@lvce-editor/preview-sandbox-worker 1.7.0 → 1.8.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.
@@ -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.set(node.__canvasId + '', node);
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.set(hdId, node)
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 = new Map()) => {
1511
+ const serialize = (document, elementMap = Object.create(null)) => {
1512
1512
  const dom = [];
1513
1513
  const css = [];
1514
1514
  const context = {
@@ -1594,7 +1594,7 @@ const handleClickLocal = (uid, hdId, clientX, clientY) => {
1594
1594
  return;
1595
1595
  }
1596
1596
  dispatchClickEvent(element, happyDomInstance.window, clientX, clientY);
1597
- const elementMap = new Map();
1597
+ const elementMap = Object.create(null);
1598
1598
  set$1(uid, {
1599
1599
  document: happyDomInstance.document,
1600
1600
  elementMap,
@@ -1623,7 +1623,7 @@ const handleInputLocal = (uid, hdId, value) => {
1623
1623
  }
1624
1624
  element.value = value;
1625
1625
  dispatchInputEvent(element, happyDomInstance.window);
1626
- const elementMap = new Map();
1626
+ const elementMap = Object.create(null);
1627
1627
  set$1(uid, {
1628
1628
  document: happyDomInstance.document,
1629
1629
  elementMap,
@@ -1653,7 +1653,7 @@ const handleKeydownLocal = (uid, hdId, key, code) => {
1653
1653
  return;
1654
1654
  }
1655
1655
  dispatchKeydownEvent(element, happyDomInstance.window, key, code);
1656
- const elementMap = new Map();
1656
+ const elementMap = Object.create(null);
1657
1657
  set$1(uid, {
1658
1658
  document: happyDomInstance.document,
1659
1659
  elementMap,
@@ -1683,7 +1683,7 @@ const handleKeyupLocal = (uid, hdId, key, code) => {
1683
1683
  return;
1684
1684
  }
1685
1685
  dispatchKeyupEvent(element, happyDomInstance.window, key, code);
1686
- const elementMap = new Map();
1686
+ const elementMap = Object.create(null);
1687
1687
  set$1(uid, {
1688
1688
  document: happyDomInstance.document,
1689
1689
  elementMap,
@@ -1721,7 +1721,7 @@ const handleMousedownLocal = (uid, hdId, clientX, clientY) => {
1721
1721
  return;
1722
1722
  }
1723
1723
  dispatchMousedownEvent(element, happyDomInstance.window, clientX, clientY);
1724
- const elementMap = new Map();
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,
@@ -1753,7 +1755,7 @@ const handleMousemoveLocal = (uid, hdId, clientX, clientY, x, y) => {
1753
1755
  const adjustedClientX = clientX - x;
1754
1756
  const adjustedClientY = clientY - y;
1755
1757
  dispatchMousemoveEvent(element, happyDomInstance.window, adjustedClientX, adjustedClientY);
1756
- const elementMap = new Map();
1758
+ const elementMap = Object.create(null);
1757
1759
  set$1(uid, {
1758
1760
  document: happyDomInstance.document,
1759
1761
  elementMap,
@@ -1783,7 +1785,7 @@ const handleMouseupLocal = (uid, hdId, clientX, clientY) => {
1783
1785
  return;
1784
1786
  }
1785
1787
  dispatchMouseupEvent(element, happyDomInstance.window, clientX, clientY);
1786
- const elementMap = new Map();
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: 'https://localhost:3000'
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 = new Map();
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 = new Map();
89815
+ const elementMap = Object.create(null);
89816
89816
  set$1(uid, {
89817
89817
  document: happyDomDocument,
89818
89818
  elementMap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/preview-sandbox-worker",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Preview SandBox Worker",
5
5
  "repository": {
6
6
  "type": "git",