@lvce-editor/extension-search-view 7.9.1 → 7.11.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
@@ -777,7 +794,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
777
794
  const errorProperty = getErrorProperty(error, prettyError);
778
795
  return create$1$1(id, errorProperty);
779
796
  };
780
- const create$a = (message, result) => {
797
+ const create$b = (message, result) => {
781
798
  return {
782
799
  id: message.id,
783
800
  jsonrpc: Two$1,
@@ -786,7 +803,7 @@ const create$a = (message, result) => {
786
803
  };
787
804
  const getSuccessResponse = (message, result) => {
788
805
  const resultProperty = result ?? null;
789
- return create$a(message, resultProperty);
806
+ return create$b(message, resultProperty);
790
807
  };
791
808
  const getErrorResponseSimple = (id, error) => {
792
809
  return {
@@ -880,7 +897,7 @@ const handleJsonRpcMessage = async (...args) => {
880
897
 
881
898
  const Two = '2.0';
882
899
 
883
- const create$9 = (method, params) => {
900
+ const create$a = (method, params) => {
884
901
  return {
885
902
  jsonrpc: Two,
886
903
  method,
@@ -888,7 +905,7 @@ const create$9 = (method, params) => {
888
905
  };
889
906
  };
890
907
 
891
- const create$8 = (id, method, params) => {
908
+ const create$9 = (id, method, params) => {
892
909
  const message = {
893
910
  id,
894
911
  jsonrpc: Two,
@@ -899,12 +916,12 @@ const create$8 = (id, method, params) => {
899
916
  };
900
917
 
901
918
  let id$1 = 0;
902
- const create$7 = () => {
919
+ const create$8 = () => {
903
920
  return ++id$1;
904
921
  };
905
922
 
906
923
  const registerPromise = map => {
907
- const id = create$7();
924
+ const id = create$8();
908
925
  const {
909
926
  promise,
910
927
  resolve
@@ -921,7 +938,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
921
938
  id,
922
939
  promise
923
940
  } = registerPromise(callbacks);
924
- const message = create$8(id, method, params);
941
+ const message = create$9(id, method, params);
925
942
  if (useSendAndTransfer && ipc.sendAndTransfer) {
926
943
  ipc.sendAndTransfer(message);
927
944
  } else {
@@ -957,7 +974,7 @@ const createRpc = ipc => {
957
974
  * @deprecated
958
975
  */
959
976
  send(method, ...params) {
960
- const message = create$9(method, params);
977
+ const message = create$a(method, params);
961
978
  ipc.send(message);
962
979
  }
963
980
  };
@@ -997,7 +1014,7 @@ const listen$1 = async (module, options) => {
997
1014
  return ipc;
998
1015
  };
999
1016
 
1000
- const create$6 = async ({
1017
+ const create$7 = async ({
1001
1018
  commandMap,
1002
1019
  isMessagePortOpen = true,
1003
1020
  messagePort
@@ -1015,7 +1032,7 @@ const create$6 = async ({
1015
1032
  return rpc;
1016
1033
  };
1017
1034
 
1018
- const create$5 = async ({
1035
+ const create$6 = async ({
1019
1036
  commandMap,
1020
1037
  isMessagePortOpen,
1021
1038
  send
@@ -1025,13 +1042,55 @@ const create$5 = async ({
1025
1042
  port2
1026
1043
  } = new MessageChannel();
1027
1044
  await send(port1);
1028
- return create$6({
1045
+ return create$7({
1029
1046
  commandMap,
1030
1047
  isMessagePortOpen,
1031
1048
  messagePort: port2
1032
1049
  });
1033
1050
  };
1034
1051
 
1052
+ const createSharedLazyRpc = factory => {
1053
+ let rpcPromise;
1054
+ const getOrCreate = () => {
1055
+ if (!rpcPromise) {
1056
+ rpcPromise = factory();
1057
+ }
1058
+ return rpcPromise;
1059
+ };
1060
+ return {
1061
+ async dispose() {
1062
+ const rpc = await getOrCreate();
1063
+ await rpc.dispose();
1064
+ },
1065
+ async invoke(method, ...params) {
1066
+ const rpc = await getOrCreate();
1067
+ return rpc.invoke(method, ...params);
1068
+ },
1069
+ async invokeAndTransfer(method, ...params) {
1070
+ const rpc = await getOrCreate();
1071
+ return rpc.invokeAndTransfer(method, ...params);
1072
+ },
1073
+ async send(method, ...params) {
1074
+ const rpc = await getOrCreate();
1075
+ rpc.send(method, ...params);
1076
+ }
1077
+ };
1078
+ };
1079
+
1080
+ const create$5 = async ({
1081
+ commandMap,
1082
+ isMessagePortOpen,
1083
+ send
1084
+ }) => {
1085
+ return createSharedLazyRpc(() => {
1086
+ return create$6({
1087
+ commandMap,
1088
+ isMessagePortOpen,
1089
+ send
1090
+ });
1091
+ });
1092
+ };
1093
+
1035
1094
  const create$4 = async ({
1036
1095
  commandMap
1037
1096
  }) => {
@@ -1064,7 +1123,7 @@ const createMockRpc = ({
1064
1123
  };
1065
1124
 
1066
1125
  const rpcs = Object.create(null);
1067
- const set$5 = (id, rpc) => {
1126
+ const set$6 = (id, rpc) => {
1068
1127
  rpcs[id] = rpc;
1069
1128
  };
1070
1129
  const get$1 = id => {
@@ -1097,7 +1156,7 @@ const create$3 = rpcId => {
1097
1156
  const mockRpc = createMockRpc({
1098
1157
  commandMap
1099
1158
  });
1100
- set$5(rpcId, mockRpc);
1159
+ set$6(rpcId, mockRpc);
1101
1160
  // @ts-ignore
1102
1161
  mockRpc[Symbol.dispose] = () => {
1103
1162
  remove(rpcId);
@@ -1106,7 +1165,7 @@ const create$3 = rpcId => {
1106
1165
  return mockRpc;
1107
1166
  },
1108
1167
  set(rpc) {
1109
- set$5(rpcId, rpc);
1168
+ set$6(rpcId, rpc);
1110
1169
  }
1111
1170
  };
1112
1171
  };
@@ -1298,6 +1357,7 @@ const ExtensionSearchFilter = 95;
1298
1357
 
1299
1358
  const LeftClick = 0;
1300
1359
 
1360
+ const DialogWorker = 7014;
1301
1361
  const ExtensionHostWorker = 44;
1302
1362
  const ExtensionManagementWorker = 9006;
1303
1363
  const RendererWorker = 1;
@@ -1307,6 +1367,11 @@ const SetCss = 'Viewlet.setCss';
1307
1367
  const SetDom2 = 'Viewlet.setDom2';
1308
1368
  const SetPatches = 'Viewlet.setPatches';
1309
1369
 
1370
+ const {
1371
+ invoke: invoke$3,
1372
+ set: set$5
1373
+ } = create$3(DialogWorker);
1374
+
1310
1375
  const {
1311
1376
  invoke: invoke$2,
1312
1377
  set: set$4
@@ -1334,6 +1399,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1334
1399
  number(y);
1335
1400
  await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1336
1401
  };
1402
+ const sendMessagePortToDialogWorker = async port => {
1403
+ const command = 'HandleMessagePort.handleMessagePort';
1404
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1405
+ };
1337
1406
  const disableExtension = async id => {
1338
1407
  return invoke$1('ExtensionManagement.disable', id);
1339
1408
  };
@@ -1344,10 +1413,6 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1344
1413
  const command = 'HandleMessagePort.handleMessagePort2';
1345
1414
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1346
1415
  };
1347
- const confirm = async (message, options) => {
1348
- const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1349
- return result;
1350
- };
1351
1416
  const writeClipBoardText = async text => {
1352
1417
  await invoke$1('ClipBoard.writeText', /* text */text);
1353
1418
  };
@@ -2244,6 +2309,10 @@ const handleChange = async (state, update) => {
2244
2309
  const User = 1;
2245
2310
  const Script = 2;
2246
2311
 
2312
+ const getCompletionText = (searchValue, completion, rangeEnd) => {
2313
+ const hasTrailingWhitespace = /\s/.test(searchValue[rangeEnd] || '');
2314
+ return completion.endsWith(':') || hasTrailingWhitespace ? completion : `${completion} `;
2315
+ };
2247
2316
  const acceptCompletionWithContext = async (context, label) => {
2248
2317
  const state = context.getState();
2249
2318
  const completion = label || state.completionItems[state.completionFocusedIndex]?.label;
@@ -2254,11 +2323,12 @@ const acceptCompletionWithContext = async (context, label) => {
2254
2323
  if (!range) {
2255
2324
  return;
2256
2325
  }
2257
- const searchValue = `${state.searchValue.slice(0, range.start)}${completion}${state.searchValue.slice(range.end)}`;
2326
+ const completionText = getCompletionText(state.searchValue, completion, range.end);
2327
+ const searchValue = `${state.searchValue.slice(0, range.start)}${completionText}${state.searchValue.slice(range.end)}`;
2258
2328
  await handleChangeWithContext(context, {
2259
2329
  completionFocusedIndex: 0,
2260
2330
  completionItems: [],
2261
- cursorOffset: range.start + completion.length,
2331
+ cursorOffset: range.start + completionText.length,
2262
2332
  focus: Input,
2263
2333
  inputSource: Script,
2264
2334
  searchValue,
@@ -2274,11 +2344,12 @@ const acceptCompletion = async (state, label) => {
2274
2344
  if (!range) {
2275
2345
  return state;
2276
2346
  }
2277
- const searchValue = `${state.searchValue.slice(0, range.start)}${completion}${state.searchValue.slice(range.end)}`;
2347
+ const completionText = getCompletionText(state.searchValue, completion, range.end);
2348
+ const searchValue = `${state.searchValue.slice(0, range.start)}${completionText}${state.searchValue.slice(range.end)}`;
2278
2349
  return handleChange(state, {
2279
2350
  completionFocusedIndex: 0,
2280
2351
  completionItems: [],
2281
- cursorOffset: range.start + completion.length,
2352
+ cursorOffset: range.start + completionText.length,
2282
2353
  focus: Input,
2283
2354
  inputSource: Script,
2284
2355
  searchValue,
@@ -2480,12 +2551,12 @@ const diff2 = uid => {
2480
2551
  };
2481
2552
 
2482
2553
  const disable$1 = async (state, _id) => {
2483
- await confirm('not implemented');
2554
+ await invoke$3('ConfirmPrompt.prompt', 'not implemented', undefined);
2484
2555
  return state;
2485
2556
  };
2486
2557
 
2487
2558
  const disableWorkspace = async (state, _id) => {
2488
- await confirm('not implemented');
2559
+ await invoke$3('ConfirmPrompt.prompt', 'not implemented', undefined);
2489
2560
  return state;
2490
2561
  };
2491
2562
 
@@ -2495,15 +2566,17 @@ const dispose = uid => {
2495
2566
  };
2496
2567
 
2497
2568
  const enable$1 = async (state, _id) => {
2498
- await confirm('not implemented');
2569
+ await invoke$3('ConfirmPrompt.prompt', 'not implemented', undefined);
2499
2570
  return state;
2500
2571
  };
2501
2572
 
2502
2573
  const enableWorkspace = async (state, _id) => {
2503
- await confirm('not implemented');
2574
+ await invoke$3('ConfirmPrompt.prompt', 'not implemented', undefined);
2504
2575
  return state;
2505
2576
  };
2506
2577
 
2578
+ 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"'];
2579
+
2507
2580
  const getFuzzyHighlights = (label, query) => {
2508
2581
  const lowerLabel = label.toLowerCase();
2509
2582
  const lowerQuery = query.toLowerCase();
@@ -2536,8 +2609,9 @@ const getCompletionItems = (value, cursorOffset) => {
2536
2609
  if (!range) {
2537
2610
  return [];
2538
2611
  }
2612
+ const suggestions = range.query.toLowerCase().startsWith('@category:') ? CategorySuggestions : Suggestions;
2539
2613
  const items = [];
2540
- for (const label of Suggestions) {
2614
+ for (const label of suggestions) {
2541
2615
  const highlights = getFuzzyHighlights(label, range.query);
2542
2616
  if (highlights) {
2543
2617
  items.push({
@@ -3312,17 +3386,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
3312
3386
  };
3313
3387
 
3314
3388
  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];
3389
+ while (patches.length > 0) {
3390
+ const patch = patches.at(-1);
3319
3391
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
3320
- lastNonNavigationIndex = i;
3321
3392
  break;
3322
3393
  }
3394
+ patches.pop();
3323
3395
  }
3324
- // Return patches up to and including the last non-navigation patch
3325
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
3396
+ return patches;
3326
3397
  };
3327
3398
 
3328
3399
  const diffTree = (oldNodes, newNodes) => {
@@ -3676,7 +3747,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
3676
3747
 
3677
3748
  const createExtensionHostWorkerRpc = async () => {
3678
3749
  try {
3679
- const rpc = await create$5({
3750
+ const rpc = await create$6({
3680
3751
  commandMap: {},
3681
3752
  send: sendMessagePortToExtensionHostWorker
3682
3753
  });
@@ -3698,7 +3769,7 @@ const initializeExtensionHostWorker = async () => {
3698
3769
 
3699
3770
  const createExtensionManagementWorkerRpc = async () => {
3700
3771
  try {
3701
- const rpc = await create$5({
3772
+ const rpc = await create$6({
3702
3773
  commandMap: {},
3703
3774
  send: port => sendMessagePortToExtensionManagementWorker(port, 0)
3704
3775
  });
@@ -3722,7 +3793,7 @@ const initialize = async () => {
3722
3793
  };
3723
3794
 
3724
3795
  const installAnotherVersion = async state => {
3725
- await confirm('not implemented');
3796
+ await invoke$3('ConfirmPrompt.prompt', 'not implemented', undefined);
3726
3797
  return state;
3727
3798
  };
3728
3799
 
@@ -4036,6 +4107,10 @@ const getCss = state => {
4036
4107
  flex-shrink: 0;
4037
4108
  }
4038
4109
 
4110
+ .ExtensionListItemDisabled:not(.ExtensionActive) {
4111
+ background: color-mix(in srgb, var(--SideBarBackground, rgb(30, 35, 36)) 95%, black);
4112
+ }
4113
+
4039
4114
  .Extensions .ListItems {
4040
4115
  display: flex;
4041
4116
  flex-direction: column;
@@ -4181,6 +4256,7 @@ const ExtensionListItemActionInstall = 'ExtensionListItemActionInstall';
4181
4256
  const ExtensionListItemAuthorName = 'ExtensionListItemAuthorName';
4182
4257
  const ExtensionListItemDescription = 'ExtensionListItemDescription';
4183
4258
  const ExtensionListItemDetail = 'ExtensionListItemDetail';
4259
+ const ExtensionListItemDisabled = 'ExtensionListItemDisabled';
4184
4260
  const ExtensionListItemDownloadCount = 'ExtensionListItemDownloadCount';
4185
4261
  const ExtensionListItemFooter = 'ExtensionListItemFooter';
4186
4262
  const ExtensionListItemIcon = 'ExtensionListItemIcon';
@@ -4485,11 +4561,8 @@ const listItemAuthorName = {
4485
4561
  className: ExtensionListItemAuthorName,
4486
4562
  type: Div
4487
4563
  };
4488
- const getClassName = focused => {
4489
- if (focused) {
4490
- return mergeClassNames(ExtensionListItem, ExtensionActive);
4491
- }
4492
- return ExtensionListItem;
4564
+ const getClassName = (focused, disabled) => {
4565
+ return mergeClassNames(ExtensionListItem, focused ? ExtensionActive : '', disabled ? ExtensionListItemDisabled : '');
4493
4566
  };
4494
4567
  const getId = focused => {
4495
4568
  if (focused) {
@@ -4519,7 +4592,7 @@ const getExtensionListItemVirtualDom = extension => {
4519
4592
  ariaRoleDescription: Extension,
4520
4593
  ariaSetSize: setSize,
4521
4594
  childCount: 2,
4522
- className: getClassName(focused),
4595
+ className: getClassName(focused, disabled),
4523
4596
  id: getId(focused),
4524
4597
  role: ListItem,
4525
4598
  type: Div
@@ -5115,6 +5188,11 @@ const listen = async () => {
5115
5188
  commandMap: commandMap
5116
5189
  });
5117
5190
  set$2(rpc);
5191
+ const dialogRpc = await create$5({
5192
+ commandMap: {},
5193
+ send: sendMessagePortToDialogWorker
5194
+ });
5195
+ set$5(dialogRpc);
5118
5196
  };
5119
5197
 
5120
5198
  const main = async () => {
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.11.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",