@plattar/plattar-ar-adapter 1.155.1 → 1.155.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 +299 -218
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +81 -3
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/embed/controllers/product-controller.d.ts +6 -0
- package/dist/embed/controllers/product-controller.js +70 -0
- package/dist/embed/plattar-embed.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1449,6 +1449,76 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
1449
1449
|
return reject(new Error("ProductController.startQRCode() - minimum required attributes not set, use product-id as a minimum"));
|
|
1450
1450
|
});
|
|
1451
1451
|
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Displays a QR Code that sends the user direct to AR
|
|
1454
|
+
* @param options
|
|
1455
|
+
* @returns
|
|
1456
|
+
*/
|
|
1457
|
+
startARQRCode(options) {
|
|
1458
|
+
return new Promise((accept, reject) => {
|
|
1459
|
+
// remove the old renderer instance if any
|
|
1460
|
+
this.removeRenderer();
|
|
1461
|
+
const opt = options || this._GetDefaultQROptions();
|
|
1462
|
+
const viewer = document.createElement("plattar-qrcode");
|
|
1463
|
+
// required attributes with defaults for plattar-viewer node
|
|
1464
|
+
const width = this.getAttribute("width") || "500px";
|
|
1465
|
+
const height = this.getAttribute("height") || "500px";
|
|
1466
|
+
viewer.setAttribute("width", width);
|
|
1467
|
+
viewer.setAttribute("height", height);
|
|
1468
|
+
if (opt.color) {
|
|
1469
|
+
viewer.setAttribute("color", opt.color);
|
|
1470
|
+
}
|
|
1471
|
+
if (opt.margin) {
|
|
1472
|
+
viewer.setAttribute("margin", "" + opt.margin);
|
|
1473
|
+
}
|
|
1474
|
+
if (opt.qrType) {
|
|
1475
|
+
viewer.setAttribute("qr-type", opt.qrType);
|
|
1476
|
+
}
|
|
1477
|
+
viewer.setAttribute("shorten", (opt.shorten && (opt.shorten === true || opt.shorten === "true")) ? "true" : "false");
|
|
1478
|
+
const qrOptions = btoa(JSON.stringify(opt));
|
|
1479
|
+
let dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
|
|
1480
|
+
const sceneID = this.getAttribute("scene-id");
|
|
1481
|
+
const configState = this.getAttribute("config-state");
|
|
1482
|
+
const embedType = this.getAttribute("embed-type");
|
|
1483
|
+
const productID = this.getAttribute("product-id");
|
|
1484
|
+
const sceneProductID = this.getAttribute("scene-product-id");
|
|
1485
|
+
const variationID = this.getAttribute("variation-id");
|
|
1486
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1487
|
+
const arMode = this.getAttribute("ar-mode");
|
|
1488
|
+
if (configState) {
|
|
1489
|
+
dst += "&config_state=" + configState;
|
|
1490
|
+
}
|
|
1491
|
+
if (embedType) {
|
|
1492
|
+
dst += "&embed_type=" + embedType;
|
|
1493
|
+
}
|
|
1494
|
+
if (productID) {
|
|
1495
|
+
dst += "&product_id=" + productID;
|
|
1496
|
+
}
|
|
1497
|
+
if (sceneProductID) {
|
|
1498
|
+
dst += "&scene_product_id=" + sceneProductID;
|
|
1499
|
+
}
|
|
1500
|
+
if (variationID) {
|
|
1501
|
+
dst += "&variation_id=" + variationID;
|
|
1502
|
+
}
|
|
1503
|
+
if (variationSKU) {
|
|
1504
|
+
dst += "&variation_sku=" + variationSKU;
|
|
1505
|
+
}
|
|
1506
|
+
if (arMode) {
|
|
1507
|
+
dst += "&ar_mode=" + arMode;
|
|
1508
|
+
}
|
|
1509
|
+
if (sceneID) {
|
|
1510
|
+
dst += "&scene_id=" + sceneID;
|
|
1511
|
+
}
|
|
1512
|
+
viewer.setAttribute("url", opt.url || dst);
|
|
1513
|
+
viewer.onload = () => {
|
|
1514
|
+
return accept(viewer);
|
|
1515
|
+
};
|
|
1516
|
+
this._element = viewer;
|
|
1517
|
+
this._state = plattar_controller_1.ControllerState.QRCode;
|
|
1518
|
+
this._prevQROpt = opt;
|
|
1519
|
+
this.append(viewer);
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1452
1522
|
startRenderer() {
|
|
1453
1523
|
return new Promise((accept, reject) => {
|
|
1454
1524
|
// remove the old renderer instance if any
|
|
@@ -1825,9 +1895,8 @@ class PlattarEmbed extends HTMLElement {
|
|
|
1825
1895
|
attributes: true
|
|
1826
1896
|
});
|
|
1827
1897
|
}
|
|
1828
|
-
const sceneID = this.hasAttribute("scene-id") ? this.getAttribute("scene-id") : null;
|
|
1829
1898
|
const productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
|
|
1830
|
-
if (
|
|
1899
|
+
if (productID) {
|
|
1831
1900
|
this._currentType = EmbedType.Legacy;
|
|
1832
1901
|
this._CreateLegacyEmbed();
|
|
1833
1902
|
return;
|
|
@@ -1850,6 +1919,15 @@ class PlattarEmbed extends HTMLElement {
|
|
|
1850
1919
|
*/
|
|
1851
1920
|
_CreateLegacyEmbed() {
|
|
1852
1921
|
this._controller = new product_controller_1.ProductController(this);
|
|
1922
|
+
const init = this.hasAttribute("init") ? this.getAttribute("init") : null;
|
|
1923
|
+
switch (init) {
|
|
1924
|
+
case "viewer":
|
|
1925
|
+
this.startViewer();
|
|
1926
|
+
break;
|
|
1927
|
+
case "qrcode":
|
|
1928
|
+
this.startQRCode();
|
|
1929
|
+
break;
|
|
1930
|
+
}
|
|
1853
1931
|
}
|
|
1854
1932
|
/**
|
|
1855
1933
|
* creates the embed
|
|
@@ -2435,7 +2513,7 @@ exports.Util = Util;
|
|
|
2435
2513
|
},{}],16:[function(require,module,exports){
|
|
2436
2514
|
"use strict";
|
|
2437
2515
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2438
|
-
exports.default = "1.155.
|
|
2516
|
+
exports.default = "1.155.2";
|
|
2439
2517
|
|
|
2440
2518
|
},{}],17:[function(require,module,exports){
|
|
2441
2519
|
"use strict";
|