ngx-json-render 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-json-render.mjs","sources":["../../../projects/ngx-json-render/src/lib/root-context.ts","../../../projects/ngx-json-render/src/lib/pointer.ts","../../../projects/ngx-json-render/src/lib/same-json.ts","../../../projects/ngx-json-render/src/lib/state.service.ts","../../../projects/ngx-json-render/src/lib/validation.service.ts","../../../projects/ngx-json-render/src/lib/actions.service.ts","../../../projects/ngx-json-render/src/lib/confirm-tokens.ts","../../../projects/ngx-json-render/src/lib/confirm-dialog.component.ts","../../../projects/ngx-json-render/src/lib/devtools.ts","../../../projects/ngx-json-render/src/lib/render-limits.ts","../../../projects/ngx-json-render/src/lib/state-reads.ts","../../../projects/ngx-json-render/src/lib/tokens.ts","../../../projects/ngx-json-render/src/lib/element.component.ts","../../../projects/ngx-json-render/src/lib/spec-validation.ts","../../../projects/ngx-json-render/src/lib/renderer.component.ts","../../../projects/ngx-json-render/src/lib/repeat-scope.component.ts","../../../projects/ngx-json-render/src/lib/children.component.ts","../../../projects/ngx-json-render/src/lib/registry.ts","../../../projects/ngx-json-render/src/lib/streaming/patch.ts","../../../projects/ngx-json-render/src/lib/streaming/observer.ts","../../../projects/ngx-json-render/src/lib/streaming/parts.ts","../../../projects/ngx-json-render/src/lib/streaming/transport.ts","../../../projects/ngx-json-render/src/lib/streaming/ui-stream.ts","../../../projects/ngx-json-render/src/lib/streaming/chat-ui.ts","../../../projects/ngx-json-render/src/lib/streaming/index.ts","../../../projects/ngx-json-render/src/public-api.ts","../../../projects/ngx-json-render/src/ngx-json-render.ts"],"sourcesContent":["import { Injectable, type Signal, type Type, signal } from '@angular/core';\nimport type {\n ActionHandler,\n ComputedFunction,\n DirectiveRegistry,\n Spec,\n StateModel,\n StateStore,\n ValidationFunction,\n} from '@json-render/core';\nimport type { RenderLimits, SpecCatalog } from './render-limits';\nimport type { ComponentRegistry, RegistryEntry, StateChange } from './types';\n\nconst EMPTY = signal(undefined);\n\n/**\n * Internal bridge between the `<json-render>` component's inputs and the\n * renderer services / element tree. The renderer component replaces these\n * signal references with its own input signals at construction time.\n *\n * @internal\n */\n@Injectable()\nexport class JsonRenderRootContext {\n spec: Signal<Spec | null | undefined> = EMPTY;\n registry: Signal<ComponentRegistry | undefined> = EMPTY;\n loading: Signal<boolean> = signal(false);\n fallback: Signal<Type<unknown> | RegistryEntry | null | undefined> = EMPTY;\n /**\n * Caps on what the spec may cost the browser. Read as the tree renders, so\n * they apply whatever `validate` is set to.\n */\n limits: Signal<RenderLimits | null | undefined> = EMPTY;\n /**\n * The catalog the spec was generated for. While loading, an element whose\n * props do not pass its component's schema waits for them.\n */\n catalog: Signal<SpecCatalog | null | undefined> = EMPTY;\n\n /** External store (controlled mode). */\n store: Signal<StateStore | null | undefined> = EMPTY;\n /** Initial state (uncontrolled mode); falls back to `spec.state`. */\n initialState: Signal<StateModel> = signal({});\n\n handlers: Signal<Record<string, ActionHandler> | undefined> = EMPTY;\n onAction: Signal<\n | ((name: string, params?: Record<string, unknown>) => unknown)\n | null\n | undefined\n > = EMPTY;\n navigate: Signal<((path: string) => void) | null | undefined> = EMPTY;\n\n validationFunctions: Signal<Record<string, ValidationFunction> | undefined> =\n EMPTY;\n functions: Signal<Record<string, ComputedFunction> | undefined> = EMPTY;\n directiveRegistry: Signal<DirectiveRegistry | undefined> = EMPTY;\n\n /** Emits uncontrolled-mode state changes to the renderer output. */\n emitStateChange: (changes: StateChange[]) => void = () => {};\n\n /** Resolve a registry entry (component + slot metadata) for a type. */\n resolveEntry(type: string): RegistryEntry | undefined {\n const raw = this.registry()?.[type] ?? this.fallback() ?? undefined;\n if (!raw) return undefined;\n return typeof raw === 'function' ? { component: raw } : raw;\n }\n}\n","import { isDevMode } from '@angular/core';\n\n/** Nesting below this is kept as one leaf, the same cut-off core uses. */\nconst MAX_FLATTEN_DEPTH = 20;\n\n/** Escape one key for a JSON Pointer: `~` → `~0`, `/` → `~1`. */\nexport function escapePointerSegment(key: string): string {\n return key.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n\n/**\n * Flatten plain objects into a `{ pointer: leaf }` map; arrays and anything\n * that is not a plain object are leaves.\n *\n * Core's `flattenToPointers` does the same but joins keys unescaped, so a key\n * such as `a/b` comes back as `/a/b` and a store write puts it at `a` → `b`.\n * Every path built here is escaped, so it reads back the key it came from.\n */\nexport function flattenToPointers(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const seen = new Set<object>();\n let warned = false;\n\n const walk = (\n value: Record<string, unknown>,\n prefix: string,\n depth: number,\n ) => {\n for (const [key, child] of Object.entries(value)) {\n const pointer = `${prefix}/${escapePointerSegment(key)}`;\n if (isPlainObject(child) && !seen.has(child)) {\n if (depth < MAX_FLATTEN_DEPTH) {\n seen.add(child);\n walk(child, pointer, depth + 1);\n continue;\n }\n if (isDevMode() && !warned) {\n warned = true;\n console.warn(\n `[ngx-json-render] state nested deeper than ${MAX_FLATTEN_DEPTH} levels is treated as one value.`,\n );\n }\n }\n result[pointer] = child;\n }\n };\n\n walk(obj, '', 0);\n return result;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n","/**\n * Whether two values hold the same JSON content.\n *\n * For telling a value that arrived as a new object from one that changed — a\n * spec element, or a leaf of `spec.state`, when the host hands over a spec\n * built from fresh objects. Plain objects and arrays are compared by what\n * they hold; anything else only by identity, which data parsed from JSON\n * never needs. A container reached twice on the way down counts as\n * different: JSON cannot refer to itself, and treating such a value as\n * changed is what the renderer did before it compared anything.\n */\nexport function sameJson(\n a: unknown,\n b: unknown,\n seen = new Set<unknown>(),\n): boolean {\n if (Object.is(a, b)) return true;\n if (!isPlainContainer(a) || !isPlainContainer(b)) return false;\n if (Array.isArray(a) !== Array.isArray(b) || seen.has(a)) return false;\n seen.add(a);\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(\n (key) => Object.hasOwn(b, key) && sameJson(a[key], b[key], seen),\n );\n}\n\nfunction isPlainContainer(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false;\n const prototype = Object.getPrototypeOf(value);\n return (\n Array.isArray(value) || prototype === Object.prototype || prototype === null\n );\n}\n","import {\n Injectable,\n type Signal,\n computed,\n effect,\n inject,\n isDevMode,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n type StateModel,\n type StateStore,\n createStateStore,\n getByPath,\n} from '@json-render/core';\nimport { escapePointerSegment, flattenToPointers } from './pointer';\nimport { JsonRenderRootContext } from './root-context';\nimport { sameJson } from './same-json';\nimport type { StateChange } from './types';\n\n/**\n * The state store of a `<json-render>` subtree.\n *\n * Wraps a core {@link StateStore} (either the internal in-memory store in\n * uncontrolled mode, or an external store passed via the `store` input) and\n * exposes the current state model as a signal.\n *\n * Inject it from catalog components or action handlers via\n * {@link injectStateStore}.\n */\n@Injectable()\nexport class JsonRenderStateService {\n private readonly root = inject(JsonRenderRootContext);\n private readonly internalStore = createStateStore({});\n\n private readonly changeListeners = new Set<\n (changes: StateChange[]) => void\n >();\n\n /** The snapshot the change listeners last heard about. */\n private lastSnapshot: StateModel = {};\n /** True while this service writes, so the store's echo is not reported. */\n private writing = false;\n\n private readonly _state = signal<StateModel>(\n {},\n // External stores may mutate snapshots in place — always propagate.\n { equal: () => false },\n );\n\n /** The current state model as a signal. */\n readonly state: Signal<StateModel> = this._state.asReadonly();\n\n private readonly currentStore = computed<StateStore>(\n () => this.root.store() ?? this.internalStore,\n );\n\n constructor() {\n const initialMode =\n untracked(this.currentStore) === this.internalStore\n ? 'uncontrolled'\n : 'controlled';\n let modeWarned = false;\n\n // Keep the state signal in sync with whichever store is active.\n effect((onCleanup) => {\n const store = this.currentStore();\n\n if (isDevMode() && !modeWarned) {\n const mode =\n store === this.internalStore ? 'uncontrolled' : 'controlled';\n if (mode !== initialMode) {\n modeWarned = true;\n console.warn(\n `[ngx-json-render] switching from ${initialMode} to ${mode} mode is not supported.`,\n );\n }\n }\n\n const controlled = store !== this.internalStore;\n this.lastSnapshot = store.getSnapshot();\n untracked(() => this._state.set(this.lastSnapshot));\n const unsubscribe = store.subscribe(() => {\n const prev = this.lastSnapshot;\n const next = store.getSnapshot();\n // Recorded before the listeners run: a watch action may write again.\n this.lastSnapshot = next;\n this._state.set(next);\n // A write the host made on its own store reaches no `set`/`update`\n // here, so the diff is the only way `watch` hears about it. Our own\n // writes report themselves, with the paths they were given.\n if (controlled && !this.writing && this.changeListeners.size > 0) {\n const changes = diffState(prev, next);\n if (changes.length > 0) this.notifyChanges(changes);\n }\n });\n onCleanup(unsubscribe);\n });\n\n // Uncontrolled mode: when the (resolved) initial state changes — e.g.\n // `spec.state` grows while streaming — diff it against the previous\n // initial state and apply only the changed leaves to the store. Leaves\n // compare by content: arrays are leaves, and a spec handed over again as\n // new objects would otherwise write every array back, over whatever the\n // user has since changed inside it.\n let prevFlat: Record<string, unknown> = {};\n effect(() => {\n if (this.root.store()) return;\n const initialState = this.root.initialState() ?? {};\n const nextFlat =\n Object.keys(initialState).length > 0\n ? flattenToPointers(initialState)\n : {};\n const allKeys = new Set([\n ...Object.keys(prevFlat),\n ...Object.keys(nextFlat),\n ]);\n const updates: Record<string, unknown> = {};\n for (const key of allKeys) {\n if (!sameJson(prevFlat[key], nextFlat[key])) {\n updates[key] = key in nextFlat ? nextFlat[key] : undefined;\n }\n }\n prevFlat = nextFlat;\n if (Object.keys(updates).length > 0) {\n untracked(() => this.internalStore.update(updates));\n }\n });\n }\n\n /** Read a value by JSON Pointer path from the current state. */\n get(path: string): unknown {\n return untracked(this.currentStore).get(path);\n }\n\n /** Write a value by JSON Pointer path and notify subscribers. */\n set(path: string, value: unknown): void {\n const store = untracked(this.currentStore);\n const prev = store.getSnapshot();\n const prevValue = getByPath(prev, path);\n this.write(store, () => store.set(path, value));\n if (prevValue !== value) {\n const changes: StateChange[] = [{ path, value }];\n this.notifyChanges(changes);\n if (!untracked(this.root.store) && store.getSnapshot() !== prev) {\n this.root.emitStateChange(changes);\n }\n }\n }\n\n /** Write multiple values at once (single notification). */\n update(updates: Record<string, unknown>): void {\n const store = untracked(this.currentStore);\n const prev = store.getSnapshot();\n this.write(store, () => store.update(updates));\n const changes: StateChange[] = [];\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 this.notifyChanges(changes);\n if (!untracked(this.root.store) && store.getSnapshot() !== prev) {\n this.root.emitStateChange(changes);\n }\n }\n }\n\n /** Return the full state object (non-reactive read). */\n getSnapshot(): StateModel {\n return untracked(this.currentStore).getSnapshot();\n }\n\n /**\n * Register a listener called with the list of changed paths whenever state\n * is written through this service, or, in controlled mode, whenever the\n * external store changes (element `watch` fields rely on this). Returns an\n * unsubscribe function.\n */\n subscribeChanges(listener: (changes: StateChange[]) => void): () => void {\n this.changeListeners.add(listener);\n return () => {\n this.changeListeners.delete(listener);\n };\n }\n\n private write(store: StateStore, apply: () => void): void {\n const wasWriting = this.writing;\n this.writing = true;\n try {\n apply();\n } finally {\n this.writing = wasWriting;\n }\n this.lastSnapshot = store.getSnapshot();\n }\n\n private notifyChanges(changes: StateChange[]): void {\n for (const listener of this.changeListeners) {\n listener(changes);\n }\n }\n}\n\n/**\n * Every path whose value differs between two state snapshots, each container\n * before what it holds, values taken from `next`. Subtrees are compared by\n * reference, so an unchanged branch costs nothing, and a store that mutates a\n * snapshot in place reports no change: the same rule as a signal's `set`.\n */\nfunction diffState(prev: StateModel, next: StateModel): StateChange[] {\n const changes: StateChange[] = [];\n const walk = (a: unknown, b: unknown, path: string): void => {\n if (a === b) return;\n if (path) changes.push({ path, value: b });\n const keys = new Set([...childKeys(a), ...childKeys(b)]);\n for (const key of keys) {\n walk(\n child(a, key),\n child(b, key),\n `${path}/${escapePointerSegment(key)}`,\n );\n }\n };\n walk(prev, next, '');\n return changes;\n}\n\nfunction childKeys(value: unknown): string[] {\n return value !== null && typeof value === 'object' ? Object.keys(value) : [];\n}\n\nfunction child(value: unknown, key: string): unknown {\n return value !== null && typeof value === 'object'\n ? (value as Record<string, unknown>)[key]\n : undefined;\n}\n\n/**\n * Inject the state store of the nearest `<json-render>` renderer.\n * Must be called from within the renderer's subtree (e.g. a catalog\n * component) or a component that provides {@link JsonRenderStateService}.\n */\nexport function injectStateStore(): JsonRenderStateService {\n return inject(JsonRenderStateService);\n}\n\n/** Reactive read of a state value by JSON Pointer path. */\nexport function injectStateValue<T>(\n path: string | (() => string),\n): Signal<T | undefined> {\n const store = injectStateStore();\n const getPath = typeof path === 'function' ? path : () => path;\n return computed(() => getByPath(store.state(), getPath()) as T | undefined);\n}\n\n/**\n * Reactive two-way binding to a state path: a value signal plus a setter\n * that writes back to the same path.\n */\nexport function injectStateBinding<T>(path: string | (() => string)): {\n value: Signal<T | undefined>;\n set: (value: T) => void;\n} {\n const store = injectStateStore();\n const getPath = typeof path === 'function' ? path : () => path;\n return {\n value: computed(() => getByPath(store.state(), getPath()) as T | undefined),\n set: (value: T) => store.set(getPath(), value),\n };\n}\n\n/**\n * Two-way bound prop helper for catalog components, mirroring `useBoundProp`\n * from the other renderers: the value comes from the already-resolved prop,\n * and the setter writes back to the bound state path (no-op if not bound).\n *\n * @example\n * ```ts\n * const ctx = injectRenderContext<{ value?: string }>();\n * const bound = injectBoundProp<string>(\n * () => ctx.props().value,\n * () => ctx.bindings()?.['value'],\n * );\n * // template: <input [value]=\"bound.value() ?? ''\" (input)=\"bound.set($any($event.target).value)\" />\n * ```\n */\nexport function injectBoundProp<T>(\n propValue: () => T | undefined,\n bindingPath: () => string | undefined,\n): { value: Signal<T | undefined>; set: (value: T) => void } {\n const store = injectStateStore();\n return {\n value: computed(propValue),\n set: (value: T) => {\n const path = bindingPath();\n if (path) store.set(path, value);\n },\n };\n}\n","import {\n DestroyRef,\n Injectable,\n type Signal,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n type ValidationConfig,\n type ValidationFunction,\n type ValidationResult,\n getByPath,\n runValidation,\n} from '@json-render/core';\nimport { JsonRenderRootContext } from './root-context';\nimport { JsonRenderStateService } from './state.service';\n\nexport interface FieldValidationState {\n touched: boolean;\n validated: boolean;\n result: ValidationResult | null;\n}\n\nfunction dynamicArgsEqual(\n a: Record<string, unknown> | undefined,\n b: Record<string, unknown> | undefined,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n const va = a[key];\n const vb = b[key];\n if (va === vb) continue;\n if (\n typeof va === 'object' &&\n va !== null &&\n typeof vb === 'object' &&\n vb !== null\n ) {\n const sa = (va as Record<string, unknown>)['$state'];\n const sb = (vb as Record<string, unknown>)['$state'];\n if (typeof sa === 'string' && sa === sb) continue;\n }\n return false;\n }\n return true;\n}\n\nfunction validationConfigEqual(\n a: ValidationConfig,\n b: ValidationConfig,\n): boolean {\n if (a === b) return true;\n\n if (a.validateOn !== b.validateOn) return false;\n\n const ac = a.checks ?? [];\n const bc = b.checks ?? [];\n if (ac.length !== bc.length) return false;\n\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\n return true;\n}\n\n/**\n * Owner of a registration made through the service's own API rather than by\n * a field component. Manual registrations release together, which is the\n * behaviour a caller of `registerField(path, config)` would expect.\n */\nconst MANUAL_OWNER: object = { manual: true };\n\n/**\n * Form validation state of a `<json-render>` subtree. Fields register their\n * {@link ValidationConfig}; the built-in `validateForm` action validates all\n * registered fields and writes the result to state.\n *\n * Registrations are owner-scoped: a path stays registered while at least one\n * owner holds it, and its config and state are dropped when the last one\n * releases. A spec that swaps screens or hides fields therefore stops\n * validating what is no longer on screen.\n */\n@Injectable()\nexport class JsonRenderValidationService {\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n\n private readonly _fieldStates = signal<Record<string, FieldValidationState>>(\n {},\n );\n private readonly _fieldConfigs = signal<Record<string, ValidationConfig>>({});\n /** Live owners per path — the reference count behind a registration. */\n private readonly fieldOwners = new Map<string, Set<object>>();\n\n /** Validation state per registered field path. */\n readonly fieldStates: Signal<Record<string, FieldValidationState>> =\n this._fieldStates.asReadonly();\n\n get customFunctions(): Record<string, ValidationFunction> {\n return untracked(this.root.validationFunctions) ?? {};\n }\n\n /**\n * Register (or update) a field's validation config.\n *\n * @param owner Identity holding the registration — pass the same value to\n * {@link unregisterField} to release it. Field components pass themselves,\n * so two components bound to one path each hold their own claim.\n */\n registerField(\n path: string,\n config: ValidationConfig,\n owner: object = MANUAL_OWNER,\n ): void {\n const owners = this.fieldOwners.get(path);\n if (owners) owners.add(owner);\n else this.fieldOwners.set(path, new Set([owner]));\n\n const prev = untracked(this._fieldConfigs);\n const existing = prev[path];\n if (existing && validationConfigEqual(existing, config)) return;\n this._fieldConfigs.set({ ...prev, [path]: config });\n }\n\n /**\n * Release one owner's registration of a field. The config and validation\n * state survive while another owner still holds the path; once the last\n * one lets go, `validateAll` stops seeing the field.\n */\n unregisterField(path: string, owner: object = MANUAL_OWNER): void {\n const owners = this.fieldOwners.get(path);\n if (!owners) return;\n owners.delete(owner);\n if (owners.size > 0) return;\n\n this.fieldOwners.delete(path);\n const prev = untracked(this._fieldConfigs);\n if (path in prev) {\n const { [path]: _removed, ...rest } = prev;\n this._fieldConfigs.set(rest);\n }\n this.clear(path);\n }\n\n /** Validate a single field and record the result. */\n validate(path: string, config: ValidationConfig): ValidationResult {\n const currentState = this.state.getSnapshot();\n // The store's own pointer walk, so `~1` and `~0` mean what they mean\n // everywhere else a path is read.\n const value = getByPath(currentState, path);\n const result = runValidation(config, {\n value,\n stateModel: currentState,\n customFunctions: this.customFunctions,\n });\n\n const prev = untracked(this._fieldStates);\n this._fieldStates.set({\n ...prev,\n [path]: {\n touched: prev[path]?.touched ?? true,\n validated: true,\n result,\n },\n });\n\n return result;\n }\n\n /** Mark a field as touched. */\n touch(path: string): void {\n const prev = untracked(this._fieldStates);\n this._fieldStates.set({\n ...prev,\n [path]: {\n ...prev[path],\n touched: true,\n validated: prev[path]?.validated ?? false,\n result: prev[path]?.result ?? null,\n },\n });\n }\n\n /** Clear a field's validation state. */\n clear(path: string): void {\n const { [path]: _, ...rest } = untracked(this._fieldStates);\n this._fieldStates.set(rest);\n }\n\n /** Validate all registered fields. Returns whether all are valid. */\n validateAll(): boolean {\n let allValid = true;\n for (const [path, config] of Object.entries(\n untracked(this._fieldConfigs),\n )) {\n const result = this.validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n return allValid;\n }\n}\n\n/** Inject the validation service of the nearest `<json-render>` renderer. */\nexport function injectValidation(): JsonRenderValidationService {\n return inject(JsonRenderValidationService);\n}\n\n/**\n * Field-level validation helper for catalog input components: registers the\n * config and exposes the field's validation state as signals.\n *\n * The registration follows the component: it moves when the bound path\n * changes and is released when the component is destroyed, so a field that\n * has left the screen no longer takes part in `validateForm`.\n */\nexport function injectFieldValidation(\n path: string | (() => string),\n config?: ValidationConfig | (() => ValidationConfig | undefined),\n): {\n state: Signal<FieldValidationState>;\n validate: () => ValidationResult;\n touch: () => void;\n clear: () => void;\n errors: Signal<string[]>;\n isValid: Signal<boolean>;\n} {\n const validation = injectValidation();\n const getPath = typeof path === 'function' ? path : () => path;\n const getConfig = typeof config === 'function' ? config : () => config;\n\n // Identity of this field's claim on a path. Two components bound to the\n // same path hold separate claims, so one being destroyed does not\n // deregister the other.\n const owner: object = {};\n let registeredPath: string | null = null;\n\n effect(() => {\n const p = getPath();\n const c = getConfig();\n const next = p && c ? p : null;\n if (registeredPath !== null && registeredPath !== next) {\n validation.unregisterField(registeredPath, owner);\n registeredPath = null;\n }\n if (next && c) {\n validation.registerField(next, c, owner);\n registeredPath = next;\n }\n });\n\n inject(DestroyRef).onDestroy(() => {\n if (registeredPath === null) return;\n validation.unregisterField(registeredPath, owner);\n registeredPath = null;\n });\n\n const state = computed<FieldValidationState>(() => {\n const current = validation.fieldStates()[getPath()];\n return current ?? { touched: false, validated: false, result: null };\n });\n\n return {\n state,\n validate: () =>\n validation.validate(getPath(), getConfig() ?? { checks: [] }),\n touch: () => validation.touch(getPath()),\n clear: () => validation.clear(getPath()),\n errors: computed(() => state().result?.errors ?? []),\n isValid: computed(() => state().result?.valid ?? true),\n };\n}\n","import {\n Injectable,\n type Signal,\n computed,\n inject,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n type ActionBinding,\n type ActionHandler,\n type ResolvedAction,\n executeAction,\n nextActionDispatchId,\n notifyActionDispatch,\n notifyActionSettle,\n resolveAction,\n} from '@json-render/core';\nimport { JsonRenderRootContext } from './root-context';\nimport { JsonRenderStateService } from './state.service';\nimport { JsonRenderValidationService } from './validation.service';\n\nlet idCounter = 0;\nfunction generateUniqueId(): string {\n idCounter += 1;\n return `${Date.now()}-${idCounter}`;\n}\n\nfunction deepResolveValue(\n value: unknown,\n get: (path: string) => unknown,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (value === '$id') {\n return generateUniqueId();\n }\n\n if (typeof value === 'object' && !Array.isArray(value)) {\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj);\n\n if (keys.length === 1 && typeof obj['$state'] === 'string') {\n return get(obj['$state'] as string);\n }\n\n if (keys.length === 1 && '$id' in obj) {\n return generateUniqueId();\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => deepResolveValue(item, get));\n }\n\n if (typeof value === 'object') {\n const resolved: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n resolved[key] = deepResolveValue(val, get);\n }\n return resolved;\n }\n\n return value;\n}\n\nexport interface PendingConfirmation {\n action: ResolvedAction;\n handler: ActionHandler;\n resolve: () => void;\n reject: () => void;\n}\n\n/**\n * Rejection produced when the user dismisses an action's confirmation dialog.\n * Carries a stable `name` so callers can tell a cancellation apart from a\n * handler failure without matching on the message.\n *\n * @internal Not part of the public API; use {@link isActionCancelled}.\n */\nexport class ActionCancelledError extends Error {\n constructor() {\n super('Action cancelled');\n this.name = 'ActionCancelledError';\n }\n}\n\n/** True for the rejection produced by cancelling a confirmation dialog. */\nexport function isActionCancelled(error: unknown): boolean {\n return error instanceof Error && error.name === 'ActionCancelledError';\n}\n\n/**\n * Action dispatcher of a `<json-render>` subtree.\n *\n * Executes {@link ActionBinding}s: built-in actions (`setState`, `pushState`,\n * `removeState`, `push`, `pop`, `validateForm`, `submitForm`) are handled\n * internally; everything else is routed to the host-provided `handlers` (or\n * the `onAction` catch-all), honoring `confirm`, `onSuccess`, and `onError`.\n */\n@Injectable()\nexport class JsonRenderActionsService {\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n private readonly validation = inject(JsonRenderValidationService, {\n optional: true,\n });\n\n private readonly extraHandlers = signal<Record<string, ActionHandler>>({});\n private readonly _loadingActions = signal<ReadonlySet<string>>(new Set());\n private readonly _pendingConfirmation = signal<PendingConfirmation | null>(\n null,\n );\n\n /** Names of actions currently executing. */\n readonly loadingActions: Signal<ReadonlySet<string>> =\n this._loadingActions.asReadonly();\n\n /** The confirmation currently awaiting user input, if any. */\n readonly pendingConfirmation: Signal<PendingConfirmation | null> =\n this._pendingConfirmation.asReadonly();\n\n /** All registered handlers (host handlers + runtime registrations). */\n get handlers(): Record<string, ActionHandler> {\n return {\n ...(untracked(this.root.handlers) ?? {}),\n ...untracked(this.extraHandlers),\n };\n }\n\n /** Register an additional action handler at runtime. */\n registerHandler(name: string, handler: ActionHandler): void {\n this.extraHandlers.set({\n ...untracked(this.extraHandlers),\n [name]: handler,\n });\n }\n\n /** Execute an action binding. */\n async execute(binding: ActionBinding): Promise<void> {\n const resolved = resolveAction(binding, this.state.getSnapshot());\n const get = (path: string) => this.state.get(path);\n const set = (path: string, value: unknown) => this.state.set(path, value);\n\n // --- devtools / observer hooks ---\n const dispatchId = nextActionDispatchId();\n const dispatchedAt = Date.now();\n notifyActionDispatch({\n id: dispatchId,\n name: resolved.action,\n params: resolved.params,\n at: dispatchedAt,\n });\n let ok = true;\n let error: unknown = undefined;\n\n try {\n if (resolved.action === 'setState' && resolved.params) {\n const statePath = resolved.params['statePath'] as string;\n const value = resolved.params['value'];\n if (statePath) {\n set(statePath, value);\n }\n return;\n }\n\n if (resolved.action === 'pushState' && resolved.params) {\n const statePath = resolved.params['statePath'] as string;\n const rawValue = resolved.params['value'];\n if (statePath) {\n const resolvedValue = deepResolveValue(rawValue, get);\n const arr = (get(statePath) as unknown[] | undefined) ?? [];\n set(statePath, [...arr, resolvedValue]);\n const clearStatePath = resolved.params['clearStatePath'] as\n string | undefined;\n if (clearStatePath) {\n set(clearStatePath, '');\n }\n }\n return;\n }\n\n if (resolved.action === 'removeState' && resolved.params) {\n const statePath = resolved.params['statePath'] as string;\n const index = resolved.params['index'] as number;\n if (statePath !== undefined && index !== undefined) {\n const arr = (get(statePath) as unknown[] | undefined) ?? [];\n set(\n statePath,\n arr.filter((_, i) => i !== index),\n );\n }\n return;\n }\n\n if (resolved.action === 'push' && resolved.params) {\n const screen = resolved.params['screen'] as string;\n if (screen) {\n const currentScreen = get('/currentScreen') as string | undefined;\n const navStack = (get('/navStack') as string[] | undefined) ?? [];\n if (currentScreen) {\n set('/navStack', [...navStack, currentScreen]);\n } else {\n set('/navStack', [...navStack, '']);\n }\n set('/currentScreen', screen);\n }\n return;\n }\n\n if (resolved.action === 'pop') {\n const navStack = (get('/navStack') as string[] | undefined) ?? [];\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', undefined);\n }\n }\n return;\n }\n\n if (resolved.action === 'validateForm') {\n if (this.checkForm(resolved) === null) {\n console.warn(\n 'validateForm action was dispatched but no JsonRenderValidationService is available.',\n );\n }\n return;\n }\n\n if (resolved.action === 'submitForm') {\n const valid = this.checkForm(resolved);\n if (valid === null) {\n console.warn(\n 'submitForm action was dispatched but no JsonRenderValidationService is available; nothing was submitted.',\n );\n return;\n }\n // An invalid form stops here, with the errors already written to\n // state and every field marked validated, so they are on screen.\n if (!valid) return;\n\n const target = resolved.params?.['action'];\n if (typeof target !== 'string' || !target) {\n console.warn(\n 'submitForm needs the action to submit to: { \"action\": \"submitForm\", \"params\": { \"action\": \"saveUser\" } }.',\n );\n return;\n }\n\n // Dispatched, not called directly, so the submitted action goes\n // through the same lookup, confirmation, loading state and observers\n // as any other — submitForm gates it, it does not replace it.\n await this.execute({\n action: target,\n params: deepResolveValue(resolved.params?.['params'], get) as\n Record<string, unknown> | undefined,\n confirm: resolved.confirm,\n onSuccess: resolved.onSuccess,\n onError: resolved.onError,\n });\n return;\n }\n\n const handler = this.lookupHandler(resolved.action);\n\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.action}`);\n return;\n }\n\n if (resolved.confirm) {\n // One question at a time: a confirm arriving while another is open\n // cancels that one, so its caller settles instead of waiting forever.\n untracked(this._pendingConfirmation)?.reject();\n // Awaited, not returned: a returned promise would let the `finally`\n // below settle the observers before the user has even answered.\n await new Promise<void>((resolve, reject) => {\n const pending: PendingConfirmation = {\n action: resolved,\n handler,\n resolve: () => this.answer(pending, resolve),\n reject: () =>\n this.answer(pending, () => reject(new ActionCancelledError())),\n };\n this._pendingConfirmation.set(pending);\n });\n }\n\n await this.runHandler(resolved, handler);\n } catch (err) {\n ok = false;\n error = err;\n throw err;\n } finally {\n const now = Date.now();\n notifyActionSettle({\n id: dispatchId,\n name: resolved.action,\n ok,\n at: now,\n durationMs: now - dispatchedAt,\n error,\n });\n }\n }\n\n /** Confirm the pending confirmation dialog. */\n confirm(): void {\n untracked(this._pendingConfirmation)?.resolve();\n }\n\n /** Cancel the pending confirmation dialog. */\n cancel(): void {\n untracked(this._pendingConfirmation)?.reject();\n }\n\n /**\n * Close `pending` and run `settle`, but only while it is still the open\n * question: a late answer to one that was replaced must not close its\n * successor.\n */\n private answer(pending: PendingConfirmation, settle: () => void): void {\n if (untracked(this._pendingConfirmation) !== pending) return;\n this._pendingConfirmation.set(null);\n settle();\n }\n\n /**\n * Validate every registered field and write `{ valid, errors }` to the\n * action's `statePath` (default `/formValidation`). Returns null when there\n * is no validation service to ask.\n *\n * Shared by `validateForm` and `submitForm`: the two must report the same\n * thing about the same form, and one implementation is how that stays true.\n */\n private checkForm(resolved: ResolvedAction): boolean | null {\n if (!this.validation) return null;\n\n const valid = this.validation.validateAll();\n const errors: Record<string, string[]> = {};\n for (const [path, fieldState] of Object.entries(\n untracked(this.validation.fieldStates),\n )) {\n if (fieldState.result && !fieldState.result.valid) {\n errors[path] = fieldState.result.errors;\n }\n }\n const statePath =\n (resolved.params?.['statePath'] as string) || '/formValidation';\n this.state.set(statePath, { valid, errors });\n return valid;\n }\n\n private lookupHandler(name: string): ActionHandler | undefined {\n const direct = this.handlers[name];\n if (direct) return direct;\n // Catch-all: route unknown actions to the `onAction` input when provided.\n const onAction = untracked(this.root.onAction);\n if (onAction) {\n return (params) => onAction(name, params);\n }\n return undefined;\n }\n\n private async runHandler(\n resolved: ResolvedAction,\n handler: ActionHandler,\n ): Promise<void> {\n this._loadingActions.set(\n new Set(untracked(this._loadingActions)).add(resolved.action),\n );\n try {\n await executeAction({\n action: resolved,\n handler,\n setState: (path, value) => this.state.set(path, value),\n navigate: untracked(this.root.navigate) ?? undefined,\n executeAction: async (binding) => {\n await this.execute(binding);\n },\n });\n } finally {\n const next = new Set(untracked(this._loadingActions));\n next.delete(resolved.action);\n this._loadingActions.set(next);\n }\n }\n}\n\n/** Inject the actions service of the nearest `<json-render>` renderer. */\nexport function injectActions(): JsonRenderActionsService {\n return inject(JsonRenderActionsService);\n}\n\n/**\n * Convenience helper for executing a fixed action binding, mirroring\n * `useAction` from the other renderers.\n */\nexport function injectAction(binding: ActionBinding): {\n execute: () => Promise<void>;\n isLoading: Signal<boolean>;\n} {\n const actions = injectActions();\n return {\n execute: () => actions.execute(binding),\n isLoading: computed(() => actions.loadingActions().has(binding.action)),\n };\n}\n","import { InjectionToken, type Type, inject } from '@angular/core';\nimport type { ActionConfirm } from '@json-render/core';\n\n/** The two words the confirmation dialog says on its own. */\nexport interface ConfirmLabels {\n confirm: string;\n cancel: string;\n}\n\n/**\n * Labels for the default confirmation dialog's buttons, when the spec does not\n * supply `confirmLabel` / `cancelLabel` of its own.\n *\n * They are the only strings this package puts on screen, and they were English\n * with no way to change them. Override once, in an app's providers:\n *\n * ```ts\n * { provide: JR_CONFIRM_LABELS, useValue: { confirm: 'Подтвердить', cancel: 'Отмена' } }\n * ```\n */\nexport const JR_CONFIRM_LABELS = new InjectionToken<ConfirmLabels>(\n 'ngx-json-render JR_CONFIRM_LABELS',\n {\n providedIn: 'root',\n factory: () => ({ confirm: 'Confirm', cancel: 'Cancel' }),\n },\n);\n\n/**\n * Everything a replacement confirmation dialog is given: the config the spec\n * asked for, and the two ways to answer it. Inject it with\n * {@link injectConfirmContext}.\n */\nexport interface ConfirmContext {\n /** Title, message, labels and variant, straight from the action binding. */\n readonly config: ActionConfirm;\n /** Let the action proceed. */\n readonly confirm: () => void;\n /** Dismiss it — a normal answer, not a failure. */\n readonly cancel: () => void;\n}\n\n/** The confirmation a replacement dialog component is rendered for. */\nexport const CONFIRM_CONTEXT = new InjectionToken<ConfirmContext>(\n 'ngx-json-render CONFIRM_CONTEXT',\n);\n\n/**\n * The component `<json-render>` should render for a `confirm` on an action.\n * Unset means the packaged {@link JrConfirmDialog}.\n *\n * The component is rendered with a {@link CONFIRM_CONTEXT} in its injector, so\n * it takes no inputs and emits no outputs:\n *\n * ```ts\n * @Component({ template: `<my-modal (ok)=\"ctx.confirm()\" (dismiss)=\"ctx.cancel()\">…` })\n * export class AppConfirm {\n * readonly ctx = injectConfirmContext();\n * }\n * // providers: [{ provide: JR_CONFIRM_DIALOG, useValue: AppConfirm }]\n * ```\n */\nexport const JR_CONFIRM_DIALOG = new InjectionToken<Type<unknown>>(\n 'ngx-json-render JR_CONFIRM_DIALOG',\n);\n\n/** Inject the confirmation a replacement dialog component is rendering for. */\nexport function injectConfirmContext(): ConfirmContext {\n const ctx = inject(CONFIRM_CONTEXT, { optional: true });\n if (!ctx) {\n throw new Error(\n 'injectConfirmContext() must be used inside a component provided through JR_CONFIRM_DIALOG',\n );\n }\n return ctx;\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n type ElementRef,\n afterNextRender,\n computed,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport type { ActionConfirm } from '@json-render/core';\nimport { JR_CONFIRM_LABELS } from './confirm-tokens';\n\nlet dialogIdCounter = 0;\n\n/**\n * Default confirmation dialog shown for action bindings with a `confirm`\n * field. Rendered automatically by `<json-render>`; can also be used\n * standalone with a custom action flow.\n *\n * It is a real dialog: `role=\"dialog\"` with `aria-modal`, labelled by its own\n * title and described by its message, focus moved in on open and returned to\n * wherever it came from on close, Tab kept inside it and Escape cancelling.\n * A generated UI can ask for confirmation of something destructive, so a\n * keyboard or screen-reader user has to be able to answer it.\n *\n * Colours come from CSS custom properties with light and dark defaults, so an\n * app can theme it — `--jr-confirm-surface`, `--jr-confirm-ink`,\n * `--jr-confirm-muted`, `--jr-confirm-border`, `--jr-confirm-scrim`,\n * `--jr-confirm-accent`, `--jr-confirm-danger`, `--jr-confirm-on-accent`,\n * `--jr-confirm-radius` — and replace it outright through\n * {@link JR_CONFIRM_DIALOG} when that is not enough.\n */\n@Component({\n selector: 'jr-confirm-dialog',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '(keydown.escape)': 'cancelled.emit()',\n },\n template: `\n <div class=\"jr-confirm-scrim\" (click)=\"cancelled.emit()\">\n <div\n class=\"jr-confirm-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-describedby]=\"messageId\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event)\"\n >\n <h3 class=\"jr-confirm-title\" [id]=\"titleId\">{{ config().title }}</h3>\n <p class=\"jr-confirm-message\" [id]=\"messageId\">{{ config().message }}</p>\n <div class=\"jr-confirm-actions\">\n <button #cancel type=\"button\" class=\"jr-confirm-cancel\" (click)=\"cancelled.emit()\">\n {{ config().cancelLabel ?? labels.cancel }}\n </button>\n <button\n #confirm\n type=\"button\"\n class=\"jr-confirm-confirm\"\n [class.jr-confirm-danger]=\"isDanger()\"\n (click)=\"confirmed.emit()\"\n >\n {{ config().confirmLabel ?? labels.confirm }}\n </button>\n </div>\n </div>\n </div>\n `,\n styles: `\n :host {\n --jr-confirm-scrim-default: rgba(0, 0, 0, 0.5);\n --jr-confirm-surface-default: #ffffff;\n --jr-confirm-ink-default: #111827;\n --jr-confirm-muted-default: #6b7280;\n --jr-confirm-border-default: #d1d5db;\n --jr-confirm-accent-default: #3b82f6;\n --jr-confirm-danger-default: #dc2626;\n --jr-confirm-on-accent-default: #ffffff;\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --jr-confirm-scrim-default: rgba(0, 0, 0, 0.65);\n --jr-confirm-surface-default: #1f2937;\n --jr-confirm-ink-default: #f3f4f6;\n --jr-confirm-muted-default: #9ca3af;\n --jr-confirm-border-default: #4b5563;\n --jr-confirm-accent-default: #60a5fa;\n --jr-confirm-danger-default: #f87171;\n --jr-confirm-on-accent-default: #111827;\n }\n }\n\n .jr-confirm-scrim {\n position: fixed;\n inset: 0;\n z-index: 50;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: var(--jr-confirm-scrim, var(--jr-confirm-scrim-default));\n }\n\n .jr-confirm-panel {\n width: 100%;\n max-width: 400px;\n padding: 24px;\n border-radius: var(--jr-confirm-radius, 8px);\n background-color: var(--jr-confirm-surface, var(--jr-confirm-surface-default));\n color: var(--jr-confirm-ink, var(--jr-confirm-ink-default));\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);\n }\n\n .jr-confirm-title {\n margin: 0 0 8px 0;\n font-size: 18px;\n font-weight: 600;\n }\n\n .jr-confirm-message {\n margin: 0 0 24px 0;\n color: var(--jr-confirm-muted, var(--jr-confirm-muted-default));\n }\n\n .jr-confirm-actions {\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n }\n\n .jr-confirm-actions button {\n padding: 8px 16px;\n border-radius: 6px;\n font: inherit;\n cursor: pointer;\n }\n\n .jr-confirm-cancel {\n border: 1px solid var(--jr-confirm-border, var(--jr-confirm-border-default));\n background-color: transparent;\n color: inherit;\n }\n\n .jr-confirm-confirm {\n border: none;\n background-color: var(--jr-confirm-accent, var(--jr-confirm-accent-default));\n color: var(--jr-confirm-on-accent, var(--jr-confirm-on-accent-default));\n }\n\n .jr-confirm-confirm.jr-confirm-danger {\n background-color: var(--jr-confirm-danger, var(--jr-confirm-danger-default));\n }\n `,\n})\nexport class JrConfirmDialog {\n readonly config = input.required<ActionConfirm>();\n readonly confirmed = output<void>();\n readonly cancelled = output<void>();\n\n protected readonly labels = inject(JR_CONFIRM_LABELS);\n\n private readonly id = dialogIdCounter++;\n protected readonly titleId = `jr-confirm-title-${this.id}`;\n protected readonly messageId = `jr-confirm-message-${this.id}`;\n\n private readonly cancelButton =\n viewChild<ElementRef<HTMLButtonElement>>('cancel');\n private readonly confirmButton =\n viewChild<ElementRef<HTMLButtonElement>>('confirm');\n\n protected readonly isDanger = computed(\n () => this.config().variant === 'danger',\n );\n\n constructor() {\n // Whatever was focused when the action fired — usually the control that\n // dispatched it, which is still in the document behind the dialog.\n const previous =\n typeof document !== 'undefined'\n ? (document.activeElement as HTMLElement | null)\n : null;\n\n // Cancel takes focus rather than confirm: a dialog exists to interrupt,\n // and landing on the destructive answer makes a stray Enter destructive.\n afterNextRender(() => this.cancelButton()?.nativeElement.focus());\n\n inject(DestroyRef).onDestroy(() => previous?.focus?.());\n }\n\n /**\n * Keep Tab inside the dialog. With exactly two buttons the whole trap is\n * wrapping the ends; a modal that lets focus wander behind it is a modal\n * only for people using a mouse.\n */\n protected onKeydown(event: KeyboardEvent): void {\n if (event.key !== 'Tab') return;\n const cancel = this.cancelButton()?.nativeElement;\n const confirm = this.confirmButton()?.nativeElement;\n if (!cancel || !confirm) return;\n\n const active = event.target;\n if (event.shiftKey && active === cancel) {\n event.preventDefault();\n confirm.focus();\n } else if (!event.shiftKey && active === confirm) {\n event.preventDefault();\n cancel.focus();\n }\n }\n}\n","import { DestroyRef, type Signal, inject, signal } from '@angular/core';\nimport { isDevtoolsActive, subscribeDevtoolsActive } from '@json-render/core';\n\n/**\n * Reactive mirror of the json-render devtools-active flag. When active, the\n * renderer wraps each element with a `data-jr-key` attribute for the picker.\n */\nexport function injectDevtoolsActive(): Signal<boolean> {\n const active = signal(isDevtoolsActive());\n const unsubscribe = subscribeDevtoolsActive(() =>\n active.set(isDevtoolsActive()),\n );\n inject(DestroyRef).onDestroy(unsubscribe);\n return active.asReadonly();\n}\n","import type { Spec, SpecIssue, UIElement } from '@json-render/core';\n\n/**\n * Caps on what a spec is allowed to cost the browser.\n *\n * A spec is attacker-shaped input: whatever produced one chose its own size,\n * its own nesting and — through `repeat` — its own array lengths. These are\n * the three of those the renderer can enforce for you.\n *\n * Every field is opt-in and unset means unlimited. There are no defaults\n * because no single number is right for every catalog, and a default would\n * change what an existing app renders the moment it upgraded.\n *\n * Limits are enforced whenever they are set, whatever `validate` is: a number\n * the app chose is a control, not advice. What \"enforced\" means differs by\n * limit, because the limits differ in kind — see each field.\n *\n * @example\n * ```html\n * <json-render\n * [spec]=\"spec()\"\n * [registry]=\"registry\"\n * [renderLimits]=\"{ maxElements: 500, maxDepth: 16, maxRepeatItems: 200 }\"\n * />\n * ```\n */\nexport interface RenderLimits {\n /**\n * Most elements a spec may contain. A spec over the cap does not render at\n * all: element count is a property of the whole spec, and there is no\n * meaningful \"first 500 elements\" of a graph.\n */\n readonly maxElements?: number;\n /**\n * Deepest the render tree may nest, counting the root as 1. An element\n * below the cap does not render, and neither does anything under it; what\n * fits still renders. Reported as an error, so `validate=\"strict\"` refuses\n * the spec outright rather than truncating it.\n *\n * A capped element does not act either — its `watch` stays unwired, so it\n * cannot dispatch actions from behind the cap.\n */\n readonly maxDepth?: number;\n /**\n * Most items one `repeat` may expand. The surplus items do not render.\n *\n * Enforced at render time only: `repeat` iterates a live state array, so no\n * amount of inspecting the spec can predict how long it will be. Nested\n * repeats multiply, so this is a per-repeat cap, not a total.\n */\n readonly maxRepeatItems?: number;\n}\n\n/**\n * Issue codes this package reports, widening core's set with the ones only a\n * renderer can find.\n *\n * - `cycle` — an element renders itself against the same data, which cannot\n * terminate. A tree that recurses into its items is not this.\n * - `too_deep` / `too_many_elements` — a {@link RenderLimits} cap was passed.\n * - `unknown_component` — a `type` the catalog does not define.\n * - `invalid_props` — an element's props fail its component's schema, or the\n * element fails the catalog's spec schema: a missing `children`, say.\n */\nexport type SpecCheckIssueCode =\n | SpecIssue['code']\n | 'cycle'\n | 'too_deep'\n | 'too_many_elements'\n | 'unknown_component'\n | 'invalid_props';\n\n/**\n * A problem found in a spec. Core's {@link SpecIssue} widened with the codes\n * above, so a {@link SpecIssue} is always one of these.\n */\nexport interface SpecCheckIssue {\n readonly severity: 'error' | 'warning';\n readonly message: string;\n readonly elementKey?: string;\n readonly code: SpecCheckIssueCode;\n}\n\n/**\n * The part of a json-render `Catalog` the check needs.\n *\n * Structural on purpose: a real catalog satisfies it, and the renderer stays\n * free of any dependency on the schema library behind `validate`.\n */\nexport interface SpecCatalog {\n /** Component type names the catalog defines. */\n readonly componentNames: readonly string[];\n /** Check a spec against the catalog's own schema. */\n validate(spec: unknown): {\n readonly success: boolean;\n readonly error?: unknown;\n };\n /**\n * The definitions the catalog was created from. Where\n * `data.components[type].props` is a schema — anything with a `safeParse`,\n * as a Zod schema has — each element's props are checked against its own\n * component's. Without it, props are checked only as far as `validate`\n * checks them, which for a catalog of more than one component is not at\n * all.\n *\n * `unknown` rather than that shape, so that a `Catalog` whose generic\n * arguments were left off — and whose `data` is therefore `unknown` — still\n * fits.\n */\n readonly data?: unknown;\n}\n\n/** The part of a props schema the check calls: what a Zod schema has. */\ninterface PropsSchema {\n safeParse(value: unknown): {\n readonly success: boolean;\n readonly error?: unknown;\n };\n}\n\n/** One complaint from a schema, at a path into the value it was given. */\ninterface SchemaIssue {\n readonly path: readonly unknown[];\n readonly message: string;\n}\n\n/** What one walk of the element graph found. */\nexport interface SpecGraph {\n /** Nesting depth from `spec.root`, counting the root as 1. */\n readonly depth: number;\n /**\n * Keys that close a cycle which cannot terminate. A back edge that\n * descends into repeat items is not one of these.\n */\n readonly cycles: readonly string[];\n}\n\n/**\n * A hostile spec can fail the catalog's schema in as many places as it has\n * properties. Report enough to act on and stop; the spec is refused either\n * way, and a console full of them helps nobody.\n */\nconst MAX_REPORTED_PROP_ISSUES = 20;\n\n/**\n * Whether this element's `repeat` descends into the item it is already inside,\n * rather than re-reading a fixed path in state.\n *\n * A relative statePath — `{\"$item\": \"children\"}` — resolves against the\n * enclosing item, so each pass reads one level further into the data and the\n * recursion ends where the data does. A plain string is absolute: every pass\n * reads the same array, and a spec that re-enters itself through one never\n * terminates.\n */\nfunction descendsIntoItems(element: UIElement): boolean {\n const repeat = element.repeat;\n return repeat !== undefined && typeof repeat.statePath !== 'string';\n}\n\n/** Every key an element renders below itself: `children` plus every slot. */\nfunction childKeysOf(element: UIElement): readonly string[] {\n const slots = element.slots;\n if (!slots) return element.children ?? [];\n const fromSlots = Object.values(slots).flat();\n return element.children ? [...element.children, ...fromSlots] : fromSlots;\n}\n\ninterface Frame {\n readonly key: string;\n readonly kids: readonly string[];\n next: number;\n deepest: number;\n}\n\n/**\n * Walk the element graph once for depth and cycles.\n *\n * Iterative on purpose. A recursive walk would blow the stack on exactly the\n * specs this exists to catch, which would make the guard a second way to\n * crash rather than the fix for the first.\n *\n * Depth is measured from `spec.root`, because that is what renders. Cycles\n * are swept for across every element, including the ones no parent reaches:\n * an unreachable cycle is still a defect, and one edit away from a reachable\n * one.\n *\n * Not every element that reaches itself is a defect, though. Drawing a tree —\n * a comment thread, a file browser, a nested menu — means an element that\n * repeats over a relative path and renders itself for each item, and that ends\n * when the data does. A back edge is only reported when nothing along it\n * descends into the data, which is the case that cannot end.\n *\n * `depthBelow` is memoised per element, so a shared subtree costs one visit\n * instead of one per path into it — without that, a spec whose elements each\n * name the next two is exponential to check. The memo makes the reported\n * depth a lower bound once a cycle has been cut, since which edge closes the\n * cycle depends on the order the walk reached it. The cycle is reported as an\n * error of its own, which is the finding worth acting on.\n */\nexport function analyseSpecGraph(spec: Spec): SpecGraph {\n const elements = spec.elements ?? {};\n const cycles = new Set<string>();\n const depthBelow = new Map<string, number>();\n const onPath = new Set<string>();\n\n const walkFrom = (start: string): void => {\n const first = elements[start];\n if (!first || depthBelow.has(start)) return;\n\n const stack: Frame[] = [\n { key: start, kids: childKeysOf(first), next: 0, deepest: 0 },\n ];\n onPath.add(start);\n\n while (stack.length > 0) {\n const frame = stack[stack.length - 1]!;\n\n if (frame.next < frame.kids.length) {\n const childKey = frame.kids[frame.next++]!;\n const memo = depthBelow.get(childKey);\n if (memo !== undefined) {\n frame.deepest = Math.max(frame.deepest, memo);\n continue;\n }\n // A child that closes the cycle is not followed — that is what keeps\n // this walk finite — and not counted towards depth either.\n if (onPath.has(childKey)) {\n const from = stack.findIndex((frame) => frame.key === childKey);\n const descends = stack\n .slice(from)\n .some((frame) => descendsIntoItems(elements[frame.key]!));\n if (!descends) cycles.add(childKey);\n continue;\n }\n const child = elements[childKey];\n // A child the spec never defined is validateSpec's finding, not ours.\n if (!child) continue;\n onPath.add(childKey);\n stack.push({\n key: childKey,\n kids: childKeysOf(child),\n next: 0,\n deepest: 0,\n });\n continue;\n }\n\n stack.pop();\n onPath.delete(frame.key);\n const depth = frame.deepest + 1;\n depthBelow.set(frame.key, depth);\n const parent = stack[stack.length - 1];\n if (parent) parent.deepest = Math.max(parent.deepest, depth);\n }\n };\n\n if (spec.root) walkFrom(spec.root);\n const depth = (spec.root ? depthBelow.get(spec.root) : undefined) ?? 0;\n\n for (const key of Object.keys(elements)) walkFrom(key);\n\n return { depth, cycles: [...cycles] };\n}\n\n/** Report a cycle, naming the element that is its own descendant. */\nexport function cycleIssue(key: string): SpecCheckIssue {\n return {\n severity: 'error',\n code: 'cycle',\n elementKey: key,\n message: `Element \"${key}\" renders itself against the same data, which never terminates. The cycle is broken where it closes — the repeated element does not render a second time — but the spec cannot be drawn as written. A tree that recurses needs a repeat with a relative statePath, like {\"$item\": \"children\"}.`,\n };\n}\n\n/** Report a breached element-count cap. */\nexport function elementCountIssue(\n count: number,\n limit: number,\n): SpecCheckIssue {\n return {\n severity: 'error',\n code: 'too_many_elements',\n message: `Spec has ${count} elements, over the limit of ${limit}. Nothing is rendered: renderLimits.maxElements is a cap on the whole spec.`,\n };\n}\n\n/** Report a breached depth cap. */\nexport function depthIssue(depth: number, limit: number): SpecCheckIssue {\n return {\n severity: 'error',\n code: 'too_deep',\n message: `Spec nests ${depth} levels deep, over the limit of ${limit}. Elements below level ${limit} do not render.`,\n };\n}\n\n/**\n * Check a spec against a catalog: the component types it names, then the\n * catalog's spec schema, then each element's props against its own\n * component's schema.\n *\n * The props need that pass of their own. Core builds one schema for the whole\n * spec, and it gives an element's props a component's schema only when the\n * catalog has exactly one component; with more, every element's props are an\n * open record, whatever its `type`. So `catalog.validate` holds an element to\n * its shape — `children`, a `type` from the catalog — and not to its props.\n *\n * Whatever that schema did say about the props of an element checked here is\n * dropped: with a one-component catalog it would be reported twice, and it\n * judges expressions this pass knows to leave alone.\n *\n * The schema passes are skipped while a type is unknown. That is an error on\n * its own, and the spec schema would only restate it as a `type` outside the\n * ones it accepts.\n */\nexport function catalogIssues(\n spec: Spec,\n catalog: SpecCatalog,\n): SpecCheckIssue[] {\n const elements = Object.entries(spec.elements ?? {});\n const known = new Set(catalog.componentNames);\n\n const unknown: SpecCheckIssue[] = [];\n for (const [key, element] of elements) {\n if (known.has(element.type)) continue;\n unknown.push({\n severity: 'error',\n code: 'unknown_component',\n elementKey: key,\n message: `Element \"${key}\" has type \"${element.type}\", which this catalog does not define. Nothing renders for it.`,\n });\n }\n if (unknown.length > 0) return unknown;\n\n const schemas = new Map<string, PropsSchema>();\n for (const [key, element] of elements) {\n const schema = propsSchemaOf(catalog.data, element.type);\n if (schema) schemas.set(key, schema);\n }\n\n const found = specSchemaIssues(spec, catalog).filter(\n ({ path }) =>\n !(\n path[0] === 'elements' &&\n typeof path[1] === 'string' &&\n schemas.has(path[1]) &&\n path[2] === 'props'\n ),\n );\n for (const [key, element] of elements) {\n const room = MAX_REPORTED_PROP_ISSUES - found.length;\n if (room <= 0) break;\n const schema = schemas.get(key);\n if (schema) found.push(...propsIssues(key, element, schema, room));\n }\n\n return found.slice(0, MAX_REPORTED_PROP_ISSUES).map(toSpecCheckIssue);\n}\n\n/**\n * Whether an element's props have arrived: they pass its component's schema,\n * leaving out what the schema says about expressions, the same way\n * {@link catalogIssues} judges them. The renderer holds an element back on\n * this while the spec streams.\n *\n * The props are taken as written in the spec, not as resolved. What a stream\n * leaves out is spec, and an expression that is there has arrived, whatever\n * it resolves to; checking the spec also keeps state writes from re-running\n * the schema.\n *\n * True when the catalog declares no schema that can be called for the type:\n * there is nothing to wait for. False when the schema throws, or fails\n * without saying where — the element mounts once loading ends either way.\n */\nexport function propsArrived(\n element: UIElement,\n catalog: SpecCatalog,\n): boolean {\n const schema = propsSchemaOf(catalog.data, element.type);\n if (!schema) return true;\n const props = element.props ?? {};\n let result: ReturnType<PropsSchema['safeParse']>;\n try {\n result = schema.safeParse(props);\n } catch {\n return false;\n }\n if (result.success) return true;\n const issues = readIssues(result.error);\n return (\n issues.length > 0 &&\n issues.every(({ path }) => reachesExpression(props, path))\n );\n}\n\n/**\n * The props schema a catalog declares for a component type, if it declares\n * one that can be called.\n */\nfunction propsSchemaOf(data: unknown, type: string): PropsSchema | undefined {\n const components = (data as { components?: unknown } | null | undefined)\n ?.components;\n if (\n typeof components !== 'object' ||\n components === null ||\n !Object.hasOwn(components, type)\n ) {\n return undefined;\n }\n const props = (\n components as Record<string, { props?: unknown } | null | undefined>\n )[type]?.props;\n return typeof (props as Partial<PropsSchema> | null | undefined)\n ?.safeParse === 'function'\n ? (props as PropsSchema)\n : undefined;\n}\n\n/** What the catalog's spec schema reported, with paths rooted at the spec. */\nfunction specSchemaIssues(spec: Spec, catalog: SpecCatalog): SchemaIssue[] {\n try {\n const result = catalog.validate(spec);\n return result.success ? [] : readIssues(result.error);\n } catch (error) {\n return [{ path: [], message: threwMessage('the catalog schema', error) }];\n }\n}\n\n/**\n * What an element's component schema says about its props, leaving out what\n * it says about expressions, with paths rooted at the spec.\n *\n * A schema that throws counts as a rejection, not a crash. Real ones do:\n * `ValidationConfigSchema`, which every Material input's `validation` prop\n * uses, recurses through `enabled` and overflows the stack a thousand\n * `$and`s deep.\n */\nfunction propsIssues(\n key: string,\n element: UIElement,\n schema: PropsSchema,\n room: number,\n): SchemaIssue[] {\n const at = ['elements', key, 'props'];\n let result: ReturnType<PropsSchema['safeParse']>;\n try {\n result = schema.safeParse(element.props);\n } catch (error) {\n return [\n {\n path: at,\n message: threwMessage(`the \"${element.type}\" schema`, error),\n },\n ];\n }\n if (result.success) return [];\n\n const issues: SchemaIssue[] = [];\n for (const { path, message } of readIssues(result.error)) {\n if (issues.length >= room) break;\n if (reachesExpression(element.props, path)) continue;\n issues.push({ path: [...at, ...path], message });\n }\n return issues;\n}\n\n/**\n * Whether a props issue is about an expression: it sits on one, inside one,\n * or on a value holding one.\n *\n * `{\"$state\": \"/title\"}` where the schema wants a string is not a defect.\n * Core resolves every such value before the component sees it, so the schema\n * would be judging something that never renders. Any `$`-prefixed key counts\n * — directive names must start with `$`, and so would an expression added to\n * core later. A value merely holding one is left alone too, since a union or\n * a refinement over it ran on the unresolved value.\n *\n * The props object itself is not an expression: core resolves the values\n * inside it, never the object.\n */\nfunction reachesExpression(props: unknown, path: readonly unknown[]): boolean {\n let value = props;\n for (const segment of path) {\n if (typeof value !== 'object' || value === null) return false;\n value = (value as Record<PropertyKey, unknown>)[segment as PropertyKey];\n if (isExpression(value)) return true;\n }\n return holdsExpression(value);\n}\n\n/** A value core resolves at render time — or will, once it knows the key. */\nfunction isExpression(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value).some((key) => key.startsWith('$'))\n );\n}\n\n/**\n * Whether anything nested inside `value` is an expression.\n *\n * Iterative, and it remembers what it has seen, for the same reason as\n * {@link analyseSpecGraph}: props are as attacker-shaped as the rest of the\n * spec, and a check that overflowed or looped on them would be a second way\n * to crash.\n */\nfunction holdsExpression(value: unknown): boolean {\n const pending: unknown[] = [value];\n const seen = new Set<object>();\n while (pending.length > 0) {\n const current = pending.pop();\n if (typeof current !== 'object' || current === null) continue;\n if (seen.has(current)) continue;\n seen.add(current);\n for (const child of Object.values(current)) {\n if (isExpression(child)) return true;\n pending.push(child);\n }\n }\n return false;\n}\n\n/**\n * Read what a schema reported.\n *\n * Read defensively rather than typed against the schema library: the shape\n * below (`issues`, each with `path` and `message`) is what every version of\n * it has produced, and a renderer that threw while explaining a bad spec\n * would be the worse failure.\n */\nfunction readIssues(error: unknown): SchemaIssue[] {\n const raw = (error as { issues?: unknown } | null | undefined)?.issues;\n if (!Array.isArray(raw)) return [];\n\n return raw.map((entry): SchemaIssue => {\n const item = entry as { path?: unknown; message?: unknown } | null;\n const path = item?.path;\n const message = item?.message;\n return {\n path: Array.isArray(path) ? path : [],\n message: typeof message === 'string' ? message : 'is not valid',\n };\n });\n}\n\nfunction threwMessage(schema: string, error: unknown): string {\n const reason =\n error instanceof Error ? ` (${error.name}: ${error.message})` : '';\n return `${schema} threw instead of answering${reason}, so this counts as rejected`;\n}\n\nfunction toSpecCheckIssue({ path, message }: SchemaIssue): SpecCheckIssue {\n // Paths are rooted at the spec, so `elements.<key>.props.<prop>` names the\n // element in its second segment.\n const elementKey =\n path[0] === 'elements' && typeof path[1] === 'string' ? path[1] : undefined;\n const where = path.length > 0 ? path.map(String).join('.') : 'spec';\n return {\n severity: 'error',\n code: 'invalid_props',\n ...(elementKey === undefined ? {} : { elementKey }),\n message: `${where}: ${message}`,\n };\n}\n","import {\n type DirectiveRegistry,\n type UIElement,\n resolveRepeatStatePath,\n} from '@json-render/core';\n\n/**\n * The state paths an element's expressions can read, or `null` when that\n * can't be known from the spec.\n *\n * Worked out from the spec alone, before anything resolves, so that an element\n * can depend on those paths rather than on the whole state. The answer may\n * name more paths than a given resolution reads — both branches of a `$cond`,\n * say — but never fewer: a path left out would be a write the element misses,\n * and it would keep showing the old value with nothing in the console.\n *\n * `null` is the safe answer, and it is given whenever the spec holds something\n * this reader does not model:\n *\n * - a registered directive, whose `resolve` receives the whole context and may\n * read any path at all;\n * - a `$`-prefixed key it doesn't recognise, which is what an expression added\n * to core after this was written would look like;\n * - a read of the whole state (`''` or `'/'`), and a condition it can't parse.\n *\n * The walk mirrors core's `resolvePropValue` and `evaluateVisibility`, in the\n * same order, because the order decides which expression an object is.\n */\nexport function collectStateReads(\n element: UIElement,\n directives: DirectiveRegistry | undefined,\n repeatBasePath: string | undefined,\n): ReadonlySet<string> | null {\n const reader = new StateReader(directives, repeatBasePath);\n const understood =\n reader.condition(element.visible) &&\n Object.values(element.props ?? {}).every((value) => reader.value(value));\n return understood ? reader.paths : null;\n}\n\ntype Expression = Record<string, unknown>;\n\nfunction isObject(value: unknown): value is Expression {\n return typeof value === 'object' && value !== null;\n}\n\n/** Comparison operators a single condition may carry, as core reads them. */\nconst COMPARISONS = ['eq', 'neq', 'gt', 'gte', 'lt', 'lte'] as const;\n\nclass StateReader {\n readonly paths = new Set<string>();\n\n constructor(\n private readonly directives: DirectiveRegistry | undefined,\n private readonly repeatBasePath: string | undefined,\n ) {}\n\n /** A prop value. Returns false when it can read state this can't name. */\n value(value: unknown): boolean {\n if (!isObject(value)) return true;\n\n if (typeof value['$state'] === 'string') return this.state(value['$state']);\n if (typeof value['$item'] === 'string') return this.item(value['$item']);\n if ('$index' in value && value['$index'] === true) return true;\n // A two-way binding reads the path it writes back to.\n if (typeof value['$bindState'] === 'string') {\n return this.state(value['$bindState']);\n }\n if (typeof value['$bindItem'] === 'string') {\n return this.boundItem(value['$bindItem']);\n }\n if ('$cond' in value && '$then' in value && '$else' in value) {\n return (\n this.condition(value['$cond']) &&\n this.value(value['$then']) &&\n this.value(value['$else'])\n );\n }\n if (typeof value['$computed'] === 'string') {\n // The function is handed its resolved arguments and nothing else.\n const args = value['args'];\n return (\n !args || Object.values(Object(args)).every((arg) => this.value(arg))\n );\n }\n if (typeof value['$template'] === 'string') {\n return this.template(value['$template']);\n }\n\n if (Array.isArray(value)) return value.every((item) => this.value(item));\n\n if (this.directives) {\n for (const name of this.directives.keys()) {\n if (name in value) return false;\n }\n }\n for (const [key, entry] of Object.entries(value)) {\n if (key.startsWith('$') || !this.value(entry)) return false;\n }\n return true;\n }\n\n /** A `visible` condition, or the condition of a `$cond`. */\n condition(condition: unknown): boolean {\n if (condition === undefined || typeof condition === 'boolean') return true;\n if (Array.isArray(condition)) {\n return condition.every((single) => this.singleCondition(single));\n }\n if (!isObject(condition)) return false;\n for (const group of ['$and', '$or'] as const) {\n if (group in condition) {\n const children = condition[group];\n return (\n Array.isArray(children) &&\n children.every((child) => this.condition(child))\n );\n }\n }\n return this.singleCondition(condition);\n }\n\n private singleCondition(condition: unknown): boolean {\n if (!isObject(condition)) return false;\n let understood: boolean;\n if ('$index' in condition) {\n understood = true;\n } else if ('$item' in condition) {\n const item = condition['$item'];\n understood = typeof item === 'string' && this.item(item);\n } else {\n // Core reads `$state` here without checking it: anything but a string\n // path reads the whole state.\n const path = condition['$state'];\n understood = typeof path === 'string' && this.state(path);\n }\n // Core looks only at the first operator present. Reading all of them is\n // a superset of that.\n for (const operator of COMPARISONS) {\n const operand = condition[operator];\n if (isObject(operand) && typeof operand['$state'] === 'string') {\n understood = this.state(operand['$state']) && understood;\n }\n }\n return understood;\n }\n\n private template(template: string): boolean {\n for (const [, placeholder] of template.matchAll(/\\$\\{([^}]+)\\}/g)) {\n if (placeholder.startsWith('/')) {\n if (!this.state(placeholder)) return false;\n continue;\n }\n // Core tries the repeat item first and falls back to a state path of\n // the same name when the item has nothing there.\n if (!this.item(placeholder) || !this.state(`/${placeholder}`)) {\n return false;\n }\n }\n return true;\n }\n\n private state(path: string): boolean {\n if (path === '' || path === '/') return false;\n this.paths.add(path);\n return true;\n }\n\n /**\n * A `$bindItem`, joined the way core joins it — which is not quite how it\n * joins an `$item` read. Outside a repeat it resolves to nothing.\n */\n private boundItem(itemPath: string): boolean {\n if (this.repeatBasePath === undefined) return true;\n return this.state(\n itemPath === ''\n ? this.repeatBasePath\n : `${this.repeatBasePath}/${itemPath}`,\n );\n }\n\n /**\n * A read of the repeat item, as the state path it sits at. The item value\n * reaches the element on its own, but only as the same object when an\n * external store edits it in place, so the path is what notices the edit.\n */\n private item(itemPath: string): boolean {\n if (this.repeatBasePath === undefined) return true;\n const path = resolveRepeatStatePath(\n { $item: itemPath },\n this.repeatBasePath,\n );\n return path !== undefined && this.state(path);\n }\n}\n","import { InjectionToken, type Signal, inject, isDevMode } from '@angular/core';\nimport type { RenderContext, RenderPath, RepeatScope } from './types';\n\n/**\n * The render context of the element currently being rendered.\n * Provided by the renderer for every catalog component instance.\n */\nexport const RENDER_CONTEXT = new InjectionToken<RenderContext>(\n 'ngx-json-render RENDER_CONTEXT',\n);\n\n/**\n * The spec key of the element currently being rendered. Provided alongside\n * {@link RENDER_CONTEXT} for every catalog component instance.\n */\nexport const ELEMENT_KEY = new InjectionToken<Signal<string>>(\n 'ngx-json-render ELEMENT_KEY',\n);\n\n/**\n * The current repeat scope. Present only for elements rendered inside a\n * `repeat` block.\n */\nexport const REPEAT_SCOPE = new InjectionToken<RepeatScope>(\n 'ngx-json-render REPEAT_SCOPE',\n);\n\n/**\n * This element's position in the render tree. Provided by `<jr-element>` for\n * everything it renders below itself, so each element can see its own depth\n * and its own ancestry.\n *\n * @internal Not part of the public API: it exists so the renderer can refuse\n * to draw an element that is its own ancestor, and to enforce\n * `renderLimits.maxDepth`.\n */\nexport const RENDER_PATH = new InjectionToken<Signal<RenderPath>>(\n 'ngx-json-render RENDER_PATH',\n);\n\n/**\n * Whether an element that skipped a state write checks that it was right to:\n * that resolving it against the whole state would not give anything else.\n * On in dev mode, off in production.\n *\n * @internal Not part of the public API. The check calls `$computed`\n * functions again, so tests that count those calls turn it off.\n */\nexport const CHECK_SKIPPED_WRITES = new InjectionToken<boolean>(\n 'ngx-json-render CHECK_SKIPPED_WRITES',\n { providedIn: 'root', factory: () => isDevMode() },\n);\n\n/**\n * Inject the render context inside a catalog component.\n *\n * @example\n * ```ts\n * @Component({\n * selector: 'app-button',\n * template: `<button (click)=\"ctx.emit('press')\">{{ ctx.props().label }}</button>`,\n * })\n * export class ButtonComponent {\n * readonly ctx = injectRenderContext<{ label: string }>();\n * }\n * ```\n */\nexport function injectRenderContext<\n P = Record<string, unknown>,\n>(): RenderContext<P> {\n const ctx = inject(RENDER_CONTEXT, { optional: true });\n if (!ctx) {\n throw new Error(\n 'injectRenderContext() must be used inside a component rendered by <json-render>',\n );\n }\n return ctx as RenderContext<P>;\n}\n\n/**\n * Inject the spec key of the element this component renders.\n *\n * Catalog components that collect their children — a tab group discovering\n * its tabs, for instance — need it to order registrations by the spec's\n * `children` array rather than by the order the children happened to\n * announce themselves in.\n *\n * @example\n * ```ts\n * const key = injectElementKey();\n * const index = computed(() => parent.element().children?.indexOf(key()) ?? -1);\n * ```\n */\nexport function injectElementKey(): Signal<string> {\n const key = inject(ELEMENT_KEY, { optional: true });\n if (!key) {\n throw new Error(\n 'injectElementKey() must be used inside a component rendered by <json-render>',\n );\n }\n return key;\n}\n\n/**\n * Inject the current repeat scope, or `null` when the component is not\n * rendered inside a `repeat` block.\n */\nexport function injectRepeatScope(): RepeatScope | null {\n return inject(REPEAT_SCOPE, { optional: true });\n}\n","import { NgComponentOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n Injector,\n type Signal,\n computed,\n effect,\n inject,\n input,\n isDevMode,\n signal,\n untracked,\n} from '@angular/core';\nimport type {\n ActionBinding,\n PropResolutionContext,\n StateModel,\n UIElement,\n} from '@json-render/core';\nimport {\n evaluateVisibility,\n getByPath,\n resolveActionParam,\n resolveBindings,\n resolveElementProps,\n} from '@json-render/core';\nimport { JsonRenderActionsService, isActionCancelled } from './actions.service';\nimport { injectDevtoolsActive } from './devtools';\nimport { JsonRenderRootContext } from './root-context';\nimport { sameJson } from './same-json';\nimport { propsArrived } from './render-limits';\nimport { collectStateReads } from './state-reads';\nimport { JsonRenderStateService } from './state.service';\nimport {\n CHECK_SKIPPED_WRITES,\n ELEMENT_KEY,\n REPEAT_SCOPE,\n RENDER_CONTEXT,\n RENDER_PATH,\n} from './tokens';\nimport type { EventHandle, RenderContext, RenderPath } from './types';\n\nconst warnedSlots = new Set<string>();\n\n/**\n * Report a failure from a fire-and-forget action dispatch. Cancelling a\n * confirmation dialog is a normal outcome, not an error, so it stays silent.\n */\nfunction reportActionError(error: unknown): void {\n if (isActionCancelled(error)) return;\n console.error(error);\n}\n\n/**\n * Whether `inner` reads strictly deeper into state than `outer` — the state\n * path of one repeat item nested inside another's.\n *\n * `null` is the world outside any repeat, so stepping into one is always\n * progress. Below that it is a prefix test on the resolved path, and the\n * trailing separator is what keeps `/tree/10` from counting as a step inside\n * `/tree/1`.\n */\nfunction descendsInto(outer: string | null, inner: string | null): boolean {\n if (inner === null) return false;\n if (outer === null) return true;\n return inner.startsWith(`${outer}/`);\n}\n\n/**\n * Whether this element renders itself again without getting anywhere — the\n * one arrangement that cannot terminate.\n *\n * An element reaching itself is not by itself a defect. It is how a tree gets\n * drawn — a comment thread, a file browser, a nested menu — where each pass\n * repeats over a path relative to the item it is already inside and so reads\n * one level further into the data. That ends when the data does.\n *\n * What separates the two is whether the repeat descended. Compare against the\n * nearest occurrence above: `/tree/0` then `/tree/0/children/1` is a tree\n * walking down, while `/items/0` then `/items/1` is a spec repeating over a\n * fixed array inside itself, and `/items/0` twice is one with no repeat\n * between the passes at all. Only the first can run out.\n */\nfunction repeatsItself(path: RenderPath): boolean {\n for (let step = path.parent; step !== null; step = step.parent) {\n if (step.key !== path.key) continue;\n return !descendsInto(step.scopePath, path.scopePath);\n }\n return false;\n}\n\n/**\n * Whether two objects hold the same values under the same keys.\n *\n * `objectsByIdentity` decides what the same object or array reference means.\n * The internal store copies every path it writes and never touches a snapshot\n * it has handed out, so there the same reference is the same content. An\n * external store may write into its snapshot in place, so there only\n * primitives can be trusted to compare equal, and any object value counts as\n * changed.\n */\nfunction sameValues(\n a: Readonly<Record<string, unknown>>,\n b: Readonly<Record<string, unknown>>,\n objectsByIdentity: boolean,\n): boolean {\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key of keys) {\n if (!Object.hasOwn(b, key)) return false;\n const value = a[key];\n if (!Object.is(value, b[key])) return false;\n if (!objectsByIdentity && typeof value === 'object' && value !== null) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Whether two resolved values hold the same content, however they are built.\n *\n * For the dev-mode check on skipped writes, which compares a fresh resolution\n * with an old one: a `$computed` function returns a new object every time,\n * so identity says nothing there. What it can't see into — functions, a `Map`,\n * a class instance — it counts as the same, because a check that warns about\n * a correct element is worse than one that misses a case.\n */\nfunction sameContent(\n a: unknown,\n b: unknown,\n seen = new Set<unknown>(),\n): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a === 'function' && typeof b === 'function') return true;\n if (typeof a !== 'object' || typeof b !== 'object' || !a || !b) return false;\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n if (a instanceof Date) return a.getTime() === (b as Date).getTime();\n const plain =\n Array.isArray(a) || Object.getPrototypeOf(a) === Object.prototype;\n if (!plain || seen.has(a)) return true;\n seen.add(a);\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(\n (key) =>\n Object.hasOwn(b, key) &&\n sameContent(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n seen,\n ),\n );\n}\n\n/**\n * Whether a state write at `written` can change the value at `bound`: the\n * same path, a container above it, or a path inside it.\n */\nfunction touches(written: string, bound: string): boolean {\n return (\n written === bound ||\n bound.startsWith(`${written}/`) ||\n written.startsWith(`${bound}/`)\n );\n}\n\n/** Element keys already warned about by the check on skipped writes. */\nconst warnedSkippedWrites = new Set<string>();\n\nconst EMPTY_READS: ReadonlySet<string> = new Set();\n\nfunction sameReads(\n a: ReadonlySet<string> | null,\n b: ReadonlySet<string> | null,\n): boolean {\n if (a === b) return true;\n if (!a || !b || a.size !== b.size) return false;\n for (const path of a) if (!b.has(path)) return false;\n return true;\n}\n\n/** The chain from the root down to `path`, as a line a human can follow. */\nfunction describePath(path: RenderPath): string {\n const keys: string[] = [];\n for (let step: RenderPath | null = path; step !== null; step = step.parent) {\n keys.push(step.key);\n }\n return keys.reverse().join(' \\u2192 ');\n}\n\n/**\n * Renders a single spec element: evaluates visibility, resolves prop\n * expressions against the state model, wires event/watch bindings, and\n * instantiates the catalog component with a {@link RenderContext} injector.\n *\n * @internal Used by `<json-render>` and `<jr-children>`.\n */\n@Component({\n selector: 'jr-element',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NgComponentOutlet],\n styles: `:host { display: contents; }`,\n template: `\n @if (!refusal() && rawElement() && visible() && component()) {\n @if (devtoolsKey(); as dk) {\n <span [attr.data-jr-key]=\"dk\" style=\"display: contents\">\n <ng-container *ngComponentOutlet=\"component(); injector: outletInjector\" />\n </span>\n } @else {\n <ng-container *ngComponentOutlet=\"component(); injector: outletInjector\" />\n }\n }\n `,\n})\nexport class JrElement {\n readonly elementKey = input.required<string>();\n\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n private readonly actions = inject(JsonRenderActionsService);\n private readonly repeatScope = inject(REPEAT_SCOPE, { optional: true });\n private readonly parentPath = inject(RENDER_PATH, { optional: true });\n private readonly devtoolsActive = injectDevtoolsActive();\n\n /**\n * The raw (unresolved) element from the spec.\n *\n * Compared by content, not identity. A streamed patch shares every element\n * it did not touch, and the identity check settles those at once; but a\n * spec can also arrive as all-new objects — a whole-spec part, a host that\n * fetches it again, `buildSpecFromParts` replaying a message — and then an\n * element whose content is unchanged would resolve, and every container\n * with a fresh `children` array re-render, for nothing.\n */\n readonly rawElement = computed<UIElement | undefined>(\n () => this.root.spec()?.elements?.[this.elementKey()],\n { equal: (a, b) => sameJson(a, b) },\n );\n\n /**\n * The state paths this element's expressions can read, or null when the\n * spec doesn't say — see {@link collectStateReads} for when that is.\n */\n private readonly stateReads = computed<ReadonlySet<string> | null>(\n () => {\n const el = this.rawElement();\n if (!el) return EMPTY_READS;\n return collectStateReads(\n el,\n this.root.directiveRegistry(),\n this.repeatScope?.basePath(),\n );\n },\n { equal: sameReads },\n );\n\n /**\n * One signal per path this element reads, each holding the value at that\n * path. They are rebuilt only when the paths change, and a cell that stays\n * keeps its last value, so a path that didn't change is not a change.\n *\n * A cell compares like a resolved prop does: primitives by value, objects\n * by reference with the internal store (which copies every path it writes)\n * and never equal with an external `store`, which may write into its\n * snapshot in place.\n */\n private readonly stateCells = (() => {\n let cells = new Map<string, Signal<unknown>>();\n return computed<ReadonlyMap<string, Signal<unknown>> | null>(() => {\n const reads = this.stateReads();\n if (reads === null) return null;\n const next = new Map<string, Signal<unknown>>();\n for (const path of reads) {\n next.set(\n path,\n cells.get(path) ??\n computed(() => getByPath(this.state.state(), path), {\n equal: (a, b) =>\n Object.is(a, b) &&\n (typeof a !== 'object' ||\n a === null ||\n !untracked(this.root.store)),\n }),\n );\n }\n cells = next;\n return next;\n });\n })();\n\n /**\n * How many times {@link readableState} has taken a snapshot. The dev-mode\n * check compares it between state writes to tell which ones were skipped.\n */\n private snapshotsTaken = 0;\n\n /**\n * The state to resolve against: the whole snapshot, but only as fresh as\n * the paths this element reads. A write elsewhere doesn't reach it, so the\n * element doesn't resolve anything for it. An element whose reads are\n * unknown follows every write, as all elements did before.\n */\n private readonly readableState = computed<StateModel>(\n () => {\n this.snapshotsTaken++;\n const cells = this.stateCells();\n if (cells === null) return this.state.state();\n for (const cell of cells.values()) cell();\n return untracked(this.state.state);\n },\n // A snapshot an external store mutated in place is the same object, and\n // still has to count as newer when a cell says so.\n { equal: () => false },\n );\n\n /** Prop/visibility resolution context (state + repeat scope + extensions). */\n private readonly resolutionCtx = computed<PropResolutionContext>(() => {\n const scope = this.repeatScope;\n return {\n stateModel: this.readableState(),\n ...(scope\n ? {\n repeatItem: scope.item(),\n repeatIndex: scope.index(),\n repeatBasePath: scope.basePath(),\n }\n : {}),\n functions: this.root.functions() ?? {},\n directives: this.root.directiveRegistry(),\n };\n });\n\n protected readonly visible = computed(() => {\n const el = this.rawElement();\n if (!el || el.visible === undefined) return true;\n return evaluateVisibility(el.visible, this.resolutionCtx());\n });\n\n /**\n * How many state writes have touched a path this element is two-way bound\n * to. See {@link resolution} for why those writes count on their own.\n */\n private readonly boundWrites = signal(0);\n\n /**\n * The element with all prop expressions resolved, and the bound writes it\n * was resolved after.\n *\n * Resolving builds a new props object every time, so a result that holds\n * the same values as the last one counts as unchanged and keeps the old\n * object; otherwise one keystroke would re-run every catalog template that\n * happened to resolve.\n *\n * A write to a path the element is bound to always counts, though. Its\n * component writes the user's input into the DOM before it reaches state,\n * so the DOM can differ from a prop whose value never did: typing and a\n * `clearStatePath` in the same turn take the prop from '' through 'milk'\n * back to '' with nobody reading 'milk'. The README tells catalog authors\n * to sync such inputs with an effect on props, and that effect only gets to\n * put the DOM right if it runs. Writes anywhere else compare by value, like\n * any element's.\n */\n private readonly resolution = computed<{\n element: UIElement | undefined;\n boundWrites: number;\n }>(\n () => {\n const boundWrites = this.boundWrites();\n const el = this.rawElement();\n if (!el) return { element: undefined, boundWrites };\n return {\n element: {\n ...el,\n props: resolveElementProps(el.props ?? {}, this.resolutionCtx()),\n },\n boundWrites,\n };\n },\n {\n equal: (a, b) => {\n if (a.boundWrites !== b.boundWrites) return false;\n if (a.element === b.element) return true;\n if (!a.element || !b.element) return false;\n const { props: aProps, ...aRest } = a.element;\n const { props: bProps, ...bRest } = b.element;\n // Everything but props is the spec element itself, never state.\n return (\n sameValues(aRest, bRest, true) &&\n sameValues(aProps, bProps, !untracked(this.root.store))\n );\n },\n },\n );\n\n /** The element with all prop expressions resolved. */\n readonly resolvedElement = computed<UIElement | undefined>(\n () => this.resolution().element,\n );\n\n /** Two-way binding paths ($bindState / $bindItem) by prop name. */\n readonly bindings = computed<Record<string, string> | undefined>(\n () => {\n const el = this.rawElement();\n return el\n ? resolveBindings(el.props ?? {}, this.resolutionCtx())\n : undefined;\n },\n {\n equal: (a, b) => a === b || (!!a && !!b && sameValues(a, b, true)),\n },\n );\n\n private readonly entry = computed(() => {\n const el = this.rawElement();\n return el ? this.root.resolveEntry(el.type) : undefined;\n });\n\n /** Set once the real component has been shown; see {@link held}. */\n private mounted = false;\n\n /**\n * Whether the component waits for its props: the spec is still loading, a\n * catalog was given, and the props written so far do not pass the\n * component's schema (see {@link propsArrived}).\n *\n * One-way. Once the component has been shown it is never swapped back for\n * the fallback, even if a later patch takes a prop away again: a component\n * flickering out mid-stream is worse than one showing a gap. Once latched\n * this reads no signals, so a mounted element pays nothing for the gate on\n * later patches — and neither does any element when nothing is loading.\n */\n protected readonly held = computed(() => {\n if (this.mounted) return false;\n const el = this.rawElement();\n const catalog = this.root.catalog();\n const held =\n !!el && !!catalog && this.root.loading() && !propsArrived(el, catalog);\n if (!held && this.entry() && this.visible() && !this.refusal()) {\n this.mounted = true;\n }\n return held;\n });\n\n /** What the outlet shows: the component, or its fallback while held. */\n protected readonly component = computed(() =>\n this.held()\n ? (this.entry()?.fallback ?? null)\n : (this.entry()?.component ?? null),\n );\n\n protected readonly devtoolsKey = computed(() =>\n this.devtoolsActive() ? this.elementKey() : null,\n );\n\n /**\n * Where this element sits in the tree. Passed down to everything it renders\n * below itself, which is what lets each element see its own ancestry\n * without the renderer holding a registry of who is drawing what.\n */\n private readonly path = computed<RenderPath>(() => {\n const parent = this.parentPath?.() ?? null;\n return {\n key: this.elementKey(),\n depth: (parent?.depth ?? 0) + 1,\n scopePath: this.repeatScope?.basePath() ?? null,\n parent,\n };\n });\n\n /**\n * Why this element is not drawn, or null when it is.\n *\n * The cycle half is unconditional — not something `validate` turns on. An\n * element that renders itself without reading any deeper renders forever,\n * and a spec that never stops rendering takes the tab with it; refusing to\n * draw the repetition is the only outcome that leaves anything on screen.\n * It costs one walk up a chain of parents, bounded by `maxDepth` where one\n * is set and by the spec's own nesting where it is not.\n */\n protected readonly refusal = computed<'cycle' | 'depth' | null>(() => {\n const path = this.path();\n if (repeatsItself(path)) return 'cycle';\n const maxDepth = this.root.limits()?.maxDepth;\n if (maxDepth !== undefined && path.depth > maxDepth) return 'depth';\n return null;\n });\n\n private readonly renderCtx: RenderContext = {\n element: this.resolvedElement as Signal<UIElement>,\n props: computed(() => this.resolvedElement()?.props ?? {}),\n emit: (event) => this.fireEvent(event),\n on: (event) => this.eventHandle(event),\n bindings: this.bindings,\n loading: computed(() => this.root.loading()),\n setBound: (prop, value) => {\n const path = untracked(this.bindings)?.[prop];\n if (path) {\n this.state.set(path, value);\n } else if (isDevMode()) {\n console.warn(\n `[ngx-json-render] setBound(\"${prop}\"): prop has no $bindState/$bindItem binding`,\n );\n }\n },\n };\n\n // Typed as Injector for the peer range: see `confirmInjector` in\n // renderer.component.ts.\n protected readonly outletInjector: Injector = Injector.create({\n providers: [\n { provide: RENDER_CONTEXT, useValue: this.renderCtx },\n { provide: ELEMENT_KEY, useValue: this.elementKey },\n { provide: RENDER_PATH, useValue: this.path },\n ],\n parent: inject(Injector),\n });\n\n constructor() {\n // Warn (once) when this element is refused. Both reasons are silent\n // failures on screen — something the spec asked for is missing — so\n // neither should be silent in the console.\n let warnedRefusal = false;\n effect(() => {\n const reason = this.refusal();\n if (!reason || warnedRefusal) return;\n warnedRefusal = true;\n const path = untracked(this.path);\n if (reason === 'cycle') {\n console.warn(\n `[ngx-json-render] Cycle in the spec: ${describePath(path)}. \"${path.key}\" renders itself again without reading any deeper into state${path.scopePath === null ? '' : ` (still at \"${path.scopePath}\")`}, so it never ends. It is not rendered again; everything above it still is. A tree that recurses needs a repeat with a relative statePath, like {\"$item\": \"children\"}.`,\n );\n } else {\n console.warn(\n `[ngx-json-render] renderLimits.maxDepth (${untracked(this.root.limits)?.maxDepth}) reached at ${describePath(path)}. \"${path.key}\" and anything below it do not render.`,\n );\n }\n });\n\n // Dev mode: after a state write this element skipped, check that it was\n // right to. Resolving against the whole state has to give what the element\n // already shows; anything else is a read the spec analysis didn't name.\n if (inject(CHECK_SKIPPED_WRITES)) {\n let snapshotsSeen = -1;\n effect(() => {\n this.state.state();\n const shown = this.resolvedElement();\n const shownVisible = this.visible();\n const reads = this.stateReads();\n untracked(() => {\n const skipped = this.snapshotsTaken === snapshotsSeen;\n snapshotsSeen = this.snapshotsTaken;\n if (skipped && shown && reads !== null) {\n this.checkSkippedWrite(shown, shownVisible, reads);\n }\n });\n });\n }\n\n // Count the writes that touch a path this element is bound to. Only an\n // element with bindings listens, and it reads them when a write arrives,\n // so a binding that moves (a repeat item that shifts) is followed without\n // subscribing again.\n effect((onCleanup) => {\n if (!this.bindings()) return;\n const unsubscribe = this.state.subscribeChanges((changes) => {\n const paths = Object.values(untracked(this.bindings) ?? {});\n if (\n changes.some((change) =>\n paths.some((path) => touches(change.path, path)),\n )\n ) {\n this.boundWrites.update((count) => count + 1);\n }\n });\n onCleanup(unsubscribe);\n });\n\n // Warn (once per type) about unknown component types.\n const warnedTypes = new Set<string>();\n effect(() => {\n const el = this.rawElement();\n if (!el || this.entry() || warnedTypes.has(el.type)) return;\n warnedTypes.add(el.type);\n console.warn(`No renderer for component type: ${el.type}`);\n });\n\n // Warn about unknown / default slots when the registry carries metadata.\n effect(() => {\n const el = this.rawElement();\n const meta = this.entry();\n if (!el?.slots || !meta?.slots) return;\n const available = new Set(meta.slots);\n for (const slotName of Object.keys(el.slots)) {\n const warnKey = `${el.type}:${slotName}`;\n if (warnedSlots.has(warnKey)) continue;\n if (slotName === 'default') {\n warnedSlots.add(warnKey);\n console.warn(\n `[json-render] Component \"${el.type}\" uses slots.default. Use \"children\" for default slot content.`,\n );\n } else if (!available.has(slotName)) {\n warnedSlots.add(warnKey);\n console.warn(\n `[json-render] Unknown slot \"${slotName}\" on component \"${el.type}\". Available slots: ${meta.slots.join(', ')}`,\n );\n }\n }\n });\n\n // Watch effect: fire actions when watched state paths change.\n effect((onCleanup) => {\n // A refused element does not act, not just draw nothing. `watch` is the\n // one thing an element does without being on screen, so leaving it wired\n // would let the element past `maxDepth` — or the one that closes a cycle\n // — keep dispatching actions from behind a cap that was supposed to have\n // stopped it. Reading the signal here also unwires it if the refusal\n // arrives later, when the limits change.\n if (this.refusal()) return;\n const watchConfig = this.rawElement()?.watch;\n if (!watchConfig) return;\n const paths = Object.keys(watchConfig);\n if (paths.length === 0) return;\n\n const unsubscribe = this.state.subscribeChanges((changes) => {\n const changedPaths = new Set(changes.map((change) => change.path));\n\n void (async () => {\n for (const path of paths) {\n if (!changedPaths.has(path)) continue;\n const binding = watchConfig[path];\n if (binding) await this.dispatch(binding);\n }\n })().catch(reportActionError);\n });\n\n onCleanup(unsubscribe);\n });\n }\n\n /**\n * Resolve this element against the whole current state and warn, once per\n * element key, when that differs from what it shows after skipping a write.\n *\n * It only reports, and leaves the element as it is: correcting it here would\n * make dev mode render what production doesn't.\n */\n private checkSkippedWrite(\n shown: UIElement,\n shownVisible: boolean,\n reads: ReadonlySet<string>,\n ): void {\n const key = this.elementKey();\n const el = this.rawElement();\n if (!el || warnedSkippedWrites.has(key)) return;\n const ctx = this.liveResolutionCtx();\n let props: Record<string, unknown>;\n let visible: boolean;\n try {\n props = resolveElementProps(el.props ?? {}, ctx);\n visible = el.visible === undefined || evaluateVisibility(el.visible, ctx);\n } catch {\n return;\n }\n const differs = Object.keys({ ...props, ...shown.props }).filter(\n (prop) => !sameContent(props[prop], shown.props[prop]),\n );\n if (visible !== shownVisible) differs.push('visible');\n if (differs.length === 0) return;\n warnedSkippedWrites.add(key);\n const paths = reads.size > 0 ? [...reads].join(', ') : 'no state paths';\n console.warn(\n `[ngx-json-render] \"${key}\" did not resolve again after a state write, but resolving it now changes ${differs.join(', ')}. It resolves only when a state path it reads changes, and it reads ${paths}. Either a $computed function in it depends on something besides its args, or the renderer missed a read — please report the spec at https://github.com/shteynu/ngx-json-render/issues. This check runs in dev mode only.`,\n );\n }\n\n /**\n * Resolution context with a live state snapshot, so `$state` references in\n * later actions of a chain see mutations from earlier ones.\n */\n private liveResolutionCtx(): PropResolutionContext {\n return {\n ...untracked(this.resolutionCtx),\n stateModel: this.state.getSnapshot(),\n };\n }\n\n /**\n * Fire-and-forget entry point for event emission: dispatching is async, but\n * a template listener has nowhere to await it, so the failure must be\n * handled here rather than escaping as an unhandled rejection.\n */\n private fireEvent(eventName: string): void {\n this.emitEvent(eventName).catch(reportActionError);\n }\n\n private async emitEvent(eventName: string): Promise<void> {\n const binding = untracked(this.rawElement)?.on?.[eventName];\n if (binding) await this.dispatch(binding);\n }\n\n /**\n * Run an `on` or `watch` binding's actions in order. Params are resolved\n * per action, just before it runs, so a `$state` read in a later action of\n * the chain sees what an earlier one wrote.\n */\n private async dispatch(\n binding: ActionBinding | ActionBinding[],\n ): Promise<void> {\n for (const b of Array.isArray(binding) ? binding : [binding]) {\n if (!b.params) {\n await this.actions.execute(b);\n continue;\n }\n const liveCtx = this.liveResolutionCtx();\n const resolved: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(b.params)) {\n resolved[key] = resolveActionParam(val, liveCtx);\n }\n await this.actions.execute({ ...b, params: resolved });\n }\n }\n\n private eventHandle(eventName: string): EventHandle {\n const el = this.rawElement();\n const binding = el?.on?.[eventName];\n if (!binding) {\n return { emit: () => {}, shouldPreventDefault: false, bound: false };\n }\n const actionBindings = Array.isArray(binding) ? binding : [binding];\n return {\n emit: () => this.fireEvent(eventName),\n shouldPreventDefault: actionBindings.some((b) => b.preventDefault),\n bound: true,\n };\n }\n}\n","import type { Spec } from '@json-render/core';\nimport { autoFixSpec, validateSpec } from '@json-render/core';\nimport type {\n RenderLimits,\n SpecCatalog,\n SpecCheckIssue,\n} from './render-limits';\nimport {\n analyseSpecGraph,\n catalogIssues,\n cycleIssue,\n depthIssue,\n elementCountIssue,\n} from './render-limits';\n\n/**\n * How much a spec has to be trusted.\n *\n * - `off` — render whatever arrives. The default, and what every version\n * before this one did.\n * - `warn` — check the spec, apply the lossless fixes, report what is left,\n * render it anyway.\n * - `strict` — the same check, but an error means the spec does not render.\n *\n * This governs *reporting* and strict refusal. {@link RenderLimits} are a\n * separate axis: a limit the app set is enforced in every mode, including\n * `off`.\n */\nexport type SpecValidationMode = 'off' | 'warn' | 'strict';\n\n/** Everything {@link checkSpec} needs beyond the spec and the mode. */\nexport interface SpecCheckOptions {\n /** Caps on the spec's size, enforced whatever the mode. */\n readonly limits?: RenderLimits | null;\n /**\n * The catalog the spec was generated for. Given one, the check also reports\n * component types the catalog does not define, elements its spec schema\n * rejects, and props their component's schema rejects — the half of \"is\n * this spec renderable\" that structure alone cannot answer. A prop written\n * as an expression is not judged: it has no value until render time.\n */\n readonly catalog?: SpecCatalog | null;\n}\n\n/** What {@link checkSpec} found, and the spec that should render. */\nexport interface SpecCheck {\n /**\n * The spec to render: the input with lossless fixes applied, or the input\n * untouched when validation is off.\n */\n readonly spec: Spec | null;\n /** Structural, limit and catalog issues left after the fixes. */\n readonly issues: readonly SpecCheckIssue[];\n /** Descriptions of the fixes that were applied. */\n readonly fixes: readonly string[];\n /** Whether an issue of `error` severity survived. */\n readonly hasErrors: boolean;\n /**\n * Whether the spec is refused outright, in every mode, for breaching an\n * enforced limit. Distinct from {@link hasErrors}, which only stops a spec\n * under `strict`.\n */\n readonly blocked: boolean;\n}\n\nconst CLEAN: SpecCheck = {\n spec: null,\n issues: [],\n fixes: [],\n hasErrors: false,\n blocked: false,\n};\n\n/**\n * Check a spec the way `validate` and `renderLimits` ask for.\n *\n * Only lossless fixes are applied — `visible`, `on` and `repeat` that a model\n * put inside `props`, which the renderer would otherwise ignore, moved back\n * where they belong. The lossy ones prune content, and core's own guidance is\n * to re-prompt rather than accept that; a renderer that silently deleted\n * elements would be the worse failure.\n *\n * Note what is *not* here: cycles are broken as the tree renders, whatever\n * this returns, because a spec that never stops rendering is a crash rather\n * than an opinion about quality. This reports them so an app can see them.\n */\nexport function checkSpec(\n spec: Spec | null,\n mode: SpecValidationMode,\n options: SpecCheckOptions = {},\n): SpecCheck {\n if (!spec) return CLEAN;\n\n const limits = options.limits ?? null;\n const wantsStructure = mode !== 'off';\n // `maxRepeatItems` caps a live state array, which no amount of reading the\n // spec can predict — it is enforced as the repeat expands, not here.\n const maxElements = limits?.maxElements;\n const maxDepth = limits?.maxDepth;\n if (!wantsStructure && maxElements === undefined && maxDepth === undefined) {\n return { spec, issues: [], fixes: [], hasErrors: false, blocked: false };\n }\n\n // The order below is the point of this function, not an accident of it.\n //\n // Core's `validateSpec` walks the element tree by recursion, so the specs\n // that most need a limit are the ones that would overflow the stack proving\n // they exceed it. Each cheap, non-recursive cap therefore runs first and can\n // stop the expensive check from being attempted at all: count, then depth —\n // measured by a walk of our own that uses an explicit stack — and only then\n // the structural pass.\n //\n // `autoFixSpec` only relocates fields inside `props` and never touches\n // `children` or `slots`, so measuring the graph before fixing it measures\n // the same graph.\n\n if (maxElements !== undefined) {\n const count = Object.keys(spec.elements ?? {}).length;\n if (count > maxElements) {\n const issue = elementCountIssue(count, maxElements);\n return {\n spec,\n issues: [issue],\n fixes: [],\n hasErrors: true,\n blocked: true,\n };\n }\n }\n\n const issues: SpecCheckIssue[] = [];\n let tooDeep = false;\n if (wantsStructure || maxDepth !== undefined) {\n const graph = analyseSpecGraph(spec);\n if (maxDepth !== undefined && graph.depth > maxDepth) {\n tooDeep = true;\n issues.push(depthIssue(graph.depth, maxDepth));\n }\n if (wantsStructure) {\n for (const key of graph.cycles) issues.push(cycleIssue(key));\n }\n }\n\n // A spec past its depth cap is not handed to the recursive checks. The cap\n // is the finding worth having, and it renders truncated either way.\n const fixed =\n wantsStructure && !tooDeep\n ? autoFixSpec(spec, { lossy: false })\n : { spec, fixes: [] as string[] };\n if (wantsStructure && !tooDeep) {\n issues.push(...validateSpec(fixed.spec).issues);\n if (options.catalog) {\n issues.push(...catalogIssues(fixed.spec, options.catalog));\n }\n }\n\n return {\n spec: fixed.spec,\n issues,\n fixes: fixed.fixes,\n hasErrors: issues.some((issue) => issue.severity === 'error'),\n blocked: false,\n };\n}\n\n/**\n * Render issues as one indented block, errors and warnings alike.\n *\n * Core's `formatSpecIssues` drops warnings and only accepts core's own issue\n * codes, so it cannot describe what this package reports. Use this instead\n * when showing `issues()` to a developer.\n */\nexport function formatSpecCheckIssues(\n issues: readonly SpecCheckIssue[],\n): string {\n return issues\n .map(\n (issue) =>\n ` ${issue.severity === 'error' ? 'error ' : 'warning'} ${\n issue.elementKey ? `[${issue.elementKey}] ` : ''\n }${issue.message}`,\n )\n .join('\\n');\n}\n\n/**\n * Report a check to the console: fixes as information, issues at the severity\n * the outcome gives them. A spec that will not render — refused by a limit,\n * or by `strict` — is reported as an error, because something the developer\n * asked for is now missing from the screen; one that renders anyway is a\n * warning.\n */\nexport function reportSpecCheck(\n check: SpecCheck,\n mode: SpecValidationMode,\n): void {\n if (check.fixes.length > 0) {\n console.info(\n `[ngx-json-render] Fixed ${check.fixes.length} spec issue(s) before rendering:\\n` +\n check.fixes.map((fix) => ` - ${fix}`).join('\\n'),\n );\n }\n\n if (check.issues.length === 0) return;\n\n const report = `[ngx-json-render] Spec validation:\\n${formatSpecCheckIssues(check.issues)}`;\n if (check.blocked) {\n console.error(\n `${report}\\nNothing is rendered: the spec is over a renderLimits cap.`,\n );\n } else if (mode === 'strict' && check.hasErrors) {\n console.error(`${report}\\nNothing is rendered: validate=\"strict\".`);\n } else {\n console.warn(report);\n }\n}\n","import { NgComponentOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n Injector,\n type Type,\n computed,\n effect,\n inject,\n input,\n output,\n} from '@angular/core';\nimport type {\n ActionHandler,\n ComputedFunction,\n DirectiveDefinition,\n Spec,\n StateModel,\n StateStore,\n ValidationFunction,\n} from '@json-render/core';\nimport { createDirectiveRegistry } from '@json-render/core';\nimport { JsonRenderActionsService } from './actions.service';\nimport { JrConfirmDialog } from './confirm-dialog.component';\nimport {\n CONFIRM_CONTEXT,\n type ConfirmContext,\n JR_CONFIRM_DIALOG,\n} from './confirm-tokens';\nimport { JrElement } from './element.component';\nimport type { RenderLimits, SpecCatalog } from './render-limits';\nimport { JsonRenderRootContext } from './root-context';\nimport {\n type SpecValidationMode,\n checkSpec,\n reportSpecCheck,\n} from './spec-validation';\nimport { JsonRenderStateService } from './state.service';\nimport type { ComponentRegistry, RegistryEntry, StateChange } from './types';\nimport { JsonRenderValidationService } from './validation.service';\n\n/**\n * Renders a json-render {@link Spec} using a registry of Angular components.\n *\n * The renderer owns the state store, action dispatcher, and validation state\n * of its subtree (all injectable from catalog components). Pass an external\n * {@link StateStore} via `store` for controlled mode or to share state across\n * renderers.\n *\n * @example\n * ```html\n * <json-render\n * [spec]=\"spec()\"\n * [registry]=\"registry\"\n * [handlers]=\"handlers\"\n * [loading]=\"isStreaming()\"\n * (stateChange)=\"onStateChange($event)\"\n * />\n * ```\n */\n@Component({\n selector: 'json-render',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [JrElement, JrConfirmDialog, NgComponentOutlet],\n providers: [\n JsonRenderRootContext,\n JsonRenderStateService,\n JsonRenderValidationService,\n JsonRenderActionsService,\n ],\n styles: `:host { display: contents; }`,\n template: `\n @if (rootKey(); as key) {\n <jr-element [elementKey]=\"key\" />\n }\n @if (pendingConfirm(); as confirm) {\n @if (customDialog; as dialog) {\n <ng-container\n *ngComponentOutlet=\"dialog; injector: confirmInjector() ?? undefined\"\n />\n } @else {\n <jr-confirm-dialog\n [config]=\"confirm\"\n (confirmed)=\"actions.confirm()\"\n (cancelled)=\"actions.cancel()\"\n />\n }\n }\n `,\n})\nexport class JsonRenderer {\n /** The UI spec to render (may be partial while streaming). */\n readonly spec = input.required<Spec | null>();\n /** Component registry mapping catalog type names to Angular components. */\n readonly registry = input.required<ComponentRegistry>();\n /** Whether the spec is currently loading/streaming. */\n readonly loading = input(false);\n /** Fallback component for unknown types. */\n readonly fallback = input<Type<unknown> | RegistryEntry | null>(null);\n /**\n * Whether to check the spec's structure before rendering it, and what to do\n * about what turns up. Off by default.\n *\n * `'warn'` reports the issues and renders anyway; `'strict'` renders nothing\n * when the spec has errors. Both first apply the lossless fixes — `visible`,\n * `on` and `repeat` misplaced inside `props` are moved back to the element,\n * where they take effect instead of being ignored.\n *\n * The check is skipped while `loading` is true: a spec that is still\n * arriving is expected to reference children that have not streamed in yet.\n */\n readonly validate = input<SpecValidationMode>('off');\n\n /**\n * Caps on what the spec may cost the browser: `maxElements`, `maxDepth` and\n * `maxRepeatItems`. Unset by default, and each field is independently\n * optional.\n *\n * Unlike `validate`, these are enforced in every mode — a number the app\n * chose is a control, not a report. A spec over `maxElements` renders\n * nothing; `maxDepth` and `maxRepeatItems` truncate where they are hit.\n * They apply while `loading` too: a partial spec is a subset of the\n * finished one, so a cap can only ever fire early, never falsely.\n */\n readonly renderLimits = input<RenderLimits | null>(null);\n\n /**\n * The catalog the spec was generated for. Given one, `validate` also checks\n * what structure alone cannot: that every `type` is a component the catalog\n * defines, that every element has the shape the catalog's spec schema asks\n * for — a `children` array, even on a leaf — and that its props match its\n * component's schema. A prop written as an expression — `$state`,\n * `$bindState`, `$template`, a directive — has no value until render time,\n * so it is not checked.\n *\n * The check is read only when `validate` is on, and — like the rest of\n * it — skipped while `loading`.\n *\n * While `loading`, the catalog also gates mounting, whatever `validate` is:\n * an element whose props do not yet pass its component's schema shows its\n * registry entry's `fallback`, or nothing, instead of a component with half\n * its props. Once an element has mounted it stays mounted, and when\n * `loading` ends every element mounts.\n */\n readonly catalog = input<SpecCatalog | null>(null);\n\n /**\n * Initial state model (uncontrolled mode). Defaults to `spec.state`.\n * Ignored when `store` is provided.\n */\n readonly state = input<StateModel | undefined>(undefined);\n /** External state store (controlled mode). */\n readonly store = input<StateStore | null>(null);\n\n /** Action handlers by action name. */\n readonly handlers = input<Record<string, ActionHandler> | undefined>(\n undefined,\n );\n /** Catch-all action handler for actions without a dedicated handler. */\n readonly onAction = input<\n ((name: string, params?: Record<string, unknown>) => unknown) | null\n >(null);\n /** Navigation function used by `onSuccess: { navigate }` handlers. */\n readonly navigate = input<((path: string) => void) | null>(null);\n\n /** Custom validation functions. */\n readonly validationFunctions = input<\n Record<string, ValidationFunction> | undefined\n >(undefined);\n /** Named functions for `$computed` expressions in props. */\n readonly functions = input<Record<string, ComputedFunction> | undefined>(\n undefined,\n );\n /** Custom directives for user-defined `$`-prefixed dynamic values. */\n readonly directives = input<DirectiveDefinition<any>[] | undefined>(\n undefined,\n );\n\n /** Emits state changes in uncontrolled mode. */\n readonly stateChange = output<StateChange[]>();\n\n /** The state store of this renderer (also injectable in the subtree). */\n readonly stateStore: JsonRenderStateService;\n /** The action dispatcher of this renderer. */\n protected readonly actions: JsonRenderActionsService;\n\n /**\n * The spec as checked, and what the check found. While `loading`, the mode\n * is forced off: the spec is still arriving, and the missing children it\n * refers to are the normal state of a stream, not a defect.\n */\n private readonly checked = computed(() =>\n checkSpec(this.spec(), this.loading() ? 'off' : this.validate(), {\n limits: this.renderLimits(),\n catalog: this.catalog(),\n }),\n );\n\n constructor() {\n const root = inject(JsonRenderRootContext);\n // The fixed spec, not the input: a `visible` the check moved out of\n // `props` has to be the one the tree renders, or the fix is cosmetic.\n root.spec = computed(() => this.checked().spec);\n root.registry = this.registry;\n root.loading = this.loading;\n root.fallback = this.fallback;\n root.limits = this.renderLimits;\n root.catalog = this.catalog;\n root.store = this.store;\n root.initialState = computed(\n () => this.state() ?? this.spec()?.state ?? {},\n );\n root.handlers = this.handlers;\n root.onAction = this.onAction;\n root.navigate = this.navigate;\n root.validationFunctions = this.validationFunctions;\n root.functions = this.functions;\n root.directiveRegistry = computed(() => {\n const definitions = this.directives();\n return definitions ? createDirectiveRegistry(definitions) : undefined;\n });\n root.emitStateChange = (changes) => this.stateChange.emit(changes);\n\n // Instantiate the subtree services now that the root context is wired.\n this.stateStore = inject(JsonRenderStateService);\n inject(JsonRenderValidationService);\n this.actions = inject(JsonRenderActionsService);\n\n // Reports once per distinct check rather than once per render: `checked`\n // only recomputes when the spec, the mode, the limits or the loading flag\n // change. Silent while loading — a limit can fire on a spec that is still\n // arriving, and reporting it on every patch would bury the one report\n // that describes the finished spec.\n effect(() => {\n if (this.loading()) return;\n reportSpecCheck(this.checked(), this.validate());\n });\n }\n\n protected readonly rootKey = computed(() => {\n const checked = this.checked();\n // A spec over an enforced cap does not render in any mode. Whether to\n // check was the app's decision; once it has made it, honouring the answer\n // is not also `validate`'s to decide.\n if (checked.blocked) return null;\n // A spec whose errors survived the fixes does not render under `strict`.\n // Reporting it and drawing half of it anyway is the behaviour the mode\n // exists to refuse.\n if (this.validate() === 'strict' && checked.hasErrors) return null;\n const spec = checked.spec;\n return spec?.root && spec.elements?.[spec.root] ? spec.root : null;\n });\n\n protected readonly pendingConfirm = computed(\n () => this.actions.pendingConfirmation()?.action.confirm ?? null,\n );\n\n /**\n * The app's own dialog, if it provided one. Read once: which component\n * answers a confirmation is an application decision, not something that\n * changes between two confirmations.\n */\n protected readonly customDialog = inject(JR_CONFIRM_DIALOG, {\n optional: true,\n });\n private readonly injector = inject(Injector);\n\n /**\n * A replacement dialog takes no inputs and emits no outputs — it injects\n * everything it needs, the way catalog components do. That keeps the seam\n * one token wide instead of a component contract the renderer would have to\n * bind to.\n */\n // Typed as Injector, not left to inference: Angular 20+ infers its\n // `DestroyableInjector`, which Angular 19's typings do not export, and the\n // inferred type would land in the published declarations.\n protected readonly confirmInjector = computed((): Injector | null => {\n const config = this.pendingConfirm();\n if (!config) return null;\n const context: ConfirmContext = {\n config,\n confirm: () => this.actions.confirm(),\n cancel: () => this.actions.cancel(),\n };\n return Injector.create({\n providers: [{ provide: CONFIRM_CONTEXT, useValue: context }],\n parent: this.injector,\n });\n });\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n forwardRef,\n input,\n} from '@angular/core';\nimport { REPEAT_SCOPE } from './tokens';\nimport type { RepeatScope } from './types';\n\n/**\n * Provides the repeat scope (item, index, absolute base path) to the elements\n * rendered inside a `repeat` block.\n *\n * @internal Used by `<jr-children>`; not intended for direct use.\n */\n@Component({\n selector: 'jr-repeat-scope',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n { provide: REPEAT_SCOPE, useExisting: forwardRef(() => JrRepeatScope) },\n ],\n styles: `:host { display: contents; }`,\n template: '<ng-content />',\n})\nexport class JrRepeatScope implements RepeatScope {\n readonly item = input.required<unknown>();\n readonly index = input.required<number>();\n readonly basePath = input.required<string>();\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n inject,\n input,\n untracked,\n} from '@angular/core';\nimport {\n getByPath,\n resolveRepeatItemStatePath,\n resolveRepeatStatePath,\n} from '@json-render/core';\nimport { JrElement } from './element.component';\nimport { JrRepeatScope } from './repeat-scope.component';\nimport { JsonRenderRootContext } from './root-context';\nimport { JsonRenderStateService } from './state.service';\nimport { REPEAT_SCOPE, injectRenderContext } from './tokens';\n\n/**\n * Renders the children of the current element. Place it inside a catalog\n * component's template where nested content should appear — like a\n * `<router-outlet>` for the spec tree.\n *\n * - Default (no `slot`): renders `element.children`, honoring the element's\n * `repeat` field (one pass per item of the referenced state array, with the\n * proper repeat scope for `$item` / `$index` / `$bindItem` expressions).\n * - With `slot`: renders the element keys of `element.slots[slot]`.\n *\n * @example\n * ```html\n * <div class=\"card\">\n * <h3>{{ ctx.props().title }}</h3>\n * <jr-children />\n * </div>\n * ```\n */\n@Component({\n selector: 'jr-children',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [JrElement, JrRepeatScope],\n styles: `:host { display: contents; }`,\n template: `\n @if (repeat()) {\n @for (item of repeatItems(); track trackItem($index, item)) {\n <jr-repeat-scope\n [item]=\"item\"\n [index]=\"$index\"\n [basePath]=\"itemPath($index)\"\n >\n @for (key of childKeys(); track key) {\n <jr-element [elementKey]=\"key\" />\n }\n </jr-repeat-scope>\n }\n } @else {\n @for (key of childKeys(); track key) {\n <jr-element [elementKey]=\"key\" />\n }\n }\n `,\n})\nexport class JrChildren {\n /** Named slot to render instead of the default children. */\n readonly slot = input<string | null>(null);\n\n private readonly ctx = injectRenderContext();\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n // The repeat scope enclosing the host element (scopes created by this\n // element's own repeat live below, in the template).\n private readonly parentScope = inject(REPEAT_SCOPE, { optional: true });\n\n protected readonly childKeys = computed<string[]>(() => {\n const el = this.ctx.element();\n if (!el) return [];\n const slot = this.slot();\n if (slot) return el.slots?.[slot] ?? [];\n return el.children ?? [];\n });\n\n protected readonly repeat = computed(() => {\n if (this.slot()) return undefined;\n return this.ctx.element()?.repeat;\n });\n\n private readonly repeatBasePath = computed<string | undefined>(() => {\n const rep = this.repeat();\n if (!rep) return undefined;\n const resolved = resolveRepeatStatePath(\n rep.statePath,\n this.parentScope?.basePath(),\n );\n if (resolved === undefined) {\n console.warn(\n '[ngx-json-render] $item in repeat.statePath used outside of a repeat scope',\n );\n }\n return resolved;\n });\n\n /** Every item the repeat's state array holds, before any cap. */\n private readonly allRepeatItems = computed<unknown[]>(() => {\n const basePath = this.repeatBasePath();\n if (basePath === undefined) return [];\n return (\n (getByPath(this.state.state(), basePath) as unknown[] | undefined) ?? []\n );\n });\n\n /**\n * The items this repeat actually renders.\n *\n * `repeat` iterates a state array the spec may itself have supplied, which\n * is the one place a spec sizes the render tree out of data rather than out\n * of its own structure — so the cap has to be applied here, as it expands,\n * rather than anywhere a spec can be inspected up front.\n */\n protected readonly repeatItems = computed<unknown[]>(() => {\n const items = this.allRepeatItems();\n const max = this.root.limits()?.maxRepeatItems;\n return max !== undefined && items.length > max\n ? items.slice(0, max)\n : items;\n });\n\n constructor() {\n // Warn (once) when the cap holds items back. Reading the count only after\n // the two cheap guards keeps the effect from tracking the state array at\n // all once there is nothing left to say.\n let warnedRepeatCap = false;\n effect(() => {\n const max = this.root.limits()?.maxRepeatItems;\n if (max === undefined || warnedRepeatCap) return;\n const total = this.allRepeatItems().length;\n if (total <= max) return;\n warnedRepeatCap = true;\n console.warn(\n `[ngx-json-render] renderLimits.maxRepeatItems (${max}) reached: \"${untracked(this.repeatBasePath)}\" holds ${total} items, so ${total - max} of them do not render.`,\n );\n });\n\n // Warn (once per key) about children referencing missing elements.\n const warned = new Set<string>();\n effect(() => {\n if (this.root.loading()) return;\n const spec = this.root.spec();\n if (!spec) return;\n for (const key of this.childKeys()) {\n if (!spec.elements?.[key] && !warned.has(key)) {\n warned.add(key);\n console.warn(\n `[json-render] Missing element \"${key}\" referenced as child of \"${untracked(this.ctx.element)?.type}\". This element will not render.`,\n );\n }\n }\n });\n }\n\n protected itemPath(index: number): string {\n return resolveRepeatItemStatePath(this.repeatBasePath()!, index);\n }\n\n protected trackItem(index: number, item: unknown): unknown {\n const rep = untracked(this.repeat);\n if (rep?.key && typeof item === 'object' && item !== null) {\n return (item as Record<string, unknown>)[rep.key] ?? index;\n }\n return index;\n }\n}\n","import type { Type } from '@angular/core';\nimport type { Catalog, StateStore } from '@json-render/core';\nimport { flattenToPointers } from './pointer';\nimport type {\n Actions,\n CatalogHasActions,\n ComponentRegistry,\n Components,\n RegistryEntry,\n SetState,\n StateModel,\n} from './types';\n\n/**\n * Result returned by {@link defineRegistry}.\n */\nexport interface DefineRegistryResult {\n /** Component registry for `<json-render [registry]=\"...\">`. */\n registry: ComponentRegistry;\n /**\n * Create renderer-compatible handlers from the catalog actions.\n * Accepts getter functions so handlers always read the latest\n * state/setState.\n */\n handlers: (\n getSetState: () => SetState | undefined,\n getState: () => StateModel,\n ) => Record<string, (params: Record<string, unknown>) => Promise<void>>;\n /**\n * Execute an action by name imperatively\n * (for use outside the renderer tree, e.g. initial state loading).\n */\n executeAction: (\n actionName: string,\n params: Record<string, unknown> | undefined,\n setState: SetState,\n state?: StateModel,\n ) => Promise<void>;\n}\n\n/**\n * Options for defineRegistry.\n *\n * When the catalog declares actions, the `actions` field is required.\n * When the catalog has no actions (or `actions: {}`), the field is optional.\n */\ntype DefineRegistryOptions<C extends Catalog> = {\n components?: Components<C>;\n} & (CatalogHasActions<C> extends true\n ? { actions: Actions<C> }\n : { actions?: Actions<C> });\n\n/** @internal */\ntype DefineRegistryActionFn = (\n params: Record<string, unknown> | undefined,\n setState: SetState,\n state: StateModel,\n) => Promise<void>;\n\n/**\n * Create a registry from a catalog with components and/or actions.\n *\n * Component keys are type-checked against the catalog, and slot metadata from\n * the catalog is carried into the registry for dev-mode slot warnings.\n *\n * @example\n * ```ts\n * const { registry, handlers } = defineRegistry(catalog, {\n * components: { Card: CardComponent, Button: ButtonComponent },\n * actions: {\n * refresh: async (params, setState) => {\n * setState((prev) => ({ ...prev, refreshedAt: Date.now() }));\n * },\n * },\n * });\n * ```\n */\nexport function defineRegistry<C extends Catalog>(\n catalog: C,\n options: DefineRegistryOptions<C>,\n): DefineRegistryResult {\n const catalogComponents = (\n catalog as unknown as {\n data?: { components?: Record<string, { slots?: string[] }> };\n }\n ).data?.components;\n\n // Build the component registry, attaching slot metadata from the catalog.\n const registry: ComponentRegistry = {};\n if (options.components) {\n for (const [name, value] of Object.entries(options.components) as Array<\n [string, Type<unknown> | Pick<RegistryEntry, 'component' | 'fallback'>]\n >) {\n const entry: RegistryEntry =\n typeof value === 'function'\n ? { component: value }\n : {\n component: value.component,\n ...(value.fallback ? { fallback: value.fallback } : {}),\n };\n const slots = catalogComponents?.[name]?.slots;\n if (slots) entry.slots = slots;\n registry[name] = entry;\n }\n }\n\n // Build action helpers.\n const actionMap = options.actions\n ? (Object.entries(options.actions) as Array<\n [string, DefineRegistryActionFn]\n >)\n : [];\n\n const handlers = (\n getSetState: () => SetState | undefined,\n getState: () => StateModel,\n ): Record<string, (params: Record<string, unknown>) => Promise<void>> => {\n const result: Record<\n string,\n (params: Record<string, unknown>) => Promise<void>\n > = {};\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\n const executeAction = async (\n actionName: string,\n params: Record<string, unknown> | undefined,\n setState: SetState,\n state: StateModel = {},\n ): Promise<void> => {\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\n return { registry, handlers, executeAction };\n}\n\n/**\n * Build a {@link SetState} (whole-state updater) on top of a path-based\n * store. The updater's result is diffed against the previous state and only\n * changed leaves are written, preserving fine-grained reactivity.\n *\n * Works with both a core {@link StateStore} and the renderer's injected\n * `JsonRenderStateService`.\n */\nexport function createStoreSetState(\n store: Pick<StateStore, 'getSnapshot' | 'update'>,\n): SetState {\n return (updater) => {\n const prev = store.getSnapshot();\n const next = updater(prev);\n if (next === prev) return;\n const prevFlat = flattenToPointers(prev);\n const nextFlat = flattenToPointers(next);\n const allKeys = new Set([\n ...Object.keys(prevFlat),\n ...Object.keys(nextFlat),\n ]);\n const updates: Record<string, unknown> = {};\n for (const key of allKeys) {\n if (prevFlat[key] !== nextFlat[key]) {\n updates[key] = key in nextFlat ? nextFlat[key] : undefined;\n }\n }\n if (Object.keys(updates).length > 0) {\n store.update(updates);\n }\n };\n}\n","import type { JsonPatch, Spec, UIElement } from '@json-render/core';\nimport {\n addByPath,\n getByPath,\n removeByPath,\n setByPath,\n} from '@json-render/core';\n\n/**\n * Writes a value at a path inside an already-private object. `addByPath` and\n * `setByPath` differ only on arrays — RFC 6902 `add` splices, `replace`\n * overwrites — which is why the op picks the writer rather than the path\n * routing below.\n */\ntype PathWriter = (\n obj: Record<string, unknown>,\n path: string,\n value: unknown,\n) => void;\n\n/**\n * Split a JSON Pointer into its segments, undoing RFC 6901's escapes.\n *\n * `@json-render/core` parses pointers the same way for `setByPath` and\n * friends but does not export the helper, so {@link copyAlongPath} carries\n * its own copy. The two must agree on where a path descends, or a write would\n * land on a node that was never copied.\n */\nfunction parseJsonPointer(path: string): string[] {\n const raw = path.startsWith('/') ? path.slice(1).split('/') : path.split('/');\n return raw.map((token) => token.replace(/~1/g, '/').replace(/~0/g, '~'));\n}\n\n/**\n * Replace every node `path` descends through with a shallow copy of itself.\n *\n * `root` must already be private to the caller. Afterwards a mutating write\n * along that same path — `setByPath`, `addByPath`, `removeByPath` — only ever\n * touches nodes nobody else is holding, while everything off the path stays\n * shared. That keeps a patch proportional to the depth of its path rather than\n * to the size of the spec, which matters when a stream applies hundreds of\n * them.\n *\n * Descent stops at anything that is not an object: the writers overwrite such\n * a node outright, and one that does not exist yet is created fresh, so in\n * neither case is there anything of the caller's left to protect.\n */\nfunction copyAlongPath(root: Record<string, unknown>, path: string): void {\n const segments = parseJsonPointer(path);\n let current = root;\n\n // The final segment is written, not descended into, so it needs no copy.\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i];\n const child = current[segment];\n if (child === null || typeof child !== 'object') return;\n\n const copy = Array.isArray(child)\n ? [...child]\n : { ...(child as Record<string, unknown>) };\n current[segment] = copy;\n current = copy as unknown as Record<string, unknown>;\n }\n}\n\n/**\n * Write a value at a spec path, copying every node on the way so the caller's\n * previous spec keeps its own contents.\n */\nfunction writeSpecValue(\n newSpec: Spec,\n path: string,\n value: unknown,\n write: PathWriter,\n): void {\n if (path === '/root') {\n newSpec.root = value as string;\n return;\n }\n\n if (path === '/state') {\n newSpec.state = value as Record<string, unknown>;\n return;\n }\n\n if (path.startsWith('/state/')) {\n if (!newSpec.state) newSpec.state = {};\n const statePath = path.slice('/state'.length); // e.g. \"/posts\"\n const state = newSpec.state as Record<string, unknown>;\n copyAlongPath(state, statePath);\n write(state, statePath, value);\n return;\n }\n\n if (path.startsWith('/elements/')) {\n const pathParts = path.slice('/elements/'.length).split('/');\n const elementKey = pathParts[0];\n if (!elementKey) return;\n\n if (pathParts.length === 1) {\n newSpec.elements[elementKey] = value as UIElement;\n return;\n }\n\n // A prop path whose element is not there is dropped rather than\n // auto-created: the generic writers would happily conjure an element with\n // props and no `type`, which renders as nothing and warns about an unknown\n // component. A malformed patch should lose its own write, not add a broken\n // element to the tree.\n const element = newSpec.elements[elementKey];\n if (!element) return;\n\n const propPath = '/' + pathParts.slice(1).join('/');\n const newElement = { ...element } as unknown as Record<string, unknown>;\n copyAlongPath(newElement, propPath);\n write(newElement, propPath, value);\n newSpec.elements[elementKey] = newElement as unknown as UIElement;\n return;\n }\n\n // Any other top-level path is applied verbatim. The spec grammar is\n // upstream's and grows without this renderer: dropping what we do not\n // recognise would silently discard a field a newer `@json-render/core`\n // understands.\n const root = newSpec as unknown as Record<string, unknown>;\n copyAlongPath(root, path);\n write(root, path, value);\n}\n\n/** Remove the value at a spec path, with the same copy-on-write discipline. */\nfunction removeSpecValue(newSpec: Spec, path: string): void {\n if (path === '/state') {\n delete newSpec.state;\n return;\n }\n\n if (path.startsWith('/state/') && newSpec.state) {\n const statePath = path.slice('/state'.length);\n const state = newSpec.state as Record<string, unknown>;\n copyAlongPath(state, statePath);\n removeByPath(state, statePath);\n return;\n }\n\n if (path.startsWith('/elements/')) {\n const pathParts = path.slice('/elements/'.length).split('/');\n const elementKey = pathParts[0];\n if (!elementKey) return;\n\n if (pathParts.length === 1) {\n const { [elementKey]: _removed, ...rest } = newSpec.elements;\n newSpec.elements = rest;\n return;\n }\n\n const element = newSpec.elements[elementKey];\n if (!element) return;\n\n const propPath = '/' + pathParts.slice(1).join('/');\n const newElement = { ...element } as unknown as Record<string, unknown>;\n copyAlongPath(newElement, propPath);\n removeByPath(newElement, propPath);\n newSpec.elements[elementKey] = newElement as unknown as UIElement;\n return;\n }\n\n const root = newSpec as unknown as Record<string, unknown>;\n copyAlongPath(root, path);\n removeByPath(root, path);\n}\n\n/**\n * Apply an RFC 6902 JSON patch to a spec, returning a new spec object and\n * sharing every subtree the patch did not touch.\n *\n * This is the only patch engine in the package: `injectUIStream`,\n * `injectChatUI` and `buildSpecFromParts` all route through it, so the same\n * stream produces the same spec whichever one an app reached for. The write\n * primitives come from `@json-render/core`, so `add` splices into an array\n * where `replace` overwrites, exactly as the other renderers do.\n *\n * One deliberate deviation from RFC 6902: a failing `test` op is a no-op\n * rather than an abort. These patches come off a model's output, where the\n * established behaviour — see the line parser — is to drop what does not make\n * sense and keep rendering rather than kill a generation mid-flight.\n */\nexport function applyPatch(spec: Spec, patch: JsonPatch): Spec {\n const newSpec = {\n ...spec,\n elements: { ...spec.elements },\n ...(spec.state ? { state: { ...spec.state } } : {}),\n };\n\n switch (patch.op) {\n case 'add': {\n writeSpecValue(newSpec, patch.path, patch.value, addByPath);\n break;\n }\n case 'replace': {\n writeSpecValue(newSpec, patch.path, patch.value, setByPath);\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 = getByPath(newSpec, patch.from);\n removeSpecValue(newSpec, patch.from);\n writeSpecValue(newSpec, patch.path, moveValue, addByPath);\n break;\n }\n case 'copy': {\n if (!patch.from) break;\n // RFC 6902 copies the *value*. Handing over the live reference instead\n // aliases source and target, and a `path` that descends into its own\n // `from` then makes the spec self-referential — which the next request\n // discovers when it tries to serialise it into the body.\n const copyValue = structuredClone(getByPath(newSpec, patch.from));\n writeSpecValue(newSpec, patch.path, copyValue, addByPath);\n break;\n }\n case 'test': {\n break;\n }\n }\n\n return newSpec;\n}\n","import type { JsonPatch } from '@json-render/core';\n\n/** Token usage as the AI SDK reports it in its usage line. */\nexport interface StreamObserverUsage {\n promptTokens: number;\n completionTokens: number;\n totalTokens: number;\n}\n\n/**\n * Hooks into every `injectUIStream` and `injectChatUI` generation in the app,\n * the counterpart of `registerActionObserver` in `@json-render/core`. This is\n * what `ngx-json-render/devtools` fills its Stream tab from, so it is private\n * API: the `ɵ` prefix says it may change in any release.\n */\nexport interface StreamObserver {\n /** A generation started. */\n onStart?(): void;\n /** A patch was applied to the spec, in arrival order. */\n onPatch?(patch: JsonPatch): void;\n /** A line of prose arrived (`injectChatUI` only). */\n onText?(text: string): void;\n /** The usage line arrived (`injectUIStream` only). */\n onUsage?(usage: StreamObserverUsage): void;\n /** The generation ended; `ok` is false on an error, true on a stop. */\n onEnd?(ok: boolean): void;\n}\n\nconst observers = new Set<StreamObserver>();\n\n/**\n * Register an observer for every stream in the app. Returns the function that\n * removes it. Private API for `ngx-json-render/devtools`.\n */\nexport function ɵregisterStreamObserver(observer: StreamObserver): () => void {\n observers.add(observer);\n return () => {\n observers.delete(observer);\n };\n}\n\n/**\n * Tell every observer. An observer that throws is a devtools bug, and it must\n * not become a failed generation in the app it is inspecting.\n */\nexport function notifyStreamObservers<K extends keyof StreamObserver>(\n event: K,\n ...args: Parameters<NonNullable<StreamObserver[K]>>\n): void {\n if (observers.size === 0) return;\n for (const observer of observers) {\n try {\n (observer[event] as ((...a: typeof args) => void) | undefined)?.(...args);\n } catch (error) {\n console.error('[ngx-json-render] A stream observer threw:', error);\n }\n }\n}\n\n/**\n * The start and end of one hook's generations, as observers see them.\n *\n * A superseded or stopped request only settles once its abort has gone\n * through, after the next generation may already have started. Reporting its\n * end from there would close the new generation instead of the old one, so a\n * generation ends here the moment it is superseded or stopped, and its own\n * late end is dropped.\n */\nexport function createObservedRuns(): {\n /** Start a generation, ending any still open. Returns its end. */\n start: () => (ok: boolean) => void;\n /** End the open generation, if any, as a stop. */\n stop: () => void;\n} {\n let endOpen: (() => void) | null = null;\n return {\n start() {\n endOpen?.();\n let ended = false;\n const end = (ok: boolean) => {\n if (ended) return;\n ended = true;\n if (endOpen === stop) endOpen = null;\n notifyStreamObservers('onEnd', ok);\n };\n const stop = () => end(true);\n endOpen = stop;\n notifyStreamObservers('onStart');\n return end;\n },\n stop() {\n endOpen?.();\n },\n };\n}\n","import { type Signal, computed } from '@angular/core';\nimport type {\n FlatElement,\n Spec,\n SpecDataPart,\n UIElement,\n} from '@json-render/core';\nimport { SPEC_DATA_PART_TYPE, nestedToFlat } from '@json-render/core';\nimport { applyPatch } from './patch';\n\n/**\n * Convert a flat element list to a Spec.\n * Input elements use key/parentKey to establish identity and relationships.\n * Output spec uses the map-based format where key is the map entry key\n * and parent-child relationships are expressed through children arrays.\n */\nexport function flatToTree(elements: FlatElement[]): Spec {\n // The map is what gives every element its children array, so the second\n // pass can push into one without checking for it.\n const elementMap: Record<string, UIElement & { children: string[] }> = {};\n let root = '';\n\n // First pass: add all elements to map\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\n // Second pass: build parent-child relationships\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n\n return { root, elements: elementMap };\n}\n\n/**\n * A single part from the AI SDK's `message.parts` array. This is a minimal\n * structural type so that library helpers do not depend on the AI SDK.\n */\nexport interface DataPart {\n type: string;\n text?: string;\n data?: unknown;\n /**\n * The SDK's reconciliation key. A part written with one is *replaced* by the\n * next part carrying the same id, rather than followed by it — so a spec\n * streamed as patches must be written without an id, and only a whole-spec\n * part (`flat` / `nested`), which is a snapshot of itself, can share one.\n */\n id?: string;\n}\n\n/**\n * Type guard that validates a data part payload looks like a valid\n * {@link SpecDataPart} before we cast it.\n */\nfunction isSpecDataPart(data: unknown): data is SpecDataPart {\n if (typeof data !== 'object' || data === null) return false;\n const obj = data as Record<string, unknown>;\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}\n\n/**\n * Build a `Spec` by replaying all spec data parts from a message's\n * parts array (AI SDK `UIMessage.parts`). Returns `null` if no spec data\n * parts are present.\n */\nexport function buildSpecFromParts(parts: DataPart[]): Spec | null {\n let spec: Spec = { root: '', elements: {} };\n let hasSpec = false;\n\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 spec = applyPatch(spec, payload.patch);\n } else if (payload.type === 'flat') {\n hasSpec = true;\n spec = { ...spec, ...payload.spec };\n } else if (payload.type === 'nested') {\n hasSpec = true;\n spec = { ...spec, ...nestedToFlat(payload.spec) };\n }\n }\n }\n\n return hasSpec ? spec : null;\n}\n\n/**\n * Extract and join all text content from a message's parts array.\n */\nexport function getTextFromParts(parts: DataPart[]): string {\n return parts\n .filter(\n (p): p is DataPart & { text: string } =>\n p.type === 'text' && typeof p.text === 'string',\n )\n .map((p) => p.text.trim())\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Extract both the json-render spec and the text content from a message's\n * parts array, as memoized signals. Angular counterpart of\n * `useJsonRenderMessage` from the other renderers.\n *\n * @example\n * ```ts\n * readonly msg = jsonRenderMessage(() => this.message().parts);\n * // template: @if (msg.hasSpec()) { <json-render [spec]=\"msg.spec()\" ... /> }\n * ```\n */\nexport function jsonRenderMessage(\n parts: Signal<DataPart[]> | (() => DataPart[]),\n): {\n spec: Signal<Spec | null>;\n text: Signal<string>;\n hasSpec: Signal<boolean>;\n} {\n const result = computed(() => {\n const p = parts();\n return {\n spec: buildSpecFromParts(p),\n text: getTextFromParts(p),\n };\n });\n\n return {\n spec: computed(() => result().spec),\n text: computed(() => result().text),\n hasSpec: computed(() => {\n const s = result().spec;\n return s !== null && Object.keys(s.elements || {}).length > 0;\n }),\n };\n}\n","/**\n * Sink for the decoded text of a streamed response. `@json-render/core`'s\n * mixed-stream parser already has this shape, so a hook can hand its own\n * consumer or the core one to {@link streamRequest} unchanged.\n */\nexport interface StreamConsumer {\n push(text: string): void;\n flush(): void;\n}\n\n/** One streamed POST: where to send it, what to send, and how to cancel it. */\nexport interface StreamRequest {\n api: string;\n body: unknown;\n fetch?: typeof globalThis.fetch;\n signal: AbortSignal;\n}\n\n/**\n * The write permit of a single request.\n *\n * A hook's signals are shared by every request it ever makes, so a request\n * that has been superseded must not write to them on its way out — its stale\n * spec would flash over the fresh one, and its `finally` would clear\n * `isStreaming` while its replacement is still streaming. Routing every write\n * and callback through {@link commit} makes that structural: a superseded\n * request has no way to reach the signals, rather than each write site being\n * individually responsible for remembering to check.\n */\nexport interface RequestGate {\n readonly signal: AbortSignal;\n /** Whether this request is still the session's current one. */\n isCurrent(): boolean;\n /** Run `write` only while this request is still the current one. */\n commit(write: () => void): void;\n}\n\n/**\n * Tracks which request owns a hook's signals. Each {@link begin} supersedes\n * the one before it.\n */\nexport interface StreamSession {\n begin(): RequestGate;\n /** Abort the in-flight request, leaving no request current. */\n cancel(): void;\n}\n\nexport function createStreamSession(): StreamSession {\n let current: AbortController | null = null;\n\n return {\n begin(): RequestGate {\n current?.abort();\n const controller = new AbortController();\n current = controller;\n const isCurrent = () => current === controller;\n return {\n signal: controller.signal,\n isCurrent,\n commit(write) {\n if (isCurrent()) write();\n },\n };\n },\n cancel() {\n current?.abort();\n // Cleared, not just aborted: with no current controller the in-flight\n // request's gate closes too, so a stop() cannot be undone a moment later\n // by the request it just cancelled.\n current = null;\n },\n };\n}\n\n/** True for the rejection `fetch` and a stream reader raise on abort. */\nexport function isAbortError(error: unknown): boolean {\n return (error as Error | undefined)?.name === 'AbortError';\n}\n\n/**\n * Buffer decoded text and hand back whole lines, dropping blank ones. What is\n * left when the stream ends is flushed as a final line, since a model's last\n * line often arrives without its newline.\n */\nexport function createLineConsumer(\n onLine: (line: string) => void,\n): StreamConsumer {\n let buffer = '';\n return {\n push(text) {\n buffer += text;\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed) onLine(trimmed);\n }\n },\n flush() {\n const trimmed = buffer.trim();\n buffer = '';\n if (trimmed) onLine(trimmed);\n },\n };\n}\n\n/**\n * Mine an error response for something better to show than its status code.\n */\nasync function readErrorMessage(response: Response): Promise<string> {\n try {\n const body = await response.json();\n if (body.message) return String(body.message);\n if (body.error) return String(body.error);\n } catch {\n // A non-JSON error body is ordinary; the status line still says enough.\n }\n return `HTTP error: ${response.status}`;\n}\n\n/**\n * POST `body` and feed the streamed response to `consumer` until it ends.\n *\n * Both hooks share this so the request lifecycle — error mining, the reader\n * loop, the decoder's final flush — has one implementation to get right\n * rather than one per hook that has to be fixed twice.\n */\nexport async function streamRequest(\n request: StreamRequest,\n consumer: StreamConsumer,\n): Promise<void> {\n // Bound, because a bare `globalThis.fetch` called as a plain function is\n // an illegal invocation in the browser.\n const doFetch = request.fetch ?? globalThis.fetch.bind(globalThis);\n\n const response = await doFetch(request.api, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(request.body),\n signal: request.signal,\n });\n\n if (!response.ok) {\n throw new Error(await readErrorMessage(response));\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No response body');\n }\n\n const decoder = new TextDecoder();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n consumer.push(decoder.decode(value, { stream: true }));\n }\n\n // Without the final, non-streaming decode a multi-byte character split\n // across the last chunk is dropped instead of surfacing.\n const tail = decoder.decode();\n if (tail) consumer.push(tail);\n\n consumer.flush();\n}\n","import { DestroyRef, type Signal, inject, signal } from '@angular/core';\nimport type { JsonPatch, Spec } from '@json-render/core';\nimport type {\n RenderLimits,\n SpecCatalog,\n SpecCheckIssue,\n} from '../render-limits';\nimport {\n type SpecValidationMode,\n checkSpec,\n formatSpecCheckIssues,\n reportSpecCheck,\n} from '../spec-validation';\nimport { createObservedRuns, notifyStreamObservers } from './observer';\nimport { applyPatch } from './patch';\nimport {\n createLineConsumer,\n createStreamSession,\n isAbortError,\n streamRequest,\n} from './transport';\n\n/**\n * Token usage metadata from AI generation.\n */\nexport interface TokenUsage {\n promptTokens: number;\n completionTokens: number;\n totalTokens: number;\n}\n\n/**\n * Parse result for a single line — either a patch or usage metadata.\n */\ntype ParsedLine =\n | { type: 'patch'; patch: JsonPatch }\n | { type: 'usage'; usage: TokenUsage }\n | null;\n\n/**\n * Parse a single JSON line (patch or metadata). Anything that is not one of\n * the two is dropped: half-written lines and stray prose are ordinary in a\n * model's output, and aborting the generation over one would lose the UI\n * built so far.\n */\nfunction parseLine(line: string): ParsedLine {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('//')) {\n return null;\n }\n const parsed = JSON.parse(trimmed);\n\n // Check for usage metadata\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\n // Parseable JSON is not yet a patch: without this, a stray object would be\n // recorded as a raw line and handed to the engine as an opless patch.\n if (typeof parsed?.op !== 'string' || typeof parsed?.path !== 'string') {\n return null;\n }\n\n return { type: 'patch', patch: parsed as JsonPatch };\n } catch {\n return null;\n }\n}\n\n/**\n * Per-call options for {@link UIStreamReturn.send}.\n */\nexport interface UIStreamSendOptions {\n /** Arbitrary context forwarded to the endpoint as `context`. */\n context?: Record<string, unknown>;\n /**\n * Spec to refine instead of starting from an empty one. It is sent to the\n * endpoint as `currentSpec` and the streamed patches apply on top of it.\n */\n previousSpec?: Spec;\n}\n\n/**\n * Options for {@link injectUIStream}.\n */\nexport interface UIStreamOptions {\n /** API endpoint */\n api: string;\n /** Callback when complete */\n onComplete?: (spec: Spec) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n /**\n * Whether to check the finished spec's structure, and what a problem means.\n * Off by default.\n *\n * The check runs once, when the generation completes — a spec mid-stream is\n * supposed to be incomplete. Both modes apply the lossless fixes and publish\n * the fixed spec; `'warn'` reports what is left, while `'strict'` fails the\n * generation instead of calling `onComplete`, so an app that persists the\n * spec there does not persist a broken one.\n */\n validate?: SpecValidationMode;\n /**\n * Caps on what the finished spec may cost the browser. Enforced whatever\n * `validate` is: a spec over `maxElements` fails the generation rather than\n * reaching `onComplete`.\n */\n renderLimits?: RenderLimits | null;\n /**\n * The catalog the spec was generated for. Given one, `validate` also checks\n * every element `type` against the catalog and each element's props against\n * its component's schema — the half a structural check cannot see. Props\n * written as expressions are left alone: they have no value until render\n * time.\n */\n catalog?: SpecCatalog | null;\n /**\n * Transport, defaulting to the global `fetch`.\n *\n * Anything with fetch's shape works, so a test, a demo replaying a recorded\n * generation, or an app that has to add auth headers or route through its\n * own HTTP layer can supply one instead of patching the global. It is called\n * with the endpoint and a request carrying the JSON body and the abort\n * signal, and must resolve to a `Response` whose `body` is a readable\n * stream of the JSONL patches.\n */\n fetch?: typeof globalThis.fetch;\n}\n\n/**\n * Return type for {@link injectUIStream}.\n */\nexport interface UIStreamReturn {\n /** Current UI spec */\n readonly spec: Signal<Spec | null>;\n /** Whether currently streaming */\n readonly isStreaming: Signal<boolean>;\n /** Error if any */\n readonly error: Signal<Error | null>;\n /** Token usage from the last generation */\n readonly usage: Signal<TokenUsage | null>;\n /** Raw JSONL lines received from the stream (JSON patch lines) */\n readonly rawLines: Signal<string[]>;\n /**\n * What the check found in the finished spec — structure, catalog and\n * limits alike. Empty until a generation completes; empty while `validate`\n * is off unless a `renderLimits` cap was passed, since those are enforced\n * in every mode.\n */\n readonly issues: Signal<readonly SpecCheckIssue[]>;\n /** Send a prompt to generate UI */\n send: (prompt: string, options?: UIStreamSendOptions) => Promise<void>;\n /**\n * Stop the in-flight generation, keeping whatever has rendered so far.\n * A no-op when nothing is streaming.\n */\n stop: () => void;\n /** Stop any generation and clear the spec, error, usage and raw lines. */\n clear: () => void;\n}\n\n/**\n * Streaming UI generation. POSTs `{ prompt, context, currentSpec }` to the\n * endpoint and progressively applies the returned JSONL patch stream to the\n * `spec` signal, so partial UIs render as they arrive.\n *\n * Must be called in an injection context (aborts in-flight requests on\n * destroy).\n *\n * @example\n * ```ts\n * export class GeneratePage {\n * readonly ui = injectUIStream({ api: '/api/generate' });\n * }\n * // template:\n * // <json-render [spec]=\"ui.spec()\" [registry]=\"registry\" [loading]=\"ui.isStreaming()\" />\n * ```\n */\nexport function injectUIStream(options: UIStreamOptions): UIStreamReturn {\n const spec = signal<Spec | null>(null);\n const isStreaming = signal(false);\n const error = signal<Error | null>(null);\n const usage = signal<TokenUsage | null>(null);\n const rawLines = signal<string[]>([]);\n const issues = signal<readonly SpecCheckIssue[]>([]);\n const validate = options.validate ?? 'off';\n const checkOptions = {\n limits: options.renderLimits ?? null,\n catalog: options.catalog ?? null,\n };\n const session = createStreamSession();\n const runs = createObservedRuns();\n\n inject(DestroyRef).onDestroy(() => session.cancel());\n\n const stop = () => {\n session.cancel();\n runs.stop();\n isStreaming.set(false);\n };\n\n const clear = () => {\n // Aborting first is what makes this true: without it the in-flight\n // request puts its spec straight back on the next patch it applies.\n stop();\n spec.set(null);\n error.set(null);\n usage.set(null);\n rawLines.set([]);\n issues.set([]);\n };\n\n const send = async (prompt: string, sendOptions?: UIStreamSendOptions) => {\n const gate = session.begin();\n\n isStreaming.set(true);\n error.set(null);\n usage.set(null);\n rawLines.set([]);\n issues.set([]);\n\n const previousSpec = sendOptions?.previousSpec;\n let currentSpec: Spec =\n previousSpec && previousSpec.root\n ? { ...previousSpec, elements: { ...previousSpec.elements } }\n : { root: '', elements: {} };\n spec.set(currentSpec);\n const end = runs.start();\n let failed = false;\n\n const handleLine = (line: string) => {\n const parsed = parseLine(line);\n if (!parsed) return;\n gate.commit(() => {\n if (parsed.type === 'usage') {\n usage.set(parsed.usage);\n notifyStreamObservers('onUsage', parsed.usage);\n return;\n }\n rawLines.update((prev) => [...prev, line]);\n currentSpec = applyPatch(currentSpec, parsed.patch);\n spec.set(currentSpec);\n notifyStreamObservers('onPatch', parsed.patch);\n });\n };\n\n try {\n await streamRequest(\n {\n api: options.api,\n body: {\n prompt,\n context: sendOptions?.context,\n currentSpec,\n },\n fetch: options.fetch,\n signal: gate.signal,\n },\n createLineConsumer(handleLine),\n );\n\n gate.commit(() => {\n const check = checkSpec(currentSpec, validate, checkOptions);\n reportSpecCheck(check, validate);\n if (check.spec) {\n currentSpec = check.spec;\n spec.set(currentSpec);\n }\n issues.set(check.issues);\n\n // Under `strict` a broken generation is a failure, not a result: the\n // app's onComplete is where a spec usually gets persisted, and handing\n // it one that cannot render is the outcome this mode is asked to\n // prevent. The spec stays put so the app can show or discard it.\n // A limit the app set fails the generation whatever the mode: the\n // spec it would hand `onComplete` is one the app already said it did\n // not want rendered.\n if (check.blocked || (validate === 'strict' && check.hasErrors)) {\n const invalid = new Error(\n `Generated spec failed validation:\\n${formatSpecCheckIssues(check.issues)}`,\n );\n failed = true;\n error.set(invalid);\n options.onError?.(invalid);\n return;\n }\n options.onComplete?.(currentSpec);\n });\n } catch (err) {\n if (isAbortError(err)) return;\n failed = true;\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n gate.commit(() => {\n error.set(resolvedError);\n options.onError?.(resolvedError);\n });\n } finally {\n gate.commit(() => isStreaming.set(false));\n end(!failed);\n }\n };\n\n return {\n spec: spec.asReadonly(),\n isStreaming: isStreaming.asReadonly(),\n error: error.asReadonly(),\n usage: usage.asReadonly(),\n rawLines: rawLines.asReadonly(),\n issues: issues.asReadonly(),\n send,\n stop,\n clear,\n };\n}\n","import { DestroyRef, type Signal, inject, signal } from '@angular/core';\nimport type { Spec } from '@json-render/core';\nimport { createMixedStreamParser } from '@json-render/core';\nimport type {\n RenderLimits,\n SpecCatalog,\n SpecCheckIssue,\n} from '../render-limits';\nimport {\n type SpecValidationMode,\n checkSpec,\n formatSpecCheckIssues,\n reportSpecCheck,\n} from '../spec-validation';\nimport { createObservedRuns, notifyStreamObservers } from './observer';\nimport { applyPatch } from './patch';\nimport { createStreamSession, isAbortError, streamRequest } from './transport';\n\n/**\n * A single message in the chat, which may contain text, a rendered UI spec,\n * or both.\n */\nexport interface ChatMessage {\n /** Unique message ID */\n id: string;\n /** Who sent this message */\n role: 'user' | 'assistant';\n /** Text content (conversational prose) */\n text: string;\n /** json-render Spec built from JSONL patches (null if no UI was generated) */\n spec: Spec | null;\n}\n\n/**\n * Options for {@link injectChatUI}.\n */\nexport interface ChatUIOptions {\n /** API endpoint that accepts `{ messages: Array<{ role, content }> }` and returns a text stream */\n api: string;\n /** Callback when streaming completes for a message */\n onComplete?: (message: ChatMessage) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n /**\n * Transport, defaulting to the global `fetch`. Same contract as\n * `UIStreamOptions.fetch`: it receives the endpoint and a request\n * carrying the JSON body and the abort signal, and must resolve to a\n * `Response` whose `body` streams the reply.\n */\n fetch?: typeof globalThis.fetch;\n /**\n * Whether to check the spec a reply built, and what a problem means. Off by\n * default; same contract as `UIStreamOptions.validate`, applied once per\n * reply that produced a spec.\n */\n validate?: SpecValidationMode;\n /**\n * Caps on what the finished spec may cost the browser. Enforced whatever\n * `validate` is: a spec over `maxElements` fails the generation rather than\n * reaching `onComplete`.\n */\n renderLimits?: RenderLimits | null;\n /**\n * The catalog the spec was generated for. Given one, `validate` also checks\n * every element `type` against the catalog and each element's props against\n * its component's schema — the half a structural check cannot see. Props\n * written as expressions are left alone: they have no value until render\n * time.\n */\n catalog?: SpecCatalog | null;\n}\n\n/**\n * Return type for {@link injectChatUI}.\n */\nexport interface ChatUIReturn {\n /** All messages in the conversation */\n readonly messages: Signal<ChatMessage[]>;\n /** Whether currently streaming an assistant response */\n readonly isStreaming: Signal<boolean>;\n /** Error from the last request, if any */\n readonly error: Signal<Error | null>;\n /**\n * What the check found in the last completed reply's spec — structure,\n * catalog and limits alike. Empty until a reply completes; empty while\n * `validate` is off unless a `renderLimits` cap was passed, since those are\n * enforced in every mode.\n */\n readonly issues: Signal<readonly SpecCheckIssue[]>;\n /** Send a user message */\n send: (text: string) => Promise<void>;\n /**\n * Stop the in-flight reply, keeping whatever the assistant has said so far.\n * A no-op when nothing is streaming.\n */\n stop: () => void;\n /** Stop any reply and clear all messages and the error. */\n clear: () => void;\n}\n\nlet chatMessageIdCounter = 0;\nfunction generateChatId(): string {\n if (\n typeof crypto !== 'undefined' &&\n typeof crypto.randomUUID === 'function'\n ) {\n return crypto.randomUUID();\n }\n chatMessageIdCounter += 1;\n return `msg-${Date.now()}-${chatMessageIdCounter}`;\n}\n\n/**\n * Chat + GenUI: manages a multi-turn conversation where each assistant\n * message can contain both conversational text and a json-render UI spec.\n * The full message history is sent to the endpoint and the streamed response\n * is split into text lines and JSONL patch lines.\n *\n * Must be called in an injection context.\n */\nexport function injectChatUI(options: ChatUIOptions): ChatUIReturn {\n const messages = signal<ChatMessage[]>([]);\n const isStreaming = signal(false);\n const error = signal<Error | null>(null);\n const issues = signal<readonly SpecCheckIssue[]>([]);\n const validate = options.validate ?? 'off';\n const checkOptions = {\n limits: options.renderLimits ?? null,\n catalog: options.catalog ?? null,\n };\n const session = createStreamSession();\n const runs = createObservedRuns();\n\n inject(DestroyRef).onDestroy(() => session.cancel());\n\n const stop = () => {\n session.cancel();\n runs.stop();\n isStreaming.set(false);\n };\n\n const clear = () => {\n stop();\n messages.set([]);\n error.set(null);\n issues.set([]);\n };\n\n const send = async (text: string) => {\n if (!text.trim()) return;\n\n const gate = session.begin();\n\n const userMessage: ChatMessage = {\n id: generateChatId(),\n role: 'user',\n text: text.trim(),\n spec: null,\n };\n\n const assistantId = generateChatId();\n const assistantMessage: ChatMessage = {\n id: assistantId,\n role: 'assistant',\n text: '',\n spec: null,\n };\n\n /**\n * Drop this turn's assistant bubble if it never got any text.\n *\n * Deliberately outside the gate: the edit is scoped to this request's own\n * message id, so it is safe even once a newer request has appended its\n * turn — and a superseded request is exactly when it is needed, since an\n * empty bubble left behind renders as a blank reply and is serialised\n * into every later turn's history.\n */\n const dropEmptyPlaceholder = () => {\n messages.update((prev) =>\n prev.filter((m) => m.id !== assistantId || m.text.length > 0),\n );\n };\n\n // Built before the new turn is appended, so it carries the conversation so\n // far. Assistant turns with no text are left out: they say nothing to the\n // model, some providers reject empty content outright, and a turn being\n // superseded right now may still have its placeholder in the list.\n const historyForApi = [\n ...messages()\n .filter((m) => m.role !== 'assistant' || m.text.length > 0)\n .map((m) => ({\n role: m.role,\n content: m.text,\n })),\n { role: 'user' as const, content: text.trim() },\n ];\n\n // Append user message and empty assistant placeholder\n messages.update((prev) => [...prev, userMessage, assistantMessage]);\n isStreaming.set(true);\n error.set(null);\n const end = runs.start();\n let failed = false;\n\n // Mutable state for accumulating the assistant response\n let accumulatedText = '';\n let currentSpec: Spec = { root: '', elements: {} };\n let hasSpec = false;\n\n const parser = createMixedStreamParser({\n onPatch(patch) {\n hasSpec = true;\n // applyPatch returns a fresh spec that shares what the patch did not\n // touch, so the message can hold it directly — no snapshot copy.\n currentSpec = applyPatch(currentSpec, patch);\n const snapshot = currentSpec;\n gate.commit(() => {\n messages.update((prev) =>\n prev.map((m) =>\n m.id === assistantId ? { ...m, spec: snapshot } : m,\n ),\n );\n notifyStreamObservers('onPatch', patch);\n });\n },\n onText(line) {\n accumulatedText += (accumulatedText ? '\\n' : '') + line;\n const snapshot = accumulatedText;\n gate.commit(() => {\n messages.update((prev) =>\n prev.map((m) =>\n m.id === assistantId ? { ...m, text: snapshot } : m,\n ),\n );\n notifyStreamObservers('onText', line);\n });\n },\n });\n\n try {\n await streamRequest(\n {\n api: options.api,\n body: { messages: historyForApi },\n fetch: options.fetch,\n signal: gate.signal,\n },\n parser,\n );\n\n gate.commit(() => {\n // A reply that only talked has no spec to check, and reporting\n // \"missing root\" for a sentence would be nonsense.\n const check = checkSpec(\n hasSpec ? currentSpec : null,\n validate,\n checkOptions,\n );\n if (hasSpec) {\n reportSpecCheck(check, validate);\n if (check.spec) currentSpec = check.spec;\n }\n issues.set(check.issues);\n\n const finalMessage: ChatMessage = {\n id: assistantId,\n role: 'assistant',\n text: accumulatedText,\n spec: hasSpec ? currentSpec : null,\n };\n // The reply keeps the fixed spec, so what renders in the bubble is\n // what was checked.\n messages.update((prev) =>\n prev.map((m) => (m.id === assistantId ? finalMessage : m)),\n );\n\n // A limit the app set fails the generation whatever the mode: the\n // spec it would hand `onComplete` is one the app already said it did\n // not want rendered.\n if (check.blocked || (validate === 'strict' && check.hasErrors)) {\n const invalid = new Error(\n `Generated spec failed validation:\\n${formatSpecCheckIssues(check.issues)}`,\n );\n failed = true;\n error.set(invalid);\n options.onError?.(invalid);\n return;\n }\n options.onComplete?.(finalMessage);\n });\n } catch (err) {\n // Unconditional: however this turn ended, its own bubble goes with it if\n // nothing was ever said into it. A superseded request usually unwinds by\n // abort, but one whose stream failed for its own reason after being\n // replaced would otherwise leave the placeholder behind.\n dropEmptyPlaceholder();\n if (isAbortError(err)) return;\n failed = true;\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n gate.commit(() => {\n error.set(resolvedError);\n options.onError?.(resolvedError);\n });\n } finally {\n gate.commit(() => isStreaming.set(false));\n end(!failed);\n }\n };\n\n return {\n messages: messages.asReadonly(),\n isStreaming: isStreaming.asReadonly(),\n error: error.asReadonly(),\n issues: issues.asReadonly(),\n send,\n stop,\n clear,\n };\n}\n","/**\n * Streaming: applying a model's output to a spec as it arrives.\n *\n * - `patch` — the immutable RFC 6902 engine every entry point applies through.\n * - `transport` — one streamed request lifecycle, shared by both hooks.\n * - `parts` — adapters for the AI SDK's message parts.\n * - `ui-stream` / `chat-ui` — the two hooks, composed from the above.\n */\nexport { applyPatch } from './patch';\nexport {\n ɵregisterStreamObserver,\n type StreamObserver,\n type StreamObserverUsage,\n} from './observer';\nexport {\n buildSpecFromParts,\n flatToTree,\n getTextFromParts,\n jsonRenderMessage,\n type DataPart,\n} from './parts';\nexport {\n injectUIStream,\n type TokenUsage,\n type UIStreamOptions,\n type UIStreamReturn,\n type UIStreamSendOptions,\n} from './ui-stream';\nexport {\n injectChatUI,\n type ChatMessage,\n type ChatUIOptions,\n type ChatUIReturn,\n} from './chat-ui';\n","/*\n * Public API Surface of ngx-json-render\n */\n\n// Renderer components\nexport { JsonRenderer } from './lib/renderer.component';\nexport { JrChildren } from './lib/children.component';\nexport { JrElement } from './lib/element.component';\nexport { JrRepeatScope } from './lib/repeat-scope.component';\nexport { JrConfirmDialog } from './lib/confirm-dialog.component';\nexport {\n CONFIRM_CONTEXT,\n JR_CONFIRM_DIALOG,\n JR_CONFIRM_LABELS,\n injectConfirmContext,\n type ConfirmContext,\n type ConfirmLabels,\n} from './lib/confirm-tokens';\n\n// Render context / DI\nexport {\n ELEMENT_KEY,\n RENDER_CONTEXT,\n REPEAT_SCOPE,\n injectElementKey,\n injectRenderContext,\n injectRepeatScope,\n} from './lib/tokens';\nexport { JsonRenderRootContext } from './lib/root-context';\n\n// State\nexport {\n JsonRenderStateService,\n injectStateStore,\n injectStateValue,\n injectStateBinding,\n injectBoundProp,\n} from './lib/state.service';\n\n// Actions\nexport {\n JsonRenderActionsService,\n injectActions,\n injectAction,\n isActionCancelled,\n type PendingConfirmation,\n} from './lib/actions.service';\n\n// Validation\nexport {\n JsonRenderValidationService,\n injectValidation,\n injectFieldValidation,\n type FieldValidationState,\n} from './lib/validation.service';\n\n// Spec validation\nexport {\n checkSpec,\n formatSpecCheckIssues,\n type SpecCheck,\n type SpecCheckOptions,\n type SpecValidationMode,\n} from './lib/spec-validation';\n\n// Render limits\nexport {\n type RenderLimits,\n type SpecCatalog,\n type SpecCheckIssue,\n type SpecCheckIssueCode,\n} from './lib/render-limits';\n\n// Registry\nexport {\n defineRegistry,\n createStoreSetState,\n type DefineRegistryResult,\n} from './lib/registry';\n\n// Types\nexport type {\n Actions,\n ActionFn,\n CatalogHasActions,\n ComponentRegistry,\n Components,\n EventHandle,\n RegistryEntry,\n RenderContext,\n RepeatScope,\n SetState,\n StateChange,\n StateModel,\n} from './lib/types';\n\n// Streaming / AI helpers\nexport {\n applyPatch,\n buildSpecFromParts,\n flatToTree,\n getTextFromParts,\n injectChatUI,\n injectUIStream,\n jsonRenderMessage,\n type ChatMessage,\n type ChatUIOptions,\n type ChatUIReturn,\n type DataPart,\n type TokenUsage,\n type UIStreamOptions,\n type UIStreamReturn,\n type UIStreamSendOptions,\n} from './lib/streaming';\n\n// Schema (spec format + prompt rules)\nexport {\n schema,\n type AngularSchema,\n type AngularSpec,\n} from 'ngx-json-render/schema';\n\n// Devtools\nexport { injectDevtoolsActive } from './lib/devtools';\n// Private API for ngx-json-render/devtools; may change in any release.\nexport {\n ɵregisterStreamObserver,\n type StreamObserver,\n type StreamObserverUsage,\n} from './lib/streaming';\n\n// Core re-exports (for convenience)\nexport type {\n ActionBinding,\n ActionHandler,\n InferActionParams,\n InferCatalogComponents,\n InferComponentProps,\n JsonPatch,\n Spec,\n SpecIssue,\n StateStore,\n UIElement,\n VisibilityCondition,\n} from '@json-render/core';\nexport {\n autoFixSpec,\n createStateStore,\n formatSpecIssues,\n nestedToFlat,\n validateSpec,\n} from '@json-render/core';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,4EAAC;AAE/B;;;;;;AAMG;MAEU,qBAAqB,CAAA;IAChC,IAAI,GAAoC,KAAK;IAC7C,QAAQ,GAA0C,KAAK;AACvD,IAAA,OAAO,GAAoB,MAAM,CAAC,KAAK,8EAAC;IACxC,QAAQ,GAA6D,KAAK;AAC1E;;;AAGG;IACH,MAAM,GAA4C,KAAK;AACvD;;;AAGG;IACH,OAAO,GAA2C,KAAK;;IAGvD,KAAK,GAA0C,KAAK;;AAEpD,IAAA,YAAY,GAAuB,MAAM,CAAC,EAAE,mFAAC;IAE7C,QAAQ,GAAsD,KAAK;IACnE,QAAQ,GAIJ,KAAK;IACT,QAAQ,GAAwD,KAAK;IAErE,mBAAmB,GACjB,KAAK;IACP,SAAS,GAAyD,KAAK;IACvE,iBAAiB,GAA0C,KAAK;;AAGhE,IAAA,eAAe,GAAqC,MAAK,EAAE,CAAC;;AAG5D,IAAA,YAAY,CAAC,IAAY,EAAA;AACvB,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,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AO,CAAC,OAAO,GAAG,OAAO,CAAC;oBAC1B;gBACF;AACA,gBAAA,OAAO,CAAC,UAAU,GAAG,YAAY,CAAC;AACpC,YAAA,CAAC,CAAC;QACJ;QAAE,OAAO,GAAG,EAAE;;;;;AAKZ,YAAA,oBAAoB,EAAE;YACtB,IAAI,YAAY,CAAC,GAAG,CAAC;gBAAE;YACvB,MAAM,GAAG,IAAI;YACb,MAAM,aAAa,GAAG,GAAG,YAAY,KAAK,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACzE,YAAA,IAAI,CAAC,MAAM,CAAC,MAAK;AACf,gBAAA,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC;AACxB,gBAAA,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;AAClC,YAAA,CAAC,CAAC;QACJ;gBAAU;AACR,YAAA,IAAI,CAAC,MAAM,CAAC,MAAM,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzC,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC;QACd;AACF,IAAA,CAAC;IAED,OAAO;AACL,QAAA,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE;AAC/B,QAAA,WAAW,EAAE,WAAW,CAAC,UAAU,EAAE;AACrC,QAAA,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;AACzB,QAAA,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE;QAC3B,IAAI;QACJ,IAAI;QACJ,KAAK;KACN;AACH;;AC9TA;;;;;;;AAOG;;ACPH;;AAEG;AAEH;;ACJA;;AAEG;;"}
1
+ {"version":3,"file":"ngx-json-render.mjs","sources":["../../../projects/ngx-json-render/src/lib/root-context.ts","../../../projects/ngx-json-render/src/lib/pointer.ts","../../../projects/ngx-json-render/src/lib/same-json.ts","../../../projects/ngx-json-render/src/lib/state.service.ts","../../../projects/ngx-json-render/src/lib/validation.service.ts","../../../projects/ngx-json-render/src/lib/actions.service.ts","../../../projects/ngx-json-render/src/lib/confirm-tokens.ts","../../../projects/ngx-json-render/src/lib/confirm-dialog.component.ts","../../../projects/ngx-json-render/src/lib/devtools.ts","../../../projects/ngx-json-render/src/lib/render-limits.ts","../../../projects/ngx-json-render/src/lib/state-reads.ts","../../../projects/ngx-json-render/src/lib/tokens.ts","../../../projects/ngx-json-render/src/lib/element.component.ts","../../../projects/ngx-json-render/src/lib/provide.ts","../../../projects/ngx-json-render/src/lib/spec-validation.ts","../../../projects/ngx-json-render/src/lib/renderer.component.ts","../../../projects/ngx-json-render/src/lib/repeat-scope.component.ts","../../../projects/ngx-json-render/src/lib/children.component.ts","../../../projects/ngx-json-render/src/lib/registry.ts","../../../projects/ngx-json-render/src/lib/streaming/patch.ts","../../../projects/ngx-json-render/src/lib/streaming/observer.ts","../../../projects/ngx-json-render/src/lib/streaming/parts.ts","../../../projects/ngx-json-render/src/lib/streaming/transport.ts","../../../projects/ngx-json-render/src/lib/streaming/ui-stream.ts","../../../projects/ngx-json-render/src/lib/streaming/chat-ui.ts","../../../projects/ngx-json-render/src/lib/streaming/index.ts","../../../projects/ngx-json-render/src/public-api.ts","../../../projects/ngx-json-render/src/ngx-json-render.ts"],"sourcesContent":["import { Injectable, type Signal, type Type, signal } from '@angular/core';\nimport type {\n ActionHandler,\n ComputedFunction,\n DirectiveRegistry,\n Spec,\n StateModel,\n StateStore,\n ValidationFunction,\n} from '@json-render/core';\nimport type { RenderLimits, SpecCatalog } from './render-limits';\nimport type { ComponentRegistry, RegistryEntry, StateChange } from './types';\n\nconst EMPTY = signal(undefined);\n\n/**\n * Internal bridge between the `<json-render>` component's inputs and the\n * renderer services / element tree. The renderer component replaces these\n * signal references with its own input signals at construction time.\n *\n * @internal\n */\n@Injectable()\nexport class JsonRenderRootContext {\n spec: Signal<Spec | null | undefined> = EMPTY;\n registry: Signal<ComponentRegistry | undefined> = EMPTY;\n loading: Signal<boolean> = signal(false);\n fallback: Signal<Type<unknown> | RegistryEntry | null | undefined> = EMPTY;\n /**\n * Caps on what the spec may cost the browser. Read as the tree renders, so\n * they apply whatever `validate` is set to.\n */\n limits: Signal<RenderLimits | null | undefined> = EMPTY;\n /**\n * The catalog the spec was generated for. While loading, an element whose\n * props do not pass its component's schema waits for them.\n */\n catalog: Signal<SpecCatalog | null | undefined> = EMPTY;\n\n /** External store (controlled mode). */\n store: Signal<StateStore | null | undefined> = EMPTY;\n /** Initial state (uncontrolled mode); falls back to `spec.state`. */\n initialState: Signal<StateModel> = signal({});\n\n handlers: Signal<Record<string, ActionHandler> | undefined> = EMPTY;\n onAction: Signal<\n | ((name: string, params?: Record<string, unknown>) => unknown)\n | null\n | undefined\n > = EMPTY;\n navigate: Signal<((path: string) => void) | null | undefined> = EMPTY;\n\n validationFunctions: Signal<Record<string, ValidationFunction> | undefined> =\n EMPTY;\n functions: Signal<Record<string, ComputedFunction> | undefined> = EMPTY;\n directiveRegistry: Signal<DirectiveRegistry | undefined> = EMPTY;\n\n /** Emits uncontrolled-mode state changes to the renderer output. */\n emitStateChange: (changes: StateChange[]) => void = () => {};\n\n /** Resolve a registry entry (component + slot metadata) for a type. */\n resolveEntry(type: string): RegistryEntry | undefined {\n const raw = this.registry()?.[type] ?? this.fallback() ?? undefined;\n if (!raw) return undefined;\n return typeof raw === 'function' ? { component: raw } : raw;\n }\n}\n","import { isDevMode } from '@angular/core';\n\n/** Nesting below this is kept as one leaf, the same cut-off core uses. */\nconst MAX_FLATTEN_DEPTH = 20;\n\n/** Escape one key for a JSON Pointer: `~` → `~0`, `/` → `~1`. */\nexport function escapePointerSegment(key: string): string {\n return key.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n\n/**\n * Flatten plain objects into a `{ pointer: leaf }` map; arrays and anything\n * that is not a plain object are leaves.\n *\n * Core's `flattenToPointers` does the same but joins keys unescaped, so a key\n * such as `a/b` comes back as `/a/b` and a store write puts it at `a` → `b`.\n * Every path built here is escaped, so it reads back the key it came from.\n */\nexport function flattenToPointers(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const seen = new Set<object>();\n let warned = false;\n\n const walk = (\n value: Record<string, unknown>,\n prefix: string,\n depth: number,\n ) => {\n for (const [key, child] of Object.entries(value)) {\n const pointer = `${prefix}/${escapePointerSegment(key)}`;\n if (isPlainObject(child) && !seen.has(child)) {\n if (depth < MAX_FLATTEN_DEPTH) {\n seen.add(child);\n walk(child, pointer, depth + 1);\n continue;\n }\n if (isDevMode() && !warned) {\n warned = true;\n console.warn(\n `[ngx-json-render] state nested deeper than ${MAX_FLATTEN_DEPTH} levels is treated as one value.`,\n );\n }\n }\n result[pointer] = child;\n }\n };\n\n walk(obj, '', 0);\n return result;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n","/**\n * Whether two values hold the same JSON content.\n *\n * For telling a value that arrived as a new object from one that changed — a\n * spec element, or a leaf of `spec.state`, when the host hands over a spec\n * built from fresh objects. Plain objects and arrays are compared by what\n * they hold; anything else only by identity, which data parsed from JSON\n * never needs. A container reached twice on the way down counts as\n * different: JSON cannot refer to itself, and treating such a value as\n * changed is what the renderer did before it compared anything.\n */\nexport function sameJson(\n a: unknown,\n b: unknown,\n seen = new Set<unknown>(),\n): boolean {\n if (Object.is(a, b)) return true;\n if (!isPlainContainer(a) || !isPlainContainer(b)) return false;\n if (Array.isArray(a) !== Array.isArray(b) || seen.has(a)) return false;\n seen.add(a);\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(\n (key) => Object.hasOwn(b, key) && sameJson(a[key], b[key], seen),\n );\n}\n\nfunction isPlainContainer(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false;\n const prototype = Object.getPrototypeOf(value);\n return (\n Array.isArray(value) || prototype === Object.prototype || prototype === null\n );\n}\n","import {\n Injectable,\n type Signal,\n computed,\n effect,\n inject,\n isDevMode,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n type StateModel,\n type StateStore,\n createStateStore,\n getByPath,\n} from '@json-render/core';\nimport { escapePointerSegment, flattenToPointers } from './pointer';\nimport { JsonRenderRootContext } from './root-context';\nimport { sameJson } from './same-json';\nimport type { StateChange } from './types';\n\n/**\n * The state store of a `<json-render>` subtree.\n *\n * Wraps a core {@link StateStore} (either the internal in-memory store in\n * uncontrolled mode, or an external store passed via the `store` input) and\n * exposes the current state model as a signal.\n *\n * Inject it from catalog components or action handlers via\n * {@link injectStateStore}.\n */\n@Injectable()\nexport class JsonRenderStateService {\n private readonly root = inject(JsonRenderRootContext);\n private readonly internalStore = createStateStore({});\n\n private readonly changeListeners = new Set<\n (changes: StateChange[]) => void\n >();\n\n /** The snapshot the change listeners last heard about. */\n private lastSnapshot: StateModel = {};\n /** True while this service writes, so the store's echo is not reported. */\n private writing = false;\n\n private readonly _state = signal<StateModel>(\n {},\n // External stores may mutate snapshots in place — always propagate.\n { equal: () => false },\n );\n\n /** The current state model as a signal. */\n readonly state: Signal<StateModel> = this._state.asReadonly();\n\n private readonly currentStore = computed<StateStore>(\n () => this.root.store() ?? this.internalStore,\n );\n\n constructor() {\n const initialMode =\n untracked(this.currentStore) === this.internalStore\n ? 'uncontrolled'\n : 'controlled';\n let modeWarned = false;\n\n // Keep the state signal in sync with whichever store is active.\n effect((onCleanup) => {\n const store = this.currentStore();\n\n if (isDevMode() && !modeWarned) {\n const mode =\n store === this.internalStore ? 'uncontrolled' : 'controlled';\n if (mode !== initialMode) {\n modeWarned = true;\n console.warn(\n `[ngx-json-render] switching from ${initialMode} to ${mode} mode is not supported.`,\n );\n }\n }\n\n const controlled = store !== this.internalStore;\n this.lastSnapshot = store.getSnapshot();\n untracked(() => this._state.set(this.lastSnapshot));\n const unsubscribe = store.subscribe(() => {\n const prev = this.lastSnapshot;\n const next = store.getSnapshot();\n // Recorded before the listeners run: a watch action may write again.\n this.lastSnapshot = next;\n this._state.set(next);\n // A write the host made on its own store reaches no `set`/`update`\n // here, so the diff is the only way `watch` hears about it. Our own\n // writes report themselves, with the paths they were given.\n if (controlled && !this.writing && this.changeListeners.size > 0) {\n const changes = diffState(prev, next);\n if (changes.length > 0) this.notifyChanges(changes);\n }\n });\n onCleanup(unsubscribe);\n });\n\n // Uncontrolled mode: when the (resolved) initial state changes — e.g.\n // `spec.state` grows while streaming — diff it against the previous\n // initial state and apply only the changed leaves to the store. Leaves\n // compare by content: arrays are leaves, and a spec handed over again as\n // new objects would otherwise write every array back, over whatever the\n // user has since changed inside it.\n let prevFlat: Record<string, unknown> = {};\n effect(() => {\n if (this.root.store()) return;\n const initialState = this.root.initialState() ?? {};\n const nextFlat =\n Object.keys(initialState).length > 0\n ? flattenToPointers(initialState)\n : {};\n const allKeys = new Set([\n ...Object.keys(prevFlat),\n ...Object.keys(nextFlat),\n ]);\n const updates: Record<string, unknown> = {};\n for (const key of allKeys) {\n if (!sameJson(prevFlat[key], nextFlat[key])) {\n updates[key] = key in nextFlat ? nextFlat[key] : undefined;\n }\n }\n prevFlat = nextFlat;\n if (Object.keys(updates).length > 0) {\n untracked(() => this.internalStore.update(updates));\n }\n });\n }\n\n /** Read a value by JSON Pointer path from the current state. */\n get(path: string): unknown {\n return untracked(this.currentStore).get(path);\n }\n\n /** Write a value by JSON Pointer path and notify subscribers. */\n set(path: string, value: unknown): void {\n const store = untracked(this.currentStore);\n const prev = store.getSnapshot();\n const prevValue = getByPath(prev, path);\n this.write(store, () => store.set(path, value));\n if (prevValue !== value) {\n const changes: StateChange[] = [{ path, value }];\n this.notifyChanges(changes);\n if (!untracked(this.root.store) && store.getSnapshot() !== prev) {\n this.root.emitStateChange(changes);\n }\n }\n }\n\n /** Write multiple values at once (single notification). */\n update(updates: Record<string, unknown>): void {\n const store = untracked(this.currentStore);\n const prev = store.getSnapshot();\n this.write(store, () => store.update(updates));\n const changes: StateChange[] = [];\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 this.notifyChanges(changes);\n if (!untracked(this.root.store) && store.getSnapshot() !== prev) {\n this.root.emitStateChange(changes);\n }\n }\n }\n\n /** Return the full state object (non-reactive read). */\n getSnapshot(): StateModel {\n return untracked(this.currentStore).getSnapshot();\n }\n\n /**\n * Register a listener called with the list of changed paths whenever state\n * is written through this service, or, in controlled mode, whenever the\n * external store changes (element `watch` fields rely on this). Returns an\n * unsubscribe function.\n */\n subscribeChanges(listener: (changes: StateChange[]) => void): () => void {\n this.changeListeners.add(listener);\n return () => {\n this.changeListeners.delete(listener);\n };\n }\n\n private write(store: StateStore, apply: () => void): void {\n const wasWriting = this.writing;\n this.writing = true;\n try {\n apply();\n } finally {\n this.writing = wasWriting;\n }\n this.lastSnapshot = store.getSnapshot();\n }\n\n private notifyChanges(changes: StateChange[]): void {\n for (const listener of this.changeListeners) {\n listener(changes);\n }\n }\n}\n\n/**\n * Every path whose value differs between two state snapshots, each container\n * before what it holds, values taken from `next`. Subtrees are compared by\n * reference, so an unchanged branch costs nothing, and a store that mutates a\n * snapshot in place reports no change: the same rule as a signal's `set`.\n */\nfunction diffState(prev: StateModel, next: StateModel): StateChange[] {\n const changes: StateChange[] = [];\n const walk = (a: unknown, b: unknown, path: string): void => {\n if (a === b) return;\n if (path) changes.push({ path, value: b });\n const keys = new Set([...childKeys(a), ...childKeys(b)]);\n for (const key of keys) {\n walk(\n child(a, key),\n child(b, key),\n `${path}/${escapePointerSegment(key)}`,\n );\n }\n };\n walk(prev, next, '');\n return changes;\n}\n\nfunction childKeys(value: unknown): string[] {\n return value !== null && typeof value === 'object' ? Object.keys(value) : [];\n}\n\nfunction child(value: unknown, key: string): unknown {\n return value !== null && typeof value === 'object'\n ? (value as Record<string, unknown>)[key]\n : undefined;\n}\n\n/**\n * Inject the state store of the nearest `<json-render>` renderer.\n * Must be called from within the renderer's subtree (e.g. a catalog\n * component) or a component that provides {@link JsonRenderStateService}.\n */\nexport function injectStateStore(): JsonRenderStateService {\n return inject(JsonRenderStateService);\n}\n\n/** Reactive read of a state value by JSON Pointer path. */\nexport function injectStateValue<T>(\n path: string | (() => string),\n): Signal<T | undefined> {\n const store = injectStateStore();\n const getPath = typeof path === 'function' ? path : () => path;\n return computed(() => getByPath(store.state(), getPath()) as T | undefined);\n}\n\n/**\n * Reactive two-way binding to a state path: a value signal plus a setter\n * that writes back to the same path.\n */\nexport function injectStateBinding<T>(path: string | (() => string)): {\n value: Signal<T | undefined>;\n set: (value: T) => void;\n} {\n const store = injectStateStore();\n const getPath = typeof path === 'function' ? path : () => path;\n return {\n value: computed(() => getByPath(store.state(), getPath()) as T | undefined),\n set: (value: T) => store.set(getPath(), value),\n };\n}\n\n/**\n * Two-way bound prop helper for catalog components, mirroring `useBoundProp`\n * from the other renderers: the value comes from the already-resolved prop,\n * and the setter writes back to the bound state path (no-op if not bound).\n *\n * @example\n * ```ts\n * const ctx = injectRenderContext<{ value?: string }>();\n * const bound = injectBoundProp<string>(\n * () => ctx.props().value,\n * () => ctx.bindings()?.['value'],\n * );\n * // template: <input [value]=\"bound.value() ?? ''\" (input)=\"bound.set($any($event.target).value)\" />\n * ```\n */\nexport function injectBoundProp<T>(\n propValue: () => T | undefined,\n bindingPath: () => string | undefined,\n): { value: Signal<T | undefined>; set: (value: T) => void } {\n const store = injectStateStore();\n return {\n value: computed(propValue),\n set: (value: T) => {\n const path = bindingPath();\n if (path) store.set(path, value);\n },\n };\n}\n","import {\n DestroyRef,\n Injectable,\n type Signal,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n type ValidationConfig,\n type ValidationFunction,\n type ValidationResult,\n getByPath,\n runValidation,\n} from '@json-render/core';\nimport { JsonRenderRootContext } from './root-context';\nimport { JsonRenderStateService } from './state.service';\n\nexport interface FieldValidationState {\n touched: boolean;\n validated: boolean;\n result: ValidationResult | null;\n}\n\nfunction dynamicArgsEqual(\n a: Record<string, unknown> | undefined,\n b: Record<string, unknown> | undefined,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n const va = a[key];\n const vb = b[key];\n if (va === vb) continue;\n if (\n typeof va === 'object' &&\n va !== null &&\n typeof vb === 'object' &&\n vb !== null\n ) {\n const sa = (va as Record<string, unknown>)['$state'];\n const sb = (vb as Record<string, unknown>)['$state'];\n if (typeof sa === 'string' && sa === sb) continue;\n }\n return false;\n }\n return true;\n}\n\nfunction validationConfigEqual(\n a: ValidationConfig,\n b: ValidationConfig,\n): boolean {\n if (a === b) return true;\n\n if (a.validateOn !== b.validateOn) return false;\n\n const ac = a.checks ?? [];\n const bc = b.checks ?? [];\n if (ac.length !== bc.length) return false;\n\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\n return true;\n}\n\n/**\n * Owner of a registration made through the service's own API rather than by\n * a field component. Manual registrations release together, which is the\n * behaviour a caller of `registerField(path, config)` would expect.\n */\nconst MANUAL_OWNER: object = { manual: true };\n\n/**\n * Form validation state of a `<json-render>` subtree. Fields register their\n * {@link ValidationConfig}; the built-in `validateForm` action validates all\n * registered fields and writes the result to state.\n *\n * Registrations are owner-scoped: a path stays registered while at least one\n * owner holds it, and its config and state are dropped when the last one\n * releases. A spec that swaps screens or hides fields therefore stops\n * validating what is no longer on screen.\n */\n@Injectable()\nexport class JsonRenderValidationService {\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n\n private readonly _fieldStates = signal<Record<string, FieldValidationState>>(\n {},\n );\n private readonly _fieldConfigs = signal<Record<string, ValidationConfig>>({});\n /** Live owners per path — the reference count behind a registration. */\n private readonly fieldOwners = new Map<string, Set<object>>();\n\n /** Validation state per registered field path. */\n readonly fieldStates: Signal<Record<string, FieldValidationState>> =\n this._fieldStates.asReadonly();\n\n get customFunctions(): Record<string, ValidationFunction> {\n return untracked(this.root.validationFunctions) ?? {};\n }\n\n /**\n * Register (or update) a field's validation config.\n *\n * @param owner Identity holding the registration — pass the same value to\n * {@link unregisterField} to release it. Field components pass themselves,\n * so two components bound to one path each hold their own claim.\n */\n registerField(\n path: string,\n config: ValidationConfig,\n owner: object = MANUAL_OWNER,\n ): void {\n const owners = this.fieldOwners.get(path);\n if (owners) owners.add(owner);\n else this.fieldOwners.set(path, new Set([owner]));\n\n const prev = untracked(this._fieldConfigs);\n const existing = prev[path];\n if (existing && validationConfigEqual(existing, config)) return;\n this._fieldConfigs.set({ ...prev, [path]: config });\n }\n\n /**\n * Release one owner's registration of a field. The config and validation\n * state survive while another owner still holds the path; once the last\n * one lets go, `validateAll` stops seeing the field.\n */\n unregisterField(path: string, owner: object = MANUAL_OWNER): void {\n const owners = this.fieldOwners.get(path);\n if (!owners) return;\n owners.delete(owner);\n if (owners.size > 0) return;\n\n this.fieldOwners.delete(path);\n const prev = untracked(this._fieldConfigs);\n if (path in prev) {\n const { [path]: _removed, ...rest } = prev;\n this._fieldConfigs.set(rest);\n }\n this.clear(path);\n }\n\n /** Validate a single field and record the result. */\n validate(path: string, config: ValidationConfig): ValidationResult {\n const currentState = this.state.getSnapshot();\n // The store's own pointer walk, so `~1` and `~0` mean what they mean\n // everywhere else a path is read.\n const value = getByPath(currentState, path);\n const result = runValidation(config, {\n value,\n stateModel: currentState,\n customFunctions: this.customFunctions,\n });\n\n const prev = untracked(this._fieldStates);\n this._fieldStates.set({\n ...prev,\n [path]: {\n touched: prev[path]?.touched ?? true,\n validated: true,\n result,\n },\n });\n\n return result;\n }\n\n /** Mark a field as touched. */\n touch(path: string): void {\n const prev = untracked(this._fieldStates);\n this._fieldStates.set({\n ...prev,\n [path]: {\n ...prev[path],\n touched: true,\n validated: prev[path]?.validated ?? false,\n result: prev[path]?.result ?? null,\n },\n });\n }\n\n /** Clear a field's validation state. */\n clear(path: string): void {\n const { [path]: _, ...rest } = untracked(this._fieldStates);\n this._fieldStates.set(rest);\n }\n\n /** Validate all registered fields. Returns whether all are valid. */\n validateAll(): boolean {\n let allValid = true;\n for (const [path, config] of Object.entries(\n untracked(this._fieldConfigs),\n )) {\n const result = this.validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n return allValid;\n }\n}\n\n/** Inject the validation service of the nearest `<json-render>` renderer. */\nexport function injectValidation(): JsonRenderValidationService {\n return inject(JsonRenderValidationService);\n}\n\n/**\n * Field-level validation helper for catalog input components: registers the\n * config and exposes the field's validation state as signals.\n *\n * The registration follows the component: it moves when the bound path\n * changes and is released when the component is destroyed, so a field that\n * has left the screen no longer takes part in `validateForm`.\n */\nexport function injectFieldValidation(\n path: string | (() => string),\n config?: ValidationConfig | (() => ValidationConfig | undefined),\n): {\n state: Signal<FieldValidationState>;\n validate: () => ValidationResult;\n touch: () => void;\n clear: () => void;\n errors: Signal<string[]>;\n isValid: Signal<boolean>;\n} {\n const validation = injectValidation();\n const getPath = typeof path === 'function' ? path : () => path;\n const getConfig = typeof config === 'function' ? config : () => config;\n\n // Identity of this field's claim on a path. Two components bound to the\n // same path hold separate claims, so one being destroyed does not\n // deregister the other.\n const owner: object = {};\n let registeredPath: string | null = null;\n\n effect(() => {\n const p = getPath();\n const c = getConfig();\n const next = p && c ? p : null;\n if (registeredPath !== null && registeredPath !== next) {\n validation.unregisterField(registeredPath, owner);\n registeredPath = null;\n }\n if (next && c) {\n validation.registerField(next, c, owner);\n registeredPath = next;\n }\n });\n\n inject(DestroyRef).onDestroy(() => {\n if (registeredPath === null) return;\n validation.unregisterField(registeredPath, owner);\n registeredPath = null;\n });\n\n const state = computed<FieldValidationState>(() => {\n const current = validation.fieldStates()[getPath()];\n return current ?? { touched: false, validated: false, result: null };\n });\n\n return {\n state,\n validate: () =>\n validation.validate(getPath(), getConfig() ?? { checks: [] }),\n touch: () => validation.touch(getPath()),\n clear: () => validation.clear(getPath()),\n errors: computed(() => state().result?.errors ?? []),\n isValid: computed(() => state().result?.valid ?? true),\n };\n}\n","import {\n Injectable,\n type Signal,\n computed,\n inject,\n signal,\n untracked,\n} from '@angular/core';\nimport {\n type ActionBinding,\n type ActionHandler,\n type ResolvedAction,\n executeAction,\n nextActionDispatchId,\n notifyActionDispatch,\n notifyActionSettle,\n resolveAction,\n} from '@json-render/core';\nimport { JsonRenderRootContext } from './root-context';\nimport { JsonRenderStateService } from './state.service';\nimport { JsonRenderValidationService } from './validation.service';\n\nlet idCounter = 0;\nfunction generateUniqueId(): string {\n idCounter += 1;\n return `${Date.now()}-${idCounter}`;\n}\n\nfunction deepResolveValue(\n value: unknown,\n get: (path: string) => unknown,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (value === '$id') {\n return generateUniqueId();\n }\n\n if (typeof value === 'object' && !Array.isArray(value)) {\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj);\n\n if (keys.length === 1 && typeof obj['$state'] === 'string') {\n return get(obj['$state'] as string);\n }\n\n if (keys.length === 1 && '$id' in obj) {\n return generateUniqueId();\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => deepResolveValue(item, get));\n }\n\n if (typeof value === 'object') {\n const resolved: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n resolved[key] = deepResolveValue(val, get);\n }\n return resolved;\n }\n\n return value;\n}\n\nexport interface PendingConfirmation {\n action: ResolvedAction;\n handler: ActionHandler;\n resolve: () => void;\n reject: () => void;\n}\n\n/**\n * Rejection produced when the user dismisses an action's confirmation dialog.\n * Carries a stable `name` so callers can tell a cancellation apart from a\n * handler failure without matching on the message.\n *\n * @internal Not part of the public API; use {@link isActionCancelled}.\n */\nexport class ActionCancelledError extends Error {\n constructor() {\n super('Action cancelled');\n this.name = 'ActionCancelledError';\n }\n}\n\n/** True for the rejection produced by cancelling a confirmation dialog. */\nexport function isActionCancelled(error: unknown): boolean {\n return error instanceof Error && error.name === 'ActionCancelledError';\n}\n\n/**\n * Action dispatcher of a `<json-render>` subtree.\n *\n * Executes {@link ActionBinding}s: built-in actions (`setState`, `pushState`,\n * `removeState`, `push`, `pop`, `validateForm`, `submitForm`) are handled\n * internally; everything else is routed to the host-provided `handlers` (or\n * the `onAction` catch-all), honoring `confirm`, `onSuccess`, and `onError`.\n */\n@Injectable()\nexport class JsonRenderActionsService {\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n private readonly validation = inject(JsonRenderValidationService, {\n optional: true,\n });\n\n private readonly extraHandlers = signal<Record<string, ActionHandler>>({});\n private readonly _loadingActions = signal<ReadonlySet<string>>(new Set());\n private readonly _pendingConfirmation = signal<PendingConfirmation | null>(\n null,\n );\n\n /** Names of actions currently executing. */\n readonly loadingActions: Signal<ReadonlySet<string>> =\n this._loadingActions.asReadonly();\n\n /** The confirmation currently awaiting user input, if any. */\n readonly pendingConfirmation: Signal<PendingConfirmation | null> =\n this._pendingConfirmation.asReadonly();\n\n /** All registered handlers (host handlers + runtime registrations). */\n get handlers(): Record<string, ActionHandler> {\n return {\n ...(untracked(this.root.handlers) ?? {}),\n ...untracked(this.extraHandlers),\n };\n }\n\n /** Register an additional action handler at runtime. */\n registerHandler(name: string, handler: ActionHandler): void {\n this.extraHandlers.set({\n ...untracked(this.extraHandlers),\n [name]: handler,\n });\n }\n\n /** Execute an action binding. */\n async execute(binding: ActionBinding): Promise<void> {\n const resolved = resolveAction(binding, this.state.getSnapshot());\n const get = (path: string) => this.state.get(path);\n const set = (path: string, value: unknown) => this.state.set(path, value);\n\n // --- devtools / observer hooks ---\n const dispatchId = nextActionDispatchId();\n const dispatchedAt = Date.now();\n notifyActionDispatch({\n id: dispatchId,\n name: resolved.action,\n params: resolved.params,\n at: dispatchedAt,\n });\n let ok = true;\n let error: unknown = undefined;\n\n try {\n if (resolved.action === 'setState' && resolved.params) {\n const statePath = resolved.params['statePath'] as string;\n const value = resolved.params['value'];\n if (statePath) {\n set(statePath, value);\n }\n return;\n }\n\n if (resolved.action === 'pushState' && resolved.params) {\n const statePath = resolved.params['statePath'] as string;\n const rawValue = resolved.params['value'];\n if (statePath) {\n const resolvedValue = deepResolveValue(rawValue, get);\n const arr = (get(statePath) as unknown[] | undefined) ?? [];\n set(statePath, [...arr, resolvedValue]);\n const clearStatePath = resolved.params['clearStatePath'] as\n string | undefined;\n if (clearStatePath) {\n set(clearStatePath, '');\n }\n }\n return;\n }\n\n if (resolved.action === 'removeState' && resolved.params) {\n const statePath = resolved.params['statePath'] as string;\n const index = resolved.params['index'] as number;\n if (statePath !== undefined && index !== undefined) {\n const arr = (get(statePath) as unknown[] | undefined) ?? [];\n set(\n statePath,\n arr.filter((_, i) => i !== index),\n );\n }\n return;\n }\n\n if (resolved.action === 'push' && resolved.params) {\n const screen = resolved.params['screen'] as string;\n if (screen) {\n const currentScreen = get('/currentScreen') as string | undefined;\n const navStack = (get('/navStack') as string[] | undefined) ?? [];\n if (currentScreen) {\n set('/navStack', [...navStack, currentScreen]);\n } else {\n set('/navStack', [...navStack, '']);\n }\n set('/currentScreen', screen);\n }\n return;\n }\n\n if (resolved.action === 'pop') {\n const navStack = (get('/navStack') as string[] | undefined) ?? [];\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', undefined);\n }\n }\n return;\n }\n\n if (resolved.action === 'validateForm') {\n if (this.checkForm(resolved) === null) {\n console.warn(\n 'validateForm action was dispatched but no JsonRenderValidationService is available.',\n );\n }\n return;\n }\n\n if (resolved.action === 'submitForm') {\n const valid = this.checkForm(resolved);\n if (valid === null) {\n console.warn(\n 'submitForm action was dispatched but no JsonRenderValidationService is available; nothing was submitted.',\n );\n return;\n }\n // An invalid form stops here, with the errors already written to\n // state and every field marked validated, so they are on screen.\n if (!valid) return;\n\n const target = resolved.params?.['action'];\n if (typeof target !== 'string' || !target) {\n console.warn(\n 'submitForm needs the action to submit to: { \"action\": \"submitForm\", \"params\": { \"action\": \"saveUser\" } }.',\n );\n return;\n }\n\n // Dispatched, not called directly, so the submitted action goes\n // through the same lookup, confirmation, loading state and observers\n // as any other — submitForm gates it, it does not replace it.\n await this.execute({\n action: target,\n params: deepResolveValue(resolved.params?.['params'], get) as\n Record<string, unknown> | undefined,\n confirm: resolved.confirm,\n onSuccess: resolved.onSuccess,\n onError: resolved.onError,\n });\n return;\n }\n\n const handler = this.lookupHandler(resolved.action);\n\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.action}`);\n return;\n }\n\n if (resolved.confirm) {\n // One question at a time: a confirm arriving while another is open\n // cancels that one, so its caller settles instead of waiting forever.\n untracked(this._pendingConfirmation)?.reject();\n // Awaited, not returned: a returned promise would let the `finally`\n // below settle the observers before the user has even answered.\n await new Promise<void>((resolve, reject) => {\n const pending: PendingConfirmation = {\n action: resolved,\n handler,\n resolve: () => this.answer(pending, resolve),\n reject: () =>\n this.answer(pending, () => reject(new ActionCancelledError())),\n };\n this._pendingConfirmation.set(pending);\n });\n }\n\n await this.runHandler(resolved, handler);\n } catch (err) {\n ok = false;\n error = err;\n throw err;\n } finally {\n const now = Date.now();\n notifyActionSettle({\n id: dispatchId,\n name: resolved.action,\n ok,\n at: now,\n durationMs: now - dispatchedAt,\n error,\n });\n }\n }\n\n /** Confirm the pending confirmation dialog. */\n confirm(): void {\n untracked(this._pendingConfirmation)?.resolve();\n }\n\n /** Cancel the pending confirmation dialog. */\n cancel(): void {\n untracked(this._pendingConfirmation)?.reject();\n }\n\n /**\n * Close `pending` and run `settle`, but only while it is still the open\n * question: a late answer to one that was replaced must not close its\n * successor.\n */\n private answer(pending: PendingConfirmation, settle: () => void): void {\n if (untracked(this._pendingConfirmation) !== pending) return;\n this._pendingConfirmation.set(null);\n settle();\n }\n\n /**\n * Validate every registered field and write `{ valid, errors }` to the\n * action's `statePath` (default `/formValidation`). Returns null when there\n * is no validation service to ask.\n *\n * Shared by `validateForm` and `submitForm`: the two must report the same\n * thing about the same form, and one implementation is how that stays true.\n */\n private checkForm(resolved: ResolvedAction): boolean | null {\n if (!this.validation) return null;\n\n const valid = this.validation.validateAll();\n const errors: Record<string, string[]> = {};\n for (const [path, fieldState] of Object.entries(\n untracked(this.validation.fieldStates),\n )) {\n if (fieldState.result && !fieldState.result.valid) {\n errors[path] = fieldState.result.errors;\n }\n }\n const statePath =\n (resolved.params?.['statePath'] as string) || '/formValidation';\n this.state.set(statePath, { valid, errors });\n return valid;\n }\n\n private lookupHandler(name: string): ActionHandler | undefined {\n const direct = this.handlers[name];\n if (direct) return direct;\n // Catch-all: route unknown actions to the `onAction` input when provided.\n const onAction = untracked(this.root.onAction);\n if (onAction) {\n return (params) => onAction(name, params);\n }\n return undefined;\n }\n\n private async runHandler(\n resolved: ResolvedAction,\n handler: ActionHandler,\n ): Promise<void> {\n this._loadingActions.set(\n new Set(untracked(this._loadingActions)).add(resolved.action),\n );\n try {\n await executeAction({\n action: resolved,\n handler,\n setState: (path, value) => this.state.set(path, value),\n navigate: untracked(this.root.navigate) ?? undefined,\n executeAction: async (binding) => {\n await this.execute(binding);\n },\n });\n } finally {\n const next = new Set(untracked(this._loadingActions));\n next.delete(resolved.action);\n this._loadingActions.set(next);\n }\n }\n}\n\n/** Inject the actions service of the nearest `<json-render>` renderer. */\nexport function injectActions(): JsonRenderActionsService {\n return inject(JsonRenderActionsService);\n}\n\n/**\n * Convenience helper for executing a fixed action binding, mirroring\n * `useAction` from the other renderers.\n */\nexport function injectAction(binding: ActionBinding): {\n execute: () => Promise<void>;\n isLoading: Signal<boolean>;\n} {\n const actions = injectActions();\n return {\n execute: () => actions.execute(binding),\n isLoading: computed(() => actions.loadingActions().has(binding.action)),\n };\n}\n","import { InjectionToken, type Type, inject } from '@angular/core';\nimport type { ActionConfirm } from '@json-render/core';\n\n/** The two words the confirmation dialog says on its own. */\nexport interface ConfirmLabels {\n confirm: string;\n cancel: string;\n}\n\n/**\n * Labels for the default confirmation dialog's buttons, when the spec does not\n * supply `confirmLabel` / `cancelLabel` of its own.\n *\n * They are the only strings this package puts on screen, and they were English\n * with no way to change them. Override once, in an app's providers:\n *\n * ```ts\n * { provide: JR_CONFIRM_LABELS, useValue: { confirm: 'Подтвердить', cancel: 'Отмена' } }\n * ```\n */\nexport const JR_CONFIRM_LABELS = new InjectionToken<ConfirmLabels>(\n 'ngx-json-render JR_CONFIRM_LABELS',\n {\n providedIn: 'root',\n factory: () => ({ confirm: 'Confirm', cancel: 'Cancel' }),\n },\n);\n\n/**\n * Everything a replacement confirmation dialog is given: the config the spec\n * asked for, and the two ways to answer it. Inject it with\n * {@link injectConfirmContext}.\n */\nexport interface ConfirmContext {\n /** Title, message, labels and variant, straight from the action binding. */\n readonly config: ActionConfirm;\n /** Let the action proceed. */\n readonly confirm: () => void;\n /** Dismiss it — a normal answer, not a failure. */\n readonly cancel: () => void;\n}\n\n/** The confirmation a replacement dialog component is rendered for. */\nexport const CONFIRM_CONTEXT = new InjectionToken<ConfirmContext>(\n 'ngx-json-render CONFIRM_CONTEXT',\n);\n\n/**\n * The component `<json-render>` should render for a `confirm` on an action.\n * Unset means the packaged {@link JrConfirmDialog}.\n *\n * The component is rendered with a {@link CONFIRM_CONTEXT} in its injector, so\n * it takes no inputs and emits no outputs:\n *\n * ```ts\n * @Component({ template: `<my-modal (ok)=\"ctx.confirm()\" (dismiss)=\"ctx.cancel()\">…` })\n * export class AppConfirm {\n * readonly ctx = injectConfirmContext();\n * }\n * // providers: [{ provide: JR_CONFIRM_DIALOG, useValue: AppConfirm }]\n * ```\n */\nexport const JR_CONFIRM_DIALOG = new InjectionToken<Type<unknown>>(\n 'ngx-json-render JR_CONFIRM_DIALOG',\n);\n\n/** Inject the confirmation a replacement dialog component is rendering for. */\nexport function injectConfirmContext(): ConfirmContext {\n const ctx = inject(CONFIRM_CONTEXT, { optional: true });\n if (!ctx) {\n throw new Error(\n 'injectConfirmContext() must be used inside a component provided through JR_CONFIRM_DIALOG',\n );\n }\n return ctx;\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n type ElementRef,\n afterNextRender,\n computed,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport type { ActionConfirm } from '@json-render/core';\nimport { JR_CONFIRM_LABELS } from './confirm-tokens';\n\nlet dialogIdCounter = 0;\n\n/**\n * Default confirmation dialog shown for action bindings with a `confirm`\n * field. Rendered automatically by `<json-render>`; can also be used\n * standalone with a custom action flow.\n *\n * It is a real dialog: `role=\"dialog\"` with `aria-modal`, labelled by its own\n * title and described by its message, focus moved in on open and returned to\n * wherever it came from on close, Tab kept inside it and Escape cancelling.\n * A generated UI can ask for confirmation of something destructive, so a\n * keyboard or screen-reader user has to be able to answer it.\n *\n * Colours come from CSS custom properties with light and dark defaults, so an\n * app can theme it — `--jr-confirm-surface`, `--jr-confirm-ink`,\n * `--jr-confirm-muted`, `--jr-confirm-border`, `--jr-confirm-scrim`,\n * `--jr-confirm-accent`, `--jr-confirm-danger`, `--jr-confirm-on-accent`,\n * `--jr-confirm-radius` — and replace it outright through\n * {@link JR_CONFIRM_DIALOG} when that is not enough.\n */\n@Component({\n selector: 'jr-confirm-dialog',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '(keydown.escape)': 'cancelled.emit()',\n },\n template: `\n <div class=\"jr-confirm-scrim\" (click)=\"cancelled.emit()\">\n <div\n class=\"jr-confirm-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-describedby]=\"messageId\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event)\"\n >\n <h3 class=\"jr-confirm-title\" [id]=\"titleId\">{{ config().title }}</h3>\n <p class=\"jr-confirm-message\" [id]=\"messageId\">{{ config().message }}</p>\n <div class=\"jr-confirm-actions\">\n <button #cancel type=\"button\" class=\"jr-confirm-cancel\" (click)=\"cancelled.emit()\">\n {{ config().cancelLabel ?? labels.cancel }}\n </button>\n <button\n #confirm\n type=\"button\"\n class=\"jr-confirm-confirm\"\n [class.jr-confirm-danger]=\"isDanger()\"\n (click)=\"confirmed.emit()\"\n >\n {{ config().confirmLabel ?? labels.confirm }}\n </button>\n </div>\n </div>\n </div>\n `,\n styles: `\n :host {\n --jr-confirm-scrim-default: rgba(0, 0, 0, 0.5);\n --jr-confirm-surface-default: #ffffff;\n --jr-confirm-ink-default: #111827;\n --jr-confirm-muted-default: #6b7280;\n --jr-confirm-border-default: #d1d5db;\n --jr-confirm-accent-default: #3b82f6;\n --jr-confirm-danger-default: #dc2626;\n --jr-confirm-on-accent-default: #ffffff;\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --jr-confirm-scrim-default: rgba(0, 0, 0, 0.65);\n --jr-confirm-surface-default: #1f2937;\n --jr-confirm-ink-default: #f3f4f6;\n --jr-confirm-muted-default: #9ca3af;\n --jr-confirm-border-default: #4b5563;\n --jr-confirm-accent-default: #60a5fa;\n --jr-confirm-danger-default: #f87171;\n --jr-confirm-on-accent-default: #111827;\n }\n }\n\n .jr-confirm-scrim {\n position: fixed;\n inset: 0;\n z-index: 50;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: var(--jr-confirm-scrim, var(--jr-confirm-scrim-default));\n }\n\n .jr-confirm-panel {\n width: 100%;\n max-width: 400px;\n padding: 24px;\n border-radius: var(--jr-confirm-radius, 8px);\n background-color: var(--jr-confirm-surface, var(--jr-confirm-surface-default));\n color: var(--jr-confirm-ink, var(--jr-confirm-ink-default));\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);\n }\n\n .jr-confirm-title {\n margin: 0 0 8px 0;\n font-size: 18px;\n font-weight: 600;\n }\n\n .jr-confirm-message {\n margin: 0 0 24px 0;\n color: var(--jr-confirm-muted, var(--jr-confirm-muted-default));\n }\n\n .jr-confirm-actions {\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n }\n\n .jr-confirm-actions button {\n padding: 8px 16px;\n border-radius: 6px;\n font: inherit;\n cursor: pointer;\n }\n\n .jr-confirm-cancel {\n border: 1px solid var(--jr-confirm-border, var(--jr-confirm-border-default));\n background-color: transparent;\n color: inherit;\n }\n\n .jr-confirm-confirm {\n border: none;\n background-color: var(--jr-confirm-accent, var(--jr-confirm-accent-default));\n color: var(--jr-confirm-on-accent, var(--jr-confirm-on-accent-default));\n }\n\n .jr-confirm-confirm.jr-confirm-danger {\n background-color: var(--jr-confirm-danger, var(--jr-confirm-danger-default));\n }\n `,\n})\nexport class JrConfirmDialog {\n readonly config = input.required<ActionConfirm>();\n readonly confirmed = output<void>();\n readonly cancelled = output<void>();\n\n protected readonly labels = inject(JR_CONFIRM_LABELS);\n\n private readonly id = dialogIdCounter++;\n protected readonly titleId = `jr-confirm-title-${this.id}`;\n protected readonly messageId = `jr-confirm-message-${this.id}`;\n\n private readonly cancelButton =\n viewChild<ElementRef<HTMLButtonElement>>('cancel');\n private readonly confirmButton =\n viewChild<ElementRef<HTMLButtonElement>>('confirm');\n\n protected readonly isDanger = computed(\n () => this.config().variant === 'danger',\n );\n\n constructor() {\n // Whatever was focused when the action fired — usually the control that\n // dispatched it, which is still in the document behind the dialog.\n const previous =\n typeof document !== 'undefined'\n ? (document.activeElement as HTMLElement | null)\n : null;\n\n // Cancel takes focus rather than confirm: a dialog exists to interrupt,\n // and landing on the destructive answer makes a stray Enter destructive.\n afterNextRender(() => this.cancelButton()?.nativeElement.focus());\n\n inject(DestroyRef).onDestroy(() => previous?.focus?.());\n }\n\n /**\n * Keep Tab inside the dialog. With exactly two buttons the whole trap is\n * wrapping the ends; a modal that lets focus wander behind it is a modal\n * only for people using a mouse.\n */\n protected onKeydown(event: KeyboardEvent): void {\n if (event.key !== 'Tab') return;\n const cancel = this.cancelButton()?.nativeElement;\n const confirm = this.confirmButton()?.nativeElement;\n if (!cancel || !confirm) return;\n\n const active = event.target;\n if (event.shiftKey && active === cancel) {\n event.preventDefault();\n confirm.focus();\n } else if (!event.shiftKey && active === confirm) {\n event.preventDefault();\n cancel.focus();\n }\n }\n}\n","import { DestroyRef, type Signal, inject, signal } from '@angular/core';\nimport { isDevtoolsActive, subscribeDevtoolsActive } from '@json-render/core';\n\n/**\n * Reactive mirror of the json-render devtools-active flag. When active, the\n * renderer wraps each element with a `data-jr-key` attribute for the picker.\n */\nexport function injectDevtoolsActive(): Signal<boolean> {\n const active = signal(isDevtoolsActive());\n const unsubscribe = subscribeDevtoolsActive(() =>\n active.set(isDevtoolsActive()),\n );\n inject(DestroyRef).onDestroy(unsubscribe);\n return active.asReadonly();\n}\n","import type { Spec, SpecIssue, UIElement } from '@json-render/core';\n\n/**\n * Caps on what a spec is allowed to cost the browser.\n *\n * A spec is attacker-shaped input: whatever produced one chose its own size,\n * its own nesting and — through `repeat` — its own array lengths. These are\n * the three of those the renderer can enforce for you.\n *\n * Every field is opt-in and unset means unlimited. There are no defaults\n * because no single number is right for every catalog, and a default would\n * change what an existing app renders the moment it upgraded.\n *\n * Limits are enforced whenever they are set, whatever `validate` is: a number\n * the app chose is a control, not advice. What \"enforced\" means differs by\n * limit, because the limits differ in kind — see each field.\n *\n * @example\n * ```html\n * <json-render\n * [spec]=\"spec()\"\n * [registry]=\"registry\"\n * [renderLimits]=\"{ maxElements: 500, maxDepth: 16, maxRepeatItems: 200 }\"\n * />\n * ```\n */\nexport interface RenderLimits {\n /**\n * Most elements a spec may contain. A spec over the cap does not render at\n * all: element count is a property of the whole spec, and there is no\n * meaningful \"first 500 elements\" of a graph.\n */\n readonly maxElements?: number;\n /**\n * Deepest the render tree may nest, counting the root as 1. An element\n * below the cap does not render, and neither does anything under it; what\n * fits still renders. Reported as an error, so `validate=\"strict\"` refuses\n * the spec outright rather than truncating it.\n *\n * A capped element does not act either — its `watch` stays unwired, so it\n * cannot dispatch actions from behind the cap.\n */\n readonly maxDepth?: number;\n /**\n * Most items one `repeat` may expand. The surplus items do not render.\n *\n * Enforced at render time only: `repeat` iterates a live state array, so no\n * amount of inspecting the spec can predict how long it will be. Nested\n * repeats multiply, so this is a per-repeat cap, not a total.\n */\n readonly maxRepeatItems?: number;\n}\n\n/**\n * Issue codes this package reports, widening core's set with the ones only a\n * renderer can find.\n *\n * - `cycle` — an element renders itself against the same data, which cannot\n * terminate. A tree that recurses into its items is not this.\n * - `too_deep` / `too_many_elements` — a {@link RenderLimits} cap was passed.\n * - `unknown_component` — a `type` the catalog does not define.\n * - `invalid_props` — an element's props fail its component's schema, or the\n * element fails the catalog's spec schema: a missing `children`, say.\n */\nexport type SpecCheckIssueCode =\n | SpecIssue['code']\n | 'cycle'\n | 'too_deep'\n | 'too_many_elements'\n | 'unknown_component'\n | 'invalid_props';\n\n/**\n * A problem found in a spec. Core's {@link SpecIssue} widened with the codes\n * above, so a {@link SpecIssue} is always one of these.\n */\nexport interface SpecCheckIssue {\n readonly severity: 'error' | 'warning';\n readonly message: string;\n readonly elementKey?: string;\n readonly code: SpecCheckIssueCode;\n}\n\n/**\n * The part of a json-render `Catalog` the check needs.\n *\n * Structural on purpose: a real catalog satisfies it, and the renderer stays\n * free of any dependency on the schema library behind `validate`.\n */\nexport interface SpecCatalog {\n /** Component type names the catalog defines. */\n readonly componentNames: readonly string[];\n /** Check a spec against the catalog's own schema. */\n validate(spec: unknown): {\n readonly success: boolean;\n readonly error?: unknown;\n };\n /**\n * The definitions the catalog was created from. Where\n * `data.components[type].props` is a schema — anything with a `safeParse`,\n * as a Zod schema has — each element's props are checked against its own\n * component's. Without it, props are checked only as far as `validate`\n * checks them, which for a catalog of more than one component is not at\n * all.\n *\n * `unknown` rather than that shape, so that a `Catalog` whose generic\n * arguments were left off — and whose `data` is therefore `unknown` — still\n * fits.\n */\n readonly data?: unknown;\n}\n\n/** The part of a props schema the check calls: what a Zod schema has. */\ninterface PropsSchema {\n safeParse(value: unknown): {\n readonly success: boolean;\n readonly error?: unknown;\n };\n}\n\n/** One complaint from a schema, at a path into the value it was given. */\ninterface SchemaIssue {\n readonly path: readonly unknown[];\n readonly message: string;\n}\n\n/** What one walk of the element graph found. */\nexport interface SpecGraph {\n /** Nesting depth from `spec.root`, counting the root as 1. */\n readonly depth: number;\n /**\n * Keys that close a cycle which cannot terminate. A back edge that\n * descends into repeat items is not one of these.\n */\n readonly cycles: readonly string[];\n}\n\n/**\n * A hostile spec can fail the catalog's schema in as many places as it has\n * properties. Report enough to act on and stop; the spec is refused either\n * way, and a console full of them helps nobody.\n */\nconst MAX_REPORTED_PROP_ISSUES = 20;\n\n/**\n * Whether this element's `repeat` descends into the item it is already inside,\n * rather than re-reading a fixed path in state.\n *\n * A relative statePath — `{\"$item\": \"children\"}` — resolves against the\n * enclosing item, so each pass reads one level further into the data and the\n * recursion ends where the data does. A plain string is absolute: every pass\n * reads the same array, and a spec that re-enters itself through one never\n * terminates.\n */\nfunction descendsIntoItems(element: UIElement): boolean {\n const repeat = element.repeat;\n return repeat !== undefined && typeof repeat.statePath !== 'string';\n}\n\n/** Every key an element renders below itself: `children` plus every slot. */\nfunction childKeysOf(element: UIElement): readonly string[] {\n const slots = element.slots;\n if (!slots) return element.children ?? [];\n const fromSlots = Object.values(slots).flat();\n return element.children ? [...element.children, ...fromSlots] : fromSlots;\n}\n\ninterface Frame {\n readonly key: string;\n readonly kids: readonly string[];\n next: number;\n deepest: number;\n}\n\n/**\n * Walk the element graph once for depth and cycles.\n *\n * Iterative on purpose. A recursive walk would blow the stack on exactly the\n * specs this exists to catch, which would make the guard a second way to\n * crash rather than the fix for the first.\n *\n * Depth is measured from `spec.root`, because that is what renders. Cycles\n * are swept for across every element, including the ones no parent reaches:\n * an unreachable cycle is still a defect, and one edit away from a reachable\n * one.\n *\n * Not every element that reaches itself is a defect, though. Drawing a tree —\n * a comment thread, a file browser, a nested menu — means an element that\n * repeats over a relative path and renders itself for each item, and that ends\n * when the data does. A back edge is only reported when nothing along it\n * descends into the data, which is the case that cannot end.\n *\n * `depthBelow` is memoised per element, so a shared subtree costs one visit\n * instead of one per path into it — without that, a spec whose elements each\n * name the next two is exponential to check. The memo makes the reported\n * depth a lower bound once a cycle has been cut, since which edge closes the\n * cycle depends on the order the walk reached it. The cycle is reported as an\n * error of its own, which is the finding worth acting on.\n */\nexport function analyseSpecGraph(spec: Spec): SpecGraph {\n const elements = spec.elements ?? {};\n const cycles = new Set<string>();\n const depthBelow = new Map<string, number>();\n const onPath = new Set<string>();\n\n const walkFrom = (start: string): void => {\n const first = elements[start];\n if (!first || depthBelow.has(start)) return;\n\n const stack: Frame[] = [\n { key: start, kids: childKeysOf(first), next: 0, deepest: 0 },\n ];\n onPath.add(start);\n\n while (stack.length > 0) {\n const frame = stack[stack.length - 1]!;\n\n if (frame.next < frame.kids.length) {\n const childKey = frame.kids[frame.next++]!;\n const memo = depthBelow.get(childKey);\n if (memo !== undefined) {\n frame.deepest = Math.max(frame.deepest, memo);\n continue;\n }\n // A child that closes the cycle is not followed — that is what keeps\n // this walk finite — and not counted towards depth either.\n if (onPath.has(childKey)) {\n const from = stack.findIndex((frame) => frame.key === childKey);\n const descends = stack\n .slice(from)\n .some((frame) => descendsIntoItems(elements[frame.key]!));\n if (!descends) cycles.add(childKey);\n continue;\n }\n const child = elements[childKey];\n // A child the spec never defined is validateSpec's finding, not ours.\n if (!child) continue;\n onPath.add(childKey);\n stack.push({\n key: childKey,\n kids: childKeysOf(child),\n next: 0,\n deepest: 0,\n });\n continue;\n }\n\n stack.pop();\n onPath.delete(frame.key);\n const depth = frame.deepest + 1;\n depthBelow.set(frame.key, depth);\n const parent = stack[stack.length - 1];\n if (parent) parent.deepest = Math.max(parent.deepest, depth);\n }\n };\n\n if (spec.root) walkFrom(spec.root);\n const depth = (spec.root ? depthBelow.get(spec.root) : undefined) ?? 0;\n\n for (const key of Object.keys(elements)) walkFrom(key);\n\n return { depth, cycles: [...cycles] };\n}\n\n/** Report a cycle, naming the element that is its own descendant. */\nexport function cycleIssue(key: string): SpecCheckIssue {\n return {\n severity: 'error',\n code: 'cycle',\n elementKey: key,\n message: `Element \"${key}\" renders itself against the same data, which never terminates. The cycle is broken where it closes — the repeated element does not render a second time — but the spec cannot be drawn as written. A tree that recurses needs a repeat with a relative statePath, like {\"$item\": \"children\"}.`,\n };\n}\n\n/** Report a breached element-count cap. */\nexport function elementCountIssue(\n count: number,\n limit: number,\n): SpecCheckIssue {\n return {\n severity: 'error',\n code: 'too_many_elements',\n message: `Spec has ${count} elements, over the limit of ${limit}. Nothing is rendered: renderLimits.maxElements is a cap on the whole spec.`,\n };\n}\n\n/** Report a breached depth cap. */\nexport function depthIssue(depth: number, limit: number): SpecCheckIssue {\n return {\n severity: 'error',\n code: 'too_deep',\n message: `Spec nests ${depth} levels deep, over the limit of ${limit}. Elements below level ${limit} do not render.`,\n };\n}\n\n/**\n * Check a spec against a catalog: the component types it names, then the\n * catalog's spec schema, then each element's props against its own\n * component's schema.\n *\n * The props need that pass of their own. Core builds one schema for the whole\n * spec, and it gives an element's props a component's schema only when the\n * catalog has exactly one component; with more, every element's props are an\n * open record, whatever its `type`. So `catalog.validate` holds an element to\n * its shape — `children`, a `type` from the catalog — and not to its props.\n *\n * Whatever that schema did say about the props of an element checked here is\n * dropped: with a one-component catalog it would be reported twice, and it\n * judges expressions this pass knows to leave alone.\n *\n * The schema passes are skipped while a type is unknown. That is an error on\n * its own, and the spec schema would only restate it as a `type` outside the\n * ones it accepts.\n */\nexport function catalogIssues(\n spec: Spec,\n catalog: SpecCatalog,\n): SpecCheckIssue[] {\n const elements = Object.entries(spec.elements ?? {});\n const known = new Set(catalog.componentNames);\n\n const unknown: SpecCheckIssue[] = [];\n for (const [key, element] of elements) {\n if (known.has(element.type)) continue;\n unknown.push({\n severity: 'error',\n code: 'unknown_component',\n elementKey: key,\n message: `Element \"${key}\" has type \"${element.type}\", which this catalog does not define. Nothing renders for it.`,\n });\n }\n if (unknown.length > 0) return unknown;\n\n const schemas = new Map<string, PropsSchema>();\n for (const [key, element] of elements) {\n const schema = propsSchemaOf(catalog.data, element.type);\n if (schema) schemas.set(key, schema);\n }\n\n const found = specSchemaIssues(spec, catalog).filter(\n ({ path }) =>\n !(\n path[0] === 'elements' &&\n typeof path[1] === 'string' &&\n schemas.has(path[1]) &&\n path[2] === 'props'\n ),\n );\n for (const [key, element] of elements) {\n const room = MAX_REPORTED_PROP_ISSUES - found.length;\n if (room <= 0) break;\n const schema = schemas.get(key);\n if (schema) found.push(...propsIssues(key, element, schema, room));\n }\n\n return found.slice(0, MAX_REPORTED_PROP_ISSUES).map(toSpecCheckIssue);\n}\n\n/**\n * Whether an element's props have arrived: they pass its component's schema,\n * leaving out what the schema says about expressions, the same way\n * {@link catalogIssues} judges them. The renderer holds an element back on\n * this while the spec streams.\n *\n * The props are taken as written in the spec, not as resolved. What a stream\n * leaves out is spec, and an expression that is there has arrived, whatever\n * it resolves to; checking the spec also keeps state writes from re-running\n * the schema.\n *\n * True when the catalog declares no schema that can be called for the type:\n * there is nothing to wait for. False when the schema throws, or fails\n * without saying where — the element mounts once loading ends either way.\n */\nexport function propsArrived(\n element: UIElement,\n catalog: SpecCatalog,\n): boolean {\n const schema = propsSchemaOf(catalog.data, element.type);\n if (!schema) return true;\n const props = element.props ?? {};\n let result: ReturnType<PropsSchema['safeParse']>;\n try {\n result = schema.safeParse(props);\n } catch {\n return false;\n }\n if (result.success) return true;\n const issues = readIssues(result.error);\n return (\n issues.length > 0 &&\n issues.every(({ path }) => reachesExpression(props, path))\n );\n}\n\n/**\n * The props schema a catalog declares for a component type, if it declares\n * one that can be called.\n */\nfunction propsSchemaOf(data: unknown, type: string): PropsSchema | undefined {\n const components = (data as { components?: unknown } | null | undefined)\n ?.components;\n if (\n typeof components !== 'object' ||\n components === null ||\n !Object.hasOwn(components, type)\n ) {\n return undefined;\n }\n const props = (\n components as Record<string, { props?: unknown } | null | undefined>\n )[type]?.props;\n return typeof (props as Partial<PropsSchema> | null | undefined)\n ?.safeParse === 'function'\n ? (props as PropsSchema)\n : undefined;\n}\n\n/** What the catalog's spec schema reported, with paths rooted at the spec. */\nfunction specSchemaIssues(spec: Spec, catalog: SpecCatalog): SchemaIssue[] {\n try {\n const result = catalog.validate(spec);\n return result.success ? [] : readIssues(result.error);\n } catch (error) {\n return [{ path: [], message: threwMessage('the catalog schema', error) }];\n }\n}\n\n/**\n * What an element's component schema says about its props, leaving out what\n * it says about expressions, with paths rooted at the spec.\n *\n * A schema that throws counts as a rejection, not a crash. Real ones do:\n * `ValidationConfigSchema`, which every Material input's `validation` prop\n * uses, recurses through `enabled` and overflows the stack a thousand\n * `$and`s deep.\n */\nfunction propsIssues(\n key: string,\n element: UIElement,\n schema: PropsSchema,\n room: number,\n): SchemaIssue[] {\n const at = ['elements', key, 'props'];\n let result: ReturnType<PropsSchema['safeParse']>;\n try {\n result = schema.safeParse(element.props);\n } catch (error) {\n return [\n {\n path: at,\n message: threwMessage(`the \"${element.type}\" schema`, error),\n },\n ];\n }\n if (result.success) return [];\n\n const issues: SchemaIssue[] = [];\n for (const { path, message } of readIssues(result.error)) {\n if (issues.length >= room) break;\n if (reachesExpression(element.props, path)) continue;\n issues.push({ path: [...at, ...path], message });\n }\n return issues;\n}\n\n/**\n * Whether a props issue is about an expression: it sits on one, inside one,\n * or on a value holding one.\n *\n * `{\"$state\": \"/title\"}` where the schema wants a string is not a defect.\n * Core resolves every such value before the component sees it, so the schema\n * would be judging something that never renders. Any `$`-prefixed key counts\n * — directive names must start with `$`, and so would an expression added to\n * core later. A value merely holding one is left alone too, since a union or\n * a refinement over it ran on the unresolved value.\n *\n * The props object itself is not an expression: core resolves the values\n * inside it, never the object.\n */\nfunction reachesExpression(props: unknown, path: readonly unknown[]): boolean {\n let value = props;\n for (const segment of path) {\n if (typeof value !== 'object' || value === null) return false;\n value = (value as Record<PropertyKey, unknown>)[segment as PropertyKey];\n if (isExpression(value)) return true;\n }\n return holdsExpression(value);\n}\n\n/** A value core resolves at render time — or will, once it knows the key. */\nfunction isExpression(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value).some((key) => key.startsWith('$'))\n );\n}\n\n/**\n * Whether anything nested inside `value` is an expression.\n *\n * Iterative, and it remembers what it has seen, for the same reason as\n * {@link analyseSpecGraph}: props are as attacker-shaped as the rest of the\n * spec, and a check that overflowed or looped on them would be a second way\n * to crash.\n */\nfunction holdsExpression(value: unknown): boolean {\n const pending: unknown[] = [value];\n const seen = new Set<object>();\n while (pending.length > 0) {\n const current = pending.pop();\n if (typeof current !== 'object' || current === null) continue;\n if (seen.has(current)) continue;\n seen.add(current);\n for (const child of Object.values(current)) {\n if (isExpression(child)) return true;\n pending.push(child);\n }\n }\n return false;\n}\n\n/**\n * Read what a schema reported.\n *\n * Read defensively rather than typed against the schema library: the shape\n * below (`issues`, each with `path` and `message`) is what every version of\n * it has produced, and a renderer that threw while explaining a bad spec\n * would be the worse failure.\n */\nfunction readIssues(error: unknown): SchemaIssue[] {\n const raw = (error as { issues?: unknown } | null | undefined)?.issues;\n if (!Array.isArray(raw)) return [];\n\n return raw.map((entry): SchemaIssue => {\n const item = entry as { path?: unknown; message?: unknown } | null;\n const path = item?.path;\n const message = item?.message;\n return {\n path: Array.isArray(path) ? path : [],\n message: typeof message === 'string' ? message : 'is not valid',\n };\n });\n}\n\nfunction threwMessage(schema: string, error: unknown): string {\n const reason =\n error instanceof Error ? ` (${error.name}: ${error.message})` : '';\n return `${schema} threw instead of answering${reason}, so this counts as rejected`;\n}\n\nfunction toSpecCheckIssue({ path, message }: SchemaIssue): SpecCheckIssue {\n // Paths are rooted at the spec, so `elements.<key>.props.<prop>` names the\n // element in its second segment.\n const elementKey =\n path[0] === 'elements' && typeof path[1] === 'string' ? path[1] : undefined;\n const where = path.length > 0 ? path.map(String).join('.') : 'spec';\n return {\n severity: 'error',\n code: 'invalid_props',\n ...(elementKey === undefined ? {} : { elementKey }),\n message: `${where}: ${message}`,\n };\n}\n","import {\n type DirectiveRegistry,\n type UIElement,\n resolveRepeatStatePath,\n} from '@json-render/core';\n\n/**\n * The state paths an element's expressions can read, or `null` when that\n * can't be known from the spec.\n *\n * Worked out from the spec alone, before anything resolves, so that an element\n * can depend on those paths rather than on the whole state. The answer may\n * name more paths than a given resolution reads — both branches of a `$cond`,\n * say — but never fewer: a path left out would be a write the element misses,\n * and it would keep showing the old value with nothing in the console.\n *\n * `null` is the safe answer, and it is given whenever the spec holds something\n * this reader does not model:\n *\n * - a registered directive, whose `resolve` receives the whole context and may\n * read any path at all;\n * - a `$`-prefixed key it doesn't recognise, which is what an expression added\n * to core after this was written would look like;\n * - a read of the whole state (`''` or `'/'`), and a condition it can't parse.\n *\n * The walk mirrors core's `resolvePropValue` and `evaluateVisibility`, in the\n * same order, because the order decides which expression an object is.\n */\nexport function collectStateReads(\n element: UIElement,\n directives: DirectiveRegistry | undefined,\n repeatBasePath: string | undefined,\n): ReadonlySet<string> | null {\n const reader = new StateReader(directives, repeatBasePath);\n const understood =\n reader.condition(element.visible) &&\n Object.values(element.props ?? {}).every((value) => reader.value(value));\n return understood ? reader.paths : null;\n}\n\ntype Expression = Record<string, unknown>;\n\nfunction isObject(value: unknown): value is Expression {\n return typeof value === 'object' && value !== null;\n}\n\n/** Comparison operators a single condition may carry, as core reads them. */\nconst COMPARISONS = ['eq', 'neq', 'gt', 'gte', 'lt', 'lte'] as const;\n\nclass StateReader {\n readonly paths = new Set<string>();\n\n constructor(\n private readonly directives: DirectiveRegistry | undefined,\n private readonly repeatBasePath: string | undefined,\n ) {}\n\n /** A prop value. Returns false when it can read state this can't name. */\n value(value: unknown): boolean {\n if (!isObject(value)) return true;\n\n if (typeof value['$state'] === 'string') return this.state(value['$state']);\n if (typeof value['$item'] === 'string') return this.item(value['$item']);\n if ('$index' in value && value['$index'] === true) return true;\n // A two-way binding reads the path it writes back to.\n if (typeof value['$bindState'] === 'string') {\n return this.state(value['$bindState']);\n }\n if (typeof value['$bindItem'] === 'string') {\n return this.boundItem(value['$bindItem']);\n }\n if ('$cond' in value && '$then' in value && '$else' in value) {\n return (\n this.condition(value['$cond']) &&\n this.value(value['$then']) &&\n this.value(value['$else'])\n );\n }\n if (typeof value['$computed'] === 'string') {\n // The function is handed its resolved arguments and nothing else.\n const args = value['args'];\n return (\n !args || Object.values(Object(args)).every((arg) => this.value(arg))\n );\n }\n if (typeof value['$template'] === 'string') {\n return this.template(value['$template']);\n }\n\n if (Array.isArray(value)) return value.every((item) => this.value(item));\n\n if (this.directives) {\n for (const name of this.directives.keys()) {\n if (name in value) return false;\n }\n }\n for (const [key, entry] of Object.entries(value)) {\n if (key.startsWith('$') || !this.value(entry)) return false;\n }\n return true;\n }\n\n /** A `visible` condition, or the condition of a `$cond`. */\n condition(condition: unknown): boolean {\n if (condition === undefined || typeof condition === 'boolean') return true;\n if (Array.isArray(condition)) {\n return condition.every((single) => this.singleCondition(single));\n }\n if (!isObject(condition)) return false;\n for (const group of ['$and', '$or'] as const) {\n if (group in condition) {\n const children = condition[group];\n return (\n Array.isArray(children) &&\n children.every((child) => this.condition(child))\n );\n }\n }\n return this.singleCondition(condition);\n }\n\n private singleCondition(condition: unknown): boolean {\n if (!isObject(condition)) return false;\n let understood: boolean;\n if ('$index' in condition) {\n understood = true;\n } else if ('$item' in condition) {\n const item = condition['$item'];\n understood = typeof item === 'string' && this.item(item);\n } else {\n // Core reads `$state` here without checking it: anything but a string\n // path reads the whole state.\n const path = condition['$state'];\n understood = typeof path === 'string' && this.state(path);\n }\n // Core looks only at the first operator present. Reading all of them is\n // a superset of that.\n for (const operator of COMPARISONS) {\n const operand = condition[operator];\n if (isObject(operand) && typeof operand['$state'] === 'string') {\n understood = this.state(operand['$state']) && understood;\n }\n }\n return understood;\n }\n\n private template(template: string): boolean {\n for (const [, placeholder] of template.matchAll(/\\$\\{([^}]+)\\}/g)) {\n if (placeholder.startsWith('/')) {\n if (!this.state(placeholder)) return false;\n continue;\n }\n // Core tries the repeat item first and falls back to a state path of\n // the same name when the item has nothing there.\n if (!this.item(placeholder) || !this.state(`/${placeholder}`)) {\n return false;\n }\n }\n return true;\n }\n\n private state(path: string): boolean {\n if (path === '' || path === '/') return false;\n this.paths.add(path);\n return true;\n }\n\n /**\n * A `$bindItem`, joined the way core joins it — which is not quite how it\n * joins an `$item` read. Outside a repeat it resolves to nothing.\n */\n private boundItem(itemPath: string): boolean {\n if (this.repeatBasePath === undefined) return true;\n return this.state(\n itemPath === ''\n ? this.repeatBasePath\n : `${this.repeatBasePath}/${itemPath}`,\n );\n }\n\n /**\n * A read of the repeat item, as the state path it sits at. The item value\n * reaches the element on its own, but only as the same object when an\n * external store edits it in place, so the path is what notices the edit.\n */\n private item(itemPath: string): boolean {\n if (this.repeatBasePath === undefined) return true;\n const path = resolveRepeatStatePath(\n { $item: itemPath },\n this.repeatBasePath,\n );\n return path !== undefined && this.state(path);\n }\n}\n","import { InjectionToken, type Signal, inject, isDevMode } from '@angular/core';\nimport type { RenderContext, RenderPath, RepeatScope } from './types';\n\n/**\n * The render context of the element currently being rendered.\n * Provided by the renderer for every catalog component instance.\n */\nexport const RENDER_CONTEXT = new InjectionToken<RenderContext>(\n 'ngx-json-render RENDER_CONTEXT',\n);\n\n/**\n * The spec key of the element currently being rendered. Provided alongside\n * {@link RENDER_CONTEXT} for every catalog component instance.\n */\nexport const ELEMENT_KEY = new InjectionToken<Signal<string>>(\n 'ngx-json-render ELEMENT_KEY',\n);\n\n/**\n * The current repeat scope. Present only for elements rendered inside a\n * `repeat` block.\n */\nexport const REPEAT_SCOPE = new InjectionToken<RepeatScope>(\n 'ngx-json-render REPEAT_SCOPE',\n);\n\n/**\n * This element's position in the render tree. Provided by `<jr-element>` for\n * everything it renders below itself, so each element can see its own depth\n * and its own ancestry.\n *\n * @internal Not part of the public API: it exists so the renderer can refuse\n * to draw an element that is its own ancestor, and to enforce\n * `renderLimits.maxDepth`.\n */\nexport const RENDER_PATH = new InjectionToken<Signal<RenderPath>>(\n 'ngx-json-render RENDER_PATH',\n);\n\n/**\n * Whether an element that skipped a state write checks that it was right to:\n * that resolving it against the whole state would not give anything else.\n * On in dev mode, off in production.\n *\n * @internal Not part of the public API. The check calls `$computed`\n * functions again, so tests that count those calls turn it off.\n */\nexport const CHECK_SKIPPED_WRITES = new InjectionToken<boolean>(\n 'ngx-json-render CHECK_SKIPPED_WRITES',\n { providedIn: 'root', factory: () => isDevMode() },\n);\n\n/**\n * Inject the render context inside a catalog component.\n *\n * @example\n * ```ts\n * @Component({\n * selector: 'app-button',\n * template: `<button (click)=\"ctx.emit('press')\">{{ ctx.props().label }}</button>`,\n * })\n * export class ButtonComponent {\n * readonly ctx = injectRenderContext<{ label: string }>();\n * }\n * ```\n */\nexport function injectRenderContext<\n P = Record<string, unknown>,\n>(): RenderContext<P> {\n const ctx = inject(RENDER_CONTEXT, { optional: true });\n if (!ctx) {\n throw new Error(\n 'injectRenderContext() must be used inside a component rendered by <json-render>',\n );\n }\n return ctx as RenderContext<P>;\n}\n\n/**\n * Inject the spec key of the element this component renders.\n *\n * Catalog components that collect their children — a tab group discovering\n * its tabs, for instance — need it to order registrations by the spec's\n * `children` array rather than by the order the children happened to\n * announce themselves in.\n *\n * @example\n * ```ts\n * const key = injectElementKey();\n * const index = computed(() => parent.element().children?.indexOf(key()) ?? -1);\n * ```\n */\nexport function injectElementKey(): Signal<string> {\n const key = inject(ELEMENT_KEY, { optional: true });\n if (!key) {\n throw new Error(\n 'injectElementKey() must be used inside a component rendered by <json-render>',\n );\n }\n return key;\n}\n\n/**\n * Inject the current repeat scope, or `null` when the component is not\n * rendered inside a `repeat` block.\n */\nexport function injectRepeatScope(): RepeatScope | null {\n return inject(REPEAT_SCOPE, { optional: true });\n}\n","import { NgComponentOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n Injector,\n type Signal,\n computed,\n effect,\n inject,\n input,\n isDevMode,\n signal,\n untracked,\n} from '@angular/core';\nimport type {\n ActionBinding,\n PropResolutionContext,\n StateModel,\n UIElement,\n} from '@json-render/core';\nimport {\n evaluateVisibility,\n getByPath,\n resolveActionParam,\n resolveBindings,\n resolveElementProps,\n} from '@json-render/core';\nimport { JsonRenderActionsService, isActionCancelled } from './actions.service';\nimport { injectDevtoolsActive } from './devtools';\nimport { JsonRenderRootContext } from './root-context';\nimport { sameJson } from './same-json';\nimport { propsArrived } from './render-limits';\nimport { collectStateReads } from './state-reads';\nimport { JsonRenderStateService } from './state.service';\nimport {\n CHECK_SKIPPED_WRITES,\n ELEMENT_KEY,\n REPEAT_SCOPE,\n RENDER_CONTEXT,\n RENDER_PATH,\n} from './tokens';\nimport type { EventHandle, RenderContext, RenderPath } from './types';\n\nconst warnedSlots = new Set<string>();\n\n/**\n * Report a failure from a fire-and-forget action dispatch. Cancelling a\n * confirmation dialog is a normal outcome, not an error, so it stays silent.\n */\nfunction reportActionError(error: unknown): void {\n if (isActionCancelled(error)) return;\n console.error(error);\n}\n\n/**\n * Whether `inner` reads strictly deeper into state than `outer` — the state\n * path of one repeat item nested inside another's.\n *\n * `null` is the world outside any repeat, so stepping into one is always\n * progress. Below that it is a prefix test on the resolved path, and the\n * trailing separator is what keeps `/tree/10` from counting as a step inside\n * `/tree/1`.\n */\nfunction descendsInto(outer: string | null, inner: string | null): boolean {\n if (inner === null) return false;\n if (outer === null) return true;\n return inner.startsWith(`${outer}/`);\n}\n\n/**\n * Whether this element renders itself again without getting anywhere — the\n * one arrangement that cannot terminate.\n *\n * An element reaching itself is not by itself a defect. It is how a tree gets\n * drawn — a comment thread, a file browser, a nested menu — where each pass\n * repeats over a path relative to the item it is already inside and so reads\n * one level further into the data. That ends when the data does.\n *\n * What separates the two is whether the repeat descended. Compare against the\n * nearest occurrence above: `/tree/0` then `/tree/0/children/1` is a tree\n * walking down, while `/items/0` then `/items/1` is a spec repeating over a\n * fixed array inside itself, and `/items/0` twice is one with no repeat\n * between the passes at all. Only the first can run out.\n */\nfunction repeatsItself(path: RenderPath): boolean {\n for (let step = path.parent; step !== null; step = step.parent) {\n if (step.key !== path.key) continue;\n return !descendsInto(step.scopePath, path.scopePath);\n }\n return false;\n}\n\n/**\n * Whether two objects hold the same values under the same keys.\n *\n * `objectsByIdentity` decides what the same object or array reference means.\n * The internal store copies every path it writes and never touches a snapshot\n * it has handed out, so there the same reference is the same content. An\n * external store may write into its snapshot in place, so there only\n * primitives can be trusted to compare equal, and any object value counts as\n * changed.\n */\nfunction sameValues(\n a: Readonly<Record<string, unknown>>,\n b: Readonly<Record<string, unknown>>,\n objectsByIdentity: boolean,\n): boolean {\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key of keys) {\n if (!Object.hasOwn(b, key)) return false;\n const value = a[key];\n if (!Object.is(value, b[key])) return false;\n if (!objectsByIdentity && typeof value === 'object' && value !== null) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Whether two resolved values hold the same content, however they are built.\n *\n * For the dev-mode check on skipped writes, which compares a fresh resolution\n * with an old one: a `$computed` function returns a new object every time,\n * so identity says nothing there. What it can't see into — functions, a `Map`,\n * a class instance — it counts as the same, because a check that warns about\n * a correct element is worse than one that misses a case.\n */\nfunction sameContent(\n a: unknown,\n b: unknown,\n seen = new Set<unknown>(),\n): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a === 'function' && typeof b === 'function') return true;\n if (typeof a !== 'object' || typeof b !== 'object' || !a || !b) return false;\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n if (a instanceof Date) return a.getTime() === (b as Date).getTime();\n const plain =\n Array.isArray(a) || Object.getPrototypeOf(a) === Object.prototype;\n if (!plain || seen.has(a)) return true;\n seen.add(a);\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(\n (key) =>\n Object.hasOwn(b, key) &&\n sameContent(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n seen,\n ),\n );\n}\n\n/**\n * Whether a state write at `written` can change the value at `bound`: the\n * same path, a container above it, or a path inside it.\n */\nfunction touches(written: string, bound: string): boolean {\n return (\n written === bound ||\n bound.startsWith(`${written}/`) ||\n written.startsWith(`${bound}/`)\n );\n}\n\n/** Element keys already warned about by the check on skipped writes. */\nconst warnedSkippedWrites = new Set<string>();\n\nconst EMPTY_READS: ReadonlySet<string> = new Set();\n\nfunction sameReads(\n a: ReadonlySet<string> | null,\n b: ReadonlySet<string> | null,\n): boolean {\n if (a === b) return true;\n if (!a || !b || a.size !== b.size) return false;\n for (const path of a) if (!b.has(path)) return false;\n return true;\n}\n\n/** The chain from the root down to `path`, as a line a human can follow. */\nfunction describePath(path: RenderPath): string {\n const keys: string[] = [];\n for (let step: RenderPath | null = path; step !== null; step = step.parent) {\n keys.push(step.key);\n }\n return keys.reverse().join(' \\u2192 ');\n}\n\n/**\n * Renders a single spec element: evaluates visibility, resolves prop\n * expressions against the state model, wires event/watch bindings, and\n * instantiates the catalog component with a {@link RenderContext} injector.\n *\n * @internal Used by `<json-render>` and `<jr-children>`.\n */\n@Component({\n selector: 'jr-element',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [NgComponentOutlet],\n styles: `:host { display: contents; }`,\n template: `\n @if (!refusal() && rawElement() && visible() && component()) {\n @if (devtoolsKey(); as dk) {\n <span [attr.data-jr-key]=\"dk\" style=\"display: contents\">\n <ng-container *ngComponentOutlet=\"component(); injector: outletInjector\" />\n </span>\n } @else {\n <ng-container *ngComponentOutlet=\"component(); injector: outletInjector\" />\n }\n }\n `,\n})\nexport class JrElement {\n readonly elementKey = input.required<string>();\n\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n private readonly actions = inject(JsonRenderActionsService);\n private readonly repeatScope = inject(REPEAT_SCOPE, { optional: true });\n private readonly parentPath = inject(RENDER_PATH, { optional: true });\n private readonly devtoolsActive = injectDevtoolsActive();\n\n /**\n * The raw (unresolved) element from the spec.\n *\n * Compared by content, not identity. A streamed patch shares every element\n * it did not touch, and the identity check settles those at once; but a\n * spec can also arrive as all-new objects — a whole-spec part, a host that\n * fetches it again, `buildSpecFromParts` replaying a message — and then an\n * element whose content is unchanged would resolve, and every container\n * with a fresh `children` array re-render, for nothing.\n */\n readonly rawElement = computed<UIElement | undefined>(\n () => this.root.spec()?.elements?.[this.elementKey()],\n { equal: (a, b) => sameJson(a, b) },\n );\n\n /**\n * The state paths this element's expressions can read, or null when the\n * spec doesn't say — see {@link collectStateReads} for when that is.\n */\n private readonly stateReads = computed<ReadonlySet<string> | null>(\n () => {\n const el = this.rawElement();\n if (!el) return EMPTY_READS;\n return collectStateReads(\n el,\n this.root.directiveRegistry(),\n this.repeatScope?.basePath(),\n );\n },\n { equal: sameReads },\n );\n\n /**\n * One signal per path this element reads, each holding the value at that\n * path. They are rebuilt only when the paths change, and a cell that stays\n * keeps its last value, so a path that didn't change is not a change.\n *\n * A cell compares like a resolved prop does: primitives by value, objects\n * by reference with the internal store (which copies every path it writes)\n * and never equal with an external `store`, which may write into its\n * snapshot in place.\n */\n private readonly stateCells = (() => {\n let cells = new Map<string, Signal<unknown>>();\n return computed<ReadonlyMap<string, Signal<unknown>> | null>(() => {\n const reads = this.stateReads();\n if (reads === null) return null;\n const next = new Map<string, Signal<unknown>>();\n for (const path of reads) {\n next.set(\n path,\n cells.get(path) ??\n computed(() => getByPath(this.state.state(), path), {\n equal: (a, b) =>\n Object.is(a, b) &&\n (typeof a !== 'object' ||\n a === null ||\n !untracked(this.root.store)),\n }),\n );\n }\n cells = next;\n return next;\n });\n })();\n\n /**\n * How many times {@link readableState} has taken a snapshot. The dev-mode\n * check compares it between state writes to tell which ones were skipped.\n */\n private snapshotsTaken = 0;\n\n /**\n * The state to resolve against: the whole snapshot, but only as fresh as\n * the paths this element reads. A write elsewhere doesn't reach it, so the\n * element doesn't resolve anything for it. An element whose reads are\n * unknown follows every write, as all elements did before.\n */\n private readonly readableState = computed<StateModel>(\n () => {\n this.snapshotsTaken++;\n const cells = this.stateCells();\n if (cells === null) return this.state.state();\n for (const cell of cells.values()) cell();\n return untracked(this.state.state);\n },\n // A snapshot an external store mutated in place is the same object, and\n // still has to count as newer when a cell says so.\n { equal: () => false },\n );\n\n /** Prop/visibility resolution context (state + repeat scope + extensions). */\n private readonly resolutionCtx = computed<PropResolutionContext>(() => {\n const scope = this.repeatScope;\n return {\n stateModel: this.readableState(),\n ...(scope\n ? {\n repeatItem: scope.item(),\n repeatIndex: scope.index(),\n repeatBasePath: scope.basePath(),\n }\n : {}),\n functions: this.root.functions() ?? {},\n directives: this.root.directiveRegistry(),\n };\n });\n\n protected readonly visible = computed(() => {\n const el = this.rawElement();\n if (!el || el.visible === undefined) return true;\n return evaluateVisibility(el.visible, this.resolutionCtx());\n });\n\n /**\n * How many state writes have touched a path this element is two-way bound\n * to. See {@link resolution} for why those writes count on their own.\n */\n private readonly boundWrites = signal(0);\n\n /**\n * The element with all prop expressions resolved, and the bound writes it\n * was resolved after.\n *\n * Resolving builds a new props object every time, so a result that holds\n * the same values as the last one counts as unchanged and keeps the old\n * object; otherwise one keystroke would re-run every catalog template that\n * happened to resolve.\n *\n * A write to a path the element is bound to always counts, though. Its\n * component writes the user's input into the DOM before it reaches state,\n * so the DOM can differ from a prop whose value never did: typing and a\n * `clearStatePath` in the same turn take the prop from '' through 'milk'\n * back to '' with nobody reading 'milk'. The README tells catalog authors\n * to sync such inputs with an effect on props, and that effect only gets to\n * put the DOM right if it runs. Writes anywhere else compare by value, like\n * any element's.\n */\n private readonly resolution = computed<{\n element: UIElement | undefined;\n boundWrites: number;\n }>(\n () => {\n const boundWrites = this.boundWrites();\n const el = this.rawElement();\n if (!el) return { element: undefined, boundWrites };\n return {\n element: {\n ...el,\n props: resolveElementProps(el.props ?? {}, this.resolutionCtx()),\n },\n boundWrites,\n };\n },\n {\n equal: (a, b) => {\n if (a.boundWrites !== b.boundWrites) return false;\n if (a.element === b.element) return true;\n if (!a.element || !b.element) return false;\n const { props: aProps, ...aRest } = a.element;\n const { props: bProps, ...bRest } = b.element;\n // Everything but props is the spec element itself, never state.\n return (\n sameValues(aRest, bRest, true) &&\n sameValues(aProps, bProps, !untracked(this.root.store))\n );\n },\n },\n );\n\n /** The element with all prop expressions resolved. */\n readonly resolvedElement = computed<UIElement | undefined>(\n () => this.resolution().element,\n );\n\n /** Two-way binding paths ($bindState / $bindItem) by prop name. */\n readonly bindings = computed<Record<string, string> | undefined>(\n () => {\n const el = this.rawElement();\n return el\n ? resolveBindings(el.props ?? {}, this.resolutionCtx())\n : undefined;\n },\n {\n equal: (a, b) => a === b || (!!a && !!b && sameValues(a, b, true)),\n },\n );\n\n private readonly entry = computed(() => {\n const el = this.rawElement();\n return el ? this.root.resolveEntry(el.type) : undefined;\n });\n\n /** Set once the real component has been shown; see {@link held}. */\n private mounted = false;\n\n /**\n * Whether the component waits for its props: the spec is still loading, a\n * catalog was given, and the props written so far do not pass the\n * component's schema (see {@link propsArrived}).\n *\n * One-way. Once the component has been shown it is never swapped back for\n * the fallback, even if a later patch takes a prop away again: a component\n * flickering out mid-stream is worse than one showing a gap. Once latched\n * this reads no signals, so a mounted element pays nothing for the gate on\n * later patches — and neither does any element when nothing is loading.\n */\n protected readonly held = computed(() => {\n if (this.mounted) return false;\n const el = this.rawElement();\n const catalog = this.root.catalog();\n const held =\n !!el && !!catalog && this.root.loading() && !propsArrived(el, catalog);\n if (!held && this.entry() && this.visible() && !this.refusal()) {\n this.mounted = true;\n }\n return held;\n });\n\n /** What the outlet shows: the component, or its fallback while held. */\n protected readonly component = computed(() =>\n this.held()\n ? (this.entry()?.fallback ?? null)\n : (this.entry()?.component ?? null),\n );\n\n protected readonly devtoolsKey = computed(() =>\n this.devtoolsActive() ? this.elementKey() : null,\n );\n\n /**\n * Where this element sits in the tree. Passed down to everything it renders\n * below itself, which is what lets each element see its own ancestry\n * without the renderer holding a registry of who is drawing what.\n */\n private readonly path = computed<RenderPath>(() => {\n const parent = this.parentPath?.() ?? null;\n return {\n key: this.elementKey(),\n depth: (parent?.depth ?? 0) + 1,\n scopePath: this.repeatScope?.basePath() ?? null,\n parent,\n };\n });\n\n /**\n * Why this element is not drawn, or null when it is.\n *\n * The cycle half is unconditional — not something `validate` turns on. An\n * element that renders itself without reading any deeper renders forever,\n * and a spec that never stops rendering takes the tab with it; refusing to\n * draw the repetition is the only outcome that leaves anything on screen.\n * It costs one walk up a chain of parents, bounded by `maxDepth` where one\n * is set and by the spec's own nesting where it is not.\n */\n protected readonly refusal = computed<'cycle' | 'depth' | null>(() => {\n const path = this.path();\n if (repeatsItself(path)) return 'cycle';\n const maxDepth = this.root.limits()?.maxDepth;\n if (maxDepth !== undefined && path.depth > maxDepth) return 'depth';\n return null;\n });\n\n private readonly renderCtx: RenderContext = {\n element: this.resolvedElement as Signal<UIElement>,\n props: computed(() => this.resolvedElement()?.props ?? {}),\n emit: (event) => this.fireEvent(event),\n on: (event) => this.eventHandle(event),\n bindings: this.bindings,\n loading: computed(() => this.root.loading()),\n setBound: (prop, value) => {\n const path = untracked(this.bindings)?.[prop];\n if (path) {\n this.state.set(path, value);\n } else if (isDevMode()) {\n console.warn(\n `[ngx-json-render] setBound(\"${prop}\"): prop has no $bindState/$bindItem binding`,\n );\n }\n },\n };\n\n // Typed as Injector for the peer range: see `confirmInjector` in\n // renderer.component.ts.\n protected readonly outletInjector: Injector = Injector.create({\n providers: [\n { provide: RENDER_CONTEXT, useValue: this.renderCtx },\n { provide: ELEMENT_KEY, useValue: this.elementKey },\n { provide: RENDER_PATH, useValue: this.path },\n ],\n parent: inject(Injector),\n });\n\n constructor() {\n // Warn (once) when this element is refused. Both reasons are silent\n // failures on screen — something the spec asked for is missing — so\n // neither should be silent in the console.\n let warnedRefusal = false;\n effect(() => {\n const reason = this.refusal();\n if (!reason || warnedRefusal) return;\n warnedRefusal = true;\n const path = untracked(this.path);\n if (reason === 'cycle') {\n console.warn(\n `[ngx-json-render] Cycle in the spec: ${describePath(path)}. \"${path.key}\" renders itself again without reading any deeper into state${path.scopePath === null ? '' : ` (still at \"${path.scopePath}\")`}, so it never ends. It is not rendered again; everything above it still is. A tree that recurses needs a repeat with a relative statePath, like {\"$item\": \"children\"}.`,\n );\n } else {\n console.warn(\n `[ngx-json-render] renderLimits.maxDepth (${untracked(this.root.limits)?.maxDepth}) reached at ${describePath(path)}. \"${path.key}\" and anything below it do not render.`,\n );\n }\n });\n\n // Dev mode: after a state write this element skipped, check that it was\n // right to. Resolving against the whole state has to give what the element\n // already shows; anything else is a read the spec analysis didn't name.\n if (inject(CHECK_SKIPPED_WRITES)) {\n let snapshotsSeen = -1;\n effect(() => {\n this.state.state();\n const shown = this.resolvedElement();\n const shownVisible = this.visible();\n const reads = this.stateReads();\n untracked(() => {\n const skipped = this.snapshotsTaken === snapshotsSeen;\n snapshotsSeen = this.snapshotsTaken;\n if (skipped && shown && reads !== null) {\n this.checkSkippedWrite(shown, shownVisible, reads);\n }\n });\n });\n }\n\n // Count the writes that touch a path this element is bound to. Only an\n // element with bindings listens, and it reads them when a write arrives,\n // so a binding that moves (a repeat item that shifts) is followed without\n // subscribing again.\n effect((onCleanup) => {\n if (!this.bindings()) return;\n const unsubscribe = this.state.subscribeChanges((changes) => {\n const paths = Object.values(untracked(this.bindings) ?? {});\n if (\n changes.some((change) =>\n paths.some((path) => touches(change.path, path)),\n )\n ) {\n this.boundWrites.update((count) => count + 1);\n }\n });\n onCleanup(unsubscribe);\n });\n\n // Warn (once per type) about unknown component types.\n const warnedTypes = new Set<string>();\n effect(() => {\n const el = this.rawElement();\n if (!el || this.entry() || warnedTypes.has(el.type)) return;\n warnedTypes.add(el.type);\n console.warn(`No renderer for component type: ${el.type}`);\n });\n\n // Warn about unknown / default slots when the registry carries metadata.\n effect(() => {\n const el = this.rawElement();\n const meta = this.entry();\n if (!el?.slots || !meta?.slots) return;\n const available = new Set(meta.slots);\n for (const slotName of Object.keys(el.slots)) {\n const warnKey = `${el.type}:${slotName}`;\n if (warnedSlots.has(warnKey)) continue;\n if (slotName === 'default') {\n warnedSlots.add(warnKey);\n console.warn(\n `[json-render] Component \"${el.type}\" uses slots.default. Use \"children\" for default slot content.`,\n );\n } else if (!available.has(slotName)) {\n warnedSlots.add(warnKey);\n console.warn(\n `[json-render] Unknown slot \"${slotName}\" on component \"${el.type}\". Available slots: ${meta.slots.join(', ')}`,\n );\n }\n }\n });\n\n // Watch effect: fire actions when watched state paths change.\n effect((onCleanup) => {\n // A refused element does not act, not just draw nothing. `watch` is the\n // one thing an element does without being on screen, so leaving it wired\n // would let the element past `maxDepth` — or the one that closes a cycle\n // — keep dispatching actions from behind a cap that was supposed to have\n // stopped it. Reading the signal here also unwires it if the refusal\n // arrives later, when the limits change.\n if (this.refusal()) return;\n const watchConfig = this.rawElement()?.watch;\n if (!watchConfig) return;\n const paths = Object.keys(watchConfig);\n if (paths.length === 0) return;\n\n const unsubscribe = this.state.subscribeChanges((changes) => {\n const changedPaths = new Set(changes.map((change) => change.path));\n\n void (async () => {\n for (const path of paths) {\n if (!changedPaths.has(path)) continue;\n const binding = watchConfig[path];\n if (binding) await this.dispatch(binding);\n }\n })().catch(reportActionError);\n });\n\n onCleanup(unsubscribe);\n });\n }\n\n /**\n * Resolve this element against the whole current state and warn, once per\n * element key, when that differs from what it shows after skipping a write.\n *\n * It only reports, and leaves the element as it is: correcting it here would\n * make dev mode render what production doesn't.\n */\n private checkSkippedWrite(\n shown: UIElement,\n shownVisible: boolean,\n reads: ReadonlySet<string>,\n ): void {\n const key = this.elementKey();\n const el = this.rawElement();\n if (!el || warnedSkippedWrites.has(key)) return;\n const ctx = this.liveResolutionCtx();\n let props: Record<string, unknown>;\n let visible: boolean;\n try {\n props = resolveElementProps(el.props ?? {}, ctx);\n visible = el.visible === undefined || evaluateVisibility(el.visible, ctx);\n } catch {\n return;\n }\n const differs = Object.keys({ ...props, ...shown.props }).filter(\n (prop) => !sameContent(props[prop], shown.props[prop]),\n );\n if (visible !== shownVisible) differs.push('visible');\n if (differs.length === 0) return;\n warnedSkippedWrites.add(key);\n const paths = reads.size > 0 ? [...reads].join(', ') : 'no state paths';\n console.warn(\n `[ngx-json-render] \"${key}\" did not resolve again after a state write, but resolving it now changes ${differs.join(', ')}. It resolves only when a state path it reads changes, and it reads ${paths}. Either a $computed function in it depends on something besides its args, or the renderer missed a read — please report the spec at https://github.com/shteynu/ngx-json-render/issues. This check runs in dev mode only.`,\n );\n }\n\n /**\n * Resolution context with a live state snapshot, so `$state` references in\n * later actions of a chain see mutations from earlier ones.\n */\n private liveResolutionCtx(): PropResolutionContext {\n return {\n ...untracked(this.resolutionCtx),\n stateModel: this.state.getSnapshot(),\n };\n }\n\n /**\n * Fire-and-forget entry point for event emission: dispatching is async, but\n * a template listener has nowhere to await it, so the failure must be\n * handled here rather than escaping as an unhandled rejection.\n */\n private fireEvent(eventName: string): void {\n this.emitEvent(eventName).catch(reportActionError);\n }\n\n private async emitEvent(eventName: string): Promise<void> {\n const binding = untracked(this.rawElement)?.on?.[eventName];\n if (binding) await this.dispatch(binding);\n }\n\n /**\n * Run an `on` or `watch` binding's actions in order. Params are resolved\n * per action, just before it runs, so a `$state` read in a later action of\n * the chain sees what an earlier one wrote.\n */\n private async dispatch(\n binding: ActionBinding | ActionBinding[],\n ): Promise<void> {\n for (const b of Array.isArray(binding) ? binding : [binding]) {\n if (!b.params) {\n await this.actions.execute(b);\n continue;\n }\n const liveCtx = this.liveResolutionCtx();\n const resolved: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(b.params)) {\n resolved[key] = resolveActionParam(val, liveCtx);\n }\n await this.actions.execute({ ...b, params: resolved });\n }\n }\n\n private eventHandle(eventName: string): EventHandle {\n const el = this.rawElement();\n const binding = el?.on?.[eventName];\n if (!binding) {\n return { emit: () => {}, shouldPreventDefault: false, bound: false };\n }\n const actionBindings = Array.isArray(binding) ? binding : [binding];\n return {\n emit: () => this.fireEvent(eventName),\n shouldPreventDefault: actionBindings.some((b) => b.preventDefault),\n bound: true,\n };\n }\n}\n","import {\n InjectionToken,\n type Provider,\n type Type,\n inject,\n} from '@angular/core';\nimport type {\n ActionHandler,\n ComputedFunction,\n DirectiveDefinition,\n ValidationFunction,\n} from '@json-render/core';\nimport type { RenderLimits, SpecCatalog } from './render-limits';\nimport type { SpecValidationMode } from './spec-validation';\nimport type { ComponentRegistry, RegistryEntry } from './types';\n\n/**\n * Renderer defaults for every `<json-render>` below a provider: each field is\n * the input of the same name.\n *\n * An input bound on the element wins over the provided value, and a value\n * left `null` or `undefined` on the element falls through to it. Named\n * vocabularies — `handlers`, `functions`, `validationFunctions` and\n * `directives` — merge by name instead, the element's entry winning a name\n * both define. Everything else replaces: a `registry` belongs to its catalog,\n * so two are never mixed behind your back (spread them yourself to combine).\n */\nexport interface JsonRenderConfig {\n registry?: ComponentRegistry;\n fallback?: Type<unknown> | RegistryEntry | null;\n validate?: SpecValidationMode;\n renderLimits?: RenderLimits | null;\n catalog?: SpecCatalog | null;\n handlers?: Record<string, ActionHandler>;\n onAction?:\n ((name: string, params?: Record<string, unknown>) => unknown) | null;\n navigate?: ((path: string) => void) | null;\n validationFunctions?: Record<string, ValidationFunction>;\n functions?: Record<string, ComputedFunction>;\n directives?: DirectiveDefinition<any>[];\n}\n\n/**\n * The defaults the nearest {@link provideJsonRender} supplies, already merged\n * with any provider above it.\n */\nexport const JSON_RENDER_CONFIG = new InjectionToken<JsonRenderConfig>(\n 'JSON_RENDER_CONFIG',\n);\n\n/**\n * Set renderer defaults once instead of on every `<json-render>`:\n *\n * ```ts\n * bootstrapApplication(App, { providers: [provideJsonRender({ registry })] });\n * ```\n *\n * ```html\n * <json-render [spec]=\"m.spec\" />\n * ```\n *\n * Pass a function to build the defaults with `inject()`, for handlers that\n * call your services:\n *\n * ```ts\n * provideJsonRender(() => {\n * const orders = inject(OrderService);\n * return { registry, handlers: { cancelOrder: (p) => orders.cancel(p['id']) } };\n * });\n * ```\n *\n * Works in application, route and component `providers`. A provider below\n * another extends it with the same rules an element input does: its own\n * values replace, its named vocabularies merge.\n */\nexport function provideJsonRender(\n config: JsonRenderConfig | (() => JsonRenderConfig),\n): Provider[] {\n return [\n {\n provide: JSON_RENDER_CONFIG,\n useFactory: (): JsonRenderConfig => {\n const outer = inject(JSON_RENDER_CONFIG, {\n optional: true,\n skipSelf: true,\n });\n const own = typeof config === 'function' ? config() : config;\n return outer ? mergeJsonRenderConfig(outer, own) : own;\n },\n },\n ];\n}\n\n/** `inner` over `outer`, by the rules {@link JsonRenderConfig} describes. */\nfunction mergeJsonRenderConfig(\n outer: JsonRenderConfig,\n inner: JsonRenderConfig,\n): JsonRenderConfig {\n const merged: JsonRenderConfig = { ...outer };\n for (const [key, value] of Object.entries(inner) as [\n keyof JsonRenderConfig,\n unknown,\n ][]) {\n if (value !== undefined && value !== null) {\n (merged as Record<string, unknown>)[key] = value;\n }\n }\n merged.handlers = mergeByName(outer.handlers, inner.handlers);\n merged.functions = mergeByName(outer.functions, inner.functions);\n merged.validationFunctions = mergeByName(\n outer.validationFunctions,\n inner.validationFunctions,\n );\n merged.directives = mergeDirectives(outer.directives, inner.directives);\n return merged;\n}\n\n/**\n * Two name → value maps as one, `inner` winning a name both define. Returns\n * whichever is given when only one is, so an unmerged map keeps its identity.\n *\n * @internal\n */\nexport function mergeByName<T>(\n outer: Record<string, T> | null | undefined,\n inner: Record<string, T> | null | undefined,\n): Record<string, T> | undefined {\n if (!outer) return inner ?? undefined;\n if (!inner) return outer;\n return { ...outer, ...inner };\n}\n\n/**\n * Two directive lists as one, `inner` winning a name both define — the\n * directive registry keeps the last definition of a name.\n *\n * @internal\n */\nexport function mergeDirectives(\n outer: DirectiveDefinition<any>[] | null | undefined,\n inner: DirectiveDefinition<any>[] | null | undefined,\n): DirectiveDefinition<any>[] | undefined {\n if (!outer) return inner ?? undefined;\n if (!inner) return outer;\n return [...outer, ...inner];\n}\n","import type { Spec } from '@json-render/core';\nimport { autoFixSpec, validateSpec } from '@json-render/core';\nimport type {\n RenderLimits,\n SpecCatalog,\n SpecCheckIssue,\n} from './render-limits';\nimport {\n analyseSpecGraph,\n catalogIssues,\n cycleIssue,\n depthIssue,\n elementCountIssue,\n} from './render-limits';\n\n/**\n * How much a spec has to be trusted.\n *\n * - `off` — render whatever arrives. The default, and what every version\n * before this one did.\n * - `warn` — check the spec, apply the lossless fixes, report what is left,\n * render it anyway.\n * - `strict` — the same check, but an error means the spec does not render.\n *\n * This governs *reporting* and strict refusal. {@link RenderLimits} are a\n * separate axis: a limit the app set is enforced in every mode, including\n * `off`.\n */\nexport type SpecValidationMode = 'off' | 'warn' | 'strict';\n\n/** Everything {@link checkSpec} needs beyond the spec and the mode. */\nexport interface SpecCheckOptions {\n /** Caps on the spec's size, enforced whatever the mode. */\n readonly limits?: RenderLimits | null;\n /**\n * The catalog the spec was generated for. Given one, the check also reports\n * component types the catalog does not define, elements its spec schema\n * rejects, and props their component's schema rejects — the half of \"is\n * this spec renderable\" that structure alone cannot answer. A prop written\n * as an expression is not judged: it has no value until render time.\n */\n readonly catalog?: SpecCatalog | null;\n}\n\n/** What {@link checkSpec} found, and the spec that should render. */\nexport interface SpecCheck {\n /**\n * The spec to render: the input with lossless fixes applied, or the input\n * untouched when validation is off.\n */\n readonly spec: Spec | null;\n /** Structural, limit and catalog issues left after the fixes. */\n readonly issues: readonly SpecCheckIssue[];\n /** Descriptions of the fixes that were applied. */\n readonly fixes: readonly string[];\n /** Whether an issue of `error` severity survived. */\n readonly hasErrors: boolean;\n /**\n * Whether the spec is refused outright, in every mode, for breaching an\n * enforced limit. Distinct from {@link hasErrors}, which only stops a spec\n * under `strict`.\n */\n readonly blocked: boolean;\n}\n\nconst CLEAN: SpecCheck = {\n spec: null,\n issues: [],\n fixes: [],\n hasErrors: false,\n blocked: false,\n};\n\n/**\n * Check a spec the way `validate` and `renderLimits` ask for.\n *\n * Only lossless fixes are applied — `visible`, `on` and `repeat` that a model\n * put inside `props`, which the renderer would otherwise ignore, moved back\n * where they belong. The lossy ones prune content, and core's own guidance is\n * to re-prompt rather than accept that; a renderer that silently deleted\n * elements would be the worse failure.\n *\n * Note what is *not* here: cycles are broken as the tree renders, whatever\n * this returns, because a spec that never stops rendering is a crash rather\n * than an opinion about quality. This reports them so an app can see them.\n */\nexport function checkSpec(\n spec: Spec | null,\n mode: SpecValidationMode,\n options: SpecCheckOptions = {},\n): SpecCheck {\n if (!spec) return CLEAN;\n\n const limits = options.limits ?? null;\n const wantsStructure = mode !== 'off';\n // `maxRepeatItems` caps a live state array, which no amount of reading the\n // spec can predict — it is enforced as the repeat expands, not here.\n const maxElements = limits?.maxElements;\n const maxDepth = limits?.maxDepth;\n if (!wantsStructure && maxElements === undefined && maxDepth === undefined) {\n return { spec, issues: [], fixes: [], hasErrors: false, blocked: false };\n }\n\n // The order below is the point of this function, not an accident of it.\n //\n // Core's `validateSpec` walks the element tree by recursion, so the specs\n // that most need a limit are the ones that would overflow the stack proving\n // they exceed it. Each cheap, non-recursive cap therefore runs first and can\n // stop the expensive check from being attempted at all: count, then depth —\n // measured by a walk of our own that uses an explicit stack — and only then\n // the structural pass.\n //\n // `autoFixSpec` only relocates fields inside `props` and never touches\n // `children` or `slots`, so measuring the graph before fixing it measures\n // the same graph.\n\n if (maxElements !== undefined) {\n const count = Object.keys(spec.elements ?? {}).length;\n if (count > maxElements) {\n const issue = elementCountIssue(count, maxElements);\n return {\n spec,\n issues: [issue],\n fixes: [],\n hasErrors: true,\n blocked: true,\n };\n }\n }\n\n const issues: SpecCheckIssue[] = [];\n let tooDeep = false;\n if (wantsStructure || maxDepth !== undefined) {\n const graph = analyseSpecGraph(spec);\n if (maxDepth !== undefined && graph.depth > maxDepth) {\n tooDeep = true;\n issues.push(depthIssue(graph.depth, maxDepth));\n }\n if (wantsStructure) {\n for (const key of graph.cycles) issues.push(cycleIssue(key));\n }\n }\n\n // A spec past its depth cap is not handed to the recursive checks. The cap\n // is the finding worth having, and it renders truncated either way.\n const fixed =\n wantsStructure && !tooDeep\n ? autoFixSpec(spec, { lossy: false })\n : { spec, fixes: [] as string[] };\n if (wantsStructure && !tooDeep) {\n issues.push(...validateSpec(fixed.spec).issues);\n if (options.catalog) {\n issues.push(...catalogIssues(fixed.spec, options.catalog));\n }\n }\n\n return {\n spec: fixed.spec,\n issues,\n fixes: fixed.fixes,\n hasErrors: issues.some((issue) => issue.severity === 'error'),\n blocked: false,\n };\n}\n\n/**\n * Render issues as one indented block, errors and warnings alike.\n *\n * Core's `formatSpecIssues` drops warnings and only accepts core's own issue\n * codes, so it cannot describe what this package reports. Use this instead\n * when showing `issues()` to a developer.\n */\nexport function formatSpecCheckIssues(\n issues: readonly SpecCheckIssue[],\n): string {\n return issues\n .map(\n (issue) =>\n ` ${issue.severity === 'error' ? 'error ' : 'warning'} ${\n issue.elementKey ? `[${issue.elementKey}] ` : ''\n }${issue.message}`,\n )\n .join('\\n');\n}\n\n/**\n * Report a check to the console: fixes as information, issues at the severity\n * the outcome gives them. A spec that will not render — refused by a limit,\n * or by `strict` — is reported as an error, because something the developer\n * asked for is now missing from the screen; one that renders anyway is a\n * warning.\n */\nexport function reportSpecCheck(\n check: SpecCheck,\n mode: SpecValidationMode,\n): void {\n if (check.fixes.length > 0) {\n console.info(\n `[ngx-json-render] Fixed ${check.fixes.length} spec issue(s) before rendering:\\n` +\n check.fixes.map((fix) => ` - ${fix}`).join('\\n'),\n );\n }\n\n if (check.issues.length === 0) return;\n\n const report = `[ngx-json-render] Spec validation:\\n${formatSpecCheckIssues(check.issues)}`;\n if (check.blocked) {\n console.error(\n `${report}\\nNothing is rendered: the spec is over a renderLimits cap.`,\n );\n } else if (mode === 'strict' && check.hasErrors) {\n console.error(`${report}\\nNothing is rendered: validate=\"strict\".`);\n } else {\n console.warn(report);\n }\n}\n","import { NgComponentOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n Injector,\n type Type,\n computed,\n effect,\n inject,\n input,\n output,\n} from '@angular/core';\nimport type {\n ActionHandler,\n ComputedFunction,\n DirectiveDefinition,\n Spec,\n StateModel,\n StateStore,\n ValidationFunction,\n} from '@json-render/core';\nimport { createDirectiveRegistry } from '@json-render/core';\nimport { JsonRenderActionsService } from './actions.service';\nimport { JrConfirmDialog } from './confirm-dialog.component';\nimport {\n CONFIRM_CONTEXT,\n type ConfirmContext,\n JR_CONFIRM_DIALOG,\n} from './confirm-tokens';\nimport { JrElement } from './element.component';\nimport type { RenderLimits, SpecCatalog } from './render-limits';\nimport {\n JSON_RENDER_CONFIG,\n type JsonRenderConfig,\n mergeByName,\n mergeDirectives,\n} from './provide';\nimport { JsonRenderRootContext } from './root-context';\nimport {\n type SpecValidationMode,\n checkSpec,\n reportSpecCheck,\n} from './spec-validation';\nimport { JsonRenderStateService } from './state.service';\nimport type { ComponentRegistry, RegistryEntry, StateChange } from './types';\nimport { JsonRenderValidationService } from './validation.service';\n\n/**\n * Renders a json-render {@link Spec} using a registry of Angular components.\n *\n * The renderer owns the state store, action dispatcher, and validation state\n * of its subtree (all injectable from catalog components). Pass an external\n * {@link StateStore} via `store` for controlled mode or to share state across\n * renderers.\n *\n * @example\n * ```html\n * <json-render\n * [spec]=\"spec()\"\n * [registry]=\"registry\"\n * [handlers]=\"handlers\"\n * [loading]=\"isStreaming()\"\n * (stateChange)=\"onStateChange($event)\"\n * />\n * ```\n */\n@Component({\n selector: 'json-render',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [JrElement, JrConfirmDialog, NgComponentOutlet],\n providers: [\n JsonRenderRootContext,\n JsonRenderStateService,\n JsonRenderValidationService,\n JsonRenderActionsService,\n ],\n styles: `:host { display: contents; }`,\n template: `\n @if (rootKey(); as key) {\n <jr-element [elementKey]=\"key\" />\n }\n @if (pendingConfirm(); as confirm) {\n @if (customDialog; as dialog) {\n <ng-container\n *ngComponentOutlet=\"dialog; injector: confirmInjector() ?? undefined\"\n />\n } @else {\n <jr-confirm-dialog\n [config]=\"confirm\"\n (confirmed)=\"actions.confirm()\"\n (cancelled)=\"actions.cancel()\"\n />\n }\n }\n `,\n})\nexport class JsonRenderer {\n /** The UI spec to render (may be partial while streaming). */\n readonly spec = input.required<Spec | null>();\n /**\n * Component registry mapping catalog type names to Angular components.\n * Required unless a {@link provideJsonRender} above supplies one.\n */\n readonly registry = input<ComponentRegistry | undefined>(undefined);\n /** Whether the spec is currently loading/streaming. */\n readonly loading = input(false);\n /** Fallback component for unknown types. */\n readonly fallback = input<Type<unknown> | RegistryEntry | null>(null);\n /**\n * Whether to check the spec's structure before rendering it, and what to do\n * about what turns up. Off by default.\n *\n * `'warn'` reports the issues and renders anyway; `'strict'` renders nothing\n * when the spec has errors. Both first apply the lossless fixes — `visible`,\n * `on` and `repeat` misplaced inside `props` are moved back to the element,\n * where they take effect instead of being ignored.\n *\n * The check is skipped while `loading` is true: a spec that is still\n * arriving is expected to reference children that have not streamed in yet.\n */\n readonly validate = input<SpecValidationMode | undefined>(undefined);\n\n /**\n * Caps on what the spec may cost the browser: `maxElements`, `maxDepth` and\n * `maxRepeatItems`. Unset by default, and each field is independently\n * optional.\n *\n * Unlike `validate`, these are enforced in every mode — a number the app\n * chose is a control, not a report. A spec over `maxElements` renders\n * nothing; `maxDepth` and `maxRepeatItems` truncate where they are hit.\n * They apply while `loading` too: a partial spec is a subset of the\n * finished one, so a cap can only ever fire early, never falsely.\n */\n readonly renderLimits = input<RenderLimits | null>(null);\n\n /**\n * The catalog the spec was generated for. Given one, `validate` also checks\n * what structure alone cannot: that every `type` is a component the catalog\n * defines, that every element has the shape the catalog's spec schema asks\n * for — a `children` array, even on a leaf — and that its props match its\n * component's schema. A prop written as an expression — `$state`,\n * `$bindState`, `$template`, a directive — has no value until render time,\n * so it is not checked.\n *\n * The check is read only when `validate` is on, and — like the rest of\n * it — skipped while `loading`.\n *\n * While `loading`, the catalog also gates mounting, whatever `validate` is:\n * an element whose props do not yet pass its component's schema shows its\n * registry entry's `fallback`, or nothing, instead of a component with half\n * its props. Once an element has mounted it stays mounted, and when\n * `loading` ends every element mounts.\n */\n readonly catalog = input<SpecCatalog | null>(null);\n\n /**\n * Initial state model (uncontrolled mode). Defaults to `spec.state`.\n * Ignored when `store` is provided.\n */\n readonly state = input<StateModel | undefined>(undefined);\n /** External state store (controlled mode). */\n readonly store = input<StateStore | null>(null);\n\n /** Action handlers by action name. */\n readonly handlers = input<Record<string, ActionHandler> | undefined>(\n undefined,\n );\n /** Catch-all action handler for actions without a dedicated handler. */\n readonly onAction = input<\n ((name: string, params?: Record<string, unknown>) => unknown) | null\n >(null);\n /** Navigation function used by `onSuccess: { navigate }` handlers. */\n readonly navigate = input<((path: string) => void) | null>(null);\n\n /** Custom validation functions. */\n readonly validationFunctions = input<\n Record<string, ValidationFunction> | undefined\n >(undefined);\n /** Named functions for `$computed` expressions in props. */\n readonly functions = input<Record<string, ComputedFunction> | undefined>(\n undefined,\n );\n /** Custom directives for user-defined `$`-prefixed dynamic values. */\n readonly directives = input<DirectiveDefinition<any>[] | undefined>(\n undefined,\n );\n\n /** Emits state changes in uncontrolled mode. */\n readonly stateChange = output<StateChange[]>();\n\n /** The state store of this renderer (also injectable in the subtree). */\n readonly stateStore: JsonRenderStateService;\n /** The action dispatcher of this renderer. */\n protected readonly actions: JsonRenderActionsService;\n\n /**\n * The nearest {@link provideJsonRender}'s defaults. Every option input\n * falls through to these when left `null` or `undefined`; see\n * {@link JsonRenderConfig} for the merge rules.\n */\n private readonly config: JsonRenderConfig =\n inject(JSON_RENDER_CONFIG, { optional: true }) ?? {};\n\n private readonly mode = computed<SpecValidationMode>(\n () => this.validate() ?? this.config.validate ?? 'off',\n );\n private readonly limits = computed(\n () => this.renderLimits() ?? this.config.renderLimits ?? null,\n );\n private readonly specCatalog = computed(\n () => this.catalog() ?? this.config.catalog ?? null,\n );\n\n /**\n * The spec as checked, and what the check found. While `loading`, the mode\n * is forced off: the spec is still arriving, and the missing children it\n * refers to are the normal state of a stream, not a defect.\n */\n private readonly checked = computed(() =>\n checkSpec(this.spec(), this.loading() ? 'off' : this.mode(), {\n limits: this.limits(),\n catalog: this.specCatalog(),\n }),\n );\n\n constructor() {\n const root = inject(JsonRenderRootContext);\n // The fixed spec, not the input: a `visible` the check moved out of\n // `props` has to be the one the tree renders, or the fix is cosmetic.\n root.spec = computed(() => this.checked().spec);\n const config = this.config;\n // Read only once an element needs a component, like a required input:\n // a renderer with no spec yet has no use for one.\n root.registry = computed(() => {\n const registry = this.registry() ?? config.registry;\n if (!registry) {\n throw new Error(\n '[ngx-json-render] <json-render> has no registry. Bind [registry], or supply one for the whole app with provideJsonRender({ registry }).',\n );\n }\n return registry;\n });\n root.loading = this.loading;\n root.fallback = computed(() => this.fallback() ?? config.fallback ?? null);\n root.limits = this.limits;\n root.catalog = this.specCatalog;\n root.store = this.store;\n root.initialState = computed(\n () => this.state() ?? this.spec()?.state ?? {},\n );\n root.handlers = computed(() =>\n mergeByName(config.handlers, this.handlers()),\n );\n root.onAction = computed(() => this.onAction() ?? config.onAction ?? null);\n root.navigate = computed(() => this.navigate() ?? config.navigate ?? null);\n root.validationFunctions = computed(() =>\n mergeByName(config.validationFunctions, this.validationFunctions()),\n );\n root.functions = computed(() =>\n mergeByName(config.functions, this.functions()),\n );\n root.directiveRegistry = computed(() => {\n const definitions = mergeDirectives(config.directives, this.directives());\n return definitions ? createDirectiveRegistry(definitions) : undefined;\n });\n root.emitStateChange = (changes) => this.stateChange.emit(changes);\n\n // Instantiate the subtree services now that the root context is wired.\n this.stateStore = inject(JsonRenderStateService);\n inject(JsonRenderValidationService);\n this.actions = inject(JsonRenderActionsService);\n\n // Reports once per distinct check rather than once per render: `checked`\n // only recomputes when the spec, the mode, the limits or the loading flag\n // change. Silent while loading — a limit can fire on a spec that is still\n // arriving, and reporting it on every patch would bury the one report\n // that describes the finished spec.\n effect(() => {\n if (this.loading()) return;\n reportSpecCheck(this.checked(), this.mode());\n });\n\n // With validation off, a `root` that names no element renders nothing and\n // nothing says why — the first mistake a hand-written spec tends to have.\n // Skipped while loading (a stream sends `/root` before its element) and\n // under `warn`/`strict`, where the check already reports `root_not_found`.\n // Once per root key, not once per change detection run.\n const warnedRoots = new Set<string>();\n effect(() => {\n if (this.loading() || this.mode() !== 'off') return;\n const spec = this.checked().spec;\n if (!spec?.root) return;\n const root = spec.root;\n if (spec.elements?.[root] || warnedRoots.has(root)) return;\n warnedRoots.add(root);\n console.warn(\n `[ngx-json-render] root \"${root}\" is not in elements; nothing is rendered.`,\n );\n });\n }\n\n protected readonly rootKey = computed(() => {\n const checked = this.checked();\n // A spec over an enforced cap does not render in any mode. Whether to\n // check was the app's decision; once it has made it, honouring the answer\n // is not also `validate`'s to decide.\n if (checked.blocked) return null;\n // A spec whose errors survived the fixes does not render under `strict`.\n // Reporting it and drawing half of it anyway is the behaviour the mode\n // exists to refuse.\n if (this.mode() === 'strict' && checked.hasErrors) return null;\n const spec = checked.spec;\n return spec?.root && spec.elements?.[spec.root] ? spec.root : null;\n });\n\n protected readonly pendingConfirm = computed(\n () => this.actions.pendingConfirmation()?.action.confirm ?? null,\n );\n\n /**\n * The app's own dialog, if it provided one. Read once: which component\n * answers a confirmation is an application decision, not something that\n * changes between two confirmations.\n */\n protected readonly customDialog = inject(JR_CONFIRM_DIALOG, {\n optional: true,\n });\n private readonly injector = inject(Injector);\n\n /**\n * A replacement dialog takes no inputs and emits no outputs — it injects\n * everything it needs, the way catalog components do. That keeps the seam\n * one token wide instead of a component contract the renderer would have to\n * bind to.\n */\n // Typed as Injector, not left to inference: Angular 20+ infers its\n // `DestroyableInjector`, which Angular 19's typings do not export, and the\n // inferred type would land in the published declarations.\n protected readonly confirmInjector = computed((): Injector | null => {\n const config = this.pendingConfirm();\n if (!config) return null;\n const context: ConfirmContext = {\n config,\n confirm: () => this.actions.confirm(),\n cancel: () => this.actions.cancel(),\n };\n return Injector.create({\n providers: [{ provide: CONFIRM_CONTEXT, useValue: context }],\n parent: this.injector,\n });\n });\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n forwardRef,\n input,\n} from '@angular/core';\nimport { REPEAT_SCOPE } from './tokens';\nimport type { RepeatScope } from './types';\n\n/**\n * Provides the repeat scope (item, index, absolute base path) to the elements\n * rendered inside a `repeat` block.\n *\n * @internal Used by `<jr-children>`; not intended for direct use.\n */\n@Component({\n selector: 'jr-repeat-scope',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n { provide: REPEAT_SCOPE, useExisting: forwardRef(() => JrRepeatScope) },\n ],\n styles: `:host { display: contents; }`,\n template: '<ng-content />',\n})\nexport class JrRepeatScope implements RepeatScope {\n readonly item = input.required<unknown>();\n readonly index = input.required<number>();\n readonly basePath = input.required<string>();\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n inject,\n input,\n untracked,\n} from '@angular/core';\nimport {\n getByPath,\n resolveRepeatItemStatePath,\n resolveRepeatStatePath,\n} from '@json-render/core';\nimport { JrElement } from './element.component';\nimport { JrRepeatScope } from './repeat-scope.component';\nimport { JsonRenderRootContext } from './root-context';\nimport { JsonRenderStateService } from './state.service';\nimport { REPEAT_SCOPE, injectRenderContext } from './tokens';\n\n/**\n * Renders the children of the current element. Place it inside a catalog\n * component's template where nested content should appear — like a\n * `<router-outlet>` for the spec tree.\n *\n * - Default (no `slot`): renders `element.children`, honoring the element's\n * `repeat` field (one pass per item of the referenced state array, with the\n * proper repeat scope for `$item` / `$index` / `$bindItem` expressions).\n * - With `slot`: renders the element keys of `element.slots[slot]`.\n *\n * @example\n * ```html\n * <div class=\"card\">\n * <h3>{{ ctx.props().title }}</h3>\n * <jr-children />\n * </div>\n * ```\n */\n@Component({\n selector: 'jr-children',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [JrElement, JrRepeatScope],\n styles: `:host { display: contents; }`,\n template: `\n @if (repeat()) {\n @for (item of repeatItems(); track trackItem($index, item)) {\n <jr-repeat-scope\n [item]=\"item\"\n [index]=\"$index\"\n [basePath]=\"itemPath($index)\"\n >\n @for (key of childKeys(); track key) {\n <jr-element [elementKey]=\"key\" />\n }\n </jr-repeat-scope>\n }\n } @else {\n @for (key of childKeys(); track key) {\n <jr-element [elementKey]=\"key\" />\n }\n }\n `,\n})\nexport class JrChildren {\n /** Named slot to render instead of the default children. */\n readonly slot = input<string | null>(null);\n\n private readonly ctx = injectRenderContext();\n private readonly root = inject(JsonRenderRootContext);\n private readonly state = inject(JsonRenderStateService);\n // The repeat scope enclosing the host element (scopes created by this\n // element's own repeat live below, in the template).\n private readonly parentScope = inject(REPEAT_SCOPE, { optional: true });\n\n protected readonly childKeys = computed<string[]>(() => {\n const el = this.ctx.element();\n if (!el) return [];\n const slot = this.slot();\n if (slot) return el.slots?.[slot] ?? [];\n return el.children ?? [];\n });\n\n protected readonly repeat = computed(() => {\n if (this.slot()) return undefined;\n return this.ctx.element()?.repeat;\n });\n\n private readonly repeatBasePath = computed<string | undefined>(() => {\n const rep = this.repeat();\n if (!rep) return undefined;\n const resolved = resolveRepeatStatePath(\n rep.statePath,\n this.parentScope?.basePath(),\n );\n if (resolved === undefined) {\n console.warn(\n '[ngx-json-render] $item in repeat.statePath used outside of a repeat scope',\n );\n }\n return resolved;\n });\n\n /** Every item the repeat's state array holds, before any cap. */\n private readonly allRepeatItems = computed<unknown[]>(() => {\n const basePath = this.repeatBasePath();\n if (basePath === undefined) return [];\n return (\n (getByPath(this.state.state(), basePath) as unknown[] | undefined) ?? []\n );\n });\n\n /**\n * The items this repeat actually renders.\n *\n * `repeat` iterates a state array the spec may itself have supplied, which\n * is the one place a spec sizes the render tree out of data rather than out\n * of its own structure — so the cap has to be applied here, as it expands,\n * rather than anywhere a spec can be inspected up front.\n */\n protected readonly repeatItems = computed<unknown[]>(() => {\n const items = this.allRepeatItems();\n const max = this.root.limits()?.maxRepeatItems;\n return max !== undefined && items.length > max\n ? items.slice(0, max)\n : items;\n });\n\n constructor() {\n // Warn (once) when the cap holds items back. Reading the count only after\n // the two cheap guards keeps the effect from tracking the state array at\n // all once there is nothing left to say.\n let warnedRepeatCap = false;\n effect(() => {\n const max = this.root.limits()?.maxRepeatItems;\n if (max === undefined || warnedRepeatCap) return;\n const total = this.allRepeatItems().length;\n if (total <= max) return;\n warnedRepeatCap = true;\n console.warn(\n `[ngx-json-render] renderLimits.maxRepeatItems (${max}) reached: \"${untracked(this.repeatBasePath)}\" holds ${total} items, so ${total - max} of them do not render.`,\n );\n });\n\n // Warn (once per key) about children referencing missing elements.\n const warned = new Set<string>();\n effect(() => {\n if (this.root.loading()) return;\n const spec = this.root.spec();\n if (!spec) return;\n for (const key of this.childKeys()) {\n if (!spec.elements?.[key] && !warned.has(key)) {\n warned.add(key);\n console.warn(\n `[json-render] Missing element \"${key}\" referenced as child of \"${untracked(this.ctx.element)?.type}\". This element will not render.`,\n );\n }\n }\n });\n }\n\n protected itemPath(index: number): string {\n return resolveRepeatItemStatePath(this.repeatBasePath()!, index);\n }\n\n protected trackItem(index: number, item: unknown): unknown {\n const rep = untracked(this.repeat);\n if (rep?.key && typeof item === 'object' && item !== null) {\n return (item as Record<string, unknown>)[rep.key] ?? index;\n }\n return index;\n }\n}\n","import type { Type } from '@angular/core';\nimport type { Catalog, StateStore } from '@json-render/core';\nimport { flattenToPointers } from './pointer';\nimport type {\n Actions,\n CatalogHasActions,\n ComponentRegistry,\n Components,\n RegistryEntry,\n SetState,\n StateModel,\n} from './types';\n\n/**\n * Result returned by {@link defineRegistry}.\n */\nexport interface DefineRegistryResult {\n /** Component registry for `<json-render [registry]=\"...\">`. */\n registry: ComponentRegistry;\n /**\n * Create renderer-compatible handlers from the catalog actions.\n * Accepts getter functions so handlers always read the latest\n * state/setState.\n */\n handlers: (\n getSetState: () => SetState | undefined,\n getState: () => StateModel,\n ) => Record<string, (params: Record<string, unknown>) => Promise<void>>;\n /**\n * Execute an action by name imperatively\n * (for use outside the renderer tree, e.g. initial state loading).\n */\n executeAction: (\n actionName: string,\n params: Record<string, unknown> | undefined,\n setState: SetState,\n state?: StateModel,\n ) => Promise<void>;\n}\n\n/**\n * Options for defineRegistry.\n *\n * When the catalog declares actions, the `actions` field is required.\n * When the catalog has no actions (or `actions: {}`), the field is optional.\n */\ntype DefineRegistryOptions<C extends Catalog> = {\n components?: Components<C>;\n} & (CatalogHasActions<C> extends true\n ? { actions: Actions<C> }\n : { actions?: Actions<C> });\n\n/** @internal */\ntype DefineRegistryActionFn = (\n params: Record<string, unknown> | undefined,\n setState: SetState,\n state: StateModel,\n) => Promise<void>;\n\n/**\n * Create a registry from a catalog with components and/or actions.\n *\n * Component keys are type-checked against the catalog, and slot metadata from\n * the catalog is carried into the registry for dev-mode slot warnings.\n *\n * @example\n * ```ts\n * const { registry, handlers } = defineRegistry(catalog, {\n * components: { Card: CardComponent, Button: ButtonComponent },\n * actions: {\n * refresh: async (params, setState) => {\n * setState((prev) => ({ ...prev, refreshedAt: Date.now() }));\n * },\n * },\n * });\n * ```\n */\nexport function defineRegistry<C extends Catalog>(\n catalog: C,\n options: DefineRegistryOptions<C>,\n): DefineRegistryResult {\n const catalogComponents = (\n catalog as unknown as {\n data?: { components?: Record<string, { slots?: string[] }> };\n }\n ).data?.components;\n\n // Build the component registry, attaching slot metadata from the catalog.\n const registry: ComponentRegistry = {};\n if (options.components) {\n for (const [name, value] of Object.entries(options.components) as Array<\n [string, Type<unknown> | Pick<RegistryEntry, 'component' | 'fallback'>]\n >) {\n const entry: RegistryEntry =\n typeof value === 'function'\n ? { component: value }\n : {\n component: value.component,\n ...(value.fallback ? { fallback: value.fallback } : {}),\n };\n const slots = catalogComponents?.[name]?.slots;\n if (slots) entry.slots = slots;\n registry[name] = entry;\n }\n }\n\n // Build action helpers.\n const actionMap = options.actions\n ? (Object.entries(options.actions) as Array<\n [string, DefineRegistryActionFn]\n >)\n : [];\n\n const handlers = (\n getSetState: () => SetState | undefined,\n getState: () => StateModel,\n ): Record<string, (params: Record<string, unknown>) => Promise<void>> => {\n const result: Record<\n string,\n (params: Record<string, unknown>) => Promise<void>\n > = {};\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\n const executeAction = async (\n actionName: string,\n params: Record<string, unknown> | undefined,\n setState: SetState,\n state: StateModel = {},\n ): Promise<void> => {\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\n return { registry, handlers, executeAction };\n}\n\n/**\n * Build a {@link SetState} (whole-state updater) on top of a path-based\n * store. The updater's result is diffed against the previous state and only\n * changed leaves are written, preserving fine-grained reactivity.\n *\n * Works with both a core {@link StateStore} and the renderer's injected\n * `JsonRenderStateService`.\n */\nexport function createStoreSetState(\n store: Pick<StateStore, 'getSnapshot' | 'update'>,\n): SetState {\n return (updater) => {\n const prev = store.getSnapshot();\n const next = updater(prev);\n if (next === prev) return;\n const prevFlat = flattenToPointers(prev);\n const nextFlat = flattenToPointers(next);\n const allKeys = new Set([\n ...Object.keys(prevFlat),\n ...Object.keys(nextFlat),\n ]);\n const updates: Record<string, unknown> = {};\n for (const key of allKeys) {\n if (prevFlat[key] !== nextFlat[key]) {\n updates[key] = key in nextFlat ? nextFlat[key] : undefined;\n }\n }\n if (Object.keys(updates).length > 0) {\n store.update(updates);\n }\n };\n}\n","import type { JsonPatch, Spec, UIElement } from '@json-render/core';\nimport {\n addByPath,\n getByPath,\n removeByPath,\n setByPath,\n} from '@json-render/core';\n\n/**\n * Writes a value at a path inside an already-private object. `addByPath` and\n * `setByPath` differ only on arrays — RFC 6902 `add` splices, `replace`\n * overwrites — which is why the op picks the writer rather than the path\n * routing below.\n */\ntype PathWriter = (\n obj: Record<string, unknown>,\n path: string,\n value: unknown,\n) => void;\n\n/**\n * Split a JSON Pointer into its segments, undoing RFC 6901's escapes.\n *\n * `@json-render/core` parses pointers the same way for `setByPath` and\n * friends but does not export the helper, so {@link copyAlongPath} carries\n * its own copy. The two must agree on where a path descends, or a write would\n * land on a node that was never copied.\n */\nfunction parseJsonPointer(path: string): string[] {\n const raw = path.startsWith('/') ? path.slice(1).split('/') : path.split('/');\n return raw.map((token) => token.replace(/~1/g, '/').replace(/~0/g, '~'));\n}\n\n/**\n * Replace every node `path` descends through with a shallow copy of itself.\n *\n * `root` must already be private to the caller. Afterwards a mutating write\n * along that same path — `setByPath`, `addByPath`, `removeByPath` — only ever\n * touches nodes nobody else is holding, while everything off the path stays\n * shared. That keeps a patch proportional to the depth of its path rather than\n * to the size of the spec, which matters when a stream applies hundreds of\n * them.\n *\n * Descent stops at anything that is not an object: the writers overwrite such\n * a node outright, and one that does not exist yet is created fresh, so in\n * neither case is there anything of the caller's left to protect.\n */\nfunction copyAlongPath(root: Record<string, unknown>, path: string): void {\n const segments = parseJsonPointer(path);\n let current = root;\n\n // The final segment is written, not descended into, so it needs no copy.\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i];\n const child = current[segment];\n if (child === null || typeof child !== 'object') return;\n\n const copy = Array.isArray(child)\n ? [...child]\n : { ...(child as Record<string, unknown>) };\n current[segment] = copy;\n current = copy as unknown as Record<string, unknown>;\n }\n}\n\n/**\n * Write a value at a spec path, copying every node on the way so the caller's\n * previous spec keeps its own contents.\n */\nfunction writeSpecValue(\n newSpec: Spec,\n path: string,\n value: unknown,\n write: PathWriter,\n): void {\n if (path === '/root') {\n newSpec.root = value as string;\n return;\n }\n\n if (path === '/state') {\n newSpec.state = value as Record<string, unknown>;\n return;\n }\n\n if (path.startsWith('/state/')) {\n if (!newSpec.state) newSpec.state = {};\n const statePath = path.slice('/state'.length); // e.g. \"/posts\"\n const state = newSpec.state as Record<string, unknown>;\n copyAlongPath(state, statePath);\n write(state, statePath, value);\n return;\n }\n\n if (path.startsWith('/elements/')) {\n const pathParts = path.slice('/elements/'.length).split('/');\n const elementKey = pathParts[0];\n if (!elementKey) return;\n\n if (pathParts.length === 1) {\n newSpec.elements[elementKey] = value as UIElement;\n return;\n }\n\n // A prop path whose element is not there is dropped rather than\n // auto-created: the generic writers would happily conjure an element with\n // props and no `type`, which renders as nothing and warns about an unknown\n // component. A malformed patch should lose its own write, not add a broken\n // element to the tree.\n const element = newSpec.elements[elementKey];\n if (!element) return;\n\n const propPath = '/' + pathParts.slice(1).join('/');\n const newElement = { ...element } as unknown as Record<string, unknown>;\n copyAlongPath(newElement, propPath);\n write(newElement, propPath, value);\n newSpec.elements[elementKey] = newElement as unknown as UIElement;\n return;\n }\n\n // Any other top-level path is applied verbatim. The spec grammar is\n // upstream's and grows without this renderer: dropping what we do not\n // recognise would silently discard a field a newer `@json-render/core`\n // understands.\n const root = newSpec as unknown as Record<string, unknown>;\n copyAlongPath(root, path);\n write(root, path, value);\n}\n\n/** Remove the value at a spec path, with the same copy-on-write discipline. */\nfunction removeSpecValue(newSpec: Spec, path: string): void {\n if (path === '/state') {\n delete newSpec.state;\n return;\n }\n\n if (path.startsWith('/state/') && newSpec.state) {\n const statePath = path.slice('/state'.length);\n const state = newSpec.state as Record<string, unknown>;\n copyAlongPath(state, statePath);\n removeByPath(state, statePath);\n return;\n }\n\n if (path.startsWith('/elements/')) {\n const pathParts = path.slice('/elements/'.length).split('/');\n const elementKey = pathParts[0];\n if (!elementKey) return;\n\n if (pathParts.length === 1) {\n const { [elementKey]: _removed, ...rest } = newSpec.elements;\n newSpec.elements = rest;\n return;\n }\n\n const element = newSpec.elements[elementKey];\n if (!element) return;\n\n const propPath = '/' + pathParts.slice(1).join('/');\n const newElement = { ...element } as unknown as Record<string, unknown>;\n copyAlongPath(newElement, propPath);\n removeByPath(newElement, propPath);\n newSpec.elements[elementKey] = newElement as unknown as UIElement;\n return;\n }\n\n const root = newSpec as unknown as Record<string, unknown>;\n copyAlongPath(root, path);\n removeByPath(root, path);\n}\n\n/**\n * Apply an RFC 6902 JSON patch to a spec, returning a new spec object and\n * sharing every subtree the patch did not touch.\n *\n * This is the only patch engine in the package: `injectUIStream`,\n * `injectChatUI` and `buildSpecFromParts` all route through it, so the same\n * stream produces the same spec whichever one an app reached for. The write\n * primitives come from `@json-render/core`, so `add` splices into an array\n * where `replace` overwrites, exactly as the other renderers do.\n *\n * One deliberate deviation from RFC 6902: a failing `test` op is a no-op\n * rather than an abort. These patches come off a model's output, where the\n * established behaviour — see the line parser — is to drop what does not make\n * sense and keep rendering rather than kill a generation mid-flight.\n */\nexport function applyPatch(spec: Spec, patch: JsonPatch): Spec {\n const newSpec = {\n ...spec,\n elements: { ...spec.elements },\n ...(spec.state ? { state: { ...spec.state } } : {}),\n };\n\n switch (patch.op) {\n case 'add': {\n writeSpecValue(newSpec, patch.path, patch.value, addByPath);\n break;\n }\n case 'replace': {\n writeSpecValue(newSpec, patch.path, patch.value, setByPath);\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 = getByPath(newSpec, patch.from);\n removeSpecValue(newSpec, patch.from);\n writeSpecValue(newSpec, patch.path, moveValue, addByPath);\n break;\n }\n case 'copy': {\n if (!patch.from) break;\n // RFC 6902 copies the *value*. Handing over the live reference instead\n // aliases source and target, and a `path` that descends into its own\n // `from` then makes the spec self-referential — which the next request\n // discovers when it tries to serialise it into the body.\n const copyValue = structuredClone(getByPath(newSpec, patch.from));\n writeSpecValue(newSpec, patch.path, copyValue, addByPath);\n break;\n }\n case 'test': {\n break;\n }\n }\n\n return newSpec;\n}\n","import type { JsonPatch } from '@json-render/core';\n\n/** Token usage as the AI SDK reports it in its usage line. */\nexport interface StreamObserverUsage {\n promptTokens: number;\n completionTokens: number;\n totalTokens: number;\n}\n\n/**\n * Hooks into every `injectUIStream` and `injectChatUI` generation in the app,\n * the counterpart of `registerActionObserver` in `@json-render/core`. This is\n * what `ngx-json-render/devtools` fills its Stream tab from, so it is private\n * API: the `ɵ` prefix says it may change in any release.\n */\nexport interface StreamObserver {\n /** A generation started. */\n onStart?(): void;\n /** A patch was applied to the spec, in arrival order. */\n onPatch?(patch: JsonPatch): void;\n /** A line of prose arrived (`injectChatUI` only). */\n onText?(text: string): void;\n /** The usage line arrived (`injectUIStream` only). */\n onUsage?(usage: StreamObserverUsage): void;\n /** The generation ended; `ok` is false on an error, true on a stop. */\n onEnd?(ok: boolean): void;\n}\n\nconst observers = new Set<StreamObserver>();\n\n/**\n * Register an observer for every stream in the app. Returns the function that\n * removes it. Private API for `ngx-json-render/devtools`.\n */\nexport function ɵregisterStreamObserver(observer: StreamObserver): () => void {\n observers.add(observer);\n return () => {\n observers.delete(observer);\n };\n}\n\n/**\n * Tell every observer. An observer that throws is a devtools bug, and it must\n * not become a failed generation in the app it is inspecting.\n */\nexport function notifyStreamObservers<K extends keyof StreamObserver>(\n event: K,\n ...args: Parameters<NonNullable<StreamObserver[K]>>\n): void {\n if (observers.size === 0) return;\n for (const observer of observers) {\n try {\n (observer[event] as ((...a: typeof args) => void) | undefined)?.(...args);\n } catch (error) {\n console.error('[ngx-json-render] A stream observer threw:', error);\n }\n }\n}\n\n/**\n * The start and end of one hook's generations, as observers see them.\n *\n * A superseded or stopped request only settles once its abort has gone\n * through, after the next generation may already have started. Reporting its\n * end from there would close the new generation instead of the old one, so a\n * generation ends here the moment it is superseded or stopped, and its own\n * late end is dropped.\n */\nexport function createObservedRuns(): {\n /** Start a generation, ending any still open. Returns its end. */\n start: () => (ok: boolean) => void;\n /** End the open generation, if any, as a stop. */\n stop: () => void;\n} {\n let endOpen: (() => void) | null = null;\n return {\n start() {\n endOpen?.();\n let ended = false;\n const end = (ok: boolean) => {\n if (ended) return;\n ended = true;\n if (endOpen === stop) endOpen = null;\n notifyStreamObservers('onEnd', ok);\n };\n const stop = () => end(true);\n endOpen = stop;\n notifyStreamObservers('onStart');\n return end;\n },\n stop() {\n endOpen?.();\n },\n };\n}\n","import { type Signal, computed } from '@angular/core';\nimport type {\n FlatElement,\n Spec,\n SpecDataPart,\n UIElement,\n} from '@json-render/core';\nimport { SPEC_DATA_PART_TYPE, nestedToFlat } from '@json-render/core';\nimport { applyPatch } from './patch';\n\n/**\n * Convert a flat element list to a Spec.\n * Input elements use key/parentKey to establish identity and relationships.\n * Output spec uses the map-based format where key is the map entry key\n * and parent-child relationships are expressed through children arrays.\n */\nexport function flatToTree(elements: FlatElement[]): Spec {\n // The map is what gives every element its children array, so the second\n // pass can push into one without checking for it.\n const elementMap: Record<string, UIElement & { children: string[] }> = {};\n let root = '';\n\n // First pass: add all elements to map\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\n // Second pass: build parent-child relationships\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n\n return { root, elements: elementMap };\n}\n\n/**\n * A single part from the AI SDK's `message.parts` array. This is a minimal\n * structural type so that library helpers do not depend on the AI SDK.\n */\nexport interface DataPart {\n type: string;\n text?: string;\n data?: unknown;\n /**\n * The SDK's reconciliation key. A part written with one is *replaced* by the\n * next part carrying the same id, rather than followed by it — so a spec\n * streamed as patches must be written without an id, and only a whole-spec\n * part (`flat` / `nested`), which is a snapshot of itself, can share one.\n */\n id?: string;\n}\n\n/**\n * Type guard that validates a data part payload looks like a valid\n * {@link SpecDataPart} before we cast it.\n */\nfunction isSpecDataPart(data: unknown): data is SpecDataPart {\n if (typeof data !== 'object' || data === null) return false;\n const obj = data as Record<string, unknown>;\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}\n\n/**\n * Build a `Spec` by replaying all spec data parts from a message's\n * parts array (AI SDK `UIMessage.parts`). Returns `null` if no spec data\n * parts are present.\n */\nexport function buildSpecFromParts(parts: DataPart[]): Spec | null {\n let spec: Spec = { root: '', elements: {} };\n let hasSpec = false;\n\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 spec = applyPatch(spec, payload.patch);\n } else if (payload.type === 'flat') {\n hasSpec = true;\n spec = { ...spec, ...payload.spec };\n } else if (payload.type === 'nested') {\n hasSpec = true;\n spec = { ...spec, ...nestedToFlat(payload.spec) };\n }\n }\n }\n\n return hasSpec ? spec : null;\n}\n\n/**\n * Extract and join all text content from a message's parts array.\n */\nexport function getTextFromParts(parts: DataPart[]): string {\n return parts\n .filter(\n (p): p is DataPart & { text: string } =>\n p.type === 'text' && typeof p.text === 'string',\n )\n .map((p) => p.text.trim())\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Extract both the json-render spec and the text content from a message's\n * parts array, as memoized signals. Angular counterpart of\n * `useJsonRenderMessage` from the other renderers.\n *\n * @example\n * ```ts\n * readonly msg = jsonRenderMessage(() => this.message().parts);\n * // template: @if (msg.hasSpec()) { <json-render [spec]=\"msg.spec()\" ... /> }\n * ```\n */\nexport function jsonRenderMessage(\n parts: Signal<DataPart[]> | (() => DataPart[]),\n): {\n spec: Signal<Spec | null>;\n text: Signal<string>;\n hasSpec: Signal<boolean>;\n} {\n const result = computed(() => {\n const p = parts();\n return {\n spec: buildSpecFromParts(p),\n text: getTextFromParts(p),\n };\n });\n\n return {\n spec: computed(() => result().spec),\n text: computed(() => result().text),\n hasSpec: computed(() => {\n const s = result().spec;\n return s !== null && Object.keys(s.elements || {}).length > 0;\n }),\n };\n}\n","/**\n * Sink for the decoded text of a streamed response. `@json-render/core`'s\n * mixed-stream parser already has this shape, so a hook can hand its own\n * consumer or the core one to {@link streamRequest} unchanged.\n */\nexport interface StreamConsumer {\n push(text: string): void;\n flush(): void;\n}\n\n/** One streamed POST: where to send it, what to send, and how to cancel it. */\nexport interface StreamRequest {\n api: string;\n body: unknown;\n fetch?: typeof globalThis.fetch;\n signal: AbortSignal;\n}\n\n/**\n * The write permit of a single request.\n *\n * A hook's signals are shared by every request it ever makes, so a request\n * that has been superseded must not write to them on its way out — its stale\n * spec would flash over the fresh one, and its `finally` would clear\n * `isStreaming` while its replacement is still streaming. Routing every write\n * and callback through {@link commit} makes that structural: a superseded\n * request has no way to reach the signals, rather than each write site being\n * individually responsible for remembering to check.\n */\nexport interface RequestGate {\n readonly signal: AbortSignal;\n /** Whether this request is still the session's current one. */\n isCurrent(): boolean;\n /** Run `write` only while this request is still the current one. */\n commit(write: () => void): void;\n}\n\n/**\n * Tracks which request owns a hook's signals. Each {@link begin} supersedes\n * the one before it.\n */\nexport interface StreamSession {\n begin(): RequestGate;\n /** Abort the in-flight request, leaving no request current. */\n cancel(): void;\n}\n\nexport function createStreamSession(): StreamSession {\n let current: AbortController | null = null;\n\n return {\n begin(): RequestGate {\n current?.abort();\n const controller = new AbortController();\n current = controller;\n const isCurrent = () => current === controller;\n return {\n signal: controller.signal,\n isCurrent,\n commit(write) {\n if (isCurrent()) write();\n },\n };\n },\n cancel() {\n current?.abort();\n // Cleared, not just aborted: with no current controller the in-flight\n // request's gate closes too, so a stop() cannot be undone a moment later\n // by the request it just cancelled.\n current = null;\n },\n };\n}\n\n/** True for the rejection `fetch` and a stream reader raise on abort. */\nexport function isAbortError(error: unknown): boolean {\n return (error as Error | undefined)?.name === 'AbortError';\n}\n\n/**\n * Buffer decoded text and hand back whole lines, dropping blank ones. What is\n * left when the stream ends is flushed as a final line, since a model's last\n * line often arrives without its newline.\n */\nexport function createLineConsumer(\n onLine: (line: string) => void,\n): StreamConsumer {\n let buffer = '';\n return {\n push(text) {\n buffer += text;\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed) onLine(trimmed);\n }\n },\n flush() {\n const trimmed = buffer.trim();\n buffer = '';\n if (trimmed) onLine(trimmed);\n },\n };\n}\n\n/**\n * Mine an error response for something better to show than its status code.\n */\nasync function readErrorMessage(response: Response): Promise<string> {\n try {\n const body = await response.json();\n if (body.message) return String(body.message);\n if (body.error) return String(body.error);\n } catch {\n // A non-JSON error body is ordinary; the status line still says enough.\n }\n return `HTTP error: ${response.status}`;\n}\n\n/**\n * POST `body` and feed the streamed response to `consumer` until it ends.\n *\n * Both hooks share this so the request lifecycle — error mining, the reader\n * loop, the decoder's final flush — has one implementation to get right\n * rather than one per hook that has to be fixed twice.\n */\nexport async function streamRequest(\n request: StreamRequest,\n consumer: StreamConsumer,\n): Promise<void> {\n // Bound, because a bare `globalThis.fetch` called as a plain function is\n // an illegal invocation in the browser.\n const doFetch = request.fetch ?? globalThis.fetch.bind(globalThis);\n\n const response = await doFetch(request.api, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(request.body),\n signal: request.signal,\n });\n\n if (!response.ok) {\n throw new Error(await readErrorMessage(response));\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No response body');\n }\n\n const decoder = new TextDecoder();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n consumer.push(decoder.decode(value, { stream: true }));\n }\n\n // Without the final, non-streaming decode a multi-byte character split\n // across the last chunk is dropped instead of surfacing.\n const tail = decoder.decode();\n if (tail) consumer.push(tail);\n\n consumer.flush();\n}\n","import { DestroyRef, type Signal, inject, signal } from '@angular/core';\nimport type { JsonPatch, Spec } from '@json-render/core';\nimport type {\n RenderLimits,\n SpecCatalog,\n SpecCheckIssue,\n} from '../render-limits';\nimport {\n type SpecValidationMode,\n checkSpec,\n formatSpecCheckIssues,\n reportSpecCheck,\n} from '../spec-validation';\nimport { createObservedRuns, notifyStreamObservers } from './observer';\nimport { applyPatch } from './patch';\nimport {\n createLineConsumer,\n createStreamSession,\n isAbortError,\n streamRequest,\n} from './transport';\n\n/**\n * Token usage metadata from AI generation.\n */\nexport interface TokenUsage {\n promptTokens: number;\n completionTokens: number;\n totalTokens: number;\n}\n\n/**\n * Parse result for a single line — either a patch or usage metadata.\n */\ntype ParsedLine =\n | { type: 'patch'; patch: JsonPatch }\n | { type: 'usage'; usage: TokenUsage }\n | null;\n\n/**\n * Parse a single JSON line (patch or metadata). Anything that is not one of\n * the two is dropped: half-written lines and stray prose are ordinary in a\n * model's output, and aborting the generation over one would lose the UI\n * built so far.\n */\nfunction parseLine(line: string): ParsedLine {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('//')) {\n return null;\n }\n const parsed = JSON.parse(trimmed);\n\n // Check for usage metadata\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\n // Parseable JSON is not yet a patch: without this, a stray object would be\n // recorded as a raw line and handed to the engine as an opless patch.\n if (typeof parsed?.op !== 'string' || typeof parsed?.path !== 'string') {\n return null;\n }\n\n return { type: 'patch', patch: parsed as JsonPatch };\n } catch {\n return null;\n }\n}\n\n/**\n * Per-call options for {@link UIStreamReturn.send}.\n */\nexport interface UIStreamSendOptions {\n /** Arbitrary context forwarded to the endpoint as `context`. */\n context?: Record<string, unknown>;\n /**\n * Spec to refine instead of starting from an empty one. It is sent to the\n * endpoint as `currentSpec` and the streamed patches apply on top of it.\n */\n previousSpec?: Spec;\n}\n\n/**\n * Options for {@link injectUIStream}.\n */\nexport interface UIStreamOptions {\n /** API endpoint */\n api: string;\n /** Callback when complete */\n onComplete?: (spec: Spec) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n /**\n * Whether to check the finished spec's structure, and what a problem means.\n * Off by default.\n *\n * The check runs once, when the generation completes — a spec mid-stream is\n * supposed to be incomplete. Both modes apply the lossless fixes and publish\n * the fixed spec; `'warn'` reports what is left, while `'strict'` fails the\n * generation instead of calling `onComplete`, so an app that persists the\n * spec there does not persist a broken one.\n */\n validate?: SpecValidationMode;\n /**\n * Caps on what the finished spec may cost the browser. Enforced whatever\n * `validate` is: a spec over `maxElements` fails the generation rather than\n * reaching `onComplete`.\n */\n renderLimits?: RenderLimits | null;\n /**\n * The catalog the spec was generated for. Given one, `validate` also checks\n * every element `type` against the catalog and each element's props against\n * its component's schema — the half a structural check cannot see. Props\n * written as expressions are left alone: they have no value until render\n * time.\n */\n catalog?: SpecCatalog | null;\n /**\n * Transport, defaulting to the global `fetch`.\n *\n * Anything with fetch's shape works, so a test, a demo replaying a recorded\n * generation, or an app that has to add auth headers or route through its\n * own HTTP layer can supply one instead of patching the global. It is called\n * with the endpoint and a request carrying the JSON body and the abort\n * signal, and must resolve to a `Response` whose `body` is a readable\n * stream of the JSONL patches.\n */\n fetch?: typeof globalThis.fetch;\n}\n\n/**\n * Return type for {@link injectUIStream}.\n */\nexport interface UIStreamReturn {\n /** Current UI spec */\n readonly spec: Signal<Spec | null>;\n /** Whether currently streaming */\n readonly isStreaming: Signal<boolean>;\n /** Error if any */\n readonly error: Signal<Error | null>;\n /** Token usage from the last generation */\n readonly usage: Signal<TokenUsage | null>;\n /** Raw JSONL lines received from the stream (JSON patch lines) */\n readonly rawLines: Signal<string[]>;\n /**\n * What the check found in the finished spec — structure, catalog and\n * limits alike. Empty until a generation completes; empty while `validate`\n * is off unless a `renderLimits` cap was passed, since those are enforced\n * in every mode.\n */\n readonly issues: Signal<readonly SpecCheckIssue[]>;\n /** Send a prompt to generate UI */\n send: (prompt: string, options?: UIStreamSendOptions) => Promise<void>;\n /**\n * Stop the in-flight generation, keeping whatever has rendered so far.\n * A no-op when nothing is streaming.\n */\n stop: () => void;\n /** Stop any generation and clear the spec, error, usage and raw lines. */\n clear: () => void;\n}\n\n/**\n * Streaming UI generation. POSTs `{ prompt, context, currentSpec }` to the\n * endpoint and progressively applies the returned JSONL patch stream to the\n * `spec` signal, so partial UIs render as they arrive.\n *\n * Must be called in an injection context (aborts in-flight requests on\n * destroy).\n *\n * @example\n * ```ts\n * export class GeneratePage {\n * readonly ui = injectUIStream({ api: '/api/generate' });\n * }\n * // template:\n * // <json-render [spec]=\"ui.spec()\" [registry]=\"registry\" [loading]=\"ui.isStreaming()\" />\n * ```\n */\nexport function injectUIStream(options: UIStreamOptions): UIStreamReturn {\n const spec = signal<Spec | null>(null);\n const isStreaming = signal(false);\n const error = signal<Error | null>(null);\n const usage = signal<TokenUsage | null>(null);\n const rawLines = signal<string[]>([]);\n const issues = signal<readonly SpecCheckIssue[]>([]);\n const validate = options.validate ?? 'off';\n const checkOptions = {\n limits: options.renderLimits ?? null,\n catalog: options.catalog ?? null,\n };\n const session = createStreamSession();\n const runs = createObservedRuns();\n\n inject(DestroyRef).onDestroy(() => session.cancel());\n\n const stop = () => {\n session.cancel();\n runs.stop();\n isStreaming.set(false);\n };\n\n const clear = () => {\n // Aborting first is what makes this true: without it the in-flight\n // request puts its spec straight back on the next patch it applies.\n stop();\n spec.set(null);\n error.set(null);\n usage.set(null);\n rawLines.set([]);\n issues.set([]);\n };\n\n const send = async (prompt: string, sendOptions?: UIStreamSendOptions) => {\n const gate = session.begin();\n\n isStreaming.set(true);\n error.set(null);\n usage.set(null);\n rawLines.set([]);\n issues.set([]);\n\n const previousSpec = sendOptions?.previousSpec;\n let currentSpec: Spec =\n previousSpec && previousSpec.root\n ? { ...previousSpec, elements: { ...previousSpec.elements } }\n : { root: '', elements: {} };\n spec.set(currentSpec);\n const end = runs.start();\n let failed = false;\n\n const handleLine = (line: string) => {\n const parsed = parseLine(line);\n if (!parsed) return;\n gate.commit(() => {\n if (parsed.type === 'usage') {\n usage.set(parsed.usage);\n notifyStreamObservers('onUsage', parsed.usage);\n return;\n }\n rawLines.update((prev) => [...prev, line]);\n currentSpec = applyPatch(currentSpec, parsed.patch);\n spec.set(currentSpec);\n notifyStreamObservers('onPatch', parsed.patch);\n });\n };\n\n try {\n await streamRequest(\n {\n api: options.api,\n body: {\n prompt,\n context: sendOptions?.context,\n currentSpec,\n },\n fetch: options.fetch,\n signal: gate.signal,\n },\n createLineConsumer(handleLine),\n );\n\n gate.commit(() => {\n const check = checkSpec(currentSpec, validate, checkOptions);\n reportSpecCheck(check, validate);\n if (check.spec) {\n currentSpec = check.spec;\n spec.set(currentSpec);\n }\n issues.set(check.issues);\n\n // Under `strict` a broken generation is a failure, not a result: the\n // app's onComplete is where a spec usually gets persisted, and handing\n // it one that cannot render is the outcome this mode is asked to\n // prevent. The spec stays put so the app can show or discard it.\n // A limit the app set fails the generation whatever the mode: the\n // spec it would hand `onComplete` is one the app already said it did\n // not want rendered.\n if (check.blocked || (validate === 'strict' && check.hasErrors)) {\n const invalid = new Error(\n `Generated spec failed validation:\\n${formatSpecCheckIssues(check.issues)}`,\n );\n failed = true;\n error.set(invalid);\n options.onError?.(invalid);\n return;\n }\n options.onComplete?.(currentSpec);\n });\n } catch (err) {\n if (isAbortError(err)) return;\n failed = true;\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n gate.commit(() => {\n error.set(resolvedError);\n options.onError?.(resolvedError);\n });\n } finally {\n gate.commit(() => isStreaming.set(false));\n end(!failed);\n }\n };\n\n return {\n spec: spec.asReadonly(),\n isStreaming: isStreaming.asReadonly(),\n error: error.asReadonly(),\n usage: usage.asReadonly(),\n rawLines: rawLines.asReadonly(),\n issues: issues.asReadonly(),\n send,\n stop,\n clear,\n };\n}\n","import { DestroyRef, type Signal, inject, signal } from '@angular/core';\nimport type { Spec } from '@json-render/core';\nimport { createMixedStreamParser } from '@json-render/core';\nimport type {\n RenderLimits,\n SpecCatalog,\n SpecCheckIssue,\n} from '../render-limits';\nimport {\n type SpecValidationMode,\n checkSpec,\n formatSpecCheckIssues,\n reportSpecCheck,\n} from '../spec-validation';\nimport { createObservedRuns, notifyStreamObservers } from './observer';\nimport { applyPatch } from './patch';\nimport { createStreamSession, isAbortError, streamRequest } from './transport';\n\n/**\n * A single message in the chat, which may contain text, a rendered UI spec,\n * or both.\n */\nexport interface ChatMessage {\n /** Unique message ID */\n id: string;\n /** Who sent this message */\n role: 'user' | 'assistant';\n /** Text content (conversational prose) */\n text: string;\n /** json-render Spec built from JSONL patches (null if no UI was generated) */\n spec: Spec | null;\n}\n\n/**\n * Options for {@link injectChatUI}.\n */\nexport interface ChatUIOptions {\n /** API endpoint that accepts `{ messages: Array<{ role, content }> }` and returns a text stream */\n api: string;\n /** Callback when streaming completes for a message */\n onComplete?: (message: ChatMessage) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n /**\n * Transport, defaulting to the global `fetch`. Same contract as\n * `UIStreamOptions.fetch`: it receives the endpoint and a request\n * carrying the JSON body and the abort signal, and must resolve to a\n * `Response` whose `body` streams the reply.\n */\n fetch?: typeof globalThis.fetch;\n /**\n * Whether to check the spec a reply built, and what a problem means. Off by\n * default; same contract as `UIStreamOptions.validate`, applied once per\n * reply that produced a spec.\n */\n validate?: SpecValidationMode;\n /**\n * Caps on what the finished spec may cost the browser. Enforced whatever\n * `validate` is: a spec over `maxElements` fails the generation rather than\n * reaching `onComplete`.\n */\n renderLimits?: RenderLimits | null;\n /**\n * The catalog the spec was generated for. Given one, `validate` also checks\n * every element `type` against the catalog and each element's props against\n * its component's schema — the half a structural check cannot see. Props\n * written as expressions are left alone: they have no value until render\n * time.\n */\n catalog?: SpecCatalog | null;\n}\n\n/**\n * Return type for {@link injectChatUI}.\n */\nexport interface ChatUIReturn {\n /** All messages in the conversation */\n readonly messages: Signal<ChatMessage[]>;\n /** Whether currently streaming an assistant response */\n readonly isStreaming: Signal<boolean>;\n /** Error from the last request, if any */\n readonly error: Signal<Error | null>;\n /**\n * What the check found in the last completed reply's spec — structure,\n * catalog and limits alike. Empty until a reply completes; empty while\n * `validate` is off unless a `renderLimits` cap was passed, since those are\n * enforced in every mode.\n */\n readonly issues: Signal<readonly SpecCheckIssue[]>;\n /** Send a user message */\n send: (text: string) => Promise<void>;\n /**\n * Stop the in-flight reply, keeping whatever the assistant has said so far.\n * A no-op when nothing is streaming.\n */\n stop: () => void;\n /** Stop any reply and clear all messages and the error. */\n clear: () => void;\n}\n\nlet chatMessageIdCounter = 0;\nfunction generateChatId(): string {\n if (\n typeof crypto !== 'undefined' &&\n typeof crypto.randomUUID === 'function'\n ) {\n return crypto.randomUUID();\n }\n chatMessageIdCounter += 1;\n return `msg-${Date.now()}-${chatMessageIdCounter}`;\n}\n\n/**\n * Chat + GenUI: manages a multi-turn conversation where each assistant\n * message can contain both conversational text and a json-render UI spec.\n * The full message history is sent to the endpoint and the streamed response\n * is split into text lines and JSONL patch lines.\n *\n * Must be called in an injection context.\n */\nexport function injectChatUI(options: ChatUIOptions): ChatUIReturn {\n const messages = signal<ChatMessage[]>([]);\n const isStreaming = signal(false);\n const error = signal<Error | null>(null);\n const issues = signal<readonly SpecCheckIssue[]>([]);\n const validate = options.validate ?? 'off';\n const checkOptions = {\n limits: options.renderLimits ?? null,\n catalog: options.catalog ?? null,\n };\n const session = createStreamSession();\n const runs = createObservedRuns();\n\n inject(DestroyRef).onDestroy(() => session.cancel());\n\n const stop = () => {\n session.cancel();\n runs.stop();\n isStreaming.set(false);\n };\n\n const clear = () => {\n stop();\n messages.set([]);\n error.set(null);\n issues.set([]);\n };\n\n const send = async (text: string) => {\n if (!text.trim()) return;\n\n const gate = session.begin();\n\n const userMessage: ChatMessage = {\n id: generateChatId(),\n role: 'user',\n text: text.trim(),\n spec: null,\n };\n\n const assistantId = generateChatId();\n const assistantMessage: ChatMessage = {\n id: assistantId,\n role: 'assistant',\n text: '',\n spec: null,\n };\n\n /**\n * Drop this turn's assistant bubble if it never got any text.\n *\n * Deliberately outside the gate: the edit is scoped to this request's own\n * message id, so it is safe even once a newer request has appended its\n * turn — and a superseded request is exactly when it is needed, since an\n * empty bubble left behind renders as a blank reply and is serialised\n * into every later turn's history.\n */\n const dropEmptyPlaceholder = () => {\n messages.update((prev) =>\n prev.filter((m) => m.id !== assistantId || m.text.length > 0),\n );\n };\n\n // Built before the new turn is appended, so it carries the conversation so\n // far. Assistant turns with no text are left out: they say nothing to the\n // model, some providers reject empty content outright, and a turn being\n // superseded right now may still have its placeholder in the list.\n const historyForApi = [\n ...messages()\n .filter((m) => m.role !== 'assistant' || m.text.length > 0)\n .map((m) => ({\n role: m.role,\n content: m.text,\n })),\n { role: 'user' as const, content: text.trim() },\n ];\n\n // Append user message and empty assistant placeholder\n messages.update((prev) => [...prev, userMessage, assistantMessage]);\n isStreaming.set(true);\n error.set(null);\n const end = runs.start();\n let failed = false;\n\n // Mutable state for accumulating the assistant response\n let accumulatedText = '';\n let currentSpec: Spec = { root: '', elements: {} };\n let hasSpec = false;\n\n const parser = createMixedStreamParser({\n onPatch(patch) {\n hasSpec = true;\n // applyPatch returns a fresh spec that shares what the patch did not\n // touch, so the message can hold it directly — no snapshot copy.\n currentSpec = applyPatch(currentSpec, patch);\n const snapshot = currentSpec;\n gate.commit(() => {\n messages.update((prev) =>\n prev.map((m) =>\n m.id === assistantId ? { ...m, spec: snapshot } : m,\n ),\n );\n notifyStreamObservers('onPatch', patch);\n });\n },\n onText(line) {\n accumulatedText += (accumulatedText ? '\\n' : '') + line;\n const snapshot = accumulatedText;\n gate.commit(() => {\n messages.update((prev) =>\n prev.map((m) =>\n m.id === assistantId ? { ...m, text: snapshot } : m,\n ),\n );\n notifyStreamObservers('onText', line);\n });\n },\n });\n\n try {\n await streamRequest(\n {\n api: options.api,\n body: { messages: historyForApi },\n fetch: options.fetch,\n signal: gate.signal,\n },\n parser,\n );\n\n gate.commit(() => {\n // A reply that only talked has no spec to check, and reporting\n // \"missing root\" for a sentence would be nonsense.\n const check = checkSpec(\n hasSpec ? currentSpec : null,\n validate,\n checkOptions,\n );\n if (hasSpec) {\n reportSpecCheck(check, validate);\n if (check.spec) currentSpec = check.spec;\n }\n issues.set(check.issues);\n\n const finalMessage: ChatMessage = {\n id: assistantId,\n role: 'assistant',\n text: accumulatedText,\n spec: hasSpec ? currentSpec : null,\n };\n // The reply keeps the fixed spec, so what renders in the bubble is\n // what was checked.\n messages.update((prev) =>\n prev.map((m) => (m.id === assistantId ? finalMessage : m)),\n );\n\n // A limit the app set fails the generation whatever the mode: the\n // spec it would hand `onComplete` is one the app already said it did\n // not want rendered.\n if (check.blocked || (validate === 'strict' && check.hasErrors)) {\n const invalid = new Error(\n `Generated spec failed validation:\\n${formatSpecCheckIssues(check.issues)}`,\n );\n failed = true;\n error.set(invalid);\n options.onError?.(invalid);\n return;\n }\n options.onComplete?.(finalMessage);\n });\n } catch (err) {\n // Unconditional: however this turn ended, its own bubble goes with it if\n // nothing was ever said into it. A superseded request usually unwinds by\n // abort, but one whose stream failed for its own reason after being\n // replaced would otherwise leave the placeholder behind.\n dropEmptyPlaceholder();\n if (isAbortError(err)) return;\n failed = true;\n const resolvedError = err instanceof Error ? err : new Error(String(err));\n gate.commit(() => {\n error.set(resolvedError);\n options.onError?.(resolvedError);\n });\n } finally {\n gate.commit(() => isStreaming.set(false));\n end(!failed);\n }\n };\n\n return {\n messages: messages.asReadonly(),\n isStreaming: isStreaming.asReadonly(),\n error: error.asReadonly(),\n issues: issues.asReadonly(),\n send,\n stop,\n clear,\n };\n}\n","/**\n * Streaming: applying a model's output to a spec as it arrives.\n *\n * - `patch` — the immutable RFC 6902 engine every entry point applies through.\n * - `transport` — one streamed request lifecycle, shared by both hooks.\n * - `parts` — adapters for the AI SDK's message parts.\n * - `ui-stream` / `chat-ui` — the two hooks, composed from the above.\n */\nexport { applyPatch } from './patch';\nexport {\n ɵregisterStreamObserver,\n type StreamObserver,\n type StreamObserverUsage,\n} from './observer';\nexport {\n buildSpecFromParts,\n flatToTree,\n getTextFromParts,\n jsonRenderMessage,\n type DataPart,\n} from './parts';\nexport {\n injectUIStream,\n type TokenUsage,\n type UIStreamOptions,\n type UIStreamReturn,\n type UIStreamSendOptions,\n} from './ui-stream';\nexport {\n injectChatUI,\n type ChatMessage,\n type ChatUIOptions,\n type ChatUIReturn,\n} from './chat-ui';\n","/*\n * Public API Surface of ngx-json-render\n */\n\n// Renderer components\nexport { JsonRenderer } from './lib/renderer.component';\nexport { JrChildren } from './lib/children.component';\nexport { JrElement } from './lib/element.component';\nexport { JrRepeatScope } from './lib/repeat-scope.component';\nexport { JrConfirmDialog } from './lib/confirm-dialog.component';\nexport {\n CONFIRM_CONTEXT,\n JR_CONFIRM_DIALOG,\n JR_CONFIRM_LABELS,\n injectConfirmContext,\n type ConfirmContext,\n type ConfirmLabels,\n} from './lib/confirm-tokens';\n\n// App-wide defaults\nexport {\n JSON_RENDER_CONFIG,\n provideJsonRender,\n type JsonRenderConfig,\n} from './lib/provide';\n\n// Render context / DI\nexport {\n ELEMENT_KEY,\n RENDER_CONTEXT,\n REPEAT_SCOPE,\n injectElementKey,\n injectRenderContext,\n injectRepeatScope,\n} from './lib/tokens';\nexport { JsonRenderRootContext } from './lib/root-context';\n\n// State\nexport {\n JsonRenderStateService,\n injectStateStore,\n injectStateValue,\n injectStateBinding,\n injectBoundProp,\n} from './lib/state.service';\n\n// Actions\nexport {\n JsonRenderActionsService,\n injectActions,\n injectAction,\n isActionCancelled,\n type PendingConfirmation,\n} from './lib/actions.service';\n\n// Validation\nexport {\n JsonRenderValidationService,\n injectValidation,\n injectFieldValidation,\n type FieldValidationState,\n} from './lib/validation.service';\n\n// Spec validation\nexport {\n checkSpec,\n formatSpecCheckIssues,\n type SpecCheck,\n type SpecCheckOptions,\n type SpecValidationMode,\n} from './lib/spec-validation';\n\n// Render limits\nexport {\n type RenderLimits,\n type SpecCatalog,\n type SpecCheckIssue,\n type SpecCheckIssueCode,\n} from './lib/render-limits';\n\n// Registry\nexport {\n defineRegistry,\n createStoreSetState,\n type DefineRegistryResult,\n} from './lib/registry';\n\n// Types\nexport type {\n Actions,\n ActionFn,\n CatalogHasActions,\n ComponentRegistry,\n Components,\n EventHandle,\n RegistryEntry,\n RenderContext,\n RepeatScope,\n SetState,\n StateChange,\n StateModel,\n} from './lib/types';\n\n// Streaming / AI helpers\nexport {\n applyPatch,\n buildSpecFromParts,\n flatToTree,\n getTextFromParts,\n injectChatUI,\n injectUIStream,\n jsonRenderMessage,\n type ChatMessage,\n type ChatUIOptions,\n type ChatUIReturn,\n type DataPart,\n type TokenUsage,\n type UIStreamOptions,\n type UIStreamReturn,\n type UIStreamSendOptions,\n} from './lib/streaming';\n\n// Schema (spec format + prompt rules)\nexport {\n schema,\n type AngularSchema,\n type AngularSpec,\n} from 'ngx-json-render/schema';\n\n// Devtools\nexport { injectDevtoolsActive } from './lib/devtools';\n// Private API for ngx-json-render/devtools; may change in any release.\nexport {\n ɵregisterStreamObserver,\n type StreamObserver,\n type StreamObserverUsage,\n} from './lib/streaming';\n\n// Core re-exports (for convenience)\nexport type {\n ActionBinding,\n ActionHandler,\n InferActionParams,\n InferCatalogComponents,\n InferComponentProps,\n JsonPatch,\n Spec,\n SpecIssue,\n StateStore,\n UIElement,\n VisibilityCondition,\n} from '@json-render/core';\nexport {\n autoFixSpec,\n createStateStore,\n formatSpecIssues,\n nestedToFlat,\n validateSpec,\n} from '@json-render/core';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,4EAAC;AAE/B;;;;;;AAMG;MAEU,qBAAqB,CAAA;IAChC,IAAI,GAAoC,KAAK;IAC7C,QAAQ,GAA0C,KAAK;AACvD,IAAA,OAAO,GAAoB,MAAM,CAAC,KAAK,8EAAC;IACxC,QAAQ,GAA6D,KAAK;AAC1E;;;AAGG;IACH,MAAM,GAA4C,KAAK;AACvD;;;AAGG;IACH,OAAO,GAA2C,KAAK;;IAGvD,KAAK,GAA0C,KAAK;;AAEpD,IAAA,YAAY,GAAuB,MAAM,CAAC,EAAE,mFAAC;IAE7C,QAAQ,GAAsD,KAAK;IACnE,QAAQ,GAIJ,KAAK;IACT,QAAQ,GAAwD,KAAK;IAErE,mBAAmB,GACjB,KAAK;IACP,SAAS,GAAyD,KAAK;IACvE,iBAAiB,GAA0C,KAAK;;AAGhE,IAAA,eAAe,GAAqC,MAAK,EAAE,CAAC;;AAG5D,IAAA,YAAY,CAAC,IAAY,EAAA;AACvB,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,SAAS;AACnE,QAAA,IAAI,CAAC,GAAG;AAAE,YAAA,OAAO,SAAS;AAC1B,QAAA,OAAO,OAAO,GAAG,KAAK,UAAU,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG;IAC7D;wGA1CW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;4GAArB,qBAAqB,EAAA,CAAA;;4FAArB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBADjC;;;ACpBD;AACA,MAAM,iBAAiB,GAAG,EAAE;AAE5B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