@nakafa/aksara-contracts 8.4.1 → 8.9.1

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 (78) hide show
  1. package/dist/assessment/answer.d.ts +2 -0
  2. package/dist/assessment/answer.js +5 -3
  3. package/dist/assessment/closure.js +2 -1
  4. package/dist/assessment/fit.d.ts +16 -2
  5. package/dist/assessment/fit.js +23 -5
  6. package/dist/assessment/graphic.d.ts +27 -0
  7. package/dist/assessment/graphic.js +17 -1
  8. package/dist/assessment/hash.d.ts +71 -3
  9. package/dist/assessment/interaction.d.ts +18 -1
  10. package/dist/assessment/interaction.js +2 -1
  11. package/dist/assessment/item.d.ts +85 -0
  12. package/dist/assessment/item.js +1 -1
  13. package/dist/assessment/joint.d.ts +4 -3
  14. package/dist/assessment/joint.js +4 -3
  15. package/dist/assessment/key.d.ts +138 -0
  16. package/dist/assessment/key.js +6 -0
  17. package/dist/assessment/paper.d.ts +316 -0
  18. package/dist/assessment/profile.d.ts +3 -3
  19. package/dist/assessment/profile.js +4 -4
  20. package/dist/assessment/rows.d.ts +285 -3
  21. package/dist/assessment/scoring.d.ts +12 -6
  22. package/dist/assessment/scoring.js +25 -8
  23. package/dist/assessment/sketch.d.ts +125 -0
  24. package/dist/assessment/sketch.js +175 -0
  25. package/dist/assessment/snapshot.d.ts +746 -10
  26. package/dist/assessment/structure.js +4 -4
  27. package/dist/hash/sha256.d.ts +16 -0
  28. package/dist/hash/sha256.js +164 -0
  29. package/dist/hash/stream.d.ts +7 -5
  30. package/dist/hash/stream.js +13 -18
  31. package/dist/math/boundary.js +3 -22
  32. package/dist/math/edge.d.ts +11 -0
  33. package/dist/math/edge.js +74 -0
  34. package/dist/math/graph.d.ts +9 -0
  35. package/dist/math/graph.js +66 -0
  36. package/dist/math/plane.js +6 -0
  37. package/dist/math/shape.d.ts +392 -0
  38. package/dist/math/shape.js +59 -0
  39. package/dist/math/straight.d.ts +13 -0
  40. package/dist/math/straight.js +26 -0
  41. package/dist/release/snapshot/data.d.ts +88 -2
  42. package/dist/release/snapshot/verify.d.ts +285 -3
  43. package/dist/transport/group.d.ts +264 -6
  44. package/dist/transport/request.d.ts +1886 -22
  45. package/dist/transport/snapshot.d.ts +176 -4
  46. package/dist/visual/biology/blood.d.ts +91 -0
  47. package/dist/visual/biology/blood.js +55 -0
  48. package/dist/visual/biology/heart.d.ts +92 -0
  49. package/dist/visual/biology/heart.js +54 -0
  50. package/dist/visual/biology/mitochondrion.d.ts +91 -0
  51. package/dist/visual/biology/mitochondrion.js +45 -0
  52. package/dist/visual/biology/muscle.d.ts +103 -0
  53. package/dist/visual/biology/muscle.js +62 -0
  54. package/dist/visual/biology/neuron.d.ts +97 -0
  55. package/dist/visual/biology/neuron.js +48 -0
  56. package/dist/visual/biology/paddy.d.ts +100 -0
  57. package/dist/visual/biology/paddy.js +54 -0
  58. package/dist/visual/biology/synapse.d.ts +101 -0
  59. package/dist/visual/biology/synapse.js +46 -0
  60. package/dist/visual/biology/vessel.d.ts +104 -0
  61. package/dist/visual/biology/vessel.js +60 -0
  62. package/dist/visual/biology/yeast.d.ts +108 -0
  63. package/dist/visual/biology/yeast.js +61 -0
  64. package/dist/visual/catalog.d.ts +2177 -778
  65. package/dist/visual/catalog.js +28 -0
  66. package/dist/visual/mathematics/journey.d.ts +118 -0
  67. package/dist/visual/mathematics/journey.js +125 -0
  68. package/dist/visual/mathematics/logic.d.ts +90 -0
  69. package/dist/visual/mathematics/logic.js +49 -0
  70. package/dist/visual/mathematics/network.d.ts +101 -0
  71. package/dist/visual/mathematics/network.js +97 -0
  72. package/dist/visual/mathematics/numeral.d.ts +81 -0
  73. package/dist/visual/mathematics/numeral.js +48 -0
  74. package/dist/visual/mathematics/sets.d.ts +92 -0
  75. package/dist/visual/mathematics/sets.js +95 -0
  76. package/dist/visual/physics/thermodynamics.d.ts +117 -0
  77. package/dist/visual/physics/thermodynamics.js +95 -0
  78. package/package.json +2 -2
@@ -167,4 +167,85 @@ export declare function numeralVisuals<E>(rich: RichSlot<E>): {
167
167
  }>;
168
168
  readonly showReadout: Schema.optionalKey<Schema.Boolean>;
169
169
  }>, "figure">;
170
+ BundleCountLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
171
+ readonly description: RichSlot<E>;
172
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
173
+ readonly attrs: {
174
+ readonly latex: string;
175
+ };
176
+ readonly type: "mathInline";
177
+ } | {
178
+ readonly marks?: readonly [{
179
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
180
+ } | {
181
+ readonly attrs: {
182
+ readonly href: string;
183
+ };
184
+ readonly type: "link";
185
+ } | {
186
+ readonly attrs: {
187
+ readonly variant: "success" | "warning" | null;
188
+ };
189
+ readonly type: "highlight";
190
+ }, ...({
191
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
192
+ } | {
193
+ readonly attrs: {
194
+ readonly href: string;
195
+ };
196
+ readonly type: "link";
197
+ } | {
198
+ readonly attrs: {
199
+ readonly variant: "success" | "warning" | null;
200
+ };
201
+ readonly type: "highlight";
202
+ })[]];
203
+ readonly text: string;
204
+ readonly type: "text";
205
+ }, ...({
206
+ readonly attrs: {
207
+ readonly latex: string;
208
+ };
209
+ readonly type: "mathInline";
210
+ } | {
211
+ readonly marks?: readonly [{
212
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
213
+ } | {
214
+ readonly attrs: {
215
+ readonly href: string;
216
+ };
217
+ readonly type: "link";
218
+ } | {
219
+ readonly attrs: {
220
+ readonly variant: "success" | "warning" | null;
221
+ };
222
+ readonly type: "highlight";
223
+ }, ...({
224
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
225
+ } | {
226
+ readonly attrs: {
227
+ readonly href: string;
228
+ };
229
+ readonly type: "link";
230
+ } | {
231
+ readonly attrs: {
232
+ readonly variant: "success" | "warning" | null;
233
+ };
234
+ readonly type: "highlight";
235
+ })[]];
236
+ readonly text: string;
237
+ readonly type: "text";
238
+ })[]], E, never, never>>;
239
+ readonly title: RichSlot<E>;
240
+ readonly bases: Schema.NonEmptyArray<Schema.Int>;
241
+ readonly value: Schema.Int;
242
+ readonly labels: Schema.Struct<{
243
+ readonly base: Schema.Trimmed;
244
+ readonly count: Schema.Trimmed;
245
+ readonly ladder: RichSlot<E>;
246
+ readonly numeral: RichSlot<E>;
247
+ readonly viewLabel: Schema.Trimmed;
248
+ }>;
249
+ readonly showReadout: Schema.optionalKey<Schema.Boolean>;
250
+ }>, "figure">;
170
251
  };
@@ -76,10 +76,58 @@ function binaryLampLab(rich) {
76
76
  message: "Expected a number the row of lamps can show.",
77
77
  })), answerAt(["showReadout"]));
78
78
  }
79
+ /**
80
+ * How many trays the bundling desk has room for. A tray holds b boxes, so the
81
+ * highest place, b^3, shows a digit of at most this.
82
+ */
83
+ const DESK_TRAYS = 1;
84
+ /** The most sticks one heap on the bundling desk holds. */
85
+ const HEAP_STICKS = 300;
86
+ /** A base the desk can bundle in: two to nine sticks to a bundle, as the KSSM bases are. */
87
+ const BundleBaseSchema = Schema.Int.check(Schema.isBetween({ maximum: 9, minimum: 2 }));
88
+ /** The bases a bundling desk offers and the count of sticks it starts from. */
89
+ const BundleStartSchema = Schema.Struct({
90
+ bases: Schema.NonEmptyArray(BundleBaseSchema),
91
+ value: Schema.Int.check(Schema.isBetween({ maximum: HEAP_STICKS, minimum: 1 })),
92
+ });
93
+ /**
94
+ * Whether each base is offered once and the first base's desk holds the count:
95
+ * loose sticks, bundles and boxes below b each, and at most one full tray.
96
+ */
97
+ function fitsDesk({ bases, value }) {
98
+ const [first] = bases;
99
+ return (Arr.dedupe(bases).length === bases.length &&
100
+ value <= (DESK_TRAYS + 1) * first ** 3 - 1);
101
+ }
102
+ /**
103
+ * Props of `BundleCountLab`: a desk where a heap of `value` sticks is tied
104
+ * into bundles of b, the bundles boxed b to a box and the boxes set b to a
105
+ * tray (one tray fits the desk), one division by b per round, in the base the learner picks from
106
+ * `bases`. With `showReadout`, the slider shows the count, each place shows
107
+ * its digit, a caption reads each division, and the footer reads the
108
+ * division ladder and the numeral, so it is answer state.
109
+ */
110
+ function bundleCountLab(rich) {
111
+ return figure(Schema.Struct({
112
+ ...cardFields(rich),
113
+ ...BundleStartSchema.fields,
114
+ labels: Schema.Struct({
115
+ base: TextSchema,
116
+ count: TextSchema,
117
+ ladder: rich,
118
+ numeral: rich,
119
+ viewLabel: TextSchema,
120
+ }),
121
+ showReadout: Schema.optionalKey(Schema.Boolean),
122
+ }).check(Schema.makeFilter(fitsDesk, {
123
+ message: "Expected each base once and a count the first base's desk holds with one tray.",
124
+ })), answerAt(["showReadout"]));
125
+ }
79
126
  /** The place-value labs, where a number is written in a base. */
80
127
  export function numeralVisuals(rich) {
81
128
  return {
82
129
  AbacusBaseLab: abacusBaseLab(rich),
83
130
  BinaryLampLab: binaryLampLab(rich),
131
+ BundleCountLab: bundleCountLab(rich),
84
132
  };
85
133
  }
@@ -0,0 +1,92 @@
1
+ import { Schema } from "effect";
2
+ import type { RichSlot } from "#contracts/visual/card";
3
+ /** The set labs, where objects are sorted into sets and operations select regions. */
4
+ export declare function setVisuals<E>(rich: RichSlot<E>): {
5
+ VennSortLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
6
+ readonly description: RichSlot<E>;
7
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
8
+ readonly attrs: {
9
+ readonly latex: string;
10
+ };
11
+ readonly type: "mathInline";
12
+ } | {
13
+ readonly marks?: readonly [{
14
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
15
+ } | {
16
+ readonly attrs: {
17
+ readonly href: string;
18
+ };
19
+ readonly type: "link";
20
+ } | {
21
+ readonly attrs: {
22
+ readonly variant: "success" | "warning" | null;
23
+ };
24
+ readonly type: "highlight";
25
+ }, ...({
26
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
27
+ } | {
28
+ readonly attrs: {
29
+ readonly href: string;
30
+ };
31
+ readonly type: "link";
32
+ } | {
33
+ readonly attrs: {
34
+ readonly variant: "success" | "warning" | null;
35
+ };
36
+ readonly type: "highlight";
37
+ })[]];
38
+ readonly text: string;
39
+ readonly type: "text";
40
+ }, ...({
41
+ readonly attrs: {
42
+ readonly latex: string;
43
+ };
44
+ readonly type: "mathInline";
45
+ } | {
46
+ readonly marks?: readonly [{
47
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
48
+ } | {
49
+ readonly attrs: {
50
+ readonly href: string;
51
+ };
52
+ readonly type: "link";
53
+ } | {
54
+ readonly attrs: {
55
+ readonly variant: "success" | "warning" | null;
56
+ };
57
+ readonly type: "highlight";
58
+ }, ...({
59
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
60
+ } | {
61
+ readonly attrs: {
62
+ readonly href: string;
63
+ };
64
+ readonly type: "link";
65
+ } | {
66
+ readonly attrs: {
67
+ readonly variant: "success" | "warning" | null;
68
+ };
69
+ readonly type: "highlight";
70
+ })[]];
71
+ readonly text: string;
72
+ readonly type: "text";
73
+ })[]], E, never, never>>;
74
+ readonly title: RichSlot<E>;
75
+ readonly objects: Schema.NonEmptyArray<Schema.Struct<{
76
+ readonly name: Schema.Trimmed;
77
+ readonly object: Schema.Literals<readonly ["apple", "lemon", "lime", "tennis-ball", "steel-ball", "red-ball", "blue-ball", "washer", "coin", "toy-car", "red-block", "green-block", "yellow-block", "blue-cup", "green-cup"]>;
78
+ }>>;
79
+ readonly operations: Schema.NonEmptyArray<Schema.Literals<readonly ["intersection", "union", "complement", "outside-union", "difference", "triple-intersection", "union-with-pair"]>>;
80
+ readonly sets: Schema.$Array<Schema.Struct<{
81
+ readonly attribute: Schema.Literals<readonly ["red", "yellow", "blue", "green", "metal", "wood", "plastic", "ball", "fruit"]>;
82
+ readonly name: Schema.Trimmed;
83
+ }>>;
84
+ readonly labels: Schema.Struct<{
85
+ readonly count: RichSlot<E>;
86
+ readonly members: RichSlot<E>;
87
+ readonly operation: Schema.Trimmed;
88
+ readonly viewLabel: Schema.Trimmed;
89
+ }>;
90
+ readonly showCount: Schema.optionalKey<Schema.Boolean>;
91
+ }>, "figure">;
92
+ };
@@ -0,0 +1,95 @@
1
+ import { Array as Arr, Schema } from "effect";
2
+ import { cardFields, TextSchema } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** What a hoop can gather the objects by: a colour, a material, being a ball, or being a fruit. */
5
+ const VENN_ATTRIBUTES = [
6
+ "red",
7
+ "yellow",
8
+ "blue",
9
+ "green",
10
+ "metal",
11
+ "wood",
12
+ "plastic",
13
+ "ball",
14
+ "fruit",
15
+ ];
16
+ /** The everyday objects the mat can hold, each at most once. */
17
+ const VENN_OBJECTS = [
18
+ "apple",
19
+ "lemon",
20
+ "lime",
21
+ "tennis-ball",
22
+ "steel-ball",
23
+ "red-ball",
24
+ "blue-ball",
25
+ "washer",
26
+ "coin",
27
+ "toy-car",
28
+ "red-block",
29
+ "green-block",
30
+ "yellow-block",
31
+ "blue-cup",
32
+ "green-cup",
33
+ ];
34
+ /** The operations the toolbar can offer, from A ∩ B to A ∪ (B ∩ C). */
35
+ const VENN_OPERATIONS = [
36
+ "intersection",
37
+ "union",
38
+ "complement",
39
+ "outside-union",
40
+ "difference",
41
+ "triple-intersection",
42
+ "union-with-pair",
43
+ ];
44
+ /** The operations that name the third set C, so they need three hoops. */
45
+ const THREE_SET_OPERATIONS = [
46
+ "triple-intersection",
47
+ "union-with-pair",
48
+ ];
49
+ /** The fewest and the most hoops the mat lays out. */
50
+ const HOOP_RANGE = { maximum: 3, minimum: 2 };
51
+ /** The hoops, the objects and the operations a lab offers. */
52
+ const SortSchema = Schema.Struct({
53
+ objects: Schema.NonEmptyArray(Schema.Struct({ name: TextSchema, object: Schema.Literals(VENN_OBJECTS) })),
54
+ operations: Schema.NonEmptyArray(Schema.Literals(VENN_OPERATIONS)),
55
+ sets: Schema.Array(Schema.Struct({
56
+ attribute: Schema.Literals(VENN_ATTRIBUTES),
57
+ name: TextSchema,
58
+ })).check(Schema.isMinLength(HOOP_RANGE.minimum), Schema.isMaxLength(HOOP_RANGE.maximum)),
59
+ });
60
+ /** Whether every list holds each entry once, and every operation has the hoops it names. */
61
+ function isSort({ objects, operations, sets }) {
62
+ const kinds = Arr.map(objects, ({ object }) => object);
63
+ const attributes = Arr.map(sets, ({ attribute }) => attribute);
64
+ return (Arr.dedupe(kinds).length === kinds.length &&
65
+ Arr.dedupe(attributes).length === attributes.length &&
66
+ Arr.dedupe(operations).length === operations.length &&
67
+ (sets.length === HOOP_RANGE.maximum ||
68
+ !Arr.some(operations, (operation) => Arr.contains(THREE_SET_OPERATIONS, operation))));
69
+ }
70
+ /**
71
+ * Props of `VennSortLab`: a universal-set mat with two or three hoops, A, B
72
+ * and C, each gathering the `objects` with one attribute. In Play the objects
73
+ * roll from a tray into their regions; picking one of the `operations`
74
+ * shades the region it selects. With `showCount`, the footer gives how many
75
+ * objects the operation selects and lists them, so it is answer state.
76
+ */
77
+ function vennSortLab(rich) {
78
+ return figure(Schema.Struct({
79
+ ...cardFields(rich),
80
+ ...SortSchema.fields,
81
+ labels: Schema.Struct({
82
+ count: rich,
83
+ members: rich,
84
+ operation: TextSchema,
85
+ viewLabel: TextSchema,
86
+ }),
87
+ showCount: Schema.optionalKey(Schema.Boolean),
88
+ }).check(Schema.makeFilter(isSort, {
89
+ message: "Expected each object, attribute and operation once, two or three hoops, and three hoops for an operation that names C.",
90
+ })), answerAt(["showCount"]));
91
+ }
92
+ /** The set labs, where objects are sorted into sets and operations select regions. */
93
+ export function setVisuals(rich) {
94
+ return { VennSortLab: vennSortLab(rich) };
95
+ }
@@ -0,0 +1,117 @@
1
+ import { Schema } from "effect";
2
+ import type { RichSlot } from "#contracts/visual/card";
3
+ /** The thermodynamics labs, where a gas exchanges heat and work. */
4
+ export declare function thermodynamicsVisuals<E>(rich: RichSlot<E>): {
5
+ GasProcessLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
6
+ readonly description: RichSlot<E>;
7
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
8
+ readonly attrs: {
9
+ readonly latex: string;
10
+ };
11
+ readonly type: "mathInline";
12
+ } | {
13
+ readonly marks?: readonly [{
14
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
15
+ } | {
16
+ readonly attrs: {
17
+ readonly href: string;
18
+ };
19
+ readonly type: "link";
20
+ } | {
21
+ readonly attrs: {
22
+ readonly variant: "success" | "warning" | null;
23
+ };
24
+ readonly type: "highlight";
25
+ }, ...({
26
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
27
+ } | {
28
+ readonly attrs: {
29
+ readonly href: string;
30
+ };
31
+ readonly type: "link";
32
+ } | {
33
+ readonly attrs: {
34
+ readonly variant: "success" | "warning" | null;
35
+ };
36
+ readonly type: "highlight";
37
+ })[]];
38
+ readonly text: string;
39
+ readonly type: "text";
40
+ }, ...({
41
+ readonly attrs: {
42
+ readonly latex: string;
43
+ };
44
+ readonly type: "mathInline";
45
+ } | {
46
+ readonly marks?: readonly [{
47
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
48
+ } | {
49
+ readonly attrs: {
50
+ readonly href: string;
51
+ };
52
+ readonly type: "link";
53
+ } | {
54
+ readonly attrs: {
55
+ readonly variant: "success" | "warning" | null;
56
+ };
57
+ readonly type: "highlight";
58
+ }, ...({
59
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
60
+ } | {
61
+ readonly attrs: {
62
+ readonly href: string;
63
+ };
64
+ readonly type: "link";
65
+ } | {
66
+ readonly attrs: {
67
+ readonly variant: "success" | "warning" | null;
68
+ };
69
+ readonly type: "highlight";
70
+ })[]];
71
+ readonly text: string;
72
+ readonly type: "text";
73
+ })[]], E, never, never>>;
74
+ readonly title: RichSlot<E>;
75
+ readonly gamma: Schema.optionalKey<Schema.Finite>;
76
+ readonly labels: Schema.Struct<{
77
+ readonly endPressure: Schema.Trimmed;
78
+ readonly endState: RichSlot<E>;
79
+ readonly endVolume: Schema.Trimmed;
80
+ readonly energy: Schema.Trimmed;
81
+ readonly heat: RichSlot<E>;
82
+ readonly internal: RichSlot<E>;
83
+ readonly law: RichSlot<E>;
84
+ readonly pressureAxis: RichSlot<E>;
85
+ readonly process: Schema.Trimmed;
86
+ readonly processes: Schema.$Record<Schema.Literals<readonly ["isobaric", "isochoric", "isothermal", "adiabatic"]>, Schema.Trimmed>;
87
+ readonly startState: RichSlot<E>;
88
+ readonly viewLabel: Schema.Trimmed;
89
+ readonly volumeAxis: RichSlot<E>;
90
+ readonly work: RichSlot<E>;
91
+ }>;
92
+ readonly moles: Schema.Finite;
93
+ readonly processes: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
94
+ readonly process: Schema.Literals<readonly ["isobaric", "isothermal", "adiabatic"]>;
95
+ readonly volume: Schema.Struct<{
96
+ readonly end: Schema.Finite;
97
+ readonly max: Schema.Finite;
98
+ readonly min: Schema.Finite;
99
+ }>;
100
+ }>, Schema.Struct<{
101
+ readonly pressure: Schema.Struct<{
102
+ readonly end: Schema.Finite;
103
+ readonly max: Schema.Finite;
104
+ readonly min: Schema.Finite;
105
+ }>;
106
+ readonly process: Schema.Literal<"isochoric">;
107
+ }>]>>;
108
+ readonly showValues: Schema.optionalKey<Schema.Boolean>;
109
+ readonly start: Schema.Union<readonly [Schema.Struct<{
110
+ readonly pressure: Schema.Finite;
111
+ readonly volume: Schema.Finite;
112
+ }>, Schema.Struct<{
113
+ readonly temperature: Schema.Finite;
114
+ readonly volume: Schema.Finite;
115
+ }>]>;
116
+ }>, "figure">;
117
+ };
@@ -0,0 +1,95 @@
1
+ import { Array as Arr, Schema } from "effect";
2
+ import { byIds, cardFields, TextSchema } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** The four processes of an ideal gas the lab can run. */
5
+ const GAS_PROCESSES = [
6
+ "isobaric",
7
+ "isochoric",
8
+ "isothermal",
9
+ "adiabatic",
10
+ ];
11
+ /** A quantity of the gas that must be above zero: an amount, a pressure, a volume or a temperature. */
12
+ const PositiveSchema = Schema.Finite.check(Schema.isGreaterThan(0));
13
+ /**
14
+ * The starting state: its volume with either its pressure or its
15
+ * temperature, in kPa, L and K. The lab works the third out from pV = nRT.
16
+ */
17
+ const StartSchema = Schema.Union([
18
+ Schema.Struct({ pressure: PositiveSchema, volume: PositiveSchema }),
19
+ Schema.Struct({ temperature: PositiveSchema, volume: PositiveSchema }),
20
+ ]);
21
+ /** Where the end of a process starts, and how far the learner may drag it. */
22
+ const EndRangeSchema = Schema.Struct({
23
+ end: PositiveSchema,
24
+ max: PositiveSchema,
25
+ min: PositiveSchema,
26
+ });
27
+ /**
28
+ * One process the toolbar offers: the end's volume for isobaric, isothermal
29
+ * and adiabatic, and the end's pressure for isochoric, where the volume holds.
30
+ */
31
+ const SetupSchema = Schema.Union([
32
+ Schema.Struct({
33
+ process: Schema.Literals(["isobaric", "isothermal", "adiabatic"]),
34
+ volume: EndRangeSchema,
35
+ }),
36
+ Schema.Struct({
37
+ pressure: EndRangeSchema,
38
+ process: Schema.Literal("isochoric"),
39
+ }),
40
+ ]);
41
+ /** The range a process's end moves through: its pressure when isochoric, else its volume. */
42
+ function rangeOf(setup) {
43
+ return setup.process === "isochoric" ? setup.pressure : setup.volume;
44
+ }
45
+ /** Whether each process is offered once, and each end starts inside a range that has room to move. */
46
+ function isProcessList(processes) {
47
+ const names = Arr.map(processes, ({ process }) => process);
48
+ return (Arr.dedupe(names).length === names.length &&
49
+ Arr.every(processes, (setup) => {
50
+ const { end, max, min } = rangeOf(setup);
51
+ return min < max && min <= end && end <= max;
52
+ }));
53
+ }
54
+ /**
55
+ * Props of `GasProcessLab`: `moles` of an ideal gas in a cylinder under a
56
+ * piston, beside a p-V diagram. The learner picks one of the offered
57
+ * `processes` and drags point 2 along that process's own path; the rig shows
58
+ * what holds the process (a weight, pins, a water bath or a foam jacket), the
59
+ * thermometer and the piston follow, and the footer's Q, W and ΔU bars share
60
+ * one scale, W being the work done by the gas. `gamma` is the gas's heat
61
+ * capacity ratio, 5/3 unless set. With `showValues`, the bars read signed
62
+ * joules and the first law is worked with the numbers, so it is answer state.
63
+ */
64
+ function gasProcessLab(rich) {
65
+ return figure(Schema.Struct({
66
+ ...cardFields(rich),
67
+ gamma: Schema.optionalKey(Schema.Finite.check(Schema.isGreaterThan(1))),
68
+ labels: Schema.Struct({
69
+ endPressure: TextSchema,
70
+ endState: rich,
71
+ endVolume: TextSchema,
72
+ energy: TextSchema,
73
+ heat: rich,
74
+ internal: rich,
75
+ law: rich,
76
+ pressureAxis: rich,
77
+ process: TextSchema,
78
+ processes: byIds(GAS_PROCESSES, TextSchema),
79
+ startState: rich,
80
+ viewLabel: TextSchema,
81
+ volumeAxis: rich,
82
+ work: rich,
83
+ }),
84
+ moles: PositiveSchema,
85
+ processes: Schema.NonEmptyArray(SetupSchema),
86
+ showValues: Schema.optionalKey(Schema.Boolean),
87
+ start: StartSchema,
88
+ }).check(Schema.makeFilter(({ processes }) => isProcessList(processes), {
89
+ message: "Expected each process once, and each end inside a range whose minimum is below its maximum.",
90
+ })), answerAt(["showValues"]));
91
+ }
92
+ /** The thermodynamics labs, where a gas exchanges heat and work. */
93
+ export function thermodynamicsVisuals(rich) {
94
+ return { GasProcessLab: gasProcessLab(rich) };
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakafa/aksara-contracts",
3
- "version": "8.4.1",
3
+ "version": "8.9.1",
4
4
  "description": "Schemas and verification contracts for Nakafa content releases.",
5
5
  "homepage": "https://github.com/nakafaai/aksara#readme",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -21,7 +21,7 @@
21
21
  "directory": "packages/contracts"
22
22
  },
23
23
  "peerDependencies": {
24
- "effect": "4.1.4"
24
+ "effect": "4.1.5"
25
25
  },
26
26
  "exports": {
27
27
  "./artifact/integrity": {