@lvce-editor/preview-sandbox-worker 4.11.1 → 4.12.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.
@@ -529,7 +529,7 @@ const execute = (command, ...args) => {
529
529
 
530
530
  const Two$1 = '2.0';
531
531
  const callbacks$1 = Object.create(null);
532
- const get$2 = id => {
532
+ const get$3 = id => {
533
533
  return callbacks$1[id];
534
534
  };
535
535
  const remove$2 = id => {
@@ -719,7 +719,7 @@ const warn = (...args) => {
719
719
  console.warn(...args);
720
720
  };
721
721
  const resolve = (id, response) => {
722
- const fn = get$2(id);
722
+ const fn = get$3(id);
723
723
  if (!fn) {
724
724
  console.log(response);
725
725
  warn(`callback ${id} may already be disposed`);
@@ -1114,7 +1114,7 @@ const rpcs = Object.create(null);
1114
1114
  const set$5 = (id, rpc) => {
1115
1115
  rpcs[id] = rpc;
1116
1116
  };
1117
- const get$1 = id => {
1117
+ const get$2 = id => {
1118
1118
  return rpcs[id];
1119
1119
  };
1120
1120
  const remove$1 = id => {
@@ -1125,18 +1125,18 @@ const remove$1 = id => {
1125
1125
  const create = rpcId => {
1126
1126
  return {
1127
1127
  async dispose() {
1128
- const rpc = get$1(rpcId);
1128
+ const rpc = get$2(rpcId);
1129
1129
  await rpc.dispose();
1130
1130
  },
1131
1131
  // @ts-ignore
1132
1132
  invoke(method, ...params) {
1133
- const rpc = get$1(rpcId);
1133
+ const rpc = get$2(rpcId);
1134
1134
  // @ts-ignore
1135
1135
  return rpc.invoke(method, ...params);
1136
1136
  },
1137
1137
  // @ts-ignore
1138
1138
  invokeAndTransfer(method, ...params) {
1139
- const rpc = get$1(rpcId);
1139
+ const rpc = get$2(rpcId);
1140
1140
  // @ts-ignore
1141
1141
  return rpc.invokeAndTransfer(method, ...params);
1142
1142
  },
@@ -1158,20 +1158,190 @@ const create = rpcId => {
1158
1158
  };
1159
1159
  };
1160
1160
 
1161
+ const Audio = 0;
1162
+ const Button$1 = 1;
1163
+ const Col = 2;
1164
+ const ColGroup = 3;
1165
+ const Div$1 = 4;
1166
+ const H1$1 = 5;
1167
+ const Input$1 = 6;
1168
+ const Kbd = 7;
1169
+ const Span$1 = 8;
1170
+ const Table$1 = 9;
1171
+ const TBody$1 = 10;
1172
+ const Td$1 = 11;
1173
+ const Text = 12;
1174
+ const Th$1 = 13;
1175
+ const THead$1 = 14;
1176
+ const Tr$1 = 15;
1177
+ const I = 16;
1178
+ const Img$1 = 17;
1179
+ const Root = 0;
1180
+ const Ins = 20;
1181
+ const Del$1 = 21;
1182
+ const H2$1 = 22;
1183
+ const H3$1 = 23;
1184
+ const H4$1 = 24;
1185
+ const H5$1 = 25;
1186
+ const H6$1 = 26;
1187
+ const Article$1 = 27;
1188
+ const Aside$1 = 28;
1189
+ const Footer$1 = 29;
1190
+ const Header$1 = 30;
1191
+ const Nav$1 = 40;
1192
+ const Section$1 = 41;
1193
+ const Search$1 = 42;
1194
+ const Dd$1 = 43;
1195
+ const Dl$1 = 44;
1196
+ const Figcaption$1 = 45;
1197
+ const Figure$1 = 46;
1198
+ const Hr$1 = 47;
1199
+ const Li$1 = 48;
1200
+ const Ol$1 = 49;
1201
+ const P$1 = 50;
1202
+ const Pre$1 = 51;
1203
+ const A$1 = 53;
1204
+ const Abbr$1 = 54;
1205
+ const Br$1 = 55;
1206
+ const Cite$1 = 56;
1207
+ const Data$1 = 57;
1208
+ const Time$1 = 58;
1209
+ const Tfoot$1 = 59;
1210
+ const Ul$1 = 60;
1211
+ const Video = 61;
1212
+ const TextArea$1 = 62;
1213
+ const Select$1 = 63;
1214
+ const Option$1 = 64;
1215
+ const Code$1 = 65;
1216
+ const Label$1 = 66;
1217
+ const Dt$1 = 67;
1218
+ const Iframe$1 = 68;
1219
+ const Main = 69;
1220
+ const Strong = 70;
1221
+ const Em = 71;
1222
+ const Style = 72;
1223
+ const Html = 73;
1224
+ const Head = 74;
1225
+ const Title = 75;
1226
+ const Meta = 76;
1227
+ const Canvas$1 = 77;
1228
+ const Form$1 = 78;
1229
+ const BlockQuote = 79;
1230
+ const Quote = 80;
1231
+ const Circle$1 = 81;
1232
+ const Defs$1 = 82;
1233
+ const Ellipse$1 = 83;
1234
+ const G$1 = 84;
1235
+ const Line$1 = 85;
1236
+ const Path$1 = 86;
1237
+ const Polygon$1 = 87;
1238
+ const Polyline$1 = 88;
1239
+ const Rect$1 = 89;
1240
+ const Svg$1 = 90;
1241
+ const Use$1 = 91;
1242
+ const Reference = 100;
1243
+
1244
+ const VirtualDomElements = {
1245
+ __proto__: null,
1246
+ A: A$1,
1247
+ Abbr: Abbr$1,
1248
+ Article: Article$1,
1249
+ Aside: Aside$1,
1250
+ Audio,
1251
+ BlockQuote,
1252
+ Br: Br$1,
1253
+ Button: Button$1,
1254
+ Canvas: Canvas$1,
1255
+ Circle: Circle$1,
1256
+ Cite: Cite$1,
1257
+ Code: Code$1,
1258
+ Col,
1259
+ ColGroup,
1260
+ Data: Data$1,
1261
+ Dd: Dd$1,
1262
+ Defs: Defs$1,
1263
+ Del: Del$1,
1264
+ Div: Div$1,
1265
+ Dl: Dl$1,
1266
+ Dt: Dt$1,
1267
+ Ellipse: Ellipse$1,
1268
+ Em,
1269
+ Figcaption: Figcaption$1,
1270
+ Figure: Figure$1,
1271
+ Footer: Footer$1,
1272
+ Form: Form$1,
1273
+ G: G$1,
1274
+ H1: H1$1,
1275
+ H2: H2$1,
1276
+ H3: H3$1,
1277
+ H4: H4$1,
1278
+ H5: H5$1,
1279
+ H6: H6$1,
1280
+ Head,
1281
+ Header: Header$1,
1282
+ Hr: Hr$1,
1283
+ Html,
1284
+ I,
1285
+ Iframe: Iframe$1,
1286
+ Img: Img$1,
1287
+ Input: Input$1,
1288
+ Ins,
1289
+ Kbd,
1290
+ Label: Label$1,
1291
+ Li: Li$1,
1292
+ Line: Line$1,
1293
+ Main,
1294
+ Meta,
1295
+ Nav: Nav$1,
1296
+ Ol: Ol$1,
1297
+ Option: Option$1,
1298
+ P: P$1,
1299
+ Path: Path$1,
1300
+ Polygon: Polygon$1,
1301
+ Polyline: Polyline$1,
1302
+ Pre: Pre$1,
1303
+ Quote,
1304
+ Rect: Rect$1,
1305
+ Reference,
1306
+ Root,
1307
+ Search: Search$1,
1308
+ Section: Section$1,
1309
+ Select: Select$1,
1310
+ Span: Span$1,
1311
+ Strong,
1312
+ Style,
1313
+ Svg: Svg$1,
1314
+ TBody: TBody$1,
1315
+ THead: THead$1,
1316
+ Table: Table$1,
1317
+ Td: Td$1,
1318
+ Text,
1319
+ TextArea: TextArea$1,
1320
+ Tfoot: Tfoot$1,
1321
+ Th: Th$1,
1322
+ Time: Time$1,
1323
+ Title,
1324
+ Tr: Tr$1,
1325
+ Ul: Ul$1,
1326
+ Use: Use$1,
1327
+ Video
1328
+ };
1329
+
1161
1330
  const DialogWorker = 7014;
1162
1331
  const RendererWorker = 1;
1163
1332
 
1164
1333
  const {
1165
- invoke: invoke$1,
1334
+ invoke: invoke$2,
1166
1335
  set: set$4
1167
1336
  } = create(DialogWorker);
1168
1337
 
1169
1338
  const {
1170
- invoke,
1339
+ invoke: invoke$1,
1171
1340
  set: set$3
1172
1341
  } = create(3211);
1173
1342
 
1174
1343
  const {
1344
+ invoke,
1175
1345
  invokeAndTransfer,
1176
1346
  set: set$2
1177
1347
  } = create(RendererWorker);
@@ -1179,6 +1349,9 @@ const sendMessagePortToDialogWorker = async port => {
1179
1349
  const command = 'HandleMessagePort.handleMessagePort';
1180
1350
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1181
1351
  };
1352
+ const getPreference = async key => {
1353
+ return await invoke('Preferences.get', key);
1354
+ };
1182
1355
 
1183
1356
  const terminate = () => {
1184
1357
  globalThis.close();
@@ -1269,7 +1442,7 @@ const getOffscreenCanvas = async (uid, width, height) => {
1269
1442
  id,
1270
1443
  promise
1271
1444
  } = registerCallback();
1272
- await invoke('Preview.createOffscreenCanvas', uid, id, width, height);
1445
+ await invoke$1('Preview.createOffscreenCanvas', uid, id, width, height);
1273
1446
  const [offscreenCanvas, canvasId] = await promise;
1274
1447
  return {
1275
1448
  canvasId,
@@ -1280,68 +1453,13 @@ const getOffscreenCanvas = async (uid, width, height) => {
1280
1453
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
1281
1454
 
1282
1455
  const states$2 = new Map();
1283
- const get = uid => {
1456
+ const get$1 = uid => {
1284
1457
  return states$2.get(uid);
1285
1458
  };
1286
1459
  const set$1 = (uid, instance) => {
1287
1460
  states$2.set(uid, instance);
1288
1461
  };
1289
1462
 
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
-
1345
1463
  const mergeClassNames = (...classNames) => {
1346
1464
  return classNames.filter(Boolean).join(' ');
1347
1465
  };
@@ -1354,6 +1472,8 @@ const text = data => {
1354
1472
  };
1355
1473
  };
1356
1474
 
1475
+ new Set(Object.values(VirtualDomElements));
1476
+
1357
1477
  const Body = 'Body';
1358
1478
 
1359
1479
  const Div = 'div';
@@ -1407,6 +1527,17 @@ const Iframe = 'iframe';
1407
1527
  const Del = 'del';
1408
1528
  const H6 = 'h6';
1409
1529
  const Canvas = 'canvas';
1530
+ const Circle = 'circle';
1531
+ const Defs = 'defs';
1532
+ const Ellipse = 'ellipse';
1533
+ const G = 'g';
1534
+ const Line = 'line';
1535
+ const Path = 'path';
1536
+ const Polygon = 'polygon';
1537
+ const Polyline = 'polyline';
1538
+ const Rect = 'rect';
1539
+ const Svg = 'svg';
1540
+ const Use = 'use';
1410
1541
 
1411
1542
  const tagMap = {
1412
1543
  [A]: A$1,
@@ -1416,18 +1547,22 @@ const tagMap = {
1416
1547
  [Br]: Br$1,
1417
1548
  [Button]: Button$1,
1418
1549
  [Canvas]: Canvas$1,
1550
+ [Circle]: Circle$1,
1419
1551
  [Cite]: Cite$1,
1420
1552
  [Code]: Code$1,
1421
1553
  [Data]: Data$1,
1422
1554
  [Dd]: Dd$1,
1555
+ [Defs]: Defs$1,
1423
1556
  [Del]: Del$1,
1424
1557
  [Div]: Div$1,
1425
1558
  [Dl]: Dl$1,
1426
1559
  [Dt]: Dt$1,
1560
+ [Ellipse]: Ellipse$1,
1427
1561
  [Figcaption]: Figcaption$1,
1428
1562
  [Figure]: Figure$1,
1429
1563
  [Footer]: Footer$1,
1430
1564
  [Form]: Div$1,
1565
+ [G]: G$1,
1431
1566
  [H1]: H1$1,
1432
1567
  [H2]: H2$1,
1433
1568
  [H3]: H3$1,
@@ -1441,15 +1576,21 @@ const tagMap = {
1441
1576
  [Input]: Input$1,
1442
1577
  [Label]: Label$1,
1443
1578
  [Li]: Li$1,
1579
+ [Line]: Line$1,
1444
1580
  [Nav]: Nav$1,
1445
1581
  [Ol]: Ol$1,
1446
1582
  [Option]: Option$1,
1447
1583
  [P]: P$1,
1584
+ [Path]: Path$1,
1585
+ [Polygon]: Polygon$1,
1586
+ [Polyline]: Polyline$1,
1448
1587
  [Pre]: Pre$1,
1588
+ [Rect]: Rect$1,
1449
1589
  [Search]: Search$1,
1450
1590
  [Section]: Section$1,
1451
1591
  [Select]: Select$1,
1452
1592
  [Span]: Span$1,
1593
+ [Svg]: Svg$1,
1453
1594
  [Table]: Table$1,
1454
1595
  [TBody]: TBody$1,
1455
1596
  [Td]: Td$1,
@@ -1460,6 +1601,7 @@ const tagMap = {
1460
1601
  [Time]: Time$1,
1461
1602
  [Tr]: Tr$1,
1462
1603
  [Ul]: Ul$1,
1604
+ [Use]: Use$1,
1463
1605
  html: Html,
1464
1606
  style: Style
1465
1607
  };
@@ -1488,6 +1630,7 @@ const commonAllowedAttributes = new Set([
1488
1630
  'reversed', 'start',
1489
1631
  // Other semantic attributes
1490
1632
  'open', 'datetime', 'cite', 'for', 'label']);
1633
+ const svgAllowedAttributes = new Set(['cx', 'cy', 'd', 'fill', 'fill-opacity', 'fill-rule', 'offset', 'opacity', 'points', 'preserveAspectRatio', 'r', 'rx', 'ry', 'stop-color', 'stop-opacity', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-opacity', 'stroke-width', 'transform', 'vector-effect', 'viewBox', 'x', 'x1', 'x2', 'y', 'y1', 'y2']);
1491
1634
  const isDefaultAllowedAttribute = (attributeName, defaultAllowedAttributes) => {
1492
1635
  // Allow data-* attributes
1493
1636
  if (attributeName.startsWith('data-')) {
@@ -1501,6 +1644,9 @@ const isDefaultAllowedAttribute = (attributeName, defaultAllowedAttributes) => {
1501
1644
  if (commonAllowedAttributes.has(attributeName)) {
1502
1645
  return true;
1503
1646
  }
1647
+ if (svgAllowedAttributes.has(attributeName)) {
1648
+ return true;
1649
+ }
1504
1650
  // Check if in default list
1505
1651
  return defaultAllowedAttributes.includes(attributeName);
1506
1652
  };
@@ -1684,7 +1830,7 @@ const serialize = (document, elementMap = Object.create(null)) => {
1684
1830
  };
1685
1831
 
1686
1832
  const getSerializedDom = uid => {
1687
- const item = get(uid);
1833
+ const item = get$1(uid);
1688
1834
  if (!item) {
1689
1835
  throw new Error(`No HappyDom instance found for uid ${uid}`);
1690
1836
  }
@@ -1729,7 +1875,7 @@ const dispatchChangeEvent = (element, window) => {
1729
1875
  };
1730
1876
 
1731
1877
  const handleChangeLocal = (uid, hdId, value) => {
1732
- const happyDomInstance = get(uid);
1878
+ const happyDomInstance = get$1(uid);
1733
1879
  if (!happyDomInstance) {
1734
1880
  return;
1735
1881
  }
@@ -1760,7 +1906,7 @@ const dispatchClickEvent = (element, window, clientX = 0, clientY = 0) => {
1760
1906
  };
1761
1907
 
1762
1908
  const handleClickLocal = (uid, hdId, clientX, clientY, x, y) => {
1763
- const happyDomInstance = get(uid);
1909
+ const happyDomInstance = get$1(uid);
1764
1910
  if (!happyDomInstance) {
1765
1911
  return;
1766
1912
  }
@@ -1786,7 +1932,7 @@ const dispatchContextmenuEvent = (element, window, clientX = 0, clientY = 0) =>
1786
1932
  };
1787
1933
 
1788
1934
  const handleContextmenuLocal = (uid, hdId, clientX, clientY, x, y) => {
1789
- const happyDomInstance = get(uid);
1935
+ const happyDomInstance = get$1(uid);
1790
1936
  if (!happyDomInstance) {
1791
1937
  return;
1792
1938
  }
@@ -1808,7 +1954,7 @@ const dispatchInputEvent = (element, window) => {
1808
1954
  };
1809
1955
 
1810
1956
  const handleInputLocal = (uid, hdId, value) => {
1811
- const happyDomInstance = get(uid);
1957
+ const happyDomInstance = get$1(uid);
1812
1958
  if (!happyDomInstance) {
1813
1959
  return;
1814
1960
  }
@@ -1966,7 +2112,7 @@ const dispatchKeydownEvent = (element, window, key, code) => {
1966
2112
  };
1967
2113
 
1968
2114
  const handleKeydownLocal = (uid, hdId, key, code) => {
1969
- const happyDomInstance = get(uid);
2115
+ const happyDomInstance = get$1(uid);
1970
2116
  if (!happyDomInstance) {
1971
2117
  return;
1972
2118
  }
@@ -2013,7 +2159,7 @@ const dispatchKeyupEvent = (element, window, key, code) => {
2013
2159
  };
2014
2160
 
2015
2161
  const handleKeyupLocal = (uid, hdId, key, code) => {
2016
- const happyDomInstance = get(uid);
2162
+ const happyDomInstance = get$1(uid);
2017
2163
  if (!happyDomInstance) {
2018
2164
  return;
2019
2165
  }
@@ -2051,7 +2197,7 @@ const dispatchMousedownEvent = (element, window, clientX = 0, clientY = 0) => {
2051
2197
  };
2052
2198
 
2053
2199
  const handleMousedownLocal = (uid, hdId, clientX, clientY) => {
2054
- const happyDomInstance = get(uid);
2200
+ const happyDomInstance = get$1(uid);
2055
2201
  if (!happyDomInstance) {
2056
2202
  return;
2057
2203
  }
@@ -2075,7 +2221,7 @@ const dispatchMouseleaveEvent = (element, window, clientX = 0, clientY = 0) => {
2075
2221
  };
2076
2222
 
2077
2223
  const handleMouseleaveLocal = (uid, hdId, clientX, clientY, x, y) => {
2078
- const happyDomInstance = get(uid);
2224
+ const happyDomInstance = get$1(uid);
2079
2225
  if (!happyDomInstance) {
2080
2226
  return;
2081
2227
  }
@@ -2101,7 +2247,7 @@ const dispatchMousemoveEvent = (element, window, clientX = 0, clientY = 0) => {
2101
2247
  };
2102
2248
 
2103
2249
  const handleMousemoveLocal = (uid, hdId, clientX, clientY, x, y) => {
2104
- const happyDomInstance = get(uid);
2250
+ const happyDomInstance = get$1(uid);
2105
2251
  if (!happyDomInstance) {
2106
2252
  return;
2107
2253
  }
@@ -2127,7 +2273,7 @@ const dispatchMouseoutEvent = (element, window, clientX = 0, clientY = 0) => {
2127
2273
  };
2128
2274
 
2129
2275
  const handleMouseoutLocal = (uid, hdId, clientX, clientY, x, y) => {
2130
- const happyDomInstance = get(uid);
2276
+ const happyDomInstance = get$1(uid);
2131
2277
  if (!happyDomInstance) {
2132
2278
  return;
2133
2279
  }
@@ -2151,7 +2297,7 @@ const dispatchMouseoverEvent = (element, window, clientX = 0, clientY = 0) => {
2151
2297
  };
2152
2298
 
2153
2299
  const handleMouseoverLocal = (uid, hdId, clientX, clientY, x, y) => {
2154
- const happyDomInstance = get(uid);
2300
+ const happyDomInstance = get$1(uid);
2155
2301
  if (!happyDomInstance) {
2156
2302
  return;
2157
2303
  }
@@ -2175,7 +2321,7 @@ const dispatchMouseupEvent = (element, window, clientX = 0, clientY = 0) => {
2175
2321
  };
2176
2322
 
2177
2323
  const handleMouseupLocal = (uid, hdId, clientX, clientY) => {
2178
- const happyDomInstance = get(uid);
2324
+ const happyDomInstance = get$1(uid);
2179
2325
  if (!happyDomInstance) {
2180
2326
  return;
2181
2327
  }
@@ -2206,7 +2352,7 @@ const dispatchPointerdownEvent = (element, window, clientX = 0, clientY = 0) =>
2206
2352
  };
2207
2353
 
2208
2354
  const handlePointerdownLocal = (uid, hdId, clientX, clientY, x, y) => {
2209
- const happyDomInstance = get(uid);
2355
+ const happyDomInstance = get$1(uid);
2210
2356
  if (!happyDomInstance) {
2211
2357
  return;
2212
2358
  }
@@ -2237,7 +2383,7 @@ const dispatchPointermoveEvent = (element, window, clientX = 0, clientY = 0) =>
2237
2383
  };
2238
2384
 
2239
2385
  const handlePointermoveLocal = (uid, hdId, clientX, clientY, x, y) => {
2240
- const happyDomInstance = get(uid);
2386
+ const happyDomInstance = get$1(uid);
2241
2387
  if (!happyDomInstance) {
2242
2388
  return;
2243
2389
  }
@@ -2268,7 +2414,7 @@ const dispatchPointeroutEvent = (element, window, clientX = 0, clientY = 0) => {
2268
2414
  };
2269
2415
 
2270
2416
  const handlePointeroutLocal = (uid, hdId, clientX, clientY, x, y) => {
2271
- const happyDomInstance = get(uid);
2417
+ const happyDomInstance = get$1(uid);
2272
2418
  if (!happyDomInstance) {
2273
2419
  return;
2274
2420
  }
@@ -2299,7 +2445,7 @@ const dispatchPointeroverEvent = (element, window, clientX = 0, clientY = 0) =>
2299
2445
  };
2300
2446
 
2301
2447
  const handlePointeroverLocal = (uid, hdId, clientX, clientY, x, y) => {
2302
- const happyDomInstance = get(uid);
2448
+ const happyDomInstance = get$1(uid);
2303
2449
  if (!happyDomInstance) {
2304
2450
  return;
2305
2451
  }
@@ -2330,7 +2476,7 @@ const dispatchPointerupEvent = (element, window, clientX = 0, clientY = 0) => {
2330
2476
  };
2331
2477
 
2332
2478
  const handlePointerupLocal = (uid, hdId, clientX, clientY, x, y) => {
2333
- const happyDomInstance = get(uid);
2479
+ const happyDomInstance = get$1(uid);
2334
2480
  if (!happyDomInstance) {
2335
2481
  return;
2336
2482
  }
@@ -2344,6 +2490,32 @@ const handlePointerup = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
2344
2490
  return handlePointerupLocal(uid, hdId, clientX, clientY, x, y);
2345
2491
  };
2346
2492
 
2493
+ const get = async key => {
2494
+ return getPreference(key);
2495
+ };
2496
+
2497
+ const errorUids = new Set();
2498
+ const workerConsole$1 = globalThis.console;
2499
+ const isClearableError = error => {
2500
+ return error.name === 'ReferenceError' || error.name === 'SyntaxError';
2501
+ };
2502
+ const handle = async (uid, error) => {
2503
+ const hadClearableError = errorUids.delete(uid);
2504
+ if (error) {
2505
+ if (isClearableError(error)) {
2506
+ errorUids.add(uid);
2507
+ }
2508
+ return;
2509
+ }
2510
+ if (!hadClearableError) {
2511
+ return;
2512
+ }
2513
+ const enabled = await get('preview.clearConsoleOnErrorResolved');
2514
+ if (enabled === true) {
2515
+ workerConsole$1.clear();
2516
+ }
2517
+ };
2518
+
2347
2519
  function getDefaultExportFromCjs (x) {
2348
2520
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2349
2521
  }
@@ -90015,7 +90187,7 @@ const getErrorCodeFrame = (scriptContent, error, contextLines = 2) => {
90015
90187
  };
90016
90188
 
90017
90189
  const alert = message => {
90018
- void invoke$1('ConfirmPrompt.prompt', message);
90190
+ void invoke$2('ConfirmPrompt.prompt', message);
90019
90191
  };
90020
90192
 
90021
90193
  const createLocalStorage = () => {
@@ -90448,7 +90620,7 @@ const isInternalMutation = records => {
90448
90620
  return records.length > 0 && records.every(record => record.type === 'attributes' && record.attributeName === 'data-id');
90449
90621
  };
90450
90622
  const handleMutations = async uid => {
90451
- const happyDomInstance = get(uid);
90623
+ const happyDomInstance = get$1(uid);
90452
90624
  if (!happyDomInstance) {
90453
90625
  return;
90454
90626
  }
@@ -90461,7 +90633,7 @@ const handleMutations = async uid => {
90461
90633
  });
90462
90634
  getParsedNodesChildNodeCount(serialized.dom);
90463
90635
  try {
90464
- await invoke('Preview.handleMutation', uid);
90636
+ await invoke$1('Preview.handleMutation', uid);
90465
90637
  } catch (error) {
90466
90638
  console.error(error);
90467
90639
  // ignore
@@ -90806,13 +90978,14 @@ const loadContent = async (uid, width, height, content, scripts) => {
90806
90978
  if (error) {
90807
90979
  console.warn(`preview error: ${error} ${codeFrame}`);
90808
90980
  }
90981
+ await handle(uid, error);
90809
90982
  return {
90810
90983
  errorMessage
90811
90984
  };
90812
90985
  };
90813
90986
 
90814
90987
  const resize = (uid, dimensions) => {
90815
- const happyDomInstance = get(uid);
90988
+ const happyDomInstance = get$1(uid);
90816
90989
  if (!happyDomInstance) {
90817
90990
  return;
90818
90991
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/preview-sandbox-worker",
3
- "version": "4.11.1",
3
+ "version": "4.12.0",
4
4
  "description": "Preview SandBox Worker",
5
5
  "repository": {
6
6
  "type": "git",
package/settings.json ADDED
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "category": "preview",
4
+ "description": "Controls whether the developer console is cleared after a preview syntax or reference error is resolved.",
5
+ "heading": "Clear Console On Error Resolved",
6
+ "id": "preview.clearConsoleOnErrorResolved",
7
+ "type": 3,
8
+ "value": false
9
+ }
10
+ ]