@lvce-editor/ipc 3.4.0 → 3.5.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 +1 -0
- package/dist/index.js +69 -33
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export const IpcChildWithElectronMessagePort: IpcChild
|
|
|
7
7
|
export const IpcChildWithElectronUtilityProcess: IpcChild
|
|
8
8
|
export const IpcChildWithNodeForkedProcess: IpcChild
|
|
9
9
|
export const IpcChildWithWebSocket: IpcChild
|
|
10
|
+
export const IpcChildWithNodeWorker: IpcChild
|
|
10
11
|
|
|
11
12
|
interface IpcParent {
|
|
12
13
|
readonly create: any
|
package/dist/index.js
CHANGED
|
@@ -151,7 +151,7 @@ const isMessagePortMain = value => {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
// @ts-ignore
|
|
154
|
-
const listen$
|
|
154
|
+
const listen$7 = ({
|
|
155
155
|
messagePort
|
|
156
156
|
}) => {
|
|
157
157
|
if (!isMessagePortMain(messagePort)) {
|
|
@@ -176,7 +176,7 @@ const getActualData$1 = event => {
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
// @ts-ignore
|
|
179
|
-
const wrap$
|
|
179
|
+
const wrap$a = messagePort => {
|
|
180
180
|
return {
|
|
181
181
|
messagePort,
|
|
182
182
|
// @ts-ignore
|
|
@@ -213,8 +213,8 @@ const wrap$9 = messagePort => {
|
|
|
213
213
|
|
|
214
214
|
const IpcChildWithElectronMessagePort = {
|
|
215
215
|
__proto__: null,
|
|
216
|
-
listen: listen$
|
|
217
|
-
wrap: wrap$
|
|
216
|
+
listen: listen$7,
|
|
217
|
+
wrap: wrap$a
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
// @ts-ignore
|
|
@@ -232,7 +232,7 @@ const getUtilityProcessPortData = event => {
|
|
|
232
232
|
};
|
|
233
233
|
};
|
|
234
234
|
|
|
235
|
-
const listen$
|
|
235
|
+
const listen$6 = () => {
|
|
236
236
|
// @ts-ignore
|
|
237
237
|
const {
|
|
238
238
|
parentPort
|
|
@@ -244,12 +244,12 @@ const listen$5 = () => {
|
|
|
244
244
|
};
|
|
245
245
|
|
|
246
246
|
// @ts-ignore
|
|
247
|
-
const signal$
|
|
247
|
+
const signal$3 = parentPort => {
|
|
248
248
|
parentPort.postMessage('ready');
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
// @ts-ignore
|
|
252
|
-
const wrap$
|
|
252
|
+
const wrap$9 = parentPort => {
|
|
253
253
|
return {
|
|
254
254
|
parentPort,
|
|
255
255
|
// @ts-ignore
|
|
@@ -287,16 +287,16 @@ const wrap$8 = parentPort => {
|
|
|
287
287
|
|
|
288
288
|
const IpcChildWithElectronUtilityProcess = {
|
|
289
289
|
__proto__: null,
|
|
290
|
-
listen: listen$
|
|
291
|
-
signal: signal$
|
|
292
|
-
wrap: wrap$
|
|
290
|
+
listen: listen$6,
|
|
291
|
+
signal: signal$3,
|
|
292
|
+
wrap: wrap$9
|
|
293
293
|
};
|
|
294
294
|
|
|
295
295
|
const getData = event => {
|
|
296
296
|
return event.data;
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
-
const listen$
|
|
299
|
+
const listen$5 = () => {
|
|
300
300
|
// @ts-ignore
|
|
301
301
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
302
302
|
throw new TypeError('module is not in web worker scope');
|
|
@@ -305,10 +305,10 @@ const listen$4 = () => {
|
|
|
305
305
|
globalThis.postMessage('ready');
|
|
306
306
|
return globalThis;
|
|
307
307
|
};
|
|
308
|
-
const signal$
|
|
308
|
+
const signal$2 = global => {
|
|
309
309
|
global.postMessage('ready');
|
|
310
310
|
};
|
|
311
|
-
const wrap$
|
|
311
|
+
const wrap$8 = global => {
|
|
312
312
|
return {
|
|
313
313
|
global,
|
|
314
314
|
/**
|
|
@@ -341,9 +341,9 @@ const wrap$7 = global => {
|
|
|
341
341
|
|
|
342
342
|
const IpcChildWithModuleWorker = {
|
|
343
343
|
__proto__: null,
|
|
344
|
-
listen: listen$
|
|
345
|
-
signal: signal$
|
|
346
|
-
wrap: wrap$
|
|
344
|
+
listen: listen$5,
|
|
345
|
+
signal: signal$2,
|
|
346
|
+
wrap: wrap$8
|
|
347
347
|
};
|
|
348
348
|
|
|
349
349
|
const withResolvers = () => {
|
|
@@ -375,9 +375,9 @@ const waitForFirstMessage = async port => {
|
|
|
375
375
|
return event.data;
|
|
376
376
|
};
|
|
377
377
|
|
|
378
|
-
const listen$
|
|
379
|
-
const parentIpcRaw = listen$
|
|
380
|
-
const parentIpc = wrap$
|
|
378
|
+
const listen$4 = async () => {
|
|
379
|
+
const parentIpcRaw = listen$5();
|
|
380
|
+
const parentIpc = wrap$8(parentIpcRaw);
|
|
381
381
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
382
382
|
if (firstMessage.method !== 'initialize') {
|
|
383
383
|
throw new IpcError('unexpected first message');
|
|
@@ -389,7 +389,7 @@ const listen$3 = async () => {
|
|
|
389
389
|
}
|
|
390
390
|
return globalThis;
|
|
391
391
|
};
|
|
392
|
-
const wrap$
|
|
392
|
+
const wrap$7 = port => {
|
|
393
393
|
return {
|
|
394
394
|
port,
|
|
395
395
|
/**
|
|
@@ -426,11 +426,11 @@ const wrap$6 = port => {
|
|
|
426
426
|
|
|
427
427
|
const IpcChildWithModuleWorkerAndMessagePort = {
|
|
428
428
|
__proto__: null,
|
|
429
|
-
listen: listen$
|
|
430
|
-
wrap: wrap$
|
|
429
|
+
listen: listen$4,
|
|
430
|
+
wrap: wrap$7
|
|
431
431
|
};
|
|
432
432
|
|
|
433
|
-
const listen$
|
|
433
|
+
const listen$3 = async () => {
|
|
434
434
|
if (!process.send) {
|
|
435
435
|
throw new Error('process.send must be defined');
|
|
436
436
|
}
|
|
@@ -438,7 +438,7 @@ const listen$2 = async () => {
|
|
|
438
438
|
};
|
|
439
439
|
|
|
440
440
|
// @ts-ignore
|
|
441
|
-
const signal = process => {
|
|
441
|
+
const signal$1 = process => {
|
|
442
442
|
process.send('ready');
|
|
443
443
|
};
|
|
444
444
|
|
|
@@ -454,7 +454,7 @@ const getActualData = (message, handle) => {
|
|
|
454
454
|
};
|
|
455
455
|
|
|
456
456
|
// @ts-ignore
|
|
457
|
-
const wrap$
|
|
457
|
+
const wrap$6 = process => {
|
|
458
458
|
return {
|
|
459
459
|
process,
|
|
460
460
|
// @ts-ignore
|
|
@@ -486,16 +486,16 @@ const wrap$5 = process => {
|
|
|
486
486
|
|
|
487
487
|
const IpcChildWithNodeForkedProcess = {
|
|
488
488
|
__proto__: null,
|
|
489
|
-
listen: listen$
|
|
490
|
-
signal,
|
|
491
|
-
wrap: wrap$
|
|
489
|
+
listen: listen$3,
|
|
490
|
+
signal: signal$1,
|
|
491
|
+
wrap: wrap$6
|
|
492
492
|
};
|
|
493
493
|
|
|
494
494
|
const isMessagePort = value => {
|
|
495
495
|
return value && value instanceof MessagePort;
|
|
496
496
|
};
|
|
497
497
|
|
|
498
|
-
const listen$
|
|
498
|
+
const listen$2 = async ({
|
|
499
499
|
messagePort
|
|
500
500
|
}) => {
|
|
501
501
|
if (!isMessagePort(messagePort)) {
|
|
@@ -503,7 +503,7 @@ const listen$1 = async ({
|
|
|
503
503
|
}
|
|
504
504
|
return messagePort;
|
|
505
505
|
};
|
|
506
|
-
const wrap$
|
|
506
|
+
const wrap$5 = port => {
|
|
507
507
|
return {
|
|
508
508
|
port,
|
|
509
509
|
on(event, listener) {
|
|
@@ -525,15 +525,51 @@ const wrap$4 = port => {
|
|
|
525
525
|
};
|
|
526
526
|
|
|
527
527
|
const IpcChildWithNodeMessagePort = {
|
|
528
|
+
__proto__: null,
|
|
529
|
+
listen: listen$2,
|
|
530
|
+
wrap: wrap$5
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
const listen$1 = async () => {
|
|
534
|
+
const {
|
|
535
|
+
parentPort
|
|
536
|
+
} = await import('node:worker_threads');
|
|
537
|
+
if (!parentPort) {
|
|
538
|
+
throw new IpcError('parentPort is required');
|
|
539
|
+
}
|
|
540
|
+
return parentPort;
|
|
541
|
+
};
|
|
542
|
+
const signal = parentPort => {
|
|
543
|
+
parentPort.postMessage('ready');
|
|
544
|
+
};
|
|
545
|
+
const wrap$4 = parentPort => {
|
|
546
|
+
return {
|
|
547
|
+
parentPort,
|
|
548
|
+
on(event, listener) {
|
|
549
|
+
this.parentPort.on(event, listener);
|
|
550
|
+
},
|
|
551
|
+
off(event, listener) {
|
|
552
|
+
this.parentPort.off(event, listener);
|
|
553
|
+
},
|
|
554
|
+
send(message) {
|
|
555
|
+
this.parentPort.postMessage(message);
|
|
556
|
+
},
|
|
557
|
+
dispose() {
|
|
558
|
+
this.parentPort.close();
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
const IpcChildWithNodeWorker = {
|
|
528
564
|
__proto__: null,
|
|
529
565
|
listen: listen$1,
|
|
566
|
+
signal,
|
|
530
567
|
wrap: wrap$4
|
|
531
568
|
};
|
|
532
569
|
|
|
533
570
|
const Open = 1;
|
|
534
571
|
const Close = 2;
|
|
535
572
|
|
|
536
|
-
// @ts-ignore
|
|
537
573
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
538
574
|
const {
|
|
539
575
|
resolve,
|
|
@@ -1000,9 +1036,9 @@ const IpcParentWithNodeForkedProcess = {
|
|
|
1000
1036
|
wrap: wrap$1
|
|
1001
1037
|
};
|
|
1002
1038
|
|
|
1003
|
-
// @ts-ignore
|
|
1004
1039
|
const getFirstNodeWorkerEvent = worker => {
|
|
1005
1040
|
return getFirstEvent(worker, {
|
|
1041
|
+
message: Message,
|
|
1006
1042
|
exit: Exit,
|
|
1007
1043
|
error: Error$1
|
|
1008
1044
|
});
|
|
@@ -1076,4 +1112,4 @@ const IpcParentWithNodeWorker = {
|
|
|
1076
1112
|
wrap
|
|
1077
1113
|
};
|
|
1078
1114
|
|
|
1079
|
-
export { IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithWebSocket, IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|
|
1115
|
+
export { IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker, IpcChildWithWebSocket, IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|