@lvce-editor/ipc 9.2.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 +60 -17
- package/package.json +1 -1
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');
|
|
@@ -336,20 +336,20 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
336
336
|
this._rawIpc.start();
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
const wrap$
|
|
339
|
+
const wrap$4 = port => {
|
|
340
340
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
341
341
|
};
|
|
342
342
|
|
|
343
343
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
344
344
|
__proto__: null,
|
|
345
|
-
listen: listen$
|
|
346
|
-
wrap: wrap$
|
|
345
|
+
listen: listen$2,
|
|
346
|
+
wrap: wrap$4
|
|
347
347
|
};
|
|
348
348
|
|
|
349
|
-
const listen = () => {
|
|
349
|
+
const listen$1 = () => {
|
|
350
350
|
return window;
|
|
351
351
|
};
|
|
352
|
-
const signal = global => {
|
|
352
|
+
const signal$1 = global => {
|
|
353
353
|
global.postMessage(readyMessage);
|
|
354
354
|
};
|
|
355
355
|
class IpcChildWithWindow extends Ipc {
|
|
@@ -382,11 +382,54 @@ class IpcChildWithWindow extends Ipc {
|
|
|
382
382
|
this._rawIpc.addEventListener('message', wrapped);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
const wrap$
|
|
385
|
+
const wrap$3 = window => {
|
|
386
386
|
return new IpcChildWithWindow(window);
|
|
387
387
|
};
|
|
388
388
|
|
|
389
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 = {
|
|
390
433
|
__proto__: null,
|
|
391
434
|
listen,
|
|
392
435
|
signal,
|
|
@@ -607,4 +650,4 @@ const IpcParentWithWebSocket$1 = {
|
|
|
607
650
|
wrap
|
|
608
651
|
};
|
|
609
652
|
|
|
610
|
-
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 };
|