@lvce-editor/text-search-worker 4.7.0 → 4.9.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.
@@ -599,7 +599,7 @@ const create$4 = (method, params) => {
599
599
  };
600
600
  };
601
601
  const callbacks = Object.create(null);
602
- const set$2 = (id, fn) => {
602
+ const set$4 = (id, fn) => {
603
603
  callbacks[id] = fn;
604
604
  };
605
605
  const get$2 = id => {
@@ -618,7 +618,7 @@ const registerPromise = () => {
618
618
  resolve,
619
619
  promise
620
620
  } = Promise.withResolvers();
621
- set$2(id, resolve);
621
+ set$4(id, resolve);
622
622
  return {
623
623
  id,
624
624
  promise
@@ -1003,7 +1003,7 @@ const listen$1 = async (module, options) => {
1003
1003
  const ipc = module.wrap(rawIpc);
1004
1004
  return ipc;
1005
1005
  };
1006
- const create$7 = async ({
1006
+ const create$8 = async ({
1007
1007
  commandMap,
1008
1008
  messagePort,
1009
1009
  isMessagePortOpen
@@ -1021,7 +1021,7 @@ const create$7 = async ({
1021
1021
  };
1022
1022
  const MessagePortRpcParent = {
1023
1023
  __proto__: null,
1024
- create: create$7
1024
+ create: create$8
1025
1025
  };
1026
1026
  const create$1$1 = async ({
1027
1027
  commandMap,
@@ -1085,7 +1085,8 @@ const clearSearchResults$1 = state => {
1085
1085
  maxLineY: 0,
1086
1086
  message: '',
1087
1087
  focus: FocusSearchInput,
1088
- focusSource: Script
1088
+ focusSource: Script,
1089
+ inputSource: Script
1089
1090
  };
1090
1091
  };
1091
1092
 
@@ -1117,26 +1118,39 @@ const collapseDetails = state => {
1117
1118
  };
1118
1119
  };
1119
1120
 
1120
- const RendererWorker = 1;
1121
-
1122
1121
  const rpcs = Object.create(null);
1123
- const set$1 = (id, rpc) => {
1122
+ const set$3 = (id, rpc) => {
1124
1123
  rpcs[id] = rpc;
1125
1124
  };
1126
1125
  const get$1 = id => {
1127
1126
  return rpcs[id];
1128
1127
  };
1129
-
1130
- const invoke$2 = (method, ...params) => {
1131
- const rpc = get$1(RendererWorker);
1128
+ const RendererWorker$1 = 1;
1129
+ const invoke$2$1 = (method, ...params) => {
1130
+ const rpc = get$1(RendererWorker$1);
1132
1131
  // @ts-ignore
1133
1132
  return rpc.invoke(method, ...params);
1134
1133
  };
1135
- const invokeAndTransfer = (method, ...params) => {
1136
- const rpc = get$1(RendererWorker);
1134
+ const invokeAndTransfer$2 = (method, ...params) => {
1135
+ const rpc = get$1(RendererWorker$1);
1137
1136
  // @ts-ignore
1138
1137
  return rpc.invokeAndTransfer(method, ...params);
1139
1138
  };
1139
+ const set$2 = rpc => {
1140
+ set$3(RendererWorker$1, rpc);
1141
+ };
1142
+ const RendererWorker = {
1143
+ __proto__: null,
1144
+ invoke: invoke$2$1,
1145
+ invokeAndTransfer: invokeAndTransfer$2,
1146
+ set: set$2
1147
+ };
1148
+
1149
+ const {
1150
+ invoke: invoke$2,
1151
+ invokeAndTransfer,
1152
+ set: set$1
1153
+ } = RendererWorker;
1140
1154
 
1141
1155
  const copy = async state => {
1142
1156
  const {
@@ -1194,6 +1208,20 @@ const create$2 = () => {
1194
1208
  };
1195
1209
  };
1196
1210
  return wrapped;
1211
+ },
1212
+ diff(uid, modules, numbers) {
1213
+ const {
1214
+ oldState,
1215
+ newState
1216
+ } = states[uid];
1217
+ const diffResult = [];
1218
+ for (let i = 0; i < modules.length; i++) {
1219
+ const fn = modules[i];
1220
+ if (!fn(oldState, newState)) {
1221
+ diffResult.push(numbers[i]);
1222
+ }
1223
+ }
1224
+ return diffResult;
1197
1225
  }
1198
1226
  };
1199
1227
  };
@@ -1286,15 +1314,19 @@ const RenderExcludeValue = 6;
1286
1314
  const RenderFocusContext = 7;
1287
1315
 
1288
1316
  const diffType$5 = RenderExcludeValue;
1289
- const isEqual$5 = (oldState, newState) => {
1317
+ const isEqual$6 = (oldState, newState) => {
1290
1318
  return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
1291
1319
  };
1292
1320
 
1293
1321
  const diffType$4 = RenderFocus;
1294
- const isEqual$4 = (oldState, newState) => {
1322
+ const isEqual$5 = (oldState, newState) => {
1295
1323
  return oldState.focus === newState.focus || newState.focusSource === User;
1296
1324
  };
1297
1325
 
1326
+ const isEqual$4 = (oldState, newState) => {
1327
+ return oldState.focus === newState.focus;
1328
+ };
1329
+
1298
1330
  const diffType$3 = RenderIncludeValue;
1299
1331
  const isEqual$3 = (oldState, newState) => {
1300
1332
  return oldState.includeValue === newState.includeValue || newState.inputSource === User;
@@ -1315,8 +1347,8 @@ const isEqual = (oldState, newState) => {
1315
1347
  return oldState.value === newState.value || newState.inputSource === User;
1316
1348
  };
1317
1349
 
1318
- const modules = [isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual$1, isEqual];
1319
- const numbers = [diffType$2, diffType$4, diffType$3, diffType$5, diffType$1, diffType];
1350
+ const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
1351
+ const numbers = [diffType$2, diffType$4, diffType$3, diffType$5, diffType$1, diffType, RenderFocusContext];
1320
1352
 
1321
1353
  const diff$1 = (oldState, newState) => {
1322
1354
  const diffResult = [];
@@ -1787,12 +1819,7 @@ const focusReplaceValue$1 = state => {
1787
1819
  };
1788
1820
  };
1789
1821
 
1790
- const setFocus = async focusKey => {
1791
- await invoke$2('Focus.setFocus', focusKey);
1792
- };
1793
-
1794
1822
  const focusSearchValue$1 = async state => {
1795
- await setFocus(FocusSearchInput);
1796
1823
  return {
1797
1824
  ...state,
1798
1825
  focus: FocusSearchInput
@@ -1806,7 +1833,7 @@ const focusSearchValueNext = state => {
1806
1833
  return focusMatchCase$1(state);
1807
1834
  };
1808
1835
 
1809
- const commandIds = ['clearSearchResults', 'collapseAll', 'collapseDetails', 'copy', 'dismissItem', 'dispose', 'expandDetails', 'focusFirst', 'focusIndex', 'focusLast', 'focusMatchCase', 'focusMatchCasePrevious', 'focusMatchWholeWord', 'focusNext', 'focusNextInput', 'focusNextPage', 'focusPreserveCasePrevious', 'focusPrevious', 'focusPreviousInput', 'focusPreviousPage', 'focusRegex', 'focusRegexNext', 'focusReplaceAll', 'focusReplaceValue', 'focusReplaceValueNext', 'focusReplaceValuePrevious', 'focusSearchValue', 'focusSearchValueNext', 'handleClick', 'handleClickAt', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleContextMenuMouseAt', 'handleExcludeInput', 'handleFocusIn', 'handleHeaderClick', 'handleHeaderFocusIn', 'handleHeaderFocusOut', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression', 'viewAsTree'];
1836
+ const commandIds = ['clearSearchResults', 'collapseAll', 'collapseDetails', 'copy', 'dismissItem', 'dispose', 'expandDetails', 'focusFirst', 'focusIndex', 'focusLast', 'focusMatchCase', 'focusMatchCasePrevious', 'focusMatchWholeWord', 'focusNext', 'focusNextInput', 'focusNextPage', 'focusPreserveCasePrevious', 'focusPrevious', 'focusPreviousInput', 'focusPreviousPage', 'focusRegex', 'focusRegexNext', 'focusReplaceAll', 'focusReplaceValue', 'focusReplaceValueNext', 'focusReplaceValuePrevious', 'focusSearchValue', 'focusSearchValueNext', 'handleClick', 'handleClickAt', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleContextMenuMouseAt', 'handleExcludeInput', 'handleFocusIn', 'handleHeaderClick', 'handleHeaderContextMenu', 'handleHeaderFocusIn', 'handleHeaderFocusOut', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression', 'viewAsTree'];
1810
1837
 
1811
1838
  const getCommandIds = () => {
1812
1839
  return commandIds;
@@ -1825,7 +1852,7 @@ const CtrlCmd = 1 << 11 >>> 0;
1825
1852
  const Shift = 1 << 10 >>> 0;
1826
1853
  const Alt = 1 << 9 >>> 0;
1827
1854
 
1828
- const getKeyBindings = () => {
1855
+ const getSearchHeaderKeyBindings = () => {
1829
1856
  return [{
1830
1857
  key: CtrlCmd | Alt | Enter,
1831
1858
  command: 'Search.replaceAll',
@@ -1847,6 +1874,18 @@ const getKeyBindings = () => {
1847
1874
  command: 'Search.nextHistoryResult',
1848
1875
  when: FocusSearchInput
1849
1876
  }, {
1877
+ key: Enter,
1878
+ command: 'Search.submit',
1879
+ when: FocusSearchInput
1880
+ }, {
1881
+ key: Enter,
1882
+ command: 'Search.submit',
1883
+ when: FocusSearchReplaceInput
1884
+ }];
1885
+ };
1886
+
1887
+ const getSearchResultKeyBindings = () => {
1888
+ return [{
1850
1889
  key: DownArrow,
1851
1890
  command: 'Search.focusNext',
1852
1891
  when: FocusSearchResults
@@ -1870,17 +1909,13 @@ const getKeyBindings = () => {
1870
1909
  key: CtrlCmd | KeyC,
1871
1910
  command: 'Search.copy',
1872
1911
  when: FocusSearchResults
1873
- }, {
1874
- key: Enter,
1875
- command: 'Search.submit',
1876
- when: FocusSearchInput
1877
- }, {
1878
- key: Enter,
1879
- command: 'Search.submit',
1880
- when: FocusSearchReplaceInput
1881
1912
  }];
1882
1913
  };
1883
1914
 
1915
+ const getKeyBindings = () => {
1916
+ return [...getSearchHeaderKeyBindings(), ...getSearchResultKeyBindings()];
1917
+ };
1918
+
1884
1919
  const handleError = error => {
1885
1920
  console.error(`[text-search-worker] ${error}`);
1886
1921
  };
@@ -2459,6 +2494,10 @@ const handleHeaderClick = async (state, name) => {
2459
2494
  return fn(state);
2460
2495
  };
2461
2496
 
2497
+ const handleHeaderContextMenu = async state => {
2498
+ return state;
2499
+ };
2500
+
2462
2501
  const handleHeaderFocusIn = state => {
2463
2502
  return state;
2464
2503
  };
@@ -2877,7 +2916,9 @@ const selectIndexFile = async (state, searchResult, index) => {
2877
2916
  listFocused: true,
2878
2917
  listItems: filteredResults,
2879
2918
  maxLineY,
2880
- icons
2919
+ icons,
2920
+ focus: FocusSearchResults,
2921
+ focusSource: Script
2881
2922
  };
2882
2923
  };
2883
2924
 
@@ -2921,9 +2962,6 @@ const selectIndexPreview = async (state, searchResult, index) => {
2921
2962
  const fileResult = items[fileIndex];
2922
2963
  const relativePath = getRelativePath(fileResult.text);
2923
2964
  const absolutePath = `${workspacePath}${relativePath}`;
2924
- if (state.focus !== FocusSearchResults) {
2925
- await setFocus(FocusSearchResults);
2926
- }
2927
2965
  await openUri(absolutePath, true, {
2928
2966
  selections: new Uint32Array([lineNumber, 0, lineNumber, 0])
2929
2967
  });
@@ -2931,7 +2969,8 @@ const selectIndexPreview = async (state, searchResult, index) => {
2931
2969
  ...state,
2932
2970
  listFocusedIndex: index,
2933
2971
  listFocused: false,
2934
- focus: FocusSearchResults
2972
+ focus: FocusSearchResults,
2973
+ focusSource: Script
2935
2974
  };
2936
2975
  };
2937
2976
 
@@ -2962,7 +3001,7 @@ const selectIndex = async (state, index) => {
2962
3001
  return fn(state, searchResult, index);
2963
3002
  };
2964
3003
 
2965
- const handleClickAt = (state, eventX, eventY) => {
3004
+ const handleClickAt = async (state, eventX, eventY) => {
2966
3005
  const {
2967
3006
  x,
2968
3007
  y,
@@ -3362,6 +3401,7 @@ const TreeItem = 'treeitem';
3362
3401
 
3363
3402
  const HandleClick = 'handleClick';
3364
3403
  const HandleContextMenu = 'handleContextMenu';
3404
+ const HandleHeaderContextMenu = 'handleHeaderContextMenu';
3365
3405
  const HandleExcludeInput = 'handleExcludeInput';
3366
3406
  const HandleHeaderClick2 = 'handleHeaderClick2';
3367
3407
  const HandleHeaderFocusIn = 'handleHeaderFocusIn';
@@ -3929,7 +3969,8 @@ const parentNode = {
3929
3969
  childCount: 2,
3930
3970
  onClick: HandleHeaderClick2,
3931
3971
  onFocusIn: HandleHeaderFocusIn,
3932
- onFocusOut: HandleHeaderFocusOut
3972
+ onFocusOut: HandleHeaderFocusOut,
3973
+ onContextMenu: HandleHeaderContextMenu
3933
3974
  };
3934
3975
  const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus) => {
3935
3976
  const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus), ...getSearchHeaderDetailsVirtualDom(flags, message)];
@@ -4335,6 +4376,10 @@ const renderEventListeners = () => {
4335
4376
  name: HandleContextMenu,
4336
4377
  params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
4337
4378
  preventDefault: true
4379
+ }, {
4380
+ name: HandleHeaderContextMenu,
4381
+ params: ['handleHeaderContextMenu'],
4382
+ preventDefault: true
4338
4383
  }, {
4339
4384
  name: HandleWheel,
4340
4385
  params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
@@ -4487,7 +4532,6 @@ const handleFocusIn = async (state, key) => {
4487
4532
  if (state.focus === focusKey) {
4488
4533
  return state;
4489
4534
  }
4490
- await setFocus(FocusSearch);
4491
4535
  return {
4492
4536
  ...state,
4493
4537
  focus: focusKey,
@@ -4604,8 +4648,8 @@ const handleContextMenu = async (state, button, x, y) => {
4604
4648
 
4605
4649
  const commandMap = {
4606
4650
  'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
4607
- 'TextSearch.collapseDetails': wrapCommand(collapseDetails),
4608
4651
  'TextSearch.collapseAll': wrapCommand(collapseAll$1),
4652
+ 'TextSearch.collapseDetails': wrapCommand(collapseDetails),
4609
4653
  'TextSearch.copy': wrapCommand(copy),
4610
4654
  'TextSearch.diff2': diff2,
4611
4655
  'TextSearch.dismissItem': wrapCommand(dismissItem),
@@ -4633,11 +4677,11 @@ const commandMap = {
4633
4677
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
4634
4678
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
4635
4679
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
4636
- 'TextSearch.viewAsTree': wrapCommand(viewAsTree),
4637
4680
  'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
4638
4681
  'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
4639
4682
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
4640
4683
  'TextSearch.handleHeaderClick': wrapCommand(handleHeaderClick),
4684
+ 'TextSearch.handleHeaderContextMenu': wrapCommand(handleHeaderContextMenu),
4641
4685
  'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
4642
4686
  'TextSearch.handleHeaderFocusOut': wrapCommand(handleHeaderFocusOut),
4643
4687
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
@@ -4651,7 +4695,6 @@ const commandMap = {
4651
4695
  'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
4652
4696
  'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
4653
4697
  'TextSearch.handleWheel': wrapCommand(handleWheel),
4654
- 'TextSearch.launchSearchProcess': wrapCommand(launchSearchProcess),
4655
4698
  'TextSearch.loadContent': wrapCommand(loadContent),
4656
4699
  'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
4657
4700
  'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
@@ -4667,6 +4710,7 @@ const commandMap = {
4667
4710
  'TextSearch.toggleSearchDetails': wrapCommand(toggleDetailsExpanded),
4668
4711
  'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
4669
4712
  'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
4713
+ 'TextSearch.viewAsTree': wrapCommand(viewAsTree),
4670
4714
  // not wrapped
4671
4715
  'TextSearch.create': create,
4672
4716
  'TextSearch.getCommandIds': getCommandIds,
@@ -4687,7 +4731,7 @@ const listen = async () => {
4687
4731
  const rpc = await WebWorkerRpcClient.create({
4688
4732
  commandMap: commandMap
4689
4733
  });
4690
- set$1(RendererWorker, rpc);
4734
+ set$1(rpc);
4691
4735
  };
4692
4736
 
4693
4737
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "4.7.0",
3
+ "version": "4.9.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"