@xmachines/play-vue 1.0.0-beta.30 → 1.0.0-beta.31
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 +31 -31
- package/dist/PlayRenderer.js.map +1 -1
- package/dist/PlayRenderer.vue.d.ts +5 -14
- package/dist/PlayRenderer.vue.d.ts.map +1 -1
- package/dist/PlayRenderer.vue_vue_type_script_lang.js +51 -34
- package/dist/PlayRenderer.vue_vue_type_script_lang.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/node_modules/@json-render/vue/dist/index.js +44 -42
- package/dist/node_modules/@json-render/vue/dist/index.js.map +1 -1
- package/dist/types.d.ts +12 -18
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ without muting console output.
|
|
|
36
36
|
- `PlayRenderer` — main renderer component (Vue SFC)
|
|
37
37
|
- `useActor` — composable for accessing the actor inside a `PlayRenderer` tree
|
|
38
38
|
- `defineRegistry` — SFC-aware wrapper; auto-wraps `.vue` SFCs via `h(SFC, ctx)`
|
|
39
|
-
- `
|
|
39
|
+
- `useBoundProp` — re-exported from `@json-render/vue`
|
|
40
40
|
- `ComponentFn` (type) — re-exported from `@json-render/vue`
|
|
41
41
|
- `ComponentContext` (type) — re-exported from `@json-render/vue`
|
|
42
42
|
- `PlayRendererProps` (type)
|
|
@@ -60,14 +60,14 @@ export type Catalog = typeof catalog;
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
```vue
|
|
63
|
-
<!-- Login.vue — Vue SFC;
|
|
63
|
+
<!-- Login.vue — Vue SFC; useBoundProp works in <script setup> -->
|
|
64
64
|
<script setup lang="ts">
|
|
65
|
-
import {
|
|
65
|
+
import { useBoundProp } from "@xmachines/play-vue";
|
|
66
66
|
import type { ComponentContext } from "@xmachines/play-vue";
|
|
67
67
|
import type { Catalog } from "./catalog.js";
|
|
68
68
|
|
|
69
69
|
const { props, emit, bindings } = defineProps<ComponentContext<Catalog, "Login">>();
|
|
70
|
-
const [username, setUsername] =
|
|
70
|
+
const [username, setUsername] = useBoundProp<string>(bindings?.username ?? "/username");
|
|
71
71
|
</script>
|
|
72
72
|
|
|
73
73
|
<template>
|
|
@@ -88,9 +88,17 @@ import { catalog } from "./catalog.js";
|
|
|
88
88
|
import LoginSFC from "./Login.vue";
|
|
89
89
|
import DashboardSFC from "./Dashboard.vue";
|
|
90
90
|
|
|
91
|
-
export const
|
|
91
|
+
export const registryResult = defineRegistry(catalog, {
|
|
92
92
|
components: { Login: LoginSFC, Dashboard: DashboardSFC },
|
|
93
|
-
actions: {
|
|
93
|
+
actions: {
|
|
94
|
+
login: async (params) => {
|
|
95
|
+
if (!params) return;
|
|
96
|
+
actor.send({ type: "auth.login", username: params.username });
|
|
97
|
+
},
|
|
98
|
+
logout: async (params) => {
|
|
99
|
+
actor.send({ type: "auth.logout" });
|
|
100
|
+
},
|
|
101
|
+
},
|
|
94
102
|
});
|
|
95
103
|
```
|
|
96
104
|
|
|
@@ -171,7 +179,7 @@ export const machine = setup({
|
|
|
171
179
|
import { definePlayer } from "@xmachines/play-xstate";
|
|
172
180
|
import { PlayRenderer } from "@xmachines/play-vue";
|
|
173
181
|
import { machine } from "./machine.js";
|
|
174
|
-
import {
|
|
182
|
+
import { registryResult } from "./registry.js";
|
|
175
183
|
|
|
176
184
|
const createPlayer = definePlayer({ machine });
|
|
177
185
|
const actor = createPlayer();
|
|
@@ -179,11 +187,7 @@ actor.start();
|
|
|
179
187
|
</script>
|
|
180
188
|
|
|
181
189
|
<template>
|
|
182
|
-
<PlayRenderer
|
|
183
|
-
:actor="actor"
|
|
184
|
-
:registry="registry"
|
|
185
|
-
:actions="{ login: 'auth.login', logout: 'auth.logout' }"
|
|
186
|
-
/>
|
|
190
|
+
<PlayRenderer :actor="actor" :registryResult="registryResult" />
|
|
187
191
|
</template>
|
|
188
192
|
```
|
|
189
193
|
|
|
@@ -194,23 +198,16 @@ actor.start();
|
|
|
194
198
|
Main Vue component. Subscribes to `actor.currentView` and renders the spec.
|
|
195
199
|
|
|
196
200
|
```vue
|
|
197
|
-
<PlayRenderer
|
|
198
|
-
:actor="actor"
|
|
199
|
-
:registry="registry"
|
|
200
|
-
:actions="{ login: 'auth.login' }"
|
|
201
|
-
:store="myStore"
|
|
202
|
-
/>
|
|
201
|
+
<PlayRenderer :actor="actor" :registryResult="registryResult" :store="myStore" />
|
|
203
202
|
```
|
|
204
203
|
|
|
205
204
|
**`actor`** — A `PlayerActor` (or any `AbstractActor & Viewable`). Provides the `currentView` signal.
|
|
206
205
|
|
|
207
|
-
**`
|
|
206
|
+
**`registryResult`** — The full `DefineRegistryResult` returned by `defineRegistry(catalog, { components, actions })` from `@xmachines/play-vue`. Pass `.vue` SFCs directly — they are auto-wrapped via `h(SFC, ctx)` so `useBoundProp` and other composables work inside `<script setup>`.
|
|
208
207
|
|
|
209
208
|
`defineRegistry` also accepts `onRenderError(error, elementType)`, which receives errors
|
|
210
209
|
caught by `@json-render/vue`'s inner element boundary before the default logger is used.
|
|
211
210
|
|
|
212
|
-
**`actions`** — Maps json-render action names (from spec `on` bindings) to XState event type strings. Type-checked against `EventFromLogic<TLogic>["type"]` when `TLogic` is specified.
|
|
213
|
-
|
|
214
211
|
**`store`** (optional) — Controls per-view UI state (`$state` bindings, form values):
|
|
215
212
|
|
|
216
213
|
- **Omitted (uncontrolled, default):** A fresh `@xstate/store` atom is created per view transition, seeded from `view.spec.state`.
|
|
@@ -228,9 +225,17 @@ const store: StateStore = xstateStoreStateStore({ atom: createAtom({ username: "
|
|
|
228
225
|
overriding the outer Vue error boundary:
|
|
229
226
|
|
|
230
227
|
```ts
|
|
231
|
-
export const
|
|
228
|
+
export const registryResult = defineRegistry(catalog, {
|
|
232
229
|
components: { Login: LoginSFC, Dashboard: DashboardSFC },
|
|
233
|
-
actions: {
|
|
230
|
+
actions: {
|
|
231
|
+
login: async (params) => {
|
|
232
|
+
if (!params) return;
|
|
233
|
+
actor.send({ type: "auth.login", username: params.username });
|
|
234
|
+
},
|
|
235
|
+
logout: async (params) => {
|
|
236
|
+
actor.send({ type: "auth.logout" });
|
|
237
|
+
},
|
|
238
|
+
},
|
|
234
239
|
onRenderError(error, elementType) {
|
|
235
240
|
reportExpectedRenderError(error, elementType);
|
|
236
241
|
},
|
|
@@ -238,12 +243,7 @@ export const { registry } = defineRegistry(catalog, {
|
|
|
238
243
|
```
|
|
239
244
|
|
|
240
245
|
```vue
|
|
241
|
-
<PlayRenderer
|
|
242
|
-
:actor="actor"
|
|
243
|
-
:registry="registry"
|
|
244
|
-
:store="store"
|
|
245
|
-
:actions="{ login: 'auth.login' }"
|
|
246
|
-
/>
|
|
246
|
+
<PlayRenderer :actor="actor" :registryResult="registryResult" :store="store" />
|
|
247
247
|
```
|
|
248
248
|
|
|
249
249
|
---
|
|
@@ -283,5 +283,5 @@ Priority: **route param fills `undefined` slots; explicit non-`undefined` spec p
|
|
|
283
283
|
- Vue reactivity is only used to trigger re-renders — not for business logic
|
|
284
284
|
- `actor.currentView` (TC39 Signal) is bridged to Vue's reactive system inside `PlayRenderer`
|
|
285
285
|
- Per-view UI state lives in an `@xstate/store` atom, not in Vue reactive state
|
|
286
|
-
- `@json-render/vue` drives rendering; `PlayRenderer` is the signal bridge — import `defineRegistry`, `ComponentFn`, `ComponentContext`, and `
|
|
287
|
-
- Vue views should be `.vue` SFCs using `ComponentContext<MyCatalog, "X">` — `defineRegistry` from `@xmachines/play-vue` auto-wraps them via `h(SFC, ctx)`, giving each SFC its own `setup()` context where `
|
|
286
|
+
- `@json-render/vue` drives rendering; `PlayRenderer` is the signal bridge — import `defineRegistry`, `ComponentFn`, `ComponentContext`, and `useBoundProp` from `@xmachines/play-vue`
|
|
287
|
+
- Vue views should be `.vue` SFCs using `ComponentContext<MyCatalog, "X">` — `defineRegistry` from `@xmachines/play-vue` auto-wraps them via `h(SFC, ctx)`, giving each SFC its own `setup()` context where `useBoundProp` and Vue composables work correctly
|
package/dist/PlayRenderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayRenderer.js","names":[],"sources":["../src/PlayRenderer.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * PlayRenderer - Main Vue renderer component for XMachines Play architecture\n *\n * Architecture
|
|
1
|
+
{"version":3,"file":"PlayRenderer.js","names":[],"sources":["../src/PlayRenderer.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * PlayRenderer - Main Vue renderer component for XMachines Play architecture\n *\n * Architecture:\n * - Subscribes to actor.currentView signal via TC39 Signal watcher\n * - Renders view.spec via StateProvider → ActionProvider → VisibilityProvider → Renderer\n * - Routes actor actions via registryResult.handlers() — real async dispatch functions\n * - Vue ref only for triggering renders, NOT business logic\n *\n * State store: uses external `store` prop if provided (controlled mode); otherwise\n * creates a fresh @xstate/store atom per view transition seeded from spec.state.\n *\n * @invariant Actor Authority - Actor decides all state transitions via guards\n * @invariant Passive Infrastructure - Component observes signals, sends events\n * @invariant Signal-Only Reactivity - Business logic state lives in actor signals\n */\n\nimport { defineComponent, ref, toRaw, markRaw, onUnmounted, h } from \"vue\";\nimport type { PropType } from \"vue\";\nimport { watchSignal } from \"@xmachines/play-signals\";\nimport type { PlayRendererProps } from \"./types.js\";\nimport type { AbstractActor, Viewable, ViewMetadata } from \"@xmachines/play-actor\";\nimport type { AnyActorLogic } from \"xstate\";\nimport type { DefineRegistryResult } from \"@json-render/vue\";\nimport type { StateStore } from \"@json-render/core\";\nimport {\n\tRenderer,\n\tStateProvider,\n\tActionProvider,\n\tVisibilityProvider,\n\tuseStateStore,\n} from \"@json-render/vue\";\nimport type { SetState } from \"@json-render/vue\";\nimport { createAtom } from \"@xstate/store\";\nimport { xstateStoreStateStore } from \"@json-render/xstate\";\nimport { provideActor, type PlayActor } from \"./useActor.js\";\n\n/**\n * Inner component that renders inside StateProvider so it can call useStateStore()\n * to get the live set/getSnapshot functions needed by registryResult.handlers().\n */\nconst PlayRendererInner = defineComponent({\n\tname: \"PlayRendererInner\",\n\tprops: {\n\t\tregistryResult: {\n\t\t\ttype: Object as PropType<DefineRegistryResult>,\n\t\t\trequired: true,\n\t\t},\n\t\tspec: {\n\t\t\ttype: Object as PropType<import(\"@json-render/core\").Spec | null>,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\tsetup(props) {\n\t\treturn () => {\n\t\t\tconst { update, getSnapshot } = useStateStore();\n\t\t\t// Build a SetState adapter: handlers factory expects updater-function pattern\n\t\t\tconst setStateAdapter: SetState = (updater) => {\n\t\t\t\tconst prev = getSnapshot();\n\t\t\t\tupdate(updater(prev));\n\t\t\t};\n\t\t\tconst handlers = props.registryResult.handlers(\n\t\t\t\t() => setStateAdapter,\n\t\t\t\t() => getSnapshot(),\n\t\t\t);\n\t\t\tconst rawRegistry = props.registryResult.registry;\n\n\t\t\treturn h(ActionProvider, { handlers }, () =>\n\t\t\t\th(VisibilityProvider, {}, () =>\n\t\t\t\t\th(Renderer, { spec: props.spec, registry: rawRegistry }),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t},\n});\n\nexport default defineComponent({\n\tname: \"PlayRenderer\",\n\tprops: {\n\t\tactor: {\n\t\t\ttype: Object as PropType<AbstractActor<AnyActorLogic> & Viewable>,\n\t\t\trequired: true,\n\t\t},\n\t\tregistryResult: {\n\t\t\ttype: Object as PropType<DefineRegistryResult>,\n\t\t\trequired: true,\n\t\t},\n\t\tstore: {\n\t\t\ttype: Object as PropType<StateStore>,\n\t\t\tdefault: undefined,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Unwrap actor from Vue's reactive proxy to access raw Signal objects\n\t\tconst actor = toRaw(props.actor);\n\n\t\t// Unwrap the registryResult and mark components as raw to avoid Vue reactivity overhead\n\t\tconst rawRegistryResult: DefineRegistryResult = {\n\t\t\t...toRaw(props.registryResult),\n\t\t\tregistry: markRaw(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries(toRaw(props.registryResult).registry).map(([k, v]) => [\n\t\t\t\t\t\tk,\n\t\t\t\t\t\tmarkRaw(v as object),\n\t\t\t\t\t]),\n\t\t\t\t) as DefineRegistryResult[\"registry\"],\n\t\t\t),\n\t\t};\n\n\t\t// Provide the raw actor to all descendants via Vue's provide/inject mechanism\n\t\tprovideActor(actor as PlayActor);\n\n\t\t// Get initial value from unwrapped signal\n\t\tconst initialView = actor.currentView.get();\n\n\t\t// Vue ref for triggering re-renders (NOT business logic state)\n\t\tconst view = ref<ViewMetadata | null>(initialView);\n\n\t\t// Internal per-view store — recreated on each view transition when no external store.\n\t\tlet internalStore: StateStore | null = null;\n\t\tlet lastView: ViewMetadata | null = null;\n\t\tlet storeKey = 0;\n\n\t\t// Signal watcher for bridging TC39 Signals to Vue reactivity\n\t\tconst unwatch = watchSignal(actor.currentView, (nextView) => {\n\t\t\tview.value = nextView;\n\t\t});\n\n\t\tonUnmounted(() => {\n\t\t\tunwatch();\n\t\t});\n\n\t\treturn () => {\n\t\t\t// No view — show fallback slot\n\t\t\tif (!view.value) {\n\t\t\t\treturn slots.fallback ? slots.fallback() : null;\n\t\t\t}\n\n\t\t\tconst spec = view.value.spec;\n\n\t\t\t// Resolve the store: external (controlled) or internal per-view atom\n\t\t\tlet store: StateStore;\n\t\t\tif (props.store) {\n\t\t\t\tstore = props.store;\n\t\t\t} else {\n\t\t\t\tif (internalStore === null || lastView !== view.value) {\n\t\t\t\t\tconst initialState = (spec.state as Record<string, unknown>) ?? {};\n\t\t\t\t\tinternalStore = xstateStoreStateStore({ atom: createAtom(initialState) });\n\t\t\t\t\tlastView = view.value;\n\t\t\t\t\tstoreKey++;\n\t\t\t\t}\n\t\t\t\tstore = internalStore;\n\t\t\t}\n\n\t\t\t// PlayRendererInner renders inside StateProvider so useStateStore() works\n\t\t\treturn h(StateProvider, { store, key: storeKey }, () =>\n\t\t\t\th(PlayRendererInner, { registryResult: rawRegistryResult, spec }),\n\t\t\t);\n\t\t};\n\t},\n});\n</script>\n"],"mappings":""}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
2
|
import { AbstractActor, Viewable } from '@xmachines/play-actor';
|
|
3
3
|
import { AnyActorLogic } from 'xstate';
|
|
4
|
-
import {
|
|
4
|
+
import { DefineRegistryResult } from '@json-render/vue';
|
|
5
5
|
import { StateStore } from '@json-render/core';
|
|
6
6
|
declare const _default: import('vue', { with: { "resolution-mode": "import" } }).DefineComponent<import('vue', { with: { "resolution-mode": "import" } }).ExtractPropTypes<{
|
|
7
7
|
actor: {
|
|
8
8
|
type: PropType<AbstractActor<AnyActorLogic> & Viewable>;
|
|
9
9
|
required: true;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
type: PropType<
|
|
11
|
+
registryResult: {
|
|
12
|
+
type: PropType<DefineRegistryResult>;
|
|
13
13
|
required: true;
|
|
14
14
|
};
|
|
15
15
|
store: {
|
|
16
16
|
type: PropType<StateStore>;
|
|
17
17
|
default: undefined;
|
|
18
18
|
};
|
|
19
|
-
actions: {
|
|
20
|
-
type: PropType<Record<string, string>>;
|
|
21
|
-
default: () => {};
|
|
22
|
-
};
|
|
23
19
|
}>, () => import('vue', { with: { "resolution-mode": "import" } }).VNode<import('vue', { with: { "resolution-mode": "import" } }).RendererNode, import('vue', { with: { "resolution-mode": "import" } }).RendererElement, {
|
|
24
20
|
[key: string]: any;
|
|
25
21
|
}> | import('vue', { with: { "resolution-mode": "import" } }).VNode<import('vue', { with: { "resolution-mode": "import" } }).RendererNode, import('vue', { with: { "resolution-mode": "import" } }).RendererElement, {
|
|
@@ -29,21 +25,16 @@ declare const _default: import('vue', { with: { "resolution-mode": "import" } })
|
|
|
29
25
|
type: PropType<AbstractActor<AnyActorLogic> & Viewable>;
|
|
30
26
|
required: true;
|
|
31
27
|
};
|
|
32
|
-
|
|
33
|
-
type: PropType<
|
|
28
|
+
registryResult: {
|
|
29
|
+
type: PropType<DefineRegistryResult>;
|
|
34
30
|
required: true;
|
|
35
31
|
};
|
|
36
32
|
store: {
|
|
37
33
|
type: PropType<StateStore>;
|
|
38
34
|
default: undefined;
|
|
39
35
|
};
|
|
40
|
-
actions: {
|
|
41
|
-
type: PropType<Record<string, string>>;
|
|
42
|
-
default: () => {};
|
|
43
|
-
};
|
|
44
36
|
}>> & Readonly<{}>, {
|
|
45
37
|
store: StateStore;
|
|
46
|
-
actions: Record<string, string>;
|
|
47
38
|
}, {}, {}, {}, string, import('vue', { with: { "resolution-mode": "import" } }).ComponentProvideOptions, true, {}, any>;
|
|
48
39
|
export default _default;
|
|
49
40
|
//# sourceMappingURL=PlayRenderer.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayRenderer.vue.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlayRenderer.vue.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.vue"],"names":[],"mappings":"AAuLA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAGpC,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;;;cAwDjC,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;;;;cAIjD,QAAQ,CAAC,oBAAoB,CAAC;;;;cAI9B,QAAQ,CAAC,UAAU,CAAC;;;;;;;;;cARpB,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;;;;cAIjD,QAAQ,CAAC,oBAAoB,CAAC;;;;cAI9B,QAAQ,CAAC,UAAU,CAAC;;;;;;AAZvC,wBAoFG"}
|
|
@@ -1,57 +1,74 @@
|
|
|
1
|
-
import { ActionProvider as e, Renderer as t, StateProvider as n, VisibilityProvider as r } from "./node_modules/@json-render/vue/dist/index.js";
|
|
2
|
-
import { createAtom as
|
|
3
|
-
import { xstateStoreStateStore as
|
|
4
|
-
import { provideActor as
|
|
5
|
-
import { defineComponent as
|
|
6
|
-
import { watchSignal as
|
|
1
|
+
import { ActionProvider as e, Renderer as t, StateProvider as n, VisibilityProvider as r, useStateStore as i } from "./node_modules/@json-render/vue/dist/index.js";
|
|
2
|
+
import { createAtom as a } from "./node_modules/@xstate/store/dist/store-69e7e2d5.esm.js";
|
|
3
|
+
import { xstateStoreStateStore as o } from "./node_modules/@json-render/xstate/dist/index.js";
|
|
4
|
+
import { provideActor as s } from "./useActor.js";
|
|
5
|
+
import { defineComponent as c, h as l, markRaw as u, onUnmounted as d, ref as f, toRaw as p } from "vue";
|
|
6
|
+
import { watchSignal as m } from "@xmachines/play-signals";
|
|
7
7
|
//#region src/PlayRenderer.vue?vue&type=script&lang.ts
|
|
8
|
-
var
|
|
8
|
+
var h = c({
|
|
9
|
+
name: "PlayRendererInner",
|
|
10
|
+
props: {
|
|
11
|
+
registryResult: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: !0
|
|
14
|
+
},
|
|
15
|
+
spec: {
|
|
16
|
+
type: Object,
|
|
17
|
+
default: null
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
setup(n) {
|
|
21
|
+
return () => {
|
|
22
|
+
let { update: a, getSnapshot: o } = i(), s = (e) => {
|
|
23
|
+
a(e(o()));
|
|
24
|
+
}, c = n.registryResult.handlers(() => s, () => o()), u = n.registryResult.registry;
|
|
25
|
+
return l(e, { handlers: c }, () => l(r, {}, () => l(t, {
|
|
26
|
+
spec: n.spec,
|
|
27
|
+
registry: u
|
|
28
|
+
})));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}), g = c({
|
|
9
32
|
name: "PlayRenderer",
|
|
10
33
|
props: {
|
|
11
34
|
actor: {
|
|
12
35
|
type: Object,
|
|
13
36
|
required: !0
|
|
14
37
|
},
|
|
15
|
-
|
|
38
|
+
registryResult: {
|
|
16
39
|
type: Object,
|
|
17
40
|
required: !0
|
|
18
41
|
},
|
|
19
42
|
store: {
|
|
20
43
|
type: Object,
|
|
21
44
|
default: void 0
|
|
22
|
-
},
|
|
23
|
-
actions: {
|
|
24
|
-
type: Object,
|
|
25
|
-
default: () => ({})
|
|
26
45
|
}
|
|
27
46
|
},
|
|
28
|
-
setup(
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
setup(e, { slots: t }) {
|
|
48
|
+
let r = p(e.actor), i = {
|
|
49
|
+
...p(e.registryResult),
|
|
50
|
+
registry: u(Object.fromEntries(Object.entries(p(e.registryResult).registry).map(([e, t]) => [e, u(t)])))
|
|
51
|
+
};
|
|
52
|
+
s(r);
|
|
53
|
+
let c = f(r.currentView.get()), g = null, _ = null, v = 0, y = m(r.currentView, (e) => {
|
|
54
|
+
c.value = e;
|
|
33
55
|
});
|
|
34
|
-
return
|
|
35
|
-
|
|
56
|
+
return d(() => {
|
|
57
|
+
y();
|
|
36
58
|
}), () => {
|
|
37
|
-
if (!
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
key: b
|
|
47
|
-
}, () => c(e, { handlers: u }, () => c(r, {}, () => c(t, {
|
|
48
|
-
spec: o,
|
|
49
|
-
registry: g
|
|
50
|
-
}))));
|
|
59
|
+
if (!c.value) return t.fallback ? t.fallback() : null;
|
|
60
|
+
let r = c.value.spec, s;
|
|
61
|
+
return e.store ? s = e.store : ((g === null || _ !== c.value) && (g = o({ atom: a(r.state ?? {}) }), _ = c.value, v++), s = g), l(n, {
|
|
62
|
+
store: s,
|
|
63
|
+
key: v
|
|
64
|
+
}, () => l(h, {
|
|
65
|
+
registryResult: i,
|
|
66
|
+
spec: r
|
|
67
|
+
}));
|
|
51
68
|
};
|
|
52
69
|
}
|
|
53
70
|
});
|
|
54
71
|
//#endregion
|
|
55
|
-
export {
|
|
72
|
+
export { g as default };
|
|
56
73
|
|
|
57
74
|
//# sourceMappingURL=PlayRenderer.vue_vue_type_script_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayRenderer.vue_vue_type_script_lang.js","names":[],"sources":["../src/PlayRenderer.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * PlayRenderer - Main Vue renderer component for XMachines Play architecture\n *\n * Architecture
|
|
1
|
+
{"version":3,"file":"PlayRenderer.vue_vue_type_script_lang.js","names":[],"sources":["../src/PlayRenderer.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * PlayRenderer - Main Vue renderer component for XMachines Play architecture\n *\n * Architecture:\n * - Subscribes to actor.currentView signal via TC39 Signal watcher\n * - Renders view.spec via StateProvider → ActionProvider → VisibilityProvider → Renderer\n * - Routes actor actions via registryResult.handlers() — real async dispatch functions\n * - Vue ref only for triggering renders, NOT business logic\n *\n * State store: uses external `store` prop if provided (controlled mode); otherwise\n * creates a fresh @xstate/store atom per view transition seeded from spec.state.\n *\n * @invariant Actor Authority - Actor decides all state transitions via guards\n * @invariant Passive Infrastructure - Component observes signals, sends events\n * @invariant Signal-Only Reactivity - Business logic state lives in actor signals\n */\n\nimport { defineComponent, ref, toRaw, markRaw, onUnmounted, h } from \"vue\";\nimport type { PropType } from \"vue\";\nimport { watchSignal } from \"@xmachines/play-signals\";\nimport type { PlayRendererProps } from \"./types.js\";\nimport type { AbstractActor, Viewable, ViewMetadata } from \"@xmachines/play-actor\";\nimport type { AnyActorLogic } from \"xstate\";\nimport type { DefineRegistryResult } from \"@json-render/vue\";\nimport type { StateStore } from \"@json-render/core\";\nimport {\n\tRenderer,\n\tStateProvider,\n\tActionProvider,\n\tVisibilityProvider,\n\tuseStateStore,\n} from \"@json-render/vue\";\nimport type { SetState } from \"@json-render/vue\";\nimport { createAtom } from \"@xstate/store\";\nimport { xstateStoreStateStore } from \"@json-render/xstate\";\nimport { provideActor, type PlayActor } from \"./useActor.js\";\n\n/**\n * Inner component that renders inside StateProvider so it can call useStateStore()\n * to get the live set/getSnapshot functions needed by registryResult.handlers().\n */\nconst PlayRendererInner = defineComponent({\n\tname: \"PlayRendererInner\",\n\tprops: {\n\t\tregistryResult: {\n\t\t\ttype: Object as PropType<DefineRegistryResult>,\n\t\t\trequired: true,\n\t\t},\n\t\tspec: {\n\t\t\ttype: Object as PropType<import(\"@json-render/core\").Spec | null>,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\tsetup(props) {\n\t\treturn () => {\n\t\t\tconst { update, getSnapshot } = useStateStore();\n\t\t\t// Build a SetState adapter: handlers factory expects updater-function pattern\n\t\t\tconst setStateAdapter: SetState = (updater) => {\n\t\t\t\tconst prev = getSnapshot();\n\t\t\t\tupdate(updater(prev));\n\t\t\t};\n\t\t\tconst handlers = props.registryResult.handlers(\n\t\t\t\t() => setStateAdapter,\n\t\t\t\t() => getSnapshot(),\n\t\t\t);\n\t\t\tconst rawRegistry = props.registryResult.registry;\n\n\t\t\treturn h(ActionProvider, { handlers }, () =>\n\t\t\t\th(VisibilityProvider, {}, () =>\n\t\t\t\t\th(Renderer, { spec: props.spec, registry: rawRegistry }),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t},\n});\n\nexport default defineComponent({\n\tname: \"PlayRenderer\",\n\tprops: {\n\t\tactor: {\n\t\t\ttype: Object as PropType<AbstractActor<AnyActorLogic> & Viewable>,\n\t\t\trequired: true,\n\t\t},\n\t\tregistryResult: {\n\t\t\ttype: Object as PropType<DefineRegistryResult>,\n\t\t\trequired: true,\n\t\t},\n\t\tstore: {\n\t\t\ttype: Object as PropType<StateStore>,\n\t\t\tdefault: undefined,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\t// Unwrap actor from Vue's reactive proxy to access raw Signal objects\n\t\tconst actor = toRaw(props.actor);\n\n\t\t// Unwrap the registryResult and mark components as raw to avoid Vue reactivity overhead\n\t\tconst rawRegistryResult: DefineRegistryResult = {\n\t\t\t...toRaw(props.registryResult),\n\t\t\tregistry: markRaw(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries(toRaw(props.registryResult).registry).map(([k, v]) => [\n\t\t\t\t\t\tk,\n\t\t\t\t\t\tmarkRaw(v as object),\n\t\t\t\t\t]),\n\t\t\t\t) as DefineRegistryResult[\"registry\"],\n\t\t\t),\n\t\t};\n\n\t\t// Provide the raw actor to all descendants via Vue's provide/inject mechanism\n\t\tprovideActor(actor as PlayActor);\n\n\t\t// Get initial value from unwrapped signal\n\t\tconst initialView = actor.currentView.get();\n\n\t\t// Vue ref for triggering re-renders (NOT business logic state)\n\t\tconst view = ref<ViewMetadata | null>(initialView);\n\n\t\t// Internal per-view store — recreated on each view transition when no external store.\n\t\tlet internalStore: StateStore | null = null;\n\t\tlet lastView: ViewMetadata | null = null;\n\t\tlet storeKey = 0;\n\n\t\t// Signal watcher for bridging TC39 Signals to Vue reactivity\n\t\tconst unwatch = watchSignal(actor.currentView, (nextView) => {\n\t\t\tview.value = nextView;\n\t\t});\n\n\t\tonUnmounted(() => {\n\t\t\tunwatch();\n\t\t});\n\n\t\treturn () => {\n\t\t\t// No view — show fallback slot\n\t\t\tif (!view.value) {\n\t\t\t\treturn slots.fallback ? slots.fallback() : null;\n\t\t\t}\n\n\t\t\tconst spec = view.value.spec;\n\n\t\t\t// Resolve the store: external (controlled) or internal per-view atom\n\t\t\tlet store: StateStore;\n\t\t\tif (props.store) {\n\t\t\t\tstore = props.store;\n\t\t\t} else {\n\t\t\t\tif (internalStore === null || lastView !== view.value) {\n\t\t\t\t\tconst initialState = (spec.state as Record<string, unknown>) ?? {};\n\t\t\t\t\tinternalStore = xstateStoreStateStore({ atom: createAtom(initialState) });\n\t\t\t\t\tlastView = view.value;\n\t\t\t\t\tstoreKey++;\n\t\t\t\t}\n\t\t\t\tstore = internalStore;\n\t\t\t}\n\n\t\t\t// PlayRendererInner renders inside StateProvider so useStateStore() works\n\t\t\treturn h(StateProvider, { store, key: storeKey }, () =>\n\t\t\t\th(PlayRendererInner, { registryResult: rawRegistryResult, spec }),\n\t\t\t);\n\t\t};\n\t},\n});\n</script>\n"],"mappings":";;;;;;;AA0CA,IAAM,IAAoB,EAAgB;CACzC,MAAM;CACN,OAAO;EACN,gBAAgB;GACf,MAAM;GACN,UAAU;GACV;EACD,MAAM;GACL,MAAM;GACN,SAAS;GACT;EACD;CACD,MAAM,GAAO;AACZ,eAAa;GACZ,IAAM,EAAE,WAAQ,mBAAgB,GAAe,EAEzC,KAA6B,MAAY;AAE9C,MAAO,EADM,GAAa,CACN,CAAC;MAEhB,IAAW,EAAM,eAAe,eAC/B,SACA,GAAa,CACnB,EACK,IAAc,EAAM,eAAe;AAEzC,UAAO,EAAE,GAAgB,EAAE,aAAU,QACpC,EAAE,GAAoB,EAAE,QACvB,EAAE,GAAU;IAAE,MAAM,EAAM;IAAM,UAAU;IAAa,CAAC,CACxD,CACD;;;CAGH,CAAC,EAEF,IAAe,EAAgB;CAC9B,MAAM;CACN,OAAO;EACN,OAAO;GACN,MAAM;GACN,UAAU;GACV;EACD,gBAAgB;GACf,MAAM;GACN,UAAU;GACV;EACD,OAAO;GACN,MAAM;GACN,SAAS,KAAA;GACT;EACD;CACD,MAAM,GAAO,EAAE,YAAS;EAEvB,IAAM,IAAQ,EAAM,EAAM,MAAM,EAG1B,IAA0C;GAC/C,GAAG,EAAM,EAAM,eAAe;GAC9B,UAAU,EACT,OAAO,YACN,OAAO,QAAQ,EAAM,EAAM,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,CACpE,GACA,EAAQ,EAAY,CACpB,CAAC,CACH,CACA;GACD;AAGD,IAAa,EAAmB;EAMhC,IAAM,IAAO,EAHO,EAAM,YAAY,KAAK,CAGO,EAG9C,IAAmC,MACnC,IAAgC,MAChC,IAAW,GAGT,IAAU,EAAY,EAAM,cAAc,MAAa;AAC5D,KAAK,QAAQ;IACZ;AAMF,SAJA,QAAkB;AACjB,MAAS;IACR,QAEW;AAEZ,OAAI,CAAC,EAAK,MACT,QAAO,EAAM,WAAW,EAAM,UAAS,GAAI;GAG5C,IAAM,IAAO,EAAK,MAAM,MAGpB;AAcJ,UAbI,EAAM,QACT,IAAQ,EAAM,UAEV,MAAkB,QAAQ,MAAa,EAAK,WAE/C,IAAgB,EAAsB,EAAE,MAAM,EADxB,EAAK,SAAqC,EAAE,CACG,EAAG,CAAC,EACzE,IAAW,EAAK,OAChB,MAED,IAAQ,IAIF,EAAE,GAAe;IAAE;IAAO,KAAK;IAAU,QAC/C,EAAE,GAAmB;IAAE,gBAAgB;IAAmB;IAAM,CAAC,CACjE;;;CAGH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* to trigger re-renders — signals are the source of truth.
|
|
7
7
|
*
|
|
8
8
|
* Re-exports `defineRegistry` (SFC-aware — auto-wraps `.vue` SFCs via `h()`),
|
|
9
|
-
* `
|
|
9
|
+
* `useBoundProp`, `ComponentFn`, and `ComponentContext` so consumers import
|
|
10
10
|
* everything from `@xmachines/play-vue` rather than `@json-render/vue` directly.
|
|
11
11
|
*
|
|
12
12
|
* @packageDocumentation
|
|
@@ -15,7 +15,7 @@ export { default as PlayRenderer } from "./PlayRenderer.vue";
|
|
|
15
15
|
export { useActor } from "./useActor.js";
|
|
16
16
|
export { defineRegistry } from "./define-registry.js";
|
|
17
17
|
export type { DefineRegistryOptions, ComponentsMap, ComponentEntry } from "./define-registry.js";
|
|
18
|
-
export {
|
|
18
|
+
export { useBoundProp } from "@json-render/vue";
|
|
19
19
|
export type { ComponentFn, ComponentContext } from "@json-render/vue";
|
|
20
20
|
export type { PlayRendererProps } from "./types.js";
|
|
21
21
|
export type { PlayActor } 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;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEjG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEjG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useBoundProp as e } from "./node_modules/@json-render/vue/dist/index.js";
|
|
2
2
|
import { useActor as t } from "./useActor.js";
|
|
3
3
|
import n from "./PlayRenderer.js";
|
|
4
4
|
import { defineRegistry as r } from "./define-registry.js";
|
|
5
|
-
export { n as PlayRenderer, r as defineRegistry, t as useActor, e as
|
|
5
|
+
export { n as PlayRenderer, r as defineRegistry, t as useActor, e as useBoundProp };
|
|
@@ -66,27 +66,23 @@ function S() {
|
|
|
66
66
|
if (!e) throw Error("useStateStore must be used within a StateProvider");
|
|
67
67
|
return e;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
let { state: t, set: r } = S();
|
|
71
|
-
return [u(() => n(t.value, e)), (t) => r(e, t)];
|
|
72
|
-
}
|
|
73
|
-
var w = /* @__PURE__ */ Symbol("json-render:visibility"), T = d({
|
|
69
|
+
var C = /* @__PURE__ */ Symbol("json-render:visibility"), w = d({
|
|
74
70
|
name: "VisibilityProvider",
|
|
75
71
|
setup(e, { slots: t }) {
|
|
76
72
|
let { state: n } = S(), i = u(() => ({ stateModel: n.value }));
|
|
77
|
-
return g(
|
|
73
|
+
return g(C, {
|
|
78
74
|
isVisible: (e) => r(e, i.value),
|
|
79
75
|
ctx: i
|
|
80
76
|
}), () => t.default?.();
|
|
81
77
|
}
|
|
82
78
|
});
|
|
83
|
-
function
|
|
84
|
-
let e = p(
|
|
79
|
+
function T() {
|
|
80
|
+
let e = p(C);
|
|
85
81
|
if (!e) throw Error("useVisibility must be used within a VisibilityProvider");
|
|
86
82
|
return e;
|
|
87
83
|
}
|
|
88
|
-
var
|
|
89
|
-
function
|
|
84
|
+
var E = /* @__PURE__ */ Symbol("json-render:validation");
|
|
85
|
+
function D(e, t) {
|
|
90
86
|
if (e === t) return !0;
|
|
91
87
|
if (!e || !t) return !1;
|
|
92
88
|
let n = Object.keys(e), r = Object.keys(t);
|
|
@@ -103,18 +99,18 @@ function O(e, t) {
|
|
|
103
99
|
}
|
|
104
100
|
return !0;
|
|
105
101
|
}
|
|
106
|
-
function
|
|
102
|
+
function O(e, t) {
|
|
107
103
|
if (e === t) return !0;
|
|
108
104
|
if (e.validateOn !== t.validateOn) return !1;
|
|
109
105
|
let n = e.checks ?? [], r = t.checks ?? [];
|
|
110
106
|
if (n.length !== r.length) return !1;
|
|
111
107
|
for (let e = 0; e < n.length; e++) {
|
|
112
108
|
let t = n[e], i = r[e];
|
|
113
|
-
if (t.type !== i.type || t.message !== i.message || !
|
|
109
|
+
if (t.type !== i.type || t.message !== i.message || !D(t.args, i.args)) return !1;
|
|
114
110
|
}
|
|
115
111
|
return !0;
|
|
116
112
|
}
|
|
117
|
-
var
|
|
113
|
+
var k = d({
|
|
118
114
|
name: "ValidationProvider",
|
|
119
115
|
props: { customFunctions: {
|
|
120
116
|
type: Object,
|
|
@@ -123,7 +119,7 @@ var A = d({
|
|
|
123
119
|
setup(e, { slots: t }) {
|
|
124
120
|
let { state: n } = S(), r = _({}), i = _({}), a = (e, t) => {
|
|
125
121
|
let n = i.value[e];
|
|
126
|
-
n &&
|
|
122
|
+
n && O(n, t) || (i.value = {
|
|
127
123
|
...i.value,
|
|
128
124
|
[e]: t
|
|
129
125
|
});
|
|
@@ -148,7 +144,7 @@ var A = d({
|
|
|
148
144
|
}
|
|
149
145
|
}, c;
|
|
150
146
|
};
|
|
151
|
-
return g(
|
|
147
|
+
return g(E, {
|
|
152
148
|
get customFunctions() {
|
|
153
149
|
return e.customFunctions;
|
|
154
150
|
},
|
|
@@ -180,30 +176,30 @@ var A = d({
|
|
|
180
176
|
}), () => t.default?.();
|
|
181
177
|
}
|
|
182
178
|
});
|
|
183
|
-
function
|
|
184
|
-
return p(
|
|
179
|
+
function A() {
|
|
180
|
+
return p(E, null) ?? null;
|
|
185
181
|
}
|
|
186
|
-
var
|
|
187
|
-
function
|
|
188
|
-
return
|
|
182
|
+
var j = 0;
|
|
183
|
+
function M() {
|
|
184
|
+
return j += 1, `${Date.now()}-${j}`;
|
|
189
185
|
}
|
|
190
|
-
function
|
|
186
|
+
function N(e, t) {
|
|
191
187
|
if (e == null) return e;
|
|
192
|
-
if (e === "$id") return
|
|
188
|
+
if (e === "$id") return M();
|
|
193
189
|
if (typeof e == "object" && !Array.isArray(e)) {
|
|
194
190
|
let n = e, r = Object.keys(n);
|
|
195
191
|
if (r.length === 1 && typeof n.$state == "string") return t(n.$state);
|
|
196
|
-
if (r.length === 1 && "$id" in n) return
|
|
192
|
+
if (r.length === 1 && "$id" in n) return M();
|
|
197
193
|
}
|
|
198
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
194
|
+
if (Array.isArray(e)) return e.map((e) => N(e, t));
|
|
199
195
|
if (typeof e == "object") {
|
|
200
196
|
let n = {};
|
|
201
|
-
for (let [r, i] of Object.entries(e)) n[r] =
|
|
197
|
+
for (let [r, i] of Object.entries(e)) n[r] = N(i, t);
|
|
202
198
|
return n;
|
|
203
199
|
}
|
|
204
200
|
return e;
|
|
205
201
|
}
|
|
206
|
-
var
|
|
202
|
+
var P = /* @__PURE__ */ Symbol("json-render:actions"), F = d({
|
|
207
203
|
name: "ActionProvider",
|
|
208
204
|
props: {
|
|
209
205
|
handlers: {
|
|
@@ -216,7 +212,7 @@ var F = /* @__PURE__ */ Symbol("json-render:actions"), I = d({
|
|
|
216
212
|
}
|
|
217
213
|
},
|
|
218
214
|
setup(e, { slots: t }) {
|
|
219
|
-
let { get: n, set: r, getSnapshot: o } = S(), s =
|
|
215
|
+
let { get: n, set: r, getSnapshot: o } = S(), s = A(), c = _(e.handlers ?? {}), l = _(/* @__PURE__ */ new Set()), u = _(null);
|
|
220
216
|
y(() => e.handlers, (e) => {
|
|
221
217
|
e && (c.value = e);
|
|
222
218
|
});
|
|
@@ -235,7 +231,7 @@ var F = /* @__PURE__ */ Symbol("json-render:actions"), I = d({
|
|
|
235
231
|
if (d.action === "pushState" && d.params) {
|
|
236
232
|
let e = d.params.statePath, t = d.params.value;
|
|
237
233
|
if (e) {
|
|
238
|
-
let i =
|
|
234
|
+
let i = N(t, n);
|
|
239
235
|
r(e, [...n(e) ?? [], i]);
|
|
240
236
|
let a = d.params.clearStatePath;
|
|
241
237
|
a && r(a, "");
|
|
@@ -330,7 +326,7 @@ var F = /* @__PURE__ */ Symbol("json-render:actions"), I = d({
|
|
|
330
326
|
e.delete(d.action), l.value = e;
|
|
331
327
|
}
|
|
332
328
|
};
|
|
333
|
-
return g(
|
|
329
|
+
return g(P, {
|
|
334
330
|
get handlers() {
|
|
335
331
|
return c.value;
|
|
336
332
|
},
|
|
@@ -347,12 +343,12 @@ var F = /* @__PURE__ */ Symbol("json-render:actions"), I = d({
|
|
|
347
343
|
}), () => t.default?.();
|
|
348
344
|
}
|
|
349
345
|
});
|
|
350
|
-
function
|
|
351
|
-
let e = p(
|
|
346
|
+
function I() {
|
|
347
|
+
let e = p(P);
|
|
352
348
|
if (!e) throw Error("useActions must be used within an ActionProvider");
|
|
353
349
|
return e;
|
|
354
350
|
}
|
|
355
|
-
var
|
|
351
|
+
var L = d({
|
|
356
352
|
name: "ConfirmDialog",
|
|
357
353
|
props: {
|
|
358
354
|
confirm: {
|
|
@@ -429,7 +425,7 @@ var R = d({
|
|
|
429
425
|
])]);
|
|
430
426
|
};
|
|
431
427
|
}
|
|
432
|
-
}),
|
|
428
|
+
}), R = /* @__PURE__ */ Symbol("json-render:repeat-scope"), z = d({
|
|
433
429
|
name: "RepeatScopeProvider",
|
|
434
430
|
props: {
|
|
435
431
|
item: { required: !0 },
|
|
@@ -443,11 +439,17 @@ var R = d({
|
|
|
443
439
|
}
|
|
444
440
|
},
|
|
445
441
|
setup(e, { slots: t }) {
|
|
446
|
-
return g(
|
|
442
|
+
return g(R, e), () => t.default?.();
|
|
447
443
|
}
|
|
448
444
|
});
|
|
449
|
-
function
|
|
450
|
-
return p(
|
|
445
|
+
function B() {
|
|
446
|
+
return p(R, null) ?? null;
|
|
447
|
+
}
|
|
448
|
+
function V(e, t) {
|
|
449
|
+
let { set: n } = S();
|
|
450
|
+
return [e, (e) => {
|
|
451
|
+
t && n(t, e);
|
|
452
|
+
}];
|
|
451
453
|
}
|
|
452
454
|
var H = {}, U = /* @__PURE__ */ Symbol("json-render:functions"), W = d({
|
|
453
455
|
name: "FunctionsProvider",
|
|
@@ -516,7 +518,7 @@ var J = d({
|
|
|
516
518
|
}
|
|
517
519
|
},
|
|
518
520
|
setup(e) {
|
|
519
|
-
let t =
|
|
521
|
+
let t = B(), { ctx: i } = T(), { execute: a } = I(), { getSnapshot: o, state: l } = S(), d = G(), p = u(() => {
|
|
520
522
|
let e = t ? {
|
|
521
523
|
...i.value,
|
|
522
524
|
repeatItem: t.item,
|
|
@@ -627,7 +629,7 @@ var J = d({
|
|
|
627
629
|
let r = e.element.repeat;
|
|
628
630
|
if (!r?.statePath) return null;
|
|
629
631
|
let i = r.statePath, a = n(t.value, i);
|
|
630
|
-
return (Array.isArray(a) ? a : []).map((t, n) => f(
|
|
632
|
+
return (Array.isArray(a) ? a : []).map((t, n) => f(z, {
|
|
631
633
|
key: r.key && typeof t == "object" && t ? String(t[r.key] ?? n) : String(n),
|
|
632
634
|
item: t,
|
|
633
635
|
index: n,
|
|
@@ -681,8 +683,8 @@ var J = d({
|
|
|
681
683
|
}), Z = d({
|
|
682
684
|
name: "ConfirmationDialogManager",
|
|
683
685
|
setup() {
|
|
684
|
-
let { pendingConfirmation: e, confirm: t, cancel: n } =
|
|
685
|
-
return () => e?.action.confirm ? f(
|
|
686
|
+
let { pendingConfirmation: e, confirm: t, cancel: n } = I();
|
|
687
|
+
return () => e?.action.confirm ? f(L, {
|
|
686
688
|
confirm: e.action.confirm,
|
|
687
689
|
onConfirm: t,
|
|
688
690
|
onCancel: n
|
|
@@ -730,7 +732,7 @@ d({
|
|
|
730
732
|
store: e.store,
|
|
731
733
|
initialState: e.initialState,
|
|
732
734
|
onStateChange: e.onStateChange
|
|
733
|
-
}, { default: () => f(
|
|
735
|
+
}, { default: () => f(w, null, { default: () => f(k, { customFunctions: e.validationFunctions }, { default: () => f(F, {
|
|
734
736
|
handlers: e.handlers,
|
|
735
737
|
navigate: e.navigate
|
|
736
738
|
}, { default: () => f(W, { functions: e.functions }, { default: () => [t.default?.(), f(Z)] }) }) }) }) });
|
|
@@ -791,6 +793,6 @@ function Q(e, t) {
|
|
|
791
793
|
};
|
|
792
794
|
}
|
|
793
795
|
//#endregion
|
|
794
|
-
export {
|
|
796
|
+
export { F as ActionProvider, X as Renderer, x as StateProvider, w as VisibilityProvider, Q as defineRegistry, V as useBoundProp, S as useStateStore };
|
|
795
797
|
|
|
796
798
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["defineComponent2","computed2","inject2","defineComponent3","ref2","inject3","defineComponent4","ref3","inject4","defineComponent5","inject5","defineComponent6","computed6","inject6","ref5","getByPath3","evaluateVisibility2","h2"],"sources":["../../../../../../../node_modules/@json-render/vue/dist/index.mjs"],"sourcesContent":["import {\n schema\n} from \"./chunk-WIPZLAF7.mjs\";\n\n// src/composables/state.ts\nimport {\n computed,\n defineComponent,\n inject,\n onUnmounted,\n provide,\n ref,\n shallowRef,\n watch\n} from \"vue\";\nimport {\n createStateStore,\n getByPath\n} from \"@json-render/core\";\nimport { flattenToPointers } from \"@json-render/core/store-utils\";\nvar STATE_KEY = /* @__PURE__ */ Symbol(\"json-render:state\");\nvar StateProvider = defineComponent({\n name: \"StateProvider\",\n props: {\n store: {\n type: Object,\n default: void 0\n },\n initialState: {\n type: Object,\n default: void 0\n },\n onStateChange: {\n type: Function,\n default: void 0\n }\n },\n setup(props, { slots }) {\n const isControlled = !!props.store;\n const internalStore = !isControlled ? createStateStore(props.initialState ?? {}) : null;\n const store = props.store ?? internalStore;\n const state = shallowRef(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n state.value = store.getSnapshot();\n });\n onUnmounted(unsubscribe);\n if (!isControlled) {\n let prevFlat = props.initialState && Object.keys(props.initialState).length > 0 ? flattenToPointers(props.initialState) : {};\n watch(\n () => props.initialState,\n (newInitialState) => {\n if (!newInitialState) return;\n const nextFlat = Object.keys(newInitialState).length > 0 ? flattenToPointers(newInitialState) : {};\n const allKeys = /* @__PURE__ */ new Set([\n ...Object.keys(prevFlat),\n ...Object.keys(nextFlat)\n ]);\n const updates = {};\n for (const key of allKeys) {\n if (prevFlat[key] !== nextFlat[key]) {\n updates[key] = key in nextFlat ? nextFlat[key] : void 0;\n }\n }\n prevFlat = nextFlat;\n if (Object.keys(updates).length > 0) {\n store.update(updates);\n }\n }\n );\n }\n const onStateChangeRef = ref(props.onStateChange);\n watch(\n () => props.onStateChange,\n (fn) => {\n onStateChangeRef.value = fn;\n }\n );\n const get = (path) => store.get(path);\n const getSnapshot = () => store.getSnapshot();\n const set = (path, value) => {\n const prev = store.getSnapshot();\n store.set(path, value);\n if (!isControlled && store.getSnapshot() !== prev) {\n onStateChangeRef.value?.([{ path, value }]);\n }\n };\n const update = (updates) => {\n const prev = store.getSnapshot();\n store.update(updates);\n if (!isControlled && store.getSnapshot() !== prev) {\n const changes = [];\n for (const [path, value] of Object.entries(updates)) {\n if (getByPath(prev, path) !== value) {\n changes.push({ path, value });\n }\n }\n if (changes.length > 0) {\n onStateChangeRef.value?.(changes);\n }\n }\n };\n provide(STATE_KEY, {\n state,\n get,\n set,\n update,\n getSnapshot\n });\n return () => slots.default?.();\n }\n});\nfunction useStateStore() {\n const ctx = inject(STATE_KEY);\n if (!ctx) {\n throw new Error(\"useStateStore must be used within a StateProvider\");\n }\n return ctx;\n}\nfunction useStateValue(path) {\n const { state } = useStateStore();\n return computed(() => getByPath(state.value, path));\n}\nfunction useStateBinding(path) {\n const { state, set } = useStateStore();\n const value = computed(() => getByPath(state.value, path));\n const setValue = (newValue) => set(path, newValue);\n return [value, setValue];\n}\n\n// src/composables/visibility.ts\nimport {\n computed as computed2,\n defineComponent as defineComponent2,\n inject as inject2,\n provide as provide2\n} from \"vue\";\nimport {\n evaluateVisibility\n} from \"@json-render/core\";\nvar VISIBILITY_KEY = /* @__PURE__ */ Symbol(\"json-render:visibility\");\nvar VisibilityProvider = defineComponent2({\n name: \"VisibilityProvider\",\n setup(_, { slots }) {\n const { state } = useStateStore();\n const ctx = computed2(() => ({\n stateModel: state.value\n }));\n const isVisible = (condition) => evaluateVisibility(condition, ctx.value);\n provide2(VISIBILITY_KEY, { isVisible, ctx });\n return () => slots.default?.();\n }\n});\nfunction useVisibility() {\n const ctx = inject2(VISIBILITY_KEY);\n if (!ctx) {\n throw new Error(\"useVisibility must be used within a VisibilityProvider\");\n }\n return ctx;\n}\nfunction useIsVisible(condition) {\n const { ctx } = useVisibility();\n return computed2(() => evaluateVisibility(condition, ctx.value));\n}\n\n// src/composables/actions.ts\nimport {\n computed as computed4,\n defineComponent as defineComponent4,\n h,\n inject as inject4,\n provide as provide4,\n ref as ref3,\n watch as watch2\n} from \"vue\";\nimport {\n resolveAction,\n executeAction\n} from \"@json-render/core\";\n\n// src/composables/validation.ts\nimport {\n computed as computed3,\n defineComponent as defineComponent3,\n inject as inject3,\n onMounted,\n onUnmounted as onUnmounted2,\n provide as provide3,\n ref as ref2\n} from \"vue\";\nimport {\n runValidation\n} from \"@json-render/core\";\nvar VALIDATION_KEY = /* @__PURE__ */ Symbol(\"json-render:validation\");\nfunction dynamicArgsEqual(a, b) {\n if (a === b) return true;\n if (!a || !b) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n const va = a[key];\n const vb = b[key];\n if (va === vb) continue;\n if (typeof va === \"object\" && va !== null && typeof vb === \"object\" && vb !== null) {\n const sa = va.$state;\n const sb = vb.$state;\n if (typeof sa === \"string\" && sa === sb) continue;\n }\n return false;\n }\n return true;\n}\nfunction validationConfigEqual(a, b) {\n if (a === b) return true;\n if (a.validateOn !== b.validateOn) return false;\n const ac = a.checks ?? [];\n const bc = b.checks ?? [];\n if (ac.length !== bc.length) return false;\n for (let i = 0; i < ac.length; i++) {\n const ca = ac[i];\n const cb = bc[i];\n if (ca.type !== cb.type) return false;\n if (ca.message !== cb.message) return false;\n if (!dynamicArgsEqual(ca.args, cb.args)) return false;\n }\n return true;\n}\nvar ValidationProvider = defineComponent3({\n name: \"ValidationProvider\",\n props: {\n customFunctions: {\n type: Object,\n default: () => ({})\n }\n },\n setup(props, { slots }) {\n const { state } = useStateStore();\n const fieldStates = ref2({});\n const fieldConfigs = ref2({});\n const registerField = (path, config) => {\n const existing = fieldConfigs.value[path];\n if (existing && validationConfigEqual(existing, config)) return;\n fieldConfigs.value = { ...fieldConfigs.value, [path]: config };\n };\n const validate = (path, config) => {\n const currentState = state.value;\n const segments = path.split(\"/\").filter(Boolean);\n let value = currentState;\n for (const seg of segments) {\n if (value != null && typeof value === \"object\") {\n value = value[seg];\n } else {\n value = void 0;\n break;\n }\n }\n const result = runValidation(config, {\n value,\n stateModel: currentState,\n customFunctions: props.customFunctions\n });\n fieldStates.value = {\n ...fieldStates.value,\n [path]: {\n touched: fieldStates.value[path]?.touched ?? true,\n validated: true,\n result\n }\n };\n return result;\n };\n const touch = (path) => {\n fieldStates.value = {\n ...fieldStates.value,\n [path]: {\n ...fieldStates.value[path],\n touched: true,\n validated: fieldStates.value[path]?.validated ?? false,\n result: fieldStates.value[path]?.result ?? null\n }\n };\n };\n const clear = (path) => {\n const { [path]: _, ...rest } = fieldStates.value;\n fieldStates.value = rest;\n };\n const validateAll = () => {\n let allValid = true;\n for (const [path, config] of Object.entries(fieldConfigs.value)) {\n const result = validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n return allValid;\n };\n provide3(VALIDATION_KEY, {\n get customFunctions() {\n return props.customFunctions;\n },\n get fieldStates() {\n return fieldStates.value;\n },\n validate,\n touch,\n clear,\n validateAll,\n registerField\n });\n return () => slots.default?.();\n }\n});\nfunction useOptionalValidation() {\n return inject3(\n VALIDATION_KEY,\n null\n ) ?? null;\n}\nfunction useValidation() {\n const ctx = inject3(VALIDATION_KEY);\n if (!ctx) {\n throw new Error(\"useValidation must be used within a ValidationProvider\");\n }\n return ctx;\n}\nfunction useFieldValidation(path, config) {\n const ctx = useValidation();\n onMounted(() => {\n if (path && config) {\n ctx.registerField(path, config);\n }\n });\n onUnmounted2(() => {\n ctx.clear(path);\n });\n const defaultState = {\n touched: false,\n validated: false,\n result: null\n };\n return {\n state: computed3(() => ctx.fieldStates[path] ?? defaultState),\n validate: () => ctx.validate(path, config ?? { checks: [] }),\n touch: () => ctx.touch(path),\n clear: () => ctx.clear(path),\n errors: computed3(() => ctx.fieldStates[path]?.result?.errors ?? []),\n isValid: computed3(() => ctx.fieldStates[path]?.result?.valid ?? true)\n };\n}\n\n// src/composables/actions.ts\nvar idCounter = 0;\nfunction generateUniqueId() {\n idCounter += 1;\n return `${Date.now()}-${idCounter}`;\n}\nfunction deepResolveValue(value, get) {\n if (value === null || value === void 0) return value;\n if (value === \"$id\") {\n return generateUniqueId();\n }\n if (typeof value === \"object\" && !Array.isArray(value)) {\n const obj = value;\n const keys = Object.keys(obj);\n if (keys.length === 1 && typeof obj.$state === \"string\") {\n return get(obj.$state);\n }\n if (keys.length === 1 && \"$id\" in obj) {\n return generateUniqueId();\n }\n }\n if (Array.isArray(value)) {\n return value.map((item) => deepResolveValue(item, get));\n }\n if (typeof value === \"object\") {\n const resolved = {};\n for (const [key, val] of Object.entries(value)) {\n resolved[key] = deepResolveValue(val, get);\n }\n return resolved;\n }\n return value;\n}\nvar ACTIONS_KEY = /* @__PURE__ */ Symbol(\"json-render:actions\");\nvar ActionProvider = defineComponent4({\n name: \"ActionProvider\",\n props: {\n handlers: {\n type: Object,\n default: () => ({})\n },\n navigate: {\n type: Function,\n default: void 0\n }\n },\n setup(props, { slots }) {\n const { get, set, getSnapshot } = useStateStore();\n const validation = useOptionalValidation();\n const handlers = ref3(props.handlers ?? {});\n const loadingActions = ref3(/* @__PURE__ */ new Set());\n const pendingConfirmation = ref3(null);\n watch2(\n () => props.handlers,\n (newHandlers) => {\n if (newHandlers) handlers.value = newHandlers;\n }\n );\n const registerHandler = (name, handler) => {\n handlers.value = { ...handlers.value, [name]: handler };\n };\n const execute = async (binding) => {\n const resolved = resolveAction(binding, getSnapshot());\n if (resolved.action === \"setState\" && resolved.params) {\n const statePath = resolved.params.statePath;\n const value = resolved.params.value;\n if (statePath) {\n set(statePath, value);\n }\n return;\n }\n if (resolved.action === \"pushState\" && resolved.params) {\n const statePath = resolved.params.statePath;\n const rawValue = resolved.params.value;\n if (statePath) {\n const resolvedValue = deepResolveValue(rawValue, get);\n const arr = get(statePath) ?? [];\n set(statePath, [...arr, resolvedValue]);\n const clearStatePath = resolved.params.clearStatePath;\n if (clearStatePath) {\n set(clearStatePath, \"\");\n }\n }\n return;\n }\n if (resolved.action === \"removeState\" && resolved.params) {\n const statePath = resolved.params.statePath;\n const index = resolved.params.index;\n if (statePath !== void 0 && index !== void 0) {\n const arr = get(statePath) ?? [];\n set(\n statePath,\n arr.filter((_, i) => i !== index)\n );\n }\n return;\n }\n if (resolved.action === \"validateForm\") {\n const validateAll = validation?.validateAll;\n if (!validateAll) {\n console.warn(\n \"validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.\"\n );\n return;\n }\n const valid = validateAll();\n const errors = {};\n for (const [path, fs] of Object.entries(validation.fieldStates)) {\n if (fs.result && !fs.result.valid) {\n errors[path] = fs.result.errors;\n }\n }\n const statePath = resolved.params?.statePath || \"/formValidation\";\n set(statePath, { valid, errors });\n return;\n }\n if (resolved.action === \"push\" && resolved.params) {\n const screen = resolved.params.screen;\n if (screen) {\n const currentScreen = get(\"/currentScreen\");\n const navStack = get(\"/navStack\") ?? [];\n if (currentScreen) {\n set(\"/navStack\", [...navStack, currentScreen]);\n } else {\n set(\"/navStack\", [...navStack, \"\"]);\n }\n set(\"/currentScreen\", screen);\n }\n return;\n }\n if (resolved.action === \"pop\") {\n const navStack = get(\"/navStack\") ?? [];\n if (navStack.length > 0) {\n const previousScreen = navStack[navStack.length - 1];\n set(\"/navStack\", navStack.slice(0, -1));\n if (previousScreen) {\n set(\"/currentScreen\", previousScreen);\n } else {\n set(\"/currentScreen\", void 0);\n }\n }\n return;\n }\n const handler = handlers.value[resolved.action];\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.action}`);\n return;\n }\n if (resolved.confirm) {\n await new Promise((resolve, reject) => {\n pendingConfirmation.value = {\n action: resolved,\n handler,\n resolve: () => {\n pendingConfirmation.value = null;\n resolve();\n },\n reject: () => {\n pendingConfirmation.value = null;\n reject(new Error(\"Action cancelled\"));\n }\n };\n });\n const addLoading2 = new Set(loadingActions.value);\n addLoading2.add(resolved.action);\n loadingActions.value = addLoading2;\n try {\n await executeAction({\n action: resolved,\n handler,\n setState: set,\n navigate: props.navigate,\n executeAction: async (name) => {\n const subBinding = { action: name };\n await execute(subBinding);\n }\n });\n } finally {\n const removeLoading = new Set(loadingActions.value);\n removeLoading.delete(resolved.action);\n loadingActions.value = removeLoading;\n }\n return;\n }\n const addLoading = new Set(loadingActions.value);\n addLoading.add(resolved.action);\n loadingActions.value = addLoading;\n try {\n await executeAction({\n action: resolved,\n handler,\n setState: set,\n navigate: props.navigate,\n executeAction: async (name) => {\n const subBinding = { action: name };\n await execute(subBinding);\n }\n });\n } finally {\n const removeLoading = new Set(loadingActions.value);\n removeLoading.delete(resolved.action);\n loadingActions.value = removeLoading;\n }\n };\n const confirm = () => pendingConfirmation.value?.resolve();\n const cancel = () => pendingConfirmation.value?.reject();\n provide4(ACTIONS_KEY, {\n get handlers() {\n return handlers.value;\n },\n get loadingActions() {\n return loadingActions.value;\n },\n get pendingConfirmation() {\n return pendingConfirmation.value;\n },\n execute,\n confirm,\n cancel,\n registerHandler\n });\n return () => slots.default?.();\n }\n});\nfunction useActions() {\n const ctx = inject4(ACTIONS_KEY);\n if (!ctx) {\n throw new Error(\"useActions must be used within an ActionProvider\");\n }\n return ctx;\n}\nfunction useAction(binding) {\n const ctx = useActions();\n return {\n execute: () => ctx.execute(binding),\n isLoading: computed4(() => ctx.loadingActions.has(binding.action))\n };\n}\nvar ConfirmDialog = defineComponent4({\n name: \"ConfirmDialog\",\n props: {\n confirm: {\n type: Object,\n required: true\n },\n onConfirm: {\n type: Function,\n required: true\n },\n onCancel: {\n type: Function,\n required: true\n }\n },\n setup(props) {\n return () => {\n const isDanger = props.confirm.variant === \"danger\";\n return h(\n \"div\",\n {\n style: {\n position: \"fixed\",\n inset: \"0\",\n backgroundColor: \"rgba(0, 0, 0, 0.5)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: \"50\"\n },\n onClick: props.onCancel\n },\n [\n h(\n \"div\",\n {\n style: {\n backgroundColor: \"white\",\n borderRadius: \"8px\",\n padding: \"24px\",\n maxWidth: \"400px\",\n width: \"100%\",\n boxShadow: \"0 20px 25px -5px rgba(0, 0, 0, 0.1)\"\n },\n onClick: (e) => e.stopPropagation()\n },\n [\n h(\n \"h3\",\n {\n style: {\n margin: \"0 0 8px 0\",\n fontSize: \"18px\",\n fontWeight: \"600\"\n }\n },\n props.confirm.title\n ),\n h(\n \"p\",\n {\n style: { margin: \"0 0 24px 0\", color: \"#6b7280\" }\n },\n props.confirm.message\n ),\n h(\n \"div\",\n {\n style: {\n display: \"flex\",\n gap: \"12px\",\n justifyContent: \"flex-end\"\n }\n },\n [\n h(\n \"button\",\n {\n style: {\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"1px solid #d1d5db\",\n backgroundColor: \"white\",\n cursor: \"pointer\"\n },\n onClick: props.onCancel\n },\n props.confirm.cancelLabel ?? \"Cancel\"\n ),\n h(\n \"button\",\n {\n style: {\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"none\",\n backgroundColor: isDanger ? \"#dc2626\" : \"#3b82f6\",\n color: \"white\",\n cursor: \"pointer\"\n },\n onClick: props.onConfirm\n },\n props.confirm.confirmLabel ?? \"Confirm\"\n )\n ]\n )\n ]\n )\n ]\n );\n };\n }\n});\n\n// src/composables/repeat-scope.ts\nimport { defineComponent as defineComponent5, inject as inject5, provide as provide5 } from \"vue\";\nvar REPEAT_SCOPE_KEY = /* @__PURE__ */ Symbol(\"json-render:repeat-scope\");\nvar RepeatScopeProvider = defineComponent5({\n name: \"RepeatScopeProvider\",\n props: {\n item: {\n required: true\n },\n index: {\n type: Number,\n required: true\n },\n basePath: {\n type: String,\n required: true\n }\n },\n setup(props, { slots }) {\n provide5(REPEAT_SCOPE_KEY, props);\n return () => slots.default?.();\n }\n});\nfunction useRepeatScope() {\n return inject5(\n REPEAT_SCOPE_KEY,\n null\n ) ?? null;\n}\n\n// src/index.ts\nimport { createStateStore as createStateStore2 } from \"@json-render/core\";\n\n// src/hooks.ts\nimport {\n ref as ref4,\n shallowRef as shallowRef2,\n computed as computed5,\n onUnmounted as onUnmounted3,\n isRef\n} from \"vue\";\nimport {\n setByPath,\n getByPath as getByPath2,\n removeByPath,\n createMixedStreamParser,\n applySpecPatch,\n nestedToFlat,\n SPEC_DATA_PART_TYPE\n} from \"@json-render/core\";\nfunction parseLine(line) {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"//\")) {\n return null;\n }\n const parsed = JSON.parse(trimmed);\n if (parsed.__meta === \"usage\") {\n return {\n type: \"usage\",\n usage: {\n promptTokens: parsed.promptTokens ?? 0,\n completionTokens: parsed.completionTokens ?? 0,\n totalTokens: parsed.totalTokens ?? 0\n }\n };\n }\n return { type: \"patch\", patch: parsed };\n } catch {\n return null;\n }\n}\nfunction setSpecValue(newSpec, path, value) {\n if (path === \"/root\") {\n newSpec.root = value;\n return;\n }\n if (path === \"/state\") {\n newSpec.state = value;\n return;\n }\n if (path.startsWith(\"/state/\")) {\n if (!newSpec.state) newSpec.state = {};\n const statePath = path.slice(\"/state\".length);\n setByPath(newSpec.state, statePath, value);\n return;\n }\n if (path.startsWith(\"/elements/\")) {\n const pathParts = path.slice(\"/elements/\".length).split(\"/\");\n const elementKey = pathParts[0];\n if (!elementKey) return;\n if (pathParts.length === 1) {\n newSpec.elements[elementKey] = value;\n } else {\n const element = newSpec.elements[elementKey];\n if (element) {\n const propPath = \"/\" + pathParts.slice(1).join(\"/\");\n const newElement = { ...element };\n setByPath(\n newElement,\n propPath,\n value\n );\n newSpec.elements[elementKey] = newElement;\n }\n }\n }\n}\nfunction removeSpecValue(newSpec, path) {\n if (path === \"/state\") {\n delete newSpec.state;\n return;\n }\n if (path.startsWith(\"/state/\") && newSpec.state) {\n const statePath = path.slice(\"/state\".length);\n removeByPath(newSpec.state, statePath);\n return;\n }\n if (path.startsWith(\"/elements/\")) {\n const pathParts = path.slice(\"/elements/\".length).split(\"/\");\n const elementKey = pathParts[0];\n if (!elementKey) return;\n if (pathParts.length === 1) {\n const { [elementKey]: _, ...rest } = newSpec.elements;\n newSpec.elements = rest;\n } else {\n const element = newSpec.elements[elementKey];\n if (element) {\n const propPath = \"/\" + pathParts.slice(1).join(\"/\");\n const newElement = { ...element };\n removeByPath(\n newElement,\n propPath\n );\n newSpec.elements[elementKey] = newElement;\n }\n }\n }\n}\nfunction getSpecValue(spec, path) {\n if (path === \"/root\") return spec.root;\n if (path === \"/state\") return spec.state;\n if (path.startsWith(\"/state/\") && spec.state) {\n const statePath = path.slice(\"/state\".length);\n return getByPath2(spec.state, statePath);\n }\n return getByPath2(spec, path);\n}\nfunction applyPatch(spec, patch) {\n const newSpec = {\n ...spec,\n elements: { ...spec.elements },\n ...spec.state ? { state: { ...spec.state } } : {}\n };\n switch (patch.op) {\n case \"add\":\n case \"replace\": {\n setSpecValue(newSpec, patch.path, patch.value);\n break;\n }\n case \"remove\": {\n removeSpecValue(newSpec, patch.path);\n break;\n }\n case \"move\": {\n if (!patch.from) break;\n const moveValue = getSpecValue(newSpec, patch.from);\n removeSpecValue(newSpec, patch.from);\n setSpecValue(newSpec, patch.path, moveValue);\n break;\n }\n case \"copy\": {\n if (!patch.from) break;\n const copyValue = getSpecValue(newSpec, patch.from);\n setSpecValue(newSpec, patch.path, copyValue);\n break;\n }\n case \"test\": {\n break;\n }\n }\n return newSpec;\n}\nfunction useUIStream({\n api,\n onComplete,\n onError\n}) {\n const spec = shallowRef2(null);\n const isStreaming = ref4(false);\n const error = ref4(null);\n const usage = ref4(null);\n const rawLines = ref4([]);\n const onCompleteRef = ref4(onComplete);\n const onErrorRef = ref4(onError);\n let abortController = null;\n const clear = () => {\n spec.value = null;\n error.value = null;\n usage.value = null;\n rawLines.value = [];\n };\n const send = async (prompt, context) => {\n abortController?.abort();\n abortController = new AbortController();\n isStreaming.value = true;\n error.value = null;\n usage.value = null;\n rawLines.value = [];\n const previousSpec = context?.previousSpec;\n let currentSpec = previousSpec && previousSpec.root ? { ...previousSpec, elements: { ...previousSpec.elements } } : { root: \"\", elements: {} };\n spec.value = currentSpec;\n try {\n const response = await fetch(api, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n prompt,\n context,\n currentSpec\n }),\n signal: abortController.signal\n });\n if (!response.ok) {\n let errorMessage = `HTTP error: ${response.status}`;\n try {\n const errorData = await response.json();\n if (errorData.message) {\n errorMessage = errorData.message;\n } else if (errorData.error) {\n errorMessage = errorData.error;\n }\n } catch {\n }\n throw new Error(errorMessage);\n }\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"No response body\");\n }\n const decoder = new TextDecoder();\n let buffer = \"\";\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const result = parseLine(trimmed);\n if (!result) continue;\n if (result.type === \"usage\") {\n usage.value = result.usage;\n } else {\n rawLines.value = [...rawLines.value, trimmed];\n currentSpec = applyPatch(currentSpec, result.patch);\n spec.value = { ...currentSpec };\n }\n }\n }\n if (buffer.trim()) {\n const trimmed = buffer.trim();\n const result = parseLine(trimmed);\n if (result) {\n if (result.type === \"usage\") {\n usage.value = result.usage;\n } else {\n rawLines.value = [...rawLines.value, trimmed];\n currentSpec = applyPatch(currentSpec, result.patch);\n spec.value = { ...currentSpec };\n }\n }\n }\n onCompleteRef.value?.(currentSpec);\n } catch (err) {\n if (err.name === \"AbortError\") {\n return;\n }\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n error.value = resolvedError;\n onErrorRef.value?.(resolvedError);\n } finally {\n isStreaming.value = false;\n }\n };\n onUnmounted3(() => {\n abortController?.abort();\n });\n return {\n spec,\n isStreaming,\n error,\n usage,\n rawLines,\n send,\n clear\n };\n}\nfunction flatToTree(elements) {\n const elementMap = {};\n let root = \"\";\n for (const element of elements) {\n elementMap[element.key] = {\n type: element.type,\n props: element.props,\n children: [],\n visible: element.visible\n };\n }\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n if (!parent.children) {\n parent.children = [];\n }\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n return { root, elements: elementMap };\n}\nfunction useBoundProp(propValue, bindingPath) {\n const { set } = useStateStore();\n return [\n propValue,\n (value) => {\n if (bindingPath) set(bindingPath, value);\n }\n ];\n}\nfunction isSpecDataPart(data) {\n if (typeof data !== \"object\" || data === null) return false;\n const obj = data;\n switch (obj.type) {\n case \"patch\":\n return typeof obj.patch === \"object\" && obj.patch !== null;\n case \"flat\":\n case \"nested\":\n return typeof obj.spec === \"object\" && obj.spec !== null;\n default:\n return false;\n }\n}\nfunction buildSpecFromParts(parts) {\n const spec = { root: \"\", elements: {} };\n let hasSpec = false;\n for (const part of parts) {\n if (part.type === SPEC_DATA_PART_TYPE) {\n if (!isSpecDataPart(part.data)) continue;\n const payload = part.data;\n if (payload.type === \"patch\") {\n hasSpec = true;\n applySpecPatch(spec, payload.patch);\n } else if (payload.type === \"flat\") {\n hasSpec = true;\n Object.assign(spec, payload.spec);\n } else if (payload.type === \"nested\") {\n hasSpec = true;\n const flat = nestedToFlat(payload.spec);\n Object.assign(spec, flat);\n }\n }\n }\n return hasSpec ? spec : null;\n}\nfunction getTextFromParts(parts) {\n return parts.filter(\n (p) => p.type === \"text\" && typeof p.text === \"string\"\n ).map((p) => p.text.trim()).filter(Boolean).join(\"\\n\\n\");\n}\nfunction useJsonRenderMessage(parts) {\n const partsRef = isRef(parts) ? parts : ref4(parts);\n const spec = computed5(() => buildSpecFromParts(partsRef.value));\n const text = computed5(() => getTextFromParts(partsRef.value));\n const hasSpec = computed5(\n () => spec.value !== null && Object.keys(spec.value.elements || {}).length > 0\n );\n return { spec, text, hasSpec };\n}\nvar chatMessageIdCounter = 0;\nfunction generateChatId() {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n chatMessageIdCounter += 1;\n return `msg-${Date.now()}-${chatMessageIdCounter}`;\n}\nfunction useChatUI({\n api,\n onComplete,\n onError\n}) {\n const messages = ref4([]);\n const isStreaming = ref4(false);\n const error = ref4(null);\n const onCompleteRef = ref4(onComplete);\n const onErrorRef = ref4(onError);\n let abortController = null;\n const clear = () => {\n messages.value = [];\n error.value = null;\n };\n const send = async (text) => {\n if (!text.trim()) return;\n abortController?.abort();\n abortController = new AbortController();\n const userMessage = {\n id: generateChatId(),\n role: \"user\",\n text: text.trim(),\n spec: null\n };\n const assistantId = generateChatId();\n const assistantMessage = {\n id: assistantId,\n role: \"assistant\",\n text: \"\",\n spec: null\n };\n messages.value = [...messages.value, userMessage, assistantMessage];\n isStreaming.value = true;\n error.value = null;\n const historyForApi = [\n ...messages.value.filter((m) => m.id !== assistantId).map((m) => ({ role: m.role, content: m.text })),\n { role: \"user\", content: text.trim() }\n ];\n let accumulatedText = \"\";\n let currentSpec = { root: \"\", elements: {} };\n let hasSpec = false;\n try {\n const response = await fetch(api, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ messages: historyForApi }),\n signal: abortController.signal\n });\n if (!response.ok) {\n let errorMessage = `HTTP error: ${response.status}`;\n try {\n const errorData = await response.json();\n if (errorData.message) {\n errorMessage = errorData.message;\n } else if (errorData.error) {\n errorMessage = errorData.error;\n }\n } catch {\n }\n throw new Error(errorMessage);\n }\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"No response body\");\n }\n const decoder = new TextDecoder();\n const parser = createMixedStreamParser({\n onPatch(patch) {\n hasSpec = true;\n applySpecPatch(currentSpec, patch);\n messages.value = messages.value.map(\n (m) => m.id === assistantId ? {\n ...m,\n spec: {\n root: currentSpec.root,\n elements: { ...currentSpec.elements },\n ...currentSpec.state ? { state: { ...currentSpec.state } } : {}\n }\n } : m\n );\n },\n onText(line) {\n accumulatedText += (accumulatedText ? \"\\n\" : \"\") + line;\n messages.value = messages.value.map(\n (m) => m.id === assistantId ? { ...m, text: accumulatedText } : m\n );\n }\n });\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n parser.push(decoder.decode(value, { stream: true }));\n }\n parser.flush();\n const finalMessage = {\n id: assistantId,\n role: \"assistant\",\n text: accumulatedText,\n spec: hasSpec ? {\n root: currentSpec.root,\n elements: { ...currentSpec.elements },\n ...currentSpec.state ? { state: { ...currentSpec.state } } : {}\n } : null\n };\n onCompleteRef.value?.(finalMessage);\n } catch (err) {\n if (err.name === \"AbortError\") {\n return;\n }\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n error.value = resolvedError;\n messages.value = messages.value.filter(\n (m) => m.id !== assistantId || m.text.length > 0\n );\n onErrorRef.value?.(resolvedError);\n } finally {\n isStreaming.value = false;\n }\n };\n onUnmounted3(() => {\n abortController?.abort();\n });\n return {\n messages,\n isStreaming,\n error,\n send,\n clear\n };\n}\n\n// src/renderer.ts\nimport {\n computed as computed6,\n defineComponent as defineComponent6,\n h as h2,\n inject as inject6,\n onErrorCaptured,\n provide as provide6,\n ref as ref5,\n watch as watch3\n} from \"vue\";\nimport {\n resolveElementProps,\n resolveBindings,\n resolveActionParam,\n evaluateVisibility as evaluateVisibility2,\n getByPath as getByPath3\n} from \"@json-render/core\";\nvar EMPTY_FUNCTIONS = {};\nvar FUNCTIONS_KEY = /* @__PURE__ */ Symbol(\"json-render:functions\");\nvar FunctionsProvider = defineComponent6({\n name: \"FunctionsProvider\",\n props: {\n functions: {\n type: Object,\n default: void 0\n }\n },\n setup(props, { slots }) {\n const fns = computed6(() => props.functions ?? EMPTY_FUNCTIONS);\n provide6(FUNCTIONS_KEY, fns);\n return () => slots.default?.();\n }\n});\nfunction useFunctions() {\n return inject6(\n FUNCTIONS_KEY,\n computed6(() => EMPTY_FUNCTIONS)\n );\n}\nvar ElementErrorBoundary = defineComponent6({\n name: \"ElementErrorBoundary\",\n props: {\n elementType: {\n type: String,\n required: true\n }\n },\n setup(props, { slots }) {\n const hasError = ref5(false);\n onErrorCaptured((error) => {\n console.error(\n `[json-render] Rendering error in <${props.elementType}>:`,\n error\n );\n hasError.value = true;\n return false;\n });\n return () => {\n if (hasError.value) return null;\n return slots.default?.();\n };\n }\n});\nasync function resolveAndExecuteBindings(actionBindings, ctx, getSnapshot, execute, cancelled) {\n for (const b of actionBindings) {\n if (cancelled?.()) break;\n if (!b.params) {\n await execute(b);\n if (cancelled?.()) break;\n continue;\n }\n const liveCtx = {\n ...ctx,\n stateModel: getSnapshot()\n };\n const resolved = {};\n for (const [key, val] of Object.entries(b.params)) {\n resolved[key] = resolveActionParam(val, liveCtx);\n }\n await execute({ ...b, params: resolved });\n if (cancelled?.()) break;\n }\n}\nvar ElementRenderer = defineComponent6({\n name: \"JsonRenderElement\",\n props: {\n element: {\n type: Object,\n required: true\n },\n spec: {\n type: Object,\n required: true\n },\n registry: {\n type: Object,\n required: true\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(props) {\n const repeatScope = useRepeatScope();\n const { ctx: visibilityCtx } = useVisibility();\n const { execute } = useActions();\n const { getSnapshot, state: watchState } = useStateStore();\n const functions = useFunctions();\n const fullCtx = computed6(() => {\n const base = repeatScope ? {\n ...visibilityCtx.value,\n repeatItem: repeatScope.item,\n repeatIndex: repeatScope.index,\n repeatBasePath: repeatScope.basePath\n } : { ...visibilityCtx.value };\n base.functions = functions.value;\n return base;\n });\n const emitEvent = async (eventName) => {\n const binding = props.element.on?.[eventName];\n if (!binding) return;\n const actionBindings = Array.isArray(binding) ? binding : [binding];\n await resolveAndExecuteBindings(\n actionBindings,\n fullCtx.value,\n getSnapshot,\n execute\n );\n };\n const onEvent = (eventName) => {\n const binding = props.element.on?.[eventName];\n if (!binding) {\n return { emit: () => {\n }, shouldPreventDefault: false, bound: false };\n }\n const actionBindings = Array.isArray(binding) ? binding : [binding];\n const shouldPreventDefault = actionBindings.some((b) => b.preventDefault);\n return {\n emit: () => {\n void emitEvent(eventName);\n },\n shouldPreventDefault,\n bound: true\n };\n };\n const watchedValues = computed6(() => {\n const cfg = props.element.watch;\n if (!cfg) return void 0;\n const values = {};\n for (const path of Object.keys(cfg)) {\n values[path] = getByPath3(watchState.value, path);\n }\n return values;\n });\n watch3(\n watchedValues,\n (current, prev, onCleanup) => {\n const cfg = props.element.watch;\n if (!cfg || !current) return;\n let cancelled = false;\n onCleanup(() => {\n cancelled = true;\n });\n const paths = Object.keys(cfg);\n void (async () => {\n for (const path of paths) {\n if (cancelled) break;\n if (prev && current[path] === prev[path]) continue;\n const binding = cfg[path];\n if (!binding) continue;\n const bindings = Array.isArray(binding) ? binding : [binding];\n await resolveAndExecuteBindings(\n bindings,\n fullCtx.value,\n getSnapshot,\n execute,\n () => cancelled\n );\n }\n })().catch(console.error);\n },\n { deep: true }\n );\n return () => {\n const ctx = fullCtx.value;\n const isVisible = props.element.visible === void 0 ? true : evaluateVisibility2(props.element.visible, ctx);\n if (!isVisible) return null;\n const rawProps = props.element.props;\n const elementBindings = resolveBindings(rawProps, ctx);\n const resolvedProps = resolveElementProps(rawProps, ctx);\n const resolvedElement = resolvedProps !== props.element.props ? { ...props.element, props: resolvedProps } : props.element;\n const Component = props.registry[resolvedElement.type] ?? props.fallback;\n if (!Component) {\n console.warn(\n `[json-render] No renderer for component type: ${resolvedElement.type}`\n );\n return null;\n }\n const childrenVNodes = resolvedElement.repeat ? h2(RepeatChildren, {\n element: resolvedElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n }) : resolvedElement.children?.map((childKey) => {\n const childElement = props.spec.elements[childKey];\n if (!childElement) {\n if (!props.loading) {\n console.warn(\n `[json-render] Missing element \"${childKey}\" referenced as child of \"${resolvedElement.type}\". This element will not render.`\n );\n }\n return null;\n }\n return h2(ElementRenderer, {\n key: childKey,\n element: childElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n });\n }).filter((n) => n !== null) ?? void 0;\n return h2(\n ElementErrorBoundary,\n { elementType: resolvedElement.type },\n {\n default: () => h2(\n Component,\n {\n element: resolvedElement,\n emit: emitEvent,\n on: onEvent,\n bindings: elementBindings,\n loading: props.loading\n },\n { default: () => childrenVNodes }\n )\n }\n );\n };\n }\n});\nvar RepeatChildren = defineComponent6({\n name: \"JsonRenderRepeatChildren\",\n props: {\n element: {\n type: Object,\n required: true\n },\n spec: {\n type: Object,\n required: true\n },\n registry: {\n type: Object,\n required: true\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(props) {\n const { state } = useStateStore();\n return () => {\n const repeat = props.element.repeat;\n if (!repeat?.statePath) return null;\n const statePath = repeat.statePath;\n const raw = getByPath3(state.value, statePath);\n const items = Array.isArray(raw) ? raw : [];\n return items.map((itemValue, index) => {\n const key = repeat.key && typeof itemValue === \"object\" && itemValue !== null ? String(\n itemValue[repeat.key] ?? index\n ) : String(index);\n return h2(\n RepeatScopeProvider,\n { key, item: itemValue, index, basePath: `${statePath}/${index}` },\n {\n default: () => props.element.children?.map((childKey) => {\n const childElement = props.spec.elements[childKey];\n if (!childElement) {\n if (!props.loading) {\n console.warn(\n `[json-render] Missing element \"${childKey}\" referenced as child of \"${props.element.type}\" (repeat). This element will not render.`\n );\n }\n return null;\n }\n return h2(ElementRenderer, {\n key: childKey,\n element: childElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n });\n }).filter((n) => n !== null) ?? null\n }\n );\n });\n };\n }\n});\nvar Renderer = defineComponent6({\n name: \"JsonRenderer\",\n props: {\n spec: {\n type: Object,\n default: null\n },\n registry: {\n type: Object,\n required: true\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(props) {\n return () => {\n if (!props.spec?.root) return null;\n const rootElement = props.spec.elements[props.spec.root];\n if (!rootElement) return null;\n return h2(ElementRenderer, {\n element: rootElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n });\n };\n }\n});\nvar ConfirmationDialogManager = defineComponent6({\n name: \"ConfirmationDialogManager\",\n setup() {\n const { pendingConfirmation, confirm, cancel } = useActions();\n return () => {\n if (!pendingConfirmation?.action.confirm) return null;\n return h2(ConfirmDialog, {\n confirm: pendingConfirmation.action.confirm,\n onConfirm: confirm,\n onCancel: cancel\n });\n };\n }\n});\nvar JSONUIProvider = defineComponent6({\n name: \"JSONUIProvider\",\n props: {\n registry: {\n type: Object,\n required: true\n },\n store: {\n type: Object,\n default: void 0\n },\n initialState: {\n type: Object,\n default: void 0\n },\n handlers: {\n type: Object,\n default: void 0\n },\n navigate: {\n type: Function,\n default: void 0\n },\n validationFunctions: {\n type: Object,\n default: void 0\n },\n functions: {\n type: Object,\n default: void 0\n },\n onStateChange: {\n type: Function,\n default: void 0\n }\n },\n setup(props, { slots }) {\n return () => h2(\n StateProvider,\n {\n store: props.store,\n initialState: props.initialState,\n onStateChange: props.onStateChange\n },\n {\n default: () => h2(VisibilityProvider, null, {\n default: () => h2(\n ValidationProvider,\n { customFunctions: props.validationFunctions },\n {\n default: () => h2(\n ActionProvider,\n { handlers: props.handlers, navigate: props.navigate },\n {\n default: () => h2(\n FunctionsProvider,\n { functions: props.functions },\n {\n default: () => [\n slots.default?.(),\n h2(ConfirmationDialogManager)\n ]\n }\n )\n }\n )\n }\n )\n })\n }\n );\n }\n});\nfunction defineRegistry(_catalog, options) {\n const registry = {};\n if (options.components) {\n for (const [name, componentFn] of Object.entries(options.components)) {\n registry[name] = defineComponent6({\n name: `JsonRenderRegistry_${name}`,\n props: {\n element: {\n type: Object,\n required: true\n },\n emit: {\n type: Function,\n required: true\n },\n on: {\n type: Function,\n required: true\n },\n bindings: {\n type: Object,\n default: void 0\n },\n loading: {\n type: Boolean,\n default: void 0\n }\n },\n setup(registryProps, { slots }) {\n return () => componentFn({\n props: registryProps.element.props,\n children: slots.default?.(),\n emit: registryProps.emit,\n on: registryProps.on,\n bindings: registryProps.bindings,\n loading: registryProps.loading\n });\n }\n });\n }\n }\n const actionMap = options.actions ? Object.entries(options.actions) : [];\n const handlers = (getSetState, getState) => {\n const result = {};\n for (const [name, actionFn] of actionMap) {\n result[name] = async (params) => {\n const setState = getSetState();\n const state = getState();\n if (setState) {\n await actionFn(params, setState, state);\n }\n };\n }\n return result;\n };\n const executeAction2 = async (actionName, params, setState, state = {}) => {\n const entry = actionMap.find(([name]) => name === actionName);\n if (entry) {\n await entry[1](params, setState, state);\n } else {\n console.warn(`Unknown action: ${actionName}`);\n }\n };\n return { registry, handlers, executeAction: executeAction2 };\n}\nfunction createRenderer(catalog, components) {\n const registry = components;\n return defineComponent6({\n name: \"CatalogRenderer\",\n props: {\n spec: {\n type: Object,\n default: null\n },\n store: {\n type: Object,\n default: void 0\n },\n state: {\n type: Object,\n default: void 0\n },\n onAction: {\n type: Function,\n default: void 0\n },\n onStateChange: {\n type: Function,\n default: void 0\n },\n functions: {\n type: Object,\n default: void 0\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(rendererProps) {\n return () => {\n const actionHandlers = rendererProps.onAction ? new Proxy(\n {},\n {\n get: (_target, prop) => {\n return (params) => rendererProps.onAction(prop, params);\n },\n has: () => true\n }\n ) : void 0;\n return h2(\n StateProvider,\n {\n store: rendererProps.store,\n initialState: rendererProps.state,\n onStateChange: rendererProps.onStateChange\n },\n {\n default: () => h2(VisibilityProvider, null, {\n default: () => h2(ValidationProvider, null, {\n default: () => h2(\n ActionProvider,\n { handlers: actionHandlers },\n {\n default: () => h2(\n FunctionsProvider,\n { functions: rendererProps.functions },\n {\n default: () => [\n h2(Renderer, {\n spec: rendererProps.spec,\n registry,\n loading: rendererProps.loading,\n fallback: rendererProps.fallback\n }),\n h2(ConfirmationDialogManager)\n ]\n }\n )\n }\n )\n })\n })\n }\n );\n };\n }\n });\n}\nexport {\n ActionProvider,\n ConfirmDialog,\n JSONUIProvider,\n Renderer,\n RepeatScopeProvider,\n StateProvider,\n ValidationProvider,\n VisibilityProvider,\n buildSpecFromParts,\n createRenderer,\n createStateStore2 as createStateStore,\n defineRegistry,\n flatToTree,\n getTextFromParts,\n schema,\n useAction,\n useActions,\n useBoundProp,\n useChatUI,\n useFieldValidation,\n useIsVisible,\n useJsonRenderMessage,\n useOptionalValidation,\n useRepeatScope,\n useStateBinding,\n useStateStore,\n useStateValue,\n useUIStream,\n useValidation,\n useVisibility\n};\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;AAoBA,IAAI,IAA4B,uBAAO,oBAAoB,EACvD,IAAgB,EAAgB;CAClC,MAAM;CACN,OAAO;EACL,OAAO;GACL,MAAM;GACN,SAAS,KAAK;GACf;EACD,cAAc;GACZ,MAAM;GACN,SAAS,KAAK;GACf;EACD,eAAe;GACb,MAAM;GACN,SAAS,KAAK;GACf;EACF;CACD,MAAM,GAAO,EAAE,YAAS;EACtB,IAAM,IAAe,CAAC,CAAC,EAAM,OACvB,IAAiB,IAA4D,OAA7C,EAAiB,EAAM,gBAAgB,EAAE,CAAC,EAC1E,IAAQ,EAAM,SAAS,GACvB,IAAQ,EAAW,EAAM,aAAa,CAAC;AAK7C,MADA,EAHoB,EAAM,gBAAgB;AACxC,KAAM,QAAQ,EAAM,aAAa;IACjC,CACsB,EACpB,CAAC,GAAc;GACjB,IAAI,IAAW,EAAM,gBAAgB,OAAO,KAAK,EAAM,aAAa,CAAC,SAAS,IAAI,EAAkB,EAAM,aAAa,GAAG,EAAE;AAC5H,WACQ,EAAM,eACX,MAAoB;AACnB,QAAI,CAAC,EAAiB;IACtB,IAAM,IAAW,OAAO,KAAK,EAAgB,CAAC,SAAS,IAAI,EAAkB,EAAgB,GAAG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W;IAC/B,IAAM,IAAW,GAAa,EACxB,IAAQ,GAAU;AACxB,IAAI,KACF,MAAM,EAAS,GAAQ,GAAU,EAAM;;AAI7C,UAAO;;EAUoB,eARN,OAAO,GAAY,GAAQ,GAAU,IAAQ,EAAE,KAAK;GACzE,IAAM,IAAQ,EAAU,MAAM,CAAC,OAAU,MAAS,EAAW;AAC7D,GAAI,IACF,MAAM,EAAM,GAAG,GAAQ,GAAU,EAAM,GAEvC,QAAQ,KAAK,mBAAmB,IAAa;;EAGW"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["defineComponent2","computed2","inject2","defineComponent3","ref2","inject3","defineComponent4","ref3","inject4","defineComponent5","inject5","defineComponent6","computed6","inject6","ref5","getByPath3","evaluateVisibility2","h2"],"sources":["../../../../../../../node_modules/@json-render/vue/dist/index.mjs"],"sourcesContent":["import {\n schema\n} from \"./chunk-WIPZLAF7.mjs\";\n\n// src/composables/state.ts\nimport {\n computed,\n defineComponent,\n inject,\n onUnmounted,\n provide,\n ref,\n shallowRef,\n watch\n} from \"vue\";\nimport {\n createStateStore,\n getByPath\n} from \"@json-render/core\";\nimport { flattenToPointers } from \"@json-render/core/store-utils\";\nvar STATE_KEY = /* @__PURE__ */ Symbol(\"json-render:state\");\nvar StateProvider = defineComponent({\n name: \"StateProvider\",\n props: {\n store: {\n type: Object,\n default: void 0\n },\n initialState: {\n type: Object,\n default: void 0\n },\n onStateChange: {\n type: Function,\n default: void 0\n }\n },\n setup(props, { slots }) {\n const isControlled = !!props.store;\n const internalStore = !isControlled ? createStateStore(props.initialState ?? {}) : null;\n const store = props.store ?? internalStore;\n const state = shallowRef(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n state.value = store.getSnapshot();\n });\n onUnmounted(unsubscribe);\n if (!isControlled) {\n let prevFlat = props.initialState && Object.keys(props.initialState).length > 0 ? flattenToPointers(props.initialState) : {};\n watch(\n () => props.initialState,\n (newInitialState) => {\n if (!newInitialState) return;\n const nextFlat = Object.keys(newInitialState).length > 0 ? flattenToPointers(newInitialState) : {};\n const allKeys = /* @__PURE__ */ new Set([\n ...Object.keys(prevFlat),\n ...Object.keys(nextFlat)\n ]);\n const updates = {};\n for (const key of allKeys) {\n if (prevFlat[key] !== nextFlat[key]) {\n updates[key] = key in nextFlat ? nextFlat[key] : void 0;\n }\n }\n prevFlat = nextFlat;\n if (Object.keys(updates).length > 0) {\n store.update(updates);\n }\n }\n );\n }\n const onStateChangeRef = ref(props.onStateChange);\n watch(\n () => props.onStateChange,\n (fn) => {\n onStateChangeRef.value = fn;\n }\n );\n const get = (path) => store.get(path);\n const getSnapshot = () => store.getSnapshot();\n const set = (path, value) => {\n const prev = store.getSnapshot();\n store.set(path, value);\n if (!isControlled && store.getSnapshot() !== prev) {\n onStateChangeRef.value?.([{ path, value }]);\n }\n };\n const update = (updates) => {\n const prev = store.getSnapshot();\n store.update(updates);\n if (!isControlled && store.getSnapshot() !== prev) {\n const changes = [];\n for (const [path, value] of Object.entries(updates)) {\n if (getByPath(prev, path) !== value) {\n changes.push({ path, value });\n }\n }\n if (changes.length > 0) {\n onStateChangeRef.value?.(changes);\n }\n }\n };\n provide(STATE_KEY, {\n state,\n get,\n set,\n update,\n getSnapshot\n });\n return () => slots.default?.();\n }\n});\nfunction useStateStore() {\n const ctx = inject(STATE_KEY);\n if (!ctx) {\n throw new Error(\"useStateStore must be used within a StateProvider\");\n }\n return ctx;\n}\nfunction useStateValue(path) {\n const { state } = useStateStore();\n return computed(() => getByPath(state.value, path));\n}\nfunction useStateBinding(path) {\n const { state, set } = useStateStore();\n const value = computed(() => getByPath(state.value, path));\n const setValue = (newValue) => set(path, newValue);\n return [value, setValue];\n}\n\n// src/composables/visibility.ts\nimport {\n computed as computed2,\n defineComponent as defineComponent2,\n inject as inject2,\n provide as provide2\n} from \"vue\";\nimport {\n evaluateVisibility\n} from \"@json-render/core\";\nvar VISIBILITY_KEY = /* @__PURE__ */ Symbol(\"json-render:visibility\");\nvar VisibilityProvider = defineComponent2({\n name: \"VisibilityProvider\",\n setup(_, { slots }) {\n const { state } = useStateStore();\n const ctx = computed2(() => ({\n stateModel: state.value\n }));\n const isVisible = (condition) => evaluateVisibility(condition, ctx.value);\n provide2(VISIBILITY_KEY, { isVisible, ctx });\n return () => slots.default?.();\n }\n});\nfunction useVisibility() {\n const ctx = inject2(VISIBILITY_KEY);\n if (!ctx) {\n throw new Error(\"useVisibility must be used within a VisibilityProvider\");\n }\n return ctx;\n}\nfunction useIsVisible(condition) {\n const { ctx } = useVisibility();\n return computed2(() => evaluateVisibility(condition, ctx.value));\n}\n\n// src/composables/actions.ts\nimport {\n computed as computed4,\n defineComponent as defineComponent4,\n h,\n inject as inject4,\n provide as provide4,\n ref as ref3,\n watch as watch2\n} from \"vue\";\nimport {\n resolveAction,\n executeAction\n} from \"@json-render/core\";\n\n// src/composables/validation.ts\nimport {\n computed as computed3,\n defineComponent as defineComponent3,\n inject as inject3,\n onMounted,\n onUnmounted as onUnmounted2,\n provide as provide3,\n ref as ref2\n} from \"vue\";\nimport {\n runValidation\n} from \"@json-render/core\";\nvar VALIDATION_KEY = /* @__PURE__ */ Symbol(\"json-render:validation\");\nfunction dynamicArgsEqual(a, b) {\n if (a === b) return true;\n if (!a || !b) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n const va = a[key];\n const vb = b[key];\n if (va === vb) continue;\n if (typeof va === \"object\" && va !== null && typeof vb === \"object\" && vb !== null) {\n const sa = va.$state;\n const sb = vb.$state;\n if (typeof sa === \"string\" && sa === sb) continue;\n }\n return false;\n }\n return true;\n}\nfunction validationConfigEqual(a, b) {\n if (a === b) return true;\n if (a.validateOn !== b.validateOn) return false;\n const ac = a.checks ?? [];\n const bc = b.checks ?? [];\n if (ac.length !== bc.length) return false;\n for (let i = 0; i < ac.length; i++) {\n const ca = ac[i];\n const cb = bc[i];\n if (ca.type !== cb.type) return false;\n if (ca.message !== cb.message) return false;\n if (!dynamicArgsEqual(ca.args, cb.args)) return false;\n }\n return true;\n}\nvar ValidationProvider = defineComponent3({\n name: \"ValidationProvider\",\n props: {\n customFunctions: {\n type: Object,\n default: () => ({})\n }\n },\n setup(props, { slots }) {\n const { state } = useStateStore();\n const fieldStates = ref2({});\n const fieldConfigs = ref2({});\n const registerField = (path, config) => {\n const existing = fieldConfigs.value[path];\n if (existing && validationConfigEqual(existing, config)) return;\n fieldConfigs.value = { ...fieldConfigs.value, [path]: config };\n };\n const validate = (path, config) => {\n const currentState = state.value;\n const segments = path.split(\"/\").filter(Boolean);\n let value = currentState;\n for (const seg of segments) {\n if (value != null && typeof value === \"object\") {\n value = value[seg];\n } else {\n value = void 0;\n break;\n }\n }\n const result = runValidation(config, {\n value,\n stateModel: currentState,\n customFunctions: props.customFunctions\n });\n fieldStates.value = {\n ...fieldStates.value,\n [path]: {\n touched: fieldStates.value[path]?.touched ?? true,\n validated: true,\n result\n }\n };\n return result;\n };\n const touch = (path) => {\n fieldStates.value = {\n ...fieldStates.value,\n [path]: {\n ...fieldStates.value[path],\n touched: true,\n validated: fieldStates.value[path]?.validated ?? false,\n result: fieldStates.value[path]?.result ?? null\n }\n };\n };\n const clear = (path) => {\n const { [path]: _, ...rest } = fieldStates.value;\n fieldStates.value = rest;\n };\n const validateAll = () => {\n let allValid = true;\n for (const [path, config] of Object.entries(fieldConfigs.value)) {\n const result = validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n return allValid;\n };\n provide3(VALIDATION_KEY, {\n get customFunctions() {\n return props.customFunctions;\n },\n get fieldStates() {\n return fieldStates.value;\n },\n validate,\n touch,\n clear,\n validateAll,\n registerField\n });\n return () => slots.default?.();\n }\n});\nfunction useOptionalValidation() {\n return inject3(\n VALIDATION_KEY,\n null\n ) ?? null;\n}\nfunction useValidation() {\n const ctx = inject3(VALIDATION_KEY);\n if (!ctx) {\n throw new Error(\"useValidation must be used within a ValidationProvider\");\n }\n return ctx;\n}\nfunction useFieldValidation(path, config) {\n const ctx = useValidation();\n onMounted(() => {\n if (path && config) {\n ctx.registerField(path, config);\n }\n });\n onUnmounted2(() => {\n ctx.clear(path);\n });\n const defaultState = {\n touched: false,\n validated: false,\n result: null\n };\n return {\n state: computed3(() => ctx.fieldStates[path] ?? defaultState),\n validate: () => ctx.validate(path, config ?? { checks: [] }),\n touch: () => ctx.touch(path),\n clear: () => ctx.clear(path),\n errors: computed3(() => ctx.fieldStates[path]?.result?.errors ?? []),\n isValid: computed3(() => ctx.fieldStates[path]?.result?.valid ?? true)\n };\n}\n\n// src/composables/actions.ts\nvar idCounter = 0;\nfunction generateUniqueId() {\n idCounter += 1;\n return `${Date.now()}-${idCounter}`;\n}\nfunction deepResolveValue(value, get) {\n if (value === null || value === void 0) return value;\n if (value === \"$id\") {\n return generateUniqueId();\n }\n if (typeof value === \"object\" && !Array.isArray(value)) {\n const obj = value;\n const keys = Object.keys(obj);\n if (keys.length === 1 && typeof obj.$state === \"string\") {\n return get(obj.$state);\n }\n if (keys.length === 1 && \"$id\" in obj) {\n return generateUniqueId();\n }\n }\n if (Array.isArray(value)) {\n return value.map((item) => deepResolveValue(item, get));\n }\n if (typeof value === \"object\") {\n const resolved = {};\n for (const [key, val] of Object.entries(value)) {\n resolved[key] = deepResolveValue(val, get);\n }\n return resolved;\n }\n return value;\n}\nvar ACTIONS_KEY = /* @__PURE__ */ Symbol(\"json-render:actions\");\nvar ActionProvider = defineComponent4({\n name: \"ActionProvider\",\n props: {\n handlers: {\n type: Object,\n default: () => ({})\n },\n navigate: {\n type: Function,\n default: void 0\n }\n },\n setup(props, { slots }) {\n const { get, set, getSnapshot } = useStateStore();\n const validation = useOptionalValidation();\n const handlers = ref3(props.handlers ?? {});\n const loadingActions = ref3(/* @__PURE__ */ new Set());\n const pendingConfirmation = ref3(null);\n watch2(\n () => props.handlers,\n (newHandlers) => {\n if (newHandlers) handlers.value = newHandlers;\n }\n );\n const registerHandler = (name, handler) => {\n handlers.value = { ...handlers.value, [name]: handler };\n };\n const execute = async (binding) => {\n const resolved = resolveAction(binding, getSnapshot());\n if (resolved.action === \"setState\" && resolved.params) {\n const statePath = resolved.params.statePath;\n const value = resolved.params.value;\n if (statePath) {\n set(statePath, value);\n }\n return;\n }\n if (resolved.action === \"pushState\" && resolved.params) {\n const statePath = resolved.params.statePath;\n const rawValue = resolved.params.value;\n if (statePath) {\n const resolvedValue = deepResolveValue(rawValue, get);\n const arr = get(statePath) ?? [];\n set(statePath, [...arr, resolvedValue]);\n const clearStatePath = resolved.params.clearStatePath;\n if (clearStatePath) {\n set(clearStatePath, \"\");\n }\n }\n return;\n }\n if (resolved.action === \"removeState\" && resolved.params) {\n const statePath = resolved.params.statePath;\n const index = resolved.params.index;\n if (statePath !== void 0 && index !== void 0) {\n const arr = get(statePath) ?? [];\n set(\n statePath,\n arr.filter((_, i) => i !== index)\n );\n }\n return;\n }\n if (resolved.action === \"validateForm\") {\n const validateAll = validation?.validateAll;\n if (!validateAll) {\n console.warn(\n \"validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.\"\n );\n return;\n }\n const valid = validateAll();\n const errors = {};\n for (const [path, fs] of Object.entries(validation.fieldStates)) {\n if (fs.result && !fs.result.valid) {\n errors[path] = fs.result.errors;\n }\n }\n const statePath = resolved.params?.statePath || \"/formValidation\";\n set(statePath, { valid, errors });\n return;\n }\n if (resolved.action === \"push\" && resolved.params) {\n const screen = resolved.params.screen;\n if (screen) {\n const currentScreen = get(\"/currentScreen\");\n const navStack = get(\"/navStack\") ?? [];\n if (currentScreen) {\n set(\"/navStack\", [...navStack, currentScreen]);\n } else {\n set(\"/navStack\", [...navStack, \"\"]);\n }\n set(\"/currentScreen\", screen);\n }\n return;\n }\n if (resolved.action === \"pop\") {\n const navStack = get(\"/navStack\") ?? [];\n if (navStack.length > 0) {\n const previousScreen = navStack[navStack.length - 1];\n set(\"/navStack\", navStack.slice(0, -1));\n if (previousScreen) {\n set(\"/currentScreen\", previousScreen);\n } else {\n set(\"/currentScreen\", void 0);\n }\n }\n return;\n }\n const handler = handlers.value[resolved.action];\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.action}`);\n return;\n }\n if (resolved.confirm) {\n await new Promise((resolve, reject) => {\n pendingConfirmation.value = {\n action: resolved,\n handler,\n resolve: () => {\n pendingConfirmation.value = null;\n resolve();\n },\n reject: () => {\n pendingConfirmation.value = null;\n reject(new Error(\"Action cancelled\"));\n }\n };\n });\n const addLoading2 = new Set(loadingActions.value);\n addLoading2.add(resolved.action);\n loadingActions.value = addLoading2;\n try {\n await executeAction({\n action: resolved,\n handler,\n setState: set,\n navigate: props.navigate,\n executeAction: async (name) => {\n const subBinding = { action: name };\n await execute(subBinding);\n }\n });\n } finally {\n const removeLoading = new Set(loadingActions.value);\n removeLoading.delete(resolved.action);\n loadingActions.value = removeLoading;\n }\n return;\n }\n const addLoading = new Set(loadingActions.value);\n addLoading.add(resolved.action);\n loadingActions.value = addLoading;\n try {\n await executeAction({\n action: resolved,\n handler,\n setState: set,\n navigate: props.navigate,\n executeAction: async (name) => {\n const subBinding = { action: name };\n await execute(subBinding);\n }\n });\n } finally {\n const removeLoading = new Set(loadingActions.value);\n removeLoading.delete(resolved.action);\n loadingActions.value = removeLoading;\n }\n };\n const confirm = () => pendingConfirmation.value?.resolve();\n const cancel = () => pendingConfirmation.value?.reject();\n provide4(ACTIONS_KEY, {\n get handlers() {\n return handlers.value;\n },\n get loadingActions() {\n return loadingActions.value;\n },\n get pendingConfirmation() {\n return pendingConfirmation.value;\n },\n execute,\n confirm,\n cancel,\n registerHandler\n });\n return () => slots.default?.();\n }\n});\nfunction useActions() {\n const ctx = inject4(ACTIONS_KEY);\n if (!ctx) {\n throw new Error(\"useActions must be used within an ActionProvider\");\n }\n return ctx;\n}\nfunction useAction(binding) {\n const ctx = useActions();\n return {\n execute: () => ctx.execute(binding),\n isLoading: computed4(() => ctx.loadingActions.has(binding.action))\n };\n}\nvar ConfirmDialog = defineComponent4({\n name: \"ConfirmDialog\",\n props: {\n confirm: {\n type: Object,\n required: true\n },\n onConfirm: {\n type: Function,\n required: true\n },\n onCancel: {\n type: Function,\n required: true\n }\n },\n setup(props) {\n return () => {\n const isDanger = props.confirm.variant === \"danger\";\n return h(\n \"div\",\n {\n style: {\n position: \"fixed\",\n inset: \"0\",\n backgroundColor: \"rgba(0, 0, 0, 0.5)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: \"50\"\n },\n onClick: props.onCancel\n },\n [\n h(\n \"div\",\n {\n style: {\n backgroundColor: \"white\",\n borderRadius: \"8px\",\n padding: \"24px\",\n maxWidth: \"400px\",\n width: \"100%\",\n boxShadow: \"0 20px 25px -5px rgba(0, 0, 0, 0.1)\"\n },\n onClick: (e) => e.stopPropagation()\n },\n [\n h(\n \"h3\",\n {\n style: {\n margin: \"0 0 8px 0\",\n fontSize: \"18px\",\n fontWeight: \"600\"\n }\n },\n props.confirm.title\n ),\n h(\n \"p\",\n {\n style: { margin: \"0 0 24px 0\", color: \"#6b7280\" }\n },\n props.confirm.message\n ),\n h(\n \"div\",\n {\n style: {\n display: \"flex\",\n gap: \"12px\",\n justifyContent: \"flex-end\"\n }\n },\n [\n h(\n \"button\",\n {\n style: {\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"1px solid #d1d5db\",\n backgroundColor: \"white\",\n cursor: \"pointer\"\n },\n onClick: props.onCancel\n },\n props.confirm.cancelLabel ?? \"Cancel\"\n ),\n h(\n \"button\",\n {\n style: {\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"none\",\n backgroundColor: isDanger ? \"#dc2626\" : \"#3b82f6\",\n color: \"white\",\n cursor: \"pointer\"\n },\n onClick: props.onConfirm\n },\n props.confirm.confirmLabel ?? \"Confirm\"\n )\n ]\n )\n ]\n )\n ]\n );\n };\n }\n});\n\n// src/composables/repeat-scope.ts\nimport { defineComponent as defineComponent5, inject as inject5, provide as provide5 } from \"vue\";\nvar REPEAT_SCOPE_KEY = /* @__PURE__ */ Symbol(\"json-render:repeat-scope\");\nvar RepeatScopeProvider = defineComponent5({\n name: \"RepeatScopeProvider\",\n props: {\n item: {\n required: true\n },\n index: {\n type: Number,\n required: true\n },\n basePath: {\n type: String,\n required: true\n }\n },\n setup(props, { slots }) {\n provide5(REPEAT_SCOPE_KEY, props);\n return () => slots.default?.();\n }\n});\nfunction useRepeatScope() {\n return inject5(\n REPEAT_SCOPE_KEY,\n null\n ) ?? null;\n}\n\n// src/index.ts\nimport { createStateStore as createStateStore2 } from \"@json-render/core\";\n\n// src/hooks.ts\nimport {\n ref as ref4,\n shallowRef as shallowRef2,\n computed as computed5,\n onUnmounted as onUnmounted3,\n isRef\n} from \"vue\";\nimport {\n setByPath,\n getByPath as getByPath2,\n removeByPath,\n createMixedStreamParser,\n applySpecPatch,\n nestedToFlat,\n SPEC_DATA_PART_TYPE\n} from \"@json-render/core\";\nfunction parseLine(line) {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"//\")) {\n return null;\n }\n const parsed = JSON.parse(trimmed);\n if (parsed.__meta === \"usage\") {\n return {\n type: \"usage\",\n usage: {\n promptTokens: parsed.promptTokens ?? 0,\n completionTokens: parsed.completionTokens ?? 0,\n totalTokens: parsed.totalTokens ?? 0\n }\n };\n }\n return { type: \"patch\", patch: parsed };\n } catch {\n return null;\n }\n}\nfunction setSpecValue(newSpec, path, value) {\n if (path === \"/root\") {\n newSpec.root = value;\n return;\n }\n if (path === \"/state\") {\n newSpec.state = value;\n return;\n }\n if (path.startsWith(\"/state/\")) {\n if (!newSpec.state) newSpec.state = {};\n const statePath = path.slice(\"/state\".length);\n setByPath(newSpec.state, statePath, value);\n return;\n }\n if (path.startsWith(\"/elements/\")) {\n const pathParts = path.slice(\"/elements/\".length).split(\"/\");\n const elementKey = pathParts[0];\n if (!elementKey) return;\n if (pathParts.length === 1) {\n newSpec.elements[elementKey] = value;\n } else {\n const element = newSpec.elements[elementKey];\n if (element) {\n const propPath = \"/\" + pathParts.slice(1).join(\"/\");\n const newElement = { ...element };\n setByPath(\n newElement,\n propPath,\n value\n );\n newSpec.elements[elementKey] = newElement;\n }\n }\n }\n}\nfunction removeSpecValue(newSpec, path) {\n if (path === \"/state\") {\n delete newSpec.state;\n return;\n }\n if (path.startsWith(\"/state/\") && newSpec.state) {\n const statePath = path.slice(\"/state\".length);\n removeByPath(newSpec.state, statePath);\n return;\n }\n if (path.startsWith(\"/elements/\")) {\n const pathParts = path.slice(\"/elements/\".length).split(\"/\");\n const elementKey = pathParts[0];\n if (!elementKey) return;\n if (pathParts.length === 1) {\n const { [elementKey]: _, ...rest } = newSpec.elements;\n newSpec.elements = rest;\n } else {\n const element = newSpec.elements[elementKey];\n if (element) {\n const propPath = \"/\" + pathParts.slice(1).join(\"/\");\n const newElement = { ...element };\n removeByPath(\n newElement,\n propPath\n );\n newSpec.elements[elementKey] = newElement;\n }\n }\n }\n}\nfunction getSpecValue(spec, path) {\n if (path === \"/root\") return spec.root;\n if (path === \"/state\") return spec.state;\n if (path.startsWith(\"/state/\") && spec.state) {\n const statePath = path.slice(\"/state\".length);\n return getByPath2(spec.state, statePath);\n }\n return getByPath2(spec, path);\n}\nfunction applyPatch(spec, patch) {\n const newSpec = {\n ...spec,\n elements: { ...spec.elements },\n ...spec.state ? { state: { ...spec.state } } : {}\n };\n switch (patch.op) {\n case \"add\":\n case \"replace\": {\n setSpecValue(newSpec, patch.path, patch.value);\n break;\n }\n case \"remove\": {\n removeSpecValue(newSpec, patch.path);\n break;\n }\n case \"move\": {\n if (!patch.from) break;\n const moveValue = getSpecValue(newSpec, patch.from);\n removeSpecValue(newSpec, patch.from);\n setSpecValue(newSpec, patch.path, moveValue);\n break;\n }\n case \"copy\": {\n if (!patch.from) break;\n const copyValue = getSpecValue(newSpec, patch.from);\n setSpecValue(newSpec, patch.path, copyValue);\n break;\n }\n case \"test\": {\n break;\n }\n }\n return newSpec;\n}\nfunction useUIStream({\n api,\n onComplete,\n onError\n}) {\n const spec = shallowRef2(null);\n const isStreaming = ref4(false);\n const error = ref4(null);\n const usage = ref4(null);\n const rawLines = ref4([]);\n const onCompleteRef = ref4(onComplete);\n const onErrorRef = ref4(onError);\n let abortController = null;\n const clear = () => {\n spec.value = null;\n error.value = null;\n usage.value = null;\n rawLines.value = [];\n };\n const send = async (prompt, context) => {\n abortController?.abort();\n abortController = new AbortController();\n isStreaming.value = true;\n error.value = null;\n usage.value = null;\n rawLines.value = [];\n const previousSpec = context?.previousSpec;\n let currentSpec = previousSpec && previousSpec.root ? { ...previousSpec, elements: { ...previousSpec.elements } } : { root: \"\", elements: {} };\n spec.value = currentSpec;\n try {\n const response = await fetch(api, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n prompt,\n context,\n currentSpec\n }),\n signal: abortController.signal\n });\n if (!response.ok) {\n let errorMessage = `HTTP error: ${response.status}`;\n try {\n const errorData = await response.json();\n if (errorData.message) {\n errorMessage = errorData.message;\n } else if (errorData.error) {\n errorMessage = errorData.error;\n }\n } catch {\n }\n throw new Error(errorMessage);\n }\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"No response body\");\n }\n const decoder = new TextDecoder();\n let buffer = \"\";\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const result = parseLine(trimmed);\n if (!result) continue;\n if (result.type === \"usage\") {\n usage.value = result.usage;\n } else {\n rawLines.value = [...rawLines.value, trimmed];\n currentSpec = applyPatch(currentSpec, result.patch);\n spec.value = { ...currentSpec };\n }\n }\n }\n if (buffer.trim()) {\n const trimmed = buffer.trim();\n const result = parseLine(trimmed);\n if (result) {\n if (result.type === \"usage\") {\n usage.value = result.usage;\n } else {\n rawLines.value = [...rawLines.value, trimmed];\n currentSpec = applyPatch(currentSpec, result.patch);\n spec.value = { ...currentSpec };\n }\n }\n }\n onCompleteRef.value?.(currentSpec);\n } catch (err) {\n if (err.name === \"AbortError\") {\n return;\n }\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n error.value = resolvedError;\n onErrorRef.value?.(resolvedError);\n } finally {\n isStreaming.value = false;\n }\n };\n onUnmounted3(() => {\n abortController?.abort();\n });\n return {\n spec,\n isStreaming,\n error,\n usage,\n rawLines,\n send,\n clear\n };\n}\nfunction flatToTree(elements) {\n const elementMap = {};\n let root = \"\";\n for (const element of elements) {\n elementMap[element.key] = {\n type: element.type,\n props: element.props,\n children: [],\n visible: element.visible\n };\n }\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n if (!parent.children) {\n parent.children = [];\n }\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n return { root, elements: elementMap };\n}\nfunction useBoundProp(propValue, bindingPath) {\n const { set } = useStateStore();\n return [\n propValue,\n (value) => {\n if (bindingPath) set(bindingPath, value);\n }\n ];\n}\nfunction isSpecDataPart(data) {\n if (typeof data !== \"object\" || data === null) return false;\n const obj = data;\n switch (obj.type) {\n case \"patch\":\n return typeof obj.patch === \"object\" && obj.patch !== null;\n case \"flat\":\n case \"nested\":\n return typeof obj.spec === \"object\" && obj.spec !== null;\n default:\n return false;\n }\n}\nfunction buildSpecFromParts(parts) {\n const spec = { root: \"\", elements: {} };\n let hasSpec = false;\n for (const part of parts) {\n if (part.type === SPEC_DATA_PART_TYPE) {\n if (!isSpecDataPart(part.data)) continue;\n const payload = part.data;\n if (payload.type === \"patch\") {\n hasSpec = true;\n applySpecPatch(spec, payload.patch);\n } else if (payload.type === \"flat\") {\n hasSpec = true;\n Object.assign(spec, payload.spec);\n } else if (payload.type === \"nested\") {\n hasSpec = true;\n const flat = nestedToFlat(payload.spec);\n Object.assign(spec, flat);\n }\n }\n }\n return hasSpec ? spec : null;\n}\nfunction getTextFromParts(parts) {\n return parts.filter(\n (p) => p.type === \"text\" && typeof p.text === \"string\"\n ).map((p) => p.text.trim()).filter(Boolean).join(\"\\n\\n\");\n}\nfunction useJsonRenderMessage(parts) {\n const partsRef = isRef(parts) ? parts : ref4(parts);\n const spec = computed5(() => buildSpecFromParts(partsRef.value));\n const text = computed5(() => getTextFromParts(partsRef.value));\n const hasSpec = computed5(\n () => spec.value !== null && Object.keys(spec.value.elements || {}).length > 0\n );\n return { spec, text, hasSpec };\n}\nvar chatMessageIdCounter = 0;\nfunction generateChatId() {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n chatMessageIdCounter += 1;\n return `msg-${Date.now()}-${chatMessageIdCounter}`;\n}\nfunction useChatUI({\n api,\n onComplete,\n onError\n}) {\n const messages = ref4([]);\n const isStreaming = ref4(false);\n const error = ref4(null);\n const onCompleteRef = ref4(onComplete);\n const onErrorRef = ref4(onError);\n let abortController = null;\n const clear = () => {\n messages.value = [];\n error.value = null;\n };\n const send = async (text) => {\n if (!text.trim()) return;\n abortController?.abort();\n abortController = new AbortController();\n const userMessage = {\n id: generateChatId(),\n role: \"user\",\n text: text.trim(),\n spec: null\n };\n const assistantId = generateChatId();\n const assistantMessage = {\n id: assistantId,\n role: \"assistant\",\n text: \"\",\n spec: null\n };\n messages.value = [...messages.value, userMessage, assistantMessage];\n isStreaming.value = true;\n error.value = null;\n const historyForApi = [\n ...messages.value.filter((m) => m.id !== assistantId).map((m) => ({ role: m.role, content: m.text })),\n { role: \"user\", content: text.trim() }\n ];\n let accumulatedText = \"\";\n let currentSpec = { root: \"\", elements: {} };\n let hasSpec = false;\n try {\n const response = await fetch(api, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ messages: historyForApi }),\n signal: abortController.signal\n });\n if (!response.ok) {\n let errorMessage = `HTTP error: ${response.status}`;\n try {\n const errorData = await response.json();\n if (errorData.message) {\n errorMessage = errorData.message;\n } else if (errorData.error) {\n errorMessage = errorData.error;\n }\n } catch {\n }\n throw new Error(errorMessage);\n }\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"No response body\");\n }\n const decoder = new TextDecoder();\n const parser = createMixedStreamParser({\n onPatch(patch) {\n hasSpec = true;\n applySpecPatch(currentSpec, patch);\n messages.value = messages.value.map(\n (m) => m.id === assistantId ? {\n ...m,\n spec: {\n root: currentSpec.root,\n elements: { ...currentSpec.elements },\n ...currentSpec.state ? { state: { ...currentSpec.state } } : {}\n }\n } : m\n );\n },\n onText(line) {\n accumulatedText += (accumulatedText ? \"\\n\" : \"\") + line;\n messages.value = messages.value.map(\n (m) => m.id === assistantId ? { ...m, text: accumulatedText } : m\n );\n }\n });\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n parser.push(decoder.decode(value, { stream: true }));\n }\n parser.flush();\n const finalMessage = {\n id: assistantId,\n role: \"assistant\",\n text: accumulatedText,\n spec: hasSpec ? {\n root: currentSpec.root,\n elements: { ...currentSpec.elements },\n ...currentSpec.state ? { state: { ...currentSpec.state } } : {}\n } : null\n };\n onCompleteRef.value?.(finalMessage);\n } catch (err) {\n if (err.name === \"AbortError\") {\n return;\n }\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n error.value = resolvedError;\n messages.value = messages.value.filter(\n (m) => m.id !== assistantId || m.text.length > 0\n );\n onErrorRef.value?.(resolvedError);\n } finally {\n isStreaming.value = false;\n }\n };\n onUnmounted3(() => {\n abortController?.abort();\n });\n return {\n messages,\n isStreaming,\n error,\n send,\n clear\n };\n}\n\n// src/renderer.ts\nimport {\n computed as computed6,\n defineComponent as defineComponent6,\n h as h2,\n inject as inject6,\n onErrorCaptured,\n provide as provide6,\n ref as ref5,\n watch as watch3\n} from \"vue\";\nimport {\n resolveElementProps,\n resolveBindings,\n resolveActionParam,\n evaluateVisibility as evaluateVisibility2,\n getByPath as getByPath3\n} from \"@json-render/core\";\nvar EMPTY_FUNCTIONS = {};\nvar FUNCTIONS_KEY = /* @__PURE__ */ Symbol(\"json-render:functions\");\nvar FunctionsProvider = defineComponent6({\n name: \"FunctionsProvider\",\n props: {\n functions: {\n type: Object,\n default: void 0\n }\n },\n setup(props, { slots }) {\n const fns = computed6(() => props.functions ?? EMPTY_FUNCTIONS);\n provide6(FUNCTIONS_KEY, fns);\n return () => slots.default?.();\n }\n});\nfunction useFunctions() {\n return inject6(\n FUNCTIONS_KEY,\n computed6(() => EMPTY_FUNCTIONS)\n );\n}\nvar ElementErrorBoundary = defineComponent6({\n name: \"ElementErrorBoundary\",\n props: {\n elementType: {\n type: String,\n required: true\n }\n },\n setup(props, { slots }) {\n const hasError = ref5(false);\n onErrorCaptured((error) => {\n console.error(\n `[json-render] Rendering error in <${props.elementType}>:`,\n error\n );\n hasError.value = true;\n return false;\n });\n return () => {\n if (hasError.value) return null;\n return slots.default?.();\n };\n }\n});\nasync function resolveAndExecuteBindings(actionBindings, ctx, getSnapshot, execute, cancelled) {\n for (const b of actionBindings) {\n if (cancelled?.()) break;\n if (!b.params) {\n await execute(b);\n if (cancelled?.()) break;\n continue;\n }\n const liveCtx = {\n ...ctx,\n stateModel: getSnapshot()\n };\n const resolved = {};\n for (const [key, val] of Object.entries(b.params)) {\n resolved[key] = resolveActionParam(val, liveCtx);\n }\n await execute({ ...b, params: resolved });\n if (cancelled?.()) break;\n }\n}\nvar ElementRenderer = defineComponent6({\n name: \"JsonRenderElement\",\n props: {\n element: {\n type: Object,\n required: true\n },\n spec: {\n type: Object,\n required: true\n },\n registry: {\n type: Object,\n required: true\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(props) {\n const repeatScope = useRepeatScope();\n const { ctx: visibilityCtx } = useVisibility();\n const { execute } = useActions();\n const { getSnapshot, state: watchState } = useStateStore();\n const functions = useFunctions();\n const fullCtx = computed6(() => {\n const base = repeatScope ? {\n ...visibilityCtx.value,\n repeatItem: repeatScope.item,\n repeatIndex: repeatScope.index,\n repeatBasePath: repeatScope.basePath\n } : { ...visibilityCtx.value };\n base.functions = functions.value;\n return base;\n });\n const emitEvent = async (eventName) => {\n const binding = props.element.on?.[eventName];\n if (!binding) return;\n const actionBindings = Array.isArray(binding) ? binding : [binding];\n await resolveAndExecuteBindings(\n actionBindings,\n fullCtx.value,\n getSnapshot,\n execute\n );\n };\n const onEvent = (eventName) => {\n const binding = props.element.on?.[eventName];\n if (!binding) {\n return { emit: () => {\n }, shouldPreventDefault: false, bound: false };\n }\n const actionBindings = Array.isArray(binding) ? binding : [binding];\n const shouldPreventDefault = actionBindings.some((b) => b.preventDefault);\n return {\n emit: () => {\n void emitEvent(eventName);\n },\n shouldPreventDefault,\n bound: true\n };\n };\n const watchedValues = computed6(() => {\n const cfg = props.element.watch;\n if (!cfg) return void 0;\n const values = {};\n for (const path of Object.keys(cfg)) {\n values[path] = getByPath3(watchState.value, path);\n }\n return values;\n });\n watch3(\n watchedValues,\n (current, prev, onCleanup) => {\n const cfg = props.element.watch;\n if (!cfg || !current) return;\n let cancelled = false;\n onCleanup(() => {\n cancelled = true;\n });\n const paths = Object.keys(cfg);\n void (async () => {\n for (const path of paths) {\n if (cancelled) break;\n if (prev && current[path] === prev[path]) continue;\n const binding = cfg[path];\n if (!binding) continue;\n const bindings = Array.isArray(binding) ? binding : [binding];\n await resolveAndExecuteBindings(\n bindings,\n fullCtx.value,\n getSnapshot,\n execute,\n () => cancelled\n );\n }\n })().catch(console.error);\n },\n { deep: true }\n );\n return () => {\n const ctx = fullCtx.value;\n const isVisible = props.element.visible === void 0 ? true : evaluateVisibility2(props.element.visible, ctx);\n if (!isVisible) return null;\n const rawProps = props.element.props;\n const elementBindings = resolveBindings(rawProps, ctx);\n const resolvedProps = resolveElementProps(rawProps, ctx);\n const resolvedElement = resolvedProps !== props.element.props ? { ...props.element, props: resolvedProps } : props.element;\n const Component = props.registry[resolvedElement.type] ?? props.fallback;\n if (!Component) {\n console.warn(\n `[json-render] No renderer for component type: ${resolvedElement.type}`\n );\n return null;\n }\n const childrenVNodes = resolvedElement.repeat ? h2(RepeatChildren, {\n element: resolvedElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n }) : resolvedElement.children?.map((childKey) => {\n const childElement = props.spec.elements[childKey];\n if (!childElement) {\n if (!props.loading) {\n console.warn(\n `[json-render] Missing element \"${childKey}\" referenced as child of \"${resolvedElement.type}\". This element will not render.`\n );\n }\n return null;\n }\n return h2(ElementRenderer, {\n key: childKey,\n element: childElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n });\n }).filter((n) => n !== null) ?? void 0;\n return h2(\n ElementErrorBoundary,\n { elementType: resolvedElement.type },\n {\n default: () => h2(\n Component,\n {\n element: resolvedElement,\n emit: emitEvent,\n on: onEvent,\n bindings: elementBindings,\n loading: props.loading\n },\n { default: () => childrenVNodes }\n )\n }\n );\n };\n }\n});\nvar RepeatChildren = defineComponent6({\n name: \"JsonRenderRepeatChildren\",\n props: {\n element: {\n type: Object,\n required: true\n },\n spec: {\n type: Object,\n required: true\n },\n registry: {\n type: Object,\n required: true\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(props) {\n const { state } = useStateStore();\n return () => {\n const repeat = props.element.repeat;\n if (!repeat?.statePath) return null;\n const statePath = repeat.statePath;\n const raw = getByPath3(state.value, statePath);\n const items = Array.isArray(raw) ? raw : [];\n return items.map((itemValue, index) => {\n const key = repeat.key && typeof itemValue === \"object\" && itemValue !== null ? String(\n itemValue[repeat.key] ?? index\n ) : String(index);\n return h2(\n RepeatScopeProvider,\n { key, item: itemValue, index, basePath: `${statePath}/${index}` },\n {\n default: () => props.element.children?.map((childKey) => {\n const childElement = props.spec.elements[childKey];\n if (!childElement) {\n if (!props.loading) {\n console.warn(\n `[json-render] Missing element \"${childKey}\" referenced as child of \"${props.element.type}\" (repeat). This element will not render.`\n );\n }\n return null;\n }\n return h2(ElementRenderer, {\n key: childKey,\n element: childElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n });\n }).filter((n) => n !== null) ?? null\n }\n );\n });\n };\n }\n});\nvar Renderer = defineComponent6({\n name: \"JsonRenderer\",\n props: {\n spec: {\n type: Object,\n default: null\n },\n registry: {\n type: Object,\n required: true\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(props) {\n return () => {\n if (!props.spec?.root) return null;\n const rootElement = props.spec.elements[props.spec.root];\n if (!rootElement) return null;\n return h2(ElementRenderer, {\n element: rootElement,\n spec: props.spec,\n registry: props.registry,\n loading: props.loading,\n fallback: props.fallback\n });\n };\n }\n});\nvar ConfirmationDialogManager = defineComponent6({\n name: \"ConfirmationDialogManager\",\n setup() {\n const { pendingConfirmation, confirm, cancel } = useActions();\n return () => {\n if (!pendingConfirmation?.action.confirm) return null;\n return h2(ConfirmDialog, {\n confirm: pendingConfirmation.action.confirm,\n onConfirm: confirm,\n onCancel: cancel\n });\n };\n }\n});\nvar JSONUIProvider = defineComponent6({\n name: \"JSONUIProvider\",\n props: {\n registry: {\n type: Object,\n required: true\n },\n store: {\n type: Object,\n default: void 0\n },\n initialState: {\n type: Object,\n default: void 0\n },\n handlers: {\n type: Object,\n default: void 0\n },\n navigate: {\n type: Function,\n default: void 0\n },\n validationFunctions: {\n type: Object,\n default: void 0\n },\n functions: {\n type: Object,\n default: void 0\n },\n onStateChange: {\n type: Function,\n default: void 0\n }\n },\n setup(props, { slots }) {\n return () => h2(\n StateProvider,\n {\n store: props.store,\n initialState: props.initialState,\n onStateChange: props.onStateChange\n },\n {\n default: () => h2(VisibilityProvider, null, {\n default: () => h2(\n ValidationProvider,\n { customFunctions: props.validationFunctions },\n {\n default: () => h2(\n ActionProvider,\n { handlers: props.handlers, navigate: props.navigate },\n {\n default: () => h2(\n FunctionsProvider,\n { functions: props.functions },\n {\n default: () => [\n slots.default?.(),\n h2(ConfirmationDialogManager)\n ]\n }\n )\n }\n )\n }\n )\n })\n }\n );\n }\n});\nfunction defineRegistry(_catalog, options) {\n const registry = {};\n if (options.components) {\n for (const [name, componentFn] of Object.entries(options.components)) {\n registry[name] = defineComponent6({\n name: `JsonRenderRegistry_${name}`,\n props: {\n element: {\n type: Object,\n required: true\n },\n emit: {\n type: Function,\n required: true\n },\n on: {\n type: Function,\n required: true\n },\n bindings: {\n type: Object,\n default: void 0\n },\n loading: {\n type: Boolean,\n default: void 0\n }\n },\n setup(registryProps, { slots }) {\n return () => componentFn({\n props: registryProps.element.props,\n children: slots.default?.(),\n emit: registryProps.emit,\n on: registryProps.on,\n bindings: registryProps.bindings,\n loading: registryProps.loading\n });\n }\n });\n }\n }\n const actionMap = options.actions ? Object.entries(options.actions) : [];\n const handlers = (getSetState, getState) => {\n const result = {};\n for (const [name, actionFn] of actionMap) {\n result[name] = async (params) => {\n const setState = getSetState();\n const state = getState();\n if (setState) {\n await actionFn(params, setState, state);\n }\n };\n }\n return result;\n };\n const executeAction2 = async (actionName, params, setState, state = {}) => {\n const entry = actionMap.find(([name]) => name === actionName);\n if (entry) {\n await entry[1](params, setState, state);\n } else {\n console.warn(`Unknown action: ${actionName}`);\n }\n };\n return { registry, handlers, executeAction: executeAction2 };\n}\nfunction createRenderer(catalog, components) {\n const registry = components;\n return defineComponent6({\n name: \"CatalogRenderer\",\n props: {\n spec: {\n type: Object,\n default: null\n },\n store: {\n type: Object,\n default: void 0\n },\n state: {\n type: Object,\n default: void 0\n },\n onAction: {\n type: Function,\n default: void 0\n },\n onStateChange: {\n type: Function,\n default: void 0\n },\n functions: {\n type: Object,\n default: void 0\n },\n loading: {\n type: Boolean,\n default: void 0\n },\n fallback: {\n type: Object,\n default: void 0\n }\n },\n setup(rendererProps) {\n return () => {\n const actionHandlers = rendererProps.onAction ? new Proxy(\n {},\n {\n get: (_target, prop) => {\n return (params) => rendererProps.onAction(prop, params);\n },\n has: () => true\n }\n ) : void 0;\n return h2(\n StateProvider,\n {\n store: rendererProps.store,\n initialState: rendererProps.state,\n onStateChange: rendererProps.onStateChange\n },\n {\n default: () => h2(VisibilityProvider, null, {\n default: () => h2(ValidationProvider, null, {\n default: () => h2(\n ActionProvider,\n { handlers: actionHandlers },\n {\n default: () => h2(\n FunctionsProvider,\n { functions: rendererProps.functions },\n {\n default: () => [\n h2(Renderer, {\n spec: rendererProps.spec,\n registry,\n loading: rendererProps.loading,\n fallback: rendererProps.fallback\n }),\n h2(ConfirmationDialogManager)\n ]\n }\n )\n }\n )\n })\n })\n }\n );\n };\n }\n });\n}\nexport {\n ActionProvider,\n ConfirmDialog,\n JSONUIProvider,\n Renderer,\n RepeatScopeProvider,\n StateProvider,\n ValidationProvider,\n VisibilityProvider,\n buildSpecFromParts,\n createRenderer,\n createStateStore2 as createStateStore,\n defineRegistry,\n flatToTree,\n getTextFromParts,\n schema,\n useAction,\n useActions,\n useBoundProp,\n useChatUI,\n useFieldValidation,\n useIsVisible,\n useJsonRenderMessage,\n useOptionalValidation,\n useRepeatScope,\n useStateBinding,\n useStateStore,\n useStateValue,\n useUIStream,\n useValidation,\n useVisibility\n};\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;AAoBA,IAAI,IAA4B,uBAAO,oBAAoB,EACvD,IAAgB,EAAgB;CAClC,MAAM;CACN,OAAO;EACL,OAAO;GACL,MAAM;GACN,SAAS,KAAK;GACf;EACD,cAAc;GACZ,MAAM;GACN,SAAS,KAAK;GACf;EACD,eAAe;GACb,MAAM;GACN,SAAS,KAAK;GACf;EACF;CACD,MAAM,GAAO,EAAE,YAAS;EACtB,IAAM,IAAe,CAAC,CAAC,EAAM,OACvB,IAAiB,IAA4D,OAA7C,EAAiB,EAAM,gBAAgB,EAAE,CAAC,EAC1E,IAAQ,EAAM,SAAS,GACvB,IAAQ,EAAW,EAAM,aAAa,CAAC;AAK7C,MADA,EAHoB,EAAM,gBAAgB;AACxC,KAAM,QAAQ,EAAM,aAAa;IACjC,CACsB,EACpB,CAAC,GAAc;GACjB,IAAI,IAAW,EAAM,gBAAgB,OAAO,KAAK,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QAAQ,EAAQ,QAAQ,GAAG,EAAE;AAsBxE,QAAO;EAAE;EAAU,WArBD,GAAa,MAAa;GAC1C,IAAM,IAAS,EAAE;AACjB,QAAK,IAAM,CAAC,GAAM,MAAa,EAC7B,GAAO,KAAQ,OAAO,MAAW;IAC/B,IAAM,IAAW,GAAa,EACxB,IAAQ,GAAU;AACxB,IAAI,KACF,MAAM,EAAS,GAAQ,GAAU,EAAM;;AAI7C,UAAO;;EAUoB,eARN,OAAO,GAAY,GAAQ,GAAU,IAAQ,EAAE,KAAK;GACzE,IAAM,IAAQ,EAAU,MAAM,CAAC,OAAU,MAAS,EAAW;AAC7D,GAAI,IACF,MAAM,EAAM,GAAG,GAAQ,GAAU,EAAM,GAEvC,QAAQ,KAAK,mBAAmB,IAAa;;EAGW"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,28 +3,30 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { DefineRegistryResult } from "@json-render/vue";
|
|
7
7
|
import type { StateStore } from "@json-render/core";
|
|
8
8
|
import type { AbstractActor, Viewable } from "@xmachines/play-actor";
|
|
9
|
-
import type { AnyActorLogic
|
|
9
|
+
import type { AnyActorLogic } from "xstate";
|
|
10
10
|
/**
|
|
11
11
|
* Props for PlayRenderer component
|
|
12
12
|
*
|
|
13
13
|
* @typeParam TLogic - The XState actor logic type. Defaults to `AnyActorLogic` for
|
|
14
|
-
* non-generic usage.
|
|
15
|
-
* are constrained to the event type strings that the machine actually accepts.
|
|
14
|
+
* non-generic usage.
|
|
16
15
|
*
|
|
17
16
|
* @property actor - Actor instance with currentView signal (requires Viewable capability)
|
|
18
|
-
* @property
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* event type string is a compile error when TLogic is specified.
|
|
17
|
+
* @property registryResult - Full result from defineRegistry() in @json-render/vue.
|
|
18
|
+
* Contains both the component registry and the action handlers factory. Action handlers
|
|
19
|
+
* are real async functions dispatching to the actor (not string-mapped event types).
|
|
22
20
|
*/
|
|
23
21
|
export interface PlayRendererProps<TLogic extends AnyActorLogic = AnyActorLogic> {
|
|
24
22
|
/** Actor instance with currentView signal (requires Viewable capability) */
|
|
25
23
|
actor: AbstractActor<TLogic> & Viewable;
|
|
26
|
-
/**
|
|
27
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Full result from defineRegistry() — contains component registry and action handlers.
|
|
26
|
+
* Action handlers are async functions that dispatch to the actor (not string-mapped
|
|
27
|
+
* event type stubs). Replaces the old `registry` + `actions` prop pair.
|
|
28
|
+
*/
|
|
29
|
+
registryResult: DefineRegistryResult;
|
|
28
30
|
/**
|
|
29
31
|
* Optional external StateStore (e.g. from `xstateStoreStateStore` in @json-render/xstate).
|
|
30
32
|
* When provided, PlayRenderer operates in controlled mode — spec.state is ignored and
|
|
@@ -33,13 +35,5 @@ export interface PlayRendererProps<TLogic extends AnyActorLogic = AnyActorLogic>
|
|
|
33
35
|
* seeded from spec.state.
|
|
34
36
|
*/
|
|
35
37
|
store?: StateStore;
|
|
36
|
-
/**
|
|
37
|
-
* Optional map of json-render action names to XState event type strings.
|
|
38
|
-
* Values are constrained to valid event types for TLogic — wrong event type strings
|
|
39
|
-
* are caught at compile time when TLogic is specified.
|
|
40
|
-
*/
|
|
41
|
-
actions?: {
|
|
42
|
-
[actionName: string]: EventFromLogic<TLogic>["type"];
|
|
43
|
-
};
|
|
44
38
|
}
|
|
45
39
|
//# 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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa;IAC9E,4EAA4E;IAC5E,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;IAExC;;;;OAIG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-vue",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.31",
|
|
4
4
|
"description": "Vue renderer for XMachines Play architecture",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"reactive",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"prepublishOnly": "npm run build"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@xmachines/play": "1.0.0-beta.
|
|
46
|
-
"@xmachines/play-actor": "1.0.0-beta.
|
|
47
|
-
"@xmachines/play-signals": "1.0.0-beta.
|
|
45
|
+
"@xmachines/play": "1.0.0-beta.31",
|
|
46
|
+
"@xmachines/play-actor": "1.0.0-beta.31",
|
|
47
|
+
"@xmachines/play-signals": "1.0.0-beta.31"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@json-render/core": "^0.16.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/node": "^25.5.0",
|
|
54
54
|
"@vitejs/plugin-vue": "^6.0.5",
|
|
55
55
|
"@vue/test-utils": "^2.4.6",
|
|
56
|
-
"@xmachines/shared": "1.0.0-beta.
|
|
56
|
+
"@xmachines/shared": "1.0.0-beta.31",
|
|
57
57
|
"@xstate/store": ">=3.17.0",
|
|
58
58
|
"oxfmt": "^0.43.0",
|
|
59
59
|
"oxlint": "^1.57.0",
|