@lvce-editor/test-worker 2.1.0 → 3.0.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/testWorkerMain.js +30 -29
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -308,14 +308,14 @@ const readyMessage = 'ready';
|
|
|
308
308
|
const getData$2 = event => {
|
|
309
309
|
return event.data;
|
|
310
310
|
};
|
|
311
|
-
const listen$
|
|
311
|
+
const listen$7 = () => {
|
|
312
312
|
// @ts-ignore
|
|
313
313
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
314
314
|
throw new TypeError('module is not in web worker scope');
|
|
315
315
|
}
|
|
316
316
|
return globalThis;
|
|
317
317
|
};
|
|
318
|
-
const signal$
|
|
318
|
+
const signal$7 = global => {
|
|
319
319
|
global.postMessage(readyMessage);
|
|
320
320
|
};
|
|
321
321
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -341,7 +341,7 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
341
341
|
this._rawIpc.addEventListener('message', callback);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
const wrap$
|
|
344
|
+
const wrap$e = global => {
|
|
345
345
|
return new IpcChildWithModuleWorker(global);
|
|
346
346
|
};
|
|
347
347
|
const withResolvers = () => {
|
|
@@ -366,10 +366,10 @@ const waitForFirstMessage = async port => {
|
|
|
366
366
|
// @ts-ignore
|
|
367
367
|
return event.data;
|
|
368
368
|
};
|
|
369
|
-
const listen$
|
|
370
|
-
const parentIpcRaw = listen$
|
|
371
|
-
signal$
|
|
372
|
-
const parentIpc = wrap$
|
|
369
|
+
const listen$6 = async () => {
|
|
370
|
+
const parentIpcRaw = listen$7();
|
|
371
|
+
signal$7(parentIpcRaw);
|
|
372
|
+
const parentIpc = wrap$e(parentIpcRaw);
|
|
373
373
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
374
374
|
if (firstMessage.method !== 'initialize') {
|
|
375
375
|
throw new IpcError('unexpected first message');
|
|
@@ -414,13 +414,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
414
414
|
this._rawIpc.start();
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
const wrap$
|
|
417
|
+
const wrap$d = port => {
|
|
418
418
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
419
419
|
};
|
|
420
420
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
421
421
|
__proto__: null,
|
|
422
|
-
listen: listen$
|
|
423
|
-
wrap: wrap$
|
|
422
|
+
listen: listen$6,
|
|
423
|
+
wrap: wrap$d
|
|
424
424
|
};
|
|
425
425
|
|
|
426
426
|
const Two = '2.0';
|
|
@@ -445,9 +445,6 @@ let id = 0;
|
|
|
445
445
|
const create$3 = () => {
|
|
446
446
|
return ++id;
|
|
447
447
|
};
|
|
448
|
-
const warn = (...args) => {
|
|
449
|
-
console.warn(...args);
|
|
450
|
-
};
|
|
451
448
|
const registerPromise = () => {
|
|
452
449
|
const id = create$3();
|
|
453
450
|
const {
|
|
@@ -460,16 +457,6 @@ const registerPromise = () => {
|
|
|
460
457
|
promise
|
|
461
458
|
};
|
|
462
459
|
};
|
|
463
|
-
const resolve = (id, response) => {
|
|
464
|
-
const fn = get(id);
|
|
465
|
-
if (!fn) {
|
|
466
|
-
console.log(response);
|
|
467
|
-
warn(`callback ${id} may already be disposed`);
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
fn(response);
|
|
471
|
-
remove(id);
|
|
472
|
-
};
|
|
473
460
|
const create$2 = (method, params) => {
|
|
474
461
|
const {
|
|
475
462
|
id,
|
|
@@ -617,6 +604,19 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
617
604
|
}
|
|
618
605
|
throw new JsonRpcError('unexpected response message');
|
|
619
606
|
};
|
|
607
|
+
const warn = (...args) => {
|
|
608
|
+
console.warn(...args);
|
|
609
|
+
};
|
|
610
|
+
const resolve = (id, response) => {
|
|
611
|
+
const fn = get(id);
|
|
612
|
+
if (!fn) {
|
|
613
|
+
console.log(response);
|
|
614
|
+
warn(`callback ${id} may already be disposed`);
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
fn(response);
|
|
618
|
+
remove(id);
|
|
619
|
+
};
|
|
620
620
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
621
621
|
const getErrorType = prettyError => {
|
|
622
622
|
if (prettyError && prettyError.type) {
|
|
@@ -2015,11 +2015,6 @@ const getPortTuple = () => {
|
|
|
2015
2015
|
};
|
|
2016
2016
|
};
|
|
2017
2017
|
|
|
2018
|
-
const sendPortToWebView = async (webviewId, port) => {
|
|
2019
|
-
await invokeAndTransfer('Transferrable.transferToRendererProcess', webviewId, port);
|
|
2020
|
-
console.log('did send port to renderer process');
|
|
2021
|
-
};
|
|
2022
|
-
|
|
2023
2018
|
const waitForFirstEventEvent = async port => {
|
|
2024
2019
|
const {
|
|
2025
2020
|
resolve,
|
|
@@ -2046,7 +2041,13 @@ const createPortIpc = async webViewId => {
|
|
|
2046
2041
|
port2
|
|
2047
2042
|
} = getPortTuple();
|
|
2048
2043
|
const firstEventPromise = waitForFirstEventEvent(port1);
|
|
2049
|
-
|
|
2044
|
+
// TODO ask extension host worker about webview uid
|
|
2045
|
+
|
|
2046
|
+
const info = await invoke('WebView.getWebViewInfo', webViewId);
|
|
2047
|
+
const portType = 'test';
|
|
2048
|
+
await invokeAndTransfer('WebView.setPort', info.uid, port2, info.origin, portType);
|
|
2049
|
+
|
|
2050
|
+
// await SendPortToWebView.sendPortToWebView(webViewId, port2)
|
|
2050
2051
|
const firstEvent = await firstEventPromise;
|
|
2051
2052
|
if (firstEvent.data !== 'ready') {
|
|
2052
2053
|
throw new Error('unexpected first message');
|