@lvce-editor/extension-search-view 4.12.0 → 5.0.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.
@@ -1066,10 +1066,11 @@ const create$2 = () => {
1066
1066
  wrapCommand(fn) {
1067
1067
  const wrapped = async (uid, ...args) => {
1068
1068
  const {
1069
+ oldState,
1069
1070
  newState
1070
1071
  } = states[uid];
1071
1072
  const newerState = await fn(newState, ...args);
1072
- if (newState === newerState) {
1073
+ if (oldState === newerState || newState === newerState) {
1073
1074
  return;
1074
1075
  }
1075
1076
  const latest = states[uid];
@@ -1134,6 +1135,8 @@ const TargetValue = 'event.target.value';
1134
1135
 
1135
1136
  const Script$1 = 2;
1136
1137
 
1138
+ const ManageExtension$1 = 8;
1139
+
1137
1140
  const LeftClick = 0;
1138
1141
 
1139
1142
  const DebugWorker = 55;
@@ -1306,9 +1309,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1306
1309
  return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1307
1310
  };
1308
1311
 
1309
- const User = 1;
1310
- const Script = 2;
1311
-
1312
1312
  const getScrollBarY$1 = (delta, finalDelta, size, scrollBarSize) => {
1313
1313
  if (finalDelta === 0) {
1314
1314
  return 0;
@@ -1459,8 +1459,16 @@ const searchExtensions = async (extensions, value, platform, assetDir) => {
1459
1459
  };
1460
1460
 
1461
1461
  // TODO debounce
1462
- const handleInput = async (state, value, inputSource = User) => {
1462
+ const handleChange = async (state, update) => {
1463
+ const fullNewState = {
1464
+ ...state,
1465
+ ...update
1466
+ };
1463
1467
  try {
1468
+ const value = fullNewState.searchValue;
1469
+ const {
1470
+ inputSource
1471
+ } = fullNewState;
1464
1472
  const hasValue = value.length > 0;
1465
1473
  const inputActions = getInputActions(hasValue);
1466
1474
  const {
@@ -1524,18 +1532,19 @@ const handleInput = async (state, value, inputSource = User) => {
1524
1532
  // TODO send error to error worker
1525
1533
  await handleError(error);
1526
1534
  return {
1527
- ...state,
1528
- searchValue: value,
1535
+ ...fullNewState,
1529
1536
  message: `${error}`
1530
1537
  };
1531
1538
  }
1532
1539
  };
1533
1540
 
1534
1541
  const clearSearchResults = state => {
1535
- return handleInput({
1542
+ return handleChange(state, {
1536
1543
  ...state,
1537
- focus: Input
1538
- }, '', Script$1);
1544
+ focus: Input,
1545
+ searchValue: '',
1546
+ inputSource: Script$1
1547
+ });
1539
1548
  };
1540
1549
 
1541
1550
  const closeSuggest = state => {
@@ -1624,9 +1633,17 @@ const searchFileHtml = async uri => {
1624
1633
  const getFilePathElectron = async file => {
1625
1634
  return invoke$2('FileSystemHandle.getFilePathElectron', file);
1626
1635
  };
1627
- const showContextMenu$1 = async (x, y, id, ...args) => {
1636
+ const showContextMenu = async (x, y, id, ...args) => {
1628
1637
  return invoke$2('ContextMenu.show', x, y, id, ...args);
1629
1638
  };
1639
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1640
+ number(uid);
1641
+ number(menuId);
1642
+ number(x);
1643
+ number(y);
1644
+ // @ts-ignore
1645
+ await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1646
+ };
1630
1647
  const getElectronVersion = async () => {
1631
1648
  return invoke$2('Process.getElectronVersion');
1632
1649
  };
@@ -1742,6 +1759,9 @@ const getKeyBindings$1 = async () => {
1742
1759
  const writeClipBoardText = async text => {
1743
1760
  await invoke$2('ClipBoard.writeText', /* text */text);
1744
1761
  };
1762
+ const readClipBoardText = async () => {
1763
+ return invoke$2('ClipBoard.readText');
1764
+ };
1745
1765
  const writeClipBoardImage = async blob => {
1746
1766
  // @ts-ignore
1747
1767
  await invoke$2('ClipBoard.writeImage', /* text */blob);
@@ -1785,6 +1805,16 @@ const sendMessagePortToRendererProcess = async port => {
1785
1805
  // @ts-ignore
1786
1806
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1787
1807
  };
1808
+ const sendMessagePortToTextMeasurementWorker = async port => {
1809
+ const command = 'TextMeasurement.handleMessagePort';
1810
+ // @ts-ignore
1811
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1812
+ };
1813
+ const sendMessagePortToSourceControlWorker = async port => {
1814
+ const command = 'SourceControl.handleMessagePort';
1815
+ // @ts-ignore
1816
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1817
+ };
1788
1818
  const getPreference = async key => {
1789
1819
  return await invoke$2('Preferences.get', key);
1790
1820
  };
@@ -1856,7 +1886,7 @@ const openExtensionSearch = async () => {
1856
1886
  };
1857
1887
  const setExtensionsSearchValue = async searchValue => {
1858
1888
  // @ts-ignore
1859
- return invoke$2('Extensions.handleInput', searchValue);
1889
+ return invoke$2('Extensions.handleInput', searchValue, Script$1);
1860
1890
  };
1861
1891
  const openExternal = async uri => {
1862
1892
  // @ts-ignore
@@ -1933,6 +1963,7 @@ const RendererWorker = {
1933
1963
  openUri: openUri$2,
1934
1964
  openUrl,
1935
1965
  openWidget,
1966
+ readClipBoardText,
1936
1967
  readFile,
1937
1968
  registerMockRpc,
1938
1969
  registerWebViewInterceptor,
@@ -1949,7 +1980,9 @@ const RendererWorker = {
1949
1980
  sendMessagePortToMarkdownWorker,
1950
1981
  sendMessagePortToRendererProcess,
1951
1982
  sendMessagePortToSearchProcess,
1983
+ sendMessagePortToSourceControlWorker,
1952
1984
  sendMessagePortToSyntaxHighlightingWorker,
1985
+ sendMessagePortToTextMeasurementWorker,
1953
1986
  set: set$3,
1954
1987
  setAdditionalFocus,
1955
1988
  setColorTheme,
@@ -1957,7 +1990,8 @@ const RendererWorker = {
1957
1990
  setFocus,
1958
1991
  setWebViewPort,
1959
1992
  setWorkspacePath,
1960
- showContextMenu: showContextMenu$1,
1993
+ showContextMenu,
1994
+ showContextMenu2,
1961
1995
  showErrorDialog,
1962
1996
  showMessageBox,
1963
1997
  showSaveFilePicker,
@@ -2092,13 +2126,16 @@ const isEqual$2 = (oldState, newState) => {
2092
2126
  if (!newState.focus) {
2093
2127
  return true;
2094
2128
  }
2095
- return oldState.focus === newState.focus;
2129
+ return oldState.focus === newState.focus && oldState.inputSource === newState.inputSource;
2096
2130
  };
2097
2131
 
2098
2132
  const isEqual$1 = (oldState, newState) => {
2099
2133
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex && oldState.message === newState.message && oldState.inputActions === newState.inputActions && oldState.placeholder === newState.placeholder && oldState.scrollBarHeight === newState.scrollBarHeight;
2100
2134
  };
2101
2135
 
2136
+ const User = 1;
2137
+ const Script = 2;
2138
+
2102
2139
  const isEqual = (oldState, newState) => {
2103
2140
  return newState.inputSource === User || oldState.searchValue === newState.searchValue;
2104
2141
  };
@@ -2148,6 +2185,7 @@ const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength)
2148
2185
  return {
2149
2186
  ...state,
2150
2187
  focusedIndex: index,
2188
+ listFocusedIndex: index,
2151
2189
  minLineY: newMinLineY,
2152
2190
  maxLineY: newMaxLineY,
2153
2191
  focused: true,
@@ -2170,6 +2208,7 @@ const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) =
2170
2208
  return {
2171
2209
  ...state,
2172
2210
  focusedIndex: index,
2211
+ listFocusedIndex: index,
2173
2212
  minLineY: newMinLineY,
2174
2213
  maxLineY: newMaxLineY,
2175
2214
  focused: true,
@@ -2195,6 +2234,7 @@ const focusIndex = (state, index) => {
2195
2234
  return {
2196
2235
  ...state,
2197
2236
  focusedIndex: -1,
2237
+ listFocusedIndex: -1,
2198
2238
  focused: true
2199
2239
  };
2200
2240
  }
@@ -2208,6 +2248,7 @@ const focusIndex = (state, index) => {
2208
2248
  return {
2209
2249
  ...state,
2210
2250
  focusedIndex: index,
2251
+ listFocusedIndex: index,
2211
2252
  focused: true
2212
2253
  };
2213
2254
  };
@@ -2391,6 +2432,14 @@ const getMenuEntries = () => {
2391
2432
  }];
2392
2433
  };
2393
2434
 
2435
+ const getMenuEntries2 = state => {
2436
+ return getMenuEntries();
2437
+ };
2438
+
2439
+ const getMenuIds = () => {
2440
+ return [ManageExtension$1];
2441
+ };
2442
+
2394
2443
  const handleBlur = state => {
2395
2444
  return {
2396
2445
  ...state,
@@ -2405,7 +2454,6 @@ const getExtensionDetailUri = extensionId => {
2405
2454
  const {
2406
2455
  invoke: invoke$1,
2407
2456
  set: set$1,
2408
- showContextMenu,
2409
2457
  openUri: openUri$1,
2410
2458
  sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1
2411
2459
  } = RendererWorker;
@@ -2479,18 +2527,20 @@ const handleClickCurrentButKeepFocus = state => {
2479
2527
  return handleClick(state, focusedIndex);
2480
2528
  };
2481
2529
 
2482
- const show = async (x, y, id) => {
2483
- number(x);
2484
- number(y);
2485
- number(id);
2486
- await showContextMenu(x, y, id);
2530
+ const show2 = async (uid, menuId, x, y, args) => {
2531
+ await showContextMenu2(uid, menuId, x, y, args);
2487
2532
  };
2488
2533
 
2489
2534
  const ManageExtension = 8;
2490
2535
 
2491
2536
  const handleContextMenu = async (state, button, x, y) => {
2492
2537
  // TODO use focused index when when context menu button is -1 (keyboard)
2493
- await show(x, y, ManageExtension);
2538
+ const {
2539
+ uid
2540
+ } = state;
2541
+ await show2(uid, ManageExtension, x, y, {
2542
+ menuId: ManageExtension
2543
+ });
2494
2544
  return state;
2495
2545
  };
2496
2546
 
@@ -2514,6 +2564,13 @@ const handleHeaderContextMenu = async state => {
2514
2564
  return state;
2515
2565
  };
2516
2566
 
2567
+ const handleInput = async (state, value, inputSource = User) => {
2568
+ return handleChange(state, {
2569
+ searchValue: value,
2570
+ inputSource
2571
+ });
2572
+ };
2573
+
2517
2574
  // TODO show error / warning when installment fails / times out
2518
2575
  const handleInstall = async (state, id) => {
2519
2576
  return state;
@@ -3484,6 +3541,7 @@ const commandMap = {
3484
3541
  'SearchExtensions.focusFirst': wrapCommand(focusFirst),
3485
3542
  'SearchExtensions.focusIndex': wrapCommand(focusIndex),
3486
3543
  'SearchExtensions.focusLast': wrapCommand(focusLast),
3544
+ 'SearchExtensions.getMenuEntries2': wrapGetter(getMenuEntries2),
3487
3545
  'SearchExtensions.focusNext': wrapCommand(focusNext),
3488
3546
  'SearchExtensions.handleHeaderContextMenu': wrapCommand(handleHeaderContextMenu),
3489
3547
  'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
@@ -3524,7 +3582,8 @@ const commandMap = {
3524
3582
  'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
3525
3583
  'SearchExtensions.terminate': terminate,
3526
3584
  'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest),
3527
- 'SearchExtensions.resize': wrapCommand(resize)
3585
+ 'SearchExtensions.resize': wrapCommand(resize),
3586
+ 'SearchExtensions.getMenuIds': getMenuIds
3528
3587
  };
3529
3588
 
3530
3589
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "4.12.0",
3
+ "version": "5.0.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",