@plattar/plattar-ar-adapter 1.122.3 → 1.123.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.
- package/build/es2015/plattar-ar-adapter.js +8643 -5719
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +1587 -459
- package/build/es2019/plattar-ar-adapter.min.js +9 -1
- package/dist/ar/launcher-ar.d.ts +8 -1
- package/dist/ar/launcher-ar.js +12 -0
- package/dist/ar/model-ar.d.ts +0 -5
- package/dist/ar/model-ar.js +1 -12
- package/dist/ar/product-ar.d.ts +1 -6
- package/dist/ar/product-ar.js +3 -14
- package/dist/ar/raw-ar.d.ts +0 -5
- package/dist/ar/raw-ar.js +0 -12
- package/dist/ar/scene-ar.d.ts +21 -1
- package/dist/ar/scene-ar.js +148 -5
- package/dist/embed/controllers/configurator-controller.d.ts +17 -0
- package/dist/embed/controllers/configurator-controller.js +178 -0
- package/dist/embed/controllers/plattar-controller.d.ts +62 -0
- package/dist/embed/controllers/plattar-controller.js +62 -0
- package/dist/embed/controllers/product-controller.d.ts +17 -0
- package/dist/embed/controllers/product-controller.js +133 -0
- package/dist/embed/controllers/viewer-controller.d.ts +17 -0
- package/dist/embed/controllers/viewer-controller.js +147 -0
- package/dist/embed/controllers/vto-controller.d.ts +17 -0
- package/dist/embed/controllers/vto-controller.js +169 -0
- package/dist/embed/plattar-embed.d.ts +8 -10
- package/dist/embed/plattar-embed.js +72 -223
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/util/configurator-state.d.ts +26 -0
- package/dist/util/configurator-state.js +92 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -6
- package/dist/ar/configurator-ar.d.ts +0 -9
- package/dist/ar/configurator-ar.js +0 -19
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const plattar_api_1 = require("@plattar/plattar-api");
|
|
4
|
-
const
|
|
4
|
+
const product_controller_1 = require("./controllers/product-controller");
|
|
5
|
+
const viewer_controller_1 = require("./controllers/viewer-controller");
|
|
6
|
+
const configurator_controller_1 = require("./controllers/configurator-controller");
|
|
7
|
+
const vto_controller_1 = require("./controllers/vto-controller");
|
|
5
8
|
/**
|
|
6
|
-
* This tracks the current
|
|
9
|
+
* This tracks the current embed type
|
|
7
10
|
*/
|
|
8
|
-
var
|
|
9
|
-
(function (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
EmbedState[EmbedState["QRCode"] = 4] = "QRCode";
|
|
15
|
-
})(EmbedState || (EmbedState = {}));
|
|
11
|
+
var EmbedType;
|
|
12
|
+
(function (EmbedType) {
|
|
13
|
+
EmbedType[EmbedType["Viewer"] = 0] = "Viewer";
|
|
14
|
+
EmbedType[EmbedType["Configurator"] = 1] = "Configurator";
|
|
15
|
+
EmbedType[EmbedType["VTO"] = 2] = "VTO";
|
|
16
|
+
})(EmbedType || (EmbedType = {}));
|
|
16
17
|
/**
|
|
17
18
|
* This is the primary <plattar-embed /> node that allows easy embedding
|
|
18
19
|
* of Plattar related content
|
|
@@ -20,49 +21,34 @@ var EmbedState;
|
|
|
20
21
|
class PlattarEmbed extends HTMLElement {
|
|
21
22
|
constructor() {
|
|
22
23
|
super();
|
|
23
|
-
// this is the current
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
color: "#101721",
|
|
27
|
-
qrType: "default",
|
|
28
|
-
margin: 0
|
|
29
|
-
};
|
|
30
|
-
this._sceneID = null;
|
|
31
|
-
this._productID = null;
|
|
32
|
-
this._variationID = null;
|
|
33
|
-
this._isReady = false;
|
|
34
|
-
this._width = "500px";
|
|
35
|
-
this._height = "500px";
|
|
36
|
-
this._server = "production";
|
|
37
|
-
this._viewer = null;
|
|
24
|
+
// this is the current embed type, viewer by default
|
|
25
|
+
this._currentType = EmbedType.Viewer;
|
|
26
|
+
this._controller = null;
|
|
38
27
|
}
|
|
39
28
|
get viewer() {
|
|
40
|
-
return this.
|
|
29
|
+
return this._controller ? this._controller.element : null;
|
|
41
30
|
}
|
|
42
31
|
connectedCallback() {
|
|
32
|
+
const embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "viewer";
|
|
33
|
+
if (embedType) {
|
|
34
|
+
switch (embedType.toLowerCase()) {
|
|
35
|
+
case "viewer":
|
|
36
|
+
this._currentType = EmbedType.Viewer;
|
|
37
|
+
break;
|
|
38
|
+
case "vto":
|
|
39
|
+
this._currentType = EmbedType.VTO;
|
|
40
|
+
break;
|
|
41
|
+
case "configurator":
|
|
42
|
+
this._currentType = EmbedType.Configurator;
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
this._currentType = EmbedType.Viewer;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
43
48
|
const observer = new MutationObserver((mutations) => {
|
|
44
49
|
mutations.forEach((mutation) => {
|
|
45
50
|
if (mutation.type === "attributes") {
|
|
46
|
-
|
|
47
|
-
const productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
|
|
48
|
-
const variationID = this.hasAttribute("variation-id") ? this.getAttribute("variation-id") : null;
|
|
49
|
-
let updated = false;
|
|
50
|
-
if (sceneID !== this._sceneID) {
|
|
51
|
-
this._sceneID = sceneID;
|
|
52
|
-
updated = true;
|
|
53
|
-
}
|
|
54
|
-
if (productID !== this._productID) {
|
|
55
|
-
this._productID = productID;
|
|
56
|
-
updated = true;
|
|
57
|
-
}
|
|
58
|
-
if (variationID !== this._variationID) {
|
|
59
|
-
this._variationID = variationID;
|
|
60
|
-
updated = true;
|
|
61
|
-
}
|
|
62
|
-
if (updated) {
|
|
63
|
-
// re-render based on internal state
|
|
64
|
-
this._OnAttributesUpdated();
|
|
65
|
-
}
|
|
51
|
+
this._OnAttributesUpdated();
|
|
66
52
|
}
|
|
67
53
|
});
|
|
68
54
|
});
|
|
@@ -71,21 +57,24 @@ class PlattarEmbed extends HTMLElement {
|
|
|
71
57
|
});
|
|
72
58
|
const server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
|
|
73
59
|
plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
const sceneID = this.hasAttribute("scene-id") ? this.getAttribute("scene-id") : null;
|
|
61
|
+
const productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
|
|
62
|
+
// decide which controller to initialise
|
|
63
|
+
if (this._currentType === EmbedType.Viewer) {
|
|
64
|
+
// initialise product if scene-id is missing but product-id is defined
|
|
65
|
+
if (!sceneID && productID) {
|
|
66
|
+
this._controller = new product_controller_1.ProductController(this);
|
|
67
|
+
}
|
|
68
|
+
else if (sceneID) {
|
|
69
|
+
this._controller = new viewer_controller_1.ViewerController(this);
|
|
70
|
+
}
|
|
76
71
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this._variationID = this.hasAttribute("variation-id") ? this.getAttribute("variation-id") : null;
|
|
80
|
-
const width = this.hasAttribute("width") ? this.getAttribute("width") : "500px";
|
|
81
|
-
const height = this.hasAttribute("height") ? this.getAttribute("height") : "500px";
|
|
82
|
-
if (width) {
|
|
83
|
-
this._width = width;
|
|
72
|
+
else if (this._currentType === EmbedType.Configurator) {
|
|
73
|
+
this._controller = new configurator_controller_1.ConfiguratorController(this);
|
|
84
74
|
}
|
|
85
|
-
if (
|
|
86
|
-
this.
|
|
75
|
+
else if (this._currentType === EmbedType.VTO) {
|
|
76
|
+
this._controller = new vto_controller_1.VTOController(this);
|
|
87
77
|
}
|
|
88
|
-
this._isReady = true;
|
|
89
78
|
const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
|
|
90
79
|
if (init === "ar") {
|
|
91
80
|
this.startAR();
|
|
@@ -113,194 +102,54 @@ class PlattarEmbed extends HTMLElement {
|
|
|
113
102
|
}
|
|
114
103
|
initAR() {
|
|
115
104
|
return new Promise((accept, reject) => {
|
|
116
|
-
if (!this.
|
|
117
|
-
return reject(new Error("PlattarEmbed.initAR() - cannot execute as
|
|
118
|
-
}
|
|
119
|
-
// if scene is not set but product is, then use ProductAR
|
|
120
|
-
if (!this._sceneID && this._productID) {
|
|
121
|
-
const product = new product_ar_1.ProductAR(this._productID, this._variationID);
|
|
122
|
-
return product.init().then(accept).catch(reject);
|
|
105
|
+
if (!this._controller) {
|
|
106
|
+
return reject(new Error("PlattarEmbed.initAR() - cannot execute as controller has not loaded yet"));
|
|
123
107
|
}
|
|
124
|
-
|
|
125
|
-
// NOTE: At some point this should check for Scenes when SceneAR
|
|
126
|
-
// is implemented
|
|
127
|
-
if (this._productID) {
|
|
128
|
-
const product = new product_ar_1.ProductAR(this._productID, this._variationID);
|
|
129
|
-
return product.init().then(accept).catch(reject);
|
|
130
|
-
}
|
|
131
|
-
// otherwise, scene was set so use SceneAR
|
|
132
|
-
if (this._sceneID) {
|
|
133
|
-
return reject(new Error("PlattarEmbed.initAR() - scene-id not yet supported"));
|
|
134
|
-
}
|
|
135
|
-
return reject(new Error("PlattarEmbed.initAR() - minimum required attributes not set, use scene-id or product-id as a minimum"));
|
|
108
|
+
return this._controller.initAR().then(accept).catch(reject);
|
|
136
109
|
});
|
|
137
110
|
}
|
|
138
111
|
startAR() {
|
|
139
112
|
return new Promise((accept, reject) => {
|
|
140
|
-
if (!this.
|
|
141
|
-
return reject(new Error("PlattarEmbed.startAR() - cannot execute as
|
|
113
|
+
if (!this._controller) {
|
|
114
|
+
return reject(new Error("PlattarEmbed.startAR() - cannot execute as controller has not loaded yet"));
|
|
142
115
|
}
|
|
143
|
-
this.
|
|
144
|
-
launcher.start();
|
|
145
|
-
accept();
|
|
146
|
-
}).catch(reject);
|
|
116
|
+
return this._controller.startAR().then(accept).catch(reject);
|
|
147
117
|
});
|
|
148
118
|
}
|
|
149
119
|
startViewer() {
|
|
150
120
|
return new Promise((accept, reject) => {
|
|
151
|
-
if (!this.
|
|
152
|
-
return reject(new Error("PlattarEmbed.startViewer() - cannot execute as
|
|
121
|
+
if (!this._controller) {
|
|
122
|
+
return reject(new Error("PlattarEmbed.startViewer() - cannot execute as controller has not loaded yet"));
|
|
153
123
|
}
|
|
154
|
-
|
|
155
|
-
this._viewer.remove();
|
|
156
|
-
this._viewer = null;
|
|
157
|
-
}
|
|
158
|
-
// if scene is set, we use <plattar-viewer /> node from plattar-web
|
|
159
|
-
if (this._sceneID) {
|
|
160
|
-
const viewer = document.createElement("plattar-viewer");
|
|
161
|
-
viewer.setAttribute("width", this._width);
|
|
162
|
-
viewer.setAttribute("height", this._height);
|
|
163
|
-
viewer.setAttribute("server", this._server);
|
|
164
|
-
viewer.setAttribute("scene-id", this._sceneID);
|
|
165
|
-
if (this._productID) {
|
|
166
|
-
viewer.setAttribute("product-id", this._productID);
|
|
167
|
-
}
|
|
168
|
-
if (this._variationID) {
|
|
169
|
-
viewer.setAttribute("variation-id", this._variationID);
|
|
170
|
-
}
|
|
171
|
-
viewer.onload = () => {
|
|
172
|
-
return accept(viewer);
|
|
173
|
-
};
|
|
174
|
-
const shadow = this.shadowRoot || this.attachShadow({ mode: 'open' });
|
|
175
|
-
shadow.append(viewer);
|
|
176
|
-
this._viewer = viewer;
|
|
177
|
-
this._currentState = EmbedState.SceneViewer;
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
// if product is set, we use <plattar-product /> node from plattar-web
|
|
181
|
-
if (this._productID) {
|
|
182
|
-
const viewer = document.createElement("plattar-product");
|
|
183
|
-
viewer.setAttribute("width", this._width);
|
|
184
|
-
viewer.setAttribute("height", this._height);
|
|
185
|
-
viewer.setAttribute("server", this._server);
|
|
186
|
-
viewer.setAttribute("product-id", this._productID);
|
|
187
|
-
if (this._variationID) {
|
|
188
|
-
viewer.setAttribute("variation-id", this._variationID);
|
|
189
|
-
}
|
|
190
|
-
viewer.onload = () => {
|
|
191
|
-
return accept(viewer);
|
|
192
|
-
};
|
|
193
|
-
const shadow = this.shadowRoot || this.attachShadow({ mode: 'open' });
|
|
194
|
-
shadow.append(viewer);
|
|
195
|
-
this._viewer = viewer;
|
|
196
|
-
this._currentState = EmbedState.ProductViewer;
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
return reject(new Error("PlattarEmbed.startViewer() - minimum required attributes not set, use scene-id or product-id as a minimum"));
|
|
124
|
+
return this._controller.startRenderer().then(accept).catch(reject);
|
|
200
125
|
});
|
|
201
126
|
}
|
|
202
127
|
startQRCode(options = null) {
|
|
203
128
|
return new Promise((accept, reject) => {
|
|
204
|
-
if (!this.
|
|
205
|
-
return reject(new Error("PlattarEmbed.startQRCode() - cannot execute as
|
|
206
|
-
}
|
|
207
|
-
const opt = options || this._qrCodeOptions;
|
|
208
|
-
// reset instance for later use
|
|
209
|
-
this._qrCodeOptions = opt;
|
|
210
|
-
if (this._viewer) {
|
|
211
|
-
this._viewer.remove();
|
|
212
|
-
this._viewer = null;
|
|
213
|
-
}
|
|
214
|
-
// if scene is set, we embed a QR code that takes us to viewer.html
|
|
215
|
-
if (this._sceneID) {
|
|
216
|
-
const viewer = document.createElement("plattar-qrcode");
|
|
217
|
-
viewer.setAttribute("width", this._width);
|
|
218
|
-
viewer.setAttribute("height", this._height);
|
|
219
|
-
if (opt.color) {
|
|
220
|
-
viewer.setAttribute("color", opt.color);
|
|
221
|
-
}
|
|
222
|
-
if (opt.margin) {
|
|
223
|
-
viewer.setAttribute("margin", "" + opt.margin);
|
|
224
|
-
}
|
|
225
|
-
if (opt.qrType) {
|
|
226
|
-
viewer.setAttribute("qr-type", opt.qrType);
|
|
227
|
-
}
|
|
228
|
-
let dst = plattar_api_1.Server.location().base + "renderer/viewer.html?scene_id=" + this._sceneID;
|
|
229
|
-
if (this._productID) {
|
|
230
|
-
dst += "&productId=" + this._productID;
|
|
231
|
-
}
|
|
232
|
-
if (this._variationID) {
|
|
233
|
-
dst += "&variationId=" + this._variationID;
|
|
234
|
-
}
|
|
235
|
-
viewer.setAttribute("url", dst);
|
|
236
|
-
viewer.onload = () => {
|
|
237
|
-
return accept(viewer);
|
|
238
|
-
};
|
|
239
|
-
const shadow = this.shadowRoot || this.attachShadow({ mode: 'open' });
|
|
240
|
-
shadow.append(viewer);
|
|
241
|
-
this._viewer = viewer;
|
|
242
|
-
this._currentState = EmbedState.QRCode;
|
|
243
|
-
return;
|
|
129
|
+
if (!this._controller) {
|
|
130
|
+
return reject(new Error("PlattarEmbed.startQRCode() - cannot execute as controller has not loaded yet"));
|
|
244
131
|
}
|
|
245
|
-
|
|
246
|
-
if (this._productID) {
|
|
247
|
-
const viewer = document.createElement("plattar-qrcode");
|
|
248
|
-
viewer.setAttribute("width", this._width);
|
|
249
|
-
viewer.setAttribute("height", this._height);
|
|
250
|
-
if (opt.color) {
|
|
251
|
-
viewer.setAttribute("color", opt.color);
|
|
252
|
-
}
|
|
253
|
-
if (opt.margin) {
|
|
254
|
-
viewer.setAttribute("margin", "" + opt.margin);
|
|
255
|
-
}
|
|
256
|
-
if (opt.qrType) {
|
|
257
|
-
viewer.setAttribute("qr-type", opt.qrType);
|
|
258
|
-
}
|
|
259
|
-
let dst = plattar_api_1.Server.location().base + "renderer/product.html?product_id=" + this._productID;
|
|
260
|
-
if (this._variationID) {
|
|
261
|
-
dst += "&variation_id=" + this._variationID;
|
|
262
|
-
}
|
|
263
|
-
viewer.setAttribute("url", dst);
|
|
264
|
-
viewer.onload = () => {
|
|
265
|
-
return accept(viewer);
|
|
266
|
-
};
|
|
267
|
-
const shadow = this.shadowRoot || this.attachShadow({ mode: 'open' });
|
|
268
|
-
shadow.append(viewer);
|
|
269
|
-
this._viewer = viewer;
|
|
270
|
-
this._currentState = EmbedState.QRCode;
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
return reject(new Error("PlattarEmbed.startQRCode() - minimum required attributes not set, use scene-id or product-id as a minimum"));
|
|
132
|
+
return this._controller.startQRCode(options).then(accept).catch(reject);
|
|
274
133
|
});
|
|
275
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* This will remove the currently active Renderer
|
|
137
|
+
*
|
|
138
|
+
* @returns - true if removed successfully, false otherwise
|
|
139
|
+
*/
|
|
140
|
+
removeRenderer() {
|
|
141
|
+
if (!this._controller) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return this._controller.removeRenderer();
|
|
145
|
+
}
|
|
276
146
|
/**
|
|
277
147
|
* This is called by the observer if any of the embed attributes have changed
|
|
278
148
|
* based on the state of the embed, we update the internal structure accordingly
|
|
279
149
|
*/
|
|
280
150
|
_OnAttributesUpdated() {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
// re-render the QR Code when attributes have changed
|
|
286
|
-
if (this._currentState === EmbedState.QRCode) {
|
|
287
|
-
this.startQRCode(this._qrCodeOptions);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
// use the messenger function to change variation when attributes have changed
|
|
291
|
-
if (this._currentState === EmbedState.SceneViewer) {
|
|
292
|
-
const viewer = this.viewer;
|
|
293
|
-
if (viewer) {
|
|
294
|
-
viewer.messenger.selectVariation(this._productID, this._variationID);
|
|
295
|
-
}
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
if (this._currentState === EmbedState.ProductViewer) {
|
|
299
|
-
const viewer = this.viewer;
|
|
300
|
-
if (viewer) {
|
|
301
|
-
viewer.messenger.selectVariation(this._variationID);
|
|
302
|
-
}
|
|
303
|
-
return;
|
|
151
|
+
if (this._controller) {
|
|
152
|
+
this._controller.onAttributesUpdated();
|
|
304
153
|
}
|
|
305
154
|
}
|
|
306
155
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * as PlattarWeb from "@plattar/plattar-web";
|
|
2
2
|
export * as PlattarQRCode from "@plattar/plattar-qrcode";
|
|
3
3
|
export * as version from "./version";
|
|
4
|
-
export { ConfiguratorAR } from "./ar/configurator-ar";
|
|
5
4
|
export { ProductAR } from "./ar/product-ar";
|
|
6
5
|
export { SceneAR } from "./ar/scene-ar";
|
|
7
6
|
export { ModelAR } from "./ar/model-ar";
|
|
8
7
|
export { RawAR } from "./ar/raw-ar";
|
|
9
8
|
export { Util } from "./util/util";
|
|
9
|
+
export { ConfiguratorState } from "./util/configurator-state";
|
package/dist/index.js
CHANGED
|
@@ -22,12 +22,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.ProductAR = exports.
|
|
25
|
+
exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.ProductAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
|
|
26
26
|
exports.PlattarWeb = __importStar(require("@plattar/plattar-web"));
|
|
27
27
|
exports.PlattarQRCode = __importStar(require("@plattar/plattar-qrcode"));
|
|
28
28
|
exports.version = __importStar(require("./version"));
|
|
29
|
-
var configurator_ar_1 = require("./ar/configurator-ar");
|
|
30
|
-
Object.defineProperty(exports, "ConfiguratorAR", { enumerable: true, get: function () { return configurator_ar_1.ConfiguratorAR; } });
|
|
31
29
|
var product_ar_1 = require("./ar/product-ar");
|
|
32
30
|
Object.defineProperty(exports, "ProductAR", { enumerable: true, get: function () { return product_ar_1.ProductAR; } });
|
|
33
31
|
var scene_ar_1 = require("./ar/scene-ar");
|
|
@@ -38,6 +36,8 @@ var raw_ar_1 = require("./ar/raw-ar");
|
|
|
38
36
|
Object.defineProperty(exports, "RawAR", { enumerable: true, get: function () { return raw_ar_1.RawAR; } });
|
|
39
37
|
var util_1 = require("./util/util");
|
|
40
38
|
Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return util_1.Util; } });
|
|
39
|
+
var configurator_state_1 = require("./util/configurator-state");
|
|
40
|
+
Object.defineProperty(exports, "ConfiguratorState", { enumerable: true, get: function () { return configurator_state_1.ConfiguratorState; } });
|
|
41
41
|
const plattar_embed_1 = __importDefault(require("./embed/plattar-embed"));
|
|
42
42
|
const version_1 = __importDefault(require("./version"));
|
|
43
43
|
if (customElements) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface SceneProductData {
|
|
2
|
+
scene_product_id: string;
|
|
3
|
+
product_variation_id: string;
|
|
4
|
+
meta_data: {
|
|
5
|
+
augment: boolean;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare class ConfiguratorState {
|
|
9
|
+
private readonly _state;
|
|
10
|
+
constructor(state?: string | null | undefined);
|
|
11
|
+
/**
|
|
12
|
+
* Adds a new Scene Product/Variation combo with meta-data into the Configurator State
|
|
13
|
+
*
|
|
14
|
+
* @param sceneProductID - The Scene Product ID to be used (as defined in Plattar CMS)
|
|
15
|
+
* @param productVariationID - The Product Variation ID to be used (as defined in Plattar CMS)
|
|
16
|
+
* @param metaData - Arbitrary meta-data that can be used against certain operaions
|
|
17
|
+
*/
|
|
18
|
+
addSceneProduct(sceneProductID: string, productVariationID: string, metaData?: any | null | undefined): void;
|
|
19
|
+
/**
|
|
20
|
+
* Iterate over the internal state data
|
|
21
|
+
*/
|
|
22
|
+
forEach(callback: (data: SceneProductData) => void): void;
|
|
23
|
+
get length(): number;
|
|
24
|
+
static decode(state: string): ConfiguratorState;
|
|
25
|
+
encode(): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfiguratorState = void 0;
|
|
4
|
+
class ConfiguratorState {
|
|
5
|
+
constructor(state = null) {
|
|
6
|
+
const defaultState = {
|
|
7
|
+
meta: {
|
|
8
|
+
scene_product_index: 0,
|
|
9
|
+
product_variation_index: 1,
|
|
10
|
+
meta_index: 2,
|
|
11
|
+
},
|
|
12
|
+
states: []
|
|
13
|
+
};
|
|
14
|
+
if (state) {
|
|
15
|
+
try {
|
|
16
|
+
const decodedb64State = atob(state);
|
|
17
|
+
const parsedState = JSON.parse(decodedb64State);
|
|
18
|
+
// set the meta data
|
|
19
|
+
if (parsedState.meta) {
|
|
20
|
+
defaultState.meta.scene_product_index = parsedState.meta.scene_product_index || 0;
|
|
21
|
+
defaultState.meta.product_variation_index = parsedState.meta.product_variation_index || 1;
|
|
22
|
+
defaultState.meta.meta_index = parsedState.meta.meta_index || 2;
|
|
23
|
+
}
|
|
24
|
+
defaultState.states = parsedState.states || [];
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
console.error("ConfiguratorState.constructor() - there was an error parsing configurator state");
|
|
28
|
+
console.error(err);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this._state = defaultState;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Adds a new Scene Product/Variation combo with meta-data into the Configurator State
|
|
35
|
+
*
|
|
36
|
+
* @param sceneProductID - The Scene Product ID to be used (as defined in Plattar CMS)
|
|
37
|
+
* @param productVariationID - The Product Variation ID to be used (as defined in Plattar CMS)
|
|
38
|
+
* @param metaData - Arbitrary meta-data that can be used against certain operaions
|
|
39
|
+
*/
|
|
40
|
+
addSceneProduct(sceneProductID, productVariationID, metaData = null) {
|
|
41
|
+
if (sceneProductID && productVariationID) {
|
|
42
|
+
const states = this._state.states;
|
|
43
|
+
const meta = this._state.meta;
|
|
44
|
+
const newData = [];
|
|
45
|
+
newData.splice(meta.scene_product_index, 0, sceneProductID);
|
|
46
|
+
newData.splice(meta.product_variation_index, 0, productVariationID);
|
|
47
|
+
if (metaData) {
|
|
48
|
+
newData.splice(meta.meta_index, 0, metaData);
|
|
49
|
+
}
|
|
50
|
+
states.push(newData);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Iterate over the internal state data
|
|
55
|
+
*/
|
|
56
|
+
forEach(callback) {
|
|
57
|
+
const states = this._state.states;
|
|
58
|
+
const meta = this._state.meta;
|
|
59
|
+
if (states.length > 0) {
|
|
60
|
+
states.forEach((productState) => {
|
|
61
|
+
if (productState.length === 2) {
|
|
62
|
+
callback({
|
|
63
|
+
scene_product_id: productState[meta.scene_product_index],
|
|
64
|
+
product_variation_id: productState[meta.product_variation_index],
|
|
65
|
+
meta_data: {
|
|
66
|
+
augment: true
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (productState.length === 3) {
|
|
71
|
+
callback({
|
|
72
|
+
scene_product_id: productState[meta.scene_product_index],
|
|
73
|
+
product_variation_id: productState[meta.product_variation_index],
|
|
74
|
+
meta_data: {
|
|
75
|
+
augment: productState[meta.meta_index].augment || true
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
get length() {
|
|
83
|
+
return this._state.states.length;
|
|
84
|
+
}
|
|
85
|
+
static decode(state) {
|
|
86
|
+
return new ConfiguratorState(state);
|
|
87
|
+
}
|
|
88
|
+
encode() {
|
|
89
|
+
return btoa(JSON.stringify(this._state));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ConfiguratorState = ConfiguratorState;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.123.3";
|
|
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.
|
|
3
|
+
"version": "1.123.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,17 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@plattar/plattar-analytics": "^1.117.2",
|
|
41
41
|
"@plattar/plattar-api": "^1.120.1",
|
|
42
|
-
"@plattar/plattar-qrcode": "1.
|
|
43
|
-
"@plattar/plattar-
|
|
42
|
+
"@plattar/plattar-qrcode": "1.122.1",
|
|
43
|
+
"@plattar/plattar-services": "^1.120.1",
|
|
44
|
+
"@plattar/plattar-web": "^1.122.3"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@babel/cli": "^7.
|
|
47
|
-
"@babel/core": "^7.
|
|
47
|
+
"@babel/cli": "^7.17.0",
|
|
48
|
+
"@babel/core": "^7.17.2",
|
|
48
49
|
"@babel/preset-env": "^7.16.11",
|
|
49
50
|
"browserify": "^17.0.0",
|
|
50
51
|
"typescript": "^4.5.5",
|
|
51
|
-
"uglify-
|
|
52
|
+
"uglify-js": "^3.15.1"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfiguratorAR = void 0;
|
|
4
|
-
const launcher_ar_1 = require("./launcher-ar");
|
|
5
|
-
/**
|
|
6
|
-
* Performs AR related to Plattar Configurator functionalities
|
|
7
|
-
*/
|
|
8
|
-
class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
9
|
-
init() {
|
|
10
|
-
throw new Error("Method not implemented.");
|
|
11
|
-
}
|
|
12
|
-
launch() {
|
|
13
|
-
throw new Error("Method not implemented.");
|
|
14
|
-
}
|
|
15
|
-
start() {
|
|
16
|
-
throw new Error("Method not implemented.");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.ConfiguratorAR = ConfiguratorAR;
|