@mathscan/geometry-engine 0.1.0

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 (380) hide show
  1. package/README.md +1101 -0
  2. package/dist/coordinates/grid.d.cts +8 -0
  3. package/dist/coordinates/grid.d.ts +9 -0
  4. package/dist/coordinates/grid.d.ts.map +1 -0
  5. package/dist/coordinates/lineClipping.d.cts +3 -0
  6. package/dist/coordinates/lineClipping.d.ts +4 -0
  7. package/dist/coordinates/lineClipping.d.ts.map +1 -0
  8. package/dist/coordinates/transform.d.cts +18 -0
  9. package/dist/coordinates/transform.d.ts +19 -0
  10. package/dist/coordinates/transform.d.ts.map +1 -0
  11. package/dist/core.cjs +1 -0
  12. package/dist/core.mjs +4 -0
  13. package/dist/entries/core.d.cts +16 -0
  14. package/dist/entries/core.d.ts +17 -0
  15. package/dist/entries/core.d.ts.map +1 -0
  16. package/dist/entries/react.d.cts +18 -0
  17. package/dist/entries/react.d.ts +19 -0
  18. package/dist/entries/react.d.ts.map +1 -0
  19. package/dist/entries/schemas.d.cts +14 -0
  20. package/dist/entries/schemas.d.ts +15 -0
  21. package/dist/entries/schemas.d.ts.map +1 -0
  22. package/dist/entries/validation.d.cts +12 -0
  23. package/dist/entries/validation.d.ts +13 -0
  24. package/dist/entries/validation.d.ts.map +1 -0
  25. package/dist/exercise.schema-BV2b7rtN.cjs +2 -0
  26. package/dist/exercise.schema-BV2b7rtN.cjs.map +1 -0
  27. package/dist/exercise.schema-ckVBW9XA.js +212 -0
  28. package/dist/exercise.schema-ckVBW9XA.js.map +1 -0
  29. package/dist/geometry/distance.d.cts +9 -0
  30. package/dist/geometry/distance.d.ts +10 -0
  31. package/dist/geometry/distance.d.ts.map +1 -0
  32. package/dist/geometry/entities/circle.d.cts +36 -0
  33. package/dist/geometry/entities/circle.d.ts +37 -0
  34. package/dist/geometry/entities/circle.d.ts.map +1 -0
  35. package/dist/geometry/entities/index.d.cts +60 -0
  36. package/dist/geometry/entities/index.d.ts +61 -0
  37. package/dist/geometry/entities/index.d.ts.map +1 -0
  38. package/dist/geometry/entities/line.d.cts +43 -0
  39. package/dist/geometry/entities/line.d.ts +44 -0
  40. package/dist/geometry/entities/line.d.ts.map +1 -0
  41. package/dist/geometry/entities/point.d.cts +27 -0
  42. package/dist/geometry/entities/point.d.ts +28 -0
  43. package/dist/geometry/entities/point.d.ts.map +1 -0
  44. package/dist/geometry/entities/relations.d.cts +27 -0
  45. package/dist/geometry/entities/relations.d.ts +28 -0
  46. package/dist/geometry/entities/relations.d.ts.map +1 -0
  47. package/dist/geometry/entities/segment.d.cts +45 -0
  48. package/dist/geometry/entities/segment.d.ts +46 -0
  49. package/dist/geometry/entities/segment.d.ts.map +1 -0
  50. package/dist/geometry/entityCapabilities.d.cts +2 -0
  51. package/dist/geometry/entityCapabilities.d.ts +3 -0
  52. package/dist/geometry/entityCapabilities.d.ts.map +1 -0
  53. package/dist/geometry/entityModel.d.cts +139 -0
  54. package/dist/geometry/entityModel.d.ts +140 -0
  55. package/dist/geometry/entityModel.d.ts.map +1 -0
  56. package/dist/geometry/entityRecord.d.cts +27 -0
  57. package/dist/geometry/entityRecord.d.ts +28 -0
  58. package/dist/geometry/entityRecord.d.ts.map +1 -0
  59. package/dist/geometry/evaluateGraph.d.cts +37 -0
  60. package/dist/geometry/evaluateGraph.d.ts +38 -0
  61. package/dist/geometry/evaluateGraph.d.ts.map +1 -0
  62. package/dist/geometry/geometryObject.d.cts +4 -0
  63. package/dist/geometry/geometryObject.d.ts +5 -0
  64. package/dist/geometry/geometryObject.d.ts.map +1 -0
  65. package/dist/geometry/goalCandidate.d.cts +8 -0
  66. package/dist/geometry/goalCandidate.d.ts +9 -0
  67. package/dist/geometry/goalCandidate.d.ts.map +1 -0
  68. package/dist/geometry/hitTest.d.cts +23 -0
  69. package/dist/geometry/hitTest.d.ts +24 -0
  70. package/dist/geometry/hitTest.d.ts.map +1 -0
  71. package/dist/geometry/point.d.cts +5 -0
  72. package/dist/geometry/point.d.ts +6 -0
  73. package/dist/geometry/point.d.ts.map +1 -0
  74. package/dist/geometry/pointOrigin.d.cts +5 -0
  75. package/dist/geometry/pointOrigin.d.ts +6 -0
  76. package/dist/geometry/pointOrigin.d.ts.map +1 -0
  77. package/dist/geometry/v1Bridge.d.cts +41 -0
  78. package/dist/geometry/v1Bridge.d.ts +42 -0
  79. package/dist/geometry/v1Bridge.d.ts.map +1 -0
  80. package/dist/geometryAttemptStatus-5L_q6-9l.js +184 -0
  81. package/dist/geometryAttemptStatus-5L_q6-9l.js.map +1 -0
  82. package/dist/geometryAttemptStatus-N_XHIkiS.cjs +2 -0
  83. package/dist/geometryAttemptStatus-N_XHIkiS.cjs.map +1 -0
  84. package/dist/geometryState.schema-D0ixyGYE.js +955 -0
  85. package/dist/geometryState.schema-D0ixyGYE.js.map +1 -0
  86. package/dist/geometryState.schema-DKQ-durx.cjs +2 -0
  87. package/dist/geometryState.schema-DKQ-durx.cjs.map +1 -0
  88. package/dist/goals-C3ZwbEh_.js +451 -0
  89. package/dist/goals-C3ZwbEh_.js.map +1 -0
  90. package/dist/goals-CxR5qPDC.cjs +2 -0
  91. package/dist/goals-CxR5qPDC.cjs.map +1 -0
  92. package/dist/index.cjs +1 -0
  93. package/dist/index.d.cts +4 -0
  94. package/dist/index.d.ts +5 -0
  95. package/dist/index.d.ts.map +1 -0
  96. package/dist/index.mjs +10 -0
  97. package/dist/measure/geometryAdapter.d.cts +26 -0
  98. package/dist/measure/geometryAdapter.d.ts +27 -0
  99. package/dist/measure/geometryAdapter.d.ts.map +1 -0
  100. package/dist/measure/kernel.d.cts +25 -0
  101. package/dist/measure/kernel.d.ts +26 -0
  102. package/dist/measure/kernel.d.ts.map +1 -0
  103. package/dist/numerics/policy.d.cts +17 -0
  104. package/dist/numerics/policy.d.ts +18 -0
  105. package/dist/numerics/policy.d.ts.map +1 -0
  106. package/dist/react-BEcdx1f6.js +1851 -0
  107. package/dist/react-BEcdx1f6.js.map +1 -0
  108. package/dist/react-Pp_VSk--.cjs +2 -0
  109. package/dist/react-Pp_VSk--.cjs.map +1 -0
  110. package/dist/react.cjs +1 -0
  111. package/dist/react.mjs +2 -0
  112. package/dist/renderer/GeometryCanvas.d.cts +14 -0
  113. package/dist/renderer/GeometryCanvas.d.ts +15 -0
  114. package/dist/renderer/GeometryCanvas.d.ts.map +1 -0
  115. package/dist/renderer/GeometryCompanion.d.cts +29 -0
  116. package/dist/renderer/GeometryCompanion.d.ts +30 -0
  117. package/dist/renderer/GeometryCompanion.d.ts.map +1 -0
  118. package/dist/renderer/GeometryGrid.d.cts +7 -0
  119. package/dist/renderer/GeometryGrid.d.ts +8 -0
  120. package/dist/renderer/GeometryGrid.d.ts.map +1 -0
  121. package/dist/renderer/GeometryInstruments.d.cts +7 -0
  122. package/dist/renderer/GeometryInstruments.d.ts +8 -0
  123. package/dist/renderer/GeometryInstruments.d.ts.map +1 -0
  124. package/dist/renderer/StudentGeometryCanvas.d.cts +11 -0
  125. package/dist/renderer/StudentGeometryCanvas.d.ts +12 -0
  126. package/dist/renderer/StudentGeometryCanvas.d.ts.map +1 -0
  127. package/dist/renderer/StudentGeometryExercise.d.cts +36 -0
  128. package/dist/renderer/StudentGeometryExercise.d.ts +37 -0
  129. package/dist/renderer/StudentGeometryExercise.d.ts.map +1 -0
  130. package/dist/renderer/Toolbar.d.cts +7 -0
  131. package/dist/renderer/Toolbar.d.ts +8 -0
  132. package/dist/renderer/Toolbar.d.ts.map +1 -0
  133. package/dist/renderer/deriveRenderableGeometry.d.cts +15 -0
  134. package/dist/renderer/deriveRenderableGeometry.d.ts +16 -0
  135. package/dist/renderer/deriveRenderableGeometry.d.ts.map +1 -0
  136. package/dist/renderer/deriveSemanticScene.d.cts +58 -0
  137. package/dist/renderer/deriveSemanticScene.d.ts +59 -0
  138. package/dist/renderer/deriveSemanticScene.d.ts.map +1 -0
  139. package/dist/renderer/entityDisplayName.d.cts +12 -0
  140. package/dist/renderer/entityDisplayName.d.ts +13 -0
  141. package/dist/renderer/entityDisplayName.d.ts.map +1 -0
  142. package/dist/renderer/gesturePolicy.d.cts +97 -0
  143. package/dist/renderer/gesturePolicy.d.ts +98 -0
  144. package/dist/renderer/gesturePolicy.d.ts.map +1 -0
  145. package/dist/renderer/shapes/CircleShape.d.cts +17 -0
  146. package/dist/renderer/shapes/CircleShape.d.ts +18 -0
  147. package/dist/renderer/shapes/CircleShape.d.ts.map +1 -0
  148. package/dist/renderer/shapes/EntityLabel.d.cts +14 -0
  149. package/dist/renderer/shapes/EntityLabel.d.ts +15 -0
  150. package/dist/renderer/shapes/EntityLabel.d.ts.map +1 -0
  151. package/dist/renderer/shapes/EntityShape.d.cts +18 -0
  152. package/dist/renderer/shapes/EntityShape.d.ts +19 -0
  153. package/dist/renderer/shapes/EntityShape.d.ts.map +1 -0
  154. package/dist/renderer/shapes/LineShape.d.cts +16 -0
  155. package/dist/renderer/shapes/LineShape.d.ts +17 -0
  156. package/dist/renderer/shapes/LineShape.d.ts.map +1 -0
  157. package/dist/renderer/shapes/PointShape.d.cts +17 -0
  158. package/dist/renderer/shapes/PointShape.d.ts +18 -0
  159. package/dist/renderer/shapes/PointShape.d.ts.map +1 -0
  160. package/dist/renderer/shapes/SegmentShape.d.cts +17 -0
  161. package/dist/renderer/shapes/SegmentShape.d.ts +18 -0
  162. package/dist/renderer/shapes/SegmentShape.d.ts.map +1 -0
  163. package/dist/renderer/shapes/SnapMarker.d.cts +8 -0
  164. package/dist/renderer/shapes/SnapMarker.d.ts +9 -0
  165. package/dist/renderer/shapes/SnapMarker.d.ts.map +1 -0
  166. package/dist/renderer/shapes/StrokedLine.d.cts +18 -0
  167. package/dist/renderer/shapes/StrokedLine.d.ts +19 -0
  168. package/dist/renderer/shapes/StrokedLine.d.ts.map +1 -0
  169. package/dist/renderer/studentExerciseSession.d.cts +71 -0
  170. package/dist/renderer/studentExerciseSession.d.ts +72 -0
  171. package/dist/renderer/studentExerciseSession.d.ts.map +1 -0
  172. package/dist/renderer/useConnectionPreview.d.cts +44 -0
  173. package/dist/renderer/useConnectionPreview.d.ts +45 -0
  174. package/dist/renderer/useConnectionPreview.d.ts.map +1 -0
  175. package/dist/renderer/usePlacementSnap.d.cts +28 -0
  176. package/dist/renderer/usePlacementSnap.d.ts +29 -0
  177. package/dist/renderer/usePlacementSnap.d.ts.map +1 -0
  178. package/dist/renderer/usePointerGestures.d.cts +46 -0
  179. package/dist/renderer/usePointerGestures.d.ts +47 -0
  180. package/dist/renderer/usePointerGestures.d.ts.map +1 -0
  181. package/dist/schemas/circle.schema.d.cts +8 -0
  182. package/dist/schemas/circle.schema.d.ts +9 -0
  183. package/dist/schemas/circle.schema.d.ts.map +1 -0
  184. package/dist/schemas/entityDefinition.schema.d.cts +69 -0
  185. package/dist/schemas/entityDefinition.schema.d.ts +70 -0
  186. package/dist/schemas/entityDefinition.schema.d.ts.map +1 -0
  187. package/dist/schemas/entityDocument.d.cts +95 -0
  188. package/dist/schemas/entityDocument.d.ts +96 -0
  189. package/dist/schemas/entityDocument.d.ts.map +1 -0
  190. package/dist/schemas/entityPresentation.schema.d.cts +12 -0
  191. package/dist/schemas/entityPresentation.schema.d.ts +13 -0
  192. package/dist/schemas/entityPresentation.schema.d.ts.map +1 -0
  193. package/dist/schemas/exercise.schema.d.cts +217 -0
  194. package/dist/schemas/exercise.schema.d.ts +218 -0
  195. package/dist/schemas/exercise.schema.d.ts.map +1 -0
  196. package/dist/schemas/exerciseProjection.d.cts +10 -0
  197. package/dist/schemas/exerciseProjection.d.ts +11 -0
  198. package/dist/schemas/exerciseProjection.d.ts.map +1 -0
  199. package/dist/schemas/exerciseV2.schema.d.cts +137 -0
  200. package/dist/schemas/exerciseV2.schema.d.ts +138 -0
  201. package/dist/schemas/exerciseV2.schema.d.ts.map +1 -0
  202. package/dist/schemas/exerciseV3.schema.d.cts +149 -0
  203. package/dist/schemas/exerciseV3.schema.d.ts +150 -0
  204. package/dist/schemas/exerciseV3.schema.d.ts.map +1 -0
  205. package/dist/schemas/geometryObject.schema.d.cts +17 -0
  206. package/dist/schemas/geometryObject.schema.d.ts +18 -0
  207. package/dist/schemas/geometryObject.schema.d.ts.map +1 -0
  208. package/dist/schemas/geometryState.schema.d.cts +64 -0
  209. package/dist/schemas/geometryState.schema.d.ts +65 -0
  210. package/dist/schemas/geometryState.schema.d.ts.map +1 -0
  211. package/dist/schemas/givenElement.schema.d.cts +24 -0
  212. package/dist/schemas/givenElement.schema.d.ts +25 -0
  213. package/dist/schemas/givenElement.schema.d.ts.map +1 -0
  214. package/dist/schemas/goals/createGoal.schema.d.cts +12 -0
  215. package/dist/schemas/goals/createGoal.schema.d.ts +13 -0
  216. package/dist/schemas/goals/createGoal.schema.d.ts.map +1 -0
  217. package/dist/schemas/goals/geometryGoal.schema.d.cts +58 -0
  218. package/dist/schemas/goals/geometryGoal.schema.d.ts +59 -0
  219. package/dist/schemas/goals/geometryGoal.schema.d.ts.map +1 -0
  220. package/dist/schemas/goals/goalKindDeclaration.d.cts +53 -0
  221. package/dist/schemas/goals/goalKindDeclaration.d.ts +54 -0
  222. package/dist/schemas/goals/goalKindDeclaration.d.ts.map +1 -0
  223. package/dist/schemas/goals/midpointGoal.schema.d.cts +9 -0
  224. package/dist/schemas/goals/midpointGoal.schema.d.ts +10 -0
  225. package/dist/schemas/goals/midpointGoal.schema.d.ts.map +1 -0
  226. package/dist/schemas/goals/parallelGoal.schema.d.cts +15 -0
  227. package/dist/schemas/goals/parallelGoal.schema.d.ts +16 -0
  228. package/dist/schemas/goals/parallelGoal.schema.d.ts.map +1 -0
  229. package/dist/schemas/goals/perpendicularGoal.schema.d.cts +15 -0
  230. package/dist/schemas/goals/perpendicularGoal.schema.d.ts +16 -0
  231. package/dist/schemas/goals/perpendicularGoal.schema.d.ts.map +1 -0
  232. package/dist/schemas/goals/segmentLengthGoal.schema.d.cts +9 -0
  233. package/dist/schemas/goals/segmentLengthGoal.schema.d.ts +10 -0
  234. package/dist/schemas/goals/segmentLengthGoal.schema.d.ts.map +1 -0
  235. package/dist/schemas/goals/throughPointsGoal.schema.d.cts +13 -0
  236. package/dist/schemas/goals/throughPointsGoal.schema.d.ts +14 -0
  237. package/dist/schemas/goals/throughPointsGoal.schema.d.ts.map +1 -0
  238. package/dist/schemas/identifier.schema.d.cts +2 -0
  239. package/dist/schemas/identifier.schema.d.ts +3 -0
  240. package/dist/schemas/identifier.schema.d.ts.map +1 -0
  241. package/dist/schemas/line.schema.d.cts +7 -0
  242. package/dist/schemas/line.schema.d.ts +8 -0
  243. package/dist/schemas/line.schema.d.ts.map +1 -0
  244. package/dist/schemas/migrate.d.cts +21 -0
  245. package/dist/schemas/migrate.d.ts +22 -0
  246. package/dist/schemas/migrate.d.ts.map +1 -0
  247. package/dist/schemas/objectTypeName.schema.d.cts +8 -0
  248. package/dist/schemas/objectTypeName.schema.d.ts +9 -0
  249. package/dist/schemas/objectTypeName.schema.d.ts.map +1 -0
  250. package/dist/schemas/point.schema.d.cts +15 -0
  251. package/dist/schemas/point.schema.d.ts +16 -0
  252. package/dist/schemas/point.schema.d.ts.map +1 -0
  253. package/dist/schemas/pointOrigin.schema.d.cts +25 -0
  254. package/dist/schemas/pointOrigin.schema.d.ts +26 -0
  255. package/dist/schemas/pointOrigin.schema.d.ts.map +1 -0
  256. package/dist/schemas/segment.schema.d.cts +8 -0
  257. package/dist/schemas/segment.schema.d.ts +9 -0
  258. package/dist/schemas/segment.schema.d.ts.map +1 -0
  259. package/dist/schemas/v1ToV2.d.cts +37 -0
  260. package/dist/schemas/v1ToV2.d.ts +38 -0
  261. package/dist/schemas/v1ToV2.d.ts.map +1 -0
  262. package/dist/schemas/v2ToV3.d.cts +37 -0
  263. package/dist/schemas/v2ToV3.d.ts +38 -0
  264. package/dist/schemas/v2ToV3.d.ts.map +1 -0
  265. package/dist/schemas/v3ToV4.d.cts +3 -0
  266. package/dist/schemas/v3ToV4.d.ts +4 -0
  267. package/dist/schemas/v3ToV4.d.ts.map +1 -0
  268. package/dist/schemas/viewport.schema.d.cts +3 -0
  269. package/dist/schemas/viewport.schema.d.ts +4 -0
  270. package/dist/schemas/viewport.schema.d.ts.map +1 -0
  271. package/dist/schemas.cjs +1 -0
  272. package/dist/schemas.mjs +3 -0
  273. package/dist/snapping/computeSnap.d.cts +30 -0
  274. package/dist/snapping/computeSnap.d.ts +31 -0
  275. package/dist/snapping/computeSnap.d.ts.map +1 -0
  276. package/dist/state/geometryContext.d.cts +40 -0
  277. package/dist/state/geometryContext.d.ts +41 -0
  278. package/dist/state/geometryContext.d.ts.map +1 -0
  279. package/dist/state/resolvePoints.d.cts +51 -0
  280. package/dist/state/resolvePoints.d.ts +52 -0
  281. package/dist/state/resolvePoints.d.ts.map +1 -0
  282. package/dist/store/attemptChange.d.cts +30 -0
  283. package/dist/store/attemptChange.d.ts +31 -0
  284. package/dist/store/attemptChange.d.ts.map +1 -0
  285. package/dist/store/constructionCommand.d.cts +35 -0
  286. package/dist/store/constructionCommand.d.ts +36 -0
  287. package/dist/store/constructionCommand.d.ts.map +1 -0
  288. package/dist/store/constructionIdentity.d.cts +21 -0
  289. package/dist/store/constructionIdentity.d.ts +22 -0
  290. package/dist/store/constructionIdentity.d.ts.map +1 -0
  291. package/dist/store/createStore.d.cts +6 -0
  292. package/dist/store/createStore.d.ts +7 -0
  293. package/dist/store/createStore.d.ts.map +1 -0
  294. package/dist/store/history.d.cts +2 -0
  295. package/dist/store/history.d.ts +3 -0
  296. package/dist/store/history.d.ts.map +1 -0
  297. package/dist/store/studentStore.d.cts +151 -0
  298. package/dist/store/studentStore.d.ts +152 -0
  299. package/dist/store/studentStore.d.ts.map +1 -0
  300. package/dist/store/teacherStore.d.cts +111 -0
  301. package/dist/store/teacherStore.d.ts +112 -0
  302. package/dist/store/teacherStore.d.ts.map +1 -0
  303. package/dist/store/useStoreState.d.cts +2 -0
  304. package/dist/store/useStoreState.d.ts +3 -0
  305. package/dist/store/useStoreState.d.ts.map +1 -0
  306. package/dist/studentStore-CEKTtMCh.js +1162 -0
  307. package/dist/studentStore-CEKTtMCh.js.map +1 -0
  308. package/dist/studentStore-DLftfFAl.cjs +2 -0
  309. package/dist/studentStore-DLftfFAl.cjs.map +1 -0
  310. package/dist/validation/checkGeometryAnswer.d.cts +63 -0
  311. package/dist/validation/checkGeometryAnswer.d.ts +64 -0
  312. package/dist/validation/checkGeometryAnswer.d.ts.map +1 -0
  313. package/dist/validation/deriveGeometryCanvasFeedback.d.cts +7 -0
  314. package/dist/validation/deriveGeometryCanvasFeedback.d.ts +8 -0
  315. package/dist/validation/deriveGeometryCanvasFeedback.d.ts.map +1 -0
  316. package/dist/validation/exerciseLoad.d.cts +29 -0
  317. package/dist/validation/exerciseLoad.d.ts +30 -0
  318. package/dist/validation/exerciseLoad.d.ts.map +1 -0
  319. package/dist/validation/geometryAttemptStatus.d.cts +23 -0
  320. package/dist/validation/geometryAttemptStatus.d.ts +24 -0
  321. package/dist/validation/geometryAttemptStatus.d.ts.map +1 -0
  322. package/dist/validation/getGeometryExerciseWarnings.d.cts +16 -0
  323. package/dist/validation/getGeometryExerciseWarnings.d.ts +17 -0
  324. package/dist/validation/getGeometryExerciseWarnings.d.ts.map +1 -0
  325. package/dist/validation/goals/create.d.cts +3 -0
  326. package/dist/validation/goals/create.d.ts +4 -0
  327. package/dist/validation/goals/create.d.ts.map +1 -0
  328. package/dist/validation/goals/goalContext.d.cts +44 -0
  329. package/dist/validation/goals/goalContext.d.ts +45 -0
  330. package/dist/validation/goals/goalContext.d.ts.map +1 -0
  331. package/dist/validation/goals/goalKindHandler.d.cts +26 -0
  332. package/dist/validation/goals/goalKindHandler.d.ts +27 -0
  333. package/dist/validation/goals/goalKindHandler.d.ts.map +1 -0
  334. package/dist/validation/goals/index.d.cts +14 -0
  335. package/dist/validation/goals/index.d.ts +15 -0
  336. package/dist/validation/goals/index.d.ts.map +1 -0
  337. package/dist/validation/goals/midpoint.d.cts +4 -0
  338. package/dist/validation/goals/midpoint.d.ts +5 -0
  339. package/dist/validation/goals/midpoint.d.ts.map +1 -0
  340. package/dist/validation/goals/parallel.d.cts +3 -0
  341. package/dist/validation/goals/parallel.d.ts +4 -0
  342. package/dist/validation/goals/parallel.d.ts.map +1 -0
  343. package/dist/validation/goals/perpendicular.d.cts +3 -0
  344. package/dist/validation/goals/perpendicular.d.ts +4 -0
  345. package/dist/validation/goals/perpendicular.d.ts.map +1 -0
  346. package/dist/validation/goals/previewGeometry.d.cts +9 -0
  347. package/dist/validation/goals/previewGeometry.d.ts +10 -0
  348. package/dist/validation/goals/previewGeometry.d.ts.map +1 -0
  349. package/dist/validation/goals/segmentLength.d.cts +3 -0
  350. package/dist/validation/goals/segmentLength.d.ts +4 -0
  351. package/dist/validation/goals/segmentLength.d.ts.map +1 -0
  352. package/dist/validation/goals/throughPoints.d.cts +5 -0
  353. package/dist/validation/goals/throughPoints.d.ts +6 -0
  354. package/dist/validation/goals/throughPoints.d.ts.map +1 -0
  355. package/dist/validation/gradingFingerprints.d.cts +4 -0
  356. package/dist/validation/gradingFingerprints.d.ts +5 -0
  357. package/dist/validation/gradingFingerprints.d.ts.map +1 -0
  358. package/dist/validation/revealGeometryAnswers.d.cts +3 -0
  359. package/dist/validation/revealGeometryAnswers.d.ts +4 -0
  360. package/dist/validation/revealGeometryAnswers.d.ts.map +1 -0
  361. package/dist/validation/revealGeometryAttempt.d.cts +36 -0
  362. package/dist/validation/revealGeometryAttempt.d.ts +37 -0
  363. package/dist/validation/revealGeometryAttempt.d.ts.map +1 -0
  364. package/dist/validation/types.d.cts +58 -0
  365. package/dist/validation/types.d.ts +59 -0
  366. package/dist/validation/types.d.ts.map +1 -0
  367. package/dist/validation/validateGeometryExercise.d.cts +30 -0
  368. package/dist/validation/validateGeometryExercise.d.ts +31 -0
  369. package/dist/validation/validateGeometryExercise.d.ts.map +1 -0
  370. package/dist/validation/validateGeometryState.d.cts +16 -0
  371. package/dist/validation/validateGeometryState.d.ts +17 -0
  372. package/dist/validation/validateGeometryState.d.ts.map +1 -0
  373. package/dist/validation/validateGeometryStateInput.d.cts +22 -0
  374. package/dist/validation/validateGeometryStateInput.d.ts +23 -0
  375. package/dist/validation/validateGeometryStateInput.d.ts.map +1 -0
  376. package/dist/validation.cjs +2 -0
  377. package/dist/validation.cjs.map +1 -0
  378. package/dist/validation.mjs +269 -0
  379. package/dist/validation.mjs.map +1 -0
  380. package/package.json +150 -0
@@ -0,0 +1,31 @@
1
+ import { SceneEntity } from '../geometry/hitTest.js';
2
+ import { Point, PointId } from '../geometry/point.js';
3
+ import { EntityId, PointDefinition } from '../geometry/entityModel.js';
4
+ import { MathViewport } from '../schemas/viewport.schema.js';
5
+ export type SnapKind = 'point' | 'intersection' | 'grid' | 'onObject';
6
+ export interface SnapResult {
7
+ position: Point;
8
+ kind: SnapKind;
9
+ targetIds: string[];
10
+ parameter?: number;
11
+ distance: number;
12
+ }
13
+ export interface SnapScene {
14
+ points: ReadonlyMap<PointId, Point>;
15
+ objects: readonly SceneEntity[];
16
+ viewport: MathViewport;
17
+ showGrid?: boolean;
18
+ isSnapTarget?: (id: EntityId) => boolean;
19
+ }
20
+ export interface SnapOptions {
21
+ tolerance: number;
22
+ exclude?: readonly string[];
23
+ kinds?: readonly SnapKind[];
24
+ }
25
+ export declare function computeSnap(at: Point, scene: SnapScene, options: SnapOptions): SnapResult | null;
26
+ export declare function snapPosition(at: Point, scene: SnapScene, options: SnapOptions): Point;
27
+ export declare function originForSnap(placement: {
28
+ position: Point;
29
+ snap: SnapResult | null;
30
+ }): PointDefinition | null;
31
+ //# sourceMappingURL=computeSnap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeSnap.d.ts","sourceRoot":"","sources":["../../src/snapping/computeSnap.ts"],"names":[],"mappings":"AAWA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAmB,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,UAAU,CAAA;AAErE,MAAM,WAAW,UAAU;IAEzB,QAAQ,EAAE,KAAK,CAAA;IACf,IAAI,EAAE,QAAQ,CAAA;IAGd,SAAS,EAAE,MAAM,EAAE,CAAA;IAGnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACnC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IAC/B,QAAQ,EAAE,YAAY,CAAA;IAEtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAQlB,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAA;CACzC;AAED,MAAM,WAAW,WAAW;IAE1B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;CAC5B;AA4GD,wBAAgB,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAQhG;AAID,wBAAgB,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,CAErF;AAaD,wBAAgB,aAAa,CAAC,SAAS,EAAE;IACvC,QAAQ,EAAE,KAAK,CAAA;IACf,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;CACxB,GAAG,eAAe,GAAG,IAAI,CAczB"}
@@ -0,0 +1,40 @@
1
+ import { EntityId, EntityKind, GeometryContext } from '../geometry/entityModel.cjs';
2
+ import { Point, PointId } from '../geometry/point.cjs';
3
+ import { MeasuredObject } from '../measure/geometryAdapter.cjs';
4
+ import { GeometryExercise, ToolName } from '../schemas/exercise.schema.cjs';
5
+ import { GeometryState } from '../schemas/geometryState.schema.cjs';
6
+ import { ObjectTypeName } from '../schemas/objectTypeName.schema.cjs';
7
+ /**
8
+ * What M2.2 adds on top of the frozen `GeometryContext` minimum. The extra
9
+ * members are the lookups the four consumers actually asked for — the graph
10
+ * edges in both directions, the measured form the JSXGraph seam wants, the
11
+ * exercise's own capabilities, and the staleness check.
12
+ *
13
+ * Read-only to consumers: every collection is handed out as `readonly` or as a
14
+ * fresh array, and no index another consumer is reading is ever exposed.
15
+ */
16
+ export interface IndexedGeometryContext extends GeometryContext {
17
+ kindOf(id: EntityId): EntityKind | undefined;
18
+ parentsOf(id: EntityId): readonly EntityId[];
19
+ removalClosureOf(id: EntityId): readonly EntityId[];
20
+ readonly points: ReadonlyMap<PointId, Point>;
21
+ measuredOf(id: EntityId): MeasuredObject | null;
22
+ allowsObjectType(type: ObjectTypeName): boolean;
23
+ allowsTool(tool: ToolName): boolean;
24
+ isBuiltFrom(exercise: GeometryExercise, geometry: GeometryState): boolean;
25
+ }
26
+ /**
27
+ * Indexes an exercise and one attempt against it into a single read-only
28
+ * scene, resolving every point once.
29
+ *
30
+ * Both arguments are the parsed, schema-checked types, which is what "built
31
+ * only from validated data" means here: there is no second builder taking
32
+ * `unknown`, and a caller holding untrusted JSON goes through
33
+ * `validateGeometryStateInput()` first, exactly as it does today.
34
+ *
35
+ * Nothing throws. A document the schemas would reject — a duplicate id, a
36
+ * parent that does not exist, a cycle — indexes anyway and reports what it
37
+ * found in `issues`, because the authoring warnings and the dev page must
38
+ * describe a broken exercise rather than disappear on it.
39
+ */
40
+ export declare function buildGeometryContext(exercise: GeometryExercise, geometry: GeometryState): IndexedGeometryContext;
@@ -0,0 +1,41 @@
1
+ import { EntityId, EntityKind, GeometryContext } from '../geometry/entityModel.js';
2
+ import { Point, PointId } from '../geometry/point.js';
3
+ import { MeasuredObject } from '../measure/geometryAdapter.js';
4
+ import { GeometryExercise, ToolName } from '../schemas/exercise.schema.js';
5
+ import { GeometryState } from '../schemas/geometryState.schema.js';
6
+ import { ObjectTypeName } from '../schemas/objectTypeName.schema.js';
7
+ /**
8
+ * What M2.2 adds on top of the frozen `GeometryContext` minimum. The extra
9
+ * members are the lookups the four consumers actually asked for — the graph
10
+ * edges in both directions, the measured form the JSXGraph seam wants, the
11
+ * exercise's own capabilities, and the staleness check.
12
+ *
13
+ * Read-only to consumers: every collection is handed out as `readonly` or as a
14
+ * fresh array, and no index another consumer is reading is ever exposed.
15
+ */
16
+ export interface IndexedGeometryContext extends GeometryContext {
17
+ kindOf(id: EntityId): EntityKind | undefined;
18
+ parentsOf(id: EntityId): readonly EntityId[];
19
+ removalClosureOf(id: EntityId): readonly EntityId[];
20
+ readonly points: ReadonlyMap<PointId, Point>;
21
+ measuredOf(id: EntityId): MeasuredObject | null;
22
+ allowsObjectType(type: ObjectTypeName): boolean;
23
+ allowsTool(tool: ToolName): boolean;
24
+ isBuiltFrom(exercise: GeometryExercise, geometry: GeometryState): boolean;
25
+ }
26
+ /**
27
+ * Indexes an exercise and one attempt against it into a single read-only
28
+ * scene, resolving every point once.
29
+ *
30
+ * Both arguments are the parsed, schema-checked types, which is what "built
31
+ * only from validated data" means here: there is no second builder taking
32
+ * `unknown`, and a caller holding untrusted JSON goes through
33
+ * `validateGeometryStateInput()` first, exactly as it does today.
34
+ *
35
+ * Nothing throws. A document the schemas would reject — a duplicate id, a
36
+ * parent that does not exist, a cycle — indexes anyway and reports what it
37
+ * found in `issues`, because the authoring warnings and the dev page must
38
+ * describe a broken exercise rather than disappear on it.
39
+ */
40
+ export declare function buildGeometryContext(exercise: GeometryExercise, geometry: GeometryState): IndexedGeometryContext;
41
+ //# sourceMappingURL=geometryContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometryContext.d.ts","sourceRoot":"","sources":["../../src/state/geometryContext.ts"],"names":[],"mappings":"AA8DA,OAAO,KAAK,EAEV,QAAQ,EACR,UAAU,EAGV,eAAe,EAIhB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAE7D,MAAM,CAAC,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;IAI5C,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,QAAQ,EAAE,CAAA;IAI5C,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,QAAQ,EAAE,CAAA;IAKnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAK5C,UAAU,CAAC,EAAE,EAAE,QAAQ,GAAG,cAAc,GAAG,IAAI,CAAA;IAI/C,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAA;IAC/C,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;IAInC,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAA;CAC1E;AAyLD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,GACtB,sBAAsB,CAqLxB"}
@@ -0,0 +1,51 @@
1
+ import { EntityId } from '../geometry/entityModel.cjs';
2
+ import { SceneEntity } from '../geometry/hitTest.cjs';
3
+ import { Point, PointId } from '../geometry/point.cjs';
4
+ import { GeometryExercise } from '../schemas/exercise.schema.cjs';
5
+ import { GeometryState } from '../schemas/geometryState.schema.cjs';
6
+ import { IndexedGeometryContext } from './geometryContext.cjs';
7
+ /**
8
+ * Every object a point can be built on: the exercise's own entities plus the
9
+ * student's constructions, as the `{ id, definition }` pairs a hit-test or snap
10
+ * scene is made of.
11
+ *
12
+ * Keyed by id and in declaration order, exercise first, because a construction
13
+ * re-declaring a given id loses to it exactly as it does in the context.
14
+ */
15
+ export declare function objectsInScope(exercise: GeometryExercise, geometry: GeometryState): Map<EntityId, SceneEntity>;
16
+ /**
17
+ * Resolves every point to coordinates. A point is simply absent from the
18
+ * result when it cannot be resolved — its object was deleted, its two objects
19
+ * became parallel so the intersection vanished, or its origins form a cycle.
20
+ * Callers treat "absent" as "not on screen": renderers skip it, validation
21
+ * skips candidates and constructions built on it. Nothing throws, because a
22
+ * student mid-construction is allowed to have a figure that briefly makes no
23
+ * sense.
24
+ *
25
+ * Given points come from `exercise`, not from `geometry` — a pinned given is
26
+ * placed by the exercise whatever a submitted attempt claims, which is a
27
+ * grading-integrity rule and is enforced while the context is indexed.
28
+ *
29
+ * Iteration order is part of the contract: pinned givens, then draggable
30
+ * givens, then the attempt's own points. `findPointAt()` in the student store
31
+ * promotes the first point within reuse tolerance, so the order decides which
32
+ * point a revealed answer lands on.
33
+ */
34
+ export declare function resolvePoints(exercise: GeometryExercise, geometry: GeometryState): ReadonlyMap<PointId, Point>;
35
+ export declare function resolvePoint(exercise: GeometryExercise, geometry: GeometryState, id: PointId): Point | null;
36
+ /**
37
+ * Every point an exercise places on its own, with no attempt against it — what
38
+ * the teacher canvas draws and what a revealed answer is measured against.
39
+ *
40
+ * A v1 given carried its coordinates and needed no resolution; a v2 exercise
41
+ * entity is a definition, so a given point sitting on a given segment has a
42
+ * position only once the graph has been walked (M2.6.c.1).
43
+ */
44
+ export declare function resolveExercisePoints(exercise: GeometryExercise): ReadonlyMap<PointId, Point>;
45
+ /**
46
+ * The same walk, kept whole rather than reduced to its points: a teacher-side
47
+ * caller that also needs presentation — which is every renderer, since M2.G.4
48
+ * routes drawing through the capability triple — would otherwise index the
49
+ * exercise a second time to answer what the context already knows.
50
+ */
51
+ export declare function exerciseGeometryContext(exercise: GeometryExercise): IndexedGeometryContext;
@@ -0,0 +1,52 @@
1
+ import { EntityId } from '../geometry/entityModel.js';
2
+ import { SceneEntity } from '../geometry/hitTest.js';
3
+ import { Point, PointId } from '../geometry/point.js';
4
+ import { GeometryExercise } from '../schemas/exercise.schema.js';
5
+ import { GeometryState } from '../schemas/geometryState.schema.js';
6
+ import { IndexedGeometryContext } from './geometryContext.js';
7
+ /**
8
+ * Every object a point can be built on: the exercise's own entities plus the
9
+ * student's constructions, as the `{ id, definition }` pairs a hit-test or snap
10
+ * scene is made of.
11
+ *
12
+ * Keyed by id and in declaration order, exercise first, because a construction
13
+ * re-declaring a given id loses to it exactly as it does in the context.
14
+ */
15
+ export declare function objectsInScope(exercise: GeometryExercise, geometry: GeometryState): Map<EntityId, SceneEntity>;
16
+ /**
17
+ * Resolves every point to coordinates. A point is simply absent from the
18
+ * result when it cannot be resolved — its object was deleted, its two objects
19
+ * became parallel so the intersection vanished, or its origins form a cycle.
20
+ * Callers treat "absent" as "not on screen": renderers skip it, validation
21
+ * skips candidates and constructions built on it. Nothing throws, because a
22
+ * student mid-construction is allowed to have a figure that briefly makes no
23
+ * sense.
24
+ *
25
+ * Given points come from `exercise`, not from `geometry` — a pinned given is
26
+ * placed by the exercise whatever a submitted attempt claims, which is a
27
+ * grading-integrity rule and is enforced while the context is indexed.
28
+ *
29
+ * Iteration order is part of the contract: pinned givens, then draggable
30
+ * givens, then the attempt's own points. `findPointAt()` in the student store
31
+ * promotes the first point within reuse tolerance, so the order decides which
32
+ * point a revealed answer lands on.
33
+ */
34
+ export declare function resolvePoints(exercise: GeometryExercise, geometry: GeometryState): ReadonlyMap<PointId, Point>;
35
+ export declare function resolvePoint(exercise: GeometryExercise, geometry: GeometryState, id: PointId): Point | null;
36
+ /**
37
+ * Every point an exercise places on its own, with no attempt against it — what
38
+ * the teacher canvas draws and what a revealed answer is measured against.
39
+ *
40
+ * A v1 given carried its coordinates and needed no resolution; a v2 exercise
41
+ * entity is a definition, so a given point sitting on a given segment has a
42
+ * position only once the graph has been walked (M2.6.c.1).
43
+ */
44
+ export declare function resolveExercisePoints(exercise: GeometryExercise): ReadonlyMap<PointId, Point>;
45
+ /**
46
+ * The same walk, kept whole rather than reduced to its points: a teacher-side
47
+ * caller that also needs presentation — which is every renderer, since M2.G.4
48
+ * routes drawing through the capability triple — would otherwise index the
49
+ * exercise a second time to answer what the context already knows.
50
+ */
51
+ export declare function exerciseGeometryContext(exercise: GeometryExercise): IndexedGeometryContext;
52
+ //# sourceMappingURL=resolvePoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvePoints.d.ts","sourceRoot":"","sources":["../../src/state/resolvePoints.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAwB,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAErF;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,GACtB,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAS5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,GACtB,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAO7B;AAGD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,OAAO,GACV,KAAK,GAAG,IAAI,CAEd;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAE7F;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,sBAAsB,CAE1F"}
@@ -0,0 +1,30 @@
1
+ import { EntityId } from '../geometry/entityModel.cjs';
2
+ import { GeometryState } from '../schemas/geometryState.schema.cjs';
3
+ /**
4
+ * What a completed student action did to the attempt (RFC 0005 § Decision 2).
5
+ * Each code maps to a row of ADR 0009's student-mutation inventory. The list
6
+ * may grow additively, so a consumer treats a value it does not know as a
7
+ * generic change.
8
+ */
9
+ export type StudentGeometryAction = 'point-placed' | 'point-promoted' | 'segment-created' | 'line-created' | 'point-moved' | 'deleted' | 'undo' | 'redo' | 'reset' | 'revealed';
10
+ export interface StudentGeometryChangeMeta {
11
+ action: StudentGeometryAction;
12
+ entityIds: string[];
13
+ }
14
+ /**
15
+ * The store's record of its last completed action. `sequence` rises by one per
16
+ * action on that store, so two identical actions in a row are still two
17
+ * receipts. Delivery metadata, not a command log: only the latest is kept, and
18
+ * it is never serialized or put in history.
19
+ */
20
+ export interface StudentAttemptChangeReceipt extends StudentGeometryChangeMeta {
21
+ sequence: number;
22
+ }
23
+ export declare function sameData(a: unknown, b: unknown): boolean;
24
+ /**
25
+ * The ids whose definition, presentation entry or answer membership differs
26
+ * between two attempts — what an undo, a redo, a reset or a reveal changed.
27
+ * Ordered by first appearance: the earlier attempt's entities, presentation and
28
+ * answers, then the later one's.
29
+ */
30
+ export declare function changedEntityIds(before: GeometryState, after: GeometryState): EntityId[];
@@ -0,0 +1,31 @@
1
+ import { EntityId } from '../geometry/entityModel.js';
2
+ import { GeometryState } from '../schemas/geometryState.schema.js';
3
+ /**
4
+ * What a completed student action did to the attempt (RFC 0005 § Decision 2).
5
+ * Each code maps to a row of ADR 0009's student-mutation inventory. The list
6
+ * may grow additively, so a consumer treats a value it does not know as a
7
+ * generic change.
8
+ */
9
+ export type StudentGeometryAction = 'point-placed' | 'point-promoted' | 'segment-created' | 'line-created' | 'point-moved' | 'deleted' | 'undo' | 'redo' | 'reset' | 'revealed';
10
+ export interface StudentGeometryChangeMeta {
11
+ action: StudentGeometryAction;
12
+ entityIds: string[];
13
+ }
14
+ /**
15
+ * The store's record of its last completed action. `sequence` rises by one per
16
+ * action on that store, so two identical actions in a row are still two
17
+ * receipts. Delivery metadata, not a command log: only the latest is kept, and
18
+ * it is never serialized or put in history.
19
+ */
20
+ export interface StudentAttemptChangeReceipt extends StudentGeometryChangeMeta {
21
+ sequence: number;
22
+ }
23
+ export declare function sameData(a: unknown, b: unknown): boolean;
24
+ /**
25
+ * The ids whose definition, presentation entry or answer membership differs
26
+ * between two attempts — what an undo, a redo, a reset or a reveal changed.
27
+ * Ordered by first appearance: the earlier attempt's entities, presentation and
28
+ * answers, then the later one's.
29
+ */
30
+ export declare function changedEntityIds(before: GeometryState, after: GeometryState): EntityId[];
31
+ //# sourceMappingURL=attemptChange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attemptChange.d.ts","sourceRoot":"","sources":["../../src/store/attemptChange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC7B,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,UAAU,CAAA;AAEd,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,qBAAqB,CAAA;IAI7B,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,2BAA4B,SAAQ,yBAAyB;IAC5E,QAAQ,EAAE,MAAM,CAAA;CACjB;AAMD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAYxD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,QAAQ,EAAE,CAexF"}
@@ -0,0 +1,35 @@
1
+ import { EntityId, PointDefinition } from '../geometry/entityModel.cjs';
2
+ import { PointId } from '../geometry/point.cjs';
3
+ /**
4
+ * An end of a construction, before the engine has decided what it costs. A
5
+ * gesture reports where it landed; whether that is a point yet is not the
6
+ * gesture's business.
7
+ *
8
+ * These types live apart from the store because the gesture layer speaks them
9
+ * too — `useConnectionPreview` resolves a release into one of these and hands
10
+ * it on, which is how the preview stopped creating entities of its own.
11
+ */
12
+ export type ConstructionEndpoint = {
13
+ kind: 'existing';
14
+ id: PointId;
15
+ } | {
16
+ kind: 'create';
17
+ origin: PointDefinition;
18
+ };
19
+ export interface ConstructionCommand {
20
+ tool: 'segment' | 'line';
21
+ from: ConstructionEndpoint;
22
+ to: ConstructionEndpoint;
23
+ }
24
+ /**
25
+ * Why the last construction attempt made nothing new: the document already
26
+ * declares that construction, as `entityId` (RFC 0004 § Decision 1). A code
27
+ * rather than a sentence, so a host can say it in its own language.
28
+ *
29
+ * Transient, like the rest of a store's gesture state: never serialized and
30
+ * never in history.
31
+ */
32
+ export interface ConstructionNotice {
33
+ code: 'duplicate-construction';
34
+ entityId: EntityId;
35
+ }
@@ -0,0 +1,36 @@
1
+ import { EntityId, PointDefinition } from '../geometry/entityModel.js';
2
+ import { PointId } from '../geometry/point.js';
3
+ /**
4
+ * An end of a construction, before the engine has decided what it costs. A
5
+ * gesture reports where it landed; whether that is a point yet is not the
6
+ * gesture's business.
7
+ *
8
+ * These types live apart from the store because the gesture layer speaks them
9
+ * too — `useConnectionPreview` resolves a release into one of these and hands
10
+ * it on, which is how the preview stopped creating entities of its own.
11
+ */
12
+ export type ConstructionEndpoint = {
13
+ kind: 'existing';
14
+ id: PointId;
15
+ } | {
16
+ kind: 'create';
17
+ origin: PointDefinition;
18
+ };
19
+ export interface ConstructionCommand {
20
+ tool: 'segment' | 'line';
21
+ from: ConstructionEndpoint;
22
+ to: ConstructionEndpoint;
23
+ }
24
+ /**
25
+ * Why the last construction attempt made nothing new: the document already
26
+ * declares that construction, as `entityId` (RFC 0004 § Decision 1). A code
27
+ * rather than a sentence, so a host can say it in its own language.
28
+ *
29
+ * Transient, like the rest of a store's gesture state: never serialized and
30
+ * never in history.
31
+ */
32
+ export interface ConstructionNotice {
33
+ code: 'duplicate-construction';
34
+ entityId: EntityId;
35
+ }
36
+ //# sourceMappingURL=constructionCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructionCommand.d.ts","sourceRoot":"","sources":["../../src/store/constructionCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GAIjC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CAAA;AAE/C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAA;IACxB,IAAI,EAAE,oBAAoB,CAAA;IAC1B,EAAE,EAAE,oBAAoB,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,wBAAwB,CAAA;IAC9B,QAAQ,EAAE,QAAQ,CAAA;CACnB"}
@@ -0,0 +1,21 @@
1
+ import { EntityDefinition, EntityId } from '../geometry/entityModel.cjs';
2
+ import { PointId } from '../geometry/point.cjs';
3
+ import { ConstructionEndpoint, ConstructionNotice } from './constructionCommand.cjs';
4
+ type EntityRecord = Readonly<Record<EntityId, EntityDefinition>>;
5
+ /**
6
+ * The first entity in `entities`, in record order, that declares the same
7
+ * construction as `candidate`, or `null`. `owns` narrows the search to one
8
+ * ownership domain: a student's answer may repeat a given, never their own work.
9
+ */
10
+ export declare function findSameConstruction(entities: EntityRecord, candidate: EntityDefinition, owns?: (id: EntityId) => boolean): EntityId | null;
11
+ /**
12
+ * The points a connection's `create` endpoints should land on instead of new
13
+ * ones, one answer per endpoint (`null` for an `existing` end, or one with
14
+ * nothing to land on): the first point with exactly that origin anywhere on
15
+ * the canvas. Givens come first — read through the attempt, since a moved
16
+ * draggable given is where the attempt says — then the attempt's own points in
17
+ * record order. Both ends in one pass, because a gesture asks for both at once.
18
+ */
19
+ export declare function findEndpointsInScene(endpoints: readonly ConstructionEndpoint[], givens: EntityRecord, attempt?: EntityRecord): (PointId | null)[];
20
+ export declare function duplicateOf(entityId: EntityId): ConstructionNotice;
21
+ export {};
@@ -0,0 +1,22 @@
1
+ import { EntityDefinition, EntityId } from '../geometry/entityModel.js';
2
+ import { PointId } from '../geometry/point.js';
3
+ import { ConstructionEndpoint, ConstructionNotice } from './constructionCommand.js';
4
+ type EntityRecord = Readonly<Record<EntityId, EntityDefinition>>;
5
+ /**
6
+ * The first entity in `entities`, in record order, that declares the same
7
+ * construction as `candidate`, or `null`. `owns` narrows the search to one
8
+ * ownership domain: a student's answer may repeat a given, never their own work.
9
+ */
10
+ export declare function findSameConstruction(entities: EntityRecord, candidate: EntityDefinition, owns?: (id: EntityId) => boolean): EntityId | null;
11
+ /**
12
+ * The points a connection's `create` endpoints should land on instead of new
13
+ * ones, one answer per endpoint (`null` for an `existing` end, or one with
14
+ * nothing to land on): the first point with exactly that origin anywhere on
15
+ * the canvas. Givens come first — read through the attempt, since a moved
16
+ * draggable given is where the attempt says — then the attempt's own points in
17
+ * record order. Both ends in one pass, because a gesture asks for both at once.
18
+ */
19
+ export declare function findEndpointsInScene(endpoints: readonly ConstructionEndpoint[], givens: EntityRecord, attempt?: EntityRecord): (PointId | null)[];
20
+ export declare function duplicateOf(entityId: EntityId): ConstructionNotice;
21
+ export {};
22
+ //# sourceMappingURL=constructionIdentity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructionIdentity.d.ts","sourceRoot":"","sources":["../../src/store/constructionIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AASrF,KAAK,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAA;AA0ChE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,gBAAgB,EAC3B,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,GAC/B,QAAQ,GAAG,IAAI,CASjB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,oBAAoB,EAAE,EAC1C,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,YAAiB,GACzB,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CA+BpB;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,kBAAkB,CAElE"}
@@ -0,0 +1,6 @@
1
+ export interface Store<T> {
2
+ getState(): T;
3
+ setState(update: Partial<T> | ((state: T) => Partial<T>)): void;
4
+ subscribe(listener: (state: T, previousState: T) => void): () => void;
5
+ }
6
+ export declare function createStore<T extends object>(initialState: T): Store<T>;
@@ -0,0 +1,7 @@
1
+ export interface Store<T> {
2
+ getState(): T;
3
+ setState(update: Partial<T> | ((state: T) => Partial<T>)): void;
4
+ subscribe(listener: (state: T, previousState: T) => void): () => void;
5
+ }
6
+ export declare function createStore<T extends object>(initialState: T): Store<T>;
7
+ //# sourceMappingURL=createStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStore.d.ts","sourceRoot":"","sources":["../../src/store/createStore.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,QAAQ,IAAI,CAAC,CAAA;IACb,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC/D,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CACtE;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAqBvE"}
@@ -0,0 +1,2 @@
1
+ export declare const MAX_HISTORY_ENTRIES = 100;
2
+ export declare function pushHistory<T>(past: readonly T[], entry: T): T[];
@@ -0,0 +1,3 @@
1
+ export declare const MAX_HISTORY_ENTRIES = 100;
2
+ export declare function pushHistory<T>(past: readonly T[], entry: T): T[];
3
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/store/history.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAGhE"}
@@ -0,0 +1,151 @@
1
+ import { GeometryExercise } from '../schemas/exercise.schema.cjs';
2
+ import { GeometryState } from '../schemas/geometryState.schema.cjs';
3
+ import { PointDefinition } from '../geometry/entityModel.cjs';
4
+ import { ObjectTypeName } from '../schemas/objectTypeName.schema.cjs';
5
+ import { Point, PointId } from '../geometry/point.cjs';
6
+ import { RevealedAnswerShape } from '../validation/types.cjs';
7
+ import { ConstructionCommand, ConstructionNotice } from './constructionCommand.cjs';
8
+ import { StudentAttemptChangeReceipt } from './attemptChange.cjs';
9
+ import { Store } from './createStore.cjs';
10
+ export type { StudentAttemptChangeReceipt, StudentGeometryAction, StudentGeometryChangeMeta, } from './attemptChange.cjs';
11
+ export type { ConstructionCommand, ConstructionEndpoint, ConstructionNotice, } from './constructionCommand.cjs';
12
+ export interface StudentState {
13
+ exercise: GeometryExercise;
14
+ geometry: GeometryState;
15
+ pendingObjectType: ObjectTypeName | null;
16
+ pendingFirstPointId: PointId | null;
17
+ selectedObjectId: string | null;
18
+ past: GeometryState[];
19
+ future: GeometryState[];
20
+ coalesceTag: string | null;
21
+ interactionEpoch?: number;
22
+ constructionNotice?: ConstructionNotice | null;
23
+ readOnly?: boolean;
24
+ lastAttemptChange?: StudentAttemptChangeReceipt | null;
25
+ }
26
+ export interface StudentRemovalImpact {
27
+ constructionIds: string[];
28
+ pointIds: string[];
29
+ }
30
+ /**
31
+ * One store per attempt. Pass `savedGeometry` to resume a stored attempt —
32
+ * validate it first with validateGeometryStateJson(), which checks it against
33
+ * this exercise. A resumed attempt starts with empty history: undo must not
34
+ * reach back past what the student can see.
35
+ *
36
+ * The store holds the exercise without its authored `solution` (ADR 0015):
37
+ * the canonical answer is never student state.
38
+ */
39
+ export declare function createStudentStore(exercise: GeometryExercise, savedGeometry?: GeometryState): Store<StudentState>;
40
+ /**
41
+ * Locks or unlocks the attempt (RFC 0005 § Decision 3). While read-only every
42
+ * public student action that could change attempt data does nothing and no
43
+ * tool can be armed; selection stays available for inspection.
44
+ *
45
+ * Locking disarms the tool and clears the pending endpoint, the selection and
46
+ * the notice, and moves the epoch so a late pointer release writes nothing. A
47
+ * drag whose frames already moved a point keeps that position, its one undo
48
+ * entry and its one `point-moved` receipt, all in the locking transition.
49
+ * Unlocking moves the epoch as well, so a contact pressed during the lock
50
+ * cannot start editing once it lifts; no point is draggable while locked.
51
+ * `replaceStudentAttempt()` and `replaceStudentSession()` still work while
52
+ * locked; `store.setState()` is not guarded at all.
53
+ */
54
+ export declare function setStudentReadOnly(store: Store<StudentState>, readOnly: boolean): void;
55
+ /**
56
+ * Host authority: installs `attempt` on the same store, as a controlled value
57
+ * that differs from the current one (RFC 0005 § Decision 2). Both history
58
+ * stacks and all interaction state are cleared and the epoch moves, so it
59
+ * cannot be undone and a live gesture is dropped. Works while read-only, and is
60
+ * not a student action: `lastAttemptChange` is left as it was, and a drag it
61
+ * interrupts gets no receipt.
62
+ *
63
+ * The attempt is taken as already parsed and checked against this exercise —
64
+ * validate untrusted input first, as for `createStudentStore()`.
65
+ */
66
+ export declare function replaceStudentAttempt(store: Store<StudentState>, attempt: GeometryState): void;
67
+ /**
68
+ * Host authority: installs a different exercise and its attempt together, in
69
+ * one transition, so no subscriber ever sees the new exercise with the old
70
+ * attempt. An absent attempt is a fresh empty one. Otherwise it behaves as
71
+ * `replaceStudentAttempt()` does: same store, history and interaction state
72
+ * cleared, epoch moved, read-only kept, no receipt, and parsed input expected.
73
+ * As at creation, the authored `solution` is left out of the store.
74
+ */
75
+ export declare function replaceStudentSession(store: Store<StudentState>, exercise: GeometryExercise, attempt?: GeometryState): void;
76
+ export declare function selectStudentObjectType(store: Store<StudentState>, type: ObjectTypeName | null): void;
77
+ /**
78
+ * Abandons a click-click construction in progress: the first endpoint is
79
+ * forgotten and the tool stays armed. What a canvas calls when a gesture is
80
+ * cancelled — a system gesture, a second finger, a release off the canvas —
81
+ * so the next tap starts a construction rather than finishing a stale one.
82
+ */
83
+ export declare function cancelStudentConstruction(store: Store<StudentState>): void;
84
+ export declare function undoStudentChange(store: Store<StudentState>): void;
85
+ export declare function redoStudentChange(store: Store<StudentState>): void;
86
+ /**
87
+ * Starts the attempt over on the same store (RFC 0004 § Decision 2): the
88
+ * exercise and its givens stay, and everything the student did goes — their
89
+ * constructions, any given they dragged (it returns to where the teacher put
90
+ * it), the tool, the selection, a pending endpoint and the notice. A resumed
91
+ * attempt resets to empty, not to what was saved.
92
+ *
93
+ * Not undoable: both history stacks are emptied, so neither Undo nor Redo can
94
+ * bring the old attempt back. The store object and its subscribers are kept.
95
+ * The epoch moves even when the attempt was already empty, which is how a
96
+ * canvas drops a gesture in flight, and a host clearing checked feedback on a
97
+ * geometry or epoch change sees every reset. Nothing saved outside the store
98
+ * is touched.
99
+ *
100
+ * A student action: it does nothing while read-only, and it records a `reset`
101
+ * receipt even for an attempt that was already empty.
102
+ */
103
+ export declare function resetStudentAttempt(store: Store<StudentState>): void;
104
+ export declare function addStudentPoint(store: Store<StudentState>, definition: PointDefinition, countsAsConstruction?: boolean): PointId | null;
105
+ export declare function promoteStudentPoint(store: Store<StudentState>, pointId: PointId): void;
106
+ /**
107
+ * Drags a point to `point`, respecting what the point is:
108
+ * - free: takes the new coordinates;
109
+ * - on-object: slides along its object, so the drag re-parameterizes rather
110
+ * than detaching it (a point placed on a line stays on that line);
111
+ * - intersection: ignored — its position is its parents' to decide.
112
+ */
113
+ export declare function moveStudentPoint(store: Store<StudentState>, pointId: PointId, point: Point): void;
114
+ export declare function isStudentPointDraggable(state: StudentState, pointId: PointId): boolean;
115
+ export declare function endStudentPointDrag(store: Store<StudentState>): void;
116
+ /**
117
+ * The one way a gesture becomes geometry (RFC 0001 § 11).
118
+ *
119
+ * Two rules the pre-M2.9 code broke, both of them here now:
120
+ *
121
+ * 1. **One gesture is one commit is one undo.** Every entity the command needs
122
+ * is written inside a single `commitGeometry()`, so a segment that had to
123
+ * invent its endpoint still costs the student exactly one undo — and undoing
124
+ * it takes the invented point with it.
125
+ * 2. **An invented endpoint is not part of the answer.** Only the shape the
126
+ * student drew is, which is what keeps a `create` goal from being satisfied
127
+ * by scaffolding they never chose to make.
128
+ *
129
+ * A third since RFC 0004: **a construction the student already built is not
130
+ * built twice.** The whole staged document is dropped — no invented point, no
131
+ * history entry, the redo stack intact — and `constructionNotice` names the one
132
+ * that is there.
133
+ */
134
+ export declare function executeConstruction(store: Store<StudentState>, command: ConstructionCommand): void;
135
+ export declare function pickStudentPoint(store: Store<StudentState>, pointId: PointId): void;
136
+ export declare function selectStudentObject(store: Store<StudentState>, id: string | null): void;
137
+ export declare function isStudentOwned(state: StudentState, id: string): boolean;
138
+ /**
139
+ * Everything that disappears along with `id`, the target included, the same
140
+ * way getGivenRemovalImpact() reports cascades on the teacher side.
141
+ *
142
+ * The cascade follows the dependency graph upwards: a construction needs its
143
+ * endpoints, and a derived point needs its objects, so deleting a segment can
144
+ * strip an intersection point, which can strip a construction that used it,
145
+ * and so on. Since M2.2 that is one walk of the context's reverse edges — the
146
+ * fixpoint loop it replaces rescanned both documents once per entity it
147
+ * removed.
148
+ */
149
+ export declare function getStudentRemovalImpact(state: StudentState, id: string): StudentRemovalImpact;
150
+ export declare function deleteStudentObject(store: Store<StudentState>, id: string): void;
151
+ export declare function revealStudentAnswer(store: Store<StudentState>, shape: RevealedAnswerShape): void;