Repository navigation
XState v6 - #5543
Open
davidkpiano wants to merge 578 commits into
Open
XState v6#5543davidkpiano wants to merge 578 commits into
davidkpiano wants to merge 578 commits into
Conversation
🦋 Changeset detectedLatest commit: 7c1eaff The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Closed
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
… next (#5786) * @xstate/store: port flushStorage, clearStorage and inspector fixes to next * fix(store): preserve cleared history across pure transitions and hydration
* Fix machine snapshot shape after initialization errors (#5678) * Version Packages (#5682) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fix Changesets packing with pnpm 10 (#5684) Changesets v3 invokes pnpm pack with --out, which pnpm 9 does not support. Upgrade the repository pin and refresh the pnpm 10 patch hash so frozen installs continue to work. * Add separate transition metadata typing (#5700) * Add distinct state and transition meta types * Use meta for state metadata typing * Update packages/core/src/setup.ts Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> * Preserve invoke transition metadata types --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> * Version Packages (#5710) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(core): widen the meta parameters of `AnyStateNode` and `AnyStateNodeDefinition` (#5712) * fix(core): widen the meta parameters of AnyStateNode and AnyStateNodeDefinition `StateNode` and `StateNodeDefinition` gained `TStateMeta` and `TTransitionMeta` in #5700. Both default to `MetaObject` rather than widening, so the aliases meant to stand for "a node of any machine" stopped covering the nodes of an `AnyStateMachine`, which have those parameters as `any`. Assignability hides this — `any` assigns in both directions — but tooling that tracks `any` does not: `@typescript-eslint`'s `no-unsafe-argument` and `no-unsafe-return` report every node read off an untyped machine. `AnyTransitionDefinition` was widened along with the new parameters in that same change; these two were missed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(core): widen the graph module's AnyStateNode too, and cover the transition slot `graph/types.ts` declared a second `AnyStateNode` with the same defect, which `toDirectedGraph` and `getStateNodes` consume and `graph/index.ts` re-exports. It now re-exports the core alias rather than restating it, so the two cannot drift apart again. The test asserted only the state metadata parameter. `TTransitionMeta` defaults to `TStateMeta`, so dropping it would be harmless, but writing `MetaObject` into that slot explicitly would not have been caught. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> * Version Packages (#5717) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(core): preserve arbitrary metadata in generic node containers (#5718) * fix(core): preserve arbitrary metadata in generic node containers * docs(core): clarify history value metadata documentation * Version Packages (#5720) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * @xstate/store 4.x: declare xstate as an optional peer; backport store fixes from next (#5760) * @xstate/store 4.x: declare xstate as an optional peer; backport store fixes from next Backports store-only fixes from #5697 (69b6663) and the useStore inspect option from #5683 (c57f80e). * Address review: drain flushStorage, restart event history on clear, commit-phase inspector * @xstate/store: preserve cleared history across pure transitions and pending effects (#5764) * Fix clearStorage history reset across pure transitions and pending effects * Invalidate pre-clear snapshot effects and stale rehydrate reads * feat(store): add source atoms with shared subscription lifecycle (#5782) * feat(store): add source atoms with shared subscription lifecycle * fix(store): recover source activation and async delivery errors * Version Packages (#5774) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Christian Rishøj <christian@rishoj.net> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Fix setup state inference with exact optional properties * Describe state inference without compiler flag details * Simplify user documentation around supported behavior
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Freeze machine context in development * Address review: freeze children of frozen context, keep root context on restore, keep __proto__ as data
* Rename executable action object types to executable effects * Clarify which renames the codemod covers
* Remove state inputs when their state exits * Document state input lifetime
* docs: explain transition functions and graph coverage * docs: normalize empty changeset * docs: clarify transition graph limitations
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
) * fix(core): matches() accepts state values with non-literal leaves * fix(core): keep matches() checking literal keys beside wide leaves TestStateValueCheck now validates per position: every literal key must name a state at its level and every literal child must match, while a non-literal leaf (string, or a map with string keys) passes only at its own position. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Ben Freed <ben.freed@mrocorp.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Deliver events to serialized actor refs by address
A serialized actor ref ({ xstate$type: 'actorRef', id, address }) used as an
enq.sendTo target now resolves by address to the live actor, or is reported
as a 'missingTarget' dead letter. Previously deliverEvent threw a TypeError
and the event was lost.
* Persist actor ref addresses in context so non-child refs route after restore
* Resolve serialized ref send targets at delivery and persist them in timers
* Deliver events to serialized actor refs by address
A serialized actor ref ({ xstate$type: 'actorRef', id, address }) used as an
enq.sendTo target now resolves by address to the live actor, or is reported
as a 'missingTarget' dead letter. Previously deliverEvent threw a TypeError
and the event was lost.
* Persist actor ref addresses in context so non-child refs route after restore
* Make built-in event and effect type strings consistent
- xstate.init and xstate.stop are events; @xstate.stop stays the stop effect
- Effect types use the @xstate. prefix (@xstate.cancelEffect, @xstate.cleanup,
@xstate.effect, @xstate.log); helper source keys are @xstate.listener and
@xstate.subscription, and user sources may not use either reserved prefix
- Remove legacy suffixed lifecycle event aliases (xstate.done.actor.<id> etc.)
- State timeout event is xstate.timeout.state
* Use one serialized actor identity shape
- Actor refs serialize and persist as { $actor: address } (SerializedActorRef,
with optional string incarnation); the pre-beta xstate$type shape still
restores
- System snapshot incarnations are strings; SystemActorState.logic is src;
ExecutionIdentity.systemId is executionId
- Persisted timers record scheduledAt (startedAt still restores)
- Persisted snapshots no longer mirror machine.version at the top level
- Effect descriptors use { $actor, incarnation? } actor fields; system
dead-letter effects use kind 'builtin' like effect descriptors
* Make the core public surface consistent
- serializeMachine/createMachineFromConfig are machineToJSON/machineFromJSON;
machineToJSON and machineConfigToJSON return MachineJSON
- createLogic and its Logic* types are createStepLogic and Step*; async
logic types are declared as AsyncLogic*; drop the LogicEffect alias
- EffectDescriptor/getEffectDescriptor are
ExecutableEffectDescriptor/describeExecutableEffect
- Remove listenerLogic/subscriptionLogic, __unsafe_getAllOwnEventDescriptors,
checkStateIn, pathToStateValue and SpecialTargets exports; toObserver is
the private _toObserver export
- Setup marker types use one *Marker naming and an experimental plumbing tag
- Remove the devTools?: never and React Provider machine shims
- State nodes declare context schemas with schemas.context
* Make adapter names consistent and add changesets
- @xstate/effect: fromEffect* are createEffectLogic, createEffectStreamLogic
and createEffectEventStreamLogic
- @xstate/test: createFailureDatabase/FailureDatabaseOptions are
createTestFailureStore/TestFailureStoreOptions, serializeTestSuite is
testSuiteToJSON, ModelTestFailure is ModelTestFailureError
- Migration guide lists names changed during the v6 prereleases
* Drop version from the stable persisted envelope fields
* Remove alpha-shape restore compatibility
* Use @xstate. keys for built-in JSON guards and reserve both prefixes for source names
* Accept '#id' state references in snapshot.matches
* Use xstate.init for the store's initial inspection event
* Resolve serialized ref send targets at delivery and persist them in timers
* Store pending timers as a list without generated ids
* Check a serialized ref's incarnation when delivering to it
* Revive only untargeted serialized refs in persisted context and document the reserved key
* Document what self.getSnapshot() returns during a transition
* Key built-in timers in event field order and re-arm checkpointed timers by key in the durable example
* Drop the last top-level persisted version compat path
* Use $error for portable errors in @xstate/test; note v5 actor ref shape
* Keep #id matches overload separate so value checks still infer
* Stop exporting pathToStateValue internally
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…@xstate/test surface, SCXML descriptors (#5808) * Require xstate peer in framework adapters * Keep useActorRef source updates off the caller's machine * Trim @xstate/test public exports * Accept Vitest 4 as an @xstate/test peer * Drop legacy suffix outcome checks in @xstate/test * Compile SCXML done descriptors to category types with matches * Add changesets for pre-beta package fixes * Remove unused withScheduledReference * Restore documented @xstate/test concurrency and trace exports * Port @xstate/test/effect-schema to stable Effect 4 * Match SCXML done.state descriptors by sanitized state id
…napshots, pure spawn refs, internal types (#5810) * Make ActorRefFrom accept actor logic only and remove ActorRefFromLogic * Require invoke input when the invoked logic requires input * Report malformed persisted snapshots as InvalidSnapshotError error snapshots * Return an inert actor ref from speculative enq.spawn * Stop exporting internal type helpers and the parent actor option * Restore inline invokes by invoke id instead of a synthetic source name * Derive implicit state and invoke ids from paths without the (machine) placeholder * Require an id on machines that declare a version * Type ActorRefFrom machine snapshots fully * Require escaped dots in state keys and reject all duplicate state ids * Type-check # targets against implicit state ids * Tag root parallel states with the machine id in @xstate/effect * Persist a source-less child as an inline invoke only when that invoke created it * Report an explicit null snapshot as InvalidSnapshotError * Predict speculative spawn ids with the committed allocator * Reject undefined as required invoke and spawn input * Complete partial restored state values from the resolved configuration * Document the limits of inline invoke persistence * Throw on bare string transition targets at machine creation
* Resolve # targets by exact id only * Scope codemod id checks per machine config; scan template literals; clarify route id docs
* docs(core): ship v6 docs with the npm package * fix(core): keep documentation links usable before build
…ck (#5817) * test(graph): cover transition evaluation diagnostics * fix(graph): explain transition evaluation failures * test: reproduce v6 invoke input and schema context typing bugs * fix: preserve v6 schema context and invoke input mapper types * test: reproduce queued sender and inspection observer failures * fix: retain queued event sources and isolate inspection errors * test: reproduce swallowed transition enqueue effects * test: cover speculative enqueue and parent relay isolation * fix: preserve queued transition effects during selection * test: preserve caught spawn detection across nested can * test(core): keep enqueue validation catchable during selection * fix(core): preserve enqueue validation and document alpha fixes
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat(core): observe emissions across an actor system * fix(core): release pending system subscriptions Addresses review finding: "Canceled emission listeners remain in memory".
# Conflicts: # CONTRIBUTING.md # README.md # package.json # packages/core/CHANGELOG.md # packages/core/package.json # packages/core/src/State.ts # packages/core/src/StateMachine.ts # packages/core/src/StateNode.ts # packages/core/src/createMachine.ts # packages/core/src/graph/types.ts # packages/core/src/setup.ts # packages/core/src/stateUtils.ts # packages/core/src/types.ts # packages/core/test/input.test.ts # packages/core/test/meta.test.ts # packages/core/test/types.test.ts # packages/core/test/waitFor.test.ts # packages/xstate-store-react/CHANGELOG.md # packages/xstate-store-react/README.md # packages/xstate-store-react/package.json # packages/xstate-store-react/src/index.test.tsx # packages/xstate-store-react/src/index.ts # packages/xstate-store-solid/CHANGELOG.md # packages/xstate-store-solid/README.md # packages/xstate-store-solid/package.json # packages/xstate-store/CHANGELOG.md # packages/xstate-store/README.md # packages/xstate-store/package.json # packages/xstate-store/src/atom.ts # packages/xstate-store/src/index.ts # packages/xstate-store/src/persist.ts # packages/xstate-store/test/persist.test.ts # packages/xstate-svelte/CHANGELOG.md # packages/xstate-svelte/package.json # packages/xstate-svelte/src/useActor.ts # packages/xstate-vue/CHANGELOG.md # packages/xstate-vue/package.json # packages/xstate-vue/src/useSelector.ts # pnpm-lock.yaml # scripts/ensure-pnpm.js
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moved from #5257