@plattar/plattar-ar-adapter 1.167.6 → 1.167.9
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.
- package/build/es2015/plattar-ar-adapter.js +108 -51
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +102 -46
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/embed/controllers/configurator-controller.d.ts +0 -1
- package/dist/embed/controllers/configurator-controller.js +0 -9
- package/dist/embed/controllers/plattar-controller.d.ts +6 -1
- package/dist/embed/controllers/plattar-controller.js +27 -0
- package/dist/embed/controllers/product-controller.d.ts +0 -1
- package/dist/embed/controllers/product-controller.js +0 -8
- package/dist/embed/controllers/vto-controller.d.ts +0 -1
- package/dist/embed/controllers/vto-controller.js +0 -9
- package/dist/embed/plattar-embed.d.ts +1 -0
- package/dist/embed/plattar-embed.js +34 -12
- package/dist/util/util.d.ts +1 -0
- package/dist/util/util.js +24 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -7
|
@@ -293,15 +293,6 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
293
293
|
const configAR = new configurator_ar_1.ConfiguratorAR({ state: await this.getConfiguratorState(), useARBanner: this.getBooleanAttribute("show-ar-banner") });
|
|
294
294
|
return configAR.init();
|
|
295
295
|
}
|
|
296
|
-
removeRenderer() {
|
|
297
|
-
if (this._element) {
|
|
298
|
-
this._element.remove();
|
|
299
|
-
this._element = null;
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
this.removeMessengerObservers();
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
296
|
get element() {
|
|
306
297
|
return this._element;
|
|
307
298
|
}
|
|
@@ -75,7 +75,7 @@ export declare abstract class PlattarController {
|
|
|
75
75
|
/**
|
|
76
76
|
* Removes the currently active renderer view from the DOM
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
removeRenderer(): boolean;
|
|
79
79
|
/**
|
|
80
80
|
* Get the underlying renderer component (if any)
|
|
81
81
|
*/
|
|
@@ -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
|
}
|
|
@@ -201,6 +201,23 @@ class PlattarController {
|
|
|
201
201
|
};
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Removes the currently active renderer view from the DOM
|
|
206
|
+
*/
|
|
207
|
+
removeRenderer() {
|
|
208
|
+
// remove all other children
|
|
209
|
+
const shadow = this.parent.shadowRoot;
|
|
210
|
+
if (shadow) {
|
|
211
|
+
let child = shadow.lastElementChild;
|
|
212
|
+
while (child) {
|
|
213
|
+
shadow.removeChild(child);
|
|
214
|
+
child = shadow.lastElementChild;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this._element = null;
|
|
218
|
+
this.removeMessengerObservers();
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
204
221
|
/**
|
|
205
222
|
* Returns the Parent Instance
|
|
206
223
|
*/
|
|
@@ -252,5 +269,15 @@ class PlattarController {
|
|
|
252
269
|
const shadow = this.parent.shadowRoot || this.parent.attachShadow({ mode: 'open' });
|
|
253
270
|
shadow.append(element);
|
|
254
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
*
|
|
274
|
+
* @param element
|
|
275
|
+
*/
|
|
276
|
+
removeChild(element) {
|
|
277
|
+
const shadow = this.parent.shadowRoot;
|
|
278
|
+
if (shadow) {
|
|
279
|
+
shadow.removeChild(element);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
255
282
|
}
|
|
256
283
|
exports.PlattarController = PlattarController;
|
|
@@ -19,6 +19,5 @@ export declare class ProductController extends PlattarController {
|
|
|
19
19
|
startARQRCode(options: any): Promise<HTMLElement>;
|
|
20
20
|
startRenderer(): Promise<HTMLElement>;
|
|
21
21
|
initAR(): Promise<LauncherAR>;
|
|
22
|
-
removeRenderer(): boolean;
|
|
23
22
|
get element(): HTMLElement | null;
|
|
24
23
|
}
|
|
@@ -217,14 +217,6 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
217
217
|
return reject(new Error("ProductController.initAR() - minimum required attributes not set, use product-id as a minimum"));
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
-
removeRenderer() {
|
|
221
|
-
if (this._element) {
|
|
222
|
-
this._element.remove();
|
|
223
|
-
this._element = null;
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
220
|
get element() {
|
|
229
221
|
return this._element;
|
|
230
222
|
}
|
|
@@ -231,15 +231,6 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
231
231
|
const configAR = new configurator_ar_1.ConfiguratorAR({ state: await this.getConfiguratorState(), useARBanner: this.getBooleanAttribute("show-ar-banner") });
|
|
232
232
|
return configAR.init();
|
|
233
233
|
}
|
|
234
|
-
removeRenderer() {
|
|
235
|
-
if (this._element) {
|
|
236
|
-
this._element.remove();
|
|
237
|
-
this._element = null;
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
this.removeMessengerObservers();
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
234
|
get element() {
|
|
244
235
|
return this._element;
|
|
245
236
|
}
|
|
@@ -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
|
*/
|
|
@@ -34,6 +35,7 @@ class PlattarEmbed extends HTMLElement {
|
|
|
34
35
|
this._observerState = ObserverState.Unlocked;
|
|
35
36
|
this._controller = null;
|
|
36
37
|
this._currentSceneID = null;
|
|
38
|
+
this._currentServer = null;
|
|
37
39
|
this._observer = null;
|
|
38
40
|
}
|
|
39
41
|
get viewer() {
|
|
@@ -49,9 +51,6 @@ class PlattarEmbed extends HTMLElement {
|
|
|
49
51
|
* creates a brand new instance of this embed
|
|
50
52
|
*/
|
|
51
53
|
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
54
|
if (!this._observer) {
|
|
56
55
|
this._observer = new MutationObserver((mutations) => {
|
|
57
56
|
if (this._observerState === ObserverState.Unlocked) {
|
|
@@ -108,15 +107,23 @@ class PlattarEmbed extends HTMLElement {
|
|
|
108
107
|
* embedding products with variations (without a scene-id)
|
|
109
108
|
*/
|
|
110
109
|
_CreateLegacyEmbed() {
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
// server cannot be changed once its set - defaults to production
|
|
111
|
+
const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
|
|
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");
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
/**
|
|
@@ -124,6 +131,21 @@ class PlattarEmbed extends HTMLElement {
|
|
|
124
131
|
* this can also be called when attributes/state changes so embeds can be re-loaded
|
|
125
132
|
*/
|
|
126
133
|
_CreateEmbed(attributeName) {
|
|
134
|
+
// check if controller needs to be destroyed due to server change
|
|
135
|
+
const serverAttribute = this.hasAttribute("server") ? this.getAttribute("server") : "production";
|
|
136
|
+
if (this._currentServer !== serverAttribute) {
|
|
137
|
+
this._currentServer = serverAttribute || "production";
|
|
138
|
+
// reset the controller if any
|
|
139
|
+
if (this._controller) {
|
|
140
|
+
this._controller.removeRenderer();
|
|
141
|
+
this._controller = null;
|
|
142
|
+
}
|
|
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
|
+
}
|
|
148
|
+
plattar_api_1.Server.create(plattar_api_1.Server.match(this._currentServer || "production"));
|
|
127
149
|
const embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "configurator";
|
|
128
150
|
const currentEmbed = this._currentType;
|
|
129
151
|
if (embedType) {
|
package/dist/util/util.d.ts
CHANGED
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.
|
|
1
|
+
declare const _default: "1.167.9";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plattar/plattar-ar-adapter",
|
|
3
|
-
"version": "1.167.
|
|
3
|
+
"version": "1.167.9",
|
|
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.
|
|
42
|
+
"@plattar/plattar-qrcode": "1.165.1",
|
|
43
43
|
"@plattar/plattar-services": "^1.157.1",
|
|
44
|
-
"@plattar/plattar-web": "^1.
|
|
44
|
+
"@plattar/plattar-web": "^1.165.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/cli": "^7.23.
|
|
48
|
-
"@babel/core": "^7.23.
|
|
49
|
-
"@babel/preset-env": "^7.23.
|
|
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.
|
|
51
|
+
"typescript": "^5.3.3",
|
|
52
52
|
"uglify-js": "^3.17.4"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|