@itwin/core-electron 4.0.0-dev.10 → 4.0.0-dev.100

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +59 -1
  2. package/lib/cjs/ElectronBackend.d.ts +1 -1
  3. package/lib/cjs/ElectronBackend.js +21 -17
  4. package/lib/cjs/ElectronBackend.js.map +1 -1
  5. package/lib/cjs/ElectronFrontend.d.ts +1 -1
  6. package/lib/cjs/ElectronFrontend.js +21 -17
  7. package/lib/cjs/ElectronFrontend.js.map +1 -1
  8. package/lib/cjs/__DOC_ONLY__.d.ts +19 -3
  9. package/lib/cjs/__DOC_ONLY__.d.ts.map +1 -1
  10. package/lib/cjs/__DOC_ONLY__.js +42 -22
  11. package/lib/cjs/__DOC_ONLY__.js.map +1 -1
  12. package/lib/cjs/backend/ElectronHost.d.ts +107 -104
  13. package/lib/cjs/backend/ElectronHost.d.ts.map +1 -1
  14. package/lib/cjs/backend/ElectronHost.js +240 -242
  15. package/lib/cjs/backend/ElectronHost.js.map +1 -1
  16. package/lib/cjs/backend/ElectronPreload.d.ts +1 -1
  17. package/lib/cjs/backend/ElectronPreload.js +39 -39
  18. package/lib/cjs/backend/ElectronPreload.js.map +1 -1
  19. package/lib/cjs/common/ElectronIpcInterface.d.ts +10 -7
  20. package/lib/cjs/common/ElectronIpcInterface.d.ts.map +1 -1
  21. package/lib/cjs/common/ElectronIpcInterface.js +12 -5
  22. package/lib/cjs/common/ElectronIpcInterface.js.map +1 -1
  23. package/lib/cjs/common/ElectronIpcTransport.d.ts +44 -44
  24. package/lib/cjs/common/ElectronIpcTransport.js +186 -186
  25. package/lib/cjs/common/ElectronIpcTransport.js.map +1 -1
  26. package/lib/cjs/common/ElectronPush.d.ts +17 -20
  27. package/lib/cjs/common/ElectronPush.d.ts.map +1 -1
  28. package/lib/cjs/common/ElectronPush.js +45 -48
  29. package/lib/cjs/common/ElectronPush.js.map +1 -1
  30. package/lib/cjs/common/ElectronRpcManager.d.ts +23 -26
  31. package/lib/cjs/common/ElectronRpcManager.d.ts.map +1 -1
  32. package/lib/cjs/common/ElectronRpcManager.js +56 -65
  33. package/lib/cjs/common/ElectronRpcManager.js.map +1 -1
  34. package/lib/cjs/common/ElectronRpcProtocol.d.ts +34 -34
  35. package/lib/cjs/common/ElectronRpcProtocol.js +58 -58
  36. package/lib/cjs/common/ElectronRpcProtocol.js.map +1 -1
  37. package/lib/cjs/common/ElectronRpcRequest.d.ts +19 -19
  38. package/lib/cjs/common/ElectronRpcRequest.js +56 -56
  39. package/lib/cjs/common/ITwinElectronApi.d.ts +13 -10
  40. package/lib/cjs/common/ITwinElectronApi.d.ts.map +1 -1
  41. package/lib/cjs/common/ITwinElectronApi.js +6 -6
  42. package/lib/cjs/common/ITwinElectronApi.js.map +1 -1
  43. package/lib/cjs/frontend/ElectronApp.d.ts +38 -35
  44. package/lib/cjs/frontend/ElectronApp.d.ts.map +1 -1
  45. package/lib/cjs/frontend/ElectronApp.js +76 -75
  46. package/lib/cjs/frontend/ElectronApp.js.map +1 -1
  47. package/package.json +25 -26
  48. package/lib/cjs/common/ElectronManagerLoggerCategory.d.ts +0 -11
  49. package/lib/cjs/common/ElectronManagerLoggerCategory.d.ts.map +0 -1
  50. package/lib/cjs/common/ElectronManagerLoggerCategory.js +0 -19
  51. package/lib/cjs/common/ElectronManagerLoggerCategory.js.map +0 -1
@@ -1,59 +1,59 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ElectronRpcProtocol = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- const ElectronIpcTransport_1 = require("./ElectronIpcTransport");
14
- const ElectronRpcRequest_1 = require("./ElectronRpcRequest");
15
- /* eslint-disable deprecation/deprecation */
16
- /** RPC interface protocol for an Electron-based application.
17
- * @internal
18
- */
19
- class ElectronRpcProtocol extends core_common_1.RpcProtocol {
20
- /** Constructs an Electron protocol. */
21
- constructor(configuration, ipcSocket) {
22
- super(configuration);
23
- /** The RPC request class for this protocol. */
24
- this.requestType = ElectronRpcRequest_1.ElectronRpcRequest;
25
- /** Specifies where to break large binary request payloads. */
26
- this.transferChunkThreshold = 48 * 1024 * 1024;
27
- /** @internal */
28
- this.requests = new Map();
29
- this.ipcSocket = ipcSocket;
30
- this.transport = (0, ElectronIpcTransport_1.initializeIpc)(this);
31
- }
32
- /** @internal */
33
- onRpcClientInitialized(definition, _client) {
34
- this.registerInterface(definition);
35
- }
36
- /** @internal */
37
- onRpcImplInitialized(definition, _impl) {
38
- this.registerInterface(definition);
39
- }
40
- /** @internal */
41
- onRpcClientTerminated(definition, _client) {
42
- this.purgeInterface(definition);
43
- }
44
- /** @internal */
45
- onRpcImplTerminated(definition, _impl) {
46
- this.purgeInterface(definition);
47
- }
48
- registerInterface(definition) {
49
- if (ElectronRpcProtocol.instances.has(definition.interfaceName))
50
- throw new core_common_1.IModelError(core_bentley_1.BentleyStatus.ERROR, `RPC interface "${definition.interfaceName}"" is already associated with a protocol.`);
51
- ElectronRpcProtocol.instances.set(definition.interfaceName, this);
52
- }
53
- purgeInterface(definition) {
54
- ElectronRpcProtocol.instances.delete(definition.interfaceName);
55
- }
56
- }
57
- exports.ElectronRpcProtocol = ElectronRpcProtocol;
58
- ElectronRpcProtocol.instances = new Map();
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ElectronRpcProtocol = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const ElectronIpcTransport_1 = require("./ElectronIpcTransport");
14
+ const ElectronRpcRequest_1 = require("./ElectronRpcRequest");
15
+ /* eslint-disable deprecation/deprecation */
16
+ /** RPC interface protocol for an Electron-based application.
17
+ * @internal
18
+ */
19
+ class ElectronRpcProtocol extends core_common_1.RpcProtocol {
20
+ /** Constructs an Electron protocol. */
21
+ constructor(configuration, ipcSocket) {
22
+ super(configuration);
23
+ /** The RPC request class for this protocol. */
24
+ this.requestType = ElectronRpcRequest_1.ElectronRpcRequest;
25
+ /** Specifies where to break large binary request payloads. */
26
+ this.transferChunkThreshold = 48 * 1024 * 1024;
27
+ /** @internal */
28
+ this.requests = new Map();
29
+ this.ipcSocket = ipcSocket;
30
+ this.transport = (0, ElectronIpcTransport_1.initializeIpc)(this);
31
+ }
32
+ /** @internal */
33
+ onRpcClientInitialized(definition, _client) {
34
+ this.registerInterface(definition);
35
+ }
36
+ /** @internal */
37
+ onRpcImplInitialized(definition, _impl) {
38
+ this.registerInterface(definition);
39
+ }
40
+ /** @internal */
41
+ onRpcClientTerminated(definition, _client) {
42
+ this.purgeInterface(definition);
43
+ }
44
+ /** @internal */
45
+ onRpcImplTerminated(definition, _impl) {
46
+ this.purgeInterface(definition);
47
+ }
48
+ registerInterface(definition) {
49
+ if (ElectronRpcProtocol.instances.has(definition.interfaceName))
50
+ throw new core_common_1.IModelError(core_bentley_1.BentleyStatus.ERROR, `RPC interface "${definition.interfaceName}"" is already associated with a protocol.`);
51
+ ElectronRpcProtocol.instances.set(definition.interfaceName, this);
52
+ }
53
+ purgeInterface(definition) {
54
+ ElectronRpcProtocol.instances.delete(definition.interfaceName);
55
+ }
56
+ }
57
+ ElectronRpcProtocol.instances = new Map();
58
+ exports.ElectronRpcProtocol = ElectronRpcProtocol;
59
59
  //# sourceMappingURL=ElectronRpcProtocol.js.map
@@ -1 +1 @@
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,4CAA4C;AAE5C;;GAEG;AACH,MAAa,mBAAoB,SAAQ,yBAAW;IAgBlD,uCAAuC;IACvC,YAAmB,aAAuC,EAAE,SAAoB;QAC9E,KAAK,CAAC,aAAa,CAAC,CAAC;QAdvB,+CAA+C;QAC/B,gBAAW,GAAG,uCAAkB,CAAC;QAEjD,8DAA8D;QAC9C,2BAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;QAE1D,gBAAgB;QACT,aAAQ,GAAoC,IAAI,GAAG,EAAE,CAAC;QAQ3D,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;AApDe,6BAAS,GAAqC,IAAI,GAAG,EAAE,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/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError, IpcSocket, RpcInterface, RpcInterfaceDefinition, RpcProtocol } from \"@itwin/core-common\";\r\nimport { ElectronIpcTransport, initializeIpc, IpcTransportMessage } from \"./ElectronIpcTransport\";\r\nimport { ElectronRpcConfiguration } from \"./ElectronRpcManager\";\r\nimport { ElectronRpcRequest } from \"./ElectronRpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** RPC interface protocol for an Electron-based application.\r\n * @internal\r\n */\r\nexport class ElectronRpcProtocol extends RpcProtocol {\r\n public static instances: Map<string, ElectronRpcProtocol> = new Map();\r\n public ipcSocket: IpcSocket;\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = ElectronRpcRequest;\r\n\r\n /** Specifies where to break large binary request payloads. */\r\n public override transferChunkThreshold = 48 * 1024 * 1024;\r\n\r\n /** @internal */\r\n public requests: Map<string, ElectronRpcRequest> = new Map();\r\n\r\n /** @internal */\r\n public readonly transport: ElectronIpcTransport<IpcTransportMessage, IpcTransportMessage>;\r\n\r\n /** Constructs an Electron protocol. */\r\n public constructor(configuration: ElectronRpcConfiguration, ipcSocket: IpcSocket) {\r\n super(configuration);\r\n this.ipcSocket = ipcSocket;\r\n this.transport = initializeIpc(this);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcClientInitialized(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\r\n this.registerInterface(definition);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcImplInitialized(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\r\n this.registerInterface(definition);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcClientTerminated(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\r\n this.purgeInterface(definition);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcImplTerminated(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\r\n this.purgeInterface(definition);\r\n }\r\n\r\n private registerInterface(definition: RpcInterfaceDefinition) {\r\n if (ElectronRpcProtocol.instances.has(definition.interfaceName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${definition.interfaceName}\"\" is already associated with a protocol.`);\r\n\r\n ElectronRpcProtocol.instances.set(definition.interfaceName, this);\r\n }\r\n\r\n private purgeInterface(definition: RpcInterfaceDefinition) {\r\n ElectronRpcProtocol.instances.delete(definition.interfaceName);\r\n }\r\n}\r\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,4CAA4C;AAE5C;;GAEG;AACH,MAAa,mBAAoB,SAAQ,yBAAW;IAgBlD,uCAAuC;IACvC,YAAmB,aAAuC,EAAE,SAAoB;QAC9E,KAAK,CAAC,aAAa,CAAC,CAAC;QAdvB,+CAA+C;QAC/B,gBAAW,GAAG,uCAAkB,CAAC;QAEjD,8DAA8D;QAC9C,2BAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;QAE1D,gBAAgB;QACT,aAAQ,GAAoC,IAAI,GAAG,EAAE,CAAC;QAQ3D,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;;AAnDa,6BAAS,GAAqC,IAAI,GAAG,EAAE,AAA9C,CAA+C;AAD3D,kDAAmB","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/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError, IpcSocket, RpcInterface, RpcInterfaceDefinition, RpcProtocol } from \"@itwin/core-common\";\r\nimport { ElectronIpcTransport, initializeIpc, IpcTransportMessage } from \"./ElectronIpcTransport\";\r\nimport { ElectronRpcConfiguration } from \"./ElectronRpcManager\";\r\nimport { ElectronRpcRequest } from \"./ElectronRpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** RPC interface protocol for an Electron-based application.\r\n * @internal\r\n */\r\nexport class ElectronRpcProtocol extends RpcProtocol {\r\n public static instances: Map<string, ElectronRpcProtocol> = new Map();\r\n public ipcSocket: IpcSocket;\r\n\r\n /** The RPC request class for this protocol. */\r\n public readonly requestType = ElectronRpcRequest;\r\n\r\n /** Specifies where to break large binary request payloads. */\r\n public override transferChunkThreshold = 48 * 1024 * 1024;\r\n\r\n /** @internal */\r\n public requests: Map<string, ElectronRpcRequest> = new Map();\r\n\r\n /** @internal */\r\n public readonly transport: ElectronIpcTransport<IpcTransportMessage, IpcTransportMessage>;\r\n\r\n /** Constructs an Electron protocol. */\r\n public constructor(configuration: ElectronRpcConfiguration, ipcSocket: IpcSocket) {\r\n super(configuration);\r\n this.ipcSocket = ipcSocket;\r\n this.transport = initializeIpc(this);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcClientInitialized(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\r\n this.registerInterface(definition);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcImplInitialized(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\r\n this.registerInterface(definition);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcClientTerminated(definition: RpcInterfaceDefinition, _client: RpcInterface): void {\r\n this.purgeInterface(definition);\r\n }\r\n\r\n /** @internal */\r\n public override onRpcImplTerminated(definition: RpcInterfaceDefinition, _impl: RpcInterface): void {\r\n this.purgeInterface(definition);\r\n }\r\n\r\n private registerInterface(definition: RpcInterfaceDefinition) {\r\n if (ElectronRpcProtocol.instances.has(definition.interfaceName))\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface \"${definition.interfaceName}\"\" is already associated with a protocol.`);\r\n\r\n ElectronRpcProtocol.instances.set(definition.interfaceName, this);\r\n }\r\n\r\n private purgeInterface(definition: RpcInterfaceDefinition) {\r\n ElectronRpcProtocol.instances.delete(definition.interfaceName);\r\n }\r\n}\r\n"]}
@@ -1,20 +1,20 @@
1
- import { RpcRequest, RpcRequestFulfillment } from "@itwin/core-common";
2
- import { ElectronRpcProtocol } from "./ElectronRpcProtocol";
3
- /** @internal */
4
- export declare class ElectronRpcRequest extends RpcRequest {
5
- private _res;
6
- private _fulfillment;
7
- /** Convenience access to the protocol of this request. */
8
- readonly protocol: ElectronRpcProtocol;
9
- /** Sends the request. */
10
- protected send(): Promise<number>;
11
- /** Loads the request. */
12
- protected load(): Promise<import("@itwin/core-common").RpcSerializedValue>;
13
- /** Sets request header values. */
14
- protected setHeader(_name: string, _value: string): void;
15
- /** @internal */
16
- notifyResponse(fulfillment: RpcRequestFulfillment): void;
17
- /** @internal */
18
- dispose(): void;
19
- }
1
+ import { RpcRequest, RpcRequestFulfillment } from "@itwin/core-common";
2
+ import { ElectronRpcProtocol } from "./ElectronRpcProtocol";
3
+ /** @internal */
4
+ export declare class ElectronRpcRequest extends RpcRequest {
5
+ private _res;
6
+ private _fulfillment;
7
+ /** Convenience access to the protocol of this request. */
8
+ readonly protocol: ElectronRpcProtocol;
9
+ /** Sends the request. */
10
+ protected send(): Promise<number>;
11
+ /** Loads the request. */
12
+ protected load(): Promise<import("@itwin/core-common").RpcSerializedValue>;
13
+ /** Sets request header values. */
14
+ protected setHeader(_name: string, _value: string): void;
15
+ /** @internal */
16
+ notifyResponse(fulfillment: RpcRequestFulfillment): void;
17
+ /** @internal */
18
+ dispose(): void;
19
+ }
20
20
  //# sourceMappingURL=ElectronRpcRequest.d.ts.map
@@ -1,57 +1,57 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ElectronRpcRequest = void 0;
8
- const core_common_1 = require("@itwin/core-common");
9
- /* eslint-disable deprecation/deprecation */
10
- /** @internal */
11
- class ElectronRpcRequest extends core_common_1.RpcRequest {
12
- constructor() {
13
- super(...arguments);
14
- this._res = () => undefined;
15
- this._fulfillment = undefined;
16
- /** Convenience access to the protocol of this request. */
17
- this.protocol = this.client.configuration.protocol;
18
- }
19
- /** Sends the request. */
20
- async send() {
21
- try {
22
- this.protocol.requests.set(this.id, this);
23
- const request = await this.protocol.serialize(this);
24
- this.protocol.transport.sendRequest(request);
25
- }
26
- catch (e) {
27
- this.protocol.events.raiseEvent(core_common_1.RpcProtocolEvent.ConnectionErrorReceived, this);
28
- }
29
- return new Promise((resolve) => {
30
- this._res = resolve;
31
- });
32
- }
33
- /** Loads the request. */
34
- async load() {
35
- const fulfillment = this._fulfillment;
36
- if (!fulfillment) {
37
- throw new Error("No request fulfillment available.");
38
- }
39
- return fulfillment.result;
40
- }
41
- /** Sets request header values. */
42
- setHeader(_name, _value) {
43
- // No implementation
44
- }
45
- /** @internal */
46
- notifyResponse(fulfillment) {
47
- this._fulfillment = fulfillment;
48
- this._res(fulfillment.status);
49
- }
50
- /** @internal */
51
- dispose() {
52
- this.protocol.requests.delete(this.id);
53
- super.dispose();
54
- }
55
- }
56
- exports.ElectronRpcRequest = ElectronRpcRequest;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ElectronRpcRequest = void 0;
8
+ const core_common_1 = require("@itwin/core-common");
9
+ /* eslint-disable deprecation/deprecation */
10
+ /** @internal */
11
+ class ElectronRpcRequest extends core_common_1.RpcRequest {
12
+ constructor() {
13
+ super(...arguments);
14
+ this._res = () => undefined;
15
+ this._fulfillment = undefined;
16
+ /** Convenience access to the protocol of this request. */
17
+ this.protocol = this.client.configuration.protocol;
18
+ }
19
+ /** Sends the request. */
20
+ async send() {
21
+ try {
22
+ this.protocol.requests.set(this.id, this);
23
+ const request = await this.protocol.serialize(this);
24
+ this.protocol.transport.sendRequest(request);
25
+ }
26
+ catch (e) {
27
+ this.protocol.events.raiseEvent(core_common_1.RpcProtocolEvent.ConnectionErrorReceived, this);
28
+ }
29
+ return new Promise((resolve) => {
30
+ this._res = resolve;
31
+ });
32
+ }
33
+ /** Loads the request. */
34
+ async load() {
35
+ const fulfillment = this._fulfillment;
36
+ if (!fulfillment) {
37
+ throw new Error("No request fulfillment available.");
38
+ }
39
+ return fulfillment.result;
40
+ }
41
+ /** Sets request header values. */
42
+ setHeader(_name, _value) {
43
+ // No implementation
44
+ }
45
+ /** @internal */
46
+ notifyResponse(fulfillment) {
47
+ this._fulfillment = fulfillment;
48
+ this._res(fulfillment.status);
49
+ }
50
+ /** @internal */
51
+ dispose() {
52
+ this.protocol.requests.delete(this.id);
53
+ super.dispose();
54
+ }
55
+ }
56
+ exports.ElectronRpcRequest = ElectronRpcRequest;
57
57
  //# sourceMappingURL=ElectronRpcRequest.js.map
@@ -1,11 +1,14 @@
1
- import type { IpcRendererEvent } from "electron";
2
- /** These methods are stored on `window.itwinjs` */
3
- export interface ITwinElectronApi {
4
- addListener: (channel: string, listener: ElectronListener) => void;
5
- removeListener: (channel: string, listener: ElectronListener) => void;
6
- invoke: (channel: string, ...data: any[]) => Promise<any>;
7
- once: (channel: string, listener: (event: any, ...args: any[]) => void) => void;
8
- send: (channel: string, ...data: any[]) => void;
9
- }
10
- export declare type ElectronListener = (event: IpcRendererEvent, ...args: any[]) => void;
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import type { IpcRendererEvent } from "electron";
5
+ /** These methods are stored on `window.itwinjs` */
6
+ export interface ITwinElectronApi {
7
+ addListener: (channel: string, listener: ElectronListener) => void;
8
+ removeListener: (channel: string, listener: ElectronListener) => void;
9
+ invoke: (channel: string, ...data: any[]) => Promise<any>;
10
+ once: (channel: string, listener: (event: any, ...args: any[]) => void) => void;
11
+ send: (channel: string, ...data: any[]) => void;
12
+ }
13
+ export type ElectronListener = (event: IpcRendererEvent, ...args: any[]) => void;
11
14
  //# sourceMappingURL=ITwinElectronApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ITwinElectronApi.d.ts","sourceRoot":"","sources":["../../../src/common/ITwinElectronApi.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACnE,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtE,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1D,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAChF,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjD;AAED,oBAAY,gBAAgB,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
1
+ {"version":3,"file":"ITwinElectronApi.d.ts","sourceRoot":"","sources":["../../../src/common/ITwinElectronApi.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACnE,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtE,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1D,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAChF,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
@@ -1,7 +1,7 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  //# sourceMappingURL=ITwinElectronApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ITwinElectronApi.js","sourceRoot":"","sources":["../../../src/common/ITwinElectronApi.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","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\nimport type { IpcRendererEvent } from \"electron\";\r\n\r\n/** These methods are stored on `window.itwinjs` */\r\nexport interface ITwinElectronApi {\r\n addListener: (channel: string, listener: ElectronListener) => void;\r\n removeListener: (channel: string, listener: ElectronListener) => void;\r\n invoke: (channel: string, ...data: any[]) => Promise<any>;\r\n once: (channel: string, listener: (event: any, ...args: any[]) => void) => void;\r\n send: (channel: string, ...data: any[]) => void; // only valid for render -> main\r\n}\r\n\r\nexport type ElectronListener = (event: IpcRendererEvent, ...args: any[]) => void;\r\n"]}
1
+ {"version":3,"file":"ITwinElectronApi.js","sourceRoot":"","sources":["../../../src/common/ITwinElectronApi.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","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 RpcInterface\r\n */\r\n\r\nimport type { IpcRendererEvent } from \"electron\";\r\n\r\n/** These methods are stored on `window.itwinjs` */\r\nexport interface ITwinElectronApi {\r\n addListener: (channel: string, listener: ElectronListener) => void;\r\n removeListener: (channel: string, listener: ElectronListener) => void;\r\n invoke: (channel: string, ...data: any[]) => Promise<any>;\r\n once: (channel: string, listener: (event: any, ...args: any[]) => void) => void;\r\n send: (channel: string, ...data: any[]) => void; // only valid for render -> main\r\n}\r\n\r\nexport type ElectronListener = (event: IpcRendererEvent, ...args: any[]) => void;\r\n"]}
@@ -1,36 +1,39 @@
1
- import { PromiseReturnType } from "@itwin/core-bentley";
2
- import { NativeAppOpts } from "@itwin/core-frontend";
3
- import { DialogModuleMethod } from "../common/ElectronIpcInterface";
4
- import type { ITwinElectronApi } from "../common/ITwinElectronApi";
5
- declare global {
6
- interface Window {
7
- itwinjs: ITwinElectronApi;
8
- }
9
- }
10
- /** @beta */
11
- export declare type ElectronAppOpts = NativeAppOpts;
12
- /**
13
- * Frontend of an Electron App.
14
- * @beta
15
- */
16
- export declare class ElectronApp {
17
- private static _ipc?;
18
- static get isValid(): boolean;
19
- /**
20
- * Start the frontend of an Electron application.
21
- * @param opts Options for your ElectronApp
22
- * @note This method must only be called from the frontend of an Electron app (i.e. when [ProcessDetector.isElectronAppFrontend]($bentley) is `true`).
23
- */
24
- static startup(opts?: ElectronAppOpts): Promise<void>;
25
- static shutdown(): Promise<void>;
26
- /**
27
- * Call an asynchronous method in the [Electron.Dialog](https://www.electronjs.org/docs/api/dialog) interface from a previously initialized ElectronFrontend.
28
- * @param methodName the name of the method to call
29
- * @param args arguments to method
30
- * @deprecated in 3.x. use [[dialogIpc]]
31
- */
32
- static callDialog<T extends DialogModuleMethod>(methodName: T, ...args: Parameters<Electron.Dialog[T]>): Promise<PromiseReturnType<Electron.Dialog[T]>>;
33
- /** Proxy object for calling methods of `Electron.Dialog` */
34
- static dialogIpc: import("@itwin/core-bentley").PickAsyncMethods<Electron.Dialog>;
35
- }
1
+ /** @packageDocumentation
2
+ * @module Renderer
3
+ */
4
+ import { PromiseReturnType } from "@itwin/core-bentley";
5
+ import { NativeAppOpts } from "@itwin/core-frontend";
6
+ import { DialogModuleMethod } from "../common/ElectronIpcInterface";
7
+ import type { ITwinElectronApi } from "../common/ITwinElectronApi";
8
+ declare global {
9
+ interface Window {
10
+ itwinjs: ITwinElectronApi;
11
+ }
12
+ }
13
+ /** @beta */
14
+ export type ElectronAppOpts = NativeAppOpts;
15
+ /**
16
+ * Frontend of an Electron App.
17
+ * @beta
18
+ */
19
+ export declare class ElectronApp {
20
+ private static _ipc?;
21
+ static get isValid(): boolean;
22
+ /**
23
+ * Start the frontend of an Electron application.
24
+ * @param opts Options for your ElectronApp
25
+ * @note This method must only be called from the frontend of an Electron app (i.e. when [ProcessDetector.isElectronAppFrontend]($bentley) is `true`).
26
+ */
27
+ static startup(opts?: ElectronAppOpts): Promise<void>;
28
+ static shutdown(): Promise<void>;
29
+ /**
30
+ * Call an asynchronous method in the [Electron.Dialog](https://www.electronjs.org/docs/api/dialog) interface from a previously initialized ElectronFrontend.
31
+ * @param methodName the name of the method to call
32
+ * @param args arguments to method
33
+ * @deprecated in 3.x. use [[dialogIpc]]
34
+ */
35
+ static callDialog<T extends DialogModuleMethod>(methodName: T, ...args: Parameters<Electron.Dialog[T]>): Promise<PromiseReturnType<Electron.Dialog[T]>>;
36
+ /** Proxy object for calling methods of `Electron.Dialog` */
37
+ static dialogIpc: import("@itwin/core-bentley").PickAsyncMethods<Electron.Dialog>;
38
+ }
36
39
  //# sourceMappingURL=ElectronApp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/ElectronApp.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAqB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,gBAAgB,CAAC;KAC3B;CACF;AA4BD,YAAY;AACZ,oBAAY,eAAe,GAAG,aAAa,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAc;IAClC,WAAkB,OAAO,IAAI,OAAO,CAAoC;IAExE;;;;OAIG;WACiB,OAAO,CAAC,IAAI,CAAC,EAAE,eAAe;WAU9B,QAAQ;IAM5B;;;;;OAKG;WACiB,UAAU,CAAC,CAAC,SAAS,kBAAkB,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAInH,4DAA4D;IAC5D,OAAc,SAAS,kEAA6E;CACrG"}
1
+ {"version":3,"file":"ElectronApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/ElectronApp.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAmB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAqB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,gBAAgB,CAAC;KAC3B;CACF;AA4BD,YAAY;AACZ,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAc;IAClC,WAAkB,OAAO,IAAI,OAAO,CAAoC;IAExE;;;;OAIG;WACiB,OAAO,CAAC,IAAI,CAAC,EAAE,eAAe;WAU9B,QAAQ;IAM5B;;;;;OAKG;WACiB,UAAU,CAAC,CAAC,SAAS,kBAAkB,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAInH,4DAA4D;IAC5D,OAAc,SAAS,kEAA6E;CACrG"}
@@ -1,76 +1,77 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElectronApp = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- const core_bentley_1 = require("@itwin/core-bentley");
9
- const core_frontend_1 = require("@itwin/core-frontend");
10
- const ElectronIpcInterface_1 = require("../common/ElectronIpcInterface");
11
- const ElectronRpcManager_1 = require("../common/ElectronRpcManager");
12
- /**
13
- * Frontend Ipc support for Electron apps.
14
- */
15
- class ElectronIpc {
16
- constructor() {
17
- var _a;
18
- // use the methods on window.itwinjs exposed by ElectronPreload.ts, or ipcRenderer directly if running with nodeIntegration=true (**only** for tests).
19
- // Note that `require("electron")` doesn't work with nodeIntegration=false - that's what it stops
20
- // eslint-disable-next-line @typescript-eslint/no-var-requires
21
- this._api = (_a = window.itwinjs) !== null && _a !== void 0 ? _a : require("electron").ipcRenderer;
22
- }
23
- addListener(channelName, listener) {
24
- this._api.addListener(channelName, listener);
25
- return () => this._api.removeListener(channelName, listener);
26
- }
27
- removeListener(channelName, listener) {
28
- this._api.removeListener(channelName, listener);
29
- }
30
- send(channel, ...data) {
31
- this._api.send(channel, ...data);
32
- }
33
- async invoke(channel, ...args) {
34
- return this._api.invoke(channel, ...args);
35
- }
36
- }
37
- /**
38
- * Frontend of an Electron App.
39
- * @beta
40
- */
41
- class ElectronApp {
42
- static get isValid() { return undefined !== this._ipc; }
43
- /**
44
- * Start the frontend of an Electron application.
45
- * @param opts Options for your ElectronApp
46
- * @note This method must only be called from the frontend of an Electron app (i.e. when [ProcessDetector.isElectronAppFrontend]($bentley) is `true`).
47
- */
48
- static async startup(opts) {
49
- var _a;
50
- if (!core_bentley_1.ProcessDetector.isElectronAppFrontend)
51
- throw new Error("Not running under Electron");
52
- if (!this.isValid) {
53
- this._ipc = new ElectronIpc();
54
- ElectronRpcManager_1.ElectronRpcManager.initializeFrontend(this._ipc, (_a = opts === null || opts === void 0 ? void 0 : opts.iModelApp) === null || _a === void 0 ? void 0 : _a.rpcInterfaces);
55
- }
56
- await core_frontend_1.NativeApp.startup(this._ipc, opts);
57
- }
58
- static async shutdown() {
59
- this._ipc = undefined;
60
- await core_frontend_1.NativeApp.shutdown();
61
- ElectronRpcManager_1.ElectronRpcManager.terminateFrontend();
62
- }
63
- /**
64
- * Call an asynchronous method in the [Electron.Dialog](https://www.electronjs.org/docs/api/dialog) interface from a previously initialized ElectronFrontend.
65
- * @param methodName the name of the method to call
66
- * @param args arguments to method
67
- * @deprecated in 3.x. use [[dialogIpc]]
68
- */
69
- static async callDialog(methodName, ...args) {
70
- return core_frontend_1.IpcApp.callIpcChannel(ElectronIpcInterface_1.dialogChannel, "callDialog", methodName, ...args);
71
- }
72
- }
73
- exports.ElectronApp = ElectronApp;
74
- /** Proxy object for calling methods of `Electron.Dialog` */
75
- ElectronApp.dialogIpc = core_frontend_1.IpcApp.makeIpcFunctionProxy(ElectronIpcInterface_1.dialogChannel, "callDialog");
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ElectronApp = void 0;
8
+ /** @packageDocumentation
9
+ * @module Renderer
10
+ */
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_frontend_1 = require("@itwin/core-frontend");
13
+ const ElectronIpcInterface_1 = require("../common/ElectronIpcInterface");
14
+ const ElectronRpcManager_1 = require("../common/ElectronRpcManager");
15
+ /**
16
+ * Frontend Ipc support for Electron apps.
17
+ */
18
+ class ElectronIpc {
19
+ addListener(channelName, listener) {
20
+ this._api.addListener(channelName, listener);
21
+ return () => this._api.removeListener(channelName, listener);
22
+ }
23
+ removeListener(channelName, listener) {
24
+ this._api.removeListener(channelName, listener);
25
+ }
26
+ send(channel, ...data) {
27
+ this._api.send(channel, ...data);
28
+ }
29
+ async invoke(channel, ...args) {
30
+ return this._api.invoke(channel, ...args);
31
+ }
32
+ constructor() {
33
+ // use the methods on window.itwinjs exposed by ElectronPreload.ts, or ipcRenderer directly if running with nodeIntegration=true (**only** for tests).
34
+ // Note that `require("electron")` doesn't work with nodeIntegration=false - that's what it stops
35
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
36
+ this._api = window.itwinjs ?? require("electron").ipcRenderer;
37
+ }
38
+ }
39
+ /**
40
+ * Frontend of an Electron App.
41
+ * @beta
42
+ */
43
+ class ElectronApp {
44
+ static get isValid() { return undefined !== this._ipc; }
45
+ /**
46
+ * Start the frontend of an Electron application.
47
+ * @param opts Options for your ElectronApp
48
+ * @note This method must only be called from the frontend of an Electron app (i.e. when [ProcessDetector.isElectronAppFrontend]($bentley) is `true`).
49
+ */
50
+ static async startup(opts) {
51
+ if (!core_bentley_1.ProcessDetector.isElectronAppFrontend)
52
+ throw new Error("Not running under Electron");
53
+ if (!this.isValid) {
54
+ this._ipc = new ElectronIpc();
55
+ ElectronRpcManager_1.ElectronRpcManager.initializeFrontend(this._ipc, opts?.iModelApp?.rpcInterfaces); // eslint-disable-line deprecation/deprecation
56
+ }
57
+ await core_frontend_1.NativeApp.startup(this._ipc, opts);
58
+ }
59
+ static async shutdown() {
60
+ this._ipc = undefined;
61
+ await core_frontend_1.NativeApp.shutdown();
62
+ ElectronRpcManager_1.ElectronRpcManager.terminateFrontend();
63
+ }
64
+ /**
65
+ * Call an asynchronous method in the [Electron.Dialog](https://www.electronjs.org/docs/api/dialog) interface from a previously initialized ElectronFrontend.
66
+ * @param methodName the name of the method to call
67
+ * @param args arguments to method
68
+ * @deprecated in 3.x. use [[dialogIpc]]
69
+ */
70
+ static async callDialog(methodName, ...args) {
71
+ return core_frontend_1.IpcApp.callIpcChannel(ElectronIpcInterface_1.dialogChannel, "callDialog", methodName, ...args);
72
+ }
73
+ }
74
+ /** Proxy object for calling methods of `Electron.Dialog` */
75
+ ElectronApp.dialogIpc = core_frontend_1.IpcApp.makeIpcFunctionProxy(ElectronIpcInterface_1.dialogChannel, "callDialog");
76
+ exports.ElectronApp = ElectronApp;
76
77
  //# sourceMappingURL=ElectronApp.js.map