@xmachines/docs 1.0.0-beta.18 → 1.0.0-beta.20
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/api/@xmachines/play/README.md +1 -1
- package/api/@xmachines/play/classes/PlayError.md +4 -4
- package/api/@xmachines/play/type-aliases/PlayEvent.md +3 -3
- package/api/@xmachines/play-actor/README.md +2 -2
- package/api/@xmachines/play-actor/classes/AbstractActor.md +4 -4
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +2 -2
- package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
- package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +3 -3
- package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
- package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
- package/api/@xmachines/play-dom/functions/renderSpec.md +1 -1
- package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +7 -7
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +7 -7
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +3 -3
- package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +1 -1
- package/api/@xmachines/play-react/README.md +7 -2
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +9 -5
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
- package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +6 -6
- package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +23 -23
- package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +9 -9
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +4 -4
- package/api/@xmachines/play-router/README.md +103 -47
- package/api/@xmachines/play-router/classes/BaseRouteMap.md +4 -4
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +21 -21
- package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
- package/api/@xmachines/play-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-router/functions/createBrowserHistory.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +6 -42
- package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
- package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +38 -0
- package/api/@xmachines/play-router/functions/isRouteReachable.md +38 -0
- package/api/@xmachines/play-router/functions/machineToGraph.md +19 -0
- package/api/@xmachines/play-router/functions/routeExists.md +1 -1
- package/api/@xmachines/play-router/functions/sanitizePathname.md +40 -0
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +9 -8
- package/api/@xmachines/play-router/functions/validateStateExists.md +8 -8
- package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +3 -3
- package/api/@xmachines/play-router/interfaces/BrowserHistory.md +14 -14
- package/api/@xmachines/play-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +15 -0
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +17 -0
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
- package/api/@xmachines/play-router/interfaces/RouteMap.md +4 -4
- package/api/@xmachines/play-router/interfaces/RouteNode.md +12 -12
- package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
- package/api/@xmachines/play-router/interfaces/RouteTree.md +7 -6
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +4 -4
- package/api/@xmachines/play-router/interfaces/VanillaRouter.md +4 -4
- package/api/@xmachines/play-router/type-aliases/MachineGraph.md +20 -0
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-signals/README.md +8 -2
- package/api/@xmachines/play-signals/functions/watchSignal.md +8 -1
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
- package/api/@xmachines/play-solid/README.md +1 -1
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +6 -6
- package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid-router/README.md +1 -1
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +24 -24
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +16 -16
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +9 -9
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +4 -4
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/README.md +1 -4
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +23 -23
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +28 -0
- package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +9 -9
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/README.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +26 -25
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +9 -9
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +4 -4
- package/api/@xmachines/play-vue/README.md +1 -1
- package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +5 -5
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +2 -1
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +7 -7
- package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +7 -7
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +27 -32
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +9 -9
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +4 -4
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +4 -4
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-xstate/README.md +6 -6
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +12 -12
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +1 -1
- package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +36 -0
- package/api/@xmachines/play-xstate/functions/definePlayer.md +2 -2
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +2 -2
- package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
- package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
- package/api/@xmachines/shared/functions/defineXmVitestConfig.md +2 -2
- package/api/@xmachines/shared/functions/xmAliases.md +1 -1
- package/api/_media/play.md +447 -0
- package/examples/multi-router-integration.md +1 -1
- package/examples/routing-patterns.md +1 -1
- package/guides/installation.md +30 -30
- package/package.json +5 -3
- package/rfc/broker.md +100 -0
- package/rfc/browser.md +44 -0
- package/rfc/cli.md +118 -0
- package/rfc/git.md +61 -0
- package/rfc/mcp.md +43 -0
- package/rfc/node.md +36 -0
- package/rfc/play.md +447 -0
- package/rfc/rest.md +102 -0
- package/rfc/run.md +159 -0
- package/rfc/streams.md +168 -0
- package/api/@xmachines/play-router/functions/crawlMachine.md +0 -92
- package/api/@xmachines/play-router/functions/extractRoute.md +0 -45
- package/api/@xmachines/play-router/interfaces/StateVisit.md +0 -15
- package/api/@xmachines/play-tanstack-react-router/variables/extractMachineRoutes.md +0 -64
- package/api/@xmachines/play-xstate/functions/stateMatches.md +0 -25
package/rfc/streams.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# RFC: Streams
|
|
2
|
+
|
|
3
|
+
**Status:** Draft
|
|
4
|
+
**Version:** 1
|
|
5
|
+
**Scope:** Stream primitives, transforms, framing, durability
|
|
6
|
+
**Non-goals:** Execution semantics, protocols, storage backends
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. Purpose
|
|
11
|
+
|
|
12
|
+
This RFC defines the **stream abstraction** used throughout XMachines.
|
|
13
|
+
|
|
14
|
+
Streams are the **only integration boundary** between:
|
|
15
|
+
|
|
16
|
+
- runtimes
|
|
17
|
+
- transports
|
|
18
|
+
- durability backends
|
|
19
|
+
- adapters (REST, MCP, Git, server, browser)
|
|
20
|
+
|
|
21
|
+
Everything that moves data in XMachines moves through **streams**.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. Canonical Stream Type
|
|
26
|
+
|
|
27
|
+
### 2.1 Web Streams (authoritative)
|
|
28
|
+
|
|
29
|
+
All streams in XMachines are defined using **WHATWG Web Streams**:
|
|
30
|
+
|
|
31
|
+
- `ReadableStream<T>`
|
|
32
|
+
- `WritableStream<T>`
|
|
33
|
+
- `TransformStream<I, O>`
|
|
34
|
+
|
|
35
|
+
This applies uniformly to:
|
|
36
|
+
|
|
37
|
+
- browsers
|
|
38
|
+
- Node.js
|
|
39
|
+
- servers
|
|
40
|
+
- workers
|
|
41
|
+
|
|
42
|
+
No other stream type is part of the core contract.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### 2.2 Node.js interop (non-core)
|
|
47
|
+
|
|
48
|
+
Node classic streams (`stream.Readable`, `stream.Writable`) are **not** part of the
|
|
49
|
+
contract.
|
|
50
|
+
|
|
51
|
+
Interop with Node streams is handled by explicit Node adapter packages
|
|
52
|
+
(see [Node RFC](node.md)).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 3. Stream Roles
|
|
57
|
+
|
|
58
|
+
Streams appear in four distinct roles:
|
|
59
|
+
|
|
60
|
+
| Role | Type | Meaning |
|
|
61
|
+
| -------- | -------------- | ------------------------ |
|
|
62
|
+
| Input | WritableStream | accepts events |
|
|
63
|
+
| Output | ReadableStream | emits outputs |
|
|
64
|
+
| Error | ReadableStream | emits errors |
|
|
65
|
+
| Snapshot | ReadableStream | emits materialized state |
|
|
66
|
+
|
|
67
|
+
Roles are never overloaded.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 4. Transforms
|
|
72
|
+
|
|
73
|
+
A **transform** is a `TransformStream` that:
|
|
74
|
+
|
|
75
|
+
- preserves ordering
|
|
76
|
+
- preserves backpressure
|
|
77
|
+
- does not buffer unbounded data
|
|
78
|
+
|
|
79
|
+
Transforms are the **only mechanism** for:
|
|
80
|
+
|
|
81
|
+
- framing (NDJSON, SSE)
|
|
82
|
+
- durability
|
|
83
|
+
- filtering
|
|
84
|
+
- projection
|
|
85
|
+
- multiplexing
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 5. Framing Transforms
|
|
90
|
+
|
|
91
|
+
### 5.1 NDJSON
|
|
92
|
+
|
|
93
|
+
- newline-delimited JSON
|
|
94
|
+
- one logical record per chunk
|
|
95
|
+
- ordering preserved
|
|
96
|
+
- used for logs and bulk streaming
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### 5.2 SSE
|
|
101
|
+
|
|
102
|
+
- text-based framing
|
|
103
|
+
- browser-friendly
|
|
104
|
+
- transform-only
|
|
105
|
+
- no protocol semantics
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### 5.3 JSON (single value)
|
|
110
|
+
|
|
111
|
+
- non-streaming
|
|
112
|
+
- used for snapshots and acknowledgements
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 6. Durability Transforms
|
|
117
|
+
|
|
118
|
+
Durability is implemented as **stream transforms**.
|
|
119
|
+
|
|
120
|
+
Examples:
|
|
121
|
+
|
|
122
|
+
- Git-backed transforms
|
|
123
|
+
- Valkey-backed transforms
|
|
124
|
+
- filesystem-backed transforms
|
|
125
|
+
|
|
126
|
+
Rules:
|
|
127
|
+
|
|
128
|
+
- append-only
|
|
129
|
+
- ordering preserved
|
|
130
|
+
- replayable
|
|
131
|
+
- never implicit
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 7. Replay & Projection
|
|
136
|
+
|
|
137
|
+
**Replay** is reading from a durable stream and piping it into another stream.
|
|
138
|
+
|
|
139
|
+
**Projection** is transforming a stream into another representation **without
|
|
140
|
+
changing semantics**.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 8. Backpressure & Cancellation
|
|
145
|
+
|
|
146
|
+
- Backpressure MUST be respected
|
|
147
|
+
- Cancellation MUST propagate across transforms
|
|
148
|
+
- Closing a stream signals upstream cancellation
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 9. Invariants
|
|
153
|
+
|
|
154
|
+
1. Web Streams are the only core abstraction
|
|
155
|
+
2. Everything is a stream or transform
|
|
156
|
+
3. Framing does not change semantics
|
|
157
|
+
4. Durability is implemented as transforms
|
|
158
|
+
5. Ordering is preserved
|
|
159
|
+
6. Replay is deterministic
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 10. Lock statement
|
|
164
|
+
|
|
165
|
+
> Streams are the universal integration boundary in XMachines.
|
|
166
|
+
> All execution, transport, durability, and projection is expressed as streams
|
|
167
|
+
> and transforms.
|
|
168
|
+
> This is Streams.
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
[Documentation](../../../README.md) / [@xmachines/play-router](../README.md) / crawlMachine
|
|
2
|
-
|
|
3
|
-
# Function: crawlMachine()
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
function crawlMachine(machine): StateVisit[];
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Defined in: [crawl-machine.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-router/src/crawl-machine.ts#L74)
|
|
10
|
-
|
|
11
|
-
Crawl state machine graph using breadth-first traversal
|
|
12
|
-
|
|
13
|
-
Visits all state nodes in the machine, including deeply nested states, and returns
|
|
14
|
-
complete list of visits with path and parent information. This enables systematic
|
|
15
|
-
discovery of all states for route extraction and tree building.
|
|
16
|
-
|
|
17
|
-
**Architectural Context:** Implements **Actor Authority (INV-01)** by extracting
|
|
18
|
-
routing information from the state machine definition rather than external configuration.
|
|
19
|
-
The BFS traversal ensures all nested states are discovered, enabling the Actor to
|
|
20
|
-
define the complete navigation structure through its machine definition.
|
|
21
|
-
|
|
22
|
-
## Parameters
|
|
23
|
-
|
|
24
|
-
| Parameter | Type | Description |
|
|
25
|
-
| --------- | ------------------------------------------------------------------------- | -------------------------------- |
|
|
26
|
-
| `machine` | [`AnyStateMachine`](https://www.jsdocs.io/package/xstate#AnyStateMachine) | XState v5 state machine to crawl |
|
|
27
|
-
|
|
28
|
-
## Returns
|
|
29
|
-
|
|
30
|
-
[`StateVisit`](../interfaces/StateVisit.md)[]
|
|
31
|
-
|
|
32
|
-
Array of state visits in breadth-first order
|
|
33
|
-
|
|
34
|
-
## Examples
|
|
35
|
-
|
|
36
|
-
Basic machine crawl
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { createMachine } from "xstate";
|
|
40
|
-
import { crawlMachine } from "@xmachines/play-router";
|
|
41
|
-
|
|
42
|
-
const machine = createMachine({
|
|
43
|
-
initial: "home",
|
|
44
|
-
states: {
|
|
45
|
-
home: {},
|
|
46
|
-
dashboard: {
|
|
47
|
-
initial: "overview",
|
|
48
|
-
states: {
|
|
49
|
-
overview: {},
|
|
50
|
-
settings: {},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const visits = crawlMachine(machine);
|
|
57
|
-
// Returns visits for: root, home, dashboard, dashboard.overview, dashboard.settings
|
|
58
|
-
console.log(visits.map((v) => v.path.join(".")));
|
|
59
|
-
// ['', 'home', 'dashboard', 'dashboard.overview', 'dashboard.settings']
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Extract state paths and parents
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import { crawlMachine } from "@xmachines/play-router";
|
|
66
|
-
|
|
67
|
-
const visits = crawlMachine(machine);
|
|
68
|
-
visits.forEach((visit) => {
|
|
69
|
-
console.log({
|
|
70
|
-
path: visit.path.join(".") || "root",
|
|
71
|
-
hasParent: !!visit.parent,
|
|
72
|
-
hasChildren: Object.keys(visit.node.states).length > 0,
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## See
|
|
78
|
-
|
|
79
|
-
- [RFC Play v1](https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md)
|
|
80
|
-
- [extractRoute](extractRoute.md) for extracting route from individual states
|
|
81
|
-
- [extractMachineRoutes](extractMachineRoutes.md) for complete route extraction
|
|
82
|
-
- [StateVisit](../interfaces/StateVisit.md) for visit structure
|
|
83
|
-
|
|
84
|
-
## Remarks
|
|
85
|
-
|
|
86
|
-
**BFS Traversal:** Breadth-first search ensures systematic discovery of all states
|
|
87
|
-
at each nesting level before descending deeper. This produces a predictable ordering
|
|
88
|
-
useful for route tree construction and debugging.
|
|
89
|
-
|
|
90
|
-
**Path Format:** Paths use array notation (`['dashboard', 'settings']`) which can be
|
|
91
|
-
joined with dots for state IDs (`'dashboard.settings'`) matching XState's hierarchical
|
|
92
|
-
state naming convention.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
[Documentation](../../../README.md) / [@xmachines/play-router](../README.md) / extractRoute
|
|
2
|
-
|
|
3
|
-
# Function: extractRoute()
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
function extractRoute(node, path, stateMap): RouteInfo | null;
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Defined in: [extract-route.ts:26](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-router/src/extract-route.ts#L26)
|
|
10
|
-
|
|
11
|
-
Extract route information from state node with validation
|
|
12
|
-
|
|
13
|
-
States with meta.route are "routable" - they can receive play.route events
|
|
14
|
-
(when machine is wrapped with formatPlayRouteTransitions).
|
|
15
|
-
|
|
16
|
-
## Parameters
|
|
17
|
-
|
|
18
|
-
| Parameter | Type | Description |
|
|
19
|
-
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- |
|
|
20
|
-
| `node` | [`StateNode`](https://www.jsdocs.io/package/xstate#StateNode) | XState StateNode to extract route from |
|
|
21
|
-
| `path` | `string`[] | State path segments from root |
|
|
22
|
-
| `stateMap` | `Map`\<`string`, [`StateNode`](https://www.jsdocs.io/package/xstate#StateNode)\<[`MachineContext`](https://www.jsdocs.io/package/xstate#MachineContext), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\>\> | Map of all state IDs to StateNodes for validation |
|
|
23
|
-
|
|
24
|
-
## Returns
|
|
25
|
-
|
|
26
|
-
[`RouteInfo`](../interfaces/RouteInfo.md) \| `null`
|
|
27
|
-
|
|
28
|
-
RouteInfo if state has meta.route, null otherwise
|
|
29
|
-
|
|
30
|
-
## Throws
|
|
31
|
-
|
|
32
|
-
If route path is malformed (missing leading /)
|
|
33
|
-
|
|
34
|
-
## Throws
|
|
35
|
-
|
|
36
|
-
If route references non-existent state
|
|
37
|
-
|
|
38
|
-
## Example
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
const node = {
|
|
42
|
-
id: "dashboard",
|
|
43
|
-
meta: { route: "/dashboard" },
|
|
44
|
-
};
|
|
45
|
-
```
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
[Documentation](../../../README.md) / [@xmachines/play-router](../README.md) / StateVisit
|
|
2
|
-
|
|
3
|
-
# Interface: StateVisit
|
|
4
|
-
|
|
5
|
-
Defined in: [types.ts:28](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-router/src/types.ts#L28)
|
|
6
|
-
|
|
7
|
-
Represents a visit to a state node during graph crawling
|
|
8
|
-
|
|
9
|
-
## Properties
|
|
10
|
-
|
|
11
|
-
| Property | Type | Description | Defined in |
|
|
12
|
-
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
-
| <a id="property-node"></a> `node` | [`StateNode`](https://www.jsdocs.io/package/xstate#StateNode) | The state node being visited | [types.ts:30](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-router/src/types.ts#L30) |
|
|
14
|
-
| <a id="property-parent"></a> `parent` | \| [`StateNode`](https://www.jsdocs.io/package/xstate#StateNode)\<[`MachineContext`](https://www.jsdocs.io/package/xstate#MachineContext), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> \| `null` | Parent state node (null for root) | [types.ts:34](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-router/src/types.ts#L34) |
|
|
15
|
-
| <a id="property-path"></a> `path` | `string`[] | Path from root to this state (e.g., ['dashboard', 'overview']) | [types.ts:32](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-router/src/types.ts#L32) |
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / extractMachineRoutes
|
|
2
|
-
|
|
3
|
-
# Variable: extractMachineRoutes
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
const extractMachineRoutes: (machine) => RouteTree;
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Defined in: play-router/dist/extract-routes.d.ts:40
|
|
10
|
-
|
|
11
|
-
Extract complete route tree from state machine graph
|
|
12
|
-
|
|
13
|
-
Crawls machine starting from root, visits all state nodes (including nested
|
|
14
|
-
and parallel), extracts meta.route metadata, validates route references,
|
|
15
|
-
and builds hierarchical tree.
|
|
16
|
-
|
|
17
|
-
## Parameters
|
|
18
|
-
|
|
19
|
-
| Parameter | Type | Description |
|
|
20
|
-
| --------- | ------------------------------------------------------------------------- | ----------------------- |
|
|
21
|
-
| `machine` | [`AnyStateMachine`](https://www.jsdocs.io/package/xstate#AnyStateMachine) | XState v5 state machine |
|
|
22
|
-
|
|
23
|
-
## Returns
|
|
24
|
-
|
|
25
|
-
[`RouteTree`](../../play-router/interfaces/RouteTree.md)
|
|
26
|
-
|
|
27
|
-
Route tree with root, byStateId map, and byPath map
|
|
28
|
-
|
|
29
|
-
## Throws
|
|
30
|
-
|
|
31
|
-
If route references non-existent state
|
|
32
|
-
|
|
33
|
-
## Throws
|
|
34
|
-
|
|
35
|
-
If route path is malformed (doesn't start with /)
|
|
36
|
-
|
|
37
|
-
## Throws
|
|
38
|
-
|
|
39
|
-
If parallel states define conflicting routes
|
|
40
|
-
|
|
41
|
-
## Example
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { createMachine } from "xstate";
|
|
45
|
-
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
46
|
-
|
|
47
|
-
const machine = createMachine({
|
|
48
|
-
initial: "home",
|
|
49
|
-
states: {
|
|
50
|
-
home: { id: "home", meta: { route: "/" } },
|
|
51
|
-
dashboard: {
|
|
52
|
-
id: "dashboard",
|
|
53
|
-
meta: { route: "/dashboard" },
|
|
54
|
-
initial: "overview",
|
|
55
|
-
states: {
|
|
56
|
-
overview: { id: "overview", meta: { route: "/overview" } },
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const tree = extractMachineRoutes(machine);
|
|
63
|
-
console.log(tree.byPath.get("/dashboard/overview"));
|
|
64
|
-
```
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / stateMatches
|
|
2
|
-
|
|
3
|
-
# Function: stateMatches()
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
function stateMatches<TContext>(stateValue): Guard<TContext, PlayEvent>;
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Defined in: [packages/play-xstate/src/guards/helpers.ts:75](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-xstate/src/guards/helpers.ts#L75)
|
|
10
|
-
|
|
11
|
-
## Type Parameters
|
|
12
|
-
|
|
13
|
-
| Type Parameter | Default type |
|
|
14
|
-
| -------------- | ------------------------------- |
|
|
15
|
-
| `TContext` | `Record`\<`string`, `unknown`\> |
|
|
16
|
-
|
|
17
|
-
## Parameters
|
|
18
|
-
|
|
19
|
-
| Parameter | Type |
|
|
20
|
-
| ------------ | -------- |
|
|
21
|
-
| `stateValue` | `string` |
|
|
22
|
-
|
|
23
|
-
## Returns
|
|
24
|
-
|
|
25
|
-
[`Guard`](../type-aliases/Guard.md)\<`TContext`, [`PlayEvent`](../../play/type-aliases/PlayEvent.md)\>
|