@threekit-tools/treble 0.0.57 → 0.0.60-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Treble/Snapshots.js +32 -63
- package/dist/Treble/Treble.d.ts +9 -7
- package/dist/Treble/Treble.js +26 -6
- package/dist/Treble/Wishlist.d.ts +3 -3
- package/dist/Treble/Wishlist.js +1 -0
- package/dist/api/configurations.d.ts +2 -3
- package/dist/api/configurations.js +28 -22
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/server.d.ts +2 -0
- package/dist/api/server.js +11 -0
- package/dist/components/Cards/index.js +3 -4
- package/dist/components/Dropdown/index.js +6 -10
- package/dist/components/Strips/index.js +3 -4
- package/dist/components/Swatch/index.js +3 -4
- package/dist/components/TextInput/index.d.ts +1 -0
- package/dist/components/TextInput/index.js +2 -2
- package/dist/components/TextInput/textInput.styles.js +1 -1
- package/dist/components/ThreekitProvider/index.d.ts +1 -0
- package/dist/components/ThreekitProvider/index.js +10 -3
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/TrebleApp/index.d.ts +1 -0
- package/dist/components/TrebleApp/index.js +16 -6
- package/dist/components/Wishlist/index.js +6 -11
- package/dist/components/containers/formInputContainer.d.ts +9 -5
- package/dist/components/containers/formInputContainer.js +14 -19
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +4 -0
- package/dist/hooks/useAttribute/index.d.ts +2 -2
- package/dist/hooks/useAttribute/index.js +6 -5
- package/dist/hooks/useConfigurator/index.d.ts +2 -2
- package/dist/hooks/useConfigurator/index.js +7 -3
- package/dist/hooks/useNestedConfigurator/index.d.ts +8 -0
- package/dist/hooks/useNestedConfigurator/index.js +93 -0
- package/dist/hooks/useProductCache/index.d.ts +22 -0
- package/dist/hooks/useProductCache/index.js +28 -0
- package/dist/hooks/useSingleAnimation/index.d.ts +17 -0
- package/dist/hooks/useSingleAnimation/index.js +264 -0
- package/dist/hooks/useWishlist/index.d.ts +10 -7
- package/dist/hooks/useWishlist/index.js +17 -25
- package/dist/http/configurations.d.ts +1 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +14 -0
- package/dist/http/server.js +17 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -1
- package/dist/store/attributes.d.ts +14 -1
- package/dist/store/attributes.js +6 -45
- package/dist/store/price.js +2 -2
- package/dist/store/product.d.ts +47 -2
- package/dist/store/product.js +267 -12
- package/dist/store/translations.d.ts +4 -2
- package/dist/store/translations.js +4 -12
- package/dist/store/treble.d.ts +36 -2
- package/dist/store/treble.js +214 -52
- package/dist/store/wishlist.d.ts +3 -2
- package/dist/threekit.d.ts +20 -2
- package/dist/utils.d.ts +9 -11
- package/dist/utils.js +83 -27
- package/package.json +17 -2
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
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.launch = exports.getPlayerElementId = exports.isPlayerLoading = exports.isThreekitInitialized = exports.setPlayerElement = exports.setPlayerLoading = exports.setThreekitInitialized = void 0;
|
|
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;
|
|
54
54
|
var connection_1 = __importDefault(require("../connection"));
|
|
55
55
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
56
56
|
var api_1 = __importDefault(require("../api"));
|
|
@@ -62,6 +62,7 @@ var price_1 = require("./price");
|
|
|
62
62
|
var wishlist_1 = require("./wishlist");
|
|
63
63
|
var translations_1 = require("./translations");
|
|
64
64
|
var product_1 = require("./product");
|
|
65
|
+
var message_1 = __importDefault(require("../components/message"));
|
|
65
66
|
/*****************************************************
|
|
66
67
|
* Helper Functions
|
|
67
68
|
****************************************************/
|
|
@@ -97,16 +98,20 @@ var EVENTS = {};
|
|
|
97
98
|
* State
|
|
98
99
|
****************************************************/
|
|
99
100
|
var initialState = {
|
|
101
|
+
threekitEnv: 'preview',
|
|
100
102
|
isThreekitInitialized: false,
|
|
101
103
|
isPlayerLoading: false,
|
|
102
104
|
playerElId: undefined,
|
|
105
|
+
notifications: true,
|
|
103
106
|
};
|
|
104
107
|
/*****************************************************
|
|
105
108
|
* Actions
|
|
106
109
|
****************************************************/
|
|
110
|
+
exports.setThreekitEnv = (0, toolkit_1.createAction)('treble/set-threekit-env');
|
|
107
111
|
exports.setThreekitInitialized = (0, toolkit_1.createAction)('treble/set-threekit-initialized');
|
|
108
112
|
exports.setPlayerLoading = (0, toolkit_1.createAction)('treble/set-player-loading');
|
|
109
113
|
exports.setPlayerElement = (0, toolkit_1.createAction)('treble/set-player-element');
|
|
114
|
+
exports.reloadTreble = (0, toolkit_1.createAction)('treble/reload');
|
|
110
115
|
/*****************************************************
|
|
111
116
|
* Slice
|
|
112
117
|
****************************************************/
|
|
@@ -115,14 +120,24 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
115
120
|
initialState: initialState,
|
|
116
121
|
reducers: {},
|
|
117
122
|
extraReducers: function (builder) {
|
|
118
|
-
builder.addCase(exports.
|
|
119
|
-
state.
|
|
123
|
+
builder.addCase(exports.setThreekitEnv, function (state, action) {
|
|
124
|
+
state.threekitEnv = action.payload;
|
|
125
|
+
return state;
|
|
126
|
+
});
|
|
127
|
+
builder.addCase(exports.setThreekitInitialized, function (state, action) {
|
|
128
|
+
state.isThreekitInitialized = action.payload;
|
|
129
|
+
return state;
|
|
120
130
|
});
|
|
121
131
|
builder.addCase(exports.setPlayerLoading, function (state, action) {
|
|
122
132
|
state.isPlayerLoading = action.payload;
|
|
133
|
+
return state;
|
|
123
134
|
});
|
|
124
135
|
builder.addCase(exports.setPlayerElement, function (state, action) {
|
|
125
136
|
state.playerElId = action.payload;
|
|
137
|
+
return state;
|
|
138
|
+
});
|
|
139
|
+
builder.addCase(exports.reloadTreble, function (state, action) {
|
|
140
|
+
return __assign(__assign({}, state), action.payload);
|
|
126
141
|
});
|
|
127
142
|
},
|
|
128
143
|
}).reducer;
|
|
@@ -130,6 +145,11 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
130
145
|
* Standard Selectors
|
|
131
146
|
****************************************************/
|
|
132
147
|
// Loading Trackers
|
|
148
|
+
var getThreekitEnv = function (state) {
|
|
149
|
+
return state.treble.threekitEnv;
|
|
150
|
+
};
|
|
151
|
+
exports.getThreekitEnv = getThreekitEnv;
|
|
152
|
+
// Loading Trackers
|
|
133
153
|
var isThreekitInitialized = function (state) {
|
|
134
154
|
return state.treble.isThreekitInitialized;
|
|
135
155
|
};
|
|
@@ -146,41 +166,109 @@ exports.getPlayerElementId = getPlayerElementId;
|
|
|
146
166
|
/*****************************************************
|
|
147
167
|
* Complex Actions
|
|
148
168
|
****************************************************/
|
|
169
|
+
var initPlayer = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
+
var el, authToken, assetId, stageId, orgId, playerConfig, initialConfiguration, player, configurator;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
|
|
175
|
+
return [4 /*yield*/, window.threekitPlayer(__assign(__assign({ el: el,
|
|
176
|
+
// Variables to sort out
|
|
177
|
+
authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration }))];
|
|
178
|
+
case 1:
|
|
179
|
+
player = _a.sent();
|
|
180
|
+
return [4 /*yield*/, player.getConfigurator()];
|
|
181
|
+
case 2:
|
|
182
|
+
configurator = _a.sent();
|
|
183
|
+
if (window.threekit) {
|
|
184
|
+
window.threekit = Object.assign(window.threekit, {
|
|
185
|
+
player: player,
|
|
186
|
+
configurator: configurator,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
else
|
|
190
|
+
window.threekit = {
|
|
191
|
+
player: player,
|
|
192
|
+
configurator: configurator,
|
|
193
|
+
treble: new Treble_1.default({
|
|
194
|
+
player: player,
|
|
195
|
+
orgId: orgId,
|
|
196
|
+
initialConfiguration: configurator.getConfiguration(),
|
|
197
|
+
}),
|
|
198
|
+
};
|
|
199
|
+
dispatch((0, exports.setThreekitInitialized)(true));
|
|
200
|
+
dispatch((0, exports.setPlayerLoading)(false));
|
|
201
|
+
window.threekit.player.on('setConfiguration', function () {
|
|
202
|
+
dispatch((0, attributes_1.setAttributes)(window.threekit.configurator.getDisplayAttributes()));
|
|
203
|
+
});
|
|
204
|
+
return [2 /*return*/];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}); }; };
|
|
208
|
+
exports.initPlayer = initPlayer;
|
|
149
209
|
var launch = function (launchConfig) {
|
|
150
210
|
return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
-
var config, credentials, products, threekitEnv, playerConfig, envCredentials,
|
|
152
|
-
var
|
|
153
|
-
return __generator(this, function (
|
|
154
|
-
switch (
|
|
211
|
+
var config, productId, credentials, productsRaw, products, threekitEnv, serverUrl, playerConfig, envCredentials, _a, assetId, stageId, configurationId, initialConfigurationRaw, threekitDomainRaw, orgId, authToken, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration;
|
|
212
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
213
|
+
return __generator(this, function (_j) {
|
|
214
|
+
switch (_j.label) {
|
|
155
215
|
case 0:
|
|
156
216
|
if (window.threekit)
|
|
157
217
|
return [2 /*return*/];
|
|
158
218
|
config = (0, utils_1.loadTrebleConfig)();
|
|
159
|
-
credentials =
|
|
160
|
-
|
|
219
|
+
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) || {};
|
|
220
|
+
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) || {};
|
|
221
|
+
if (!((_f = launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.productId) === null || _f === void 0 ? void 0 : _f.length)) {
|
|
222
|
+
productsRaw = { default: productsRaw };
|
|
223
|
+
productId = 'default';
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
productId = launchConfig.productId;
|
|
227
|
+
products = Object.entries(productsRaw).reduce(function (output, _a) {
|
|
228
|
+
var _b;
|
|
229
|
+
var prodId = _a[0], envs = _a[1];
|
|
230
|
+
var updatedEnvs = Object.entries(envs).reduce(function (result, _a) {
|
|
231
|
+
var _b;
|
|
232
|
+
var env = _a[0], conf = _a[1];
|
|
233
|
+
var initialConfiguration;
|
|
234
|
+
var assetId;
|
|
235
|
+
var stageId;
|
|
236
|
+
var configurationId;
|
|
237
|
+
if (typeof conf === 'string') {
|
|
238
|
+
if ((0, utils_1.isUuid)(conf))
|
|
239
|
+
assetId = conf;
|
|
240
|
+
else
|
|
241
|
+
configurationId = conf;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
stageId = conf.stageId;
|
|
245
|
+
if (conf.configurationId)
|
|
246
|
+
configurationId = conf.configurationId;
|
|
247
|
+
else if ((0, utils_1.isUuid)(conf.assetId))
|
|
248
|
+
assetId = conf.assetId;
|
|
249
|
+
else
|
|
250
|
+
configurationId = conf.assetId;
|
|
251
|
+
}
|
|
252
|
+
return Object.assign(result, (_b = {},
|
|
253
|
+
_b[env] = {
|
|
254
|
+
assetId: assetId,
|
|
255
|
+
stageId: stageId,
|
|
256
|
+
configurationId: configurationId,
|
|
257
|
+
initialConfiguration: initialConfiguration,
|
|
258
|
+
},
|
|
259
|
+
_b));
|
|
260
|
+
}, {});
|
|
261
|
+
return Object.assign(output, (_b = {}, _b[prodId] = updatedEnvs, _b));
|
|
262
|
+
}, {});
|
|
161
263
|
if (!Object.keys(credentials).length || !Object.keys(products).length)
|
|
162
264
|
return [2 /*return*/, console.error('Missing credentials')];
|
|
163
265
|
threekitEnv = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.threekitEnv) || process.env.THREEKIT_ENV || 'preview';
|
|
266
|
+
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);
|
|
164
267
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, config.player, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.playerConfig);
|
|
165
268
|
envCredentials = credentials[threekitEnv];
|
|
166
|
-
|
|
269
|
+
_a = products[productId][threekitEnv], assetId = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
|
|
167
270
|
threekitDomainRaw = envCredentials.threekitDomain || "".concat(threekitEnv, ".threekit.com");
|
|
168
271
|
orgId = envCredentials.orgId, authToken = envCredentials.publicToken;
|
|
169
|
-
if (typeof product === 'string') {
|
|
170
|
-
if ((0, utils_1.isUuid)(product))
|
|
171
|
-
assetId = product;
|
|
172
|
-
else
|
|
173
|
-
configurationId = product;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
stageId = product.stageId;
|
|
177
|
-
if (product.configurationId)
|
|
178
|
-
configurationId = product.configurationId;
|
|
179
|
-
else if ((0, utils_1.isUuid)(product.assetId))
|
|
180
|
-
assetId = product.assetId;
|
|
181
|
-
else
|
|
182
|
-
configurationId = product.assetId;
|
|
183
|
-
}
|
|
184
272
|
if (playerConfig.elementId) {
|
|
185
273
|
el = document.getElementById(playerConfig.elementId);
|
|
186
274
|
if (el)
|
|
@@ -196,59 +284,60 @@ var launch = function (launchConfig) {
|
|
|
196
284
|
orgId: orgId,
|
|
197
285
|
assetId: assetId,
|
|
198
286
|
threekitDomain: threekitDomainRaw,
|
|
287
|
+
serverUrl: serverUrl,
|
|
199
288
|
});
|
|
200
289
|
threekitDomain = connection_1.default.getConnection().threekitDomain;
|
|
201
290
|
initialConfiguration = __assign({}, initialConfigurationRaw);
|
|
202
291
|
updatedAssetId = assetId;
|
|
203
292
|
params = (0, utils_1.getParams)();
|
|
204
|
-
configId = ((
|
|
293
|
+
configId = ((_h = params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]) === null || _h === void 0 ? void 0 : _h.length)
|
|
205
294
|
? params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]
|
|
206
295
|
: configurationId;
|
|
207
296
|
if (!configId) return [3 /*break*/, 2];
|
|
208
297
|
return [4 /*yield*/, api_1.default.configurations.fetch(configId)];
|
|
209
298
|
case 1:
|
|
210
|
-
configuration =
|
|
299
|
+
configuration = _j.sent();
|
|
211
300
|
if (configuration) {
|
|
212
301
|
initialConfiguration = Object.assign({}, initialConfigurationRaw, configuration.data.variant);
|
|
213
302
|
connection_1.default.connect({ assetId: configuration.data.productId });
|
|
214
303
|
updatedAssetId = configuration.data.productId;
|
|
215
304
|
}
|
|
216
|
-
|
|
305
|
+
_j.label = 2;
|
|
217
306
|
case 2:
|
|
218
307
|
if (!updatedAssetId)
|
|
219
308
|
return [2 /*return*/, console.error('missing assetId')];
|
|
220
309
|
// We create the threekit script
|
|
221
|
-
return [4 /*yield*/, (
|
|
310
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
311
|
+
var script = document.createElement('script');
|
|
312
|
+
script.src = "".concat(threekitDomain, "/app/js/threekit-player-bundle.js");
|
|
313
|
+
script.id = 'threekit-player-bundle';
|
|
314
|
+
script.onload = function () { return resolve(); };
|
|
315
|
+
document.head.appendChild(script);
|
|
316
|
+
})];
|
|
222
317
|
case 3:
|
|
223
318
|
// We create the threekit script
|
|
224
|
-
|
|
225
|
-
return [4 /*yield*/,
|
|
226
|
-
|
|
227
|
-
authToken: authToken, stageId: stageId, assetId: updatedAssetId }, playerConfig), { initialConfiguration: initialConfiguration }))];
|
|
228
|
-
case 4:
|
|
229
|
-
player = _f.sent();
|
|
230
|
-
return [4 /*yield*/, player.getConfigurator()];
|
|
231
|
-
case 5:
|
|
232
|
-
configurator = _f.sent();
|
|
233
|
-
window.threekit = {
|
|
234
|
-
player: player,
|
|
235
|
-
configurator: configurator,
|
|
236
|
-
treble: new Treble_1.default({
|
|
237
|
-
player: player,
|
|
319
|
+
_j.sent();
|
|
320
|
+
return [4 /*yield*/, dispatch((0, exports.initPlayer)({
|
|
321
|
+
el: el,
|
|
238
322
|
orgId: orgId,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
323
|
+
authToken: authToken,
|
|
324
|
+
stageId: stageId,
|
|
325
|
+
assetId: updatedAssetId,
|
|
326
|
+
playerConfig: playerConfig,
|
|
327
|
+
initialConfiguration: initialConfiguration,
|
|
328
|
+
}))];
|
|
329
|
+
case 4:
|
|
330
|
+
_j.sent();
|
|
331
|
+
document.addEventListener('treble:notification', function (e) {
|
|
332
|
+
message_1.default.info(e.detail.message);
|
|
247
333
|
});
|
|
248
334
|
EVENTS = Object.assign(EVENTS, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.eventHandlers);
|
|
335
|
+
dispatch((0, exports.setThreekitEnv)(threekitEnv));
|
|
249
336
|
dispatch((0, translations_1.initTranslations)(launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.locale));
|
|
250
337
|
dispatch((0, price_1.initPrice)());
|
|
251
|
-
dispatch((0,
|
|
338
|
+
dispatch((0, price_1.updatePrice)());
|
|
339
|
+
dispatch((0, product_1.initProduct)(products));
|
|
340
|
+
dispatch((0, product_1.setProductId)(productId));
|
|
252
341
|
dispatch((0, wishlist_1.refreshWishlist)());
|
|
253
342
|
return [2 /*return*/];
|
|
254
343
|
}
|
|
@@ -256,4 +345,77 @@ var launch = function (launchConfig) {
|
|
|
256
345
|
}); };
|
|
257
346
|
};
|
|
258
347
|
exports.launch = launch;
|
|
348
|
+
var unloadPlayer = function () { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
349
|
+
return __generator(this, function (_a) {
|
|
350
|
+
switch (_a.label) {
|
|
351
|
+
case 0:
|
|
352
|
+
dispatch((0, exports.setThreekitInitialized)(true));
|
|
353
|
+
dispatch((0, exports.setPlayerLoading)(false));
|
|
354
|
+
dispatch((0, attributes_1.setAttributes)([]));
|
|
355
|
+
dispatch((0, product_1.setName)(''));
|
|
356
|
+
dispatch((0, product_1.setMetadata)({}));
|
|
357
|
+
return [4 /*yield*/, window.threekit.player.unload()];
|
|
358
|
+
case 1:
|
|
359
|
+
_a.sent();
|
|
360
|
+
return [2 /*return*/];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}); }; };
|
|
364
|
+
exports.unloadPlayer = unloadPlayer;
|
|
365
|
+
var reloadPlayer = function (config) {
|
|
366
|
+
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
367
|
+
var connectionObj, assetId, stageId, initialConfiguration, configuration, state, trebleConfig, playerConfig, el;
|
|
368
|
+
return __generator(this, function (_a) {
|
|
369
|
+
switch (_a.label) {
|
|
370
|
+
case 0:
|
|
371
|
+
connectionObj = connection_1.default.getConnection();
|
|
372
|
+
if (!(config === undefined)) return [3 /*break*/, 1];
|
|
373
|
+
assetId = connectionObj.assetId;
|
|
374
|
+
return [3 /*break*/, 4];
|
|
375
|
+
case 1:
|
|
376
|
+
if (!(typeof config === 'string')) return [3 /*break*/, 2];
|
|
377
|
+
assetId = config;
|
|
378
|
+
return [3 /*break*/, 4];
|
|
379
|
+
case 2:
|
|
380
|
+
assetId = (config === null || config === void 0 ? void 0 : config.assetId) || connectionObj.assetId;
|
|
381
|
+
stageId = config === null || config === void 0 ? void 0 : config.stageId;
|
|
382
|
+
initialConfiguration = (config === null || config === void 0 ? void 0 : config.configuration) || {};
|
|
383
|
+
if (!(config === null || config === void 0 ? void 0 : config.configurationId)) return [3 /*break*/, 4];
|
|
384
|
+
return [4 /*yield*/, api_1.default.configurations.fetch(config === null || config === void 0 ? void 0 : config.configurationId)];
|
|
385
|
+
case 3:
|
|
386
|
+
configuration = _a.sent();
|
|
387
|
+
if (configuration) {
|
|
388
|
+
initialConfiguration = Object.assign({}, initialConfiguration, configuration.data.variant);
|
|
389
|
+
assetId = configuration.data.productId;
|
|
390
|
+
}
|
|
391
|
+
_a.label = 4;
|
|
392
|
+
case 4:
|
|
393
|
+
// Update connection
|
|
394
|
+
if (assetId !== connectionObj.assetId)
|
|
395
|
+
connection_1.default.connect({ assetId: assetId });
|
|
396
|
+
state = getState();
|
|
397
|
+
trebleConfig = (0, utils_1.loadTrebleConfig)();
|
|
398
|
+
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, trebleConfig.player);
|
|
399
|
+
el = document.getElementById(state.treble.playerElId);
|
|
400
|
+
if (state.treble.isThreekitInitialized)
|
|
401
|
+
dispatch((0, exports.unloadPlayer)());
|
|
402
|
+
return [4 /*yield*/, dispatch((0, exports.initPlayer)({
|
|
403
|
+
el: el,
|
|
404
|
+
orgId: connectionObj.orgId,
|
|
405
|
+
authToken: connectionObj.authToken,
|
|
406
|
+
stageId: stageId,
|
|
407
|
+
assetId: assetId,
|
|
408
|
+
playerConfig: playerConfig,
|
|
409
|
+
initialConfiguration: initialConfiguration,
|
|
410
|
+
}))];
|
|
411
|
+
case 5:
|
|
412
|
+
_a.sent();
|
|
413
|
+
dispatch((0, price_1.updatePrice)());
|
|
414
|
+
dispatch((0, product_1.initProduct)());
|
|
415
|
+
return [2 /*return*/];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}); };
|
|
419
|
+
};
|
|
420
|
+
exports.reloadPlayer = reloadPlayer;
|
|
259
421
|
exports.default = reducer;
|
package/dist/store/wishlist.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import {
|
|
2
|
+
import { WishlistArray } from '../Treble';
|
|
3
|
+
import { ISaveConfiguration } from '../api/configurations';
|
|
3
4
|
/*****************************************************
|
|
4
5
|
* Types and Interfaces
|
|
5
6
|
****************************************************/
|
|
@@ -8,7 +9,7 @@ export declare type WishlistState = WishlistArray;
|
|
|
8
9
|
* Standard Selectors
|
|
9
10
|
****************************************************/
|
|
10
11
|
export declare const refreshWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], void, {}>;
|
|
11
|
-
export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[],
|
|
12
|
+
export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], Omit<ISaveConfiguration, "configurator">, {}>;
|
|
12
13
|
export declare const clearWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/clear", never, never>;
|
|
13
14
|
export declare const removeFromWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[idx: number], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/remove-item", never, never>;
|
|
14
15
|
/*****************************************************
|
package/dist/threekit.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ISceneQuery {
|
|
|
20
20
|
child?: string;
|
|
21
21
|
parent?: boolean;
|
|
22
22
|
includeParent?: boolean;
|
|
23
|
-
from?: ISceneQuery;
|
|
23
|
+
from?: string | ISceneQuery;
|
|
24
24
|
hasPlug?: string;
|
|
25
25
|
operator?: any;
|
|
26
26
|
operatorIndex?: number;
|
|
@@ -36,6 +36,7 @@ export interface ISceneQuery {
|
|
|
36
36
|
hierarchial?: boolean;
|
|
37
37
|
}
|
|
38
38
|
export interface ISceneResult {
|
|
39
|
+
id: string;
|
|
39
40
|
name: string;
|
|
40
41
|
configurator: IThreekitPrivateConfigurator;
|
|
41
42
|
}
|
|
@@ -83,6 +84,11 @@ export interface IDisplayAttributeAssetValue extends IConfigurationAssetValue {
|
|
|
83
84
|
tags: Array<string>;
|
|
84
85
|
label: string;
|
|
85
86
|
}
|
|
87
|
+
export interface IHydratedAttributeAssetValue extends IDisplayAttributeAssetValue {
|
|
88
|
+
label: string;
|
|
89
|
+
handleSelect: () => Promise<void>;
|
|
90
|
+
selected: boolean;
|
|
91
|
+
}
|
|
86
92
|
export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigurationAsset> {
|
|
87
93
|
assetType: AssetType;
|
|
88
94
|
blacklist: [];
|
|
@@ -92,12 +98,17 @@ export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigu
|
|
|
92
98
|
values: Array<V>;
|
|
93
99
|
}
|
|
94
100
|
export declare type IDisplayAttributeAsset = IAttributeAssetBase<IDisplayAttributeAssetValue>;
|
|
101
|
+
export declare type IHydratedAttributeAsset = IAttributeAssetBase<IHydratedAttributeAssetValue>;
|
|
95
102
|
export declare type IAttributeAsset = IAttributeAssetBase<IConfigurationAssetValue>;
|
|
96
103
|
/****** String TYPE ATTRIBUTE *******/
|
|
97
104
|
export interface IDisplayAttributeStringValue {
|
|
98
105
|
label: string;
|
|
99
106
|
value: string;
|
|
100
107
|
}
|
|
108
|
+
export interface IHydratedAttributeStringValue extends IDisplayAttributeStringValue {
|
|
109
|
+
handleSelect: () => Promise<void>;
|
|
110
|
+
selected: boolean;
|
|
111
|
+
}
|
|
101
112
|
export interface IAttributeStringBase<V> extends IAttributeBase<'String', string> {
|
|
102
113
|
blacklist: [];
|
|
103
114
|
defaultValue: string;
|
|
@@ -106,6 +117,7 @@ export interface IAttributeStringBase<V> extends IAttributeBase<'String', string
|
|
|
106
117
|
values: Array<V>;
|
|
107
118
|
}
|
|
108
119
|
export declare type IDisplayAttributeString = IAttributeStringBase<IDisplayAttributeStringValue>;
|
|
120
|
+
export declare type IHydratedAttributeString = IAttributeStringBase<IHydratedAttributeStringValue>;
|
|
109
121
|
export declare type IAttributeString = IAttributeStringBase<string>;
|
|
110
122
|
/****** STRING TYPE ATTRIBUTE *******/
|
|
111
123
|
export interface IAttributeColor extends IAttributeBase<'Color', IConfigurationColor> {
|
|
@@ -122,7 +134,9 @@ export interface IAttributeNumber extends IAttributeBase<'Number', number> {
|
|
|
122
134
|
/****** getAttributes() *******/
|
|
123
135
|
export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber;
|
|
124
136
|
/****** getDisplayAttributes() *******/
|
|
125
|
-
export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset |
|
|
137
|
+
export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber;
|
|
138
|
+
/****** Treble Hydrated Values *******/
|
|
139
|
+
export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber;
|
|
126
140
|
/***************************************************
|
|
127
141
|
* Camera
|
|
128
142
|
**************************************************/
|
|
@@ -160,6 +174,8 @@ export interface IThreekitScene {
|
|
|
160
174
|
RENDERED: 'rendered';
|
|
161
175
|
};
|
|
162
176
|
get: (query: ISceneQuery | string) => ISceneResult;
|
|
177
|
+
find: (query: ISceneQuery | string) => ISceneResult;
|
|
178
|
+
set: (query: ISceneQuery | string, transform: ICoordinates) => void;
|
|
163
179
|
}
|
|
164
180
|
export interface IThreekitTools {
|
|
165
181
|
addTool: (tool: string) => void;
|
|
@@ -192,6 +208,7 @@ export interface IThreekitPlayer {
|
|
|
192
208
|
getConfigurator: () => Promise<IThreekitConfigurator>;
|
|
193
209
|
enableApi: (api: PRIVATE_APIS) => any;
|
|
194
210
|
snapshotAsync: (snapshotConfig: ISnapshotConfig) => Promise<string>;
|
|
211
|
+
unload: () => Promise<string>;
|
|
195
212
|
}
|
|
196
213
|
export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
|
|
197
214
|
getAppliedConfiguration: (attributeName: string) => string;
|
|
@@ -259,6 +276,7 @@ export interface IProducts extends Record<string, string | Partial<IProduct>> {
|
|
|
259
276
|
export interface IProject {
|
|
260
277
|
credentials: ICredentials;
|
|
261
278
|
products: IProducts;
|
|
279
|
+
serverUrl?: string;
|
|
262
280
|
}
|
|
263
281
|
export interface ITrebleConfig {
|
|
264
282
|
project: IProject;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute } from './threekit';
|
|
1
|
+
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute, ISetConfiguration, IHydratedAttribute } from './threekit';
|
|
3
2
|
import { ITrebleConfig, IAttributeTypes } from './threekit';
|
|
4
3
|
import { RawAttributeValue } from './hooks/useAttribute';
|
|
4
|
+
import { ITranslationMap } from './api/products';
|
|
5
5
|
interface ICameraPosition {
|
|
6
6
|
position: ICoordinates;
|
|
7
7
|
quaternion: IQuaternion;
|
|
@@ -22,7 +22,7 @@ export declare const generateLayoutClassName: (component: string, customClassNam
|
|
|
22
22
|
export declare const generateToolClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
|
|
23
23
|
export declare const generateDisplayClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
|
|
24
24
|
export declare const generateFormClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const isJsonString: (str: string) => boolean;
|
|
26
26
|
export declare const objectToQueryStr: (obj: Record<string, any>) => string;
|
|
27
27
|
export declare const getParams: () => Record<string, string | {
|
|
28
28
|
[key: string]: any;
|
|
@@ -43,17 +43,15 @@ export declare const getCameraPosition: (cameraApi: IThreekitCamera) => {
|
|
|
43
43
|
export declare const setCameraPosition: (cameraApi: IThreekitCamera, cameraPosition: ICameraPosition) => void;
|
|
44
44
|
export declare const dataURItoBlob: (dataURI: string) => Blob;
|
|
45
45
|
export declare const dataURItoFile: (dataURI: string, filename: string) => File;
|
|
46
|
+
export declare const downloadSnapshot: (snapshot: string, filename: string) => Promise<void>;
|
|
46
47
|
export declare const copyToClipboard: (data: string | Record<string, string | number | boolean>) => void;
|
|
47
48
|
export declare const easeInOutCubic: (val: number) => number;
|
|
48
49
|
export declare const metadataValueToObject: (data: string) => Record<string, string | number>;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
export declare const createThreekitScriptEl: (threekitDomain: string) => Promise<void>;
|
|
56
|
-
export declare const translateAttribute: (attributes: Array<IThreekitDisplayAttribute>, translations?: ITranslationMap | undefined, language?: string | undefined) => IThreekitDisplayAttribute;
|
|
50
|
+
export declare const hydrateAttribute: (data: [
|
|
51
|
+
Record<string, IThreekitDisplayAttribute>,
|
|
52
|
+
undefined | ITranslationMap,
|
|
53
|
+
undefined | string
|
|
54
|
+
], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>) => Record<string, IHydratedAttribute>;
|
|
57
55
|
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: IAttributeTypes) => string | number | boolean | File | IConfigurationColor | {
|
|
58
56
|
assetId: RawAttributeValue;
|
|
59
57
|
} | undefined;
|