@threekit-tools/treble 0.0.90 → 0.0.91-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 (205) hide show
  1. package/dist/Treble/Treble.d.ts +2 -2
  2. package/dist/Treble/Treble.js +2 -2
  3. package/dist/Treble/index.d.ts +1 -1
  4. package/dist/Treble/index.js +1 -1
  5. package/dist/components/BreatheAnimation/index.js +2 -2
  6. package/dist/components/TurntableAnimation/index.js +2 -2
  7. package/dist/components/containers/formInputContainer.js +3 -3
  8. package/dist/hooks/useAttribute/index.js +1 -5
  9. package/dist/hooks/useConfigurationChangeStatus/index.d.ts +2 -0
  10. package/dist/hooks/{usePlayerLoadingStatus → useConfigurationChangeStatus}/index.js +2 -2
  11. package/dist/hooks/useNestedConfigurator/index.js +1 -2
  12. package/dist/hooks/usePlayerReady/index.d.ts +2 -0
  13. package/dist/hooks/{useAnimationStart → usePlayerReady}/index.js +2 -2
  14. package/dist/hooks/useSpaces/Canvas.d.ts +37 -0
  15. package/dist/hooks/useSpaces/Canvas.js +199 -0
  16. package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
  17. package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
  18. package/dist/hooks/useSpaces/SpacesState.d.ts +162 -0
  19. package/dist/hooks/useSpaces/SpacesState.js +1791 -0
  20. package/dist/hooks/useSpaces/constants.d.ts +44 -0
  21. package/dist/hooks/useSpaces/constants.js +105 -0
  22. package/dist/hooks/{useRoomBuilder → useSpaces}/dataHandlers.d.ts +6 -4
  23. package/dist/hooks/{useRoomBuilder → useSpaces}/dataHandlers.js +104 -42
  24. package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
  25. package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
  26. package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
  27. package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
  28. package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
  29. package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
  30. package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
  31. package/dist/hooks/useSpaces/draw/drawDoors.js +93 -0
  32. package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
  33. package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
  34. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
  35. package/dist/hooks/useSpaces/draw/drawGrid.js +31 -0
  36. package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
  37. package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
  38. package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
  39. package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
  40. package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
  41. package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
  42. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +10 -0
  43. package/dist/hooks/useSpaces/draw/drawWalls.js +64 -0
  44. package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
  45. package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
  46. package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
  47. package/dist/hooks/useSpaces/draw/index.js +129 -0
  48. package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
  49. package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
  50. package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
  51. package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
  52. package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
  53. package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
  54. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
  55. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
  56. package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
  57. package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
  58. package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
  59. package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
  60. package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
  61. package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
  62. package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
  63. package/dist/hooks/{useRoomBuilder → useSpaces/geometry}/findLoops.js +14 -9
  64. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
  65. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
  66. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
  67. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
  68. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
  69. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
  70. package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
  71. package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
  72. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
  73. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
  74. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
  75. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
  76. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
  77. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
  78. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
  79. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
  80. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
  81. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
  82. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
  83. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
  84. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
  85. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
  86. package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
  87. package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
  88. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
  89. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
  90. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
  91. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
  92. package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
  93. package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
  94. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
  95. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
  96. package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
  97. package/dist/hooks/useSpaces/geometry/index.js +64 -0
  98. package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
  99. package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
  100. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
  101. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
  102. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
  103. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
  104. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
  105. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
  106. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
  107. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
  108. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
  109. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
  110. package/dist/hooks/useSpaces/index.d.ts +76 -0
  111. package/dist/hooks/useSpaces/index.js +475 -0
  112. package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
  113. package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
  114. package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
  115. package/dist/hooks/useSpaces/themes/default.js +96 -0
  116. package/dist/hooks/{useRoomBuilder/themes.d.ts → useSpaces/themes/index.d.ts} +3 -4
  117. package/dist/hooks/useSpaces/themes/index.js +21 -0
  118. package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
  119. package/dist/hooks/useSpaces/themes/light.js +96 -0
  120. package/dist/hooks/{useRoomBuilder → useSpaces}/types.d.ts +131 -35
  121. package/dist/hooks/{useRoomBuilder → useSpaces}/types.js +13 -1
  122. package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
  123. package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
  124. package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
  125. package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
  126. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
  127. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
  128. package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
  129. package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
  130. package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
  131. package/dist/hooks/useSpaces/validators/index.js +40 -0
  132. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
  133. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
  134. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
  135. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
  136. package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
  137. package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
  138. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
  139. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
  140. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
  141. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
  142. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
  143. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
  144. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
  145. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
  146. package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
  147. package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
  148. package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.js +1 -1
  149. package/dist/icons/AngleSnapping.d.ts +3 -0
  150. package/dist/icons/AngleSnapping.js +28 -0
  151. package/dist/icons/Center.d.ts +3 -0
  152. package/dist/icons/Center.js +24 -0
  153. package/dist/icons/Draw.js +3 -3
  154. package/dist/icons/GridSnapping.d.ts +3 -0
  155. package/dist/icons/GridSnapping.js +28 -0
  156. package/dist/icons/LayoutAlt.d.ts +3 -0
  157. package/dist/icons/LayoutAlt.js +21 -0
  158. package/dist/icons/Magnet.d.ts +3 -0
  159. package/dist/icons/Magnet.js +27 -0
  160. package/dist/icons/Player3D.d.ts +3 -0
  161. package/dist/icons/Player3D.js +21 -0
  162. package/dist/icons/Save.d.ts +3 -0
  163. package/dist/icons/Save.js +21 -0
  164. package/dist/icons/UnitCm.d.ts +3 -0
  165. package/dist/icons/UnitCm.js +22 -0
  166. package/dist/icons/UnitFeet.d.ts +3 -0
  167. package/dist/icons/UnitFeet.js +22 -0
  168. package/dist/icons/UnitInch.d.ts +3 -0
  169. package/dist/icons/UnitInch.js +22 -0
  170. package/dist/icons/UnitMeter.d.ts +3 -0
  171. package/dist/icons/UnitMeter.js +21 -0
  172. package/dist/icons/Window.js +4 -4
  173. package/dist/icons/index.js +22 -0
  174. package/dist/icons/types.d.ts +1 -1
  175. package/dist/index.d.ts +17 -3
  176. package/dist/index.js +35 -7
  177. package/dist/store/attributes.d.ts +1 -0
  178. package/dist/store/index.d.ts +39 -8
  179. package/dist/store/index.js +3 -1
  180. package/dist/store/product.js +4 -7
  181. package/dist/store/spaces.d.ts +47 -0
  182. package/dist/store/spaces.js +197 -0
  183. package/dist/store/treble.d.ts +1 -1
  184. package/dist/store/treble.js +24 -26
  185. package/dist/types.d.ts +6 -0
  186. package/package.json +1 -1
  187. package/dist/hooks/useAnimationStart/index.d.ts +0 -2
  188. package/dist/hooks/usePlayerLoadingStatus/index.d.ts +0 -2
  189. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
  190. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
  191. package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
  192. package/dist/hooks/useRoomBuilder/constants.js +0 -48
  193. package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
  194. package/dist/hooks/useRoomBuilder/draw.js +0 -573
  195. package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
  196. package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
  197. package/dist/hooks/useRoomBuilder/geometry.js +0 -325
  198. package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
  199. package/dist/hooks/useRoomBuilder/index.js +0 -303
  200. package/dist/hooks/useRoomBuilder/themes.js +0 -273
  201. package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
  202. package/dist/hooks/useRoomBuilder/validators.js +0 -362
  203. /package/dist/Treble/{snapshots.d.ts → snapshot.d.ts} +0 -0
  204. /package/dist/Treble/{snapshots.js → snapshot.js} +0 -0
  205. /package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.d.ts +0 -0
@@ -1,273 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.IThemes = void 0;
5
- var IThemes;
6
- (function (IThemes) {
7
- IThemes["DEFAULT"] = "default";
8
- IThemes["BLUEPRINT"] = "blueprint";
9
- IThemes["LIGHT"] = "light";
10
- })(IThemes = exports.IThemes || (exports.IThemes = {}));
11
- var HIGHLIGHT_COLOR = '#36738E';
12
- var ACTIVE_COLOR = 'green';
13
- var ERROR_COLOR = 'red';
14
- var DEFAULT_WALL_THICKNESS = 18;
15
- var DEFAULT_VERTEX_RADIUS = (DEFAULT_WALL_THICKNESS - 6) / 2;
16
- var DEFAULT_FEATURE_THICKNESS = DEFAULT_WALL_THICKNESS + 6;
17
- var defaultTheme = {
18
- grid: {
19
- gridStepGap: 12,
20
- lineThickness: 1,
21
- secondaryLineThickness: 2,
22
- lineColor: '#ddd',
23
- backgroundColor: '#fff',
24
- secondaryLineIncrement: 4,
25
- },
26
- floor: {
27
- color: '#eee',
28
- textColor: '#666',
29
- },
30
- dimensions: {
31
- padding: DEFAULT_WALL_THICKNESS / 2 + 12,
32
- lineThickness: 1,
33
- lineColor: '#444',
34
- fontSize: 14,
35
- font: 'Helvetica',
36
- textColor: '#444',
37
- textBackgroundColor: 'white',
38
- },
39
- wall: {
40
- fill: '#d9d9d9',
41
- stroke: '#d9d9d9',
42
- strokeWidth: 0,
43
- thickness: DEFAULT_WALL_THICKNESS,
44
- highlight: {
45
- fill: HIGHLIGHT_COLOR,
46
- stroke: HIGHLIGHT_COLOR,
47
- },
48
- active: {
49
- fill: ACTIVE_COLOR,
50
- stroke: ACTIVE_COLOR,
51
- },
52
- error: {
53
- fill: ERROR_COLOR,
54
- stroke: ERROR_COLOR,
55
- },
56
- },
57
- vertex: {
58
- innerFill: '#36738E',
59
- outerFill: 'white',
60
- stroke: '#36738E',
61
- strokeWidth: 2,
62
- outerRadius: DEFAULT_VERTEX_RADIUS,
63
- innerRadius: DEFAULT_VERTEX_RADIUS / 2,
64
- highlight: {
65
- innerFill: HIGHLIGHT_COLOR,
66
- outerFill: HIGHLIGHT_COLOR,
67
- stroke: HIGHLIGHT_COLOR,
68
- },
69
- active: {
70
- innerFill: ACTIVE_COLOR,
71
- outerFill: ACTIVE_COLOR,
72
- stroke: ACTIVE_COLOR,
73
- },
74
- error: {
75
- innerFill: ERROR_COLOR,
76
- outerFill: ERROR_COLOR,
77
- stroke: ERROR_COLOR,
78
- },
79
- },
80
- feature: {
81
- fill: '#888',
82
- stroke: '#888',
83
- strokeWidth: 0,
84
- thickness: DEFAULT_FEATURE_THICKNESS,
85
- highlight: {
86
- fill: HIGHLIGHT_COLOR,
87
- stroke: HIGHLIGHT_COLOR,
88
- },
89
- active: {
90
- fill: ACTIVE_COLOR,
91
- stroke: ACTIVE_COLOR,
92
- },
93
- error: {
94
- fill: ERROR_COLOR,
95
- stroke: ERROR_COLOR,
96
- },
97
- },
98
- };
99
- var BLUEPRINT_WALL_THICKNESS = 22;
100
- var BLUEPRINT_VERTEX_RADIUS = (BLUEPRINT_WALL_THICKNESS - 8) / 2;
101
- var BLUEPRINT_FEATURE_THICKNESS = BLUEPRINT_WALL_THICKNESS + 6;
102
- var blueprint = {
103
- grid: {
104
- gridStepGap: 20,
105
- lineThickness: 1,
106
- secondaryLineThickness: 2,
107
- lineColor: '#fff',
108
- backgroundColor: '#37588B',
109
- secondaryLineIncrement: 3,
110
- },
111
- floor: {
112
- color: '#eee',
113
- textColor: '#666',
114
- },
115
- dimensions: {
116
- padding: DEFAULT_WALL_THICKNESS / 2 + 12,
117
- lineThickness: 1,
118
- lineColor: '#fff',
119
- fontSize: 14,
120
- font: 'Helvetica',
121
- textColor: '#444',
122
- textBackgroundColor: '#fff',
123
- },
124
- wall: {
125
- fill: '#848484',
126
- stroke: '#fff',
127
- strokeWidth: 1,
128
- thickness: BLUEPRINT_WALL_THICKNESS,
129
- highlight: {
130
- fill: HIGHLIGHT_COLOR,
131
- stroke: HIGHLIGHT_COLOR,
132
- },
133
- active: {
134
- fill: ACTIVE_COLOR,
135
- stroke: ACTIVE_COLOR,
136
- },
137
- error: {
138
- fill: ERROR_COLOR,
139
- stroke: ERROR_COLOR,
140
- },
141
- },
142
- vertex: {
143
- innerFill: '#fff',
144
- outerFill: '#fff',
145
- stroke: '#36738E',
146
- strokeWidth: 0,
147
- outerRadius: BLUEPRINT_VERTEX_RADIUS,
148
- innerRadius: BLUEPRINT_VERTEX_RADIUS / 2,
149
- highlight: {
150
- innerFill: HIGHLIGHT_COLOR,
151
- outerFill: HIGHLIGHT_COLOR,
152
- stroke: HIGHLIGHT_COLOR,
153
- },
154
- active: {
155
- innerFill: ACTIVE_COLOR,
156
- outerFill: ACTIVE_COLOR,
157
- stroke: ACTIVE_COLOR,
158
- },
159
- error: {
160
- innerFill: ERROR_COLOR,
161
- outerFill: ERROR_COLOR,
162
- stroke: ERROR_COLOR,
163
- },
164
- },
165
- feature: {
166
- fill: '#888',
167
- stroke: '#888',
168
- strokeWidth: 0,
169
- thickness: BLUEPRINT_FEATURE_THICKNESS,
170
- highlight: {
171
- fill: HIGHLIGHT_COLOR,
172
- stroke: HIGHLIGHT_COLOR,
173
- },
174
- active: {
175
- fill: ACTIVE_COLOR,
176
- stroke: ACTIVE_COLOR,
177
- },
178
- error: {
179
- fill: ERROR_COLOR,
180
- stroke: ERROR_COLOR,
181
- },
182
- },
183
- };
184
- var LIGHT_WALL_THICKNESS = 8;
185
- var LIGHT_VERTEX_RADIUS = (LIGHT_WALL_THICKNESS + 8) / 2;
186
- var LIGHT_FEATURE_THICKNESS = LIGHT_WALL_THICKNESS + 4;
187
- var light = {
188
- grid: {
189
- gridStepGap: 15,
190
- lineThickness: 1,
191
- secondaryLineThickness: 2,
192
- lineColor: '#ddd',
193
- backgroundColor: '#fff',
194
- secondaryLineIncrement: undefined,
195
- },
196
- floor: {
197
- color: '#eee',
198
- textColor: '#666',
199
- },
200
- dimensions: {
201
- padding: DEFAULT_WALL_THICKNESS / 2 + 12,
202
- lineThickness: 1,
203
- lineColor: '#444',
204
- fontSize: 14,
205
- font: 'Helvetica',
206
- textColor: '#444',
207
- textBackgroundColor: '#fff',
208
- },
209
- wall: {
210
- fill: '#000',
211
- stroke: '#000',
212
- strokeWidth: 0,
213
- thickness: LIGHT_WALL_THICKNESS,
214
- highlight: {
215
- fill: HIGHLIGHT_COLOR,
216
- stroke: HIGHLIGHT_COLOR,
217
- },
218
- active: {
219
- fill: ACTIVE_COLOR,
220
- stroke: ACTIVE_COLOR,
221
- },
222
- error: {
223
- fill: ERROR_COLOR,
224
- stroke: ERROR_COLOR,
225
- },
226
- },
227
- vertex: {
228
- innerFill: '#aaa',
229
- outerFill: '#fff',
230
- stroke: '#000',
231
- strokeWidth: 1,
232
- outerRadius: LIGHT_VERTEX_RADIUS,
233
- innerRadius: (LIGHT_VERTEX_RADIUS / 5) * 3,
234
- highlight: {
235
- innerFill: HIGHLIGHT_COLOR,
236
- outerFill: '#fff',
237
- stroke: '#000',
238
- },
239
- active: {
240
- innerFill: ACTIVE_COLOR,
241
- outerFill: '#fff',
242
- stroke: '#000',
243
- },
244
- error: {
245
- innerFill: ERROR_COLOR,
246
- outerFill: ERROR_COLOR,
247
- stroke: ERROR_COLOR,
248
- },
249
- },
250
- feature: {
251
- fill: '#888',
252
- stroke: '#888',
253
- strokeWidth: 0,
254
- thickness: LIGHT_FEATURE_THICKNESS,
255
- highlight: {
256
- fill: HIGHLIGHT_COLOR,
257
- stroke: HIGHLIGHT_COLOR,
258
- },
259
- active: {
260
- fill: ACTIVE_COLOR,
261
- stroke: ACTIVE_COLOR,
262
- },
263
- error: {
264
- fill: ERROR_COLOR,
265
- stroke: ERROR_COLOR,
266
- },
267
- },
268
- };
269
- exports.default = (_a = {},
270
- _a[IThemes.DEFAULT] = defaultTheme,
271
- _a[IThemes.BLUEPRINT] = blueprint,
272
- _a[IThemes.LIGHT] = light,
273
- _a);
@@ -1,36 +0,0 @@
1
- import { IWall, IFeatures, IElementAddress, IWalls, IErrorElement, IFeature, INewWall, ICoordinate2D, IVertex, ISnapPoint } from './types';
2
- export interface IFeatureValidatorInput {
3
- updatedFeature: Pick<IFeature, 'length' | 'offset'> & {
4
- address: IElementAddress;
5
- };
6
- wall: IWall;
7
- features: IFeatures;
8
- }
9
- export interface IAddWallValidatorInput {
10
- newWall: Pick<IWall, 'line'> & Pick<INewWall, 'snapStartTo' | 'snapEndTo'>;
11
- walls: IWalls;
12
- features: IFeatures;
13
- }
14
- export interface IMoveVertexValidatorInput {
15
- updatedPosition: {
16
- point: ICoordinate2D;
17
- snapTo?: ISnapPoint;
18
- };
19
- walls: IWalls;
20
- vertex: IVertex;
21
- features: IFeatures;
22
- }
23
- declare type IValidatorFunction<T> = (input: T) => false | IErrorElement;
24
- export declare function isWallTooShort(input: IAddWallValidatorInput): false | IErrorElement;
25
- export declare function isWallIntersectingFeature(input: IAddWallValidatorInput): false | IErrorElement;
26
- export declare function isWallOverlappingExisitingWalls(input: IAddWallValidatorInput): false | IErrorElement;
27
- export declare function isWallEndingOnFeature(input: IAddWallValidatorInput): false | IErrorElement;
28
- export declare function isFeatureOutsideWallBounds(input: IFeatureValidatorInput): false | IErrorElement;
29
- export declare function isFeatureCollidingWithExistingFeature(input: IFeatureValidatorInput): false | IErrorElement;
30
- export declare function areWallsTooShort(input: IMoveVertexValidatorInput): false | IErrorElement;
31
- export declare function areWallsIntersecting(input: IMoveVertexValidatorInput): false | IErrorElement;
32
- export declare function areWallsOrphaningFeatures(input: IMoveVertexValidatorInput): false | IErrorElement;
33
- export declare function areWallsDuplicated(input: IMoveVertexValidatorInput): false | IErrorElement;
34
- export declare function isVertexLandingOnFeature(input: IMoveVertexValidatorInput): false | IErrorElement;
35
- export declare function runValidators<T>(validators: Array<IValidatorFunction<T>>, input: T): IErrorElement[] | null;
36
- export {};
@@ -1,362 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.runValidators = exports.isVertexLandingOnFeature = exports.areWallsDuplicated = exports.areWallsOrphaningFeatures = exports.areWallsIntersecting = exports.areWallsTooShort = exports.isFeatureCollidingWithExistingFeature = exports.isFeatureOutsideWallBounds = exports.isWallEndingOnFeature = exports.isWallOverlappingExisitingWalls = exports.isWallIntersectingFeature = exports.isWallTooShort = void 0;
13
- var types_1 = require("./types");
14
- var geometry_1 = require("./geometry");
15
- var messaging_1 = require("./messaging");
16
- var constants_1 = require("./constants");
17
- function isLineTooShort(wallOrLine) {
18
- var minLength = constants_1.MIN_WALL_LENGTH;
19
- var line = Array.isArray(wallOrLine) ? wallOrLine : wallOrLine.line;
20
- var tooClose = geometry_1.arePointsWithinProximity.apply(void 0, __spreadArray(__spreadArray([], line, false), [minLength], false));
21
- if (tooClose)
22
- return {
23
- message: messaging_1.errorMessages.wallTooShort(),
24
- type: types_1.IErrorTypes.HARD,
25
- };
26
- return false;
27
- }
28
- function isWallTooShort(input) {
29
- return isLineTooShort(input.newWall.line);
30
- }
31
- exports.isWallTooShort = isWallTooShort;
32
- function isWallIntersectingFeature(input) {
33
- var _a;
34
- var newWall = input.newWall, walls = input.walls, features = input.features;
35
- if (!walls.length || !Object.values(features).flat().length)
36
- return false;
37
- var intersectingFeature;
38
- for (var i = 0; i < walls.length && !intersectingFeature; i++) {
39
- if (!walls[i].connections)
40
- continue;
41
- var intersectionPoint = (0, geometry_1.getLineSegmentsIntersection)(newWall.line, walls[i].line);
42
- if (!intersectionPoint)
43
- continue;
44
- var intersectionOffset = (0, geometry_1.getLengthOfLineSegment)([
45
- walls[i].line[0],
46
- intersectionPoint,
47
- ]);
48
- for (var j = 0; j < walls[i].connections.length && !intersectingFeature; j++) {
49
- var _b = walls[i].connections[j], type = _b[0], index = _b[1];
50
- var feature = (_a = features[type]) === null || _a === void 0 ? void 0 : _a[index];
51
- if (!feature)
52
- continue;
53
- if (feature.offset < intersectionOffset &&
54
- intersectionOffset < feature.offset + feature.length)
55
- intersectingFeature = { type: type, index: index };
56
- }
57
- }
58
- if (!intersectingFeature)
59
- return false;
60
- return ({
61
- address: intersectingFeature,
62
- message: messaging_1.errorMessages.addWallCollidingWithFeature(intersectingFeature.type),
63
- type: types_1.IErrorTypes.SOFT,
64
- } || false);
65
- }
66
- exports.isWallIntersectingFeature = isWallIntersectingFeature;
67
- function isWallOverlappingExisitingWalls(input) {
68
- var newWall = input.newWall, walls = input.walls;
69
- var snapStartTo = newWall.snapStartTo, snapEndTo = newWall.snapEndTo;
70
- if ((snapStartTo === null || snapStartTo === void 0 ? void 0 : snapStartTo.type) === types_1.IElements.WALL &&
71
- (snapEndTo === null || snapEndTo === void 0 ? void 0 : snapEndTo.type) === types_1.IElements.WALL &&
72
- snapStartTo.index === snapEndTo.index) {
73
- return {
74
- address: {
75
- type: types_1.IElements.WALL,
76
- index: snapStartTo.index,
77
- },
78
- type: types_1.IErrorTypes.SOFT,
79
- message: messaging_1.errorMessages.wallsNotUnique(),
80
- };
81
- }
82
- var overlappingIndex = walls.findIndex(function (wall, i) {
83
- var line = wall.line;
84
- if ((0, geometry_1.areLinesEqual)(line, newWall.line))
85
- return true;
86
- if ((snapStartTo === null || snapStartTo === void 0 ? void 0 : snapStartTo.type) === types_1.IElements.VERTEX &&
87
- ((0, geometry_1.arePointsEqual)(snapStartTo.point, line[0]) ||
88
- (0, geometry_1.arePointsEqual)(snapStartTo.point, line[1])) &&
89
- (snapEndTo === null || snapEndTo === void 0 ? void 0 : snapEndTo.type) === types_1.IElements.WALL &&
90
- snapEndTo.index === i) {
91
- return true;
92
- }
93
- if ((snapEndTo === null || snapEndTo === void 0 ? void 0 : snapEndTo.type) === types_1.IElements.VERTEX &&
94
- ((0, geometry_1.arePointsEqual)(snapEndTo.point, line[0]) ||
95
- (0, geometry_1.arePointsEqual)(snapEndTo.point, line[1])) &&
96
- (snapStartTo === null || snapStartTo === void 0 ? void 0 : snapStartTo.type) === types_1.IElements.WALL &&
97
- snapStartTo.index === i) {
98
- return true;
99
- }
100
- return false;
101
- });
102
- if (overlappingIndex !== -1) {
103
- return {
104
- address: {
105
- type: types_1.IElements.WALL,
106
- index: overlappingIndex,
107
- },
108
- type: types_1.IErrorTypes.SOFT,
109
- message: messaging_1.errorMessages.wallsNotUnique(),
110
- };
111
- }
112
- return false;
113
- }
114
- exports.isWallOverlappingExisitingWalls = isWallOverlappingExisitingWalls;
115
- function isWallEndingOnFeature(input) {
116
- var snapPoint = input.newWall.snapEndTo;
117
- if (!snapPoint)
118
- return false;
119
- if (snapPoint.type === types_1.IElements.WINDOW ||
120
- snapPoint.type === types_1.IElements.DOOR ||
121
- snapPoint.type === types_1.IElements.OPENING)
122
- return {
123
- address: snapPoint,
124
- message: messaging_1.errorMessages.addWallCollidingWithFeature(snapPoint.type),
125
- type: types_1.IErrorTypes.SOFT,
126
- };
127
- return false;
128
- }
129
- exports.isWallEndingOnFeature = isWallEndingOnFeature;
130
- function isFeatureOutsideWallBounds(input) {
131
- var wall = input.wall, updatedFeature = input.updatedFeature;
132
- var padding = constants_1.WALL_PADDING_FOR_FEATURE;
133
- var wallLength = (0, geometry_1.getLengthOfLineSegment)(wall.line);
134
- if (updatedFeature.offset < padding ||
135
- updatedFeature.offset + updatedFeature.length > wallLength - padding)
136
- return {
137
- address: updatedFeature.address,
138
- type: types_1.IErrorTypes.HARD,
139
- message: messaging_1.errorMessages.featureOutsideWallBounds(),
140
- };
141
- return false;
142
- }
143
- exports.isFeatureOutsideWallBounds = isFeatureOutsideWallBounds;
144
- function isFeatureCollidingWithExistingFeature(input) {
145
- var _a, _b;
146
- var features = input.features, wall = input.wall, updatedFeature = input.updatedFeature;
147
- if (!features || !((_a = wall.connections) === null || _a === void 0 ? void 0 : _a.length))
148
- return false;
149
- if (!Object.values(updatedFeature).flat().length)
150
- return false;
151
- for (var i = 0; i < wall.connections.length; i++) {
152
- var _c = wall.connections[i], type = _c[0], index = _c[1];
153
- if (updatedFeature.address.type === type &&
154
- updatedFeature.address.index === index)
155
- continue;
156
- var existingFeature = (_b = features[type]) === null || _b === void 0 ? void 0 : _b[index];
157
- if (!existingFeature)
158
- continue;
159
- if ((0, geometry_1.doLinesOverlap)([updatedFeature.offset, updatedFeature.length], [existingFeature.offset, existingFeature.length]))
160
- return {
161
- address: { type: type, index: index },
162
- type: types_1.IErrorTypes.SOFT,
163
- message: messaging_1.errorMessages.featuresColliding(type),
164
- };
165
- }
166
- return false;
167
- }
168
- exports.isFeatureCollidingWithExistingFeature = isFeatureCollidingWithExistingFeature;
169
- function areWallsTooShort(input) {
170
- var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
171
- var _a = vertex.connections.reduce(function (output, connection) {
172
- var _a;
173
- var wallIndex = connection[0], vertexIndex = connection[1];
174
- output.wallIndexes.push(wallIndex);
175
- output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
176
- _a[wallIndex] = vertexIndex,
177
- _a));
178
- return output;
179
- }, {
180
- wallIndexes: [],
181
- updatedVerticesMap: {},
182
- }), wallIndexes = _a.wallIndexes, updatedVerticesMap = _a.updatedVerticesMap;
183
- for (var _i = 0, wallIndexes_1 = wallIndexes; _i < wallIndexes_1.length; _i++) {
184
- var index = wallIndexes_1[_i];
185
- var line = walls[index].line;
186
- line[updatedVerticesMap[index]] = updatedPosition.point;
187
- if (isLineTooShort(line))
188
- return {
189
- address: { type: types_1.IElements.WALL, index: index },
190
- message: messaging_1.errorMessages.wallTooShort(),
191
- type: types_1.IErrorTypes.HARD,
192
- };
193
- }
194
- return false;
195
- }
196
- exports.areWallsTooShort = areWallsTooShort;
197
- function areWallsIntersecting(input) {
198
- var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
199
- var _a = vertex.connections.reduce(function (output, connection) {
200
- var _a;
201
- var wallIndex = connection[0], vertexIndex = connection[1];
202
- output.wallIndexes.add(wallIndex);
203
- output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
204
- _a[wallIndex] = vertexIndex,
205
- _a));
206
- return output;
207
- }, {
208
- wallIndexes: new Set([]),
209
- updatedVerticesMap: {},
210
- }), wallIndexes = _a.wallIndexes, updatedVerticesMap = _a.updatedVerticesMap;
211
- for (var _i = 0, _b = Array.from(wallIndexes); _i < _b.length; _i++) {
212
- var validateWallIndex = _b[_i];
213
- var line = walls[validateWallIndex].line;
214
- line[updatedVerticesMap[validateWallIndex]] = updatedPosition.point;
215
- for (var i = 0; i < walls.length; i++) {
216
- if (wallIndexes.has(i))
217
- continue;
218
- var wall = walls[i];
219
- if (!wall)
220
- continue;
221
- var intersectionPoint = (0, geometry_1.getLineSegmentsIntersection)(line, wall.line);
222
- if (intersectionPoint)
223
- return {
224
- address: { type: types_1.IElements.WALL, index: i },
225
- message: messaging_1.errorMessages.addWallCollidingWithWall(),
226
- type: types_1.IErrorTypes.SOFT,
227
- };
228
- }
229
- }
230
- return false;
231
- }
232
- exports.areWallsIntersecting = areWallsIntersecting;
233
- function areWallsOrphaningFeatures(input) {
234
- var _a;
235
- var walls = input.walls, vertex = input.vertex, features = input.features, updatedPosition = input.updatedPosition;
236
- var _b = vertex.connections.reduce(function (output, connection) {
237
- var _a;
238
- var wallIndex = connection[0], vertexIndex = connection[1];
239
- output.wallIndexes.add(wallIndex);
240
- output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
241
- _a[wallIndex] = vertexIndex,
242
- _a));
243
- return output;
244
- }, {
245
- wallIndexes: new Set([]),
246
- updatedVerticesMap: {},
247
- }), wallIndexes = _b.wallIndexes, updatedVerticesMap = _b.updatedVerticesMap;
248
- for (var _i = 0, _c = Array.from(wallIndexes); _i < _c.length; _i++) {
249
- var wallIdx = _c[_i];
250
- var wall = walls[wallIdx];
251
- if (!wall.connections.length)
252
- continue;
253
- var updatedLine = JSON.parse(JSON.stringify(wall.line));
254
- updatedLine[updatedVerticesMap[wallIdx]] = updatedPosition.point;
255
- var currentWallLength = (0, geometry_1.getLengthOfLineSegment)(wall.line);
256
- var updatedWallLength = (0, geometry_1.getLengthOfLineSegment)(updatedLine);
257
- var wallLengthDelta = updatedWallLength - currentWallLength;
258
- for (var i = 0; i < wall.connections.length; i++) {
259
- var _d = wall.connections[i], type = _d[0], index = _d[1];
260
- var feat = (_a = features[type]) === null || _a === void 0 ? void 0 : _a[index];
261
- if (!feat)
262
- continue;
263
- var error = {
264
- address: { type: type, index: index },
265
- message: 'feature collision',
266
- type: types_1.IErrorTypes.HARD,
267
- };
268
- if (updatedVerticesMap[wallIdx] === 0 &&
269
- feat.offset - wallLengthDelta < constants_1.WALL_PADDING_FOR_FEATURE)
270
- return error;
271
- else if (feat.offset + feat.length >
272
- updatedWallLength - constants_1.WALL_PADDING_FOR_FEATURE) {
273
- return error;
274
- }
275
- }
276
- }
277
- return false;
278
- }
279
- exports.areWallsOrphaningFeatures = areWallsOrphaningFeatures;
280
- function areWallsDuplicated(input) {
281
- var _a, _b, _c;
282
- var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
283
- var point = (_b = (_a = updatedPosition.snapTo) === null || _a === void 0 ? void 0 : _a.point) !== null && _b !== void 0 ? _b : updatedPosition.point;
284
- var _d = vertex.connections.reduce(function (output, connection) {
285
- var _a;
286
- var wallIndex = connection[0], vertexIndex = connection[1];
287
- output.wallIndexes.add(wallIndex);
288
- output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
289
- _a[wallIndex] = vertexIndex,
290
- _a));
291
- return output;
292
- }, {
293
- wallIndexes: new Set([]),
294
- updatedVerticesMap: {},
295
- }), wallIndexes = _d.wallIndexes, updatedVerticesMap = _d.updatedVerticesMap;
296
- for (var _i = 0, _e = Array.from(wallIndexes); _i < _e.length; _i++) {
297
- var wallIdx = _e[_i];
298
- var wall = walls[wallIdx];
299
- var updatedLine = JSON.parse(JSON.stringify(wall.line));
300
- updatedLine[updatedVerticesMap[wallIdx]] = point;
301
- if (((_c = updatedPosition.snapTo) === null || _c === void 0 ? void 0 : _c.type) === types_1.IElements.WALL &&
302
- updatedPosition.snapTo.index !== wallIdx) {
303
- var _f = walls[updatedPosition.snapTo.index].line, xTest = _f[0], yTest = _f[1];
304
- var unmovedPoint = updatedLine[updatedVerticesMap[wallIdx] === 1 ? 0 : 1];
305
- if ((0, geometry_1.arePointsEqual)(unmovedPoint, xTest) ||
306
- (0, geometry_1.arePointsEqual)(unmovedPoint, yTest))
307
- return {
308
- address: {
309
- type: types_1.IElements.WALL,
310
- index: updatedPosition.snapTo.index,
311
- },
312
- type: types_1.IErrorTypes.SOFT,
313
- message: messaging_1.errorMessages.wallsNotUnique(),
314
- };
315
- }
316
- for (var i = 0; i < walls.length; i++) {
317
- if (wallIdx === i)
318
- continue;
319
- var existingWall = walls[i];
320
- var error = {
321
- address: { type: types_1.IElements.WALL, index: i },
322
- type: types_1.IErrorTypes.SOFT,
323
- message: messaging_1.errorMessages.wallsNotUnique(),
324
- };
325
- if (((0, geometry_1.arePointsEqual)(existingWall[0], wall.line[0]) &&
326
- (0, geometry_1.arePointsEqual)(existingWall[1], wall.line[1])) ||
327
- ((0, geometry_1.arePointsEqual)(existingWall[0], wall.line[1]) &&
328
- (0, geometry_1.arePointsEqual)(existingWall[1], wall.line[0]))) {
329
- return error;
330
- }
331
- }
332
- }
333
- return false;
334
- }
335
- exports.areWallsDuplicated = areWallsDuplicated;
336
- function isVertexLandingOnFeature(input) {
337
- var snapPoint = input.updatedPosition.snapTo;
338
- if (!snapPoint)
339
- return false;
340
- if (snapPoint.type === types_1.IElements.WINDOW ||
341
- snapPoint.type === types_1.IElements.DOOR ||
342
- snapPoint.type === types_1.IElements.OPENING)
343
- return {
344
- address: snapPoint,
345
- message: messaging_1.errorMessages.addWallCollidingWithFeature(snapPoint.type),
346
- type: types_1.IErrorTypes.SOFT,
347
- };
348
- return false;
349
- }
350
- exports.isVertexLandingOnFeature = isVertexLandingOnFeature;
351
- function runValidators(validators, input) {
352
- var errors = validators.reduce(function (output, validate) {
353
- var error = validate(input);
354
- if (error)
355
- output.push(error);
356
- return output;
357
- }, []);
358
- if (errors.length)
359
- return errors;
360
- return null;
361
- }
362
- exports.runValidators = runValidators;
File without changes
File without changes