@xmachines/play-solid 1.1.0 → 2.0.0

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/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  > Solid renderer for XMachines Play architecture
4
4
 
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
- [![Version](https://img.shields.io/badge/version-1.1.0-blue)](https://www.npmjs.com/package/@xmachines/play-solid)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/badge/version-2.0.0-blue)](https://www.npmjs.com/package/@xmachines/play-solid)
7
6
 
8
7
  SolidJS rendering layer that passively observes actor signals and renders UI components via `@xmachines/json-render-solid`. SolidJS reactivity is used solely to trigger re-renders — TC39 Signals are the source of truth.
9
8
 
@@ -0,0 +1,156 @@
1
+ import { ActorContext } from "./useActor.js";
2
+ import { createComponent } from "solid-js/web";
3
+ import { StateProvider, useStateStore } from "@xmachines/json-render-solid";
4
+ import { ErrorBoundary, createContext, createEffect, createMemo, createSignal, onCleanup, useContext } from "solid-js";
5
+ import { createAtom } from "@xstate/store";
6
+ import { xstateStoreStateStore } from "@xmachines/json-render-xstate";
7
+ import { watchSignal } from "@xmachines/play-signals";
8
+ import { assertNonNullable } from "@xmachines/play";
9
+ import { attachRenderErrorHandler, createViewStoreLifecycle } from "@xmachines/play-actor";
10
+ //#region packages/play-solid/src/ActorProvider.tsx
11
+ /**
12
+ * ActorProvider — Smart SolidJS provider component for the XMachines Play actor lifecycle.
13
+ *
14
+ * Escape hatch primitive for library authors who need direct control. Most users should
15
+ * use PlayUIProvider (batteries-included composite) instead.
16
+ *
17
+ * This component:
18
+ * - Subscribes to actor.currentView signal via watchSignal (in component body per Phase 29)
19
+ * - Manages per-view StateStore lifecycle (controlled/uncontrolled)
20
+ * - Resolves action handlers via inner component pattern (inside StateProvider)
21
+ * - Injects onRenderError into registry if provided
22
+ * - Provides ActorContext (actor) and ViewContext (spec + handlers + registry) to children
23
+ * - Wraps render path in SolidJS ErrorBoundary
24
+ *
25
+ * Per D-11: The old `ActorProvider = ActorContext.Provider` alias is removed. This new smart
26
+ * component takes the name. Use `ActorContext.Provider` directly for escape-hatch access.
27
+ *
28
+ * @packageDocumentation
29
+ */
30
+ var ViewContext = createContext(null);
31
+ /**
32
+ * Hook to access the current view context inside an ActorProvider tree.
33
+ *
34
+ * @throws {Error} If called outside an ActorProvider (or PlayUIProvider) tree
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * import { usePlayView } from "@xmachines/play-solid";
39
+ *
40
+ * const MyRenderer: Component = () => {
41
+ * const view = usePlayView();
42
+ * return <Renderer spec={view.spec} registry={view.registry} />;
43
+ * };
44
+ * ```
45
+ */
46
+ function usePlayView() {
47
+ return assertNonNullable(useContext(ViewContext), "ViewContext");
48
+ }
49
+ /**
50
+ * Inner component that runs inside StateProvider so it can call useStateStore()
51
+ * to get live set/getSnapshot for handler resolution.
52
+ */
53
+ var ActorProviderInner = (innerProps) => {
54
+ const stateCtx = useStateStore();
55
+ const setStateAdapter = (updater) => {
56
+ const prev = stateCtx.getSnapshot();
57
+ stateCtx.update(updater(prev));
58
+ };
59
+ const handlers = innerProps.registryResult.handlers(() => setStateAdapter, () => stateCtx.getSnapshot());
60
+ const viewValue = {
61
+ spec: innerProps.spec,
62
+ handlers,
63
+ registry: innerProps.registryResult.registry,
64
+ store: innerProps.store
65
+ };
66
+ return createComponent(ViewContext.Provider, {
67
+ value: viewValue,
68
+ get children() {
69
+ return innerProps.children;
70
+ }
71
+ });
72
+ };
73
+ /**
74
+ * Smart ActorProvider component — owns actor bridging, signal subscription,
75
+ * StateStore lifecycle, handler resolution, and error boundary.
76
+ *
77
+ * Per D-11: Replaces the old raw alias `ActorProvider = ActorContext.Provider`.
78
+ * Consumers who previously used `<ActorProvider value={actor}>` should now use
79
+ * `<ActorContext.Provider value={actor}>` for raw provider access, or migrate to
80
+ * this smart component / PlayUIProvider.
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * import { ActorProvider, PlayRenderer } from "@xmachines/play-solid";
85
+ *
86
+ * <ActorProvider actor={myActor} registryResult={registryResult}>
87
+ * <PlayRenderer />
88
+ * </ActorProvider>
89
+ * ```
90
+ */
91
+ var ActorProvider = (props) => {
92
+ const [view, setView] = createSignal(null);
93
+ const actorProxy = new Proxy({}, {
94
+ get(_target, prop) {
95
+ const current = props.actor;
96
+ const value = Reflect.get(current, prop, current);
97
+ return typeof value === "function" ? value.bind(current) : value;
98
+ },
99
+ has(_target, prop) {
100
+ return prop in props.actor;
101
+ }
102
+ });
103
+ const resolvedRegistryResult = createMemo(() => {
104
+ if (!props.onRenderError) return props.registryResult;
105
+ return {
106
+ ...props.registryResult,
107
+ registry: attachRenderErrorHandler(props.registryResult.registry, props.onRenderError)
108
+ };
109
+ });
110
+ const storeLifecycle = createViewStoreLifecycle((seed) => xstateStoreStateStore({ atom: createAtom(seed) }));
111
+ createEffect(() => {
112
+ const update = (nextView) => setView(nextView);
113
+ update(props.actor.currentView.get());
114
+ const unwatch = watchSignal(props.actor.currentView, (nextView) => {
115
+ update(nextView);
116
+ });
117
+ onCleanup(() => unwatch());
118
+ });
119
+ return createComponent(ActorContext.Provider, {
120
+ value: actorProxy,
121
+ get children() {
122
+ return createComponent(ErrorBoundary, {
123
+ fallback: (err) => {
124
+ props.onError?.(err);
125
+ return props.fallback ?? null;
126
+ },
127
+ get children() {
128
+ return (() => {
129
+ const currentView = view();
130
+ if (!currentView) return props.fallback ?? null;
131
+ const store = storeLifecycle.resolve(props.actor, currentView, props.store).guardedStore;
132
+ return createComponent(StateProvider, {
133
+ store,
134
+ get children() {
135
+ return createComponent(ActorProviderInner, {
136
+ get registryResult() {
137
+ return resolvedRegistryResult();
138
+ },
139
+ spec: currentView,
140
+ store,
141
+ get children() {
142
+ return props.children;
143
+ }
144
+ });
145
+ }
146
+ });
147
+ })();
148
+ }
149
+ });
150
+ }
151
+ });
152
+ };
153
+ //#endregion
154
+ export { ActorProvider, usePlayView };
155
+
156
+ //# 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","attachRenderErrorHandler","createViewStoreLifecycle","PlaySpec","BaseActorProviderProps","BaseViewContextValue","ActorContext","AnyPlayActor","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","actorProxy","Proxy","get","_target","prop","current","actor","Reflect","bind","has","resolvedRegistryResult","onRenderError","storeLifecycle","seed","atom","nextView","currentView","unwatch","err","resolve","guardedStore"],"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 \"@xmachines/json-render-solid\";\nimport type { DefineRegistryResult, SetState } from \"@xmachines/json-render-solid\";\nimport type { StateStore } from \"@xmachines/json-render-core\";\nimport type { ComponentRegistry } from \"@xmachines/json-render-solid\";\nimport { createAtom } from \"@xstate/store\";\nimport { xstateStoreStateStore } from \"@xmachines/json-render-xstate\";\nimport { watchSignal } from \"@xmachines/play-signals\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport {\n\tattachRenderErrorHandler,\n\tcreateViewStoreLifecycle,\n\ttype PlaySpec,\n\ttype BaseActorProviderProps,\n\ttype BaseViewContextValue,\n} from \"@xmachines/play-actor\";\nimport { ActorContext, type AnyPlayActor } 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// A stable Proxy is provided as the ActorContext value instead of the raw\n\t// actor: Solid's Context.Provider reads `value` once at creation, so passing\n\t// `props.actor` directly would snapshot the FIRST actor and useActor()\n\t// consumers would never see a prop swap. With the proxy, consumers keep the\n\t// reference obtained at creation time, yet every property access (send,\n\t// currentView, …) resolves against the latest actor. Reading `props.actor`\n\t// inside the traps is a reactive read, so consumers accessing properties in\n\t// tracking scopes (createEffect, createMemo, JSX) re-run on swap. Methods\n\t// are bound to the current actor so `this` (including private fields) works\n\t// exactly as with a direct call. Mirrors play-vue's ActorProvider proxy.\n\tconst actorProxy = new Proxy({} as AnyPlayActor, {\n\t\tget(_target, prop) {\n\t\t\tconst current = props.actor as AnyPlayActor;\n\t\t\tconst value = Reflect.get(current, prop, current) as unknown;\n\t\t\treturn typeof value === \"function\" ? value.bind(current) : value;\n\t\t},\n\t\thas(_target, prop) {\n\t\t\treturn prop in (props.actor as AnyPlayActor);\n\t\t},\n\t});\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\treturn {\n\t\t\t...props.registryResult,\n\t\t\tregistry: attachRenderErrorHandler(props.registryResult.registry, props.onRenderError),\n\t\t};\n\t});\n\n\t// Store lifecycle (reseed on viewKey change, refresh /context in place\n\t// otherwise, actor-swap reset, guard identity cache) — the shared\n\t// coordinator from @xmachines/play-actor; only the reactivity wiring in the\n\t// tracked JSX scope below is Solid's.\n\tconst storeLifecycle = createViewStoreLifecycle((seed) =>\n\t\txstateStoreStateStore({ atom: createAtom(seed) }),\n\t);\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={actorProxy}>\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 the store (external/controlled or internal\n\t\t\t\t\t// per-viewKey) via the shared lifecycle; children get the\n\t\t\t\t\t// guarded store — /context is read-only to the spec. Reading\n\t\t\t\t\t// props.actor and props.store HERE keeps both tracked in this\n\t\t\t\t\t// scope, so swaps re-run the resolution.\n\t\t\t\t\tconst store: StateStore = storeLifecycle.resolve(\n\t\t\t\t\t\tprops.actor,\n\t\t\t\t\t\tcurrentView,\n\t\t\t\t\t\tprops.store,\n\t\t\t\t\t).guardedStore;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAM2B,cAAcvB,cAAuC,IAAI;;;;;;;;;;;;;;;;AAiB/D,SAAgBwB,cAAgC;CAC/C,OAAOV,kBAAkBb,WAAWsB,WAAW,GAAG,aAAa;AAChE;;;;;AA+BA,IAAMQ,sBAKAI,eAAe;CACpB,MAAMC,WAAW9B,cAAc;CAG/B,MAAM+B,mBAA6BC,YAAY;EAC9C,MAAMC,OAAOH,SAASI,YAAY;EAClCJ,SAASK,OAAOH,QAAQC,IAAI,CAAC;CAC9B;CAEA,MAAMG,WAAWP,WAAWH,eAAeU,eACpCL,uBACAD,SAASI,YAAY,CAC5B;CAEA,MAAMG,YAA8B;EACnCV,MAAME,WAAWF;EACjBS;EACAE,UAAUT,WAAWH,eAAeY;EACpCV,OAAOC,WAAWD;CACnB;CAEA,OAAAW,gBAAQtB,YAAYuB,UAAQ;EAACC,OAAOJ;EAAS,IAAAb,WAAA;GAAA,OAAGK,WAAWL;EAAQ;CAAA,CAAA;AACpE;;;;;;;;;;;;;;;;;;;AAwBA,IAAakB,iBAAgDC,UAAU;CAEtE,MAAM,CAACC,MAAMC,WAAWvD,aAA8B,IAAI;CAY1D,MAAMwD,aAAa,IAAIC,MAAM,CAAC,GAAmB;EAChDC,IAAIC,SAASC,MAAM;GAClB,MAAMC,UAAUR,MAAMS;GACtB,MAAMX,QAAQY,QAAQL,IAAIG,SAASD,MAAMC,OAAO;GAChD,OAAO,OAAOV,UAAU,aAAaA,MAAMa,KAAKH,OAAO,IAAIV;EAC5D;EACAc,IAAIN,SAASC,MAAM;GAClB,OAAOA,QAASP,MAAMS;EACvB;CACD,CAAC;CAKD,MAAMI,yBAAyBhE,iBAAiB;EAC/C,IAAI,CAACmD,MAAMc,eAAe,OAAOd,MAAMjB;EACvC,OAAO;GACN,GAAGiB,MAAMjB;GACTY,UAAU7B,yBAAyBkC,MAAMjB,eAAeY,UAAUK,MAAMc,aAAa;EACtF;CACD,CAAC;CAMD,MAAMC,iBAAiBhD,0BAA0BiD,SAChDrD,sBAAsB,EAAEsD,MAAMvD,WAAWsD,IAAI,EAAE,CAAC,CACjD;CAMApE,mBAAmB;EAClB,MAAM4C,UAAU0B,aAA8BhB,QAAQgB,QAAQ;EAC9D1B,OAAOQ,MAAMS,MAAMU,YAAYd,IAAI,CAAoB;EACvD,MAAMe,UAAUxD,YAAYoC,MAAMS,MAAMU,cAAcD,aAAa;GAClE1B,OAAO0B,QAA2B;EACnC,CAAC;EACDpE,gBAAgBsE,QAAQ,CAAC;CAC1B,CAAC;CAED,OAAAxB,gBACEzB,aAAa0B,UAAQ;EAACC,OAAOK;EAAU,IAAAtB,WAAA;GAAA,OAAAe,gBACtC3C,eAAa;IACbwB,WAAW4C,QAAiB;KAC3BrB,MAAMrB,UAAU0C,GAAG;KACnB,OAAOrB,MAAMvB,YAAY;IAC1B;IAAC,IAAAI,WAAA;KAAA,cAEO;MACP,MAAMsC,cAAclB,KAAK;MACzB,IAAI,CAACkB,aAAa,OAAOnB,MAAMvB,YAAY;MAO3C,MAAMQ,QAAoB8B,eAAeO,QACxCtB,MAAMS,OACNU,aACAnB,MAAMf,KACP,CAAC,CAACsC;MAEF,OAAA3B,gBACExC,eAAa;OAAQ6B;OAAK,IAAAJ,WAAA;QAAA,OAAAe,gBACzBd,oBAAkB;SAAA,IAClBC,iBAAc;UAAA,OAAE8B,uBAAuB;SAAC;SACxC7B,MAAMmC;SACClC;SAAK,IAAAJ,WAAA;UAAA,OAEXmB,MAAMnB;SAAQ;QAAA,CAAA;OAAA;MAAA,CAAA;KAInB,EAAA,CAAG;IAAC;GAAA,CAAA;EAAA;CAAA,CAAA;AAIR"}
@@ -0,0 +1,25 @@
1
+ import { usePlayView } from "./ActorProvider.js";
2
+ import { createComponent } from "solid-js/web";
3
+ import { Renderer } from "@xmachines/json-render-solid";
4
+ //#region packages/play-solid/src/PlayRenderer.tsx
5
+ /**
6
+ * Zero-prop leaf renderer. Must be placed inside an ActorProvider or PlayUIProvider tree.
7
+ *
8
+ * Reads ViewContextValue (spec, handlers, registry) from the enclosing provider
9
+ * via usePlayView() and renders the spec via @xmachines/json-render-solid's Renderer.
10
+ */
11
+ var PlayRenderer = () => {
12
+ const view = usePlayView();
13
+ return createComponent(Renderer, {
14
+ get spec() {
15
+ return view.spec;
16
+ },
17
+ get registry() {
18
+ return view.registry;
19
+ }
20
+ });
21
+ };
22
+ //#endregion
23
+ export { PlayRenderer };
24
+
25
+ //# sourceMappingURL=PlayRenderer.js.map
@@ -0,0 +1 @@
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 @xmachines/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 \"@xmachines/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 @xmachines/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,qBAAgC;CAC5C,MAAMC,OAAOF,YAAY;CACzB,OAAAG,gBAAQJ,UAAQ;EAAA,IAACK,OAAI;GAAA,OAAEF,KAAKE;EAAI;EAAA,IAAEC,WAAQ;GAAA,OAAEH,KAAKG;EAAQ;CAAA,CAAA;AAC1D"}
@@ -0,0 +1,61 @@
1
+ import { ActorProvider, usePlayView } from "./ActorProvider.js";
2
+ import { createComponent, mergeProps } from "solid-js/web";
3
+ import { JSONUIProvider } from "@xmachines/json-render-solid";
4
+ //#region packages/play-solid/src/PlayUIProvider.tsx
5
+ /**
6
+ * Inner bridge component — must be inside ActorProvider's tree so usePlayView() has
7
+ * access to the resolved ViewContextValue. Reads handlers and registry from the view
8
+ * context and passes them to JSONUIProvider.
9
+ *
10
+ * This bridge pattern mirrors the React implementation (JSONUIBridge in play-react).
11
+ */
12
+ var JSONUIBridge = (bridgeProps) => {
13
+ const view = usePlayView();
14
+ return createComponent(JSONUIProvider, mergeProps({
15
+ get registry() {
16
+ return view.registry;
17
+ },
18
+ get handlers() {
19
+ return view.handlers;
20
+ },
21
+ get store() {
22
+ return view.store;
23
+ }
24
+ }, () => bridgeProps.validationFunctions !== void 0 && { validationFunctions: bridgeProps.validationFunctions }, () => bridgeProps.navigate !== void 0 && { navigate: bridgeProps.navigate }, () => bridgeProps.functions !== void 0 && { functions: bridgeProps.functions }, { get children() {
25
+ return bridgeProps.children;
26
+ } }));
27
+ };
28
+ /**
29
+ * Batteries-included composite provider: ActorProvider + JSONUIProvider.
30
+ *
31
+ * Provides the full JSON render context stack:
32
+ * - ActorContext (actor instance via ActorProvider)
33
+ * - ViewContext (spec, handlers, registry via ActorProvider)
34
+ * - StateProvider + ActionProvider + VisibilityProvider + ValidationProvider (via JSONUIProvider)
35
+ * - ConfirmDialogManager (via JSONUIProvider)
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * <PlayUIProvider actor={myActor} registryResult={registryResult} navigate={navigate}>
40
+ * <PlayRenderer />
41
+ * </PlayUIProvider>
42
+ * ```
43
+ */
44
+ var PlayUIProvider = (props) => {
45
+ return createComponent(ActorProvider, mergeProps({
46
+ get actor() {
47
+ return props.actor;
48
+ },
49
+ get registryResult() {
50
+ return props.registryResult;
51
+ }
52
+ }, () => props.store !== void 0 && { store: props.store }, () => props.fallback !== void 0 && { fallback: props.fallback }, () => props.onError !== void 0 && { onError: props.onError }, () => props.onRenderError !== void 0 && { onRenderError: props.onRenderError }, { get children() {
53
+ return createComponent(JSONUIBridge, mergeProps(() => props.validationFunctions !== void 0 && { validationFunctions: props.validationFunctions }, () => props.navigate !== void 0 && { navigate: props.navigate }, () => props.functions !== void 0 && { functions: props.functions }, { get children() {
54
+ return props.children;
55
+ } }));
56
+ } }));
57
+ };
58
+ //#endregion
59
+ export { PlayUIProvider };
60
+
61
+ //# 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 \"@xmachines/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,gBACLG,gBACI;CACJ,MAAMC,OAAOV,YAAY;CAEzB,OAAAW,gBACEd,gBAAce,WAAA;EAAA,IACdC,WAAQ;GAAA,OAAEH,KAAKG;EAAQ;EAAA,IACvBC,WAAQ;GAAA,OAAEJ,KAAKI;EAAQ;EAAA,IACvBC,QAAK;GAAA,OAAEL,KAAKK;EAAK;CAAA,SACZN,YAAYO,wBAAwBC,KAAAA,KAAa,EACrDD,qBAAqBP,YAAYO,oBAClC,SACKP,YAAYS,aAAaD,KAAAA,KAAa,EAAEC,UAAUT,YAAYS,SAAS,SACvET,YAAYU,cAAcF,KAAAA,KAAa,EAAEE,WAAWV,YAAYU,UAAU,GAAC,EAAA,IAAAZ,WAAA;EAAA,OAE/EE,YAAYF;CAAQ,EAAA,CAAA,CAAA;AAGxB;;;;;;;;;;;;;;;;;AAkBA,IAAaa,kBAAkDC,UAAU;CACxE,OAAAV,gBACEZ,eAAaa,WAAA;EAAA,IACbU,QAAK;GAAA,OAAED,MAAMC;EAAK;EAAA,IAClBC,iBAAc;GAAA,OAAEF,MAAME;EAAc;CAAA,SAC/BF,MAAMN,UAAUE,KAAAA,KAAa,EAAEF,OAAOM,MAAMN,MAAM,SAClDM,MAAMG,aAAaP,KAAAA,KAAa,EAAEO,UAAUH,MAAMG,SAAS,SAC3DH,MAAMI,YAAYR,KAAAA,KAAa,EAAEQ,SAASJ,MAAMI,QAAQ,SACxDJ,MAAMK,kBAAkBT,KAAAA,KAAa,EAAES,eAAeL,MAAMK,cAAc,GAAC,EAAA,IAAAnB,WAAA;EAAA,OAAAI,gBAE/EL,cAAYM,iBACPS,MAAML,wBAAwBC,KAAAA,KAAa,EAC/CD,qBAAqBK,MAAML,oBAC5B,SACKK,MAAMH,aAAaD,KAAAA,KAAa,EAAEC,UAAUG,MAAMH,SAAS,SAC3DG,MAAMF,cAAcF,KAAAA,KAAa,EAAEE,WAAWE,MAAMF,UAAU,GAAC,EAAA,IAAAZ,WAAA;GAAA,OAEnEc,MAAMd;EAAQ,EAAA,CAAA,CAAA;CAAA,EAAA,CAAA,CAAA;AAInB"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { ActorContext, useActor } from "./useActor.js";
2
+ import { ActorProvider, usePlayView } from "./ActorProvider.js";
3
+ import { PlayRenderer } from "./PlayRenderer.js";
4
+ import { PlayUIProvider } from "./PlayUIProvider.js";
5
+ import { ActionProvider, JSONUIProvider, Renderer, StateProvider, ValidationProvider, VisibilityProvider, defineRegistry, useAction, useActions, useBoundProp, useFieldValidation, useIsVisible, useOptionalValidation, useStateBinding, useStateStore, useStateValue, useVisibility } from "@xmachines/json-render-solid";
6
+ export { ActionProvider, ActorContext, ActorProvider, JSONUIProvider, PlayRenderer, PlayUIProvider, Renderer, StateProvider, ValidationProvider, VisibilityProvider, defineRegistry, useAction, useActions, useActor, useBoundProp, useFieldValidation, useIsVisible, useOptionalValidation, usePlayView, useStateBinding, useStateStore, useStateValue, useVisibility };
@@ -0,0 +1,36 @@
1
+ import { createContext, useContext } from "solid-js";
2
+ import { assertNonNullable } from "@xmachines/play";
3
+ //#region packages/play-solid/src/useActor.ts
4
+ /**
5
+ * useActor — SolidJS hook for accessing the raw actor inside an ActorProvider tree.
6
+ *
7
+ * Components rendered inside ActorProvider (or PlayUIProvider) can call useActor()
8
+ * to get direct access to the actor instance without prop drilling.
9
+ *
10
+ * @throws {Error} If called outside an ActorProvider tree
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { useActor } from "@xmachines/play-solid";
15
+ *
16
+ * function MyComponent() {
17
+ * const actor = useActor();
18
+ * return <button onClick={() => actor.send({ type: "SUBMIT" })}>Submit</button>;
19
+ * }
20
+ * ```
21
+ *
22
+ * @packageDocumentation
23
+ */
24
+ /**
25
+ * SolidJS context for the actor — exported so consumers can use ActorContext.Provider
26
+ * directly as an escape hatch (per D-11). The smart ActorProvider component takes
27
+ * the name "ActorProvider" and is the recommended entry point.
28
+ */
29
+ var ActorContext = createContext(null);
30
+ function useActor() {
31
+ return assertNonNullable(useContext(ActorContext), "ActorContext");
32
+ }
33
+ //#endregion
34
+ export { ActorContext, useActor };
35
+
36
+ //# 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\n/** Bare actor type accepted by Solid context providers. For the full routing + view shape, use `PlayActor` from `@xmachines/play-router`. */\nexport type AnyPlayActor = 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<AnyPlayActor | null>(null);\n\nexport function useActor(): AnyPlayActor {\n\treturn assertNonNullable(useContext(ActorContext), \"ActorContext\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,eAAe,cAAmC,IAAI;AAEnE,SAAgB,WAAyB;CACxC,OAAO,kBAAkB,WAAW,YAAY,GAAG,cAAc;AAClE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmachines/play-solid",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Solid renderer for XMachines Play architecture",
5
5
  "keywords": [
6
6
  "catalog",
@@ -14,7 +14,7 @@
14
14
  "author": "XMachines Contributors",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+ssh://git@gitlab.com/xmachin-es/xmachines-js.git",
17
+ "url": "git+https://gitlab.com/xmachin-es/xmachines-js.git",
18
18
  "directory": "packages/play-solid"
19
19
  },
20
20
  "files": [
@@ -24,11 +24,14 @@
24
24
  ],
25
25
  "type": "module",
26
26
  "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
27
29
  "exports": {
28
30
  ".": {
29
31
  "types": "./dist/index.d.ts",
30
32
  "default": "./dist/index.js"
31
- }
33
+ },
34
+ "./package.json": "./package.json"
32
35
  },
33
36
  "publishConfig": {
34
37
  "access": "public"
@@ -43,18 +46,18 @@
43
46
  "test:ui": "vitest --ui"
44
47
  },
45
48
  "dependencies": {
46
- "@xmachines/play": "1.1.0",
47
- "@xmachines/play-actor": "1.1.0",
48
- "@xmachines/play-signals": "1.1.0"
49
+ "@xmachines/play": "2.0.0",
50
+ "@xmachines/play-actor": "2.0.0",
51
+ "@xmachines/play-signals": "2.0.0"
49
52
  },
50
53
  "devDependencies": {
51
54
  "@solidjs/testing-library": "^0.8.10",
52
55
  "@testing-library/jest-dom": "^6.9.1",
53
56
  "@types/node": "^26.2.0",
54
- "@vitest/browser-playwright": "^4.1.10",
55
- "@xmachines/json-render-core": "^0.19.0-xm.2",
56
- "@xmachines/json-render-solid": "^0.19.0-xm.2",
57
- "@xmachines/json-render-xstate": "^0.19.0-xm.2",
57
+ "@vitest/browser-playwright": "^4.1.11",
58
+ "@xmachines/json-render-core": "^0.20.0-xm.2",
59
+ "@xmachines/json-render-solid": "^0.20.0-xm.2",
60
+ "@xmachines/json-render-xstate": "^0.20.0-xm.2",
58
61
  "@xstate/store": "^3.17.0",
59
62
  "jsdom": "^29.1.0",
60
63
  "oxfmt": "^0.64.0",
@@ -68,9 +71,9 @@
68
71
  "zod": "^4.4.1"
69
72
  },
70
73
  "peerDependencies": {
71
- "@xmachines/json-render-core": "^0.19.0-xm.2",
72
- "@xmachines/json-render-solid": "^0.19.0-xm.2",
73
- "@xmachines/json-render-xstate": "^0.19.0-xm.2",
74
+ "@xmachines/json-render-core": "^0.20.0-xm.2",
75
+ "@xmachines/json-render-solid": "^0.20.0-xm.2",
76
+ "@xmachines/json-render-xstate": "^0.20.0-xm.2",
74
77
  "@xstate/store": "^3.17.0",
75
78
  "solid-js": "^1.8.0",
76
79
  "xstate": "^5.31.0"