@threekit-tools/treble 0.0.49 → 0.0.50

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 (37) hide show
  1. package/dist/Treble/Snapshots.js +0 -26
  2. package/dist/Treble/Treble.d.ts +2 -1
  3. package/dist/Treble/Treble.js +2 -2
  4. package/dist/Treble/Wishlist.d.ts +3 -2
  5. package/dist/Treble/Wishlist.js +12 -12
  6. package/dist/components/Accordion/index.d.ts +1 -1
  7. package/dist/components/ThreekitProvider/index.d.ts +3 -1
  8. package/dist/components/ThreekitProvider/index.js +3 -3
  9. package/dist/components/containers/formInputContainer.d.ts +1 -1
  10. package/dist/hooks/useAttribute/index.js +3 -3
  11. package/dist/hooks/useConfigurator/index.js +3 -3
  12. package/dist/hooks/useMetadata/index.js +2 -2
  13. package/dist/hooks/useName/index.js +2 -2
  14. package/dist/hooks/usePlayerLoadingStatus/index.js +2 -2
  15. package/dist/hooks/usePlayerPortal/index.js +2 -2
  16. package/dist/hooks/usePrice/index.d.ts +1 -1
  17. package/dist/hooks/usePrice/index.js +2 -2
  18. package/dist/hooks/useShare/index.js +2 -2
  19. package/dist/hooks/useSnapshot/index.js +2 -2
  20. package/dist/hooks/useThreekitInitStatus/index.js +2 -2
  21. package/dist/hooks/useWishlist/index.js +8 -7
  22. package/dist/store/attributes.d.ts +20 -0
  23. package/dist/store/attributes.js +135 -0
  24. package/dist/store/index.d.ts +67 -7
  25. package/dist/store/index.js +36 -4
  26. package/dist/store/price.d.ts +32 -0
  27. package/dist/store/price.js +56 -0
  28. package/dist/store/product.d.ts +21 -0
  29. package/dist/store/product.js +46 -0
  30. package/dist/store/translations.d.ts +21 -0
  31. package/dist/store/translations.js +46 -0
  32. package/dist/store/treble.d.ts +41 -0
  33. package/dist/store/{threekit.js → treble.js} +51 -225
  34. package/dist/store/wishlist.d.ts +24 -0
  35. package/dist/store/wishlist.js +101 -0
  36. package/package.json +1 -1
  37. package/dist/store/threekit.d.ts +0 -68
@@ -129,32 +129,6 @@ var Snapshots = /** @class */ (function () {
129
129
  }, Promise.resolve(snapshots));
130
130
  };
131
131
  this.takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(_this, void 0, void 0, function () {
132
- // function getSnapshot() {
133
- // return window.threekit.player.snapshotAsync({
134
- // size,
135
- // mimeType: `image/${SNAPSHOT_FORMATS[format]}`,
136
- // })
137
- // }
138
- // function getSnapshots(
139
- // cameras: Array<string | undefined>,
140
- // camerasMap: CamerasMap
141
- // ) {
142
- // let snapshots: Array<string> = []
143
- // return cameras.reduce((snapshotPromise, camera) => {
144
- // return snapshotPromise.then(
145
- // () =>
146
- // new Promise(async (resolve) => {
147
- // if (camera)
148
- // await window.threekit.configurator.setConfiguration({
149
- // [attributeName]: camerasMap[camera],
150
- // })
151
- // const snapshotStr = await getSnapshot()
152
- // snapshots.push(snapshotStr)
153
- // resolve(snapshots)
154
- // })
155
- // )
156
- // }, Promise.resolve(snapshots))
157
- // }
158
132
  function saveSnapshotToPlatform(snapshot, filename) {
159
133
  return __awaiter(this, void 0, void 0, function () {
160
134
  var files, response;
@@ -4,6 +4,7 @@ import { IWishlist } from './Wishlist';
4
4
  import Snapshots from './Snapshots';
5
5
  interface ITreble {
6
6
  player: IThreekitPlayer;
7
+ orgId: string;
7
8
  }
8
9
  export interface ISaveConfigurationConfig {
9
10
  customerId?: string;
@@ -16,7 +17,7 @@ declare class Treble {
16
17
  wishlist: IWishlist;
17
18
  private _snapshots;
18
19
  takeSnapshots: Snapshots['takeSnapshots'];
19
- constructor({ player }: ITreble);
20
+ constructor({ player, orgId }: ITreble);
20
21
  saveConfiguration: (config?: ISaveConfigurationConfig | undefined) => Promise<{
21
22
  resumableUrl: string;
22
23
  } & import("../http/configurations").IConfigurationResponse & {
@@ -48,7 +48,7 @@ var Snapshots_1 = __importDefault(require("./Snapshots"));
48
48
  var Treble = /** @class */ (function () {
49
49
  function Treble(_a) {
50
50
  var _this = this;
51
- var player = _a.player;
51
+ var player = _a.player, orgId = _a.orgId;
52
52
  this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
53
53
  var threekitDomain, _a, customerId, metadata, productVersion, files, response, params, url;
54
54
  var _b;
@@ -86,7 +86,7 @@ var Treble = /** @class */ (function () {
86
86
  // Threekit API
87
87
  this._api = api_1.default;
88
88
  this._player = player;
89
- this.wishlist = (0, Wishlist_1.default)();
89
+ this.wishlist = (0, Wishlist_1.default)(orgId);
90
90
  this._snapshots = new Snapshots_1.default();
91
91
  this.takeSnapshots = this._snapshots.takeSnapshots;
92
92
  // this._player = player.enableApi('player')
@@ -8,11 +8,12 @@ export interface IWishlist {
8
8
  clearWishlist(): Array<IConfigurationResponse>;
9
9
  }
10
10
  declare class Wishlist implements IWishlist {
11
- constructor();
11
+ _wishlistKey: string;
12
+ constructor(orgId: string);
12
13
  getWishlist: () => Promise<WishlistArray>;
13
14
  addItem: (config?: ISaveConfigurationConfig | undefined) => Promise<WishlistArray>;
14
15
  removeItemByIdx: (idx: number) => WishlistArray;
15
16
  clearWishlist: () => WishlistArray;
16
17
  }
17
- export default function createWishlist(): Wishlist;
18
+ export default function createWishlist(orgId: string): Wishlist;
18
19
  export {};
@@ -53,7 +53,7 @@ var connection_1 = __importDefault(require("../connection"));
53
53
  var constants_1 = require("../constants");
54
54
  var wishlistData;
55
55
  var Wishlist = /** @class */ (function () {
56
- function Wishlist() {
56
+ function Wishlist(orgId) {
57
57
  var _this = this;
58
58
  this.getWishlist = function () { return __awaiter(_this, void 0, void 0, function () {
59
59
  var threekitDomain, wishlistListStr, wishlistList, wishlistDataRaw;
@@ -63,7 +63,7 @@ var Wishlist = /** @class */ (function () {
63
63
  if (wishlistData)
64
64
  return [2 /*return*/, wishlistData];
65
65
  threekitDomain = connection_1.default.getConnection().threekitDomain;
66
- wishlistListStr = localStorage.getItem(constants_1.WISHLIST_LOCALSTORAGE_KEY);
66
+ wishlistListStr = localStorage.getItem(this._wishlistKey);
67
67
  wishlistList = JSON.parse(wishlistListStr || '[]');
68
68
  return [4 /*yield*/, Promise.all(wishlistList.map(function (el) { return api_1.default.configurations.fetch(el); }))];
69
69
  case 1:
@@ -87,20 +87,19 @@ var Wishlist = /** @class */ (function () {
87
87
  case 0:
88
88
  if (!wishlistData) {
89
89
  wishlistData = [];
90
- localStorage.setItem(constants_1.WISHLIST_LOCALSTORAGE_KEY, JSON.stringify([]));
90
+ localStorage.setItem(this._wishlistKey, JSON.stringify([]));
91
91
  }
92
92
  configPrepped = Object.assign({ snapshot: true }, config);
93
93
  return [4 /*yield*/, window.threekit.treble.saveConfiguration(configPrepped)];
94
94
  case 1:
95
95
  savedConfiguration = _a.sent();
96
- // const savedConfiguration = await this.saveConfiguration(configPrepped)
97
96
  if (!savedConfiguration)
98
97
  return [2 /*return*/, wishlistData];
99
98
  wishlistData = __spreadArray(__spreadArray([], wishlistData, true), [savedConfiguration], false);
100
- wishlistListStr = localStorage.getItem(constants_1.WISHLIST_LOCALSTORAGE_KEY);
99
+ wishlistListStr = localStorage.getItem(this._wishlistKey);
101
100
  wishlistList = JSON.parse(wishlistListStr || '[]');
102
101
  wishlistList.push(savedConfiguration.shortId);
103
- localStorage.setItem(constants_1.WISHLIST_LOCALSTORAGE_KEY, JSON.stringify(wishlistList));
102
+ localStorage.setItem(this._wishlistKey, JSON.stringify(wishlistList));
104
103
  return [2 /*return*/, this.getWishlist()];
105
104
  }
106
105
  });
@@ -108,7 +107,7 @@ var Wishlist = /** @class */ (function () {
108
107
  this.removeItemByIdx = function (idx) {
109
108
  if (!(wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length)) {
110
109
  wishlistData = [];
111
- localStorage.setItem(constants_1.WISHLIST_LOCALSTORAGE_KEY, JSON.stringify([]));
110
+ localStorage.setItem(_this._wishlistKey, JSON.stringify([]));
112
111
  return wishlistData;
113
112
  }
114
113
  if (idx > (wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length) - 1)
@@ -116,22 +115,23 @@ var Wishlist = /** @class */ (function () {
116
115
  var updatedWishlist = __spreadArray([], wishlistData, true);
117
116
  updatedWishlist.splice(idx, 1);
118
117
  wishlistData = updatedWishlist;
119
- var wishlistListStr = localStorage.getItem(constants_1.WISHLIST_LOCALSTORAGE_KEY);
118
+ var wishlistListStr = localStorage.getItem(_this._wishlistKey);
120
119
  var wishlistList = JSON.parse(wishlistListStr || '[]');
121
120
  wishlistList.splice(idx, 1);
122
- localStorage.setItem(constants_1.WISHLIST_LOCALSTORAGE_KEY, JSON.stringify(wishlistList));
121
+ localStorage.setItem(_this._wishlistKey, JSON.stringify(wishlistList));
123
122
  return wishlistData;
124
123
  };
125
124
  this.clearWishlist = function () {
126
125
  wishlistData = [];
127
- localStorage.setItem(constants_1.WISHLIST_LOCALSTORAGE_KEY, JSON.stringify([]));
126
+ localStorage.setItem(_this._wishlistKey, JSON.stringify([]));
128
127
  return wishlistData;
129
128
  };
129
+ this._wishlistKey = "".concat(constants_1.WISHLIST_LOCALSTORAGE_KEY, "_").concat(orgId);
130
130
  this.getWishlist();
131
131
  }
132
132
  return Wishlist;
133
133
  }());
134
- function createWishlist() {
135
- return new Wishlist();
134
+ function createWishlist(orgId) {
135
+ return new Wishlist(orgId);
136
136
  }
137
137
  exports.default = createWishlist;
@@ -6,7 +6,7 @@ interface AccordionItemProps extends React.FC {
6
6
  onClick: () => void;
7
7
  }
8
8
  interface AccordionProps<T> {
9
- children: React.FunctionComponentElement<T>;
9
+ children: React.FunctionComponentElement<T> | Array<React.FunctionComponentElement<T>>;
10
10
  }
11
11
  export declare const Accordion: {
12
12
  (props: AccordionProps<AccordionItemProps>): React.FunctionComponentElement<AccordionItemProps>[] | null;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import { ILaunchConfig } from '../../store/threekit';
2
+ import { Reducer } from 'redux';
3
+ import { ILaunchConfig } from '../../store/treble';
3
4
  interface Theme {
4
5
  [key: string]: string | number;
5
6
  }
6
7
  export interface ThreekitProviderProps extends Partial<ILaunchConfig> {
7
8
  theme?: Theme;
9
+ reducer?: Record<string, Reducer>;
8
10
  children: React.ReactNode;
9
11
  }
10
12
  declare const ThreekitProvider: (props: ThreekitProviderProps) => JSX.Element;
@@ -24,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  var react_1 = __importStar(require("react"));
26
26
  var store_1 = __importStar(require("../../store"));
27
- var threekit_1 = require("../../store/threekit");
27
+ var treble_1 = require("../../store/treble");
28
28
  var react_redux_1 = require("react-redux");
29
29
  var styled_components_1 = require("styled-components");
30
30
  var theme_1 = __importDefault(require("../../theme"));
@@ -34,7 +34,7 @@ var App = function (props) {
34
34
  (0, react_1.useEffect)(function () {
35
35
  var init = function () {
36
36
  var playerConfig = props.playerConfig, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
37
- dispatch((0, threekit_1.launch)({ playerConfig: playerConfig, project: project, locale: locale, threekitEnv: threekitEnv, eventHandlers: eventHandlers }));
37
+ dispatch((0, treble_1.launch)({ playerConfig: playerConfig, project: project, locale: locale, threekitEnv: threekitEnv, eventHandlers: eventHandlers }));
38
38
  };
39
39
  init();
40
40
  return;
@@ -42,7 +42,7 @@ var App = function (props) {
42
42
  return react_1.default.createElement(react_1.default.Fragment, null, props.children);
43
43
  };
44
44
  var ThreekitProvider = function (props) {
45
- return (react_1.default.createElement(react_redux_1.Provider, { store: store_1.default },
45
+ return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
46
46
  react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
47
47
  react_1.default.createElement(GlobalStyles_styles_1.default, null),
48
48
  react_1.default.createElement(App, { locale: props.locale, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
@@ -45,7 +45,7 @@ interface IPrepAttributeConfig {
45
45
  sort?: string;
46
46
  }
47
47
  export declare const prepAttributeForComponent: (attribute: IThreekitDisplayAttribute, config: IPrepAttributeConfig) => {
48
- selected: string | number | import("../../threekit").IConfigurationColor | import("../../threekit").IConfigurationAsset;
48
+ selected: string | number | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
49
49
  options: IDisplayAttributeAssetValue[] | {
50
50
  name: string;
51
51
  label: string;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
4
+ var attributes_1 = require("../../store/attributes");
5
5
  var utils_1 = require("../../utils");
6
6
  var useAttribute = function (attributeName) {
7
7
  if (!attributeName)
8
8
  return [undefined, undefined];
9
9
  var dispatch = (0, store_1.useThreekitDispatch)();
10
- var attributes = (0, store_1.useThreekitSelector)(threekit_1.getAttributes);
10
+ var attributes = (0, store_1.useThreekitSelector)(attributes_1.getAttributes);
11
11
  if (!attributeName || !attributes)
12
12
  return [undefined, undefined];
13
13
  var attribute = attributes[attributeName];
@@ -16,7 +16,7 @@ var useAttribute = function (attributeName) {
16
16
  var handleChange = function (value) {
17
17
  var _a;
18
18
  var preppedValue = (0, utils_1.selectionToConfiguration)(value, attribute.type);
19
- dispatch((0, threekit_1.setConfiguration)((_a = {},
19
+ dispatch((0, attributes_1.setConfiguration)((_a = {},
20
20
  _a[attributeName] = preppedValue,
21
21
  _a)));
22
22
  };
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var threekit_1 = require("../../store/threekit");
3
+ var attributes_1 = require("../../store/attributes");
4
4
  var store_1 = require("../../store");
5
5
  var useConfigurator = function () {
6
6
  var dispatch = (0, store_1.useThreekitDispatch)();
7
- var attributes = (0, store_1.useThreekitSelector)(threekit_1.getAttributes);
7
+ var attributes = (0, store_1.useThreekitSelector)(attributes_1.getAttributes);
8
8
  if (!attributes)
9
9
  return [undefined, undefined];
10
10
  var handleChange = function (configuration) {
11
- return dispatch((0, threekit_1.setConfiguration)(configuration));
11
+ return dispatch((0, attributes_1.setConfiguration)(configuration));
12
12
  };
13
13
  return [attributes, handleChange];
14
14
  };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
4
+ var product_1 = require("../../store/product");
5
5
  var useMetadata = function () {
6
- var metadata = (0, store_1.useThreekitSelector)(threekit_1.getMetadata);
6
+ var metadata = (0, store_1.useThreekitSelector)(product_1.getMetadata);
7
7
  return metadata;
8
8
  };
9
9
  exports.default = useMetadata;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
5
- var useName = function () { return (0, store_1.useThreekitSelector)(threekit_1.getName); };
4
+ var product_1 = require("../../store/product");
5
+ var useName = function () { return (0, store_1.useThreekitSelector)(product_1.getName); };
6
6
  exports.default = useName;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
4
+ var treble_1 = require("../../store/treble");
5
5
  var usePlayerLoadingStatus = function () {
6
- return (0, store_1.useThreekitSelector)(threekit_1.isPlayerLoading);
6
+ return (0, store_1.useThreekitSelector)(treble_1.isPlayerLoading);
7
7
  };
8
8
  exports.default = usePlayerLoadingStatus;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var react_1 = require("react");
4
4
  var react_redux_1 = require("react-redux");
5
- var threekit_1 = require("../../store/threekit");
5
+ var treble_1 = require("../../store/treble");
6
6
  var constants_1 = require("../../constants");
7
7
  var usePlayerPortal = function () {
8
8
  var htmlElements = (0, react_1.useRef)({
@@ -10,7 +10,7 @@ var usePlayerPortal = function () {
10
10
  playerLoader: null,
11
11
  playerWrapper: null,
12
12
  });
13
- var playerElementId = (0, react_redux_1.useSelector)(threekit_1.getPlayerElementId);
13
+ var playerElementId = (0, react_redux_1.useSelector)(treble_1.getPlayerElementId);
14
14
  if (!playerElementId)
15
15
  return [undefined, undefined];
16
16
  var portalPlayerTo = function (toEl) {
@@ -1,3 +1,3 @@
1
- import { IPrice } from '../../store/threekit';
1
+ import { IPrice } from '../../store/price';
2
2
  declare const usePrice: () => IPrice | undefined;
3
3
  export default usePrice;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
5
- var usePrice = function () { return (0, store_1.useThreekitSelector)(threekit_1.getPrice); };
4
+ var price_1 = require("../../store/price");
5
+ var usePrice = function () { return (0, store_1.useThreekitSelector)(price_1.getPrice); };
6
6
  exports.default = usePrice;
@@ -40,11 +40,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var store_1 = require("../../store");
43
- var threekit_1 = require("../../store/threekit");
43
+ var treble_1 = require("../../store/treble");
44
44
  var message_1 = __importDefault(require("../../components/message"));
45
45
  var utils_1 = require("../../utils");
46
46
  var useShare = function () {
47
- var isLoaded = (0, store_1.useThreekitSelector)(threekit_1.isThreekitLoaded);
47
+ var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
48
48
  if (!isLoaded)
49
49
  return undefined;
50
50
  var handleShare = function (msg) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
4
+ var treble_1 = require("../../store/treble");
5
5
  var useSnapshot = function (cameras, config) {
6
- var isLoaded = (0, store_1.useThreekitSelector)(threekit_1.isThreekitLoaded);
6
+ var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
7
7
  if (!isLoaded)
8
8
  return undefined;
9
9
  var takeSnapshot = function () {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var store_1 = require("../../store");
4
- var threekit_1 = require("../../store/threekit");
4
+ var treble_1 = require("../../store/treble");
5
5
  var useThreekitInitStatus = function () {
6
- return (0, store_1.useThreekitSelector)(threekit_1.isThreekitLoaded);
6
+ return (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
7
7
  };
8
8
  exports.default = useThreekitInitStatus;
@@ -3,25 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var threekit_1 = require("../../store/threekit");
6
+ var wishlist_1 = require("../../store/wishlist");
7
+ var treble_1 = require("../../store/treble");
7
8
  var store_1 = require("../../store");
8
9
  var utils_1 = require("../../utils");
9
10
  var message_1 = __importDefault(require("../../components/message"));
10
11
  var useWishlist = function () {
11
12
  var dispatch = (0, store_1.useThreekitDispatch)();
12
- var isLoaded = (0, store_1.useThreekitSelector)(threekit_1.isThreekitLoaded);
13
- var wishlist = (0, store_1.useThreekitSelector)(threekit_1.getWishlist);
13
+ var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
14
+ var wishlist = (0, store_1.useThreekitSelector)(wishlist_1.getWishlist);
14
15
  if (!isLoaded)
15
16
  return [undefined, undefined, undefined, undefined, undefined, undefined];
16
17
  var handleAddToWishlist = function (config) {
17
- return dispatch((0, threekit_1.addToWishlist)(config));
18
+ return dispatch((0, wishlist_1.addToWishlist)(config));
18
19
  };
19
20
  var handleRemoveFromWishlist = function (idx) {
20
- dispatch((0, threekit_1.removeFromWishlist)(idx));
21
+ dispatch((0, wishlist_1.removeFromWishlist)(idx));
21
22
  message_1.default.info('Item removed from wishlist');
22
23
  };
23
24
  var handleResumeItem = function (idx) {
24
- dispatch((0, threekit_1.resumeFromWishlist)(idx));
25
+ dispatch((0, wishlist_1.resumeFromWishlist)(idx));
25
26
  };
26
27
  var handleShareItem = function (idx) {
27
28
  var url = (0, utils_1.getResumableUrl)(wishlist[idx].shortId);
@@ -29,7 +30,7 @@ var useWishlist = function () {
29
30
  message_1.default.info('Link copied!');
30
31
  };
31
32
  var handleClearWishlist = function () {
32
- dispatch(threekit_1.clearWishlist);
33
+ dispatch(wishlist_1.clearWishlist);
33
34
  };
34
35
  return [
35
36
  wishlist,
@@ -0,0 +1,20 @@
1
+ import { RootState, ThreekitDispatch } from './index';
2
+ import { ISetConfiguration, IThreekitDisplayAttribute } from '../threekit';
3
+ /*****************************************************
4
+ * Types and Interfaces
5
+ ****************************************************/
6
+ export declare type AttributesState = Record<string, IThreekitDisplayAttribute>;
7
+ /*****************************************************
8
+ * Actions
9
+ ****************************************************/
10
+ export declare const setAttributes: import("@reduxjs/toolkit").ActionCreatorWithPayload<IThreekitDisplayAttribute[], string>;
11
+ /*****************************************************
12
+ * Slice
13
+ ****************************************************/
14
+ declare const reducer: import("redux").Reducer<AttributesState, import("redux").AnyAction>;
15
+ /*****************************************************
16
+ * Standard Selectors
17
+ ****************************************************/
18
+ export declare const getAttributes: (state: RootState) => undefined | Record<string, IThreekitDisplayAttribute>;
19
+ export declare const setConfiguration: (config: ISetConfiguration) => (dispatch: ThreekitDispatch) => Promise<void>;
20
+ export default reducer;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.setConfiguration = exports.getAttributes = exports.setAttributes = void 0;
40
+ var toolkit_1 = require("@reduxjs/toolkit");
41
+ var treble_1 = require("./treble");
42
+ // export interface AttributesState {
43
+ // attributes: Record<string, IThreekitDisplayAttribute>;
44
+ // }
45
+ /*****************************************************
46
+ * Actions
47
+ ****************************************************/
48
+ exports.setAttributes = (0, toolkit_1.createAction)('setAttributes');
49
+ /*****************************************************
50
+ * State and Data
51
+ ****************************************************/
52
+ var initialState = {};
53
+ /*****************************************************
54
+ * Slice
55
+ ****************************************************/
56
+ var reducer = (0, toolkit_1.createSlice)({
57
+ name: 'attributes',
58
+ initialState: initialState,
59
+ reducers: {},
60
+ extraReducers: function (builder) {
61
+ builder.addCase(exports.setAttributes, function (state, action) {
62
+ state = action.payload.reduce(function (output, attr) {
63
+ var _a;
64
+ return Object.assign(output, (_a = {}, _a[attr.name] = attr, _a));
65
+ }, {});
66
+ return state;
67
+ });
68
+ },
69
+ }).reducer;
70
+ /*****************************************************
71
+ * Standard Selectors
72
+ ****************************************************/
73
+ // Attributes
74
+ var getAttributes = function (state) {
75
+ // const { isThreekitLoaded, attributes, language, translations } =
76
+ // state.threekit;
77
+ var attributes = state.attributes;
78
+ var isThreekitInitialized = state.treble.isThreekitInitialized;
79
+ var _a = state.translations, language = _a.language, translations = _a.translations;
80
+ if (!isThreekitInitialized)
81
+ return undefined;
82
+ if (!attributes)
83
+ return undefined;
84
+ var hasTranslation = !!language && !!translations;
85
+ return Object.values(attributes).reduce(function (output, attribute) {
86
+ var _a;
87
+ var _b;
88
+ return Object.assign(output, (_a = {},
89
+ _a[attribute.name] = Object.assign({}, attribute, {
90
+ label: hasTranslation
91
+ ? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
92
+ : attribute.name,
93
+ }, attribute.type === 'String'
94
+ ? {
95
+ values: attribute.values.map(function (el) {
96
+ var _a;
97
+ return Object.assign({}, el, {
98
+ label: hasTranslation
99
+ ? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
100
+ : el.label,
101
+ });
102
+ }),
103
+ }
104
+ : attribute.type === 'Asset'
105
+ ? {
106
+ values: attribute.values.map(function (el) {
107
+ var _a;
108
+ return Object.assign({}, el, {
109
+ label: hasTranslation
110
+ ? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
111
+ : el.name,
112
+ });
113
+ }),
114
+ }
115
+ : undefined),
116
+ _a));
117
+ }, {});
118
+ };
119
+ exports.getAttributes = getAttributes;
120
+ // Configurator
121
+ var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
122
+ return __generator(this, function (_a) {
123
+ switch (_a.label) {
124
+ case 0:
125
+ dispatch((0, treble_1.setPlayerLoading)(true));
126
+ return [4 /*yield*/, window.threekit.configurator.setConfiguration(config)];
127
+ case 1:
128
+ _a.sent();
129
+ dispatch((0, treble_1.setPlayerLoading)(false));
130
+ return [2 /*return*/];
131
+ }
132
+ });
133
+ }); }; };
134
+ exports.setConfiguration = setConfiguration;
135
+ exports.default = reducer;