@lvce-editor/file-search-worker 5.15.0 → 5.17.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.
- package/dist/fileSearchWorkerMain.js +124 -76
- package/package.json +1 -1
|
@@ -60,49 +60,57 @@ class AssertionError extends Error {
|
|
|
60
60
|
this.name = 'AssertionError';
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
const Object$1 = 1;
|
|
64
|
+
const Number$1 = 2;
|
|
65
|
+
const Array$1 = 3;
|
|
66
|
+
const String = 4;
|
|
67
|
+
const Boolean$1 = 5;
|
|
68
|
+
const Function = 6;
|
|
69
|
+
const Null = 7;
|
|
70
|
+
const Unknown = 8;
|
|
63
71
|
const getType = value => {
|
|
64
72
|
switch (typeof value) {
|
|
65
73
|
case 'number':
|
|
66
|
-
return
|
|
74
|
+
return Number$1;
|
|
67
75
|
case 'function':
|
|
68
|
-
return
|
|
76
|
+
return Function;
|
|
69
77
|
case 'string':
|
|
70
|
-
return
|
|
78
|
+
return String;
|
|
71
79
|
case 'object':
|
|
72
80
|
if (value === null) {
|
|
73
|
-
return
|
|
81
|
+
return Null;
|
|
74
82
|
}
|
|
75
83
|
if (Array.isArray(value)) {
|
|
76
|
-
return
|
|
84
|
+
return Array$1;
|
|
77
85
|
}
|
|
78
|
-
return
|
|
86
|
+
return Object$1;
|
|
79
87
|
case 'boolean':
|
|
80
|
-
return
|
|
88
|
+
return Boolean$1;
|
|
81
89
|
default:
|
|
82
|
-
return
|
|
90
|
+
return Unknown;
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
const object = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
95
|
+
if (type !== Object$1) {
|
|
88
96
|
throw new AssertionError('expected value to be of type object');
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
const number = value => {
|
|
92
100
|
const type = getType(value);
|
|
93
|
-
if (type !==
|
|
101
|
+
if (type !== Number$1) {
|
|
94
102
|
throw new AssertionError('expected value to be of type number');
|
|
95
103
|
}
|
|
96
104
|
};
|
|
97
105
|
const array = value => {
|
|
98
106
|
const type = getType(value);
|
|
99
|
-
if (type !==
|
|
107
|
+
if (type !== Array$1) {
|
|
100
108
|
throw new AssertionError('expected value to be of type array');
|
|
101
109
|
}
|
|
102
110
|
};
|
|
103
111
|
const string = value => {
|
|
104
112
|
const type = getType(value);
|
|
105
|
-
if (type !==
|
|
113
|
+
if (type !== String) {
|
|
106
114
|
throw new AssertionError('expected value to be of type string');
|
|
107
115
|
}
|
|
108
116
|
};
|
|
@@ -431,7 +439,7 @@ const create$4$1 = (method, params) => {
|
|
|
431
439
|
};
|
|
432
440
|
};
|
|
433
441
|
const callbacks = Object.create(null);
|
|
434
|
-
const set$
|
|
442
|
+
const set$2 = (id, fn) => {
|
|
435
443
|
callbacks[id] = fn;
|
|
436
444
|
};
|
|
437
445
|
const get$2 = id => {
|
|
@@ -450,7 +458,7 @@ const registerPromise = () => {
|
|
|
450
458
|
resolve,
|
|
451
459
|
promise
|
|
452
460
|
} = Promise.withResolvers();
|
|
453
|
-
set$
|
|
461
|
+
set$2(id, resolve);
|
|
454
462
|
return {
|
|
455
463
|
id,
|
|
456
464
|
promise
|
|
@@ -523,6 +531,16 @@ const constructError = (message, type, name) => {
|
|
|
523
531
|
}
|
|
524
532
|
return new ErrorConstructor(message);
|
|
525
533
|
};
|
|
534
|
+
const joinLines = lines => {
|
|
535
|
+
return lines.join(NewLine);
|
|
536
|
+
};
|
|
537
|
+
const splitLines$1 = lines => {
|
|
538
|
+
return lines.split(NewLine);
|
|
539
|
+
};
|
|
540
|
+
const getCurrentStack = () => {
|
|
541
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(2));
|
|
542
|
+
return currentStack;
|
|
543
|
+
};
|
|
526
544
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
527
545
|
return string.indexOf(NewLine, startIndex);
|
|
528
546
|
};
|
|
@@ -533,19 +551,16 @@ const getParentStack = error => {
|
|
|
533
551
|
}
|
|
534
552
|
return parentStack;
|
|
535
553
|
};
|
|
536
|
-
const joinLines = lines => {
|
|
537
|
-
return lines.join(NewLine);
|
|
538
|
-
};
|
|
539
554
|
const MethodNotFound = -32601;
|
|
540
555
|
const Custom$1 = -32001;
|
|
541
|
-
const splitLines$1 = lines => {
|
|
542
|
-
return lines.split(NewLine);
|
|
543
|
-
};
|
|
544
556
|
const restoreJsonRpcError = error => {
|
|
557
|
+
const currentStack = getCurrentStack();
|
|
545
558
|
if (error && error instanceof Error) {
|
|
559
|
+
if (typeof error.stack === 'string') {
|
|
560
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
561
|
+
}
|
|
546
562
|
return error;
|
|
547
563
|
}
|
|
548
|
-
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(1));
|
|
549
564
|
if (error && error.code && error.code === MethodNotFound) {
|
|
550
565
|
const restoredError = new JsonRpcError(error.message);
|
|
551
566
|
const parentStack = getParentStack(error);
|
|
@@ -626,6 +641,17 @@ const getErrorType = prettyError => {
|
|
|
626
641
|
}
|
|
627
642
|
return undefined;
|
|
628
643
|
};
|
|
644
|
+
const isAlreadyStack = line => {
|
|
645
|
+
return line.trim().startsWith('at ');
|
|
646
|
+
};
|
|
647
|
+
const getStack = prettyError => {
|
|
648
|
+
const stackString = prettyError.stack || '';
|
|
649
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
650
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
651
|
+
return stackString.slice(newLineIndex + 1);
|
|
652
|
+
}
|
|
653
|
+
return stackString;
|
|
654
|
+
};
|
|
629
655
|
const getErrorProperty = (error, prettyError) => {
|
|
630
656
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
631
657
|
return {
|
|
@@ -638,7 +664,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
638
664
|
code: Custom$1,
|
|
639
665
|
message: prettyError.message,
|
|
640
666
|
data: {
|
|
641
|
-
stack: prettyError
|
|
667
|
+
stack: getStack(prettyError),
|
|
642
668
|
codeFrame: prettyError.codeFrame,
|
|
643
669
|
type: getErrorType(prettyError),
|
|
644
670
|
code: prettyError.code,
|
|
@@ -646,18 +672,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
646
672
|
}
|
|
647
673
|
};
|
|
648
674
|
};
|
|
649
|
-
const create$1$1 = (
|
|
675
|
+
const create$1$1 = (id, error) => {
|
|
650
676
|
return {
|
|
651
677
|
jsonrpc: Two,
|
|
652
|
-
id
|
|
678
|
+
id,
|
|
653
679
|
error
|
|
654
680
|
};
|
|
655
681
|
};
|
|
656
|
-
const getErrorResponse = (
|
|
682
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
657
683
|
const prettyError = preparePrettyError(error);
|
|
658
684
|
logError(error, prettyError);
|
|
659
685
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
660
|
-
return create$1$1(
|
|
686
|
+
return create$1$1(id, errorProperty);
|
|
661
687
|
};
|
|
662
688
|
const create$5 = (message, result) => {
|
|
663
689
|
return {
|
|
@@ -670,12 +696,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
670
696
|
const resultProperty = result ?? null;
|
|
671
697
|
return create$5(message, resultProperty);
|
|
672
698
|
};
|
|
699
|
+
const getErrorResponseSimple = (id, error) => {
|
|
700
|
+
return {
|
|
701
|
+
jsonrpc: Two,
|
|
702
|
+
id,
|
|
703
|
+
error: {
|
|
704
|
+
code: Custom$1,
|
|
705
|
+
// @ts-ignore
|
|
706
|
+
message: error.message,
|
|
707
|
+
data: error
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
};
|
|
673
711
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
674
712
|
try {
|
|
675
713
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
676
714
|
return getSuccessResponse(message, result);
|
|
677
715
|
} catch (error) {
|
|
678
|
-
|
|
716
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
717
|
+
return getErrorResponseSimple(message.id, error);
|
|
718
|
+
}
|
|
719
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
679
720
|
}
|
|
680
721
|
};
|
|
681
722
|
const defaultPreparePrettyError = error => {
|
|
@@ -730,7 +771,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
730
771
|
try {
|
|
731
772
|
ipc.send(response);
|
|
732
773
|
} catch (error) {
|
|
733
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
774
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
734
775
|
ipc.send(errorResponse);
|
|
735
776
|
}
|
|
736
777
|
return;
|
|
@@ -761,7 +802,7 @@ const send = (transport, method, ...params) => {
|
|
|
761
802
|
const message = create$4$1(method, params);
|
|
762
803
|
transport.send(message);
|
|
763
804
|
};
|
|
764
|
-
const invoke$
|
|
805
|
+
const invoke$2 = (ipc, method, ...params) => {
|
|
765
806
|
return invokeHelper(ipc, method, params, false);
|
|
766
807
|
};
|
|
767
808
|
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
@@ -794,7 +835,7 @@ const createRpc = ipc => {
|
|
|
794
835
|
send(ipc, method, ...params);
|
|
795
836
|
},
|
|
796
837
|
invoke(method, ...params) {
|
|
797
|
-
return invoke$
|
|
838
|
+
return invoke$2(ipc, method, ...params);
|
|
798
839
|
},
|
|
799
840
|
invokeAndTransfer(method, ...params) {
|
|
800
841
|
return invokeAndTransfer(ipc, method, ...params);
|
|
@@ -851,7 +892,7 @@ const WebWorkerRpcClient = {
|
|
|
851
892
|
};
|
|
852
893
|
|
|
853
894
|
const rpcs = Object.create(null);
|
|
854
|
-
const set$
|
|
895
|
+
const set$g = (id, rpc) => {
|
|
855
896
|
rpcs[id] = rpc;
|
|
856
897
|
};
|
|
857
898
|
const get$1 = id => {
|
|
@@ -875,20 +916,22 @@ const create$3 = rpcId => {
|
|
|
875
916
|
return rpc.invokeAndTransfer(method, ...params);
|
|
876
917
|
},
|
|
877
918
|
set(rpc) {
|
|
878
|
-
set$
|
|
919
|
+
set$g(rpcId, rpc);
|
|
920
|
+
},
|
|
921
|
+
async dispose() {
|
|
922
|
+
const rpc = get$1(rpcId);
|
|
923
|
+
await rpc.dispose();
|
|
879
924
|
}
|
|
880
925
|
};
|
|
881
926
|
};
|
|
882
927
|
const RendererWorker$1 = 1;
|
|
883
928
|
const {
|
|
884
|
-
invoke: invoke$
|
|
885
|
-
set: set$
|
|
886
|
-
} = create$3(RendererWorker$1);
|
|
929
|
+
invoke: invoke$4,
|
|
930
|
+
set: set$3} = create$3(RendererWorker$1);
|
|
887
931
|
const RendererWorker = {
|
|
888
932
|
__proto__: null,
|
|
889
|
-
invoke: invoke$
|
|
890
|
-
set: set$
|
|
891
|
-
};
|
|
933
|
+
invoke: invoke$4,
|
|
934
|
+
set: set$3};
|
|
892
935
|
|
|
893
936
|
const {
|
|
894
937
|
invoke: invoke$1,
|
|
@@ -2739,6 +2782,34 @@ const renderHeight = newState => {
|
|
|
2739
2782
|
return ['Viewlet.send', newState.uid, /* method */SetItemsHeight, /* height */newState.height];
|
|
2740
2783
|
};
|
|
2741
2784
|
|
|
2785
|
+
const mergeClassNames = (...classNames) => {
|
|
2786
|
+
return classNames.filter(Boolean).join(' ');
|
|
2787
|
+
};
|
|
2788
|
+
const px = value => {
|
|
2789
|
+
return `${value}px`;
|
|
2790
|
+
};
|
|
2791
|
+
const position = (x, y) => {
|
|
2792
|
+
return `${x}px ${y}px`;
|
|
2793
|
+
};
|
|
2794
|
+
const Div = 4;
|
|
2795
|
+
const Input = 6;
|
|
2796
|
+
const Span = 8;
|
|
2797
|
+
const Text = 12;
|
|
2798
|
+
const Img = 17;
|
|
2799
|
+
const VirtualDomElements = {
|
|
2800
|
+
__proto__: null,
|
|
2801
|
+
Div,
|
|
2802
|
+
Img,
|
|
2803
|
+
Input,
|
|
2804
|
+
Span};
|
|
2805
|
+
const text = data => {
|
|
2806
|
+
return {
|
|
2807
|
+
type: Text,
|
|
2808
|
+
text: data,
|
|
2809
|
+
childCount: 0
|
|
2810
|
+
};
|
|
2811
|
+
};
|
|
2812
|
+
|
|
2742
2813
|
const ComboBox = 'combobox';
|
|
2743
2814
|
const ListBox = 'listbox';
|
|
2744
2815
|
const None = 'none';
|
|
@@ -2776,15 +2847,10 @@ const QuickPick = 'QuickPick';
|
|
|
2776
2847
|
const QuickPickItems = 'QuickPickItems';
|
|
2777
2848
|
const QuickPickItemActive = 'QuickPickItemActive';
|
|
2778
2849
|
|
|
2779
|
-
const Div = 4;
|
|
2780
|
-
const Input = 6;
|
|
2781
|
-
const Span = 8;
|
|
2782
|
-
const Img = 17;
|
|
2783
|
-
|
|
2784
2850
|
const getQuickPickInputVirtualDom = () => {
|
|
2785
2851
|
const ariaLabel = typeNameofCommandToRun();
|
|
2786
2852
|
return {
|
|
2787
|
-
type: Input,
|
|
2853
|
+
type: VirtualDomElements.Input,
|
|
2788
2854
|
className: InputBox,
|
|
2789
2855
|
spellcheck: false,
|
|
2790
2856
|
autocapitalize: 'off',
|
|
@@ -2805,7 +2871,7 @@ const getQuickPickInputVirtualDom = () => {
|
|
|
2805
2871
|
|
|
2806
2872
|
const getQuickPickHeaderVirtualDom = () => {
|
|
2807
2873
|
return [{
|
|
2808
|
-
type: Div,
|
|
2874
|
+
type: VirtualDomElements.Div,
|
|
2809
2875
|
className: QuickPickHeader,
|
|
2810
2876
|
childCount: 1
|
|
2811
2877
|
}, getQuickPickInputVirtualDom()];
|
|
@@ -2813,7 +2879,7 @@ const getQuickPickHeaderVirtualDom = () => {
|
|
|
2813
2879
|
|
|
2814
2880
|
const getFileIconVirtualDom = icon => {
|
|
2815
2881
|
return {
|
|
2816
|
-
type: Img,
|
|
2882
|
+
type: VirtualDomElements.Img,
|
|
2817
2883
|
className: FileIcon,
|
|
2818
2884
|
src: icon,
|
|
2819
2885
|
role: None,
|
|
@@ -2821,32 +2887,14 @@ const getFileIconVirtualDom = icon => {
|
|
|
2821
2887
|
};
|
|
2822
2888
|
};
|
|
2823
2889
|
|
|
2824
|
-
const mergeClassNames = (...classNames) => {
|
|
2825
|
-
return classNames.filter(Boolean).join(' ');
|
|
2826
|
-
};
|
|
2827
|
-
const Text = 12;
|
|
2828
|
-
const text = data => {
|
|
2829
|
-
return {
|
|
2830
|
-
type: Text,
|
|
2831
|
-
text: data,
|
|
2832
|
-
childCount: 0
|
|
2833
|
-
};
|
|
2834
|
-
};
|
|
2835
|
-
const px = value => {
|
|
2836
|
-
return `${value}px`;
|
|
2837
|
-
};
|
|
2838
|
-
const position = (x, y) => {
|
|
2839
|
-
return `${x}px ${y}px`;
|
|
2840
|
-
};
|
|
2841
|
-
|
|
2842
2890
|
const quickPickHighlight = {
|
|
2843
|
-
type: Span,
|
|
2891
|
+
type: VirtualDomElements.Span,
|
|
2844
2892
|
className: QuickPickHighlight,
|
|
2845
2893
|
childCount: 1
|
|
2846
2894
|
};
|
|
2847
2895
|
const getHighlights = (sections, label) => {
|
|
2848
2896
|
const labelDom = {
|
|
2849
|
-
type: Div,
|
|
2897
|
+
type: VirtualDomElements.Div,
|
|
2850
2898
|
className: QuickPickItemLabel,
|
|
2851
2899
|
childCount: 0
|
|
2852
2900
|
};
|
|
@@ -2881,7 +2929,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
|
|
|
2881
2929
|
} = visibleItem;
|
|
2882
2930
|
const dom = [];
|
|
2883
2931
|
dom.push({
|
|
2884
|
-
type: Div,
|
|
2932
|
+
type: VirtualDomElements.Div,
|
|
2885
2933
|
className: QuickPickItem,
|
|
2886
2934
|
role: Option,
|
|
2887
2935
|
ariaPosInSet: posInSet,
|
|
@@ -2900,7 +2948,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
|
|
|
2900
2948
|
} else if (icon) {
|
|
2901
2949
|
parent.childCount++;
|
|
2902
2950
|
dom.push({
|
|
2903
|
-
type: Div,
|
|
2951
|
+
type: VirtualDomElements.Div,
|
|
2904
2952
|
className: mergeClassNames(QuickPickMaskIcon, MaskIcon, `MaskIcon${icon}`),
|
|
2905
2953
|
childCount: 0
|
|
2906
2954
|
});
|
|
@@ -2910,7 +2958,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
|
|
|
2910
2958
|
if (description) {
|
|
2911
2959
|
parent.childCount++;
|
|
2912
2960
|
dom.push({
|
|
2913
|
-
type: Div,
|
|
2961
|
+
type: VirtualDomElements.Div,
|
|
2914
2962
|
className: QuickPickItemDescription,
|
|
2915
2963
|
childCount: 1
|
|
2916
2964
|
}, text(description));
|
|
@@ -2921,11 +2969,11 @@ const getQuickPickItemVirtualDom = visibleItem => {
|
|
|
2921
2969
|
const getQuickPickNoResultsVirtualDom = () => {
|
|
2922
2970
|
const noResults$1 = noResults();
|
|
2923
2971
|
return [{
|
|
2924
|
-
type: Div,
|
|
2972
|
+
type: VirtualDomElements.Div,
|
|
2925
2973
|
className: mergeClassNames(QuickPickItem, QuickPickItemActive$1, QuickPickStatus),
|
|
2926
2974
|
childCount: 1
|
|
2927
2975
|
}, {
|
|
2928
|
-
type: Div,
|
|
2976
|
+
type: VirtualDomElements.Div,
|
|
2929
2977
|
className: Label,
|
|
2930
2978
|
childCount: 1
|
|
2931
2979
|
}, text(noResults$1)];
|
|
@@ -2947,11 +2995,11 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
2947
2995
|
const heightString = px(scrollBarHeight);
|
|
2948
2996
|
const translateString = position(0, scrollBarTop);
|
|
2949
2997
|
return [{
|
|
2950
|
-
type: Div,
|
|
2998
|
+
type: VirtualDomElements.Div,
|
|
2951
2999
|
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
2952
3000
|
childCount: 1
|
|
2953
3001
|
}, {
|
|
2954
|
-
type: Div,
|
|
3002
|
+
type: VirtualDomElements.Div,
|
|
2955
3003
|
className: ScrollBarThumb,
|
|
2956
3004
|
childCount: 0,
|
|
2957
3005
|
height: heightString,
|
|
@@ -2963,13 +3011,13 @@ const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) =>
|
|
|
2963
3011
|
const quickOpen$1 = quickOpen();
|
|
2964
3012
|
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
2965
3013
|
return [{
|
|
2966
|
-
type: Div,
|
|
3014
|
+
type: VirtualDomElements.Div,
|
|
2967
3015
|
className: mergeClassNames(Viewlet, QuickPick$1),
|
|
2968
3016
|
childCount: 2,
|
|
2969
3017
|
id: QuickPick,
|
|
2970
3018
|
ariaLabel: quickOpen$1
|
|
2971
3019
|
}, ...getQuickPickHeaderVirtualDom(), {
|
|
2972
|
-
type: Div,
|
|
3020
|
+
type: VirtualDomElements.Div,
|
|
2973
3021
|
className: mergeClassNames(List, ContainContent),
|
|
2974
3022
|
id: QuickPickItems,
|
|
2975
3023
|
role: ListBox,
|
|
@@ -2978,7 +3026,7 @@ const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) =>
|
|
|
2978
3026
|
onPointerDown: HandlePointerDown,
|
|
2979
3027
|
childCount: shouldShowScrollbar ? 2 : 1
|
|
2980
3028
|
}, {
|
|
2981
|
-
type: Div,
|
|
3029
|
+
type: VirtualDomElements.Div,
|
|
2982
3030
|
className: mergeClassNames(ListItems, ContainContent),
|
|
2983
3031
|
childCount: visibleItems.length
|
|
2984
3032
|
}, ...getQuickPickItemsVirtualDom(visibleItems), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarTop)];
|