Skip to content

Tags: disjukr/bunja

Tags

v3.0.0

Toggle v3.0.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
v3 (#29)

## Summary

This PR introduces the v3 dependency graph model for Bunja.

The main additions are `bunja.withSeed`, `bunja.will`, bunja refs,
active optional dependency tracking, and `store.prebake`. Together they
allow a bunja to declare possible dependencies statically while mounting
only the dependency branch that is actually used by the first instance
creation.

## What Changed

### Seeded bunjas

- Added `bunja.withSeed(defaultSeed, init)`.
- `seed` is creation-time data for the first matching bunja instance.
- `seed` is not part of the bunja instance identity.
- If an instance already exists, later seed values are ignored.
- `store.get`, `useBunja`, `bunja.use`, and `bunja.will` can receive
bunja refs with `seed`.

### Conditional dependencies

- Added `bunja.will`.
- `bunja.will(dep)` declares a possible bunja dependency and returns a
thunk.
- Only the called thunk becomes an active dependency and gets mounted.
- The thunk can only be called during the same bunja init function that
created it.
- `bunja.use` and `bunja.will` must still be called unconditionally and
in a stable order, similar to React’s Rules of Hooks.

### Scope value pairs

- Bunja refs and `bunja.use`/`bunja.will` can provide scope value pairs.
- The selected bunja and the provided scope value pair list must be
static.
- Dynamic `seed` values are allowed because they are not recorded in the
dependency graph.
- Scope value pairs are used to override scope values while resolving a
dependency.

### Instance identity

- Bunja instance ids now include active optional dependency ids.
- This means a bunja can resolve to different instances depending on
which `bunja.will` branch is actually selected.
- Scopes used by active optional dependencies are reflected in the
consuming bunja instance identity.
- Inactive optional dependencies do not create or mount instances.

### Prebaking

- Added `store.prebake`.
- Prebake runs bunja init functions in a dry graph-collection mode.
- It does not create ref-counted instances, mount dependencies, or run
effects.
- It is intended for devtools/debugging cases where optional
`bunja.will` dependency graphs should be discovered ahead of time.
- Root seed is intentionally not accepted by `store.prebake`; default
seeds are used for deterministic graph collection.

### Graph metadata cleanup

- Renamed `relatedScopes` to `requiredScopes`.
- `relatedBunjas` is now derived from required and optional bunja
dependencies.
- Added explicit required/optional dependency tracking internally.
- Added circular dependency guards for both normal `store.get` and
`store.prebake`.

### Adapter updates

- React adapter now accepts bunja refs in `useBunja`.
- React 19 uses `React.use` for scoped context reads when available.
- React 18 falls back to reading all bound contexts and requires scopes
to be bound before rendering.
- Solid adapter now accepts bunja refs in `useBunja`.

### Removed

- Removed `bunja.fork`.
- Scope overrides should now use `bunja.use(dep, scopeValuePairs)` or
bunja refs.

v3.0.0-alpha.5

Toggle v3.0.0-alpha.5's commit message
Use undefined for unseeded bunjas

v3.0.0-alpha.4

Toggle v3.0.0-alpha.4's commit message
Fix scoped bunja dependency graph refs

v3.0.0-alpha.3

Toggle v3.0.0-alpha.3's commit message
Set npm dist tag for prereleases

v3.0.0-alpha.2

Toggle v3.0.0-alpha.2's commit message
Pin Deno to 2.7.13 in CI

v3.0.0-alpha.1

Toggle v3.0.0-alpha.1's commit message
Refine prebake graph collection

v2.1.1

Toggle v2.1.1's commit message
don't save store to devtools global hook

v2.1.0

Toggle v2.1.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
add repository info to package.json (#27)

v2.0.0

Toggle v2.0.0's commit message
v2 is stable now

v2.0.0-alpha.9

Toggle v2.0.0-alpha.9's commit message