@threekit-tools/treble 0.0.91 → 0.0.92-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.
- package/dist/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +2 -2
- package/dist/Treble/index.d.ts +1 -1
- package/dist/Treble/index.js +1 -1
- package/dist/components/ThreekitProvider/index.js +3 -2
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +16 -53
- package/dist/hooks/useAttribute/index.js +1 -5
- package/dist/hooks/useNestedConfigurator/index.js +1 -2
- package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
- package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
- package/dist/hooks/useSpaces/SpacesState.d.ts +177 -0
- package/dist/hooks/useSpaces/SpacesState.js +1814 -0
- package/dist/hooks/useSpaces/constants.d.ts +79 -0
- package/dist/hooks/useSpaces/constants.js +130 -0
- package/dist/hooks/useSpaces/dataHandlers.d.ts +38 -0
- package/dist/hooks/useSpaces/dataHandlers.js +407 -0
- package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
- package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
- package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
- package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
- package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
- package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawDoors.js +99 -0
- package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
- package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawGrid.js +36 -0
- package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
- package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
- package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
- package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
- package/dist/hooks/useSpaces/draw/drawWalls.d.ts +11 -0
- package/dist/hooks/useSpaces/draw/drawWalls.js +90 -0
- package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
- package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
- package/dist/hooks/useSpaces/draw/index.js +129 -0
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
- package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
- package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
- package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
- package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
- package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
- package/dist/hooks/{useRoomBuilder → useSpaces/geometry}/findLoops.js +31 -13
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
- package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
- package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
- package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
- package/dist/hooks/useSpaces/geometry/index.js +64 -0
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
- package/dist/hooks/useSpaces/index.d.ts +95 -0
- package/dist/hooks/useSpaces/index.js +557 -0
- package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
- package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/default.js +96 -0
- package/dist/hooks/{useRoomBuilder/themes.d.ts → useSpaces/themes/index.d.ts} +3 -4
- package/dist/hooks/useSpaces/themes/index.js +21 -0
- package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/light.js +96 -0
- package/dist/hooks/useSpaces/types.d.ts +378 -0
- package/dist/hooks/{useRoomBuilder → useSpaces}/types.js +19 -1
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
- package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
- package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
- package/dist/hooks/useSpaces/validators/index.js +40 -0
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
- package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
- package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
- package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.js +1 -1
- package/dist/icons/Boundary.d.ts +3 -0
- package/dist/icons/Boundary.js +21 -0
- package/dist/icons/Draw.js +3 -3
- package/dist/icons/Player3D.d.ts +3 -0
- package/dist/icons/Player3D.js +21 -0
- package/dist/icons/RulerBlank.d.ts +3 -0
- package/dist/icons/RulerBlank.js +25 -0
- package/dist/icons/RulerDetailed.d.ts +3 -0
- package/dist/icons/RulerDetailed.js +27 -0
- package/dist/icons/Window.js +4 -4
- package/dist/icons/index.js +28 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.js +35 -5
- package/dist/store/attributes.d.ts +2 -1
- package/dist/store/index.d.ts +17 -31
- package/dist/store/index.js +3 -1
- package/dist/store/product.js +4 -7
- package/dist/store/spaces.d.ts +74 -0
- package/dist/store/spaces.js +354 -0
- package/dist/store/treble.d.ts +4 -2
- package/dist/store/treble.js +58 -50
- package/dist/store/wishlist.d.ts +20 -2
- package/dist/types.d.ts +14 -3
- package/package.json +2 -1
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
- package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
- package/dist/hooks/useRoomBuilder/constants.js +0 -48
- package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +0 -18
- package/dist/hooks/useRoomBuilder/dataHandlers.js +0 -187
- package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
- package/dist/hooks/useRoomBuilder/draw.js +0 -573
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
- package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
- package/dist/hooks/useRoomBuilder/geometry.js +0 -325
- package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
- package/dist/hooks/useRoomBuilder/index.js +0 -303
- package/dist/hooks/useRoomBuilder/themes.js +0 -273
- package/dist/hooks/useRoomBuilder/types.d.ts +0 -238
- package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
- package/dist/hooks/useRoomBuilder/validators.js +0 -362
- package/dist/hooks/useSpaces/Canvas.d.ts +0 -37
- package/dist/hooks/useSpaces/Canvas.js +0 -199
- /package/dist/Treble/{snapshots.d.ts → snapshot.d.ts} +0 -0
- /package/dist/Treble/{snapshots.js → snapshot.js} +0 -0
- /package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.d.ts +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (_) try {
|
|
52
|
+
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;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
|
+
if (ar || !(i in from)) {
|
|
75
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
76
|
+
ar[i] = from[i];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
80
|
+
};
|
|
81
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
82
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
|
+
};
|
|
84
|
+
var _a;
|
|
85
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
86
|
+
exports.initSpaces = exports.hydrateLayouts = exports.getWallMode = exports.getDefaults = exports.getGridSnappingEnabled = exports.getGuideSnappingEnabled = exports.getAngleSnappingEnabled = exports.getShowDimensions = exports.getTranslation = exports.getZoom = exports.getUnit = exports.getLayouts = exports.getMode = exports.getInitialized = exports.setWallModeValue = exports.setWallModeAssetIds = exports.setWallModeOptions = exports.setDefaults = exports.setGridSnappingEnabled = exports.setGuideSnappingEnabled = exports.setAngleSnappingEnabled = exports.setShowDimensions = exports.setMode = exports.setTranslation = exports.setUnit = exports.setZoom = exports.setLayouts = exports.setInitialized = void 0;
|
|
87
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
88
|
+
var api_1 = __importDefault(require("../api"));
|
|
89
|
+
var types_1 = require("../hooks/useSpaces/types");
|
|
90
|
+
var geometry_1 = require("../hooks/useSpaces/geometry");
|
|
91
|
+
var constants_1 = require("../hooks/useSpaces/constants");
|
|
92
|
+
var SpacesState_1 = __importDefault(require("../hooks/useSpaces/SpacesState"));
|
|
93
|
+
var attributes_1 = require("./attributes");
|
|
94
|
+
var themes_1 = __importStar(require("../hooks/useSpaces/themes"));
|
|
95
|
+
var dataHandlers_1 = require("../hooks/useSpaces/dataHandlers");
|
|
96
|
+
exports.setInitialized = (0, toolkit_1.createAction)('treble/spaces/set-initialized');
|
|
97
|
+
exports.setLayouts = (0, toolkit_1.createAction)('treble/spaces/set-layouts');
|
|
98
|
+
exports.setZoom = (0, toolkit_1.createAction)('treble/spaces/set-zoom');
|
|
99
|
+
exports.setUnit = (0, toolkit_1.createAction)('treble/spaces/set-unit');
|
|
100
|
+
exports.setTranslation = (0, toolkit_1.createAction)('treble/spaces/set-translation');
|
|
101
|
+
exports.setMode = (0, toolkit_1.createAction)('treble/spaces/set-mode');
|
|
102
|
+
exports.setShowDimensions = (0, toolkit_1.createAction)('treble/spaces/set-show-dimensions');
|
|
103
|
+
exports.setAngleSnappingEnabled = (0, toolkit_1.createAction)('treble/spaces/set-angle-snapping-enabled');
|
|
104
|
+
exports.setGuideSnappingEnabled = (0, toolkit_1.createAction)('treble/spaces/set-guide-snapping-enabled');
|
|
105
|
+
exports.setGridSnappingEnabled = (0, toolkit_1.createAction)('treble/spaces/set-grid-snapping-enabled');
|
|
106
|
+
exports.setDefaults = (0, toolkit_1.createAction)('treble/spaces/set-defaults');
|
|
107
|
+
exports.setWallModeOptions = (0, toolkit_1.createAction)('treble/spaces/set-wall-mode-options');
|
|
108
|
+
exports.setWallModeAssetIds = (0, toolkit_1.createAction)('treble/spaces/set-wall-mode-assetIds');
|
|
109
|
+
exports.setWallModeValue = (0, toolkit_1.createAction)('treble/spaces/set-wall-mode-value');
|
|
110
|
+
var initialState = {
|
|
111
|
+
initialized: false,
|
|
112
|
+
mode: types_1.IModes.SELECT,
|
|
113
|
+
layouts: [],
|
|
114
|
+
unit: types_1.IUnits.FEET,
|
|
115
|
+
zoom: constants_1.ZOOM_DEFAULT,
|
|
116
|
+
translation: constants_1.TRANSLATE_DEFAULT,
|
|
117
|
+
showDimensions: types_1.IDimensionOptions.DEFAULT,
|
|
118
|
+
angleSnappingEnabled: constants_1.ANGLE_SNAPPING_ENABLED,
|
|
119
|
+
guideSnappingEnabled: constants_1.GUIDE_SNAPPING_ENABLED,
|
|
120
|
+
gridSnappingEnabled: constants_1.GRID_SNAPPING_ENABLED,
|
|
121
|
+
defaults: {
|
|
122
|
+
walls: '',
|
|
123
|
+
windows: '',
|
|
124
|
+
openings: '',
|
|
125
|
+
doors: '',
|
|
126
|
+
doorOpeningDirection: constants_1.DoorOpeningDirections.INSIDE,
|
|
127
|
+
doorOrientation: constants_1.DoorOrientations.LEFT,
|
|
128
|
+
doorShowSwing: constants_1.DoorShowSwing.HIDE,
|
|
129
|
+
},
|
|
130
|
+
wallModeOptions: [],
|
|
131
|
+
wallModeAssetIds: (_a = {},
|
|
132
|
+
_a[constants_1.WallModes.WALL] = '',
|
|
133
|
+
_a[constants_1.WallModes.BOUNDARY] = '',
|
|
134
|
+
_a),
|
|
135
|
+
wallModeValue: constants_1.WallModes.WALL,
|
|
136
|
+
};
|
|
137
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
138
|
+
name: 'spaces',
|
|
139
|
+
initialState: initialState,
|
|
140
|
+
extraReducers: function (builder) {
|
|
141
|
+
builder.addCase(exports.setInitialized, function (state, action) {
|
|
142
|
+
return __assign(__assign({}, state), { initialized: action.payload });
|
|
143
|
+
});
|
|
144
|
+
builder.addCase(exports.setMode, function (state, action) {
|
|
145
|
+
return __assign(__assign({}, state), { mode: action.payload });
|
|
146
|
+
});
|
|
147
|
+
builder.addCase(exports.setLayouts, function (state, action) {
|
|
148
|
+
return __assign(__assign({}, state), { layouts: action.payload });
|
|
149
|
+
});
|
|
150
|
+
builder.addCase(exports.setUnit, function (state, action) {
|
|
151
|
+
return __assign(__assign({}, state), { unit: action.payload });
|
|
152
|
+
});
|
|
153
|
+
builder.addCase(exports.setZoom, function (state, action) {
|
|
154
|
+
return __assign(__assign({}, state), { zoom: action.payload });
|
|
155
|
+
});
|
|
156
|
+
builder.addCase(exports.setTranslation, function (state, action) {
|
|
157
|
+
return __assign(__assign({}, state), { translation: action.payload });
|
|
158
|
+
});
|
|
159
|
+
builder.addCase(exports.setShowDimensions, function (state, action) {
|
|
160
|
+
return __assign(__assign({}, state), { showDimensions: action.payload });
|
|
161
|
+
});
|
|
162
|
+
builder.addCase(exports.setAngleSnappingEnabled, function (state, action) {
|
|
163
|
+
return __assign(__assign({}, state), { angleSnappingEnabled: action.payload });
|
|
164
|
+
});
|
|
165
|
+
builder.addCase(exports.setGuideSnappingEnabled, function (state, action) {
|
|
166
|
+
return __assign(__assign({}, state), { guideSnappingEnabled: action.payload });
|
|
167
|
+
});
|
|
168
|
+
builder.addCase(exports.setGridSnappingEnabled, function (state, action) {
|
|
169
|
+
return __assign(__assign({}, state), { gridSnappingEnabled: action.payload });
|
|
170
|
+
});
|
|
171
|
+
builder.addCase(exports.setDefaults, function (state, action) {
|
|
172
|
+
return __assign(__assign({}, state), { defaults: action.payload });
|
|
173
|
+
});
|
|
174
|
+
builder.addCase(exports.setWallModeOptions, function (state, action) {
|
|
175
|
+
return __assign(__assign({}, state), { wallModeOptions: action.payload });
|
|
176
|
+
});
|
|
177
|
+
builder.addCase(exports.setWallModeValue, function (state, action) {
|
|
178
|
+
return __assign(__assign({}, state), { wallModeValue: action.payload });
|
|
179
|
+
});
|
|
180
|
+
builder.addCase(exports.setWallModeAssetIds, function (state, action) {
|
|
181
|
+
return __assign(__assign({}, state), { wallModeAssetIds: action.payload });
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
reducers: {},
|
|
185
|
+
}).reducer;
|
|
186
|
+
var getInitialized = function (state) { return state.spaces.initialized; };
|
|
187
|
+
exports.getInitialized = getInitialized;
|
|
188
|
+
var getMode = function (state) { return state.spaces.mode; };
|
|
189
|
+
exports.getMode = getMode;
|
|
190
|
+
var getLayouts = function (state) {
|
|
191
|
+
return state.spaces.layouts;
|
|
192
|
+
};
|
|
193
|
+
exports.getLayouts = getLayouts;
|
|
194
|
+
var getUnit = function (state) { return state.spaces.unit; };
|
|
195
|
+
exports.getUnit = getUnit;
|
|
196
|
+
var getZoom = function (state) { return state.spaces.zoom; };
|
|
197
|
+
exports.getZoom = getZoom;
|
|
198
|
+
var getTranslation = function (state) { return state.spaces.translation; };
|
|
199
|
+
exports.getTranslation = getTranslation;
|
|
200
|
+
var getShowDimensions = function (state) {
|
|
201
|
+
return state.spaces.showDimensions;
|
|
202
|
+
};
|
|
203
|
+
exports.getShowDimensions = getShowDimensions;
|
|
204
|
+
var getAngleSnappingEnabled = function (state) {
|
|
205
|
+
return state.spaces.angleSnappingEnabled;
|
|
206
|
+
};
|
|
207
|
+
exports.getAngleSnappingEnabled = getAngleSnappingEnabled;
|
|
208
|
+
var getGuideSnappingEnabled = function (state) {
|
|
209
|
+
return state.spaces.guideSnappingEnabled;
|
|
210
|
+
};
|
|
211
|
+
exports.getGuideSnappingEnabled = getGuideSnappingEnabled;
|
|
212
|
+
var getGridSnappingEnabled = function (state) {
|
|
213
|
+
return state.spaces.gridSnappingEnabled;
|
|
214
|
+
};
|
|
215
|
+
exports.getGridSnappingEnabled = getGridSnappingEnabled;
|
|
216
|
+
var getDefaults = function (state) { return state.spaces.defaults; };
|
|
217
|
+
exports.getDefaults = getDefaults;
|
|
218
|
+
var getWallMode = function (state) { return ({
|
|
219
|
+
options: state.spaces.wallModeOptions,
|
|
220
|
+
value: state.spaces.wallModeValue,
|
|
221
|
+
assetId: state.spaces.wallModeAssetIds[state.spaces.wallModeValue],
|
|
222
|
+
}); };
|
|
223
|
+
exports.getWallMode = getWallMode;
|
|
224
|
+
var hydrateLayouts = function (configurationIds, attributeMap) {
|
|
225
|
+
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
+
var state, layoutIds, configurationResponses, prepped;
|
|
227
|
+
var _a;
|
|
228
|
+
return __generator(this, function (_b) {
|
|
229
|
+
switch (_b.label) {
|
|
230
|
+
case 0:
|
|
231
|
+
state = getState();
|
|
232
|
+
if (state.spaces.layouts.length)
|
|
233
|
+
return [2];
|
|
234
|
+
layoutIds = __spreadArray([], configurationIds, true);
|
|
235
|
+
if ((_a = state.product.metadata) === null || _a === void 0 ? void 0 : _a._layouts)
|
|
236
|
+
state.product.metadata._layouts
|
|
237
|
+
.split(',')
|
|
238
|
+
.forEach(function (id) { return layoutIds.push(id.trim()); });
|
|
239
|
+
return [4, Promise.all(layoutIds.map(function (configId) { return api_1.default.configurations.fetch(configId); }))];
|
|
240
|
+
case 1:
|
|
241
|
+
configurationResponses = _b.sent();
|
|
242
|
+
prepped = configurationResponses.map(function (response) {
|
|
243
|
+
var _a;
|
|
244
|
+
var wallsAttribute = response.data.variant[attributeMap.walls];
|
|
245
|
+
var walls = wallsAttribute.map(function (wallAttribute) {
|
|
246
|
+
var wallConfig = wallAttribute.configuration;
|
|
247
|
+
var wall = [
|
|
248
|
+
[
|
|
249
|
+
wallConfig[attributeMap.startX],
|
|
250
|
+
wallConfig[attributeMap.startZ],
|
|
251
|
+
],
|
|
252
|
+
[
|
|
253
|
+
wallConfig[attributeMap.endX],
|
|
254
|
+
wallConfig[attributeMap.endZ],
|
|
255
|
+
],
|
|
256
|
+
];
|
|
257
|
+
return wall;
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
label: ((_a = response.data.metadata) === null || _a === void 0 ? void 0 : _a.label) || 'Layout',
|
|
261
|
+
configuration: response.data.variant,
|
|
262
|
+
loop: (0, geometry_1.findLoops)(walls).inner,
|
|
263
|
+
};
|
|
264
|
+
});
|
|
265
|
+
dispatch((0, exports.setLayouts)(prepped));
|
|
266
|
+
return [2];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}); };
|
|
270
|
+
};
|
|
271
|
+
exports.hydrateLayouts = hydrateLayouts;
|
|
272
|
+
var initSpaces = function (initConfig) {
|
|
273
|
+
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
274
|
+
var parameters, layoutIds, attributeNames, canvasDimensions, setPendingStatus, hasInitialized, configurator, attributeDefaults, defaults, wallModes, state, spaces, config, attributesState;
|
|
275
|
+
return __generator(this, function (_a) {
|
|
276
|
+
switch (_a.label) {
|
|
277
|
+
case 0:
|
|
278
|
+
parameters = initConfig.parameters, layoutIds = initConfig.layoutIds, attributeNames = initConfig.attributeNames, canvasDimensions = initConfig.canvasDimensions, setPendingStatus = initConfig.setPendingStatus;
|
|
279
|
+
hasInitialized = (0, exports.getInitialized)(getState());
|
|
280
|
+
if (!!hasInitialized) return [3, 3];
|
|
281
|
+
if (parameters.unit)
|
|
282
|
+
dispatch((0, exports.setUnit)(parameters.unit));
|
|
283
|
+
if (parameters.showDimensions)
|
|
284
|
+
dispatch((0, exports.setShowDimensions)(parameters.showDimensions));
|
|
285
|
+
if (parameters.zoomDefault)
|
|
286
|
+
dispatch((0, exports.setZoom)(parameters.zoomDefault));
|
|
287
|
+
if (parameters.translateDefault)
|
|
288
|
+
dispatch((0, exports.setTranslation)(parameters.translateDefault));
|
|
289
|
+
if (parameters.enableAngleSnapping)
|
|
290
|
+
dispatch((0, exports.setAngleSnappingEnabled)(parameters.enableAngleSnapping));
|
|
291
|
+
if (parameters.enableGridSnapping)
|
|
292
|
+
dispatch((0, exports.setAngleSnappingEnabled)(parameters.enableGridSnapping));
|
|
293
|
+
if (parameters.enableGuideSnapping)
|
|
294
|
+
dispatch((0, exports.setAngleSnappingEnabled)(parameters.enableGuideSnapping));
|
|
295
|
+
dispatch((0, exports.hydrateLayouts)(layoutIds !== null && layoutIds !== void 0 ? layoutIds : [], {
|
|
296
|
+
walls: attributeNames[types_1.IElements.WALL],
|
|
297
|
+
startX: attributeNames.wallStartX,
|
|
298
|
+
startZ: attributeNames.wallStartZ,
|
|
299
|
+
endX: attributeNames.wallEndX,
|
|
300
|
+
endZ: attributeNames.wallEndZ,
|
|
301
|
+
}));
|
|
302
|
+
return [4, window.threekit.configurator.clone()];
|
|
303
|
+
case 1:
|
|
304
|
+
configurator = _a.sent();
|
|
305
|
+
return [4, (0, dataHandlers_1.getAttributeData)(configurator, attributeNames)];
|
|
306
|
+
case 2:
|
|
307
|
+
attributeDefaults = _a.sent();
|
|
308
|
+
if (attributeDefaults) {
|
|
309
|
+
defaults = attributeDefaults.defaults, wallModes = attributeDefaults.wallModes;
|
|
310
|
+
dispatch((0, exports.setDefaults)(defaults));
|
|
311
|
+
dispatch((0, exports.setWallModeOptions)(wallModes.options));
|
|
312
|
+
dispatch((0, exports.setWallModeValue)(wallModes.value));
|
|
313
|
+
dispatch((0, exports.setWallModeAssetIds)(wallModes.assetIds));
|
|
314
|
+
}
|
|
315
|
+
dispatch((0, exports.setInitialized)(true));
|
|
316
|
+
_a.label = 3;
|
|
317
|
+
case 3:
|
|
318
|
+
state = getState();
|
|
319
|
+
spaces = state.spaces;
|
|
320
|
+
config = {
|
|
321
|
+
unit: spaces.unit,
|
|
322
|
+
scale: constants_1.SCALE,
|
|
323
|
+
snapProximity: constants_1.SNAP_PROXIMITY,
|
|
324
|
+
zoomMin: constants_1.ZOOM_MIN,
|
|
325
|
+
zoomMax: constants_1.ZOOM_MAX,
|
|
326
|
+
zoomDefault: spaces.zoom,
|
|
327
|
+
translateDefault: spaces.translation,
|
|
328
|
+
enableAngleSnapping: spaces.angleSnappingEnabled,
|
|
329
|
+
enableGuideSnapping: spaces.guideSnappingEnabled,
|
|
330
|
+
enableGridSnapping: spaces.gridSnappingEnabled,
|
|
331
|
+
showDimensions: spaces.showDimensions,
|
|
332
|
+
styles: parameters.theme && themes_1.default[parameters.theme]
|
|
333
|
+
? themes_1.default[parameters.theme]
|
|
334
|
+
: themes_1.default[themes_1.IThemes.DEFAULT],
|
|
335
|
+
};
|
|
336
|
+
attributesState = (0, attributes_1.getHydrationData)(state)[0];
|
|
337
|
+
return [2, new SpacesState_1.default({
|
|
338
|
+
config: config,
|
|
339
|
+
attributes: attributeNames,
|
|
340
|
+
attributeDefaults: spaces.defaults,
|
|
341
|
+
attributesState: JSON.parse(JSON.stringify(attributesState)),
|
|
342
|
+
canvasDimensions: canvasDimensions,
|
|
343
|
+
wallMode: {
|
|
344
|
+
value: spaces.wallModeValue,
|
|
345
|
+
assetId: spaces.wallModeAssetIds[spaces.wallModeValue],
|
|
346
|
+
},
|
|
347
|
+
setPendingStatus: setPendingStatus,
|
|
348
|
+
})];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}); };
|
|
352
|
+
};
|
|
353
|
+
exports.initSpaces = initSpaces;
|
|
354
|
+
exports.default = reducer;
|
package/dist/store/treble.d.ts
CHANGED
|
@@ -3,13 +3,15 @@ import { IProject, IPlayerConfig, IThreekitDisplayAttribute, ISetConfiguration,
|
|
|
3
3
|
export interface IPlayerInit {
|
|
4
4
|
el: HTMLElement;
|
|
5
5
|
authToken: string;
|
|
6
|
-
assetId
|
|
6
|
+
assetId?: string;
|
|
7
|
+
customId?: string;
|
|
7
8
|
stageId?: string;
|
|
8
9
|
playerConfig: IPlayerConfig;
|
|
9
10
|
initialConfiguration?: IConfiguration;
|
|
10
11
|
}
|
|
11
12
|
export interface ILaunchConfig {
|
|
12
13
|
assetId?: string;
|
|
14
|
+
customId?: string;
|
|
13
15
|
productId: string;
|
|
14
16
|
threekitEnv: string;
|
|
15
17
|
serverUrl: string;
|
|
@@ -64,6 +66,6 @@ export declare const getLoadingProgress: (state: RootState) => undefined | numbe
|
|
|
64
66
|
export declare const getPlayerInteraction: (state: RootState) => undefined | boolean;
|
|
65
67
|
export declare const initPlayer: (config: IPlayerInit) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
66
68
|
export declare const launch: (launchConfig?: Partial<ILaunchConfig>) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
67
|
-
export declare const unloadPlayer: (
|
|
69
|
+
export declare const unloadPlayer: (dispatch: ThreekitDispatch) => Promise<string>;
|
|
68
70
|
export declare const reloadPlayer: (config: undefined | string | Pick<IReloadConfig, 'assetId' | 'stageId' | 'configurationId' | 'configuration'>) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
69
71
|
export default reducer;
|
package/dist/store/treble.js
CHANGED
|
@@ -167,34 +167,32 @@ 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, playerConfig, initialConfiguration, player, configurator, orgId, cacheParameters, ruleName;
|
|
171
|
-
return __generator(this, function (
|
|
172
|
-
switch (
|
|
170
|
+
var el, authToken, assetId, customId, stageId, playerConfig, initialConfiguration, player, configurator, _a, initializedAssetId, orgId, cacheParameters, ruleName;
|
|
171
|
+
return __generator(this, function (_b) {
|
|
172
|
+
switch (_b.label) {
|
|
173
173
|
case 0:
|
|
174
|
-
el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
|
|
174
|
+
el = config.el, authToken = config.authToken, assetId = config.assetId, customId = config.customId, stageId = config.stageId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
|
|
175
175
|
dispatch((0, exports.updateLoadingProgress)(0));
|
|
176
|
-
return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
176
|
+
return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId, customId: customId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
177
177
|
var _a;
|
|
178
178
|
dispatch((0, exports.updateLoadingProgress)(progress));
|
|
179
179
|
(_a = playerConfig === null || playerConfig === void 0 ? void 0 : playerConfig.onLoadingProgress) === null || _a === void 0 ? void 0 : _a.call(playerConfig, progress);
|
|
180
180
|
} }))];
|
|
181
181
|
case 1:
|
|
182
|
-
player =
|
|
182
|
+
player = _b.sent();
|
|
183
183
|
return [4, player.getConfigurator()];
|
|
184
184
|
case 2:
|
|
185
|
-
configurator =
|
|
186
|
-
|
|
187
|
-
connection_1.default.connect({ orgId: orgId });
|
|
185
|
+
configurator = _b.sent();
|
|
186
|
+
_a = player.enableApi(types_1.PRIVATE_APIS.PLAYER), initializedAssetId = _a.assetId, orgId = _a.orgId;
|
|
187
|
+
connection_1.default.connect({ assetId: initializedAssetId, orgId: orgId });
|
|
188
188
|
cacheParameters = player.cacheParameters;
|
|
189
|
-
if (cacheParameters)
|
|
189
|
+
if (cacheParameters)
|
|
190
190
|
connection_1.default.connect({ cacheParameters: cacheParameters });
|
|
191
|
-
|
|
192
|
-
if (window.threekit) {
|
|
191
|
+
if (window.threekit)
|
|
193
192
|
window.threekit = Object.assign(window.threekit, {
|
|
194
193
|
player: player,
|
|
195
194
|
configurator: configurator,
|
|
196
195
|
});
|
|
197
|
-
}
|
|
198
196
|
else
|
|
199
197
|
window.threekit = {
|
|
200
198
|
player: player,
|
|
@@ -205,7 +203,6 @@ var initPlayer = function (config) {
|
|
|
205
203
|
orgId: orgId,
|
|
206
204
|
}),
|
|
207
205
|
};
|
|
208
|
-
dispatch((0, exports.setThreekitInitialized)(true));
|
|
209
206
|
dispatch((0, exports.setPlayerLoading)(false));
|
|
210
207
|
dispatch((0, exports.updateLoadingProgress)(1));
|
|
211
208
|
dispatch((0, exports.setPlayerInteraction)(true));
|
|
@@ -231,16 +228,24 @@ var initPlayer = function (config) {
|
|
|
231
228
|
if (window.threekit.treble._debugMode)
|
|
232
229
|
(0, utils_1.runDebugger)();
|
|
233
230
|
player.on('setConfiguration', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
-
var
|
|
231
|
+
var state, previousAttributes, attributes, configuration, updatedAttributes;
|
|
235
232
|
var _a;
|
|
236
233
|
return __generator(this, function (_b) {
|
|
237
234
|
switch (_b.label) {
|
|
238
235
|
case 0: return [4, window.threekit.treble._player.api.evaluate()];
|
|
239
236
|
case 1:
|
|
240
237
|
_b.sent();
|
|
241
|
-
|
|
242
|
-
previousAttributes = Object.values(attributes);
|
|
243
|
-
|
|
238
|
+
state = getState();
|
|
239
|
+
previousAttributes = Object.values(state.attributes);
|
|
240
|
+
attributes = window.threekit.configurator.getDisplayAttributes();
|
|
241
|
+
configuration = window.threekit.configurator.getFullConfiguration({
|
|
242
|
+
hydrate: true,
|
|
243
|
+
});
|
|
244
|
+
updatedAttributes = attributes.map(function (attr) {
|
|
245
|
+
return Object.assign({}, attr, configuration[attr.name]
|
|
246
|
+
? { value: configuration[attr.name] }
|
|
247
|
+
: undefined);
|
|
248
|
+
});
|
|
244
249
|
dispatch((0, attributes_1.setAttributes)(updatedAttributes));
|
|
245
250
|
return [4, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
|
|
246
251
|
case 2:
|
|
@@ -257,10 +262,10 @@ var initPlayer = function (config) {
|
|
|
257
262
|
exports.initPlayer = initPlayer;
|
|
258
263
|
var launch = function (launchConfig) {
|
|
259
264
|
return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
260
|
-
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;
|
|
261
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
262
|
-
return __generator(this, function (
|
|
263
|
-
switch (
|
|
265
|
+
var config, productId, credentials, productsRaw, products, threekitEnv, serverUrl, playerConfig, envCredentials, _a, assetIdRaw, customIdRaw, stageId, configurationId, initialConfigurationRaw, customId, assetId, threekitDomainRaw, authToken, playerScriptUrl, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration;
|
|
266
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
267
|
+
return __generator(this, function (_k) {
|
|
268
|
+
switch (_k.label) {
|
|
264
269
|
case 0:
|
|
265
270
|
if (window.threekit)
|
|
266
271
|
return [2];
|
|
@@ -281,6 +286,7 @@ var launch = function (launchConfig) {
|
|
|
281
286
|
var env = _a[0], conf = _a[1];
|
|
282
287
|
var initialConfiguration;
|
|
283
288
|
var assetId;
|
|
289
|
+
var customId;
|
|
284
290
|
var stageId;
|
|
285
291
|
var configurationId;
|
|
286
292
|
if (typeof conf === 'string') {
|
|
@@ -294,6 +300,8 @@ var launch = function (launchConfig) {
|
|
|
294
300
|
initialConfiguration = conf.initialConfiguration;
|
|
295
301
|
if (conf.configurationId)
|
|
296
302
|
configurationId = conf.configurationId;
|
|
303
|
+
else if (conf.customId)
|
|
304
|
+
customId = conf.customId;
|
|
297
305
|
else if ((0, utils_1.isUuid)(conf.assetId))
|
|
298
306
|
assetId = conf.assetId;
|
|
299
307
|
else
|
|
@@ -302,6 +310,7 @@ var launch = function (launchConfig) {
|
|
|
302
310
|
return Object.assign(result, (_b = {},
|
|
303
311
|
_b[env] = {
|
|
304
312
|
assetId: assetId,
|
|
313
|
+
customId: customId,
|
|
305
314
|
stageId: stageId,
|
|
306
315
|
configurationId: configurationId,
|
|
307
316
|
initialConfiguration: initialConfiguration,
|
|
@@ -318,10 +327,13 @@ var launch = function (launchConfig) {
|
|
|
318
327
|
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);
|
|
319
328
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, config.player, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.playerConfig);
|
|
320
329
|
envCredentials = credentials[threekitEnv];
|
|
321
|
-
_a = products[productId][threekitEnv] || {}, assetIdRaw = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
|
|
322
|
-
|
|
330
|
+
_a = products[productId][threekitEnv] || {}, assetIdRaw = _a.assetId, customIdRaw = _a.customId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
|
|
331
|
+
customId = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.customId) || customIdRaw;
|
|
332
|
+
assetId = ((_h = launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.customId) === null || _h === void 0 ? void 0 : _h.length)
|
|
333
|
+
? undefined
|
|
334
|
+
: (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.assetId) || assetIdRaw;
|
|
323
335
|
threekitDomainRaw = envCredentials.threekitDomain || "".concat(threekitEnv, ".threekit.com");
|
|
324
|
-
authToken = envCredentials.publicToken;
|
|
336
|
+
authToken = envCredentials.publicToken, playerScriptUrl = envCredentials.playerScriptUrl;
|
|
325
337
|
if (playerConfig.elementId) {
|
|
326
338
|
el = document.getElementById(playerConfig.elementId);
|
|
327
339
|
if (el)
|
|
@@ -333,6 +345,7 @@ var launch = function (launchConfig) {
|
|
|
333
345
|
}
|
|
334
346
|
connection_1.default.connect({
|
|
335
347
|
authToken: authToken,
|
|
348
|
+
customId: customId,
|
|
336
349
|
assetId: assetId,
|
|
337
350
|
threekitDomain: threekitDomainRaw,
|
|
338
351
|
serverUrl: serverUrl,
|
|
@@ -341,41 +354,43 @@ var launch = function (launchConfig) {
|
|
|
341
354
|
initialConfiguration = __assign({}, initialConfigurationRaw);
|
|
342
355
|
updatedAssetId = assetId;
|
|
343
356
|
params = (0, utils_1.getParams)();
|
|
344
|
-
configId = ((
|
|
357
|
+
configId = ((_j = params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]) === null || _j === void 0 ? void 0 : _j.length)
|
|
345
358
|
? params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]
|
|
346
359
|
: configurationId;
|
|
347
360
|
if (!configId) return [3, 2];
|
|
348
361
|
return [4, api_1.default.configurations.fetch(configId)];
|
|
349
362
|
case 1:
|
|
350
|
-
configuration =
|
|
363
|
+
configuration = _k.sent();
|
|
351
364
|
if (configuration) {
|
|
352
365
|
initialConfiguration = Object.assign({}, initialConfigurationRaw, configuration.data.variant);
|
|
353
366
|
connection_1.default.connect({ assetId: configuration.data.productId });
|
|
354
367
|
updatedAssetId = configuration.data.productId;
|
|
355
368
|
}
|
|
356
|
-
|
|
369
|
+
_k.label = 2;
|
|
357
370
|
case 2:
|
|
358
|
-
if (!updatedAssetId)
|
|
359
|
-
|
|
371
|
+
if (!updatedAssetId && !customId)
|
|
372
|
+
throw new Error('missing assetId and customId');
|
|
360
373
|
return [4, new Promise(function (resolve) {
|
|
361
374
|
var script = document.createElement('script');
|
|
362
|
-
script.src =
|
|
375
|
+
script.src =
|
|
376
|
+
playerScriptUrl || "".concat(threekitDomain, "/app/js/threekit-player-bundle.js");
|
|
363
377
|
script.id = 'threekit-player-bundle';
|
|
364
378
|
script.onload = function () { return resolve(); };
|
|
365
379
|
document.head.appendChild(script);
|
|
366
380
|
})];
|
|
367
381
|
case 3:
|
|
368
|
-
|
|
382
|
+
_k.sent();
|
|
369
383
|
return [4, dispatch((0, exports.initPlayer)({
|
|
370
384
|
el: el,
|
|
371
385
|
authToken: authToken,
|
|
372
386
|
stageId: stageId,
|
|
373
387
|
assetId: updatedAssetId,
|
|
388
|
+
customId: customId,
|
|
374
389
|
playerConfig: playerConfig,
|
|
375
390
|
initialConfiguration: initialConfiguration,
|
|
376
391
|
}))];
|
|
377
392
|
case 4:
|
|
378
|
-
|
|
393
|
+
_k.sent();
|
|
379
394
|
document.addEventListener('treble:notification', function (e) {
|
|
380
395
|
message_1.default.info(e.detail.message);
|
|
381
396
|
});
|
|
@@ -388,28 +403,21 @@ var launch = function (launchConfig) {
|
|
|
388
403
|
dispatch((0, price_1.initPrice)());
|
|
389
404
|
dispatch((0, price_1.updatePrice)());
|
|
390
405
|
dispatch((0, wishlist_1.refreshWishlist)());
|
|
406
|
+
dispatch((0, exports.setThreekitInitialized)(true));
|
|
391
407
|
return [2];
|
|
392
408
|
}
|
|
393
409
|
});
|
|
394
410
|
}); };
|
|
395
411
|
};
|
|
396
412
|
exports.launch = launch;
|
|
397
|
-
var unloadPlayer = function (
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
dispatch((0, product_1.setMetadata)({}));
|
|
406
|
-
return [4, window.threekit.player.unload()];
|
|
407
|
-
case 1:
|
|
408
|
-
_a.sent();
|
|
409
|
-
return [2];
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
}); }; };
|
|
413
|
+
var unloadPlayer = function (dispatch) {
|
|
414
|
+
dispatch((0, exports.setThreekitInitialized)(false));
|
|
415
|
+
dispatch((0, exports.setPlayerLoading)(true));
|
|
416
|
+
dispatch((0, attributes_1.setAttributes)([]));
|
|
417
|
+
dispatch((0, product_1.setName)(''));
|
|
418
|
+
dispatch((0, product_1.setMetadata)({}));
|
|
419
|
+
return window.threekit.player.unload();
|
|
420
|
+
};
|
|
413
421
|
exports.unloadPlayer = unloadPlayer;
|
|
414
422
|
var reloadPlayer = function (config) {
|
|
415
423
|
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -446,7 +454,7 @@ var reloadPlayer = function (config) {
|
|
|
446
454
|
playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, trebleConfig.player);
|
|
447
455
|
el = document.getElementById(state.treble.playerElId);
|
|
448
456
|
if (!state.treble.isThreekitInitialized) return [3, 6];
|
|
449
|
-
return [4, dispatch(
|
|
457
|
+
return [4, dispatch(exports.unloadPlayer)];
|
|
450
458
|
case 5:
|
|
451
459
|
_a.sent();
|
|
452
460
|
_a.label = 6;
|
package/dist/store/wishlist.d.ts
CHANGED
|
@@ -2,8 +2,26 @@ import { RootState, ThreekitDispatch } from './index';
|
|
|
2
2
|
import { WishlistArray } from '../Treble';
|
|
3
3
|
import { ISaveConfiguration } from '../api/configurations';
|
|
4
4
|
export declare type WishlistState = WishlistArray;
|
|
5
|
-
export declare const refreshWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], void, {
|
|
6
|
-
|
|
5
|
+
export declare const refreshWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], void, {
|
|
6
|
+
state?: unknown;
|
|
7
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
8
|
+
extra?: unknown;
|
|
9
|
+
rejectValue?: unknown;
|
|
10
|
+
serializedErrorType?: unknown;
|
|
11
|
+
pendingMeta?: unknown;
|
|
12
|
+
fulfilledMeta?: unknown;
|
|
13
|
+
rejectedMeta?: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], Omit<ISaveConfiguration, "configuration">, {
|
|
16
|
+
state?: unknown;
|
|
17
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
18
|
+
extra?: unknown;
|
|
19
|
+
rejectValue?: unknown;
|
|
20
|
+
serializedErrorType?: unknown;
|
|
21
|
+
pendingMeta?: unknown;
|
|
22
|
+
fulfilledMeta?: unknown;
|
|
23
|
+
rejectedMeta?: unknown;
|
|
24
|
+
}>;
|
|
7
25
|
export declare const clearWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/clear", never, never>;
|
|
8
26
|
export declare const removeFromWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[idx: number], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/remove-item", never, never>;
|
|
9
27
|
declare const reducer: import("redux").Reducer<WishlistArray, import("redux").AnyAction>;
|