From f5c5328b8376b400b9a68bedcca8d6faf08e5a72 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 31 Jul 2026 17:50:39 +0000 Subject: [PATCH] Version Packages (alpha) --- .changeset/pre.json | 3 ++ packages/core/CHANGELOG.md | 68 ++++++++++++++++++++++++++++++++++++++ packages/core/package.json | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 3ecea3e3a7..6462f536d6 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -77,6 +77,7 @@ "clear-source-names", "codemod-migrate-cli", "deferred-child-start", + "delayed-transition-context-patch", "durable-logic-effects", "eager-timeouts-delays", "eleven-functions-inline", @@ -104,6 +105,7 @@ "persist-state-input", "plain-targets", "portable-code-serialization", + "proud-states-schemas", "proud-timers-migrate", "provide-actor-variance", "public-effect-introspection", @@ -131,6 +133,7 @@ "store-is-atom", "swift-invoke-stops", "swift-send-typing", + "tidy-transition-arrays", "timeout-receives-input", "type-only-schemas", "typed-invoke-targets", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 17dc77f2cf..ae0503a8e0 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,73 @@ # xstate +## 6.0.0-alpha.26 + +### Patch Changes + +- d46fbd2: Delayed transitions (`onTimeout` and `after`) and error transitions (`onError`) in machines created with `setup({ states })` now type the `context` patch against the **target** state's context schema, matching the behavior of `on:` transitions. Previously, a cross-state context patch that was valid at runtime failed to typecheck: + + ```ts + const machine = setup({ + schemas: { + context: z.object({ reason: z.union([z.literal('timeout'), z.null()]) }) + }, + states: { + running: { schemas: { context: z.object({ reason: z.null() }) } }, + expired: { + schemas: { context: z.object({ reason: z.literal('timeout') }) } + } + } + }).createMachine({ + context: { reason: null }, + initial: 'running', + states: { + running: { + timeout: 5000, + // Previously a type error; now checked against `expired`'s context + onTimeout: () => ({ + target: 'expired', + context: { reason: 'timeout' as const } + }) + }, + expired: { type: 'final' } + } + }); + ``` + +- d9d9e29: Per-state schemas declared in `setup({ states })` are now available on the compiled machine's state nodes via `machine.states.X.schemas`, so tooling (e.g. per-state snapshot validators) can be derived from the machine alone. Previously they were only accessible on the setup return value. + + ```ts + import { setup, types } from 'xstate'; + + const machine = setup({ + states: { + running: { + schemas: { context: types<{ startedAt: number }>() } + } + } + }).createMachine({ + initial: 'running', + states: { + running: {} + } + }); + + machine.states.running.schemas?.context; // the schema declared in setup + ``` + +- 7da1486: Transition arrays are no longer accepted by the v6 `createMachine(...)` authoring API. Use a transition function to select among targets: + + ```ts + createMachine({ + always: ({ context }) => { + if (context.hour < 12) return { target: 'morning' }; + return { target: 'afternoon' }; + } + }); + ``` + + Serialized transition arrays remain supported by `createMachineFromConfig(...)`. + ## 6.0.0-alpha.25 ### Major Changes diff --git a/packages/core/package.json b/packages/core/package.json index 060b3a6f6b..d890d27b2b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "xstate", - "version": "6.0.0-alpha.25", + "version": "6.0.0-alpha.26", "description": "Finite State Machines and Statecharts for the Modern Web.", "main": "dist/xstate.cjs.js", "bin": {