spine-rigc 1.5.2 → 1.6.1

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/src/motion.ts CHANGED
@@ -54,8 +54,8 @@
54
54
  * [`keys.ts`](keys.ts) shared with the rig parser.
55
55
  */
56
56
  import { CompileError } from './errors.ts';
57
- import { dottedPath, refuseNumbersTheFileCannotCarry, refuseUnknownKeys, refuseValuesOfTheWrongType } from './keys.ts';
58
- import type { ShapeVisit, SpecValueType } from './keys.ts';
57
+ import { dottedPath, refuseNumbersTheFileCannotCarry, refuseUnknownKeys, refuseValuesOfTheWrongType, refuseValuesOutsideTheirSet } from './keys.ts';
58
+ import type { ShapeVisit, SpecEnumTable, SpecValueType } from './keys.ts';
59
59
  import { SEQUENCE_MODES } from './timelines.ts';
60
60
  import type { MotionSpec } from './types.ts';
61
61
 
@@ -165,9 +165,8 @@ export const MOTION_KEYS = {
165
165
  * fields nothing here reads — an ik key's `mix`, a deform key's `offset`, an
166
166
  * event key's `float`, a derive's `degrees`.
167
167
  *
168
- * Where an unchecked type is refused: `spec` — the version check; a track's
169
- * `property` — `compileTrack`; a derive's `kind` — `evaluateTrackDerive`; a deform
170
- * transform's `kind`, `along` and `axis` — `evaluateDeformTransform`;
168
+ * Where an unchecked type is refused: an `enum` row — the entry `MOTION_ENUMS`
169
+ * has for it, below, which is a table a control reads rather than a list here;
171
170
  * `MotionKey.v`, a key's `curve`, a derive's `depth` and `mix.pairs` (`mixed`)
172
171
  * — the track compiler by property, the curve reader, the derive evaluator and
173
172
  * `parseMix`. A sequence key's `mode` is a closed set too, but its interface
@@ -227,6 +226,24 @@ export const MOTION_TYPES = {
227
226
  DeformBend: { kind: 'enum', amount: 'number', from: 'number', to: 'number', power: 'number', along: 'enum', axis: 'enum' },
228
227
  } as const satisfies MotionTypeTable;
229
228
 
229
+ /**
230
+ * Who refuses each `enum` row of `MOTION_TYPES` outside its set (issue #900);
231
+ * `SpecEnumTable` in [`keys.ts`](keys.ts) says what an entry means. Every one
232
+ * is an owner: measured when this table was written, a planted `5` and `"foo"`
233
+ * on each row was refused by name by the reader named here, listing the names
234
+ * that exist, so none of them states a set. A deform transform's and a derive's
235
+ * `kind` choose the row they are checked against, as a generator's does.
236
+ */
237
+ export const MOTION_ENUMS = {
238
+ MotionSpec: { spec: { owner: 'parseMotionSpecInto' } },
239
+ MotionTrack: { property: { owner: 'compileTrack' } },
240
+ TrackDeriveTurn: { kind: { owner: 'evaluateTrackDerive' } },
241
+ DeformTurn: { kind: { owner: 'evaluateDeformTransform' } },
242
+ DeformAffine: { kind: { owner: 'evaluateDeformTransform' } },
243
+ DeformWave: { kind: { owner: 'evaluateDeformTransform' }, along: { owner: 'evaluateDeformTransform' }, axis: { owner: 'evaluateDeformTransform' } },
244
+ DeformBend: { kind: { owner: 'evaluateDeformTransform' }, along: { owner: 'evaluateDeformTransform' }, axis: { owner: 'evaluateDeformTransform' } },
245
+ } as const satisfies SpecEnumTable<typeof MOTION_TYPES>;
246
+
230
247
  /** A deform key's `transform` kinds, and the shape each one's keys come from. */
231
248
  const DEFORM_TRANSFORM_SHAPE: Record<string, keyof typeof MOTION_KEYS> = {
232
249
  yaw: 'DeformTurn',
@@ -778,6 +795,9 @@ function parseMotionSpecInto(raw: unknown, where: string, visits: readonly Shape
778
795
  // as an event with no audio, a yaw transform's `"depth": "true"` as a radius
779
796
  // that is undefined.
780
797
  refuseValuesOfTheWrongType(visits, MOTION_TYPES, where);
798
+ // Every `enum` row here names an owner, so this refuses nothing today; it is
799
+ // called so that a row given a set is refused from the day it is given one.
800
+ refuseValuesOutsideTheirSet(visits, MOTION_TYPES, MOTION_ENUMS, where);
781
801
 
782
802
  // Last, so every field check above keeps its own sentence for a number that
783
803
  // is not finite; what reaches this line is a finite double the float32 file