@perceptimagery/dita-configurator-staging 0.1.9001 → 0.2.1000
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/dist/index.js +98 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var __publicField = (obj, key, value) => {
|
|
|
18
18
|
return value;
|
|
19
19
|
};
|
|
20
20
|
(function() {
|
|
21
|
+
var _a, _b;
|
|
21
22
|
"use strict";
|
|
22
23
|
class FetcherServiceFactory {
|
|
23
24
|
constructor(config2) {
|
|
@@ -111,7 +112,7 @@ var __publicField = (obj, key, value) => {
|
|
|
111
112
|
host: "https://api.sprie.io"
|
|
112
113
|
};
|
|
113
114
|
const config$1 = Object.freeze(Config$2);
|
|
114
|
-
const version$1 = "0.
|
|
115
|
+
const version$1 = "0.2.1000";
|
|
115
116
|
function modifyLensArr$1(arr, element) {
|
|
116
117
|
const index = arr.findIndex((e) => e["sku"] === element["sku"]);
|
|
117
118
|
if (index !== -1) {
|
|
@@ -120,13 +121,15 @@ var __publicField = (obj, key, value) => {
|
|
|
120
121
|
return arr;
|
|
121
122
|
}
|
|
122
123
|
class APIServiceFactory {
|
|
123
|
-
constructor(fetcher2) {
|
|
124
|
+
constructor(fetcher2, shopifyAPI) {
|
|
124
125
|
__publicField(this, "isAuthenticated");
|
|
125
126
|
__publicField(this, "fetcher");
|
|
127
|
+
__publicField(this, "shopifyAPI");
|
|
126
128
|
__publicField(this, "org");
|
|
127
129
|
__publicField(this, "apiKey");
|
|
128
130
|
this.isAuthenticated = false;
|
|
129
131
|
this.fetcher = fetcher2;
|
|
132
|
+
this.shopifyAPI = shopifyAPI;
|
|
130
133
|
}
|
|
131
134
|
/**
|
|
132
135
|
*
|
|
@@ -209,6 +212,18 @@ var __publicField = (obj, key, value) => {
|
|
|
209
212
|
await this.fetcher.Post(url, bodyData);
|
|
210
213
|
}
|
|
211
214
|
}
|
|
215
|
+
async HandleShopifyAddToCart(items) {
|
|
216
|
+
let formData = {
|
|
217
|
+
"items": items
|
|
218
|
+
};
|
|
219
|
+
const responseData = await this.shopifyAPI.Post(formData);
|
|
220
|
+
if (responseData) {
|
|
221
|
+
const cart = await this.shopifyAPI.Get();
|
|
222
|
+
document.querySelector(".header__cart-count").textContent = cart.item_count;
|
|
223
|
+
document.querySelector(".drawer--full").setAttribute("close", "");
|
|
224
|
+
document.querySelector(".mini-cart").setAttribute("open", "");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
212
227
|
}
|
|
213
228
|
var ESDKStatus = /* @__PURE__ */ ((ESDKStatus2) => {
|
|
214
229
|
ESDKStatus2["Init"] = "init";
|
|
@@ -1003,38 +1018,37 @@ var __publicField = (obj, key, value) => {
|
|
|
1003
1018
|
(item) => item.key == "baseCurve"
|
|
1004
1019
|
);
|
|
1005
1020
|
let lensVariantKey = "variantId";
|
|
1006
|
-
if (baseCurve.value == "2B") {
|
|
1021
|
+
if (baseCurve && baseCurve.value == "2B") {
|
|
1007
1022
|
lensVariantKey = "2bVariantId";
|
|
1008
|
-
} else if (baseCurve.value == "6B") {
|
|
1023
|
+
} else if (baseCurve && baseCurve.value == "6B") {
|
|
1009
1024
|
lensVariantKey = "6bVariantId";
|
|
1010
1025
|
}
|
|
1011
1026
|
const lensVariantId = selectedLens.metadata.find(
|
|
1012
1027
|
(item) => item.key == lensVariantKey
|
|
1013
1028
|
);
|
|
1014
|
-
const frameId = frameVariantId ? frameVariantId.value : null;
|
|
1015
|
-
const lensId = lensVariantId ? lensVariantId.value : null;
|
|
1029
|
+
const frameId = frameVariantId ? Number(frameVariantId.value) : null;
|
|
1030
|
+
const lensId = lensVariantId ? Number(lensVariantId.value) : null;
|
|
1016
1031
|
const eventData = {
|
|
1017
1032
|
frameIdentifier: frameId,
|
|
1018
1033
|
lensIdentifier: lensId
|
|
1019
1034
|
};
|
|
1020
1035
|
customEvent.emitEvent("onAddToCart", eventData);
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
"Either the selected frame or the lens has an invalid identifier."
|
|
1036
|
-
);
|
|
1036
|
+
var cartItems = [];
|
|
1037
|
+
if (frameVariantId) {
|
|
1038
|
+
var frameItem = {
|
|
1039
|
+
id: frameId,
|
|
1040
|
+
quantity: 1
|
|
1041
|
+
};
|
|
1042
|
+
cartItems.push(frameItem);
|
|
1043
|
+
}
|
|
1044
|
+
if (lensVariantId) {
|
|
1045
|
+
var lensItem = {
|
|
1046
|
+
id: lensId,
|
|
1047
|
+
quantity: 1
|
|
1048
|
+
};
|
|
1049
|
+
cartItems.push(lensItem);
|
|
1037
1050
|
}
|
|
1051
|
+
apiService2.HandleShopifyAddToCart(cartItems);
|
|
1038
1052
|
}
|
|
1039
1053
|
},
|
|
1040
1054
|
type: "button",
|
|
@@ -42895,18 +42909,18 @@ bool bvhIntersectFirstHit(
|
|
|
42895
42909
|
this.isInitialised = true;
|
|
42896
42910
|
}
|
|
42897
42911
|
resizeRenderer() {
|
|
42898
|
-
var
|
|
42912
|
+
var _a2;
|
|
42899
42913
|
const pixelRatio = Math.min(window.devicePixelRatio, 2);
|
|
42900
42914
|
const resoWidth = Math.floor(this.canvas.clientWidth * pixelRatio);
|
|
42901
42915
|
const resoHeight = Math.floor(this.canvas.clientHeight * pixelRatio);
|
|
42902
42916
|
const needResize = this.canvas.width !== resoWidth || this.canvas.height !== resoHeight;
|
|
42903
42917
|
if (needResize) {
|
|
42904
|
-
(
|
|
42918
|
+
(_a2 = this.renderer) == null ? void 0 : _a2.setSize(resoWidth, resoHeight, false);
|
|
42905
42919
|
}
|
|
42906
42920
|
return needResize;
|
|
42907
42921
|
}
|
|
42908
42922
|
initGemstoneDependencies() {
|
|
42909
|
-
var
|
|
42923
|
+
var _a2;
|
|
42910
42924
|
rgbeLoader.load(
|
|
42911
42925
|
"https://sprie-jarvis-public.s3.eu-west-2.amazonaws.com/environment_gemstones.hdr",
|
|
42912
42926
|
(reflectionMap) => {
|
|
@@ -42921,7 +42935,7 @@ bool bvhIntersectFirstHit(
|
|
|
42921
42935
|
gemstoneMaterial.uniforms.resolution.value = this.canvasSize;
|
|
42922
42936
|
const temp5 = {};
|
|
42923
42937
|
const isCubeMap = isCubeTexture(envMap);
|
|
42924
|
-
const w2 = (isCubeMap ? (
|
|
42938
|
+
const w2 = (isCubeMap ? (_a2 = envMap == null ? void 0 : envMap.image[0]) == null ? void 0 : _a2.width : envMap == null ? void 0 : envMap.image.width) ?? 1024;
|
|
42925
42939
|
const cubeSize = w2 / 4;
|
|
42926
42940
|
const _lodMax = Math.floor(Math.log2(cubeSize));
|
|
42927
42941
|
const _cubeSize = Math.pow(2, _lodMax);
|
|
@@ -43361,11 +43375,11 @@ bool bvhIntersectFirstHit(
|
|
|
43361
43375
|
composer.addPass(renderPass);
|
|
43362
43376
|
composer.addPass(outputPass);
|
|
43363
43377
|
const animate = () => {
|
|
43364
|
-
var
|
|
43378
|
+
var _a2;
|
|
43365
43379
|
controls.update();
|
|
43366
43380
|
if (this.resizeRenderer()) {
|
|
43367
43381
|
this.camera.aspect = this.canvas.clientWidth / this.canvas.clientHeight;
|
|
43368
|
-
(
|
|
43382
|
+
(_a2 = this.camera) == null ? void 0 : _a2.updateProjectionMatrix();
|
|
43369
43383
|
}
|
|
43370
43384
|
const initialBackground = this.scene.background;
|
|
43371
43385
|
this.scene.background = null;
|
|
@@ -43537,9 +43551,9 @@ bool bvhIntersectFirstHit(
|
|
|
43537
43551
|
const orgName = (settings == null ? void 0 : settings.orgName) || "";
|
|
43538
43552
|
reactExports.useEffect(() => {
|
|
43539
43553
|
(async () => {
|
|
43540
|
-
var
|
|
43554
|
+
var _a2;
|
|
43541
43555
|
configurator.current = new ThreeDConfigurator();
|
|
43542
|
-
await ((
|
|
43556
|
+
await ((_a2 = configurator.current) == null ? void 0 : _a2.Init(apiService2.apiKey));
|
|
43543
43557
|
const apiRes = await apiService2.FetchAssetBySKUOrBarcode({
|
|
43544
43558
|
sku,
|
|
43545
43559
|
barcode: null
|
|
@@ -51234,6 +51248,55 @@ bool bvhIntersectFirstHit(
|
|
|
51234
51248
|
onAddToCart: "add-to-cart"
|
|
51235
51249
|
});
|
|
51236
51250
|
let CustomEventEmitter = _CustomEventEmitter2;
|
|
51251
|
+
const ShopifyConfig = {
|
|
51252
|
+
getCartUrl: ((_a = window.Shopify) == null ? void 0 : _a.routes.root) + "/cart.js",
|
|
51253
|
+
addToCartUrl: ((_b = window.Shopify) == null ? void 0 : _b.routes.root) + "/cart/add.js"
|
|
51254
|
+
};
|
|
51255
|
+
const configShopify = Object.freeze(ShopifyConfig);
|
|
51256
|
+
class ShopifyServiceFactory {
|
|
51257
|
+
constructor(config2) {
|
|
51258
|
+
__publicField(this, "config");
|
|
51259
|
+
this.config = config2;
|
|
51260
|
+
}
|
|
51261
|
+
RequestOptions(method, data) {
|
|
51262
|
+
const headers = {
|
|
51263
|
+
Accept: "application/json",
|
|
51264
|
+
"Content-Type": "application/json"
|
|
51265
|
+
};
|
|
51266
|
+
return {
|
|
51267
|
+
method,
|
|
51268
|
+
headers,
|
|
51269
|
+
...method === "POST" && {
|
|
51270
|
+
body: JSON.stringify(data)
|
|
51271
|
+
}
|
|
51272
|
+
};
|
|
51273
|
+
}
|
|
51274
|
+
/**
|
|
51275
|
+
* @description nice and tidy reuqest wrapper
|
|
51276
|
+
* @returns
|
|
51277
|
+
*/
|
|
51278
|
+
async Get() {
|
|
51279
|
+
await fetch(this.config.getCartUrl, this.RequestOptions("GET")).then((response) => {
|
|
51280
|
+
const result = response.json();
|
|
51281
|
+
return result;
|
|
51282
|
+
}).catch((e) => {
|
|
51283
|
+
console.error("Error:", e);
|
|
51284
|
+
});
|
|
51285
|
+
}
|
|
51286
|
+
/**
|
|
51287
|
+
* @description nice and tidy reuqest wrapper
|
|
51288
|
+
* @param {object} data body Data
|
|
51289
|
+
* @returns
|
|
51290
|
+
*/
|
|
51291
|
+
async Post(data) {
|
|
51292
|
+
await fetch(this.config.addToCartUrl, this.RequestOptions("POST", data || {})).then((response) => {
|
|
51293
|
+
const result = response.json();
|
|
51294
|
+
return result;
|
|
51295
|
+
}).catch((e) => {
|
|
51296
|
+
console.error("Error:", e);
|
|
51297
|
+
});
|
|
51298
|
+
}
|
|
51299
|
+
}
|
|
51237
51300
|
const { log, error } = console;
|
|
51238
51301
|
const logErr = (...data) => {
|
|
51239
51302
|
error("❌ Sprie Error:", ...data);
|
|
@@ -51243,6 +51306,10 @@ bool bvhIntersectFirstHit(
|
|
|
51243
51306
|
HOST: config$1.host,
|
|
51244
51307
|
STORE_PREFIX: config$1.storePrefix
|
|
51245
51308
|
};
|
|
51309
|
+
const shopifyConfig = {
|
|
51310
|
+
addToCartUrl: configShopify.addToCartUrl,
|
|
51311
|
+
getCartUrl: configShopify.getCartUrl
|
|
51312
|
+
};
|
|
51246
51313
|
class DitaConfiguratorPublicAPI {
|
|
51247
51314
|
constructor() {
|
|
51248
51315
|
__publicField(this, "sdkService");
|
|
@@ -51250,7 +51317,7 @@ bool bvhIntersectFirstHit(
|
|
|
51250
51317
|
__publicField(this, "uiService");
|
|
51251
51318
|
__publicField(this, "events");
|
|
51252
51319
|
this.events = new CustomEventEmitter();
|
|
51253
|
-
this.apiService = new APIServiceFactory(new FetcherServiceFactory(fetcherConfig));
|
|
51320
|
+
this.apiService = new APIServiceFactory(new FetcherServiceFactory(fetcherConfig), new ShopifyServiceFactory(shopifyConfig));
|
|
51254
51321
|
this.uiService = new UIService({
|
|
51255
51322
|
apiService: this.apiService,
|
|
51256
51323
|
events: this.events
|