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

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 (159) hide show
  1. package/dist/Treble/Treble.d.ts +1 -1
  2. package/dist/Treble/Treble.js +3 -3
  3. package/dist/components/AttributeValue/index.js +2 -0
  4. package/dist/components/BreatheAnimation/index.js +2 -2
  5. package/dist/components/TurntableAnimation/index.js +2 -2
  6. package/dist/components/Wishlist/index.d.ts +1 -1
  7. package/dist/components/Zoom/index.d.ts +1 -1
  8. package/dist/components/containers/formInputContainer.d.ts +1 -1
  9. package/dist/components/containers/formInputContainer.js +3 -3
  10. package/dist/hooks/useConfigurationChangeStatus/index.d.ts +2 -0
  11. package/dist/hooks/{usePlayerLoadingStatus → useConfigurationChangeStatus}/index.js +2 -2
  12. package/dist/hooks/useNestedConfigurator/index.js +1 -2
  13. package/dist/hooks/usePlayerReady/index.d.ts +2 -0
  14. package/dist/hooks/{useAnimationStart → usePlayerReady}/index.js +2 -2
  15. package/dist/hooks/useRoomBuilder/RoomBuilderLayout.d.ts +8 -0
  16. package/dist/hooks/useRoomBuilder/RoomBuilderLayout.js +22 -0
  17. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +132 -0
  18. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1431 -0
  19. package/dist/hooks/useRoomBuilder/constants.d.ts +56 -0
  20. package/dist/hooks/useRoomBuilder/constants.js +63 -0
  21. package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +18 -0
  22. package/dist/hooks/useRoomBuilder/dataHandlers.js +187 -0
  23. package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
  24. package/dist/hooks/useRoomBuilder/draw.js +573 -0
  25. package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
  26. package/dist/hooks/useRoomBuilder/findLoops.js +99 -0
  27. package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
  28. package/dist/hooks/useRoomBuilder/geometry.js +325 -0
  29. package/dist/hooks/useRoomBuilder/index.d.ts +57 -0
  30. package/dist/hooks/useRoomBuilder/index.js +411 -0
  31. package/dist/hooks/useRoomBuilder/messaging.d.ts +8 -0
  32. package/dist/hooks/useRoomBuilder/messaging.js +18 -0
  33. package/dist/hooks/useRoomBuilder/themes.d.ts +12 -0
  34. package/dist/hooks/useRoomBuilder/themes.js +273 -0
  35. package/dist/hooks/useRoomBuilder/types.d.ts +247 -0
  36. package/dist/hooks/useRoomBuilder/types.js +40 -0
  37. package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
  38. package/dist/hooks/useRoomBuilder/validators.js +362 -0
  39. package/dist/icons/Add.d.ts +1 -1
  40. package/dist/icons/Add.js +3 -3
  41. package/dist/icons/Angle.d.ts +3 -0
  42. package/dist/icons/Angle.js +21 -0
  43. package/dist/icons/ArrowLeft.d.ts +1 -1
  44. package/dist/icons/ArrowLeft.js +3 -3
  45. package/dist/icons/ArrowRight.d.ts +1 -1
  46. package/dist/icons/ArrowRight.js +3 -3
  47. package/dist/icons/Camera.d.ts +1 -1
  48. package/dist/icons/Camera.js +3 -3
  49. package/dist/icons/CaretDown.d.ts +1 -1
  50. package/dist/icons/CaretDown.js +3 -3
  51. package/dist/icons/CaretLeft.d.ts +1 -1
  52. package/dist/icons/CaretLeft.js +3 -3
  53. package/dist/icons/CaretRight.d.ts +1 -1
  54. package/dist/icons/CaretRight.js +3 -3
  55. package/dist/icons/CaretUp.d.ts +1 -1
  56. package/dist/icons/CaretUp.js +3 -3
  57. package/dist/icons/Cart.d.ts +1 -1
  58. package/dist/icons/Cart.js +3 -3
  59. package/dist/icons/Checkmate.d.ts +1 -1
  60. package/dist/icons/Checkmate.js +3 -3
  61. package/dist/icons/Clipboard.d.ts +1 -1
  62. package/dist/icons/Clipboard.js +3 -3
  63. package/dist/icons/ColorPicker.d.ts +1 -1
  64. package/dist/icons/ColorPicker.js +3 -3
  65. package/dist/icons/Copy.d.ts +1 -1
  66. package/dist/icons/Copy.js +3 -3
  67. package/dist/icons/Cursor.d.ts +3 -0
  68. package/dist/icons/Cursor.js +21 -0
  69. package/dist/icons/Delete.d.ts +1 -1
  70. package/dist/icons/Delete.js +3 -3
  71. package/dist/icons/Door.d.ts +3 -0
  72. package/dist/icons/Door.js +22 -0
  73. package/dist/icons/DoubleCaretLeft.d.ts +1 -1
  74. package/dist/icons/DoubleCaretLeft.js +3 -3
  75. package/dist/icons/DoubleCaretRight.d.ts +1 -1
  76. package/dist/icons/DoubleCaretRight.js +3 -3
  77. package/dist/icons/Download.d.ts +1 -1
  78. package/dist/icons/Download.js +3 -3
  79. package/dist/icons/Drag.d.ts +1 -1
  80. package/dist/icons/Drag.js +3 -3
  81. package/dist/icons/Draggable.d.ts +1 -1
  82. package/dist/icons/Draggable.js +3 -3
  83. package/dist/icons/Draw.d.ts +3 -0
  84. package/dist/icons/Draw.js +21 -0
  85. package/dist/icons/Edit.d.ts +1 -1
  86. package/dist/icons/Edit.js +3 -3
  87. package/dist/icons/Heart.d.ts +1 -1
  88. package/dist/icons/Heart.js +3 -3
  89. package/dist/icons/Image.d.ts +1 -1
  90. package/dist/icons/Image.js +3 -3
  91. package/dist/icons/Info.d.ts +1 -1
  92. package/dist/icons/Info.js +3 -3
  93. package/dist/icons/Layout.d.ts +3 -0
  94. package/dist/icons/Layout.js +21 -0
  95. package/dist/icons/Mail.d.ts +1 -1
  96. package/dist/icons/Mail.js +3 -3
  97. package/dist/icons/Menu.d.ts +1 -1
  98. package/dist/icons/Menu.js +3 -3
  99. package/dist/icons/More.d.ts +1 -1
  100. package/dist/icons/More.js +3 -3
  101. package/dist/icons/NewWindow.d.ts +1 -1
  102. package/dist/icons/NewWindow.js +3 -3
  103. package/dist/icons/Opening.d.ts +3 -0
  104. package/dist/icons/Opening.js +21 -0
  105. package/dist/icons/Pause.d.ts +1 -1
  106. package/dist/icons/Pause.js +3 -3
  107. package/dist/icons/Play.d.ts +1 -1
  108. package/dist/icons/Play.js +3 -3
  109. package/dist/icons/Player3D.d.ts +3 -0
  110. package/dist/icons/Player3D.js +21 -0
  111. package/dist/icons/Redo.d.ts +1 -1
  112. package/dist/icons/Redo.js +3 -3
  113. package/dist/icons/Remove.d.ts +1 -1
  114. package/dist/icons/Remove.js +3 -3
  115. package/dist/icons/Ruler.d.ts +1 -1
  116. package/dist/icons/Ruler.js +3 -3
  117. package/dist/icons/Search.d.ts +1 -1
  118. package/dist/icons/Search.js +3 -3
  119. package/dist/icons/Settings.d.ts +1 -1
  120. package/dist/icons/Settings.js +3 -3
  121. package/dist/icons/Share.d.ts +1 -1
  122. package/dist/icons/Share.js +3 -3
  123. package/dist/icons/Switch.d.ts +1 -1
  124. package/dist/icons/Switch.js +3 -3
  125. package/dist/icons/Tag.d.ts +1 -1
  126. package/dist/icons/Tag.js +3 -3
  127. package/dist/icons/TrashCan.d.ts +3 -0
  128. package/dist/icons/TrashCan.js +21 -0
  129. package/dist/icons/TrashCanAlt.d.ts +3 -0
  130. package/dist/icons/TrashCanAlt.js +21 -0
  131. package/dist/icons/Undo.d.ts +1 -1
  132. package/dist/icons/Undo.js +3 -3
  133. package/dist/icons/Wall.d.ts +3 -0
  134. package/dist/icons/Wall.js +21 -0
  135. package/dist/icons/Window.d.ts +3 -0
  136. package/dist/icons/Window.js +22 -0
  137. package/dist/icons/Wishlist.d.ts +1 -1
  138. package/dist/icons/Wishlist.js +3 -3
  139. package/dist/icons/ZoomIn.d.ts +1 -1
  140. package/dist/icons/ZoomIn.js +3 -3
  141. package/dist/icons/ZoomOut.d.ts +1 -1
  142. package/dist/icons/ZoomOut.js +3 -3
  143. package/dist/icons/index.d.ts +2 -6
  144. package/dist/icons/index.js +22 -0
  145. package/dist/icons/types.d.ts +7 -0
  146. package/dist/icons/types.js +2 -0
  147. package/dist/index.d.ts +17 -2
  148. package/dist/index.js +35 -4
  149. package/dist/store/attributes.d.ts +1 -0
  150. package/dist/store/index.d.ts +39 -8
  151. package/dist/store/index.js +3 -1
  152. package/dist/store/roomBuilder.d.ts +38 -0
  153. package/dist/store/roomBuilder.js +174 -0
  154. package/dist/store/treble.js +12 -6
  155. package/dist/types.d.ts +46 -7
  156. package/dist/types.js +1 -0
  157. package/package.json +1 -1
  158. package/dist/hooks/useAnimationStart/index.d.ts +0 -2
  159. package/dist/hooks/usePlayerLoadingStatus/index.d.ts +0 -2
@@ -7,21 +7,32 @@ 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-thunk").ThunkMiddleware<{
10
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
11
+ }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux-thunk").ThunkMiddleware<{
11
12
  treble: import("./treble").TrebleState;
12
13
  product: import("./product").ProductState;
13
14
  attributes: import("./attributes").AttributesState;
14
15
  translations: import("./translations").TranslationsState;
15
16
  wishlist: import("../Treble").WishlistArray;
16
17
  price: import("./price").PriceState;
17
- }, import("redux").AnyAction, undefined>]> | import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
18
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
19
+ }, import("redux").AnyAction, null> | import("redux-thunk").ThunkMiddleware<{
18
20
  treble: import("./treble").TrebleState;
19
21
  product: import("./product").ProductState;
20
22
  attributes: import("./attributes").AttributesState;
21
23
  translations: import("./translations").TranslationsState;
22
24
  wishlist: import("../Treble").WishlistArray;
23
25
  price: import("./price").PriceState;
24
- }, import("redux").AnyAction, undefined>, import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>>]>>;
26
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
27
+ }, import("redux").AnyAction, undefined> | import("redux").Middleware<{}, {
28
+ treble: import("./treble").TrebleState;
29
+ product: import("./product").ProductState;
30
+ attributes: import("./attributes").AttributesState;
31
+ translations: import("./translations").TranslationsState;
32
+ wishlist: import("../Treble").WishlistArray;
33
+ price: import("./price").PriceState;
34
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
35
+ }, import("redux").Dispatch<import("redux").AnyAction>>>>;
25
36
  export declare const createStore: (reducer?: Record<string, Reducer>) => import("@reduxjs/toolkit").EnhancedStore<{
26
37
  treble: import("./treble").TrebleState;
27
38
  product: import("./product").ProductState;
@@ -29,30 +40,50 @@ export declare const createStore: (reducer?: Record<string, Reducer>) => import(
29
40
  translations: import("./translations").TranslationsState;
30
41
  wishlist: import("../Treble").WishlistArray;
31
42
  price: import("./price").PriceState;
32
- }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
43
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
44
+ }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux-thunk").ThunkMiddleware<{
45
+ treble: import("./treble").TrebleState;
46
+ product: import("./product").ProductState;
47
+ attributes: import("./attributes").AttributesState;
48
+ translations: import("./translations").TranslationsState;
49
+ wishlist: import("../Treble").WishlistArray;
50
+ price: import("./price").PriceState;
51
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
52
+ }, import("redux").AnyAction, null> | import("redux-thunk").ThunkMiddleware<{
33
53
  treble: import("./treble").TrebleState;
34
54
  product: import("./product").ProductState;
35
55
  attributes: import("./attributes").AttributesState;
36
56
  translations: import("./translations").TranslationsState;
37
57
  wishlist: import("../Treble").WishlistArray;
38
58
  price: import("./price").PriceState;
39
- }, import("redux").AnyAction, undefined>]> | import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
59
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
60
+ }, import("redux").AnyAction, undefined> | import("redux").Middleware<{}, {
40
61
  treble: import("./treble").TrebleState;
41
62
  product: import("./product").ProductState;
42
63
  attributes: import("./attributes").AttributesState;
43
64
  translations: import("./translations").TranslationsState;
44
65
  wishlist: import("../Treble").WishlistArray;
45
66
  price: import("./price").PriceState;
46
- }, import("redux").AnyAction, undefined>, import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>>]>>;
67
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
68
+ }, import("redux").Dispatch<import("redux").AnyAction>>>>;
47
69
  export declare type RootState = ReturnType<typeof store.getState>;
48
70
  export declare type ThreekitDispatch = typeof store.dispatch;
49
- export declare const useThreekitDispatch: () => import("@reduxjs/toolkit").ThunkDispatch<{
71
+ export declare const useThreekitDispatch: () => import("redux").Dispatch<import("redux").AnyAction> & import("@reduxjs/toolkit").ThunkDispatch<{
72
+ treble: import("./treble").TrebleState;
73
+ product: import("./product").ProductState;
74
+ attributes: import("./attributes").AttributesState;
75
+ translations: import("./translations").TranslationsState;
76
+ wishlist: import("../Treble").WishlistArray;
77
+ price: import("./price").PriceState;
78
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
79
+ }, null, import("redux").AnyAction> & import("@reduxjs/toolkit").ThunkDispatch<{
50
80
  treble: import("./treble").TrebleState;
51
81
  product: import("./product").ProductState;
52
82
  attributes: import("./attributes").AttributesState;
53
83
  translations: import("./translations").TranslationsState;
54
84
  wishlist: import("../Treble").WishlistArray;
55
85
  price: import("./price").PriceState;
56
- }, undefined, import("redux").AnyAction> & import("redux").Dispatch<import("redux").AnyAction>;
86
+ roomBuilder: import("./roomBuilder").RoomBuilderState;
87
+ }, undefined, import("redux").AnyAction>;
57
88
  export declare const useThreekitSelector: TypedUseSelectorHook<RootState>;
58
89
  export default createStore;
@@ -25,6 +25,7 @@ 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"));
28
29
  var store = (0, toolkit_1.configureStore)({
29
30
  reducer: {
30
31
  treble: treble_1.default,
@@ -33,6 +34,7 @@ var store = (0, toolkit_1.configureStore)({
33
34
  translations: translations_1.default,
34
35
  wishlist: wishlist_1.default,
35
36
  price: price_1.default,
37
+ roomBuilder: roomBuilder_1.default,
36
38
  },
37
39
  middleware: function (getDefaultMiddleware) {
38
40
  return constants_1.TREBLE_DEBUG
@@ -44,7 +46,7 @@ var createStore = function (reducer) {
44
46
  if (!reducer)
45
47
  return store;
46
48
  return (0, toolkit_1.configureStore)({
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 }),
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 }),
48
50
  middleware: function (getDefaultMiddleware) {
49
51
  return constants_1.TREBLE_DEBUG
50
52
  ? getDefaultMiddleware().concat(redux_logger_1.default)
@@ -0,0 +1,38 @@
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;
@@ -0,0 +1,174 @@
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;
@@ -186,9 +186,8 @@ 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
- }
192
191
  if (window.threekit) {
193
192
  window.threekit = Object.assign(window.threekit, {
194
193
  player: player,
@@ -231,14 +230,20 @@ var initPlayer = function (config) {
231
230
  if (window.threekit.treble._debugMode)
232
231
  (0, utils_1.runDebugger)();
233
232
  window.threekit.player.on('setConfiguration', function () { return __awaiter(void 0, void 0, void 0, function () {
234
- var attributes, previousAttributes, updatedAttributes;
233
+ var state, previousAttributes, attributes, configuration, updatedAttributes;
235
234
  var _a;
236
235
  return __generator(this, function (_b) {
237
236
  switch (_b.label) {
238
237
  case 0:
239
- attributes = getState().attributes;
240
- previousAttributes = Object.values(attributes);
241
- updatedAttributes = window.threekit.configurator.getDisplayAttributes();
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
+ });
242
247
  dispatch((0, attributes_1.setAttributes)(updatedAttributes));
243
248
  return [4, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
244
249
  case 1:
@@ -289,6 +294,7 @@ var launch = function (launchConfig) {
289
294
  }
290
295
  else {
291
296
  stageId = conf.stageId;
297
+ initialConfiguration = conf.initialConfiguration;
292
298
  if (conf.configurationId)
293
299
  configurationId = conf.configurationId;
294
300
  else if ((0, utils_1.isUuid)(conf.assetId))
package/dist/types.d.ts CHANGED
@@ -19,7 +19,8 @@ export declare enum ATTRIBUTE_TYPES {
19
19
  ASSET = "Asset",
20
20
  COLOR = "Color",
21
21
  NUMBER = "Number",
22
- BOOLEAN = "Boolean"
22
+ BOOLEAN = "Boolean",
23
+ ARRAY = "Array"
23
24
  }
24
25
  export declare enum ASSET_TYPES {
25
26
  UPLOAD = "upload",
@@ -86,15 +87,17 @@ export interface ISceneResult {
86
87
  }
87
88
  export interface IConfigurationAsset {
88
89
  assetId: string;
89
- configuration?: string;
90
+ configuration?: string | IConfiguration;
90
91
  type?: string;
91
92
  }
93
+ export interface IConfigurationArray extends Array<IConfigurationAsset> {
94
+ }
92
95
  export interface IConfigurationColor {
93
96
  r: number;
94
97
  g: number;
95
98
  b: number;
96
99
  }
97
- export declare type IConfigurationAttribute = IConfigurationAsset | IConfigurationColor | string | number | boolean | undefined;
100
+ export declare type IConfigurationAttribute = IConfigurationAsset | IConfigurationArray | IConfigurationColor | string | number | boolean | undefined;
98
101
  export declare type IConfiguration = Record<string, IConfigurationAttribute>;
99
102
  export declare type ISetConfiguration = Record<string, IConfigurationAttribute>;
100
103
  interface IDisplayAttributeConfig {
@@ -126,7 +129,7 @@ export interface IHydratedAttributeAssetValue extends IDisplayAttributeAssetValu
126
129
  }
127
130
  export interface IAttributeAssetBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.ASSET, IConfigurationAsset> {
128
131
  assetType: ASSET_TYPES;
129
- blacklist: [];
132
+ blacklist: Array<string>;
130
133
  defaultValue: IConfigurationAsset;
131
134
  hiddenValues?: Array<string>;
132
135
  disabledValues?: Array<string>;
@@ -135,6 +138,38 @@ export interface IAttributeAssetBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.A
135
138
  export declare type IDisplayAttributeAsset = IAttributeAssetBase<IDisplayAttributeAssetValue>;
136
139
  export declare type IHydratedAttributeAsset = IAttributeAssetBase<IHydratedAttributeAssetValue>;
137
140
  export declare type IAttributeAsset = IAttributeAssetBase<IConfigurationAssetValue>;
141
+ export interface IConfigurationArrayValue {
142
+ assetId: string;
143
+ name: string;
144
+ configuration?: Record<string, IThreekitDisplayAttribute>;
145
+ }
146
+ export interface IDisplayAttributeArrayValue extends IConfigurationArrayValue {
147
+ name: string;
148
+ type: string;
149
+ enabled: boolean;
150
+ visible: boolean;
151
+ metadata: IMetadata;
152
+ tags: Array<string>;
153
+ label: string;
154
+ }
155
+ export interface IHydratedAttributeArrayValue extends IDisplayAttributeArrayValue {
156
+ label: string;
157
+ handleSelect: () => Promise<void>;
158
+ selected: boolean;
159
+ }
160
+ export interface IAttributeArrayBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.ARRAY, IConfigurationArray> {
161
+ blacklist: Array<string>;
162
+ hiddenValues?: Array<string>;
163
+ disabledValues?: Array<string>;
164
+ values: Array<V>;
165
+ of: {
166
+ type: ATTRIBUTE_TYPES.ASSET;
167
+ assetType: ASSET_TYPES;
168
+ };
169
+ }
170
+ export declare type IDisplayAttributeArray = IAttributeArrayBase<IDisplayAttributeArrayValue>;
171
+ export declare type IHydratedAttributeArray = IAttributeArrayBase<IHydratedAttributeArrayValue>;
172
+ export declare type IAttributeArray = IAttributeArrayBase<Pick<IConfigurationArrayValue, 'assetId'>>;
138
173
  export interface IDisplayAttributeStringValue {
139
174
  label: string;
140
175
  value: string;
@@ -166,9 +201,9 @@ export interface IAttributeNumber extends IAttributeBase<ATTRIBUTE_TYPES.NUMBER,
166
201
  export interface IAttributeBoolean extends IAttributeBase<ATTRIBUTE_TYPES.BOOLEAN, boolean> {
167
202
  defaultValue: boolean;
168
203
  }
169
- export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber | IAttributeBoolean;
170
- export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
171
- export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
204
+ export declare type IThreekitAttribute = IAttributeAsset | IAttributeArray | IAttributeColor | IAttributeString | IAttributeNumber | IAttributeBoolean;
205
+ export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeArray | IDisplayAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
206
+ export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeArray | IHydratedAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
172
207
  export interface ICoordinates {
173
208
  x: number;
174
209
  y: number;
@@ -245,6 +280,10 @@ export interface IThreekitConfigurator {
245
280
  setConfiguration: (configuration: ISetConfiguration | IConfiguration) => Promise<IConfiguration>;
246
281
  getPrice: (pricebookId: string, currency: string) => number;
247
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;
248
287
  }
249
288
  export interface IThreekitScene {
250
289
  PHASES: {
package/dist/types.js CHANGED
@@ -24,6 +24,7 @@ var ATTRIBUTE_TYPES;
24
24
  ATTRIBUTE_TYPES["COLOR"] = "Color";
25
25
  ATTRIBUTE_TYPES["NUMBER"] = "Number";
26
26
  ATTRIBUTE_TYPES["BOOLEAN"] = "Boolean";
27
+ ATTRIBUTE_TYPES["ARRAY"] = "Array";
27
28
  })(ATTRIBUTE_TYPES = exports.ATTRIBUTE_TYPES || (exports.ATTRIBUTE_TYPES = {}));
28
29
  var ASSET_TYPES;
29
30
  (function (ASSET_TYPES) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.89",
3
+ "version": "0.0.90-next-01",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1,2 +0,0 @@
1
- declare const useAnimationStart: () => boolean;
2
- export default useAnimationStart;
@@ -1,2 +0,0 @@
1
- declare const usePlayerLoadingStatus: () => boolean;
2
- export default usePlayerLoadingStatus;