@xmachines/play-vue 2.0.0-alpha.1 → 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.
Files changed (37) hide show
  1. package/README.md +27 -29
  2. package/dist/ActorProvider.js +11 -4
  3. package/dist/ActorProvider.js.map +1 -1
  4. package/dist/ActorProvider.vue_vue_type_script_lang.js +124 -76
  5. package/dist/ActorProvider.vue_vue_type_script_lang.js.map +1 -1
  6. package/dist/PlayRenderer.js +11 -4
  7. package/dist/PlayRenderer.js.map +1 -1
  8. package/dist/PlayRenderer.vue_vue_type_script_lang.js +30 -11
  9. package/dist/PlayRenderer.vue_vue_type_script_lang.js.map +1 -1
  10. package/dist/PlayUIProvider.js +11 -4
  11. package/dist/PlayUIProvider.js.map +1 -1
  12. package/dist/PlayUIProvider.vue_vue_type_script_lang.js +51 -32
  13. package/dist/PlayUIProvider.vue_vue_type_script_lang.js.map +1 -1
  14. package/dist/actor-provider-context.d.ts +22 -14
  15. package/dist/actor-provider-context.d.ts.map +1 -1
  16. package/dist/actor-provider-context.js +42 -7
  17. package/dist/actor-provider-context.js.map +1 -1
  18. package/dist/define-registry.d.ts +41 -36
  19. package/dist/define-registry.d.ts.map +1 -1
  20. package/dist/define-registry.js +117 -19
  21. package/dist/define-registry.js.map +1 -1
  22. package/dist/index.d.ts +10 -10
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +8 -8
  25. package/dist/types.d.ts +11 -7
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/useActor.d.ts +31 -25
  28. package/dist/useActor.d.ts.map +1 -1
  29. package/dist/useActor.js +54 -9
  30. package/dist/useActor.js.map +1 -1
  31. package/package.json +25 -24
  32. package/dist/ActorProvider.vue.d.ts +0 -51
  33. package/dist/ActorProvider.vue.d.ts.map +0 -1
  34. package/dist/PlayRenderer.vue.d.ts +0 -5
  35. package/dist/PlayRenderer.vue.d.ts.map +0 -1
  36. package/dist/PlayUIProvider.vue.d.ts +0 -76
  37. package/dist/PlayUIProvider.vue.d.ts.map +0 -1
@@ -1,27 +1,125 @@
1
- import { h as e } from "vue";
2
- import { defineRegistry as t } from "@xmachines/json-render-vue";
3
- //#region src/define-registry.ts
4
- function n(e) {
5
- if (typeof e != "object" || !e) return !1;
6
- let t = e;
7
- return "__vccOpts" in t || "__name" in t ? !0 : typeof t.setup == "function" || typeof t.render == "function";
1
+ import { h } from "vue";
2
+ import { defineRegistry } from "@xmachines/json-render-vue";
3
+ //#region packages/play-vue/src/define-registry.ts
4
+ /**
5
+ * The `defineRegistry` wrapper of @xmachines/play-vue.
6
+ *
7
+ * It wraps `defineRegistry` from `@xmachines/json-render-vue`, and it adds support
8
+ * for an SFC.
9
+ *
10
+ * ## Vue only — React and Solid do not need this wrapper
11
+ *
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.
18
+ *
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.
21
+ *
22
+ * Vue alone needs this adapter.
23
+ *
24
+ * ## The reason for this wrapper
25
+ *
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.
30
+ *
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.
37
+ *
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>`.
41
+ *
42
+ * ## Use
43
+ *
44
+ * Import `defineRegistry` from `@xmachines/play-vue`, not from `@xmachines/json-render-vue`:
45
+ *
46
+ * ```ts
47
+ * import { defineRegistry } from "@xmachines/play-vue";
48
+ * // not: import { defineRegistry } from "@xmachines/json-render-vue";
49
+ *
50
+ * import LoginSFC from "./views/Login.vue";
51
+ * import DashboardSFC from "./views/Dashboard.vue";
52
+ *
53
+ * const { registry } = defineRegistry(catalog, {
54
+ * components: {
55
+ * Login: LoginSFC, // a .vue SFC — the wrapper handles it
56
+ * Dashboard: DashboardSFC, // a .vue SFC — the wrapper handles it
57
+ * },
58
+ * });
59
+ * ```
60
+ *
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.
63
+ */
64
+ /**
65
+ * Tells you if a value is a Vue component object, which is an SFC, and not a plain
66
+ * `ComponentFn` function.
67
+ *
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.
71
+ *
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.
78
+ *
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.
81
+ */
82
+ function isVueSFC(value) {
83
+ if (typeof value !== "object" || value === null) return false;
84
+ const v = value;
85
+ if ("__vccOpts" in v || "__name" in v) return true;
86
+ return typeof v["setup"] === "function" || typeof v["render"] === "function";
8
87
  }
9
- function r(t) {
10
- return (n) => e(t, n);
88
+ /**
89
+ * Wraps a Vue SFC as a `ComponentFn`, and renders it with `h()`.
90
+ *
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.
94
+ */
95
+ function wrapSFC(component) {
96
+ return (ctx) => h(component, ctx);
11
97
  }
12
- function i(e, i) {
13
- let a = {};
14
- for (let [e, t] of Object.entries(i.components ?? {})) {
15
- if (t === void 0) continue;
16
- let i = e;
17
- a[i] = n(t) ? r(t) : t;
98
+ /**
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`.
101
+ *
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.
105
+ *
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.
109
+ */
110
+ function defineRegistry$1(catalog, options) {
111
+ const wrappedComponents = {};
112
+ for (const [key, component] of Object.entries(options.components ?? {})) {
113
+ if (component === void 0) continue;
114
+ const k = key;
115
+ wrappedComponents[k] = isVueSFC(component) ? wrapSFC(component) : component;
18
116
  }
19
- return t(e, {
20
- ...i,
21
- components: a
117
+ return defineRegistry(catalog, {
118
+ ...options,
119
+ components: wrappedComponents
22
120
  });
23
121
  }
24
122
  //#endregion
25
- export { i as defineRegistry };
123
+ export { defineRegistry$1 as defineRegistry };
26
124
 
27
125
  //# sourceMappingURL=define-registry.js.map
@@ -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,EAAS,GAAoC;CACrD,IAAI,OAAO,KAAU,aAAY,GAAgB,OAAO;CACxD,IAAM,IAAI;CAIV,OAFI,eAAe,KAAK,YAAY,IAAU,KAEvC,OAAO,EAAE,SAAa,cAAc,OAAO,EAAE,UAAc;AACnE;AAQA,SAAS,EACR,GACoB;CACpB,QAAQ,MAAgC,EAAE,GAAW,CAAG;AACzD;AA4BA,SAAgB,EACf,GACA,GAC2C;CAC3C,IAAM,IAAoB,CAAC;CAE3B,KAAK,IAAM,CAAC,GAAK,MAAc,OAAO,QAAQ,EAAQ,cAAc,CAAC,CAAC,GAAG;EACxE,IAAI,MAAc,KAAA,GAAW;EAC7B,IAAM,IAAI;EACV,EAAkB,KAAK,EAAS,CAAS,IACtC,EAAQ,CAAsB,IAC7B;CACL;CAGA,OAAO,EAAmB,GAAS;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,12 +16,12 @@ 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";
23
23
  export { defineRegistry } from "./define-registry.js";
24
24
  export type { DefineRegistryOptions, ComponentsMap, ComponentEntry } from "./define-registry.js";
25
- export { JSONUIProvider, StateProvider, ActionProvider, VisibilityProvider, ValidationProvider, Renderer, useBoundProp, } from "@xmachines/json-render-vue";
25
+ export { JSONUIProvider, StateProvider, ActionProvider, VisibilityProvider, ValidationProvider, Renderer, useBoundProp, useFieldValidation, } from "@xmachines/json-render-vue";
26
26
  export type { JSONUIProviderProps, StateProviderProps, ActionProviderProps, ValidationProviderProps, RendererProps, ComponentFn, ComponentContext, DefineRegistryResult, } from "@xmachines/json-render-vue";
27
27
  //# sourceMappingURL=index.d.ts.map
@@ -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,GACZ,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 as e } from "./actor-provider-context.js";
2
- import t from "./PlayRenderer.js";
3
- import { useActor as n } from "./useActor.js";
4
- import r from "./ActorProvider.js";
5
- import i from "./PlayUIProvider.js";
6
- import { defineRegistry as a } from "./define-registry.js";
7
- import { ActionProvider as o, JSONUIProvider as s, Renderer as c, StateProvider as l, ValidationProvider as u, VisibilityProvider as d, useBoundProp as f } from "@xmachines/json-render-vue";
8
- export { o as ActionProvider, r as ActorProvider, s as JSONUIProvider, t as PlayRenderer, i as PlayUIProvider, c as Renderer, l as StateProvider, u as ValidationProvider, d as VisibilityProvider, a as defineRegistry, e as getPlayViewContext, n as useActor, f as useBoundProp };
1
+ import { getPlayViewContext, usePlayView } from "./actor-provider-context.js";
2
+ import PlayRenderer_default from "./PlayRenderer.js";
3
+ import { useActor } from "./useActor.js";
4
+ import ActorProvider_default from "./ActorProvider.js";
5
+ import PlayUIProvider_default from "./PlayUIProvider.js";
6
+ import { defineRegistry } from "./define-registry.js";
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, 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"}
package/dist/useActor.js CHANGED
@@ -1,14 +1,59 @@
1
- import { inject as e, provide as t } from "vue";
2
- import { assertNonNullable as n } from "@xmachines/play";
3
- //#region src/useActor.ts
4
- var r = Symbol("xmachines.actor");
5
- function i(e) {
6
- t(r, e);
1
+ import { inject, provide } from "vue";
2
+ import { assertNonNullable } from "@xmachines/play";
3
+ //#region packages/play-vue/src/useActor.ts
4
+ /**
5
+ * useActor — the Vue composable that gives the actor inside a PlayRenderer tree.
6
+ *
7
+ * A component inside PlayRenderer calls useActor() to reach the actor instance. The
8
+ * actor is then not necessary as a prop.
9
+ *
10
+ * The composable returns a **proxy that follows a swap**, and not the raw actor
11
+ * object:
12
+ * - The proxy is a stable reference for the life of the injection. It forwards
13
+ * every operation (a property read, a property write, `in`, `Object.keys`, a
14
+ * spread, and `instanceof`) to the actor that the tree provides at that moment.
15
+ * Therefore it follows a swap of `props.actor` on `<ActorProvider>`, and a
16
+ * consumer does not inject the actor again.
17
+ * - The identity of each method is stable: `actor.send === actor.send` across
18
+ * repeated reads, with no allocation. The proxy binds the method again only when
19
+ * the method below it changes, or when the tree provides a different actor.
20
+ * - The proxy is NOT `===` the `actor` prop of `<ActorProvider>`, because it is a
21
+ * separate Proxy object. Therefore give the actor prop itself, and not the value
22
+ * of `useActor()`, to each consumer that uses the identity of the actor as a key.
23
+ * The most important such consumer is a router bridge that extends
24
+ * `RouterBridgeBase`: its guard of one bridge for each actor uses the actor
25
+ * instance as the key of a WeakMap.
26
+ *
27
+ * @throws {Error} When the caller is outside a PlayRenderer tree
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { useActor } from "@xmachines/play-vue";
32
+ *
33
+ * const actor = useActor();
34
+ * actor.send({ type: "SUBMIT" });
35
+ * ```
36
+ *
37
+ * @packageDocumentation
38
+ */
39
+ var ActorKey = Symbol("xmachines.actor");
40
+ /**
41
+ * Provides the actor to every descendant component, through the inject and provide
42
+ * mechanism of Vue.
43
+ *
44
+ * The `setup()` function of `PlayRenderer.vue` calls it. The actor is then
45
+ * available to each child component that calls `useActor()`. You need this function
46
+ * outside the framework internals only when you build your own renderer wrapper.
47
+ *
48
+ * @param actor - The actor instance to inject into the component tree.
49
+ */
50
+ function provideActor(actor) {
51
+ provide(ActorKey, actor);
7
52
  }
8
- function a() {
9
- return n(e(r), "ActorKey");
53
+ function useActor() {
54
+ return assertNonNullable(inject(ActorKey), "ActorKey");
10
55
  }
11
56
  //#endregion
12
- export { r as ActorKey, i as provideActor, a as useActor };
57
+ export { ActorKey, provideActor, useActor };
13
58
 
14
59
  //# sourceMappingURL=useActor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActor.js","names":[],"sources":["../src/useActor.ts"],"sourcesContent":["/**\n * useActor — Vue composable for accessing the provided actor inside a PlayRenderer tree.\n *\n * Components rendered inside PlayRenderer can call useActor() to reach the actor\n * instance without prop drilling.\n *\n * What is returned is a **swap-following proxy**, not the raw actor object:\n * - It is a stable reference for the lifetime of the injection, yet forwards every\n * operation (property reads/writes, `in`, `Object.keys` / spread, `instanceof`)\n * to whichever actor is CURRENTLY provided — so it transparently follows a\n * `props.actor` swap on `<ActorProvider>` without consumers re-injecting.\n * - Method identity is stable per underlying method: `actor.send === actor.send`\n * across repeated reads (allocation-free), and rebinds only when the underlying\n * method changes or the actor is swapped.\n * - It is NOT `===` the `actor` prop passed to `<ActorProvider>` (it is a distinct\n * Proxy object). Any consumer keyed on actor identity — most notably a router\n * bridge extending `RouterBridgeBase`, whose one-bridge-per-actor guard keys a\n * WeakMap on the actor instance — must be given the actor prop itself, not the\n * value returned by `useActor()`.\n *\n * @throws {Error} If called outside a PlayRenderer tree\n *\n * @example\n * ```typescript\n * import { useActor } from \"@xmachines/play-vue\";\n *\n * const actor = useActor();\n * actor.send({ type: \"SUBMIT\" });\n * ```\n *\n * @packageDocumentation\n */\n\nimport { inject, provide } from \"vue\";\nimport type { InjectionKey } from \"vue\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport type { AbstractActor } from \"@xmachines/play-actor\";\nimport type { AnyActorLogic } from \"xstate\";\n\n/** Bare actor type accepted by Vue context providers. For the full routing + view shape, use `PlayActor` from `@xmachines/play-router`. */\nexport type AnyPlayActor = AbstractActor<AnyActorLogic>;\n\nexport const ActorKey: InjectionKey<AnyPlayActor> = Symbol(\"xmachines.actor\");\n\n/**\n * Provide the actor to all descendant components via Vue's inject/provide mechanism.\n *\n * Called inside `PlayRenderer.vue`'s `setup()` to make the actor available to any\n * child component that calls `useActor()`. Not typically needed outside framework\n * internals unless building a custom renderer wrapper.\n *\n * @param actor - The actor instance to inject into the component tree.\n */\nexport function provideActor(actor: AnyPlayActor): void {\n\tprovide(ActorKey, actor);\n}\n\nexport function useActor(): AnyPlayActor {\n\treturn assertNonNullable(inject(ActorKey), \"ActorKey\");\n}\n"],"mappings":";;;AA0CA,IAAa,IAAuC,OAAO,iBAAiB;AAW5E,SAAgB,EAAa,GAA2B;CACvD,EAAQ,GAAU,CAAK;AACxB;AAEA,SAAgB,IAAyB;CACxC,OAAO,EAAkB,EAAO,CAAQ,GAAG,UAAU;AACtD"}
1
+ {"version":3,"file":"useActor.js","names":[],"sources":["../src/useActor.ts"],"sourcesContent":["/**\n * useActor — the Vue composable that gives the actor inside a PlayRenderer tree.\n *\n * A component inside PlayRenderer calls useActor() to reach the actor instance. The\n * actor is then not necessary as a prop.\n *\n * The composable returns a **proxy that follows a swap**, and not the raw actor\n * object:\n * - The proxy is a stable reference for the life of the injection. It forwards\n * every operation (a property read, a property write, `in`, `Object.keys`, a\n * spread, and `instanceof`) to the actor that the tree provides at that moment.\n * Therefore it follows a swap of `props.actor` on `<ActorProvider>`, and a\n * consumer does not inject the actor again.\n * - The identity of each method is stable: `actor.send === actor.send` across\n * repeated reads, with no allocation. The proxy binds the method again only when\n * the method below it changes, or when the tree provides a different actor.\n * - The proxy is NOT `===` the `actor` prop of `<ActorProvider>`, because it is a\n * separate Proxy object. Therefore give the actor prop itself, and not the value\n * of `useActor()`, to each consumer that uses the identity of the actor as a key.\n * The most important such consumer is a router bridge that extends\n * `RouterBridgeBase`: its guard of one bridge for each actor uses the actor\n * instance as the key of a WeakMap.\n *\n * @throws {Error} When the caller is outside a PlayRenderer tree\n *\n * @example\n * ```typescript\n * import { useActor } from \"@xmachines/play-vue\";\n *\n * const actor = useActor();\n * actor.send({ type: \"SUBMIT\" });\n * ```\n *\n * @packageDocumentation\n */\n\nimport { inject, provide } from \"vue\";\nimport type { InjectionKey } from \"vue\";\nimport { assertNonNullable } from \"@xmachines/play\";\nimport type { AbstractActor } from \"@xmachines/play-actor\";\nimport type { AnyActorLogic } from \"xstate\";\n\n/**\n * The bare actor type that the Vue context providers accept. For the complete routing and view shape, use `PlayActor` from `@xmachines/play-router`.\n */\nexport type AnyPlayActor = AbstractActor<AnyActorLogic>;\n\nexport const ActorKey: InjectionKey<AnyPlayActor> = Symbol(\"xmachines.actor\");\n\n/**\n * Provides the actor to every descendant component, through the inject and provide\n * mechanism of Vue.\n *\n * The `setup()` function of `PlayRenderer.vue` calls it. The actor is then\n * available to each child component that calls `useActor()`. You need this function\n * outside the framework internals only when you build your own renderer wrapper.\n *\n * @param actor - The actor instance to inject into the component tree.\n */\nexport function provideActor(actor: AnyPlayActor): void {\n\tprovide(ActorKey, actor);\n}\n\nexport function useActor(): AnyPlayActor {\n\treturn assertNonNullable(inject(ActorKey), \"ActorKey\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAa,WAAuC,OAAO,iBAAiB;;;;;;;;;;;AAY5E,SAAgB,aAAa,OAA2B;CACvD,QAAQ,UAAU,KAAK;AACxB;AAEA,SAAgB,WAAyB;CACxC,OAAO,kBAAkB,OAAO,QAAQ,GAAG,UAAU;AACtD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmachines/play-vue",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.1.0",
4
4
  "description": "Vue renderer for XMachines Play architecture",
5
5
  "keywords": [
6
6
  "reactive",
@@ -10,9 +10,10 @@
10
10
  "xmachines"
11
11
  ],
12
12
  "license": "MIT",
13
+ "author": "Mikael Karon <mikael@karon.se>",
13
14
  "repository": {
14
15
  "type": "git",
15
- "url": "git+ssh://git@gitlab.com/xmachin-es/xmachines-js.git",
16
+ "url": "git+https://gitlab.com/xmachin-es/xmachines-js.git",
16
17
  "directory": "packages/play-vue"
17
18
  },
18
19
  "files": [
@@ -21,60 +22,60 @@
21
22
  "LICENSE"
22
23
  ],
23
24
  "type": "module",
25
+ "sideEffects": false,
24
26
  "main": "./dist/index.js",
25
27
  "types": "./dist/index.d.ts",
26
28
  "exports": {
27
29
  ".": {
28
- "source": "./src/index.ts",
29
30
  "types": "./dist/index.d.ts",
30
31
  "default": "./dist/index.js"
31
- }
32
+ },
33
+ "./package.json": "./package.json"
32
34
  },
33
35
  "publishConfig": {
34
36
  "access": "public"
35
37
  },
36
38
  "scripts": {
37
- "build": "vite build && tsc --build --force",
39
+ "build": "vite build && tsc --build",
38
40
  "clean": "rm -rf dist *.tsbuildinfo coverage .vitest-attachments test/browser/__screenshots__ node_modules/.svelte2tsx-* node_modules/.vite*",
39
41
  "lint": "oxlint .",
40
42
  "format": "oxfmt .",
41
43
  "test": "vitest",
42
- "test:watch": "vitest",
43
- "prepublishOnly": "npm run build"
44
+ "test:coverage": "vitest run --coverage",
45
+ "test:watch": "vitest"
44
46
  },
45
47
  "dependencies": {
46
- "@xmachines/play": "2.0.0-alpha.1",
47
- "@xmachines/play-actor": "2.0.0-alpha.1",
48
- "@xmachines/play-signals": "2.0.0-alpha.1"
48
+ "@xmachines/play": "2.1.0",
49
+ "@xmachines/play-actor": "2.1.0",
50
+ "@xmachines/play-signals": "2.1.0"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@testing-library/jest-dom": "^6.9.1",
52
- "@types/node": "^26.1.1",
54
+ "@types/node": "^26.2.0",
53
55
  "@vitejs/plugin-vue": "^6.0.5",
54
- "@vitest/browser-playwright": "^4.1.10",
56
+ "@vitest/browser-playwright": "^4.1.11",
55
57
  "@vue/test-utils": "^2.4.9",
56
- "@xmachines/json-render-core": "^0.19.0-xm.2",
57
- "@xmachines/json-render-vue": "^0.19.0-xm.2",
58
- "@xmachines/json-render-xstate": "^0.19.0-xm.2",
59
- "@xmachines/shared": "2.0.0-alpha.1",
58
+ "@xmachines/json-render-core": "^0.20.0-xm.2",
59
+ "@xmachines/json-render-vue": "^0.20.0-xm.2",
60
+ "@xmachines/json-render-xstate": "^0.20.0-xm.2",
60
61
  "@xstate/store": "^3.17.0",
61
- "oxfmt": "^0.58.0",
62
- "oxlint": "^1.73.0",
62
+ "oxfmt": "^0.64.0",
63
+ "oxlint": "^1.79.0",
63
64
  "typescript": "^5.9.3 || ^6.0.3",
64
65
  "vite": "^8.0.10",
65
66
  "vite-plugin-dts": "^4.5.4",
66
- "vitest": "^4.1.10",
67
+ "vitest": "^4.1.11",
67
68
  "vue": "^3.5.33",
68
- "xstate": "^6.0.0-alpha.20",
69
+ "xstate": "^5.31.0",
69
70
  "zod": "^4.4.1"
70
71
  },
71
72
  "peerDependencies": {
72
- "@xmachines/json-render-core": "^0.19.0-xm.2",
73
- "@xmachines/json-render-vue": "^0.19.0-xm.2",
74
- "@xmachines/json-render-xstate": "^0.19.0-xm.2",
73
+ "@xmachines/json-render-core": "^0.20.0-xm.2",
74
+ "@xmachines/json-render-vue": "^0.20.0-xm.2",
75
+ "@xmachines/json-render-xstate": "^0.20.0-xm.2",
75
76
  "@xstate/store": "^3.17.0",
76
77
  "vue": "^3.5.0",
77
- "xstate": "^6.0.0-alpha.20"
78
+ "xstate": "^5.31.0"
78
79
  },
79
80
  "engines": {
80
81
  "node": ">=22.0.0"