@design-core/core 0.0.1 → 0.0.3

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 (254) hide show
  1. package/.eslintrc.json +14 -7
  2. package/.github/workflows/DesignCoreQA.yml +3 -1
  3. package/README.md +11 -4
  4. package/TODO.md +19 -0
  5. package/core/core/core.js +49 -42
  6. package/core/designCore.js +61 -2
  7. package/core/dimensions/alignedDimension.js +142 -0
  8. package/core/dimensions/angularDimension.js +550 -0
  9. package/core/dimensions/baseCircularDimension.js +244 -0
  10. package/core/dimensions/baseDimension.js +558 -0
  11. package/core/dimensions/baseLinearDimension.js +371 -0
  12. package/core/dimensions/diametricDimension.js +82 -0
  13. package/core/dimensions/dimension.js +298 -0
  14. package/core/dimensions/linearDimension.js +29 -0
  15. package/core/dimensions/radialDimension.js +78 -0
  16. package/core/dimensions/rotatedDimension.js +167 -0
  17. package/core/entities/arc.js +314 -60
  18. package/core/entities/arctext.js +642 -0
  19. package/core/entities/basePolyline.js +553 -94
  20. package/core/entities/circle.js +181 -54
  21. package/core/entities/entity.js +154 -74
  22. package/core/entities/hatch.js +807 -0
  23. package/core/entities/insert.js +200 -39
  24. package/core/entities/line.js +196 -134
  25. package/core/entities/lwpolyline.js +21 -44
  26. package/core/entities/point.js +194 -29
  27. package/core/entities/polyline.js +54 -7
  28. package/core/entities/rectangle.js +43 -13
  29. package/core/entities/solid.js +43 -6
  30. package/core/entities/text.js +324 -181
  31. package/core/lib/boundingBox.js +73 -13
  32. package/core/lib/canvas.js +256 -65
  33. package/core/lib/clipboard.js +198 -0
  34. package/core/lib/colour.js +144 -0
  35. package/core/lib/colours.js +367 -301
  36. package/core/lib/commandLine.js +16 -28
  37. package/core/lib/commandManager.js +115 -58
  38. package/core/lib/constants.js +23 -0
  39. package/core/lib/dxf/dxf.js +249 -34
  40. package/core/lib/dxf/dxfFile.js +23 -38
  41. package/core/lib/dxf/dxfIterator.js +17 -5
  42. package/core/lib/dxf/dxfRead.js +23 -7
  43. package/core/lib/dxf/dxfWrite.js +39 -129
  44. package/core/lib/dxf/handleManager.js +97 -0
  45. package/core/lib/dxf/sections/blocks.js +16 -2
  46. package/core/lib/dxf/sections/entities.js +17 -3
  47. package/core/lib/dxf/sections/header.js +10 -1
  48. package/core/lib/dxf/sections/objects.js +36 -0
  49. package/core/lib/dxf/sections/section.js +43 -5
  50. package/core/lib/dxf/sections/tables.js +17 -3
  51. package/core/lib/entityManager.js +178 -0
  52. package/core/lib/fileio.js +14 -4
  53. package/core/lib/headers.js +229 -0
  54. package/core/lib/input.js +46 -0
  55. package/core/lib/inputManager.js +199 -194
  56. package/core/lib/intersect.js +341 -468
  57. package/core/lib/logging.js +25 -1
  58. package/core/lib/matrix.js +6 -8
  59. package/core/lib/mouse.js +24 -79
  60. package/core/lib/patterns.js +690 -0
  61. package/core/lib/promptOptions.js +133 -0
  62. package/core/lib/scene.js +71 -174
  63. package/core/lib/selectionManager.js +74 -48
  64. package/core/lib/selectionWindow.js +24 -10
  65. package/core/lib/settings.js +18 -11
  66. package/core/lib/snapping.js +129 -21
  67. package/core/lib/stateManager.js +288 -0
  68. package/core/lib/strings.js +57 -5
  69. package/core/lib/utils.js +95 -11
  70. package/core/objects/dictionary.js +43 -0
  71. package/core/objects/dictionaryManager.js +80 -0
  72. package/core/properties/dimType.js +117 -0
  73. package/core/properties/flags.js +66 -0
  74. package/core/properties/property.js +26 -0
  75. package/core/properties/propertyManager.js +65 -19
  76. package/core/tables/appId.js +31 -0
  77. package/core/tables/appIdManager.js +44 -0
  78. package/core/tables/block.js +323 -0
  79. package/core/tables/blockManager.js +48 -0
  80. package/core/tables/blockRecord.js +29 -0
  81. package/core/tables/blockRecordManager.js +37 -0
  82. package/core/tables/dimStyle.js +627 -0
  83. package/core/tables/dimStyleManager.js +187 -0
  84. package/core/tables/endblk.js +28 -0
  85. package/core/tables/layer.js +219 -0
  86. package/core/tables/layerManager.js +47 -0
  87. package/core/tables/ltype.js +85 -0
  88. package/core/tables/ltypeManager.js +65 -0
  89. package/core/tables/style.js +145 -0
  90. package/core/tables/styleManager.js +55 -0
  91. package/core/tables/styleManagerBase.js +110 -0
  92. package/core/tables/tableManagerBase.js +354 -0
  93. package/core/tables/ucs.js +28 -0
  94. package/core/tables/ucsManager.js +44 -0
  95. package/core/tables/view.js +28 -0
  96. package/core/tables/viewManager.js +44 -0
  97. package/core/tables/vport.js +70 -0
  98. package/core/tables/vportManager.js +65 -0
  99. package/core/tools/chamfer.js +343 -0
  100. package/core/tools/chamferFilletBase.js +162 -0
  101. package/core/tools/copy.js +68 -40
  102. package/core/tools/copybase.js +65 -0
  103. package/core/tools/copyclip.js +59 -0
  104. package/core/tools/cornerEntity.js +138 -0
  105. package/core/tools/cutclip.js +72 -0
  106. package/core/tools/distance.js +37 -9
  107. package/core/tools/erase.js +43 -13
  108. package/core/tools/explode.js +117 -0
  109. package/core/tools/extend.js +71 -32
  110. package/core/tools/fillet.js +336 -0
  111. package/core/tools/identify.js +33 -6
  112. package/core/tools/matchProp.js +106 -0
  113. package/core/tools/mirror.js +141 -0
  114. package/core/tools/move.js +65 -32
  115. package/core/tools/offset.js +321 -0
  116. package/core/tools/pan.js +54 -0
  117. package/core/tools/pasteclip.js +93 -0
  118. package/core/tools/purge.js +90 -0
  119. package/core/tools/rotate.js +105 -70
  120. package/core/tools/scale.js +166 -0
  121. package/core/tools/tool.js +14 -4
  122. package/core/tools/trim.js +71 -32
  123. package/core/tools/zoom.js +152 -0
  124. package/package.json +3 -305
  125. package/test/dimensions/alignedDimension.test.js +211 -0
  126. package/test/dimensions/angularDimension.test.js +243 -0
  127. package/test/dimensions/baseDimension.test.js +239 -0
  128. package/test/dimensions/diametricDimension.test.js +203 -0
  129. package/test/dimensions/dimension.test.js +102 -0
  130. package/test/dimensions/radialDimension.test.js +203 -0
  131. package/test/dimensions/rotatedDimension.test.js +224 -0
  132. package/test/entities/arc.test.js +463 -41
  133. package/test/entities/arctext.test.js +329 -0
  134. package/test/entities/basePolyline.test.js +459 -10
  135. package/test/entities/circle.test.js +312 -7
  136. package/test/entities/entity.test.js +28 -9
  137. package/test/entities/hatch.test.js +606 -0
  138. package/test/entities/insert.test.js +90 -0
  139. package/test/entities/line.test.js +182 -6
  140. package/test/entities/point.test.js +375 -37
  141. package/test/entities/solid.test.js +156 -0
  142. package/test/entities/text.test.js +533 -7
  143. package/test/integration/exportIntegration.reference.dxf +1706 -0
  144. package/test/integration/exportIntegration.test.js +186 -0
  145. package/test/integration/importExportIntegration.test.js +126 -0
  146. package/test/integration/intersectionIntegration.test.js +880 -0
  147. package/test/integration/userInputIntegration.reference.dxf +1410 -0
  148. package/test/integration/userInputIntegration.test.js +269 -0
  149. package/test/lib/boundingBox.test.js +26 -2
  150. package/test/lib/canvas.test.js +613 -5
  151. package/test/lib/clipboard.test.js +70 -0
  152. package/test/lib/colour.test.js +114 -0
  153. package/test/lib/colours.test.js +63 -18
  154. package/test/lib/commandLine.test.js +159 -22
  155. package/test/lib/commandManager.test.js +4 -4
  156. package/test/lib/constants.test.js +9 -0
  157. package/test/lib/dxf/dxfFile.test.js +6 -2
  158. package/test/lib/dxf/dxfIterator.test.js +1 -1
  159. package/test/lib/dxf/dxfWrite.test.js +173 -0
  160. package/test/lib/dxf/handleManager.test.js +137 -0
  161. package/test/lib/dxf/sections/blocks.test.js +5 -5
  162. package/test/lib/dxf/sections/entities.test.js +4 -4
  163. package/test/lib/dxf/sections/header.test.js +18 -4
  164. package/test/lib/dxf/sections/objects.test.js +132 -0
  165. package/test/lib/dxf/sections/section.test.js +29 -29
  166. package/test/lib/dxf/sections/tables.test.js +3 -3
  167. package/test/lib/entityManager.test.js +163 -0
  168. package/test/lib/headers.test.js +233 -0
  169. package/test/lib/inputManager.test.js +1144 -5
  170. package/test/lib/intersect.test.js +454 -331
  171. package/test/lib/logging.test.js +1 -1
  172. package/test/lib/matrix.test.js +1 -1
  173. package/test/lib/mouse.test.js +327 -4
  174. package/test/lib/patterns.test.js +105 -0
  175. package/test/lib/promptOptions.test.js +179 -0
  176. package/test/lib/scene.test.js +16 -52
  177. package/test/lib/selectionManager.test.js +17 -5
  178. package/test/lib/settings.test.js +111 -5
  179. package/test/lib/snapping.test.js +142 -4
  180. package/test/lib/stateManager.test.js +155 -0
  181. package/test/lib/utils.test.js +81 -1
  182. package/test/objects/dictionary.test.js +81 -0
  183. package/test/objects/dictionaryManager.test.js +34 -0
  184. package/test/properties/dimType.test.js +62 -0
  185. package/test/properties/flags.test.js +164 -0
  186. package/test/properties/property.test.js +13 -0
  187. package/test/properties/propertyManager.test.js +10 -11
  188. package/test/tables/appId.test.js +46 -0
  189. package/test/tables/appIdManager.test.js +72 -0
  190. package/test/tables/block.test.js +157 -0
  191. package/test/tables/blockManager.test.js +52 -0
  192. package/test/tables/blockRecord.test.js +39 -0
  193. package/test/tables/blockRecordManager.test.js +60 -0
  194. package/test/tables/dimstyle.test.js +72 -0
  195. package/test/tables/endblk.test.js +30 -0
  196. package/test/tables/layer.test.js +95 -0
  197. package/test/tables/layerManager.test.js +172 -0
  198. package/test/{styles → tables}/ltype.test.js +7 -7
  199. package/test/{styles → tables}/ltypeManager.test.js +2 -2
  200. package/test/tables/style.test.js +44 -0
  201. package/test/tables/stylemanagerbase.test.js +220 -0
  202. package/test/tables/tableManagerBase.test.js +194 -0
  203. package/test/tables/ucs.test.js +37 -0
  204. package/test/tables/ucsManager.test.js +48 -0
  205. package/test/tables/view.test.js +37 -0
  206. package/test/tables/viewManager.test.js +48 -0
  207. package/test/tables/vport.test.js +117 -0
  208. package/test/tables/vportManager.test.js +54 -0
  209. package/test/test-helpers/test-helpers.js +66 -0
  210. package/test/tools/chamfer.test.js +970 -0
  211. package/test/tools/chamferFilletBase.test.js +446 -0
  212. package/test/tools/copy.test.js +22 -14
  213. package/test/tools/copybase.test.js +93 -0
  214. package/test/tools/copyclip.test.js +92 -0
  215. package/test/tools/cornerEntity.test.js +201 -0
  216. package/test/tools/cutclip.test.js +94 -0
  217. package/test/tools/distance.test.js +140 -18
  218. package/test/tools/erase.test.js +12 -12
  219. package/test/tools/explode.test.js +45 -0
  220. package/test/tools/extend.test.js +326 -44
  221. package/test/tools/fillet.test.js +831 -0
  222. package/test/tools/identify.test.js +115 -16
  223. package/test/tools/matchProp.test.js +84 -0
  224. package/test/tools/mirror.test.js +475 -0
  225. package/test/tools/move.test.js +75 -19
  226. package/test/tools/offset.test.js +748 -0
  227. package/test/tools/pan.test.js +72 -0
  228. package/test/tools/pasteclip.test.js +100 -0
  229. package/test/tools/purge.test.js +89 -0
  230. package/test/tools/rotate.test.js +89 -23
  231. package/test/tools/scale.test.js +529 -0
  232. package/test/tools/trim.test.js +419 -84
  233. package/test/tools/zoom.test.js +504 -0
  234. package/core/entities/alignedDimension.js +0 -279
  235. package/core/entities/angularDimension.js +0 -194
  236. package/core/entities/baseDimension.js +0 -227
  237. package/core/entities/block.js +0 -247
  238. package/core/entities/diametricDimension.js +0 -133
  239. package/core/entities/dimension.js +0 -202
  240. package/core/entities/radialDimension.js +0 -126
  241. package/core/styles/dimStyle.js +0 -719
  242. package/core/styles/dimStyleManager.js +0 -47
  243. package/core/styles/layer.js +0 -133
  244. package/core/styles/layerManager.js +0 -40
  245. package/core/styles/ltype.js +0 -86
  246. package/core/styles/ltypeManager.js +0 -50
  247. package/core/styles/style.js +0 -158
  248. package/core/styles/styleManager.js +0 -43
  249. package/core/styles/styleManagerBase.js +0 -299
  250. package/test/entities/block.test.js +0 -22
  251. package/test/styles/dimstyle.test.js +0 -19
  252. package/test/styles/layerManager.test.js +0 -150
  253. package/test/styles/style.test.js +0 -33
  254. package/test/styles/stylemanagerbase.test.js +0 -219
@@ -1,12 +1,11 @@
1
- import {Point} from '../entities/point.js';
2
- import {Input} from './inputManager.js';
1
+ import { Point } from '../entities/point.js';
2
+ import { Input } from './inputManager.js';
3
3
 
4
- import {DesignCore} from '../designCore.js';
4
+ import { DesignCore } from '../designCore.js';
5
5
 
6
+ /** CommandLine Class */
6
7
  export class CommandLine {
7
- /**
8
- * Commandline Constructor
9
- */
8
+ /** Create Commandline */
10
9
  constructor() {
11
10
  this.cmdLine = ''; // display string
12
11
  this.prompt = 'Command:';
@@ -42,30 +41,11 @@ export class CommandLine {
42
41
  * @param {string} prompt
43
42
  */
44
43
  setPrompt(prompt) {
45
- // Parse default options from prompt. Defaults are enclosed in arrows <>
46
- const expression = new RegExp('<.+>');
47
- const promptHasDefault = expression.test(prompt);
48
- const commandDefault = prompt.match(expression);
49
-
50
44
  this.prompt = `${prompt}:`;
51
- this.command = promptHasDefault ? this.parseCommandDefault(commandDefault) : '';
45
+ this.command = '';
52
46
  this.update();
53
47
  }
54
48
 
55
- /**
56
- * Checks there is only a single default value supplied and removes the <>
57
- * @param {Array} commandDefault - Array containing the <default> value
58
- * @returns value contained within the <>
59
- */
60
- parseCommandDefault(commandDefault) {
61
- if (commandDefault && commandDefault.length > 1) {
62
- throw Error('Commands can contain only a single <default>');
63
- }
64
-
65
- const defaultValue = commandDefault.at(0).replace(/<|>/gi, '');
66
- return defaultValue;
67
- }
68
-
69
49
  /**
70
50
  * Update the commandline prompt and trigger the callback
71
51
  */
@@ -78,7 +58,7 @@ export class CommandLine {
78
58
 
79
59
  if (DesignCore.Scene.inputManager.activeCommand !== undefined) {
80
60
  // TODO: This should call a common function that is currently called mouseMove in the scene class
81
- DesignCore.Scene.tempItems = [];
61
+ DesignCore.Scene.tempEntities.clear();
82
62
  DesignCore.Scene.inputManager.activeCommand.preview();
83
63
  DesignCore.Canvas.requestPaint();
84
64
  }
@@ -99,7 +79,7 @@ export class CommandLine {
99
79
  this.enterPressed();
100
80
  break;
101
81
  case 'Escape':
102
- DesignCore.Scene.inputManager.onEscapePressed();
82
+ this.escapePressed();
103
83
  break;
104
84
  case 'Space': // space
105
85
  this.spacePressed();
@@ -158,6 +138,13 @@ export class CommandLine {
158
138
  }
159
139
  }
160
140
 
141
+ /**
142
+ * Handles presses of the delete key
143
+ */
144
+ escapePressed() {
145
+ DesignCore.Scene.inputManager.onEscapePressed();
146
+ }
147
+
161
148
  /**
162
149
  * Handles presses of the delete key
163
150
  */
@@ -207,6 +194,7 @@ export class CommandLine {
207
194
  /**
208
195
  * Converts input to a type
209
196
  * @param {string} input
197
+ * @return {any}
210
198
  */
211
199
  parseInput(input) {
212
200
  const isNumber = /^[-]?\d+(?:\.\d+)?$/.test(input);
@@ -1,41 +1,59 @@
1
- import {Line} from '../entities/line.js';
2
- import {Polyline} from '../entities/polyline.js';
3
- import {Lwpolyline} from '../entities/lwpolyline.js';
4
- import {Circle} from '../entities/circle.js';
5
- import {Arc} from '../entities/arc.js';
6
- import {Rectangle} from '../entities/rectangle.js';
1
+ import { Line } from '../entities/line.js';
2
+ import { Polyline } from '../entities/polyline.js';
3
+ import { Lwpolyline } from '../entities/lwpolyline.js';
4
+ import { Circle } from '../entities/circle.js';
5
+ import { Arc } from '../entities/arc.js';
6
+ import { Rectangle } from '../entities/rectangle.js';
7
7
  // import {Ellipse} from '../entities/ellipse.js';
8
8
  // import {Spline} from '../entities/spline.js';
9
- import {Text} from '../entities/text.js';
10
- // import {Dimension} from '../entities/dimension.js';
11
- // import {AlignedDimension} from '../entities/alignedDimension.js';
12
- // import {AngularDimension} from '../entities/angularDimension.js';
13
- // import {DiametricDimension} from '../entities/diametricDimension.js';
14
- // import {RadialDimension} from '../entities/radialDimension.js';
15
- // import {BaseDimension} from '../entities/basedimension.js';
16
- import {Block} from '../entities/block.js';
17
- import {Insert} from '../entities/insert.js';
9
+ import { ArcAlignedText } from '../entities/arctext.js';
10
+ import { Text } from '../entities/text.js';
11
+ import { Block } from '../tables/block.js';
12
+ import { Insert } from '../entities/insert.js';
13
+ import { Hatch } from '../entities/hatch.js';
14
+ /*
15
+ import { Dimension } from '../dimensions/dimension.js';
16
+ import { AlignedDimension } from '../dimensions/alignedDimension.js';
17
+ import { AngularDimension } from '../dimensions/angularDimension.js';
18
+ import { LinearDimension } from '../dimensions/linearDimension.js';
19
+ import { DiametricDimension } from '../dimensions/diametricDimension.js';
20
+ import { RadialDimension } from '../dimensions/radialDimension.js';
21
+ import { RotatedDimension } from '../dimensions/rotatedDimension.js';
22
+ */
18
23
 
19
24
  // import { Point } from "../entities/point.js"
20
25
 
21
- import {Move} from '../tools/move.js';
22
- import {Copy} from '../tools/copy.js';
26
+ import { MatchProp } from '../tools/matchProp.js';
27
+ import { Move } from '../tools/move.js';
28
+ import { Copy } from '../tools/copy.js';
29
+ import { Mirror } from '../tools/mirror.js';
30
+ import { Rotate } from '../tools/rotate.js';
31
+ import { Scale } from '../tools/scale.js';
32
+ import { Erase } from '../tools/erase.js';
33
+ import { Explode } from '../tools/explode.js';
34
+ import { Distance } from '../tools/distance.js';
35
+ import { Identify } from '../tools/identify.js';
36
+ import { Extend } from '../tools/extend.js';
37
+ import { Fillet } from '../tools/fillet.js';
38
+ import { Chamfer } from '../tools/chamfer.js';
39
+ import { Trim } from '../tools/trim.js';
40
+ import { Offset } from '../tools/offset.js';
41
+ import { Purge } from '../tools/purge.js';
42
+ import { Pan } from '../tools/pan.js';
43
+ import { Zoom } from '../tools/zoom.js';
44
+
45
+ // Clipboard tools
46
+ import { Copybase } from '../tools/copybase.js';
47
+ import { Copyclip } from '../tools/copyclip.js';
48
+ import { Cutclip } from '../tools/cutclip.js';
49
+ import { Pasteclip } from '../tools/pasteclip.js';
50
+
51
+ import { Utils } from './utils.js';
52
+ import { Strings } from './strings.js';
53
+ import { Logging } from './logging.js';
54
+
55
+ import { DesignCore } from '../designCore.js';
23
56
 
24
- import {Rotate} from '../tools/rotate.js';
25
- import {Erase} from '../tools/erase.js';
26
-
27
- import {Distance} from '../tools/distance.js';
28
- import {Identify} from '../tools/identify.js';
29
-
30
- import {Extend} from '../tools/extend.js';
31
- import {Trim} from '../tools/trim.js';
32
-
33
-
34
- import {Utils} from './utils.js';
35
- import {Strings} from './strings.js';
36
- import {Logging} from './logging.js';
37
-
38
- import {DesignCore} from '../designCore.js';
39
57
 
40
58
  const classes = {
41
59
  Line,
@@ -46,29 +64,54 @@ const classes = {
46
64
  Rectangle,
47
65
  // Ellipse,
48
66
  // Spline,
67
+ ArcAlignedText,
49
68
  Text,
50
- // Dimension,
51
- // AngularDimension,
52
- // AlignedDimension,
53
- // DiametricDimension,
54
- // RadialDimension,
69
+ /*
70
+ Dimension,
71
+ AngularDimension,
72
+ AlignedDimension,
73
+ DiametricDimension,
74
+ LinearDimension,
75
+ RadialDimension,
76
+ RotatedDimension,
77
+ */
55
78
  Block,
56
79
  Insert,
80
+ Hatch,
81
+ MatchProp,
57
82
  Move,
58
83
  Copy,
84
+ Mirror,
59
85
  Rotate,
86
+ Scale,
60
87
  Erase,
88
+ Explode,
61
89
  Distance,
62
90
  Identify,
63
91
  Extend,
92
+ Fillet,
93
+ Chamfer,
64
94
  Trim,
95
+ Offset,
96
+ Purge,
97
+
98
+ Zoom,
99
+ Pan,
100
+
101
+ Copybase,
102
+ Copyclip,
103
+ Cutclip,
104
+ Pasteclip,
65
105
 
66
106
  };
67
107
 
108
+ /**
109
+ * Command Manager Class
110
+ * Registers a list of available commands
111
+ * Creates new commands
112
+ */
68
113
  export class CommandManager {
69
- /**
70
- * CommandManager constructor
71
- */
114
+ /** Create CommandManager */
72
115
  constructor() {
73
116
  // store a list of the available commands
74
117
  this.commands = [];
@@ -91,7 +134,7 @@ export class CommandManager {
91
134
 
92
135
  /**
93
136
  * Return a list of available commands
94
- * @returns array of commands
137
+ * @return {Array} array of commands
95
138
  */
96
139
  getCommands() {
97
140
  return this.commands;
@@ -100,8 +143,8 @@ export class CommandManager {
100
143
  /**
101
144
  * Create a new instance of type using data
102
145
  * @param {string} type
103
- * @param {array} data
104
- * @returns instance of type
146
+ * @param {Array} data
147
+ * @return {Object} instance of type
105
148
  */
106
149
  createNew(type, data) {
107
150
  let newItem;
@@ -118,7 +161,7 @@ export class CommandManager {
118
161
  /**
119
162
  * Check if input is valid command or shortcut
120
163
  * @param {string} input
121
- * @returns boolean
164
+ * @return {boolean} boolean
122
165
  */
123
166
  isCommandOrShortcut(input) {
124
167
  if (input === undefined) {
@@ -133,20 +176,30 @@ export class CommandManager {
133
176
  return true;
134
177
  }
135
178
 
179
+ // no matching command found, try to get a fuzzy match
180
+ // get a fuzzy match and notify but only if the user is typing a new command (not mid-command)
181
+ if (DesignCore.Scene.inputManager.activeCommand === undefined) {
182
+ const command = this.getFuzzyMatch(input);
183
+ const shortcut = this.getShortcut(command);
184
+ if (command !== undefined) {
185
+ DesignCore.Core.notify(`${Strings.Message.RECOMMEND} ${command} (${shortcut})`);
186
+ }
187
+ }
188
+
136
189
  // no matching command found
137
- // get a fuzzy match and notify
138
- const command = this.getFuzzyMatch(input);
139
- const shortcut = this.getShortcut(command);
140
- DesignCore.Core.notify(`${Strings.Message.RECOMMEND} ${command} (${shortcut})`);
141
190
  return false;
142
191
  }
143
192
 
144
193
  /**
145
194
  * Check if shortcut is valid
146
195
  * @param {string} shortcut
147
- * @returns boolean
196
+ * @return {boolean} boolean
148
197
  */
149
198
  isShortcut(shortcut) {
199
+ if (shortcut === undefined || shortcut === null || typeof shortcut !== 'string') {
200
+ return false;
201
+ }
202
+
150
203
  const found = this.commands.some((el) => typeof(el.shortcut) !== 'undefined' && el.shortcut.toUpperCase() === shortcut.toUpperCase());
151
204
  return found;
152
205
  }
@@ -154,14 +207,14 @@ export class CommandManager {
154
207
  /**
155
208
  * Check if command is valid
156
209
  * @param {string} command
157
- * @returns boolean
210
+ * @return {boolean} boolean
158
211
  */
159
212
  isCommand(command) {
160
- if (command === undefined || command === null) {
213
+ if (command === undefined || command === null || typeof command !== 'string') {
161
214
  return false;
162
215
  }
163
216
 
164
- const found = this.commands.some((el) => typeof(el.command) !== 'undefined' && el.command.toUpperCase() === command.toUpperCase());
217
+ const found = this.commands.some((el) => typeof (el.command) !== 'undefined' && el.command.toUpperCase() === command.toUpperCase());
165
218
  return found;
166
219
  }
167
220
 
@@ -169,16 +222,16 @@ export class CommandManager {
169
222
  /**
170
223
  * Returns the command for a valid input
171
224
  * @param {string} input
172
- * @returns valid type
225
+ * @return {string} valid type
173
226
  */
174
227
  getCommand(input) {
175
228
  let command;
176
229
 
177
230
  if (this.isCommand(input)) {
178
- const found = this.commands.find((el) => typeof(el.command) !== 'undefined' && el.command.toUpperCase() === input.toUpperCase());
231
+ const found = this.commands.find((el) => typeof (el.command) !== 'undefined' && el.command.toUpperCase() === input.toUpperCase());
179
232
  command = found.command;
180
233
  } else if (this.isShortcut(input)) {
181
- const found = this.commands.find((el) => typeof(el.shortcut) !== 'undefined' && el.shortcut.toUpperCase() === input.toUpperCase());
234
+ const found = this.commands.find((el) => typeof (el.shortcut) !== 'undefined' && el.shortcut.toUpperCase() === input.toUpperCase());
182
235
  command = found.command;
183
236
  }
184
237
 
@@ -193,13 +246,13 @@ export class CommandManager {
193
246
  /**
194
247
  * Returns the shortcut for a valid command
195
248
  * @param {string} command
196
- * @returns {string} shortcut
249
+ * @return {string} shortcut
197
250
  */
198
251
  getShortcut(command) {
199
252
  let shortcut;
200
253
 
201
254
  if (this.isCommand(command)) {
202
- const found = this.commands.find((el) => typeof(el.command) !== 'undefined' && el.command.toUpperCase() === command.toUpperCase());
255
+ const found = this.commands.find((el) => typeof (el.command) !== 'undefined' && el.command.toUpperCase() === command.toUpperCase());
203
256
  shortcut = found.shortcut;
204
257
  }
205
258
 
@@ -210,9 +263,13 @@ export class CommandManager {
210
263
  /**
211
264
  * Returns a fuzzy match to the input command
212
265
  * @param {string} input
213
- * @returns {string} fuzzy matched command
266
+ * @return {string} fuzzy matched command
214
267
  */
215
268
  getFuzzyMatch(input) {
269
+ if (input === undefined || input === null || typeof input !== 'string') {
270
+ return undefined;
271
+ }
272
+
216
273
  let score = Infinity;
217
274
  let fuzzyMatch;
218
275
  for (let i = 0; i < this.commands.length; i++) {
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Constants
3
+ * Shared numeric constants used across the codebase.
4
+ */
5
+ export class Constants {
6
+ /**
7
+ * Geometric tolerance values.
8
+ * Values whose absolute magnitude falls below the relevant threshold
9
+ * are treated as zero for that comparison.
10
+ */
11
+ static Tolerance = {
12
+ /** Near-zero threshold for floating-point geometric comparisons (1e-10). */
13
+ EPSILON: 1e-10,
14
+ };
15
+
16
+ /**
17
+ * Numeric precision values used for rounding and output formatting.
18
+ */
19
+ static Precision = {
20
+ /** Number of decimal places used by Utils.round(). */
21
+ DECIMALPLACES: 5,
22
+ };
23
+ }