Browse Source

docs: Update codes in docs to use require('electron')

Cheng Zhao 9 years ago
parent
commit
eac2e7cc61

+ 15 - 15
docs/README.md

@@ -31,32 +31,32 @@
 ### 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)
 

+ 1 - 1
docs/api/app.md

@@ -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();
 });

+ 1 - 12
docs/api/browser-window.md

@@ -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

+ 1 - 1
docs/api/chrome-command-line-switches.md

@@ -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');
 

+ 1 - 4
docs/api/clipboard.md

@@ -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.

+ 1 - 1
docs/api/content-tracing.md

@@ -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');

+ 2 - 2
docs/api/crash-reporter.md

@@ -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.

+ 3 - 3
docs/api/dialog.md

@@ -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.

+ 2 - 3
docs/api/frameless-window.md

@@ -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

+ 3 - 2
docs/api/global-shortcut.md

@@ -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.

+ 2 - 2
docs/api/ipc-main.md

@@ -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) {

+ 5 - 5
docs/api/menu.md

@@ -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: [

+ 14 - 15
docs/api/native-image.md

@@ -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()`

+ 2 - 4
docs/api/power-monitor.md

@@ -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');
   });
 });

+ 2 - 2
docs/api/power-save-blocker.md

@@ -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));

+ 4 - 3
docs/api/protocol.md

@@ -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)});

+ 11 - 7
docs/api/remote.md

@@ -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

+ 11 - 10
docs/api/screen.md

@@ -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) {

+ 2 - 2
docs/api/session.md

@@ -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 });
 

+ 1 - 1
docs/api/shell.md

@@ -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');
 ```

+ 5 - 4
docs/api/synopsis.md

@@ -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>

+ 4 - 3
docs/api/tray.md

@@ -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(){

+ 6 - 8
docs/api/web-contents.md

@@ -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>

+ 2 - 2
docs/api/web-frame.md

@@ -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));
   }

+ 4 - 4
docs/api/web-view-tag.md

@@ -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');
 });
 ```
 

+ 3 - 3
docs/tutorial/application-packaging.md

@@ -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');
 ```

+ 7 - 6
docs/tutorial/desktop-environment-integration.md

@@ -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

+ 3 - 2
docs/tutorial/devtools-extension.md

@@ -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

+ 10 - 8
docs/tutorial/online-offline-events.md

@@ -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');
   };

+ 4 - 3
docs/tutorial/quick-start.md

@@ -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.

+ 0 - 17
docs/tutorial/using-pepper-flash-plugin.md

@@ -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

+ 2 - 2
docs/tutorial/using-selenium-and-webdriver.md

@@ -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.