@lvce-editor/text-search-worker 4.0.0 → 4.1.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.
@@ -549,7 +549,7 @@ const waitForWebSocketToBeOpen = webSocket => {
549
549
  error: Error$3
550
550
  });
551
551
  };
552
- const create$7 = async ({
552
+ const create$6 = async ({
553
553
  webSocket
554
554
  }) => {
555
555
  const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
@@ -586,7 +586,7 @@ const wrap = webSocket => {
586
586
  };
587
587
  const IpcParentWithWebSocket$1 = {
588
588
  __proto__: null,
589
- create: create$7,
589
+ create: create$6,
590
590
  wrap
591
591
  };
592
592
 
@@ -966,6 +966,9 @@ const createRpc = ipc => {
966
966
  },
967
967
  invokeAndTransfer(method, ...params) {
968
968
  return invokeAndTransfer$1(ipc, method, ...params);
969
+ },
970
+ async dispose() {
971
+ await ipc?.dispose();
969
972
  }
970
973
  };
971
974
  return rpc;
@@ -1000,7 +1003,7 @@ const listen$1 = async (module, options) => {
1000
1003
  const ipc = module.wrap(rawIpc);
1001
1004
  return ipc;
1002
1005
  };
1003
- const create$6 = async ({
1006
+ const create$7 = async ({
1004
1007
  commandMap,
1005
1008
  messagePort,
1006
1009
  isMessagePortOpen
@@ -1018,7 +1021,7 @@ const create$6 = async ({
1018
1021
  };
1019
1022
  const MessagePortRpcParent = {
1020
1023
  __proto__: null,
1021
- create: create$6
1024
+ create: create$7
1022
1025
  };
1023
1026
  const create$1$1 = async ({
1024
1027
  commandMap,
@@ -1748,7 +1751,7 @@ const focusSearchValueNext = state => {
1748
1751
  };
1749
1752
 
1750
1753
  const Alert = 'alert';
1751
- const Button$3 = 'button';
1754
+ const Button$2 = 'button';
1752
1755
  const CheckBox = 'checkbox';
1753
1756
  const None$1 = 'none';
1754
1757
  const ScrollBar$1 = 'scrollbar';
@@ -1786,7 +1789,7 @@ const MultilineInputBox = 'MultilineInputBox';
1786
1789
  const ScrollBar = 'ScrollBar';
1787
1790
  const ScrollBarThumb = 'ScrollBarThumb';
1788
1791
  const ScrollBarVertical = 'ScrollBarVertical';
1789
- const Search$2 = 'Search';
1792
+ const Search$1 = 'Search';
1790
1793
  const SearchField = 'SearchField';
1791
1794
  const SearchFieldButton = 'SearchFieldButton';
1792
1795
  const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
@@ -1815,146 +1818,21 @@ const Viewlet = 'Viewlet';
1815
1818
  const ViewletSearchMessage = 'ViewletSearchMessage';
1816
1819
  const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1817
1820
 
1818
- const Button$2 = 1;
1819
-
1820
- var __defProp = Object.defineProperty;
1821
- var __export = (target, all) => {
1822
- for (var name in all) __defProp(target, name, {
1823
- get: all[name],
1824
- enumerable: true
1825
- });
1826
- };
1827
-
1828
- // src/parts/MergeClassNames/MergeClassNames.ts
1829
- var mergeClassNames = (...classNames) => {
1830
- return classNames.filter(Boolean).join(" ");
1831
- };
1832
-
1833
- // src/parts/VirtualDomElements/VirtualDomElements.ts
1834
- var VirtualDomElements_exports = {};
1835
- __export(VirtualDomElements_exports, {
1836
- A: () => A,
1837
- Abbr: () => Abbr,
1838
- Article: () => Article,
1839
- Aside: () => Aside,
1840
- Audio: () => Audio,
1841
- Br: () => Br,
1842
- Button: () => Button$1,
1843
- Cite: () => Cite,
1844
- Col: () => Col,
1845
- ColGroup: () => ColGroup,
1846
- Data: () => Data,
1847
- Dd: () => Dd,
1848
- Del: () => Del$1,
1849
- Div: () => Div$1,
1850
- Dl: () => Dl,
1851
- Figcaption: () => Figcaption,
1852
- Figure: () => Figure,
1853
- Footer: () => Footer,
1854
- H1: () => H1,
1855
- H2: () => H2,
1856
- H3: () => H3,
1857
- H4: () => H4$1,
1858
- H5: () => H5,
1859
- H6: () => H6,
1860
- Header: () => Header,
1861
- Hr: () => Hr,
1862
- I: () => I,
1863
- Img: () => Img$1,
1864
- Input: () => Input,
1865
- Ins: () => Ins$1,
1866
- Kbd: () => Kbd,
1867
- Li: () => Li,
1868
- Nav: () => Nav,
1869
- Ol: () => Ol,
1870
- Option: () => Option,
1871
- P: () => P,
1872
- Pre: () => Pre,
1873
- Root: () => Root,
1874
- Search: () => Search$1,
1875
- Section: () => Section,
1876
- Select: () => Select,
1877
- Span: () => Span$1,
1878
- TBody: () => TBody,
1879
- THead: () => THead,
1880
- Table: () => Table,
1881
- Td: () => Td,
1882
- Text: () => Text$1,
1883
- TextArea: () => TextArea$1,
1884
- Tfoot: () => Tfoot,
1885
- Th: () => Th,
1886
- Time: () => Time,
1887
- Tr: () => Tr,
1888
- Ul: () => Ul,
1889
- Video: () => Video
1890
- });
1891
- var Audio = 0;
1892
- var Button$1 = 1;
1893
- var Col = 2;
1894
- var ColGroup = 3;
1895
- var Div$1 = 4;
1896
- var H1 = 5;
1897
- var Input = 6;
1898
- var Kbd = 7;
1899
- var Span$1 = 8;
1900
- var Table = 9;
1901
- var TBody = 10;
1902
- var Td = 11;
1903
- var Text$1 = 12;
1904
- var Th = 13;
1905
- var THead = 14;
1906
- var Tr = 15;
1907
- var I = 16;
1908
- var Img$1 = 17;
1909
- var Root = 0;
1910
- var Ins$1 = 20;
1911
- var Del$1 = 21;
1912
- var H2 = 22;
1913
- var H3 = 23;
1914
- var H4$1 = 24;
1915
- var H5 = 25;
1916
- var H6 = 26;
1917
- var Article = 27;
1918
- var Aside = 28;
1919
- var Footer = 29;
1920
- var Header = 30;
1921
- var Nav = 40;
1922
- var Section = 41;
1923
- var Search$1 = 42;
1924
- var Dd = 43;
1925
- var Dl = 44;
1926
- var Figcaption = 45;
1927
- var Figure = 46;
1928
- var Hr = 47;
1929
- var Li = 48;
1930
- var Ol = 49;
1931
- var P = 50;
1932
- var Pre = 51;
1933
- var A = 53;
1934
- var Abbr = 54;
1935
- var Br = 55;
1936
- var Cite = 56;
1937
- var Data = 57;
1938
- var Time = 58;
1939
- var Tfoot = 59;
1940
- var Ul = 60;
1941
- var Video = 61;
1942
- var TextArea$1 = 62;
1943
- var Select = 63;
1944
- var Option = 64;
1945
-
1946
- // src/parts/PatchType/PatchType.ts
1947
- var SetText = 1;
1948
- var SetAttribute = 3;
1949
- var RemoveAttribute = 4;
1950
- var Add = 6;
1951
- var NavigateChild = 7;
1952
- var NavigateParent = 8;
1953
- var RemoveChild = 9;
1954
- var NavigateSibling = 10;
1955
-
1956
- // src/parts/ApplyPendingPatches/ApplyPendingPatches.ts
1957
- var applyPendingPatches = (patches, pendingPatches, skip) => {
1821
+ const Button$1 = 1;
1822
+
1823
+ const mergeClassNames = (...classNames) => {
1824
+ return classNames.filter(Boolean).join(' ');
1825
+ };
1826
+ const Text$1 = 12;
1827
+ const SetText = 1;
1828
+ const SetAttribute = 3;
1829
+ const RemoveAttribute = 4;
1830
+ const Add = 6;
1831
+ const NavigateChild = 7;
1832
+ const NavigateParent = 8;
1833
+ const RemoveChild = 9;
1834
+ const NavigateSibling = 10;
1835
+ const applyPendingPatches = (patches, pendingPatches, skip) => {
1958
1836
  for (let k = 0; k < pendingPatches.length - skip; k += 2) {
1959
1837
  const type = pendingPatches[k];
1960
1838
  const index = pendingPatches[k + 1];
@@ -1971,20 +1849,14 @@ var applyPendingPatches = (patches, pendingPatches, skip) => {
1971
1849
  }
1972
1850
  pendingPatches.length = 0;
1973
1851
  };
1974
-
1975
- // src/parts/IsKey/IsKey.ts
1976
- var isKey = key => {
1977
- return key !== "type" && key !== "childCount";
1852
+ const isKey = key => {
1853
+ return key !== 'type' && key !== 'childCount';
1978
1854
  };
1979
-
1980
- // src/parts/GetKeys/GetKeys.ts
1981
- var getKeys = node => {
1855
+ const getKeys = node => {
1982
1856
  const keys = Object.keys(node).filter(isKey);
1983
1857
  return keys;
1984
1858
  };
1985
-
1986
- // src/parts/GetTotalChildCount/GetTotalChildCount.ts
1987
- var getTotalChildCount = (nodes, index) => {
1859
+ const getTotalChildCount = (nodes, index) => {
1988
1860
  let i = index;
1989
1861
  let pending = 1;
1990
1862
  while (pending) {
@@ -1995,9 +1867,7 @@ var getTotalChildCount = (nodes, index) => {
1995
1867
  }
1996
1868
  return i - index;
1997
1869
  };
1998
-
1999
- // src/parts/VirtualDomDiff/VirtualDomDiff.ts
2000
- var diff = (oldNodes, newNodes) => {
1870
+ const diff = (oldNodes, newNodes) => {
2001
1871
  const patches = [];
2002
1872
  const pendingPatches = [];
2003
1873
  let i = 0;
@@ -2008,6 +1878,8 @@ var diff = (oldNodes, newNodes) => {
2008
1878
  while (i < oldNodes.length && j < newNodes.length) {
2009
1879
  const oldNode = oldNodes[i];
2010
1880
  const newNode = newNodes[j];
1881
+
1882
+ // TODO maybe don't have the current element in indexstack
2011
1883
  if (siblingOffset === maxSiblingOffset) {
2012
1884
  indexStack.pop();
2013
1885
  indexStack.pop();
@@ -2199,7 +2071,7 @@ const getActionButtonVirtualDom = action => {
2199
2071
 
2200
2072
  const getActionVirtualDom = action => {
2201
2073
  switch (action.type) {
2202
- case Button$2:
2074
+ case Button$1:
2203
2075
  return getActionButtonVirtualDom(action);
2204
2076
  default:
2205
2077
  return [];
@@ -2290,27 +2162,27 @@ const Refresh = 'Refresh';
2290
2162
 
2291
2163
  const getActions = () => {
2292
2164
  return [{
2293
- type: Button$2,
2165
+ type: Button$1,
2294
2166
  id: refresh$1(),
2295
2167
  icon: Refresh,
2296
2168
  command: 'refresh'
2297
2169
  }, {
2298
- type: Button$2,
2170
+ type: Button$1,
2299
2171
  id: clearSearchResults(),
2300
2172
  icon: ClearAll,
2301
2173
  command: 'clearSearchResults'
2302
2174
  }, {
2303
- type: Button$2,
2175
+ type: Button$1,
2304
2176
  id: openNewSearchEditor(),
2305
2177
  icon: NewFile,
2306
2178
  command: ''
2307
2179
  }, {
2308
- type: Button$2,
2180
+ type: Button$1,
2309
2181
  id: viewAsTree(),
2310
2182
  icon: ListFlat,
2311
2183
  command: ''
2312
2184
  }, {
2313
- type: Button$2,
2185
+ type: Button$1,
2314
2186
  id: collapseAll(),
2315
2187
  icon: CollapseAll,
2316
2188
  command: ''
@@ -2461,7 +2333,7 @@ const getSearchDetailsToggleVirtualDom = () => {
2461
2333
  return [{
2462
2334
  type: Div,
2463
2335
  className: ToggleDetails,
2464
- role: Button$3,
2336
+ role: Button$2,
2465
2337
  tabIndex: 0,
2466
2338
  ariaLabel: toggleSearchDetails(),
2467
2339
  title: toggleSearchDetails(),
@@ -2989,7 +2861,7 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
2989
2861
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
2990
2862
  return [{
2991
2863
  type: Div,
2992
- className: mergeClassNames(Viewlet, Search$2),
2864
+ className: mergeClassNames(Viewlet, Search$1),
2993
2865
  childCount
2994
2866
  }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
2995
2867
  };
@@ -3402,6 +3274,10 @@ const noop = state => {
3402
3274
  return state;
3403
3275
  };
3404
3276
 
3277
+ const applyBulkReplacement = async bulkEdits => {
3278
+ await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
3279
+ };
3280
+
3405
3281
  const getReplacedMessage = (fileCount, replaceCount, replacement) => {
3406
3282
  if (replaceCount === 1) {
3407
3283
  return replacedOneOccurrenceInOneFile(replacement);
@@ -3466,7 +3342,7 @@ const replaceAll = async state => {
3466
3342
  matchCount
3467
3343
  } = state;
3468
3344
  const bulkEdits = getReplaceElements(items, workspacePath, replacement);
3469
- await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
3345
+ await applyBulkReplacement(bulkEdits);
3470
3346
  const fileCount = bulkEdits.length;
3471
3347
  const message = getReplacedMessage(fileCount, matchCount, replacement);
3472
3348
  return {
@@ -4069,6 +3945,7 @@ const getSavedExcludeValue = savedState => {
4069
3945
  }
4070
3946
  return '';
4071
3947
  };
3948
+
4072
3949
  const restoreState = savedState => {
4073
3950
  return {
4074
3951
  savedValue: getSavedValue(savedState),
@@ -4530,22 +4407,32 @@ const handleContextMenuMouseAt = async (state, x, y) => {
4530
4407
  return state;
4531
4408
  };
4532
4409
 
4533
- const handleContextMenu = (state, button, x, y) => {
4410
+ const getContextMenuHandler = button => {
4534
4411
  switch (button) {
4535
4412
  case Keyboard:
4536
- return handleContextMenuKeyboard(state);
4413
+ return handleContextMenuKeyboard;
4537
4414
  default:
4538
- return handleContextMenuMouseAt(state, x, y);
4415
+ return handleContextMenuMouseAt;
4539
4416
  }
4540
4417
  };
4541
4418
 
4419
+ const handleContextMenu = async (state, button, x, y) => {
4420
+ const fn = getContextMenuHandler(button);
4421
+ const newState = await fn(state, x, y);
4422
+ return newState;
4423
+ };
4424
+
4542
4425
  const wrapCommand = fn => {
4543
4426
  const wrapped = async (uid, ...args) => {
4544
4427
  const {
4545
4428
  newState
4546
4429
  } = get(uid);
4547
4430
  const newerState = await fn(newState, ...args);
4548
- set(uid, newState, newerState);
4431
+ if (newState === newerState) {
4432
+ return;
4433
+ }
4434
+ const latest = get(uid);
4435
+ set(uid, latest.oldState, newerState);
4549
4436
  };
4550
4437
  return wrapped;
4551
4438
  };
@@ -4579,11 +4466,7 @@ const commandMap = {
4579
4466
  'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
4580
4467
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
4581
4468
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
4582
- 'TextSearch.getActions': wrapCommand(getActions),
4583
- 'TextSearch.getActionsVirtualDom': wrapCommand(getActionsVirtualDom),
4584
4469
  'TextSearch.getCommandIds': getCommandIds,
4585
- 'TextSearch.getSearchDisplayResults': wrapCommand(getDisplayResults),
4586
- 'TextSearch.getVirtualDom': wrapCommand(getSearchVirtualDom),
4587
4470
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
4588
4471
  'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
4589
4472
  'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
@@ -4603,9 +4486,8 @@ const commandMap = {
4603
4486
  'TextSearch.launchSearchProcess': wrapCommand(launchSearchProcess),
4604
4487
  'TextSearch.loadContent': wrapCommand(loadContent),
4605
4488
  'TextSearch.refresh': wrapCommand(refresh),
4606
- 'TextSearch.renderActions': wrapCommand(renderActions),
4489
+ 'TextSearch.renderActions': renderActions,
4607
4490
  'TextSearch.replaceAll': wrapCommand(replaceAll),
4608
- 'TextSearch.replaceAllAndPrompt': wrapCommand(replaceAllAndPrompt),
4609
4491
  'TextSearch.selectIndex': wrapCommand(selectIndex),
4610
4492
  'TextSearch.submit': wrapCommand(submit),
4611
4493
  'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
@@ -4626,7 +4508,12 @@ const commandMap = {
4626
4508
  'TextSearch.saveState': saveState,
4627
4509
  'TextSearch.terminate': terminate,
4628
4510
  // TODO needed?
4629
- 'TextSearch.textSearch': textSearch
4511
+ 'TextSearch.replaceAllAndPrompt': replaceAllAndPrompt,
4512
+ 'TextSearch.textSearch': textSearch,
4513
+ 'TextSearch.getActions': getActions,
4514
+ 'TextSearch.getActionsVirtualDom': getActionsVirtualDom,
4515
+ 'TextSearch.getSearchDisplayResults': getDisplayResults,
4516
+ 'TextSearch.getVirtualDom': getSearchVirtualDom
4630
4517
  };
4631
4518
 
4632
4519
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"