@rig-c/core 2.68.0 → 2.69.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
@@ -186,6 +186,16 @@ of them: it reads whatever frames you point it at, so it runs from the installed
186
186
  package on pictures of your own — which is what *Where to go next* below tells you
187
187
  to do with it, and it is the one instrument here that can see a wrong animation.
188
188
 
189
+ Programmatic checked consumers can import `rig-c/render-shared`: the official
190
+ candidate chooser (`loadCandidate`, `throughPoser`), setup and animation samplers
191
+ (`sampleSetupPose`, `sampleAnimation`) and raster reads (`pageFor`, `projector`,
192
+ `rasterisePiece`, `renderFrame`), with their argument/result types and named
193
+ failures. It loads without the optional Spine runtime; a Spine input requires
194
+ explicitly loading `rig-c/render`, whose eager runtime dependency is unchanged.
195
+ The promised scope and planned first minor release are in
196
+ [RELEASING.md, The import surface](https://github.com/rig-c/core/blob/main/RELEASING.md#the-import-surface);
197
+ [AUTHORING §0.5](docs/AUTHORING.md#05-reading-a-build-from-code) shows the call chain.
198
+
189
199
  ### Install it into your agent
190
200
 
191
201
  The guides under [Documentation](#documentation) also ship as
package/docs/AUTHORING.md CHANGED
@@ -1617,6 +1617,68 @@ written`, followed by `rigc repack: nothing was written to <out>; the work direc
1617
1617
 
1618
1618
  ---
1619
1619
 
1620
+ ### 0.5 Reading a build from code
1621
+
1622
+ The named `rig-c/render-shared` entry promises the official renderer reads for
1623
+ checked consumers (issue #1561). It is planned for the next minor, 2.69.0; wait
1624
+ for the measured release before using `>=2.69.0 <3.0.0`. It requires Bun and the
1625
+ candidate's real files, but imports no optional Spine runtime. The existing
1626
+ `rig-c/render` entry still eagerly imports that runtime.
1627
+
1628
+ ```ts
1629
+ import { readFileSync } from 'node:fs';
1630
+ import { join } from 'node:path';
1631
+ import {
1632
+ loadCandidate, throughPoser, sampleSetupPose, sampleAnimation,
1633
+ pageFor, projector, rasterisePiece, renderFrame,
1634
+ type Viewport,
1635
+ } from 'rig-c/render-shared';
1636
+
1637
+ const dir = 'build';
1638
+ const skeleton = join(dir, 'skeleton.json');
1639
+ const atlas = join(dir, 'skeleton.atlas');
1640
+ const candidate = loadCandidate({
1641
+ skeletonText: readFileSync(skeleton, 'utf8'),
1642
+ atlasText: readFileSync(atlas, 'utf8'),
1643
+ atlasDir: dir, label: skeleton,
1644
+ }, { skeleton, atlas }, undefined);
1645
+ const read = throughPoser(candidate.choice, (poser, roster) => ({
1646
+ setup: sampleSetupPose(poser, { bones: true, geometry: true })[0],
1647
+ frames: sampleAnimation(poser, 'wave', 12),
1648
+ skins: roster.skins,
1649
+ }));
1650
+ // The consumer supplies the world box and pixel grid it intends to measure.
1651
+ const viewport: Viewport = {
1652
+ minX: 0, minY: 0, maxX: 256, maxY: 256,
1653
+ scale: 1, width: 256, height: 256,
1654
+ };
1655
+ const project = projector(viewport);
1656
+ for (const piece of read.value.setup.pieces) {
1657
+ rasterisePiece(pageFor(candidate.pages, piece), piece, project, viewport,
1658
+ (x, y, r, g, b, a) => { /* read each covered sample */ });
1659
+ }
1660
+ const image = renderFrame(read.value.setup, candidate.pages, viewport, [0, 0, 0, 0]);
1661
+ ```
1662
+
1663
+ The animation name and viewport above belong to the consumer; the loader does
1664
+ not invent them. The chooser checks the model document beside the skeleton,
1665
+ its `spine.sha256`, atlas placement, page files and bone/slot/animation rosters.
1666
+ A /3 document can be loaded with `atlasText: null` when its atlas is absent.
1667
+ `throughPoser` returns `poser` and `note` with its value. Keep its callback free
1668
+ of writes: an explicitly registered runtime fallback can rerun it.
1669
+
1670
+ The entry also exports the original `CandidateAtlasError` (missing required
1671
+ atlas), `CandidatePairError` (unloadable pair or missing page),
1672
+ `SpineRuntimeError` (input needs an unregistered or unusable Spine side),
1673
+ `PoserChoiceError` (a forced-core pose refusal), `SlotSubsetError` (invalid
1674
+ slot subset) and `CoreInputError` (core input/pose refusal). The chooser's
1675
+ mismatch reason remains in the refusal: no silent substitute is selected by
1676
+ this entry. Unknown animation and missing `pageFor` page are `Error`s naming
1677
+ the requested name and available names. A forced-core flag keeps the existing
1678
+ deferred choice check; it alone does not prove `candidate.choice.core` exists.
1679
+ To use a Spine export or `forced: 'spine'`, install the runtime and explicitly
1680
+ import `rig-c/render` first; importing `render-shared` never registers it.
1681
+
1620
1682
  ## 1. The two files
1621
1683
 
1622
1684
  ### 1.1 A complete minimal rig spec
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/core",
3
- "version": "2.68.0",
3
+ "version": "2.69.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": {
@@ -11,6 +11,7 @@
11
11
  "./font5x7": "./tools/font5x7.ts",
12
12
  "./transform": "./src/transform.ts",
13
13
  "./render": "./src/render.ts",
14
+ "./render-shared": "./src/render_read.ts",
14
15
  "./png": "./src/png.ts",
15
16
  "./compile": "./src/compile.ts",
16
17
  "./rig": "./src/rig.ts",
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The promised renderer reads for checked consumers (issue #1561).
3
+ *
4
+ * This entry registers no Spine side. Rigc builds use the official candidate
5
+ * chooser and core poser; inputs needing Spine are refused by SpineRuntimeError
6
+ * unless the consumer has explicitly loaded rig-c/render. That entry keeps its
7
+ * eager runtime import and registers the same implementation this seam uses.
8
+ * Only the agreed reads, their types and their existing failure classes belong
9
+ * here. The broader implementation module is not the public contract.
10
+ */
11
+ export {
12
+ loadCandidate,
13
+ throughPoser,
14
+ sampleAnimation,
15
+ sampleSetupPose,
16
+ pageFor,
17
+ projector,
18
+ rasterisePiece,
19
+ renderFrame,
20
+ CandidateAtlasError,
21
+ CandidatePairError,
22
+ PoserChoiceError,
23
+ SlotSubsetError,
24
+ } from './render_shared.ts';
25
+ export { SpineRuntimeError } from './spine_side.ts';
26
+ export { CoreInputError } from './core/index.ts';
27
+ export type {
28
+ Candidate,
29
+ SkeletonFacts,
30
+ PoserChoice,
31
+ PoserName,
32
+ MakeCorePoser,
33
+ Poser,
34
+ Posed,
35
+ PoseSource,
36
+ PoseOptions,
37
+ DrawOptions,
38
+ SkinRoster,
39
+ SlotSubset,
40
+ Frame,
41
+ BoneSnapshot,
42
+ AttachmentPose,
43
+ AttachmentRest,
44
+ Piece,
45
+ PieceCommon,
46
+ PieceTexture,
47
+ UvWindow,
48
+ Quad,
49
+ Mesh,
50
+ ClipSource,
51
+ Viewport,
52
+ EmitPixel,
53
+ } from './render_shared.ts';
54
+ export type { Plate, RGBA } from '../tools/plate.ts';
55
+ export type { EnvironmentStep, EnvironmentChange } from './environment.ts';