zakeke-configurator-react 0.0.53 → 0.0.57
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.
|
@@ -23,7 +23,7 @@ export declare class ZakekeEnvironment {
|
|
|
23
23
|
private previousMeshesVisibleStates;
|
|
24
24
|
get internalProduct(): MPlaza.Model | null;
|
|
25
25
|
get internalScene(): Zakeke.Scene | null;
|
|
26
|
-
get internalCurrentTemplate():
|
|
26
|
+
get internalCurrentTemplate(): MPlaza.Design | null | undefined;
|
|
27
27
|
currency: string;
|
|
28
28
|
groups: Group[];
|
|
29
29
|
fonts: FontFamily[];
|
|
@@ -48,7 +48,6 @@ export declare class ZakekeEnvironment {
|
|
|
48
48
|
private getComposerModels;
|
|
49
49
|
private getFonts;
|
|
50
50
|
private getSettings;
|
|
51
|
-
private loadFonts;
|
|
52
51
|
private loadScript;
|
|
53
52
|
boot: (parameters?: any) => Promise<void>;
|
|
54
53
|
appendViewer: (container: HTMLElement) => void;
|
|
@@ -59,6 +58,8 @@ export declare class ZakekeEnvironment {
|
|
|
59
58
|
renderDesign: _.DebouncedFunc<() => Promise<void>>;
|
|
60
59
|
private handleSceneLoaded;
|
|
61
60
|
private getComposition;
|
|
61
|
+
private getDesign;
|
|
62
|
+
private internalLoadDesign;
|
|
62
63
|
loadComposition: (id: string | null) => Promise<void>;
|
|
63
64
|
private internalLoadComposition;
|
|
64
65
|
private handleAttributeSelectionChanged;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FontFamily } from ".";
|
|
2
|
+
/**
|
|
3
|
+
* Download a list of font families so that are available for the browser
|
|
4
|
+
*/
|
|
5
|
+
export declare function loadFonts(fontFamilies: FontFamily[]): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Downlod all fonts used in a design
|
|
8
|
+
*
|
|
9
|
+
* @param design Design to load fonts for
|
|
10
|
+
* @param downloadedFonts A list of downloaded fonts
|
|
11
|
+
*/
|
|
12
|
+
export declare function downloadFontsOfDesign(design: MPlaza.Design, downloadedFonts: FontFamily[]): Promise<void>;
|
|
@@ -5,7 +5,7 @@ import { FocusAttributesEventListener } from "../../../../3D/src";
|
|
|
5
5
|
export interface ProviderValue {
|
|
6
6
|
internalProduct: MPlaza.Model | null;
|
|
7
7
|
internalScene: Zakeke.Scene | null;
|
|
8
|
-
internalCurrentTemplate: MPlaza.Design;
|
|
8
|
+
internalCurrentTemplate: MPlaza.Design | null | undefined;
|
|
9
9
|
price: number;
|
|
10
10
|
culture: string;
|
|
11
11
|
currency: string;
|
package/dist/index.js
CHANGED
|
@@ -40950,7 +40950,7 @@ var ZakekeDesigner = react__WEBPACK_IMPORTED_MODULE_0__["forwardRef"](function (
|
|
|
40950
40950
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () {
|
|
40951
40951
|
if (internalProduct) {
|
|
40952
40952
|
var side = internalProduct.get("colors").at(0).get("sides").find(function (x) { return x.get('sideID') == props.areaId; });
|
|
40953
|
-
if (side && customizer) {
|
|
40953
|
+
if (side && customizer && internalCurrentTemplate) {
|
|
40954
40954
|
customizer.setDesign(internalCurrentTemplate);
|
|
40955
40955
|
customizer.setSide(side);
|
|
40956
40956
|
customizer.adaptZoomToSideAreas(false);
|
|
@@ -41049,6 +41049,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
41049
41049
|
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
|
|
41050
41050
|
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_7__);
|
|
41051
41051
|
/* harmony import */ var _3D_src__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../3D/src */ "../../3D/src/index.ts");
|
|
41052
|
+
/* harmony import */ var _fontsManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fontsManager */ "./src/fontsManager.ts");
|
|
41052
41053
|
var __assign = (undefined && undefined.__assign) || function () {
|
|
41053
41054
|
__assign = Object.assign || function(t) {
|
|
41054
41055
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -41112,6 +41113,7 @@ var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
|
|
|
41112
41113
|
|
|
41113
41114
|
|
|
41114
41115
|
|
|
41116
|
+
|
|
41115
41117
|
var ZakekeEnvironment = /** @class */ (function () {
|
|
41116
41118
|
function ZakekeEnvironment() {
|
|
41117
41119
|
var _this = this;
|
|
@@ -41122,6 +41124,7 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41122
41124
|
this.events = [];
|
|
41123
41125
|
this.zkProduct = null;
|
|
41124
41126
|
this.zkScene = null;
|
|
41127
|
+
this.zkCurrentTemplate = null;
|
|
41125
41128
|
this.zkTemplates = [];
|
|
41126
41129
|
this.internalIsFullscreen = false;
|
|
41127
41130
|
this.highlightSettings = null;
|
|
@@ -41374,22 +41377,6 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41374
41377
|
}
|
|
41375
41378
|
});
|
|
41376
41379
|
}); };
|
|
41377
|
-
this.loadFonts = function (fontFamilies) { return __awaiter(_this, void 0, void 0, function () {
|
|
41378
|
-
return __generator(this, function (_a) {
|
|
41379
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
41380
|
-
WebFont.load({
|
|
41381
|
-
timeout: 200000,
|
|
41382
|
-
custom: {
|
|
41383
|
-
families: fontFamilies.map(function (x) { return x.name + (x.variations && x.variations != "" ? ":" + x.variations : ""); }),
|
|
41384
|
-
urls: fontFamilies.map(function (x) { return x.cssUrl; })
|
|
41385
|
-
},
|
|
41386
|
-
active: function () {
|
|
41387
|
-
resolve();
|
|
41388
|
-
}
|
|
41389
|
-
});
|
|
41390
|
-
})];
|
|
41391
|
-
});
|
|
41392
|
-
}); };
|
|
41393
41380
|
this.loadScript = function (src) { return __awaiter(_this, void 0, void 0, function () {
|
|
41394
41381
|
return __generator(this, function (_a) {
|
|
41395
41382
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
@@ -41542,6 +41529,39 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41542
41529
|
})];
|
|
41543
41530
|
});
|
|
41544
41531
|
}); };
|
|
41532
|
+
this.getDesign = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
41533
|
+
return __generator(this, function (_a) {
|
|
41534
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
41535
|
+
var design = new MPlaza.Design();
|
|
41536
|
+
design.set("docID", id);
|
|
41537
|
+
design.fetch({
|
|
41538
|
+
success: function (model) {
|
|
41539
|
+
resolve(model);
|
|
41540
|
+
},
|
|
41541
|
+
error: function () {
|
|
41542
|
+
reject();
|
|
41543
|
+
}
|
|
41544
|
+
});
|
|
41545
|
+
})];
|
|
41546
|
+
});
|
|
41547
|
+
}); };
|
|
41548
|
+
this.internalLoadDesign = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
41549
|
+
var _a;
|
|
41550
|
+
return __generator(this, function (_b) {
|
|
41551
|
+
switch (_b.label) {
|
|
41552
|
+
case 0:
|
|
41553
|
+
_a = this;
|
|
41554
|
+
return [4 /*yield*/, this.getDesign(this.composition.get("designDocID"))];
|
|
41555
|
+
case 1:
|
|
41556
|
+
_a.zkCurrentTemplate = _b.sent();
|
|
41557
|
+
return [4 /*yield*/, Object(_fontsManager__WEBPACK_IMPORTED_MODULE_9__["downloadFontsOfDesign"])(this.zkCurrentTemplate, this.fonts)];
|
|
41558
|
+
case 2:
|
|
41559
|
+
_b.sent();
|
|
41560
|
+
this.renderDesign();
|
|
41561
|
+
return [2 /*return*/];
|
|
41562
|
+
}
|
|
41563
|
+
});
|
|
41564
|
+
}); };
|
|
41545
41565
|
this.loadComposition = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
41546
41566
|
return __generator(this, function (_a) {
|
|
41547
41567
|
switch (_a.label) {
|
|
@@ -41549,7 +41569,6 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41549
41569
|
case 1:
|
|
41550
41570
|
_a.sent();
|
|
41551
41571
|
this.buildStructure();
|
|
41552
|
-
this.renderDesign();
|
|
41553
41572
|
return [2 /*return*/];
|
|
41554
41573
|
}
|
|
41555
41574
|
});
|
|
@@ -41560,14 +41579,19 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41560
41579
|
return __generator(this, function (_c) {
|
|
41561
41580
|
switch (_c.label) {
|
|
41562
41581
|
case 0:
|
|
41563
|
-
if (!id) return [3 /*break*/,
|
|
41582
|
+
if (!id) return [3 /*break*/, 4];
|
|
41564
41583
|
_a = this;
|
|
41565
41584
|
return [4 /*yield*/, this.getComposition(id)];
|
|
41566
41585
|
case 1:
|
|
41567
41586
|
_a.composition = _c.sent();
|
|
41568
41587
|
this.selection.setupOnComposition(this.composition);
|
|
41569
|
-
return [3 /*break*/, 3];
|
|
41588
|
+
if (!this.composition.get("designDocID")) return [3 /*break*/, 3];
|
|
41589
|
+
return [4 /*yield*/, this.internalLoadDesign(this.composition.get("designDocID"))];
|
|
41570
41590
|
case 2:
|
|
41591
|
+
_c.sent();
|
|
41592
|
+
_c.label = 3;
|
|
41593
|
+
case 3: return [3 /*break*/, 5];
|
|
41594
|
+
case 4:
|
|
41571
41595
|
this.composition = this.selection.buildComposition();
|
|
41572
41596
|
_loop_1 = function (platformSelection) {
|
|
41573
41597
|
// Search the attribute
|
|
@@ -41591,8 +41615,8 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41591
41615
|
platformSelection = _b[_i];
|
|
41592
41616
|
_loop_1(platformSelection);
|
|
41593
41617
|
}
|
|
41594
|
-
_c.label =
|
|
41595
|
-
case
|
|
41618
|
+
_c.label = 5;
|
|
41619
|
+
case 5:
|
|
41596
41620
|
// Add all composition attributes to the platformAttributes that we will send to the plugin
|
|
41597
41621
|
this.selection.get("groups").each(function (group) {
|
|
41598
41622
|
group.get("attributes").each(function (attribute) {
|
|
@@ -41612,7 +41636,7 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41612
41636
|
script = this.selection.getAllAttributeTransformationScript();
|
|
41613
41637
|
this.viewer.adjustCamera(false);
|
|
41614
41638
|
return [4 /*yield*/, this.viewer.executeScriptAsync(script)];
|
|
41615
|
-
case
|
|
41639
|
+
case 6:
|
|
41616
41640
|
_c.sent();
|
|
41617
41641
|
this.selection.on("attributeSelectionChanged", function (e) {
|
|
41618
41642
|
_this.handleAttributeSelectionChanged(e);
|
|
@@ -41858,14 +41882,16 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41858
41882
|
return __generator(this, function (_a) {
|
|
41859
41883
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
41860
41884
|
var design = _this.zkCurrentTemplate;
|
|
41861
|
-
if (!design)
|
|
41885
|
+
if (!design) {
|
|
41862
41886
|
resolve();
|
|
41887
|
+
return;
|
|
41888
|
+
}
|
|
41863
41889
|
design.save(null, {
|
|
41864
|
-
success: function (model
|
|
41865
|
-
_this.composition.set("designDocID", model.
|
|
41890
|
+
success: function (model) {
|
|
41891
|
+
_this.composition.set("designDocID", model.get("docID"));
|
|
41866
41892
|
resolve();
|
|
41867
41893
|
},
|
|
41868
|
-
error: function (
|
|
41894
|
+
error: function () {
|
|
41869
41895
|
reject();
|
|
41870
41896
|
}
|
|
41871
41897
|
});
|
|
@@ -41941,17 +41967,12 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41941
41967
|
if (!design)
|
|
41942
41968
|
throw "Template does not exists with id " + templateId;
|
|
41943
41969
|
var designSide = design.getDesignSide(_this.zkProduct.get("colors").at(0).get("sides").get(areaId));
|
|
41944
|
-
var getRestriction = function (restriction) {
|
|
41945
|
-
if (designSide)
|
|
41946
|
-
return designSide.get(restriction);
|
|
41947
|
-
else
|
|
41948
|
-
design.get(restriction);
|
|
41949
|
-
};
|
|
41950
41970
|
var getUploadRestriction = function (restriction) {
|
|
41971
|
+
var _a, _b;
|
|
41951
41972
|
if (designSide && designSide.get("uploadRestrictions"))
|
|
41952
|
-
return designSide.get("uploadRestrictions")[restriction];
|
|
41973
|
+
return (_a = designSide.get("uploadRestrictions")) === null || _a === void 0 ? void 0 : _a[restriction];
|
|
41953
41974
|
else if (design.get("uploadRestrictions"))
|
|
41954
|
-
design.get("uploadRestrictions")[restriction];
|
|
41975
|
+
(_b = design.get("uploadRestrictions")) === null || _b === void 0 ? void 0 : _b[restriction];
|
|
41955
41976
|
else
|
|
41956
41977
|
return null;
|
|
41957
41978
|
};
|
|
@@ -41967,28 +41988,31 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
41967
41988
|
var _this = this;
|
|
41968
41989
|
return __generator(this, function (_a) {
|
|
41969
41990
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
41970
|
-
var templatesList, templates, _i, _a,
|
|
41971
|
-
return __generator(this, function (
|
|
41972
|
-
switch (
|
|
41991
|
+
var templatesList, templates, _i, _a, _template, template;
|
|
41992
|
+
return __generator(this, function (_b) {
|
|
41993
|
+
switch (_b.label) {
|
|
41973
41994
|
case 0: return [4 /*yield*/, _api__WEBPACK_IMPORTED_MODULE_6__["axiosApi"].get("designs/templates/" + this.zkProduct.get('modelID'))];
|
|
41974
41995
|
case 1:
|
|
41975
|
-
templatesList = (
|
|
41996
|
+
templatesList = (_b.sent()).data;
|
|
41976
41997
|
templates = [];
|
|
41977
|
-
if (!(templatesList.length > 0)) return [3 /*break*/,
|
|
41998
|
+
if (!(templatesList.length > 0)) return [3 /*break*/, 6];
|
|
41978
41999
|
_i = 0, _a = templatesList[0].categories[0].templates;
|
|
41979
|
-
|
|
42000
|
+
_b.label = 2;
|
|
41980
42001
|
case 2:
|
|
41981
|
-
if (!(_i < _a.length)) return [3 /*break*/,
|
|
41982
|
-
|
|
41983
|
-
|
|
41984
|
-
return [4 /*yield*/, this.getTemplate(template.designID)];
|
|
42002
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
42003
|
+
_template = _a[_i];
|
|
42004
|
+
return [4 /*yield*/, this.getTemplate(_template.designID)];
|
|
41985
42005
|
case 3:
|
|
41986
|
-
|
|
41987
|
-
|
|
42006
|
+
template = _b.sent();
|
|
42007
|
+
return [4 /*yield*/, Object(_fontsManager__WEBPACK_IMPORTED_MODULE_9__["downloadFontsOfDesign"])(template, this.fonts)];
|
|
41988
42008
|
case 4:
|
|
42009
|
+
_b.sent();
|
|
42010
|
+
templates.push(template);
|
|
42011
|
+
_b.label = 5;
|
|
42012
|
+
case 5:
|
|
41989
42013
|
_i++;
|
|
41990
42014
|
return [3 /*break*/, 2];
|
|
41991
|
-
case
|
|
42015
|
+
case 6:
|
|
41992
42016
|
resolve(templates);
|
|
41993
42017
|
return [2 /*return*/];
|
|
41994
42018
|
}
|
|
@@ -42004,34 +42028,13 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
42004
42028
|
var design = new MPlaza.Design();
|
|
42005
42029
|
design.set("docID", templateId);
|
|
42006
42030
|
design.fetch({
|
|
42007
|
-
success: function (
|
|
42008
|
-
|
|
42009
|
-
|
|
42010
|
-
|
|
42011
|
-
switch (_b.label) {
|
|
42012
|
-
case 0:
|
|
42013
|
-
fonts = [];
|
|
42014
|
-
for (_i = 0, _a = design.get("designItems").models; _i < _a.length; _i++) {
|
|
42015
|
-
item = _a[_i];
|
|
42016
|
-
data = JSON.parse(item.get("json"));
|
|
42017
|
-
attributes = data[1];
|
|
42018
|
-
fontFamily = attributes.fontFamily || (attributes.children && attributes.children.length > 0 && attributes.children[0].length > 1 ? attributes.children[0][1].fontFamily : null);
|
|
42019
|
-
if (fontFamily)
|
|
42020
|
-
fonts.push(fontFamily.replace(/"/g, ""));
|
|
42021
|
-
}
|
|
42022
|
-
fontFamilies = fonts.map(function (fontName) { return _this.fonts.find(function (fontFamily) { return fontFamily.name == fontName; }) || null; }).filter(function (x) { return x != null; });
|
|
42023
|
-
if (!(fontFamilies.length > 0)) return [3 /*break*/, 2];
|
|
42024
|
-
return [4 /*yield*/, this.loadFonts(fontFamilies)];
|
|
42025
|
-
case 1:
|
|
42026
|
-
_b.sent();
|
|
42027
|
-
_b.label = 2;
|
|
42028
|
-
case 2:
|
|
42029
|
-
resolve(design);
|
|
42030
|
-
return [2 /*return*/];
|
|
42031
|
-
}
|
|
42031
|
+
success: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
42032
|
+
return __generator(this, function (_a) {
|
|
42033
|
+
resolve(design);
|
|
42034
|
+
return [2 /*return*/];
|
|
42032
42035
|
});
|
|
42033
42036
|
}); },
|
|
42034
|
-
error: function (
|
|
42037
|
+
error: function () { return null; },
|
|
42035
42038
|
data: {
|
|
42036
42039
|
template: true
|
|
42037
42040
|
}
|
|
@@ -42277,18 +42280,25 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
42277
42280
|
throw "Called set item color but no viewer or viewer not ready";
|
|
42278
42281
|
};
|
|
42279
42282
|
this.setItemFontFamily = function (guid, fontFamily) { return __awaiter(_this, void 0, void 0, function () {
|
|
42283
|
+
var font;
|
|
42280
42284
|
return __generator(this, function (_a) {
|
|
42281
42285
|
switch (_a.label) {
|
|
42282
42286
|
case 0:
|
|
42283
|
-
if (!this.viewer) return [3 /*break*/,
|
|
42284
|
-
|
|
42287
|
+
if (!this.viewer) return [3 /*break*/, 4];
|
|
42288
|
+
font = this.fonts.find(function (x) { return x.name === fontFamily; });
|
|
42289
|
+
if (!font) return [3 /*break*/, 2];
|
|
42290
|
+
return [4 /*yield*/, Object(_fontsManager__WEBPACK_IMPORTED_MODULE_9__["loadFonts"])([font])];
|
|
42285
42291
|
case 1:
|
|
42286
42292
|
_a.sent();
|
|
42287
42293
|
this.viewer.setDesignItemFontFamily(guid, fontFamily);
|
|
42288
42294
|
this.fireItemsChange();
|
|
42289
42295
|
return [3 /*break*/, 3];
|
|
42290
|
-
case 2:
|
|
42291
|
-
|
|
42296
|
+
case 2:
|
|
42297
|
+
console.warn("No font found for " + fontFamily);
|
|
42298
|
+
_a.label = 3;
|
|
42299
|
+
case 3: return [3 /*break*/, 5];
|
|
42300
|
+
case 4: throw "Called set item font family but no viewer or viewer not ready";
|
|
42301
|
+
case 5: return [2 /*return*/];
|
|
42292
42302
|
}
|
|
42293
42303
|
});
|
|
42294
42304
|
}); };
|
|
@@ -42445,19 +42455,28 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
42445
42455
|
});
|
|
42446
42456
|
}); };
|
|
42447
42457
|
this.getPDF = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
42448
|
-
var data, pdf;
|
|
42458
|
+
var data, params, pdf;
|
|
42449
42459
|
return __generator(this, function (_a) {
|
|
42450
42460
|
switch (_a.label) {
|
|
42451
42461
|
case 0: return [4 /*yield*/, this.getScreenshot(2048, 2048)];
|
|
42452
42462
|
case 1:
|
|
42453
42463
|
data = _a.sent();
|
|
42454
|
-
|
|
42455
|
-
|
|
42456
|
-
|
|
42457
|
-
|
|
42458
|
-
|
|
42459
|
-
|
|
42460
|
-
|
|
42464
|
+
params = {
|
|
42465
|
+
environment: 2,
|
|
42466
|
+
productName: this.zkProduct.get('name'),
|
|
42467
|
+
sides: [],
|
|
42468
|
+
previewImage: data,
|
|
42469
|
+
selectedOptions: this.platformAttributesSelection.filter(function (x) { return x.attributeIsEnabled && x.attributeIsEnabled; }).map(function (_a) {
|
|
42470
|
+
var attributeLabel = _a.attributeLabel, attributeCode = _a.attributeCode, optionCode = _a.optionCode, optionLabel = _a.optionLabel;
|
|
42471
|
+
return ({
|
|
42472
|
+
attributeLabel: attributeLabel,
|
|
42473
|
+
attributeCode: !Object(_helpers__WEBPACK_IMPORTED_MODULE_0__["isPlatformCode"])(attributeCode) ? attributeCode : '',
|
|
42474
|
+
optionLabel: optionLabel,
|
|
42475
|
+
optionCode: !Object(_helpers__WEBPACK_IMPORTED_MODULE_0__["isPlatformCode"])(optionCode) ? optionCode : '',
|
|
42476
|
+
});
|
|
42477
|
+
})
|
|
42478
|
+
};
|
|
42479
|
+
return [4 /*yield*/, _api__WEBPACK_IMPORTED_MODULE_6__["axiosApi"].post(Zakeke.config.baseApiUrl + "previewdesigns/pdf", params, {
|
|
42461
42480
|
transformResponse: function (res) { return res; },
|
|
42462
42481
|
responseType: "text"
|
|
42463
42482
|
})];
|
|
@@ -42930,6 +42949,110 @@ var NonSquarePixelException = /** @class */ (function (_super) {
|
|
|
42930
42949
|
|
|
42931
42950
|
|
|
42932
42951
|
|
|
42952
|
+
/***/ }),
|
|
42953
|
+
|
|
42954
|
+
/***/ "./src/fontsManager.ts":
|
|
42955
|
+
/*!*****************************!*\
|
|
42956
|
+
!*** ./src/fontsManager.ts ***!
|
|
42957
|
+
\*****************************/
|
|
42958
|
+
/*! exports provided: loadFonts, downloadFontsOfDesign */
|
|
42959
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
42960
|
+
|
|
42961
|
+
"use strict";
|
|
42962
|
+
__webpack_require__.r(__webpack_exports__);
|
|
42963
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFonts", function() { return loadFonts; });
|
|
42964
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "downloadFontsOfDesign", function() { return downloadFontsOfDesign; });
|
|
42965
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
42966
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42967
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
42968
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42969
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42970
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42971
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42972
|
+
});
|
|
42973
|
+
};
|
|
42974
|
+
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
42975
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
42976
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
42977
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
42978
|
+
function step(op) {
|
|
42979
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
42980
|
+
while (_) try {
|
|
42981
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42982
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
42983
|
+
switch (op[0]) {
|
|
42984
|
+
case 0: case 1: t = op; break;
|
|
42985
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
42986
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
42987
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42988
|
+
default:
|
|
42989
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42990
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42991
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42992
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42993
|
+
if (t[2]) _.ops.pop();
|
|
42994
|
+
_.trys.pop(); continue;
|
|
42995
|
+
}
|
|
42996
|
+
op = body.call(thisArg, _);
|
|
42997
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
42998
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42999
|
+
}
|
|
43000
|
+
};
|
|
43001
|
+
/**
|
|
43002
|
+
* Download a list of font families so that are available for the browser
|
|
43003
|
+
*/
|
|
43004
|
+
function loadFonts(fontFamilies) {
|
|
43005
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43006
|
+
return __generator(this, function (_a) {
|
|
43007
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
43008
|
+
WebFont.load({
|
|
43009
|
+
timeout: 200000,
|
|
43010
|
+
custom: {
|
|
43011
|
+
families: fontFamilies.map(function (x) { return x.name + (x.variations && x.variations != "" ? ":" + x.variations : ""); }),
|
|
43012
|
+
urls: fontFamilies.map(function (x) { return x.cssUrl; })
|
|
43013
|
+
},
|
|
43014
|
+
active: function () {
|
|
43015
|
+
resolve();
|
|
43016
|
+
}
|
|
43017
|
+
});
|
|
43018
|
+
})];
|
|
43019
|
+
});
|
|
43020
|
+
});
|
|
43021
|
+
}
|
|
43022
|
+
/**
|
|
43023
|
+
* Downlod all fonts used in a design
|
|
43024
|
+
*
|
|
43025
|
+
* @param design Design to load fonts for
|
|
43026
|
+
* @param downloadedFonts A list of downloaded fonts
|
|
43027
|
+
*/
|
|
43028
|
+
function downloadFontsOfDesign(design, downloadedFonts) {
|
|
43029
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43030
|
+
var fonts, _i, _a, item, data, attributes, fontFamily, fontFamilies;
|
|
43031
|
+
return __generator(this, function (_b) {
|
|
43032
|
+
switch (_b.label) {
|
|
43033
|
+
case 0:
|
|
43034
|
+
fonts = [];
|
|
43035
|
+
for (_i = 0, _a = design.get("designItems").models; _i < _a.length; _i++) {
|
|
43036
|
+
item = _a[_i];
|
|
43037
|
+
data = JSON.parse(item.get("json"));
|
|
43038
|
+
attributes = data[1];
|
|
43039
|
+
fontFamily = attributes.fontFamily || (attributes.children && attributes.children.length > 0 && attributes.children[0].length > 1 ? attributes.children[0][1].fontFamily : null);
|
|
43040
|
+
if (fontFamily)
|
|
43041
|
+
fonts.push(fontFamily.replace(/"/g, ""));
|
|
43042
|
+
}
|
|
43043
|
+
fontFamilies = fonts.map(function (fontName) { return downloadedFonts.find(function (fontFamily) { return fontFamily.name == fontName; }) || null; }).filter(function (x) { return x != null; });
|
|
43044
|
+
if (!(fontFamilies.length > 0)) return [3 /*break*/, 2];
|
|
43045
|
+
return [4 /*yield*/, loadFonts(fontFamilies)];
|
|
43046
|
+
case 1:
|
|
43047
|
+
_b.sent();
|
|
43048
|
+
_b.label = 2;
|
|
43049
|
+
case 2: return [2 /*return*/];
|
|
43050
|
+
}
|
|
43051
|
+
});
|
|
43052
|
+
});
|
|
43053
|
+
}
|
|
43054
|
+
|
|
43055
|
+
|
|
42933
43056
|
/***/ }),
|
|
42934
43057
|
|
|
42935
43058
|
/***/ "./src/helpers.tsx":
|
|
@@ -43532,7 +43655,7 @@ var ImageUploadTask = /** @class */ (function () {
|
|
|
43532
43655
|
/*!***********************!*\
|
|
43533
43656
|
!*** ./src/index.tsx ***!
|
|
43534
43657
|
\***********************/
|
|
43535
|
-
/*! exports provided: ZakekeEnvironment, ZakekeViewer, ZakekeDesigner, useZakeke, ZakekeProvider, Platform, PlatformPriceType, User, Product, ProductArea, ProductQuantityRule, Variant, ZakekeEvent, TemplateConstraints, TemplateArea, Template, TextItem, ImageItem, PlatformSettings, EventMessageType, Camera, Group, Step, AttributeType, AttributeOptionShapeType, Attribute, Option */
|
|
43658
|
+
/*! exports provided: ZakekeEnvironment, ZakekeViewer, ZakekeDesigner, useZakeke, useInternalState, ZakekeProvider, Platform, PlatformPriceType, User, Product, ProductArea, ProductQuantityRule, Variant, ZakekeEvent, TemplateConstraints, TemplateArea, Template, TextItem, ImageItem, PlatformSettings, EventMessageType, Camera, Group, Step, AttributeType, AttributeOptionShapeType, Attribute, Option */
|
|
43536
43659
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
43537
43660
|
|
|
43538
43661
|
"use strict";
|
|
@@ -43549,6 +43672,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
43549
43672
|
/* harmony import */ var _state_provider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state/provider */ "./src/state/provider.tsx");
|
|
43550
43673
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useZakeke", function() { return _state_provider__WEBPACK_IMPORTED_MODULE_3__["useZakeke"]; });
|
|
43551
43674
|
|
|
43675
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useInternalState", function() { return _state_provider__WEBPACK_IMPORTED_MODULE_3__["useInternalState"]; });
|
|
43676
|
+
|
|
43552
43677
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ZakekeProvider", function() { return _state_provider__WEBPACK_IMPORTED_MODULE_3__["ZakekeProvider"]; });
|
|
43553
43678
|
|
|
43554
43679
|
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./models */ "./src/models.ts");
|
|
@@ -44112,10 +44237,10 @@ var Option = /** @class */ (function () {
|
|
|
44112
44237
|
|
|
44113
44238
|
/***/ }),
|
|
44114
44239
|
|
|
44115
|
-
/***/ "./src/state/boot.
|
|
44116
|
-
|
|
44117
|
-
!*** ./src/state/boot.
|
|
44118
|
-
|
|
44240
|
+
/***/ "./src/state/boot.tsx":
|
|
44241
|
+
/*!****************************!*\
|
|
44242
|
+
!*** ./src/state/boot.tsx ***!
|
|
44243
|
+
\****************************/
|
|
44119
44244
|
/*! exports provided: default */
|
|
44120
44245
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
44121
44246
|
|
|
@@ -44123,6 +44248,9 @@ var Option = /** @class */ (function () {
|
|
|
44123
44248
|
__webpack_require__.r(__webpack_exports__);
|
|
44124
44249
|
/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! qs */ "./node_modules/qs/lib/index.js");
|
|
44125
44250
|
/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_0__);
|
|
44251
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
|
|
44252
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
44253
|
+
/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! .. */ "./src/index.tsx");
|
|
44126
44254
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
44127
44255
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
44128
44256
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -44160,46 +44288,53 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|
|
44160
44288
|
}
|
|
44161
44289
|
};
|
|
44162
44290
|
|
|
44291
|
+
|
|
44292
|
+
|
|
44163
44293
|
// Handle boot when provider is ready
|
|
44164
|
-
var
|
|
44165
|
-
var
|
|
44166
|
-
|
|
44167
|
-
|
|
44168
|
-
|
|
44169
|
-
|
|
44170
|
-
|
|
44171
|
-
|
|
44172
|
-
|
|
44173
|
-
|
|
44174
|
-
|
|
44175
|
-
|
|
44176
|
-
|
|
44177
|
-
|
|
44178
|
-
|
|
44179
|
-
|
|
44180
|
-
|
|
44181
|
-
|
|
44182
|
-
|
|
44183
|
-
|
|
44184
|
-
|
|
44185
|
-
|
|
44186
|
-
|
|
44187
|
-
|
|
44188
|
-
}
|
|
44189
|
-
|
|
44190
|
-
|
|
44191
|
-
|
|
44192
|
-
|
|
44294
|
+
var Boot = function (_a) {
|
|
44295
|
+
var children = _a.children;
|
|
44296
|
+
var stateRef = Object(react__WEBPACK_IMPORTED_MODULE_1__["useRef"])(Object(___WEBPACK_IMPORTED_MODULE_2__["useInternalState"])());
|
|
44297
|
+
var boot = Object(react__WEBPACK_IMPORTED_MODULE_1__["useCallback"])(function (parameters) { return __awaiter(void 0, void 0, void 0, function () {
|
|
44298
|
+
var _a, _b, _c, _d;
|
|
44299
|
+
return __generator(this, function (_e) {
|
|
44300
|
+
switch (_e.label) {
|
|
44301
|
+
case 0:
|
|
44302
|
+
console.log("boot", parameters);
|
|
44303
|
+
(_a = stateRef.current) === null || _a === void 0 ? void 0 : _a.dispatch({ type: 'IS_SCENE_LOADING', isLoading: true });
|
|
44304
|
+
// Register to environment changes
|
|
44305
|
+
(_b = stateRef.current) === null || _b === void 0 ? void 0 : _b.state.environment.on('change', function () { var _a; return (_a = stateRef.current) === null || _a === void 0 ? void 0 : _a.dispatch({ type: 'UPDATE' }); });
|
|
44306
|
+
return [4 /*yield*/, ((_c = stateRef.current) === null || _c === void 0 ? void 0 : _c.state.environment.boot(parameters))];
|
|
44307
|
+
case 1:
|
|
44308
|
+
_e.sent();
|
|
44309
|
+
(_d = stateRef.current) === null || _d === void 0 ? void 0 : _d.dispatch({ type: 'IS_SCENE_LOADING', isLoading: false });
|
|
44310
|
+
return [2 /*return*/];
|
|
44311
|
+
}
|
|
44312
|
+
});
|
|
44313
|
+
}); }, []);
|
|
44314
|
+
var handleMessageReceived = Object(react__WEBPACK_IMPORTED_MODULE_1__["useCallback"])(function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
44315
|
+
var _a, _b;
|
|
44316
|
+
return __generator(this, function (_c) {
|
|
44317
|
+
if (e.data.type == "load" && !((_a = stateRef.current) === null || _a === void 0 ? void 0 : _a.state.parametersReceived)) {
|
|
44318
|
+
(_b = stateRef.current) === null || _b === void 0 ? void 0 : _b.dispatch({ type: 'PARAMETERS_RECEIVED' });
|
|
44319
|
+
boot(e.data.parameters);
|
|
44320
|
+
window.parent.postMessage({ zakekeType: "loaded" }, "*");
|
|
44321
|
+
}
|
|
44322
|
+
return [2 /*return*/];
|
|
44323
|
+
});
|
|
44324
|
+
}); }, []);
|
|
44325
|
+
Object(react__WEBPACK_IMPORTED_MODULE_1__["useEffect"])(function () {
|
|
44326
|
+
var query = qs__WEBPACK_IMPORTED_MODULE_0___default.a.parse(window.location.search);
|
|
44193
44327
|
if (query && query.ecommerce && query.ecommerce == 'preview') {
|
|
44194
44328
|
boot(null);
|
|
44195
44329
|
}
|
|
44196
44330
|
else {
|
|
44197
44331
|
window.addEventListener("message", handleMessageReceived);
|
|
44198
44332
|
}
|
|
44199
|
-
return
|
|
44200
|
-
});
|
|
44201
|
-
|
|
44202
|
-
|
|
44333
|
+
return function () { return window.removeEventListener("message", handleMessageReceived); };
|
|
44334
|
+
}, []);
|
|
44335
|
+
return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_1___default.a.Fragment, null, children);
|
|
44336
|
+
};
|
|
44337
|
+
/* harmony default export */ __webpack_exports__["default"] = (Boot);
|
|
44203
44338
|
|
|
44204
44339
|
|
|
44205
44340
|
/***/ }),
|
|
@@ -44208,23 +44343,25 @@ var boot = function (state, dispatch) { return __awaiter(void 0, void 0, void 0,
|
|
|
44208
44343
|
/*!********************************!*\
|
|
44209
44344
|
!*** ./src/state/provider.tsx ***!
|
|
44210
44345
|
\********************************/
|
|
44211
|
-
/*! exports provided: useZakeke, ZakekeProvider */
|
|
44346
|
+
/*! exports provided: useZakeke, useInternalState, ZakekeProvider */
|
|
44212
44347
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
44213
44348
|
|
|
44214
44349
|
"use strict";
|
|
44215
44350
|
__webpack_require__.r(__webpack_exports__);
|
|
44216
44351
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "useZakeke", function() { return useZakeke; });
|
|
44352
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "useInternalState", function() { return useInternalState; });
|
|
44217
44353
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ZakekeProvider", function() { return ZakekeProvider; });
|
|
44218
44354
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
44219
44355
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
44220
|
-
/* harmony import */ var
|
|
44221
|
-
/* harmony import */ var
|
|
44222
|
-
/* harmony import */ var
|
|
44356
|
+
/* harmony import */ var _boot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boot */ "./src/state/boot.tsx");
|
|
44357
|
+
/* harmony import */ var _providerValue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./providerValue */ "./src/state/providerValue.ts");
|
|
44358
|
+
/* harmony import */ var _reducer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./reducer */ "./src/state/reducer.ts");
|
|
44223
44359
|
|
|
44224
44360
|
|
|
44225
44361
|
|
|
44226
44362
|
|
|
44227
44363
|
var context = react__WEBPACK_IMPORTED_MODULE_0___default.a.createContext(null);
|
|
44364
|
+
var internalContext = react__WEBPACK_IMPORTED_MODULE_0___default.a.createContext(null);
|
|
44228
44365
|
// Use zakeke hook
|
|
44229
44366
|
var useZakeke = function () {
|
|
44230
44367
|
var value = Object(react__WEBPACK_IMPORTED_MODULE_0__["useContext"])(context);
|
|
@@ -44232,21 +44369,27 @@ var useZakeke = function () {
|
|
|
44232
44369
|
throw 'Corrupted Zakeke state';
|
|
44233
44370
|
return value;
|
|
44234
44371
|
};
|
|
44372
|
+
// Use zakeke hook
|
|
44373
|
+
var useInternalState = function () {
|
|
44374
|
+
var value = Object(react__WEBPACK_IMPORTED_MODULE_0__["useContext"])(internalContext);
|
|
44375
|
+
if (!value)
|
|
44376
|
+
throw 'Corrupted Zakeke state';
|
|
44377
|
+
return value;
|
|
44378
|
+
};
|
|
44235
44379
|
// ZakekeProvider
|
|
44236
44380
|
var ZakekeProvider = function (_a) {
|
|
44237
44381
|
var environment = _a.environment, children = _a.children;
|
|
44238
|
-
var _b = Object(react__WEBPACK_IMPORTED_MODULE_0__["useReducer"])(
|
|
44382
|
+
var _b = Object(react__WEBPACK_IMPORTED_MODULE_0__["useReducer"])(_reducer__WEBPACK_IMPORTED_MODULE_3__["reducer"], {
|
|
44239
44383
|
environment: environment,
|
|
44240
44384
|
isAddToCartLoading: false,
|
|
44241
44385
|
isSceneLoading: false,
|
|
44242
44386
|
parametersReceived: false
|
|
44243
44387
|
}), state = _b[0], dispatch = _b[1];
|
|
44244
44388
|
// Create the provider value exposed to developer
|
|
44245
|
-
var value = Object(
|
|
44246
|
-
|
|
44247
|
-
|
|
44248
|
-
|
|
44249
|
-
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(context.Provider, { value: value }, children);
|
|
44389
|
+
var value = Object(_providerValue__WEBPACK_IMPORTED_MODULE_2__["createProviderValue"])(state, dispatch);
|
|
44390
|
+
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(context.Provider, { value: value },
|
|
44391
|
+
react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(internalContext.Provider, { value: { state: state, dispatch: dispatch } },
|
|
44392
|
+
react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_boot__WEBPACK_IMPORTED_MODULE_1__["default"], null, children)));
|
|
44250
44393
|
};
|
|
44251
44394
|
|
|
44252
44395
|
|