@lvce-editor/text-search-worker 3.16.0 → 3.18.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/textSearchWorkerMain.js +163 -158
- package/package.json +1 -1
|
@@ -1,5 +1,114 @@
|
|
|
1
|
+
const normalizeLine$1 = line => {
|
|
2
|
+
if (line.startsWith('Error: ')) {
|
|
3
|
+
return line.slice('Error: '.length);
|
|
4
|
+
}
|
|
5
|
+
if (line.startsWith('VError: ')) {
|
|
6
|
+
return line.slice('VError: '.length);
|
|
7
|
+
}
|
|
8
|
+
return line;
|
|
9
|
+
};
|
|
10
|
+
const getCombinedMessage$1 = (error, message) => {
|
|
11
|
+
const stringifiedError = normalizeLine$1(`${error}`);
|
|
12
|
+
if (message) {
|
|
13
|
+
return `${message}: ${stringifiedError}`;
|
|
14
|
+
}
|
|
15
|
+
return stringifiedError;
|
|
16
|
+
};
|
|
17
|
+
const NewLine$3 = '\n';
|
|
18
|
+
const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
19
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
20
|
+
};
|
|
21
|
+
const mergeStacks$1 = (parent, child) => {
|
|
22
|
+
if (!child) {
|
|
23
|
+
return parent;
|
|
24
|
+
}
|
|
25
|
+
const parentNewLineIndex = getNewLineIndex$2(parent);
|
|
26
|
+
const childNewLineIndex = getNewLineIndex$2(child);
|
|
27
|
+
if (childNewLineIndex === -1) {
|
|
28
|
+
return parent;
|
|
29
|
+
}
|
|
30
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
31
|
+
const childRest = child.slice(childNewLineIndex);
|
|
32
|
+
const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
|
|
33
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
34
|
+
return parentFirstLine + childRest;
|
|
35
|
+
}
|
|
36
|
+
return child;
|
|
37
|
+
};
|
|
38
|
+
let VError$1 = class VError extends Error {
|
|
39
|
+
constructor(error, message) {
|
|
40
|
+
const combinedMessage = getCombinedMessage$1(error, message);
|
|
41
|
+
super(combinedMessage);
|
|
42
|
+
this.name = 'VError';
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
this.stack = mergeStacks$1(this.stack, error.stack);
|
|
45
|
+
}
|
|
46
|
+
if (error.codeFrame) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
this.codeFrame = error.codeFrame;
|
|
49
|
+
}
|
|
50
|
+
if (error.code) {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
this.code = error.code;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
class AssertionError extends Error {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = 'AssertionError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const getType = value => {
|
|
64
|
+
switch (typeof value) {
|
|
65
|
+
case 'number':
|
|
66
|
+
return 'number';
|
|
67
|
+
case 'function':
|
|
68
|
+
return 'function';
|
|
69
|
+
case 'string':
|
|
70
|
+
return 'string';
|
|
71
|
+
case 'object':
|
|
72
|
+
if (value === null) {
|
|
73
|
+
return 'null';
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return 'array';
|
|
77
|
+
}
|
|
78
|
+
return 'object';
|
|
79
|
+
case 'boolean':
|
|
80
|
+
return 'boolean';
|
|
81
|
+
default:
|
|
82
|
+
return 'unknown';
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const object = value => {
|
|
86
|
+
const type = getType(value);
|
|
87
|
+
if (type !== 'object') {
|
|
88
|
+
throw new AssertionError('expected value to be of type object');
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const number = value => {
|
|
92
|
+
const type = getType(value);
|
|
93
|
+
if (type !== 'number') {
|
|
94
|
+
throw new AssertionError('expected value to be of type number');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const array = value => {
|
|
98
|
+
const type = getType(value);
|
|
99
|
+
if (type !== 'array') {
|
|
100
|
+
throw new AssertionError('expected value to be of type array');
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const string = value => {
|
|
104
|
+
const type = getType(value);
|
|
105
|
+
if (type !== 'string') {
|
|
106
|
+
throw new AssertionError('expected value to be of type string');
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
1
110
|
const Two = '2.0';
|
|
2
|
-
const create$4
|
|
111
|
+
const create$4 = (method, params) => {
|
|
3
112
|
return {
|
|
4
113
|
jsonrpc: Two,
|
|
5
114
|
method,
|
|
@@ -69,7 +178,7 @@ class JsonRpcError extends Error {
|
|
|
69
178
|
this.name = 'JsonRpcError';
|
|
70
179
|
}
|
|
71
180
|
}
|
|
72
|
-
const NewLine$
|
|
181
|
+
const NewLine$2 = '\n';
|
|
73
182
|
const DomException = 'DOMException';
|
|
74
183
|
const ReferenceError$1 = 'ReferenceError';
|
|
75
184
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -114,23 +223,23 @@ const constructError = (message, type, name) => {
|
|
|
114
223
|
}
|
|
115
224
|
return new ErrorConstructor(message);
|
|
116
225
|
};
|
|
117
|
-
const getNewLineIndex$
|
|
118
|
-
return string.indexOf(NewLine$
|
|
226
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
227
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
119
228
|
};
|
|
120
229
|
const getParentStack = error => {
|
|
121
230
|
let parentStack = error.stack || error.data || error.message || '';
|
|
122
231
|
if (parentStack.startsWith(' at')) {
|
|
123
|
-
parentStack = error.message + NewLine$
|
|
232
|
+
parentStack = error.message + NewLine$2 + parentStack;
|
|
124
233
|
}
|
|
125
234
|
return parentStack;
|
|
126
235
|
};
|
|
127
236
|
const joinLines$1 = lines => {
|
|
128
|
-
return lines.join(NewLine$
|
|
237
|
+
return lines.join(NewLine$2);
|
|
129
238
|
};
|
|
130
239
|
const MethodNotFound = -32601;
|
|
131
240
|
const Custom = -32001;
|
|
132
241
|
const splitLines$2 = lines => {
|
|
133
|
-
return lines.split(NewLine$
|
|
242
|
+
return lines.split(NewLine$2);
|
|
134
243
|
};
|
|
135
244
|
const restoreJsonRpcError = error => {
|
|
136
245
|
if (error && error instanceof Error) {
|
|
@@ -140,14 +249,14 @@ const restoreJsonRpcError = error => {
|
|
|
140
249
|
if (error && error.code && error.code === MethodNotFound) {
|
|
141
250
|
const restoredError = new JsonRpcError(error.message);
|
|
142
251
|
const parentStack = getParentStack(error);
|
|
143
|
-
restoredError.stack = parentStack + NewLine$
|
|
252
|
+
restoredError.stack = parentStack + NewLine$2 + currentStack;
|
|
144
253
|
return restoredError;
|
|
145
254
|
}
|
|
146
255
|
if (error && error.message) {
|
|
147
256
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
148
257
|
if (error.data) {
|
|
149
258
|
if (error.data.stack && error.data.type && error.message) {
|
|
150
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$
|
|
259
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$2 + error.data.stack + NewLine$2 + currentStack;
|
|
151
260
|
} else if (error.data.stack) {
|
|
152
261
|
restoredError.stack = error.data.stack;
|
|
153
262
|
}
|
|
@@ -167,7 +276,7 @@ const restoreJsonRpcError = error => {
|
|
|
167
276
|
if (error.stack) {
|
|
168
277
|
const lowerStack = restoredError.stack || '';
|
|
169
278
|
// @ts-ignore
|
|
170
|
-
const indexNewLine = getNewLineIndex$
|
|
279
|
+
const indexNewLine = getNewLineIndex$1(lowerStack);
|
|
171
280
|
const parentStack = getParentStack(error);
|
|
172
281
|
// @ts-ignore
|
|
173
282
|
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
@@ -237,7 +346,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
237
346
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
238
347
|
return create$1$2(message, errorProperty);
|
|
239
348
|
};
|
|
240
|
-
const create$
|
|
349
|
+
const create$6 = (message, result) => {
|
|
241
350
|
return {
|
|
242
351
|
jsonrpc: Two,
|
|
243
352
|
id: message.id,
|
|
@@ -246,7 +355,7 @@ const create$5 = (message, result) => {
|
|
|
246
355
|
};
|
|
247
356
|
const getSuccessResponse = (message, result) => {
|
|
248
357
|
const resultProperty = result ?? null;
|
|
249
|
-
return create$
|
|
358
|
+
return create$6(message, resultProperty);
|
|
250
359
|
};
|
|
251
360
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
252
361
|
try {
|
|
@@ -336,7 +445,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
336
445
|
return unwrapJsonRpcResult(responseMessage);
|
|
337
446
|
};
|
|
338
447
|
const send = (transport, method, ...params) => {
|
|
339
|
-
const message = create$4
|
|
448
|
+
const message = create$4(method, params);
|
|
340
449
|
transport.send(message);
|
|
341
450
|
};
|
|
342
451
|
const invoke$3 = (ipc, method, ...params) => {
|
|
@@ -584,7 +693,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
584
693
|
stack: rest
|
|
585
694
|
};
|
|
586
695
|
};
|
|
587
|
-
const normalizeLine
|
|
696
|
+
const normalizeLine = line => {
|
|
588
697
|
if (line.startsWith('Error: ')) {
|
|
589
698
|
return line.slice('Error: '.length);
|
|
590
699
|
}
|
|
@@ -593,41 +702,41 @@ const normalizeLine$1 = line => {
|
|
|
593
702
|
}
|
|
594
703
|
return line;
|
|
595
704
|
};
|
|
596
|
-
const getCombinedMessage
|
|
597
|
-
const stringifiedError = normalizeLine
|
|
705
|
+
const getCombinedMessage = (error, message) => {
|
|
706
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
598
707
|
if (message) {
|
|
599
708
|
return `${message}: ${stringifiedError}`;
|
|
600
709
|
}
|
|
601
710
|
return stringifiedError;
|
|
602
711
|
};
|
|
603
|
-
const NewLine
|
|
604
|
-
const getNewLineIndex
|
|
605
|
-
return string.indexOf(NewLine
|
|
712
|
+
const NewLine = '\n';
|
|
713
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
714
|
+
return string.indexOf(NewLine, startIndex);
|
|
606
715
|
};
|
|
607
|
-
const mergeStacks
|
|
716
|
+
const mergeStacks = (parent, child) => {
|
|
608
717
|
if (!child) {
|
|
609
718
|
return parent;
|
|
610
719
|
}
|
|
611
|
-
const parentNewLineIndex = getNewLineIndex
|
|
612
|
-
const childNewLineIndex = getNewLineIndex
|
|
720
|
+
const parentNewLineIndex = getNewLineIndex(parent);
|
|
721
|
+
const childNewLineIndex = getNewLineIndex(child);
|
|
613
722
|
if (childNewLineIndex === -1) {
|
|
614
723
|
return parent;
|
|
615
724
|
}
|
|
616
725
|
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
617
726
|
const childRest = child.slice(childNewLineIndex);
|
|
618
|
-
const childFirstLine = normalizeLine
|
|
727
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
619
728
|
if (parentFirstLine.includes(childFirstLine)) {
|
|
620
729
|
return parentFirstLine + childRest;
|
|
621
730
|
}
|
|
622
731
|
return child;
|
|
623
732
|
};
|
|
624
|
-
|
|
733
|
+
class VError extends Error {
|
|
625
734
|
constructor(error, message) {
|
|
626
|
-
const combinedMessage = getCombinedMessage
|
|
735
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
627
736
|
super(combinedMessage);
|
|
628
737
|
this.name = 'VError';
|
|
629
738
|
if (error instanceof Error) {
|
|
630
|
-
this.stack = mergeStacks
|
|
739
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
631
740
|
}
|
|
632
741
|
if (error.codeFrame) {
|
|
633
742
|
// @ts-ignore
|
|
@@ -638,8 +747,8 @@ let VError$1 = class VError extends Error {
|
|
|
638
747
|
this.code = error.code;
|
|
639
748
|
}
|
|
640
749
|
}
|
|
641
|
-
}
|
|
642
|
-
class IpcError extends VError
|
|
750
|
+
}
|
|
751
|
+
class IpcError extends VError {
|
|
643
752
|
// @ts-ignore
|
|
644
753
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
645
754
|
if (stdout || stderr) {
|
|
@@ -846,7 +955,7 @@ const parse = content => {
|
|
|
846
955
|
try {
|
|
847
956
|
return JSON.parse(content);
|
|
848
957
|
} catch (error) {
|
|
849
|
-
throw new VError
|
|
958
|
+
throw new VError(error, 'failed to parse json');
|
|
850
959
|
}
|
|
851
960
|
};
|
|
852
961
|
const waitForWebSocketToBeOpen = webSocket => {
|
|
@@ -855,7 +964,7 @@ const waitForWebSocketToBeOpen = webSocket => {
|
|
|
855
964
|
close: Close
|
|
856
965
|
});
|
|
857
966
|
};
|
|
858
|
-
const create$
|
|
967
|
+
const create$3 = async ({
|
|
859
968
|
webSocket
|
|
860
969
|
}) => {
|
|
861
970
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -890,7 +999,7 @@ const wrap$1 = webSocket => {
|
|
|
890
999
|
};
|
|
891
1000
|
const IpcParentWithWebSocket$1 = {
|
|
892
1001
|
__proto__: null,
|
|
893
|
-
create: create$
|
|
1002
|
+
create: create$3,
|
|
894
1003
|
wrap: wrap$1
|
|
895
1004
|
};
|
|
896
1005
|
|
|
@@ -924,9 +1033,22 @@ const handleMessage = event => {
|
|
|
924
1033
|
return handleJsonRpcMessage(event.target, event.data, execute, resolve, preparePrettyError, logError, requiresSocket);
|
|
925
1034
|
};
|
|
926
1035
|
const handleIpc = ipc => {
|
|
927
|
-
|
|
1036
|
+
if ('addEventListener' in ipc) {
|
|
1037
|
+
ipc.addEventListener('message', handleMessage);
|
|
1038
|
+
} else if ('on' in ipc) {
|
|
1039
|
+
// deprecated
|
|
1040
|
+
ipc.on('message', handleMessage);
|
|
1041
|
+
}
|
|
928
1042
|
};
|
|
929
|
-
const
|
|
1043
|
+
const listen$1 = async (module, options) => {
|
|
1044
|
+
const rawIpc = await module.listen(options);
|
|
1045
|
+
if (module.signal) {
|
|
1046
|
+
module.signal(rawIpc);
|
|
1047
|
+
}
|
|
1048
|
+
const ipc = module.wrap(rawIpc);
|
|
1049
|
+
return ipc;
|
|
1050
|
+
};
|
|
1051
|
+
const create$5 = async ({
|
|
930
1052
|
commandMap,
|
|
931
1053
|
messagePort,
|
|
932
1054
|
isMessagePortOpen
|
|
@@ -944,7 +1066,7 @@ const create$2 = async ({
|
|
|
944
1066
|
};
|
|
945
1067
|
const MessagePortRpcParent = {
|
|
946
1068
|
__proto__: null,
|
|
947
|
-
create: create$
|
|
1069
|
+
create: create$5
|
|
948
1070
|
};
|
|
949
1071
|
const create$1$1 = async ({
|
|
950
1072
|
commandMap,
|
|
@@ -964,27 +1086,19 @@ const WebSocketRpcParent = {
|
|
|
964
1086
|
__proto__: null,
|
|
965
1087
|
create: create$1$1
|
|
966
1088
|
};
|
|
967
|
-
|
|
968
|
-
// @ts-ignore
|
|
969
|
-
const listen$1 = async () => {
|
|
970
|
-
const module = IpcChildWithModuleWorkerAndMessagePort$1;
|
|
971
|
-
const rawIpc = await module.listen();
|
|
972
|
-
const ipc = module.wrap(rawIpc);
|
|
973
|
-
return ipc;
|
|
974
|
-
};
|
|
975
|
-
const create$3 = async ({
|
|
1089
|
+
const create$2 = async ({
|
|
976
1090
|
commandMap
|
|
977
1091
|
}) => {
|
|
978
1092
|
// TODO create a commandMap per rpc instance
|
|
979
1093
|
register(commandMap);
|
|
980
|
-
const ipc = await listen$1();
|
|
1094
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
981
1095
|
handleIpc(ipc);
|
|
982
1096
|
const rpc = createRpc(ipc);
|
|
983
1097
|
return rpc;
|
|
984
1098
|
};
|
|
985
1099
|
const WebWorkerRpcClient = {
|
|
986
1100
|
__proto__: null,
|
|
987
|
-
create: create$
|
|
1101
|
+
create: create$2
|
|
988
1102
|
};
|
|
989
1103
|
|
|
990
1104
|
const Empty$1 = 0;
|
|
@@ -2401,59 +2515,6 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2401
2515
|
};
|
|
2402
2516
|
};
|
|
2403
2517
|
|
|
2404
|
-
class AssertionError extends Error {
|
|
2405
|
-
constructor(message) {
|
|
2406
|
-
super(message);
|
|
2407
|
-
this.name = 'AssertionError';
|
|
2408
|
-
}
|
|
2409
|
-
}
|
|
2410
|
-
const getType = value => {
|
|
2411
|
-
switch (typeof value) {
|
|
2412
|
-
case 'number':
|
|
2413
|
-
return 'number';
|
|
2414
|
-
case 'function':
|
|
2415
|
-
return 'function';
|
|
2416
|
-
case 'string':
|
|
2417
|
-
return 'string';
|
|
2418
|
-
case 'object':
|
|
2419
|
-
if (value === null) {
|
|
2420
|
-
return 'null';
|
|
2421
|
-
}
|
|
2422
|
-
if (Array.isArray(value)) {
|
|
2423
|
-
return 'array';
|
|
2424
|
-
}
|
|
2425
|
-
return 'object';
|
|
2426
|
-
case 'boolean':
|
|
2427
|
-
return 'boolean';
|
|
2428
|
-
default:
|
|
2429
|
-
return 'unknown';
|
|
2430
|
-
}
|
|
2431
|
-
};
|
|
2432
|
-
const object = value => {
|
|
2433
|
-
const type = getType(value);
|
|
2434
|
-
if (type !== 'object') {
|
|
2435
|
-
throw new AssertionError('expected value to be of type object');
|
|
2436
|
-
}
|
|
2437
|
-
};
|
|
2438
|
-
const number = value => {
|
|
2439
|
-
const type = getType(value);
|
|
2440
|
-
if (type !== 'number') {
|
|
2441
|
-
throw new AssertionError('expected value to be of type number');
|
|
2442
|
-
}
|
|
2443
|
-
};
|
|
2444
|
-
const array = value => {
|
|
2445
|
-
const type = getType(value);
|
|
2446
|
-
if (type !== 'array') {
|
|
2447
|
-
throw new AssertionError('expected value to be of type array');
|
|
2448
|
-
}
|
|
2449
|
-
};
|
|
2450
|
-
const string = value => {
|
|
2451
|
-
const type = getType(value);
|
|
2452
|
-
if (type !== 'string') {
|
|
2453
|
-
throw new AssertionError('expected value to be of type string');
|
|
2454
|
-
}
|
|
2455
|
-
};
|
|
2456
|
-
|
|
2457
2518
|
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2458
2519
|
const getProtocol$1 = uri => {
|
|
2459
2520
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
@@ -2470,62 +2531,6 @@ const textSearch$5 = async (scheme, root, query) => {
|
|
|
2470
2531
|
return result;
|
|
2471
2532
|
};
|
|
2472
2533
|
|
|
2473
|
-
const normalizeLine = line => {
|
|
2474
|
-
if (line.startsWith('Error: ')) {
|
|
2475
|
-
return line.slice('Error: '.length);
|
|
2476
|
-
}
|
|
2477
|
-
if (line.startsWith('VError: ')) {
|
|
2478
|
-
return line.slice('VError: '.length);
|
|
2479
|
-
}
|
|
2480
|
-
return line;
|
|
2481
|
-
};
|
|
2482
|
-
const getCombinedMessage = (error, message) => {
|
|
2483
|
-
const stringifiedError = normalizeLine(`${error}`);
|
|
2484
|
-
if (message) {
|
|
2485
|
-
return `${message}: ${stringifiedError}`;
|
|
2486
|
-
}
|
|
2487
|
-
return stringifiedError;
|
|
2488
|
-
};
|
|
2489
|
-
const NewLine = '\n';
|
|
2490
|
-
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
2491
|
-
return string.indexOf(NewLine, startIndex);
|
|
2492
|
-
};
|
|
2493
|
-
const mergeStacks = (parent, child) => {
|
|
2494
|
-
if (!child) {
|
|
2495
|
-
return parent;
|
|
2496
|
-
}
|
|
2497
|
-
const parentNewLineIndex = getNewLineIndex(parent);
|
|
2498
|
-
const childNewLineIndex = getNewLineIndex(child);
|
|
2499
|
-
if (childNewLineIndex === -1) {
|
|
2500
|
-
return parent;
|
|
2501
|
-
}
|
|
2502
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
2503
|
-
const childRest = child.slice(childNewLineIndex);
|
|
2504
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
2505
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
2506
|
-
return parentFirstLine + childRest;
|
|
2507
|
-
}
|
|
2508
|
-
return child;
|
|
2509
|
-
};
|
|
2510
|
-
class VError extends Error {
|
|
2511
|
-
constructor(error, message) {
|
|
2512
|
-
const combinedMessage = getCombinedMessage(error, message);
|
|
2513
|
-
super(combinedMessage);
|
|
2514
|
-
this.name = 'VError';
|
|
2515
|
-
if (error instanceof Error) {
|
|
2516
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
2517
|
-
}
|
|
2518
|
-
if (error.codeFrame) {
|
|
2519
|
-
// @ts-ignore
|
|
2520
|
-
this.codeFrame = error.codeFrame;
|
|
2521
|
-
}
|
|
2522
|
-
if (error.code) {
|
|
2523
|
-
// @ts-ignore
|
|
2524
|
-
this.code = error.code;
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2529
2534
|
const getJson = async url => {
|
|
2530
2535
|
try {
|
|
2531
2536
|
const response = await fetch(url);
|
|
@@ -2535,7 +2540,7 @@ const getJson = async url => {
|
|
|
2535
2540
|
const json = await response.json();
|
|
2536
2541
|
return json;
|
|
2537
2542
|
} catch (error) {
|
|
2538
|
-
throw new VError(error, `Failed to get json`);
|
|
2543
|
+
throw new VError$1(error, `Failed to get json`);
|
|
2539
2544
|
}
|
|
2540
2545
|
};
|
|
2541
2546
|
|
|
@@ -2548,7 +2553,7 @@ const getText = async url => {
|
|
|
2548
2553
|
const text = await response.text();
|
|
2549
2554
|
return text;
|
|
2550
2555
|
} catch (error) {
|
|
2551
|
-
throw new VError(error, `Failed to get text`);
|
|
2556
|
+
throw new VError$1(error, `Failed to get text`);
|
|
2552
2557
|
}
|
|
2553
2558
|
};
|
|
2554
2559
|
|
|
@@ -2624,7 +2629,7 @@ const getChildHandles = async handle => {
|
|
|
2624
2629
|
try {
|
|
2625
2630
|
return await getChildHandles$1(handle);
|
|
2626
2631
|
} catch (error) {
|
|
2627
|
-
throw new VError(error, 'failed to get child handles');
|
|
2632
|
+
throw new VError$1(error, 'failed to get child handles');
|
|
2628
2633
|
}
|
|
2629
2634
|
};
|
|
2630
2635
|
|
|
@@ -2923,7 +2928,7 @@ const getHandle = async uri => {
|
|
|
2923
2928
|
const handle = await getHandle$1(uri);
|
|
2924
2929
|
return handle;
|
|
2925
2930
|
} catch (error) {
|
|
2926
|
-
throw new VError(error, 'Failed to get handle');
|
|
2931
|
+
throw new VError$1(error, 'Failed to get handle');
|
|
2927
2932
|
}
|
|
2928
2933
|
};
|
|
2929
2934
|
|