@threekit-tools/treble 0.0.82 → 0.0.85
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/Treble.d.ts +9 -3
- package/dist/Treble/Treble.js +40 -11
- package/dist/Treble/index.d.ts +2 -2
- package/dist/Treble/index.js +2 -2
- package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
- package/dist/Treble/snapshots.js +247 -0
- package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
- package/dist/Treble/wishlist.js +135 -0
- package/dist/api/catalog.js +6 -6
- package/dist/api/configurations.js +3 -3
- package/dist/api/datatables.js +5 -5
- package/dist/api/orders.d.ts +5 -7
- 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 +1 -6
- 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 +2 -8
- package/dist/components/Button/index.d.ts +0 -27
- package/dist/components/Button/index.js +0 -27
- package/dist/components/Cards/index.d.ts +2 -55
- package/dist/components/Cards/index.js +3 -60
- package/dist/components/Drawer/index.js +0 -13
- package/dist/components/Dropdown/index.d.ts +2 -59
- package/dist/components/Dropdown/index.js +4 -69
- package/dist/components/FlatForm/index.d.ts +0 -21
- package/dist/components/FlatForm/index.js +5 -24
- package/dist/components/Modal/index.js +0 -13
- package/dist/components/Player/index.d.ts +1 -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 +2 -12
- package/dist/components/Share/index.js +139 -21
- package/dist/components/Share/share.styles.d.ts +9 -0
- package/dist/components/Share/share.styles.js +23 -0
- package/dist/components/Snapshots/index.d.ts +0 -8
- package/dist/components/Snapshots/index.js +0 -8
- package/dist/components/Strips/index.d.ts +2 -55
- package/dist/components/Strips/index.js +3 -60
- package/dist/components/Swatch/index.d.ts +2 -64
- package/dist/components/Swatch/index.js +3 -69
- package/dist/components/Switch/index.d.ts +2 -34
- package/dist/components/Switch/index.js +2 -38
- package/dist/components/TextInput/index.d.ts +2 -1
- package/dist/components/TextInput/index.js +2 -3
- package/dist/components/Tiles/index.d.ts +2 -29
- package/dist/components/Tiles/index.js +3 -33
- package/dist/components/TilesGroup/index.d.ts +2 -26
- package/dist/components/TilesGroup/index.js +3 -30
- package/dist/components/TotalPrice/index.d.ts +0 -6
- package/dist/components/TotalPrice/index.js +0 -6
- package/dist/components/Upload/index.d.ts +2 -1
- package/dist/components/Upload/index.js +7 -8
- package/dist/components/UploadArea/index.d.ts +2 -1
- package/dist/components/UploadArea/index.js +6 -7
- package/dist/components/Wishlist/index.d.ts +1 -4
- package/dist/components/Wishlist/index.js +2 -5
- package/dist/components/Zoom/index.d.ts +1 -18
- package/dist/components/Zoom/index.js +0 -17
- package/dist/components/formComponents.d.ts +12 -0
- package/dist/components/formComponents.js +5 -7
- package/dist/components/message/index.d.ts +0 -9
- package/dist/components/message/index.js +0 -9
- package/dist/connection.js +2 -2
- package/dist/constants.d.ts +0 -49
- package/dist/constants.js +1 -59
- package/dist/hooks/useAttribute/index.js +6 -6
- package/dist/hooks/useConfigurationLoader/index.js +5 -5
- package/dist/hooks/useNestedConfigurator/index.js +2 -2
- package/dist/hooks/useShare/index.js +3 -3
- package/dist/hooks/useSingleAnimation/index.js +20 -25
- package/dist/http/datatables.js +0 -1
- package/dist/http/orders.d.ts +6 -8
- package/dist/icons/index.d.ts +0 -41
- package/dist/icons/index.js +0 -42
- package/dist/index.d.ts +42 -3
- package/dist/index.js +84 -30
- package/dist/store/attributes.d.ts +0 -12
- package/dist/store/attributes.js +2 -15
- package/dist/store/price.d.ts +0 -12
- package/dist/store/price.js +2 -16
- package/dist/store/product.d.ts +2 -17
- package/dist/store/product.js +26 -38
- package/dist/store/translations.d.ts +0 -12
- package/dist/store/translations.js +2 -12
- package/dist/store/treble.d.ts +0 -15
- package/dist/store/treble.js +31 -66
- package/dist/store/wishlist.d.ts +0 -12
- package/dist/store/wishlist.js +4 -17
- package/dist/types.d.ts +71 -58
- package/dist/types.js +54 -0
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +8 -16
- package/package.json +18 -4
- package/dist/Treble/Snapshots.js +0 -251
- package/dist/Treble/Wishlist.js +0 -136
package/dist/store/treble.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
2
|
import { IProject, IPlayerConfig, IThreekitDisplayAttribute, ISetConfiguration, IConfiguration } from '../types';
|
|
3
|
-
/*****************************************************
|
|
4
|
-
* Types and Interfaces
|
|
5
|
-
****************************************************/
|
|
6
3
|
export interface IPlayerInit {
|
|
7
4
|
el: HTMLElement;
|
|
8
5
|
authToken: string;
|
|
@@ -48,30 +45,18 @@ export interface NotificationEvent extends Event {
|
|
|
48
45
|
interface EventHandlers {
|
|
49
46
|
postConfigurationChange?: (updatedAttributes: Array<IThreekitDisplayAttribute>, configurationChange: ISetConfiguration, previousConfiguration: Array<IThreekitDisplayAttribute>) => void | Promise<void>;
|
|
50
47
|
}
|
|
51
|
-
/*****************************************************
|
|
52
|
-
* Actions
|
|
53
|
-
****************************************************/
|
|
54
48
|
export declare const setThreekitEnv: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
55
49
|
export declare const setThreekitInitialized: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
|
|
56
50
|
export declare const setPlayerLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
|
|
57
51
|
export declare const setPlayerElement: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
58
52
|
export declare const reloadTreble: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<TrebleState>, string>;
|
|
59
53
|
export declare const updateLoadingProgress: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
60
|
-
/*****************************************************
|
|
61
|
-
* Slice
|
|
62
|
-
****************************************************/
|
|
63
54
|
declare const reducer: import("redux").Reducer<TrebleState, import("redux").AnyAction>;
|
|
64
|
-
/*****************************************************
|
|
65
|
-
* Standard Selectors
|
|
66
|
-
****************************************************/
|
|
67
55
|
export declare const getThreekitEnv: (state: RootState) => string;
|
|
68
56
|
export declare const isThreekitInitialized: (state: RootState) => boolean;
|
|
69
57
|
export declare const isPlayerLoading: (state: RootState) => boolean;
|
|
70
58
|
export declare const getPlayerElementId: (state: RootState) => undefined | string;
|
|
71
59
|
export declare const getLoadingProgress: (state: RootState) => number;
|
|
72
|
-
/*****************************************************
|
|
73
|
-
* Complex Actions
|
|
74
|
-
****************************************************/
|
|
75
60
|
export declare const initPlayer: (config: IPlayerInit) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
76
61
|
export declare const launch: (launchConfig?: Partial<ILaunchConfig>) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
77
62
|
export declare const unloadPlayer: () => (dispatch: ThreekitDispatch) => Promise<void>;
|
package/dist/store/treble.js
CHANGED
|
@@ -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,13 +80,7 @@ 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,
|
|
@@ -105,18 +89,12 @@ var initialState = {
|
|
|
105
89
|
notifications: true,
|
|
106
90
|
loadingProgress: 0,
|
|
107
91
|
};
|
|
108
|
-
/*****************************************************
|
|
109
|
-
* Actions
|
|
110
|
-
****************************************************/
|
|
111
92
|
exports.setThreekitEnv = (0, toolkit_1.createAction)('treble/set-threekit-env');
|
|
112
93
|
exports.setThreekitInitialized = (0, toolkit_1.createAction)('treble/set-threekit-initialized');
|
|
113
94
|
exports.setPlayerLoading = (0, toolkit_1.createAction)('treble/set-player-loading');
|
|
114
95
|
exports.setPlayerElement = (0, toolkit_1.createAction)('treble/set-player-element');
|
|
115
96
|
exports.reloadTreble = (0, toolkit_1.createAction)('treble/reload');
|
|
116
97
|
exports.updateLoadingProgress = (0, toolkit_1.createAction)('treble/update-loading-progress');
|
|
117
|
-
/*****************************************************
|
|
118
|
-
* Slice
|
|
119
|
-
****************************************************/
|
|
120
98
|
var reducer = (0, toolkit_1.createSlice)({
|
|
121
99
|
name: 'treble',
|
|
122
100
|
initialState: initialState,
|
|
@@ -147,15 +125,10 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
147
125
|
});
|
|
148
126
|
},
|
|
149
127
|
}).reducer;
|
|
150
|
-
/*****************************************************
|
|
151
|
-
* Standard Selectors
|
|
152
|
-
****************************************************/
|
|
153
|
-
// Loading Trackers
|
|
154
128
|
var getThreekitEnv = function (state) {
|
|
155
129
|
return state.treble.threekitEnv;
|
|
156
130
|
};
|
|
157
131
|
exports.getThreekitEnv = getThreekitEnv;
|
|
158
|
-
// Loading Trackers
|
|
159
132
|
var isThreekitInitialized = function (state) {
|
|
160
133
|
return state.treble.isThreekitInitialized;
|
|
161
134
|
};
|
|
@@ -164,19 +137,14 @@ var isPlayerLoading = function (state) {
|
|
|
164
137
|
return state.treble.isPlayerLoading;
|
|
165
138
|
};
|
|
166
139
|
exports.isPlayerLoading = isPlayerLoading;
|
|
167
|
-
// Player's HTML element
|
|
168
140
|
var getPlayerElementId = function (state) {
|
|
169
141
|
return state.treble.playerElId;
|
|
170
142
|
};
|
|
171
143
|
exports.getPlayerElementId = getPlayerElementId;
|
|
172
|
-
// Player's HTML element
|
|
173
144
|
var getLoadingProgress = function (state) {
|
|
174
145
|
return state.treble.loadingProgress;
|
|
175
146
|
};
|
|
176
147
|
exports.getLoadingProgress = getLoadingProgress;
|
|
177
|
-
/*****************************************************
|
|
178
|
-
* Complex Actions
|
|
179
|
-
****************************************************/
|
|
180
148
|
var initPlayer = function (config) {
|
|
181
149
|
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
182
150
|
var el, authToken, assetId, stageId, orgId, playerConfig, initialConfiguration, player, configurator;
|
|
@@ -184,16 +152,14 @@ var initPlayer = function (config) {
|
|
|
184
152
|
switch (_a.label) {
|
|
185
153
|
case 0:
|
|
186
154
|
el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
|
|
187
|
-
return [4
|
|
188
|
-
// Variables to sort out
|
|
189
|
-
authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
155
|
+
return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
190
156
|
var _a;
|
|
191
157
|
dispatch((0, exports.updateLoadingProgress)(progress));
|
|
192
158
|
(_a = playerConfig === null || playerConfig === void 0 ? void 0 : playerConfig.onLoadingProgress) === null || _a === void 0 ? void 0 : _a.call(playerConfig, progress);
|
|
193
159
|
} }))];
|
|
194
160
|
case 1:
|
|
195
161
|
player = _a.sent();
|
|
196
|
-
return [4
|
|
162
|
+
return [4, player.getConfigurator()];
|
|
197
163
|
case 2:
|
|
198
164
|
configurator = _a.sent();
|
|
199
165
|
if (window.threekit) {
|
|
@@ -228,14 +194,14 @@ var initPlayer = function (config) {
|
|
|
228
194
|
previousAttributes = Object.values(attributes);
|
|
229
195
|
updatedAttributes = window.threekit.configurator.getDisplayAttributes();
|
|
230
196
|
dispatch((0, attributes_1.setAttributes)(updatedAttributes));
|
|
231
|
-
return [4
|
|
197
|
+
return [4, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
|
|
232
198
|
case 1:
|
|
233
199
|
_b.sent();
|
|
234
|
-
return [2
|
|
200
|
+
return [2];
|
|
235
201
|
}
|
|
236
202
|
});
|
|
237
203
|
}); });
|
|
238
|
-
return [2
|
|
204
|
+
return [2];
|
|
239
205
|
}
|
|
240
206
|
});
|
|
241
207
|
}); };
|
|
@@ -249,7 +215,7 @@ var launch = function (launchConfig) {
|
|
|
249
215
|
switch (_j.label) {
|
|
250
216
|
case 0:
|
|
251
217
|
if (window.threekit)
|
|
252
|
-
return [2
|
|
218
|
+
return [2];
|
|
253
219
|
config = (0, utils_1.loadTrebleConfig)();
|
|
254
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) || {};
|
|
255
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) || {};
|
|
@@ -296,12 +262,14 @@ var launch = function (launchConfig) {
|
|
|
296
262
|
return Object.assign(output, (_b = {}, _b[prodId] = updatedEnvs, _b));
|
|
297
263
|
}, {});
|
|
298
264
|
if (!Object.keys(credentials).length || !Object.keys(products).length)
|
|
299
|
-
return [2
|
|
265
|
+
return [2, console.error('Missing credentials')];
|
|
266
|
+
dispatch((0, product_1.initProduct)(products));
|
|
267
|
+
dispatch((0, product_1.setProductId)(productId));
|
|
300
268
|
threekitEnv = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.threekitEnv) || process.env.THREEKIT_ENV || 'preview';
|
|
301
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);
|
|
302
270
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, config.player, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.playerConfig);
|
|
303
271
|
envCredentials = credentials[threekitEnv];
|
|
304
|
-
_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;
|
|
305
273
|
assetId = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.assetId) || assetIdRaw;
|
|
306
274
|
threekitDomainRaw = envCredentials.threekitDomain || "".concat(threekitEnv, ".threekit.com");
|
|
307
275
|
orgId = envCredentials.orgId, authToken = envCredentials.publicToken;
|
|
@@ -314,7 +282,6 @@ var launch = function (launchConfig) {
|
|
|
314
282
|
el = createPlayerLoaderEl(constants_1.TK_PLAYER_ROOT_DIV);
|
|
315
283
|
dispatch((0, exports.setPlayerElement)(constants_1.TK_PLAYER_ROOT_DIV));
|
|
316
284
|
}
|
|
317
|
-
// Connection
|
|
318
285
|
connection_1.default.connect({
|
|
319
286
|
authToken: authToken,
|
|
320
287
|
orgId: orgId,
|
|
@@ -329,8 +296,8 @@ var launch = function (launchConfig) {
|
|
|
329
296
|
configId = ((_h = params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]) === null || _h === void 0 ? void 0 : _h.length)
|
|
330
297
|
? params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]
|
|
331
298
|
: configurationId;
|
|
332
|
-
if (!configId) return [3
|
|
333
|
-
return [4
|
|
299
|
+
if (!configId) return [3, 2];
|
|
300
|
+
return [4, api_1.default.configurations.fetch(configId)];
|
|
334
301
|
case 1:
|
|
335
302
|
configuration = _j.sent();
|
|
336
303
|
if (configuration) {
|
|
@@ -341,9 +308,8 @@ var launch = function (launchConfig) {
|
|
|
341
308
|
_j.label = 2;
|
|
342
309
|
case 2:
|
|
343
310
|
if (!updatedAssetId)
|
|
344
|
-
return [2
|
|
345
|
-
|
|
346
|
-
return [4 /*yield*/, new Promise(function (resolve) {
|
|
311
|
+
return [2, console.error('missing assetId')];
|
|
312
|
+
return [4, new Promise(function (resolve) {
|
|
347
313
|
var script = document.createElement('script');
|
|
348
314
|
script.src = "".concat(threekitDomain, "/app/js/threekit-player-bundle.js");
|
|
349
315
|
script.id = 'threekit-player-bundle';
|
|
@@ -351,9 +317,8 @@ var launch = function (launchConfig) {
|
|
|
351
317
|
document.head.appendChild(script);
|
|
352
318
|
})];
|
|
353
319
|
case 3:
|
|
354
|
-
// We create the threekit script
|
|
355
320
|
_j.sent();
|
|
356
|
-
return [4
|
|
321
|
+
return [4, dispatch((0, exports.initPlayer)({
|
|
357
322
|
el: el,
|
|
358
323
|
orgId: orgId,
|
|
359
324
|
authToken: authToken,
|
|
@@ -368,14 +333,15 @@ var launch = function (launchConfig) {
|
|
|
368
333
|
message_1.default.info(e.detail.message);
|
|
369
334
|
});
|
|
370
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)());
|
|
371
339
|
dispatch((0, exports.setThreekitEnv)(threekitEnv));
|
|
372
340
|
dispatch((0, translations_1.initTranslations)(launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.locale));
|
|
373
341
|
dispatch((0, price_1.initPrice)());
|
|
374
342
|
dispatch((0, price_1.updatePrice)());
|
|
375
|
-
dispatch((0, product_1.initProduct)(products));
|
|
376
|
-
dispatch((0, product_1.setProductId)(productId));
|
|
377
343
|
dispatch((0, wishlist_1.refreshWishlist)());
|
|
378
|
-
return [2
|
|
344
|
+
return [2];
|
|
379
345
|
}
|
|
380
346
|
});
|
|
381
347
|
}); };
|
|
@@ -390,10 +356,10 @@ var unloadPlayer = function () { return function (dispatch) { return __awaiter(v
|
|
|
390
356
|
dispatch((0, attributes_1.setAttributes)([]));
|
|
391
357
|
dispatch((0, product_1.setName)(''));
|
|
392
358
|
dispatch((0, product_1.setMetadata)({}));
|
|
393
|
-
return [4
|
|
359
|
+
return [4, window.threekit.player.unload()];
|
|
394
360
|
case 1:
|
|
395
361
|
_a.sent();
|
|
396
|
-
return [2
|
|
362
|
+
return [2];
|
|
397
363
|
}
|
|
398
364
|
});
|
|
399
365
|
}); }; };
|
|
@@ -405,19 +371,19 @@ var reloadPlayer = function (config) {
|
|
|
405
371
|
switch (_a.label) {
|
|
406
372
|
case 0:
|
|
407
373
|
connectionObj = connection_1.default.getConnection();
|
|
408
|
-
if (!(config === undefined)) return [3
|
|
374
|
+
if (!(config === undefined)) return [3, 1];
|
|
409
375
|
assetId = connectionObj.assetId;
|
|
410
|
-
return [3
|
|
376
|
+
return [3, 4];
|
|
411
377
|
case 1:
|
|
412
|
-
if (!(typeof config === 'string')) return [3
|
|
378
|
+
if (!(typeof config === 'string')) return [3, 2];
|
|
413
379
|
assetId = config;
|
|
414
|
-
return [3
|
|
380
|
+
return [3, 4];
|
|
415
381
|
case 2:
|
|
416
382
|
assetId = (config === null || config === void 0 ? void 0 : config.assetId) || connectionObj.assetId;
|
|
417
383
|
stageId = config === null || config === void 0 ? void 0 : config.stageId;
|
|
418
384
|
initialConfiguration = (config === null || config === void 0 ? void 0 : config.configuration) || {};
|
|
419
|
-
if (!(config === null || config === void 0 ? void 0 : config.configurationId)) return [3
|
|
420
|
-
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)];
|
|
421
387
|
case 3:
|
|
422
388
|
configuration = _a.sent();
|
|
423
389
|
if (configuration) {
|
|
@@ -426,19 +392,18 @@ var reloadPlayer = function (config) {
|
|
|
426
392
|
}
|
|
427
393
|
_a.label = 4;
|
|
428
394
|
case 4:
|
|
429
|
-
// Update connection
|
|
430
395
|
if (assetId !== connectionObj.assetId)
|
|
431
396
|
connection_1.default.connect({ assetId: assetId });
|
|
432
397
|
state = getState();
|
|
433
398
|
trebleConfig = (0, utils_1.loadTrebleConfig)();
|
|
434
399
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, trebleConfig.player);
|
|
435
400
|
el = document.getElementById(state.treble.playerElId);
|
|
436
|
-
if (!state.treble.isThreekitInitialized) return [3
|
|
437
|
-
return [4
|
|
401
|
+
if (!state.treble.isThreekitInitialized) return [3, 6];
|
|
402
|
+
return [4, dispatch((0, exports.unloadPlayer)())];
|
|
438
403
|
case 5:
|
|
439
404
|
_a.sent();
|
|
440
405
|
_a.label = 6;
|
|
441
|
-
case 6: return [4
|
|
406
|
+
case 6: return [4, dispatch((0, exports.initPlayer)({
|
|
442
407
|
el: el,
|
|
443
408
|
orgId: connectionObj.orgId,
|
|
444
409
|
authToken: connectionObj.authToken,
|
|
@@ -451,7 +416,7 @@ var reloadPlayer = function (config) {
|
|
|
451
416
|
_a.sent();
|
|
452
417
|
dispatch((0, price_1.updatePrice)());
|
|
453
418
|
dispatch((0, product_1.initProduct)());
|
|
454
|
-
return [2
|
|
419
|
+
return [2];
|
|
455
420
|
}
|
|
456
421
|
});
|
|
457
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
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) {
|