@lvce-editor/ipc 11.4.0 → 11.6.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/index.d.ts +3 -0
- package/dist/index.js +292 -65
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const IpcChildWithNodeForkedProcess: IpcChild
|
|
|
16
16
|
export const IpcChildWithWebSocket: IpcChild
|
|
17
17
|
export const IpcChildWithNodeWorker: IpcChild
|
|
18
18
|
export const IpcChildWithRendererProcess2: IpcChild
|
|
19
|
+
export const IpcChildWithModuleWorkerAndMessagePort: IpcChild
|
|
19
20
|
|
|
20
21
|
interface IpcParent {
|
|
21
22
|
readonly create: any
|
|
@@ -27,3 +28,5 @@ export const IpcParentWithNodeForkedProcess: IpcParent
|
|
|
27
28
|
export const IpcParentWithNodeWorker: IpcParent
|
|
28
29
|
export const IpcParentWithElectronMessagePort: IpcParent
|
|
29
30
|
export const IpcParentWithMessagePort: IpcParent
|
|
31
|
+
export const IpcParentWithWebSocket: IpcParent
|
|
32
|
+
export const IpcParentWithModuleWorker: IpcParent
|
package/dist/index.js
CHANGED
|
@@ -287,7 +287,7 @@ const listen$8 = ({
|
|
|
287
287
|
}
|
|
288
288
|
return messagePort;
|
|
289
289
|
};
|
|
290
|
-
const signal$
|
|
290
|
+
const signal$8 = messagePort => {
|
|
291
291
|
messagePort.start();
|
|
292
292
|
};
|
|
293
293
|
class IpcChildWithElectronMessagePort extends Ipc {
|
|
@@ -315,15 +315,15 @@ class IpcChildWithElectronMessagePort extends Ipc {
|
|
|
315
315
|
this._rawIpc.on('close', callback);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
const wrap$
|
|
318
|
+
const wrap$f = messagePort => {
|
|
319
319
|
return new IpcChildWithElectronMessagePort(messagePort);
|
|
320
320
|
};
|
|
321
321
|
|
|
322
322
|
const IpcChildWithElectronMessagePort$1 = {
|
|
323
323
|
__proto__: null,
|
|
324
324
|
listen: listen$8,
|
|
325
|
-
signal: signal$
|
|
326
|
-
wrap: wrap$
|
|
325
|
+
signal: signal$8,
|
|
326
|
+
wrap: wrap$f
|
|
327
327
|
};
|
|
328
328
|
|
|
329
329
|
// @ts-ignore
|
|
@@ -353,7 +353,7 @@ const listen$7 = () => {
|
|
|
353
353
|
}
|
|
354
354
|
return parentPort;
|
|
355
355
|
};
|
|
356
|
-
const signal$
|
|
356
|
+
const signal$7 = parentPort => {
|
|
357
357
|
parentPort.postMessage(readyMessage);
|
|
358
358
|
};
|
|
359
359
|
class IpcChildWithElectronUtilityProcess extends Ipc {
|
|
@@ -380,18 +380,18 @@ class IpcChildWithElectronUtilityProcess extends Ipc {
|
|
|
380
380
|
this._rawIpc.on('message', callback);
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
|
-
const wrap$
|
|
383
|
+
const wrap$e = parentPort => {
|
|
384
384
|
return new IpcChildWithElectronUtilityProcess(parentPort);
|
|
385
385
|
};
|
|
386
386
|
|
|
387
387
|
const IpcChildWithElectronUtilityProcess$1 = {
|
|
388
388
|
__proto__: null,
|
|
389
389
|
listen: listen$7,
|
|
390
|
-
signal: signal$
|
|
391
|
-
wrap: wrap$
|
|
390
|
+
signal: signal$7,
|
|
391
|
+
wrap: wrap$e
|
|
392
392
|
};
|
|
393
393
|
|
|
394
|
-
const getData$
|
|
394
|
+
const getData$2 = event => {
|
|
395
395
|
return event.data;
|
|
396
396
|
};
|
|
397
397
|
|
|
@@ -402,12 +402,12 @@ const listen$6 = () => {
|
|
|
402
402
|
}
|
|
403
403
|
return globalThis;
|
|
404
404
|
};
|
|
405
|
-
const signal$
|
|
405
|
+
const signal$6 = global => {
|
|
406
406
|
global.postMessage(readyMessage);
|
|
407
407
|
};
|
|
408
408
|
class IpcChildWithModuleWorker extends Ipc {
|
|
409
409
|
getData(event) {
|
|
410
|
-
return getData$
|
|
410
|
+
return getData$2(event);
|
|
411
411
|
}
|
|
412
412
|
send(message) {
|
|
413
413
|
// @ts-ignore
|
|
@@ -428,15 +428,15 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
428
428
|
this._rawIpc.addEventListener('message', callback);
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
const wrap$
|
|
431
|
+
const wrap$d = global => {
|
|
432
432
|
return new IpcChildWithModuleWorker(global);
|
|
433
433
|
};
|
|
434
434
|
|
|
435
435
|
const IpcChildWithModuleWorker$1 = {
|
|
436
436
|
__proto__: null,
|
|
437
437
|
listen: listen$6,
|
|
438
|
-
signal: signal$
|
|
439
|
-
wrap: wrap$
|
|
438
|
+
signal: signal$6,
|
|
439
|
+
wrap: wrap$d
|
|
440
440
|
};
|
|
441
441
|
|
|
442
442
|
const withResolvers = () => {
|
|
@@ -465,8 +465,8 @@ const waitForFirstMessage = async port => {
|
|
|
465
465
|
|
|
466
466
|
const listen$5 = async () => {
|
|
467
467
|
const parentIpcRaw = listen$6();
|
|
468
|
-
signal$
|
|
469
|
-
const parentIpc = wrap$
|
|
468
|
+
signal$6(parentIpcRaw);
|
|
469
|
+
const parentIpc = wrap$d(parentIpcRaw);
|
|
470
470
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
471
471
|
if (firstMessage.method !== 'initialize') {
|
|
472
472
|
throw new IpcError('unexpected first message');
|
|
@@ -489,7 +489,7 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
489
489
|
super(port);
|
|
490
490
|
}
|
|
491
491
|
getData(event) {
|
|
492
|
-
return getData$
|
|
492
|
+
return getData$2(event);
|
|
493
493
|
}
|
|
494
494
|
send(message) {
|
|
495
495
|
this._rawIpc.postMessage(message);
|
|
@@ -511,14 +511,14 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
511
511
|
this._rawIpc.start();
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
const wrap$
|
|
514
|
+
const wrap$c = port => {
|
|
515
515
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
516
516
|
};
|
|
517
517
|
|
|
518
518
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
519
519
|
__proto__: null,
|
|
520
520
|
listen: listen$5,
|
|
521
|
-
wrap: wrap$
|
|
521
|
+
wrap: wrap$c
|
|
522
522
|
};
|
|
523
523
|
|
|
524
524
|
const getTransferrablesNode = value => {
|
|
@@ -545,7 +545,7 @@ const listen$4 = async () => {
|
|
|
545
545
|
}
|
|
546
546
|
return process;
|
|
547
547
|
};
|
|
548
|
-
const signal$
|
|
548
|
+
const signal$5 = process => {
|
|
549
549
|
process.send(readyMessage);
|
|
550
550
|
};
|
|
551
551
|
class IpcChildWithNodeForkedProcess extends Ipc {
|
|
@@ -572,15 +572,15 @@ class IpcChildWithNodeForkedProcess extends Ipc {
|
|
|
572
572
|
// ignore
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
|
-
const wrap$
|
|
575
|
+
const wrap$b = process => {
|
|
576
576
|
return new IpcChildWithNodeForkedProcess(process);
|
|
577
577
|
};
|
|
578
578
|
|
|
579
579
|
const IpcChildWithNodeForkedProcess$1 = {
|
|
580
580
|
__proto__: null,
|
|
581
581
|
listen: listen$4,
|
|
582
|
-
signal: signal$
|
|
583
|
-
wrap: wrap$
|
|
582
|
+
signal: signal$5,
|
|
583
|
+
wrap: wrap$b
|
|
584
584
|
};
|
|
585
585
|
|
|
586
586
|
const listen$3 = async ({
|
|
@@ -591,10 +591,10 @@ const listen$3 = async ({
|
|
|
591
591
|
}
|
|
592
592
|
return messagePort;
|
|
593
593
|
};
|
|
594
|
-
const signal$
|
|
594
|
+
const signal$4 = messagePort => {
|
|
595
595
|
messagePort.start();
|
|
596
596
|
};
|
|
597
|
-
const wrap$
|
|
597
|
+
const wrap$a = port => {
|
|
598
598
|
return {
|
|
599
599
|
port,
|
|
600
600
|
on(event, listener) {
|
|
@@ -625,8 +625,8 @@ const wrap$7 = port => {
|
|
|
625
625
|
const IpcChildWithNodeMessagePort = {
|
|
626
626
|
__proto__: null,
|
|
627
627
|
listen: listen$3,
|
|
628
|
-
signal: signal$
|
|
629
|
-
wrap: wrap$
|
|
628
|
+
signal: signal$4,
|
|
629
|
+
wrap: wrap$a
|
|
630
630
|
};
|
|
631
631
|
|
|
632
632
|
const listen$2 = async () => {
|
|
@@ -638,7 +638,7 @@ const listen$2 = async () => {
|
|
|
638
638
|
}
|
|
639
639
|
return parentPort;
|
|
640
640
|
};
|
|
641
|
-
const signal$
|
|
641
|
+
const signal$3 = parentPort => {
|
|
642
642
|
parentPort.postMessage(readyMessage);
|
|
643
643
|
};
|
|
644
644
|
class IpcChildWithNodeWorker extends Ipc {
|
|
@@ -665,15 +665,15 @@ class IpcChildWithNodeWorker extends Ipc {
|
|
|
665
665
|
this._rawIpc.close();
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
const wrap$
|
|
668
|
+
const wrap$9 = parentPort => {
|
|
669
669
|
return new IpcChildWithNodeWorker(parentPort);
|
|
670
670
|
};
|
|
671
671
|
|
|
672
672
|
const IpcChildWithNodeWorker$1 = {
|
|
673
673
|
__proto__: null,
|
|
674
674
|
listen: listen$2,
|
|
675
|
-
signal: signal$
|
|
676
|
-
wrap: wrap$
|
|
675
|
+
signal: signal$3,
|
|
676
|
+
wrap: wrap$9
|
|
677
677
|
};
|
|
678
678
|
|
|
679
679
|
const preloadChannelType = 'port';
|
|
@@ -682,7 +682,7 @@ const listen$1 = ({
|
|
|
682
682
|
}) => {
|
|
683
683
|
return webContents;
|
|
684
684
|
};
|
|
685
|
-
const getData = (event, message) => {
|
|
685
|
+
const getData$1 = (event, message) => {
|
|
686
686
|
const {
|
|
687
687
|
ports,
|
|
688
688
|
sender
|
|
@@ -695,7 +695,7 @@ const getData = (event, message) => {
|
|
|
695
695
|
};
|
|
696
696
|
class IpcChildWithRendererProcess2 extends Ipc {
|
|
697
697
|
getData(event, message) {
|
|
698
|
-
return getData(event, message);
|
|
698
|
+
return getData$1(event, message);
|
|
699
699
|
}
|
|
700
700
|
send(message) {
|
|
701
701
|
this._rawIpc.postMessage(preloadChannelType, message);
|
|
@@ -714,14 +714,14 @@ class IpcChildWithRendererProcess2 extends Ipc {
|
|
|
714
714
|
this._rawIpc.on('destroyed', callback);
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
|
-
const wrap$
|
|
717
|
+
const wrap$8 = webContents => {
|
|
718
718
|
return new IpcChildWithRendererProcess2(webContents);
|
|
719
719
|
};
|
|
720
720
|
|
|
721
721
|
const IpcChildWithRendererProcess2$1 = {
|
|
722
722
|
__proto__: null,
|
|
723
723
|
listen: listen$1,
|
|
724
|
-
wrap: wrap$
|
|
724
|
+
wrap: wrap$8
|
|
725
725
|
};
|
|
726
726
|
|
|
727
727
|
const Open = 1;
|
|
@@ -842,12 +842,12 @@ const listen = async ({
|
|
|
842
842
|
}
|
|
843
843
|
return webSocket;
|
|
844
844
|
};
|
|
845
|
-
const signal$
|
|
845
|
+
const signal$2 = webSocket => {
|
|
846
846
|
webSocket.resume();
|
|
847
847
|
};
|
|
848
848
|
|
|
849
849
|
// @ts-ignore
|
|
850
|
-
const wrap$
|
|
850
|
+
const wrap$7 = webSocket => {
|
|
851
851
|
return {
|
|
852
852
|
webSocket,
|
|
853
853
|
/**
|
|
@@ -897,11 +897,11 @@ const wrap$4 = webSocket => {
|
|
|
897
897
|
const IpcChildWithWebSocket = {
|
|
898
898
|
__proto__: null,
|
|
899
899
|
listen,
|
|
900
|
-
signal: signal$
|
|
901
|
-
wrap: wrap$
|
|
900
|
+
signal: signal$2,
|
|
901
|
+
wrap: wrap$7
|
|
902
902
|
};
|
|
903
903
|
|
|
904
|
-
const create$
|
|
904
|
+
const create$6 = ({
|
|
905
905
|
messagePort
|
|
906
906
|
}) => {
|
|
907
907
|
if (!isMessagePortMain(messagePort)) {
|
|
@@ -909,7 +909,7 @@ const create$3 = ({
|
|
|
909
909
|
}
|
|
910
910
|
return messagePort;
|
|
911
911
|
};
|
|
912
|
-
const signal = messagePort => {
|
|
912
|
+
const signal$1 = messagePort => {
|
|
913
913
|
messagePort.start();
|
|
914
914
|
};
|
|
915
915
|
class IpcParentWithElectronMessagePort extends Ipc {
|
|
@@ -937,20 +937,20 @@ class IpcParentWithElectronMessagePort extends Ipc {
|
|
|
937
937
|
this._rawIpc.on('close', callback);
|
|
938
938
|
}
|
|
939
939
|
}
|
|
940
|
-
const wrap$
|
|
940
|
+
const wrap$6 = messagePort => {
|
|
941
941
|
return new IpcParentWithElectronMessagePort(messagePort);
|
|
942
942
|
};
|
|
943
943
|
|
|
944
944
|
const IpcParentWithElectronMessagePort$1 = {
|
|
945
945
|
__proto__: null,
|
|
946
|
-
create: create$
|
|
947
|
-
signal,
|
|
948
|
-
wrap: wrap$
|
|
946
|
+
create: create$6,
|
|
947
|
+
signal: signal$1,
|
|
948
|
+
wrap: wrap$6
|
|
949
949
|
};
|
|
950
950
|
|
|
951
951
|
const Exit = 1;
|
|
952
|
-
const Error$
|
|
953
|
-
const Message = 3;
|
|
952
|
+
const Error$2 = 2;
|
|
953
|
+
const Message$1 = 3;
|
|
954
954
|
|
|
955
955
|
/**
|
|
956
956
|
*
|
|
@@ -987,7 +987,7 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
987
987
|
// @ts-ignore
|
|
988
988
|
const handleMessage = event => {
|
|
989
989
|
cleanup({
|
|
990
|
-
type: Message,
|
|
990
|
+
type: Message$1,
|
|
991
991
|
event,
|
|
992
992
|
stdout,
|
|
993
993
|
stderr
|
|
@@ -1022,7 +1022,7 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
1022
1022
|
};
|
|
1023
1023
|
|
|
1024
1024
|
// @ts-ignore
|
|
1025
|
-
const create$
|
|
1025
|
+
const create$5 = async ({
|
|
1026
1026
|
path,
|
|
1027
1027
|
argv = [],
|
|
1028
1028
|
execArgv = [],
|
|
@@ -1085,14 +1085,180 @@ class IpcParentWithElectronUtilityProcess extends Ipc {
|
|
|
1085
1085
|
this._rawIpc.on('message', callback);
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
|
-
const wrap$
|
|
1088
|
+
const wrap$5 = process => {
|
|
1089
1089
|
return new IpcParentWithElectronUtilityProcess(process);
|
|
1090
1090
|
};
|
|
1091
1091
|
|
|
1092
1092
|
const IpcParentWithElectronUtilityProcess$1 = {
|
|
1093
1093
|
__proto__: null,
|
|
1094
|
-
create: create$
|
|
1095
|
-
wrap: wrap$
|
|
1094
|
+
create: create$5,
|
|
1095
|
+
wrap: wrap$5
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
const create$4 = async ({
|
|
1099
|
+
messagePort,
|
|
1100
|
+
isMessagePortOpen
|
|
1101
|
+
}) => {
|
|
1102
|
+
if (!isMessagePort(messagePort)) {
|
|
1103
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1104
|
+
}
|
|
1105
|
+
if (isMessagePortOpen) {
|
|
1106
|
+
return messagePort;
|
|
1107
|
+
}
|
|
1108
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1109
|
+
message: Message$1
|
|
1110
|
+
});
|
|
1111
|
+
messagePort.start();
|
|
1112
|
+
const event = await eventPromise;
|
|
1113
|
+
// @ts-ignore
|
|
1114
|
+
if (event.data !== readyMessage) {
|
|
1115
|
+
throw new IpcError('unexpected first message');
|
|
1116
|
+
}
|
|
1117
|
+
return messagePort;
|
|
1118
|
+
};
|
|
1119
|
+
const signal = messagePort => {
|
|
1120
|
+
messagePort.start();
|
|
1121
|
+
};
|
|
1122
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1123
|
+
constructor(port) {
|
|
1124
|
+
super(port);
|
|
1125
|
+
}
|
|
1126
|
+
getData = getData$2;
|
|
1127
|
+
send(message) {
|
|
1128
|
+
this._rawIpc.postMessage(message);
|
|
1129
|
+
}
|
|
1130
|
+
sendAndTransfer(message) {
|
|
1131
|
+
throw new Error('not implemented');
|
|
1132
|
+
}
|
|
1133
|
+
dispose() {
|
|
1134
|
+
this._rawIpc.close();
|
|
1135
|
+
}
|
|
1136
|
+
onMessage(callback) {
|
|
1137
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1138
|
+
}
|
|
1139
|
+
onClose(callback) {}
|
|
1140
|
+
}
|
|
1141
|
+
const wrap$4 = messagePort => {
|
|
1142
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
const IpcParentWithMessagePort$1 = {
|
|
1146
|
+
__proto__: null,
|
|
1147
|
+
create: create$4,
|
|
1148
|
+
signal,
|
|
1149
|
+
wrap: wrap$4
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
const Message = 'message';
|
|
1153
|
+
const Error$1 = 'error';
|
|
1154
|
+
|
|
1155
|
+
const getFirstWorkerEvent = worker => {
|
|
1156
|
+
return getFirstEvent(worker, {
|
|
1157
|
+
message: Message,
|
|
1158
|
+
error: Error$1
|
|
1159
|
+
});
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
const isErrorEvent = event => {
|
|
1163
|
+
return event instanceof ErrorEvent;
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
const getWorkerDisplayName = name => {
|
|
1167
|
+
if (!name) {
|
|
1168
|
+
return '<unknown> worker';
|
|
1169
|
+
}
|
|
1170
|
+
if (name.endsWith('Worker') || name.endsWith('worker')) {
|
|
1171
|
+
return name.toLowerCase();
|
|
1172
|
+
}
|
|
1173
|
+
return `${name} Worker`;
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
const tryToGetActualErrorMessage = async ({
|
|
1177
|
+
name
|
|
1178
|
+
}) => {
|
|
1179
|
+
const displayName = getWorkerDisplayName(name);
|
|
1180
|
+
return `Failed to start ${displayName}: Worker Launch Error`;
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
class WorkerError extends Error {
|
|
1184
|
+
constructor(event) {
|
|
1185
|
+
super(event.message);
|
|
1186
|
+
const stackLines = splitLines(this.stack || '');
|
|
1187
|
+
const relevantLines = stackLines.slice(1);
|
|
1188
|
+
const relevant = joinLines(relevantLines);
|
|
1189
|
+
this.stack = `${event.message}
|
|
1190
|
+
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
1191
|
+
${relevant}`;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
const Module = 'module';
|
|
1196
|
+
|
|
1197
|
+
const create$3 = async ({
|
|
1198
|
+
url,
|
|
1199
|
+
name
|
|
1200
|
+
}) => {
|
|
1201
|
+
const worker = new Worker(url, {
|
|
1202
|
+
type: Module,
|
|
1203
|
+
name
|
|
1204
|
+
});
|
|
1205
|
+
const {
|
|
1206
|
+
type,
|
|
1207
|
+
event
|
|
1208
|
+
} = await getFirstWorkerEvent(worker);
|
|
1209
|
+
switch (type) {
|
|
1210
|
+
case Message:
|
|
1211
|
+
if (event.data !== readyMessage) {
|
|
1212
|
+
throw new IpcError('unexpected first message from worker');
|
|
1213
|
+
}
|
|
1214
|
+
break;
|
|
1215
|
+
case Error$1:
|
|
1216
|
+
if (isErrorEvent(event)) {
|
|
1217
|
+
throw new WorkerError(event);
|
|
1218
|
+
}
|
|
1219
|
+
const actualErrorMessage = await tryToGetActualErrorMessage({
|
|
1220
|
+
name
|
|
1221
|
+
});
|
|
1222
|
+
throw new Error(actualErrorMessage);
|
|
1223
|
+
}
|
|
1224
|
+
return worker;
|
|
1225
|
+
};
|
|
1226
|
+
const getData = event => {
|
|
1227
|
+
// TODO why are some events not instance of message event?
|
|
1228
|
+
if (event instanceof MessageEvent) {
|
|
1229
|
+
return event.data;
|
|
1230
|
+
}
|
|
1231
|
+
return event;
|
|
1232
|
+
};
|
|
1233
|
+
class IpcParentWithModuleWorker extends Ipc {
|
|
1234
|
+
getData(event) {
|
|
1235
|
+
return getData(event);
|
|
1236
|
+
}
|
|
1237
|
+
send(message) {
|
|
1238
|
+
this._rawIpc.postMessage(message);
|
|
1239
|
+
}
|
|
1240
|
+
sendAndTransfer(message) {
|
|
1241
|
+
const transfer = getTransferrables(message);
|
|
1242
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1243
|
+
}
|
|
1244
|
+
dispose() {
|
|
1245
|
+
// ignore
|
|
1246
|
+
}
|
|
1247
|
+
onClose(callback) {
|
|
1248
|
+
// ignore
|
|
1249
|
+
}
|
|
1250
|
+
onMessage(callback) {
|
|
1251
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const wrap$3 = worker => {
|
|
1255
|
+
return new IpcParentWithModuleWorker(worker);
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
const IpcParentWithModuleWorker$1 = {
|
|
1259
|
+
__proto__: null,
|
|
1260
|
+
create: create$3,
|
|
1261
|
+
wrap: wrap$3
|
|
1096
1262
|
};
|
|
1097
1263
|
|
|
1098
1264
|
class ChildProcessError extends Error {
|
|
@@ -1169,7 +1335,7 @@ const getFirstNodeChildProcessEvent = async childProcess => {
|
|
|
1169
1335
|
// @ts-ignore
|
|
1170
1336
|
const handleMessage = event => {
|
|
1171
1337
|
cleanup({
|
|
1172
|
-
type: Message,
|
|
1338
|
+
type: Message$1,
|
|
1173
1339
|
event,
|
|
1174
1340
|
stdout,
|
|
1175
1341
|
stderr
|
|
@@ -1187,7 +1353,7 @@ const getFirstNodeChildProcessEvent = async childProcess => {
|
|
|
1187
1353
|
// @ts-ignore
|
|
1188
1354
|
const handleError = event => {
|
|
1189
1355
|
cleanup({
|
|
1190
|
-
type: Error$
|
|
1356
|
+
type: Error$2,
|
|
1191
1357
|
event,
|
|
1192
1358
|
stdout,
|
|
1193
1359
|
stderr
|
|
@@ -1210,7 +1376,7 @@ const getFirstNodeChildProcessEvent = async childProcess => {
|
|
|
1210
1376
|
};
|
|
1211
1377
|
|
|
1212
1378
|
// @ts-ignore
|
|
1213
|
-
const create$
|
|
1379
|
+
const create$2 = async ({
|
|
1214
1380
|
path,
|
|
1215
1381
|
argv = [],
|
|
1216
1382
|
env,
|
|
@@ -1237,7 +1403,7 @@ const create$1 = async ({
|
|
|
1237
1403
|
if (type === Exit) {
|
|
1238
1404
|
throw new ChildProcessError(stderr);
|
|
1239
1405
|
}
|
|
1240
|
-
if (type === Error$
|
|
1406
|
+
if (type === Error$2) {
|
|
1241
1407
|
throw new Error(`child process had an error ${event}`);
|
|
1242
1408
|
}
|
|
1243
1409
|
if (stdio === 'inherit' && childProcess.stdout && childProcess.stderr) {
|
|
@@ -1277,14 +1443,14 @@ class IpcParentWithNodeForkedProcess extends Ipc {
|
|
|
1277
1443
|
this._rawIpc.on('message', callback);
|
|
1278
1444
|
}
|
|
1279
1445
|
}
|
|
1280
|
-
const wrap$
|
|
1446
|
+
const wrap$2 = childProcess => {
|
|
1281
1447
|
return new IpcParentWithNodeForkedProcess(childProcess);
|
|
1282
1448
|
};
|
|
1283
1449
|
|
|
1284
1450
|
const IpcParentWithNodeForkedProcess$1 = {
|
|
1285
1451
|
__proto__: null,
|
|
1286
|
-
create: create$
|
|
1287
|
-
wrap: wrap$
|
|
1452
|
+
create: create$2,
|
|
1453
|
+
wrap: wrap$2
|
|
1288
1454
|
};
|
|
1289
1455
|
|
|
1290
1456
|
const fixNodeWorkerParameters = value => {
|
|
@@ -1300,14 +1466,14 @@ const fixNodeWorkerParameters = value => {
|
|
|
1300
1466
|
|
|
1301
1467
|
const getFirstNodeWorkerEvent = worker => {
|
|
1302
1468
|
return getFirstEvent(worker, {
|
|
1303
|
-
message: Message,
|
|
1469
|
+
message: Message$1,
|
|
1304
1470
|
exit: Exit,
|
|
1305
|
-
error: Error$
|
|
1471
|
+
error: Error$2
|
|
1306
1472
|
});
|
|
1307
1473
|
};
|
|
1308
1474
|
|
|
1309
1475
|
// @ts-ignore
|
|
1310
|
-
const create = async ({
|
|
1476
|
+
const create$1 = async ({
|
|
1311
1477
|
path,
|
|
1312
1478
|
argv = [],
|
|
1313
1479
|
env = process.env,
|
|
@@ -1336,7 +1502,7 @@ const create = async ({
|
|
|
1336
1502
|
if (type === Exit) {
|
|
1337
1503
|
throw new IpcError(`Worker exited before ipc connection was established`);
|
|
1338
1504
|
}
|
|
1339
|
-
if (type === Error$
|
|
1505
|
+
if (type === Error$2) {
|
|
1340
1506
|
throw new IpcError(`Worker threw an error before ipc connection was established: ${event}`);
|
|
1341
1507
|
}
|
|
1342
1508
|
if (event !== readyMessage) {
|
|
@@ -1371,14 +1537,75 @@ class IpcParentWithNodeWorker extends Ipc {
|
|
|
1371
1537
|
this._rawIpc.on('message', callback);
|
|
1372
1538
|
}
|
|
1373
1539
|
}
|
|
1374
|
-
const wrap = worker => {
|
|
1540
|
+
const wrap$1 = worker => {
|
|
1375
1541
|
return new IpcParentWithNodeWorker(worker);
|
|
1376
1542
|
};
|
|
1377
1543
|
|
|
1378
1544
|
const IpcParentWithNodeWorker$1 = {
|
|
1545
|
+
__proto__: null,
|
|
1546
|
+
create: create$1,
|
|
1547
|
+
wrap: wrap$1
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
const stringifyCompact = value => {
|
|
1551
|
+
return JSON.stringify(value);
|
|
1552
|
+
};
|
|
1553
|
+
const parse = content => {
|
|
1554
|
+
if (content === 'undefined') {
|
|
1555
|
+
return null;
|
|
1556
|
+
}
|
|
1557
|
+
try {
|
|
1558
|
+
return JSON.parse(content);
|
|
1559
|
+
} catch (error) {
|
|
1560
|
+
throw new VError(error, 'failed to parse json');
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
const waitForWebSocketToBeOpen = webSocket => {
|
|
1565
|
+
return getFirstEvent(webSocket, {
|
|
1566
|
+
open: Open,
|
|
1567
|
+
close: Close
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1571
|
+
const create = async ({
|
|
1572
|
+
webSocket
|
|
1573
|
+
}) => {
|
|
1574
|
+
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
1575
|
+
// @ts-ignore
|
|
1576
|
+
if (firstWebSocketEvent.type === Close) {
|
|
1577
|
+
throw new IpcError('Websocket connection was immediately closed');
|
|
1578
|
+
}
|
|
1579
|
+
return webSocket;
|
|
1580
|
+
};
|
|
1581
|
+
class IpcParentWithWebSocket extends Ipc {
|
|
1582
|
+
getData(event) {
|
|
1583
|
+
return parse(event.data);
|
|
1584
|
+
}
|
|
1585
|
+
send(message) {
|
|
1586
|
+
this._rawIpc.send(stringifyCompact(message));
|
|
1587
|
+
}
|
|
1588
|
+
sendAndTransfer(message) {
|
|
1589
|
+
throw new Error('sendAndTransfer not supported');
|
|
1590
|
+
}
|
|
1591
|
+
dispose() {
|
|
1592
|
+
this._rawIpc.close();
|
|
1593
|
+
}
|
|
1594
|
+
onClose(callback) {
|
|
1595
|
+
this._rawIpc.addEventListener('close', callback);
|
|
1596
|
+
}
|
|
1597
|
+
onMessage(callback) {
|
|
1598
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
const wrap = webSocket => {
|
|
1602
|
+
return new IpcParentWithWebSocket(webSocket);
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
const IpcParentWithWebSocket$1 = {
|
|
1379
1606
|
__proto__: null,
|
|
1380
1607
|
create,
|
|
1381
1608
|
wrap
|
|
1382
1609
|
};
|
|
1383
1610
|
|
|
1384
|
-
export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess$1 as IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker$1 as IpcChildWithNodeWorker, IpcChildWithRendererProcess2$1 as IpcChildWithRendererProcess2, IpcChildWithWebSocket, IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker$1 as IpcParentWithNodeWorker };
|
|
1611
|
+
export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess$1 as IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker$1 as IpcChildWithNodeWorker, IpcChildWithRendererProcess2$1 as IpcChildWithRendererProcess2, IpcChildWithWebSocket, IpcParentWithElectronMessagePort$1 as IpcParentWithElectronMessagePort, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithMessagePort$1 as IpcParentWithMessagePort, IpcParentWithModuleWorker$1 as IpcParentWithModuleWorker, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker$1 as IpcParentWithNodeWorker, IpcParentWithWebSocket$1 as IpcParentWithWebSocket };
|