@lvce-editor/ipc 5.1.0 → 7.0.0
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/dist/browser.js +109 -166
- package/dist/index.js +109 -177
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
const getData$
|
|
1
|
+
const getData$1 = event => {
|
|
2
2
|
return event.data;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
const attachEvent = (rawIpc, getData, that) => {
|
|
6
|
+
const wrapped = event => {
|
|
7
|
+
const data = getData(event);
|
|
8
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
9
|
+
data
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
if ('onmessage' in rawIpc) {
|
|
13
|
+
rawIpc.onmessage = wrapped;
|
|
14
|
+
} else if ('on' in rawIpc) {
|
|
15
|
+
rawIpc.on('message', wrapped);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
class Ipc extends EventTarget {
|
|
19
|
+
constructor(rawIpc) {
|
|
20
|
+
super();
|
|
21
|
+
attachEvent(rawIpc, this.getData, this);
|
|
22
|
+
this._rawIpc = rawIpc;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
const readyMessage = 'ready';
|
|
6
27
|
|
|
7
28
|
const listen$2 = () => {
|
|
@@ -14,43 +35,27 @@ const listen$2 = () => {
|
|
|
14
35
|
const signal$1 = global => {
|
|
15
36
|
global.postMessage(readyMessage);
|
|
16
37
|
};
|
|
38
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
39
|
+
getData(event) {
|
|
40
|
+
return getData$1(event);
|
|
41
|
+
}
|
|
42
|
+
send(message) {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
this._rawIpc.postMessage(message);
|
|
45
|
+
}
|
|
46
|
+
sendAndTransfer(message, transfer) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
this._rawIpc.postMessage(message, transfer);
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
// ignore
|
|
52
|
+
}
|
|
53
|
+
}
|
|
17
54
|
const wrap$4 = global => {
|
|
18
|
-
return
|
|
19
|
-
global,
|
|
20
|
-
/**
|
|
21
|
-
* @type {any}
|
|
22
|
-
*/
|
|
23
|
-
listener: undefined,
|
|
24
|
-
send(message) {
|
|
25
|
-
this.global.postMessage(message);
|
|
26
|
-
},
|
|
27
|
-
sendAndTransfer(message, transferables) {
|
|
28
|
-
this.global.postMessage(message, transferables);
|
|
29
|
-
},
|
|
30
|
-
get onmessage() {
|
|
31
|
-
return this.listener;
|
|
32
|
-
},
|
|
33
|
-
set onmessage(listener) {
|
|
34
|
-
const wrappedListener = event => {
|
|
35
|
-
const data = getData$2(event);
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
listener({
|
|
38
|
-
data,
|
|
39
|
-
target: this
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
this.listener = listener;
|
|
43
|
-
this.global.onmessage = wrappedListener;
|
|
44
|
-
},
|
|
45
|
-
dispose() {
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
this.listener = null;
|
|
48
|
-
this.global.onmessage = null;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
55
|
+
return new IpcChildWithModuleWorker(global);
|
|
51
56
|
};
|
|
52
57
|
|
|
53
|
-
const IpcChildWithModuleWorker = {
|
|
58
|
+
const IpcChildWithModuleWorker$1 = {
|
|
54
59
|
__proto__: null,
|
|
55
60
|
listen: listen$2,
|
|
56
61
|
signal: signal$1,
|
|
@@ -303,94 +308,58 @@ const listen$1 = async () => {
|
|
|
303
308
|
}
|
|
304
309
|
return globalThis;
|
|
305
310
|
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
get onmessage() {
|
|
320
|
-
return this.wrappedListener;
|
|
321
|
-
},
|
|
322
|
-
set onmessage(listener) {
|
|
323
|
-
if (listener) {
|
|
324
|
-
// @ts-expect-error
|
|
325
|
-
this.wrappedListener = event => {
|
|
326
|
-
const data = getData$2(event);
|
|
327
|
-
// @ts-expect-error
|
|
328
|
-
listener({
|
|
329
|
-
data,
|
|
330
|
-
target: this
|
|
331
|
-
});
|
|
332
|
-
};
|
|
333
|
-
} else {
|
|
334
|
-
this.wrappedListener = undefined;
|
|
335
|
-
}
|
|
336
|
-
this.port.onmessage = this.wrappedListener;
|
|
311
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
312
|
+
getData(event) {
|
|
313
|
+
return getData$1(event);
|
|
314
|
+
}
|
|
315
|
+
send(message) {
|
|
316
|
+
this._rawIpc.postMessage(message);
|
|
317
|
+
}
|
|
318
|
+
sendAndTransfer(message, transfer) {
|
|
319
|
+
this._rawIpc.postMessage(message, transfer);
|
|
320
|
+
}
|
|
321
|
+
dispose() {
|
|
322
|
+
if (this._rawIpc.close) {
|
|
323
|
+
this._rawIpc.close();
|
|
337
324
|
}
|
|
338
|
-
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const wrap$3 = port => {
|
|
328
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
339
329
|
};
|
|
340
330
|
|
|
341
|
-
const IpcChildWithModuleWorkerAndMessagePort = {
|
|
331
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
342
332
|
__proto__: null,
|
|
343
333
|
listen: listen$1,
|
|
344
334
|
wrap: wrap$3
|
|
345
335
|
};
|
|
346
336
|
|
|
347
337
|
const listen = () => {
|
|
348
|
-
// @ts-ignore
|
|
349
338
|
return window;
|
|
350
339
|
};
|
|
351
340
|
const signal = global => {
|
|
352
341
|
global.postMessage(readyMessage);
|
|
353
342
|
};
|
|
343
|
+
class IpcChildWithWindow extends Ipc {
|
|
344
|
+
getData(event) {
|
|
345
|
+
return getData$1(event);
|
|
346
|
+
}
|
|
347
|
+
send(message) {
|
|
348
|
+
this._rawIpc.postMessage(message);
|
|
349
|
+
}
|
|
350
|
+
sendAndTransfer(message, transfer) {
|
|
351
|
+
// TODO set diffrent origin
|
|
352
|
+
this._rawIpc.postMessage(message, '*', transfer);
|
|
353
|
+
}
|
|
354
|
+
dispose() {
|
|
355
|
+
// ignore
|
|
356
|
+
}
|
|
357
|
+
}
|
|
354
358
|
const wrap$2 = window => {
|
|
355
|
-
return
|
|
356
|
-
window,
|
|
357
|
-
/**
|
|
358
|
-
* @type {any}
|
|
359
|
-
*/
|
|
360
|
-
listener: undefined,
|
|
361
|
-
get onmessage() {
|
|
362
|
-
return this.listener;
|
|
363
|
-
},
|
|
364
|
-
set onmessage(listener) {
|
|
365
|
-
this.listener = listener;
|
|
366
|
-
const wrappedListener = event => {
|
|
367
|
-
const data = event.data;
|
|
368
|
-
if ('method' in data) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
// @ts-ignore
|
|
372
|
-
listener({
|
|
373
|
-
data,
|
|
374
|
-
target: this
|
|
375
|
-
});
|
|
376
|
-
};
|
|
377
|
-
this.window.onmessage = wrappedListener;
|
|
378
|
-
},
|
|
379
|
-
send(message) {
|
|
380
|
-
this.window.postMessage(message);
|
|
381
|
-
},
|
|
382
|
-
sendAndTransfer(message, transfer) {
|
|
383
|
-
this.window.postMessage(message, '*', transfer);
|
|
384
|
-
},
|
|
385
|
-
dispose() {
|
|
386
|
-
this.window.onmessage = null;
|
|
387
|
-
this.window = undefined;
|
|
388
|
-
this.listener = undefined;
|
|
389
|
-
}
|
|
390
|
-
};
|
|
359
|
+
return new IpcChildWithWindow(window);
|
|
391
360
|
};
|
|
392
361
|
|
|
393
|
-
const IpcChildWithWindow = {
|
|
362
|
+
const IpcChildWithWindow$1 = {
|
|
394
363
|
__proto__: null,
|
|
395
364
|
listen,
|
|
396
365
|
signal,
|
|
@@ -510,43 +479,32 @@ const create$1 = async ({
|
|
|
510
479
|
}
|
|
511
480
|
return worker;
|
|
512
481
|
};
|
|
513
|
-
const getData
|
|
482
|
+
const getData = event => {
|
|
514
483
|
// TODO why are some events not instance of message event?
|
|
515
484
|
if (event instanceof MessageEvent) {
|
|
516
485
|
return event.data;
|
|
517
486
|
}
|
|
518
487
|
return event;
|
|
519
488
|
};
|
|
489
|
+
class IpcParentWithModuleWorker extends Ipc {
|
|
490
|
+
getData(event) {
|
|
491
|
+
return getData(event);
|
|
492
|
+
}
|
|
493
|
+
send(message) {
|
|
494
|
+
this._rawIpc.postMessage(message);
|
|
495
|
+
}
|
|
496
|
+
sendAndTransfer(message, transfer) {
|
|
497
|
+
this._rawIpc.postMessage(message, transfer);
|
|
498
|
+
}
|
|
499
|
+
dispose() {
|
|
500
|
+
// igore
|
|
501
|
+
}
|
|
502
|
+
}
|
|
520
503
|
const wrap$1 = worker => {
|
|
521
|
-
|
|
522
|
-
return {
|
|
523
|
-
get onmessage() {
|
|
524
|
-
return handleMessage;
|
|
525
|
-
},
|
|
526
|
-
set onmessage(listener) {
|
|
527
|
-
if (listener) {
|
|
528
|
-
handleMessage = event => {
|
|
529
|
-
const data = getData$1(event);
|
|
530
|
-
listener({
|
|
531
|
-
data,
|
|
532
|
-
target: this
|
|
533
|
-
});
|
|
534
|
-
};
|
|
535
|
-
} else {
|
|
536
|
-
handleMessage = null;
|
|
537
|
-
}
|
|
538
|
-
worker.onmessage = handleMessage;
|
|
539
|
-
},
|
|
540
|
-
send(message) {
|
|
541
|
-
worker.postMessage(message);
|
|
542
|
-
},
|
|
543
|
-
sendAndTransfer(message, transfer) {
|
|
544
|
-
worker.postMessage(message, transfer);
|
|
545
|
-
}
|
|
546
|
-
};
|
|
504
|
+
return new IpcParentWithModuleWorker(worker);
|
|
547
505
|
};
|
|
548
506
|
|
|
549
|
-
const IpcParentWithModuleWorker = {
|
|
507
|
+
const IpcParentWithModuleWorker$1 = {
|
|
550
508
|
__proto__: null,
|
|
551
509
|
create: create$1,
|
|
552
510
|
wrap: wrap$1
|
|
@@ -586,43 +544,28 @@ const create = async ({
|
|
|
586
544
|
}
|
|
587
545
|
return webSocket;
|
|
588
546
|
};
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
547
|
+
class IpcParentWithWebSocket extends Ipc {
|
|
548
|
+
getData(event) {
|
|
549
|
+
return parse(event.data);
|
|
550
|
+
}
|
|
551
|
+
send(message) {
|
|
552
|
+
this._rawIpc.send(stringifyCompact(message));
|
|
553
|
+
}
|
|
554
|
+
sendAndTransfer(message, transfer) {
|
|
555
|
+
throw new Error('sendAndTransfer not supported');
|
|
556
|
+
}
|
|
557
|
+
dispose() {
|
|
558
|
+
this._rawIpc.close();
|
|
559
|
+
}
|
|
560
|
+
}
|
|
592
561
|
const wrap = webSocket => {
|
|
593
|
-
return
|
|
594
|
-
webSocket,
|
|
595
|
-
/**
|
|
596
|
-
* @type {any}
|
|
597
|
-
*/
|
|
598
|
-
listener: undefined,
|
|
599
|
-
get onmessage() {
|
|
600
|
-
return this.listener;
|
|
601
|
-
},
|
|
602
|
-
set onmessage(listener) {
|
|
603
|
-
this.listener = listener;
|
|
604
|
-
const wrappedListener = event => {
|
|
605
|
-
const data = getData(event);
|
|
606
|
-
const syntheticEvent = {
|
|
607
|
-
data,
|
|
608
|
-
target: this
|
|
609
|
-
};
|
|
610
|
-
// @ts-ignore
|
|
611
|
-
listener(syntheticEvent);
|
|
612
|
-
};
|
|
613
|
-
this.webSocket.onmessage = wrappedListener;
|
|
614
|
-
},
|
|
615
|
-
send(message) {
|
|
616
|
-
const stringifiedMessage = stringifyCompact(message);
|
|
617
|
-
this.webSocket.send(stringifiedMessage);
|
|
618
|
-
}
|
|
619
|
-
};
|
|
562
|
+
return new IpcParentWithWebSocket(webSocket);
|
|
620
563
|
};
|
|
621
564
|
|
|
622
|
-
const IpcParentWithWebSocket = {
|
|
565
|
+
const IpcParentWithWebSocket$1 = {
|
|
623
566
|
__proto__: null,
|
|
624
567
|
create,
|
|
625
568
|
wrap
|
|
626
569
|
};
|
|
627
570
|
|
|
628
|
-
export { IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort, IpcChildWithWindow, IpcParentWithModuleWorker, IpcParentWithWebSocket };
|
|
571
|
+
export { IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithWindow$1 as IpcChildWithWindow, IpcParentWithModuleWorker$1 as IpcParentWithModuleWorker, IpcParentWithWebSocket$1 as IpcParentWithWebSocket };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { VError } from '@lvce-editor/verror';
|
|
2
2
|
import { string, array } from '@lvce-editor/assert';
|
|
3
3
|
|
|
4
|
+
const attachEvent = (rawIpc, getData, that) => {
|
|
5
|
+
const wrapped = event => {
|
|
6
|
+
const data = getData(event);
|
|
7
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
8
|
+
data
|
|
9
|
+
}));
|
|
10
|
+
};
|
|
11
|
+
if ('onmessage' in rawIpc) {
|
|
12
|
+
rawIpc.onmessage = wrapped;
|
|
13
|
+
} else if ('on' in rawIpc) {
|
|
14
|
+
rawIpc.on('message', wrapped);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
class Ipc extends EventTarget {
|
|
18
|
+
constructor(rawIpc) {
|
|
19
|
+
super();
|
|
20
|
+
attachEvent(rawIpc, this.getData, this);
|
|
21
|
+
this._rawIpc = rawIpc;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
4
25
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
5
26
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
6
27
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
@@ -174,46 +195,28 @@ const getActualData$1 = event => {
|
|
|
174
195
|
params: [...ports, ...data.params]
|
|
175
196
|
};
|
|
176
197
|
};
|
|
198
|
+
class IpcChildWithElectronMessagePort extends Ipc {
|
|
199
|
+
constructor(port) {
|
|
200
|
+
super(port);
|
|
201
|
+
}
|
|
202
|
+
getData(event) {
|
|
203
|
+
return getActualData$1(event);
|
|
204
|
+
}
|
|
205
|
+
send(message) {
|
|
206
|
+
this._rawIpc.postMessage(message);
|
|
207
|
+
}
|
|
208
|
+
sendAndTransfer(message, transfer) {
|
|
209
|
+
this._rawIpc.postMessage(message, transfer);
|
|
210
|
+
}
|
|
211
|
+
dispose() {
|
|
212
|
+
this._rawIpc.close();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
177
215
|
const wrap$a = messagePort => {
|
|
178
|
-
return
|
|
179
|
-
messagePort,
|
|
180
|
-
on(event, listener) {
|
|
181
|
-
if (event === 'message') {
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
const wrappedListener = event => {
|
|
184
|
-
const actualData = getActualData$1(event);
|
|
185
|
-
const syntheticEvent = {
|
|
186
|
-
data: actualData,
|
|
187
|
-
target: this
|
|
188
|
-
};
|
|
189
|
-
listener(syntheticEvent);
|
|
190
|
-
};
|
|
191
|
-
this.messagePort.on(event, wrappedListener);
|
|
192
|
-
} else if (event === 'close') {
|
|
193
|
-
this.messagePort.on('close', listener);
|
|
194
|
-
} else {
|
|
195
|
-
throw new Error('unsupported event type');
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
off(event, listener) {
|
|
199
|
-
this.messagePort.off(event, listener);
|
|
200
|
-
},
|
|
201
|
-
send(message) {
|
|
202
|
-
this.messagePort.postMessage(message);
|
|
203
|
-
},
|
|
204
|
-
sendAndTransfer(message, transfer) {
|
|
205
|
-
this.messagePort.postMessage(message, transfer);
|
|
206
|
-
},
|
|
207
|
-
dispose() {
|
|
208
|
-
this.messagePort.close();
|
|
209
|
-
},
|
|
210
|
-
start() {
|
|
211
|
-
throw new Error('start method is deprecated');
|
|
212
|
-
}
|
|
213
|
-
};
|
|
216
|
+
return new IpcChildWithElectronMessagePort(messagePort);
|
|
214
217
|
};
|
|
215
218
|
|
|
216
|
-
const IpcChildWithElectronMessagePort = {
|
|
219
|
+
const IpcChildWithElectronMessagePort$1 = {
|
|
217
220
|
__proto__: null,
|
|
218
221
|
listen: listen$7,
|
|
219
222
|
signal: signal$6,
|
|
@@ -247,54 +250,28 @@ const listen$6 = () => {
|
|
|
247
250
|
}
|
|
248
251
|
return parentPort;
|
|
249
252
|
};
|
|
250
|
-
|
|
251
|
-
// @ts-ignore
|
|
252
253
|
const signal$5 = parentPort => {
|
|
253
254
|
parentPort.postMessage(readyMessage);
|
|
254
255
|
};
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
class IpcChildWithElectronUtilityProcess extends Ipc {
|
|
257
|
+
getData(event) {
|
|
258
|
+
return getUtilityProcessPortData(event);
|
|
259
|
+
}
|
|
260
|
+
send(message) {
|
|
261
|
+
this._rawIpc.postMessage(message);
|
|
262
|
+
}
|
|
263
|
+
sendAndTransfer(message, transfer) {
|
|
264
|
+
this._rawIpc.postMessage(message, transfer);
|
|
265
|
+
}
|
|
266
|
+
dispose() {
|
|
267
|
+
this._rawIpc.close();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
257
270
|
const wrap$9 = parentPort => {
|
|
258
|
-
return
|
|
259
|
-
parentPort,
|
|
260
|
-
// @ts-ignore
|
|
261
|
-
on(event, listener) {
|
|
262
|
-
if (event === 'message') {
|
|
263
|
-
// @ts-ignore
|
|
264
|
-
const wrappedListener = event => {
|
|
265
|
-
const actualData = getUtilityProcessPortData(event);
|
|
266
|
-
const syntheticEvent = {
|
|
267
|
-
data: actualData,
|
|
268
|
-
target: this
|
|
269
|
-
};
|
|
270
|
-
listener(syntheticEvent);
|
|
271
|
-
};
|
|
272
|
-
this.parentPort.on(event, wrappedListener);
|
|
273
|
-
} else if (event === 'close') {
|
|
274
|
-
this.parentPort.on('close', listener);
|
|
275
|
-
} else {
|
|
276
|
-
throw new Error('unsupported event type');
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
// @ts-ignore
|
|
280
|
-
off(event, listener) {
|
|
281
|
-
this.parentPort.off(event, listener);
|
|
282
|
-
},
|
|
283
|
-
// @ts-ignore
|
|
284
|
-
send(message) {
|
|
285
|
-
this.parentPort.postMessage(message);
|
|
286
|
-
},
|
|
287
|
-
// @ts-ignore
|
|
288
|
-
sendAndTransfer(message, transfer) {
|
|
289
|
-
this.parentPort.postMessage(message, transfer);
|
|
290
|
-
},
|
|
291
|
-
dispose() {
|
|
292
|
-
this.parentPort.close();
|
|
293
|
-
}
|
|
294
|
-
};
|
|
271
|
+
return new IpcChildWithElectronUtilityProcess(parentPort);
|
|
295
272
|
};
|
|
296
273
|
|
|
297
|
-
const IpcChildWithElectronUtilityProcess = {
|
|
274
|
+
const IpcChildWithElectronUtilityProcess$1 = {
|
|
298
275
|
__proto__: null,
|
|
299
276
|
listen: listen$6,
|
|
300
277
|
signal: signal$5,
|
|
@@ -315,43 +292,27 @@ const listen$5 = () => {
|
|
|
315
292
|
const signal$4 = global => {
|
|
316
293
|
global.postMessage(readyMessage);
|
|
317
294
|
};
|
|
295
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
296
|
+
getData(event) {
|
|
297
|
+
return getData(event);
|
|
298
|
+
}
|
|
299
|
+
send(message) {
|
|
300
|
+
// @ts-ignore
|
|
301
|
+
this._rawIpc.postMessage(message);
|
|
302
|
+
}
|
|
303
|
+
sendAndTransfer(message, transfer) {
|
|
304
|
+
// @ts-ignore
|
|
305
|
+
this._rawIpc.postMessage(message, transfer);
|
|
306
|
+
}
|
|
307
|
+
dispose() {
|
|
308
|
+
// ignore
|
|
309
|
+
}
|
|
310
|
+
}
|
|
318
311
|
const wrap$8 = global => {
|
|
319
|
-
return
|
|
320
|
-
global,
|
|
321
|
-
/**
|
|
322
|
-
* @type {any}
|
|
323
|
-
*/
|
|
324
|
-
listener: undefined,
|
|
325
|
-
send(message) {
|
|
326
|
-
this.global.postMessage(message);
|
|
327
|
-
},
|
|
328
|
-
sendAndTransfer(message, transferables) {
|
|
329
|
-
this.global.postMessage(message, transferables);
|
|
330
|
-
},
|
|
331
|
-
get onmessage() {
|
|
332
|
-
return this.listener;
|
|
333
|
-
},
|
|
334
|
-
set onmessage(listener) {
|
|
335
|
-
const wrappedListener = event => {
|
|
336
|
-
const data = getData(event);
|
|
337
|
-
// @ts-expect-error
|
|
338
|
-
listener({
|
|
339
|
-
data,
|
|
340
|
-
target: this
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
this.listener = listener;
|
|
344
|
-
this.global.onmessage = wrappedListener;
|
|
345
|
-
},
|
|
346
|
-
dispose() {
|
|
347
|
-
// @ts-ignore
|
|
348
|
-
this.listener = null;
|
|
349
|
-
this.global.onmessage = null;
|
|
350
|
-
}
|
|
351
|
-
};
|
|
312
|
+
return new IpcChildWithModuleWorker(global);
|
|
352
313
|
};
|
|
353
314
|
|
|
354
|
-
const IpcChildWithModuleWorker = {
|
|
315
|
+
const IpcChildWithModuleWorker$1 = {
|
|
355
316
|
__proto__: null,
|
|
356
317
|
listen: listen$5,
|
|
357
318
|
signal: signal$4,
|
|
@@ -403,42 +364,27 @@ const listen$4 = async () => {
|
|
|
403
364
|
}
|
|
404
365
|
return globalThis;
|
|
405
366
|
};
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
get onmessage() {
|
|
420
|
-
return this.wrappedListener;
|
|
421
|
-
},
|
|
422
|
-
set onmessage(listener) {
|
|
423
|
-
if (listener) {
|
|
424
|
-
// @ts-expect-error
|
|
425
|
-
this.wrappedListener = event => {
|
|
426
|
-
const data = getData(event);
|
|
427
|
-
// @ts-expect-error
|
|
428
|
-
listener({
|
|
429
|
-
data,
|
|
430
|
-
target: this
|
|
431
|
-
});
|
|
432
|
-
};
|
|
433
|
-
} else {
|
|
434
|
-
this.wrappedListener = undefined;
|
|
435
|
-
}
|
|
436
|
-
this.port.onmessage = this.wrappedListener;
|
|
367
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
368
|
+
getData(event) {
|
|
369
|
+
return getData(event);
|
|
370
|
+
}
|
|
371
|
+
send(message) {
|
|
372
|
+
this._rawIpc.postMessage(message);
|
|
373
|
+
}
|
|
374
|
+
sendAndTransfer(message, transfer) {
|
|
375
|
+
this._rawIpc.postMessage(message, transfer);
|
|
376
|
+
}
|
|
377
|
+
dispose() {
|
|
378
|
+
if (this._rawIpc.close) {
|
|
379
|
+
this._rawIpc.close();
|
|
437
380
|
}
|
|
438
|
-
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const wrap$7 = port => {
|
|
384
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
439
385
|
};
|
|
440
386
|
|
|
441
|
-
const IpcChildWithModuleWorkerAndMessagePort = {
|
|
387
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
442
388
|
__proto__: null,
|
|
443
389
|
listen: listen$4,
|
|
444
390
|
wrap: wrap$7
|
|
@@ -863,7 +809,6 @@ const create$2 = async ({
|
|
|
863
809
|
}) => {
|
|
864
810
|
string(path);
|
|
865
811
|
const actualArgv = ['--ipc-type=electron-utility-process', ...argv];
|
|
866
|
-
// @ts-ignore
|
|
867
812
|
const {
|
|
868
813
|
utilityProcess
|
|
869
814
|
} = await import('electron');
|
|
@@ -887,38 +832,25 @@ const create$2 = async ({
|
|
|
887
832
|
childProcess.stderr.pipe(process.stderr);
|
|
888
833
|
return childProcess;
|
|
889
834
|
};
|
|
890
|
-
|
|
891
|
-
|
|
835
|
+
class IpcParentWithElectronUtilityProcess extends Ipc {
|
|
836
|
+
getData(data) {
|
|
837
|
+
return data;
|
|
838
|
+
}
|
|
839
|
+
send(message) {
|
|
840
|
+
this._rawIpc.postMessage(message);
|
|
841
|
+
}
|
|
842
|
+
sendAndTransfer(message, transfer) {
|
|
843
|
+
this._rawIpc.postMessage(message, transfer);
|
|
844
|
+
}
|
|
845
|
+
dispose() {
|
|
846
|
+
this._rawIpc.kill();
|
|
847
|
+
}
|
|
848
|
+
}
|
|
892
849
|
const wrap$2 = process => {
|
|
893
|
-
return
|
|
894
|
-
process,
|
|
895
|
-
// @ts-ignore
|
|
896
|
-
on(event, listener) {
|
|
897
|
-
const wrappedListener = message => {
|
|
898
|
-
const syntheticEvent = {
|
|
899
|
-
data: message,
|
|
900
|
-
target: this
|
|
901
|
-
};
|
|
902
|
-
listener(syntheticEvent);
|
|
903
|
-
};
|
|
904
|
-
this.process.on(event, wrappedListener);
|
|
905
|
-
},
|
|
906
|
-
// @ts-ignore
|
|
907
|
-
send(message) {
|
|
908
|
-
this.process.postMessage(message);
|
|
909
|
-
},
|
|
910
|
-
// @ts-ignore
|
|
911
|
-
sendAndTransfer(message, transfer) {
|
|
912
|
-
array(transfer);
|
|
913
|
-
this.process.postMessage(message, transfer);
|
|
914
|
-
},
|
|
915
|
-
dispose() {
|
|
916
|
-
this.process.kill();
|
|
917
|
-
}
|
|
918
|
-
};
|
|
850
|
+
return new IpcParentWithElectronUtilityProcess(process);
|
|
919
851
|
};
|
|
920
852
|
|
|
921
|
-
const IpcParentWithElectronUtilityProcess = {
|
|
853
|
+
const IpcParentWithElectronUtilityProcess$1 = {
|
|
922
854
|
__proto__: null,
|
|
923
855
|
create: create$2,
|
|
924
856
|
wrap: wrap$2
|
|
@@ -1188,4 +1120,4 @@ const IpcParentWithNodeWorker = {
|
|
|
1188
1120
|
wrap
|
|
1189
1121
|
};
|
|
1190
1122
|
|
|
1191
|
-
export { IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker, IpcChildWithWebSocket, IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|
|
1123
|
+
export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker, IpcChildWithWebSocket, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|