@lvce-editor/text-search-worker 3.46.0 → 3.48.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.
@@ -936,12 +936,12 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
936
936
  return invokeHelper(ipc, method, params, true);
937
937
  };
938
938
 
939
- const commands$1 = Object.create(null);
939
+ const commands = Object.create(null);
940
940
  const register = commandMap => {
941
- Object.assign(commands$1, commandMap);
941
+ Object.assign(commands, commandMap);
942
942
  };
943
943
  const getCommand = key => {
944
- return commands$1[key];
944
+ return commands[key];
945
945
  };
946
946
  const execute = (command, ...args) => {
947
947
  const fn = getCommand(command);
@@ -1086,6 +1086,30 @@ const clearSearchResults$1 = state => {
1086
1086
  };
1087
1087
  };
1088
1088
 
1089
+ const PreserveCase$2 = 1 << 0; // 1
1090
+ const UseRegularExpression$2 = 1 << 1; // 2
1091
+ const ReplaceExpanded = 1 << 2; // 4
1092
+ const MatchWholeWord$2 = 1 << 3; // 8
1093
+ const MatchCase$2 = 1 << 4; // 16
1094
+ const DetailsExpanded = 1 << 5; // 32
1095
+ const OpenEditors = 1 << 6; // 64
1096
+ const UseIgnoreFiles = 1 << 7; // 128
1097
+ const hasDetailsExpanded = flags => {
1098
+ return (flags & DetailsExpanded) === DetailsExpanded;
1099
+ };
1100
+
1101
+ const collapseDetails = state => {
1102
+ const {
1103
+ flags
1104
+ } = state;
1105
+ return {
1106
+ ...state,
1107
+ flags: flags & -33,
1108
+ focus: FocusSearchInput,
1109
+ focusSource: Script
1110
+ };
1111
+ };
1112
+
1089
1113
  const RendererWorker = 1;
1090
1114
 
1091
1115
  const rpcs = Object.create(null);
@@ -1238,19 +1262,19 @@ const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file
1238
1262
  const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
1239
1263
  const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
1240
1264
  const ManyResultsInOneFile = '{PH1} results in 1 file';
1241
- const MatchCase$2 = 'Match Case';
1242
- const MatchWholeWord$2 = 'Match Whole Word';
1265
+ const MatchCase$1 = 'Match Case';
1266
+ const MatchWholeWord$1 = 'Match Whole Word';
1243
1267
  const NoResults = 'No results found';
1244
1268
  const Oneresult = '1 result in 1 file';
1245
1269
  const OpenNewSearchEditor = 'Open New Search Editor';
1246
- const PreserveCase$2 = 'Preserve Case';
1270
+ const PreserveCase$1 = 'Preserve Case';
1247
1271
  const Refresh$1 = 'Refresh';
1248
1272
  const Replace = 'Replace';
1249
1273
  const ReplaceAll$1 = 'Replace All';
1250
1274
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
1251
1275
  const ReplacedOneOccurrenceInOneFile = "Replaced 1 occurrence across 1 file with '{PH1}'";
1252
1276
  const ToggleReplace$1 = 'Toggle Replace';
1253
- const UseRegularExpression$2 = 'Use Regular Expression';
1277
+ const UseRegularExpression$1 = 'Use Regular Expression';
1254
1278
  const ViewAsTree = 'View as Tree';
1255
1279
  const FilesToInclude$1 = 'Files to Include';
1256
1280
  const FilesToExclude$1 = 'Files to Exclude';
@@ -1268,19 +1292,19 @@ const toggleReplace$1 = () => {
1268
1292
  return i18nString(ToggleReplace$1);
1269
1293
  };
1270
1294
  const matchCase = () => {
1271
- return i18nString(MatchCase$2);
1295
+ return i18nString(MatchCase$1);
1272
1296
  };
1273
1297
  const preserveCase = () => {
1274
- return i18nString(PreserveCase$2);
1298
+ return i18nString(PreserveCase$1);
1275
1299
  };
1276
1300
  const matchWholeWord = () => {
1277
- return i18nString(MatchWholeWord$2);
1301
+ return i18nString(MatchWholeWord$1);
1278
1302
  };
1279
1303
  const toggleSearchDetails = () => {
1280
1304
  return i18nString(ToggleSearchDetails$1);
1281
1305
  };
1282
1306
  const useRegularExpression = () => {
1283
- return i18nString(UseRegularExpression$2);
1307
+ return i18nString(UseRegularExpression$1);
1284
1308
  };
1285
1309
  const manyResultsInOneFile = resultCount => {
1286
1310
  return i18nString(ManyResultsInOneFile, {
@@ -1520,23 +1544,23 @@ const dismissItem = state => {
1520
1544
  };
1521
1545
  };
1522
1546
 
1523
- const focusMatchCase$1 = state => {
1547
+ const expandDetails = state => {
1548
+ const {
1549
+ flags
1550
+ } = state;
1524
1551
  return {
1525
1552
  ...state,
1526
- focus: FocusSearchMatchCase
1553
+ flags: flags | DetailsExpanded,
1554
+ focus: FocusSearchIncludeInput,
1555
+ focusSource: Script
1527
1556
  };
1528
1557
  };
1529
1558
 
1530
- const PreserveCase$1 = 1 << 0; // 1
1531
- const UseRegularExpression$1 = 1 << 1; // 2
1532
- const ReplaceExpanded = 1 << 2; // 4
1533
- const MatchWholeWord$1 = 1 << 3; // 8
1534
- const MatchCase$1 = 1 << 4; // 16
1535
- const DetailsExpanded = 1 << 5; // 32
1536
- const OpenEditors = 1 << 6; // 64
1537
- const UseIgnoreFiles = 1 << 7; // 128
1538
- const hasDetailsExpanded = flags => {
1539
- return (flags & DetailsExpanded) === DetailsExpanded;
1559
+ const focusMatchCase$1 = state => {
1560
+ return {
1561
+ ...state,
1562
+ focus: FocusSearchMatchCase
1563
+ };
1540
1564
  };
1541
1565
 
1542
1566
  const getNextFocus = (focus, flags) => {
@@ -1779,9 +1803,10 @@ const getActionsVirtualDom = actions => {
1779
1803
  }, ...actions.flatMap(getActionVirtualDom)];
1780
1804
  };
1781
1805
 
1782
- const commands = ['clearSearchResults', 'copy', 'dismissItem', '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', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression'];
1806
+ const commandIds = ['clearSearchResults', 'collapseDetails', 'copy', 'dismissItem', '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', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression'];
1807
+
1783
1808
  const getCommandIds = () => {
1784
- return commands;
1809
+ return commandIds;
1785
1810
  };
1786
1811
 
1787
1812
  const getFlags = uid => {
@@ -2259,17 +2284,17 @@ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
2259
2284
  const getInputActionsInput = flags => {
2260
2285
  const inside = [{
2261
2286
  icon: MaskIconCaseSensitive,
2262
- flag: flags & MatchCase$1 ? CheckBoxEnabled : CheckBoxDisabled,
2287
+ flag: flags & MatchCase$2 ? CheckBoxEnabled : CheckBoxDisabled,
2263
2288
  title: matchCase(),
2264
2289
  name: MatchCase
2265
2290
  }, {
2266
2291
  icon: MaskIconWholeWord,
2267
- flag: flags & MatchWholeWord$1 ? CheckBoxEnabled : CheckBoxDisabled,
2292
+ flag: flags & MatchWholeWord$2 ? CheckBoxEnabled : CheckBoxDisabled,
2268
2293
  title: matchWholeWord(),
2269
2294
  name: MatchWholeWord
2270
2295
  }, {
2271
2296
  icon: MaskIconRegex,
2272
- flag: flags & UseRegularExpression$1 ? CheckBoxEnabled : CheckBoxDisabled,
2297
+ flag: flags & UseRegularExpression$2 ? CheckBoxEnabled : CheckBoxDisabled,
2273
2298
  title: useRegularExpression(),
2274
2299
  name: UseRegularExpression
2275
2300
  }];
@@ -2283,7 +2308,7 @@ const getInputActionsInput = flags => {
2283
2308
  const getInputActionsReplace = (flags, matchCount) => {
2284
2309
  const inside = [{
2285
2310
  icon: MaskIconPreserveCase,
2286
- flag: flags & PreserveCase$1 ? CheckBoxEnabled : CheckBoxDisabled,
2311
+ flag: flags & PreserveCase$2 ? CheckBoxEnabled : CheckBoxDisabled,
2287
2312
  title: preserveCase(),
2288
2313
  name: PreserveCase
2289
2314
  }];
@@ -2870,10 +2895,10 @@ const textSearch = async (root, query, options, assetDir, platform) => {
2870
2895
  // Based on https://github.com/microsoft/vscode/blob/ad375c92764b72a1f28f3e1626563e9e41e5c740/src/vs/workbench/contrib/search/browser/searchWidget.ts#L393 by Microsoft (License MIT)
2871
2896
 
2872
2897
  const validateSearchInput = (value, flags) => {
2873
- if (value.length === 0) {
2898
+ if (!value) {
2874
2899
  return '';
2875
2900
  }
2876
- if (!(flags & UseRegularExpression$1)) {
2901
+ if (!(flags & UseRegularExpression$2)) {
2877
2902
  return '';
2878
2903
  }
2879
2904
  try {
@@ -2929,8 +2954,8 @@ const handleUpdate = async (state, update) => {
2929
2954
  const scheme = getProtocol$1(root);
2930
2955
  const results = await textSearch(root, value, {
2931
2956
  threads,
2932
- isCaseSensitive: Boolean(flags & MatchCase$1),
2933
- useRegularExpression: Boolean(flags & UseRegularExpression$1),
2957
+ isCaseSensitive: Boolean(flags & MatchCase$2),
2958
+ useRegularExpression: Boolean(flags & UseRegularExpression$2),
2934
2959
  exclude: excludeValue,
2935
2960
  include: includeValue,
2936
2961
  assetDir: state.assetDir,
@@ -2938,7 +2963,7 @@ const handleUpdate = async (state, update) => {
2938
2963
  query: value,
2939
2964
  scheme,
2940
2965
  flags,
2941
- matchWholeWord: Boolean(flags & MatchWholeWord$1)
2966
+ matchWholeWord: Boolean(flags & MatchWholeWord$2)
2942
2967
  }, state.assetDir, state.platform);
2943
2968
  if (!Array.isArray(results)) {
2944
2969
  throw new TypeError('results must be of type array');
@@ -3078,28 +3103,6 @@ const replaceAll = async state => {
3078
3103
  };
3079
3104
  };
3080
3105
 
3081
- const toggleSearchFlag = (state, flag) => {
3082
- return handleUpdate(state, {
3083
- flags: state.flags ^ flag
3084
- });
3085
- };
3086
-
3087
- const collapseDetails = async state => {
3088
- return {
3089
- ...(await toggleSearchFlag(state, DetailsExpanded)),
3090
- focus: FocusSearchInput,
3091
- focusSource: Script
3092
- };
3093
- };
3094
-
3095
- const expandDetails = async state => {
3096
- return {
3097
- ...(await toggleSearchFlag(state, DetailsExpanded)),
3098
- focus: FocusSearchIncludeInput,
3099
- focusSource: Script
3100
- };
3101
- };
3102
-
3103
3106
  const toggleDetailsExpanded = state => {
3104
3107
  if (hasDetailsExpanded(state.flags)) {
3105
3108
  return collapseDetails(state);
@@ -3107,12 +3110,18 @@ const toggleDetailsExpanded = state => {
3107
3110
  return expandDetails(state);
3108
3111
  };
3109
3112
 
3113
+ const toggleSearchFlag = (state, flag) => {
3114
+ return handleUpdate(state, {
3115
+ flags: state.flags ^ flag
3116
+ });
3117
+ };
3118
+
3110
3119
  const toggleMatchCase = state => {
3111
- return toggleSearchFlag(state, MatchCase$1);
3120
+ return toggleSearchFlag(state, MatchCase$2);
3112
3121
  };
3113
3122
 
3114
3123
  const toggleMatchWholeWord = state => {
3115
- return toggleSearchFlag(state, MatchWholeWord$1);
3124
+ return toggleSearchFlag(state, MatchWholeWord$2);
3116
3125
  };
3117
3126
 
3118
3127
  const toggleOpenEditors = state => {
@@ -3120,7 +3129,7 @@ const toggleOpenEditors = state => {
3120
3129
  };
3121
3130
 
3122
3131
  const togglePreserveCase = state => {
3123
- return toggleSearchFlag(state, PreserveCase$1);
3132
+ return toggleSearchFlag(state, PreserveCase$2);
3124
3133
  };
3125
3134
 
3126
3135
  const toggleReplace = state => {
@@ -3132,7 +3141,7 @@ const toggleUseIgnoreFiles = state => {
3132
3141
  };
3133
3142
 
3134
3143
  const toggleUseRegularExpression = state => {
3135
- return toggleSearchFlag(state, UseRegularExpression$1);
3144
+ return toggleSearchFlag(state, UseRegularExpression$2);
3136
3145
  };
3137
3146
 
3138
3147
  const getClickHandler = name => {
@@ -3706,6 +3715,44 @@ const RenderReplaceValue = 4;
3706
3715
  const RenderIncludeValue = 5;
3707
3716
  const RenderExcludeValue = 6;
3708
3717
 
3718
+ const getFocusSelector = focusKey => {
3719
+ switch (focusKey) {
3720
+ case FocusSearchInput:
3721
+ return SearchValue;
3722
+ case FocusSearchReplaceInput:
3723
+ return ReplaceValue;
3724
+ case FocusToggleDetails:
3725
+ return ToggleSearchDetails;
3726
+ case FocusSearchMatchCase:
3727
+ return MatchCase;
3728
+ case FocusSearchPreserveCase:
3729
+ return PreserveCase;
3730
+ case FocusSearchRegex:
3731
+ return UseRegularExpression;
3732
+ case FocusSearchIncludeInput:
3733
+ return FilesToInclude;
3734
+ case FocusSearchExcludeInput:
3735
+ return FilesToExclude;
3736
+ case FocusSearchWholeWord:
3737
+ return MatchWholeWord;
3738
+ case FocusSearchReplaceAll:
3739
+ return ReplaceAll;
3740
+ case FocusSearchOpenEditors:
3741
+ return SearchOnlyOpenEditors;
3742
+ case FocusIgnoreFiles:
3743
+ return UseExcludeSettings;
3744
+ case FocusToggleReplace:
3745
+ return ToggleReplace;
3746
+ default:
3747
+ return '';
3748
+ }
3749
+ };
3750
+
3751
+ const renderFocus = (oldState, newState) => {
3752
+ const selector = getFocusSelector(newState.focus);
3753
+ return ['Viewlet.focusElementByName', newState.uid, selector];
3754
+ };
3755
+
3709
3756
  const createViewModel = state => {
3710
3757
  const {
3711
3758
  listItems,
@@ -3768,9 +3815,6 @@ const renderExcludeValue = (oldState, newState) => {
3768
3815
  return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
3769
3816
  };
3770
3817
 
3771
- const renderFocus = (oldState, newState) => {
3772
- return oldState.focus === newState.focus || newState.focusSource === User;
3773
- };
3774
3818
  const getRenderer = diffType => {
3775
3819
  switch (diffType) {
3776
3820
  case RenderValue:
@@ -3883,7 +3927,8 @@ const doRender = uid => {
3883
3927
  newState
3884
3928
  } = get(uid);
3885
3929
  const diffResult = diff$1(oldState, newState);
3886
- return applyRender(oldState, newState, diffResult);
3930
+ const commands = applyRender(oldState, newState, diffResult);
3931
+ return commands;
3887
3932
  };
3888
3933
 
3889
3934
  const renderActions = uid => {
@@ -3914,13 +3959,13 @@ const renderEventListeners = () => {
3914
3959
  params: ['handleInput', 'event.target.value', User]
3915
3960
  }, {
3916
3961
  name: HandleClick,
3917
- params: ['handleClickAt', 'event.clientX', 'event.clientY']
3962
+ params: ['handleClick', 'event.clientX', 'event.clientY']
3918
3963
  }, {
3919
3964
  name: HandleToggleButtonClick,
3920
- params: ['handleClickAt', 'event.clientX', 'event.clientY']
3965
+ params: ['handleToggleButtonClick']
3921
3966
  }, {
3922
3967
  name: HandleListFocus,
3923
- params: ['handleClickAt', 'event.clientX', 'event.clientY']
3968
+ params: ['handleListFocus']
3924
3969
  }, {
3925
3970
  name: HandleListBlur,
3926
3971
  params: ['handleListBlur']
@@ -3930,7 +3975,7 @@ const renderEventListeners = () => {
3930
3975
  preventDefault: true
3931
3976
  }, {
3932
3977
  name: HandleWheel,
3933
- params: ['handleContextMenu', 'event.deltaMode', 'event.deltaY'],
3978
+ params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
3934
3979
  passive: true
3935
3980
  }, {
3936
3981
  name: HandleHeaderClick2,
@@ -4523,6 +4568,8 @@ const commandMap = {
4523
4568
  'TextSearch.copy': wrapCommand(copy),
4524
4569
  'TextSearch.dismissItem': wrapCommand(dismissItem),
4525
4570
  'TextSearch.focusFirst': wrapCommand(focusFirst),
4571
+ 'TextSearch.collapseDetails': wrapCommand(collapseDetails),
4572
+ 'TextSearch.expandDetails': wrapCommand(expandDetails),
4526
4573
  'TextSearch.focusIndex': wrapCommand(focusIndex),
4527
4574
  'TextSearch.focusLast': wrapCommand(focusLast),
4528
4575
  'TextSearch.focusMatchCase': wrapCommand(focusMatchCase$1),
@@ -4537,14 +4584,14 @@ const commandMap = {
4537
4584
  'TextSearch.focusPreviousInput': wrapCommand(focusPreviousInput),
4538
4585
  'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
4539
4586
  'TextSearch.focusRegex': wrapCommand(focusRegex),
4540
- 'TextSearch.getCommandIds': getCommandIds,
4541
4587
  'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
4542
4588
  'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
4543
4589
  'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
4544
4590
  'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
4545
4591
  'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
4546
- 'TextSearch.renderActions': wrapCommand(renderActions),
4547
4592
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
4593
+ 'TextSearch.getCommandIds': getCommandIds,
4594
+ 'TextSearch.renderActions': wrapCommand(renderActions),
4548
4595
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
4549
4596
  'TextSearch.getActions': wrapCommand(getActions),
4550
4597
  'TextSearch.getActionsVirtualDom': wrapCommand(getActionsVirtualDom),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.46.0",
3
+ "version": "3.48.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"