@threekit-tools/treble 0.0.89-next-006 → 0.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  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.useRoomBuilder = 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.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.Player3DIcon = 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.RoomBuilderLayoutIcon = exports.BreatheAnimation = exports.TurntableAnimation = exports.DraggableHint = exports.PlayerLoadingSpinner = exports.PlayerLoadingCircular = exports.ProductLayout = exports.TrebleApp = void 0;
8
- exports.LayoutIcon = exports.WallIcon = exports.OpeningIcon = exports.DoorIcon = exports.DrawIcon = exports.WindowIcon = exports.CursorIcon = exports.TrashCanAltIcon = exports.TrashCanIcon = exports.AngleIcon = exports.SpinnerIcon = void 0;
7
+ exports.AngleIcon = 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 = exports.TrebleApp = void 0;
8
+ exports.LayoutIcon = exports.WallIcon = exports.OpeningIcon = exports.DoorIcon = exports.DrawIcon = exports.WindowIcon = exports.CursorIcon = exports.TrashCanAltIcon = exports.TrashCanIcon = void 0;
9
9
  var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
10
10
  exports.useAttribute = useAttribute_1.default;
11
11
  var useConfigurator_1 = __importDefault(require("./hooks/useConfigurator"));
@@ -120,8 +120,6 @@ var TurntableAnimation_1 = __importDefault(require("./components/TurntableAnimat
120
120
  exports.TurntableAnimation = TurntableAnimation_1.default;
121
121
  var BreatheAnimation_1 = __importDefault(require("./components/BreatheAnimation"));
122
122
  exports.BreatheAnimation = BreatheAnimation_1.default;
123
- var RoomBuilderLayout_1 = __importDefault(require("./hooks/useRoomBuilder/RoomBuilderLayout"));
124
- exports.RoomBuilderLayoutIcon = RoomBuilderLayout_1.default;
125
123
  var Add_1 = __importDefault(require("./icons/Add"));
126
124
  exports.AddIcon = Add_1.default;
127
125
  var ArrowLeft_1 = __importDefault(require("./icons/ArrowLeft"));
@@ -180,8 +178,6 @@ var Pause_1 = __importDefault(require("./icons/Pause"));
180
178
  exports.PauseIcon = Pause_1.default;
181
179
  var Play_1 = __importDefault(require("./icons/Play"));
182
180
  exports.PlayIcon = Play_1.default;
183
- var Player3D_1 = __importDefault(require("./icons/Player3D"));
184
- exports.Player3DIcon = Player3D_1.default;
185
181
  var Redo_1 = __importDefault(require("./icons/Redo"));
186
182
  exports.RedoIcon = Redo_1.default;
187
183
  var Remove_1 = __importDefault(require("./icons/Remove"));
@@ -12,7 +12,6 @@ export declare const getHydrationData: ((state: {
12
12
  translations: import("./translations").TranslationsState;
13
13
  wishlist: import("../Treble").WishlistArray;
14
14
  price: import("./price").PriceState;
15
- roomBuilder: import("./roomBuilder").RoomBuilderState;
16
15
  }) => [Record<string, IThreekitDisplayAttribute>, ITranslationMap | undefined, string | undefined]) & import("reselect").OutputSelectorFields<(args_0: AttributesState, args_1: string | undefined) => [Record<string, IThreekitDisplayAttribute>, ITranslationMap | undefined, string | undefined] & {
17
16
  clearCache: () => void;
18
17
  }> & {
@@ -7,7 +7,6 @@ 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
- roomBuilder: import("./roomBuilder").RoomBuilderState;
11
10
  }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
12
11
  treble: import("./treble").TrebleState;
13
12
  product: import("./product").ProductState;
@@ -15,7 +14,6 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
15
14
  translations: import("./translations").TranslationsState;
16
15
  wishlist: import("../Treble").WishlistArray;
17
16
  price: import("./price").PriceState;
18
- roomBuilder: import("./roomBuilder").RoomBuilderState;
19
17
  }, import("redux").AnyAction, undefined>]> | import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
20
18
  treble: import("./treble").TrebleState;
21
19
  product: import("./product").ProductState;
@@ -23,7 +21,6 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
23
21
  translations: import("./translations").TranslationsState;
24
22
  wishlist: import("../Treble").WishlistArray;
25
23
  price: import("./price").PriceState;
26
- roomBuilder: import("./roomBuilder").RoomBuilderState;
27
24
  }, import("redux").AnyAction, undefined>, import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>>]>>;
28
25
  export declare const createStore: (reducer?: Record<string, Reducer>) => import("@reduxjs/toolkit").EnhancedStore<{
29
26
  treble: import("./treble").TrebleState;
@@ -32,7 +29,6 @@ export declare const createStore: (reducer?: Record<string, Reducer>) => import(
32
29
  translations: import("./translations").TranslationsState;
33
30
  wishlist: import("../Treble").WishlistArray;
34
31
  price: import("./price").PriceState;
35
- roomBuilder: import("./roomBuilder").RoomBuilderState;
36
32
  }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
37
33
  treble: import("./treble").TrebleState;
38
34
  product: import("./product").ProductState;
@@ -40,7 +36,6 @@ export declare const createStore: (reducer?: Record<string, Reducer>) => import(
40
36
  translations: import("./translations").TranslationsState;
41
37
  wishlist: import("../Treble").WishlistArray;
42
38
  price: import("./price").PriceState;
43
- roomBuilder: import("./roomBuilder").RoomBuilderState;
44
39
  }, import("redux").AnyAction, undefined>]> | import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
45
40
  treble: import("./treble").TrebleState;
46
41
  product: import("./product").ProductState;
@@ -48,7 +43,6 @@ export declare const createStore: (reducer?: Record<string, Reducer>) => import(
48
43
  translations: import("./translations").TranslationsState;
49
44
  wishlist: import("../Treble").WishlistArray;
50
45
  price: import("./price").PriceState;
51
- roomBuilder: import("./roomBuilder").RoomBuilderState;
52
46
  }, import("redux").AnyAction, undefined>, import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>>]>>;
53
47
  export declare type RootState = ReturnType<typeof store.getState>;
54
48
  export declare type ThreekitDispatch = typeof store.dispatch;
@@ -59,7 +53,6 @@ export declare const useThreekitDispatch: () => import("@reduxjs/toolkit").Thunk
59
53
  translations: import("./translations").TranslationsState;
60
54
  wishlist: import("../Treble").WishlistArray;
61
55
  price: import("./price").PriceState;
62
- roomBuilder: import("./roomBuilder").RoomBuilderState;
63
56
  }, undefined, import("redux").AnyAction> & import("redux").Dispatch<import("redux").AnyAction>;
64
57
  export declare const useThreekitSelector: TypedUseSelectorHook<RootState>;
65
58
  export default createStore;
@@ -25,7 +25,6 @@ var attributes_1 = __importDefault(require("./attributes"));
25
25
  var wishlist_1 = __importDefault(require("./wishlist"));
26
26
  var translations_1 = __importDefault(require("./translations"));
27
27
  var price_1 = __importDefault(require("./price"));
28
- var roomBuilder_1 = __importDefault(require("./roomBuilder"));
29
28
  var store = (0, toolkit_1.configureStore)({
30
29
  reducer: {
31
30
  treble: treble_1.default,
@@ -34,7 +33,6 @@ var store = (0, toolkit_1.configureStore)({
34
33
  translations: translations_1.default,
35
34
  wishlist: wishlist_1.default,
36
35
  price: price_1.default,
37
- roomBuilder: roomBuilder_1.default,
38
36
  },
39
37
  middleware: function (getDefaultMiddleware) {
40
38
  return constants_1.TREBLE_DEBUG
@@ -46,7 +44,7 @@ var createStore = function (reducer) {
46
44
  if (!reducer)
47
45
  return store;
48
46
  return (0, toolkit_1.configureStore)({
49
- 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, roomBuilder: roomBuilder_1.default }),
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 }),
50
48
  middleware: function (getDefaultMiddleware) {
51
49
  return constants_1.TREBLE_DEBUG
52
50
  ? getDefaultMiddleware().concat(redux_logger_1.default)
@@ -186,8 +186,9 @@ var initPlayer = function (config) {
186
186
  orgId = player.enableApi(types_1.PRIVATE_APIS.PLAYER).orgId;
187
187
  connection_1.default.connect({ orgId: orgId });
188
188
  cacheParameters = player.cacheParameters;
189
- if (cacheParameters)
189
+ if (cacheParameters) {
190
190
  connection_1.default.connect({ cacheParameters: cacheParameters });
191
+ }
191
192
  if (window.threekit) {
192
193
  window.threekit = Object.assign(window.threekit, {
193
194
  player: player,
@@ -230,20 +231,14 @@ var initPlayer = function (config) {
230
231
  if (window.threekit.treble._debugMode)
231
232
  (0, utils_1.runDebugger)();
232
233
  window.threekit.player.on('setConfiguration', function () { return __awaiter(void 0, void 0, void 0, function () {
233
- var state, previousAttributes, attributes, configuration, updatedAttributes;
234
+ var attributes, previousAttributes, updatedAttributes;
234
235
  var _a;
235
236
  return __generator(this, function (_b) {
236
237
  switch (_b.label) {
237
238
  case 0:
238
- state = getState();
239
- previousAttributes = Object.values(state.attributes);
240
- attributes = window.threekit.configurator.getDisplayAttributes();
241
- configuration = window.threekit.configurator.getFullConfiguration();
242
- updatedAttributes = attributes.map(function (attr) {
243
- return Object.assign({}, attr, configuration[attr.name]
244
- ? { value: configuration[attr.name] }
245
- : undefined);
246
- });
239
+ attributes = getState().attributes;
240
+ previousAttributes = Object.values(attributes);
241
+ updatedAttributes = window.threekit.configurator.getDisplayAttributes();
247
242
  dispatch((0, attributes_1.setAttributes)(updatedAttributes));
248
243
  return [4, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
249
244
  case 1:
package/dist/types.d.ts CHANGED
@@ -280,10 +280,6 @@ export interface IThreekitConfigurator {
280
280
  setConfiguration: (configuration: ISetConfiguration | IConfiguration) => Promise<IConfiguration>;
281
281
  getPrice: (pricebookId: string, currency: string) => number;
282
282
  getDisplayAttributes: (config?: IDisplayAttributeConfig) => Array<IThreekitDisplayAttribute>;
283
- getNestedConfigurator: (path: string | Array<string | number>) => IThreekitConfigurator | undefined;
284
- getFullConfiguration: () => IConfiguration;
285
- setFullConfiguration: (configuration: IConfiguration) => void;
286
- on: (eventName: string, callback: () => void) => void;
287
283
  }
288
284
  export interface IThreekitScene {
289
285
  PHASES: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.89-next-006",
3
+ "version": "0.0.90",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ICoordinate2D } from './types';
3
- interface IRoomBuilderLayout {
4
- loops?: Array<ICoordinate2D[]>;
5
- size?: number;
6
- }
7
- export default function RoomBuilderLayout(props: IRoomBuilderLayout): JSX.Element;
8
- export {};
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
7
- function RoomBuilderLayout(props) {
8
- var loops = props.loops;
9
- var size = props.size || 20;
10
- if (!(loops === null || loops === void 0 ? void 0 : loops.length))
11
- return react_1.default.createElement(react_1.default.Fragment, null);
12
- var paths = loops.map(function (loop) {
13
- return loop
14
- .map(function (_a, i) {
15
- var x = _a[0], y = _a[1];
16
- return (i === 0 ? 'M ' : 'L ') + x + ' ' + y;
17
- })
18
- .join(' ') + ' Z';
19
- });
20
- return (react_1.default.createElement("svg", { width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: "none", xmlns: "http://www.w3.org/2000/svg" }, paths.map(function (path, i) { return (react_1.default.createElement("path", { key: "path-".concat(i), d: path, stroke: "white", strokeWidth: 1 })); })));
21
- }
22
- exports.default = RoomBuilderLayout;
@@ -1,3 +0,0 @@
1
- import { IIcon } from './types';
2
- export declare const Player3D: IIcon;
3
- export default Player3D;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Player3D = void 0;
11
- var react_1 = __importDefault(require("react"));
12
- var styled_components_1 = __importDefault(require("styled-components"));
13
- var SVG = styled_components_1.default.svg(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .tk-icon {\n fill: ", ";\n }\n"], ["\n .tk-icon {\n fill: ", ";\n }\n"])), function (props) { return props.color || props.theme.textColor; });
14
- var Player3D = function (props) {
15
- return (react_1.default.createElement(SVG, { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", color: props.color },
16
- react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.1678 1.05955L10.0003 1L9.83285 1.05955L3.5161 3.30527L3.18359 3.42348V3.77638V11.6364V11.9893L3.5161 12.1075L9.83285 14.3533L10.0003 14.4128L10.1678 14.3533L16.4845 12.1075L16.817 11.9893V11.6364V3.77638V3.42348L16.4845 3.30527L10.1678 1.05955ZM9.50034 6.375L4.18359 4.4848V11.2835L9.50034 13.1738V6.375ZM15.817 11.2835L10.5003 13.1737V6.375L15.817 4.4848V11.2835ZM14.8244 3.77638L10.0003 5.49144L5.17622 3.77638L10.0003 2.06132L14.8244 3.77638ZM2.21438 8.32289C0.919876 9.24063 0 10.4827 0 11.9723C0 13.8117 1.40245 15.2735 3.1809 16.2135C4.71477 17.0242 6.6857 17.5461 8.83542 17.6854L8.17982 18.126C7.95064 18.28 7.88972 18.5907 8.04376 18.8199C8.1978 19.0491 8.50847 19.11 8.73766 18.956L10.7929 17.5746L11.4103 17.1596L10.7929 16.7447L10.5744 16.5978V16.579L10.5477 16.5799L8.73767 15.3632C8.50849 15.2091 8.19782 15.2701 8.04377 15.4992C7.88972 15.7284 7.95063 16.0391 8.17981 16.1931L8.69201 16.5374C4.48846 16.2038 1.26536 14.287 1.26536 11.9723C1.26536 11.2181 1.60756 10.5062 2.21438 9.87745V8.32289ZM18.3477 10.6094C18.5992 11.0402 18.7346 11.4979 18.7346 11.9723C18.7346 13.9903 16.2848 15.7059 12.8714 16.3336V17.489C14.3526 17.2412 15.7018 16.804 16.8191 16.2135C18.5975 15.2735 20 13.8117 20 11.9723C20 10.709 19.3383 9.6237 18.3477 8.76332V10.6094Z", className: "tk-icon" })));
17
- };
18
- exports.Player3D = Player3D;
19
- exports.Player3D.iconName = 'player-3d';
20
- exports.default = exports.Player3D;
21
- var templateObject_1;
@@ -1,38 +0,0 @@
1
- import { RootState, ThreekitDispatch } from './index';
2
- import { IConfiguration } from '../types';
3
- import { ICoordinate2D, IModes } from '../hooks/useRoomBuilder/types';
4
- interface ILayout {
5
- label: string;
6
- configuration: IConfiguration;
7
- loop: Array<ICoordinate2D[]>;
8
- }
9
- interface IAttributeMap {
10
- walls: string;
11
- startX: string;
12
- startZ: string;
13
- endX: string;
14
- endZ: string;
15
- }
16
- export interface RoomBuilderState {
17
- mode: IModes;
18
- layouts: Array<ILayout>;
19
- zoom: null | number;
20
- translation: null | ICoordinate2D;
21
- showDimensions: boolean;
22
- angleSnappingEnabled: boolean;
23
- }
24
- export declare const setLayouts: import("@reduxjs/toolkit").ActionCreatorWithPayload<ILayout[], string>;
25
- export declare const setZoom: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
26
- export declare const setTranslation: import("@reduxjs/toolkit").ActionCreatorWithPayload<ICoordinate2D, string>;
27
- export declare const setMode: import("@reduxjs/toolkit").ActionCreatorWithPayload<IModes, string>;
28
- export declare const setShowDimensions: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
29
- export declare const setAngleSnappingEnabled: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
30
- declare const reducer: import("redux").Reducer<RoomBuilderState, import("redux").AnyAction>;
31
- export declare const getMode: (state: RootState) => IModes;
32
- export declare const getLayouts: (state: RootState) => Array<ILayout>;
33
- export declare const getZoom: (state: RootState) => number | null;
34
- export declare const getTranslation: (state: RootState) => ICoordinate2D | null;
35
- export declare const getShowDimensions: (state: RootState) => boolean;
36
- export declare const getAngleSnappingEnabled: (state: RootState) => boolean;
37
- export declare const hydrateLayouts: (configurationIds: Array<string>, attributeMap: IAttributeMap) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
38
- export default reducer;
@@ -1,174 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
57
- };
58
- var __importDefault = (this && this.__importDefault) || function (mod) {
59
- return (mod && mod.__esModule) ? mod : { "default": mod };
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.hydrateLayouts = exports.getAngleSnappingEnabled = exports.getShowDimensions = exports.getTranslation = exports.getZoom = exports.getLayouts = exports.getMode = exports.setAngleSnappingEnabled = exports.setShowDimensions = exports.setMode = exports.setTranslation = exports.setZoom = exports.setLayouts = void 0;
63
- var toolkit_1 = require("@reduxjs/toolkit");
64
- var api_1 = __importDefault(require("../api"));
65
- var types_1 = require("../hooks/useRoomBuilder/types");
66
- var findLoops_1 = require("../hooks/useRoomBuilder/findLoops");
67
- exports.setLayouts = (0, toolkit_1.createAction)('treble/roomb-builder/set-layouts');
68
- exports.setZoom = (0, toolkit_1.createAction)('treble/roomb-builder/set-zoom');
69
- exports.setTranslation = (0, toolkit_1.createAction)('treble/roomb-builder/set-translation');
70
- exports.setMode = (0, toolkit_1.createAction)('treble/roomb-builder/set-mode');
71
- exports.setShowDimensions = (0, toolkit_1.createAction)('treble/roomb-builder/set-show-dimensions');
72
- exports.setAngleSnappingEnabled = (0, toolkit_1.createAction)('treble/roomb-builder/set-angle-snapping-enabled');
73
- var initialState = {
74
- mode: types_1.IModes.SELECT,
75
- layouts: [],
76
- zoom: null,
77
- translation: null,
78
- showDimensions: true,
79
- angleSnappingEnabled: true,
80
- };
81
- var reducer = (0, toolkit_1.createSlice)({
82
- name: 'room-builder',
83
- initialState: initialState,
84
- extraReducers: function (builder) {
85
- builder.addCase(exports.setMode, function (state, action) {
86
- return __assign(__assign({}, state), { mode: action.payload });
87
- });
88
- builder.addCase(exports.setLayouts, function (state, action) {
89
- return __assign(__assign({}, state), { layouts: action.payload });
90
- });
91
- builder.addCase(exports.setZoom, function (state, action) {
92
- return __assign(__assign({}, state), { zoom: action.payload });
93
- });
94
- builder.addCase(exports.setTranslation, function (state, action) {
95
- return __assign(__assign({}, state), { translation: action.payload });
96
- });
97
- builder.addCase(exports.setShowDimensions, function (state, action) {
98
- return __assign(__assign({}, state), { showDimensions: action.payload });
99
- });
100
- builder.addCase(exports.setAngleSnappingEnabled, function (state, action) {
101
- return __assign(__assign({}, state), { angleSnappingEnabled: action.payload });
102
- });
103
- },
104
- reducers: {},
105
- }).reducer;
106
- var getMode = function (state) { return state.roomBuilder.mode; };
107
- exports.getMode = getMode;
108
- var getLayouts = function (state) {
109
- return state.roomBuilder.layouts;
110
- };
111
- exports.getLayouts = getLayouts;
112
- var getZoom = function (state) { return state.roomBuilder.zoom; };
113
- exports.getZoom = getZoom;
114
- var getTranslation = function (state) {
115
- return state.roomBuilder.translation;
116
- };
117
- exports.getTranslation = getTranslation;
118
- var getShowDimensions = function (state) {
119
- return state.roomBuilder.showDimensions;
120
- };
121
- exports.getShowDimensions = getShowDimensions;
122
- var getAngleSnappingEnabled = function (state) {
123
- return state.roomBuilder.angleSnappingEnabled;
124
- };
125
- exports.getAngleSnappingEnabled = getAngleSnappingEnabled;
126
- var hydrateLayouts = function (configurationIds, attributeMap) {
127
- return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
128
- var state, layoutIds, configurationResponses, prepped;
129
- var _a;
130
- return __generator(this, function (_b) {
131
- switch (_b.label) {
132
- case 0:
133
- state = getState();
134
- if (state.roomBuilder.layouts.length)
135
- return [2];
136
- layoutIds = __spreadArray([], configurationIds, true);
137
- if ((_a = state.product.metadata) === null || _a === void 0 ? void 0 : _a._layouts)
138
- state.product.metadata._layouts
139
- .split(',')
140
- .forEach(function (id) { return layoutIds.push(id.trim()); });
141
- return [4, Promise.all(layoutIds.map(function (configId) { return api_1.default.configurations.fetch(configId); }))];
142
- case 1:
143
- configurationResponses = _b.sent();
144
- prepped = configurationResponses.map(function (response) {
145
- var _a;
146
- var wallsAttribute = response.data.variant[attributeMap.walls];
147
- var walls = wallsAttribute.map(function (wallAttribute) {
148
- var wallConfig = wallAttribute.configuration;
149
- var wall = [
150
- [
151
- wallConfig[attributeMap.startX],
152
- wallConfig[attributeMap.startZ],
153
- ],
154
- [
155
- wallConfig[attributeMap.endX],
156
- wallConfig[attributeMap.endZ],
157
- ],
158
- ];
159
- return wall;
160
- });
161
- return {
162
- label: ((_a = response.data.metadata) === null || _a === void 0 ? void 0 : _a.label) || 'Layout',
163
- configuration: response.data.variant,
164
- loop: (0, findLoops_1.findLoops)(walls).inner,
165
- };
166
- });
167
- dispatch((0, exports.setLayouts)(prepped));
168
- return [2];
169
- }
170
- });
171
- }); };
172
- };
173
- exports.hydrateLayouts = hydrateLayouts;
174
- exports.default = reducer;