@lvce-editor/ipc 9.1.0 → 9.3.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 +64 -17
- package/dist/index.js +4 -0
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -26,14 +26,14 @@ class Ipc extends EventTarget {
|
|
|
26
26
|
|
|
27
27
|
const readyMessage = 'ready';
|
|
28
28
|
|
|
29
|
-
const listen$
|
|
29
|
+
const listen$3 = () => {
|
|
30
30
|
// @ts-ignore
|
|
31
31
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
32
32
|
throw new TypeError('module is not in web worker scope');
|
|
33
33
|
}
|
|
34
34
|
return globalThis;
|
|
35
35
|
};
|
|
36
|
-
const signal$
|
|
36
|
+
const signal$2 = global => {
|
|
37
37
|
global.postMessage(readyMessage);
|
|
38
38
|
};
|
|
39
39
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -58,15 +58,15 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
58
58
|
this._rawIpc.addEventListener('message', callback);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
const wrap$
|
|
61
|
+
const wrap$5 = global => {
|
|
62
62
|
return new IpcChildWithModuleWorker(global);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const IpcChildWithModuleWorker$1 = {
|
|
66
66
|
__proto__: null,
|
|
67
|
-
listen: listen$
|
|
68
|
-
signal: signal$
|
|
69
|
-
wrap: wrap$
|
|
67
|
+
listen: listen$3,
|
|
68
|
+
signal: signal$2,
|
|
69
|
+
wrap: wrap$5
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
@@ -294,10 +294,10 @@ const waitForFirstMessage = async port => {
|
|
|
294
294
|
return event.data;
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
-
const listen$
|
|
298
|
-
const parentIpcRaw = listen$
|
|
299
|
-
signal$
|
|
300
|
-
const parentIpc = wrap$
|
|
297
|
+
const listen$2 = async () => {
|
|
298
|
+
const parentIpcRaw = listen$3();
|
|
299
|
+
signal$2(parentIpcRaw);
|
|
300
|
+
const parentIpc = wrap$5(parentIpcRaw);
|
|
301
301
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
302
302
|
if (firstMessage.method !== 'initialize') {
|
|
303
303
|
throw new IpcError('unexpected first message');
|
|
@@ -311,6 +311,9 @@ const listen$1 = async () => {
|
|
|
311
311
|
return globalThis;
|
|
312
312
|
};
|
|
313
313
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
314
|
+
constructor(port) {
|
|
315
|
+
super(port);
|
|
316
|
+
}
|
|
314
317
|
getData(event) {
|
|
315
318
|
return getData$1(event);
|
|
316
319
|
}
|
|
@@ -330,22 +333,23 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
330
333
|
}
|
|
331
334
|
onMessage(callback) {
|
|
332
335
|
this._rawIpc.addEventListener('message', callback);
|
|
336
|
+
this._rawIpc.start();
|
|
333
337
|
}
|
|
334
338
|
}
|
|
335
|
-
const wrap$
|
|
339
|
+
const wrap$4 = port => {
|
|
336
340
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
337
341
|
};
|
|
338
342
|
|
|
339
343
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
340
344
|
__proto__: null,
|
|
341
|
-
listen: listen$
|
|
342
|
-
wrap: wrap$
|
|
345
|
+
listen: listen$2,
|
|
346
|
+
wrap: wrap$4
|
|
343
347
|
};
|
|
344
348
|
|
|
345
|
-
const listen = () => {
|
|
349
|
+
const listen$1 = () => {
|
|
346
350
|
return window;
|
|
347
351
|
};
|
|
348
|
-
const signal = global => {
|
|
352
|
+
const signal$1 = global => {
|
|
349
353
|
global.postMessage(readyMessage);
|
|
350
354
|
};
|
|
351
355
|
class IpcChildWithWindow extends Ipc {
|
|
@@ -378,11 +382,54 @@ class IpcChildWithWindow extends Ipc {
|
|
|
378
382
|
this._rawIpc.addEventListener('message', wrapped);
|
|
379
383
|
}
|
|
380
384
|
}
|
|
381
|
-
const wrap$
|
|
385
|
+
const wrap$3 = window => {
|
|
382
386
|
return new IpcChildWithWindow(window);
|
|
383
387
|
};
|
|
384
388
|
|
|
385
389
|
const IpcChildWithWindow$1 = {
|
|
390
|
+
__proto__: null,
|
|
391
|
+
listen: listen$1,
|
|
392
|
+
signal: signal$1,
|
|
393
|
+
wrap: wrap$3
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
const listen = ({
|
|
397
|
+
port
|
|
398
|
+
}) => {
|
|
399
|
+
return port;
|
|
400
|
+
};
|
|
401
|
+
const signal = port => {
|
|
402
|
+
port.postMessage(readyMessage);
|
|
403
|
+
};
|
|
404
|
+
class IpcChildWithMessagePort extends Ipc {
|
|
405
|
+
constructor(port) {
|
|
406
|
+
super(port);
|
|
407
|
+
}
|
|
408
|
+
getData(event) {
|
|
409
|
+
return getData$1(event);
|
|
410
|
+
}
|
|
411
|
+
send(message) {
|
|
412
|
+
this._rawIpc.postMessage(message);
|
|
413
|
+
}
|
|
414
|
+
sendAndTransfer(message, transfer) {
|
|
415
|
+
this._rawIpc.postMessage(message, transfer);
|
|
416
|
+
}
|
|
417
|
+
dispose() {
|
|
418
|
+
// ignore
|
|
419
|
+
}
|
|
420
|
+
onClose(callback) {
|
|
421
|
+
// ignore
|
|
422
|
+
}
|
|
423
|
+
onMessage(callback) {
|
|
424
|
+
this._rawIpc.addEventListener('message', callback);
|
|
425
|
+
this._rawIpc.start();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
const wrap$2 = port => {
|
|
429
|
+
return new IpcChildWithMessagePort(port);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
const IpcChildWithMessagePort$1 = {
|
|
386
433
|
__proto__: null,
|
|
387
434
|
listen,
|
|
388
435
|
signal,
|
|
@@ -603,4 +650,4 @@ const IpcParentWithWebSocket$1 = {
|
|
|
603
650
|
wrap
|
|
604
651
|
};
|
|
605
652
|
|
|
606
|
-
export { IpcChildWithModuleWorker$1 as IpcChildWithModuleWorker, IpcChildWithModuleWorkerAndMessagePort$1 as IpcChildWithModuleWorkerAndMessagePort, IpcChildWithWindow$1 as IpcChildWithWindow, IpcParentWithModuleWorker$1 as IpcParentWithModuleWorker, IpcParentWithWebSocket$1 as IpcParentWithWebSocket };
|
|
653
|
+
export { IpcChildWithMessagePort$1 as IpcChildWithMessagePort, 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
|
@@ -379,6 +379,9 @@ const listen$5 = async () => {
|
|
|
379
379
|
return globalThis;
|
|
380
380
|
};
|
|
381
381
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
382
|
+
constructor(port) {
|
|
383
|
+
super(port);
|
|
384
|
+
}
|
|
382
385
|
getData(event) {
|
|
383
386
|
return getData$1(event);
|
|
384
387
|
}
|
|
@@ -398,6 +401,7 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
398
401
|
}
|
|
399
402
|
onMessage(callback) {
|
|
400
403
|
this._rawIpc.addEventListener('message', callback);
|
|
404
|
+
this._rawIpc.start();
|
|
401
405
|
}
|
|
402
406
|
}
|
|
403
407
|
const wrap$8 = port => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/ipc",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Inter Process Communication for Lvce Editor",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@lvce-editor/assert": "^1.2.0",
|
|
18
|
-
"@lvce-editor/verror": "^1.
|
|
18
|
+
"@lvce-editor/verror": "^1.3.0",
|
|
19
19
|
"@lvce-editor/web-socket-server": "^1.2.0"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|