@plattar/plattar-ar-adapter 1.167.2 → 1.167.3

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.
@@ -295,7 +295,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
295
295
  }
296
296
  removeRenderer() {
297
297
  if (this._element) {
298
- this._element.remove();
298
+ this.removeChild(this._element);
299
299
  this._element = null;
300
300
  return true;
301
301
  }
@@ -114,4 +114,9 @@ export declare abstract class PlattarController {
114
114
  * @param element - The element to append
115
115
  */
116
116
  append(element: HTMLElement): void;
117
+ /**
118
+ *
119
+ * @param element
120
+ */
121
+ removeChild(element: HTMLElement): void;
117
122
  }
@@ -252,5 +252,15 @@ class PlattarController {
252
252
  const shadow = this.parent.shadowRoot || this.parent.attachShadow({ mode: 'open' });
253
253
  shadow.append(element);
254
254
  }
255
+ /**
256
+ *
257
+ * @param element
258
+ */
259
+ removeChild(element) {
260
+ const shadow = this.parent.shadowRoot;
261
+ if (shadow) {
262
+ shadow.removeChild(element);
263
+ }
264
+ }
255
265
  }
256
266
  exports.PlattarController = PlattarController;
@@ -219,7 +219,7 @@ class ProductController extends plattar_controller_1.PlattarController {
219
219
  }
220
220
  removeRenderer() {
221
221
  if (this._element) {
222
- this._element.remove();
222
+ this.removeChild(this._element);
223
223
  this._element = null;
224
224
  return true;
225
225
  }
@@ -233,7 +233,7 @@ class VTOController extends plattar_controller_1.PlattarController {
233
233
  }
234
234
  removeRenderer() {
235
235
  if (this._element) {
236
- this._element.remove();
236
+ this.removeChild(this._element);
237
237
  this._element = null;
238
238
  return true;
239
239
  }
@@ -9,6 +9,7 @@ export default class PlattarEmbed extends HTMLElement {
9
9
  private _observerState;
10
10
  private _controller;
11
11
  private _currentSceneID;
12
+ private _currentServer;
12
13
  private _observer;
13
14
  constructor();
14
15
  get viewer(): HTMLElement | null;
@@ -34,6 +34,7 @@ class PlattarEmbed extends HTMLElement {
34
34
  this._observerState = ObserverState.Unlocked;
35
35
  this._controller = null;
36
36
  this._currentSceneID = null;
37
+ this._currentServer = null;
37
38
  this._observer = null;
38
39
  }
39
40
  get viewer() {
@@ -49,9 +50,6 @@ class PlattarEmbed extends HTMLElement {
49
50
  * creates a brand new instance of this embed
50
51
  */
51
52
  create() {
52
- // server cannot be changed once its set - defaults to production
53
- const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
54
- plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
55
53
  if (!this._observer) {
56
54
  this._observer = new MutationObserver((mutations) => {
57
55
  if (this._observerState === ObserverState.Unlocked) {
@@ -108,6 +106,9 @@ class PlattarEmbed extends HTMLElement {
108
106
  * embedding products with variations (without a scene-id)
109
107
  */
110
108
  _CreateLegacyEmbed() {
109
+ // server cannot be changed once its set - defaults to production
110
+ const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
111
+ plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
111
112
  this._controller = new product_controller_1.ProductController(this);
112
113
  const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
113
114
  switch (init) {
@@ -124,6 +125,17 @@ class PlattarEmbed extends HTMLElement {
124
125
  * this can also be called when attributes/state changes so embeds can be re-loaded
125
126
  */
126
127
  _CreateEmbed(attributeName) {
128
+ // check if controller needs to be destroyed due to server change
129
+ const serverAttribute = this.hasAttribute("server") ? this.getAttribute("server") : "production";
130
+ if (this._currentServer !== serverAttribute) {
131
+ this._currentSceneID = serverAttribute || "production";
132
+ // reset the controller if any
133
+ if (this._controller) {
134
+ this._controller.removeRenderer();
135
+ this._controller = null;
136
+ }
137
+ }
138
+ plattar_api_1.Server.create(plattar_api_1.Server.match(this._currentServer || "production"));
127
139
  const embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "configurator";
128
140
  const currentEmbed = this._currentType;
129
141
  if (embedType) {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.167.2";
1
+ declare const _default: "1.167.3";
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.2";
3
+ exports.default = "1.167.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.167.2",
3
+ "version": "1.167.3",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -39,16 +39,16 @@
39
39
  "dependencies": {
40
40
  "@plattar/plattar-analytics": "^1.152.2",
41
41
  "@plattar/plattar-api": "^1.159.1",
42
- "@plattar/plattar-qrcode": "1.160.1",
42
+ "@plattar/plattar-qrcode": "1.165.1",
43
43
  "@plattar/plattar-services": "^1.157.1",
44
- "@plattar/plattar-web": "^1.154.3"
44
+ "@plattar/plattar-web": "^1.165.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/cli": "^7.23.4",
48
- "@babel/core": "^7.23.3",
49
- "@babel/preset-env": "^7.23.3",
47
+ "@babel/cli": "^7.23.9",
48
+ "@babel/core": "^7.23.9",
49
+ "@babel/preset-env": "^7.23.9",
50
50
  "browserify": "^17.0.0",
51
- "typescript": "^5.3.2",
51
+ "typescript": "^5.3.3",
52
52
  "uglify-js": "^3.17.4"
53
53
  },
54
54
  "publishConfig": {