@itwin/core-electron 5.0.0-dev.8 → 5.0.0-dev.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,53 @@
1
1
  # Change Log - @itwin/core-electron
2
2
 
3
- This log was last generated on Thu, 14 Nov 2024 18:13:56 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 11 Mar 2025 15:27:53 GMT and should not be manually modified.
4
+
5
+ ## 4.10.10
6
+ Tue, 11 Mar 2025 15:25:11 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 4.10.9
11
+ Tue, 11 Mar 2025 05:17:33 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 4.10.8
16
+ Thu, 06 Mar 2025 14:13:37 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 4.10.7
21
+ Tue, 18 Feb 2025 17:27:03 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 4.10.6
26
+ Fri, 24 Jan 2025 08:02:40 GMT
27
+
28
+ _Version update only_
29
+
30
+ ## 4.10.5
31
+ Tue, 21 Jan 2025 21:56:45 GMT
32
+
33
+ _Version update only_
34
+
35
+ ## 4.10.4
36
+ Mon, 13 Jan 2025 14:06:43 GMT
37
+
38
+ _Version update only_
39
+
40
+ ## 4.10.3
41
+ Mon, 06 Jan 2025 14:00:13 GMT
42
+
43
+ _Version update only_
44
+
45
+ ## 4.10.2
46
+ Thu, 21 Nov 2024 15:22:20 GMT
47
+
48
+ ### Updates
49
+
50
+ - Bumped `username` to `7.0.0`
4
51
 
5
52
  ## 4.10.1
6
53
  Thu, 14 Nov 2024 18:11:00 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronHost.d.ts","sourceRoot":"","sources":["../../../src/backend/ElectronHost.ts"],"names":[],"mappings":"AAKA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA+B,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC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AAED;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAc;IACjC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAU;IAC3C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAwB;IAChD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA0B;IAC1D,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAgB;IAC3C,OAAc,gBAAgB,EAAE,MAAM,CAAC;IACvC,OAAc,WAAW,EAAE,MAAM,CAAC;IAClC,OAAc,WAAW,EAAE,MAAM,CAAC;IAClC,OAAc,SAAS,EAAE,gBAAgB,CAAC;IAC1C,WAAkB,OAAO,qBAAsC;IAC/D,WAAkB,GAAG,iBAAkC;IACvD,WAAkB,QAAQ,0BAA6B;IAEvD,OAAO;IAEP;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAkB5C,OAAO,CAAC,MAAM,CAAC,WAAW;IAiD1B,qDAAqD;IACrD,WAAkB,UAAU,8BAA+B;IAE3D;;OAEG;WACW,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS;IAKzG,wFAAwF;WAC1E,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIhF;;;OAGG;WACiB,cAAc,CAAC,aAAa,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC5F,WAAkB,OAAO,YAAsC;IAE/D;;;;;;OAMG;WACiB,OAAO,CAAC,IAAI,CAAC,EAAE,gBAAgB;CAmCpD"}
@@ -36,6 +36,15 @@ class ElectronIpc {
36
36
  * @beta
37
37
  */
38
38
  class ElectronHost {
39
+ static _ipc;
40
+ static _developmentServer;
41
+ static _electron;
42
+ static _electronFrontend = "electron://frontend/";
43
+ static _mainWindow;
44
+ static webResourcesPath;
45
+ static appIconPath;
46
+ static frontendURL;
47
+ static rpcConfig;
39
48
  static get ipcMain() { return this._electron?.ipcMain; }
40
49
  static get app() { return this._electron?.app; }
41
50
  static get electron() { return this._electron; }
@@ -199,7 +208,6 @@ class ElectronHost {
199
208
  }
200
209
  }
201
210
  exports.ElectronHost = ElectronHost;
202
- ElectronHost._electronFrontend = "electron://frontend/";
203
211
  class ElectronDialogHandler extends core_backend_1.IpcHandler {
204
212
  get channelName() { return ElectronIpcInterface_1.electronIpcStrings.dialogChannel; }
205
213
  async callDialog(method, ...args) {
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronHost.js","sourceRoot":"","sources":["../../../src/backend/ElectronHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAU/F,yBAAyB;AACzB,6BAA6B;AAC7B,sDAAgF;AAChF,sDAAsF;AACtF,oDAA0I;AAC1I,qEAA4F;AAC5F,yEAAwF;AAExF,sEAAsE;AAEtE,MAAM,WAAW;IACR,WAAW,CAAC,OAAe,EAAE,QAAqB;QACvD,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtE,CAAC;IACM,cAAc,CAAC,OAAe,EAAE,QAAqB;QAC1D,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IACM,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QACzC,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;QACjG,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IACM,MAAM,CAAC,OAAe,EAAE,QAAoD;QACjF,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAA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C,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,IAA6B,EAAE,KAAa,GAAG;IAC/D,IAAI,OAAuB,CAAC;IAC5B,OAAO,UAAqB,GAAG,IAAW;QACxC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Main\r\n */\r\n\r\n// Note: only import *types* from electron so this file can be imported by apps that sometimes use Electron and sometimes not.\r\nimport type { BrowserWindow, BrowserWindowConstructorOptions, WebPreferences } from \"electron\";\r\nimport type * as ElectronModule from \"electron\";\r\n\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { BeDuration, IModelStatus, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport { IModelError, IpcListener, IpcSocketBackend, RemoveFunction, RpcConfiguration, RpcInterfaceDefinition } from \"@itwin/core-common\";\r\nimport { ElectronRpcConfiguration, ElectronRpcManager } from \"../common/ElectronRpcManager\";\r\nimport { DialogModuleMethod, electronIpcStrings } from \"../common/ElectronIpcInterface\";\r\n\r\n// cSpell:ignore signin devserver webcontents copyfile unmaximize eopt\r\n\r\nclass ElectronIpc implements IpcSocketBackend {\r\n public addListener(channel: string, listener: IpcListener): RemoveFunction {\r\n ElectronHost.ipcMain.addListener(channel, listener);\r\n return () => ElectronHost.ipcMain.removeListener(channel, listener);\r\n }\r\n public removeListener(channel: string, listener: IpcListener) {\r\n ElectronHost.ipcMain.removeListener(channel, listener);\r\n }\r\n public send(channel: string, ...args: any[]): void {\r\n const window = ElectronHost.mainWindow ?? ElectronHost.electron.BrowserWindow.getAllWindows()[0];\r\n window?.webContents.send(channel, ...args);\r\n }\r\n public handle(channel: string, listener: (evt: any, ...args: any[]) => Promise<any>): RemoveFunction {\r\n ElectronHost.ipcMain.removeHandler(channel); // make sure there's not already a handler registered\r\n ElectronHost.ipcMain.handle(channel, listener);\r\n return () => ElectronHost.ipcMain.removeHandler(channel);\r\n }\r\n}\r\n\r\n/**\r\n * Options for [[ElectronHost.startup]]\r\n * @beta\r\n */\r\nexport interface ElectronHostOptions {\r\n /** the path to find web resources */\r\n webResourcesPath?: string;\r\n /** filename for the app's icon, relative to [[webResourcesPath]] */\r\n iconName?: string;\r\n /** name of frontend url to open. */\r\n frontendURL?: string;\r\n /** use a development server rather than the \"electron\" protocol for loading frontend (see https://www.electronjs.org/docs/api/protocol) */\r\n developmentServer?: boolean;\r\n /** port number for development server. Default is 3000 */\r\n frontendPort?: number;\r\n /** list of RPC interface definitions to register */\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n /** list of [IpcHandler]($backend) classes to register */\r\n ipcHandlers?: (typeof IpcHandler)[];\r\n}\r\n\r\n/** @beta */\r\nexport interface ElectronHostOpts extends NativeHostOpts {\r\n electronHost?: ElectronHostOptions;\r\n}\r\n\r\n/** @beta */\r\nexport interface ElectronHostWindowOptions extends BrowserWindowConstructorOptions {\r\n /** Name used to construct key for saving window size, position and maximize status to the settings store */\r\n storeWindowName?: string;\r\n /** The style of window title bar. Default is `default`. */\r\n titleBarStyle?: (\"default\" | \"hidden\" | \"hiddenInset\" | \"customButtonsOnHover\");\r\n /** Web page settings */\r\n webPreferences?: Omit<WebPreferences, \"preload\" | \"experimentalFeatures\" | \"nodeIntegration\" | \"contextIsolation\" | \"sandbox\" | \"nodeIntegrationInWorker\" | \"nodeIntegrationInSubFrames\">;\r\n}\r\n\r\n/** the size and position of a window as stored in the settings file.\r\n * @beta\r\n */\r\nexport interface WindowSizeAndPositionProps {\r\n width: number;\r\n height: number;\r\n x: number;\r\n y: number;\r\n}\r\n\r\n/**\r\n * The backend for Electron-based desktop applications\r\n * @beta\r\n */\r\nexport class ElectronHost {\r\n private static _ipc: ElectronIpc;\r\n private static _developmentServer: boolean;\r\n private static _electron: typeof ElectronModule;\r\n private static _electronFrontend = \"electron://frontend/\";\r\n private static _mainWindow?: BrowserWindow;\r\n public static webResourcesPath: string;\r\n public static appIconPath: string;\r\n public static frontendURL: string;\r\n public static rpcConfig: RpcConfiguration;\r\n public static get ipcMain() { return this._electron?.ipcMain; }\r\n public static get app() { return this._electron?.app; }\r\n public static get electron() { return this._electron; }\r\n\r\n private constructor() { }\r\n\r\n /**\r\n * Converts an \"electron://frontend/\" URL to an \"file://{absolute file path}\" URL.\r\n *\r\n * We use this protocol in production builds because our frontend must be built with absolute URLs,\r\n * however, since we're loading everything directly from the install directory, we cannot know the\r\n * absolute path at build time.\r\n */\r\n private static transformElectronUrlToFileUrl(requestedUrl: string): string {\r\n // Note that the \"frontend/\" path is arbitrary - this is just so we can handle *some* relative URLs...\r\n let assetPath = requestedUrl.substring(this._electronFrontend.length);\r\n if (assetPath.length === 0)\r\n assetPath = \"index.html\";\r\n assetPath = path.normalize(`${this.webResourcesPath}/${assetPath}`);\r\n // File protocols don't follow symlinks, so we need to resolve this to a real path.\r\n // However, if the file doesn't exist, it's fine to return an invalid path here - the request will just fail with net::ERR_FILE_NOT_FOUND\r\n try {\r\n assetPath = fs.realpathSync(assetPath);\r\n } catch {\r\n // console.warn(`WARNING: Frontend requested \"${requestedUrl}\", but ${assetPath} does not exist`);\r\n }\r\n if (!assetPath.startsWith(this.webResourcesPath))\r\n throw new Error(`Access to files outside installation directory (${this.webResourcesPath}) is prohibited`);\r\n return `file://${assetPath}`;\r\n }\r\n\r\n private static _openWindow(options?: ElectronHostWindowOptions) {\r\n const webPreferences: WebPreferences = {\r\n ...options?.webPreferences,\r\n\r\n // These web preference variables should not be overriden by the ElectronHostWindowOptions\r\n preload: require.resolve(/* webpack: copyfile */\"./ElectronPreload.js\"),\r\n experimentalFeatures: false,\r\n nodeIntegration: false,\r\n contextIsolation: true,\r\n sandbox: true,\r\n nodeIntegrationInWorker: false,\r\n nodeIntegrationInSubFrames: false,\r\n };\r\n\r\n const opts: BrowserWindowConstructorOptions = {\r\n ...options,\r\n autoHideMenuBar: true,\r\n icon: this.appIconPath,\r\n webPreferences,\r\n };\r\n\r\n this._mainWindow = new (this.electron.BrowserWindow)(opts);\r\n ElectronRpcConfiguration.targetWindowId = this._mainWindow.id;\r\n this._mainWindow.on(\"closed\", () => this._mainWindow = undefined);\r\n this._mainWindow.loadURL(this.frontendURL); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n /** Monitors and saves main window size, position and maximized state */\r\n if (options?.storeWindowName) {\r\n const mainWindow = this._mainWindow;\r\n const windowName = options.storeWindowName;\r\n const saveWindowPosition = () => {\r\n const bounds: WindowSizeAndPositionProps = mainWindow.getBounds();\r\n NativeHost.settingsStore.setData(`windowSizeAndPos-${windowName}`, JSON.stringify(bounds));\r\n };\r\n const saveMaximized = (maximized: boolean) => {\r\n NativeHost.settingsStore.setData(`windowMaximized-${windowName}`, maximized);\r\n };\r\n\r\n mainWindow.on(\"maximize\", () => saveMaximized(true));\r\n mainWindow.on(\"unmaximize\", () => saveMaximized(false));\r\n saveMaximized(mainWindow.isMaximized());\r\n\r\n const debouncedSaveWindowSizeAndPos = debounce(() => saveWindowPosition());\r\n mainWindow.on(\"resize\", () => debouncedSaveWindowSizeAndPos());\r\n mainWindow.on(\"move\", () => debouncedSaveWindowSizeAndPos());\r\n saveWindowPosition();\r\n }\r\n }\r\n\r\n /** The \"main\" BrowserWindow for this application. */\r\n public static get mainWindow() { return this._mainWindow; }\r\n\r\n /**\r\n * Gets window size and position for a window, by name, from settings file, if present.\r\n */\r\n public static getWindowSizeAndPositionSetting(windowName: string): WindowSizeAndPositionProps | undefined {\r\n const saved = NativeHost.settingsStore.getString(`windowSizeAndPos-${windowName}`);\r\n return saved ? JSON.parse(saved) as WindowSizeAndPositionProps : undefined;\r\n }\r\n\r\n /** Gets \"window maximized\" flag for a window, by name, from settings file if present */\r\n public static getWindowMaximizedSetting(windowName: string): boolean | undefined {\r\n return NativeHost.settingsStore.getBoolean(`windowMaximized-${windowName}`);\r\n }\r\n\r\n /**\r\n * Open the main Window when the app is ready.\r\n * @param windowOptions Options for constructing the main BrowserWindow. See: https://electronjs.org/docs/api/browser-window#new-browserwindowoptions\r\n */\r\n public static async openMainWindow(windowOptions?: ElectronHostWindowOptions): Promise<void> {\r\n const app = this.app;\r\n // quit the application when all windows are closed (unless we're running on MacOS)\r\n app.on(\"window-all-closed\", () => {\r\n if (process.platform !== \"darwin\")\r\n app.quit();\r\n });\r\n\r\n // re-open the main window if it was closed and the app is re-activated (this is the normal MacOS behavior)\r\n app.on(\"activate\", () => {\r\n if (!this._mainWindow)\r\n this._openWindow(windowOptions);\r\n });\r\n\r\n if (this._developmentServer) {\r\n // Occasionally, the electron backend may start before the webpack devserver has even started.\r\n // If this happens, we'll just retry and keep reloading the page.\r\n app.on(\"web-contents-created\", (_e, webcontents) => {\r\n webcontents.on(\"did-fail-load\", async (_event, errorCode, _errorDescription, _validatedURL, isMainFrame) => {\r\n // errorCode -102 is CONNECTION_REFUSED - see https://cs.chromium.org/chromium/src/net/base/net_error_list.h\r\n if (isMainFrame && errorCode === -102) {\r\n await BeDuration.wait(100);\r\n webcontents.reload();\r\n }\r\n });\r\n });\r\n }\r\n\r\n await app.whenReady();\r\n\r\n if (!this._developmentServer) {\r\n // handle any \"electron://\" requests and redirect them to \"file://\" URLs\r\n this.electron.protocol.handle(\"electron\", async (request) => ElectronHost.electron.net.fetch(this.transformElectronUrlToFileUrl(request.url)));\r\n }\r\n\r\n this._openWindow(windowOptions);\r\n }\r\n\r\n public static get isValid() { return this._ipc !== undefined; }\r\n\r\n /**\r\n * Initialize the backend of an Electron app.\r\n * This method configures the backend for all of the inter-process communication (RPC and IPC) for an\r\n * Electron app. It should be called from your Electron main function.\r\n * @param opts Options that control aspects of your backend.\r\n * @note This method must only be called from the backend of an Electron app (i.e. when [ProcessDetector.isElectronAppBackend]($bentley) is `true`).\r\n */\r\n public static async startup(opts?: ElectronHostOpts) {\r\n if (!ProcessDetector.isElectronAppBackend)\r\n throw new Error(\"Not running under Electron\");\r\n\r\n if (!this.isValid) {\r\n this._electron = require(\"electron\"); // eslint-disable-line @typescript-eslint/no-require-imports\r\n this._ipc = new ElectronIpc();\r\n const app = this.app;\r\n if (!app.isReady())\r\n this.electron.protocol.registerSchemesAsPrivileged([{\r\n scheme: \"electron\",\r\n privileges: {\r\n standard: true,\r\n secure: true,\r\n supportFetchAPI: true,\r\n },\r\n }]);\r\n const eopt = opts?.electronHost;\r\n this._developmentServer = eopt?.developmentServer ?? false;\r\n const frontendPort = eopt?.frontendPort ?? 3000;\r\n this.webResourcesPath = eopt?.webResourcesPath ?? \"\";\r\n this.frontendURL = eopt?.frontendURL ?? (this._developmentServer ? `http://localhost:${frontendPort}` : `${this._electronFrontend}index.html`);\r\n this.appIconPath = path.join(this.webResourcesPath, eopt?.iconName ?? \"appicon.ico\");\r\n this.rpcConfig = ElectronRpcManager.initializeBackend(this._ipc, eopt?.rpcInterfaces);\r\n }\r\n\r\n opts = opts ?? {};\r\n opts.ipcHost = opts.ipcHost ?? {};\r\n opts.ipcHost.socket = this._ipc;\r\n await NativeHost.startup(opts);\r\n if (IpcHost.isValid) {\r\n ElectronDialogHandler.register();\r\n opts.electronHost?.ipcHandlers?.forEach((ipc) => ipc.register());\r\n }\r\n }\r\n}\r\n\r\nclass ElectronDialogHandler extends IpcHandler {\r\n public get channelName() { return electronIpcStrings.dialogChannel; }\r\n public async callDialog(method: DialogModuleMethod, ...args: any) {\r\n const dialog = ElectronHost.electron.dialog;\r\n const dialogMethod = dialog[method] as (...args: any[]) => any;\r\n if (typeof dialogMethod !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `illegal electron dialog method`);\r\n\r\n return dialogMethod.call(dialog, ...args);\r\n }\r\n}\r\n\r\nfunction debounce(func: (...args: any[]) => any, ms: number = 200) {\r\n let timeout: NodeJS.Timeout;\r\n return function (this: any, ...args: any[]) {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(() => {\r\n func.apply(this, args);\r\n }, ms);\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ElectronHost.js","sourceRoot":"","sources":["../../../src/backend/ElectronHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAU/F,yBAAyB;AACzB,6BAA6B;AAC7B,sDAAgF;AAChF,sDAAsF;AACtF,oDAA0I;AAC1I,qEAA4F;AAC5F,yEAAwF;AAExF,sEAAsE;AAEtE,MAAM,WAAW;IACR,WAAW,CAChB,OAAe,EACf,QAA4C;QAE5C,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtE,CAAC;IACM,cAAc,CAAC,OAAe,EAAE,QAAqB;QAC1D,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IACM,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QACzC,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;QACjG,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IACM,MAAM,CAAC,OAAe,EAAE,QAAoD;QACjF,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,qDAAqD;QACl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,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAA4B,CAAC;QAC/D,IAAI,OAAO,YAAY,KAAK,UAAU;YACpC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,gBAAgB,EAAE,gCAAgC,CAAC,CAAC;QAEzF,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,IAA6B,EAAE,KAAa,GAAG;IAC/D,IAAI,OAAuB,CAAC;IAC5B,OAAO,UAAqB,GAAG,IAAW;QACxC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Main\r\n */\r\n\r\n// Note: only import *types* from electron so this file can be imported by apps that sometimes use Electron and sometimes not.\r\nimport type { BrowserWindow, BrowserWindowConstructorOptions, WebPreferences } from \"electron\";\r\nimport type * as ElectronModule from \"electron\";\r\n\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { BeDuration, IModelStatus, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport { IModelError, IpcListener, IpcSocketBackend, RemoveFunction, RpcConfiguration, RpcInterfaceDefinition } from \"@itwin/core-common\";\r\nimport { ElectronRpcConfiguration, ElectronRpcManager } from \"../common/ElectronRpcManager\";\r\nimport { DialogModuleMethod, electronIpcStrings } from \"../common/ElectronIpcInterface\";\r\n\r\n// cSpell:ignore signin devserver webcontents copyfile unmaximize eopt\r\n\r\nclass ElectronIpc implements IpcSocketBackend {\r\n public addListener(\r\n channel: string,\r\n listener: (evt: any, ...args: any[]) => void, // There is mismatch between IPC Event and Electron.IpcMainEvent. Defining `evt` as any as a temporary fix\r\n ): RemoveFunction {\r\n ElectronHost.ipcMain.addListener(channel, listener);\r\n return () => ElectronHost.ipcMain.removeListener(channel, listener);\r\n }\r\n public removeListener(channel: string, listener: IpcListener) {\r\n ElectronHost.ipcMain.removeListener(channel, listener);\r\n }\r\n public send(channel: string, ...args: any[]): void {\r\n const window = ElectronHost.mainWindow ?? ElectronHost.electron.BrowserWindow.getAllWindows()[0];\r\n window?.webContents.send(channel, ...args);\r\n }\r\n public handle(channel: string, listener: (evt: any, ...args: any[]) => Promise<any>): RemoveFunction {\r\n ElectronHost.ipcMain.removeHandler(channel); // make sure there's not already a handler registered\r\n ElectronHost.ipcMain.handle(channel, listener);\r\n return () => ElectronHost.ipcMain.removeHandler(channel);\r\n }\r\n}\r\n\r\n/**\r\n * Options for [[ElectronHost.startup]]\r\n * @beta\r\n */\r\nexport interface ElectronHostOptions {\r\n /** the path to find web resources */\r\n webResourcesPath?: string;\r\n /** filename for the app's icon, relative to [[webResourcesPath]] */\r\n iconName?: string;\r\n /** name of frontend url to open. */\r\n frontendURL?: string;\r\n /** use a development server rather than the \"electron\" protocol for loading frontend (see https://www.electronjs.org/docs/api/protocol) */\r\n developmentServer?: boolean;\r\n /** port number for development server. Default is 3000 */\r\n frontendPort?: number;\r\n /** list of RPC interface definitions to register */\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n /** list of [IpcHandler]($backend) classes to register */\r\n ipcHandlers?: (typeof IpcHandler)[];\r\n}\r\n\r\n/** @beta */\r\nexport interface ElectronHostOpts extends NativeHostOpts {\r\n electronHost?: ElectronHostOptions;\r\n}\r\n\r\n/** @beta */\r\nexport interface ElectronHostWindowOptions extends BrowserWindowConstructorOptions {\r\n /** Name used to construct key for saving window size, position and maximize status to the settings store */\r\n storeWindowName?: string;\r\n /** The style of window title bar. Default is `default`. */\r\n titleBarStyle?: (\"default\" | \"hidden\" | \"hiddenInset\" | \"customButtonsOnHover\");\r\n /** Web page settings */\r\n webPreferences?: Omit<WebPreferences, \"preload\" | \"experimentalFeatures\" | \"nodeIntegration\" | \"contextIsolation\" | \"sandbox\" | \"nodeIntegrationInWorker\" | \"nodeIntegrationInSubFrames\">;\r\n}\r\n\r\n/** the size and position of a window as stored in the settings file.\r\n * @beta\r\n */\r\nexport interface WindowSizeAndPositionProps {\r\n width: number;\r\n height: number;\r\n x: number;\r\n y: number;\r\n}\r\n\r\n/**\r\n * The backend for Electron-based desktop applications\r\n * @beta\r\n */\r\nexport class ElectronHost {\r\n private static _ipc: ElectronIpc;\r\n private static _developmentServer: boolean;\r\n private static _electron: typeof ElectronModule;\r\n private static _electronFrontend = \"electron://frontend/\";\r\n private static _mainWindow?: BrowserWindow;\r\n public static webResourcesPath: string;\r\n public static appIconPath: string;\r\n public static frontendURL: string;\r\n public static rpcConfig: RpcConfiguration;\r\n public static get ipcMain() { return this._electron?.ipcMain; }\r\n public static get app() { return this._electron?.app; }\r\n public static get electron() { return this._electron; }\r\n\r\n private constructor() { }\r\n\r\n /**\r\n * Converts an \"electron://frontend/\" URL to an \"file://{absolute file path}\" URL.\r\n *\r\n * We use this protocol in production builds because our frontend must be built with absolute URLs,\r\n * however, since we're loading everything directly from the install directory, we cannot know the\r\n * absolute path at build time.\r\n */\r\n private static transformElectronUrlToFileUrl(requestedUrl: string): string {\r\n // Note that the \"frontend/\" path is arbitrary - this is just so we can handle *some* relative URLs...\r\n let assetPath = requestedUrl.substring(this._electronFrontend.length);\r\n if (assetPath.length === 0)\r\n assetPath = \"index.html\";\r\n assetPath = path.normalize(`${this.webResourcesPath}/${assetPath}`);\r\n // File protocols don't follow symlinks, so we need to resolve this to a real path.\r\n // However, if the file doesn't exist, it's fine to return an invalid path here - the request will just fail with net::ERR_FILE_NOT_FOUND\r\n try {\r\n assetPath = fs.realpathSync(assetPath);\r\n } catch {\r\n // console.warn(`WARNING: Frontend requested \"${requestedUrl}\", but ${assetPath} does not exist`);\r\n }\r\n if (!assetPath.startsWith(this.webResourcesPath))\r\n throw new Error(`Access to files outside installation directory (${this.webResourcesPath}) is prohibited`);\r\n return `file://${assetPath}`;\r\n }\r\n\r\n private static _openWindow(options?: ElectronHostWindowOptions) {\r\n const webPreferences: WebPreferences = {\r\n ...options?.webPreferences,\r\n\r\n // These web preference variables should not be overriden by the ElectronHostWindowOptions\r\n preload: require.resolve(/* webpack: copyfile */\"./ElectronPreload.js\"),\r\n experimentalFeatures: false,\r\n nodeIntegration: false,\r\n contextIsolation: true,\r\n sandbox: true,\r\n nodeIntegrationInWorker: false,\r\n nodeIntegrationInSubFrames: false,\r\n };\r\n\r\n const opts: BrowserWindowConstructorOptions = {\r\n ...options,\r\n autoHideMenuBar: true,\r\n icon: this.appIconPath,\r\n webPreferences,\r\n };\r\n\r\n this._mainWindow = new (this.electron.BrowserWindow)(opts);\r\n ElectronRpcConfiguration.targetWindowId = this._mainWindow.id;\r\n this._mainWindow.on(\"closed\", () => this._mainWindow = undefined);\r\n this._mainWindow.loadURL(this.frontendURL); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n /** Monitors and saves main window size, position and maximized state */\r\n if (options?.storeWindowName) {\r\n const mainWindow = this._mainWindow;\r\n const windowName = options.storeWindowName;\r\n const saveWindowPosition = () => {\r\n const bounds: WindowSizeAndPositionProps = mainWindow.getBounds();\r\n NativeHost.settingsStore.setData(`windowSizeAndPos-${windowName}`, JSON.stringify(bounds));\r\n };\r\n const saveMaximized = (maximized: boolean) => {\r\n NativeHost.settingsStore.setData(`windowMaximized-${windowName}`, maximized);\r\n };\r\n\r\n mainWindow.on(\"maximize\", () => saveMaximized(true));\r\n mainWindow.on(\"unmaximize\", () => saveMaximized(false));\r\n saveMaximized(mainWindow.isMaximized());\r\n\r\n const debouncedSaveWindowSizeAndPos = debounce(() => saveWindowPosition());\r\n mainWindow.on(\"resize\", () => debouncedSaveWindowSizeAndPos());\r\n mainWindow.on(\"move\", () => debouncedSaveWindowSizeAndPos());\r\n saveWindowPosition();\r\n }\r\n }\r\n\r\n /** The \"main\" BrowserWindow for this application. */\r\n public static get mainWindow() { return this._mainWindow; }\r\n\r\n /**\r\n * Gets window size and position for a window, by name, from settings file, if present.\r\n */\r\n public static getWindowSizeAndPositionSetting(windowName: string): WindowSizeAndPositionProps | undefined {\r\n const saved = NativeHost.settingsStore.getString(`windowSizeAndPos-${windowName}`);\r\n return saved ? JSON.parse(saved) as WindowSizeAndPositionProps : undefined;\r\n }\r\n\r\n /** Gets \"window maximized\" flag for a window, by name, from settings file if present */\r\n public static getWindowMaximizedSetting(windowName: string): boolean | undefined {\r\n return NativeHost.settingsStore.getBoolean(`windowMaximized-${windowName}`);\r\n }\r\n\r\n /**\r\n * Open the main Window when the app is ready.\r\n * @param windowOptions Options for constructing the main BrowserWindow. See: https://electronjs.org/docs/api/browser-window#new-browserwindowoptions\r\n */\r\n public static async openMainWindow(windowOptions?: ElectronHostWindowOptions): Promise<void> {\r\n const app = this.app;\r\n // quit the application when all windows are closed (unless we're running on MacOS)\r\n app.on(\"window-all-closed\", () => {\r\n if (process.platform !== \"darwin\")\r\n app.quit();\r\n });\r\n\r\n // re-open the main window if it was closed and the app is re-activated (this is the normal MacOS behavior)\r\n app.on(\"activate\", () => {\r\n if (!this._mainWindow)\r\n this._openWindow(windowOptions);\r\n });\r\n\r\n if (this._developmentServer) {\r\n // Occasionally, the electron backend may start before the webpack devserver has even started.\r\n // If this happens, we'll just retry and keep reloading the page.\r\n app.on(\"web-contents-created\", (_e, webcontents) => {\r\n webcontents.on(\"did-fail-load\", async (_event, errorCode, _errorDescription, _validatedURL, isMainFrame) => {\r\n // errorCode -102 is CONNECTION_REFUSED - see https://cs.chromium.org/chromium/src/net/base/net_error_list.h\r\n if (isMainFrame && errorCode === -102) {\r\n await BeDuration.wait(100);\r\n webcontents.reload();\r\n }\r\n });\r\n });\r\n }\r\n\r\n await app.whenReady();\r\n\r\n if (!this._developmentServer) {\r\n // handle any \"electron://\" requests and redirect them to \"file://\" URLs\r\n this.electron.protocol.handle(\"electron\", async (request) => ElectronHost.electron.net.fetch(this.transformElectronUrlToFileUrl(request.url)));\r\n }\r\n\r\n this._openWindow(windowOptions);\r\n }\r\n\r\n public static get isValid() { return this._ipc !== undefined; }\r\n\r\n /**\r\n * Initialize the backend of an Electron app.\r\n * This method configures the backend for all of the inter-process communication (RPC and IPC) for an\r\n * Electron app. It should be called from your Electron main function.\r\n * @param opts Options that control aspects of your backend.\r\n * @note This method must only be called from the backend of an Electron app (i.e. when [ProcessDetector.isElectronAppBackend]($bentley) is `true`).\r\n */\r\n public static async startup(opts?: ElectronHostOpts) {\r\n if (!ProcessDetector.isElectronAppBackend)\r\n throw new Error(\"Not running under Electron\");\r\n\r\n if (!this.isValid) {\r\n this._electron = require(\"electron\"); // eslint-disable-line @typescript-eslint/no-require-imports\r\n this._ipc = new ElectronIpc();\r\n const app = this.app;\r\n if (!app.isReady())\r\n this.electron.protocol.registerSchemesAsPrivileged([{\r\n scheme: \"electron\",\r\n privileges: {\r\n standard: true,\r\n secure: true,\r\n supportFetchAPI: true,\r\n },\r\n }]);\r\n const eopt = opts?.electronHost;\r\n this._developmentServer = eopt?.developmentServer ?? false;\r\n const frontendPort = eopt?.frontendPort ?? 3000;\r\n this.webResourcesPath = eopt?.webResourcesPath ?? \"\";\r\n this.frontendURL = eopt?.frontendURL ?? (this._developmentServer ? `http://localhost:${frontendPort}` : `${this._electronFrontend}index.html`);\r\n this.appIconPath = path.join(this.webResourcesPath, eopt?.iconName ?? \"appicon.ico\");\r\n this.rpcConfig = ElectronRpcManager.initializeBackend(this._ipc, eopt?.rpcInterfaces);\r\n }\r\n\r\n opts = opts ?? {};\r\n opts.ipcHost = opts.ipcHost ?? {};\r\n opts.ipcHost.socket = this._ipc;\r\n await NativeHost.startup(opts);\r\n if (IpcHost.isValid) {\r\n ElectronDialogHandler.register();\r\n opts.electronHost?.ipcHandlers?.forEach((ipc) => ipc.register());\r\n }\r\n }\r\n}\r\n\r\nclass ElectronDialogHandler extends IpcHandler {\r\n public get channelName() { return electronIpcStrings.dialogChannel; }\r\n public async callDialog(method: DialogModuleMethod, ...args: any) {\r\n const dialog = ElectronHost.electron.dialog;\r\n const dialogMethod = dialog[method] as (...args: any[]) => any;\r\n if (typeof dialogMethod !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `illegal electron dialog method`);\r\n\r\n return dialogMethod.call(dialog, ...args);\r\n }\r\n}\r\n\r\nfunction debounce(func: (...args: any[]) => any, ms: number = 200) {\r\n let timeout: NodeJS.Timeout;\r\n return function (this: any, ...args: any[]) {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(() => {\r\n func.apply(this, args);\r\n }, ms);\r\n };\r\n}\r\n"]}
@@ -14,13 +14,15 @@ const OBJECTS_CHANNEL = (0, core_common_1.iTwinChannel)("rpc.objects");
14
14
  const DATA_CHANNEL = (0, core_common_1.iTwinChannel)("rpc.data");
15
15
  /** @internal */
16
16
  class ElectronIpcTransport {
17
+ _partials;
18
+ _removeListeners = [];
19
+ _protocol;
17
20
  get protocol() { return this._protocol; }
18
21
  sendRequest(request) {
19
22
  const value = this._extractValue(request);
20
23
  this._send(request, value);
21
24
  }
22
25
  constructor(protocol) {
23
- this._removeListeners = [];
24
26
  this._protocol = protocol;
25
27
  this._partials = new Map();
26
28
  this._setupDataChannel();
@@ -114,6 +116,7 @@ class ElectronIpcTransport {
114
116
  exports.ElectronIpcTransport = ElectronIpcTransport;
115
117
  /** @internal */
116
118
  class FrontendIpcTransport extends ElectronIpcTransport {
119
+ _pushTransport;
117
120
  setupPush() {
118
121
  const pushTransport = new ElectronPush_1.ElectronPushTransport(this);
119
122
  this._pushTransport = pushTransport;
@@ -132,6 +135,7 @@ class FrontendIpcTransport extends ElectronIpcTransport {
132
135
  exports.FrontendIpcTransport = FrontendIpcTransport;
133
136
  /** @internal */
134
137
  class BackendIpcTransport extends ElectronIpcTransport {
138
+ _browserWindow;
135
139
  setupPush() {
136
140
  core_common_1.RpcPushConnection.for = (channel, client) => new ElectronPush_1.ElectronPushConnection(channel, client, this);
137
141
  core_common_1.RpcPushChannel.enabled = true;
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronIpcTransport.js","sourceRoot":"","sources":["../../../src/common/ElectronIpcTransport.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AA6N/F,sCAUC;AArOD,sDAAmF;AACnF,oDAE4B;AAC5B,iDAA+E;AAC/E,6DAAgE;AAIhE,MAAM,eAAe,GAAG,IAAA,0BAAY,EAAC,aAAa,CAAC,CAAC;AACpD,MAAM,YAAY,GAAG,IAAA,0BAAY,EAAC,UAAU,CAAC,CAAC;AAO9C,gBAAgB;AAChB,MAAsB,oBAAoB;IAKxC,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAEzC,WAAW,CAAC,OAA6B;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,YAAmB,QAA6B;QAVxC,qBAAgB,GAAmB,EAAE,CAAC;QAW5C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAES,SAAS,KAAK,CAAC;IAEjB,iBAAiB;QACvB,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE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AAC,CAAC;IAC9E,CAAC;IAEO,qBAAqB;QAC3B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,CAAC,8FAA8F;YAClG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,4DAA4D;QACvH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,0BAA0B,EAAE,GAAG,EAAE,CAAC,2BAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;CACF;AA/CD,kDA+CC;AAED,IAAI,SAA2C,CAAC;AAEhD,gBAAgB;AAChB,SAAgB,aAAa,CAAC,QAA6B;IACzD,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjD,SAAS,CAAC,OAAO,EAAE,CAAC;QACpB,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,SAAS,KAAK,SAAS;QACzB,SAAS,GAAG,8BAAe,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE7H,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { BentleyError, BentleyStatus, ProcessDetector } from \"@itwin/core-bentley\";\nimport {\n IModelError, iTwinChannel, RpcPushChannel, RpcPushConnection, RpcRequestFulfillment, RpcSerializedValue, SerializedRpcRequest,\n} from \"@itwin/core-common\";\nimport { ElectronPushConnection, ElectronPushTransport } from \"./ElectronPush\";\nimport { ElectronRpcConfiguration } from \"./ElectronRpcManager\";\nimport { ElectronRpcProtocol } from \"./ElectronRpcProtocol\";\nimport { ElectronRpcRequest } from \"./ElectronRpcRequest\";\n\nconst OBJECTS_CHANNEL = iTwinChannel(\"rpc.objects\");\nconst DATA_CHANNEL = iTwinChannel(\"rpc.data\");\n\ninterface PartialPayload { id: string, index: number, data: Uint8Array }\n\n/** @internal */\nexport interface IpcTransportMessage { id: string, parameters?: RpcSerializedValue, result?: RpcSerializedValue }\n\n/** @internal */\nexport abstract class ElectronIpcTransport<TIn extends IpcTransportMessage = IpcTransportMessage, TOut extends IpcTransportMessage = IpcTransportMessage> {\n private _partials: Map<string, { message: TIn, received: number } | PartialPayload[]>;\n private _removeListeners: VoidFunction[] = [];\n protected _protocol: ElectronRpcProtocol;\n\n public get protocol() { return this._protocol; }\n\n public sendRequest(request: SerializedRpcRequest) {\n const value = this._extractValue(request);\n this._send(request, value);\n }\n\n public constructor(protocol: ElectronRpcProtocol) {\n this._protocol = protocol;\n this._partials = new Map();\n this._setupDataChannel();\n this._setupObjectsChannel();\n this.setupPush();\n }\n\n protected setupPush() { }\n\n private _setupDataChannel() {\n const removeListener = this.protocol.ipcSocket.addListener(DATA_CHANNEL, async (evt: any, chunk: PartialPayload) => {\n let pending = this._partials.get(chunk.id);\n if (!pending) {\n pending = [];\n this._partials.set(chunk.id, pending);\n }\n\n if (Array.isArray(pending)) {\n pending.push(chunk);\n } else {\n ++pending.received;\n\n const value = this._extractValue(pending.message);\n value.data[chunk.index] = chunk.data;\n\n if (pending.received === (value.chunks || 0)) {\n this.handleComplete(pending.message.id, evt);\n }\n }\n });\n this._removeListeners.push(removeListener);\n }\n\n private _setupObjectsChannel() {\n const removeListener = this.protocol.ipcSocket.addListener(OBJECTS_CHANNEL, async (evt: any, message: TIn) => {\n const pending = this._partials.get(message.id);\n if (pending && !Array.isArray(pending)) {\n throw new IModelError(BentleyStatus.ERROR, `Message already received for id \"${message.id}\".`);\n }\n\n const partial = { message, received: 0 };\n this._partials.set(message.id, partial);\n const value = this._extractValue(partial.message);\n\n if (pending && Array.isArray(pending)) {\n for (const chunk of pending) {\n ++partial.received;\n value.data[chunk.index] = chunk.data;\n }\n }\n\n if (partial.received === (value.chunks || 0)) {\n this.handleComplete(message.id, evt);\n }\n });\n this._removeListeners.push(removeListener);\n }\n\n private _extractValue(t: IpcTransportMessage): RpcSerializedValue {\n if (t.parameters) {\n return t.parameters;\n }\n\n if (t.result) {\n return t.result;\n }\n\n throw new IModelError(BentleyStatus.ERROR, \"Unknown value type.\");\n }\n\n private _send(message: IpcTransportMessage, value: RpcSerializedValue, evt?: any) {\n const chunks = value.data;\n if (chunks.length) {\n value.chunks = chunks.length;\n value.data = [];\n }\n\n this.performSend(OBJECTS_CHANNEL, message, evt);\n\n for (let index = 0; index !== chunks.length; ++index) {\n const chunk: PartialPayload = { id: message.id, index, data: chunks[index] };\n this.performSend(DATA_CHANNEL, chunk, evt);\n }\n }\n\n protected performSend(channel: string, message: any, evt: any) {\n (evt ? evt.sender : this.protocol.ipcSocket).send(channel, message);\n }\n\n protected abstract handleComplete(id: string, evt: any): void;\n\n /** @internal */\n public sendResponse(message: TOut, evt: any) {\n const value = this._extractValue(message);\n this._send(message, value, evt);\n }\n\n protected loadMessage(id: string) {\n const partial = this._partials.get(id);\n if (!partial || Array.isArray(partial)) {\n throw new IModelError(BentleyStatus.ERROR, `Incomplete transmission for id \"${id}\".`);\n }\n\n this._partials.delete(id);\n return partial.message;\n }\n\n public cleanup() {\n this._removeListeners.forEach((removeListener) => removeListener());\n }\n}\n\n/** @internal */\nexport class FrontendIpcTransport extends ElectronIpcTransport<RpcRequestFulfillment> {\n private _pushTransport?: ElectronPushTransport;\n\n protected override setupPush() {\n const pushTransport = new ElectronPushTransport(this);\n this._pushTransport = pushTransport;\n RpcPushChannel.setup(pushTransport);\n }\n\n protected async handleComplete(id: string) {\n const message = this.loadMessage(id);\n\n if (this._pushTransport && this._pushTransport.consume(message)) {\n return;\n }\n\n const protocol = this._protocol;\n const request = protocol.requests.get(message.id) as ElectronRpcRequest;\n request.notifyResponse(message);\n }\n}\n\n/** @internal */\nexport class BackendIpcTransport extends ElectronIpcTransport<SerializedRpcRequest, RpcRequestFulfillment> {\n private _browserWindow: any;\n\n protected override setupPush() {\n RpcPushConnection.for = (channel, client) => new ElectronPushConnection(channel, client, this);\n RpcPushChannel.enabled = true;\n }\n\n protected async handleComplete(id: string, evt: any) {\n const message = this.loadMessage(id);\n\n let response: RpcRequestFulfillment;\n try {\n const protocol = this._protocol;\n response = await protocol.fulfill(message);\n } catch (err) {\n response = await RpcRequestFulfillment.forUnknownError(message, err);\n }\n\n const raw = response.rawResult;\n response.rawResult = undefined; // Otherwise, it will be serialized in IPC layer and large responses will then crash the app\n this.sendResponse(response, evt);\n response.rawResult = raw;\n }\n\n protected override performSend(channel: string, message: any, evt: any) {\n if (evt) {\n return super.performSend(channel, message, evt);\n }\n\n this._requireBrowserWindow();\n const target = ElectronRpcConfiguration.targetWindowId;\n const windows = target ? [this._browserWindow.fromId(target)] : this._browserWindow.getAllWindows();\n windows.forEach((window: any) => window.webContents.send(channel, message));\n }\n\n private _requireBrowserWindow() {\n if (this._browserWindow) {\n return;\n }\n\n try { // Wrapping require in a try/catch signals to webpack that this is only an optional dependency\n this._browserWindow = require(\"electron\").BrowserWindow; // eslint-disable-line @typescript-eslint/no-require-imports\n } catch (err) {\n throw new IModelError(BentleyStatus.ERROR, `Error requiring electron`, () => BentleyError.getErrorProps(err));\n }\n }\n}\n\nlet transport: ElectronIpcTransport | undefined;\n\n/** @internal */\nexport function initializeIpc(protocol: ElectronRpcProtocol) {\n if (transport && transport.protocol !== protocol) {\n transport.cleanup();\n transport = undefined;\n }\n\n if (undefined === transport)\n transport = ProcessDetector.isElectronAppFrontend ? new FrontendIpcTransport(protocol) : new BackendIpcTransport(protocol);\n\n return transport;\n}\n"]}
1
+ {"version":3,"file":"ElectronIpcTransport.js","sourceRoot":"","sources":["../../../src/common/ElectronIpcTransport.ts"],"names":[],"m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AE,CAAC;YACb,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,0BAA0B,EAAE,GAAG,EAAE,CAAC,2BAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;CACF;AA/CD,kDA+CC;AAED,IAAI,SAA2C,CAAC;AAEhD,gBAAgB;AAChB,SAAgB,aAAa,CAAC,QAA6B;IACzD,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjD,SAAS,CAAC,OAAO,EAAE,CAAC;QACpB,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,SAAS,KAAK,SAAS;QACzB,SAAS,GAAG,8BAAe,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE7H,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { BentleyError, BentleyStatus, ProcessDetector } from \"@itwin/core-bentley\";\nimport {\n IModelError, iTwinChannel, RpcPushChannel, RpcPushConnection, RpcRequestFulfillment, RpcSerializedValue, SerializedRpcRequest,\n} from \"@itwin/core-common\";\nimport { ElectronPushConnection, ElectronPushTransport } from \"./ElectronPush\";\nimport { ElectronRpcConfiguration } from \"./ElectronRpcManager\";\nimport { ElectronRpcProtocol } from \"./ElectronRpcProtocol\";\nimport { ElectronRpcRequest } from \"./ElectronRpcRequest\";\n\nconst OBJECTS_CHANNEL = iTwinChannel(\"rpc.objects\");\nconst DATA_CHANNEL = iTwinChannel(\"rpc.data\");\n\ninterface PartialPayload { id: string, index: number, data: Uint8Array }\n\n/** @internal */\nexport interface IpcTransportMessage { id: string, parameters?: RpcSerializedValue, result?: RpcSerializedValue }\n\n/** @internal */\nexport abstract class ElectronIpcTransport<TIn extends IpcTransportMessage = IpcTransportMessage, TOut extends IpcTransportMessage = IpcTransportMessage> {\n private _partials: Map<string, { message: TIn, received: number } | PartialPayload[]>;\n private _removeListeners: VoidFunction[] = [];\n protected _protocol: ElectronRpcProtocol;\n\n public get protocol() { return this._protocol; }\n\n public sendRequest(request: SerializedRpcRequest) {\n const value = this._extractValue(request);\n this._send(request, value);\n }\n\n public constructor(protocol: ElectronRpcProtocol) {\n this._protocol = protocol;\n this._partials = new Map();\n this._setupDataChannel();\n this._setupObjectsChannel();\n this.setupPush();\n }\n\n protected setupPush() { }\n\n private _setupDataChannel() {\n const removeListener = this.protocol.ipcSocket.addListener(DATA_CHANNEL, async (evt: any, chunk: PartialPayload) => {\n let pending = this._partials.get(chunk.id);\n if (!pending) {\n pending = [];\n this._partials.set(chunk.id, pending);\n }\n\n if (Array.isArray(pending)) {\n pending.push(chunk);\n } else {\n ++pending.received;\n\n const value = this._extractValue(pending.message);\n value.data[chunk.index] = chunk.data;\n\n if (pending.received === (value.chunks || 0)) {\n this.handleComplete(pending.message.id, evt);\n }\n }\n });\n this._removeListeners.push(removeListener);\n }\n\n private _setupObjectsChannel() {\n const removeListener = this.protocol.ipcSocket.addListener(OBJECTS_CHANNEL, async (evt: any, message: TIn) => {\n const pending = this._partials.get(message.id);\n if (pending && !Array.isArray(pending)) {\n throw new IModelError(BentleyStatus.ERROR, `Message already received for id \"${message.id}\".`);\n }\n\n const partial = { message, received: 0 };\n this._partials.set(message.id, partial);\n const value = this._extractValue(partial.message);\n\n if (pending && Array.isArray(pending)) {\n for (const chunk of pending) {\n ++partial.received;\n value.data[chunk.index] = chunk.data;\n }\n }\n\n if (partial.received === (value.chunks || 0)) {\n this.handleComplete(message.id, evt);\n }\n });\n this._removeListeners.push(removeListener);\n }\n\n private _extractValue(t: IpcTransportMessage): RpcSerializedValue {\n if (t.parameters) {\n return t.parameters;\n }\n\n if (t.result) {\n return t.result;\n }\n\n throw new IModelError(BentleyStatus.ERROR, \"Unknown value type.\");\n }\n\n private _send(message: IpcTransportMessage, value: RpcSerializedValue, evt?: any) {\n const chunks = value.data;\n if (chunks.length) {\n value.chunks = chunks.length;\n value.data = [];\n }\n\n this.performSend(OBJECTS_CHANNEL, message, evt);\n\n for (let index = 0; index !== chunks.length; ++index) {\n const chunk: PartialPayload = { id: message.id, index, data: chunks[index] };\n this.performSend(DATA_CHANNEL, chunk, evt);\n }\n }\n\n protected performSend(channel: string, message: any, evt: any) {\n (evt ? evt.sender : this.protocol.ipcSocket).send(channel, message);\n }\n\n protected abstract handleComplete(id: string, evt: any): void;\n\n /** @internal */\n public sendResponse(message: TOut, evt: any) {\n const value = this._extractValue(message);\n this._send(message, value, evt);\n }\n\n protected loadMessage(id: string) {\n const partial = this._partials.get(id);\n if (!partial || Array.isArray(partial)) {\n throw new IModelError(BentleyStatus.ERROR, `Incomplete transmission for id \"${id}\".`);\n }\n\n this._partials.delete(id);\n return partial.message;\n }\n\n public cleanup() {\n this._removeListeners.forEach((removeListener) => removeListener());\n }\n}\n\n/** @internal */\nexport class FrontendIpcTransport extends ElectronIpcTransport<RpcRequestFulfillment> {\n private _pushTransport?: ElectronPushTransport;\n\n protected override setupPush() {\n const pushTransport = new ElectronPushTransport(this);\n this._pushTransport = pushTransport;\n RpcPushChannel.setup(pushTransport);\n }\n\n protected async handleComplete(id: string) {\n const message = this.loadMessage(id);\n\n if (this._pushTransport && this._pushTransport.consume(message)) {\n return;\n }\n\n const protocol = this._protocol;\n const request = protocol.requests.get(message.id) as ElectronRpcRequest;\n request.notifyResponse(message);\n }\n}\n\n/** @internal */\nexport class BackendIpcTransport extends ElectronIpcTransport<SerializedRpcRequest, RpcRequestFulfillment> {\n private _browserWindow: any;\n\n protected override setupPush() {\n RpcPushConnection.for = (channel, client) => new ElectronPushConnection(channel, client, this);\n RpcPushChannel.enabled = true;\n }\n\n protected async handleComplete(id: string, evt: any) {\n const message = this.loadMessage(id);\n\n let response: RpcRequestFulfillment;\n try {\n const protocol = this._protocol;\n response = await protocol.fulfill(message);\n } catch (err) {\n response = await RpcRequestFulfillment.forUnknownError(message, err);\n }\n\n const raw = response.rawResult;\n response.rawResult = undefined; // Otherwise, it will be serialized in IPC layer and large responses will then crash the app\n this.sendResponse(response, evt);\n response.rawResult = raw;\n }\n\n protected override performSend(channel: string, message: any, evt: any) {\n if (evt) {\n return super.performSend(channel, message, evt);\n }\n\n this._requireBrowserWindow();\n const target = ElectronRpcConfiguration.targetWindowId;\n const windows = target ? [this._browserWindow.fromId(target)] : this._browserWindow.getAllWindows();\n windows.forEach((window: any) => window.webContents.send(channel, message));\n }\n\n private _requireBrowserWindow() {\n if (this._browserWindow) {\n return;\n }\n\n try { // Wrapping require in a try/catch signals to webpack that this is only an optional dependency\n this._browserWindow = require(\"electron\").BrowserWindow; // eslint-disable-line @typescript-eslint/no-require-imports\n } catch (err) {\n throw new IModelError(BentleyStatus.ERROR, `Error requiring electron`, () => BentleyError.getErrorProps(err));\n }\n }\n}\n\nlet transport: ElectronIpcTransport | undefined;\n\n/** @internal */\nexport function initializeIpc(protocol: ElectronRpcProtocol) {\n if (transport && transport.protocol !== protocol) {\n transport.cleanup();\n transport = undefined;\n }\n\n if (undefined === transport)\n transport = ProcessDetector.isElectronAppFrontend ? new FrontendIpcTransport(protocol) : new BackendIpcTransport(protocol);\n\n return transport;\n}\n"]}
@@ -9,10 +9,11 @@ const core_common_1 = require("@itwin/core-common");
9
9
  const PUSH = "__push__";
10
10
  /** @internal */
11
11
  class ElectronPushTransport extends core_common_1.RpcPushTransport {
12
+ _ipc;
13
+ _last = -1;
12
14
  get last() { return this._last; }
13
15
  constructor(ipc) {
14
16
  super();
15
- this._last = -1;
16
17
  this._ipc = ipc;
17
18
  }
18
19
  consume(response) {
@@ -30,9 +31,10 @@ class ElectronPushTransport extends core_common_1.RpcPushTransport {
30
31
  exports.ElectronPushTransport = ElectronPushTransport;
31
32
  /** @internal */
32
33
  class ElectronPushConnection extends core_common_1.RpcPushConnection {
34
+ _ipc;
35
+ _next = -1;
33
36
  constructor(channel, client, ipc) {
34
37
  super(channel, client);
35
- this._next = -1;
36
38
  this._ipc = ipc;
37
39
  }
38
40
  async send(messageData) {
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronPush.js","sourceRoot":"","sources":["../../../src/common/ElectronPush.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAA+H;AAG/H,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,gBAAgB;AAChB,MAAa,qBAAsB,SAAQ,8BAAgB;IAIzD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAExC,YAAmB,GAAyB;QAC1C,KAAK,EAAE,CAAC;QALF,UAAK,GAAW,CAAC,CAAC,CAAC;QAMzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAEM,OAAO,CAAC,QAA+B;QAC5C,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;QAE7B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,WAAW,GAAG,2BAAa,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnF,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzBD,sDAyBC;AAED,gBAAgB;AAChB,MAAa,sBAA0B,SAAQ,+BAAoB;IAIjE,YAAmB,OAA0B,EAAE,MAAe,EAAE,GAAwB;QACtF,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAHjB,UAAK,GAAW,CAAC,CAAC,CAAC;QAIzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAgB;QAChC,MAAM,MAAM,GAAG,2BAAa,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACxE,MAAM,WAAW,GAA0B,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9I,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;CACF;AAdD,wDAcC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { RpcMarshaling, RpcPushChannel, RpcPushConnection, RpcPushTransport, RpcRequestFulfillment } from \"@itwin/core-common\";\nimport { BackendIpcTransport, FrontendIpcTransport } from \"./ElectronIpcTransport\";\n\nconst PUSH = \"__push__\";\n\n/** @internal */\nexport class ElectronPushTransport extends RpcPushTransport {\n private _ipc: FrontendIpcTransport;\n private _last: number = -1;\n\n public get last() { return this._last; }\n\n public constructor(ipc: FrontendIpcTransport) {\n super();\n this._ipc = ipc;\n }\n\n public consume(response: RpcRequestFulfillment): boolean {\n if (response.interfaceName !== PUSH) {\n return false;\n }\n\n this._last = response.status;\n\n if (this.onMessage) {\n const messageData = RpcMarshaling.deserialize(this._ipc.protocol, response.result);\n this.onMessage(response.id, messageData);\n }\n\n return true;\n }\n}\n\n/** @internal */\nexport class ElectronPushConnection<T> extends RpcPushConnection<T> {\n private _ipc: BackendIpcTransport;\n private _next: number = -1;\n\n public constructor(channel: RpcPushChannel<T>, client: unknown, ipc: BackendIpcTransport) {\n super(channel, client);\n this._ipc = ipc;\n }\n\n public async send(messageData: any) {\n const result = RpcMarshaling.serialize(this._ipc.protocol, messageData);\n const fulfillment: RpcRequestFulfillment = { result, rawResult: messageData, interfaceName: PUSH, id: this.channel.id, status: ++this._next };\n this._ipc.sendResponse(fulfillment, undefined);\n }\n}\n"]}
1
+ {"version":3,"file":"ElectronPush.js","sourceRoot":"","sources":["../../../src/common/ElectronPush.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAA+H;AAG/H,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,gBAAgB;AAChB,MAAa,qBAAsB,SAAQ,8BAAgB;IACjD,IAAI,CAAuB;IAC3B,KAAK,GAAW,CAAC,CAAC,CAAC;IAE3B,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAExC,YAAmB,GAAyB;QAC1C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAEM,OAAO,CAAC,QAA+B;QAC5C,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;QAE7B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,WAAW,GAAG,2BAAa,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnF,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzBD,sDAyBC;AAED,gBAAgB;AAChB,MAAa,sBAA0B,SAAQ,+BAAoB;IACzD,IAAI,CAAsB;IAC1B,KAAK,GAAW,CAAC,CAAC,CAAC;IAE3B,YAAmB,OAA0B,EAAE,MAAe,EAAE,GAAwB;QACtF,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAgB;QAChC,MAAM,MAAM,GAAG,2BAAa,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACxE,MAAM,WAAW,GAA0B,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9I,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;CACF;AAdD,wDAcC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { RpcMarshaling, RpcPushChannel, RpcPushConnection, RpcPushTransport, RpcRequestFulfillment } from \"@itwin/core-common\";\nimport { BackendIpcTransport, FrontendIpcTransport } from \"./ElectronIpcTransport\";\n\nconst PUSH = \"__push__\";\n\n/** @internal */\nexport class ElectronPushTransport extends RpcPushTransport {\n private _ipc: FrontendIpcTransport;\n private _last: number = -1;\n\n public get last() { return this._last; }\n\n public constructor(ipc: FrontendIpcTransport) {\n super();\n this._ipc = ipc;\n }\n\n public consume(response: RpcRequestFulfillment): boolean {\n if (response.interfaceName !== PUSH) {\n return false;\n }\n\n this._last = response.status;\n\n if (this.onMessage) {\n const messageData = RpcMarshaling.deserialize(this._ipc.protocol, response.result);\n this.onMessage(response.id, messageData);\n }\n\n return true;\n }\n}\n\n/** @internal */\nexport class ElectronPushConnection<T> extends RpcPushConnection<T> {\n private _ipc: BackendIpcTransport;\n private _next: number = -1;\n\n public constructor(channel: RpcPushChannel<T>, client: unknown, ipc: BackendIpcTransport) {\n super(channel, client);\n this._ipc = ipc;\n }\n\n public async send(messageData: any) {\n const result = RpcMarshaling.serialize(this._ipc.protocol, messageData);\n const fulfillment: RpcRequestFulfillment = { result, rawResult: messageData, interfaceName: PUSH, id: this.channel.id, status: ++this._next };\n this._ipc.sendResponse(fulfillment, undefined);\n }\n}\n"]}
@@ -11,6 +11,7 @@ const ElectronRpcProtocol_1 = require("./ElectronRpcProtocol");
11
11
  * @internal
12
12
  */
13
13
  class ElectronRpcConfiguration extends core_common_1.RpcConfiguration {
14
+ static targetWindowId;
14
15
  }
15
16
  exports.ElectronRpcConfiguration = ElectronRpcConfiguration;
16
17
  /** Coordinates usage of RPC interfaces for an Electron-based application.
@@ -28,11 +29,8 @@ class ElectronRpcManager extends core_common_1.RpcManager {
28
29
  static performInitialization(ipcSocket, rpcs) {
29
30
  const interfaces = rpcs ?? [];
30
31
  const config = class extends ElectronRpcConfiguration {
31
- constructor() {
32
- super(...arguments);
33
- this.interfaces = () => interfaces;
34
- this.protocol = new ElectronRpcProtocol_1.ElectronRpcProtocol(this, ipcSocket);
35
- }
32
+ interfaces = () => interfaces;
33
+ protocol = new ElectronRpcProtocol_1.ElectronRpcProtocol(this, ipcSocket);
36
34
  };
37
35
  for (const def of interfaces) {
38
36
  core_common_1.RpcConfiguration.assign(def, () => config);
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronRpcManager.js","sourceRoot":"","sources":["../../../src/common/ElectronRpcManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAuJ;AACvJ,+DAA4D;AAE5D;;GAEG;AACH,MAAsB,wBAAyB,SAAQ,8BAAgB;CAMtE;AAND,4DAMC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wBAAU;IAChD,yEAAyE;IAClE,MAAM,CAAC,kBAAkB,CAAC,WAA8B,EAAE,UAAqC;QACpG,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IAED,wEAAwE;IACjE,MAAM,CAAC,iBAAiB,CAAC,UAA4B,EAAE,UAAqC;QACjG,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC1E,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,SAAoB,EAAE,IAA+B;QACxF,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,KAAM,SAAQ,wBAAwB;YAAtC;;gBACN,eAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC;gBAC9B,aAAQ,GAAwB,IAAI,yCAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAClF,CAAC;SAAA,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,8BAAgB,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,8BAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,wEAAwE;IACjE,MAAM,CAAC,iBAAiB;QAC7B,OAAO,kBAAkB,CAAC,kBAAkB,EAAE,CAAC;IACjD,CAAC;IAEO,MAAM,CAAC,kBAAkB;QAC/B,MAAM,WAAW,GAAG,yBAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAE3D,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,IAAI,WAAW,EAAE,CAAC;YAC3C,wBAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AAxCD,gDAwCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IpcSocket, IpcSocketBackend, IpcSocketFrontend, RpcConfiguration, RpcInterfaceDefinition, RpcManager, RpcRegistry } from \"@itwin/core-common\";\nimport { ElectronRpcProtocol } from \"./ElectronRpcProtocol\";\n\n/** RPC interface configuration for an Electron-based application.\n * @internal\n */\nexport abstract class ElectronRpcConfiguration extends RpcConfiguration {\n\n public static targetWindowId?: number;\n\n /** The protocol of the configuration. */\n public abstract override protocol: ElectronRpcProtocol;\n}\n\n/** Coordinates usage of RPC interfaces for an Electron-based application.\n * @internal\n */\nexport class ElectronRpcManager extends RpcManager {\n /** Initializes ElectronRpcManager for the frontend of an application. */\n public static initializeFrontend(ipcFrontend: IpcSocketFrontend, interfaces?: RpcInterfaceDefinition[]): ElectronRpcConfiguration {\n return ElectronRpcManager.performInitialization(ipcFrontend, interfaces);\n }\n\n /** Initializes ElectronRpcManager for the backend of an application. */\n public static initializeBackend(ipcBackend: IpcSocketBackend, interfaces?: RpcInterfaceDefinition[]): ElectronRpcConfiguration {\n return ElectronRpcManager.performInitialization(ipcBackend, interfaces);\n }\n\n private static performInitialization(ipcSocket: IpcSocket, rpcs?: RpcInterfaceDefinition[]): ElectronRpcConfiguration {\n const interfaces = rpcs ?? [];\n const config = class extends ElectronRpcConfiguration {\n public interfaces = () => interfaces;\n public protocol: ElectronRpcProtocol = new ElectronRpcProtocol(this, ipcSocket);\n };\n\n for (const def of interfaces) {\n RpcConfiguration.assign(def, () => config);\n }\n\n const instance = RpcConfiguration.obtain(config);\n RpcConfiguration.initializeInterfaces(instance);\n\n return instance;\n }\n\n /** Terminates ElectronRpcManager for the frontend of an application. */\n public static terminateFrontend() {\n return ElectronRpcManager.performTermination();\n }\n\n private static performTermination() {\n const definitions = RpcRegistry.instance.definitionClasses;\n\n for (const [, interfaceDef] of definitions) {\n RpcManager.terminateInterface(interfaceDef);\n }\n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AAO,kBAAkB,CAAC,kBAAkB,EAAE,CAAC;IACjD,CAAC;IAEO,MAAM,CAAC,kBAAkB;QAC/B,MAAM,WAAW,GAAG,yBAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAE3D,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,IAAI,WAAW,EAAE,CAAC;YAC3C,wBAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AAxCD,gDAwCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IpcSocket, IpcSocketBackend, IpcSocketFrontend, RpcConfiguration, RpcInterfaceDefinition, RpcManager, RpcRegistry } from \"@itwin/core-common\";\nimport { ElectronRpcProtocol } from \"./ElectronRpcProtocol\";\n\n/** RPC interface configuration for an Electron-based application.\n * @internal\n */\nexport abstract class ElectronRpcConfiguration extends RpcConfiguration {\n\n public static targetWindowId?: number;\n\n /** The protocol of the configuration. */\n public abstract override protocol: ElectronRpcProtocol;\n}\n\n/** Coordinates usage of RPC interfaces for an Electron-based application.\n * @internal\n */\nexport class ElectronRpcManager extends RpcManager {\n /** Initializes ElectronRpcManager for the frontend of an application. */\n public static initializeFrontend(ipcFrontend: IpcSocketFrontend, interfaces?: RpcInterfaceDefinition[]): ElectronRpcConfiguration {\n return ElectronRpcManager.performInitialization(ipcFrontend, interfaces);\n }\n\n /** Initializes ElectronRpcManager for the backend of an application. */\n public static initializeBackend(ipcBackend: IpcSocketBackend, interfaces?: RpcInterfaceDefinition[]): ElectronRpcConfiguration {\n return ElectronRpcManager.performInitialization(ipcBackend, interfaces);\n }\n\n private static performInitialization(ipcSocket: IpcSocket, rpcs?: RpcInterfaceDefinition[]): ElectronRpcConfiguration {\n const interfaces = rpcs ?? [];\n const config = class extends ElectronRpcConfiguration {\n public interfaces = () => interfaces;\n public protocol: ElectronRpcProtocol = new ElectronRpcProtocol(this, ipcSocket);\n };\n\n for (const def of interfaces) {\n RpcConfiguration.assign(def, () => config);\n }\n\n const instance = RpcConfiguration.obtain(config);\n RpcConfiguration.initializeInterfaces(instance);\n\n return instance;\n }\n\n /** Terminates ElectronRpcManager for the frontend of an application. */\n public static terminateFrontend() {\n return ElectronRpcManager.performTermination();\n }\n\n private static performTermination() {\n const definitions = RpcRegistry.instance.definitionClasses;\n\n for (const [, interfaceDef] of definitions) {\n RpcManager.terminateInterface(interfaceDef);\n }\n }\n}\n"]}
@@ -16,15 +16,19 @@ const ElectronRpcRequest_1 = require("./ElectronRpcRequest");
16
16
  * @internal
17
17
  */
18
18
  class ElectronRpcProtocol extends core_common_1.RpcProtocol {
19
+ static instances = new Map();
20
+ ipcSocket;
21
+ /** The RPC request class for this protocol. */
22
+ requestType = ElectronRpcRequest_1.ElectronRpcRequest;
23
+ /** Specifies where to break large binary request payloads. */
24
+ transferChunkThreshold = 48 * 1024 * 1024;
25
+ /** @internal */
26
+ requests = new Map();
27
+ /** @internal */
28
+ transport;
19
29
  /** Constructs an Electron protocol. */
20
30
  constructor(configuration, ipcSocket) {
21
31
  super(configuration);
22
- /** The RPC request class for this protocol. */
23
- this.requestType = ElectronRpcRequest_1.ElectronRpcRequest;
24
- /** Specifies where to break large binary request payloads. */
25
- this.transferChunkThreshold = 48 * 1024 * 1024;
26
- /** @internal */
27
- this.requests = new Map();
28
32
  this.ipcSocket = ipcSocket;
29
33
  this.transport = (0, ElectronIpcTransport_1.initializeIpc)(this);
30
34
  }
@@ -54,5 +58,4 @@ class ElectronRpcProtocol extends core_common_1.RpcProtocol {
54
58
  }
55
59
  }
56
60
  exports.ElectronRpcProtocol = ElectronRpcProtocol;
57
- ElectronRpcProtocol.instances = new Map();
58
61
  //# sourceMappingURL=ElectronRpcProtocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronRpcProtocol.js","sourceRoot":"","sources":["../../../src/common/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AAC;QAEpI,mBAAmB,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAEO,cAAc,CAAC,UAAkC;QACvD,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;;AApDH,kDAqDC;AApDe,6BAAS,GAAqC,IAAI,GAAG,EAAE,AAA9C,CAA+C","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError, IpcSocket, RpcInterface, RpcInterfaceDefinition, RpcProtocol } from \"@itwin/core-common\";\nimport { ElectronIpcTransport, initializeIpc, IpcTransportMessage } from \"./ElectronIpcTransport\";\nimport { ElectronRpcConfiguration } from \"./ElectronRpcManager\";\nimport { ElectronRpcRequest } from \"./ElectronRpcRequest\";\n\n/** RPC interface protocol for an Electron-based application.\n * @internal\n */\nexport class ElectronRpcProtocol extends RpcProtocol {\n public static instances: Map<string, ElectronRpcProtocol> = new Map();\n public ipcSocket: IpcSocket;\n\n /** The RPC request class for this protocol. */\n public readonly requestType = ElectronRpcRequest;\n\n /** Specifies where to break large binary request payloads. */\n public override transferChunkThreshold = 48 * 1024 * 1024;\n\n /** @internal */\n public requests: Map<string, ElectronRpcRequest> = new Map();\n\n /** @internal */\n public readonly transport: ElectronIpcTransport<IpcTransportMessage, IpcTransportMessage>;\n\n /** Constructs an Electron protocol. */\n public constructor(configuration: ElectronRpcConfiguration, ipcSocket: IpcSocket) {\n super(configuration);\n this.ipcSocket = ipcSocket;\n this.transport = initializeIpc(this);\n }\n\n /** @internal */\n public override onRpcClientInitialized(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\n this.registerInterface(definition);\n }\n\n /** @internal */\n public override onRpcImplInitialized(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\n this.registerInterface(definition);\n }\n\n /** @internal */\n public override onRpcClientTerminated(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\n this.purgeInterface(definition);\n }\n\n /** @internal */\n public override onRpcImplTerminated(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\n this.purgeInterface(definition);\n }\n\n private registerInterface(definition: RpcInterfaceDefinition) {\n if (ElectronRpcProtocol.instances.has(definition.interfaceName))\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${definition.interfaceName}\"\" is already associated with a protocol.`);\n\n ElectronRpcProtocol.instances.set(definition.interfaceName, this);\n }\n\n private purgeInterface(definition: RpcInterfaceDefinition) {\n ElectronRpcProtocol.instances.delete(definition.interfaceName);\n }\n}\n"]}
1
+ {"version":3,"file":"ElectronRpcProtocol.js","sourceRoot":"","sources":["../../../src/common/ElectronRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,oDAA+G;AAC/G,iEAAkG;AAElG,6DAA0D;AAE1D;;GAEG;AACH,MAAa,mBAAoB,SAAQ,yBAAW;IAC3C,MAAM,CAAC,SAAS,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC/D,SAAS,CAAY;IAE5B,+CAA+C;IAC/B,WAAW,GAAG,uCAAkB,CAAC;IAEjD,8DAA8D;IAC9C,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IAE1D,gBAAgB;IACT,QAAQ,GAAoC,IAAI,GAAG,EAAE,CAAC;IAE7D,gBAAgB;IACA,SAAS,CAAiE;IAE1F,uCAAuC;IACvC,YAAmB,aAAuC,EAAE,SAAoB;QAC9E,KAAK,CAAC,aAAa,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAA,oCAAa,EAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,gBAAgB;IACA,sBAAsB,CAAC,UAAkC,EAAE,OAAqB;QAC9F,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;IACA,oBAAoB,CAAC,UAAkC,EAAE,KAAmB;QAC1F,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;IACA,qBAAqB,CAAC,UAAkC,EAAE,OAAqB;QAC7F,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAED,gBAAgB;IACA,mBAAmB,CAAC,UAAkC,EAAE,KAAmB;QACzF,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAEO,iBAAiB,CAAC,UAAkC;QAC1D,IAAI,mBAAmB,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC;YAC7D,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,kBAAkB,UAAU,CAAC,aAAa,2CAA2C,CAAC,CAAC;QAEpI,mBAAmB,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAEO,cAAc,CAAC,UAAkC;QACvD,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;;AApDH,kDAqDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError, IpcSocket, RpcInterface, RpcInterfaceDefinition, RpcProtocol } from \"@itwin/core-common\";\nimport { ElectronIpcTransport, initializeIpc, IpcTransportMessage } from \"./ElectronIpcTransport\";\nimport { ElectronRpcConfiguration } from \"./ElectronRpcManager\";\nimport { ElectronRpcRequest } from \"./ElectronRpcRequest\";\n\n/** RPC interface protocol for an Electron-based application.\n * @internal\n */\nexport class ElectronRpcProtocol extends RpcProtocol {\n public static instances: Map<string, ElectronRpcProtocol> = new Map();\n public ipcSocket: IpcSocket;\n\n /** The RPC request class for this protocol. */\n public readonly requestType = ElectronRpcRequest;\n\n /** Specifies where to break large binary request payloads. */\n public override transferChunkThreshold = 48 * 1024 * 1024;\n\n /** @internal */\n public requests: Map<string, ElectronRpcRequest> = new Map();\n\n /** @internal */\n public readonly transport: ElectronIpcTransport<IpcTransportMessage, IpcTransportMessage>;\n\n /** Constructs an Electron protocol. */\n public constructor(configuration: ElectronRpcConfiguration, ipcSocket: IpcSocket) {\n super(configuration);\n this.ipcSocket = ipcSocket;\n this.transport = initializeIpc(this);\n }\n\n /** @internal */\n public override onRpcClientInitialized(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\n this.registerInterface(definition);\n }\n\n /** @internal */\n public override onRpcImplInitialized(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\n this.registerInterface(definition);\n }\n\n /** @internal */\n public override onRpcClientTerminated(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\n this.purgeInterface(definition);\n }\n\n /** @internal */\n public override onRpcImplTerminated(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\n this.purgeInterface(definition);\n }\n\n private registerInterface(definition: RpcInterfaceDefinition) {\n if (ElectronRpcProtocol.instances.has(definition.interfaceName))\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${definition.interfaceName}\"\" is already associated with a protocol.`);\n\n ElectronRpcProtocol.instances.set(definition.interfaceName, this);\n }\n\n private purgeInterface(definition: RpcInterfaceDefinition) {\n ElectronRpcProtocol.instances.delete(definition.interfaceName);\n }\n}\n"]}
@@ -15,6 +15,6 @@ export declare class ElectronRpcRequest extends RpcRequest {
15
15
  /** @internal */
16
16
  notifyResponse(fulfillment: RpcRequestFulfillment): void;
17
17
  /** @internal */
18
- dispose(): void;
18
+ [Symbol.dispose](): void;
19
19
  }
20
20
  //# sourceMappingURL=ElectronRpcRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronRpcRequest.d.ts","sourceRoot":"","sources":["../../../src/common/ElectronRpcRequest.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,UAAU,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,UAAU;IAChD,OAAO,CAAC,IAAI,CAA4C;IACxD,OAAO,CAAC,YAAY,CAAgD;IAEpE,0DAA0D;IAC1D,SAAyB,QAAQ,EAAE,mBAAmB,CAA6C;IAEnG,yBAAyB;cACT,IAAI;IAcpB,yBAAyB;cACT,IAAI;IASpB,kCAAkC;IAClC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIxD,gBAAgB;IACT,cAAc,CAAC,WAAW,EAAE,qBAAqB;IAKxD,gBAAgB;IACA,OAAO;CAIxB"}
1
+ {"version":3,"file":"ElectronRpcRequest.d.ts","sourceRoot":"","sources":["../../../src/common/ElectronRpcRequest.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,UAAU,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,UAAU;IAChD,OAAO,CAAC,IAAI,CAA4C;IACxD,OAAO,CAAC,YAAY,CAAgD;IAEpE,0DAA0D;IAC1D,SAAyB,QAAQ,EAAE,mBAAmB,CAA6C;IAEnG,yBAAyB;cACT,IAAI;IAcpB,yBAAyB;cACT,IAAI;IASpB,kCAAkC;IAClC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIxD,gBAAgB;IACT,cAAc,CAAC,WAAW,EAAE,qBAAqB;IAKxD,gBAAgB;IACD,CAAC,MAAM,CAAC,OAAO,CAAC;CAIhC"}
@@ -8,13 +8,10 @@ exports.ElectronRpcRequest = void 0;
8
8
  const core_common_1 = require("@itwin/core-common");
9
9
  /** @internal */
10
10
  class ElectronRpcRequest extends core_common_1.RpcRequest {
11
- constructor() {
12
- super(...arguments);
13
- this._res = () => undefined;
14
- this._fulfillment = undefined;
15
- /** Convenience access to the protocol of this request. */
16
- this.protocol = this.client.configuration.protocol;
17
- }
11
+ _res = () => undefined;
12
+ _fulfillment = undefined;
13
+ /** Convenience access to the protocol of this request. */
14
+ protocol = this.client.configuration.protocol;
18
15
  /** Sends the request. */
19
16
  async send() {
20
17
  try {
@@ -47,9 +44,9 @@ class ElectronRpcRequest extends core_common_1.RpcRequest {
47
44
  this._res(fulfillment.status);
48
45
  }
49
46
  /** @internal */
50
- dispose() {
47
+ [Symbol.dispose]() {
51
48
  this.protocol.requests.delete(this.id);
52
- super.dispose();
49
+ super[Symbol.dispose]();
53
50
  }
54
51
  }
55
52
  exports.ElectronRpcRequest = ElectronRpcRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronRpcRequest.js","sourceRoot":"","sources":["../../../src/common/ElectronRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAyF;AAGzF,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,wBAAU;IAAlD;;QACU,SAAI,GAA4B,GAAG,EAAE,CAAC,SAAS,CAAC;QAChD,iBAAY,GAAsC,SAAS,CAAC;QAEpE,0DAA0D;QACjC,aAAQ,GAAwB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAe,CAAC;IA2CrG,CAAC;IAzCC,yBAAyB;IACf,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACpD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,8BAAgB,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC,CAAC,uDAAuD;QAC1I,CAAC;QAED,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,yBAAyB;IACf,KAAK,CAAC,IAAI;QAClB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,kCAAkC;IACxB,SAAS,CAAC,KAAa,EAAE,MAAc;QAC/C,oBAAoB;IACtB,CAAC;IAED,gBAAgB;IACT,cAAc,CAAC,WAAkC;QACtD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,gBAAgB;IACA,OAAO;QACrB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAhDD,gDAgDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { RpcProtocolEvent, RpcRequest, RpcRequestFulfillment } from \"@itwin/core-common\";\nimport { ElectronRpcProtocol } from \"./ElectronRpcProtocol\";\n\n/** @internal */\nexport class ElectronRpcRequest extends RpcRequest {\n private _res: (value: number) => void = () => undefined;\n private _fulfillment: RpcRequestFulfillment | undefined = undefined;\n\n /** Convenience access to the protocol of this request. */\n public override readonly protocol: ElectronRpcProtocol = this.client.configuration.protocol as any;\n\n /** Sends the request. */\n protected async send() {\n try {\n this.protocol.requests.set(this.id, this);\n const request = await this.protocol.serialize(this);\n this.protocol.transport.sendRequest(request);\n } catch {\n this.protocol.events.raiseEvent(RpcProtocolEvent.ConnectionErrorReceived, this); // eslint-disable-line @typescript-eslint/no-deprecated\n }\n\n return new Promise<number>((resolve) => {\n this._res = resolve;\n });\n }\n\n /** Loads the request. */\n protected async load() {\n const fulfillment = this._fulfillment;\n if (!fulfillment) {\n throw new Error(\"No request fulfillment available.\");\n }\n\n return fulfillment.result;\n }\n\n /** Sets request header values. */\n protected setHeader(_name: string, _value: string): void {\n // No implementation\n }\n\n /** @internal */\n public notifyResponse(fulfillment: RpcRequestFulfillment) {\n this._fulfillment = fulfillment;\n this._res(fulfillment.status);\n }\n\n /** @internal */\n public override dispose() {\n this.protocol.requests.delete(this.id);\n super.dispose();\n }\n}\n"]}
1
+ {"version":3,"file":"ElectronRpcRequest.js","sourceRoot":"","sources":["../../../src/common/ElectronRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAyF;AAGzF,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,wBAAU;IACxC,IAAI,GAA4B,GAAG,EAAE,CAAC,SAAS,CAAC;IAChD,YAAY,GAAsC,SAAS,CAAC;IAEpE,0DAA0D;IACjC,QAAQ,GAAwB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAe,CAAC;IAEnG,yBAAyB;IAC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AC;IAC1B,CAAC;CACF;AAhDD,gDAgDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { RpcProtocolEvent, RpcRequest, RpcRequestFulfillment } from \"@itwin/core-common\";\nimport { ElectronRpcProtocol } from \"./ElectronRpcProtocol\";\n\n/** @internal */\nexport class ElectronRpcRequest extends RpcRequest {\n private _res: (value: number) => void = () => undefined;\n private _fulfillment: RpcRequestFulfillment | undefined = undefined;\n\n /** Convenience access to the protocol of this request. */\n public override readonly protocol: ElectronRpcProtocol = this.client.configuration.protocol as any;\n\n /** Sends the request. */\n protected async send() {\n try {\n this.protocol.requests.set(this.id, this);\n const request = await this.protocol.serialize(this);\n this.protocol.transport.sendRequest(request);\n } catch {\n this.protocol.events.raiseEvent(RpcProtocolEvent.ConnectionErrorReceived, this); // eslint-disable-line @typescript-eslint/no-deprecated\n }\n\n return new Promise<number>((resolve) => {\n this._res = resolve;\n });\n }\n\n /** Loads the request. */\n protected async load() {\n const fulfillment = this._fulfillment;\n if (!fulfillment) {\n throw new Error(\"No request fulfillment available.\");\n }\n\n return fulfillment.result;\n }\n\n /** Sets request header values. */\n protected setHeader(_name: string, _value: string): void {\n // No implementation\n }\n\n /** @internal */\n public notifyResponse(fulfillment: RpcRequestFulfillment) {\n this._fulfillment = fulfillment;\n this._res(fulfillment.status);\n }\n\n /** @internal */\n public override[Symbol.dispose]() {\n this.protocol.requests.delete(this.id);\n super[Symbol.dispose]();\n }\n}\n"]}
@@ -16,6 +16,7 @@ const ElectronRpcManager_1 = require("../common/ElectronRpcManager");
16
16
  * Frontend Ipc support for Electron apps.
17
17
  */
18
18
  class ElectronIpc {
19
+ _api;
19
20
  addListener(channelName, listener) {
20
21
  this._api.addListener(channelName, listener);
21
22
  return () => this._api.removeListener(channelName, listener);
@@ -41,6 +42,7 @@ class ElectronIpc {
41
42
  * @beta
42
43
  */
43
44
  class ElectronApp {
45
+ static _ipc;
44
46
  static get isValid() { return undefined !== this._ipc; }
45
47
  /**
46
48
  * Start the frontend of an Electron application.
@@ -61,8 +63,8 @@ class ElectronApp {
61
63
  await core_frontend_1.NativeApp.shutdown();
62
64
  ElectronRpcManager_1.ElectronRpcManager.terminateFrontend();
63
65
  }
66
+ /** Proxy object for calling methods of `Electron.Dialog` */
67
+ static dialogIpc = core_frontend_1.IpcApp.makeIpcFunctionProxy(ElectronIpcInterface_1.electronIpcStrings.dialogChannel, "callDialog");
64
68
  }
65
69
  exports.ElectronApp = ElectronApp;
66
- /** Proxy object for calling methods of `Electron.Dialog` */
67
- ElectronApp.dialogIpc = core_frontend_1.IpcApp.makeIpcFunctionProxy(ElectronIpcInterface_1.electronIpcStrings.dialogChannel, "callDialog");
68
70
  //# sourceMappingURL=ElectronApp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronApp.js","sourceRoot":"","sources":["../../../src/frontend/ElectronApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAAsD;AAEtD,wDAAyF;AAEzF,yEAAoE;AACpE,qEAAkE;AASlE;;GAEG;AACH,MAAM,WAAW;IAER,WAAW,CAAC,WAAmB,EAAE,QAAqB;QAC3D,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC7C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IACM,cAAc,CAAC,WAAmB,EAAE,QAAqB;QAC9D,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACM,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QACzC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;I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*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Renderer\n */\n\nimport { ProcessDetector } from \"@itwin/core-bentley\";\nimport { IpcListener, IpcSocketFrontend } from \"@itwin/core-common\";\nimport { _callIpcChannel, IpcApp, NativeApp, NativeAppOpts } from \"@itwin/core-frontend\";\nimport type { IpcRenderer } from \"electron\";\nimport { electronIpcStrings } from \"../common/ElectronIpcInterface\";\nimport { ElectronRpcManager } from \"../common/ElectronRpcManager\";\nimport type { ITwinElectronApi } from \"../common/ITwinElectronApi\";\n\ndeclare global {\n interface Window {\n itwinjs: ITwinElectronApi;\n }\n}\n\n/**\n * Frontend Ipc support for Electron apps.\n */\nclass ElectronIpc implements IpcSocketFrontend {\n private _api: ITwinElectronApi | IpcRenderer;\n public addListener(channelName: string, listener: IpcListener) {\n this._api.addListener(channelName, listener);\n return () => this._api.removeListener(channelName, listener);\n }\n public removeListener(channelName: string, listener: IpcListener) {\n this._api.removeListener(channelName, listener);\n }\n public send(channel: string, ...data: any[]) {\n this._api.send(channel, ...data);\n }\n public async invoke(channel: string, ...args: any[]) {\n return this._api.invoke(channel, ...args);\n }\n constructor() {\n // use the methods on window.itwinjs exposed by ElectronPreload.ts, or ipcRenderer directly if running with nodeIntegration=true (**only** for tests).\n // Note that `require(\"electron\")` doesn't work with nodeIntegration=false - that's what it stops\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n this._api = window.itwinjs ?? require(\"electron\").ipcRenderer;\n }\n}\n\n/** @beta */\nexport type ElectronAppOpts = NativeAppOpts;\n\n/**\n * Frontend of an Electron App.\n * @beta\n */\nexport class ElectronApp {\n private static _ipc?: ElectronIpc;\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Start the frontend of an Electron application.\n * @param opts Options for your ElectronApp\n * @note This method must only be called from the frontend of an Electron app (i.e. when [ProcessDetector.isElectronAppFrontend]($bentley) is `true`).\n */\n public static async startup(opts?: ElectronAppOpts) {\n if (!ProcessDetector.isElectronAppFrontend)\n throw new Error(\"Not running under Electron\");\n if (!this.isValid) {\n this._ipc = new ElectronIpc();\n ElectronRpcManager.initializeFrontend(this._ipc, opts?.iModelApp?.rpcInterfaces); // eslint-disable-line @typescript-eslint/no-deprecated\n }\n await NativeApp.startup(this._ipc!, opts);\n }\n\n public static async shutdown() {\n this._ipc = undefined;\n await NativeApp.shutdown();\n ElectronRpcManager.terminateFrontend();\n }\n\n /** Proxy object for calling methods of `Electron.Dialog` */\n public static dialogIpc = IpcApp.makeIpcFunctionProxy<Electron.Dialog>(electronIpcStrings.dialogChannel, \"callDialog\");\n}\n"]}
1
+ {"version":3,"file":"ElectronApp.js","sourceRoot":"","sources":["../../../src/frontend/ElectronApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAAsD;AAEtD,wDAAyF;AAEzF,yEAAoE;AACpE,qEAAkE;AASlE;;GAEG;AACH,MAAM,WAAW;IACP,IAAI,CAAiC;IACtC,WAAW,CAAC,WAAmB,EAAE,QAAqB;QAC3D,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC7C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IACM,cAAc,CAAC,WAAmB,EAAE,QAAqB;QAC9D,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IACM,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QACzC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACnC,CAAC;IACM,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,GAAG,IAAW;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD;QACE,sJAAsJ;QACtJ,iGAAiG;QACjG,iEAAiE;QACjE,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC;IAChE,CAAC;CACF;AAKD;;;GAGG;AACH,MAAa,WAAW;IACd,MAAM,CAAC,IAAI,CAAe;IAC3B,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAsB;QAChD,IAAI,CAAC,8BAAe,CAAC,qBAAqB;YACxC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,uCAAkB,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,uDAAuD;QAC3I,CAAC;QACD,MAAM,yBAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,MAAM,yBAAS,CAAC,QAAQ,EAAE,CAAC;QAC3B,uCAAkB,CAAC,iBAAiB,EAAE,CAAC;IACzC,CAAC;IAED,4DAA4D;IACrD,MAAM,CAAC,SAAS,GAAG,sBAAM,CAAC,oBAAoB,CAAkB,yCAAkB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;;AA1BzH,kCA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Renderer\n */\n\nimport { ProcessDetector } from \"@itwin/core-bentley\";\nimport { IpcListener, IpcSocketFrontend } from \"@itwin/core-common\";\nimport { _callIpcChannel, IpcApp, NativeApp, NativeAppOpts } from \"@itwin/core-frontend\";\nimport type { IpcRenderer } from \"electron\";\nimport { electronIpcStrings } from \"../common/ElectronIpcInterface\";\nimport { ElectronRpcManager } from \"../common/ElectronRpcManager\";\nimport type { ITwinElectronApi } from \"../common/ITwinElectronApi\";\n\ndeclare global {\n interface Window {\n itwinjs: ITwinElectronApi;\n }\n}\n\n/**\n * Frontend Ipc support for Electron apps.\n */\nclass ElectronIpc implements IpcSocketFrontend {\n private _api: ITwinElectronApi | IpcRenderer;\n public addListener(channelName: string, listener: IpcListener) {\n this._api.addListener(channelName, listener);\n return () => this._api.removeListener(channelName, listener);\n }\n public removeListener(channelName: string, listener: IpcListener) {\n this._api.removeListener(channelName, listener);\n }\n public send(channel: string, ...data: any[]) {\n this._api.send(channel, ...data);\n }\n public async invoke(channel: string, ...args: any[]) {\n return this._api.invoke(channel, ...args);\n }\n constructor() {\n // use the methods on window.itwinjs exposed by ElectronPreload.ts, or ipcRenderer directly if running with nodeIntegration=true (**only** for tests).\n // Note that `require(\"electron\")` doesn't work with nodeIntegration=false - that's what it stops\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n this._api = window.itwinjs ?? require(\"electron\").ipcRenderer;\n }\n}\n\n/** @beta */\nexport type ElectronAppOpts = NativeAppOpts;\n\n/**\n * Frontend of an Electron App.\n * @beta\n */\nexport class ElectronApp {\n private static _ipc?: ElectronIpc;\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Start the frontend of an Electron application.\n * @param opts Options for your ElectronApp\n * @note This method must only be called from the frontend of an Electron app (i.e. when [ProcessDetector.isElectronAppFrontend]($bentley) is `true`).\n */\n public static async startup(opts?: ElectronAppOpts) {\n if (!ProcessDetector.isElectronAppFrontend)\n throw new Error(\"Not running under Electron\");\n if (!this.isValid) {\n this._ipc = new ElectronIpc();\n ElectronRpcManager.initializeFrontend(this._ipc, opts?.iModelApp?.rpcInterfaces); // eslint-disable-line @typescript-eslint/no-deprecated\n }\n await NativeApp.startup(this._ipc!, opts);\n }\n\n public static async shutdown() {\n this._ipc = undefined;\n await NativeApp.shutdown();\n ElectronRpcManager.terminateFrontend();\n }\n\n /** Proxy object for calling methods of `Electron.Dialog` */\n public static dialogIpc = IpcApp.makeIpcFunctionProxy<Electron.Dialog>(electronIpcStrings.dialogChannel, \"callDialog\");\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-electron",
3
- "version": "5.0.0-dev.8",
3
+ "version": "5.0.0-dev.82",
4
4
  "description": "iTwin.js ElectronHost and ElectronApp",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -21,45 +21,45 @@
21
21
  "url": "http://www.bentley.com"
22
22
  },
23
23
  "peerDependencies": {
24
- "@itwin/core-backend": "^5.0.0-dev.8",
25
- "@itwin/core-bentley": "^5.0.0-dev.8",
26
- "@itwin/core-common": "^5.0.0-dev.8",
27
- "@itwin/core-frontend": "^5.0.0-dev.8",
28
- "electron": "^33.0.0"
24
+ "electron": "^35.0.0",
25
+ "@itwin/core-bentley": "5.0.0-dev.82",
26
+ "@itwin/core-backend": "5.0.0-dev.82",
27
+ "@itwin/core-frontend": "5.0.0-dev.82",
28
+ "@itwin/core-common": "5.0.0-dev.82"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@itwin/eslint-plugin": "5.0.0-dev.1",
32
32
  "@types/chai": "4.3.1",
33
33
  "@types/mocha": "^10.0.6",
34
- "@types/node": "~20.9.5",
34
+ "@types/node": "~20.17.0",
35
35
  "chai": "^4.3.10",
36
- "cpx2": "^3.0.0",
37
- "electron": "^33.0.0",
36
+ "cpx2": "^8.0.0",
37
+ "electron": "^35.0.0",
38
38
  "eslint": "^9.13.0",
39
39
  "glob": "^10.3.12",
40
- "mocha": "^10.2.0",
41
- "rimraf": "^3.0.2",
42
- "source-map-loader": "^4.0.0",
40
+ "mocha": "^11.1.0",
41
+ "rimraf": "^6.0.1",
42
+ "source-map-loader": "^5.0.0",
43
43
  "typescript": "~5.6.2",
44
- "webpack": "^5.76.0",
44
+ "webpack": "^5.97.1",
45
45
  "webpack-cli": "^5.0.1",
46
- "@itwin/build-tools": "5.0.0-dev.8",
47
- "@itwin/certa": "5.0.0-dev.8",
48
- "@itwin/core-bentley": "5.0.0-dev.8",
49
- "@itwin/core-backend": "5.0.0-dev.8",
50
- "@itwin/core-common": "5.0.0-dev.8",
51
- "@itwin/core-frontend": "5.0.0-dev.8"
46
+ "@itwin/build-tools": "5.0.0-dev.82",
47
+ "@itwin/certa": "5.0.0-dev.82",
48
+ "@itwin/core-common": "5.0.0-dev.82",
49
+ "@itwin/core-backend": "5.0.0-dev.82",
50
+ "@itwin/core-bentley": "5.0.0-dev.82",
51
+ "@itwin/core-frontend": "5.0.0-dev.82"
52
52
  },
53
53
  "dependencies": {
54
54
  "@openid/appauth": "^1.2.6",
55
55
  "open": "^7.0.0",
56
- "username": "^5.1.0"
56
+ "username": "^7.0.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "npm run -s build:cjs && npm run -s webpack:test && npm run -s copy:test-assets",
60
60
  "build:cjs": "tsc 1>&2 --outDir lib/cjs",
61
61
  "copy:test-assets": "cpx \"./src/test/assets/**/*\" ./lib/cjs/test/assets",
62
- "clean": "rimraf lib .rush/temp/package-deps*.json",
62
+ "clean": "rimraf -g lib .rush/temp/package-deps*.json",
63
63
  "docs": "betools docs --json=../../generated-docs/core/core-electron/file.json --tsIndexFile=./__DOC_ONLY__.ts --onlyJson",
64
64
  "extract-api": "betools extract-api --entry=__DOC_ONLY__",
65
65
  "lint": "eslint \"./src/**/*.ts\" 1>&2",