@lvce-editor/ipc 7.2.0 → 7.4.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 +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +82 -35
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -3,8 +3,8 @@ const getData$1 = event => {
|
|
|
3
3
|
};
|
|
4
4
|
|
|
5
5
|
const attachEvents = that => {
|
|
6
|
-
const handleMessage =
|
|
7
|
-
const data = that.getData(
|
|
6
|
+
const handleMessage = (...args) => {
|
|
7
|
+
const data = that.getData(...args);
|
|
8
8
|
that.dispatchEvent(new MessageEvent('message', {
|
|
9
9
|
data
|
|
10
10
|
}));
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export const IpcChildWithElectronUtilityProcess: IpcChild
|
|
|
15
15
|
export const IpcChildWithNodeForkedProcess: IpcChild
|
|
16
16
|
export const IpcChildWithWebSocket: IpcChild
|
|
17
17
|
export const IpcChildWithNodeWorker: IpcChild
|
|
18
|
+
export const IpcChildWithRendererProcess2: IpcChild
|
|
18
19
|
|
|
19
20
|
interface IpcParent {
|
|
20
21
|
readonly create: any
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { VError } from '@lvce-editor/verror';
|
|
|
2
2
|
import { string, array } from '@lvce-editor/assert';
|
|
3
3
|
|
|
4
4
|
const attachEvents = that => {
|
|
5
|
-
const handleMessage =
|
|
6
|
-
const data = that.getData(
|
|
5
|
+
const handleMessage = (...args) => {
|
|
6
|
+
const data = that.getData(...args);
|
|
7
7
|
that.dispatchEvent(new MessageEvent('message', {
|
|
8
8
|
data
|
|
9
9
|
}));
|
|
@@ -172,7 +172,7 @@ const isMessagePortMain = value => {
|
|
|
172
172
|
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
-
const listen$
|
|
175
|
+
const listen$8 = ({
|
|
176
176
|
messagePort
|
|
177
177
|
}) => {
|
|
178
178
|
if (!isMessagePortMain(messagePort)) {
|
|
@@ -219,15 +219,15 @@ class IpcChildWithElectronMessagePort extends Ipc {
|
|
|
219
219
|
this._rawIpc.on('close', callback);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
const wrap$
|
|
222
|
+
const wrap$b = messagePort => {
|
|
223
223
|
return new IpcChildWithElectronMessagePort(messagePort);
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
const IpcChildWithElectronMessagePort$1 = {
|
|
227
227
|
__proto__: null,
|
|
228
|
-
listen: listen$
|
|
228
|
+
listen: listen$8,
|
|
229
229
|
signal: signal$6,
|
|
230
|
-
wrap: wrap$
|
|
230
|
+
wrap: wrap$b
|
|
231
231
|
};
|
|
232
232
|
|
|
233
233
|
// @ts-ignore
|
|
@@ -247,7 +247,7 @@ const getUtilityProcessPortData = event => {
|
|
|
247
247
|
|
|
248
248
|
const readyMessage = 'ready';
|
|
249
249
|
|
|
250
|
-
const listen$
|
|
250
|
+
const listen$7 = () => {
|
|
251
251
|
// @ts-ignore
|
|
252
252
|
const {
|
|
253
253
|
parentPort
|
|
@@ -280,22 +280,22 @@ class IpcChildWithElectronUtilityProcess extends Ipc {
|
|
|
280
280
|
this._rawIpc.on('message', callback);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
const wrap$
|
|
283
|
+
const wrap$a = parentPort => {
|
|
284
284
|
return new IpcChildWithElectronUtilityProcess(parentPort);
|
|
285
285
|
};
|
|
286
286
|
|
|
287
287
|
const IpcChildWithElectronUtilityProcess$1 = {
|
|
288
288
|
__proto__: null,
|
|
289
|
-
listen: listen$
|
|
289
|
+
listen: listen$7,
|
|
290
290
|
signal: signal$5,
|
|
291
|
-
wrap: wrap$
|
|
291
|
+
wrap: wrap$a
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
const getData = event => {
|
|
294
|
+
const getData$1 = event => {
|
|
295
295
|
return event.data;
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
-
const listen$
|
|
298
|
+
const listen$6 = () => {
|
|
299
299
|
// @ts-ignore
|
|
300
300
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
301
301
|
throw new TypeError('module is not in web worker scope');
|
|
@@ -307,7 +307,7 @@ const signal$4 = global => {
|
|
|
307
307
|
};
|
|
308
308
|
class IpcChildWithModuleWorker extends Ipc {
|
|
309
309
|
getData(event) {
|
|
310
|
-
return getData(event);
|
|
310
|
+
return getData$1(event);
|
|
311
311
|
}
|
|
312
312
|
send(message) {
|
|
313
313
|
// @ts-ignore
|
|
@@ -327,15 +327,15 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
327
327
|
this._rawIpc.addEventListener('message', callback);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const wrap$
|
|
330
|
+
const wrap$9 = global => {
|
|
331
331
|
return new IpcChildWithModuleWorker(global);
|
|
332
332
|
};
|
|
333
333
|
|
|
334
334
|
const IpcChildWithModuleWorker$1 = {
|
|
335
335
|
__proto__: null,
|
|
336
|
-
listen: listen$
|
|
336
|
+
listen: listen$6,
|
|
337
337
|
signal: signal$4,
|
|
338
|
-
wrap: wrap$
|
|
338
|
+
wrap: wrap$9
|
|
339
339
|
};
|
|
340
340
|
|
|
341
341
|
const withResolvers = () => {
|
|
@@ -367,10 +367,10 @@ const waitForFirstMessage = async port => {
|
|
|
367
367
|
return event.data;
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
-
const listen$
|
|
371
|
-
const parentIpcRaw = listen$
|
|
370
|
+
const listen$5 = async () => {
|
|
371
|
+
const parentIpcRaw = listen$6();
|
|
372
372
|
signal$4(parentIpcRaw);
|
|
373
|
-
const parentIpc = wrap$
|
|
373
|
+
const parentIpc = wrap$9(parentIpcRaw);
|
|
374
374
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
375
375
|
if (firstMessage.method !== 'initialize') {
|
|
376
376
|
throw new IpcError('unexpected first message');
|
|
@@ -385,7 +385,7 @@ const listen$4 = async () => {
|
|
|
385
385
|
};
|
|
386
386
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
387
387
|
getData(event) {
|
|
388
|
-
return getData(event);
|
|
388
|
+
return getData$1(event);
|
|
389
389
|
}
|
|
390
390
|
send(message) {
|
|
391
391
|
this._rawIpc.postMessage(message);
|
|
@@ -405,17 +405,17 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
405
405
|
this._rawIpc.addEventListener('message', callback);
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
const wrap$
|
|
408
|
+
const wrap$8 = port => {
|
|
409
409
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
410
410
|
};
|
|
411
411
|
|
|
412
412
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
413
413
|
__proto__: null,
|
|
414
|
-
listen: listen$
|
|
415
|
-
wrap: wrap$
|
|
414
|
+
listen: listen$5,
|
|
415
|
+
wrap: wrap$8
|
|
416
416
|
};
|
|
417
417
|
|
|
418
|
-
const listen$
|
|
418
|
+
const listen$4 = async () => {
|
|
419
419
|
if (!process.send) {
|
|
420
420
|
throw new Error('process.send must be defined');
|
|
421
421
|
}
|
|
@@ -439,7 +439,7 @@ const getActualData = (message, handle) => {
|
|
|
439
439
|
};
|
|
440
440
|
|
|
441
441
|
// @ts-ignore
|
|
442
|
-
const wrap$
|
|
442
|
+
const wrap$7 = process => {
|
|
443
443
|
return {
|
|
444
444
|
process,
|
|
445
445
|
// @ts-ignore
|
|
@@ -475,16 +475,16 @@ const wrap$6 = process => {
|
|
|
475
475
|
|
|
476
476
|
const IpcChildWithNodeForkedProcess = {
|
|
477
477
|
__proto__: null,
|
|
478
|
-
listen: listen$
|
|
478
|
+
listen: listen$4,
|
|
479
479
|
signal: signal$3,
|
|
480
|
-
wrap: wrap$
|
|
480
|
+
wrap: wrap$7
|
|
481
481
|
};
|
|
482
482
|
|
|
483
483
|
const isMessagePort = value => {
|
|
484
484
|
return value && value instanceof MessagePort;
|
|
485
485
|
};
|
|
486
486
|
|
|
487
|
-
const listen$
|
|
487
|
+
const listen$3 = async ({
|
|
488
488
|
messagePort
|
|
489
489
|
}) => {
|
|
490
490
|
if (!isMessagePort(messagePort)) {
|
|
@@ -495,7 +495,7 @@ const listen$2 = async ({
|
|
|
495
495
|
const signal$2 = messagePort => {
|
|
496
496
|
messagePort.start();
|
|
497
497
|
};
|
|
498
|
-
const wrap$
|
|
498
|
+
const wrap$6 = port => {
|
|
499
499
|
return {
|
|
500
500
|
port,
|
|
501
501
|
on(event, listener) {
|
|
@@ -525,12 +525,12 @@ const wrap$5 = port => {
|
|
|
525
525
|
|
|
526
526
|
const IpcChildWithNodeMessagePort = {
|
|
527
527
|
__proto__: null,
|
|
528
|
-
listen: listen$
|
|
528
|
+
listen: listen$3,
|
|
529
529
|
signal: signal$2,
|
|
530
|
-
wrap: wrap$
|
|
530
|
+
wrap: wrap$6
|
|
531
531
|
};
|
|
532
532
|
|
|
533
|
-
const listen$
|
|
533
|
+
const listen$2 = async () => {
|
|
534
534
|
const {
|
|
535
535
|
parentPort
|
|
536
536
|
} = await import('node:worker_threads');
|
|
@@ -542,7 +542,7 @@ const listen$1 = async () => {
|
|
|
542
542
|
const signal$1 = parentPort => {
|
|
543
543
|
parentPort.postMessage(readyMessage);
|
|
544
544
|
};
|
|
545
|
-
const wrap$
|
|
545
|
+
const wrap$5 = parentPort => {
|
|
546
546
|
return {
|
|
547
547
|
parentPort,
|
|
548
548
|
on(event, listener) {
|
|
@@ -569,8 +569,55 @@ const wrap$4 = parentPort => {
|
|
|
569
569
|
|
|
570
570
|
const IpcChildWithNodeWorker = {
|
|
571
571
|
__proto__: null,
|
|
572
|
-
listen: listen$
|
|
572
|
+
listen: listen$2,
|
|
573
573
|
signal: signal$1,
|
|
574
|
+
wrap: wrap$5
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const preloadChannelType = 'port';
|
|
578
|
+
const listen$1 = ({
|
|
579
|
+
webContents
|
|
580
|
+
}) => {
|
|
581
|
+
return webContents;
|
|
582
|
+
};
|
|
583
|
+
const getData = (event, message) => {
|
|
584
|
+
const {
|
|
585
|
+
ports,
|
|
586
|
+
sender
|
|
587
|
+
} = event;
|
|
588
|
+
const data = {
|
|
589
|
+
...message,
|
|
590
|
+
params: [...message.params, ...ports, sender.id]
|
|
591
|
+
};
|
|
592
|
+
return data;
|
|
593
|
+
};
|
|
594
|
+
class IpcChildWithRendererProcess2 extends Ipc {
|
|
595
|
+
getData(event, message) {
|
|
596
|
+
return getData(event, message);
|
|
597
|
+
}
|
|
598
|
+
send(message) {
|
|
599
|
+
this._rawIpc.postMessage(preloadChannelType, message);
|
|
600
|
+
}
|
|
601
|
+
sendAndTransfer(message, transfer) {
|
|
602
|
+
this._rawIpc.postMessage(preloadChannelType, message, transfer);
|
|
603
|
+
}
|
|
604
|
+
dispose() {
|
|
605
|
+
// ignore
|
|
606
|
+
}
|
|
607
|
+
onMessage(callback) {
|
|
608
|
+
this._rawIpc.ipc.on(preloadChannelType, callback);
|
|
609
|
+
}
|
|
610
|
+
onClose(callback) {
|
|
611
|
+
this._rawIpc.on('destroyed', callback);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
const wrap$4 = webContents => {
|
|
615
|
+
return new IpcChildWithRendererProcess2(webContents);
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
const IpcChildWithRendererProcess2$1 = {
|
|
619
|
+
__proto__: null,
|
|
620
|
+
listen: listen$1,
|
|
574
621
|
wrap: wrap$4
|
|
575
622
|
};
|
|
576
623
|
|
|
@@ -1143,4 +1190,4 @@ const IpcParentWithNodeWorker = {
|
|
|
1143
1190
|
wrap
|
|
1144
1191
|
};
|
|
1145
1192
|
|
|
1146
|
-
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$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|
|
1193
|
+
export { IpcChildWithElectronMessagePort$1 as IpcChildWithElectronMessagePort, IpcChildWithElectronUtilityProcess$1 as IpcChildWithElectronUtilityProcess, IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithNodeForkedProcess, IpcChildWithNodeMessagePort, IpcChildWithNodeWorker, IpcChildWithRendererProcess2$1 as IpcChildWithRendererProcess2, IpcChildWithWebSocket, IpcParentWithElectronUtilityProcess$1 as IpcParentWithElectronUtilityProcess, IpcParentWithNodeForkedProcess$1 as IpcParentWithNodeForkedProcess, IpcParentWithNodeWorker };
|