Merge remote-tracking branch 'origin/master' into renaesop_master
This commit is contained in:
commit
84a9b6a42d
336 changed files with 16704 additions and 2418 deletions
|
@ -667,6 +667,8 @@ app.setJumpList([
|
|||
* `argv` String[] - An array of the second instance's command line arguments
|
||||
* `workingDirectory` String - The second instance's working directory
|
||||
|
||||
Returns `Boolean`.
|
||||
|
||||
This method makes your application a Single Instance Application - instead of
|
||||
allowing multiple instances of your app to run, this will ensure that only a
|
||||
single instance of your app is running, and other instances signal this
|
||||
|
|
|
@ -44,31 +44,31 @@ Objects created with `new BrowserView` have the following properties:
|
|||
|
||||
#### `view.webContents` _Experimental_
|
||||
|
||||
A [`webContents`](web-contents.md) object owned by this view.
|
||||
A [`WebContents`](web-contents.md) object owned by this view.
|
||||
|
||||
#### `win.id` _Experimental_
|
||||
#### `view.id` _Experimental_
|
||||
|
||||
A `Integer` representing the unique ID of the view.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
Objects created with `new BrowserWindow` have the following instance methods:
|
||||
Objects created with `new BrowserView` have the following instance methods:
|
||||
|
||||
#### `win.setAutoResize(options)` _Experimental_
|
||||
#### `view.setAutoResize(options)` _Experimental_
|
||||
|
||||
* `options` Object
|
||||
* `width`: If `true`, the view's width will grow and shrink together with
|
||||
the window. `false` by default.
|
||||
* `height`: If `true`, the view's height will grow and shrink together with
|
||||
the window. `false` by default.
|
||||
* `width` Boolean - If `true`, the view's width will grow and shrink together
|
||||
with the window. `false` by default.
|
||||
* `height` Boolean - If `true`, the view's height will grow and shrink
|
||||
together with the window. `false` by default.
|
||||
|
||||
#### `win.setBounds(bounds)` _Experimental_
|
||||
#### `view.setBounds(bounds)` _Experimental_
|
||||
|
||||
* `bounds` [Rectangle](structures/rectangle.md)
|
||||
|
||||
Resizes and moves the view to the supplied bounds relative to the window.
|
||||
|
||||
#### `win.setBackgroundColor(color)` _Experimental_
|
||||
#### `view.setBackgroundColor(color)` _Experimental_
|
||||
|
||||
* `color` String - Color in `#aarrggbb` or `#argb` form. The alpha channel is
|
||||
optional.
|
||||
|
|
|
@ -307,6 +307,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||
'Electron Isolated Context' entry in the combo box at the top of the
|
||||
Console tab. **Note:** This option is currently experimental and may
|
||||
change or be removed in future Electron releases.
|
||||
* `nativeWindowOpen` Boolean (optional) - Whether to use native `window.open()`. Defaults to `false`.
|
||||
|
||||
When setting minimum or maximum window size with `minWidth`/`maxWidth`/
|
||||
`minHeight`/`maxHeight`, it only constrains the users. It won't prevent you from
|
||||
|
@ -1027,7 +1028,7 @@ Same as `webContents.capturePage([rect, ]callback)`.
|
|||
* `httpReferrer` String (optional) - A HTTP Referrer url.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
|
||||
Same as `webContents.loadURL(url[, options])`.
|
||||
|
|
|
@ -28,7 +28,7 @@ Disables the disk cache for HTTP requests.
|
|||
|
||||
Disable HTTP/2 and SPDY/3.1 protocols.
|
||||
|
||||
## --debug=`port` and --debug-brk=`port`
|
||||
## --inspect=`port` and --inspect-brk=`port`
|
||||
|
||||
Debug-related flags, see the [Debugging the Main Process][debugging-main-process] guide for details.
|
||||
|
||||
|
@ -36,6 +36,10 @@ Debug-related flags, see the [Debugging the Main Process][debugging-main-process
|
|||
|
||||
Enables remote debugging over HTTP on the specified `port`.
|
||||
|
||||
## --disk-cache-size=`size`
|
||||
|
||||
Forces the maximum disk space to be used by the disk cache, in bytes.
|
||||
|
||||
## --js-flags=`flags`
|
||||
|
||||
Specifies the flags passed to the Node JS engine. It has to be passed when starting
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# desktopCapturer
|
||||
|
||||
> Access information about media sources that can be used to capture audio and
|
||||
> video from the desktop using the [`navigator.webkitGetUserMedia`] API.
|
||||
> video from the desktop using the [`navigator.mediaDevices.getUserMedia`] API.
|
||||
|
||||
Process: [Renderer](../glossary.md#renderer-process)
|
||||
|
||||
|
@ -16,7 +16,7 @@ desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
|
|||
if (error) throw error
|
||||
for (let i = 0; i < sources.length; ++i) {
|
||||
if (sources[i].name === 'Electron') {
|
||||
navigator.webkitGetUserMedia({
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
audio: false,
|
||||
video: {
|
||||
mandatory: {
|
||||
|
@ -44,12 +44,27 @@ function handleError (e) {
|
|||
```
|
||||
|
||||
To capture video from a source provided by `desktopCapturer` the constraints
|
||||
passed to [`navigator.webkitGetUserMedia`] must include
|
||||
passed to [`navigator.mediaDevices.getUserMedia`] must include
|
||||
`chromeMediaSource: 'desktop'`, and `audio: false`.
|
||||
|
||||
To capture both audio and video from the entire desktop the constraints passed
|
||||
to [`navigator.webkitGetUserMedia`] must include `chromeMediaSource: 'screen'`,
|
||||
and `audio: true`, but should not include a `chromeMediaSourceId` constraint.
|
||||
to [`navigator.mediaDevices.getUserMedia`] must include `chromeMediaSource: 'desktop'`,
|
||||
for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint.
|
||||
|
||||
```javascript
|
||||
const constraints = {
|
||||
audio: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop'
|
||||
}
|
||||
},
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
|
@ -60,7 +75,7 @@ The `desktopCapturer` module has the following methods:
|
|||
* `options` Object
|
||||
* `types` String[] - An array of Strings that lists the types of desktop sources
|
||||
to be captured, available types are `screen` and `window`.
|
||||
* `thumbnailSize` [Size](structures/size.md) (optional) - The size that the media source thumbnail
|
||||
* `thumbnailSize` [Size](structures/size.md) (optional) - The size that the media source thumbnail
|
||||
should be scaled to. Default is `150` x `150`.
|
||||
* `callback` Function
|
||||
* `error` Error
|
||||
|
@ -73,4 +88,4 @@ and calls `callback(error, sources)` when finished.
|
|||
objects, each `DesktopCapturerSource` represents a screen or an individual window that can be
|
||||
captured.
|
||||
|
||||
[`navigator.webkitGetUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/Navigator/getUserMedia
|
||||
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
|
||||
|
|
|
@ -161,8 +161,8 @@ It returns the index of the clicked button.
|
|||
|
||||
The `browserWindow` argument allows the dialog to attach itself to a parent window, making it modal.
|
||||
|
||||
If a `callback` is passed, the API call will be asynchronous and the result
|
||||
will be passed via `callback(response)`.
|
||||
If a `callback` is passed, the dialog will not block the process. The API call
|
||||
will be asynchronous and the result will be passed via `callback(response)`.
|
||||
|
||||
### `dialog.showErrorBox(title, content)`
|
||||
|
||||
|
|
|
@ -153,6 +153,8 @@ Creates a new `NativeImage` instance from `buffer`.
|
|||
|
||||
* `dataURL` String
|
||||
|
||||
Returns `NativeImage`
|
||||
|
||||
Creates a new `NativeImage` instance from `dataURL`.
|
||||
|
||||
## Class: NativeImage
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# MemoryInfo Object
|
||||
|
||||
* `workingSetSize` Integer - Process id of the process.
|
||||
* `pid` Integer - Process id of the process.
|
||||
* `workingSetSize` Integer - The amount of memory currently pinned to actual physical RAM.
|
||||
* `peakWorkingSetSize` Integer - The maximum amount of memory that has ever been pinned
|
||||
to actual physical RAM.
|
||||
|
@ -9,4 +9,4 @@
|
|||
* `sharedBytes` Integer - The amount of memory shared between processes, typically
|
||||
memory consumed by the Electron code itself
|
||||
|
||||
Note that all statistics are reported in Kilobytes.
|
||||
Note that all statistics are reported in Kilobytes.
|
||||
|
|
|
@ -218,6 +218,36 @@ When in-page navigation happens, the page URL changes but does not cause
|
|||
navigation outside of the page. Examples of this occurring are when anchor links
|
||||
are clicked or when the DOM `hashchange` event is triggered.
|
||||
|
||||
#### Event: 'will-prevent-unload'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
|
||||
Emitted when a `beforeunload` event handler is attempting to cancel a page unload.
|
||||
|
||||
Calling `event.preventDefault()` will ignore the `beforeunload` event handler
|
||||
and allow the page to be unloaded.
|
||||
|
||||
```javascript
|
||||
const {BrowserWindow, dialog} = require('electron')
|
||||
const win = new BrowserWindow({width: 800, height: 600})
|
||||
win.webContents.on('will-prevent-unload', (event) => {
|
||||
const choice = dialog.showMessageBox(win, {
|
||||
type: 'question',
|
||||
buttons: ['Leave', 'Stay'],
|
||||
title: 'Do you want to leave this site?',
|
||||
message: 'Changes you made may not be saved.',
|
||||
defaultId: 0,
|
||||
cancelId: 1
|
||||
})
|
||||
const leave = (choice === 0)
|
||||
if (leave) {
|
||||
event.preventDefault()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Event: 'crashed'
|
||||
|
||||
Returns:
|
||||
|
@ -537,7 +567,7 @@ that can't be set via `<webview>` attributes.
|
|||
* `httpReferrer` String (optional) - A HTTP Referrer url.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
|
||||
Loads the `url` in the window. The `url` must contain the protocol prefix,
|
||||
|
@ -1295,6 +1325,10 @@ Setting the WebRTC IP handling policy allows you to control which IPs are
|
|||
exposed via WebRTC. See [BrowserLeaks](https://browserleaks.com/webrtc) for
|
||||
more details.
|
||||
|
||||
#### `contents.getOSProcessId()`
|
||||
|
||||
Returns `Integer` - The `pid` of the associated renderer process.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `contents.id`
|
||||
|
|
|
@ -312,8 +312,8 @@ webview.addEventListener('dom-ready', () => {
|
|||
* `httpReferrer` String (optional) - A HTTP Referrer url.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
|
||||
Loads the `url` in the webview, the `url` must contain the protocol prefix,
|
||||
e.g. the `http://` or `file://`.
|
||||
|
@ -511,14 +511,14 @@ Inserts `text` to the focused element.
|
|||
|
||||
* `text` String - Content to be searched, must not be empty.
|
||||
* `options` Object (optional)
|
||||
* `forward` Boolean - Whether to search forward or backward, defaults to `true`.
|
||||
* `findNext` Boolean - Whether the operation is first request or a follow up,
|
||||
* `forward` Boolean - (optional) Whether to search forward or backward, defaults to `true`.
|
||||
* `findNext` Boolean - (optional) Whether the operation is first request or a follow up,
|
||||
defaults to `false`.
|
||||
* `matchCase` Boolean - Whether search should be case-sensitive,
|
||||
* `matchCase` Boolean - (optional) Whether search should be case-sensitive,
|
||||
defaults to `false`.
|
||||
* `wordStart` Boolean - Whether to look only at the start of words.
|
||||
* `wordStart` Boolean - (optional) Whether to look only at the start of words.
|
||||
defaults to `false`.
|
||||
* `medialCapitalAsWordStart` Boolean - When combined with `wordStart`,
|
||||
* `medialCapitalAsWordStart` Boolean - (optional) When combined with `wordStart`,
|
||||
accepts a match in the middle of a word if the match begins with an
|
||||
uppercase letter followed by a lowercase or non-letter.
|
||||
Accepts several other intra-word matches, defaults to `false`.
|
||||
|
|
|
@ -45,3 +45,40 @@ has to be a field of `BrowserWindow`'s options.
|
|||
|
||||
Sends a message to the parent window with the specified origin or `*` for no
|
||||
origin preference.
|
||||
|
||||
### Use Native `window.open()`
|
||||
|
||||
If you want to use native `window.open()` implementation, pass `useNativeWindowOpen: true` in `webPreferences` option.
|
||||
Native `window.open()` allows synchronous access to opened windows so it is convenient choice if you need to open a dialog or a preferences window.
|
||||
|
||||
The creation of the `BrowserWindow` is customizable in `WebContents`'s `new-window` event.
|
||||
|
||||
```javascript
|
||||
// main process
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true
|
||||
}
|
||||
})
|
||||
mainWindow.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
|
||||
if (frameName === 'modal') {
|
||||
// open window as modal
|
||||
event.preventDefault()
|
||||
Object.assign(options, {
|
||||
modal: true,
|
||||
parent: mainWindow,
|
||||
width: 100,
|
||||
height: 100
|
||||
})
|
||||
event.newGuest = new BrowserWindow(options)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
```javascript
|
||||
// renderer process (mainWindow)
|
||||
let modal = window.open('', 'modal')
|
||||
modal.document.write('<h1>Hello</h1>')
|
||||
```
|
||||
|
|
|
@ -25,7 +25,7 @@ so you can use it for browser testing in place of [PhantomJS](http://phantomjs.o
|
|||
|
||||
__2. Build System__
|
||||
|
||||
In order to avoid the complexity of building all of Chromium, Electron uses [`libchromiumcontent`](https://github.com/brightray/libchromiumcontent) to access
|
||||
In order to avoid the complexity of building all of Chromium, Electron uses [`libchromiumcontent`](https://github.com/electron/libchromiumcontent) to access
|
||||
Chromium's Content API. `libchromiumcontent` is a single shared library that
|
||||
includes the Chromium Content module and all of its dependencies. Users don't
|
||||
need a powerful machine to build Electron.
|
||||
|
|
|
@ -11,9 +11,9 @@ Following `gyp` files contain the main rules for building Electron:
|
|||
* `electron.gyp` defines how Electron itself is built.
|
||||
* `common.gypi` adjusts the build configurations of Node to make it build
|
||||
together with Chromium.
|
||||
* `vendor/brightray/brightray.gyp` defines how `brightray` is built and
|
||||
* `brightray/brightray.gyp` defines how `brightray` is built and
|
||||
includes the default configurations for linking with Chromium.
|
||||
* `vendor/brightray/brightray.gypi` includes general build configurations about
|
||||
* `brightray/brightray.gypi` includes general build configurations about
|
||||
building.
|
||||
|
||||
## Component Build
|
||||
|
|
|
@ -32,3 +32,4 @@ For further guidance on setting up editor integration, see these pages:
|
|||
|
||||
* [Atom](https://atom.io/packages/clang-format)
|
||||
* [Vim & Emacs](http://clang.llvm.org/docs/ClangFormat.html#vim-integration)
|
||||
* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
|
||||
|
|
|
@ -47,7 +47,7 @@ source code matches the code running in the attached process and break
|
|||
accordingly.
|
||||
|
||||
Relevant code files can be found in `./atom/` as well as in Brightray, found in
|
||||
`./vendor/brightray/browser` and `./vendor/brightray/common`. If you're hardcore,
|
||||
`./brightray/browser` and `./brightray/common`. If you're hardcore,
|
||||
you can also debug Chromium directly, which is obviously found in `chromium_src`.
|
||||
|
||||
### Attaching
|
||||
|
|
|
@ -18,8 +18,8 @@ to enable step-through debugging with breakpoints inside Electron's source code.
|
|||
tail calls, and other compiler optimizations.
|
||||
|
||||
* **Xcode**: In addition to Xcode, also install the Xcode command line tools.
|
||||
They include LLDB, the default debugger in Xcode on Mac OS X. It supports
|
||||
debugging C, Objective-C and C++ on the desktop and iOS devices and simulator.
|
||||
They include LLDB, the default debugger in Xcode on Mac OS X. It supports
|
||||
debugging C, Objective-C and C++ on the desktop and iOS devices and simulator.
|
||||
|
||||
## Attaching to and Debugging Electron
|
||||
|
||||
|
@ -40,7 +40,7 @@ that isn't behaving correctly - so you'd like to break on that command's C++
|
|||
counterpart inside the Electron source.
|
||||
|
||||
Relevant code files can be found in `./atom/` as well as in Brightray, found in
|
||||
`./vendor/brightray/browser` and `./vendor/brightray/common`. If you're hardcore,
|
||||
`./brightray/browser` and `./brightray/common`. If you're hardcore,
|
||||
you can also debug Chromium directly, which is obviously found in `chromium_src`.
|
||||
|
||||
Let's assume that you want to debug `app.setName()`, which is defined in `browser.cc`
|
||||
|
@ -77,7 +77,7 @@ Process 25244 stopped
|
|||
```
|
||||
|
||||
To show the arguments and local variables for the current frame, run `frame variable` (or `fr v`),
|
||||
which will show you that the app is currently setting the name to "Electron".
|
||||
which will show you that the app is currently setting the name to "Electron".
|
||||
|
||||
```bash
|
||||
(lldb) frame variable
|
||||
|
|
|
@ -72,7 +72,7 @@ when running `git status`:
|
|||
```sh
|
||||
$ git status
|
||||
|
||||
modified: vendor/brightray (new commits)
|
||||
modified: vendor/libchromiumcontent (new commits)
|
||||
modified: vendor/node (new commits)
|
||||
```
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ Chrome/Node API changes.
|
|||
- Upgrade `vendor/depot_tools` for any build tools changes needed
|
||||
- Update the `libchromiumcontent` SHA-1 to download in `script/lib/config.py`
|
||||
- Open a pull request on `electron/libchromiumcontent` with the changes
|
||||
- Open a pull request on `electron/brightray` with the changes
|
||||
- This should include upgrading the `vendor/libchromiumcontent` submodule
|
||||
- Open a pull request on `electron/electron` with the changes
|
||||
- This should include upgrading the submodules in `vendor/` as needed
|
||||
- Verify debug builds succeed on:
|
||||
|
|
|
@ -12,10 +12,8 @@ The ASAR format was created primarily to improve performance on Windows... TODO
|
|||
|
||||
### Brightray
|
||||
|
||||
[Brightray][brightray] is a static library that makes [libchromiumcontent]
|
||||
easier to use in applications. It was created specifically for Electron, but can
|
||||
be used to enable Chromium's renderer in native apps that are not based on
|
||||
Electron.
|
||||
Brightray is a static library that makes [libchromiumcontent]
|
||||
easier to use in applications.
|
||||
|
||||
Brightray is a low-level dependency of Electron that does not concern the
|
||||
majority of Electron users.
|
||||
|
@ -142,7 +140,6 @@ embedded content.
|
|||
[addons]: https://nodejs.org/api/addons.html
|
||||
[asar]: https://github.com/electron/asar
|
||||
[autoUpdater]: api/auto-updater.md
|
||||
[brightray]: https://github.com/electron/brightray
|
||||
[electron-builder]: https://github.com/electron-userland/electron-builder
|
||||
[libchromiumcontent]: #libchromiumcontent
|
||||
[Mac App Store Submission Guide]: tutorials/mac-app-store-submission-guide.md
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
# Debugging the Main Process in node-inspector
|
||||
|
||||
[`node-inspector`][node-inspector] provides a familiar DevTools GUI that can
|
||||
be used in Chrome to debug Electron's main process, however, because
|
||||
`node-inspector` relies on some native Node modules they must be rebuilt to
|
||||
target the version of Electron you wish to debug. You can either rebuild
|
||||
the `node-inspector` dependencies yourself, or let
|
||||
[`electron-inspector`][electron-inspector] do it for you, both approaches are
|
||||
covered in this document.
|
||||
|
||||
**Note**: At the time of writing the latest release of `node-inspector`
|
||||
(0.12.8) can't be rebuilt to target Electron 1.3.0 or later without patching
|
||||
one of its dependencies. If you use `electron-inspector` it will take care of
|
||||
this for you.
|
||||
|
||||
|
||||
## Use `electron-inspector` for Debugging
|
||||
|
||||
### 1. Install the [node-gyp required tools][node-gyp-required-tools]
|
||||
|
||||
### 2. Install [`electron-rebuild`][electron-rebuild], if you haven't done so already.
|
||||
|
||||
```shell
|
||||
npm install electron-rebuild --save-dev
|
||||
```
|
||||
|
||||
### 3. Install [`electron-inspector`][electron-inspector]
|
||||
|
||||
```shell
|
||||
npm install electron-inspector --save-dev
|
||||
```
|
||||
|
||||
### 4. Start Electron
|
||||
|
||||
Launch Electron with the `--debug` switch:
|
||||
|
||||
```shell
|
||||
electron --debug=5858 your/app
|
||||
```
|
||||
|
||||
or, to pause execution on the first line of JavaScript:
|
||||
|
||||
```shell
|
||||
electron --debug-brk=5858 your/app
|
||||
```
|
||||
|
||||
### 5. Start electron-inspector
|
||||
|
||||
On macOS / Linux:
|
||||
|
||||
```shell
|
||||
node_modules/.bin/electron-inspector
|
||||
```
|
||||
|
||||
On Windows:
|
||||
|
||||
```shell
|
||||
node_modules\\.bin\\electron-inspector
|
||||
```
|
||||
|
||||
`electron-inspector` will need to rebuild `node-inspector` dependencies on the
|
||||
first run, and any time you change your Electron version. The rebuild process
|
||||
may require an internet connection to download Node headers and libs, and may
|
||||
take a few minutes.
|
||||
|
||||
### 6. Load the debugger UI
|
||||
|
||||
Open http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 in the Chrome
|
||||
browser. You may have to click pause if starting with `--debug-brk` to force
|
||||
the UI to update.
|
||||
|
||||
|
||||
## Use `node-inspector` for Debugging
|
||||
|
||||
### 1. Install the [node-gyp required tools][node-gyp-required-tools]
|
||||
|
||||
### 2. Install [`node-inspector`][node-inspector]
|
||||
|
||||
```bash
|
||||
$ npm install node-inspector
|
||||
```
|
||||
|
||||
### 3. Install [`node-pre-gyp`][node-pre-gyp]
|
||||
|
||||
```bash
|
||||
$ npm install node-pre-gyp
|
||||
```
|
||||
|
||||
### 4. Recompile the `node-inspector` `v8` modules for Electron
|
||||
|
||||
**Note:** Update the target argument to be your Electron version number
|
||||
|
||||
```bash
|
||||
$ node_modules/.bin/node-pre-gyp --target=1.2.5 --runtime=electron --fallback-to-build --directory node_modules/v8-debug/ --dist-url=https://atom.io/download/atom-shell reinstall
|
||||
$ node_modules/.bin/node-pre-gyp --target=1.2.5 --runtime=electron --fallback-to-build --directory node_modules/v8-profiler/ --dist-url=https://atom.io/download/atom-shell reinstall
|
||||
```
|
||||
|
||||
See also [How to install native modules][how-to-install-native-modules].
|
||||
|
||||
### 5. Enable debug mode for Electron
|
||||
|
||||
You can either start Electron with a debug flag like:
|
||||
|
||||
```bash
|
||||
$ electron --debug=5858 your/app
|
||||
```
|
||||
|
||||
or, to pause your script on the first line:
|
||||
|
||||
```bash
|
||||
$ electron --debug-brk=5858 your/app
|
||||
```
|
||||
|
||||
### 6. Start the [`node-inspector`][node-inspector] server using Electron
|
||||
|
||||
```bash
|
||||
$ ELECTRON_RUN_AS_NODE=true path/to/electron.exe node_modules/node-inspector/bin/inspector.js
|
||||
```
|
||||
|
||||
### 7. Load the debugger UI
|
||||
|
||||
Open http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 in the Chrome
|
||||
browser. You may have to click pause if starting with `--debug-brk` to see the
|
||||
entry line.
|
||||
|
||||
[electron-inspector]: https://github.com/enlight/electron-inspector
|
||||
[electron-rebuild]: https://github.com/electron/electron-rebuild
|
||||
[node-inspector]: https://github.com/node-inspector/node-inspector
|
||||
[node-pre-gyp]: https://github.com/mapbox/node-pre-gyp
|
||||
[node-gyp-required-tools]: https://github.com/nodejs/node-gyp#installation
|
||||
[how-to-install-native-modules]: using-native-node-modules.md#how-to-install-native-modules
|
|
@ -3,31 +3,31 @@
|
|||
The DevTools in an Electron browser window can only debug JavaScript that's
|
||||
executed in that window (i.e. the web pages). To debug JavaScript that's
|
||||
executed in the main process you will need to use an external debugger and
|
||||
launch Electron with the `--debug` or `--debug-brk` switch.
|
||||
launch Electron with the `--inspector` or `--inspector-brk` switch.
|
||||
|
||||
## Command Line Switches
|
||||
|
||||
Use one of the following command line switches to enable debugging of the main
|
||||
process:
|
||||
|
||||
### `--debug=[port]`
|
||||
### `--inspect=[port]`
|
||||
|
||||
Electron will listen for V8 debugger protocol messages on the specified `port`,
|
||||
Electron will listen for V8 inspector protocol messages on the specified `port`,
|
||||
an external debugger will need to connect on this port. The default `port` is
|
||||
`5858`.
|
||||
|
||||
```shell
|
||||
electron --debug=5858 your/app
|
||||
electron --inspect=5858 your/app
|
||||
```
|
||||
|
||||
### `--debug-brk=[port]`
|
||||
### `--inspect-brk=[port]`
|
||||
|
||||
Like `--debug` but pauses execution on the first line of JavaScript.
|
||||
Like `--inspector` but pauses execution on the first line of JavaScript.
|
||||
|
||||
## External Debuggers
|
||||
|
||||
You will need to use a debugger that supports the V8 debugger protocol,
|
||||
the following guides should help you to get started:
|
||||
You will need to use a debugger that supports the V8 inspector protocol.
|
||||
|
||||
- Connect Chrome by visiting `chrome://inspect` and selecting to inspect the
|
||||
launched Electron app present there.
|
||||
- [Debugging the Main Process in VSCode](debugging-main-process-vscode.md)
|
||||
- [Debugging the Main Process in node-inspector](debugging-main-process-node-inspector.md)
|
||||
|
|
|
@ -192,10 +192,10 @@ $ .\node_modules\.bin\electron .
|
|||
If you downloaded Electron manually, you can also use the included
|
||||
binary to execute your app directly.
|
||||
|
||||
#### Windows
|
||||
#### macOS
|
||||
|
||||
```bash
|
||||
$ .\electron\electron.exe your-app\
|
||||
$ ./Electron.app/Contents/MacOS/Electron your-app/
|
||||
```
|
||||
|
||||
#### Linux
|
||||
|
@ -204,10 +204,10 @@ $ .\electron\electron.exe your-app\
|
|||
$ ./electron/electron your-app/
|
||||
```
|
||||
|
||||
#### macOS
|
||||
#### Windows
|
||||
|
||||
```bash
|
||||
$ ./Electron.app/Contents/MacOS/Electron your-app/
|
||||
$ .\electron\electron.exe your-app\
|
||||
```
|
||||
|
||||
`Electron.app` here is part of the Electron's release package, you can download
|
||||
|
|
|
@ -109,7 +109,7 @@ In order to run your package, your users will need Windows 10 with the so-called
|
|||
In opposition to traditional UWP apps, packaged apps currently need to undergo a
|
||||
manual verification process, for which you can apply [here][centennial-campaigns].
|
||||
In the meantime, all users will be able to just install your package by double-clicking it,
|
||||
so a submission to the store might not be necessary if you're simply looking for an
|
||||
so a submission to the store might not be necessary if you're simply looking for an
|
||||
easier installation method. In managed environments (usually enterprises), the
|
||||
`Add-AppxPackage` [PowerShell Cmdlet can be used to install it in an automated fashion][add-appxpackage].
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue