Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
b543127
feat(core)!: transactions, subtree subscriptions and immutable stored…
codeBelt Nov 17, 2026
836c3a1
feat(utils)!: per-field hydration, stricter equality and identity-bas…
codeBelt Nov 17, 2026
e34e5dd
feat(adapters)!: rename injectStore to injectClassyStore and widen th…
codeBelt Nov 17, 2026
669406c
test: add a seeded randomized test, React regressions and export type…
codeBelt Nov 17, 2026
7d10d2b
build: verify the published package shape and add the 1.0 changeset
codeBelt Nov 17, 2026
04fe30f
docs: 1.0 upgrade guide and documentation for the new behavior
codeBelt Nov 17, 2026
56182a5
refactor(core): close transactions without a per-call closure
codeBelt Nov 18, 2026
96ca5b4
chore(deps): update the Solid packages to 2.0.0 stable
codeBelt Nov 18, 2026
965e945
feat(solid)!: require stable Solid 2 and drop the preview label
codeBelt Nov 18, 2026
fae8b1f
docs(solid): describe Solid 2 only
codeBelt Nov 18, 2026
b201de9
chore(deps): update the docs site, example TypeScript and CI Bun
codeBelt Nov 18, 2026
c4cd8b4
feat(core): add batch() for direct writes made outside a store method
codeBelt Nov 18, 2026
9c8bf06
docs: describe 1.0 on its own terms
codeBelt Nov 18, 2026
b18d772
build: run the docs site on the workspace library and require Node 22
codeBelt Nov 18, 2026
a14a003
docs(examples): remove stray colour-tool links from the Next.js README
codeBelt Nov 18, 2026
a395e17
docs: start the changelog at 1.0.0
codeBelt Nov 18, 2026
b1d9ad7
test: cover gaps found by a coverage run and a mutation sample
codeBelt Nov 18, 2026
5f15539
test: finish the mutation sweep and cover the gaps it found
codeBelt Nov 18, 2026
f8a012f
fix(core): keep a frozen object in a store as a value
codeBelt Nov 18, 2026
7540662
docs: record frozen values and the current bundle size in CLAUDE.md
codeBelt Nov 18, 2026
d31fbe9
docs: add the pre-1.0 review plan
codeBelt Nov 18, 2026
0c0d44c
test: add a repeatable mutation runner
codeBelt Nov 18, 2026
6b3afa9
build: add a bundle-size script with a baseline
codeBelt Nov 18, 2026
bd0d11f
test: add a core per-operation benchmark
codeBelt Nov 18, 2026
f58ab6f
docs: list the stage 1 tooling commands in the review plan
codeBelt Nov 18, 2026
95e67dc
test: keep one list of equivalent mutants per source file
codeBelt Nov 18, 2026
dd7ba0c
test: cover the write and delete guards of the shared backing copy
codeBelt Nov 18, 2026
e70a223
build: add a floor guard for the quality bar
codeBelt Nov 18, 2026
23b153c
test: characterise store and node identity
codeBelt Nov 18, 2026
6e46283
test: add type tests for every public export
codeBelt Nov 19, 2026
230d305
test: characterise notification order
codeBelt Nov 18, 2026
b13dad1
test: characterise detached subtrees
codeBelt Nov 19, 2026
d76d56d
test: cover the last uncovered line and function of the ownership module
codeBelt Nov 19, 2026
1cf6829
test: extend the differential fuzz test
codeBelt Nov 19, 2026
bf1fff4
test: characterise getters
codeBelt Nov 18, 2026
6018458
test: characterise proxy invariants
codeBelt Nov 19, 2026
7313f48
docs: name the kinds of reason an unkillable mutant can have
codeBelt Nov 19, 2026
eb085ea
docs: say which model a helper agent runs on in the review plan
codeBelt Nov 19, 2026
d175b11
test: hold every source file to full line and function coverage
codeBelt Nov 19, 2026
367cb34
docs: allow Opus for helper agents in the review plan
codeBelt Nov 19, 2026
2cf34fa
test: cover the persist behaviour that mutation testing found untested
codeBelt Nov 19, 2026
589812f
test: cover the persist behaviour that mutation testing found untested
codeBelt Nov 19, 2026
fc055ea
test: cover the persist behaviour that mutation testing found untested
codeBelt Nov 19, 2026
f9fa30e
test: cover the shallowEqual behaviour that mutation testing found un…
codeBelt Nov 19, 2026
0a1199f
test: cover the history behaviour that mutation testing found untested
codeBelt Nov 19, 2026
7386c6f
test: cover the reactive collections behaviour that mutation testing …
codeBelt Nov 19, 2026
a6946cc
test: pin that every status subscriber hears about a history dispose
codeBelt Nov 19, 2026
12e009e
test: cover the core behaviour that mutation testing found untested
codeBelt Nov 19, 2026
b60cc1c
test: cover the core behaviour that mutation testing found untested
codeBelt Nov 19, 2026
f183854
test: cover the ownership behaviour that mutation testing found untested
codeBelt Nov 19, 2026
c9e83a3
test: cover the snapshot behaviour that mutation testing found untested
codeBelt Nov 19, 2026
b41cc7d
test: record the mutation results after triage
codeBelt Nov 19, 2026
20a34f6
test: require a label on every unkillable mutant's reason
codeBelt Nov 19, 2026
1ede2d6
test: record the core, React and memory baselines
codeBelt Nov 19, 2026
c070953
build: write down the quality bar and gate it in CI
codeBelt Nov 19, 2026
5bc4008
test: allow one clock tick or five percent when comparing React timings
codeBelt Nov 19, 2026
d7b49c8
docs: report on stage 1 of the review
codeBelt Nov 19, 2026
9ab9744
chore: ignore helper-agent worktrees
codeBelt Nov 19, 2026
492b63e
docs: mark stage 2 of the review as started
codeBelt Nov 19, 2026
825ba2d
docs: record that commits and pushes need no further approval
codeBelt Nov 19, 2026
fa25ae6
fix(docs): record a change the demo traces missed before subscribing
codeBelt Nov 19, 2026
a73a92d
docs: name the docs site's browser tests in the review plan
codeBelt Nov 19, 2026
ac38f2f
docs: add the stage 2 reports for Valtio, MobX, Vue reactivity and So…
codeBelt Nov 19, 2026
12fe57d
docs: add the stage 2 report for Svelte 5
codeBelt Nov 19, 2026
912a3e2
docs: add the stage 2 report on the five adapters
codeBelt Nov 19, 2026
04bd91d
docs: add the stage 2 reports for Signals and Immer
codeBelt Nov 19, 2026
5d866cb
docs: update the stage 2 status in the review plan
codeBelt Nov 19, 2026
c59084e
docs: add the stage 2 security report
codeBelt Nov 19, 2026
cd6a73f
docs: add the stage 2 report for Legend-State
codeBelt Nov 19, 2026
2a43f72
docs: add the stage 2 report for Zustand and Jotai
codeBelt Nov 19, 2026
1b426fb
docs: add the stage 2 report
codeBelt Nov 19, 2026
7d70d50
docs: mark stage 2 done in the review plan
codeBelt Nov 19, 2026
57404c3
docs: allow merges into branches other than main, and start stage 3
codeBelt Nov 19, 2026
5a3d05a
docs: add the stage 3 merge of the stage 2 reports
codeBelt Nov 19, 2026
216b3d1
docs: correct the stage 2 report on how MobX holds a function
codeBelt Nov 19, 2026
cbb03c9
docs: record that the agent decides, and scrub machine paths from the…
codeBelt Nov 19, 2026
3432a74
docs: record where stage 3 stands at the pause
codeBelt Nov 19, 2026
74966f1
docs: add the first wave of stage 3 reports and lift the pause
codeBelt Nov 25, 2026
f566ea7
docs: finish the own-code and getter reports of stage 3
codeBelt Nov 25, 2026
96111db
docs: add the stage 3 list of pinned behaviours
codeBelt Nov 25, 2026
5ab613f
docs: add the stage 3 report on persist, devtools and history
codeBelt Nov 25, 2026
2884386
docs: start the stage 3 decision document
codeBelt Nov 25, 2026
5d0030b
docs: save the second-wave reports as they stood, and put helper agen…
codeBelt Nov 25, 2026
d959365
docs: decide classes and narrow the getter rule in the stage 3 draft
codeBelt Nov 25, 2026
d039455
docs: add the guarantees, the release workflow and history to the sta…
codeBelt Nov 25, 2026
a0f754f
docs: add the stage 3 report on a development build and diagnostics
codeBelt Nov 25, 2026
cecf80a
docs: decide error codes and the development build in the stage 3 draft
codeBelt Nov 25, 2026
cdabeb1
docs: add the stage 3 report on adapters and collections
codeBelt Nov 25, 2026
342a1ab
docs: decide adapters and collections in the stage 3 draft
codeBelt Nov 25, 2026
b0529ad
docs: finish the stage 3 report on snapshots
codeBelt Nov 25, 2026
8c01b85
docs: decide snapshots in the stage 3 draft
codeBelt Nov 25, 2026
116e5d5
docs: set the size ceilings in the stage 3 draft
codeBelt Nov 25, 2026
a656d93
docs: add the stage 3 check of the base class
codeBelt Nov 25, 2026
e8b115d
docs: decide the base class and restore in place in the stage 3 draft
codeBelt Nov 25, 2026
b892220
docs: add the index, the list of what was not taken and the stage 4 o…
codeBelt Nov 25, 2026
cec3e81
docs: add the briefs for the adversarial review of the stage 3 decisions
codeBelt Nov 25, 2026
b7f019f
docs: add the adversarial review of the stage 3 decisions as a whole
codeBelt Nov 25, 2026
73087de
docs: add briefs for two follow-up spikes the adversarial review asks…
codeBelt Nov 25, 2026
6df83be
docs: add the adversarial review of the core decisions
codeBelt Nov 25, 2026
52808a7
docs: add the adversarial review of delivery, utilities and adapters
codeBelt Nov 25, 2026
53732ec
docs: add a brief for four core fixes the adversarial review asks for
codeBelt Nov 25, 2026
add5b71
docs: answer the adversarial review in the stage 3 decisions
codeBelt Nov 25, 2026
c9c30f6
docs: bring the stage 3 status in the review plan up to date
codeBelt Nov 25, 2026
c2de600
docs: add the spike of three combinations, and the briefs for what fo…
codeBelt Nov 25, 2026
1fb6cb7
docs: record the timings of the trap combination, the ownership patch…
codeBelt Nov 25, 2026
f5620b1
docs: decide nine stage 3 entries again from three follow-up spikes
codeBelt Nov 25, 2026
9d07770
docs: update the stage 3 status in the review plan
codeBelt Nov 25, 2026
f27d496
docs: add the spike of four core fixes, and its final figures to the …
codeBelt Nov 25, 2026
444aef1
docs: add the second adversarial review, and where stage 3 stopped
codeBelt Nov 25, 2026
240041d
docs: add briefs for two spikes the second adversarial review asks for
codeBelt Nov 25, 2026
7ae33cd
docs: answer the second adversarial review where no build is needed
codeBelt Nov 25, 2026
7ad0f67
docs: update the stage 3 status in the review plan
codeBelt Nov 25, 2026
a14cd94
docs: add the brief for the third adversarial review
codeBelt Nov 25, 2026
402f99d
docs: add the spike of three more core fixes
codeBelt Nov 25, 2026
6ecce72
docs: decide five stage 3 entries again after the second adversarial …
codeBelt Nov 25, 2026
447201a
docs: update the stage 3 status in the review plan
codeBelt Nov 25, 2026
dabb21d
docs: add the third adversarial review and the briefs for two last sp…
codeBelt Nov 25, 2026
d7f51f1
docs: answer the third adversarial review where no build is needed
codeBelt Nov 25, 2026
381b64c
docs: mark what waits for the two last spikes, and update the plan's …
codeBelt Nov 25, 2026
ea70c71
docs: decide the persist rules from one build of all of them
codeBelt Nov 25, 2026
ace81ad
test: let the core benchmark's --only take a list of metrics
codeBelt Nov 25, 2026
a5e4935
docs: decide the rule for functions a last time, and answer the third…
codeBelt Nov 25, 2026
f4c8e65
docs: re-wrap one paragraph of the stage 3 decisions
codeBelt Nov 25, 2026
c332e5e
docs: re-wrap the over-long paragraphs of the stage 3 decisions
codeBelt Nov 25, 2026
0f52347
docs: update the stage 3 status in the review plan
codeBelt Nov 25, 2026
a1e1d99
docs: add one decision record per stage 3 decision, not yet checked
codeBelt Nov 25, 2026
cb93724
docs: add the 1.0 spec and the stage 3 report draft, and the new mode…
codeBelt Nov 25, 2026
d50bf26
docs: record where the handover stopped
codeBelt Nov 25, 2026
0eae6a0
docs: add the stage 4 task list, not yet checked
codeBelt Nov 25, 2026
e7e6afa
docs: note that the stage 4 task list is in
codeBelt Nov 25, 2026
7a1dec5
docs: record that the handover happened and the new session runs the …
codeBelt Nov 25, 2026
944a2f7
docs: settle the open points of the step 7 documents in the decision …
codeBelt Nov 25, 2026
24a7a5b
docs: record that the step 7 documents were checked and are being fixed
codeBelt Nov 25, 2026
ea0e0d0
docs: note that T-01 is written and waits for stage 3 to end
codeBelt Nov 25, 2026
737512e
docs(spec): correct the spec against the decision document
codeBelt Nov 25, 2026
da08e4b
docs(decisions): correct the 46 records against the decision document
codeBelt Nov 25, 2026
7f82dfd
docs: name the six messages of today that get codes in step 2
codeBelt Nov 25, 2026
b89f479
docs: correct the stage 4 task list against the decision document
codeBelt Nov 25, 2026
b080def
docs: finish the stage 3 report and settle the records' open points
codeBelt Nov 25, 2026
c47b050
docs: mark stage 3 done at b080def and start "Where stage 4 stands"
codeBelt Nov 25, 2026
a46cd96
build: add the size ceilings and make the floor guard judge every commit
codeBelt Nov 25, 2026
ae990df
build: hold the guard form of a development-only check with two checks
codeBelt Nov 25, 2026
09ba1f2
fix(size): type bundle() so its bytes fit Bun.gzipSync
codeBelt Nov 25, 2026
269b737
docs: record checkpoint 1 and the starting timings of stage 4
codeBelt Nov 25, 2026
bd50ec4
fix(floor): judge a pull request's head, not the merge CI checks out
codeBelt Nov 25, 2026
dc2f144
feat!: give today's messages their stable codes, and a page of codes
codeBelt Nov 25, 2026
08cb14e
docs: name the error codes in the 1.0 changeset, and record T-03
codeBelt Nov 25, 2026
5c25a04
test(browser): match the Solid owner error by its code
codeBelt Nov 25, 2026
0b6b4b3
refactor: remove the ten dead lines of the three core files
codeBelt Nov 25, 2026
4bc0077
docs: record T-04 and the browser test fix
codeBelt Nov 25, 2026
319a478
refactor(persist): remove the dead and redundant blocks
codeBelt Nov 25, 2026
d363ba5
docs: record T-05
codeBelt Nov 25, 2026
3f5f07d
refactor: remove the redundant checks of equality.ts and history.ts
codeBelt Nov 25, 2026
082b8a3
docs: record T-06
codeBelt Nov 25, 2026
06ceaa8
refactor(react): remove the two snapshot-cache traps proxy-compare ca…
codeBelt Nov 25, 2026
7737d15
docs: record T-07
codeBelt Nov 25, 2026
c4ec4d1
docs: record checkpoint 2
codeBelt Nov 25, 2026
54ec834
style: format the checkpoint 2 timings, which lint refused
codeBelt Nov 25, 2026
bdaa479
fix: remove the walk to a detached parent, so a read below one returns
codeBelt Nov 25, 2026
6941098
test(mutation): record the full run of checkpoint 2
codeBelt Nov 25, 2026
7a21179
docs: record T-08
codeBelt Nov 25, 2026
6052255
perf: decide getters from a table per prototype, not a descriptor walk
codeBelt Nov 25, 2026
5b033fb
docs: record T-09
codeBelt Nov 25, 2026
b5146a2
test(persist): wait for the write itself in the clear-during-restore …
codeBelt Nov 25, 2026
5693204
docs: record the persist test fix
codeBelt Nov 25, 2026
ae8ffec
fix: make a delete that removes nothing no change
codeBelt Nov 25, 2026
536f496
docs: record T-10
codeBelt Nov 25, 2026
684cedf
fix: make a definition through the store a write
codeBelt Nov 25, 2026
09c6afb
docs: record T-11
codeBelt Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"updateInternalDependencies": "patch",
"ignore": [
"classy-store-angular-example",
"classy-store-docs",
"classy-store-nextjs-example",
"classy-store-solid-example",
"classy-store-svelte-example",
Expand Down
26 changes: 26 additions & 0 deletions .changeset/stable-one.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@codebelt/classy-store": major
---

Release 1.0.0, the first stable version. The public API and its behavior are now covered by semantic versioning.

**Breaking changes**

- Store methods and array operations are transactions. Synchronous subscribers, including every framework adapter, are notified once when the outermost call returns instead of once per property write. A `sort` or `unshift` on a long list is now one notification and one snapshot.
- `subscribe()` on a nested proxy observes only that proxy's subtree. It no longer fires for sibling changes.
- Each `subscribe()` call is an independent registration; subscribing the same callback twice yields two subscriptions.
- A frozen object held in a store is an immutable value, kept by reference and never proxied. That covers any object you freeze, a snapshot assigned into a store, and one read through React's auto-tracked hook. Reading a nested object through a frozen object no longer throws.
- `persist`: hydration is per field. A stored field is restored unless that same field was edited locally while the read was in flight, and a local edit can no longer overwrite the stored record before it is restored. Stored data whose version differs is ignored unless `migrate` is provided.
- `shallowEqual` returns `false` for values with different prototypes, compares dates by instant and maps and sets one level deep, and no longer treats arbitrary key-less objects as equal.
- `devtools()` returns a handle with `dispose()` instead of a function, and no longer declares anything on the global `Window` type.
- Angular: `injectStore` is renamed `injectClassyStore`.
- Solid: the adapter requires Solid 2 (`solid-js@^2.0.0`).
- Every error message now reads `@codebelt/classy-store [code]: facts`, with a stable code such as `[not-a-store]` or `[getter-cycle]`; the adapters' messages share that prefix. Match on the code, not the text after it. The documentation's "Errors and warnings" page lists every code.

**Other changes**

- `withHistory`: undo and redo remove top-level fields that the restored entry lacks, `undo()` steps back over an edit made in the same tick, and unchanged fields keep their identity.
- Reactive collections compare keys and values by identity, so a plain object works as a key whether it is given raw, as a store proxy or as a snapshot. Lookups scan the raw backing array.
- `batch(run)` is exported to group direct writes made outside a store method into one synchronous notification.
- `PROXYABLE` is exported so a class can opt into nested reactivity with `static [PROXYABLE] = true`.
- The package declares `engines.node >= 22` and exports `./package.json`.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# The floor guard compares against the commit the pull request started from.
with: {fetch-depth: 0}
- uses: actions/setup-node@v6
with:
node-version: "24"
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.4.3"
bun-version: "1.4.4"
- run: bun install --frozen-lockfile
- run: bun run lint
- run: bun run test
# A pull request is checked out as a merge of its head into main; the
# guard judges the branch's own commits, up to the head.
- name: Floor of CONSTRAINTS.md (no silenced check, skipped test or loosened rule)
run: node scripts/floor-guard.mjs --head ${{ github.event.pull_request.head.sha }}
- name: Unit tests, with every source file at full line and function coverage
run: bun run test:coverage
# Packed-consumer typechecks resolve the package's generated declarations.
- run: bun run build
- run: bun run typecheck
- name: Published package shape (publint, arethetypeswrong)
run: bun run --filter @codebelt/classy-store check:package
- name: Bundle size budgets
run: bun packages/classy-store/tests/size/runSize.ts
- name: Solid 2 example production build
run: bun run --filter classy-store-solid-example build
- name: Angular 22 example production build
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ jobs:
node-version: "24"
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.4.3"
- run: bun install --cwd website --frozen-lockfile
bun-version: "1.4.4"
- run: bun install --frozen-lockfile
# Builds the library first: the site runs the package from this repository.
- run: bun run docs:build
- run: bunx playwright install --with-deps chromium
working-directory: website
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/react-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ jobs:
fail-fast: false
matrix:
react: ["18.0.0", "18.3.1", "19.0.0", "19.3.1"]
node: ["24"]
# The package declares Node 22 as its minimum; prove it on one consumer.
include:
- react: "19.3.1"
node: "22"
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: "24"
node-version: ${{ matrix.node }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.4.3"
bun-version: "1.4.4"
- run: bun install --frozen-lockfile
- run: bun run build
- run: node packages/classy-store/tests/compatibility/runCompatibility.mjs "${{ matrix.react }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/react-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
node-version: "24"
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.4.3"
bun-version: "1.4.4"
- run: bun install --frozen-lockfile
- name: Use Ubuntu archive mirror for browser dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
node-version: "24"
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.4.3"
bun-version: "1.4.4"
- run: bun install --frozen-lockfile
- run: bun run build
- name: Create Release PR or Detect Publishable Versions
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Finder (MacOS) folder config
.DS_Store

# Worktrees of helper agents. Each holds its own biome.json, which Biome
# refuses as a nested root configuration.
.claude/worktrees/
.claude/settings.local.json

# Browser test artifacts
playwright-report
test-results
63 changes: 45 additions & 18 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,42 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## What This Library Is

`@codebelt/classy-store` is a class-based reactive state management library (~2.3 KB gzipped) for React, Vue, Svelte, Solid, and Angular. You define state as a plain TypeScript class, wrap it with `createClassyStore()`, and get a reactive proxy back. Class getters become automatically memoized computed values. ES6 Proxy intercepts mutations, batches them via `queueMicrotask`, and notifies framework-specific bindings via immutable snapshots with structural sharing.
`@codebelt/classy-store` is a class-based reactive state management library (core about 3.7 KB minified and gzipped; about 4.9 KB with the React hooks) for React, Vue, Svelte, Solid, and Angular. You define state as a plain TypeScript class, wrap it with `createClassyStore()`, and get a reactive proxy back. Class getters become automatically memoized computed values. ES6 Proxy intercepts mutations and notifies subscribers through immutable snapshots with structural sharing: framework bindings synchronously, ordinary subscribers batched via `queueMicrotask`.

## Monorepo Layout

```
packages/classy-store/src/
├── core/core.ts # Layer 1: Write Proxy — createClassyStore(), subscribe()
├── index.ts # Main entry: createClassyStore, snapshot, subscribe, batch, shallowEqual, PROXYABLE
├── storeRuntime.ts # Runtime shared by every entry and both module formats (#store-runtime)
├── types.ts # Public Snapshot<T>, SubscribeOptions
├── core/core.ts # Layer 1: Write Proxy — createClassyStore(), subscribe(), transactions, computed getters
├── core/ownership.ts # StoreInternal: one node per object, parent links, detached subtrees
├── core/core.types.ts # DepEntry, ComputedEntry
├── snapshot/snapshot.ts # Layer 2: Immutable snapshots — snapshot(), structural sharing
├── types.ts # Snapshot<T>, StoreInternal, DepEntry, ComputedEntry
├── index.ts # Main barrel: createClassyStore, snapshot, subscribe, shallowEqual
├── collections/collections.ts # ReactiveMap and ReactiveSet (array-backed Map/Set emulation)
├── collections/index.ts # Collections barrel: reactiveMap, reactiveSet, ReactiveMap, ReactiveSet
├── collections/index.ts # Collections entry: reactiveMap, reactiveSet, ReactiveMap, ReactiveSet
├── frameworks/
│ ├── react/react.ts # Layer 3 (React): useClassyStore(), useLocalStore() via useSyncExternalStore
│ ├── vue/vue.ts # Vue: useClassyStore() → ShallowRef<Snapshot<T>> (onUnmounted cleanup)
│ ├── react/react.ts # Layer 3 (React): client entry re-exporting the hooks
│ ├── react/server.ts # Server-safe entry: prepareStoreForHydration()
│ ├── react/hooks/ # useClassyStore, useLocalStore, useHistoryStatus, usePersistStatus
│ ├── react/utils/ # createStoreHook, tracking caches used by the auto-tracked hook
│ ├── vue/vue.ts # Vue: useClassyStore() → Ref<Snapshot<T>> (effect-scope cleanup)
│ ├── svelte/svelte.ts # Svelte: toSvelteStore() → ClassyReadable<Snapshot<T>>
│ ├── solid/solid.ts # Solid: useClassyStore() → () => Snapshot<T> signal (onCleanup)
│ └── angular/angular.ts # Angular: injectStore() → Signal<Snapshot<T>> (DestroyRef)
│ ├── solid/solid.ts # Solid 2: useClassyStore() → () => Snapshot<T> (owner cleanup)
│ └── angular/angular.ts # Angular: injectClassyStore() → Signal<Snapshot<T>> (DestroyRef)
└── utils/
├── index.ts # Utils barrel: persist, devtools, subscribeKey, withHistory
├── index.ts # Utils entry: persist, devtools, subscribeKey, withHistory
├── persist/persist.ts # persist() — storage, transforms, versioning, cross-tab sync, TTL
├── devtools/devtools.ts # devtools() — Redux DevTools integration, time-travel
├── history/history.ts # withHistory() — undo/redo via snapshot stack, pause/resume
├── subscribe-key/subscribe-key.ts # subscribeKey() — single-property subscription
├── equality/equality.ts # shallowEqual
├── cloneSnapshot/ # Mutable copies of snapshots, used by persist and history
├── utilityStatus/ # Status publisher behind the persist and history handles
└── internal/internal.ts # isPlainObject, canProxy, findGetterDescriptor, PROXYABLE

website/ # Fumadocs static site (Next.js)
website/ # Fumadocs static site (Next.js); a workspace member that runs the library built from this repository
website/content/docs/ # .md source for all doc pages
website/examples/ # Live React controls used by the MDX example pages
website/public/ # Static assets and old demo bookmark redirect
Expand All @@ -51,10 +59,17 @@ bun run test # Run all tests (Bun test runner, uses happy-dom for React
bun run lint # Check with Biome linter
bun run lint:fix # Auto-fix Biome lint issues
bun run typecheck # TypeScript type check without emit
bun run check:package # Build, then publint + arethetypeswrong on the packed tarball
bun run checkall # lint + test + typecheck (full CI check)

bun run docs:dev # Start Fumadocs at http://localhost:3000
bun run docs:build # Export the GitHub Pages site to website/out/
bun run test:coverage # Unit tests; fails if a source file is below 100% of lines or functions
bun run check:floor # Diff-scoped guard for the floor in CONSTRAINTS.md
bun run size # Build, then gzipped size per entry point against its budget
bun run test:mutation # Mutation run over the core files (about ten minutes); pass file paths to limit it
bun run benchmark:core # Per-operation timings on Bun; benchmark:core:node for V8

bun run docs:dev # Build the library, then start Fumadocs at http://localhost:3000
bun run docs:build # Build the library, then export the GitHub Pages site to website/out/
```

Run from `packages/classy-store/`:
Expand All @@ -69,7 +84,7 @@ bun run typecheck # TypeScript type check without emit

### Test helper pattern

Because mutations are batched via `queueMicrotask`, tests must flush the microtask queue before asserting on subscriber calls:
Ordinary subscriptions are batched via `queueMicrotask`, so tests must flush the microtask queue before asserting on subscriber calls. A `{sync: true}` subscription can be asserted immediately:

```typescript
const flush = () => new Promise<void>((resolve) => setTimeout(resolve, 0));
Expand All @@ -84,9 +99,15 @@ it('notifies on mutation', async () => {
});
```

## Quality Bar

Read [CONSTRAINTS.md](CONSTRAINTS.md) before writing code. Do not weaken it to
make a change pass: a rule there is loosened only together with a decision
record under `docs/decisions/`.

## Code Style

Enforced by Biome 2.4.0 (`biome.json` at repo root):
Enforced by Biome (`biome.json` at repo root; the version is pinned in the root `package.json`):

- 2-space indentation, single quotes, no bracket spacing
- `noUnusedImports` is an error
Expand All @@ -95,10 +116,16 @@ Enforced by Biome 2.4.0 (`biome.json` at repo root):
## Key Technical Facts

- **No arrow function methods:** Arrow function properties (`increment = () => {}`) have `this` lexically bound to the raw instance. `.bind()` is a no-op on arrow functions, so the GET trap cannot rebind `this` to the proxy. Mutations inside arrow functions bypass the SET trap entirely — no notifications, no reactivity. Always use prototype methods (`increment() {}`).
- **Batching:** mutations are coalesced via `queueMicrotask`. Multiple synchronous writes (including array `push` which triggers multiple SET traps) produce a single subscriber notification.
- **Batching:** ordinary subscribers are coalesced via `queueMicrotask`. Multiple synchronous writes (including array `push` which triggers multiple SET traps) produce a single notification.
- **Transactions:** `{sync: true}` subscribers, which is every framework binding, are notified once per direct write, and once per store method or array-method call, when the outermost call returns. Versions still bump on every write, so reads inside the call are current. Without this an in-place `sort` or `unshift` notifies once per moved element and each notification rebuilds the list snapshot. The exported `batch(run)` opens the same transaction around direct writes made outside a method.
- **Subscription scope:** `subscribe(node)` observes that node's subtree only. Each call is its own registration.
- **Frozen objects are values:** a frozen object held in a store is kept by reference and never proxied. That covers any object the caller froze, a snapshot assigned into a store, and a snapshot read through React's tracking proxy. The store does not look inside it: replace the field to update. The frozen check is cached in `linkChild()` (`core.ts`), because `Object.isFrozen` scans every property; do not move it into `canProxy()`, which history and persist use to copy frozen snapshot content.
- **Read-only properties:** a Proxy must return a non-writable, non-configurable property's own value, so `linkChild()` leaves such a value unproxied. That is what makes a frozen store root readable. A store embedded by its proxy is already that value and stays a child.
- **Internal state:** stored in a `WeakMap<proxy, StoreInternal>` — never on the user's object. Allows GC when a store is dereferenced.
- **Non-proxyable types:** `Date`, `RegExp`, native `Map`, and native `Set` are treated as opaque values (internal slots can't be intercepted by Proxy). Use `reactiveMap()` and `reactiveSet()` for Map/Set semantics. Replace Date instances entirely to trigger updates.
- **Extending reactive types:** a class can opt into deep proxying by setting `static [PROXYABLE] = true` (the `PROXYABLE` symbol is exported from `utils/internal`). `ReactiveMap` and `ReactiveSet` use this.
- **Non-proxyable types:** `Date`, `RegExp`, native `Map`, and native `Set` are treated as opaque values (internal slots can't be intercepted by Proxy). Use `reactiveMap()` and `reactiveSet()` for Map/Set semantics. Replace Date instances entirely to trigger updates. Frozen objects are opaque in the same way.
- **Extending reactive types:** a class can opt into deep proxying by setting `static [PROXYABLE] = true` (the `PROXYABLE` symbol is exported from the main entry). `ReactiveMap` and `ReactiveSet` use this.
- **Collection identity:** reactive collections match members with `identityOf()`, which is the same for a raw object, its store proxy and every snapshot of it. Lookups scan the raw backing array except for tracked reads in a React component.
- **Typecheck with the package script:** run `bun run typecheck`, not `bunx tsc`; the latter can resolve a different TypeScript and miss errors.
- **`persist()` exclusions:** getters (detected by walking the prototype chain with `Object.getOwnPropertyDescriptor`) and methods (`typeof value === 'function'`) are automatically excluded from persistence. Only own data properties are saved.
- **Computed memoization:** two layers — the write proxy caches getter results keyed on dependency versions/values; the snapshot layer adds cross-snapshot caching using structural sharing reference equality.
- **Structural sharing:** unchanged sub-trees reuse the previous frozen snapshot reference. This makes `Object.is` comparisons in selectors efficient without `shallowEqual`.
Expand Down
Loading