semajsx 0.6.0 → 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 (76) hide show
  1. package/dist/{client-CButR91p.mjs → client-BrupjhG0.mjs} +4 -4
  2. package/dist/{client-CButR91p.mjs.map → client-BrupjhG0.mjs.map} +1 -1
  3. package/dist/{computed-BidG06Lt.mjs → computed-BpjqvQu1.mjs} +2 -2
  4. package/dist/{computed-BidG06Lt.mjs.map → computed-BpjqvQu1.mjs.map} +1 -1
  5. package/dist/document-DsiJO2jG.mjs +5 -0
  6. package/dist/{document-BOJDaiBc.mjs → document-XKyAs62C.mjs} +2 -2
  7. package/dist/{document-BOJDaiBc.mjs.map → document-XKyAs62C.mjs.map} +1 -1
  8. package/dist/dom/index.mjs +3 -3
  9. package/dist/dom/jsx-dev-runtime.d.mts +1 -1
  10. package/dist/dom/jsx-dev-runtime.mjs +2 -2
  11. package/dist/dom/jsx-runtime.d.mts +1 -1
  12. package/dist/dom/jsx-runtime.mjs +2 -2
  13. package/dist/{index-D_FIlSk3.d.mts → index-CmxkYOtR.d.mts} +2 -2
  14. package/dist/{index-D_FIlSk3.d.mts.map → index-CmxkYOtR.d.mts.map} +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/{jsx-runtime-D9ZNjMJ2.mjs → jsx-runtime-BFs1c0xz.mjs} +1 -1
  17. package/dist/jsx-runtime-BFs1c0xz.mjs.map +1 -0
  18. package/dist/{jsx-runtime-tIuFmhTh.d.mts → jsx-runtime-C-TtSL51.d.mts} +9 -4
  19. package/dist/jsx-runtime-C-TtSL51.d.mts.map +1 -0
  20. package/dist/{jsx-runtime-BjCGsceN.mjs → jsx-runtime-kv_6vBiR.mjs} +1 -1
  21. package/dist/{jsx-runtime-BjCGsceN.mjs.map → jsx-runtime-kv_6vBiR.mjs.map} +1 -1
  22. package/dist/{lucide-C5BghhSl.mjs → lucide-Ddt_N9dJ.mjs} +3 -3
  23. package/dist/{lucide-C5BghhSl.mjs.map → lucide-Ddt_N9dJ.mjs.map} +1 -1
  24. package/dist/{resource-CNwiNxJX.d.mts → resource-CX-sVeS_.d.mts} +5 -2
  25. package/dist/resource-CX-sVeS_.d.mts.map +1 -0
  26. package/dist/{resource-DSlXDZZi.mjs → resource-pm7qP-jV.mjs} +2 -2
  27. package/dist/{resource-DSlXDZZi.mjs.map → resource-pm7qP-jV.mjs.map} +1 -1
  28. package/dist/signal/index.mjs +3 -3
  29. package/dist/{signal-BN8vHXDb.mjs → signal-4PgGfydw.mjs} +1 -1
  30. package/dist/{signal-BN8vHXDb.mjs.map → signal-4PgGfydw.mjs.map} +1 -1
  31. package/dist/{src-B4VBiHa8.mjs → src-CAyv9Uf9.mjs} +24 -17
  32. package/dist/src-CAyv9Uf9.mjs.map +1 -0
  33. package/dist/{src-DUpFNNM_.mjs → src-CXY-7FC3.mjs} +4 -4
  34. package/dist/{src-DUpFNNM_.mjs.map → src-CXY-7FC3.mjs.map} +1 -1
  35. package/dist/{src-BqX3sryB.mjs → src-C_aFsFJ3.mjs} +4 -4
  36. package/dist/{src-BqX3sryB.mjs.map → src-C_aFsFJ3.mjs.map} +1 -1
  37. package/dist/{src-DW3tIczg.mjs → src-Cv4rRVzv.mjs} +4 -4
  38. package/dist/{src-DW3tIczg.mjs.map → src-Cv4rRVzv.mjs.map} +1 -1
  39. package/dist/{src-Ds9vl42d.mjs → src-DV9uwtE5.mjs} +2 -2
  40. package/dist/{src-Ds9vl42d.mjs.map → src-DV9uwtE5.mjs.map} +1 -1
  41. package/dist/{src-75qcxwT_.mjs → src-SqJ6k7Xv.mjs} +13 -29
  42. package/dist/src-SqJ6k7Xv.mjs.map +1 -0
  43. package/dist/ssg/index.d.mts +1 -1
  44. package/dist/ssg/index.d.mts.map +1 -1
  45. package/dist/ssg/index.mjs +14 -9
  46. package/dist/ssg/index.mjs.map +1 -1
  47. package/dist/ssg/plugins/docs-theme.d.mts +68 -29
  48. package/dist/ssg/plugins/docs-theme.d.mts.map +1 -1
  49. package/dist/ssg/plugins/docs-theme.mjs +2747 -380
  50. package/dist/ssg/plugins/docs-theme.mjs.map +1 -1
  51. package/dist/ssg/plugins/fonts/MAPLE_MONO_LICENSE.txt +93 -0
  52. package/dist/ssg/plugins/fonts/MapleMono-NF-CN-Regular.woff2 +0 -0
  53. package/dist/ssg/plugins/lucide.d.mts +2 -2
  54. package/dist/ssg/plugins/lucide.mjs +5 -5
  55. package/dist/ssr/client.d.mts +1 -1
  56. package/dist/ssr/client.mjs +5 -5
  57. package/dist/ssr/index.d.mts +1 -1
  58. package/dist/ssr/index.d.mts.map +1 -1
  59. package/dist/ssr/index.mjs +8 -8
  60. package/dist/style/index.mjs +1 -1
  61. package/dist/style/react.mjs +2 -2
  62. package/dist/style/vue.mjs +2 -2
  63. package/dist/terminal/index.mjs +3 -3
  64. package/dist/terminal/jsx-dev-runtime.mjs +2 -2
  65. package/dist/terminal/jsx-runtime.mjs +2 -2
  66. package/dist/{types-BmDIxXiP.d.mts → types-BaS-zTDX.d.mts} +3 -1
  67. package/dist/{types-BmDIxXiP.d.mts.map → types-BaS-zTDX.d.mts.map} +1 -1
  68. package/dist/{utils-DbTAs943.mjs → utils-BrGmTgfG.mjs} +1 -1
  69. package/dist/{utils-DbTAs943.mjs.map → utils-BrGmTgfG.mjs.map} +1 -1
  70. package/package.json +2 -2
  71. package/dist/document-CwHVG_PJ.mjs +0 -5
  72. package/dist/jsx-runtime-D9ZNjMJ2.mjs.map +0 -1
  73. package/dist/jsx-runtime-tIuFmhTh.d.mts.map +0 -1
  74. package/dist/resource-CNwiNxJX.d.mts.map +0 -1
  75. package/dist/src-75qcxwT_.mjs.map +0 -1
  76. package/dist/src-B4VBiHa8.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"src-BqX3sryB.mjs","names":[],"sources":["../../dom/src/operations.ts","../../dom/src/properties.ts","../../dom/src/render.ts","../../dom/src/portal.ts","../../dom/src/forward.ts","../../dom/src/style-anchor.ts","../../dom/src/native.ts"],"sourcesContent":["/**\n * Low-level DOM operations\n */\n\nexport function createElement(tagName: string): Element {\n return document.createElement(tagName);\n}\n\nexport function createTextNode(text: string): Text {\n return document.createTextNode(text);\n}\n\nexport function createComment(text: string): Comment {\n return document.createComment(text);\n}\n\nexport function appendChild(parent: Node, child: Node): void {\n parent.appendChild(child);\n}\n\nexport function removeChild(node: Node): void {\n node.parentNode?.removeChild(node);\n}\n\nexport function insertBefore(parent: Node, newNode: Node, refNode: Node | null): void {\n parent.insertBefore(newNode, refNode);\n}\n\nexport function replaceNode(oldNode: Node, newNode: Node): void {\n oldNode.parentNode?.replaceChild(newNode, oldNode);\n}\n\nexport function setText(node: Node, text: string): void {\n node.textContent = text;\n}\n\nexport function getParent(node: Node): Node | null {\n return node.parentNode;\n}\n\nexport function getNextSibling(node: Node): Node | null {\n return node.nextSibling;\n}\n","import type { Signal } from \"@semajsx/signal\";\nimport type { Ref } from \"@semajsx/core\";\nimport { isSignal } from \"@semajsx/signal\";\nimport { isStyleToken, inject, type StyleToken } from \"@semajsx/style\";\n\n/**\n * Class value type - can be string, StyleToken, array, or falsy\n */\ntype ClassValue = string | StyleToken | ClassValue[] | false | null | undefined;\n\n/**\n * Resolve a class value to a string\n *\n * Supports:\n * - Strings: returned as-is\n * - StyleTokens: injects CSS and returns className\n * - Arrays: recursively resolves all values\n * - Falsy values: filtered out\n *\n * @example\n * resolveClass(\"btn\") // \"btn\"\n * resolveClass(button.root) // \"root-x7f3a\" (injects CSS)\n * resolveClass([button.root, \"custom\", isLarge && button.large]) // \"root-x7f3a custom large-y8g4b\"\n */\nfunction resolveClass(value: ClassValue): string {\n if (!value) {\n return \"\";\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (isStyleToken(value)) {\n // Inject CSS for the token\n inject(value);\n // Return the className (or empty string if none)\n return value._ ?? \"\";\n }\n\n if (Array.isArray(value)) {\n // Recursively resolve array values, filter empty strings\n return value.map(resolveClass).filter(Boolean).join(\" \");\n }\n\n return \"\";\n}\n\n/**\n * Set a property on an element\n */\nexport function setProperty(element: Element, key: string, value: unknown): void {\n // Skip internal props\n if (key === \"key\" || key === \"ref\" || key === \"children\") {\n return;\n }\n\n // Handle events\n if (key.startsWith(\"on\") && typeof value === \"function\") {\n const eventName = key.toLowerCase().substring(2); // \"onClick\" -> \"click\"\n\n // Use addEventListener instead of property assignment for better reliability\n // especially in hydration scenarios\n const element_any = element as any;\n\n // Remove old listener if exists (stored on element)\n const oldListener = element_any[`__${key}`];\n if (oldListener) {\n element.removeEventListener(eventName, oldListener);\n }\n\n // Add new listener and store reference for future cleanup\n element.addEventListener(eventName, value as EventListener);\n element_any[`__${key}`] = value;\n\n return;\n }\n\n // Handle className/class with StyleToken support\n if (key === \"className\" || key === \"class\") {\n if (value == null) {\n element.removeAttribute(\"class\");\n return;\n }\n\n // Resolve class value (may be string, StyleToken, or array)\n const resolvedClass = resolveClass(value as ClassValue);\n if (resolvedClass) {\n element.setAttribute(\"class\", resolvedClass);\n } else {\n element.removeAttribute(\"class\");\n }\n return;\n }\n\n // Handle style\n if (key === \"style\" && element instanceof HTMLElement) {\n if (typeof value === \"string\") {\n element.style.cssText = value;\n } else if (typeof value === \"object\" && value !== null) {\n Object.assign(element.style, value);\n }\n return;\n }\n\n // Handle special boolean attributes\n if (typeof value === \"boolean\") {\n if (value) {\n element.setAttribute(key, \"\");\n } else {\n element.removeAttribute(key);\n }\n return;\n }\n\n // Handle value for form elements\n if (key === \"value\") {\n if (\n element instanceof HTMLInputElement ||\n element instanceof HTMLTextAreaElement ||\n element instanceof HTMLSelectElement\n ) {\n element.value = String(value ?? \"\");\n return;\n }\n }\n\n // Handle checked for checkboxes\n if (key === \"checked\" && element instanceof HTMLInputElement) {\n element.checked = Boolean(value);\n return;\n }\n\n // Default: set as attribute\n if (value == null) {\n element.removeAttribute(key);\n } else {\n element.setAttribute(key, String(value));\n }\n}\n\n/**\n * Set a signal property on an element\n */\nexport function setSignalProperty<T = unknown>(\n element: Element,\n key: string,\n signal: Signal<T>,\n): () => void {\n // Set initial value\n setProperty(element, key, signal.value);\n\n // Subscribe to changes and update property\n return signal.subscribe((value: T) => {\n setProperty(element, key, value);\n });\n}\n\n/**\n * Set a ref on an element\n * - Supports both Signal refs and callback refs\n * - Returns a cleanup function to clear the ref\n */\nexport function setRef(element: Node, ref: Ref<any>): () => void {\n // Signal ref\n if (isSignal(ref)) {\n ref.value = element;\n return () => {\n ref.value = null;\n };\n }\n\n // Callback ref\n if (typeof ref === \"function\") {\n ref(element);\n return () => {\n ref(null);\n };\n }\n\n // Invalid ref type\n return () => {};\n}\n","import type { VNode } from \"@semajsx/core\";\nimport {\n resource,\n stream,\n createRenderer,\n isAsyncIterator,\n isPromise,\n Fragment,\n Portal,\n type RenderedNode,\n type RenderStrategy,\n type ContextMap,\n} from \"@semajsx/core\";\nimport { setProperty, setSignalProperty, setRef } from \"./properties\";\nimport {\n appendChild,\n createElement,\n createTextNode,\n createComment,\n removeChild,\n replaceNode,\n insertBefore,\n getParent,\n getNextSibling,\n} from \"./operations\";\n\n/**\n * Helper to recursively collect all actual DOM nodes from a rendered node\n * Handles fragments and signal nodes that may not have their own DOM node\n */\nfunction collectNodes(rendered: RenderedNode<Node>): Node[] {\n const nodes: Node[] = [];\n\n // Portal: children are already rendered to the portal container\n // Don't collect them here as they shouldn't be added to the main tree\n if (rendered.vnode.type === Portal) {\n return nodes;\n }\n\n // Fragment: no node, only children\n if (rendered.vnode.type === Fragment) {\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Signal marker: include marker node + content children\n if (rendered.vnode.type === \"#signal\") {\n if (rendered.node) {\n nodes.push(rendered.node); // marker\n }\n // Collect content children (after marker)\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Regular elements and text nodes: just the node itself\n if (rendered.node) {\n nodes.push(rendered.node);\n } else if (rendered.children.length > 0) {\n // Component returned Fragment or other node-less structure\n // Need to collect from children\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n }\n return nodes;\n}\n\n/**\n * Result returned by the render function\n */\nexport interface DOMRenderResult {\n /**\n * Unmount the rendered tree and cleanup subscriptions\n */\n unmount: () => void;\n}\n\n/**\n * DOM-specific render strategy with optimization\n */\nconst domStrategy: RenderStrategy<Node> = {\n createTextNode,\n createComment,\n createElement,\n getParent,\n getNextSibling,\n insertBefore,\n appendChild,\n removeChild,\n replaceNode,\n setProperty,\n setSignalProperty,\n setRef,\n tryReuseNode,\n};\n\n// Create DOM renderer with optimization\nconst { renderNode, unmount: unmountCore } = createRenderer(domStrategy);\n\n/**\n * Render a VNode tree to the DOM\n * Supports sync VNodes, async VNodes (Promise), and streaming VNodes (AsyncIterableIterator)\n *\n * @example\n * // Basic usage\n * const { unmount } = render(<App />, container);\n *\n * @example\n * // With signals (auto-updates)\n * const count = signal(0);\n * render(<div>{count}</div>, container);\n * count.value++; // UI updates automatically\n *\n * @example\n * // Cleanup when needed\n * const { unmount } = render(<App />, container);\n * unmount();\n */\nexport function render(\n element: VNode | Promise<VNode> | AsyncIterableIterator<VNode>,\n container: Element,\n): DOMRenderResult {\n // Initialize empty context map for root render\n const initialContext: ContextMap = new Map();\n\n let rendered: RenderedNode<Node>;\n\n // Handle async element (Promise<VNode>)\n if (isPromise(element)) {\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = resource(element, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: initialContext },\n children: [],\n };\n rendered = renderNode(signalVNode, initialContext);\n if (rendered.node) {\n appendChild(container, rendered.node);\n }\n } else if (isAsyncIterator(element)) {\n // Handle async generator (AsyncIterableIterator<VNode>)\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = stream(element, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: initialContext },\n children: [],\n };\n rendered = renderNode(signalVNode, initialContext);\n if (rendered.node) {\n appendChild(container, rendered.node);\n }\n } else {\n // Handle sync VNode\n rendered = renderNode(element, initialContext);\n\n // Collect all nodes (handles Fragments with multiple children)\n const nodes = collectNodes(rendered);\n for (const node of nodes) {\n appendChild(container, node);\n }\n }\n\n // Return result object with unmount method\n return {\n unmount: () => unmountCore(rendered),\n };\n}\n\n/**\n * Try to reuse an existing DOM node instead of replacing it\n * Returns true if the node was successfully reused\n */\nfunction tryReuseNode(\n oldDom: Node,\n newDom: Node,\n oldRendered: RenderedNode<Node>,\n newRendered: RenderedNode<Node>,\n): boolean {\n // Both are text nodes - just update the content\n if (oldDom.nodeType === Node.TEXT_NODE && newDom.nodeType === Node.TEXT_NODE) {\n if (oldDom.textContent !== newDom.textContent) {\n oldDom.textContent = newDom.textContent;\n }\n // Update the newRendered to point to the old (reused) DOM node\n newRendered.node = oldDom;\n return true;\n }\n\n // Both are elements with the same tag name - update properties and children\n if (\n oldDom.nodeType === Node.ELEMENT_NODE &&\n newDom.nodeType === Node.ELEMENT_NODE &&\n (oldDom as Element).tagName === (newDom as Element).tagName\n ) {\n const oldElement = oldDom as Element;\n const newElement = newDom as Element;\n\n // Update attributes\n // Remove old attributes\n for (let i = oldElement.attributes.length - 1; i >= 0; i--) {\n const attr = oldElement.attributes[i];\n if (attr && !newElement.hasAttribute(attr.name)) {\n oldElement.removeAttribute(attr.name);\n }\n }\n\n // Set new attributes\n for (let i = 0; i < newElement.attributes.length; i++) {\n const attr = newElement.attributes[i];\n if (attr && oldElement.getAttribute(attr.name) !== attr.value) {\n oldElement.setAttribute(attr.name, attr.value);\n }\n }\n\n // Use keyed reconciliation if children have keys\n const hasKeys = hasChildKeys(oldRendered) || hasChildKeys(newRendered);\n\n if (hasKeys && oldRendered.children.length > 0 && newRendered.children.length > 0) {\n reconcileKeyedChildren(oldElement, oldRendered.children, newRendered.children);\n } else {\n // Fallback: replace all children\n // Clear old children\n while (oldElement.firstChild) {\n oldElement.removeChild(oldElement.firstChild);\n }\n\n // Add new children\n while (newElement.firstChild) {\n oldElement.appendChild(newElement.firstChild);\n }\n }\n\n // Update the newRendered to point to the old (reused) DOM node\n newRendered.node = oldDom;\n\n // Cleanup old subscriptions\n for (const unsub of oldRendered.subscriptions) {\n unsub();\n }\n\n return true;\n }\n\n // Different node types - can't reuse\n return false;\n}\n\n/**\n * Check if any children have keys\n */\nfunction hasChildKeys(rendered: RenderedNode<Node>): boolean {\n return rendered.children.some((child) => child.vnode.key != null);\n}\n\n/**\n * Reconcile children using keys for efficient list updates\n */\nfunction reconcileKeyedChildren(\n parent: Element,\n oldChildren: RenderedNode<Node>[],\n newChildren: RenderedNode<Node>[],\n): void {\n // Build a map of old children by key\n const oldKeyMap = new Map<string | number, RenderedNode<Node>>();\n const oldKeylessChildren: RenderedNode<Node>[] = [];\n\n for (const child of oldChildren) {\n if (child.vnode.key != null) {\n oldKeyMap.set(child.vnode.key, child);\n } else {\n oldKeylessChildren.push(child);\n }\n }\n\n // Track which old children have been reused\n const reusedKeys = new Set<string | number>();\n let keylessIndex = 0;\n\n // Process new children\n for (let i = 0; i < newChildren.length; i++) {\n const newChild = newChildren[i];\n if (!newChild) continue;\n\n const newKey = newChild.vnode.key;\n let oldChild: RenderedNode<Node> | undefined;\n let reused = false;\n\n // Try to find matching old child by key\n if (newKey != null) {\n oldChild = oldKeyMap.get(newKey);\n if (oldChild) {\n reusedKeys.add(newKey);\n reused = true;\n }\n } else {\n // No key, try to reuse next keyless child\n if (keylessIndex < oldKeylessChildren.length) {\n oldChild = oldKeylessChildren[keylessIndex++];\n }\n }\n\n // If we found a matching old child, try to update it\n if (oldChild && reused && oldChild.node && newChild.node) {\n const sameType =\n oldChild.vnode.type === newChild.vnode.type ||\n (oldChild.node.nodeType === Node.TEXT_NODE && newChild.node.nodeType === Node.TEXT_NODE);\n\n if (sameType) {\n // Try to reuse the node\n const nodeReused = tryReuseNode(oldChild.node, newChild.node, oldChild, newChild);\n\n if (nodeReused) {\n // Ensure the child is in the correct position\n const currentNode = parent.childNodes[i];\n if (currentNode !== oldChild.node) {\n parent.insertBefore(oldChild.node, currentNode || null);\n }\n continue;\n }\n }\n }\n\n // Can't reuse, insert the new child\n if (newChild.node) {\n const currentNode = parent.childNodes[i];\n if (currentNode) {\n parent.insertBefore(newChild.node, currentNode);\n } else {\n parent.appendChild(newChild.node);\n }\n }\n }\n\n // Remove old children that weren't reused\n for (const [key, oldChild] of oldKeyMap) {\n if (!reusedKeys.has(key) && oldChild.node) {\n removeChild(oldChild.node);\n unmountCore(oldChild);\n }\n }\n\n // Remove excess keyless children\n for (let i = keylessIndex; i < oldKeylessChildren.length; i++) {\n const oldChild = oldKeylessChildren[i];\n if (oldChild && oldChild.node) {\n removeChild(oldChild.node);\n unmountCore(oldChild);\n }\n }\n\n // Remove any extra DOM nodes that are still in the parent\n while (parent.childNodes.length > newChildren.length) {\n const lastChild = parent.lastChild;\n if (lastChild) {\n parent.removeChild(lastChild);\n }\n }\n}\n","import type { JSXNode, VNode } from \"@semajsx/core\";\nimport { Portal, h } from \"@semajsx/core\";\n\n/**\n * Portal props interface\n */\nexport interface PortalProps {\n children: JSXNode;\n container: Element;\n}\n\n/**\n * Create a portal VNode that renders children into a different DOM container\n *\n * @param children - The children to render\n * @param container - The target DOM container element\n * @returns A portal VNode\n *\n * @example\n * ```tsx\n * const Modal = () => {\n * return createPortal(\n * <div class=\"modal\">Modal content</div>,\n * document.body\n * );\n * };\n * ```\n */\nexport function createPortal(children: JSXNode, container: Element): VNode {\n // Use h() to create Portal VNode with proper normalization\n return h(Portal, { container }, children);\n}\n\n/**\n * Portal component (alternative to createPortal function)\n *\n * @example\n * ```tsx\n * <Portal container={document.body}>\n * <div class=\"modal\">Modal content</div>\n * </Portal>\n * ```\n */\nexport function PortalComponent(props: PortalProps): VNode {\n return createPortal(props.children, props.container);\n}\n","import type { JSXNode, VNode } from \"@semajsx/core\";\nimport { Forward, h } from \"@semajsx/core\";\n\n/**\n * Forward props interface\n */\nexport interface ForwardProps {\n children: JSXNode;\n [key: string]: unknown;\n}\n\n/**\n * Forward component - merges props onto its single child element\n *\n * Forward is a renderless primitive that injects props into its child\n * without producing an extra DOM node. Think of it as declarative\n * prop spreading from parent to child.\n *\n * Props merging behavior:\n * - `class`/`className`: concatenated (both applied)\n * - `style`: merged objects (Forward overrides per-property)\n * - Event handlers (`on*`): chained (both run)\n * - Other props: Forward overrides child\n *\n * @example\n * ```tsx\n * <Forward onClick={handler} class=\"extra\">\n * <button class=\"btn\">Click me</button>\n * </Forward>\n * // renders: <button class=\"btn extra\" onClick={handler}>Click me</button>\n * ```\n */\nexport function ForwardComponent(props: ForwardProps): VNode {\n const { children, ...rest } = props;\n return h(Forward, rest, children);\n}\n","/**\n * Style anchor components for @semajsx/dom\n *\n * These components control where styles are injected in the DOM.\n * Useful for Shadow DOM and component-scoped style injection.\n */\n\nimport type { VNode, JSXNode } from \"@semajsx/core\";\nimport { Fragment } from \"@semajsx/core\";\n\n/**\n * Style anchor context - stores the current injection target\n */\nlet appStyleTarget: Element | ShadowRoot | null = null;\nlet componentStyleTarget: Element | ShadowRoot | null = null;\n\n/**\n * Get the current style injection target\n *\n * Priority:\n * 1. Component anchor (if set)\n * 2. App anchor (if set)\n * 3. document.head (default)\n */\nexport function getStyleTarget(): Element | ShadowRoot {\n return componentStyleTarget ?? appStyleTarget ?? document.head;\n}\n\n/**\n * Set the app-level style injection target\n *\n * Use this for Shadow DOM to inject styles into the shadow root\n * instead of document.head.\n */\nexport function setAppStyleTarget(target: Element | ShadowRoot | null): void {\n appStyleTarget = target;\n}\n\n/**\n * Set the component-level style injection target\n *\n * This only affects the current component, not children.\n */\nexport function setComponentStyleTarget(target: Element | ShadowRoot | null): void {\n componentStyleTarget = target;\n}\n\n/**\n * AppStyleAnchor props\n */\nexport interface AppStyleAnchorProps {\n /** The target element or shadow root for style injection */\n target: Element | ShadowRoot;\n /** Children to render */\n children?: JSXNode;\n}\n\n/**\n * AppStyleAnchor - Sets the global style injection target\n *\n * Use this component to redirect all style injection to a specific target,\n * typically a Shadow DOM root.\n *\n * @example\n * ```tsx\n * function MyWebComponent() {\n * const shadow = useShadowRoot();\n *\n * return (\n * <AppStyleAnchor target={shadow}>\n * <App />\n * </AppStyleAnchor>\n * );\n * }\n * ```\n */\nexport function AppStyleAnchor({ target, children }: AppStyleAnchorProps): VNode {\n // Set the target when the component mounts\n setAppStyleTarget(target);\n\n // Return children wrapped in a fragment\n return {\n type: Fragment,\n props: {},\n children: children ? [children as VNode] : [],\n key: undefined,\n };\n}\n\n/**\n * ComponentStyleAnchor props\n */\nexport interface ComponentStyleAnchorProps {\n /** The target element or shadow root for style injection */\n target: Element | ShadowRoot;\n /** Children to render */\n children?: JSXNode;\n}\n\n/**\n * ComponentStyleAnchor - Sets style injection target for current component only\n *\n * Unlike AppStyleAnchor, this only affects styles used directly in the\n * component where it's declared. Child components use the App anchor\n * or fall back to document.head.\n *\n * @example\n * ```tsx\n * function IsolatedComponent() {\n * const containerRef = signal<HTMLElement | null>(null);\n *\n * return (\n * <div>\n * <style-container ref={containerRef} />\n * <ComponentStyleAnchor target={containerRef}>\n * <div class={card.root}>...</div>\n * <ChildComponent /> {* Uses App anchor, NOT this anchor *}\n * </ComponentStyleAnchor>\n * </div>\n * );\n * }\n * ```\n */\nexport function ComponentStyleAnchor({ target, children }: ComponentStyleAnchorProps): VNode {\n // Set the target when the component mounts\n setComponentStyleTarget(target);\n\n // Return children wrapped in a fragment\n return {\n type: Fragment,\n props: {},\n children: children ? [children as VNode] : [],\n key: undefined,\n };\n}\n","import type { VNode } from \"@semajsx/core\";\n\nexport interface NativeProps {\n /** The native DOM element to embed in the SemaJSX tree */\n element: Element;\n /** Additional attributes to apply to the element */\n [key: string]: unknown;\n}\n\n/**\n * Embed a native DOM element in the SemaJSX render tree.\n *\n * Useful for integrating third-party libraries that return real DOM elements\n * (e.g., Lucide's createElement, D3 nodes, Canvas elements).\n *\n * Props (except `element`) are applied to the element using the same\n * property-setting logic as regular JSX elements — supports class, style,\n * event handlers, signals, and standard attributes.\n *\n * @example\n * ```tsx\n * import { Native } from \"semajsx/dom\";\n * import { createElement, Rocket } from \"lucide\";\n *\n * const App = () => (\n * <div>\n * <Native element={createElement(Rocket)} stroke=\"#007aff\" />\n * </div>\n * );\n * ```\n */\nexport function Native({ element, ...attrs }: NativeProps): VNode {\n return {\n type: \"#native\",\n props: { __nativeNode: element, ...attrs },\n children: [],\n };\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,cAAc,SAA0B;AACtD,QAAO,SAAS,cAAc,QAAQ;;AAGxC,SAAgB,eAAe,MAAoB;AACjD,QAAO,SAAS,eAAe,KAAK;;AAGtC,SAAgB,cAAc,MAAuB;AACnD,QAAO,SAAS,cAAc,KAAK;;AAGrC,SAAgB,YAAY,QAAc,OAAmB;AAC3D,QAAO,YAAY,MAAM;;AAG3B,SAAgB,YAAY,MAAkB;AAC5C,MAAK,YAAY,YAAY,KAAK;;AAGpC,SAAgB,aAAa,QAAc,SAAe,SAA4B;AACpF,QAAO,aAAa,SAAS,QAAQ;;AAGvC,SAAgB,YAAY,SAAe,SAAqB;AAC9D,SAAQ,YAAY,aAAa,SAAS,QAAQ;;AAGpD,SAAgB,QAAQ,MAAY,MAAoB;AACtD,MAAK,cAAc;;AAGrB,SAAgB,UAAU,MAAyB;AACjD,QAAO,KAAK;;AAGd,SAAgB,eAAe,MAAyB;AACtD,QAAO,KAAK;;;;;;;;;;;;;;;;;;;ACjBd,SAAS,aAAa,OAA2B;AAC/C,KAAI,CAAC,MACH,QAAO;AAGT,KAAI,OAAO,UAAU,SACnB,QAAO;AAGT,KAAI,aAAa,MAAM,EAAE;AAEvB,SAAO,MAAM;AAEb,SAAO,MAAM,KAAK;;AAGpB,KAAI,MAAM,QAAQ,MAAM,CAEtB,QAAO,MAAM,IAAI,aAAa,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;AAG1D,QAAO;;;;;AAMT,SAAgB,YAAY,SAAkB,KAAa,OAAsB;AAE/E,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B,QAAO;EACL,MAAM;EACN,OAAO,EAAE;EACT,UAAU,WAAW,CAAC,SAAkB,GAAG,EAAE;EAC7C,KAAK;EACN;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCH,SAAgB,qBAAqB,EAAE,QAAQ,YAA8C;AAE3F,yBAAwB,OAAO;AAG/B,QAAO;EACL,MAAM;EACN,OAAO,EAAE;EACT,UAAU,WAAW,CAAC,SAAkB,GAAG,EAAE;EAC7C,KAAK;EACN;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtGH,SAAgB,OAAO,EAAE,SAAS,GAAG,SAA6B;AAChE,QAAO;EACL,MAAM;EACN,OAAO;GAAE,cAAc;GAAS,GAAG;GAAO;EAC1C,UAAU,EAAE;EACb"}
1
+ {"version":3,"file":"src-C_aFsFJ3.mjs","names":[],"sources":["../../dom/src/operations.ts","../../dom/src/properties.ts","../../dom/src/render.ts","../../dom/src/portal.ts","../../dom/src/forward.ts","../../dom/src/style-anchor.ts","../../dom/src/native.ts"],"sourcesContent":["/**\n * Low-level DOM operations\n */\n\nexport function createElement(tagName: string): Element {\n return document.createElement(tagName);\n}\n\nexport function createTextNode(text: string): Text {\n return document.createTextNode(text);\n}\n\nexport function createComment(text: string): Comment {\n return document.createComment(text);\n}\n\nexport function appendChild(parent: Node, child: Node): void {\n parent.appendChild(child);\n}\n\nexport function removeChild(node: Node): void {\n node.parentNode?.removeChild(node);\n}\n\nexport function insertBefore(parent: Node, newNode: Node, refNode: Node | null): void {\n parent.insertBefore(newNode, refNode);\n}\n\nexport function replaceNode(oldNode: Node, newNode: Node): void {\n oldNode.parentNode?.replaceChild(newNode, oldNode);\n}\n\nexport function setText(node: Node, text: string): void {\n node.textContent = text;\n}\n\nexport function getParent(node: Node): Node | null {\n return node.parentNode;\n}\n\nexport function getNextSibling(node: Node): Node | null {\n return node.nextSibling;\n}\n","import type { Signal } from \"@semajsx/signal\";\nimport type { Ref } from \"@semajsx/core\";\nimport { isSignal } from \"@semajsx/signal\";\nimport { isStyleToken, inject, type StyleToken } from \"@semajsx/style\";\n\n/**\n * Class value type - can be string, StyleToken, array, or falsy\n */\ntype ClassValue = string | StyleToken | ClassValue[] | false | null | undefined;\n\n/**\n * Resolve a class value to a string\n *\n * Supports:\n * - Strings: returned as-is\n * - StyleTokens: injects CSS and returns className\n * - Arrays: recursively resolves all values\n * - Falsy values: filtered out\n *\n * @example\n * resolveClass(\"btn\") // \"btn\"\n * resolveClass(button.root) // \"root-x7f3a\" (injects CSS)\n * resolveClass([button.root, \"custom\", isLarge && button.large]) // \"root-x7f3a custom large-y8g4b\"\n */\nfunction resolveClass(value: ClassValue): string {\n if (!value) {\n return \"\";\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (isStyleToken(value)) {\n // Inject CSS for the token\n inject(value);\n // Return the className (or empty string if none)\n return value._ ?? \"\";\n }\n\n if (Array.isArray(value)) {\n // Recursively resolve array values, filter empty strings\n return value.map(resolveClass).filter(Boolean).join(\" \");\n }\n\n return \"\";\n}\n\n/**\n * Set a property on an element\n */\nexport function setProperty(element: Element, key: string, value: unknown): void {\n // Skip internal props\n if (key === \"key\" || key === \"ref\" || key === \"children\") {\n return;\n }\n\n // Handle events\n if (key.startsWith(\"on\") && typeof value === \"function\") {\n const eventName = key.toLowerCase().substring(2); // \"onClick\" -> \"click\"\n\n // Use addEventListener instead of property assignment for better reliability\n // especially in hydration scenarios\n const element_any = element as any;\n\n // Remove old listener if exists (stored on element)\n const oldListener = element_any[`__${key}`];\n if (oldListener) {\n element.removeEventListener(eventName, oldListener);\n }\n\n // Add new listener and store reference for future cleanup\n element.addEventListener(eventName, value as EventListener);\n element_any[`__${key}`] = value;\n\n return;\n }\n\n // Handle className/class with StyleToken support\n if (key === \"className\" || key === \"class\") {\n if (value == null) {\n element.removeAttribute(\"class\");\n return;\n }\n\n // Resolve class value (may be string, StyleToken, or array)\n const resolvedClass = resolveClass(value as ClassValue);\n if (resolvedClass) {\n element.setAttribute(\"class\", resolvedClass);\n } else {\n element.removeAttribute(\"class\");\n }\n return;\n }\n\n // Handle style\n if (key === \"style\" && element instanceof HTMLElement) {\n if (typeof value === \"string\") {\n element.style.cssText = value;\n } else if (typeof value === \"object\" && value !== null) {\n Object.assign(element.style, value);\n }\n return;\n }\n\n // Handle special boolean attributes\n if (typeof value === \"boolean\") {\n if (value) {\n element.setAttribute(key, \"\");\n } else {\n element.removeAttribute(key);\n }\n return;\n }\n\n // Handle value for form elements\n if (key === \"value\") {\n if (\n element instanceof HTMLInputElement ||\n element instanceof HTMLTextAreaElement ||\n element instanceof HTMLSelectElement\n ) {\n element.value = String(value ?? \"\");\n return;\n }\n }\n\n // Handle checked for checkboxes\n if (key === \"checked\" && element instanceof HTMLInputElement) {\n element.checked = Boolean(value);\n return;\n }\n\n // Default: set as attribute\n if (value == null) {\n element.removeAttribute(key);\n } else {\n element.setAttribute(key, String(value));\n }\n}\n\n/**\n * Set a signal property on an element\n */\nexport function setSignalProperty<T = unknown>(\n element: Element,\n key: string,\n signal: Signal<T>,\n): () => void {\n // Set initial value\n setProperty(element, key, signal.value);\n\n // Subscribe to changes and update property\n return signal.subscribe((value: T) => {\n setProperty(element, key, value);\n });\n}\n\n/**\n * Set a ref on an element\n * - Supports both Signal refs and callback refs\n * - Returns a cleanup function to clear the ref\n */\nexport function setRef(element: Node, ref: Ref<any>): () => void {\n // Signal ref\n if (isSignal(ref)) {\n ref.value = element;\n return () => {\n ref.value = null;\n };\n }\n\n // Callback ref\n if (typeof ref === \"function\") {\n ref(element);\n return () => {\n ref(null);\n };\n }\n\n // Invalid ref type\n return () => {};\n}\n","import type { VNode } from \"@semajsx/core\";\nimport {\n resource,\n stream,\n createRenderer,\n isAsyncIterator,\n isPromise,\n Fragment,\n Portal,\n type RenderedNode,\n type RenderStrategy,\n type ContextMap,\n} from \"@semajsx/core\";\nimport { setProperty, setSignalProperty, setRef } from \"./properties\";\nimport {\n appendChild,\n createElement,\n createTextNode,\n createComment,\n removeChild,\n replaceNode,\n insertBefore,\n getParent,\n getNextSibling,\n} from \"./operations\";\n\n/**\n * Helper to recursively collect all actual DOM nodes from a rendered node\n * Handles fragments and signal nodes that may not have their own DOM node\n */\nfunction collectNodes(rendered: RenderedNode<Node>): Node[] {\n const nodes: Node[] = [];\n\n // Portal: children are already rendered to the portal container\n // Don't collect them here as they shouldn't be added to the main tree\n if (rendered.vnode.type === Portal) {\n return nodes;\n }\n\n // Fragment: no node, only children\n if (rendered.vnode.type === Fragment) {\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Signal marker: include marker node + content children\n if (rendered.vnode.type === \"#signal\") {\n if (rendered.node) {\n nodes.push(rendered.node); // marker\n }\n // Collect content children (after marker)\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Regular elements and text nodes: just the node itself\n if (rendered.node) {\n nodes.push(rendered.node);\n } else if (rendered.children.length > 0) {\n // Component returned Fragment or other node-less structure\n // Need to collect from children\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n }\n return nodes;\n}\n\n/**\n * Result returned by the render function\n */\nexport interface DOMRenderResult {\n /**\n * Unmount the rendered tree and cleanup subscriptions\n */\n unmount: () => void;\n}\n\n/**\n * DOM-specific render strategy with optimization\n */\nconst domStrategy: RenderStrategy<Node> = {\n createTextNode,\n createComment,\n createElement,\n getParent,\n getNextSibling,\n insertBefore,\n appendChild,\n removeChild,\n replaceNode,\n setProperty,\n setSignalProperty,\n setRef,\n tryReuseNode,\n};\n\n// Create DOM renderer with optimization\nconst { renderNode, unmount: unmountCore } = createRenderer(domStrategy);\n\n/**\n * Render a VNode tree to the DOM\n * Supports sync VNodes, async VNodes (Promise), and streaming VNodes (AsyncIterableIterator)\n *\n * @example\n * // Basic usage\n * const { unmount } = render(<App />, container);\n *\n * @example\n * // With signals (auto-updates)\n * const count = signal(0);\n * render(<div>{count}</div>, container);\n * count.value++; // UI updates automatically\n *\n * @example\n * // Cleanup when needed\n * const { unmount } = render(<App />, container);\n * unmount();\n */\nexport function render(\n element: VNode | Promise<VNode> | AsyncIterableIterator<VNode>,\n container: Element,\n): DOMRenderResult {\n // Initialize empty context map for root render\n const initialContext: ContextMap = new Map();\n\n let rendered: RenderedNode<Node>;\n\n // Handle async element (Promise<VNode>)\n if (isPromise(element)) {\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = resource(element, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: initialContext },\n children: [],\n };\n rendered = renderNode(signalVNode, initialContext);\n if (rendered.node) {\n appendChild(container, rendered.node);\n }\n } else if (isAsyncIterator(element)) {\n // Handle async generator (AsyncIterableIterator<VNode>)\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = stream(element, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: initialContext },\n children: [],\n };\n rendered = renderNode(signalVNode, initialContext);\n if (rendered.node) {\n appendChild(container, rendered.node);\n }\n } else {\n // Handle sync VNode\n rendered = renderNode(element, initialContext);\n\n // Collect all nodes (handles Fragments with multiple children)\n const nodes = collectNodes(rendered);\n for (const node of nodes) {\n appendChild(container, node);\n }\n }\n\n // Return result object with unmount method\n return {\n unmount: () => unmountCore(rendered),\n };\n}\n\n/**\n * Try to reuse an existing DOM node instead of replacing it\n * Returns true if the node was successfully reused\n */\nfunction tryReuseNode(\n oldDom: Node,\n newDom: Node,\n oldRendered: RenderedNode<Node>,\n newRendered: RenderedNode<Node>,\n): boolean {\n // Both are text nodes - just update the content\n if (oldDom.nodeType === Node.TEXT_NODE && newDom.nodeType === Node.TEXT_NODE) {\n if (oldDom.textContent !== newDom.textContent) {\n oldDom.textContent = newDom.textContent;\n }\n // Update the newRendered to point to the old (reused) DOM node\n newRendered.node = oldDom;\n return true;\n }\n\n // Both are elements with the same tag name - update properties and children\n if (\n oldDom.nodeType === Node.ELEMENT_NODE &&\n newDom.nodeType === Node.ELEMENT_NODE &&\n (oldDom as Element).tagName === (newDom as Element).tagName\n ) {\n const oldElement = oldDom as Element;\n const newElement = newDom as Element;\n\n // Update attributes\n // Remove old attributes\n for (let i = oldElement.attributes.length - 1; i >= 0; i--) {\n const attr = oldElement.attributes[i];\n if (attr && !newElement.hasAttribute(attr.name)) {\n oldElement.removeAttribute(attr.name);\n }\n }\n\n // Set new attributes\n for (let i = 0; i < newElement.attributes.length; i++) {\n const attr = newElement.attributes[i];\n if (attr && oldElement.getAttribute(attr.name) !== attr.value) {\n oldElement.setAttribute(attr.name, attr.value);\n }\n }\n\n // Use keyed reconciliation if children have keys\n const hasKeys = hasChildKeys(oldRendered) || hasChildKeys(newRendered);\n\n if (hasKeys && oldRendered.children.length > 0 && newRendered.children.length > 0) {\n reconcileKeyedChildren(oldElement, oldRendered.children, newRendered.children);\n } else {\n // Fallback: replace all children\n // Clear old children\n while (oldElement.firstChild) {\n oldElement.removeChild(oldElement.firstChild);\n }\n\n // Add new children\n while (newElement.firstChild) {\n oldElement.appendChild(newElement.firstChild);\n }\n }\n\n // Update the newRendered to point to the old (reused) DOM node\n newRendered.node = oldDom;\n\n // Cleanup old subscriptions\n for (const unsub of oldRendered.subscriptions) {\n unsub();\n }\n\n return true;\n }\n\n // Different node types - can't reuse\n return false;\n}\n\n/**\n * Check if any children have keys\n */\nfunction hasChildKeys(rendered: RenderedNode<Node>): boolean {\n return rendered.children.some((child) => child.vnode.key != null);\n}\n\n/**\n * Reconcile children using keys for efficient list updates\n */\nfunction reconcileKeyedChildren(\n parent: Element,\n oldChildren: RenderedNode<Node>[],\n newChildren: RenderedNode<Node>[],\n): void {\n // Build a map of old children by key\n const oldKeyMap = new Map<string | number, RenderedNode<Node>>();\n const oldKeylessChildren: RenderedNode<Node>[] = [];\n\n for (const child of oldChildren) {\n if (child.vnode.key != null) {\n oldKeyMap.set(child.vnode.key, child);\n } else {\n oldKeylessChildren.push(child);\n }\n }\n\n // Track which old children have been reused\n const reusedKeys = new Set<string | number>();\n let keylessIndex = 0;\n\n // Process new children\n for (let i = 0; i < newChildren.length; i++) {\n const newChild = newChildren[i];\n if (!newChild) continue;\n\n const newKey = newChild.vnode.key;\n let oldChild: RenderedNode<Node> | undefined;\n let reused = false;\n\n // Try to find matching old child by key\n if (newKey != null) {\n oldChild = oldKeyMap.get(newKey);\n if (oldChild) {\n reusedKeys.add(newKey);\n reused = true;\n }\n } else {\n // No key, try to reuse next keyless child\n if (keylessIndex < oldKeylessChildren.length) {\n oldChild = oldKeylessChildren[keylessIndex++];\n }\n }\n\n // If we found a matching old child, try to update it\n if (oldChild && reused && oldChild.node && newChild.node) {\n const sameType =\n oldChild.vnode.type === newChild.vnode.type ||\n (oldChild.node.nodeType === Node.TEXT_NODE && newChild.node.nodeType === Node.TEXT_NODE);\n\n if (sameType) {\n // Try to reuse the node\n const nodeReused = tryReuseNode(oldChild.node, newChild.node, oldChild, newChild);\n\n if (nodeReused) {\n // Ensure the child is in the correct position\n const currentNode = parent.childNodes[i];\n if (currentNode !== oldChild.node) {\n parent.insertBefore(oldChild.node, currentNode || null);\n }\n continue;\n }\n }\n }\n\n // Can't reuse, insert the new child\n if (newChild.node) {\n const currentNode = parent.childNodes[i];\n if (currentNode) {\n parent.insertBefore(newChild.node, currentNode);\n } else {\n parent.appendChild(newChild.node);\n }\n }\n }\n\n // Remove old children that weren't reused\n for (const [key, oldChild] of oldKeyMap) {\n if (!reusedKeys.has(key) && oldChild.node) {\n removeChild(oldChild.node);\n unmountCore(oldChild);\n }\n }\n\n // Remove excess keyless children\n for (let i = keylessIndex; i < oldKeylessChildren.length; i++) {\n const oldChild = oldKeylessChildren[i];\n if (oldChild && oldChild.node) {\n removeChild(oldChild.node);\n unmountCore(oldChild);\n }\n }\n\n // Remove any extra DOM nodes that are still in the parent\n while (parent.childNodes.length > newChildren.length) {\n const lastChild = parent.lastChild;\n if (lastChild) {\n parent.removeChild(lastChild);\n }\n }\n}\n","import type { JSXNode, VNode } from \"@semajsx/core\";\nimport { Portal, h } from \"@semajsx/core\";\n\n/**\n * Portal props interface\n */\nexport interface PortalProps {\n children: JSXNode;\n container: Element;\n}\n\n/**\n * Create a portal VNode that renders children into a different DOM container\n *\n * @param children - The children to render\n * @param container - The target DOM container element\n * @returns A portal VNode\n *\n * @example\n * ```tsx\n * const Modal = () => {\n * return createPortal(\n * <div class=\"modal\">Modal content</div>,\n * document.body\n * );\n * };\n * ```\n */\nexport function createPortal(children: JSXNode, container: Element): VNode {\n // Use h() to create Portal VNode with proper normalization\n return h(Portal, { container }, children);\n}\n\n/**\n * Portal component (alternative to createPortal function)\n *\n * @example\n * ```tsx\n * <Portal container={document.body}>\n * <div class=\"modal\">Modal content</div>\n * </Portal>\n * ```\n */\nexport function PortalComponent(props: PortalProps): VNode {\n return createPortal(props.children, props.container);\n}\n","import type { JSXNode, VNode } from \"@semajsx/core\";\nimport { Forward, h } from \"@semajsx/core\";\n\n/**\n * Forward props interface\n */\nexport interface ForwardProps {\n children: JSXNode;\n [key: string]: unknown;\n}\n\n/**\n * Forward component - merges props onto its single child element\n *\n * Forward is a renderless primitive that injects props into its child\n * without producing an extra DOM node. Think of it as declarative\n * prop spreading from parent to child.\n *\n * Props merging behavior:\n * - `class`/`className`: concatenated (both applied)\n * - `style`: merged objects (Forward overrides per-property)\n * - Event handlers (`on*`): chained (both run)\n * - Other props: Forward overrides child\n *\n * @example\n * ```tsx\n * <Forward onClick={handler} class=\"extra\">\n * <button class=\"btn\">Click me</button>\n * </Forward>\n * // renders: <button class=\"btn extra\" onClick={handler}>Click me</button>\n * ```\n */\nexport function ForwardComponent(props: ForwardProps): VNode {\n const { children, ...rest } = props;\n return h(Forward, rest, children);\n}\n","/**\n * Style anchor components for @semajsx/dom\n *\n * These components control where styles are injected in the DOM.\n * Useful for Shadow DOM and component-scoped style injection.\n */\n\nimport type { VNode, JSXNode } from \"@semajsx/core\";\nimport { Fragment } from \"@semajsx/core\";\n\n/**\n * Style anchor context - stores the current injection target\n */\nlet appStyleTarget: Element | ShadowRoot | null = null;\nlet componentStyleTarget: Element | ShadowRoot | null = null;\n\n/**\n * Get the current style injection target\n *\n * Priority:\n * 1. Component anchor (if set)\n * 2. App anchor (if set)\n * 3. document.head (default)\n */\nexport function getStyleTarget(): Element | ShadowRoot {\n return componentStyleTarget ?? appStyleTarget ?? document.head;\n}\n\n/**\n * Set the app-level style injection target\n *\n * Use this for Shadow DOM to inject styles into the shadow root\n * instead of document.head.\n */\nexport function setAppStyleTarget(target: Element | ShadowRoot | null): void {\n appStyleTarget = target;\n}\n\n/**\n * Set the component-level style injection target\n *\n * This only affects the current component, not children.\n */\nexport function setComponentStyleTarget(target: Element | ShadowRoot | null): void {\n componentStyleTarget = target;\n}\n\n/**\n * AppStyleAnchor props\n */\nexport interface AppStyleAnchorProps {\n /** The target element or shadow root for style injection */\n target: Element | ShadowRoot;\n /** Children to render */\n children?: JSXNode;\n}\n\n/**\n * AppStyleAnchor - Sets the global style injection target\n *\n * Use this component to redirect all style injection to a specific target,\n * typically a Shadow DOM root.\n *\n * @example\n * ```tsx\n * function MyWebComponent() {\n * const shadow = useShadowRoot();\n *\n * return (\n * <AppStyleAnchor target={shadow}>\n * <App />\n * </AppStyleAnchor>\n * );\n * }\n * ```\n */\nexport function AppStyleAnchor({ target, children }: AppStyleAnchorProps): VNode {\n // Set the target when the component mounts\n setAppStyleTarget(target);\n\n // Return children wrapped in a fragment\n return {\n type: Fragment,\n props: {},\n children: children ? [children as VNode] : [],\n key: undefined,\n };\n}\n\n/**\n * ComponentStyleAnchor props\n */\nexport interface ComponentStyleAnchorProps {\n /** The target element or shadow root for style injection */\n target: Element | ShadowRoot;\n /** Children to render */\n children?: JSXNode;\n}\n\n/**\n * ComponentStyleAnchor - Sets style injection target for current component only\n *\n * Unlike AppStyleAnchor, this only affects styles used directly in the\n * component where it's declared. Child components use the App anchor\n * or fall back to document.head.\n *\n * @example\n * ```tsx\n * function IsolatedComponent() {\n * const containerRef = signal<HTMLElement | null>(null);\n *\n * return (\n * <div>\n * <style-container ref={containerRef} />\n * <ComponentStyleAnchor target={containerRef}>\n * <div class={card.root}>...</div>\n * <ChildComponent /> {* Uses App anchor, NOT this anchor *}\n * </ComponentStyleAnchor>\n * </div>\n * );\n * }\n * ```\n */\nexport function ComponentStyleAnchor({ target, children }: ComponentStyleAnchorProps): VNode {\n // Set the target when the component mounts\n setComponentStyleTarget(target);\n\n // Return children wrapped in a fragment\n return {\n type: Fragment,\n props: {},\n children: children ? [children as VNode] : [],\n key: undefined,\n };\n}\n","import type { VNode } from \"@semajsx/core\";\n\nexport interface NativeProps {\n /** The native DOM element to embed in the SemaJSX tree */\n element: Element;\n /** Additional attributes to apply to the element */\n [key: string]: unknown;\n}\n\n/**\n * Embed a native DOM element in the SemaJSX render tree.\n *\n * Useful for integrating third-party libraries that return real DOM elements\n * (e.g., Lucide's createElement, D3 nodes, Canvas elements).\n *\n * Props (except `element`) are applied to the element using the same\n * property-setting logic as regular JSX elements — supports class, style,\n * event handlers, signals, and standard attributes.\n *\n * @example\n * ```tsx\n * import { Native } from \"semajsx/dom\";\n * import { createElement, Rocket } from \"lucide\";\n *\n * const App = () => (\n * <div>\n * <Native element={createElement(Rocket)} stroke=\"#007aff\" />\n * </div>\n * );\n * ```\n */\nexport function Native({ element, ...attrs }: NativeProps): VNode {\n return {\n type: \"#native\",\n props: { __nativeNode: element, ...attrs },\n children: [],\n };\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,cAAc,SAA0B;AACtD,QAAO,SAAS,cAAc,QAAQ;;AAGxC,SAAgB,eAAe,MAAoB;AACjD,QAAO,SAAS,eAAe,KAAK;;AAGtC,SAAgB,cAAc,MAAuB;AACnD,QAAO,SAAS,cAAc,KAAK;;AAGrC,SAAgB,YAAY,QAAc,OAAmB;AAC3D,QAAO,YAAY,MAAM;;AAG3B,SAAgB,YAAY,MAAkB;AAC5C,MAAK,YAAY,YAAY,KAAK;;AAGpC,SAAgB,aAAa,QAAc,SAAe,SAA4B;AACpF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UAAmB,WAA2B;AAEzE,QAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS;;;;;;;;;;;;AAa3C,SAAgB,gBAAgB,OAA2B;AACzD,QAAO,aAAa,MAAM,UAAU,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;ACZtD,SAAgB,iBAAiB,OAA4B;CAC3D,MAAM,EAAE,UAAU,GAAG,SAAS;AAC9B,QAAO,EAAE,SAAS,MAAM,SAAS;;;;;;;;ACrBnC,IAAI,iBAA8C;AAClD,IAAI,uBAAoD;;;;;;;;;AAUxD,SAAgB,iBAAuC;AACrD,QAAO,wBAAwB,kBAAkB,SAAS;;;;;;;;AAS5D,SAAgB,kBAAkB,QAA2C;AAC3E,kBAAiB;;;;;;;AAQnB,SAAgB,wBAAwB,QAA2C;AACjF,wBAAuB;;;;;;;;;;;;;;;;;;;;;AAgCzB,SAAgB,eAAe,EAAE,QAAQ,YAAwC;AAE/E,mBAAkB,OAAO;AAGzB,QAAO;EACL,MAAM;EACN,OAAO,EAAE;EACT,UAAU,WAAW,CAAC,SAAkB,GAAG,EAAE;EAC7C,KAAK;EACN;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCH,SAAgB,qBAAqB,EAAE,QAAQ,YAA8C;AAE3F,yBAAwB,OAAO;AAG/B,QAAO;EACL,MAAM;EACN,OAAO,EAAE;EACT,UAAU,WAAW,CAAC,SAAkB,GAAG,EAAE;EAC7C,KAAK;EACN;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtGH,SAAgB,OAAO,EAAE,SAAS,GAAG,SAA6B;AAChE,QAAO;EACL,MAAM;EACN,OAAO;GAAE,cAAc;GAAS,GAAG;GAAO;EAC1C,UAAU,EAAE;EACb"}
@@ -1,6 +1,6 @@
1
- import { t as signal } from "./signal-BN8vHXDb.mjs";
2
- import { t as computed } from "./computed-BidG06Lt.mjs";
3
- import { t as isSignal } from "./utils-DbTAs943.mjs";
1
+ import { t as signal } from "./signal-4PgGfydw.mjs";
2
+ import { t as computed } from "./computed-BpjqvQu1.mjs";
3
+ import { t as isSignal } from "./utils-BrGmTgfG.mjs";
4
4
 
5
5
  //#region ../core/src/types.ts
6
6
  /**
@@ -654,4 +654,4 @@ function createRenderer(strategy) {
654
654
 
655
655
  //#endregion
656
656
  export { Forward as _, jsxs as a, when as c, createComponentAPI as d, ISLAND_MARKER as f, isVNode as g, h, jsx as i, Context as l, createTextVNode as m, isAsyncIterator as n, resource as o, createFragment as p, isPromise as r, stream as s, createRenderer as t, context as u, Fragment as v, Portal as y };
657
- //# sourceMappingURL=src-DW3tIczg.mjs.map
657
+ //# sourceMappingURL=src-Cv4rRVzv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"src-DW3tIczg.mjs","names":[],"sources":["../../core/src/types.ts","../../core/src/vnode.ts","../../core/src/shared/island-marker.ts","../../core/src/context.ts","../../core/src/helpers.ts","../../core/src/jsx.ts","../../core/src/component.ts","../../core/src/render-core.ts"],"sourcesContent":["import type { ReadableSignal, WritableSignal } from \"./signal\";\n\n/**\n * Special VNode type for fragment support\n */\nexport const Fragment: symbol = Symbol.for(\"semajsx.fragment\");\n\n/**\n * Special VNode type for portal support\n */\nexport const Portal: symbol = Symbol.for(\"semajsx.portal\");\n\n/**\n * Special VNode type for forward support\n * Forward merges its props onto its single child element without producing a DOM node\n */\nexport const Forward: symbol = Symbol.for(\"semajsx.forward\");\n\n/**\n * VNode types\n * - The runtime VNode tree always resolves to these `type` values\n */\nexport type VNodeType = string | Component<any> | typeof Fragment | typeof Portal | typeof Forward;\n\n/**\n * VNode: The basic unit of the runtime render tree\n * - `type`: the element/component type\n * - `props`: attributes or props passed to the node (may be null)\n * - `children`: resolved child nodes (always normalized to VNode[] at render time)\n */\nexport interface VNode {\n type: VNodeType;\n props: Record<string, any> | null;\n children: VNode[];\n key?: string | number | null;\n}\n\n/**\n * Primitive values allowed in JSX\n * - These are normalized during VNode construction\n */\nexport type JSXPrimitive = string | number | boolean | null | undefined;\n\n/**\n * A JSXNode represents any valid \"JSX expression result\"\n * - Could be a raw VNode/primitive, or wrapped in a reactive/async container\n */\nexport type JSXNode =\n | VNode\n | JSXPrimitive\n | Iterable<JSXNode>\n | ReadableSignal<JSXNode>\n | Promise<JSXNode>\n | AsyncIterableIterator<JSXNode>;\n\n/**\n * Component type\n * - Optional `ctx` parameter allows passing in custom API/runtime helpers\n */\nexport type Component<P = any> = (props: P, ctx?: ComponentAPI) => JSXNode;\n\n/**\n * ComponentAPI - Runtime API available to components via second parameter\n */\nexport interface ComponentAPI {\n /**\n * Inject a context value\n * @param context - The context to inject\n * @returns The current value of the context, or undefined if not provided\n */\n inject<T>(context: Context<T>): T | undefined;\n}\n\n/**\n * Ref types\n */\n\n/**\n * Ref - can be a WritableSignal or a callback function\n * This allows both reactive refs and imperative refs\n */\nexport type Ref<T> = WritableSignal<T | null> | ((instance: T | null) => void);\n\n/**\n * Context types\n */\n\n/**\n * Context - a typed Symbol for identifying context\n */\nexport type Context<T> = symbol & { __type?: T };\n\n/**\n * Context provide entry: [Context, value]\n */\nexport type ContextProvide<T = any> = [Context<T>, T];\n\n/**\n * Context component props - supports single or multiple context provides\n */\nexport interface ContextProps {\n // Single context: [ThemeContext, theme]\n // Multiple contexts: [[ThemeContext, theme], [UserContext, user]]\n provide: ContextProvide | ContextProvide[];\n children?: JSXNode;\n}\n\n/**\n * Helper type to allow Signal values for any attribute\n */\nexport type SignalOr<T> = T | ReadableSignal<T>;\n\n/**\n * Makes all properties in T accept Signal values\n * Excludes event handlers (functions) and children\n */\nexport type WithSignals<T> = {\n [K in keyof T]: K extends `on${string}`\n ? T[K] // Event handlers don't need Signal wrapper\n : K extends \"children\"\n ? T[K] // Children handled separately\n : T[K] extends (...args: any[]) => any\n ? T[K] // Other functions don't need Signal wrapper\n : SignalOr<T[K]>;\n};\n\n/**\n * Adds key property to element attributes for list reconciliation\n */\nexport type WithKey<T> = T & {\n key?: string | number;\n};\n","import type { JSXNode, VNode, VNodeType } from \"./types\";\nimport type { Signal } from \"@semajsx/signal\";\nimport { Fragment } from \"./types\";\nimport { isSignal } from \"@semajsx/signal\";\n\n/**\n * Create a VNode (Virtual Node)\n */\nexport function h(\n type: VNodeType,\n props: Record<string, any> | null,\n ...children: JSXNode[]\n): VNode {\n return {\n type,\n props: props || {},\n children: normalizeChildren(children),\n key: props?.key,\n };\n}\n\n/**\n * Create a text VNode\n */\nexport function createTextVNode(text: string | number): VNode {\n return {\n type: \"#text\",\n props: { nodeValue: String(text) },\n children: [],\n };\n}\n\n/**\n * Create a signal VNode wrapper\n */\nexport function createSignalVNode(signal: Signal<unknown>): VNode {\n return {\n type: \"#signal\",\n props: { signal },\n children: [],\n };\n}\n\n/**\n * Normalize children into an array of VNodes\n */\nfunction normalizeChildren(children: JSXNode[]): VNode[] {\n const result: VNode[] = [];\n\n for (const child of children) {\n if (child == null || typeof child === \"boolean\") {\n // Skip nullish and boolean values\n continue;\n }\n\n if (Array.isArray(child)) {\n // Recursively flatten arrays\n result.push(...normalizeChildren(child));\n } else if (typeof child === \"string\" || typeof child === \"number\") {\n // Convert primitives to text nodes\n result.push(createTextVNode(child));\n } else if (isSignal(child)) {\n // Wrap signals in special signal nodes\n result.push(createSignalVNode(child));\n } else if (isVNode(child)) {\n // Already a VNode\n result.push(child);\n } else {\n // Unknown type, skip\n console.warn(\"Unknown child type:\", typeof child);\n }\n }\n\n return result;\n}\n\n/**\n * Check if a value is a VNode\n */\nexport function isVNode(value: unknown): value is VNode {\n return (\n value != null &&\n typeof value === \"object\" &&\n \"type\" in value &&\n \"props\" in value &&\n \"children\" in value\n );\n}\n\n/**\n * Create a Fragment\n */\nexport function createFragment(children: JSXNode[]): VNode {\n return h(Fragment, null, ...children);\n}\n","/**\n * Unique symbol to mark Island components\n * This symbol is used to identify components that should be hydrated on the client\n */\nexport const ISLAND_MARKER: symbol = Symbol.for(\"semajsx.island\");\n","/**\n * Context API implementation\n */\n\nimport { h } from \"./vnode\";\nimport { Fragment } from \"./types\";\nimport type { ComponentAPI, Context as ContextType, ContextProps, VNode } from \"./types\";\n\n// Context map type - stores context values for current render environment\nexport type ContextMap = Map<symbol, any>;\n\n/**\n * Create a new Context (returns a typed Symbol)\n *\n * @param name - Optional name for debugging (defaults to \"anonymous\")\n * @returns Context symbol\n *\n * @example\n * ```typescript\n * const ThemeContext = context<Theme>();\n * const UserContext = context<User>('user'); // With debug name\n *\n * <Context provide={[ThemeContext, theme]}>\n * <App />\n * </Context>\n * ```\n */\nexport function context<T>(name?: string): ContextType<T> {\n const debugName = name || \"anonymous\";\n return Symbol(debugName) as ContextType<T>;\n}\n\n/**\n * Context component - provides context values to child components\n *\n * @example\n * ```typescript\n * // Single context\n * <Context provide={[ThemeContext, theme]}>\n * <App />\n * </Context>\n *\n * // Multiple contexts\n * <Context provide={[\n * [ThemeContext, theme],\n * [UserContext, user]\n * ]}>\n * <App />\n * </Context>\n * ```\n */\nexport function Context(props: ContextProps): VNode {\n const children = props.children\n ? Array.isArray(props.children)\n ? props.children\n : [props.children]\n : [];\n return h(Fragment, null, ...children);\n}\n\n// Mark as special context provider component\n(Context as any).__isContextProvider = true;\n\n/**\n * Create ComponentAPI instance for a component\n *\n * @param contextMap - The context map for current render environment\n * @returns ComponentAPI instance\n */\nexport function createComponentAPI(contextMap: ContextMap): ComponentAPI {\n return {\n inject<T>(context: ContextType<T>): T | undefined {\n return contextMap.get(context);\n },\n };\n}\n","import type { JSXNode } from \"./types\";\nimport type { Signal } from \"@semajsx/signal\";\nimport { computed, signal } from \"@semajsx/signal\";\n\n/**\n * Conditional rendering helper\n *\n * Renders content when condition signal is true, nothing when false.\n *\n * @example\n * // With VNode\n * const hint = when(showHint, <text>Press Ctrl+C to exit</text>);\n *\n * @example\n * // With function (lazy evaluation)\n * const hint = when(showHint, () => <text>Press Ctrl+C to exit</text>);\n */\nexport function when(\n condition: Signal<boolean>,\n content: JSXNode | (() => JSXNode),\n): Signal<JSXNode | null> {\n return computed([condition], (show) => {\n if (!show) return null;\n return typeof content === \"function\" ? content() : content;\n });\n}\n\n/**\n * Async resource helper for Promise<VNode>\n *\n * Renders pending content (or null) while the promise is pending, then renders\n * the resolved VNode. Handle errors in the promise itself using .catch().\n *\n * @example\n * // Handle everything in the promise\n * const content = resource(\n * fetchData()\n * .then(data => <text>{data}</text>)\n * .catch(err => <text color=\"red\">Error: {err.message}</text>)\n * );\n *\n * @example\n * // With optional pending content\n * const content = resource(\n * fetchData().then(data => <text>{data}</text>),\n * <text>Loading...</text>\n * );\n */\nexport function resource(promise: Promise<JSXNode>, pending?: JSXNode): Signal<JSXNode | null> {\n const content = signal<JSXNode | null>(pending || null);\n\n promise\n .then((result) => {\n content.value = result;\n })\n .catch((err) => {\n console.error(\"Unhandled promise rejection in resource():\", err);\n });\n\n return content;\n}\n\n/**\n * Async stream helper for AsyncIterable<VNode>\n *\n * Renders each yielded VNode from the async iterator, replacing the previous\n * content with each new value.\n *\n * @example\n * async function* generateContent() {\n * yield <text>Loading...</text>;\n * const data = await fetchData();\n * yield <text>Data: {data}</text>;\n * }\n *\n * const content = stream(generateContent());\n */\nexport function stream(\n iterator: AsyncIterable<JSXNode>,\n pending?: JSXNode,\n): Signal<JSXNode | null> {\n const content = signal<JSXNode | null>(pending || null);\n\n (async () => {\n try {\n for await (const vnode of iterator) {\n content.value = vnode;\n }\n } catch (err) {\n console.error(\"Error in stream():\", err);\n }\n })();\n\n return content;\n}\n","import { VNode, VNodeType } from \"./types\";\nimport { h } from \"./vnode\";\n\nexport function jsx(type: VNodeType, props: any, key?: any): VNode {\n const { children, ...restProps } = props || {};\n\n if (key !== undefined) {\n restProps.key = key;\n }\n\n if (children !== undefined) {\n return h(type, restProps, children);\n }\n\n return h(type, restProps);\n}\n\nexport function jsxs(type: VNodeType, props: any, key?: any): VNode {\n const { children, ...restProps } = props || {};\n\n if (key !== undefined) {\n restProps.key = key;\n }\n\n if (children !== undefined) {\n const childArray = Array.isArray(children) ? children : [children];\n return h(type, restProps, ...childArray);\n }\n\n return h(type, restProps);\n}\n","import type { JSXNode, JSXPrimitive, VNode } from \"./types\";\nimport { Fragment } from \"./types\";\nimport { isSignal } from \"@semajsx/signal\";\nimport { createSignalVNode, createTextVNode, isVNode } from \"./vnode\";\n\n/**\n * Normalize the `children` prop passed to components so it mirrors React semantics.\n * - 0 children => undefined\n * - 1 child => the child itself\n * - >1 children => array\n */\nexport function normalizeChildrenProp(children: VNode[]): VNode | VNode[] | undefined {\n if (children.length === 0) {\n return undefined;\n }\n if (children.length === 1) {\n return children[0];\n }\n return children;\n}\n\n/**\n * Normalize any JSXNode result from a component into a concrete VNode.\n */\nexport function normalizeComponentResult(result: VNode | JSXPrimitive | Iterable<JSXNode>): VNode {\n if (isVNode(result)) {\n return result;\n }\n\n if (typeof result === \"string\" || typeof result === \"number\") {\n return createTextVNode(result);\n }\n\n if (result == null || typeof result === \"boolean\") {\n return createTextVNode(\"\");\n }\n\n if (Array.isArray(result) || isIterable(result)) {\n const normalizedChildren = normalizeIterableChildren(result);\n return {\n type: Fragment,\n props: {},\n children: normalizedChildren,\n };\n }\n\n throw new Error(`Invalid component return type: ${typeof result}`);\n}\n\nfunction normalizeIterableChildren(children: Iterable<JSXNode>): VNode[] {\n const normalized: VNode[] = [];\n\n for (const child of children) {\n if (child == null || typeof child === \"boolean\") {\n continue;\n }\n\n if (Array.isArray(child) || isIterable(child)) {\n normalized.push(...normalizeIterableChildren(child as Iterable<JSXNode>));\n continue;\n }\n\n if (typeof child === \"string\" || typeof child === \"number\") {\n normalized.push(createTextVNode(child));\n continue;\n }\n\n if (isSignal(child)) {\n normalized.push(createSignalVNode(child));\n continue;\n }\n\n if (isVNode(child)) {\n normalized.push(child);\n continue;\n }\n\n throw new Error(`Invalid child in iterable: ${typeof child}`);\n }\n\n return normalized;\n}\n\nfunction isIterable(value: unknown): value is Iterable<unknown> {\n return value != null && typeof (value as any)[Symbol.iterator] === \"function\";\n}\n","import type { VNode, Ref } from \"./types\";\nimport { Fragment, Forward, Portal } from \"./types\";\nimport { isSignal } from \"@semajsx/signal\";\nimport { isVNode } from \"./vnode\";\nimport { resource, stream } from \"./helpers\";\nimport { type ContextMap, createComponentAPI } from \"./context\";\nimport { normalizeChildrenProp, normalizeComponentResult } from \"./component\";\n\n/**\n * Generic rendered node structure\n */\nexport interface RenderedNode<TNode> {\n vnode: VNode;\n node: TNode | null;\n subscriptions: Array<() => void>;\n children: RenderedNode<TNode>[];\n}\n\n/**\n * Operations strategy for different rendering targets\n */\nexport interface RenderStrategy<TNode> {\n /**\n * Create a text node\n */\n createTextNode(text: string): TNode;\n\n /**\n * Create a comment node (used for markers)\n */\n createComment(text: string): TNode;\n\n /**\n * Create an element node\n */\n createElement(type: string): TNode;\n\n /**\n * Get the parent node of a node\n */\n getParent(node: TNode): TNode | null;\n\n /**\n * Get the next sibling of a node\n */\n getNextSibling(node: TNode): TNode | null;\n\n /**\n * Insert a node before another node\n */\n insertBefore(parent: TNode, newNode: TNode, beforeNode: TNode | null): void;\n\n /**\n * Append child to parent\n */\n appendChild(parent: TNode, child: TNode): void;\n\n /**\n * Remove child from its parent\n */\n removeChild(node: TNode): void;\n\n /**\n * Replace old node with new node\n */\n replaceNode(oldNode: TNode, newNode: TNode): void;\n\n /**\n * Set a property on a node\n */\n setProperty(node: TNode, key: string, value: unknown): void;\n\n /**\n * Set a signal property on a node (returns unsubscribe function)\n */\n setSignalProperty(node: TNode, key: string, signal: any): () => void;\n\n /**\n * Optional: Set a ref on a node (returns cleanup function)\n * This is only used for DOM rendering\n */\n setRef?(node: TNode, ref: Ref<TNode>): () => void;\n\n /**\n * Optional: Try to reuse an existing node instead of replacing it\n * Returns true if the node was successfully reused\n * This is used for DOM optimization but not needed for terminal\n */\n tryReuseNode?(\n oldNode: TNode,\n newNode: TNode,\n oldRendered: RenderedNode<TNode>,\n newRendered: RenderedNode<TNode>,\n ): boolean;\n}\n\n/**\n * Check if a value is a Promise\n */\nexport function isPromise<T>(value: any): value is Promise<T> {\n return value && typeof value.then === \"function\";\n}\n\n/**\n * Check if a value is an AsyncIterator\n */\nexport function isAsyncIterator<T>(value: any): value is AsyncIterableIterator<T> {\n return value && typeof value[Symbol.asyncIterator] === \"function\";\n}\n\n/**\n * Core rendering logic - works for both DOM and Terminal\n */\nexport function createRenderer<TNode>(strategy: RenderStrategy<TNode>): {\n renderNode: (vnode: VNode, parentContext: ContextMap) => RenderedNode<TNode>;\n unmount: (node: RenderedNode<TNode>) => void;\n cleanupSubscriptions: (node: RenderedNode<TNode>) => void;\n} {\n /**\n * Helper to recursively collect all actual DOM nodes from a rendered node\n * Handles fragments and signal nodes that may not have their own DOM node\n */\n function collectNodes(rendered: RenderedNode<TNode>): TNode[] {\n const nodes: TNode[] = [];\n\n // Fragment: no node, only children\n if (rendered.vnode.type === Fragment) {\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Portal: children are rendered into a different container,\n // so they should not be collected in the parent tree\n if (rendered.vnode.type === Portal) {\n return nodes;\n }\n\n // Signal marker: include marker node + content children\n if (rendered.vnode.type === \"#signal\") {\n if (rendered.node) {\n nodes.push(rendered.node); // marker\n }\n // Collect content children (after marker)\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Regular elements and text nodes: just the node itself\n // Children are already attached to the node\n if (rendered.node) {\n nodes.push(rendered.node);\n }\n\n return nodes;\n }\n\n /**\n * Render a single VNode\n */\n function renderNode(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const { type } = vnode;\n\n // Text node\n if (type === \"#text\") {\n return renderTextNode(vnode);\n }\n\n // Signal VNode\n if (type === \"#signal\") {\n return renderSignalNode(vnode, parentContext);\n }\n\n // Fragment\n if (type === Fragment) {\n return renderFragment(vnode, parentContext);\n }\n\n // Portal\n if (type === Portal) {\n return renderPortal(vnode, parentContext);\n }\n\n // Forward\n if (type === Forward) {\n return renderForward(vnode, parentContext);\n }\n\n // Native node (pre-created element from external libraries)\n if (type === \"#native\") {\n return renderNativeNode(vnode);\n }\n\n // Component\n if (typeof type === \"function\") {\n return renderComponent(vnode, parentContext);\n }\n\n // Element\n if (typeof type === \"string\") {\n return renderElement(vnode, parentContext);\n }\n\n throw new Error(`Unknown VNode type: ${String(type)}`);\n }\n\n /**\n * Render a text node\n */\n function renderTextNode(vnode: VNode): RenderedNode<TNode> {\n const text = vnode.props?.nodeValue || \"\";\n const node = strategy.createTextNode(text);\n\n return {\n vnode,\n node,\n subscriptions: [],\n children: [],\n };\n }\n\n /**\n * Render a signal VNode\n */\n function renderSignalNode(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const signal = vnode.props?.signal;\n // Use captured context if available (for async components), otherwise parent context\n const contextForSignal = vnode.props?.context || parentContext;\n\n if (!isSignal(signal)) {\n throw new Error(\"Signal VNode must have a signal prop\");\n }\n\n // Create a comment node as a marker to track the signal's position in the DOM\n // This is necessary because signal content might be a Fragment (no direct node)\n // or might be empty initially\n const marker = strategy.createComment(\"signal\");\n\n // Get initial value and render it\n const initialValue = signal.value;\n let currentRendered = renderValueToNode(initialValue, contextForSignal);\n\n const subscriptions: Array<() => void> = [];\n\n // Subscribe to signal changes\n const unsubscribe = signal.subscribe((value) => {\n const newRendered = renderValueToNode(value, contextForSignal);\n\n // Collect actual DOM nodes from old and new rendered trees\n const oldContentNodes = collectNodes(currentRendered);\n const newContentNodes = collectNodes(newRendered);\n\n // Get the parent from the marker\n const parent = strategy.getParent(marker);\n if (!parent) {\n console.warn(\"[Signal] Marker not in DOM, cannot update\");\n return;\n }\n\n // Remove all old content nodes\n for (const node of oldContentNodes) {\n strategy.removeChild(node);\n }\n\n // Insert new content nodes after the marker\n let insertAfter = strategy.getNextSibling(marker);\n for (const node of newContentNodes) {\n strategy.insertBefore(parent, node, insertAfter);\n // Update insertAfter to maintain order (insert at the position after the last inserted)\n insertAfter = strategy.getNextSibling(node);\n }\n\n // Unmount old rendered tree: cleans up subscriptions AND removes\n // portal children from their containers (cleanupSubscriptions alone\n // would leave portal content orphaned in the portal container)\n unmount(currentRendered);\n\n currentRendered = newRendered;\n });\n\n subscriptions.push(unsubscribe);\n\n return {\n vnode,\n node: marker,\n subscriptions,\n children: currentRendered ? [currentRendered] : [],\n };\n }\n\n /**\n * Helper to convert a signal value to a rendered node\n */\n function renderValueToNode(value: unknown, context: ContextMap): RenderedNode<TNode> {\n let newVNode: VNode;\n\n // Convert value to VNode\n if (isVNode(value)) {\n newVNode = value;\n } else if (Array.isArray(value)) {\n // Support arrays - wrap in Fragment automatically\n // This allows: computed(todos, list => list.map(...))\n // Without requiring manual Fragment wrapping\n newVNode = {\n type: Fragment,\n props: {},\n children: value.filter(isVNode), // Filter out non-VNodes\n };\n } else if (typeof value === \"string\" || typeof value === \"number\") {\n newVNode = {\n type: \"#text\",\n props: { nodeValue: String(value) },\n children: [],\n };\n } else if (value == null || typeof value === \"boolean\") {\n // Render empty text for null/undefined/boolean\n // This works for both DOM and terminal\n newVNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n } else {\n throw new Error(`Invalid signal value type: ${typeof value}`);\n }\n\n return renderNode(newVNode, context);\n }\n\n /**\n * Render a fragment\n */\n function renderFragment(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const children = vnode.children.map((child) => renderNode(child, parentContext));\n\n // Fragment has no node of its own\n return {\n vnode,\n node: null,\n subscriptions: [],\n children,\n };\n }\n\n /**\n * Render a portal\n * Portal renders its children into a different container\n */\n function renderPortal(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const container = vnode.props?.container;\n\n if (!container) {\n throw new Error(\"Portal must have a container prop\");\n }\n\n // Render children with same context\n const children = vnode.children.map((child) => renderNode(child, parentContext));\n\n // Append all child nodes to the portal container (recursively handles fragments)\n for (const child of children) {\n const nodes = collectNodes(child);\n for (const node of nodes) {\n strategy.appendChild(container, node);\n }\n }\n\n // Portal has no node in the parent tree\n return {\n vnode,\n node: null,\n subscriptions: [],\n children,\n };\n }\n\n /**\n * Merge Forward's props into the child's props\n * - class/className: concatenated (array)\n * - style: merged objects (Forward overrides per-property)\n * - on* events: chained (both handlers run)\n * - other props: Forward overrides child\n */\n function mergeForwardProps(\n childProps: Record<string, any>,\n forwardProps: Record<string, any>,\n ): Record<string, any> {\n const merged = { ...childProps };\n\n for (const [key, value] of Object.entries(forwardProps)) {\n if (key === \"key\" || key === \"children\") continue;\n\n if ((key === \"class\" || key === \"className\") && merged[key] != null) {\n // Concatenate class values as array — renderers resolve arrays\n merged[key] = [merged[key], value];\n } else if (key === \"style\" && typeof merged[key] === \"object\" && typeof value === \"object\") {\n // Merge style objects (Forward properties override)\n merged[key] = { ...merged[key], ...value };\n } else if (\n key.startsWith(\"on\") &&\n typeof value === \"function\" &&\n typeof merged[key] === \"function\"\n ) {\n // Chain event handlers: Forward's runs first, then child's\n const existing = merged[key];\n merged[key] = (...args: unknown[]) => {\n value(...args);\n existing(...args);\n };\n } else {\n merged[key] = value;\n }\n }\n\n return merged;\n }\n\n /**\n * Render a Forward node\n * Forward merges its props onto its single child and renders it directly\n */\n function renderForward(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const child = vnode.children[0];\n\n if (!child || vnode.children.length !== 1) {\n throw new Error(\"Forward must have exactly one child element\");\n }\n\n const forwardProps = vnode.props || {};\n\n // Create a new VNode with merged props\n const mergedChild: VNode = {\n ...child,\n props: mergeForwardProps(child.props || {}, forwardProps),\n };\n\n // Render the merged child directly — Forward is completely transparent\n return renderNode(mergedChild, parentContext);\n }\n\n /**\n * Render a native node (pre-created element from external libraries)\n * The element is used directly without creating a new one.\n * Additional props are applied via the strategy's setProperty/setSignalProperty.\n */\n function renderNativeNode(vnode: VNode): RenderedNode<TNode> {\n const nativeNode = vnode.props?.__nativeNode as TNode;\n\n if (!nativeNode) {\n throw new Error(\"Native VNode must have an __nativeNode prop\");\n }\n\n const subscriptions: Array<() => void> = [];\n\n // Apply additional props to the native node\n const props = vnode.props || {};\n for (const [key, value] of Object.entries(props)) {\n if (key === \"__nativeNode\" || key === \"key\" || key === \"children\") continue;\n\n if (isSignal(value)) {\n const unsub = strategy.setSignalProperty(nativeNode, key, value);\n subscriptions.push(unsub);\n } else {\n strategy.setProperty(nativeNode, key, value);\n }\n }\n\n return {\n vnode,\n node: nativeNode,\n subscriptions,\n children: [],\n };\n }\n\n /**\n * Render a component\n */\n function renderComponent(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n if (typeof vnode.type !== \"function\") {\n throw new Error(\"Component vnode must have a function type\");\n }\n\n const Component = vnode.type;\n const props = {\n ...vnode.props,\n children: normalizeChildrenProp(vnode.children),\n };\n\n // Prepare current component's context\n let currentContext = parentContext;\n\n // Check if this is a Context Provider\n const isContextProvider = (Component as any).__isContextProvider;\n\n if (isContextProvider) {\n // Context Provider: create new context map with provided values\n currentContext = new Map(parentContext);\n const provide = (props as any).provide;\n\n if (provide) {\n // Check if it's a single provide [Context, value] or multiple [[Context, value], ...]\n const isSingle = provide.length === 2 && typeof provide[0] === \"symbol\";\n\n if (isSingle) {\n // Single: [Context, value]\n const [context, value] = provide;\n currentContext.set(context, value);\n } else {\n // Multiple: [[Context, value], ...]\n for (const [context, value] of provide) {\n currentContext.set(context, value);\n }\n }\n }\n }\n\n // Create ComponentAPI\n const ctx = createComponentAPI(currentContext);\n\n // Call component function with props and ctx\n const result = Component(props, ctx);\n\n // Handle async component (Promise<VNode>)\n if (isPromise(result)) {\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = resource(result, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: currentContext },\n children: [],\n };\n const rendered = renderNode(signalVNode, currentContext);\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n // Handle async generator component (AsyncIterableIterator<VNode>)\n if (isAsyncIterator(result)) {\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = stream(result, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: currentContext },\n children: [],\n };\n const rendered = renderNode(signalVNode, currentContext);\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n // Handle signal component (Signal<VNode>)\n if (isSignal(result)) {\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: result, context: currentContext },\n children: [],\n };\n const rendered = renderNode(signalVNode, currentContext);\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n // Handle normal sync component (VNode)\n const normalizedResult = normalizeComponentResult(result);\n const rendered = renderNode(normalizedResult, currentContext);\n\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n /**\n * Render an element\n */\n function renderElement(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n if (typeof vnode.type !== \"string\") {\n throw new Error(\"Element vnode must have a string type\");\n }\n\n const element = strategy.createElement(vnode.type);\n const subscriptions: Array<() => void> = [];\n\n // Apply props\n const props = vnode.props || {};\n for (const [key, value] of Object.entries(props)) {\n if (key === \"key\" || key === \"children\") continue;\n\n // Handle ref separately\n if (key === \"ref\") {\n if (strategy.setRef && value != null) {\n const cleanup = strategy.setRef(element, value as Ref<TNode>);\n subscriptions.push(cleanup);\n }\n continue;\n }\n\n if (isSignal(value)) {\n const unsub = strategy.setSignalProperty(element, key, value);\n subscriptions.push(unsub);\n } else {\n strategy.setProperty(element, key, value);\n }\n }\n\n // Render children with same context\n const children = vnode.children.map((child) => renderNode(child, parentContext));\n\n // Append all child nodes (recursively handles fragments and signal wrappers)\n for (const child of children) {\n const nodes = collectNodes(child);\n for (const node of nodes) {\n strategy.appendChild(element, node);\n }\n }\n\n return {\n vnode,\n node: element,\n subscriptions,\n children,\n };\n }\n\n /**\n * Unmount a rendered node\n */\n function unmount(node: RenderedNode<TNode>): void {\n // Cleanup subscriptions\n for (const unsub of node.subscriptions) {\n unsub();\n }\n\n // Recursively unmount children\n for (const child of node.children) {\n unmount(child);\n }\n\n // Remove from tree\n if (node.node) {\n strategy.removeChild(node.node);\n }\n }\n\n /**\n * Clean up subscriptions without removing nodes from tree\n */\n function cleanupSubscriptions(node: RenderedNode<TNode>): void {\n // Cleanup subscriptions\n for (const unsub of node.subscriptions) {\n unsub();\n }\n\n // Recursively cleanup children\n for (const child of node.children) {\n cleanupSubscriptions(child);\n }\n }\n\n return {\n renderNode: renderNode,\n unmount: unmount,\n cleanupSubscriptions: cleanupSubscriptions,\n };\n}\n"],"mappings":";;;;;;;;AAKA,MAAa,WAAmB,OAAO,IAAI,mBAAmB;;;;AAK9D,MAAa,SAAiB,OAAO,IAAI,iBAAiB;;;;;AAM1D,MAAa,UAAkB,OAAO,IAAI,kBAAkB;;;;;;;ACR5D,SAAgB,EACd,MACA,OACA,GAAG,UACI;AACP,QAAO;EACL;EACA,OAAO,SAAS,EAAE;EAClB,UAAU,kBAAkB,SAAS;EACrC,KAAK,OAAO;EACb;;;;;AAMH,SAAgB,gBAAgB,MAA8B;AAC5D,QAAO;EACL,MAAM;EACN,OAAO,EAAE,WAAW,OAAO,KAAK,EAAE;EAClC,UAAU,EAAE;EACb;;;;;AAMH,SAAgB,kBAAkB,QAAgC;AAChE,QAAO;EACL,MAAM;EACN,OAAO,EAAE,QAAQ;EACjB,UAAU,EAAE;EACb;;;;;AAMH,SAAS,kBAAkB,UAA8B;CACvD,MAAM,SAAkB,EAAE;AAE1B,MAAK,MAAM,SAAS,UAAU;AAC5B,MAAI,SAAS,QAAQ,OAAO,UAAU,UAEpC;AAGF,MAAI,MAAM,QAAQ,MAAM,CAEtB,QAAO,KAAK,GAAG,kBAAkB,MAAM,CAAC;WAC/B,OAAO,UAAU,YAAY,OAAO,UAAU,SAEvD,QAAO,KAAK,gBAAgB,MAAM,CAAC;WAC1B,SAAS,MAAM,CAExB,QAAO,KAAK,kBAAkB,MAAM,CAAC;WAC5B,QAAQ,MAAM,CAEvB,QAAO,KAAK,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AAO;GACL;GACA,MAAM;GACN;GACA;GACD;;;;;CAMH,SAAS,QAAQ,MAAiC;AAEhD,OAAK,MAAM,SAAS,KAAK,cACvB,QAAO;AAIT,OAAK,MAAM,SAAS,KAAK,SACvB,SAAQ,MAAM;AAIhB,MAAI,KAAK,KACP,UAAS,YAAY,KAAK,KAAK;;;;;CAOnC,SAAS,qBAAqB,MAAiC;AAE7D,OAAK,MAAM,SAAS,KAAK,cACvB,QAAO;AAIT,OAAK,MAAM,SAAS,KAAK,SACvB,sBAAqB,MAAM;;AAI/B,QAAO;EACO;EACH;EACa;EACvB"}
1
+ {"version":3,"file":"src-Cv4rRVzv.mjs","names":[],"sources":["../../core/src/types.ts","../../core/src/vnode.ts","../../core/src/shared/island-marker.ts","../../core/src/context.ts","../../core/src/helpers.ts","../../core/src/jsx.ts","../../core/src/component.ts","../../core/src/render-core.ts"],"sourcesContent":["import type { ReadableSignal, WritableSignal } from \"./signal\";\n\n/**\n * Special VNode type for fragment support\n */\nexport const Fragment: symbol = Symbol.for(\"semajsx.fragment\");\n\n/**\n * Special VNode type for portal support\n */\nexport const Portal: symbol = Symbol.for(\"semajsx.portal\");\n\n/**\n * Special VNode type for forward support\n * Forward merges its props onto its single child element without producing a DOM node\n */\nexport const Forward: symbol = Symbol.for(\"semajsx.forward\");\n\n/**\n * VNode types\n * - The runtime VNode tree always resolves to these `type` values\n */\nexport type VNodeType = string | Component<any> | typeof Fragment | typeof Portal | typeof Forward;\n\n/**\n * VNode: The basic unit of the runtime render tree\n * - `type`: the element/component type\n * - `props`: attributes or props passed to the node (may be null)\n * - `children`: resolved child nodes (always normalized to VNode[] at render time)\n */\nexport interface VNode {\n type: VNodeType;\n props: Record<string, any> | null;\n children: VNode[];\n key?: string | number | null;\n}\n\n/**\n * Primitive values allowed in JSX\n * - These are normalized during VNode construction\n */\nexport type JSXPrimitive = string | number | boolean | null | undefined;\n\n/**\n * A JSXNode represents any valid \"JSX expression result\"\n * - Could be a raw VNode/primitive, or wrapped in a reactive/async container\n */\nexport type JSXNode =\n | VNode\n | JSXPrimitive\n | Iterable<JSXNode>\n | ReadableSignal<JSXNode>\n | Promise<JSXNode>\n | AsyncIterableIterator<JSXNode>;\n\n/**\n * Component type\n * - Optional `ctx` parameter allows passing in custom API/runtime helpers\n */\nexport type Component<P = any> = (props: P, ctx?: ComponentAPI) => JSXNode;\n\n/**\n * ComponentAPI - Runtime API available to components via second parameter\n */\nexport interface ComponentAPI {\n /**\n * Inject a context value\n * @param context - The context to inject\n * @returns The current value of the context, or undefined if not provided\n */\n inject<T>(context: Context<T>): T | undefined;\n}\n\n/**\n * Ref types\n */\n\n/**\n * Ref - can be a WritableSignal or a callback function\n * This allows both reactive refs and imperative refs\n */\nexport type Ref<T> = WritableSignal<T | null> | ((instance: T | null) => void);\n\n/**\n * Context types\n */\n\n/**\n * Context - a typed Symbol for identifying context\n */\nexport type Context<T> = symbol & { __type?: T };\n\n/**\n * Context provide entry: [Context, value]\n */\nexport type ContextProvide<T = any> = [Context<T>, T];\n\n/**\n * Context component props - supports single or multiple context provides\n */\nexport interface ContextProps {\n // Single context: [ThemeContext, theme]\n // Multiple contexts: [[ThemeContext, theme], [UserContext, user]]\n provide: ContextProvide | ContextProvide[];\n children?: JSXNode;\n}\n\n/**\n * Helper type to allow Signal values for any attribute\n */\nexport type SignalOr<T> = T | ReadableSignal<T>;\n\n/**\n * Makes all properties in T accept Signal values\n * Excludes event handlers (functions) and children\n */\nexport type WithSignals<T> = {\n [K in keyof T]: K extends `on${string}`\n ? T[K] // Event handlers don't need Signal wrapper\n : K extends \"children\"\n ? T[K] // Children handled separately\n : T[K] extends (...args: any[]) => any\n ? T[K] // Other functions don't need Signal wrapper\n : SignalOr<T[K]>;\n};\n\n/**\n * Adds key property to element attributes for list reconciliation\n */\nexport type WithKey<T> = T & {\n key?: string | number;\n};\n","import type { JSXNode, VNode, VNodeType } from \"./types\";\nimport type { Signal } from \"@semajsx/signal\";\nimport { Fragment } from \"./types\";\nimport { isSignal } from \"@semajsx/signal\";\n\n/**\n * Create a VNode (Virtual Node)\n */\nexport function h(\n type: VNodeType,\n props: Record<string, any> | null,\n ...children: JSXNode[]\n): VNode {\n return {\n type,\n props: props || {},\n children: normalizeChildren(children),\n key: props?.key,\n };\n}\n\n/**\n * Create a text VNode\n */\nexport function createTextVNode(text: string | number): VNode {\n return {\n type: \"#text\",\n props: { nodeValue: String(text) },\n children: [],\n };\n}\n\n/**\n * Create a signal VNode wrapper\n */\nexport function createSignalVNode(signal: Signal<unknown>): VNode {\n return {\n type: \"#signal\",\n props: { signal },\n children: [],\n };\n}\n\n/**\n * Normalize children into an array of VNodes\n */\nfunction normalizeChildren(children: JSXNode[]): VNode[] {\n const result: VNode[] = [];\n\n for (const child of children) {\n if (child == null || typeof child === \"boolean\") {\n // Skip nullish and boolean values\n continue;\n }\n\n if (Array.isArray(child)) {\n // Recursively flatten arrays\n result.push(...normalizeChildren(child));\n } else if (typeof child === \"string\" || typeof child === \"number\") {\n // Convert primitives to text nodes\n result.push(createTextVNode(child));\n } else if (isSignal(child)) {\n // Wrap signals in special signal nodes\n result.push(createSignalVNode(child));\n } else if (isVNode(child)) {\n // Already a VNode\n result.push(child);\n } else {\n // Unknown type, skip\n console.warn(\"Unknown child type:\", typeof child);\n }\n }\n\n return result;\n}\n\n/**\n * Check if a value is a VNode\n */\nexport function isVNode(value: unknown): value is VNode {\n return (\n value != null &&\n typeof value === \"object\" &&\n \"type\" in value &&\n \"props\" in value &&\n \"children\" in value\n );\n}\n\n/**\n * Create a Fragment\n */\nexport function createFragment(children: JSXNode[]): VNode {\n return h(Fragment, null, ...children);\n}\n","/**\n * Unique symbol to mark Island components\n * This symbol is used to identify components that should be hydrated on the client\n */\nexport const ISLAND_MARKER: symbol = Symbol.for(\"semajsx.island\");\n","/**\n * Context API implementation\n */\n\nimport { h } from \"./vnode\";\nimport { Fragment } from \"./types\";\nimport type { ComponentAPI, Context as ContextType, ContextProps, VNode } from \"./types\";\n\n// Context map type - stores context values for current render environment\nexport type ContextMap = Map<symbol, any>;\n\n/**\n * Create a new Context (returns a typed Symbol)\n *\n * @param name - Optional name for debugging (defaults to \"anonymous\")\n * @returns Context symbol\n *\n * @example\n * ```typescript\n * const ThemeContext = context<Theme>();\n * const UserContext = context<User>('user'); // With debug name\n *\n * <Context provide={[ThemeContext, theme]}>\n * <App />\n * </Context>\n * ```\n */\nexport function context<T>(name?: string): ContextType<T> {\n const debugName = name || \"anonymous\";\n return Symbol(debugName) as ContextType<T>;\n}\n\n/**\n * Context component - provides context values to child components\n *\n * @example\n * ```typescript\n * // Single context\n * <Context provide={[ThemeContext, theme]}>\n * <App />\n * </Context>\n *\n * // Multiple contexts\n * <Context provide={[\n * [ThemeContext, theme],\n * [UserContext, user]\n * ]}>\n * <App />\n * </Context>\n * ```\n */\nexport function Context(props: ContextProps): VNode {\n const children = props.children\n ? Array.isArray(props.children)\n ? props.children\n : [props.children]\n : [];\n return h(Fragment, null, ...children);\n}\n\n// Mark as special context provider component\n(Context as any).__isContextProvider = true;\n\n/**\n * Create ComponentAPI instance for a component\n *\n * @param contextMap - The context map for current render environment\n * @returns ComponentAPI instance\n */\nexport function createComponentAPI(contextMap: ContextMap): ComponentAPI {\n return {\n inject<T>(context: ContextType<T>): T | undefined {\n return contextMap.get(context);\n },\n };\n}\n","import type { JSXNode } from \"./types\";\nimport type { Signal } from \"@semajsx/signal\";\nimport { computed, signal } from \"@semajsx/signal\";\n\n/**\n * Conditional rendering helper\n *\n * Renders content when condition signal is true, nothing when false.\n *\n * @example\n * // With VNode\n * const hint = when(showHint, <text>Press Ctrl+C to exit</text>);\n *\n * @example\n * // With function (lazy evaluation)\n * const hint = when(showHint, () => <text>Press Ctrl+C to exit</text>);\n */\nexport function when(\n condition: Signal<boolean>,\n content: JSXNode | (() => JSXNode),\n): Signal<JSXNode | null> {\n return computed([condition], (show) => {\n if (!show) return null;\n return typeof content === \"function\" ? content() : content;\n });\n}\n\n/**\n * Async resource helper for Promise<VNode>\n *\n * Renders pending content (or null) while the promise is pending, then renders\n * the resolved VNode. Handle errors in the promise itself using .catch().\n *\n * @example\n * // Handle everything in the promise\n * const content = resource(\n * fetchData()\n * .then(data => <text>{data}</text>)\n * .catch(err => <text color=\"red\">Error: {err.message}</text>)\n * );\n *\n * @example\n * // With optional pending content\n * const content = resource(\n * fetchData().then(data => <text>{data}</text>),\n * <text>Loading...</text>\n * );\n */\nexport function resource(promise: Promise<JSXNode>, pending?: JSXNode): Signal<JSXNode | null> {\n const content = signal<JSXNode | null>(pending || null);\n\n promise\n .then((result) => {\n content.value = result;\n })\n .catch((err) => {\n console.error(\"Unhandled promise rejection in resource():\", err);\n });\n\n return content;\n}\n\n/**\n * Async stream helper for AsyncIterable<VNode>\n *\n * Renders each yielded VNode from the async iterator, replacing the previous\n * content with each new value.\n *\n * @example\n * async function* generateContent() {\n * yield <text>Loading...</text>;\n * const data = await fetchData();\n * yield <text>Data: {data}</text>;\n * }\n *\n * const content = stream(generateContent());\n */\nexport function stream(\n iterator: AsyncIterable<JSXNode>,\n pending?: JSXNode,\n): Signal<JSXNode | null> {\n const content = signal<JSXNode | null>(pending || null);\n\n (async () => {\n try {\n for await (const vnode of iterator) {\n content.value = vnode;\n }\n } catch (err) {\n console.error(\"Error in stream():\", err);\n }\n })();\n\n return content;\n}\n","import { VNode, VNodeType } from \"./types\";\nimport { h } from \"./vnode\";\n\nexport function jsx(type: VNodeType, props: any, key?: any): VNode {\n const { children, ...restProps } = props || {};\n\n if (key !== undefined) {\n restProps.key = key;\n }\n\n if (children !== undefined) {\n return h(type, restProps, children);\n }\n\n return h(type, restProps);\n}\n\nexport function jsxs(type: VNodeType, props: any, key?: any): VNode {\n const { children, ...restProps } = props || {};\n\n if (key !== undefined) {\n restProps.key = key;\n }\n\n if (children !== undefined) {\n const childArray = Array.isArray(children) ? children : [children];\n return h(type, restProps, ...childArray);\n }\n\n return h(type, restProps);\n}\n","import type { JSXNode, JSXPrimitive, VNode } from \"./types\";\nimport { Fragment } from \"./types\";\nimport { isSignal } from \"@semajsx/signal\";\nimport { createSignalVNode, createTextVNode, isVNode } from \"./vnode\";\n\n/**\n * Normalize the `children` prop passed to components so it mirrors React semantics.\n * - 0 children => undefined\n * - 1 child => the child itself\n * - >1 children => array\n */\nexport function normalizeChildrenProp(children: VNode[]): VNode | VNode[] | undefined {\n if (children.length === 0) {\n return undefined;\n }\n if (children.length === 1) {\n return children[0];\n }\n return children;\n}\n\n/**\n * Normalize any JSXNode result from a component into a concrete VNode.\n */\nexport function normalizeComponentResult(result: VNode | JSXPrimitive | Iterable<JSXNode>): VNode {\n if (isVNode(result)) {\n return result;\n }\n\n if (typeof result === \"string\" || typeof result === \"number\") {\n return createTextVNode(result);\n }\n\n if (result == null || typeof result === \"boolean\") {\n return createTextVNode(\"\");\n }\n\n if (Array.isArray(result) || isIterable(result)) {\n const normalizedChildren = normalizeIterableChildren(result);\n return {\n type: Fragment,\n props: {},\n children: normalizedChildren,\n };\n }\n\n throw new Error(`Invalid component return type: ${typeof result}`);\n}\n\nfunction normalizeIterableChildren(children: Iterable<JSXNode>): VNode[] {\n const normalized: VNode[] = [];\n\n for (const child of children) {\n if (child == null || typeof child === \"boolean\") {\n continue;\n }\n\n if (Array.isArray(child) || isIterable(child)) {\n normalized.push(...normalizeIterableChildren(child as Iterable<JSXNode>));\n continue;\n }\n\n if (typeof child === \"string\" || typeof child === \"number\") {\n normalized.push(createTextVNode(child));\n continue;\n }\n\n if (isSignal(child)) {\n normalized.push(createSignalVNode(child));\n continue;\n }\n\n if (isVNode(child)) {\n normalized.push(child);\n continue;\n }\n\n throw new Error(`Invalid child in iterable: ${typeof child}`);\n }\n\n return normalized;\n}\n\nfunction isIterable(value: unknown): value is Iterable<unknown> {\n return value != null && typeof (value as any)[Symbol.iterator] === \"function\";\n}\n","import type { VNode, Ref } from \"./types\";\nimport { Fragment, Forward, Portal } from \"./types\";\nimport { isSignal } from \"@semajsx/signal\";\nimport { isVNode } from \"./vnode\";\nimport { resource, stream } from \"./helpers\";\nimport { type ContextMap, createComponentAPI } from \"./context\";\nimport { normalizeChildrenProp, normalizeComponentResult } from \"./component\";\n\n/**\n * Generic rendered node structure\n */\nexport interface RenderedNode<TNode> {\n vnode: VNode;\n node: TNode | null;\n subscriptions: Array<() => void>;\n children: RenderedNode<TNode>[];\n}\n\n/**\n * Operations strategy for different rendering targets\n */\nexport interface RenderStrategy<TNode> {\n /**\n * Create a text node\n */\n createTextNode(text: string): TNode;\n\n /**\n * Create a comment node (used for markers)\n */\n createComment(text: string): TNode;\n\n /**\n * Create an element node\n */\n createElement(type: string): TNode;\n\n /**\n * Get the parent node of a node\n */\n getParent(node: TNode): TNode | null;\n\n /**\n * Get the next sibling of a node\n */\n getNextSibling(node: TNode): TNode | null;\n\n /**\n * Insert a node before another node\n */\n insertBefore(parent: TNode, newNode: TNode, beforeNode: TNode | null): void;\n\n /**\n * Append child to parent\n */\n appendChild(parent: TNode, child: TNode): void;\n\n /**\n * Remove child from its parent\n */\n removeChild(node: TNode): void;\n\n /**\n * Replace old node with new node\n */\n replaceNode(oldNode: TNode, newNode: TNode): void;\n\n /**\n * Set a property on a node\n */\n setProperty(node: TNode, key: string, value: unknown): void;\n\n /**\n * Set a signal property on a node (returns unsubscribe function)\n */\n setSignalProperty(node: TNode, key: string, signal: any): () => void;\n\n /**\n * Optional: Set a ref on a node (returns cleanup function)\n * This is only used for DOM rendering\n */\n setRef?(node: TNode, ref: Ref<TNode>): () => void;\n\n /**\n * Optional: Try to reuse an existing node instead of replacing it\n * Returns true if the node was successfully reused\n * This is used for DOM optimization but not needed for terminal\n */\n tryReuseNode?(\n oldNode: TNode,\n newNode: TNode,\n oldRendered: RenderedNode<TNode>,\n newRendered: RenderedNode<TNode>,\n ): boolean;\n}\n\n/**\n * Check if a value is a Promise\n */\nexport function isPromise<T>(value: any): value is Promise<T> {\n return value && typeof value.then === \"function\";\n}\n\n/**\n * Check if a value is an AsyncIterator\n */\nexport function isAsyncIterator<T>(value: any): value is AsyncIterableIterator<T> {\n return value && typeof value[Symbol.asyncIterator] === \"function\";\n}\n\n/**\n * Core rendering logic - works for both DOM and Terminal\n */\nexport function createRenderer<TNode>(strategy: RenderStrategy<TNode>): {\n renderNode: (vnode: VNode, parentContext: ContextMap) => RenderedNode<TNode>;\n unmount: (node: RenderedNode<TNode>) => void;\n cleanupSubscriptions: (node: RenderedNode<TNode>) => void;\n} {\n /**\n * Helper to recursively collect all actual DOM nodes from a rendered node\n * Handles fragments and signal nodes that may not have their own DOM node\n */\n function collectNodes(rendered: RenderedNode<TNode>): TNode[] {\n const nodes: TNode[] = [];\n\n // Fragment: no node, only children\n if (rendered.vnode.type === Fragment) {\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Portal: children are rendered into a different container,\n // so they should not be collected in the parent tree\n if (rendered.vnode.type === Portal) {\n return nodes;\n }\n\n // Signal marker: include marker node + content children\n if (rendered.vnode.type === \"#signal\") {\n if (rendered.node) {\n nodes.push(rendered.node); // marker\n }\n // Collect content children (after marker)\n for (const child of rendered.children) {\n nodes.push(...collectNodes(child));\n }\n return nodes;\n }\n\n // Regular elements and text nodes: just the node itself\n // Children are already attached to the node\n if (rendered.node) {\n nodes.push(rendered.node);\n }\n\n return nodes;\n }\n\n /**\n * Render a single VNode\n */\n function renderNode(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const { type } = vnode;\n\n // Text node\n if (type === \"#text\") {\n return renderTextNode(vnode);\n }\n\n // Signal VNode\n if (type === \"#signal\") {\n return renderSignalNode(vnode, parentContext);\n }\n\n // Fragment\n if (type === Fragment) {\n return renderFragment(vnode, parentContext);\n }\n\n // Portal\n if (type === Portal) {\n return renderPortal(vnode, parentContext);\n }\n\n // Forward\n if (type === Forward) {\n return renderForward(vnode, parentContext);\n }\n\n // Native node (pre-created element from external libraries)\n if (type === \"#native\") {\n return renderNativeNode(vnode);\n }\n\n // Component\n if (typeof type === \"function\") {\n return renderComponent(vnode, parentContext);\n }\n\n // Element\n if (typeof type === \"string\") {\n return renderElement(vnode, parentContext);\n }\n\n throw new Error(`Unknown VNode type: ${String(type)}`);\n }\n\n /**\n * Render a text node\n */\n function renderTextNode(vnode: VNode): RenderedNode<TNode> {\n const text = vnode.props?.nodeValue || \"\";\n const node = strategy.createTextNode(text);\n\n return {\n vnode,\n node,\n subscriptions: [],\n children: [],\n };\n }\n\n /**\n * Render a signal VNode\n */\n function renderSignalNode(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const signal = vnode.props?.signal;\n // Use captured context if available (for async components), otherwise parent context\n const contextForSignal = vnode.props?.context || parentContext;\n\n if (!isSignal(signal)) {\n throw new Error(\"Signal VNode must have a signal prop\");\n }\n\n // Create a comment node as a marker to track the signal's position in the DOM\n // This is necessary because signal content might be a Fragment (no direct node)\n // or might be empty initially\n const marker = strategy.createComment(\"signal\");\n\n // Get initial value and render it\n const initialValue = signal.value;\n let currentRendered = renderValueToNode(initialValue, contextForSignal);\n\n const subscriptions: Array<() => void> = [];\n\n // Subscribe to signal changes\n const unsubscribe = signal.subscribe((value) => {\n const newRendered = renderValueToNode(value, contextForSignal);\n\n // Collect actual DOM nodes from old and new rendered trees\n const oldContentNodes = collectNodes(currentRendered);\n const newContentNodes = collectNodes(newRendered);\n\n // Get the parent from the marker\n const parent = strategy.getParent(marker);\n if (!parent) {\n console.warn(\"[Signal] Marker not in DOM, cannot update\");\n return;\n }\n\n // Remove all old content nodes\n for (const node of oldContentNodes) {\n strategy.removeChild(node);\n }\n\n // Insert new content nodes after the marker\n let insertAfter = strategy.getNextSibling(marker);\n for (const node of newContentNodes) {\n strategy.insertBefore(parent, node, insertAfter);\n // Update insertAfter to maintain order (insert at the position after the last inserted)\n insertAfter = strategy.getNextSibling(node);\n }\n\n // Unmount old rendered tree: cleans up subscriptions AND removes\n // portal children from their containers (cleanupSubscriptions alone\n // would leave portal content orphaned in the portal container)\n unmount(currentRendered);\n\n currentRendered = newRendered;\n });\n\n subscriptions.push(unsubscribe);\n\n return {\n vnode,\n node: marker,\n subscriptions,\n children: currentRendered ? [currentRendered] : [],\n };\n }\n\n /**\n * Helper to convert a signal value to a rendered node\n */\n function renderValueToNode(value: unknown, context: ContextMap): RenderedNode<TNode> {\n let newVNode: VNode;\n\n // Convert value to VNode\n if (isVNode(value)) {\n newVNode = value;\n } else if (Array.isArray(value)) {\n // Support arrays - wrap in Fragment automatically\n // This allows: computed(todos, list => list.map(...))\n // Without requiring manual Fragment wrapping\n newVNode = {\n type: Fragment,\n props: {},\n children: value.filter(isVNode), // Filter out non-VNodes\n };\n } else if (typeof value === \"string\" || typeof value === \"number\") {\n newVNode = {\n type: \"#text\",\n props: { nodeValue: String(value) },\n children: [],\n };\n } else if (value == null || typeof value === \"boolean\") {\n // Render empty text for null/undefined/boolean\n // This works for both DOM and terminal\n newVNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n } else {\n throw new Error(`Invalid signal value type: ${typeof value}`);\n }\n\n return renderNode(newVNode, context);\n }\n\n /**\n * Render a fragment\n */\n function renderFragment(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const children = vnode.children.map((child) => renderNode(child, parentContext));\n\n // Fragment has no node of its own\n return {\n vnode,\n node: null,\n subscriptions: [],\n children,\n };\n }\n\n /**\n * Render a portal\n * Portal renders its children into a different container\n */\n function renderPortal(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const container = vnode.props?.container;\n\n if (!container) {\n throw new Error(\"Portal must have a container prop\");\n }\n\n // Render children with same context\n const children = vnode.children.map((child) => renderNode(child, parentContext));\n\n // Append all child nodes to the portal container (recursively handles fragments)\n for (const child of children) {\n const nodes = collectNodes(child);\n for (const node of nodes) {\n strategy.appendChild(container, node);\n }\n }\n\n // Portal has no node in the parent tree\n return {\n vnode,\n node: null,\n subscriptions: [],\n children,\n };\n }\n\n /**\n * Merge Forward's props into the child's props\n * - class/className: concatenated (array)\n * - style: merged objects (Forward overrides per-property)\n * - on* events: chained (both handlers run)\n * - other props: Forward overrides child\n */\n function mergeForwardProps(\n childProps: Record<string, any>,\n forwardProps: Record<string, any>,\n ): Record<string, any> {\n const merged = { ...childProps };\n\n for (const [key, value] of Object.entries(forwardProps)) {\n if (key === \"key\" || key === \"children\") continue;\n\n if ((key === \"class\" || key === \"className\") && merged[key] != null) {\n // Concatenate class values as array — renderers resolve arrays\n merged[key] = [merged[key], value];\n } else if (key === \"style\" && typeof merged[key] === \"object\" && typeof value === \"object\") {\n // Merge style objects (Forward properties override)\n merged[key] = { ...merged[key], ...value };\n } else if (\n key.startsWith(\"on\") &&\n typeof value === \"function\" &&\n typeof merged[key] === \"function\"\n ) {\n // Chain event handlers: Forward's runs first, then child's\n const existing = merged[key];\n merged[key] = (...args: unknown[]) => {\n value(...args);\n existing(...args);\n };\n } else {\n merged[key] = value;\n }\n }\n\n return merged;\n }\n\n /**\n * Render a Forward node\n * Forward merges its props onto its single child and renders it directly\n */\n function renderForward(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n const child = vnode.children[0];\n\n if (!child || vnode.children.length !== 1) {\n throw new Error(\"Forward must have exactly one child element\");\n }\n\n const forwardProps = vnode.props || {};\n\n // Create a new VNode with merged props\n const mergedChild: VNode = {\n ...child,\n props: mergeForwardProps(child.props || {}, forwardProps),\n };\n\n // Render the merged child directly — Forward is completely transparent\n return renderNode(mergedChild, parentContext);\n }\n\n /**\n * Render a native node (pre-created element from external libraries)\n * The element is used directly without creating a new one.\n * Additional props are applied via the strategy's setProperty/setSignalProperty.\n */\n function renderNativeNode(vnode: VNode): RenderedNode<TNode> {\n const nativeNode = vnode.props?.__nativeNode as TNode;\n\n if (!nativeNode) {\n throw new Error(\"Native VNode must have an __nativeNode prop\");\n }\n\n const subscriptions: Array<() => void> = [];\n\n // Apply additional props to the native node\n const props = vnode.props || {};\n for (const [key, value] of Object.entries(props)) {\n if (key === \"__nativeNode\" || key === \"key\" || key === \"children\") continue;\n\n if (isSignal(value)) {\n const unsub = strategy.setSignalProperty(nativeNode, key, value);\n subscriptions.push(unsub);\n } else {\n strategy.setProperty(nativeNode, key, value);\n }\n }\n\n return {\n vnode,\n node: nativeNode,\n subscriptions,\n children: [],\n };\n }\n\n /**\n * Render a component\n */\n function renderComponent(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n if (typeof vnode.type !== \"function\") {\n throw new Error(\"Component vnode must have a function type\");\n }\n\n const Component = vnode.type;\n const props = {\n ...vnode.props,\n children: normalizeChildrenProp(vnode.children),\n };\n\n // Prepare current component's context\n let currentContext = parentContext;\n\n // Check if this is a Context Provider\n const isContextProvider = (Component as any).__isContextProvider;\n\n if (isContextProvider) {\n // Context Provider: create new context map with provided values\n currentContext = new Map(parentContext);\n const provide = (props as any).provide;\n\n if (provide) {\n // Check if it's a single provide [Context, value] or multiple [[Context, value], ...]\n const isSingle = provide.length === 2 && typeof provide[0] === \"symbol\";\n\n if (isSingle) {\n // Single: [Context, value]\n const [context, value] = provide;\n currentContext.set(context, value);\n } else {\n // Multiple: [[Context, value], ...]\n for (const [context, value] of provide) {\n currentContext.set(context, value);\n }\n }\n }\n }\n\n // Create ComponentAPI\n const ctx = createComponentAPI(currentContext);\n\n // Call component function with props and ctx\n const result = Component(props, ctx);\n\n // Handle async component (Promise<VNode>)\n if (isPromise(result)) {\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = resource(result, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: currentContext },\n children: [],\n };\n const rendered = renderNode(signalVNode, currentContext);\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n // Handle async generator component (AsyncIterableIterator<VNode>)\n if (isAsyncIterator(result)) {\n const pending: VNode = {\n type: \"#text\",\n props: { nodeValue: \"\" },\n children: [],\n };\n const resultSignal = stream(result, pending);\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: resultSignal, context: currentContext },\n children: [],\n };\n const rendered = renderNode(signalVNode, currentContext);\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n // Handle signal component (Signal<VNode>)\n if (isSignal(result)) {\n const signalVNode: VNode = {\n type: \"#signal\",\n props: { signal: result, context: currentContext },\n children: [],\n };\n const rendered = renderNode(signalVNode, currentContext);\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n // Handle normal sync component (VNode)\n const normalizedResult = normalizeComponentResult(result);\n const rendered = renderNode(normalizedResult, currentContext);\n\n return {\n vnode,\n node: rendered.node,\n subscriptions: rendered.subscriptions,\n children: [rendered],\n };\n }\n\n /**\n * Render an element\n */\n function renderElement(vnode: VNode, parentContext: ContextMap): RenderedNode<TNode> {\n if (typeof vnode.type !== \"string\") {\n throw new Error(\"Element vnode must have a string type\");\n }\n\n const element = strategy.createElement(vnode.type);\n const subscriptions: Array<() => void> = [];\n\n // Apply props\n const props = vnode.props || {};\n for (const [key, value] of Object.entries(props)) {\n if (key === \"key\" || key === \"children\") continue;\n\n // Handle ref separately\n if (key === \"ref\") {\n if (strategy.setRef && value != null) {\n const cleanup = strategy.setRef(element, value as Ref<TNode>);\n subscriptions.push(cleanup);\n }\n continue;\n }\n\n if (isSignal(value)) {\n const unsub = strategy.setSignalProperty(element, key, value);\n subscriptions.push(unsub);\n } else {\n strategy.setProperty(element, key, value);\n }\n }\n\n // Render children with same context\n const children = vnode.children.map((child) => renderNode(child, parentContext));\n\n // Append all child nodes (recursively handles fragments and signal wrappers)\n for (const child of children) {\n const nodes = collectNodes(child);\n for (const node of nodes) {\n strategy.appendChild(element, node);\n }\n }\n\n return {\n vnode,\n node: element,\n subscriptions,\n children,\n };\n }\n\n /**\n * Unmount a rendered node\n */\n function unmount(node: RenderedNode<TNode>): void {\n // Cleanup subscriptions\n for (const unsub of node.subscriptions) {\n unsub();\n }\n\n // Recursively unmount children\n for (const child of node.children) {\n unmount(child);\n }\n\n // Remove from tree\n if (node.node) {\n strategy.removeChild(node.node);\n }\n }\n\n /**\n * Clean up subscriptions without removing nodes from tree\n */\n function cleanupSubscriptions(node: RenderedNode<TNode>): void {\n // Cleanup subscriptions\n for (const unsub of node.subscriptions) {\n unsub();\n }\n\n // Recursively cleanup children\n for (const child of node.children) {\n cleanupSubscriptions(child);\n }\n }\n\n return {\n renderNode: renderNode,\n unmount: unmount,\n cleanupSubscriptions: cleanupSubscriptions,\n };\n}\n"],"mappings":";;;;;;;;AAKA,MAAa,WAAmB,OAAO,IAAI,mBAAmB;;;;AAK9D,MAAa,SAAiB,OAAO,IAAI,iBAAiB;;;;;AAM1D,MAAa,UAAkB,OAAO,IAAI,kBAAkB;;;;;;;ACR5D,SAAgB,EACd,MACA,OACA,GAAG,UACI;AACP,QAAO;EACL;EACA,OAAO,SAAS,EAAE;EAClB,UAAU,kBAAkB,SAAS;EACrC,KAAK,OAAO;EACb;;;;;AAMH,SAAgB,gBAAgB,MAA8B;AAC5D,QAAO;EACL,MAAM;EACN,OAAO,EAAE,WAAW,OAAO,KAAK,EAAE;EAClC,UAAU,EAAE;EACb;;;;;AAMH,SAAgB,kBAAkB,QAAgC;AAChE,QAAO;EACL,MAAM;EACN,OAAO,EAAE,QAAQ;EACjB,UAAU,EAAE;EACb;;;;;AAMH,SAAS,kBAAkB,UAA8B;CACvD,MAAM,SAAkB,EAAE;AAE1B,MAAK,MAAM,SAAS,UAAU;AAC5B,MAAI,SAAS,QAAQ,OAAO,UAAU,UAEpC;AAGF,MAAI,MAAM,QAAQ,MAAM,CAEtB,QAAO,KAAK,GAAG,kBAAkB,MAAM,CAAC;WAC/B,OAAO,UAAU,YAAY,OAAO,UAAU,SAEvD,QAAO,KAAK,gBAAgB,MAAM,CAAC;WAC1B,SAAS,MAAM,CAExB,QAAO,KAAK,kBAAkB,MAAM,CAAC;WAC5B,QAAQ,MAAM,CAEvB,QAAO,KAAK,MAAM;MAGlB,SAAQ,KAAK,uBAAuB,OAAO,MAA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,SAAS,QAAQ,MAAiC;AAEhD,OAAK,MAAM,SAAS,KAAK,cACvB,QAAO;AAIT,OAAK,MAAM,SAAS,KAAK,SACvB,SAAQ,MAAM;AAIhB,MAAI,KAAK,KACP,UAAS,YAAY,KAAK,KAAK;;;;;CAOnC,SAAS,qBAAqB,MAAiC;AAE7D,OAAK,MAAM,SAAS,KAAK,cACvB,QAAO;AAIT,OAAK,MAAM,SAAS,KAAK,SACvB,sBAAqB,MAAM;;AAI/B,QAAO;EACO;EACH;EACa;EACvB"}
@@ -1,4 +1,4 @@
1
- import { t as isSignal } from "./utils-DbTAs943.mjs";
1
+ import { t as isSignal } from "./utils-BrGmTgfG.mjs";
2
2
 
3
3
  //#region ../style/src/classes.ts
4
4
  /**
@@ -1004,4 +1004,4 @@ function container(query, ...tokens) {
1004
1004
 
1005
1005
  //#endregion
1006
1006
  export { keyframes as A, inject as B, slideRight as C, spin as D, slideUpKf as E, StyleRegistry as F, rules as G, preload as H, createCx as I, classes as K, createRegistry as L, createTheme as M, defineTokens as N, spinKf as O, isTokenRef as P, hashString as R, slideLeftKf as S, slideUp as T, isStyleToken as U, injectStyles as V, rule as W, scaleOut as _, bounce as a, slideDownKf as b, fadeInKf as c, ping as d, pingKf as f, scaleInKf as g, scaleIn as h, media as i, keyframesToken as j, isKeyframeRef as k, fadeOut as l, pulseKf as m, container as n, bounceKf as o, pulse as p, isClassRef as q, defineBreakpoints as r, fadeIn as s, breakpoints as t, fadeOutKf as u, scaleOutKf as v, slideRightKf as w, slideLeft as x, slideDown as y, uniqueId as z };
1007
- //# sourceMappingURL=src-Ds9vl42d.mjs.map
1007
+ //# sourceMappingURL=src-DV9uwtE5.mjs.map