@plattar/plattar-ar-adapter 1.158.3 → 1.163.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.
- package/build/es2015/plattar-ar-adapter.js +513 -293
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +192 -100
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/configurator-ar.d.ts +6 -2
- package/dist/ar/configurator-ar.js +17 -8
- package/dist/ar/launcher-ar.d.ts +2 -0
- package/dist/ar/launcher-ar.js +2 -1
- package/dist/ar/model-ar.d.ts +6 -2
- package/dist/ar/model-ar.js +14 -4
- package/dist/ar/product-ar.d.ts +8 -4
- package/dist/ar/product-ar.js +28 -6
- package/dist/ar/raw-ar.d.ts +7 -3
- package/dist/ar/raw-ar.js +16 -8
- package/dist/ar/scene-ar.d.ts +7 -3
- package/dist/ar/scene-ar.js +16 -8
- package/dist/ar/scene-product-ar.d.ts +2 -2
- package/dist/ar/scene-product-ar.js +5 -4
- package/dist/embed/controllers/configurator-controller.js +12 -2
- package/dist/embed/controllers/plattar-controller.d.ts +6 -0
- package/dist/embed/controllers/plattar-controller.js +12 -0
- package/dist/embed/controllers/product-controller.js +11 -1
- package/dist/embed/controllers/vto-controller.js +7 -2
- package/dist/embed/plattar-embed.d.ts +2 -0
- package/dist/embed/plattar-embed.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/viewers/ar-viewer.d.ts +8 -1
- package/dist/viewers/ar-viewer.js +8 -2
- package/dist/viewers/quicklook-viewer.d.ts +1 -4
- package/dist/viewers/quicklook-viewer.js +9 -18
- package/dist/viewers/reality-viewer.d.ts +1 -1
- package/dist/viewers/reality-viewer.js +2 -5
- package/dist/viewers/scene-viewer.d.ts +1 -3
- package/dist/viewers/scene-viewer.js +9 -23
- package/package.json +7 -7
|
@@ -119,6 +119,7 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
119
119
|
const variationID = this.getAttribute("variation-id");
|
|
120
120
|
const variationSKU = this.getAttribute("variation-sku");
|
|
121
121
|
const arMode = this.getAttribute("ar-mode");
|
|
122
|
+
const showBanner = this.getAttribute("show-ar-banner");
|
|
122
123
|
if (configState) {
|
|
123
124
|
dst += "&config_state=" + configState;
|
|
124
125
|
}
|
|
@@ -143,6 +144,9 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
143
144
|
if (sceneID) {
|
|
144
145
|
dst += "&scene_id=" + sceneID;
|
|
145
146
|
}
|
|
147
|
+
if (showBanner) {
|
|
148
|
+
dst += "&show_ar_banner=" + showBanner;
|
|
149
|
+
}
|
|
146
150
|
viewer.setAttribute("url", opt.url || dst);
|
|
147
151
|
viewer.onload = () => {
|
|
148
152
|
return accept(viewer);
|
|
@@ -201,7 +205,13 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
201
205
|
if (productID) {
|
|
202
206
|
const variationID = this.getAttribute("variation-id");
|
|
203
207
|
const variationSKU = this.getAttribute("variation-sku");
|
|
204
|
-
const product = new
|
|
208
|
+
//const product: ProductAR = new ProductAR(productID, variationID, variationSKU);
|
|
209
|
+
const product = new product_ar_1.ProductAR({
|
|
210
|
+
productID: productID,
|
|
211
|
+
variationID: variationID ? variationID : (variationSKU ? null : "default"),
|
|
212
|
+
variationSKU: variationSKU,
|
|
213
|
+
useARBanner: this.getBooleanAttribute("show-ar-banner")
|
|
214
|
+
});
|
|
205
215
|
return product.init().then(accept).catch(reject);
|
|
206
216
|
}
|
|
207
217
|
return reject(new Error("ProductController.initAR() - minimum required attributes not set, use product-id as a minimum"));
|
|
@@ -210,7 +210,12 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
210
210
|
const state = (await this.getConfiguratorState()).state;
|
|
211
211
|
const first = state.first();
|
|
212
212
|
if (first) {
|
|
213
|
-
const sceneProductAR = new __1.SceneProductAR(
|
|
213
|
+
const sceneProductAR = new __1.SceneProductAR({
|
|
214
|
+
productID: first.scene_product_id,
|
|
215
|
+
variationID: first.product_variation_id,
|
|
216
|
+
variationSKU: null,
|
|
217
|
+
useARBanner: this.getBooleanAttribute("show-ar-banner")
|
|
218
|
+
});
|
|
214
219
|
return sceneProductAR.init();
|
|
215
220
|
}
|
|
216
221
|
throw new Error("VTOController.initAR() - invalid decoded config-state does not have any product states");
|
|
@@ -223,7 +228,7 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
223
228
|
if (!sceneID) {
|
|
224
229
|
throw new Error("VTOController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
|
|
225
230
|
}
|
|
226
|
-
const configAR = new configurator_ar_1.ConfiguratorAR(await this.getConfiguratorState());
|
|
231
|
+
const configAR = new configurator_ar_1.ConfiguratorAR({ state: await this.getConfiguratorState(), useARBanner: this.getBooleanAttribute("show-ar-banner") });
|
|
227
232
|
return configAR.init();
|
|
228
233
|
}
|
|
229
234
|
removeRenderer() {
|
|
@@ -57,4 +57,6 @@ export default class PlattarEmbed extends HTMLElement {
|
|
|
57
57
|
* based on the state of the embed, we update the internal structure accordingly
|
|
58
58
|
*/
|
|
59
59
|
private _OnAttributesUpdated;
|
|
60
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
61
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
60
62
|
}
|
|
@@ -223,5 +223,21 @@ class PlattarEmbed extends HTMLElement {
|
|
|
223
223
|
this._controller.onAttributesUpdated(attributeName);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
+
addEventListener(type, listener, options) {
|
|
227
|
+
// add to the element event listener
|
|
228
|
+
super.addEventListener(type, listener, options);
|
|
229
|
+
const eventType = 'arclick';
|
|
230
|
+
if (type === eventType) {
|
|
231
|
+
// automatically enable `show-ar-banner` to true if an arclick event is added
|
|
232
|
+
this.setAttribute('show-ar-banner', 'true');
|
|
233
|
+
// if this is a redirect url from an AR Action - we need to fire the event listener now
|
|
234
|
+
const url = new URL(location.href);
|
|
235
|
+
if (url.searchParams.get('plattar_ar_action') === 'true') {
|
|
236
|
+
setTimeout(() => {
|
|
237
|
+
this.dispatchEvent(new Event(eventType));
|
|
238
|
+
}, 200);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
226
242
|
}
|
|
227
243
|
exports.default = PlattarEmbed;
|
package/dist/index.d.ts
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.163.2";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ARBanner {
|
|
2
|
+
readonly title: string;
|
|
3
|
+
readonly subtitle: string;
|
|
4
|
+
readonly button: 'Visit';
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class ARViewer {
|
|
2
7
|
modelUrl: string | null;
|
|
8
|
+
banner: ARBanner | null;
|
|
3
9
|
constructor();
|
|
4
10
|
abstract start(): void;
|
|
5
11
|
abstract get nodeType(): string;
|
|
6
12
|
abstract get device(): string;
|
|
13
|
+
get composedActionURL(): string;
|
|
7
14
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ARViewer = void 0;
|
|
3
4
|
class ARViewer {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.modelUrl = null;
|
|
6
|
-
this.
|
|
7
|
+
this.banner = null;
|
|
8
|
+
}
|
|
9
|
+
get composedActionURL() {
|
|
10
|
+
const link = new URL(location.href);
|
|
11
|
+
link.searchParams.set("plattar_ar_action", "true");
|
|
12
|
+
return encodeURI(link.href);
|
|
7
13
|
}
|
|
8
14
|
}
|
|
9
|
-
exports.
|
|
15
|
+
exports.ARViewer = ARViewer;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import ARViewer from "./ar-viewer";
|
|
1
|
+
import { ARViewer } from "./ar-viewer";
|
|
2
2
|
export default class QuicklookViewer extends ARViewer {
|
|
3
|
-
araction: string | null;
|
|
4
|
-
arcallback: () => void;
|
|
5
|
-
titleHTML: string;
|
|
6
3
|
constructor();
|
|
7
4
|
get nodeType(): string;
|
|
8
5
|
get device(): string;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ar_viewer_1 =
|
|
7
|
-
class QuicklookViewer extends ar_viewer_1.
|
|
3
|
+
const ar_viewer_1 = require("./ar-viewer");
|
|
4
|
+
class QuicklookViewer extends ar_viewer_1.ARViewer {
|
|
8
5
|
constructor() {
|
|
9
6
|
super();
|
|
10
|
-
this.araction = null;
|
|
11
|
-
this.titleHTML = "&checkoutTitle=" + document.title + "&checkoutSubtitle=" + document.title;
|
|
12
|
-
this.arcallback = () => { };
|
|
13
7
|
}
|
|
14
8
|
get nodeType() {
|
|
15
9
|
return "Quick Look";
|
|
@@ -24,23 +18,20 @@ class QuicklookViewer extends ar_viewer_1.default {
|
|
|
24
18
|
const anchor = document.createElement("a");
|
|
25
19
|
anchor.setAttribute("rel", "ar");
|
|
26
20
|
anchor.appendChild(document.createElement("img"));
|
|
21
|
+
const banner = this.banner;
|
|
27
22
|
let url = this.modelUrl;
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
if (banner) {
|
|
24
|
+
url += `#callToAction=${banner.button}`;
|
|
25
|
+
url += `&checkoutTitle=${banner.title}`;
|
|
26
|
+
url += `&checkoutSubtitle=${banner.subtitle}`;
|
|
30
27
|
const handleQuicklook = (event) => {
|
|
31
28
|
if (event.data === "_apple_ar_quicklook_button_tapped") {
|
|
32
|
-
this.
|
|
29
|
+
window.location.assign(this.composedActionURL);
|
|
33
30
|
}
|
|
34
|
-
document.body.removeChild(anchor);
|
|
35
|
-
anchor.removeEventListener("message", handleQuicklook, false);
|
|
36
31
|
};
|
|
37
32
|
anchor.addEventListener("message", handleQuicklook, false);
|
|
38
|
-
document.body.appendChild(anchor);
|
|
39
|
-
url += "#callToAction=" + araction;
|
|
40
|
-
if (this.titleHTML) {
|
|
41
|
-
url += this.titleHTML;
|
|
42
|
-
}
|
|
43
33
|
}
|
|
34
|
+
document.body.appendChild(anchor);
|
|
44
35
|
anchor.setAttribute("href", encodeURI(url));
|
|
45
36
|
anchor.click();
|
|
46
37
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ar_viewer_1 =
|
|
7
|
-
class RealityViewer extends ar_viewer_1.
|
|
3
|
+
const ar_viewer_1 = require("./ar-viewer");
|
|
4
|
+
class RealityViewer extends ar_viewer_1.ARViewer {
|
|
8
5
|
constructor() {
|
|
9
6
|
super();
|
|
10
7
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ar_viewer_1 =
|
|
7
|
-
class SceneViewer extends ar_viewer_1.
|
|
3
|
+
const ar_viewer_1 = require("./ar-viewer");
|
|
4
|
+
class SceneViewer extends ar_viewer_1.ARViewer {
|
|
8
5
|
constructor() {
|
|
9
6
|
super();
|
|
10
|
-
this.araction = null;
|
|
11
7
|
this.isVertical = false;
|
|
12
|
-
this.titleHTML = "<b>" + document.title;
|
|
13
8
|
this.isVertical = false;
|
|
14
9
|
}
|
|
15
10
|
get nodeType() {
|
|
@@ -22,27 +17,18 @@ class SceneViewer extends ar_viewer_1.default {
|
|
|
22
17
|
if (!this.modelUrl) {
|
|
23
18
|
throw new Error("SceneViewer.start() - model url not set, use SceneViewer.modelUrl");
|
|
24
19
|
}
|
|
25
|
-
const
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const linkOverride = encodeURIComponent(`${location.href}#no-ar-fallback`);
|
|
21
|
+
let intent = `intent://arvr.google.com/scene-viewer/1.1?file=${this.modelUrl}&mode=ar_preferred`;
|
|
22
|
+
const banner = this.banner;
|
|
23
|
+
if (banner) {
|
|
24
|
+
intent += `&title=<b>${banner.title}</b><br>${banner.subtitle}`;
|
|
25
|
+
intent += `&link=${this.composedActionURL}`;
|
|
31
26
|
}
|
|
32
|
-
if (!composedLink) {
|
|
33
|
-
throw new Error("SceneViewer.start() - failed to create composition link, check parameters");
|
|
34
|
-
}
|
|
35
|
-
const linkOverride = encodeURIComponent(location.href + '#no-ar-fallback');
|
|
36
|
-
let intent = 'intent://arvr.google.com/scene-viewer/1.1';
|
|
37
|
-
intent += '?file=' + this.modelUrl;
|
|
38
|
-
intent += '&mode=ar_preferred';
|
|
39
|
-
intent += '&link=' + composedLink;
|
|
40
|
-
intent += '&title=<b>' + this.titleHTML;
|
|
41
27
|
if (this.isVertical) {
|
|
42
28
|
intent += '&enable_vertical_placement=true';
|
|
43
29
|
}
|
|
44
30
|
intent += ' #Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;';
|
|
45
|
-
intent +=
|
|
31
|
+
intent += `S.browser_fallback_url=${linkOverride};end;`;
|
|
46
32
|
const anchor = document.createElement("a");
|
|
47
33
|
anchor.setAttribute("href", intent);
|
|
48
34
|
anchor.click();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plattar/plattar-ar-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.163.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",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"homepage": "https://www.plattar.com",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@plattar/plattar-analytics": "^1.152.2",
|
|
41
|
-
"@plattar/plattar-api": "^1.
|
|
42
|
-
"@plattar/plattar-qrcode": "1.
|
|
41
|
+
"@plattar/plattar-api": "^1.159.1",
|
|
42
|
+
"@plattar/plattar-qrcode": "1.160.1",
|
|
43
43
|
"@plattar/plattar-services": "^1.157.1",
|
|
44
44
|
"@plattar/plattar-web": "^1.154.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/cli": "^7.
|
|
48
|
-
"@babel/core": "^7.
|
|
49
|
-
"@babel/preset-env": "^7.
|
|
47
|
+
"@babel/cli": "^7.23.4",
|
|
48
|
+
"@babel/core": "^7.23.3",
|
|
49
|
+
"@babel/preset-env": "^7.23.3",
|
|
50
50
|
"browserify": "^17.0.0",
|
|
51
|
-
"typescript": "^5.
|
|
51
|
+
"typescript": "^5.3.2",
|
|
52
52
|
"uglify-js": "^3.17.4"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|