@lvce-editor/test-worker 11.8.0 → 11.10.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 +70 -52
- package/package.json +2 -2
package/dist/testWorkerMain.js
CHANGED
|
@@ -456,7 +456,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
456
456
|
return promise;
|
|
457
457
|
};
|
|
458
458
|
const Message$1 = 3;
|
|
459
|
-
const create$5 = async ({
|
|
459
|
+
const create$5$1 = async ({
|
|
460
460
|
isMessagePortOpen,
|
|
461
461
|
messagePort
|
|
462
462
|
}) => {
|
|
@@ -507,7 +507,7 @@ const wrap$5 = messagePort => {
|
|
|
507
507
|
};
|
|
508
508
|
const IpcParentWithMessagePort$1 = {
|
|
509
509
|
__proto__: null,
|
|
510
|
-
create: create$5,
|
|
510
|
+
create: create$5$1,
|
|
511
511
|
signal: signal$1,
|
|
512
512
|
wrap: wrap$5
|
|
513
513
|
};
|
|
@@ -713,7 +713,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
713
713
|
}
|
|
714
714
|
};
|
|
715
715
|
};
|
|
716
|
-
const create$1
|
|
716
|
+
const create$1 = (id, error) => {
|
|
717
717
|
return {
|
|
718
718
|
jsonrpc: Two$1,
|
|
719
719
|
id,
|
|
@@ -724,9 +724,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
724
724
|
const prettyError = preparePrettyError(error);
|
|
725
725
|
logError(error, prettyError);
|
|
726
726
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
727
|
-
return create$1
|
|
727
|
+
return create$1(id, errorProperty);
|
|
728
728
|
};
|
|
729
|
-
const create$
|
|
729
|
+
const create$4 = (message, result) => {
|
|
730
730
|
return {
|
|
731
731
|
jsonrpc: Two$1,
|
|
732
732
|
id: message.id,
|
|
@@ -735,7 +735,7 @@ const create$3 = (message, result) => {
|
|
|
735
735
|
};
|
|
736
736
|
const getSuccessResponse = (message, result) => {
|
|
737
737
|
const resultProperty = result ?? null;
|
|
738
|
-
return create$
|
|
738
|
+
return create$4(message, resultProperty);
|
|
739
739
|
};
|
|
740
740
|
const getErrorResponseSimple = (id, error) => {
|
|
741
741
|
return {
|
|
@@ -849,14 +849,14 @@ const execute$2 = (command, ...args) => {
|
|
|
849
849
|
};
|
|
850
850
|
|
|
851
851
|
const Two = '2.0';
|
|
852
|
-
const create$
|
|
852
|
+
const create$t = (method, params) => {
|
|
853
853
|
return {
|
|
854
854
|
jsonrpc: Two,
|
|
855
855
|
method,
|
|
856
856
|
params
|
|
857
857
|
};
|
|
858
858
|
};
|
|
859
|
-
const create$
|
|
859
|
+
const create$s = (id, method, params) => {
|
|
860
860
|
const message = {
|
|
861
861
|
id,
|
|
862
862
|
jsonrpc: Two,
|
|
@@ -866,14 +866,14 @@ const create$r = (id, method, params) => {
|
|
|
866
866
|
return message;
|
|
867
867
|
};
|
|
868
868
|
let id = 0;
|
|
869
|
-
const create$
|
|
869
|
+
const create$r = () => {
|
|
870
870
|
return ++id;
|
|
871
871
|
};
|
|
872
872
|
|
|
873
873
|
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
874
874
|
|
|
875
875
|
const registerPromise = map => {
|
|
876
|
-
const id = create$
|
|
876
|
+
const id = create$r();
|
|
877
877
|
const {
|
|
878
878
|
promise,
|
|
879
879
|
resolve
|
|
@@ -891,7 +891,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
891
891
|
id,
|
|
892
892
|
promise
|
|
893
893
|
} = registerPromise(callbacks);
|
|
894
|
-
const message = create$
|
|
894
|
+
const message = create$s(id, method, params);
|
|
895
895
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
896
896
|
ipc.sendAndTransfer(message);
|
|
897
897
|
} else {
|
|
@@ -927,7 +927,7 @@ const createRpc = ipc => {
|
|
|
927
927
|
* @deprecated
|
|
928
928
|
*/
|
|
929
929
|
send(method, ...params) {
|
|
930
|
-
const message = create$
|
|
930
|
+
const message = create$t(method, params);
|
|
931
931
|
ipc.send(message);
|
|
932
932
|
}
|
|
933
933
|
};
|
|
@@ -993,13 +993,13 @@ const createSharedLazyRpc = factory => {
|
|
|
993
993
|
}
|
|
994
994
|
};
|
|
995
995
|
};
|
|
996
|
-
const create$
|
|
996
|
+
const create$j = async ({
|
|
997
997
|
commandMap,
|
|
998
998
|
isMessagePortOpen,
|
|
999
999
|
send
|
|
1000
1000
|
}) => {
|
|
1001
1001
|
return createSharedLazyRpc(() => {
|
|
1002
|
-
return create$
|
|
1002
|
+
return create$3({
|
|
1003
1003
|
commandMap,
|
|
1004
1004
|
isMessagePortOpen,
|
|
1005
1005
|
send
|
|
@@ -1008,9 +1008,9 @@ const create$i = async ({
|
|
|
1008
1008
|
};
|
|
1009
1009
|
const LazyTransferMessagePortRpcParent = {
|
|
1010
1010
|
__proto__: null,
|
|
1011
|
-
create: create$
|
|
1011
|
+
create: create$j
|
|
1012
1012
|
};
|
|
1013
|
-
const create$
|
|
1013
|
+
const create$e = async ({
|
|
1014
1014
|
commandMap,
|
|
1015
1015
|
isMessagePortOpen,
|
|
1016
1016
|
messagePort
|
|
@@ -1028,9 +1028,9 @@ const create$d = async ({
|
|
|
1028
1028
|
};
|
|
1029
1029
|
const MessagePortRpcParent = {
|
|
1030
1030
|
__proto__: null,
|
|
1031
|
-
create: create$
|
|
1031
|
+
create: create$e
|
|
1032
1032
|
};
|
|
1033
|
-
const create$
|
|
1033
|
+
const create$5 = async ({
|
|
1034
1034
|
commandMap,
|
|
1035
1035
|
isMessagePortOpen = true,
|
|
1036
1036
|
messagePort
|
|
@@ -1047,7 +1047,7 @@ const create$4 = async ({
|
|
|
1047
1047
|
messagePort.start();
|
|
1048
1048
|
return rpc;
|
|
1049
1049
|
};
|
|
1050
|
-
const create$
|
|
1050
|
+
const create$3 = async ({
|
|
1051
1051
|
commandMap,
|
|
1052
1052
|
isMessagePortOpen,
|
|
1053
1053
|
send
|
|
@@ -1057,13 +1057,13 @@ const create$2 = async ({
|
|
|
1057
1057
|
port2
|
|
1058
1058
|
} = new MessageChannel();
|
|
1059
1059
|
await send(port1);
|
|
1060
|
-
return create$
|
|
1060
|
+
return create$5({
|
|
1061
1061
|
commandMap,
|
|
1062
1062
|
isMessagePortOpen,
|
|
1063
1063
|
messagePort: port2
|
|
1064
1064
|
});
|
|
1065
1065
|
};
|
|
1066
|
-
const create$
|
|
1066
|
+
const create$2 = async ({
|
|
1067
1067
|
commandMap
|
|
1068
1068
|
}) => {
|
|
1069
1069
|
// TODO create a commandMap per rpc instance
|
|
@@ -1075,7 +1075,7 @@ const create$1 = async ({
|
|
|
1075
1075
|
};
|
|
1076
1076
|
const WebWorkerRpcClient = {
|
|
1077
1077
|
__proto__: null,
|
|
1078
|
-
create: create$
|
|
1078
|
+
create: create$2
|
|
1079
1079
|
};
|
|
1080
1080
|
const createMockRpc = ({
|
|
1081
1081
|
commandMap
|
|
@@ -1189,18 +1189,6 @@ const initializeEditorWorker = async () => {
|
|
|
1189
1189
|
set$2(rpc);
|
|
1190
1190
|
};
|
|
1191
1191
|
|
|
1192
|
-
/* eslint-disable no-console */
|
|
1193
|
-
const clearConsole = () => {
|
|
1194
|
-
console.clear();
|
|
1195
|
-
};
|
|
1196
|
-
|
|
1197
|
-
const createUrlWithQueryParameter = (url, locationHref, time) => {
|
|
1198
|
-
const parsedUrl = new URL(url, locationHref);
|
|
1199
|
-
parsedUrl.searchParams.set('time', `${time}`);
|
|
1200
|
-
const string = parsedUrl.toString();
|
|
1201
|
-
return string;
|
|
1202
|
-
};
|
|
1203
|
-
|
|
1204
1192
|
class AssertionError extends Error {
|
|
1205
1193
|
constructor(message) {
|
|
1206
1194
|
super(message);
|
|
@@ -3964,18 +3952,11 @@ const importTest = async url => {
|
|
|
3964
3952
|
};
|
|
3965
3953
|
|
|
3966
3954
|
let items = [];
|
|
3967
|
-
const hasItems = () => {
|
|
3968
|
-
return items.length > 0;
|
|
3969
|
-
};
|
|
3970
3955
|
const push = item => {
|
|
3971
3956
|
items = [...items, item];
|
|
3972
3957
|
};
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3975
|
-
if (!item) {
|
|
3976
|
-
throw new Error(`no item found`);
|
|
3977
|
-
}
|
|
3978
|
-
return item;
|
|
3958
|
+
const maybeLast = () => {
|
|
3959
|
+
return items.at(-1);
|
|
3979
3960
|
};
|
|
3980
3961
|
|
|
3981
3962
|
const getFileUri = href => {
|
|
@@ -4043,29 +4024,66 @@ const execute = async (href, platform, assetDir) => {
|
|
|
4043
4024
|
}
|
|
4044
4025
|
};
|
|
4045
4026
|
|
|
4046
|
-
const
|
|
4047
|
-
|
|
4048
|
-
|
|
4027
|
+
const doHotReload = async (url, platform, assetDir) => {
|
|
4028
|
+
// eslint-disable-next-line no-console
|
|
4029
|
+
console.clear();
|
|
4030
|
+
await execute(url, platform, assetDir);
|
|
4031
|
+
};
|
|
4032
|
+
|
|
4033
|
+
const createUrlWithQueryParameter = (url, locationHref, time) => {
|
|
4034
|
+
const parsedUrl = new URL(url, locationHref);
|
|
4035
|
+
parsedUrl.searchParams.set('time', `${time}`);
|
|
4036
|
+
const string = parsedUrl.toString();
|
|
4037
|
+
return string;
|
|
4038
|
+
};
|
|
4039
|
+
|
|
4040
|
+
const emptyHotReloadArgs = {
|
|
4041
|
+
assetDir: '',
|
|
4042
|
+
platform: 0,
|
|
4043
|
+
shouldHotReload: false,
|
|
4044
|
+
url: ''
|
|
4045
|
+
};
|
|
4046
|
+
|
|
4047
|
+
const getHotReloadArgs = (latestItem, locationHref, time) => {
|
|
4048
|
+
if (!latestItem) {
|
|
4049
|
+
return emptyHotReloadArgs;
|
|
4049
4050
|
}
|
|
4050
|
-
const last$1 = last();
|
|
4051
4051
|
const {
|
|
4052
4052
|
assetDir,
|
|
4053
4053
|
inProgress,
|
|
4054
4054
|
platform,
|
|
4055
4055
|
url
|
|
4056
|
-
} =
|
|
4056
|
+
} = latestItem;
|
|
4057
4057
|
if (inProgress) {
|
|
4058
|
-
return;
|
|
4058
|
+
return emptyHotReloadArgs;
|
|
4059
4059
|
}
|
|
4060
4060
|
const withQueryParameter = createUrlWithQueryParameter(url, locationHref, time);
|
|
4061
|
-
|
|
4062
|
-
|
|
4061
|
+
return {
|
|
4062
|
+
assetDir,
|
|
4063
|
+
platform,
|
|
4064
|
+
shouldHotReload: true,
|
|
4065
|
+
url: withQueryParameter
|
|
4066
|
+
};
|
|
4067
|
+
};
|
|
4068
|
+
|
|
4069
|
+
const hotReloadTest = async (lastItem, locationHref, time) => {
|
|
4070
|
+
const {
|
|
4071
|
+
assetDir,
|
|
4072
|
+
platform,
|
|
4073
|
+
shouldHotReload,
|
|
4074
|
+
url
|
|
4075
|
+
} = getHotReloadArgs(lastItem, locationHref, time);
|
|
4076
|
+
if (!shouldHotReload) {
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
await doHotReload(url, platform, assetDir);
|
|
4063
4080
|
};
|
|
4064
4081
|
|
|
4065
4082
|
const handleFileWatcherEvent = async event => {
|
|
4066
4083
|
const locationHref = location.href;
|
|
4067
4084
|
const time = Date.now();
|
|
4068
|
-
|
|
4085
|
+
const lastItem = maybeLast();
|
|
4086
|
+
await hotReloadTest(lastItem, locationHref, time);
|
|
4069
4087
|
};
|
|
4070
4088
|
|
|
4071
4089
|
const commandMap = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-worker",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.10.0",
|
|
4
4
|
"description": "Test Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/testWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@lvce-editor/constants": "^
|
|
14
|
+
"@lvce-editor/constants": "^3.0.0"
|
|
15
15
|
},
|
|
16
16
|
"types": "dist/api.d.ts"
|
|
17
17
|
}
|