@lvce-editor/text-search-worker 2.8.0 → 2.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.
@@ -25,9 +25,6 @@ const clearSearchResults$1 = state => {
25
25
  };
26
26
 
27
27
  const state$3 = {
28
- /**
29
- * @type {any}
30
- */
31
28
  ipc: undefined
32
29
  };
33
30
  const get$2 = () => {
@@ -505,9 +502,11 @@ const create = (uid, x, y, width, height, workspacePath, assetDir) => {
505
502
  finalDeltaY: 0,
506
503
  focused: false,
507
504
  focusedIndex: -1,
508
- handleOffset: 0
505
+ handleOffset: 0,
506
+ focusSource: User
509
507
  };
510
508
  set(uid, state, state);
509
+ return state;
511
510
  };
512
511
 
513
512
  // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
@@ -893,16 +892,18 @@ const Tree = 'tree';
893
892
  const TreeItem$1 = 'treeitem';
894
893
  const ToolBar = 'toolbar';
895
894
 
895
+ const Actions = 'Actions';
896
+ const Badge = 'Badge';
896
897
  const Chevron = 'Chevron';
897
898
  const CloseMaskIcon = 'MaskIcon MaskIconClose';
898
899
  const Empty = '';
899
900
  const FileIcon = 'FileIcon';
900
- const IconButton = 'IconButton';
901
- const Actions = 'Actions';
902
901
  const FocusOutline = 'FocusOutline';
902
+ const Grow = 'Grow';
903
903
  const Highlight = 'Highlight';
904
904
  const HighlightDeleted = 'HighlightDeleted';
905
905
  const HighlightInserted = 'HighlightInserted';
906
+ const IconButton = 'IconButton';
906
907
  const Label = 'Label';
907
908
  const List = 'List';
908
909
  const MaskIcon = 'MaskIcon';
@@ -911,11 +912,16 @@ const MaskIconChevronRight = 'MaskIconChevronRight';
911
912
  const MultilineInputBox = 'MultilineInputBox';
912
913
  const Search$1 = 'Search';
913
914
  const SearchField = 'SearchField';
915
+ const SearchFieldButton = 'SearchFieldButton';
916
+ const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
914
917
  const SearchFieldButtons = 'SearchFieldButtons';
915
918
  const SearchFieldContainer = 'SearchFieldContainer';
916
919
  const SearchHeader = 'SearchHeader';
920
+ const SearchHeaderDetails = 'SearchHeaderDetails';
917
921
  const SearchHeaderTop = 'SearchHeaderTop';
922
+ const SearchHeaderTopRight = 'SearchHeaderTopRight';
918
923
  const SearchRemove = 'SearchRemove';
924
+ const SearchToggleButton = 'SearchToggleButton';
919
925
  const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
920
926
  const SourceControlBadge = 'SourceControlBadge';
921
927
  const TreeItem = 'TreeItem';
@@ -935,10 +941,14 @@ const Ins = 20;
935
941
  const Del = 21;
936
942
  const TextArea = 62;
937
943
 
944
+ const mergeClassNames = (...classNames) => {
945
+ return classNames.filter(Boolean).join(' ');
946
+ };
947
+
938
948
  const getIconVirtualDom = (icon, type = Div) => {
939
949
  return {
940
950
  type,
941
- className: `MaskIcon MaskIcon${icon}`,
951
+ className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
942
952
  role: None,
943
953
  childCount: 0
944
954
  };
@@ -1129,7 +1139,7 @@ const getSearchFieldButtonVirtualDom = button => {
1129
1139
  } = button;
1130
1140
  return [{
1131
1141
  type: Div,
1132
- className: `SearchFieldButton ${checked ? 'SearchFieldButtonChecked' : ''}`,
1142
+ className: mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : ''),
1133
1143
  title,
1134
1144
  role: CheckBox,
1135
1145
  ariaChecked: checked,
@@ -1137,7 +1147,7 @@ const getSearchFieldButtonVirtualDom = button => {
1137
1147
  childCount: 1
1138
1148
  }, {
1139
1149
  type: Div,
1140
- className: `MaskIcon ${icon}`,
1150
+ className: mergeClassNames(MaskIcon, icon),
1141
1151
  childCount: 0
1142
1152
  }];
1143
1153
  };
@@ -1199,7 +1209,7 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
1199
1209
  childCount: 2
1200
1210
  }, {
1201
1211
  type: Button,
1202
- className: `IconButton SearchToggleButton ${replaceExpanded ? SearchToggleButtonExpanded : ''}`,
1212
+ className: mergeClassNames(IconButton, SearchToggleButton, replaceExpanded ? SearchToggleButtonExpanded : ''),
1203
1213
  title: 'Toggle Replace',
1204
1214
  ariaLabel: 'Toggle Replace',
1205
1215
  ariaExpanded: replaceExpanded,
@@ -1207,11 +1217,11 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
1207
1217
  'data-command': 'toggleReplace'
1208
1218
  }, {
1209
1219
  type: Div,
1210
- className: `${MaskIcon} ${replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight}`,
1220
+ className: mergeClassNames(MaskIcon, replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
1211
1221
  childCount: 0
1212
1222
  }, {
1213
1223
  type: Div,
1214
- className: 'SearchHeaderTopRight',
1224
+ className: SearchHeaderTopRight,
1215
1225
  role: None,
1216
1226
  childCount: replaceExpanded ? 2 : 1
1217
1227
  }, ...getSearchFieldVirtualDom('search-value', 'Search', 'handleInput', [{
@@ -1242,10 +1252,11 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
1242
1252
  console.log({
1243
1253
  detailsExpanded
1244
1254
  });
1255
+ // @ts-ignore
1245
1256
  dom[0].childCount++;
1246
1257
  dom.push({
1247
1258
  type: Div,
1248
- className: 'SearchHeaderDetails',
1259
+ className: SearchHeaderDetails,
1249
1260
  childCount: 4
1250
1261
  }, text('files to include'), {
1251
1262
  type: Input,
@@ -1261,7 +1272,7 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
1261
1272
  const getBadgeVirtualDom = (className, count) => {
1262
1273
  return [{
1263
1274
  type: Div,
1264
- className: `Badge ${className}`,
1275
+ className: mergeClassNames(Badge, className),
1265
1276
  childCount: 1
1266
1277
  }, text(`${count}`)];
1267
1278
  };
@@ -1269,7 +1280,7 @@ const getBadgeVirtualDom = (className, count) => {
1269
1280
  const getChevronDownVirtualDom = (extraClassName = '') => {
1270
1281
  return {
1271
1282
  type: Div,
1272
- className: `${Chevron} MaskIconChevronDown ${extraClassName}`,
1283
+ className: mergeClassNames(Chevron, MaskIconChevronDown, extraClassName),
1273
1284
  childCount: 0
1274
1285
  };
1275
1286
  };
@@ -1299,29 +1310,30 @@ const highlighted = {
1299
1310
  className: Highlight,
1300
1311
  childCount: 1
1301
1312
  };
1313
+ const label1 = {
1314
+ type: Div,
1315
+ className: mergeClassNames(Label, Grow),
1316
+ childCount: 1
1317
+ };
1318
+ const label3 = {
1319
+ ...label1,
1320
+ childCount: 3
1321
+ };
1322
+ const label4 = {
1323
+ ...label1,
1324
+ childCount: 4
1325
+ };
1302
1326
  const getLabelVirtualDom = (displayText, matchLength, matchStart, replacement) => {
1303
- const dom = [];
1304
- const label = {
1305
- type: Div,
1306
- className: Label + ' Grow',
1307
- childCount: 1
1308
- };
1309
- dom.push(label);
1310
1327
  if (matchLength) {
1311
1328
  const before = displayText.slice(0, matchStart);
1312
1329
  const highlight = displayText.slice(matchStart, matchStart + matchLength);
1313
1330
  const after = displayText.slice(matchStart + matchLength);
1314
1331
  if (replacement) {
1315
- dom.push(text(before), deleted, text(highlight), inserted, text(replacement), text(after));
1316
- label.childCount = 4;
1317
- } else {
1318
- label.childCount = 3;
1319
- dom.push(text(before), highlighted, text(highlight), text(after));
1332
+ return [label4, text(before), deleted, text(highlight), inserted, text(replacement), text(after)];
1320
1333
  }
1321
- } else {
1322
- dom.push(text(displayText));
1334
+ return [label3, text(before), highlighted, text(highlight), text(after)];
1323
1335
  }
1324
- return dom;
1336
+ return [label1, text(displayText)];
1325
1337
  };
1326
1338
 
1327
1339
  const PaddingRight = '12px';
@@ -1392,14 +1404,7 @@ const getSearchResultsVirtualDom = visibleItems => {
1392
1404
  return visibleItems.flatMap(getSearchResultVirtualDom);
1393
1405
  };
1394
1406
 
1395
- const mergeClassNames = (...classNames) => {
1396
- return classNames.filter(Boolean).join(' ');
1397
- };
1398
-
1399
1407
  const getSearchVirtualDom = (visibleItems, replaceExpanded, matchCase, matchWholeWord, useRegularExpression, message, detailsExpanded, focusOutline) => {
1400
- /**
1401
- * @type {any[]}
1402
- */
1403
1408
  const dom = [];
1404
1409
  dom.push({
1405
1410
  type: Div,
@@ -1438,7 +1443,7 @@ const handleIconThemeChange = state => {
1438
1443
  };
1439
1444
  };
1440
1445
 
1441
- const handleError = async (error, notify = true, prefix = '') => {
1446
+ const handleError = error => {
1442
1447
  console.error(`[text-search-worker] ${error}`);
1443
1448
  };
1444
1449
 
@@ -1489,13 +1494,6 @@ const isEmptyString = string => {
1489
1494
  return string === EmptyString;
1490
1495
  };
1491
1496
 
1492
- /**
1493
- *
1494
- * @param {number} size
1495
- * @param {number} contentSize
1496
- * @param {number} minimumSliderSize
1497
- * @returns
1498
- */
1499
1497
  const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1500
1498
  if (size >= contentSize) {
1501
1499
  return 0;
@@ -1530,7 +1528,7 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
1530
1528
  };
1531
1529
  };
1532
1530
 
1533
- const RE_PROTOCOL = /^([a-z\-]+):\/\//;
1531
+ const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
1534
1532
  const getProtocol = uri => {
1535
1533
  const protocolMatch = uri.match(RE_PROTOCOL);
1536
1534
  if (protocolMatch) {
@@ -1954,9 +1952,8 @@ const state = {
1954
1952
  const getHandleDb = async () => {
1955
1953
  // @ts-ignore
1956
1954
  const db = await openDB('handle', state.dbVersion, {
1957
- async upgrade(db, oldVersion) {
1955
+ async upgrade(db) {
1958
1956
  if (!db.objectStoreNames.contains('file-handles-store')) {
1959
- // @ts-ignore
1960
1957
  await db.createObjectStore('file-handles-store', {});
1961
1958
  }
1962
1959
  }
@@ -2404,7 +2401,7 @@ const getFileIndex = (items, index) => {
2404
2401
  }
2405
2402
  return -1;
2406
2403
  };
2407
- const selectIndexFile = async (state, searchResult, index) => {
2404
+ const selectIndexFile = (state, searchResult, index) => {
2408
2405
  const {
2409
2406
  collapsedPaths
2410
2407
  } = state;
@@ -2441,7 +2438,7 @@ const selectIndexPreview = async (state, searchResult, index) => {
2441
2438
  listFocused: false
2442
2439
  };
2443
2440
  };
2444
- const selectIndex = async (state, index, isClose) => {
2441
+ const selectIndex = async (state, index) => {
2445
2442
  if (index === -1) {
2446
2443
  return {
2447
2444
  ...state,
@@ -2652,11 +2649,11 @@ const getSelector = focusKey => {
2652
2649
  };
2653
2650
  const renderFocus = {
2654
2651
  isEqual(oldState, newState) {
2655
- return oldState.focus === newState.focus;
2652
+ return oldState.focus === newState.focus || newState.focusSource === User;
2656
2653
  },
2657
2654
  apply(newState) {
2658
2655
  const selector = getSelector(newState.focus);
2659
- return ['Viewlet.send', newState.uid, 'setFocus', selector];
2656
+ return ['Viewlet.send', newState.uid, 'setFocus', selector, newState.focusSource];
2660
2657
  }
2661
2658
  };
2662
2659
  const render = [renderItems, renderFocus];
@@ -2796,7 +2793,8 @@ const getSearchFocusKey = key => {
2796
2793
  const focusSearchValue = state => {
2797
2794
  return {
2798
2795
  ...state,
2799
- focus: FocusSearchInput
2796
+ focus: FocusSearchInput,
2797
+ focusSource: Script
2800
2798
  };
2801
2799
  };
2802
2800
  const focusMatchCasePrevious = state => {
@@ -2817,37 +2815,43 @@ const focusRegexNext = state => {
2817
2815
  const focusReplaceValue = state => {
2818
2816
  return {
2819
2817
  ...state,
2820
- focus: FocusSearchReplaceInput
2818
+ focus: FocusSearchReplaceInput,
2819
+ focusSource: Script
2821
2820
  };
2822
2821
  };
2823
2822
  const focusMatchCase = state => {
2824
2823
  return {
2825
2824
  ...state,
2826
- focus: FocusSearchMatchCase
2825
+ focus: FocusSearchMatchCase,
2826
+ focusSource: Script
2827
2827
  };
2828
2828
  };
2829
2829
  const focusPreserveCase = state => {
2830
2830
  return {
2831
2831
  ...state,
2832
- focus: FocusSearchPreserveCase
2832
+ focus: FocusSearchPreserveCase,
2833
+ focusSource: Script
2833
2834
  };
2834
2835
  };
2835
2836
  const focusMatchWholeWord = state => {
2836
2837
  return {
2837
2838
  ...state,
2838
- focus: FocusSearchWholeWord
2839
+ focus: FocusSearchWholeWord,
2840
+ focusSource: Script
2839
2841
  };
2840
2842
  };
2841
2843
  const focusRegex = state => {
2842
2844
  return {
2843
2845
  ...state,
2844
- focus: FocusSearchRegex
2846
+ focus: FocusSearchRegex,
2847
+ focusSource: Script
2845
2848
  };
2846
2849
  };
2847
2850
  const focusReplaceAll = state => {
2848
2851
  return {
2849
2852
  ...state,
2850
- focus: FocusSearchReplaceAll
2853
+ focus: FocusSearchReplaceAll,
2854
+ focusSource: Script
2851
2855
  };
2852
2856
  };
2853
2857
  const handleFocusIn = (state, key) => {
@@ -2855,10 +2859,11 @@ const handleFocusIn = (state, key) => {
2855
2859
  if (state.focus === focusKey) {
2856
2860
  return state;
2857
2861
  }
2858
- setFocus(focusKey);
2862
+ void setFocus(focusKey);
2859
2863
  return {
2860
2864
  ...state,
2861
- focus: focusKey
2865
+ focus: focusKey,
2866
+ focusSource: User
2862
2867
  };
2863
2868
  };
2864
2869
 
@@ -2887,6 +2892,7 @@ const show = async (x, y, id, ...args) => {
2887
2892
  number(y);
2888
2893
  number(id);
2889
2894
  // TODO
2895
+ await invoke$1('ContextMenu.show', x, y, id, ...args);
2890
2896
  };
2891
2897
 
2892
2898
  const Search = 18;
@@ -2978,7 +2984,7 @@ const requiresSocket = () => {
2978
2984
  const preparePrettyError = error => {
2979
2985
  return error;
2980
2986
  };
2981
- const logError = error => {
2987
+ const logError = () => {
2982
2988
  // handled by renderer worker
2983
2989
  };
2984
2990
  const handleMessage = event => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",