@lvce-editor/extension-detail-view 3.22.0 → 3.23.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.
|
@@ -60,31 +60,39 @@ 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 string = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
95
|
+
if (type !== String) {
|
|
88
96
|
throw new AssertionError('expected value to be of type string');
|
|
89
97
|
}
|
|
90
98
|
};
|
|
@@ -338,22 +346,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
338
346
|
const wrap$f = global => {
|
|
339
347
|
return new IpcChildWithModuleWorker(global);
|
|
340
348
|
};
|
|
341
|
-
const withResolvers = () => {
|
|
342
|
-
let _resolve;
|
|
343
|
-
const promise = new Promise(resolve => {
|
|
344
|
-
_resolve = resolve;
|
|
345
|
-
});
|
|
346
|
-
return {
|
|
347
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
348
|
-
resolve: _resolve,
|
|
349
|
-
promise
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
349
|
const waitForFirstMessage = async port => {
|
|
353
350
|
const {
|
|
354
351
|
resolve,
|
|
355
352
|
promise
|
|
356
|
-
} = withResolvers();
|
|
353
|
+
} = Promise.withResolvers();
|
|
357
354
|
port.addEventListener('message', resolve, {
|
|
358
355
|
once: true
|
|
359
356
|
});
|
|
@@ -424,7 +421,7 @@ const create$4 = (method, params) => {
|
|
|
424
421
|
};
|
|
425
422
|
};
|
|
426
423
|
const callbacks = Object.create(null);
|
|
427
|
-
const set$
|
|
424
|
+
const set$2 = (id, fn) => {
|
|
428
425
|
callbacks[id] = fn;
|
|
429
426
|
};
|
|
430
427
|
const get$2 = id => {
|
|
@@ -434,16 +431,16 @@ const remove = id => {
|
|
|
434
431
|
delete callbacks[id];
|
|
435
432
|
};
|
|
436
433
|
let id$1 = 0;
|
|
437
|
-
const create$3 = () => {
|
|
434
|
+
const create$3$1 = () => {
|
|
438
435
|
return ++id$1;
|
|
439
436
|
};
|
|
440
437
|
const registerPromise = () => {
|
|
441
|
-
const id = create$3();
|
|
438
|
+
const id = create$3$1();
|
|
442
439
|
const {
|
|
443
440
|
resolve,
|
|
444
441
|
promise
|
|
445
442
|
} = Promise.withResolvers();
|
|
446
|
-
set$
|
|
443
|
+
set$2(id, resolve);
|
|
447
444
|
return {
|
|
448
445
|
id,
|
|
449
446
|
promise
|
|
@@ -516,6 +513,16 @@ const constructError = (message, type, name) => {
|
|
|
516
513
|
}
|
|
517
514
|
return new ErrorConstructor(message);
|
|
518
515
|
};
|
|
516
|
+
const joinLines = lines => {
|
|
517
|
+
return lines.join(NewLine);
|
|
518
|
+
};
|
|
519
|
+
const splitLines = lines => {
|
|
520
|
+
return lines.split(NewLine);
|
|
521
|
+
};
|
|
522
|
+
const getCurrentStack = () => {
|
|
523
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
524
|
+
return currentStack;
|
|
525
|
+
};
|
|
519
526
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
520
527
|
return string.indexOf(NewLine, startIndex);
|
|
521
528
|
};
|
|
@@ -526,19 +533,16 @@ const getParentStack = error => {
|
|
|
526
533
|
}
|
|
527
534
|
return parentStack;
|
|
528
535
|
};
|
|
529
|
-
const joinLines = lines => {
|
|
530
|
-
return lines.join(NewLine);
|
|
531
|
-
};
|
|
532
536
|
const MethodNotFound = -32601;
|
|
533
537
|
const Custom = -32001;
|
|
534
|
-
const splitLines = lines => {
|
|
535
|
-
return lines.split(NewLine);
|
|
536
|
-
};
|
|
537
538
|
const restoreJsonRpcError = error => {
|
|
539
|
+
const currentStack = getCurrentStack();
|
|
538
540
|
if (error && error instanceof Error) {
|
|
541
|
+
if (typeof error.stack === 'string') {
|
|
542
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
543
|
+
}
|
|
539
544
|
return error;
|
|
540
545
|
}
|
|
541
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
542
546
|
if (error && error.code && error.code === MethodNotFound) {
|
|
543
547
|
const restoredError = new JsonRpcError(error.message);
|
|
544
548
|
const parentStack = getParentStack(error);
|
|
@@ -619,6 +623,17 @@ const getErrorType = prettyError => {
|
|
|
619
623
|
}
|
|
620
624
|
return undefined;
|
|
621
625
|
};
|
|
626
|
+
const isAlreadyStack = line => {
|
|
627
|
+
return line.trim().startsWith('at ');
|
|
628
|
+
};
|
|
629
|
+
const getStack = prettyError => {
|
|
630
|
+
const stackString = prettyError.stack || '';
|
|
631
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
632
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
633
|
+
return stackString.slice(newLineIndex + 1);
|
|
634
|
+
}
|
|
635
|
+
return stackString;
|
|
636
|
+
};
|
|
622
637
|
const getErrorProperty = (error, prettyError) => {
|
|
623
638
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
624
639
|
return {
|
|
@@ -631,7 +646,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
631
646
|
code: Custom,
|
|
632
647
|
message: prettyError.message,
|
|
633
648
|
data: {
|
|
634
|
-
stack: prettyError
|
|
649
|
+
stack: getStack(prettyError),
|
|
635
650
|
codeFrame: prettyError.codeFrame,
|
|
636
651
|
type: getErrorType(prettyError),
|
|
637
652
|
code: prettyError.code,
|
|
@@ -639,18 +654,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
639
654
|
}
|
|
640
655
|
};
|
|
641
656
|
};
|
|
642
|
-
const create$1$1 = (
|
|
657
|
+
const create$1$1 = (id, error) => {
|
|
643
658
|
return {
|
|
644
659
|
jsonrpc: Two,
|
|
645
|
-
id
|
|
660
|
+
id,
|
|
646
661
|
error
|
|
647
662
|
};
|
|
648
663
|
};
|
|
649
|
-
const getErrorResponse = (
|
|
664
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
650
665
|
const prettyError = preparePrettyError(error);
|
|
651
666
|
logError(error, prettyError);
|
|
652
667
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
653
|
-
return create$1$1(
|
|
668
|
+
return create$1$1(id, errorProperty);
|
|
654
669
|
};
|
|
655
670
|
const create$5 = (message, result) => {
|
|
656
671
|
return {
|
|
@@ -663,12 +678,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
663
678
|
const resultProperty = result ?? null;
|
|
664
679
|
return create$5(message, resultProperty);
|
|
665
680
|
};
|
|
681
|
+
const getErrorResponseSimple = (id, error) => {
|
|
682
|
+
return {
|
|
683
|
+
jsonrpc: Two,
|
|
684
|
+
id,
|
|
685
|
+
error: {
|
|
686
|
+
code: Custom,
|
|
687
|
+
// @ts-ignore
|
|
688
|
+
message: error.message,
|
|
689
|
+
data: error
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
};
|
|
666
693
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
667
694
|
try {
|
|
668
695
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
669
696
|
return getSuccessResponse(message, result);
|
|
670
697
|
} catch (error) {
|
|
671
|
-
|
|
698
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
699
|
+
return getErrorResponseSimple(message.id, error);
|
|
700
|
+
}
|
|
701
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
672
702
|
}
|
|
673
703
|
};
|
|
674
704
|
const defaultPreparePrettyError = error => {
|
|
@@ -723,7 +753,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
723
753
|
try {
|
|
724
754
|
ipc.send(response);
|
|
725
755
|
} catch (error) {
|
|
726
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
756
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
727
757
|
ipc.send(errorResponse);
|
|
728
758
|
}
|
|
729
759
|
return;
|
|
@@ -828,7 +858,7 @@ const listen$1 = async (module, options) => {
|
|
|
828
858
|
const ipc = module.wrap(rawIpc);
|
|
829
859
|
return ipc;
|
|
830
860
|
};
|
|
831
|
-
const create$
|
|
861
|
+
const create$3 = async ({
|
|
832
862
|
commandMap
|
|
833
863
|
}) => {
|
|
834
864
|
// TODO create a commandMap per rpc instance
|
|
@@ -840,12 +870,12 @@ const create$2 = async ({
|
|
|
840
870
|
};
|
|
841
871
|
const WebWorkerRpcClient = {
|
|
842
872
|
__proto__: null,
|
|
843
|
-
create: create$
|
|
873
|
+
create: create$3
|
|
844
874
|
};
|
|
845
875
|
|
|
846
876
|
const assetDir = '';
|
|
847
877
|
|
|
848
|
-
const create$
|
|
878
|
+
const create$2 = () => {
|
|
849
879
|
const states = Object.create(null);
|
|
850
880
|
return {
|
|
851
881
|
get(uid) {
|
|
@@ -909,9 +939,9 @@ const {
|
|
|
909
939
|
set: set$1,
|
|
910
940
|
dispose: dispose$1,
|
|
911
941
|
wrapCommand
|
|
912
|
-
} = create$
|
|
942
|
+
} = create$2();
|
|
913
943
|
|
|
914
|
-
const create = (uid, uri, x, y, width, height, platform, assetDir$1) => {
|
|
944
|
+
const create$1 = (uid, uri, x, y, width, height, platform, assetDir$1) => {
|
|
915
945
|
const state = {
|
|
916
946
|
description: '',
|
|
917
947
|
iconSrc: '',
|
|
@@ -1146,26 +1176,46 @@ const handleClickFeatures = async (state, name) => {
|
|
|
1146
1176
|
};
|
|
1147
1177
|
|
|
1148
1178
|
const rpcs = Object.create(null);
|
|
1149
|
-
const set$
|
|
1179
|
+
const set$g = (id, rpc) => {
|
|
1150
1180
|
rpcs[id] = rpc;
|
|
1151
1181
|
};
|
|
1152
1182
|
const get = id => {
|
|
1153
1183
|
return rpcs[id];
|
|
1154
1184
|
};
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
return
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1185
|
+
|
|
1186
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1187
|
+
|
|
1188
|
+
const create = rpcId => {
|
|
1189
|
+
return {
|
|
1190
|
+
// @ts-ignore
|
|
1191
|
+
invoke(method, ...params) {
|
|
1192
|
+
const rpc = get(rpcId);
|
|
1193
|
+
// @ts-ignore
|
|
1194
|
+
return rpc.invoke(method, ...params);
|
|
1195
|
+
},
|
|
1196
|
+
// @ts-ignore
|
|
1197
|
+
invokeAndTransfer(method, ...params) {
|
|
1198
|
+
const rpc = get(rpcId);
|
|
1199
|
+
// @ts-ignore
|
|
1200
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1201
|
+
},
|
|
1202
|
+
set(rpc) {
|
|
1203
|
+
set$g(rpcId, rpc);
|
|
1204
|
+
},
|
|
1205
|
+
async dispose() {
|
|
1206
|
+
const rpc = get(rpcId);
|
|
1207
|
+
await rpc.dispose();
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1163
1210
|
};
|
|
1211
|
+
const RendererWorker$1 = 1;
|
|
1212
|
+
const {
|
|
1213
|
+
invoke: invoke$4,
|
|
1214
|
+
set: set$3} = create(RendererWorker$1);
|
|
1164
1215
|
const RendererWorker = {
|
|
1165
1216
|
__proto__: null,
|
|
1166
|
-
invoke: invoke$
|
|
1167
|
-
set: set$
|
|
1168
|
-
};
|
|
1217
|
+
invoke: invoke$4,
|
|
1218
|
+
set: set$3};
|
|
1169
1219
|
|
|
1170
1220
|
const {
|
|
1171
1221
|
invoke,
|
|
@@ -2650,7 +2700,7 @@ const terminate = () => {
|
|
|
2650
2700
|
};
|
|
2651
2701
|
|
|
2652
2702
|
const commandMap = {
|
|
2653
|
-
'ExtensionDetail.create': create,
|
|
2703
|
+
'ExtensionDetail.create': create$1,
|
|
2654
2704
|
'ExtensionDetail.diff2': diff2,
|
|
2655
2705
|
'ExtensionDetail.dispose': dispose,
|
|
2656
2706
|
'ExtensionDetail.getCommandIds': getCommandIds,
|