@lvce-editor/update-worker 2.9.0 → 2.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/updateWorkerMain.js +91 -50
- package/package.json +1 -1
package/dist/updateWorkerMain.js
CHANGED
|
@@ -537,7 +537,10 @@ const constructError = (message, type, name) => {
|
|
|
537
537
|
if (ErrorConstructor === Error) {
|
|
538
538
|
const error = new Error(message);
|
|
539
539
|
if (name && name !== 'VError') {
|
|
540
|
-
error
|
|
540
|
+
Object.defineProperty(error, 'name', {
|
|
541
|
+
configurable: true,
|
|
542
|
+
value: name
|
|
543
|
+
});
|
|
541
544
|
}
|
|
542
545
|
return error;
|
|
543
546
|
}
|
|
@@ -554,8 +557,10 @@ const getCurrentStack = () => {
|
|
|
554
557
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
555
558
|
return currentStack;
|
|
556
559
|
};
|
|
557
|
-
const getNewLineIndex = (string, startIndex
|
|
558
|
-
|
|
560
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
561
|
+
{
|
|
562
|
+
return string.indexOf(NewLine);
|
|
563
|
+
}
|
|
559
564
|
};
|
|
560
565
|
const getParentStack = error => {
|
|
561
566
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -566,55 +571,91 @@ const getParentStack = error => {
|
|
|
566
571
|
};
|
|
567
572
|
const MethodNotFound = -32601;
|
|
568
573
|
const Custom = -32001;
|
|
574
|
+
const setStack = (error, stack) => {
|
|
575
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
576
|
+
if (descriptor) {
|
|
577
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
581
|
+
error.stack = stack;
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
Object.defineProperty(error, 'stack', {
|
|
586
|
+
configurable: true,
|
|
587
|
+
value: stack,
|
|
588
|
+
writable: true
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
const restoreExistingError = (error, currentStack) => {
|
|
592
|
+
if (typeof error.stack === 'string') {
|
|
593
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
594
|
+
}
|
|
595
|
+
return error;
|
|
596
|
+
};
|
|
597
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
598
|
+
const restoredError = new JsonRpcError(error.message);
|
|
599
|
+
const parentStack = getParentStack(error);
|
|
600
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
601
|
+
return restoredError;
|
|
602
|
+
};
|
|
603
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
604
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
605
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (error.data.stack) {
|
|
609
|
+
setStack(restoredError, error.data.stack);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
const applyDataProperties = (restoredError, error) => {
|
|
613
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
614
|
+
if (error.data.codeFrame) {
|
|
615
|
+
// @ts-ignore
|
|
616
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
617
|
+
}
|
|
618
|
+
if (error.data.code) {
|
|
619
|
+
// @ts-ignore
|
|
620
|
+
restoredError.code = error.data.code;
|
|
621
|
+
}
|
|
622
|
+
if (error.data.type) {
|
|
623
|
+
// @ts-ignore
|
|
624
|
+
restoredError.name = error.data.type;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
628
|
+
if (error.stack) {
|
|
629
|
+
const lowerStack = restoredError.stack || '';
|
|
630
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
631
|
+
const parentStack = getParentStack(error);
|
|
632
|
+
// @ts-ignore
|
|
633
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
634
|
+
}
|
|
635
|
+
if (error.codeFrame) {
|
|
636
|
+
// @ts-ignore
|
|
637
|
+
restoredError.codeFrame = error.codeFrame;
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
641
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
642
|
+
if (error.data) {
|
|
643
|
+
applyDataProperties(restoredError, error);
|
|
644
|
+
} else {
|
|
645
|
+
applyDirectProperties(restoredError, error);
|
|
646
|
+
}
|
|
647
|
+
return restoredError;
|
|
648
|
+
};
|
|
569
649
|
const restoreJsonRpcError = error => {
|
|
570
650
|
const currentStack = getCurrentStack();
|
|
571
651
|
if (error && error instanceof Error) {
|
|
572
|
-
|
|
573
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
574
|
-
}
|
|
575
|
-
return error;
|
|
652
|
+
return restoreExistingError(error, currentStack);
|
|
576
653
|
}
|
|
577
654
|
if (error && error.code && error.code === MethodNotFound) {
|
|
578
|
-
|
|
579
|
-
const parentStack = getParentStack(error);
|
|
580
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
581
|
-
return restoredError;
|
|
655
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
582
656
|
}
|
|
583
657
|
if (error && error.message) {
|
|
584
|
-
|
|
585
|
-
if (error.data) {
|
|
586
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
587
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
588
|
-
} else if (error.data.stack) {
|
|
589
|
-
restoredError.stack = error.data.stack;
|
|
590
|
-
}
|
|
591
|
-
if (error.data.codeFrame) {
|
|
592
|
-
// @ts-ignore
|
|
593
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
594
|
-
}
|
|
595
|
-
if (error.data.code) {
|
|
596
|
-
// @ts-ignore
|
|
597
|
-
restoredError.code = error.data.code;
|
|
598
|
-
}
|
|
599
|
-
if (error.data.type) {
|
|
600
|
-
// @ts-ignore
|
|
601
|
-
restoredError.name = error.data.type;
|
|
602
|
-
}
|
|
603
|
-
} else {
|
|
604
|
-
if (error.stack) {
|
|
605
|
-
const lowerStack = restoredError.stack || '';
|
|
606
|
-
// @ts-ignore
|
|
607
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
608
|
-
const parentStack = getParentStack(error);
|
|
609
|
-
// @ts-ignore
|
|
610
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
611
|
-
}
|
|
612
|
-
if (error.codeFrame) {
|
|
613
|
-
// @ts-ignore
|
|
614
|
-
restoredError.codeFrame = error.codeFrame;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
return restoredError;
|
|
658
|
+
return restoreMessageError(error);
|
|
618
659
|
}
|
|
619
660
|
if (typeof error === 'string') {
|
|
620
661
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -1074,14 +1115,9 @@ const create = rpcId => {
|
|
|
1074
1115
|
};
|
|
1075
1116
|
};
|
|
1076
1117
|
|
|
1077
|
-
const Electron = 2;
|
|
1078
|
-
|
|
1079
1118
|
const DialogWorker = 7014;
|
|
1080
1119
|
const RendererWorker = 1;
|
|
1081
1120
|
|
|
1082
|
-
const DownloadingUpdate = 2;
|
|
1083
|
-
const DownloadedUpdate = 3;
|
|
1084
|
-
|
|
1085
1121
|
const {
|
|
1086
1122
|
invoke: invoke$1,
|
|
1087
1123
|
set: set$1
|
|
@@ -1097,6 +1133,11 @@ const sendMessagePortToDialogWorker = async port => {
|
|
|
1097
1133
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1098
1134
|
};
|
|
1099
1135
|
|
|
1136
|
+
const Electron = 2;
|
|
1137
|
+
|
|
1138
|
+
const DownloadingUpdate = 2;
|
|
1139
|
+
const DownloadedUpdate = 3;
|
|
1140
|
+
|
|
1100
1141
|
const emptyObject = {};
|
|
1101
1142
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1102
1143
|
const i18nString = (key, placeholders = emptyObject) => {
|