@lvce-editor/text-search-worker 4.11.0 → 4.13.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.
@@ -588,7 +588,7 @@ const create$4$1 = (method, params) => {
588
588
  };
589
589
  };
590
590
  const callbacks = Object.create(null);
591
- const set$2 = (id, fn) => {
591
+ const set$4 = (id, fn) => {
592
592
  callbacks[id] = fn;
593
593
  };
594
594
  const get$2 = id => {
@@ -607,7 +607,7 @@ const registerPromise = () => {
607
607
  resolve,
608
608
  promise
609
609
  } = Promise.withResolvers();
610
- set$2(id, resolve);
610
+ set$4(id, resolve);
611
611
  return {
612
612
  id,
613
613
  promise
@@ -951,7 +951,7 @@ const send = (transport, method, ...params) => {
951
951
  const message = create$4$1(method, params);
952
952
  transport.send(message);
953
953
  };
954
- const invoke$4 = (ipc, method, ...params) => {
954
+ const invoke$2 = (ipc, method, ...params) => {
955
955
  return invokeHelper(ipc, method, params, false);
956
956
  };
957
957
  const invokeAndTransfer$1 = (ipc, method, ...params) => {
@@ -984,7 +984,7 @@ const createRpc = ipc => {
984
984
  send(ipc, method, ...params);
985
985
  },
986
986
  invoke(method, ...params) {
987
- return invoke$4(ipc, method, ...params);
987
+ return invoke$2(ipc, method, ...params);
988
988
  },
989
989
  invokeAndTransfer(method, ...params) {
990
990
  return invokeAndTransfer$1(ipc, method, ...params);
@@ -1174,6 +1174,7 @@ const create$3 = rpcId => {
1174
1174
  };
1175
1175
  };
1176
1176
  const RendererWorker$1 = 1;
1177
+ const SearchProcess$1 = 77;
1177
1178
  const {
1178
1179
  invoke: invoke$3,
1179
1180
  invokeAndTransfer: invokeAndTransfer$3,
@@ -1184,12 +1185,17 @@ const RendererWorker = {
1184
1185
  invokeAndTransfer: invokeAndTransfer$3,
1185
1186
  set: set$3
1186
1187
  };
1188
+ const {
1189
+ set: set$2$1} = create$3(SearchProcess$1);
1190
+ const SearchProcess = {
1191
+ __proto__: null,
1192
+ set: set$2$1
1193
+ };
1187
1194
 
1188
1195
  const {
1189
- invoke: invoke$2,
1196
+ invoke: invoke$1,
1190
1197
  invokeAndTransfer,
1191
- set: set$1
1192
- } = RendererWorker;
1198
+ set: set$2} = RendererWorker;
1193
1199
 
1194
1200
  const copy = async state => {
1195
1201
  const {
@@ -1200,7 +1206,7 @@ const copy = async state => {
1200
1206
  return state;
1201
1207
  }
1202
1208
  const item = items[listFocusedIndex];
1203
- await invoke$2('ClipBoard.writeText', item.text);
1209
+ await invoke$1('ClipBoard.writeText', item.text);
1204
1210
  return state;
1205
1211
  };
1206
1212
 
@@ -1267,7 +1273,7 @@ const create$2 = () => {
1267
1273
 
1268
1274
  const {
1269
1275
  get,
1270
- set,
1276
+ set: set$1,
1271
1277
  wrapCommand
1272
1278
  } = create$2();
1273
1279
 
@@ -1344,7 +1350,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1344
1350
  incrementalSearch: false,
1345
1351
  searchId: ''
1346
1352
  };
1347
- set(uid, state, state);
1353
+ set$1(uid, state, state);
1348
1354
  return state;
1349
1355
  };
1350
1356
 
@@ -2001,7 +2007,7 @@ const handleUpdateError = async (state, update, error) => {
2001
2007
 
2002
2008
  const getFileIcon = async result => {
2003
2009
  if (result.type === File) {
2004
- return invoke$2('IconTheme.getFileIcon', {
2010
+ return invoke$1('IconTheme.getFileIcon', {
2005
2011
  name: result.text
2006
2012
  });
2007
2013
  }
@@ -2064,20 +2070,20 @@ const getScrollBarY$1 = getScrollBarOffset$1;
2064
2070
  const textSearch$6 = async (scheme, root, query) => {
2065
2071
  string(scheme);
2066
2072
  string(query);
2067
- const result = await invoke$2('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
2073
+ const result = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
2068
2074
  return result;
2069
2075
  };
2070
2076
 
2071
2077
  const textSearch$5 = async (scheme, root, query, options, assetDir) => {
2072
- return invoke$2('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
2078
+ return invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
2073
2079
  };
2074
2080
 
2075
2081
  const textSearch$4 = async (scheme, root, query) => {
2076
- return invoke$2('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
2082
+ return invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
2077
2083
  };
2078
2084
 
2079
2085
  const textSearch$3 = async (scheme, root, query, options, assetDir) => {
2080
- return invoke$2('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
2086
+ return invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
2081
2087
  };
2082
2088
 
2083
2089
  const getRipGrepArgs = ({
@@ -2149,11 +2155,6 @@ const getOrCreate$1 = () => {
2149
2155
  return state$1.rpc;
2150
2156
  };
2151
2157
 
2152
- const invoke$1 = async (method, ...params) => {
2153
- const rpc = await getOrCreate$1();
2154
- return rpc.invoke(method, ...params);
2155
- };
2156
-
2157
2158
  const getPortTuple = () => {
2158
2159
  const {
2159
2160
  port1,
@@ -2178,6 +2179,7 @@ const launchSearchProcessElectron = async () => {
2178
2179
  await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port1, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
2179
2180
  port2.start();
2180
2181
  const rpc = await rpcPromise;
2182
+ set(rpc);
2181
2183
  return rpc;
2182
2184
  };
2183
2185
 
@@ -2192,9 +2194,16 @@ const getOrCreate = () => {
2192
2194
  return state.rpc;
2193
2195
  };
2194
2196
 
2195
- const invoke = async (method, ...params) => {
2196
- const rpc = await getOrCreate();
2197
- return rpc.invoke(method, ...params);
2197
+ const {
2198
+ set} = SearchProcess;
2199
+ const lazyInvoke = async (platform, method, ...params) => {
2200
+ if (platform === Electron) {
2201
+ await getOrCreate();
2202
+ } else if (platform === Remote) {
2203
+ await getOrCreate$1();
2204
+ }
2205
+ // @ts-ignore
2206
+ return invoke(method, ...params);
2198
2207
  };
2199
2208
 
2200
2209
  const textSearch$2 = async (scheme, root, query, options, assetDir, platform) => {
@@ -2206,16 +2215,14 @@ const textSearch$2 = async (scheme, root, query, options, assetDir, platform) =>
2206
2215
  ripGrepArgs,
2207
2216
  searchDir: root
2208
2217
  };
2209
- if (platform === Remote) {
2210
- const result = await invoke$1('TextSearch.search', actualOptions);
2218
+ if (platform === Remote || platform === Electron) {
2219
+ // @ts-ignore
2220
+ const result = await lazyInvoke(platform, 'TextSearch.search', actualOptions);
2211
2221
  // TODO api is weird
2222
+ // @ts-ignore
2212
2223
  return result.results;
2213
2224
  }
2214
- if (platform === Electron) {
2215
- const result = await invoke('TextSearch.search', actualOptions);
2216
- return result.results;
2217
- }
2218
- const results = await invoke$2('SearchProcess.invoke', 'TextSearch.search', actualOptions);
2225
+ const results = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
2219
2226
  // TODO api is weird
2220
2227
  return results.results;
2221
2228
  };
@@ -2347,7 +2354,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
2347
2354
  searchDir: root,
2348
2355
  id: searchId
2349
2356
  };
2350
- const resultPromise = invoke$1('TextSearch.searchIncremental', actualOptions);
2357
+ const resultPromise = lazyInvoke(platform, 'TextSearch.searchIncremental', actualOptions);
2351
2358
  for (let i = 0; i < 100; i++) {
2352
2359
  const latest = get(uid);
2353
2360
  const {
@@ -2361,7 +2368,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
2361
2368
  } = newState;
2362
2369
  const listHeight = height - headerHeight;
2363
2370
  const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
2364
- const visible = await invoke$1('TextSearch.getIncrementalResults', searchId, minLineY, minLineY + numberOfVisible);
2371
+ const visible = await lazyInvoke(platform, 'TextSearch.getIncrementalResults', searchId, minLineY, minLineY + numberOfVisible);
2365
2372
  const latest2 = get(uid);
2366
2373
  if (!latest2 || latest2.newState.searchId !== searchId) {
2367
2374
  return;
@@ -2373,9 +2380,9 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
2373
2380
  minLineY: 0,
2374
2381
  maxLineY: visible.length
2375
2382
  };
2376
- set(uid, latest2.oldState, updatedState2);
2383
+ set$1(uid, latest2.oldState, updatedState2);
2377
2384
  // @ts-ignore
2378
- await invoke$2('Search.rerender');
2385
+ await invoke$1('Search.rerender');
2379
2386
  await waitForNextFrame();
2380
2387
  }
2381
2388
  await resultPromise;
@@ -2405,7 +2412,7 @@ const handleUpdateIncremental = async (state, update) => {
2405
2412
  ...partialNewState,
2406
2413
  searchId
2407
2414
  };
2408
- set(uid, latest1.oldState, updatedState1);
2415
+ set$1(uid, latest1.oldState, updatedState1);
2409
2416
 
2410
2417
  // TODO await promise?
2411
2418
  void textSearchIncremental(root, value, {
@@ -2517,7 +2524,7 @@ const noop = state => {
2517
2524
  };
2518
2525
 
2519
2526
  const applyBulkReplacement = async bulkEdits => {
2520
- await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
2527
+ await invoke$1('BulkReplacement.applyBulkReplacement', bulkEdits);
2521
2528
  };
2522
2529
 
2523
2530
  const getReplacedMessage = (fileCount, replaceCount, replacement) => {
@@ -2755,6 +2762,10 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
2755
2762
  return fn(state, value, inputSource);
2756
2763
  };
2757
2764
 
2765
+ const initialize = async platform => {
2766
+ // TODO
2767
+ };
2768
+
2758
2769
  // TODO optimize this function to return the minimum number
2759
2770
  // of visible items needed, e.g. when not scrolled 5 items with
2760
2771
  // 20px fill 100px but when scrolled 6 items are needed
@@ -3111,7 +3122,7 @@ const getFileIndex = (items, index) => {
3111
3122
  };
3112
3123
 
3113
3124
  const openUri = async (path, focus = true, props = {}) => {
3114
- await invoke$2(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
3125
+ await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
3115
3126
  };
3116
3127
 
3117
3128
  // TODO this should be in FileSystem module
@@ -4432,7 +4443,7 @@ const render2 = (uid, diffResult) => {
4432
4443
  oldState,
4433
4444
  newState
4434
4445
  } = get(uid);
4435
- set(uid, newState, newState);
4446
+ set$1(uid, newState, newState);
4436
4447
  const commands = applyRender(oldState, newState, diffResult);
4437
4448
  return commands;
4438
4449
  };
@@ -4599,7 +4610,7 @@ const renderIncremental = uid => {
4599
4610
  };
4600
4611
 
4601
4612
  const prompt = (text, options) => {
4602
- return invoke$2('ConfirmPrompt.prompt', text, options);
4613
+ return invoke$1('ConfirmPrompt.prompt', text, options);
4603
4614
  };
4604
4615
 
4605
4616
  const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
@@ -4794,7 +4805,7 @@ const show = async (x, y, id, ...args) => {
4794
4805
  number(y);
4795
4806
  number(id);
4796
4807
  // TODO
4797
- await invoke$2('ContextMenu.show', x, y, id, ...args);
4808
+ await invoke$1('ContextMenu.show', x, y, id, ...args);
4798
4809
  };
4799
4810
 
4800
4811
  const Search = 18;
@@ -4897,6 +4908,7 @@ const commandMap = {
4897
4908
  'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
4898
4909
  'TextSearch.viewAsTree': wrapCommand(viewAsTree),
4899
4910
  // not wrapped
4911
+ 'TextSearch.initialize': initialize,
4900
4912
  'TextSearch.create': create,
4901
4913
  'TextSearch.getCommandIds': getCommandIds,
4902
4914
  'TextSearch.getKeyBindings': getKeyBindings,
@@ -4916,7 +4928,7 @@ const listen = async () => {
4916
4928
  const rpc = await WebWorkerRpcClient.create({
4917
4929
  commandMap: commandMap
4918
4930
  });
4919
- set$1(rpc);
4931
+ set$2(rpc);
4920
4932
  };
4921
4933
 
4922
4934
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "4.11.0",
3
+ "version": "4.13.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"