@threekit-tools/treble 0.0.81 → 0.0.84

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.
Files changed (110) hide show
  1. package/dist/Treble/Treble.d.ts +11 -5
  2. package/dist/Treble/Treble.js +41 -12
  3. package/dist/Treble/index.d.ts +2 -2
  4. package/dist/Treble/index.js +7 -3
  5. package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
  6. package/dist/Treble/snapshots.js +247 -0
  7. package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
  8. package/dist/Treble/wishlist.js +135 -0
  9. package/dist/api/catalog.js +6 -6
  10. package/dist/api/configurations.js +3 -3
  11. package/dist/api/datatables.js +5 -5
  12. package/dist/api/index.js +5 -1
  13. package/dist/api/orders.d.ts +5 -7
  14. package/dist/api/orders.js +12 -12
  15. package/dist/api/price.js +2 -2
  16. package/dist/api/products.js +2 -2
  17. package/dist/components/Accordion/index.js +6 -7
  18. package/dist/components/AttributeTitle/index.d.ts +0 -9
  19. package/dist/components/AttributeTitle/index.js +0 -9
  20. package/dist/components/AttributeValue/index.d.ts +0 -6
  21. package/dist/components/AttributeValue/index.js +2 -8
  22. package/dist/components/Button/index.d.ts +0 -27
  23. package/dist/components/Button/index.js +0 -27
  24. package/dist/components/Cards/index.d.ts +2 -55
  25. package/dist/components/Cards/index.js +3 -60
  26. package/dist/components/Drawer/index.js +7 -16
  27. package/dist/components/Dropdown/index.d.ts +2 -59
  28. package/dist/components/Dropdown/index.js +11 -72
  29. package/dist/components/FlatForm/index.d.ts +0 -21
  30. package/dist/components/FlatForm/index.js +10 -25
  31. package/dist/components/Modal/index.js +2 -15
  32. package/dist/components/Player/index.d.ts +1 -1
  33. package/dist/components/PortalToArOverlay/index.js +5 -1
  34. package/dist/components/PortalToElement/index.js +0 -8
  35. package/dist/components/ProductDescription/index.d.ts +0 -6
  36. package/dist/components/ProductDescription/index.js +0 -6
  37. package/dist/components/ProductName/index.d.ts +0 -9
  38. package/dist/components/ProductName/index.js +0 -9
  39. package/dist/components/Share/index.d.ts +0 -12
  40. package/dist/components/Share/index.js +2 -14
  41. package/dist/components/Snapshots/index.d.ts +0 -8
  42. package/dist/components/Snapshots/index.js +2 -10
  43. package/dist/components/Strips/index.d.ts +2 -55
  44. package/dist/components/Strips/index.js +3 -60
  45. package/dist/components/Swatch/index.d.ts +2 -64
  46. package/dist/components/Swatch/index.js +3 -69
  47. package/dist/components/Switch/index.d.ts +2 -34
  48. package/dist/components/Switch/index.js +2 -38
  49. package/dist/components/Tabs/index.js +5 -1
  50. package/dist/components/TextInput/index.d.ts +2 -1
  51. package/dist/components/TextInput/index.js +2 -3
  52. package/dist/components/ThreekitProvider/index.js +5 -1
  53. package/dist/components/Tiles/index.d.ts +2 -29
  54. package/dist/components/Tiles/index.js +3 -33
  55. package/dist/components/TilesGroup/index.d.ts +2 -26
  56. package/dist/components/TilesGroup/index.js +3 -30
  57. package/dist/components/TotalPrice/index.d.ts +0 -6
  58. package/dist/components/TotalPrice/index.js +0 -6
  59. package/dist/components/TrebleApp/index.js +5 -1
  60. package/dist/components/Upload/index.d.ts +2 -1
  61. package/dist/components/Upload/index.js +21 -17
  62. package/dist/components/UploadArea/index.d.ts +2 -1
  63. package/dist/components/UploadArea/index.js +18 -15
  64. package/dist/components/Wishlist/index.d.ts +0 -3
  65. package/dist/components/Wishlist/index.js +12 -10
  66. package/dist/components/Zoom/index.d.ts +0 -17
  67. package/dist/components/Zoom/index.js +5 -21
  68. package/dist/components/formComponents.d.ts +12 -0
  69. package/dist/components/formComponents.js +10 -8
  70. package/dist/components/message/index.d.ts +0 -9
  71. package/dist/components/message/index.js +4 -31
  72. package/dist/connection.js +2 -2
  73. package/dist/constants.d.ts +0 -49
  74. package/dist/constants.js +1 -59
  75. package/dist/hooks/useAttribute/index.d.ts +1 -1
  76. package/dist/hooks/useAttribute/index.js +6 -6
  77. package/dist/hooks/useConfigurationLoader/index.js +5 -5
  78. package/dist/hooks/useNestedConfigurator/index.js +2 -2
  79. package/dist/hooks/useShare/index.js +3 -3
  80. package/dist/hooks/useSingleAnimation/index.js +20 -25
  81. package/dist/http/datatables.js +0 -1
  82. package/dist/http/index.js +5 -1
  83. package/dist/http/orders.d.ts +6 -8
  84. package/dist/icons/Spinner.js +5 -1
  85. package/dist/icons/index.d.ts +0 -41
  86. package/dist/icons/index.js +0 -42
  87. package/dist/index.d.ts +42 -3
  88. package/dist/index.js +84 -26
  89. package/dist/store/attributes.d.ts +0 -12
  90. package/dist/store/attributes.js +2 -15
  91. package/dist/store/index.d.ts +1 -1
  92. package/dist/store/price.d.ts +0 -12
  93. package/dist/store/price.js +2 -16
  94. package/dist/store/product.d.ts +6 -21
  95. package/dist/store/product.js +26 -38
  96. package/dist/store/translations.d.ts +1 -13
  97. package/dist/store/translations.js +2 -12
  98. package/dist/store/treble.d.ts +1 -16
  99. package/dist/store/treble.js +31 -66
  100. package/dist/store/wishlist.d.ts +0 -12
  101. package/dist/store/wishlist.js +4 -17
  102. package/dist/types.d.ts +118 -65
  103. package/dist/types.js +54 -0
  104. package/dist/utils.d.ts +10 -10
  105. package/dist/utils.js +8 -16
  106. package/package.json +16 -4
  107. package/dist/Treble/Snapshots.js +0 -251
  108. package/dist/Treble/Wishlist.js +0 -136
  109. package/dist/hooks/useImageEditor/index.d.ts +0 -14
  110. package/dist/hooks/useImageEditor/index.js +0 -320
@@ -1,251 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var api_1 = __importDefault(require("../api"));
43
- // import connection from '../connection';
44
- var constants_1 = require("../constants");
45
- var utils_1 = require("../utils");
46
- var DEFAULT_CAMERA_CONFIG = {
47
- filename: "snapshot",
48
- size: { width: 1920, height: 1080 },
49
- format: constants_1.SNAPSHOT_FORMATS.png,
50
- attributeName: constants_1.ATTRIBUTES_RESERVED.camera,
51
- output: constants_1.SNAPSHOT_OUTPUTS.blob,
52
- useStage: false,
53
- };
54
- var cameraValues;
55
- var getCameraValue = function (configurator, cameraAttrName) {
56
- if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
57
- var attribute = configurator
58
- .getDisplayAttributes()
59
- .find(function (el) { return el.name === cameraAttrName; });
60
- if (!attribute)
61
- return undefined;
62
- return attribute.value;
63
- };
64
- var getCamerasMap = function (configurator, cameraAttrName) {
65
- if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
66
- if (cameraValues)
67
- return cameraValues;
68
- var attribute = configurator
69
- .getDisplayAttributes()
70
- .find(function (el) { return el.name === cameraAttrName; });
71
- if (!attribute) {
72
- cameraValues = {};
73
- return cameraValues;
74
- }
75
- var cameraAttribute = attribute;
76
- cameraAttribute.values.forEach(function (el) {
77
- var _a;
78
- var value = cameraAttribute.type === constants_1.ATTRIBUTE_TYPES.asset
79
- ? { assetId: el.assetId }
80
- : el.value;
81
- cameraValues = Object.assign(cameraValues || {}, (_a = {},
82
- _a[el.label] = value,
83
- _a));
84
- }, {});
85
- return cameraValues;
86
- };
87
- var getSnapshot = function (_a) {
88
- var size = _a.size, format = _a.format;
89
- return window.threekit.player.snapshotAsync({
90
- size: size,
91
- mimeType: "image/".concat(constants_1.SNAPSHOT_FORMATS[format]),
92
- });
93
- };
94
- var getSnapshots = function (cameras, snapshotConfig) { return __awaiter(void 0, void 0, void 0, function () {
95
- var attributeName, size, format, configurator, _a, camerasMap, snapshots;
96
- return __generator(this, function (_b) {
97
- switch (_b.label) {
98
- case 0:
99
- attributeName = snapshotConfig.attributeName || DEFAULT_CAMERA_CONFIG.attributeName;
100
- size = snapshotConfig.size || DEFAULT_CAMERA_CONFIG.size;
101
- format = snapshotConfig.format || DEFAULT_CAMERA_CONFIG.format;
102
- if (!(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.useStage)) return [3 /*break*/, 2];
103
- return [4 /*yield*/, window.threekit.player.getStageConfigurator()];
104
- case 1:
105
- _a = _b.sent();
106
- return [3 /*break*/, 3];
107
- case 2:
108
- _a = window.threekit.configurator;
109
- _b.label = 3;
110
- case 3:
111
- configurator = _a;
112
- camerasMap = getCamerasMap(configurator, attributeName);
113
- if (!camerasMap)
114
- return [2 /*return*/, Promise.resolve([])];
115
- snapshots = [];
116
- return [2 /*return*/, cameras.reduce(function (snapshotPromise, camera) {
117
- return snapshotPromise.then(function () {
118
- return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
119
- var snapshotStr;
120
- var _a;
121
- return __generator(this, function (_b) {
122
- switch (_b.label) {
123
- case 0:
124
- if (!camera) return [3 /*break*/, 2];
125
- return [4 /*yield*/, configurator.setConfiguration((_a = {},
126
- _a[attributeName] = camerasMap[camera],
127
- _a))];
128
- case 1:
129
- _b.sent();
130
- _b.label = 2;
131
- case 2: return [4 /*yield*/, getSnapshot({ size: size, format: format })];
132
- case 3:
133
- snapshotStr = _b.sent();
134
- snapshots.push(snapshotStr);
135
- resolve(snapshots);
136
- return [2 /*return*/];
137
- }
138
- });
139
- }); });
140
- });
141
- }, Promise.resolve(snapshots))];
142
- }
143
- });
144
- }); };
145
- var Snapshots = /** @class */ (function () {
146
- function Snapshots() {
147
- var _this = this;
148
- this.getSnapshot = getSnapshot;
149
- this.takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(_this, void 0, void 0, function () {
150
- var filename, size, format, attributeName, output, configurator, _a, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _b, attachments, response, urlsArray, snapshotBlobs, snapshotFiles;
151
- var _c;
152
- return __generator(this, function (_d) {
153
- switch (_d.label) {
154
- case 0:
155
- filename = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.filename) || DEFAULT_CAMERA_CONFIG.filename;
156
- size = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.size) || DEFAULT_CAMERA_CONFIG.size;
157
- format = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.format) || DEFAULT_CAMERA_CONFIG.format;
158
- attributeName = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.attributeName) || DEFAULT_CAMERA_CONFIG.attributeName;
159
- output = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.output) || DEFAULT_CAMERA_CONFIG.output;
160
- if (!(snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.useStage)) return [3 /*break*/, 2];
161
- return [4 /*yield*/, window.threekit.player.getStageConfigurator()];
162
- case 1:
163
- _a = _d.sent();
164
- return [3 /*break*/, 3];
165
- case 2:
166
- _a = window.threekit.configurator;
167
- _d.label = 3;
168
- case 3:
169
- configurator = _a;
170
- cameras = Array.isArray(camerasList) ? camerasList : [camerasList];
171
- if (!(cameras.length === 1 && cameras[0] === undefined)) return [3 /*break*/, 5];
172
- return [4 /*yield*/, this.getSnapshot({ size: size, format: format })];
173
- case 4:
174
- snapshotData = _d.sent();
175
- snapshotsRaw = [snapshotData];
176
- return [3 /*break*/, 8];
177
- case 5:
178
- camerasMap_1 = getCamerasMap(configurator, attributeName);
179
- if (!camerasMap_1)
180
- return [2 /*return*/, null];
181
- cameras = cameras.filter(function (el) { return el === undefined || Object.keys(camerasMap_1).includes(el); });
182
- currentCamera = getCameraValue(configurator, attributeName);
183
- cameraPosition = (0, utils_1.getCameraPosition)(window.threekit.player.camera);
184
- return [4 /*yield*/, getSnapshots(cameras, snapshotsConfig)];
185
- case 6:
186
- snapshotsRaw = _d.sent();
187
- return [4 /*yield*/, configurator.setConfiguration((_c = {},
188
- _c[attributeName] = currentCamera,
189
- _c))];
190
- case 7:
191
- _d.sent();
192
- (0, utils_1.setCameraPosition)(window.threekit.player.camera, cameraPosition);
193
- _d.label = 8;
194
- case 8:
195
- _b = output;
196
- switch (_b) {
197
- case constants_1.SNAPSHOT_OUTPUTS.url: return [3 /*break*/, 9];
198
- case constants_1.SNAPSHOT_OUTPUTS.download: return [3 /*break*/, 11];
199
- case constants_1.SNAPSHOT_OUTPUTS.blob: return [3 /*break*/, 12];
200
- case constants_1.SNAPSHOT_OUTPUTS.file: return [3 /*break*/, 13];
201
- case constants_1.SNAPSHOT_OUTPUTS.dataUrl: return [3 /*break*/, 14];
202
- }
203
- return [3 /*break*/, 14];
204
- case 9:
205
- attachments = snapshotsRaw.reduce(function (output, el, idx) {
206
- var _a;
207
- var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
208
- ? (0, utils_1.regularToKebabCase)(camerasList[idx] || 'default')
209
- : filename;
210
- var preppedFilename = cameraName === filename
211
- ? "".concat(filename, ".").concat(format)
212
- : "".concat(filename, "-").concat(cameraName, ".").concat(format);
213
- var file = (0, utils_1.dataURItoFile)(el, preppedFilename);
214
- return Object.assign(output, (_a = {}, _a[cameraName] = file, _a));
215
- }, {});
216
- return [4 /*yield*/, api_1.default.configurations.save({
217
- assetId: window.threekit.player.assetId,
218
- configuration: window.threekit.configurator.getConfiguration(),
219
- attachments: attachments,
220
- })];
221
- case 10:
222
- response = _d.sent();
223
- urlsArray = Object.values(response.data.attachments);
224
- return [2 /*return*/, Promise.resolve(urlsArray)];
225
- case 11:
226
- snapshotsRaw.forEach(function (snapshotBlob, idx) {
227
- var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
228
- ? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
229
- : '';
230
- (0, utils_1.downloadSnapshot)(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
231
- });
232
- return [2 /*return*/, Promise.resolve()];
233
- case 12:
234
- snapshotBlobs = snapshotsRaw.map(function (el) { return (0, utils_1.dataURItoBlob)(el); });
235
- return [2 /*return*/, Promise.resolve(snapshotBlobs)];
236
- case 13:
237
- snapshotFiles = snapshotsRaw.map(function (el, idx) {
238
- var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
239
- ? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
240
- : '';
241
- return (0, utils_1.dataURItoFile)(el, "".concat(filename).concat(cameraName, ".").concat(format));
242
- });
243
- return [2 /*return*/, Promise.resolve(snapshotFiles)];
244
- case 14: return [2 /*return*/, Promise.resolve(snapshotsRaw)];
245
- }
246
- });
247
- }); };
248
- }
249
- return Snapshots;
250
- }());
251
- exports.default = Snapshots;
@@ -1,136 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
- var __importDefault = (this && this.__importDefault) || function (mod) {
48
- return (mod && mod.__esModule) ? mod : { "default": mod };
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- var api_1 = __importDefault(require("../api"));
52
- var constants_1 = require("../constants");
53
- var wishlistData;
54
- var Wishlist = /** @class */ (function () {
55
- function Wishlist(orgId) {
56
- var _this = this;
57
- this.getWishlist = function () { return __awaiter(_this, void 0, void 0, function () {
58
- var wishlistListStr, wishlistList, wishlistDataRaw;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0:
62
- if (wishlistData)
63
- return [2 /*return*/, wishlistData];
64
- wishlistListStr = localStorage.getItem(this._wishlistKey);
65
- wishlistList = JSON.parse(wishlistListStr || '[]');
66
- return [4 /*yield*/, Promise.all(wishlistList.map(function (el) { return api_1.default.configurations.fetch(el); }))];
67
- case 1:
68
- wishlistDataRaw = _a.sent();
69
- wishlistData = wishlistDataRaw.map(function (el) { return el.data; });
70
- return [2 /*return*/, wishlistData];
71
- }
72
- });
73
- }); };
74
- this.addItem = function () { return __awaiter(_this, void 0, void 0, function () {
75
- var thumbnails, savedConfiguration, wishlistListStr, wishlistList;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0:
79
- if (!wishlistData) {
80
- wishlistData = [];
81
- localStorage.setItem(this._wishlistKey, JSON.stringify([]));
82
- }
83
- return [4 /*yield*/, window.threekit.treble.takeSnapshots(undefined, {
84
- output: 'file',
85
- filename: 'thumbnail',
86
- })];
87
- case 1:
88
- thumbnails = (_a.sent());
89
- return [4 /*yield*/, window.threekit.treble.saveConfiguration({
90
- attachments: { thumbnail: thumbnails[0] },
91
- })];
92
- case 2:
93
- savedConfiguration = _a.sent();
94
- if (!savedConfiguration)
95
- return [2 /*return*/, wishlistData];
96
- wishlistData = __spreadArray(__spreadArray([], wishlistData, true), [savedConfiguration], false);
97
- wishlistListStr = localStorage.getItem(this._wishlistKey);
98
- wishlistList = JSON.parse(wishlistListStr || '[]');
99
- wishlistList.push(savedConfiguration.shortId);
100
- localStorage.setItem(this._wishlistKey, JSON.stringify(wishlistList));
101
- return [2 /*return*/, this.getWishlist()];
102
- }
103
- });
104
- }); };
105
- this.removeItemByIdx = function (idx) {
106
- if (!(wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length)) {
107
- wishlistData = [];
108
- localStorage.setItem(_this._wishlistKey, JSON.stringify([]));
109
- return wishlistData;
110
- }
111
- if (idx > (wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length) - 1)
112
- return wishlistData;
113
- var updatedWishlist = __spreadArray([], wishlistData, true);
114
- updatedWishlist.splice(idx, 1);
115
- wishlistData = updatedWishlist;
116
- var wishlistListStr = localStorage.getItem(_this._wishlistKey);
117
- var wishlistList = JSON.parse(wishlistListStr || '[]');
118
- wishlistList.splice(idx, 1);
119
- localStorage.setItem(_this._wishlistKey, JSON.stringify(wishlistList));
120
- return wishlistData;
121
- };
122
- this.clearWishlist = function () {
123
- wishlistData = [];
124
- localStorage.setItem(_this._wishlistKey, JSON.stringify([]));
125
- return wishlistData;
126
- };
127
- this._wishlistKey = "".concat(constants_1.WISHLIST_LOCALSTORAGE_KEY, "_").concat(orgId);
128
- this.getWishlist();
129
- return this;
130
- }
131
- return Wishlist;
132
- }());
133
- function createWishlist(orgId) {
134
- return new Wishlist(orgId);
135
- }
136
- exports.default = createWishlist;
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- interface UseImageEditorConfig {
3
- canvasHeight?: number;
4
- canvasWidth?: number;
5
- cornerCircleSize?: number;
6
- cropRatio?: number;
7
- }
8
- declare function useImageEditor(image: string, config: UseImageEditorConfig): null[] | (import("react").MutableRefObject<HTMLCanvasElement | null> | {
9
- handleCrop: () => void;
10
- } | {
11
- handleInvert: () => void;
12
- handleGrayscale: () => void;
13
- })[];
14
- export default useImageEditor;