@xmachines/play-dom 1.0.0-beta.33 → 1.0.0-beta.35
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 +87 -17
- package/dist/PlayRenderer.d.ts +1 -1
- package/dist/PlayRenderer.d.ts.map +1 -1
- package/dist/PlayRenderer.js +16 -8
- package/dist/PlayRenderer.js.map +1 -1
- package/dist/connect-renderer.d.ts +1 -1
- package/dist/connect-renderer.d.ts.map +1 -1
- package/dist/create-play-ui.d.ts +56 -0
- package/dist/create-play-ui.d.ts.map +1 -0
- package/dist/create-play-ui.js +77 -0
- package/dist/create-play-ui.js.map +1 -0
- package/dist/create-renderer.d.ts +1 -1
- package/dist/create-renderer.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/json-render/index.d.ts +1 -1
- package/dist/json-render/index.d.ts.map +1 -1
- package/dist/json-render/types.d.ts +33 -23
- package/dist/json-render/types.d.ts.map +1 -1
- package/dist/json-render/types.js +4 -5
- package/dist/json-render/types.js.map +1 -1
- package/dist/{xm-types.d.ts → types.d.ts} +28 -4
- package/dist/types.d.ts.map +1 -0
- package/dist/{xm-types.js → types.js} +2 -2
- package/dist/types.js.map +1 -0
- package/package.json +5 -5
- package/dist/xm-types.d.ts.map +0 -1
- package/dist/xm-types.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,24 +12,95 @@ npm install @xmachines/play-dom @json-render/core zod
|
|
|
12
12
|
|
|
13
13
|
## Key Exports
|
|
14
14
|
|
|
15
|
-
| Export | Description
|
|
16
|
-
| --------------------------------------------------- |
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
15
|
+
| Export | Description |
|
|
16
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| `createPlayUI(registryResult, options?)` | Batteries-included factory: returns `mount(actor, container) → disconnect` — parallel to `PlayUIProvider` in framework packages |
|
|
18
|
+
| `createRenderer(catalog, componentMap)` | One-call factory: returns `mount(actor, container, options?) → disconnect` |
|
|
19
|
+
| `connectRenderer(options)` | Functional API: connect actor → DOM with full options |
|
|
20
|
+
| `defineRegistry(catalog, { components, actions })` | Build a catalog-typed `DomRegistry` with typed action handlers |
|
|
21
|
+
| `UIProviderOptions` | Standard options interface: `validationFunctions`, `navigate`, `functions`, `onRenderError`, `fallback` |
|
|
22
|
+
| `PlayRenderer` | Class-based renderer — `connect()` / `disconnect()` lifecycle |
|
|
23
|
+
| `schema` | DOM schema for `defineCatalog` (mirrors `@json-render/react/schema`) |
|
|
24
|
+
| `ComponentFn<C, K>` | Catalog-typed DOM component function type |
|
|
25
|
+
| `ComponentContext<C, K>` | Context passed to each `ComponentFn` — `props`, `on`, `emit`, `children`, `bindings`, `ctx` |
|
|
26
|
+
| `ActionFn<C, K>` | `(params, setState, state) => Promise<void>` — catalog-typed action handler |
|
|
27
|
+
| `SetState` | `(updater: prev => next) => void` — write to the local state store |
|
|
28
|
+
| `BaseComponentProps<P>` | Base type for catalog component prop definitions |
|
|
29
|
+
| `CatalogHasActions<C>` | Conditional type: `true` when catalog declares actions |
|
|
30
|
+
| `renderSpec(spec, store, registry, send, handlers)` | Pure Spec → DOM renderer (advanced use) |
|
|
31
|
+
|
|
32
|
+
## Quick Start — `createPlayUI`
|
|
33
|
+
|
|
34
|
+
The standard entry point — mirrors `PlayUIProvider` in framework packages. Pass a `registryResult` (from `defineRegistry`) plus optional `UIProviderOptions`, and get back a `mount` function:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { defineRegistry, createPlayUI, schema } from "@xmachines/play-dom";
|
|
38
|
+
import { defineCatalog } from "@json-render/core";
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
import type { ComponentFn } from "@xmachines/play-dom";
|
|
41
|
+
|
|
42
|
+
// 1. Define catalog
|
|
43
|
+
const catalog = defineCatalog(schema, {
|
|
44
|
+
components: {
|
|
45
|
+
Home: { props: z.object({ title: z.string() }) },
|
|
46
|
+
Login: { props: z.object({ title: z.string(), username: z.string().optional() }) },
|
|
47
|
+
},
|
|
48
|
+
actions: {
|
|
49
|
+
login: { params: z.object({ username: z.string() }) },
|
|
50
|
+
logout: {},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// 2. Build registry with typed action handlers
|
|
55
|
+
const registryResult = defineRegistry(catalog, {
|
|
56
|
+
components: {
|
|
57
|
+
Home: ({ props }) => {
|
|
58
|
+
const el = document.createElement("section");
|
|
59
|
+
el.textContent = props.title;
|
|
60
|
+
return el;
|
|
61
|
+
},
|
|
62
|
+
Login: ({ props, on }) => {
|
|
63
|
+
const section = document.createElement("section");
|
|
64
|
+
const button = document.createElement("button");
|
|
65
|
+
button.textContent = "Log In";
|
|
66
|
+
const submit = on("submit");
|
|
67
|
+
button.addEventListener("click", () => submit.emit());
|
|
68
|
+
section.append(button);
|
|
69
|
+
return section;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
actions: {
|
|
73
|
+
login: async (params) => {
|
|
74
|
+
if (!params) return;
|
|
75
|
+
actor.send({ type: "auth.login", username: params.username });
|
|
76
|
+
},
|
|
77
|
+
logout: async () => actor.send({ type: "auth.logout" }),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// 3. Create the UI factory (once, at module level)
|
|
82
|
+
const ui = createPlayUI(registryResult, {
|
|
83
|
+
onRenderError: (error, elementType) => console.warn(`<${elementType}> crashed:`, error),
|
|
84
|
+
fallback: (() => {
|
|
85
|
+
const el = document.createElement("p");
|
|
86
|
+
el.textContent = "Loading…";
|
|
87
|
+
return el;
|
|
88
|
+
})(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// 4. Mount when actor and container are ready
|
|
92
|
+
const actor = createPlayer()();
|
|
93
|
+
actor.start();
|
|
94
|
+
|
|
95
|
+
const disconnect = ui.mount(actor, document.getElementById("app")!);
|
|
96
|
+
|
|
97
|
+
// Cleanup:
|
|
98
|
+
disconnect();
|
|
99
|
+
```
|
|
29
100
|
|
|
30
101
|
## Quick Start — `createRenderer`
|
|
31
102
|
|
|
32
|
-
The
|
|
103
|
+
The lower-level one-call pattern — takes a catalog and component map directly:
|
|
33
104
|
|
|
34
105
|
```typescript
|
|
35
106
|
import { createRenderer, schema } from "@xmachines/play-dom";
|
|
@@ -252,6 +323,5 @@ renderer.disconnect(); // stops watching, clears container
|
|
|
252
323
|
|
|
253
324
|
## Learn More
|
|
254
325
|
|
|
255
|
-
- [DOM Router adapter `@xmachines/play-dom-router`](../play-dom-router
|
|
256
|
-
- [API reference](../../packages/docs/api/@xmachines/play-dom/README.md)
|
|
326
|
+
- [DOM Router adapter `@xmachines/play-dom-router`](../play-dom-router)
|
|
257
327
|
- [Play RFC](../../packages/docs/rfc/play.md)
|
package/dist/PlayRenderer.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type { AbstractActor, Viewable } from "@xmachines/play-actor";
|
|
12
12
|
import type { AnyActorLogic } from "xstate";
|
|
13
13
|
import type { DomRegistry } from "./json-render/types.js";
|
|
14
|
-
import type { PlayDomOptions } from "./
|
|
14
|
+
import type { PlayDomOptions } from "./types.js";
|
|
15
15
|
/**
|
|
16
16
|
* PlayRenderer connects an actor's `currentView` signal to the DOM renderer.
|
|
17
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayRenderer.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"PlayRenderer.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAY,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,YAAY;IAwBvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IA1BzB,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,cAAc,CAAsB;IAC5C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAQ;IAEtB;;;;;;;;;OASG;gBAEe,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,EAC9C,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,cAAmB;IAG9C;;;;;;;;OAQG;IACH,OAAO,IAAI,IAAI;IAMf;;OAEG;IACH,UAAU,IAAI,IAAI;IAmBlB,OAAO,CAAC,OAAO;CAkGf"}
|
package/dist/PlayRenderer.js
CHANGED
|
@@ -15,7 +15,7 @@ import { renderSpec } from "./json-render/renderer.js";
|
|
|
15
15
|
/**
|
|
16
16
|
* Safely coerce a spec's `state` field to a plain object for `createAtom`.
|
|
17
17
|
*
|
|
18
|
-
* `spec.state` is typed as `unknown` in `
|
|
18
|
+
* `spec.state` is typed as `unknown` in `PlaySpec`. At runtime it can be
|
|
19
19
|
* `null`, `undefined`, a primitive, or a plain object depending on what the
|
|
20
20
|
* machine author put in the view spec. `createAtom` requires a plain object as
|
|
21
21
|
* its initial value — anything else produces a broken store at runtime.
|
|
@@ -137,13 +137,14 @@ export class PlayRenderer {
|
|
|
137
137
|
this.container.replaceChildren();
|
|
138
138
|
}
|
|
139
139
|
_render(view) {
|
|
140
|
-
// Reset alive before releasing old subscriptions — any synchronous callback
|
|
141
|
-
// from the old store's unsubscribe sees alive=true and will be accepted.
|
|
142
|
-
// This differs from disconnect() which sets alive=false BEFORE calling storeUnsub.
|
|
143
140
|
this._alive = true;
|
|
144
|
-
//
|
|
145
|
-
|
|
141
|
+
// Capture and clear before calling — prevents the synchronous callback fired
|
|
142
|
+
// by some store implementations during unsubscribe from seeing a live
|
|
143
|
+
// _storeUnsubscribe and re-entering the rerender path with stale view/store.
|
|
144
|
+
// Mirrors the capture-then-clear pattern used in disconnect().
|
|
145
|
+
const oldUnsub = this._storeUnsubscribe;
|
|
146
146
|
this._storeUnsubscribe = null;
|
|
147
|
+
oldUnsub?.();
|
|
147
148
|
// Release watch cleanups from the previous view's initial render.
|
|
148
149
|
// Without this, watch subscriptions from the prior view remain active
|
|
149
150
|
// between a view transition and the first store update in the new view,
|
|
@@ -162,7 +163,7 @@ export class PlayRenderer {
|
|
|
162
163
|
const store = this.options.store
|
|
163
164
|
? this.options.store
|
|
164
165
|
: xstateStoreStateStore({
|
|
165
|
-
atom: createAtom(toAtomState(view.
|
|
166
|
+
atom: createAtom(toAtomState(view.state)),
|
|
166
167
|
});
|
|
167
168
|
const send = this.actor.send.bind(this.actor);
|
|
168
169
|
// Build a SetState function backed by the xstate store.
|
|
@@ -178,6 +179,13 @@ export class PlayRenderer {
|
|
|
178
179
|
// patch unless the StateStore contract is updated to match.
|
|
179
180
|
store.update(next);
|
|
180
181
|
};
|
|
182
|
+
// Warn when both registryResult and handlers are provided — handlers is silently ignored.
|
|
183
|
+
// This prevents silent data loss during migration from the legacy pattern.
|
|
184
|
+
if (this.options.registryResult && this.options.handlers) {
|
|
185
|
+
console.warn("[play-dom] Both registryResult and handlers were provided. " +
|
|
186
|
+
"handlers is ignored when registryResult is present. " +
|
|
187
|
+
"Remove the handlers option to silence this warning.");
|
|
188
|
+
}
|
|
181
189
|
// Resolve handlers: prefer registryResult (wires setState/getState from store),
|
|
182
190
|
// fall back to pre-resolved handlers map for backward compatibility.
|
|
183
191
|
const handlers = this.options.registryResult
|
|
@@ -195,7 +203,7 @@ export class PlayRenderer {
|
|
|
195
203
|
cleanup();
|
|
196
204
|
this._watchCleanups = [];
|
|
197
205
|
this.container.replaceChildren();
|
|
198
|
-
const node = renderSpec(view
|
|
206
|
+
const node = renderSpec(view, store, this.registry, send, handlers, undefined, undefined, undefined, loading, (cleanup) => {
|
|
199
207
|
this._watchCleanups.push(cleanup);
|
|
200
208
|
});
|
|
201
209
|
if (node)
|
package/dist/PlayRenderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayRenderer.js","sourceRoot":"","sources":["../src/PlayRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD;;;;;;;;;;;;GAYG;AACH,SAAS,WAAW,CAAC,KAAc;IAClC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAY,CAAC;QACtD,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAClD,OAAO,KAAgC,CAAC;QACzC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,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC;QAEF,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnD,QAAQ,EAAE,CAAC;IACZ,CAAC;CACD"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* The implementation delegates entirely to PlayRenderer.
|
|
8
8
|
*/
|
|
9
|
-
import type { ConnectRendererOptions } from "./
|
|
9
|
+
import type { ConnectRendererOptions } from "./types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Connect a signal-driven DOM renderer to an actor's `currentView` signal.
|
|
12
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-renderer.d.ts","sourceRoot":"","sources":["../src/connect-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAkB,MAAM,
|
|
1
|
+
{"version":3,"file":"connect-renderer.d.ts","sourceRoot":"","sources":["../src/connect-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAkB,MAAM,YAAY,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,IAAI,CA+B3E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createPlayUI — batteries-included DOM factory.
|
|
3
|
+
*
|
|
4
|
+
* Takes a DefineRegistryResult (user calls defineRegistry themselves) and returns
|
|
5
|
+
* a mount function. Calling mount(actor, container) starts the renderer and returns
|
|
6
|
+
* a disconnect function for cleanup.
|
|
7
|
+
*
|
|
8
|
+
* Parallel to <PlayUIProvider registryResult={...}> in framework renderers.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { defineRegistry, createPlayUI } from "@xmachines/play-dom";
|
|
13
|
+
*
|
|
14
|
+
* const registryResult = defineRegistry(catalog, { components, actions });
|
|
15
|
+
* const mount = createPlayUI(registryResult, { onRenderError: console.error });
|
|
16
|
+
* const disconnect = mount(actor, document.getElementById("app")!);
|
|
17
|
+
*
|
|
18
|
+
* // Later:
|
|
19
|
+
* disconnect();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
import type { AbstractActor, Viewable } from "@xmachines/play-actor";
|
|
25
|
+
import type { AnyActorLogic } from "xstate";
|
|
26
|
+
import type { StateStore } from "@json-render/core";
|
|
27
|
+
import type { DefineRegistryResult } from "./json-render/types.js";
|
|
28
|
+
import type { CreatePlayUIOptions } from "./types.js";
|
|
29
|
+
/**
|
|
30
|
+
* Per-mount options that can override factory-level settings.
|
|
31
|
+
*/
|
|
32
|
+
export interface MountOptions {
|
|
33
|
+
/** Optional external StateStore (controlled mode). When omitted, a fresh atom is created per view. */
|
|
34
|
+
store?: StateStore;
|
|
35
|
+
/** When true, suppresses missing-child warnings during streaming spec ingestion. */
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The mount function returned by createPlayUI.
|
|
40
|
+
* Call with (actor, container, mountOptions?) to start the renderer.
|
|
41
|
+
* Returns a disconnect function for cleanup.
|
|
42
|
+
*/
|
|
43
|
+
export type MountFn = (actor: AbstractActor<AnyActorLogic> & Viewable, container: HTMLElement, options?: MountOptions) => () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Create a batteries-included DOM renderer mount function.
|
|
46
|
+
*
|
|
47
|
+
* The user is responsible for calling defineRegistry to produce registryResult.
|
|
48
|
+
* createPlayUI closes over the registryResult and returns a mount function that
|
|
49
|
+
* can be called once per actor/container pair.
|
|
50
|
+
*
|
|
51
|
+
* @param registryResult - Result from defineRegistry() containing registry + handlers factory.
|
|
52
|
+
* @param options - Optional factory-level configuration (validationFunctions, navigate, etc.)
|
|
53
|
+
* @returns mount function: (actor, container, mountOptions?) → disconnect
|
|
54
|
+
*/
|
|
55
|
+
export declare function createPlayUI(registryResult: DefineRegistryResult, options?: CreatePlayUIOptions): MountFn;
|
|
56
|
+
//# sourceMappingURL=create-play-ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-play-ui.d.ts","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,sGAAsG;IACtG,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,oFAAoF;IACpF,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CACrB,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,EAC9C,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,YAAY,KAClB,MAAM,IAAI,CAAC;AAEhB;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC3B,cAAc,EAAE,oBAAoB,EACpC,OAAO,GAAE,mBAAwB,GAC/B,OAAO,CA6CT"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createPlayUI — batteries-included DOM factory.
|
|
3
|
+
*
|
|
4
|
+
* Takes a DefineRegistryResult (user calls defineRegistry themselves) and returns
|
|
5
|
+
* a mount function. Calling mount(actor, container) starts the renderer and returns
|
|
6
|
+
* a disconnect function for cleanup.
|
|
7
|
+
*
|
|
8
|
+
* Parallel to <PlayUIProvider registryResult={...}> in framework renderers.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { defineRegistry, createPlayUI } from "@xmachines/play-dom";
|
|
13
|
+
*
|
|
14
|
+
* const registryResult = defineRegistry(catalog, { components, actions });
|
|
15
|
+
* const mount = createPlayUI(registryResult, { onRenderError: console.error });
|
|
16
|
+
* const disconnect = mount(actor, document.getElementById("app")!);
|
|
17
|
+
*
|
|
18
|
+
* // Later:
|
|
19
|
+
* disconnect();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
import { PlayRenderer } from "./PlayRenderer.js";
|
|
25
|
+
/**
|
|
26
|
+
* Create a batteries-included DOM renderer mount function.
|
|
27
|
+
*
|
|
28
|
+
* The user is responsible for calling defineRegistry to produce registryResult.
|
|
29
|
+
* createPlayUI closes over the registryResult and returns a mount function that
|
|
30
|
+
* can be called once per actor/container pair.
|
|
31
|
+
*
|
|
32
|
+
* @param registryResult - Result from defineRegistry() containing registry + handlers factory.
|
|
33
|
+
* @param options - Optional factory-level configuration (validationFunctions, navigate, etc.)
|
|
34
|
+
* @returns mount function: (actor, container, mountOptions?) → disconnect
|
|
35
|
+
*/
|
|
36
|
+
export function createPlayUI(registryResult, options = {}) {
|
|
37
|
+
const { onRenderError, fallback } = options;
|
|
38
|
+
// Note: validationFunctions, navigate, functions are json-render provider features.
|
|
39
|
+
// The DOM layer doesn't have a provider tree — these are noted for future integration
|
|
40
|
+
// if a DOM ValidationProvider equivalent is introduced in @json-render/dom.
|
|
41
|
+
// For now they are accepted in options for API parity but not forwarded.
|
|
42
|
+
return function mount(actor, container, mountOptions) {
|
|
43
|
+
// Build the registry: if onRenderError is provided, inject it via Object.defineProperty
|
|
44
|
+
// (same pattern as framework renderers, centralised per D-19).
|
|
45
|
+
// Note: spreading registryResult.registry does NOT copy non-enumerable properties —
|
|
46
|
+
// this intentionally drops any registry-level onRenderError so the options-level
|
|
47
|
+
// handler has sole authority (D-19 pattern).
|
|
48
|
+
const registry = onRenderError
|
|
49
|
+
? (() => {
|
|
50
|
+
const r = { ...registryResult.registry };
|
|
51
|
+
Object.defineProperty(r, "onRenderError", {
|
|
52
|
+
value: onRenderError,
|
|
53
|
+
enumerable: false,
|
|
54
|
+
configurable: true,
|
|
55
|
+
});
|
|
56
|
+
return r;
|
|
57
|
+
})()
|
|
58
|
+
: registryResult.registry;
|
|
59
|
+
const rendererOptions = {
|
|
60
|
+
registryResult,
|
|
61
|
+
...(mountOptions?.store !== undefined && { store: mountOptions.store }),
|
|
62
|
+
...(mountOptions?.loading !== undefined && { loading: mountOptions.loading }),
|
|
63
|
+
};
|
|
64
|
+
const renderer = new PlayRenderer(container, actor, registry, rendererOptions);
|
|
65
|
+
renderer.connect();
|
|
66
|
+
// Handle fallback for null view on initial mount (same pattern as connectRenderer).
|
|
67
|
+
// connect() calls _render() synchronously so the container is already populated
|
|
68
|
+
// at this point if actor.currentView is non-null.
|
|
69
|
+
if (fallback != null && container.childNodes.length === 0) {
|
|
70
|
+
container.appendChild(fallback);
|
|
71
|
+
}
|
|
72
|
+
return function disconnect() {
|
|
73
|
+
renderer.disconnect();
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=create-play-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-play-ui.js","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAyBjD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAC3B,cAAoC,EACpC,UAA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;QAED,OAAO,SAAS,UAAU;YACzB,QAAQ,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -56,7 +56,7 @@ import type { AbstractActor, Viewable } from "@xmachines/play-actor";
|
|
|
56
56
|
import type { AnyActorLogic } from "xstate";
|
|
57
57
|
import type { Catalog } from "@json-render/core";
|
|
58
58
|
import type { ComponentRegistry } from "./json-render/types.js";
|
|
59
|
-
import type { PlayDomOptions } from "./
|
|
59
|
+
import type { PlayDomOptions } from "./types.js";
|
|
60
60
|
/**
|
|
61
61
|
* Create a reusable DOM renderer factory from a catalog and component map.
|
|
62
62
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-renderer.d.ts","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"create-renderer.d.ts","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAC/C,OAAO,EAAE,CAAC,EACV,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAChC,CACF,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,EAC9C,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC5C,MAAM,IAAI,CAWd"}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
export { connectRenderer } from "./connect-renderer.js";
|
|
29
29
|
export { PlayRenderer } from "./PlayRenderer.js";
|
|
30
30
|
export { createRenderer } from "./create-renderer.js";
|
|
31
|
-
export
|
|
31
|
+
export { createPlayUI } from "./create-play-ui.js";
|
|
32
|
+
export type { MountFn, MountOptions } from "./create-play-ui.js";
|
|
33
|
+
export type { ConnectRendererOptions, PlayDomOptions, CreatePlayUIOptions } from "./types.js";
|
|
32
34
|
export { defineRegistry, renderSpec, schema } from "./json-render/index.js";
|
|
33
|
-
export type { EventHandle, SetState, CatalogHasActions, BaseComponentProps, DomRenderContext, DomComponentRenderer, ComponentContext, ComponentFn, ComponentRegistry, Actions, ActionFn, DefineRegistryOptions, DefineRegistryResult, DomRegistry, DomSchema, } from "./json-render/index.js";
|
|
35
|
+
export type { EventHandle, SetState, RenderErrorHandler, UIProviderOptions, CatalogHasActions, BaseComponentProps, DomRenderContext, DomComponentRenderer, ComponentContext, ComponentFn, ComponentRegistry, Actions, ActionFn, DefineRegistryOptions, DefineRegistryResult, DomRegistry, DomSchema, } from "./json-render/index.js";
|
|
34
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGjE,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAG9F,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC5E,YAAY,EACX,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,SAAS,GACT,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
export { connectRenderer } from "./connect-renderer.js";
|
|
30
30
|
export { PlayRenderer } from "./PlayRenderer.js";
|
|
31
31
|
export { createRenderer } from "./create-renderer.js";
|
|
32
|
+
// createPlayUI — batteries-included DOM factory (additive, per D-27, D-29)
|
|
33
|
+
export { createPlayUI } from "./create-play-ui.js";
|
|
32
34
|
// json-render/dom layer (re-exported for consumer convenience)
|
|
33
35
|
export { defineRegistry, renderSpec, schema } from "./json-render/index.js";
|
|
34
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,8BAA8B;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,8BAA8B;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,2EAA2E;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,+DAA+D;AAC/D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -15,6 +15,6 @@ export { renderSpec } from "./renderer.js";
|
|
|
15
15
|
export { defineRegistry } from "./types.js";
|
|
16
16
|
export { schema } from "./schema.js";
|
|
17
17
|
export type { DomSchema } from "./schema.js";
|
|
18
|
-
export type { EventHandle, SetState, CatalogHasActions, BaseComponentProps, DomRenderContext, DomComponentRenderer, ComponentContext, ComponentFn, ComponentRegistry, Actions, ActionFn, DefineRegistryOptions, DefineRegistryResult, DomRegistry, } from "./types.js";
|
|
18
|
+
export type { EventHandle, SetState, RenderErrorHandler, UIProviderOptions, CatalogHasActions, BaseComponentProps, DomRenderContext, DomComponentRenderer, ComponentContext, ComponentFn, ComponentRegistry, Actions, ActionFn, DefineRegistryOptions, DefineRegistryResult, DomRegistry, } from "./types.js";
|
|
19
19
|
export type { ComputedFunction } from "@json-render/core";
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json-render/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACX,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json-render/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACX,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
-
import type { ActionHandler, Catalog, ComputedFunction, InferActionParams, InferCatalogActions, InferCatalogComponents, InferComponentProps, StateModel, Spec, StateStore, UIElement } from "@json-render/core";
|
|
16
|
+
import type { ActionHandler, Catalog, ComputedFunction, RenderErrorHandler, InferActionParams, InferCatalogActions, InferCatalogComponents, InferComponentProps, StateModel, Spec, StateStore, UIElement } from "@json-render/core";
|
|
17
17
|
/**
|
|
18
18
|
* Function to update the local state store.
|
|
19
19
|
*
|
|
@@ -26,6 +26,38 @@ import type { ActionHandler, Catalog, ComputedFunction, InferActionParams, Infer
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export type SetState = (updater: (prev: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
29
|
+
export type { RenderErrorHandler };
|
|
30
|
+
/**
|
|
31
|
+
* Shared UI-provider options — the configurable rendering behaviours that sit
|
|
32
|
+
* above the core actor/registry wiring.
|
|
33
|
+
*
|
|
34
|
+
* These fields mirror the forwarded props on `JSONUIProvider` /
|
|
35
|
+
* `JsonUIProvider` across @json-render/react, /vue, /solid, /svelte.
|
|
36
|
+
* Grouping them here lets `ConnectRendererOptions` and `CreatePlayUIOptions`
|
|
37
|
+
* in `types.ts` extend a single source of truth.
|
|
38
|
+
*/
|
|
39
|
+
export interface UIProviderOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Custom validation functions for the json-render ValidationProvider equivalent.
|
|
42
|
+
* Each function receives `(value, args?)` and returns a boolean.
|
|
43
|
+
*/
|
|
44
|
+
validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Navigation function forwarded to json-render computed functions that need to
|
|
47
|
+
* trigger programmatic navigation (e.g. a `navigate` action in the catalog).
|
|
48
|
+
*/
|
|
49
|
+
navigate?: (path: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Custom computed functions available to `$computed` field expressions in specs.
|
|
52
|
+
* Mirrors the `functions` prop on `JSONUIProvider` / `JsonUIProvider`.
|
|
53
|
+
*/
|
|
54
|
+
functions?: Record<string, ComputedFunction>;
|
|
55
|
+
/**
|
|
56
|
+
* Called when an individual catalog component throws during render.
|
|
57
|
+
* Forwarded as `onRenderError` to the underlying renderer.
|
|
58
|
+
*/
|
|
59
|
+
onRenderError?: RenderErrorHandler;
|
|
60
|
+
}
|
|
29
61
|
/**
|
|
30
62
|
* Evaluates to `true` when a catalog declares at least one action; `false` otherwise.
|
|
31
63
|
*
|
|
@@ -252,27 +284,5 @@ export interface DefineRegistryResult {
|
|
|
252
284
|
*/
|
|
253
285
|
executeAction: (actionName: string, params: Record<string, unknown> | undefined, setState: SetState, state?: StateModel) => Promise<void>;
|
|
254
286
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Build a `DomRegistry` from a catalog and component/action options.
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* ```ts
|
|
260
|
-
* import { defineRegistry } from "@xmachines/play-dom";
|
|
261
|
-
* import { authCatalog } from "@xmachines/play-actor-shared";
|
|
262
|
-
*
|
|
263
|
-
* const registryResult = defineRegistry(authCatalog, {
|
|
264
|
-
* components: { Home, Login, Dashboard, ... },
|
|
265
|
-
* actions: {
|
|
266
|
-
* login: async ({ username }) => actor.send({ type: 'auth.login', username }),
|
|
267
|
-
* logout: async () => actor.send({ type: 'auth.logout' }),
|
|
268
|
-
* route: async ({ to, params }) => actor.send({ type: 'play.route', to, params }),
|
|
269
|
-
* },
|
|
270
|
-
* });
|
|
271
|
-
*
|
|
272
|
-
* const { registry, handlers } = registryResult;
|
|
273
|
-
* const resolvedHandlers = handlers(() => undefined, () => ({}));
|
|
274
|
-
* connectRenderer({ actor, registry, container, handlers: resolvedHandlers });
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
287
|
export declare function defineRegistry<C extends Catalog>(_catalog: C, options: DefineRegistryOptions<C>): DefineRegistryResult;
|
|
278
288
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/json-render/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,IAAI,EACJ,UAAU,EACV,SAAS,EACT,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG,CACtB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/D,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/json-render/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,IAAI,EACJ,UAAU,EACV,SAAS,EACT,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG,CACtB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OA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C,SAAS,OAAO,IAAI;KACvC,CAAC,IAAI,MAAM,mBAAmB,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,OAAO,IAAI;IACtD;;;;OAIG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAClC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,IAAI,GACnC;IACA;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACpB,GACA;IACA;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;IACtB;;;;;;;;;OASG;IACH,QAAQ,EAAE,CACT,WAAW,EAAE,MAAM,QAAQ,GAAG,SAAS,EACvC,QAAQ,EAAE,MAAM,UAAU,KACtB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACnC;;;;;;;;;;OAUG;IACH,aAAa,EAAE,CACd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,QAAQ,EAAE,QAAQ,EAClB,KAAK,CAAC,EAAE,UAAU,KACd,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AA4BD,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAC/C,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAC/B,oBAAoB,CAmHtB"}
|
|
@@ -36,6 +36,8 @@ import { resolveActionParam } from "@json-render/core";
|
|
|
36
36
|
* connectRenderer({ actor, registry, container, handlers: resolvedHandlers });
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
+
/** No-op SetState used when no store is attached. Extracted to module scope to avoid re-creation. */
|
|
40
|
+
const noopSetState = (_updater) => { };
|
|
39
41
|
export function defineRegistry(_catalog, options) {
|
|
40
42
|
const components = (options.components ?? {});
|
|
41
43
|
const actionDefs = (options.actions ?? {});
|
|
@@ -98,11 +100,8 @@ export function defineRegistry(_catalog, options) {
|
|
|
98
100
|
// getSetState / getState are called at action-invocation time (not at handlers() call time)
|
|
99
101
|
// so the action always sees the latest store state even after re-renders.
|
|
100
102
|
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
// throw a TypeError at runtime. Actions that depend on setState will have no effect
|
|
104
|
-
// on state in this case, which is the correct semantics for a stateless view.
|
|
105
|
-
const noopSetState = (_updater) => { };
|
|
103
|
+
// handlers factory — uses module-level noopSetState when no store is attached so
|
|
104
|
+
// action functions that call setState(...) do not throw a TypeError at runtime.
|
|
106
105
|
const handlers = (getSetState, getState) => {
|
|
107
106
|
const result = {};
|
|
108
107
|
for (const [name, actionFn] of Object.entries(actionDefs)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/json-render/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/json-render/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAmWvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,qGAAqG;AACrG,MAAM,YAAY,GAAa,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC;AAEhD,MAAM,UAAU,cAAc,CAC7B,QAAW,EACX,OAAiC;IAEjC,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAA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EF,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,4FAA4F;IAC5F,0EAA0E;IAC1E,EAAE;IACF,iFAAiF;IACjF,gFAAgF;IAChF,MAAM,QAAQ,GAAG,CAChB,WAAuC,EACvC,QAA0B,EACM,EAAE;QAClC,MAAM,MAAM,GAAkC,EAAE,CAAC;QACjD,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAC5C,UAAuE,CACvE,EAAE,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,MAA+B,EAAE,EAAE;gBACxD,MAAM,QAAQ,GAAG,WAAW,EAAE,IAAI,YAAY,CAAC;gBAC/C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACzB,MAAM,QAAQ,CACb,MAAwE,EACxE,QAAQ,EACR,KAAK,CACL,CAAC;YACH,CAAC,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;IAEF,+EAA+E;IAC/E,MAAM,aAAa,GAAG,KAAK,EAC1B,UAAkB,EAClB,MAA2C,EAC3C,QAAkB,EAClB,QAAoB,EAAE,EACN,EAAE;QAClB,MAAM,QAAQ,GAAI,UAAwE,CACzF,UAAU,CACV,CAAC;QACF,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,QAAQ,CACb,MAAwE,EACxE,QAAQ,EACR,KAAK,CACL,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* types.ts — XMachines-specific type definitions for play-dom.
|
|
3
3
|
*
|
|
4
4
|
* These types depend on @xmachines/play-actor and stay in play-dom.
|
|
5
5
|
* Pure json-render types live in ./json-render/types.ts.
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import type { AbstractActor, Viewable } from "@xmachines/play-actor";
|
|
10
10
|
import type { AnyActorLogic } from "xstate";
|
|
11
11
|
import type { ActionHandler, StateStore } from "@json-render/core";
|
|
12
|
-
import type { DefineRegistryResult, DomRegistry } from "./json-render/types.js";
|
|
12
|
+
import type { DefineRegistryResult, DomRegistry, UIProviderOptions } from "./json-render/types.js";
|
|
13
|
+
export type { UIProviderOptions } from "./json-render/types.js";
|
|
13
14
|
/**
|
|
14
15
|
* Options for PlayRenderer.
|
|
15
16
|
*/
|
|
@@ -51,7 +52,7 @@ export interface PlayDomOptions {
|
|
|
51
52
|
/**
|
|
52
53
|
* Options for connectRenderer() — backward compat API.
|
|
53
54
|
*/
|
|
54
|
-
export interface ConnectRendererOptions {
|
|
55
|
+
export interface ConnectRendererOptions extends UIProviderOptions {
|
|
55
56
|
/** Actor instance with currentView signal (requires Viewable capability) */
|
|
56
57
|
actor: AbstractActor<AnyActorLogic> & Viewable;
|
|
57
58
|
/**
|
|
@@ -113,4 +114,27 @@ export interface ConnectRendererOptions {
|
|
|
113
114
|
*/
|
|
114
115
|
loading?: boolean;
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Options for createPlayUI() — the batteries-included DOM factory.
|
|
119
|
+
*
|
|
120
|
+
* Extends UIProviderOptions (shared configurable UI behaviours) with the
|
|
121
|
+
* DOM-specific `fallback` element. Parallel to PlayUIProvider's extra props
|
|
122
|
+
* in the framework renderers.
|
|
123
|
+
*
|
|
124
|
+
* @see createPlayUI
|
|
125
|
+
*/
|
|
126
|
+
export interface CreatePlayUIOptions extends UIProviderOptions {
|
|
127
|
+
/**
|
|
128
|
+
* Optional fallback element shown when `currentView` is `null` on **initial mount** only.
|
|
129
|
+
*
|
|
130
|
+
* The fallback is appended immediately after `mount()` if the container is empty at
|
|
131
|
+
* that moment (i.e. the actor's initial view is `null`).
|
|
132
|
+
*
|
|
133
|
+
* **Limitation:** If the actor's view transitions to `null` after mount, the container
|
|
134
|
+
* will be cleared but this fallback will NOT be re-appended. For dynamic fallback
|
|
135
|
+
* behavior (null view after non-null), use `PlayRenderer` directly and wrap the
|
|
136
|
+
* `actor.currentView` signal to inject fallback content.
|
|
137
|
+
*/
|
|
138
|
+
fallback?: HTMLElement | null;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEnG,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEzC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAChE,4EAA4E;IAC5E,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;IAE/C;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,EAAE,WAAW,CAAC;IAEtB,uCAAuC;IACvC,SAAS,EAAE,WAAW,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAE9B;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEzC;;;;OAIG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC7D;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* types.ts — XMachines-specific type definitions for play-dom.
|
|
3
3
|
*
|
|
4
4
|
* These types depend on @xmachines/play-actor and stay in play-dom.
|
|
5
5
|
* Pure json-render types live in ./json-render/types.ts.
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
export {};
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-dom",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.35",
|
|
4
4
|
"description": "Vanilla DOM renderer for XMachines Play architecture with signal-driven rendering",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actor",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"prepublishOnly": "npm run build"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@xmachines/play": "1.0.0-beta.
|
|
47
|
-
"@xmachines/play-actor": "1.0.0-beta.
|
|
48
|
-
"@xmachines/play-signals": "1.0.0-beta.
|
|
46
|
+
"@xmachines/play": "1.0.0-beta.35",
|
|
47
|
+
"@xmachines/play-actor": "1.0.0-beta.35",
|
|
48
|
+
"@xmachines/play-signals": "1.0.0-beta.35"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@json-render/core": "^0.18.0",
|
|
52
52
|
"@json-render/xstate": "^0.18.0",
|
|
53
53
|
"@types/node": "^25.6.0",
|
|
54
|
-
"@xmachines/shared": "1.0.0-beta.
|
|
54
|
+
"@xmachines/shared": "1.0.0-beta.35",
|
|
55
55
|
"@xstate/store": "^3.17.0",
|
|
56
56
|
"oxfmt": "^0.45.0",
|
|
57
57
|
"oxlint": "^1.60.0",
|
package/dist/xm-types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xm-types.d.ts","sourceRoot":"","sources":["../src/xm-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEzC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;;;OAMG;IACH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