@plattar/plattar-ar-adapter 1.168.2 → 1.169.2

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.
@@ -210,9 +210,9 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
210
210
  const showAR = this.getAttribute("show-ar");
211
211
  const showUI = this.getAttribute("show-ui");
212
212
  if (configState) {
213
- let encodedState = configState.state.encode();
213
+ const encodedState = configState.state.encode();
214
214
  if (encodedState.length < 6000) {
215
- viewer.setAttribute("config-state", configState.state.encode());
215
+ viewer.setAttribute("config-state", encodedState);
216
216
  }
217
217
  }
218
218
  if (showAR) {
@@ -0,0 +1,16 @@
1
+ import { LauncherAR } from "../../ar/launcher-ar";
2
+ import { DecodedConfiguratorState } from "../../util/configurator-state";
3
+ import { PlattarController } from "./plattar-controller";
4
+ /**
5
+ * Manages an instance of the <plattar-ewall> HTML Element
6
+ */
7
+ export declare class WebXRController extends PlattarController {
8
+ private _cachedConfigState;
9
+ getConfiguratorState(): Promise<DecodedConfiguratorState>;
10
+ onAttributesUpdated(attributeName: string): Promise<void>;
11
+ startViewerQRCode(options: any): Promise<HTMLElement>;
12
+ get element(): HTMLElement | null;
13
+ startQRCode(options: any): Promise<HTMLElement>;
14
+ startRenderer(): Promise<HTMLElement>;
15
+ initAR(): Promise<LauncherAR>;
16
+ }
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebXRController = void 0;
4
+ const util_1 = require("../../util/util");
5
+ const plattar_controller_1 = require("./plattar-controller");
6
+ /**
7
+ * Manages an instance of the <plattar-ewall> HTML Element
8
+ */
9
+ class WebXRController extends plattar_controller_1.PlattarController {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._cachedConfigState = null;
13
+ }
14
+ async getConfiguratorState() {
15
+ if (this._cachedConfigState) {
16
+ return this._cachedConfigState;
17
+ }
18
+ this._cachedConfigState = this.createConfiguratorState();
19
+ return this._cachedConfigState;
20
+ }
21
+ async onAttributesUpdated(attributeName) {
22
+ const state = this._state;
23
+ if (state === plattar_controller_1.ControllerState.Renderer) {
24
+ const viewer = this.element;
25
+ if (viewer) {
26
+ if (attributeName === "variation-id") {
27
+ const variationIDs = this.getAttribute("variation-id");
28
+ const variationIDsList = variationIDs ? variationIDs.split(",") : [];
29
+ if (variationIDsList.length > 0) {
30
+ await viewer.messenger.selectVariationID(variationIDsList);
31
+ }
32
+ }
33
+ if (attributeName === "variation-sku") {
34
+ const variationSKUs = this.getAttribute("variation-sku");
35
+ const variationSKUList = variationSKUs ? variationSKUs.split(",") : [];
36
+ if (variationSKUList.length > 0) {
37
+ await viewer.messenger.selectVariationSKU(variationSKUList);
38
+ }
39
+ }
40
+ }
41
+ return;
42
+ }
43
+ // re-render the QR Code when attributes have changed
44
+ if (state === plattar_controller_1.ControllerState.QRCode) {
45
+ if (attributeName === "variation-id") {
46
+ const configState = await this.getConfiguratorState();
47
+ const variationIDs = this.getAttribute("variation-id");
48
+ const variationIDsList = variationIDs ? variationIDs.split(",") : [];
49
+ variationIDsList.forEach((variationID) => {
50
+ configState.state.setVariationID(variationID);
51
+ });
52
+ }
53
+ if (attributeName === "variation-sku") {
54
+ const configState = await this.getConfiguratorState();
55
+ const variationSKUs = this.getAttribute("variation-sku");
56
+ const variationSKUList = variationSKUs ? variationSKUs.split(",") : [];
57
+ variationSKUList.forEach((variationSKU) => {
58
+ configState.state.setVariationSKU(variationSKU);
59
+ });
60
+ }
61
+ this.startQRCode(this._prevQROpt);
62
+ return;
63
+ }
64
+ }
65
+ startViewerQRCode(options) {
66
+ return this.startQRCode(options);
67
+ }
68
+ get element() {
69
+ return this._element;
70
+ }
71
+ async startQRCode(options) {
72
+ // remove the old renderer instance if any
73
+ this.removeRenderer();
74
+ const sceneID = this.getAttribute("scene-id");
75
+ if (!sceneID) {
76
+ throw new Error("WebXRController.startQRCode() - minimum required attributes not set, use scene-id as a minimum");
77
+ }
78
+ const opt = options || this._GetDefaultQROptions();
79
+ const viewer = document.createElement("plattar-qrcode");
80
+ this._element = viewer;
81
+ // required attributes with defaults for plattar-viewer node
82
+ const width = this.getAttribute("width") || "500px";
83
+ const height = this.getAttribute("height") || "500px";
84
+ viewer.setAttribute("width", width);
85
+ viewer.setAttribute("height", height);
86
+ if (opt.color) {
87
+ viewer.setAttribute("color", opt.color);
88
+ }
89
+ if (opt.margin) {
90
+ viewer.setAttribute("margin", "" + opt.margin);
91
+ }
92
+ if (opt.qrType) {
93
+ viewer.setAttribute("qr-type", opt.qrType);
94
+ }
95
+ viewer.setAttribute("shorten", (opt.shorten && (opt.shorten === true || opt.shorten === "true")) ? "true" : "false");
96
+ const dst = location.href;
97
+ viewer.setAttribute("url", opt.url || dst);
98
+ this._state = plattar_controller_1.ControllerState.QRCode;
99
+ this._prevQROpt = opt;
100
+ return new Promise((accept, reject) => {
101
+ viewer.onload = () => {
102
+ return accept(viewer);
103
+ };
104
+ this.append(viewer);
105
+ });
106
+ }
107
+ async startRenderer() {
108
+ // remove the old renderer instance if any
109
+ this.removeRenderer();
110
+ if (!util_1.Util.canAugment()) {
111
+ return this.startQRCode(this._GetDefaultQROptions());
112
+ }
113
+ const sceneID = this.getAttribute("scene-id");
114
+ if (!sceneID) {
115
+ throw new Error("WebXRController.startRenderer() - minimum required attributes not set, use scene-id as a minimum");
116
+ }
117
+ // required attributes with defaults for plattar-configurator node
118
+ const width = this.getAttribute("width") || "500px";
119
+ const height = this.getAttribute("height") || "500px";
120
+ const server = this.getAttribute("server") || "production";
121
+ const viewer = document.createElement("plattar-8wall");
122
+ this._element = viewer;
123
+ viewer.setAttribute("width", width);
124
+ viewer.setAttribute("height", height);
125
+ viewer.setAttribute("server", server);
126
+ viewer.setAttribute("scene-id", sceneID);
127
+ const showAR = this.getAttribute("show-ar");
128
+ const showUI = this.getAttribute("show-ui");
129
+ if (showAR) {
130
+ viewer.setAttribute("show-ar", showAR);
131
+ }
132
+ if (showUI) {
133
+ viewer.setAttribute("show-ui", showUI);
134
+ }
135
+ return new Promise((accept, reject) => {
136
+ this.append(viewer);
137
+ return accept(viewer);
138
+ });
139
+ }
140
+ async initAR() {
141
+ throw new Error("WebXRController.initAR() - cannot proceed as AR not available in webxr");
142
+ }
143
+ }
144
+ exports.WebXRController = WebXRController;
@@ -5,6 +5,7 @@ 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
7
  const util_1 = require("../util/util");
8
+ const webxr_controller_1 = require("./controllers/webxr-controller");
8
9
  /**
9
10
  * This tracks the current embed type
10
11
  */
@@ -13,7 +14,8 @@ var EmbedType;
13
14
  EmbedType[EmbedType["Configurator"] = 0] = "Configurator";
14
15
  EmbedType[EmbedType["Legacy"] = 1] = "Legacy";
15
16
  EmbedType[EmbedType["VTO"] = 2] = "VTO";
16
- EmbedType[EmbedType["None"] = 3] = "None";
17
+ EmbedType[EmbedType["WebXR"] = 3] = "WebXR";
18
+ EmbedType[EmbedType["None"] = 4] = "None";
17
19
  })(EmbedType || (EmbedType = {}));
18
20
  /**
19
21
  * Controls the state of the observer
@@ -153,6 +155,9 @@ class PlattarEmbed extends HTMLElement {
153
155
  case "vto":
154
156
  this._currentType = EmbedType.VTO;
155
157
  break;
158
+ case "webxr":
159
+ this._currentType = EmbedType.WebXR;
160
+ break;
156
161
  case "viewer":
157
162
  case "configurator":
158
163
  default:
@@ -181,6 +186,9 @@ class PlattarEmbed extends HTMLElement {
181
186
  case EmbedType.Configurator:
182
187
  this._controller = new configurator_controller_1.ConfiguratorController(this);
183
188
  break;
189
+ case EmbedType.WebXR:
190
+ this._controller = new webxr_controller_1.WebXRController(this);
191
+ break;
184
192
  case EmbedType.VTO:
185
193
  this._controller = new vto_controller_1.VTOController(this);
186
194
  break;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.168.2";
1
+ declare const _default: "1.169.2";
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.168.2";
3
+ exports.default = "1.169.2";
@@ -27,7 +27,7 @@ class SceneViewer extends ar_viewer_1.ARViewer {
27
27
  if (this.isVertical) {
28
28
  intent += '&enable_vertical_placement=true';
29
29
  }
30
- intent += ' #Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;';
30
+ intent += '#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;';
31
31
  intent += `S.browser_fallback_url=${linkOverride};end;`;
32
32
  const anchor = document.createElement("a");
33
33
  anchor.setAttribute("href", intent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.168.2",
3
+ "version": "1.169.2",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -41,14 +41,14 @@
41
41
  "@plattar/plattar-api": "^1.159.1",
42
42
  "@plattar/plattar-qrcode": "1.165.1",
43
43
  "@plattar/plattar-services": "^1.157.1",
44
- "@plattar/plattar-web": "^1.165.1"
44
+ "@plattar/plattar-web": "^1.169.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/cli": "^7.23.9",
48
- "@babel/core": "^7.23.9",
49
- "@babel/preset-env": "^7.23.9",
47
+ "@babel/cli": "^7.24.1",
48
+ "@babel/core": "^7.24.3",
49
+ "@babel/preset-env": "^7.24.3",
50
50
  "browserify": "^17.0.0",
51
- "typescript": "^5.3.3",
51
+ "typescript": "^5.4.3",
52
52
  "uglify-js": "^3.17.4"
53
53
  },
54
54
  "publishConfig": {