@plattar/plattar-ar-adapter 1.167.11 → 1.167.13

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.
@@ -1143,6 +1143,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
1143
1143
  }
1144
1144
  // optional attributes
1145
1145
  let configState = null;
1146
+ this._state = plattar_controller_1.ControllerState.Renderer;
1146
1147
  try {
1147
1148
  const dState = await this.getConfiguratorState();
1148
1149
  // if this is declared, we have a furniture scene that we need to re-create the embed
@@ -1187,7 +1188,6 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
1187
1188
  if (showUI) {
1188
1189
  viewer.setAttribute("show-ui", showUI);
1189
1190
  }
1190
- this._state = plattar_controller_1.ControllerState.Renderer;
1191
1191
  return new Promise((accept, reject) => {
1192
1192
  this.append(viewer);
1193
1193
  if (configState) {
@@ -1538,7 +1538,18 @@ class PlattarController {
1538
1538
  * @param element - The element to append
1539
1539
  */
1540
1540
  append(element) {
1541
+ if (this._element !== element) {
1542
+ return;
1543
+ }
1544
+ // ensure append only allows a single element in the shadow DOM
1541
1545
  const shadow = this.parent.shadowRoot || this.parent.attachShadow({ mode: 'open' });
1546
+ if (shadow) {
1547
+ let child = shadow.lastElementChild;
1548
+ while (child) {
1549
+ shadow.removeChild(child);
1550
+ child = shadow.lastElementChild;
1551
+ }
1552
+ }
1542
1553
  shadow.append(element);
1543
1554
  }
1544
1555
  /**
@@ -1628,14 +1639,15 @@ class ProductController extends plattar_controller_1.PlattarController {
1628
1639
  dst += "&show_ar=" + showAR;
1629
1640
  }
1630
1641
  viewer.setAttribute("url", opt.url || dst);
1631
- viewer.onload = () => {
1632
- return accept(viewer);
1633
- };
1634
- this.append(viewer);
1635
1642
  this._element = viewer;
1636
1643
  this._state = plattar_controller_1.ControllerState.QRCode;
1637
1644
  this._prevQROpt = opt;
1638
- return;
1645
+ return new Promise((accept, reject) => {
1646
+ viewer.onload = () => {
1647
+ return accept(viewer);
1648
+ };
1649
+ this.append(viewer);
1650
+ });
1639
1651
  }
1640
1652
  return reject(new Error("ProductController.startQRCode() - minimum required attributes not set, use product-id as a minimum"));
1641
1653
  });
@@ -1705,13 +1717,15 @@ class ProductController extends plattar_controller_1.PlattarController {
1705
1717
  dst += "&show_ar_banner=" + showBanner;
1706
1718
  }
1707
1719
  viewer.setAttribute("url", opt.url || dst);
1708
- viewer.onload = () => {
1709
- return accept(viewer);
1710
- };
1711
1720
  this._element = viewer;
1712
1721
  this._state = plattar_controller_1.ControllerState.QRCode;
1713
1722
  this._prevQROpt = opt;
1714
- this.append(viewer);
1723
+ return new Promise((accept, reject) => {
1724
+ viewer.onload = () => {
1725
+ return accept(viewer);
1726
+ };
1727
+ this.append(viewer);
1728
+ });
1715
1729
  });
1716
1730
  }
1717
1731
  startRenderer() {
@@ -1742,13 +1756,14 @@ class ProductController extends plattar_controller_1.PlattarController {
1742
1756
  if (showAR) {
1743
1757
  viewer.setAttribute("show-ar", showAR);
1744
1758
  }
1745
- viewer.onload = () => {
1746
- return accept(viewer);
1747
- };
1748
- this.append(viewer);
1749
1759
  this._element = viewer;
1750
1760
  this._state = plattar_controller_1.ControllerState.Renderer;
1751
- return;
1761
+ return new Promise((accept, reject) => {
1762
+ viewer.onload = () => {
1763
+ return accept(viewer);
1764
+ };
1765
+ this.append(viewer);
1766
+ });
1752
1767
  }
1753
1768
  return reject(new Error("ProductController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
1754
1769
  });
@@ -1919,6 +1934,7 @@ class VTOController extends plattar_controller_1.PlattarController {
1919
1934
  if (!sceneID) {
1920
1935
  throw new Error("VTOController.startRenderer() - minimum required attributes not set, use scene-id as a minimum");
1921
1936
  }
1937
+ this._state = plattar_controller_1.ControllerState.Renderer;
1922
1938
  // required attributes with defaults for plattar-facear node
1923
1939
  const width = this.getAttribute("width") || "500px";
1924
1940
  const height = this.getAttribute("height") || "500px";
@@ -1957,7 +1973,6 @@ class VTOController extends plattar_controller_1.PlattarController {
1957
1973
  if (variationID) {
1958
1974
  viewer.setAttribute("variation-id", variationID);
1959
1975
  }
1960
- this._state = plattar_controller_1.ControllerState.Renderer;
1961
1976
  return new Promise((accept, reject) => {
1962
1977
  this.append(viewer);
1963
1978
  if (configState) {
@@ -2866,7 +2881,7 @@ exports.Util = Util;
2866
2881
  },{}],16:[function(require,module,exports){
2867
2882
  "use strict";
2868
2883
  Object.defineProperty(exports, "__esModule", { value: true });
2869
- exports.default = "1.167.11";
2884
+ exports.default = "1.167.13";
2870
2885
 
2871
2886
  },{}],17:[function(require,module,exports){
2872
2887
  "use strict";