@xmachines/play-dom 2.0.0 → 2.1.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.
@@ -1,16 +1,17 @@
1
1
  /**
2
- * createPlayUI — batteries-included DOM factory.
2
+ * createPlayUI — the complete DOM factory.
3
3
  *
4
- * Takes a `DefineRegistryResult` (the caller is responsible for calling
5
- * `defineRegistry`) and returns a `MountFn`. Calling `mount(actor, container)`
6
- * starts the renderer and returns a `disconnect` cleanup function.
4
+ * It takes a `DefineRegistryResult`, and the caller calls `defineRegistry` itself.
5
+ * It returns a `MountFn`. A `mount(actor, container)` call starts the renderer, and
6
+ * it returns a `disconnect` cleanup function.
7
7
  *
8
- * Factory-level options (`functions`, `validationFunctions`, `navigate`,
9
- * `onRenderError`, `fallback`) are closed over at creation time and applied on
10
- * every `mount()` call. Per-mount options (`store`, `loading`) can be passed
11
- * to the `mount()` call itself via `MountOptions`.
8
+ * The factory holds the factory options (`functions`, `validationFunctions`,
9
+ * `navigate`, `onRenderError`, and `fallback`) from the moment of its creation, and
10
+ * it applies them on every `mount()` call. Give the mount options (`store` and
11
+ * `loading`) to the `mount()` call itself, through `MountOptions`.
12
12
  *
13
- * Parallel to `<PlayUIProvider registryResult={...}>` in the framework renderers.
13
+ * This factory is parallel to `<PlayUIProvider registryResult={...}>` in the
14
+ * framework renderers.
14
15
  *
15
16
  * @example
16
17
  * ```typescript
@@ -36,50 +37,51 @@ import type { StateStore } from "@xmachines/json-render-core";
36
37
  import type { DefineRegistryResult } from "@xmachines/json-render-dom";
37
38
  import type { CreatePlayUIOptions } from "./types.js";
38
39
  /**
39
- * Per-mount options passed to the `MountFn` returned by `createPlayUI`.
40
+ * The mount options of the `MountFn` that `createPlayUI` returns.
40
41
  *
41
- * These override or supplement the factory-level options on a per-actor/container
42
- * basis. Factory-level options (`functions`, `validationFunctions`, `navigate`,
43
- * `onRenderError`, `fallback`) are set once when calling `createPlayUI`.
42
+ * They replace or complete the factory options, for one actor and one container.
43
+ * The `createPlayUI` call sets the factory options (`functions`,
44
+ * `validationFunctions`, `navigate`, `onRenderError`, and `fallback`) one time.
44
45
  */
45
46
  export interface MountOptions {
46
47
  /**
47
- * Optional external `StateStore` (controlled mode).
48
- * When omitted, a fresh `@xstate/store` atom is created per view transition
49
- * seeded from `spec.state`.
48
+ * The optional external `StateStore`, which is the controlled mode.
49
+ * Without it, the renderer makes a new `@xstate/store` atom for each view
50
+ * transition, with the values of `spec.state`.
50
51
  */
51
52
  store?: StateStore;
52
53
  /**
53
- * When `true`, suppresses missing-child warnings during streaming spec ingestion
54
- * and exposes `ctx.ctx.loading` to component implementations.
54
+ * With the value `true`, the renderer stops each warning about an absent child
55
+ * during the ingestion of a streaming spec. It also gives `ctx.ctx.loading` to each
56
+ * component implementation.
55
57
  */
56
58
  loading?: boolean;
57
59
  }
58
60
  /**
59
- * The mount function returned by `createPlayUI`.
61
+ * The mount function that `createPlayUI` returns.
60
62
  *
61
- * Call with `(actor, container, mountOptions?)` to start the renderer.
62
- * Returns a `disconnect` cleanup function that stops rendering and clears
63
- * the container.
63
+ * Call it with `(actor, container, mountOptions?)` to start the renderer.
64
+ * It returns a `disconnect` cleanup function. That function stops the render and
65
+ * clears the container.
64
66
  */
65
67
  export type MountFn = (actor: AbstractActor<AnyActorLogic> & Viewable, container: HTMLElement, options?: MountOptions) => () => void;
66
68
  /**
67
- * Create a batteries-included DOM renderer mount function.
69
+ * Creates the mount function of the complete DOM renderer.
68
70
  *
69
- * The caller is responsible for producing `registryResult` via `defineRegistry`.
70
- * `createPlayUI` closes over it and returns a `MountFn` that can be invoked
71
- * once per actor/container pair.
71
+ * The caller makes `registryResult` with `defineRegistry`. `createPlayUI` holds it,
72
+ * and it returns a `MountFn`. Call that function one time for each pair of an actor
73
+ * and a container.
72
74
  *
73
- * @param registryResult - Result from `defineRegistry()` provides the registry
74
- * and the lazy handlers factory.
75
- * @param options - Factory-level configuration (see {@link CreatePlayUIOptions}):
76
- * - `functions` — named compute functions for `$computed` prop expressions.
77
- * - `directives` — custom `$`-prefixed dynamic values resolved during prop resolution.
78
- * - `validationFunctions` — custom validation functions; available at `ctx.ctx.validationFunctions`.
79
- * - `navigate` — navigation callback; invoked on `onSuccess: { navigate: "..." }`.
80
- * - `onRenderError` — `(error, name)` handler for component render errors and action handler rejections.
81
- * - `fallback` — element shown when the actor's initial view is `null`.
82
- * @returns `MountFn`: `(actor, container, mountOptions?) → disconnect`
75
+ * @param registryResult - The result of `defineRegistry()`. It gives the registry
76
+ * and the factory of the handlers, which it builds late.
77
+ * @param options - The factory configuration. See {@link CreatePlayUIOptions}:
78
+ * - `functions` — the named compute functions of a `$computed` prop expression.
79
+ * - `directives` — your own dynamic values with a `$` prefix. The renderer resolves them with the props.
80
+ * - `validationFunctions` — your own check functions. They are available at `ctx.ctx.validationFunctions`.
81
+ * - `navigate` — the navigation callback. The renderer calls it for `onSuccess: { navigate: "..." }`.
82
+ * - `onRenderError` — the `(error, name)` handler of a component render error and of an action handler rejection.
83
+ * - `fallback` — the element to show when the first view of the actor is `null`.
84
+ * @returns The `MountFn`: `(actor, container, mountOptions?) → disconnect`
83
85
  */
84
86
  export declare function createPlayUI(registryResult: DefineRegistryResult, options?: CreatePlayUIOptions): MountFn;
85
87
  //# sourceMappingURL=create-play-ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-play-ui.d.ts","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAA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,IAAI,CAAC;AAEhB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC3B,cAAc,EAAE,oBAAoB,EACpC,OAAO,GAAE,mBAAwB,GAC/B,OAAO,CA8CT"}
@@ -1,16 +1,17 @@
1
1
  /**
2
- * createPlayUI — batteries-included DOM factory.
2
+ * createPlayUI — the complete DOM factory.
3
3
  *
4
- * Takes a `DefineRegistryResult` (the caller is responsible for calling
5
- * `defineRegistry`) and returns a `MountFn`. Calling `mount(actor, container)`
6
- * starts the renderer and returns a `disconnect` cleanup function.
4
+ * It takes a `DefineRegistryResult`, and the caller calls `defineRegistry` itself.
5
+ * It returns a `MountFn`. A `mount(actor, container)` call starts the renderer, and
6
+ * it returns a `disconnect` cleanup function.
7
7
  *
8
- * Factory-level options (`functions`, `validationFunctions`, `navigate`,
9
- * `onRenderError`, `fallback`) are closed over at creation time and applied on
10
- * every `mount()` call. Per-mount options (`store`, `loading`) can be passed
11
- * to the `mount()` call itself via `MountOptions`.
8
+ * The factory holds the factory options (`functions`, `validationFunctions`,
9
+ * `navigate`, `onRenderError`, and `fallback`) from the moment of its creation, and
10
+ * it applies them on every `mount()` call. Give the mount options (`store` and
11
+ * `loading`) to the `mount()` call itself, through `MountOptions`.
12
12
  *
13
- * Parallel to `<PlayUIProvider registryResult={...}>` in the framework renderers.
13
+ * This factory is parallel to `<PlayUIProvider registryResult={...}>` in the
14
+ * framework renderers.
14
15
  *
15
16
  * @example
16
17
  * ```typescript
@@ -32,28 +33,29 @@
32
33
  */
33
34
  import { PlayRenderer } from "./PlayRenderer.js";
34
35
  /**
35
- * Create a batteries-included DOM renderer mount function.
36
+ * Creates the mount function of the complete DOM renderer.
36
37
  *
37
- * The caller is responsible for producing `registryResult` via `defineRegistry`.
38
- * `createPlayUI` closes over it and returns a `MountFn` that can be invoked
39
- * once per actor/container pair.
38
+ * The caller makes `registryResult` with `defineRegistry`. `createPlayUI` holds it,
39
+ * and it returns a `MountFn`. Call that function one time for each pair of an actor
40
+ * and a container.
40
41
  *
41
- * @param registryResult - Result from `defineRegistry()` provides the registry
42
- * and the lazy handlers factory.
43
- * @param options - Factory-level configuration (see {@link CreatePlayUIOptions}):
44
- * - `functions` — named compute functions for `$computed` prop expressions.
45
- * - `directives` — custom `$`-prefixed dynamic values resolved during prop resolution.
46
- * - `validationFunctions` — custom validation functions; available at `ctx.ctx.validationFunctions`.
47
- * - `navigate` — navigation callback; invoked on `onSuccess: { navigate: "..." }`.
48
- * - `onRenderError` — `(error, name)` handler for component render errors and action handler rejections.
49
- * - `fallback` — element shown when the actor's initial view is `null`.
50
- * @returns `MountFn`: `(actor, container, mountOptions?) → disconnect`
42
+ * @param registryResult - The result of `defineRegistry()`. It gives the registry
43
+ * and the factory of the handlers, which it builds late.
44
+ * @param options - The factory configuration. See {@link CreatePlayUIOptions}:
45
+ * - `functions` — the named compute functions of a `$computed` prop expression.
46
+ * - `directives` — your own dynamic values with a `$` prefix. The renderer resolves them with the props.
47
+ * - `validationFunctions` — your own check functions. They are available at `ctx.ctx.validationFunctions`.
48
+ * - `navigate` — the navigation callback. The renderer calls it for `onSuccess: { navigate: "..." }`.
49
+ * - `onRenderError` — the `(error, name)` handler of a component render error and of an action handler rejection.
50
+ * - `fallback` — the element to show when the first view of the actor is `null`.
51
+ * @returns The `MountFn`: `(actor, container, mountOptions?) → disconnect`
51
52
  */
52
53
  export function createPlayUI(registryResult, options = {}) {
53
54
  const { onRenderError, fallback, functions, directives, validationFunctions, navigate, onConfirm, } = options;
54
55
  return function mount(actor, container, mountOptions) {
55
- // All UIProviderOptions (onRenderError, functions, validationFunctions, navigate) are
56
- // forwarded directly through PlayDomOptions PlayRenderer → renderSpec → DomRenderContext.
56
+ // Each option of UIProviderOptions (onRenderError, functions, validationFunctions,
57
+ // and navigate) goes directly through PlayDomOptions, then PlayRenderer, then
58
+ // renderSpec, then DomRenderContext.
57
59
  const rendererOptions = {
58
60
  registryResult,
59
61
  ...(mountOptions?.store !== undefined && { store: mountOptions.store }),
@@ -67,9 +69,9 @@ export function createPlayUI(registryResult, options = {}) {
67
69
  };
68
70
  const renderer = new PlayRenderer(container, actor, registryResult.registry, rendererOptions);
69
71
  renderer.connect();
70
- // Handle fallback for null view on initial mount.
71
- // connect() calls _render() synchronously so the container is already populated
72
- // at this point if actor.currentView is non-null.
72
+ // Handle the fallback of a null view on the first mount.
73
+ // connect() calls _render() synchronously. Therefore the container holds the view
74
+ // already at this point, when actor.currentView is not null.
73
75
  if (fallback != null && container.childNodes.length === 0) {
74
76
  container.appendChild(fallback);
75
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-play-ui.js","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAsCjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAC3B,cAAoC,EACpC,UAA+B,EAAE;IAEjC,MAAM,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,QAAQ,EACR,SAAS,GACT,GAAG,OAAO,CAAC;IAEZ,OAAO,SAAS,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY;QACnD,sFAAsF;QACtF,4FAA4F;QAC5F,MAAM,eAAe,GAAG;YACvB,cAAc;YACd,GAAG,CAAC,YAAY,EAAE,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC;YACvE,GAAG,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7E,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7C,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;YAC/C,GAAG,CAAC,mB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vB,cAAc;YACd,GAAG,CAAC,YAAY,EAAE,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC;YACvE,GAAG,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7E,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7C,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;YAC/C,GAAG,CAAC,mBAAmB,KAAK,SAAS,IAAI,EAAE,mBAAmB,EAAE,CAAC;YACjE,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC3C,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7C,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,CAAC;SACrD,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,YAAY,CAChC,SAAS,EACT,KAAK,EACL,cAAc,CAAC,QAAQ,EACvB,eAAe,CACf,CAAC;QACF,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnB,yDAAyD;QACzD,kFAAkF;QAClF,6DAA6D;QAC7D,IAAI,QAAQ,IAAI,IAAI,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,SAAS,UAAU;YACzB,QAAQ,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * create-renderer.ts — createRenderer convenience factory for @xmachines/play-dom.
2
+ * create-renderer.ts — the createRenderer factory of @xmachines/play-dom.
3
3
  *
4
- * Mirrors the `createRenderer` export from @xmachines/json-render-react, /vue, /solid, /svelte.
5
- * Calls `defineRegistry` once at factory creation time and returns a
6
- * `mount(actor, container, options?)` function that wires up PlayRenderer and
7
- * returns a `disconnect` cleanup function.
4
+ * It matches the `createRenderer` export of @xmachines/json-render-react, of /vue,
5
+ * of /solid, and of /svelte. It calls `defineRegistry` one time, at the creation of
6
+ * the factory. It then returns a `mount(actor, container, options?)` function. That
7
+ * function connects a PlayRenderer, and it returns a `disconnect` cleanup function.
8
8
  *
9
- * Reduces consumer boilerplate from 3–4 steps to one call.
9
+ * The consumer therefore writes one call, and not three or four steps.
10
10
  *
11
11
  * @example
12
12
  * ```ts
@@ -40,13 +40,13 @@
40
40
  * return el;
41
41
  * };
42
42
  *
43
- * // Build the factory once (at module scope)
43
+ * // Build the factory one time, at module scope
44
44
  * const mount = createRenderer(catalog, { Home, Login });
45
45
  *
46
- * // Mount when actor + container are ready
46
+ * // Mount when the actor and the container are ready
47
47
  * const disconnect = mount(actor, document.getElementById("app")!);
48
48
  *
49
- * // Cleanup:
49
+ * // Clean up:
50
50
  * disconnect();
51
51
  * ```
52
52
  *
@@ -58,24 +58,28 @@ import type { Catalog } from "@xmachines/json-render-core";
58
58
  import type { ComponentRegistry } from "@xmachines/json-render-dom";
59
59
  import type { PlayDomOptions } from "./types.js";
60
60
  /**
61
- * Create a reusable DOM renderer factory from a catalog and component map.
61
+ * Creates a DOM renderer factory from a catalog and a component map. You can use
62
+ * the factory more than one time.
62
63
  *
63
- * Returns a `mount(actor, container, options?)` function that wires up the
64
- * PlayRenderer in one call and returns a `disconnect` cleanup function.
64
+ * It returns a `mount(actor, container, options?)` function. That function connects
65
+ * the PlayRenderer in one call, and it returns a `disconnect` cleanup function.
65
66
  *
66
- * @param catalog - The json-render Catalog describing component and action schemas.
67
- * @param componentMap - Component implementations keyed by catalog component name.
68
- * @returns A `mount` function that accepts `(actor, container, options?)` and returns `disconnect`.
67
+ * @param catalog - The json-render Catalog. It describes the schema of each component and of each action.
68
+ * @param componentMap - The component implementations, with the catalog component name as the key.
69
+ * @returns A `mount` function. It accepts `(actor, container, options?)`, and it returns `disconnect`.
69
70
  *
70
71
  * @remarks
71
- * `createRenderer` manages `registryResult` internally it calls `defineRegistry` once and
72
- * reuses the result across all `mount()` calls. The `mount` options type therefore excludes
73
- * `registryResult` (it is always provided by `createRenderer` itself and cannot be overridden).
72
+ * `createRenderer` manages `registryResult` internally. It calls `defineRegistry`
73
+ * one time, and it uses that result in every `mount()` call. Therefore the options
74
+ * type of `mount` holds no `registryResult`: `createRenderer` always gives it, and
75
+ * you cannot replace it.
74
76
  *
75
- * If you need to call `registryResult.executeAction()` programmatically (outside the emit/on
76
- * flow), or pass additional provider options (`navigate`, `onRenderError`, `functions`, etc.),
77
- * use `createPlayUI` (which accepts the full `CreatePlayUIOptions`) or `defineRegistry` with
78
- * `PlayRenderer` directly rather than `createRenderer`.
77
+ * Two situations need a different function. In the first, your code calls
78
+ * `registryResult.executeAction()` itself, outside the emit and on flow. In the
79
+ * second, you give more provider options, such as `navigate`, `onRenderError`, or
80
+ * `functions`. Use `createPlayUI`, which accepts the complete
81
+ * `CreatePlayUIOptions`. You can also use `defineRegistry` with `PlayRenderer`
82
+ * directly.
79
83
  */
80
84
  export declare function createRenderer<C extends Catalog>(catalog: C, componentMap: ComponentRegistry<C>): (actor: AbstractActor<AnyActorLogic> & Viewable, container: HTMLElement, options?: Omit<PlayDomOptions, "registryResult">) => () => void;
81
85
  //# sourceMappingURL=create-renderer.d.ts.map
@@ -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,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MAAM,IAAI,CAWd"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * create-renderer.ts — createRenderer convenience factory for @xmachines/play-dom.
2
+ * create-renderer.ts — the createRenderer factory of @xmachines/play-dom.
3
3
  *
4
- * Mirrors the `createRenderer` export from @xmachines/json-render-react, /vue, /solid, /svelte.
5
- * Calls `defineRegistry` once at factory creation time and returns a
6
- * `mount(actor, container, options?)` function that wires up PlayRenderer and
7
- * returns a `disconnect` cleanup function.
4
+ * It matches the `createRenderer` export of @xmachines/json-render-react, of /vue,
5
+ * of /solid, and of /svelte. It calls `defineRegistry` one time, at the creation of
6
+ * the factory. It then returns a `mount(actor, container, options?)` function. That
7
+ * function connects a PlayRenderer, and it returns a `disconnect` cleanup function.
8
8
  *
9
- * Reduces consumer boilerplate from 3–4 steps to one call.
9
+ * The consumer therefore writes one call, and not three or four steps.
10
10
  *
11
11
  * @example
12
12
  * ```ts
@@ -40,13 +40,13 @@
40
40
  * return el;
41
41
  * };
42
42
  *
43
- * // Build the factory once (at module scope)
43
+ * // Build the factory one time, at module scope
44
44
  * const mount = createRenderer(catalog, { Home, Login });
45
45
  *
46
- * // Mount when actor + container are ready
46
+ * // Mount when the actor and the container are ready
47
47
  * const disconnect = mount(actor, document.getElementById("app")!);
48
48
  *
49
- * // Cleanup:
49
+ * // Clean up:
50
50
  * disconnect();
51
51
  * ```
52
52
  *
@@ -55,24 +55,28 @@
55
55
  import { PlayRenderer } from "./PlayRenderer.js";
56
56
  import { defineRegistry } from "@xmachines/json-render-dom";
57
57
  /**
58
- * Create a reusable DOM renderer factory from a catalog and component map.
58
+ * Creates a DOM renderer factory from a catalog and a component map. You can use
59
+ * the factory more than one time.
59
60
  *
60
- * Returns a `mount(actor, container, options?)` function that wires up the
61
- * PlayRenderer in one call and returns a `disconnect` cleanup function.
61
+ * It returns a `mount(actor, container, options?)` function. That function connects
62
+ * the PlayRenderer in one call, and it returns a `disconnect` cleanup function.
62
63
  *
63
- * @param catalog - The json-render Catalog describing component and action schemas.
64
- * @param componentMap - Component implementations keyed by catalog component name.
65
- * @returns A `mount` function that accepts `(actor, container, options?)` and returns `disconnect`.
64
+ * @param catalog - The json-render Catalog. It describes the schema of each component and of each action.
65
+ * @param componentMap - The component implementations, with the catalog component name as the key.
66
+ * @returns A `mount` function. It accepts `(actor, container, options?)`, and it returns `disconnect`.
66
67
  *
67
68
  * @remarks
68
- * `createRenderer` manages `registryResult` internally it calls `defineRegistry` once and
69
- * reuses the result across all `mount()` calls. The `mount` options type therefore excludes
70
- * `registryResult` (it is always provided by `createRenderer` itself and cannot be overridden).
69
+ * `createRenderer` manages `registryResult` internally. It calls `defineRegistry`
70
+ * one time, and it uses that result in every `mount()` call. Therefore the options
71
+ * type of `mount` holds no `registryResult`: `createRenderer` always gives it, and
72
+ * you cannot replace it.
71
73
  *
72
- * If you need to call `registryResult.executeAction()` programmatically (outside the emit/on
73
- * flow), or pass additional provider options (`navigate`, `onRenderError`, `functions`, etc.),
74
- * use `createPlayUI` (which accepts the full `CreatePlayUIOptions`) or `defineRegistry` with
75
- * `PlayRenderer` directly rather than `createRenderer`.
74
+ * Two situations need a different function. In the first, your code calls
75
+ * `registryResult.executeAction()` itself, outside the emit and on flow. In the
76
+ * second, you give more provider options, such as `navigate`, `onRenderError`, or
77
+ * `functions`. Use `createPlayUI`, which accepts the complete
78
+ * `CreatePlayUIOptions`. You can also use `defineRegistry` with `PlayRenderer`
79
+ * directly.
76
80
  */
77
81
  export function createRenderer(catalog, componentMap) {
78
82
  const registryResult = defineRegistry(catalog, { components: componentMap });
@@ -1 +1 @@
1
- {"version":3,"file":"create-renderer.js","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;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U,EAAE,CAAC;IACpC,CAAC,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  /**
2
- * @xmachines/play-dom — Vanilla DOM renderer for XMachines Play architecture.
2
+ * @xmachines/play-dom — the vanilla DOM renderer of the XMachines Play architecture.
3
3
  *
4
- * Public API split into two layers:
4
+ * The public API has two layers:
5
5
  *
6
- * **XMachines layer** (this package):
7
- * - `createRenderer()` — one-call factory: returns `mount(actor, container, options?) → disconnect`
8
- * - `createPlayUI()` — batteries-included factory with full options: returns `MountFn`
9
- * - `PlayRenderer` — class-based renderer with `connect()` / `disconnect()` lifecycle
6
+ * **The XMachines layer**, in this package:
7
+ * - `createRenderer()` — the one-call factory. It returns `mount(actor, container, options?) → disconnect`
8
+ * - `createPlayUI()` — the complete factory, with every option. It returns a `MountFn`
9
+ * - `PlayRenderer` — the renderer class, with a `connect()` and `disconnect()` lifecycle
10
10
  * - `PlayDomOptions`, `CreatePlayUIOptions`, `MountFn`, `MountOptions`
11
11
  *
12
- * **json-render layer** (re-exported from @xmachines/json-render-dom):
13
- * - `defineRegistry` — build a catalog-typed DomRegistry
14
- * - `renderSpec` — pure Spec → DOM renderer (uses resolveElementProps from core)
15
- * - `ComponentFn` — catalog-typed component function type
16
- * - `ComponentContext` — catalog-typed render context (props, emit, on, children, bindings)
17
- * - `ComponentRegistry` — catalog-typed registry input type
18
- * - `DomComponentRenderer` — raw element-level renderer type
19
- * - `DomRegistry` — raw registry type
20
- * - `DomRenderContext` — raw render context
21
- * - `EventHandle` — event handle returned by on()
22
- * - `SetState` — state updater function passed to ActionFn
23
- * - `CatalogHasActions` — conditional type: true when catalog declares actions
24
- * - `BaseComponentProps` — base props type for catalog component definitions
12
+ * **The json-render layer**, re-exported from @xmachines/json-render-dom:
13
+ * - `defineRegistry` — it builds a catalog-typed DomRegistry
14
+ * - `renderSpec` — the pure Spec → DOM renderer. It uses resolveElementProps of the core
15
+ * - `ComponentFn` — the catalog-typed type of a component function
16
+ * - `ComponentContext` — the catalog-typed render context: props, emit, on, children, bindings
17
+ * - `ComponentRegistry` — the catalog-typed input type of the registry
18
+ * - `DomComponentRenderer` — the raw renderer type of one element
19
+ * - `DomRegistry` — the raw registry type
20
+ * - `DomRenderContext` — the raw render context
21
+ * - `EventHandle` — the event handle that on() returns
22
+ * - `SetState` — the state updater function of an ActionFn
23
+ * - `CatalogHasActions` — the conditional type. It is true when the catalog declares an action
24
+ * - `BaseComponentProps` — the base props type of a catalog component definition
25
25
  *
26
26
  * @packageDocumentation
27
27
  */
package/dist/index.js CHANGED
@@ -1,34 +1,34 @@
1
1
  /**
2
- * @xmachines/play-dom — Vanilla DOM renderer for XMachines Play architecture.
2
+ * @xmachines/play-dom — the vanilla DOM renderer of the XMachines Play architecture.
3
3
  *
4
- * Public API split into two layers:
4
+ * The public API has two layers:
5
5
  *
6
- * **XMachines layer** (this package):
7
- * - `createRenderer()` — one-call factory: returns `mount(actor, container, options?) → disconnect`
8
- * - `createPlayUI()` — batteries-included factory with full options: returns `MountFn`
9
- * - `PlayRenderer` — class-based renderer with `connect()` / `disconnect()` lifecycle
6
+ * **The XMachines layer**, in this package:
7
+ * - `createRenderer()` — the one-call factory. It returns `mount(actor, container, options?) → disconnect`
8
+ * - `createPlayUI()` — the complete factory, with every option. It returns a `MountFn`
9
+ * - `PlayRenderer` — the renderer class, with a `connect()` and `disconnect()` lifecycle
10
10
  * - `PlayDomOptions`, `CreatePlayUIOptions`, `MountFn`, `MountOptions`
11
11
  *
12
- * **json-render layer** (re-exported from @xmachines/json-render-dom):
13
- * - `defineRegistry` — build a catalog-typed DomRegistry
14
- * - `renderSpec` — pure Spec → DOM renderer (uses resolveElementProps from core)
15
- * - `ComponentFn` — catalog-typed component function type
16
- * - `ComponentContext` — catalog-typed render context (props, emit, on, children, bindings)
17
- * - `ComponentRegistry` — catalog-typed registry input type
18
- * - `DomComponentRenderer` — raw element-level renderer type
19
- * - `DomRegistry` — raw registry type
20
- * - `DomRenderContext` — raw render context
21
- * - `EventHandle` — event handle returned by on()
22
- * - `SetState` — state updater function passed to ActionFn
23
- * - `CatalogHasActions` — conditional type: true when catalog declares actions
24
- * - `BaseComponentProps` — base props type for catalog component definitions
12
+ * **The json-render layer**, re-exported from @xmachines/json-render-dom:
13
+ * - `defineRegistry` — it builds a catalog-typed DomRegistry
14
+ * - `renderSpec` — the pure Spec → DOM renderer. It uses resolveElementProps of the core
15
+ * - `ComponentFn` — the catalog-typed type of a component function
16
+ * - `ComponentContext` — the catalog-typed render context: props, emit, on, children, bindings
17
+ * - `ComponentRegistry` — the catalog-typed input type of the registry
18
+ * - `DomComponentRenderer` — the raw renderer type of one element
19
+ * - `DomRegistry` — the raw registry type
20
+ * - `DomRenderContext` — the raw render context
21
+ * - `EventHandle` — the event handle that on() returns
22
+ * - `SetState` — the state updater function of an ActionFn
23
+ * - `CatalogHasActions` — the conditional type. It is true when the catalog declares an action
24
+ * - `BaseComponentProps` — the base props type of a catalog component definition
25
25
  *
26
26
  * @packageDocumentation
27
27
  */
28
- // XMachines integration layer
28
+ // The integration layer of XMachines
29
29
  export { PlayRenderer } from "./PlayRenderer.js";
30
30
  export { createRenderer } from "./create-renderer.js";
31
31
  export { createPlayUI } from "./create-play-ui.js";
32
- // @xmachines/json-render-dom (re-exported for consumer convenience)
32
+ // @xmachines/json-render-dom. This package re-exports it, for the convenience of a consumer
33
33
  export { defineRegistry, renderSpec, schema, createValidationRegistry, } from "@xmachines/json-render-dom";
34
34
  //# 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,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,oEAAoE;AACpE,OAAO,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,wBAAwB,GACxB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,4FAA4F;AAC5F,OAAO,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,wBAAwB,GACxB,MAAM,4BAA4B,CAAC"}