@threekit-tools/treble 0.0.86 → 0.0.88

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.
@@ -1,5 +1,5 @@
1
1
  import threekitAPI from '../api';
2
- import { IThreekitPlayer, IThreekitPrivatePlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../types';
2
+ import { IThreekitPlayer, IThreekitPrivatePlayer, IThreekitPrivateConfigurator } from '../types';
3
3
  import { IWishlist } from './wishlist';
4
4
  import snapshots from './snapshots';
5
5
  import { ISaveConfiguration } from '../api/configurations';
@@ -8,7 +8,6 @@ import { ICartItem } from '../http/orders';
8
8
  interface ITreble {
9
9
  player: IThreekitPlayer;
10
10
  orgId: string;
11
- initialConfiguration: IConfiguration;
12
11
  }
13
12
  interface IEmailShareCredentials {
14
13
  to: string;
@@ -22,11 +21,10 @@ declare class Treble {
22
21
  _api: typeof threekitAPI;
23
22
  _player: IThreekitPrivatePlayer;
24
23
  wishlist: IWishlist;
25
- private _initialConfiguration;
26
24
  private _snapshots;
27
25
  takeSnapshots: typeof snapshots['takeSnapshots'];
28
26
  _debugMode: boolean;
29
- constructor({ player, orgId, initialConfiguration }: ITreble);
27
+ constructor({ player, orgId }: ITreble);
30
28
  createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
31
29
  saveConfiguration: (config?: Partial<Omit<ISaveConfiguration, 'configuration'>>) => Promise<{
32
30
  resumableUrl: string;
@@ -34,7 +32,6 @@ declare class Treble {
34
32
  thumbnail: string;
35
33
  }>;
36
34
  getNestedConfigurator: (address: string | Array<string>) => undefined | IThreekitPrivateConfigurator;
37
- resetConfiguration: (configuration?: ISetConfiguration) => void;
38
35
  sendEmail: (credentials: IEmailShareCredentials, templateData: Record<string, any>) => Promise<import("../http/server").IPostEmailResponse>;
39
36
  }
40
37
  export default Treble;
@@ -48,7 +48,7 @@ var wishlist_1 = __importDefault(require("./wishlist"));
48
48
  var snapshots_1 = __importDefault(require("./snapshots"));
49
49
  var Treble = (function () {
50
50
  function Treble(_a) {
51
- var player = _a.player, orgId = _a.orgId, initialConfiguration = _a.initialConfiguration;
51
+ var player = _a.player, orgId = _a.orgId;
52
52
  var _this = this;
53
53
  this.createOrder = function (order) { return __awaiter(_this, void 0, void 0, function () {
54
54
  var updatedOrder, configuration, response;
@@ -129,11 +129,6 @@ var Treble = (function () {
129
129
  })) === null || _a === void 0 ? void 0 : _a.configurator;
130
130
  }, player.getConfigurator());
131
131
  };
132
- this.resetConfiguration = function (configuration) {
133
- var initialConfiguration = JSON.parse(_this._initialConfiguration);
134
- var updateConfiguration = Object.assign(initialConfiguration, configuration);
135
- window.threekit.configurator.setConfiguration(updateConfiguration);
136
- };
137
132
  this.sendEmail = function (credentials, templateData) {
138
133
  if (!credentials)
139
134
  throw new Error('sendEmail is missing credentials object');
@@ -155,7 +150,6 @@ var Treble = (function () {
155
150
  this._snapshots = snapshots_1.default;
156
151
  this.takeSnapshots = this._snapshots.takeSnapshots;
157
152
  this._player = player.enableApi(types_1.PRIVATE_APIS.PLAYER);
158
- this._initialConfiguration = JSON.stringify(initialConfiguration);
159
153
  this._debugMode = constants_1.TREBLE_DEBUG;
160
154
  }
161
155
  return Treble;
@@ -4,6 +4,7 @@ interface AccordionItemProps extends React.FC {
4
4
  label: string;
5
5
  handleSelect: () => void;
6
6
  onClick: () => void;
7
+ children?: React.ReactNode;
7
8
  }
8
9
  interface AccordionProps<T> {
9
10
  children: React.FunctionComponentElement<T> | Array<React.FunctionComponentElement<T>>;
@@ -23,6 +23,8 @@ var AttributeValue = function (props) {
23
23
  return null;
24
24
  value = (_b = assetAttribute_1.values.find(function (el) { return el.assetId === assetAttribute_1.value.assetId; })) === null || _b === void 0 ? void 0 : _b.name;
25
25
  }
26
+ else if (attributeData.type === types_1.ATTRIBUTE_TYPES.COLOR)
27
+ value = JSON.stringify(attributeData.value);
26
28
  else
27
29
  value = attributeData.value;
28
30
  if (!attribute)
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
- export declare const PortalToArOverlay: React.FC;
2
+ interface PortalToAROverlayProps {
3
+ children?: React.ReactNode;
4
+ }
5
+ export declare const PortalToArOverlay: React.FC<PortalToAROverlayProps>;
3
6
  export default PortalToArOverlay;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface IPortalToElementProps {
3
3
  to?: string;
4
4
  strict?: boolean;
5
+ children?: React.ReactNode;
5
6
  }
6
7
  export declare const PortalToElement: React.FC<IPortalToElementProps>;
7
8
  export default PortalToElement;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { IProducts } from '../../types';
3
3
  export interface ProductLayoutProps {
4
4
  products: Record<string, IProducts>;
5
+ children?: React.ReactNode;
5
6
  }
6
7
  declare const ProductLayout: React.FC<ProductLayoutProps>;
7
8
  export default ProductLayout;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface ITabPaneProps {
3
3
  label: string;
4
4
  onClick: () => void;
5
+ children?: React.ReactNode;
5
6
  }
6
7
  interface ITabs {
7
8
  TabPane: React.FC<ITabPaneProps>;
@@ -4,7 +4,7 @@ export declare const FORM_COMPONENT_TYPES: {
4
4
  };
5
5
  export declare const formComponents: {
6
6
  [x: string]: {
7
- [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null) | ((props: import("./TextInput").ITextInput) => JSX.Element | null);
7
+ [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./TextInput").ITextInput) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null);
8
8
  } | {
9
9
  [x: string]: (props: import("./Upload").IUpload) => JSX.Element | null;
10
10
  };
@@ -12,7 +12,7 @@ export declare const formComponents: {
12
12
  [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null);
13
13
  };
14
14
  String: {
15
- [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null) | ((props: import("./TextInput").ITextInput) => JSX.Element | null);
15
+ [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./TextInput").ITextInput) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null);
16
16
  };
17
17
  upload: {
18
18
  [x: string]: (props: import("./Upload").IUpload) => JSX.Element | null;
@@ -41,6 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var api_1 = __importDefault(require("../../api"));
43
43
  var attributes_1 = require("../../store/attributes");
44
+ var treble_1 = require("../../store/treble");
44
45
  var store_1 = require("../../store");
45
46
  var useConfigurationLoader = function () {
46
47
  var dispatch = (0, store_1.useThreekitDispatch)();
@@ -56,10 +57,19 @@ var useConfigurationLoader = function () {
56
57
  configuration = _a.sent();
57
58
  if (!configuration)
58
59
  return [2];
60
+ if (!(configuration.data.productId === window.threekit.player.assetId)) return [3, 3];
59
61
  return [4, dispatch((0, attributes_1.setConfiguration)(configuration.data.variant))];
60
62
  case 2:
61
63
  _a.sent();
62
- return [2, Promise.resolve()];
64
+ return [3, 5];
65
+ case 3: return [4, dispatch((0, treble_1.reloadPlayer)({
66
+ assetId: configuration.data.productId,
67
+ configuration: configuration.data.variant,
68
+ }))];
69
+ case 4:
70
+ _a.sent();
71
+ _a.label = 5;
72
+ case 5: return [2, Promise.resolve()];
63
73
  }
64
74
  });
65
75
  }); };
@@ -14,6 +14,7 @@ interface UseProductCache {
14
14
  cache: Array<HydratedCacheProduct>;
15
15
  products: Array<ISelectableProduct>;
16
16
  onLoadNewProduct: (config?: string | IReloadConfig) => Promise<void>;
17
+ onResetProduct: () => Promise<void>;
17
18
  }
18
19
  declare const useProductCache: () => UseProductCache;
19
20
  export default useProductCache;
@@ -1,4 +1,40 @@
1
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
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  var product_1 = require("../../store/product");
4
40
  var store_1 = require("../../store");
@@ -9,6 +45,12 @@ var useProductCache = function () {
9
45
  var onLoadNewProduct = function (config) {
10
46
  return dispatch((0, product_1.loadNewProduct)(config));
11
47
  };
48
+ var onResetProduct = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4, dispatch((0, product_1.resetProductConfiguration)())];
51
+ case 1: return [2, _a.sent()];
52
+ }
53
+ }); }); };
12
54
  var hydratedCache = cache.map(function (el, i) {
13
55
  return Object.assign({}, el, {
14
56
  selected: activeProductIdx === i,
@@ -25,6 +67,6 @@ var useProductCache = function () {
25
67
  return dispatch((0, product_1.loadProduct)(prod, config));
26
68
  },
27
69
  }); });
28
- return { cache: hydratedCache, products: products, onLoadNewProduct: onLoadNewProduct };
70
+ return { cache: hydratedCache, products: products, onLoadNewProduct: onLoadNewProduct, onResetProduct: onResetProduct };
29
71
  };
30
72
  exports.default = useProductCache;
@@ -0,0 +1,3 @@
1
+ declare type UseShareHook = undefined | (() => Promise<void>);
2
+ declare const useResetProduct: () => UseShareHook;
3
+ export default useResetProduct;
@@ -0,0 +1,55 @@
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
+ var store_1 = require("../../store");
40
+ var treble_1 = require("../../store/treble");
41
+ var product_1 = require("../../store/product");
42
+ var useResetProduct = function () {
43
+ var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
44
+ var dispatch = (0, store_1.useThreekitDispatch)();
45
+ if (!isLoaded)
46
+ return undefined;
47
+ var handleReset = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4, dispatch((0, product_1.resetProductConfiguration)())];
50
+ case 1: return [2, _a.sent()];
51
+ }
52
+ }); }); };
53
+ return handleReset;
54
+ };
55
+ exports.default = useResetProduct;
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ import Cards from './components/Cards';
23
23
  import Dropdown from './components/Dropdown';
24
24
  import Strips from './components/Strips';
25
25
  import Swatch from './components/Swatch';
26
+ import TextInput from './components/TextInput';
26
27
  import Tiles from './components/Tiles';
27
28
  import TilesGroup from './components/TilesGroup';
28
29
  import Upload from './components/Upload';
@@ -95,4 +96,4 @@ import WishlistIcon from './icons/Wishlist';
95
96
  import ZoomInIcon from './icons/ZoomIn';
96
97
  import ZoomOutIcon from './icons/ZoomOut';
97
98
  import SpinnerIcon from './icons/Spinner';
98
- export { useAttribute, useConfigurator, useConfigurationLoader, useFirstPlayerInteraction, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, Skeleton, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, TrebleApp, ProductLayout, PlayerLoadingCircular, PlayerLoadingSpinner, DraggableHint, TurntableAnimation, BreatheAnimation, AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DraggableIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, };
99
+ export { useAttribute, useConfigurator, useConfigurationLoader, useFirstPlayerInteraction, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, TextInput, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, Skeleton, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, TrebleApp, ProductLayout, PlayerLoadingCircular, PlayerLoadingSpinner, DraggableHint, TurntableAnimation, BreatheAnimation, AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DraggableIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, };
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ 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
- exports.ProductLayout = exports.TrebleApp = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.PortalToArOverlay = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.Skeleton = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayer = exports.useLoadingProgress = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useFirstPlayerInteraction = exports.useConfigurationLoader = exports.useConfigurator = exports.useAttribute = void 0;
7
- exports.SpinnerIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.PlayIcon = exports.PauseIcon = exports.NewWindowIcon = exports.MoreIcon = exports.MenuIcon = exports.MailIcon = exports.InfoIcon = exports.ImageIcon = exports.HeartIcon = exports.EditIcon = exports.DragIcon = exports.DraggableIcon = exports.DownloadIcon = exports.DoubleCaretRightIcon = exports.DoubleCaretLeftIcon = exports.DeleteIcon = exports.CopyIcon = exports.ColorPickerIcon = exports.ClipboardIcon = exports.CheckmateIcon = exports.CartIcon = exports.CaretRightIcon = exports.CaretLeftIcon = exports.CaretUpIcon = exports.CaretDownIcon = exports.CameraIcon = exports.ArrowRightIcon = exports.ArrowLeftIcon = exports.AddIcon = exports.BreatheAnimation = exports.TurntableAnimation = exports.DraggableHint = exports.PlayerLoadingSpinner = exports.PlayerLoadingCircular = void 0;
6
+ exports.TrebleApp = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.PortalToArOverlay = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.Skeleton = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.TextInput = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayer = exports.useLoadingProgress = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useFirstPlayerInteraction = exports.useConfigurationLoader = exports.useConfigurator = exports.useAttribute = void 0;
7
+ exports.SpinnerIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.PlayIcon = exports.PauseIcon = exports.NewWindowIcon = exports.MoreIcon = exports.MenuIcon = exports.MailIcon = exports.InfoIcon = exports.ImageIcon = exports.HeartIcon = exports.EditIcon = exports.DragIcon = exports.DraggableIcon = exports.DownloadIcon = exports.DoubleCaretRightIcon = exports.DoubleCaretLeftIcon = exports.DeleteIcon = exports.CopyIcon = exports.ColorPickerIcon = exports.ClipboardIcon = exports.CheckmateIcon = exports.CartIcon = exports.CaretRightIcon = exports.CaretLeftIcon = exports.CaretUpIcon = exports.CaretDownIcon = exports.CameraIcon = exports.ArrowRightIcon = exports.ArrowLeftIcon = exports.AddIcon = exports.BreatheAnimation = exports.TurntableAnimation = exports.DraggableHint = exports.PlayerLoadingSpinner = exports.PlayerLoadingCircular = exports.ProductLayout = void 0;
8
8
  var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
9
9
  exports.useAttribute = useAttribute_1.default;
10
10
  var useConfigurator_1 = __importDefault(require("./hooks/useConfigurator"));
@@ -55,6 +55,8 @@ var Strips_1 = __importDefault(require("./components/Strips"));
55
55
  exports.Strips = Strips_1.default;
56
56
  var Swatch_1 = __importDefault(require("./components/Swatch"));
57
57
  exports.Swatch = Swatch_1.default;
58
+ var TextInput_1 = __importDefault(require("./components/TextInput"));
59
+ exports.TextInput = TextInput_1.default;
58
60
  var Tiles_1 = __importDefault(require("./components/Tiles"));
59
61
  exports.Tiles = Tiles_1.default;
60
62
  var TilesGroup_1 = __importDefault(require("./components/TilesGroup"));
@@ -7,7 +7,7 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
7
7
  translations: import("./translations").TranslationsState;
8
8
  wishlist: import("../Treble").WishlistArray;
9
9
  price: import("./price").PriceState;
10
- }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>> | import("redux-thunk").ThunkMiddleware<{
10
+ }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux-thunk").ThunkMiddleware<{
11
11
  treble: import("./treble").TrebleState;
12
12
  product: import("./product").ProductState;
13
13
  attributes: import("./attributes").AttributesState;
@@ -36,7 +36,7 @@ export declare const createStore: (reducer?: Record<string, Reducer>) => import(
36
36
  translations: import("./translations").TranslationsState;
37
37
  wishlist: import("../Treble").WishlistArray;
38
38
  price: import("./price").PriceState;
39
- }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>> | import("redux-thunk").ThunkMiddleware<{
39
+ }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux-thunk").ThunkMiddleware<{
40
40
  treble: import("./treble").TrebleState;
41
41
  product: import("./product").ProductState;
42
42
  attributes: import("./attributes").AttributesState;
@@ -34,18 +34,22 @@ var store = (0, toolkit_1.configureStore)({
34
34
  wishlist: wishlist_1.default,
35
35
  price: price_1.default,
36
36
  },
37
- middleware: constants_1.TREBLE_DEBUG
38
- ? function (getDefaultMiddleware) { return getDefaultMiddleware().concat(redux_logger_1.default); }
39
- : function (getDefaultMiddleware) { return getDefaultMiddleware(); },
37
+ middleware: function (getDefaultMiddleware) {
38
+ return constants_1.TREBLE_DEBUG
39
+ ? getDefaultMiddleware().concat(redux_logger_1.default)
40
+ : getDefaultMiddleware();
41
+ },
40
42
  });
41
43
  var createStore = function (reducer) {
42
44
  if (!reducer)
43
45
  return store;
44
46
  return (0, toolkit_1.configureStore)({
45
47
  reducer: __assign(__assign({}, reducer), { treble: treble_1.default, product: product_1.default, attributes: attributes_1.default, translations: translations_1.default, wishlist: wishlist_1.default, price: price_1.default }),
46
- middleware: constants_1.TREBLE_DEBUG
47
- ? function (getDefaultMiddleware) { return getDefaultMiddleware().concat(redux_logger_1.default); }
48
- : function (getDefaultMiddleware) { return getDefaultMiddleware(); },
48
+ middleware: function (getDefaultMiddleware) {
49
+ return constants_1.TREBLE_DEBUG
50
+ ? getDefaultMiddleware().concat(redux_logger_1.default)
51
+ : getDefaultMiddleware();
52
+ },
49
53
  });
50
54
  };
51
55
  exports.createStore = createStore;
@@ -16,8 +16,7 @@ export interface LoadProductConfig {
16
16
  export interface CachedProductState extends Pick<CachedProduct, 'id' | 'name' | 'label' | 'thumbnail'> {
17
17
  data: string;
18
18
  }
19
- interface IEnvConfig extends Record<string, Partial<IProduct>> {
20
- }
19
+ declare type IEnvConfig = Record<string, Partial<IProduct>>;
21
20
  export interface IHydratedProducts extends Record<string, IEnvConfig> {
22
21
  }
23
22
  export interface ProductState {
@@ -43,7 +42,8 @@ export declare const getName: (state: RootState) => undefined | string;
43
42
  export declare const getMetadata: (state: RootState) => undefined | IMetadata;
44
43
  export declare const getActiveCacheIdx: (state: RootState) => number;
45
44
  export declare const getProductCache: (state: RootState) => Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
46
- export declare const initProduct: (prods?: IHydratedProducts) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
45
+ export declare const setProducts: (products: IHydratedProducts) => IHydratedProducts;
46
+ export declare const initProduct: () => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
47
47
  export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, 'label' | 'thumbnail'>) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
48
48
  payload: CachedProductState;
49
49
  type: string;
@@ -52,4 +52,5 @@ export declare const loadProduct: (id: string, config?: LoadProductConfig) => (d
52
52
  export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
53
53
  export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
54
54
  export declare const removeProductIdx: (idx?: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
55
+ export declare const resetProductConfiguration: () => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
55
56
  export default reducer;
@@ -50,11 +50,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.removeProductIdx = exports.changeActiveCacheIdx = exports.loadNewProduct = exports.loadProduct = exports.cacheActiveProduct = exports.initProduct = exports.getProductCache = exports.getActiveCacheIdx = exports.getMetadata = exports.getName = exports.getProductId = exports.decrementActiveCacheIdx = exports.incrementActiveCacheIdx = exports.setActiveCacheIdx = exports.removeFromCache = exports.updateActiveProductCache = exports.appendToCache = exports.setMetadata = exports.setName = exports.setProductId = exports.PRODUCTS = void 0;
53
+ exports.resetProductConfiguration = exports.removeProductIdx = exports.changeActiveCacheIdx = exports.loadNewProduct = exports.loadProduct = exports.cacheActiveProduct = exports.initProduct = exports.setProducts = exports.getProductCache = exports.getActiveCacheIdx = exports.getMetadata = exports.getName = exports.getProductId = exports.decrementActiveCacheIdx = exports.incrementActiveCacheIdx = exports.setActiveCacheIdx = exports.removeFromCache = exports.updateActiveProductCache = exports.appendToCache = exports.setMetadata = exports.setName = exports.setProductId = exports.PRODUCTS = void 0;
54
54
  var toolkit_1 = require("@reduxjs/toolkit");
55
55
  var types_1 = require("../types");
56
56
  var connection_1 = __importDefault(require("../connection"));
57
57
  var treble_1 = require("./treble");
58
+ var attributes_1 = require("./attributes");
59
+ var INITIAL_CONFIGURATIONS = {};
58
60
  exports.setProductId = (0, toolkit_1.createAction)('treble/set-product-id');
59
61
  exports.setName = (0, toolkit_1.createAction)('treble/set-product-name');
60
62
  exports.setMetadata = (0, toolkit_1.createAction)('treble/set-metadata');
@@ -142,25 +144,29 @@ var getProductCache = function (state) {
142
144
  });
143
145
  };
144
146
  exports.getProductCache = getProductCache;
145
- var initProduct = function (prods) {
146
- return function (dispatch, getState) {
147
- if (prods)
148
- exports.PRODUCTS = prods;
149
- if (!window.threekit)
150
- return;
151
- var state = getState();
152
- var name = window.threekit.player.scene.get({
153
- id: window.threekit.player.assetId,
154
- }).name;
155
- var metadata = window.threekit.configurator.getMetadata();
156
- dispatch((0, exports.setName)(name));
157
- dispatch((0, exports.setMetadata)(metadata));
158
- if (!state.product.cache.length) {
159
- dispatch((0, exports.setActiveCacheIdx)(0));
160
- dispatch((0, exports.cacheActiveProduct)());
161
- }
162
- };
147
+ var setProducts = function (products) {
148
+ return (exports.PRODUCTS = products);
163
149
  };
150
+ exports.setProducts = setProducts;
151
+ var initProduct = function () { return function (dispatch, getState) {
152
+ var state = getState();
153
+ var name = window.threekit.player.scene.get({
154
+ id: window.threekit.player.assetId,
155
+ }).name;
156
+ var metadata = window.threekit.configurator.getMetadata();
157
+ var productId = state.product.id;
158
+ if (productId && !INITIAL_CONFIGURATIONS[productId]) {
159
+ var player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
160
+ var configuration = player.configurator.getFullConfiguration();
161
+ INITIAL_CONFIGURATIONS[productId] = JSON.stringify(configuration);
162
+ }
163
+ dispatch((0, exports.setName)(name));
164
+ dispatch((0, exports.setMetadata)(metadata));
165
+ if (!state.product.cache.length) {
166
+ dispatch((0, exports.setActiveCacheIdx)(0));
167
+ dispatch((0, exports.cacheActiveProduct)());
168
+ }
169
+ }; };
164
170
  exports.initProduct = initProduct;
165
171
  var cacheActiveProduct = function (config) {
166
172
  return function (dispatch, getState) {
@@ -306,4 +312,16 @@ var removeProductIdx = function (idx) {
306
312
  }); };
307
313
  };
308
314
  exports.removeProductIdx = removeProductIdx;
315
+ var resetProductConfiguration = function () { return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
316
+ var state, initialConfiguration;
317
+ return __generator(this, function (_a) {
318
+ state = getState();
319
+ if (!state.product.id)
320
+ return [2];
321
+ initialConfiguration = INITIAL_CONFIGURATIONS[state.product.id];
322
+ dispatch((0, attributes_1.setConfiguration)(JSON.parse(initialConfiguration)));
323
+ return [2];
324
+ });
325
+ }); }; };
326
+ exports.resetProductConfiguration = resetProductConfiguration;
309
327
  exports.default = reducer;
@@ -5,7 +5,6 @@ export interface IPlayerInit {
5
5
  authToken: string;
6
6
  assetId: string;
7
7
  stageId?: string;
8
- orgId: string;
9
8
  playerConfig: IPlayerConfig;
10
9
  initialConfiguration?: IConfiguration;
11
10
  }
@@ -167,11 +167,11 @@ var getPlayerInteraction = function (state) {
167
167
  exports.getPlayerInteraction = getPlayerInteraction;
168
168
  var initPlayer = function (config) {
169
169
  return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
170
- var el, authToken, assetId, stageId, orgId, playerConfig, initialConfiguration, player, configurator, ruleName;
170
+ var el, authToken, assetId, stageId, playerConfig, initialConfiguration, player, configurator, orgId, ruleName;
171
171
  return __generator(this, function (_a) {
172
172
  switch (_a.label) {
173
173
  case 0:
174
- el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
174
+ el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
175
175
  dispatch((0, exports.updateLoadingProgress)(0));
176
176
  return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
177
177
  var _a;
@@ -183,6 +183,8 @@ var initPlayer = function (config) {
183
183
  return [4, player.getConfigurator()];
184
184
  case 2:
185
185
  configurator = _a.sent();
186
+ orgId = player.enableApi(types_1.PRIVATE_APIS.PLAYER).orgId;
187
+ connection_1.default.connect({ orgId: orgId });
186
188
  if (window.threekit) {
187
189
  window.threekit = Object.assign(window.threekit, {
188
190
  player: player,
@@ -197,7 +199,6 @@ var initPlayer = function (config) {
197
199
  treble: new Treble_1.default({
198
200
  player: player,
199
201
  orgId: orgId,
200
- initialConfiguration: configurator.getConfiguration(),
201
202
  }),
202
203
  };
203
204
  dispatch((0, exports.setThreekitInitialized)(true));
@@ -250,7 +251,7 @@ var initPlayer = function (config) {
250
251
  exports.initPlayer = initPlayer;
251
252
  var launch = function (launchConfig) {
252
253
  return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
253
- var config, productId, credentials, productsRaw, products, threekitEnv, serverUrl, playerConfig, envCredentials, _a, assetIdRaw, stageId, configurationId, initialConfigurationRaw, assetId, threekitDomainRaw, orgId, authToken, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration;
254
+ var config, productId, credentials, productsRaw, products, threekitEnv, serverUrl, playerConfig, envCredentials, _a, assetIdRaw, stageId, configurationId, initialConfigurationRaw, assetId, threekitDomainRaw, authToken, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration;
254
255
  var _b, _c, _d, _e, _f, _g, _h;
255
256
  return __generator(this, function (_j) {
256
257
  switch (_j.label) {
@@ -304,7 +305,7 @@ var launch = function (launchConfig) {
304
305
  }, {});
305
306
  if (!Object.keys(credentials).length || !Object.keys(products).length)
306
307
  return [2, console.error('Missing credentials')];
307
- dispatch((0, product_1.initProduct)(products));
308
+ (0, product_1.setProducts)(products);
308
309
  dispatch((0, product_1.setProductId)(productId));
309
310
  threekitEnv = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.threekitEnv) || process.env.THREEKIT_ENV || 'preview';
310
311
  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);
@@ -313,7 +314,7 @@ var launch = function (launchConfig) {
313
314
  _a = products[productId][threekitEnv] || {}, assetIdRaw = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
314
315
  assetId = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.assetId) || assetIdRaw;
315
316
  threekitDomainRaw = envCredentials.threekitDomain || "".concat(threekitEnv, ".threekit.com");
316
- orgId = envCredentials.orgId, authToken = envCredentials.publicToken;
317
+ authToken = envCredentials.publicToken;
317
318
  if (playerConfig.elementId) {
318
319
  el = document.getElementById(playerConfig.elementId);
319
320
  if (el)
@@ -325,7 +326,6 @@ var launch = function (launchConfig) {
325
326
  }
326
327
  connection_1.default.connect({
327
328
  authToken: authToken,
328
- orgId: orgId,
329
329
  assetId: assetId,
330
330
  threekitDomain: threekitDomainRaw,
331
331
  serverUrl: serverUrl,
@@ -361,7 +361,6 @@ var launch = function (launchConfig) {
361
361
  _j.sent();
362
362
  return [4, dispatch((0, exports.initPlayer)({
363
363
  el: el,
364
- orgId: orgId,
365
364
  authToken: authToken,
366
365
  stageId: stageId,
367
366
  assetId: updatedAssetId,
@@ -446,7 +445,6 @@ var reloadPlayer = function (config) {
446
445
  _a.label = 6;
447
446
  case 6: return [4, dispatch((0, exports.initPlayer)({
448
447
  el: el,
449
- orgId: connectionObj.orgId,
450
448
  authToken: connectionObj.authToken,
451
449
  stageId: stageId,
452
450
  assetId: assetId,
package/dist/types.d.ts CHANGED
@@ -86,7 +86,7 @@ export interface ISceneResult {
86
86
  }
87
87
  export interface IConfigurationAsset {
88
88
  assetId: string;
89
- configuration?: string;
89
+ configuration?: IConfiguration | string;
90
90
  type?: string;
91
91
  }
92
92
  export interface IConfigurationColor {
@@ -281,14 +281,24 @@ export interface IThreekitPlayer {
281
281
  unload: () => Promise<string>;
282
282
  }
283
283
  export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
284
+ name: string;
285
+ metadata: IMetadata;
284
286
  getAppliedConfiguration: (attributeName: string) => string;
285
287
  getFullConfiguration: () => IConfiguration;
286
288
  }
287
289
  export interface IThreekitPrivatePlayer {
290
+ v: string;
291
+ id: string;
292
+ assetId: string;
293
+ stageId: undefined | string;
294
+ instanceId: string;
295
+ assetType: string;
296
+ orgId: string;
297
+ rect: DOMRect;
298
+ isFullscreen: boolean;
299
+ zoomDisabled: boolean;
288
300
  getConfigurator: () => IThreekitPrivateConfigurator;
289
- configurator: {
290
- getFullConfiguration: () => IConfiguration;
291
- };
301
+ configurator: IThreekitPrivateConfigurator;
292
302
  calculateLogs: () => Promise<Record<string, any>>;
293
303
  getAssetInstance: (query: ISceneQueryNode | string) => Promise<string>;
294
304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -32,7 +32,8 @@
32
32
  "lint-staged": "lint-staged",
33
33
  "check-format": "prettier -c ./src",
34
34
  "format": "prettier --write ./src",
35
- "test": "jest"
35
+ "test": "jest",
36
+ "deploy": "npm run build && npm publish"
36
37
  },
37
38
  "lint-staged": {
38
39
  "./src/**/*.{css,less,scss,html,json,jsx,js,tsx,ts}": [