@lvce-editor/test-worker 9.5.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 +70 -11
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -1113,6 +1113,45 @@ 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
|
+
|
|
1151
|
+
const handleFileWatcherEvent = async event => {
|
|
1152
|
+
await hotReloadTest();
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1116
1155
|
// @ts-nocheck
|
|
1117
1156
|
|
|
1118
1157
|
const getPlatform = () => {
|
|
@@ -1705,16 +1744,6 @@ const ClipBoard = {
|
|
|
1705
1744
|
writeNativeFiles
|
|
1706
1745
|
};
|
|
1707
1746
|
|
|
1708
|
-
const execute$1 = async (id, ...args) => {
|
|
1709
|
-
// @ts-ignore
|
|
1710
|
-
return invoke$1(id, ...args);
|
|
1711
|
-
};
|
|
1712
|
-
|
|
1713
|
-
const Command = {
|
|
1714
|
-
__proto__: null,
|
|
1715
|
-
execute: execute$1
|
|
1716
|
-
};
|
|
1717
|
-
|
|
1718
1747
|
const selectItem$1 = async text => {
|
|
1719
1748
|
await invoke$1('Menu.selectItem', text);
|
|
1720
1749
|
};
|
|
@@ -3878,6 +3907,10 @@ const executeTest = async (name, fn, globals = {}) => {
|
|
|
3878
3907
|
await invoke$1('TestFrameWork.showOverlay', type, background, text);
|
|
3879
3908
|
};
|
|
3880
3909
|
|
|
3910
|
+
const hotReloadEnabled = () => {
|
|
3911
|
+
return false;
|
|
3912
|
+
};
|
|
3913
|
+
|
|
3881
3914
|
const importScript = async url => {
|
|
3882
3915
|
try {
|
|
3883
3916
|
return await import(url);
|
|
@@ -3897,6 +3930,24 @@ const importTest = async url => {
|
|
|
3897
3930
|
}
|
|
3898
3931
|
};
|
|
3899
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
|
+
|
|
3900
3951
|
// TODO move this into three steps:
|
|
3901
3952
|
// 1. import test module
|
|
3902
3953
|
// 2. execute test
|
|
@@ -3931,11 +3982,19 @@ const execute = async (href, platform, assetDir) => {
|
|
|
3931
3982
|
// 4. run the test
|
|
3932
3983
|
// 5. if test fails, display error message
|
|
3933
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
|
+
}
|
|
3934
3992
|
};
|
|
3935
3993
|
|
|
3936
3994
|
const commandMap = {
|
|
3937
3995
|
'Test.execute': execute,
|
|
3938
|
-
'Test.executeMock': executeMock
|
|
3996
|
+
'Test.executeMock': executeMock,
|
|
3997
|
+
'FileWatcher.handleEvent': handleFileWatcherEvent
|
|
3939
3998
|
};
|
|
3940
3999
|
|
|
3941
4000
|
const send = async port => {
|