@lvce-editor/quick-pick-worker 4.4.0 → 4.4.2

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.
@@ -598,7 +598,10 @@ const constructError = (message, type, name) => {
598
598
  if (ErrorConstructor === Error) {
599
599
  const error = new Error(message);
600
600
  if (name && name !== 'VError') {
601
- error.name = name;
601
+ Object.defineProperty(error, 'name', {
602
+ configurable: true,
603
+ value: name
604
+ });
602
605
  }
603
606
  return error;
604
607
  }
@@ -615,8 +618,10 @@ const getCurrentStack = () => {
615
618
  const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
616
619
  return currentStack;
617
620
  };
618
- const getNewLineIndex = (string, startIndex = undefined) => {
619
- return string.indexOf(NewLine, startIndex);
621
+ const getNewLineIndex = (string, startIndex) => {
622
+ {
623
+ return string.indexOf(NewLine);
624
+ }
620
625
  };
621
626
  const getParentStack = error => {
622
627
  let parentStack = error.stack || error.data || error.message || '';
@@ -627,55 +632,91 @@ const getParentStack = error => {
627
632
  };
628
633
  const MethodNotFound = -32601;
629
634
  const Custom$2 = -32001;
635
+ const setStack = (error, stack) => {
636
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
637
+ if (descriptor) {
638
+ if (!descriptor.configurable && !descriptor.writable) {
639
+ return;
640
+ }
641
+ if (!descriptor.configurable && descriptor.writable) {
642
+ error.stack = stack;
643
+ return;
644
+ }
645
+ }
646
+ Object.defineProperty(error, 'stack', {
647
+ configurable: true,
648
+ value: stack,
649
+ writable: true
650
+ });
651
+ };
652
+ const restoreExistingError = (error, currentStack) => {
653
+ if (typeof error.stack === 'string') {
654
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
655
+ }
656
+ return error;
657
+ };
658
+ const restoreMethodNotFoundError = (error, currentStack) => {
659
+ const restoredError = new JsonRpcError(error.message);
660
+ const parentStack = getParentStack(error);
661
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
662
+ return restoredError;
663
+ };
664
+ const restoreStackFromData = (restoredError, error, currentStack) => {
665
+ if (error.data.stack && error.data.type && error.message) {
666
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
667
+ return;
668
+ }
669
+ if (error.data.stack) {
670
+ setStack(restoredError, error.data.stack);
671
+ }
672
+ };
673
+ const applyDataProperties = (restoredError, error) => {
674
+ restoreStackFromData(restoredError, error, getCurrentStack());
675
+ if (error.data.codeFrame) {
676
+ // @ts-ignore
677
+ restoredError.codeFrame = error.data.codeFrame;
678
+ }
679
+ if (error.data.code) {
680
+ // @ts-ignore
681
+ restoredError.code = error.data.code;
682
+ }
683
+ if (error.data.type) {
684
+ // @ts-ignore
685
+ restoredError.name = error.data.type;
686
+ }
687
+ };
688
+ const applyDirectProperties = (restoredError, error) => {
689
+ if (error.stack) {
690
+ const lowerStack = restoredError.stack || '';
691
+ const indexNewLine = getNewLineIndex(lowerStack);
692
+ const parentStack = getParentStack(error);
693
+ // @ts-ignore
694
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
695
+ }
696
+ if (error.codeFrame) {
697
+ // @ts-ignore
698
+ restoredError.codeFrame = error.codeFrame;
699
+ }
700
+ };
701
+ const restoreMessageError = (error, _currentStack) => {
702
+ const restoredError = constructError(error.message, error.type, error.name);
703
+ if (error.data) {
704
+ applyDataProperties(restoredError, error);
705
+ } else {
706
+ applyDirectProperties(restoredError, error);
707
+ }
708
+ return restoredError;
709
+ };
630
710
  const restoreJsonRpcError = error => {
631
711
  const currentStack = getCurrentStack();
632
712
  if (error && error instanceof Error) {
633
- if (typeof error.stack === 'string') {
634
- error.stack = error.stack + NewLine + currentStack;
635
- }
636
- return error;
713
+ return restoreExistingError(error, currentStack);
637
714
  }
638
715
  if (error && error.code && error.code === MethodNotFound) {
639
- const restoredError = new JsonRpcError(error.message);
640
- const parentStack = getParentStack(error);
641
- restoredError.stack = parentStack + NewLine + currentStack;
642
- return restoredError;
716
+ return restoreMethodNotFoundError(error, currentStack);
643
717
  }
644
718
  if (error && error.message) {
645
- const restoredError = constructError(error.message, error.type, error.name);
646
- if (error.data) {
647
- if (error.data.stack && error.data.type && error.message) {
648
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
649
- } else if (error.data.stack) {
650
- restoredError.stack = error.data.stack;
651
- }
652
- if (error.data.codeFrame) {
653
- // @ts-ignore
654
- restoredError.codeFrame = error.data.codeFrame;
655
- }
656
- if (error.data.code) {
657
- // @ts-ignore
658
- restoredError.code = error.data.code;
659
- }
660
- if (error.data.type) {
661
- // @ts-ignore
662
- restoredError.name = error.data.type;
663
- }
664
- } else {
665
- if (error.stack) {
666
- const lowerStack = restoredError.stack || '';
667
- // @ts-ignore
668
- const indexNewLine = getNewLineIndex(lowerStack);
669
- const parentStack = getParentStack(error);
670
- // @ts-ignore
671
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
672
- }
673
- if (error.codeFrame) {
674
- // @ts-ignore
675
- restoredError.codeFrame = error.codeFrame;
676
- }
677
- }
678
- return restoredError;
719
+ return restoreMessageError(error);
679
720
  }
680
721
  if (typeof error === 'string') {
681
722
  return new Error(`JsonRpc Error: ${error}`);
@@ -880,9 +921,9 @@ const create$a = (id, method, params) => {
880
921
  return message;
881
922
  };
882
923
 
883
- let id$2 = 0;
924
+ let id = 0;
884
925
  const create$9 = () => {
885
- return ++id$2;
926
+ return ++id;
886
927
  };
887
928
 
888
929
  const registerPromise = map => {
@@ -1135,13 +1176,6 @@ const create$4 = rpcId => {
1135
1176
  };
1136
1177
  };
1137
1178
 
1138
- const Div = 4;
1139
- const Input = 6;
1140
- const Span = 8;
1141
- const Text = 12;
1142
- const Img = 17;
1143
- const Reference = 100;
1144
-
1145
1179
  const EditorWorker = 99;
1146
1180
  const ExtensionManagementWorker = 9006;
1147
1181
  const RendererWorker = 1;
@@ -1217,9 +1251,11 @@ const closeWidget = async id => {
1217
1251
  await closeWidget$1(id);
1218
1252
  };
1219
1253
 
1220
- let id$1 = 0;
1254
+ const state$3 = {
1255
+ value: 0
1256
+ };
1221
1257
  const create$3 = () => {
1222
- return ++id$1;
1258
+ return ++state$3.value;
1223
1259
  };
1224
1260
 
1225
1261
  const callbacks$1 = Object.create(null);
@@ -1887,7 +1923,7 @@ const next = (items, index) => {
1887
1923
  return (index + 1) % items.length;
1888
1924
  };
1889
1925
  const previous = (items, index) => {
1890
- return index === 0 ? items.length - 1 : index - 1;
1926
+ return (index === 0 ? items.length : index) - 1;
1891
1927
  };
1892
1928
 
1893
1929
  const focusFirst = state => {
@@ -2434,7 +2470,7 @@ const warn = (...args) => {
2434
2470
  console.warn(...args);
2435
2471
  };
2436
2472
 
2437
- const state$1 = {
2473
+ const state$2 = {
2438
2474
  menuEntries: []
2439
2475
  };
2440
2476
  const getAll = async () => {
@@ -2445,10 +2481,10 @@ const getAll = async () => {
2445
2481
  } catch {
2446
2482
  // ignore
2447
2483
  }
2448
- return state$1.menuEntries;
2484
+ return state$2.menuEntries;
2449
2485
  };
2450
2486
  const add$1 = menuEntries => {
2451
- state$1.menuEntries = [...state$1.menuEntries, ...menuEntries];
2487
+ state$2.menuEntries = [...state$2.menuEntries, ...menuEntries];
2452
2488
  };
2453
2489
 
2454
2490
  const changeLanguageModePick = {
@@ -2519,30 +2555,34 @@ const getPicks$c = async (value, args, {
2519
2555
  return converted;
2520
2556
  };
2521
2557
 
2522
- const state = {
2558
+ const state$1 = {
2523
2559
  args: [],
2524
2560
  items: Object.create(null)
2525
2561
  };
2526
2562
 
2527
- let id = 0;
2563
+ const idState = {
2564
+ value: 0
2565
+ };
2528
2566
  const add = items => {
2529
- const nextId = ++id;
2530
- state.items[nextId] = items;
2567
+ const nextId = ++idState.value;
2568
+ state$1.items[nextId] = items;
2531
2569
  return nextId;
2532
2570
  };
2533
2571
  const get = id => {
2534
- return state.items[id] || [];
2572
+ return state$1.items[id] || [];
2535
2573
  };
2536
2574
  const remove = id => {
2537
- delete state.items[id];
2575
+ delete state$1.items[id];
2538
2576
  };
2539
2577
 
2540
- let rpc;
2578
+ const state = {
2579
+ rpc: undefined
2580
+ };
2541
2581
  const set = newRpc => {
2542
- rpc = newRpc;
2582
+ state.rpc = newRpc;
2543
2583
  };
2544
2584
  const invoke = (method, ...args) => {
2545
- return rpc.invoke(method, ...args);
2585
+ return state.rpc.invoke(method, ...args);
2546
2586
  };
2547
2587
 
2548
2588
  const toProtoVisibleItem$2 = item => {
@@ -2563,9 +2603,14 @@ const toProtoVisibleItem$2 = item => {
2563
2603
  };
2564
2604
  };
2565
2605
  const getPicks$b = async (searchValue, args) => {
2566
- state.args = args;
2606
+ state$1.args = args;
2567
2607
  const options = args.at(-1);
2568
- const items = options?.mode === 'quickInput' ? searchValue === '' && options?.customItemsId ? get(options.customItemsId) : await invoke('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue) : options?.customItemsId ? get(options.customItemsId) : args[1] || [];
2608
+ let items;
2609
+ if (options?.mode === 'quickInput') {
2610
+ items = searchValue === '' && options?.customItemsId ? get(options.customItemsId) : await invoke('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue);
2611
+ } else {
2612
+ items = options?.customItemsId ? get(options.customItemsId) : args[1] || [];
2613
+ }
2569
2614
  const mapped = items.map(toProtoVisibleItem$2);
2570
2615
  return mapped;
2571
2616
  };
@@ -2688,7 +2733,7 @@ const QuickOpen = 'Quick open';
2688
2733
  const SearchForText = 'Search for text';
2689
2734
  const ShowAndRunCommands = 'Show And Run Commands';
2690
2735
  const TypeNameOfCommandToRun = 'Type the name of a command to run.';
2691
- const PressEnterToGoToLine = `Press 'Enter' to go to line {PH1} column {PH2}`;
2736
+ const PressEnterToGoToLine = "Press 'Enter' to go to line {PH1} column {PH2}";
2692
2737
 
2693
2738
  const pressEnterToGoToLine = (row, column) => {
2694
2739
  return i18nString(PressEnterToGoToLine, {
@@ -2730,7 +2775,7 @@ const getPicksGoToColumn = async value => {
2730
2775
  }
2731
2776
  if (value.startsWith(GoToColumn)) {
2732
2777
  const columnString = value.slice(GoToColumn.length);
2733
- const wantedColumn = Number.parseInt(columnString, 10);
2778
+ const wantedColumn = Number(columnString);
2734
2779
  if (Number.isNaN(wantedColumn)) {
2735
2780
  return getPicksGoToColumnBase();
2736
2781
  }
@@ -2773,7 +2818,7 @@ const getPicksGoToLineBase = async () => {
2773
2818
 
2774
2819
  const parseGotoline = value => {
2775
2820
  const lineString = value.slice(GoToLine$1.length);
2776
- const wantedLine = Number.parseInt(lineString, 10);
2821
+ const wantedLine = Number(lineString);
2777
2822
  if (Number.isNaN(wantedLine)) {
2778
2823
  return -1;
2779
2824
  }
@@ -2874,7 +2919,8 @@ const getIconName = language => {
2874
2919
  if (!extension) {
2875
2920
  return '';
2876
2921
  }
2877
- return `file${extension.startsWith('.') ? extension : `.${extension}`}`;
2922
+ const normalizedExtension = extension.startsWith('.') ? extension : `.${extension}`;
2923
+ return `file${normalizedExtension}`;
2878
2924
  };
2879
2925
  const toProtoVisibleItem$1 = language => {
2880
2926
  const iconName = getIconName(language);
@@ -3027,7 +3073,7 @@ const selectPickExtension = async item => {
3027
3073
  };
3028
3074
  }
3029
3075
  return {
3030
- command: KeepOpen
3076
+ command: Hide
3031
3077
  };
3032
3078
  };
3033
3079
  const selectPick$9 = async item => {
@@ -3051,7 +3097,7 @@ const getOptions = args => {
3051
3097
  const selectPick$8 = async (_pick, value) => {
3052
3098
  const {
3053
3099
  args
3054
- } = state;
3100
+ } = state$1;
3055
3101
  const options = getOptions(args);
3056
3102
  const resolveId = args[2];
3057
3103
  const result = options.mode === 'quickPick' ? _pick.value : {
@@ -3100,7 +3146,7 @@ const goToPositionAndFocus = async (rowIndex, columnIndex) => {
3100
3146
  const selectPickGoToColumn = async (item, value) => {
3101
3147
  if (value.startsWith(GoToColumn)) {
3102
3148
  const columnString = value.slice(2);
3103
- const wantedColumn = Number.parseInt(columnString, 10);
3149
+ const wantedColumn = Number(columnString);
3104
3150
  const text = await getText();
3105
3151
  const position = getPosition(text, wantedColumn);
3106
3152
  await goToPositionAndFocus(position.row, position.column);
@@ -3116,7 +3162,7 @@ const selectPickGoToColumn = async (item, value) => {
3116
3162
  const selectPick$6 = async (item, value) => {
3117
3163
  if (value.startsWith(GoToLine$1)) {
3118
3164
  const lineString = value.slice(GoToLine$1.length);
3119
- const wantedLine = Number.parseInt(lineString, 10);
3165
+ const wantedLine = Number(lineString);
3120
3166
  const rowIndex = wantedLine - 1;
3121
3167
  const columnIndex = 0;
3122
3168
  await goToPositionAndFocus(rowIndex, columnIndex);
@@ -3232,6 +3278,9 @@ const requestVersions = new Map();
3232
3278
  const requestVersionGenerator = {
3233
3279
  value: 0
3234
3280
  };
3281
+ const isSamePicker = (state, latestState) => {
3282
+ return latestState.uri === state.uri && latestState.args === state.args;
3283
+ };
3235
3284
  const isQuickInput = args => {
3236
3285
  const options = args.at(-1);
3237
3286
  return options?.mode === 'quickInput';
@@ -3291,7 +3340,7 @@ const setValueWithContext = async (context, newValue) => {
3291
3340
  requestVersions.set(state.uid, requestVersion);
3292
3341
  const result = await setValue(state, newValue);
3293
3342
  await context.updateState(latestState => {
3294
- if (requestVersions.get(latestState.uid) !== requestVersion) {
3343
+ if (requestVersions.get(latestState.uid) !== requestVersion || !isSamePicker(state, latestState)) {
3295
3344
  return latestState;
3296
3345
  }
3297
3346
  return {
@@ -3461,7 +3510,8 @@ const waitUntilVisible = () => {
3461
3510
  return promise;
3462
3511
  };
3463
3512
  const notifyVisible = () => {
3464
- const pendingCallbacks = callbacks.splice(0);
3513
+ const pendingCallbacks = [...callbacks];
3514
+ callbacks.length = 0;
3465
3515
  for (const callback of pendingCallbacks) {
3466
3516
  callback();
3467
3517
  }
@@ -3697,6 +3747,13 @@ const renderHeight = (_oldState, newState) => {
3697
3747
  return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */height];
3698
3748
  };
3699
3749
 
3750
+ const Div = 4;
3751
+ const Input = 6;
3752
+ const Span = 8;
3753
+ const Text = 12;
3754
+ const Img = 17;
3755
+ const Reference = 100;
3756
+
3700
3757
  const mergeClassNames = (...classNames) => {
3701
3758
  return classNames.filter(Boolean).join(' ');
3702
3759
  };
@@ -4203,11 +4260,10 @@ const getHighlights = (sections, label) => {
4203
4260
  nodes.push(text(label));
4204
4261
  } else {
4205
4262
  for (const section of sections) {
4263
+ labelDom.childCount++;
4206
4264
  if (section.highlighted) {
4207
- labelDom.childCount++;
4208
4265
  nodes.push(quickPickHighlight, text(section.text));
4209
4266
  } else {
4210
- labelDom.childCount++;
4211
4267
  nodes.push(text(section.text));
4212
4268
  }
4213
4269
  }
@@ -4317,7 +4373,7 @@ const getRootNodeCount = nodes => {
4317
4373
  count++;
4318
4374
  } else {
4319
4375
  const lastIndex = remainingChildCounts.length - 1;
4320
- remainingChildCounts[lastIndex] = remainingChildCounts[lastIndex] - 1;
4376
+ remainingChildCounts[lastIndex] -= 1;
4321
4377
  }
4322
4378
  remainingChildCounts.push(node.childCount);
4323
4379
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"