@nakafa/aksara-contracts 8.1.0 → 8.4.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.
- package/dist/math/boundary.d.ts +9 -0
- package/dist/math/boundary.js +81 -0
- package/dist/math/curve.d.ts +1 -0
- package/dist/math/curve.js +4 -2
- package/dist/math/formula/affine.d.ts +22 -0
- package/dist/math/formula/affine.js +79 -0
- package/dist/math/formula/contour.js +27 -12
- package/dist/math/object.d.ts +12 -0
- package/dist/math/object.js +11 -0
- package/dist/math/plane.d.ts +10 -0
- package/dist/math/plane.js +7 -1
- package/dist/math/space.d.ts +8 -0
- package/dist/math/space.js +5 -1
- package/dist/math/visual.d.ts +239 -212
- package/dist/visual/base/math.d.ts +78 -0
- package/dist/visual/base/math.js +31 -3
- package/dist/visual/base/media.d.ts +67 -0
- package/dist/visual/biology/bacteria.d.ts +268 -0
- package/dist/visual/biology/cell.d.ts +201 -0
- package/dist/visual/biology/climate.d.ts +201 -0
- package/dist/visual/biology/ecology.d.ts +268 -0
- package/dist/visual/biology/physiology.d.ts +201 -0
- package/dist/visual/biology/plant.d.ts +335 -0
- package/dist/visual/biology.d.ts +16 -16
- package/dist/visual/biology.js +2 -2
- package/dist/visual/card.d.ts +79 -1
- package/dist/visual/card.js +18 -2
- package/dist/visual/catalog.d.ts +14808 -28
- package/dist/visual/catalog.js +26 -0
- package/dist/visual/chemistry/atom.d.ts +203 -2
- package/dist/visual/chemistry/atom.js +2 -2
- package/dist/visual/chemistry/balance.d.ts +335 -0
- package/dist/visual/chemistry/bonding.d.ts +335 -0
- package/dist/visual/chemistry/discovery.d.ts +469 -0
- package/dist/visual/chemistry/electrochemistry.d.ts +134 -0
- package/dist/visual/chemistry/electron.d.ts +134 -0
- package/dist/visual/chemistry/laws.d.ts +268 -0
- package/dist/visual/chemistry/particles.d.ts +335 -0
- package/dist/visual/chemistry/periodic.d.ts +134 -0
- package/dist/visual/chemistry/rate.d.ts +67 -0
- package/dist/visual/chemistry/reaction.d.ts +201 -0
- package/dist/visual/chemistry/titration.d.ts +67 -0
- package/dist/visual/length.d.ts +79 -0
- package/dist/visual/length.js +37 -0
- package/dist/visual/mathematics/chance.d.ts +258 -0
- package/dist/visual/mathematics/chance.js +117 -0
- package/dist/visual/mathematics/chart.d.ts +67 -0
- package/dist/visual/mathematics/charts.d.ts +335 -0
- package/dist/visual/mathematics/function.d.ts +205 -4
- package/dist/visual/mathematics/function.js +4 -4
- package/dist/visual/mathematics/geometry.d.ts +1 -1
- package/dist/visual/mathematics/geometry.js +1 -1
- package/dist/visual/mathematics/numeral.d.ts +170 -0
- package/dist/visual/mathematics/numeral.js +85 -0
- package/dist/visual/physics/braking.d.ts +268 -0
- package/dist/visual/physics/circuit.d.ts +343 -0
- package/dist/visual/physics/circuit.js +86 -0
- package/dist/visual/physics/circular.d.ts +134 -0
- package/dist/visual/physics/dynamics.d.ts +579 -0
- package/dist/visual/physics/dynamics.js +134 -0
- package/dist/visual/physics/efficiency.d.ts +402 -0
- package/dist/visual/physics/electronics.d.ts +260 -0
- package/dist/visual/physics/electronics.js +71 -0
- package/dist/visual/physics/falling.d.ts +268 -0
- package/dist/visual/physics/field.d.ts +249 -0
- package/dist/visual/physics/field.js +60 -0
- package/dist/visual/physics/fluid.d.ts +336 -0
- package/dist/visual/physics/fluid.js +83 -0
- package/dist/visual/physics/force.d.ts +335 -0
- package/dist/visual/physics/gravity.d.ts +172 -0
- package/dist/visual/physics/gravity.js +47 -0
- package/dist/visual/physics/heat.d.ts +255 -0
- package/dist/visual/physics/heat.js +66 -0
- package/dist/visual/physics/instrument.d.ts +469 -0
- package/dist/visual/physics/light.d.ts +343 -0
- package/dist/visual/physics/light.js +90 -0
- package/dist/visual/physics/measurement.d.ts +268 -0
- package/dist/visual/physics/motion.d.ts +402 -0
- package/dist/visual/physics/nuclear.d.ts +258 -0
- package/dist/visual/physics/nuclear.js +69 -0
- package/dist/visual/physics/parabolic.d.ts +69 -2
- package/dist/visual/physics/parabolic.js +2 -2
- package/dist/visual/physics/position.d.ts +402 -0
- package/dist/visual/physics/power.d.ts +536 -0
- package/dist/visual/physics/precision.d.ts +469 -0
- package/dist/visual/physics/product.d.ts +268 -0
- package/dist/visual/physics/reading.d.ts +253 -0
- package/dist/visual/physics/reading.js +61 -0
- package/dist/visual/physics/record.d.ts +134 -0
- package/dist/visual/physics/relative.d.ts +201 -0
- package/dist/visual/physics/solar.d.ts +402 -0
- package/dist/visual/physics/vector.d.ts +335 -0
- package/dist/visual/physics/velocity.d.ts +469 -0
- package/dist/visual/physics/wave.d.ts +338 -0
- package/dist/visual/physics/wave.js +85 -0
- package/dist/visual/politics.d.ts +403 -1
- package/dist/visual/politics.js +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,73 @@ import { type RichSlot } from "#contracts/visual/card";
|
|
|
7
7
|
export declare function reactionVisuals<E>(rich: RichSlot<E>): {
|
|
8
8
|
ChemicalReactionCharacteristicsLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
9
9
|
readonly description: RichSlot<E>;
|
|
10
|
+
readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
|
|
11
|
+
readonly attrs: {
|
|
12
|
+
readonly latex: string;
|
|
13
|
+
};
|
|
14
|
+
readonly type: "mathInline";
|
|
15
|
+
} | {
|
|
16
|
+
readonly marks?: readonly [{
|
|
17
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
18
|
+
} | {
|
|
19
|
+
readonly attrs: {
|
|
20
|
+
readonly href: string;
|
|
21
|
+
};
|
|
22
|
+
readonly type: "link";
|
|
23
|
+
} | {
|
|
24
|
+
readonly attrs: {
|
|
25
|
+
readonly variant: "success" | "warning" | null;
|
|
26
|
+
};
|
|
27
|
+
readonly type: "highlight";
|
|
28
|
+
}, ...({
|
|
29
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
30
|
+
} | {
|
|
31
|
+
readonly attrs: {
|
|
32
|
+
readonly href: string;
|
|
33
|
+
};
|
|
34
|
+
readonly type: "link";
|
|
35
|
+
} | {
|
|
36
|
+
readonly attrs: {
|
|
37
|
+
readonly variant: "success" | "warning" | null;
|
|
38
|
+
};
|
|
39
|
+
readonly type: "highlight";
|
|
40
|
+
})[]];
|
|
41
|
+
readonly text: string;
|
|
42
|
+
readonly type: "text";
|
|
43
|
+
}, ...({
|
|
44
|
+
readonly attrs: {
|
|
45
|
+
readonly latex: string;
|
|
46
|
+
};
|
|
47
|
+
readonly type: "mathInline";
|
|
48
|
+
} | {
|
|
49
|
+
readonly marks?: readonly [{
|
|
50
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
51
|
+
} | {
|
|
52
|
+
readonly attrs: {
|
|
53
|
+
readonly href: string;
|
|
54
|
+
};
|
|
55
|
+
readonly type: "link";
|
|
56
|
+
} | {
|
|
57
|
+
readonly attrs: {
|
|
58
|
+
readonly variant: "success" | "warning" | null;
|
|
59
|
+
};
|
|
60
|
+
readonly type: "highlight";
|
|
61
|
+
}, ...({
|
|
62
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
63
|
+
} | {
|
|
64
|
+
readonly attrs: {
|
|
65
|
+
readonly href: string;
|
|
66
|
+
};
|
|
67
|
+
readonly type: "link";
|
|
68
|
+
} | {
|
|
69
|
+
readonly attrs: {
|
|
70
|
+
readonly variant: "success" | "warning" | null;
|
|
71
|
+
};
|
|
72
|
+
readonly type: "highlight";
|
|
73
|
+
})[]];
|
|
74
|
+
readonly text: string;
|
|
75
|
+
readonly type: "text";
|
|
76
|
+
})[]], E, never, never>>;
|
|
10
77
|
readonly title: RichSlot<E>;
|
|
11
78
|
readonly labels: Schema.Struct<{
|
|
12
79
|
readonly after: Schema.Trimmed;
|
|
@@ -27,6 +94,73 @@ export declare function reactionVisuals<E>(rich: RichSlot<E>): {
|
|
|
27
94
|
}>, "figure">;
|
|
28
95
|
ChemicalReactionTypesLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
29
96
|
readonly description: RichSlot<E>;
|
|
97
|
+
readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
|
|
98
|
+
readonly attrs: {
|
|
99
|
+
readonly latex: string;
|
|
100
|
+
};
|
|
101
|
+
readonly type: "mathInline";
|
|
102
|
+
} | {
|
|
103
|
+
readonly marks?: readonly [{
|
|
104
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
105
|
+
} | {
|
|
106
|
+
readonly attrs: {
|
|
107
|
+
readonly href: string;
|
|
108
|
+
};
|
|
109
|
+
readonly type: "link";
|
|
110
|
+
} | {
|
|
111
|
+
readonly attrs: {
|
|
112
|
+
readonly variant: "success" | "warning" | null;
|
|
113
|
+
};
|
|
114
|
+
readonly type: "highlight";
|
|
115
|
+
}, ...({
|
|
116
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
117
|
+
} | {
|
|
118
|
+
readonly attrs: {
|
|
119
|
+
readonly href: string;
|
|
120
|
+
};
|
|
121
|
+
readonly type: "link";
|
|
122
|
+
} | {
|
|
123
|
+
readonly attrs: {
|
|
124
|
+
readonly variant: "success" | "warning" | null;
|
|
125
|
+
};
|
|
126
|
+
readonly type: "highlight";
|
|
127
|
+
})[]];
|
|
128
|
+
readonly text: string;
|
|
129
|
+
readonly type: "text";
|
|
130
|
+
}, ...({
|
|
131
|
+
readonly attrs: {
|
|
132
|
+
readonly latex: string;
|
|
133
|
+
};
|
|
134
|
+
readonly type: "mathInline";
|
|
135
|
+
} | {
|
|
136
|
+
readonly marks?: readonly [{
|
|
137
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
138
|
+
} | {
|
|
139
|
+
readonly attrs: {
|
|
140
|
+
readonly href: string;
|
|
141
|
+
};
|
|
142
|
+
readonly type: "link";
|
|
143
|
+
} | {
|
|
144
|
+
readonly attrs: {
|
|
145
|
+
readonly variant: "success" | "warning" | null;
|
|
146
|
+
};
|
|
147
|
+
readonly type: "highlight";
|
|
148
|
+
}, ...({
|
|
149
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
150
|
+
} | {
|
|
151
|
+
readonly attrs: {
|
|
152
|
+
readonly href: string;
|
|
153
|
+
};
|
|
154
|
+
readonly type: "link";
|
|
155
|
+
} | {
|
|
156
|
+
readonly attrs: {
|
|
157
|
+
readonly variant: "success" | "warning" | null;
|
|
158
|
+
};
|
|
159
|
+
readonly type: "highlight";
|
|
160
|
+
})[]];
|
|
161
|
+
readonly text: string;
|
|
162
|
+
readonly type: "text";
|
|
163
|
+
})[]], E, never, never>>;
|
|
30
164
|
readonly title: RichSlot<E>;
|
|
31
165
|
readonly labels: Schema.Struct<{
|
|
32
166
|
readonly after: Schema.Trimmed;
|
|
@@ -49,6 +183,73 @@ export declare function reactionVisuals<E>(rich: RichSlot<E>): {
|
|
|
49
183
|
}>, "figure">;
|
|
50
184
|
MethaneCombustionEquationLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
51
185
|
readonly description: RichSlot<E>;
|
|
186
|
+
readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
|
|
187
|
+
readonly attrs: {
|
|
188
|
+
readonly latex: string;
|
|
189
|
+
};
|
|
190
|
+
readonly type: "mathInline";
|
|
191
|
+
} | {
|
|
192
|
+
readonly marks?: readonly [{
|
|
193
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
194
|
+
} | {
|
|
195
|
+
readonly attrs: {
|
|
196
|
+
readonly href: string;
|
|
197
|
+
};
|
|
198
|
+
readonly type: "link";
|
|
199
|
+
} | {
|
|
200
|
+
readonly attrs: {
|
|
201
|
+
readonly variant: "success" | "warning" | null;
|
|
202
|
+
};
|
|
203
|
+
readonly type: "highlight";
|
|
204
|
+
}, ...({
|
|
205
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
206
|
+
} | {
|
|
207
|
+
readonly attrs: {
|
|
208
|
+
readonly href: string;
|
|
209
|
+
};
|
|
210
|
+
readonly type: "link";
|
|
211
|
+
} | {
|
|
212
|
+
readonly attrs: {
|
|
213
|
+
readonly variant: "success" | "warning" | null;
|
|
214
|
+
};
|
|
215
|
+
readonly type: "highlight";
|
|
216
|
+
})[]];
|
|
217
|
+
readonly text: string;
|
|
218
|
+
readonly type: "text";
|
|
219
|
+
}, ...({
|
|
220
|
+
readonly attrs: {
|
|
221
|
+
readonly latex: string;
|
|
222
|
+
};
|
|
223
|
+
readonly type: "mathInline";
|
|
224
|
+
} | {
|
|
225
|
+
readonly marks?: readonly [{
|
|
226
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
227
|
+
} | {
|
|
228
|
+
readonly attrs: {
|
|
229
|
+
readonly href: string;
|
|
230
|
+
};
|
|
231
|
+
readonly type: "link";
|
|
232
|
+
} | {
|
|
233
|
+
readonly attrs: {
|
|
234
|
+
readonly variant: "success" | "warning" | null;
|
|
235
|
+
};
|
|
236
|
+
readonly type: "highlight";
|
|
237
|
+
}, ...({
|
|
238
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
239
|
+
} | {
|
|
240
|
+
readonly attrs: {
|
|
241
|
+
readonly href: string;
|
|
242
|
+
};
|
|
243
|
+
readonly type: "link";
|
|
244
|
+
} | {
|
|
245
|
+
readonly attrs: {
|
|
246
|
+
readonly variant: "success" | "warning" | null;
|
|
247
|
+
};
|
|
248
|
+
readonly type: "highlight";
|
|
249
|
+
})[]];
|
|
250
|
+
readonly text: string;
|
|
251
|
+
readonly type: "text";
|
|
252
|
+
})[]], E, never, never>>;
|
|
52
253
|
readonly title: RichSlot<E>;
|
|
53
254
|
readonly labels: Schema.Struct<{
|
|
54
255
|
readonly equation: RichSlot<E>;
|
|
@@ -4,6 +4,73 @@ import { type RichSlot } from "#contracts/visual/card";
|
|
|
4
4
|
export declare function titrationVisuals<E>(rich: RichSlot<E>): {
|
|
5
5
|
TitrationLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
6
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>>;
|
|
7
74
|
readonly title: RichSlot<E>;
|
|
8
75
|
readonly analyte: Schema.Struct<{
|
|
9
76
|
readonly concentration: Schema.Finite;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { RichText } from "#contracts/assessment/inline";
|
|
2
|
+
/**
|
|
3
|
+
* About how many glyphs a LaTeX formula draws: one for each letter, digit and
|
|
4
|
+
* symbol, one for each command such as `\alpha` or `\le`, the letters of its
|
|
5
|
+
* words in `\text{...}`, and nothing for grouping, scripts or spacing. A
|
|
6
|
+
* fraction counts its numerator and denominator side by side, which is what a
|
|
7
|
+
* reader scans.
|
|
8
|
+
*/
|
|
9
|
+
export declare function latexGlyphs(latex: string): number;
|
|
10
|
+
/** How many characters a rich text shows: its letters, and the glyphs of its math. */
|
|
11
|
+
export declare function visibleLength(text: RichText): number;
|
|
12
|
+
/** Keeps a rich text to at most `limit` visible characters (`visibleLength`). */
|
|
13
|
+
export declare function atMostVisible(limit: number, message: string): import("effect/SchemaAST").Filter<readonly [{
|
|
14
|
+
readonly attrs: {
|
|
15
|
+
readonly latex: string;
|
|
16
|
+
};
|
|
17
|
+
readonly type: "mathInline";
|
|
18
|
+
} | {
|
|
19
|
+
readonly marks?: readonly [{
|
|
20
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
21
|
+
} | {
|
|
22
|
+
readonly attrs: {
|
|
23
|
+
readonly href: string;
|
|
24
|
+
};
|
|
25
|
+
readonly type: "link";
|
|
26
|
+
} | {
|
|
27
|
+
readonly attrs: {
|
|
28
|
+
readonly variant: "success" | "warning" | null;
|
|
29
|
+
};
|
|
30
|
+
readonly type: "highlight";
|
|
31
|
+
}, ...({
|
|
32
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
33
|
+
} | {
|
|
34
|
+
readonly attrs: {
|
|
35
|
+
readonly href: string;
|
|
36
|
+
};
|
|
37
|
+
readonly type: "link";
|
|
38
|
+
} | {
|
|
39
|
+
readonly attrs: {
|
|
40
|
+
readonly variant: "success" | "warning" | null;
|
|
41
|
+
};
|
|
42
|
+
readonly type: "highlight";
|
|
43
|
+
})[]];
|
|
44
|
+
readonly text: string;
|
|
45
|
+
readonly type: "text";
|
|
46
|
+
}, ...({
|
|
47
|
+
readonly attrs: {
|
|
48
|
+
readonly latex: string;
|
|
49
|
+
};
|
|
50
|
+
readonly type: "mathInline";
|
|
51
|
+
} | {
|
|
52
|
+
readonly marks?: readonly [{
|
|
53
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
54
|
+
} | {
|
|
55
|
+
readonly attrs: {
|
|
56
|
+
readonly href: string;
|
|
57
|
+
};
|
|
58
|
+
readonly type: "link";
|
|
59
|
+
} | {
|
|
60
|
+
readonly attrs: {
|
|
61
|
+
readonly variant: "success" | "warning" | null;
|
|
62
|
+
};
|
|
63
|
+
readonly type: "highlight";
|
|
64
|
+
}, ...({
|
|
65
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
66
|
+
} | {
|
|
67
|
+
readonly attrs: {
|
|
68
|
+
readonly href: string;
|
|
69
|
+
};
|
|
70
|
+
readonly type: "link";
|
|
71
|
+
} | {
|
|
72
|
+
readonly attrs: {
|
|
73
|
+
readonly variant: "success" | "warning" | null;
|
|
74
|
+
};
|
|
75
|
+
readonly type: "highlight";
|
|
76
|
+
})[]];
|
|
77
|
+
readonly text: string;
|
|
78
|
+
readonly type: "text";
|
|
79
|
+
})[]]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
/** Commands that set size, style or spacing and draw no glyph of their own. */
|
|
3
|
+
const SILENT = /\\(?:(?:left|right|big|Big|bigg|Bigg|displaystyle|textstyle|scriptstyle|quad|qquad)(?![a-zA-Z])|[,;:!> ])/gu;
|
|
4
|
+
/** Commands whose argument is words, which show letter for letter. */
|
|
5
|
+
const WORDS = /\\(?:text|textbf|textit|textrm|mathrm|mathbf|mathit|operatorname)\s*\{(?<words>[^{}]*)\}/gu;
|
|
6
|
+
/** Any other command or escaped symbol, which draws one glyph. */
|
|
7
|
+
const GLYPH = /\\(?:[a-zA-Z]+|.)/gu;
|
|
8
|
+
/** Grouping, script and alignment marks, which shape a formula and show nothing. */
|
|
9
|
+
const MARKS = /[{}^_&\s]/gu;
|
|
10
|
+
/**
|
|
11
|
+
* About how many glyphs a LaTeX formula draws: one for each letter, digit and
|
|
12
|
+
* symbol, one for each command such as `\alpha` or `\le`, the letters of its
|
|
13
|
+
* words in `\text{...}`, and nothing for grouping, scripts or spacing. A
|
|
14
|
+
* fraction counts its numerator and denominator side by side, which is what a
|
|
15
|
+
* reader scans.
|
|
16
|
+
*/
|
|
17
|
+
export function latexGlyphs(latex) {
|
|
18
|
+
return (latex
|
|
19
|
+
// The named group is also the first argument after the whole match.
|
|
20
|
+
.replace(WORDS, (_command, words) => words.replace(/\s/gu, "~"))
|
|
21
|
+
.replace(SILENT, "")
|
|
22
|
+
.replace(GLYPH, "#")
|
|
23
|
+
.replace(MARKS, "").length);
|
|
24
|
+
}
|
|
25
|
+
/** How many characters a rich text shows: its letters, and the glyphs of its math. */
|
|
26
|
+
export function visibleLength(text) {
|
|
27
|
+
return Arr.reduce(text, 0, (sum, node) => sum +
|
|
28
|
+
(node.type === "text"
|
|
29
|
+
? Array.from(node.text).length
|
|
30
|
+
: latexGlyphs(node.attrs.latex)));
|
|
31
|
+
}
|
|
32
|
+
/** Keeps a rich text to at most `limit` visible characters (`visibleLength`). */
|
|
33
|
+
export function atMostVisible(limit, message) {
|
|
34
|
+
return Schema.makeFilter((text) => visibleLength(text) <= limit, {
|
|
35
|
+
message,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type RichSlot } from "#contracts/visual/card";
|
|
3
|
+
/** The probability labs, where a random experiment runs many times. */
|
|
4
|
+
export declare function chanceVisuals<E>(rich: RichSlot<E>): {
|
|
5
|
+
DiceRollLab: 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 dice: Schema.Literals<readonly [1, 2]>;
|
|
76
|
+
readonly target: Schema.optionalKey<Schema.Int>;
|
|
77
|
+
readonly labels: Schema.Struct<{
|
|
78
|
+
readonly frequency: RichSlot<E>;
|
|
79
|
+
readonly hits: RichSlot<E>;
|
|
80
|
+
readonly probability: RichSlot<E>;
|
|
81
|
+
readonly trials: RichSlot<E>;
|
|
82
|
+
readonly viewLabel: Schema.Trimmed;
|
|
83
|
+
}>;
|
|
84
|
+
}>, "figure">;
|
|
85
|
+
GaltonBoardLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
86
|
+
readonly description: RichSlot<E>;
|
|
87
|
+
readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
|
|
88
|
+
readonly attrs: {
|
|
89
|
+
readonly latex: string;
|
|
90
|
+
};
|
|
91
|
+
readonly type: "mathInline";
|
|
92
|
+
} | {
|
|
93
|
+
readonly marks?: readonly [{
|
|
94
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
95
|
+
} | {
|
|
96
|
+
readonly attrs: {
|
|
97
|
+
readonly href: string;
|
|
98
|
+
};
|
|
99
|
+
readonly type: "link";
|
|
100
|
+
} | {
|
|
101
|
+
readonly attrs: {
|
|
102
|
+
readonly variant: "success" | "warning" | null;
|
|
103
|
+
};
|
|
104
|
+
readonly type: "highlight";
|
|
105
|
+
}, ...({
|
|
106
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
107
|
+
} | {
|
|
108
|
+
readonly attrs: {
|
|
109
|
+
readonly href: string;
|
|
110
|
+
};
|
|
111
|
+
readonly type: "link";
|
|
112
|
+
} | {
|
|
113
|
+
readonly attrs: {
|
|
114
|
+
readonly variant: "success" | "warning" | null;
|
|
115
|
+
};
|
|
116
|
+
readonly type: "highlight";
|
|
117
|
+
})[]];
|
|
118
|
+
readonly text: string;
|
|
119
|
+
readonly type: "text";
|
|
120
|
+
}, ...({
|
|
121
|
+
readonly attrs: {
|
|
122
|
+
readonly latex: string;
|
|
123
|
+
};
|
|
124
|
+
readonly type: "mathInline";
|
|
125
|
+
} | {
|
|
126
|
+
readonly marks?: readonly [{
|
|
127
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
128
|
+
} | {
|
|
129
|
+
readonly attrs: {
|
|
130
|
+
readonly href: string;
|
|
131
|
+
};
|
|
132
|
+
readonly type: "link";
|
|
133
|
+
} | {
|
|
134
|
+
readonly attrs: {
|
|
135
|
+
readonly variant: "success" | "warning" | null;
|
|
136
|
+
};
|
|
137
|
+
readonly type: "highlight";
|
|
138
|
+
}, ...({
|
|
139
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
140
|
+
} | {
|
|
141
|
+
readonly attrs: {
|
|
142
|
+
readonly href: string;
|
|
143
|
+
};
|
|
144
|
+
readonly type: "link";
|
|
145
|
+
} | {
|
|
146
|
+
readonly attrs: {
|
|
147
|
+
readonly variant: "success" | "warning" | null;
|
|
148
|
+
};
|
|
149
|
+
readonly type: "highlight";
|
|
150
|
+
})[]];
|
|
151
|
+
readonly text: string;
|
|
152
|
+
readonly type: "text";
|
|
153
|
+
})[]], E, never, never>>;
|
|
154
|
+
readonly title: RichSlot<E>;
|
|
155
|
+
readonly labels: Schema.Struct<{
|
|
156
|
+
readonly balls: RichSlot<E>;
|
|
157
|
+
readonly expected: RichSlot<E>;
|
|
158
|
+
readonly mean: RichSlot<E>;
|
|
159
|
+
readonly rows: Schema.Trimmed;
|
|
160
|
+
readonly spread: RichSlot<E>;
|
|
161
|
+
readonly tilt: Schema.Trimmed;
|
|
162
|
+
readonly viewLabel: Schema.Trimmed;
|
|
163
|
+
}>;
|
|
164
|
+
readonly probability: Schema.Literals<readonly [0.3, 0.5, 0.7]>;
|
|
165
|
+
readonly rows: Schema.Int;
|
|
166
|
+
readonly showExpected: Schema.optionalKey<Schema.Boolean>;
|
|
167
|
+
}>, "figure">;
|
|
168
|
+
MarbleDrawLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
169
|
+
readonly description: RichSlot<E>;
|
|
170
|
+
readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
|
|
171
|
+
readonly attrs: {
|
|
172
|
+
readonly latex: string;
|
|
173
|
+
};
|
|
174
|
+
readonly type: "mathInline";
|
|
175
|
+
} | {
|
|
176
|
+
readonly marks?: readonly [{
|
|
177
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
178
|
+
} | {
|
|
179
|
+
readonly attrs: {
|
|
180
|
+
readonly href: string;
|
|
181
|
+
};
|
|
182
|
+
readonly type: "link";
|
|
183
|
+
} | {
|
|
184
|
+
readonly attrs: {
|
|
185
|
+
readonly variant: "success" | "warning" | null;
|
|
186
|
+
};
|
|
187
|
+
readonly type: "highlight";
|
|
188
|
+
}, ...({
|
|
189
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
190
|
+
} | {
|
|
191
|
+
readonly attrs: {
|
|
192
|
+
readonly href: string;
|
|
193
|
+
};
|
|
194
|
+
readonly type: "link";
|
|
195
|
+
} | {
|
|
196
|
+
readonly attrs: {
|
|
197
|
+
readonly variant: "success" | "warning" | null;
|
|
198
|
+
};
|
|
199
|
+
readonly type: "highlight";
|
|
200
|
+
})[]];
|
|
201
|
+
readonly text: string;
|
|
202
|
+
readonly type: "text";
|
|
203
|
+
}, ...({
|
|
204
|
+
readonly attrs: {
|
|
205
|
+
readonly latex: string;
|
|
206
|
+
};
|
|
207
|
+
readonly type: "mathInline";
|
|
208
|
+
} | {
|
|
209
|
+
readonly marks?: readonly [{
|
|
210
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
211
|
+
} | {
|
|
212
|
+
readonly attrs: {
|
|
213
|
+
readonly href: string;
|
|
214
|
+
};
|
|
215
|
+
readonly type: "link";
|
|
216
|
+
} | {
|
|
217
|
+
readonly attrs: {
|
|
218
|
+
readonly variant: "success" | "warning" | null;
|
|
219
|
+
};
|
|
220
|
+
readonly type: "highlight";
|
|
221
|
+
}, ...({
|
|
222
|
+
readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
|
|
223
|
+
} | {
|
|
224
|
+
readonly attrs: {
|
|
225
|
+
readonly href: string;
|
|
226
|
+
};
|
|
227
|
+
readonly type: "link";
|
|
228
|
+
} | {
|
|
229
|
+
readonly attrs: {
|
|
230
|
+
readonly variant: "success" | "warning" | null;
|
|
231
|
+
};
|
|
232
|
+
readonly type: "highlight";
|
|
233
|
+
})[]];
|
|
234
|
+
readonly text: string;
|
|
235
|
+
readonly type: "text";
|
|
236
|
+
})[]], E, never, never>>;
|
|
237
|
+
readonly title: RichSlot<E>;
|
|
238
|
+
readonly event: Schema.optionalKey<Schema.Struct<{
|
|
239
|
+
readonly first: Schema.Literals<readonly ["red", "blue", "green", "yellow", "white"]>;
|
|
240
|
+
readonly second: Schema.Literals<readonly ["red", "blue", "green", "yellow", "white"]>;
|
|
241
|
+
}>>;
|
|
242
|
+
readonly labels: Schema.Struct<{
|
|
243
|
+
readonly both: RichSlot<E>;
|
|
244
|
+
readonly first: RichSlot<E>;
|
|
245
|
+
readonly frequency: RichSlot<E>;
|
|
246
|
+
readonly rule: Schema.Trimmed;
|
|
247
|
+
readonly rules: Schema.$Record<Schema.Literals<readonly ["replace", "keep"]>, Schema.Trimmed>;
|
|
248
|
+
readonly second: RichSlot<E>;
|
|
249
|
+
readonly trials: RichSlot<E>;
|
|
250
|
+
readonly viewLabel: Schema.Trimmed;
|
|
251
|
+
}>;
|
|
252
|
+
readonly marbles: Schema.NonEmptyArray<Schema.Struct<{
|
|
253
|
+
readonly color: Schema.Literals<readonly ["red", "blue", "green", "yellow", "white"]>;
|
|
254
|
+
readonly count: Schema.Int;
|
|
255
|
+
}>>;
|
|
256
|
+
readonly rule: Schema.optionalKey<Schema.Literals<readonly ["replace", "keep"]>>;
|
|
257
|
+
}>, "figure">;
|
|
258
|
+
};
|