aispritejs 0.5.6 → 0.5.8

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/llms.txt CHANGED
@@ -1,40 +1,10 @@
1
1
  # aispritejs
2
2
 
3
- > Input-driven, renderer-agnostic 2D sprite animation runtime — a tiny, Rive-like *visual* state machine. Developers set runtime inputs (`Number` / `Boolean` / `Trigger`); a JSON transition graph decides which animation frame is on screen. The core is pure TypeScript with zero runtime dependencies and never imports `pixi.js`, the DOM, or any canvas API. Bind it to a renderer (PixiJS v8, etc.) through a thin adapter. Browser / Node / Bun / Deno / WebView / Worker friendly.
4
-
5
- Primary audience: developers building browser-based games and interactive web experiences who want to decouple *visual* animation state from game logic. You set parameters like `speed=4`, `isGrounded=false`, `fireTrigger("jump")`; `aispritejs` picks the visual state and ticks the active frame. It is a complement to — never a dependency of — a game-logic FSM such as `aifsmjs` (event-driven); here the model is input-driven, like Rive, but sprite-atlas based with no wasm runtime.
6
-
7
- Key guarantees: deterministic `update(dt)` (identical inputs + Δt ⇒ identical frames); no per-frame allocation; named errors (`InvalidGraphError`, `UnknownInputError`, `InputTypeError`, `SpriteAnimatorDisposedError`) instead of bare throws; public API is the `createSpriteAnimator` factory (no exported class constructor); `dispose()` idempotent, `reset()` keeps buffers, subscriptions return an unsubscribe and accept `{ signal, once }`; own minimal typed emitter (does NOT import `aieventjs`); `sideEffects: false`; core gzip ≈ 3.5 KB.
8
-
9
- ## Documentation
10
-
11
- - [README.md](README.md): canonical English README — Why, Mental Model, Core API, Semantics (the precise rules), Errors, Decoupling, Comparison, AI-Agent Reading Guide, Testing, Status, Roadmap.
12
- - [README_ZHTW.md](README_ZHTW.md): Traditional Chinese mirror of the canonical README.
13
- - [ROADMAP.md](ROADMAP.md): phased plan (v0.1.0 core → v0.2.0 PixiJS adapter → v0.3.0 atlas parser + JSON Schema → 1.0 freeze) and design invariants.
14
- - [STABILITY.md](STABILITY.md): stability tier of every public symbol plus the pinned behavioural contract.
15
- - [CHANGELOG.md](CHANGELOG.md): Keep a Changelog format; the 0.1.1 entry notes SLSA build provenance (OIDC publish); the 0.1.0 entry covers the full core surface and CI guarantees.
16
- - [CONTRIBUTING.md](CONTRIBUTING.md): quick-start commands, design principles, commit & PR style.
17
- - [llms-full.txt](llms-full.txt): README + CHANGELOG + CONTRIBUTING + examples index concatenated into one file — load this when an AI agent needs the full context in a single fetch.
18
-
19
- ## Source layout
20
-
21
- - [src/index.ts](src/index.ts): root barrel — re-exports the `sprite/` core. Imports no renderer.
22
- - [src/sprite/types.ts](src/sprite/types.ts): every public type in one file (`SpriteGraph`, `InputDef`, `StateDef`, `TransitionDef`, `TransitionCondition`, `SpriteAnimator`, handlers).
23
- - [src/sprite/machine.ts](src/sprite/machine.ts): `createSpriteAnimator` — the input-driven engine (`setInput` / `fireTrigger` / `update` / `reset` / `dispose`, `onStateChange` / `onComplete`, `activeState` / `activeFrameKey` / `activeFrameIndex`).
24
- - [src/sprite/compile.ts](src/sprite/compile.ts): graph validation + normalisation into precomputed, allocation-free runtime form (per-state cumulative timings; per-state transition candidate lists sorted by priority then declared order).
25
- - [src/sprite/inputs.ts](src/sprite/inputs.ts): O(1) input store (Number/Boolean values + Trigger pending flags) with default-reset.
26
- - [src/sprite/emitter.ts](src/sprite/emitter.ts): the package's own minimal typed signal with `{ signal, once }` — no `aieventjs` import.
27
- - [src/sprite/errors.ts](src/sprite/errors.ts): the four named error classes.
28
- - [src/pixi/animator.ts](src/pixi/animator.ts): the `aispritejs/pixi` adapter — `createPixiSpriteAnimator(sprite, graph, textures, options?)` swaps a PIXI.Sprite's texture to the active frame and applies the atlas anchor. Imports `pixi.js` **type-only** (optional peer); the core never imports it. Subpath: `aispritejs/pixi`.
29
- - [src/atlas/parse.ts](src/atlas/parse.ts): the `aispritejs/atlas` parser — `parseAtlas(atlas, control?)` / `loadAtlas(atlas, control?)` turn a PixiJS-v8 atlas into a `SpriteGraph` / `SpriteAnimator`, ignoring any foreign event-driven `states` block. `InvalidAtlasError`, `SpriteControl`. Pure, zero-dependency. Subpath: `aispritejs/atlas`. JSON Schema at [schemas/aispritejs-graph.schema.json](schemas/aispritejs-graph.schema.json), exported as `aispritejs/schema`.
30
-
31
- ## Examples
32
-
33
- - [examples/01-platformer-inputs/index.ts](examples/01-platformer-inputs/index.ts): a renderer-free `idle` / `walk` / `jump` graph — a Number drives idle⇄walk, a Trigger fires an Any-State jump that beats walk by priority and is one-shot, `jump` auto-returns to idle via `onEnd`. Run with `pnpm example:platformer`.
34
-
35
- ## Quality gates
36
-
37
- - [.github/workflows/ci.yml](.github/workflows/ci.yml): Node 20 + 22 matrix; typecheck, lint (biome), coverage (vitest + @vitest/coverage-v8 at 95/90/100/100 thresholds, met at 100% across the board), build (tsup → ESM + CJS + .d.ts), exports verification, size budget, and llms drift check.
38
- - [scripts/check-size.mjs](scripts/check-size.mjs): per-subpath gzip budget (core ≤ 3.8 KB; `aispritejs/pixi` ≤ 4.2 KB, pixi.js external; `aispritejs/atlas` ≤ 4.4 KB, zero-dependency).
39
- - [scripts/verify-exports.mjs](scripts/verify-exports.mjs): asserts every `package.json#exports` entry resolves to a real file in `dist/`.
40
- - [.github/workflows/publish.yml](.github/workflows/publish.yml): OIDC trusted-publisher + provenance on tag-push.
3
+ Renderer-agnostic input-driven sprite animator with Pixi adapter, atlas parser, and schema export.
4
+
5
+ - Start: README.md
6
+ - Stability: STABILITY.md
7
+ - Current backlog: REVIEW.md
8
+ - Examples: examples/README.md
9
+ - Changelog: CHANGELOG.md
10
+ - Full generated context: llms-full.txt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aispritejs",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Input-driven, renderer-agnostic 2D sprite animation runtime — a tiny, Rive-like visual state machine driven by Number / Boolean / Trigger inputs. JSON transition graph, deterministic update(dt), zero runtime dependencies. Browser / Node / Bun / Deno / WebView / Worker friendly.",
5
5
  "keywords": [
6
6
  "sprite",
@@ -66,15 +66,17 @@
66
66
  "test:watch": "vitest",
67
67
  "lint": "biome check src test",
68
68
  "format": "biome format --write src test",
69
- "typecheck": "tsc --noEmit",
69
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
70
+ "verify:docs": "node scripts/verify-docs.mjs",
70
71
  "verify:exports": "node scripts/verify-exports.mjs",
72
+ "verify:dist": "node scripts/check-dist-subpaths.mjs",
71
73
  "check:size": "node scripts/check-size.mjs",
72
74
  "build:llms": "node scripts/build-llms-full.mjs",
73
75
  "verify:llms": "node scripts/build-llms-full.mjs --check",
74
76
  "coverage": "vitest run --coverage",
75
77
  "example:platformer": "tsx examples/01-platformer-inputs/index.ts",
76
78
  "example:explosion": "tsx examples/02-explosion-pixi/index.ts",
77
- "prepublishOnly": "pnpm typecheck && pnpm lint && pnpm coverage && pnpm build && pnpm verify:exports && pnpm verify:llms && pnpm check:size"
79
+ "prepublishOnly": "pnpm typecheck && pnpm lint && pnpm verify:docs && pnpm coverage && pnpm build && pnpm verify:dist && pnpm verify:exports && pnpm verify:llms && pnpm check:size"
78
80
  },
79
81
  "peerDependencies": {
80
82
  "pixi.js": "^8.0.0"
@@ -26,7 +26,7 @@
26
26
  "additionalProperties": {
27
27
  "type": "object",
28
28
  "properties": {
29
- "duration": { "type": "number", "exclusiveMinimum": 0 }
29
+ "duration": { "type": "number", "exclusiveMinimum": 0, "maximum": 86400000 }
30
30
  }
31
31
  }
32
32
  },
@@ -74,7 +74,7 @@
74
74
  "properties": {
75
75
  "animation": { "type": "string" },
76
76
  "loop": { "type": "boolean" },
77
- "speed": { "type": "number", "exclusiveMinimum": 0 },
77
+ "speed": { "type": "number", "exclusiveMinimum": 0, "maximum": 1000 },
78
78
  "onEnd": { "type": "string" }
79
79
  },
80
80
  "additionalProperties": false
@@ -119,9 +119,10 @@
119
119
  "type": "string"
120
120
  },
121
121
  "defaultFrameDuration": {
122
- "description": "Fallback frame duration (ms, > 0) for frames without explicit timing. Defaults to 100.",
122
+ "description": "Fallback frame duration (ms, > 0) for frames without explicit timing. Defaults to 100. Maximum 86400000 (24 h).",
123
123
  "type": "number",
124
- "exclusiveMinimum": 0
124
+ "exclusiveMinimum": 0,
125
+ "maximum": 86400000
125
126
  }
126
127
  }
127
128
  }