@lvce-editor/extension-search-view 7.9.1 → 7.10.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.
@@ -592,7 +592,10 @@ const constructError = (message, type, name) => {
592
592
  if (ErrorConstructor === Error) {
593
593
  const error = new Error(message);
594
594
  if (name && name !== 'VError') {
595
- error.name = name;
595
+ Object.defineProperty(error, 'name', {
596
+ configurable: true,
597
+ value: name
598
+ });
596
599
  }
597
600
  return error;
598
601
  }
@@ -623,31 +626,45 @@ const getParentStack = error => {
623
626
  };
624
627
  const MethodNotFound = -32601;
625
628
  const Custom = -32001;
629
+ const setStack = (error, stack) => {
630
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
631
+ if (descriptor) {
632
+ if (!descriptor.configurable && !descriptor.writable) {
633
+ return;
634
+ }
635
+ if (!descriptor.configurable && descriptor.writable) {
636
+ error.stack = stack;
637
+ return;
638
+ }
639
+ }
640
+ Object.defineProperty(error, 'stack', {
641
+ configurable: true,
642
+ value: stack,
643
+ writable: true
644
+ });
645
+ };
626
646
  const restoreExistingError = (error, currentStack) => {
627
647
  if (typeof error.stack === 'string') {
628
- error.stack = error.stack + NewLine + currentStack;
648
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
629
649
  }
630
650
  return error;
631
651
  };
632
652
  const restoreMethodNotFoundError = (error, currentStack) => {
633
653
  const restoredError = new JsonRpcError(error.message);
634
654
  const parentStack = getParentStack(error);
635
- restoredError.stack = parentStack + NewLine + currentStack;
655
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
636
656
  return restoredError;
637
657
  };
638
658
  const restoreStackFromData = (restoredError, error, currentStack) => {
639
659
  if (error.data.stack && error.data.type && error.message) {
640
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
660
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
641
661
  return;
642
662
  }
643
663
  if (error.data.stack) {
644
- restoredError.stack = error.data.stack;
664
+ setStack(restoredError, error.data.stack);
645
665
  }
646
666
  };
647
667
  const applyDataProperties = (restoredError, error) => {
648
- if (!error.data) {
649
- return;
650
- }
651
668
  restoreStackFromData(restoredError, error, getCurrentStack());
652
669
  if (error.data.codeFrame) {
653
670
  // @ts-ignore
@@ -668,7 +685,7 @@ const applyDirectProperties = (restoredError, error) => {
668
685
  const indexNewLine = getNewLineIndex(lowerStack);
669
686
  const parentStack = getParentStack(error);
670
687
  // @ts-ignore
671
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
688
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
672
689
  }
673
690
  if (error.codeFrame) {
674
691
  // @ts-ignore
@@ -2244,6 +2261,10 @@ const handleChange = async (state, update) => {
2244
2261
  const User = 1;
2245
2262
  const Script = 2;
2246
2263
 
2264
+ const getCompletionText = (searchValue, completion, rangeEnd) => {
2265
+ const hasTrailingWhitespace = /\s/.test(searchValue[rangeEnd] || '');
2266
+ return completion.endsWith(':') || hasTrailingWhitespace ? completion : `${completion} `;
2267
+ };
2247
2268
  const acceptCompletionWithContext = async (context, label) => {
2248
2269
  const state = context.getState();
2249
2270
  const completion = label || state.completionItems[state.completionFocusedIndex]?.label;
@@ -2254,11 +2275,12 @@ const acceptCompletionWithContext = async (context, label) => {
2254
2275
  if (!range) {
2255
2276
  return;
2256
2277
  }
2257
- const searchValue = `${state.searchValue.slice(0, range.start)}${completion}${state.searchValue.slice(range.end)}`;
2278
+ const completionText = getCompletionText(state.searchValue, completion, range.end);
2279
+ const searchValue = `${state.searchValue.slice(0, range.start)}${completionText}${state.searchValue.slice(range.end)}`;
2258
2280
  await handleChangeWithContext(context, {
2259
2281
  completionFocusedIndex: 0,
2260
2282
  completionItems: [],
2261
- cursorOffset: range.start + completion.length,
2283
+ cursorOffset: range.start + completionText.length,
2262
2284
  focus: Input,
2263
2285
  inputSource: Script,
2264
2286
  searchValue,
@@ -2274,11 +2296,12 @@ const acceptCompletion = async (state, label) => {
2274
2296
  if (!range) {
2275
2297
  return state;
2276
2298
  }
2277
- const searchValue = `${state.searchValue.slice(0, range.start)}${completion}${state.searchValue.slice(range.end)}`;
2299
+ const completionText = getCompletionText(state.searchValue, completion, range.end);
2300
+ const searchValue = `${state.searchValue.slice(0, range.start)}${completionText}${state.searchValue.slice(range.end)}`;
2278
2301
  return handleChange(state, {
2279
2302
  completionFocusedIndex: 0,
2280
2303
  completionItems: [],
2281
- cursorOffset: range.start + completion.length,
2304
+ cursorOffset: range.start + completionText.length,
2282
2305
  focus: Input,
2283
2306
  inputSource: Script,
2284
2307
  searchValue,
@@ -2504,6 +2527,8 @@ const enableWorkspace = async (state, _id) => {
2504
2527
  return state;
2505
2528
  };
2506
2529
 
2530
+ const CategorySuggestions = ['@category:"ai"', '@category:"azure"', '@category:"chat"', '@category:"data science"', '@category:"debuggers"', '@category:"education"', '@category:"extension packs"', '@category:"formatters"', '@category:"keymaps"', '@category:"language packs"', '@category:"linters"', '@category:"machine learning"', '@category:"notebooks"', '@category:"other"', '@category:"programming languages"', '@category:"scm providers"', '@category:"snippets"', '@category:"testing"', '@category:"themes"', '@category:"visualization"'];
2531
+
2507
2532
  const getFuzzyHighlights = (label, query) => {
2508
2533
  const lowerLabel = label.toLowerCase();
2509
2534
  const lowerQuery = query.toLowerCase();
@@ -2536,8 +2561,9 @@ const getCompletionItems = (value, cursorOffset) => {
2536
2561
  if (!range) {
2537
2562
  return [];
2538
2563
  }
2564
+ const suggestions = range.query.toLowerCase().startsWith('@category:') ? CategorySuggestions : Suggestions;
2539
2565
  const items = [];
2540
- for (const label of Suggestions) {
2566
+ for (const label of suggestions) {
2541
2567
  const highlights = getFuzzyHighlights(label, range.query);
2542
2568
  if (highlights) {
2543
2569
  items.push({
@@ -3312,17 +3338,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
3312
3338
  };
3313
3339
 
3314
3340
  const removeTrailingNavigationPatches = patches => {
3315
- // Find the last non-navigation patch
3316
- let lastNonNavigationIndex = -1;
3317
- for (let i = patches.length - 1; i >= 0; i--) {
3318
- const patch = patches[i];
3341
+ while (patches.length > 0) {
3342
+ const patch = patches.at(-1);
3319
3343
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
3320
- lastNonNavigationIndex = i;
3321
3344
  break;
3322
3345
  }
3346
+ patches.pop();
3323
3347
  }
3324
- // Return patches up to and including the last non-navigation patch
3325
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
3348
+ return patches;
3326
3349
  };
3327
3350
 
3328
3351
  const diffTree = (oldNodes, newNodes) => {
@@ -4036,6 +4059,10 @@ const getCss = state => {
4036
4059
  flex-shrink: 0;
4037
4060
  }
4038
4061
 
4062
+ .ExtensionListItemDisabled:not(.ExtensionActive) {
4063
+ background: color-mix(in srgb, var(--SideBarBackground, rgb(30, 35, 36)) 95%, black);
4064
+ }
4065
+
4039
4066
  .Extensions .ListItems {
4040
4067
  display: flex;
4041
4068
  flex-direction: column;
@@ -4181,6 +4208,7 @@ const ExtensionListItemActionInstall = 'ExtensionListItemActionInstall';
4181
4208
  const ExtensionListItemAuthorName = 'ExtensionListItemAuthorName';
4182
4209
  const ExtensionListItemDescription = 'ExtensionListItemDescription';
4183
4210
  const ExtensionListItemDetail = 'ExtensionListItemDetail';
4211
+ const ExtensionListItemDisabled = 'ExtensionListItemDisabled';
4184
4212
  const ExtensionListItemDownloadCount = 'ExtensionListItemDownloadCount';
4185
4213
  const ExtensionListItemFooter = 'ExtensionListItemFooter';
4186
4214
  const ExtensionListItemIcon = 'ExtensionListItemIcon';
@@ -4485,11 +4513,8 @@ const listItemAuthorName = {
4485
4513
  className: ExtensionListItemAuthorName,
4486
4514
  type: Div
4487
4515
  };
4488
- const getClassName = focused => {
4489
- if (focused) {
4490
- return mergeClassNames(ExtensionListItem, ExtensionActive);
4491
- }
4492
- return ExtensionListItem;
4516
+ const getClassName = (focused, disabled) => {
4517
+ return mergeClassNames(ExtensionListItem, focused ? ExtensionActive : '', disabled ? ExtensionListItemDisabled : '');
4493
4518
  };
4494
4519
  const getId = focused => {
4495
4520
  if (focused) {
@@ -4519,7 +4544,7 @@ const getExtensionListItemVirtualDom = extension => {
4519
4544
  ariaRoleDescription: Extension,
4520
4545
  ariaSetSize: setSize,
4521
4546
  childCount: 2,
4522
- className: getClassName(focused),
4547
+ className: getClassName(focused, disabled),
4523
4548
  id: getId(focused),
4524
4549
  role: ListItem,
4525
4550
  type: Div
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "7.9.1",
3
+ "version": "7.10.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",