@lvce-editor/preview-sandbox-worker 2.3.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 +392 -122
- 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 */
|
|
@@ -1583,7 +1529,7 @@ const dispatchClickEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
|
1583
1529
|
dispatchEvent(element, clickEvent);
|
|
1584
1530
|
};
|
|
1585
1531
|
|
|
1586
|
-
const handleClickLocal = (uid, hdId, clientX, clientY) => {
|
|
1532
|
+
const handleClickLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1587
1533
|
const happyDomInstance = get(uid);
|
|
1588
1534
|
if (!happyDomInstance) {
|
|
1589
1535
|
return;
|
|
@@ -1592,16 +1538,36 @@ const handleClickLocal = (uid, hdId, clientX, clientY) => {
|
|
|
1592
1538
|
if (!element) {
|
|
1593
1539
|
return;
|
|
1594
1540
|
}
|
|
1595
|
-
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1541
|
+
const adjustedClientX = clientX - x;
|
|
1542
|
+
const adjustedClientY = clientY - y;
|
|
1543
|
+
dispatchClickEvent(element, happyDomInstance.window, adjustedClientX, adjustedClientY);
|
|
1544
|
+
};
|
|
1545
|
+
const handleClick = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1546
|
+
return handleClickLocal(uid, hdId, clientX, clientY, x, y);
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1549
|
+
const dispatchContextmenuEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1550
|
+
const contextmenuEvent = new window.MouseEvent('contextmenu', {
|
|
1551
|
+
bubbles: true,
|
|
1552
|
+
clientX,
|
|
1553
|
+
clientY
|
|
1601
1554
|
});
|
|
1555
|
+
dispatchEvent(element, contextmenuEvent);
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
const handleContextmenuLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1559
|
+
const happyDomInstance = get(uid);
|
|
1560
|
+
if (!happyDomInstance) {
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1564
|
+
if (!element) {
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
dispatchContextmenuEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1602
1568
|
};
|
|
1603
|
-
const
|
|
1604
|
-
return
|
|
1569
|
+
const handleContextmenu = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1570
|
+
return handleContextmenuLocal(uid, hdId, clientX, clientY, x, y);
|
|
1605
1571
|
};
|
|
1606
1572
|
|
|
1607
1573
|
const dispatchInputEvent = (element, window) => {
|
|
@@ -1725,6 +1691,30 @@ const handleMousedown = (uid, hdId, clientX, clientY) => {
|
|
|
1725
1691
|
return handleMousedownLocal(uid, hdId, clientX, clientY);
|
|
1726
1692
|
};
|
|
1727
1693
|
|
|
1694
|
+
const dispatchMouseleaveEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1695
|
+
const mouseleaveEvent = new window.MouseEvent('mouseleave', {
|
|
1696
|
+
bubbles: false,
|
|
1697
|
+
clientX,
|
|
1698
|
+
clientY
|
|
1699
|
+
});
|
|
1700
|
+
dispatchEvent(element, mouseleaveEvent);
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
const handleMouseleaveLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1704
|
+
const happyDomInstance = get(uid);
|
|
1705
|
+
if (!happyDomInstance) {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1709
|
+
if (!element) {
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
dispatchMouseleaveEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1713
|
+
};
|
|
1714
|
+
const handleMouseleave = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1715
|
+
return handleMouseleaveLocal(uid, hdId, clientX, clientY, x, y);
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1728
1718
|
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
1729
1719
|
|
|
1730
1720
|
const dispatchMousemoveEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
@@ -1753,6 +1743,54 @@ const handleMousemove = (uid, hdId, clientX, clientY, x, y) => {
|
|
|
1753
1743
|
return handleMousemoveLocal(uid, hdId, clientX, clientY, x, y);
|
|
1754
1744
|
};
|
|
1755
1745
|
|
|
1746
|
+
const dispatchMouseoutEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1747
|
+
const mouseoutEvent = new window.MouseEvent('mouseout', {
|
|
1748
|
+
bubbles: true,
|
|
1749
|
+
clientX,
|
|
1750
|
+
clientY
|
|
1751
|
+
});
|
|
1752
|
+
dispatchEvent(element, mouseoutEvent);
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
const handleMouseoutLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1756
|
+
const happyDomInstance = get(uid);
|
|
1757
|
+
if (!happyDomInstance) {
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1761
|
+
if (!element) {
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
dispatchMouseoutEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1765
|
+
};
|
|
1766
|
+
const handleMouseout = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1767
|
+
return handleMouseoutLocal(uid, hdId, clientX, clientY, x, y);
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1770
|
+
const dispatchMouseoverEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1771
|
+
const mouseoverEvent = new window.MouseEvent('mouseover', {
|
|
1772
|
+
bubbles: true,
|
|
1773
|
+
clientX,
|
|
1774
|
+
clientY
|
|
1775
|
+
});
|
|
1776
|
+
dispatchEvent(element, mouseoverEvent);
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
const handleMouseoverLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1780
|
+
const happyDomInstance = get(uid);
|
|
1781
|
+
if (!happyDomInstance) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1785
|
+
if (!element) {
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
dispatchMouseoverEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1789
|
+
};
|
|
1790
|
+
const handleMouseover = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1791
|
+
return handleMouseoverLocal(uid, hdId, clientX, clientY, x, y);
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1756
1794
|
const dispatchMouseupEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1757
1795
|
const mouseupEvent = new window.MouseEvent('mouseup', {
|
|
1758
1796
|
bubbles: true,
|
|
@@ -1777,6 +1815,161 @@ const handleMouseup = (uid, hdId, clientX, clientY) => {
|
|
|
1777
1815
|
return handleMouseupLocal(uid, hdId, clientX, clientY);
|
|
1778
1816
|
};
|
|
1779
1817
|
|
|
1818
|
+
const getPointerEventConstructor$4 = window => {
|
|
1819
|
+
return window.PointerEvent || window.MouseEvent;
|
|
1820
|
+
};
|
|
1821
|
+
const dispatchPointerdownEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1822
|
+
const PointerEventConstructor = getPointerEventConstructor$4(window);
|
|
1823
|
+
const pointerdownEvent = new PointerEventConstructor('pointerdown', {
|
|
1824
|
+
bubbles: true,
|
|
1825
|
+
clientX,
|
|
1826
|
+
clientY,
|
|
1827
|
+
isPrimary: true,
|
|
1828
|
+
pointerId: 1,
|
|
1829
|
+
pointerType: 'mouse'
|
|
1830
|
+
});
|
|
1831
|
+
dispatchEvent(element, pointerdownEvent);
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
const handlePointerdownLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1835
|
+
const happyDomInstance = get(uid);
|
|
1836
|
+
if (!happyDomInstance) {
|
|
1837
|
+
return;
|
|
1838
|
+
}
|
|
1839
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1840
|
+
if (!element) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
dispatchPointerdownEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1844
|
+
};
|
|
1845
|
+
const handlePointerdown = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1846
|
+
return handlePointerdownLocal(uid, hdId, clientX, clientY, x, y);
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1849
|
+
const getPointerEventConstructor$3 = window => {
|
|
1850
|
+
return window.PointerEvent || window.MouseEvent;
|
|
1851
|
+
};
|
|
1852
|
+
const dispatchPointermoveEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1853
|
+
const PointerEventConstructor = getPointerEventConstructor$3(window);
|
|
1854
|
+
const pointermoveEvent = new PointerEventConstructor('pointermove', {
|
|
1855
|
+
bubbles: true,
|
|
1856
|
+
clientX,
|
|
1857
|
+
clientY,
|
|
1858
|
+
isPrimary: true,
|
|
1859
|
+
pointerId: 1,
|
|
1860
|
+
pointerType: 'mouse'
|
|
1861
|
+
});
|
|
1862
|
+
dispatchEvent(element, pointermoveEvent);
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
const handlePointermoveLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1866
|
+
const happyDomInstance = get(uid);
|
|
1867
|
+
if (!happyDomInstance) {
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1871
|
+
if (!element) {
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
dispatchPointermoveEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1875
|
+
};
|
|
1876
|
+
const handlePointermove = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1877
|
+
return handlePointermoveLocal(uid, hdId, clientX, clientY, x, y);
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
const getPointerEventConstructor$2 = window => {
|
|
1881
|
+
return window.PointerEvent || window.MouseEvent;
|
|
1882
|
+
};
|
|
1883
|
+
const dispatchPointeroutEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1884
|
+
const PointerEventConstructor = getPointerEventConstructor$2(window);
|
|
1885
|
+
const pointeroutEvent = new PointerEventConstructor('pointerout', {
|
|
1886
|
+
bubbles: true,
|
|
1887
|
+
clientX,
|
|
1888
|
+
clientY,
|
|
1889
|
+
isPrimary: true,
|
|
1890
|
+
pointerId: 1,
|
|
1891
|
+
pointerType: 'mouse'
|
|
1892
|
+
});
|
|
1893
|
+
dispatchEvent(element, pointeroutEvent);
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
const handlePointeroutLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1897
|
+
const happyDomInstance = get(uid);
|
|
1898
|
+
if (!happyDomInstance) {
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1902
|
+
if (!element) {
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
1905
|
+
dispatchPointeroutEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1906
|
+
};
|
|
1907
|
+
const handlePointerout = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1908
|
+
return handlePointeroutLocal(uid, hdId, clientX, clientY, x, y);
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1911
|
+
const getPointerEventConstructor$1 = window => {
|
|
1912
|
+
return window.PointerEvent || window.MouseEvent;
|
|
1913
|
+
};
|
|
1914
|
+
const dispatchPointeroverEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1915
|
+
const PointerEventConstructor = getPointerEventConstructor$1(window);
|
|
1916
|
+
const pointeroverEvent = new PointerEventConstructor('pointerover', {
|
|
1917
|
+
bubbles: true,
|
|
1918
|
+
clientX,
|
|
1919
|
+
clientY,
|
|
1920
|
+
isPrimary: true,
|
|
1921
|
+
pointerId: 1,
|
|
1922
|
+
pointerType: 'mouse'
|
|
1923
|
+
});
|
|
1924
|
+
dispatchEvent(element, pointeroverEvent);
|
|
1925
|
+
};
|
|
1926
|
+
|
|
1927
|
+
const handlePointeroverLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1928
|
+
const happyDomInstance = get(uid);
|
|
1929
|
+
if (!happyDomInstance) {
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1933
|
+
if (!element) {
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
dispatchPointeroverEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1937
|
+
};
|
|
1938
|
+
const handlePointerover = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1939
|
+
return handlePointeroverLocal(uid, hdId, clientX, clientY, x, y);
|
|
1940
|
+
};
|
|
1941
|
+
|
|
1942
|
+
const getPointerEventConstructor = window => {
|
|
1943
|
+
return window.PointerEvent || window.MouseEvent;
|
|
1944
|
+
};
|
|
1945
|
+
const dispatchPointerupEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1946
|
+
const PointerEventConstructor = getPointerEventConstructor(window);
|
|
1947
|
+
const pointerupEvent = new PointerEventConstructor('pointerup', {
|
|
1948
|
+
bubbles: true,
|
|
1949
|
+
clientX,
|
|
1950
|
+
clientY,
|
|
1951
|
+
isPrimary: true,
|
|
1952
|
+
pointerId: 1,
|
|
1953
|
+
pointerType: 'mouse'
|
|
1954
|
+
});
|
|
1955
|
+
dispatchEvent(element, pointerupEvent);
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
const handlePointerupLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
1959
|
+
const happyDomInstance = get(uid);
|
|
1960
|
+
if (!happyDomInstance) {
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1964
|
+
if (!element) {
|
|
1965
|
+
return;
|
|
1966
|
+
}
|
|
1967
|
+
dispatchPointerupEvent(element, happyDomInstance.window, clientX - x, clientY - y);
|
|
1968
|
+
};
|
|
1969
|
+
const handlePointerup = (uid, hdId, clientX = 0, clientY = 0, x = 0, y = 0) => {
|
|
1970
|
+
return handlePointerupLocal(uid, hdId, clientX, clientY, x, y);
|
|
1971
|
+
};
|
|
1972
|
+
|
|
1780
1973
|
function getDefaultExportFromCjs (x) {
|
|
1781
1974
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1782
1975
|
}
|
|
@@ -89356,6 +89549,28 @@ const createWindow = (rawHtml, url = 'http://localhost:3000') => {
|
|
|
89356
89549
|
};
|
|
89357
89550
|
};
|
|
89358
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
|
+
|
|
89359
89574
|
/**
|
|
89360
89575
|
* Extracts line and column information from an error stack trace
|
|
89361
89576
|
* Looks for patterns like "<anonymous>:114:26" in the stack trace
|
|
@@ -89587,6 +89802,7 @@ const setGlobals = (window, globalGlobals, windowGlobals) => {
|
|
|
89587
89802
|
/* eslint-disable @typescript-eslint/no-implied-eval */
|
|
89588
89803
|
|
|
89589
89804
|
const executeScripts = (window, document, scripts, width = 0, height = 0) => {
|
|
89805
|
+
exposeCanvasGlobals(window, document);
|
|
89590
89806
|
const {
|
|
89591
89807
|
globalGlobals,
|
|
89592
89808
|
windowGlobals
|
|
@@ -89657,9 +89873,7 @@ const handleMutations = async uid => {
|
|
|
89657
89873
|
elementMap,
|
|
89658
89874
|
window: happyDomInstance.window
|
|
89659
89875
|
});
|
|
89660
|
-
|
|
89661
|
-
// @ts-ignore
|
|
89662
|
-
getParsedNodesChildNodeCount(parsedDom);
|
|
89876
|
+
getParsedNodesChildNodeCount(serialized.dom);
|
|
89663
89877
|
try {
|
|
89664
89878
|
await invoke$1('Preview.handleMutation', uid);
|
|
89665
89879
|
} catch (error) {
|
|
@@ -89768,6 +89982,52 @@ const patchCanvasElements = async (document, uid) => {
|
|
|
89768
89982
|
element.__offscreenCanvas.height = heightValue;
|
|
89769
89983
|
}
|
|
89770
89984
|
});
|
|
89985
|
+
Object.defineProperty(element, 'clientWidth', {
|
|
89986
|
+
configurable: true,
|
|
89987
|
+
enumerable: true,
|
|
89988
|
+
get: () => widthValue
|
|
89989
|
+
});
|
|
89990
|
+
Object.defineProperty(element, 'clientHeight', {
|
|
89991
|
+
configurable: true,
|
|
89992
|
+
enumerable: true,
|
|
89993
|
+
get: () => heightValue
|
|
89994
|
+
});
|
|
89995
|
+
Object.defineProperty(element, 'offsetWidth', {
|
|
89996
|
+
configurable: true,
|
|
89997
|
+
enumerable: true,
|
|
89998
|
+
get: () => widthValue
|
|
89999
|
+
});
|
|
90000
|
+
Object.defineProperty(element, 'offsetHeight', {
|
|
90001
|
+
configurable: true,
|
|
90002
|
+
enumerable: true,
|
|
90003
|
+
get: () => heightValue
|
|
90004
|
+
});
|
|
90005
|
+
|
|
90006
|
+
// @ts-ignore
|
|
90007
|
+
element.getBoundingClientRect = () => {
|
|
90008
|
+
return {
|
|
90009
|
+
bottom: heightValue,
|
|
90010
|
+
height: heightValue,
|
|
90011
|
+
left: 0,
|
|
90012
|
+
right: widthValue,
|
|
90013
|
+
toJSON: () => {
|
|
90014
|
+
return {
|
|
90015
|
+
bottom: heightValue,
|
|
90016
|
+
height: heightValue,
|
|
90017
|
+
left: 0,
|
|
90018
|
+
right: widthValue,
|
|
90019
|
+
top: 0,
|
|
90020
|
+
width: widthValue,
|
|
90021
|
+
x: 0,
|
|
90022
|
+
y: 0
|
|
90023
|
+
};
|
|
90024
|
+
},
|
|
90025
|
+
top: 0,
|
|
90026
|
+
width: widthValue,
|
|
90027
|
+
x: 0,
|
|
90028
|
+
y: 0
|
|
90029
|
+
};
|
|
90030
|
+
};
|
|
89771
90031
|
instances.push({
|
|
89772
90032
|
dataId,
|
|
89773
90033
|
dimensions,
|
|
@@ -89793,6 +90053,7 @@ const updateContent = async (uid, width, height, content, scripts) => {
|
|
|
89793
90053
|
error
|
|
89794
90054
|
} = executeScripts(happyDomWindow, happyDomDocument, scripts, width, height);
|
|
89795
90055
|
const elementMap = Object.create(null);
|
|
90056
|
+
serialize(happyDomDocument, elementMap);
|
|
89796
90057
|
set$1(uid, {
|
|
89797
90058
|
document: happyDomDocument,
|
|
89798
90059
|
elementMap,
|
|
@@ -89845,13 +90106,22 @@ const commandMap = {
|
|
|
89845
90106
|
'SandBox.executeCallback': executeCallback,
|
|
89846
90107
|
'SandBox.getSerializedDom': getSerializedDom,
|
|
89847
90108
|
'SandBox.handleClick': handleClick,
|
|
90109
|
+
'SandBox.handleContextMenu': handleContextmenu,
|
|
89848
90110
|
'SandBox.handleInput': handleInput,
|
|
89849
90111
|
'SandBox.handleKeyDown': handleKeydown,
|
|
89850
90112
|
'SandBox.handleKeyUp': handleKeyup,
|
|
89851
90113
|
'SandBox.handleMessagePort': handleMessagePort,
|
|
89852
90114
|
'SandBox.handleMousedown': handleMousedown,
|
|
90115
|
+
'SandBox.handleMouseleave': handleMouseleave,
|
|
89853
90116
|
'SandBox.handleMousemove': handleMousemove,
|
|
90117
|
+
'SandBox.handleMouseout': handleMouseout,
|
|
90118
|
+
'SandBox.handleMouseover': handleMouseover,
|
|
89854
90119
|
'SandBox.handleMouseup': handleMouseup,
|
|
90120
|
+
'SandBox.handlePointerdown': handlePointerdown,
|
|
90121
|
+
'SandBox.handlePointermove': handlePointermove,
|
|
90122
|
+
'SandBox.handlePointerout': handlePointerout,
|
|
90123
|
+
'SandBox.handlePointerover': handlePointerover,
|
|
90124
|
+
'SandBox.handlePointerup': handlePointerup,
|
|
89855
90125
|
'SandBox.loadContent': loadContent,
|
|
89856
90126
|
'SandBox.resize': resize,
|
|
89857
90127
|
'SandBox.terminate': terminate
|