@lvce-editor/preview-sandbox-worker 1.7.0 → 1.9.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 +23 -23
- package/package.json +1 -1
|
@@ -1454,7 +1454,7 @@ const serializeNode = (node, dom, css, context) => {
|
|
|
1454
1454
|
uid: node.__canvasId
|
|
1455
1455
|
};
|
|
1456
1456
|
if (context.elementMap) {
|
|
1457
|
-
context.elementMap
|
|
1457
|
+
context.elementMap[node.__canvasId + ''] = node;
|
|
1458
1458
|
}
|
|
1459
1459
|
dom.push(refNode);
|
|
1460
1460
|
return 1;
|
|
@@ -1489,7 +1489,7 @@ const serializeNode = (node, dom, css, context) => {
|
|
|
1489
1489
|
// Assign element tracking ID for interactivity
|
|
1490
1490
|
const hdId = String(context.nextId++);
|
|
1491
1491
|
newNode['data-id'] = hdId;
|
|
1492
|
-
context.elementMap
|
|
1492
|
+
context.elementMap[hdId] = node
|
|
1493
1493
|
|
|
1494
1494
|
// Reserve position in dom array for this node
|
|
1495
1495
|
;
|
|
@@ -1508,7 +1508,7 @@ const serializeNode = (node, dom, css, context) => {
|
|
|
1508
1508
|
};
|
|
1509
1509
|
|
|
1510
1510
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1511
|
-
const serialize = (document, elementMap =
|
|
1511
|
+
const serialize = (document, elementMap = Object.create(null)) => {
|
|
1512
1512
|
const dom = [];
|
|
1513
1513
|
const css = [];
|
|
1514
1514
|
const context = {
|
|
@@ -1589,12 +1589,12 @@ const handleClickLocal = (uid, hdId, clientX, clientY) => {
|
|
|
1589
1589
|
if (!happyDomInstance) {
|
|
1590
1590
|
return;
|
|
1591
1591
|
}
|
|
1592
|
-
const element = happyDomInstance.elementMap
|
|
1592
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1593
1593
|
if (!element) {
|
|
1594
1594
|
return;
|
|
1595
1595
|
}
|
|
1596
1596
|
dispatchClickEvent(element, happyDomInstance.window, clientX, clientY);
|
|
1597
|
-
const elementMap =
|
|
1597
|
+
const elementMap = Object.create(null);
|
|
1598
1598
|
set$1(uid, {
|
|
1599
1599
|
document: happyDomInstance.document,
|
|
1600
1600
|
elementMap,
|
|
@@ -1617,13 +1617,13 @@ const handleInputLocal = (uid, hdId, value) => {
|
|
|
1617
1617
|
if (!happyDomInstance) {
|
|
1618
1618
|
return;
|
|
1619
1619
|
}
|
|
1620
|
-
const element = happyDomInstance.elementMap
|
|
1620
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1621
1621
|
if (!element) {
|
|
1622
1622
|
return;
|
|
1623
1623
|
}
|
|
1624
1624
|
element.value = value;
|
|
1625
1625
|
dispatchInputEvent(element, happyDomInstance.window);
|
|
1626
|
-
const elementMap =
|
|
1626
|
+
const elementMap = Object.create(null);
|
|
1627
1627
|
set$1(uid, {
|
|
1628
1628
|
document: happyDomInstance.document,
|
|
1629
1629
|
elementMap,
|
|
@@ -1648,12 +1648,12 @@ const handleKeydownLocal = (uid, hdId, key, code) => {
|
|
|
1648
1648
|
if (!happyDomInstance) {
|
|
1649
1649
|
return;
|
|
1650
1650
|
}
|
|
1651
|
-
const element = hdId ? happyDomInstance.elementMap
|
|
1651
|
+
const element = hdId ? happyDomInstance.elementMap[hdId] : happyDomInstance.document;
|
|
1652
1652
|
if (!element) {
|
|
1653
1653
|
return;
|
|
1654
1654
|
}
|
|
1655
1655
|
dispatchKeydownEvent(element, happyDomInstance.window, key, code);
|
|
1656
|
-
const elementMap =
|
|
1656
|
+
const elementMap = Object.create(null);
|
|
1657
1657
|
set$1(uid, {
|
|
1658
1658
|
document: happyDomInstance.document,
|
|
1659
1659
|
elementMap,
|
|
@@ -1678,12 +1678,12 @@ const handleKeyupLocal = (uid, hdId, key, code) => {
|
|
|
1678
1678
|
if (!happyDomInstance) {
|
|
1679
1679
|
return;
|
|
1680
1680
|
}
|
|
1681
|
-
const element = hdId ? happyDomInstance.elementMap
|
|
1681
|
+
const element = hdId ? happyDomInstance.elementMap[hdId] : happyDomInstance.document;
|
|
1682
1682
|
if (!element) {
|
|
1683
1683
|
return;
|
|
1684
1684
|
}
|
|
1685
1685
|
dispatchKeyupEvent(element, happyDomInstance.window, key, code);
|
|
1686
|
-
const elementMap =
|
|
1686
|
+
const elementMap = Object.create(null);
|
|
1687
1687
|
set$1(uid, {
|
|
1688
1688
|
document: happyDomInstance.document,
|
|
1689
1689
|
elementMap,
|
|
@@ -1716,12 +1716,12 @@ const handleMousedownLocal = (uid, hdId, clientX, clientY) => {
|
|
|
1716
1716
|
if (!happyDomInstance) {
|
|
1717
1717
|
return;
|
|
1718
1718
|
}
|
|
1719
|
-
const element = happyDomInstance.elementMap
|
|
1719
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1720
1720
|
if (!element) {
|
|
1721
1721
|
return;
|
|
1722
1722
|
}
|
|
1723
1723
|
dispatchMousedownEvent(element, happyDomInstance.window, clientX, clientY);
|
|
1724
|
-
const elementMap =
|
|
1724
|
+
const elementMap = Object.create(null);
|
|
1725
1725
|
set$1(uid, {
|
|
1726
1726
|
document: happyDomInstance.document,
|
|
1727
1727
|
elementMap,
|
|
@@ -1732,6 +1732,8 @@ const handleMousedown = (uid, hdId, clientX, clientY) => {
|
|
|
1732
1732
|
return handleMousedownLocal(uid, hdId, clientX, clientY);
|
|
1733
1733
|
};
|
|
1734
1734
|
|
|
1735
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
1736
|
+
|
|
1735
1737
|
const dispatchMousemoveEvent = (element, window, clientX = 0, clientY = 0) => {
|
|
1736
1738
|
const mousemoveEvent = new window.MouseEvent('mousemove', {
|
|
1737
1739
|
bubbles: true,
|
|
@@ -1746,14 +1748,14 @@ const handleMousemoveLocal = (uid, hdId, clientX, clientY, x, y) => {
|
|
|
1746
1748
|
if (!happyDomInstance) {
|
|
1747
1749
|
return;
|
|
1748
1750
|
}
|
|
1749
|
-
const element = happyDomInstance.elementMap
|
|
1751
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1750
1752
|
if (!element) {
|
|
1751
1753
|
return;
|
|
1752
1754
|
}
|
|
1753
1755
|
const adjustedClientX = clientX - x;
|
|
1754
1756
|
const adjustedClientY = clientY - y;
|
|
1755
1757
|
dispatchMousemoveEvent(element, happyDomInstance.window, adjustedClientX, adjustedClientY);
|
|
1756
|
-
const elementMap =
|
|
1758
|
+
const elementMap = Object.create(null);
|
|
1757
1759
|
set$1(uid, {
|
|
1758
1760
|
document: happyDomInstance.document,
|
|
1759
1761
|
elementMap,
|
|
@@ -1778,12 +1780,12 @@ const handleMouseupLocal = (uid, hdId, clientX, clientY) => {
|
|
|
1778
1780
|
if (!happyDomInstance) {
|
|
1779
1781
|
return;
|
|
1780
1782
|
}
|
|
1781
|
-
const element = happyDomInstance.elementMap
|
|
1783
|
+
const element = happyDomInstance.elementMap[hdId];
|
|
1782
1784
|
if (!element) {
|
|
1783
1785
|
return;
|
|
1784
1786
|
}
|
|
1785
1787
|
dispatchMouseupEvent(element, happyDomInstance.window, clientX, clientY);
|
|
1786
|
-
const elementMap =
|
|
1788
|
+
const elementMap = Object.create(null);
|
|
1787
1789
|
set$1(uid, {
|
|
1788
1790
|
document: happyDomInstance.document,
|
|
1789
1791
|
elementMap,
|
|
@@ -89359,15 +89361,13 @@ class Window extends BrowserWindow {
|
|
|
89359
89361
|
}
|
|
89360
89362
|
}
|
|
89361
89363
|
|
|
89362
|
-
const createWindow = rawHtml => {
|
|
89364
|
+
const createWindow = (rawHtml, url = 'http://localhost:3000') => {
|
|
89363
89365
|
const window = new Window({
|
|
89364
|
-
url
|
|
89366
|
+
url
|
|
89365
89367
|
});
|
|
89366
89368
|
const {
|
|
89367
89369
|
document
|
|
89368
89370
|
} = window;
|
|
89369
|
-
|
|
89370
|
-
// Parse the raw HTML into the happy-dom document
|
|
89371
89371
|
document.documentElement.innerHTML = rawHtml;
|
|
89372
89372
|
return {
|
|
89373
89373
|
document,
|
|
@@ -89669,7 +89669,7 @@ const handleMutations = async uid => {
|
|
|
89669
89669
|
if (!happyDomInstance) {
|
|
89670
89670
|
return;
|
|
89671
89671
|
}
|
|
89672
|
-
const elementMap =
|
|
89672
|
+
const elementMap = Object.create(null);
|
|
89673
89673
|
const serialized = serialize(happyDomInstance.document, elementMap);
|
|
89674
89674
|
set$1(uid, {
|
|
89675
89675
|
document: happyDomInstance.document,
|
|
@@ -89812,7 +89812,7 @@ const updateContent = async (uid, width, height, content, scripts) => {
|
|
|
89812
89812
|
codeFrame,
|
|
89813
89813
|
error
|
|
89814
89814
|
} = executeScripts(happyDomWindow, happyDomDocument, scripts, width, height);
|
|
89815
|
-
const elementMap =
|
|
89815
|
+
const elementMap = Object.create(null);
|
|
89816
89816
|
set$1(uid, {
|
|
89817
89817
|
document: happyDomDocument,
|
|
89818
89818
|
elementMap,
|