@plattar/plattar-ar-adapter 1.167.5 → 1.167.7

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.
@@ -4,6 +4,7 @@ const plattar_api_1 = require("@plattar/plattar-api");
4
4
  const configurator_controller_1 = require("./controllers/configurator-controller");
5
5
  const vto_controller_1 = require("./controllers/vto-controller");
6
6
  const product_controller_1 = require("./controllers/product-controller");
7
+ const util_1 = require("../util/util");
7
8
  /**
8
9
  * This tracks the current embed type
9
10
  */
@@ -108,16 +109,21 @@ class PlattarEmbed extends HTMLElement {
108
109
  _CreateLegacyEmbed() {
109
110
  // server cannot be changed once its set - defaults to production
110
111
  const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
111
- plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
112
- this._controller = new product_controller_1.ProductController(this);
113
- const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
114
- switch (init) {
115
- case "viewer":
116
- this.startViewer();
117
- break;
118
- case "qrcode":
119
- this.startQRCode();
120
- break;
112
+ if (util_1.Util.isValidServerLocation(server)) {
113
+ plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
114
+ this._controller = new product_controller_1.ProductController(this);
115
+ const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
116
+ switch (init) {
117
+ case "viewer":
118
+ this.startViewer();
119
+ break;
120
+ case "qrcode":
121
+ this.startQRCode();
122
+ break;
123
+ }
124
+ }
125
+ else {
126
+ console.warn("PlattarEmbed.CreateLegacy - cannot create as server attribute " + server + " is invalid, embed status remains unchanged");
121
127
  }
122
128
  }
123
129
  /**
@@ -128,13 +134,17 @@ class PlattarEmbed extends HTMLElement {
128
134
  // check if controller needs to be destroyed due to server change
129
135
  const serverAttribute = this.hasAttribute("server") ? this.getAttribute("server") : "production";
130
136
  if (this._currentServer !== serverAttribute) {
131
- this._currentSceneID = serverAttribute || "production";
137
+ this._currentServer = serverAttribute || "production";
132
138
  // reset the controller if any
133
139
  if (this._controller) {
134
140
  this._controller.removeRenderer();
135
141
  this._controller = null;
136
142
  }
137
143
  }
144
+ if (!util_1.Util.isValidServerLocation(this._currentServer)) {
145
+ console.warn("PlattarEmbed.Create - cannot create as server attribute " + this._currentServer + " is invalid, embed status remains unchanged");
146
+ return;
147
+ }
138
148
  plattar_api_1.Server.create(plattar_api_1.Server.match(this._currentServer || "production"));
139
149
  const embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "configurator";
140
150
  const currentEmbed = this._currentType;
@@ -2,6 +2,7 @@
2
2
  * Static Utility Functions
3
3
  */
4
4
  export declare class Util {
5
+ static isValidServerLocation(server: string | null | undefined): boolean;
5
6
  static canAugment(): boolean;
6
7
  static canQuicklook(): boolean;
7
8
  static canSceneViewer(): boolean;
package/dist/util/util.js CHANGED
@@ -5,6 +5,30 @@ exports.Util = void 0;
5
5
  * Static Utility Functions
6
6
  */
7
7
  class Util {
8
+ static isValidServerLocation(server) {
9
+ if (!server) {
10
+ return false;
11
+ }
12
+ switch (server.toLowerCase()) {
13
+ case "staging.plattar.space":
14
+ case "cdn-staging.plattar.space":
15
+ case "staging":
16
+ case "app.plattar.com":
17
+ case "cdn.plattar.com":
18
+ case "prod":
19
+ case "production":
20
+ case "review.plattar.com":
21
+ case "review":
22
+ case "qa":
23
+ case "dev":
24
+ case "developer":
25
+ case "development":
26
+ case "local":
27
+ case "localhost":
28
+ return true;
29
+ }
30
+ return false;
31
+ }
8
32
  static canAugment() {
9
33
  return Util.canQuicklook() || Util.canSceneViewer();
10
34
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.167.5";
1
+ declare const _default: "1.167.7";
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.5";
3
+ exports.default = "1.167.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.167.5",
3
+ "version": "1.167.7",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",