@lvce-editor/test-worker 3.3.0 → 3.5.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.
@@ -95,27 +95,6 @@ const string = value => {
95
95
  }
96
96
  };
97
97
 
98
- const walkValue = (value, transferrables, isTransferrable) => {
99
- if (!value) {
100
- return;
101
- }
102
- if (isTransferrable(value)) {
103
- transferrables.push(value);
104
- return;
105
- }
106
- if (Array.isArray(value)) {
107
- for (const item of value) {
108
- walkValue(item, transferrables, isTransferrable);
109
- }
110
- return;
111
- }
112
- if (typeof value === 'object') {
113
- for (const property of Object.values(value)) {
114
- walkValue(property, transferrables, isTransferrable);
115
- }
116
- return;
117
- }
118
- };
119
98
  const isMessagePort = value => {
120
99
  return value && value instanceof MessagePort;
121
100
  };
@@ -140,6 +119,27 @@ const isTransferrable = value => {
140
119
  }
141
120
  return false;
142
121
  };
122
+ const walkValue = (value, transferrables, isTransferrable) => {
123
+ if (!value) {
124
+ return;
125
+ }
126
+ if (isTransferrable(value)) {
127
+ transferrables.push(value);
128
+ return;
129
+ }
130
+ if (Array.isArray(value)) {
131
+ for (const item of value) {
132
+ walkValue(item, transferrables, isTransferrable);
133
+ }
134
+ return;
135
+ }
136
+ if (typeof value === 'object') {
137
+ for (const property of Object.values(value)) {
138
+ walkValue(property, transferrables, isTransferrable);
139
+ }
140
+ return;
141
+ }
142
+ };
143
143
  const getTransferrables = value => {
144
144
  const transferrables = [];
145
145
  walkValue(value, transferrables, isTransferrable);
@@ -172,30 +172,35 @@ const NewLine$1 = '\n';
172
172
  const joinLines$1 = lines => {
173
173
  return lines.join(NewLine$1);
174
174
  };
175
- const splitLines$1 = lines => {
176
- return lines.split(NewLine$1);
177
- };
178
- const isModuleNotFoundMessage = line => {
179
- return line.includes('[ERR_MODULE_NOT_FOUND]');
175
+ const RE_AT = /^\s+at/;
176
+ const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
177
+ const isNormalStackLine = line => {
178
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
180
179
  };
181
- const getModuleNotFoundError = stderr => {
182
- const lines = splitLines$1(stderr);
183
- const messageIndex = lines.findIndex(isModuleNotFoundMessage);
184
- const message = lines[messageIndex];
180
+ const getDetails = lines => {
181
+ const index = lines.findIndex(isNormalStackLine);
182
+ if (index === -1) {
183
+ return {
184
+ actualMessage: joinLines$1(lines),
185
+ rest: []
186
+ };
187
+ }
188
+ let lastIndex = index - 1;
189
+ while (++lastIndex < lines.length) {
190
+ if (!isNormalStackLine(lines[lastIndex])) {
191
+ break;
192
+ }
193
+ }
185
194
  return {
186
- message,
187
- code: ERR_MODULE_NOT_FOUND
195
+ actualMessage: lines[index - 1],
196
+ rest: lines.slice(index, lastIndex)
188
197
  };
189
198
  };
190
- const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
191
- const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
199
+ const splitLines$1 = lines => {
200
+ return lines.split(NewLine$1);
201
+ };
192
202
  const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
193
203
  const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
194
- const RE_AT = /^\s+at/;
195
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
196
- const isUnhelpfulNativeModuleError = stderr => {
197
- return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
198
- };
199
204
  const isMessageCodeBlockStartIndex = line => {
200
205
  return RE_MESSAGE_CODE_BLOCK_START.test(line);
201
206
  };
@@ -210,51 +215,46 @@ const getMessageCodeBlock = stderr => {
210
215
  const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
211
216
  return relevantMessage;
212
217
  };
213
- const getNativeModuleErrorMessage = stderr => {
214
- const message = getMessageCodeBlock(stderr);
218
+ const isModuleNotFoundMessage = line => {
219
+ return line.includes('[ERR_MODULE_NOT_FOUND]');
220
+ };
221
+ const getModuleNotFoundError = stderr => {
222
+ const lines = splitLines$1(stderr);
223
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage);
224
+ const message = lines[messageIndex];
215
225
  return {
216
- message: `Incompatible native node module: ${message}`,
217
- code: E_INCOMPATIBLE_NATIVE_MODULE
226
+ message,
227
+ code: ERR_MODULE_NOT_FOUND
218
228
  };
219
229
  };
220
- const isModulesSyntaxError = stderr => {
230
+ const isModuleNotFoundError = stderr => {
221
231
  if (!stderr) {
222
232
  return false;
223
233
  }
224
- return stderr.includes('SyntaxError: Cannot use import statement outside a module');
225
- };
226
- const getModuleSyntaxError = () => {
227
- return {
228
- message: `ES Modules are not supported in electron`,
229
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
230
- };
234
+ return stderr.includes('ERR_MODULE_NOT_FOUND');
231
235
  };
232
- const isModuleNotFoundError = stderr => {
236
+ const isModulesSyntaxError = stderr => {
233
237
  if (!stderr) {
234
238
  return false;
235
239
  }
236
- return stderr.includes('ERR_MODULE_NOT_FOUND');
240
+ return stderr.includes('SyntaxError: Cannot use import statement outside a module');
237
241
  };
238
- const isNormalStackLine = line => {
239
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
242
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
243
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
244
+ const isUnhelpfulNativeModuleError = stderr => {
245
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
240
246
  };
241
- const getDetails = lines => {
242
- const index = lines.findIndex(isNormalStackLine);
243
- if (index === -1) {
244
- return {
245
- actualMessage: joinLines$1(lines),
246
- rest: []
247
- };
248
- }
249
- let lastIndex = index - 1;
250
- while (++lastIndex < lines.length) {
251
- if (!isNormalStackLine(lines[lastIndex])) {
252
- break;
253
- }
254
- }
247
+ const getNativeModuleErrorMessage = stderr => {
248
+ const message = getMessageCodeBlock(stderr);
255
249
  return {
256
- actualMessage: lines[index - 1],
257
- rest: lines.slice(index, lastIndex)
250
+ message: `Incompatible native node module: ${message}`,
251
+ code: E_INCOMPATIBLE_NATIVE_MODULE
252
+ };
253
+ };
254
+ const getModuleSyntaxError = () => {
255
+ return {
256
+ message: `ES Modules are not supported in electron`,
257
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
258
258
  };
259
259
  };
260
260
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -273,7 +273,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
273
273
  rest
274
274
  } = getDetails(lines);
275
275
  return {
276
- message: `${actualMessage}`,
276
+ message: actualMessage,
277
277
  code: '',
278
278
  stack: rest
279
279
  };
@@ -315,7 +315,7 @@ const listen$7 = () => {
315
315
  }
316
316
  return globalThis;
317
317
  };
318
- const signal$7 = global => {
318
+ const signal$8 = global => {
319
319
  global.postMessage(readyMessage);
320
320
  };
321
321
  class IpcChildWithModuleWorker extends Ipc {
@@ -341,7 +341,7 @@ class IpcChildWithModuleWorker extends Ipc {
341
341
  this._rawIpc.addEventListener('message', callback);
342
342
  }
343
343
  }
344
- const wrap$e = global => {
344
+ const wrap$f = global => {
345
345
  return new IpcChildWithModuleWorker(global);
346
346
  };
347
347
  const withResolvers = () => {
@@ -350,6 +350,7 @@ const withResolvers = () => {
350
350
  _resolve = resolve;
351
351
  });
352
352
  return {
353
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
353
354
  resolve: _resolve,
354
355
  promise
355
356
  };
@@ -368,8 +369,8 @@ const waitForFirstMessage = async port => {
368
369
  };
369
370
  const listen$6 = async () => {
370
371
  const parentIpcRaw = listen$7();
371
- signal$7(parentIpcRaw);
372
- const parentIpc = wrap$e(parentIpcRaw);
372
+ signal$8(parentIpcRaw);
373
+ const parentIpc = wrap$f(parentIpcRaw);
373
374
  const firstMessage = await waitForFirstMessage(parentIpc);
374
375
  if (firstMessage.method !== 'initialize') {
375
376
  throw new IpcError('unexpected first message');
@@ -388,9 +389,6 @@ const listen$6 = async () => {
388
389
  return globalThis;
389
390
  };
390
391
  class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
391
- constructor(port) {
392
- super(port);
393
- }
394
392
  getData(event) {
395
393
  return getData$2(event);
396
394
  }
@@ -414,13 +412,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
414
412
  this._rawIpc.start();
415
413
  }
416
414
  }
417
- const wrap$d = port => {
415
+ const wrap$e = port => {
418
416
  return new IpcChildWithModuleWorkerAndMessagePort(port);
419
417
  };
420
418
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
421
419
  __proto__: null,
422
420
  listen: listen$6,
423
- wrap: wrap$d
421
+ wrap: wrap$e
424
422
  };
425
423
 
426
424
  const Two = '2.0';
@@ -786,6 +784,8 @@ const execute$3 = (command, ...args) => {
786
784
 
787
785
  const createRpc = ipc => {
788
786
  const rpc = {
787
+ // @ts-ignore
788
+ ipc,
789
789
  /**
790
790
  * @deprecated
791
791
  */
@@ -812,7 +812,8 @@ const logError$1 = () => {
812
812
  };
813
813
  const handleMessage = event => {
814
814
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
815
- return handleJsonRpcMessage(event.target, event.data, execute$3, resolve, preparePrettyError$1, logError$1, actualRequiresSocket);
815
+ const actualExecute = event?.target?.execute || execute$3;
816
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError$1, logError$1, actualRequiresSocket);
816
817
  };
817
818
  const handleIpc = ipc => {
818
819
  if ('addEventListener' in ipc) {
@@ -1851,8 +1852,22 @@ const TestFrameWorkComponentQuickPick = {
1851
1852
  setValue: setValue$1
1852
1853
  };
1853
1854
 
1855
+ const Script = 2;
1856
+
1854
1857
  const setValue = async value => {
1855
- await invoke('Search.handleInput', value);
1858
+ await invoke('Search.handleInput', value, Script);
1859
+ };
1860
+ const setReplaceValue = async value => {
1861
+ await invoke('Search.handleReplaceInput', value, Script);
1862
+ };
1863
+ const setExcludeValue = async value => {
1864
+ await invoke('Search.handleExcludeInput', value, Script);
1865
+ };
1866
+ const replaceAll = async () => {
1867
+ await invoke('Search.replaceAll');
1868
+ };
1869
+ const setIncludeValue = async value => {
1870
+ await invoke('Search.handleIncludeInput', value, Script);
1856
1871
  };
1857
1872
  const clearSearchResults = async () => {
1858
1873
  await invoke('Search.clearSearchResults');
@@ -1878,6 +1893,9 @@ const focusPreviousPage = async () => {
1878
1893
  const focusPrevious$1 = async () => {
1879
1894
  await invoke('Search.focusPrevious');
1880
1895
  };
1896
+ const toggleSearchDetails = async () => {
1897
+ await invoke('Search.toggleSearchDetails');
1898
+ };
1881
1899
  const toggleMatchCase = async () => {
1882
1900
  await invoke('Search.toggleMatchCase');
1883
1901
  };
@@ -1890,6 +1908,9 @@ const togglePreserveCase = async () => {
1890
1908
  const toggleUseRegularExpression = async () => {
1891
1909
  await invoke('Search.toggleUseRegularExpression');
1892
1910
  };
1911
+ const toggleReplace = async () => {
1912
+ await invoke('Search.toggleReplace');
1913
+ };
1893
1914
 
1894
1915
  const TestFrameWorkComponentSearch = {
1895
1916
  __proto__: null,
@@ -1901,10 +1922,16 @@ const TestFrameWorkComponentSearch = {
1901
1922
  focusNextPage,
1902
1923
  focusPrevious: focusPrevious$1,
1903
1924
  focusPreviousPage,
1925
+ replaceAll,
1926
+ setExcludeValue,
1927
+ setIncludeValue,
1928
+ setReplaceValue,
1904
1929
  setValue,
1905
1930
  toggleMatchCase,
1906
1931
  toggleMatchWholeWord,
1907
1932
  togglePreserveCase,
1933
+ toggleReplace,
1934
+ toggleSearchDetails,
1908
1935
  toggleUseRegularExpression
1909
1936
  };
1910
1937
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",