@nakafa/aksara-contracts 6.1.0 → 6.3.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/assessment/figure.d.ts +177 -6
- package/dist/math/bounds.js +23 -6
- package/dist/math/curve.d.ts +22 -0
- package/dist/math/curve.js +29 -1
- package/dist/math/formula/field.d.ts +23 -0
- package/dist/math/formula/field.js +19 -0
- package/dist/math/formula/plane.d.ts +17 -4
- package/dist/math/formula/plane.js +34 -88
- package/dist/math/formula/region.d.ts +16 -0
- package/dist/math/formula/region.js +94 -0
- package/dist/math/formula/scope.d.ts +4 -0
- package/dist/math/formula/scope.js +27 -13
- package/dist/math/formula/slider.d.ts +9 -0
- package/dist/math/formula/slider.js +32 -0
- package/dist/math/object.d.ts +2 -0
- package/dist/math/object.js +2 -0
- package/dist/math/plane.d.ts +87 -5
- package/dist/math/plane.js +24 -5
- package/dist/math/scene.js +7 -3
- package/dist/math/space.d.ts +29 -0
- package/dist/math/space.js +14 -1
- package/dist/math/visual.d.ts +169 -3
- package/dist/math/visual.js +12 -2
- package/package.json +1 -1
package/dist/math/scene.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Array as Arr, BigDecimal } from "effect";
|
|
|
2
2
|
import { arcCurvatureUnresolved, arcEndpointsUnresolved, } from "#contracts/math/arc";
|
|
3
3
|
import { clippedPathCoordinates, sceneCoordinate as coordinate, frameCoordinates, pointCoordinates, } from "#contracts/math/coordinate";
|
|
4
4
|
import { cuboidExtents, quadraticExtrema, radialOffsets, } from "#contracts/math/extent";
|
|
5
|
+
import { isPlaneFormulaPoint } from "#contracts/math/formula/field";
|
|
5
6
|
import { axisSpan, measureUnresolved, quadraticCurvatureUnresolved, spanUnresolved, } from "#contracts/math/precision";
|
|
6
7
|
import { decimal, decimalRatio } from "#contracts/math/rational";
|
|
7
8
|
/** Projects exact cardinal extrema from one circle or directed arc. */
|
|
@@ -63,7 +64,7 @@ function objectCoordinates(frame, object, index, threshold) {
|
|
|
63
64
|
if (object.kind === "ray") {
|
|
64
65
|
return clippedPathCoordinates(frame, "ray", object.from, object.through, root, threshold);
|
|
65
66
|
}
|
|
66
|
-
if (object.kind === "segment") {
|
|
67
|
+
if (object.kind === "segment" || object.kind === "vector") {
|
|
67
68
|
return [
|
|
68
69
|
...pointCoordinates(object.from, [...root, "from"]),
|
|
69
70
|
...pointCoordinates(object.to, [...root, "to"]),
|
|
@@ -89,9 +90,12 @@ function objectCoordinates(frame, object, index, threshold) {
|
|
|
89
90
|
}
|
|
90
91
|
return [];
|
|
91
92
|
}
|
|
92
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Projects all exact label anchors after the objects they annotate. An anchor
|
|
95
|
+
* placed by formulas moves with the sliders, so it holds no exact coordinate.
|
|
96
|
+
*/
|
|
93
97
|
function labelCoordinates(labels) {
|
|
94
|
-
return Arr.flatMap(labels, (
|
|
98
|
+
return Arr.flatMap(labels, ({ at }, index) => isPlaneFormulaPoint(at) ? [] : pointCoordinates(at, ["labels", index, "at"]));
|
|
95
99
|
}
|
|
96
100
|
/** Projects semantic camera or isometric coordinates before space objects. */
|
|
97
101
|
function viewCoordinates(view) {
|
package/dist/math/space.d.ts
CHANGED
|
@@ -205,6 +205,20 @@ export declare const SpaceMathObjectSchema: Schema.Union<readonly [Schema.Struct
|
|
|
205
205
|
readonly y: Schema.Finite;
|
|
206
206
|
readonly z: Schema.Finite;
|
|
207
207
|
}>;
|
|
208
|
+
}>, Schema.Struct<{
|
|
209
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
210
|
+
readonly id: Schema.String;
|
|
211
|
+
readonly from: Schema.Struct<{
|
|
212
|
+
readonly x: Schema.Finite;
|
|
213
|
+
readonly y: Schema.Finite;
|
|
214
|
+
readonly z: Schema.Finite;
|
|
215
|
+
}>;
|
|
216
|
+
readonly kind: Schema.Literal<"vector">;
|
|
217
|
+
readonly to: Schema.Struct<{
|
|
218
|
+
readonly x: Schema.Finite;
|
|
219
|
+
readonly y: Schema.Finite;
|
|
220
|
+
readonly z: Schema.Finite;
|
|
221
|
+
}>;
|
|
208
222
|
}>]>;
|
|
209
223
|
export type SpaceMathObject = typeof SpaceMathObjectSchema.Type;
|
|
210
224
|
/** Exact Cartesian frame presented behind a space construction. */
|
|
@@ -493,8 +507,23 @@ export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
|
493
507
|
readonly y: Schema.Finite;
|
|
494
508
|
readonly z: Schema.Finite;
|
|
495
509
|
}>;
|
|
510
|
+
}>, Schema.Struct<{
|
|
511
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
512
|
+
readonly id: Schema.String;
|
|
513
|
+
readonly from: Schema.Struct<{
|
|
514
|
+
readonly x: Schema.Finite;
|
|
515
|
+
readonly y: Schema.Finite;
|
|
516
|
+
readonly z: Schema.Finite;
|
|
517
|
+
}>;
|
|
518
|
+
readonly kind: Schema.Literal<"vector">;
|
|
519
|
+
readonly to: Schema.Struct<{
|
|
520
|
+
readonly x: Schema.Finite;
|
|
521
|
+
readonly y: Schema.Finite;
|
|
522
|
+
readonly z: Schema.Finite;
|
|
523
|
+
}>;
|
|
496
524
|
}>]>>;
|
|
497
525
|
readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
526
|
+
readonly label: Schema.optionalKey<Schema.String>;
|
|
498
527
|
readonly max: Schema.Finite;
|
|
499
528
|
readonly min: Schema.Finite;
|
|
500
529
|
readonly name: Schema.String;
|
package/dist/math/space.js
CHANGED
|
@@ -3,7 +3,7 @@ import { hasUniquePositions, MathAxisRangeSchema, MathViewPaddingSchema, mathVis
|
|
|
3
3
|
import { spaceBoundsIssues } from "#contracts/math/bounds";
|
|
4
4
|
import { FormulaParameterSchema } from "#contracts/math/formula/field";
|
|
5
5
|
import { formulaScopeIssues, parameterScope, spaceFormulaFields, } from "#contracts/math/formula/scope";
|
|
6
|
-
import { MATH_LINE_MESSAGE, MATH_POLYLINE_MESSAGE, MATH_RAY_MESSAGE, MATH_SEGMENT_MESSAGE, MathObjectFields, mathLabelAnchorFields, } from "#contracts/math/object";
|
|
6
|
+
import { MATH_LINE_MESSAGE, MATH_POLYLINE_MESSAGE, MATH_RAY_MESSAGE, MATH_SEGMENT_MESSAGE, MATH_VECTOR_MESSAGE, MathObjectFields, mathLabelAnchorFields, } from "#contracts/math/object";
|
|
7
7
|
import { spaceResolutionIssues } from "#contracts/math/resolution";
|
|
8
8
|
import { SpaceSolidObjectSchemas } from "#contracts/math/solid";
|
|
9
9
|
import { hasCoplanarArea } from "#contracts/math/vector";
|
|
@@ -37,6 +37,18 @@ const SpaceSegmentObjectSchema = Schema.Struct({
|
|
|
37
37
|
}).pipe(Schema.check(Schema.makeFilter(({ from, to }) => !sameSpacePoint(from, to), {
|
|
38
38
|
message: MATH_SEGMENT_MESSAGE,
|
|
39
39
|
})));
|
|
40
|
+
/**
|
|
41
|
+
* An arrow from its tail to its head, such as a displacement, a force, or a
|
|
42
|
+
* position vector: a segment that ends in an arrowhead.
|
|
43
|
+
*/
|
|
44
|
+
const SpaceVectorObjectSchema = Schema.Struct({
|
|
45
|
+
...MathObjectFields,
|
|
46
|
+
from: SpacePointSchema,
|
|
47
|
+
kind: Schema.Literal("vector"),
|
|
48
|
+
to: SpacePointSchema,
|
|
49
|
+
}).pipe(Schema.check(Schema.makeFilter(({ from, to }) => !sameSpacePoint(from, to), {
|
|
50
|
+
message: MATH_VECTOR_MESSAGE,
|
|
51
|
+
})));
|
|
40
52
|
const SpacePolylineObjectSchema = Schema.Struct({
|
|
41
53
|
...MathObjectFields,
|
|
42
54
|
kind: Schema.Literal("polyline"),
|
|
@@ -73,6 +85,7 @@ export const SpaceMathObjectSchema = Schema.Union([
|
|
|
73
85
|
SpacePolylineObjectSchema,
|
|
74
86
|
SpaceRayObjectSchema,
|
|
75
87
|
SpaceSegmentObjectSchema,
|
|
88
|
+
SpaceVectorObjectSchema,
|
|
76
89
|
]);
|
|
77
90
|
/** Exact Cartesian frame presented behind a space construction. */
|
|
78
91
|
export const SpaceMathFrameSchema = Schema.Struct({
|
package/dist/math/visual.d.ts
CHANGED
|
@@ -13,10 +13,13 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
13
13
|
}>;
|
|
14
14
|
}>;
|
|
15
15
|
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
16
|
-
readonly at: Schema.Struct<{
|
|
16
|
+
readonly at: Schema.Union<readonly [Schema.Struct<{
|
|
17
17
|
readonly x: Schema.Finite;
|
|
18
18
|
readonly y: Schema.Finite;
|
|
19
|
-
}
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
readonly x: Schema.String;
|
|
21
|
+
readonly y: Schema.String;
|
|
22
|
+
}>]>;
|
|
20
23
|
readonly key: Schema.String;
|
|
21
24
|
readonly objectId: Schema.String;
|
|
22
25
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
@@ -36,6 +39,20 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
36
39
|
readonly id: Schema.String;
|
|
37
40
|
readonly equation: Schema.String;
|
|
38
41
|
readonly kind: Schema.Literal<"implicit">;
|
|
42
|
+
}>, Schema.Struct<{
|
|
43
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
44
|
+
readonly id: Schema.String;
|
|
45
|
+
readonly kind: Schema.Literal<"loop">;
|
|
46
|
+
readonly points: Schema.$Array<Schema.Struct<{
|
|
47
|
+
readonly x: Schema.String;
|
|
48
|
+
readonly y: Schema.String;
|
|
49
|
+
}>>;
|
|
50
|
+
}>, Schema.Struct<{
|
|
51
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
52
|
+
readonly id: Schema.String;
|
|
53
|
+
readonly kind: Schema.Literal<"marker">;
|
|
54
|
+
readonly x: Schema.String;
|
|
55
|
+
readonly y: Schema.String;
|
|
39
56
|
}>, Schema.Struct<{
|
|
40
57
|
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
41
58
|
readonly id: Schema.String;
|
|
@@ -46,6 +63,14 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
46
63
|
}>;
|
|
47
64
|
readonly x: Schema.String;
|
|
48
65
|
readonly y: Schema.String;
|
|
66
|
+
}>, Schema.Struct<{
|
|
67
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
68
|
+
readonly id: Schema.String;
|
|
69
|
+
readonly kind: Schema.Literal<"path">;
|
|
70
|
+
readonly points: Schema.$Array<Schema.Struct<{
|
|
71
|
+
readonly x: Schema.String;
|
|
72
|
+
readonly y: Schema.String;
|
|
73
|
+
}>>;
|
|
49
74
|
}>, Schema.Struct<{
|
|
50
75
|
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
51
76
|
readonly id: Schema.String;
|
|
@@ -168,14 +193,31 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
168
193
|
readonly x: Schema.Finite;
|
|
169
194
|
readonly y: Schema.Finite;
|
|
170
195
|
}>;
|
|
196
|
+
}>, Schema.Struct<{
|
|
197
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
198
|
+
readonly id: Schema.String;
|
|
199
|
+
readonly from: Schema.Struct<{
|
|
200
|
+
readonly x: Schema.Finite;
|
|
201
|
+
readonly y: Schema.Finite;
|
|
202
|
+
}>;
|
|
203
|
+
readonly kind: Schema.Literal<"vector">;
|
|
204
|
+
readonly to: Schema.Struct<{
|
|
205
|
+
readonly x: Schema.Finite;
|
|
206
|
+
readonly y: Schema.Finite;
|
|
207
|
+
}>;
|
|
171
208
|
}>]>>;
|
|
172
209
|
readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
210
|
+
readonly label: Schema.optionalKey<Schema.String>;
|
|
173
211
|
readonly max: Schema.Finite;
|
|
174
212
|
readonly min: Schema.Finite;
|
|
175
213
|
readonly name: Schema.String;
|
|
176
214
|
readonly step: Schema.optionalKey<Schema.Finite>;
|
|
177
215
|
readonly value: Schema.Finite;
|
|
178
216
|
}>>>;
|
|
217
|
+
readonly readouts: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
218
|
+
readonly formula: Schema.String;
|
|
219
|
+
readonly key: Schema.String;
|
|
220
|
+
}>>>;
|
|
179
221
|
readonly space: Schema.Literal<"plane">;
|
|
180
222
|
readonly view: Schema.Struct<{
|
|
181
223
|
readonly kind: Schema.Literal<"fit">;
|
|
@@ -412,8 +454,23 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
412
454
|
readonly y: Schema.Finite;
|
|
413
455
|
readonly z: Schema.Finite;
|
|
414
456
|
}>;
|
|
457
|
+
}>, Schema.Struct<{
|
|
458
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
459
|
+
readonly id: Schema.String;
|
|
460
|
+
readonly from: Schema.Struct<{
|
|
461
|
+
readonly x: Schema.Finite;
|
|
462
|
+
readonly y: Schema.Finite;
|
|
463
|
+
readonly z: Schema.Finite;
|
|
464
|
+
}>;
|
|
465
|
+
readonly kind: Schema.Literal<"vector">;
|
|
466
|
+
readonly to: Schema.Struct<{
|
|
467
|
+
readonly x: Schema.Finite;
|
|
468
|
+
readonly y: Schema.Finite;
|
|
469
|
+
readonly z: Schema.Finite;
|
|
470
|
+
}>;
|
|
415
471
|
}>]>>;
|
|
416
472
|
readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
473
|
+
readonly label: Schema.optionalKey<Schema.String>;
|
|
417
474
|
readonly max: Schema.Finite;
|
|
418
475
|
readonly min: Schema.Finite;
|
|
419
476
|
readonly name: Schema.String;
|
|
@@ -611,6 +668,20 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
611
668
|
readonly y: number;
|
|
612
669
|
readonly z: number;
|
|
613
670
|
};
|
|
671
|
+
} | {
|
|
672
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
673
|
+
readonly id: string;
|
|
674
|
+
readonly from: {
|
|
675
|
+
readonly x: number;
|
|
676
|
+
readonly y: number;
|
|
677
|
+
readonly z: number;
|
|
678
|
+
};
|
|
679
|
+
readonly kind: "vector";
|
|
680
|
+
readonly to: {
|
|
681
|
+
readonly x: number;
|
|
682
|
+
readonly y: number;
|
|
683
|
+
readonly z: number;
|
|
684
|
+
};
|
|
614
685
|
} | {
|
|
615
686
|
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
616
687
|
readonly id: string;
|
|
@@ -816,6 +887,20 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
816
887
|
readonly y: number;
|
|
817
888
|
readonly z: number;
|
|
818
889
|
};
|
|
890
|
+
} | {
|
|
891
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
892
|
+
readonly id: string;
|
|
893
|
+
readonly from: {
|
|
894
|
+
readonly x: number;
|
|
895
|
+
readonly y: number;
|
|
896
|
+
readonly z: number;
|
|
897
|
+
};
|
|
898
|
+
readonly kind: "vector";
|
|
899
|
+
readonly to: {
|
|
900
|
+
readonly x: number;
|
|
901
|
+
readonly y: number;
|
|
902
|
+
readonly z: number;
|
|
903
|
+
};
|
|
819
904
|
} | {
|
|
820
905
|
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
821
906
|
readonly id: string;
|
|
@@ -885,6 +970,7 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
885
970
|
readonly kind: "function";
|
|
886
971
|
})[]];
|
|
887
972
|
readonly parameters?: readonly {
|
|
973
|
+
readonly label?: string;
|
|
888
974
|
readonly max: number;
|
|
889
975
|
readonly min: number;
|
|
890
976
|
readonly name: string;
|
|
@@ -929,6 +1015,9 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
929
1015
|
};
|
|
930
1016
|
readonly labels?: readonly {
|
|
931
1017
|
readonly at: {
|
|
1018
|
+
readonly x: string;
|
|
1019
|
+
readonly y: string;
|
|
1020
|
+
} | {
|
|
932
1021
|
readonly x: number;
|
|
933
1022
|
readonly y: number;
|
|
934
1023
|
};
|
|
@@ -965,6 +1054,28 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
965
1054
|
readonly id: string;
|
|
966
1055
|
readonly inequalities: readonly [string, ...string[]];
|
|
967
1056
|
readonly kind: "region";
|
|
1057
|
+
} | {
|
|
1058
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1059
|
+
readonly id: string;
|
|
1060
|
+
readonly kind: "marker";
|
|
1061
|
+
readonly x: string;
|
|
1062
|
+
readonly y: string;
|
|
1063
|
+
} | {
|
|
1064
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1065
|
+
readonly id: string;
|
|
1066
|
+
readonly kind: "path";
|
|
1067
|
+
readonly points: readonly {
|
|
1068
|
+
readonly x: string;
|
|
1069
|
+
readonly y: string;
|
|
1070
|
+
}[];
|
|
1071
|
+
} | {
|
|
1072
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1073
|
+
readonly id: string;
|
|
1074
|
+
readonly kind: "loop";
|
|
1075
|
+
readonly points: readonly {
|
|
1076
|
+
readonly x: string;
|
|
1077
|
+
readonly y: string;
|
|
1078
|
+
}[];
|
|
968
1079
|
} | {
|
|
969
1080
|
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
970
1081
|
readonly id: string;
|
|
@@ -1008,6 +1119,18 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
1008
1119
|
readonly x: number;
|
|
1009
1120
|
readonly y: number;
|
|
1010
1121
|
};
|
|
1122
|
+
} | {
|
|
1123
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1124
|
+
readonly id: string;
|
|
1125
|
+
readonly from: {
|
|
1126
|
+
readonly x: number;
|
|
1127
|
+
readonly y: number;
|
|
1128
|
+
};
|
|
1129
|
+
readonly kind: "vector";
|
|
1130
|
+
readonly to: {
|
|
1131
|
+
readonly x: number;
|
|
1132
|
+
readonly y: number;
|
|
1133
|
+
};
|
|
1011
1134
|
} | {
|
|
1012
1135
|
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1013
1136
|
readonly id: string;
|
|
@@ -1112,6 +1235,28 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
1112
1235
|
readonly id: string;
|
|
1113
1236
|
readonly inequalities: readonly [string, ...string[]];
|
|
1114
1237
|
readonly kind: "region";
|
|
1238
|
+
} | {
|
|
1239
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1240
|
+
readonly id: string;
|
|
1241
|
+
readonly kind: "marker";
|
|
1242
|
+
readonly x: string;
|
|
1243
|
+
readonly y: string;
|
|
1244
|
+
} | {
|
|
1245
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1246
|
+
readonly id: string;
|
|
1247
|
+
readonly kind: "path";
|
|
1248
|
+
readonly points: readonly {
|
|
1249
|
+
readonly x: string;
|
|
1250
|
+
readonly y: string;
|
|
1251
|
+
}[];
|
|
1252
|
+
} | {
|
|
1253
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1254
|
+
readonly id: string;
|
|
1255
|
+
readonly kind: "loop";
|
|
1256
|
+
readonly points: readonly {
|
|
1257
|
+
readonly x: string;
|
|
1258
|
+
readonly y: string;
|
|
1259
|
+
}[];
|
|
1115
1260
|
} | {
|
|
1116
1261
|
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1117
1262
|
readonly id: string;
|
|
@@ -1155,6 +1300,18 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
1155
1300
|
readonly x: number;
|
|
1156
1301
|
readonly y: number;
|
|
1157
1302
|
};
|
|
1303
|
+
} | {
|
|
1304
|
+
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1305
|
+
readonly id: string;
|
|
1306
|
+
readonly from: {
|
|
1307
|
+
readonly x: number;
|
|
1308
|
+
readonly y: number;
|
|
1309
|
+
};
|
|
1310
|
+
readonly kind: "vector";
|
|
1311
|
+
readonly to: {
|
|
1312
|
+
readonly x: number;
|
|
1313
|
+
readonly y: number;
|
|
1314
|
+
};
|
|
1158
1315
|
} | {
|
|
1159
1316
|
readonly appearance: "answer" | "construction" | "highlight" | "primary" | "reference" | "secondary" | "warning";
|
|
1160
1317
|
readonly id: string;
|
|
@@ -1232,17 +1389,26 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
1232
1389
|
readonly kind: "function";
|
|
1233
1390
|
})[]];
|
|
1234
1391
|
readonly parameters?: readonly {
|
|
1392
|
+
readonly label?: string;
|
|
1235
1393
|
readonly max: number;
|
|
1236
1394
|
readonly min: number;
|
|
1237
1395
|
readonly name: string;
|
|
1238
1396
|
readonly step?: number;
|
|
1239
1397
|
readonly value: number;
|
|
1240
1398
|
}[];
|
|
1399
|
+
readonly readouts?: readonly {
|
|
1400
|
+
readonly formula: string;
|
|
1401
|
+
readonly key: string;
|
|
1402
|
+
}[];
|
|
1241
1403
|
readonly space: "plane";
|
|
1242
1404
|
readonly view: {
|
|
1243
1405
|
readonly kind: "fit";
|
|
1244
1406
|
readonly padding?: number;
|
|
1245
1407
|
};
|
|
1246
1408
|
}, import("../errors.js").ContractDecodeError, never>;
|
|
1247
|
-
/**
|
|
1409
|
+
/**
|
|
1410
|
+
* Returns every rich-label key a scene names, once each: its anchors in
|
|
1411
|
+
* authored order, then its readouts and its sliders' labels. A readout or a
|
|
1412
|
+
* slider may show the same rich label as an anchor.
|
|
1413
|
+
*/
|
|
1248
1414
|
export declare function mathVisualLabelKeys(visual: MathVisual): string[];
|
package/dist/math/visual.js
CHANGED
|
@@ -9,7 +9,17 @@ export const MathVisualSchema = Schema.Union([
|
|
|
9
9
|
]);
|
|
10
10
|
/** Strictly decodes one untrusted mathematical scene into its stable contract. */
|
|
11
11
|
export const decodeMathVisual = Effect.fn("AksaraContracts.decodeMathVisual")((input) => decodeContract(MathVisualSchema, "MathVisual", input));
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Returns every rich-label key a scene names, once each: its anchors in
|
|
14
|
+
* authored order, then its readouts and its sliders' labels. A readout or a
|
|
15
|
+
* slider may show the same rich label as an anchor.
|
|
16
|
+
*/
|
|
13
17
|
export function mathVisualLabelKeys(visual) {
|
|
14
|
-
return Arr.
|
|
18
|
+
return Arr.dedupe([
|
|
19
|
+
...Arr.map(visual.labels ?? [], ({ key }) => key),
|
|
20
|
+
...(visual.space === "plane"
|
|
21
|
+
? Arr.map(visual.readouts ?? [], ({ key }) => key)
|
|
22
|
+
: []),
|
|
23
|
+
...Arr.flatMap(visual.parameters ?? [], ({ label }) => label === undefined ? [] : [label]),
|
|
24
|
+
]);
|
|
15
25
|
}
|
package/package.json
CHANGED