From 2c87dfef8a89474cd48a2e4b004d86b9db2acc0e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 10:36:25 -0500 Subject: [PATCH 1/7] add fs-extra devDependency to spec --- spec/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/package.json b/spec/package.json index 30fa0480992d..22d5c2fd02f3 100644 --- a/spec/package.json +++ b/spec/package.json @@ -10,6 +10,7 @@ "chai-as-promised": "^7.1.1", "coffee-script": "1.12.7", "dbus-native": "^0.2.3", + "fs-extra": "^6.0.0", "graceful-fs": "^4.1.9", "mkdirp": "^0.5.1", "mocha": "^3.1.0", From cf6d36cb72c5a0e45f24760ace82372cf57fa6e2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 12:18:38 -0500 Subject: [PATCH 2/7] Consistent docs for LoadURLOptions.httpReferrer --- docs/api/browser-window.md | 2 +- docs/api/webview-tag.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index ab2d6c7b1149..a6dfe1d65876 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1150,7 +1150,7 @@ Same as `webContents.capturePage([rect, ]callback)`. * `url` String * `options` Object (optional) - * `httpReferrer` String (optional) - An HTTP Referrer url. + * `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An 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) diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 2bbfc0ce590a..1d991ff2e697 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -306,7 +306,7 @@ webview.addEventListener('dom-ready', () => { * `url` URL * `options` Object (optional) - * `httpReferrer` String (optional) - An HTTP Referrer url. + * `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An 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) - From 8acbfca06b82db9dd755c7ca3dbaf889e09fc517 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 12:40:46 -0500 Subject: [PATCH 3/7] Make Referrer.policy types parseable by e-t-d --- docs/api/structures/referrer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/structures/referrer.md b/docs/api/structures/referrer.md index eb788dca3046..3d1f6ed9fee6 100644 --- a/docs/api/structures/referrer.md +++ b/docs/api/structures/referrer.md @@ -3,8 +3,8 @@ * `url` String - HTTP Referrer URL. * `policy` String - Can be `default`, `unsafe-url`, `no-referrer-when-downgrade`, `no-referrer`, `origin`, - `strict-origin-when-cross-origin`, `same-origin`, `strict-origin`, or - `no-referrer`. See the [Referrer-Policy spec][1] for more details on the + `strict-origin-when-cross-origin`, `same-origin`, `strict-origin`. + See the [Referrer-Policy spec][1] for more details on the meaning of these values. [1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy From 13877ce2c8d0aeaf2cdb9799992d4bed93e1b3d1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 13:05:05 -0500 Subject: [PATCH 4/7] Fix routingId type Previous phrasing confused electron-typescript-definitions, thinking that routingId was of type `unique` :smiley: --- docs/api/web-frame.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index 20eaea77a953..72fda772d938 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -237,10 +237,10 @@ renderer process. ### `webFrame.findFrameByRoutingId(routingId)` -* `routingId` Integer - A unique frame id in the current renderer process. - Routing IDs can be retrieved from `WebFrame` instances (`webFrame.routingId`) - and are also passed by frame specific `WebContents` navigation events (e.g. - `did-frame-navigate`) +* `routingId` Integer - An `Integer` representing the unique frame id in the + current renderer process. Routing IDs can be retrieved from `WebFrame` + instances (`webFrame.routingId`) and are also passed by frame + specific `WebContents` navigation events (e.g. `did-frame-navigate`) Returns `WebFrame` - that has the supplied `routingId`, `null` if not found. @@ -276,5 +276,6 @@ current renderer process. ### `webFrame.routingId` -A unique frame id in the current renderer process. Distinct WebFrame instances -that refer to the same underlying frame will have the same `routingId`. \ No newline at end of file +An `Integer` representing the unique frame id in the current renderer process. +Distinct WebFrame instances that refer to the same underlying frame will have +the same `routingId`. From bdae24355242d6320670752c065d86538abb2235 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 13:17:11 -0500 Subject: [PATCH 5/7] Reinstate docs for app.makeSingleInstance() Since this method is mentioned in breaking-changes.md, we need the docs to prevent create-typescript-definitions from failing with "error TS2339: Property 'makeSingleInstance' does not exist on type 'App'." The reinstated docs are marked with deprecation warnings that refer the reader to the new API calls. --- docs/api/app.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/docs/api/app.md b/docs/api/app.md index 4661c9e4095a..f69fcd329716 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -758,6 +758,71 @@ app.setJumpList([ ]) ``` +### `app.makeSingleInstance(callback)` *(Deprecated)* + +* `callback` Function + * `argv` String[] - An array of the second instance's command line arguments + * `workingDirectory` String - The second instance's working directory + +Returns `Boolean`. + +**Deprecated**: This method has been deprecated and is scheduled for removal. +Please use `app.requestSingleInstanceLock()` instead. + +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 +instance and exit. + +`callback` will be called by the first instance with `callback(argv, workingDirectory)` +when a second instance has been executed. `argv` is an Array of the second instance's +command line arguments, and `workingDirectory` is its current working directory. Usually +applications respond to this by making their primary window focused and +non-minimized. + +The `callback` is guaranteed to be executed after the `ready` event of `app` +gets emitted. + +This method returns `false` if your process is the primary instance of the +application and your app should continue loading. And returns `true` if your +process has sent its parameters to another instance, and you should immediately +quit. + +On macOS the system enforces single instance automatically when users try to open +a second instance of your app in Finder, and the `open-file` and `open-url` +events will be emitted for that. However when users start your app in command +line the system's single instance mechanism will be bypassed and you have to +use this method to ensure single instance. + +An example of activating the window of primary instance when a second instance +starts: + +```javascript +const {app} = require('electron') +let myWindow = null + +const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => { + // Someone tried to run a second instance, we should focus our window. + if (myWindow) { + if (myWindow.isMinimized()) myWindow.restore() + myWindow.focus() + } +}) + +if (isSecondInstance) { + app.quit() +} + +// Create myWindow, load the rest of the app, etc... +app.on('ready', () => { +}) +``` + +### `app.releaseSingleInstance()` + +Releases all locks that were created by `makeSingleInstance`. This will allow +multiple instances of the application to once again run side by side. + ### `app.requestSingleInstanceLock()` Returns `Boolean` @@ -818,6 +883,15 @@ holding the single instance lock. You can request the lock with `app.requestSingleInstanceLock()` and release with `app.releaseSingleInstanceLock()` +### `app.releaseSingleInstance()` *(Deprecated)* + +Releases all locks that were created by `makeSingleInstance`. This will allow +multiple instances of the application to once again run side by side. + +**Deprecated**: This method has been deprecated and is scheduled for removal. +Please use the `app.requestSingleInstanceLock()` and `app.releaseSingleInstanceLock()` +methods instead. + ### `app.releaseSingleInstanceLock()` Releases all locks that were created by `requestSingleInstanceLock`. This will From 5354e804d00cc92498f36e0de773a39fa795d25f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 13:27:35 -0500 Subject: [PATCH 6/7] Fix oops: remove duplicate doc from last commit --- docs/api/app.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index f69fcd329716..1a240bae6fc9 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -818,11 +818,6 @@ app.on('ready', () => { }) ``` -### `app.releaseSingleInstance()` - -Releases all locks that were created by `makeSingleInstance`. This will allow -multiple instances of the application to once again run side by side. - ### `app.requestSingleInstanceLock()` Returns `Boolean` From c2282ce4bdf32c0228f75935f3731ef975ffd21b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 11 May 2018 13:33:27 -0500 Subject: [PATCH 7/7] remove accidentally-commited changes --- spec/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/package.json b/spec/package.json index 22d5c2fd02f3..30fa0480992d 100644 --- a/spec/package.json +++ b/spec/package.json @@ -10,7 +10,6 @@ "chai-as-promised": "^7.1.1", "coffee-script": "1.12.7", "dbus-native": "^0.2.3", - "fs-extra": "^6.0.0", "graceful-fs": "^4.1.9", "mkdirp": "^0.5.1", "mocha": "^3.1.0",