@nakafa/aksara-contracts 0.30.0 → 0.32.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/README.md +5 -1
- package/dist/math/base.d.ts +49 -0
- package/dist/math/base.js +103 -0
- package/dist/math/plane.d.ts +317 -0
- package/dist/math/plane.js +151 -0
- package/dist/math/space.d.ts +397 -0
- package/dist/math/space.js +129 -0
- package/dist/math/vector.d.ts +3 -0
- package/dist/math/vector.js +74 -0
- package/dist/math/visual.d.ts +984 -0
- package/dist/math/visual.js +15 -0
- package/dist/preview/artifact.js +2 -2
- package/dist/projection/digest.d.ts +36 -0
- package/dist/projection/question.d.ts +159 -1
- package/dist/projection/question.js +75 -17
- package/dist/projection/spec.d.ts +199 -1
- package/dist/projection/spec.js +8 -1
- package/dist/projection/verify.d.ts +36 -0
- package/dist/release/rollback/spec.d.ts +228 -12
- package/dist/transport/batch.d.ts +405 -0
- package/dist/transport/batch.js +14 -2
- package/dist/transport/group.d.ts +632 -32
- package/dist/transport/group.js +2 -1
- package/dist/transport/request.d.ts +1122 -132
- package/dist/transport/response.d.ts +300 -12
- package/package.json +5 -1
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Mathematical objects supported by a Cartesian space scene. */
|
|
3
|
+
export declare const SpaceMathObjectSchema: Schema.Union<readonly [Schema.Struct<{
|
|
4
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
5
|
+
readonly id: Schema.String;
|
|
6
|
+
readonly kind: Schema.Literal<"closed-spline">;
|
|
7
|
+
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
8
|
+
readonly x: Schema.Finite;
|
|
9
|
+
readonly y: Schema.Finite;
|
|
10
|
+
readonly z: Schema.Finite;
|
|
11
|
+
}>, Schema.Struct<{
|
|
12
|
+
readonly x: Schema.Finite;
|
|
13
|
+
readonly y: Schema.Finite;
|
|
14
|
+
readonly z: Schema.Finite;
|
|
15
|
+
}>, Schema.Struct<{
|
|
16
|
+
readonly x: Schema.Finite;
|
|
17
|
+
readonly y: Schema.Finite;
|
|
18
|
+
readonly z: Schema.Finite;
|
|
19
|
+
}>]>, readonly [Schema.Struct<{
|
|
20
|
+
readonly x: Schema.Finite;
|
|
21
|
+
readonly y: Schema.Finite;
|
|
22
|
+
readonly z: Schema.Finite;
|
|
23
|
+
}>]>;
|
|
24
|
+
}>, Schema.Struct<{
|
|
25
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
26
|
+
readonly id: Schema.String;
|
|
27
|
+
readonly center: Schema.Struct<{
|
|
28
|
+
readonly x: Schema.Finite;
|
|
29
|
+
readonly y: Schema.Finite;
|
|
30
|
+
readonly z: Schema.Finite;
|
|
31
|
+
}>;
|
|
32
|
+
readonly kind: Schema.Literal<"cuboid">;
|
|
33
|
+
readonly size: Schema.Struct<{
|
|
34
|
+
readonly height: Schema.Finite;
|
|
35
|
+
readonly length: Schema.Finite;
|
|
36
|
+
readonly width: Schema.Finite;
|
|
37
|
+
}>;
|
|
38
|
+
}>, Schema.Struct<{
|
|
39
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
40
|
+
readonly id: Schema.String;
|
|
41
|
+
readonly kind: Schema.Literal<"line">;
|
|
42
|
+
readonly through: Schema.Tuple<readonly [Schema.Struct<{
|
|
43
|
+
readonly x: Schema.Finite;
|
|
44
|
+
readonly y: Schema.Finite;
|
|
45
|
+
readonly z: Schema.Finite;
|
|
46
|
+
}>, Schema.Struct<{
|
|
47
|
+
readonly x: Schema.Finite;
|
|
48
|
+
readonly y: Schema.Finite;
|
|
49
|
+
readonly z: Schema.Finite;
|
|
50
|
+
}>]>;
|
|
51
|
+
}>, Schema.Struct<{
|
|
52
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
53
|
+
readonly id: Schema.String;
|
|
54
|
+
readonly at: Schema.Struct<{
|
|
55
|
+
readonly x: Schema.Finite;
|
|
56
|
+
readonly y: Schema.Finite;
|
|
57
|
+
readonly z: Schema.Finite;
|
|
58
|
+
}>;
|
|
59
|
+
readonly kind: Schema.Literal<"point">;
|
|
60
|
+
}>, Schema.Struct<{
|
|
61
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
62
|
+
readonly id: Schema.String;
|
|
63
|
+
readonly kind: Schema.Literal<"polygon">;
|
|
64
|
+
readonly vertices: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
65
|
+
readonly x: Schema.Finite;
|
|
66
|
+
readonly y: Schema.Finite;
|
|
67
|
+
readonly z: Schema.Finite;
|
|
68
|
+
}>, Schema.Struct<{
|
|
69
|
+
readonly x: Schema.Finite;
|
|
70
|
+
readonly y: Schema.Finite;
|
|
71
|
+
readonly z: Schema.Finite;
|
|
72
|
+
}>, Schema.Struct<{
|
|
73
|
+
readonly x: Schema.Finite;
|
|
74
|
+
readonly y: Schema.Finite;
|
|
75
|
+
readonly z: Schema.Finite;
|
|
76
|
+
}>]>, readonly [Schema.Struct<{
|
|
77
|
+
readonly x: Schema.Finite;
|
|
78
|
+
readonly y: Schema.Finite;
|
|
79
|
+
readonly z: Schema.Finite;
|
|
80
|
+
}>]>;
|
|
81
|
+
}>, Schema.Struct<{
|
|
82
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
83
|
+
readonly id: Schema.String;
|
|
84
|
+
readonly kind: Schema.Literal<"polyline">;
|
|
85
|
+
readonly vertices: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
86
|
+
readonly x: Schema.Finite;
|
|
87
|
+
readonly y: Schema.Finite;
|
|
88
|
+
readonly z: Schema.Finite;
|
|
89
|
+
}>, Schema.Struct<{
|
|
90
|
+
readonly x: Schema.Finite;
|
|
91
|
+
readonly y: Schema.Finite;
|
|
92
|
+
readonly z: Schema.Finite;
|
|
93
|
+
}>]>, readonly [Schema.Struct<{
|
|
94
|
+
readonly x: Schema.Finite;
|
|
95
|
+
readonly y: Schema.Finite;
|
|
96
|
+
readonly z: Schema.Finite;
|
|
97
|
+
}>]>;
|
|
98
|
+
}>, Schema.Struct<{
|
|
99
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
100
|
+
readonly id: Schema.String;
|
|
101
|
+
readonly from: Schema.Struct<{
|
|
102
|
+
readonly x: Schema.Finite;
|
|
103
|
+
readonly y: Schema.Finite;
|
|
104
|
+
readonly z: Schema.Finite;
|
|
105
|
+
}>;
|
|
106
|
+
readonly kind: Schema.Literal<"ray">;
|
|
107
|
+
readonly through: Schema.Struct<{
|
|
108
|
+
readonly x: Schema.Finite;
|
|
109
|
+
readonly y: Schema.Finite;
|
|
110
|
+
readonly z: Schema.Finite;
|
|
111
|
+
}>;
|
|
112
|
+
}>, Schema.Struct<{
|
|
113
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
114
|
+
readonly id: Schema.String;
|
|
115
|
+
readonly from: Schema.Struct<{
|
|
116
|
+
readonly x: Schema.Finite;
|
|
117
|
+
readonly y: Schema.Finite;
|
|
118
|
+
readonly z: Schema.Finite;
|
|
119
|
+
}>;
|
|
120
|
+
readonly kind: Schema.Literal<"segment">;
|
|
121
|
+
readonly to: Schema.Struct<{
|
|
122
|
+
readonly x: Schema.Finite;
|
|
123
|
+
readonly y: Schema.Finite;
|
|
124
|
+
readonly z: Schema.Finite;
|
|
125
|
+
}>;
|
|
126
|
+
}>, Schema.Struct<{
|
|
127
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
128
|
+
readonly id: Schema.String;
|
|
129
|
+
readonly kind: Schema.Literal<"spline">;
|
|
130
|
+
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
131
|
+
readonly x: Schema.Finite;
|
|
132
|
+
readonly y: Schema.Finite;
|
|
133
|
+
readonly z: Schema.Finite;
|
|
134
|
+
}>, Schema.Struct<{
|
|
135
|
+
readonly x: Schema.Finite;
|
|
136
|
+
readonly y: Schema.Finite;
|
|
137
|
+
readonly z: Schema.Finite;
|
|
138
|
+
}>, Schema.Struct<{
|
|
139
|
+
readonly x: Schema.Finite;
|
|
140
|
+
readonly y: Schema.Finite;
|
|
141
|
+
readonly z: Schema.Finite;
|
|
142
|
+
}>]>, readonly [Schema.Struct<{
|
|
143
|
+
readonly x: Schema.Finite;
|
|
144
|
+
readonly y: Schema.Finite;
|
|
145
|
+
readonly z: Schema.Finite;
|
|
146
|
+
}>]>;
|
|
147
|
+
}>]>;
|
|
148
|
+
/** Exact Cartesian frame presented behind a space construction. */
|
|
149
|
+
export declare const SpaceMathFrameSchema: Schema.Struct<{
|
|
150
|
+
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
151
|
+
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
152
|
+
readonly kind: Schema.Literal<"cartesian">;
|
|
153
|
+
readonly x: Schema.Struct<{
|
|
154
|
+
readonly max: Schema.Finite;
|
|
155
|
+
readonly min: Schema.Finite;
|
|
156
|
+
}>;
|
|
157
|
+
readonly y: Schema.Struct<{
|
|
158
|
+
readonly max: Schema.Finite;
|
|
159
|
+
readonly min: Schema.Finite;
|
|
160
|
+
}>;
|
|
161
|
+
readonly z: Schema.Struct<{
|
|
162
|
+
readonly max: Schema.Finite;
|
|
163
|
+
readonly min: Schema.Finite;
|
|
164
|
+
}>;
|
|
165
|
+
}>;
|
|
166
|
+
/** Minimal semantic views supported by one space scene. */
|
|
167
|
+
export declare const SpaceMathViewSchema: Schema.Union<readonly [Schema.Struct<{
|
|
168
|
+
readonly kind: Schema.Literal<"camera">;
|
|
169
|
+
readonly position: Schema.Struct<{
|
|
170
|
+
readonly x: Schema.Finite;
|
|
171
|
+
readonly y: Schema.Finite;
|
|
172
|
+
readonly z: Schema.Finite;
|
|
173
|
+
}>;
|
|
174
|
+
readonly target: Schema.Struct<{
|
|
175
|
+
readonly x: Schema.Finite;
|
|
176
|
+
readonly y: Schema.Finite;
|
|
177
|
+
readonly z: Schema.Finite;
|
|
178
|
+
}>;
|
|
179
|
+
}>, Schema.Struct<{
|
|
180
|
+
readonly kind: Schema.Literal<"fit">;
|
|
181
|
+
readonly padding: Schema.optionalKey<Schema.Finite>;
|
|
182
|
+
}>, Schema.Struct<{
|
|
183
|
+
readonly kind: Schema.Literal<"isometric">;
|
|
184
|
+
readonly target: Schema.optionalKey<Schema.Struct<{
|
|
185
|
+
readonly x: Schema.Finite;
|
|
186
|
+
readonly y: Schema.Finite;
|
|
187
|
+
readonly z: Schema.Finite;
|
|
188
|
+
}>>;
|
|
189
|
+
}>]>;
|
|
190
|
+
/** One coordinate anchor resolved against a separate rich-label map. */
|
|
191
|
+
export declare const SpaceLabelAnchorSchema: Schema.Struct<{
|
|
192
|
+
readonly at: Schema.Struct<{
|
|
193
|
+
readonly x: Schema.Finite;
|
|
194
|
+
readonly y: Schema.Finite;
|
|
195
|
+
readonly z: Schema.Finite;
|
|
196
|
+
}>;
|
|
197
|
+
readonly key: Schema.String;
|
|
198
|
+
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
199
|
+
}>;
|
|
200
|
+
/** Complete stable space visual before rich labels are attached. */
|
|
201
|
+
export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
202
|
+
readonly frame: Schema.Struct<{
|
|
203
|
+
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
204
|
+
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
205
|
+
readonly kind: Schema.Literal<"cartesian">;
|
|
206
|
+
readonly x: Schema.Struct<{
|
|
207
|
+
readonly max: Schema.Finite;
|
|
208
|
+
readonly min: Schema.Finite;
|
|
209
|
+
}>;
|
|
210
|
+
readonly y: Schema.Struct<{
|
|
211
|
+
readonly max: Schema.Finite;
|
|
212
|
+
readonly min: Schema.Finite;
|
|
213
|
+
}>;
|
|
214
|
+
readonly z: Schema.Struct<{
|
|
215
|
+
readonly max: Schema.Finite;
|
|
216
|
+
readonly min: Schema.Finite;
|
|
217
|
+
}>;
|
|
218
|
+
}>;
|
|
219
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
220
|
+
readonly at: Schema.Struct<{
|
|
221
|
+
readonly x: Schema.Finite;
|
|
222
|
+
readonly y: Schema.Finite;
|
|
223
|
+
readonly z: Schema.Finite;
|
|
224
|
+
}>;
|
|
225
|
+
readonly key: Schema.String;
|
|
226
|
+
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
227
|
+
}>>>;
|
|
228
|
+
readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
229
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
230
|
+
readonly id: Schema.String;
|
|
231
|
+
readonly kind: Schema.Literal<"closed-spline">;
|
|
232
|
+
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
233
|
+
readonly x: Schema.Finite;
|
|
234
|
+
readonly y: Schema.Finite;
|
|
235
|
+
readonly z: Schema.Finite;
|
|
236
|
+
}>, Schema.Struct<{
|
|
237
|
+
readonly x: Schema.Finite;
|
|
238
|
+
readonly y: Schema.Finite;
|
|
239
|
+
readonly z: Schema.Finite;
|
|
240
|
+
}>, Schema.Struct<{
|
|
241
|
+
readonly x: Schema.Finite;
|
|
242
|
+
readonly y: Schema.Finite;
|
|
243
|
+
readonly z: Schema.Finite;
|
|
244
|
+
}>]>, readonly [Schema.Struct<{
|
|
245
|
+
readonly x: Schema.Finite;
|
|
246
|
+
readonly y: Schema.Finite;
|
|
247
|
+
readonly z: Schema.Finite;
|
|
248
|
+
}>]>;
|
|
249
|
+
}>, Schema.Struct<{
|
|
250
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
251
|
+
readonly id: Schema.String;
|
|
252
|
+
readonly center: Schema.Struct<{
|
|
253
|
+
readonly x: Schema.Finite;
|
|
254
|
+
readonly y: Schema.Finite;
|
|
255
|
+
readonly z: Schema.Finite;
|
|
256
|
+
}>;
|
|
257
|
+
readonly kind: Schema.Literal<"cuboid">;
|
|
258
|
+
readonly size: Schema.Struct<{
|
|
259
|
+
readonly height: Schema.Finite;
|
|
260
|
+
readonly length: Schema.Finite;
|
|
261
|
+
readonly width: Schema.Finite;
|
|
262
|
+
}>;
|
|
263
|
+
}>, Schema.Struct<{
|
|
264
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
265
|
+
readonly id: Schema.String;
|
|
266
|
+
readonly kind: Schema.Literal<"line">;
|
|
267
|
+
readonly through: Schema.Tuple<readonly [Schema.Struct<{
|
|
268
|
+
readonly x: Schema.Finite;
|
|
269
|
+
readonly y: Schema.Finite;
|
|
270
|
+
readonly z: Schema.Finite;
|
|
271
|
+
}>, Schema.Struct<{
|
|
272
|
+
readonly x: Schema.Finite;
|
|
273
|
+
readonly y: Schema.Finite;
|
|
274
|
+
readonly z: Schema.Finite;
|
|
275
|
+
}>]>;
|
|
276
|
+
}>, Schema.Struct<{
|
|
277
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
278
|
+
readonly id: Schema.String;
|
|
279
|
+
readonly at: Schema.Struct<{
|
|
280
|
+
readonly x: Schema.Finite;
|
|
281
|
+
readonly y: Schema.Finite;
|
|
282
|
+
readonly z: Schema.Finite;
|
|
283
|
+
}>;
|
|
284
|
+
readonly kind: Schema.Literal<"point">;
|
|
285
|
+
}>, Schema.Struct<{
|
|
286
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
287
|
+
readonly id: Schema.String;
|
|
288
|
+
readonly kind: Schema.Literal<"polygon">;
|
|
289
|
+
readonly vertices: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
290
|
+
readonly x: Schema.Finite;
|
|
291
|
+
readonly y: Schema.Finite;
|
|
292
|
+
readonly z: Schema.Finite;
|
|
293
|
+
}>, Schema.Struct<{
|
|
294
|
+
readonly x: Schema.Finite;
|
|
295
|
+
readonly y: Schema.Finite;
|
|
296
|
+
readonly z: Schema.Finite;
|
|
297
|
+
}>, Schema.Struct<{
|
|
298
|
+
readonly x: Schema.Finite;
|
|
299
|
+
readonly y: Schema.Finite;
|
|
300
|
+
readonly z: Schema.Finite;
|
|
301
|
+
}>]>, readonly [Schema.Struct<{
|
|
302
|
+
readonly x: Schema.Finite;
|
|
303
|
+
readonly y: Schema.Finite;
|
|
304
|
+
readonly z: Schema.Finite;
|
|
305
|
+
}>]>;
|
|
306
|
+
}>, Schema.Struct<{
|
|
307
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
308
|
+
readonly id: Schema.String;
|
|
309
|
+
readonly kind: Schema.Literal<"polyline">;
|
|
310
|
+
readonly vertices: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
311
|
+
readonly x: Schema.Finite;
|
|
312
|
+
readonly y: Schema.Finite;
|
|
313
|
+
readonly z: Schema.Finite;
|
|
314
|
+
}>, Schema.Struct<{
|
|
315
|
+
readonly x: Schema.Finite;
|
|
316
|
+
readonly y: Schema.Finite;
|
|
317
|
+
readonly z: Schema.Finite;
|
|
318
|
+
}>]>, readonly [Schema.Struct<{
|
|
319
|
+
readonly x: Schema.Finite;
|
|
320
|
+
readonly y: Schema.Finite;
|
|
321
|
+
readonly z: Schema.Finite;
|
|
322
|
+
}>]>;
|
|
323
|
+
}>, Schema.Struct<{
|
|
324
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
325
|
+
readonly id: Schema.String;
|
|
326
|
+
readonly from: Schema.Struct<{
|
|
327
|
+
readonly x: Schema.Finite;
|
|
328
|
+
readonly y: Schema.Finite;
|
|
329
|
+
readonly z: Schema.Finite;
|
|
330
|
+
}>;
|
|
331
|
+
readonly kind: Schema.Literal<"ray">;
|
|
332
|
+
readonly through: Schema.Struct<{
|
|
333
|
+
readonly x: Schema.Finite;
|
|
334
|
+
readonly y: Schema.Finite;
|
|
335
|
+
readonly z: Schema.Finite;
|
|
336
|
+
}>;
|
|
337
|
+
}>, Schema.Struct<{
|
|
338
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
339
|
+
readonly id: Schema.String;
|
|
340
|
+
readonly from: Schema.Struct<{
|
|
341
|
+
readonly x: Schema.Finite;
|
|
342
|
+
readonly y: Schema.Finite;
|
|
343
|
+
readonly z: Schema.Finite;
|
|
344
|
+
}>;
|
|
345
|
+
readonly kind: Schema.Literal<"segment">;
|
|
346
|
+
readonly to: Schema.Struct<{
|
|
347
|
+
readonly x: Schema.Finite;
|
|
348
|
+
readonly y: Schema.Finite;
|
|
349
|
+
readonly z: Schema.Finite;
|
|
350
|
+
}>;
|
|
351
|
+
}>, Schema.Struct<{
|
|
352
|
+
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
353
|
+
readonly id: Schema.String;
|
|
354
|
+
readonly kind: Schema.Literal<"spline">;
|
|
355
|
+
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
356
|
+
readonly x: Schema.Finite;
|
|
357
|
+
readonly y: Schema.Finite;
|
|
358
|
+
readonly z: Schema.Finite;
|
|
359
|
+
}>, Schema.Struct<{
|
|
360
|
+
readonly x: Schema.Finite;
|
|
361
|
+
readonly y: Schema.Finite;
|
|
362
|
+
readonly z: Schema.Finite;
|
|
363
|
+
}>, Schema.Struct<{
|
|
364
|
+
readonly x: Schema.Finite;
|
|
365
|
+
readonly y: Schema.Finite;
|
|
366
|
+
readonly z: Schema.Finite;
|
|
367
|
+
}>]>, readonly [Schema.Struct<{
|
|
368
|
+
readonly x: Schema.Finite;
|
|
369
|
+
readonly y: Schema.Finite;
|
|
370
|
+
readonly z: Schema.Finite;
|
|
371
|
+
}>]>;
|
|
372
|
+
}>]>>;
|
|
373
|
+
readonly space: Schema.Literal<"space">;
|
|
374
|
+
readonly view: Schema.Union<readonly [Schema.Struct<{
|
|
375
|
+
readonly kind: Schema.Literal<"camera">;
|
|
376
|
+
readonly position: Schema.Struct<{
|
|
377
|
+
readonly x: Schema.Finite;
|
|
378
|
+
readonly y: Schema.Finite;
|
|
379
|
+
readonly z: Schema.Finite;
|
|
380
|
+
}>;
|
|
381
|
+
readonly target: Schema.Struct<{
|
|
382
|
+
readonly x: Schema.Finite;
|
|
383
|
+
readonly y: Schema.Finite;
|
|
384
|
+
readonly z: Schema.Finite;
|
|
385
|
+
}>;
|
|
386
|
+
}>, Schema.Struct<{
|
|
387
|
+
readonly kind: Schema.Literal<"fit">;
|
|
388
|
+
readonly padding: Schema.optionalKey<Schema.Finite>;
|
|
389
|
+
}>, Schema.Struct<{
|
|
390
|
+
readonly kind: Schema.Literal<"isometric">;
|
|
391
|
+
readonly target: Schema.optionalKey<Schema.Struct<{
|
|
392
|
+
readonly x: Schema.Finite;
|
|
393
|
+
readonly y: Schema.Finite;
|
|
394
|
+
readonly z: Schema.Finite;
|
|
395
|
+
}>>;
|
|
396
|
+
}>]>;
|
|
397
|
+
}>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathFeatureVisibilitySchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PositiveMeasureSchema, SpacePointSchema, sameSpacePoint, } from "#contracts/math/base";
|
|
3
|
+
import { hasCoplanarArea } from "#contracts/math/vector";
|
|
4
|
+
const ObjectFields = {
|
|
5
|
+
appearance: MathAppearanceSchema,
|
|
6
|
+
id: MathVisualKeySchema,
|
|
7
|
+
};
|
|
8
|
+
const SpacePointObjectSchema = Schema.Struct({
|
|
9
|
+
...ObjectFields,
|
|
10
|
+
at: SpacePointSchema,
|
|
11
|
+
kind: Schema.Literal("point"),
|
|
12
|
+
});
|
|
13
|
+
const SpacePathSchema = Schema.TupleWithRest(Schema.Tuple([SpacePointSchema, SpacePointSchema]), [SpacePointSchema]);
|
|
14
|
+
const SpaceShapeSchema = Schema.TupleWithRest(Schema.Tuple([SpacePointSchema, SpacePointSchema, SpacePointSchema]), [SpacePointSchema]);
|
|
15
|
+
const SpaceLineObjectSchema = Schema.Struct({
|
|
16
|
+
...ObjectFields,
|
|
17
|
+
kind: Schema.Literal("line"),
|
|
18
|
+
through: Schema.Tuple([SpacePointSchema, SpacePointSchema]),
|
|
19
|
+
}).pipe(Schema.check(Schema.makeFilter(({ through: [from, to] }) => !sameSpacePoint(from, to), {
|
|
20
|
+
message: "Expected a line through two distinct positions.",
|
|
21
|
+
})));
|
|
22
|
+
const SpaceRayObjectSchema = Schema.Struct({
|
|
23
|
+
...ObjectFields,
|
|
24
|
+
from: SpacePointSchema,
|
|
25
|
+
kind: Schema.Literal("ray"),
|
|
26
|
+
through: SpacePointSchema,
|
|
27
|
+
}).pipe(Schema.check(Schema.makeFilter(({ from, through }) => !sameSpacePoint(from, through), {
|
|
28
|
+
message: "Expected a ray through a position distinct from its start.",
|
|
29
|
+
})));
|
|
30
|
+
const SpaceSegmentObjectSchema = Schema.Struct({
|
|
31
|
+
...ObjectFields,
|
|
32
|
+
from: SpacePointSchema,
|
|
33
|
+
kind: Schema.Literal("segment"),
|
|
34
|
+
to: SpacePointSchema,
|
|
35
|
+
}).pipe(Schema.check(Schema.makeFilter(({ from, to }) => !sameSpacePoint(from, to), {
|
|
36
|
+
message: "Expected a segment with distinct ends.",
|
|
37
|
+
})));
|
|
38
|
+
const SpacePolylineObjectSchema = Schema.Struct({
|
|
39
|
+
...ObjectFields,
|
|
40
|
+
kind: Schema.Literal("polyline"),
|
|
41
|
+
vertices: SpacePathSchema,
|
|
42
|
+
}).pipe(Schema.check(Schema.makeFilter(({ vertices }) => hasUniquePositions(vertices, sameSpacePoint), { message: "Expected unique polyline vertices." })));
|
|
43
|
+
const SpacePolygonObjectSchema = Schema.Struct({
|
|
44
|
+
...ObjectFields,
|
|
45
|
+
kind: Schema.Literal("polygon"),
|
|
46
|
+
vertices: SpaceShapeSchema,
|
|
47
|
+
}).pipe(Schema.check(Schema.makeFilter(({ vertices }) => hasUniquePositions(vertices, sameSpacePoint) &&
|
|
48
|
+
hasCoplanarArea(vertices), {
|
|
49
|
+
message: "Expected unique, coplanar vertices forming a non-degenerate polygon.",
|
|
50
|
+
})));
|
|
51
|
+
const SpaceSplineObjectSchema = Schema.Struct({
|
|
52
|
+
...ObjectFields,
|
|
53
|
+
kind: Schema.Literal("spline"),
|
|
54
|
+
samples: SpaceShapeSchema,
|
|
55
|
+
}).pipe(Schema.check(Schema.makeFilter(({ samples }) => hasUniquePositions(samples, sameSpacePoint), { message: "Expected at least three unique spline samples." })));
|
|
56
|
+
const SpaceClosedSplineObjectSchema = Schema.Struct({
|
|
57
|
+
...ObjectFields,
|
|
58
|
+
kind: Schema.Literal("closed-spline"),
|
|
59
|
+
samples: SpaceShapeSchema,
|
|
60
|
+
}).pipe(Schema.check(Schema.makeFilter(({ samples }) => hasUniquePositions(samples, sameSpacePoint), {
|
|
61
|
+
message: "Expected unique closed-spline samples without a repeated closing sample.",
|
|
62
|
+
})));
|
|
63
|
+
/**
|
|
64
|
+
* Axis-aligned cuboid whose length spans x, height spans y, and width spans z.
|
|
65
|
+
*/
|
|
66
|
+
const SpaceCuboidObjectSchema = Schema.Struct({
|
|
67
|
+
...ObjectFields,
|
|
68
|
+
center: SpacePointSchema,
|
|
69
|
+
kind: Schema.Literal("cuboid"),
|
|
70
|
+
size: Schema.Struct({
|
|
71
|
+
height: PositiveMeasureSchema,
|
|
72
|
+
length: PositiveMeasureSchema,
|
|
73
|
+
width: PositiveMeasureSchema,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
/** Mathematical objects supported by a Cartesian space scene. */
|
|
77
|
+
export const SpaceMathObjectSchema = Schema.Union([
|
|
78
|
+
SpaceClosedSplineObjectSchema,
|
|
79
|
+
SpaceCuboidObjectSchema,
|
|
80
|
+
SpaceLineObjectSchema,
|
|
81
|
+
SpacePointObjectSchema,
|
|
82
|
+
SpacePolygonObjectSchema,
|
|
83
|
+
SpacePolylineObjectSchema,
|
|
84
|
+
SpaceRayObjectSchema,
|
|
85
|
+
SpaceSegmentObjectSchema,
|
|
86
|
+
SpaceSplineObjectSchema,
|
|
87
|
+
]);
|
|
88
|
+
/** Exact Cartesian frame presented behind a space construction. */
|
|
89
|
+
export const SpaceMathFrameSchema = Schema.Struct({
|
|
90
|
+
axes: MathFeatureVisibilitySchema,
|
|
91
|
+
grid: MathFeatureVisibilitySchema,
|
|
92
|
+
kind: Schema.Literal("cartesian"),
|
|
93
|
+
x: MathAxisRangeSchema,
|
|
94
|
+
y: MathAxisRangeSchema,
|
|
95
|
+
z: MathAxisRangeSchema,
|
|
96
|
+
});
|
|
97
|
+
const SpaceFitViewSchema = Schema.Struct({
|
|
98
|
+
kind: Schema.Literal("fit"),
|
|
99
|
+
padding: Schema.optionalKey(MathViewPaddingSchema),
|
|
100
|
+
});
|
|
101
|
+
const SpaceIsometricViewSchema = Schema.Struct({
|
|
102
|
+
kind: Schema.Literal("isometric"),
|
|
103
|
+
target: Schema.optionalKey(SpacePointSchema),
|
|
104
|
+
});
|
|
105
|
+
const SpaceCameraViewSchema = Schema.Struct({
|
|
106
|
+
kind: Schema.Literal("camera"),
|
|
107
|
+
position: SpacePointSchema,
|
|
108
|
+
target: SpacePointSchema,
|
|
109
|
+
}).pipe(Schema.check(Schema.makeFilter(({ position, target }) => !sameSpacePoint(position, target), { message: "Expected distinct camera position and target." })));
|
|
110
|
+
/** Minimal semantic views supported by one space scene. */
|
|
111
|
+
export const SpaceMathViewSchema = Schema.Union([
|
|
112
|
+
SpaceCameraViewSchema,
|
|
113
|
+
SpaceFitViewSchema,
|
|
114
|
+
SpaceIsometricViewSchema,
|
|
115
|
+
]);
|
|
116
|
+
/** One coordinate anchor resolved against a separate rich-label map. */
|
|
117
|
+
export const SpaceLabelAnchorSchema = Schema.Struct({
|
|
118
|
+
at: SpacePointSchema,
|
|
119
|
+
key: MathVisualKeySchema,
|
|
120
|
+
placement: Schema.optionalKey(MathLabelPlacementSchema),
|
|
121
|
+
});
|
|
122
|
+
/** Complete stable space visual before rich labels are attached. */
|
|
123
|
+
export const SpaceMathVisualSchema = Schema.Struct({
|
|
124
|
+
frame: SpaceMathFrameSchema,
|
|
125
|
+
labels: Schema.optionalKey(Schema.Array(SpaceLabelAnchorSchema)),
|
|
126
|
+
objects: Schema.NonEmptyArray(SpaceMathObjectSchema),
|
|
127
|
+
space: Schema.Literal("space"),
|
|
128
|
+
view: SpaceMathViewSchema,
|
|
129
|
+
}).pipe(Schema.check(Schema.makeFilter(({ labels = [], objects }) => mathVisualIdentityIssues(objects, labels))));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GEOMETRY_TOLERANCE } from "#contracts/math/base";
|
|
2
|
+
/** Checks a space polygon is planar and has non-zero area. */
|
|
3
|
+
export function hasCoplanarArea(vertices) {
|
|
4
|
+
const offsets = normalizedSpaceOffsets(vertices);
|
|
5
|
+
let strongestNormal;
|
|
6
|
+
let strongestLength = 0;
|
|
7
|
+
const vectors = offsets.slice(1);
|
|
8
|
+
for (const [leftIndex, left] of vectors.entries()) {
|
|
9
|
+
for (const right of vectors.slice(leftIndex + 1)) {
|
|
10
|
+
const candidate = cross(left, right);
|
|
11
|
+
const candidateLength = length(candidate);
|
|
12
|
+
if (candidateLength > strongestLength) {
|
|
13
|
+
strongestLength = candidateLength;
|
|
14
|
+
strongestNormal = candidate;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (!(strongestNormal && strongestLength > GEOMETRY_TOLERANCE)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const unitNormal = divide(strongestNormal, strongestLength);
|
|
22
|
+
return offsets.every((offset) => Math.abs(dot(unitNormal, offset)) <=
|
|
23
|
+
GEOMETRY_TOLERANCE * Math.max(1, length(offset)));
|
|
24
|
+
}
|
|
25
|
+
/** Translates before scaling so coplanarity is independent of scene location. */
|
|
26
|
+
function normalizedSpaceOffsets(vertices) {
|
|
27
|
+
const [origin] = vertices;
|
|
28
|
+
let offsets = vertices.map(({ x, y, z }) => ({
|
|
29
|
+
x: x - origin.x,
|
|
30
|
+
y: y - origin.y,
|
|
31
|
+
z: z - origin.z,
|
|
32
|
+
}));
|
|
33
|
+
if (offsets.some(({ x, y, z }) => !(Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)))) {
|
|
34
|
+
let sourceScale = 1;
|
|
35
|
+
for (const { x, y, z } of vertices) {
|
|
36
|
+
sourceScale = Math.max(sourceScale, Math.abs(x), Math.abs(y), Math.abs(z));
|
|
37
|
+
}
|
|
38
|
+
offsets = vertices.map(({ x, y, z }) => ({
|
|
39
|
+
x: x / sourceScale - origin.x / sourceScale,
|
|
40
|
+
y: y / sourceScale - origin.y / sourceScale,
|
|
41
|
+
z: z / sourceScale - origin.z / sourceScale,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
let extent = 0;
|
|
45
|
+
for (const { x, y, z } of offsets) {
|
|
46
|
+
extent = Math.max(extent, Math.abs(x), Math.abs(y), Math.abs(z));
|
|
47
|
+
}
|
|
48
|
+
const divisor = Math.max(extent, Number.MIN_VALUE);
|
|
49
|
+
return offsets.map((offset) => divide(offset, divisor));
|
|
50
|
+
}
|
|
51
|
+
/** Returns the cross product of two space vectors. */
|
|
52
|
+
function cross(left, right) {
|
|
53
|
+
return {
|
|
54
|
+
x: left.y * right.z - left.z * right.y,
|
|
55
|
+
y: left.z * right.x - left.x * right.z,
|
|
56
|
+
z: left.x * right.y - left.y * right.x,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Returns the dot product of two space vectors. */
|
|
60
|
+
function dot(left, right) {
|
|
61
|
+
return left.x * right.x + left.y * right.y + left.z * right.z;
|
|
62
|
+
}
|
|
63
|
+
/** Returns a stable Euclidean vector length. */
|
|
64
|
+
function length(value) {
|
|
65
|
+
return Math.hypot(value.x, value.y, value.z);
|
|
66
|
+
}
|
|
67
|
+
/** Divides one space vector by a positive finite scale. */
|
|
68
|
+
function divide(value, divisor) {
|
|
69
|
+
return {
|
|
70
|
+
x: value.x / divisor,
|
|
71
|
+
y: value.y / divisor,
|
|
72
|
+
z: value.z / divisor,
|
|
73
|
+
};
|
|
74
|
+
}
|