@lvce-editor/text-search-worker 3.33.0 → 3.36.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.
@@ -1653,7 +1653,7 @@ const focusSearchValueNext = state => {
1653
1653
  };
1654
1654
 
1655
1655
  const Alert = 'alert';
1656
- const Button$2 = 'button';
1656
+ const Button$3 = 'button';
1657
1657
  const CheckBox = 'checkbox';
1658
1658
  const None$1 = 'none';
1659
1659
  const ScrollBar$1 = 'scrollbar';
@@ -1691,7 +1691,7 @@ const MultilineInputBox = 'MultilineInputBox';
1691
1691
  const ScrollBar = 'ScrollBar';
1692
1692
  const ScrollBarThumb = 'ScrollBarThumb';
1693
1693
  const ScrollBarVertical = 'ScrollBarVertical';
1694
- const Search$1 = 'Search';
1694
+ const Search$2 = 'Search';
1695
1695
  const SearchField = 'SearchField';
1696
1696
  const SearchFieldButton = 'SearchFieldButton';
1697
1697
  const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
@@ -1719,23 +1719,23 @@ const TreeItems$1 = 'TreeItems';
1719
1719
  const Viewlet = 'Viewlet';
1720
1720
  const ViewletSearchMessage = 'ViewletSearchMessage';
1721
1721
 
1722
- const Button$1 = 1;
1722
+ const Button$2 = 1;
1723
1723
 
1724
1724
  const mergeClassNames = (...classNames) => {
1725
1725
  return classNames.filter(Boolean).join(' ');
1726
1726
  };
1727
1727
 
1728
- const Button = 1;
1729
- const Del = 21;
1730
- const Div = 4;
1731
- const H4 = 24;
1732
- const Img = 17;
1733
- const Ins = 20;
1734
- const Span = 8;
1735
- const Text = 12;
1736
- const TextArea = 62;
1737
-
1738
- const getIconVirtualDom = (icon, type = Div) => {
1728
+ const Button$1 = 1;
1729
+ const Del$1 = 21;
1730
+ const Div$1 = 4;
1731
+ const H4$1 = 24;
1732
+ const Img$1 = 17;
1733
+ const Ins$1 = 20;
1734
+ const Span$1 = 8;
1735
+ const Text$1 = 12;
1736
+ const TextArea$1 = 62;
1737
+
1738
+ const getIconVirtualDom = (icon, type = Div$1) => {
1739
1739
  return {
1740
1740
  type,
1741
1741
  className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
@@ -1751,7 +1751,7 @@ const getActionButtonVirtualDom = action => {
1751
1751
  command
1752
1752
  } = action;
1753
1753
  return [{
1754
- type: Button,
1754
+ type: Button$1,
1755
1755
  className: IconButton,
1756
1756
  title: id,
1757
1757
  'data-command': command,
@@ -1761,7 +1761,7 @@ const getActionButtonVirtualDom = action => {
1761
1761
 
1762
1762
  const getActionVirtualDom = action => {
1763
1763
  switch (action.type) {
1764
- case Button$1:
1764
+ case Button$2:
1765
1765
  return getActionButtonVirtualDom(action);
1766
1766
  default:
1767
1767
  return [];
@@ -1770,7 +1770,7 @@ const getActionVirtualDom = action => {
1770
1770
 
1771
1771
  const getActionsVirtualDom = actions => {
1772
1772
  return [{
1773
- type: Div,
1773
+ type: Div$1,
1774
1774
  className: Actions,
1775
1775
  role: ToolBar,
1776
1776
  childCount: actions.length
@@ -1860,27 +1860,27 @@ const Refresh = 'Refresh';
1860
1860
 
1861
1861
  const getActions = () => {
1862
1862
  return [{
1863
- type: Button$1,
1863
+ type: Button$2,
1864
1864
  id: refresh$1(),
1865
1865
  icon: Refresh,
1866
1866
  command: 'refresh'
1867
1867
  }, {
1868
- type: Button$1,
1868
+ type: Button$2,
1869
1869
  id: clearSearchResults(),
1870
1870
  icon: ClearAll,
1871
1871
  command: 'clearSearchResults'
1872
1872
  }, {
1873
- type: Button$1,
1873
+ type: Button$2,
1874
1874
  id: openNewSearchEditor(),
1875
1875
  icon: NewFile,
1876
1876
  command: ''
1877
1877
  }, {
1878
- type: Button$1,
1878
+ type: Button$2,
1879
1879
  id: viewAsTree(),
1880
1880
  icon: ListFlat,
1881
1881
  command: ''
1882
1882
  }, {
1883
- type: Button$1,
1883
+ type: Button$2,
1884
1884
  id: collapseAll(),
1885
1885
  icon: CollapseAll,
1886
1886
  command: ''
@@ -1917,7 +1917,7 @@ const getChildCount = (expanded, matchCount) => {
1917
1917
  const pathBaseName = path => {
1918
1918
  return path.slice(path.lastIndexOf('/') + 1);
1919
1919
  };
1920
- const getAbsolutePath = relativePath => {
1920
+ const getRelativePath = relativePath => {
1921
1921
  if (relativePath.startsWith('./')) {
1922
1922
  return `/${relativePath.slice(2)}`; // TODO support windows paths
1923
1923
  }
@@ -1926,7 +1926,7 @@ const getAbsolutePath = relativePath => {
1926
1926
 
1927
1927
  const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
1928
1928
  const path = text;
1929
- const absolutePath = getAbsolutePath(path);
1929
+ const absolutePath = getRelativePath(path);
1930
1930
  const baseName = pathBaseName(path);
1931
1931
  const index = originalResults.indexOf(results[i]);
1932
1932
  const matchCount = getMatchCount(results, index);
@@ -2026,16 +2026,16 @@ const UseRegularExpression = 'UseRegularExpression';
2026
2026
 
2027
2027
  const getSearchDetailsToggleVirtualDom = () => {
2028
2028
  return [{
2029
- type: Div,
2029
+ type: Div$1,
2030
2030
  className: ToggleDetails,
2031
- role: Button$2,
2031
+ role: Button$3,
2032
2032
  tabIndex: 0,
2033
2033
  ariaLabel: toggleSearchDetails(),
2034
2034
  title: toggleSearchDetails(),
2035
2035
  name: ToggleSearchDetails,
2036
2036
  childCount: 1
2037
2037
  }, {
2038
- type: Div,
2038
+ type: Div$1,
2039
2039
  className: mergeClassNames(MaskIcon, MaskIconEllipsis),
2040
2040
  childCount: 0
2041
2041
  }];
@@ -2043,7 +2043,7 @@ const getSearchDetailsToggleVirtualDom = () => {
2043
2043
 
2044
2044
  const text = data => {
2045
2045
  return {
2046
- type: Text,
2046
+ type: Text$1,
2047
2047
  text: data,
2048
2048
  childCount: 0
2049
2049
  };
@@ -2051,7 +2051,7 @@ const text = data => {
2051
2051
 
2052
2052
  const getSearchMessageVirtualDom = message => {
2053
2053
  return [{
2054
- type: Div,
2054
+ type: Div$1,
2055
2055
  className: ViewletSearchMessage,
2056
2056
  role: Status,
2057
2057
  tabIndex: 0,
@@ -2061,7 +2061,7 @@ const getSearchMessageVirtualDom = message => {
2061
2061
 
2062
2062
  const getSearchHeaderDetailsCollapsedVirtualDom = message => {
2063
2063
  return [{
2064
- type: Div,
2064
+ type: Div$1,
2065
2065
  className: SearchHeaderDetails,
2066
2066
  childCount: 2
2067
2067
  }, ...getSearchMessageVirtualDom(message), ...getSearchDetailsToggleVirtualDom()];
@@ -2109,7 +2109,7 @@ const getSearchFieldButtonVirtualDom = button => {
2109
2109
  disabled
2110
2110
  } = button;
2111
2111
  return [{
2112
- type: Button,
2112
+ type: Button$1,
2113
2113
  className: getClassName(checked, disabled),
2114
2114
  name,
2115
2115
  title,
@@ -2118,7 +2118,7 @@ const getSearchFieldButtonVirtualDom = button => {
2118
2118
  tabIndex: 0,
2119
2119
  childCount: 1
2120
2120
  }, {
2121
- type: Span,
2121
+ type: Span$1,
2122
2122
  className: mergeClassNames(MaskIcon, icon),
2123
2123
  childCount: 0
2124
2124
  }];
@@ -2133,7 +2133,7 @@ const getOutSideButtonsDom = outsideButtons => {
2133
2133
  }
2134
2134
  return {
2135
2135
  preNodes: [{
2136
- type: Div,
2136
+ type: Div$1,
2137
2137
  className: SearchFieldContainer,
2138
2138
  role: None$1,
2139
2139
  childCount: 1 + outsideButtons.length
@@ -2149,12 +2149,12 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2149
2149
  } = getOutSideButtonsDom(outsideButtons);
2150
2150
  const searchFieldClassName = hasError ? mergeClassNames(SearchField, SearchFieldError) : SearchField;
2151
2151
  const dom = [...preNodes, {
2152
- type: Div,
2152
+ type: Div$1,
2153
2153
  className: searchFieldClassName,
2154
2154
  role: None$1,
2155
2155
  childCount: 2
2156
2156
  }, {
2157
- type: TextArea,
2157
+ type: TextArea$1,
2158
2158
  className: MultilineInputBox,
2159
2159
  spellcheck: false,
2160
2160
  autocapitalize: 'off',
@@ -2165,7 +2165,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2165
2165
  onFocus,
2166
2166
  childCount: 0
2167
2167
  }, {
2168
- type: Div,
2168
+ type: Div$1,
2169
2169
  className: SearchFieldButtons,
2170
2170
  childCount: insideButtons.length
2171
2171
  }, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom), ...postNodes];
@@ -2176,19 +2176,19 @@ const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
2176
2176
  const includeButtons = getInputActionsInclude(flags);
2177
2177
  const excludeButtons = getInputActionsExclude(flags);
2178
2178
  return [{
2179
- type: Div,
2179
+ type: Div$1,
2180
2180
  className: SearchHeaderDetailsExpanded,
2181
2181
  childCount: 5
2182
2182
  }, {
2183
- type: Div,
2183
+ type: Div$1,
2184
2184
  className: SearchHeaderDetailsExpandedTop,
2185
2185
  childCount: 2
2186
2186
  }, ...getSearchDetailsToggleVirtualDom(), {
2187
- type: H4,
2187
+ type: H4$1,
2188
2188
  className: SearchHeaderDetailsHeading,
2189
2189
  childCount: 1
2190
2190
  }, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, 'Include', HandleIncludeInput, includeButtons.inside, includeButtons.outside), {
2191
- type: H4,
2191
+ type: H4$1,
2192
2192
  className: SearchHeaderDetailsHeading,
2193
2193
  childCount: 1
2194
2194
  }, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, 'Exclude', HandleExcludeInput, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message)];
@@ -2247,7 +2247,7 @@ const getInputActionsReplace = (flags, matchCount) => {
2247
2247
 
2248
2248
  const getSearchToggleVirtualDom = flags => {
2249
2249
  return [{
2250
- type: Button,
2250
+ type: Button$1,
2251
2251
  className: mergeClassNames(IconButton, SearchToggleButton, flags & ReplaceExpanded ? SearchToggleButtonExpanded : ''),
2252
2252
  title: toggleReplace$1(),
2253
2253
  ariaLabel: toggleReplace$1(),
@@ -2256,7 +2256,7 @@ const getSearchToggleVirtualDom = flags => {
2256
2256
  'data-command': 'toggleReplace',
2257
2257
  name: ToggleReplace
2258
2258
  }, {
2259
- type: Div,
2259
+ type: Div$1,
2260
2260
  className: mergeClassNames(MaskIcon, flags & ReplaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
2261
2261
  childCount: 0
2262
2262
  }];
@@ -2266,12 +2266,12 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
2266
2266
  const inputActions = getInputActionsInput(flags);
2267
2267
  const replaceActions = getInputActionsReplace(flags, matchCount);
2268
2268
  const dom = [{
2269
- type: Div,
2269
+ type: Div$1,
2270
2270
  className: SearchHeaderTop,
2271
2271
  role: None$1,
2272
2272
  childCount: 2
2273
2273
  }, ...getSearchToggleVirtualDom(flags), {
2274
- type: Div,
2274
+ type: Div$1,
2275
2275
  className: SearchHeaderTopRight,
2276
2276
  role: None$1,
2277
2277
  childCount: flags & ReplaceExpanded ? 2 : 1
@@ -2284,7 +2284,7 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
2284
2284
 
2285
2285
  const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount) => {
2286
2286
  const dom = [{
2287
- type: Div,
2287
+ type: Div$1,
2288
2288
  className: SearchHeader,
2289
2289
  role: None$1,
2290
2290
  childCount: 2,
@@ -2299,7 +2299,7 @@ const getSearchInputErrorVirtualDom = errorMessage => {
2299
2299
  return [];
2300
2300
  }
2301
2301
  return [{
2302
- type: Div,
2302
+ type: Div$1,
2303
2303
  className: SearchInputError,
2304
2304
  role: Alert,
2305
2305
  childCount: 1
@@ -2313,7 +2313,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
2313
2313
  return [];
2314
2314
  }
2315
2315
  return [{
2316
- type: Div,
2316
+ type: Div$1,
2317
2317
  className: mergeClassNames(ScrollBar, ScrollBarVertical),
2318
2318
  childCount: 1,
2319
2319
  onPointerDown: HandleScrollBarPointerDown,
@@ -2321,7 +2321,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
2321
2321
  ariaControls: TreeItems,
2322
2322
  ariaValueNow: scrollBarValue
2323
2323
  }, {
2324
- type: Div,
2324
+ type: Div$1,
2325
2325
  className: ScrollBarThumb,
2326
2326
  height: scrollBarHeight,
2327
2327
  translate: `0 ${scrollBarY}px`,
@@ -2347,26 +2347,26 @@ const getBadgeVirtualDom = (className, badgeText) => {
2347
2347
  return [];
2348
2348
  }
2349
2349
  return [{
2350
- type: Div,
2350
+ type: Div$1,
2351
2351
  className: mergeClassNames(Badge, className),
2352
2352
  childCount: 1
2353
2353
  }, text(badgeText)];
2354
2354
  };
2355
2355
 
2356
2356
  const chevronDownVirtualDom = {
2357
- type: Div,
2357
+ type: Div$1,
2358
2358
  className: mergeClassNames(Chevron, MaskIconChevronDown),
2359
2359
  childCount: 0
2360
2360
  };
2361
2361
  const chevronRightVirtualDom = {
2362
- type: Div,
2362
+ type: Div$1,
2363
2363
  className: mergeClassNames(Chevron, MaskIconChevronRight),
2364
2364
  childCount: 0
2365
2365
  };
2366
2366
 
2367
2367
  const getFileIconVirtualDom = icon => {
2368
2368
  return {
2369
- type: Img,
2369
+ type: Img$1,
2370
2370
  className: FileIcon,
2371
2371
  src: icon,
2372
2372
  role: None$1,
@@ -2374,23 +2374,34 @@ const getFileIconVirtualDom = icon => {
2374
2374
  };
2375
2375
  };
2376
2376
 
2377
+ const getIconsVirtualDom = (expanded, icon) => {
2378
+ switch (expanded) {
2379
+ case Expanded:
2380
+ return [chevronDownVirtualDom, getFileIconVirtualDom(icon)];
2381
+ case Collapsed:
2382
+ return [chevronRightVirtualDom, getFileIconVirtualDom(icon)];
2383
+ default:
2384
+ return [];
2385
+ }
2386
+ };
2387
+
2377
2388
  const deleted = {
2378
- type: Del,
2389
+ type: Del$1,
2379
2390
  className: HighlightDeleted,
2380
2391
  childCount: 1
2381
2392
  };
2382
2393
  const inserted = {
2383
- type: Ins,
2394
+ type: Ins$1,
2384
2395
  className: HighlightInserted,
2385
2396
  childCount: 1
2386
2397
  };
2387
2398
  const highlighted = {
2388
- type: Span,
2399
+ type: Span$1,
2389
2400
  className: Highlight,
2390
2401
  childCount: 1
2391
2402
  };
2392
2403
  const label1 = {
2393
- type: Div,
2404
+ type: Div$1,
2394
2405
  className: mergeClassNames(Label, Grow),
2395
2406
  childCount: 1
2396
2407
  };
@@ -2428,16 +2439,6 @@ const getSearchResultClassName = focused => {
2428
2439
 
2429
2440
  const PaddingRight = '12px';
2430
2441
 
2431
- const getIconsVirtualDom = (expanded, icon) => {
2432
- switch (expanded) {
2433
- case Expanded:
2434
- return [chevronDownVirtualDom, getFileIconVirtualDom(icon)];
2435
- case Collapsed:
2436
- return [chevronRightVirtualDom, getFileIconVirtualDom(icon)];
2437
- default:
2438
- return [];
2439
- }
2440
- };
2441
2442
  const getSearchResultVirtualDom = rowInfo => {
2442
2443
  const {
2443
2444
  matchStart,
@@ -2455,7 +2456,7 @@ const getSearchResultVirtualDom = rowInfo => {
2455
2456
  badgeText
2456
2457
  } = rowInfo;
2457
2458
  const dom = [{
2458
- type: Div,
2459
+ type: Div$1,
2459
2460
  role: TreeItem$1,
2460
2461
  className: getSearchResultClassName(focused),
2461
2462
  title,
@@ -2469,11 +2470,11 @@ const getSearchResultVirtualDom = rowInfo => {
2469
2470
  paddingRight: PaddingRight,
2470
2471
  ariaExpanded: getAriaExpanded(expanded)
2471
2472
  }, ...getIconsVirtualDom(expanded, icon), ...getLabelVirtualDom(displayText, matchLength, matchStart, replacement), ...getBadgeVirtualDom(SourceControlBadge, badgeText), {
2472
- type: Div,
2473
+ type: Div$1,
2473
2474
  className: SearchRemove,
2474
2475
  childCount: 1
2475
2476
  }, {
2476
- type: Div,
2477
+ type: Div$1,
2477
2478
  className: CloseMaskIcon,
2478
2479
  childCount: 0
2479
2480
  }];
@@ -2483,7 +2484,7 @@ const getSearchResultVirtualDom = rowInfo => {
2483
2484
  const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
2484
2485
  const pixelOffset = deltaY % itemHeight;
2485
2486
  return [{
2486
- type: Div,
2487
+ type: Div$1,
2487
2488
  className: TreeItems$1,
2488
2489
  childCount: visibleItems.length,
2489
2490
  onClick: HandleClick,
@@ -2497,7 +2498,7 @@ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
2497
2498
  const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
2498
2499
  const scrollBarDomNodes = scrollbarHeight === 0 ? 0 : 1;
2499
2500
  return [{
2500
- type: Div,
2501
+ type: Div$1,
2501
2502
  className: mergeClassNames(Viewlet, List, Tree, focusOutline ? FocusOutline : Empty),
2502
2503
  role: Tree$1,
2503
2504
  tabIndex: 0,
@@ -2509,8 +2510,8 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
2509
2510
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
2510
2511
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
2511
2512
  return [{
2512
- type: Div,
2513
- className: mergeClassNames(Viewlet, Search$1),
2513
+ type: Div$1,
2514
+ className: mergeClassNames(Viewlet, Search$2),
2514
2515
  childCount
2515
2516
  }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
2516
2517
  };
@@ -3388,10 +3389,6 @@ const selectIndexFile = async (state, searchResult, index) => {
3388
3389
  };
3389
3390
  };
3390
3391
 
3391
- const openUri = async (path, focus = true, props = {}) => {
3392
- await invoke$2(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
3393
- };
3394
-
3395
3392
  const getFileIndex = (items, index) => {
3396
3393
  for (let i = index; i >= 0; i--) {
3397
3394
  const item = items[i];
@@ -3401,9 +3398,15 @@ const getFileIndex = (items, index) => {
3401
3398
  }
3402
3399
  return -1;
3403
3400
  };
3401
+
3402
+ const openUri = async (path, focus = true, props = {}) => {
3403
+ await invoke$2(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
3404
+ };
3405
+
3404
3406
  const selectIndexPreview = async (state, searchResult, index) => {
3405
3407
  const {
3406
- items
3408
+ items,
3409
+ workspacePath
3407
3410
  } = state;
3408
3411
  const fileIndex = getFileIndex(items, index);
3409
3412
  if (fileIndex === -1) {
@@ -3413,9 +3416,9 @@ const selectIndexPreview = async (state, searchResult, index) => {
3413
3416
  lineNumber
3414
3417
  } = searchResult;
3415
3418
  const fileResult = items[fileIndex];
3416
- const path = getAbsolutePath(fileResult.text);
3417
- string(path);
3418
- await openUri(path, true, {
3419
+ const relativePath = getRelativePath(fileResult.text);
3420
+ const absolutePath = `${workspacePath}${relativePath}`;
3421
+ await openUri(absolutePath, true, {
3419
3422
  selections: new Uint32Array([lineNumber, 0, lineNumber, 0])
3420
3423
  });
3421
3424
  return {
@@ -3746,6 +3749,355 @@ const doRender = uid => {
3746
3749
  return commands;
3747
3750
  };
3748
3751
 
3752
+ var __defProp = Object.defineProperty;
3753
+ var __export = (target, all) => {
3754
+ for (var name in all) __defProp(target, name, {
3755
+ get: all[name],
3756
+ enumerable: true
3757
+ });
3758
+ };
3759
+
3760
+ // src/parts/VirtualDomElements/VirtualDomElements.ts
3761
+ var VirtualDomElements_exports = {};
3762
+ __export(VirtualDomElements_exports, {
3763
+ A: () => A,
3764
+ Abbr: () => Abbr,
3765
+ Article: () => Article,
3766
+ Aside: () => Aside,
3767
+ Audio: () => Audio,
3768
+ Br: () => Br,
3769
+ Button: () => Button,
3770
+ Cite: () => Cite,
3771
+ Col: () => Col,
3772
+ ColGroup: () => ColGroup,
3773
+ Data: () => Data,
3774
+ Dd: () => Dd,
3775
+ Del: () => Del,
3776
+ Div: () => Div,
3777
+ Dl: () => Dl,
3778
+ Figcaption: () => Figcaption,
3779
+ Figure: () => Figure,
3780
+ Footer: () => Footer,
3781
+ H1: () => H1,
3782
+ H2: () => H2,
3783
+ H3: () => H3,
3784
+ H4: () => H4,
3785
+ H5: () => H5,
3786
+ H6: () => H6,
3787
+ Header: () => Header,
3788
+ Hr: () => Hr,
3789
+ I: () => I,
3790
+ Img: () => Img,
3791
+ Input: () => Input,
3792
+ Ins: () => Ins,
3793
+ Kbd: () => Kbd,
3794
+ Li: () => Li,
3795
+ Nav: () => Nav,
3796
+ Ol: () => Ol,
3797
+ Option: () => Option,
3798
+ P: () => P,
3799
+ Pre: () => Pre,
3800
+ Root: () => Root,
3801
+ Search: () => Search$1,
3802
+ Section: () => Section,
3803
+ Select: () => Select,
3804
+ Span: () => Span,
3805
+ TBody: () => TBody,
3806
+ THead: () => THead,
3807
+ Table: () => Table,
3808
+ Td: () => Td,
3809
+ Text: () => Text,
3810
+ TextArea: () => TextArea,
3811
+ Tfoot: () => Tfoot,
3812
+ Th: () => Th,
3813
+ Time: () => Time,
3814
+ Tr: () => Tr,
3815
+ Ul: () => Ul,
3816
+ Video: () => Video
3817
+ });
3818
+ var Audio = 0;
3819
+ var Button = 1;
3820
+ var Col = 2;
3821
+ var ColGroup = 3;
3822
+ var Div = 4;
3823
+ var H1 = 5;
3824
+ var Input = 6;
3825
+ var Kbd = 7;
3826
+ var Span = 8;
3827
+ var Table = 9;
3828
+ var TBody = 10;
3829
+ var Td = 11;
3830
+ var Text = 12;
3831
+ var Th = 13;
3832
+ var THead = 14;
3833
+ var Tr = 15;
3834
+ var I = 16;
3835
+ var Img = 17;
3836
+ var Root = 0;
3837
+ var Ins = 20;
3838
+ var Del = 21;
3839
+ var H2 = 22;
3840
+ var H3 = 23;
3841
+ var H4 = 24;
3842
+ var H5 = 25;
3843
+ var H6 = 26;
3844
+ var Article = 27;
3845
+ var Aside = 28;
3846
+ var Footer = 29;
3847
+ var Header = 30;
3848
+ var Nav = 40;
3849
+ var Section = 41;
3850
+ var Search$1 = 42;
3851
+ var Dd = 43;
3852
+ var Dl = 44;
3853
+ var Figcaption = 45;
3854
+ var Figure = 46;
3855
+ var Hr = 47;
3856
+ var Li = 48;
3857
+ var Ol = 49;
3858
+ var P = 50;
3859
+ var Pre = 51;
3860
+ var A = 53;
3861
+ var Abbr = 54;
3862
+ var Br = 55;
3863
+ var Cite = 56;
3864
+ var Data = 57;
3865
+ var Time = 58;
3866
+ var Tfoot = 59;
3867
+ var Ul = 60;
3868
+ var Video = 61;
3869
+ var TextArea = 62;
3870
+ var Select = 63;
3871
+ var Option = 64;
3872
+
3873
+ // src/parts/PatchType/PatchType.ts
3874
+ var SetText = 1;
3875
+ var SetAttribute = 3;
3876
+ var RemoveAttribute = 4;
3877
+ var Add = 6;
3878
+ var NavigateChild = 7;
3879
+ var NavigateParent = 8;
3880
+ var RemoveChild = 9;
3881
+ var NavigateSibling = 10;
3882
+
3883
+ // src/parts/ApplyPendingPatches/ApplyPendingPatches.ts
3884
+ var applyPendingPatches = (patches, pendingPatches, skip) => {
3885
+ for (let k = 0; k < pendingPatches.length - skip; k += 2) {
3886
+ const type = pendingPatches[k];
3887
+ const index = pendingPatches[k + 1];
3888
+ if (type === NavigateParent) {
3889
+ patches.push({
3890
+ type
3891
+ });
3892
+ } else {
3893
+ patches.push({
3894
+ type,
3895
+ index
3896
+ });
3897
+ }
3898
+ }
3899
+ pendingPatches.length = 0;
3900
+ };
3901
+
3902
+ // src/parts/GetKeys/GetKeys.ts
3903
+ var isKey = key => {
3904
+ return key !== "type" && key !== "childCount";
3905
+ };
3906
+ var getKeys = node => {
3907
+ const keys = Object.keys(node).filter(isKey);
3908
+ return keys;
3909
+ };
3910
+
3911
+ // src/parts/GetTotalChildCount/GetTotalChildCount.ts
3912
+ var getTotalChildCount = (nodes, index) => {
3913
+ let i = index;
3914
+ let pending = 1;
3915
+ while (pending) {
3916
+ const node = nodes[i];
3917
+ pending += node.childCount;
3918
+ pending--;
3919
+ i++;
3920
+ }
3921
+ return i - index;
3922
+ };
3923
+
3924
+ // src/parts/VirtualDomDiff/VirtualDomDiff.ts
3925
+ var diff = (oldNodes, newNodes) => {
3926
+ const patches = [];
3927
+ const pendingPatches = [];
3928
+ let i = 0;
3929
+ let j = 0;
3930
+ let siblingOffset = 0;
3931
+ let maxSiblingOffset = 1;
3932
+ const indexStack = [0, 1];
3933
+ while (i < oldNodes.length && j < newNodes.length) {
3934
+ const oldNode = oldNodes[i];
3935
+ const newNode = newNodes[j];
3936
+ if (siblingOffset === maxSiblingOffset) {
3937
+ pendingPatches.push(NavigateParent, 0);
3938
+ maxSiblingOffset = indexStack.pop();
3939
+ siblingOffset = indexStack.pop() + 1;
3940
+ }
3941
+ if (oldNode.type !== newNode.type) {
3942
+ let skip = 0;
3943
+ if (pendingPatches.length > 0 && pendingPatches.at(-2) === NavigateChild) {
3944
+ skip = 2;
3945
+ }
3946
+ applyPendingPatches(patches, pendingPatches, skip);
3947
+ const oldTotal = getTotalChildCount(oldNodes, i);
3948
+ const newTotal = getTotalChildCount(newNodes, j);
3949
+ patches.push({
3950
+ type: RemoveChild,
3951
+ index: siblingOffset
3952
+ });
3953
+ patches.push({
3954
+ type: Add,
3955
+ nodes: newNodes.slice(j, j + newTotal)
3956
+ });
3957
+ siblingOffset++;
3958
+ i += oldTotal;
3959
+ j += newTotal;
3960
+ continue;
3961
+ }
3962
+ if (oldNode.type === Text && newNode.type === Text) {
3963
+ if (oldNode.text !== newNode.text) {
3964
+ if (siblingOffset !== 0) {
3965
+ pendingPatches.push(NavigateSibling, siblingOffset);
3966
+ }
3967
+ applyPendingPatches(patches, pendingPatches, 0);
3968
+ patches.push({
3969
+ type: SetText,
3970
+ value: newNode.text
3971
+ });
3972
+ }
3973
+ i++;
3974
+ j++;
3975
+ siblingOffset++;
3976
+ continue;
3977
+ }
3978
+ const oldKeys = getKeys(oldNode);
3979
+ const newKeys = getKeys(newNode);
3980
+ let hasAttributeChanges = false;
3981
+ for (const key of newKeys) {
3982
+ if (oldNode[key] !== newNode[key]) {
3983
+ hasAttributeChanges = true;
3984
+ break;
3985
+ }
3986
+ }
3987
+ for (const key of oldKeys) {
3988
+ if (!(key in newNode)) {
3989
+ hasAttributeChanges = true;
3990
+ break;
3991
+ }
3992
+ }
3993
+ if (hasAttributeChanges) {
3994
+ applyPendingPatches(patches, pendingPatches, 0);
3995
+ for (const key of newKeys) {
3996
+ if (oldNode[key] !== newNode[key]) {
3997
+ patches.push({
3998
+ type: SetAttribute,
3999
+ key,
4000
+ value: newNode[key]
4001
+ });
4002
+ }
4003
+ }
4004
+ for (const key of oldKeys) {
4005
+ if (!(key in newNode)) {
4006
+ patches.push({
4007
+ type: RemoveAttribute,
4008
+ key
4009
+ });
4010
+ }
4011
+ }
4012
+ }
4013
+ if (oldNode.childCount && newNode.childCount) {
4014
+ maxSiblingOffset = oldNode.childCount;
4015
+ indexStack.push(0, maxSiblingOffset);
4016
+ pendingPatches.push(NavigateChild, 0);
4017
+ i++;
4018
+ j++;
4019
+ continue;
4020
+ }
4021
+ if (oldNode.childCount) {
4022
+ applyPendingPatches(patches, pendingPatches, 0);
4023
+ for (let k = 0; k < oldNode.childCount; k++) {
4024
+ patches.push({
4025
+ type: RemoveChild,
4026
+ index: 0
4027
+ });
4028
+ }
4029
+ i += getTotalChildCount(oldNodes, i);
4030
+ j++;
4031
+ continue;
4032
+ }
4033
+ if (newNode.childCount) {
4034
+ applyPendingPatches(patches, pendingPatches, 0);
4035
+ const total = getTotalChildCount(newNodes, j);
4036
+ patches.push({
4037
+ type: Add,
4038
+ nodes: newNodes.slice(j + 1, j + total)
4039
+ });
4040
+ i++;
4041
+ j += total;
4042
+ continue;
4043
+ }
4044
+ i++;
4045
+ j++;
4046
+ siblingOffset++;
4047
+ }
4048
+ while (i < oldNodes.length) {
4049
+ if (indexStack.length !== 2) {
4050
+ patches.push({
4051
+ type: NavigateParent
4052
+ });
4053
+ }
4054
+ patches.push({
4055
+ type: RemoveChild,
4056
+ index: siblingOffset
4057
+ });
4058
+ i += getTotalChildCount(oldNodes, i);
4059
+ indexStack.pop();
4060
+ indexStack.pop();
4061
+ }
4062
+ while (j < newNodes.length) {
4063
+ if (siblingOffset > 0) {
4064
+ patches.push({
4065
+ type: NavigateSibling,
4066
+ index: siblingOffset
4067
+ });
4068
+ siblingOffset = 0;
4069
+ }
4070
+ const count = getTotalChildCount(newNodes, j);
4071
+ patches.push({
4072
+ type: Add,
4073
+ nodes: newNodes.slice(j, j + count)
4074
+ });
4075
+ j += count;
4076
+ }
4077
+ return patches;
4078
+ };
4079
+
4080
+ const getDom = state => {
4081
+ const displayResults = getDisplayResults(state.listItems, state.itemHeight, state.fileCount, state.value, state.minLineY, state.maxLineY, state.replacement, state.icons, state.listFocusedIndex, state.collapsedPaths, state.items);
4082
+ const focusOutline = state.listFocused && state.listFocusedIndex === -1;
4083
+ const scrollBarValue = state.deltaY / state.finalDeltaY * 100;
4084
+ const scrollBarY = getScrollBarY(state.deltaY, state.finalDeltaY, state.height - state.headerHeight, state.scrollBarHeight);
4085
+ const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount);
4086
+ return dom;
4087
+ };
4088
+
4089
+ // TODO cache rendered dom so that it can be used for dom diffing
4090
+ const renderIncremental = uid => {
4091
+ const {
4092
+ oldState,
4093
+ newState
4094
+ } = get(uid);
4095
+ const oldDom = getDom(oldState);
4096
+ const newDom = getDom(newState);
4097
+ const patches = diff(oldDom, newDom);
4098
+ return patches;
4099
+ };
4100
+
3749
4101
  const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
3750
4102
  if (matchCount === 1) {
3751
4103
  if (replacement) {
@@ -4022,6 +4374,7 @@ const commandMap = {
4022
4374
  'TextSearch.getFocus': getFocus,
4023
4375
  'TextSearch.getKeyBindings': getKeyBindings,
4024
4376
  'TextSearch.render': doRender,
4377
+ 'TextSearch.renderIncremental': renderIncremental,
4025
4378
  'TextSearch.saveState': saveState,
4026
4379
  // TODO needed?
4027
4380
  'TextSearch.textSearch': textSearch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.33.0",
3
+ "version": "3.36.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",