@lvce-editor/file-search-worker 3.2.0 → 3.3.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.
@@ -54,27 +54,6 @@ class VError extends Error {
54
54
  }
55
55
  }
56
56
 
57
- const walkValue = (value, transferrables, isTransferrable) => {
58
- if (!value) {
59
- return;
60
- }
61
- if (isTransferrable(value)) {
62
- transferrables.push(value);
63
- return;
64
- }
65
- if (Array.isArray(value)) {
66
- for (const item of value) {
67
- walkValue(item, transferrables, isTransferrable);
68
- }
69
- return;
70
- }
71
- if (typeof value === 'object') {
72
- for (const property of Object.values(value)) {
73
- walkValue(property, transferrables, isTransferrable);
74
- }
75
- return;
76
- }
77
- };
78
57
  const isMessagePort = value => {
79
58
  return value && value instanceof MessagePort;
80
59
  };
@@ -99,6 +78,27 @@ const isTransferrable = value => {
99
78
  }
100
79
  return false;
101
80
  };
81
+ const walkValue = (value, transferrables, isTransferrable) => {
82
+ if (!value) {
83
+ return;
84
+ }
85
+ if (isTransferrable(value)) {
86
+ transferrables.push(value);
87
+ return;
88
+ }
89
+ if (Array.isArray(value)) {
90
+ for (const item of value) {
91
+ walkValue(item, transferrables, isTransferrable);
92
+ }
93
+ return;
94
+ }
95
+ if (typeof value === 'object') {
96
+ for (const property of Object.values(value)) {
97
+ walkValue(property, transferrables, isTransferrable);
98
+ }
99
+ return;
100
+ }
101
+ };
102
102
  const getTransferrables = value => {
103
103
  const transferrables = [];
104
104
  walkValue(value, transferrables, isTransferrable);
@@ -128,9 +128,6 @@ const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
128
128
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
129
129
  const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
130
130
  const NewLine$1 = '\n';
131
- const joinLines$1 = lines => {
132
- return lines.join(NewLine$1);
133
- };
134
131
  const splitLines$2 = lines => {
135
132
  return lines.split(NewLine$1);
136
133
  };
@@ -146,6 +143,9 @@ const getModuleNotFoundError = stderr => {
146
143
  code: ERR_MODULE_NOT_FOUND
147
144
  };
148
145
  };
146
+ const joinLines$1 = lines => {
147
+ return lines.join(NewLine$1);
148
+ };
149
149
  const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
150
150
  const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
151
151
  const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
@@ -232,7 +232,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
232
232
  rest
233
233
  } = getDetails(lines);
234
234
  return {
235
- message: `${actualMessage}`,
235
+ message: actualMessage,
236
236
  code: '',
237
237
  stack: rest
238
238
  };
@@ -267,14 +267,14 @@ const readyMessage = 'ready';
267
267
  const getData$2 = event => {
268
268
  return event.data;
269
269
  };
270
- const listen$6 = () => {
270
+ const listen$7 = () => {
271
271
  // @ts-ignore
272
272
  if (typeof WorkerGlobalScope === 'undefined') {
273
273
  throw new TypeError('module is not in web worker scope');
274
274
  }
275
275
  return globalThis;
276
276
  };
277
- const signal$6 = global => {
277
+ const signal$7 = global => {
278
278
  global.postMessage(readyMessage);
279
279
  };
280
280
  class IpcChildWithModuleWorker extends Ipc {
@@ -300,7 +300,7 @@ class IpcChildWithModuleWorker extends Ipc {
300
300
  this._rawIpc.addEventListener('message', callback);
301
301
  }
302
302
  }
303
- const wrap$d = global => {
303
+ const wrap$e = global => {
304
304
  return new IpcChildWithModuleWorker(global);
305
305
  };
306
306
  const withResolvers = () => {
@@ -309,6 +309,7 @@ const withResolvers = () => {
309
309
  _resolve = resolve;
310
310
  });
311
311
  return {
312
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
312
313
  resolve: _resolve,
313
314
  promise
314
315
  };
@@ -325,10 +326,10 @@ const waitForFirstMessage = async port => {
325
326
  // @ts-ignore
326
327
  return event.data;
327
328
  };
328
- const listen$5 = async () => {
329
- const parentIpcRaw = listen$6();
330
- signal$6(parentIpcRaw);
331
- const parentIpc = wrap$d(parentIpcRaw);
329
+ const listen$6 = async () => {
330
+ const parentIpcRaw = listen$7();
331
+ signal$7(parentIpcRaw);
332
+ const parentIpc = wrap$e(parentIpcRaw);
332
333
  const firstMessage = await waitForFirstMessage(parentIpc);
333
334
  if (firstMessage.method !== 'initialize') {
334
335
  throw new IpcError('unexpected first message');
@@ -347,9 +348,6 @@ const listen$5 = async () => {
347
348
  return globalThis;
348
349
  };
349
350
  class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
350
- constructor(port) {
351
- super(port);
352
- }
353
351
  getData(event) {
354
352
  return getData$2(event);
355
353
  }
@@ -373,13 +371,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
373
371
  this._rawIpc.start();
374
372
  }
375
373
  }
376
- const wrap$c = port => {
374
+ const wrap$d = port => {
377
375
  return new IpcChildWithModuleWorkerAndMessagePort(port);
378
376
  };
379
377
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
380
378
  __proto__: null,
381
- listen: listen$5,
382
- wrap: wrap$c
379
+ listen: listen$6,
380
+ wrap: wrap$d
383
381
  };
384
382
 
385
383
  const Two = '2.0';
@@ -404,9 +402,6 @@ let id = 0;
404
402
  const create$3 = () => {
405
403
  return ++id;
406
404
  };
407
- const warn$1 = (...args) => {
408
- console.warn(...args);
409
- };
410
405
  const registerPromise = () => {
411
406
  const id = create$3();
412
407
  const {
@@ -419,16 +414,6 @@ const registerPromise = () => {
419
414
  promise
420
415
  };
421
416
  };
422
- const resolve = (id, response) => {
423
- const fn = get(id);
424
- if (!fn) {
425
- console.log(response);
426
- warn$1(`callback ${id} may already be disposed`);
427
- return;
428
- }
429
- fn(response);
430
- remove$2(id);
431
- };
432
417
  const create$2 = (method, params) => {
433
418
  const {
434
419
  id,
@@ -576,6 +561,19 @@ const unwrapJsonRpcResult = responseMessage => {
576
561
  }
577
562
  throw new JsonRpcError('unexpected response message');
578
563
  };
564
+ const warn$1 = (...args) => {
565
+ console.warn(...args);
566
+ };
567
+ const resolve = (id, response) => {
568
+ const fn = get(id);
569
+ if (!fn) {
570
+ console.log(response);
571
+ warn$1(`callback ${id} may already be disposed`);
572
+ return;
573
+ }
574
+ fn(response);
575
+ remove$2(id);
576
+ };
579
577
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
580
578
  const getErrorType = prettyError => {
581
579
  if (prettyError && prettyError.type) {
@@ -811,6 +809,19 @@ const File$2 = 7;
811
809
 
812
810
  const fileMapUrl = `${assetDir}/config/fileMap.json`;
813
811
 
812
+ const getBlob$2 = async url => {
813
+ try {
814
+ const response = await fetch(url);
815
+ if (!response.ok) {
816
+ throw new Error(response.statusText);
817
+ }
818
+ const text = await response.blob();
819
+ return text;
820
+ } catch (error) {
821
+ throw new VError(error, `Failed to request blob for ${url}`);
822
+ }
823
+ };
824
+
814
825
  const getJson = async url => {
815
826
  try {
816
827
  const response = await fetch(url);
@@ -885,9 +896,9 @@ const readDirWithFileTypes$1 = async uri => {
885
896
  const chmod$1 = () => {
886
897
  throw new Error('[memfs] chmod not implemented');
887
898
  };
888
- const getBlob$1 = async uri => {
889
- const content = await readFile$1(uri);
890
- const blob = new Blob([content]);
899
+ const getBlob$1 = async (uri, type) => {
900
+ const fetchUri = `${assetDir}${uri}`;
901
+ const blob = getBlob$2(fetchUri);
891
902
  return blob;
892
903
  };
893
904
 
@@ -1055,16 +1066,16 @@ const readDirWithFileTypes = uri => {
1055
1066
  }
1056
1067
  return dirents;
1057
1068
  };
1058
- const getBlob = uri => {
1069
+ const getBlob = (uri, type) => {
1059
1070
  const content = readFile(uri);
1060
- const contentType = getContentType(uri);
1071
+ const contentType = type || getContentType(uri);
1061
1072
  const blob = new Blob([content], {
1062
1073
  type: contentType
1063
1074
  });
1064
1075
  return blob;
1065
1076
  };
1066
- const getBlobUrl = uri => {
1067
- const blob = getBlob(uri);
1077
+ const getBlobUrl = (uri, type) => {
1078
+ const blob = getBlob(uri, type);
1068
1079
  const url = URL.createObjectURL(blob);
1069
1080
  return url;
1070
1081
  };
@@ -1654,50 +1665,6 @@ const QuickPickEntriesCustom = {
1654
1665
  state: state$3
1655
1666
  };
1656
1667
 
1657
- const name$7 = 'noop';
1658
- const getPlaceholder$8 = () => {
1659
- return '';
1660
- };
1661
- const getHelpEntries$7 = () => {
1662
- return [];
1663
- };
1664
- const getNoResults$7 = () => {
1665
- return noResults();
1666
- };
1667
- const getPicks$8 = async value => {
1668
- return [];
1669
- };
1670
- const selectPick$8 = async item => {
1671
- return {
1672
- command: Hide
1673
- };
1674
- };
1675
- const getFilterValue$7 = value => {
1676
- return value;
1677
- };
1678
- const getPickFilterValue$3 = pick => {
1679
- return pick;
1680
- };
1681
-
1682
- const QuickPickNoop = {
1683
- __proto__: null,
1684
- getFilterValue: getFilterValue$7,
1685
- getHelpEntries: getHelpEntries$7,
1686
- getNoResults: getNoResults$7,
1687
- getPickFilterValue: getPickFilterValue$3,
1688
- getPicks: getPicks$8,
1689
- getPlaceholder: getPlaceholder$8,
1690
- name: name$7,
1691
- selectPick: selectPick$8
1692
- };
1693
-
1694
- const Command = '>';
1695
- const Symbol$1 = '@';
1696
- const WorkspaceSymbol = '#';
1697
- const GoToLine = ':';
1698
- const View = 'view ';
1699
- const None = '';
1700
-
1701
1668
  const handleError = async (error, notify = true, prefix = '') => {
1702
1669
  console.error(error);
1703
1670
  };
@@ -1713,8 +1680,8 @@ const getAll = () => {
1713
1680
  return state$2.menuEntries;
1714
1681
  };
1715
1682
 
1716
- const name$6 = 'command';
1717
- const getPlaceholder$7 = () => {
1683
+ const name$7 = 'command';
1684
+ const getPlaceholder$8 = () => {
1718
1685
  return typeNameofCommandToRun();
1719
1686
  };
1720
1687
  const helpEntries = () => {
@@ -1726,7 +1693,7 @@ const helpEntries = () => {
1726
1693
  const getLabel$2 = () => {
1727
1694
  return '';
1728
1695
  };
1729
- const getNoResults$6 = () => {
1696
+ const getNoResults$7 = () => {
1730
1697
  return {
1731
1698
  label: noMatchingResults()
1732
1699
  };
@@ -1767,7 +1734,7 @@ const getExtensionPicks = async () => {
1767
1734
 
1768
1735
  // TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
1769
1736
 
1770
- const getPicks$7 = async () => {
1737
+ const getPicks$8 = async () => {
1771
1738
  const builtinPicks = await getBuiltinPicks();
1772
1739
  const extensionPicks = await getExtensionPicks();
1773
1740
  return [...builtinPicks, ...extensionPicks];
@@ -1804,16 +1771,16 @@ const selectPickExtension = async item => {
1804
1771
  command: Hide
1805
1772
  };
1806
1773
  };
1807
- const selectPick$7 = async item => {
1774
+ const selectPick$8 = async item => {
1808
1775
  if (item.id.startsWith('ext.')) {
1809
1776
  return selectPickExtension(item);
1810
1777
  }
1811
1778
  return selectPickBuiltin(item);
1812
1779
  };
1813
- const getFilterValue$6 = value => {
1780
+ const getFilterValue$7 = value => {
1814
1781
  return value;
1815
1782
  };
1816
- const getPickFilterValue$2 = pick => {
1783
+ const getPickFilterValue$3 = pick => {
1817
1784
  return pick.label;
1818
1785
  };
1819
1786
  const getPickLabel$2 = pick => {
@@ -1825,17 +1792,17 @@ const getPickIcon$2 = () => {
1825
1792
 
1826
1793
  const QuickPickEntriesCommand = {
1827
1794
  __proto__: null,
1828
- getFilterValue: getFilterValue$6,
1795
+ getFilterValue: getFilterValue$7,
1829
1796
  getLabel: getLabel$2,
1830
- getNoResults: getNoResults$6,
1831
- getPickFilterValue: getPickFilterValue$2,
1797
+ getNoResults: getNoResults$7,
1798
+ getPickFilterValue: getPickFilterValue$3,
1832
1799
  getPickIcon: getPickIcon$2,
1833
1800
  getPickLabel: getPickLabel$2,
1834
- getPicks: getPicks$7,
1835
- getPlaceholder: getPlaceholder$7,
1801
+ getPicks: getPicks$8,
1802
+ getPlaceholder: getPlaceholder$8,
1836
1803
  helpEntries,
1837
- name: name$6,
1838
- selectPick: selectPick$7
1804
+ name: name$7,
1805
+ selectPick: selectPick$8
1839
1806
  };
1840
1807
 
1841
1808
  const execute = async (method, ...params) => {
@@ -1948,7 +1915,7 @@ function promisifyRequest(request) {
1948
1915
  request.addEventListener('success', success);
1949
1916
  request.addEventListener('error', error);
1950
1917
  });
1951
- // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
1918
+ // This mapping exists in reverseTransformCache but doesn't exist in transformCache. This
1952
1919
  // is because we create many promises from a single IDBRequest.
1953
1920
  reverseTransformCache.set(promise, request);
1954
1921
  return promise;
@@ -2315,8 +2282,8 @@ const searchFile = async (path, value, prepare, assetDir) => {
2315
2282
  return result;
2316
2283
  };
2317
2284
 
2318
- const name$5 = 'file';
2319
- const getPlaceholder$6 = () => {
2285
+ const name$6 = 'file';
2286
+ const getPlaceholder$7 = () => {
2320
2287
  return '';
2321
2288
  };
2322
2289
  const getLabel$1 = () => {
@@ -2324,23 +2291,23 @@ const getLabel$1 = () => {
2324
2291
  };
2325
2292
 
2326
2293
  // TODO help entries should not be here
2327
- const getHelpEntries$6 = () => {
2294
+ const getHelpEntries$7 = () => {
2328
2295
  return [{
2329
2296
  description: goToFile(),
2330
2297
  category: 'global commands'
2331
2298
  }];
2332
2299
  };
2333
- const getNoResults$5 = () => {
2300
+ const getNoResults$6 = () => {
2334
2301
  return {
2335
2302
  label: noMatchingResults()
2336
2303
  };
2337
2304
  };
2338
- const getPicks$6 = async searchValue => {
2305
+ const getPicks$7 = async searchValue => {
2339
2306
  {
2340
2307
  return [];
2341
2308
  }
2342
2309
  };
2343
- const selectPick$6 = async pick => {
2310
+ const selectPick$7 = async pick => {
2344
2311
  if (typeof pick === 'object') {
2345
2312
  pick = pick.pick;
2346
2313
  }
@@ -2351,10 +2318,10 @@ const selectPick$6 = async pick => {
2351
2318
  command: Hide
2352
2319
  };
2353
2320
  };
2354
- const getFilterValue$5 = value => {
2321
+ const getFilterValue$6 = value => {
2355
2322
  return value;
2356
2323
  };
2357
- const getPickFilterValue$1 = pick => {
2324
+ const getPickFilterValue$2 = pick => {
2358
2325
  if (typeof pick === 'object') {
2359
2326
  pick = pick.pick;
2360
2327
  }
@@ -2389,33 +2356,33 @@ const isPrepared$1 = () => {
2389
2356
 
2390
2357
  const QuickPickEntriesFile = {
2391
2358
  __proto__: null,
2392
- getFilterValue: getFilterValue$5,
2393
- getHelpEntries: getHelpEntries$6,
2359
+ getFilterValue: getFilterValue$6,
2360
+ getHelpEntries: getHelpEntries$7,
2394
2361
  getLabel: getLabel$1,
2395
- getNoResults: getNoResults$5,
2362
+ getNoResults: getNoResults$6,
2396
2363
  getPickDescription: getPickDescription$1,
2397
2364
  getPickFileIcon: getPickFileIcon$1,
2398
- getPickFilterValue: getPickFilterValue$1,
2365
+ getPickFilterValue: getPickFilterValue$2,
2399
2366
  getPickIcon: getPickIcon$1,
2400
2367
  getPickLabel: getPickLabel$1,
2401
- getPicks: getPicks$6,
2402
- getPlaceholder: getPlaceholder$6,
2368
+ getPicks: getPicks$7,
2369
+ getPlaceholder: getPlaceholder$7,
2403
2370
  isPrepared: isPrepared$1,
2404
- name: name$5,
2405
- selectPick: selectPick$6
2371
+ name: name$6,
2372
+ selectPick: selectPick$7
2406
2373
  };
2407
2374
 
2408
- const name$4 = 'goToLine';
2409
- const getPlaceholder$5 = () => {
2375
+ const name$5 = 'goToLine';
2376
+ const getPlaceholder$6 = () => {
2410
2377
  return '';
2411
2378
  };
2412
- const getHelpEntries$5 = () => {
2379
+ const getHelpEntries$6 = () => {
2413
2380
  return [];
2414
2381
  };
2415
- const getNoResults$4 = () => {
2382
+ const getNoResults$5 = () => {
2416
2383
  return undefined;
2417
2384
  };
2418
- const getPicks$5 = async () => {
2385
+ const getPicks$6 = async () => {
2419
2386
  const picks = [{
2420
2387
  label: '1'
2421
2388
  }, {
@@ -2431,7 +2398,7 @@ const getPicks$5 = async () => {
2431
2398
  }];
2432
2399
  return picks;
2433
2400
  };
2434
- const selectPick$5 = async item => {
2401
+ const selectPick$6 = async item => {
2435
2402
  const rowIndex = Number.parseInt(item.label);
2436
2403
  const position = {
2437
2404
  rowIndex,
@@ -2443,15 +2410,52 @@ const selectPick$5 = async item => {
2443
2410
  command: Hide
2444
2411
  };
2445
2412
  };
2446
- const getFilterValue$4 = value => {
2413
+ const getFilterValue$5 = value => {
2447
2414
  return value;
2448
2415
  };
2449
2416
 
2450
2417
  const QuickPickEntriesGoToLine = {
2418
+ __proto__: null,
2419
+ getFilterValue: getFilterValue$5,
2420
+ getHelpEntries: getHelpEntries$6,
2421
+ getNoResults: getNoResults$5,
2422
+ getPicks: getPicks$6,
2423
+ getPlaceholder: getPlaceholder$6,
2424
+ name: name$5,
2425
+ selectPick: selectPick$6
2426
+ };
2427
+
2428
+ const name$4 = 'noop';
2429
+ const getPlaceholder$5 = () => {
2430
+ return '';
2431
+ };
2432
+ const getHelpEntries$5 = () => {
2433
+ return [];
2434
+ };
2435
+ const getNoResults$4 = () => {
2436
+ return noResults();
2437
+ };
2438
+ const getPicks$5 = async value => {
2439
+ return [];
2440
+ };
2441
+ const selectPick$5 = async item => {
2442
+ return {
2443
+ command: Hide
2444
+ };
2445
+ };
2446
+ const getFilterValue$4 = value => {
2447
+ return value;
2448
+ };
2449
+ const getPickFilterValue$1 = pick => {
2450
+ return pick;
2451
+ };
2452
+
2453
+ const QuickPickNoop = {
2451
2454
  __proto__: null,
2452
2455
  getFilterValue: getFilterValue$4,
2453
2456
  getHelpEntries: getHelpEntries$5,
2454
2457
  getNoResults: getNoResults$4,
2458
+ getPickFilterValue: getPickFilterValue$1,
2455
2459
  getPicks: getPicks$5,
2456
2460
  getPlaceholder: getPlaceholder$5,
2457
2461
  name: name$4,
@@ -2563,6 +2567,13 @@ const QuickPickEntriesWorkspaceSymbol = {
2563
2567
  selectPick: selectPick$2
2564
2568
  };
2565
2569
 
2570
+ const Command = '>';
2571
+ const Symbol$1 = '@';
2572
+ const WorkspaceSymbol = '#';
2573
+ const GoToLine = ':';
2574
+ const View = 'view ';
2575
+ const None = '';
2576
+
2566
2577
  // TODO avoid global variable
2567
2578
 
2568
2579
  const state = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "main": "dist/fileSearchWorkerMain.js",
6
6
  "type": "module",