@lvce-editor/test-worker 9.7.0 → 9.8.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.
@@ -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,11 @@ const createLazyRpc = rpcId => {
1113
1116
  };
1114
1117
  };
1115
1118
 
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();
1119
+ const createUrlWithQueryParameter = url => {
1120
+ const parsedUrl = new URL(url, location.href);
1121
+ parsedUrl.searchParams.set('time', `${Date.now()}`);
1122
+ const string = parsedUrl.toString();
1123
+ return string;
1153
1124
  };
1154
1125
 
1155
1126
  // @ts-nocheck
@@ -1744,6 +1715,16 @@ const ClipBoard = {
1744
1715
  writeNativeFiles
1745
1716
  };
1746
1717
 
1718
+ const execute$1 = async (id, ...args) => {
1719
+ // @ts-ignore
1720
+ return invoke$1(id, ...args);
1721
+ };
1722
+
1723
+ const Command = {
1724
+ __proto__: null,
1725
+ execute: execute$1
1726
+ };
1727
+
1747
1728
  const selectItem$1 = async text => {
1748
1729
  await invoke$1('Menu.selectItem', text);
1749
1730
  };
@@ -3907,8 +3888,9 @@ const executeTest = async (name, fn, globals = {}) => {
3907
3888
  await invoke$1('TestFrameWork.showOverlay', type, background, text);
3908
3889
  };
3909
3890
 
3910
- const hotReloadEnabled = () => {
3911
- return false;
3891
+ const hotReloadEnabled = async () => {
3892
+ const preference = await getPreference('E2eTest.hotReload');
3893
+ return Boolean(preference);
3912
3894
  };
3913
3895
 
3914
3896
  const importScript = async url => {
@@ -3930,6 +3912,21 @@ const importTest = async url => {
3930
3912
  }
3931
3913
  };
3932
3914
 
3915
+ let items = [];
3916
+ const hasItems = () => {
3917
+ return items.length > 0;
3918
+ };
3919
+ const push = item => {
3920
+ items = [...items, item];
3921
+ };
3922
+ const last = () => {
3923
+ const item = items.at(-1);
3924
+ if (!item) {
3925
+ throw new Error(`no item found`);
3926
+ }
3927
+ return item;
3928
+ };
3929
+
3933
3930
  const getFileUri = href => {
3934
3931
  const rest = href.slice('/remote'.length);
3935
3932
  const fileUrl = `file://${rest}`;
@@ -3953,6 +3950,12 @@ const watchForHotReload = async (platform, href) => {
3953
3950
  // 2. execute test
3954
3951
  // 3. print out results
3955
3952
  const execute = async (href, platform, assetDir) => {
3953
+ push({
3954
+ url: href,
3955
+ assetDir,
3956
+ platform,
3957
+ inProgress: true
3958
+ });
3956
3959
  const globals = createApi(platform, assetDir);
3957
3960
  // TODO
3958
3961
  // 0. wait for page to be ready
@@ -3984,13 +3987,45 @@ const execute = async (href, platform, assetDir) => {
3984
3987
  // 6. if test succeeds, display success message
3985
3988
 
3986
3989
  // TODO maybe setup file watcher earlier, to not miss events?
3990
+
3991
+ push({
3992
+ url: href,
3993
+ assetDir,
3994
+ platform,
3995
+ inProgress: false
3996
+ });
3997
+ // TODO if file watcher was previously added, don't need to add one
3987
3998
  try {
3988
- if (hotReloadEnabled()) ;
3999
+ if (await hotReloadEnabled()) {
4000
+ await watchForHotReload(platform, href);
4001
+ }
3989
4002
  } catch {
3990
4003
  // ignore
3991
4004
  }
3992
4005
  };
3993
4006
 
4007
+ const hotReloadTest = async () => {
4008
+ if (!hasItems()) {
4009
+ return;
4010
+ }
4011
+ const last$1 = last();
4012
+ const {
4013
+ platform,
4014
+ url,
4015
+ assetDir,
4016
+ inProgress
4017
+ } = last$1;
4018
+ if (inProgress) {
4019
+ return;
4020
+ }
4021
+ const withQueryParameter = createUrlWithQueryParameter(url);
4022
+ await execute(withQueryParameter, platform, assetDir);
4023
+ };
4024
+
4025
+ const handleFileWatcherEvent = async event => {
4026
+ await hotReloadTest();
4027
+ };
4028
+
3994
4029
  const commandMap = {
3995
4030
  'Test.execute': execute,
3996
4031
  'Test.executeMock': executeMock,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "9.7.0",
3
+ "version": "9.8.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",