@xmachines/docs 1.0.0-beta.15 → 1.0.0-beta.17

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 (197) hide show
  1. package/api/@xmachines/play/README.md +56 -17
  2. package/api/@xmachines/play/classes/PlayError.md +240 -0
  3. package/api/@xmachines/play/type-aliases/PlayEvent.md +4 -4
  4. package/api/@xmachines/play-actor/README.md +32 -31
  5. package/api/@xmachines/play-actor/classes/AbstractActor.md +65 -53
  6. package/api/@xmachines/play-actor/interfaces/PlaySpec.md +37 -0
  7. package/api/@xmachines/play-actor/interfaces/Routable.md +5 -4
  8. package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +6 -6
  9. package/api/@xmachines/play-actor/interfaces/Viewable.md +8 -8
  10. package/api/@xmachines/play-dom/README.md +36 -0
  11. package/api/@xmachines/play-dom/classes/PlayRenderer.md +83 -0
  12. package/api/@xmachines/play-dom/functions/connectRenderer.md +51 -0
  13. package/api/@xmachines/play-dom/functions/renderSpec.md +28 -0
  14. package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +18 -0
  15. package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +18 -0
  16. package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +14 -0
  17. package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +23 -0
  18. package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +11 -0
  19. package/api/@xmachines/play-react/README.md +226 -305
  20. package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +12 -38
  21. package/api/@xmachines/play-react/functions/defineRegistry.md +47 -0
  22. package/api/@xmachines/play-react/functions/useActor.md +13 -0
  23. package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
  24. package/api/@xmachines/play-react/functions/useStateBinding.md +32 -0
  25. package/api/@xmachines/play-react/interfaces/ComponentContext.md +35 -0
  26. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
  27. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
  28. package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +15 -7
  29. package/api/@xmachines/play-react/type-aliases/ComponentFn.md +34 -0
  30. package/api/@xmachines/play-react/type-aliases/PlayActor.md +9 -0
  31. package/api/@xmachines/play-react/variables/PlayRenderer.md +18 -30
  32. package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +32 -32
  33. package/api/@xmachines/play-react-router/classes/RouteMap.md +5 -5
  34. package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +11 -5
  35. package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
  36. package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +14 -8
  37. package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
  38. package/api/@xmachines/play-router/README.md +51 -0
  39. package/api/@xmachines/play-router/classes/BaseRouteMap.md +6 -6
  40. package/api/@xmachines/play-router/classes/RouterBridgeBase.md +44 -40
  41. package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
  42. package/api/@xmachines/play-router/functions/connectRouter.md +1 -1
  43. package/api/@xmachines/play-router/functions/crawlMachine.md +1 -1
  44. package/api/@xmachines/play-router/functions/createBrowserHistory.md +4 -1
  45. package/api/@xmachines/play-router/functions/createRouteMap.md +3 -3
  46. package/api/@xmachines/play-router/functions/createRouter.md +1 -1
  47. package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
  48. package/api/@xmachines/play-router/functions/extractMachineRoutes.md +1 -1
  49. package/api/@xmachines/play-router/functions/extractRoute.md +1 -1
  50. package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
  51. package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
  52. package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
  53. package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
  54. package/api/@xmachines/play-router/functions/routeExists.md +1 -1
  55. package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
  56. package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
  57. package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +3 -3
  58. package/api/@xmachines/play-router/interfaces/BrowserHistory.md +19 -15
  59. package/api/@xmachines/play-router/interfaces/BrowserWindow.md +14 -14
  60. package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +6 -6
  61. package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
  62. package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
  63. package/api/@xmachines/play-router/interfaces/RouteMap.md +4 -4
  64. package/api/@xmachines/play-router/interfaces/RouteNode.md +10 -10
  65. package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
  66. package/api/@xmachines/play-router/interfaces/RouteTree.md +4 -4
  67. package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +55 -0
  68. package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
  69. package/api/@xmachines/play-router/interfaces/StateVisit.md +4 -4
  70. package/api/@xmachines/play-router/interfaces/VanillaRouter.md +4 -4
  71. package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
  72. package/api/@xmachines/play-signals/README.md +22 -10
  73. package/api/@xmachines/play-signals/functions/watchSignal.md +35 -0
  74. package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
  75. package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
  76. package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
  77. package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
  78. package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
  79. package/api/@xmachines/play-signals/namespaces/Signal/classes/Computed.md +3 -9
  80. package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +3 -11
  81. package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +5 -7
  82. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +3 -13
  83. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +0 -2
  84. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +0 -2
  85. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +0 -2
  86. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +0 -2
  87. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +0 -2
  88. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +0 -2
  89. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +0 -2
  90. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +0 -2
  91. package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +0 -2
  92. package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +0 -2
  93. package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +0 -2
  94. package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
  95. package/api/@xmachines/play-solid/README.md +193 -219
  96. package/api/@xmachines/play-solid/functions/defineRegistry.md +47 -0
  97. package/api/@xmachines/play-solid/functions/useActor.md +13 -0
  98. package/api/@xmachines/play-solid/functions/useStateBinding.md +23 -0
  99. package/api/@xmachines/play-solid/interfaces/ComponentContext.md +35 -0
  100. package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +15 -7
  101. package/api/@xmachines/play-solid/type-aliases/ComponentFn.md +34 -0
  102. package/api/@xmachines/play-solid/type-aliases/PlayActor.md +9 -0
  103. package/api/@xmachines/play-solid/variables/PlayRenderer.md +15 -43
  104. package/api/@xmachines/play-solid-router/README.md +2 -0
  105. package/api/@xmachines/play-solid-router/classes/RouteMap.md +6 -6
  106. package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +37 -37
  107. package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +11 -5
  108. package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
  109. package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +65 -51
  110. package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +14 -8
  111. package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
  112. package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +3 -1
  113. package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
  114. package/api/@xmachines/play-tanstack-react-router/README.md +1 -5
  115. package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +5 -5
  116. package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +45 -33
  117. package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +11 -5
  118. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +2 -2
  119. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
  120. package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +1 -1
  121. package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +1 -1
  122. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +14 -8
  123. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
  124. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
  125. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
  126. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +24 -4
  127. package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +6 -6
  128. package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +33 -33
  129. package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +11 -5
  130. package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
  131. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +14 -8
  132. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
  133. package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +3 -1
  134. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
  135. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +4 -4
  136. package/api/@xmachines/play-vue/README.md +216 -209
  137. package/api/@xmachines/play-vue/functions/defineRegistry.md +32 -0
  138. package/api/@xmachines/play-vue/functions/useActor.md +13 -0
  139. package/api/@xmachines/play-vue/functions/useStateBinding.md +30 -0
  140. package/api/@xmachines/play-vue/interfaces/ComponentContext.md +35 -0
  141. package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +14 -6
  142. package/api/@xmachines/play-vue/type-aliases/ComponentFn.md +33 -0
  143. package/api/@xmachines/play-vue/type-aliases/PlayActor.md +9 -0
  144. package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
  145. package/api/@xmachines/play-vue-router/README.md +21 -0
  146. package/api/@xmachines/play-vue-router/classes/RouteMap.md +7 -7
  147. package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +7 -7
  148. package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +46 -49
  149. package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
  150. package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +4 -4
  151. package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +3 -1
  152. package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +7 -1
  153. package/api/@xmachines/play-xstate/README.md +250 -107
  154. package/api/@xmachines/play-xstate/classes/PlayerActor.md +77 -55
  155. package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +24 -18
  156. package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
  157. package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
  158. package/api/@xmachines/play-xstate/functions/definePlayer.md +12 -61
  159. package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
  160. package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
  161. package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
  162. package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
  163. package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
  164. package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
  165. package/api/@xmachines/play-xstate/functions/stateMatches.md +1 -1
  166. package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +9 -13
  167. package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +22 -0
  168. package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +8 -9
  169. package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
  170. package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
  171. package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
  172. package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
  173. package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +6 -5
  174. package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +14 -4
  175. package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +19 -4
  176. package/api/@xmachines/shared/functions/defineXmVitestConfig.md +2 -2
  177. package/api/@xmachines/shared/functions/xmAliases.md +1 -1
  178. package/api/README.md +1 -1
  179. package/api/llms.txt +11 -5
  180. package/examples/README.md +20 -6
  181. package/examples/multi-router-integration.md +33 -24
  182. package/examples/routing-patterns.md +2 -3
  183. package/package.json +3 -3
  184. package/api/@xmachines/play-catalog/README.md +0 -331
  185. package/api/@xmachines/play-catalog/functions/defineCatalog.md +0 -98
  186. package/api/@xmachines/play-catalog/functions/defineComponents.md +0 -134
  187. package/api/@xmachines/play-catalog/type-aliases/Catalog.md +0 -48
  188. package/api/@xmachines/play-catalog/type-aliases/ComponentsFor.md +0 -20
  189. package/api/@xmachines/play-catalog/type-aliases/InferComponentProps.md +0 -65
  190. package/api/@xmachines/play-catalog/type-aliases/NoExtraKeys.md +0 -17
  191. package/api/@xmachines/play-xstate/functions/mergeViewProps.md +0 -26
  192. package/api/@xmachines/play-xstate/functions/validateComponentBinding.md +0 -39
  193. package/api/@xmachines/play-xstate/functions/validateViewProps.md +0 -80
  194. package/api/@xmachines/play-xstate/interfaces/CatalogEntry.md +0 -16
  195. package/api/@xmachines/play-xstate/type-aliases/Catalog.md +0 -21
  196. package/api/@xmachines/play-xstate/type-aliases/ValidationResult.md +0 -17
  197. package/api/@xmachines/play-xstate/type-aliases/ViewMergeContext.md +0 -35
@@ -4,11 +4,13 @@
4
4
 
5
5
  **Protocol layer defining Actor ↔ Infrastructure event contracts for XMachines Play Architecture.**
6
6
 
7
- `@xmachines/play` is intentionally small. It provides the base event contract used across adapters and actor implementations while keeping framework/runtime concerns out of business logic.
7
+ `@xmachines/play` is intentionally small. It provides the base event type and the base error
8
+ class used across all adapters and actor implementations, while keeping framework and runtime
9
+ concerns out of business logic.
8
10
 
9
11
  ## Overview
10
12
 
11
- This package exports protocol types only (no runtime behavior). It exists to preserve strict separation between:
13
+ This package exports the shared Play protocol surface. It exists to preserve strict separation between:
12
14
 
13
15
  - **Actors** (business authority)
14
16
  - **Infrastructure adapters** (routers/renderers that observe and forward)
@@ -29,40 +31,73 @@ npm install @xmachines/play
29
31
 
30
32
  This package exports:
31
33
 
32
- - `PlayEvent<TPayload>`
34
+ | Export | Type | Purpose |
35
+ | ----------- | ----- | ------------------------------------------------- |
36
+ | `PlayEvent` | type | Minimal event shape — `{ type: string, ...rest }` |
37
+ | `PlayError` | class | Base class for all `@xmachines/*` typed errors |
33
38
 
34
- `PlayEvent` is the minimal event shape:
39
+ ### `PlayEvent`
35
40
 
36
- ```ts
37
- type PlayEvent<TPayload extends Record<string, any> = Record<string, any>> = {
38
- readonly type: string;
39
- } & TPayload;
41
+ ```typescript
42
+ import type { PlayEvent } from "@xmachines/play";
43
+
44
+ // Flexible (default):
45
+ const event: PlayEvent = { type: "auth.login", userId: "123" };
46
+
47
+ // Type-safe (with generic):
48
+ type LoginEvent = PlayEvent<{ userId: string }>;
49
+ const login: LoginEvent = { type: "auth.login", userId: "123" };
40
50
  ```
41
51
 
42
- ## Usage
52
+ ### `PlayError`
43
53
 
44
- ### Base event usage
54
+ Base class for all typed runtime errors thrown by `@xmachines/*` packages.
45
55
 
46
- ```ts
47
- import type { PlayEvent } from "@xmachines/play";
56
+ Every `PlayError` carries two structured fields:
48
57
 
49
- type LoginEvent = PlayEvent<{ userId: string }>;
58
+ - **`scope`** the class or module that threw (e.g. `"RouterBridgeBase"`)
59
+ - **`code`** — a stable, machine-readable identifier (e.g. `"PLAY_ROUTER_SYNC_FAILED"`)
50
60
 
51
- const event: LoginEvent = {
52
- type: "auth.login",
53
- userId: "user-123",
54
- };
61
+ ```typescript
62
+ import { PlayError } from "@xmachines/play";
63
+
64
+ // Catching any @xmachines/* error:
65
+ try {
66
+ bridge.connect();
67
+ } catch (err) {
68
+ if (err instanceof PlayError) {
69
+ console.error(`[${err.scope}:${err.code}] ${err.message}`);
70
+ }
71
+ }
55
72
  ```
56
73
 
74
+ Package-specific subclasses are exported from each package's `./errors` subpath:
75
+
76
+ ```typescript
77
+ import { RouterSyncError } from "@xmachines/play-router/errors";
78
+ import { InvalidEventError, MissingRouteParamError } from "@xmachines/play-xstate/errors";
79
+ import {
80
+ MissingCatalogError,
81
+ MissingComponentError,
82
+ RendererError,
83
+ } from "@xmachines/play-react/errors";
84
+ import { MissingCatalogError, MissingComponentError } from "@xmachines/play-solid/errors";
85
+ import { VueRouterCorrectionError } from "@xmachines/play-vue-router/errors";
86
+ ```
87
+
88
+ See each package's README for the full list of error classes and when they are thrown.
89
+
57
90
  ## Architecture Notes
58
91
 
59
92
  - Keep `@xmachines/play` as the base protocol boundary.
60
93
  - Keep actor implementation details in adapter packages such as `@xmachines/play-xstate`.
94
+ - Never match on `.message` strings — always match on `instanceof` or `.code`.
61
95
 
62
96
  ## Related Packages
63
97
 
64
98
  - [@xmachines/play-actor](../play-actor/README.md)
65
99
  - [@xmachines/play-xstate](../play-xstate/README.md)
100
+ - [@xmachines/play-router](../play-router/README.md)
66
101
 
67
102
  ## License
68
103
 
@@ -125,6 +160,10 @@ These protocols enforce the following invariants:
125
160
  4. **Signal-Only Reactivity**: All state changes flow through TC39 Signals
126
161
  5. **State-Driven Reset**: Navigation follows state machine transition rules
127
162
 
163
+ ## Classes
164
+
165
+ - [PlayError](classes/PlayError.md)
166
+
128
167
  ## Type Aliases
129
168
 
130
169
  - [PlayEvent](type-aliases/PlayEvent.md)
@@ -0,0 +1,240 @@
1
+ [Documentation](../../../README.md) / [@xmachines/play](../README.md) / PlayError
2
+
3
+ # Class: PlayError
4
+
5
+ Defined in: [packages/play/src/errors.ts:63](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play/src/errors.ts#L63)
6
+
7
+ Base class for all typed runtime errors thrown by `@xmachines/*` packages.
8
+
9
+ `PlayError` gives every error two structured fields:
10
+
11
+ - `scope` — the class or module that threw (e.g. `"RouterBridgeBase"`)
12
+ - `code` — a stable, machine-readable identifier (e.g. `"PLAY_ROUTER_SYNC_FAILED"`)
13
+
14
+ These fields let application code branch on error type without parsing `.message`
15
+ strings, which change across releases.
16
+
17
+ ## Error codes
18
+
19
+ Each `@xmachines/*` package exports its own typed subclasses from an
20
+ `"./errors"` subpath:
21
+
22
+ | Package | Import |
23
+ | ---------------------------- | ----------------------------------- |
24
+ | `@xmachines/play-router` | `@xmachines/play-router/errors` |
25
+ | `@xmachines/play-vue-router` | `@xmachines/play-vue-router/errors` |
26
+ | `@xmachines/play-xstate` | `@xmachines/play-xstate/errors` |
27
+ | `@xmachines/play-react` | `@xmachines/play-react/errors` |
28
+ | `@xmachines/play-solid` | `@xmachines/play-solid/errors` |
29
+
30
+ `PlayError` itself is exported from the root `@xmachines/play` and is the base
31
+ for all of those subclasses.
32
+
33
+ ## Catching errors by type
34
+
35
+ ```typescript
36
+ import { PlayError } from "@xmachines/play";
37
+ import { RouterSyncError } from "@xmachines/play-router/errors";
38
+
39
+ try {
40
+ bridge.connect();
41
+ } catch (err) {
42
+ if (err instanceof RouterSyncError) {
43
+ // err.scope === "RouterBridgeBase"
44
+ // err.code === "PLAY_ROUTER_SYNC_FAILED"
45
+ // err.cause — the original error that triggered the sync failure
46
+ reportToMonitoring(err);
47
+ } else if (err instanceof PlayError) {
48
+ // Any other @xmachines/* error
49
+ console.error(`[${err.scope}:${err.code}] ${err.message}`);
50
+ } else {
51
+ throw err; // Re-throw unknown errors
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## Extending PlayError
57
+
58
+ ```typescript
59
+ import { PlayError } from "@xmachines/play";
60
+
61
+ export class MyPackageError extends PlayError {
62
+ constructor(message: string, options?: ErrorOptions) {
63
+ super("MyScope", "MY_PACKAGE_ERROR_CODE", message, options);
64
+ this.name = "MyPackageError";
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## Extends
70
+
71
+ - `Error`
72
+
73
+ ## Constructors
74
+
75
+ ### Constructor
76
+
77
+ ```ts
78
+ new PlayError(
79
+ scope,
80
+ code,
81
+ message,
82
+ options?): PlayError;
83
+ ```
84
+
85
+ Defined in: [packages/play/src/errors.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play/src/errors.ts#L82)
86
+
87
+ #### Parameters
88
+
89
+ | Parameter | Type | Description |
90
+ | ---------- | -------------- | ------------------------------------------------------------------------- |
91
+ | `scope` | `string` | The class or module throwing this error. |
92
+ | `code` | `string` | Machine-readable error identifier (e.g. `"PLAY_ROUTER_SYNC_FAILED"`). |
93
+ | `message` | `string` | Human-readable description. Do not match on this in code. |
94
+ | `options?` | `ErrorOptions` | Standard `ErrorOptions`; pass `{ cause: originalError }` to chain errors. |
95
+
96
+ #### Returns
97
+
98
+ `PlayError`
99
+
100
+ #### Overrides
101
+
102
+ ```ts
103
+ Error.constructor;
104
+ ```
105
+
106
+ ## Properties
107
+
108
+ | Property | Modifier | Type | Description | Inherited from | Defined in |
109
+ | ------------------------------------------------------- | ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
110
+ | <a id="property-cause"></a> `cause?` | `public` | `unknown` | - | `Error.cause` | - |
111
+ | <a id="property-code"></a> `code` | `readonly` | `string` | A stable, machine-readable error identifier. Error codes follow the `PLAY_<PACKAGE>_<DESCRIPTION>` naming convention and are guaranteed stable across patch and minor releases within a major version. Never match on `.message` — always match on `.code` or the subclass. | - | [packages/play/src/errors.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play/src/errors.ts#L74) |
112
+ | <a id="property-message"></a> `message` | `public` | `string` | - | `Error.message` | - |
113
+ | <a id="property-name"></a> `name` | `public` | `string` | - | `Error.name` | - |
114
+ | <a id="property-scope"></a> `scope` | `readonly` | `string` | The class or module that threw this error (e.g. `"RouterBridgeBase"`). | - | [packages/play/src/errors.ts:65](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play/src/errors.ts#L65) |
115
+ | <a id="property-stack"></a> `stack?` | `public` | `string` | - | `Error.stack` | - |
116
+ | <a id="property-stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | - |
117
+
118
+ ## Methods
119
+
120
+ ### captureStackTrace()
121
+
122
+ ```ts
123
+ static captureStackTrace(targetObject, constructorOpt?): void;
124
+ ```
125
+
126
+ Creates a `.stack` property on `targetObject`, which when accessed returns
127
+ a string representing the location in the code at which
128
+ `Error.captureStackTrace()` was called.
129
+
130
+ ```js
131
+ const myObject = {};
132
+ Error.captureStackTrace(myObject);
133
+ myObject.stack; // Similar to `new Error().stack`
134
+ ```
135
+
136
+ The first line of the trace will be prefixed with
137
+ `${myObject.name}: ${myObject.message}`.
138
+
139
+ The optional `constructorOpt` argument accepts a function. If given, all frames
140
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
141
+ generated stack trace.
142
+
143
+ The `constructorOpt` argument is useful for hiding implementation
144
+ details of error generation from the user. For instance:
145
+
146
+ ```js
147
+ function a() {
148
+ b();
149
+ }
150
+
151
+ function b() {
152
+ c();
153
+ }
154
+
155
+ function c() {
156
+ // Create an error without stack trace to avoid calculating the stack trace twice.
157
+ const { stackTraceLimit } = Error;
158
+ Error.stackTraceLimit = 0;
159
+ const error = new Error();
160
+ Error.stackTraceLimit = stackTraceLimit;
161
+
162
+ // Capture the stack trace above function b
163
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
164
+ throw error;
165
+ }
166
+
167
+ a();
168
+ ```
169
+
170
+ #### Parameters
171
+
172
+ | Parameter | Type |
173
+ | ----------------- | ---------- |
174
+ | `targetObject` | `object` |
175
+ | `constructorOpt?` | `Function` |
176
+
177
+ #### Returns
178
+
179
+ `void`
180
+
181
+ #### Inherited from
182
+
183
+ ```ts
184
+ Error.captureStackTrace;
185
+ ```
186
+
187
+ ---
188
+
189
+ ### isError()
190
+
191
+ ```ts
192
+ static isError(error): error is Error;
193
+ ```
194
+
195
+ Indicates whether the argument provided is a built-in Error instance or not.
196
+
197
+ #### Parameters
198
+
199
+ | Parameter | Type |
200
+ | --------- | --------- |
201
+ | `error` | `unknown` |
202
+
203
+ #### Returns
204
+
205
+ `error is Error`
206
+
207
+ #### Inherited from
208
+
209
+ ```ts
210
+ Error.isError;
211
+ ```
212
+
213
+ ---
214
+
215
+ ### prepareStackTrace()
216
+
217
+ ```ts
218
+ static prepareStackTrace(err, stackTraces): any;
219
+ ```
220
+
221
+ #### Parameters
222
+
223
+ | Parameter | Type |
224
+ | ------------- | ------------ |
225
+ | `err` | `Error` |
226
+ | `stackTraces` | `CallSite`[] |
227
+
228
+ #### Returns
229
+
230
+ `any`
231
+
232
+ #### See
233
+
234
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
235
+
236
+ #### Inherited from
237
+
238
+ ```ts
239
+ Error.prepareStackTrace;
240
+ ```
@@ -6,7 +6,7 @@
6
6
  type PlayEvent<TPayload> = object & TPayload;
7
7
  ```
8
8
 
9
- Defined in: [types.ts:69](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.15/packages/play/src/types.ts#L69)
9
+ Defined in: [packages/play/src/types.ts:69](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play/src/types.ts#L69)
10
10
 
11
11
  Generic event type for Play Architecture
12
12
 
@@ -32,9 +32,9 @@ Robot, and other state machine libraries.
32
32
 
33
33
  ## Type Declaration
34
34
 
35
- | Name | Type | Defined in |
36
- | ------ | -------- | -------------------------------------------------------------------------------------------------------------- |
37
- | `type` | `string` | [types.ts:70](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.15/packages/play/src/types.ts#L70) |
35
+ | Name | Type | Defined in |
36
+ | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
37
+ | `type` | `string` | [packages/play/src/types.ts:70](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play/src/types.ts#L70) |
38
38
 
39
39
  ## Type Parameters
40
40
 
@@ -30,6 +30,7 @@ npm install @xmachines/play-actor
30
30
  - `AbstractActor`
31
31
  - `Routable` (type)
32
32
  - `Viewable` (type)
33
+ - `ViewMetadata` (type)
33
34
 
34
35
  **Peer dependencies:**
35
36
 
@@ -45,7 +46,7 @@ npm install @xmachines/play-actor
45
46
  import { definePlayer } from "@xmachines/play-xstate";
46
47
 
47
48
  // definePlayer returns PlayerActor (extends AbstractActor)
48
- const createPlayer = definePlayer({ machine, catalog });
49
+ const createPlayer = definePlayer({ machine });
49
50
  const actor = createPlayer();
50
51
  actor.start();
51
52
 
@@ -73,8 +74,7 @@ Implement `Routable` to add routing support:
73
74
 
74
75
  Implement `Viewable` to add view rendering support:
75
76
 
76
- - `currentView: Signal.State<ViewMetadata | null>` - Current UI structure (updated at state entry)
77
- - `catalog: Record<string, unknown>` - Component catalog
77
+ - `currentView: Signal.State<ViewMetadata | null>` - Current view spec (updated on every state transition). `ViewMetadata` has the shape `{ component: string; spec: Spec }` where `spec` is a `@json-render/core` spec object driving the renderer.
78
78
 
79
79
  **Inherited from XState Actor:**
80
80
 
@@ -86,39 +86,39 @@ Implement `Viewable` to add view rendering support:
86
86
  **Example implementation pattern:**
87
87
 
88
88
  ```typescript
89
- import { AbstractActor, type Routable, type Viewable, type ViewMetadata } from "@xmachines/play-actor";
89
+ import {
90
+ AbstractActor,
91
+ type Routable,
92
+ type Viewable,
93
+ type ViewMetadata,
94
+ } from "@xmachines/play-actor";
90
95
  import { Signal } from "@xmachines/play-signals";
91
96
  import type { AnyActorLogic, AnyMachineSnapshot } from "xstate";
92
97
 
93
98
  class PlayerActor<TLogic extends AnyActorLogic>
94
- extends AbstractActor<TLogic>
95
- implements Routable, Viewable
99
+ extends AbstractActor<TLogic>
100
+ implements Routable, Viewable
96
101
  {
97
- // Required: reactive state snapshot
98
- state = new Signal.State<AnyMachineSnapshot>(this.getSnapshot() as AnyMachineSnapshot);
99
-
100
- // Routable: derived navigation path
101
- currentRoute = new Signal.Computed(() => {
102
- return deriveRoute(this.state.get());
103
- });
104
-
105
- // Viewable: current UI structure — Signal.State, updated at state entry (not computed)
106
- currentView = new Signal.State<ViewMetadata | null>(null);
107
-
108
- // Viewable: component catalog
109
- catalog: Record<string, unknown>;
110
-
111
- constructor(logic: TLogic, catalog: Record<string, unknown>) {
112
- super(logic);
113
- this.catalog = catalog;
114
-
115
- // Subscribe to XState transitions and update signals
116
- this.subscribe((snapshot) => {
117
- this.state.set(snapshot as AnyMachineSnapshot);
118
- // Update currentView based on snapshot meta...
119
- });
120
- }
121
- }
102
+ // Required: reactive state snapshot
103
+ state = new Signal.State<AnyMachineSnapshot>(this.getSnapshot() as AnyMachineSnapshot);
104
+
105
+ // Routable: derived navigation path
106
+ currentRoute = new Signal.Computed(() => {
107
+ return deriveRoute(this.state.get());
108
+ });
109
+
110
+ // Viewable: current view spec — Signal.State, updated on every state transition
111
+ currentView = new Signal.State<ViewMetadata | null>(null);
112
+
113
+ constructor(logic: TLogic) {
114
+ super(logic);
115
+
116
+ // Subscribe to XState transitions and update signals
117
+ this.subscribe((snapshot) => {
118
+ this.state.set(snapshot as AnyMachineSnapshot);
119
+ // Derive currentView from snapshot meta and update the signal...
120
+ });
121
+ }
122
122
  }
123
123
  ```
124
124
 
@@ -242,6 +242,7 @@ reactive signals for Infrastructure layer communication.
242
242
 
243
243
  ## Interfaces
244
244
 
245
+ - [PlaySpec](interfaces/PlaySpec.md)
245
246
  - [Routable](interfaces/Routable.md)
246
247
  - [Viewable](interfaces/Viewable.md)
247
248
  - [ViewMetadata](interfaces/ViewMetadata.md)