@plattar/plattar-ar-adapter 1.123.3 → 1.123.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.
@@ -0,0 +1,14 @@
1
+ import { ProductAR } from "./product-ar";
2
+ import { LauncherAR } from "./launcher-ar";
3
+ /**
4
+ * Allows launching Product AR by providing a SceneProduct ID instead.
5
+ * SceneProducts are much more convenient to grab from the Plattar CMS
6
+ */
7
+ export declare class SceneProductAR extends ProductAR {
8
+ private readonly _sceneProductID;
9
+ private _attachedProductID;
10
+ constructor(sceneProductID?: string | undefined | null, variationID?: string | undefined | null);
11
+ get sceneProductID(): string;
12
+ get productID(): string;
13
+ init(): Promise<LauncherAR>;
14
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SceneProductAR = void 0;
4
+ const product_ar_1 = require("./product-ar");
5
+ const plattar_api_1 = require("@plattar/plattar-api");
6
+ const util_1 = require("../util/util");
7
+ /**
8
+ * Allows launching Product AR by providing a SceneProduct ID instead.
9
+ * SceneProducts are much more convenient to grab from the Plattar CMS
10
+ */
11
+ class SceneProductAR extends product_ar_1.ProductAR {
12
+ constructor(sceneProductID = null, variationID = null) {
13
+ super(sceneProductID, variationID);
14
+ // this is evaluated in the init() function
15
+ this._attachedProductID = null;
16
+ if (!sceneProductID) {
17
+ throw new Error("SceneProductAR.constructor(sceneProductID, variationID) - sceneProductID must be defined");
18
+ }
19
+ this._sceneProductID = sceneProductID;
20
+ }
21
+ get sceneProductID() {
22
+ return this._sceneProductID;
23
+ }
24
+ get productID() {
25
+ if (!this._attachedProductID) {
26
+ throw new Error("SceneProductAR.productID() - product id was not defined, did you call init()?");
27
+ }
28
+ return this._attachedProductID;
29
+ }
30
+ init() {
31
+ return new Promise((accept, reject) => {
32
+ if (!util_1.Util.canAugment()) {
33
+ return reject(new Error("SceneProductAR.init() - cannot proceed as AR not available in context"));
34
+ }
35
+ const sceneProduct = new plattar_api_1.SceneProduct(this.sceneProductID);
36
+ sceneProduct.get().then((sceneProduct) => {
37
+ const productID = sceneProduct.attributes.product_id;
38
+ if (!productID) {
39
+ return reject("SceneProductAR.init() - Scene Product does not have an attached Product instance");
40
+ }
41
+ this._attachedProductID = productID;
42
+ // execute the standard Product AR functionality
43
+ return super.init().then(accept).catch(reject);
44
+ }).catch(reject);
45
+ });
46
+ }
47
+ }
48
+ exports.SceneProductAR = SceneProductAR;
@@ -12,6 +12,14 @@ export declare class ConfiguratorController extends PlattarController {
12
12
  startQRCode(options: any): Promise<HTMLElement>;
13
13
  startRenderer(): Promise<HTMLElement>;
14
14
  initAR(): Promise<LauncherAR>;
15
+ /**
16
+ * Private Function - This launches the Static/Inherited AR Mode
17
+ */
18
+ private _InitARInherited;
19
+ /**
20
+ * Private Function - This launches the Dynamic/Generated AR Mode
21
+ */
22
+ private _InitARGenerated;
15
23
  removeRenderer(): boolean;
16
24
  get element(): HTMLElement | null;
17
25
  }
@@ -4,6 +4,9 @@ exports.ConfiguratorController = void 0;
4
4
  const plattar_api_1 = require("@plattar/plattar-api");
5
5
  const plattar_services_1 = require("@plattar/plattar-services");
6
6
  const raw_ar_1 = require("../../ar/raw-ar");
7
+ const scene_ar_1 = require("../../ar/scene-ar");
8
+ const scene_product_ar_1 = require("../../ar/scene-product-ar");
9
+ const configurator_state_1 = require("../../util/configurator-state");
7
10
  const util_1 = require("../../util/util");
8
11
  const plattar_controller_1 = require("./plattar-controller");
9
12
  /**
@@ -109,59 +112,103 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
109
112
  if (!util_1.Util.canAugment()) {
110
113
  return reject(new Error("ConfiguratorController.initAR() - cannot proceed as AR not available in context"));
111
114
  }
112
- // if scene ID is available and the state is a configurator viewer
113
- // we can use the real-time configurator state to launch the AR view
114
- const viewer = this.element;
115
- const sceneID = this.getAttribute("scene-id");
116
- if (viewer && sceneID) {
117
- let output = "glb";
118
- if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
119
- output = "usdz";
115
+ const arMode = this.getAttribute("ar-mode") || "generated";
116
+ switch (arMode.toLowerCase()) {
117
+ case "inherited":
118
+ this._InitARInherited(accept, reject);
119
+ return;
120
+ case "generated":
121
+ default:
122
+ this._InitARGenerated(accept, reject);
123
+ }
124
+ });
125
+ }
126
+ /**
127
+ * Private Function - This launches the Static/Inherited AR Mode
128
+ */
129
+ _InitARInherited(accept, reject) {
130
+ const sceneID = this.getAttribute("scene-id");
131
+ const configState = this.getAttribute("config-state");
132
+ // use config-state if its available
133
+ if (sceneID && configState) {
134
+ const state = configurator_state_1.ConfiguratorState.decode(configState);
135
+ const first = state.first();
136
+ if (first) {
137
+ const sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
138
+ sceneProductAR.init().then(accept).catch(reject);
139
+ return;
140
+ }
141
+ return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
142
+ }
143
+ // otherwise fallback to using scene
144
+ if (sceneID) {
145
+ configurator_state_1.ConfiguratorState.decodeScene(sceneID).then((state) => {
146
+ const first = state.first();
147
+ if (first) {
148
+ const sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
149
+ return sceneProductAR.init().then(accept).catch(reject);
120
150
  }
121
- return viewer.messenger.getARFile(output).then((result) => {
122
- const rawAR = new raw_ar_1.RawAR(result.filename);
123
- return rawAR.init().then(accept).catch(reject);
124
- }).catch(reject);
151
+ return reject(new Error("ConfiguratorController.initAR() - invalid Scene does not have any product states"));
152
+ }).catch(reject);
153
+ return;
154
+ }
155
+ return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
156
+ }
157
+ /**
158
+ * Private Function - This launches the Dynamic/Generated AR Mode
159
+ */
160
+ _InitARGenerated(accept, reject) {
161
+ // if scene ID is available and the state is a configurator viewer
162
+ // we can use the real-time configurator state to launch the AR view
163
+ const viewer = this.element;
164
+ const sceneID = this.getAttribute("scene-id");
165
+ if (viewer && sceneID && viewer.messenger) {
166
+ let output = "glb";
167
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
168
+ output = "usdz";
125
169
  }
126
- const configState = this.getAttribute("config-state");
127
- // otherwise scene ID is available to the viewer is not launched
128
- // we can use the static configuration state to launch the AR view
129
- if (sceneID && configState) {
130
- try {
131
- const decodedb64State = atob(configState);
132
- const state = JSON.parse(decodedb64State);
133
- if (state.meta) {
134
- const sceneProductIndex = state.meta.scene_product_index || 0;
135
- const variationIndex = state.meta.product_variation_index || 1;
136
- const states = state.states || [];
137
- if (states.length > 0) {
138
- const configurator = new plattar_services_1.Configurator();
139
- states.forEach((productState) => {
140
- configurator.addSceneProduct(productState[sceneProductIndex], productState[variationIndex]);
141
- });
142
- if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
143
- configurator.output = "usdz";
144
- }
145
- if (util_1.Util.canSceneViewer()) {
146
- configurator.output = "glb";
147
- }
148
- const server = this.getAttribute("server") || "production";
149
- configurator.server = server;
150
- return configurator.get().then((result) => {
151
- const rawAR = new raw_ar_1.RawAR(result.filename);
152
- rawAR.init().then(accept).catch(reject);
153
- }).catch(reject);
154
- }
155
- return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
156
- }
157
- return reject(new Error("ConfiguratorController.initAR() - invalid config-state for configurator"));
170
+ viewer.messenger.getARFile(output).then((result) => {
171
+ const rawAR = new raw_ar_1.RawAR(result.filename);
172
+ return rawAR.init().then(accept).catch(reject);
173
+ }).catch(reject);
174
+ return;
175
+ }
176
+ const configState = this.getAttribute("config-state");
177
+ // otherwise scene ID is available to the viewer is not launched
178
+ // we can use the static configuration state to launch the AR view
179
+ if (sceneID && configState) {
180
+ const state = configurator_state_1.ConfiguratorState.decode(configState);
181
+ if (state.length > 0) {
182
+ const server = this.getAttribute("server") || "production";
183
+ const configurator = new plattar_services_1.Configurator();
184
+ configurator.server = server;
185
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
186
+ configurator.output = "usdz";
158
187
  }
159
- catch (err) {
160
- return reject(err);
188
+ if (util_1.Util.canSceneViewer()) {
189
+ configurator.output = "glb";
161
190
  }
191
+ state.forEach((productState) => {
192
+ if (productState.meta_data.augment === true) {
193
+ configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
194
+ }
195
+ });
196
+ configurator.get().then((result) => {
197
+ const rawAR = new raw_ar_1.RawAR(result.filename);
198
+ rawAR.init().then(accept).catch(reject);
199
+ }).catch(reject);
200
+ return;
162
201
  }
163
- return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
164
- });
202
+ return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
203
+ }
204
+ // otherwise no config-state or viewer is active
205
+ // fallback to using default SceneAR implementation
206
+ if (sceneID) {
207
+ const sceneAR = new scene_ar_1.SceneAR(sceneID);
208
+ sceneAR.init().then(accept).catch(reject);
209
+ return;
210
+ }
211
+ return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
165
212
  }
166
213
  removeRenderer() {
167
214
  if (this._element) {
@@ -27,7 +27,9 @@ class ProductController extends plattar_controller_1.PlattarController {
27
27
  const viewer = this._element;
28
28
  if (viewer) {
29
29
  const variationID = this.getAttribute("variation-id");
30
- viewer.messenger.selectVariation(variationID);
30
+ if (variationID && viewer.messenger) {
31
+ viewer.messenger.selectVariation(variationID);
32
+ }
31
33
  }
32
34
  return;
33
35
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewerController = void 0;
4
4
  const plattar_api_1 = require("@plattar/plattar-api");
5
5
  const product_ar_1 = require("../../ar/product-ar");
6
+ const scene_product_ar_1 = require("../../ar/scene-product-ar");
6
7
  const util_1 = require("../../util/util");
7
8
  const plattar_controller_1 = require("./plattar-controller");
8
9
  /**
@@ -26,9 +27,11 @@ class ViewerController extends plattar_controller_1.PlattarController {
26
27
  if (state === plattar_controller_1.ControllerState.Renderer) {
27
28
  const viewer = this._element;
28
29
  if (viewer) {
29
- const productID = this.getAttribute("product-id");
30
+ const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
30
31
  const variationID = this.getAttribute("variation-id");
31
- viewer.messenger.selectVariation(productID, variationID);
32
+ if (productID && variationID && viewer.messenger) {
33
+ viewer.messenger.selectVariation(productID, variationID);
34
+ }
32
35
  }
33
36
  return;
34
37
  }
@@ -57,7 +60,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
57
60
  }
58
61
  let dst = plattar_api_1.Server.location().base + "renderer/viewer.html?scene_id=" + sceneID;
59
62
  // optional attributes
60
- const productID = this.getAttribute("product-id");
63
+ const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
61
64
  const variationID = this.getAttribute("variation-id");
62
65
  if (productID) {
63
66
  dst += "&productId=" + productID;
@@ -94,7 +97,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
94
97
  viewer.setAttribute("server", server);
95
98
  viewer.setAttribute("scene-id", sceneID);
96
99
  // optional attributes
97
- const productID = this.getAttribute("product-id");
100
+ const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
98
101
  const variationID = this.getAttribute("variation-id");
99
102
  if (productID) {
100
103
  viewer.setAttribute("product-id", productID);
@@ -119,17 +122,25 @@ class ViewerController extends plattar_controller_1.PlattarController {
119
122
  return reject(new Error("ViewerController.initAR() - cannot proceed as AR not available in context"));
120
123
  }
121
124
  const productID = this.getAttribute("product-id");
125
+ // use product-id if available
122
126
  if (productID) {
123
127
  const variationID = this.getAttribute("variation-id");
124
128
  const product = new product_ar_1.ProductAR(productID, variationID);
125
129
  return product.init().then(accept).catch(reject);
126
130
  }
131
+ const sceneProductID = this.getAttribute("scene-product-id");
132
+ // use scene-product-id if available
133
+ if (sceneProductID) {
134
+ const variationID = this.getAttribute("variation-id");
135
+ const product = new scene_product_ar_1.SceneProductAR(sceneProductID, variationID);
136
+ return product.init().then(accept).catch(reject);
137
+ }
127
138
  const sceneID = this.getAttribute("scene-id");
128
139
  // otherwise, scene was set so use SceneAR
129
140
  if (sceneID) {
130
- return reject(new Error("ViewerController.initAR() - AR mode for scene-id not yet supported, use product-id"));
141
+ return reject(new Error("ViewerController.initAR() - AR mode for scene-id not yet supported, use product-id or scene-product-id"));
131
142
  }
132
- return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use scene-id or product-id as a minimum"));
143
+ return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use product-id or scene-product-id as a minimum"));
133
144
  });
134
145
  }
135
146
  removeRenderer() {
@@ -12,6 +12,14 @@ export declare class VTOController extends PlattarController {
12
12
  startQRCode(options: any): Promise<HTMLElement>;
13
13
  startRenderer(): Promise<HTMLElement>;
14
14
  initAR(): Promise<LauncherAR>;
15
+ /**
16
+ * Private Function - This launches the Static/Inherited AR Mode
17
+ */
18
+ private _InitARInherited;
19
+ /**
20
+ * Private Function - This launches the Dynamic/Generated AR Mode
21
+ */
22
+ private _InitARGenerated;
15
23
  removeRenderer(): boolean;
16
24
  get element(): HTMLElement | null;
17
25
  }
@@ -113,46 +113,94 @@ class VTOController extends plattar_controller_1.PlattarController {
113
113
  if (!(util_1.Util.isSafari() || util_1.Util.isChromeOnIOS())) {
114
114
  return reject(new Error("VTOController.initAR() - cannot proceed as VTO AR only available on IOS Mobile devices"));
115
115
  }
116
- // if scene ID is available and the state is a configurator viewer
117
- // we can use the real-time configurator state to launch the AR view
118
- const viewer = this.element;
119
- const sceneID = this.getAttribute("scene-id");
120
- if (viewer && sceneID) {
121
- return viewer.messenger.getARFile("vto").then((result) => {
122
- const rawAR = new raw_ar_1.RawAR(result.filename);
123
- return rawAR.init().then(accept).catch(reject);
124
- }).catch(reject);
116
+ const arMode = this.getAttribute("ar-mode") || "generated";
117
+ switch (arMode.toLowerCase()) {
118
+ case "inherited":
119
+ this._InitARInherited(accept, reject);
120
+ return;
121
+ case "generated":
122
+ default:
123
+ this._InitARGenerated(accept, reject);
125
124
  }
126
- const configState = this.getAttribute("config-state");
127
- // otherwise scene ID is available to the viewer is not launched
128
- // we can use the static configuration state to launch the AR view
129
- if (sceneID && configState) {
130
- const state = __1.ConfiguratorState.decode(configState);
131
- if (state.length > 0) {
132
- const server = this.getAttribute("server") || "production";
133
- const configurator = new plattar_services_1.Configurator();
134
- configurator.server = server;
135
- configurator.output = "vto";
136
- state.forEach((productState) => {
137
- if (productState.meta_data.augment === true) {
138
- configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
139
- }
140
- });
141
- return configurator.get().then((result) => {
142
- const rawAR = new raw_ar_1.RawAR(result.filename);
143
- rawAR.init().then(accept).catch(reject);
144
- }).catch(reject);
145
- }
146
- return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
125
+ });
126
+ }
127
+ /**
128
+ * Private Function - This launches the Static/Inherited AR Mode
129
+ */
130
+ _InitARInherited(accept, reject) {
131
+ const sceneID = this.getAttribute("scene-id");
132
+ const configState = this.getAttribute("config-state");
133
+ // use config-state if its available
134
+ if (sceneID && configState) {
135
+ const state = __1.ConfiguratorState.decode(configState);
136
+ const first = state.first();
137
+ if (first) {
138
+ const sceneProductAR = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
139
+ sceneProductAR.init().then(accept).catch(reject);
140
+ return;
147
141
  }
148
- // otherwise no config-state or viewer is active
149
- // fallback to using default SceneAR implementation
150
- if (sceneID) {
151
- const sceneAR = new __1.SceneAR(sceneID);
152
- return sceneAR.init().then(accept).catch(reject);
142
+ return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
143
+ }
144
+ // otherwise fallback to using scene
145
+ if (sceneID) {
146
+ __1.ConfiguratorState.decodeScene(sceneID).then((state) => {
147
+ const first = state.first();
148
+ if (first) {
149
+ const sceneProductAR = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
150
+ return sceneProductAR.init().then(accept).catch(reject);
151
+ }
152
+ return reject(new Error("VTOController.initAR() - invalid Scene does not have any product states"));
153
+ }).catch(reject);
154
+ return;
155
+ }
156
+ return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
157
+ }
158
+ /**
159
+ * Private Function - This launches the Dynamic/Generated AR Mode
160
+ */
161
+ _InitARGenerated(accept, reject) {
162
+ // if scene ID is available and the state is a configurator viewer
163
+ // we can use the real-time configurator state to launch the AR view
164
+ const viewer = this.element;
165
+ const sceneID = this.getAttribute("scene-id");
166
+ if (viewer && sceneID && viewer.messenger) {
167
+ viewer.messenger.getARFile("vto").then((result) => {
168
+ const rawAR = new raw_ar_1.RawAR(result.filename);
169
+ return rawAR.init().then(accept).catch(reject);
170
+ }).catch(reject);
171
+ return;
172
+ }
173
+ const configState = this.getAttribute("config-state");
174
+ // otherwise scene ID is available to the viewer is not launched
175
+ // we can use the static configuration state to launch the AR view
176
+ if (sceneID && configState) {
177
+ const state = __1.ConfiguratorState.decode(configState);
178
+ if (state.length > 0) {
179
+ const server = this.getAttribute("server") || "production";
180
+ const configurator = new plattar_services_1.Configurator();
181
+ configurator.server = server;
182
+ configurator.output = "vto";
183
+ state.forEach((productState) => {
184
+ if (productState.meta_data.augment === true) {
185
+ configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
186
+ }
187
+ });
188
+ configurator.get().then((result) => {
189
+ const rawAR = new raw_ar_1.RawAR(result.filename);
190
+ rawAR.init().then(accept).catch(reject);
191
+ }).catch(reject);
192
+ return;
153
193
  }
154
- return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
155
- });
194
+ return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
195
+ }
196
+ // otherwise no config-state or viewer is active
197
+ // fallback to using default SceneAR implementation
198
+ if (sceneID) {
199
+ const sceneAR = new __1.SceneAR(sceneID);
200
+ sceneAR.init().then(accept).catch(reject);
201
+ return;
202
+ }
203
+ return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
156
204
  }
157
205
  removeRenderer() {
158
206
  if (this._element) {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * as PlattarWeb from "@plattar/plattar-web";
2
2
  export * as PlattarQRCode from "@plattar/plattar-qrcode";
3
3
  export * as version from "./version";
4
4
  export { ProductAR } from "./ar/product-ar";
5
+ export { SceneProductAR } from "./ar/scene-product-ar";
5
6
  export { SceneAR } from "./ar/scene-ar";
6
7
  export { ModelAR } from "./ar/model-ar";
7
8
  export { RawAR } from "./ar/raw-ar";
package/dist/index.js CHANGED
@@ -22,12 +22,14 @@ 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.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.ProductAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
25
+ exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = 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
29
  var product_ar_1 = require("./ar/product-ar");
30
30
  Object.defineProperty(exports, "ProductAR", { enumerable: true, get: function () { return product_ar_1.ProductAR; } });
31
+ var scene_product_ar_1 = require("./ar/scene-product-ar");
32
+ Object.defineProperty(exports, "SceneProductAR", { enumerable: true, get: function () { return scene_product_ar_1.SceneProductAR; } });
31
33
  var scene_ar_1 = require("./ar/scene-ar");
32
34
  Object.defineProperty(exports, "SceneAR", { enumerable: true, get: function () { return scene_ar_1.SceneAR; } });
33
35
  var model_ar_1 = require("./ar/model-ar");
@@ -8,6 +8,14 @@ export interface SceneProductData {
8
8
  export declare class ConfiguratorState {
9
9
  private readonly _state;
10
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
+ setSceneProduct(sceneProductID: string, productVariationID: string, metaData?: any | null | undefined): void;
11
19
  /**
12
20
  * Adds a new Scene Product/Variation combo with meta-data into the Configurator State
13
21
  *
@@ -16,11 +24,44 @@ export declare class ConfiguratorState {
16
24
  * @param metaData - Arbitrary meta-data that can be used against certain operaions
17
25
  */
18
26
  addSceneProduct(sceneProductID: string, productVariationID: string, metaData?: any | null | undefined): void;
27
+ /**
28
+ * Search and return the data index reference for the provided Scene Product ID
29
+ * if not found, will return null
30
+ * @param sceneProductID
31
+ */
32
+ findSceneProductIndex(sceneProductID: string): any[] | null;
33
+ /**
34
+ * Search and return the data for the provided Scene Product ID
35
+ * if not found, will return null
36
+ * @param sceneProductID
37
+ */
38
+ findSceneProduct(sceneProductID: string): SceneProductData | null;
19
39
  /**
20
40
  * Iterate over the internal state data
21
41
  */
22
42
  forEach(callback: (data: SceneProductData) => void): void;
43
+ /**
44
+ * @returns Returns the first reference of data in the stack, otherwise returns null
45
+ */
46
+ first(): SceneProductData | null;
23
47
  get length(): number;
48
+ /**
49
+ * Decodes and returns an instance of ConfiguratorState from a previously
50
+ * encoded state
51
+ * @param state - The previously encoded state as a Base64 String
52
+ * @returns - ConfiguratorState instance
53
+ */
24
54
  static decode(state: string): ConfiguratorState;
55
+ /**
56
+ * Generates a new ConfiguratorState instance from all SceneProducts and default
57
+ * variations from the provided Scene ID
58
+ * @param sceneID - the Scene ID to generate
59
+ * @returns - Promise that resolves into a ConfiguratorState instance
60
+ */
61
+ static decodeScene(sceneID?: string | null | undefined): Promise<ConfiguratorState>;
62
+ /**
63
+ * Encode and return the internal ConfiguratorState as a Base64 String
64
+ * @returns - Base64 String
65
+ */
25
66
  encode(): string;
26
67
  }