xstate 6.0.0-beta.1 → 6.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/{createActor-551369be.development.esm.js → createActor-0250284a.development.esm.js} +244 -41
  2. package/dist/{createActor-cbe3abac.esm.js → createActor-20a97166.esm.js} +243 -40
  3. package/dist/{createActor-a49ae0ce.development.cjs.js → createActor-c029d29f.development.cjs.js} +245 -40
  4. package/dist/{createActor-25900f76.cjs.js → createActor-c91c9ffe.cjs.js} +244 -39
  5. package/dist/declarations/src/createActor.d.ts +3 -1
  6. package/dist/declarations/src/createMachine.d.ts +6 -3
  7. package/dist/declarations/src/durable/index.d.ts +43 -8
  8. package/dist/declarations/src/effectDescriptor.d.ts +2 -2
  9. package/dist/declarations/src/machineVersion.types.d.ts +2 -2
  10. package/dist/declarations/src/setup.d.ts +2 -2
  11. package/dist/declarations/src/systemTransition.d.ts +1 -1
  12. package/dist/declarations/src/types.d.ts +4 -2
  13. package/dist/declarations/src/types.v6.d.ts +37 -2
  14. package/dist/{effectDescriptor-f73da4ec.development.cjs.js → effectDescriptor-3fff5c51.development.cjs.js} +5 -5
  15. package/dist/{effectDescriptor-2fa27c54.cjs.js → effectDescriptor-47f73e7e.cjs.js} +5 -5
  16. package/dist/{effectDescriptor-321a8ce9.development.esm.js → effectDescriptor-5ac7dccb.development.esm.js} +5 -5
  17. package/dist/{effectDescriptor-d8b0f749.esm.js → effectDescriptor-e93df910.esm.js} +5 -5
  18. package/dist/{machineSchemas-88d01821.cjs.js → legacySnapshot-8d595687.cjs.js} +117 -1
  19. package/dist/{machineSchemas-45c21bc2.esm.js → legacySnapshot-9e06feb4.esm.js} +116 -2
  20. package/dist/{machineSchemas-b5736804.development.esm.js → legacySnapshot-ae6594a7.development.esm.js} +117 -3
  21. package/dist/{machineSchemas-6d96bef4.development.cjs.js → legacySnapshot-ebf0b2b8.development.cjs.js} +118 -2
  22. package/dist/xstate-actors.cjs.js +1 -1
  23. package/dist/xstate-actors.development.cjs.js +1 -1
  24. package/dist/xstate-actors.development.esm.js +2 -2
  25. package/dist/xstate-actors.esm.js +2 -2
  26. package/dist/xstate-actors.umd.min.js +1 -1
  27. package/dist/xstate-actors.umd.min.js.map +1 -1
  28. package/dist/xstate-durable.cjs.js +120 -10
  29. package/dist/xstate-durable.development.cjs.js +120 -10
  30. package/dist/xstate-durable.development.esm.js +120 -10
  31. package/dist/xstate-durable.esm.js +120 -10
  32. package/dist/xstate-durable.umd.min.js +1 -1
  33. package/dist/xstate-durable.umd.min.js.map +1 -1
  34. package/dist/xstate-fsm.cjs.js +4 -4
  35. package/dist/xstate-fsm.development.cjs.js +4 -4
  36. package/dist/xstate-fsm.development.esm.js +4 -4
  37. package/dist/xstate-fsm.esm.js +4 -4
  38. package/dist/xstate-fsm.umd.min.js +1 -1
  39. package/dist/xstate-fsm.umd.min.js.map +1 -1
  40. package/dist/xstate-graph.cjs.js +1 -1
  41. package/dist/xstate-graph.development.cjs.js +1 -1
  42. package/dist/xstate-graph.development.esm.js +2 -2
  43. package/dist/xstate-graph.esm.js +2 -2
  44. package/dist/xstate-graph.umd.min.js +1 -1
  45. package/dist/xstate-graph.umd.min.js.map +1 -1
  46. package/dist/xstate-persist.cjs.js +23 -12
  47. package/dist/xstate-persist.development.cjs.js +23 -12
  48. package/dist/xstate-persist.development.esm.js +17 -6
  49. package/dist/xstate-persist.esm.js +17 -6
  50. package/dist/xstate-persist.umd.min.js +1 -1
  51. package/dist/xstate-persist.umd.min.js.map +1 -1
  52. package/dist/xstate-validation.cjs.js +1 -1
  53. package/dist/xstate-validation.development.cjs.js +1 -1
  54. package/dist/xstate-validation.development.esm.js +1 -1
  55. package/dist/xstate-validation.esm.js +1 -1
  56. package/dist/xstate.cjs.js +63 -51
  57. package/dist/xstate.development.cjs.js +63 -51
  58. package/dist/xstate.development.esm.js +53 -41
  59. package/dist/xstate.esm.js +53 -41
  60. package/dist/xstate.umd.min.js +1 -1
  61. package/dist/xstate.umd.min.js.map +1 -1
  62. package/docs/api-stability.json +267 -249
  63. package/docs/backend-workflows.md +3 -3
  64. package/docs/durable-execution.md +72 -48
  65. package/docs/errors.md +2 -2
  66. package/docs/examples.md +34 -34
  67. package/docs/fsm.md +2 -1
  68. package/docs/guards.md +1 -1
  69. package/docs/index.md +1 -1
  70. package/docs/invoke.md +34 -2
  71. package/docs/persistence.md +16 -10
  72. package/docs/serialization.md +1 -1
  73. package/docs/setup-and-provide.md +3 -3
  74. package/docs/spawn.md +1 -1
  75. package/docs/system-transitions.md +6 -6
  76. package/docs/tutorial.md +5 -5
  77. package/docs/typescript.md +9 -0
  78. package/docs/xstate-v5-to-v6.md +17 -17
  79. package/package.json +1 -1
@@ -85,7 +85,7 @@ const machine = machineFromJSON(definition, {
85
85
 
86
86
  The second argument supplies the runtime sources the definition refers to: `actions`, `guards`, `actors`, `delays`, and `evaluators` for code expressions. Invokes keep their string `src` names, so a machine built this way can be cloned with different actors through [`provide()`](setup-and-provide.md), including when restoring its children. Deserialization still requires an implementation for every referenced actor; provide the initial implementations in the second argument, then override them by name.
87
87
 
88
- Actions in JSON are objects. The built-in vocabulary is `{ type: '@xstate.raise', event, id?, delay? }`, `{ type: '@xstate.emit', event }`, `{ type: '@xstate.assign', context }`, `{ type: '@xstate.cancel', id }` and `{ type: '@xstate.log', args }`. Any other `{ type, params }` object is a custom action resolved against the `actions` sources. Guards are `{ type, params? }` references resolved against `guards`. Two guard types are built in: `{ type: '@xstate.not', params: { guard } }` negates another guard reference or expression, and `{ type: '@xstate.stateIn', params: { stateId: '#id' } }` is true while the state node with that `id` is active (the same check as `snapshot.matches('#id')`). Source names, and the names of `actions`, `guards` and `delays` defined in the JSON, may not start with `xstate.` or `@xstate.`; those prefixes are reserved for built-in names. Because the runtime invokes these references itself, a JSON-referenced guard receives the transition arguments object first and the declared `params` second — unlike code-authored machines, where guards are plain functions called by your own transition code.
88
+ Actions in JSON are objects. The built-in vocabulary is `{ type: '@xstate.raise', event, id?, delay? }`, `{ type: '@xstate.emit', event }`, `{ type: '@xstate.assign', context }`, `{ type: '@xstate.cancel', id }` and `{ type: '@xstate.log', args }`. Any other `{ type, params }` object is a custom action resolved against the `actions` sources. Guards are `{ type, params? }` references resolved against `guards`. Two guard types are built in: `{ type: '@xstate.not', params: { guard } }` negates another guard reference or expression, and `{ type: '@xstate.stateIn', params: { stateId: '#id' } }` is true while the state node with that `id` is active (the same check as `snapshot.matches('#id')`). Source names, and the names of `actions`, `guards` and `delays` defined in the JSON, may not start with `xstate.` or `@xstate.`; those prefixes are reserved for built-in names. Because the runtime invokes these references itself, a JSON-referenced guard receives the transition arguments object first and the declared `params` second. This differs from code-authored machines, where guards are plain functions called by your own transition code.
89
89
 
90
90
  Machines built from JSON round-trip losslessly. The loader copies the definition, and each serialization returns a fresh copy. Mutating either copy does not change the machine.
91
91
 
@@ -140,8 +140,8 @@ Validation can be installed, replaced or disabled by a derived setup. Installing
140
140
 
141
141
  Where a validation failure surfaces depends on which side of the delivery boundary produced the invalid value:
142
142
 
143
- - **Events arriving from outside the actor** — from `actor.send` or from another actor — are rejected at the boundary when their payload fails its schema, or when the event type is undeclared and `unknownEvents` is `'error'`. The event is never delivered: the actor does not transition, does not error, and no API throws. The rejection is reported to the `onRejectedEvent` dead-letter hook on `createActor` options and as a development-mode console warning. In pure `transition(...)` calls, the snapshot is returned unchanged together with a `@xstate.deadLetter` effect carrying the rejection.
144
- - **Values the actor produces itself** — input, context, output, emitted events and delayed raised events — error the actor when they fail their schema, and pure `transition(...)`/`initialTransition(...)` throw an `ActorValidationError`. These are machine bugs.
143
+ - **Events arriving from outside the actor** (from `actor.send` or from another actor) are rejected at the boundary when their payload fails its schema, or when the event type is undeclared and `unknownEvents` is `'error'`. The event is never delivered: the actor does not transition, does not error, and no API throws. The rejection is reported to the `onRejectedEvent` dead-letter hook on `createActor` options and as a development-mode console warning. In pure `transition(...)` calls, the snapshot is returned unchanged together with a `@xstate.deadLetter` effect carrying the rejection.
144
+ - **Values the actor produces itself** (input, context, output, emitted events and delayed raised events) error the actor when they fail their schema, and pure `transition(...)`/`initialTransition(...)` throw an `ActorValidationError`. These are machine bugs.
145
145
 
146
146
  ## Sources on the machine
147
147
 
@@ -175,7 +175,7 @@ idle: {
175
175
  }
176
176
  ```
177
177
 
178
- Named actions and guards are plain functions called with only their params — nothing is injected. Pass values from `context` or the event explicitly. Declare param types on the function itself, or with `schemas.actions` and `schemas.guards` so the params are checked before the implementations exist:
178
+ Named actions and guards are plain functions called with only their params. Nothing is injected. Pass values from `context` or the event explicitly. Declare param types on the function itself, or with `schemas.actions` and `schemas.guards` so the params are checked before the implementations exist:
179
179
 
180
180
  ```ts
181
181
  setup({
package/docs/spawn.md CHANGED
@@ -46,7 +46,7 @@ The name is checked against `actors`; its required input and returned actor refe
46
46
 
47
47
  Passing the logic value remains convenient: `enq.spawn(actors.upload, options)`. XState recovers its registered name when possible. Inline unregistered logic may run but cannot be durably persisted.
48
48
 
49
- Spawning with an `id` that a live child of the same parent already uses throws: an address names at most one live actor. Stop the existing child first — an id stopped earlier in the same transition is free to reuse, and a child that completed on its own frees its id for the transition handling its completion. Generate ids from something stable, such as a file or participant id.
49
+ Spawning with an `id` that a live child of the same parent already uses throws: an address names at most one live actor. Stop the existing child first. An id stopped earlier in the same transition is free to reuse, and a child that completed on its own frees its id for the transition handling its completion. Generate ids from something stable, such as a file or participant id.
50
50
 
51
51
  ## Where you can spawn
52
52
 
@@ -67,8 +67,8 @@ actor's macrostep. Microsteps are atomic; system snapshots contain no unfinished
67
67
  microstep or continuation state. A UI presenting individual completed
68
68
  microsteps within a macrostep needs a separate tracing interface.
69
69
 
70
- Snapshot actor references are data: `{ $actor, incarnation }`, the same shape as `SerializedActorRef`, with a string `incarnation`. Use `$actor`
71
- as `actorPath`, for example `snapshot.actors[snapshot.root].snapshot.children.worker.$actor`.
70
+ Snapshot actor references are data: `{ '@actor': address, incarnation }`, the same shape as `SerializedActorRef`, with a string `incarnation`. Use `@actor`
71
+ as `actorPath`, for example `snapshot.actors[snapshot.root].snapshot.children.worker["@actor"]`.
72
72
  Paths encode IDs; avoid concatenating unescaped IDs. Replacing an actor at the
73
73
  same path allocates a fresh incarnation.
74
74
 
@@ -101,7 +101,7 @@ Select a pending timer in a simulator with its current occurrence:
101
101
 
102
102
  ```ts
103
103
  const selected = snapshot.timers.find((timer) => timer.dueAt === 6000)!;
104
- const [next] = systemTransition(systemLogic, snapshot, selected.source.$actor, {
104
+ const [next] = systemTransition(systemLogic, snapshot, selected.source["@actor"], {
105
105
  type: 'xstate.timer',
106
106
  occurrence: selected.occurrence
107
107
  });
@@ -128,7 +128,7 @@ using the source actor's definition and saved input; the host owns the
128
128
  external implementation. Its result reenters as a correlated input:
129
129
 
130
130
  ```ts
131
- const [resolved] = systemTransition(systemLogic, pendingSnapshot, effect.source.$actor, {
131
+ const [resolved] = systemTransition(systemLogic, pendingSnapshot, effect.source["@actor"], {
132
132
  type: 'xstate.system.effect.result',
133
133
  effectId: effect.id,
134
134
  event: { type: 'xstate.async.resolve', data: result }
@@ -150,8 +150,8 @@ input, outputs, events and effect arguments are JSON-compatible. Actor reference
150
150
  state-node references, errors and named mappers use data markers. Errors retain
151
151
  name/message. Undefined properties follow ordinary JSON rules. Cycles,
152
152
  unregistered functions, live actors, class instances, symbols, bigint and
153
- nonfinite numbers are rejected. `$actor`, `$stateNode`, `$error` and
154
- `$systemMapper` marker shapes are reserved. Logic versions must match on replay.
153
+ nonfinite numbers are rejected. `@actor`, `@stateNode`, `@error` and
154
+ `@systemMapper` marker shapes are reserved. Logic versions must match on replay.
155
155
 
156
156
  Transition functions, guards and mappers must be deterministic and pure.
157
157
  Read external values from input/events and virtual time from `system._clock.now()`.
package/docs/tutorial.md CHANGED
@@ -430,7 +430,7 @@ Nothing about the machine changes. A UI reads snapshots and sends events.
430
430
 
431
431
  ```html
432
432
  <p id="status">stopped</p>
433
- <p id="title">—</p>
433
+ <p id="title"></p>
434
434
  <button id="play">Play</button> <button id="pause">Pause</button>
435
435
  <button id="stop">Stop</button> <button id="previous">Previous</button>
436
436
  <button id="next">Next</button> <button id="mute">Mute</button>
@@ -475,7 +475,7 @@ Frameworks work the same way, with a hook or store binding instead of manual sub
475
475
 
476
476
  You built one machine with context, guards, invoked async logic, hierarchy, parallel regions, delayed events, emitted events and a UI. From here:
477
477
 
478
- - [Statecharts](statecharts.md) — nested, parallel and history states
479
- - [Actors](actors.md) — spawning, communication and actor systems
480
- - [Frameworks](frameworks.md) — bindings for React, Vue, Svelte and Solid
481
- - [Testing](testing.md) — testing machines and the actors that run them
478
+ - [Statecharts](statecharts.md): nested, parallel and history states
479
+ - [Actors](actors.md): spawning, communication and actor systems
480
+ - [Frameworks](frameworks.md): bindings for React, Vue, Svelte and Solid
481
+ - [Testing](testing.md): testing machines and the actors that run them
@@ -49,6 +49,12 @@ adding explicit type annotations.
49
49
 
50
50
  For an actor used in one state, `invoke: s.createInvoke({ src, input, onDone })` infers input and completion output from `src`. Keep the helper inline in `s.createMachine(...)` to also infer that state's narrowed context, ancestor context, state input and transition target requirements. The helper works alongside named actor sources. See [typed inline invokes](invoke.md#typed-inline-invokes).
51
51
 
52
+ A bare inline `invoke: { src: logic, onDone }` cannot correlate its source with
53
+ the output; with no registered actor sources it has `event.output: unknown`.
54
+ Use `s.createInvoke(...)` or a source registered in `setup({ actors })` when
55
+ reading the output. This is especially important for generated machine code:
56
+ the bare form cannot infer the output type from `src`.
57
+
52
58
  An async function can be used directly as `src`. Declare `schemas.input`, `schemas.output`, and `schemas.error` on the invoke to type the function and its lifecycle handlers together. Without `schemas.output`, `onDone.event.output` infers from the async return value.
53
59
 
54
60
  Public schema event keys create typed methods on `actor.trigger`; internal
@@ -84,6 +90,9 @@ When `schemas.events` is declared, each key in an `on` map must match a
84
90
  declared event type. Matching wildcards (`'*'`, `'user.*'`) and known reserved
85
91
  machine descriptors are allowed; misspelled or invented reserved prefixes are rejected. Without `schemas.events`, any key is accepted.
86
92
 
93
+ An empty `schemas.events: {}` means the machine has no public events. Final
94
+ state output callbacks still receive the declared context and input types.
95
+
87
96
  ```ts
88
97
  on: {
89
98
  toggel: { target: 'active' }
@@ -79,12 +79,12 @@ Beyond simplifying the action/guard surface, v6 introduces a number of features
79
79
 
80
80
  ## 1. Inline functions replace action creators
81
81
 
82
- This is the largest change. Action creators (`assign`, `raise`, `sendTo`, `emit`, `log`, `cancel`, `enqueueActions`, `spawnChild`, `stopChild`, `forwardTo`, `sendParent`) are **no longer exported**.
82
+ This is the largest change. Action creators (`assign`, `raise`, `sendTo`, `emit`, `log`, `cancel`, `enqueueActions`, `spawnChild`, `stopChild`, `forwardTo`, `sendParent`) are no longer exported.
83
83
 
84
- In v6, every `entry`, `exit`, and transition handler is a **single function** that receives `(args, enq)` where `enq` is a queue of side effects. The function can also **return** an object that the engine applies after it runs:
84
+ In v6, every `entry`, `exit`, and transition handler is a **single function** that receives `(args, enq)` where `enq` is a queue of side effects. The function can also return an object that the engine applies after it runs:
85
85
 
86
86
  - **Transition handlers** (`on`, `always`, `after`, `onTimeout`, `onDone`, `onError`) - may return a target, a new `context`, `reenter`, or `meta`.
87
- - **Entry / exit actions** - may return a new `context` (or `children`). They **cannot** return a `target`; entry/exit cannot transition.
87
+ - **Entry / exit actions** - may return a new `context` (or `children`). They cannot return a `target`; entry/exit cannot transition.
88
88
 
89
89
  Returned `context` values are patches. XState merges a patch into the current context at the top level (`{ ...context, ...patch }`): omitted keys keep their current values, and a nested object in the patch replaces the current value of that key. If a transition targets a state with a narrower `schemas.context`, the patch type requires the keys needed to satisfy that state's context.
90
90
 
@@ -241,7 +241,7 @@ An **entry / exit action** may return:
241
241
  | `context` | shallow context patch |
242
242
  | `children` | replacement children record |
243
243
 
244
- Returning nothing (`undefined`) means "no changes". For transition handlers specifically, returning nothing without calling `enq` also means **the event is treated as unhandled at this state** - useful for inline guarding. A handler that calls `enq` is taken even when it returns nothing, so check the condition first:
244
+ Returning nothing (`undefined`) means "no changes". For transition handlers specifically, returning nothing without calling `enq` also means the event is treated as unhandled at this state - useful for inline guarding. A handler that calls `enq` is taken even when it returns nothing, so check the condition first:
245
245
 
246
246
  ```ts
247
247
  // v6 - guard inline by returning undefined
@@ -306,8 +306,8 @@ runs, because the two exit sets no longer overlap.
306
306
  ```ts
307
307
  // Parallel state `p` with regions `a` and `b`.
308
308
  // Event `t`: `a` reenters itself; `b.b1` moves to `b.b2`.
309
- // v5 after `t`: { a: 'a1', b: 'b1' } — `b` was reset when `p` was exited.
310
- // v6 after `t`: { a: 'a1', b: 'b2' } — only `a` was exited.
309
+ // v5 after `t`: { a: 'a1', b: 'b1' }: `b` was reset when `p` was exited.
310
+ // v6 after `t`: { a: 'a1', b: 'b2' }: only `a` was exited.
311
311
  ```
312
312
 
313
313
  Reset the sibling regions explicitly if the v5 behavior was intended: target
@@ -737,7 +737,7 @@ const fetchUser = createAsyncLogic({
737
737
  });
738
738
  ```
739
739
 
740
- `enq.step(key, exec)` records each step's outcome on the snapshot under `effects[key]`, so on rehydration the step is **not re-executed** - the previous result is replayed. This makes async logic durable across restarts.
740
+ `enq.step(key, exec)` records each step's outcome on the snapshot under `effects[key]`, so on rehydration the step is not re-executed - the previous result is replayed. This makes async logic durable across restarts.
741
741
 
742
742
  When `timeout` elapses, the logic aborts and rejects with `TimeoutError` (also exported):
743
743
 
@@ -942,8 +942,8 @@ on: {
942
942
 
943
943
  ## 12. Internal events
944
944
 
945
- Events declared in `schemas.internalEvents` can be **raised** internally but
946
- are **rejected** by the public actor protocol. Wildcard patterns are supported.
945
+ Events declared in `schemas.internalEvents` can be raised internally but
946
+ are rejected by the public actor protocol. Wildcard patterns are supported.
947
947
 
948
948
  ```ts
949
949
  const machine = createMachine({
@@ -1014,7 +1014,7 @@ states: {
1014
1014
 
1015
1015
  The function must resolve to a target - returning `undefined` throws "must resolve to a target".
1016
1016
 
1017
- Choice states are entered automatically by routing **into** them. They cannot themselves declare `invoke`, `after`, `on`, or `entry`/`exit` (machine creation rejects these).
1017
+ Choice states are entered automatically by routing into them. They cannot themselves declare `invoke`, `after`, `on`, or `entry`/`exit` (machine creation rejects these).
1018
1018
 
1019
1019
  ---
1020
1020
 
@@ -1046,7 +1046,7 @@ State `timeout` and `createAsyncLogic({ timeout })` accept `number` (ms) or `str
1046
1046
  | Seconds | `'5s'`, `'1.5s'` | integer or decimal + `s` suffix |
1047
1047
  | ISO 8601 duration | `'PT5S'`, `'PT1M30S'`, `'PT2H'`, `'P1D'`, `'P1W'`, `'P1DT12H'` | always starts with `P` |
1048
1048
 
1049
- Plain `'5m'`, `'1h'`, `'1d'`, `'1w'` (without the `P`/`PT` prefix) are **not** accepted - use the ISO 8601 form for anything beyond seconds and milliseconds.
1049
+ Plain `'5m'`, `'1h'`, `'1d'`, `'1w'` (without the `P`/`PT` prefix) are not accepted - use the ISO 8601 form for anything beyond seconds and milliseconds.
1050
1050
 
1051
1051
  `after` delays accept the same duration formats. A string delay is resolved against the machine's named `delays` first; only strings that don't match a named delay are parsed as durations.
1052
1052
 
@@ -1089,7 +1089,7 @@ loop until the process ran out of memory.
1089
1089
 
1090
1090
  <!-- exports removed from and added to packages/core/src/index.ts on the v6 branch (relative to main / v5) -->
1091
1091
 
1092
- These exports have been **removed** from `xstate`:
1092
+ These exports have been removed from `xstate`:
1093
1093
 
1094
1094
  - Action creators (entire `actions.ts` module): `assign`, `raise`, `sendTo`, `sendParent`, `forwardTo`, `emit`, `log`, `cancel`, `enqueueActions`, `spawnChild`, `stopChild`, `stop`, plus their `*Action`/`*Params` types
1095
1095
  - Guard combinators and helpers: `and`, `or`, `not`, `stateIn`
@@ -1116,7 +1116,7 @@ These exports have been **removed** from `xstate`:
1116
1116
 
1117
1117
  `SetupReturn`, the type returned by `setup(...)`, is still exported, but its type parameters changed, so a v5 `SetupReturn<TContext, TEvent, ...>` annotation no longer type-checks. Use `typeof yourSetup` to name the type of a specific setup.
1118
1118
 
1119
- These exports have been **added**:
1119
+ These exports have been added:
1120
1120
 
1121
1121
  - `setup` (reshaped - see §4) and `createSystem` for typed system registries
1122
1122
  - Setup state contract types: `SetupStateSchema`, `SetupStateSchemas`, `SetupStateType`
@@ -1275,7 +1275,7 @@ on: {
1275
1275
 
1276
1276
  ## 20. Persistence / rehydration
1277
1277
 
1278
- Persisted snapshots round-trip through `JSON.stringify` and rehydrate via `restoreActor(machine, persisted)` from `xstate/persist`. The internal shape changed, so v5 persisted snapshots are **not** binary-compatible with v6 - drain or migrate stored state during your rollout.
1278
+ Persisted snapshots round-trip through `JSON.stringify` and rehydrate via `restoreActor(machine, persisted)` from `xstate/persist`. The internal shape changed, so v5 persisted snapshots are not binary-compatible with v6 - drain or migrate stored state during your rollout.
1279
1279
 
1280
1280
  ```ts
1281
1281
  import { restoreActor } from 'xstate/persist';
@@ -1296,7 +1296,7 @@ Child actors, async logic with effects, and listener-resume semantics are all pa
1296
1296
 
1297
1297
  The host serializes the payload. Development builds warn when `context`, `output`, `error`, or state input holds a value that does not survive a JSON round-trip: functions, symbols, `BigInt`, `Map`, `Set`, cycles, `NaN`, and `Infinity`. Persisting a snapshot whose `context` contains a circular reference throws an error that names the actor and the context path. See [Persistence](persistence.md) for the format rules.
1298
1298
 
1299
- Actor refs in persisted `context` are stored as `{ "$actor": "<address>" }`. v5 stored them as `{ "xstate$$type": 1, "id": "<id>" }`; v6 does not read that shape, so convert those entries with [`machineVersions`](persistence.md#migrate-machine-versions) before restoring v5 snapshots.
1299
+ Actor refs in persisted `context` are stored as `{ "@actor": "<address>" }`. v5 stored them as `{ "xstate$$type": 1, "id": "<id>" }`; v6 does not read that shape, so convert those entries with [`machineVersions`](persistence.md#migrate-machine-versions) before restoring v5 snapshots.
1300
1300
 
1301
1301
  ### Snapshot versioning
1302
1302
 
@@ -1752,7 +1752,7 @@ A diff that matches a known v6 change is classified with a rule instead of `uncl
1752
1752
  | --- | --- |
1753
1753
  | `anonymous-child-id` | Child or send-target ids that differ only by a generated suffix. |
1754
1754
  | `error-string-shape` | Error strings with the same message after the prefix is removed. |
1755
- | `context-reference` | `context` that is equal after removing actor-reference keys (`$actor`). |
1755
+ | `context-reference` | `context` that is equal after removing actor-reference keys (`@actor`). |
1756
1756
  | `done-event-session` | Processed events that are equal after dropping `sessionId`. |
1757
1757
  | `final-state-output` | `output` that is undefined in v5 and set in v6, because v6 uses a top-level final state's `output` when the root has none (see [Machine output](#machine-output)). |
1758
1758
  | `root-send-parent` | `status` and `error` where v5 errored with `Unable to send event to actor '#_parent'` and v6 did not, because v6 makes a send to a missing parent a dead letter (see [Sending to a missing target](#sending-to-a-missing-target)). Later fields of that step, such as `value`, can still differ. |
@@ -1840,7 +1840,7 @@ Code written against a v6 alpha uses names that changed before the beta. The old
1840
1840
  | `xstate.system.cancelEffect`, `xstate.logic.cleanup` effects | `@xstate.cancelEffect`, `@xstate.cleanup` |
1841
1841
  | `xstate.logic.effect`, `xstate.log` system effects | `@xstate.effect`, `@xstate.log` |
1842
1842
  | suffixed `xstate.done.actor.<id>` etc. descriptors | category types with `matches` (see [Internal lifecycle events](#internal-lifecycle-events)) |
1843
- | `{ xstate$type: 'actorRef', id, address, src }` | `{ $actor: address }` (`SerializedActorRef`) |
1843
+ | `{ xstate$type: 'actorRef', id, address, src }` | `{ '@actor': address }` (`SerializedActorRef`; `$actor` in 6.0.0-beta.1) |
1844
1844
  | persisted timer `startedAt` | `scheduledAt` |
1845
1845
  | `snapshot.timers` record keyed by generated ids (`xstate.after.<delay>.<stateId>`, `xstate.timeout.state.<stateId>`, `xstate.timer.auto.<n>`) | list; built-in timers have no `id`, delayed sends without an `id` carry `seq` |
1846
1846
  | `scheduleTimer(source, id, delay)`, `cancelTimer(source, id)`, `{ type: 'xstate.timer', id }` | `scheduleTimer(source, timer, delay)`, `cancelTimer(source, timer)`, `{ type: 'xstate.timer', ...timer }` (`TimerKey`) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xstate",
3
- "version": "6.0.0-beta.1",
3
+ "version": "6.0.0-beta.2",
4
4
  "description": "Finite State Machines and Statecharts for the Modern Web.",
5
5
  "main": "dist/xstate.cjs.js",
6
6
  "bin": {