rig-c 2.37.0 → 2.38.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 CHANGED
@@ -575,6 +575,7 @@ commands take it and what its default is.
575
575
  | `build … --atlas-in <file.atlas>` | the same build with every part resolved to a **region of an existing pack** instead of a loose PNG; a name the atlas lacks, a size the spec disagrees with or a rectangle off its page is refused by name |
576
576
  | `validate <dir>` | re-gates artifacts already on disk |
577
577
  | `repack <dir> --out <dir>` | a packed build **repacked from its own output** — `skeleton.json`, `skeleton.atlas` and the pages, with no parts kept — under the packing flags `build --pack` takes, so a packer improvement reaches a build whose parts are gone. Every region is lifted off its page, the skeleton read back with `ingest`, and `build --pack` run over the lifted parts with the same gate; it writes only after every region is shown pixel-identical to the input's, the skeleton byte-identical and the gate green, and refuses by name an atlas it cannot lift exactly. A skeleton the rebuild does not reproduce byte for byte — a build written before 2.2.0, whose header box was its stage — is refused naming every differing path, and written, every path printed, only under `--accept-skeleton-differences`. `--stage-box <slot>` reads the stage from the box a build carries for it (`skeleton.stageBox`), the one way the three files alone carry the stage exactly ([AUTHORING §0.4](docs/AUTHORING.md)) |
578
+ | `repack <dir> --out <dir> --keep-pages` | **`skeleton.model.json` alone, for the pages already in place** — for a player that reads the document beside an atlas and pages that already shipped. The same read and stage rules, then `build --atlas-in` over the input atlas in place of the lift and the pack; it writes the document, and nothing else, only after its `pages` are shown to state the atlas as it stands, the rebuilt skeleton byte-identical to the one on disk (so `spine.sha256` names it — no acceptance flag here) and the gate green. `--out` is usually the build's own directory and must not already hold a `skeleton.model.json`; a page or region line the document has no field for is refused by name ([AUTHORING §0.4](docs/AUTHORING.md)) |
578
579
  | `ingest <skeleton.json> --out <dir>` | `build` run backwards: reads a Spine 4.3 skeleton and writes the rig spec and motion spec that **rebuild it**, plus a findings report naming everything it could not carry. a skeleton that declares no stage is carried as declaring none, `--stage x,y,w,h` adds a box to one — and is refused, rather than ignored, beside one that declares a box — and `--images <dir>` writes the spec's own images directory — the opposite direction from `build --images`, which overrides it — so the rebuild carries no flag at all |
579
580
  | `explain --rig … --motion …` | the compiled rig as a table — every bone with its resolved parent, the slots in draw order, every timeline key by key. Writes nothing. What to reach for when a rig compiles and still looks wrong |
580
581
  | `render --candidate <dir>` | PNG frames plus a contact sheet, in `render/`. `--hide <slot,…>` or `--slot <slot,…>` draws part of the rig on the **same grid** as the whole, so the two frames overlay and the difference is the part; `frames.json` records the subset and `check` refuses such a set as a reference. `--geometry` adds a `geometry.json` per set: every frame's bone world transforms and skinned attachment vertices, with the rest geometry, on the frames' own grid |
package/docs/AUTHORING.md CHANGED
@@ -1317,6 +1317,7 @@ that lifts them.
1317
1317
  | `--stage x,y,w,h` | handed to `ingest` as its own `--stage` (§0.3) — a box for a skeleton that states none, refused beside one that does |
1318
1318
  | `--stage-box <slot>` | handed to `ingest` as its own `--stage-box` (§0.3): the stage read from the bounding box a build writes for a rig that states `skeleton.stageBox` — the exact way to carry the stage through a repack of the three files alone (*The stage*, below). `ingest`'s refusals reach the caller in its own words |
1319
1319
  | `--accept-skeleton-differences` | write the rebuild even where its `skeleton.json` differs from the input's, with **every** differing path printed and both values (default: refused naming them, check (b) below). Nothing else relaxes: check (a) and the gate hold exactly as without it. Beside a skeleton that comes back byte-identical, check (b)'s line says the flag accepted nothing |
1320
+ | `--keep-pages` | write **`skeleton.model.json` alone**, for the atlas and pages as they stand — nothing lifted, nothing packed, no page and no atlas written (*Keeping the pages*, below). Takes none of the packing flags and not `--accept-skeleton-differences`, each refused by name (exit 2) |
1320
1321
 
1321
1322
  Every other flag `build` takes is refused by name, with the reason `repack` does not
1322
1323
  take it (`--rig`, `--motion`, `--images`, `--manifest`, `--copy-images`, `--pack`,
@@ -1449,6 +1450,71 @@ either way; the stage line is where it shows. Pass `--stage-box <slot>` for such
1449
1450
  build. (`--stage` adds a box only to a skeleton that states none, which is `ingest`'s
1450
1451
  rule.)
1451
1452
 
1453
+ **Keeping the pages — `--keep-pages`** (issue #1339). A player that reads
1454
+ `skeleton.model.json` needs the document for the pages it already ships, not for new
1455
+ ones: a repack's document states the repacked placement, and beside the old pages it
1456
+ describes texels that are not there. `--keep-pages` writes that document and nothing
1457
+ else:
1458
+
1459
+ ```bash
1460
+ bun cli.ts repack spine/ --out spine/ --keep-pages
1461
+ # .. keep --keep-pages: the atlas and its pages are kept as they are and skeleton.model.json is the one file written; profile spine
1462
+ # .. stage 640 x 725 at -0.000016,-25 — read from the skeleton's header box: …
1463
+ # .. check (a) pages: the document states the atlas's 1 page(s) and 10 region(s) as they stand, field for field (pagesOfAtlas of the input atlas) — no page and no atlas is written
1464
+ # .. check (b) skeleton.json: byte-identical to the input's — the document's spine.sha256 names the file on disk
1465
+ # .. check (c) gate: green — the report above, on the build against the atlas as it stands
1466
+ # rigc: wrote /abs/path/spine/skeleton.model.json
1467
+ ```
1468
+
1469
+ The read and the stage are the repack's — the same `ingest`, the same `--stage` and
1470
+ `--stage-box`, the same stage line. In place of the lift and `build --pack` it runs
1471
+ **`build --atlas-in`** over the input atlas (§0.1's *a pack somebody already made*),
1472
+ which resolves every part to a region of that atlas and writes no page; the atlas and
1473
+ its pages are staged as copies in the work directory, so the document's page names
1474
+ are the atlas's own. Before the one write, three things are shown: **(a)** the
1475
+ document's `pages` are the input atlas's pages and regions field for field;
1476
+ **(b)** the rebuilt `skeleton.json` is byte-identical to the input's, so
1477
+ `spine.sha256` names the file on disk — **with no acceptance**: a document whose digest
1478
+ names a skeleton other than the one beside it is exactly what this must not write, so
1479
+ `--accept-skeleton-differences` is refused here, and a build written before 2.2.0
1480
+ needs the full repack, which writes the rebuilt skeleton with its own pages; **(c)**
1481
+ the gate is green.
1482
+
1483
+ - `--out` is usually the build's own directory. It may hold anything **except** a
1484
+ `skeleton.model.json`, which is never written over (exit 2, naming the file): remove
1485
+ it to have it rewritten. The atlas has to sit beside the skeleton, because the
1486
+ document's page names are paths from the directory it sits in.
1487
+ - What the document states is accepted as it stands: a turned region, a trimmed
1488
+ region, a page `scale:`, `pma: true`, `index:` and a name spelled twice — the
1489
+ document has fields for each and the core reads them. Whether the skeleton still
1490
+ rebuilds byte for byte against such an atlas is check (b)'s to say, not a
1491
+ refusal's — and measured, it differs for a trim: `gallery/nod` laid with every
1492
+ region turned 90 is written, its poses equal to the document over its own pack, but
1493
+ laid turned **and trimmed** it is refused by (b) on `skeleton.y` and
1494
+ `skeleton.height` alone, because a trimmed region's quad is its kept rectangle and
1495
+ the setup-pose box in the header shrinks with it (`RPK23`). A line the document has **no field for** — `filter` other than
1496
+ `Linear, Linear` (the core samples every page bilinearly), `format`, `repeat`,
1497
+ `split`/`pad`, any other — is refused naming the page or region, because a player
1498
+ reading only the document would draw without it.
1499
+ - ⚠️ **A texel is not seen.** Nothing in the three files records one — the atlas
1500
+ states rectangles, not contents — so a page edited after its pack is a page the
1501
+ atlas still describes, and the document written beside it is the same bytes
1502
+ (`RPK24`). The document states placement only.
1503
+
1504
+ Measured on `gallery/nod` and `gallery/flex` built `--pack` and reduced to the three
1505
+ kinds of file (`RPK20`, `RPK21`): every input file the same bytes after (sha256), the
1506
+ document the one file added, its pages `pagesOfAtlas` of the atlas on disk,
1507
+ `cli_core.ts` writing the same document byte for byte; posed through the core
1508
+ (`poseRawSetup`, `poseRawAnimation`), every pose text-equal to the one the document
1509
+ `build` wrote gives, and `render --poser core` drawing the same decoded pixels from the
1510
+ kept pages as from the build. Without `--stage-box` the stage is the header's box by
1511
+ the rules above — the document differs from `build`'s there, by design, and in the
1512
+ order `ingest` writes the animations — and neither the poses nor the frames read it;
1513
+ with the stage carried as a box and `--stage-box` given, the stage is the declared one
1514
+ too. The document's `images` section names the atlas's page and region for each part,
1515
+ where the full repack's names the lifted part in a work directory that no longer
1516
+ exists; nothing that poses or draws reads it.
1517
+
1452
1518
  **What each refusal says, and what to change:**
1453
1519
 
1454
1520
  | `rigc repack: …` | exit | change |
@@ -1460,6 +1526,11 @@ rule.)
1460
1526
  | `ingest found N blocker(s) …` / `ingest refused the skeleton: …` | 1 / 2 | the skeleton cannot be read back exactly (§0.3's findings); `--stage` beside a stated box is `ingest`'s refusal |
1461
1527
  | `--out <dir> is not empty …` / `is a file …` | 2 | name a new directory |
1462
1528
  | `repack takes no --<flag>: …` | 2 | drop the flag |
1529
+ | `<atlas> cannot be stated by skeleton.model.json as it stands — N reason(s), and nothing was written:` then one line per reason (`page … states filter: …`, `… a line skeleton.model.json has no field for`, `page … is not on disk`, `page … declares size …`, `region … occupies … which leaves the … page`) | 1 | `--keep-pages`: the atlas states something the document cannot carry; repack without `--keep-pages`, or rebuild from the parts |
1530
+ | `the build against <atlas> as it stands refused: image "…" resolves to region "…", which the atlas at <atlas> does not have …` | 1 | `--keep-pages`: the skeleton draws a region the atlas does not name — the atlas was edited, or is another build's |
1531
+ | `no skeleton.model.json describes these files as they stand, …` then `(b) skeleton.json: …` and the paths | 1 | `--keep-pages`: the skeleton is not what this rigc writes from what it states, so no digest can name it; repack without `--keep-pages` (which writes the rebuild and its pages) |
1532
+ | `--out <dir> already holds skeleton.model.json …` | 2 | `--keep-pages`: remove the document to have it rewritten, or name another `--out` |
1533
+ | `repack --keep-pages takes no --<flag>: …` / `the atlas … is not in the skeleton's directory …` | 2 | drop the flag; keep the atlas beside the skeleton |
1463
1534
 
1464
1535
  A red gate is `build`'s own report and its `rigc: N assertion(s) failed — nothing
1465
1536
  written`, followed by `rigc repack: nothing was written to <out>; the work directory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-c",
3
- "version": "2.37.0",
3
+ "version": "2.38.0",
4
4
  "description": "AI-authored 2D rigging and animation, verified before it is written. rigc compiles a rig spec into skeleton data in the Spine 4.3 format, gates it with named assertions held to a spine-core round trip's verdicts, and emits nothing that fails. Ships as an agent skill.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli/repack.ts CHANGED
@@ -34,6 +34,14 @@
34
34
  * `runBuild` that no `finally` sees, from an `exit` listener. A process killed
35
35
  * by a signal runs neither and leaves its one directory.
36
36
  *
37
+ * `--keep-pages` (issue #1339) is the same read, refusals-first and stage
38
+ * rules included, ending in a different build: `build --atlas-in` over the
39
+ * input atlas, which resolves every part to a region of the pack already on
40
+ * disk and writes no page, and then the document alone (`keptPagesDocument`).
41
+ * A flag rather than a verb, because its flow is this one minus the lift and
42
+ * the pages — a second verb would be a second copy of every refusal above
43
+ * the build, free to drift from this one.
44
+ *
37
45
  * ⚠️ The lifted parts are not kept: the output is the input's shape, and the
38
46
  * parts are recoverable from it at any time by the same lift — keeping a
39
47
  * second copy of every texel beside the pages would be two records of one
@@ -41,9 +49,10 @@
41
49
  */
42
50
  import { parseAtlasText } from '../atlas.ts';
43
51
  import { relativeImagesPath } from '../compile.ts';
52
+ import { CompileError } from '../errors.ts';
44
53
  import { ingest, INGEST_GUTTERS, IngestError, type IngestFinding, type IngestOptions, IngestSpecRefused, type IngestStage } from '../ingest.ts';
45
- import { MODEL_DOCUMENT_FILE } from '../model.ts';
46
- import { atlasRefusals, documentDisagreements, firstLineApart, type InputPage, liftAtlas, polygonOwnedTexels, regionDifferences, REPACK_WORK_PREFIX, RepackError, skeletonDifferences } from '../repack.ts';
54
+ import { MODEL_DOCUMENT_FILE, pagesOfAtlas, spineFileSha256 } from '../model.ts';
55
+ import { atlasRefusals, documentDisagreements, firstLineApart, type InputPage, keptPageRefusals, liftAtlas, polygonOwnedTexels, regionDifferences, REPACK_WORK_PREFIX, RepackError, skeletonDifferences } from '../repack.ts';
47
56
  import {
48
57
  type BuildGate,
49
58
  type BuildReport,
@@ -64,7 +73,7 @@ import {
64
73
  writeBuildReport,
65
74
  } from './shared.ts';
66
75
  import { DEFAULT_PADDING, DEFAULT_PAGE_SIZE } from '../atlas.ts';
67
- import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
76
+ import { constants, copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
68
77
  import { tmpdir } from 'node:os';
69
78
  import { basename, dirname, join, resolve } from 'node:path';
70
79
 
@@ -78,7 +87,14 @@ import { basename, dirname, join, resolve } from 'node:path';
78
87
  */
79
88
  export const ACCEPT_FLAG = 'accept-skeleton-differences';
80
89
 
81
- export const REPACK_FLAGS = ['out', 'atlas', 'page-size', 'padding', 'page-edges', 'pack-shape', 'profile', 'stage', 'stage-box', ACCEPT_FLAG, 'report'] as const;
90
+ /**
91
+ * The switch that writes `skeleton.model.json` alone, for the atlas and pages
92
+ * as they stand (issue #1339): `build --atlas-in` over the input atlas in place
93
+ * of the lift and `build --pack`, nothing written but the document.
94
+ */
95
+ export const KEEP_PAGES_FLAG = 'keep-pages';
96
+
97
+ export const REPACK_FLAGS = ['out', 'atlas', 'page-size', 'padding', 'page-edges', 'pack-shape', 'profile', 'stage', 'stage-box', ACCEPT_FLAG, KEEP_PAGES_FLAG, 'report'] as const;
82
98
 
83
99
  /** `build`'s flags that `repack` does not take, and why — each refused by name rather than ignored. */
84
100
  const BUILD_FLAGS_REFUSED: Readonly<Record<string, string>> = {
@@ -88,7 +104,7 @@ const BUILD_FLAGS_REFUSED: Readonly<Record<string, string>> = {
88
104
  images: 'repack lifts the parts off the pages the atlas names; it takes no parts directory',
89
105
  'copy-images': 'repack always writes self-contained pages into --out, which is what packing is',
90
106
  pack: 'repack always packs; the flag would say nothing',
91
- 'atlas-in': 'repack MAKES a new pack out of the regions of the old one; --atlas-in would keep the old pack — pass the build itself',
107
+ 'atlas-in': `repack MAKES a new pack out of the regions of the old one; --atlas-in would keep the old pack — pass the build itself, and --${KEEP_PAGES_FLAG} to keep its pack`,
92
108
  cut: 'repack takes a build directory, not a cut',
93
109
  cuts: 'repack takes a build directory, not a cuts table',
94
110
  };
@@ -244,27 +260,87 @@ function pagesLine(inputAtlas: string, inputPages: readonly InputPage[], outAtla
244
260
  );
245
261
  }
246
262
 
263
+ /**
264
+ * `--keep-pages`'s flags beside the ones it makes meaningless — each refused
265
+ * by name rather than ignored (issue #1339).
266
+ */
267
+ const KEEP_PAGES_REFUSED: Readonly<Record<string, string>> = {
268
+ 'page-size': 'nothing is packed, so a page size says nothing',
269
+ padding: 'nothing is packed, so a padding says nothing',
270
+ 'page-edges': 'nothing is packed, so the page edges say nothing',
271
+ 'pack-shape': 'nothing is packed, so the pack shape says nothing',
272
+ [ACCEPT_FLAG]:
273
+ `a document whose spine.sha256 names a skeleton other than the skeleton.json on disk is exactly what --${KEEP_PAGES_FLAG} must not write, and --${KEEP_PAGES_FLAG} writes no skeleton — ` +
274
+ 'repack without it writes the rebuild, its atlas and its pages together',
275
+ };
276
+
277
+ /** Every flag given that `--keep-pages` makes meaningless, refused by name. */
278
+ function refuseKeepPagesConflicts(flags: Record<string, string>): void {
279
+ for (const name of Object.keys(KEEP_PAGES_REFUSED).sort()) {
280
+ if (flags[name] !== undefined) throw new UsageError(`repack --${KEEP_PAGES_FLAG} takes no --${name}: ${KEEP_PAGES_REFUSED[name]}`);
281
+ }
282
+ }
283
+
284
+ /**
285
+ * `--out` under `--keep-pages`: required, a directory or absent, and holding
286
+ * no `skeleton.model.json` — the one file the command writes is never written
287
+ * over (issue #1339). Any other file may be there: the input's own directory
288
+ * is the usual `--out`, since the document belongs beside the pair and pages
289
+ * it states.
290
+ */
291
+ function readKeptOut(flags: Record<string, string>): string {
292
+ if (flags.out === undefined) throw new UsageError(`repack --${KEEP_PAGES_FLAG} needs --out <dir> — the directory ${MODEL_DOCUMENT_FILE} is written into (the build's own directory, to sit beside the pages it states)`);
293
+ const out = resolve(flags.out);
294
+ if (existsSync(out)) {
295
+ if (!statSync(out).isDirectory()) throw new RepackError(`--out ${out} is a file; it takes a directory — nothing was written`, 2);
296
+ const held = join(out, MODEL_DOCUMENT_FILE);
297
+ if (existsSync(held)) {
298
+ throw new RepackError(
299
+ `--out ${out} already holds ${MODEL_DOCUMENT_FILE} — --${KEEP_PAGES_FLAG} writes that file and nothing else, and never over one: ` +
300
+ 'a document already there is a record somebody kept, and which of the two describes the pages is not this command\'s to decide. ' +
301
+ `Remove ${held} first to have it rewritten, or name another --out; nothing was written`,
302
+ 2,
303
+ );
304
+ }
305
+ }
306
+ return out;
307
+ }
308
+
309
+ /** The name the input atlas is staged under in the work directory: not `skeleton.atlas`, which the build writes beside it. */
310
+ const KEPT_ATLAS = 'kept.atlas';
311
+
247
312
  /**
248
313
  * repack — the command body both entries register, with the entry's own gate
249
314
  * (`build`'s). `plant` is the selftest's (`RepackPlant`).
250
315
  */
251
316
  export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, plant?: RepackPlant): void {
252
317
  refuseForeignFlags(flags);
318
+ const keeping = flags[KEEP_PAGES_FLAG] !== undefined;
319
+ if (keeping) refuseKeepPagesConflicts(flags);
253
320
  if (positional.length !== 1) throw new UsageError(`repack takes one path — the build directory, or its skeleton.json — and was given ${positional.length}`);
254
321
  // Every flag read before anything is: a typo is a usage error, never a default.
255
- const packing: Record<string, string> = {
256
- 'page-size': String(readIntFlag(flags, 'page-size', DEFAULT_PAGE_SIZE)),
257
- padding: String(readIntFlag(flags, 'padding', DEFAULT_PADDING)),
258
- 'page-edges': readPageEdges(flags),
259
- 'pack-shape': readPackShape(flags),
260
- profile: readProfile(flags),
261
- };
322
+ const packing: Record<string, string> = keeping
323
+ ? { profile: readProfile(flags) }
324
+ : {
325
+ 'page-size': String(readIntFlag(flags, 'page-size', DEFAULT_PAGE_SIZE)),
326
+ padding: String(readIntFlag(flags, 'padding', DEFAULT_PADDING)),
327
+ 'page-edges': readPageEdges(flags),
328
+ 'pack-shape': readPackShape(flags),
329
+ profile: readProfile(flags),
330
+ };
262
331
  const stage = readStageFlag(flags.stage);
263
- const out = readOut(flags);
332
+ const out = keeping ? readKeptOut(flags) : readOut(flags);
264
333
  // `--report` (issue #1213): refused inside --out, written on a red gate by the build body and here once --out is written.
265
334
  const record = readReportFlag(flags, 'repack', out, gate.supplier);
266
335
  const input = resolveBuild(positional[0], flags.atlas);
267
336
  if (input.atlas !== 'there') throw new UsageError(input.atlasRefusal);
337
+ const atlasDir = dirname(input.atlasPath);
338
+ if (keeping && resolve(atlasDir) !== resolve(dirname(input.skeletonPath))) {
339
+ throw new UsageError(
340
+ `repack --${KEEP_PAGES_FLAG}: the atlas ${input.atlasPath} is not in the skeleton's directory ${dirname(input.skeletonPath)} — ` +
341
+ `${MODEL_DOCUMENT_FILE} sits beside skeleton.json and states the atlas's page names as paths from there, so beside this skeleton they would name pages that are not there`,
342
+ );
343
+ }
268
344
  const skeletonText = readSkeletonText(input.skeletonPath);
269
345
  const atlasText = readFileSync(input.atlasPath, 'utf8');
270
346
  const parsed = parseAtlasText(atlasText);
@@ -272,10 +348,15 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
272
348
  console.log(`rigc repack ${input.skeletonPath}`);
273
349
  console.log(` .. atlas ${input.atlasPath}`);
274
350
  console.log(` .. out ${out}`);
275
- console.log(` .. pack page-size ${packing['page-size']}, padding ${packing.padding}, page-edges ${packing['page-edges']}, pack-shape ${packing['pack-shape']}, profile ${packing.profile}`);
351
+ console.log(
352
+ keeping
353
+ ? ` .. keep --${KEEP_PAGES_FLAG}: the atlas and its pages are kept as they are and ${MODEL_DOCUMENT_FILE} is the one file written; profile ${packing.profile}`
354
+ : ` .. pack page-size ${packing['page-size']}, padding ${packing.padding}, page-edges ${packing['page-edges']}, pack-shape ${packing['pack-shape']}, profile ${packing.profile}`,
355
+ );
276
356
 
277
- // What the atlas cannot carry through a repack, all of it, before anything is made.
278
- const { refusals, pages } = atlasRefusals(parsed, dirname(input.atlasPath));
357
+ // What the atlas cannot carry — through a repack, or into the document as it stands — all of it, before anything is made.
358
+ const lifting = keeping ? null : atlasRefusals(parsed, atlasDir);
359
+ const refusals = lifting === null ? keptPageRefusals(parsed, atlasDir) : lifting.refusals;
279
360
  const modelText = modelTextBeside(input.skeletonPath, skeletonText);
280
361
  const disagreement = modelText === undefined ? null : documentDisagreements((parseJsonNamed(modelText, join(dirname(input.skeletonPath), MODEL_DOCUMENT_FILE)) as { pages?: unknown }).pages, parsed);
281
362
  if (disagreement !== null) {
@@ -287,7 +368,7 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
287
368
  }
288
369
  if (refusals.length > 0) {
289
370
  throw new RepackError(
290
- `${input.atlasPath} cannot be lifted exactly — ${refusals.length} reason(s), and nothing was written:\n${refusals.map((r) => ` ${r}`).join('\n')}`,
371
+ `${input.atlasPath} ${keeping ? `cannot be stated by ${MODEL_DOCUMENT_FILE} as it stands` : 'cannot be lifted exactly'} — ${refusals.length} reason(s), and nothing was written:\n${refusals.map((r) => ` ${r}`).join('\n')}`,
291
372
  );
292
373
  }
293
374
  console.log(
@@ -312,12 +393,15 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
312
393
  const liftDir = join(work, 'lift');
313
394
  const specsDir = join(work, 'specs');
314
395
  const buildDir = join(work, 'build');
315
- const lifted = liftAtlas(pages, liftDir);
316
- console.log(
317
- ` .. lift ${lifted.parts.size} region(s) off ${pages.length} page(s), each named once: ${lifted.turned} turned on its page, ${lifted.trimmed} trimmed of whitespace — ` +
318
- 'each lifted as the drawing it is (extractRegion)',
319
- );
320
- if (plant !== undefined) plant(liftDir);
396
+ // Under --keep-pages nothing is lifted: the build resolves every part against the input atlas (`--atlas-in`), which reads no loose file.
397
+ const lifted = lifting === null ? null : liftAtlas(lifting.pages, liftDir);
398
+ if (lifted !== null && lifting !== null) {
399
+ console.log(
400
+ ` .. lift ${lifted.parts.size} region(s) off ${lifting.pages.length} page(s), each named once: ${lifted.turned} turned on its page, ${lifted.trimmed} trimmed of whitespace — ` +
401
+ 'each lifted as the drawing it is (extractRegion)',
402
+ );
403
+ if (plant !== undefined) plant(liftDir);
404
+ }
321
405
 
322
406
  let result: { rig: unknown; motion: unknown; findings: IngestFinding[] };
323
407
  try {
@@ -342,6 +426,11 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
342
426
  writeFileSync(rigPath, `${JSON.stringify(result.rig, null, 2)}\n`);
343
427
  writeFileSync(motionPath, `${JSON.stringify(result.motion, null, 2)}\n`);
344
428
 
429
+ if (lifted === null || lifting === null) {
430
+ keptPagesDocument({ flags, gate, record, input, skeletonText, atlasText, parsed, out, rigPath, motionPath, buildDir, profile: packing.profile });
431
+ return;
432
+ }
433
+
345
434
  // (c) `build --pack` through the entry's own gate. It returns only green; a red gate exits from inside it.
346
435
  stagedBuild({ rig: rigPath, motion: motionPath, out: buildDir, pack: 'true', ...packing }, gate, record);
347
436
 
@@ -373,10 +462,7 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
373
462
  } else {
374
463
  // Accepted, every path is printed: an accepted difference nobody is shown is the silence the check exists to remove.
375
464
  const diff = skeletonDifferences(parseJsonNamed(skeletonText, input.skeletonPath), parseJsonNamed(outSkeleton, join(buildDir, 'skeleton.json')), accepting ? Infinity : SKELETON_DIFFERENCES_SHOWN);
376
- const head =
377
- diff.total === 0
378
- ? `skeleton.json: the rebuild states the same values in other bytes — ${firstLineApart(skeletonText, outSkeleton)}`
379
- : `skeleton.json: ${diff.total} place(s) differ from the input`;
465
+ const head = skeletonHead(diff.total, skeletonText, outSkeleton);
380
466
  if (accepting) {
381
467
  console.log(` .. check (b) ${head}, accepted by --${ACCEPT_FLAG} — the output's skeleton is this rigc's rebuild, not the input's bytes:`);
382
468
  for (const line of diff.lines) console.log(` .. ${line}`);
@@ -398,7 +484,7 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
398
484
  const staged = readdirSync(buildDir).sort();
399
485
  const expected = [...BUILD_TEXTS, ...outPages].sort();
400
486
  if (staged.join('\n') !== expected.join('\n')) throw new Error(`internal: the staged build holds [${staged.join(', ')}], not [${expected.join(', ')}]`);
401
- console.log(pagesLine(atlasText, pages, outAtlas, buildDir, outPages));
487
+ console.log(pagesLine(atlasText, lifting.pages, outAtlas, buildDir, outPages));
402
488
 
403
489
  mkdirSync(out, { recursive: true });
404
490
  for (const name of [...outPages, ...BUILD_TEXTS]) {
@@ -412,3 +498,109 @@ export function cmdRepack({ flags, positional }: CommandArgs, gate: BuildGate, p
412
498
  process.off('exit', onExit);
413
499
  }
414
500
  }
501
+
502
+ /** Check (b)'s head: how many places differ, or — values equal, bytes not — the first line apart. */
503
+ function skeletonHead(total: number, skeletonText: string, outSkeleton: string): string {
504
+ return total === 0
505
+ ? `skeleton.json: the rebuild states the same values in other bytes — ${firstLineApart(skeletonText, outSkeleton)}`
506
+ : `skeleton.json: ${total} place(s) differ from the input`;
507
+ }
508
+
509
+ /**
510
+ * `--keep-pages`' tail (issue #1339): `build --atlas-in` over the input atlas
511
+ * — the build that resolves every part against a pack somebody already made
512
+ * and writes no page — then the two checks that say the document it spelled
513
+ * describes the files on disk, then the one write.
514
+ *
515
+ * The input atlas and its pages are staged as copies in the build's own
516
+ * directory, so `--atlas-in`'s re-anchored page names (`relative(outDir, …)`)
517
+ * are the atlas's own spellings and the document's `pages` names what sits
518
+ * beside the input skeleton. Nothing under the input is opened for writing.
519
+ *
520
+ * (a) the document's `pages` are `pagesOfAtlas` of the input atlas text,
521
+ * field for field — what `build` would have stated had it written this
522
+ * atlas itself;
523
+ * (b) the rebuilt `skeleton.json` is byte-identical to the input's, so the
524
+ * document's `spine.sha256` names the file it will sit beside. There is
525
+ * no acceptance here: a digest of a skeleton that is not on disk is the
526
+ * document the command exists not to write;
527
+ * (c) the gate is green — `runBuild` returns only then.
528
+ */
529
+ function keptPagesDocument(c: {
530
+ flags: Record<string, string>;
531
+ gate: BuildGate;
532
+ record: BuildReport | null;
533
+ input: { skeletonPath: string; atlasPath: string };
534
+ skeletonText: string;
535
+ atlasText: string;
536
+ parsed: ReturnType<typeof parseAtlasText>;
537
+ out: string;
538
+ rigPath: string;
539
+ motionPath: string;
540
+ buildDir: string;
541
+ profile: string;
542
+ }): void {
543
+ const atlasDir = dirname(c.input.atlasPath);
544
+ mkdirSync(c.buildDir, { recursive: true });
545
+ const keptAtlas = join(c.buildDir, KEPT_ATLAS);
546
+ writeFileSync(keptAtlas, c.atlasText);
547
+ for (const page of c.parsed.pages) {
548
+ const to = join(c.buildDir, page.name);
549
+ mkdirSync(dirname(to), { recursive: true });
550
+ copyFileSync(resolve(atlasDir, page.name), to);
551
+ }
552
+
553
+ // (c) `build --atlas-in` through the entry's own gate. It returns only green; a red gate exits from inside it.
554
+ // A compile refusal names the staged copy of the atlas, so it is restated naming the input's own.
555
+ try {
556
+ stagedBuild({ rig: c.rigPath, motion: c.motionPath, out: c.buildDir, 'atlas-in': keptAtlas, profile: c.profile }, c.gate, c.record);
557
+ } catch (err) {
558
+ if (!(err instanceof CompileError)) throw err;
559
+ throw new RepackError(`the build against ${c.input.atlasPath} as it stands refused: ${err.message.split(keptAtlas).join(c.input.atlasPath)} — nothing was written`);
560
+ }
561
+
562
+ const lost: string[] = [];
563
+ const documentText = readFileSync(join(c.buildDir, MODEL_DOCUMENT_FILE), 'utf8');
564
+ const doc = parseJsonNamed(documentText, join(c.buildDir, MODEL_DOCUMENT_FILE)) as { pages?: unknown; spine?: { sha256?: unknown } };
565
+ const stated = skeletonDifferences(pagesOfAtlas(c.atlasText), doc.pages, SKELETON_DIFFERENCES_SHOWN);
566
+ const regionCount = c.parsed.pages.reduce((n, p) => n + p.regions.length, 0);
567
+ if (stated.total > 0) {
568
+ lost.push(
569
+ `(a) pages: ${stated.total} place(s) where the document would not state the atlas as it stands${stated.total > stated.lines.length ? ` (the first ${stated.lines.length})` : ''} — "the input" is the atlas read, "the rebuild" the document:`,
570
+ ...stated.lines.map((d) => ` pages${d.startsWith('[') ? '' : '.'}${d}`),
571
+ );
572
+ } else {
573
+ console.log(
574
+ ` .. check (a) pages: the document states the atlas's ${c.parsed.pages.length} page(s) and ${regionCount} region(s) as they stand, field for field (pagesOfAtlas of the input atlas) — ` +
575
+ 'no page and no atlas is written',
576
+ );
577
+ }
578
+ const outSkeleton = readFileSync(join(c.buildDir, 'skeleton.json'), 'utf8');
579
+ if (outSkeleton === c.skeletonText) {
580
+ console.log(" .. check (b) skeleton.json: byte-identical to the input's — the document's spine.sha256 names the file on disk");
581
+ } else {
582
+ const diff = skeletonDifferences(parseJsonNamed(c.skeletonText, c.input.skeletonPath), parseJsonNamed(outSkeleton, join(c.buildDir, 'skeleton.json')), SKELETON_DIFFERENCES_SHOWN);
583
+ lost.push(
584
+ `(b) ${skeletonHead(diff.total, c.skeletonText, outSkeleton)}${diff.total > diff.lines.length ? ` (the first ${diff.lines.length})` : ''}:`,
585
+ ...diff.lines.map((d) => ` ${d}`),
586
+ ` the document's spine.sha256 would name this rebuild, not the skeleton.json beside it — the one thing --${KEEP_PAGES_FLAG} must not write, so it takes no --${ACCEPT_FLAG}. ` +
587
+ 'repack without it writes the rebuild together with its own atlas and pages, every difference listed under that flag; a build written before 2.2.0, whose header was the stage, differs here in its header box and nowhere else',
588
+ );
589
+ }
590
+ if (lost.length > 0) throw new RepackError(`no ${MODEL_DOCUMENT_FILE} describes these files as they stand, so nothing was written to ${c.out}:\n${lost.map((l) => ` ${l}`).join('\n')}`);
591
+ if (doc.spine?.sha256 !== spineFileSha256(c.skeletonText)) throw new Error(`internal: the staged ${MODEL_DOCUMENT_FILE}'s spine.sha256 is not the digest of the skeleton.json it was built from`);
592
+ console.log(' .. check (c) gate: green — the report above, on the build against the atlas as it stands');
593
+
594
+ mkdirSync(c.out, { recursive: true });
595
+ // `readKeptOut` refused an existing document; one appearing since is refused here rather than written over.
596
+ copyFileSync(join(c.buildDir, MODEL_DOCUMENT_FILE), join(c.out, MODEL_DOCUMENT_FILE), constants.COPYFILE_EXCL);
597
+ console.log(`rigc: wrote ${join(c.out, MODEL_DOCUMENT_FILE)}`);
598
+ if (c.record !== null) writeBuildReport(c.record);
599
+ if (resolve(c.out) === resolve(dirname(c.input.skeletonPath))) console.log(c.gate.look(c.out));
600
+ else {
601
+ console.log(
602
+ `rigc: ${MODEL_DOCUMENT_FILE} names the atlas's pages as paths from ${dirname(c.input.skeletonPath)} and the digest of the skeleton.json there; ` +
603
+ 'it is read beside those files',
604
+ );
605
+ }
606
+ }
package/src/cli/shared.ts CHANGED
@@ -125,7 +125,7 @@ export { PACKAGE_ROOT, readPackageMeta, readVersion };
125
125
  * needs a value` (issue #328). `CLI10`/`CLI11` in `selftest.ts` now hold the two
126
126
  * halves together by reading `--help` rather than by naming a flag.
127
127
  */
128
- const BOOLEAN_FLAGS = new Set(['all-frames', 'all-bones', 'help', 'copy-images', 'again', 'pack', 'copy', 'geometry', 'accept-skeleton-differences']);
128
+ const BOOLEAN_FLAGS = new Set(['all-frames', 'all-bones', 'help', 'copy-images', 'again', 'pack', 'copy', 'geometry', 'accept-skeleton-differences', 'keep-pages']);
129
129
 
130
130
  /**
131
131
  * The flags a command is allowed to spell more than once.
@@ -1092,6 +1092,13 @@ const FLAG_MEANINGS: Record<string, string> = {
1092
1092
  'with both values (default: refused naming them). It says only where the two differ, never why — a build written ' +
1093
1093
  'before 2.2.0, whose header box was the stage, differs in those four fields and nowhere else. Region identity and ' +
1094
1094
  'the gate hold exactly as without it; beside an input that needs none, the check line says it accepted nothing',
1095
+ 'keep-pages':
1096
+ 'write skeleton.model.json alone, for the atlas and pages as they stand: nothing is lifted or packed, the build ' +
1097
+ 'resolves every part against the input atlas (build --atlas-in) and the document states that atlas\'s pages and ' +
1098
+ 'regions field for field, its spine.sha256 the skeleton.json beside them. Written only when the rebuilt skeleton is ' +
1099
+ 'byte-identical to the input\'s and the gate is green; --out may be the build\'s own directory and must not already ' +
1100
+ 'hold skeleton.model.json (refused by name, never written over). A page or region line the document has no field ' +
1101
+ 'for is refused naming it. Takes none of the packing flags, nor --accept-skeleton-differences',
1095
1102
  'stage-box':
1096
1103
  'the slot whose bounding box carries the stage — what `build` writes for a rig that asks for one ' +
1097
1104
  '(`skeleton.stageBox`). Its four corners are read as the rebuild\'s stage in place of the header\'s box, which ' +
@@ -1308,6 +1315,7 @@ export const COMMANDS: CommandDoc[] = [
1308
1315
  core: {
1309
1316
  usage: [
1310
1317
  `rigc repack <dir | skeleton.json> --out <dir> [--atlas <path>] [--page-size ${DEFAULT_PAGE_SIZE}] [--padding ${DEFAULT_PADDING}] [--page-edges pot|free] [--pack-shape rect|polygon] [--profile spine|spine-html] [--stage x,y,w,h] [--stage-box <slot>] [--accept-skeleton-differences] [--report <file>] (gated without spine-core — see repack --help)`,
1318
+ `rigc repack <dir | skeleton.json> --out <dir> --keep-pages [--atlas <path>] [--profile spine|spine-html] [--stage x,y,w,h] [--stage-box <slot>] [--report <file>] (skeleton.model.json alone, pages kept)`,
1311
1319
  ],
1312
1320
  notes: [
1313
1321
  'a packed build repacked from its own output — skeleton.json, skeleton.atlas and the',
@@ -1322,15 +1330,17 @@ export const COMMANDS: CommandDoc[] = [
1322
1330
  'here: the model side over the document and the round trip\'s own rules restated over',
1323
1331
  'the emitted text, A00_ROUNDTRIP_PARSE a SKIP naming spine-core. An atlas the lift',
1324
1332
  'cannot read exactly is refused by name before anything is made: docs/AUTHORING.md',
1325
- '§0.4 lists what is accepted and what is refused, and why.',
1333
+ '§0.4 lists what is accepted and what is refused, and why. --keep-pages writes',
1334
+ 'skeleton.model.json alone, for the atlas and pages as they stand (see repack --help).',
1326
1335
  ],
1327
1336
  },
1328
1337
  },
1329
1338
  spineFormat: true,
1330
1339
  usage: [
1331
1340
  `rigc repack <dir | skeleton.json> --out <dir> [--atlas <path>] [--page-size ${DEFAULT_PAGE_SIZE}] [--padding ${DEFAULT_PADDING}] [--page-edges pot|free] [--pack-shape rect|polygon] [--profile spine|spine-html] [--stage x,y,w,h] [--stage-box <slot>] [--accept-skeleton-differences] [--report <file>]`,
1341
+ `rigc repack <dir | skeleton.json> --out <dir> --keep-pages [--atlas <path>] [--profile spine|spine-html] [--stage x,y,w,h] [--stage-box <slot>] [--report <file>] (skeleton.model.json alone, pages kept)`,
1332
1342
  ],
1333
- flags: ['out', 'atlas', 'page-size', 'padding', 'page-edges', 'pack-shape', 'profile', 'stage', 'stage-box', 'accept-skeleton-differences', 'report'],
1343
+ flags: ['out', 'atlas', 'page-size', 'padding', 'page-edges', 'pack-shape', 'profile', 'stage', 'stage-box', 'accept-skeleton-differences', 'keep-pages', 'report'],
1334
1344
  overrides: {
1335
1345
  out: {
1336
1346
  value: '<dir>',
@@ -1360,6 +1370,15 @@ export const COMMANDS: CommandDoc[] = [
1360
1370
  'lists what is accepted and what is refused, and why. The stage line says which stage the',
1361
1371
  'rebuild declared and where it was read (--stage, the skeleton.model.json beside the',
1362
1372
  'pair, or the header\'s box).',
1373
+ '--keep-pages writes skeleton.model.json alone, for the atlas and pages as they stand (a',
1374
+ 'player that reads the document beside pages already shipped): the same read, the same',
1375
+ 'ingest and stage rules, then build --atlas-in over the input atlas, which writes no page.',
1376
+ '(a) the document states the atlas\'s pages and regions field for field; (b) the rebuilt',
1377
+ 'skeleton.json is byte-identical to the input\'s, so spine.sha256 names the file on disk',
1378
+ '(no acceptance: a digest of another skeleton is the document it must not write); (c) the',
1379
+ 'gate is green. A turned, trimmed, scaled or premultiplied page is stated as it is; a line',
1380
+ 'the document has no field for is refused by name. Nothing in the three files records a',
1381
+ 'texel, so a page edited after its pack is not seen: the document states placement only.',
1363
1382
  ],
1364
1383
  },
1365
1384
  {
package/src/repack.ts CHANGED
@@ -40,6 +40,10 @@
40
40
  * PNG is missing or not the size the atlas declares, would be lifted from
41
41
  * texels the atlas does not describe.
42
42
  *
43
+ * `repack --keep-pages` (issue #1339) asks another question of the same
44
+ * atlas — not "can it be repacked?" but "can the model document state it as
45
+ * it stands?" — and `keptPageRefusals` is its list.
46
+ *
43
47
  * 🔒 Every refusal is collected before the first file is written, and the
44
48
  * command writes nothing when there is one. Nothing here guesses: there is no
45
49
  * "close enough" cut.
@@ -49,8 +53,10 @@
49
53
  */
50
54
  import { type AtlasPage, type AtlasRegion, extractRegion, footprintCell, packFootprints, pageFootprint, type ParsedAtlas, readEntry } from './atlas.ts';
51
55
  import { Plate, readPlate } from '../tools/plate.ts';
56
+ import { MODEL_DOCUMENT_FILE } from './model.ts';
57
+ import { readPngHeader } from './png.ts';
52
58
  import { existsSync, mkdirSync } from 'node:fs';
53
- import { dirname, join, resolve } from 'node:path';
59
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
54
60
 
55
61
  /**
56
62
  * A repack refused: an input it cannot lift exactly, a repack that lost
@@ -260,6 +266,99 @@ export function atlasRefusals(parsed: ParsedAtlas, atlasDir: string): { refusals
260
266
  return { refusals, pages };
261
267
  }
262
268
 
269
+ /**
270
+ * The page lines `skeleton.model.json` states (issue #1339): `size` as the
271
+ * page's `width`/`height`, `pma`, and `scale` as the number written
272
+ * (`pagesOfAtlas`). `filter: Linear, Linear` is the one sampling the document
273
+ * implies by leaving filters out — the core's draw is bilinear on every path
274
+ * (`src/render.ts`'s header) — so a page stating it states nothing the document
275
+ * drops.
276
+ */
277
+ const PAGE_FIELDS_STATED = new Set(['size', 'pma', 'scale']);
278
+
279
+ /** The region lines the document states: placement, the drawing's own size and turn, and `index`. */
280
+ const REGION_FIELDS_STATED = new Set([...REGION_PLACEMENT_KEYS, 'index']);
281
+
282
+ /**
283
+ * Every reason a model document cannot be written for this atlas AS IT STANDS
284
+ * — `repack --keep-pages`, issue #1339 — in file order, empty when it can be.
285
+ *
286
+ * The question is not `atlasRefusals`' (can it be lifted and repacked?) but
287
+ * whether the document's `pages` section can say everything the atlas says.
288
+ * So a turned region, a trimmed region, a page `scale:`, `pma: true`, an
289
+ * `index:` and a name the atlas spells twice are not refused here — the
290
+ * document states each of them (`ModelPage`, `ModelPageRegion`) and the core
291
+ * reads them (`./core/uvs.ts`); whether the skeleton still rebuilds byte for
292
+ * byte against them is the command's check (b), not a guess made here. Every
293
+ * line the document has no field for is refused naming its page or region: a
294
+ * player reading only the document would draw without it. The page PNGs are
295
+ * checked as `atlasRefusals` checks them — on disk, the size the atlas
296
+ * declares, every rectangle on its page — because the document is written to
297
+ * sit beside them; and a page name that is not a relative path below the
298
+ * atlas's directory is refused, because the document's page names are paths
299
+ * from the directory it sits in.
300
+ *
301
+ * ⚠️ What no refusal here can see is a texel. Nothing in the three files
302
+ * records one — the atlas states rectangles, not contents — so a page edited
303
+ * after it was packed is a page the atlas still describes, and the document
304
+ * written beside it is the same bytes. That is a limit of the inputs, stated
305
+ * rather than papered over.
306
+ */
307
+ export function keptPageRefusals(parsed: ParsedAtlas, atlasDir: string): string[] {
308
+ const refusals: string[] = [];
309
+ if (parsed.regions.length === 0) refusals.push('the atlas names no region, so the document would state no placement');
310
+ for (const { page, fields, regions } of atlasFields(parsed)) {
311
+ const segments = page.name.split('/');
312
+ if (page.name.includes('\\') || isAbsolute(page.name) || segments.some((s) => s === '' || s === '.' || s === '..')) {
313
+ refusals.push(
314
+ `page "${page.name}" is not a relative path below the atlas's directory (an empty, "." or ".." segment, a leading "/" or a "\\"), ` +
315
+ `and ${MODEL_DOCUMENT_FILE}'s page names are paths from the directory it sits in`,
316
+ );
317
+ } else {
318
+ const path = resolve(atlasDir, page.name);
319
+ if (!existsSync(path)) refusals.push(`page "${page.name}" is not on disk: nothing at ${path}`);
320
+ else {
321
+ const header = readPngHeader(path);
322
+ if (header.info === null) refusals.push(`page "${page.name}" cannot be read as PNG: ${header.problem}`);
323
+ else if (header.info.width !== page.width || header.info.height !== page.height) {
324
+ refusals.push(
325
+ `page "${page.name}" declares size ${page.width}x${page.height} and ${path} is ${header.info.width}x${header.info.height} — ` +
326
+ 'the document would state the declared grid beside a page that is not on it',
327
+ );
328
+ }
329
+ }
330
+ }
331
+ for (const entry of fields) {
332
+ const value = entry.values.join(', ');
333
+ if (PAGE_FIELDS_STATED.has(entry.key) || (entry.key === 'filter' && value === PAGE_FIELDS_WRITTEN.filter)) continue;
334
+ refusals.push(
335
+ entry.key === 'filter'
336
+ ? `page "${page.name}" states filter: ${value} — ${MODEL_DOCUMENT_FILE} states no filter and the core samples every page bilinearly (filter: ${PAGE_FIELDS_WRITTEN.filter}), so a player reading the document would draw this page otherwise than the atlas asks`
337
+ : `page "${page.name}" states ${entry.key}: ${value}, a line ${MODEL_DOCUMENT_FILE} has no field for — a player reading only the document would draw without it`,
338
+ );
339
+ }
340
+ regions.forEach(({ raw, fields: regionFields }, k) => {
341
+ const name = raw.trim();
342
+ for (const entry of regionFields) {
343
+ if (entry.key === 'rotate') {
344
+ if (!ROTATE_VALUES.has(entry.values[0] ?? '')) {
345
+ refusals.push(`region "${name}" on page "${page.name}" states rotate: ${entry.values.join(', ')}, which is not one of true, false, 0, 90, 180, 270 — the turns the document's degrees can state`);
346
+ }
347
+ continue;
348
+ }
349
+ if (REGION_FIELDS_STATED.has(entry.key)) continue;
350
+ refusals.push(
351
+ `region "${name}" on page "${page.name}" states ${entry.key}: ${entry.values.join(', ')}, a line ${MODEL_DOCUMENT_FILE} has no field for` +
352
+ `${entry.key === 'split' || entry.key === 'pad' ? ' (a nine-patch region)' : ''} — a player reading only the document would draw without it`,
353
+ );
354
+ }
355
+ const geometry = geometryRefusal(page, page.regions[k]);
356
+ if (geometry !== null) refusals.push(geometry);
357
+ });
358
+ }
359
+ return refusals;
360
+ }
361
+
263
362
  /** Every region the atlas names, lifted, in file order, by its (trimmed) name. */
264
363
  export interface Lift {
265
364
  parts: Map<string, Plate>;