window.print can't work in node-webkit - node-webkit

I hava a web project with express. when I convert the project to node-webkit use package.json
{
"name": "hello"
"main": "http://localhost:3001",
"node-main": "index.js",
"window": {
"toolbar": false,
"frame": true,
"width": 1170,
"height": 780
},
...
}
it can work well. but there is a button in one page, it will call window.print() on click and now it can't work in node-webkit application.
Any idea about what I am doing wrong? or are there any other solution to print the page?

Related

Why is "create" undefined for Edge extension notifications?

Running code in Edge extension throws a TypeError, unable to get property 'create' of undefined or null reference.
I have tried running it in both the popup and background scripts. I have the notifications permissions in the manifest. I did see that some APIs require being run in the content script, but since I'm not engaging the tabs or web pages, I don't think that applies to me...?
Manifest:
{
"name": "xxx",
"author": "xxx", "version": "1.1",
"options_page": "options.html",
"background": {
"scripts": ["jquery-3.3.1.min.js","background.js"], "persistent": true
},
"permissions": [
"xxx",
"background",
"notifications",
"storage"
],
"offline_enabled": true,
"browser_action": {
"default_title": "xxx",
"default_popup": "popup.html",
"default_icon": "32.png"
},
"manifest_version": 2
}
Background script:
try{
browser.notifications.create("test",{
"type": "basic",
"title": "Test",
"iconUrl": "48.png",
"message": "This is a test"
});
}catch(e){
alert(e);
}
Based on your description, first, you could try to upgrade the Edge browser to the latest version, then, try to use the browser.notifications.create method.
But, in my opinion, I prefer to display the notification using the Web Notifications API, you could check this article.

There is no 'package.json' - node-webkit app

I'm making my first desktop application using node-webkit.
I followed all the steps to package the app on windows but I'm getting this error:
There is no 'package.json' in the package, please make sure the 'package.json' is in the root of the package.
Although the package is in the root.
sample package.json file
{
"name": "name of app",
"version": "1.0.0",
"main": "index.html",
"single-instance": true,
"node-remote": "<local>",
"window": {
"title": "name to show in title bar",
"icon": "icon to show in titlebar",
"position": "center",
"min_width": 1024,
"min_height": 600,
"toolbar": true,
"width": 1362,
"height": 768
},
"dependencies": {
"express": "3.x"
},
"webkit": {
"plugin": true
}
}
Ok I found my mistake. In fact, I was compressing the folder containing the package json and the other files. So what I made was like that:
App.zip
|
|-App
|-package.json
|-Other files
What is correct is this:
App.zip
|-package.json
|-Other files

node webkit app-view permissions

I have a backbone web app and everything works fine in my browser. Now I want to make a .exe with Node webkit.
This is my package.json file:
{
"name": "XXXX",
"main": "index.html",
"window": {
"toolbar": true,
"width": 800,
"height": 600
},
"single-instance": false,
"version": "1alpha",
"private": true
}
but when I execute the program I obtain these message in the js console:
You do not have permission to use the appview element. Be sure to declare the 'appview' permission in your manifest file and use the --enable-app-view command line flag.
I've been how to fix it here but I didn't find any solution.
Any idea? thanks
I have find any partial solution. If a change the main option to:
"main": "http://localhost:8000",
it works perfectly, but I need to start a little web server before and I don't want to do that. Any idea?

Having trouble packaging node webkit app

I wrote a small app in node webkit, and am having trouble packaging it. My eventual goal is to have a .exe that I can give to other people.
I can run it from the command line with "nodewebkit".
I've tried zipping the files and saving the result as app.nw, but when I try to run that I just get the default node webkit screen. I've read through the docs on rogerwang github, but haven't gotten anywhere because I can't get through that first step.
The app consists of a few files: index.html, main.js, styles.css. It depends on a few node modules as well as jquery. The package.json file is pasted below... any suggestions would be much appreciated.
{
"name": "spl",
"version": "0.0.0",
"description": "",
"keywords": [],
"main": "index.html",
"homepage": "https://github.com/lpappone/spl",
"bugs": "https://github.com/lpappone/spl/issues",
"window": {
"title": "Splitter",
"toolbar": false,
"frame": true,
"width": 800,
"height": 500
},
"author": {
"name": "Lauren Pappone",
"email": "",
"url": "https://github.com/lpappone"
},
"repository": {
"type": "git",
"url": "git://github.com/lpappone/spl.git"
},
"dependencies": {
"fast-csv": "^0.5.3",
"recursive-readdir": "^1.2.0"
},
"devDependencies": {},
"engines": {
"node": ">=0.8.0"
}
}
The directory structure looks like this, and when I inspect the contents of the .nw, it is exactly the same:
You seem to be doing this on a Mac, so I'll cover that. Windows and Linux are slightly more complicated because they don't have App Bundles the way Mac OSX does.
Are you copying your app.nw to the right place? Are you sure you're including everything in app.nw?
Is this what you're doing?:
First you need to create app.nw, which is just a zip file of your entire project. If you go to your project dir (the one containing package.json) you can do this by typing
zip -r ../app.nw .
Now create a copy of node-webkit.app and copy app.nw into node-webkit.app/Contents/Resources/
cp app.nw node-webkit.app/Contents/Resources/
You should be able to run node-webkit.app now and it should run your app. (You might have some issues with security settings and such)
See https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps#mac-os-x for further details.

IE styling in Sencha Touch

When I load the default ST app in IE10, styling is non-existant even with the following defined in app.json:
If I load in Chrome, the styling is present. I have carried out an app refresh too.
I'm using ST2.3.1 with cmd 4
"css": [
{
"path": "resources/css/app.css",
"platform": ["chrome", "safari", "android", "firefox"],
"theme": "Default",
"update": "delta"
},
{
"path": "resources/css/wp.css",
"platform": ["ie10"],
"theme": "Default",
"update": "delta"
}
If I look in myapp\resources\css I can see app.css and wp.css.
Looking at the Sencha theming guide, you may need to change "theme" from "Default" to "Windows" in your second JSON object. Then do a sencha app refresh and try again.