@xmachines/play-vue 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.
@@ -2,38 +2,45 @@ import { inject } from "vue";
2
2
  import { assertNonNullable } from "@xmachines/play";
3
3
  //#region packages/play-vue/src/actor-provider-context.ts
4
4
  /**
5
- * ViewContextValue and getPlayViewContext — shared context types for Vue provider architecture.
5
+ * ViewContextValue and usePlayViewthe shared context types of the Vue provider architecture.
6
6
  *
7
- * Extracted from ActorProvider.vue so TypeScript can re-export these types from index.ts.
8
- * (The vue-shim.d.ts only declares a default export from *.vue files, so named exports
9
- * from .vue SFCs are not visible to TypeScript's re-export resolution.)
7
+ * This file holds them, and not ActorProvider.vue, so that TypeScript can
8
+ * re-export the types from index.ts. (The file vue-shim.d.ts declares a default
9
+ * export of each *.vue file only. Therefore TypeScript does not see a named export
10
+ * of a .vue SFC when it resolves a re-export.)
10
11
  *
11
12
  * @packageDocumentation
12
13
  */
13
14
  /**
14
- * Injection key for the ViewContextValue. Exported so ActorProvider.vue can use it
15
- * as the canonical key without re-declaring.
15
+ * The injection key of the ViewContextValue. This file exports it, so that
16
+ * ActorProvider.vue uses it as the canonical key and declares no second key.
16
17
  *
17
- * @internal Use getPlayViewContext() as the public API; do not inject ViewKey directly.
18
+ * @internal Use usePlayView() as the public API. Never inject ViewKey directly.
18
19
  */
19
20
  var ViewKey = Symbol("xmachines.view");
20
21
  /**
21
- * Access the current ViewContextValue from inside an ActorProvider tree.
22
+ * Returns the current ViewContextValue inside an ActorProvider tree.
22
23
  *
23
- * @throws {Error} If called outside an <ActorProvider> (or <PlayUIProvider>) tree
24
+ * @throws {Error} When the caller is outside an <ActorProvider> tree or a <PlayUIProvider> tree
24
25
  *
25
26
  * @example
26
27
  * ```typescript
27
- * import { getPlayViewContext } from "@xmachines/play-vue";
28
+ * import { usePlayView } from "@xmachines/play-vue";
28
29
  *
29
- * const view = getPlayViewContext();
30
+ * const view = usePlayView();
30
31
  * // view.spec, view.handlers, view.registry
31
32
  * ```
32
33
  */
33
- function getPlayViewContext() {
34
+ function usePlayView() {
34
35
  return assertNonNullable(inject(ViewKey), "ViewKey");
35
36
  }
37
+ /**
38
+ * Access the current ViewContextValue from inside an ActorProvider tree.
39
+ *
40
+ * @deprecated Renamed to {@link usePlayView}; will be removed in the next major.
41
+ */
42
+ var getPlayViewContext = usePlayView;
36
43
  //#endregion
37
- export { ViewKey, getPlayViewContext };
44
+ export { ViewKey, getPlayViewContext, usePlayView };
38
45
 
39
46
  //# sourceMappingURL=actor-provider-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actor-provider-context.js","names":[],"sources":["../src/actor-provider-context.ts"],"sourcesContent":["/**\n * ViewContextValue and getPlayViewContext — shared context types for Vue provider architecture.\n *\n * Extracted from ActorProvider.vue so TypeScript can re-export these types from index.ts.\n * (The vue-shim.d.ts only declares a default export from *.vue files, so named exports\n * from .vue SFCs are not visible to TypeScript's re-export resolution.)\n *\n * @packageDocumentation\n */\n\nimport { inject } from \"vue\";\nimport type { InjectionKey } from \"vue\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport type { ComponentRegistry } from \"@xmachines/json-render-vue\";\nimport type { BaseViewContextValue } from \"@xmachines/play-actor\";\n\n/**\n * Context value provided by ActorProvider and consumed by PlayRenderer (zero-prop leaf).\n * Accessible via getPlayViewContext() inside any ActorProvider/PlayUIProvider tree.\n */\nexport interface ViewContextValue extends BaseViewContextValue<ComponentRegistry> {}\n\n/**\n * Injection key for the ViewContextValue. Exported so ActorProvider.vue can use it\n * as the canonical key without re-declaring.\n *\n * @internal Use getPlayViewContext() as the public API; do not inject ViewKey directly.\n */\nexport const ViewKey: InjectionKey<ViewContextValue> = Symbol(\"xmachines.view\");\n\n/**\n * Access the current ViewContextValue from inside an ActorProvider tree.\n *\n * @throws {Error} If called outside an <ActorProvider> (or <PlayUIProvider>) tree\n *\n * @example\n * ```typescript\n * import { getPlayViewContext } from \"@xmachines/play-vue\";\n *\n * const view = getPlayViewContext();\n * // view.spec, view.handlers, view.registry\n * ```\n */\nexport function getPlayViewContext(): ViewContextValue {\n\treturn assertNonNullable(inject(ViewKey), \"ViewKey\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,IAAa,UAA0C,OAAO,gBAAgB;;;;;;;;;;;;;;AAe9E,SAAgB,qBAAuC;CACtD,OAAO,kBAAkB,OAAO,OAAO,GAAG,SAAS;AACpD"}
1
+ {"version":3,"file":"actor-provider-context.js","names":[],"sources":["../src/actor-provider-context.ts"],"sourcesContent":["/**\n * ViewContextValue and usePlayViewthe shared context types of the Vue provider architecture.\n *\n * This file holds them, and not ActorProvider.vue, so that TypeScript can\n * re-export the types from index.ts. (The file vue-shim.d.ts declares a default\n * export of each *.vue file only. Therefore TypeScript does not see a named export\n * of a .vue SFC when it resolves a re-export.)\n *\n * @packageDocumentation\n */\n\nimport { inject } from \"vue\";\nimport type { InjectionKey } from \"vue\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport type { ComponentRegistry } from \"@xmachines/json-render-vue\";\nimport type { BaseViewContextValue } from \"@xmachines/play-actor\";\n\n/**\n * The context value that ActorProvider provides and PlayRenderer, the leaf without\n * props, reads. usePlayView() gives it inside every ActorProvider tree and\n * PlayUIProvider tree.\n */\nexport interface ViewContextValue extends BaseViewContextValue<ComponentRegistry> {}\n\n/**\n * The injection key of the ViewContextValue. This file exports it, so that\n * ActorProvider.vue uses it as the canonical key and declares no second key.\n *\n * @internal Use usePlayView() as the public API. Never inject ViewKey directly.\n */\nexport const ViewKey: InjectionKey<ViewContextValue> = Symbol(\"xmachines.view\");\n\n/**\n * Returns the current ViewContextValue inside an ActorProvider tree.\n *\n * @throws {Error} When the caller is outside an <ActorProvider> tree or a <PlayUIProvider> tree\n *\n * @example\n * ```typescript\n * import { usePlayView } from \"@xmachines/play-vue\";\n *\n * const view = usePlayView();\n * // view.spec, view.handlers, view.registry\n * ```\n */\nexport function usePlayView(): ViewContextValue {\n\treturn assertNonNullable(inject(ViewKey), \"ViewKey\");\n}\n\n/**\n * Access the current ViewContextValue from inside an ActorProvider tree.\n *\n * @deprecated Renamed to {@link usePlayView}; will be removed in the next major.\n */\nexport const getPlayViewContext = usePlayView;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,IAAa,UAA0C,OAAO,gBAAgB;;;;;;;;;;;;;;AAe9E,SAAgB,cAAgC;CAC/C,OAAO,kBAAkB,OAAO,OAAO,GAAG,SAAS;AACpD;;;;;;AAOA,IAAa,qBAAqB"}
@@ -1,40 +1,44 @@
1
1
  /**
2
- * `defineRegistry` wrapper for @xmachines/play-vue.
2
+ * The `defineRegistry` wrapper of @xmachines/play-vue.
3
3
  *
4
- * Wraps `defineRegistry` from `@xmachines/json-render-vue` with automatic SFC support.
4
+ * It wraps `defineRegistry` from `@xmachines/json-render-vue`, and it adds support
5
+ * for an SFC.
5
6
  *
6
- * ## Vue-specific — React and Solid do not need this
7
+ * ## Vue only — React and Solid do not need this wrapper
7
8
  *
8
- * In React, `useContext()` works anywhere inside the component call tree.
9
- * In Solid, `useContext()` works inside reactive computations and component renders.
10
- * Neither has the strict "synchronous setup() only" constraint that Vue's `inject()`
11
- * imposes so their `defineRegistry` implementations call `componentFn(ctx)` directly
12
- * with no wrapping needed.
9
+ * In React, `useContext()` works everywhere inside the component call tree. In
10
+ * Solid, `useContext()` works inside a reactive computation and inside a component
11
+ * render. Neither framework has the strict rule of the Vue function `inject()`,
12
+ * which runs during a synchronous `setup()` only. Therefore the `defineRegistry`
13
+ * implementation of each of them calls `componentFn(ctx)` directly, and it wraps
14
+ * nothing.
13
15
  *
14
- * For the DOM renderer, there is no component system at all just render functions
15
- * returning `HTMLElement` so injection context is not applicable.
16
+ * The DOM renderer has no component system at all. It has render functions that
17
+ * return an `HTMLElement`. An injection context is therefore not relevant.
16
18
  *
17
- * Only Vue requires this adapter.
19
+ * Vue alone needs this adapter.
18
20
  *
19
- * ## Why this wrapper exists
21
+ * ## The reason for this wrapper
20
22
  *
21
- * `@xmachines/json-render-vue`'s `defineRegistry` calls each registered component as a plain
22
- * function: `componentFn(ctx)`. A `.vue` SFC (output of `defineComponent` or
23
- * `<script setup>`) is an **object**, not a function — calling it throws.
23
+ * The `defineRegistry` function of `@xmachines/json-render-vue` calls each
24
+ * registered component as a plain function: `componentFn(ctx)`. A `.vue` SFC, which
25
+ * is the output of `defineComponent` or of `<script setup>`, is an **object**, not a
26
+ * function. A call to that object throws.
24
27
  *
25
- * More fundamentally, `defineRegistry` calls components inside its own render
26
- * function (the return value of `setup()`). Vue's `inject()` — and composables built
27
- * on it: `useStateBinding`, `useStateStore` only work during synchronous `setup()`
28
- * execution, not inside render functions. Plain `.ts` `ComponentFn` files cannot
29
- * call any Vue composable for this reason.
28
+ * There is a second and deeper reason. `defineRegistry` calls each component inside
29
+ * its own render function, which is the return value of `setup()`. The Vue function
30
+ * `inject()`, and each composable on it, such as `useStateBinding` and
31
+ * `useStateStore`, works during the synchronous run of `setup()` only, not inside a
32
+ * render function. For this reason a plain `.ts` `ComponentFn` file can call no Vue
33
+ * composable.
30
34
  *
31
- * This wrapper auto-detects Vue SFCs in the `components` map and wraps them via
32
- * `h(SFC, ctx)`. The SFC renders as a child component with its own `setup()`,
33
- * giving full access to composables inside `<script setup>`.
35
+ * This wrapper finds each Vue SFC in the `components` map, and it wraps the SFC with
36
+ * `h(SFC, ctx)`. The SFC then renders as a child component with its own `setup()`,
37
+ * and every composable works inside `<script setup>`.
34
38
  *
35
- * ## Usage
39
+ * ## Use
36
40
  *
37
- * Import `defineRegistry` from `@xmachines/play-vue` instead of `@xmachines/json-render-vue`:
41
+ * Import `defineRegistry` from `@xmachines/play-vue`, not from `@xmachines/json-render-vue`:
38
42
  *
39
43
  * ```ts
40
44
  * import { defineRegistry } from "@xmachines/play-vue";
@@ -45,14 +49,14 @@
45
49
  *
46
50
  * const { registry } = defineRegistry(catalog, {
47
51
  * components: {
48
- * Login: LoginSFC, // .vue SFC — auto-wrapped
49
- * Dashboard: DashboardSFC, // .vue SFC — auto-wrapped
52
+ * Login: LoginSFC, // a .vue SFC — the wrapper handles it
53
+ * Dashboard: DashboardSFC, // a .vue SFC — the wrapper handles it
50
54
  * },
51
55
  * });
52
56
  * ```
53
57
  *
54
- * Plain `ComponentFn` functions still work and are passed through unchanged.
55
- * Mixing SFCs and plain functions in the same registry is supported.
58
+ * A plain `ComponentFn` function also works, and the wrapper passes it through
59
+ * without a change. One registry can hold both SFCs and plain functions.
56
60
  */
57
61
  import { type Component } from "vue";
58
62
  import { defineRegistry as defineRegistryBase, type ComponentFn } from "@xmachines/json-render-vue";
@@ -65,15 +69,16 @@ export type DefineRegistryOptions<C extends Catalog> = Omit<Parameters<typeof de
65
69
  components?: ComponentsMap<C>;
66
70
  };
67
71
  /**
68
- * Create a component registry, automatically wrapping `.vue` SFCs so they work
69
- * correctly with `@xmachines/json-render-vue`'s rendering pipeline.
72
+ * Creates a component registry. It wraps each `.vue` SFC, so that the SFC works
73
+ * correctly with the render pipeline of `@xmachines/json-render-vue`.
70
74
  *
71
- * Drop-in replacement for `defineRegistry` from `@xmachines/json-render-vue`. Import from
72
- * `@xmachines/play-vue` to get SFC support for free.
75
+ * This function is the drop-in replacement for `defineRegistry` from
76
+ * `@xmachines/json-render-vue`. Import it from `@xmachines/play-vue`, and you get
77
+ * the support for an SFC.
73
78
  *
74
- * @param catalog - The json-render catalog defining component prop shapes.
75
- * @param options - Registry options. `components` entries may be `.vue` SFCs
76
- * (objects) or plain `ComponentFn` functions both are handled automatically.
79
+ * @param catalog - The json-render catalog. It defines the prop shape of each component.
80
+ * @param options - The registry options. Each `components` entry is a `.vue` SFC,
81
+ * which is an object, or a plain `ComponentFn` function. The wrapper handles both.
77
82
  */
78
83
  export declare function defineRegistry<C extends Catalog>(catalog: C, options: DefineRegistryOptions<C>): ReturnType<typeof defineRegistryBase<C>>;
79
84
  //# sourceMappingURL=define-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-registry.d.ts","sourceRoot":"","sources":["../src/define-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAAK,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EACN,cAAc,IAAI,kBAAkB,EAEpC,KAAK,WAAW,EAEhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAwCnF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,MAAM,sBAAsB,CAAC,CAAC,CAAC,IACpF,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GACjB,SAAS,CAAC;AAEb,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,OAAO,IAAI;KAC7C,CAAC,IAAI,MAAM,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,OAAO,IAAI,IAAI,CAC1D,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3C,YAAY,CACZ,GAAG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAC/C,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAC/B,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAa1C"}
1
+ {"version":3,"file":"define-registry.d.ts","sourceRoot":"","sources":["../src/define-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAK,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EACN,cAAc,IAAI,kBAAkB,EAEpC,KAAK,WAAW,EAEhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AA0CnF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,MAAM,sBAAsB,CAAC,CAAC,CAAC,IACpF,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GACjB,SAAS,CAAC;AAEb,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,OAAO,IAAI;KAC7C,CAAC,IAAI,MAAM,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,OAAO,IAAI,IAAI,CAC1D,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3C,YAAY,CACZ,GAAG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAC/C,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAC/B,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAa1C"}
@@ -2,42 +2,46 @@ import { h } from "vue";
2
2
  import { defineRegistry } from "@xmachines/json-render-vue";
3
3
  //#region packages/play-vue/src/define-registry.ts
4
4
  /**
5
- * `defineRegistry` wrapper for @xmachines/play-vue.
5
+ * The `defineRegistry` wrapper of @xmachines/play-vue.
6
6
  *
7
- * Wraps `defineRegistry` from `@xmachines/json-render-vue` with automatic SFC support.
7
+ * It wraps `defineRegistry` from `@xmachines/json-render-vue`, and it adds support
8
+ * for an SFC.
8
9
  *
9
- * ## Vue-specific — React and Solid do not need this
10
+ * ## Vue only — React and Solid do not need this wrapper
10
11
  *
11
- * In React, `useContext()` works anywhere inside the component call tree.
12
- * In Solid, `useContext()` works inside reactive computations and component renders.
13
- * Neither has the strict "synchronous setup() only" constraint that Vue's `inject()`
14
- * imposes so their `defineRegistry` implementations call `componentFn(ctx)` directly
15
- * with no wrapping needed.
12
+ * In React, `useContext()` works everywhere inside the component call tree. In
13
+ * Solid, `useContext()` works inside a reactive computation and inside a component
14
+ * render. Neither framework has the strict rule of the Vue function `inject()`,
15
+ * which runs during a synchronous `setup()` only. Therefore the `defineRegistry`
16
+ * implementation of each of them calls `componentFn(ctx)` directly, and it wraps
17
+ * nothing.
16
18
  *
17
- * For the DOM renderer, there is no component system at all just render functions
18
- * returning `HTMLElement` so injection context is not applicable.
19
+ * The DOM renderer has no component system at all. It has render functions that
20
+ * return an `HTMLElement`. An injection context is therefore not relevant.
19
21
  *
20
- * Only Vue requires this adapter.
22
+ * Vue alone needs this adapter.
21
23
  *
22
- * ## Why this wrapper exists
24
+ * ## The reason for this wrapper
23
25
  *
24
- * `@xmachines/json-render-vue`'s `defineRegistry` calls each registered component as a plain
25
- * function: `componentFn(ctx)`. A `.vue` SFC (output of `defineComponent` or
26
- * `<script setup>`) is an **object**, not a function — calling it throws.
26
+ * The `defineRegistry` function of `@xmachines/json-render-vue` calls each
27
+ * registered component as a plain function: `componentFn(ctx)`. A `.vue` SFC, which
28
+ * is the output of `defineComponent` or of `<script setup>`, is an **object**, not a
29
+ * function. A call to that object throws.
27
30
  *
28
- * More fundamentally, `defineRegistry` calls components inside its own render
29
- * function (the return value of `setup()`). Vue's `inject()` — and composables built
30
- * on it: `useStateBinding`, `useStateStore` only work during synchronous `setup()`
31
- * execution, not inside render functions. Plain `.ts` `ComponentFn` files cannot
32
- * call any Vue composable for this reason.
31
+ * There is a second and deeper reason. `defineRegistry` calls each component inside
32
+ * its own render function, which is the return value of `setup()`. The Vue function
33
+ * `inject()`, and each composable on it, such as `useStateBinding` and
34
+ * `useStateStore`, works during the synchronous run of `setup()` only, not inside a
35
+ * render function. For this reason a plain `.ts` `ComponentFn` file can call no Vue
36
+ * composable.
33
37
  *
34
- * This wrapper auto-detects Vue SFCs in the `components` map and wraps them via
35
- * `h(SFC, ctx)`. The SFC renders as a child component with its own `setup()`,
36
- * giving full access to composables inside `<script setup>`.
38
+ * This wrapper finds each Vue SFC in the `components` map, and it wraps the SFC with
39
+ * `h(SFC, ctx)`. The SFC then renders as a child component with its own `setup()`,
40
+ * and every composable works inside `<script setup>`.
37
41
  *
38
- * ## Usage
42
+ * ## Use
39
43
  *
40
- * Import `defineRegistry` from `@xmachines/play-vue` instead of `@xmachines/json-render-vue`:
44
+ * Import `defineRegistry` from `@xmachines/play-vue`, not from `@xmachines/json-render-vue`:
41
45
  *
42
46
  * ```ts
43
47
  * import { defineRegistry } from "@xmachines/play-vue";
@@ -48,31 +52,32 @@ import { defineRegistry } from "@xmachines/json-render-vue";
48
52
  *
49
53
  * const { registry } = defineRegistry(catalog, {
50
54
  * components: {
51
- * Login: LoginSFC, // .vue SFC — auto-wrapped
52
- * Dashboard: DashboardSFC, // .vue SFC — auto-wrapped
55
+ * Login: LoginSFC, // a .vue SFC — the wrapper handles it
56
+ * Dashboard: DashboardSFC, // a .vue SFC — the wrapper handles it
53
57
  * },
54
58
  * });
55
59
  * ```
56
60
  *
57
- * Plain `ComponentFn` functions still work and are passed through unchanged.
58
- * Mixing SFCs and plain functions in the same registry is supported.
61
+ * A plain `ComponentFn` function also works, and the wrapper passes it through
62
+ * without a change. One registry can hold both SFCs and plain functions.
59
63
  */
60
64
  /**
61
- * Detect whether a value is a Vue component object (SFC) rather than a plain
65
+ * Tells you if a value is a Vue component object, which is an SFC, and not a plain
62
66
  * `ComponentFn` function.
63
67
  *
64
- * Vue SFCs produced by `defineComponent` or `<script setup>` compilation are
65
- * plain objects (not callable). A `ComponentFn` is always a plain function.
68
+ * A Vue SFC from `defineComponent` or from the compilation of `<script setup>` is a
69
+ * plain object, and a call to it is not possible. A `ComponentFn` is always a plain
70
+ * function.
66
71
  *
67
- * Detection strategy (checked in order):
68
- * 1. `__vccOpts` — set by vite-plugin-vue / vue-loader on every `<script setup>` SFC.
69
- * 2. `__name` — set by Vite on named SFCs (present alongside `__vccOpts` but also
70
- * on `defineComponent({ name: "..." })` output without `<script setup>`).
71
- * 3. `setup` is a function — the `defineComponent({ setup() {} })` signature.
72
- * 4. `render` is a function — the `defineComponent({ render() {} })` signature.
72
+ * The function makes four tests, in this order:
73
+ * 1. `__vccOpts` — vite-plugin-vue and vue-loader set it on every `<script setup>` SFC.
74
+ * 2. `__name` — Vite sets it on a named SFC. It is present beside `__vccOpts`, and
75
+ * also on the output of `defineComponent({ name: "..." })` without `<script setup>`.
76
+ * 3. `setup` is a function — this is the `defineComponent({ setup() {} })` signature.
77
+ * 4. `render` is a function — this is the `defineComponent({ render() {} })` signature.
73
78
  *
74
- * Requiring `setup` / `render` to be **functions** prevents plain POJOs that
75
- * happen to have a `setup` or `render` key from being misidentified as components.
79
+ * Tests 3 and 4 require a **function**. A plain object with a `setup` key or a
80
+ * `render` key is therefore not a component for this function.
76
81
  */
77
82
  function isVueSFC(value) {
78
83
  if (typeof value !== "object" || value === null) return false;
@@ -81,24 +86,26 @@ function isVueSFC(value) {
81
86
  return typeof v["setup"] === "function" || typeof v["render"] === "function";
82
87
  }
83
88
  /**
84
- * Wrap a Vue SFC as a `ComponentFn` by rendering it via `h()`.
89
+ * Wraps a Vue SFC as a `ComponentFn`, and renders it with `h()`.
85
90
  *
86
- * The SFC receives the full `ComponentContext` as its props and renders in its
87
- * own child component `setup()`, where Vue composables work correctly.
91
+ * The SFC receives the complete `ComponentContext` as its props. It renders in the
92
+ * `setup()` function of its own child component, where each Vue composable works
93
+ * correctly.
88
94
  */
89
95
  function wrapSFC(component) {
90
96
  return (ctx) => h(component, ctx);
91
97
  }
92
98
  /**
93
- * Create a component registry, automatically wrapping `.vue` SFCs so they work
94
- * correctly with `@xmachines/json-render-vue`'s rendering pipeline.
99
+ * Creates a component registry. It wraps each `.vue` SFC, so that the SFC works
100
+ * correctly with the render pipeline of `@xmachines/json-render-vue`.
95
101
  *
96
- * Drop-in replacement for `defineRegistry` from `@xmachines/json-render-vue`. Import from
97
- * `@xmachines/play-vue` to get SFC support for free.
102
+ * This function is the drop-in replacement for `defineRegistry` from
103
+ * `@xmachines/json-render-vue`. Import it from `@xmachines/play-vue`, and you get
104
+ * the support for an SFC.
98
105
  *
99
- * @param catalog - The json-render catalog defining component prop shapes.
100
- * @param options - Registry options. `components` entries may be `.vue` SFCs
101
- * (objects) or plain `ComponentFn` functions both are handled automatically.
106
+ * @param catalog - The json-render catalog. It defines the prop shape of each component.
107
+ * @param options - The registry options. Each `components` entry is a `.vue` SFC,
108
+ * which is an object, or a plain `ComponentFn` function. The wrapper handles both.
102
109
  */
103
110
  function defineRegistry$1(catalog, options) {
104
111
  const wrappedComponents = {};
@@ -1 +1 @@
1
- {"version":3,"file":"define-registry.js","names":[],"sources":["../src/define-registry.ts"],"sourcesContent":["/**\n * `defineRegistry` wrapper for @xmachines/play-vue.\n *\n * Wraps `defineRegistry` from `@xmachines/json-render-vue` with automatic SFC support.\n *\n * ## Vue-specific — React and Solid do not need this\n *\n * In React, `useContext()` works anywhere inside the component call tree.\n * In Solid, `useContext()` works inside reactive computations and component renders.\n * Neither has the strict \"synchronous setup() only\" constraint that Vue's `inject()`\n * imposes so their `defineRegistry` implementations call `componentFn(ctx)` directly\n * with no wrapping needed.\n *\n * For the DOM renderer, there is no component system at all just render functions\n * returning `HTMLElement` so injection context is not applicable.\n *\n * Only Vue requires this adapter.\n *\n * ## Why this wrapper exists\n *\n * `@xmachines/json-render-vue`'s `defineRegistry` calls each registered component as a plain\n * function: `componentFn(ctx)`. A `.vue` SFC (output of `defineComponent` or\n * `<script setup>`) is an **object**, not a function calling it throws.\n *\n * More fundamentally, `defineRegistry` calls components inside its own render\n * function (the return value of `setup()`). Vue's `inject()` and composables built\n * on it: `useStateBinding`, `useStateStore` only work during synchronous `setup()`\n * execution, not inside render functions. Plain `.ts` `ComponentFn` files cannot\n * call any Vue composable for this reason.\n *\n * This wrapper auto-detects Vue SFCs in the `components` map and wraps them via\n * `h(SFC, ctx)`. The SFC renders as a child component with its own `setup()`,\n * giving full access to composables inside `<script setup>`.\n *\n * ## Usage\n *\n * Import `defineRegistry` from `@xmachines/play-vue` instead of `@xmachines/json-render-vue`:\n *\n * ```ts\n * import { defineRegistry } from \"@xmachines/play-vue\";\n * // not: import { defineRegistry } from \"@xmachines/json-render-vue\";\n *\n * import LoginSFC from \"./views/Login.vue\";\n * import DashboardSFC from \"./views/Dashboard.vue\";\n *\n * const { registry } = defineRegistry(catalog, {\n * components: {\n * Login: LoginSFC, // .vue SFC — auto-wrapped\n * Dashboard: DashboardSFC, // .vue SFC — auto-wrapped\n * },\n * });\n * ```\n *\n * Plain `ComponentFn` functions still work and are passed through unchanged.\n * Mixing SFCs and plain functions in the same registry is supported.\n */\n\nimport { h, type Component } from \"vue\";\nimport {\n\tdefineRegistry as defineRegistryBase,\n\ttype ComponentContext,\n\ttype ComponentFn,\n\ttype Components,\n} from \"@xmachines/json-render-vue\";\nimport type { Catalog, InferCatalogComponents } from \"@xmachines/json-render-core\";\n\n/**\n * Detect whether a value is a Vue component object (SFC) rather than a plain\n * `ComponentFn` function.\n *\n * Vue SFCs produced by `defineComponent` or `<script setup>` compilation are\n * plain objects (not callable). A `ComponentFn` is always a plain function.\n *\n * Detection strategy (checked in order):\n * 1. `__vccOpts` — set by vite-plugin-vue / vue-loader on every `<script setup>` SFC.\n * 2. `__name` — set by Vite on named SFCs (present alongside `__vccOpts` but also\n * on `defineComponent({ name: \"...\" })` output without `<script setup>`).\n * 3. `setup` is a function — the `defineComponent({ setup() {} })` signature.\n * 4. `render` is a function — the `defineComponent({ render() {} })` signature.\n *\n * Requiring `setup` / `render` to be **functions** prevents plain POJOs that\n * happen to have a `setup` or `render` key from being misidentified as components.\n */\nfunction isVueSFC(value: unknown): value is Component {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst v = value as Record<string, unknown>;\n\t// Compiler-injected markers unambiguous Vue component identifiers.\n\tif (\"__vccOpts\" in v || \"__name\" in v) return true;\n\t// defineComponent() output: setup or render must be callable, not just present.\n\treturn typeof v[\"setup\"] === \"function\" || typeof v[\"render\"] === \"function\";\n}\n\n/**\n * Wrap a Vue SFC as a `ComponentFn` by rendering it via `h()`.\n *\n * The SFC receives the full `ComponentContext` as its props and renders in its\n * own child component `setup()`, where Vue composables work correctly.\n */\nfunction wrapSFC<C extends Catalog, K extends keyof InferCatalogComponents<C>>(\n\tcomponent: Component,\n): ComponentFn<C, K> {\n\treturn (ctx: ComponentContext<C, K>) => h(component, ctx);\n}\n\nexport type ComponentEntry<C extends Catalog, K extends keyof InferCatalogComponents<C>> =\n\t| ComponentFn<C, K>\n\t| Component;\n\nexport type ComponentsMap<C extends Catalog> = {\n\t[K in keyof InferCatalogComponents<C>]?: ComponentEntry<C, K>;\n};\n\nexport type DefineRegistryOptions<C extends Catalog> = Omit<\n\tParameters<typeof defineRegistryBase<C>>[1],\n\t\"components\"\n> & {\n\tcomponents?: ComponentsMap<C>;\n};\n\n/**\n * Create a component registry, automatically wrapping `.vue` SFCs so they work\n * correctly with `@xmachines/json-render-vue`'s rendering pipeline.\n *\n * Drop-in replacement for `defineRegistry` from `@xmachines/json-render-vue`. Import from\n * `@xmachines/play-vue` to get SFC support for free.\n *\n * @param catalog - The json-render catalog defining component prop shapes.\n * @param options - Registry options. `components` entries may be `.vue` SFCs\n * (objects) or plain `ComponentFn` functions both are handled automatically.\n */\nexport function defineRegistry<C extends Catalog>(\n\tcatalog: C,\n\toptions: DefineRegistryOptions<C>,\n): ReturnType<typeof defineRegistryBase<C>> {\n\tconst wrappedComponents = {} as Components<C>;\n\n\tfor (const [key, component] of Object.entries(options.components ?? {})) {\n\t\tif (component === undefined) continue;\n\t\tconst k = key as keyof InferCatalogComponents<C>;\n\t\twrappedComponents[k] = isVueSFC(component)\n\t\t\t? wrapSFC(component as Component)\n\t\t\t: (component as ComponentFn<C, typeof k>);\n\t}\n\n\tconst baseOptions = options as Parameters<typeof defineRegistryBase<C>>[1];\n\treturn defineRegistryBase(catalog, { ...baseOptions, components: wrappedComponents });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,SAAS,SAAS,OAAoC;CACrD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,IAAI;CAEV,IAAI,eAAe,KAAK,YAAY,GAAG,OAAO;CAE9C,OAAO,OAAO,EAAE,aAAa,cAAc,OAAO,EAAE,cAAc;AACnE;;;;;;;AAQA,SAAS,QACR,WACoB;CACpB,QAAQ,QAAgC,EAAE,WAAW,GAAG;AACzD;;;;;;;;;;;;AA4BA,SAAgB,iBACf,SACA,SAC2C;CAC3C,MAAM,oBAAoB,CAAC;CAE3B,KAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,QAAQ,cAAc,CAAC,CAAC,GAAG;EACxE,IAAI,cAAc,KAAA,GAAW;EAC7B,MAAM,IAAI;EACV,kBAAkB,KAAK,SAAS,SAAS,IACtC,QAAQ,SAAsB,IAC7B;CACL;CAGA,OAAO,eAAmB,SAAS;EAAE,GAAG;EAAa,YAAY;CAAkB,CAAC;AACrF"}
1
+ {"version":3,"file":"define-registry.js","names":[],"sources":["../src/define-registry.ts"],"sourcesContent":["/**\n * The `defineRegistry` wrapper of @xmachines/play-vue.\n *\n * It wraps `defineRegistry` from `@xmachines/json-render-vue`, and it adds support\n * for an SFC.\n *\n * ## Vue only — React and Solid do not need this wrapper\n *\n * In React, `useContext()` works everywhere inside the component call tree. In\n * Solid, `useContext()` works inside a reactive computation and inside a component\n * render. Neither framework has the strict rule of the Vue function `inject()`,\n * which runs during a synchronous `setup()` only. Therefore the `defineRegistry`\n * implementation of each of them calls `componentFn(ctx)` directly, and it wraps\n * nothing.\n *\n * The DOM renderer has no component system at all. It has render functions that\n * return an `HTMLElement`. An injection context is therefore not relevant.\n *\n * Vue alone needs this adapter.\n *\n * ## The reason for this wrapper\n *\n * The `defineRegistry` function of `@xmachines/json-render-vue` calls each\n * registered component as a plain function: `componentFn(ctx)`. A `.vue` SFC, which\n * is the output of `defineComponent` or of `<script setup>`, is an **object**, not a\n * function. A call to that object throws.\n *\n * There is a second and deeper reason. `defineRegistry` calls each component inside\n * its own render function, which is the return value of `setup()`. The Vue function\n * `inject()`, and each composable on it, such as `useStateBinding` and\n * `useStateStore`, works during the synchronous run of `setup()` only, not inside a\n * render function. For this reason a plain `.ts` `ComponentFn` file can call no Vue\n * composable.\n *\n * This wrapper finds each Vue SFC in the `components` map, and it wraps the SFC with\n * `h(SFC, ctx)`. The SFC then renders as a child component with its own `setup()`,\n * and every composable works inside `<script setup>`.\n *\n * ## Use\n *\n * Import `defineRegistry` from `@xmachines/play-vue`, not from `@xmachines/json-render-vue`:\n *\n * ```ts\n * import { defineRegistry } from \"@xmachines/play-vue\";\n * // not: import { defineRegistry } from \"@xmachines/json-render-vue\";\n *\n * import LoginSFC from \"./views/Login.vue\";\n * import DashboardSFC from \"./views/Dashboard.vue\";\n *\n * const { registry } = defineRegistry(catalog, {\n * components: {\n * Login: LoginSFC, // a .vue SFC — the wrapper handles it\n * Dashboard: DashboardSFC, // a .vue SFC — the wrapper handles it\n * },\n * });\n * ```\n *\n * A plain `ComponentFn` function also works, and the wrapper passes it through\n * without a change. One registry can hold both SFCs and plain functions.\n */\n\nimport { h, type Component } from \"vue\";\nimport {\n\tdefineRegistry as defineRegistryBase,\n\ttype ComponentContext,\n\ttype ComponentFn,\n\ttype Components,\n} from \"@xmachines/json-render-vue\";\nimport type { Catalog, InferCatalogComponents } from \"@xmachines/json-render-core\";\n\n/**\n * Tells you if a value is a Vue component object, which is an SFC, and not a plain\n * `ComponentFn` function.\n *\n * A Vue SFC from `defineComponent` or from the compilation of `<script setup>` is a\n * plain object, and a call to it is not possible. A `ComponentFn` is always a plain\n * function.\n *\n * The function makes four tests, in this order:\n * 1. `__vccOpts` — vite-plugin-vue and vue-loader set it on every `<script setup>` SFC.\n * 2. `__name` — Vite sets it on a named SFC. It is present beside `__vccOpts`, and\n * also on the output of `defineComponent({ name: \"...\" })` without `<script setup>`.\n * 3. `setup` is a function — this is the `defineComponent({ setup() {} })` signature.\n * 4. `render` is a function — this is the `defineComponent({ render() {} })` signature.\n *\n * Tests 3 and 4 require a **function**. A plain object with a `setup` key or a\n * `render` key is therefore not a component for this function.\n */\nfunction isVueSFC(value: unknown): value is Component {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst v = value as Record<string, unknown>;\n\t// The markers of the compiler. They identify a Vue component without a doubt.\n\tif (\"__vccOpts\" in v || \"__name\" in v) return true;\n\t// The output of defineComponent(): the code must be able to call setup or render, and their presence is not sufficient.\n\treturn typeof v[\"setup\"] === \"function\" || typeof v[\"render\"] === \"function\";\n}\n\n/**\n * Wraps a Vue SFC as a `ComponentFn`, and renders it with `h()`.\n *\n * The SFC receives the complete `ComponentContext` as its props. It renders in the\n * `setup()` function of its own child component, where each Vue composable works\n * correctly.\n */\nfunction wrapSFC<C extends Catalog, K extends keyof InferCatalogComponents<C>>(\n\tcomponent: Component,\n): ComponentFn<C, K> {\n\treturn (ctx: ComponentContext<C, K>) => h(component, ctx);\n}\n\nexport type ComponentEntry<C extends Catalog, K extends keyof InferCatalogComponents<C>> =\n\t| ComponentFn<C, K>\n\t| Component;\n\nexport type ComponentsMap<C extends Catalog> = {\n\t[K in keyof InferCatalogComponents<C>]?: ComponentEntry<C, K>;\n};\n\nexport type DefineRegistryOptions<C extends Catalog> = Omit<\n\tParameters<typeof defineRegistryBase<C>>[1],\n\t\"components\"\n> & {\n\tcomponents?: ComponentsMap<C>;\n};\n\n/**\n * Creates a component registry. It wraps each `.vue` SFC, so that the SFC works\n * correctly with the render pipeline of `@xmachines/json-render-vue`.\n *\n * This function is the drop-in replacement for `defineRegistry` from\n * `@xmachines/json-render-vue`. Import it from `@xmachines/play-vue`, and you get\n * the support for an SFC.\n *\n * @param catalog - The json-render catalog. It defines the prop shape of each component.\n * @param options - The registry options. Each `components` entry is a `.vue` SFC,\n * which is an object, or a plain `ComponentFn` function. The wrapper handles both.\n */\nexport function defineRegistry<C extends Catalog>(\n\tcatalog: C,\n\toptions: DefineRegistryOptions<C>,\n): ReturnType<typeof defineRegistryBase<C>> {\n\tconst wrappedComponents = {} as Components<C>;\n\n\tfor (const [key, component] of Object.entries(options.components ?? {})) {\n\t\tif (component === undefined) continue;\n\t\tconst k = key as keyof InferCatalogComponents<C>;\n\t\twrappedComponents[k] = isVueSFC(component)\n\t\t\t? wrapSFC(component as Component)\n\t\t\t: (component as ComponentFn<C, typeof k>);\n\t}\n\n\tconst baseOptions = options as Parameters<typeof defineRegistryBase<C>>[1];\n\treturn defineRegistryBase(catalog, { ...baseOptions, components: wrappedComponents });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAS,SAAS,OAAoC;CACrD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,IAAI;CAEV,IAAI,eAAe,KAAK,YAAY,GAAG,OAAO;CAE9C,OAAO,OAAO,EAAE,aAAa,cAAc,OAAO,EAAE,cAAc;AACnE;;;;;;;;AASA,SAAS,QACR,WACoB;CACpB,QAAQ,QAAgC,EAAE,WAAW,GAAG;AACzD;;;;;;;;;;;;;AA6BA,SAAgB,iBACf,SACA,SAC2C;CAC3C,MAAM,oBAAoB,CAAC;CAE3B,KAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,QAAQ,cAAc,CAAC,CAAC,GAAG;EACxE,IAAI,cAAc,KAAA,GAAW;EAC7B,MAAM,IAAI;EACV,kBAAkB,KAAK,SAAS,SAAS,IACtC,QAAQ,SAAsB,IAC7B;CACL;CAGA,OAAO,eAAmB,SAAS;EAAE,GAAG;EAAa,YAAY;CAAkB,CAAC;AACrF"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * @xmachines/play-vue - Vue 3 renderer for XMachines Play architecture
2
+ * @xmachines/play-vue - Vue 3 renderer for the XMachines Play architecture
3
3
  *
4
- * Provides a thin Vue rendering layer that passively observes actor signals
5
- * and renders UI components via @xmachines/json-render-vue. Vue reactivity is only used
6
- * to trigger re-renders signals are the source of truth.
4
+ * This package is a thin Vue rendering layer. It observes the actor signals and
5
+ * renders the UI components with @xmachines/json-render-vue. Vue reactivity only
6
+ * triggers the re-render. The signals are the source of truth.
7
7
  *
8
- * Re-exports `defineRegistry` (SFC-aware auto-wraps `.vue` SFCs via `h()`),
9
- * `useBoundProp`, `ComponentFn`, `ComponentContext`, and all json-render providers
10
- * so consumers import everything from `@xmachines/play-vue` rather than
11
- * `@xmachines/json-render-vue` directly.
8
+ * The package re-exports `defineRegistry`, which knows an SFC and wraps each `.vue`
9
+ * SFC with `h()`. It also re-exports `useBoundProp`, `ComponentFn`,
10
+ * `ComponentContext`, and every json-render provider. A consumer therefore imports
11
+ * everything from `@xmachines/play-vue`, and not from `@xmachines/json-render-vue`.
12
12
  *
13
13
  * @packageDocumentation
14
14
  */
@@ -16,7 +16,7 @@ export { default as PlayRenderer } from "./PlayRenderer.vue";
16
16
  export { default as ActorProvider } from "./ActorProvider.vue";
17
17
  export { default as PlayUIProvider } from "./PlayUIProvider.vue";
18
18
  export type { ActorProviderProps, PlayUIProviderProps, RenderErrorHandler, VisibilityProviderProps, } from "./types.js";
19
- export { getPlayViewContext } from "./actor-provider-context.js";
19
+ export { usePlayView, getPlayViewContext } from "./actor-provider-context.js";
20
20
  export type { ViewContextValue } from "./actor-provider-context.js";
21
21
  export { useActor } from "./useActor.js";
22
22
  export type { AnyPlayActor } from "./useActor.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGjE,YAAY,EACX,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGjG,OAAO,EACN,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACX,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGjE,YAAY,EACX,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGjG,OAAO,EACN,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACX,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { getPlayViewContext } from "./actor-provider-context.js";
1
+ import { getPlayViewContext, usePlayView } from "./actor-provider-context.js";
2
2
  import PlayRenderer_default from "./PlayRenderer.js";
3
3
  import { useActor } from "./useActor.js";
4
4
  import ActorProvider_default from "./ActorProvider.js";
5
5
  import PlayUIProvider_default from "./PlayUIProvider.js";
6
6
  import { defineRegistry } from "./define-registry.js";
7
7
  import { ActionProvider, JSONUIProvider, Renderer, StateProvider, ValidationProvider, VisibilityProvider, useBoundProp, useFieldValidation } from "@xmachines/json-render-vue";
8
- export { ActionProvider, ActorProvider_default as ActorProvider, JSONUIProvider, PlayRenderer_default as PlayRenderer, PlayUIProvider_default as PlayUIProvider, Renderer, StateProvider, ValidationProvider, VisibilityProvider, defineRegistry, getPlayViewContext, useActor, useBoundProp, useFieldValidation };
8
+ export { ActionProvider, ActorProvider_default as ActorProvider, JSONUIProvider, PlayRenderer_default as PlayRenderer, PlayUIProvider_default as PlayUIProvider, Renderer, StateProvider, ValidationProvider, VisibilityProvider, defineRegistry, getPlayViewContext, useActor, useBoundProp, useFieldValidation, usePlayView };
package/dist/types.d.ts CHANGED
@@ -1,28 +1,32 @@
1
1
  /**
2
- * TypeScript type definitions for play-vue
2
+ * The TypeScript type definitions of play-vue
3
3
  *
4
4
  * @packageDocumentation
5
5
  */
6
6
  import type { DefineRegistryResult } from "@xmachines/json-render-vue";
7
7
  import type { BaseActorProviderProps } from "@xmachines/play-actor";
8
8
  /**
9
- * Props for the ActorProvider component.
10
- * Extracted to types.ts so TypeScript can re-export without the vue-shim limitation.
9
+ * The props of the ActorProvider component.
10
+ * This file holds them, so that TypeScript can re-export them. The vue-shim has a
11
+ * limit that stops a re-export from the .vue file.
11
12
  */
12
13
  export interface ActorProviderProps extends BaseActorProviderProps<DefineRegistryResult> {
13
14
  }
14
15
  /**
15
- * Props for PlayUIProvider — all ActorProvider props plus JSONUIProvider's own props.
16
+ * The props of PlayUIProvider — every ActorProvider prop, and also the props of JSONUIProvider.
16
17
  */
17
18
  export type { RenderErrorHandler } from "@xmachines/json-render-vue";
19
+ /**
20
+ * @deprecated Unused; will be removed in the next major.
21
+ */
18
22
  export interface VisibilityProviderProps {
19
23
  }
20
24
  export interface PlayUIProviderProps extends ActorProviderProps {
21
- /** Navigate function forwarded to JSONUIProvider for link resolution */
25
+ /** The navigate function. The provider gives it to JSONUIProvider, which resolves each link with it */
22
26
  navigate?: (path: string) => void;
23
- /** Validation functions forwarded to JSONUIProvider */
27
+ /** The validation functions. The provider gives them to JSONUIProvider */
24
28
  validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;
25
- /** Named functions for $computed expressions in props */
29
+ /** The named functions of a $computed expression in a prop */
26
30
  functions?: Record<string, (args?: Record<string, unknown>, state?: Record<string, unknown>) => unknown>;
27
31
  }
28
32
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB,CAAC,oBAAoB,CAAC;CAAG;AAE3F;;GAEG;AACH,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIrE,MAAM,WAAW,uBAAuB;CAAG;AAE3C,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC9D,wEAAwE;IACxE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,MAAM,CAC3B,MAAM,EACN,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAC3D,CAAC;IACF,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAC5E,CAAC;CACF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB,CAAC,oBAAoB,CAAC;CAAG;AAE3F;;GAEG;AACH,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIrE;;GAEG;AACH,MAAM,WAAW,uBAAuB;CAAG;AAE3C,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC9D,uGAAuG;IACvG,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,0EAA0E;IAC1E,mBAAmB,CAAC,EAAE,MAAM,CAC3B,MAAM,EACN,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAC3D,CAAC;IACF,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAC5E,CAAC;CACF"}
@@ -1,24 +1,27 @@
1
1
  /**
2
- * useActor — Vue composable for accessing the provided actor inside a PlayRenderer tree.
3
- *
4
- * Components rendered inside PlayRenderer can call useActor() to reach the actor
5
- * instance without prop drilling.
6
- *
7
- * What is returned is a **swap-following proxy**, not the raw actor object:
8
- * - It is a stable reference for the lifetime of the injection, yet forwards every
9
- * operation (property reads/writes, `in`, `Object.keys` / spread, `instanceof`)
10
- * to whichever actor is CURRENTLY provided so it transparently follows a
11
- * `props.actor` swap on `<ActorProvider>` without consumers re-injecting.
12
- * - Method identity is stable per underlying method: `actor.send === actor.send`
13
- * across repeated reads (allocation-free), and rebinds only when the underlying
14
- * method changes or the actor is swapped.
15
- * - It is NOT `===` the `actor` prop passed to `<ActorProvider>` (it is a distinct
16
- * Proxy object). Any consumer keyed on actor identity most notably a router
17
- * bridge extending `RouterBridgeBase`, whose one-bridge-per-actor guard keys a
18
- * WeakMap on the actor instance — must be given the actor prop itself, not the
19
- * value returned by `useActor()`.
20
- *
21
- * @throws {Error} If called outside a PlayRenderer tree
2
+ * useActor — the Vue composable that gives the actor inside a PlayRenderer tree.
3
+ *
4
+ * A component inside PlayRenderer calls useActor() to reach the actor instance. The
5
+ * actor is then not necessary as a prop.
6
+ *
7
+ * The composable returns a **proxy that follows a swap**, and not the raw actor
8
+ * object:
9
+ * - The proxy is a stable reference for the life of the injection. It forwards
10
+ * every operation (a property read, a property write, `in`, `Object.keys`, a
11
+ * spread, and `instanceof`) to the actor that the tree provides at that moment.
12
+ * Therefore it follows a swap of `props.actor` on `<ActorProvider>`, and a
13
+ * consumer does not inject the actor again.
14
+ * - The identity of each method is stable: `actor.send === actor.send` across
15
+ * repeated reads, with no allocation. The proxy binds the method again only when
16
+ * the method below it changes, or when the tree provides a different actor.
17
+ * - The proxy is NOT `===` the `actor` prop of `<ActorProvider>`, because it is a
18
+ * separate Proxy object. Therefore give the actor prop itself, and not the value
19
+ * of `useActor()`, to each consumer that uses the identity of the actor as a key.
20
+ * The most important such consumer is a router bridge that extends
21
+ * `RouterBridgeBase`: its guard of one bridge for each actor uses the actor
22
+ * instance as the key of a WeakMap.
23
+ *
24
+ * @throws {Error} When the caller is outside a PlayRenderer tree
22
25
  *
23
26
  * @example
24
27
  * ```typescript
@@ -33,15 +36,18 @@
33
36
  import type { InjectionKey } from "vue";
34
37
  import type { AbstractActor } from "@xmachines/play-actor";
35
38
  import type { AnyActorLogic } from "xstate";
36
- /** Bare actor type accepted by Vue context providers. For the full routing + view shape, use `PlayActor` from `@xmachines/play-router`. */
39
+ /**
40
+ * The bare actor type that the Vue context providers accept. For the complete routing and view shape, use `PlayActor` from `@xmachines/play-router`.
41
+ */
37
42
  export type AnyPlayActor = AbstractActor<AnyActorLogic>;
38
43
  export declare const ActorKey: InjectionKey<AnyPlayActor>;
39
44
  /**
40
- * Provide the actor to all descendant components via Vue's inject/provide mechanism.
45
+ * Provides the actor to every descendant component, through the inject and provide
46
+ * mechanism of Vue.
41
47
  *
42
- * Called inside `PlayRenderer.vue`'s `setup()` to make the actor available to any
43
- * child component that calls `useActor()`. Not typically needed outside framework
44
- * internals unless building a custom renderer wrapper.
48
+ * The `setup()` function of `PlayRenderer.vue` calls it. The actor is then
49
+ * available to each child component that calls `useActor()`. You need this function
50
+ * outside the framework internals only when you build your own renderer wrapper.
45
51
  *
46
52
  * @param actor - The actor instance to inject into the component tree.
47
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useActor.d.ts","sourceRoot":"","sources":["../src/useActor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,2IAA2I;AAC3I,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,YAAY,CAA6B,CAAC;AAE9E;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAEtD;AAED,wBAAgB,QAAQ,IAAI,YAAY,CAEvC"}
1
+ {"version":3,"file":"useActor.d.ts","sourceRoot":"","sources":["../src/useActor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,YAAY,CAA6B,CAAC;AAE9E;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAEtD;AAED,wBAAgB,QAAQ,IAAI,YAAY,CAEvC"}