@xmachines/play-vue 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -25
- package/dist/ActorProvider.js.map +1 -1
- package/dist/ActorProvider.vue_vue_type_script_lang.js +13 -13
- package/dist/ActorProvider.vue_vue_type_script_lang.js.map +1 -1
- package/dist/PlayRenderer.js.map +1 -1
- package/dist/PlayRenderer.vue_vue_type_script_lang.js +7 -7
- package/dist/PlayRenderer.vue_vue_type_script_lang.js.map +1 -1
- package/dist/PlayUIProvider.js.map +1 -1
- package/dist/PlayUIProvider.vue_vue_type_script_lang.js +8 -7
- package/dist/PlayUIProvider.vue_vue_type_script_lang.js.map +1 -1
- package/dist/actor-provider-context.d.ts +22 -14
- package/dist/actor-provider-context.d.ts.map +1 -1
- package/dist/actor-provider-context.js +20 -13
- package/dist/actor-provider-context.js.map +1 -1
- package/dist/define-registry.d.ts +41 -36
- package/dist/define-registry.d.ts.map +1 -1
- package/dist/define-registry.js +57 -50
- package/dist/define-registry.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/types.d.ts +11 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/useActor.d.ts +31 -25
- package/dist/useActor.d.ts.map +1 -1
- package/dist/useActor.js +28 -24
- package/dist/useActor.js.map +1 -1
- package/package.json +5 -4
|
@@ -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
|
|
5
|
+
* ViewContextValue and usePlayView — the shared context types of the Vue provider architecture.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* (The vue-shim.d.ts
|
|
9
|
-
*
|
|
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
|
-
*
|
|
15
|
-
* as the canonical key
|
|
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
|
|
18
|
+
* @internal Use usePlayView() as the public API. Never inject ViewKey directly.
|
|
18
19
|
*/
|
|
19
20
|
var ViewKey = Symbol("xmachines.view");
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Returns the current ViewContextValue inside an ActorProvider tree.
|
|
22
23
|
*
|
|
23
|
-
* @throws {Error}
|
|
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 {
|
|
28
|
+
* import { usePlayView } from "@xmachines/play-vue";
|
|
28
29
|
*
|
|
29
|
-
* const view =
|
|
30
|
+
* const view = usePlayView();
|
|
30
31
|
* // view.spec, view.handlers, view.registry
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
|
-
function
|
|
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
|
|
1
|
+
{"version":3,"file":"actor-provider-context.js","names":[],"sources":["../src/actor-provider-context.ts"],"sourcesContent":["/**\n * ViewContextValue and usePlayView — the 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
|
|
2
|
+
* The `defineRegistry` wrapper of @xmachines/play-vue.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* It wraps `defineRegistry` from `@xmachines/json-render-vue`, and it adds support
|
|
5
|
+
* for an SFC.
|
|
5
6
|
*
|
|
6
|
-
* ## Vue
|
|
7
|
+
* ## Vue only — React and Solid do not need this wrapper
|
|
7
8
|
*
|
|
8
|
-
* In React, `useContext()` works
|
|
9
|
-
*
|
|
10
|
-
* Neither has the strict
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
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
|
-
*
|
|
19
|
+
* Vue alone needs this adapter.
|
|
18
20
|
*
|
|
19
|
-
* ##
|
|
21
|
+
* ## The reason for this wrapper
|
|
20
22
|
*
|
|
21
|
-
* `@xmachines/json-render-vue`
|
|
22
|
-
* function: `componentFn(ctx)`. A `.vue` SFC
|
|
23
|
-
* `<script setup
|
|
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
|
-
*
|
|
26
|
-
* function
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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
|
|
32
|
-
* `h(SFC, ctx)`. The SFC renders as a child component with its own `setup()`,
|
|
33
|
-
*
|
|
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
|
-
* ##
|
|
39
|
+
* ## Use
|
|
36
40
|
*
|
|
37
|
-
* Import `defineRegistry` from `@xmachines/play-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 —
|
|
49
|
-
* Dashboard: DashboardSFC, // .vue SFC —
|
|
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
|
-
*
|
|
55
|
-
*
|
|
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
|
-
*
|
|
69
|
-
* correctly with `@xmachines/json-render-vue
|
|
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
|
-
*
|
|
72
|
-
* `@xmachines/
|
|
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
|
|
75
|
-
* @param options -
|
|
76
|
-
*
|
|
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
|
|
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"}
|
package/dist/define-registry.js
CHANGED
|
@@ -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
|
|
5
|
+
* The `defineRegistry` wrapper of @xmachines/play-vue.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* It wraps `defineRegistry` from `@xmachines/json-render-vue`, and it adds support
|
|
8
|
+
* for an SFC.
|
|
8
9
|
*
|
|
9
|
-
* ## Vue
|
|
10
|
+
* ## Vue only — React and Solid do not need this wrapper
|
|
10
11
|
*
|
|
11
|
-
* In React, `useContext()` works
|
|
12
|
-
*
|
|
13
|
-
* Neither has the strict
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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
|
-
*
|
|
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.
|
|
19
21
|
*
|
|
20
|
-
*
|
|
22
|
+
* Vue alone needs this adapter.
|
|
21
23
|
*
|
|
22
|
-
* ##
|
|
24
|
+
* ## The reason for this wrapper
|
|
23
25
|
*
|
|
24
|
-
* `@xmachines/json-render-vue`
|
|
25
|
-
* function: `componentFn(ctx)`. A `.vue` SFC
|
|
26
|
-
* `<script setup
|
|
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
|
-
*
|
|
29
|
-
* function
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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
|
|
35
|
-
* `h(SFC, ctx)`. The SFC renders as a child component with its own `setup()`,
|
|
36
|
-
*
|
|
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
|
-
* ##
|
|
42
|
+
* ## Use
|
|
39
43
|
*
|
|
40
|
-
* Import `defineRegistry` from `@xmachines/play-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 —
|
|
52
|
-
* Dashboard: DashboardSFC, // .vue SFC —
|
|
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
|
-
*
|
|
58
|
-
*
|
|
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
|
-
*
|
|
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
|
|
65
|
-
* plain
|
|
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
|
-
*
|
|
68
|
-
* 1. `__vccOpts` —
|
|
69
|
-
* 2. `__name` —
|
|
70
|
-
* on `defineComponent({ name: "..." })`
|
|
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
|
-
*
|
|
75
|
-
*
|
|
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
|
-
*
|
|
89
|
+
* Wraps a Vue SFC as a `ComponentFn`, and renders it with `h()`.
|
|
85
90
|
*
|
|
86
|
-
* The SFC receives the
|
|
87
|
-
* own child component
|
|
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
|
-
*
|
|
94
|
-
* correctly with `@xmachines/json-render-vue
|
|
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
|
-
*
|
|
97
|
-
* `@xmachines/
|
|
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
|
|
100
|
-
* @param options -
|
|
101
|
-
*
|
|
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
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `@xmachines/json-render-vue
|
|
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";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
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
|
-
/**
|
|
25
|
+
/** The navigate function. The provider gives it to JSONUIProvider, which resolves each link with it */
|
|
22
26
|
navigate?: (path: string) => void;
|
|
23
|
-
/**
|
|
27
|
+
/** The validation functions. The provider gives them to JSONUIProvider */
|
|
24
28
|
validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;
|
|
25
|
-
/**
|
|
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
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/useActor.d.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useActor — Vue composable
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
45
|
+
* Provides the actor to every descendant component, through the inject and provide
|
|
46
|
+
* mechanism of Vue.
|
|
41
47
|
*
|
|
42
|
-
*
|
|
43
|
-
* child component that calls `useActor()`.
|
|
44
|
-
* internals
|
|
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
|
*/
|
package/dist/useActor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActor.d.ts","sourceRoot":"","sources":["../src/useActor.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|