@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.
@@ -173,6 +173,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
173
173
  }
174
174
  // optional attributes
175
175
  let configState = null;
176
+ this._state = plattar_controller_1.ControllerState.Renderer;
176
177
  try {
177
178
  const dState = await this.getConfiguratorState();
178
179
  // if this is declared, we have a furniture scene that we need to re-create the embed
@@ -217,7 +218,6 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
217
218
  if (showUI) {
218
219
  viewer.setAttribute("show-ui", showUI);
219
220
  }
220
- this._state = plattar_controller_1.ControllerState.Renderer;
221
221
  return new Promise((accept, reject) => {
222
222
  this.append(viewer);
223
223
  if (configState) {
@@ -266,7 +266,18 @@ class PlattarController {
266
266
  * @param element - The element to append
267
267
  */
268
268
  append(element) {
269
+ if (this._element !== element) {
270
+ return;
271
+ }
272
+ // ensure append only allows a single element in the shadow DOM
269
273
  const shadow = this.parent.shadowRoot || this.parent.attachShadow({ mode: 'open' });
274
+ if (shadow) {
275
+ let child = shadow.lastElementChild;
276
+ while (child) {
277
+ shadow.removeChild(child);
278
+ child = shadow.lastElementChild;
279
+ }
280
+ }
270
281
  shadow.append(element);
271
282
  }
272
283
  /**
@@ -71,14 +71,15 @@ class ProductController extends plattar_controller_1.PlattarController {
71
71
  dst += "&show_ar=" + showAR;
72
72
  }
73
73
  viewer.setAttribute("url", opt.url || dst);
74
- viewer.onload = () => {
75
- return accept(viewer);
76
- };
77
- this.append(viewer);
78
74
  this._element = viewer;
79
75
  this._state = plattar_controller_1.ControllerState.QRCode;
80
76
  this._prevQROpt = opt;
81
- return;
77
+ return new Promise((accept, reject) => {
78
+ viewer.onload = () => {
79
+ return accept(viewer);
80
+ };
81
+ this.append(viewer);
82
+ });
82
83
  }
83
84
  return reject(new Error("ProductController.startQRCode() - minimum required attributes not set, use product-id as a minimum"));
84
85
  });
@@ -148,13 +149,15 @@ class ProductController extends plattar_controller_1.PlattarController {
148
149
  dst += "&show_ar_banner=" + showBanner;
149
150
  }
150
151
  viewer.setAttribute("url", opt.url || dst);
151
- viewer.onload = () => {
152
- return accept(viewer);
153
- };
154
152
  this._element = viewer;
155
153
  this._state = plattar_controller_1.ControllerState.QRCode;
156
154
  this._prevQROpt = opt;
157
- this.append(viewer);
155
+ return new Promise((accept, reject) => {
156
+ viewer.onload = () => {
157
+ return accept(viewer);
158
+ };
159
+ this.append(viewer);
160
+ });
158
161
  });
159
162
  }
160
163
  startRenderer() {
@@ -185,13 +188,14 @@ class ProductController extends plattar_controller_1.PlattarController {
185
188
  if (showAR) {
186
189
  viewer.setAttribute("show-ar", showAR);
187
190
  }
188
- viewer.onload = () => {
189
- return accept(viewer);
190
- };
191
- this.append(viewer);
192
191
  this._element = viewer;
193
192
  this._state = plattar_controller_1.ControllerState.Renderer;
194
- return;
193
+ return new Promise((accept, reject) => {
194
+ viewer.onload = () => {
195
+ return accept(viewer);
196
+ };
197
+ this.append(viewer);
198
+ });
195
199
  }
196
200
  return reject(new Error("ProductController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
197
201
  });
@@ -136,6 +136,7 @@ class VTOController extends plattar_controller_1.PlattarController {
136
136
  if (!sceneID) {
137
137
  throw new Error("VTOController.startRenderer() - minimum required attributes not set, use scene-id as a minimum");
138
138
  }
139
+ this._state = plattar_controller_1.ControllerState.Renderer;
139
140
  // required attributes with defaults for plattar-facear node
140
141
  const width = this.getAttribute("width") || "500px";
141
142
  const height = this.getAttribute("height") || "500px";
@@ -174,7 +175,6 @@ class VTOController extends plattar_controller_1.PlattarController {
174
175
  if (variationID) {
175
176
  viewer.setAttribute("variation-id", variationID);
176
177
  }
177
- this._state = plattar_controller_1.ControllerState.Renderer;
178
178
  return new Promise((accept, reject) => {
179
179
  this.append(viewer);
180
180
  if (configState) {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.167.11";
1
+ declare const _default: "1.167.13";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = "1.167.11";
3
+ exports.default = "1.167.13";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.167.11",
3
+ "version": "1.167.13",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",