@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.
@@ -76,10 +76,13 @@ export declare const MathVisualPropsSchema: Schema.Struct<{
76
76
  }>;
77
77
  }>;
78
78
  readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
79
- readonly at: Schema.Struct<{
79
+ readonly at: Schema.Union<readonly [Schema.Struct<{
80
80
  readonly x: Schema.Finite;
81
81
  readonly y: Schema.Finite;
82
- }>;
82
+ }>, Schema.Struct<{
83
+ readonly x: Schema.String;
84
+ readonly y: Schema.String;
85
+ }>]>;
83
86
  readonly key: Schema.String;
84
87
  readonly objectId: Schema.String;
85
88
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
@@ -99,6 +102,20 @@ export declare const MathVisualPropsSchema: Schema.Struct<{
99
102
  readonly id: Schema.String;
100
103
  readonly equation: Schema.String;
101
104
  readonly kind: Schema.Literal<"implicit">;
105
+ }>, Schema.Struct<{
106
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
107
+ readonly id: Schema.String;
108
+ readonly kind: Schema.Literal<"loop">;
109
+ readonly points: Schema.$Array<Schema.Struct<{
110
+ readonly x: Schema.String;
111
+ readonly y: Schema.String;
112
+ }>>;
113
+ }>, Schema.Struct<{
114
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
115
+ readonly id: Schema.String;
116
+ readonly kind: Schema.Literal<"marker">;
117
+ readonly x: Schema.String;
118
+ readonly y: Schema.String;
102
119
  }>, Schema.Struct<{
103
120
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
104
121
  readonly id: Schema.String;
@@ -109,6 +126,14 @@ export declare const MathVisualPropsSchema: Schema.Struct<{
109
126
  }>;
110
127
  readonly x: Schema.String;
111
128
  readonly y: Schema.String;
129
+ }>, Schema.Struct<{
130
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
131
+ readonly id: Schema.String;
132
+ readonly kind: Schema.Literal<"path">;
133
+ readonly points: Schema.$Array<Schema.Struct<{
134
+ readonly x: Schema.String;
135
+ readonly y: Schema.String;
136
+ }>>;
112
137
  }>, Schema.Struct<{
113
138
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
114
139
  readonly id: Schema.String;
@@ -231,14 +256,31 @@ export declare const MathVisualPropsSchema: Schema.Struct<{
231
256
  readonly x: Schema.Finite;
232
257
  readonly y: Schema.Finite;
233
258
  }>;
259
+ }>, Schema.Struct<{
260
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
261
+ readonly id: Schema.String;
262
+ readonly from: Schema.Struct<{
263
+ readonly x: Schema.Finite;
264
+ readonly y: Schema.Finite;
265
+ }>;
266
+ readonly kind: Schema.Literal<"vector">;
267
+ readonly to: Schema.Struct<{
268
+ readonly x: Schema.Finite;
269
+ readonly y: Schema.Finite;
270
+ }>;
234
271
  }>]>>;
235
272
  readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
273
+ readonly label: Schema.optionalKey<Schema.String>;
236
274
  readonly max: Schema.Finite;
237
275
  readonly min: Schema.Finite;
238
276
  readonly name: Schema.String;
239
277
  readonly step: Schema.optionalKey<Schema.Finite>;
240
278
  readonly value: Schema.Finite;
241
279
  }>>>;
280
+ readonly readouts: Schema.optionalKey<Schema.$Array<Schema.Struct<{
281
+ readonly formula: Schema.String;
282
+ readonly key: Schema.String;
283
+ }>>>;
242
284
  readonly space: Schema.Literal<"plane">;
243
285
  readonly view: Schema.Struct<{
244
286
  readonly kind: Schema.Literal<"fit">;
@@ -475,8 +517,23 @@ export declare const MathVisualPropsSchema: Schema.Struct<{
475
517
  readonly y: Schema.Finite;
476
518
  readonly z: Schema.Finite;
477
519
  }>;
520
+ }>, Schema.Struct<{
521
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
522
+ readonly id: Schema.String;
523
+ readonly from: Schema.Struct<{
524
+ readonly x: Schema.Finite;
525
+ readonly y: Schema.Finite;
526
+ readonly z: Schema.Finite;
527
+ }>;
528
+ readonly kind: Schema.Literal<"vector">;
529
+ readonly to: Schema.Struct<{
530
+ readonly x: Schema.Finite;
531
+ readonly y: Schema.Finite;
532
+ readonly z: Schema.Finite;
533
+ }>;
478
534
  }>]>>;
479
535
  readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
536
+ readonly label: Schema.optionalKey<Schema.String>;
480
537
  readonly max: Schema.Finite;
481
538
  readonly min: Schema.Finite;
482
539
  readonly name: Schema.String;
@@ -902,10 +959,13 @@ export declare const FigureAttrsSchema: Schema.Union<readonly [Schema.Struct<{
902
959
  }>;
903
960
  }>;
904
961
  readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
905
- readonly at: Schema.Struct<{
962
+ readonly at: Schema.Union<readonly [Schema.Struct<{
906
963
  readonly x: Schema.Finite;
907
964
  readonly y: Schema.Finite;
908
- }>;
965
+ }>, Schema.Struct<{
966
+ readonly x: Schema.String;
967
+ readonly y: Schema.String;
968
+ }>]>;
909
969
  readonly key: Schema.String;
910
970
  readonly objectId: Schema.String;
911
971
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
@@ -925,6 +985,20 @@ export declare const FigureAttrsSchema: Schema.Union<readonly [Schema.Struct<{
925
985
  readonly id: Schema.String;
926
986
  readonly equation: Schema.String;
927
987
  readonly kind: Schema.Literal<"implicit">;
988
+ }>, Schema.Struct<{
989
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
990
+ readonly id: Schema.String;
991
+ readonly kind: Schema.Literal<"loop">;
992
+ readonly points: Schema.$Array<Schema.Struct<{
993
+ readonly x: Schema.String;
994
+ readonly y: Schema.String;
995
+ }>>;
996
+ }>, Schema.Struct<{
997
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
998
+ readonly id: Schema.String;
999
+ readonly kind: Schema.Literal<"marker">;
1000
+ readonly x: Schema.String;
1001
+ readonly y: Schema.String;
928
1002
  }>, Schema.Struct<{
929
1003
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
930
1004
  readonly id: Schema.String;
@@ -935,6 +1009,14 @@ export declare const FigureAttrsSchema: Schema.Union<readonly [Schema.Struct<{
935
1009
  }>;
936
1010
  readonly x: Schema.String;
937
1011
  readonly y: Schema.String;
1012
+ }>, Schema.Struct<{
1013
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1014
+ readonly id: Schema.String;
1015
+ readonly kind: Schema.Literal<"path">;
1016
+ readonly points: Schema.$Array<Schema.Struct<{
1017
+ readonly x: Schema.String;
1018
+ readonly y: Schema.String;
1019
+ }>>;
938
1020
  }>, Schema.Struct<{
939
1021
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
940
1022
  readonly id: Schema.String;
@@ -1057,14 +1139,31 @@ export declare const FigureAttrsSchema: Schema.Union<readonly [Schema.Struct<{
1057
1139
  readonly x: Schema.Finite;
1058
1140
  readonly y: Schema.Finite;
1059
1141
  }>;
1142
+ }>, Schema.Struct<{
1143
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1144
+ readonly id: Schema.String;
1145
+ readonly from: Schema.Struct<{
1146
+ readonly x: Schema.Finite;
1147
+ readonly y: Schema.Finite;
1148
+ }>;
1149
+ readonly kind: Schema.Literal<"vector">;
1150
+ readonly to: Schema.Struct<{
1151
+ readonly x: Schema.Finite;
1152
+ readonly y: Schema.Finite;
1153
+ }>;
1060
1154
  }>]>>;
1061
1155
  readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1156
+ readonly label: Schema.optionalKey<Schema.String>;
1062
1157
  readonly max: Schema.Finite;
1063
1158
  readonly min: Schema.Finite;
1064
1159
  readonly name: Schema.String;
1065
1160
  readonly step: Schema.optionalKey<Schema.Finite>;
1066
1161
  readonly value: Schema.Finite;
1067
1162
  }>>>;
1163
+ readonly readouts: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1164
+ readonly formula: Schema.String;
1165
+ readonly key: Schema.String;
1166
+ }>>>;
1068
1167
  readonly space: Schema.Literal<"plane">;
1069
1168
  readonly view: Schema.Struct<{
1070
1169
  readonly kind: Schema.Literal<"fit">;
@@ -1301,8 +1400,23 @@ export declare const FigureAttrsSchema: Schema.Union<readonly [Schema.Struct<{
1301
1400
  readonly y: Schema.Finite;
1302
1401
  readonly z: Schema.Finite;
1303
1402
  }>;
1403
+ }>, Schema.Struct<{
1404
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1405
+ readonly id: Schema.String;
1406
+ readonly from: Schema.Struct<{
1407
+ readonly x: Schema.Finite;
1408
+ readonly y: Schema.Finite;
1409
+ readonly z: Schema.Finite;
1410
+ }>;
1411
+ readonly kind: Schema.Literal<"vector">;
1412
+ readonly to: Schema.Struct<{
1413
+ readonly x: Schema.Finite;
1414
+ readonly y: Schema.Finite;
1415
+ readonly z: Schema.Finite;
1416
+ }>;
1304
1417
  }>]>>;
1305
1418
  readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1419
+ readonly label: Schema.optionalKey<Schema.String>;
1306
1420
  readonly max: Schema.Finite;
1307
1421
  readonly min: Schema.Finite;
1308
1422
  readonly name: Schema.String;
@@ -1799,10 +1913,13 @@ export declare const FigureNodeSchema: Schema.Struct<{
1799
1913
  }>;
1800
1914
  }>;
1801
1915
  readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1802
- readonly at: Schema.Struct<{
1916
+ readonly at: Schema.Union<readonly [Schema.Struct<{
1803
1917
  readonly x: Schema.Finite;
1804
1918
  readonly y: Schema.Finite;
1805
- }>;
1919
+ }>, Schema.Struct<{
1920
+ readonly x: Schema.String;
1921
+ readonly y: Schema.String;
1922
+ }>]>;
1806
1923
  readonly key: Schema.String;
1807
1924
  readonly objectId: Schema.String;
1808
1925
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
@@ -1822,6 +1939,20 @@ export declare const FigureNodeSchema: Schema.Struct<{
1822
1939
  readonly id: Schema.String;
1823
1940
  readonly equation: Schema.String;
1824
1941
  readonly kind: Schema.Literal<"implicit">;
1942
+ }>, Schema.Struct<{
1943
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1944
+ readonly id: Schema.String;
1945
+ readonly kind: Schema.Literal<"loop">;
1946
+ readonly points: Schema.$Array<Schema.Struct<{
1947
+ readonly x: Schema.String;
1948
+ readonly y: Schema.String;
1949
+ }>>;
1950
+ }>, Schema.Struct<{
1951
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1952
+ readonly id: Schema.String;
1953
+ readonly kind: Schema.Literal<"marker">;
1954
+ readonly x: Schema.String;
1955
+ readonly y: Schema.String;
1825
1956
  }>, Schema.Struct<{
1826
1957
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1827
1958
  readonly id: Schema.String;
@@ -1832,6 +1963,14 @@ export declare const FigureNodeSchema: Schema.Struct<{
1832
1963
  }>;
1833
1964
  readonly x: Schema.String;
1834
1965
  readonly y: Schema.String;
1966
+ }>, Schema.Struct<{
1967
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1968
+ readonly id: Schema.String;
1969
+ readonly kind: Schema.Literal<"path">;
1970
+ readonly points: Schema.$Array<Schema.Struct<{
1971
+ readonly x: Schema.String;
1972
+ readonly y: Schema.String;
1973
+ }>>;
1835
1974
  }>, Schema.Struct<{
1836
1975
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
1837
1976
  readonly id: Schema.String;
@@ -1954,14 +2093,31 @@ export declare const FigureNodeSchema: Schema.Struct<{
1954
2093
  readonly x: Schema.Finite;
1955
2094
  readonly y: Schema.Finite;
1956
2095
  }>;
2096
+ }>, Schema.Struct<{
2097
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
2098
+ readonly id: Schema.String;
2099
+ readonly from: Schema.Struct<{
2100
+ readonly x: Schema.Finite;
2101
+ readonly y: Schema.Finite;
2102
+ }>;
2103
+ readonly kind: Schema.Literal<"vector">;
2104
+ readonly to: Schema.Struct<{
2105
+ readonly x: Schema.Finite;
2106
+ readonly y: Schema.Finite;
2107
+ }>;
1957
2108
  }>]>>;
1958
2109
  readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2110
+ readonly label: Schema.optionalKey<Schema.String>;
1959
2111
  readonly max: Schema.Finite;
1960
2112
  readonly min: Schema.Finite;
1961
2113
  readonly name: Schema.String;
1962
2114
  readonly step: Schema.optionalKey<Schema.Finite>;
1963
2115
  readonly value: Schema.Finite;
1964
2116
  }>>>;
2117
+ readonly readouts: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2118
+ readonly formula: Schema.String;
2119
+ readonly key: Schema.String;
2120
+ }>>>;
1965
2121
  readonly space: Schema.Literal<"plane">;
1966
2122
  readonly view: Schema.Struct<{
1967
2123
  readonly kind: Schema.Literal<"fit">;
@@ -2198,8 +2354,23 @@ export declare const FigureNodeSchema: Schema.Struct<{
2198
2354
  readonly y: Schema.Finite;
2199
2355
  readonly z: Schema.Finite;
2200
2356
  }>;
2357
+ }>, Schema.Struct<{
2358
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
2359
+ readonly id: Schema.String;
2360
+ readonly from: Schema.Struct<{
2361
+ readonly x: Schema.Finite;
2362
+ readonly y: Schema.Finite;
2363
+ readonly z: Schema.Finite;
2364
+ }>;
2365
+ readonly kind: Schema.Literal<"vector">;
2366
+ readonly to: Schema.Struct<{
2367
+ readonly x: Schema.Finite;
2368
+ readonly y: Schema.Finite;
2369
+ readonly z: Schema.Finite;
2370
+ }>;
2201
2371
  }>]>>;
2202
2372
  readonly parameters: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2373
+ readonly label: Schema.optionalKey<Schema.String>;
2203
2374
  readonly max: Schema.Finite;
2204
2375
  readonly min: Schema.Finite;
2205
2376
  readonly name: Schema.String;
@@ -1,6 +1,7 @@
1
- import { Array as Arr, Result } from "effect";
1
+ import { Array as Arr, Option, Result } from "effect";
2
2
  import { arcContained, axisContains, circleContained, cuboidContained, quadraticContained, } from "#contracts/math/extent";
3
- import { planeFormulaGeometry, } from "#contracts/math/formula/plane";
3
+ import { isPlaneFormulaPoint } from "#contracts/math/formula/field";
4
+ import { planeFormulaGeometry, planeFormulaPoint, } from "#contracts/math/formula/plane";
4
5
  import { geometryVisible } from "#contracts/math/formula/scope";
5
6
  import { spaceFormulaGeometry } from "#contracts/math/formula/space";
6
7
  import { infinitePathIntersectsBox } from "#contracts/math/intersection";
@@ -45,11 +46,14 @@ function sampledVisible(geometry, frame) {
45
46
  function planeObjectContained(frame, object, scope, labels) {
46
47
  if (object.kind === "function") {
47
48
  const axis = object.inputAxis ?? "x";
48
- const named = Arr.flatMap(labels, ({ at, objectId }) => objectId === object.id ? [at[axis]] : []);
49
+ const named = Arr.flatMap(labels, ({ at, objectId }) => objectId === object.id && !isPlaneFormulaPoint(at) ? [at[axis]] : []);
49
50
  return sampledVisible(planeFormulaGeometry(object, frame, scope, named), frame);
50
51
  }
51
52
  if (object.kind === "implicit" ||
53
+ object.kind === "loop" ||
54
+ object.kind === "marker" ||
52
55
  object.kind === "parametric" ||
56
+ object.kind === "path" ||
53
57
  object.kind === "polar" ||
54
58
  object.kind === "region") {
55
59
  return sampledVisible(planeFormulaGeometry(object, frame, scope), frame);
@@ -64,7 +68,7 @@ function planeObjectContained(frame, object, scope, labels) {
64
68
  if (object.kind === "point") {
65
69
  return planeContains(frame, object.at);
66
70
  }
67
- if (object.kind === "segment") {
71
+ if (object.kind === "segment" || object.kind === "vector") {
68
72
  return Arr.every([object.from, object.to], (point) => planeContains(frame, point));
69
73
  }
70
74
  if (object.kind === "polyline" || object.kind === "polygon") {
@@ -98,7 +102,7 @@ function spaceObjectContained(frame, object, scope) {
98
102
  if (object.kind === "point") {
99
103
  return spaceContains(frame, object.at);
100
104
  }
101
- if (object.kind === "segment") {
105
+ if (object.kind === "segment" || object.kind === "vector") {
102
106
  return Arr.every([object.from, object.to], (point) => spaceContains(frame, point));
103
107
  }
104
108
  if (object.kind === "polyline" || object.kind === "polygon") {
@@ -106,6 +110,19 @@ function spaceObjectContained(frame, object, scope) {
106
110
  }
107
111
  return cuboidContained(frame, object);
108
112
  }
113
+ /**
114
+ * Whether a plane label starts inside its frame. A label placed by formulas is
115
+ * checked where the sliders start; a formula that does not read is reported by
116
+ * its own field, so it is not reported again.
117
+ */
118
+ function planeLabelContained(frame, label, scope) {
119
+ if (!isPlaneFormulaPoint(label.at)) {
120
+ return planeContains(frame, label.at);
121
+ }
122
+ const placed = planeFormulaPoint(label.at, scope);
123
+ return (Result.isFailure(placed) ||
124
+ Option.exists(placed.success, (point) => planeContains(frame, point)));
125
+ }
109
126
  /** Reports every finite plane object or label that escapes its authored frame. */
110
127
  export function planeBoundsIssues(frame, objects, labels, scope = {}) {
111
128
  return [
@@ -117,7 +134,7 @@ export function planeBoundsIssues(frame, objects, labels, scope = {}) {
117
134
  path: ["objects", index],
118
135
  },
119
136
  ]),
120
- ...Arr.flatMap(labels, (label, index) => planeContains(frame, label.at)
137
+ ...Arr.flatMap(labels, (label, index) => planeLabelContained(frame, label, scope)
121
138
  ? []
122
139
  : [
123
140
  {
@@ -15,6 +15,20 @@ export declare const PlaneCurveObjectSchemas: readonly [Schema.Struct<{
15
15
  readonly id: Schema.String;
16
16
  readonly equation: Schema.String;
17
17
  readonly kind: Schema.Literal<"implicit">;
18
+ }>, Schema.Struct<{
19
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
20
+ readonly id: Schema.String;
21
+ readonly kind: Schema.Literal<"loop">;
22
+ readonly points: Schema.$Array<Schema.Struct<{
23
+ readonly x: Schema.String;
24
+ readonly y: Schema.String;
25
+ }>>;
26
+ }>, Schema.Struct<{
27
+ readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
28
+ readonly id: Schema.String;
29
+ readonly kind: Schema.Literal<"marker">;
30
+ readonly x: Schema.String;
31
+ readonly y: Schema.String;
18
32
  }>, Schema.Struct<{
19
33
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
20
34
  readonly id: Schema.String;
@@ -25,6 +39,14 @@ export declare const PlaneCurveObjectSchemas: readonly [Schema.Struct<{
25
39
  }>;
26
40
  readonly x: Schema.String;
27
41
  readonly y: Schema.String;
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<"path">;
46
+ readonly points: Schema.$Array<Schema.Struct<{
47
+ readonly x: Schema.String;
48
+ readonly y: Schema.String;
49
+ }>>;
28
50
  }>, Schema.Struct<{
29
51
  readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
30
52
  readonly id: Schema.String;
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { MathAxisRangeSchema } from "#contracts/math/base";
3
- import { EquationTextSchema, FormulaTextSchema, InequalityTextSchema, } from "#contracts/math/formula/field";
3
+ import { EquationTextSchema, FormulaTextSchema, InequalityTextSchema, PlaneFormulaPointSchema, } from "#contracts/math/formula/field";
4
4
  import { MathObjectFields } from "#contracts/math/object";
5
5
  /**
6
6
  * The graph of y = f(x), or of x = f(y) when its input axis is y. The renderer
@@ -45,11 +45,39 @@ const PlaneRegionObjectSchema = Schema.Struct({
45
45
  inequalities: Schema.NonEmptyArray(InequalityTextSchema),
46
46
  kind: Schema.Literal("region"),
47
47
  });
48
+ /** A point placed by formulas of the sliders, which moves as they move. */
49
+ const PlaneMarkerObjectSchema = Schema.Struct({
50
+ ...MathObjectFields,
51
+ kind: Schema.Literal("marker"),
52
+ x: FormulaTextSchema,
53
+ y: FormulaTextSchema,
54
+ });
55
+ /**
56
+ * Straight segments through points placed by formulas of the sliders, such as
57
+ * the moving radius of a unit circle. A `path` stays open.
58
+ */
59
+ const PlanePathObjectSchema = Schema.Struct({
60
+ ...MathObjectFields,
61
+ kind: Schema.Literal("path"),
62
+ points: Schema.Array(PlaneFormulaPointSchema).check(Schema.isMinLength(2)),
63
+ });
64
+ /**
65
+ * A closed outline through points placed by formulas of the sliders, such as
66
+ * a right triangle with angle a: the last point joins back to the first.
67
+ */
68
+ const PlaneLoopObjectSchema = Schema.Struct({
69
+ ...MathObjectFields,
70
+ kind: Schema.Literal("loop"),
71
+ points: Schema.Array(PlaneFormulaPointSchema).check(Schema.isMinLength(3)),
72
+ });
48
73
  /** The plane objects a formula defines, which a renderer samples itself. */
49
74
  export const PlaneCurveObjectSchemas = [
50
75
  PlaneFunctionObjectSchema,
51
76
  PlaneImplicitObjectSchema,
77
+ PlaneLoopObjectSchema,
78
+ PlaneMarkerObjectSchema,
52
79
  PlaneParametricObjectSchema,
80
+ PlanePathObjectSchema,
53
81
  PlanePolarObjectSchema,
54
82
  PlaneRegionObjectSchema,
55
83
  ];
@@ -8,8 +8,11 @@ export declare const InequalityTextSchema: Schema.String;
8
8
  /**
9
9
  * One slider a learner moves to change every formula that reads its name. Its
10
10
  * value starts inside its range, and a positive step, when given, snaps it.
11
+ * A `label` names the rich label the slider shows instead of its letter, such
12
+ * as theta for an angle slider named `a`.
11
13
  */
12
14
  export declare const FormulaParameterSchema: Schema.Struct<{
15
+ readonly label: Schema.optionalKey<Schema.String>;
13
16
  readonly max: Schema.Finite;
14
17
  readonly min: Schema.Finite;
15
18
  readonly name: Schema.String;
@@ -17,3 +20,23 @@ export declare const FormulaParameterSchema: Schema.Struct<{
17
20
  readonly value: Schema.Finite;
18
21
  }>;
19
22
  export type FormulaParameter = typeof FormulaParameterSchema.Type;
23
+ /** A plane point placed by formulas of the sliders, such as (cos(a), sin(a)). */
24
+ export declare const PlaneFormulaPointSchema: Schema.Struct<{
25
+ readonly x: Schema.String;
26
+ readonly y: Schema.String;
27
+ }>;
28
+ export type PlaneFormulaPoint = typeof PlaneFormulaPointSchema.Type;
29
+ /** Whether an anchor is placed by formulas rather than written exactly. */
30
+ export declare const isPlaneFormulaPoint: <I>(input: I) => input is I & {
31
+ readonly x: string;
32
+ readonly y: string;
33
+ };
34
+ /**
35
+ * One value a scene shows under its picture, such as cos(a), next to the rich
36
+ * label its key names. It reads only the sliders and follows them.
37
+ */
38
+ export declare const FormulaReadoutSchema: Schema.Struct<{
39
+ readonly formula: Schema.String;
40
+ readonly key: Schema.String;
41
+ }>;
42
+ export type FormulaReadout = typeof FormulaReadoutSchema.Type;
@@ -1,4 +1,5 @@
1
1
  import { Array as Arr, Result, Schema } from "effect";
2
+ import { MathVisualKeySchema } from "#contracts/math/base";
2
3
  import { readFormula, readRelation } from "#contracts/math/formula/parse";
3
4
  import { FormulaParameterNameSchema, } from "#contracts/math/formula/syntax";
4
5
  /** Passes a formula that reads, or names the problem of one that does not. */
@@ -24,8 +25,11 @@ export const InequalityTextSchema = Schema.String.check(Schema.makeFilter(compar
24
25
  /**
25
26
  * One slider a learner moves to change every formula that reads its name. Its
26
27
  * value starts inside its range, and a positive step, when given, snaps it.
28
+ * A `label` names the rich label the slider shows instead of its letter, such
29
+ * as theta for an angle slider named `a`.
27
30
  */
28
31
  export const FormulaParameterSchema = Schema.Struct({
32
+ label: Schema.optionalKey(MathVisualKeySchema),
29
33
  max: Schema.Finite,
30
34
  min: Schema.Finite,
31
35
  name: FormulaParameterNameSchema,
@@ -33,3 +37,18 @@ export const FormulaParameterSchema = Schema.Struct({
33
37
  value: Schema.Finite,
34
38
  }).check(Schema.makeFilter(({ max, min, value }) => (min < max && min <= value && value <= max) ||
35
39
  "Expected min < max and a value between them."));
40
+ /** A plane point placed by formulas of the sliders, such as (cos(a), sin(a)). */
41
+ export const PlaneFormulaPointSchema = Schema.Struct({
42
+ x: FormulaTextSchema,
43
+ y: FormulaTextSchema,
44
+ });
45
+ /** Whether an anchor is placed by formulas rather than written exactly. */
46
+ export const isPlaneFormulaPoint = Schema.is(PlaneFormulaPointSchema);
47
+ /**
48
+ * One value a scene shows under its picture, such as cos(a), next to the rich
49
+ * label its key names. It reads only the sliders and follows them.
50
+ */
51
+ export const FormulaReadoutSchema = Schema.Struct({
52
+ formula: FormulaTextSchema,
53
+ key: MathVisualKeySchema,
54
+ });
@@ -1,11 +1,12 @@
1
- import { Result, Schema } from "effect";
1
+ import { Option, Result, Schema } from "effect";
2
2
  import type { PlaneCurveObjectSchemas } from "#contracts/math/curve";
3
- import { type SampleBox } from "#contracts/math/formula/box";
3
+ import { type SampleBox, type SamplePoint } from "#contracts/math/formula/box";
4
4
  import { type FormulaEvaluator, type FormulaScope } from "#contracts/math/formula/compile";
5
+ import type { PlaneFormulaPoint } from "#contracts/math/formula/field";
5
6
  import type { FormulaError } from "#contracts/math/formula/syntax";
6
7
  /**
7
- * What a formula object draws once sampled: curves, a shaded region with
8
- * solid or dashed edges, a surface grid, or the flat faces of a solid.
8
+ * What a formula object draws once sampled: curves, marked points, a shaded
9
+ * region with solid or dashed edges, a surface grid, or the faces of a solid.
9
10
  */
10
11
  export declare const FormulaGeometrySchema: Schema.Union<readonly [Schema.Struct<{
11
12
  readonly branches: Schema.$Array<Schema.$Array<Schema.Struct<{
@@ -14,6 +15,13 @@ export declare const FormulaGeometrySchema: Schema.Union<readonly [Schema.Struct
14
15
  readonly z: Schema.Finite;
15
16
  }>>>;
16
17
  readonly kind: Schema.Literal<"curves">;
18
+ }>, Schema.Struct<{
19
+ readonly kind: Schema.Literal<"points">;
20
+ readonly points: Schema.$Array<Schema.Struct<{
21
+ readonly x: Schema.Finite;
22
+ readonly y: Schema.Finite;
23
+ readonly z: Schema.Finite;
24
+ }>>;
17
25
  }>, Schema.Struct<{
18
26
  readonly boundary: Schema.$Array<Schema.Struct<{
19
27
  readonly points: Schema.$Array<Schema.Struct<{
@@ -53,6 +61,11 @@ export type FormulaGeometry = typeof FormulaGeometrySchema.Type;
53
61
  export declare function compileText(text: string): Result.Result<FormulaEvaluator, FormulaError>;
54
62
  /** Evaluates one compiled formula with one more variable bound. */
55
63
  export declare function evaluateWith(evaluate: FormulaEvaluator, scope: FormulaScope, name: string, value: number): number;
64
+ /**
65
+ * Places one formula point with the sliders' current values. A coordinate
66
+ * that is not finite there, such as ln(0), places nothing.
67
+ */
68
+ export declare function planeFormulaPoint(point: PlaneFormulaPoint, scope: FormulaScope): Result.Result<Option.Option<SamplePoint>, FormulaError>;
56
69
  /** The plane objects a formula defines. */
57
70
  export type PlaneFormulaObject = (typeof PlaneCurveObjectSchemas)[number]["Type"];
58
71
  /**