@xmachines/play-actor 1.0.0-beta.25 → 1.0.0-beta.26
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/dist/abstract-actor.d.ts +57 -182
- package/dist/abstract-actor.d.ts.map +1 -1
- package/dist/abstract-actor.js +33 -49
- package/dist/abstract-actor.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/abstract-actor.d.ts
CHANGED
|
@@ -21,72 +21,11 @@ import type { Signal } from "@xmachines/play-signals";
|
|
|
21
21
|
import type { Spec } from "@json-render/core";
|
|
22
22
|
/**
|
|
23
23
|
* Optional capability: Routing support
|
|
24
|
-
*
|
|
25
|
-
* Actors implementing this interface can derive a route from their state.
|
|
26
|
-
* Router adapters observe the currentRoute signal to sync browser URLs.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* class MyActor extends AbstractActor implements Routable {
|
|
31
|
-
* currentRoute = new Signal.Computed(() => deriveRoute(this.state.get()));
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* // Router requires Routable
|
|
35
|
-
* function connectRouter<T extends AbstractActor & Routable>(actor: T) {
|
|
36
|
-
* watcher.watch(actor.currentRoute);
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
24
|
*/
|
|
40
25
|
export interface Routable {
|
|
41
|
-
/**
|
|
42
|
-
* Current route signal
|
|
43
|
-
*
|
|
44
|
-
* Computed signal derived from state machine. Infrastructure observes to sync browser URL.
|
|
45
|
-
*
|
|
46
|
-
* Invariant: Passive Infrastructure - Infrastructure reflects route, never decides.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const watcher = new Signal.subtle.Watcher(() => {
|
|
51
|
-
* const route = actor.currentRoute.get();
|
|
52
|
-
* console.log('Route changed:', route);
|
|
53
|
-
* });
|
|
54
|
-
* watcher.watch(actor.currentRoute);
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
26
|
readonly currentRoute: Signal.Computed<string | null>;
|
|
58
|
-
/**
|
|
59
|
-
* The route derived from the machine's **initial** state — fixed at construction
|
|
60
|
-
* and never changes, even after `start()` with a restored snapshot.
|
|
61
|
-
*
|
|
62
|
-
* Router bridges use this to distinguish a deep-link (browser URL differs from
|
|
63
|
-
* the initial route because the user navigated there) from a restore (browser is
|
|
64
|
-
* at the machine's default starting URL while the actor was restored to a
|
|
65
|
-
* different route from a snapshot).
|
|
66
|
-
*
|
|
67
|
-
* `null` when the machine's initial state has no `meta.route`.
|
|
68
|
-
*/
|
|
69
27
|
readonly initialRoute: string | null;
|
|
70
28
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Optional capability: View rendering support
|
|
73
|
-
*
|
|
74
|
-
* Actors implementing this interface can derive view structures from their state.
|
|
75
|
-
* Renderers observe the currentView signal to update the UI.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* class MyActor extends AbstractActor implements Viewable {
|
|
80
|
-
* currentView = new Signal.State(null);
|
|
81
|
-
* }
|
|
82
|
-
*
|
|
83
|
-
* // Renderer requires Viewable
|
|
84
|
-
* function renderView<T extends AbstractActor & Viewable>(actor: T) {
|
|
85
|
-
* const view = actor.currentView.get();
|
|
86
|
-
* // view.component is the component name; view.spec is the json-render spec
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
29
|
/**
|
|
91
30
|
* XMachines extension of `@json-render/core` `Spec`.
|
|
92
31
|
*
|
|
@@ -95,31 +34,56 @@ export interface Routable {
|
|
|
95
34
|
* fields named here are ever exposed to components; nothing leaks from context
|
|
96
35
|
* without an opt-in declaration.
|
|
97
36
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* spec: {
|
|
101
|
-
* root: "root",
|
|
102
|
-
* contextProps: ["username"], // expose context.username as a prop slot
|
|
103
|
-
* elements: {
|
|
104
|
-
* root: { type: "Dashboard", props: { username: undefined }, children: [] },
|
|
105
|
-
* },
|
|
106
|
-
* }
|
|
107
|
-
* ```
|
|
37
|
+
* Use `typedSpec<TContext>(...)` at the definition site to validate `contextProps`
|
|
38
|
+
* entries against your machine's context type at compile time.
|
|
108
39
|
*/
|
|
109
40
|
export interface PlaySpec extends Spec {
|
|
110
41
|
/**
|
|
111
42
|
* Explicit allowlist of machine context field names to expose as prop slots.
|
|
112
|
-
*
|
|
113
43
|
* Each named field is merged into every spec element's `props` at view derivation
|
|
114
|
-
* time, filling any slot whose current value is `undefined`.
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* always take priority over both.
|
|
44
|
+
* time, filling any slot whose current value is `undefined`.
|
|
45
|
+
*
|
|
46
|
+
* Use `typedSpec<TContext>(...)` to constrain entries to `keyof TContext & string`.
|
|
118
47
|
*/
|
|
119
|
-
contextProps?: string[];
|
|
48
|
+
readonly contextProps?: readonly string[];
|
|
120
49
|
}
|
|
121
50
|
/**
|
|
122
|
-
*
|
|
51
|
+
* Identity helper that constrains a `PlaySpec` object's `contextProps` to keys
|
|
52
|
+
* of a specific machine context type, giving compile-time validation and IDE
|
|
53
|
+
* autocomplete at the definition site.
|
|
54
|
+
*
|
|
55
|
+
* XState's `meta` field is typed as `Record<string, unknown>`, so TypeScript
|
|
56
|
+
* cannot infer the constraint from context. `typedSpec<MyCtx>(...)` is the
|
|
57
|
+
* opt-in mechanism that activates enforcement where the spec is written.
|
|
58
|
+
*
|
|
59
|
+
* At runtime this is a no-op — the spec object is returned unchanged.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* interface DashboardCtx {
|
|
64
|
+
* username: string;
|
|
65
|
+
* params: Record<string, string>;
|
|
66
|
+
* query: Record<string, string>;
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* meta: {
|
|
70
|
+
* view: {
|
|
71
|
+
* component: "Dashboard",
|
|
72
|
+
* spec: typedSpec<DashboardCtx>({
|
|
73
|
+
* root: "root",
|
|
74
|
+
* contextProps: ["username"], // ✓ key of DashboardCtx
|
|
75
|
+
* // contextProps: ["usernaem"], // ✗ compile error
|
|
76
|
+
* elements: { root: { type: "Dashboard", props: {}, children: [] } },
|
|
77
|
+
* }),
|
|
78
|
+
* },
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function typedSpec<TContext extends object>(spec: Omit<PlaySpec, "contextProps"> & {
|
|
83
|
+
readonly contextProps?: readonly (keyof TContext & string)[];
|
|
84
|
+
}): PlaySpec;
|
|
85
|
+
/**
|
|
86
|
+
* View metadata for rendering.
|
|
123
87
|
*
|
|
124
88
|
* Describes the component to be rendered and the json-render Spec to use.
|
|
125
89
|
* Used by PlayRenderer to dynamically render UI based on actor state.
|
|
@@ -130,6 +94,9 @@ export interface ViewMetadata {
|
|
|
130
94
|
/**
|
|
131
95
|
* XMachines view spec — extends `@json-render/core` Spec with `contextProps`
|
|
132
96
|
* for explicit context field exposure.
|
|
97
|
+
*
|
|
98
|
+
* Use `typedSpec<TContext>(...)` at the definition site to validate
|
|
99
|
+
* `contextProps` entries against the machine context type.
|
|
133
100
|
*/
|
|
134
101
|
spec: PlaySpec;
|
|
135
102
|
}
|
|
@@ -139,131 +106,39 @@ export interface ViewMetadata {
|
|
|
139
106
|
* `Viewable` marks actors that publish a `currentView` signal.
|
|
140
107
|
* Renderers such as `PlayRenderer` consume this contract to resolve the
|
|
141
108
|
* current view description into concrete UI without embedding view logic inside the
|
|
142
|
-
* framework adapter.
|
|
143
|
-
* passed to PlayRenderer, not stored on the actor.
|
|
109
|
+
* framework adapter.
|
|
144
110
|
*/
|
|
145
111
|
export interface Viewable {
|
|
146
112
|
/**
|
|
147
|
-
* Current view signal
|
|
113
|
+
* Current view signal.
|
|
148
114
|
*
|
|
149
|
-
* State signal containing view.component and view.spec from meta.view.
|
|
150
|
-
*
|
|
151
|
-
* Invariant: Logic-Driven UI - View structure is defined by business logic, not JSX.
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```typescript
|
|
155
|
-
* const watcher = new Signal.subtle.Watcher(() => {
|
|
156
|
-
* const view = actor.currentView.get();
|
|
157
|
-
* console.log('View changed:', view.component, view.spec);
|
|
158
|
-
* });
|
|
159
|
-
* watcher.watch(actor.currentView);
|
|
160
|
-
* ```
|
|
115
|
+
* State signal containing view.component and view.spec from meta.view.
|
|
116
|
+
* Infrastructure renders view — Logic-Driven UI invariant.
|
|
161
117
|
*/
|
|
162
118
|
readonly currentView: Signal.State<ViewMetadata | null>;
|
|
163
119
|
}
|
|
164
120
|
/**
|
|
165
121
|
* Abstract base class for Play Architecture actors.
|
|
166
122
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* The core protocol contains only:
|
|
171
|
-
* - state: Reactive state snapshot
|
|
172
|
-
* - send: Event dispatch method
|
|
173
|
-
*
|
|
174
|
-
* Optional capabilities (routing, view rendering) are provided via interfaces:
|
|
175
|
-
* - Implement Routable for routing support
|
|
176
|
-
* - Implement Viewable for view rendering support
|
|
177
|
-
*
|
|
178
|
-
* Concrete implementations created by @xmachines/play-xstate adapter.
|
|
179
|
-
*
|
|
180
|
-
* @typeParam TLogic - XState actor logic type (maintains type safety)
|
|
181
|
-
* @typeParam TEvent - Event type union that this actor's send() accepts.
|
|
182
|
-
* Defaults to `EventObject` (`{ type: string }`) for backward compatibility.
|
|
183
|
-
* Use `EventFromLogic<TMachine>` from xstate to infer the exact event union
|
|
184
|
-
* from a state machine (e.g., in `PlayerActor`).
|
|
185
|
-
*
|
|
186
|
-
* Invariant: Actor Authority - Actor is the sole source of truth for state transitions.
|
|
187
|
-
* Invariant: Signal-Only Reactivity - Infrastructure observes via TC39 Signals.
|
|
188
|
-
* Invariant: Passive Infrastructure - Infrastructure reflects, never decides.
|
|
123
|
+
* Provides signal-driven state observation that integrates with XState ecosystem
|
|
124
|
+
* tooling (devtools, inspection) while exposing reactive signals for
|
|
125
|
+
* Infrastructure layer communication.
|
|
189
126
|
*
|
|
190
|
-
* @
|
|
191
|
-
*
|
|
192
|
-
* ```typescript
|
|
193
|
-
* class SimpleActor extends AbstractActor<AnyActorLogic> {
|
|
194
|
-
* state = new Signal.State({...});
|
|
195
|
-
* send(event) { ... }
|
|
196
|
-
* }
|
|
197
|
-
* ```
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* Typed event actor - two type params
|
|
201
|
-
* ```typescript
|
|
202
|
-
* type AuthEvent = { type: "auth.login"; username: string } | { type: "auth.logout" };
|
|
203
|
-
* class AuthActor extends AbstractActor<AnyActorLogic, AuthEvent> {
|
|
204
|
-
* state = new Signal.State({...});
|
|
205
|
-
* send(event: AuthEvent) { ... }
|
|
206
|
-
* }
|
|
207
|
-
* ```
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* Full-featured actor (routing + view)
|
|
211
|
-
* ```typescript
|
|
212
|
-
* class PlayerActor extends AbstractActor<AnyActorLogic, EventFromLogic<TMachine>>
|
|
213
|
-
* implements Routable, Viewable {
|
|
214
|
-
* state = new Signal.State({...});
|
|
215
|
-
* currentRoute = new Signal.Computed(() => deriveRoute(this.state.get()));
|
|
216
|
-
* currentView = new Signal.State(null);
|
|
217
|
-
* send(event) { ... }
|
|
218
|
-
* }
|
|
219
|
-
* ```
|
|
220
|
-
*
|
|
221
|
-
* @see [Play RFC](../../docs/rfc/play.md)
|
|
222
|
-
* @see {@link Routable} for routing capability
|
|
223
|
-
* @see {@link Viewable} for view rendering capability
|
|
127
|
+
* @typeParam TLogic - XState actor logic type
|
|
128
|
+
* @typeParam TEvent - Event type constraint (defaults to EventObject)
|
|
224
129
|
*/
|
|
225
130
|
export declare abstract class AbstractActor<TLogic extends AnyActorLogic, TEvent extends EventObject = EventObject> extends Actor<TLogic> {
|
|
226
131
|
/**
|
|
227
132
|
* Reactive snapshot of current actor state.
|
|
228
133
|
*
|
|
229
|
-
* Typed as `Signal.State<unknown>` at the abstract level; concrete implementations
|
|
230
|
-
* narrow this to the actual snapshot type (e.g., `Signal.State<AnyMachineSnapshot>`
|
|
231
|
-
* in `@xmachines/play-xstate`'s `PlayerActor`).
|
|
232
|
-
*
|
|
233
134
|
* Infrastructure observes this signal to react to state changes without
|
|
234
|
-
* directly coupling to the
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
* ```typescript
|
|
238
|
-
* // Infrastructure observes state signal
|
|
239
|
-
* const watcher = new Signal.subtle.Watcher(() => {
|
|
240
|
-
* console.log('Actor state changed:', actor.state.get());
|
|
241
|
-
* });
|
|
242
|
-
* watcher.watch(actor.state);
|
|
243
|
-
* ```
|
|
135
|
+
* directly coupling to the actor's internal state machine implementation.
|
|
244
136
|
*/
|
|
245
137
|
abstract state: Signal.State<unknown>;
|
|
246
138
|
/**
|
|
247
|
-
* Send event to Actor
|
|
248
|
-
*
|
|
249
|
-
* Infrastructure forwards user intents (navigation, domain events, custom events)
|
|
250
|
-
* as events to the Actor. The Actor's state machine guards determine whether
|
|
251
|
-
* each event is valid from the current state.
|
|
252
|
-
*
|
|
253
|
-
* @param event - Event object with type property (e.g., PlayEvent, PlayRouteEvent)
|
|
254
|
-
*
|
|
255
|
-
* Invariant: Actor Authority - Only Actor decides whether an event is valid.
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* ```typescript
|
|
259
|
-
* // Infrastructure forwards user intent
|
|
260
|
-
* actor.send({ type: 'auth.login', userId: '123' });
|
|
261
|
-
* // Actor's guards determine if event is allowed
|
|
262
|
-
* ```
|
|
139
|
+
* Send event to Actor.
|
|
263
140
|
*
|
|
264
|
-
*
|
|
265
|
-
* Accepts any event object with a type property. Core events (PlayEvent) are in
|
|
266
|
-
* @xmachines/play, routing events (PlayRouteEvent) are in @xmachines/play-router.
|
|
141
|
+
* Constrained to TEvent for type safety in concrete implementations.
|
|
267
142
|
*/
|
|
268
143
|
abstract send(event: TEvent): void;
|
|
269
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-actor.d.ts","sourceRoot":"","sources":["../src/abstract-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"abstract-actor.d.ts","sourceRoot":"","sources":["../src/abstract-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,QAAS,SAAQ,IAAI;IACrC;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,SAAS,CAAC,QAAQ,SAAS,MAAM,EAChD,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;CAC7D,GACC,QAAQ,CAEV;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,IAAI,EAAE,QAAQ,CAAC;CACf;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CACxD;AAED;;;;;;;;;GASG;AACH,8BAAsB,aAAa,CAClC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,WAAW,GAAG,WAAW,CACvC,SAAQ,KAAK,CAAC,MAAM,CAAC;IACtB;;;;;OAKG;IACH,SAAgB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE7C;;;;OAIG;aACsB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAClD"}
|
package/dist/abstract-actor.js
CHANGED
|
@@ -18,65 +18,49 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { Actor } from "xstate";
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* while enforcing minimal signal protocol for Actor ↔ Infrastructure communication.
|
|
25
|
-
*
|
|
26
|
-
* The core protocol contains only:
|
|
27
|
-
* - state: Reactive state snapshot
|
|
28
|
-
* - send: Event dispatch method
|
|
29
|
-
*
|
|
30
|
-
* Optional capabilities (routing, view rendering) are provided via interfaces:
|
|
31
|
-
* - Implement Routable for routing support
|
|
32
|
-
* - Implement Viewable for view rendering support
|
|
21
|
+
* Identity helper that constrains a `PlaySpec` object's `contextProps` to keys
|
|
22
|
+
* of a specific machine context type, giving compile-time validation and IDE
|
|
23
|
+
* autocomplete at the definition site.
|
|
33
24
|
*
|
|
34
|
-
*
|
|
25
|
+
* XState's `meta` field is typed as `Record<string, unknown>`, so TypeScript
|
|
26
|
+
* cannot infer the constraint from context. `typedSpec<MyCtx>(...)` is the
|
|
27
|
+
* opt-in mechanism that activates enforcement where the spec is written.
|
|
35
28
|
*
|
|
36
|
-
*
|
|
37
|
-
* @typeParam TEvent - Event type union that this actor's send() accepts.
|
|
38
|
-
* Defaults to `EventObject` (`{ type: string }`) for backward compatibility.
|
|
39
|
-
* Use `EventFromLogic<TMachine>` from xstate to infer the exact event union
|
|
40
|
-
* from a state machine (e.g., in `PlayerActor`).
|
|
41
|
-
*
|
|
42
|
-
* Invariant: Actor Authority - Actor is the sole source of truth for state transitions.
|
|
43
|
-
* Invariant: Signal-Only Reactivity - Infrastructure observes via TC39 Signals.
|
|
44
|
-
* Invariant: Passive Infrastructure - Infrastructure reflects, never decides.
|
|
29
|
+
* At runtime this is a no-op — the spec object is returned unchanged.
|
|
45
30
|
*
|
|
46
31
|
* @example
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* interface DashboardCtx {
|
|
34
|
+
* username: string;
|
|
35
|
+
* params: Record<string, string>;
|
|
36
|
+
* query: Record<string, string>;
|
|
52
37
|
* }
|
|
53
|
-
* ```
|
|
54
38
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
39
|
+
* meta: {
|
|
40
|
+
* view: {
|
|
41
|
+
* component: "Dashboard",
|
|
42
|
+
* spec: typedSpec<DashboardCtx>({
|
|
43
|
+
* root: "root",
|
|
44
|
+
* contextProps: ["username"], // ✓ key of DashboardCtx
|
|
45
|
+
* // contextProps: ["usernaem"], // ✗ compile error
|
|
46
|
+
* elements: { root: { type: "Dashboard", props: {}, children: [] } },
|
|
47
|
+
* }),
|
|
48
|
+
* },
|
|
62
49
|
* }
|
|
63
50
|
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function typedSpec(spec) {
|
|
53
|
+
return spec;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Abstract base class for Play Architecture actors.
|
|
64
57
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* class PlayerActor extends AbstractActor<AnyActorLogic, EventFromLogic<TMachine>>
|
|
69
|
-
* implements Routable, Viewable {
|
|
70
|
-
* state = new Signal.State({...});
|
|
71
|
-
* currentRoute = new Signal.Computed(() => deriveRoute(this.state.get()));
|
|
72
|
-
* currentView = new Signal.State(null);
|
|
73
|
-
* send(event) { ... }
|
|
74
|
-
* }
|
|
75
|
-
* ```
|
|
58
|
+
* Provides signal-driven state observation that integrates with XState ecosystem
|
|
59
|
+
* tooling (devtools, inspection) while exposing reactive signals for
|
|
60
|
+
* Infrastructure layer communication.
|
|
76
61
|
*
|
|
77
|
-
* @
|
|
78
|
-
* @
|
|
79
|
-
* @see {@link Viewable} for view rendering capability
|
|
62
|
+
* @typeParam TLogic - XState actor logic type
|
|
63
|
+
* @typeParam TEvent - Event type constraint (defaults to EventObject)
|
|
80
64
|
*/
|
|
81
65
|
export class AbstractActor extends Actor {
|
|
82
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-actor.js","sourceRoot":"","sources":["../src/abstract-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAwC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"abstract-actor.js","sourceRoot":"","sources":["../src/abstract-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAwC,MAAM,QAAQ,CAAC;AAkCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,SAAS,CACxB,IAEC;IAED,OAAO,IAAgB,CAAC;AACzB,CAAC;AAuCD;;;;;;;;;GASG;AACH,MAAM,OAAgB,aAGpB,SAAQ,KAAa;CAetB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* @packageDocumentation
|
|
16
16
|
* @see [Play RFC](../../docs/rfc/play.md)
|
|
17
17
|
*/
|
|
18
|
-
export { AbstractActor, type Routable, type Viewable, type ViewMetadata, type PlaySpec, } from "./abstract-actor.js";
|
|
18
|
+
export { AbstractActor, typedSpec, type Routable, type Viewable, type ViewMetadata, type PlaySpec, } from "./abstract-actor.js";
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,QAAQ,GACb,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,aAAa,EACb,SAAS,EACT,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,QAAQ,GACb,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,aAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,aAAa,EACb,SAAS,GAKT,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-actor",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.26",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Abstract Actor base class for XMachines Play Architecture",
|
|
6
6
|
"keywords": [
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^25.5.0",
|
|
46
|
-
"@xmachines/shared": "1.0.0-beta.
|
|
46
|
+
"@xmachines/shared": "1.0.0-beta.26",
|
|
47
47
|
"oxfmt": "^0.43.0",
|
|
48
48
|
"oxlint": "^1.57.0",
|
|
49
49
|
"vitest": "^4.1.2",
|
|
50
50
|
"xstate": "^5.30.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@xmachines/play": "1.0.0-beta.
|
|
54
|
-
"@xmachines/play-signals": "1.0.0-beta.
|
|
53
|
+
"@xmachines/play": "1.0.0-beta.26",
|
|
54
|
+
"@xmachines/play-signals": "1.0.0-beta.26",
|
|
55
55
|
"xstate": "^5.30.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|