@lvce-editor/test-worker 9.7.0 → 9.9.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 +81 -42
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -64,7 +64,7 @@ const Object$1 = 1;
|
|
|
64
64
|
const Number$1 = 2;
|
|
65
65
|
const Array$1 = 3;
|
|
66
66
|
const String = 4;
|
|
67
|
-
const Boolean = 5;
|
|
67
|
+
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
70
70
|
const Unknown = 8;
|
|
@@ -85,7 +85,7 @@ const getType = value => {
|
|
|
85
85
|
}
|
|
86
86
|
return Object$1;
|
|
87
87
|
case 'boolean':
|
|
88
|
-
return Boolean;
|
|
88
|
+
return Boolean$1;
|
|
89
89
|
default:
|
|
90
90
|
return Unknown;
|
|
91
91
|
}
|
|
@@ -1087,6 +1087,9 @@ const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
|
1087
1087
|
// @ts-ignore
|
|
1088
1088
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1089
1089
|
};
|
|
1090
|
+
const getPreference = async key => {
|
|
1091
|
+
return await invoke$1('Preferences.get', key);
|
|
1092
|
+
};
|
|
1090
1093
|
|
|
1091
1094
|
const createLazyRpc = rpcId => {
|
|
1092
1095
|
let rpcPromise;
|
|
@@ -1113,43 +1116,16 @@ const createLazyRpc = rpcId => {
|
|
|
1113
1116
|
};
|
|
1114
1117
|
};
|
|
1115
1118
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
const Command = {
|
|
1122
|
-
__proto__: null,
|
|
1123
|
-
execute: execute$1
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
|
-
let items = [];
|
|
1127
|
-
const hasItems = () => {
|
|
1128
|
-
return items.length > 0;
|
|
1129
|
-
};
|
|
1130
|
-
const last = () => {
|
|
1131
|
-
const item = items.at(-1);
|
|
1132
|
-
if (!item) {
|
|
1133
|
-
throw new Error(`no item found`);
|
|
1134
|
-
}
|
|
1135
|
-
return item;
|
|
1136
|
-
};
|
|
1137
|
-
|
|
1138
|
-
const hotReloadTest = async () => {
|
|
1139
|
-
if (!hasItems()) {
|
|
1140
|
-
return;
|
|
1141
|
-
}
|
|
1142
|
-
const last$1 = last();
|
|
1143
|
-
const {
|
|
1144
|
-
platform,
|
|
1145
|
-
url,
|
|
1146
|
-
assetDir
|
|
1147
|
-
} = last$1;
|
|
1148
|
-
await execute$1(url, platform, assetDir);
|
|
1119
|
+
/* eslint-disable no-console */
|
|
1120
|
+
const clearConsole = () => {
|
|
1121
|
+
console.clear();
|
|
1149
1122
|
};
|
|
1150
1123
|
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1124
|
+
const createUrlWithQueryParameter = url => {
|
|
1125
|
+
const parsedUrl = new URL(url, location.href);
|
|
1126
|
+
parsedUrl.searchParams.set('time', `${Date.now()}`);
|
|
1127
|
+
const string = parsedUrl.toString();
|
|
1128
|
+
return string;
|
|
1153
1129
|
};
|
|
1154
1130
|
|
|
1155
1131
|
// @ts-nocheck
|
|
@@ -1744,6 +1720,16 @@ const ClipBoard = {
|
|
|
1744
1720
|
writeNativeFiles
|
|
1745
1721
|
};
|
|
1746
1722
|
|
|
1723
|
+
const execute$1 = async (id, ...args) => {
|
|
1724
|
+
// @ts-ignore
|
|
1725
|
+
return invoke$1(id, ...args);
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
const Command = {
|
|
1729
|
+
__proto__: null,
|
|
1730
|
+
execute: execute$1
|
|
1731
|
+
};
|
|
1732
|
+
|
|
1747
1733
|
const selectItem$1 = async text => {
|
|
1748
1734
|
await invoke$1('Menu.selectItem', text);
|
|
1749
1735
|
};
|
|
@@ -2239,7 +2225,6 @@ const EditorSourceAction = {
|
|
|
2239
2225
|
selectIndex: selectIndex$5
|
|
2240
2226
|
};
|
|
2241
2227
|
|
|
2242
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2243
2228
|
const openContextMenu = async index => {
|
|
2244
2229
|
// @ts-ignore
|
|
2245
2230
|
await invoke$1('Explorer.handleContextMenuKeyboard', index);
|
|
@@ -2618,7 +2603,6 @@ const stringifyJson = data => {
|
|
|
2618
2603
|
return JSON.stringify(data, null, 2) + '\n';
|
|
2619
2604
|
};
|
|
2620
2605
|
|
|
2621
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2622
2606
|
const writeFile = async (uri, content) => {
|
|
2623
2607
|
await invoke$1('FileSystem.writeFile', uri, content);
|
|
2624
2608
|
};
|
|
@@ -3907,8 +3891,9 @@ const executeTest = async (name, fn, globals = {}) => {
|
|
|
3907
3891
|
await invoke$1('TestFrameWork.showOverlay', type, background, text);
|
|
3908
3892
|
};
|
|
3909
3893
|
|
|
3910
|
-
const hotReloadEnabled = () => {
|
|
3911
|
-
|
|
3894
|
+
const hotReloadEnabled = async () => {
|
|
3895
|
+
const preference = await getPreference('E2eTest.hotReload');
|
|
3896
|
+
return Boolean(preference);
|
|
3912
3897
|
};
|
|
3913
3898
|
|
|
3914
3899
|
const importScript = async url => {
|
|
@@ -3930,6 +3915,21 @@ const importTest = async url => {
|
|
|
3930
3915
|
}
|
|
3931
3916
|
};
|
|
3932
3917
|
|
|
3918
|
+
let items = [];
|
|
3919
|
+
const hasItems = () => {
|
|
3920
|
+
return items.length > 0;
|
|
3921
|
+
};
|
|
3922
|
+
const push = item => {
|
|
3923
|
+
items = [...items, item];
|
|
3924
|
+
};
|
|
3925
|
+
const last = () => {
|
|
3926
|
+
const item = items.at(-1);
|
|
3927
|
+
if (!item) {
|
|
3928
|
+
throw new Error(`no item found`);
|
|
3929
|
+
}
|
|
3930
|
+
return item;
|
|
3931
|
+
};
|
|
3932
|
+
|
|
3933
3933
|
const getFileUri = href => {
|
|
3934
3934
|
const rest = href.slice('/remote'.length);
|
|
3935
3935
|
const fileUrl = `file://${rest}`;
|
|
@@ -3953,6 +3953,12 @@ const watchForHotReload = async (platform, href) => {
|
|
|
3953
3953
|
// 2. execute test
|
|
3954
3954
|
// 3. print out results
|
|
3955
3955
|
const execute = async (href, platform, assetDir) => {
|
|
3956
|
+
push({
|
|
3957
|
+
url: href,
|
|
3958
|
+
assetDir,
|
|
3959
|
+
platform,
|
|
3960
|
+
inProgress: true
|
|
3961
|
+
});
|
|
3956
3962
|
const globals = createApi(platform, assetDir);
|
|
3957
3963
|
// TODO
|
|
3958
3964
|
// 0. wait for page to be ready
|
|
@@ -3984,13 +3990,46 @@ const execute = async (href, platform, assetDir) => {
|
|
|
3984
3990
|
// 6. if test succeeds, display success message
|
|
3985
3991
|
|
|
3986
3992
|
// TODO maybe setup file watcher earlier, to not miss events?
|
|
3993
|
+
|
|
3994
|
+
push({
|
|
3995
|
+
url: href,
|
|
3996
|
+
assetDir,
|
|
3997
|
+
platform,
|
|
3998
|
+
inProgress: false
|
|
3999
|
+
});
|
|
4000
|
+
// TODO if file watcher was previously added, don't need to add one
|
|
3987
4001
|
try {
|
|
3988
|
-
if (hotReloadEnabled())
|
|
4002
|
+
if (await hotReloadEnabled()) {
|
|
4003
|
+
await watchForHotReload(platform, href);
|
|
4004
|
+
}
|
|
3989
4005
|
} catch {
|
|
3990
4006
|
// ignore
|
|
3991
4007
|
}
|
|
3992
4008
|
};
|
|
3993
4009
|
|
|
4010
|
+
const hotReloadTest = async () => {
|
|
4011
|
+
if (!hasItems()) {
|
|
4012
|
+
return;
|
|
4013
|
+
}
|
|
4014
|
+
const last$1 = last();
|
|
4015
|
+
const {
|
|
4016
|
+
platform,
|
|
4017
|
+
url,
|
|
4018
|
+
assetDir,
|
|
4019
|
+
inProgress
|
|
4020
|
+
} = last$1;
|
|
4021
|
+
if (inProgress) {
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4024
|
+
const withQueryParameter = createUrlWithQueryParameter(url);
|
|
4025
|
+
clearConsole();
|
|
4026
|
+
await execute(withQueryParameter, platform, assetDir);
|
|
4027
|
+
};
|
|
4028
|
+
|
|
4029
|
+
const handleFileWatcherEvent = async event => {
|
|
4030
|
+
await hotReloadTest();
|
|
4031
|
+
};
|
|
4032
|
+
|
|
3994
4033
|
const commandMap = {
|
|
3995
4034
|
'Test.execute': execute,
|
|
3996
4035
|
'Test.executeMock': executeMock,
|