@nakafa/aksara-contracts 7.0.0 → 8.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 (74) hide show
  1. package/dist/assessment/figure.d.ts +24 -48725
  2. package/dist/assessment/figure.js +10 -6
  3. package/dist/visual/base/layout.d.ts +6 -6
  4. package/dist/visual/base/math.d.ts +4 -4
  5. package/dist/visual/base/media.d.ts +2 -2
  6. package/dist/visual/biology/bacteria.d.ts +55 -0
  7. package/dist/visual/biology/bacteria.js +79 -0
  8. package/dist/visual/biology/cell.d.ts +89 -0
  9. package/dist/visual/biology/cell.js +95 -0
  10. package/dist/visual/biology/climate.d.ts +75 -0
  11. package/dist/visual/biology/climate.js +94 -0
  12. package/dist/visual/biology/ecology.d.ts +75 -0
  13. package/dist/visual/biology/ecology.js +94 -0
  14. package/dist/visual/biology.d.ts +9 -9
  15. package/dist/visual/card.d.ts +0 -2
  16. package/dist/visual/card.js +0 -6
  17. package/dist/visual/catalog.d.ts +1610 -27079
  18. package/dist/visual/catalog.js +47 -1
  19. package/dist/visual/chemistry/atom.d.ts +4 -4
  20. package/dist/visual/chemistry/balance.d.ts +79 -0
  21. package/dist/visual/chemistry/balance.js +128 -0
  22. package/dist/visual/chemistry/bonding.d.ts +80 -0
  23. package/dist/visual/chemistry/bonding.js +147 -0
  24. package/dist/visual/chemistry/discovery.d.ts +96 -0
  25. package/dist/visual/chemistry/discovery.js +137 -0
  26. package/dist/visual/chemistry/electron.d.ts +2 -2
  27. package/dist/visual/chemistry/laws.d.ts +4 -4
  28. package/dist/visual/chemistry/particles.d.ts +5 -5
  29. package/dist/visual/chemistry/periodic.d.ts +2 -2
  30. package/dist/visual/chemistry/reaction.d.ts +3 -3
  31. package/dist/visual/entry.d.ts +4 -4
  32. package/dist/visual/mathematics/chart.d.ts +1 -1
  33. package/dist/visual/mathematics/charts.d.ts +5 -5
  34. package/dist/visual/mathematics/function.d.ts +7 -7
  35. package/dist/visual/mathematics/geometry.d.ts +4 -213
  36. package/dist/visual/mathematics/geometry.js +3 -65
  37. package/dist/visual/physics/braking.d.ts +62 -0
  38. package/dist/visual/physics/braking.js +83 -0
  39. package/dist/visual/physics/circular.d.ts +36 -0
  40. package/dist/visual/physics/circular.js +51 -0
  41. package/dist/visual/physics/efficiency.d.ts +93 -0
  42. package/dist/visual/physics/efficiency.js +129 -0
  43. package/dist/visual/physics/falling.d.ts +56 -0
  44. package/dist/visual/physics/falling.js +77 -0
  45. package/dist/visual/physics/force.d.ts +88 -0
  46. package/dist/visual/physics/force.js +115 -0
  47. package/dist/visual/physics/instrument.d.ts +93 -0
  48. package/dist/visual/physics/instrument.js +135 -0
  49. package/dist/visual/physics/measurement.d.ts +4 -4
  50. package/dist/visual/physics/motion.d.ts +6 -6
  51. package/dist/visual/physics/parabolic.d.ts +2 -2
  52. package/dist/visual/physics/position.d.ts +87 -0
  53. package/dist/visual/physics/position.js +123 -0
  54. package/dist/visual/physics/power.d.ts +121 -0
  55. package/dist/visual/physics/power.js +162 -0
  56. package/dist/visual/physics/precision.d.ts +96 -0
  57. package/dist/visual/physics/precision.js +137 -0
  58. package/dist/visual/physics/product.d.ts +73 -0
  59. package/dist/visual/physics/product.js +96 -0
  60. package/dist/visual/physics/record.d.ts +34 -0
  61. package/dist/visual/physics/record.js +46 -0
  62. package/dist/visual/physics/relative.d.ts +55 -0
  63. package/dist/visual/physics/relative.js +76 -0
  64. package/dist/visual/physics/solar.d.ts +91 -0
  65. package/dist/visual/physics/solar.js +126 -0
  66. package/dist/visual/physics/vector.d.ts +103 -0
  67. package/dist/visual/physics/vector.js +123 -0
  68. package/dist/visual/physics/velocity.d.ts +7 -7
  69. package/dist/visual/politics.d.ts +8 -8
  70. package/package.json +1 -1
  71. package/dist/visual/mathematics/line.d.ts +0 -179
  72. package/dist/visual/mathematics/line.js +0 -156
  73. package/dist/visual/mathematics/number.d.ts +0 -21
  74. package/dist/visual/mathematics/number.js +0 -53
@@ -1,156 +0,0 @@
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
- }
@@ -1,21 +0,0 @@
1
- import { Schema } from "effect";
2
- import { type RichSlot } from "#contracts/visual/card";
3
- /** Props of `NumberLine`: segments on a line, with an optional visible range. */
4
- export declare function numberLine<E>(rich: RichSlot<E>): import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
5
- readonly description: RichSlot<E>;
6
- readonly title: RichSlot<E>;
7
- readonly max: Schema.optionalKey<Schema.Finite>;
8
- readonly min: Schema.optionalKey<Schema.Finite>;
9
- readonly segments: Schema.NonEmptyArray<Schema.Struct<{
10
- readonly backgroundColor: Schema.optionalKey<Schema.Literal<"transparent">>;
11
- readonly end: Schema.optionalKey<Schema.Finite>;
12
- readonly endInclusive: Schema.optionalKey<Schema.Boolean>;
13
- readonly endLabel: Schema.optionalKey<RichSlot<E>>;
14
- readonly label: Schema.optionalKey<RichSlot<E>>;
15
- readonly shaded: Schema.optionalKey<Schema.Boolean>;
16
- readonly showPoints: Schema.optionalKey<Schema.Boolean>;
17
- readonly start: Schema.optionalKey<Schema.Finite>;
18
- readonly startInclusive: Schema.optionalKey<Schema.Boolean>;
19
- readonly startLabel: Schema.optionalKey<RichSlot<E>>;
20
- }>>;
21
- }>>;
@@ -1,53 +0,0 @@
1
- import { Schema } from "effect";
2
- import { cardFields } from "#contracts/visual/card";
3
- import { figure } from "#contracts/visual/entry";
4
- /** The two ends of one segment; a missing end is a ray to the edge of the axis. */
5
- const SegmentEndsSchema = Schema.Struct({
6
- end: Schema.optionalKey(Schema.Finite),
7
- start: Schema.optionalKey(Schema.Finite),
8
- });
9
- /** Checks that a segment that has two ends does not end before it starts. */
10
- function isOrderedSegment({ end, start }) {
11
- return start === undefined || end === undefined || start <= end;
12
- }
13
- /**
14
- * One segment of a number line. A segment without a start or an end is a ray
15
- * to the edge of the axis, as the renderer draws it. The corpus sets a
16
- * background only to transparent, and an arbitrary color is not part of this
17
- * contract, because no meaning may ride on color.
18
- */
19
- function segment(rich) {
20
- return Schema.Struct({
21
- backgroundColor: Schema.optionalKey(Schema.Literal("transparent")),
22
- end: Schema.optionalKey(Schema.Finite),
23
- endInclusive: Schema.optionalKey(Schema.Boolean),
24
- endLabel: Schema.optionalKey(rich),
25
- label: Schema.optionalKey(rich),
26
- shaded: Schema.optionalKey(Schema.Boolean),
27
- showPoints: Schema.optionalKey(Schema.Boolean),
28
- start: Schema.optionalKey(Schema.Finite),
29
- startInclusive: Schema.optionalKey(Schema.Boolean),
30
- startLabel: Schema.optionalKey(rich),
31
- }).check(Schema.makeFilter(isOrderedSegment, {
32
- message: "Expected a segment that does not end before it starts.",
33
- }));
34
- }
35
- /** The visible range of a number line, each end optional. */
36
- const VisibleRangeSchema = Schema.Struct({
37
- max: Schema.optionalKey(Schema.Finite),
38
- min: Schema.optionalKey(Schema.Finite),
39
- });
40
- /** Checks that the visible range of a number line runs upward. */
41
- function isOrderedRange({ max, min }) {
42
- return min === undefined || max === undefined || min < max;
43
- }
44
- /** Props of `NumberLine`: segments on a line, with an optional visible range. */
45
- export function numberLine(rich) {
46
- return figure(Schema.Struct({
47
- ...cardFields(rich),
48
- ...VisibleRangeSchema.fields,
49
- segments: Schema.NonEmptyArray(segment(rich)),
50
- }).check(Schema.makeFilter(isOrderedRange, {
51
- message: "Expected a visible range whose minimum is below its maximum.",
52
- })));
53
- }