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