@lvce-editor/text-search-worker 5.31.0 → 5.32.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.
@@ -1159,6 +1159,7 @@ const Highlight = 'Highlight';
1159
1159
  const HighlightDeleted = 'HighlightDeleted';
1160
1160
  const HighlightInserted = 'HighlightInserted';
1161
1161
  const IconButton = 'IconButton';
1162
+ const IconButtonDisabled = 'IconButtonDisabled';
1162
1163
  const Label = 'Label';
1163
1164
  const List$1 = 'List';
1164
1165
  const MaskIcon = 'MaskIcon';
@@ -1394,10 +1395,11 @@ const create$2 = () => {
1394
1395
  wrapCommand(fn) {
1395
1396
  const wrapped = async (uid, ...args) => {
1396
1397
  const {
1398
+ oldState,
1397
1399
  newState
1398
1400
  } = states[uid];
1399
1401
  const newerState = await fn(newState, ...args);
1400
- if (newState === newerState) {
1402
+ if (oldState === newerState || newState === newerState) {
1401
1403
  return;
1402
1404
  }
1403
1405
  const latest = states[uid];
@@ -1678,14 +1680,15 @@ const Script = 2;
1678
1680
  const clearSearchResults$1 = state => {
1679
1681
  return {
1680
1682
  ...state,
1681
- value: '',
1683
+ focus: FocusSearchInput,
1684
+ focusSource: Script,
1685
+ inputSource: Script,
1682
1686
  items: [],
1683
- minLineY: 0,
1684
1687
  maxLineY: 0,
1685
1688
  message: '',
1686
- focus: FocusSearchInput,
1687
- focusSource: Script,
1688
- inputSource: Script
1689
+ minLineY: 0,
1690
+ replacement: '',
1691
+ value: ''
1689
1692
  };
1690
1693
  };
1691
1694
 
@@ -2179,7 +2182,7 @@ const i18nString = (key, placeholders = emptyObject) => {
2179
2182
  };
2180
2183
 
2181
2184
  const ClearSearchResults = 'Clear Search Results';
2182
- const CollapseAll$1 = 'Collapse All';
2185
+ const CollapseAll$2 = 'Collapse All';
2183
2186
  const ConfirmReplaceManyOccurrencesInManyFiles = "Replace {PH1} occurrences across {PH2} files with '{PH3}'";
2184
2187
  const ConfirmReplaceManyOccurrencesInManyFilesNoValue = 'Replace {PH1} occurrences across {PH2} files';
2185
2188
  const ConfirmReplaceManyOccurrencesInOneFile = "Replace {PH1} occurrences across 1 file with '{PH2}'";
@@ -2206,7 +2209,7 @@ const NoResults = 'No results found';
2206
2209
  const Oneresult = '1 result in 1 file';
2207
2210
  const OpenNewSearchEditor = 'Open New Search Editor';
2208
2211
  const PreserveCase$1 = 'Preserve Case';
2209
- const Refresh$1 = 'Refresh';
2212
+ const Refresh$2 = 'Refresh';
2210
2213
  const Replace = 'Replace';
2211
2214
  const ReplaceAll$1 = 'Replace All';
2212
2215
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
@@ -2219,7 +2222,7 @@ const ToggleReplace$1 = 'Toggle Replace';
2219
2222
  const ToggleSearchDetails$1 = 'Toggle Search Details';
2220
2223
  const UseExcludeSettings$1 = 'Use Exclude Settings';
2221
2224
  const UseRegularExpression$1 = 'Use Regular Expression';
2222
- const ViewAsTree = 'View as Tree';
2225
+ const ViewAsTree$1 = 'View as Tree';
2223
2226
  const TheResultSetOnlyContainsASubSetOfMatches = 'The result set only contains a subset of all matches. Be more specific in your search to narrow down the results.';
2224
2227
 
2225
2228
  const noResults = () => {
@@ -2341,7 +2344,7 @@ const copyAll = () => {
2341
2344
  return i18nString(CopyAll);
2342
2345
  };
2343
2346
  const refresh$1 = () => {
2344
- return i18nString(Refresh$1);
2347
+ return i18nString(Refresh$2);
2345
2348
  };
2346
2349
  const clearSearchResults = () => {
2347
2350
  return i18nString(ClearSearchResults);
@@ -2350,10 +2353,10 @@ const openNewSearchEditor = () => {
2350
2353
  return i18nString(OpenNewSearchEditor);
2351
2354
  };
2352
2355
  const viewAsTree$1 = () => {
2353
- return i18nString(ViewAsTree);
2356
+ return i18nString(ViewAsTree$1);
2354
2357
  };
2355
2358
  const collapseAll = () => {
2356
- return i18nString(CollapseAll$1);
2359
+ return i18nString(CollapseAll$2);
2357
2360
  };
2358
2361
  const filesToInclude = () => {
2359
2362
  return i18nString(FilesToInclude$1);
@@ -2810,6 +2813,33 @@ const getMenuEntryIds = () => {
2810
2813
  return [Search$1, InputContextMenu];
2811
2814
  };
2812
2815
 
2816
+ const ClearAll$1 = 'ClearAll';
2817
+ const CollapseAll$1 = 'CollapseAll';
2818
+ const FilesToExclude = 'FilesToExclude';
2819
+ const FilesToInclude = 'FilesToInclude';
2820
+ const MatchCase = 'MatchCase';
2821
+ const MatchWholeWord = 'MatchWholeWord';
2822
+ const PreserveCase = 'PreserveCase';
2823
+ const Remove = 'Remove';
2824
+ const ReplaceAll = 'ReplaceAll';
2825
+ const ReplaceValue = 'ReplaceValue';
2826
+ const SearchOnlyOpenEditors = 'SearchOnlyOpenEditors';
2827
+ const SearchValue = 'SearchValue';
2828
+ const ToggleReplace = 'ToggleReplace';
2829
+ const ToggleSearchDetails = 'ToggleSearchDetails';
2830
+ const UseExcludeSettings = 'UseExcludeSettings';
2831
+ const UseRegularExpression = 'UseRegularExpression';
2832
+ const Refresh$1 = 'Refresh';
2833
+ const OpenSearchEditor = 'OpenSearchEditor';
2834
+ const ViewAsTree = 'ViewAsTree';
2835
+
2836
+ const openSearchEditor = async state => {
2837
+ // TODO
2838
+ return {
2839
+ ...state
2840
+ };
2841
+ };
2842
+
2813
2843
  const handleError = error => {
2814
2844
  console.error(`[text-search-worker] ${error}`);
2815
2845
  };
@@ -3185,6 +3215,31 @@ const handleUpdate = async (state, update) => {
3185
3215
  }
3186
3216
  };
3187
3217
 
3218
+ const refresh = state => {
3219
+ return handleUpdate(state, {});
3220
+ };
3221
+
3222
+ const viewAsTree = async state => {
3223
+ return state;
3224
+ };
3225
+
3226
+ const handleActionClick = async (state, name) => {
3227
+ switch (name) {
3228
+ case ClearAll$1:
3229
+ return clearSearchResults$1(state);
3230
+ case CollapseAll$1:
3231
+ return collapseAll$1(state);
3232
+ case ViewAsTree:
3233
+ return viewAsTree(state);
3234
+ case Refresh$1:
3235
+ return refresh(state);
3236
+ case OpenSearchEditor:
3237
+ return openSearchEditor(state);
3238
+ default:
3239
+ return state;
3240
+ }
3241
+ };
3242
+
3188
3243
  const handleExcludeInput = (state, value, inputSource = Script) => {
3189
3244
  return handleUpdate(state, {
3190
3245
  excludeValue: value,
@@ -3192,21 +3247,6 @@ const handleExcludeInput = (state, value, inputSource = Script) => {
3192
3247
  });
3193
3248
  };
3194
3249
 
3195
- const FilesToExclude = 'FilesToExclude';
3196
- const FilesToInclude = 'FilesToInclude';
3197
- const MatchCase = 'MatchCase';
3198
- const MatchWholeWord = 'MatchWholeWord';
3199
- const PreserveCase = 'PreserveCase';
3200
- const ReplaceAll = 'ReplaceAll';
3201
- const ReplaceValue = 'ReplaceValue';
3202
- const SearchOnlyOpenEditors = 'SearchOnlyOpenEditors';
3203
- const SearchValue = 'SearchValue';
3204
- const ToggleReplace = 'ToggleReplace';
3205
- const ToggleSearchDetails = 'ToggleSearchDetails';
3206
- const UseExcludeSettings = 'UseExcludeSettings';
3207
- const UseRegularExpression = 'UseRegularExpression';
3208
- const Remove = 'Remove';
3209
-
3210
3250
  const noop = state => {
3211
3251
  return state;
3212
3252
  };
@@ -4264,7 +4304,10 @@ const handleClickAt = async (state, eventX, eventY, name) => {
4264
4304
  return selectIndex(state, index);
4265
4305
  };
4266
4306
 
4267
- const handleListPointerDown = async (state, button) => {
4307
+ const handleListPointerDown = async (state, button, name) => {
4308
+ if (name) {
4309
+ return state;
4310
+ }
4268
4311
  if (button !== LeftClick) {
4269
4312
  return state;
4270
4313
  }
@@ -4426,10 +4469,6 @@ const previousHistoryResult = async state => {
4426
4469
  };
4427
4470
  };
4428
4471
 
4429
- const refresh = state => {
4430
- return handleUpdate(state, {});
4431
- };
4432
-
4433
4472
  const removeCurrent = async state => {
4434
4473
  const {
4435
4474
  focusedIndex,
@@ -4641,6 +4680,7 @@ const HandleInputBlur = 18;
4641
4680
  const HandleListPointerDown = 19;
4642
4681
  const HandleInputContextMenu = 20;
4643
4682
  const HandleInputSelectionChange = 21;
4683
+ const HandleActionClick = 22;
4644
4684
 
4645
4685
  const getSearchDetailsToggleVirtualDom = () => {
4646
4686
  return [{
@@ -4660,7 +4700,7 @@ const getSearchDetailsToggleVirtualDom = () => {
4660
4700
  }];
4661
4701
  };
4662
4702
 
4663
- const getClassName = indented => {
4703
+ const getClassName$1 = indented => {
4664
4704
  if (indented) {
4665
4705
  return mergeClassNames(ViewletSearchMessage, ViewletSearchMessageIndented);
4666
4706
  }
@@ -4669,7 +4709,7 @@ const getClassName = indented => {
4669
4709
  const getSearchMessageVirtualDom = (message, indented) => {
4670
4710
  return [{
4671
4711
  type: Div,
4672
- className: getClassName(indented),
4712
+ className: getClassName$1(indented),
4673
4713
  role: Status,
4674
4714
  childCount: 1
4675
4715
  }, text(message)];
@@ -5332,17 +5372,25 @@ const getIconVirtualDom = (icon, type = Div) => {
5332
5372
  };
5333
5373
  };
5334
5374
 
5375
+ const getClassName = enabled => {
5376
+ if (enabled) {
5377
+ return IconButton;
5378
+ }
5379
+ return mergeClassNames(IconButton, IconButtonDisabled);
5380
+ };
5335
5381
  const getActionButtonVirtualDom = action => {
5336
5382
  const {
5337
5383
  id,
5338
5384
  icon,
5339
- command
5385
+ label,
5386
+ enabled
5340
5387
  } = action;
5388
+ const className = getClassName(enabled);
5341
5389
  return [{
5342
5390
  type: Button$2,
5343
- className: IconButton,
5344
- title: id,
5345
- 'data-command': command,
5391
+ className,
5392
+ title: label,
5393
+ name: id,
5346
5394
  childCount: 1
5347
5395
  }, getIconVirtualDom(icon)];
5348
5396
  };
@@ -5361,7 +5409,8 @@ const getActionsVirtualDom = actions => {
5361
5409
  type: Div,
5362
5410
  className: Actions,
5363
5411
  role: ToolBar,
5364
- childCount: actions.length
5412
+ childCount: actions.length,
5413
+ onClick: HandleActionClick
5365
5414
  }, ...actions.flatMap(getActionVirtualDom)];
5366
5415
  };
5367
5416
 
@@ -5371,37 +5420,52 @@ const ListFlat = 'ListFlat';
5371
5420
  const NewFile = 'NewFile';
5372
5421
  const Refresh = 'Refresh';
5373
5422
 
5374
- const getActions = () => {
5423
+ const getActions = state => {
5424
+ const {
5425
+ value,
5426
+ replacement
5427
+ } = state;
5428
+ const bothEmpty = value === '' && replacement === '';
5375
5429
  return [{
5376
5430
  type: Button,
5377
- id: refresh$1(),
5431
+ label: refresh$1(),
5378
5432
  icon: Refresh,
5379
- command: 'refresh'
5433
+ id: Refresh$1,
5434
+ command: 'refresh',
5435
+ enabled: true
5380
5436
  }, {
5381
5437
  type: Button,
5382
- id: clearSearchResults(),
5438
+ label: clearSearchResults(),
5383
5439
  icon: ClearAll,
5384
- command: 'clearSearchResults'
5440
+ command: 'clearSearchResults',
5441
+ id: ClearAll$1,
5442
+ enabled: !bothEmpty
5385
5443
  }, {
5386
5444
  type: Button,
5387
- id: openNewSearchEditor(),
5445
+ label: openNewSearchEditor(),
5388
5446
  icon: NewFile,
5389
- command: ''
5447
+ command: '',
5448
+ id: OpenSearchEditor,
5449
+ enabled: true
5390
5450
  }, {
5391
5451
  type: Button,
5392
- id: viewAsTree$1(),
5452
+ label: viewAsTree$1(),
5393
5453
  icon: ListFlat,
5394
- command: ''
5454
+ command: '',
5455
+ id: ViewAsTree,
5456
+ enabled: true
5395
5457
  }, {
5396
5458
  type: Button,
5397
- id: collapseAll(),
5459
+ label: collapseAll(),
5398
5460
  icon: CollapseAll,
5399
- command: ''
5461
+ command: '',
5462
+ id: CollapseAll$1,
5463
+ enabled: true
5400
5464
  }];
5401
5465
  };
5402
5466
 
5403
- const renderActions = uid => {
5404
- const actions = getActions();
5467
+ const renderActions = state => {
5468
+ const actions = getActions(state);
5405
5469
  const dom = getActionsVirtualDom(actions);
5406
5470
  return dom;
5407
5471
  };
@@ -5424,7 +5488,7 @@ const renderEventListeners = () => {
5424
5488
  params: ['handleClickAt', ClientX, ClientY, TargetName]
5425
5489
  }, {
5426
5490
  name: HandleListPointerDown,
5427
- params: ['handleListPointerDown', Button$1]
5491
+ params: ['handleListPointerDown', Button$1, TargetName]
5428
5492
  }, {
5429
5493
  name: HandleToggleButtonClick,
5430
5494
  params: ['handleToggleButtonClick']
@@ -5442,6 +5506,9 @@ const renderEventListeners = () => {
5442
5506
  name: HandleInputContextMenu,
5443
5507
  params: ['handleInputContextMenu', TargetName, Button$1, ClientX, ClientY],
5444
5508
  preventDefault: true
5509
+ }, {
5510
+ name: HandleActionClick,
5511
+ params: ['handleActionClick', TargetName]
5445
5512
  }, {
5446
5513
  name: HandleInputSelectionChange,
5447
5514
  params: ['handleInputSelectionChange', TargetName, TargetSelectionStart, TargetSelectionEnd]
@@ -5658,10 +5725,6 @@ const submit = state => {
5658
5725
  });
5659
5726
  };
5660
5727
 
5661
- const viewAsTree = async state => {
5662
- return state;
5663
- };
5664
-
5665
5728
  const Keyboard = -1;
5666
5729
 
5667
5730
  const handleContextMenuKeyboard = async state => {
@@ -5745,7 +5808,6 @@ const commandMap = {
5745
5808
  'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
5746
5809
  'TextSearch.focusRegex': wrapCommand(focusRegex),
5747
5810
  'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
5748
- 'TextSearch.replaceAllInFile': wrapCommand(replaceAllInFile),
5749
5811
  'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
5750
5812
  'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
5751
5813
  'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
@@ -5753,6 +5815,7 @@ const commandMap = {
5753
5815
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
5754
5816
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
5755
5817
  'TextSearch.getMenuEntries': wrapGetter(getMenuEntries),
5818
+ 'TextSearch.handleActionClick': wrapCommand(handleActionClick),
5756
5819
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
5757
5820
  'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
5758
5821
  'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
@@ -5784,11 +5847,13 @@ const commandMap = {
5784
5847
  'TextSearch.handleWheel': wrapCommand(handleWheel),
5785
5848
  'TextSearch.loadContent': wrapCommand(loadContent),
5786
5849
  'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
5850
+ 'TextSearch.openSearchEditor': wrapCommand(openSearchEditor),
5787
5851
  'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
5788
5852
  'TextSearch.refresh': wrapCommand(refresh),
5789
5853
  'TextSearch.removeCurrent': wrapCommand(removeCurrent),
5790
5854
  'TextSearch.removeIndex': wrapCommand(removeIndex),
5791
5855
  'TextSearch.replaceAll': wrapCommand(replaceAll),
5856
+ 'TextSearch.replaceAllInFile': wrapCommand(replaceAllInFile),
5792
5857
  'TextSearch.rerender': rerender,
5793
5858
  'TextSearch.selectIndex': wrapCommand(selectIndex),
5794
5859
  'TextSearch.setLimit': wrapCommand(setLimit),
@@ -5812,8 +5877,8 @@ const commandMap = {
5812
5877
  'TextSearch.renderIncremental': renderIncremental,
5813
5878
  'TextSearch.restoreState': restoreState,
5814
5879
  'TextSearch.saveState': wrapGetter(saveState),
5880
+ 'TextSearch.renderActions': wrapGetter(renderActions),
5815
5881
  'TextSearch.terminate': terminate,
5816
- 'TextSearch.renderActions': renderActions,
5817
5882
  'TextSearch.getMenuEntryIds': getMenuEntryIds,
5818
5883
  // TODO needed?
5819
5884
  'TextSearch.replaceAllAndPrompt': replaceAllAndPrompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "5.31.0",
3
+ "version": "5.32.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"