@lvce-editor/preview-sandbox-worker 4.6.0 → 4.7.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/previewSandBoxWorkerMain.js +141 -100
- package/package.json +1 -1
|
@@ -580,7 +580,10 @@ const constructError = (message, type, name) => {
|
|
|
580
580
|
if (ErrorConstructor === Error) {
|
|
581
581
|
const error = new Error(message);
|
|
582
582
|
if (name && name !== 'VError') {
|
|
583
|
-
error
|
|
583
|
+
Object.defineProperty(error, 'name', {
|
|
584
|
+
configurable: true,
|
|
585
|
+
value: name
|
|
586
|
+
});
|
|
584
587
|
}
|
|
585
588
|
return error;
|
|
586
589
|
}
|
|
@@ -597,8 +600,10 @@ const getCurrentStack = () => {
|
|
|
597
600
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
598
601
|
return currentStack;
|
|
599
602
|
};
|
|
600
|
-
const getNewLineIndex = (string, startIndex
|
|
601
|
-
|
|
603
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
604
|
+
{
|
|
605
|
+
return string.indexOf(NewLine);
|
|
606
|
+
}
|
|
602
607
|
};
|
|
603
608
|
const getParentStack = error => {
|
|
604
609
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -609,55 +614,91 @@ const getParentStack = error => {
|
|
|
609
614
|
};
|
|
610
615
|
const MethodNotFound = -32601;
|
|
611
616
|
const Custom = -32001;
|
|
617
|
+
const setStack = (error, stack) => {
|
|
618
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
619
|
+
if (descriptor) {
|
|
620
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
624
|
+
error.stack = stack;
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
Object.defineProperty(error, 'stack', {
|
|
629
|
+
configurable: true,
|
|
630
|
+
value: stack,
|
|
631
|
+
writable: true
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
const restoreExistingError = (error, currentStack) => {
|
|
635
|
+
if (typeof error.stack === 'string') {
|
|
636
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
637
|
+
}
|
|
638
|
+
return error;
|
|
639
|
+
};
|
|
640
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
641
|
+
const restoredError = new JsonRpcError(error.message);
|
|
642
|
+
const parentStack = getParentStack(error);
|
|
643
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
644
|
+
return restoredError;
|
|
645
|
+
};
|
|
646
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
647
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
648
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (error.data.stack) {
|
|
652
|
+
setStack(restoredError, error.data.stack);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
const applyDataProperties = (restoredError, error) => {
|
|
656
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
657
|
+
if (error.data.codeFrame) {
|
|
658
|
+
// @ts-ignore
|
|
659
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
660
|
+
}
|
|
661
|
+
if (error.data.code) {
|
|
662
|
+
// @ts-ignore
|
|
663
|
+
restoredError.code = error.data.code;
|
|
664
|
+
}
|
|
665
|
+
if (error.data.type) {
|
|
666
|
+
// @ts-ignore
|
|
667
|
+
restoredError.name = error.data.type;
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
671
|
+
if (error.stack) {
|
|
672
|
+
const lowerStack = restoredError.stack || '';
|
|
673
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
674
|
+
const parentStack = getParentStack(error);
|
|
675
|
+
// @ts-ignore
|
|
676
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
677
|
+
}
|
|
678
|
+
if (error.codeFrame) {
|
|
679
|
+
// @ts-ignore
|
|
680
|
+
restoredError.codeFrame = error.codeFrame;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
684
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
685
|
+
if (error.data) {
|
|
686
|
+
applyDataProperties(restoredError, error);
|
|
687
|
+
} else {
|
|
688
|
+
applyDirectProperties(restoredError, error);
|
|
689
|
+
}
|
|
690
|
+
return restoredError;
|
|
691
|
+
};
|
|
612
692
|
const restoreJsonRpcError = error => {
|
|
613
693
|
const currentStack = getCurrentStack();
|
|
614
694
|
if (error && error instanceof Error) {
|
|
615
|
-
|
|
616
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
617
|
-
}
|
|
618
|
-
return error;
|
|
695
|
+
return restoreExistingError(error, currentStack);
|
|
619
696
|
}
|
|
620
697
|
if (error && error.code && error.code === MethodNotFound) {
|
|
621
|
-
|
|
622
|
-
const parentStack = getParentStack(error);
|
|
623
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
624
|
-
return restoredError;
|
|
698
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
625
699
|
}
|
|
626
700
|
if (error && error.message) {
|
|
627
|
-
|
|
628
|
-
if (error.data) {
|
|
629
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
630
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
631
|
-
} else if (error.data.stack) {
|
|
632
|
-
restoredError.stack = error.data.stack;
|
|
633
|
-
}
|
|
634
|
-
if (error.data.codeFrame) {
|
|
635
|
-
// @ts-ignore
|
|
636
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
637
|
-
}
|
|
638
|
-
if (error.data.code) {
|
|
639
|
-
// @ts-ignore
|
|
640
|
-
restoredError.code = error.data.code;
|
|
641
|
-
}
|
|
642
|
-
if (error.data.type) {
|
|
643
|
-
// @ts-ignore
|
|
644
|
-
restoredError.name = error.data.type;
|
|
645
|
-
}
|
|
646
|
-
} else {
|
|
647
|
-
if (error.stack) {
|
|
648
|
-
const lowerStack = restoredError.stack || '';
|
|
649
|
-
// @ts-ignore
|
|
650
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
651
|
-
const parentStack = getParentStack(error);
|
|
652
|
-
// @ts-ignore
|
|
653
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
654
|
-
}
|
|
655
|
-
if (error.codeFrame) {
|
|
656
|
-
// @ts-ignore
|
|
657
|
-
restoredError.codeFrame = error.codeFrame;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return restoredError;
|
|
701
|
+
return restoreMessageError(error);
|
|
661
702
|
}
|
|
662
703
|
if (typeof error === 'string') {
|
|
663
704
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -1117,61 +1158,6 @@ const create = rpcId => {
|
|
|
1117
1158
|
};
|
|
1118
1159
|
};
|
|
1119
1160
|
|
|
1120
|
-
const Button$1 = 1;
|
|
1121
|
-
const Div$1 = 4;
|
|
1122
|
-
const H1$1 = 5;
|
|
1123
|
-
const Input$1 = 6;
|
|
1124
|
-
const Span$1 = 8;
|
|
1125
|
-
const Table$1 = 9;
|
|
1126
|
-
const TBody$1 = 10;
|
|
1127
|
-
const Td$1 = 11;
|
|
1128
|
-
const Text = 12;
|
|
1129
|
-
const Th$1 = 13;
|
|
1130
|
-
const THead$1 = 14;
|
|
1131
|
-
const Tr$1 = 15;
|
|
1132
|
-
const Img$1 = 17;
|
|
1133
|
-
const Del$1 = 21;
|
|
1134
|
-
const H2$1 = 22;
|
|
1135
|
-
const H3$1 = 23;
|
|
1136
|
-
const H4$1 = 24;
|
|
1137
|
-
const H5$1 = 25;
|
|
1138
|
-
const H6$1 = 26;
|
|
1139
|
-
const Article$1 = 27;
|
|
1140
|
-
const Aside$1 = 28;
|
|
1141
|
-
const Footer$1 = 29;
|
|
1142
|
-
const Header$1 = 30;
|
|
1143
|
-
const Nav$1 = 40;
|
|
1144
|
-
const Section$1 = 41;
|
|
1145
|
-
const Search$1 = 42;
|
|
1146
|
-
const Dd$1 = 43;
|
|
1147
|
-
const Dl$1 = 44;
|
|
1148
|
-
const Figcaption$1 = 45;
|
|
1149
|
-
const Figure$1 = 46;
|
|
1150
|
-
const Hr$1 = 47;
|
|
1151
|
-
const Li$1 = 48;
|
|
1152
|
-
const Ol$1 = 49;
|
|
1153
|
-
const P$1 = 50;
|
|
1154
|
-
const Pre$1 = 51;
|
|
1155
|
-
const A$1 = 53;
|
|
1156
|
-
const Abbr$1 = 54;
|
|
1157
|
-
const Br$1 = 55;
|
|
1158
|
-
const Cite$1 = 56;
|
|
1159
|
-
const Data$1 = 57;
|
|
1160
|
-
const Time$1 = 58;
|
|
1161
|
-
const Tfoot$1 = 59;
|
|
1162
|
-
const Ul$1 = 60;
|
|
1163
|
-
const TextArea$1 = 62;
|
|
1164
|
-
const Select$1 = 63;
|
|
1165
|
-
const Option$1 = 64;
|
|
1166
|
-
const Code$1 = 65;
|
|
1167
|
-
const Label$1 = 66;
|
|
1168
|
-
const Dt$1 = 67;
|
|
1169
|
-
const Iframe$1 = 68;
|
|
1170
|
-
const Style = 72;
|
|
1171
|
-
const Html = 73;
|
|
1172
|
-
const Canvas$1 = 77;
|
|
1173
|
-
const Reference = 100;
|
|
1174
|
-
|
|
1175
1161
|
const DialogWorker = 7014;
|
|
1176
1162
|
const RendererWorker = 1;
|
|
1177
1163
|
|
|
@@ -1301,6 +1287,61 @@ const set$1 = (uid, instance) => {
|
|
|
1301
1287
|
states$1.set(uid, instance);
|
|
1302
1288
|
};
|
|
1303
1289
|
|
|
1290
|
+
const Button$1 = 1;
|
|
1291
|
+
const Div$1 = 4;
|
|
1292
|
+
const H1$1 = 5;
|
|
1293
|
+
const Input$1 = 6;
|
|
1294
|
+
const Span$1 = 8;
|
|
1295
|
+
const Table$1 = 9;
|
|
1296
|
+
const TBody$1 = 10;
|
|
1297
|
+
const Td$1 = 11;
|
|
1298
|
+
const Text = 12;
|
|
1299
|
+
const Th$1 = 13;
|
|
1300
|
+
const THead$1 = 14;
|
|
1301
|
+
const Tr$1 = 15;
|
|
1302
|
+
const Img$1 = 17;
|
|
1303
|
+
const Del$1 = 21;
|
|
1304
|
+
const H2$1 = 22;
|
|
1305
|
+
const H3$1 = 23;
|
|
1306
|
+
const H4$1 = 24;
|
|
1307
|
+
const H5$1 = 25;
|
|
1308
|
+
const H6$1 = 26;
|
|
1309
|
+
const Article$1 = 27;
|
|
1310
|
+
const Aside$1 = 28;
|
|
1311
|
+
const Footer$1 = 29;
|
|
1312
|
+
const Header$1 = 30;
|
|
1313
|
+
const Nav$1 = 40;
|
|
1314
|
+
const Section$1 = 41;
|
|
1315
|
+
const Search$1 = 42;
|
|
1316
|
+
const Dd$1 = 43;
|
|
1317
|
+
const Dl$1 = 44;
|
|
1318
|
+
const Figcaption$1 = 45;
|
|
1319
|
+
const Figure$1 = 46;
|
|
1320
|
+
const Hr$1 = 47;
|
|
1321
|
+
const Li$1 = 48;
|
|
1322
|
+
const Ol$1 = 49;
|
|
1323
|
+
const P$1 = 50;
|
|
1324
|
+
const Pre$1 = 51;
|
|
1325
|
+
const A$1 = 53;
|
|
1326
|
+
const Abbr$1 = 54;
|
|
1327
|
+
const Br$1 = 55;
|
|
1328
|
+
const Cite$1 = 56;
|
|
1329
|
+
const Data$1 = 57;
|
|
1330
|
+
const Time$1 = 58;
|
|
1331
|
+
const Tfoot$1 = 59;
|
|
1332
|
+
const Ul$1 = 60;
|
|
1333
|
+
const TextArea$1 = 62;
|
|
1334
|
+
const Select$1 = 63;
|
|
1335
|
+
const Option$1 = 64;
|
|
1336
|
+
const Code$1 = 65;
|
|
1337
|
+
const Label$1 = 66;
|
|
1338
|
+
const Dt$1 = 67;
|
|
1339
|
+
const Iframe$1 = 68;
|
|
1340
|
+
const Style = 72;
|
|
1341
|
+
const Html = 73;
|
|
1342
|
+
const Canvas$1 = 77;
|
|
1343
|
+
const Reference = 100;
|
|
1344
|
+
|
|
1304
1345
|
const mergeClassNames = (...classNames) => {
|
|
1305
1346
|
return classNames.filter(Boolean).join(' ');
|
|
1306
1347
|
};
|