@lvce-editor/test-worker 3.19.0 → 3.20.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 -17
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -430,10 +430,10 @@ const create$4 = (method, params) => {
|
|
|
430
430
|
};
|
|
431
431
|
};
|
|
432
432
|
const callbacks = Object.create(null);
|
|
433
|
-
const set$
|
|
433
|
+
const set$2 = (id, fn) => {
|
|
434
434
|
callbacks[id] = fn;
|
|
435
435
|
};
|
|
436
|
-
const get$
|
|
436
|
+
const get$2 = id => {
|
|
437
437
|
return callbacks[id];
|
|
438
438
|
};
|
|
439
439
|
const remove = id => {
|
|
@@ -449,7 +449,7 @@ const registerPromise = () => {
|
|
|
449
449
|
resolve,
|
|
450
450
|
promise
|
|
451
451
|
} = Promise.withResolvers();
|
|
452
|
-
set$
|
|
452
|
+
set$2(id, resolve);
|
|
453
453
|
return {
|
|
454
454
|
id,
|
|
455
455
|
promise
|
|
@@ -606,7 +606,7 @@ const warn = (...args) => {
|
|
|
606
606
|
console.warn(...args);
|
|
607
607
|
};
|
|
608
608
|
const resolve = (id, response) => {
|
|
609
|
-
const fn = get$
|
|
609
|
+
const fn = get$2(id);
|
|
610
610
|
if (!fn) {
|
|
611
611
|
console.log(response);
|
|
612
612
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -849,19 +849,19 @@ const WebWorkerRpcClient = {
|
|
|
849
849
|
const RendererWorker = 1;
|
|
850
850
|
|
|
851
851
|
const rpcs = Object.create(null);
|
|
852
|
-
const set = (id, rpc) => {
|
|
852
|
+
const set$1 = (id, rpc) => {
|
|
853
853
|
rpcs[id] = rpc;
|
|
854
854
|
};
|
|
855
|
-
const get = id => {
|
|
855
|
+
const get$1 = id => {
|
|
856
856
|
return rpcs[id];
|
|
857
857
|
};
|
|
858
858
|
|
|
859
859
|
const invoke = (method, ...params) => {
|
|
860
|
-
const rpc = get(RendererWorker);
|
|
860
|
+
const rpc = get$1(RendererWorker);
|
|
861
861
|
return rpc.invoke(method, ...params);
|
|
862
862
|
};
|
|
863
863
|
const invokeAndTransfer = (method, ...params) => {
|
|
864
|
-
const rpc = get(RendererWorker);
|
|
864
|
+
const rpc = get$1(RendererWorker);
|
|
865
865
|
return rpc.invokeAndTransfer(method, ...params);
|
|
866
866
|
};
|
|
867
867
|
|
|
@@ -959,6 +959,21 @@ const importTest = async url => {
|
|
|
959
959
|
}
|
|
960
960
|
};
|
|
961
961
|
|
|
962
|
+
const webViews = Object.create(null);
|
|
963
|
+
const set = (id, webView) => {
|
|
964
|
+
webViews[id] = webView;
|
|
965
|
+
};
|
|
966
|
+
const get = id => {
|
|
967
|
+
return webViews[id];
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
const getLocatorRpc = locator => {
|
|
971
|
+
if (locator.webViewId) {
|
|
972
|
+
return get(locator.webViewId);
|
|
973
|
+
}
|
|
974
|
+
return Rpc;
|
|
975
|
+
};
|
|
976
|
+
|
|
962
977
|
// @ts-nocheck
|
|
963
978
|
|
|
964
979
|
const Assert = {
|
|
@@ -976,7 +991,7 @@ const Assert = {
|
|
|
976
991
|
const expect$1 = locator => {
|
|
977
992
|
const {
|
|
978
993
|
invoke
|
|
979
|
-
} = locator
|
|
994
|
+
} = getLocatorRpc(locator);
|
|
980
995
|
return {
|
|
981
996
|
async checkSingleElementCondition(fnName, options) {
|
|
982
997
|
Assert.string(fnName);
|
|
@@ -1121,10 +1136,8 @@ const Locator = function (selector, {
|
|
|
1121
1136
|
this._hasText = hasText;
|
|
1122
1137
|
};
|
|
1123
1138
|
const performAction = async (locator, action, options) => {
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1126
|
-
} = locator.webView || Rpc;
|
|
1127
|
-
return invoke('TestFrameWork.performAction', locator, action, options);
|
|
1139
|
+
const rpc = getLocatorRpc(locator);
|
|
1140
|
+
return rpc.invoke('TestFrameWork.performAction', locator, action, options);
|
|
1128
1141
|
};
|
|
1129
1142
|
Locator.prototype.click = async function ({
|
|
1130
1143
|
button = 'left'
|
|
@@ -2281,13 +2294,13 @@ const fromId = async webViewId => {
|
|
|
2281
2294
|
return invoke$1(ipc, method, ...params);
|
|
2282
2295
|
}
|
|
2283
2296
|
};
|
|
2297
|
+
set(webViewId, webViewRpc);
|
|
2284
2298
|
return {
|
|
2285
2299
|
locator(selector, options) {
|
|
2286
2300
|
const baseLocator = create(selector, options);
|
|
2287
|
-
baseLocator.
|
|
2301
|
+
baseLocator.webViewId = webViewId;
|
|
2288
2302
|
return baseLocator;
|
|
2289
|
-
}
|
|
2290
|
-
expect: expect$1
|
|
2303
|
+
}
|
|
2291
2304
|
};
|
|
2292
2305
|
};
|
|
2293
2306
|
|
|
@@ -2379,7 +2392,7 @@ const listen = async () => {
|
|
|
2379
2392
|
const rpc = await WebWorkerRpcClient.create({
|
|
2380
2393
|
commandMap: commandMap
|
|
2381
2394
|
});
|
|
2382
|
-
set(RendererWorker, rpc);
|
|
2395
|
+
set$1(RendererWorker, rpc);
|
|
2383
2396
|
};
|
|
2384
2397
|
|
|
2385
2398
|
const main = async () => {
|