@lvce-editor/extension-search-view 7.22.0 → 7.24.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.
@@ -2221,6 +2221,7 @@ const requestVersionGenerator = {
2221
2221
  const getSearchResult = async state => {
2222
2222
  const {
2223
2223
  allExtensions,
2224
+ focus,
2224
2225
  headerHeight,
2225
2226
  height,
2226
2227
  itemHeight,
@@ -2253,7 +2254,7 @@ const getSearchResult = async state => {
2253
2254
  return {
2254
2255
  deltaY: 0,
2255
2256
  finalDeltaY,
2256
- focus: state.focus,
2257
+ focus,
2257
2258
  inputActions,
2258
2259
  items,
2259
2260
  maxLineY,
@@ -2281,7 +2282,10 @@ const handleChangeWithContext = async (context, update, waitForExtensions = true
2281
2282
  try {
2282
2283
  const result = await getSearchResult(requestState);
2283
2284
  await context.updateState(state => {
2284
- if (requestVersions.get(state.uid) !== requestVersion) {
2285
+ const {
2286
+ uid
2287
+ } = state;
2288
+ if (requestVersions.get(uid) !== requestVersion) {
2285
2289
  return state;
2286
2290
  }
2287
2291
  return {
@@ -2294,7 +2298,10 @@ const handleChangeWithContext = async (context, update, waitForExtensions = true
2294
2298
  } catch (error) {
2295
2299
  await handleError(error);
2296
2300
  await context.updateState(state => {
2297
- if (requestVersions.get(state.uid) !== requestVersion) {
2301
+ const {
2302
+ uid
2303
+ } = state;
2304
+ if (requestVersions.get(uid) !== requestVersion) {
2298
2305
  return state;
2299
2306
  }
2300
2307
  return {
@@ -2342,45 +2349,56 @@ const getCompletionText = (searchValue, completion, rangeEnd) => {
2342
2349
  return completion.endsWith(':') || hasTrailingWhitespace ? completion : `${completion} `;
2343
2350
  };
2344
2351
  const acceptCompletionWithContext = async (context, label) => {
2345
- const state = context.getState();
2346
- const completion = label || state.completionItems[state.completionFocusedIndex]?.label;
2352
+ const {
2353
+ completionFocusedIndex,
2354
+ completionItems,
2355
+ cursorOffset,
2356
+ searchValue
2357
+ } = context.getState();
2358
+ const completion = label || completionItems[completionFocusedIndex]?.label;
2347
2359
  if (!completion) {
2348
2360
  return;
2349
2361
  }
2350
- const range = getCompletionRange(state.searchValue, state.cursorOffset);
2362
+ const range = getCompletionRange(searchValue, cursorOffset);
2351
2363
  if (!range) {
2352
2364
  return;
2353
2365
  }
2354
- const completionText = getCompletionText(state.searchValue, completion, range.end);
2355
- const searchValue = `${state.searchValue.slice(0, range.start)}${completionText}${state.searchValue.slice(range.end)}`;
2366
+ const completionText = getCompletionText(searchValue, completion, range.end);
2367
+ const newSearchValue = `${searchValue.slice(0, range.start)}${completionText}${searchValue.slice(range.end)}`;
2356
2368
  await handleChangeWithContext(context, {
2357
2369
  completionFocusedIndex: 0,
2358
2370
  completionItems: [],
2359
2371
  cursorOffset: range.start + completionText.length,
2360
2372
  focus: Input,
2361
2373
  inputSource: Script,
2362
- searchValue,
2374
+ searchValue: newSearchValue,
2363
2375
  suggestOpen: false
2364
2376
  });
2365
2377
  };
2366
2378
  const acceptCompletion = async (state, label) => {
2367
- const completion = label || state.completionItems[state.completionFocusedIndex]?.label;
2379
+ const {
2380
+ completionFocusedIndex,
2381
+ completionItems,
2382
+ cursorOffset,
2383
+ searchValue
2384
+ } = state;
2385
+ const completion = label || completionItems[completionFocusedIndex]?.label;
2368
2386
  if (!completion) {
2369
2387
  return state;
2370
2388
  }
2371
- const range = getCompletionRange(state.searchValue, state.cursorOffset);
2389
+ const range = getCompletionRange(searchValue, cursorOffset);
2372
2390
  if (!range) {
2373
2391
  return state;
2374
2392
  }
2375
- const completionText = getCompletionText(state.searchValue, completion, range.end);
2376
- const searchValue = `${state.searchValue.slice(0, range.start)}${completionText}${state.searchValue.slice(range.end)}`;
2393
+ const completionText = getCompletionText(searchValue, completion, range.end);
2394
+ const newSearchValue = `${searchValue.slice(0, range.start)}${completionText}${searchValue.slice(range.end)}`;
2377
2395
  return handleChange(state, {
2378
2396
  completionFocusedIndex: 0,
2379
2397
  completionItems: [],
2380
2398
  cursorOffset: range.start + completionText.length,
2381
2399
  focus: Input,
2382
2400
  inputSource: Script,
2383
- searchValue,
2401
+ searchValue: newSearchValue,
2384
2402
  suggestOpen: false
2385
2403
  });
2386
2404
  };
@@ -2398,7 +2416,10 @@ const clearSearchResultsWithContext = async context => {
2398
2416
  };
2399
2417
 
2400
2418
  const closeSuggest = state => {
2401
- if (!state.suggestOpen) {
2419
+ const {
2420
+ suggestOpen
2421
+ } = state;
2422
+ if (!suggestOpen) {
2402
2423
  return state;
2403
2424
  }
2404
2425
  return {
@@ -2590,13 +2611,17 @@ const updateStatus = (extension, id, status, builtin) => {
2590
2611
  };
2591
2612
  };
2592
2613
  const setExtensionStatus = (state, id, status, builtin) => {
2614
+ const {
2615
+ allExtensions,
2616
+ items
2617
+ } = state;
2593
2618
  if (!isExtensionStatus(status)) {
2594
2619
  throw new TypeError(`Invalid extension status: ${status}`);
2595
2620
  }
2596
2621
  return {
2597
2622
  ...state,
2598
- allExtensions: state.allExtensions.map(extension => updateStatus(extension, id, status, builtin)),
2599
- items: state.items.map(extension => updateStatus(extension, id, status, builtin))
2623
+ allExtensions: allExtensions.map(extension => updateStatus(extension, id, status, builtin)),
2624
+ items: items.map(extension => updateStatus(extension, id, status, builtin))
2600
2625
  };
2601
2626
  };
2602
2627
 
@@ -3907,6 +3932,17 @@ const getMenuEntriesList = (builtin, disabled = false, status) => {
3907
3932
  }];
3908
3933
  };
3909
3934
 
3935
+ const RE_WORD_START = /\b[a-z]/g;
3936
+ const getMenuEntriesCategory = () => {
3937
+ return CategorySuggestions.map(query => ({
3938
+ args: [query],
3939
+ command: 'Extensions.filterByCategory',
3940
+ flags: None,
3941
+ id: query,
3942
+ label: query.slice(11, -1).replaceAll(RE_WORD_START, character => character.toUpperCase()).replace('Ai', 'AI').replace('Scm', 'SCM')
3943
+ }));
3944
+ };
3945
+
3910
3946
  const getMenuEntriesFilter = () => {
3911
3947
  return [{
3912
3948
  command: 'Extensions.filterByFeatured',
@@ -3939,9 +3975,13 @@ const getMenuEntriesFilter = () => {
3939
3975
  id: 'separator1',
3940
3976
  label: ''
3941
3977
  }, {
3942
- command: 'SearchExtensions.filterByCategory',
3978
+ args: [{
3979
+ menuId: ExtensionSearchFilter,
3980
+ subMenu: 'category'
3981
+ }],
3982
+ command: '',
3943
3983
  flags: SubMenu,
3944
- id: 'filterByCategory',
3984
+ id: ExtensionSearchFilter,
3945
3985
  label: category()
3946
3986
  }, {
3947
3987
  command: 'Extensions.filterByInstalled',
@@ -3997,7 +4037,7 @@ const getMenuEntries2 = (state, props) => {
3997
4037
  } = props;
3998
4038
  switch (menuId) {
3999
4039
  case ExtensionSearchFilter:
4000
- return getMenuEntriesFilter();
4040
+ return props.subMenu === 'category' ? getMenuEntriesCategory() : getMenuEntriesFilter();
4001
4041
  default:
4002
4042
  return getMenuEntriesList(props.builtin, props.disabled, props.status);
4003
4043
  }
@@ -4062,7 +4102,10 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, headerHeight) =>
4062
4102
  };
4063
4103
 
4064
4104
  const handleCompletionPointerDown = (state, label) => {
4065
- if (state.completionItems.every(item => item.label !== label)) {
4105
+ const {
4106
+ completionItems
4107
+ } = state;
4108
+ if (completionItems.every(item => item.label !== label)) {
4066
4109
  return Promise.resolve(state);
4067
4110
  }
4068
4111
  return acceptCompletion(state, label);
@@ -4119,7 +4162,8 @@ const handleClickFilter = async state => {
4119
4162
  const menuHeight = 370;
4120
4163
  const menuY = y + headerHeight + menuHeight;
4121
4164
  await show2(uid, ExtensionSearchFilter, menuX, menuY, {
4122
- menuId: ExtensionSearchFilter
4165
+ menuId: ExtensionSearchFilter,
4166
+ openSubMenuToLeft: true
4123
4167
  });
4124
4168
  return state;
4125
4169
  };
@@ -4637,9 +4681,13 @@ const handleUninstall = async (state, id) => {
4637
4681
  };
4638
4682
 
4639
4683
  const handleWheel = (state, deltaMode, deltaY) => {
4684
+ const {
4685
+ deltaY: currentDeltaY,
4686
+ scrollSensitivity
4687
+ } = state;
4640
4688
  number(deltaMode);
4641
4689
  number(deltaY);
4642
- return setDeltaY(state, state.deltaY + deltaY * state.scrollSensitivity);
4690
+ return setDeltaY(state, currentDeltaY + deltaY * scrollSensitivity);
4643
4691
  };
4644
4692
 
4645
4693
  const createExtensionManagementWorkerRpc = async () => {
@@ -4732,7 +4780,10 @@ const loadContentWithContext = async (context, savedState) => {
4732
4780
  const size = getViewletSize(width);
4733
4781
  const scrollSensitivity = getIsFirefox() ? 2.5 : 1;
4734
4782
  await context.updateState(state => {
4735
- if (!state.initial) {
4783
+ const {
4784
+ initial
4785
+ } = state;
4786
+ if (!initial) {
4736
4787
  return state;
4737
4788
  }
4738
4789
  return {
@@ -4758,7 +4809,11 @@ const loadContentWithContext = async (context, savedState) => {
4758
4809
  };
4759
4810
 
4760
4811
  const openSuggest = state => {
4761
- const completionItems = getCompletionItems(state.searchValue, state.cursorOffset);
4812
+ const {
4813
+ cursorOffset,
4814
+ searchValue
4815
+ } = state;
4816
+ const completionItems = getCompletionItems(searchValue, cursorOffset);
4762
4817
  if (completionItems.length === 0) {
4763
4818
  return state;
4764
4819
  }
@@ -5041,7 +5096,10 @@ const getTitleSuffix = searchValue => {
5041
5096
  return marketplace();
5042
5097
  };
5043
5098
  const renderTitle = state => {
5044
- return `${extensions()}: ${getTitleSuffix(state.searchValue)}`;
5099
+ const {
5100
+ searchValue
5101
+ } = state;
5102
+ return `${extensions()}: ${getTitleSuffix(searchValue)}`;
5045
5103
  };
5046
5104
 
5047
5105
  const renderTitleCommand = newState => {
@@ -5281,22 +5339,32 @@ const scrollDown = state => {
5281
5339
  };
5282
5340
 
5283
5341
  const selectNextCompletion = state => {
5284
- if (!state.suggestOpen || state.completionItems.length === 0) {
5342
+ const {
5343
+ completionFocusedIndex,
5344
+ completionItems,
5345
+ suggestOpen
5346
+ } = state;
5347
+ if (!suggestOpen || completionItems.length === 0) {
5285
5348
  return state;
5286
5349
  }
5287
5350
  return {
5288
5351
  ...state,
5289
- completionFocusedIndex: (state.completionFocusedIndex + 1) % state.completionItems.length
5352
+ completionFocusedIndex: (completionFocusedIndex + 1) % completionItems.length
5290
5353
  };
5291
5354
  };
5292
5355
 
5293
5356
  const selectPreviousCompletion = state => {
5294
- if (!state.suggestOpen || state.completionItems.length === 0) {
5357
+ const {
5358
+ completionFocusedIndex,
5359
+ completionItems,
5360
+ suggestOpen
5361
+ } = state;
5362
+ if (!suggestOpen || completionItems.length === 0) {
5295
5363
  return state;
5296
5364
  }
5297
5365
  return {
5298
5366
  ...state,
5299
- completionFocusedIndex: (state.completionFocusedIndex - 1 + state.completionItems.length) % state.completionItems.length
5367
+ completionFocusedIndex: (completionFocusedIndex - 1 + completionItems.length) % completionItems.length
5300
5368
  };
5301
5369
  };
5302
5370
 
@@ -5318,7 +5386,10 @@ const applyComponentState = (currentState, state) => {
5318
5386
  const setComponentState = wrapCommand(applyComponentState);
5319
5387
 
5320
5388
  const toggleSuggest = state => {
5321
- return state.suggestOpen ? closeSuggest(state) : openSuggest(state);
5389
+ const {
5390
+ suggestOpen
5391
+ } = state;
5392
+ return suggestOpen ? closeSuggest(state) : openSuggest(state);
5322
5393
  };
5323
5394
 
5324
5395
  const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
@@ -5338,6 +5409,7 @@ const commandMap = {
5338
5409
  'SearchExtensions.enable': wrapCommand(enable$1),
5339
5410
  'SearchExtensions.enableWorkspace': wrapCommand(enableWorkspace),
5340
5411
  'SearchExtensions.filterByBuiltin': wrapAsyncCommand(createFilterCommand(Builtin)),
5412
+ 'SearchExtensions.filterByCategory': wrapAsyncCommand(filterByValueWithContext),
5341
5413
  'SearchExtensions.filterByDisabled': wrapAsyncCommand(createFilterCommand(Disabled$2)),
5342
5414
  'SearchExtensions.filterByEnabled': wrapAsyncCommand(createFilterCommand(Enabled$1)),
5343
5415
  'SearchExtensions.filterByFeatured': wrapAsyncCommand(createFilterCommand(Featured)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "7.22.0",
3
+ "version": "7.24.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",