@lvce-editor/renderer-process 13.8.0 → 13.10.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/rendererProcessMain.js +53 -14
- package/package.json +1 -1
|
@@ -559,6 +559,16 @@ const constructError = (message, type, name) => {
|
|
|
559
559
|
}
|
|
560
560
|
return new ErrorConstructor(message);
|
|
561
561
|
};
|
|
562
|
+
const joinLines$2 = lines => {
|
|
563
|
+
return lines.join(NewLine$3);
|
|
564
|
+
};
|
|
565
|
+
const splitLines$2 = lines => {
|
|
566
|
+
return lines.split(NewLine$3);
|
|
567
|
+
};
|
|
568
|
+
const getCurrentStack = () => {
|
|
569
|
+
const currentStack = joinLines$2(splitLines$2(new Error().stack || '').slice(2));
|
|
570
|
+
return currentStack;
|
|
571
|
+
};
|
|
562
572
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
563
573
|
return string.indexOf(NewLine$3, startIndex);
|
|
564
574
|
};
|
|
@@ -569,19 +579,16 @@ const getParentStack = error => {
|
|
|
569
579
|
}
|
|
570
580
|
return parentStack;
|
|
571
581
|
};
|
|
572
|
-
const joinLines$2 = lines => {
|
|
573
|
-
return lines.join(NewLine$3);
|
|
574
|
-
};
|
|
575
582
|
const MethodNotFound = -32601;
|
|
576
583
|
const Custom = -32001;
|
|
577
|
-
const splitLines$2 = lines => {
|
|
578
|
-
return lines.split(NewLine$3);
|
|
579
|
-
};
|
|
580
584
|
const restoreJsonRpcError = error => {
|
|
585
|
+
const currentStack = getCurrentStack();
|
|
581
586
|
if (error && error instanceof Error) {
|
|
587
|
+
if (typeof error.stack === 'string') {
|
|
588
|
+
error.stack = error.stack + NewLine$3 + currentStack;
|
|
589
|
+
}
|
|
582
590
|
return error;
|
|
583
591
|
}
|
|
584
|
-
const currentStack = joinLines$2(splitLines$2(new Error().stack || '').slice(1));
|
|
585
592
|
if (error && error.code && error.code === MethodNotFound) {
|
|
586
593
|
const restoredError = new JsonRpcError(error.message);
|
|
587
594
|
const parentStack = getParentStack(error);
|
|
@@ -662,6 +669,17 @@ const getErrorType = prettyError => {
|
|
|
662
669
|
}
|
|
663
670
|
return undefined;
|
|
664
671
|
};
|
|
672
|
+
const isAlreadyStack = line => {
|
|
673
|
+
return line.trim().startsWith('at ');
|
|
674
|
+
};
|
|
675
|
+
const getStack = prettyError => {
|
|
676
|
+
const stackString = prettyError.stack || '';
|
|
677
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
678
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
679
|
+
return stackString.slice(newLineIndex + 1);
|
|
680
|
+
}
|
|
681
|
+
return stackString;
|
|
682
|
+
};
|
|
665
683
|
const getErrorProperty = (error, prettyError) => {
|
|
666
684
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
667
685
|
return {
|
|
@@ -674,7 +692,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
674
692
|
code: Custom,
|
|
675
693
|
message: prettyError.message,
|
|
676
694
|
data: {
|
|
677
|
-
stack: prettyError
|
|
695
|
+
stack: getStack(prettyError),
|
|
678
696
|
codeFrame: prettyError.codeFrame,
|
|
679
697
|
type: getErrorType(prettyError),
|
|
680
698
|
code: prettyError.code,
|
|
@@ -682,18 +700,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
682
700
|
}
|
|
683
701
|
};
|
|
684
702
|
};
|
|
685
|
-
const create$1$1 = (
|
|
703
|
+
const create$1$1 = (id, error) => {
|
|
686
704
|
return {
|
|
687
705
|
jsonrpc: Two,
|
|
688
|
-
id
|
|
706
|
+
id,
|
|
689
707
|
error
|
|
690
708
|
};
|
|
691
709
|
};
|
|
692
|
-
const getErrorResponse = (
|
|
710
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
693
711
|
const prettyError = preparePrettyError(error);
|
|
694
712
|
logError(error, prettyError);
|
|
695
713
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
696
|
-
return create$1$1(
|
|
714
|
+
return create$1$1(id, errorProperty);
|
|
697
715
|
};
|
|
698
716
|
const create$J = (message, result) => {
|
|
699
717
|
return {
|
|
@@ -706,12 +724,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
706
724
|
const resultProperty = result ?? null;
|
|
707
725
|
return create$J(message, resultProperty);
|
|
708
726
|
};
|
|
727
|
+
const getErrorResponseSimple = (id, error) => {
|
|
728
|
+
return {
|
|
729
|
+
jsonrpc: Two,
|
|
730
|
+
id,
|
|
731
|
+
error: {
|
|
732
|
+
code: Custom,
|
|
733
|
+
// @ts-ignore
|
|
734
|
+
message: error.message,
|
|
735
|
+
data: error
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
};
|
|
709
739
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
710
740
|
try {
|
|
711
741
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
712
742
|
return getSuccessResponse(message, result);
|
|
713
743
|
} catch (error) {
|
|
714
|
-
|
|
744
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
745
|
+
return getErrorResponseSimple(message.id, error);
|
|
746
|
+
}
|
|
747
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
715
748
|
}
|
|
716
749
|
};
|
|
717
750
|
const defaultPreparePrettyError = error => {
|
|
@@ -766,7 +799,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
766
799
|
try {
|
|
767
800
|
ipc.send(response);
|
|
768
801
|
} catch (error) {
|
|
769
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
802
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
770
803
|
ipc.send(errorResponse);
|
|
771
804
|
}
|
|
772
805
|
return;
|
|
@@ -1233,6 +1266,7 @@ const TextArea$1 = 'textarea';
|
|
|
1233
1266
|
const Select$1 = 'select';
|
|
1234
1267
|
const Option$1 = 'option';
|
|
1235
1268
|
const Code$1 = 'code';
|
|
1269
|
+
const Label$1 = 'label';
|
|
1236
1270
|
const Audio$2 = 0;
|
|
1237
1271
|
const Button = 1;
|
|
1238
1272
|
const Col = 2;
|
|
@@ -1286,6 +1320,7 @@ const TextArea = 62;
|
|
|
1286
1320
|
const Select = 63;
|
|
1287
1321
|
const Option = 64;
|
|
1288
1322
|
const Code$2 = 65;
|
|
1323
|
+
const Label = 66;
|
|
1289
1324
|
const getElementTag = type => {
|
|
1290
1325
|
switch (type) {
|
|
1291
1326
|
case Audio$2:
|
|
@@ -1392,6 +1427,8 @@ const getElementTag = type => {
|
|
|
1392
1427
|
return Option$1;
|
|
1393
1428
|
case Code$2:
|
|
1394
1429
|
return Code$1;
|
|
1430
|
+
case Label:
|
|
1431
|
+
return Label$1;
|
|
1395
1432
|
default:
|
|
1396
1433
|
throw new Error(`element tag not found ${type}`);
|
|
1397
1434
|
}
|
|
@@ -1792,6 +1829,8 @@ const getEventListenerArg = (param, event) => {
|
|
|
1792
1829
|
return event.defaultPrevented;
|
|
1793
1830
|
case 'event.target.dataset.name':
|
|
1794
1831
|
return event.target.dataset.name;
|
|
1832
|
+
case 'event.target.dataset.index':
|
|
1833
|
+
return event.target.dataset.index;
|
|
1795
1834
|
default:
|
|
1796
1835
|
return param;
|
|
1797
1836
|
}
|