@plattar/plattar-ar-adapter 1.155.1 → 1.155.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.
@@ -12,6 +12,12 @@ export declare class ProductController extends PlattarController {
12
12
  constructor(parent: HTMLElement);
13
13
  onAttributesUpdated(attributeName: string): Promise<void>;
14
14
  startViewerQRCode(options: any): Promise<HTMLElement>;
15
+ /**
16
+ * Displays a QR Code that sends the user direct to AR
17
+ * @param options
18
+ * @returns
19
+ */
20
+ startARQRCode(options: any): Promise<HTMLElement>;
15
21
  startRenderer(): Promise<HTMLElement>;
16
22
  initAR(): Promise<LauncherAR>;
17
23
  removeRenderer(): boolean;
@@ -88,6 +88,76 @@ class ProductController extends plattar_controller_1.PlattarController {
88
88
  return reject(new Error("ProductController.startQRCode() - minimum required attributes not set, use product-id as a minimum"));
89
89
  });
90
90
  }
91
+ /**
92
+ * Displays a QR Code that sends the user direct to AR
93
+ * @param options
94
+ * @returns
95
+ */
96
+ startARQRCode(options) {
97
+ return new Promise((accept, reject) => {
98
+ // remove the old renderer instance if any
99
+ this.removeRenderer();
100
+ const opt = options || this._GetDefaultQROptions();
101
+ const viewer = document.createElement("plattar-qrcode");
102
+ // required attributes with defaults for plattar-viewer node
103
+ const width = this.getAttribute("width") || "500px";
104
+ const height = this.getAttribute("height") || "500px";
105
+ viewer.setAttribute("width", width);
106
+ viewer.setAttribute("height", height);
107
+ if (opt.color) {
108
+ viewer.setAttribute("color", opt.color);
109
+ }
110
+ if (opt.margin) {
111
+ viewer.setAttribute("margin", "" + opt.margin);
112
+ }
113
+ if (opt.qrType) {
114
+ viewer.setAttribute("qr-type", opt.qrType);
115
+ }
116
+ viewer.setAttribute("shorten", (opt.shorten && (opt.shorten === true || opt.shorten === "true")) ? "true" : "false");
117
+ const qrOptions = btoa(JSON.stringify(opt));
118
+ let dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
119
+ const sceneID = this.getAttribute("scene-id");
120
+ const configState = this.getAttribute("config-state");
121
+ const embedType = this.getAttribute("embed-type");
122
+ const productID = this.getAttribute("product-id");
123
+ const sceneProductID = this.getAttribute("scene-product-id");
124
+ const variationID = this.getAttribute("variation-id");
125
+ const variationSKU = this.getAttribute("variation-sku");
126
+ const arMode = this.getAttribute("ar-mode");
127
+ if (configState) {
128
+ dst += "&config_state=" + configState;
129
+ }
130
+ if (embedType) {
131
+ dst += "&embed_type=" + embedType;
132
+ }
133
+ if (productID) {
134
+ dst += "&product_id=" + productID;
135
+ }
136
+ if (sceneProductID) {
137
+ dst += "&scene_product_id=" + sceneProductID;
138
+ }
139
+ if (variationID) {
140
+ dst += "&variation_id=" + variationID;
141
+ }
142
+ if (variationSKU) {
143
+ dst += "&variation_sku=" + variationSKU;
144
+ }
145
+ if (arMode) {
146
+ dst += "&ar_mode=" + arMode;
147
+ }
148
+ if (sceneID) {
149
+ dst += "&scene_id=" + sceneID;
150
+ }
151
+ viewer.setAttribute("url", opt.url || dst);
152
+ viewer.onload = () => {
153
+ return accept(viewer);
154
+ };
155
+ this._element = viewer;
156
+ this._state = plattar_controller_1.ControllerState.QRCode;
157
+ this._prevQROpt = opt;
158
+ this.append(viewer);
159
+ });
160
+ }
91
161
  startRenderer() {
92
162
  return new Promise((accept, reject) => {
93
163
  // remove the old renderer instance if any
@@ -61,9 +61,8 @@ class PlattarEmbed extends HTMLElement {
61
61
  attributes: true
62
62
  });
63
63
  }
64
- const sceneID = this.hasAttribute("scene-id") ? this.getAttribute("scene-id") : null;
65
64
  const productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
66
- if (!sceneID && productID) {
65
+ if (productID) {
67
66
  this._currentType = EmbedType.Legacy;
68
67
  this._CreateLegacyEmbed();
69
68
  return;
@@ -86,6 +85,15 @@ class PlattarEmbed extends HTMLElement {
86
85
  */
87
86
  _CreateLegacyEmbed() {
88
87
  this._controller = new product_controller_1.ProductController(this);
88
+ const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
89
+ switch (init) {
90
+ case "viewer":
91
+ this.startViewer();
92
+ break;
93
+ case "qrcode":
94
+ this.startQRCode();
95
+ break;
96
+ }
89
97
  }
90
98
  /**
91
99
  * creates the embed
@@ -44,12 +44,14 @@ class ConfiguratorState {
44
44
  * purposes of Configuration
45
45
  */
46
46
  setVariationSKU(productVariationSKU) {
47
- const variationID = this._mappedVariationSKUValues.get(productVariationSKU);
48
- if (!variationID) {
47
+ const variationIDs = this._mappedVariationSKUValues.get(productVariationSKU);
48
+ if (!variationIDs) {
49
49
  console.warn("ConfiguratorState.setVariationSKU() - Variation SKU of " + productVariationSKU + " is not defined in any variations");
50
50
  return;
51
51
  }
52
- this.setVariationID(variationID);
52
+ variationIDs.forEach((variationID) => {
53
+ this.setVariationID(variationID);
54
+ });
53
55
  }
54
56
  /**
55
57
  * Modifyes the SceneProduct that this Variation belongs to and changes for
@@ -319,7 +321,13 @@ class ConfiguratorState {
319
321
  variations.forEach((variation) => {
320
322
  configState._mappedVariationIDValues.set(variation.id, sceneProduct.id);
321
323
  if (variation.attributes.sku) {
322
- configState._mappedVariationSKUValues.set(variation.attributes.sku, variation.id);
324
+ const existingSKUs = configState._mappedVariationSKUValues.get(variation.attributes.sku);
325
+ if (existingSKUs) {
326
+ existingSKUs.push(variation.id);
327
+ }
328
+ else {
329
+ configState._mappedVariationSKUValues.set(variation.attributes.sku, [variation.id]);
330
+ }
323
331
  }
324
332
  });
325
333
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.155.1";
1
+ declare const _default: "1.155.3";
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.155.1";
3
+ exports.default = "1.155.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.155.1",
3
+ "version": "1.155.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",