@nakafa/aksara-contracts 6.4.0 → 7.0.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 (117) hide show
  1. package/dist/assessment/catalog.d.ts +30 -6
  2. package/dist/assessment/catalog.js +33 -10
  3. package/dist/assessment/choice.d.ts +10 -0
  4. package/dist/assessment/closure.d.ts +2 -1
  5. package/dist/assessment/closure.js +43 -62
  6. package/dist/assessment/document.d.ts +18 -0
  7. package/dist/assessment/document.js +10 -0
  8. package/dist/assessment/figure.d.ts +47605 -1555
  9. package/dist/assessment/figure.js +14 -217
  10. package/dist/assessment/hash.d.ts +274 -4
  11. package/dist/assessment/inline.d.ts +25 -0
  12. package/dist/assessment/inline.js +22 -3
  13. package/dist/assessment/interaction.d.ts +10 -0
  14. package/dist/assessment/item.d.ts +864 -0
  15. package/dist/assessment/item.js +10 -2
  16. package/dist/assessment/locales.d.ts +10 -0
  17. package/dist/assessment/locales.js +58 -0
  18. package/dist/assessment/paper.d.ts +1349 -12
  19. package/dist/assessment/paper.js +93 -9
  20. package/dist/assessment/part.d.ts +5 -0
  21. package/dist/assessment/profile.d.ts +4 -4
  22. package/dist/assessment/rows.d.ts +1409 -0
  23. package/dist/assessment/rows.js +44 -0
  24. package/dist/assessment/scalar.d.ts +1 -1
  25. package/dist/assessment/scoring.d.ts +1 -1
  26. package/dist/assessment/snapshot.d.ts +376 -20
  27. package/dist/assessment/structure.d.ts +6 -0
  28. package/dist/assessment/structure.js +22 -2
  29. package/dist/locale.d.ts +9 -9
  30. package/dist/locale.js +4 -3
  31. package/dist/program/snapshot/hash.d.ts +2 -2
  32. package/dist/program/snapshot/spec.d.ts +2 -2
  33. package/dist/projection/material.d.ts +10 -0
  34. package/dist/projection/material.js +1 -1
  35. package/dist/quran/attribution.d.ts +2 -2
  36. package/dist/quran/identity.d.ts +31 -10
  37. package/dist/quran/identity.js +15 -3
  38. package/dist/quran/provenance.d.ts +16 -16
  39. package/dist/quran/provenance.js +4 -1
  40. package/dist/quran/snapshot/hash.d.ts +2 -2
  41. package/dist/quran/snapshot/row/hash.d.ts +48 -15
  42. package/dist/quran/snapshot/row.d.ts +18 -8
  43. package/dist/quran/snapshot/spec.d.ts +2 -2
  44. package/dist/quran/source.d.ts +17 -7
  45. package/dist/quran/source.js +13 -1
  46. package/dist/quran/spec.d.ts +4 -4
  47. package/dist/quran/spec.js +2 -1
  48. package/dist/release/current/evidence.d.ts +9 -9
  49. package/dist/release/current/state.d.ts +11 -11
  50. package/dist/release/hash.d.ts +2 -2
  51. package/dist/release/identity.d.ts +1 -1
  52. package/dist/release/lifecycle.d.ts +7 -7
  53. package/dist/release/policy.d.ts +1 -1
  54. package/dist/release/snapshot/data.d.ts +37 -11
  55. package/dist/release/snapshot/evidence/assessment.d.ts +1 -1
  56. package/dist/release/snapshot/evidence/program.d.ts +1 -1
  57. package/dist/release/snapshot/evidence/quran.d.ts +1 -1
  58. package/dist/release/snapshot/evidence.d.ts +3 -3
  59. package/dist/release/snapshot/verify.d.ts +180 -12
  60. package/dist/release/spec.d.ts +13 -13
  61. package/dist/release/verify.d.ts +2 -2
  62. package/dist/runtime/spec.d.ts +6 -6
  63. package/dist/runtime/verify.d.ts +4 -4
  64. package/dist/transport/group.d.ts +111 -33
  65. package/dist/transport/request.d.ts +1174 -114
  66. package/dist/transport/response.d.ts +64 -64
  67. package/dist/transport/snapshot.d.ts +74 -22
  68. package/dist/visual/base/layout.d.ts +27 -0
  69. package/dist/visual/base/layout.js +35 -0
  70. package/dist/visual/base/math.d.ts +523 -0
  71. package/dist/visual/base/math.js +72 -0
  72. package/dist/visual/base/media.d.ts +13 -0
  73. package/dist/visual/base/media.js +25 -0
  74. package/dist/visual/biology.d.ts +203 -0
  75. package/dist/visual/biology.js +108 -0
  76. package/dist/visual/card.d.ts +32 -0
  77. package/dist/visual/card.js +30 -0
  78. package/dist/visual/catalog.d.ts +28633 -0
  79. package/dist/visual/catalog.js +73 -0
  80. package/dist/visual/chemistry/atom.d.ts +79 -0
  81. package/dist/visual/chemistry/atom.js +109 -0
  82. package/dist/visual/chemistry/electron.d.ts +41 -0
  83. package/dist/visual/chemistry/electron.js +69 -0
  84. package/dist/visual/chemistry/laws.d.ts +86 -0
  85. package/dist/visual/chemistry/laws.js +117 -0
  86. package/dist/visual/chemistry/particles.d.ts +114 -0
  87. package/dist/visual/chemistry/particles.js +149 -0
  88. package/dist/visual/chemistry/periodic.d.ts +52 -0
  89. package/dist/visual/chemistry/periodic.js +85 -0
  90. package/dist/visual/chemistry/reaction.d.ts +60 -0
  91. package/dist/visual/chemistry/reaction.js +76 -0
  92. package/dist/visual/entry.d.ts +42 -0
  93. package/dist/visual/entry.js +48 -0
  94. package/dist/visual/mathematics/chart.d.ts +30 -0
  95. package/dist/{assessment → visual/mathematics}/chart.js +26 -18
  96. package/dist/visual/mathematics/charts.d.ts +118 -0
  97. package/dist/visual/mathematics/charts.js +100 -0
  98. package/dist/visual/mathematics/function.d.ts +82 -0
  99. package/dist/visual/mathematics/function.js +102 -0
  100. package/dist/visual/mathematics/geometry.d.ts +222 -0
  101. package/dist/visual/mathematics/geometry.js +81 -0
  102. package/dist/visual/mathematics/line.d.ts +179 -0
  103. package/dist/visual/mathematics/line.js +156 -0
  104. package/dist/visual/mathematics/number.d.ts +21 -0
  105. package/dist/visual/mathematics/number.js +53 -0
  106. package/dist/visual/physics/measurement.d.ts +66 -0
  107. package/dist/visual/physics/measurement.js +85 -0
  108. package/dist/visual/physics/motion.d.ts +85 -0
  109. package/dist/visual/physics/motion.js +110 -0
  110. package/dist/visual/physics/parabolic.d.ts +42 -0
  111. package/dist/visual/physics/parabolic.js +56 -0
  112. package/dist/visual/physics/velocity.d.ts +112 -0
  113. package/dist/visual/physics/velocity.js +144 -0
  114. package/dist/visual/politics.d.ts +92 -0
  115. package/dist/visual/politics.js +76 -0
  116. package/package.json +13 -5
  117. package/dist/assessment/chart.d.ts +0 -62
@@ -0,0 +1,222 @@
1
+ import { Schema } from "effect";
2
+ import { type RichSlot } from "#contracts/visual/card";
3
+ /**
4
+ * The visuals of lines, numbers, and circles. The exact trigonometric values
5
+ * of a unit circle are what a learner is asked to find, so they are answer
6
+ * state.
7
+ */
8
+ export declare function geometryVisuals<E>(rich: RichSlot<E>): {
9
+ LineEquation: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
10
+ readonly description: RichSlot<E>;
11
+ readonly title: RichSlot<E>;
12
+ readonly cameraPosition: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
13
+ readonly cameraTarget: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
14
+ readonly data: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
15
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
16
+ readonly cone: Schema.optionalKey<Schema.Struct<{
17
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
18
+ readonly size: Schema.optionalKey<Schema.Finite>;
19
+ }>>;
20
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
21
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
22
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
23
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
24
+ }>>;
25
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
26
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
27
+ readonly at: Schema.optionalKey<Schema.Int>;
28
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
29
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
30
+ readonly text: RichSlot<E>;
31
+ }>>>;
32
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
33
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
34
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
35
+ readonly points: Schema.NonEmptyArray<Schema.Struct<{
36
+ readonly x: Schema.Finite;
37
+ readonly y: Schema.Finite;
38
+ readonly z: Schema.Finite;
39
+ }>>;
40
+ readonly smooth: Schema.optionalKey<Schema.Boolean>;
41
+ }>, Schema.Struct<{
42
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
43
+ readonly cone: Schema.optionalKey<Schema.Struct<{
44
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
45
+ readonly size: Schema.optionalKey<Schema.Finite>;
46
+ }>>;
47
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
48
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
49
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
50
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
51
+ }>>;
52
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
53
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
54
+ readonly at: Schema.optionalKey<Schema.Int>;
55
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
56
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
57
+ readonly text: RichSlot<E>;
58
+ }>>>;
59
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
60
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
61
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
62
+ readonly curve: Schema.Struct<{
63
+ readonly amplitude: Schema.Finite;
64
+ readonly domain: Schema.Tuple<readonly [Schema.Finite, Schema.Finite]>;
65
+ readonly frequency: Schema.Finite;
66
+ readonly kind: Schema.Literals<readonly ["sin", "cos", "tan"]>;
67
+ readonly phase: Schema.Finite;
68
+ readonly samples: Schema.optionalKey<Schema.Int>;
69
+ readonly shift: Schema.Finite;
70
+ }>;
71
+ }>, Schema.Struct<{
72
+ readonly center: Schema.optionalKey<Schema.Struct<{
73
+ readonly x: Schema.Finite;
74
+ readonly y: Schema.Finite;
75
+ readonly z: Schema.Finite;
76
+ }>>;
77
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
78
+ readonly height: Schema.Finite;
79
+ readonly kind: Schema.Literal<"cuboid">;
80
+ readonly length: Schema.Finite;
81
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
82
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
83
+ readonly width: Schema.Finite;
84
+ }>, Schema.Struct<{
85
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
86
+ readonly cone: Schema.optionalKey<Schema.Struct<{
87
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
88
+ readonly size: Schema.optionalKey<Schema.Finite>;
89
+ }>>;
90
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
91
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
92
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
93
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
94
+ }>>;
95
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
96
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
97
+ readonly at: Schema.optionalKey<Schema.Int>;
98
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
99
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
100
+ readonly text: RichSlot<E>;
101
+ }>>>;
102
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
103
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
104
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
105
+ readonly kind: Schema.Literal<"circle-outline">;
106
+ readonly radius: Schema.Finite;
107
+ }>, Schema.Struct<{
108
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
109
+ readonly cone: Schema.optionalKey<Schema.Struct<{
110
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
111
+ readonly size: Schema.optionalKey<Schema.Finite>;
112
+ }>>;
113
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
114
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
115
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
116
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
117
+ }>>;
118
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
119
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
120
+ readonly at: Schema.optionalKey<Schema.Int>;
121
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
122
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
123
+ readonly text: RichSlot<E>;
124
+ }>>>;
125
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
126
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
127
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
128
+ readonly radius: Schema.Finite;
129
+ readonly startDegrees: Schema.Finite;
130
+ readonly sweepDegrees: Schema.Finite;
131
+ readonly kind: Schema.Literal<"circle-chord">;
132
+ }>, Schema.Struct<{
133
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
134
+ readonly cone: Schema.optionalKey<Schema.Struct<{
135
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
136
+ readonly size: Schema.optionalKey<Schema.Finite>;
137
+ }>>;
138
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
139
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
140
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
141
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
142
+ }>>;
143
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
144
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
145
+ readonly at: Schema.optionalKey<Schema.Int>;
146
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
147
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
148
+ readonly text: RichSlot<E>;
149
+ }>>>;
150
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
151
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
152
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
153
+ readonly degrees: Schema.Finite;
154
+ readonly kind: Schema.Literal<"circle-radius">;
155
+ readonly radius: Schema.Finite;
156
+ }>, Schema.Struct<{
157
+ readonly radius: Schema.Finite;
158
+ readonly startDegrees: Schema.Finite;
159
+ readonly sweepDegrees: Schema.Finite;
160
+ readonly color: Schema.Trimmed;
161
+ readonly kind: Schema.Literal<"circle-arc" | "circle-segment">;
162
+ readonly label: Schema.optionalKey<Schema.Struct<{
163
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
164
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
165
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
166
+ readonly text: RichSlot<E>;
167
+ readonly progress: Schema.optionalKey<Schema.Finite>;
168
+ }>>;
169
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
170
+ readonly segments: Schema.optionalKey<Schema.Int>;
171
+ }>, Schema.Struct<{
172
+ readonly radius: Schema.Finite;
173
+ readonly startDegrees: Schema.Finite;
174
+ readonly sweepDegrees: Schema.Finite;
175
+ readonly color: Schema.Trimmed;
176
+ readonly kind: Schema.Literal<"circle-arc" | "circle-segment">;
177
+ readonly label: Schema.optionalKey<Schema.Struct<{
178
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
179
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
180
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
181
+ readonly text: RichSlot<E>;
182
+ readonly progress: Schema.optionalKey<Schema.Finite>;
183
+ }>>;
184
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
185
+ readonly segments: Schema.optionalKey<Schema.Int>;
186
+ }>]>>;
187
+ readonly showZAxis: Schema.optionalKey<Schema.Boolean>;
188
+ }>>;
189
+ NumberLine: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
190
+ readonly description: RichSlot<E>;
191
+ readonly title: RichSlot<E>;
192
+ readonly max: Schema.optionalKey<Schema.Finite>;
193
+ readonly min: Schema.optionalKey<Schema.Finite>;
194
+ readonly segments: Schema.NonEmptyArray<Schema.Struct<{
195
+ readonly backgroundColor: Schema.optionalKey<Schema.Literal<"transparent">>;
196
+ readonly end: Schema.optionalKey<Schema.Finite>;
197
+ readonly endInclusive: Schema.optionalKey<Schema.Boolean>;
198
+ readonly endLabel: Schema.optionalKey<RichSlot<E>>;
199
+ readonly label: Schema.optionalKey<RichSlot<E>>;
200
+ readonly shaded: Schema.optionalKey<Schema.Boolean>;
201
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
202
+ readonly start: Schema.optionalKey<Schema.Finite>;
203
+ readonly startInclusive: Schema.optionalKey<Schema.Boolean>;
204
+ readonly startLabel: Schema.optionalKey<RichSlot<E>>;
205
+ }>>;
206
+ }>>;
207
+ QuadraticEquationReadingRoomProblem: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
208
+ readonly description: Schema.optionalKey<RichSlot<E>>;
209
+ readonly heightLabel: RichSlot<E>;
210
+ readonly widthLabel: RichSlot<E>;
211
+ }>>;
212
+ UnitCircle: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
213
+ readonly description: RichSlot<E>;
214
+ readonly title: RichSlot<E>;
215
+ readonly angle: Schema.optionalKey<Schema.Finite>;
216
+ readonly trigValues: Schema.optionalKey<Schema.Struct<{
217
+ readonly cos: Schema.optionalKey<Schema.Trimmed>;
218
+ readonly sin: Schema.optionalKey<Schema.Trimmed>;
219
+ readonly tan: Schema.optionalKey<Schema.Trimmed>;
220
+ }>>;
221
+ }>>;
222
+ };
@@ -0,0 +1,81 @@
1
+ import { Schema } from "effect";
2
+ import { LatexSchema } from "#contracts/assessment/scalar";
3
+ import { cardFields, TripleSchema, } from "#contracts/visual/card";
4
+ import { answerAt, figure } from "#contracts/visual/entry";
5
+ import { sceneLine } from "#contracts/visual/mathematics/line";
6
+ import { numberLine } from "#contracts/visual/mathematics/number";
7
+ /**
8
+ * Where the `LineEquation` card puts the camera when `cameraPosition` is left
9
+ * out: `DEFAULT_CAMERA_POSITION_X`, `_Y`, and `_Z` in
10
+ * `components/contents/mathematics/line/equation.tsx` of Nakafa's design system
11
+ * (read on 13 October 2026).
12
+ */
13
+ const DEFAULT_CAMERA_POSITION = [10, 6, 10];
14
+ /**
15
+ * Where the scene looks when `cameraTarget` is left out: the origin, as
16
+ * `DEFAULT_CAMERA_TARGET` in `components/three/camera-controls.tsx` of the
17
+ * same package says (read on 13 October 2026).
18
+ */
19
+ const DEFAULT_CAMERA_TARGET = [0, 0, 0];
20
+ /** The camera of a scene: where it sits and where it looks, each optional. */
21
+ const CameraPoseSchema = Schema.Struct({
22
+ cameraPosition: Schema.optionalKey(TripleSchema),
23
+ cameraTarget: Schema.optionalKey(TripleSchema),
24
+ });
25
+ /**
26
+ * Checks that the camera sits away from the point it looks at, with the
27
+ * renderer's defaults for a pose that is left out. A camera on its target has
28
+ * no direction to look in, and the renderer measures its zoom and its distance
29
+ * limits from that distance, which is then zero.
30
+ */
31
+ function hasCameraDistance({ cameraPosition = DEFAULT_CAMERA_POSITION, cameraTarget = DEFAULT_CAMERA_TARGET, }) {
32
+ const [x, y, z] = cameraPosition;
33
+ const [targetX, targetY, targetZ] = cameraTarget;
34
+ return x !== targetX || y !== targetY || z !== targetZ;
35
+ }
36
+ /** Props of `LineEquation`: lines, curves, and circle parts in three dimensions. */
37
+ function lineEquation(rich) {
38
+ return figure(Schema.Struct({
39
+ ...cardFields(rich),
40
+ ...CameraPoseSchema.fields,
41
+ data: Schema.NonEmptyArray(sceneLine(rich)),
42
+ showZAxis: Schema.optionalKey(Schema.Boolean),
43
+ }).check(Schema.makeFilter(hasCameraDistance, {
44
+ message: "Expected a camera that sits away from the point it looks at.",
45
+ })));
46
+ }
47
+ /** The exact sine, cosine, and tangent of the angle, each as LaTeX, such as `5/13`. */
48
+ const TrigValuesSchema = Schema.Struct({
49
+ cos: Schema.optionalKey(LatexSchema),
50
+ sin: Schema.optionalKey(LatexSchema),
51
+ tan: Schema.optionalKey(LatexSchema),
52
+ });
53
+ /** Props of `UnitCircle`: the angle in degrees and its exact values in LaTeX. */
54
+ function unitCircle(rich) {
55
+ return figure(Schema.Struct({
56
+ ...cardFields(rich),
57
+ angle: Schema.optionalKey(Schema.Finite),
58
+ trigValues: Schema.optionalKey(TrigValuesSchema),
59
+ }), answerAt(["trigValues"]));
60
+ }
61
+ /** Props of `QuadraticEquationReadingRoomProblem`: a room whose sides are unknown. */
62
+ function readingRoom(rich) {
63
+ return figure(Schema.Struct({
64
+ description: Schema.optionalKey(rich),
65
+ heightLabel: rich,
66
+ widthLabel: rich,
67
+ }));
68
+ }
69
+ /**
70
+ * The visuals of lines, numbers, and circles. The exact trigonometric values
71
+ * of a unit circle are what a learner is asked to find, so they are answer
72
+ * state.
73
+ */
74
+ export function geometryVisuals(rich) {
75
+ return {
76
+ LineEquation: lineEquation(rich),
77
+ NumberLine: numberLine(rich),
78
+ QuadraticEquationReadingRoomProblem: readingRoom(rich),
79
+ UnitCircle: unitCircle(rich),
80
+ };
81
+ }
@@ -0,0 +1,179 @@
1
+ import { Schema } from "effect";
2
+ import { type RichSlot } from "#contracts/visual/card";
3
+ /**
4
+ * One line of a `LineEquation` scene: a line through points, a curve by its
5
+ * formula, a cuboid, or a part of a circle.
6
+ */
7
+ export declare function sceneLine<E>(rich: RichSlot<E>): Schema.Union<readonly [Schema.Struct<{
8
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
9
+ readonly cone: Schema.optionalKey<Schema.Struct<{
10
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
11
+ readonly size: Schema.optionalKey<Schema.Finite>;
12
+ }>>;
13
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
14
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
15
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
16
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
17
+ }>>;
18
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
19
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
20
+ readonly at: Schema.optionalKey<Schema.Int>;
21
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
22
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
23
+ readonly text: RichSlot<E>;
24
+ }>>>;
25
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
26
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
27
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
28
+ readonly points: Schema.NonEmptyArray<Schema.Struct<{
29
+ readonly x: Schema.Finite;
30
+ readonly y: Schema.Finite;
31
+ readonly z: Schema.Finite;
32
+ }>>;
33
+ readonly smooth: Schema.optionalKey<Schema.Boolean>;
34
+ }>, Schema.Struct<{
35
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
36
+ readonly cone: Schema.optionalKey<Schema.Struct<{
37
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
38
+ readonly size: Schema.optionalKey<Schema.Finite>;
39
+ }>>;
40
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
41
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
42
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
43
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
44
+ }>>;
45
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
46
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
47
+ readonly at: Schema.optionalKey<Schema.Int>;
48
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
49
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
50
+ readonly text: RichSlot<E>;
51
+ }>>>;
52
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
53
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
54
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
55
+ readonly curve: Schema.Struct<{
56
+ readonly amplitude: Schema.Finite;
57
+ readonly domain: Schema.Tuple<readonly [Schema.Finite, Schema.Finite]>;
58
+ readonly frequency: Schema.Finite;
59
+ readonly kind: Schema.Literals<readonly ["sin", "cos", "tan"]>;
60
+ readonly phase: Schema.Finite;
61
+ readonly samples: Schema.optionalKey<Schema.Int>;
62
+ readonly shift: Schema.Finite;
63
+ }>;
64
+ }>, Schema.Struct<{
65
+ readonly center: Schema.optionalKey<Schema.Struct<{
66
+ readonly x: Schema.Finite;
67
+ readonly y: Schema.Finite;
68
+ readonly z: Schema.Finite;
69
+ }>>;
70
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
71
+ readonly height: Schema.Finite;
72
+ readonly kind: Schema.Literal<"cuboid">;
73
+ readonly length: Schema.Finite;
74
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
75
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
76
+ readonly width: Schema.Finite;
77
+ }>, Schema.Struct<{
78
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
79
+ readonly cone: Schema.optionalKey<Schema.Struct<{
80
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
81
+ readonly size: Schema.optionalKey<Schema.Finite>;
82
+ }>>;
83
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
84
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
85
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
86
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
87
+ }>>;
88
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
89
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
90
+ readonly at: Schema.optionalKey<Schema.Int>;
91
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
92
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
93
+ readonly text: RichSlot<E>;
94
+ }>>>;
95
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
96
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
97
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
98
+ readonly kind: Schema.Literal<"circle-outline">;
99
+ readonly radius: Schema.Finite;
100
+ }>, Schema.Struct<{
101
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
102
+ readonly cone: Schema.optionalKey<Schema.Struct<{
103
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
104
+ readonly size: Schema.optionalKey<Schema.Finite>;
105
+ }>>;
106
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
107
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
108
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
109
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
110
+ }>>;
111
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
112
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
113
+ readonly at: Schema.optionalKey<Schema.Int>;
114
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
115
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
116
+ readonly text: RichSlot<E>;
117
+ }>>>;
118
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
119
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
120
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
121
+ readonly radius: Schema.Finite;
122
+ readonly startDegrees: Schema.Finite;
123
+ readonly sweepDegrees: Schema.Finite;
124
+ readonly kind: Schema.Literal<"circle-chord">;
125
+ }>, Schema.Struct<{
126
+ readonly color: Schema.optionalKey<Schema.Trimmed>;
127
+ readonly cone: Schema.optionalKey<Schema.Struct<{
128
+ readonly position: Schema.Literals<readonly ["start", "end", "both"]>;
129
+ readonly size: Schema.optionalKey<Schema.Finite>;
130
+ }>>;
131
+ readonly curvePoints: Schema.optionalKey<Schema.Int>;
132
+ readonly endpoints: Schema.optionalKey<Schema.Struct<{
133
+ readonly end: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
134
+ readonly start: Schema.optionalKey<Schema.Literals<readonly ["open", "closed"]>>;
135
+ }>>;
136
+ readonly labels: Schema.optionalKey<Schema.NonEmptyArray<Schema.Struct<{
137
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
138
+ readonly at: Schema.optionalKey<Schema.Int>;
139
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
140
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
141
+ readonly text: RichSlot<E>;
142
+ }>>>;
143
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
144
+ readonly pointIndices: Schema.optionalKey<Schema.NonEmptyArray<Schema.Int>>;
145
+ readonly showPoints: Schema.optionalKey<Schema.Boolean>;
146
+ readonly degrees: Schema.Finite;
147
+ readonly kind: Schema.Literal<"circle-radius">;
148
+ readonly radius: Schema.Finite;
149
+ }>, Schema.Struct<{
150
+ readonly radius: Schema.Finite;
151
+ readonly startDegrees: Schema.Finite;
152
+ readonly sweepDegrees: Schema.Finite;
153
+ readonly color: Schema.Trimmed;
154
+ readonly kind: Schema.Literal<"circle-arc" | "circle-segment">;
155
+ readonly label: Schema.optionalKey<Schema.Struct<{
156
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
157
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
158
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
159
+ readonly text: RichSlot<E>;
160
+ readonly progress: Schema.optionalKey<Schema.Finite>;
161
+ }>>;
162
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
163
+ readonly segments: Schema.optionalKey<Schema.Int>;
164
+ }>, Schema.Struct<{
165
+ readonly radius: Schema.Finite;
166
+ readonly startDegrees: Schema.Finite;
167
+ readonly sweepDegrees: Schema.Finite;
168
+ readonly color: Schema.Trimmed;
169
+ readonly kind: Schema.Literal<"circle-arc" | "circle-segment">;
170
+ readonly label: Schema.optionalKey<Schema.Struct<{
171
+ readonly anchorX: Schema.optionalKey<Schema.Literals<readonly ["center", "left", "right"]>>;
172
+ readonly fontSize: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["marker", "compact", "annotation", "reading", "display", "diagram"]>, Schema.Finite]>>;
173
+ readonly offset: Schema.optionalKey<Schema.Tuple<readonly [Schema.Finite, Schema.Finite, Schema.Finite]>>;
174
+ readonly text: RichSlot<E>;
175
+ readonly progress: Schema.optionalKey<Schema.Finite>;
176
+ }>>;
177
+ readonly lineWidth: Schema.optionalKey<Schema.Finite>;
178
+ readonly segments: Schema.optionalKey<Schema.Int>;
179
+ }>]>;
@@ -0,0 +1,156 @@
1
+ import { Array as Arr, Schema } from "effect";
2
+ import { NonNegativeIntSchema } from "#contracts/assessment/scalar";
3
+ import { PositiveMeasureSchema, SpacePointSchema } from "#contracts/math/base";
4
+ import { TextSchema, TripleSchema, } from "#contracts/visual/card";
5
+ /** The named sizes of a label in a three-dimensional scene. */
6
+ const FONT_SIZES = [
7
+ "marker",
8
+ "compact",
9
+ "annotation",
10
+ "reading",
11
+ "display",
12
+ "diagram",
13
+ ];
14
+ /** The size of a label: a named size, or a measure in scene units. */
15
+ const FontSizeSchema = Schema.Union([
16
+ Schema.Literals(FONT_SIZES),
17
+ PositiveMeasureSchema,
18
+ ]);
19
+ /**
20
+ * The width of a line on screen. Zero is a width: the renderer draws no stroke,
21
+ * so a series with `showPoints` shows its points alone, as the answer to TKA
22
+ * compulsory mathematics set 3, question 8, shows its two fixed points.
23
+ */
24
+ const LineWidthSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
25
+ /** Whether the first or last point of a line belongs to it. */
26
+ const EndpointStateSchema = Schema.Literals(["open", "closed"]);
27
+ /** A label on a line: rich text at one of its points, nudged by an offset, at an optional size. */
28
+ function lineLabel(rich) {
29
+ return Schema.Struct({
30
+ anchorX: Schema.optionalKey(Schema.Literals(["center", "left", "right"])),
31
+ at: Schema.optionalKey(NonNegativeIntSchema),
32
+ fontSize: Schema.optionalKey(FontSizeSchema),
33
+ offset: Schema.optionalKey(TripleSchema),
34
+ text: rich,
35
+ });
36
+ }
37
+ /** The stroke, markers, and labels every drawn line may carry. */
38
+ function strokeFields(rich) {
39
+ return {
40
+ color: Schema.optionalKey(TextSchema),
41
+ cone: Schema.optionalKey(Schema.Struct({
42
+ position: Schema.Literals(["start", "end", "both"]),
43
+ size: Schema.optionalKey(PositiveMeasureSchema),
44
+ })),
45
+ curvePoints: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(1))),
46
+ endpoints: Schema.optionalKey(Schema.Struct({
47
+ end: Schema.optionalKey(EndpointStateSchema),
48
+ start: Schema.optionalKey(EndpointStateSchema),
49
+ })),
50
+ labels: Schema.optionalKey(Schema.NonEmptyArray(lineLabel(rich))),
51
+ lineWidth: Schema.optionalKey(LineWidthSchema),
52
+ pointIndices: Schema.optionalKey(Schema.NonEmptyArray(NonNegativeIntSchema)),
53
+ showPoints: Schema.optionalKey(Schema.Boolean),
54
+ };
55
+ }
56
+ /** The indices and label places of a line drawn through its points. */
57
+ const IndexedLineSchema = Schema.Struct({
58
+ labels: Schema.optionalKey(Schema.Array(Schema.Struct({ at: Schema.optionalKey(NonNegativeIntSchema) }))),
59
+ pointIndices: Schema.optionalKey(Schema.Array(NonNegativeIntSchema)),
60
+ points: Schema.Array(Schema.Unknown),
61
+ });
62
+ /** Checks that every index of a line names one of its points. */
63
+ function hasIndexedPoints(line) {
64
+ const count = line.points.length;
65
+ return (Arr.every(line.pointIndices ?? [], (index) => index < count) &&
66
+ Arr.every(line.labels ?? [], ({ at }) => at === undefined || at < count));
67
+ }
68
+ /** A line or curve through its points. */
69
+ function pointLine(rich) {
70
+ return Schema.Struct({
71
+ ...strokeFields(rich),
72
+ points: Schema.NonEmptyArray(SpacePointSchema),
73
+ smooth: Schema.optionalKey(Schema.Boolean),
74
+ }).check(Schema.makeFilter(hasIndexedPoints, {
75
+ message: "Expected every point index to name a point of the line.",
76
+ }));
77
+ }
78
+ /** A nonzero finite number, such as the amplitude of a curve. */
79
+ const NonZeroSchema = Schema.Finite.check(Schema.makeFilter((value) => value !== 0, {
80
+ message: "Expected a nonzero finite number.",
81
+ }));
82
+ /**
83
+ * One curve `y = amplitude · f(frequency · x + phase) + shift` over its domain,
84
+ * where `f` is the sine, the cosine, or the tangent. The renderer computes its
85
+ * points on a grid of `samples`, at least 200.
86
+ */
87
+ const CurveSchema = Schema.Struct({
88
+ amplitude: NonZeroSchema,
89
+ domain: Schema.Tuple([Schema.Finite, Schema.Finite]).check(Schema.makeFilter(([from, to]) => from < to, {
90
+ message: "Expected a domain whose start is below its end.",
91
+ })),
92
+ frequency: NonZeroSchema,
93
+ kind: Schema.Literals(["sin", "cos", "tan"]),
94
+ phase: Schema.Finite,
95
+ samples: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(200))),
96
+ shift: Schema.Finite,
97
+ });
98
+ /** The radius and the turn of a circle part, in degrees. */
99
+ const CircleTurnFields = {
100
+ radius: PositiveMeasureSchema,
101
+ startDegrees: Schema.Finite,
102
+ sweepDegrees: Schema.Finite,
103
+ };
104
+ /** An arc or a segment of a circle, with one optional label along it. */
105
+ function circleArc(rich, kind) {
106
+ return Schema.Struct({
107
+ ...CircleTurnFields,
108
+ color: TextSchema,
109
+ kind: Schema.Literal(kind),
110
+ label: Schema.optionalKey(Schema.Struct({
111
+ ...lineLabel(rich).fields,
112
+ progress: Schema.optionalKey(Schema.Finite),
113
+ }).mapFields(({ at: _at, ...fields }) => fields)),
114
+ lineWidth: Schema.optionalKey(LineWidthSchema),
115
+ segments: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
116
+ });
117
+ }
118
+ /**
119
+ * One line of a `LineEquation` scene: a line through points, a curve by its
120
+ * formula, a cuboid, or a part of a circle.
121
+ */
122
+ export function sceneLine(rich) {
123
+ const stroke = strokeFields(rich);
124
+ return Schema.Union([
125
+ pointLine(rich),
126
+ Schema.Struct({ ...stroke, curve: CurveSchema }),
127
+ Schema.Struct({
128
+ center: Schema.optionalKey(SpacePointSchema),
129
+ color: stroke.color,
130
+ height: PositiveMeasureSchema,
131
+ kind: Schema.Literal("cuboid"),
132
+ length: PositiveMeasureSchema,
133
+ lineWidth: stroke.lineWidth,
134
+ showPoints: stroke.showPoints,
135
+ width: PositiveMeasureSchema,
136
+ }),
137
+ Schema.Struct({
138
+ ...stroke,
139
+ kind: Schema.Literal("circle-outline"),
140
+ radius: PositiveMeasureSchema,
141
+ }),
142
+ Schema.Struct({
143
+ ...stroke,
144
+ ...CircleTurnFields,
145
+ kind: Schema.Literal("circle-chord"),
146
+ }),
147
+ Schema.Struct({
148
+ ...stroke,
149
+ degrees: Schema.Finite,
150
+ kind: Schema.Literal("circle-radius"),
151
+ radius: PositiveMeasureSchema,
152
+ }),
153
+ circleArc(rich, "circle-arc"),
154
+ circleArc(rich, "circle-segment"),
155
+ ]);
156
+ }