@fictjs/runtime 0.5.2 → 0.7.0

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.
Files changed (63) hide show
  1. package/dist/advanced.cjs +13 -9
  2. package/dist/advanced.cjs.map +1 -1
  3. package/dist/advanced.d.cts +4 -4
  4. package/dist/advanced.d.ts +4 -4
  5. package/dist/advanced.js +8 -4
  6. package/dist/advanced.js.map +1 -1
  7. package/dist/{chunk-D2IWOO4X.js → chunk-4LCHQ7U4.js} +250 -99
  8. package/dist/chunk-4LCHQ7U4.js.map +1 -0
  9. package/dist/{chunk-LRFMCJY3.js → chunk-7YQK3XKY.js} +120 -27
  10. package/dist/chunk-7YQK3XKY.js.map +1 -0
  11. package/dist/{chunk-QB2UD62G.cjs → chunk-CEV6TO5U.cjs} +8 -8
  12. package/dist/{chunk-QB2UD62G.cjs.map → chunk-CEV6TO5U.cjs.map} +1 -1
  13. package/dist/{chunk-ZR435MDC.cjs → chunk-FSCBL7RI.cjs} +120 -27
  14. package/dist/chunk-FSCBL7RI.cjs.map +1 -0
  15. package/dist/{chunk-KNGHYGK4.cjs → chunk-HHDHQGJY.cjs} +17 -17
  16. package/dist/{chunk-KNGHYGK4.cjs.map → chunk-HHDHQGJY.cjs.map} +1 -1
  17. package/dist/{chunk-Z6M3HKLG.cjs → chunk-PRF4QG73.cjs} +400 -249
  18. package/dist/chunk-PRF4QG73.cjs.map +1 -0
  19. package/dist/{chunk-4NUHM77Z.js → chunk-TLDT76RV.js} +3 -3
  20. package/dist/{chunk-SLFAEVKJ.js → chunk-WRU3IZOA.js} +3 -3
  21. package/dist/{context-CTBE00S_.d.cts → context-BFbHf9nC.d.cts} +1 -1
  22. package/dist/{context-lkLhbkFJ.d.ts → context-C4vBQbb4.d.ts} +1 -1
  23. package/dist/{effect-BpSNEJJz.d.cts → effect-DAzpH7Mm.d.cts} +33 -1
  24. package/dist/{effect-BpSNEJJz.d.ts → effect-DAzpH7Mm.d.ts} +33 -1
  25. package/dist/index.cjs +42 -42
  26. package/dist/index.d.cts +5 -5
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.dev.js +206 -46
  29. package/dist/index.dev.js.map +1 -1
  30. package/dist/index.js +3 -3
  31. package/dist/internal.cjs +55 -41
  32. package/dist/internal.cjs.map +1 -1
  33. package/dist/internal.d.cts +3 -3
  34. package/dist/internal.d.ts +3 -3
  35. package/dist/internal.js +17 -3
  36. package/dist/internal.js.map +1 -1
  37. package/dist/loader.cjs +9 -9
  38. package/dist/loader.js +1 -1
  39. package/dist/{props-XTHYD19o.d.cts → props-84UJeWO8.d.cts} +1 -1
  40. package/dist/{props-x-HbI-jX.d.ts → props-BRhFK50f.d.ts} +1 -1
  41. package/dist/{scope-CdbGmsFf.d.ts → scope-D3DpsfoG.d.ts} +1 -1
  42. package/dist/{scope-DfcP9I-A.d.cts → scope-DlCBL1Ft.d.cts} +1 -1
  43. package/package.json +1 -1
  44. package/src/advanced.ts +1 -1
  45. package/src/binding.ts +229 -101
  46. package/src/constants.ts +1 -1
  47. package/src/cycle-guard.ts +4 -3
  48. package/src/dom.ts +15 -4
  49. package/src/hooks.ts +1 -1
  50. package/src/internal.ts +7 -0
  51. package/src/lifecycle.ts +1 -1
  52. package/src/props.ts +60 -1
  53. package/src/signal.ts +60 -10
  54. package/src/store.ts +131 -18
  55. package/src/transition.ts +46 -9
  56. package/dist/chunk-D2IWOO4X.js.map +0 -1
  57. package/dist/chunk-LRFMCJY3.js.map +0 -1
  58. package/dist/chunk-Z6M3HKLG.cjs.map +0 -1
  59. package/dist/chunk-ZR435MDC.cjs.map +0 -1
  60. package/dist/jsx-dev-runtime.d.cts +0 -671
  61. package/dist/jsx-dev-runtime.d.ts +0 -671
  62. /package/dist/{chunk-4NUHM77Z.js.map → chunk-TLDT76RV.js.map} +0 -0
  63. /package/dist/{chunk-SLFAEVKJ.js.map → chunk-WRU3IZOA.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx.ts","../src/node-ops.ts","../src/transition.ts","../src/scheduler.ts","../src/hydration.ts","../src/binding.ts","../src/props.ts","../src/dom.ts"],"sourcesContent":["import type { FictNode } from './types'\n\nexport const Fragment = Symbol('Fragment')\n\nexport function jsx(\n type: string | typeof Fragment | ((props: Record<string, unknown>) => FictNode),\n props: Record<string, unknown>,\n key?: string,\n): FictNode {\n return { type, props, key }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = FictNode\n\n export interface IntrinsicElements {\n // Document structure\n html: HTMLAttributes<HTMLHtmlElement>\n head: HTMLAttributes<HTMLHeadElement>\n body: HTMLAttributes<HTMLBodyElement>\n title: HTMLAttributes<HTMLTitleElement>\n meta: MetaHTMLAttributes<HTMLMetaElement>\n link: LinkHTMLAttributes<HTMLLinkElement>\n style: StyleHTMLAttributes<HTMLStyleElement>\n script: ScriptHTMLAttributes<HTMLScriptElement>\n noscript: HTMLAttributes<HTMLElement>\n\n // Layout & Semantic\n div: HTMLAttributes<HTMLDivElement>\n span: HTMLAttributes<HTMLSpanElement>\n main: HTMLAttributes<HTMLElement>\n header: HTMLAttributes<HTMLElement>\n footer: HTMLAttributes<HTMLElement>\n section: HTMLAttributes<HTMLElement>\n article: HTMLAttributes<HTMLElement>\n aside: HTMLAttributes<HTMLElement>\n nav: HTMLAttributes<HTMLElement>\n address: HTMLAttributes<HTMLElement>\n\n // Headings\n h1: HTMLAttributes<HTMLHeadingElement>\n h2: HTMLAttributes<HTMLHeadingElement>\n h3: HTMLAttributes<HTMLHeadingElement>\n h4: HTMLAttributes<HTMLHeadingElement>\n h5: HTMLAttributes<HTMLHeadingElement>\n h6: HTMLAttributes<HTMLHeadingElement>\n hgroup: HTMLAttributes<HTMLElement>\n\n // Text content\n p: HTMLAttributes<HTMLParagraphElement>\n blockquote: BlockquoteHTMLAttributes<HTMLQuoteElement>\n pre: HTMLAttributes<HTMLPreElement>\n figure: HTMLAttributes<HTMLElement>\n figcaption: HTMLAttributes<HTMLElement>\n hr: HTMLAttributes<HTMLHRElement>\n br: HTMLAttributes<HTMLBRElement>\n wbr: HTMLAttributes<HTMLElement>\n\n // Inline text semantics\n a: AnchorHTMLAttributes<HTMLAnchorElement>\n abbr: HTMLAttributes<HTMLElement>\n b: HTMLAttributes<HTMLElement>\n bdi: HTMLAttributes<HTMLElement>\n bdo: HTMLAttributes<HTMLElement>\n cite: HTMLAttributes<HTMLElement>\n code: HTMLAttributes<HTMLElement>\n data: DataHTMLAttributes<HTMLDataElement>\n dfn: HTMLAttributes<HTMLElement>\n em: HTMLAttributes<HTMLElement>\n i: HTMLAttributes<HTMLElement>\n kbd: HTMLAttributes<HTMLElement>\n mark: HTMLAttributes<HTMLElement>\n q: QuoteHTMLAttributes<HTMLQuoteElement>\n rp: HTMLAttributes<HTMLElement>\n rt: HTMLAttributes<HTMLElement>\n ruby: HTMLAttributes<HTMLElement>\n s: HTMLAttributes<HTMLElement>\n samp: HTMLAttributes<HTMLElement>\n small: HTMLAttributes<HTMLElement>\n strong: HTMLAttributes<HTMLElement>\n sub: HTMLAttributes<HTMLElement>\n sup: HTMLAttributes<HTMLElement>\n time: TimeHTMLAttributes<HTMLTimeElement>\n u: HTMLAttributes<HTMLElement>\n var: HTMLAttributes<HTMLElement>\n\n // Lists\n ul: HTMLAttributes<HTMLUListElement>\n ol: OlHTMLAttributes<HTMLOListElement>\n li: LiHTMLAttributes<HTMLLIElement>\n dl: HTMLAttributes<HTMLDListElement>\n dt: HTMLAttributes<HTMLElement>\n dd: HTMLAttributes<HTMLElement>\n menu: HTMLAttributes<HTMLMenuElement>\n\n // Tables\n table: TableHTMLAttributes<HTMLTableElement>\n caption: HTMLAttributes<HTMLTableCaptionElement>\n colgroup: ColgroupHTMLAttributes<HTMLTableColElement>\n col: ColHTMLAttributes<HTMLTableColElement>\n thead: HTMLAttributes<HTMLTableSectionElement>\n tbody: HTMLAttributes<HTMLTableSectionElement>\n tfoot: HTMLAttributes<HTMLTableSectionElement>\n tr: HTMLAttributes<HTMLTableRowElement>\n th: ThHTMLAttributes<HTMLTableCellElement>\n td: TdHTMLAttributes<HTMLTableCellElement>\n\n // Forms\n form: FormHTMLAttributes<HTMLFormElement>\n fieldset: FieldsetHTMLAttributes<HTMLFieldSetElement>\n legend: HTMLAttributes<HTMLLegendElement>\n label: LabelHTMLAttributes<HTMLLabelElement>\n input: InputHTMLAttributes<HTMLInputElement>\n button: ButtonHTMLAttributes<HTMLButtonElement>\n select: SelectHTMLAttributes<HTMLSelectElement>\n datalist: HTMLAttributes<HTMLDataListElement>\n optgroup: OptgroupHTMLAttributes<HTMLOptGroupElement>\n option: OptionHTMLAttributes<HTMLOptionElement>\n textarea: TextareaHTMLAttributes<HTMLTextAreaElement>\n output: OutputHTMLAttributes<HTMLOutputElement>\n progress: ProgressHTMLAttributes<HTMLProgressElement>\n meter: MeterHTMLAttributes<HTMLMeterElement>\n\n // Interactive\n details: DetailsHTMLAttributes<HTMLDetailsElement>\n summary: HTMLAttributes<HTMLElement>\n dialog: DialogHTMLAttributes<HTMLDialogElement>\n\n // Media\n img: ImgHTMLAttributes<HTMLImageElement>\n picture: HTMLAttributes<HTMLPictureElement>\n source: SourceHTMLAttributes<HTMLSourceElement>\n audio: AudioVideoHTMLAttributes<HTMLAudioElement>\n video: AudioVideoHTMLAttributes<HTMLVideoElement>\n track: TrackHTMLAttributes<HTMLTrackElement>\n map: MapHTMLAttributes<HTMLMapElement>\n area: AreaHTMLAttributes<HTMLAreaElement>\n\n // Embedded content\n iframe: IframeHTMLAttributes<HTMLIFrameElement>\n embed: EmbedHTMLAttributes<HTMLEmbedElement>\n object: ObjectHTMLAttributes<HTMLObjectElement>\n param: ParamHTMLAttributes<HTMLParamElement>\n canvas: CanvasHTMLAttributes<HTMLCanvasElement>\n\n // SVG (basic support)\n svg: SVGAttributes<SVGSVGElement>\n path: SVGAttributes<SVGPathElement>\n circle: SVGAttributes<SVGCircleElement>\n rect: SVGAttributes<SVGRectElement>\n line: SVGAttributes<SVGLineElement>\n polyline: SVGAttributes<SVGPolylineElement>\n polygon: SVGAttributes<SVGPolygonElement>\n ellipse: SVGAttributes<SVGEllipseElement>\n g: SVGAttributes<SVGGElement>\n defs: SVGAttributes<SVGDefsElement>\n use: SVGAttributes<SVGUseElement>\n text: SVGAttributes<SVGTextElement>\n tspan: SVGAttributes<SVGTSpanElement>\n\n // Web components / other\n template: HTMLAttributes<HTMLTemplateElement>\n slot: SlotHTMLAttributes<HTMLSlotElement>\n portal: HTMLAttributes<HTMLElement>\n }\n\n export interface ElementChildrenAttribute {\n children: unknown\n }\n}\n\n// ============================================================================\n// Base HTML Attributes\n// ============================================================================\n\ninterface HTMLAttributes<T> {\n // Children\n children?: FictNode | FictNode[]\n\n // JSX special attributes\n key?: string | number\n\n // Core attributes\n id?: string\n class?: string\n style?: string | Record<string, string | number>\n title?: string\n lang?: string\n dir?: 'ltr' | 'rtl' | 'auto'\n hidden?: boolean | 'hidden' | 'until-found'\n tabIndex?: number\n draggable?: boolean | 'true' | 'false'\n contentEditable?: boolean | 'true' | 'false' | 'inherit'\n spellCheck?: boolean | 'true' | 'false'\n translate?: 'yes' | 'no'\n inert?: boolean\n popover?: 'auto' | 'manual'\n\n // Experimental / newer\n autofocus?: boolean\n slot?: string\n accessKey?: string\n\n // Event handlers\n onClick?: (e: MouseEvent) => void\n onDblClick?: (e: MouseEvent) => void\n onMouseDown?: (e: MouseEvent) => void\n onMouseUp?: (e: MouseEvent) => void\n onMouseMove?: (e: MouseEvent) => void\n onMouseEnter?: (e: MouseEvent) => void\n onMouseLeave?: (e: MouseEvent) => void\n onMouseOver?: (e: MouseEvent) => void\n onMouseOut?: (e: MouseEvent) => void\n onContextMenu?: (e: MouseEvent) => void\n onInput?: (e: InputEvent) => void\n onChange?: (e: Event) => void\n onSubmit?: (e: SubmitEvent) => void\n onReset?: (e: Event) => void\n onKeyDown?: (e: KeyboardEvent) => void\n onKeyUp?: (e: KeyboardEvent) => void\n onKeyPress?: (e: KeyboardEvent) => void\n onFocus?: (e: FocusEvent) => void\n onBlur?: (e: FocusEvent) => void\n onScroll?: (e: Event) => void\n onWheel?: (e: WheelEvent) => void\n onLoad?: (e: Event) => void\n onError?: (e: Event) => void\n\n // Drag events\n onDrag?: (e: DragEvent) => void\n onDragStart?: (e: DragEvent) => void\n onDragEnd?: (e: DragEvent) => void\n onDragEnter?: (e: DragEvent) => void\n onDragLeave?: (e: DragEvent) => void\n onDragOver?: (e: DragEvent) => void\n onDrop?: (e: DragEvent) => void\n\n // Touch events\n onTouchStart?: (e: TouchEvent) => void\n onTouchMove?: (e: TouchEvent) => void\n onTouchEnd?: (e: TouchEvent) => void\n onTouchCancel?: (e: TouchEvent) => void\n\n // Animation events\n onAnimationStart?: (e: AnimationEvent) => void\n onAnimationEnd?: (e: AnimationEvent) => void\n onAnimationIteration?: (e: AnimationEvent) => void\n onTransitionEnd?: (e: TransitionEvent) => void\n\n // Pointer events\n onPointerDown?: (e: PointerEvent) => void\n onPointerUp?: (e: PointerEvent) => void\n onPointerMove?: (e: PointerEvent) => void\n onPointerEnter?: (e: PointerEvent) => void\n onPointerLeave?: (e: PointerEvent) => void\n onPointerOver?: (e: PointerEvent) => void\n onPointerOut?: (e: PointerEvent) => void\n onPointerCancel?: (e: PointerEvent) => void\n\n // Ref\n ref?: ((el: T | null) => void) | { current: T | null }\n\n // ARIA attributes (common ones)\n role?: string\n 'aria-hidden'?: boolean | 'true' | 'false'\n 'aria-label'?: string\n 'aria-labelledby'?: string\n 'aria-describedby'?: string\n 'aria-live'?: 'off' | 'polite' | 'assertive'\n 'aria-atomic'?: boolean | 'true' | 'false'\n 'aria-busy'?: boolean | 'true' | 'false'\n 'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time'\n 'aria-disabled'?: boolean | 'true' | 'false'\n 'aria-expanded'?: boolean | 'true' | 'false'\n 'aria-haspopup'?: boolean | 'true' | 'false' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'\n 'aria-pressed'?: boolean | 'true' | 'false' | 'mixed'\n 'aria-selected'?: boolean | 'true' | 'false'\n 'aria-checked'?: boolean | 'true' | 'false' | 'mixed'\n 'aria-controls'?: string\n 'aria-owns'?: string\n 'aria-activedescendant'?: string\n 'aria-valuemin'?: number\n 'aria-valuemax'?: number\n 'aria-valuenow'?: number\n 'aria-valuetext'?: string\n 'aria-orientation'?: 'horizontal' | 'vertical'\n 'aria-readonly'?: boolean | 'true' | 'false'\n 'aria-required'?: boolean | 'true' | 'false'\n 'aria-invalid'?: boolean | 'true' | 'false' | 'grammar' | 'spelling'\n 'aria-errormessage'?: string\n 'aria-modal'?: boolean | 'true' | 'false'\n 'aria-placeholder'?: string\n 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other'\n 'aria-colcount'?: number\n 'aria-colindex'?: number\n 'aria-colspan'?: number\n 'aria-rowcount'?: number\n 'aria-rowindex'?: number\n 'aria-rowspan'?: number\n 'aria-setsize'?: number\n 'aria-posinset'?: number\n 'aria-level'?: number\n 'aria-multiselectable'?: boolean | 'true' | 'false'\n 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both'\n 'aria-details'?: string\n 'aria-keyshortcuts'?: string\n 'aria-roledescription'?: string\n\n // Data attributes via index signature\n [key: `data-${string}`]: string | number | boolean | undefined\n}\n\n// ============================================================================\n// Specialized Attribute Interfaces\n// ============================================================================\n\ninterface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {\n href?: string\n target?: '_self' | '_blank' | '_parent' | '_top' | string\n rel?: string\n download?: boolean | string\n hreflang?: string\n type?: string\n referrerPolicy?: ReferrerPolicy\n ping?: string\n}\n\ninterface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {\n type?: 'button' | 'submit' | 'reset'\n disabled?: boolean\n name?: string\n value?: string\n form?: string\n formAction?: string\n formEncType?: string\n formMethod?: string\n formNoValidate?: boolean\n formTarget?: string\n popovertarget?: string\n popovertargetaction?: 'show' | 'hide' | 'toggle'\n}\n\ninterface InputHTMLAttributes<T> extends HTMLAttributes<T> {\n type?: string\n value?: string | number | readonly string[]\n defaultValue?: string | number | readonly string[]\n checked?: boolean\n defaultChecked?: boolean\n disabled?: boolean\n placeholder?: string\n name?: string\n form?: string\n required?: boolean\n readonly?: boolean\n multiple?: boolean\n min?: number | string\n max?: number | string\n minLength?: number\n maxLength?: number\n step?: number | string\n pattern?: string\n size?: number\n accept?: string\n capture?: boolean | 'user' | 'environment'\n list?: string\n autoComplete?: string\n autoCapitalize?: string\n inputMode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'\n height?: number | string\n width?: number | string\n alt?: string\n src?: string\n formAction?: string\n formEncType?: string\n formMethod?: string\n formNoValidate?: boolean\n formTarget?: string\n}\n\ninterface FormHTMLAttributes<T> extends HTMLAttributes<T> {\n action?: string\n method?: 'get' | 'post' | 'dialog'\n encType?: string\n target?: string\n name?: string\n noValidate?: boolean\n autoComplete?: 'on' | 'off'\n acceptCharset?: string\n}\n\ninterface ImgHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n alt?: string\n width?: number | string\n height?: number | string\n srcSet?: string\n sizes?: string\n loading?: 'eager' | 'lazy'\n decoding?: 'async' | 'auto' | 'sync'\n crossOrigin?: 'anonymous' | 'use-credentials'\n referrerPolicy?: ReferrerPolicy\n useMap?: string\n isMap?: boolean\n fetchPriority?: 'auto' | 'high' | 'low'\n}\n\ninterface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: string | number\n defaultValue?: string\n disabled?: boolean\n placeholder?: string\n name?: string\n form?: string\n required?: boolean\n readonly?: boolean\n rows?: number\n cols?: number\n minLength?: number\n maxLength?: number\n wrap?: 'hard' | 'soft' | 'off'\n autoComplete?: string\n}\n\ninterface SelectHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: string | number | readonly string[]\n defaultValue?: string | number | readonly string[]\n disabled?: boolean\n name?: string\n form?: string\n required?: boolean\n multiple?: boolean\n size?: number\n autoComplete?: string\n}\n\ninterface OptionHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: string | number\n disabled?: boolean\n selected?: boolean\n label?: string\n}\n\ninterface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {\n disabled?: boolean\n label?: string\n}\n\ninterface LabelHTMLAttributes<T> extends HTMLAttributes<T> {\n for?: string\n htmlFor?: string\n form?: string\n}\n\ninterface FieldsetHTMLAttributes<T> extends HTMLAttributes<T> {\n disabled?: boolean\n name?: string\n form?: string\n}\n\ninterface OutputHTMLAttributes<T> extends HTMLAttributes<T> {\n for?: string\n htmlFor?: string\n form?: string\n name?: string\n}\n\ninterface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: number | string\n max?: number | string\n}\n\ninterface MeterHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: number | string\n min?: number | string\n max?: number | string\n low?: number | string\n high?: number | string\n optimum?: number | string\n}\n\n// Table elements\ninterface TableHTMLAttributes<T> extends HTMLAttributes<T> {\n cellPadding?: number | string\n cellSpacing?: number | string\n border?: number | string\n}\n\ninterface ThHTMLAttributes<T> extends HTMLAttributes<T> {\n colSpan?: number\n rowSpan?: number\n scope?: 'row' | 'col' | 'rowgroup' | 'colgroup'\n abbr?: string\n headers?: string\n}\n\ninterface TdHTMLAttributes<T> extends HTMLAttributes<T> {\n colSpan?: number\n rowSpan?: number\n headers?: string\n}\n\ninterface ColHTMLAttributes<T> extends HTMLAttributes<T> {\n span?: number\n}\n\ninterface ColgroupHTMLAttributes<T> extends HTMLAttributes<T> {\n span?: number\n}\n\n// List elements\ninterface OlHTMLAttributes<T> extends HTMLAttributes<T> {\n start?: number\n reversed?: boolean\n type?: '1' | 'a' | 'A' | 'i' | 'I'\n}\n\ninterface LiHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: number\n}\n\n// Media elements\ninterface AudioVideoHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n controls?: boolean\n autoPlay?: boolean\n loop?: boolean\n muted?: boolean\n preload?: 'none' | 'metadata' | 'auto'\n crossOrigin?: 'anonymous' | 'use-credentials'\n poster?: string // video only\n width?: number | string // video only\n height?: number | string // video only\n playsInline?: boolean\n disableRemotePlayback?: boolean\n onPlay?: (e: Event) => void\n onPause?: (e: Event) => void\n onEnded?: (e: Event) => void\n onTimeUpdate?: (e: Event) => void\n onVolumeChange?: (e: Event) => void\n onSeeking?: (e: Event) => void\n onSeeked?: (e: Event) => void\n onLoadedData?: (e: Event) => void\n onLoadedMetadata?: (e: Event) => void\n onCanPlay?: (e: Event) => void\n onCanPlayThrough?: (e: Event) => void\n onWaiting?: (e: Event) => void\n onPlaying?: (e: Event) => void\n onProgress?: (e: Event) => void\n onDurationChange?: (e: Event) => void\n onRateChange?: (e: Event) => void\n onStalled?: (e: Event) => void\n onSuspend?: (e: Event) => void\n onEmptied?: (e: Event) => void\n}\n\ninterface SourceHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n srcSet?: string\n sizes?: string\n type?: string\n media?: string\n width?: number | string\n height?: number | string\n}\n\ninterface TrackHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n srcLang?: string\n label?: string\n kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata'\n default?: boolean\n}\n\n// Embedded content\ninterface IframeHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n srcDoc?: string\n name?: string\n width?: number | string\n height?: number | string\n allow?: string\n allowFullScreen?: boolean\n sandbox?: string\n loading?: 'eager' | 'lazy'\n referrerPolicy?: ReferrerPolicy\n}\n\ninterface EmbedHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n type?: string\n width?: number | string\n height?: number | string\n}\n\ninterface ObjectHTMLAttributes<T> extends HTMLAttributes<T> {\n data?: string\n type?: string\n name?: string\n width?: number | string\n height?: number | string\n form?: string\n useMap?: string\n}\n\ninterface ParamHTMLAttributes<T> extends HTMLAttributes<T> {\n name?: string\n value?: string\n}\n\ninterface CanvasHTMLAttributes<T> extends HTMLAttributes<T> {\n width?: number | string\n height?: number | string\n}\n\ninterface MapHTMLAttributes<T> extends HTMLAttributes<T> {\n name?: string\n}\n\ninterface AreaHTMLAttributes<T> extends HTMLAttributes<T> {\n alt?: string\n coords?: string\n href?: string\n hreflang?: string\n download?: boolean | string\n rel?: string\n shape?: 'rect' | 'circle' | 'poly' | 'default'\n target?: string\n referrerPolicy?: ReferrerPolicy\n ping?: string\n}\n\n// Interactive elements\ninterface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {\n open?: boolean\n onToggle?: (e: Event) => void\n}\n\ninterface DialogHTMLAttributes<T> extends HTMLAttributes<T> {\n open?: boolean\n onClose?: (e: Event) => void\n onCancel?: (e: Event) => void\n}\n\n// Other elements\ninterface BlockquoteHTMLAttributes<T> extends HTMLAttributes<T> {\n cite?: string\n}\n\ninterface QuoteHTMLAttributes<T> extends HTMLAttributes<T> {\n cite?: string\n}\n\ninterface TimeHTMLAttributes<T> extends HTMLAttributes<T> {\n dateTime?: string\n}\n\ninterface DataHTMLAttributes<T> extends HTMLAttributes<T> {\n value?: string\n}\n\ninterface MetaHTMLAttributes<T> extends HTMLAttributes<T> {\n name?: string\n content?: string\n httpEquiv?: string\n charSet?: string\n property?: string\n}\n\ninterface LinkHTMLAttributes<T> extends HTMLAttributes<T> {\n href?: string\n rel?: string\n type?: string\n media?: string\n as?: string\n crossOrigin?: 'anonymous' | 'use-credentials'\n referrerPolicy?: ReferrerPolicy\n sizes?: string\n hreflang?: string\n integrity?: string\n fetchPriority?: 'auto' | 'high' | 'low'\n disabled?: boolean\n}\n\ninterface StyleHTMLAttributes<T> extends HTMLAttributes<T> {\n media?: string\n nonce?: string\n blocking?: string\n}\n\ninterface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {\n src?: string\n type?: string\n async?: boolean\n defer?: boolean\n crossOrigin?: 'anonymous' | 'use-credentials'\n integrity?: string\n noModule?: boolean\n nonce?: string\n referrerPolicy?: ReferrerPolicy\n fetchPriority?: 'auto' | 'high' | 'low'\n blocking?: string\n}\n\ninterface SlotHTMLAttributes<T> extends HTMLAttributes<T> {\n name?: string\n onSlotchange?: (e: Event) => void\n}\n\n// SVG Attributes (basic support)\ninterface SVGAttributes<T> extends HTMLAttributes<T> {\n // Core SVG attributes\n viewBox?: string\n xmlns?: string\n xmlnsXlink?: string\n fill?: string\n stroke?: string\n strokeWidth?: string | number\n strokeLinecap?: 'butt' | 'round' | 'square'\n strokeLinejoin?: 'miter' | 'round' | 'bevel'\n strokeDasharray?: string\n strokeDashoffset?: string | number\n strokeOpacity?: string | number\n fillOpacity?: string | number\n opacity?: string | number\n transform?: string\n transformOrigin?: string\n clipPath?: string\n mask?: string\n filter?: string\n\n // Shape attributes\n d?: string\n cx?: string | number\n cy?: string | number\n r?: string | number\n rx?: string | number\n ry?: string | number\n x?: string | number\n y?: string | number\n x1?: string | number\n y1?: string | number\n x2?: string | number\n y2?: string | number\n width?: string | number\n height?: string | number\n points?: string\n pathLength?: string | number\n\n // Text attributes\n textAnchor?: 'start' | 'middle' | 'end'\n dominantBaseline?: string\n dx?: string | number\n dy?: string | number\n fontSize?: string | number\n fontFamily?: string\n fontWeight?: string | number\n\n // Use element\n href?: string\n xlinkHref?: string\n\n // Gradient/pattern\n gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox'\n gradientTransform?: string\n spreadMethod?: 'pad' | 'reflect' | 'repeat'\n offset?: string | number\n stopColor?: string\n stopOpacity?: string | number\n\n // Clip/mask\n clipPathUnits?: 'userSpaceOnUse' | 'objectBoundingBox'\n maskUnits?: 'userSpaceOnUse' | 'objectBoundingBox'\n maskContentUnits?: 'userSpaceOnUse' | 'objectBoundingBox'\n\n // Other\n preserveAspectRatio?: string\n markerStart?: string\n markerMid?: string\n markerEnd?: string\n vectorEffect?: string\n}\n","/**\n * Low-level DOM node helpers shared across runtime modules.\n * Keep this file dependency-free to avoid module cycles.\n */\n\n/**\n * Convert a value to a flat array of DOM nodes.\n * Defensively handles proxies and non-DOM values.\n */\nexport function toNodeArray(node: Node | Node[] | unknown): Node[] {\n try {\n if (Array.isArray(node)) {\n // Preserve original array reference when it's already a flat Node array\n let allNodes = true\n for (const item of node) {\n let isItemNode = false\n try {\n isItemNode = item instanceof Node\n } catch {\n isItemNode = false\n }\n if (!isItemNode) {\n allNodes = false\n break\n }\n }\n if (allNodes) {\n return node as Node[]\n }\n const result: Node[] = []\n for (const item of node) {\n result.push(...toNodeArray(item))\n }\n return result\n }\n if (node === null || node === undefined || node === false) {\n return []\n }\n } catch {\n return []\n }\n\n let isNode = false\n try {\n isNode = node instanceof Node\n } catch {\n // If safe check fails, treat as primitive string\n isNode = false\n }\n\n if (isNode) {\n try {\n if (node instanceof DocumentFragment) {\n return Array.from(node.childNodes)\n }\n } catch {\n // Ignore fragment check error\n }\n return [node as Node]\n }\n\n try {\n // Duck-type BindingHandle-like values\n if (typeof node === 'object' && node !== null && 'marker' in node) {\n return toNodeArray((node as { marker: unknown }).marker)\n }\n } catch {\n // Ignore property check error\n }\n\n // Primitive fallback\n try {\n return [document.createTextNode(String(node))]\n } catch {\n return [document.createTextNode('')]\n }\n}\n\n/**\n * Insert nodes before an anchor node, preserving order.\n * Uses DocumentFragment for batch insertion when inserting multiple nodes.\n */\nexport function insertNodesBefore(\n parent: ParentNode & Node,\n nodes: Node[],\n anchor: Node | null,\n): void {\n if (nodes.length === 0) return\n\n // Single node optimization - direct insertion\n if (nodes.length === 1) {\n const node = nodes[0]!\n if (node === undefined || node === null) return\n if (node.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {\n parent.ownerDocument.adoptNode(node)\n }\n try {\n parent.insertBefore(node, anchor)\n } catch (e: unknown) {\n if (parent.ownerDocument) {\n try {\n const clone = parent.ownerDocument.importNode(node, true)\n parent.insertBefore(clone, anchor)\n return\n } catch {\n // Clone fallback failed\n }\n }\n throw e\n }\n return\n }\n\n // Batch insertion using DocumentFragment for multiple nodes\n const doc = parent.ownerDocument\n if (doc) {\n const frag = doc.createDocumentFragment()\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]!\n if (node === undefined || node === null) continue\n // Handle DocumentFragment - append children\n if (node.nodeType === 11) {\n const childrenArr = Array.from(node.childNodes)\n for (let j = 0; j < childrenArr.length; j++) {\n frag.appendChild(childrenArr[j]!)\n }\n } else {\n if (node.ownerDocument !== doc) {\n doc.adoptNode(node)\n }\n frag.appendChild(node)\n }\n }\n parent.insertBefore(frag, anchor)\n return\n }\n\n // Fallback for non-document contexts (rare)\n const insertSingle = (nodeToInsert: Node, anchorNode: Node | null): Node => {\n if (nodeToInsert.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {\n parent.ownerDocument.adoptNode(nodeToInsert)\n }\n try {\n parent.insertBefore(nodeToInsert, anchorNode)\n return nodeToInsert\n } catch (e: unknown) {\n if (parent.ownerDocument) {\n try {\n const clone = parent.ownerDocument.importNode(nodeToInsert, true)\n parent.insertBefore(clone, anchorNode)\n return clone\n } catch {\n // Clone fallback failed\n }\n }\n throw e\n }\n }\n\n for (let i = nodes.length - 1; i >= 0; i--) {\n const node = nodes[i]!\n if (node === undefined || node === null) continue\n\n // Handle DocumentFragment - insert children in reverse order\n const isFrag = node.nodeType === 11\n if (isFrag) {\n const childrenArr = Array.from(node.childNodes)\n for (let j = childrenArr.length - 1; j >= 0; j--) {\n const child = childrenArr[j]!\n anchor = insertSingle(child, anchor)\n }\n } else {\n anchor = insertSingle(node, anchor)\n }\n }\n}\n\n/**\n * Remove an array of nodes from the DOM.\n */\nexport function removeNodes(nodes: Node[]): void {\n for (const node of nodes) {\n node.parentNode?.removeChild(node)\n }\n}\n\nconst SLOT_START = 'fict:slot:start'\nconst SLOT_END = 'fict:slot:end'\n\nfunction isSlotStart(node: Node | null): node is Comment {\n return !!(node && node.nodeType === 8 && (node as Comment).data === SLOT_START)\n}\n\nfunction isSlotEnd(node: Node | null): node is Comment {\n return !!(node && node.nodeType === 8 && (node as Comment).data === SLOT_END)\n}\n\nexport function getSlotEnd(start: Comment): Comment {\n let depth = 1\n let cursor: Node | null = start.nextSibling\n while (cursor) {\n if (isSlotStart(cursor)) {\n depth++\n } else if (isSlotEnd(cursor)) {\n depth--\n if (depth === 0) {\n return cursor\n }\n }\n cursor = cursor.nextSibling\n }\n\n const owner = start.ownerDocument ?? document\n const end = owner.createComment(SLOT_END)\n if (start.parentNode) {\n start.parentNode.insertBefore(end, start.nextSibling)\n }\n return end\n}\n\nexport function resolvePath(root: Node, path: number[]): Node | null {\n let current: Node | null = root\n for (const index of path) {\n if (!current) return null\n let child: Node | null = current.firstChild\n let currentIndex = 0\n while (child) {\n if (isSlotStart(child)) {\n if (currentIndex === index) {\n current = child\n break\n }\n const end = getSlotEnd(child as Comment)\n child = end.nextSibling\n currentIndex++\n continue\n }\n if (currentIndex === index) {\n current = child\n break\n }\n currentIndex++\n child = child.nextSibling\n }\n if (!child) {\n return null\n }\n }\n return current\n}\n","import { createEffect } from './effect'\nimport { setTransitionContext, signal, scheduleFlush, untrack } from './signal'\n\n// ============================================================================\n// startTransition - Mark updates as low priority\n// ============================================================================\n\n/**\n * Execute a function with low-priority scheduling.\n * Updates triggered inside the callback will be processed after any high-priority updates.\n * This keeps the UI responsive during expensive operations.\n *\n * @param fn - The function to execute in transition context\n *\n * @example\n * ```tsx\n * const handleInput = (e) => {\n * query = e.target.value // High priority: immediate\n * startTransition(() => {\n * // Low priority: processed after high priority updates\n * filteredItems = allItems.filter(x => x.includes(query))\n * })\n * }\n * ```\n */\nexport function startTransition(fn: () => void): void {\n const prev = setTransitionContext(true)\n try {\n fn()\n } finally {\n setTransitionContext(prev)\n scheduleFlush()\n }\n}\n\n// ============================================================================\n// useTransition - Hook for managing transition state\n// ============================================================================\n\n/**\n * React-style useTransition hook.\n * Returns a pending signal and a startTransition function.\n *\n * @returns A tuple of [isPending accessor, startTransition function]\n *\n * @example\n * ```tsx\n * function SearchComponent() {\n * let query = $state('')\n * const [isPending, start] = useTransition()\n *\n * const handleChange = (e) => {\n * query = e.target.value\n * start(() => {\n * // Expensive filtering happens in low priority\n * filteredResults = expensiveFilter(allData, query)\n * })\n * }\n *\n * return (\n * <>\n * <input value={query} onInput={handleChange} />\n * {isPending() && <Spinner />}\n * <Results items={filteredResults} />\n * </>\n * )\n * }\n * ```\n */\nexport function useTransition(): [() => boolean, (fn: () => void | PromiseLike<unknown>) => void] {\n const pending = signal(false)\n let pendingCount = 0\n\n const beginPending = () => {\n pendingCount += 1\n if (pendingCount === 1) {\n pending(true)\n }\n }\n\n const endPending = () => {\n if (pendingCount === 0) return\n pendingCount -= 1\n if (pendingCount === 0) {\n pending(false)\n }\n }\n\n const start = (fn: () => void | PromiseLike<unknown>) => {\n beginPending()\n let result: void | PromiseLike<unknown> | undefined\n let thrown: unknown\n let didThrow = false\n\n startTransition(() => {\n try {\n result = fn()\n } catch (err) {\n thrown = err\n didThrow = true\n }\n })\n\n if (didThrow) {\n endPending()\n throw thrown\n }\n\n if (result && typeof (result as PromiseLike<unknown>).then === 'function') {\n Promise.resolve(result).finally(() => {\n endPending()\n })\n return\n }\n\n // Keep pending true for at least one microtask so UI can observe it.\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(endPending)\n } else {\n Promise.resolve().then(endPending)\n }\n }\n\n return [() => pending(), start]\n}\n\n// ============================================================================\n// useDeferredValue - Defer value updates to low priority\n// ============================================================================\n\n/**\n * Creates a deferred version of a value that updates with low priority.\n * The returned accessor will lag behind the source value during rapid updates,\n * allowing high-priority work to complete first.\n *\n * @param getValue - Accessor function that returns the source value\n * @returns Accessor function that returns the deferred value\n *\n * @example\n * ```tsx\n * function SearchResults({ query }) {\n * const deferredQuery = useDeferredValue(() => query)\n *\n * // deferredQuery lags behind query during rapid typing\n * const results = expensiveSearch(deferredQuery())\n *\n * return <ResultList items={results} />\n * }\n * ```\n */\nexport function useDeferredValue<T>(getValue: () => T): () => T {\n const deferredValue = signal(getValue())\n\n // Track source value changes and update deferred value in transition\n createEffect(() => {\n const newValue = getValue()\n // Use untrack to read current deferred value without creating a dependency\n // This prevents the effect from re-running when deferredValue changes\n const currentDeferred = untrack(() => deferredValue())\n if (currentDeferred !== newValue) {\n startTransition(() => {\n deferredValue(newValue)\n })\n }\n })\n\n return () => deferredValue()\n}\n","import { batch as baseBatch, untrack as baseUntrack } from './signal'\n\nexport function batch<T>(fn: () => T): T {\n return baseBatch(fn)\n}\n\nexport function untrack<T>(fn: () => T): T {\n return baseUntrack(fn)\n}\n\n// Transition APIs for priority scheduling\nexport { startTransition, useTransition, useDeferredValue } from './transition'\n","interface HydrationContext {\n cursor: Node | null\n boundary: Node | null\n owner: Document\n}\n\nconst hydrationStack: HydrationContext[] = []\n\nexport function withHydration(root: ParentNode & Node, fn: () => void): void {\n const owner = root.ownerDocument ?? document\n hydrationStack.push({\n cursor: root.firstChild,\n boundary: null,\n owner,\n })\n try {\n fn()\n } finally {\n hydrationStack.pop()\n }\n}\n\nexport function withHydrationRange(\n start: Node | null,\n end: Node | null,\n owner: Document,\n fn: () => void,\n): void {\n hydrationStack.push({\n cursor: start,\n boundary: end,\n owner,\n })\n try {\n fn()\n } finally {\n hydrationStack.pop()\n }\n}\n\nexport function claimNodes(templateRoot: Node, fallback: () => Node): Node {\n const ctx = hydrationStack[hydrationStack.length - 1]\n if (!ctx || !ctx.cursor) {\n return fallback()\n }\n\n const count = templateRoot.nodeType === 11 ? templateRoot.childNodes.length : 1\n if (count === 0) return fallback()\n\n const claimed: Node[] = []\n let cursor: Node | null = ctx.cursor\n for (let i = 0; i < count; i++) {\n if (!cursor || cursor === ctx.boundary) {\n return fallback()\n }\n claimed.push(cursor)\n cursor = cursor.nextSibling\n }\n\n ctx.cursor = cursor\n\n if (claimed.length === 1) {\n return claimed[0]!\n }\n\n const frag = ctx.owner.createDocumentFragment()\n for (const node of claimed) {\n frag.appendChild(node)\n }\n return frag\n}\n\nexport function isHydratingActive(): boolean {\n return hydrationStack.length > 0\n}\n","/**\n * Fict Reactive DOM Binding System\n *\n * This module provides the core mechanisms for reactive DOM updates.\n * It bridges the gap between Fict's reactive system (signals, effects)\n * and the DOM, enabling fine-grained updates without a virtual DOM.\n *\n * Design Philosophy:\n * - Values wrapped in functions `() => T` are treated as reactive\n * - Static values are applied once without tracking\n * - The compiler transforms JSX expressions to use these primitives\n */\n\nimport {\n $$EVENTS,\n DelegatedEvents,\n UnitlessStyles,\n Properties,\n ChildProperties,\n getPropAlias,\n SVGNamespace,\n} from './constants'\nimport { createRenderEffect } from './effect'\nimport { withHydrationRange, isHydratingActive } from './hydration'\nimport { Fragment } from './jsx'\nimport {\n createRootContext,\n destroyRoot,\n flushOnMount,\n getCurrentRoot,\n handleError,\n handleSuspend,\n pushRoot,\n popRoot,\n registerRootCleanup,\n type RootContext,\n} from './lifecycle'\nimport { toNodeArray, removeNodes, insertNodesBefore } from './node-ops'\nimport { __fictIsHydrating } from './resume'\nimport { batch } from './scheduler'\nimport { computed, untrack, isSignal, isComputed, isEffect, isEffectScope } from './signal'\nimport type { Cleanup, FictNode } from './types'\n\nconst isDev =\n typeof __DEV__ !== 'undefined'\n ? __DEV__\n : typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n\nconst TEXT_CACHE = Symbol('fict:text')\nconst ATTR_CACHE = Symbol('fict:attr')\nconst PROP_CACHE = Symbol('fict:prop')\nconst STYLE_CACHE = Symbol('fict:style')\nconst CLASS_STATE_CACHE = Symbol('fict:class-state')\nconst CLASS_VALUE_CACHE = Symbol('fict:class-value')\nconst NON_REACTIVE_FN_MARKER = Symbol.for('fict:non-reactive-fn')\nconst REACTIVE_FN_MARKER = Symbol.for('fict:reactive-fn')\nconst NON_REACTIVE_FN_REGISTRY_KEY = Symbol.for('fict:non-reactive-fn-registry')\n\ntype NonReactiveRegistryHost = typeof globalThis & {\n [NON_REACTIVE_FN_REGISTRY_KEY]?: WeakSet<(...args: unknown[]) => unknown>\n}\n\nconst PROPERTY_BINDING_KEYS = new Set([\n 'value',\n 'checked',\n 'selected',\n 'disabled',\n 'readOnly',\n 'multiple',\n 'muted',\n])\n\nconst STYLE_PROP_CACHE = new Map<string, string>()\nconst hasOwn = Object.prototype.hasOwnProperty\n\nfunction getNonReactiveFnRegistry(): WeakSet<(...args: unknown[]) => unknown> {\n const host = globalThis as NonReactiveRegistryHost\n let registry = host[NON_REACTIVE_FN_REGISTRY_KEY]\n if (!registry) {\n registry = new WeakSet<(...args: unknown[]) => unknown>()\n host[NON_REACTIVE_FN_REGISTRY_KEY] = registry\n }\n return registry\n}\n\nfunction isExplicitReactiveFn(value: unknown): boolean {\n if (typeof value !== 'function') return false\n return (\n (value as ((...args: unknown[]) => unknown) & { [REACTIVE_FN_MARKER]?: boolean })[\n REACTIVE_FN_MARKER\n ] === true\n )\n}\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\n/** A reactive value that can be either static or a getter function */\nexport type MaybeReactive<T> = T | (() => T)\n\n/** Internal type for createElement function reference */\nexport type CreateElementFn = (node: FictNode) => Node\n\n/** Handle returned by conditional/list bindings for cleanup */\nexport interface BindingHandle {\n /** Marker node(s) used for positioning */\n marker: Comment | DocumentFragment\n /** Flush pending content - call after markers are inserted into DOM */\n flush?: () => void\n /** Dispose function to clean up the binding */\n dispose: Cleanup\n}\n\n/** Managed child node with its dispose function */\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Check if a value is reactive (a getter function that returns a value).\n *\n * A value is considered reactive if:\n * 1. It's a signal or computed value created by the runtime (marked with Symbol)\n * 2. It's a zero-argument function (getter pattern used by the compiler)\n *\n * NOT considered reactive:\n * - Event handlers (functions that take arguments)\n * - Effect disposers (zero-arg but for cleanup, not value access)\n * - Effect scopes (zero-arg but for scope management)\n *\n * @param value - The value to check\n * @returns true if the value is a reactive getter\n *\n * @example\n * ```ts\n * const [count, setCount] = createSignal(0)\n * isReactive(count) // true - signal accessor\n * isReactive(() => 42) // true - getter pattern\n * isReactive((x) => x) // false - takes argument\n * isReactive('hello') // false - not a function\n * isReactive(effectDisposer) // false - effect cleanup function\n * ```\n */\nexport function isReactive(value: unknown): value is () => unknown {\n if (typeof value !== 'function') return false\n\n // Explicit non-reactive marker always wins.\n if (isNonReactiveFn(value)) return false\n\n // Check for runtime-created signals/computed (most reliable)\n if (isSignal(value) || isComputed(value)) return true\n\n // Explicit marker for user-authored reactive getters.\n if (isExplicitReactiveFn(value)) return true\n\n // Exclude effect disposers and effect scopes - they are zero-arg\n // functions but not reactive getters\n if (isEffect(value) || isEffectScope(value)) return false\n\n // Fall back to length check for compiler-generated getters\n // Zero-argument functions are treated as reactive getters\n return value.length === 0\n}\n\n/**\n * Stricter reactive check that only considers explicitly marked values.\n * Used in DOM/event paths where regular callbacks must not be treated as\n * reactive getters.\n *\n * Only returns true for:\n * - Signal accessors (created by createSignal)\n * - Computed accessors (created by createMemo)\n * - Prop getters (marked by __fictProp)\n * - Explicitly marked getters (reactive(...))\n */\nexport function isStrictlyReactive(value: unknown): value is () => unknown {\n if (typeof value !== 'function') return false\n // Do NOT use length === 0 as fallback - many callbacks have 0 params.\n return (\n isSignal(value) || isComputed(value) || isPropGetterFn(value) || isExplicitReactiveFn(value)\n )\n}\n\n// Import-like check for prop getter marker without circular dependency\nconst PROP_GETTER_MARKER = Symbol.for('fict:prop-getter')\nfunction isPropGetterFn(value: unknown): boolean {\n if (typeof value !== 'function') return false\n return (value as any)[PROP_GETTER_MARKER] === true\n}\n\nfunction isNonReactiveFn(value: unknown): boolean {\n if (typeof value !== 'function') return false\n if (getNonReactiveFnRegistry().has(value as (...args: unknown[]) => unknown)) return true\n return (\n (value as ((...args: unknown[]) => unknown) & { [NON_REACTIVE_FN_MARKER]?: boolean })[\n NON_REACTIVE_FN_MARKER\n ] === true\n )\n}\n\n/**\n * Mark a function as non-reactive so runtime bindings won't treat it as a getter.\n * Useful for callback props / function-as-child patterns that must remain callbacks.\n */\nexport function nonReactive<T extends (...args: unknown[]) => unknown>(fn: T): T {\n getNonReactiveFnRegistry().add(fn as (...args: unknown[]) => unknown)\n if (Object.isExtensible(fn)) {\n try {\n ;(fn as T & { [NON_REACTIVE_FN_MARKER]?: boolean })[NON_REACTIVE_FN_MARKER] = true\n } catch {\n // Ignore marker failures on non-standard function objects.\n }\n }\n return fn\n}\n\n/**\n * Mark a zero-arg function as an explicit reactive getter.\n * Useful when authoring runtime code manually and you need function values\n * to participate in reactive binding without relying on heuristics.\n */\nexport function reactive<T>(fn: () => T): () => T {\n if (Object.isExtensible(fn)) {\n try {\n ;(fn as (() => T) & { [REACTIVE_FN_MARKER]?: boolean })[REACTIVE_FN_MARKER] = true\n } catch {\n // Ignore marker failures on non-standard function objects.\n }\n }\n return fn\n}\n\n/**\n * Unwrap a potentially reactive value to get the actual value\n */\nexport function unwrap<T>(value: MaybeReactive<T>): T {\n return isReactive(value) ? (value as () => T)() : value\n}\n\n/**\n * Invoke an event handler or handler accessor in a safe way.\n * Supports handlers that return another handler and handlers that expect an\n * optional data payload followed by the event.\n */\nexport function callEventHandler(\n handler: EventListenerOrEventListenerObject | null | undefined,\n event: Event,\n node?: EventTarget | null,\n data?: unknown,\n): void {\n if (!handler) return\n\n const context = (node ?? event.currentTarget ?? undefined) as EventTarget | undefined\n const invoke = (fn: EventListenerOrEventListenerObject | null | undefined): void => {\n if (typeof fn === 'function') {\n const result =\n data === undefined\n ? (fn as EventListener).call(context, event)\n : (fn as (data: unknown, e: Event) => unknown).call(context, data, event)\n\n if (typeof result === 'function' && result !== fn) {\n if (data === undefined) {\n ;(result as EventListener).call(context, event)\n } else {\n ;(result as (data: unknown, e: Event) => unknown).call(context, data, event)\n }\n } else if (result && typeof (result as EventListenerObject).handleEvent === 'function') {\n ;(result as EventListenerObject).handleEvent.call(result as EventListenerObject, event)\n }\n } else if (fn && typeof fn.handleEvent === 'function') {\n fn.handleEvent.call(fn, event)\n }\n }\n\n invoke(handler)\n}\n\n// ============================================================================\n// Text Binding\n// ============================================================================\n\n/**\n * Create a text node that reactively updates when the value changes.\n *\n * @example\n * ```ts\n * // Static text\n * createTextBinding(\"Hello\")\n *\n * // Reactive text (compiler output)\n * createTextBinding(() => $count())\n * ```\n */\nexport function createTextBinding(value: MaybeReactive<unknown>): Text {\n const text = document.createTextNode('')\n\n if (isReactive(value)) {\n // Reactive: create effect to update text when value changes\n createRenderEffect(() => {\n setText(text, (value as () => unknown)())\n })\n } else {\n // Static: set once\n setText(text, value)\n }\n\n return text\n}\n\n/**\n * Bind a reactive value to an existing text node.\n * This is a convenience function for binding to existing DOM nodes.\n */\nexport function bindText(textNode: Text, getValue: () => unknown): Cleanup {\n return createRenderEffect(() => setText(textNode, getValue()))\n}\n\n/**\n * Patch text node content with per-node value caching.\n * This is the low-level primitive used by compiled render effects.\n */\nexport function setText(textNode: Text, value: unknown): void {\n const next = formatTextValue(value)\n const cache = textNode as unknown as Record<PropertyKey, unknown>\n const prev = cache[TEXT_CACHE]\n if (prev === next && textNode.data === next) return\n cache[TEXT_CACHE] = next\n if (textNode.data !== next) {\n textNode.data = next\n }\n}\n\n/**\n * Format a value for text content\n */\nfunction formatTextValue(value: unknown): string {\n if (value == null || value === false) {\n return ''\n }\n return String(value)\n}\n\n// ============================================================================\n// Attribute Binding\n// ============================================================================\n\n/** Attribute setter function type */\nexport type AttributeSetter = (el: Element, key: string, value: unknown) => void\n\n/**\n * Create a reactive attribute binding on an element.\n *\n * @example\n * ```ts\n * // Static attribute\n * createAttributeBinding(button, 'disabled', false, setAttribute)\n *\n * // Reactive attribute (compiler output)\n * createAttributeBinding(button, 'disabled', () => !$isValid(), setAttribute)\n * ```\n */\nexport function createAttributeBinding(\n el: Element,\n key: string,\n value: MaybeReactive<unknown>,\n setter: AttributeSetter,\n): void {\n if (isReactive(value)) {\n // Reactive: create effect to update attribute when value changes\n createRenderEffect(() => {\n setter(el, key, (value as () => unknown)())\n })\n } else {\n // Static: set once\n setter(el, key, value)\n }\n}\n\n/**\n * Bind a reactive value to an element's attribute.\n */\nexport function bindAttribute(el: Element, key: string, getValue: () => unknown): Cleanup {\n return createRenderEffect(() => setAttr(el, key, getValue()))\n}\n\n/**\n * Patch attribute value with per-node, per-attribute cache.\n */\nexport function setAttr(el: Element, key: string, value: unknown): void {\n const cacheTarget = el as unknown as Record<PropertyKey, unknown>\n const attrCache =\n (cacheTarget[ATTR_CACHE] as Record<string, unknown> | undefined) ??\n (cacheTarget[ATTR_CACHE] = Object.create(null))\n if (attrCache[key] === value) return\n attrCache[key] = value\n\n if (value === undefined || value === null || value === false) {\n el.removeAttribute(key)\n } else if (value === true) {\n el.setAttribute(key, '')\n } else {\n el.setAttribute(key, String(value))\n }\n}\n\n/**\n * Bind a reactive value to an element's property.\n */\nexport function bindProperty(el: Element, key: string, getValue: () => unknown): Cleanup {\n return createRenderEffect(() => setProp(el, key, getValue()))\n}\n\n/**\n * Patch DOM property with per-node, per-property cache.\n */\nexport function setProp(el: Element, key: string, value: unknown): void {\n const cacheTarget = el as unknown as Record<PropertyKey, unknown>\n const propCache =\n (cacheTarget[PROP_CACHE] as Record<string, unknown> | undefined) ??\n (cacheTarget[PROP_CACHE] = Object.create(null))\n if (propCache[key] === value) return\n propCache[key] = value\n\n if (PROPERTY_BINDING_KEYS.has(key) && (value === undefined || value === null)) {\n const fallback = key === 'checked' || key === 'selected' ? false : ''\n ;(el as unknown as Record<string, unknown>)[key] = fallback\n return\n }\n ;(el as unknown as Record<string, unknown>)[key] = value\n}\n\n// ============================================================================\n// Style Binding\n// ============================================================================\n\n/**\n * Apply styles to an element, supporting reactive style objects/strings.\n */\nexport function createStyleBinding(\n el: Element,\n value: MaybeReactive<string | Record<string, string | number> | null | undefined>,\n): void {\n if (isReactive(value)) {\n createRenderEffect(() => {\n setStyle(el, (value as () => unknown)() as string | Record<string, string | number> | null)\n })\n } else {\n setStyle(el, value)\n }\n}\n\n/**\n * Bind a reactive style value to an existing element.\n */\nexport function bindStyle(\n el: Element,\n getValue: () => string | Record<string, string | number> | null | undefined,\n): Cleanup {\n return createRenderEffect(() => setStyle(el, getValue()))\n}\n\n/**\n * Patch style value with cached previous style payload.\n */\nexport function setStyle(\n el: Element,\n value: string | Record<string, string | number> | null | undefined,\n): void {\n const target = el as Element & { style: CSSStyleDeclaration }\n const cache = target as unknown as Record<PropertyKey, unknown>\n const prev = cache[STYLE_CACHE]\n if (typeof value === 'string' && prev === value) return\n if ((value === null || value === undefined) && (prev === null || prev === undefined)) return\n applyStyle(target, value, prev)\n cache[STYLE_CACHE] = value\n}\n\n/**\n * Apply a style value to an element\n */\nfunction applyStyle(\n el: Element & { style: CSSStyleDeclaration },\n value: unknown,\n prev: unknown,\n): void {\n if (typeof value === 'string') {\n el.style.cssText = value\n } else if (value && typeof value === 'object') {\n const styles = value as Record<string, string | number>\n\n // If we previously set styles via string, clear before applying object map\n if (typeof prev === 'string') {\n el.style.cssText = ''\n }\n\n // Remove styles that were present in prev but not in current\n if (prev && typeof prev === 'object') {\n const prevStyles = prev as Record<string, string | number>\n for (const key in prevStyles) {\n if (!hasOwn.call(prevStyles, key)) continue\n if (!hasOwn.call(styles, key)) {\n const cssProperty = normalizeStyleProperty(key)\n el.style.removeProperty(cssProperty)\n }\n }\n }\n\n for (const prop in styles) {\n if (!hasOwn.call(styles, prop)) continue\n const v = styles[prop]\n if (v != null) {\n const cssProperty = normalizeStyleProperty(prop)\n const unitless = isUnitlessStyleProperty(prop) || isUnitlessStyleProperty(cssProperty)\n const valueStr = typeof v === 'number' && !unitless ? `${v}px` : String(v)\n el.style.setProperty(cssProperty, valueStr)\n } else {\n const cssProperty = normalizeStyleProperty(prop)\n el.style.removeProperty(cssProperty) // Handle null/undefined values by removing\n }\n }\n } else {\n // If value is null/undefined, we might want to clear styles set by PREVIOUS binding?\n // But blindly clearing cssText is dangerous.\n // Ideally we remove keys from prev.\n if (prev && typeof prev === 'object') {\n const prevStyles = prev as Record<string, string | number>\n for (const key in prevStyles) {\n if (!hasOwn.call(prevStyles, key)) continue\n const cssProperty = normalizeStyleProperty(key)\n el.style.removeProperty(cssProperty)\n }\n } else if (typeof prev === 'string') {\n el.style.cssText = ''\n }\n }\n}\n\nconst isUnitlessStyleProperty = isDev\n ? (prop: string): boolean => UnitlessStyles.has(prop)\n : (prop: string): boolean => prop === 'opacity' || prop === 'zIndex'\n\nfunction normalizeStyleProperty(prop: string): string {\n const cached = STYLE_PROP_CACHE.get(prop)\n if (cached) return cached\n const normalized = prop.includes('-') ? prop : prop.replace(/([A-Z])/g, '-$1').toLowerCase()\n STYLE_PROP_CACHE.set(prop, normalized)\n return normalized\n}\n\n// ============================================================================\n// Class Binding\n// ============================================================================\n\n/**\n * Apply class to an element, supporting reactive class values.\n */\nexport function createClassBinding(\n el: Element,\n value: MaybeReactive<string | Record<string, boolean> | null | undefined>,\n): void {\n if (isReactive(value)) {\n createRenderEffect(() =>\n setClass(el, (value as () => string | Record<string, boolean> | null | undefined)()),\n )\n } else {\n setClass(el, value)\n }\n}\n\n/**\n * Bind a reactive class value to an existing element.\n */\nexport function bindClass(\n el: Element,\n getValue: () => string | Record<string, boolean> | null | undefined,\n): Cleanup {\n return createRenderEffect(() => setClass(el, getValue()))\n}\n\n/**\n * Patch class value using per-node cached class state.\n */\nexport function setClass(\n el: Element,\n value: string | Record<string, boolean> | null | undefined,\n): void {\n const cache = el as unknown as Record<PropertyKey, unknown>\n const prevValue = cache[CLASS_VALUE_CACHE]\n const prevState = (cache[CLASS_STATE_CACHE] as Record<string, boolean> | undefined) ?? {}\n\n // Preserve existing behavior: short-circuit only for stable string values.\n if (typeof value === 'string') {\n if (typeof prevValue === 'string' && prevValue === value) return\n el.className = value\n cache[CLASS_STATE_CACHE] = {}\n cache[CLASS_VALUE_CACHE] = value\n return\n }\n\n cache[CLASS_STATE_CACHE] = applyClass(el, value, prevState)\n cache[CLASS_VALUE_CACHE] = value\n}\n\n/**\n * Toggle a class key (supports space-separated class names)\n */\nfunction toggleClassKey(node: Element, key: string, value: boolean): void {\n const classNames = key.trim().split(/\\s+/)\n for (let i = 0, len = classNames.length; i < len; i++) {\n node.classList.toggle(classNames[i]!, value)\n }\n}\n\n/**\n * Apply a class value to an element using classList.toggle for efficient updates.\n * Returns the new prev state for tracking.\n */\nfunction applyClass(el: Element, value: unknown, prev: unknown): Record<string, boolean> {\n const prevState = (prev && typeof prev === 'object' ? prev : {}) as Record<string, boolean>\n\n // Handle string value - full replacement\n if (typeof value === 'string') {\n el.className = value\n // Clear prev state since we're doing full replacement\n return {}\n }\n\n // Handle object value - incremental updates\n if (value && typeof value === 'object') {\n const classes = value as Record<string, boolean>\n const classKeys = Object.keys(classes)\n const prevKeys = Object.keys(prevState)\n\n // Remove classes that were true but are now false or missing\n for (let i = 0, len = prevKeys.length; i < len; i++) {\n const key = prevKeys[i]!\n if (!key || key === 'undefined' || classes[key]) continue\n toggleClassKey(el, key, false)\n delete prevState[key]\n }\n\n // Add classes that are now true\n for (let i = 0, len = classKeys.length; i < len; i++) {\n const key = classKeys[i]!\n const classValue = !!classes[key]\n if (!key || key === 'undefined' || prevState[key] === classValue || !classValue) continue\n toggleClassKey(el, key, true)\n prevState[key] = classValue\n }\n\n return prevState\n }\n\n // Handle null/undefined - clear all tracked classes\n if (!value) {\n for (const key of Object.keys(prevState)) {\n if (key && key !== 'undefined') {\n toggleClassKey(el, key, false)\n }\n }\n return {}\n }\n\n return prevState\n}\n\n/**\n * Exported classList function for direct use (compatible with dom-expressions)\n */\nexport function classList(\n node: Element,\n value: Record<string, boolean> | null | undefined,\n prev: Record<string, boolean> = {},\n): Record<string, boolean> {\n return applyClass(node, value, prev)\n}\n\n// ============================================================================\n// Child/Insert Binding (Dynamic Children)\n// ============================================================================\n\n/**\n * Insert reactive content into a parent element.\n * This is a simpler API than createChildBinding for basic cases.\n *\n * @param parent - The parent element to insert into\n * @param getValue - Function that returns the value to render\n * @param markerOrCreateElement - Optional marker node to insert before, or createElementFn\n * @param createElementFn - Optional function to create DOM elements (when marker is provided)\n */\nexport function insert(\n parent: ParentNode & Node,\n getValue: () => FictNode,\n markerOrCreateElement?: Node | CreateElementFn,\n createElementFn?: CreateElementFn,\n): Cleanup {\n const hostRoot = getCurrentRoot()\n let marker: Node\n let ownsMarker = false\n let createFn: CreateElementFn | undefined = createElementFn\n\n if (markerOrCreateElement instanceof Node) {\n marker = markerOrCreateElement\n createFn = createElementFn\n } else {\n marker = document.createComment('fict:insert')\n parent.appendChild(marker)\n createFn = markerOrCreateElement as CreateElementFn | undefined\n ownsMarker = true\n }\n\n let currentNodes: Node[] = []\n let currentText: Text | null = null\n let currentRoot: RootContext | null = null\n\n const clearCurrentNodes = () => {\n if (currentNodes.length > 0) {\n removeNodes(currentNodes)\n currentNodes = []\n }\n }\n\n const setTextNode = (textValue: string, shouldInsert: boolean, parentNode: ParentNode & Node) => {\n if (!currentText) {\n currentText = document.createTextNode(textValue)\n } else if (currentText.data !== textValue) {\n currentText.data = textValue\n }\n\n if (!shouldInsert) {\n clearCurrentNodes()\n return\n }\n\n if (currentNodes.length === 1 && currentNodes[0] === currentText) {\n return\n }\n\n clearCurrentNodes()\n insertNodesBefore(parentNode, [currentText], marker)\n currentNodes = [currentText]\n }\n\n const dispose = createRenderEffect(() => {\n const value = getValue()\n const parentNode = marker.parentNode as (ParentNode & Node) | null\n const isPrimitive =\n value == null ||\n value === false ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n\n if (isPrimitive) {\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n if (!parentNode) {\n clearCurrentNodes()\n return\n }\n const textValue = value == null || value === false ? '' : String(value)\n const shouldInsert = value != null && value !== false\n setTextNode(textValue, shouldInsert, parentNode)\n return\n }\n\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n clearCurrentNodes()\n\n const root = createRootContext(hostRoot)\n const prev = pushRoot(root)\n let nodes: Node[] = []\n let handledError = false\n try {\n let newNode: Node | Node[]\n\n if (value instanceof Node) {\n newNode = value\n } else if (Array.isArray(value)) {\n if (value.every(v => v instanceof Node)) {\n newNode = value as Node[]\n } else {\n if (createFn) {\n const mapped: Node[] = []\n for (const item of value) {\n mapped.push(...toNodeArray(createFn(item as any)))\n }\n newNode = mapped\n } else {\n newNode = document.createTextNode(String(value))\n }\n }\n } else {\n newNode = createFn ? createFn(value) : document.createTextNode(String(value))\n }\n\n nodes = toNodeArray(newNode)\n if (root.suspended) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (parentNode) {\n insertNodesBefore(parentNode, nodes, marker)\n }\n } catch (err) {\n if (handleSuspend(err as any, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (handleError(err, { source: 'renderChild' }, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n throw err\n } finally {\n popRoot(prev)\n if (!handledError) {\n flushOnMount(root)\n }\n }\n\n // If we reach here, no error was handled (handledError blocks return early)\n currentRoot = root\n currentNodes = nodes\n })\n\n return () => {\n dispose()\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n clearCurrentNodes()\n if (ownsMarker) {\n marker.parentNode?.removeChild(marker)\n }\n }\n}\n\n/**\n * Insert reactive content between two marker comments.\n * Supports hydration by claiming existing nodes between markers.\n */\nexport function insertBetween(\n start: Comment,\n end: Comment,\n getValue: () => FictNode,\n createElementFn?: CreateElementFn,\n): Cleanup {\n const hostRoot = getCurrentRoot()\n let currentNodes: Node[] = []\n let currentText: Text | null = null\n let currentRoot: RootContext | null = null\n let initialHydrating = __fictIsHydrating()\n\n const collectBetween = (): Node[] => {\n const nodes: Node[] = []\n let cursor = start.nextSibling\n while (cursor && cursor !== end) {\n nodes.push(cursor)\n cursor = cursor.nextSibling\n }\n return nodes\n }\n\n const clearCurrentNodes = () => {\n if (currentNodes.length > 0) {\n removeNodes(currentNodes)\n currentNodes = []\n }\n }\n\n const setTextNode = (textValue: string, shouldInsert: boolean) => {\n if (!currentText) {\n currentText = document.createTextNode(textValue)\n } else if (currentText.data !== textValue) {\n currentText.data = textValue\n }\n\n if (!shouldInsert) {\n clearCurrentNodes()\n return\n }\n\n if (currentNodes.length === 1 && currentNodes[0] === currentText) {\n return\n }\n\n clearCurrentNodes()\n const parentNode = start.parentNode as (ParentNode & Node) | null\n if (parentNode) {\n insertNodesBefore(parentNode, [currentText], end)\n currentNodes = [currentText]\n }\n }\n\n const dispose = createRenderEffect(() => {\n const value = getValue()\n const parentNode = start.parentNode as (ParentNode & Node) | null\n const isPrimitive =\n value == null ||\n value === false ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n\n if (isPrimitive) {\n if (initialHydrating && isHydratingActive() && parentNode) {\n const existing = collectBetween()\n if (existing.length > 0) {\n currentNodes = existing\n const only = existing.length === 1 ? existing[0] : null\n currentText = only && only.nodeType === 3 ? (only as Text) : null\n }\n }\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n if (!parentNode) {\n clearCurrentNodes()\n return\n }\n const textValue = value == null || value === false ? '' : String(value)\n const shouldInsert = value != null && value !== false\n setTextNode(textValue, shouldInsert)\n initialHydrating = false\n return\n }\n\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n clearCurrentNodes()\n\n const root = createRootContext(hostRoot)\n const prev = pushRoot(root)\n let nodes: Node[] = []\n let handledError = false\n try {\n let newNode: Node | Node[] = undefined as unknown as Node | Node[]\n const createValue = () => {\n if (value instanceof Node) {\n return value\n }\n if (Array.isArray(value)) {\n if (value.every(v => v instanceof Node)) {\n return value as Node[]\n }\n if (createElementFn) {\n const mapped: Node[] = []\n for (const item of value) {\n mapped.push(...toNodeArray(createElementFn(item as any)))\n }\n return mapped\n }\n return document.createTextNode(String(value))\n }\n return createElementFn ? createElementFn(value) : document.createTextNode(String(value))\n }\n\n if (initialHydrating && isHydratingActive() && parentNode) {\n withHydrationRange(start.nextSibling, end, parentNode.ownerDocument ?? document, () => {\n newNode = createValue()\n })\n } else {\n newNode = createValue()\n }\n\n nodes = toNodeArray(newNode)\n if (root.suspended) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (parentNode && !initialHydrating) {\n insertNodesBefore(parentNode, nodes, end)\n }\n } catch (err) {\n if (handleSuspend(err as any, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (handleError(err, { source: 'renderChild' }, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n throw err\n } finally {\n popRoot(prev)\n if (!handledError) {\n flushOnMount(root)\n }\n }\n\n currentRoot = root\n currentNodes = initialHydrating ? collectBetween() : nodes\n initialHydrating = false\n })\n\n return () => {\n dispose()\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n clearCurrentNodes()\n }\n}\n\n/**\n * Create a reactive child binding that updates when the child value changes.\n * This is used for dynamic expressions like `{show && <Modal />}` or `{items.map(...)}`.\n *\n * @example\n * ```ts\n * // Reactive child (compiler output for {count})\n * createChildBinding(parent, () => $count(), createElement)\n *\n * // Reactive conditional (compiler output for {show && <Modal />})\n * createChildBinding(parent, () => $show() && jsx(Modal, {}), createElement)\n * ```\n */\nexport function createChildBinding(\n parent: ParentNode & Node,\n getValue: () => FictNode,\n createElementFn: CreateElementFn,\n): BindingHandle {\n const marker = document.createComment('fict:child')\n parent.appendChild(marker)\n const hostRoot = getCurrentRoot()\n\n const dispose = createRenderEffect(() => {\n const root = createRootContext(hostRoot)\n const prev = pushRoot(root)\n let nodes: Node[] = []\n let handledError = false\n try {\n const value = getValue()\n\n // Skip if value is null/undefined/false\n if (value == null || value === false) {\n return\n }\n\n const output = createElementFn(value)\n nodes = toNodeArray(output)\n const parentNode = marker.parentNode as (ParentNode & Node) | null\n if (parentNode) {\n insertNodesBefore(parentNode, nodes, marker)\n }\n return () => {\n destroyRoot(root)\n removeNodes(nodes)\n }\n } catch (err) {\n if (handleSuspend(err as any, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (handleError(err, { source: 'renderChild' }, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n throw err\n } finally {\n popRoot(prev)\n if (!handledError) {\n flushOnMount(root)\n }\n }\n })\n\n return {\n marker,\n dispose: () => {\n dispose()\n marker.parentNode?.removeChild(marker)\n },\n }\n}\n\n// ============================================================================\n// Event Delegation System\n// ============================================================================\n\n// Extend Element/Document type to support event delegation\ndeclare global {\n interface Element {\n _$host?: Element\n [key: `$$${string}`]: EventListener | [EventListener, unknown] | undefined\n [key: `$$${string}Data`]: unknown\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface Document extends Record<string, unknown> {}\n}\n\n/**\n * Initialize event delegation for a set of event names.\n * Events will be handled at the document level and dispatched to the appropriate handlers.\n *\n * @param eventNames - Array of event names to delegate\n * @param doc - The document to attach handlers to (default: window.document)\n *\n * @example\n * ```ts\n * // Called automatically by the compiler for delegated events\n * delegateEvents(['click', 'input', 'keydown'])\n * ```\n */\nexport function delegateEvents(eventNames: string[], doc: Document = window.document): void {\n const e = (doc[$$EVENTS] as Set<string>) || (doc[$$EVENTS] = new Set<string>())\n for (let i = 0, l = eventNames.length; i < l; i++) {\n const name = eventNames[i]!\n if (!e.has(name)) {\n e.add(name)\n doc.addEventListener(name, globalEventHandler)\n }\n }\n}\n\n/**\n * Clear all delegated event handlers from a document.\n *\n * @param doc - The document to clear handlers from (default: window.document)\n */\nexport function clearDelegatedEvents(doc: Document = window.document): void {\n const e = doc[$$EVENTS] as Set<string> | undefined\n if (e) {\n for (const name of e.keys()) {\n doc.removeEventListener(name, globalEventHandler)\n }\n delete doc[$$EVENTS]\n }\n}\n\n/**\n * Global event handler for delegated events.\n * Walks up the DOM tree to find and call handlers stored as $$eventName properties.\n */\nfunction globalEventHandler(e: Event): void {\n const asNode = (value: unknown): Node | null =>\n value && typeof (value as Node).nodeType === 'number' ? (value as Node) : null\n const asElement = (value: unknown): Element | null => {\n const n = asNode(value)\n if (!n) return null\n if (n.nodeType === 1) return n as Element\n return (n as ChildNode).parentElement\n }\n\n let node = asElement(e.target)\n const key = `$$${e.type}` as const\n const dataKey = `${key}Data` as `$$${string}Data`\n const oriTarget = e.target\n const oriCurrentTarget = e.currentTarget\n let lastHandled: Element | null = null\n\n // Retarget helper for shadow DOM and portals\n const retarget = (value: EventTarget) =>\n Object.defineProperty(e, 'target', {\n configurable: true,\n value,\n })\n\n // Handler for each node in the bubble path\n const handleNode = (): boolean => {\n if (!node) return false\n const handler = node[key]\n if (handler && !(node as HTMLButtonElement).disabled) {\n const resolveData = (value: unknown): unknown => {\n if (typeof value === 'function') {\n try {\n const fn = value as (event?: Event) => unknown\n return fn.length > 0 ? fn(e) : fn()\n } catch {\n return (value as () => unknown)()\n }\n }\n return value\n }\n\n const rawData = (node as any)[dataKey] as unknown\n const hasData = rawData !== undefined\n const resolvedNodeData = hasData ? resolveData(rawData) : undefined\n // Wrap event handler calls in batch for synchronous flush & reduced microtasks\n batch(() => {\n if (typeof handler === 'function') {\n callEventHandler(handler, e, node, hasData ? resolvedNodeData : undefined)\n } else if (Array.isArray(handler)) {\n const tupleData = resolveData(handler[1])\n callEventHandler(handler[0], e, node, tupleData)\n }\n })\n if (e.cancelBubble) return false\n }\n // Handle shadow DOM host retargeting\n const shadowHost = (node as unknown as ShadowRoot).host\n if (\n shadowHost &&\n typeof shadowHost !== 'string' &&\n !(shadowHost as Element)._$host &&\n (() => {\n const targetNode = asNode(e.target)\n return targetNode ? node.contains(targetNode) : false\n })()\n ) {\n retarget(shadowHost as EventTarget)\n }\n return true\n }\n\n // Walk up tree helper\n const walkUpTree = (): void => {\n while (handleNode() && node) {\n node = asElement(node._$host || node.parentNode || (node as unknown as ShadowRoot).host)\n }\n }\n\n // Simulate currentTarget\n Object.defineProperty(e, 'currentTarget', {\n configurable: true,\n get() {\n return node || document\n },\n })\n\n // Use composedPath for shadow DOM support\n if (e.composedPath) {\n const path = e.composedPath()\n retarget(path[0] as EventTarget)\n for (let i = 0; i < path.length - 2; i++) {\n const nextNode = asElement(path[i] as EventTarget)\n if (!nextNode || nextNode === lastHandled) continue\n node = nextNode\n if (!handleNode()) break\n lastHandled = node\n // Handle portal event bubbling\n if (node._$host) {\n node = node._$host\n walkUpTree()\n break\n }\n // Don't bubble above root of event delegation\n if (node.parentNode === oriCurrentTarget) {\n break\n }\n }\n } else {\n // Fallback for browsers without composedPath\n walkUpTree()\n }\n\n // Reset target\n retarget(oriTarget as EventTarget)\n}\n\n/**\n * Add an event listener to an element.\n * If the event is in DelegatedEvents, it uses event delegation for better performance.\n *\n * @param node - The element to add the listener to\n * @param name - The event name (lowercase)\n * @param handler - The event handler or [handler, data] tuple\n * @param delegate - Whether to use delegation (auto-detected based on event name)\n */\nexport function addEventListener(\n node: Element,\n name: string,\n handler: EventListener | [EventListener, unknown] | null | undefined,\n delegate?: boolean,\n): void {\n if (handler == null) return\n\n if (delegate) {\n // Event delegation: store handler on element\n if (Array.isArray(handler)) {\n ;(node as unknown as Record<string, unknown>)[`$$${name}`] = handler[0]\n ;(node as unknown as Record<string, unknown>)[`$$${name}Data`] = handler[1]\n } else {\n ;(node as unknown as Record<string, unknown>)[`$$${name}`] = handler\n }\n } else if (Array.isArray(handler)) {\n // Non-delegated with data binding\n const handlerFn = handler[0] as (data: unknown, e: Event) => void\n node.addEventListener(name, (e: Event) => handlerFn.call(node, handler[1], e))\n } else {\n // Regular event listener\n node.addEventListener(name, handler as EventListener)\n }\n}\n\n// ============================================================================\n// Event Binding\n// ============================================================================\n\n/**\n * Bind an event listener to an element.\n * Uses event delegation for better performance when applicable.\n *\n * @example\n * ```ts\n * // Static event\n * bindEvent(button, 'click', handleClick)\n *\n * // Reactive event (compiler output)\n * bindEvent(button, 'click', () => $handler())\n *\n * // With modifiers\n * bindEvent(button, 'click', handler, { capture: true, passive: true, once: true })\n * ```\n */\nexport function bindEvent(\n el: Element,\n eventName: string,\n handler: EventListenerOrEventListenerObject | null | undefined,\n options?: boolean | AddEventListenerOptions,\n): Cleanup {\n if (handler == null) return () => {}\n const rootRef = getCurrentRoot()\n\n // Optimization: Global Event Delegation\n // If the event is delegatable and no options were provided,\n // we attach the handler to the element property and rely on the global listener.\n const shouldDelegate = options == null && DelegatedEvents.has(eventName)\n if (shouldDelegate) {\n const key = `$$${eventName}`\n\n // Ensure global delegation is active for this event\n delegateEvents([eventName])\n\n // Use stricter check - don't misidentify regular callbacks as reactive\n const resolveHandler = isStrictlyReactive(handler)\n ? (handler as () => EventListenerOrEventListenerObject | null | undefined)\n : () => handler\n\n // Cache a single wrapper that resolves the latest handler when invoked\n // @ts-expect-error - using dynamic property for delegation\n el[key] = function (this: any, ...args: any[]) {\n try {\n const fn = resolveHandler()\n callEventHandler(fn as EventListenerOrEventListenerObject, args[0] as Event, el)\n } catch (err) {\n if (!handleError(err, { source: 'event', eventName }, rootRef)) {\n throw err\n }\n }\n }\n\n // Cleanup: remove property (no effect needed for static or reactive)\n return () => {\n // @ts-expect-error - using dynamic property for delegation\n el[key] = undefined\n }\n }\n\n // Fallback: Native addEventListener\n // Used for non-delegated events or when options are present\n // Use stricter check - don't misidentify regular callbacks as reactive\n const getHandler = isStrictlyReactive(handler) ? (handler as () => unknown) : () => handler\n\n // Create wrapped handler that resolves reactive handlers\n const wrapped: EventListener = event => {\n try {\n const resolved = getHandler()\n callEventHandler(resolved as EventListenerOrEventListenerObject, event, el)\n } catch (err) {\n if (handleError(err, { source: 'event', eventName }, rootRef)) {\n return\n }\n throw err\n }\n }\n\n el.addEventListener(eventName, wrapped, options)\n const cleanup = () => el.removeEventListener(eventName, wrapped, options)\n registerRootCleanup(cleanup)\n return cleanup\n}\n\n// ============================================================================\n// Ref Binding\n// ============================================================================\n\n/**\n * Bind a ref to an element.\n * Supports both callback refs and ref objects.\n *\n * @param el - The element to bind the ref to\n * @param ref - Either a callback function, a ref object, or a reactive getter\n * @returns Cleanup function\n *\n * @example\n * ```ts\n * // Callback ref\n * bindRef(el, (element) => { store.input = element })\n *\n * // Ref object\n * const inputRef = createRef()\n * bindRef(el, inputRef)\n *\n * // Reactive ref (compiler output)\n * bindRef(el, () => props.ref)\n * ```\n */\nexport function bindRef(el: Element, ref: unknown): Cleanup {\n if (ref == null) return () => {}\n\n // Handle reactive refs (getters)\n const getRef = isReactive(ref) ? (ref as () => unknown) : () => ref\n\n const applyRef = (refValue: unknown) => {\n if (refValue == null) return\n\n if (typeof refValue === 'function') {\n // Callback ref: call with element\n ;(refValue as (el: Element) => void)(el)\n } else if (typeof refValue === 'object' && 'current' in refValue) {\n // Ref object: set current property\n ;(refValue as { current: Element | null }).current = el\n }\n }\n\n // Apply ref initially\n const initialRef = getRef()\n applyRef(initialRef)\n\n // For reactive refs, track changes\n if (isReactive(ref)) {\n const cleanup = createRenderEffect(() => {\n const currentRef = getRef()\n applyRef(currentRef)\n })\n registerRootCleanup(cleanup)\n\n // On cleanup, null out the ref\n const nullifyCleanup = () => {\n const currentRef = getRef()\n if (currentRef && typeof currentRef === 'object' && 'current' in currentRef) {\n ;(currentRef as { current: Element | null }).current = null\n }\n }\n registerRootCleanup(nullifyCleanup)\n\n return () => {\n cleanup()\n nullifyCleanup()\n }\n }\n\n // For static refs, register cleanup to null out on unmount\n const cleanup = () => {\n const refValue = getRef()\n if (refValue && typeof refValue === 'object' && 'current' in refValue) {\n ;(refValue as { current: Element | null }).current = null\n }\n }\n registerRootCleanup(cleanup)\n\n return cleanup\n}\n\n// ============================================================================\n// Spread Props\n// ============================================================================\n\n/**\n * Apply spread props to an element with reactive updates.\n * This handles dynamic spread like `<div {...props}>`.\n *\n * @param node - The element to apply props to\n * @param props - The props object (may have reactive getters)\n * @param isSVG - Whether this is an SVG element\n * @param skipChildren - Whether to skip children handling\n * @returns The previous props for tracking changes\n *\n * @example\n * ```ts\n * // Compiler output for <div {...props} />\n * spread(el, props, false, false)\n * ```\n */\nexport function spread(\n node: Element,\n props: Record<string, unknown> = {},\n isSVG = false,\n skipChildren = false,\n): Record<string, unknown> {\n const prevProps: Record<string, unknown> = {}\n\n // Handle children if not skipped\n if (!skipChildren && 'children' in props) {\n createRenderEffect(() => {\n prevProps.children = props.children\n })\n }\n\n // Handle ref\n createRenderEffect(() => {\n if (typeof props.ref === 'function') {\n ;(props.ref as (el: Element) => void)(node)\n }\n })\n\n // Handle all other props\n createRenderEffect(() => {\n assign(node, props, isSVG, true, prevProps, true)\n })\n\n return prevProps\n}\n\n/**\n * Assign props to a node, tracking previous values for efficient updates.\n * This is the core prop assignment logic used by spread.\n *\n * @param node - The element to assign props to\n * @param props - New props object\n * @param isSVG - Whether this is an SVG element\n * @param skipChildren - Whether to skip children handling\n * @param prevProps - Previous props for comparison\n * @param skipRef - Whether to skip ref handling\n */\nexport function assign(\n node: Element,\n props: Record<string, unknown>,\n isSVG = false,\n skipChildren = false,\n prevProps: Record<string, unknown> = {},\n skipRef = false,\n): void {\n props = props || {}\n\n // Remove props that are no longer present\n for (const prop in prevProps) {\n if (!(prop in props)) {\n if (prop === 'children') continue\n prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props)\n }\n }\n\n // Set or update props\n for (const prop in props) {\n if (prop === 'children') {\n if (!skipChildren) {\n // Handle children insertion\n prevProps.children = props.children\n }\n continue\n }\n const value = props[prop]\n prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props)\n }\n}\n\n/**\n * Assign a single prop to a node.\n */\nfunction assignProp(\n node: Element,\n prop: string,\n value: unknown,\n prev: unknown,\n isSVG: boolean,\n skipRef: boolean,\n props: Record<string, unknown>,\n): unknown {\n // Style handling\n if (prop === 'style') {\n applyStyle(node as Element & { style: CSSStyleDeclaration }, value, prev)\n return value\n }\n\n // classList handling\n if (prop === 'classList') {\n return applyClass(node, value, prev)\n }\n\n // Skip if value unchanged\n if (value === prev) return prev\n\n // Ref handling\n if (prop === 'ref') {\n if (!skipRef && typeof value === 'function') {\n ;(value as (el: Element) => void)(node)\n }\n return value\n }\n\n // Event handling: on:eventname\n if (prop.slice(0, 3) === 'on:') {\n const eventName = prop.slice(3)\n if (typeof value === 'string') {\n node.setAttribute(prop, value)\n return value\n }\n if (prev && typeof prev !== 'string') node.removeEventListener(eventName, prev as EventListener)\n if (value) node.addEventListener(eventName, value as EventListener)\n return value\n }\n\n // Capture event handling: oncapture:eventname\n if (prop.slice(0, 10) === 'oncapture:') {\n const eventName = prop.slice(10)\n if (prev) node.removeEventListener(eventName, prev as EventListener, true)\n if (value) node.addEventListener(eventName, value as EventListener, true)\n return value\n }\n\n // Standard event handling: onClick, onInput, etc.\n if (prop.slice(0, 2) === 'on') {\n const eventName = prop.slice(2).toLowerCase()\n const shouldDelegate = DelegatedEvents.has(eventName)\n if (!shouldDelegate && prev) {\n const handler = Array.isArray(prev) ? prev[0] : prev\n node.removeEventListener(eventName, handler as EventListener)\n }\n if (shouldDelegate || value) {\n addEventListener(node, eventName, value as EventListener, shouldDelegate)\n if (shouldDelegate) delegateEvents([eventName])\n }\n return value\n }\n\n // Explicit attribute: attr:name\n if (prop.slice(0, 5) === 'attr:') {\n if (value == null) node.removeAttribute(prop.slice(5))\n else node.setAttribute(prop.slice(5), String(value))\n return value\n }\n\n // Explicit boolean attribute: bool:name\n if (prop.slice(0, 5) === 'bool:') {\n if (value) node.setAttribute(prop.slice(5), '')\n else node.removeAttribute(prop.slice(5))\n return value\n }\n\n // Explicit property: prop:name\n if (prop.slice(0, 5) === 'prop:') {\n ;(node as unknown as Record<string, unknown>)[prop.slice(5)] = value\n return value\n }\n\n // Class/className handling\n if (prop === 'class' || prop === 'className') {\n if (value == null) node.removeAttribute('class')\n else node.className = String(value)\n return value\n }\n\n // Check if custom element\n const isCE = node.nodeName.includes('-') || 'is' in props\n\n // Property handling (for non-SVG elements)\n if (!isSVG) {\n const propAlias = isDev ? getPropAlias(prop, node.tagName) : undefined\n const isProperty = isDev\n ? Properties.has(prop)\n : prop in (node as unknown as Record<string, unknown>)\n const isChildProp = isDev\n ? ChildProperties.has(prop)\n : prop === 'innerHTML' ||\n prop === 'textContent' ||\n prop === 'innerText' ||\n prop === 'children'\n\n if (propAlias || isProperty || isChildProp || isCE) {\n const propName = propAlias || prop\n if (isCE && !isProperty && !isChildProp && !propAlias) {\n ;(node as unknown as Record<string, unknown>)[toPropertyName(propName)] = value\n } else {\n ;(node as unknown as Record<string, unknown>)[propName] = value\n }\n return value\n }\n }\n\n // SVG namespace handling\n if (isSVG && prop.indexOf(':') > -1) {\n const [prefix, name] = prop.split(':')\n const ns = SVGNamespace[prefix!]\n if (ns) {\n if (value == null) node.removeAttributeNS(ns, name!)\n else node.setAttributeNS(ns, name!, String(value))\n return value\n }\n }\n\n // Default: set as attribute\n const attrName = prop === 'htmlFor' ? 'for' : prop\n if (value == null) node.removeAttribute(attrName)\n else node.setAttribute(attrName, String(value))\n return value\n}\n\n/**\n * Convert kebab-case to camelCase for property names\n */\nfunction toPropertyName(name: string): string {\n return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase())\n}\n\n// ============================================================================\n// Conditional Rendering\n// ============================================================================\n\n/**\n * Create a conditional rendering binding.\n * Efficiently renders one of two branches based on a condition.\n *\n * This is an optimized version for `{condition ? <A /> : <B />}` patterns\n * where both branches are known statically.\n *\n * @example\n * ```ts\n * // Compiler output for {show ? <A /> : <B />}\n * createConditional(\n * () => $show(),\n * () => jsx(A, {}),\n * () => jsx(B, {}),\n * createElement\n * )\n * ```\n */\nexport function createConditional(\n condition: () => boolean,\n renderTrue: () => FictNode,\n createElementFn: CreateElementFn,\n renderFalse?: () => FictNode,\n startOverride?: Comment,\n endOverride?: Comment,\n): BindingHandle {\n const useProvided = !!(startOverride && endOverride)\n const startMarker = useProvided ? startOverride! : document.createComment('fict:cond:start')\n const endMarker = useProvided ? endOverride! : document.createComment('fict:cond:end')\n const fragment = useProvided ? startMarker : document.createDocumentFragment()\n if (!useProvided) {\n ;(fragment as DocumentFragment).append(startMarker, endMarker)\n }\n const hostRoot = getCurrentRoot()\n\n let currentNodes: Node[] = []\n let currentRoot: RootContext | null = null\n let lastCondition: boolean | undefined = undefined\n let pendingRender = false\n let initialHydrating = __fictIsHydrating()\n\n const collectBetween = (): Node[] => {\n const nodes: Node[] = []\n let cursor = startMarker.nextSibling\n while (cursor && cursor !== endMarker) {\n nodes.push(cursor)\n cursor = cursor.nextSibling\n }\n return nodes\n }\n\n // Use computed to memoize condition value - this prevents the effect from\n // re-running when condition dependencies change but the boolean result stays same.\n // This is critical because re-running the effect would purge child effect deps\n // (like bindText) even if we early-return, breaking fine-grained reactivity.\n const conditionMemo = computed(condition)\n\n const runConditional = () => {\n const cond = conditionMemo()\n const parent = startMarker.parentNode as (ParentNode & Node) | null\n if (!parent) {\n pendingRender = true\n return\n }\n pendingRender = false\n\n if (initialHydrating && isHydratingActive()) {\n initialHydrating = false\n lastCondition = cond\n\n const render = cond ? renderTrue : renderFalse\n if (!render) {\n currentNodes = collectBetween()\n return\n }\n\n const root = createRootContext(hostRoot)\n const prev = pushRoot(root)\n let handledError = false\n try {\n // Call render() INSIDE withHydrationRange so that template() and insertBetween\n // see the correct hydration context for the conditional content\n withHydrationRange(\n startMarker.nextSibling,\n endMarker,\n parent.ownerDocument ?? document,\n () => {\n const output = untrack(render)\n if (output == null || output === false) {\n return\n }\n createElementFn(output)\n },\n )\n currentNodes = collectBetween()\n } catch (err) {\n if (handleSuspend(err as any, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (handleError(err, { source: 'renderChild' }, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n throw err\n } finally {\n popRoot(prev)\n if (!handledError) {\n flushOnMount(root)\n currentRoot = root\n } else {\n currentRoot = null\n }\n }\n return\n }\n\n if (lastCondition === cond && currentNodes.length > 0) {\n return\n }\n if (lastCondition === cond && lastCondition === false && renderFalse === undefined) {\n return\n }\n lastCondition = cond\n\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n removeNodes(currentNodes)\n currentNodes = []\n\n const render = cond ? renderTrue : renderFalse\n if (!render) {\n return\n }\n\n const root = createRootContext(hostRoot)\n const prev = pushRoot(root)\n let handledError = false\n try {\n // Use untrack to prevent render function's signal accesses from being\n // tracked by createConditional's effect. This ensures that signals used\n // inside the render function (e.g., nested if conditions) don't cause\n // createConditional to re-run, which would purge child effect deps.\n const output = untrack(render)\n if (output == null || output === false) {\n return\n }\n const el = createElementFn(output)\n const nodes = toNodeArray(el)\n insertNodesBefore(parent, nodes, endMarker)\n currentNodes = nodes\n } catch (err) {\n if (handleSuspend(err as any, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n if (handleError(err, { source: 'renderChild' }, root)) {\n handledError = true\n destroyRoot(root)\n return\n }\n throw err\n } finally {\n popRoot(prev)\n if (!handledError) {\n flushOnMount(root)\n currentRoot = root\n } else {\n currentRoot = null\n }\n }\n }\n\n const dispose = createRenderEffect(runConditional)\n\n return {\n marker: fragment,\n flush: () => {\n if (pendingRender) {\n runConditional()\n }\n },\n dispose: () => {\n dispose()\n if (currentRoot) {\n destroyRoot(currentRoot)\n }\n removeNodes(currentNodes)\n currentNodes = []\n startMarker.parentNode?.removeChild(startMarker)\n endMarker.parentNode?.removeChild(endMarker)\n },\n }\n}\n\n// ============================================================================\n// Show/Hide Helper\n// ==========================================================================\n\n/**\n * Create a show/hide binding that uses CSS display instead of DOM manipulation.\n * More efficient than conditional when the content is expensive to create.\n *\n * @example\n * ```ts\n * createShow(container, () => $visible())\n * ```\n */\nexport function createShow(\n el: Element & { style: CSSStyleDeclaration },\n condition: () => boolean,\n displayValue?: string,\n): void {\n const originalDisplay = displayValue ?? el.style.display\n createRenderEffect(() => {\n el.style.display = condition() ? originalDisplay : 'none'\n })\n}\n\n// ============================================================================\n// Portal\n// ============================================================================\n\n/**\n * Create a portal that renders content into a different DOM container.\n *\n * @example\n * ```ts\n * createPortal(\n * document.body,\n * () => jsx(Modal, { children: 'Hello' }),\n * createElement\n * )\n * ```\n */\nexport function createPortal(\n container: ParentNode & Node,\n render: () => FictNode,\n createElementFn: CreateElementFn,\n): BindingHandle {\n // Capture the parent root BEFORE any effects run\n // This is needed because createRenderEffect will push/pop its own root context\n const parentRoot = getCurrentRoot()\n\n const marker = document.createComment('fict:portal')\n container.appendChild(marker)\n\n let currentNodes: Node[] = []\n let currentRoot: RootContext | null = null\n\n const dispose = createRenderEffect(() => {\n // Clean up previous\n if (currentRoot) {\n destroyRoot(currentRoot)\n currentRoot = null\n }\n if (currentNodes.length > 0) {\n removeNodes(currentNodes)\n currentNodes = []\n }\n\n // Create new content\n const root = createRootContext(parentRoot)\n const prev = pushRoot(root)\n let handledError = false\n try {\n const output = render()\n if (output != null && output !== false) {\n const el = createElementFn(output)\n const nodes = toNodeArray(el)\n if (marker.parentNode) {\n insertNodesBefore(marker.parentNode as ParentNode & Node, nodes, marker)\n }\n currentNodes = nodes\n }\n } catch (err) {\n if (handleSuspend(err as any, root)) {\n handledError = true\n destroyRoot(root)\n currentNodes = []\n return\n }\n if (handleError(err, { source: 'renderChild' }, root)) {\n handledError = true\n destroyRoot(root)\n currentNodes = []\n return\n }\n throw err\n } finally {\n popRoot(prev)\n if (!handledError) {\n flushOnMount(root)\n currentRoot = root\n } else {\n currentRoot = null\n }\n }\n })\n\n // The portal's dispose function must be named so we can register it for cleanup\n const portalDispose = () => {\n dispose()\n if (currentRoot) {\n destroyRoot(currentRoot)\n }\n if (currentNodes.length > 0) {\n removeNodes(currentNodes)\n }\n marker.parentNode?.removeChild(marker)\n }\n\n // Register the portal's cleanup with the parent component's root context\n // This ensures the portal is cleaned up when the parent unmounts\n // We use parentRoot (captured before createRenderEffect) to avoid registering\n // with the portal's internal root which would be destroyed separately\n if (parentRoot) {\n parentRoot.destroyCallbacks.push(portalDispose)\n }\n\n return {\n marker,\n dispose: portalDispose,\n }\n}\n\nfunction patchElement(el: Element, output: FictNode): boolean {\n if (\n output === null ||\n output === undefined ||\n output === false ||\n typeof output === 'string' ||\n typeof output === 'number'\n ) {\n el.textContent =\n output === null || output === undefined || output === false ? '' : String(output)\n return true\n }\n\n if (output instanceof Text) {\n el.textContent = output.data\n return true\n }\n\n if (output && typeof output === 'object' && !(output instanceof Node)) {\n const vnode = output as { type?: unknown; props?: Record<string, unknown> }\n if (typeof vnode.type === 'string' && vnode.type.toLowerCase() === el.tagName.toLowerCase()) {\n const children = vnode.props?.children\n const props = vnode.props ?? {}\n\n // Update props (except children and key)\n for (const [key, value] of Object.entries(props)) {\n if (key === 'children' || key === 'key') continue\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value === null ||\n value === undefined\n ) {\n if (key === 'class' || key === 'className') {\n el.setAttribute('class', value === false || value === null ? '' : String(value))\n } else if (key === 'style' && typeof value === 'string') {\n ;(el as Element & { style: CSSStyleDeclaration }).style.cssText = value\n } else if (value === false || value === null || value === undefined) {\n el.removeAttribute(key)\n } else if (value === true) {\n el.setAttribute(key, '')\n } else {\n el.setAttribute(key, String(value))\n }\n }\n }\n\n // Handle primitive children\n if (\n typeof children === 'string' ||\n typeof children === 'number' ||\n children === null ||\n children === undefined ||\n children === false\n ) {\n el.textContent =\n children === null || children === undefined || children === false ? '' : String(children)\n return true\n }\n\n // Handle single nested VNode child - recursively patch\n if (\n children &&\n typeof children === 'object' &&\n !Array.isArray(children) &&\n !(children instanceof Node)\n ) {\n const childVNode = children as { type?: unknown; props?: Record<string, unknown> }\n if (typeof childVNode.type === 'string') {\n // Find matching child element in the DOM\n const childEl = el.querySelector(childVNode.type)\n if (childEl && patchElement(childEl, children as FictNode)) {\n return true\n }\n }\n }\n\n return false\n }\n }\n\n if (output instanceof Node) {\n if (output.nodeType === Node.ELEMENT_NODE) {\n const nextEl = output as Element\n if (nextEl.tagName.toLowerCase() === el.tagName.toLowerCase()) {\n el.textContent = nextEl.textContent\n return true\n }\n } else if (output.nodeType === Node.TEXT_NODE) {\n el.textContent = (output as Text).data\n return true\n }\n }\n\n return false\n}\n\nfunction patchNode(currentNode: Node | null, nextOutput: FictNode): boolean {\n if (!currentNode) return false\n\n if (\n currentNode instanceof Text &&\n (nextOutput === null ||\n nextOutput === undefined ||\n nextOutput === false ||\n typeof nextOutput === 'string' ||\n typeof nextOutput === 'number' ||\n nextOutput instanceof Text)\n ) {\n const nextText =\n nextOutput instanceof Text\n ? nextOutput.data\n : nextOutput === null || nextOutput === undefined || nextOutput === false\n ? ''\n : String(nextOutput)\n currentNode.data = nextText\n return true\n }\n\n if (currentNode instanceof Element && patchElement(currentNode, nextOutput)) {\n return true\n }\n\n if (nextOutput instanceof Node && currentNode === nextOutput) {\n return true\n }\n\n return false\n}\n\nfunction _isFragmentVNode(\n value: unknown,\n): value is { type: typeof Fragment; props?: { children?: FictNode | FictNode[] } } {\n return (\n value != null &&\n typeof value === 'object' &&\n !(value instanceof Node) &&\n (value as { type?: unknown }).type === Fragment\n )\n}\n\nfunction normalizeChildren(\n children: FictNode | FictNode[] | undefined,\n result: FictNode[] = [],\n): FictNode[] {\n if (children === undefined) {\n return result\n }\n if (Array.isArray(children)) {\n for (const child of children) {\n normalizeChildren(child, result)\n }\n return result\n }\n if (children === null || children === false) {\n return result\n }\n result.push(children)\n return result\n}\n\nfunction _patchFragmentChildren(\n nodes: Node[],\n children: FictNode | FictNode[] | undefined,\n): boolean {\n const normalized = normalizeChildren(children)\n if (normalized.length !== nodes.length) {\n return false\n }\n for (let i = 0; i < normalized.length; i++) {\n if (!patchNode(nodes[i]!, normalized[i]!)) {\n return false\n }\n }\n return true\n}\n\n// DOM utility functions are imported from './node-ops' to avoid duplication\n","import { createMemo } from './memo'\nimport { isComputed, isEffect, isEffectScope, isSignal } from './signal'\n\nconst PROP_GETTER_MARKER = Symbol.for('fict:prop-getter')\nconst NON_REACTIVE_FN_MARKER = Symbol.for('fict:non-reactive-fn')\nconst REACTIVE_FN_MARKER = Symbol.for('fict:reactive-fn')\nconst NON_REACTIVE_FN_REGISTRY_KEY = Symbol.for('fict:non-reactive-fn-registry')\nconst propGetters = new WeakSet<(...args: unknown[]) => unknown>()\nconst rawToProxy = new WeakMap<object, object>()\nconst proxyToRaw = new WeakMap<object, object>()\n\ntype NonReactiveRegistryHost = typeof globalThis & {\n [NON_REACTIVE_FN_REGISTRY_KEY]?: WeakSet<(...args: unknown[]) => unknown>\n}\n\nfunction getNonReactiveFnRegistry(): WeakSet<(...args: unknown[]) => unknown> {\n const host = globalThis as NonReactiveRegistryHost\n let registry = host[NON_REACTIVE_FN_REGISTRY_KEY]\n if (!registry) {\n registry = new WeakSet<(...args: unknown[]) => unknown>()\n host[NON_REACTIVE_FN_REGISTRY_KEY] = registry\n }\n return registry\n}\n\n/**\n * @internal\n * Marks a zero-arg getter so props proxy can lazily evaluate it.\n * Users normally never call this directly; the compiler injects it.\n */\nexport function __fictProp<T>(getter: () => T): () => T {\n if (typeof getter === 'function' && getter.length === 0) {\n propGetters.add(getter)\n if (Object.isExtensible(getter)) {\n try {\n ;(getter as (() => T) & { [PROP_GETTER_MARKER]?: boolean })[PROP_GETTER_MARKER] = true\n } catch {\n // Ignore marker failures on non-standard function objects.\n }\n }\n }\n return getter\n}\n\nfunction isPropGetter(value: unknown): value is () => unknown {\n if (typeof value !== 'function') return false\n const fn = value as (() => unknown) & { [PROP_GETTER_MARKER]?: boolean }\n return propGetters.has(fn as (...args: unknown[]) => unknown) || fn[PROP_GETTER_MARKER] === true\n}\n\nfunction isNonReactiveFn(value: unknown): boolean {\n if (typeof value !== 'function') return false\n if (getNonReactiveFnRegistry().has(value as (...args: unknown[]) => unknown)) return true\n return (\n (value as ((...args: unknown[]) => unknown) & { [NON_REACTIVE_FN_MARKER]?: boolean })[\n NON_REACTIVE_FN_MARKER\n ] === true\n )\n}\n\nfunction markNonReactiveFn<T extends (...args: unknown[]) => unknown>(fn: T): T {\n getNonReactiveFnRegistry().add(fn as (...args: unknown[]) => unknown)\n if (Object.isExtensible(fn)) {\n try {\n ;(fn as T & { [NON_REACTIVE_FN_MARKER]?: boolean })[NON_REACTIVE_FN_MARKER] = true\n } catch {\n // Ignore marker failures on non-standard function objects.\n }\n }\n return fn\n}\n\nfunction isExplicitReactiveFn(value: unknown): boolean {\n if (typeof value !== 'function') return false\n return (\n (value as ((...args: unknown[]) => unknown) & { [REACTIVE_FN_MARKER]?: boolean })[\n REACTIVE_FN_MARKER\n ] === true\n )\n}\n\nfunction normalizePropsFunction(value: unknown): unknown {\n if (typeof value !== 'function') return value\n if (value.length !== 0) return value\n if (isPropGetter(value) || isSignal(value) || isComputed(value) || isExplicitReactiveFn(value)) {\n return value\n }\n if (isEffect(value) || isEffectScope(value) || isNonReactiveFn(value)) return value\n return markNonReactiveFn(value as (...args: unknown[]) => unknown)\n}\n\nexport function createPropsProxy<T extends Record<string, unknown>>(props: T): T {\n if (!props || typeof props !== 'object') {\n return props\n }\n\n if (proxyToRaw.has(props)) {\n return props\n }\n\n const cached = rawToProxy.get(props)\n if (cached) {\n return cached as T\n }\n\n const proxy = new Proxy(props, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver)\n if (isPropGetter(value)) {\n return value()\n }\n return normalizePropsFunction(value)\n },\n set(target, prop, value, receiver) {\n return Reflect.set(target, prop, value, receiver)\n },\n has(target, prop) {\n return prop in target\n },\n ownKeys(target) {\n return Reflect.ownKeys(target)\n },\n getOwnPropertyDescriptor(target, prop) {\n return Object.getOwnPropertyDescriptor(target, prop)\n },\n })\n\n rawToProxy.set(props, proxy)\n proxyToRaw.set(proxy, props)\n\n return proxy as T\n}\n\nexport function unwrapProps<T extends Record<string, unknown>>(props: T): T {\n if (!props || typeof props !== 'object') {\n return props\n }\n return (proxyToRaw.get(props) as T | undefined) ?? props\n}\n\n/**\n * Create a rest-like props object while preserving prop getters.\n * Excludes the specified keys from the returned object.\n */\nexport function __fictPropsRest<T extends Record<string, unknown>>(\n props: T,\n exclude: (string | number | symbol)[],\n): Record<string, unknown> {\n const raw = unwrapProps(props)\n const out: Record<string, unknown> = {}\n const excludeSet = new Set(exclude)\n\n for (const key of Reflect.ownKeys(raw)) {\n if (excludeSet.has(key)) continue\n out[key as string] = (raw as Record<string | symbol, unknown>)[key]\n }\n\n // Wrap in props proxy so getters remain lazy when accessed via rest\n return createPropsProxy(out)\n}\n\n/**\n * Merge multiple props-like objects while preserving lazy getters.\n * Later sources override earlier ones.\n *\n * Uses lazy lookup strategy - properties are only accessed when read,\n * avoiding upfront iteration of all keys.\n */\ntype MergeSource<T extends Record<string, unknown>> = T | (() => T)\n\nexport function mergeProps<T extends Record<string, unknown>>(\n ...sources: (MergeSource<T> | null | undefined)[]\n): Record<string, unknown> {\n // Filter out null/undefined sources upfront and store as concrete type\n const validSources: MergeSource<T>[] = sources.filter(\n (s): s is MergeSource<T> => s != null && (typeof s === 'object' || typeof s === 'function'),\n )\n\n if (validSources.length === 0) {\n return {}\n }\n\n if (validSources.length === 1 && typeof validSources[0] === 'object') {\n // Return source directly to preserve getter behavior (consistent with multi-source)\n return validSources[0]!\n }\n\n const resolveSource = (src: MergeSource<T>): T | undefined => {\n const value = typeof src === 'function' ? src() : src\n if (!value || typeof value !== 'object') return undefined\n return unwrapProps(value as T)\n }\n\n const hasProp = (prop: string | symbol) => {\n for (const src of validSources) {\n const raw = resolveSource(src)\n if (raw && prop in raw) {\n return true\n }\n }\n return false\n }\n\n const readProp = (prop: string | symbol) => {\n // Only return undefined if no source has this Symbol property\n // Search sources in reverse order (last wins)\n for (let i = validSources.length - 1; i >= 0; i--) {\n const src = validSources[i]!\n const raw = resolveSource(src)\n if (!raw || !(prop in raw)) continue\n\n const value = (raw as Record<string | symbol, unknown>)[prop]\n // Preserve prop getters - let child component's createPropsProxy unwrap lazily\n // Note: For Symbol properties, we still wrap in getter if source is dynamic\n if (typeof src === 'function' && !isPropGetter(value)) {\n return __fictProp(() => {\n const latest = resolveSource(src)\n if (!latest || !(prop in latest)) return undefined\n return (latest as Record<string | symbol, unknown>)[prop]\n })\n }\n return value\n }\n return undefined\n }\n\n return new Proxy({} as Record<string, unknown>, {\n get(_, prop) {\n return readProp(prop)\n },\n\n has(_, prop) {\n return hasProp(prop)\n },\n\n ownKeys() {\n const keys = new Set<string | symbol>()\n for (const src of validSources) {\n const raw = resolveSource(src)\n if (raw) {\n for (const key of Reflect.ownKeys(raw)) {\n keys.add(key)\n }\n }\n }\n return Array.from(keys)\n },\n\n getOwnPropertyDescriptor(_, prop) {\n if (!hasProp(prop)) return undefined\n return {\n enumerable: true,\n configurable: true,\n get: () => readProp(prop),\n }\n },\n })\n}\n\nexport type PropGetter<T> = (() => T) & { __fictProp: true }\n\nexport interface PropOptions {\n unwrap?: boolean\n}\n\n/**\n * Create a keyed prop getter that tracks both the key and the target access.\n * Useful for dynamic property access like obj[key] where key is reactive.\n */\nexport function keyed<T, K extends string | number | symbol>(\n target: T | PropGetter<T>,\n key: K | (() => K),\n options?: PropOptions,\n): PropGetter<unknown> {\n return prop(() => {\n const resolvedTarget = isPropGetter(target) ? (target as () => T)() : target\n const resolvedKey = typeof key === 'function' ? (key as () => K)() : key\n return (resolvedTarget as Record<string | number | symbol, unknown>)[resolvedKey]\n }, options)\n}\n/**\n * Memoize a prop getter to cache expensive computations.\n * Use when prop expressions involve heavy calculations or you need lazy, reactive props.\n * Set { unwrap: false } to keep nested prop getters as values.\n *\n * @example\n * ```tsx\n * // Without prop - recomputes on every access\n * <Child data={expensiveComputation(list, filter)} />\n *\n * // With prop - cached until dependencies change, auto-unwrapped by props proxy\n * const memoizedData = prop(() => expensiveComputation(list, filter))\n * <Child data={memoizedData} />\n * ```\n */\nexport function prop<T>(getter: () => T, options?: PropOptions): PropGetter<T> {\n if (isPropGetter(getter)) {\n return getter as PropGetter<T>\n }\n // Capture getter to avoid type narrowing from isPropGetter guard\n const fn: () => T = getter\n const unwrap = options?.unwrap !== false\n // Wrap in prop so component props proxy auto-unwraps when passed down.\n return __fictProp(\n createMemo(() => {\n const value = fn()\n if (unwrap && isPropGetter(value)) {\n return (value as () => T)()\n }\n return value\n }),\n ) as PropGetter<T>\n}\n","/**\n * Fict DOM Rendering System\n *\n * This module provides DOM rendering capabilities with reactive bindings.\n * It transforms JSX virtual nodes into actual DOM elements, automatically\n * setting up reactive updates for dynamic values.\n *\n * Key Features:\n * - Reactive text content: `{count}` updates when count changes\n * - Reactive attributes: `disabled={!isValid}` updates reactively\n * - Reactive children: `{show && <Modal />}` handles conditionals\n * - List rendering: `{items.map(...)}` with efficient keyed updates\n */\n\nimport {\n createTextBinding,\n createAttributeBinding,\n createStyleBinding,\n createClassBinding,\n createChildBinding,\n bindEvent,\n isReactive,\n type MaybeReactive,\n type AttributeSetter,\n type BindingHandle,\n} from './binding'\nimport { Properties, ChildProperties, getPropAlias, SVGElements, SVGNamespace } from './constants'\nimport { getDevtoolsHook } from './devtools'\nimport { __fictPushContext, __fictPopContext, __fictGetCurrentComponentId } from './hooks'\nimport { claimNodes, isHydratingActive, withHydration } from './hydration'\nimport { Fragment } from './jsx'\nimport {\n createRootContext,\n destroyRoot,\n flushOnMount,\n handleError,\n handleSuspend,\n pushRoot,\n popRoot,\n registerRootCleanup,\n getCurrentRoot,\n onMount,\n onCleanup,\n} from './lifecycle'\nimport { createPropsProxy, unwrapProps } from './props'\nimport {\n __fictIsHydrating,\n __fictIsResumable,\n __fictRegisterScope,\n __fictEnterHydration,\n __fictExitHydration,\n} from './resume'\nimport { untrack } from './scheduler'\nimport type { DOMElement, FictNode, FictVNode, RefObject } from './types'\n\ntype NamespaceContext = 'svg' | 'mathml' | null\n\nconst SVG_NS = 'http://www.w3.org/2000/svg'\nconst MATHML_NS = 'http://www.w3.org/1998/Math/MathML'\nconst isDev =\n typeof __DEV__ !== 'undefined'\n ? __DEV__\n : typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n\nlet nextComponentId = 1\n\n// ============================================================================\n// Main Render Function\n// ============================================================================\n\n/**\n * Render a Fict view into a container element.\n *\n * @param view - A function that returns the view to render\n * @param container - The DOM container to render into\n * @returns A teardown function to unmount the view\n *\n * @example\n * ```ts\n * const unmount = render(() => <App />, document.getElementById('root')!)\n * // Later: unmount()\n * ```\n */\nexport function render(view: () => FictNode, container: HTMLElement): () => void {\n const root = createRootContext()\n const prev = pushRoot(root)\n let dom: DOMElement = undefined as unknown as DOMElement\n try {\n const output = view()\n // createElement must be called within the root context\n // so that child components register their onMount callbacks correctly\n if (__fictIsHydrating()) {\n withHydration(container, () => {\n dom = createElement(output)\n })\n } else {\n dom = createElement(output)\n }\n } finally {\n popRoot(prev)\n }\n\n if (!__fictIsHydrating()) {\n container.replaceChildren(dom)\n }\n container.setAttribute('data-fict-fine-grained', '1')\n\n flushOnMount(root)\n\n const teardown = () => {\n destroyRoot(root)\n container.innerHTML = ''\n }\n\n return teardown\n}\n\n/**\n * Hydrate a component into an existing DOM container.\n * Unlike render(), this runs the view function INSIDE the hydration context\n * so that template() can claim existing DOM nodes.\n *\n * @param view - A function that returns the view to hydrate\n * @param container - The DOM container with existing SSR content\n * @returns A teardown function to unmount the view\n */\nexport function hydrateComponent(view: () => FictNode, container: HTMLElement): () => void {\n const root = createRootContext()\n const prev = pushRoot(root)\n\n // Enable hydration flags for bindings that check __fictIsHydrating()\n __fictEnterHydration()\n\n try {\n // Run the view function INSIDE withHydration so template() can claim nodes\n withHydration(container, () => {\n view()\n })\n } finally {\n __fictExitHydration()\n popRoot(prev)\n }\n\n container.setAttribute('data-fict-fine-grained', '1')\n flushOnMount(root)\n\n const teardown = () => {\n destroyRoot(root)\n }\n\n return teardown\n}\n\n// ============================================================================\n// Element Creation\n// ============================================================================\n\n/**\n * Create a DOM element from a Fict node.\n * This is the main entry point for converting virtual nodes to real DOM.\n *\n * Supports:\n * - Native DOM nodes (passed through)\n * - Null/undefined/false (empty text node)\n * - Arrays (DocumentFragment)\n * - Strings/numbers (text nodes)\n * - Booleans (empty text node)\n * - VNodes (components or HTML elements)\n * - Reactive values (functions returning any of the above)\n */\nexport function createElement(node: FictNode): DOMElement {\n return createElementWithContext(node, null)\n}\n\nfunction resolveNamespace(tagName: string, namespace: NamespaceContext): NamespaceContext {\n if (tagName === 'svg') return 'svg'\n if (tagName === 'math') return 'mathml'\n if (namespace === 'mathml') return 'mathml'\n if (namespace === 'svg') return 'svg'\n if (isDev && SVGElements.has(tagName)) return 'svg'\n return null\n}\n\nfunction createElementWithContext(node: FictNode, namespace: NamespaceContext): DOMElement {\n // Already a DOM node - pass through\n if (node instanceof Node) {\n return node\n }\n\n // Null/undefined/false - empty placeholder\n if (node === null || node === undefined || node === false) {\n return document.createTextNode('')\n }\n\n // Reactive getter function - resolve to actual node\n if (isReactive(node)) {\n const resolved = (node as () => FictNode)()\n if (resolved === node) {\n return document.createTextNode('')\n }\n return createElementWithContext(resolved, namespace)\n }\n\n // Non-reactive function values are not valid DOM nodes.\n // Keep callback values inert instead of stringifying function source.\n if (typeof node === 'function') {\n return document.createTextNode('')\n }\n\n if (typeof node === 'object' && node !== null && !(node instanceof Node)) {\n // Handle BindingHandle (list/conditional bindings, etc)\n if ('marker' in node) {\n const handle = node as { marker: unknown; dispose?: () => void; flush?: () => void }\n // Register dispose cleanup if available\n if (typeof handle.dispose === 'function') {\n registerRootCleanup(handle.dispose)\n }\n if (typeof handle.flush === 'function') {\n const runFlush = () => handle.flush && handle.flush()\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(runFlush)\n } else {\n Promise.resolve()\n .then(runFlush)\n .catch(() => undefined)\n }\n }\n return createElement(handle.marker as FictNode)\n }\n }\n\n // Array - create fragment\n if (Array.isArray(node)) {\n const frag = document.createDocumentFragment()\n for (const child of node) {\n appendChildNode(frag, child, namespace)\n }\n return frag\n }\n\n // Primitive values - text node\n if (typeof node === 'string' || typeof node === 'number') {\n return document.createTextNode(String(node))\n }\n\n if (typeof node === 'boolean') {\n return document.createTextNode('')\n }\n\n // VNode\n const vnode = node as FictVNode\n\n // Function component\n if (typeof vnode.type === 'function') {\n const rawProps = unwrapProps(vnode.props ?? {}) as Record<string, unknown>\n const baseProps =\n vnode.key === undefined\n ? rawProps\n : new Proxy(rawProps, {\n get(target, prop, receiver) {\n if (prop === 'key') return vnode.key\n return Reflect.get(target, prop, receiver)\n },\n has(target, prop) {\n if (prop === 'key') return true\n return prop in target\n },\n ownKeys(target) {\n const keys = new Set(Reflect.ownKeys(target))\n keys.add('key')\n return Array.from(keys)\n },\n getOwnPropertyDescriptor(target, prop) {\n if (prop === 'key') {\n return { enumerable: true, configurable: true, value: vnode.key }\n }\n return Object.getOwnPropertyDescriptor(target, prop)\n },\n })\n\n const props = createPropsProxy(baseProps)\n // Create a fresh hook context for this component instance.\n // This preserves slot state across re-renders driven by __fictRender.\n const hook = isDev ? getDevtoolsHook() : undefined\n const parentId = hook ? __fictGetCurrentComponentId() : undefined\n const componentId = hook ? nextComponentId++ : undefined\n\n // Register component\n if (hook?.registerComponent && componentId !== undefined) {\n hook.registerComponent(componentId, vnode.type.name || 'Anonymous', parentId)\n }\n\n const ctx = __fictPushContext()\n if (componentId !== undefined) {\n ctx.componentId = componentId\n if (parentId !== undefined) {\n ctx.parentId = parentId\n }\n }\n\n try {\n const rendered = vnode.type(props)\n\n // Register lifecycle hooks\n if (hook && componentId !== undefined) {\n onMount(() => {\n hook.componentMount?.(componentId)\n })\n onCleanup(() => hook.componentUnmount?.(componentId))\n }\n if (__fictIsResumable() && !__fictIsHydrating()) {\n const content = createElementWithContext(rendered as FictNode, namespace)\n const host =\n namespace === 'svg'\n ? document.createElementNS(SVG_NS, 'fict-host')\n : namespace === 'mathml'\n ? document.createElementNS(MATHML_NS, 'fict-host')\n : document.createElement('fict-host')\n host.setAttribute('data-fict-host', '')\n if (namespace === null && (host as HTMLElement).style) {\n ;(host as HTMLElement).style.display = 'contents'\n }\n const meta = (vnode.type as unknown as { __fictMeta?: { id?: string; resume?: string } })\n .__fictMeta\n const typeKey = (meta?.id ?? vnode.type.name) || 'Anonymous'\n __fictRegisterScope(ctx, host, typeKey, rawProps)\n if (meta?.resume) {\n host.setAttribute('data-fict-h', meta.resume)\n }\n if (content instanceof DocumentFragment) {\n host.append(...Array.from(content.childNodes))\n } else {\n host.appendChild(content)\n }\n return host as DOMElement\n }\n\n return createElementWithContext(rendered as FictNode, namespace)\n } catch (err) {\n if (handleSuspend(err as any)) {\n return document.createComment('fict:suspend')\n }\n handleError(err, { source: 'render', componentName: vnode.type.name })\n throw err\n } finally {\n __fictPopContext()\n }\n }\n\n // Fragment\n if (vnode.type === Fragment) {\n const frag = document.createDocumentFragment()\n const children = vnode.props?.children as FictNode | FictNode[] | undefined\n appendChildren(frag, children, namespace)\n return frag\n }\n\n // HTML Element\n const tagName = typeof vnode.type === 'string' ? vnode.type : 'div'\n const resolvedNamespace = resolveNamespace(tagName, namespace)\n const el =\n resolvedNamespace === 'svg'\n ? document.createElementNS(SVG_NS, tagName)\n : resolvedNamespace === 'mathml'\n ? document.createElementNS(MATHML_NS, tagName)\n : document.createElement(tagName)\n applyProps(el, vnode.props ?? {}, resolvedNamespace === 'svg')\n appendChildren(\n el as unknown as ParentNode & Node,\n vnode.props?.children as FictNode | FictNode[] | undefined,\n tagName === 'foreignObject' ? null : resolvedNamespace,\n )\n return el as DOMElement\n}\n\n/**\n * Create a template cloning factory from an HTML string.\n * Used by the compiler for efficient DOM generation.\n *\n * @param html - The HTML string to create a template from\n * @param isImportNode - Use importNode for elements like img/iframe\n * @param isSVG - Whether the template is SVG content\n * @param isMathML - Whether the template is MathML content\n */\nexport function template(\n html: string,\n isImportNode?: boolean,\n isSVG?: boolean,\n isMathML?: boolean,\n): () => Node {\n let node: Node | null = null\n\n const create = (): Node => {\n const t = document.createElement('template')\n\n if (isSVG) {\n // fix: Wrap HTML in <svg> to parse content in SVG namespace\n // Then extract the actual content (firstChild of the wrapper svg)\n t.innerHTML = `<svg>${html}</svg>`\n const wrapper = (t as HTMLTemplateElement).content.firstChild!\n // Dev check for multi-root SVG templates\n if (isDev && wrapper.childNodes.length !== 1) {\n console.warn(\n `[fict] template() received multi-root SVG content (${wrapper.childNodes.length} nodes). ` +\n `Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`,\n )\n }\n if (wrapper.childNodes.length === 1) {\n return wrapper.firstChild!\n }\n // Preserve all root nodes by returning a fragment\n const fragment = document.createDocumentFragment()\n fragment.append(...Array.from(wrapper.childNodes))\n return fragment\n }\n if (isMathML) {\n // fix: Wrap HTML in <math> to parse content in MathML namespace\n // Then extract the actual content (firstChild of the wrapper math)\n t.innerHTML = `<math>${html}</math>`\n const wrapper = (t as HTMLTemplateElement).content.firstChild!\n // Dev check for multi-root MathML templates\n if (isDev && wrapper.childNodes.length !== 1) {\n console.warn(\n `[fict] template() received multi-root MathML content (${wrapper.childNodes.length} nodes). ` +\n `Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`,\n )\n }\n if (wrapper.childNodes.length === 1) {\n return wrapper.firstChild!\n }\n // Preserve all root nodes by returning a fragment\n const fragment = document.createDocumentFragment()\n fragment.append(...Array.from(wrapper.childNodes))\n return fragment\n }\n\n t.innerHTML = html\n const content = (t as HTMLTemplateElement).content\n // Dev check for multi-root templates\n if (isDev && content.childNodes.length !== 1) {\n console.warn(\n `[fict] template() received multi-root content (${content.childNodes.length} nodes). ` +\n `Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`,\n )\n }\n if (content.childNodes.length === 1) {\n return content.firstChild!\n }\n // Preserve all root nodes by returning a fragment\n return content\n }\n\n // Create the cloning function\n const fn = isImportNode\n ? () =>\n untrack(() => {\n const base = node || (node = create())\n return isHydratingActive()\n ? claimNodes(base, () => document.importNode(base, true))\n : document.importNode(base, true)\n })\n : () => {\n const base = node || (node = create())\n return isHydratingActive()\n ? claimNodes(base, () => base.cloneNode(true))\n : base.cloneNode(true)\n }\n\n // Add cloneNode property for compatibility\n ;(fn as { cloneNode?: typeof fn }).cloneNode = fn\n\n return fn\n}\n\n// ============================================================================\n// Child Node Handling\n// ============================================================================\n\n// Use the comprehensive Properties set from constants for property binding\n// These properties must update via DOM property semantics rather than attributes\n\n/**\n * Check if a value is a runtime binding handle\n */\nfunction isBindingHandle(node: unknown): node is BindingHandle {\n return (\n node !== null &&\n typeof node === 'object' &&\n 'marker' in node &&\n 'dispose' in node &&\n typeof (node as BindingHandle).dispose === 'function'\n )\n}\n\n/**\n * Append a child node to a parent, handling all node types including reactive values.\n */\nfunction appendChildNode(\n parent: ParentNode & Node,\n child: FictNode,\n namespace: NamespaceContext,\n): void {\n // Skip nullish values\n if (child === null || child === undefined || child === false) {\n return\n }\n\n // Handle BindingHandle (recursive)\n if (isBindingHandle(child)) {\n appendChildNode(parent, child.marker, namespace)\n // Flush pending nodes now that markers are in the DOM\n child.flush?.()\n return\n }\n\n // Handle function children:\n // - reactive accessors (signals/computed/getters) become child bindings\n // - non-reactive callbacks stay inert\n if (typeof child === 'function') {\n const childGetter = child as () => FictNode\n if (isReactive(childGetter)) {\n createChildBinding(parent, childGetter, node => createElementWithContext(node, namespace))\n return\n }\n return\n }\n\n // Static child - create element and append\n if (Array.isArray(child)) {\n for (const item of child) {\n appendChildNode(parent, item, namespace)\n }\n return\n }\n\n // Cast to Node for remaining logic\n let domNode: Node\n if (typeof child !== 'object' || child === null) {\n domNode = document.createTextNode(String(child ?? ''))\n } else {\n domNode = createElementWithContext(child as any, namespace) as Node\n }\n\n // Handle DocumentFragment manually to avoid JSDOM issues\n if (domNode.nodeType === 11) {\n const children = Array.from(domNode.childNodes)\n for (const node of children) {\n appendChildNode(parent, node as FictNode, namespace)\n }\n return\n }\n\n if (domNode.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {\n parent.ownerDocument.adoptNode(domNode)\n }\n\n try {\n parent.appendChild(domNode)\n } catch (e: any) {\n if (parent.ownerDocument) {\n const clone = parent.ownerDocument.importNode(domNode, true)\n parent.appendChild(clone)\n return\n }\n throw e\n }\n}\n\n/**\n * Append multiple children, handling arrays and nested structures.\n */\nfunction appendChildren(\n parent: ParentNode & Node,\n children: FictNode | FictNode[] | undefined,\n namespace: NamespaceContext,\n): void {\n if (children === undefined) return\n\n if (Array.isArray(children)) {\n for (const child of children) {\n appendChildren(parent, child, namespace)\n }\n return\n }\n\n appendChildNode(parent, children, namespace)\n}\n\n// ============================================================================\n// Ref Handling\n// ============================================================================\n\n/**\n * Apply a ref to an element, supporting both callback and object refs.\n * Both types are automatically cleaned up on unmount.\n */\nfunction applyRef(el: Element, value: unknown): void {\n if (typeof value === 'function') {\n // Callback ref\n const refFn = value as (el: Element | null) => void\n refFn(el)\n\n // Match React behavior: call ref(null) on unmount\n const root = getCurrentRoot()\n if (root) {\n registerRootCleanup(() => {\n refFn(null)\n })\n } else if (isDev) {\n console.warn(\n '[fict] Ref applied outside of a root context. ' +\n 'The ref cleanup (setting to null) will not run automatically. ' +\n 'Consider using createRoot() or ensure the element is created within a component.',\n )\n }\n } else if (value && typeof value === 'object' && 'current' in value) {\n // Object ref\n const refObj = value as RefObject<Element>\n refObj.current = el\n\n // Auto-cleanup on unmount\n const root = getCurrentRoot()\n if (root) {\n registerRootCleanup(() => {\n refObj.current = null\n })\n } else if (isDev) {\n console.warn(\n '[fict] Ref applied outside of a root context. ' +\n 'The ref cleanup (setting to null) will not run automatically. ' +\n 'Consider using createRoot() or ensure the element is created within a component.',\n )\n }\n }\n}\n\n// ============================================================================\n// Props Handling\n// ============================================================================\n\n/**\n * Apply props to an HTML element, setting up reactive bindings as needed.\n * Uses comprehensive property constants for correct attribute/property handling.\n */\nfunction applyProps(el: Element, props: Record<string, unknown>, isSVG = false): void {\n props = unwrapProps(props)\n const tagName = el.tagName\n\n // Check if this is a custom element\n const isCE = tagName.includes('-') || 'is' in props\n\n for (const [key, value] of Object.entries(props)) {\n if (key === 'children') continue\n\n // Ref handling\n if (key === 'ref') {\n applyRef(el, value)\n continue\n }\n\n // Event handling with delegation support\n if (isEventKey(key)) {\n bindEvent(\n el,\n eventNameFromProp(key),\n value as MaybeReactive<EventListenerOrEventListenerObject | null | undefined>,\n )\n continue\n }\n\n // Explicit on: namespace for non-delegated events\n if (key.slice(0, 3) === 'on:') {\n bindEvent(\n el,\n key.slice(3),\n value as MaybeReactive<EventListenerOrEventListenerObject | null | undefined>,\n false, // Non-delegated\n )\n continue\n }\n\n // Capture events\n if (key.slice(0, 10) === 'oncapture:') {\n bindEvent(\n el,\n key.slice(10),\n value as MaybeReactive<EventListenerOrEventListenerObject | null | undefined>,\n true, // Capture\n )\n continue\n }\n\n // Class/ClassName\n if (key === 'class' || key === 'className') {\n createClassBinding(el, value as MaybeReactive<string | Record<string, boolean> | null>)\n continue\n }\n\n // classList for object-style class binding\n if (key === 'classList') {\n createClassBinding(el, value as MaybeReactive<Record<string, boolean> | null>)\n continue\n }\n\n // Style\n if (key === 'style') {\n createStyleBinding(\n el,\n value as MaybeReactive<string | Record<string, string | number> | null>,\n )\n continue\n }\n\n // dangerouslySetInnerHTML\n if (key === 'dangerouslySetInnerHTML' && value && typeof value === 'object') {\n const htmlValue = (value as { __html?: string }).__html\n if (htmlValue !== undefined) {\n if (isReactive(htmlValue)) {\n createAttributeBinding(el, 'innerHTML', htmlValue as () => unknown, setInnerHTML)\n } else {\n el.innerHTML = htmlValue\n }\n }\n continue\n }\n\n // Child properties (innerHTML, textContent, etc.)\n if (\n (isDev && ChildProperties.has(key)) ||\n key === 'innerHTML' ||\n key === 'textContent' ||\n key === 'innerText' ||\n key === 'children'\n ) {\n createAttributeBinding(el, key, value as MaybeReactive<unknown>, setProperty)\n continue\n }\n\n // Forced attribute via attr: prefix\n if (key.slice(0, 5) === 'attr:') {\n createAttributeBinding(el, key.slice(5), value as MaybeReactive<unknown>, setAttribute)\n continue\n }\n\n // Forced boolean attribute via bool: prefix\n if (key.slice(0, 5) === 'bool:') {\n createAttributeBinding(el, key.slice(5), value as MaybeReactive<unknown>, setBoolAttribute)\n continue\n }\n\n // Forced property via prop: prefix\n if (key.slice(0, 5) === 'prop:') {\n createAttributeBinding(el, key.slice(5), value as MaybeReactive<unknown>, setProperty)\n continue\n }\n\n // Check for property alias (element-specific mappings)\n const propAlias = !isSVG && isDev ? getPropAlias(key, tagName) : undefined\n const isProperty = !isSVG\n ? isDev\n ? Properties.has(key)\n : key in (el as unknown as Record<string, unknown>)\n : false\n\n // Handle properties and element-specific attributes\n if (propAlias || isProperty || (isCE && !isSVG)) {\n const propName = propAlias || key\n // Custom elements use toPropertyName conversion\n if (isCE && !isProperty && !propAlias) {\n createAttributeBinding(\n el,\n toPropertyName(propName),\n value as MaybeReactive<unknown>,\n setProperty,\n )\n } else {\n createAttributeBinding(el, propName, value as MaybeReactive<unknown>, setProperty)\n }\n continue\n }\n\n // SVG namespaced attributes (xlink:href, xml:lang, etc.)\n if (isSVG && key.indexOf(':') > -1) {\n const [prefix, name] = key.split(':')\n const ns = SVGNamespace[prefix!]\n if (ns) {\n createAttributeBinding(el, key, value as MaybeReactive<unknown>, (el, _key, val) =>\n setAttributeNS(el, ns, name!, val),\n )\n continue\n }\n }\n\n // Regular attributes (potentially reactive)\n // Apply alias mapping (className -> class, htmlFor -> for)\n const attrName = key === 'htmlFor' ? 'for' : key\n createAttributeBinding(el, attrName, value as MaybeReactive<unknown>, setAttribute)\n }\n}\n\n/**\n * Convert kebab-case to camelCase for custom element properties\n */\nfunction toPropertyName(name: string): string {\n return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase())\n}\n\n// ============================================================================\n// Attribute Setters\n// ============================================================================\n\n/**\n * Set an attribute on an element, handling various value types.\n */\nconst setAttribute: AttributeSetter = (el: Element, key: string, value: unknown): void => {\n // Remove attribute for nullish/false values\n if (value === undefined || value === null || value === false) {\n el.removeAttribute(key)\n return\n }\n\n // Boolean true -> empty string attribute\n if (value === true) {\n el.setAttribute(key, '')\n return\n }\n\n // Primitive values\n const valueType = typeof value\n if (valueType === 'string' || valueType === 'number') {\n el.setAttribute(key, String(value))\n return\n }\n\n // DOM property (for cases like `value`, `checked`, etc.)\n if (key in el) {\n ;(el as unknown as Record<string, unknown>)[key] = value\n return\n }\n\n // Fallback: set as attribute\n el.setAttribute(key, String(value))\n}\n\n/**\n * Set a property on an element, ensuring nullish values clear sensibly.\n */\nconst setProperty: AttributeSetter = (el: Element, key: string, value: unknown): void => {\n if (value === undefined || value === null) {\n const fallback = key === 'checked' || key === 'selected' ? false : ''\n ;(el as unknown as Record<string, unknown>)[key] = fallback\n return\n }\n\n // Handle style object binding style={{ color: 'red' }}\n if (key === 'style' && typeof value === 'object' && value !== null) {\n for (const k in value as Record<string, string>) {\n const v = (value as Record<string, string>)[k]\n if (v !== undefined) {\n ;((el as HTMLElement).style as unknown as Record<string, string>)[k] = String(v)\n }\n }\n return\n }\n\n ;(el as unknown as Record<string, unknown>)[key] = value as unknown\n}\n\n/**\n * Set innerHTML on an element (used for dangerouslySetInnerHTML)\n */\nconst setInnerHTML: AttributeSetter = (el: Element, _key: string, value: unknown): void => {\n const next = value == null ? '' : String(value)\n const node = el as HTMLElement\n if (node.innerHTML === next) return\n node.innerHTML = next\n}\n\n/**\n * Set a boolean attribute on an element (empty string when true, removed when false)\n */\nconst setBoolAttribute: AttributeSetter = (el: Element, key: string, value: unknown): void => {\n if (value) {\n el.setAttribute(key, '')\n } else {\n el.removeAttribute(key)\n }\n}\n\n/**\n * Set an attribute with a namespace (for SVG xlink:href, etc.)\n */\nfunction setAttributeNS(el: Element, namespace: string, name: string, value: unknown): void {\n if (value == null) {\n el.removeAttributeNS(namespace, name)\n } else {\n el.setAttributeNS(namespace, name, String(value))\n }\n}\n\n// ============================================================================\n// Event Handling Utilities\n// ============================================================================\n\n/**\n * Check if a prop key is an event handler (starts with \"on\")\n */\nfunction isEventKey(key: string): boolean {\n return key.startsWith('on') && key.length > 2 && key[2]!.toUpperCase() === key[2]\n}\n\n/**\n * Convert a React-style event prop to a DOM event name\n * e.g., \"onClick\" -> \"click\", \"onMouseDown\" -> \"mousedown\"\n */\nfunction eventNameFromProp(key: string): string {\n return key.slice(2).toLowerCase()\n}\n\n// ============================================================================\n// Exports for Advanced Usage\n// ============================================================================\n\nexport {\n createTextBinding,\n createChildBinding,\n createAttributeBinding,\n createStyleBinding,\n createClassBinding,\n isReactive,\n}\n\nexport type { BindingHandle, MaybeReactive }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,WAAW,OAAO,UAAU;;;ACOlC,SAAS,YAAY,MAAuC;AACjE,MAAI;AACF,QAAI,MAAM,QAAQ,IAAI,GAAG;AAEvB,UAAI,WAAW;AACf,iBAAW,QAAQ,MAAM;AACvB,YAAI,aAAa;AACjB,YAAI;AACF,uBAAa,gBA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ACrD;AAKA,IAAM,eAAgC,CAAC,IAAa,MAAc,UAAyB;AACzF,QAAM,OAAO,SAAS,OAAO,KAAK,OAAO,KAAK;AAC9C,QAAM,OAAO;AACb,MAAI,KAAK,cAAc,KAAM;AAC7B,OAAK,YAAY;AACnB;AAKA,IAAM,mBAAoC,CAAC,IAAa,KAAa,UAAyB;AAC5F,MAAI,OAAO;AACT,OAAG,aAAa,KAAK,EAAE;AAAA,EACzB,OAAO;AACL,OAAG,gBAAgB,GAAG;AAAA,EACxB;AACF;AAKA,SAAS,eAAe,IAAa,WAAmB,MAAc,OAAsB;AAC1F,MAAI,SAAS,MAAM;AACjB,OAAG,kBAAkB,WAAW,IAAI;AAAA,EACtC,OAAO;AACL,OAAG,eAAe,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,EAClD;AACF;AASA,SAAS,WAAW,KAAsB;AACxC,SAAO,IAAI,WAAW,IAAI,KAAK,IAAI,SAAS,KAAK,IAAI,CAAC,EAAG,YAAY,MAAM,IAAI,CAAC;AAClF;AAMA,SAAS,kBAAkB,KAAqB;AAC9C,SAAO,IAAI,MAAM,CAAC,EAAE,YAAY;AAClC;","names":["batch","untrack","prop","batch","applyRef","cleanup","render","root","prev","handledError","PROP_GETTER_MARKER","NON_REACTIVE_FN_MARKER","REACTIVE_FN_MARKER","NON_REACTIVE_FN_REGISTRY_KEY","getNonReactiveFnRegistry","isNonReactiveFn","isExplicitReactiveFn","prop","unwrap","isDev","prop","untrack","toPropertyName","el"]}