@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.
@@ -639,9 +639,6 @@ const plattar_controller_1 = require("./plattar-controller");
639
639
  class ConfiguratorController extends plattar_controller_1.PlattarController {
640
640
  constructor(parent) {
641
641
  super(parent);
642
- this._state = plattar_controller_1.ControllerState.None;
643
- this._element = null;
644
- this._prevQROpt = null;
645
642
  }
646
643
  onAttributesUpdated() {
647
644
  const state = this._state;
@@ -651,7 +648,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
651
648
  return;
652
649
  }
653
650
  }
654
- startQRCode(options) {
651
+ startViewerQRCode(options) {
655
652
  return new Promise((accept, reject) => {
656
653
  // remove the old renderer instance if any
657
654
  this.removeRenderer();
@@ -852,6 +849,7 @@ exports.ConfiguratorController = ConfiguratorController;
852
849
  "use strict";
853
850
  Object.defineProperty(exports, "__esModule", { value: true });
854
851
  exports.PlattarController = exports.ControllerState = void 0;
852
+ const plattar_api_1 = require("@plattar/plattar-api");
855
853
  var ControllerState;
856
854
  (function (ControllerState) {
857
855
  ControllerState[ControllerState["None"] = 0] = "None";
@@ -863,6 +861,9 @@ var ControllerState;
863
861
  */
864
862
  class PlattarController {
865
863
  constructor(parent) {
864
+ this._state = ControllerState.None;
865
+ this._element = null;
866
+ this._prevQROpt = null;
866
867
  this._parent = parent;
867
868
  }
868
869
  /**
@@ -887,6 +888,86 @@ class PlattarController {
887
888
  }).catch(reject);
888
889
  });
889
890
  }
891
+ /**
892
+ * Decide which QR Code to render according to the qr-type attribute
893
+ * @param options
894
+ * @returns
895
+ */
896
+ startQRCode(options) {
897
+ const qrType = this.getAttribute("qr-type") || "viewer";
898
+ switch (qrType.toLowerCase()) {
899
+ case "ar":
900
+ return this.startARQRCode(options);
901
+ case "viewer":
902
+ default:
903
+ return this.startViewerQRCode(options);
904
+ }
905
+ }
906
+ /**
907
+ * Displays a QR Code that sends the user direct to AR
908
+ * @param options
909
+ * @returns
910
+ */
911
+ startARQRCode(options) {
912
+ return new Promise((accept, reject) => {
913
+ // remove the old renderer instance if any
914
+ this.removeRenderer();
915
+ const opt = options || PlattarController.DEFAULT_QR_OPTIONS;
916
+ const viewer = document.createElement("plattar-qrcode");
917
+ // required attributes with defaults for plattar-viewer node
918
+ const width = this.getAttribute("width") || "500px";
919
+ const height = this.getAttribute("height") || "500px";
920
+ viewer.setAttribute("width", width);
921
+ viewer.setAttribute("height", height);
922
+ if (opt.color) {
923
+ viewer.setAttribute("color", opt.color);
924
+ }
925
+ if (opt.margin) {
926
+ viewer.setAttribute("margin", "" + opt.margin);
927
+ }
928
+ if (opt.qrType) {
929
+ viewer.setAttribute("qr-type", opt.qrType);
930
+ }
931
+ const qrOptions = btoa(JSON.stringify(opt));
932
+ let dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
933
+ const sceneID = this.getAttribute("scene-id");
934
+ const configState = this.getAttribute("config-state");
935
+ const embedType = this.getAttribute("embed-type");
936
+ const productID = this.getAttribute("product-id");
937
+ const sceneProductID = this.getAttribute("scene-product-id");
938
+ const variationID = this.getAttribute("variation-id");
939
+ const arMode = this.getAttribute("ar-mode");
940
+ if (configState) {
941
+ dst += "&config_state=" + configState;
942
+ }
943
+ if (embedType) {
944
+ dst += "&embed_type=" + embedType;
945
+ }
946
+ if (productID) {
947
+ dst += "&product_id=" + productID;
948
+ }
949
+ if (sceneProductID) {
950
+ dst += "&scene_product_id=" + sceneProductID;
951
+ }
952
+ if (variationID) {
953
+ dst += "&variation_id=" + variationID;
954
+ }
955
+ if (arMode) {
956
+ dst += "&ar_mode=" + arMode;
957
+ }
958
+ if (sceneID) {
959
+ dst += "&scene_id=" + sceneID;
960
+ }
961
+ viewer.setAttribute("url", opt.url || dst);
962
+ viewer.onload = () => {
963
+ return accept(viewer);
964
+ };
965
+ this._element = viewer;
966
+ this._state = ControllerState.QRCode;
967
+ this._prevQROpt = opt;
968
+ this.append(viewer);
969
+ });
970
+ }
890
971
  /**
891
972
  * Returns the Parent Instance
892
973
  */
@@ -912,7 +993,7 @@ class PlattarController {
912
993
  }
913
994
  exports.PlattarController = PlattarController;
914
995
 
915
- },{}],9:[function(require,module,exports){
996
+ },{"@plattar/plattar-api":42}],9:[function(require,module,exports){
916
997
  "use strict";
917
998
  Object.defineProperty(exports, "__esModule", { value: true });
918
999
  exports.ProductController = void 0;
@@ -926,9 +1007,6 @@ const plattar_controller_1 = require("./plattar-controller");
926
1007
  class ProductController extends plattar_controller_1.PlattarController {
927
1008
  constructor(parent) {
928
1009
  super(parent);
929
- this._state = plattar_controller_1.ControllerState.None;
930
- this._element = null;
931
- this._prevQROpt = null;
932
1010
  }
933
1011
  onAttributesUpdated() {
934
1012
  const state = this._state;
@@ -949,7 +1027,7 @@ class ProductController extends plattar_controller_1.PlattarController {
949
1027
  return;
950
1028
  }
951
1029
  }
952
- startQRCode(options) {
1030
+ startViewerQRCode(options) {
953
1031
  return new Promise((accept, reject) => {
954
1032
  // remove the old renderer instance if any
955
1033
  this.removeRenderer();
@@ -1073,9 +1151,6 @@ const plattar_controller_1 = require("./plattar-controller");
1073
1151
  class ViewerController extends plattar_controller_1.PlattarController {
1074
1152
  constructor(parent) {
1075
1153
  super(parent);
1076
- this._state = plattar_controller_1.ControllerState.None;
1077
- this._element = null;
1078
- this._prevQROpt = null;
1079
1154
  }
1080
1155
  onAttributesUpdated() {
1081
1156
  const state = this._state;
@@ -1097,7 +1172,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
1097
1172
  return;
1098
1173
  }
1099
1174
  }
1100
- startQRCode(options) {
1175
+ startViewerQRCode(options) {
1101
1176
  return new Promise((accept, reject) => {
1102
1177
  // remove the old renderer instance if any
1103
1178
  this.removeRenderer();
@@ -1249,9 +1324,6 @@ const plattar_controller_1 = require("./plattar-controller");
1249
1324
  class VTOController extends plattar_controller_1.PlattarController {
1250
1325
  constructor(parent) {
1251
1326
  super(parent);
1252
- this._state = plattar_controller_1.ControllerState.None;
1253
- this._element = null;
1254
- this._prevQROpt = null;
1255
1327
  }
1256
1328
  onAttributesUpdated() {
1257
1329
  const state = this._state;
@@ -1261,7 +1333,7 @@ class VTOController extends plattar_controller_1.PlattarController {
1261
1333
  return;
1262
1334
  }
1263
1335
  }
1264
- startQRCode(options) {
1336
+ startViewerQRCode(options) {
1265
1337
  return new Promise((accept, reject) => {
1266
1338
  // remove the old renderer instance if any
1267
1339
  this.removeRenderer();
@@ -1981,7 +2053,7 @@ exports.Util = Util;
1981
2053
  },{}],16:[function(require,module,exports){
1982
2054
  "use strict";
1983
2055
  Object.defineProperty(exports, "__esModule", { value: true });
1984
- exports.default = "1.128.1";
2056
+ exports.default = "1.129.1";
1985
2057
 
1986
2058
  },{}],17:[function(require,module,exports){
1987
2059
  "use strict";