@xmachines/play-solid 1.0.0-beta.5 → 1.0.0-beta.50

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mikael Karon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,109 +1,203 @@
1
+ <!-- generated-by: gsd-doc-writer -->
2
+
1
3
  # @xmachines/play-solid
2
4
 
3
- SolidJS renderer for XMachines Play architecture. Enables catalog-driven view rendering with actor-owned business state.
5
+ > Solid renderer for XMachines Play architecture
6
+
7
+ SolidJS rendering layer that passively observes actor signals and renders UI components via `@json-render/solid`. SolidJS reactivity is used solely to trigger re-renders — TC39 Signals are the source of truth.
8
+
9
+ Part of the [xmachines-js monorepo](../../README.md).
4
10
 
5
11
  ## Installation
6
12
 
7
13
  ```bash
8
- npm install @xmachines/play-solid solid-js
14
+ npm install @xmachines/play-solid
9
15
  ```
10
16
 
11
- ## Current Exports
12
-
13
- - `PlayRenderer`
14
- - `PlayRendererProps` (type)
17
+ **Peer dependencies** — install alongside the package:
15
18
 
16
- ## Usage
17
-
18
- ```typescript
19
- import { PlayRenderer } from '@xmachines/play-solid';
20
- import { definePlayer } from '@xmachines/play-xstate';
21
- import { defineCatalog } from '@xmachines/play-catalog';
19
+ ```bash
20
+ npm install solid-js xstate @xstate/store @json-render/solid @json-render/core @json-render/xstate
21
+ ```
22
22
 
23
- // Define catalog
24
- const catalog = defineCatalog({
25
- Home: { component: 'Home', props: {} },
26
- Login: { component: 'Login', props: { error: { type: 'string' } } }
23
+ ## Quick Start
24
+
25
+ ```tsx
26
+ import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-solid";
27
+ import { definePlayer } from "@xmachines/play-xstate";
28
+ import { defineCatalog } from "@json-render/core";
29
+ import { schema } from "@json-render/solid/schema";
30
+
31
+ // 1. Define a catalog
32
+ const catalog = defineCatalog(schema, {
33
+ components: {
34
+ Home: { props: z.object({}), description: "Home screen" },
35
+ Login: { props: z.object({ error: z.string().optional() }), description: "Login screen" },
36
+ },
37
+ actions: {},
27
38
  });
28
39
 
29
- // Create player
30
- const createPlayer = definePlayer({
31
- machine: authMachine,
32
- catalog
40
+ // 2. Build a component registry
41
+ const registryResult = defineRegistry(catalog, {
42
+ components: {
43
+ Home: () => <div>Welcome home!</div>,
44
+ Login: (ctx) => <div>Login {ctx.props.error && <span>{ctx.props.error}</span>}</div>,
45
+ },
33
46
  });
34
47
 
48
+ // 3. Create and start an actor
49
+ const createPlayer = definePlayer({ machine: myMachine });
35
50
  const actor = createPlayer();
36
51
  actor.start();
37
52
 
38
- // Define components
39
- const components = {
40
- Home: (props) => <div>Home</div>,
41
- Login: (props) => (
42
- <form onSubmit={(e) => {
43
- e.preventDefault();
44
- props.send({ type: 'auth.login', payload: {...} });
45
- }}>
46
- {props.error && <p>{props.error}</p>}
47
- <input type="text" name="username" />
48
- <button type="submit">Login</button>
49
- </form>
50
- )
51
- };
53
+ // 4. Render
54
+ function App() {
55
+ return (
56
+ <PlayUIProvider actor={actor} registryResult={registryResult}>
57
+ <PlayRenderer />
58
+ </PlayUIProvider>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ## Usage
64
+
65
+ ### `PlayUIProvider` + `PlayRenderer` (recommended)
52
66
 
53
- // Render
54
- <PlayRenderer actor={actor} components={components} />
67
+ `PlayUIProvider` is the batteries-included entry point. It wraps `ActorProvider` and `JSONUIProvider` into a single composite provider. `PlayRenderer` is a zero-prop leaf component that reads view context and renders the current spec.
68
+
69
+ ```tsx
70
+ import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-solid";
71
+
72
+ <PlayUIProvider
73
+ actor={actor}
74
+ registryResult={registryResult}
75
+ fallback={<div>Loading…</div>}
76
+ onError={(err) => console.error(err)}
77
+ navigate={navigateFn} // optional: passed to JSONUIProvider
78
+ validationFunctions={valFns} // optional: form validation helpers
79
+ >
80
+ <PlayRenderer />
81
+ </PlayUIProvider>;
55
82
  ```
56
83
 
57
- ## API
84
+ ### `ActorProvider` (escape hatch)
58
85
 
59
- ### PlayRenderer
86
+ For library authors who need direct control over provider composition:
60
87
 
61
- Component that observes `actor.currentView` signal and renders the appropriate component from the catalog.
88
+ ```tsx
89
+ import { ActorProvider, PlayRenderer } from "@xmachines/play-solid";
62
90
 
63
- **Props:**
91
+ <ActorProvider actor={actor} registryResult={registryResult}>
92
+ <PlayRenderer />
93
+ </ActorProvider>;
94
+ ```
64
95
 
65
- - `actor: AbstractActor & Viewable` - Actor instance with currentView signal
66
- - `components: Record<string, Component<any>>` - Map of component names to SolidJS components
67
- - `fallback?: JSX.Element` - Optional fallback to show when currentView is null
96
+ ### `useActor` hook
68
97
 
69
- **Features:**
98
+ Access the raw actor instance anywhere inside an `ActorProvider` or `PlayUIProvider` tree:
70
99
 
71
- - Automatically bridges TC39 Signals to SolidJS reactivity
72
- - Passes `send` function to components for event forwarding
73
- - Handles missing components gracefully with error logging
74
- - Uses one-shot watcher re-watch pattern for proper signal observation
100
+ ```tsx
101
+ import { useActor } from "@xmachines/play-solid";
75
102
 
76
- ## Canonical Watcher Lifecycle
103
+ function SubmitButton() {
104
+ const actor = useActor();
105
+ return <button onClick={() => actor.send({ type: "SUBMIT" })}>Submit</button>;
106
+ }
107
+ ```
77
108
 
78
- Use the same watcher flow as React/Vue/router packages:
109
+ ### `usePlayView` hook
79
110
 
80
- 1. `notify`
81
- 2. `queueMicrotask`
82
- 3. `getPending()`
83
- 4. read actor signals and update framework-local render trigger
84
- 5. re-arm with `watch(...)` or `watch()`
111
+ Access the resolved view context (spec, handlers, registry) from within the provider tree:
85
112
 
86
- Watcher notifications are one-shot, so re-arm is mandatory.
113
+ ```tsx
114
+ import { usePlayView } from "@xmachines/play-solid";
115
+ import { Renderer } from "@json-render/solid";
87
116
 
88
- ## Cleanup Contract
117
+ const MyRenderer = () => {
118
+ const view = usePlayView();
119
+ return <Renderer spec={view.spec} registry={view.registry} />;
120
+ };
121
+ ```
89
122
 
90
- Solid integrations must perform explicit teardown:
123
+ ## API Summary
124
+
125
+ ### Components
126
+
127
+ | Export | Description |
128
+ | ---------------- | ------------------------------------------------------------------------------ |
129
+ | `PlayUIProvider` | Batteries-included composite provider (recommended entry point) |
130
+ | `PlayRenderer` | Zero-prop leaf component; renders the current view spec inside a provider tree |
131
+ | `ActorProvider` | Lower-level smart provider for escape-hatch composition |
132
+
133
+ ### Hooks
134
+
135
+ | Export | Description |
136
+ | --------------- | --------------------------------------------------------------------------------- |
137
+ | `useActor()` | Returns the raw `PlayActor` instance from context; throws outside a provider tree |
138
+ | `usePlayView()` | Returns the current `ViewContextValue` (spec, handlers, registry, store) |
139
+
140
+ ### Context
141
+
142
+ | Export | Description |
143
+ | -------------- | -------------------------------------------------------------------------------------- |
144
+ | `ActorContext` | SolidJS context for the actor; use `ActorContext.Provider` directly as an escape hatch |
145
+
146
+ ### Re-exports from `@json-render/solid`
147
+
148
+ This package re-exports the full `@json-render/solid` public API so consumers do not need a direct dependency:
149
+
150
+ ```tsx
151
+ import {
152
+ // Providers
153
+ JSONUIProvider,
154
+ StateProvider,
155
+ ActionProvider,
156
+ VisibilityProvider,
157
+ ValidationProvider,
158
+ // Renderer
159
+ Renderer,
160
+ // Registry factory + hooks
161
+ defineRegistry,
162
+ useBoundProp,
163
+ useStateBinding,
164
+ useStateValue,
165
+ useStateStore,
166
+ useActions,
167
+ useAction,
168
+ useIsVisible,
169
+ useFieldValidation,
170
+ useOptionalValidation,
171
+ useVisibility,
172
+ } from "@xmachines/play-solid";
173
+ ```
91
174
 
92
- - Use `onCleanup` for lifecycle teardown.
93
- - Call `unwatch(...)` on teardown, not only reference nulling.
94
- - Keep adapters/renderers passive; state validity remains actor-owned.
175
+ ### Key Types
95
176
 
96
- ## Architecture
177
+ | Type | Description |
178
+ | --------------------- | --------------------------------------------------------------------- |
179
+ | `PlayUIProviderProps` | Props for `PlayUIProvider` |
180
+ | `ActorProviderProps` | Props for `ActorProvider` |
181
+ | `ViewContextValue` | Shape of the context value from `usePlayView()` |
182
+ | `PlayActor` | `AbstractActor<AnyActorLogic>` — the actor type accepted by providers |
97
183
 
98
- PlayRenderer follows the XMachines Play architecture:
184
+ ## Testing
99
185
 
100
- - **Actor Authority**: Actor controls all state transitions via guards
101
- - **Passive Infrastructure**: Renderer observes signals, sends events
102
- - **Signal-Only Reactivity**: Business logic state lives in actor signals
186
+ Run tests for this package in isolation:
103
187
 
104
- The renderer bridges TC39 Signals (used by XMachines actors) to SolidJS's reactivity system using `Signal.subtle.Watcher` with a one-shot re-watch pattern.
188
+ ```bash
189
+ npm test -w packages/play-solid
190
+ ```
191
+
192
+ Or from within the package directory:
193
+
194
+ ```bash
195
+ npm test # single run (jsdom environment)
196
+ npm run test:watch # watch mode
197
+ npm run test:ui # interactive Vitest UI
198
+ ```
105
199
 
106
- Signals remain observation plumbing, not an alternate mutation channel.
200
+ Coverage is collected with v8 (80% threshold for lines, functions, branches, and statements). Browser-specific tests live in `test/browser/` and are excluded from the default jsdom run.
107
201
 
108
202
  ## License
109
203
 
@@ -0,0 +1,94 @@
1
+ import { ActorContext as e } from "./useActor.js";
2
+ import { createComponent as t } from "solid-js/web";
3
+ import { StateProvider as n, useStateStore as r } from "@json-render/solid";
4
+ import { ErrorBoundary as i, createContext as a, createEffect as o, createMemo as s, createSignal as c, onCleanup as l, useContext as u } from "solid-js";
5
+ import { createAtom as d } from "@xstate/store";
6
+ import { xstateStoreStateStore as f } from "@json-render/xstate";
7
+ import { watchSignal as p } from "@xmachines/play-signals";
8
+ import { assertNonNullable as m } from "@xmachines/play";
9
+ //#region src/ActorProvider.tsx
10
+ var h = a(null);
11
+ function g() {
12
+ return m(u(h), "ViewContext");
13
+ }
14
+ var _ = (e) => {
15
+ let n = r(), i = (e) => {
16
+ let t = n.getSnapshot();
17
+ n.update(e(t));
18
+ }, a = e.registryResult.handlers(() => i, () => n.getSnapshot()), o = {
19
+ spec: e.spec,
20
+ handlers: a,
21
+ registry: e.registryResult.registry,
22
+ store: e.store
23
+ };
24
+ return t(h.Provider, {
25
+ value: o,
26
+ get children() {
27
+ return e.children;
28
+ }
29
+ });
30
+ }, v = (r) => {
31
+ let [a, u] = c(null), m = s(() => {
32
+ if (!r.onRenderError) return r.registryResult;
33
+ let e = { ...r.registryResult.registry };
34
+ return Object.defineProperty(e, "onRenderError", {
35
+ value: r.onRenderError,
36
+ enumerable: !1,
37
+ configurable: !0
38
+ }), {
39
+ ...r.registryResult,
40
+ registry: e
41
+ };
42
+ }), h = null, g = null;
43
+ return o(() => {
44
+ let e = (e) => u(e);
45
+ e(r.actor.currentView.get());
46
+ let t = p(r.actor.currentView, (t) => {
47
+ e(t);
48
+ });
49
+ l(() => t());
50
+ }), t(e.Provider, {
51
+ get value() {
52
+ return r.actor;
53
+ },
54
+ get children() {
55
+ return t(i, {
56
+ fallback: (e) => (r.onError?.(e), r.fallback ?? null),
57
+ get children() {
58
+ return (() => {
59
+ let e = a();
60
+ if (!e) return r.fallback ?? null;
61
+ let i;
62
+ if (r.store) i = r.store;
63
+ else {
64
+ if (h === null || g !== e) {
65
+ let t = e.state;
66
+ h = f({ atom: d(typeof t == "object" && t && !Array.isArray(t) && (Object.getPrototypeOf(t) === Object.prototype || Object.getPrototypeOf(t) === null) ? t : {}) }), g = e;
67
+ }
68
+ i = h;
69
+ }
70
+ return t(n, {
71
+ store: i,
72
+ get children() {
73
+ return t(_, {
74
+ get registryResult() {
75
+ return m();
76
+ },
77
+ spec: e,
78
+ store: i,
79
+ get children() {
80
+ return r.children;
81
+ }
82
+ });
83
+ }
84
+ });
85
+ })();
86
+ }
87
+ });
88
+ }
89
+ });
90
+ };
91
+ //#endregion
92
+ export { v as ActorProvider, g as usePlayView };
93
+
94
+ //# sourceMappingURL=ActorProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorProvider.js","names":["createSignal","createEffect","createMemo","onCleanup","createContext","useContext","ErrorBoundary","Component","JSX","StateProvider","useStateStore","DefineRegistryResult","SetState","StateStore","ComponentRegistry","createAtom","xstateStoreStateStore","watchSignal","assertNonNullable","PlaySpec","BaseActorProviderProps","BaseViewContextValue","ActorContext","PlayActor","ViewContextValue","ViewContext","usePlayView","ActorProviderProps","fallback","Element","onError","error","children","ActorProviderInner","registryResult","spec","store","innerProps","stateCtx","setStateAdapter","updater","prev","getSnapshot","update","handlers","viewValue","registry","_$createComponent","Provider","value","ActorProvider","props","view","setView","resolvedRegistryResult","onRenderError","r","Object","defineProperty","enumerable","configurable","internalStore","lastView","nextView","actor","currentView","get","unwatch","err","rawState","state","initialState","Array","isArray","getPrototypeOf","prototype","Record","atom"],"sources":["../src/ActorProvider.tsx"],"sourcesContent":["/**\n * ActorProvider — Smart SolidJS provider component for the XMachines Play actor lifecycle.\n *\n * Escape hatch primitive for library authors who need direct control. Most users should\n * use PlayUIProvider (batteries-included composite) instead.\n *\n * This component:\n * - Subscribes to actor.currentView signal via watchSignal (in component body per Phase 29)\n * - Manages per-view StateStore lifecycle (controlled/uncontrolled)\n * - Resolves action handlers via inner component pattern (inside StateProvider)\n * - Injects onRenderError into registry if provided\n * - Provides ActorContext (actor) and ViewContext (spec + handlers + registry) to children\n * - Wraps render path in SolidJS ErrorBoundary\n *\n * Per D-11: The old `ActorProvider = ActorContext.Provider` alias is removed. This new smart\n * component takes the name. Use `ActorContext.Provider` directly for escape-hatch access.\n *\n * @packageDocumentation\n */\n\nimport {\n\tcreateSignal,\n\tcreateEffect,\n\tcreateMemo,\n\tonCleanup,\n\tcreateContext,\n\tuseContext,\n\tErrorBoundary,\n} from \"solid-js\";\nimport type { Component, JSX } from \"solid-js\";\nimport { StateProvider, useStateStore } from \"@json-render/solid\";\nimport type { DefineRegistryResult, SetState } from \"@json-render/solid\";\nimport type { StateStore } from \"@json-render/core\";\nimport type { ComponentRegistry } from \"@json-render/solid\";\nimport { createAtom } from \"@xstate/store\";\nimport { xstateStoreStateStore } from \"@json-render/xstate\";\nimport { watchSignal } from \"@xmachines/play-signals\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport type { PlaySpec, BaseActorProviderProps, BaseViewContextValue } from \"@xmachines/play-actor\";\nimport { ActorContext, type PlayActor } from \"./useActor.js\";\n\n// ---------------------------------------------------------------------------\n// ViewContextValue — shape of the context value provided by ActorProvider\n// ---------------------------------------------------------------------------\n\n/**\n * Value provided by ActorProvider's ViewContext.\n * Access via usePlayView() inside the ActorProvider tree.\n */\nexport interface ViewContextValue extends BaseViewContextValue<ComponentRegistry> {}\n\nconst ViewContext = createContext<ViewContextValue | null>(null);\n\n/**\n * Hook to access the current view context inside an ActorProvider tree.\n *\n * @throws {Error} If called outside an ActorProvider (or PlayUIProvider) tree\n *\n * @example\n * ```tsx\n * import { usePlayView } from \"@xmachines/play-solid\";\n *\n * const MyRenderer: Component = () => {\n * const view = usePlayView();\n * return <Renderer spec={view.spec} registry={view.registry} />;\n * };\n * ```\n */\nexport function usePlayView(): ViewContextValue {\n\treturn assertNonNullable(useContext(ViewContext), \"ViewContext\");\n}\n\n// ---------------------------------------------------------------------------\n// ActorProviderProps\n// ---------------------------------------------------------------------------\n\n/**\n * Props for ActorProvider — the escape hatch primitive.\n *\n * For batteries-included usage, prefer PlayUIProvider which wraps ActorProvider\n * with JSONUIProvider and all required sub-providers.\n */\nexport interface ActorProviderProps extends BaseActorProviderProps<DefineRegistryResult> {\n\t/** Optional fallback element shown when currentView is null or ErrorBoundary catches */\n\tfallback?: JSX.Element;\n\n\t/** Optional callback invoked when SolidJS ErrorBoundary catches an error */\n\tonError?: (error: unknown) => void;\n\n\t/** Children — required; must include <PlayRenderer /> (or use PlayUIProvider shorthand) */\n\tchildren: JSX.Element;\n}\n\n// ---------------------------------------------------------------------------\n// ActorProviderInner — resolves handlers inside StateProvider tree\n// ---------------------------------------------------------------------------\n\n/**\n * Inner component that runs inside StateProvider so it can call useStateStore()\n * to get live set/getSnapshot for handler resolution.\n */\nconst ActorProviderInner: Component<{\n\tregistryResult: DefineRegistryResult;\n\tspec: PlaySpec;\n\tstore: StateStore;\n\tchildren: JSX.Element;\n}> = (innerProps) => {\n\tconst stateCtx = useStateStore();\n\n\t// Build SetState adapter bridging stateCtx.update/getSnapshot\n\tconst setStateAdapter: SetState = (updater) => {\n\t\tconst prev = stateCtx.getSnapshot();\n\t\tstateCtx.update(updater(prev));\n\t};\n\n\tconst handlers = innerProps.registryResult.handlers(\n\t\t() => setStateAdapter,\n\t\t() => stateCtx.getSnapshot(),\n\t);\n\n\tconst viewValue: ViewContextValue = {\n\t\tspec: innerProps.spec,\n\t\thandlers,\n\t\tregistry: innerProps.registryResult.registry,\n\t\tstore: innerProps.store,\n\t};\n\n\treturn <ViewContext.Provider value={viewValue}>{innerProps.children}</ViewContext.Provider>;\n};\n\n// ---------------------------------------------------------------------------\n// ActorProvider — the smart component (per D-11 takes the ActorProvider name)\n// ---------------------------------------------------------------------------\n\n/**\n * Smart ActorProvider component — owns actor bridging, signal subscription,\n * StateStore lifecycle, handler resolution, and error boundary.\n *\n * Per D-11: Replaces the old raw alias `ActorProvider = ActorContext.Provider`.\n * Consumers who previously used `<ActorProvider value={actor}>` should now use\n * `<ActorContext.Provider value={actor}>` for raw provider access, or migrate to\n * this smart component / PlayUIProvider.\n *\n * @example\n * ```tsx\n * import { ActorProvider, PlayRenderer } from \"@xmachines/play-solid\";\n *\n * <ActorProvider actor={myActor} registryResult={registryResult}>\n * <PlayRenderer />\n * </ActorProvider>\n * ```\n */\nexport const ActorProvider: Component<ActorProviderProps> = (props) => {\n\t// SolidJS signal for current view (PlaySpec | null)\n\tconst [view, setView] = createSignal<PlaySpec | null>(null);\n\n\t// Inject onRenderError into registry if provided (non-enumerable override).\n\t// Memoized so that creating a new object on every reactive evaluation does not\n\t// cause unnecessary re-renders of child components that receive this as a prop.\n\tconst resolvedRegistryResult = createMemo(() => {\n\t\tif (!props.onRenderError) return props.registryResult;\n\t\tconst r = { ...props.registryResult.registry };\n\t\tObject.defineProperty(r, \"onRenderError\", {\n\t\t\tvalue: props.onRenderError,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true,\n\t\t});\n\t\treturn { ...props.registryResult, registry: r };\n\t});\n\n\t// Per-view internal store — recreated on each view transition (uncontrolled mode)\n\tlet internalStore: StateStore | null = null;\n\tlet lastView: PlaySpec | null = null;\n\n\t// Bridge TC39 Signal to SolidJS signal — seed AND watch atomically inside a single\n\t// createEffect to eliminate the race window between .get() and watcher registration.\n\t// If the TC39 signal changes between the initial .get() and first watcher notification,\n\t// the update function captures the latest value without missing it.\n\tcreateEffect(() => {\n\t\tconst update = (nextView: PlaySpec | null) => setView(nextView);\n\t\tupdate(props.actor.currentView.get() as PlaySpec | null);\n\t\tconst unwatch = watchSignal(props.actor.currentView, (nextView) => {\n\t\t\tupdate(nextView as PlaySpec | null);\n\t\t});\n\t\tonCleanup(() => unwatch());\n\t});\n\n\treturn (\n\t\t<ActorContext.Provider value={props.actor as PlayActor}>\n\t\t\t<ErrorBoundary\n\t\t\t\tfallback={(err: unknown) => {\n\t\t\t\t\tprops.onError?.(err);\n\t\t\t\t\treturn props.fallback ?? null;\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{(() => {\n\t\t\t\t\tconst currentView = view();\n\t\t\t\t\tif (!currentView) return props.fallback ?? null;\n\n\t\t\t\t\t// Resolve store: external (controlled) or internal per-view atom\n\t\t\t\t\tlet store: StateStore;\n\t\t\t\t\tif (props.store) {\n\t\t\t\t\t\tstore = props.store;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (internalStore === null || lastView !== currentView) {\n\t\t\t\t\t\t\t// Proto-safe guard: spec.state must be a plain object (T-37-05-02)\n\t\t\t\t\t\t\tconst rawState = currentView.state;\n\t\t\t\t\t\t\tconst initialState =\n\t\t\t\t\t\t\t\trawState !== null &&\n\t\t\t\t\t\t\t\ttypeof rawState === \"object\" &&\n\t\t\t\t\t\t\t\t!Array.isArray(rawState) &&\n\t\t\t\t\t\t\t\t(Object.getPrototypeOf(rawState) === Object.prototype ||\n\t\t\t\t\t\t\t\t\tObject.getPrototypeOf(rawState) === null)\n\t\t\t\t\t\t\t\t\t? (rawState as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t: {};\n\t\t\t\t\t\t\tinternalStore = xstateStoreStateStore({\n\t\t\t\t\t\t\t\tatom: createAtom(initialState),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tlastView = currentView;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstore = internalStore;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<StateProvider store={store}>\n\t\t\t\t\t\t\t<ActorProviderInner\n\t\t\t\t\t\t\t\tregistryResult={resolvedRegistryResult()}\n\t\t\t\t\t\t\t\tspec={currentView}\n\t\t\t\t\t\t\t\tstore={store}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{props.children}\n\t\t\t\t\t\t\t</ActorProviderInner>\n\t\t\t\t\t\t</StateProvider>\n\t\t\t\t\t);\n\t\t\t\t})()}\n\t\t\t</ErrorBoundary>\n\t\t</ActorContext.Provider>\n\t);\n};\n"],"mappings":";;;;;;;;;AAmDA,IAAMyB,IAAcrB,EAAuC,KAAK;AAiBhE,SAAgBsB,IAAgC;AAC/C,QAAOR,EAAkBb,EAAWoB,EAAY,EAAE,cAAc;;AAgCjE,IAAMQ,KAKAI,MAAe;CACpB,IAAMC,IAAW5B,GAAe,EAG1B6B,KAA6BC,MAAY;EAC9C,IAAMC,IAAOH,EAASI,aAAa;AACnCJ,IAASK,OAAOH,EAAQC,EAAK,CAAC;IAGzBG,IAAWP,EAAWH,eAAeU,eACpCL,SACAD,EAASI,aAChB,CAAC,EAEKG,IAA8B;EACnCV,MAAME,EAAWF;EACjBS;EACAE,UAAUT,EAAWH,eAAeY;EACpCV,OAAOC,EAAWD;EAClB;AAED,QAAAW,EAAQtB,EAAYuB,UAAQ;EAACC,OAAOJ;EAAS,IAAAb,WAAA;AAAA,UAAGK,EAAWL;;EAAQ,CAAA;GAyBvDkB,KAAgDC,MAAU;CAEtE,IAAM,CAACC,GAAMC,KAAWrD,EAA8B,KAAK,EAKrDsD,IAAyBpD,QAAiB;AAC/C,MAAI,CAACiD,EAAMI,cAAe,QAAOJ,EAAMjB;EACvC,IAAMsB,IAAI,EAAE,GAAGL,EAAMjB,eAAeY,UAAU;AAM9C,SALAW,OAAOC,eAAeF,GAAG,iBAAiB;GACzCP,OAAOE,EAAMI;GACbI,YAAY;GACZC,cAAc;GACd,CAAC,EACK;GAAE,GAAGT,EAAMjB;GAAgBY,UAAUU;GAAG;GAC9C,EAGEK,IAAmC,MACnCC,IAA4B;AAehC,QATA7D,QAAmB;EAClB,IAAM0C,KAAUoB,MAA8BV,EAAQU,EAAS;AAC/DpB,IAAOQ,EAAMa,MAAMC,YAAYC,KAAK,CAAoB;EACxD,IAAMC,IAAUlD,EAAYkC,EAAMa,MAAMC,cAAcF,MAAa;AAClEpB,KAAOoB,EAA4B;IAClC;AACF5D,UAAgBgE,GAAS,CAAC;GACzB,EAEFpB,EACEzB,EAAa0B,UAAQ;EAAA,IAACC,QAAK;AAAA,UAAEE,EAAMa;;EAAkB,IAAAhC,WAAA;AAAA,UAAAe,EACpDzC,GAAa;IACbsB,WAAWwC,OACVjB,EAAMrB,UAAUsC,EAAI,EACbjB,EAAMvB,YAAY;IACzB,IAAAI,WAAA;AAAA,mBAEO;MACP,IAAMiC,IAAcb,GAAM;AAC1B,UAAI,CAACa,EAAa,QAAOd,EAAMvB,YAAY;MAG3C,IAAIQ;AACJ,UAAIe,EAAMf,MACTA,KAAQe,EAAMf;WACR;AACN,WAAIyB,MAAkB,QAAQC,MAAaG,GAAa;QAEvD,IAAMI,IAAWJ,EAAYK;AAY7BR,QAHAD,IAAgB7C,EAAsB,EACrC6D,MAAM9D,EAPN,OAAOsD,KAAa,YADpBA,KAEA,CAACG,MAAMC,QAAQJ,EAAS,KACvBZ,OAAOiB,eAAeL,EAAS,KAAKZ,OAAOkB,aAC3ClB,OAAOiB,eAAeL,EAAS,KAAK,QACjCA,IACD,EAAE,CAEwB,EAC7B,CAAC,EACFP,IAAWG;;AAEZ7B,WAAQyB;;AAGT,aAAAd,EACEtC,GAAa;OAAQ2B;OAAK,IAAAJ,WAAA;AAAA,eAAAe,EACzBd,GAAkB;SAAA,IAClBC,iBAAc;AAAA,iBAAEoB,GAAwB;;SACxCnB,MAAM8B;SACC7B;SAAK,IAAAJ,WAAA;AAAA,iBAEXmB,EAAMnB;;SAAQ,CAAA;;OAAA,CAAA;SAIf;;IAAA,CAAA;;EAAA,CAAA"}
@@ -1,31 +1,19 @@
1
- import { Dynamic as e, createComponent as t, insert as n, memo as r, mergeProps as i, template as a } from "solid-js/web";
2
- import { createSignal as o, onMount as s } from "solid-js";
3
- import { Signal as c } from "@xmachines/play-signals";
1
+ import { usePlayView as e } from "./ActorProvider.js";
2
+ import { createComponent as t } from "solid-js/web";
3
+ import { Renderer as n } from "@json-render/solid";
4
4
  //#region src/PlayRenderer.tsx
5
- var l = /* @__PURE__ */ a("<div class=play-renderer-error>Component \"<!>\" not found in catalog. Available: "), u = (a) => {
6
- let [u, d] = o(a.actor.currentView.get());
7
- s(() => {
8
- let e = new c.subtle.Watcher(() => {
9
- queueMicrotask(() => {
10
- e.getPending(), d(a.actor.currentView.get()), e.watch(a.actor.currentView);
11
- });
12
- });
13
- e.watch(a.actor.currentView);
5
+ var r = () => {
6
+ let r = e();
7
+ return t(n, {
8
+ get spec() {
9
+ return r.spec;
10
+ },
11
+ get registry() {
12
+ return r.registry;
13
+ }
14
14
  });
15
- let f = a.actor.send.bind(a.actor);
16
- return [
17
- r(() => r(() => !u())() && (a.fallback || null)),
18
- r(() => r(() => !!(u() && !a.components))() && (console.error(`Components catalog is ${a.components === null ? "null" : "undefined"}. Cannot render component "${u().component}".`), a.fallback || null)),
19
- r(() => r(() => !!(u() && a.components && !a.components[u().component]))() && (console.error(`Component "${u().component}" not found in catalog. Available components: ${Object.keys(a.components).join(", ")}`), (() => {
20
- var e = l(), t = e.firstChild.nextSibling;
21
- return t.nextSibling, n(e, () => u().component, t), n(e, () => Object.keys(a.components).join(", "), null), e;
22
- })())),
23
- r(() => r(() => !!(u() && a.components && a.components[u().component]))() && t(e, i({ get component() {
24
- return a.components[u().component];
25
- } }, () => u().props, { send: f })))
26
- ];
27
15
  };
28
16
  //#endregion
29
- export { u as PlayRenderer };
17
+ export { r as PlayRenderer };
30
18
 
31
19
  //# sourceMappingURL=PlayRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlayRenderer.js","names":["createSignal","onMount","Component","Dynamic","Signal","PlayRendererProps","SolidView","PlayRenderer","props","view","setView","actor","currentView","get","watcher","subtle","Watcher","queueMicrotask","getPending","watch","sendBound","send","bind","_$memo","fallback","components","console","error","component","Object","keys","join","_el$","_tmpl$","_el$2","firstChild","_el$5","nextSibling","_el$3","_$insert","_$createComponent","_$mergeProps"],"sources":["../src/PlayRenderer.tsx"],"sourcesContent":["/**\n * PlayRenderer - Main SolidJS renderer component for XMachines Play architecture\n *\n * @packageDocumentation\n */\n\nimport { createSignal, onMount, type Component } from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { Signal } from \"@xmachines/play-signals\";\nimport type { PlayRendererProps, SolidView } from \"./types.js\";\n\n/**\n * Main renderer component that subscribes to actor signals and renders UI\n *\n * Architecture (per XMachines Play patterns):\n * - Subscribes to actor.currentView signal via TC39 Signal.subtle.Watcher\n * - Dynamically renders catalog components based on view.component string\n * - Forwards user events to actor via actor.send()\n * - SolidJS signal only for triggering renders, NOT business logic\n *\n * Invariant: Actor Authority - Actor decides all state transitions via guards.\n * Invariant: Passive Infrastructure - Component observes signals and sends events.\n * Invariant: Signal-Only Reactivity - Business logic state lives in actor signals.\n *\n * @example\n * ```typescript\n * import { PlayRenderer } from \"@xmachines/play-solidjs\";\n * import { definePlayer } from \"@xmachines/play-xstate\";\n *\n * const actor = definePlayer({ machine, catalog })();\n * actor.start();\n *\n * const components = {\n * Dashboard: (props) => <div>User: {props.userId}</div>,\n * LoginForm: (props) => (\n * <form onSubmit={(e) => {\n * e.preventDefault();\n * props.send({ type: \"auth.login\", payload: {...} });\n * }}>...</form>\n * )\n * };\n *\n * <PlayRenderer actor={actor} components={components} />\n * ```\n *\n * @param props - Component props\n * @returns SolidJS element rendering current view from actor\n *\n * @remarks\n * **Component lookup:** Dynamically looks up component from `components` map\n * using `view.component` string from actor.currentView signal.\n *\n * **Event forwarding:** Injects `send` function as prop to components. Components\n * call `send(event)` to forward intents to actor. Actor guards decide validity.\n *\n * **Error handling:** If component not found in catalog, logs error and shows\n * fallback. This indicates missing component registration, not runtime error.\n *\n * **Signal bridge:** Uses one-shot re-watch pattern. TC39 Signal watchers stop\n * watching after notification, so watcher.watch() must be called in microtask\n * after getPending() to re-arm for next notification.\n *\n * **CRITICAL:** Never call actor.send() during render - only in event handlers.\n * Calling send during render causes infinite render loops.\n */\nexport const PlayRenderer: Component<PlayRendererProps> = (props) => {\n\t// Create SolidJS signal for view\n\t// Signal is NOT business logic state - it's just SolidJS's render trigger\n\tconst [view, setView] = createSignal<SolidView>(props.actor.currentView.get() as SolidView);\n\n\t// Bridge TC39 Signal to SolidJS signal\n\t// Uses one-shot re-watch pattern (must re-watch after each notification)\n\tonMount(() => {\n\t\tconst watcher = new Signal.subtle.Watcher(() => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\t// Acknowledge the notification\n\t\t\t\twatcher.getPending();\n\n\t\t\t\t// Update SolidJS signal (triggers SolidJS reactivity)\n\t\t\t\tsetView(props.actor.currentView.get() as SolidView);\n\n\t\t\t\t// Re-watch for next notification (one-shot pattern)\n\t\t\t\t// TC39 Signal watchers stop watching after notification\n\t\t\t\twatcher.watch(props.actor.currentView);\n\t\t\t});\n\t\t});\n\n\t\t// Watch actor.currentView for changes\n\t\twatcher.watch(props.actor.currentView);\n\n\t\t// Note: TC39 Signal watchers don't have explicit disposal\n\t\t// The watcher will be garbage collected when the component unmounts\n\t});\n\n\t// Bind send function (ensures correct 'this' context)\n\tconst sendBound = props.actor.send.bind(props.actor);\n\n\treturn (\n\t\t<>\n\t\t\t{/* No view - show fallback */}\n\t\t\t{!view() && (props.fallback || null)}\n\n\t\t\t{/* Handle null/undefined components catalog gracefully */}\n\t\t\t{view() &&\n\t\t\t\t!props.components &&\n\t\t\t\t(() => {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`Components catalog is ${props.components === null ? \"null\" : \"undefined\"}. ` +\n\t\t\t\t\t\t\t`Cannot render component \"${view()!.component}\".`,\n\t\t\t\t\t);\n\t\t\t\t\treturn props.fallback || null;\n\t\t\t\t})()}\n\n\t\t\t{/* View exists but component not found */}\n\t\t\t{view() &&\n\t\t\t\tprops.components &&\n\t\t\t\t!props.components[view()!.component] &&\n\t\t\t\t(() => {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`Component \"${view()!.component}\" not found in catalog. ` +\n\t\t\t\t\t\t\t`Available components: ${Object.keys(props.components).join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div class=\"play-renderer-error\">\n\t\t\t\t\t\t\tComponent \"{view()!.component}\" not found in catalog. Available:{\" \"}\n\t\t\t\t\t\t\t{Object.keys(props.components).join(\", \")}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t})()}\n\n\t\t\t{/* Render matched component dynamically */}\n\t\t\t{view() && props.components && props.components[view()!.component] && (\n\t\t\t\t<Dynamic\n\t\t\t\t\tcomponent={props.components[view()!.component]}\n\t\t\t\t\t{...view()!.props}\n\t\t\t\t\tsend={sendBound}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"mappings":";;;;iHAiEaO,KAA8CC,MAAU;CAGpE,IAAM,CAACC,GAAMC,KAAWV,EAAwBQ,EAAMG,MAAMC,YAAYC,KAAK,CAAc;AAI3FZ,SAAc;EACb,IAAMa,IAAU,IAAIV,EAAOW,OAAOC,cAAc;AAC/CC,wBAAqB;AASpBH,IAPAA,EAAQI,YAAY,EAGpBR,EAAQF,EAAMG,MAAMC,YAAYC,KAAK,CAAc,EAInDC,EAAQK,MAAMX,EAAMG,MAAMC,YAAY;KACrC;IACD;AAGFE,IAAQK,MAAMX,EAAMG,MAAMC,YAAY;GAIrC;CAGF,IAAMQ,IAAYZ,EAAMG,MAAMU,KAAKC,KAAKd,EAAMG,MAAM;AAEpD,QAAA;EAAAY,QAGGA,QAAA,CAACd,GAAM,CAAA,EAAA,KAAKD,EAAMgB,YAAY,MAAK;EAAAD,QAGnCA,QAAA,CAAA,EAAAd,GAAM,IACN,CAACD,EAAMiB,YAAU,EAAA,KAEhBC,QAAQC,MACP,yBAAyBnB,EAAMiB,eAAe,OAAO,SAAS,YAAW,6BAC5ChB,GAAM,CAAEmB,UAAS,IAC9C,EACMpB,EAAMgB,YAAY,MACtB;EAAAD,QAGJA,QAAA,CAAA,EAAAd,GAAM,IACND,EAAMiB,cACN,CAACjB,EAAMiB,WAAWhB,GAAM,CAAEmB,YAAU,EAAA,KAEnCF,QAAQC,MACP,cAAclB,GAAM,CAAEmB,UAAS,gDACLC,OAAOC,KAAKtB,EAAMiB,WAAW,CAACM,KAAK,KAAK,GAClE,SACD;GAAA,IAAAC,IAAAC,GAAA,EAAAG,IAAAJ,EAAAG,WAAAE;AAG2C,UAH3CD,EAAAC,aAAAE,EAAAP,SAEcvB,GAAM,CAAEmB,WAASQ,EAAA,EAAAG,EAAAP,SAC5BH,OAAOC,KAAKtB,EAAMiB,WAAW,CAACM,KAAK,KAAK,EAAA,KAAA,EAAAC;MAAA,EAGxC;EAAAT,QAGJA,QAAA,CAAA,EAAAd,GAAM,IAAID,EAAMiB,cAAcjB,EAAMiB,WAAWhB,GAAM,CAAEmB,YAAU,EAAA,IAAAY,EAChErC,GAAOsC,EAAA,EAAA,IACPb,YAAS;AAAA,UAAEpB,EAAMiB,WAAWhB,GAAM,CAAEmB;KAAU,QAC1CnB,GAAM,CAAED,OAAK,EACjBa,MAAMD,GAAS,CAAA,CAEhB,CAAA;EAAA"}
1
+ {"version":3,"file":"PlayRenderer.js","names":["Component","Renderer","usePlayView","PlayRenderer","view","_$createComponent","spec","registry"],"sources":["../src/PlayRenderer.tsx"],"sourcesContent":["/**\n * PlayRenderer - Zero-prop leaf component for XMachines Play SolidJS architecture.\n *\n * Reads view context from the enclosing ActorProvider (or PlayUIProvider) via\n * usePlayView() and renders the spec using @json-render/solid's Renderer.\n *\n * Standard usage:\n * ```tsx\n * <PlayUIProvider actor={myActor} registryResult={registryResult}>\n * <PlayRenderer />\n * </PlayUIProvider>\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { Component } from \"solid-js\";\nimport { Renderer } from \"@json-render/solid\";\nimport { usePlayView } from \"./ActorProvider.js\";\n\n/**\n * Zero-prop leaf renderer. Must be placed inside an ActorProvider or PlayUIProvider tree.\n *\n * Reads ViewContextValue (spec, handlers, registry) from the enclosing provider\n * via usePlayView() and renders the spec via @json-render/solid's Renderer.\n */\nexport const PlayRenderer: Component = () => {\n\tconst view = usePlayView();\n\treturn <Renderer spec={view.spec} registry={view.registry} />;\n};\n"],"mappings":";;;;AA0BA,IAAaG,UAAgC;CAC5C,IAAMC,IAAOF,GAAa;AAC1B,QAAAG,EAAQJ,GAAQ;EAAA,IAACK,OAAI;AAAA,UAAEF,EAAKE;;EAAI,IAAEC,WAAQ;AAAA,UAAEH,EAAKG;;EAAQ,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { ActorProvider as e, usePlayView as t } from "./ActorProvider.js";
2
+ import { createComponent as n, mergeProps as r } from "solid-js/web";
3
+ import { JSONUIProvider as i } from "@json-render/solid";
4
+ //#region src/PlayUIProvider.tsx
5
+ var a = (e) => {
6
+ let a = t();
7
+ return n(i, r({
8
+ get registry() {
9
+ return a.registry;
10
+ },
11
+ get handlers() {
12
+ return a.handlers;
13
+ },
14
+ get store() {
15
+ return a.store;
16
+ }
17
+ }, () => e.validationFunctions !== void 0 && { validationFunctions: e.validationFunctions }, () => e.navigate !== void 0 && { navigate: e.navigate }, () => e.functions !== void 0 && { functions: e.functions }, { get children() {
18
+ return e.children;
19
+ } }));
20
+ }, o = (t) => n(e, r({
21
+ get actor() {
22
+ return t.actor;
23
+ },
24
+ get registryResult() {
25
+ return t.registryResult;
26
+ }
27
+ }, () => t.store !== void 0 && { store: t.store }, () => t.fallback !== void 0 && { fallback: t.fallback }, () => t.onError !== void 0 && { onError: t.onError }, () => t.onRenderError !== void 0 && { onRenderError: t.onRenderError }, { get children() {
28
+ return n(a, r(() => t.validationFunctions !== void 0 && { validationFunctions: t.validationFunctions }, () => t.navigate !== void 0 && { navigate: t.navigate }, () => t.functions !== void 0 && { functions: t.functions }, { get children() {
29
+ return t.children;
30
+ } }));
31
+ } }));
32
+ //#endregion
33
+ export { o as PlayUIProvider };
34
+
35
+ //# sourceMappingURL=PlayUIProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlayUIProvider.js","names":["Component","JSX","JSONUIProvider","JSONUIProviderProps","ActorProvider","usePlayView","ActorProviderProps","JSONUIForwardedProps","Pick","PlayUIProviderProps","Partial","JSONUIBridge","children","Element","bridgeProps","view","_$createComponent","_$mergeProps","registry","handlers","store","validationFunctions","undefined","navigate","functions","PlayUIProvider","props","actor","registryResult","fallback","onError","onRenderError"],"sources":["../src/PlayUIProvider.tsx"],"sourcesContent":["/**\n * PlayUIProvider — Batteries-included SolidJS provider for XMachines Play.\n *\n * Wraps ActorProvider + JSONUIProvider into a single composite provider.\n * This is the recommended entry point for most users.\n *\n * Standard usage:\n * ```tsx\n * import { PlayUIProvider, PlayRenderer, defineRegistry } from \"@xmachines/play-solid\";\n *\n * const registryResult = defineRegistry(myCatalog, { components, actions });\n *\n * <PlayUIProvider actor={myActor} registryResult={registryResult}>\n * <PlayRenderer />\n * </PlayUIProvider>\n * ```\n *\n * For full control (library authors), use ActorProvider directly.\n *\n * @packageDocumentation\n */\n\nimport type { Component, JSX } from \"solid-js\";\nimport { JSONUIProvider, type JSONUIProviderProps } from \"@json-render/solid\";\nimport { ActorProvider, usePlayView, type ActorProviderProps } from \"./ActorProvider.js\";\n\n// Pick only the forwarded props from JSONUIProviderProps (per D-16)\ntype JSONUIForwardedProps = Pick<\n\tJSONUIProviderProps,\n\t\"validationFunctions\" | \"navigate\" | \"functions\"\n>;\n\n/**\n * Props for PlayUIProvider — all ActorProvider props plus JSONUIProvider's forwarded props.\n */\nexport interface PlayUIProviderProps extends ActorProviderProps, Partial<JSONUIForwardedProps> {}\n\n/**\n * Inner bridge component — must be inside ActorProvider's tree so usePlayView() has\n * access to the resolved ViewContextValue. Reads handlers and registry from the view\n * context and passes them to JSONUIProvider.\n *\n * This bridge pattern mirrors the React implementation (JSONUIBridge in play-react).\n */\nconst JSONUIBridge: Component<Partial<JSONUIForwardedProps> & { children: JSX.Element }> = (\n\tbridgeProps,\n) => {\n\tconst view = usePlayView();\n\n\treturn (\n\t\t<JSONUIProvider\n\t\t\tregistry={view.registry}\n\t\t\thandlers={view.handlers}\n\t\t\tstore={view.store}\n\t\t\t{...(bridgeProps.validationFunctions !== undefined && {\n\t\t\t\tvalidationFunctions: bridgeProps.validationFunctions,\n\t\t\t})}\n\t\t\t{...(bridgeProps.navigate !== undefined && { navigate: bridgeProps.navigate })}\n\t\t\t{...(bridgeProps.functions !== undefined && { functions: bridgeProps.functions })}\n\t\t>\n\t\t\t{bridgeProps.children}\n\t\t</JSONUIProvider>\n\t);\n};\n\n/**\n * Batteries-included composite provider: ActorProvider + JSONUIProvider.\n *\n * Provides the full JSON render context stack:\n * - ActorContext (actor instance via ActorProvider)\n * - ViewContext (spec, handlers, registry via ActorProvider)\n * - StateProvider + ActionProvider + VisibilityProvider + ValidationProvider (via JSONUIProvider)\n * - ConfirmDialogManager (via JSONUIProvider)\n *\n * @example\n * ```tsx\n * <PlayUIProvider actor={myActor} registryResult={registryResult} navigate={navigate}>\n * <PlayRenderer />\n * </PlayUIProvider>\n * ```\n */\nexport const PlayUIProvider: Component<PlayUIProviderProps> = (props) => {\n\treturn (\n\t\t<ActorProvider\n\t\t\tactor={props.actor}\n\t\t\tregistryResult={props.registryResult}\n\t\t\t{...(props.store !== undefined && { store: props.store })}\n\t\t\t{...(props.fallback !== undefined && { fallback: props.fallback })}\n\t\t\t{...(props.onError !== undefined && { onError: props.onError })}\n\t\t\t{...(props.onRenderError !== undefined && { onRenderError: props.onRenderError })}\n\t\t>\n\t\t\t<JSONUIBridge\n\t\t\t\t{...(props.validationFunctions !== undefined && {\n\t\t\t\t\tvalidationFunctions: props.validationFunctions,\n\t\t\t\t})}\n\t\t\t\t{...(props.navigate !== undefined && { navigate: props.navigate })}\n\t\t\t\t{...(props.functions !== undefined && { functions: props.functions })}\n\t\t\t>\n\t\t\t\t{props.children}\n\t\t\t</JSONUIBridge>\n\t\t</ActorProvider>\n\t);\n};\n"],"mappings":";;;;AA4CA,IAAMW,KACLG,MACI;CACJ,IAAMC,IAAOV,GAAa;AAE1B,QAAAW,EACEd,GAAce,EAAA;EAAA,IACdC,WAAQ;AAAA,UAAEH,EAAKG;;EAAQ,IACvBC,WAAQ;AAAA,UAAEJ,EAAKI;;EAAQ,IACvBC,QAAK;AAAA,UAAEL,EAAKK;;EAAK,QACZN,EAAYO,wBAAwBC,KAAAA,KAAa,EACrDD,qBAAqBP,EAAYO,qBACjC,QACIP,EAAYS,aAAaD,KAAAA,KAAa,EAAEC,UAAUT,EAAYS,UAAU,QACxET,EAAYU,cAAcF,KAAAA,KAAa,EAAEE,WAAWV,EAAYU,WAAW,EAAA,EAAA,IAAAZ,WAAA;AAAA,SAE/EE,EAAYF;IAAQ,CAAA,CAAA;GAqBXa,KAAkDC,MAC9DV,EACEZ,GAAaa,EAAA;CAAA,IACbU,QAAK;AAAA,SAAED,EAAMC;;CAAK,IAClBC,iBAAc;AAAA,SAAEF,EAAME;;CAAc,QAC/BF,EAAMN,UAAUE,KAAAA,KAAa,EAAEF,OAAOM,EAAMN,OAAO,QACnDM,EAAMG,aAAaP,KAAAA,KAAa,EAAEO,UAAUH,EAAMG,UAAU,QAC5DH,EAAMI,YAAYR,KAAAA,KAAa,EAAEQ,SAASJ,EAAMI,SAAS,QACzDJ,EAAMK,kBAAkBT,KAAAA,KAAa,EAAES,eAAeL,EAAMK,eAAe,EAAA,EAAA,IAAAnB,WAAA;AAAA,QAAAI,EAE/EL,GAAYM,QACPS,EAAML,wBAAwBC,KAAAA,KAAa,EAC/CD,qBAAqBK,EAAML,qBAC3B,QACIK,EAAMH,aAAaD,KAAAA,KAAa,EAAEC,UAAUG,EAAMH,UAAU,QAC5DG,EAAMF,cAAcF,KAAAA,KAAa,EAAEE,WAAWE,EAAMF,WAAW,EAAA,EAAA,IAAAZ,WAAA;AAAA,SAEnEc,EAAMd;IAAQ,CAAA,CAAA;GAAA,CAAA,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,6 @@
1
- import { PlayRenderer as e } from "./PlayRenderer.js";
2
- export { e as PlayRenderer };
1
+ import { ActorContext as e, useActor as t } from "./useActor.js";
2
+ import { ActorProvider as n, usePlayView as r } from "./ActorProvider.js";
3
+ import { PlayRenderer as i } from "./PlayRenderer.js";
4
+ import { PlayUIProvider as a } from "./PlayUIProvider.js";
5
+ import { ActionProvider as o, JSONUIProvider as s, Renderer as c, StateProvider as l, ValidationProvider as u, VisibilityProvider as d, defineRegistry as f, useAction as p, useActions as m, useBoundProp as h, useFieldValidation as g, useIsVisible as _, useOptionalValidation as v, useStateBinding as y, useStateStore as b, useStateValue as x, useVisibility as S } from "@json-render/solid";
6
+ export { o as ActionProvider, e as ActorContext, n as ActorProvider, s as JSONUIProvider, i as PlayRenderer, a as PlayUIProvider, c as Renderer, l as StateProvider, u as ValidationProvider, d as VisibilityProvider, f as defineRegistry, p as useAction, m as useActions, t as useActor, h as useBoundProp, g as useFieldValidation, _ as useIsVisible, v as useOptionalValidation, r as usePlayView, y as useStateBinding, b as useStateStore, x as useStateValue, S as useVisibility };
@@ -0,0 +1,11 @@
1
+ import { createContext as e, useContext as t } from "solid-js";
2
+ import { assertNonNullable as n } from "@xmachines/play";
3
+ //#region src/useActor.ts
4
+ var r = e(null);
5
+ function i() {
6
+ return n(t(r), "ActorContext");
7
+ }
8
+ //#endregion
9
+ export { r as ActorContext, i as useActor };
10
+
11
+ //# sourceMappingURL=useActor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActor.js","names":[],"sources":["../src/useActor.ts"],"sourcesContent":["/**\n * useActor — SolidJS hook for accessing the raw actor inside an ActorProvider tree.\n *\n * Components rendered inside ActorProvider (or PlayUIProvider) can call useActor()\n * to get direct access to the actor instance without prop drilling.\n *\n * @throws {Error} If called outside an ActorProvider tree\n *\n * @example\n * ```typescript\n * import { useActor } from \"@xmachines/play-solid\";\n *\n * function MyComponent() {\n * const actor = useActor();\n * return <button onClick={() => actor.send({ type: \"SUBMIT\" })}>Submit</button>;\n * }\n * ```\n *\n * @packageDocumentation\n */\n\nimport { createContext, useContext } from \"solid-js\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport type { AbstractActor } from \"@xmachines/play-actor\";\nimport type { AnyActorLogic } from \"xstate\";\n\nexport type PlayActor = AbstractActor<AnyActorLogic>;\n\n/**\n * SolidJS context for the actor — exported so consumers can use ActorContext.Provider\n * directly as an escape hatch (per D-11). The smart ActorProvider component takes\n * the name \"ActorProvider\" and is the recommended entry point.\n */\nexport const ActorContext = createContext<PlayActor | null>(null);\n\nexport function useActor(): PlayActor {\n\treturn assertNonNullable(useContext(ActorContext), \"ActorContext\");\n}\n"],"mappings":";;;AAiCA,IAAa,IAAe,EAAgC,KAAK;AAEjE,SAAgB,IAAsB;AACrC,QAAO,EAAkB,EAAW,EAAa,EAAE,eAAe"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xmachines/play-solid",
3
- "version": "1.0.0-beta.5",
4
- "description": "SolidJS renderer for XMachines Play architecture",
3
+ "version": "1.0.0-beta.50",
4
+ "description": "Solid renderer for XMachines Play architecture",
5
5
  "keywords": [
6
6
  "catalog",
7
7
  "play",
@@ -20,6 +20,7 @@
20
20
  "type": "module",
21
21
  "exports": {
22
22
  ".": {
23
+ "source": "./src/index.ts",
23
24
  "types": "./dist/index.d.ts",
24
25
  "default": "./dist/index.js"
25
26
  }
@@ -29,29 +30,44 @@
29
30
  },
30
31
  "scripts": {
31
32
  "build": "vite build && tsc --build",
32
- "clean": "rm -rf dist tsconfig.tsbuildinfo",
33
- "typecheck": "tsc --noEmit",
34
- "test": "vitest run",
33
+ "clean": "rm -rf dist *.tsbuildinfo coverage .vitest-attachments test/browser/__screenshots__ node_modules/.svelte2tsx-*",
34
+ "lint": "oxlint .",
35
+ "format": "oxfmt .",
36
+ "test": "vitest",
35
37
  "test:watch": "vitest",
36
38
  "test:ui": "vitest --ui",
37
39
  "prepublishOnly": "npm run build"
38
40
  },
39
41
  "dependencies": {
40
- "@xmachines/play-actor": "1.0.0-beta.5",
41
- "@xmachines/play-catalog": "1.0.0-beta.5",
42
- "@xmachines/play-signals": "1.0.0-beta.5"
42
+ "@xmachines/play": "1.0.0-beta.50",
43
+ "@xmachines/play-actor": "1.0.0-beta.50",
44
+ "@xmachines/play-signals": "1.0.0-beta.50"
43
45
  },
44
46
  "devDependencies": {
47
+ "@json-render/core": "^0.18.0",
48
+ "@json-render/solid": "^0.18.0",
49
+ "@json-render/xstate": "^0.18.0",
45
50
  "@solidjs/testing-library": "^0.8.10",
46
- "@types/node": "^25.5.0",
47
- "@xmachines/shared": "1.0.0-beta.5",
48
- "solid-js": "^1.9.11",
49
- "typescript": "^5.9.3",
50
- "vite": "^8.0.0",
51
+ "@testing-library/jest-dom": "^6.9.1",
52
+ "@types/node": "^25.6.0",
53
+ "@xmachines/shared": "1.0.0-beta.50",
54
+ "@xstate/store": "^3.17.0",
55
+ "jsdom": "^29.1.0",
56
+ "oxfmt": "^0.47.0",
57
+ "oxlint": "^1.62.0",
58
+ "solid-js": "^1.9.12",
59
+ "typescript": "^5.9.3 || ^6.0.3",
60
+ "vite": "^8.0.10",
51
61
  "vite-plugin-solid": "^2.11.11",
52
- "vitest": "^4.1.0"
62
+ "vitest": "^4.1.5",
63
+ "xstate": "^5.31.0"
53
64
  },
54
65
  "peerDependencies": {
55
- "solid-js": "^1.8.0 || ^1.9.0"
66
+ "@json-render/core": "^0.18.0",
67
+ "@json-render/solid": "^0.18.0",
68
+ "@json-render/xstate": "^0.18.0",
69
+ "@xstate/store": "^3.17.0",
70
+ "solid-js": "^1.8.0",
71
+ "xstate": "^5.31.0"
56
72
  }
57
73
  }
@@ -1,63 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * SolidJS renderer for XMachines Play architecture
3
- *
4
- * @packageDocumentation
5
- */
6
- export { PlayRenderer } from "./PlayRenderer.js";
7
- export type { PlayRendererProps } from "./types.js";
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
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"}