@threekit-tools/treble 0.0.82 → 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.
Files changed (83) hide show
  1. package/dist/Treble/Snapshots.js +31 -32
  2. package/dist/Treble/Treble.js +3 -4
  3. package/dist/Treble/Wishlist.js +8 -8
  4. package/dist/api/catalog.js +6 -6
  5. package/dist/api/configurations.js +3 -3
  6. package/dist/api/datatables.js +5 -5
  7. package/dist/api/orders.js +12 -12
  8. package/dist/api/price.js +2 -2
  9. package/dist/api/products.js +2 -2
  10. package/dist/components/Accordion/index.js +1 -6
  11. package/dist/components/AttributeTitle/index.d.ts +0 -9
  12. package/dist/components/AttributeTitle/index.js +0 -9
  13. package/dist/components/AttributeValue/index.d.ts +0 -6
  14. package/dist/components/AttributeValue/index.js +0 -6
  15. package/dist/components/Button/index.d.ts +0 -27
  16. package/dist/components/Button/index.js +0 -27
  17. package/dist/components/Cards/index.d.ts +0 -54
  18. package/dist/components/Cards/index.js +0 -57
  19. package/dist/components/Drawer/index.js +0 -13
  20. package/dist/components/Dropdown/index.d.ts +0 -58
  21. package/dist/components/Dropdown/index.js +1 -66
  22. package/dist/components/FlatForm/index.d.ts +0 -21
  23. package/dist/components/FlatForm/index.js +0 -21
  24. package/dist/components/Modal/index.js +0 -13
  25. package/dist/components/PortalToElement/index.js +0 -8
  26. package/dist/components/ProductDescription/index.d.ts +0 -6
  27. package/dist/components/ProductDescription/index.js +0 -6
  28. package/dist/components/ProductName/index.d.ts +0 -9
  29. package/dist/components/ProductName/index.js +0 -9
  30. package/dist/components/Share/index.d.ts +0 -12
  31. package/dist/components/Share/index.js +0 -12
  32. package/dist/components/Snapshots/index.d.ts +0 -8
  33. package/dist/components/Snapshots/index.js +0 -8
  34. package/dist/components/Strips/index.d.ts +0 -54
  35. package/dist/components/Strips/index.js +0 -57
  36. package/dist/components/Swatch/index.d.ts +0 -63
  37. package/dist/components/Swatch/index.js +0 -66
  38. package/dist/components/Switch/index.d.ts +0 -33
  39. package/dist/components/Switch/index.js +0 -36
  40. package/dist/components/TextInput/index.js +0 -1
  41. package/dist/components/Tiles/index.d.ts +0 -28
  42. package/dist/components/Tiles/index.js +0 -30
  43. package/dist/components/TilesGroup/index.d.ts +0 -25
  44. package/dist/components/TilesGroup/index.js +0 -27
  45. package/dist/components/TotalPrice/index.d.ts +0 -6
  46. package/dist/components/TotalPrice/index.js +0 -6
  47. package/dist/components/Upload/index.js +5 -6
  48. package/dist/components/UploadArea/index.js +4 -5
  49. package/dist/components/Wishlist/index.d.ts +1 -4
  50. package/dist/components/Wishlist/index.js +2 -5
  51. package/dist/components/Zoom/index.d.ts +1 -18
  52. package/dist/components/Zoom/index.js +0 -17
  53. package/dist/components/formComponents.js +0 -2
  54. package/dist/components/message/index.d.ts +0 -9
  55. package/dist/components/message/index.js +0 -9
  56. package/dist/connection.js +2 -2
  57. package/dist/constants.d.ts +0 -27
  58. package/dist/constants.js +0 -36
  59. package/dist/hooks/useAttribute/index.js +6 -6
  60. package/dist/hooks/useConfigurationLoader/index.js +5 -5
  61. package/dist/hooks/useNestedConfigurator/index.js +2 -2
  62. package/dist/hooks/useShare/index.js +3 -3
  63. package/dist/hooks/useSingleAnimation/index.js +5 -11
  64. package/dist/http/datatables.js +0 -1
  65. package/dist/icons/index.d.ts +0 -41
  66. package/dist/icons/index.js +0 -42
  67. package/dist/index.d.ts +42 -3
  68. package/dist/index.js +84 -30
  69. package/dist/store/attributes.d.ts +0 -12
  70. package/dist/store/attributes.js +2 -15
  71. package/dist/store/price.d.ts +0 -12
  72. package/dist/store/price.js +2 -16
  73. package/dist/store/product.d.ts +2 -17
  74. package/dist/store/product.js +23 -37
  75. package/dist/store/translations.d.ts +0 -12
  76. package/dist/store/translations.js +2 -12
  77. package/dist/store/treble.d.ts +0 -15
  78. package/dist/store/treble.js +31 -66
  79. package/dist/store/wishlist.d.ts +0 -12
  80. package/dist/store/wishlist.js +4 -17
  81. package/dist/types.d.ts +0 -34
  82. package/dist/utils.js +3 -12
  83. package/package.json +16 -4
@@ -54,10 +54,6 @@ exports.removeProductIdx = exports.changeActiveCacheIdx = exports.loadNewProduct
54
54
  var toolkit_1 = require("@reduxjs/toolkit");
55
55
  var connection_1 = __importDefault(require("../connection"));
56
56
  var treble_1 = require("./treble");
57
- /*****************************************************
58
- * Actions
59
- ****************************************************/
60
- // Actions to be used only internally
61
57
  exports.setProductId = (0, toolkit_1.createAction)('treble/set-product-id');
62
58
  exports.setName = (0, toolkit_1.createAction)('treble/set-product-name');
63
59
  exports.setMetadata = (0, toolkit_1.createAction)('treble/set-metadata');
@@ -67,17 +63,10 @@ exports.removeFromCache = (0, toolkit_1.createAction)('treble/remove-from-cache'
67
63
  exports.setActiveCacheIdx = (0, toolkit_1.createAction)('treble/set-active-cache-idx');
68
64
  exports.incrementActiveCacheIdx = (0, toolkit_1.createAction)('treble/increment-active-cache-idx');
69
65
  exports.decrementActiveCacheIdx = (0, toolkit_1.createAction)('treble/decrement-active-cache-idx');
70
- /*****************************************************
71
- * State
72
- ****************************************************/
73
66
  var initialState = {
74
- // ID of initialized item
75
67
  id: undefined,
76
- // Name of the Initialized Item
77
68
  name: undefined,
78
- // Initialized item's metadata
79
69
  metadata: undefined,
80
- // cached products. Does not include the active product
81
70
  cache: [],
82
71
  activeCacheIdx: 0,
83
72
  };
@@ -89,10 +78,13 @@ var reducer = (0, toolkit_1.createSlice)({
89
78
  return __assign(__assign({}, state), { id: action.payload });
90
79
  });
91
80
  builder.addCase(exports.setName, function (state, action) {
92
- return __assign(__assign({}, state), { name: action.payload });
81
+ var name = window.threekit.player.scene.get({
82
+ id: window.threekit.player.assetId,
83
+ }).name;
84
+ return __assign(__assign({}, state), { name: action.payload || name });
93
85
  });
94
86
  builder.addCase(exports.setMetadata, function (state, action) {
95
- return __assign(__assign({}, state), { metadata: action.payload });
87
+ return __assign(__assign({}, state), { metadata: action.payload || window.threekit.configurator.getMetadata() });
96
88
  });
97
89
  builder.addCase(exports.appendToCache, function (state, action) {
98
90
  state.cache.push(action.payload);
@@ -125,9 +117,6 @@ var reducer = (0, toolkit_1.createSlice)({
125
117
  },
126
118
  reducers: {},
127
119
  }).reducer;
128
- /*****************************************************
129
- * Standard Selectors
130
- ****************************************************/
131
120
  var getProductId = function (state) {
132
121
  return state.product.id;
133
122
  };
@@ -136,12 +125,10 @@ var getName = function (state) {
136
125
  return state.product.name;
137
126
  };
138
127
  exports.getName = getName;
139
- // Metadata
140
128
  var getMetadata = function (state) {
141
129
  return state.product.metadata;
142
130
  };
143
131
  exports.getMetadata = getMetadata;
144
- // Product Cache
145
132
  var getActiveCacheIdx = function (state) {
146
133
  return state.product.activeCacheIdx;
147
134
  };
@@ -154,13 +141,12 @@ var getProductCache = function (state) {
154
141
  });
155
142
  };
156
143
  exports.getProductCache = getProductCache;
157
- /*****************************************************
158
- * Complex Actions
159
- ****************************************************/
160
144
  var initProduct = function (prods) {
161
145
  return function (dispatch, getState) {
162
146
  if (prods)
163
147
  exports.PRODUCTS = prods;
148
+ if (!window.threekit)
149
+ return;
164
150
  var state = getState();
165
151
  var name = window.threekit.player.scene.get({
166
152
  id: window.threekit.player.assetId,
@@ -203,19 +189,19 @@ var loadProduct = function (id, config) {
203
189
  state = getState();
204
190
  productsList = Object.keys(exports.PRODUCTS);
205
191
  if (!productsList.includes(id))
206
- return [2 /*return*/];
192
+ return [2];
207
193
  productConfig = exports.PRODUCTS[id][state.treble.threekitEnv];
208
194
  dispatch((0, exports.setProductId)(id));
209
195
  if (cacheProduct)
210
196
  dispatch((0, exports.cacheActiveProduct)());
211
- return [4 /*yield*/, dispatch((0, treble_1.reloadPlayer)(productConfig))];
197
+ return [4, dispatch((0, treble_1.reloadPlayer)(productConfig))];
212
198
  case 1:
213
199
  _a.sent();
214
200
  if (cacheProduct) {
215
201
  dispatch((0, exports.incrementActiveCacheIdx)());
216
202
  dispatch((0, exports.cacheActiveProduct)());
217
203
  }
218
- return [2 /*return*/];
204
+ return [2];
219
205
  }
220
206
  });
221
207
  }); };
@@ -238,14 +224,14 @@ var loadNewProduct = function (config) {
238
224
  dispatch((0, exports.cacheActiveProduct)({ label: label, thumbnail: thumbnail }));
239
225
  if (config)
240
226
  dispatch((0, exports.setProductId)(undefined));
241
- return [4 /*yield*/, dispatch((0, treble_1.reloadPlayer)(config))];
227
+ return [4, dispatch((0, treble_1.reloadPlayer)(config))];
242
228
  case 1:
243
229
  _a.sent();
244
230
  if (shouldCacheProduct) {
245
231
  dispatch((0, exports.incrementActiveCacheIdx)());
246
232
  dispatch((0, exports.cacheActiveProduct)({ label: label, thumbnail: thumbnail }));
247
233
  }
248
- return [2 /*return*/];
234
+ return [2];
249
235
  }
250
236
  });
251
237
  }); };
@@ -260,20 +246,20 @@ var changeActiveCacheIdx = function (idx) {
260
246
  state = getState();
261
247
  cache = state.product.cache;
262
248
  if (idx >= cache.length)
263
- return [2 /*return*/, Promise.resolve()];
249
+ return [2, Promise.resolve()];
264
250
  dispatch((0, exports.cacheActiveProduct)());
265
251
  cachedProduct = __assign({}, state.product.cache[idx]);
266
252
  data = JSON.parse(cachedProduct.data);
267
253
  connection_1.default.connect(data.connection);
268
254
  dispatch((0, exports.setActiveCacheIdx)(idx));
269
255
  dispatch((0, exports.setProductId)(cachedProduct.id));
270
- return [4 /*yield*/, dispatch((0, treble_1.reloadPlayer)({
256
+ return [4, dispatch((0, treble_1.reloadPlayer)({
271
257
  assetId: data.connection.assetId,
272
258
  configuration: data.configuration,
273
259
  }))];
274
260
  case 1:
275
261
  _a.sent();
276
- return [2 /*return*/];
262
+ return [2];
277
263
  }
278
264
  });
279
265
  }); };
@@ -288,21 +274,21 @@ var removeProductIdx = function (idx) {
288
274
  state = getState();
289
275
  _a = state.product, cache = _a.cache, activeCacheIdx = _a.activeCacheIdx;
290
276
  if (cache.length <= 1)
291
- return [2 /*return*/, Promise.resolve()];
292
- if (!(!idx || idx === activeCacheIdx)) return [3 /*break*/, 5];
293
- if (!(activeCacheIdx === state.product.cache.length - 1)) return [3 /*break*/, 2];
294
- return [4 /*yield*/, dispatch((0, exports.changeActiveCacheIdx)(activeCacheIdx - 1))];
277
+ return [2, Promise.resolve()];
278
+ if (!(!idx || idx === activeCacheIdx)) return [3, 5];
279
+ if (!(activeCacheIdx === state.product.cache.length - 1)) return [3, 2];
280
+ return [4, dispatch((0, exports.changeActiveCacheIdx)(activeCacheIdx - 1))];
295
281
  case 1:
296
282
  _b.sent();
297
283
  dispatch((0, exports.removeFromCache)(activeCacheIdx));
298
- return [3 /*break*/, 4];
284
+ return [3, 4];
299
285
  case 2:
300
286
  dispatch((0, exports.removeFromCache)(activeCacheIdx));
301
- return [4 /*yield*/, dispatch((0, exports.changeActiveCacheIdx)(activeCacheIdx))];
287
+ return [4, dispatch((0, exports.changeActiveCacheIdx)(activeCacheIdx))];
302
288
  case 3:
303
289
  _b.sent();
304
290
  _b.label = 4;
305
- case 4: return [3 /*break*/, 6];
291
+ case 4: return [3, 6];
306
292
  case 5:
307
293
  if (idx >= activeCacheIdx) {
308
294
  dispatch((0, exports.removeFromCache)(idx));
@@ -312,7 +298,7 @@ var removeProductIdx = function (idx) {
312
298
  dispatch((0, exports.removeFromCache)(idx));
313
299
  }
314
300
  _b.label = 6;
315
- case 6: return [2 /*return*/, Promise.resolve()];
301
+ case 6: return [2, Promise.resolve()];
316
302
  }
317
303
  });
318
304
  }); };
@@ -1,24 +1,12 @@
1
1
  import { RootState, ThreekitDispatch } from './index';
2
2
  import { ITranslationMap } from '../api/products';
3
- /*****************************************************
4
- * Types and Interfaces
5
- ****************************************************/
6
3
  export interface TranslationsState {
7
4
  language: string | undefined;
8
5
  }
9
- /*****************************************************
10
- * Constants
11
- ****************************************************/
12
6
  export declare let TRANSLATIONS: undefined | ITranslationMap;
13
- /*****************************************************
14
- * Actions
15
- ****************************************************/
16
7
  export declare const setLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
17
8
  export declare const initTranslations: (language?: string) => (dispatch: ThreekitDispatch) => Promise<void>;
18
9
  declare const reducer: import("redux").Reducer<TranslationsState, import("redux").AnyAction>;
19
- /*****************************************************
20
- * Standard Selectors
21
- ****************************************************/
22
10
  export declare const getLanguage: (state: RootState) => undefined | string;
23
11
  export declare const getLanguageOptions: (state: RootState) => Array<string>;
24
12
  export default reducer;
@@ -42,28 +42,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.getLanguageOptions = exports.getLanguage = exports.initTranslations = exports.setLanguage = exports.TRANSLATIONS = void 0;
43
43
  var toolkit_1 = require("@reduxjs/toolkit");
44
44
  var api_1 = __importDefault(require("../api"));
45
- /*****************************************************
46
- * Actions
47
- ****************************************************/
48
45
  exports.setLanguage = (0, toolkit_1.createAction)('treble/translations/set-language');
49
46
  var initTranslations = function (language) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
50
47
  return __generator(this, function (_a) {
51
48
  switch (_a.label) {
52
- case 0: return [4 /*yield*/, api_1.default.products.fetchTranslations()];
49
+ case 0: return [4, api_1.default.products.fetchTranslations()];
53
50
  case 1:
54
51
  exports.TRANSLATIONS = _a.sent();
55
52
  if (language)
56
53
  dispatch((0, exports.setLanguage)(language));
57
- return [2 /*return*/];
54
+ return [2];
58
55
  }
59
56
  });
60
57
  }); }; };
61
58
  exports.initTranslations = initTranslations;
62
- /*****************************************************
63
- * State
64
- ****************************************************/
65
59
  var initialState = {
66
- // Selected language
67
60
  language: undefined,
68
61
  };
69
62
  var reducer = (0, toolkit_1.createSlice)({
@@ -76,9 +69,6 @@ var reducer = (0, toolkit_1.createSlice)({
76
69
  },
77
70
  reducers: {},
78
71
  }).reducer;
79
- /*****************************************************
80
- * Standard Selectors
81
- ****************************************************/
82
72
  var getLanguage = function (state) {
83
73
  return state.translations.language;
84
74
  };
@@ -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>;
@@ -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 /*yield*/, window.threekitPlayer(__assign(__assign({ el: el,
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 /*yield*/, player.getConfigurator()];
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 /*yield*/, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
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 /*return*/];
200
+ return [2];
235
201
  }
236
202
  });
237
203
  }); });
238
- return [2 /*return*/];
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 /*return*/];
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 /*return*/, console.error('Missing credentials')];
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 /*break*/, 2];
333
- return [4 /*yield*/, api_1.default.configurations.fetch(configId)];
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 /*return*/, console.error('missing assetId')];
345
- // We create the threekit script
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 /*yield*/, dispatch((0, exports.initPlayer)({
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 /*return*/];
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 /*yield*/, window.threekit.player.unload()];
359
+ return [4, window.threekit.player.unload()];
394
360
  case 1:
395
361
  _a.sent();
396
- return [2 /*return*/];
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 /*break*/, 1];
374
+ if (!(config === undefined)) return [3, 1];
409
375
  assetId = connectionObj.assetId;
410
- return [3 /*break*/, 4];
376
+ return [3, 4];
411
377
  case 1:
412
- if (!(typeof config === 'string')) return [3 /*break*/, 2];
378
+ if (!(typeof config === 'string')) return [3, 2];
413
379
  assetId = config;
414
- return [3 /*break*/, 4];
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 /*break*/, 4];
420
- return [4 /*yield*/, api_1.default.configurations.fetch(config === null || config === void 0 ? void 0 : config.configurationId)];
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 /*break*/, 6];
437
- return [4 /*yield*/, dispatch((0, exports.unloadPlayer)())];
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 /*yield*/, dispatch((0, exports.initPlayer)({
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 /*return*/];
419
+ return [2];
455
420
  }
456
421
  });
457
422
  }); };
@@ -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;
@@ -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 /*yield*/, window.threekit.treble.wishlist.getWishlist()];
46
+ case 0: return [4, window.threekit.treble.wishlist.getWishlist()];
53
47
  case 1:
54
48
  wishlistData = _a.sent();
55
- return [2 /*return*/, wishlistData];
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 /*yield*/, window.threekit.treble.wishlist.addItem(config)];
57
+ case 0: return [4, window.threekit.treble.wishlist.addItem(config)];
64
58
  case 1:
65
59
  wishlistData = _a.sent();
66
- return [2 /*return*/, wishlistData];
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) {