Skip to content

3.1.0

Choose a tag to compare

@unadlib unadlib released this 19 Jul 17:18
· 145 commits to main since this release

Coaction 3.1.0

Coaction 3.1.0 introduces an authoritative patch commit/replay bridge for adapter authors and rebuilds @coaction/history around the controlled journal API in Travels 2.1.

The result is patch-sized history storage, substantially less duplicated work, and undo/redo that continues to flow through Coaction’s validation, middleware, adapter, subscription, and transport pipeline.

Highlights

Travels-powered history

@coaction/history now uses Travels 2.1 as its timeline engine for JSON-compatible state.

  • Whole-store commits hand Coaction’s existing patch pair directly to recordPatches().
  • Partialized histories derive one patch pair over the tracked projection.
  • Undo and redo are delegated through the controlled Travels journal.
  • History storage scales with recorded changes instead of full-state snapshots.
  • The Travels 2.0 compatibility path and its additional replay, rollback, and journal-rebuild work have been removed.

Existing compatibility behavior remains available for runtime-only state such as circular or shared graphs, Date, sparse arrays, symbol keys, and custom prototypes. If tracked state becomes non-JSON-compatible, the current patch timeline is materialized once and
recording continues with snapshots.

Patch-native history access

@coaction/history adds getPatches() for direct access to the compact timeline:

const timeline = store.history.getPatches();

if (timeline) {
  const { patches, inversePatches, position } = timeline;
}

getPast() and getFuture() remain available, but now materialize compatibility snapshots only when requested.

New adapter integration APIs

The following APIs are now exported from coaction/adapter:

  • onStoreCommit()
  • onStoreCommitPrepare()
  • replayStorePatches()

They allow external runtimes to observe authoritative patch pairs and replay transitions through Coaction without taking ownership of a second state timeline.

Direct root replacements now publish commit events, and replay can preserve a middleware-scoped setState boundary.

Core fixes and performance work

  • Shared store-readiness metadata across the root, local, shared, and adapter entry bundles.
  • Fixed missed readiness callbacks when applications mix Coaction entry points.
  • Preserved circular, shared, and other non-tree local object graphs when publishing replacement commits.
  • Skipped commit-prepare work for scalar transitions while retaining exact replacement preparation for object graphs.
  • Preserved the direct core apply fast path during history navigation.

Worker integration coverage

Real-browser SharedWorker and Web Worker coverage has been added for:

  • Angular
  • Jotai
  • MobX
  • Pinia
  • React
  • Solid
  • Svelte
  • Valtio
  • Vue
  • Zustand

The new coverage validates cross-page synchronization, async client actions, framework-specific reactive updates, and safe remote error redaction.

Documentation

  • Expanded the @coaction/history documentation with its patch API, partialized history behavior, persistence shape, and compatibility rules.
  • Refined the Chinese homepage positioning around fine-grained state tracking and precise UI rendering.

Upgrade notes

All official Coaction packages move together to 3.1.0, and their Coaction peer ranges now require ^3.1.0. Update the core package and every installed @coaction/* integration together.

For example:

pnpm up coaction@^3.1.0 @coaction/history@^3.1.0

@coaction/history now requires travels@^2.1.0. Package managers install it automatically, but existing lockfiles pinned to Travels 2.0 must be refreshed.

Existing store definitions do not require migration.

Full Changelog: v3.0.0...v3.1.0