-
-
Save shalaby/34f071830cf6d9e86f80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Node-WebKit CheatSheet | |
# Download: https://github.com/rogerwang/node-webkit#downloads | |
# Old Versions: https://github.com/rogerwang/node-webkit/wiki/Downloads-of-old-versions | |
# Wiki: https://github.com/rogerwang/node-webkit/wiki | |
# How: https://github.com/rogerwang/node-webkit/wiki/How-node.js-is-integrated-with-chromium | |
# 1. Run your application. | |
# https://github.com/rogerwang/node-webkit/wiki/How-to-run-apps | |
# Compress your application including index.html and package.json into a zip archive and rename it to app.nw | |
./nw path_to_app.nw | |
# Or run the directory including your application | |
./nw path_to_app_dir | |
# Only on Mac OSX, you can also use nw like this. (assuming it's installed to the Applications directory) | |
open -n -a node-webkit "/home/path/to/app" | |
# 2. Package your application. | |
# https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps | |
# Windows: Making an executable file out of a .nw file. | |
copy /b nw.exe+app.nw app.exe | |
# Linux: Making an executable file out of a .nw file. | |
cat /usr/bin/nw app.nw > app && chmod +x app | |
# Max OSX: Making an executable file out of a .nw file. | |
# https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps#mac-os-x | |
# 3. Command Lines Switches. | |
# https://github.com/rogerwang/node-webkit/wiki/Command-line-switches#--urlwebsite-url | |
./nw path_to_app_dir --url="website-url" # Directly open "website-url". | |
./nw path_to_app_dir --no-toolbar # Force disabling toolbar. | |
./nw path_to_app_dir --data-path # Override the default data path (where cookies and localStorage etc. resides). | |
# 4. Compile to Native Code and Protect JavaScript Source Code. | |
# https://github.com/rogerwang/node-webkit/wiki/Protect-JavaScript-source-code-with-v8-snapshot | |
nwsnapshot --extra_code source.js snapshot.bin # JS source code is compiled to native code (aka. 'snapshot'). | |
# Then, add the following field to package.json: "snapshot" : "snapshot.bin" | |
# 5. Application Auto Building Scripts for Linux Windows and OSX. | |
# https://github.com/rogerwang/node-webkit/wiki/Application-auto-building-scripts-for-Linux-Windows-and-OSX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Native UI Library. | |
// Do: | |
// - One thing you may not notice is after deleting objects, you should always assign null to a deleted UI object, in case you accidentally reuse it. | |
// Don'ts: | |
// - Do not recreate UI elements, reuse them. | |
// - Do not reassign an element, such as `menu.items[0] = item` or `item = new gui.MenuItem({})`. | |
// - Do not delete an element, such `delete item`. | |
// - Do not change UI types' prototype. | |
// Load native UI library | |
// or global.window.nwDispatcher.requireNwGui() | |
var gui = require('nw.gui'); | |
// 1.1. Window. | |
// https://github.com/rogerwang/node-webkit/wiki/Window | |
// See also Frameless Window: https://github.com/rogerwang/node-webkit/wiki/Frameless-window | |
var win = gui.Window.get([window_object]); // If window_object is not specifed, then return current window's Window object, otherwise return window_object's Window object. | |
var win = gui.Window.open(url[, options]); // Open a new window and load url in it, you can specify extra options with the window. All window subfields in Manifest format can be used. | |
win.window; // Get DOM's window object in the native window. | |
win.x; // Get or Set left/top offset from window to screen. | |
win.y; // Get or Set left/top offset from window to screen. | |
win.width; // Get or Set window's size. | |
win.height; // Get or Set window's size. | |
win.title; // Get or Set window's title. | |
win.menu; // Get or Set window's menubar. Set with a Menu with type menubar. | |
win.isFullScreen; // Get or Set whether we're in fullscreen mode. | |
win.isKioskMode; // Get or Set whether we're in kiosk mode. | |
win.zoomLevel; // Get or Set the page zoom. 0 for normal size; positive value for zooming in; negative value for zooming out. | |
win.moveTo(x, y); // Moves a window's left and top edge to the specified coordinates. | |
win.moveBy(x, y); // Moves a window a specified number of pixels relative to its current coordinates. | |
win.resizeTo(width, height); // Resizes a window to the specified width and height. | |
win.resizeBy(width, height); // Resizes a window by the specified amount. | |
win.focus(); // Focus on the window. | |
win.blur(); // Move focus away. Usually it will move focus to other windows of your app, since on some platforms there is no concept of blur. | |
win.show(); // Show the window if it's not showed, show will not focus on the window on some platforms, so you need to call focus if you want to. show(false) has the same effect with hide(). | |
win.hide(); // Hide the window. Users will not be able to find the window if it's hidden. | |
win.close([force]); // Close current window, you can catch the close event to prevent the closing. If force is specified and equals to true, then the close event will be ignored. | |
win.reload(); // Reloads the current window. | |
win.reloadIgnoringCache(); // Like reload(), but don't use caches (aka "shift-reload"). | |
win.maximize(); // Maximize the window on GTK and Windows, zoom the window on Mac. | |
win.unmaximize(); // Unmaximize the window, e.g. the reverse of maximize(). | |
win.minimize(); // Minimize the window to taskbar on Windows, iconify the window on GTK, and miniaturize the window on Mac. | |
win.restore(); // Restore window to previous state after the window is minimized, e.g. the reverse of minimize(). It's not named unminimize since restore is already used commonly on Window. | |
win.enterFullscreen(); // Make the window fullscreen. This function is different with HTML5 FullScreen API, which can make part of the page fullscreen, Window.enterFullscreen() will only fullscreen the whole window. | |
win.leaveFullscreen(); // Leave the fullscreen mode. | |
win.toggleFullscreen(); // Toggle the fullscreen mode. | |
win.enterKioskMode(); // Enter the Kiosk mode. In Kiosk mode, the app will be fullscreen and try to prevent users from leaving the app, so you should remember to provide a way in app to leave Kiosk mode. This mode is mainly used for presentation on public displays. | |
win.leaveKioskMode(); // Leave the Kiosk mode. | |
win.toggleKioskMode(); // Toggle the kiosk mode. | |
win.showDevTools([id | iframe, headless]); // Open the devtools to inspect the window. | |
win.closeDevTools(); // Close the devtools window. | |
win.isDevToolsOpen(); // Query the status of devtools window. | |
win.setMaximumSize(width, height); // Set window's maximum size. | |
win.setMinimumSize(width, height); // Set window's minimum size. | |
win.setResizable(Boolean resizable); // Set whether window is resizable. | |
win.setAlwaysOnTop(Boolean top); // Sets the widget to be on top of all other windows in the windowing system. | |
win.setPosition(String position); // Shortcut to move window to specified position. Currently only center is supported on all platforms, which will put window in the middle of the screen. | |
win.setShowInTaskbar(Boolean show); // Control whether to show window in taskbar or dock. | |
win.requestAttention(Boolean attention); // Pass true to indicate that the window needs user's action, pass false to cancel it. The final behaviour depends on the platform. | |
win.setBadgeLabel(label); // Windows and OSX only. Set the badge label on the window icon in taskbar or dock. | |
win.cookies.*; // This includes multiple functions to manipulate the cookies. The API is defined in the same way as Chrome Extensions'. node-webkit supports the get, getAll, remove and set methods; onChanged event (supporting both addListener and removeListener function on this event). | |
win.eval(frame, script); // Execute a piece of JavaScript in the window, if frame argument is null, or in the context of an iframe, if frame is an iframe object. The script argument is the content of the JavaScript source code. | |
win.capturePage(callback [,image_format|config_object]); // Captures the visible area of the window. More: https://gist.github.com/zhchbin/4749217 | |
win.on('close', cb); // The close event is a special event that will affect the result of the Window.close() function. | |
win.on('closed', cb); // The closed event is emitted after corresponding window is closed. | |
win.on('loading', cb); // Emitted when the window starts to reload, normally you cannot catch this event because usually it's emitted before you actually setup the callback. The only situation that you can catch this event is when you refresh the window and listen to this event in another window. | |
win.on('loaded', cb); // Emitted when the window is fully loaded, this event behaves the same with window.onload, but doesn't rely on the DOM. | |
win.on('document-start', cb); // Emitted when the document object in this window or a child iframe is available, after any files from css, but before any other DOM is constructed or any other script is run; | |
win.on('document-end', cb); // Emitted when the document object in this window or a child iframe is loaded, before the onload event is emitted. | |
win.on('focus', cb); // Emitted when window gets focus. | |
win.on('blur', cb); // Emitted when window loses focus. | |
win.on('minimize', cb); // Emitted when window is minimized. | |
win.on('restore', cb); // Emitted when window is restored from minimize state. | |
win.on('maximize', cb); // Emitted when window is maximized. | |
win.on('unmaximize', cb); // Emitted when window is restored from maximize state. Note that on some platforms window can be resized even when maximized, so the unmaximize may not be emitted when a maximized window is resized instead of being unmaximized | |
win.on('move', cb); // Emitted after window is moved. The callback is called with 2 arguments: (x, y) for the new location of the upper-left corner of the window. | |
win.on('resize', cb); // Emitted after window is resized. The callback is called with 2 arguments: (width, height) for the new size of the window. | |
win.on('enter-fullscreen', cb); // Emitted when window enters fullscreen state. | |
win.on('leave-fullscreen', cb); // Emitted when window leaves fullscreen state. | |
win.on('zoom', cb); // Emitted when window zooming changed. It has a parameter indicating the new zoom level. See Window.zoom for the parameter's value definition. | |
win.on('capturepagedone', cb); // Emitted after the capturePage method is called and image data is ready. See Window.capturePage's callback function for the parameter's value definition. | |
win.on('devtools-opened', cb); // Emitted after Devtools is opened by any means (since v0.8.0), or ready after calling Window.showDevTools(id, headless) with headless = true. | |
win.on('devtools-closed', cb); // Emitted after Devtools is closed. | |
win.on('new-win-policy', cb); // Emitted when a new window is requested from this window or a child iframe, e.g. user clicks a link with _blank target. | |
// 1.2. Menu. | |
// https://github.com/rogerwang/node-webkit/wiki/Menu | |
var menu = new gui.Menu([option]); // Create a new Menu. If no option is specified, a normal context menu will be created. To create a menu to be used as window's menu, you need to explicitly specify 'type': 'menubar' in the option, e.g. new Menu({ 'type': 'menubar' }). | |
gui.Window.get().menu = menu; // Then you can set the window menu by setting the menu property of the window. | |
menu.items; // Get an array that contains all items of a menu. | |
menu.items.length; // Get how many items this Menu has. | |
menu.items[i]; // Get the ith menu item of the Menu. It will return a MenuItem object. | |
menu.item[x].click; // Reference: x is the index of the menu object. | |
menu.append(MenuItem item); // Append item of MenuItem type to the tail of the Menu. | |
menu.insert(MenuItem item, int i); // Insert item of MenuItem type to the ith position of the Menu, Menu is 0-indexed. | |
menu.remove(MenuItem item); // Remove item from Menu. This method requires you to keep the MenuItem outside the Menu. | |
menu.removeAt(int i); // Remove the ith item form Menu. | |
menu.popup(int x, int y); // Popup the Menu at position (x, y) in current window. Usually you would listen to contextmenu event of DOM elements and manually popup the menu. | |
menu.createMacBuiltin(appname); // OSX only. Create the default menus (App, Edit and Windows). Later the items can be manipulated with the items property. The argument appname is use for the title of App menu. | |
// 1.3. Menu Item. | |
// https://github.com/rogerwang/node-webkit/wiki/MenuItem | |
// MenuItem represents an item in a menu. A MenuItem can be a separator or a normal item which has label and icon. | |
// MenuItem is usually used with Menu together. | |
var menuItem = new gui.MenuItem({ // Create new MenuItem. | |
type: "normal", // Can also be "separator", "checkbox". A MenuItem's type can be set only when you create it, it cannot be changed at runtime. | |
label: "I'm a menu item", // Label of the MenuItem. It can only be plain text for now. | |
icon: "img/icon.png" // Icon of the MenuItem. It can be a relative path which points to an icon in your app, or an absolute path pointing to a file in user's system. | |
tooltip: "Hey!" // Tooltip of the MenuItem. A tooltip is short string that describes the menu item, it will show when you hover your mouse on the item. | |
checked: false, // Whether the MenuItem is checked. Usually if a MenuItem is checked, there will be a mark on the left side of it. It's used mostly to indicate whether an option is on. | |
enabled: true, // Whether the MenuItem is enabled. An disabled MenuItem will be greyed out and you will not be able to click on it. | |
key: "s", // A single character string to specify the shortcut key for the menu item. | |
submenu: null, // Submenu of a MenuItem, the submenu must be a Menu object. | |
modifiers: "ctrl-alt", | |
click: function() { // Emitted when user activates the menu item. | |
console.log('clicked!'); | |
}, | |
}); | |
menuItem.type; // Get the type of a MenuItem, it can be separator, checkbox and normal for now. A MenuItem's type can be set only when you create it, it cannot be changed at runtime. | |
menuItem.label; // Get or Set the label of a MenuItem, it can only be plain text for now. | |
menuItem.icon; // Get or Set the icon of a MenuItem, it must a path to your icon file. It can be a relative path which points to an icon in your app, or an absolute path pointing to a file in user's system. | |
menuItem.tooltip; // Get or Set the tooltip of a MenuItem, it can only be plain text. A tooltip is short string that describes the menu item, it will show when you hover your mouse on the item. | |
menuItem.checked; // Get or Set whether the MenuItem is checked. Usually if a MenuItem is checked, there will be a mark on the left side of it. It's used mostly to indicate whether an option is on. | |
menuItem.enabled; // Get or Set whether the MenuItem is enabled. An disabled MenuItem will be greyed out and you will not be able to click on it. | |
menuItem.submenu; // Get or Set the submenu of a MenuItem, the submenu must be a Menu object. Developers had better set submenu in the option when creating the MenuItem, changing it at runtime is slow on some platforms. | |
menuItem.click; // Get or Set the click callback of a MenuItem, the click must be a valid function, it will be called when users activate the item. | |
menuItem.key; // A single character string to specify the shortcut key for the menu item. | |
menuItem.modifiers; // A string to specify the modifier keys for the shortcut of the menu item. e.g. "cmd-shift". It should be the concatenation of the following strings: cmd, shift, ctrl, alt. | |
menuItem.on('click', function() { }); // Emitted when user activates the menu item. | |
// 1.4. App. | |
// https://github.com/rogerwang/node-webkit/wiki/App | |
gui.App.argv; // Get the command line arguments when starting the app. | |
gui.App.fullArgv; // Get all the command line arguments when starting the app. Because node-webkit itself used switches like --no-sandbox and --process-per-tab, it would confuse the app when the switches were meant to be given to node-webkit, so App.argv just filtered such switches (arguments' precedence were kept). | |
gui.App.dataPath; // Get the application's data path in user's directory. Windows: %LOCALAPPDATA%/<name>; Linux: ~/.config/<name>; OSX: ~/Library/Application Support/<name> where <name> is the field in the manifest. | |
gui.App.manifest; // Get the JSON object of the manifest file. | |
gui.App.clearCache(); // Clear the HTTP cache in memory and the one on disk. This method call is synchronized. | |
gui.App.closeAllWindows(); // Send the close event to all windows of current app, if no window is blocking the close event, then the app will quit after all windows have done shutdown. Use this method to quit an app will give windows a chance to save data. | |
gui.AppcrashBrowser(); // These 2 functions crashes the browser process and the renderer process respectively, to test the Crash dump feature. | |
gui.App.crashRenderer(); // These 2 functions crashes the browser process and the renderer process respectively, to test the Crash dump feature. | |
gui.App.getProxyForURL(url); // Query the proxy to be used for loading url in DOM. The return value is in the same format used in PAC (e.g. "DIRECT", "PROXY localhost:8080"). | |
gui.App.quit(); // Quit current app. This method will not send close event to windows and app will just quit quietly. | |
gui.App.setCrashDumpDir(dir); // Set the directory where the minidump file will be saved on crash. For more information, see Crash dump. | |
gui.App.addOriginAccessWhitelistEntry(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); // Add an entry to the whitelist used for controlling cross-origin access. | |
gui.App.removeOriginAccessWhitelistEntry(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); // Remove an entry from the whitelist used for controlling cross-origin access. See addOriginAccessWhitelistEntry above. | |
gui.App.on('open', function() { }); // Emitted when users opened a file with your app. There is a single parameter of this event callback: Since v0.7.0, it is the full command line of the program; before that it's the argument in the command line and the event is sent multiple times for each of the arguments. | |
gui.App.on('reopen', function() { }); // This is a Mac specific feature. This event is sent when the user clicks the dock icon for an already running application. | |
// 1.5. Clipboard. | |
// https://github.com/rogerwang/node-webkit/wiki/Clipboard | |
var clipboard = gui.Clipboard.get(); // We can not create a clipboard, we have to receive the system clipboard | |
clipboard.set('I love node!', 'text'); // Write data to the clipboard. type specifies the mime type of the data, only text (plain text data) is supported now. | |
clipboard.get([type]); // Returns the data of type from clipboard. Only text (plain text data) is supported now. | |
clipboard.clear(); // Clear the clipboard. | |
// 1.6. Tray. | |
// https://github.com/rogerwang/node-webkit/wiki/Tray | |
// See also: Minimize to tray. | |
// https://github.com/rogerwang/node-webkit/wiki/Minimize-to-tray | |
var tray = new gui.Tray({ // Create a new Tray, option is an object contains initial settings for the Tray. | |
title: 'Tray', // On Mac title will be showed on status bar along with its icon, but it doesn't have effects on GTK and Windows, since the latter two platforms only support tray to be showed as icons. | |
tooltip: 'Hey!', // Get or Set the tooltip of Tray. tooltip shows when you hover the Tray with mouse. Tooltip is showed on all three platforms. | |
icon: 'img/icon.png', // Get or Set the icon of Tray, icon must a path to your icon file. It can be a relative path which points to an icon in your app, or an absolute path pointing to a file in user's system. | |
menu: null, // Get or Set the menu of Tray, menu will be showed when you click on the Tray icon. | |
}); | |
tray.title; // Get or Set the title of Tray. | |
tray.tooltip; // Get or Set the tooltip of Tray. tooltip shows when you hover the Tray with mouse. | |
tray.icon; // Get or Set the icon of Tray, icon must a path to your icon file. It can be a relative path which points to an icon in your app, or an absolute path pointing to a file in user's system. | |
tray.alticon; // Get or Set the alternate (active) tray icon for Mac. It has no effects on Linux and Win. | |
tray.menu; // Get or Set the menu of Tray, menu will be showed when you click on the Tray icon. | |
tray.remove(); // Remove the tray. Once removed, you will not be able to show it again and you should set your tray variable to null. There is no way temporarily hide a tray icon. | |
tray.on('click', function() { }); // Emitted when user clicks the menu item with left mouse button. | |
// 1.7. Shell. | |
// https://github.com/rogerwang/node-webkit/wiki/Shell | |
gui.Shell.openExternal(URI); // Open the given external protocol URI in the desktop's default manner. (For example, mailto: URLs in the default mail user agent.) | |
gui.Shell.openItem(file_path); // Open the given file_path in the desktop's default manner. | |
gui.Shell.showItemInFolder(file_path); // Show the given file_path in a file manager. If possible, select the file. | |
// 1.8. Process. | |
// https://github.com/rogerwang/node-webkit/wiki/Changes-related-to-node | |
process.versions['node-webkit']; // Get version of node webkit in app. And to quickly know the node-webkit's version you are using now, you can type nw:version in the toolbar. | |
process.versions['chromium']; // Get the chromium version which node-webkit is based on. | |
process.mainModule; // Get the start page (such as index.html) as specified in the manifest. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Node-Webkit Tricks. | |
// 1. Router. | |
// You don't need a router in node-webkit, because you already have a better one: the file: protocol. | |
// More: https://github.com/rogerwang/node-webkit/wiki/about-node.js-server-side-script-in-node-webkit#router | |
// However the recommended way is not opening a new window or changing the `window.location`, you should just replace part of your page with ajax, like below. | |
// In this way users won't have bad experience feeling refreshing the page, and the current javascript context is also kept. | |
$('#main').load('views/user.html#zcbenz'); | |
// 2. Template Engine. | |
// The basic idea is: use the template engine to generate contents on the fly, and then append dynamic contents into the DOM. | |
// More: https://github.com/rogerwang/node-webkit/wiki/about-node.js-server-side-script-in-node-webkit#template-engine | |
// 3. Global Variable. | |
// The `global` variable is also useful for apps that have multiple windows. | |
// Every opened window will share a same `global`, so you can use it to transfer messages across different windows. | |
// More: https://github.com/rogerwang/node-webkit/wiki/about-node.js-server-side-script-in-node-webkit#page-navigation-and-multiple-windows | |
// 4. Livereload Node-Webkit on Changes. | |
// https://github.com/rogerwang/node-webkit/wiki/Livereload-node-webkit-on-changes | |
// Add this script tag to the end of your main file: | |
var path = './'; | |
var fs = require('fs'); | |
fs.watch(path, function() { | |
if (location) | |
location.reload(); | |
}); | |
// 5. Play with Window. | |
// https://github.com/rogerwang/node-webkit/wiki/Play-with-window | |
window.open(URL,name,specs); // Create a new window. | |
window.close(); // Close a window. | |
window.focus(); // Focus on a window. | |
window.blur(); // Blur on a window. | |
window.resizeTo(width,height); // Resizes a window to the specified width and height. | |
window.resizeBy(width,height); // Resizes a window by the specified amount. | |
window.moveTo(x,y); // Moves a window's left and top edge to the specified coordinates. | |
window.moveBy(x,y); // Moves a window a specified number of pixels relative to its current coordinates. | |
// 6. Save Persistent Data in App. | |
// It's very common to store persistent data in native apps, people usually do it by embedding external databases or manipulating plain text files. | |
// In node-webkit, you have much better choices than that, you can use Web SQL Database, embedded databases, Web Storage (localStorage and sessionStorage) or Application Cache without headaches of any extra dependencies. | |
// https://github.com/rogerwang/node-webkit/wiki/Save-persistent-data-in-app | |
// 6.1. Web SQL Database. | |
// http://html5doctor.com/introducing-web-sql-databases/ | |
// 6.2. IndexedDB. (you might prefer using an abstraction, like PouchDB) | |
// https://developer.mozilla.org/en-US/docs/IndexedDB | |
// 6.3. PouchDB. | |
// http://pouchdb.com/ | |
// 6.4. EJDB. | |
// https://github.com/Softmotions/ejdb | |
// 6.5. NeDB. | |
// https://github.com/louischatriot/nedb | |
// 7. Crash Dump. | |
// https://github.com/rogerwang/node-webkit/wiki/Crash-dump | |
// 8. Transfer Objects Between Window and Node. | |
// https://github.com/rogerwang/node-webkit/wiki/Transfer-objects-between-window-and-node | |
// 9. Building Node-Webkit. | |
// https://github.com/rogerwang/node-webkit/wiki/Building-node-webkit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Manifest Format | |
// Every app package should contain a manifest file named package.json, | |
// it will tell node-webkit how to open the app and control how the browser behaves. | |
// package.json should be written in the format of JSON. | |
// https://github.com/rogerwang/node-webkit/wiki/Manifest-format | |
{ | |
"main": "index.html", // required: (string) which page should be opened when node-webkit starts. | |
"name": "nw-demo", // required: (string) the name of the package. This must be a unique, lowercase alpha-numeric name without spaces. It may include "." or "_" or "-" characters. It is otherwise opaque.name should be globally unique since node-webkit will store app's data under the directory named name. | |
"chromium-args": "", // (string) Specify chromium (content shell) command line arguments. It will be useful if you want to distribute the app with some custom chromium args. | |
"description": "my node-webkit app", // (string) a brief description of the package. By convention, the first sentence (up to the first ". ") should be usable as a package title in listings. | |
"dom_storage_quota": 524288, // (int) Number of mega bytes for the quota of the DOM storage. The suggestion is to put double the value you want. | |
"inject-js-start": "", // (string) a local filename, relative to the application path, used to specify a JavaScript file to inject to the window. inject-js-start: The injecting JavaScript code is to be executed after any files from css, but before any other DOM is constructed or any other script is run. | |
"inject-js-end": "", // (string) a local filename, relative to the application path, used to specify a JavaScript file to inject to the window.inject-js-end: The injecting JavaScript code is to be executed after the document object is loaded, before onload event is fired. | |
"js-flags": "", // (string) Specify the flags passed to JS engine(v8). e.g. turn on Harmony Proxies and Collections feature. | |
"no-edit-menu": false, // (boolean) whether the default Edit menu should be disabled on Mac. The default value is false. Only effective on Mac. | |
"node": true, // (boolean) set nodejs to false will disable Node support in WebKit. | |
"node-main": "script.js", // (string) specify the path to a node.js script file, it will be executed on startup in Node context. | |
"node-remote": "", // (string) Enable calling Node in remote pages. The value controls for which sites this feature should be turned on. The format is the same with the "proxy bypass rules" of the browser. | |
"snapshot": "", // (string) Specify the path to the snapshot file to be loaded with the application. The snapshot file contains compiled code of your application. | |
"single-instance": true, // (boolean) by default node-webkit only allows one instance of your app if your app is a standalone package, if you want to allow multiple instances of your app running at the same time, specify this to false. | |
"user-agent": "Mozilla/5.0 ...", // (string) Override the User-Agent header in HTTP requests made from the application. | |
"version": "0.1.0", // (string) a version string conforming to the Semantic Versioning requirements. | |
"keywords": [ "demo", "node-webkit" ], // (array) an Array of string keywords to assist users searching for the package in catalogs. | |
"maintainers": [{ // (array) an Array of maintainers of the package. Each maintainer is a hash which must have a "name" property and may optionally provide "email" and "web" properties. | |
"name": "Julien Le Coupanec", | |
"email": "[email protected]", | |
"web": "https://gentlenode.com", | |
}], | |
"contributors": [{ // (array) an Array of hashes each containing the details of a contributor. Format is the same as for author. By convention, the first contributor is the original author of the package. | |
"name": "Bill Bloggs", | |
"email": "[email protected]", | |
"web": "http://www.bblogmedia.com", | |
}], | |
"bugs": "https://gentlenode.com/bugs", // (string) URL for submitting bugs. Can be mailto or http. | |
"licenses": [{ // (array) an Array of licenses under which the package is provided. Each license is a hash with a "type" property specifying the type of license and a url property linking to the actual text. If the license is one of the official open source licenses the official license name or its abbreviation may be explicated with the "type" property. If an abbreviation is provided (in parentheses), the abbreviation must be used. | |
"type": "GPLv2", | |
"url": "http://www.example.com/licenses/gpl.html", | |
}], | |
"repositories": [{ // (array) an Array of repositories where the package can be located. Each repository is a hash with properties for the "type" and "url" location of the repository to clone/checkout the package. A "path" property may also be specified to locate the package in the repository if it does not reside at the root. | |
"type": "git", | |
"url": "http://github.com/example.git", | |
"path": "packages/mypackage" | |
}], | |
"window": { // (object) controls how the main window looks. | |
"title": "My Node-Webkit App", // (string) the default title of window created by node-webkit, it's very useful if you want to show your own title when the app is starting. | |
"icon": "link.png", // (string) path to window's icon. | |
"toolbar": true, // (boolean) should the navigation toolbar be showed. | |
"frame": false, // boolean) specify it to false to make the window frameless. | |
"width": 800, // (int) the initial width of the main window. | |
"height": 500, // (int) the initial height of the main window. | |
"position": "mouse", // (string) be null or center or mouse, controls where window will be put. | |
"min_width": 400, // (int) minimum width of window. | |
"min_height": 200, // (int) minimum height of window. | |
"max_width": 800, // (int) maximum width of window. | |
"max_height": 600, // (int) maximum height of window. | |
"as_desktop": false, // (boolean) show as desktop background window under X11 environment. | |
"always-on-top": true, // (boolean) whether the window should always stay on top of other windows. | |
"kiosk": false, // (boolean) whether to use Kiosk mode. In Kiosk mode, the app will be fullscreen and try to prevent users from leaving the app, so you should remember to provide a way in app to leave Kiosk mode. This mode is mainly used for presentation on public displays. | |
"fullscreen": false, // (boolean) whether window is fullscreen. | |
"show": true, // (boolean) specify it to false if you want your app to be hidden on startup. | |
"show_in_taskbar": true, // (boolean) whether the window is shown in taskbar or dock. The default is true. | |
"resizable": true // (boolean) whether window is resizable. | |
}, | |
"webkit": { // (object) controls what features of WebKit should be on/off. | |
"plugin": false, // (boolean) whether to load external browser plugins like Flash, default to false. | |
"java": false, // (boolean) whether to load Java applets, default to false. | |
"page-cache": false // (boolean) whether to enable page cache, default to false. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment