@3fv/electron-utility-process-manager 1.0.1

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 (97) hide show
  1. package/.prettierrc.js +14 -0
  2. package/README.md +166 -0
  3. package/examples/lib-examples/complex/complex-main.d.ts +1 -0
  4. package/examples/lib-examples/complex/complex-main.js +108 -0
  5. package/examples/lib-examples/complex/complex-main.js.map +1 -0
  6. package/examples/lib-examples/complex/complex-node.d.ts +1 -0
  7. package/examples/lib-examples/complex/complex-node.js +17 -0
  8. package/examples/lib-examples/complex/complex-node.js.map +1 -0
  9. package/examples/lib-examples/complex/complex-renderer.d.ts +1 -0
  10. package/examples/lib-examples/complex/complex-renderer.js +18 -0
  11. package/examples/lib-examples/complex/complex-renderer.js.map +1 -0
  12. package/examples/lib-examples/complex/complex-types.d.ts +3 -0
  13. package/examples/lib-examples/complex/complex-types.js +3 -0
  14. package/examples/lib-examples/complex/complex-types.js.map +1 -0
  15. package/examples/lib-examples/simple/simple-main.d.ts +1 -0
  16. package/examples/lib-examples/simple/simple-main.js +106 -0
  17. package/examples/lib-examples/simple/simple-main.js.map +1 -0
  18. package/examples/lib-examples/simple/simple-node.d.ts +1 -0
  19. package/examples/lib-examples/simple/simple-node.js +17 -0
  20. package/examples/lib-examples/simple/simple-node.js.map +1 -0
  21. package/examples/lib-examples/simple/simple-renderer.d.ts +1 -0
  22. package/examples/lib-examples/simple/simple-renderer.js +17 -0
  23. package/examples/lib-examples/simple/simple-renderer.js.map +1 -0
  24. package/jest.config.js +20 -0
  25. package/lib/cjs/common/clients.d.ts +103 -0
  26. package/lib/cjs/common/clients.js +180 -0
  27. package/lib/cjs/common/clients.js.map +1 -0
  28. package/lib/cjs/common/guards.d.ts +4 -0
  29. package/lib/cjs/common/guards.js +12 -0
  30. package/lib/cjs/common/guards.js.map +1 -0
  31. package/lib/cjs/common/index.d.ts +3 -0
  32. package/lib/cjs/common/index.js +20 -0
  33. package/lib/cjs/common/index.js.map +1 -0
  34. package/lib/cjs/common/types.d.ts +49 -0
  35. package/lib/cjs/common/types.js +21 -0
  36. package/lib/cjs/common/types.js.map +1 -0
  37. package/lib/cjs/index.d.ts +4 -0
  38. package/lib/cjs/index.js +34 -0
  39. package/lib/cjs/index.js.map +1 -0
  40. package/lib/cjs/main/UPMMainService.d.ts +69 -0
  41. package/lib/cjs/main/UPMMainService.js +292 -0
  42. package/lib/cjs/main/UPMMainService.js.map +1 -0
  43. package/lib/cjs/main/UPMMainServiceManager.d.ts +58 -0
  44. package/lib/cjs/main/UPMMainServiceManager.js +168 -0
  45. package/lib/cjs/main/UPMMainServiceManager.js.map +1 -0
  46. package/lib/cjs/main/index.d.ts +2 -0
  47. package/lib/cjs/main/index.js +19 -0
  48. package/lib/cjs/main/index.js.map +1 -0
  49. package/lib/cjs/node/UPMNodeProcess.d.ts +25 -0
  50. package/lib/cjs/node/UPMNodeProcess.js +155 -0
  51. package/lib/cjs/node/UPMNodeProcess.js.map +1 -0
  52. package/lib/cjs/node/index.d.ts +3 -0
  53. package/lib/cjs/node/index.js +23 -0
  54. package/lib/cjs/node/index.js.map +1 -0
  55. package/lib/cjs/renderer/UPMRendererClientFactory.d.ts +5 -0
  56. package/lib/cjs/renderer/UPMRendererClientFactory.js +77 -0
  57. package/lib/cjs/renderer/UPMRendererClientFactory.js.map +1 -0
  58. package/lib/cjs/renderer/index.d.ts +3 -0
  59. package/lib/cjs/renderer/index.js +23 -0
  60. package/lib/cjs/renderer/index.js.map +1 -0
  61. package/lib/mjs/common/clients.d.ts +103 -0
  62. package/lib/mjs/common/clients.js +173 -0
  63. package/lib/mjs/common/clients.js.map +1 -0
  64. package/lib/mjs/common/guards.d.ts +4 -0
  65. package/lib/mjs/common/guards.js +8 -0
  66. package/lib/mjs/common/guards.js.map +1 -0
  67. package/lib/mjs/common/index.d.ts +3 -0
  68. package/lib/mjs/common/index.js +4 -0
  69. package/lib/mjs/common/index.js.map +1 -0
  70. package/lib/mjs/common/types.d.ts +49 -0
  71. package/lib/mjs/common/types.js +18 -0
  72. package/lib/mjs/common/types.js.map +1 -0
  73. package/lib/mjs/index.d.ts +4 -0
  74. package/lib/mjs/index.js +5 -0
  75. package/lib/mjs/index.js.map +1 -0
  76. package/lib/mjs/main/UPMMainService.d.ts +69 -0
  77. package/lib/mjs/main/UPMMainService.js +262 -0
  78. package/lib/mjs/main/UPMMainService.js.map +1 -0
  79. package/lib/mjs/main/UPMMainServiceManager.d.ts +58 -0
  80. package/lib/mjs/main/UPMMainServiceManager.js +138 -0
  81. package/lib/mjs/main/UPMMainServiceManager.js.map +1 -0
  82. package/lib/mjs/main/index.d.ts +2 -0
  83. package/lib/mjs/main/index.js +3 -0
  84. package/lib/mjs/main/index.js.map +1 -0
  85. package/lib/mjs/node/UPMNodeProcess.d.ts +25 -0
  86. package/lib/mjs/node/UPMNodeProcess.js +125 -0
  87. package/lib/mjs/node/UPMNodeProcess.js.map +1 -0
  88. package/lib/mjs/node/index.d.ts +3 -0
  89. package/lib/mjs/node/index.js +4 -0
  90. package/lib/mjs/node/index.js.map +1 -0
  91. package/lib/mjs/renderer/UPMRendererClientFactory.d.ts +5 -0
  92. package/lib/mjs/renderer/UPMRendererClientFactory.js +47 -0
  93. package/lib/mjs/renderer/UPMRendererClientFactory.js.map +1 -0
  94. package/lib/mjs/renderer/index.d.ts +3 -0
  95. package/lib/mjs/renderer/index.js +4 -0
  96. package/lib/mjs/renderer/index.js.map +1 -0
  97. package/package.json +104 -0
package/.prettierrc.js ADDED
@@ -0,0 +1,14 @@
1
+
2
+ module.exports = {
3
+ "trailingComma": "none",
4
+ "tabWidth": 2,
5
+ embeddedLanguageFormatting: "auto",
6
+ printWidth: 60,
7
+ "semi": false,
8
+ "singleQuote": false,
9
+ // parser: "typescript",
10
+ parser: "babel",
11
+ bracketSpacing: true,
12
+ useTabs: false,
13
+ proseWrap: "always"
14
+ }
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # @3fv/electron-utility-process-manager
2
+ ---
3
+
4
+ ## Overview
5
+
6
+ `@3fv/electron-utility-process-manager` manages `1..n` `Electron.utilityProcess` instances/services/processes via a
7
+ single library & provides fully typed client facades automatically
8
+
9
+ ## Install
10
+
11
+ ```shell
12
+ yarn add @3fv/electron-utility-process-manager
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ This library integrates into the `node`, `main` and `renderer` processes to provide
18
+ transparent access from any process to a `node` (`Electron.utilityProcess`).
19
+
20
+ ### Possible Use-cases
21
+
22
+ - main -> node
23
+ - renderer -> node
24
+ - node -> node
25
+
26
+ ### Examples
27
+
28
+ #### Simple Example
29
+
30
+ > NOTE: The simple example uses the bare-bones approach
31
+ > and basically avoids typing wherever possible. For a
32
+ > fully typed example, checkout the [complex example](#complex-example)
33
+
34
+ ##### Node/Utility Process ([simple-node.ts](examples/simple/simple-node.ts))
35
+
36
+ ```typescript
37
+ import upmNodeProcess from "@3fv/electron-utility-process-manager/node"
38
+
39
+ upmNodeProcess.addEventHandler((clientId, port, payload) => {
40
+ console.info(`Received event from (${clientId})`, payload)
41
+ return true
42
+ })
43
+
44
+ upmNodeProcess.addRequestHandler("ping", async (type, messageId, what: string) => {
45
+ console.info(`Ping request received (${messageId})`, what)
46
+ return `pong: ${what}`
47
+ })
48
+ ```
49
+
50
+ ##### Main Process ([simple-main.ts](examples/simple/simple-main.ts))
51
+
52
+ ```typescript
53
+ import { app, BrowserWindow } from "electron"
54
+ import { UPM } from "@3fv/electron-utility-process-manager"
55
+ import type { UPMMainService } from "@3fv/electron-utility-process-manager/main"
56
+ import Path from "path"
57
+
58
+ let upmService: UPMMainService = null
59
+
60
+ async function start() {
61
+ const upm = await import("@3fv/electron-utility-process-manager/main")
62
+ const upmManager = upm.upmMainServiceManager
63
+
64
+ Object.assign(global, {
65
+ upm,
66
+ upmManager
67
+ })
68
+
69
+ console.info("UPM manager ready, now creating service", upmManager)
70
+ upmService = await upmManager.createService("simple", Path.join(__dirname, "simple-node.js"))
71
+ console.info("UPM service ready")
72
+
73
+ upmService.sendEvent("test123")
74
+
75
+ const clientPort = upmManager.createMainChannel("simple", "main-channel-01")
76
+ console.info("Start the client port")
77
+ if (UPM.isMessagePort(clientPort))
78
+ clientPort.start()
79
+
80
+ console.info("Post a message directly")
81
+ clientPort.postMessage({
82
+ channel: UPM.IPCChannel.UPMServiceMessage,
83
+ payload: { kind: UPM.MessageKind.Event, messageId: -1, data: { test: "test456" } }
84
+ })
85
+
86
+ console.info("Send event via the UPMMainService wrapper")
87
+ upmService.sendEvent({ test: "test789" }, clientPort)
88
+
89
+ console.info(`Creating port client`)
90
+ const client = upmManager.createMainClient("simple", "main-client-01")
91
+ console.info(`Send request/response: ping`)
92
+
93
+ const pongResult = await client.executeRequest("ping", ["main"])
94
+ console.info(`Received pong response`, pongResult)
95
+
96
+ await createWindow()
97
+
98
+ app.on("activate", function() {
99
+ if (BrowserWindow.getAllWindows().length === 0) createWindow()
100
+ })
101
+ }
102
+
103
+
104
+ /**
105
+ * Boilerplate
106
+ *
107
+ * > Note: this can be done via a preload script,
108
+ * but for the sake of simplicity, we are just
109
+ * disabling all security here
110
+ *
111
+ * @returns {Promise<void>}
112
+ */
113
+ async function createWindow(): Promise<void> {
114
+ const mainWindow = new BrowserWindow({
115
+ width: 1000,
116
+ height: 1000,
117
+ webPreferences: {
118
+ contextIsolation: false,
119
+ nodeIntegration: true,
120
+ sandbox: false,
121
+ devTools: true
122
+ }
123
+ })
124
+
125
+ const htmlFile = Path.resolve(__dirname, "..", "..", "..", "examples", "simple", "simple-renderer.html")
126
+ mainWindow.webContents.openDevTools({ mode: "right" })
127
+
128
+ await mainWindow.loadFile(htmlFile)
129
+ }
130
+
131
+ app.whenReady().then(start)
132
+
133
+ app.on("window-all-closed", function() {
134
+ if (process.platform !== "darwin") app.quit()
135
+ })
136
+
137
+ ```
138
+
139
+ ##### Renderer Process ([simple-renderer.ts](examples/simple/simple-renderer.ts))
140
+
141
+ ```typescript
142
+ import UPMRendererClientFactory from "@3fv/electron-utility-process-manager/renderer"
143
+
144
+ document.querySelector("#root").innerHTML = `simple-renderer-example`
145
+
146
+ async function simpleExampleUPM() {
147
+ const client = await UPMRendererClientFactory.createClient("simple",`${process.type}-01`)
148
+ const result = await client.executeRequest("ping", [process.type])
149
+ console.info(`Result: ${result}`)
150
+ }
151
+
152
+ simpleExampleUPM()
153
+ .catch(err => console.error(`renderer error: ${err.message}`, err))
154
+
155
+ export {}
156
+ ```
157
+
158
+ #### Complex Example
159
+
160
+ Checkout the [source here](examples/complex), it's basically the simple example,
161
+ but fully typed
162
+
163
+ ## TODO
164
+
165
+ - [ ] CI/CD
166
+ - [ ] Tests
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ // Modules to control application life and create native browser window
30
+ const electron_1 = require("electron");
31
+ const electron_utility_process_manager_1 = require("@3fv/electron-utility-process-manager");
32
+ const tracer_1 = __importDefault(require("tracer"));
33
+ const path_1 = __importDefault(require("path"));
34
+ const log = tracer_1.default.colorConsole();
35
+ let upmService = null;
36
+ /**
37
+ * Boilerplate
38
+ *
39
+ * > Note: this can be done via a preload script,
40
+ * but for the sake of simplicity, we are just
41
+ * disabling all security here
42
+ *
43
+ * @returns {Promise<void>}
44
+ */
45
+ async function createWindow() {
46
+ const mainWindow = new electron_1.BrowserWindow({
47
+ width: 1000,
48
+ height: 1000,
49
+ webPreferences: {
50
+ contextIsolation: false,
51
+ nodeIntegration: true,
52
+ sandbox: false,
53
+ devTools: true
54
+ }
55
+ });
56
+ // Load the sample page
57
+ const htmlFile = path_1.default.resolve(__dirname, "..", "..", "..", "examples", "complex", "complex-renderer.html");
58
+ mainWindow.webContents.openDevTools({ mode: "right" });
59
+ await mainWindow.loadFile(htmlFile);
60
+ }
61
+ async function start() {
62
+ const upm = await Promise.resolve().then(() => __importStar(require("@3fv/electron-utility-process-manager/main")));
63
+ const upmManager = upm.upmMainServiceManager;
64
+ Object.assign(global, {
65
+ upm,
66
+ upmManager
67
+ });
68
+ log.info("UPM manager ready, now creating service", upmManager);
69
+ upmService = await upmManager.createService("complex", path_1.default.join(__dirname, "complex-node.js"));
70
+ log.info("UPM service ready");
71
+ upmService.sendEvent("test123");
72
+ const clientPort = upmManager.createMainChannel("complex", "main-channel-01");
73
+ log.info("Start the client port");
74
+ if (electron_utility_process_manager_1.UPM.isMessagePort(clientPort))
75
+ clientPort.start();
76
+ log.info("Post a message directly");
77
+ clientPort.postMessage({
78
+ channel: electron_utility_process_manager_1.UPM.IPCChannel.UPMServiceMessage,
79
+ payload: { kind: electron_utility_process_manager_1.UPM.MessageKind.Event, messageId: -1, data: { test: "test456" } }
80
+ });
81
+ log.info("Send event via the UPMMainService wrapper");
82
+ upmService.sendEvent({ test: "test789" }, clientPort);
83
+ log.info(`Creating port client`);
84
+ const messageClient = upmManager.createMainClient("complex", "main-client-01"), serviceClient = messageClient.getServiceClient();
85
+ log.info(`Send request/response: ping`);
86
+ const msgPongResult = await messageClient.executeRequest("ping", "main");
87
+ log.info(`msgPongResult=${msgPongResult}`);
88
+ const servicePongResult = await serviceClient.ping("main");
89
+ log.info(`servicePongResult=${servicePongResult}`);
90
+ log.info(`Create the window/renderer`);
91
+ await createWindow();
92
+ electron_1.app.on("activate", function () {
93
+ if (electron_1.BrowserWindow.getAllWindows().length === 0)
94
+ createWindow();
95
+ });
96
+ }
97
+ // When App is READY
98
+ electron_1.app.whenReady().then(start);
99
+ // Quit when all windows are closed, except on macOS. There, it's common
100
+ // for applications and their menu bar to stay active until the user quits
101
+ // explicitly with Cmd + Q.
102
+ electron_1.app.on("window-all-closed", function () {
103
+ if (process.platform !== "darwin")
104
+ electron_1.app.quit();
105
+ });
106
+ // In this file you can include the rest of your app's specific main process
107
+ // code. You can also put them in separate files and require them here.
108
+ //# sourceMappingURL=complex-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complex-main.js","sourceRoot":"","sources":["../../complex/complex-main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAuE;AACvE,uCAA6C;AAC7C,4FAA2D;AAE3D,oDAA2B;AAC3B,gDAAuB;AAGvB,MAAM,GAAG,GAAG,gBAAM,CAAC,YAAY,EAAE,CAAA;AACjC,IAAI,UAAU,GAAmB,IAAI,CAAA;AAErC;;;;;;;;GAQG;AACH,KAAK,UAAU,YAAY;IACzB,MAAM,UAAU,GAAG,IAAI,wBAAa,CAAC;QACnC,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE;YACd,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAA;IAEF,uBAAuB;IACvB,MAAM,QAAQ,GAAG,cAAI,C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;AAEF,4EAA4E;AAC5E,uEAAuE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tracer_1 = __importDefault(require("tracer"));
7
+ const node_1 = __importDefault(require("@3fv/electron-utility-process-manager/node"));
8
+ const log = tracer_1.default.console();
9
+ node_1.default.addEventHandler((clientId, port, payload) => {
10
+ log.info(`Received event from (${clientId})`, payload);
11
+ return true;
12
+ });
13
+ node_1.default.addRequestHandler("ping", async (type, messageId, what) => {
14
+ log.info(`Ping request received (${messageId})`, what);
15
+ return `pong: ${what}`;
16
+ });
17
+ //# sourceMappingURL=complex-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complex-node.js","sourceRoot":"","sources":["../../complex/complex-node.ts"],"names":[],"mappings":";;;;;AACA,oDAA2B;AAC3B,sFAAuE;AAEvE,MAAM,GAAG,GAAG,gBAAM,CAAC,OAAO,EAAE,CAAA;AAE5B,cAAc,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACzD,GAAG,CAAC,IAAI,CAAC,wBAAwB,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAA;IACtD,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA;AAEF,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAY,EAAE,EAAE;IAC/E,GAAG,CAAC,IAAI,CAAC,0BAA0B,SAAS,GAAG,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,SAAS,IAAI,EAAE,CAAA;AACxB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const renderer_1 = __importDefault(require("@3fv/electron-utility-process-manager/renderer"));
7
+ const tracer_1 = __importDefault(require("tracer"));
8
+ const log = tracer_1.default.colorConsole();
9
+ document.querySelector("#root").innerHTML = `complex-renderer-example`;
10
+ async function complexExampleUPM() {
11
+ const messageClient = await renderer_1.default.createClient("complex", `${process.type}-01`), serviceClient = messageClient.getServiceClient();
12
+ const messageResult = await messageClient.executeRequest("ping", process.type), serviceResult = await serviceClient.ping(process.type);
13
+ log.info(`messageResult=${messageResult}`);
14
+ log.info(`serviceResult=${serviceResult}`);
15
+ }
16
+ complexExampleUPM()
17
+ .catch(err => log.error(`renderer error: ${err.message}`, err));
18
+ //# sourceMappingURL=complex-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complex-renderer.js","sourceRoot":"","sources":["../../complex/complex-renderer.ts"],"names":[],"mappings":";;;;;AAAA,8FAAqF;AACrF,oDAA2B;AAG3B,MAAM,GAAG,GAAG,gBAAM,CAAC,YAAY,EAAE,CAAA;AAEjC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,GAAG,0BAA0B,CAAA;AAEtE,KAAK,UAAU,iBAAiB;IAC9B,MAAM,aAAa,GAAG,MAAM,kBAAwB,CAAC,YAAY,CAAyB,SAAS,EAAC,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,EACvH,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAA;IAElD,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAC5E,aAAa,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD,GAAG,CAAC,IAAI,CAAC,iBAAiB,aAAa,EAAE,CAAC,CAAA;IAC1C,GAAG,CAAC,IAAI,CAAC,iBAAiB,aAAa,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED,iBAAiB,EAAE;KAChB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export interface PingPongExampleService {
2
+ ping(what: string): Promise<string>;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=complex-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complex-types.js","sourceRoot":"","sources":["../../complex/complex-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ // Modules to control application life and create native browser window
30
+ const electron_1 = require("electron");
31
+ const electron_utility_process_manager_1 = require("@3fv/electron-utility-process-manager");
32
+ const tracer_1 = __importDefault(require("tracer"));
33
+ const path_1 = __importDefault(require("path"));
34
+ const log = tracer_1.default.colorConsole();
35
+ let upmService = null;
36
+ /**
37
+ * Boilerplate
38
+ *
39
+ * > Note: this can be done via a preload script,
40
+ * but for the sake of simplicity, we are just
41
+ * disabling all security here
42
+ *
43
+ * @returns {Promise<void>}
44
+ */
45
+ async function createWindow() {
46
+ const mainWindow = new electron_1.BrowserWindow({
47
+ width: 1000,
48
+ height: 1000,
49
+ webPreferences: {
50
+ contextIsolation: false,
51
+ nodeIntegration: true,
52
+ sandbox: false,
53
+ devTools: true
54
+ }
55
+ });
56
+ // Load the sample page
57
+ const htmlFile = path_1.default.resolve(__dirname, "..", "..", "..", "examples", "simple", "simple-renderer.html");
58
+ mainWindow.webContents.openDevTools({ mode: "right" });
59
+ await mainWindow.loadFile(htmlFile);
60
+ }
61
+ async function start() {
62
+ const upm = await Promise.resolve().then(() => __importStar(require("@3fv/electron-utility-process-manager/main")));
63
+ const upmManager = upm.upmMainServiceManager;
64
+ Object.assign(global, {
65
+ upm,
66
+ upmManager
67
+ });
68
+ log.info("UPM manager ready, now creating service", upmManager);
69
+ upmService = await upmManager.createService("simple", path_1.default.join(__dirname, "simple-node.js"));
70
+ log.info("UPM service ready");
71
+ upmService.sendEvent("test123");
72
+ const clientPort = upmManager.createMainChannel("simple", "main-channel-01");
73
+ log.info("Start the client port");
74
+ if (electron_utility_process_manager_1.UPM.isMessagePort(clientPort))
75
+ clientPort.start();
76
+ log.info("Post a message directly");
77
+ clientPort.postMessage({
78
+ channel: electron_utility_process_manager_1.UPM.IPCChannel.UPMServiceMessage,
79
+ payload: { kind: electron_utility_process_manager_1.UPM.MessageKind.Event, messageId: -1, data: { test: "test456" } }
80
+ });
81
+ log.info("Send event via the UPMMainService wrapper");
82
+ upmService.sendEvent({ test: "test789" }, clientPort);
83
+ log.info(`Creating port client`);
84
+ const client = upmManager.createMainClient("simple", "main-client-01");
85
+ log.info(`Send request/response: ping`);
86
+ const pongResult = await client.executeRequest("ping", ["main"]);
87
+ log.info(`Received pong response`, pongResult);
88
+ log.info(`Create the window/renderer`);
89
+ await createWindow();
90
+ electron_1.app.on("activate", function () {
91
+ if (electron_1.BrowserWindow.getAllWindows().length === 0)
92
+ createWindow();
93
+ });
94
+ }
95
+ // When App is READY
96
+ electron_1.app.whenReady().then(start);
97
+ // Quit when all windows are closed, except on macOS. There, it's common
98
+ // for applications and their menu bar to stay active until the user quits
99
+ // explicitly with Cmd + Q.
100
+ electron_1.app.on("window-all-closed", function () {
101
+ if (process.platform !== "darwin")
102
+ electron_1.app.quit();
103
+ });
104
+ // In this file you can include the rest of your app's specific main process
105
+ // code. You can also put them in separate files and require them here.
106
+ //# sourceMappingURL=simple-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-main.js","sourceRoot":"","sources":["../../simple/simple-main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAuE;AACvE,uCAA6C;AAC7C,4FAA2D;AAG3D,oDAA2B;AAC3B,gDAAuB;AAEvB,MAAM,GAAG,GAAG,gBAAM,CAAC,YAAY,EAAE,CAAA;AACjC,IAAI,UAAU,GAAmB,IAAI,CAAA;AAErC;;;;;;;;GAQG;AACH,KAAK,UAAU,YAAY;IACzB,MAAM,UAAU,GAAG,IAAI,wBAAa,CAAC;QACnC,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE;YACd,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAA;IAEF,uBAAuB;IACvB,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QA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I,CAAC,2CAA2C,CAAC,CAAA;IACrD,UAAU,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAA;IAErD,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;IAChC,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IACtE,GAAG,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;IAEvC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAA;IAE9C,GAAG,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;IACtC,MAAM,YAAY,EAAE,CAAA;IAEpB,cAAG,CAAC,EAAE,CAAC,UAAU,EAAE;QACjB,IAAI,wBAAa,CAAC,aAAa,EAAE,CAAC,MAAM,KAAK,CAAC;YAAE,YAAY,EAAE,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,oBAAoB;AACpB,cAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAE3B,wEAAwE;AACxE,0EAA0E;AAC1E,2BAA2B;AAC3B,cAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE;IAC1B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAAE,cAAG,CAAC,IAAI,EAAE,CAAA;AAC/C,CAAC,CAAC,CAAA;AAEF,4EAA4E;AAC5E,uEAAuE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tracer_1 = __importDefault(require("tracer"));
7
+ const node_1 = __importDefault(require("@3fv/electron-utility-process-manager/node"));
8
+ const log = tracer_1.default.console();
9
+ node_1.default.addEventHandler((clientId, port, payload) => {
10
+ log.info(`Received event from (${clientId})`, payload);
11
+ return true;
12
+ });
13
+ node_1.default.addRequestHandler("ping", async (type, messageId, what) => {
14
+ log.info(`Ping request received (${messageId})`, what);
15
+ return `pong: ${what}`;
16
+ });
17
+ //# sourceMappingURL=simple-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-node.js","sourceRoot":"","sources":["../../simple/simple-node.ts"],"names":[],"mappings":";;;;;AACA,oDAA2B;AAC3B,sFAAuE;AAEvE,MAAM,GAAG,GAAG,gBAAM,CAAC,OAAO,EAAE,CAAA;AAE5B,cAAc,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACzD,GAAG,CAAC,IAAI,CAAC,wBAAwB,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAA;IACtD,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA;AAEF,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAY,EAAE,EAAE;IAC/E,GAAG,CAAC,IAAI,CAAC,0BAA0B,SAAS,GAAG,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,SAAS,IAAI,EAAE,CAAA;AACxB,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const renderer_1 = __importDefault(require("@3fv/electron-utility-process-manager/renderer"));
7
+ const tracer_1 = __importDefault(require("tracer"));
8
+ const log = tracer_1.default.colorConsole();
9
+ document.querySelector("#root").innerHTML = `simple-renderer-example`;
10
+ async function simpleExampleUPM() {
11
+ const client = await renderer_1.default.createClient("simple", `${process.type}-01`);
12
+ const result = await client.executeRequest("ping", [process.type]);
13
+ log.info(`Result: ${result}`);
14
+ }
15
+ simpleExampleUPM()
16
+ .catch(err => log.error(`renderer error: ${err.message}`, err));
17
+ //# sourceMappingURL=simple-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-renderer.js","sourceRoot":"","sources":["../../simple/simple-renderer.ts"],"names":[],"mappings":";;;;;AAAA,8FAAqF;AACrF,oDAA2B;AAE3B,MAAM,GAAG,GAAG,gBAAM,CAAC,YAAY,EAAE,CAAA;AAEjC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,GAAG,yBAAyB,CAAA;AAErE,KAAK,UAAU,gBAAgB;IAC7B,MAAM,MAAM,GAAG,MAAM,kBAAwB,CAAC,YAAY,CAAC,QAAQ,EAAC,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,CAAA;IACzF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAClE,GAAG,CAAC,IAAI,CAAC,WAAW,MAAM,EAAE,CAAC,CAAA;AAC/B,CAAC;AAED,gBAAgB,EAAE;KACf,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA"}
package/jest.config.js ADDED
@@ -0,0 +1,20 @@
1
+
2
+ const { defaults: tsjPreset } = require('ts-jest/presets');
3
+
4
+ module.exports = {
5
+ verbose: true,
6
+ testMatch: ["**/lib/cjs/**/*.spec.js"],
7
+ moduleDirectories: [
8
+ "node_modules",
9
+ "lib/cjs"
10
+ ],
11
+
12
+ transform: {
13
+
14
+ },
15
+ moduleFileExtensions: [
16
+ "ts",
17
+ "tsx",
18
+ "js"
19
+ ]
20
+ }
@@ -0,0 +1,103 @@
1
+ import { MessageRequestFn, MessageRequestMap, MessageRequestNames, MessageRequestParams, MessageRequestReturnType, Port } from "./types";
2
+ /**
3
+ * Service client interface maps a `MessageRequestMap`
4
+ * to its functional methods
5
+ */
6
+ export type IServiceClient<ReqMap extends MessageRequestMap, MType extends MessageRequestNames<ReqMap> = MessageRequestNames<ReqMap>> = {
7
+ [Type in MType]: MessageRequestFn<ReqMap, Type>;
8
+ };
9
+ /**
10
+ * Messaging client interface
11
+ */
12
+ export interface IMessageClient<ReqMap extends MessageRequestMap, MType extends MessageRequestNames<ReqMap> = MessageRequestNames<ReqMap>> {
13
+ /**
14
+ * A very low level function for sending `any` data
15
+ * to the `utilityProcess`
16
+ *
17
+ * @param data
18
+ */
19
+ sendEvent(data: any): void;
20
+ /**
21
+ * Execute a request, with a response expected
22
+ *
23
+ * @param type
24
+ * @param args determined by the typed `MessageRequestMap` & `Type` parameters
25
+ */
26
+ executeRequest<Type extends MType, R extends MessageRequestReturnType<ReqMap, Type> = MessageRequestReturnType<ReqMap, Type>>(type: Type, ...args: MessageRequestParams<ReqMap, Type>): Promise<R>;
27
+ /**
28
+ * Close the message client
29
+ */
30
+ close(): void;
31
+ /**
32
+ * Resolve when client is ready to use
33
+ */
34
+ whenReady(): Promise<IMessageClient<ReqMap, MType>>;
35
+ /**
36
+ * Get service client from message client
37
+ */
38
+ getServiceClient(): IServiceClient<ReqMap, MType>;
39
+ }
40
+ /**
41
+ * Generic `MessagePort` client implementation, which
42
+ * is functional in any process.
43
+ *
44
+ * > NOTE: Aside from the main & renderer processes,
45
+ * > an `utilityProcess` could potentially also
46
+ * > use this client to communicate with a separate
47
+ * > `utilityProcess`
48
+ */
49
+ export declare class MessagePortClient<ReqMap extends MessageRequestMap, MType extends MessageRequestNames<ReqMap> = MessageRequestNames<ReqMap>> implements IMessageClient<ReqMap, MType> {
50
+ readonly clientId: string;
51
+ readonly port: Port;
52
+ /**
53
+ * Used to generate IDS
54
+ *
55
+ * @private
56
+ */
57
+ private idSequence_;
58
+ /**
59
+ * A `Map` responsible for mapping `messageId`
60
+ * values to a `PendingRequestMessage`
61
+ *
62
+ * @private
63
+ */
64
+ private readonly pendingMessages_;
65
+ /**
66
+ * Get the next `messageId`
67
+ *
68
+ * @returns {number}
69
+ * @private
70
+ */
71
+ private generateMessageId;
72
+ /**
73
+ * Remove a pending message mapping based on supplied ID
74
+ *
75
+ * @param {number} messageId
76
+ * @private
77
+ */
78
+ private removePendingMessage;
79
+ /**
80
+ * Handle messages posted by the `utilityProcess` via
81
+ * either `process.parentPort` or a specific `MessagePort`
82
+ *
83
+ * @param payloadOrEnvelopeOrData
84
+ * @private
85
+ */
86
+ private onMessage;
87
+ sendEvent(data: any): void;
88
+ executeRequest<Type extends MType, R extends MessageRequestReturnType<ReqMap, Type> = MessageRequestReturnType<ReqMap, Type>>(type: Type, ...args: MessageRequestParams<ReqMap, Type>): Promise<R>;
89
+ close(): void;
90
+ whenReady(): Promise<this>;
91
+ /**
92
+ * Return a simple proxy facade wrapping
93
+ * `executeRequest` into individual methods
94
+ */
95
+ getServiceClient(): IServiceClient<ReqMap, MType>;
96
+ /**
97
+ * Create a new `MessagePortClient`
98
+ *
99
+ * @param clientId
100
+ * @param port
101
+ */
102
+ constructor(clientId: string, port: Port);
103
+ }