spine-rigc 1.9.0 → 1.9.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.
Files changed (45) hide show
  1. package/cli.ts +9 -0
  2. package/docs/AUTHORING.md +2 -2
  3. package/package.json +1 -1
  4. package/src/assertions/bodies/a09.ts +82 -0
  5. package/src/assertions/bodies/a12.ts +30 -0
  6. package/src/assertions/bodies/a24.ts +68 -0
  7. package/src/assertions/bodies/a25.ts +39 -0
  8. package/src/assertions/bodies/a26.ts +61 -0
  9. package/src/assertions/bodies/a29.ts +34 -0
  10. package/src/assertions/bodies/a30.ts +50 -0
  11. package/src/assertions/bodies/a32.ts +44 -0
  12. package/src/assertions/bodies/a39.ts +303 -0
  13. package/src/assertions/bodies/a43.ts +181 -0
  14. package/src/assertions/bodies/a46.ts +224 -0
  15. package/src/assertions/facts/animation_durations.ts +37 -0
  16. package/src/assertions/facts/bone_timelines.ts +37 -0
  17. package/src/assertions/facts/deform_survey.ts +27 -0
  18. package/src/assertions/facts/event_keys.ts +55 -0
  19. package/src/assertions/facts/sequences.ts +85 -0
  20. package/src/assertions/facts/skeleton_roster.ts +45 -0
  21. package/src/assertions/facts/two_colour.ts +52 -0
  22. package/src/assertions/inward_advance.ts +58 -0
  23. package/src/assertions/model/animation_durations.ts +57 -0
  24. package/src/assertions/model/bone_timelines.ts +56 -0
  25. package/src/assertions/model/constraints.ts +34 -16
  26. package/src/assertions/model/deform_survey.ts +24 -0
  27. package/src/assertions/model/event_keys.ts +45 -0
  28. package/src/assertions/model/index.ts +64 -2
  29. package/src/assertions/model/linked_meshes.ts +2 -2
  30. package/src/assertions/model/mesh_attachments.ts +1 -1
  31. package/src/assertions/model/region_joins.ts +20 -12
  32. package/src/assertions/model/sequences.ts +157 -0
  33. package/src/assertions/model/skeleton_roster.ts +23 -0
  34. package/src/assertions/model/skin_entries.ts +18 -8
  35. package/src/assertions/model/skin_members.ts +5 -3
  36. package/src/assertions/model/skin_meshes.ts +1 -1
  37. package/src/assertions/model/slot_colour.ts +5 -4
  38. package/src/assertions/model/two_colour.ts +61 -0
  39. package/src/assertions/model/vertex_polygons.ts +9 -8
  40. package/src/compile.ts +114 -14
  41. package/src/deformmeasure.ts +35 -2270
  42. package/src/deformstructure.ts +60 -18
  43. package/src/deformsurvey.ts +2295 -0
  44. package/src/render.ts +80 -4
  45. package/src/validate.ts +361 -1103
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The model side's supply of `AnimationDurationFacts` (issue #1025, cut 4c-3
3
+ * of step 4c of #380): the document's animations in the file's order, each
4
+ * with the runtime's duration and every timeline's own duration.
5
+ *
6
+ * Every number is the core's reading, through functions rigc already runs:
7
+ *
8
+ * - **The roster's order** is the file's, `fileAnimationOrder` (`src/compile.ts`,
9
+ * issue #1034): a `rigc-compiled/3` document's stated `editorOrder`, else the
10
+ * emitter's own rule over the document's names — integer-like names first,
11
+ * as the file keys them.
12
+ * - **An animation's duration** is `CoreAnimationTimelines.duration`, the last
13
+ * key time of every timeline as float32 — the value `tools/pose_oracle.ts
14
+ * compare` holds equal to spine-core's on its `animations` roster.
15
+ * - **A timeline's own duration** is its last key's time as the core read it
16
+ * (float32): each bone and slot timeline, each constraint timeline in the
17
+ * order the runtime builds them (`modelConstraintTimelineSources`), each
18
+ * attachment's deform and sequence timeline, the draw order and the events.
19
+ * How many timelines that makes is the count the runtime builds
20
+ * (`timelineCount`, which the selftest's `VF10` holds equal to the runtime's
21
+ * on every slider animation); a walk that lists another count is this
22
+ * module's defect and throws by name rather than handing A09 a list of the
23
+ * wrong length.
24
+ *
25
+ * Links nothing from the runtime.
26
+ */
27
+ import { fileAnimationOrder } from '../../compile.ts';
28
+ import type { AnimationDuration, AnimationDurationFacts } from '../facts/animation_durations.ts';
29
+ import { modelConstraintTimelineSources, timelineCount } from './constraints.ts';
30
+ import type { ReadDocument } from './parse.ts';
31
+
32
+ /** The last of `times`, which the core read in key order. */
33
+ const lastOf = (times: ReadonlyArray<{ time: number }>): number[] => (times.length === 0 ? [] : [times[times.length - 1].time]);
34
+
35
+ export function modelAnimationDurations(read: ReadDocument): AnimationDurationFacts {
36
+ const constraintTimelines = modelConstraintTimelineSources(read);
37
+ const animations: AnimationDuration[] = [];
38
+ for (const name of fileAnimationOrder(read.doc)) {
39
+ const anim = read.doc.animations.find((a) => a.name === name);
40
+ if (anim === undefined) continue;
41
+ const t = anim.timelines;
42
+ const durations: number[] = [];
43
+ for (const target of [...t.bones, ...t.slots]) for (const tl of target.timelines) durations.push(...lastOf(tl.keys));
44
+ for (const source of constraintTimelines) if (source.animation === name) durations.push(...lastOf(source.keys));
45
+ for (const a of t.attachments) {
46
+ if (a.deform !== null) durations.push(...lastOf(a.deform));
47
+ if (a.sequence !== null) durations.push(...lastOf(a.sequence));
48
+ }
49
+ durations.push(...lastOf(t.drawOrder), ...lastOf(t.events));
50
+ const built = timelineCount(t);
51
+ if (durations.length !== built) {
52
+ throw new Error(`internal: animation "${name}": the durations walk lists ${durations.length} timeline(s) and the core reads ${built}`);
53
+ }
54
+ animations.push({ name, duration: t.duration, timelineDurations: durations });
55
+ }
56
+ return { animations };
57
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The model side's supply of `BoneTimelineFacts` (issue #1025, cut 4c-4 of
3
+ * #380): every animation's bone timelines as the Spine file states them.
4
+ *
5
+ * The same reading A45's slot timelines are given (`fileSlotTimelines` in
6
+ * `./slot_colour.ts`), over the `bones` group: the animations put in the
7
+ * file's order by `editorAnimationOrder` (`src/compile.ts`, the function the
8
+ * emitter is handed), each animation's bones and their timelines laid out as
9
+ * the file lays them (`animations.<name>.bones.<bone>.<timeline> = keys`, in
10
+ * the document's order, which is the order `emitAnimation` writes the model's
11
+ * map in), and the whole handed to the emitter's own `withoutParserDefaults`
12
+ * and `inEditorKeyOrder` (`src/keyorder.ts`) — so a key field the emitter
13
+ * leaves out at the parser's default (`time: 0`, a translate key's `y: 0`) is
14
+ * left out here too, and a body printing a key's `time` prints what it prints
15
+ * over the file. Nothing here restates either rule.
16
+ *
17
+ * Links nothing from the runtime.
18
+ */
19
+ import { editorAnimationOrder } from '../../compile.ts';
20
+ import { inEditorKeyOrder, withoutParserDefaults } from '../../keyorder.ts';
21
+ import type { BoneTimelineFacts, BoneTimelines } from '../facts/bone_timelines.ts';
22
+ import { isObj, type Json } from '../values.ts';
23
+ import type { ReadDocument } from './parse.ts';
24
+
25
+ const list = (v: unknown): Json[] => (Array.isArray(v) ? v.filter(isObj) : []);
26
+
27
+ /** Every animation's bone timelines as the Spine file states them: `animations.<name>.bones.<bone>.<timeline> = keys`. */
28
+ export function fileBoneTimelines(read: ReadDocument): BoneTimelines[] {
29
+ const byName = new Map<string, Json>();
30
+ for (const anim of list(read.json.animations)) if (typeof anim.name === 'string') byName.set(anim.name, anim);
31
+ const animations: Json = {};
32
+ for (const name of editorAnimationOrder([...byName.keys()])) {
33
+ const bones: Json = {};
34
+ for (const bone of list((byName.get(name) as Json).bones)) {
35
+ if (typeof bone.name !== 'string') continue;
36
+ const timelines: Json = {};
37
+ for (const timeline of list(bone.timelines)) {
38
+ if (typeof timeline.name === 'string') timelines[timeline.name] = list(timeline.keys).map((key) => ({ ...key }));
39
+ }
40
+ bones[bone.name] = timelines;
41
+ }
42
+ // An animation keying no bone writes no `bones` group — `emitAnimation`'s `if (animation.bones.size)`.
43
+ animations[name] = Object.keys(bones).length > 0 ? { bones } : {};
44
+ }
45
+ const file = inEditorKeyOrder(withoutParserDefaults({ animations }));
46
+ const out: BoneTimelines[] = [];
47
+ for (const [animation, anim] of Object.entries(file.animations)) {
48
+ if (!isObj(anim) || !isObj(anim.bones)) continue;
49
+ for (const [bone, timelines] of Object.entries(anim.bones)) out.push({ animation, bone, timelines });
50
+ }
51
+ return out;
52
+ }
53
+
54
+ export function modelBoneTimelines(read: ReadDocument): BoneTimelineFacts {
55
+ return { boneTimelines: fileBoneTimelines(read) };
56
+ }
@@ -19,10 +19,12 @@
19
19
  * runtime's), and the timelines it carries are the bone and slot timelines
20
20
  * plus the count of every later group the reader counts.
21
21
  * - **The timelines**: the animations in the file's order
22
- * (`editorAnimationOrder`, the function the emitter is handed); in each the
23
- * groups in the runtime's order (`../facts/constraints.ts`' ⭐) and each
24
- * group's entries and timelines in the document's order, which the emitter
25
- * writes unchanged. A key's time and value are the core's (float32), and a
22
+ * (`fileAnimationOrder`, issue #1034: a `rigc-compiled/3` document's
23
+ * `editorOrder`, else the emitter's own rule over its names); in each the
24
+ * groups in the runtime's order (`../facts/constraints.ts`' ⭐), each
25
+ * group's entries in the order the file keys them — the document's, an
26
+ * integer-like constraint name first (`keyedOrder`) — and each entry's
27
+ * timelines in the document's order, which the emitter writes unchanged. A key's time and value are the core's (float32), and a
26
28
  * Bézier segment's samples `bezierPolyline` over the numbers the document
27
29
  * states — the runtime's curve, as the core reproduces it.
28
30
  * - **The reach of a physics timeline naming none** is asked of the core's
@@ -39,7 +41,7 @@
39
41
  *
40
42
  * Links nothing from the runtime.
41
43
  */
42
- import { editorAnimationOrder } from '../../compile.ts';
44
+ import { fileAnimationOrder, keyedOrder, type OrderedDocument } from '../../compile.ts';
43
45
  import { bezierPolyline, type CoreAnimationTimelines, type CoreKey } from '../../core/animation.ts';
44
46
  import { TRANSFORM_MIXES, TRANSFORM_PROPERTIES, type CoreConstraintRecord } from '../../core/constraints.ts';
45
47
  import { EVERY_GLOBAL_PHYSICS, posedPhysics, type CorePhysicsRecord, type PhysicsTimelineKind } from '../../core/constraints_physics.ts';
@@ -144,39 +146,55 @@ export interface ModelConstraintTimelineSource {
144
146
  keys: readonly CoreKey[];
145
147
  }
146
148
 
149
+ /** How the animations are put in the file's order: `fileAnimationOrder`. A parameter only so the selftest can show what another order would print (`VF11`). */
150
+ export type AnimationFileOrder = (doc: OrderedDocument) => readonly string[];
151
+
152
+ /**
153
+ * `entries` in the order the Spine file keys them by name (issue #1034): each
154
+ * constraint group of an animation is an object the emitter fills in the
155
+ * model's order, so the names are grouped as they first appear and put
156
+ * through `keyedOrder` — an integer-like name first — and every entry of one
157
+ * name keeps its place among them.
158
+ */
159
+ function inKeyedOrder<T extends { name: string }>(entries: readonly T[]): T[] {
160
+ const names = entries.map((e) => e.name);
161
+ return keyedOrder(names.filter((n, i) => names.indexOf(n) === i)).flatMap((name) => entries.filter((e) => e.name === name));
162
+ }
163
+
147
164
  /** Every constraint timeline of the document, in the order the runtime builds them (the header) — the walk `modelConstraintFacts` reads, and the selftest's measurement of each derivation. */
148
- export function modelConstraintTimelineSources(read: ReadDocument): ModelConstraintTimelineSource[] {
165
+ export function modelConstraintTimelineSources(read: ReadDocument, animations: AnimationFileOrder = fileAnimationOrder): ModelConstraintTimelineSource[] {
149
166
  const { doc } = read;
150
167
  const jsonAnimations = Array.isArray(read.json.animations) ? read.json.animations.filter(isObj) : [];
151
168
  const out: ModelConstraintTimelineSource[] = [];
152
- for (const name of editorAnimationOrder(doc.animations.map((a) => a.name))) {
169
+ for (const name of animations(doc)) {
153
170
  const anim = doc.animations.find((a) => a.name === name);
154
171
  if (anim === undefined) continue;
155
172
  const c = anim.constraints;
156
- for (const tl of c.ik) out.push({ animation: name, kind: 'ik', word: 'ik', name: tl.name, keys: tl.keys });
157
- for (const tl of c.transform) out.push({ animation: name, kind: 'transform', word: 'transform', name: tl.name, keys: tl.keys });
158
- for (const entry of c.path) {
173
+ for (const tl of inKeyedOrder(c.ik)) out.push({ animation: name, kind: 'ik', word: 'ik', name: tl.name, keys: tl.keys });
174
+ for (const tl of inKeyedOrder(c.transform)) out.push({ animation: name, kind: 'transform', word: 'transform', name: tl.name, keys: tl.keys });
175
+ for (const entry of inKeyedOrder(c.path)) {
159
176
  for (const word of Object.keys(entry)) {
160
177
  if (word === 'position' || word === 'spacing' || word === 'mix') out.push({ animation: name, kind: 'path', word, name: entry.name, keys: entry[word] ?? [] });
161
178
  }
162
179
  }
163
- for (const tl of c.physicsKeyed ?? []) out.push({ animation: name, kind: 'physics', word: tl.kind, name: tl.name, keys: tl.keys });
180
+ for (const tl of inKeyedOrder(c.physicsKeyed ?? [])) out.push({ animation: name, kind: 'physics', word: tl.kind, name: tl.name, keys: tl.keys });
164
181
  // A slider entry's timelines in the order the document lists them, which `readSliderTimelines` keeps by name only.
165
182
  const jsonSliders = ((): Json[] => {
166
183
  const json = jsonAnimations.find((a) => a.name === name)?.constraints;
167
184
  return isObj(json) && Array.isArray(json.slider) ? json.slider.filter(isObj) : [];
168
185
  })();
169
- c.slider.forEach((entry, i) => {
170
- const listed = Array.isArray(jsonSliders[i]?.timelines) ? (jsonSliders[i].timelines as unknown[]).filter(isObj).map((t) => t.name) : [];
186
+ // Paired with the document's own entry by index before the walk is put in the file's order.
187
+ const sliders = c.slider.map((entry, i) => ({ name: entry.name, entry, listed: Array.isArray(jsonSliders[i]?.timelines) ? (jsonSliders[i].timelines as unknown[]).filter(isObj).map((t) => t.name) : [] }));
188
+ for (const { entry, listed } of inKeyedOrder(sliders)) {
171
189
  for (const word of listed) {
172
190
  if (word === 'time' || word === 'mix') out.push({ animation: name, kind: 'slider', word, name: entry.name, keys: entry[word] ?? [] });
173
191
  }
174
- });
192
+ }
175
193
  }
176
194
  return out;
177
195
  }
178
196
 
179
- export function modelConstraintFacts(read: ReadDocument): ConstraintFacts {
197
+ export function modelConstraintFacts(read: ReadDocument, animations: AnimationFileOrder = fileAnimationOrder): ConstraintFacts {
180
198
  const { doc } = read;
181
199
  const constraints: ConstraintEntry[] = doc.constraints.map((c) => {
182
200
  if (c.record === undefined) throw new Error(`internal: ${c.kind} constraint "${c.name}" is one the reader returned without its record`);
@@ -184,7 +202,7 @@ export function modelConstraintFacts(read: ReadDocument): ConstraintFacts {
184
202
  });
185
203
  const indexOf = (kind: ConstraintKind, name: string): number => doc.constraints.findIndex((c) => c.kind === kind && c.name === name);
186
204
  const physicsRecords = doc.constraints.flatMap((c) => (c.record?.kind === 'physics' ? [c.record] : []));
187
- const timelines: ConstraintTimeline[] = modelConstraintTimelineSources(read).map(({ animation, kind, word, name, keys }) => {
205
+ const timelines: ConstraintTimeline[] = modelConstraintTimelineSources(read, animations).map(({ animation, kind, word, name, keys }) => {
188
206
  const constraint = name === EVERY_GLOBAL_PHYSICS && kind === 'physics' ? -1 : indexOf(kind, name);
189
207
  const reach = constraint >= 0 ? [constraint] : [...unnamedReach(physicsRecords, word as PhysicsTimelineKind)].map((n) => indexOf('physics', n)).sort((a, b) => a - b);
190
208
  const rule = kind === 'physics' ? physicsRuleFor(word) : undefined;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The model side's supply of `DeformSurveyFacts` (issue #1025, cut 4c-3 of
3
+ * step 4c of #380): the survey off the model document alone —
4
+ * `surveyOfModel` (`src/deformsurvey.ts`), the document's structure read by
5
+ * `modelStructure` (`src/deformstructure.ts`) and every pose taken by the
6
+ * core's poser. It is the survey `explain` takes of a build that carries a
7
+ * model document (`surveyOfBuild`'s model path) and the one
8
+ * `tools/survey_hashes.ts` holds byte for byte to spine-core's on every corpus
9
+ * row; called, not restated.
10
+ *
11
+ * A pose the core refuses — a construct it leaves out, a value it computes as
12
+ * no number — is a `CoreInputError` naming why, and it reaches A39 as the
13
+ * refusal: the line the harness prints for a body that threw, the core's
14
+ * sentence in it. A survey that is not the runtime's is never handed on.
15
+ *
16
+ * Links nothing from the runtime.
17
+ */
18
+ import { surveyOfModel } from '../../deformsurvey.ts';
19
+ import type { DeformSurveyFacts } from '../facts/deform_survey.ts';
20
+ import type { ReadDocument } from './parse.ts';
21
+
22
+ export function modelDeformSurvey(read: ReadDocument): DeformSurveyFacts {
23
+ return { survey: (exempt) => surveyOfModel(read.doc, exempt) };
24
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The model side's supply of `EventKeyFacts` (issue #1025, cut 4c-4 of #380):
3
+ * every event key of the document, with the declaration it fires.
4
+ *
5
+ * - **The order is the file's.** The animations by `editorAnimationOrder`
6
+ * (`src/compile.ts`, the function the emitter is handed), and an animation's
7
+ * keys in the document's order, which is the order `emitAnimation` writes
8
+ * the model's list in; an animation with no event key writes no `events`
9
+ * group, so it carries no event timeline here either.
10
+ * - **The moved clause's inputs.** Which of `volume` and `balance` the key
11
+ * states — the document's key carries the fields the file's does, and the
12
+ * parser-default pass leaves an event key's audio fields alone (its row is
13
+ * `time` only) — and whether the declaration names an audio path, the
14
+ * `audio` the document's `events` section states for that name.
15
+ * - **No `kept` finding, ever.** The four clauses that stay with the round
16
+ * trip are states `readModel` refuses (`readEventKeys`), so on a document
17
+ * this side has read none of them can hold.
18
+ *
19
+ * Links nothing from the runtime.
20
+ */
21
+ import { editorAnimationOrder } from '../../compile.ts';
22
+ import type { EventKeyEntry, EventKeyFacts } from '../facts/event_keys.ts';
23
+ import { isObj, type Json } from '../values.ts';
24
+ import type { ReadDocument } from './parse.ts';
25
+
26
+ const list = (v: unknown): Json[] => (Array.isArray(v) ? v.filter(isObj) : []);
27
+
28
+ export function modelEventKeys(read: ReadDocument): EventKeyFacts {
29
+ const audio = new Map<string, boolean>();
30
+ for (const def of list(read.json.events)) if (typeof def.name === 'string') audio.set(def.name, typeof def.audio === 'string');
31
+ const byName = new Map<string, Json>();
32
+ for (const anim of list(read.json.animations)) if (typeof anim.name === 'string') byName.set(anim.name, anim);
33
+ const keys: EventKeyEntry[] = [];
34
+ let timelines = 0;
35
+ for (const animation of editorAnimationOrder([...byName.keys()])) {
36
+ const events = list((byName.get(animation) as Json).events);
37
+ if (events.length === 0) continue;
38
+ timelines++;
39
+ events.forEach((key, index) => {
40
+ const name = String(key.name);
41
+ keys.push({ animation, index, kept: [], stopped: false, name, sets: { volume: key.volume !== undefined, balance: key.balance !== undefined }, audio: audio.get(name) ?? false });
42
+ });
43
+ }
44
+ return { parsed: true, animations: true, timelines, keys };
45
+ }
@@ -9,7 +9,10 @@
9
9
  * the body inside its own `check`; this entry supplies them from the document
10
10
  * (`./parse.ts`, `./skin_entries.ts`, `./atlas_pages.ts`, `./slot_colour.ts`;
11
11
  * cut 4c-2's `./mesh_attachments.ts`, `./vertex_polygons.ts`,
12
- * `./linked_meshes.ts`, `./constraints.ts`)
12
+ * `./linked_meshes.ts`, `./constraints.ts`; cut 4c-4's
13
+ * `./skeleton_roster.ts`, `./bone_timelines.ts`, `./event_keys.ts`; cut
14
+ * 4c-3's `./deform_survey.ts`, `./animation_durations.ts`, `./two_colour.ts`,
15
+ * `./sequences.ts`)
13
16
  * and calls the same body inside the same harness (`../harness.ts`). The
14
17
  * selftest holds the two to the same lines on every call it makes with a
15
18
  * model in hand, and `tools/verdict_gate.ts` on every recipe.
@@ -88,6 +91,31 @@ import type { MeshFacts } from '../facts/mesh_attachments.ts';
88
91
  import type { PolygonFacts } from '../facts/vertex_polygons.ts';
89
92
  import type { LinkFacts } from '../facts/linked_meshes.ts';
90
93
  import type { ConstraintFacts } from '../facts/constraints.ts';
94
+ import { a12NoDarkColor } from '../bodies/a12.ts';
95
+ import { a24AxisSpaceStroke } from '../bodies/a24.ts';
96
+ import { a25DetachedBoneParentage } from '../bodies/a25.ts';
97
+ import { a26SlotDrawOrder } from '../bodies/a26.ts';
98
+ import { a29StrokeWithinContactDepth } from '../bodies/a29.ts';
99
+ import { a30StrokeWithinCapContainment } from '../bodies/a30.ts';
100
+ import { a32EventKeysResolve } from '../bodies/a32.ts';
101
+ import { modelSkeletonRoster } from './skeleton_roster.ts';
102
+ import { modelBoneTimelines } from './bone_timelines.ts';
103
+ import { modelEventKeys } from './event_keys.ts';
104
+ import type { SkeletonRosterFacts } from '../facts/skeleton_roster.ts';
105
+ import type { BoneTimelineFacts } from '../facts/bone_timelines.ts';
106
+ import type { EventKeyFacts } from '../facts/event_keys.ts';
107
+ import { a39DeformKeepsTriangleWinding } from '../bodies/a39.ts';
108
+ import { a09AnimationDurationMatchesSpec } from '../bodies/a09.ts';
109
+ import { a43TwoColorTintLoadsAndPosesAsWritten } from '../bodies/a43.ts';
110
+ import { a46SequenceAttachmentsShowTheFrameTheFileStates } from '../bodies/a46.ts';
111
+ import { modelDeformSurvey } from './deform_survey.ts';
112
+ import { modelAnimationDurations } from './animation_durations.ts';
113
+ import { modelTwoColour } from './two_colour.ts';
114
+ import { modelSequences } from './sequences.ts';
115
+ import type { DeformSurveyFacts } from '../facts/deform_survey.ts';
116
+ import type { AnimationDurationFacts } from '../facts/animation_durations.ts';
117
+ import type { TwoColourFacts } from '../facts/two_colour.ts';
118
+ import type { SequenceFacts } from '../facts/sequences.ts';
91
119
 
92
120
  /** What the model side is given. */
93
121
  export interface ModelValidateInput {
@@ -96,7 +124,7 @@ export interface ModelValidateInput {
96
124
  /** The directory the document's page names resolve against — the build's `--out`. */
97
125
  atlasDir: string;
98
126
  profile: AssertionProfile;
99
- /** The rig info the build carries, as `validate()` is handed it — A13, A15, A19 (cut 4c-1) and A20, A21, A28, A41, A47, A48 (cut 4c-2) read it; optional because `ValidateInput.rig` is: absent for a bare directory, on both sides. */
127
+ /** The rig info the build carries, as `validate()` is handed it — A13, A15, A19 (cut 4c-1) and A20, A21, A28, A41, A47, A48 (cut 4c-2) and A24, A25, A26, A29, A30 (cut 4c-4) read it; optional because `ValidateInput.rig` is: absent for a bare directory, on both sides. */
100
128
  rig?: RigInfo;
101
129
  /**
102
130
  * The stage and the pages' `pma`, for a `rigc-compiled/2` or `/1` document,
@@ -106,6 +134,8 @@ export interface ModelValidateInput {
106
134
  * `given` beside it is refused by name.
107
135
  */
108
136
  given?: ModelGiven;
137
+ /** The motion spec's declared durations, as `validate()` is handed them — A09 reads them (cut 4c-3); absent where the caller has no motion spec, on both sides. */
138
+ declaredDurations?: Record<string, number>;
109
139
  }
110
140
 
111
141
  /** The model side's report: `validate()`'s shape, over the moved assertions and the two parse rules. */
@@ -134,6 +164,13 @@ export interface ModelSupply {
134
164
  polygons: (read: ReadDocument) => PolygonFacts;
135
165
  links: (read: ReadDocument) => LinkFacts;
136
166
  constraints: (read: ReadDocument) => ConstraintFacts;
167
+ skeletonRoster: (read: ReadDocument) => SkeletonRosterFacts;
168
+ boneTimelines: (read: ReadDocument) => BoneTimelineFacts;
169
+ eventKeys: (read: ReadDocument) => EventKeyFacts;
170
+ deformSurvey: (read: ReadDocument) => DeformSurveyFacts;
171
+ animationDurations: (read: ReadDocument) => AnimationDurationFacts;
172
+ twoColour: (read: ReadDocument) => TwoColourFacts;
173
+ sequences: (read: ReadDocument) => SequenceFacts;
137
174
  }
138
175
 
139
176
  /** The suppliers the model side runs on. */
@@ -151,6 +188,13 @@ export const MODEL_SUPPLY: ModelSupply = {
151
188
  polygons: modelPolygonFacts,
152
189
  links: modelLinkFacts,
153
190
  constraints: modelConstraintFacts,
191
+ skeletonRoster: modelSkeletonRoster,
192
+ boneTimelines: modelBoneTimelines,
193
+ eventKeys: modelEventKeys,
194
+ deformSurvey: modelDeformSurvey,
195
+ animationDurations: modelAnimationDurations,
196
+ twoColour: modelTwoColour,
197
+ sequences: modelSequences,
154
198
  };
155
199
 
156
200
  /**
@@ -169,6 +213,13 @@ export interface MovedAssertion {
169
213
  * model side's place for a rule `validate()` runs BEFORE its round trip
170
214
  * (A08, issue #589), so that a region miss is named by the rule's own
171
215
  * sentence on both sides while the parse beside it refuses the file.
216
+ *
217
+ * Since cut 4c-4 also every rule `validate()` runs over the skeleton JSON
218
+ * whatever its round trip did (A12, A24, A25, A26, A29, A30, and A32, which
219
+ * runs before it): on the runtime's side their verdict does not wait on the
220
+ * load, so on this side it does not wait on the region rule, and where both
221
+ * parses refuse a build the two sides' lines of these rules are still
222
+ * compared.
172
223
  */
173
224
  beforeTheParse?: boolean;
174
225
  }
@@ -207,6 +258,17 @@ export const MOVED_ASSERTIONS: readonly MovedAssertion[] = [
207
258
  { code: 'A19_OVERLAY_PNGS_HAVE_ALPHA', run: (v, read, input, supply) => a19OverlayPngsHaveAlpha(v, supply.atlasRegions(read, input), supply.stage(read, input), supply.skinEntries(read), input), unread: SKIP_NO_ATLAS },
208
259
  { code: 'A27_REGION_NAME_MATCHES_PAGE_FILENAME', run: (v, read, input, supply) => a27RegionNameMatchesPageFilename(v, supply.atlasRegions(read, input)), unread: SKIP_NO_ATLAS },
209
260
  { code: 'A28_RIBBON_ROWS_SHARE_WEIGHTS', run: (v, read, input, supply) => a28RibbonRowsShareWeights(v, supply.meshes(read), input.rig), unread: SKIP_NO_MODEL },
261
+ { code: 'A32_EVENT_KEYS_RESOLVE', run: (v, read, _input, supply) => a32EventKeysResolve(v, supply.eventKeys(read)), unread: SKIP_NO_MODEL, beforeTheParse: true },
262
+ { code: 'A12_NO_DARK_COLOR', run: (v, read, _input, supply) => a12NoDarkColor(v, supply.skeletonRoster(read), supply.slotColour(read).slotTimelines), unread: SKIP_NO_MODEL, beforeTheParse: true },
263
+ { code: 'A24_AXIS_SPACE_STROKE', run: (v, read, input, supply) => a24AxisSpaceStroke(v, supply.boneTimelines(read), input), unread: SKIP_NO_MODEL, beforeTheParse: true },
264
+ { code: 'A25_DETACHED_BONE_PARENTAGE', run: (v, read, input, supply) => a25DetachedBoneParentage(v, supply.skeletonRoster(read), input), unread: SKIP_NO_MODEL, beforeTheParse: true },
265
+ { code: 'A26_SLOT_DRAW_ORDER', run: (v, read, input, supply) => a26SlotDrawOrder(v, supply.skeletonRoster(read), input), unread: SKIP_NO_MODEL, beforeTheParse: true },
266
+ { code: 'A29_STROKE_WITHIN_CONTACT_DEPTH', run: (v, read, input, supply) => a29StrokeWithinContactDepth(v, supply.boneTimelines(read), input), unread: SKIP_NO_MODEL, beforeTheParse: true },
267
+ { code: 'A30_STROKE_WITHIN_CAP_CONTAINMENT', run: (v, read, input, supply) => a30StrokeWithinCapContainment(v, supply.boneTimelines(read), input), unread: SKIP_NO_MODEL, beforeTheParse: true },
268
+ { code: 'A39_DEFORM_KEEPS_TRIANGLE_WINDING', run: (v, read, input, supply) => a39DeformKeepsTriangleWinding(v, supply.deformSurvey(read), input.rig), unread: SKIP_NO_MODEL },
269
+ { code: 'A09_ANIMATION_DURATION_MATCHES_SPEC', run: (v, read, input, supply) => a09AnimationDurationMatchesSpec(v, supply.animationDurations(read), input.declaredDurations), unread: SKIP_NO_MODEL },
270
+ { code: 'A43_TWO_COLOR_TINT_LOADS_AND_POSES_AS_WRITTEN', run: (v, read, _input, supply) => a43TwoColorTintLoadsAndPosesAsWritten(v, supply.twoColour(read)), unread: SKIP_NO_MODEL },
271
+ { code: 'A46_SEQUENCE_ATTACHMENTS_SHOW_THE_FRAME_THE_FILE_STATES', run: (v, read, _input, supply) => a46SequenceAttachmentsShowTheFrameTheFileStates(v, supply.sequences(read)), unread: SKIP_NO_MODEL },
210
272
  ];
211
273
 
212
274
  /** The codes the model side prints: its two parse rules, then the moved assertions. */
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The model side's supply of `LinkFacts` (issue #1025, step 4c of #380): the
3
3
  * document's `linkedmesh` records, in the order the Spine file spells them —
4
- * the skins by the emitter's `editorSkinOrder`, each skin's slot keys by its
5
- * `editorSlotKeyOrder`, each slot's records in table order
4
+ * the skins and each skin's slot keys in the file's order (`fileSkinOrder`,
5
+ * issue #1034), each slot's records in table order
6
6
  * (`fileSpelledEntries`, `./vertex_polygons.ts`).
7
7
  *
8
8
  * `encoding` is empty on every link: a link record has no geometry field, so
@@ -6,7 +6,7 @@
6
6
  * Every value is the document's, through a function rigc already runs:
7
7
  *
8
8
  * - **The order** is `fileOrderedEntries` (`./skin_entries.ts`), the skins
9
- * put in the file's order by the emitter's `editorSkinOrder`.
9
+ * put in the file's order (`fileSkinOrder`, issue #1034).
10
10
  * - **A binding's bone** is the index the emitter writes for its name,
11
11
  * `boneIndexOf` over the document's bones (`src/emit_spine.ts`), and its
12
12
  * weight the float32 the runtime stores a vertex array in (`Math.fround`,
@@ -9,9 +9,10 @@
9
9
  * no pages, and the registry skips A08 on it by name rather than reading that
10
10
  * as an atlas that declares no region (`./index.ts`).
11
11
  * - **The lookups** walk the document's skins as the file lays them: the skins
12
- * by the emitter's `editorSkinOrder`, a skin's slot keys by its
13
- * `editorSlotKeyOrder` (both `src/compile.ts`, the functions `emitSkins` is
14
- * handed) — NOT the draw order `./skin_entries.ts` walks, because A08 walks the
12
+ * and each skin's slot keys in the order `fileSkinOrder` gives
13
+ * (`src/compile.ts`, issue #1034) — a `rigc-compiled/3` document's
14
+ * `editorOrder`, else the emitter's `editorSkinOrder` and
15
+ * `editorSlotKeyOrder`, the functions `emitSkins` is handed — NOT the draw order `./skin_entries.ts` walks, because A08 walks the
15
16
  * file's keys and the loaded skins do not — and a slot's records in its
16
17
  * table's order. A record of a kind that resolves a region (`CORE_REGION_KINDS`:
17
18
  * region, mesh, linked mesh) joins under its `name`, else its placeholder,
@@ -21,7 +22,7 @@
21
22
  *
22
23
  * Links nothing from the runtime.
23
24
  */
24
- import { editorSkinOrder, editorSlotKeyOrder } from '../../compile.ts';
25
+ import { fileSkinOrder, skinsInFileOrder } from '../../compile.ts';
25
26
  import { CORE_REGION_KINDS } from '../../core/index.ts';
26
27
  import type { SkinTableEntry } from '../../model.ts';
27
28
  import type { RegionJoinFacts } from '../facts/region_joins.ts';
@@ -29,19 +30,26 @@ import { attachmentRegionLookups, type AttachmentRegionJoin } from '../region_lo
29
30
  import { isObj, type Json } from '../values.ts';
30
31
  import type { ReadDocument } from './parse.ts';
31
32
 
32
- /** The joins, with the skins and their slot keys put in order by `skins` and `slotKeys` — the emitter's unless the selftest asks what the document's own order would print. */
33
- export function modelRegionJoinsWith(
34
- read: ReadDocument,
35
- skins: <T extends { name: string }>(list: readonly T[]) => T[] = editorSkinOrder,
36
- slotKeys: <T>(table: Record<string, T>) => Record<string, T> = editorSlotKeyOrder,
37
- ): RegionJoinFacts {
33
+ /** The skins and each skin's slot keys in an order other than the file's — a parameter only so the selftest can show what that order would print. */
34
+ export type SlotKeyWalk = <T extends Json & { name: string }>(skins: readonly T[]) => Array<{ skin: T; slots: readonly string[] }>;
35
+
36
+ /**
37
+ * The joins, with the skins and their slot keys in the file's order — the order
38
+ * a `rigc-compiled/3` document states, else the emitter's rule
39
+ * (`fileSkinOrder`, issue #1034) — unless the selftest hands `order`, the
40
+ * skins and each skin's slot keys in another order, to show what it would
41
+ * print (`VF09`, `VF11`).
42
+ */
43
+ export function modelRegionJoinsWith(read: ReadDocument, order?: SlotKeyWalk): RegionJoinFacts {
38
44
  const pages = read.doc.pages;
39
45
  const regionNames = pages === null ? null : pages.flatMap((page) => page.regions.map((region) => region.name));
40
46
  const stated = (Array.isArray(read.json.skins) ? read.json.skins.filter(isObj) : []).filter((skin): skin is Json & { name: string } => typeof skin.name === 'string');
41
47
  const joins: AttachmentRegionJoin[] = [];
42
- for (const skin of skins(stated)) {
48
+ const walk = order === undefined ? skinsInFileOrder(stated, fileSkinOrder(read.doc)) : order(stated);
49
+ for (const { skin, slots } of walk) {
43
50
  if (!isObj(skin.attachments)) continue;
44
- for (const [slot, table] of Object.entries(slotKeys(skin.attachments))) {
51
+ for (const slot of slots) {
52
+ const table = skin.attachments[slot];
45
53
  if (!isObj(table)) continue;
46
54
  for (const [placeholder, record] of Object.entries(table)) {
47
55
  if (!isObj(record) || !CORE_REGION_KINDS.has(record.kind as SkinTableEntry['kind'])) continue;