@xmachines/play-xstate 5.0.2 → 6.1.0

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > XState v5 adapter for the XMachines Play Architecture. It binds a state machine to the actor base, with atom-driven reactivity and a router integration.
4
4
 
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/badge/version-5.0.2-blue)](https://www.npmjs.com/package/@xmachines/play-xstate)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/badge/version-6.1.0-blue)](https://www.npmjs.com/package/@xmachines/play-xstate)
6
6
 
7
7
  ---
8
8
 
@@ -13,12 +13,13 @@
13
13
  ## Installation
14
14
 
15
15
  ```bash
16
- pnpm add @xmachines/play-xstate @xmachines/play @xmachines/play-atom xstate
16
+ pnpm add @xmachines/play-xstate @xmachines/core @xmachines/play @xmachines/play-atom xstate
17
17
  ```
18
18
 
19
19
  **Peer dependencies.** Install them with the package:
20
20
 
21
- - [`@xmachines/play`](../play/README.md) — the core protocol. This package reads `shallowEqualExcept` and `DISPOSE` from it.
21
+ - [`@xmachines/core`](../core/README.md) — the base package. This package reads the helpers of its `utils` subpath.
22
+ - [`@xmachines/play`](../play/README.md) — the core protocol. This package reads the error classes from its `errors` subpath.
22
23
  - [`@xmachines/play-atom`](../play-atom/README.md) — the atom primitives. `PlayerActor` holds `currentView` and `currentRoute` as atoms.
23
24
  - `xstate` ^5.33.0 — the XState v5 runtime.
24
25
 
@@ -195,7 +196,7 @@ const createRouted = definePlayer({ machine, actor: compose(PlayerActor, withRou
195
196
  const createBare = definePlayer({ machine });
196
197
  ```
197
198
 
198
- **The composition ORDER decides nothing.** `currentRoute` and `currentView` are computed atoms over `state`, and neither reads the other, so one write for each transition reaches both and the engine evaluates them in topological order. A router bridge therefore sees a guard redirect and a renderer sees the view of the same snapshot, whatever order `compose` applied. A release before this one wrote `currentView` from an `onSnapshot` override, and the order was load-bearing there.
199
+ **The composition ORDER decides nothing.** `currentRoute` and `currentView` are computed atoms over `state`, and neither reads the other, so one write for each transition reaches both and the engine evaluates them in topological order. A router bridge therefore sees a guard redirect and a renderer sees the view of the same snapshot, whatever order `compose` applied.
199
200
 
200
201
  **A lifecycle hook receives the bare actor.** `PlayerOptions` is typed before the class is composed, so it cannot name the capabilities, and a narrower hook parameter is refused under `strictFunctionTypes`. A hook that reads `currentRoute` or `currentView` reads them through a binding of the composed type:
201
202
 
@@ -212,9 +213,9 @@ composed = actor;
212
213
 
213
214
  | Atom | Type | Capability | Description |
214
215
  | -------------- | -------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
215
- | `currentRoute` | `ReadonlyAtom<string \| null>` | routing | The URL that comes from the `meta.route` template of the active state and from the context |
216
+ | `currentRoute` | `ReadonlyAtom<string \| null>` | routing | The URL from the `meta.route` template of the active state and from the context. A parallel machine uses its first routed region |
216
217
  | `initialRoute` | `readonly string \| null` | routing | The route of the initial state of the machine. The construction fixes it, and a router bridge uses it to detect a deep link or a restore |
217
- | `currentView` | `ReadonlyAtom<PlaySpec \| null>` | view | The view spec from the `meta.view` metadata of the active state, with the context params added |
218
+ | `currentView` | `ReadonlyAtom<PlaySpec \| null>` | view | The `meta.view` of the deepest active state, or the composed view of a state that declares `outlets`, with the context under `/context` |
218
219
 
219
220
  `state` is the ONE atom that the actor writes. `currentRoute` and `currentView` are
220
221
  COMPUTED over it, so one write for each transition reaches both in one propagation and no
@@ -222,6 +223,13 @@ observer reads the new state beside an old derivation. Each derivation reports a
222
223
  through the `onError` option and keeps its last good value; it throws never, because it
223
224
  runs inside the write.
224
225
 
226
+ **A parent view with `outlets` shares the screen with its substates.** The derivation then
227
+ walks the active states from the root, puts the view of each active child into its outlet,
228
+ and keeps the `viewKey` of the outermost composing view, so a change of the page keeps the
229
+ store of the layout. A machine that declares no `outlets` keeps the rule that the deepest
230
+ view wins. The [State Machines guide](../docs/guides/state-machines.md#a-layout-and-its-pages-outlets)
231
+ shows a complete machine.
232
+
225
233
  **`currentRoute` notifies on every transition, and `currentView` notifies on a change of
226
234
  the view alone.** The two atoms answer two different questions. A router bridge needs the
227
235
  answer of the actor to each event that it proposed, and a guard that refuses an inbound
@@ -241,7 +249,6 @@ the path yourself, when you run work that belongs to a change of the route alone
241
249
  | `send(event)` | Sends a typed event to the machine and calls the `onTransition` hook |
242
250
  | `can(event)` | Returns `true` when the current state accepts the given event |
243
251
  | `getSnapshot()` | Returns the current XState snapshot |
244
- | `[DISPOSE]()` | Stops the actor at the end of a `using` scope. The release is `stop()` |
245
252
 
246
253
  #### Atom usage example
247
254
 
@@ -334,11 +341,22 @@ const machine = setup({}).createMachine(config);
334
341
  | `isAbsoluteRoute(route)` | Returns `true` when the route string is an absolute URL path |
335
342
  | `buildRouteUrl(template, context)` | Replaces each `:param` placeholder of a route template with a context value |
336
343
 
337
- #### The release protocol
344
+ #### A scope that owns an actor
345
+
346
+ `PlayerActor` carries no dispose key. A scope that owns an actor publishes its `stop()`
347
+ with `asDisposable` of [`@xmachines/core/utils`](../core/README.md):
338
348
 
339
- `DISPOSE` comes from [`@xmachines/play`](../play/README.md), and this package re-exports
340
- it, because `PlayerActor` carries `[DISPOSE]`: a scope releases an actor with `using` and
341
- writes no teardown.
349
+ ```typescript
350
+ import { asDisposable } from "@xmachines/core/utils";
351
+
352
+ {
353
+ const actor = definePlayer({ machine })();
354
+ using _stop = asDisposable(() => {
355
+ actor.stop();
356
+ });
357
+ actor.start();
358
+ } // stop() runs here, and after an exception too
359
+ ```
342
360
 
343
361
  ---
344
362
 
@@ -403,7 +421,7 @@ import type {
403
421
  `RouteObject`, `RouteMetadata`, `RouteData`, and `RouteDataResolver` have one
404
422
  definition, and it lives in [`@xmachines/play-router`](../play-router/README.md). `@xmachines/play-xstate/routing`
405
423
  re-exports them, so either import path gives you the same type. The MAIN entry point of
406
- this package re-exports them no longer: it would name an optional peer in the types of
424
+ this package does not re-export them: it would name an optional peer in the types of
407
425
  every consumer, including one that composes no routing.
408
426
 
409
427
  ### The object form of `meta.route`
@@ -418,12 +436,13 @@ meta: {
418
436
  // Where the generated transition sits. The default is "root", which is what
419
437
  // XState does: every route transition sits on the root of the machine.
420
438
  // "root" — one transition on the root. A route from any state arrives.
421
- // "local" — one transition on the PARENT. The parent keeps its entry action,
422
- // and a route from outside the parent arrives NOWHERE.
423
- // "both" — one in each place. The parent keeps its entry action, and a route
424
- // from outside the parent still arrives.
439
+ // "local" — one transition on the PARENT. The parent keeps its entry action
440
+ // under `reenter: false`, and a route from outside the parent
441
+ // arrives NOWHERE.
442
+ // "both" — one in each place. The parent keeps its entry action under
443
+ // `reenter: false`, and a route from outside the parent still arrives.
425
444
  handler: "both",
426
- // Whether the transition re-enters its OWN DOMAIN. The default is false, which
445
+ // Whether the transition re-enters its DOMAIN. The default is false, which
427
446
  // is the default of XState. Under `handler: "root"` the domain is the root of
428
447
  // the machine, so `false` spares the root alone: each ancestor between the root
429
448
  // and the target still runs its exit and its entry actions. `handler` is the
@@ -438,13 +457,12 @@ meta: {
438
457
 
439
458
  An unknown `handler` value throws `InvalidRouteHandlerError` at the format time.
440
459
 
441
- > **Upgrading from 3.x: the `reenter` default changed, and a machine that relies on it
442
- > goes quiet.** An earlier release wrote `reenter: true` on EVERY generated transition,
443
- > so every routed state re-entered its own domain on each navigation and ran its `entry`
444
- > actions again. The flag is now what `meta.route` declares, and the default is `false` —
445
- > which is the default of XState. A state whose `entry` action must run on each
446
- > navigation has to declare `reenter: true` for itself. Nothing throws, and the action
447
- > simply stops running.
460
+ > **The `reenter` flag re-enters the domain, and not the target.** The target state runs
461
+ > its own `exit` and `entry` actions on each navigation to it, under both values. A state
462
+ > that declares `reenter: true` also re-enters the domain of its transition: the root
463
+ > under `handler: "root"`, and the parent under `"local"` and `"both"` while the parent is
464
+ > active. A route to the ROOT of the machine is the one exception: the root is then the
465
+ > target and the domain, so the root runs those actions only under `reenter: true`.
448
466
 
449
467
  The `data` field follows the `WithDynamicParams` shape of XState, so the function form
450
468
  reads the context and the event:
@@ -9,8 +9,8 @@
9
9
  * {@link compose} applies each capability from left to right, so the LAST one is the
10
10
  * outermost class. The ORDER decides no value: a capability that publishes one derives it
11
11
  * with a computed atom over `state`, and the engine evaluates every derivation from the
12
- * one write of a transition, in topological order. `onSnapshot` remains for a capability
13
- * that must run an EFFECT, and an override of it still calls `super.onSnapshot()` first.
12
+ * one write of a transition, in topological order. A capability that must run an EFFECT
13
+ * overrides `onSnapshot`, and the override calls `super.onSnapshot()` first.
14
14
  *
15
15
  * ## Why the types read this way
16
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAsBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAU3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAW1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,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;;;;GA6BG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;gBACzC,KAAK,EAAE,OAAO;CAS1B"}
package/dist/errors.js CHANGED
@@ -1,25 +1,5 @@
1
1
  import { PlayError } from "@xmachines/play/errors";
2
- /**
3
- * Converts a value from a throw into a string, and it trusts that value not:
4
- * `String()` itself throws for an object with a null prototype, and also for a value
5
- * whose `toString` or `Symbol.toPrimitive` throws. This function runs inside the
6
- * error path. A second throw here therefore replaces the real failure of the machine
7
- * with a `TypeError`, and it passes around `onError`.
8
- */
9
- const safeString = (value) => {
10
- try {
11
- return String(value);
12
- }
13
- catch {
14
- try {
15
- return Object.prototype.toString.call(value);
16
- }
17
- catch {
18
- // A revoked Proxy throws also on an inspection of the brand.
19
- return "[unrepresentable value]";
20
- }
21
- }
22
- };
2
+ import { describeValue, safeString } from "@xmachines/core/utils";
23
3
  /**
24
4
  * `buildRouteUrl()` throws this error when the context of the actor does not hold a
25
5
  * necessary route parameter.
@@ -162,25 +142,6 @@ export class InvalidMachineError extends PlayError {
162
142
  this.name = "InvalidMachineError";
163
143
  }
164
144
  }
165
- /**
166
- * Describes an unknown value for the message of an error, and throws nothing itself.
167
- *
168
- * `JSON.stringify` alone is not enough for a value that arrives from the config of a
169
- * user. It returns the VALUE `undefined` for a function, for a symbol, and for
170
- * `undefined`, which puts the text "undefined" in a field that is declared `string`.
171
- * It also THROWS a `TypeError` for a circular object, and an error constructor that
172
- * throws hides the error that it was built to report.
173
- *
174
- * The fallback names the type instead, for example `[function]`.
175
- */
176
- function describeValue(value) {
177
- try {
178
- return JSON.stringify(value) ?? `[${typeof value}]`;
179
- }
180
- catch {
181
- return `[${typeof value}]`;
182
- }
183
- }
184
145
  /**
185
146
  * `normalizeRoute()` throws this error when the `meta.route` value of a state is not
186
147
  * a string and not an object with a `path` property.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAA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;;;;GA2BG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C,qDAAqD;IAC5C,MAAM,CAAU;IAEzB,YAAY,MAAe;QAC1B,KAAK,CACJ,aAAa,EACb,2BAA2B,EAC3B,iDAAiD,CACjD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACrD,YAAY,KAAc;QACzB,KAAK,CACJ,aAAa,EACb,8BAA8B,EAC9B,8CAA8C,UAAU,CAAC,KAAK,CAAC,GAAG,EAClE,EAAE,KAAK,EAAE,KAAK,EAAE,CAChB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD"}
package/dist/index.d.ts CHANGED
@@ -16,5 +16,4 @@ export { PlayerActor } from "./player-actor.js";
16
16
  export { compose } from "./capabilities.js";
17
17
  export type { Capability, PlayerConstructor } from "./capabilities.js";
18
18
  export type { PlayerConfig, PlayerOptions, PlayerFactory, PlayerFactoryResumeOptions, } from "./types.js";
19
- export { DISPOSE } from "@xmachines/play";
20
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,0BAA0B,GAC1B,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,0BAA0B,GAC1B,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -22,9 +22,4 @@ export { compose } from "./capabilities.js";
22
22
  // `formatPlayRouteTransitions`, and the route types. Each one names
23
23
  // `@xmachines/play-router` in its `.d.ts`, and that package is an OPTIONAL peer. This
24
24
  // entry therefore names no capability package, exactly as the view half does.
25
- // The release protocol of @xmachines/play. This package's own published `.d.ts` names
26
- // exactly these, so a consumer reads them from here and needs no second manifest
27
- // entry. It names `asCleanup` nowhere: a consumer of this package RECEIVES a
28
- // release, and builds one only with @xmachines/play itself.
29
- export { DISPOSE } from "@xmachines/play";
30
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,yFAAyF;AACzF,uFAAuF;AACvF,0EAA0E;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS5C,qFAAqF;AACrF,sEAAsE;AACtE,oEAAoE;AACpE,sFAAsF;AACtF,8EAA8E;AAC9E,sFAAsF;AACtF,iFAAiF;AACjF,6EAA6E;AAC7E,4DAA4D;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,yFAAyF;AACzF,uFAAuF;AACvF,0EAA0E;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS5C,qFAAqF;AACrF,sEAAsE;AACtE,oEAAoE;AACpE,sFAAsF;AACtF,8EAA8E"}
@@ -1,6 +1,5 @@
1
1
  import { Actor, type AnyStateMachine, type AnyMachineSnapshot, type InputFrom, type ActorOptions, type Observer, type Snapshot, type SnapshotFrom, type Subscription, type EventFromLogic } from "xstate";
2
2
  import type { PlayActor } from "@xmachines/play-actor";
3
- import { DISPOSE } from "@xmachines/play";
4
3
  import type { Atom } from "@xmachines/play-atom";
5
4
  import type { PlayerOptions } from "./types.js";
6
5
  /**
@@ -267,28 +266,5 @@ export declare class PlayerActor<TMachine extends AnyStateMachine> extends Actor
267
266
  * @param snapshot - The stable snapshot of this transition.
268
267
  */
269
268
  protected onSnapshot(snapshot: AnyMachineSnapshot): void;
270
- /**
271
- * Stops the actor when the scope of a `using` declaration ends.
272
- *
273
- * The actor is a `Disposable`, so a scope that owns one writes no teardown:
274
- *
275
- * ```ts
276
- * {
277
- * using actor = definePlayer({ machine })();
278
- * actor.start();
279
- * actor.send({ type: "go" });
280
- * // stop() runs here, and it runs even when send() throws
281
- * }
282
- * ```
283
- *
284
- * The release is {@link stop}, which is synchronous and idempotent. `Disposable` and
285
- * not `AsyncDisposable`: a `Disposable` serves `using` AND `await using`, while an
286
- * `AsyncDisposable` raises a TypeError under a plain `using`.
287
- *
288
- * The key is `DISPOSE` of `@xmachines/play` and not a bare `Symbol.dispose`, so that
289
- * the method still answers a `using` that a bundler downlevelled for a target without
290
- * the well-known symbol.
291
- */
292
- [DISPOSE](): void;
293
269
  }
294
270
  //# sourceMappingURL=player-actor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"player-actor.d.ts","sourceRoot":"","sources":["../src/player-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkBhD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAWxC,CAAC;AAYF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,qBAAa,WAAW,CAAC,QAAQ,SAAS,eAAe,CACxD,SAAQ,KAAK,CAAC,QAAQ,CACtB,YAAW,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAElF,OAAO,CAAC,aAAa,CAAC,CAA0B;IAChD;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IAC3C,iCAAiC;IACjC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,QAAQ,CAAC,GAAG,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QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,EACzD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EACxC,gBAAgB,CAAC,EAAE,MAAM,IAAI,GAC3B,YAAY;IAyCf;;;;;OAKG;IACM,oBAAoB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAInE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAIxD"}
@@ -1,24 +1,7 @@
1
1
  import { Actor, } from "xstate";
2
- import { DISPOSE } from "@xmachines/play";
3
2
  import { createWritableAtom } from "@xmachines/play-atom";
3
+ import { isError } from "@xmachines/core/utils";
4
4
  import { ActorThrewNonErrorError, InvalidEventError, InvalidMachineError } from "./errors.js";
5
- /**
6
- * Tells you if a value is an `Error`, by its identity or by its brand: `instanceof`
7
- * misses an error from another realm, such as an iframe or `node:vm`. The function
8
- * prefers `Error.isError` where the runtime has it (Node >= 24, and a
9
- * Baseline-2025 browser), because that function refuses a false
10
- * `Symbol.toStringTag`. In every other runtime the function tests the brand. The
11
- * type is structural, because the lib target of this repository is older than the
12
- * API.
13
- */
14
- const isRealError = (value) => {
15
- if (value instanceof Error)
16
- return true;
17
- const isError = Error.isError;
18
- if (isError)
19
- return isError(value);
20
- return Object.prototype.toString.call(value) === "[object Error]";
21
- };
22
5
  /**
23
6
  * Normalizes a failure of the actor for `onError`.
24
7
  *
@@ -32,7 +15,7 @@ const isRealError = (value) => {
32
15
  */
33
16
  export const toError = (value) => {
34
17
  try {
35
- if (isRealError(value)) {
18
+ if (isError(value)) {
36
19
  return value;
37
20
  }
38
21
  }
@@ -260,8 +243,8 @@ export class PlayerActor extends Actor {
260
243
  // state beside an old derivation, and the composition order of the capabilities
261
244
  // decides nothing.
262
245
  //
263
- // `onSnapshot` remains for a capability that must run an EFFECT on a
264
- // transition. A capability that publishes a value derives it instead.
246
+ // A capability that must run an EFFECT on a transition overrides
247
+ // `onSnapshot`. A capability that publishes a value derives it instead.
265
248
  //
266
249
  // The whole order of one transition:
267
250
  // 1. state receives its new value, and every computed atom over it follows
@@ -467,30 +450,5 @@ export class PlayerActor extends Actor {
467
450
  // The base class holds no capability. A mixin overrides this method.
468
451
  void snapshot;
469
452
  }
470
- /**
471
- * Stops the actor when the scope of a `using` declaration ends.
472
- *
473
- * The actor is a `Disposable`, so a scope that owns one writes no teardown:
474
- *
475
- * ```ts
476
- * {
477
- * using actor = definePlayer({ machine })();
478
- * actor.start();
479
- * actor.send({ type: "go" });
480
- * // stop() runs here, and it runs even when send() throws
481
- * }
482
- * ```
483
- *
484
- * The release is {@link stop}, which is synchronous and idempotent. `Disposable` and
485
- * not `AsyncDisposable`: a `Disposable` serves `using` AND `await using`, while an
486
- * `AsyncDisposable` raises a TypeError under a plain `using`.
487
- *
488
- * The key is `DISPOSE` of `@xmachines/play` and not a bare `Symbol.dispose`, so that
489
- * the method still answers a `using` that a bundler downlevelled for a target without
490
- * the well-known symbol.
491
- */
492
- [DISPOSE]() {
493
- this.stop();
494
- }
495
453
  }
496
454
  //# sourceMappingURL=player-actor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"player-actor.js","sourceRoot":"","sources":["../src/player-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAWL,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG9F;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,CAAC,KAAc,EAAkB,EAAE;IACtD,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,OAAO,GAAI,KAA0D,CAAC,O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,qBAAqB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnE,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,OAAO;YACN,WAAW,EAAE,GAAG,EAAE;gBACjB,IAAI,OAAO,EAAE,CAAC;oBACb,OAAO,GAAG,KAAK,CAAC;oBAChB,IAAI,CAAC,qBAAqB,GAAG,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACpE,CAAC;gBACD,YAAY,CAAC,WAAW,EAAE,CAAC;YAC5B,CAAC;SACD,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACM,oBAAoB,CAAC,OAAiB;QAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,oBAAgE,CAAC;QACvF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IACD;;;;;;;;;;;;;;;;;;;OAmBG;IACO,UAAU,CAAC,QAA4B;QAChD,qEAAqE;QACrE,KAAK,QAAQ,CAAC;IACf,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-play-route-transitions.d.ts","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,YAAY,CAAC;AAgB7D;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,IAAI,CAAC,EAAE;QACN;;;;;WAKG;QACH,KAAK,CAAC,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,2FAA2F;IAC3F,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAiHF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,kBAAkB,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC,CA2L5F"}
1
+ {"version":3,"file":"format-play-route-transitions.d.ts","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,YAAY,CAAC;AAgB7D;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,IAAI,CAAC,EAAE;QACN;;;;;WAKG;QACH,KAAK,CAAC,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,2FAA2F;IAC3F,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAiHF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,kBAAkB,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC,CA4L5F"}
@@ -1,5 +1,5 @@
1
1
  import { assign } from "xstate";
2
- import { shallowEqualExcept } from "@xmachines/play";
2
+ import { shallowEqualExcept } from "@xmachines/core/utils";
3
3
  import { MissingStateIdError } from "../errors.js";
4
4
  import { normalizeRoute, routeData, routeHandler, routeReenter } from "./derive-route.js";
5
5
  /**
@@ -176,8 +176,8 @@ export function formatPlayRouteTransitions(machineConfig) {
176
176
  // The LOCAL transition. It sits on the PARENT of this state, and it targets
177
177
  // this state relatively. XState offers the transitions of the deepest active
178
178
  // state node first, so this transition answers the event while the parent is
179
- // active, and the parent therefore runs its exit and its entry actions NOT
180
- // again.
179
+ // active. The parent therefore runs its exit and its entry actions again only
180
+ // where the state declares `reenter: true`.
181
181
  //
182
182
  // Under `"local"` this is the ONLY transition of the state, so a route that
183
183
  // arrives while the parent is inactive matches nothing and the actor does not
@@ -213,12 +213,13 @@ export function formatPlayRouteTransitions(machineConfig) {
213
213
  const walk = machineStates ? collectRoutes(machineStates) : undefined;
214
214
  // The ROOT of the machine can declare a route of its own, which a chart does when
215
215
  // its whole document owns a path prefix, for example `/doc` with `/doc/a` under it.
216
- // `collectRoutes` walks `states` only, so the root got no transition, and a URL for
217
- // the root moved the machine nowhere: a press on BACK to `/doc` left the actor on
218
- // the child it already held, and the URL and the actor diverged.
216
+ // `collectRoutes` walks `states` only, so without this block the root gets no
217
+ // transition, and a URL for the root moves the machine nowhere: a press on BACK to
218
+ // `/doc` leaves the actor on the child it already holds, and the URL and the actor
219
+ // diverge.
219
220
  //
220
221
  // The transition targets the root by its ID. XState enters the `initial` child of
221
- // an ID target, which is the state that a URL for the root means. The `reenter`
222
+ // a compound target, which is the state that a URL for the root means. The `reenter`
222
223
  // flag does NOT decide that: a route to the root lands on the initial child of the
223
224
  // root under `false` and under `true`. The flag decides only whether the root runs
224
225
  // its own `exit` and `entry` actions again. The root therefore reads the flag from
@@ -1 +1 @@
1
- {"version":3,"file":"format-play-route-transitions.js","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1F;;;;;;;;;;GAUG;AACH,MAAM,kBAAkB,GAAG,CAAoC,IAAmB,EAAE,IAAO,EAAK,EAAE,CACjG,IAAI,KAAK,SAAS,IAAI,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAmCpE;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAa,EAAE,CACvD,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAKnE;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAgC,EAAW,EAAE,CACvE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAqB,CAAC,IAAI,KAAK,SAAS,CAAC;AAE1F;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAmB,EAAE,EAAE,CAC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1C,iFAAiF;QACjF,8EAA8E;QAC9E,kFAAkF;QAClF,0EAA0E;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG;YACZ,GAAG,UAAU;YACb,YAAY,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;SACnF,CAAC;IACH,CAAC;IAED,OAAO,IAAS,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"format-play-route-transitions.js","sourceRoot":"","sources":["../../src/routing/format-play-route-transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1F;;;;;;;;;;GAUG;AACH,MAAM,kBAAkB,GAAG,CAAoC,IAAmB,EAAE,IAAO,EAAK,EAAE,CACjG,IAAI,KAAK,SAAS,IAAI,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAmCpE;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAa,EAAE,CACvD,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAKnE;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAgC,EAAW,EAAE,CACvE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAqB,CAAC,IAAI,KAAK,SAAS,CAAC;AAE1F;;;;GAIG;A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AM,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC;QAE1C,iFAAiF;QACjF,8EAA8E;QAC9E,kFAAkF;QAClF,0EAA0E;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG;YACZ,GAAG,UAAU;YACb,YAAY,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;SACnF,CAAC;IACH,CAAC;IAED,OAAO,IAAS,CAAC;AAClB,CAAC"}
@@ -13,6 +13,31 @@
13
13
  * entry point.
14
14
  */
15
15
  import type { AnyMachineSnapshot } from "xstate";
16
+ /** The part of an XState state node that the walks of this module read. */
17
+ export interface BranchNode {
18
+ id: string;
19
+ meta?: unknown;
20
+ states?: Record<string, BranchNode>;
21
+ }
22
+ /**
23
+ * The keys of the active children of a node, from its part of `snapshot.value`: one key
24
+ * for a compound node, one for each region of a parallel node, in the order of the
25
+ * machine, and none for an atomic node.
26
+ */
27
+ export declare const activeChildKeys: (value: unknown) => string[];
28
+ /** The part of `snapshot.value` that belongs to the active child `key`. */
29
+ export declare const activeChildValue: (value: unknown, key: string) => unknown;
30
+ /**
31
+ * The keys of the active children of a node, in the order that a branch walk tries
32
+ * them: the first region whose active subtree declares a `meta.route` comes first, and
33
+ * the others keep the order of the machine.
34
+ *
35
+ * A parallel machine often holds its routes in ONE region, and that region need not be
36
+ * the first one: a menu or a session region can come before it. The route derivation
37
+ * and the view derivation both follow this order, so the URL comes from the routed
38
+ * region, and the view without outlets belongs to the region of the URL.
39
+ */
40
+ export declare const branchOrder: (node: BranchNode, value: unknown) => string[];
16
41
  /**
17
42
  * Collects the `meta` object of the active state nodes of a SINGLE branch, from the
18
43
  * root to a leaf. The key of each entry is the state id, and the order is the
@@ -28,11 +53,11 @@ import type { AnyMachineSnapshot } from "xstate";
28
53
  * the meta keys are those ids, and they carry no information about the ancestry.
29
54
  *
30
55
  * Therefore this function walks `snapshot.value`, which holds the real hierarchy of
31
- * the active states by the state key, against the node tree of the machine. It
32
- * follows the FIRST active child at each level. This gives one deterministic branch,
33
- * which matches the historical behavior of "the first that it finds" for a parallel
34
- * machine. It also works with an explicit id, because each node carries its own `id`
35
- * and its own `meta`.
56
+ * the active states by the state key, against the node tree of the machine. At each
57
+ * level it follows the first key of {@link branchOrder}: for a parallel node, that is
58
+ * the first region whose active subtree declares a route, or the first region when no
59
+ * region does. This gives one deterministic branch. It also works with an explicit id,
60
+ * because each node carries its own `id` and its own `meta`.
36
61
  *
37
62
  * The function returns `null` when the snapshot exposes no machine and no value to
38
63
  * walk. This is a defensive measure, because a real XState snapshot always exposes
@@ -1 +1 @@
1
- {"version":3,"file":"state-meta.d.ts","sourceRoot":"","sources":["../src/state-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAU,kBAAkB,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAqC5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,kBAAkB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAMxF,CAAC"}
1
+ {"version":3,"file":"state-meta.d.ts","sourceRoot":"","sources":["../src/state-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,MAAM,EAKhD,CAAC;AAER,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,KAAK,MAAM,KAAG,OAGlD,CAAC;AAiBd;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,UAAU,EAAE,OAAO,OAAO,KAAG,MAAM,EAUpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAU,kBAAkB,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAyB5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,kBAAkB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAMxF,CAAC"}
@@ -1,3 +1,53 @@
1
+ /**
2
+ * The keys of the active children of a node, from its part of `snapshot.value`: one key
3
+ * for a compound node, one for each region of a parallel node, in the order of the
4
+ * machine, and none for an atomic node.
5
+ */
6
+ export const activeChildKeys = (value) => typeof value === "string"
7
+ ? [value]
8
+ : value !== null && typeof value === "object"
9
+ ? Object.keys(value)
10
+ : [];
11
+ /** The part of `snapshot.value` that belongs to the active child `key`. */
12
+ export const activeChildValue = (value, key) => value !== null && typeof value === "object"
13
+ ? value[key] // nosemgrep: gitlab.eslint.detect-object-injection
14
+ : undefined;
15
+ const declaresRoute = (node) => node.meta !== null &&
16
+ typeof node.meta === "object" &&
17
+ node.meta.route !== undefined;
18
+ /** `true` when a state of the active subtree of `node` declares a `meta.route`. */
19
+ const routeBelow = (node, value) => {
20
+ if (declaresRoute(node))
21
+ return true;
22
+ for (const key of activeChildKeys(value)) {
23
+ const child = node.states?.[key]; // nosemgrep: gitlab.eslint.detect-object-injection
24
+ if (child && routeBelow(child, activeChildValue(value, key)))
25
+ return true;
26
+ }
27
+ return false;
28
+ };
29
+ /**
30
+ * The keys of the active children of a node, in the order that a branch walk tries
31
+ * them: the first region whose active subtree declares a `meta.route` comes first, and
32
+ * the others keep the order of the machine.
33
+ *
34
+ * A parallel machine often holds its routes in ONE region, and that region need not be
35
+ * the first one: a menu or a session region can come before it. The route derivation
36
+ * and the view derivation both follow this order, so the URL comes from the routed
37
+ * region, and the view without outlets belongs to the region of the URL.
38
+ */
39
+ export const branchOrder = (node, value) => {
40
+ const keys = activeChildKeys(value);
41
+ if (keys.length < 2)
42
+ return keys;
43
+ const routed = keys.find((key) => {
44
+ const child = node.states?.[key]; // nosemgrep: gitlab.eslint.detect-object-injection
45
+ return child !== undefined && routeBelow(child, activeChildValue(value, key));
46
+ });
47
+ return routed === undefined || routed === keys[0]
48
+ ? keys
49
+ : [routed, ...keys.filter((key) => key !== routed)];
50
+ };
1
51
  /**
2
52
  * Collects the `meta` object of the active state nodes of a SINGLE branch, from the
3
53
  * root to a leaf. The key of each entry is the state id, and the order is the
@@ -13,11 +63,11 @@
13
63
  * the meta keys are those ids, and they carry no information about the ancestry.
14
64
  *
15
65
  * Therefore this function walks `snapshot.value`, which holds the real hierarchy of
16
- * the active states by the state key, against the node tree of the machine. It
17
- * follows the FIRST active child at each level. This gives one deterministic branch,
18
- * which matches the historical behavior of "the first that it finds" for a parallel
19
- * machine. It also works with an explicit id, because each node carries its own `id`
20
- * and its own `meta`.
66
+ * the active states by the state key, against the node tree of the machine. At each
67
+ * level it follows the first key of {@link branchOrder}: for a parallel node, that is
68
+ * the first region whose active subtree declares a route, or the first region when no
69
+ * region does. This gives one deterministic branch. It also works with an explicit id,
70
+ * because each node carries its own `id` and its own `meta`.
21
71
  *
22
72
  * The function returns `null` when the snapshot exposes no machine and no value to
23
73
  * walk. This is a defensive measure, because a real XState snapshot always exposes
@@ -34,26 +84,15 @@ export const firstActiveBranchMeta = (snapshot) => {
34
84
  if (node.meta && typeof node.meta === "object") {
35
85
  ordered[node.id] = node.meta; // nosemgrep: gitlab.eslint.detect-object-injection
36
86
  }
37
- // Find the key of the active child at this level. A string value is the name of an
38
- // atomic active leaf. An object value is a compound node, with one key, or a
39
- // parallel node, with many keys: take the first key, for one deterministic
40
- // branch.
41
- let key;
42
- if (typeof value === "string") {
43
- key = value;
44
- }
45
- else if (value && typeof value === "object") {
46
- key = Object.keys(value)[0];
47
- }
87
+ // The key of the active child at this level: the name of an atomic active leaf, the
88
+ // one key of a compound node, or the routed region of a parallel node.
89
+ const key = branchOrder(node, value)[0];
48
90
  if (key === undefined)
49
91
  break;
50
92
  const child = node.states?.[key]; // nosemgrep: gitlab.eslint.detect-object-injection
51
93
  if (!child)
52
94
  break;
53
- value =
54
- typeof value === "object" && value !== null
55
- ? value[key] // nosemgrep: gitlab.eslint.detect-object-injection
56
- : {};
95
+ value = activeChildValue(value, key);
57
96
  node = child;
58
97
  }
59
98
  return ordered;
@@ -1 +1 @@
1
- {"version":3,"file":"state-meta.js","sourceRoot":"","sources":["../src/state-meta.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACpC,QAA4B,EACK,EAAE;IACnC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,IAEnB,CAAC;IACb,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,IAAI,IAAI,GAA4B,IAAI,CAAC;IACzC,IAAI,KAAK,GAAY,QAAQ,CAAC,KAAK,CAAC;IAEpC,OAAO,IAAI,EAAE,CAAC;QACb,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,mDAAmD;QAClF,CAAC;QAED,mFAAmF;QACnF,6EAA6E;QAC7E,2EAA2E;QAC3E,UAAU;QACV,IAAI,GAAuB,CAAC;QAC5B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C,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM;QAE7B,MAAM,KAAK,GAA2B,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,mDAAmD;QAC7G,IAAI,CAAC,KAAK;YAAE,MAAM;QAClB,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,IAAI,GAAG,KAAK,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAA4B,EAAkC,EAAE;IAC/F,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,IAAI,GAAG,qBAAqB,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;IACnE,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAgC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"derive-current-view.d.ts","sourceRoot":"","sources":["../../src/view/derive-current-view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAiC,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAyEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,kBAAkB,KAAG,QAAQ,GAAG,IA4C3E,CAAC"}
1
+ {"version":3,"file":"derive-current-view.d.ts","sourceRoot":"","sources":["../../src/view/derive-current-view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAIN,KAAK,QAAQ,EAGb,MAAM,sBAAsB,CAAC;AAkL9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,kBAAkB,KAAG,QAAQ,GAAG,IA2D3E,CAAC"}
@@ -1,5 +1,6 @@
1
- import { composePlayState, toAtomState } from "@xmachines/play-view";
2
- import { activeStateMeta } from "../state-meta.js";
1
+ import { composePlayState, composeViews, toAtomState, } from "@xmachines/play-view";
2
+ import { createWarnOnce } from "@xmachines/core/utils";
3
+ import { activeChildKeys, activeChildValue, activeStateMeta, branchOrder, } from "../state-meta.js";
3
4
  /**
4
5
  * The migration warning of the `contextProps` field, which 1.x removed. The code
5
6
  * writes it one time for each spec. A meta.view object from a person passes around
@@ -9,15 +10,12 @@ import { activeStateMeta } from "../state-meta.js";
9
10
  * meta.view object. Therefore the warning appears one time, and not for each
10
11
  * snapshot.
11
12
  */
12
- const warnedContextProps = new WeakSet();
13
+ const warnOnce = createWarnOnce();
13
14
  const warnRemovedContextProps = (viewMeta) => {
14
- if (warnedContextProps.has(viewMeta))
15
- return;
16
- warnedContextProps.add(viewMeta);
17
- console.warn("[play-xstate] meta.view.contextProps has been removed: the whole machine context " +
15
+ warnOnce(viewMeta, "[play-xstate] meta.view.contextProps has been removed: the whole machine context " +
18
16
  "is always projected under /context. Delete the field — it no longer filters anything.");
19
17
  };
20
- /** Reads the `view` of one meta entry, when the entry holds a whole PlaySpec. */
18
+ /** Reads the `view` of one meta entry, when the entry holds a whole spec. */
21
19
  const viewOfEntry = (stateMeta) => {
22
20
  const maybeView = stateMeta && typeof stateMeta === "object"
23
21
  ? stateMeta.view
@@ -55,6 +53,92 @@ const resolveViewMeta = (meta) => {
55
53
  }
56
54
  return null;
57
55
  };
56
+ /**
57
+ * Resolves the view of one active state node and its active descendants.
58
+ *
59
+ * A node whose view declares `outlets` composes: the tree holds the resolved view of
60
+ * each active child. Any other node keeps the rule of a view without outlets: the
61
+ * deepest view below it wins, and a parallel node follows the region of the URL when
62
+ * that region resolves to a view, and its first region that resolves to one otherwise.
63
+ */
64
+ const resolveViewTree = (node, value) => {
65
+ const view = viewOfEntry(node.meta);
66
+ if (view && "contextProps" in view) {
67
+ warnRemovedContextProps(view);
68
+ }
69
+ // A view with outlets places its children in the order of the machine. Any other
70
+ // node tries the routed region first, so its view belongs to the region of the URL.
71
+ const keys = view?.outlets ? activeChildKeys(value) : branchOrder(node, value);
72
+ const children = [];
73
+ for (const key of keys) {
74
+ const child = node.states?.[key]; // nosemgrep: gitlab.eslint.detect-object-injection
75
+ if (!child)
76
+ continue;
77
+ const resolved = resolveViewTree(child, activeChildValue(value, key));
78
+ if (resolved)
79
+ children.push({ key, resolved });
80
+ // Without outlets, only the first child that resolves counts.
81
+ if (resolved && !view?.outlets)
82
+ break;
83
+ }
84
+ if (view?.outlets) {
85
+ return {
86
+ tree: {
87
+ id: node.id,
88
+ view,
89
+ children: children.map(({ key, resolved }) => ({ key, tree: resolved.tree })),
90
+ },
91
+ composes: true,
92
+ };
93
+ }
94
+ const deeper = children[0]?.resolved;
95
+ if (deeper)
96
+ return deeper;
97
+ return view ? { tree: { id: node.id, view, children: [] }, composes: false } : null;
98
+ };
99
+ // Whether any state node of a machine declares `outlets`, for each root node. A
100
+ // machine without outlets skips the walk of the view tree on every snapshot.
101
+ const outletsByMachine = new WeakMap();
102
+ const declaresOutlets = (node) => Boolean(viewOfEntry(node.meta)?.outlets) ||
103
+ Object.values(node.states ?? {}).some(declaresOutlets);
104
+ const machineDeclaresOutlets = (root) => {
105
+ let declares = outletsByMachine.get(root);
106
+ if (declares === undefined) {
107
+ declares = declaresOutlets(root);
108
+ outletsByMachine.set(root, declares);
109
+ }
110
+ return declares;
111
+ };
112
+ /**
113
+ * Derives the view of a machine that declares `outlets` somewhere. The walk of the view
114
+ * tree alone decides that view: a composed view, the plain view that the walk resolved,
115
+ * or `null` when no active state holds a view.
116
+ *
117
+ * The function returns `undefined` for a machine that declares no `outlets`. The caller
118
+ * then derives the view as before, which keeps every such machine on the exact rule that
119
+ * it had, the flat fallback of a parallel machine included.
120
+ */
121
+ const deriveTreeView = (snapshot) => {
122
+ const root = snapshot?.machine?.root;
123
+ if (!root || !machineDeclaresOutlets(root))
124
+ return undefined;
125
+ const resolved = resolveViewTree(root, snapshot.value);
126
+ if (!resolved)
127
+ return null;
128
+ // A tree that does not compose is a view without outlets.
129
+ if (!resolved.composes)
130
+ return { viewKey: resolved.tree.id, view: resolved.tree.view };
131
+ const composed = composeViews(resolved.tree);
132
+ return {
133
+ viewKey: resolved.tree.id,
134
+ view: {
135
+ root: composed.root,
136
+ elements: composed.elements,
137
+ ...(composed.state !== undefined && { state: composed.state }),
138
+ viewParts: composed.viewParts,
139
+ },
140
+ };
141
+ };
58
142
  /**
59
143
  * Derives the current view of the actor from the state metadata.
60
144
  *
@@ -96,6 +180,22 @@ const resolveViewMeta = (meta) => {
96
180
  * @returns The derived `PlaySpec`, or `null` when the current state has no view metadata.
97
181
  */
98
182
  export const deriveCurrentView = (snapshot) => {
183
+ const slice = snapshot?.context !== null && typeof snapshot?.context === "object"
184
+ ? snapshot.context
185
+ : undefined;
186
+ // A parent view with `outlets` shares the screen with the views of its substates.
187
+ const treeView = deriveTreeView(snapshot);
188
+ if (treeView !== undefined) {
189
+ if (treeView === null)
190
+ return null;
191
+ const authoredState = treeView.view.state !== undefined ? toAtomState(treeView.view.state) : undefined;
192
+ const state = composePlayState(authoredState, slice);
193
+ return {
194
+ ...treeView.view,
195
+ viewKey: treeView.viewKey,
196
+ ...(state !== undefined && { state }),
197
+ };
198
+ }
99
199
  // Follow the SAME single active branch as the route derivation. Therefore the view
100
200
  // on the screen of a parallel machine belongs to the region of the URL, when that
101
201
  // region declares a view.
@@ -124,9 +224,6 @@ export const deriveCurrentView = (snapshot) => {
124
224
  // Project the complete context under /context. composePlayState skips the
125
225
  // projection, the authored state wins, and the code writes a warning in development,
126
226
  // when spec.state declares a top-level "context" key already.
127
- const slice = snapshot.context !== null && typeof snapshot.context === "object"
128
- ? snapshot.context
129
- : undefined;
130
227
  const authoredState = viewMeta.state !== undefined ? toAtomState(viewMeta.state) : undefined;
131
228
  const state = composePlayState(authoredState, slice);
132
229
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"derive-current-view.js","sourceRoot":"","sources":["../../src/view/derive-current-view.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAiB,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASnD;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAU,CAAC;AACjD,MAAM,uBAAuB,GAAG,CAAC,QAAgB,EAAQ,EAAE;IAC1D,IAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO;IAC7C,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CACX,mFAAmF;QAClF,uFAAuF,CACxF,CAAC;AACH,CAAC,CAAC;AAEF,iFAAiF;AACjF,MAAM,WAAW,GAAG,CAAC,SAAkB,EAAmB,EAAE;IAC3D,MAAM,SAAS,GACd,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;QACzC,CAAC,CAAE,SAAgC,CAAC,IAAI;QACxC,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,SAAS;QACf,OAAO,SAAS,KAAK,QAAQ;QAC7B,MAAM,IAAK,SAAoB;QAC/B,UAAU,IAAK,SAAoB;QACnC,CAAC,CAAE,SAAsB;QACzB,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAA6B,EAA2B,EAAE;IAClF,oFAAoF;IACpF,qFAAqF;IACrF,0CAA0C;IAC1C,EAAE;IACF,+EAA+E;IAC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
  * The ORDER of the composition does not matter. `currentView` and `currentRoute` are two
48
48
  * computed atoms over `state`, and neither reads the other, so the engine evaluates both
49
- * from one write in topological order. An earlier release wrote `currentView` from an
50
- * `onSnapshot` override, and the order then decided which capability held its new value
51
- * first.
49
+ * from one write in topological order.
52
50
  *
53
51
  * @param Base - The actor class to extend, normally `PlayerActor` or the result of
54
52
  * another capability.
@@ -1 +1 @@
1
- {"version":3,"file":"with-view.d.ts","sourceRoot":"","sources":["../src/with-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAI9C,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAsC3D;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,SAAS,eAAe,EACxD,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAC/B,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAuFvC"}
1
+ {"version":3,"file":"with-view.d.ts","sourceRoot":"","sources":["../src/with-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAI9C,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAsC3D;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,SAAS,eAAe,EACxD,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAC/B,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAyFvC"}
package/dist/with-view.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createAtom } from "@xmachines/play-atom";
2
- import { shallowEqualExcept } from "@xmachines/play";
2
+ import { shallowEqualExcept } from "@xmachines/core/utils";
3
3
  import { reuseComposedState } from "@xmachines/play-view";
4
4
  import { toError } from "./player-actor.js";
5
5
  import { deriveCurrentView } from "./view/derive-current-view.js";
@@ -64,9 +64,7 @@ const viewSpecsEquivalent = (a, b) => {
64
64
  *
65
65
  * The ORDER of the composition does not matter. `currentView` and `currentRoute` are two
66
66
  * computed atoms over `state`, and neither reads the other, so the engine evaluates both
67
- * from one write in topological order. An earlier release wrote `currentView` from an
68
- * `onSnapshot` override, and the order then decided which capability held its new value
69
- * first.
67
+ * from one write in topological order.
70
68
  *
71
69
  * @param Base - The actor class to extend, normally `PlayerActor` or the result of
72
70
  * another capability.
@@ -79,10 +77,9 @@ export function withView(Base) {
79
77
  *
80
78
  * It emits a **new object reference** on each real change of the view on the screen:
81
79
  * the view of a different state, or a change of a param or of the context that changes
82
- * the resolved spec. A re-entry with `reenter: true` and new params also changes the
83
- * spec. A snapshot that changes no view on the screen, such as an assign of the
84
- * context alone, keeps the previous reference. A provider below the atom therefore
85
- * mounts the UI again not on every event.
80
+ * the resolved spec. A snapshot that changes no view on the screen, such as an
81
+ * assign of the context alone, keeps the previous reference. A provider below the
82
+ * atom therefore mounts the UI again not on every event.
86
83
  *
87
84
  * The `PlaySpec` of the emission carries the context of the machine in its composed
88
85
  * `state` field, under the read-only `/context` subtree. A spec therefore reads the
@@ -92,10 +89,13 @@ export function withView(Base) {
92
89
  *
93
90
  * The atom returns `null` when the current state has no `meta.view` metadata.
94
91
  *
95
- * Two states can declare two separate `meta.view` literals with an identical
96
- * structure. A transition between those two states then emits two different
97
- * references, and a provider mounts the UI again. Move the shared literal into one
98
- * `typedSpec` constant, and the identity then removes the duplicate.
92
+ * Two states that each declare a `meta.view` emit two different `viewKey` values,
93
+ * also when the two specs are one `typedSpec` constant: the key is the id of the
94
+ * state node that declares the view. A transition between those two states therefore
95
+ * emits again, and a provider seeds a new store, which removes the ephemeral state.
96
+ * The ephemeral state survives a move between the children when the parent holds
97
+ * the key: declare the view on the parent and none on the children, or declare
98
+ * `outlets` on the parent, which keeps its id as the `viewKey` of the composed view.
99
99
  *
100
100
  * It is a COMPUTED atom over `state`, and not a written one. One write for each
101
101
  * transition therefore reaches the whole actor — `state.set(snapshot)` — and the
@@ -1 +1 @@
1
- {"version":3,"file":"with-view.js","sourceRoot":"","sources":["../src/with-view.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAgC,MAAM,sBAAsB,CAAC;AAExF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAkB,EAAE,CAAkB,EAAW,EAAE;IAC/E,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IAExD,MAAM,SAAS,GAAG,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;IACnC,2EAA2E;IAC3E,8EAA8E;IAC9E,aAAa;IACb,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,WAAW,CAAC,MAAM,KAAK,MAAM,CA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BACnB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;oBACzB,CAAC,CAAC,CAAC;gBACJ,CAAC;gBACD,OAAO,eAAe,CAAC;YACxB,CAAC;QACF,CAAC,CACD,CAAC;KACF;IAED,OAAO,aAAa,CAAC;AACtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmachines/play-xstate",
3
- "version": "5.0.2",
3
+ "version": "6.1.0",
4
4
  "description": "XState v5 adapter for Play Architecture",
5
5
  "keywords": [
6
6
  "actor-model",
@@ -57,17 +57,18 @@
57
57
  "test:coverage": "vitest run --coverage"
58
58
  },
59
59
  "dependencies": {
60
- "@xmachines/play-actor": "5.0.2",
61
- "@xmachines/play-pattern": "5.0.2"
60
+ "@xmachines/play-actor": "6.1.0",
61
+ "@xmachines/play-pattern": "6.1.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@testing-library/jest-dom": "^7.0.1",
65
65
  "@types/node": "^26.6.2",
66
- "@xmachines/json-render-core": "^0.20.0-xm.4",
67
- "@xmachines/play": "5.0.2",
68
- "@xmachines/play-atom": "5.0.2",
69
- "@xmachines/play-router": "5.0.2",
70
- "@xmachines/play-view": "5.0.2",
66
+ "@xmachines/core": "6.1.0",
67
+ "@xmachines/json-render-core": "^0.21.0-xm.2",
68
+ "@xmachines/play": "6.1.0",
69
+ "@xmachines/play-atom": "6.1.0",
70
+ "@xmachines/play-router": "6.1.0",
71
+ "@xmachines/play-view": "6.1.0",
71
72
  "oxfmt": "^0.70.0",
72
73
  "oxlint": "^1.85.0",
73
74
  "typescript": "^5.9.3 || ^6.0.3",
@@ -76,10 +77,11 @@
76
77
  "xstate": "^5.33.0"
77
78
  },
78
79
  "peerDependencies": {
79
- "@xmachines/play": "5.0.2",
80
- "@xmachines/play-atom": "5.0.2",
81
- "@xmachines/play-router": "5.0.2",
82
- "@xmachines/play-view": "5.0.2",
80
+ "@xmachines/core": "6.1.0",
81
+ "@xmachines/play": "6.1.0",
82
+ "@xmachines/play-atom": "6.1.0",
83
+ "@xmachines/play-router": "6.1.0",
84
+ "@xmachines/play-view": "6.1.0",
83
85
  "xstate": "^5.33.0"
84
86
  },
85
87
  "peerDependenciesMeta": {