Single File Component (.aihu) runtime — registers custom elements compiled by @aihu/compiler.
_ensureA11yStylesfunction _ensureA11yStyles(): void_hmrReplacefunction _hmrReplace(element: HTMLElement, newSetup: Setup): void_registerAgentDispatcherfunction _registerAgentDispatcher( element: Element | null | undefined, dispatcher: InstanceAgentDispatcher, ): voidRegister a mounted instance's agent dispatcher.
_registerAgentServerBindingfunction _registerAgentServerBinding( element: Element | null | undefined, binding: InstanceAgentServerBinding, ): voidRegister a mounted instance's FULL server agent binding.
_setHydratefunction _setHydrate(fn: HydrateFn): void_setMountfunction _setMount(fn: MountFn): void_setSignalfunction _setSignal(s: typeof SignalFactory): void_takeAgentDispatcherfunction _takeAgentDispatcher( element: Element | null | undefined, ): InstanceAgentDispatcher | undefinedLook up the instance dispatcher registered for `element` (the mounted host custom element).
_takeAgentServerBindingfunction _takeAgentServerBinding( element: Element | null | undefined, ): InstanceAgentServerBinding | undefinedTake (read) the server binding registered for `element`.
announcefunction announce(message: string): voidProgrammatic ARIA announcement.
createFocusTrapfunction createFocusTrap( active: boolean | (() => boolean), returnFocus: boolean, initialFocus: string | null, childFn: () => Branch, ): BranchFocus-trap boundary.
createResourcefunction createResource<T>(factory: () => Promise<T>): ResourceHandle<T>Create a reactive resource backed by an async `factory`.
createStreamfunction createStream(factory: () => Promise<ReadableStream<string> | null>): StreamHandleCreate a reactive stream handle backed by a `ReadableStream<string>` factory.
defineComponentfunction defineComponent(setupOrOptions: Setup | ComponentOptions): typeof HTMLElementdefineElementfunction defineElement( name: string, Ctor: typeof HTMLElement, options?: DefineOptions, ): voidonAdoptfunction _onAdopt(fn: () => void): voidonAttributeChangefunction _onAttributeChange( fn: (name: string, oldValue: string | null, newValue: string | null) => void, ): voidonCleanupfunction _onCleanup(fn: () => void): voidonMountfunction _onMount(fn: () => void | (() => void)): void__aihu_cpathconst __aihu_cpath = (p: string): string => …Comment-safe path for structural markers — the walker's `_commentPath` (`-` → `_` so arbitrary list keys can't terminate the comment early).
__aihu_eattrconst __aihu_eattr = (v: unknown): string => …Attribute-value escape (`&` and `"`), the walker's `escapeAttr`.
__aihu_keyconst __aihu_key = (v: unknown): string => …List-item key normalization — the walker's `String(key).replace(/\./g, '_')` (dots would splice into the path grammar; see `_structuralSubtrees` in
__aihu_sattrconst __aihu_sattr = (k: string, v: unknown): string => …One serialized attribute (` k="v"` / ` k` / nothing), mirroring the walker's `serializeAttrs` value rules for a RESOLVED value: functions (event handlers) never serialize, `true` renders the bare attribute, `false`/`undefined` render nothing, everything else stringifies escaped.
__aihu_stextconst __aihu_stext = (v: unknown): string => …Escaped text hole for a REACTIVE leaf — the walker reads `String(get())`, so `null`/`undefined` stringify ("null"/"undefined"), exactly like a client-side reactive text binding would render them.
__aihu_stext0const __aihu_stext0 = (v: unknown): string => …Escaped text hole for an EAGER leaf — the walker's `leafText` renders nullish static values as the empty string.
_hydrateOnVisibleconst _hydrateOnVisible = (element: HTMLElement, hydrate: () => void): void => …ComponentOptionsinterface ComponentOptions<A extends ReadonlyArray<string> = ReadonlyArray<string>> {
attrs?: A
/**
* R1 ($prop reactivity, template-syntax-v2 round 5): rich per-prop
* metadata bag describing the Lit-style `attribute` / `reflect` /
* `converter` lowering. When non-empty, the runtime synthesizes
* `observedAttributes` from prop entries with `attribute !== false`,
* wires `attributeChangedCallback`, allocates one `Signal` per prop
* initialized to `value`, defines a JS property accessor on the class
* prototype, and (when `reflect: true`) reflects signal writes back to
* the attribute with a re-entrancy guard.
*
* Value flows through to the setup function via `ctx.props.<name>`,
* a per-name `Signal<unknown>`. Setup callers are expected to read via
* the signal-getter call (e.g. `props.title()`); writes via
* `props.title.set(...)` or via the JS property accessor on the host
* element (`el.title = newValue`) flow back through the same signal.
*/
props?: PropsConfig
/**
* Recipe class-extension (master spec §9.4): the generated element class
* extends this base custom-element class instead of `HTMLElement`, so the
* base's `connectedCallback` (role/ARIA/keyboard, form-control inheritance,
* cross-piece context provision) runs on the host. Emitted by the compiler's
* `$extends:` macro. Options-form only — base-extending recipes always carry
* `$prop` declarations, so they compile to the options-form. The base's
* `connectedCallback` runs BEFORE the template mounts (so a context-providing
* primitive registers before its slotted child pieces upgrade), and its
* `disconnectedCallback` runs on teardown; `observedAttributes` are unioned
* and `attributeChangedCallback` is forwarded to the base.
*/
base?: typeof HTMLElement
setup: (ctx: SetupContext & AttrContext<A> & PropsContext) => Branch | Leaf
}Options passed to the overloaded `defineComponent` when typed `observedAttributes` + per-attribute signals are desired.
DefineOptionsinterface DefineOptions {
shadowMode?: ShadowMode
/** When true, connectedCallback checks window.__aihu_state__[name] and calls the injected hydrate fn. Plan 3.2. */
hydrate?: boolean
}InstanceAgentDispatcherinterface InstanceAgentDispatcher {
readonly tag: string
/** opaqueId → action invoker (called with the positional args array). */
readonly actions: Record<string, (args: unknown[]) => unknown>
/** opaqueId → read accessor (current signal value). */
readonly reads: Record<string, () => unknown>
/** opaqueId → write accessor. */
readonly writes: Record<string, (value: unknown) => void>
}The instance-bound dispatcher shape.
InstanceAgentServerBindinginterface InstanceAgentServerBinding {
readonly tag: string
/** memberName → action invoker (called with the positional args array). */
readonly actions: Record<string, (args: unknown) => unknown>
/** memberName → read accessor (current signal/computed value). */
readonly reads: Record<string, () => unknown>
/** memberName → write accessor (prop signal setter). */
readonly writes: Record<string, (value: unknown) => void>
/** `$scope` from the `@agent` block, or undefined when unscoped. */
readonly scope: string | undefined
/** `$rate-limit` as `'<n>/min'`, or undefined when unlimited. */
readonly rateLimit: string | undefined
}The full, per-instance agent binding the SERVER build injects into the setup body.
PropDefinterface PropDef {
value?: unknown
attribute?: boolean | string
reflect?: boolean
converter?: (raw: string | null) => unknown
}R1 — single `$prop` definition.
PropSignalinterface PropSignal {
(): unknown
set(v: unknown): void
}R1 — per-prop signal handle exposed to setup.
ResourceHandleinterface ResourceHandle<T> {
/** True while a fetch is in flight (initial load or a refetch). */
readonly loading: boolean
/** The latest resolved value, or `null` before the first success. */
readonly data: T | null
/** The error from the most recent failed run, or `null`. */
readonly error: Error | null
/** Re-run the factory. Resolves when the run settles. */
refetch(): Promise<void>
}SetupContextinterface SetupContext {
readonly host: ShadowRoot | Element
readonly element: HTMLElement
}Context passed to a `defineComponent` setup function.
StreamHandleinterface StreamHandle {
readonly value: string
readonly delta: string
readonly status: StreamStatus
readonly error: Error | null
start(
source?: ReadableStream<string> | (() => Promise<ReadableStream<string> | null>),
): Promise<void>
stop(): void
}PropsConfigtype PropsConfig = Record<string, PropDef>Setuptype Setup = (ctx: SetupContext) => Branch | LeafA `defineComponent` setup function: receives a `SetupContext`, returns the arbor tree to mount.
ShadowModetype ShadowMode = 'light' | 'shadow'Rendering mode for the custom element — a BINARY choice (DA4 #437).
StreamStatustype StreamStatus = 'idle' | 'streaming' | 'done' | 'error'