/** * Item element handler — translates `parent_tile`-placed mount/patch/ * unmount mutations into pub/sub events that container widgets subscribe * to. * * Container widgets (chips strip, FAQ accordion, nav tips) declare * themselves participants by implementing the `CompositionalContainer` * contract and subscribing to `runtime.events` with * `element.compositional_append` / `element.compositional_patch` / * `element.compositional_remove`. Each container filters by * `props.tile_id === this.tileId`. * * Why pub/sub rather than DOM lookup? The runtime's event bus is * domain-agnostic and already exists. Container widgets that aren't * mounted yet (slow inline-slot wrapper hydration) miss the event, * but the next subscribe-then-replay pass at container mount time picks * up the durable session state from the LLM's `mounted_elements`. No * DOM crawling, no MutationObserver wiring, no ordering assumption. * * The handler is dumb: it forwards the wire `content` as the `item` * payload. The backend wrote that content as a fully-formed * compositional-item envelope (`{kind, config: {id, title, payload}}`) * so the receiving container can append it verbatim. */ import type { ElementHandlerContext, ElementTypeHandler, ValidateResult } from './ElementTypeHandler'; import type { MountedElement } from './types'; /** Event names. Kept as module constants so subscribers can import them * instead of memorizing strings. */ export declare const COMPOSITIONAL_APPEND_EVENT = "element.compositional_append"; export declare const COMPOSITIONAL_PATCH_EVENT = "element.compositional_patch"; export declare const COMPOSITIONAL_REMOVE_EVENT = "element.compositional_remove"; export interface CompositionalAppendEvent { /** Parent tile id from the mount's placement. Receivers filter on this. */ tile_id: string; /** Unique id of the mounted item — the receiving container should also * set this on the item's DOM as `data-syntro-element-id`. */ instance_id: string; /** Wire shape constructed by the backend — `{kind, config: {…}}`. */ item: Record; /** Insertion position — receivers honor this when appending. */ position: 'append' | 'prepend'; } export interface CompositionalPatchEvent { tile_id: string; instance_id: string; item: Record; } export interface CompositionalRemoveEvent { tile_id: string; instance_id: string; } export declare class ItemHandler implements ElementTypeHandler { readonly typeName: "item"; readonly lifecycle: "stateful"; validate(instance: MountedElement, _ctx: ElementHandlerContext): ValidateResult; mount(instance: MountedElement, ctx: ElementHandlerContext): Promise; patch(instance: MountedElement, ctx: ElementHandlerContext): Promise; unmount(instance: MountedElement, ctx: ElementHandlerContext): Promise; } //# sourceMappingURL=ItemHandler.d.ts.map