@lvce-editor/test-worker 9.6.0 → 9.7.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 +65 -11
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -1113,8 +1113,43 @@ const createLazyRpc = rpcId => {
|
|
|
1113
1113
|
};
|
|
1114
1114
|
};
|
|
1115
1115
|
|
|
1116
|
+
const execute$1 = async (id, ...args) => {
|
|
1117
|
+
// @ts-ignore
|
|
1118
|
+
return invoke$1(id, ...args);
|
|
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);
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1116
1151
|
const handleFileWatcherEvent = async event => {
|
|
1117
|
-
|
|
1152
|
+
await hotReloadTest();
|
|
1118
1153
|
};
|
|
1119
1154
|
|
|
1120
1155
|
// @ts-nocheck
|
|
@@ -1709,16 +1744,6 @@ const ClipBoard = {
|
|
|
1709
1744
|
writeNativeFiles
|
|
1710
1745
|
};
|
|
1711
1746
|
|
|
1712
|
-
const execute$1 = async (id, ...args) => {
|
|
1713
|
-
// @ts-ignore
|
|
1714
|
-
return invoke$1(id, ...args);
|
|
1715
|
-
};
|
|
1716
|
-
|
|
1717
|
-
const Command = {
|
|
1718
|
-
__proto__: null,
|
|
1719
|
-
execute: execute$1
|
|
1720
|
-
};
|
|
1721
|
-
|
|
1722
1747
|
const selectItem$1 = async text => {
|
|
1723
1748
|
await invoke$1('Menu.selectItem', text);
|
|
1724
1749
|
};
|
|
@@ -3882,6 +3907,10 @@ const executeTest = async (name, fn, globals = {}) => {
|
|
|
3882
3907
|
await invoke$1('TestFrameWork.showOverlay', type, background, text);
|
|
3883
3908
|
};
|
|
3884
3909
|
|
|
3910
|
+
const hotReloadEnabled = () => {
|
|
3911
|
+
return false;
|
|
3912
|
+
};
|
|
3913
|
+
|
|
3885
3914
|
const importScript = async url => {
|
|
3886
3915
|
try {
|
|
3887
3916
|
return await import(url);
|
|
@@ -3901,6 +3930,24 @@ const importTest = async url => {
|
|
|
3901
3930
|
}
|
|
3902
3931
|
};
|
|
3903
3932
|
|
|
3933
|
+
const getFileUri = href => {
|
|
3934
|
+
const rest = href.slice('/remote'.length);
|
|
3935
|
+
const fileUrl = `file://${rest}`;
|
|
3936
|
+
return fileUrl;
|
|
3937
|
+
};
|
|
3938
|
+
const watchForHotReload = async (platform, href) => {
|
|
3939
|
+
if (platform !== Remote) {
|
|
3940
|
+
return;
|
|
3941
|
+
}
|
|
3942
|
+
if (!href.startsWith('/remote')) {
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
const fileUrl = getFileUri(href);
|
|
3946
|
+
const callbackCommand = 'FileWatcher.handleEvent';
|
|
3947
|
+
// @ts-ignore
|
|
3948
|
+
await invoke$1('FileWatcher.watchFile', TestWorker, callbackCommand, fileUrl);
|
|
3949
|
+
};
|
|
3950
|
+
|
|
3904
3951
|
// TODO move this into three steps:
|
|
3905
3952
|
// 1. import test module
|
|
3906
3953
|
// 2. execute test
|
|
@@ -3935,6 +3982,13 @@ const execute = async (href, platform, assetDir) => {
|
|
|
3935
3982
|
// 4. run the test
|
|
3936
3983
|
// 5. if test fails, display error message
|
|
3937
3984
|
// 6. if test succeeds, display success message
|
|
3985
|
+
|
|
3986
|
+
// TODO maybe setup file watcher earlier, to not miss events?
|
|
3987
|
+
try {
|
|
3988
|
+
if (hotReloadEnabled()) ;
|
|
3989
|
+
} catch {
|
|
3990
|
+
// ignore
|
|
3991
|
+
}
|
|
3938
3992
|
};
|
|
3939
3993
|
|
|
3940
3994
|
const commandMap = {
|