@plattar/plattar-ar-adapter 1.128.1 → 1.129.1

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,12 +4,9 @@ import { PlattarController } from "./plattar-controller";
4
4
  * Manages an instance of the <plattar-configurator> HTML Element
5
5
  */
6
6
  export declare class ConfiguratorController extends PlattarController {
7
- private _state;
8
- private _element;
9
- private _prevQROpt;
10
7
  constructor(parent: HTMLElement);
11
8
  onAttributesUpdated(): void;
12
- startQRCode(options: any): Promise<HTMLElement>;
9
+ startViewerQRCode(options: any): Promise<HTMLElement>;
13
10
  startRenderer(): Promise<HTMLElement>;
14
11
  initAR(): Promise<LauncherAR>;
15
12
  /**
@@ -15,9 +15,6 @@ const plattar_controller_1 = require("./plattar-controller");
15
15
  class ConfiguratorController extends plattar_controller_1.PlattarController {
16
16
  constructor(parent) {
17
17
  super(parent);
18
- this._state = plattar_controller_1.ControllerState.None;
19
- this._element = null;
20
- this._prevQROpt = null;
21
18
  }
22
19
  onAttributesUpdated() {
23
20
  const state = this._state;
@@ -27,7 +24,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
27
24
  return;
28
25
  }
29
26
  }
30
- startQRCode(options) {
27
+ startViewerQRCode(options) {
31
28
  return new Promise((accept, reject) => {
32
29
  // remove the old renderer instance if any
33
30
  this.removeRenderer();
@@ -13,17 +13,15 @@ export declare abstract class PlattarController {
13
13
  */
14
14
  static get DEFAULT_QR_OPTIONS(): any;
15
15
  private readonly _parent;
16
+ protected _state: ControllerState;
17
+ protected _element: HTMLElement | null;
18
+ protected _prevQROpt: any;
16
19
  constructor(parent: HTMLElement);
17
20
  /**
18
21
  * Called by the parent when a HTML Attribute has changed and the controller
19
22
  * requires an update
20
23
  */
21
24
  abstract onAttributesUpdated(): void;
22
- /**
23
- * Start Rendering a QR Code with the provided options
24
- * @param options (optional) - The QR Code Options
25
- */
26
- abstract startQRCode(options: any | undefined | null): Promise<HTMLElement>;
27
25
  /**
28
26
  * Start the underlying Plattar Renderer for this Controller
29
27
  */
@@ -32,6 +30,23 @@ export declare abstract class PlattarController {
32
30
  * Initialise and start AR mode if available
33
31
  */
34
32
  startAR(): Promise<void>;
33
+ /**
34
+ * Start Rendering a QR Code with the provided options
35
+ * @param options (optional) - The QR Code Options
36
+ */
37
+ abstract startViewerQRCode(options: any | undefined | null): Promise<HTMLElement>;
38
+ /**
39
+ * Decide which QR Code to render according to the qr-type attribute
40
+ * @param options
41
+ * @returns
42
+ */
43
+ startQRCode(options: any): Promise<HTMLElement>;
44
+ /**
45
+ * Displays a QR Code that sends the user direct to AR
46
+ * @param options
47
+ * @returns
48
+ */
49
+ startARQRCode(options: any): Promise<HTMLElement>;
35
50
  /**
36
51
  * Initialise and return a launcher that can be used to start AR
37
52
  */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlattarController = exports.ControllerState = void 0;
4
+ const plattar_api_1 = require("@plattar/plattar-api");
4
5
  var ControllerState;
5
6
  (function (ControllerState) {
6
7
  ControllerState[ControllerState["None"] = 0] = "None";
@@ -12,6 +13,9 @@ var ControllerState;
12
13
  */
13
14
  class PlattarController {
14
15
  constructor(parent) {
16
+ this._state = ControllerState.None;
17
+ this._element = null;
18
+ this._prevQROpt = null;
15
19
  this._parent = parent;
16
20
  }
17
21
  /**
@@ -36,6 +40,86 @@ class PlattarController {
36
40
  }).catch(reject);
37
41
  });
38
42
  }
43
+ /**
44
+ * Decide which QR Code to render according to the qr-type attribute
45
+ * @param options
46
+ * @returns
47
+ */
48
+ startQRCode(options) {
49
+ const qrType = this.getAttribute("qr-type") || "viewer";
50
+ switch (qrType.toLowerCase()) {
51
+ case "ar":
52
+ return this.startARQRCode(options);
53
+ case "viewer":
54
+ default:
55
+ return this.startViewerQRCode(options);
56
+ }
57
+ }
58
+ /**
59
+ * Displays a QR Code that sends the user direct to AR
60
+ * @param options
61
+ * @returns
62
+ */
63
+ startARQRCode(options) {
64
+ return new Promise((accept, reject) => {
65
+ // remove the old renderer instance if any
66
+ this.removeRenderer();
67
+ const opt = options || PlattarController.DEFAULT_QR_OPTIONS;
68
+ const viewer = document.createElement("plattar-qrcode");
69
+ // required attributes with defaults for plattar-viewer node
70
+ const width = this.getAttribute("width") || "500px";
71
+ const height = this.getAttribute("height") || "500px";
72
+ viewer.setAttribute("width", width);
73
+ viewer.setAttribute("height", height);
74
+ if (opt.color) {
75
+ viewer.setAttribute("color", opt.color);
76
+ }
77
+ if (opt.margin) {
78
+ viewer.setAttribute("margin", "" + opt.margin);
79
+ }
80
+ if (opt.qrType) {
81
+ viewer.setAttribute("qr-type", opt.qrType);
82
+ }
83
+ const qrOptions = btoa(JSON.stringify(opt));
84
+ let dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
85
+ const sceneID = this.getAttribute("scene-id");
86
+ const configState = this.getAttribute("config-state");
87
+ const embedType = this.getAttribute("embed-type");
88
+ const productID = this.getAttribute("product-id");
89
+ const sceneProductID = this.getAttribute("scene-product-id");
90
+ const variationID = this.getAttribute("variation-id");
91
+ const arMode = this.getAttribute("ar-mode");
92
+ if (configState) {
93
+ dst += "&config_state=" + configState;
94
+ }
95
+ if (embedType) {
96
+ dst += "&embed_type=" + embedType;
97
+ }
98
+ if (productID) {
99
+ dst += "&product_id=" + productID;
100
+ }
101
+ if (sceneProductID) {
102
+ dst += "&scene_product_id=" + sceneProductID;
103
+ }
104
+ if (variationID) {
105
+ dst += "&variation_id=" + variationID;
106
+ }
107
+ if (arMode) {
108
+ dst += "&ar_mode=" + arMode;
109
+ }
110
+ if (sceneID) {
111
+ dst += "&scene_id=" + sceneID;
112
+ }
113
+ viewer.setAttribute("url", opt.url || dst);
114
+ viewer.onload = () => {
115
+ return accept(viewer);
116
+ };
117
+ this._element = viewer;
118
+ this._state = ControllerState.QRCode;
119
+ this._prevQROpt = opt;
120
+ this.append(viewer);
121
+ });
122
+ }
39
123
  /**
40
124
  * Returns the Parent Instance
41
125
  */
@@ -4,12 +4,9 @@ import { PlattarController } from "./plattar-controller";
4
4
  * Manages an instance of the <plattar-product> HTML Element
5
5
  */
6
6
  export declare class ProductController extends PlattarController {
7
- private _state;
8
- private _element;
9
- private _prevQROpt;
10
7
  constructor(parent: HTMLElement);
11
8
  onAttributesUpdated(): void;
12
- startQRCode(options: any): Promise<HTMLElement>;
9
+ startViewerQRCode(options: any): Promise<HTMLElement>;
13
10
  startRenderer(): Promise<HTMLElement>;
14
11
  initAR(): Promise<LauncherAR>;
15
12
  removeRenderer(): boolean;
@@ -11,9 +11,6 @@ const plattar_controller_1 = require("./plattar-controller");
11
11
  class ProductController extends plattar_controller_1.PlattarController {
12
12
  constructor(parent) {
13
13
  super(parent);
14
- this._state = plattar_controller_1.ControllerState.None;
15
- this._element = null;
16
- this._prevQROpt = null;
17
14
  }
18
15
  onAttributesUpdated() {
19
16
  const state = this._state;
@@ -34,7 +31,7 @@ class ProductController extends plattar_controller_1.PlattarController {
34
31
  return;
35
32
  }
36
33
  }
37
- startQRCode(options) {
34
+ startViewerQRCode(options) {
38
35
  return new Promise((accept, reject) => {
39
36
  // remove the old renderer instance if any
40
37
  this.removeRenderer();
@@ -4,12 +4,9 @@ import { PlattarController } from "./plattar-controller";
4
4
  * Manages an instance of the <plattar-viewer> HTML Element
5
5
  */
6
6
  export declare class ViewerController extends PlattarController {
7
- private _state;
8
- private _element;
9
- private _prevQROpt;
10
7
  constructor(parent: HTMLElement);
11
8
  onAttributesUpdated(): void;
12
- startQRCode(options: any): Promise<HTMLElement>;
9
+ startViewerQRCode(options: any): Promise<HTMLElement>;
13
10
  startRenderer(): Promise<HTMLElement>;
14
11
  initAR(): Promise<LauncherAR>;
15
12
  removeRenderer(): boolean;
@@ -13,9 +13,6 @@ const plattar_controller_1 = require("./plattar-controller");
13
13
  class ViewerController extends plattar_controller_1.PlattarController {
14
14
  constructor(parent) {
15
15
  super(parent);
16
- this._state = plattar_controller_1.ControllerState.None;
17
- this._element = null;
18
- this._prevQROpt = null;
19
16
  }
20
17
  onAttributesUpdated() {
21
18
  const state = this._state;
@@ -37,7 +34,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
37
34
  return;
38
35
  }
39
36
  }
40
- startQRCode(options) {
37
+ startViewerQRCode(options) {
41
38
  return new Promise((accept, reject) => {
42
39
  // remove the old renderer instance if any
43
40
  this.removeRenderer();
@@ -4,12 +4,9 @@ import { PlattarController } from "./plattar-controller";
4
4
  * Manages an instance of the <plattar-configurator> HTML Element
5
5
  */
6
6
  export declare class VTOController extends PlattarController {
7
- private _state;
8
- private _element;
9
- private _prevQROpt;
10
7
  constructor(parent: HTMLElement);
11
8
  onAttributesUpdated(): void;
12
- startQRCode(options: any): Promise<HTMLElement>;
9
+ startViewerQRCode(options: any): Promise<HTMLElement>;
13
10
  startRenderer(): Promise<HTMLElement>;
14
11
  initAR(): Promise<LauncherAR>;
15
12
  /**
@@ -13,9 +13,6 @@ const plattar_controller_1 = require("./plattar-controller");
13
13
  class VTOController extends plattar_controller_1.PlattarController {
14
14
  constructor(parent) {
15
15
  super(parent);
16
- this._state = plattar_controller_1.ControllerState.None;
17
- this._element = null;
18
- this._prevQROpt = null;
19
16
  }
20
17
  onAttributesUpdated() {
21
18
  const state = this._state;
@@ -25,7 +22,7 @@ class VTOController extends plattar_controller_1.PlattarController {
25
22
  return;
26
23
  }
27
24
  }
28
- startQRCode(options) {
25
+ startViewerQRCode(options) {
29
26
  return new Promise((accept, reject) => {
30
27
  // remove the old renderer instance if any
31
28
  this.removeRenderer();
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.128.1";
1
+ declare const _default: "1.129.1";
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.128.1";
3
+ exports.default = "1.129.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.128.1",
3
+ "version": "1.129.1",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -44,11 +44,11 @@
44
44
  "@plattar/plattar-web": "^1.128.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/cli": "^7.17.6",
48
- "@babel/core": "^7.17.9",
49
- "@babel/preset-env": "^7.16.11",
47
+ "@babel/cli": "^7.17.10",
48
+ "@babel/core": "^7.17.10",
49
+ "@babel/preset-env": "^7.17.10",
50
50
  "browserify": "^17.0.0",
51
- "typescript": "^4.6.3",
51
+ "typescript": "^4.6.4",
52
52
  "uglify-js": "^3.15.4"
53
53
  },
54
54
  "publishConfig": {