@lvce-editor/text-search-worker 5.30.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';
@@ -1205,7 +1206,7 @@ const Viewlet = 'Viewlet';
1205
1206
  const ViewletSearchMessage = 'ViewletSearchMessage';
1206
1207
  const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1207
1208
 
1208
- const File$1 = 7;
1209
+ const File$2 = 7;
1209
1210
 
1210
1211
  const Button$2 = 1;
1211
1212
  const Div = 4;
@@ -1244,6 +1245,7 @@ const RendererWorker = 1;
1244
1245
  const SearchProcess = 77;
1245
1246
  const IconThemeWorker = 7009;
1246
1247
 
1248
+ const File$1 = 1;
1247
1249
  const Match$1 = 2;
1248
1250
 
1249
1251
  const FocusElementByName = 'Viewlet.focusElementByName';
@@ -1393,10 +1395,11 @@ const create$2 = () => {
1393
1395
  wrapCommand(fn) {
1394
1396
  const wrapped = async (uid, ...args) => {
1395
1397
  const {
1398
+ oldState,
1396
1399
  newState
1397
1400
  } = states[uid];
1398
1401
  const newerState = await fn(newState, ...args);
1399
- if (newState === newerState) {
1402
+ if (oldState === newerState || newState === newerState) {
1400
1403
  return;
1401
1404
  }
1402
1405
  const latest = states[uid];
@@ -1677,14 +1680,15 @@ const Script = 2;
1677
1680
  const clearSearchResults$1 = state => {
1678
1681
  return {
1679
1682
  ...state,
1680
- value: '',
1683
+ focus: FocusSearchInput,
1684
+ focusSource: Script,
1685
+ inputSource: Script,
1681
1686
  items: [],
1682
- minLineY: 0,
1683
1687
  maxLineY: 0,
1684
1688
  message: '',
1685
- focus: FocusSearchInput,
1686
- focusSource: Script,
1687
- inputSource: Script
1689
+ minLineY: 0,
1690
+ replacement: '',
1691
+ value: ''
1688
1692
  };
1689
1693
  };
1690
1694
 
@@ -1994,7 +1998,7 @@ const toIconRequest = item => {
1994
1998
  const filePath = getFilePath(item.text);
1995
1999
  const fileName = getFileName(filePath);
1996
2000
  return {
1997
- type: File$1,
2001
+ type: File$2,
1998
2002
  name: fileName,
1999
2003
  path: filePath
2000
2004
  };
@@ -2178,7 +2182,7 @@ const i18nString = (key, placeholders = emptyObject) => {
2178
2182
  };
2179
2183
 
2180
2184
  const ClearSearchResults = 'Clear Search Results';
2181
- const CollapseAll$1 = 'Collapse All';
2185
+ const CollapseAll$2 = 'Collapse All';
2182
2186
  const ConfirmReplaceManyOccurrencesInManyFiles = "Replace {PH1} occurrences across {PH2} files with '{PH3}'";
2183
2187
  const ConfirmReplaceManyOccurrencesInManyFilesNoValue = 'Replace {PH1} occurrences across {PH2} files';
2184
2188
  const ConfirmReplaceManyOccurrencesInOneFile = "Replace {PH1} occurrences across 1 file with '{PH2}'";
@@ -2205,7 +2209,7 @@ const NoResults = 'No results found';
2205
2209
  const Oneresult = '1 result in 1 file';
2206
2210
  const OpenNewSearchEditor = 'Open New Search Editor';
2207
2211
  const PreserveCase$1 = 'Preserve Case';
2208
- const Refresh$1 = 'Refresh';
2212
+ const Refresh$2 = 'Refresh';
2209
2213
  const Replace = 'Replace';
2210
2214
  const ReplaceAll$1 = 'Replace All';
2211
2215
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
@@ -2218,7 +2222,7 @@ const ToggleReplace$1 = 'Toggle Replace';
2218
2222
  const ToggleSearchDetails$1 = 'Toggle Search Details';
2219
2223
  const UseExcludeSettings$1 = 'Use Exclude Settings';
2220
2224
  const UseRegularExpression$1 = 'Use Regular Expression';
2221
- const ViewAsTree = 'View as Tree';
2225
+ const ViewAsTree$1 = 'View as Tree';
2222
2226
  const TheResultSetOnlyContainsASubSetOfMatches = 'The result set only contains a subset of all matches. Be more specific in your search to narrow down the results.';
2223
2227
 
2224
2228
  const noResults = () => {
@@ -2340,7 +2344,7 @@ const copyAll = () => {
2340
2344
  return i18nString(CopyAll);
2341
2345
  };
2342
2346
  const refresh$1 = () => {
2343
- return i18nString(Refresh$1);
2347
+ return i18nString(Refresh$2);
2344
2348
  };
2345
2349
  const clearSearchResults = () => {
2346
2350
  return i18nString(ClearSearchResults);
@@ -2349,10 +2353,10 @@ const openNewSearchEditor = () => {
2349
2353
  return i18nString(OpenNewSearchEditor);
2350
2354
  };
2351
2355
  const viewAsTree$1 = () => {
2352
- return i18nString(ViewAsTree);
2356
+ return i18nString(ViewAsTree$1);
2353
2357
  };
2354
2358
  const collapseAll = () => {
2355
- return i18nString(CollapseAll$1);
2359
+ return i18nString(CollapseAll$2);
2356
2360
  };
2357
2361
  const filesToInclude = () => {
2358
2362
  return i18nString(FilesToInclude$1);
@@ -2727,7 +2731,7 @@ const getMenuEntriesInput = options => {
2727
2731
  }];
2728
2732
  };
2729
2733
 
2730
- const getMenuEntriesList = (state, props) => {
2734
+ const getMenuEntriesFile = (state, props) => {
2731
2735
  return [{
2732
2736
  id: 'replaceAll',
2733
2737
  label: replaceAll$1(),
@@ -2756,9 +2760,48 @@ const getMenuEntriesList = (state, props) => {
2756
2760
  }];
2757
2761
  };
2758
2762
 
2763
+ const getMenuEntriesMatch = (state, props) => {
2764
+ return [{
2765
+ id: 'dismiss',
2766
+ label: dismiss(),
2767
+ flags: None$1,
2768
+ command: 'Search.removeCurrent'
2769
+ }, {
2770
+ id: 'copy',
2771
+ label: copy(),
2772
+ flags: None$1,
2773
+ command: 'Search.copy'
2774
+ }, {
2775
+ id: 'copyAll',
2776
+ label: copyAll(),
2777
+ flags: None$1,
2778
+ command: 'Search.copyAll'
2779
+ }];
2780
+ };
2781
+
2782
+ const getMenuEntriesList = (state, props) => {
2783
+ const {
2784
+ items
2785
+ } = state;
2786
+ const {
2787
+ index
2788
+ } = props;
2789
+ const item = items[index];
2790
+ if (!item) {
2791
+ return [];
2792
+ }
2793
+ if (item.type === Match$1) {
2794
+ return getMenuEntriesMatch();
2795
+ }
2796
+ if (item.type === File$1) {
2797
+ return getMenuEntriesFile();
2798
+ }
2799
+ return [];
2800
+ };
2801
+
2759
2802
  const getMenuEntries = (state, props) => {
2760
2803
  if (props.menuId === Search$1) {
2761
- return getMenuEntriesList();
2804
+ return getMenuEntriesList(state, props);
2762
2805
  }
2763
2806
  if (props.menuId === InputContextMenu) {
2764
2807
  return getMenuEntriesInput(props);
@@ -2770,6 +2813,33 @@ const getMenuEntryIds = () => {
2770
2813
  return [Search$1, InputContextMenu];
2771
2814
  };
2772
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
+
2773
2843
  const handleError = error => {
2774
2844
  console.error(`[text-search-worker] ${error}`);
2775
2845
  };
@@ -3145,6 +3215,31 @@ const handleUpdate = async (state, update) => {
3145
3215
  }
3146
3216
  };
3147
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
+
3148
3243
  const handleExcludeInput = (state, value, inputSource = Script) => {
3149
3244
  return handleUpdate(state, {
3150
3245
  excludeValue: value,
@@ -3152,21 +3247,6 @@ const handleExcludeInput = (state, value, inputSource = Script) => {
3152
3247
  });
3153
3248
  };
3154
3249
 
3155
- const FilesToExclude = 'FilesToExclude';
3156
- const FilesToInclude = 'FilesToInclude';
3157
- const MatchCase = 'MatchCase';
3158
- const MatchWholeWord = 'MatchWholeWord';
3159
- const PreserveCase = 'PreserveCase';
3160
- const ReplaceAll = 'ReplaceAll';
3161
- const ReplaceValue = 'ReplaceValue';
3162
- const SearchOnlyOpenEditors = 'SearchOnlyOpenEditors';
3163
- const SearchValue = 'SearchValue';
3164
- const ToggleReplace = 'ToggleReplace';
3165
- const ToggleSearchDetails = 'ToggleSearchDetails';
3166
- const UseExcludeSettings = 'UseExcludeSettings';
3167
- const UseRegularExpression = 'UseRegularExpression';
3168
- const Remove = 'Remove';
3169
-
3170
3250
  const noop = state => {
3171
3251
  return state;
3172
3252
  };
@@ -4224,7 +4304,10 @@ const handleClickAt = async (state, eventX, eventY, name) => {
4224
4304
  return selectIndex(state, index);
4225
4305
  };
4226
4306
 
4227
- const handleListPointerDown = async (state, button) => {
4307
+ const handleListPointerDown = async (state, button, name) => {
4308
+ if (name) {
4309
+ return state;
4310
+ }
4228
4311
  if (button !== LeftClick) {
4229
4312
  return state;
4230
4313
  }
@@ -4386,10 +4469,6 @@ const previousHistoryResult = async state => {
4386
4469
  };
4387
4470
  };
4388
4471
 
4389
- const refresh = state => {
4390
- return handleUpdate(state, {});
4391
- };
4392
-
4393
4472
  const removeCurrent = async state => {
4394
4473
  const {
4395
4474
  focusedIndex,
@@ -4601,6 +4680,7 @@ const HandleInputBlur = 18;
4601
4680
  const HandleListPointerDown = 19;
4602
4681
  const HandleInputContextMenu = 20;
4603
4682
  const HandleInputSelectionChange = 21;
4683
+ const HandleActionClick = 22;
4604
4684
 
4605
4685
  const getSearchDetailsToggleVirtualDom = () => {
4606
4686
  return [{
@@ -4620,7 +4700,7 @@ const getSearchDetailsToggleVirtualDom = () => {
4620
4700
  }];
4621
4701
  };
4622
4702
 
4623
- const getClassName = indented => {
4703
+ const getClassName$1 = indented => {
4624
4704
  if (indented) {
4625
4705
  return mergeClassNames(ViewletSearchMessage, ViewletSearchMessageIndented);
4626
4706
  }
@@ -4629,7 +4709,7 @@ const getClassName = indented => {
4629
4709
  const getSearchMessageVirtualDom = (message, indented) => {
4630
4710
  return [{
4631
4711
  type: Div,
4632
- className: getClassName(indented),
4712
+ className: getClassName$1(indented),
4633
4713
  role: Status,
4634
4714
  childCount: 1
4635
4715
  }, text(message)];
@@ -5292,17 +5372,25 @@ const getIconVirtualDom = (icon, type = Div) => {
5292
5372
  };
5293
5373
  };
5294
5374
 
5375
+ const getClassName = enabled => {
5376
+ if (enabled) {
5377
+ return IconButton;
5378
+ }
5379
+ return mergeClassNames(IconButton, IconButtonDisabled);
5380
+ };
5295
5381
  const getActionButtonVirtualDom = action => {
5296
5382
  const {
5297
5383
  id,
5298
5384
  icon,
5299
- command
5385
+ label,
5386
+ enabled
5300
5387
  } = action;
5388
+ const className = getClassName(enabled);
5301
5389
  return [{
5302
5390
  type: Button$2,
5303
- className: IconButton,
5304
- title: id,
5305
- 'data-command': command,
5391
+ className,
5392
+ title: label,
5393
+ name: id,
5306
5394
  childCount: 1
5307
5395
  }, getIconVirtualDom(icon)];
5308
5396
  };
@@ -5321,7 +5409,8 @@ const getActionsVirtualDom = actions => {
5321
5409
  type: Div,
5322
5410
  className: Actions,
5323
5411
  role: ToolBar,
5324
- childCount: actions.length
5412
+ childCount: actions.length,
5413
+ onClick: HandleActionClick
5325
5414
  }, ...actions.flatMap(getActionVirtualDom)];
5326
5415
  };
5327
5416
 
@@ -5331,37 +5420,52 @@ const ListFlat = 'ListFlat';
5331
5420
  const NewFile = 'NewFile';
5332
5421
  const Refresh = 'Refresh';
5333
5422
 
5334
- const getActions = () => {
5423
+ const getActions = state => {
5424
+ const {
5425
+ value,
5426
+ replacement
5427
+ } = state;
5428
+ const bothEmpty = value === '' && replacement === '';
5335
5429
  return [{
5336
5430
  type: Button,
5337
- id: refresh$1(),
5431
+ label: refresh$1(),
5338
5432
  icon: Refresh,
5339
- command: 'refresh'
5433
+ id: Refresh$1,
5434
+ command: 'refresh',
5435
+ enabled: true
5340
5436
  }, {
5341
5437
  type: Button,
5342
- id: clearSearchResults(),
5438
+ label: clearSearchResults(),
5343
5439
  icon: ClearAll,
5344
- command: 'clearSearchResults'
5440
+ command: 'clearSearchResults',
5441
+ id: ClearAll$1,
5442
+ enabled: !bothEmpty
5345
5443
  }, {
5346
5444
  type: Button,
5347
- id: openNewSearchEditor(),
5445
+ label: openNewSearchEditor(),
5348
5446
  icon: NewFile,
5349
- command: ''
5447
+ command: '',
5448
+ id: OpenSearchEditor,
5449
+ enabled: true
5350
5450
  }, {
5351
5451
  type: Button,
5352
- id: viewAsTree$1(),
5452
+ label: viewAsTree$1(),
5353
5453
  icon: ListFlat,
5354
- command: ''
5454
+ command: '',
5455
+ id: ViewAsTree,
5456
+ enabled: true
5355
5457
  }, {
5356
5458
  type: Button,
5357
- id: collapseAll(),
5459
+ label: collapseAll(),
5358
5460
  icon: CollapseAll,
5359
- command: ''
5461
+ command: '',
5462
+ id: CollapseAll$1,
5463
+ enabled: true
5360
5464
  }];
5361
5465
  };
5362
5466
 
5363
- const renderActions = uid => {
5364
- const actions = getActions();
5467
+ const renderActions = state => {
5468
+ const actions = getActions(state);
5365
5469
  const dom = getActionsVirtualDom(actions);
5366
5470
  return dom;
5367
5471
  };
@@ -5384,7 +5488,7 @@ const renderEventListeners = () => {
5384
5488
  params: ['handleClickAt', ClientX, ClientY, TargetName]
5385
5489
  }, {
5386
5490
  name: HandleListPointerDown,
5387
- params: ['handleListPointerDown', Button$1]
5491
+ params: ['handleListPointerDown', Button$1, TargetName]
5388
5492
  }, {
5389
5493
  name: HandleToggleButtonClick,
5390
5494
  params: ['handleToggleButtonClick']
@@ -5402,6 +5506,9 @@ const renderEventListeners = () => {
5402
5506
  name: HandleInputContextMenu,
5403
5507
  params: ['handleInputContextMenu', TargetName, Button$1, ClientX, ClientY],
5404
5508
  preventDefault: true
5509
+ }, {
5510
+ name: HandleActionClick,
5511
+ params: ['handleActionClick', TargetName]
5405
5512
  }, {
5406
5513
  name: HandleInputSelectionChange,
5407
5514
  params: ['handleInputSelectionChange', TargetName, TargetSelectionStart, TargetSelectionEnd]
@@ -5618,10 +5725,6 @@ const submit = state => {
5618
5725
  });
5619
5726
  };
5620
5727
 
5621
- const viewAsTree = async state => {
5622
- return state;
5623
- };
5624
-
5625
5728
  const Keyboard = -1;
5626
5729
 
5627
5730
  const handleContextMenuKeyboard = async state => {
@@ -5631,7 +5734,8 @@ const handleContextMenuKeyboard = async state => {
5631
5734
  uid
5632
5735
  } = state; // TODO
5633
5736
  await show2(uid, Search$1, x, y, {
5634
- menuId: Search$1
5737
+ menuId: Search$1,
5738
+ index: 0 // TODO pass proper index
5635
5739
  });
5636
5740
  return state;
5637
5741
  };
@@ -5648,6 +5752,15 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
5648
5752
  } = state;
5649
5753
  const topHeight = getTopHeight(flags);
5650
5754
  const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
5755
+ const {
5756
+ oldState,
5757
+ newState
5758
+ } = get$1(uid);
5759
+ set(uid, oldState, {
5760
+ ...newState,
5761
+ listFocusedIndex: index,
5762
+ focusedIndex: index
5763
+ });
5651
5764
  await show2(uid, Search$1, x, y, {
5652
5765
  menuId: Search$1,
5653
5766
  index
@@ -5695,7 +5808,6 @@ const commandMap = {
5695
5808
  'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
5696
5809
  'TextSearch.focusRegex': wrapCommand(focusRegex),
5697
5810
  'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
5698
- 'TextSearch.replaceAllInFile': wrapCommand(replaceAllInFile),
5699
5811
  'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
5700
5812
  'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
5701
5813
  'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
@@ -5703,6 +5815,7 @@ const commandMap = {
5703
5815
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
5704
5816
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
5705
5817
  'TextSearch.getMenuEntries': wrapGetter(getMenuEntries),
5818
+ 'TextSearch.handleActionClick': wrapCommand(handleActionClick),
5706
5819
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
5707
5820
  'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
5708
5821
  'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
@@ -5734,11 +5847,13 @@ const commandMap = {
5734
5847
  'TextSearch.handleWheel': wrapCommand(handleWheel),
5735
5848
  'TextSearch.loadContent': wrapCommand(loadContent),
5736
5849
  'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
5850
+ 'TextSearch.openSearchEditor': wrapCommand(openSearchEditor),
5737
5851
  'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
5738
5852
  'TextSearch.refresh': wrapCommand(refresh),
5739
5853
  'TextSearch.removeCurrent': wrapCommand(removeCurrent),
5740
5854
  'TextSearch.removeIndex': wrapCommand(removeIndex),
5741
5855
  'TextSearch.replaceAll': wrapCommand(replaceAll),
5856
+ 'TextSearch.replaceAllInFile': wrapCommand(replaceAllInFile),
5742
5857
  'TextSearch.rerender': rerender,
5743
5858
  'TextSearch.selectIndex': wrapCommand(selectIndex),
5744
5859
  'TextSearch.setLimit': wrapCommand(setLimit),
@@ -5762,8 +5877,8 @@ const commandMap = {
5762
5877
  'TextSearch.renderIncremental': renderIncremental,
5763
5878
  'TextSearch.restoreState': restoreState,
5764
5879
  'TextSearch.saveState': wrapGetter(saveState),
5880
+ 'TextSearch.renderActions': wrapGetter(renderActions),
5765
5881
  'TextSearch.terminate': terminate,
5766
- 'TextSearch.renderActions': renderActions,
5767
5882
  'TextSearch.getMenuEntryIds': getMenuEntryIds,
5768
5883
  // TODO needed?
5769
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.30.0",
3
+ "version": "5.32.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"