@xmachines/docs 1.0.0-beta.16 → 1.0.0-beta.18
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 +56 -17
- package/api/@xmachines/play/classes/PlayError.md +240 -0
- package/api/@xmachines/play/type-aliases/PlayEvent.md +4 -4
- package/api/@xmachines/play-actor/README.md +32 -31
- package/api/@xmachines/play-actor/classes/AbstractActor.md +20 -19
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +37 -0
- package/api/@xmachines/play-actor/interfaces/Routable.md +5 -4
- package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +6 -6
- package/api/@xmachines/play-actor/interfaces/Viewable.md +8 -8
- package/api/@xmachines/play-dom/README.md +36 -0
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +83 -0
- package/api/@xmachines/play-dom/functions/connectRenderer.md +51 -0
- package/api/@xmachines/play-dom/functions/renderSpec.md +28 -0
- package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +18 -0
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +18 -0
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +14 -0
- package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +23 -0
- package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +11 -0
- package/api/@xmachines/play-react/README.md +227 -305
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
- package/api/@xmachines/play-react/functions/defineRegistry.md +47 -0
- package/api/@xmachines/play-react/functions/useActor.md +13 -0
- package/api/@xmachines/play-react/functions/useBoundProp.md +43 -0
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/functions/useStateBinding.md +32 -0
- package/api/@xmachines/play-react/interfaces/ComponentContext.md +35 -0
- 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 +15 -7
- package/api/@xmachines/play-react/type-aliases/ComponentFn.md +34 -0
- package/api/@xmachines/play-react/type-aliases/PlayActor.md +9 -0
- package/api/@xmachines/play-react/variables/PlayRenderer.md +18 -30
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +32 -32
- package/api/@xmachines/play-react-router/classes/RouteMap.md +5 -5
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +11 -5
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +14 -8
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-router/README.md +51 -0
- package/api/@xmachines/play-router/classes/BaseRouteMap.md +6 -6
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +33 -35
- 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/crawlMachine.md +1 -1
- package/api/@xmachines/play-router/functions/createBrowserHistory.md +4 -1
- package/api/@xmachines/play-router/functions/createRouteMap.md +3 -3
- 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 +1 -1
- package/api/@xmachines/play-router/functions/extractRoute.md +1 -1
- 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/routeExists.md +1 -1
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
- package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
- package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +3 -3
- package/api/@xmachines/play-router/interfaces/BrowserHistory.md +19 -15
- package/api/@xmachines/play-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
- 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 +10 -10
- package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
- package/api/@xmachines/play-router/interfaces/RouteTree.md +4 -4
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +55 -0
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-router/interfaces/StateVisit.md +4 -4
- package/api/@xmachines/play-router/interfaces/VanillaRouter.md +4 -4
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-signals/README.md +22 -10
- package/api/@xmachines/play-signals/functions/watchSignal.md +35 -0
- 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 +193 -219
- package/api/@xmachines/play-solid/functions/defineRegistry.md +47 -0
- package/api/@xmachines/play-solid/functions/useActor.md +13 -0
- package/api/@xmachines/play-solid/functions/useStateBinding.md +23 -0
- package/api/@xmachines/play-solid/interfaces/ComponentContext.md +35 -0
- package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +15 -7
- package/api/@xmachines/play-solid/type-aliases/ComponentFn.md +34 -0
- package/api/@xmachines/play-solid/type-aliases/PlayActor.md +9 -0
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +15 -43
- package/api/@xmachines/play-solid-router/README.md +56 -30
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +6 -6
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +37 -37
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +11 -5
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +18 -17
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +14 -8
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +3 -1
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/README.md +1 -5
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +45 -33
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +11 -5
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
- 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/PlayRouterProviderProps.md +14 -8
- 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/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +24 -4
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +6 -6
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +33 -33
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +11 -5
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +14 -8
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +3 -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 +219 -209
- package/api/@xmachines/play-vue/functions/defineRegistry.md +32 -0
- package/api/@xmachines/play-vue/functions/useActor.md +13 -0
- package/api/@xmachines/play-vue/functions/useStateBinding.md +30 -0
- package/api/@xmachines/play-vue/interfaces/ComponentContext.md +35 -0
- package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +14 -6
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +16 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentFn.md +33 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +15 -0
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +21 -0
- package/api/@xmachines/play-vue/type-aliases/PlayActor.md +9 -0
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +74 -29
- 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 +48 -51
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +4 -4
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +3 -1
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +7 -1
- package/api/@xmachines/play-xstate/README.md +236 -111
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +36 -33
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +24 -18
- 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/definePlayer.md +12 -61
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
- 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/functions/stateMatches.md +1 -1
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +9 -13
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +8 -9
- 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 +14 -4
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +19 -4
- package/api/@xmachines/shared/functions/defineXmVitestConfig.md +2 -2
- package/api/@xmachines/shared/functions/xmAliases.md +1 -1
- package/api/README.md +2 -2
- package/api/llms.txt +12 -6
- package/examples/multi-router-integration.md +31 -19
- package/guides/README.md +2 -1
- package/guides/installation.md +1 -6
- package/package.json +2 -2
- package/api/@xmachines/play-catalog/README.md +0 -331
- package/api/@xmachines/play-catalog/functions/defineCatalog.md +0 -98
- package/api/@xmachines/play-catalog/functions/defineComponents.md +0 -134
- package/api/@xmachines/play-catalog/type-aliases/Catalog.md +0 -48
- package/api/@xmachines/play-catalog/type-aliases/ComponentsFor.md +0 -20
- package/api/@xmachines/play-catalog/type-aliases/InferComponentProps.md +0 -65
- package/api/@xmachines/play-catalog/type-aliases/NoExtraKeys.md +0 -17
- package/api/@xmachines/play-xstate/functions/mergeViewProps.md +0 -26
- package/api/@xmachines/play-xstate/functions/validateComponentBinding.md +0 -39
- package/api/@xmachines/play-xstate/functions/validateViewProps.md +0 -80
- package/api/@xmachines/play-xstate/interfaces/CatalogEntry.md +0 -16
- package/api/@xmachines/play-xstate/type-aliases/Catalog.md +0 -21
- package/api/@xmachines/play-xstate/type-aliases/ValidationResult.md +0 -17
- 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
|
|
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
|
|
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
|
-
|
|
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`
|
|
39
|
+
### `PlayEvent`
|
|
35
40
|
|
|
36
|
-
```
|
|
37
|
-
type PlayEvent
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
52
|
+
### `PlayError`
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
Base class for all typed runtime errors thrown by `@xmachines/*` packages.
|
|
45
55
|
|
|
46
|
-
|
|
47
|
-
import type { PlayEvent } from "@xmachines/play";
|
|
56
|
+
Every `PlayError` carries two structured fields:
|
|
48
57
|
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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.18/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.18/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.18/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.18/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.
|
|
9
|
+
Defined in: [packages/play/src/types.ts:69](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/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.
|
|
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.18/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
|
|
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
|
|
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 {
|
|
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
|
-
|
|
95
|
-
|
|
99
|
+
extends AbstractActor<TLogic>
|
|
100
|
+
implements Routable, Viewable
|
|
96
101
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[Documentation](../../../README.md) / [@xmachines/play-actor](../README.md) / AbstractActor
|
|
2
2
|
|
|
3
|
-
# Abstract Class: AbstractActor\<TLogic\>
|
|
3
|
+
# Abstract Class: AbstractActor\<TLogic, TEvent\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:
|
|
5
|
+
Defined in: [packages/play-actor/src/abstract-actor.ts:231](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-actor/src/abstract-actor.ts#L231)
|
|
6
6
|
|
|
7
7
|
Abstract base class for Play Architecture actors.
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ Concrete implementations created by @xmachines/play-xstate adapter.
|
|
|
23
23
|
|
|
24
24
|
## Examples
|
|
25
25
|
|
|
26
|
-
Simple actor (no routing, no view)
|
|
26
|
+
Simple actor (no routing, no view) - single type param, backward compat
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
class SimpleActor extends AbstractActor<AnyActorLogic> {
|
|
@@ -32,24 +32,24 @@ class SimpleActor extends AbstractActor<AnyActorLogic> {
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Typed event actor - two type params
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
|
|
38
|
+
type AuthEvent = { type: "auth.login"; username: string } | { type: "auth.logout" };
|
|
39
|
+
class AuthActor extends AbstractActor<AnyActorLogic, AuthEvent> {
|
|
39
40
|
state = new Signal.State({...});
|
|
40
|
-
|
|
41
|
-
send(event) { ... }
|
|
41
|
+
send(event: AuthEvent) { ... }
|
|
42
42
|
}
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Full-featured actor (routing + view)
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
|
-
class PlayerActor extends AbstractActor<AnyActorLogic
|
|
48
|
+
class PlayerActor extends AbstractActor<AnyActorLogic, EventFromLogic<TMachine>>
|
|
49
|
+
implements Routable, Viewable {
|
|
49
50
|
state = new Signal.State({...});
|
|
50
51
|
currentRoute = new Signal.Computed(() => deriveRoute(this.state.get()));
|
|
51
52
|
currentView = new Signal.State(null);
|
|
52
|
-
catalog = {};
|
|
53
53
|
send(event) { ... }
|
|
54
54
|
}
|
|
55
55
|
```
|
|
@@ -70,16 +70,17 @@ class PlayerActor extends AbstractActor<AnyActorLogic> implements Routable, View
|
|
|
70
70
|
|
|
71
71
|
## Type Parameters
|
|
72
72
|
|
|
73
|
-
| Type Parameter | Description
|
|
74
|
-
| ---------------------------------------------------------------------------------------- |
|
|
75
|
-
| `TLogic` _extends_ [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | XState actor logic type (maintains type safety)
|
|
73
|
+
| Type Parameter | Default type | Description |
|
|
74
|
+
| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
75
|
+
| `TLogic` _extends_ [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | - | XState actor logic type (maintains type safety) |
|
|
76
|
+
| `TEvent` _extends_ [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject) | [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject) | Event type union that this actor's send() accepts. Defaults to `EventObject` (`{ type: string }`) for backward compatibility. Use `EventFromLogic<TMachine>` from xstate to infer the exact event union from a state machine (e.g., in `PlayerActor`). Invariant: Actor Authority - Actor is the sole source of truth for state transitions. Invariant: Signal-Only Reactivity - Infrastructure observes via TC39 Signals. Invariant: Passive Infrastructure - Infrastructure reflects, never decides. |
|
|
76
77
|
|
|
77
78
|
## Constructors
|
|
78
79
|
|
|
79
80
|
### Constructor
|
|
80
81
|
|
|
81
82
|
```ts
|
|
82
|
-
new AbstractActor<TLogic>(logic, options?): AbstractActor<TLogic>;
|
|
83
|
+
new AbstractActor<TLogic, TEvent>(logic, options?): AbstractActor<TLogic, TEvent>;
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
Creates a new actor instance for the given logic with the provided options,
|
|
@@ -94,7 +95,7 @@ if any.
|
|
|
94
95
|
|
|
95
96
|
#### Returns
|
|
96
97
|
|
|
97
|
-
`AbstractActor`\<`TLogic`\>
|
|
98
|
+
`AbstractActor`\<`TLogic`, `TEvent`\>
|
|
98
99
|
|
|
99
100
|
#### Inherited from
|
|
100
101
|
|
|
@@ -114,7 +115,7 @@ Actor<TLogic>.constructor
|
|
|
114
115
|
| <a id="property-ref"></a> `ref` | `public` | [`ActorRef`](https://www.jsdocs.io/package/xstate#ActorRef)\<[`SnapshotFrom`](https://www.jsdocs.io/package/xstate#SnapshotFrom)\<`TLogic`\>, [`EventFromLogic`](https://www.jsdocs.io/package/xstate#EventFromLogic)\<`TLogic`\>, [`EmittedFrom`](https://www.jsdocs.io/package/xstate#EmittedFrom)\<`TLogic`\>\> | - | `Actor.ref` | - |
|
|
115
116
|
| <a id="property-sessionid"></a> `sessionId` | `public` | `string` | The globally unique process ID for this invocation. | `Actor.sessionId` | - |
|
|
116
117
|
| <a id="property-src"></a> `src` | `public` | \| `string` \| [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | - | `Actor.src` | - |
|
|
117
|
-
| <a id="property-state"></a> `state` | `abstract` | [`State`](../../play-signals/namespaces/Signal/classes/State.md)\<`unknown`\> | Reactive snapshot of current actor state. Typed as `Signal.State<unknown>` at the abstract level; concrete implementations narrow this to the actual snapshot type (e.g., `Signal.State<AnyMachineSnapshot>` in `@xmachines/play-xstate`'s `PlayerActor`). Infrastructure observes this signal to react to state changes without directly coupling to the Actor's internal state machine implementation. **Example** `// Infrastructure observes state signal const watcher = new Signal.subtle.Watcher(() => { console.log('Actor state changed:', actor.state.get()); }); watcher.watch(actor.state);` | - | [packages/play-actor/src/abstract-actor.ts:
|
|
118
|
+
| <a id="property-state"></a> `state` | `abstract` | [`State`](../../play-signals/namespaces/Signal/classes/State.md)\<`unknown`\> | Reactive snapshot of current actor state. Typed as `Signal.State<unknown>` at the abstract level; concrete implementations narrow this to the actual snapshot type (e.g., `Signal.State<AnyMachineSnapshot>` in `@xmachines/play-xstate`'s `PlayerActor`). Infrastructure observes this signal to react to state changes without directly coupling to the Actor's internal state machine implementation. **Example** `// Infrastructure observes state signal const watcher = new Signal.subtle.Watcher(() => { console.log('Actor state changed:', actor.state.get()); }); watcher.watch(actor.state);` | - | [packages/play-actor/src/abstract-actor.ts:254](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-actor/src/abstract-actor.ts#L254) |
|
|
118
119
|
| <a id="property-system"></a> `system` | `public` | [`AnyActorSystem`](https://www.jsdocs.io/package/xstate#AnyActorSystem) | The system to which this actor belongs. | `Actor.system` | - |
|
|
119
120
|
| <a id="property-systemid"></a> `systemId` | `public` | `string` \| `undefined` | - | `Actor.systemId` | - |
|
|
120
121
|
|
|
@@ -275,7 +276,7 @@ Actor.select;
|
|
|
275
276
|
abstract send(event): void;
|
|
276
277
|
```
|
|
277
278
|
|
|
278
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:
|
|
279
|
+
Defined in: [packages/play-actor/src/abstract-actor.ts:278](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-actor/src/abstract-actor.ts#L278)
|
|
279
280
|
|
|
280
281
|
Send event to Actor
|
|
281
282
|
|
|
@@ -285,9 +286,9 @@ each event is valid from the current state.
|
|
|
285
286
|
|
|
286
287
|
#### Parameters
|
|
287
288
|
|
|
288
|
-
| Parameter | Type
|
|
289
|
-
| --------- |
|
|
290
|
-
| `event` | `
|
|
289
|
+
| Parameter | Type | Description |
|
|
290
|
+
| --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
291
|
+
| `event` | `TEvent` | Event object with type property (e.g., PlayEvent, PlayRouteEvent) Invariant: Actor Authority - Only Actor decides whether an event is valid. |
|
|
291
292
|
|
|
292
293
|
#### Returns
|
|
293
294
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-actor](../README.md) / PlaySpec
|
|
2
|
+
|
|
3
|
+
# Interface: PlaySpec
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/play-actor/src/abstract-actor.ts:112](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-actor/src/abstract-actor.ts#L112)
|
|
6
|
+
|
|
7
|
+
XMachines extension of `@json-render/core` `Spec`.
|
|
8
|
+
|
|
9
|
+
Adds `contextProps` — an explicit allowlist of machine context fields that
|
|
10
|
+
`deriveCurrentView` merges into element props as low-priority slots. Only
|
|
11
|
+
fields named here are ever exposed to components; nothing leaks from context
|
|
12
|
+
without an opt-in declaration.
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
spec: {
|
|
18
|
+
root: "root",
|
|
19
|
+
contextProps: ["username"], // expose context.username as a prop slot
|
|
20
|
+
elements: {
|
|
21
|
+
root: { type: "Dashboard", props: { username: undefined }, children: [] },
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Extends
|
|
27
|
+
|
|
28
|
+
- `Spec`
|
|
29
|
+
|
|
30
|
+
## Properties
|
|
31
|
+
|
|
32
|
+
| Property | Type | Description | Inherited from | Defined in |
|
|
33
|
+
| -------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| <a id="property-contextprops"></a> `contextProps?` | `string`[] | Explicit allowlist of machine context field names to expose as prop slots. Each named field is merged into every spec element's `props` at view derivation time, filling any slot whose current value is `undefined`. `null` and `undefined` context values are skipped. URL route params (from `context.routeParams`) take priority over `contextProps` values; explicit non-`undefined` spec props always take priority over both. | - | [packages/play-actor/src/abstract-actor.ts:122](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.18/packages/play-actor/src/abstract-actor.ts#L122) |
|
|
35
|
+
| <a id="property-elements"></a> `elements` | `Record`\<`string`, `UIElement`\> | Flat map of elements by key | `Spec.elements` | - |
|
|
36
|
+
| <a id="property-root"></a> `root` | `string` | Root element key | `Spec.root` | - |
|
|
37
|
+
| <a id="property-state"></a> `state?` | `Record`\<`string`, `unknown`\> | Optional initial state to seed the state model. Components using statePath will read from / write to this state. | `Spec.state` | - |
|