@lvce-editor/text-search-worker 3.8.0 → 3.10.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.
@@ -799,6 +799,19 @@ const WebWorkerRpcClient = {
799
799
  create: create$1$1
800
800
  };
801
801
 
802
+ const Empty$1 = 0;
803
+ const FocusSearchInput = 21;
804
+ const FocusSearchReplaceInput = 31;
805
+ const FocusSearchMatchCase = 32;
806
+ const FocusSearchRegex = 33;
807
+ const FocusSearchWholeWord = 34;
808
+ const FocusSearchReplaceAll = 35;
809
+ const FocusSearchPreserveCase = 36;
810
+ const FocusSearchIncludeInput = 1007;
811
+
812
+ const User = 1;
813
+ const Script = 2;
814
+
802
815
  const clearSearchResults$1 = state => {
803
816
  return {
804
817
  ...state,
@@ -806,7 +819,9 @@ const clearSearchResults$1 = state => {
806
819
  items: [],
807
820
  minLineY: 0,
808
821
  maxLineY: 0,
809
- message: ''
822
+ message: '',
823
+ focus: FocusSearchInput,
824
+ focusSource: Script
810
825
  };
811
826
  };
812
827
 
@@ -835,9 +850,6 @@ const copy = async state => {
835
850
  return state;
836
851
  };
837
852
 
838
- const User = 1;
839
- const Script = 2;
840
-
841
853
  const minimumSliderSize = 20;
842
854
 
843
855
  const states = Object.create(null);
@@ -874,15 +886,6 @@ const create$1 = ({
874
886
  };
875
887
  };
876
888
 
877
- const Empty$1 = 0;
878
- const FocusSearchInput = 21;
879
- const FocusSearchReplaceInput = 31;
880
- const FocusSearchMatchCase = 32;
881
- const FocusSearchRegex = 33;
882
- const FocusSearchWholeWord = 34;
883
- const FocusSearchReplaceAll = 35;
884
- const FocusSearchPreserveCase = 36;
885
-
886
889
  const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '') => {
887
890
  const state = {
888
891
  uid,
@@ -1061,7 +1064,10 @@ const UiStrings = {
1061
1064
  UseRegularExpression: 'Use Regular Expression',
1062
1065
  ViewAsTree: 'View as Tree',
1063
1066
  FilesToInclude: 'Files to Include',
1064
- FilesToExclude: 'Files to Exclude'
1067
+ FilesToExclude: 'Files to Exclude',
1068
+ ToggleSearchDetails: 'Toggle Search Details',
1069
+ SearchOnlyOpenEditors: 'Search Only Open Editors',
1070
+ UseExcludeSettings: 'Use Exclude Settings'
1065
1071
  };
1066
1072
  const noResults = () => {
1067
1073
  return i18nString(UiStrings.NoResults);
@@ -1081,6 +1087,9 @@ const preserveCase = () => {
1081
1087
  const matchWholeWord = () => {
1082
1088
  return i18nString(UiStrings.MatchWholeWord);
1083
1089
  };
1090
+ const toggleSearchDetails = () => {
1091
+ return i18nString(UiStrings.ToggleSearchDetails);
1092
+ };
1084
1093
  const useRegularExpression = () => {
1085
1094
  return i18nString(UiStrings.UseRegularExpression);
1086
1095
  };
@@ -1159,6 +1168,12 @@ const filesToInclude = () => {
1159
1168
  const filesToExclude = () => {
1160
1169
  return i18nString(UiStrings.FilesToExclude);
1161
1170
  };
1171
+ const searchOnlyOpenEditors = () => {
1172
+ return i18nString(UiStrings.SearchOnlyOpenEditors);
1173
+ };
1174
+ const useExcludeSettings = () => {
1175
+ return i18nString(UiStrings.UseExcludeSettings);
1176
+ };
1162
1177
 
1163
1178
  const getStatusMessage = (resultCount, fileResultCount) => {
1164
1179
  number(resultCount);
@@ -1332,6 +1347,8 @@ const ReplaceExpanded = 1 << 2; // 4
1332
1347
  const MatchWholeWord = 1 << 3; // 8
1333
1348
  const MatchCase = 1 << 4; // 16
1334
1349
  const DetailsExpanded = 1 << 5; // 32
1350
+ const OpenEditors = 1 << 6; // 64
1351
+ const UseIgnoreFiles = 1 << 7; // 128
1335
1352
 
1336
1353
  const hasPreserveCase = flags => {
1337
1354
  return (flags & PreserveCase) === PreserveCase;
@@ -1348,6 +1365,9 @@ const hasMatchWholeWord = flags => {
1348
1365
  const hasMatchCase = flags => {
1349
1366
  return (flags & MatchCase) === MatchCase;
1350
1367
  };
1368
+ const hasDetailsExpanded = flags => {
1369
+ return (flags & DetailsExpanded) === DetailsExpanded;
1370
+ };
1351
1371
 
1352
1372
  const focusSearchValueNext = state => {
1353
1373
  if (hasReplaceExpanded(state.flags)) {
@@ -1375,15 +1395,16 @@ const Grow = 'Grow';
1375
1395
  const Highlight = 'Highlight';
1376
1396
  const HighlightDeleted = 'HighlightDeleted';
1377
1397
  const HighlightInserted = 'HighlightInserted';
1378
- const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1379
1398
  const IconButton = 'IconButton';
1380
1399
  const Label = 'Label';
1381
1400
  const List = 'List';
1382
1401
  const MaskIcon = 'MaskIcon';
1402
+ const MaskIconBook = 'MaskIconBook';
1383
1403
  const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1384
1404
  const MaskIconChevronDown = 'MaskIconChevronDown';
1385
1405
  const MaskIconChevronRight = 'MaskIconChevronRight';
1386
1406
  const MaskIconEllipsis = 'MaskIconEllipsis';
1407
+ const MaskIconExclude = 'MaskIconExclude';
1387
1408
  const MaskIconPreserveCase = 'MaskIconPreserveCase';
1388
1409
  const MaskIconRegex = 'MaskIconRegex';
1389
1410
  const MaskIconReplaceAll = 'MaskIconReplaceAll';
@@ -1397,6 +1418,9 @@ const SearchFieldButtons = 'SearchFieldButtons';
1397
1418
  const SearchFieldContainer = 'SearchFieldContainer';
1398
1419
  const SearchHeader = 'SearchHeader';
1399
1420
  const SearchHeaderDetails = 'SearchHeaderDetails';
1421
+ const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1422
+ const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1423
+ const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1400
1424
  const SearchHeaderTop = 'SearchHeaderTop';
1401
1425
  const SearchHeaderTopRight = 'SearchHeaderTopRight';
1402
1426
  const SearchRemove = 'SearchRemove';
@@ -1412,12 +1436,13 @@ const ViewletSearchMessage = 'ViewletSearchMessage';
1412
1436
  const Button$1 = 1;
1413
1437
 
1414
1438
  const Button = 1;
1439
+ const Del = 21;
1415
1440
  const Div = 4;
1416
- const Span = 8;
1417
- const Text = 12;
1441
+ const H4 = 24;
1418
1442
  const Img = 17;
1419
1443
  const Ins = 20;
1420
- const Del = 21;
1444
+ const Span = 8;
1445
+ const Text = 12;
1421
1446
  const TextArea = 62;
1422
1447
 
1423
1448
  const mergeClassNames = (...classNames) => {
@@ -1616,8 +1641,8 @@ const getSearchDetailsToggleVirtualDom = () => {
1616
1641
  className: ToggleDetails,
1617
1642
  role: Button$2,
1618
1643
  tabIndex: 0,
1619
- ariaLabel: 'Toggle Search Details',
1620
- title: 'Toggle Search Details',
1644
+ ariaLabel: toggleSearchDetails(),
1645
+ title: toggleSearchDetails(),
1621
1646
  childCount: 1
1622
1647
  }, {
1623
1648
  type: Div,
@@ -1720,11 +1745,35 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
1720
1745
  };
1721
1746
 
1722
1747
  const getSearchHeaderDetailsExpandedVirtualDom = message => {
1748
+ const includeButtons = [{
1749
+ icon: MaskIconBook,
1750
+ title: searchOnlyOpenEditors(),
1751
+ command: 'searchOnlyOpenEditors',
1752
+ checked: false
1753
+ }];
1754
+ const excludeButtons = [{
1755
+ icon: MaskIconExclude,
1756
+ title: useExcludeSettings(),
1757
+ command: 'toggleUseExcludeSettings',
1758
+ checked: false
1759
+ }];
1723
1760
  return [{
1724
1761
  type: Div,
1725
1762
  className: SearchHeaderDetailsExpanded,
1726
- childCount: 6
1727
- }, ...getSearchDetailsToggleVirtualDom(), text(filesToInclude()), ...getSearchFieldVirtualDom('files-to-include-value', 'Include', 'handleIncludeInput', [], []), text(filesToExclude()), ...getSearchFieldVirtualDom('files-to-exclude-value', 'Exclude', 'handleExcludeInput', [], []), ...getSearchMessageVirtualDom(message)];
1763
+ childCount: 5
1764
+ }, {
1765
+ type: Div,
1766
+ className: SearchHeaderDetailsExpandedTop,
1767
+ childCount: 2
1768
+ }, ...getSearchDetailsToggleVirtualDom(), {
1769
+ type: H4,
1770
+ className: SearchHeaderDetailsHeading,
1771
+ childCount: 1
1772
+ }, text(filesToInclude()), ...getSearchFieldVirtualDom('files-to-include-value', 'Include', 'handleIncludeInput', includeButtons, []), {
1773
+ type: H4,
1774
+ className: SearchHeaderDetailsHeading,
1775
+ childCount: 1
1776
+ }, text(filesToExclude()), ...getSearchFieldVirtualDom('files-to-exclude-value', 'Exclude', 'handleExcludeInput', excludeButtons, []), ...getSearchMessageVirtualDom(message)];
1728
1777
  };
1729
1778
 
1730
1779
  const getSearchHeaderDetailsVirtualDom = (flags, message) => {
@@ -2774,12 +2823,21 @@ const handleReplaceInput = (state, value, inputSource = Script) => {
2774
2823
  });
2775
2824
  };
2776
2825
 
2826
+ const handleExcludeInput = (state, value, inputSource = Script) => {
2827
+ return handleUpdate(state, {
2828
+ excludeValue: value,
2829
+ inputSource
2830
+ });
2831
+ };
2832
+
2777
2833
  const getInputHandler = name => {
2778
2834
  switch (name) {
2779
2835
  case 'search-value':
2780
2836
  return handleInput;
2781
2837
  case 'replacement-value':
2782
2838
  return handleReplaceInput;
2839
+ case 'files-to-exclude-value':
2840
+ return handleExcludeInput;
2783
2841
  default:
2784
2842
  throw new Error(`unknown input handler: ${name}`);
2785
2843
  }
@@ -2790,6 +2848,14 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
2790
2848
  return fn(state, value, inputSource);
2791
2849
  };
2792
2850
 
2851
+ const handleIncludeInput = (state, includeValue) => {
2852
+ return {
2853
+ ...state,
2854
+ includeValue,
2855
+ focusSource: User
2856
+ };
2857
+ };
2858
+
2793
2859
  const first = () => {
2794
2860
  return 0;
2795
2861
  };
@@ -3135,13 +3201,27 @@ const getSavedFlags = savedState => {
3135
3201
  }
3136
3202
  return 0;
3137
3203
  };
3204
+ const getSavedIncludeValue = savedState => {
3205
+ if (savedState && typeof savedState === 'object' && 'includeValue' in savedState && typeof savedState.includeValue === 'string') {
3206
+ return savedState.includeValue;
3207
+ }
3208
+ return '';
3209
+ };
3210
+ const getSavedExcludeValue = savedState => {
3211
+ if (savedState && typeof savedState === 'object' && 'excludeValue' in savedState && typeof savedState.excludeValue === 'string') {
3212
+ return savedState.excludeValue;
3213
+ }
3214
+ return '';
3215
+ };
3138
3216
  const restoreState = savedState => {
3139
3217
  return {
3140
3218
  savedValue: getSavedValue(savedState),
3141
3219
  replacement: getSavedReplacement(savedState),
3142
3220
  savedCollapsedPaths: [],
3143
3221
  threads: 1,
3144
- flags: getSavedFlags(savedState)
3222
+ flags: getSavedFlags(savedState),
3223
+ includeValue: getSavedIncludeValue(savedState),
3224
+ excludeValue: getSavedExcludeValue(savedState)
3145
3225
  };
3146
3226
  };
3147
3227
 
@@ -3175,18 +3255,8 @@ const refresh = state => {
3175
3255
  return handleUpdate(state, {});
3176
3256
  };
3177
3257
 
3178
- const renderItems = {
3179
- isEqual(oldState, newState) {
3180
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons;
3181
- },
3182
- apply(oldState, newState) {
3183
- const displayResults = getDisplayResults(newState.items, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.collapsedPaths, newState.icons, newState.focusedIndex);
3184
- const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
3185
- const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
3186
- return ['Viewlet.setDom2', newState.uid, dom];
3187
- }
3188
- };
3189
- const getSelector = focusKey => {
3258
+ // TODO just return name
3259
+ const getFocusSelector = focusKey => {
3190
3260
  switch (focusKey) {
3191
3261
  case FocusSearchInput:
3192
3262
  return '[name="search-value"]';
@@ -3198,16 +3268,30 @@ const getSelector = focusKey => {
3198
3268
  return '[title="Preserve Case"]';
3199
3269
  case FocusSearchRegex:
3200
3270
  return '[title="Use Regular Expression"]';
3271
+ case FocusSearchIncludeInput:
3272
+ return '[name="files-to-include-value"]';
3201
3273
  default:
3202
3274
  return '';
3203
3275
  }
3204
3276
  };
3277
+
3278
+ const renderItems = {
3279
+ isEqual(oldState, newState) {
3280
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons;
3281
+ },
3282
+ apply(oldState, newState) {
3283
+ const displayResults = getDisplayResults(newState.items, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.collapsedPaths, newState.icons, newState.focusedIndex);
3284
+ const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
3285
+ const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
3286
+ return ['Viewlet.setDom2', newState.uid, dom];
3287
+ }
3288
+ };
3205
3289
  const renderFocus = {
3206
3290
  isEqual(oldState, newState) {
3207
3291
  return oldState.focus === newState.focus || newState.focusSource === User;
3208
3292
  },
3209
- apply(newState) {
3210
- const selector = getSelector(newState.focus);
3293
+ apply(oldState, newState) {
3294
+ const selector = getFocusSelector(newState.focus);
3211
3295
  return ['Viewlet.send', newState.uid, 'setFocus', selector, newState.focusSource];
3212
3296
  }
3213
3297
  };
@@ -3227,7 +3311,7 @@ const renderReplacement = {
3227
3311
  return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, '[name="search-replace-value"]'];
3228
3312
  }
3229
3313
  };
3230
- const render = [renderItems, renderFocus, renderValue, renderReplacement];
3314
+ const render = [renderItems, renderValue, renderReplacement, renderFocus];
3231
3315
  const doRender = uid => {
3232
3316
  const {
3233
3317
  oldState,
@@ -3335,12 +3419,16 @@ const saveState = uid => {
3335
3419
  const {
3336
3420
  value,
3337
3421
  replacement,
3338
- flags
3422
+ flags,
3423
+ includeValue,
3424
+ excludeValue
3339
3425
  } = newState;
3340
3426
  return {
3341
3427
  value,
3342
3428
  replacement,
3343
- flags
3429
+ flags,
3430
+ includeValue,
3431
+ excludeValue
3344
3432
  };
3345
3433
  };
3346
3434
 
@@ -3438,7 +3526,19 @@ const toggleSearchFlag = (state, flag) => {
3438
3526
  };
3439
3527
 
3440
3528
  const toggleDetailsExpanded = state => {
3441
- return toggleSearchFlag(state, DetailsExpanded);
3529
+ const newState = toggleSearchFlag(state, DetailsExpanded);
3530
+ if (hasDetailsExpanded(newState.flags)) {
3531
+ return {
3532
+ ...newState,
3533
+ focus: FocusSearchIncludeInput,
3534
+ focusSource: Script
3535
+ };
3536
+ }
3537
+ return {
3538
+ ...newState,
3539
+ focus: FocusSearchInput,
3540
+ focusSource: Script
3541
+ };
3442
3542
  };
3443
3543
 
3444
3544
  const toggleMatchCase = state => {
@@ -3449,6 +3549,10 @@ const toggleMatchWholeWord = state => {
3449
3549
  return toggleSearchFlag(state, MatchWholeWord);
3450
3550
  };
3451
3551
 
3552
+ const toggleOpenEditors = state => {
3553
+ return toggleSearchFlag(state, OpenEditors);
3554
+ };
3555
+
3452
3556
  const togglePreserveCase = state => {
3453
3557
  return toggleSearchFlag(state, PreserveCase);
3454
3558
  };
@@ -3457,6 +3561,10 @@ const toggleReplace = state => {
3457
3561
  return toggleSearchFlag(state, ReplaceExpanded);
3458
3562
  };
3459
3563
 
3564
+ const toggleUseIgnoreFiles = state => {
3565
+ return toggleSearchFlag(state, UseIgnoreFiles);
3566
+ };
3567
+
3460
3568
  const toggleUseRegularExpression = state => {
3461
3569
  return toggleSearchFlag(state, UseRegularExpression);
3462
3570
  };
@@ -3538,6 +3646,8 @@ const commandMap = {
3538
3646
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
3539
3647
  'TextSearch.handleInput': wrapCommand(handleInput),
3540
3648
  'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
3649
+ 'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
3650
+ 'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
3541
3651
  'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
3542
3652
  'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
3543
3653
  'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
@@ -3550,10 +3660,12 @@ const commandMap = {
3550
3660
  'TextSearch.submit': wrapCommand(submit),
3551
3661
  'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
3552
3662
  'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
3663
+ 'TextSearch.toggleOpenEditors': wrapCommand(toggleOpenEditors),
3553
3664
  'TextSearch.togglePreserveCase': wrapCommand(togglePreserveCase),
3554
3665
  'TextSearch.toggleReplace': wrapCommand(toggleReplace),
3555
- 'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
3556
3666
  'TextSearch.toggleSearchDetails': wrapCommand(toggleDetailsExpanded),
3667
+ 'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
3668
+ 'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
3557
3669
  // not wrapped
3558
3670
  'TextSearch.create': create,
3559
3671
  'TextSearch.render': doRender,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",