@threekit-tools/treble 0.0.80 → 0.0.83
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/Treble/Snapshots.d.ts +2 -2
- package/dist/Treble/Snapshots.js +31 -32
- package/dist/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +4 -5
- package/dist/Treble/Wishlist.d.ts +2 -2
- package/dist/Treble/Wishlist.js +19 -21
- package/dist/Treble/index.js +5 -1
- package/dist/api/catalog.js +6 -6
- package/dist/api/configurations.js +3 -3
- package/dist/api/datatables.js +5 -5
- package/dist/api/index.js +5 -1
- package/dist/api/orders.js +12 -12
- package/dist/api/price.js +2 -2
- package/dist/api/products.js +2 -2
- package/dist/components/Accordion/index.js +6 -7
- package/dist/components/AttributeTitle/index.d.ts +0 -9
- package/dist/components/AttributeTitle/index.js +0 -9
- package/dist/components/AttributeValue/index.d.ts +0 -6
- package/dist/components/AttributeValue/index.js +0 -6
- package/dist/components/Button/index.d.ts +0 -27
- package/dist/components/Button/index.js +0 -27
- package/dist/components/Cards/index.d.ts +0 -54
- package/dist/components/Cards/index.js +0 -57
- package/dist/components/Drawer/index.js +7 -16
- package/dist/components/Dropdown/index.d.ts +0 -58
- package/dist/components/Dropdown/index.js +8 -69
- package/dist/components/FlatForm/index.d.ts +0 -21
- package/dist/components/FlatForm/index.js +5 -22
- package/dist/components/Modal/index.js +2 -15
- package/dist/components/Player/index.d.ts +0 -1
- package/dist/components/Player/index.js +4 -38
- package/dist/components/PortalToArOverlay/index.js +5 -1
- package/dist/components/PortalToElement/index.js +0 -8
- package/dist/components/ProductDescription/index.d.ts +0 -6
- package/dist/components/ProductDescription/index.js +0 -6
- package/dist/components/ProductName/index.d.ts +0 -9
- package/dist/components/ProductName/index.js +0 -9
- package/dist/components/Share/index.d.ts +0 -12
- package/dist/components/Share/index.js +2 -14
- package/dist/components/Snapshots/index.d.ts +0 -8
- package/dist/components/Snapshots/index.js +2 -10
- package/dist/components/Strips/index.d.ts +0 -54
- package/dist/components/Strips/index.js +0 -57
- package/dist/components/Swatch/index.d.ts +0 -63
- package/dist/components/Swatch/index.js +0 -66
- package/dist/components/Switch/index.d.ts +0 -33
- package/dist/components/Switch/index.js +0 -36
- package/dist/components/Tabs/index.js +5 -1
- package/dist/components/TextInput/index.js +0 -1
- package/dist/components/ThreekitProvider/index.js +7 -2
- package/dist/components/Tiles/index.d.ts +0 -28
- package/dist/components/Tiles/index.js +0 -30
- package/dist/components/TilesGroup/index.d.ts +0 -25
- package/dist/components/TilesGroup/index.js +0 -27
- package/dist/components/TotalPrice/index.d.ts +0 -6
- package/dist/components/TotalPrice/index.js +0 -6
- package/dist/components/TrebleApp/index.js +5 -1
- package/dist/components/Upload/index.js +19 -15
- package/dist/components/UploadArea/index.js +16 -13
- package/dist/components/Wishlist/index.d.ts +0 -3
- package/dist/components/Wishlist/index.js +12 -10
- package/dist/components/Zoom/index.d.ts +0 -17
- package/dist/components/Zoom/index.js +5 -21
- package/dist/components/formComponents.js +5 -3
- package/dist/components/message/index.d.ts +0 -9
- package/dist/components/message/index.js +4 -31
- package/dist/connection.js +2 -2
- package/dist/constants.d.ts +0 -27
- package/dist/constants.js +0 -36
- package/dist/hooks/useAttribute/index.d.ts +1 -1
- package/dist/hooks/useAttribute/index.js +6 -6
- package/dist/hooks/useConfigurationLoader/index.js +5 -5
- package/dist/hooks/useLoadingProgress/index.d.ts +2 -0
- package/dist/hooks/useLoadingProgress/index.js +9 -0
- package/dist/hooks/useNestedConfigurator/index.js +2 -2
- package/dist/hooks/usePlayer/index.d.ts +3 -0
- package/dist/hooks/usePlayer/index.js +38 -0
- package/dist/hooks/useShare/index.js +3 -3
- package/dist/hooks/useSingleAnimation/index.js +5 -11
- package/dist/hooks/useSnapshot/index.d.ts +1 -1
- package/dist/hooks/useWishlist/index.d.ts +1 -1
- package/dist/http/datatables.js +0 -1
- package/dist/http/index.js +5 -1
- package/dist/icons/Spinner.js +5 -1
- package/dist/icons/index.d.ts +0 -41
- package/dist/icons/index.js +0 -42
- package/dist/index.d.ts +44 -3
- package/dist/index.js +88 -26
- package/dist/store/attributes.d.ts +0 -12
- package/dist/store/attributes.js +2 -15
- package/dist/store/index.d.ts +1 -1
- package/dist/store/price.d.ts +0 -12
- package/dist/store/price.js +2 -16
- package/dist/store/product.d.ts +6 -21
- package/dist/store/product.js +23 -37
- package/dist/store/translations.d.ts +1 -13
- package/dist/store/translations.js +2 -12
- package/dist/store/treble.d.ts +4 -16
- package/dist/store/treble.js +47 -66
- package/dist/store/wishlist.d.ts +1 -13
- package/dist/store/wishlist.js +4 -17
- package/dist/types.d.ts +47 -41
- package/dist/utils.d.ts +8 -8
- package/dist/utils.js +3 -12
- package/package.json +16 -4
package/dist/store/treble.js
CHANGED
|
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.reloadPlayer = exports.unloadPlayer = exports.launch = exports.initPlayer = exports.getPlayerElementId = exports.isPlayerLoading = exports.isThreekitInitialized = exports.getThreekitEnv = exports.reloadTreble = exports.setPlayerElement = exports.setPlayerLoading = exports.setThreekitInitialized = exports.setThreekitEnv = void 0;
|
|
53
|
+
exports.reloadPlayer = exports.unloadPlayer = exports.launch = exports.initPlayer = exports.getLoadingProgress = exports.getPlayerElementId = exports.isPlayerLoading = exports.isThreekitInitialized = exports.getThreekitEnv = exports.updateLoadingProgress = exports.reloadTreble = exports.setPlayerElement = exports.setPlayerLoading = exports.setThreekitInitialized = exports.setThreekitEnv = void 0;
|
|
54
54
|
var connection_1 = __importDefault(require("../connection"));
|
|
55
55
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
56
56
|
var api_1 = __importDefault(require("../api"));
|
|
@@ -63,17 +63,7 @@ var wishlist_1 = require("./wishlist");
|
|
|
63
63
|
var translations_1 = require("./translations");
|
|
64
64
|
var product_1 = require("./product");
|
|
65
65
|
var message_1 = __importDefault(require("../components/message"));
|
|
66
|
-
/*****************************************************
|
|
67
|
-
* Helper Functions
|
|
68
|
-
****************************************************/
|
|
69
66
|
var createPlayerLoaderEl = function (elementId) {
|
|
70
|
-
/**
|
|
71
|
-
* By default the player is loaded into a player-loader div that
|
|
72
|
-
* is placed outside the user's view. This is done because in
|
|
73
|
-
* React the Threekit Initialization may happen before the
|
|
74
|
-
* component with the player HTML element has loaded which would
|
|
75
|
-
* otherwise throw an error.
|
|
76
|
-
*/
|
|
77
67
|
var playerElement = document.getElementById(elementId);
|
|
78
68
|
if (playerElement)
|
|
79
69
|
return playerElement;
|
|
@@ -90,31 +80,21 @@ var createPlayerLoaderEl = function (elementId) {
|
|
|
90
80
|
document.body.appendChild(playerLoader);
|
|
91
81
|
return playerElement;
|
|
92
82
|
};
|
|
93
|
-
/*****************************************************
|
|
94
|
-
* Constants and Event Handlers
|
|
95
|
-
****************************************************/
|
|
96
83
|
var EVENTS = {};
|
|
97
|
-
/*****************************************************
|
|
98
|
-
* State
|
|
99
|
-
****************************************************/
|
|
100
84
|
var initialState = {
|
|
101
85
|
threekitEnv: 'preview',
|
|
102
86
|
isThreekitInitialized: false,
|
|
103
87
|
isPlayerLoading: false,
|
|
104
88
|
playerElId: undefined,
|
|
105
89
|
notifications: true,
|
|
90
|
+
loadingProgress: 0,
|
|
106
91
|
};
|
|
107
|
-
/*****************************************************
|
|
108
|
-
* Actions
|
|
109
|
-
****************************************************/
|
|
110
92
|
exports.setThreekitEnv = (0, toolkit_1.createAction)('treble/set-threekit-env');
|
|
111
93
|
exports.setThreekitInitialized = (0, toolkit_1.createAction)('treble/set-threekit-initialized');
|
|
112
94
|
exports.setPlayerLoading = (0, toolkit_1.createAction)('treble/set-player-loading');
|
|
113
95
|
exports.setPlayerElement = (0, toolkit_1.createAction)('treble/set-player-element');
|
|
114
96
|
exports.reloadTreble = (0, toolkit_1.createAction)('treble/reload');
|
|
115
|
-
|
|
116
|
-
* Slice
|
|
117
|
-
****************************************************/
|
|
97
|
+
exports.updateLoadingProgress = (0, toolkit_1.createAction)('treble/update-loading-progress');
|
|
118
98
|
var reducer = (0, toolkit_1.createSlice)({
|
|
119
99
|
name: 'treble',
|
|
120
100
|
initialState: initialState,
|
|
@@ -139,17 +119,16 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
139
119
|
builder.addCase(exports.reloadTreble, function (state, action) {
|
|
140
120
|
return __assign(__assign({}, state), action.payload);
|
|
141
121
|
});
|
|
122
|
+
builder.addCase(exports.updateLoadingProgress, function (state, action) {
|
|
123
|
+
state.loadingProgress = Math.round(action.payload * 100);
|
|
124
|
+
return state;
|
|
125
|
+
});
|
|
142
126
|
},
|
|
143
127
|
}).reducer;
|
|
144
|
-
/*****************************************************
|
|
145
|
-
* Standard Selectors
|
|
146
|
-
****************************************************/
|
|
147
|
-
// Loading Trackers
|
|
148
128
|
var getThreekitEnv = function (state) {
|
|
149
129
|
return state.treble.threekitEnv;
|
|
150
130
|
};
|
|
151
131
|
exports.getThreekitEnv = getThreekitEnv;
|
|
152
|
-
// Loading Trackers
|
|
153
132
|
var isThreekitInitialized = function (state) {
|
|
154
133
|
return state.treble.isThreekitInitialized;
|
|
155
134
|
};
|
|
@@ -158,14 +137,14 @@ var isPlayerLoading = function (state) {
|
|
|
158
137
|
return state.treble.isPlayerLoading;
|
|
159
138
|
};
|
|
160
139
|
exports.isPlayerLoading = isPlayerLoading;
|
|
161
|
-
// Player's HTML element
|
|
162
140
|
var getPlayerElementId = function (state) {
|
|
163
141
|
return state.treble.playerElId;
|
|
164
142
|
};
|
|
165
143
|
exports.getPlayerElementId = getPlayerElementId;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
var getLoadingProgress = function (state) {
|
|
145
|
+
return state.treble.loadingProgress;
|
|
146
|
+
};
|
|
147
|
+
exports.getLoadingProgress = getLoadingProgress;
|
|
169
148
|
var initPlayer = function (config) {
|
|
170
149
|
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
150
|
var el, authToken, assetId, stageId, orgId, playerConfig, initialConfiguration, player, configurator;
|
|
@@ -173,12 +152,14 @@ var initPlayer = function (config) {
|
|
|
173
152
|
switch (_a.label) {
|
|
174
153
|
case 0:
|
|
175
154
|
el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
|
|
176
|
-
return [4
|
|
177
|
-
|
|
178
|
-
|
|
155
|
+
return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
156
|
+
var _a;
|
|
157
|
+
dispatch((0, exports.updateLoadingProgress)(progress));
|
|
158
|
+
(_a = playerConfig === null || playerConfig === void 0 ? void 0 : playerConfig.onLoadingProgress) === null || _a === void 0 ? void 0 : _a.call(playerConfig, progress);
|
|
159
|
+
} }))];
|
|
179
160
|
case 1:
|
|
180
161
|
player = _a.sent();
|
|
181
|
-
return [4
|
|
162
|
+
return [4, player.getConfigurator()];
|
|
182
163
|
case 2:
|
|
183
164
|
configurator = _a.sent();
|
|
184
165
|
if (window.threekit) {
|
|
@@ -200,6 +181,7 @@ var initPlayer = function (config) {
|
|
|
200
181
|
};
|
|
201
182
|
dispatch((0, exports.setThreekitInitialized)(true));
|
|
202
183
|
dispatch((0, exports.setPlayerLoading)(false));
|
|
184
|
+
dispatch((0, exports.updateLoadingProgress)(1));
|
|
203
185
|
if (window.threekit.treble._debugMode)
|
|
204
186
|
(0, utils_1.runDebugger)();
|
|
205
187
|
window.threekit.player.on('setConfiguration', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -212,14 +194,14 @@ var initPlayer = function (config) {
|
|
|
212
194
|
previousAttributes = Object.values(attributes);
|
|
213
195
|
updatedAttributes = window.threekit.configurator.getDisplayAttributes();
|
|
214
196
|
dispatch((0, attributes_1.setAttributes)(updatedAttributes));
|
|
215
|
-
return [4
|
|
197
|
+
return [4, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
|
|
216
198
|
case 1:
|
|
217
199
|
_b.sent();
|
|
218
|
-
return [2
|
|
200
|
+
return [2];
|
|
219
201
|
}
|
|
220
202
|
});
|
|
221
203
|
}); });
|
|
222
|
-
return [2
|
|
204
|
+
return [2];
|
|
223
205
|
}
|
|
224
206
|
});
|
|
225
207
|
}); };
|
|
@@ -233,7 +215,7 @@ var launch = function (launchConfig) {
|
|
|
233
215
|
switch (_j.label) {
|
|
234
216
|
case 0:
|
|
235
217
|
if (window.threekit)
|
|
236
|
-
return [2
|
|
218
|
+
return [2];
|
|
237
219
|
config = (0, utils_1.loadTrebleConfig)();
|
|
238
220
|
credentials = ((_b = launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.project) === null || _b === void 0 ? void 0 : _b.credentials) || ((_c = config.project) === null || _c === void 0 ? void 0 : _c.credentials) || {};
|
|
239
221
|
productsRaw = ((_d = launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.project) === null || _d === void 0 ? void 0 : _d.products) || ((_e = config.project) === null || _e === void 0 ? void 0 : _e.products) || {};
|
|
@@ -280,12 +262,14 @@ var launch = function (launchConfig) {
|
|
|
280
262
|
return Object.assign(output, (_b = {}, _b[prodId] = updatedEnvs, _b));
|
|
281
263
|
}, {});
|
|
282
264
|
if (!Object.keys(credentials).length || !Object.keys(products).length)
|
|
283
|
-
return [2
|
|
265
|
+
return [2, console.error('Missing credentials')];
|
|
266
|
+
dispatch((0, product_1.initProduct)(products));
|
|
267
|
+
dispatch((0, product_1.setProductId)(productId));
|
|
284
268
|
threekitEnv = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.threekitEnv) || process.env.THREEKIT_ENV || 'preview';
|
|
285
269
|
serverUrl = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.serverUrl) || ((_g = config === null || config === void 0 ? void 0 : config.project) === null || _g === void 0 ? void 0 : _g.serverUrl);
|
|
286
270
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, config.player, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.playerConfig);
|
|
287
271
|
envCredentials = credentials[threekitEnv];
|
|
288
|
-
_a = products[productId][threekitEnv], assetIdRaw = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
|
|
272
|
+
_a = products[productId][threekitEnv] || {}, assetIdRaw = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
|
|
289
273
|
assetId = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.assetId) || assetIdRaw;
|
|
290
274
|
threekitDomainRaw = envCredentials.threekitDomain || "".concat(threekitEnv, ".threekit.com");
|
|
291
275
|
orgId = envCredentials.orgId, authToken = envCredentials.publicToken;
|
|
@@ -298,7 +282,6 @@ var launch = function (launchConfig) {
|
|
|
298
282
|
el = createPlayerLoaderEl(constants_1.TK_PLAYER_ROOT_DIV);
|
|
299
283
|
dispatch((0, exports.setPlayerElement)(constants_1.TK_PLAYER_ROOT_DIV));
|
|
300
284
|
}
|
|
301
|
-
// Connection
|
|
302
285
|
connection_1.default.connect({
|
|
303
286
|
authToken: authToken,
|
|
304
287
|
orgId: orgId,
|
|
@@ -313,8 +296,8 @@ var launch = function (launchConfig) {
|
|
|
313
296
|
configId = ((_h = params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]) === null || _h === void 0 ? void 0 : _h.length)
|
|
314
297
|
? params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]
|
|
315
298
|
: configurationId;
|
|
316
|
-
if (!configId) return [3
|
|
317
|
-
return [4
|
|
299
|
+
if (!configId) return [3, 2];
|
|
300
|
+
return [4, api_1.default.configurations.fetch(configId)];
|
|
318
301
|
case 1:
|
|
319
302
|
configuration = _j.sent();
|
|
320
303
|
if (configuration) {
|
|
@@ -325,9 +308,8 @@ var launch = function (launchConfig) {
|
|
|
325
308
|
_j.label = 2;
|
|
326
309
|
case 2:
|
|
327
310
|
if (!updatedAssetId)
|
|
328
|
-
return [2
|
|
329
|
-
|
|
330
|
-
return [4 /*yield*/, new Promise(function (resolve) {
|
|
311
|
+
return [2, console.error('missing assetId')];
|
|
312
|
+
return [4, new Promise(function (resolve) {
|
|
331
313
|
var script = document.createElement('script');
|
|
332
314
|
script.src = "".concat(threekitDomain, "/app/js/threekit-player-bundle.js");
|
|
333
315
|
script.id = 'threekit-player-bundle';
|
|
@@ -335,9 +317,8 @@ var launch = function (launchConfig) {
|
|
|
335
317
|
document.head.appendChild(script);
|
|
336
318
|
})];
|
|
337
319
|
case 3:
|
|
338
|
-
// We create the threekit script
|
|
339
320
|
_j.sent();
|
|
340
|
-
return [4
|
|
321
|
+
return [4, dispatch((0, exports.initPlayer)({
|
|
341
322
|
el: el,
|
|
342
323
|
orgId: orgId,
|
|
343
324
|
authToken: authToken,
|
|
@@ -352,14 +333,15 @@ var launch = function (launchConfig) {
|
|
|
352
333
|
message_1.default.info(e.detail.message);
|
|
353
334
|
});
|
|
354
335
|
EVENTS = Object.assign(EVENTS, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.eventHandlers);
|
|
336
|
+
dispatch((0, product_1.setName)());
|
|
337
|
+
dispatch((0, product_1.setMetadata)());
|
|
338
|
+
dispatch((0, product_1.initProduct)());
|
|
355
339
|
dispatch((0, exports.setThreekitEnv)(threekitEnv));
|
|
356
340
|
dispatch((0, translations_1.initTranslations)(launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.locale));
|
|
357
341
|
dispatch((0, price_1.initPrice)());
|
|
358
342
|
dispatch((0, price_1.updatePrice)());
|
|
359
|
-
dispatch((0, product_1.initProduct)(products));
|
|
360
|
-
dispatch((0, product_1.setProductId)(productId));
|
|
361
343
|
dispatch((0, wishlist_1.refreshWishlist)());
|
|
362
|
-
return [2
|
|
344
|
+
return [2];
|
|
363
345
|
}
|
|
364
346
|
});
|
|
365
347
|
}); };
|
|
@@ -374,10 +356,10 @@ var unloadPlayer = function () { return function (dispatch) { return __awaiter(v
|
|
|
374
356
|
dispatch((0, attributes_1.setAttributes)([]));
|
|
375
357
|
dispatch((0, product_1.setName)(''));
|
|
376
358
|
dispatch((0, product_1.setMetadata)({}));
|
|
377
|
-
return [4
|
|
359
|
+
return [4, window.threekit.player.unload()];
|
|
378
360
|
case 1:
|
|
379
361
|
_a.sent();
|
|
380
|
-
return [2
|
|
362
|
+
return [2];
|
|
381
363
|
}
|
|
382
364
|
});
|
|
383
365
|
}); }; };
|
|
@@ -389,19 +371,19 @@ var reloadPlayer = function (config) {
|
|
|
389
371
|
switch (_a.label) {
|
|
390
372
|
case 0:
|
|
391
373
|
connectionObj = connection_1.default.getConnection();
|
|
392
|
-
if (!(config === undefined)) return [3
|
|
374
|
+
if (!(config === undefined)) return [3, 1];
|
|
393
375
|
assetId = connectionObj.assetId;
|
|
394
|
-
return [3
|
|
376
|
+
return [3, 4];
|
|
395
377
|
case 1:
|
|
396
|
-
if (!(typeof config === 'string')) return [3
|
|
378
|
+
if (!(typeof config === 'string')) return [3, 2];
|
|
397
379
|
assetId = config;
|
|
398
|
-
return [3
|
|
380
|
+
return [3, 4];
|
|
399
381
|
case 2:
|
|
400
382
|
assetId = (config === null || config === void 0 ? void 0 : config.assetId) || connectionObj.assetId;
|
|
401
383
|
stageId = config === null || config === void 0 ? void 0 : config.stageId;
|
|
402
384
|
initialConfiguration = (config === null || config === void 0 ? void 0 : config.configuration) || {};
|
|
403
|
-
if (!(config === null || config === void 0 ? void 0 : config.configurationId)) return [3
|
|
404
|
-
return [4
|
|
385
|
+
if (!(config === null || config === void 0 ? void 0 : config.configurationId)) return [3, 4];
|
|
386
|
+
return [4, api_1.default.configurations.fetch(config === null || config === void 0 ? void 0 : config.configurationId)];
|
|
405
387
|
case 3:
|
|
406
388
|
configuration = _a.sent();
|
|
407
389
|
if (configuration) {
|
|
@@ -410,19 +392,18 @@ var reloadPlayer = function (config) {
|
|
|
410
392
|
}
|
|
411
393
|
_a.label = 4;
|
|
412
394
|
case 4:
|
|
413
|
-
// Update connection
|
|
414
395
|
if (assetId !== connectionObj.assetId)
|
|
415
396
|
connection_1.default.connect({ assetId: assetId });
|
|
416
397
|
state = getState();
|
|
417
398
|
trebleConfig = (0, utils_1.loadTrebleConfig)();
|
|
418
399
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, trebleConfig.player);
|
|
419
400
|
el = document.getElementById(state.treble.playerElId);
|
|
420
|
-
if (!state.treble.isThreekitInitialized) return [3
|
|
421
|
-
return [4
|
|
401
|
+
if (!state.treble.isThreekitInitialized) return [3, 6];
|
|
402
|
+
return [4, dispatch((0, exports.unloadPlayer)())];
|
|
422
403
|
case 5:
|
|
423
404
|
_a.sent();
|
|
424
405
|
_a.label = 6;
|
|
425
|
-
case 6: return [4
|
|
406
|
+
case 6: return [4, dispatch((0, exports.initPlayer)({
|
|
426
407
|
el: el,
|
|
427
408
|
orgId: connectionObj.orgId,
|
|
428
409
|
authToken: connectionObj.authToken,
|
|
@@ -435,7 +416,7 @@ var reloadPlayer = function (config) {
|
|
|
435
416
|
_a.sent();
|
|
436
417
|
dispatch((0, price_1.updatePrice)());
|
|
437
418
|
dispatch((0, product_1.initProduct)());
|
|
438
|
-
return [2
|
|
419
|
+
return [2];
|
|
439
420
|
}
|
|
440
421
|
});
|
|
441
422
|
}); };
|
package/dist/store/wishlist.d.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
2
|
import { WishlistArray } from '../Treble';
|
|
3
3
|
import { ISaveConfiguration } from '../api/configurations';
|
|
4
|
-
/*****************************************************
|
|
5
|
-
* Types and Interfaces
|
|
6
|
-
****************************************************/
|
|
7
4
|
export declare type WishlistState = WishlistArray;
|
|
8
|
-
/*****************************************************
|
|
9
|
-
* Standard Selectors
|
|
10
|
-
****************************************************/
|
|
11
5
|
export declare const refreshWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], void, {}>;
|
|
12
|
-
export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], Omit<ISaveConfiguration, "
|
|
6
|
+
export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], Omit<ISaveConfiguration, "configuration">, {}>;
|
|
13
7
|
export declare const clearWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/clear", never, never>;
|
|
14
8
|
export declare const removeFromWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[idx: number], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/remove-item", never, never>;
|
|
15
|
-
/*****************************************************
|
|
16
|
-
* Slice
|
|
17
|
-
****************************************************/
|
|
18
9
|
declare const reducer: import("redux").Reducer<WishlistArray, import("redux").AnyAction>;
|
|
19
|
-
/*****************************************************
|
|
20
|
-
* Standard Selectors
|
|
21
|
-
****************************************************/
|
|
22
10
|
export declare const getWishlist: (state: RootState) => WishlistArray;
|
|
23
11
|
export declare const resumeFromWishlist: (idx: number) => (_: ThreekitDispatch, getState: () => RootState) => void;
|
|
24
12
|
export default reducer;
|
package/dist/store/wishlist.js
CHANGED
|
@@ -38,21 +38,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.resumeFromWishlist = exports.getWishlist = exports.removeFromWishlist = exports.clearWishlist = exports.addToWishlist = exports.refreshWishlist = void 0;
|
|
40
40
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
41
|
-
/*****************************************************
|
|
42
|
-
* State
|
|
43
|
-
****************************************************/
|
|
44
41
|
var initialState = [];
|
|
45
|
-
/*****************************************************
|
|
46
|
-
* Standard Selectors
|
|
47
|
-
****************************************************/
|
|
48
42
|
exports.refreshWishlist = (0, toolkit_1.createAsyncThunk)('treble/wishlist/refresh-data', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
43
|
var wishlistData;
|
|
50
44
|
return __generator(this, function (_a) {
|
|
51
45
|
switch (_a.label) {
|
|
52
|
-
case 0: return [4
|
|
46
|
+
case 0: return [4, window.threekit.treble.wishlist.getWishlist()];
|
|
53
47
|
case 1:
|
|
54
48
|
wishlistData = _a.sent();
|
|
55
|
-
return [2
|
|
49
|
+
return [2, wishlistData];
|
|
56
50
|
}
|
|
57
51
|
});
|
|
58
52
|
}); });
|
|
@@ -60,10 +54,10 @@ exports.addToWishlist = (0, toolkit_1.createAsyncThunk)('treble/wishlist/add-ite
|
|
|
60
54
|
var wishlistData;
|
|
61
55
|
return __generator(this, function (_a) {
|
|
62
56
|
switch (_a.label) {
|
|
63
|
-
case 0: return [4
|
|
57
|
+
case 0: return [4, window.threekit.treble.wishlist.addItem(config)];
|
|
64
58
|
case 1:
|
|
65
59
|
wishlistData = _a.sent();
|
|
66
|
-
return [2
|
|
60
|
+
return [2, wishlistData];
|
|
67
61
|
}
|
|
68
62
|
});
|
|
69
63
|
}); });
|
|
@@ -75,9 +69,6 @@ exports.removeFromWishlist = (0, toolkit_1.createAction)('treble/wishlist/remove
|
|
|
75
69
|
var wishlistData = window.threekit.treble.wishlist.removeItemByIdx(idx);
|
|
76
70
|
return { payload: wishlistData };
|
|
77
71
|
});
|
|
78
|
-
/*****************************************************
|
|
79
|
-
* Slice
|
|
80
|
-
****************************************************/
|
|
81
72
|
var reducer = (0, toolkit_1.createSlice)({
|
|
82
73
|
name: 'wishlist',
|
|
83
74
|
initialState: initialState,
|
|
@@ -97,10 +88,6 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
97
88
|
});
|
|
98
89
|
},
|
|
99
90
|
}).reducer;
|
|
100
|
-
/*****************************************************
|
|
101
|
-
* Standard Selectors
|
|
102
|
-
****************************************************/
|
|
103
|
-
// Wishlist
|
|
104
91
|
var getWishlist = function (state) { return state.wishlist; };
|
|
105
92
|
exports.getWishlist = getWishlist;
|
|
106
93
|
var resumeFromWishlist = function (idx) { return function (_, getState) {
|
package/dist/types.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ export declare type DISPLAY_OPTIONS = 'webgl' | 'image';
|
|
|
7
7
|
export declare type IAttributeTypes = 'String' | 'Asset' | 'Color' | 'Number' | 'Boolean';
|
|
8
8
|
export declare type AssetType = 'upload' | 'item';
|
|
9
9
|
export declare type IMetadata = Record<string, string | number | null>;
|
|
10
|
-
/***************************************************
|
|
11
|
-
* Scene
|
|
12
|
-
**************************************************/
|
|
13
10
|
export interface ISceneQuery {
|
|
14
11
|
all?: boolean;
|
|
15
12
|
id?: string;
|
|
@@ -41,9 +38,6 @@ export interface ISceneResult {
|
|
|
41
38
|
name: string;
|
|
42
39
|
configurator: IThreekitPrivateConfigurator;
|
|
43
40
|
}
|
|
44
|
-
/***************************************************
|
|
45
|
-
* Configuration
|
|
46
|
-
**************************************************/
|
|
47
41
|
export interface IConfigurationAsset {
|
|
48
42
|
assetId: string;
|
|
49
43
|
configuration?: string;
|
|
@@ -57,11 +51,6 @@ export interface IConfigurationColor {
|
|
|
57
51
|
export declare type IConfigurationAttribute = IConfigurationAsset | IConfigurationColor | string | number | boolean | undefined;
|
|
58
52
|
export declare type IConfiguration = Record<string, IConfigurationAttribute>;
|
|
59
53
|
export declare type ISetConfiguration = Record<string, IConfigurationAttribute>;
|
|
60
|
-
/***************************************************
|
|
61
|
-
* ATTRIBUTES
|
|
62
|
-
*
|
|
63
|
-
* This section covers both getAttributes() and getDisplayAttributes()
|
|
64
|
-
**************************************************/
|
|
65
54
|
interface IDisplayAttributeConfig {
|
|
66
55
|
includeHidden?: boolean;
|
|
67
56
|
}
|
|
@@ -72,7 +61,6 @@ interface IAttributeBase<T extends IAttributeTypes, V extends IConfigurationAttr
|
|
|
72
61
|
value: V;
|
|
73
62
|
label: string;
|
|
74
63
|
}
|
|
75
|
-
/****** ASSET TYPE ATTRIBUTE *******/
|
|
76
64
|
export interface IConfigurationAssetValue {
|
|
77
65
|
assetId: string;
|
|
78
66
|
name: string;
|
|
@@ -101,7 +89,6 @@ export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigu
|
|
|
101
89
|
export declare type IDisplayAttributeAsset = IAttributeAssetBase<IDisplayAttributeAssetValue>;
|
|
102
90
|
export declare type IHydratedAttributeAsset = IAttributeAssetBase<IHydratedAttributeAssetValue>;
|
|
103
91
|
export declare type IAttributeAsset = IAttributeAssetBase<IConfigurationAssetValue>;
|
|
104
|
-
/****** String TYPE ATTRIBUTE *******/
|
|
105
92
|
export interface IDisplayAttributeStringValue {
|
|
106
93
|
label: string;
|
|
107
94
|
value: string;
|
|
@@ -120,11 +107,9 @@ export interface IAttributeStringBase<V> extends IAttributeBase<'String', string
|
|
|
120
107
|
export declare type IDisplayAttributeString = IAttributeStringBase<IDisplayAttributeStringValue>;
|
|
121
108
|
export declare type IHydratedAttributeString = IAttributeStringBase<IHydratedAttributeStringValue>;
|
|
122
109
|
export declare type IAttributeString = IAttributeStringBase<string>;
|
|
123
|
-
/****** STRING TYPE ATTRIBUTE *******/
|
|
124
110
|
export interface IAttributeColor extends IAttributeBase<'Color', IConfigurationColor> {
|
|
125
111
|
defaultValue: IConfigurationColor;
|
|
126
112
|
}
|
|
127
|
-
/****** NUMBER TYPE ATTRIBUTE *******/
|
|
128
113
|
export interface IAttributeNumber extends IAttributeBase<'Number', number> {
|
|
129
114
|
defaultValue: number;
|
|
130
115
|
lockToStep: boolean;
|
|
@@ -132,19 +117,12 @@ export interface IAttributeNumber extends IAttributeBase<'Number', number> {
|
|
|
132
117
|
min?: number;
|
|
133
118
|
step: number;
|
|
134
119
|
}
|
|
135
|
-
/****** NUMBER TYPE ATTRIBUTE *******/
|
|
136
120
|
export interface IAttributeBoolean extends IAttributeBase<'Boolean', boolean> {
|
|
137
121
|
defaultValue: boolean;
|
|
138
122
|
}
|
|
139
|
-
/****** getAttributes() *******/
|
|
140
123
|
export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber | IAttributeBoolean;
|
|
141
|
-
/****** getDisplayAttributes() *******/
|
|
142
124
|
export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
|
|
143
|
-
/****** Treble Hydrated Values *******/
|
|
144
125
|
export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
|
|
145
|
-
/***************************************************
|
|
146
|
-
* Camera
|
|
147
|
-
**************************************************/
|
|
148
126
|
export interface ICoordinates {
|
|
149
127
|
x: number;
|
|
150
128
|
y: number;
|
|
@@ -161,9 +139,53 @@ export interface ISnapshotConfig {
|
|
|
161
139
|
};
|
|
162
140
|
}
|
|
163
141
|
export declare type SNAPSHOT_FORMAT_TYPES = 'jpg' | 'png';
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
142
|
+
export interface Node {
|
|
143
|
+
name: string;
|
|
144
|
+
nodeId: string;
|
|
145
|
+
type: string;
|
|
146
|
+
}
|
|
147
|
+
export interface HitNode {
|
|
148
|
+
distance: number;
|
|
149
|
+
intersection: ICoordinates;
|
|
150
|
+
nodeId: string;
|
|
151
|
+
hierarchy: Array<Node>;
|
|
152
|
+
}
|
|
153
|
+
export interface PlayerToolEvent {
|
|
154
|
+
altKey: boolean;
|
|
155
|
+
clientX: number;
|
|
156
|
+
clientY: number;
|
|
157
|
+
deltaX: number;
|
|
158
|
+
deltaY: number;
|
|
159
|
+
ctrlKey: boolean;
|
|
160
|
+
isTouch: boolean;
|
|
161
|
+
metaKey: boolean;
|
|
162
|
+
shiftKey: boolean;
|
|
163
|
+
which: number;
|
|
164
|
+
originalEvent: MouseEvent;
|
|
165
|
+
rect: DOMRect;
|
|
166
|
+
hitNodes: Array<HitNode>;
|
|
167
|
+
}
|
|
168
|
+
export interface CustomPlayerTool {
|
|
169
|
+
key: string;
|
|
170
|
+
label: string;
|
|
171
|
+
active: boolean;
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
handlers: {
|
|
174
|
+
click?: (event: PlayerToolEvent) => void | Promise<void>;
|
|
175
|
+
mousedown?: (event: PlayerToolEvent) => void | Promise<void>;
|
|
176
|
+
mouseup?: (event: PlayerToolEvent) => void | Promise<void>;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export interface IThreekitTools {
|
|
180
|
+
addTool: (tool: string | CustomPlayerTool) => void;
|
|
181
|
+
addTools: (tools: Array<string | CustomPlayerTool>) => void;
|
|
182
|
+
removeTool: (tool: string) => void;
|
|
183
|
+
removeTools: (tools: Array<string>) => void;
|
|
184
|
+
setPrimary: (tool: string) => void;
|
|
185
|
+
getPrimaryTool: () => string;
|
|
186
|
+
setTool: () => void;
|
|
187
|
+
setTools: () => void;
|
|
188
|
+
}
|
|
167
189
|
export interface IConfigurationChangeEvent {
|
|
168
190
|
name: string;
|
|
169
191
|
appliedConfiguration: Record<string, string>;
|
|
@@ -189,16 +211,6 @@ export interface IThreekitScene {
|
|
|
189
211
|
find: (query: ISceneQuery | string) => ISceneResult;
|
|
190
212
|
set: (query: ISceneQuery | string, transform: ICoordinates) => void;
|
|
191
213
|
}
|
|
192
|
-
export interface IThreekitTools {
|
|
193
|
-
addTool: (tool: string) => void;
|
|
194
|
-
addTools: (tools: string[]) => void;
|
|
195
|
-
removeTool: (tool: string) => void;
|
|
196
|
-
removeTools: (tools: string[]) => void;
|
|
197
|
-
setPrimary: (tool: string) => void;
|
|
198
|
-
getPrimaryTool: () => string;
|
|
199
|
-
setTool: () => void;
|
|
200
|
-
setTools: () => void;
|
|
201
|
-
}
|
|
202
214
|
export interface IThreekitCamera {
|
|
203
215
|
frameBoundingSphere: () => void;
|
|
204
216
|
getPosition: () => ICoordinates;
|
|
@@ -265,9 +277,6 @@ export interface ThreekitInitConfig {
|
|
|
265
277
|
help?: string;
|
|
266
278
|
};
|
|
267
279
|
}
|
|
268
|
-
/***************************************************
|
|
269
|
-
* Treble Declarations
|
|
270
|
-
**************************************************/
|
|
271
280
|
export interface IFrameworkConfig {
|
|
272
281
|
productsCtx: __WebpackModuleApi.RequireContext;
|
|
273
282
|
}
|
|
@@ -297,9 +306,6 @@ export interface ITrebleConfig {
|
|
|
297
306
|
treble: IFrameworkConfig;
|
|
298
307
|
player: IPlayerConfig;
|
|
299
308
|
}
|
|
300
|
-
/***************************************************
|
|
301
|
-
* Global Declaration
|
|
302
|
-
**************************************************/
|
|
303
309
|
declare global {
|
|
304
310
|
interface Window {
|
|
305
311
|
threekitPlayer: (arg0: ThreekitInitConfig) => Promise<IThreekitPlayer>;
|
package/dist/utils.d.ts
CHANGED
|
@@ -15,13 +15,13 @@ interface IAttributeComponentProps {
|
|
|
15
15
|
interface IAttributesComponentProps {
|
|
16
16
|
[attributeName: string]: undefined | false | IAttributeComponentProps;
|
|
17
17
|
}
|
|
18
|
-
export declare const generateClassName: (baseClass: string) => (component: string, customClassName?: string
|
|
19
|
-
export declare const generateInputClassName: (component: string, customClassName?: string
|
|
20
|
-
export declare const generateWidgetClassName: (component: string, customClassName?: string
|
|
21
|
-
export declare const generateLayoutClassName: (component: string, customClassName?: string
|
|
22
|
-
export declare const generateToolClassName: (component: string, customClassName?: string
|
|
23
|
-
export declare const generateDisplayClassName: (component: string, customClassName?: string
|
|
24
|
-
export declare const generateFormClassName: (component: string, customClassName?: string
|
|
18
|
+
export declare const generateClassName: (baseClass: string) => (component: string, customClassName?: string, title?: string) => string;
|
|
19
|
+
export declare const generateInputClassName: (component: string, customClassName?: string, title?: string) => string;
|
|
20
|
+
export declare const generateWidgetClassName: (component: string, customClassName?: string, title?: string) => string;
|
|
21
|
+
export declare const generateLayoutClassName: (component: string, customClassName?: string, title?: string) => string;
|
|
22
|
+
export declare const generateToolClassName: (component: string, customClassName?: string, title?: string) => string;
|
|
23
|
+
export declare const generateDisplayClassName: (component: string, customClassName?: string, title?: string) => string;
|
|
24
|
+
export declare const generateFormClassName: (component: string, customClassName?: string, title?: string) => string;
|
|
25
25
|
export declare const isIOS: () => RegExpMatchArray | null;
|
|
26
26
|
export declare const isJsonString: (str: string) => boolean;
|
|
27
27
|
export declare const objectToQueryStr: (obj: Record<string, any>) => string;
|
|
@@ -57,7 +57,7 @@ export declare const selectionToConfiguration: (value: RawAttributeValue, attrib
|
|
|
57
57
|
assetId: RawAttributeValue;
|
|
58
58
|
} | undefined;
|
|
59
59
|
export declare const filterFormAttributes: (attributes: Record<string, IThreekitDisplayAttribute>, attributeComponentProps: IAttributesComponentProps, includeReservedAttributes: boolean) => IThreekitDisplayAttribute[];
|
|
60
|
-
export declare const isUuid: (str?: string
|
|
60
|
+
export declare const isUuid: (str?: string) => boolean;
|
|
61
61
|
export declare const runDebugger: () => Promise<void>;
|
|
62
62
|
export declare const loadTrebleConfig: () => Partial<ITrebleConfig>;
|
|
63
63
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -143,35 +143,26 @@ var shallowCompare = function (value1, value2) {
|
|
|
143
143
|
};
|
|
144
144
|
exports.shallowCompare = shallowCompare;
|
|
145
145
|
var deepCompare = function (item1, item2) {
|
|
146
|
-
// Are the items the same type
|
|
147
146
|
if (typeof item1 !== typeof item2)
|
|
148
147
|
return false;
|
|
149
|
-
// If that type is Array we deepCompare each item
|
|
150
|
-
// against its counter part
|
|
151
|
-
// The same arrays in different orders will fail this check
|
|
152
148
|
else if (Array.isArray(item1)) {
|
|
153
149
|
if (item1.length !== item2.length)
|
|
154
150
|
return false;
|
|
155
151
|
for (var i = 0; i < item1.length; i++)
|
|
156
152
|
if (!(0, exports.deepCompare)(item1[i], item2[i]))
|
|
157
153
|
return false;
|
|
158
|
-
// If they're objects...
|
|
159
154
|
}
|
|
160
155
|
else if (isObject(item1)) {
|
|
161
156
|
var keys1 = Object.keys(item1);
|
|
162
157
|
var keys2 = Object.keys(item2);
|
|
163
|
-
// We makre sure they have the same keys...
|
|
164
158
|
if (keys1.length !== keys2.length) {
|
|
165
159
|
return false;
|
|
166
160
|
}
|
|
167
|
-
// and then deep compare each value
|
|
168
161
|
for (var _i = 0, keys1_2 = keys1; _i < keys1_2.length; _i++) {
|
|
169
162
|
var key = keys1_2[_i];
|
|
170
163
|
if (!(0, exports.deepCompare)(item1[key], item2[key]))
|
|
171
164
|
return false;
|
|
172
165
|
}
|
|
173
|
-
// This leaves us with literals that can be
|
|
174
|
-
// compared directly
|
|
175
166
|
}
|
|
176
167
|
else if (item1 !== item2)
|
|
177
168
|
return false;
|
|
@@ -280,7 +271,7 @@ var downloadSnapshot = function (snapshot, filename) { return __awaiter(void 0,
|
|
|
280
271
|
link.addEventListener('click', clickHandler);
|
|
281
272
|
document.body.appendChild(link);
|
|
282
273
|
link.click();
|
|
283
|
-
return [2
|
|
274
|
+
return [2];
|
|
284
275
|
});
|
|
285
276
|
}); };
|
|
286
277
|
exports.downloadSnapshot = downloadSnapshot;
|
|
@@ -409,12 +400,12 @@ var runDebugger = function () { return __awaiter(void 0, void 0, void 0, functio
|
|
|
409
400
|
var logs;
|
|
410
401
|
return __generator(this, function (_a) {
|
|
411
402
|
switch (_a.label) {
|
|
412
|
-
case 0: return [4
|
|
403
|
+
case 0: return [4, window.threekit.treble._player.calculateLogs()];
|
|
413
404
|
case 1:
|
|
414
405
|
logs = _a.sent();
|
|
415
406
|
if (logs.length)
|
|
416
407
|
console.log("Threekit Debugger: \n", logs);
|
|
417
|
-
return [2
|
|
408
|
+
return [2];
|
|
418
409
|
}
|
|
419
410
|
});
|
|
420
411
|
}); };
|