@shadow-js/core 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reactivity/scheduler.ts","../src/reactivity/hooks/useStore.ts","../src/reactivity/hooks/useData.ts","../src/reactivity/hooks/useId.ts","../src/reactivity/hooks/useMemo.ts","../src/reactivity/hooks/useOptimistic.ts","../src/reactivity/hooks/onMount.ts","../src/runtime/For.ts","../src/runtime/Show.ts","../src/runtime/Title.ts","../src/runtime/lazy.ts","../src/runtime/Portal.ts","../src/runtime/Suspense.ts","../src/runtime/ErrorBoundary.ts","../src/runtime/render.ts","../src/runtime/createElement.ts"],"names":["toNode","render"],"mappings":";;;;AAuBA,IAAI,OAAA,GAAU,KAAA;AAMd,IAAM,KAAA,uBAAY,GAAA,EAAgB;AAalC,SAAS,KAAA,GAAQ;AACf,EAAA,OAAA,GAAU,KAAA;AACV,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,CAAK,KAAK,CAAA;AAC9B,EAAA,KAAA,CAAM,KAAA,EAAM;AACZ,EAAA,KAAA,MAAW,MAAM,KAAA,EAAO;AACtB,IAAA,IAAI;AACF,MAAA,EAAA,EAAG;AAAA,IACL,CAAA,CAAA,MAAQ;AAAA,IAIR;AAAA,EACF;AACF;AAwBO,SAAS,eAAe,EAAA,EAAgB;AAC7C,EAAA,KAAA,CAAM,IAAI,EAAE,CAAA;AACZ,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAA,GAAU,IAAA;AACV,IAAA,cAAA,CAAe,KAAK,CAAA;AAAA,EACtB;AACF;;;AC1CO,SAAS,QAAA,CACd,cACA,IAAA,EACsD;AA9CxD,EAAA,IAAA,EAAA;AAgDE,EAAA,IAAI,KAAA,GAAQ,YAAA;AAKZ,EAAA,MAAM,GAAA,GACJ,OAAO,MAAA,CAAA,IAAA,KAAgB,WAAA,GAEjB,YAOA,GAAA,GAC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AAEA,EAAA,IACE,OAAO,OAAA,KAAY,QAAA,IACnB,OAAA,KAAY,IAAA,IACZ,cAAc,OAAA,EACd;AACA,IAAA,SAAA,CAAU,YAAY,OAAe,CAAA;AAAA,EACvC,CAAA,MAAO;AACL,IAAA,MAAM,OAAO,qBAAA,EAAsB;AAAA,EACrC;AAEA,EAAA,OAAO,OAAA;AACT;;;AC/GO,SAAS,aAAA,CACd,GAAA,EACA,KAAA,EAAA,GACG,QAAA,EACM;AACT,EAAA,MAAM,UAAA,GAAa,EAAE,GAAI,KAAA,IAAS,EAAC,EAAG;AACtC,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,UAAA,CAAW,WAAW,QAAA,CAAS,MAAA,KAAW,CAAA,GAAI,QAAA,CAAS,CAAC,CAAA,GAAI,QAAA;AAAA,EAC9D;AACA,EAAA,OAAO,GAAA,CAAI,KAAK,UAAU,CAAA;AAC5B","file":"index.js","sourcesContent":["/**\n * ShadowJS Effect Scheduler\n *\n * This module provides asynchronous effect scheduling for ShadowJS's reactive system.\n * It batches and defers effect execution to optimize performance and prevent redundant updates.\n *\n * The scheduler uses microtask queuing to ensure effects run after the current synchronous\n * execution context completes, allowing multiple related changes to batch together.\n *\n * @example\n * ```typescript\n * import { scheduleEffect } from \"./scheduler\";\n *\n * // Effects are batched and run asynchronously\n * scheduleEffect(() => console.log(\"Effect 1\"));\n * scheduleEffect(() => console.log(\"Effect 2\"));\n *\n * // Both effects will run in the same microtask\n * console.log(\"Synchronous code\");\n * ```\n */\n\n// Flag to track if a flush is already scheduled\nlet pending = false;\n\n/**\n * Queue of effect functions waiting to be executed.\n * Using Set to prevent duplicate effects from being scheduled.\n */\nconst queue = new Set<() => void>();\n\n/**\n * Flush the effect queue by executing all scheduled effects.\n *\n * This function:\n * 1. Resets the pending flag\n * 2. Creates a snapshot of current queued effects\n * 3. Clears the queue to prevent infinite loops\n * 4. Executes each effect, swallowing any errors to prevent one bad effect from breaking others\n *\n * @internal\n */\nfunction flush() {\n pending = false;\n const tasks = Array.from(queue);\n queue.clear();\n for (const fn of tasks) {\n try {\n fn();\n } catch {\n // Silently swallow effect errors to prevent one bad effect\n // from breaking the entire reactive system. Effects should\n // handle their own error boundaries if needed.\n }\n }\n}\n\n/**\n * Schedule an effect to run asynchronously in the next microtask.\n *\n * Effects are batched together and executed after the current synchronous\n * execution context completes. This prevents redundant re-renders and\n * improves performance by grouping related updates.\n *\n * If multiple effects are scheduled in the same execution context,\n * they will all run together in a single microtask, ensuring consistency.\n *\n * @param fn - Effect function to execute asynchronously\n *\n * @example\n * ```typescript\n * // Effects are automatically batched\n * scheduleEffect(() => updateComponent1());\n * scheduleEffect(() => updateComponent2());\n *\n * // Both effects run together after synchronous code completes\n * doSyncWork();\n * ```\n */\nexport function scheduleEffect(fn: () => void) {\n queue.add(fn);\n if (!pending) {\n pending = true;\n queueMicrotask(flush);\n }\n}\n\n/**\n * Optional batching utility for synchronous operations.\n *\n * Currently this is a simple passthrough since ShadowJS's reactive system\n * already provides natural batching through the effect scheduling mechanism.\n * The function is provided for API compatibility and future enhancements.\n *\n * @param fn - Function to execute, potentially with batched updates\n * @returns The return value of the executed function\n *\n * @example\n * ```typescript\n * const result = batch(() => {\n * // Multiple reactive updates here will be batched automatically\n * setCount(count() + 1);\n * setName(\"Updated\");\n * return computeValue();\n * });\n * ```\n */\nexport function batch<T>(fn: () => T): T {\n // Simple batch: run fn; enqueued effects will flush in same tick anyway\n return fn();\n}\n","import { scheduleEffect } from \"../scheduler\";\nimport { __currentEffect, __currentEffectDeps } from \"./useEffect\";\n\nexport type Store<T> = {\n /**\n * Reactive getter for the store's current value.\n * Reading this within an effect subscribes that effect to changes.\n */\n (): T;\n /**\n * Direct, non-reactive access to the current value.\n */\n value: T;\n /**\n * Internal marker so we can detect Shadow stores at runtime.\n */\n __isStore: boolean;\n};\n\n/**\n * Create a reactive store.\n *\n * - Calling the returned function reads the current value and subscribes\n * the current effect (if any).\n * - Calling the setter updates the value and notifies subscribers.\n *\n * HMR (dev-only, Vite):\n * - Pass a stable `hmrKey` to preserve the store value across module updates.\n * The value is saved in `import.meta.hot.data` on dispose and restored\n * when the module re-evaluates after a hot update.\n *\n * Example:\n * const [count, setCount] = useStore(0, {\n * hmrKey: import.meta.url + \"#App.count\"\n * });\n *\n * @param initialValue Initial value of the store.\n * @param opts Optional settings.\n * - hmrKey: string key to persist the value across Vite HMR updates.\n * @returns A tuple [store, set] where:\n * - store is a callable getter (Store<T>)\n * - set is a setter (newValue: T | ((prev: T) => T)) => void\n */\nexport function useStore<T>(\n initialValue: T,\n opts?: { hmrKey?: string }\n): [Store<T>, (newValue: T | ((prev: T) => T)) => void] {\n // Current value (may be overridden by HMR restore in dev)\n let value = initialValue;\n\n // Dev-only HMR state restore/persist using Vite's hot data bucket.\n // This is a no-op in production builds.\n // Note: requires a stable hmrKey per store.\n const hot =\n typeof import.meta !== \"undefined\"\n ? (\n import.meta as {\n hot?: {\n accept?: () => void;\n dispose?: (cb: () => void) => void;\n data?: Record<string, unknown>;\n };\n }\n ).hot\n : null;\n if (opts?.hmrKey && hot?.data) {\n const bucket = (hot.data.__shadowStores ||= Object.create(null)) as Record<\n string,\n unknown\n >;\n\n if (opts.hmrKey in bucket) {\n value = bucket[opts.hmrKey] as T;\n }\n\n hot.accept?.();\n hot.dispose?.(() => {\n bucket[opts.hmrKey!] = value;\n });\n }\n\n // Effects subscribed to this store\n const subscribers = new Set<() => void>();\n\n /**\n * Read the current value and subscribe the current effect (if any).\n */\n const read = () => {\n if (__currentEffect) {\n // Register current effect as a subscriber\n subscribers.add(__currentEffect);\n }\n // Also record this store's subscriber set for cleanup purposes\n if (__currentEffectDeps) {\n __currentEffectDeps.add(subscribers);\n }\n return value;\n };\n\n /**\n * Write to the store and notify subscribers when the value changes.\n *\n * @param newValue New store value.\n */\n const write = (newValue: T | ((prev: T) => T)) => {\n value =\n typeof newValue === \"function\"\n ? (newValue as (prev: T) => T)(value)\n : newValue;\n if (value !== newValue) {\n subscribers.forEach((effect) => scheduleEffect(effect));\n }\n };\n\n // The store is a callable getter with extra properties\n const store = (() => read()) as Store<T>;\n\n // Define a non-reactive property accessor `.value`\n Object.defineProperty(store, \"value\", {\n get: read,\n set: write,\n });\n\n // Mark as a Shadow store\n (store as { __isStore: true }).__isStore = true;\n\n return [store, write];\n}\n","import { useEffect } from \"./useEffect\";\nimport { useStore } from \"./useStore\";\nimport { ERRORS } from \"../../errors\";\n\n/**\n * Return type of `useData`.\n * A reactive accessor function with extra properties.\n */\nexport type UseDataReturn<T> = {\n (): T | undefined;\n loading: () => boolean;\n error: () => unknown;\n mutate: (value: T | ((prev: T | undefined) => T)) => void;\n refetch: () => Promise<void>;\n};\n\n/**\n * A fetcher function that takes a source and returns a Promise of data.\n */\nexport type Fetcher<S, T> = (source: S) => Promise<T>;\n\n/**\n * Reactive data-fetching hook.\n *\n * @param source A static value or reactive getter providing the fetch key.\n * @param fetcher Async function to fetch data for the given source.\n * @param deps Optional reactive dependencies controlling refetching.\n * @returns A reactive accessor with `.loading`, `.error`, `.mutate`, `.refetch`.\n */\nexport function useData<S, T>(\n source: (() => S) | S,\n fetcher?: Fetcher<S, T>,\n deps?: (() => unknown)[]\n): UseDataReturn<T> {\n // Validate optional args\n if (fetcher !== undefined && typeof fetcher !== \"function\") {\n throw ERRORS.HOOK_INVALID_ARGUMENT(\"useData\", \"fetcher\", \"function\");\n }\n if (deps !== undefined) {\n if (!Array.isArray(deps) || deps.some((d) => typeof d !== \"function\")) {\n throw ERRORS.HOOK_INVALID_DEPS(\"useData\");\n }\n }\n\n const getSource =\n typeof source === \"function\" ? (source as () => S) : () => source as S;\n\n const [state, setState] = useStore<{\n data: T | undefined;\n loading: boolean;\n error: unknown;\n lastSource: S;\n initialized: boolean;\n }>({\n data: undefined,\n loading: !!fetcher,\n error: null,\n lastSource: getSource(),\n initialized: false,\n });\n\n let currentFetchId = 0;\n\n async function runFetch() {\n if (!fetcher) return;\n\n const fetchId = ++currentFetchId;\n const currentSource = getSource();\n\n setState({\n ...state(),\n loading: true,\n error: null,\n });\n\n try {\n const result = await fetcher(currentSource);\n\n if (fetchId === currentFetchId) {\n setState({\n data: result,\n loading: false,\n error: null,\n lastSource: currentSource,\n initialized: true,\n });\n }\n } catch (err) {\n if (fetchId === currentFetchId) {\n setState({\n ...state(),\n error: err,\n loading: false,\n lastSource: currentSource,\n initialized: true,\n });\n }\n }\n }\n\n // Run fetch on mount and when deps change\n useEffect(\n () => {\n runFetch();\n },\n deps || [() => getSource()]\n );\n\n // Create accessor with extra properties\n const data = (() => state().data) as UseDataReturn<T>;\n data.loading = () => state().loading;\n data.error = () => state().error;\n\n data.mutate = (value: T | ((prev: T | undefined) => T)) => {\n const newValue =\n typeof value === \"function\"\n ? (value as (prev: T | undefined) => T)(state().data)\n : value;\n\n setState({\n ...state(),\n data: newValue,\n loading: false,\n error: null,\n initialized: true,\n });\n };\n\n data.refetch = async () => {\n await runFetch();\n };\n\n return data;\n}\n","let globalIdCounter = 0;\n\n/**\n * Generates the next unique ID string.\n */\nfunction generateNextId(): string {\n globalIdCounter += 1;\n return String(globalIdCounter);\n}\n\n/**\n * Return a stable, globally unique id string for use in attributes\n * like `id` and `for`. Client-only counter-based implementation.\n *\n * @example\n * const id = useId();\n * <label for={id}>Name</label>\n * <input id={id} />\n *\n * @returns A unique id string, e.g., \"sfid-1\"\n */\nexport function useId(): string {\n const next = generateNextId();\n return `sfid-${next}`;\n}\n","import { useEffect } from \"./useEffect\";\nimport { useStore, type Store } from \"./useStore\";\nimport { ERRORS } from \"../../errors\";\n\n/**\n * Memoize a computed value reactively.\n *\n * `useMemo` creates a reactive store that automatically updates whenever the\n * computation function's dependencies change. Unlike `useEffect`, `useMemo`\n * returns a reactive value that can be used in JSX expressions.\n *\n * The memoized value is computed immediately and updates reactively based on\n * any reactive dependencies accessed during the computation.\n *\n * @param fn - Function that computes the memoized value. This function should\n * be pure and return the value to be memoized.\n * @returns A reactive store containing the memoized value. The returned store\n * can be called as a getter and will automatically update when dependencies change.\n *\n * @example\n * ```tsx\n * function ExpensiveComponent({ items }) {\n * // Memoize expensive computation\n * const sortedItems = useMemo(() => {\n * console.log(\"Sorting items...\");\n * return [...items()].sort((a, b) => a.name.localeCompare(b.name));\n * });\n *\n * return (\n * <ul>\n * <For each={sortedItems()}>\n * {(item) => <li>{item.name}</li>}\n * </For>\n * </ul>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Memoizing complex calculations\n * function StatsComponent({ data }) {\n * const average = useMemo(() => {\n * const values = data().map(item => item.value);\n * return values.reduce((sum, val) => sum + val, 0) / values.length;\n * });\n *\n * const max = useMemo(() => {\n * return Math.max(...data().map(item => item.value));\n * });\n *\n * return (\n * <div>\n * <p>Average: {average()}</p>\n * <p>Maximum: {max()}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useMemo<T>(fn: () => T): Store<T> {\n if (typeof fn !== \"function\") {\n throw ERRORS.HOOK_INVALID_ARGUMENT(\"useMemo\", \"fn\", \"function\");\n }\n\n const [get, set] = useStore<T>(fn());\n\n useEffect(() => {\n set(fn());\n });\n\n return get;\n}\n","import { useEffect } from \"./useEffect\";\nimport { useStore, type Store } from \"./useStore\";\nimport { ERRORS } from \"../../errors\";\n\ntype Reducer<State, Action> = (state: State, action: Action) => State;\n\n// Type guard to detect Shadow store\nfunction isStore<T>(value: unknown): value is Store<T> {\n return (\n typeof value === \"function\" &&\n (value as { __isStore?: boolean }).__isStore === true\n );\n}\n\n/**\n * Create an optimistic state derived from a base state (store or plain value).\n *\n * Overloads:\n * - useOptimistic(baseStoreOrValue)\n * - useOptimistic(baseStoreOrValue, reducer)\n *\n * @param base Base state as a Store<T> or a plain value.\n * @param reducer Optional reducer to compute next optimistic state from action.\n * @returns [optimisticStore, dispatchOrSet]\n */\nexport function useOptimistic<T>(\n base: Store<T>\n): [Store<T>, (nextState: T) => void];\nexport function useOptimistic<T, A>(\n base: Store<T>,\n reducer: Reducer<T, A>\n): [Store<T>, (action: A) => void];\nexport function useOptimistic<T>(base: T): [Store<T>, (nextState: T) => void];\nexport function useOptimistic<T, A>(\n base: T,\n reducer: Reducer<T, A>\n): [Store<T>, (action: A) => void];\n\nexport function useOptimistic<T, A>(\n base: T | Store<T>,\n reducer?: Reducer<T, A>\n): [Store<T>, (arg: A | T) => void] {\n if (reducer !== undefined && typeof reducer !== \"function\") {\n throw ERRORS.HOOK_INVALID_REDUCER(\"useOptimistic\");\n }\n\n const getBaseValue = () => (isStore<T>(base) ? base() : (base as T));\n const [optimistic, setOptimistic] = useStore<T>(getBaseValue());\n\n // Keep optimistic state in sync with base if base is a store\n useEffect(() => {\n if (isStore<T>(base)) {\n setOptimistic(base());\n }\n });\n\n // Update either via reducer or direct set\n const apply = (arg: A | T) => {\n if (reducer) {\n setOptimistic(reducer(optimistic(), arg as A));\n } else {\n setOptimistic(arg as T);\n }\n };\n\n return [optimistic, apply];\n}\n","import { getCurrentScope } from \"../../runtime/lifecycle\";\nimport { ERRORS } from \"../../errors\";\n\n/**\n * Run a function once when the component is first invoked.\n *\n * Note: This is synchronous and runs during component execution.\n *\n * @param fn The function to run once on mount.\n */\nexport function onMount(fn: () => void): void {\n if (typeof fn !== \"function\") {\n throw ERRORS.HOOK_INVALID_ARGUMENT(\"onMount\", \"fn\", \"function\");\n }\n if (!getCurrentScope()) {\n throw ERRORS.HOOK_OUTSIDE_COMPONENT(\"onMount\");\n }\n fn();\n}\n","import { useEffect } from \"../reactivity/hooks/useEffect\";\nimport { disposeBetween } from \"./lifecycle\";\nimport { ERRORS } from \"../errors\";\nimport { warn } from \"./shared/warn\";\nimport { isComponentThunk } from \"./shared/isComponentThunk\";\n\n/**\n * For component (each-only).\n *\n * Usage:\n * <For each={items()}>\n * {(item, i) => <li>{item.name}</li>}\n * </For>\n *\n * For automatically handles efficient updates by default, so no key property is needed.\n * Parameter names are flexible - you can use any names you want:\n * <For each={count()}>\n * {(num: string, idx: number) => <p>Item {idx}: {num}</p>}\n * </For>\n *\n * Or even simpler:\n * <For each={users()}>\n * {(u: User, i: number) => <div>{u.name}</div>}\n * </For>\n */\n\ntype ForProps<T> = {\n each: T[] | readonly T[];\n children: (item: T, index: number, ...rest: unknown[]) => unknown;\n};\n\nexport function For<T>(props: ForProps<T>) {\n // Anchor a region we can update\n const fragment = document.createDocumentFragment();\n const start = document.createComment(\"for-s\");\n const end = document.createComment(\"for-e\");\n fragment.appendChild(start);\n fragment.appendChild(end);\n\n if (typeof props.children !== \"function\") {\n throw ERRORS.FOR_CHILDREN_MUST_BE_FUNCTION();\n }\n\n // Mapping: key -> DOM block {start, end}\n const keyToBlock = new Map<string, { start: Comment; end: Comment }>();\n\n // For object identity keys\n const objectIdentityToKey = new WeakMap<object, string>();\n let objectIdentityCounter = 0;\n\n const getParent = () => start.parentNode as ParentNode | null;\n\n // Normalize any value to a Node for insertion\n const toNode = (value: unknown): Node => {\n if (value === null || value === undefined || typeof value === \"boolean\") {\n return document.createComment(\"\");\n }\n\n if (typeof value === \"function\") {\n try {\n if (isComponentThunk(value)) {\n return (value as () => Node)();\n }\n return toNode((value as () => unknown)());\n } catch {\n return document.createComment(\"error\");\n }\n }\n\n if (typeof value === \"object\" && value !== null && \"nodeType\" in value)\n return value as Node;\n\n if (Array.isArray(value)) {\n const df = document.createDocumentFragment();\n value.forEach((v) => {\n const n = toNode(v);\n if (n) df.appendChild(n);\n });\n return df;\n }\n\n return document.createTextNode(String(value));\n };\n\n // Insert content before a reference node\n const appendChild = (\n parent: ParentNode,\n child: unknown,\n before: ChildNode | null\n ) => {\n if (Array.isArray(child)) {\n child.forEach((n) => appendChild(parent, n, before));\n return;\n }\n\n if (child === null || child === undefined || typeof child === \"boolean\")\n return;\n\n if (typeof child === \"function\") {\n try {\n if (isComponentThunk(child)) {\n parent.insertBefore((child as () => Node)(), before);\n } else {\n appendChild(parent, (child as () => unknown)(), before);\n }\n } catch {\n // Silently handle component render errors in For loops\n parent.insertBefore(document.createComment(\"error\"), before);\n }\n return;\n }\n\n if (typeof child === \"object\" && child !== null && \"nodeType\" in child) {\n parent.insertBefore(child as Node, before);\n return;\n }\n\n parent.insertBefore(document.createTextNode(String(child)), before);\n };\n\n const createBlockAt = (before: ChildNode | null, content: unknown) => {\n const s = document.createComment(\"for-item-s\");\n const e = document.createComment(\"for-item-e\");\n const parent = getParent();\n if (!parent) return { start: s, end: e };\n parent.insertBefore(s, before);\n appendChild(parent, content, before);\n parent.insertBefore(e, before);\n return { start: s, end: e };\n };\n\n const removeBlock = (block: { start: Comment; end: Comment }) => {\n const parent = getParent();\n if (!parent) return;\n disposeBetween(block.start, block.end);\n parent.removeChild(block.start);\n parent.removeChild(block.end);\n };\n\n const moveBlockBefore = (\n block: { start: Comment; end: Comment },\n before: ChildNode | null\n ) => {\n const parent = getParent();\n if (!parent) return;\n if (block.start === before) return;\n const afterEnd = block.end.nextSibling;\n let node: ChildNode | null = block.start;\n while (node && node !== afterEnd) {\n const next: ChildNode | null = node.nextSibling;\n parent.insertBefore(node, before);\n node = next;\n }\n };\n\n const defaultKey = (item: unknown, index: number) => {\n if (item && typeof item === \"object\") {\n let k = objectIdentityToKey.get(item);\n if (!k) {\n k = `o:${++objectIdentityCounter}`;\n objectIdentityToKey.set(item, k);\n }\n return k;\n }\n return `v:${String(item)}@${index}`;\n };\n\n // Primary update routine computing diff and DOM ops\n const update = () => {\n const parent = getParent();\n if (!parent) return;\n\n const source =\n typeof props.each === \"function\"\n ? (props.each as () => unknown[])()\n : props.each;\n\n if (!Array.isArray(source)) {\n throw ERRORS.FOR_EACH_REQUIRES_ARRAY();\n }\n\n // Build expected keys\n const expectedKeys: string[] = [];\n for (let i = 0; i < source.length; i++) {\n expectedKeys.push(defaultKey(source[i] as T, i));\n }\n\n // Remove blocks not in the new set\n const expectedSet = new Set(expectedKeys);\n for (const [k, block] of keyToBlock.entries()) {\n if (!expectedSet.has(k)) {\n removeBlock(block);\n keyToBlock.delete(k);\n }\n }\n\n // Warn on duplicate keys\n const s = new Set(expectedKeys);\n warn(\n s.size === expectedKeys.length,\n \"<For> detected duplicate keys. This can cause incorrect reordering.\"\n );\n\n // Walk through desired order\n let cursor: ChildNode | null = start.nextSibling;\n for (let i = 0; i < source.length; i++) {\n const item = source[i]! as T;\n const key = expectedKeys[i]!;\n const existing = keyToBlock.get(key);\n\n if (existing) {\n if (existing.start !== cursor) moveBlockBefore(existing, cursor);\n cursor = existing.end.nextSibling;\n } else {\n const content = (\n props.children as (\n item: T,\n index: number,\n ...rest: unknown[]\n ) => unknown\n )(item, i);\n const block = createBlockAt(cursor, toNode(content));\n keyToBlock.set(key, block);\n cursor = block.end.nextSibling;\n }\n }\n };\n\n update();\n useEffect(update);\n\n return fragment;\n}\n","import { useEffect } from \"../reactivity/hooks/useEffect\";\nimport { disposeBetween } from \"./lifecycle\";\nimport { ERRORS } from \"../errors\";\nimport { warn } from \"./shared/warn\";\nimport { untrack } from \"../reactivity/hooks/useEffect\";\nimport { isComponentThunk } from \"./shared/isComponentThunk\";\n\ntype ShowProps = {\n when: boolean | (() => boolean);\n fallback?: unknown;\n children: unknown;\n /**\n * If true, unmount subtree when condition changes.\n * If false (default), detach and cache nodes for faster re-show.\n */\n unmount?: boolean;\n};\n\n/**\n * Conditional rendering:\n * - when is true: render children\n * - when is false: render fallback (if provided)\n * - if unmount=false, caches DOM nodes to avoid re-creating them\n */\nexport function Show(props: ShowProps) {\n if (typeof props.when !== \"boolean\" && typeof props.when !== \"function\") {\n throw ERRORS.SHOW_INVALID_WHEN();\n }\n\n warn(\n props.children !== undefined || props.fallback !== undefined,\n \"<Show> has no children or fallback; renders empty content.\"\n );\n\n const fragment = document.createDocumentFragment();\n const start = document.createComment(\"show-s\");\n const end = document.createComment(\"show-e\");\n fragment.appendChild(start);\n fragment.appendChild(end);\n\n const getParent = () => start.parentNode as ParentNode | null;\n\n const toNode = (value: unknown): Node => {\n if (typeof value === \"function\") {\n try {\n if (isComponentThunk(value)) {\n return (value as () => Node)();\n }\n return toNode((value as () => unknown)());\n } catch {\n return document.createComment(\"error\");\n }\n }\n if (value === null || value === undefined || typeof value === \"boolean\") {\n return document.createComment(\"\");\n }\n if (typeof value === \"object\" && value !== null && \"nodeType\" in value)\n return value as Node;\n if (Array.isArray(value)) {\n const df = document.createDocumentFragment();\n value.forEach((v) => df.appendChild(toNode(v)));\n return df;\n }\n return document.createTextNode(String(value));\n };\n\n const detachBetween = (): Node[] => {\n const parent = getParent();\n if (!parent) return [];\n const nodes: Node[] = [];\n let cur = start.nextSibling;\n while (cur && cur !== end) {\n const next = cur.nextSibling;\n nodes.push(cur);\n parent.removeChild(cur);\n cur = next;\n }\n return nodes;\n };\n\n const insertNodes = (nodes: Node[]) => {\n const parent = getParent();\n if (!parent) return;\n nodes.forEach((n) => parent.insertBefore(n, end));\n };\n\n const materialize = (content: unknown): Node[] => {\n const n = toNode(content);\n if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n const arr: Node[] = [];\n let c = (n as DocumentFragment).firstChild;\n while (c) {\n const next = c.nextSibling;\n arr.push(c);\n c = next;\n }\n return arr;\n }\n return [n];\n };\n\n let lastCond: boolean | null = null;\n let cachedTrueContent: Node[] | null = null;\n let cachedFalseContent: Node[] | null = null;\n\n const computeCond = (): boolean => {\n try {\n return typeof props.when === \"function\" ? props.when() : props.when;\n } catch {\n return false;\n }\n };\n\n const shouldUnmount = props.unmount === undefined ? false : !!props.unmount;\n\n const update = () => {\n const parent = getParent();\n if (!parent) return;\n\n const cond = computeCond();\n\n const mat = (c: unknown) => untrack(() => materialize(c));\n\n // First render\n if (lastCond === null) {\n lastCond = cond;\n if (cond) {\n insertNodes(mat(props.children));\n } else if (props.fallback !== undefined) {\n insertNodes(mat(props.fallback));\n }\n return;\n }\n\n if (cond === lastCond) return;\n\n if (shouldUnmount) {\n disposeBetween(start, end);\n if (cond) {\n insertNodes(mat(props.children));\n } else if (props.fallback !== undefined) {\n insertNodes(mat(props.fallback));\n }\n } else {\n // Dispose effects before detaching to prevent them from running while cached\n disposeBetween(start, end);\n const detachedNodes = detachBetween();\n // Cache the content for re-materialization\n if (lastCond) {\n cachedTrueContent = detachedNodes;\n } else if (props.fallback !== undefined) {\n cachedFalseContent = detachedNodes;\n }\n\n let toInsert: Node[] = [];\n if (cond) {\n // Re-materialize cached content to re-initialize effects\n toInsert = mat(cachedTrueContent || props.children);\n cachedTrueContent = null;\n } else if (props.fallback !== undefined) {\n // Re-materialize cached content to re-initialize effects\n toInsert = mat(cachedFalseContent || props.fallback);\n cachedFalseContent = null;\n }\n if (toInsert.length) insertNodes(toInsert);\n }\n\n lastCond = cond;\n };\n\n update();\n useEffect(update);\n\n return fragment;\n}\n","import { useEffect } from \"../reactivity/hooks/useEffect\";\nimport { onCleanup } from \"../reactivity/hooks/onCleanup\";\nimport { warn } from \"./shared/warn\";\nimport { isComponentThunk } from \"./shared/isComponentThunk\";\n\ntype TitleProps = {\n children?: unknown;\n};\n\n/**\n * <Title> updates document.title reactively based on its children.\n *\n * Examples:\n * <Title>My App</Title>\n * <Title>Count: {count()}</Title>\n *\n * Notes:\n * - Avoid passing component children; Title expects text-like content.\n * - On unmount, restores the previous title only if it was the last setter.\n */\nexport function Title(props: TitleProps) {\n const prevTitle = document.title;\n let lastSet: string | null = null;\n\n const toText = (v: unknown): string => {\n if (v == null || typeof v === \"boolean\") return \"\";\n if (typeof v === \"string\" || typeof v === \"number\") return String(v);\n\n if (typeof v === \"function\") {\n if (isComponentThunk(v)) {\n warn(\n false,\n \"<Title> children should be text; component children are ignored.\"\n );\n return \"\";\n }\n try {\n return toText(v());\n } catch {\n return \"\";\n }\n }\n\n if (Array.isArray(v)) {\n return v.map((x) => toText(x)).join(\"\");\n }\n\n if (typeof v === \"object\" && v !== null && \"nodeType\" in v) {\n try {\n return ((v as Node).textContent ?? \"\") as string;\n } catch {\n return \"\";\n }\n }\n\n return String(v);\n };\n\n useEffect(() => {\n const next = toText(props.children);\n document.title = next;\n lastSet = next;\n });\n\n onCleanup(() => {\n // Restore only if we were the last to set it (avoid clobbering newer Title)\n if (lastSet !== null && document.title === lastSet) {\n document.title = prevTitle;\n }\n });\n\n // Nothing to mount in the DOM\n return document.createDocumentFragment();\n}\n","/**\n * ShadowJS Lazy Loading System\n *\n * The lazy component enables code splitting and dynamic imports in ShadowJS applications.\n * It provides:\n * - **Code Splitting**: Load components on-demand\n * - **Caching**: Avoid re-importing already loaded modules\n * - **Error Handling**: Retry logic with configurable attempts\n * - **Suspense Integration**: Works seamlessly with Suspense boundaries\n * - **Type Safety**: Full TypeScript support with proper inference\n *\n * The lazy system works by:\n * 1. Creating placeholder fragments during loading\n * 2. Loading the module asynchronously\n * 3. Replacing the placeholder with the actual component\n * 4. Notifying Suspense boundaries when complete\n */\n\nimport { ERRORS } from \"../errors\";\nimport { disposeBetween } from \"./lifecycle\";\nimport { jsx } from \"./jsx\";\nimport { untrack } from \"../reactivity/hooks/useEffect\";\n\nfunction initInsertedTree(node: Node | null) {\n if (!node) return;\n if (node.nodeType === Node.ELEMENT_NODE) {\n (node as { __shadow_init?: () => void })?.__shadow_init?.();\n }\n if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n let c = (node as DocumentFragment).firstChild;\n while (c) {\n initInsertedTree(c);\n c = c.nextSibling;\n }\n }\n}\n\n// Internal metadata we attach to the fragment so Suspense can detect\n// a pending lazy placeholder.\ntype LazyMeta = {\n pending: boolean;\n promise: Promise<void>;\n onResolve: Set<() => void>;\n};\n\n// Cache for loaded components to avoid re-importing\nconst componentCache = new WeakMap<() => Promise<unknown>, unknown>();\n// Cache for in-flight loading promises\nconst promiseCache = new WeakMap<() => Promise<unknown>, Promise<void>>();\n\n/**\n * Creates a lazy-loaded component that loads on first use.\n *\n * The lazy function enables code splitting by creating a placeholder component\n * that loads the actual component asynchronously. Once loaded, the component\n * is cached for future use.\n *\n * Features:\n * - **Automatic caching**: Loaded components are cached to prevent re-importing\n * - **Retry logic**: Configurable retry attempts with delays\n * - **Suspense support**: Integrates with Suspense boundaries for loading states\n * - **Type safety**: Full TypeScript support with proper type inference\n * - **Error handling**: Graceful error handling with informative messages\n *\n * @param importFn - Function that returns a Promise resolving to the component module\n * @param options - Configuration options for loading behavior\n * @param options.retries - Number of retry attempts (default: 3)\n * @param options.retryDelay - Delay between retries in milliseconds (default: 1000)\n * @returns A lazy wrapper component that loads the actual component on first render\n *\n * @example\n * ```tsx\n * // Basic usage with dynamic import\n * const LazyComponent = lazy(() => import(\"./MyComponent\"));\n *\n * function App() {\n * return (\n * <div>\n * <LazyComponent />\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With Suspense for loading states\n * const LazyComponent = lazy(() => import(\"./MyComponent\"));\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <LazyComponent />\n * </Suspense>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom retry configuration\n * const LazyComponent = lazy(\n * () => import(\"./MyComponent\"),\n * { retries: 5, retryDelay: 2000 }\n * );\n * ```\n *\n * @example\n * ```tsx\n * // With TypeScript types\n * const LazyComponent = lazy<{ name: string }, JSX.Element>(\n * () => import(\"./MyComponent\")\n * );\n *\n * function App() {\n * return <LazyComponent name=\"World\" />;\n * }\n * ```\n */\n\n/**\n * Overload (permissive first): accepts any Promise loader shape.\n * This helps TypeScript inference for manual `new Promise(...)` cases.\n */\nexport function lazy(\n importFn: () => Promise<unknown>,\n options?: { retries?: number; retryDelay?: number }\n): (props?: Record<string, unknown>) => unknown;\n\n/**\n * Overload (typed): strongly typed default export that is a component fn.\n */\nexport function lazy<TProps = Record<string, unknown>, TResult = unknown>(\n importFn: () => Promise<{ default: (props: TProps) => TResult }>,\n options?: { retries?: number; retryDelay?: number }\n): (props: TProps) => TResult;\n\nexport function lazy<TProps = Record<string, unknown>, TResult = unknown>(\n importFn:\n | (() => Promise<unknown>)\n | (() => Promise<{ default: (props: TProps) => TResult }>),\n options: { retries?: number; retryDelay?: number } = {}\n): (props: TProps) => TResult {\n const { retries = 3, retryDelay = 1000 } = options;\n\n const load = async (attemptsLeft: number): Promise<void> => {\n try {\n const module = await importFn();\n\n let Component: ((props: TProps) => TResult) | unknown;\n if (\n module &&\n typeof module === \"object\" &&\n module !== null &&\n \"default\" in module &&\n module.default !== undefined\n ) {\n Component = module.default;\n } else if (module && typeof module === \"function\") {\n Component = module;\n } else {\n throw ERRORS.LAZY_INVALID_EXPORT();\n }\n\n componentCache.set(importFn as () => Promise<unknown>, Component);\n } catch (err) {\n if (attemptsLeft > 0) {\n await new Promise((r) => setTimeout(r, retryDelay));\n return load(attemptsLeft - 1);\n }\n throw ERRORS.LAZY_FAILED_AFTER_ATTEMPTS(retries, err);\n }\n };\n\n return function LazyWrapper(props?: TProps): TResult {\n // If already cached, render inside component scope via jsx()\n if (componentCache.has(importFn as () => Promise<unknown>)) {\n const C = componentCache.get(importFn as () => Promise<unknown>);\n return (typeof C === \"function\" ? jsx(C, props ?? {}) : C) as TResult;\n }\n\n // Create a placeholder region that we will fill when loaded.\n const frag = document.createDocumentFragment();\n const start = document.createComment(\"lazy-s\");\n const end = document.createComment(\"lazy-e\");\n frag.appendChild(start);\n frag.appendChild(end);\n\n // Reuse or start loading\n let p = promiseCache.get(importFn as () => Promise<unknown>);\n if (!p) {\n p = load(retries);\n promiseCache.set(importFn as () => Promise<unknown>, p);\n }\n\n // Attach metadata so Suspense can detect this as pending.\n const meta: LazyMeta = {\n pending: true,\n promise: p,\n onResolve: new Set(),\n };\n (frag as unknown as { __shadow_lazy: LazyMeta }).__shadow_lazy = meta;\n\n // When loaded, render the resolved component into our region.\n p.then(\n () => {\n meta.pending = false;\n const C = componentCache.get(importFn as () => Promise<unknown>)!;\n const parent = start.parentNode as ParentNode | null;\n if (!parent) {\n // still notify listeners, even if not in DOM\n meta.onResolve.forEach((fn) => {\n try {\n fn();\n } catch {\n // Silently handle lazy component errors\n }\n });\n return;\n }\n\n // Clear previous placeholder content in the region\n disposeBetween(start, end);\n\n // Render within a component scope via jsx()\n let node: unknown =\n typeof C === \"function\" ? jsx(C, props ?? {}) : (C as TResult);\n\n // NEW: unwrap component thunk\n if (\n typeof node === \"function\" &&\n (node as { __isComponent?: boolean }).__isComponent\n ) {\n try {\n node = node();\n } catch {\n // Silently handle component errors in lazy loading\n }\n }\n\n // Insert untracked and init subtrees\n untrack(() => {\n if (node && typeof node === \"object\" && \"nodeType\" in node) {\n parent.insertBefore(node as Node, end);\n initInsertedTree(node as Node);\n } else if (node !== null && node !== undefined) {\n parent.insertBefore(document.createTextNode(String(node)), end);\n }\n });\n\n // Notify any suspense slots waiting on this lazy fragment\n meta.onResolve.forEach((fn) => {\n try {\n fn();\n } catch {\n // Silently handle component errors in lazy loading\n }\n });\n meta.onResolve.clear();\n },\n () => {\n // error surfaced by load() already\n }\n );\n\n return frag as TResult;\n };\n}\n","import { untrack, useEffect } from \"../reactivity/hooks/useEffect\";\nimport { onCleanup } from \"../reactivity/hooks/onCleanup\";\nimport { disposeBetween } from \"./lifecycle\";\nimport { ERRORS } from \"../errors\";\n\n/**\n * Create a reactive section between two anchors already inserted\n * under a parent element.\n */\nfunction createReactiveSectionBetweenAnchors(\n anchorEnd: Comment,\n valueOrFunction: unknown\n): void {\n const anchorParent = anchorEnd.parentNode as ParentNode | null;\n if (!anchorParent) return;\n\n const startComment = document.createComment(\"p-r-s\");\n const endComment = document.createComment(\"p-r-e\");\n\n anchorParent.insertBefore(startComment, anchorEnd);\n anchorParent.insertBefore(endComment, anchorEnd);\n\n const insertBeforeEnd = (end: Comment, content: unknown) => {\n const parentNode = startComment.parentNode as ParentNode | null;\n if (!parentNode) return;\n const insert = (v: unknown) => {\n if (v === null || v === undefined || typeof v === \"boolean\") return;\n if (typeof v === \"string\" || typeof v === \"number\") {\n parentNode.insertBefore(document.createTextNode(String(v)), end);\n return;\n }\n if (Array.isArray(v)) {\n v.forEach((x) => insert(x));\n return;\n }\n if (typeof v === \"object\" && v !== null && \"nodeType\" in v) {\n parentNode.insertBefore(v as Node, end);\n return;\n }\n parentNode.insertBefore(document.createTextNode(String(v)), end);\n };\n insert(content);\n };\n\n const update = () => {\n const parentNode = startComment.parentNode as ParentNode | null;\n if (!parentNode) return;\n\n const newContent = untrack(() =>\n typeof valueOrFunction === \"function\"\n ? valueOrFunction()\n : valueOrFunction\n );\n\n disposeBetween(startComment, endComment);\n untrack(() => insertBeforeEnd(endComment, newContent));\n };\n\n update();\n useEffect(update);\n}\n\n/**\n * Portal renders its children into a different DOM container (mount).\n *\n * @param props.mount Target element to render into (required).\n * @param props.children Content to render (supports reactive functions).\n * @param props.ref Optional ref to the mount element.\n */\nexport function Portal(props: {\n mount?: Element | null;\n children?: unknown;\n ref?: (element: Element) => void | { current: Element | null };\n}) {\n const { mount, children, ref } = props || {};\n if (!mount) {\n throw ERRORS.PORTAL_MOUNT_REQUIRED();\n }\n\n // Forward ref to the mount element (not the content)\n if (ref) {\n if (typeof ref === \"function\") {\n try {\n ref(mount);\n } catch {\n // Silently handle ref callback errors in portals\n }\n } else if (ref && typeof ref === \"object\" && \"current\" in ref) {\n try {\n (ref as { current: Element | null }).current = mount;\n } catch {\n // Silently handle ref assignment errors in portals\n }\n }\n }\n\n // Anchors delimiting the portal content inside the mount\n const startAnchor = document.createComment(\"p-s\");\n const endAnchor = document.createComment(\"p-e\");\n mount.appendChild(startAnchor);\n mount.appendChild(endAnchor);\n\n if (children !== undefined) {\n createReactiveSectionBetweenAnchors(endAnchor, children);\n }\n\n // Cleanup on unmount\n onCleanup(() => {\n const parent = startAnchor.parentNode as ParentNode | null;\n if (!parent) return;\n disposeBetween(startAnchor, endAnchor);\n parent.removeChild(startAnchor);\n parent.removeChild(endAnchor);\n });\n\n // Portals return an empty fragment where they are declared\n return document.createDocumentFragment();\n}\n","import { untrack, useEffect } from \"../reactivity/hooks/useEffect\";\nimport { disposeBetween } from \"./lifecycle\";\nimport { isComponentThunk } from \"./shared/isComponentThunk\";\n\n/**\n * Narrow check for a thenable object (Promise-like).\n */\nfunction isThenable(value: unknown): value is Promise<unknown> {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"then\" in value &&\n typeof (value as { then: unknown }).then === \"function\"\n );\n}\n\n/**\n * Convert arbitrary values to a Node (DocumentFragment if array).\n */\n\nfunction toNode(value: unknown): Node | null {\n if (value === null || value === undefined) return null;\n if (isComponentThunk(value)) {\n try {\n return value();\n } catch {\n return document.createComment(\"error\");\n }\n }\n if (typeof value === \"object\" && value !== null && \"nodeType\" in value)\n return value as Node;\n if (Array.isArray(value)) {\n const df = document.createDocumentFragment();\n value.forEach((v) => {\n const n = toNode(v);\n if (n) df.appendChild(n);\n });\n return df;\n }\n if (typeof value === \"function\") {\n try {\n return toNode((value as () => unknown)());\n } catch {\n return document.createComment(\"error\");\n }\n }\n if (typeof value === \"string\" || typeof value === \"number\") {\n return document.createTextNode(String(value));\n }\n return document.createTextNode(String(value));\n}\n\n/**\n * Detect whether a DocumentFragment contains a nested Suspense marker.\n */\nfunction isSuspenseFragmentNode(node: unknown): boolean {\n if (\n !node ||\n typeof node !== \"object\" ||\n !(node as Node).nodeType ||\n (node as Node).nodeType !== Node.DOCUMENT_FRAGMENT_NODE\n )\n return false;\n const df = node as DocumentFragment;\n for (let i = 0; i < df.childNodes.length; i++) {\n const n = df.childNodes[i];\n if (\n n.nodeType === Node.COMMENT_NODE &&\n (n as Comment).textContent === \"suspense-s\"\n ) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Detect whether a node is a lazy placeholder fragment produced by lazy().\n * If so, returns its metadata (including the pending promise).\n */\nfunction getLazyMeta(node: unknown): {\n pending: boolean;\n promise: Promise<void>;\n onResolve: Set<() => void>;\n} | null {\n if (\n node &&\n typeof node === \"object\" &&\n (node as Node).nodeType === Node.DOCUMENT_FRAGMENT_NODE &&\n (node as { __shadow_lazy?: unknown }).__shadow_lazy &&\n typeof (node as { __shadow_lazy?: unknown }).__shadow_lazy === \"object\"\n ) {\n return (\n node as {\n __shadow_lazy: {\n pending: boolean;\n promise: Promise<void>;\n onResolve: Set<() => void>;\n };\n }\n ).__shadow_lazy;\n }\n return null;\n}\n\n/**\n * Suspense component - coordinates asynchronous operations with fallback UI.\n *\n * Suspense provides a way to show fallback content while waiting for async\n * operations to complete. It works with:\n * - Promises (thenables) thrown or returned by components\n * - Lazy-loaded components (via lazy() function)\n * - Nested Suspense components\n *\n * Behavior:\n * 1. Shows fallback content if any top-level child is pending\n * 2. Waits for all top-level async operations to resolve\n * 3. Reveals actual content once all top-level operations complete\n * 4. Keeps nested Suspense boundaries functional for fine-grained loading states\n * 5. Updates reactively when children change\n *\n * @param props.fallback - Content to show while waiting for async operations\n * @param props.children - Child components that may be async\n * @returns DocumentFragment containing the Suspense boundary\n *\n * @example\n * ```tsx\n * const [data, setData] = useStore(null);\n * const [loading, setLoading] = useStore(false);\n *\n * const fetchData = async () => {\n * setLoading(true);\n * const result = await fetch(\"/api/data\").then(r => r.json());\n * setData(result);\n * setLoading(false);\n * };\n *\n * function DataComponent() {\n * if (loading()) {\n * // This promise will be caught by Suspense\n * throw new Promise(resolve => {\n * if (!loading()) resolve();\n * });\n * }\n * return <div>{JSON.stringify(data())}</div>;\n * }\n *\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <DataComponent />\n * </Suspense>\n * );\n * ```\n *\n * @example Lazy loading\n * ```tsx\n * const LazyComponent = lazy(() => import(\"./MyComponent\"));\n *\n * return (\n * <Suspense fallback={<div>Loading component...</div>}>\n * <LazyComponent />\n * </Suspense>\n * );\n * ```\n */\nexport function Suspense(props: { fallback?: unknown; children?: unknown }) {\n const { fallback, children } = props || {};\n\n // Anchor region\n const fragment = document.createDocumentFragment();\n const startComment = document.createComment(\"suspense-s\");\n const endComment = document.createComment(\"suspense-e\");\n fragment.appendChild(startComment);\n fragment.appendChild(endComment);\n\n // Normalize children to array\n const childrenArray = (): unknown[] =>\n children === undefined\n ? []\n : Array.isArray(children)\n ? children\n : [children];\n\n const clearBetween = () => {\n disposeBetween(startComment, endComment);\n };\n\n // Each \"slot\" represents one child position and its async state\n type Slot = {\n isNested: boolean; // nested Suspense fragment?\n resolved: boolean; // resolved (top-level)\n node: Node | null; // resolved node (or placeholder)\n promise: Promise<unknown> | null; // in-flight promise\n reactive: (() => unknown) | null; // original reactive thunk if any\n };\n let slots: Slot[] = [];\n let anchors: { start: Comment; end: Comment }[] | null = null;\n let fallbackVisible = false;\n let stageOneCompleted = false;\n\n // Replace all content with fallback (if provided)\n const showFallback = () => {\n const parent = startComment.parentNode as ParentNode | null;\n if (!parent) return;\n clearBetween();\n if (fallback !== undefined) {\n const node = toNode(\n typeof fallback === \"function\"\n ? (fallback as () => unknown)()\n : fallback\n );\n if (node) parent.insertBefore(node, endComment);\n }\n fallbackVisible = true;\n };\n\n // Prepare slot anchors to place each child in its position\n const ensureAnchors = () => {\n if (anchors) return;\n const parent = startComment.parentNode as ParentNode | null;\n if (!parent) return;\n const arr = childrenArray();\n anchors = arr.map((_, i) => ({\n start: document.createComment(`suspense-slot-s:${i}`),\n end: document.createComment(`suspense-slot-e:${i}`),\n }));\n anchors.forEach((a) => {\n parent.insertBefore(a.start, endComment);\n parent.insertBefore(a.end, endComment);\n });\n };\n\n // Set content for one slot\n const setSlotContent = (index: number, node: Node | null) => {\n if (!anchors) return;\n const parent = startComment.parentNode as ParentNode | null;\n if (!parent) return;\n const a = anchors[index];\n if (!a) return;\n\n disposeBetween(a.start, a.end);\n if (node) parent.insertBefore(node, a.end);\n };\n\n // Reveal content (clear fallback and mount slots) only when all top-level\n // non-nested slots have resolved.\n const maybeReveal = () => {\n if (stageOneCompleted) return;\n for (let i = 0; i < slots.length; i++) {\n if (!slots[i].isNested && !slots[i].resolved) return;\n }\n // All top-level resolved\n stageOneCompleted = true;\n const parent = startComment.parentNode as ParentNode | null;\n if (!parent) return;\n if (fallbackVisible) {\n clearBetween();\n fallbackVisible = false;\n }\n ensureAnchors();\n // Set all non-nested slot contents now\n for (let i = 0; i < slots.length; i++) {\n if (!slots[i].isNested) {\n setSlotContent(i, slots[i].node);\n }\n }\n // Now reveal nested fragments (already resolved)\n for (let i = 0; i < slots.length; i++) {\n if (slots[i].isNested) {\n setSlotContent(i, slots[i].node);\n }\n }\n };\n\n // Resolve a child value (sync, async, or lazy placeholder)\n const inspectChild = (index: number, value: unknown) => {\n const finish = (resolvedValue: unknown) => {\n const node = toNode(resolvedValue);\n slots[index].resolved = true;\n slots[index].node = node;\n maybeReveal();\n };\n\n // Thenable\n if (isThenable(value)) {\n slots[index].promise = value;\n (value as Promise<unknown>).then(\n (v) => finish(v),\n () => finish(null) // treat rejection as resolved-null to avoid deadlock\n );\n return;\n }\n\n // Lazy placeholder detection: treat as pending until its promise resolves\n const meta = getLazyMeta(value);\n if (meta && meta.pending) {\n slots[index].promise = meta.promise;\n // Register a one-shot listener to mark resolution\n const onRes = () => finish(value);\n meta.onResolve.add(onRes);\n meta.promise.finally(() => {\n meta.onResolve.delete(onRes);\n });\n return;\n }\n\n // Already materialized value\n finish(value);\n };\n\n // Initial pass: inspect children and show fallback if anything is pending\n const process = () => {\n const arr = childrenArray();\n\n slots = arr.map((child) => {\n let value: unknown = child;\n let isNested = false;\n\n if (typeof child === \"function\") {\n try {\n value = (child as () => unknown)();\n } catch (err: unknown) {\n if (isThenable(err)) value = err;\n else throw err;\n }\n }\n\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"nodeType\" in value &&\n isSuspenseFragmentNode(value)\n ) {\n isNested = true;\n }\n\n return {\n isNested,\n resolved: isNested ? true : false,\n node: isNested ? (value as Node) : null,\n promise: null,\n reactive: typeof child === \"function\" ? (child as () => unknown) : null,\n } as Slot;\n });\n\n // Determine if any top-level child is pending (thenable or lazy)\n let hasPending = false;\n arr.forEach((child, index) => {\n let value: unknown = child;\n if (typeof child === \"function\") {\n try {\n value = (child as () => unknown)();\n } catch (err: unknown) {\n if (isThenable(err)) value = err;\n else throw err;\n }\n }\n const meta = getLazyMeta(value);\n if (\n (!slots[index].isNested && isThenable(value)) ||\n (!slots[index].isNested && meta && meta.pending)\n ) {\n hasPending = true;\n }\n });\n\n if (hasPending) {\n showFallback();\n }\n\n // Inspect children to wire promises and compute resolution\n arr.forEach((child, index) => {\n if (slots[index].isNested) return;\n let value: unknown = child;\n if (typeof child === \"function\") {\n try {\n value = (child as () => unknown)();\n } catch (err: unknown) {\n if (isThenable(err)) value = err;\n else throw err;\n }\n }\n inspectChild(index, value);\n });\n\n // In case there was nothing pending, reveal immediately\n maybeReveal();\n\n // Reactive updates for function children\n slots.forEach((slot, index) => {\n if (!slot.reactive) return;\n useEffect(() => {\n let v: unknown;\n try {\n v = slot.reactive!();\n } catch (err: unknown) {\n if (isThenable(err)) {\n (err as Promise<unknown>).then(() => {\n try {\n const next = slot.reactive!();\n if (isThenable(next)) {\n (next as Promise<unknown>).then((r) =>\n setSlotContent(\n index,\n untrack(() => toNode(r))\n )\n );\n } else {\n setSlotContent(\n index,\n untrack(() => toNode(next))\n );\n }\n } catch {\n // Silently handle Suspense cleanup errors\n }\n });\n return;\n } else {\n throw err;\n }\n }\n if (isThenable(v)) {\n (v as Promise<unknown>).then((r) =>\n setSlotContent(\n index,\n untrack(() => toNode(r))\n )\n );\n } else {\n setSlotContent(\n index,\n untrack(() => toNode(v))\n );\n }\n });\n });\n };\n\n // Wait until inserted before processing (so anchors have a parent)\n const checkConnected = () => {\n if (startComment.isConnected) process();\n else setTimeout(checkConnected, 0);\n };\n checkConnected();\n\n // If children is a reactive function, reprocess on change\n if (typeof children === \"function\") {\n useEffect(() => {\n if (startComment.isConnected) {\n anchors = null;\n fallbackVisible = false;\n stageOneCompleted = false;\n slots = [];\n clearBetween();\n process();\n }\n });\n }\n\n return fragment;\n}\n","import { untrack, useEffect } from \"../reactivity/hooks/useEffect\";\nimport { disposeBetween } from \"./lifecycle\";\nimport { isComponentThunk } from \"./shared/isComponentThunk\";\n\ntype ErrorBoundaryProps = {\n fallback?: unknown | ((error: unknown) => unknown);\n children?: unknown;\n onError?: (error: unknown) => void;\n};\n\n/**\n * ErrorBoundary catches synchronous rendering errors from its children\n * and renders a fallback. It also calls the optional `onError` handler.\n *\n * Note: It catches errors thrown during render of function children.\n * For async errors within Suspense/lazy, use Suspense and fallback.\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps) {\n const { fallback, children, onError } = props || {};\n\n // Anchor an empty fragment\n const fragment = document.createDocumentFragment();\n const startComment = document.createComment(\"error-boundary-s\");\n const endComment = document.createComment(\"error-boundary-e\");\n fragment.appendChild(startComment);\n fragment.appendChild(endComment);\n\n let hasError = false;\n let storedError: unknown = null;\n\n // Insert content before the end marker\n const insertNode = (node: unknown) => {\n const parent = startComment.parentNode as ParentNode | null;\n if (!parent) return;\n\n const insert = (v: unknown) => {\n if (v === null || v === undefined || typeof v === \"boolean\") return;\n if (Array.isArray(v)) {\n v.forEach((x) => insert(x));\n return;\n }\n if (typeof v === \"function\") {\n try {\n if (isComponentThunk(v)) {\n parent.insertBefore((v as () => Node)(), endComment);\n } else {\n insert((v as () => unknown)());\n }\n } catch {\n // Silently handle component render errors - they'll be caught by the error boundary\n }\n return;\n }\n if (typeof v === \"string\" || typeof v === \"number\") {\n parent.insertBefore(document.createTextNode(String(v)), endComment);\n return;\n }\n if (v && typeof v === \"object\" && \"nodeType\" in v) {\n parent.insertBefore(v as Node, endComment);\n return;\n }\n parent.insertBefore(document.createTextNode(String(v)), endComment);\n };\n\n untrack(() => insert(node));\n };\n\n // Render either the children or the fallback upon errors\n const render = () => {\n disposeBetween(startComment, endComment);\n\n if (hasError) {\n const node =\n typeof fallback === \"function\"\n ? (fallback as (error: unknown) => unknown)(storedError)\n : fallback;\n insertNode(node);\n return;\n }\n\n try {\n const content =\n typeof children === \"function\"\n ? (children as () => unknown)()\n : children;\n insertNode(content);\n } catch (error: unknown) {\n hasError = true;\n storedError = error;\n try {\n onError?.(error);\n } catch {\n // Silently handle onError callback errors to prevent infinite error loops\n }\n const node =\n typeof fallback === \"function\"\n ? (fallback as (error: unknown) => unknown)(error)\n : fallback;\n disposeBetween(startComment, endComment);\n insertNode(node);\n }\n };\n\n render();\n\n // If children is a function, re-run on reactive updates\n if (typeof children === \"function\") {\n useEffect(() => {\n if (!hasError) render();\n });\n }\n\n return fragment;\n}\n","/**\n * ShadowJS Render Function\n *\n * The render function is the entry point for mounting ShadowJS applications to the DOM.\n * It handles the initial mounting of components and manages the component lifecycle.\n *\n * Features:\n * - **Component Mounting**: Renders function components or DOM nodes\n * - **Lifecycle Management**: Properly initializes component scopes and effects\n * - **Cleanup**: Automatically disposes previous content before mounting new content\n * - **Error Handling**: Validates inputs and provides clear error messages\n * - **Component Thunk Support**: Handles lazy-loaded and async components\n */\n\nimport { disposeAllChildren } from \"./lifecycle\";\nimport { ERRORS } from \"../errors\";\nimport { jsx } from \"./jsx\";\n\n/**\n * Renders a ShadowJS component or DOM node into a container element.\n *\n * This function is the primary entry point for mounting ShadowJS applications.\n * It handles both function components (which get executed via JSX runtime) and\n * direct DOM nodes, providing a unified mounting interface.\n *\n * The render process:\n * 1. **Validation**: Ensures container is provided and valid\n * 2. **Cleanup**: Disposes any existing mounted content\n * 3. **Component Processing**: Handles function components vs DOM nodes\n * 4. **Mounting**: Appends the rendered content to the container\n * 5. **Lifecycle**: Initializes component scopes and effects\n *\n * @param component - Component to render. Can be:\n * - A function component that returns JSX\n * - A DOM Node or DocumentFragment\n * - A component thunk (from lazy loading)\n * @param container - Target DOM element to mount the component into.\n * Must be a valid Element (not a DocumentFragment).\n * @returns The mounted DOM node or the result of the component rendering.\n *\n * @throws Error if container is invalid or component returns invalid content\n *\n * @example\n * ```tsx\n * // Basic component rendering\n * function App() {\n * return <h1>Hello ShadowJS!</h1>;\n * }\n *\n * const root = document.getElementById(\"app\");\n * render(App, root!);\n * ```\n *\n * @example\n * ```tsx\n * // Rendering with props\n * function Greeting({ name }) {\n * return <h1>Hello, {name}!</h1>;\n * }\n *\n * const root = document.getElementById(\"app\");\n * render(() => <Greeting name=\"World\" />, root!);\n * ```\n *\n * @example\n * ```tsx\n * // Rendering existing DOM nodes\n * const existingElement = document.createElement(\"div\");\n * existingElement.textContent = \"Pre-rendered content\";\n *\n * const root = document.getElementById(\"app\");\n * render(existingElement, root!);\n * ```\n *\n * @example\n * ```tsx\n * // With lazy loading\n * const LazyApp = lazy(() => import(\"./App\"));\n *\n * const root = document.getElementById(\"app\");\n * render(LazyApp, root!);\n * ```\n */\nexport function render(component: unknown, container: Element) {\n if (!container) {\n throw ERRORS.RENDER_CONTAINER_REQUIRED();\n }\n\n disposeAllChildren(container as unknown as ParentNode);\n container.innerHTML = \"\";\n\n let element: unknown;\n\n if (typeof component === \"function\") {\n element = jsx(component, {});\n if (\n typeof element === \"function\" &&\n (element as { __isComponent?: boolean }).__isComponent\n ) {\n element = (element as () => Node)();\n }\n } else if (\n typeof component === \"object\" &&\n component !== null &&\n \"nodeType\" in component\n ) {\n element = component;\n } else {\n throw ERRORS.RENDER_INVALID_COMPONENT();\n }\n\n if (\n typeof element === \"object\" &&\n element !== null &&\n \"nodeType\" in element\n ) {\n container.appendChild(element as Node);\n } else {\n throw ERRORS.RENDER_INVALID_RETURN();\n }\n\n return element;\n}\n","import { jsx } from \"./jsx\";\n\n/**\n * Shadow's `createElement` function used by the JSX transform when\n * `jsxImportSource: \"@shadow-js/core\"` is set. Delegates to `jsx`.\n *\n * @param tag The tag name (e.g., \"div\") or a component function.\n * @param props Props object passed from JSX.\n * @param children Children passed by JSX variadic arguments.\n * @returns A DOM element or a MatchMarker (for <Match> in <Switch>).\n */\nexport function createElement(\n tag: unknown,\n props?: Record<string, unknown>,\n ...children: unknown[]\n): unknown {\n const finalProps = { ...(props || {}) };\n if (children.length > 0) {\n finalProps.children = children.length === 1 ? children[0] : children;\n }\n return jsx(tag, finalProps);\n}\n"]}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * ShadowJS Fragment Component
3
+ *
4
+ * Fragment is a special component that renders its children without creating
5
+ * an additional DOM wrapper element. It's useful for grouping elements together
6
+ * without affecting the DOM structure.
7
+ *
8
+ * Unlike other frameworks where fragments are just logical groupings, ShadowJS
9
+ * Fragment provides reactive section management, allowing individual children
10
+ * to be reactive without requiring wrapper elements.
11
+ *
12
+ * Key Features:
13
+ * - No DOM wrapper element
14
+ * - Individual reactive sections for each child
15
+ * - Automatic cleanup of reactive sections
16
+ * - Support for mixed static and reactive content
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * function ListComponent({ items }) {
21
+ * return (
22
+ * <Fragment>
23
+ * <h2>My Items</h2>
24
+ * <ul>
25
+ * <For each={items()}>
26
+ * {(item) => <li>{item.name}</li>}
27
+ * </For>
28
+ * </ul>
29
+ * <p>Total: {items.length}</p>
30
+ * </Fragment>
31
+ * );
32
+ * }
33
+ *
34
+ * // Renders without any wrapper div:
35
+ * // <h2>My Items</h2>
36
+ * // <ul>...</ul>
37
+ * // <p>Total: 5</p>
38
+ * ```
39
+ */
40
+ /**
41
+ * Fragment component - renders children without a wrapper element.
42
+ *
43
+ * Fragment allows you to group multiple elements together without creating
44
+ * an additional DOM node. Each child gets its own reactive section, enabling
45
+ * fine-grained updates while maintaining clean DOM output.
46
+ *
47
+ * This is particularly useful when:
48
+ * - You need to return multiple elements from a component
49
+ * - You want to avoid unnecessary wrapper divs
50
+ * - You need conditional rendering with multiple elements
51
+ * - You want to mix static and reactive content
52
+ *
53
+ * @param props.children - Child elements to render. Can be any valid JSX content,
54
+ * including other components, primitives, and reactive functions.
55
+ * @returns DocumentFragment containing the rendered children without a wrapper element
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * function Navigation({ user }) {
60
+ * return (
61
+ * <Fragment>
62
+ * <nav>
63
+ * <a href="/">Home</a>
64
+ * <a href="/about">About</a>
65
+ * </nav>
66
+ * {() => user() ? <div>Welcome, {() => user().name}!</div> : null}
67
+ * </Fragment>
68
+ * );
69
+ * }
70
+ *
71
+ * // Renders as:
72
+ * // <nav>...</nav>
73
+ * // <div>Welcome, John!</div>
74
+ * ```
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * // Using Fragment to avoid wrapper divs in lists
79
+ * function TodoList({ todos }) {
80
+ * return (
81
+ * <Fragment>
82
+ * <h2>Tasks</h2>
83
+ * <For each={todos()}>
84
+ * {(todo) => (
85
+ * <div className={todo().completed ? "done" : ""}>
86
+ * {todo().text}
87
+ * </div>
88
+ * )}
89
+ * </For>
90
+ * <p>Total: {todos().length}</p>
91
+ * </Fragment>
92
+ * );
93
+ * }
94
+ * ```
95
+ */
96
+ declare function Fragment({ children }: {
97
+ children: unknown;
98
+ }): DocumentFragment;
99
+
100
+ /**
101
+ * ShadowJS JSX Runtime
102
+ *
103
+ * This module implements the core JSX runtime for ShadowJS, providing:
104
+ * - **Intrinsic element creation**: HTML and SVG element rendering
105
+ * - **Function component execution**: Component lifecycle and scoping
106
+ * - **Reactive child sections**: Fine-grained reactivity for child content
107
+ * - **Props handling**: Attribute, style, and event management
108
+ * - **Async support**: Promise/thenable handling without uncaught rejections
109
+ *
110
+ * The runtime uses a sophisticated two-phase dependency tracking system:
111
+ * 1. **Collection Phase**: Gather dependencies without executing components
112
+ * 2. **Execution Phase**: Render content with proper reactive scoping
113
+ *
114
+ * This prevents cross-tracking issues between parent and child components
115
+ * while maintaining fine-grained reactivity throughout the component tree.
116
+ */
117
+
118
+ /**
119
+ * Core JSX function for ShadowJS.
120
+ *
121
+ * This function handles the creation of JSX elements, both intrinsic HTML/SVG elements
122
+ * and custom function components. It implements ShadowJS's unique approach to reactive
123
+ * JSX with component thunking and fine-grained reactivity.
124
+ *
125
+ * Processing Logic:
126
+ * 1. **Match Components**: Handle `<Match>` sentinels for Switch statements
127
+ * 2. **Function Components**: Create lazy component thunks for function tags
128
+ * 3. **Intrinsic Elements**: Create DOM elements for string tags
129
+ * 4. **Props Processing**: Handle attributes, events, refs, and styles
130
+ * 5. **Children Rendering**: Set up reactive sections for child content
131
+ *
132
+ * @param tag - Component tag (function component or string element name)
133
+ * @param props - Component props including children
134
+ * @returns JSX result (Element, Fragment, or ComponentThunk)
135
+ *
136
+ * @example
137
+ * ```tsx
138
+ * // Intrinsic element
139
+ * jsx("div", { className: "container", children: "Hello" })
140
+ * // → <div class="container">Hello</div>
141
+ *
142
+ * // Function component
143
+ * jsx(MyComponent, { name: "World" })
144
+ * // → ComponentThunk that renders MyComponent
145
+ * ```
146
+ */
147
+ declare const jsx: (tag: unknown, props?: Record<string, unknown>) => unknown;
148
+ declare const jsxs: (tag: unknown, props?: Record<string, unknown>) => unknown;
149
+ declare const jsxDEV: (tag: unknown, props?: Record<string, unknown>) => unknown;
150
+
151
+ export { Fragment as F, jsxs as a, jsxDEV as b, jsx as j };
@@ -0,0 +1,151 @@
1
+ /**
2
+ * ShadowJS Fragment Component
3
+ *
4
+ * Fragment is a special component that renders its children without creating
5
+ * an additional DOM wrapper element. It's useful for grouping elements together
6
+ * without affecting the DOM structure.
7
+ *
8
+ * Unlike other frameworks where fragments are just logical groupings, ShadowJS
9
+ * Fragment provides reactive section management, allowing individual children
10
+ * to be reactive without requiring wrapper elements.
11
+ *
12
+ * Key Features:
13
+ * - No DOM wrapper element
14
+ * - Individual reactive sections for each child
15
+ * - Automatic cleanup of reactive sections
16
+ * - Support for mixed static and reactive content
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * function ListComponent({ items }) {
21
+ * return (
22
+ * <Fragment>
23
+ * <h2>My Items</h2>
24
+ * <ul>
25
+ * <For each={items()}>
26
+ * {(item) => <li>{item.name}</li>}
27
+ * </For>
28
+ * </ul>
29
+ * <p>Total: {items.length}</p>
30
+ * </Fragment>
31
+ * );
32
+ * }
33
+ *
34
+ * // Renders without any wrapper div:
35
+ * // <h2>My Items</h2>
36
+ * // <ul>...</ul>
37
+ * // <p>Total: 5</p>
38
+ * ```
39
+ */
40
+ /**
41
+ * Fragment component - renders children without a wrapper element.
42
+ *
43
+ * Fragment allows you to group multiple elements together without creating
44
+ * an additional DOM node. Each child gets its own reactive section, enabling
45
+ * fine-grained updates while maintaining clean DOM output.
46
+ *
47
+ * This is particularly useful when:
48
+ * - You need to return multiple elements from a component
49
+ * - You want to avoid unnecessary wrapper divs
50
+ * - You need conditional rendering with multiple elements
51
+ * - You want to mix static and reactive content
52
+ *
53
+ * @param props.children - Child elements to render. Can be any valid JSX content,
54
+ * including other components, primitives, and reactive functions.
55
+ * @returns DocumentFragment containing the rendered children without a wrapper element
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * function Navigation({ user }) {
60
+ * return (
61
+ * <Fragment>
62
+ * <nav>
63
+ * <a href="/">Home</a>
64
+ * <a href="/about">About</a>
65
+ * </nav>
66
+ * {() => user() ? <div>Welcome, {() => user().name}!</div> : null}
67
+ * </Fragment>
68
+ * );
69
+ * }
70
+ *
71
+ * // Renders as:
72
+ * // <nav>...</nav>
73
+ * // <div>Welcome, John!</div>
74
+ * ```
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * // Using Fragment to avoid wrapper divs in lists
79
+ * function TodoList({ todos }) {
80
+ * return (
81
+ * <Fragment>
82
+ * <h2>Tasks</h2>
83
+ * <For each={todos()}>
84
+ * {(todo) => (
85
+ * <div className={todo().completed ? "done" : ""}>
86
+ * {todo().text}
87
+ * </div>
88
+ * )}
89
+ * </For>
90
+ * <p>Total: {todos().length}</p>
91
+ * </Fragment>
92
+ * );
93
+ * }
94
+ * ```
95
+ */
96
+ declare function Fragment({ children }: {
97
+ children: unknown;
98
+ }): DocumentFragment;
99
+
100
+ /**
101
+ * ShadowJS JSX Runtime
102
+ *
103
+ * This module implements the core JSX runtime for ShadowJS, providing:
104
+ * - **Intrinsic element creation**: HTML and SVG element rendering
105
+ * - **Function component execution**: Component lifecycle and scoping
106
+ * - **Reactive child sections**: Fine-grained reactivity for child content
107
+ * - **Props handling**: Attribute, style, and event management
108
+ * - **Async support**: Promise/thenable handling without uncaught rejections
109
+ *
110
+ * The runtime uses a sophisticated two-phase dependency tracking system:
111
+ * 1. **Collection Phase**: Gather dependencies without executing components
112
+ * 2. **Execution Phase**: Render content with proper reactive scoping
113
+ *
114
+ * This prevents cross-tracking issues between parent and child components
115
+ * while maintaining fine-grained reactivity throughout the component tree.
116
+ */
117
+
118
+ /**
119
+ * Core JSX function for ShadowJS.
120
+ *
121
+ * This function handles the creation of JSX elements, both intrinsic HTML/SVG elements
122
+ * and custom function components. It implements ShadowJS's unique approach to reactive
123
+ * JSX with component thunking and fine-grained reactivity.
124
+ *
125
+ * Processing Logic:
126
+ * 1. **Match Components**: Handle `<Match>` sentinels for Switch statements
127
+ * 2. **Function Components**: Create lazy component thunks for function tags
128
+ * 3. **Intrinsic Elements**: Create DOM elements for string tags
129
+ * 4. **Props Processing**: Handle attributes, events, refs, and styles
130
+ * 5. **Children Rendering**: Set up reactive sections for child content
131
+ *
132
+ * @param tag - Component tag (function component or string element name)
133
+ * @param props - Component props including children
134
+ * @returns JSX result (Element, Fragment, or ComponentThunk)
135
+ *
136
+ * @example
137
+ * ```tsx
138
+ * // Intrinsic element
139
+ * jsx("div", { className: "container", children: "Hello" })
140
+ * // → <div class="container">Hello</div>
141
+ *
142
+ * // Function component
143
+ * jsx(MyComponent, { name: "World" })
144
+ * // → ComponentThunk that renders MyComponent
145
+ * ```
146
+ */
147
+ declare const jsx: (tag: unknown, props?: Record<string, unknown>) => unknown;
148
+ declare const jsxs: (tag: unknown, props?: Record<string, unknown>) => unknown;
149
+ declare const jsxDEV: (tag: unknown, props?: Record<string, unknown>) => unknown;
150
+
151
+ export { Fragment as F, jsxs as a, jsxDEV as b, jsx as j };