@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
package/dist/useActor.js
CHANGED
|
@@ -2,26 +2,29 @@ import { inject, provide } from "vue";
|
|
|
2
2
|
import { assertNonNullable } from "@xmachines/play";
|
|
3
3
|
//#region packages/play-vue/src/useActor.ts
|
|
4
4
|
/**
|
|
5
|
-
* useActor — Vue composable
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
|
25
28
|
*
|
|
26
29
|
* @example
|
|
27
30
|
* ```typescript
|
|
@@ -35,11 +38,12 @@ import { assertNonNullable } from "@xmachines/play";
|
|
|
35
38
|
*/
|
|
36
39
|
var ActorKey = Symbol("xmachines.actor");
|
|
37
40
|
/**
|
|
38
|
-
*
|
|
41
|
+
* Provides the actor to every descendant component, through the inject and provide
|
|
42
|
+
* mechanism of Vue.
|
|
39
43
|
*
|
|
40
|
-
*
|
|
41
|
-
* child component that calls `useActor()`.
|
|
42
|
-
* internals
|
|
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.
|
|
43
47
|
*
|
|
44
48
|
* @param actor - The actor instance to inject into the component tree.
|
|
45
49
|
*/
|
package/dist/useActor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActor.js","names":[],"sources":["../src/useActor.ts"],"sourcesContent":["/**\n * useActor — Vue composable
|
|
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.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Vue renderer for XMachines Play architecture",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"reactive",
|
|
@@ -41,12 +41,13 @@
|
|
|
41
41
|
"lint": "oxlint .",
|
|
42
42
|
"format": "oxfmt .",
|
|
43
43
|
"test": "vitest",
|
|
44
|
+
"test:coverage": "vitest run --coverage",
|
|
44
45
|
"test:watch": "vitest"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@xmachines/play": "2.
|
|
48
|
-
"@xmachines/play-actor": "2.
|
|
49
|
-
"@xmachines/play-signals": "2.
|
|
48
|
+
"@xmachines/play": "2.1.1",
|
|
49
|
+
"@xmachines/play-actor": "2.1.1",
|
|
50
|
+
"@xmachines/play-signals": "2.1.1"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@testing-library/jest-dom": "^6.9.1",
|