@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.
- 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 +65 -53
- 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 +226 -305
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +12 -38
- 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/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 +44 -40
- 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/namespaces/Signal/classes/Computed.md +3 -9
- package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +3 -11
- package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +5 -7
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +3 -13
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +0 -2
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +0 -2
- 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 +2 -0
- 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 +65 -51
- 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 +216 -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/ComponentFn.md +33 -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 +21 -0
- 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 +46 -49
- 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 +250 -107
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +77 -55
- 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 +22 -0
- 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 +6 -5
- 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 +1 -1
- package/api/llms.txt +11 -5
- package/examples/README.md +20 -6
- package/examples/multi-router-integration.md +33 -24
- package/examples/routing-patterns.md +2 -3
- package/package.json +3 -3
- 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
|
@@ -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.17/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,20 +70,19 @@ 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
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:50
|
|
86
|
-
|
|
87
86
|
Creates a new actor instance for the given logic with the provided options,
|
|
88
87
|
if any.
|
|
89
88
|
|
|
@@ -96,7 +95,7 @@ if any.
|
|
|
96
95
|
|
|
97
96
|
#### Returns
|
|
98
97
|
|
|
99
|
-
`AbstractActor`\<`TLogic`\>
|
|
98
|
+
`AbstractActor`\<`TLogic`, `TEvent`\>
|
|
100
99
|
|
|
101
100
|
#### Inherited from
|
|
102
101
|
|
|
@@ -108,17 +107,17 @@ Actor<TLogic>.constructor
|
|
|
108
107
|
|
|
109
108
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
110
109
|
| ------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
-
| <a id="property-_parent"></a> `_parent?` | `public` | [`AnyActorRef`](https://www.jsdocs.io/package/xstate#AnyActorRef) | - | `Actor._parent` |
|
|
112
|
-
| <a id="property-clock"></a> `clock` | `public` | [`Clock`](https://www.jsdocs.io/package/xstate#Clock) | The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions. | `Actor.clock` |
|
|
113
|
-
| <a id="property-id"></a> `id` | `public` | `string` | The unique identifier for this actor relative to its parent. | `Actor.id` |
|
|
114
|
-
| <a id="property-logic"></a> `logic` | `public` | `TLogic` | - | `Actor.logic` |
|
|
115
|
-
| <a id="property-options"></a> `options` | `public` | `Readonly`\<[`ActorOptions`](https://www.jsdocs.io/package/xstate#ActorOptions)\<`TLogic`\>\> | - | `Actor.options` |
|
|
116
|
-
| <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` |
|
|
117
|
-
| <a id="property-sessionid"></a> `sessionId` | `public` | `string` | The globally unique process ID for this invocation. | `Actor.sessionId` |
|
|
118
|
-
| <a id="property-src"></a> `src` | `public` | \| `string` \| [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | - | `Actor.src` |
|
|
119
|
-
| <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:
|
|
120
|
-
| <a id="property-system"></a> `system` | `public` | [`AnyActorSystem`](https://www.jsdocs.io/package/xstate#AnyActorSystem) | The system to which this actor belongs. | `Actor.system` |
|
|
121
|
-
| <a id="property-systemid"></a> `systemId` | `public` | `string` \| `undefined` | - | `Actor.systemId` |
|
|
110
|
+
| <a id="property-_parent"></a> `_parent?` | `public` | [`AnyActorRef`](https://www.jsdocs.io/package/xstate#AnyActorRef) | - | `Actor._parent` | - |
|
|
111
|
+
| <a id="property-clock"></a> `clock` | `public` | [`Clock`](https://www.jsdocs.io/package/xstate#Clock) | The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions. | `Actor.clock` | - |
|
|
112
|
+
| <a id="property-id"></a> `id` | `public` | `string` | The unique identifier for this actor relative to its parent. | `Actor.id` | - |
|
|
113
|
+
| <a id="property-logic"></a> `logic` | `public` | `TLogic` | - | `Actor.logic` | - |
|
|
114
|
+
| <a id="property-options"></a> `options` | `public` | `Readonly`\<[`ActorOptions`](https://www.jsdocs.io/package/xstate#ActorOptions)\<`TLogic`\>\> | - | `Actor.options` | - |
|
|
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` | - |
|
|
116
|
+
| <a id="property-sessionid"></a> `sessionId` | `public` | `string` | The globally unique process ID for this invocation. | `Actor.sessionId` | - |
|
|
117
|
+
| <a id="property-src"></a> `src` | `public` | \| `string` \| [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | - | `Actor.src` | - |
|
|
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.17/packages/play-actor/src/abstract-actor.ts#L254) |
|
|
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` | - |
|
|
120
|
+
| <a id="property-systemid"></a> `systemId` | `public` | `string` \| `undefined` | - | `Actor.systemId` | - |
|
|
122
121
|
|
|
123
122
|
## Methods
|
|
124
123
|
|
|
@@ -128,8 +127,6 @@ Actor<TLogic>.constructor
|
|
|
128
127
|
observable: InteropSubscribable<SnapshotFrom<TLogic>>;
|
|
129
128
|
```
|
|
130
129
|
|
|
131
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:153
|
|
132
|
-
|
|
133
130
|
#### Returns
|
|
134
131
|
|
|
135
132
|
[`InteropSubscribable`](https://www.jsdocs.io/package/xstate#InteropSubscribable)\<[`SnapshotFrom`](https://www.jsdocs.io/package/xstate#SnapshotFrom)\<`TLogic`\>\>
|
|
@@ -148,8 +145,6 @@ Actor.[observable]
|
|
|
148
145
|
getPersistedSnapshot(): Snapshot<unknown>;
|
|
149
146
|
```
|
|
150
147
|
|
|
151
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:152
|
|
152
|
-
|
|
153
148
|
Obtain the internal state of the actor, which can be persisted.
|
|
154
149
|
|
|
155
150
|
#### Returns
|
|
@@ -184,8 +179,6 @@ Actor.getPersistedSnapshot;
|
|
|
184
179
|
getSnapshot(): SnapshotFrom<TLogic>;
|
|
185
180
|
```
|
|
186
181
|
|
|
187
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:168
|
|
188
|
-
|
|
189
182
|
Read an actor’s snapshot synchronously.
|
|
190
183
|
|
|
191
184
|
#### Returns
|
|
@@ -221,8 +214,6 @@ Actor.getSnapshot;
|
|
|
221
214
|
on<TType>(type, handler): Subscription;
|
|
222
215
|
```
|
|
223
216
|
|
|
224
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:115
|
|
225
|
-
|
|
226
217
|
#### Type Parameters
|
|
227
218
|
|
|
228
219
|
| Type Parameter |
|
|
@@ -248,13 +239,44 @@ Actor.on;
|
|
|
248
239
|
|
|
249
240
|
---
|
|
250
241
|
|
|
242
|
+
### select()
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
select<TSelected>(selector, equalityFn?): Readable<TSelected>;
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Type Parameters
|
|
249
|
+
|
|
250
|
+
| Type Parameter |
|
|
251
|
+
| -------------- |
|
|
252
|
+
| `TSelected` |
|
|
253
|
+
|
|
254
|
+
#### Parameters
|
|
255
|
+
|
|
256
|
+
| Parameter | Type |
|
|
257
|
+
| ------------- | --------------------------- |
|
|
258
|
+
| `selector` | (`snapshot`) => `TSelected` |
|
|
259
|
+
| `equalityFn?` | (`a`, `b`) => `boolean` |
|
|
260
|
+
|
|
261
|
+
#### Returns
|
|
262
|
+
|
|
263
|
+
`Readable`\<`TSelected`\>
|
|
264
|
+
|
|
265
|
+
#### Inherited from
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
Actor.select;
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
251
273
|
### send()
|
|
252
274
|
|
|
253
275
|
```ts
|
|
254
276
|
abstract send(event): void;
|
|
255
277
|
```
|
|
256
278
|
|
|
257
|
-
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.17/packages/play-actor/src/abstract-actor.ts#L278)
|
|
258
280
|
|
|
259
281
|
Send event to Actor
|
|
260
282
|
|
|
@@ -264,9 +286,9 @@ each event is valid from the current state.
|
|
|
264
286
|
|
|
265
287
|
#### Parameters
|
|
266
288
|
|
|
267
|
-
| Parameter | Type
|
|
268
|
-
| --------- |
|
|
269
|
-
| `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. |
|
|
270
292
|
|
|
271
293
|
#### Returns
|
|
272
294
|
|
|
@@ -299,8 +321,6 @@ Actor.send;
|
|
|
299
321
|
start(): this;
|
|
300
322
|
```
|
|
301
323
|
|
|
302
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:119
|
|
303
|
-
|
|
304
324
|
Starts the Actor from the initial state
|
|
305
325
|
|
|
306
326
|
#### Returns
|
|
@@ -321,8 +341,6 @@ Actor.start;
|
|
|
321
341
|
stop(): this;
|
|
322
342
|
```
|
|
323
343
|
|
|
324
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:123
|
|
325
|
-
|
|
326
344
|
Stops the Actor and unsubscribe all listeners.
|
|
327
345
|
|
|
328
346
|
#### Returns
|
|
@@ -345,8 +363,6 @@ Actor.stop;
|
|
|
345
363
|
subscribe(observer): Subscription;
|
|
346
364
|
```
|
|
347
365
|
|
|
348
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:113
|
|
349
|
-
|
|
350
366
|
Subscribe an observer to an actor’s snapshot values.
|
|
351
367
|
|
|
352
368
|
##### Parameters
|
|
@@ -423,8 +439,6 @@ subscribe(
|
|
|
423
439
|
completeListener?): Subscription;
|
|
424
440
|
```
|
|
425
441
|
|
|
426
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:114
|
|
427
|
-
|
|
428
442
|
Subscribe an observer to an actor’s snapshot values.
|
|
429
443
|
|
|
430
444
|
##### Parameters
|
|
@@ -502,16 +516,14 @@ Actor.subscribe;
|
|
|
502
516
|
toJSON(): object;
|
|
503
517
|
```
|
|
504
518
|
|
|
505
|
-
Defined in: node_modules/xstate/dist/declarations/src/createActor.d.ts:135
|
|
506
|
-
|
|
507
519
|
#### Returns
|
|
508
520
|
|
|
509
521
|
`object`
|
|
510
522
|
|
|
511
|
-
| Name | Type | Defined in
|
|
512
|
-
| -------------- | -------- |
|
|
513
|
-
| `id` | `string` |
|
|
514
|
-
| `xstate$$type` | `number` |
|
|
523
|
+
| Name | Type | Defined in |
|
|
524
|
+
| -------------- | -------- | ---------- |
|
|
525
|
+
| `id` | `string` | - |
|
|
526
|
+
| `xstate$$type` | `number` | - |
|
|
515
527
|
|
|
516
528
|
#### Inherited from
|
|
517
529
|
|
|
@@ -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.17/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.17/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` | - |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: Routable
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:
|
|
5
|
+
Defined in: [packages/play-actor/src/abstract-actor.ts:42](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L42)
|
|
6
6
|
|
|
7
7
|
Optional capability: Routing support
|
|
8
8
|
|
|
@@ -24,6 +24,7 @@ function connectRouter<T extends AbstractActor & Routable>(actor: T) {
|
|
|
24
24
|
|
|
25
25
|
## Properties
|
|
26
26
|
|
|
27
|
-
| Property | Modifier | Type | Description
|
|
28
|
-
| ------------------------------------------------- | ---------- | -------------------------------------------------------------------------------------------- |
|
|
29
|
-
| <a id="property-currentroute"></a> `currentRoute` | `readonly` | [`Computed`](../../play-signals/namespaces/Signal/classes/Computed.md)\<`string` \| `null`\> | Current route signal Computed signal derived from state machine. Infrastructure observes to sync browser URL. Invariant: Passive Infrastructure - Infrastructure reflects route, never decides. **Example** `const watcher = new Signal.subtle.Watcher(() => { const route = actor.currentRoute.get(); console.log('Route changed:', route); }); watcher.watch(actor.currentRoute);`
|
|
27
|
+
| Property | Modifier | Type | Description | Defined in |
|
|
28
|
+
| ------------------------------------------------- | ---------- | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| <a id="property-currentroute"></a> `currentRoute` | `readonly` | [`Computed`](../../play-signals/namespaces/Signal/classes/Computed.md)\<`string` \| `null`\> | Current route signal Computed signal derived from state machine. Infrastructure observes to sync browser URL. Invariant: Passive Infrastructure - Infrastructure reflects route, never decides. **Example** `const watcher = new Signal.subtle.Watcher(() => { const route = actor.currentRoute.get(); console.log('Route changed:', route); }); watcher.watch(actor.currentRoute);` | [packages/play-actor/src/abstract-actor.ts:59](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L59) |
|
|
30
|
+
| <a id="property-initialroute"></a> `initialRoute` | `readonly` | `string` \| `null` | The route derived from the machine's **initial** state — fixed at construction and never changes, even after `start()` with a restored snapshot. Router bridges use this to distinguish a deep-link (browser URL differs from the initial route because the user navigated there) from a restore (browser is at the machine's default starting URL while the actor was restored to a different route from a snapshot). `null` when the machine's initial state has no `meta.route`. | [packages/play-actor/src/abstract-actor.ts:71](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L71) |
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: ViewMetadata
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:
|
|
5
|
+
Defined in: [packages/play-actor/src/abstract-actor.ts:131](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L131)
|
|
6
6
|
|
|
7
7
|
View metadata for rendering
|
|
8
8
|
|
|
9
|
-
Describes the component to be rendered and the
|
|
9
|
+
Describes the component to be rendered and the json-render Spec to use.
|
|
10
10
|
Used by PlayRenderer to dynamically render UI based on actor state.
|
|
11
11
|
|
|
12
12
|
## Properties
|
|
13
13
|
|
|
14
|
-
| Property | Type
|
|
15
|
-
| ------------------------------------------- |
|
|
16
|
-
| <a id="property-component"></a> `component` | `string`
|
|
17
|
-
| <a id="property-
|
|
14
|
+
| Property | Type | Description | Defined in |
|
|
15
|
+
| ------------------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
+
| <a id="property-component"></a> `component` | `string` | Root element type name (for diagnostics and component resolution) | [packages/play-actor/src/abstract-actor.ts:133](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L133) |
|
|
17
|
+
| <a id="property-spec"></a> `spec` | [`PlaySpec`](PlaySpec.md) | XMachines view spec — extends `@json-render/core` Spec with `contextProps` for explicit context field exposure. | [packages/play-actor/src/abstract-actor.ts:138](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L138) |
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: Viewable
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:
|
|
5
|
+
Defined in: [packages/play-actor/src/abstract-actor.ts:150](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L150)
|
|
6
6
|
|
|
7
7
|
Actor capability for exposing renderable view state.
|
|
8
8
|
|
|
9
|
-
`Viewable` marks actors that publish a `currentView` signal
|
|
10
|
-
|
|
9
|
+
`Viewable` marks actors that publish a `currentView` signal.
|
|
10
|
+
Renderers such as `PlayRenderer` consume this contract to resolve the
|
|
11
11
|
current view description into concrete UI without embedding view logic inside the
|
|
12
|
-
framework adapter.
|
|
12
|
+
framework adapter. Component lookup is handled by the json-render registry
|
|
13
|
+
passed to PlayRenderer, not stored on the actor.
|
|
13
14
|
|
|
14
15
|
## Properties
|
|
15
16
|
|
|
16
|
-
| Property | Modifier | Type | Description
|
|
17
|
-
| ----------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------- |
|
|
18
|
-
| <a id="property-
|
|
19
|
-
| <a id="property-currentview"></a> `currentView` | `readonly` | [`State`](../../play-signals/namespaces/Signal/classes/State.md)\<[`ViewMetadata`](ViewMetadata.md) \| `null`\> | Current view signal State signal containing UI structure schema from meta.view. Infrastructure renders view. Invariant: Logic-Driven UI - View structure is defined by business logic, not JSX. **Example** `const watcher = new Signal.subtle.Watcher(() => { const view = actor.currentView.get(); console.log('View changed:', view); }); watcher.watch(actor.currentView);` | [packages/play-actor/src/abstract-actor.ts:119](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.15/packages/play-actor/src/abstract-actor.ts#L119) |
|
|
17
|
+
| Property | Modifier | Type | Description | Defined in |
|
|
18
|
+
| ----------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| <a id="property-currentview"></a> `currentView` | `readonly` | [`State`](../../play-signals/namespaces/Signal/classes/State.md)\<[`ViewMetadata`](ViewMetadata.md) \| `null`\> | Current view signal State signal containing view.component and view.spec from meta.view. Infrastructure renders view. Invariant: Logic-Driven UI - View structure is defined by business logic, not JSX. **Example** `const watcher = new Signal.subtle.Watcher(() => { const view = actor.currentView.get(); console.log('View changed:', view.component, view.spec); }); watcher.watch(actor.currentView);` | [packages/play-actor/src/abstract-actor.ts:167](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-actor/src/abstract-actor.ts#L167) |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[Documentation](../../README.md) / @xmachines/play-dom
|
|
2
|
+
|
|
3
|
+
# @xmachines/play-dom
|
|
4
|
+
|
|
5
|
+
@xmachines/play-dom - Vanilla DOM renderer for XMachines Play architecture
|
|
6
|
+
|
|
7
|
+
Provides a two-layer architecture:
|
|
8
|
+
|
|
9
|
+
- Inner layer (dom-renderer): Pure json-render-core compatible DOM renderer.
|
|
10
|
+
Zero XMachines dependencies. Upstreamable to @json-render/dom.
|
|
11
|
+
- Outer layer (PlayRenderer): XMachines wrapper. Bridges actor.currentView
|
|
12
|
+
(TC39 Signal) to the inner DOM renderer using watchSignal.
|
|
13
|
+
|
|
14
|
+
Also provides connectRenderer() as a backward-compat convenience function.
|
|
15
|
+
|
|
16
|
+
No framework required. Pure DOM APIs only.
|
|
17
|
+
|
|
18
|
+
## Classes
|
|
19
|
+
|
|
20
|
+
- [PlayRenderer](classes/PlayRenderer.md)
|
|
21
|
+
|
|
22
|
+
## Interfaces
|
|
23
|
+
|
|
24
|
+
- [ConnectRendererOptions](interfaces/ConnectRendererOptions.md)
|
|
25
|
+
- [DomRenderContext](interfaces/DomRenderContext.md)
|
|
26
|
+
- [PlayDomOptions](interfaces/PlayDomOptions.md)
|
|
27
|
+
|
|
28
|
+
## Type Aliases
|
|
29
|
+
|
|
30
|
+
- [DomComponentRenderer](type-aliases/DomComponentRenderer.md)
|
|
31
|
+
- [DomRegistry](type-aliases/DomRegistry.md)
|
|
32
|
+
|
|
33
|
+
## Functions
|
|
34
|
+
|
|
35
|
+
- [connectRenderer](functions/connectRenderer.md)
|
|
36
|
+
- [renderSpec](functions/renderSpec.md)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-dom](../README.md) / PlayRenderer
|
|
2
|
+
|
|
3
|
+
# Class: PlayRenderer
|
|
4
|
+
|
|
5
|
+
Defined in: [PlayRenderer.ts:39](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-dom/src/PlayRenderer.ts#L39)
|
|
6
|
+
|
|
7
|
+
PlayRenderer connects an actor's currentView signal to the DOM renderer.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const renderer = new PlayRenderer(container, actor, registry, { actions: { ... } });
|
|
13
|
+
renderer.connect();
|
|
14
|
+
|
|
15
|
+
// Controlled mode — bring your own store:
|
|
16
|
+
import { createAtom } from "@xstate/store";
|
|
17
|
+
import { xstateStoreStateStore } from "@json-render/xstate";
|
|
18
|
+
const store = xstateStoreStateStore({ atom: createAtom({ username: "" }) });
|
|
19
|
+
const renderer = new PlayRenderer(container, actor, registry, { store, actions: { ... } });
|
|
20
|
+
|
|
21
|
+
// Later:
|
|
22
|
+
renderer.disconnect();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Constructors
|
|
26
|
+
|
|
27
|
+
### Constructor
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
new PlayRenderer(
|
|
31
|
+
container,
|
|
32
|
+
actor,
|
|
33
|
+
registry,
|
|
34
|
+
options?): PlayRenderer;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Defined in: [PlayRenderer.ts:50](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-dom/src/PlayRenderer.ts#L50)
|
|
38
|
+
|
|
39
|
+
#### Parameters
|
|
40
|
+
|
|
41
|
+
| Parameter | Type | Description |
|
|
42
|
+
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `container` | `HTMLElement` | The `HTMLElement` to render into. Cleared and repopulated on every view transition. |
|
|
44
|
+
| `actor` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Viewable`](../../play-actor/interfaces/Viewable.md) | Actor instance providing the `currentView` signal (must implement `Viewable`). |
|
|
45
|
+
| `registry` | [`DomRegistry`](../type-aliases/DomRegistry.md) | Map of component type names to `DomComponentRenderer` functions. |
|
|
46
|
+
| `options` | [`PlayDomOptions`](../interfaces/PlayDomOptions.md) | Optional configuration: `actions` map (action name → XState event type) and optional external `store` (controlled mode — when omitted, a fresh `@xstate/store` atom is created per view transition seeded from `spec.state`). |
|
|
47
|
+
|
|
48
|
+
#### Returns
|
|
49
|
+
|
|
50
|
+
`PlayRenderer`
|
|
51
|
+
|
|
52
|
+
## Methods
|
|
53
|
+
|
|
54
|
+
### connect()
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
connect(): void;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Defined in: [PlayRenderer.ts:61](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-dom/src/PlayRenderer.ts#L61)
|
|
61
|
+
|
|
62
|
+
Start watching actor.currentView and render to container.
|
|
63
|
+
Renders the initial view synchronously, then subscribes to signal changes.
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
66
|
+
|
|
67
|
+
`void`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### disconnect()
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
disconnect(): void;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Defined in: [PlayRenderer.ts:69](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-dom/src/PlayRenderer.ts#L69)
|
|
78
|
+
|
|
79
|
+
Stop watching and clear the container.
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
`void`
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-dom](../README.md) / connectRenderer
|
|
2
|
+
|
|
3
|
+
# Function: connectRenderer()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function connectRenderer(options): () => void;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [connect-renderer.ts:46](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-dom/src/connect-renderer.ts#L46)
|
|
10
|
+
|
|
11
|
+
Connect a signal-driven DOM renderer to an actor's currentView signal.
|
|
12
|
+
|
|
13
|
+
Subscribes to `actor.currentView` via TC39 Signals and renders `DomComponentRenderer`
|
|
14
|
+
functions into the provided `container` element on every state change.
|
|
15
|
+
|
|
16
|
+
- Renders the initial view immediately (synchronous)
|
|
17
|
+
- Re-renders when `actor.currentView` signal changes (via microtask)
|
|
18
|
+
- Clears container when view is `null` (optionally appends fallback)
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
| Parameter | Type | Description |
|
|
23
|
+
| --------- | ------------------------------------------------------------------- | ---------------------- |
|
|
24
|
+
| `options` | [`ConnectRendererOptions`](../interfaces/ConnectRendererOptions.md) | ConnectRendererOptions |
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
A cleanup function that stops all DOM mutations
|
|
29
|
+
|
|
30
|
+
() => `void`
|
|
31
|
+
|
|
32
|
+
## Example
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { connectRenderer, type DomComponentRenderer } from "@xmachines/play-dom";
|
|
36
|
+
|
|
37
|
+
const unwatch = connectRenderer({
|
|
38
|
+
actor,
|
|
39
|
+
registry: {
|
|
40
|
+
Home: (element, ctx) => {
|
|
41
|
+
const el = document.createElement("div");
|
|
42
|
+
el.textContent = element.props.title as string;
|
|
43
|
+
return el;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
container: document.getElementById("app")!,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Later: stop watching
|
|
50
|
+
unwatch();
|
|
51
|
+
```
|