Imported from williamngan/react-pts-canvas (
AGENTS.md). Install upstream withnpx skills add williamngan/react-pts-canvas. Copyright stays with the author.
Repository instructions for coding agents
These instructions apply to the entire react-pts-canvas repository.
Read first
- Read
llms.txtfor the compact project contract. - Read
API.mdbefore changing public props, callbacks, refs, DOM output, or lifecycle behavior. - Read
MIGRATION.mdbefore changing compatibility or deprecated APIs. - Treat files in
plans/as completed implementation records unless a user explicitly asks to revive a plan.
Sources of truth
src/index.tsxowns runtime behavior and exported types.API.mdis the canonical prose API contract.test/PtsCanvas.spec.tsxverifies browser lifecycle behavior.scripts/check-packed-package.mjsverifies the published artifact.examples/gallery/src/PtsExamples.tsxowns maintained example behavior.dist/andexamples/gallery/dist/are generated and ignored; never hand-edit them.
Invariants
- The component owns exactly one active
CanvasSpaceper mounted rendering context. - Callback, background, resize, input, playback, refresh, timing, player, and tempo changes update live.
retina,offscreen, and effective pixel-density changes replace the space.- Replacement/unmount order is returned
onReadycleanup,onDispose, input teardown, thenCanvasSpace.dispose(). - The component owns disposal; consumer-facing examples must not dispose the returned space.
- Pts actions only dispatch while the space is playing. Do not document
onActionas a wake mechanism forplay={false}. - Preserve the
"use client"boundary, ESM/CommonJS exports, external peers, and React 18.2/19 compatibility. - Deprecated aliases remain supported until a documented release decision says otherwise.
Workflow
- Use pnpm because the repository has
pnpm-lock.yaml. - Use Node
^20.19.0or>=22.12.0. - Run focused checks while editing and
pnpm checkbefore completion. - Browser tests require Playwright Chromium; see
README.md#developmentfor setup. - Do not change the package version or publish unless the user explicitly asks.
- Preserve user changes and avoid unrelated refactors.
Documentation synchronization
When changing the public contract, update all affected surfaces in the same
change: source JSDoc, API.md, task-oriented README guidance, migration notes,
the Unreleased changelog, llms.txt if a core invariant changed, and any
displayed gallery snippet. Run pnpm check:docs to catch mechanical drift.
