From fd148b5c38a8a7ff92300945b6c05a7682e0ac4e Mon Sep 17 00:00:00 2001 From: electron-bot Date: Wed, 11 Oct 2023 16:28:22 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20update=20ref=20to=20docs=20(?= =?UTF-8?q?=F0=9F=A4=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/latest/api/app.md | 8 +- docs/latest/api/browser-view.md | 1 + docs/latest/api/browser-window.md | 28 +++---- docs/latest/api/cookies.md | 4 +- docs/latest/api/ipc-renderer.md | 2 +- docs/latest/api/menu-item.md | 5 +- docs/latest/api/session.md | 2 +- .../api/structures/browser-window-options.md | 10 +-- .../api/structures/ipc-renderer-event.md | 6 +- docs/latest/api/structures/product.md | 2 - docs/latest/api/structures/web-preferences.md | 1 + docs/latest/api/system-preferences.md | 44 ----------- docs/latest/api/web-contents.md | 31 ++++---- docs/latest/api/webview-tag.md | 8 +- docs/latest/breaking-changes.md | 75 +++++++++++++++++++ .../development/build-instructions-windows.md | 4 +- docs/latest/development/creating-api.md | 6 +- .../development/debugging-on-windows.md | 2 +- docs/latest/development/issues.md | 2 +- .../latest/fiddles/features/dark-mode/main.js | 2 +- .../fiddles/features/drag-and-drop/main.js | 6 +- .../features/offscreen-rendering/main.js | 4 +- .../fiddles/features/recent-documents/main.js | 4 +- .../fiddles/features/represented-file/main.js | 2 +- .../fiddles/features/web-bluetooth/main.js | 2 +- docs/latest/fiddles/ipc/pattern-1/main.js | 2 +- docs/latest/fiddles/ipc/pattern-2/main.js | 2 +- docs/latest/fiddles/ipc/pattern-3/main.js | 2 +- .../fiddles/ipc/webview-new-window/main.js | 2 +- .../media/screenshot/take-screenshot/main.js | 7 +- .../screenshot/take-screenshot/renderer.js | 35 ++++----- .../fiddles/menus/customize-menus/index.html | 10 +-- .../fiddles/menus/customize-menus/main.js | 7 ++ .../latest/fiddles/menus/shortcuts/index.html | 12 +-- docs/latest/fiddles/menus/shortcuts/main.js | 9 ++- .../native-ui/dialogs/error-dialog/index.html | 2 +- .../native-ui/dialogs/error-dialog/main.js | 9 ++- .../dialogs/error-dialog/renderer.js | 13 +--- .../dialogs/information-dialog/index.html | 2 +- .../dialogs/information-dialog/main.js | 9 ++- .../dialogs/information-dialog/renderer.js | 13 +--- .../dialogs/open-file-or-directory/index.html | 2 +- .../dialogs/open-file-or-directory/main.js | 9 ++- .../open-file-or-directory/renderer.js | 13 +--- .../native-ui/dialogs/save-dialog/index.html | 2 +- .../native-ui/dialogs/save-dialog/main.js | 9 ++- .../native-ui/dialogs/save-dialog/renderer.js | 13 +--- .../native-ui/drag-and-drop/index.html | 2 +- .../fiddles/native-ui/drag-and-drop/main.js | 9 ++- .../native-ui/drag-and-drop/renderer.js | 13 ---- .../external-links/index.html | 67 ----------------- .../external-links/main.js | 25 ------- .../external-links/renderer.js | 7 -- .../external-links-file-manager/index.html | 6 +- .../external-links-file-manager/main.js | 9 ++- .../path-in-file-manager/index.html | 24 ------ .../path-in-file-manager/main.js | 25 ------- .../path-in-file-manager/renderer.js | 8 -- .../external-links-file-manager/renderer.js | 2 +- .../basic-notification/index.html | 22 ------ .../notifications/basic-notification/main.js | 25 ------- .../basic-notification/renderer.js | 14 ---- .../native-ui/notifications/index.html | 2 +- .../fiddles/native-ui/notifications/main.js | 9 ++- .../notification-with-image/index.html | 22 ------ .../notification-with-image/main.js | 25 ------- .../notification-with-image/renderer.js | 14 ---- docs/latest/fiddles/native-ui/tray/index.html | 4 +- docs/latest/fiddles/quick-start/main.js | 2 +- docs/latest/fiddles/screen/fit-screen/main.js | 2 +- .../fiddles/system/clipboard/copy/main.js | 2 +- .../fiddles/system/clipboard/paste/main.js | 2 +- .../index.html | 2 +- .../main.js | 2 +- .../app-information/index.html | 2 +- .../app-information/main.js | 35 ++++++++- .../app-information/renderer.js | 16 +--- .../get-version-information/index.html | 2 +- .../get-version-information/main.js | 9 ++- docs/latest/fiddles/tutorial-preload/main.js | 2 +- .../create-frameless-window/index.html | 26 ------- .../create-frameless-window/main.js | 22 ------ .../create-frameless-window/renderer.js | 8 -- .../frameless-window/index.html | 4 +- .../manage-windows/frameless-window/main.js | 9 ++- .../manage-window-state/index.html | 4 +- .../manage-window-state/main.js | 9 ++- .../manage-window-state/renderer.js | 14 +--- .../manage-windows/new-window/index.html | 2 +- .../windows/manage-windows/new-window/main.js | 9 ++- .../manage-windows/new-window/renderer.js | 8 +- .../manage-windows/window-events/index.html | 2 +- .../manage-windows/window-events/main.js | 9 ++- .../manage-windows/window-events/renderer.js | 14 +--- docs/latest/tutorial/automated-testing.md | 2 +- docs/latest/tutorial/context-isolation.md | 4 +- docs/latest/tutorial/electron-timelines.md | 9 ++- docs/latest/tutorial/introduction.md | 2 +- docs/latest/tutorial/ipc.md | 10 +-- docs/latest/tutorial/message-ports.md | 4 +- docs/latest/tutorial/performance.md | 5 +- docs/latest/tutorial/snapcraft.md | 32 +++++++- .../latest/tutorial/testing-on-headless-ci.md | 13 +--- .../tutorial-6-publishing-updating.md | 2 +- docs/latest/tutorial/windows-store-guide.md | 6 +- 105 files changed, 420 insertions(+), 666 deletions(-) delete mode 100644 docs/latest/fiddles/native-ui/external-links-file-manager/external-links/index.html delete mode 100644 docs/latest/fiddles/native-ui/external-links-file-manager/external-links/main.js delete mode 100644 docs/latest/fiddles/native-ui/external-links-file-manager/external-links/renderer.js delete mode 100644 docs/latest/fiddles/native-ui/external-links-file-manager/path-in-file-manager/index.html delete mode 100644 docs/latest/fiddles/native-ui/external-links-file-manager/path-in-file-manager/main.js delete mode 100644 docs/latest/fiddles/native-ui/external-links-file-manager/path-in-file-manager/renderer.js delete mode 100644 docs/latest/fiddles/native-ui/notifications/basic-notification/index.html delete mode 100644 docs/latest/fiddles/native-ui/notifications/basic-notification/main.js delete mode 100644 docs/latest/fiddles/native-ui/notifications/basic-notification/renderer.js delete mode 100644 docs/latest/fiddles/native-ui/notifications/notification-with-image/index.html delete mode 100644 docs/latest/fiddles/native-ui/notifications/notification-with-image/main.js delete mode 100644 docs/latest/fiddles/native-ui/notifications/notification-with-image/renderer.js delete mode 100644 docs/latest/fiddles/windows/manage-windows/create-frameless-window/index.html delete mode 100644 docs/latest/fiddles/windows/manage-windows/create-frameless-window/main.js delete mode 100644 docs/latest/fiddles/windows/manage-windows/create-frameless-window/renderer.js diff --git a/docs/latest/api/app.md b/docs/latest/api/app.md index d038784d2..df8851fa8 100644 --- a/docs/latest/api/app.md +++ b/docs/latest/api/app.md @@ -135,9 +135,8 @@ Emitted when the user wants to open a URL with the application. Your application set `NSPrincipalClass` to `AtomApplication`. As with the `open-file` event, be sure to register a listener for the `open-url` -event early in your application startup to detect if the the application being -is being opened to handle a URL. If you register the listener in response to a -`ready` event, you'll miss URLs that trigger the launch of your application. +event early in your application startup to detect if the application is being opened to handle a URL. +If you register the listener in response to a `ready` event, you'll miss URLs that trigger the launch of your application. ### Event: 'activate' _macOS_ @@ -1272,6 +1271,9 @@ On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher. **Note:** Unity launcher requires a `.desktop` file to work. For more information, please read the [Unity integration documentation][unity-requirement]. +**Note:** On macOS, you need to ensure that your application has the permission +to display notifications for this method to work. + ### `app.getBadgeCount()` _Linux_ _macOS_ Returns `Integer` - The current value displayed in the counter badge. diff --git a/docs/latest/api/browser-view.md b/docs/latest/api/browser-view.md index 543593872..349bcfa85 100644 --- a/docs/latest/api/browser-view.md +++ b/docs/latest/api/browser-view.md @@ -108,6 +108,7 @@ app.whenReady().then(() => { * `monospace` string (optional) - Defaults to `Courier New`. * `cursive` string (optional) - Defaults to `Script`. * `fantasy` string (optional) - Defaults to `Impact`. + * `math` string (optional) - Defaults to `Latin Modern Math`. * `defaultFontSize` Integer (optional) - Defaults to `16`. * `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`. * `minimumFontSize` Integer (optional) - Defaults to `0`. diff --git a/docs/latest/api/browser-window.md b/docs/latest/api/browser-window.md index da907f41a..962b56064 100644 --- a/docs/latest/api/browser-window.md +++ b/docs/latest/api/browser-window.md @@ -264,12 +264,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. Windows, which adds standard window frame. Setting it to `false` will remove window shadow and window animations. Default is `true`. * `vibrancy` string (optional) _macOS_ - Add a type of vibrancy effect to - the window, only on macOS. Can be `appearance-based`, `light`, `dark`, - `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `medium-light`, - `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, - `tooltip`, `content`, `under-window`, or `under-page`. Please note that - `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are - deprecated and have been removed in macOS Catalina (10.15). + the window, only on macOS. Can be `appearance-based`, `titlebar`, `selection`, + `menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, + `tooltip`, `content`, `under-window`, or `under-page`. * `backgroundMaterial` string (optional) _Windows_ - Set the window's system-drawn background material, including behind the non-client area. Can be `auto`, `none`, `mica`, `acrylic` or `tabbed`. See [win.setBackgroundMaterial](latest/api/browser-window.md#winsetbackgroundmaterialmaterial-windows) for more information. @@ -352,6 +349,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `monospace` string (optional) - Defaults to `Courier New`. * `cursive` string (optional) - Defaults to `Script`. * `fantasy` string (optional) - Defaults to `Impact`. + * `math` string (optional) - Defaults to `Latin Modern Math`. * `defaultFontSize` Integer (optional) - Defaults to `16`. * `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`. * `minimumFontSize` Integer (optional) - Defaults to `0`. @@ -812,6 +810,10 @@ events. A `Integer` property representing the unique ID of the window. Each ID is unique among all `BrowserWindow` instances of the entire Electron application. +#### `win.tabbingIdentifier` _macOS_ _Readonly_ + +A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set. + #### `win.autoHideMenuBar` A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key. @@ -1842,6 +1844,10 @@ tabs in the window. Selects the next tab when native tabs are enabled and there are other tabs in the window. +#### `win.showAllTabs()` _macOS_ + +Shows or hides the tab overview when native tabs are enabled. + #### `win.mergeAllWindows()` _macOS_ Merges all windows into one window with multiple tabs when native tabs @@ -1865,16 +1871,12 @@ Adds a window as a tab on this window, after the tab for the window instance. #### `win.setVibrancy(type)` _macOS_ -* `type` string | null - Can be `appearance-based`, `light`, `dark`, `titlebar`, - `selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See +* `type` string | null - Can be `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See the [macOS documentation][vibrancy-docs] for more details. Adds a vibrancy effect to the browser window. Passing `null` or an empty string will remove the vibrancy effect on the window. -Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been -deprecated and will be removed in an upcoming version of macOS. - #### `win.setBackgroundMaterial(material)` _Windows_ * `material` string @@ -1962,8 +1964,8 @@ Throws an error if `browserView` is not attached to `win`. #### `win.getBrowserViews()` _Experimental_ -Returns `BrowserView[]` - an array of all BrowserViews that have been attached -with `addBrowserView` or `setBrowserView`. +Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached +with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array. **Note:** The BrowserView API is currently experimental and may change or be removed in future Electron releases. diff --git a/docs/latest/api/cookies.md b/docs/latest/api/cookies.md index 0916202ba..1e9467cee 100644 --- a/docs/latest/api/cookies.md +++ b/docs/latest/api/cookies.md @@ -29,7 +29,7 @@ session.defaultSession.cookies.get({}) }) // Query all cookies associated with a specific url. -session.defaultSession.cookies.get({ url: 'http://www.github.com' }) +session.defaultSession.cookies.get({ url: 'https://www.github.com' }) .then((cookies) => { console.log(cookies) }).catch((error) => { @@ -38,7 +38,7 @@ session.defaultSession.cookies.get({ url: 'http://www.github.com' }) // Set a cookie with the given cookie data; // may overwrite equivalent cookies if they exist. -const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' } +const cookie = { url: 'https://www.github.com', name: 'dummy_name', value: 'dummy' } session.defaultSession.cookies.set(cookie) .then(() => { // success diff --git a/docs/latest/api/ipc-renderer.md b/docs/latest/api/ipc-renderer.md index 66e0cd4e0..55b02eddc 100644 --- a/docs/latest/api/ipc-renderer.md +++ b/docs/latest/api/ipc-renderer.md @@ -192,7 +192,7 @@ ipcMain.on('port', (e, msg) => { For more information on using `MessagePort` and `MessageChannel`, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel). -### `ipcRenderer.sendTo(webContentsId, channel, ...args)` +### `ipcRenderer.sendTo(webContentsId, channel, ...args)` _Deprecated_ * `webContentsId` number * `channel` string diff --git a/docs/latest/api/menu-item.md b/docs/latest/api/menu-item.md index 72d7e98b8..f7f9f6b5a 100644 --- a/docs/latest/api/menu-item.md +++ b/docs/latest/api/menu-item.md @@ -21,7 +21,7 @@ See [`Menu`](latest/api/menu.md) for examples. * `menuItem` MenuItem * `browserWindow` [BrowserWindow](latest/api/browser-window.md) | undefined - This will not be defined if no window is open. * `event` [KeyboardEvent](latest/api/structures/keyboard-event.md) - * `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the + * `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the `click` property will be ignored. See [roles](#roles). * `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or `radio`. @@ -118,6 +118,7 @@ The following additional roles are available on _macOS_: * `toggleTabBar` - Map to the `toggleTabBar` action. * `selectNextTab` - Map to the `selectNextTab` action. * `selectPreviousTab` - Map to the `selectPreviousTab` action. +* `showAllTabs` - Map to the `showAllTabs` action. * `mergeAllWindows` - Map to the `mergeAllWindows` action. * `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action. * `window` - The submenu is a "Window" menu. @@ -166,7 +167,7 @@ A `string` indicating the type of the item. Can be `normal`, `separator`, `subme #### `menuItem.role` -A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` +A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` #### `menuItem.accelerator` diff --git a/docs/latest/api/session.md b/docs/latest/api/session.md index 1b8e58562..e75786ad0 100644 --- a/docs/latest/api/session.md +++ b/docs/latest/api/session.md @@ -20,7 +20,7 @@ property of [`WebContents`](latest/api/web-contents.md), or from the `session` m const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 600 }) -win.loadURL('http://github.com') +win.loadURL('https://github.com') const ses = win.webContents.session console.log(ses.getUserAgent()) diff --git a/docs/latest/api/structures/browser-window-options.md b/docs/latest/api/structures/browser-window-options.md index 184cddbd8..089c2ff7e 100644 --- a/docs/latest/api/structures/browser-window-options.md +++ b/docs/latest/api/structures/browser-window-options.md @@ -111,12 +111,9 @@ hide_title: false Windows, which adds standard window frame. Setting it to `false` will remove window shadow and window animations. Default is `true`. * `vibrancy` string (optional) _macOS_ - Add a type of vibrancy effect to - the window, only on macOS. Can be `appearance-based`, `light`, `dark`, - `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `medium-light`, - `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, - `tooltip`, `content`, `under-window`, or `under-page`. Please note that - `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are - deprecated and have been removed in macOS Catalina (10.15). + the window, only on macOS. Can be `appearance-based`, `titlebar`, `selection`, + `menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, + `tooltip`, `content`, `under-window`, or `under-page`. * `backgroundMaterial` string (optional) _Windows_ - Set the window's system-drawn background material, including behind the non-client area. Can be `auto`, `none`, `mica`, `acrylic` or `tabbed`. See [win.setBackgroundMaterial](latest/api/browser-window.md#winsetbackgroundmaterialmaterial-windows) for more information. @@ -199,6 +196,7 @@ hide_title: false * `monospace` string (optional) - Defaults to `Courier New`. * `cursive` string (optional) - Defaults to `Script`. * `fantasy` string (optional) - Defaults to `Impact`. + * `math` string (optional) - Defaults to `Latin Modern Math`. * `defaultFontSize` Integer (optional) - Defaults to `16`. * `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`. * `minimumFontSize` Integer (optional) - Defaults to `0`. diff --git a/docs/latest/api/structures/ipc-renderer-event.md b/docs/latest/api/structures/ipc-renderer-event.md index d338cf759..24b042024 100644 --- a/docs/latest/api/structures/ipc-renderer-event.md +++ b/docs/latest/api/structures/ipc-renderer-event.md @@ -8,9 +8,9 @@ hide_title: false # IpcRendererEvent Object extends `Event` * `sender` [IpcRenderer](latest/api/ipc-renderer.md) - The `IpcRenderer` instance that emitted the event originally -* `senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`. -* `senderIsMainFrame` boolean (optional) - Whether the message sent via [ipcRenderer.sendTo][ipc-renderer-sendto] was sent by the main frame. This is relevant when `nodeIntegrationInSubFrames` is enabled in the originating `webContents`. +* `senderId` Integer _Deprecated_ - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`. +* `senderIsMainFrame` boolean (optional) _Deprecated_ - Whether the message sent via [ipcRenderer.sendTo][ipc-renderer-sendto] was sent by the main frame. This is relevant when `nodeIntegrationInSubFrames` is enabled in the originating `webContents`. * `ports` [MessagePort][][] - A list of MessagePorts that were transferred with this message -[ipc-renderer-sendto]: latest/api/ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args +[ipc-renderer-sendto]: latest/api/ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args-deprecated [MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort diff --git a/docs/latest/api/structures/product.md b/docs/latest/api/structures/product.md index b3db67e04..a8a5ad319 100644 --- a/docs/latest/api/structures/product.md +++ b/docs/latest/api/structures/product.md @@ -10,8 +10,6 @@ hide_title: false * `productIdentifier` string - The string that identifies the product to the Apple App Store. * `localizedDescription` string - A description of the product. * `localizedTitle` string - The name of the product. -* `contentVersion` string - A string that identifies the version of the content. -* `contentLengths` number[] - The total size of the content, in bytes. * `price` number - The cost of the product in the local currency. * `formattedPrice` string - The locale formatted price of the product. * `currencyCode` string - 3 character code presenting a product's currency based on the ISO 4217 standard. diff --git a/docs/latest/api/structures/web-preferences.md b/docs/latest/api/structures/web-preferences.md index 3105c3404..e0477f20f 100644 --- a/docs/latest/api/structures/web-preferences.md +++ b/docs/latest/api/structures/web-preferences.md @@ -74,6 +74,7 @@ hide_title: false * `monospace` string (optional) - Defaults to `Courier New`. * `cursive` string (optional) - Defaults to `Script`. * `fantasy` string (optional) - Defaults to `Impact`. + * `math` string (optional) - Defaults to `Latin Modern Math`. * `defaultFontSize` Integer (optional) - Defaults to `16`. * `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`. * `minimumFontSize` Integer (optional) - Defaults to `0`. diff --git a/docs/latest/api/system-preferences.md b/docs/latest/api/system-preferences.md index 3d007e406..a0c5e2bb8 100644 --- a/docs/latest/api/system-preferences.md +++ b/docs/latest/api/system-preferences.md @@ -34,24 +34,6 @@ Returns: * `event` Event -### Event: 'inverted-color-scheme-changed' _Windows_ _Deprecated_ - -Returns: - -* `event` Event -* `invertedColorScheme` boolean - `true` if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is being used, `false` otherwise. - -**Deprecated:** Should use the new [`updated`](latest/api/native-theme.md#event-updated) event on the `nativeTheme` module. - -### Event: 'high-contrast-color-scheme-changed' _Windows_ _Deprecated_ - -Returns: - -* `event` Event -* `highContrastColorScheme` boolean - `true` if a high contrast theme is being used, `false` otherwise. - -**Deprecated:** Should use the new [`updated`](latest/api/native-theme.md#event-updated) event on the `nativeTheme` module. - ## Methods ### `systemPreferences.isSwipeTrackingFromScrollEventsEnabled()` _macOS_ @@ -298,7 +280,6 @@ This API is only available on macOS 10.14 Mojave or newer. * `window-frame` - Window frame. * `window-text` - Text in windows. * On **macOS** - * `alternate-selected-control-text` - The text on a selected surface in a list or table. _Deprecated_ * `control-background` - The background of a large interface element, such as a browser or table. * `control` - The surface of a control. * `control-text` -The text of a control that isn’t disabled. @@ -364,21 +345,6 @@ Returns `string` - Can be `dark`, `light` or `unknown`. Gets the macOS appearance setting that is currently applied to your application, maps to [NSApplication.effectiveAppearance](https://developer.apple.com/documentation/appkit/nsapplication/2967171-effectiveappearance?language=objc) -### `systemPreferences.getAppLevelAppearance()` _macOS_ _Deprecated_ - -Returns `string` | `null` - Can be `dark`, `light` or `unknown`. - -Gets the macOS appearance setting that you have declared you want for -your application, maps to [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc). -You can use the `setAppLevelAppearance` API to set this value. - -### `systemPreferences.setAppLevelAppearance(appearance)` _macOS_ _Deprecated_ - -* `appearance` string | null - Can be `dark` or `light` - -Sets the appearance setting for your application, this should override the -system default and override the value of `getEffectiveAppearance`. - ### `systemPreferences.canPromptTouchID()` _macOS_ Returns `boolean` - whether or not this device has the ability to use Touch ID. @@ -446,16 +412,6 @@ Returns an object with system animation settings. A `boolean` property which determines whether the app avoids using semitransparent backgrounds. This maps to [NSWorkspace.accessibilityDisplayShouldReduceTransparency](https://developer.apple.com/documentation/appkit/nsworkspace/1533006-accessibilitydisplayshouldreduce) -### `systemPreferences.appLevelAppearance` _macOS_ _Deprecated_ - -A `string` property that can be `dark`, `light` or `unknown`. It determines the macOS appearance setting for -your application. This maps to values in: [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc). Setting this will override the -system default as well as the value of `getEffectiveAppearance`. - -Possible values that can be set are `dark` and `light`, and possible return values are `dark`, `light`, and `unknown`. - -This property is only available on macOS 10.14 Mojave or newer. - ### `systemPreferences.effectiveAppearance` _macOS_ _Readonly_ A `string` property that can be `dark`, `light` or `unknown`. diff --git a/docs/latest/api/web-contents.md b/docs/latest/api/web-contents.md index f8e41aaf8..4db444583 100644 --- a/docs/latest/api/web-contents.md +++ b/docs/latest/api/web-contents.md @@ -20,7 +20,7 @@ the [`BrowserWindow`](latest/api/browser-window.md) object. An example of access const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 1500 }) -win.loadURL('http://github.com') +win.loadURL('https://github.com') const contents = win.webContents console.log(contents) @@ -891,7 +891,7 @@ const win = new BrowserWindow({ webPreferences: { offscreen: true } }) win.webContents.on('paint', (event, dirty, image) => { // updateBitmap(dirty, image.getBitmap()) }) -win.loadURL('http://github.com') +win.loadURL('https://github.com') ``` #### Event: 'devtools-reload-page' @@ -1069,7 +1069,7 @@ Returns `string` - The URL of the current web page. ```javascript const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 600 }) -win.loadURL('http://github.com').then(() => { +win.loadURL('https://github.com').then(() => { const currentURL = win.webContents.getURL() console.log(currentURL) }) @@ -1543,14 +1543,6 @@ If you would like the page to stay hidden, you should ensure that `stayHidden` i Returns `boolean` - Whether this page is being captured. It returns true when the capturer count is large then 0. -#### `contents.getPrinters()` _Deprecated_ - -Get the system printer list. - -Returns [`PrinterInfo[]`](latest/api/structures/printer-info.md) - -**Deprecated:** Should use the new [`contents.getPrintersAsync`](latest/api/web-contents.md#contentsgetprintersasync) API. - #### `contents.getPrintersAsync()` Get the system printer list. @@ -1629,7 +1621,7 @@ win.webContents.print(options, (success, errorType) => { * `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches). * `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches). * `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches). - * `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages. + * `pageRanges` string (optional) - Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages. * `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `` would generate span containing the title. * `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`. * `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. @@ -1649,7 +1641,7 @@ const path = require('node:path') const os = require('node:os') const win = new BrowserWindow() -win.loadURL('http://github.com') +win.loadURL('https://github.com') win.webContents.on('did-finish-load', () => { // Use default printing options @@ -1775,6 +1767,7 @@ app.whenReady().then(() => { In `undocked` mode it's possible to dock back. In `detach` mode it's not. * `activate` boolean (optional) - Whether to bring the opened devtools window to the foreground. The default is `true`. + * `title` string (optional) - A title for the DevTools window (only in `undocked` or `detach` mode). Opens the devtools. @@ -1795,6 +1788,18 @@ Returns `boolean` - Whether the devtools is opened. Returns `boolean` - Whether the devtools view is focused . +#### `contents.getDevToolsTitle()` + +Returns `string` - the current title of the DevTools window. This will only be visible +if DevTools is opened in `undocked` or `detach` mode. + +#### `contents.setDevToolsTitle(title)` + +* `title` string + +Changes the title of the DevTools window to `title`. This will only be visible if DevTools is +opened in `undocked` or `detach` mode. + #### `contents.toggleDevTools()` Toggles the developer tools. diff --git a/docs/latest/api/webview-tag.md b/docs/latest/api/webview-tag.md index da5e651a2..f49972380 100644 --- a/docs/latest/api/webview-tag.md +++ b/docs/latest/api/webview-tag.md @@ -119,7 +119,7 @@ The `src` attribute can also accept data URLs, such as ### `nodeintegration` ```html - + ``` A `boolean`. When this attribute is present the guest page in `webview` will have node @@ -130,7 +130,7 @@ page. ### `nodeintegrationinsubframes` ```html - + ``` A `boolean` for the experimental option for enabling NodeJS support in sub-frames such as iframes @@ -168,7 +168,7 @@ after this script has finished executing. ### `httpreferrer` ```html - + ``` A `string` that sets the referrer URL for the guest page. @@ -610,7 +610,7 @@ Prints `webview`'s web page. Same as `webContents.print([options])`. * `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches). * `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches). * `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches). - * `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages. + * `pageRanges` string (optional) - Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages. * `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `` would generate span containing the title. * `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`. * `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. diff --git a/docs/latest/breaking-changes.md b/docs/latest/breaking-changes.md index d6fb1e0c4..10a751680 100644 --- a/docs/latest/breaking-changes.md +++ b/docs/latest/breaking-changes.md @@ -28,6 +28,81 @@ macOS 10.13 (High Sierra) and macOS 10.14 (Mojave) are no longer supported by [C Older versions of Electron will continue to run on these operating systems, but macOS 10.15 (Catalina) or later will be required to run Electron v27.0.0 and higher. +### Deprecated: `ipcRenderer.sendTo()` + +The `ipcRenderer.sendTo()` API has been deprecated. It should be replaced by setting up a [`MessageChannel`](latest/tutorial/message-ports.md#setting-up-a-messagechannel-between-two-renderers) between the renderers. + +The `senderId` and `senderIsMainFrame` properties of `IpcRendererEvent` have been deprecated as well. + +### Removed: color scheme events in `systemPreferences` + +The following `systemPreferences` events have been removed: + +* `inverted-color-scheme-changed` +* `high-contrast-color-scheme-changed` + +Use the new `updated` event on the `nativeTheme` module instead. + +```js +// Removed +systemPreferences.on('inverted-color-scheme-changed', () => { /* ... */ }) +systemPreferences.on('high-contrast-color-scheme-changed', () => { /* ... */ }) + +// Replace with +nativeTheme.on('updated', () => { /* ... */ }) +``` + +### Removed: `webContents.getPrinters` + +The `webContents.getPrinters` method has been removed. Use +`webContents.getPrintersAsync` instead. + +```js +const w = new BrowserWindow({ show: false }) + +// Removed +console.log(w.webContents.getPrinters()) +// Replace with +w.webContents.getPrintersAsync().then((printers) => { + console.log(printers) +}) +``` + +### Removed: `systemPreferences.{get,set}AppLevelAppearance` and `systemPreferences.appLevelAppearance` + +The `systemPreferences.getAppLevelAppearance` and `systemPreferences.setAppLevelAppearance` +methods have been removed, as well as the `systemPreferences.appLevelAppearance` property. +Use the `nativeTheme` module instead. + +```js +// Removed +systemPreferences.getAppLevelAppearance() +// Replace with +nativeTheme.shouldUseDarkColors + +// Removed +systemPreferences.appLevelAppearance +// Replace with +nativeTheme.shouldUseDarkColors + +// Removed +systemPreferences.setAppLevelAppearance('dark') +// Replace with +nativeTheme.themeSource = 'dark' +``` + +### Removed: `alternate-selected-control-text` value for `systemPreferences.getColor` + +The `alternate-selected-control-text` value for `systemPreferences.getColor` +has been removed. Use `selected-content-background` instead. + +```js +// Removed +systemPreferences.getColor('alternate-selected-control-text') +// Replace with +systemPreferences.getColor('selected-content-background') +``` + ## Planned Breaking API Changes (26.0) ### Deprecated: `webContents.getPrinters` diff --git a/docs/latest/development/build-instructions-windows.md b/docs/latest/development/build-instructions-windows.md index 116619a65..5f1c5cbb1 100644 --- a/docs/latest/development/build-instructions-windows.md +++ b/docs/latest/development/build-instructions-windows.md @@ -30,7 +30,7 @@ store from `.pdb` files. SDK, open Visual Studio Installer, select `Modify` → `Individual Components`, scroll down and select the appropriate Windows SDK to install. Another option would be to look at the - [Windows SDK and emulator archive](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive) + [Windows SDK and emulator archive](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/) and download the standalone version of the SDK respectively. * The SDK Debugging Tools must also be installed. If the Windows 10 SDK was installed via the Visual Studio installer, then they can be installed by going to: @@ -39,7 +39,7 @@ store from `.pdb` files. Or, you can download the standalone SDK installer and use it to install the Debugging Tools. If you don't currently have a Windows installation, -[dev.microsoftedge.com](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/) +[developer.microsoft.com](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/) has timebombed versions of Windows that you can use to build Electron. Building Electron is done entirely with command-line scripts and cannot be done diff --git a/docs/latest/development/creating-api.md b/docs/latest/development/creating-api.md index 7b4595578..a9cc43f46 100644 --- a/docs/latest/development/creating-api.md +++ b/docs/latest/development/creating-api.md @@ -136,9 +136,9 @@ void Initialize(v8::Local exports, In the [`typings/internal-ambient.d.ts`](https://github.com/electron/electron/blob/main/typings/internal-ambient.d.ts) file, we need to append a new property onto the `Process` interface like so: -```ts title='typings/internal-ambient.d.ts' +```ts title='typings/internal-ambient.d.ts' @ts-nocheck interface Process { - _linkedBinding(name: 'electron_browser_{api_name}', Electron.ApiName); + _linkedBinding(name: 'electron_browser_{api_name}'): Electron.ApiName; } ``` @@ -171,7 +171,7 @@ An example of the contents of this file can be found [here](https://github.com/e Add your module to the module list found at `"lib/browser/api/module-list.ts"` like so: -```typescript title='lib/browser/api/module-list.ts' +```typescript title='lib/browser/api/module-list.ts' @ts-nocheck export const browserModuleList: ElectronInternal.ModuleEntry[] = [ { name: 'apiName', loader: () => require('./api-name') }, ]; diff --git a/docs/latest/development/debugging-on-windows.md b/docs/latest/development/debugging-on-windows.md index ba5a11cf8..a283abc7c 100644 --- a/docs/latest/development/debugging-on-windows.md +++ b/docs/latest/development/debugging-on-windows.md @@ -95,7 +95,7 @@ is doing to the operating system, it can be a valuable resource. For an introduction to ProcMon's basic and advanced debugging features, go check out [this video tutorial][procmon-instructions] provided by Microsoft. -[sys-internals]: https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx +[sys-internals]: https://learn.microsoft.com/en-us/sysinternals/downloads/procmon [procmon-instructions]: https://learn.microsoft.com/en-us/shows/defrag-tools/4-process-monitor ## Using WinDbg diff --git a/docs/latest/development/issues.md b/docs/latest/development/issues.md index c9db2a62e..992a680c6 100644 --- a/docs/latest/development/issues.md +++ b/docs/latest/development/issues.md @@ -31,7 +31,7 @@ contribute: ## Asking for General Help -[The Electron website](https://electronjs.org/community) has a +[The Electron website](https://www.electronjs.org/community) has a list of resources for getting programming help, reporting security issues, contributing, and more. Please use the issue tracker for bugs only! diff --git a/docs/latest/fiddles/features/dark-mode/main.js b/docs/latest/fiddles/features/dark-mode/main.js index 34c0211a4..f28419afd 100644 --- a/docs/latest/fiddles/features/dark-mode/main.js +++ b/docs/latest/fiddles/features/dark-mode/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron') -const path = require('path') +const path = require('node:path') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/latest/fiddles/features/drag-and-drop/main.js b/docs/latest/fiddles/features/drag-and-drop/main.js index db617ba27..9ee443196 100644 --- a/docs/latest/fiddles/features/drag-and-drop/main.js +++ b/docs/latest/fiddles/features/drag-and-drop/main.js @@ -1,7 +1,7 @@ const { app, BrowserWindow, ipcMain } = require('electron') -const path = require('path') -const fs = require('fs') -const https = require('https') +const path = require('node:path') +const fs = require('node:fs') +const https = require('node:https') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/latest/fiddles/features/offscreen-rendering/main.js b/docs/latest/fiddles/features/offscreen-rendering/main.js index e4a25a47c..daf4306b8 100644 --- a/docs/latest/fiddles/features/offscreen-rendering/main.js +++ b/docs/latest/fiddles/features/offscreen-rendering/main.js @@ -1,6 +1,6 @@ const { app, BrowserWindow } = require('electron') -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') app.disableHardwareAcceleration() diff --git a/docs/latest/fiddles/features/recent-documents/main.js b/docs/latest/fiddles/features/recent-documents/main.js index d11a5bcc6..628f01f0e 100644 --- a/docs/latest/fiddles/features/recent-documents/main.js +++ b/docs/latest/fiddles/features/recent-documents/main.js @@ -1,6 +1,6 @@ const { app, BrowserWindow } = require('electron') -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/latest/fiddles/features/represented-file/main.js b/docs/latest/fiddles/features/represented-file/main.js index 387047b5d..9b107a09d 100644 --- a/docs/latest/fiddles/features/represented-file/main.js +++ b/docs/latest/fiddles/features/represented-file/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow } = require('electron') -const os = require('os') +const os = require('node:os') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/latest/fiddles/features/web-bluetooth/main.js b/docs/latest/fiddles/features/web-bluetooth/main.js index a8ed8f572..0821de287 100644 --- a/docs/latest/fiddles/features/web-bluetooth/main.js +++ b/docs/latest/fiddles/features/web-bluetooth/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow, ipcMain } = require('electron') -const path = require('path') +const path = require('node:path') let bluetoothPinCallback let selectBluetoothCallback diff --git a/docs/latest/fiddles/ipc/pattern-1/main.js b/docs/latest/fiddles/ipc/pattern-1/main.js index 567baf402..c43937eda 100644 --- a/docs/latest/fiddles/ipc/pattern-1/main.js +++ b/docs/latest/fiddles/ipc/pattern-1/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow, ipcMain } = require('electron') -const path = require('path') +const path = require('node:path') function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/docs/latest/fiddles/ipc/pattern-2/main.js b/docs/latest/fiddles/ipc/pattern-2/main.js index 4cf3aab44..187a6d83b 100644 --- a/docs/latest/fiddles/ipc/pattern-2/main.js +++ b/docs/latest/fiddles/ipc/pattern-2/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow, ipcMain, dialog } = require('electron') -const path = require('path') +const path = require('node:path') async function handleFileOpen () { const { canceled, filePaths } = await dialog.showOpenDialog() diff --git a/docs/latest/fiddles/ipc/pattern-3/main.js b/docs/latest/fiddles/ipc/pattern-3/main.js index 4c2334dfb..91c0c1a64 100644 --- a/docs/latest/fiddles/ipc/pattern-3/main.js +++ b/docs/latest/fiddles/ipc/pattern-3/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow, Menu, ipcMain } = require('electron') -const path = require('path') +const path = require('node:path') function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/docs/latest/fiddles/ipc/webview-new-window/main.js b/docs/latest/fiddles/ipc/webview-new-window/main.js index cab3b1ec1..a76c1434c 100644 --- a/docs/latest/fiddles/ipc/webview-new-window/main.js +++ b/docs/latest/fiddles/ipc/webview-new-window/main.js @@ -1,6 +1,6 @@ // Modules to control application life and create native browser window const { app, BrowserWindow } = require('electron') -const path = require('path') +const path = require('node:path') function createWindow () { // Create the browser window. diff --git a/docs/latest/fiddles/media/screenshot/take-screenshot/main.js b/docs/latest/fiddles/media/screenshot/take-screenshot/main.js index be8ed9832..cb09498a0 100644 --- a/docs/latest/fiddles/media/screenshot/take-screenshot/main.js +++ b/docs/latest/fiddles/media/screenshot/take-screenshot/main.js @@ -1,4 +1,4 @@ -const { BrowserWindow, app, screen, ipcMain } = require('electron') +const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron') let mainWindow = null @@ -6,12 +6,17 @@ ipcMain.handle('get-screen-size', () => { return screen.getPrimaryDisplay().workAreaSize }) +ipcMain.handle('get-sources', (event, options) => { + return desktopCapturer.getSources(options) +}) + function createWindow () { const windowOptions = { width: 600, height: 300, title: 'Take a Screenshot', webPreferences: { + contextIsolation: false, nodeIntegration: true } } diff --git a/docs/latest/fiddles/media/screenshot/take-screenshot/renderer.js b/docs/latest/fiddles/media/screenshot/take-screenshot/renderer.js index e7988f506..fd615325b 100644 --- a/docs/latest/fiddles/media/screenshot/take-screenshot/renderer.js +++ b/docs/latest/fiddles/media/screenshot/take-screenshot/renderer.js @@ -1,8 +1,8 @@ -const { desktopCapturer, shell, ipcRenderer } = require('electron') +const { shell, ipcRenderer } = require('electron') -const fs = require('fs') -const os = require('os') -const path = require('path') +const fs = require('node:fs').promises +const os = require('node:os') +const path = require('node:path') const screenshot = document.getElementById('screen-shot') const screenshotMsg = document.getElementById('screenshot-path') @@ -12,24 +12,19 @@ screenshot.addEventListener('click', async (event) => { const thumbSize = await determineScreenShotSize() const options = { types: ['screen'], thumbnailSize: thumbSize } - desktopCapturer.getSources(options, (error, sources) => { - if (error) return console.log(error) + const sources = await ipcRenderer.invoke('get-sources', options) + for (const source of sources) { + const sourceName = source.name.toLowerCase() + if (sourceName === 'entire screen' || sourceName === 'screen 1') { + const screenshotPath = path.join(os.tmpdir(), 'screenshot.png') - sources.forEach((source) => { - const sourceName = source.name.toLowerCase() - if (sourceName === 'entire screen' || sourceName === 'screen 1') { - const screenshotPath = path.join(os.tmpdir(), 'screenshot.png') + await fs.writeFile(screenshotPath, source.thumbnail.toPNG()) + shell.openExternal(`file://${screenshotPath}`) - fs.writeFile(screenshotPath, source.thumbnail.toPNG(), (error) => { - if (error) return console.log(error) - shell.openExternal(`file://${screenshotPath}`) - - const message = `Saved screenshot to: ${screenshotPath}` - screenshotMsg.textContent = message - }) - } - }) - }) + const message = `Saved screenshot to: ${screenshotPath}` + screenshotMsg.textContent = message + } + } }) async function determineScreenShotSize () { diff --git a/docs/latest/fiddles/menus/customize-menus/index.html b/docs/latest/fiddles/menus/customize-menus/index.html index 9d077d35d..798745c17 100644 --- a/docs/latest/fiddles/menus/customize-menus/index.html +++ b/docs/latest/fiddles/menus/customize-menus/index.html @@ -21,7 +21,7 @@

Open the - full API documentation(opens in new window)ProTip