]> khamidou — GitHub mirrors - electron.git/commitdiff
docs: Update codes in docs to use require('electron')
authorCheng Zhao <zcbenz@gmail.com>
Thu, 12 Nov 2015 13:20:09 +0000 (21:20 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 12 Nov 2015 13:20:09 +0000 (21:20 +0800)
32 files changed:
docs/README.md
docs/api/app.md
docs/api/browser-window.md
docs/api/chrome-command-line-switches.md
docs/api/clipboard.md
docs/api/content-tracing.md
docs/api/crash-reporter.md
docs/api/dialog.md
docs/api/frameless-window.md
docs/api/global-shortcut.md
docs/api/ipc-main.md
docs/api/menu.md
docs/api/native-image.md
docs/api/power-monitor.md
docs/api/power-save-blocker.md
docs/api/protocol.md
docs/api/remote.md
docs/api/screen.md
docs/api/session.md
docs/api/shell.md
docs/api/synopsis.md
docs/api/tray.md
docs/api/web-contents.md
docs/api/web-frame.md
docs/api/web-view-tag.md
docs/tutorial/application-packaging.md
docs/tutorial/desktop-environment-integration.md
docs/tutorial/devtools-extension.md
docs/tutorial/online-offline-events.md
docs/tutorial/quick-start.md
docs/tutorial/using-pepper-flash-plugin.md
docs/tutorial/using-selenium-and-webdriver.md

index fb5c64a8f17e055139601f507c9638d59cf6f252..208ff8bf47b642b3f0de5f8d18f851408deb389b 100644 (file)
 ### Modules for the Main Process:
 
 * [app](api/app.md)
-* [auto-updater](api/auto-updater.md)
-* [browser-window](api/browser-window.md)
-* [content-tracing](api/content-tracing.md)
+* [autoUpdater](api/auto-updater.md)
+* [BrowserWindow](api/browser-window.md)
+* [contentTracing](api/content-tracing.md)
 * [dialog](api/dialog.md)
-* [global-shortcut](api/global-shortcut.md)
-* [ipc-main](api/ipc-main.md)
-* [menu](api/menu.md)
-* [menu-item](api/menu-item.md)
-* [power-monitor](api/power-monitor.md)
-* [power-save-blocker](api/power-save-blocker.md)
+* [globalShortcut](api/global-shortcut.md)
+* [ipcMain](api/ipc-main.md)
+* [Menu](api/menu.md)
+* [MenuItem](api/menu-item.md)
+* [powerMonitor](api/power-monitor.md)
+* [powerSaveBlocker](api/power-save-blocker.md)
 * [protocol](api/protocol.md)
 * [session](api/session.md)
-* [web-contents](api/web-contents.md)
-* [tray](api/tray.md)
+* [webContents](api/web-contents.md)
+* [Tray](api/tray.md)
 
 ### Modules for the Renderer Process (Web Page):
 
-* [ipc-renderer](api/ipc-renderer.md)
+* [ipcRenderer](api/ipc-renderer.md)
 * [remote](api/remote.md)
-* [web-frame](api/web-frame.md)
+* [webFrame](api/web-frame.md)
 
 ### Modules for Both Processes:
 
 * [clipboard](api/clipboard.md)
-* [crash-reporter](api/crash-reporter.md)
-* [native-image](api/native-image.md)
+* [crashReporter](api/crash-reporter.md)
+* [nativeImage](api/native-image.md)
 * [screen](api/screen.md)
 * [shell](api/shell.md)
 
index fdb9f9980592df9e36d591597c9a21df744d3de0..1edc40fb89ae57418f4792d8d2f0d08f4725086f 100644 (file)
@@ -6,7 +6,7 @@ The following example shows how to quit the application when the last window is
 closed:
 
 ```javascript
-var app = require('app');
+const app = require('electron').app;
 app.on('window-all-closed', function() {
   app.quit();
 });
index 0499b6355a0059300c93b1647769f7d31063d306..670c814c741d42e7469c96fa7d9d1d3eca5eeed5 100644 (file)
@@ -4,7 +4,7 @@ The `BrowserWindow` class gives you the ability to create a browser window. For
 example:
 
 ```javascript
-var BrowserWindow = require('browser-window');
+const BrowserWindow = require('electron').BrowserWindow;
 
 var win = new BrowserWindow({ width: 800, height: 600, show: false });
 win.on('closed', function() {
@@ -291,11 +291,8 @@ Remove the DevTools extension whose name is `name`.
 Objects created with `new BrowserWindow` have the following properties:
 
 ```javascript
-var BrowserWindow = require('browser-window');
-
 // In this example `win` is our instance
 var win = new BrowserWindow({ width: 800, height: 600 });
-
 ```
 
 ### `win.webContents`
@@ -316,14 +313,6 @@ Objects created with `new BrowserWindow` have the following instance methods:
 
 **Note:** Some methods are only available on specific operating systems and are labeled as such.
 
-```javascript
-var BrowserWindow = require('browser-window');
-
-// In this example `win` is our instance
-var win = new BrowserWindow({ width: 800, height: 600 });
-
-```
-
 ### `win.destroy()`
 
 Force closing the window, the `unload` and `beforeunload` event won't be emitted
index 96dffb963135a32e381f057f66ba1bbf04a999d4..d163a726d40ec1ca6daeeb47d1672bb7d3b60d34 100644 (file)
@@ -6,7 +6,7 @@ them in your app's main script before the [ready][ready] event of [app][app]
 module is emitted:
 
 ```javascript
-var app = require('app');
+const app = require('electron').app;
 app.commandLine.appendSwitch('remote-debugging-port', '8315');
 app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1');
 
index a99605baea18ed921e7773e83fbe71c891615811..7cb5b840bc1c9ae0dc734529bf766d5a629af8a5 100644 (file)
@@ -4,7 +4,7 @@ The `clipboard` module provides methods to perform copy and paste operations.
 The following example shows how to write a string to the clipboard:
 
 ```javascript
-var clipboard = require('clipboard');
+const clipboard = require('electron').clipboard;
 clipboard.writeText('Example String');
 ```
 
@@ -12,7 +12,6 @@ On X Window systems, there is also a selection clipboard. To manipulate it
 you need to pass `selection` to each method:
 
 ```javascript
-var clipboard = require('clipboard');
 clipboard.writeText('Example String', 'selection');
 console.log(clipboard.readText('selection'));
 ```
@@ -82,7 +81,6 @@ Returns an array of supported formats for the clipboard `type`.
 Returns whether the clipboard supports the format of specified `data`.
 
 ```javascript
-var clipboard = require('clipboard');
 console.log(clipboard.has('<p>selection</p>'));
 ```
 
@@ -102,7 +100,6 @@ Reads `data` from the clipboard.
 * `type` String (optional)
 
 ```javascript
-var clipboard = require('clipboard');
 clipboard.write({text: 'test', html: "<b>test</b>"});
 ```
 Writes `data` to the clipboard.
index 2e05fc67668f5d55e38fa0f3e3b12be156668547..734e2c47cfb4aeb24d150a5355cec52d5d46de4b 100644 (file)
@@ -6,7 +6,7 @@ so you need to open `chrome://tracing/` in a Chrome browser and load the
 generated file to view the result.
 
 ```javascript
-var contentTracing = require('content-tracing');
+const contentTracing = require('electron').contentTracing;
 
 contentTracing.startRecording('*', contentTracing.DEFAULT_OPTIONS, function() {
   console.log('Tracing started');
index 64a3b2cf748d20286f9ac8ff91b57f3a95030188..8127c9bc1c93e14093529977f3a19cfbb311ea0b 100644 (file)
@@ -6,7 +6,7 @@ The following is an example of automatically submitting a crash report to a
 remote server:
 
 ```javascript
-var crashReporter = require('crash-reporter');
+const crashReporter = require('electron').crashReporter;
 
 crashReporter.start({
   productName: 'YourName',
@@ -62,7 +62,7 @@ The crash reporter will send the following data to the `submitUrl` as `POST`:
 * `ver` String - The version of Electron.
 * `platform` String - e.g. 'win32'.
 * `process_type` String - e.g. 'renderer'.
-* `guid` String - e.g. '5e1286fc-da97-479e-918b-6bfb0c3d1c72' 
+* `guid` String - e.g. '5e1286fc-da97-479e-918b-6bfb0c3d1c72'
 * `_version` String - The version in `package.json`.
 * `_productName` String - The product name in the `crashReporter` `options`
   object.
index 6acfb79884e31919056542f023aa81f5ee7586ba..884fb7c07327521bbf1d469322b156475c7b66c5 100644 (file)
@@ -8,7 +8,7 @@ An example of showing a dialog to select multiple files and directories:
 
 ```javascript
 var win = ...;  // BrowserWindow in which to show the dialog
-var dialog = require('dialog');
+const dialog = require('electron').dialog;
 console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', 'multiSelections' ]}));
 ```
 
@@ -114,6 +114,6 @@ will be passed via `callback(response)`.
 Displays a modal dialog that shows an error message.
 
 This API can be called safely before the `ready` event the `app` module emits,
-it is usually used to report errors in early stage of startup.  If called 
-before the app `ready`event on Linux, the message will be emitted to stderr, 
+it is usually used to report errors in early stage of startup.  If called
+before the app `ready`event on Linux, the message will be emitted to stderr,
 and no GUI dialog will appear.
index 707a928f9db602d4aae15e8add0ea0de98ace5a1..e70749f2894c2448ff3690a406232718bcaf90e6 100644 (file)
@@ -9,7 +9,7 @@ To create a frameless window, you need to set `frame` to `false` in
 
 
 ```javascript
-var BrowserWindow = require('browser-window');
+const BrowserWindow = require('electron').BrowserWindow;
 var win = new BrowserWindow({ width: 800, height: 600, frame: false });
 ```
 
@@ -23,8 +23,7 @@ the window controls ("traffic lights") for standard window actions.
 You can do so by specifying the new `title-bar-style` option:
 
 ```javascript
-var BrowserWindow = require('browser-window');
-var win = new BrowserWindow({ width: 800, height: 600, 'title-bar-style': 'hidden' });
+var win = new BrowserWindow({ 'title-bar-style': 'hidden' });
 ```
 
 ## Transparent window
index c9dfb194529a4485737af22669503159a90d8b78..a0f069d7f1c569ab5039d2431bc5c9c03e629dc3 100644 (file)
@@ -9,8 +9,9 @@ not have the keyboard focus. You should not use this module until the `ready`
 event of the app module is emitted.
 
 ```javascript
-var app = require('app');
-var globalShortcut = require('global-shortcut');
+const electron = require('electron');
+const app = electron.app;
+const globalShortcut = electron.globalShortcut;
 
 app.on('ready', function() {
   // Register a 'ctrl+x' shortcut listener.
index f74c70426a5c1ec86a5759f26cfd4aedadb4229e..cdbc0ce34eecfad93713547c80508791805d09f0 100644 (file)
@@ -19,7 +19,7 @@ processes:
 
 ```javascript
 // In main process.
-var ipcMain = require('ipc-main');
+const ipcMain = require('electron').ipcMain;
 ipcMain.on('asynchronous-message', function(event, arg) {
   console.log(arg);  // prints "ping"
   event.sender.send('asynchronous-reply', 'pong');
@@ -33,7 +33,7 @@ ipcMain.on('synchronous-message', function(event, arg) {
 
 ```javascript
 // In renderer process (web page).
-var ipcRenderer = require('ipc-renderer');
+const ipcRenderer = require('electron').ipcRenderer;
 console.log(ipcRenderer.sendSync('synchronous-message', 'ping')); // prints "pong"
 
 ipcRenderer.on('asynchronous-reply', function(event, arg) {
index cabd04ca855039ef7a681a46c0cc1c52a6c7952c..c947f36d4790e1d380243c2c599891b6e94f6a34 100644 (file)
@@ -16,9 +16,9 @@ the user right clicks the page:
 ```html
 <!-- index.html -->
 <script>
-var remote = require('remote');
-var Menu = remote.require('menu');
-var MenuItem = remote.require('menu-item');
+const remote = require('electron').remote;
+const Menu = remote.require('electron').Menu;
+const MenuItem = remote.require('electron').MenuItem;
 
 var menu = new Menu();
 menu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log('item 1 clicked'); } }));
@@ -136,14 +136,14 @@ var template = [
     submenu: [
       {
         label: 'Learn More',
-        click: function() { require('shell').openExternal('http://electron.atom.io') }
+        click: function() { require('electron').shell.openExternal('http://electron.atom.io') }
       },
     ]
   },
 ];
 
 if (process.platform == 'darwin') {
-  var name = require('app').getName();
+  var name = require('electron').app.getName();
   template.unshift({
     label: name,
     submenu: [
index 097a8130c2439d692fabc28a9d1f858b7afd72bc..74dc7a68fad91b7d88081facf971d33fc064bf93 100644 (file)
@@ -1,7 +1,7 @@
-# NativeImage
+# nativeImage
 
 In Electron, for the APIs that take images, you can pass either file paths or
-`NativeImage` instances. An empty image will be used when `null` is passed.
+`nativeImage` instances. An empty image will be used when `null` is passed.
 
 For example, when creating a tray or setting a window's icon, you can pass an
 image file path as a `String`:
@@ -11,10 +11,9 @@ var appIcon = new Tray('/Users/somebody/images/icon.png');
 var window = new BrowserWindow({icon: '/Users/somebody/images/window.png'});
 ```
 
-Or read the image from the clipboard which returns a `NativeImage`:
+Or read the image from the clipboard which returns a `nativeImage`:
 
 ```javascript
-var clipboard = require('clipboard');
 var image = clipboard.readImage();
 var appIcon = new Tray(image);
 ```
@@ -84,40 +83,40 @@ To mark an image as a template image, its filename should end with the word
 
 ## Methods
 
-The `NativeImage` class has the following methods:
+The `nativeImage` class has the following methods:
 
-### `NativeImage.createEmpty()`
+### `nativeImage.createEmpty()`
 
-Creates an empty `NativeImage` instance.
+Creates an empty `nativeImage` instance.
 
-### `NativeImage.createFromPath(path)`
+### `nativeImage.createFromPath(path)`
 
 * `path` String
 
-Creates a new `NativeImage` instance from a file located at `path`.
+Creates a new `nativeImage` instance from a file located at `path`.
 
-### `NativeImage.createFromBuffer(buffer[, scaleFactor])`
+### `nativeImage.createFromBuffer(buffer[, scaleFactor])`
 
 * `buffer` [Buffer][buffer]
 * `scaleFactor` Double (optional)
 
-Creates a new `NativeImage` instance from `buffer`. The default `scaleFactor` is
+Creates a new `nativeImage` instance from `buffer`. The default `scaleFactor` is
 1.0.
 
-### `NativeImage.createFromDataUrl(dataUrl)`
+### `nativeImage.createFromDataUrl(dataUrl)`
 
 * `dataUrl` String
 
-Creates a new `NativeImage` instance from `dataUrl`.
+Creates a new `nativeImage` instance from `dataUrl`.
 
 ## Instance Methods
 
 The following methods are available on instances of `nativeImage`:
 
 ```javascript
-var NativeImage = require('native-image');
+const nativeImage = require('electron').nativeImage;
 
-var image = NativeImage.createFromPath('/Users/somebody/images/icon.png');
+var image = nativeImage.createFromPath('/Users/somebody/images/icon.png');
 ```
 
 ### `image.toPng()`
index 6ffb910e164d9f533c29baa11553c436c9e84305..5313aad9c9788822fa17b89d9d7add285a1031ce 100644 (file)
@@ -1,4 +1,4 @@
-# power-monitor
+# powerMonitor
 
 The `power-monitor` module is used to monitor power state changes. You can
 only use it in the main process. You should not use this module until the `ready`
@@ -7,10 +7,8 @@ event of the `app` module is emitted.
 For example:
 
 ```javascript
-var app = require('app');
-
 app.on('ready', function() {
-  require('power-monitor').on('suspend', function() {
+  require('electron').powerMonitor.on('suspend', function() {
     console.log('The system is going to sleep');
   });
 });
index 26f0abc84808d9f32fab1d1fa4440a3df40f2d53..a3ef798411f2c38cf4a0703a0bc42b8330af3546 100644 (file)
@@ -1,13 +1,13 @@
 # powerSaveBlocker
 
-The `power-save-blocker` module is used to block the system from entering
+The `powerSaveBlocker` module is used to block the system from entering
 low-power (sleep) mode and thus allowing the app to keep the system and screen
 active.
 
 For example:
 
 ```javascript
-var powerSaveBlocker = require('power-save-blocker');
+const powerSaveBlocker = require('electron').powerSaveBlocker;
 
 var id = powerSaveBlocker.start('prevent-display-sleep');
 console.log(powerSaveBlocker.isStarted(id));
index 45d4e5146b1fd8ef6fbacf365acef795805a76ea..0f854a2bb2f29a9937c7f9855a6f443fe7b9cfaa 100644 (file)
@@ -7,11 +7,12 @@ An example of implementing a protocol that has the same effect as the
 `file://` protocol:
 
 ```javascript
-var app = require('app');
-var path = require('path');
+const electron = require('electron');
+const app = electron.app;
+const path = require('path');
 
 app.on('ready', function() {
-    var protocol = require('protocol');
+    var protocol = electron.protocol;
     protocol.registerFileProtocol('atom', function(request, callback) {
       var url = request.url.substr(7);
       callback({path: path.normalize(__dirname + '/' + url)});
index d80312c8e1a5c58701a490ecb8bcf8a4ced45782..6eaa206465aa4a87ce27fe6e0d96e7d3296bcea3 100644 (file)
@@ -3,13 +3,17 @@
 The `remote` module provides a simple way to do inter-process communication
 (IPC) between the renderer process (web page) and the main process.
 
-In Electron, GUI-related modules (such as `dialog`, `menu` etc.) are only available in the main process, not in the renderer process. In order to use them from the renderer process, the `ipc` module is necessary to send inter-process messages to the main process. With the `remote` module, you can invoke methods of the main process object without explicitly sending inter-process messages, similar to Java's [RMI](http://en.wikipedia.org/wiki/Java_remote_method_invocation).
-
-An example of creating a browser window from a renderer process:
+In Electron, GUI-related modules (such as `dialog`, `menu` etc.) are only
+available in the main process, not in the renderer process. In order to use them
+from the renderer process, the `ipc` module is necessary to send inter-process
+messages to the main process. With the `remote` module, you can invoke methods
+of the main process object without explicitly sending inter-process messages,
+similar to Java's [RMI][rmi]. An example of creating a browser window from a
+renderer process:
 
 ```javascript
-var remote = require('remote');
-var BrowserWindow = remote.require('browser-window');
+const remote = require('electron').remote;
+const BrowserWindow = remote.require('electron').BrowserWindow;
 
 var win = new BrowserWindow({ width: 800, height: 600 });
 win.loadUrl('https://github.com');
@@ -96,8 +100,6 @@ For example, the following code seems innocent at first glance. It installs a
 callback for the `close` event on a remote object:
 
 ```javascript
-var remote = require('remote');
-
 remote.getCurrentWindow().on('close', function() {
   // blabla...
 });
@@ -146,3 +148,5 @@ process.
 
 Returns the `process` object in the main process. This is the same as
 `remote.getGlobal('process')` but is cached.
+
+[rmi]: http://en.wikipedia.org/wiki/Java_remote_method_invocation
index 42468da16005b2059573fdf165e2de4a8ec0945e..eafb56a36384e32d1d6e91fdde9fbac1832576e9 100644 (file)
@@ -6,20 +6,20 @@ position, etc. You should not use this module until the `ready` event of the
 
 `screen` is an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
 
-**Note:** In the renderer / DevTools, `window.screen` is a reserved
-DOM property, so writing `var screen = require('screen')` will not work. In our
-examples below, we use `electronScreen` as the variable name instead.
-
+**Note:** In the renderer / DevTools, `window.screen` is a reserved DOM
+property, so writing `var screen = require('electron').screen` will not work.
+In our examples below, we use `electronScreen` as the variable name instead.
 An example of creating a window that fills the whole screen:
 
 ```javascript
-var app = require('app');
-var BrowserWindow = require('browser-window');
+const electron = require('electron');
+const app = electron.app;
+const BrowserWindow = electron.BrowserWindow;
 
 var mainWindow;
 
 app.on('ready', function() {
-  var electronScreen = require('screen');
+  var electronScreen = electron.screen;
   var size = electronScreen.getPrimaryDisplay().workAreaSize;
   mainWindow = new BrowserWindow({ width: size.width, height: size.height });
 });
@@ -28,13 +28,14 @@ app.on('ready', function() {
 Another example of creating a window in the external display:
 
 ```javascript
-var app = require('app');
-var BrowserWindow = require('browser-window');
+const electron = require('electron');
+const app = electron.app;
+const BrowserWindow = electron.BrowserWindow;
 
 var mainWindow;
 
 app.on('ready', function() {
-  var electronScreen = require('screen');
+  var electronScreen = electron.screen;
   var displays = electronScreen.getAllDisplays();
   var externalDisplay = null;
   for (var i in displays) {
index 25db92b73b25e7d9f7269c53251701d7202e199d..0fa72585b94efefd22ca97309e731b50e1fe1232 100644 (file)
@@ -5,7 +5,7 @@ a property of [`BrowserWindow`](browser-window.md). You can access it through an
 instance of `BrowserWindow`. For example:
 
 ```javascript
-var BrowserWindow = require('browser-window');
+const BrowserWindow = require('electron').BrowserWindow;
 
 var win = new BrowserWindow({ width: 800, height: 600 });
 win.loadUrl("http://github.com");
@@ -43,7 +43,7 @@ The `session` object has the following methods:
 The `cookies` gives you ability to query and modify cookies. For example:
 
 ```javascript
-var BrowserWindow = require('browser-window');
+const BrowserWindow = require('electron').BrowserWindow;
 
 var win = new BrowserWindow({ width: 800, height: 600 });
 
index 662fa588f3f0d4e6458068811e68bfd2025bffd5..e6678a955364b17a35114577d92064b8af121f72 100644 (file)
@@ -5,7 +5,7 @@ The `shell` module provides functions related to desktop integration.
 An example of opening a URL in the user's default browser:
 
 ```javascript
-var shell = require('shell');
+const shell = require('electron').shell;
 
 shell.openExternal('https://github.com');
 ```
index 85d9e3f8dfa6535686bc98d3b89a0714eaac346c..8df1ca98ebafccfb83b06be078d9eab5bed4eabf 100644 (file)
@@ -19,8 +19,9 @@ scripts to be able to use those modules.
 The main process script is just like a normal Node.js script:
 
 ```javascript
-var app = require('app');
-var BrowserWindow = require('browser-window');
+const electron = require('electron');
+const app = electron.app;
+const BrowserWindow = electron.BrowserWindow;
 
 var window = null;
 
@@ -38,8 +39,8 @@ ability to use node modules:
 <html>
   <body>
     <script>
-      var remote = require('remote');
-      console.log(remote.require('app').getVersion());
+      const remote = require('electron').remote;
+      console.log(remote.require('electron').app.getVersion());
     </script>
   </body>
 </html>
index 47f02c5478fa8a17fbdd391bdca83b9f3a3c4c59..ff4310308a86f9679b9144b7767aa3e20a897d3c 100644 (file)
@@ -4,9 +4,10 @@ A `Tray` represents an icon in an operating system's notification area, it is
 usually attached with a context menu.
 
 ```javascript
-var app = require('app');
-var Menu = require('menu');
-var Tray = require('tray');
+const electron = require('electron');
+const app = electron.app;
+const Menu = electron.Menu;
+const Tray = electron.Tray;
 
 var appIcon = null;
 app.on('ready', function(){
index d62706b2ba9a4b68b2903ad1d34cc9cd35cc919e..aff5752ab55f4d754aab1dd225be86cbd4e74612 100644 (file)
@@ -8,7 +8,7 @@ the [`BrowserWindow`](browser-window.md) object. An example of accessing the
 `webContents` object:
 
 ```javascript
-var BrowserWindow = require('browser-window');
+const BrowserWindow = require('electron').BrowserWindow;
 
 var win = new BrowserWindow({width: 800, height: 1500});
 win.loadUrl("http://github.com");
@@ -211,17 +211,15 @@ e.g. the `http://` or `file://`.
 
 ### `webContents.getUrl()`
 
-```javascript
-var BrowserWindow = require('browser-window');
+Returns URL of the current web page.
 
+```javascript
 var win = new BrowserWindow({width: 800, height: 600});
 win.loadUrl("http://github.com");
 
 var currentUrl = win.webContents.getUrl();
 ```
 
-Returns URL of the current web page.
-
 ### `webContents.getTitle()`
 
 Returns the title of the current web page.
@@ -445,8 +443,8 @@ By default, an empty `options` will be regarded as:
 ```
 
 ```javascript
-var BrowserWindow = require('browser-window');
-var fs = require('fs');
+const BrowserWindow = require('electron').BrowserWindow;
+const fs = require('fs');
 
 var win = new BrowserWindow({width: 800, height: 600});
 win.loadUrl("http://github.com");
@@ -538,7 +536,7 @@ app.on('ready', function() {
 <html>
 <body>
   <script>
-    require('ipcRenderer').on('ping', function(event, message) {
+    require('electron').ipcRenderer.on('ping', function(event, message) {
       console.log(message);  // Prints "whoooooooh!"
     });
   </script>
index 33597543b773214a0c417b1714497e660f9ee7f9..c9cfb48f34373dcb14a9c0fcb2a40c1081df26c1 100644 (file)
@@ -6,7 +6,7 @@ web page.
 An example of zooming current page to 200%.
 
 ```javascript
-var webFrame = require('web-frame');
+var webFrame = require('electron').webFrame;
 
 webFrame.setZoomFactor(2);
 ```
@@ -59,7 +59,7 @@ whether the word passed is correctly spelled.
 An example of using [node-spellchecker][spellchecker] as provider:
 
 ```javascript
-require('web-frame').setSpellCheckProvider("en-US", true, {
+webFrame.setSpellCheckProvider("en-US", true, {
   spellCheck: function(text) {
     return !(require('spellchecker').isMisspelled(text));
   }
index 9a0e0be33b36808a11317c1f8ad15e46054fa6ba..a12ec447138f766310aca1b2e6aa93c07a7b606b 100644 (file)
@@ -515,7 +515,7 @@ The following example code opens the new url in system's default browser.
 
 ```javascript
 webview.addEventListener('new-window', function(e) {
-  require('shell').openExternal(e.url);
+  require('electron').shell.openExternal(e.url);
 });
 ```
 
@@ -555,9 +555,9 @@ webview.send('ping');
 
 ```javascript
 // In guest page.
-var ipc = require('ipc');
-ipc.on('ping', function() {
-  ipc.sendToHost('pong');
+var ipcRenderer = require('electron').ipcRenderer;
+ipcRenderer.on('ping', function() {
+  ipcRenderer.sendToHost('pong');
 });
 ```
 
index 0cf3a6b596f42e1a3637a408924365cf96038a4b..7c1ea773e2ff2002940a05569441e864492398eb 100644 (file)
@@ -51,14 +51,14 @@ $ asar list /path/to/example.asar
 Read a file in the `asar` archive:
 
 ```javascript
-var fs = require('fs');
+const fs = require('fs');
 fs.readFileSync('/path/to/example.asar/file.txt');
 ```
 
 List all files under the root of the archive:
 
 ```javascript
-var fs = require('fs');
+const fs = require('fs');
 fs.readdirSync('/path/to/example.asar');
 ```
 
@@ -71,7 +71,7 @@ require('/path/to/example.asar/dir/module.js');
 You can also display a web page in an `asar` archive with `BrowserWindow`:
 
 ```javascript
-var BrowserWindow = require('browser-window');
+const BrowserWindow = require('electron').BrowserWindow;
 var win = new BrowserWindow({width: 800, height: 600});
 win.loadUrl('file:///path/to/example.asar/static/index.html');
 ```
index 39f74ff10771557e09bd4f6ff851dd01a89d5be7..7c4807d8f4d4c55487592331f2f7375d2773fd99 100644 (file)
@@ -86,7 +86,6 @@ To add a file to recent documents, you can use the
 [app.addRecentDocument][addrecentdocument] API:
 
 ```javascript
-var app = require('app');
 app.addRecentDocument('/Users/USERNAME/Desktop/work.type');
 ```
 
@@ -125,8 +124,10 @@ To set your custom dock menu, you can use the `app.dock.setMenu` API, which is
 only available on OS X:
 
 ```javascript
-var app = require('app');
-var Menu = require('menu');
+const electron = require('electron');
+const app = electron.app;
+const Menu = electron.Menu;
+
 var dockMenu = Menu.buildFromTemplate([
   { label: 'New Window', click: function() { console.log('New Window'); } },
   { label: 'New Window with Settings', submenu: [
@@ -172,7 +173,6 @@ To set user tasks for your application, you can use
 [app.setUserTasks][setusertaskstasks] API:
 
 ```javascript
-var app = require('app');
 app.setUserTasks([
   {
     program: process.execPath,
@@ -220,8 +220,9 @@ You can use [BrowserWindow.setThumbarButtons][setthumbarbuttons] to set
 thumbnail toolbar in your application:
 
 ```javascript
-var BrowserWindow = require('browser-window');
-var path = require('path');
+const BrowserWindow = require('electron').BrowserWindow;
+const path = require('path');
+
 var win = new BrowserWindow({
   width: 800,
   height: 600
index 8a2144be696674fde1a755f5760c53510d0b09ba..258fb41947ffc1022feba42c21633928a6d53e33 100644 (file)
@@ -24,14 +24,15 @@ Then you can load the extension in Electron by opening DevTools in any window,
 and running the following code in the DevTools console:
 
 ```javascript
-require('remote').require('browser-window').addDevToolsExtension('/some-directory/react-devtools/shells/chrome');
+const BrowserWindow = require('electron').remote.require('electron').BrowserWindow;
+BrowserWindow.addDevToolsExtension('/some-directory/react-devtools/shells/chrome');
 ```
 
 To unload the extension, you can call the `BrowserWindow.removeDevToolsExtension`
 API with its name and it will not load the next time you open the DevTools:
 
 ```javascript
-require('remote').require('browser-window').removeDevToolsExtension('React Developer Tools');
+BrowserWindow.removeDevToolsExtension('React Developer Tools');
 ```
 
 ## Format of DevTools Extension
index 46d659e07d05b3d7f76eef5cea4eefa5c2687134..6e031282b55a56906679b4dbb1e54115550cb8c1 100644 (file)
@@ -6,10 +6,11 @@ using standard HTML5 APIs, as shown in the following example.
 _main.js_
 
 ```javascript
-var app = require('app');
-var BrowserWindow = require('browser-window');
-var onlineStatusWindow;
+const electron = require('electron');
+const app = electron.app;
+const BrowserWindow = electron.BrowserWindow;
 
+var onlineStatusWindow;
 app.on('ready', function() {
   onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false });
   onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html');
@@ -45,11 +46,12 @@ to the main process and handled as needed, as shown in the following example.
 _main.js_
 
 ```javascript
-var app = require('app');
-var ipcMain = require('ipc-main');
-var BrowserWindow = require('browser-window');
-var onlineStatusWindow;
+const electron = require('electron');
+const app = electron.app;
+const ipcMain = electron.ipcMain;
+const BrowserWindow = electron.BrowserWindow;
 
+var onlineStatusWindow;
 app.on('ready', function() {
   onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false });
   onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html');
@@ -67,7 +69,7 @@ _online-status.html_
 <html>
 <body>
 <script>
-  var ipcRenderer = require('ipc-renderer');
+  const ipcRenderer = require('electron').ipcRenderer;
   var updateOnlineStatus = function() {
     ipcRenderer.send('online-status-changed', navigator.onLine ? 'online' : 'offline');
   };
index b023deccda528bb579a627064f327581b7fd2ba2..7c55340f75e265528c49414eb3ae4376582ac89b 100644 (file)
@@ -78,11 +78,12 @@ The `main.js` should create windows and handle system events, a typical
 example being:
 
 ```javascript
-var app = require('app');  // Module to control application life.
-var BrowserWindow = require('browser-window');  // Module to create native browser window.
+const electron = require('electron');
+const app = electron.app;  // Module to control application life.
+const BrowserWindow = electron.BrowserWindow;  // Module to create native browser window.
 
 // Report crashes to our server.
-require('crash-reporter').start();
+electron.crashReporter.start();
 
 // Keep a global reference of the window object, if you don't, the window will
 // be closed automatically when the JavaScript object is garbage collected.
index 9321798ffca4b0c7e460ed327bd72d42adc7c5d4..4cbbb519f4c22c3096afde0a72f1249db125596b 100644 (file)
@@ -19,23 +19,6 @@ before the app ready event. Also, add the `plugins` switch of `browser-window`.
 For example:
 
 ```javascript
-var app = require('app');
-var BrowserWindow = require('browser-window');
-
-// Report crashes to our server.
-require('crash-reporter').start();
-
-// Keep a global reference of the window object, if you don't, the window will
-// be closed automatically when the javascript object is GCed.
-var mainWindow = null;
-
-// Quit when all windows are closed.
-app.on('window-all-closed', function() {
-  if (process.platform != 'darwin') {
-    app.quit();
-  }
-});
-
 // Specify flash path.
 // On Windows, it might be /path/to/pepflashplayer.dll
 // On OS X, /path/to/PepperFlashPlayer.plugin
index 867e452442b3948cf77de78a89e29e020c2979fd..035dabdfe79f5f0e7d728e6f38016bf270b59c9a 100644 (file)
@@ -41,7 +41,7 @@ upstream, except that you have to manually specify how to connect chrome driver
 and where to find Electron's binary:
 
 ```javascript
-var webdriver = require('selenium-webdriver');
+const webdriver = require('selenium-webdriver');
 
 var driver = new webdriver.Builder()
   // The "9515" is the port opened by chrome driver.
@@ -93,7 +93,7 @@ $ npm install webdriverio
 ### 3. Connect to chrome driver
 
 ```javascript
-var webdriverio = require('webdriverio');
+const webdriverio = require('webdriverio');
 var options = {
     host: "localhost", // Use localhost as chrome driver server
     port: 9515,        // "9515" is the port opened by chrome driver.