@lvce-editor/preview-sandbox-worker 3.0.0 → 3.1.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 +80 -113
- package/package.json +1 -1
|
@@ -1238,117 +1238,63 @@ const Del = 'del';
|
|
|
1238
1238
|
const H6 = 'h6';
|
|
1239
1239
|
const Canvas = 'canvas';
|
|
1240
1240
|
|
|
1241
|
+
const tagMap = {
|
|
1242
|
+
[A]: A$1,
|
|
1243
|
+
[Abbr]: Abbr$1,
|
|
1244
|
+
[Article]: Article$1,
|
|
1245
|
+
[Aside]: Aside$1,
|
|
1246
|
+
[Br]: Br$1,
|
|
1247
|
+
[Button]: Button$1,
|
|
1248
|
+
[Canvas]: Canvas$1,
|
|
1249
|
+
[Cite]: Cite$1,
|
|
1250
|
+
[Code]: Code$1,
|
|
1251
|
+
[Data]: Data$1,
|
|
1252
|
+
[Dd]: Dd$1,
|
|
1253
|
+
[Del]: Del$1,
|
|
1254
|
+
[Div]: Div$1,
|
|
1255
|
+
[Dl]: Dl$1,
|
|
1256
|
+
[Dt]: Dt$1,
|
|
1257
|
+
[Figcaption]: Figcaption$1,
|
|
1258
|
+
[Figure]: Figure$1,
|
|
1259
|
+
[Footer]: Footer$1,
|
|
1260
|
+
[Form]: Div$1,
|
|
1261
|
+
[H1]: H1$1,
|
|
1262
|
+
[H2]: H2$1,
|
|
1263
|
+
[H3]: H3$1,
|
|
1264
|
+
[H4]: H4$1,
|
|
1265
|
+
[H5]: H5$1,
|
|
1266
|
+
[H6]: H6$1,
|
|
1267
|
+
[Header]: Header$1,
|
|
1268
|
+
[Hr]: Hr$1,
|
|
1269
|
+
[Iframe]: Iframe$1,
|
|
1270
|
+
[Img]: Img$1,
|
|
1271
|
+
[Input]: Input$1,
|
|
1272
|
+
[Label]: Label$1,
|
|
1273
|
+
[Li]: Li$1,
|
|
1274
|
+
[Nav]: Nav$1,
|
|
1275
|
+
[Ol]: Ol$1,
|
|
1276
|
+
[Option]: Option$1,
|
|
1277
|
+
[P]: P$1,
|
|
1278
|
+
[Pre]: Pre$1,
|
|
1279
|
+
[Search]: Search$1,
|
|
1280
|
+
[Section]: Section$1,
|
|
1281
|
+
[Select]: Select$1,
|
|
1282
|
+
[Span]: Span$1,
|
|
1283
|
+
[Table]: Table$1,
|
|
1284
|
+
[TBody]: TBody$1,
|
|
1285
|
+
[Td]: Td$1,
|
|
1286
|
+
[TextArea]: TextArea$1,
|
|
1287
|
+
[Tfoot]: Tfoot$1,
|
|
1288
|
+
[Th]: Th$1,
|
|
1289
|
+
[THead]: THead$1,
|
|
1290
|
+
[Time]: Time$1,
|
|
1291
|
+
[Tr]: Tr$1,
|
|
1292
|
+
[Ul]: Ul$1,
|
|
1293
|
+
html: Html,
|
|
1294
|
+
style: Style
|
|
1295
|
+
};
|
|
1241
1296
|
const getVirtualDomTag = text => {
|
|
1242
|
-
|
|
1243
|
-
case A:
|
|
1244
|
-
return A$1;
|
|
1245
|
-
case Abbr:
|
|
1246
|
-
return Abbr$1;
|
|
1247
|
-
case Article:
|
|
1248
|
-
return Article$1;
|
|
1249
|
-
case Aside:
|
|
1250
|
-
return Aside$1;
|
|
1251
|
-
case Br:
|
|
1252
|
-
return Br$1;
|
|
1253
|
-
case Button:
|
|
1254
|
-
return Button$1;
|
|
1255
|
-
case Canvas:
|
|
1256
|
-
return Canvas$1;
|
|
1257
|
-
case Cite:
|
|
1258
|
-
return Cite$1;
|
|
1259
|
-
case Code:
|
|
1260
|
-
return Code$1;
|
|
1261
|
-
case Data:
|
|
1262
|
-
return Data$1;
|
|
1263
|
-
case Dd:
|
|
1264
|
-
return Dd$1;
|
|
1265
|
-
case Del:
|
|
1266
|
-
return Del$1;
|
|
1267
|
-
case Div:
|
|
1268
|
-
return Div$1;
|
|
1269
|
-
case Dl:
|
|
1270
|
-
return Dl$1;
|
|
1271
|
-
case Dt:
|
|
1272
|
-
return Dt$1;
|
|
1273
|
-
case Figcaption:
|
|
1274
|
-
return Figcaption$1;
|
|
1275
|
-
case Figure:
|
|
1276
|
-
return Figure$1;
|
|
1277
|
-
case Footer:
|
|
1278
|
-
return Footer$1;
|
|
1279
|
-
case Form:
|
|
1280
|
-
return Div$1;
|
|
1281
|
-
case H1:
|
|
1282
|
-
return H1$1;
|
|
1283
|
-
case H2:
|
|
1284
|
-
return H2$1;
|
|
1285
|
-
case H3:
|
|
1286
|
-
return H3$1;
|
|
1287
|
-
case H4:
|
|
1288
|
-
return H4$1;
|
|
1289
|
-
case H5:
|
|
1290
|
-
return H5$1;
|
|
1291
|
-
case H6:
|
|
1292
|
-
return H6$1;
|
|
1293
|
-
case Header:
|
|
1294
|
-
return Header$1;
|
|
1295
|
-
case Hr:
|
|
1296
|
-
return Hr$1;
|
|
1297
|
-
case Iframe:
|
|
1298
|
-
return Iframe$1;
|
|
1299
|
-
case Img:
|
|
1300
|
-
return Img$1;
|
|
1301
|
-
case Input:
|
|
1302
|
-
return Input$1;
|
|
1303
|
-
case Label:
|
|
1304
|
-
return Label$1;
|
|
1305
|
-
case Li:
|
|
1306
|
-
return Li$1;
|
|
1307
|
-
case Nav:
|
|
1308
|
-
return Nav$1;
|
|
1309
|
-
case Ol:
|
|
1310
|
-
return Ol$1;
|
|
1311
|
-
case Option:
|
|
1312
|
-
return Option$1;
|
|
1313
|
-
case P:
|
|
1314
|
-
return P$1;
|
|
1315
|
-
case Pre:
|
|
1316
|
-
return Pre$1;
|
|
1317
|
-
case Search:
|
|
1318
|
-
return Search$1;
|
|
1319
|
-
case Section:
|
|
1320
|
-
return Section$1;
|
|
1321
|
-
case Select:
|
|
1322
|
-
return Select$1;
|
|
1323
|
-
case Span:
|
|
1324
|
-
return Span$1;
|
|
1325
|
-
case Table:
|
|
1326
|
-
return Table$1;
|
|
1327
|
-
case TBody:
|
|
1328
|
-
return TBody$1;
|
|
1329
|
-
case Td:
|
|
1330
|
-
return Td$1;
|
|
1331
|
-
case TextArea:
|
|
1332
|
-
return TextArea$1;
|
|
1333
|
-
case Tfoot:
|
|
1334
|
-
return Tfoot$1;
|
|
1335
|
-
case Th:
|
|
1336
|
-
return Th$1;
|
|
1337
|
-
case THead:
|
|
1338
|
-
return THead$1;
|
|
1339
|
-
case Time:
|
|
1340
|
-
return Time$1;
|
|
1341
|
-
case Tr:
|
|
1342
|
-
return Tr$1;
|
|
1343
|
-
case Ul:
|
|
1344
|
-
return Ul$1;
|
|
1345
|
-
case 'html':
|
|
1346
|
-
return Html;
|
|
1347
|
-
case 'style':
|
|
1348
|
-
return Style;
|
|
1349
|
-
default:
|
|
1350
|
-
return Div$1;
|
|
1351
|
-
}
|
|
1297
|
+
return tagMap[text] || Div$1;
|
|
1352
1298
|
};
|
|
1353
1299
|
|
|
1354
1300
|
/* eslint-disable @cspell/spellchecker */
|
|
@@ -89603,6 +89549,28 @@ const createWindow = (rawHtml, url = 'http://localhost:3000') => {
|
|
|
89603
89549
|
};
|
|
89604
89550
|
};
|
|
89605
89551
|
|
|
89552
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
89553
|
+
|
|
89554
|
+
const exposeCanvasGlobals = (window, document) => {
|
|
89555
|
+
const existingCanvasRenderingContext2D = window.CanvasRenderingContext2D || globalThis.CanvasRenderingContext2D;
|
|
89556
|
+
if (existingCanvasRenderingContext2D) {
|
|
89557
|
+
window.CanvasRenderingContext2D = existingCanvasRenderingContext2D;
|
|
89558
|
+
globalThis.CanvasRenderingContext2D = existingCanvasRenderingContext2D;
|
|
89559
|
+
return;
|
|
89560
|
+
}
|
|
89561
|
+
const canvas = document.querySelector('canvas');
|
|
89562
|
+
if (!canvas || typeof canvas.getContext !== 'function') {
|
|
89563
|
+
return;
|
|
89564
|
+
}
|
|
89565
|
+
const context = canvas.getContext('2d');
|
|
89566
|
+
const CanvasRenderingContext2D = context?.constructor;
|
|
89567
|
+
if (typeof CanvasRenderingContext2D !== 'function') {
|
|
89568
|
+
return;
|
|
89569
|
+
}
|
|
89570
|
+
window.CanvasRenderingContext2D = CanvasRenderingContext2D;
|
|
89571
|
+
globalThis.CanvasRenderingContext2D = CanvasRenderingContext2D;
|
|
89572
|
+
};
|
|
89573
|
+
|
|
89606
89574
|
/**
|
|
89607
89575
|
* Extracts line and column information from an error stack trace
|
|
89608
89576
|
* Looks for patterns like "<anonymous>:114:26" in the stack trace
|
|
@@ -89834,6 +89802,7 @@ const setGlobals = (window, globalGlobals, windowGlobals) => {
|
|
|
89834
89802
|
/* eslint-disable @typescript-eslint/no-implied-eval */
|
|
89835
89803
|
|
|
89836
89804
|
const executeScripts = (window, document, scripts, width = 0, height = 0) => {
|
|
89805
|
+
exposeCanvasGlobals(window, document);
|
|
89837
89806
|
const {
|
|
89838
89807
|
globalGlobals,
|
|
89839
89808
|
windowGlobals
|
|
@@ -89904,9 +89873,7 @@ const handleMutations = async uid => {
|
|
|
89904
89873
|
elementMap,
|
|
89905
89874
|
window: happyDomInstance.window
|
|
89906
89875
|
});
|
|
89907
|
-
|
|
89908
|
-
// @ts-ignore
|
|
89909
|
-
getParsedNodesChildNodeCount(parsedDom);
|
|
89876
|
+
getParsedNodesChildNodeCount(serialized.dom);
|
|
89910
89877
|
try {
|
|
89911
89878
|
await invoke$1('Preview.handleMutation', uid);
|
|
89912
89879
|
} catch (error) {
|