@xmachines/play-solid 1.0.0-beta.1 → 1.0.0-beta.2
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/PlayRenderer.d.ts +63 -0
- package/dist/PlayRenderer.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +7 -5
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlayRenderer - Main SolidJS renderer component for XMachines Play architecture
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { type Component } from "solid-js";
|
|
7
|
+
import type { PlayRendererProps } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Main renderer component that subscribes to actor signals and renders UI
|
|
10
|
+
*
|
|
11
|
+
* Architecture (per XMachines Play patterns):
|
|
12
|
+
* - Subscribes to actor.currentView signal via TC39 Signal.subtle.Watcher
|
|
13
|
+
* - Dynamically renders catalog components based on view.component string
|
|
14
|
+
* - Forwards user events to actor via actor.send()
|
|
15
|
+
* - SolidJS signal only for triggering renders, NOT business logic
|
|
16
|
+
*
|
|
17
|
+
* Invariant: Actor Authority - Actor decides all state transitions via guards.
|
|
18
|
+
* Invariant: Passive Infrastructure - Component observes signals and sends events.
|
|
19
|
+
* Invariant: Signal-Only Reactivity - Business logic state lives in actor signals.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { PlayRenderer } from "@xmachines/play-solidjs";
|
|
24
|
+
* import { definePlayer } from "@xmachines/play-xstate";
|
|
25
|
+
*
|
|
26
|
+
* const actor = definePlayer({ machine, catalog })();
|
|
27
|
+
* actor.start();
|
|
28
|
+
*
|
|
29
|
+
* const components = {
|
|
30
|
+
* Dashboard: (props) => <div>User: {props.userId}</div>,
|
|
31
|
+
* LoginForm: (props) => (
|
|
32
|
+
* <form onSubmit={(e) => {
|
|
33
|
+
* e.preventDefault();
|
|
34
|
+
* props.send({ type: "auth.login", payload: {...} });
|
|
35
|
+
* }}>...</form>
|
|
36
|
+
* )
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* <PlayRenderer actor={actor} components={components} />
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param props - Component props
|
|
43
|
+
* @returns SolidJS element rendering current view from actor
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* **Component lookup:** Dynamically looks up component from `components` map
|
|
47
|
+
* using `view.component` string from actor.currentView signal.
|
|
48
|
+
*
|
|
49
|
+
* **Event forwarding:** Injects `send` function as prop to components. Components
|
|
50
|
+
* call `send(event)` to forward intents to actor. Actor guards decide validity.
|
|
51
|
+
*
|
|
52
|
+
* **Error handling:** If component not found in catalog, logs error and shows
|
|
53
|
+
* fallback. This indicates missing component registration, not runtime error.
|
|
54
|
+
*
|
|
55
|
+
* **Signal bridge:** Uses one-shot re-watch pattern. TC39 Signal watchers stop
|
|
56
|
+
* watching after notification, so watcher.watch() must be called in microtask
|
|
57
|
+
* after getPending() to re-arm for next notification.
|
|
58
|
+
*
|
|
59
|
+
* **CRITICAL:** Never call actor.send() during render - only in event handlers.
|
|
60
|
+
* Calling send during render causes infinite render loops.
|
|
61
|
+
*/
|
|
62
|
+
export declare const PlayRenderer: Component<PlayRendererProps>;
|
|
63
|
+
//# sourceMappingURL=PlayRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayRenderer.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAGjE,OAAO,KAAK,EAAE,iBAAiB,EAAa,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,CAAC,iBAAiB,CA2ErD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for play-solidjs
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { AbstractActor, Viewable } from "@xmachines/play-actor";
|
|
7
|
+
import type { JSX, ValidComponent } from "solid-js";
|
|
8
|
+
import type { AnyActorLogic } from "xstate";
|
|
9
|
+
export type SolidView = {
|
|
10
|
+
component: string;
|
|
11
|
+
props: Record<string, unknown>;
|
|
12
|
+
} | null;
|
|
13
|
+
/**
|
|
14
|
+
* Props for PlayRenderer component
|
|
15
|
+
*
|
|
16
|
+
* @property actor - Actor instance with currentView signal (requires Viewable capability)
|
|
17
|
+
* @property components - Map of component names to SolidJS components
|
|
18
|
+
* @property fallback - Optional element shown when currentView is null
|
|
19
|
+
*/
|
|
20
|
+
export interface PlayRendererProps {
|
|
21
|
+
/** Actor instance with currentView signal (requires Viewable capability) */
|
|
22
|
+
actor: AbstractActor<AnyActorLogic> & Viewable;
|
|
23
|
+
/** Map of component names to SolidJS components */
|
|
24
|
+
components: Record<string, ValidComponent>;
|
|
25
|
+
/** Optional element shown when currentView is null */
|
|
26
|
+
fallback?: JSX.Element;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACjC,4EAA4E;IAC5E,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;IAE/C,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE3C,sDAAsD;IACtD,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-solid",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"description": "SolidJS renderer for XMachines Play architecture",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"catalog",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "XMachines Contributors",
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
17
19
|
],
|
|
18
20
|
"type": "module",
|
|
19
21
|
"exports": {
|
|
@@ -32,9 +34,9 @@
|
|
|
32
34
|
"prepublishOnly": "npm run build"
|
|
33
35
|
},
|
|
34
36
|
"dependencies": {
|
|
35
|
-
"@xmachines/play-actor": "1.0.0-beta.
|
|
36
|
-
"@xmachines/play-catalog": "1.0.0-beta.
|
|
37
|
-
"@xmachines/play-signals": "1.0.0-beta.
|
|
37
|
+
"@xmachines/play-actor": "1.0.0-beta.2",
|
|
38
|
+
"@xmachines/play-catalog": "1.0.0-beta.2",
|
|
39
|
+
"@xmachines/play-signals": "1.0.0-beta.2"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@solidjs/testing-library": "^0.8.10",
|