@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.
@@ -1265,7 +1265,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
1265
1265
  }
1266
1266
  removeRenderer() {
1267
1267
  if (this._element) {
1268
- this._element.remove();
1268
+ this.removeChild(this._element);
1269
1269
  this._element = null;
1270
1270
  return true;
1271
1271
  }
@@ -1533,6 +1533,16 @@ class PlattarController {
1533
1533
  const shadow = this.parent.shadowRoot || this.parent.attachShadow({ mode: 'open' });
1534
1534
  shadow.append(element);
1535
1535
  }
1536
+ /**
1537
+ *
1538
+ * @param element
1539
+ */
1540
+ removeChild(element) {
1541
+ const shadow = this.parent.shadowRoot;
1542
+ if (shadow) {
1543
+ shadow.removeChild(element);
1544
+ }
1545
+ }
1536
1546
  }
1537
1547
  exports.PlattarController = PlattarController;
1538
1548
 
@@ -1758,7 +1768,7 @@ class ProductController extends plattar_controller_1.PlattarController {
1758
1768
  }
1759
1769
  removeRenderer() {
1760
1770
  if (this._element) {
1761
- this._element.remove();
1771
+ this.removeChild(this._element);
1762
1772
  this._element = null;
1763
1773
  return true;
1764
1774
  }
@@ -2006,7 +2016,7 @@ class VTOController extends plattar_controller_1.PlattarController {
2006
2016
  }
2007
2017
  removeRenderer() {
2008
2018
  if (this._element) {
2009
- this._element.remove();
2019
+ this.removeChild(this._element);
2010
2020
  this._element = null;
2011
2021
  return true;
2012
2022
  }
@@ -2056,6 +2066,7 @@ class PlattarEmbed extends HTMLElement {
2056
2066
  this._observerState = ObserverState.Unlocked;
2057
2067
  this._controller = null;
2058
2068
  this._currentSceneID = null;
2069
+ this._currentServer = null;
2059
2070
  this._observer = null;
2060
2071
  }
2061
2072
  get viewer() {
@@ -2071,9 +2082,6 @@ class PlattarEmbed extends HTMLElement {
2071
2082
  * creates a brand new instance of this embed
2072
2083
  */
2073
2084
  create() {
2074
- // server cannot be changed once its set - defaults to production
2075
- const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
2076
- plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
2077
2085
  if (!this._observer) {
2078
2086
  this._observer = new MutationObserver((mutations) => {
2079
2087
  if (this._observerState === ObserverState.Unlocked) {
@@ -2130,6 +2138,9 @@ class PlattarEmbed extends HTMLElement {
2130
2138
  * embedding products with variations (without a scene-id)
2131
2139
  */
2132
2140
  _CreateLegacyEmbed() {
2141
+ // server cannot be changed once its set - defaults to production
2142
+ const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
2143
+ plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
2133
2144
  this._controller = new product_controller_1.ProductController(this);
2134
2145
  const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
2135
2146
  switch (init) {
@@ -2146,6 +2157,17 @@ class PlattarEmbed extends HTMLElement {
2146
2157
  * this can also be called when attributes/state changes so embeds can be re-loaded
2147
2158
  */
2148
2159
  _CreateEmbed(attributeName) {
2160
+ // check if controller needs to be destroyed due to server change
2161
+ const serverAttribute = this.hasAttribute("server") ? this.getAttribute("server") : "production";
2162
+ if (this._currentServer !== serverAttribute) {
2163
+ this._currentSceneID = serverAttribute || "production";
2164
+ // reset the controller if any
2165
+ if (this._controller) {
2166
+ this._controller.removeRenderer();
2167
+ this._controller = null;
2168
+ }
2169
+ }
2170
+ plattar_api_1.Server.create(plattar_api_1.Server.match(this._currentServer || "production"));
2149
2171
  const embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "configurator";
2150
2172
  const currentEmbed = this._currentType;
2151
2173
  if (embedType) {
@@ -2819,7 +2841,7 @@ exports.Util = Util;
2819
2841
  },{}],16:[function(require,module,exports){
2820
2842
  "use strict";
2821
2843
  Object.defineProperty(exports, "__esModule", { value: true });
2822
- exports.default = "1.167.2";
2844
+ exports.default = "1.167.3";
2823
2845
 
2824
2846
  },{}],17:[function(require,module,exports){
2825
2847
  "use strict";
@@ -6770,11 +6792,21 @@ class BaseElement extends HTMLElement {
6770
6792
 
6771
6793
  if (shortenURL && shortenURL.toLowerCase() === "true") {
6772
6794
  this._ShortenURL(url).then((newURL) => {
6773
- this._GenerateQRCode(newURL, width, height);
6795
+ // make sure by time promise is resolved that the original url hasn't been updated
6796
+ const updatedURL = this.hasAttribute("url") ? this.getAttribute("url") : undefined;
6797
+
6798
+ if (updatedURL === url) {
6799
+ this._GenerateQRCode(newURL, width, height);
6800
+ }
6774
6801
  }).catch((_err) => {
6775
6802
  console.warn(_err);
6776
6803
  // ignore error and just generate normal QR Code
6777
- this._GenerateQRCode(url, width, height);
6804
+ // make sure by time promise is resolved that the original url hasn't been updated
6805
+ const updatedURL = this.hasAttribute("url") ? this.getAttribute("url") : undefined;
6806
+
6807
+ if (updatedURL === url) {
6808
+ this._GenerateQRCode(url, width, height);
6809
+ }
6778
6810
  });
6779
6811
  }
6780
6812
  else {
@@ -6924,7 +6956,7 @@ module.exports = {
6924
6956
  version: Version
6925
6957
  };
6926
6958
  },{"./elements/qrcode-element.js":109,"./version":111}],111:[function(require,module,exports){
6927
- module.exports = "1.160.1";
6959
+ module.exports = "1.165.1";
6928
6960
 
6929
6961
  },{}],112:[function(require,module,exports){
6930
6962
  "use strict";
@@ -8022,9 +8054,8 @@ class Util {
8022
8054
 
8023
8055
  module.exports = Util;
8024
8056
  },{}],131:[function(require,module,exports){
8025
- module.exports = "1.165.1";
8026
-
8027
- },{}],132:[function(require,module,exports){
8057
+ arguments[4][111][0].apply(exports,arguments)
8058
+ },{"dup":111}],132:[function(require,module,exports){
8028
8059
  (function (global){(function (){
8029
8060
  "use strict";
8030
8061