nuclo 0.1.46 → 0.1.47
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.
- package/dist/core/attributeManager.d.ts.map +1 -1
- package/dist/list/renderer.d.ts.map +1 -1
- package/dist/nuclo.cjs +1 -1
- package/dist/nuclo.cjs.map +1 -1
- package/dist/nuclo.js +1 -1
- package/dist/nuclo.js.map +1 -1
- package/dist/nuclo.umd.js +1 -1
- package/dist/nuclo.umd.js.map +1 -1
- package/dist/utility/modifierPredicates.d.ts +2 -1
- package/dist/utility/modifierPredicates.d.ts.map +1 -1
- package/dist/utility/on.d.ts.map +1 -1
- package/dist/utility/renderables.d.ts +3 -1
- package/dist/utility/renderables.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/core/base.d.ts +2 -2
- package/types/index.d.ts +6 -6
- package/types/svg/base.d.ts +5 -3
package/dist/nuclo.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuclo.umd.js","sources":["../src/utility/typeGuards.ts","../src/utility/errorHandler.ts","../src/utility/environment.ts","../src/utility/dom.ts","../src/core/reactive.ts","../src/utility/domTypeHelpers.ts","../src/core/styleManager.ts","../src/core/attributeManager.ts","../src/utility/modifierPredicates.ts","../src/core/modifierProcessor.ts","../src/utility/conditionalInfo.ts","../src/internal/applyModifiers.ts","../src/core/conditionalRenderer.ts","../src/core/elementFactory.ts","../src/core/tagRegistry.ts","../src/list/runtime.ts","../src/utility/renderables.ts","../src/utility/arrayUtils.ts","../src/list/renderer.ts","../src/utility/conditions.ts","../src/when/index.ts","../src/core/conditionalUpdater.ts","../src/core/updateController.ts","../src/utility/events.ts","../src/utility/on.ts","../src/utility/render.ts","../src/core/runtimeBootstrap.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n return value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n return value instanceof Node;\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n return isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\nexport function isFunction<T extends Function>(value: unknown): value is T {\n return typeof value === \"function\";\n}\n\nexport function isZeroArityFunction(value: unknown): value is () => unknown {\n return isFunction(value) && (value as Function).length === 0;\n}\n","/**\n * Simplified error handling for nuclo - reduced complexity for smaller bundle size\n */\n\n// Basic error logging - no complex context tracking\nexport function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n console.error(`nuclo: ${message}`, error);\n }\n}\n\n// Simplified safe execution - no complex context\nexport function safeExecute<T>(fn: () => T, fallback?: T): T | undefined {\n try {\n return fn();\n } catch (error) {\n logError(\"Operation failed\", error);\n return fallback;\n }\n}\n\n// Basic DOM error handler\nexport function handleDOMError(error: Error | unknown, operation: string): void {\n logError(`DOM ${operation} failed`, error);\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","import { isBrowser } from \"./environment\";\nimport { logError } from \"./errorHandler\";\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n if (!parent || !child) return false;\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n if (!parent || !newNode) return false;\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return document.createTextNode(String(text));\n } catch (error) {\n logError('Failed to create text node', error);\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch (error) {\n logError('Failed to create comment node', error);\n return null;\n }\n}\n\n/**\n * Creates a comment node safely with error handling.\n * Exported for use across the codebase.\n */\nexport function createComment(text: string): Comment | null {\n return createCommentSafely(text);\n}\n\n/**\n * Creates a conditional comment placeholder node.\n * In SSR environments, this will still work because we bypass the isBrowser check.\n */\nexport function createConditionalComment(tagName: string, suffix: string = \"hidden\"): Comment | null {\n // For SSR, we need to create comments even when isBrowser is false\n // This function intentionally skips the isBrowser check for SSR compatibility\n try {\n return document.createComment(`conditional-${tagName}-${suffix}`);\n } catch (error) {\n logError('Failed to create conditional comment', error);\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(node => safeInsertBefore(parent, node, referenceNode));\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach((child) => {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n\n // Prefer the built-in isConnected property\n if (typeof node.isConnected === \"boolean\") {\n return node.isConnected;\n }\n\n // Fallback for older browsers (only if in browser environment)\n if (isBrowser && typeof document !== 'undefined') {\n return document.contains(node);\n }\n\n // In SSR or when document is not available, assume disconnected\n return false;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n","import { logError, safeExecute } from \"../utility/errorHandler\";\nimport { isNodeConnected } from \"../utility/dom\";\n\ntype TextResolver = () => Primitive;\ntype AttributeResolver = () => unknown;\n\ninterface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n}\n\ninterface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\ninterface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n updateListener?: EventListener;\n}\n\nconst reactiveTextNodes = new Map<Text, ReactiveTextNodeInfo>();\nconst reactiveElements = new Map<Element, ReactiveElementInfo>();\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n let info = reactiveElements.get(el);\n if (!info) {\n info = { attributeResolvers: new Map() };\n reactiveElements.set(el, info);\n }\n return info;\n}\n\nfunction applyAttributeResolvers(el: Element, info: ReactiveElementInfo): void {\n info.attributeResolvers.forEach(({ resolver, applyValue }, key) => {\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(`Failed to update reactive attribute: ${key}`, e);\n }\n });\n}\n\n/**\n * Creates a reactive text node that automatically updates when its resolver function changes.\n *\n * The text node will be registered for reactive updates and its content will be synchronized\n * whenever notifyReactiveTextNodes() is called.\n *\n * @param resolver - Function that returns the text content (string, number, boolean, etc.)\n * @param preEvaluated - Optional pre-evaluated value to avoid calling resolver immediately\n * @returns A Text node that will reactively update its content\n *\n * @example\n * ```ts\n * const count = signal(0);\n * const textNode = createReactiveTextNode(() => `Count: ${count.value}`);\n * // Later, when count changes and notifyReactiveTextNodes() is called,\n * // the text content automatically updates\n * ```\n */\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n return document.createTextNode(\"\");\n }\n\n const initial = arguments.length > 1 ? preEvaluated : safeExecute(resolver, \"\");\n const str = initial === undefined ? \"\" : String(initial);\n const txt = document.createTextNode(str);\n\n reactiveTextNodes.set(txt, { resolver, lastValue: str });\n return txt;\n}\n\n/**\n * Registers a reactive attribute resolver for an element.\n *\n * The resolver will be called whenever the element receives an 'update' event,\n * allowing attributes to reactively update based on application state.\n *\n * @param element - The DOM element to make reactive\n * @param key - The attribute name being made reactive (e.g., 'class', 'style', 'disabled')\n * @param resolver - Function that returns the new attribute value\n * @param applyValue - Callback that applies the resolved value to the element\n *\n * @example\n * ```ts\n * const isActive = signal(false);\n * const button = document.createElement('button');\n * registerAttributeResolver(\n * button,\n * 'class',\n * () => isActive.value ? 'active' : 'inactive',\n * (value) => button.className = String(value)\n * );\n * ```\n */\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, { resolver, applyValue });\n\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(\"Failed to apply initial attribute value\", e);\n }\n\n if (!info.updateListener) {\n const listener: EventListener = () => applyAttributeResolvers(element as Element, info);\n (element as Element).addEventListener(\"update\", listener);\n info.updateListener = listener;\n }\n}\n\n/**\n * Updates all registered reactive text nodes.\n *\n * Iterates through all reactive text nodes, re-evaluates their resolver functions,\n * and updates their content if it has changed. Automatically cleans up disconnected nodes.\n *\n * This function should be called after state changes to synchronize the DOM with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * count.value++;\n * notifyReactiveTextNodes(); // All reactive text nodes update\n * ```\n */\nexport function notifyReactiveTextNodes(): void {\n reactiveTextNodes.forEach((info, node) => {\n if (!isNodeConnected(node)) {\n reactiveTextNodes.delete(node);\n return;\n }\n try {\n const raw = safeExecute(info.resolver);\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n }\n });\n}\n\n/**\n * Updates all registered reactive elements by re-evaluating their attribute resolvers.\n *\n * Iterates through all reactive elements and triggers their registered attribute resolvers\n * to update. Automatically cleans up disconnected elements and their event listeners.\n *\n * This function should be called after state changes to synchronize element attributes\n * with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * isActive.value = true;\n * notifyReactiveElements(); // All reactive attributes update\n * ```\n */\nexport function notifyReactiveElements(): void {\n reactiveElements.forEach((info, el) => {\n if (!isNodeConnected(el)) {\n if (info.updateListener) el.removeEventListener(\"update\", info.updateListener);\n reactiveElements.delete(el);\n return;\n }\n applyAttributeResolvers(el, info);\n });\n}\n","/**\n * Type-safe DOM helper utilities to reduce type assertions across the codebase.\n * These helpers provide proper typing for DOM operations while maintaining runtime safety.\n */\n\n/**\n * Safely casts an Element-like object to Node & ParentNode interface.\n * This is a common pattern needed when working with DOM manipulation.\n *\n * @param element - The element to cast\n * @returns The element typed as Node & ParentNode\n */\nexport function asParentNode<T extends Element | object>(element: T): Node & ParentNode {\n return element as unknown as Node & ParentNode;\n}\n\n/**\n * Creates a scoped DOM insertion context that temporarily redirects appendChild\n * to insertBefore at a specific reference node. This is useful for inserting\n * content at specific positions in the DOM tree.\n *\n * @param host - The host element\n * @param referenceNode - The node before which new nodes should be inserted\n * @param callback - Function to execute with the scoped context\n * @returns The result of the callback\n */\nexport function withScopedInsertion<T, THost extends Element | object>(\n host: THost,\n referenceNode: Node,\n callback: () => T\n): T {\n const parent = asParentNode(host);\n const originalAppend = parent.appendChild.bind(parent);\n const originalInsert = parent.insertBefore.bind(parent);\n\n // Temporarily override appendChild to insert before the reference node\n // TypeScript doesn't like this override but it's safe at runtime\n (parent as unknown as Record<string, unknown>).appendChild = function(node: Node): Node {\n return originalInsert(node, referenceNode);\n };\n\n try {\n return callback();\n } finally {\n // Restore original method\n (parent as unknown as Record<string, unknown>).appendChild = originalAppend;\n }\n}\n\n/**\n * Type-safe wrapper for setting CSS style properties.\n * Provides better error handling than direct CSSStyleDeclaration access.\n * Supports both camelCase and kebab-case property names.\n *\n * @param element - The element to apply styles to\n * @param property - The CSS property name (camelCase or kebab-case)\n * @param value - The value to set (string, number, or null to remove)\n * @returns true if the style was applied successfully, false otherwise\n */\nexport function setStyleProperty(\n element: HTMLElement,\n property: string,\n value: string | number | null\n): boolean {\n try {\n if (value === null || value === undefined || value === '') {\n // Use bracket notation to remove property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = '';\n return true;\n }\n\n // Convert value to string first (might throw if toString() throws)\n const stringValue = String(value);\n // Use bracket notation to set property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = stringValue;\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Type-safe wrapper for reading CSS style properties.\n *\n * @param element - The element to read styles from\n * @param property - The CSS property name\n * @returns The computed style value or empty string if not found\n */\nexport function getStyleProperty(\n element: HTMLElement,\n property: string\n): string {\n try {\n return element.style.getPropertyValue(property);\n } catch {\n return '';\n }\n}\n","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\nimport { setStyleProperty } from \"../utility/domTypeHelpers\";\nimport { logError } from \"../utility/errorHandler\";\n\ntype StyleAssignment = Partial<CSSStyleDeclaration>;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element?.style || !styles) return;\n\n for (const [property, value] of Object.entries(styles)) {\n const success = setStyleProperty(\n element as HTMLElement,\n property,\n value as string | number | null\n );\n\n if (!success) {\n // Don't try to stringify value in error message as it might throw\n logError(`Failed to set style property '${property}'`);\n }\n }\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', () => {\n try {\n return styleValue();\n } catch (error) {\n logError('Error in style resolver function', error);\n return null;\n }\n }, (resolvedStyles) => {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver, createReactiveTextNode } from \"./reactive\";\nimport { applyStyleAttribute } from \"./styleManager\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown): void => {\n if (v == null) return;\n\n // SVG elements should always use setAttribute for most attributes\n // because many SVG properties are read-only\n const isSVGElement = el instanceof Element && el.namespaceURI === 'http://www.w3.org/2000/svg';\n\n if (isSVGElement) {\n // Always use setAttribute for SVG elements\n el.setAttribute(String(key), String(v));\n } else if (key in el) {\n // For HTML elements, try to set as property first\n try {\n (el as Record<string, unknown>)[key as string] = v;\n } catch {\n // If property is read-only, fall back to setAttribute\n if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n }\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && (raw as Function).length === 0) {\n registerAttributeResolver(el, String(key), raw as () => unknown, setValue);\n } else {\n setValue(raw);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n applySingleAttribute(element, k, value);\n }\n}\n\nexport { createReactiveTextNode } from \"./reactive\";\n","import { isFunction, isNode, isObject } from \"./typeGuards\";\n\ntype BooleanCondition = () => boolean;\n\nconst modifierProbeCache = new WeakMap<Function, { value: unknown; error: boolean }>();\n\nfunction probeOnce(fn: Function): { value: unknown; error: boolean } {\n const cached = modifierProbeCache.get(fn);\n if (cached) {\n return cached;\n }\n try {\n const value = fn();\n const record = { value, error: false };\n modifierProbeCache.set(fn, record);\n return record;\n } catch {\n const record = { value: undefined, error: true };\n modifierProbeCache.set(fn, record);\n return record;\n }\n}\n\nfunction isBooleanFunction(fn: Function): fn is BooleanCondition {\n const { value, error } = probeOnce(fn);\n if (error) return false;\n return typeof value === \"boolean\";\n}\n\nexport function isConditionalModifier(\n modifier: unknown,\n allModifiers: unknown[],\n currentIndex: number\n): modifier is BooleanCondition {\n if (\n !isFunction(modifier) ||\n (modifier as Function).length !== 0 ||\n !isBooleanFunction(modifier as Function)\n ) {\n return false;\n }\n\n const otherModifiers = allModifiers.filter((_, index) => index !== currentIndex);\n if (otherModifiers.length === 0) return false;\n\n const hasAttributesOrElements = otherModifiers.some(\n (mod) =>\n isObject(mod) || isNode(mod) || (isFunction(mod) && (mod as Function).length > 0)\n );\n\n return hasAttributesOrElements;\n}\n\nexport function findConditionalModifier(modifiers: unknown[]): number {\n for (let i = 0; i < modifiers.length; i += 1) {\n if (isConditionalModifier(modifiers[i], modifiers, i)) {\n return i;\n }\n }\n return -1;\n}\n\nexport { modifierProbeCache };\n","import { applyAttributes } from \"./attributeManager\";\nimport { createReactiveTextNode } from \"./reactive\";\nimport { logError } from \"../utility/errorHandler\";\nimport { isFunction, isNode, isObject, isPrimitive, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { createComment } from \"../utility/dom\";\n\nexport { isConditionalModifier, findConditionalModifier } from \"../utility/modifierPredicates\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n parent: ExpandedElement<TTagName>,\n modifier: NodeModifier<TTagName>,\n index: number,\n): Node | null {\n if (modifier == null) return null;\n\n if (isFunction(modifier)) {\n // Handle zero-argument functions (reactive text)\n if (isZeroArityFunction(modifier)) {\n try {\n let record = modifierProbeCache.get(modifier);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier, record);\n }\n if (record.error) {\n return createReactiveTextFragment(index, () => \"\");\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n return createReactiveTextFragment(index, modifier as () => Primitive, v);\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n return createReactiveTextFragment(index, () => \"\");\n }\n }\n\n // Handle NodeModFn functions\n const produced = modifier(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n return createStaticTextFragment(index, produced);\n }\n if (isNode(produced)) return produced;\n if (isObject(produced)) {\n applyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n }\n return null;\n }\n\n // Handle non-function modifiers\n const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n return createStaticTextFragment(index, candidate);\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n\nfunction createReactiveTextFragment(\n index: number,\n resolver: () => Primitive,\n preEvaluated?: unknown\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = createReactiveTextNode(resolver, preEvaluated);\n fragment.appendChild(textNode);\n return fragment;\n}\n\nfunction createStaticTextFragment(index: number, value: Primitive): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = document.createTextNode(String(value));\n fragment.appendChild(textNode);\n return fragment;\n}\n","export interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {\n condition: () => boolean;\n tagName: TTagName;\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n}\n\ninterface NodeWithConditionalInfo extends Node {\n _conditionalInfo?: ConditionalInfo<keyof HTMLElementTagNameMap>;\n}\n\n/**\n * Registry of all nodes that have conditional info attached.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<Node>();\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo<TTagName extends ElementTagName>(\n node: Node,\n info: ConditionalInfo<TTagName>\n): void {\n (node as NodeWithConditionalInfo)._conditionalInfo = info as ConditionalInfo<keyof HTMLElementTagNameMap>;\n activeConditionalNodes.add(node);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n */\nexport function unregisterConditionalNode(node: Node): void {\n activeConditionalNodes.delete(node);\n}\n\n/**\n * Returns a readonly view of currently tracked conditional nodes.\n */\nexport function getActiveConditionalNodes(): ReadonlySet<Node> {\n return activeConditionalNodes;\n}\n\nexport function hasConditionalInfo(node: Node): boolean {\n return Boolean((node as NodeWithConditionalInfo)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo<keyof HTMLElementTagNameMap> | null {\n return (node as NodeWithConditionalInfo)._conditionalInfo ?? null;\n}\n","/**\n * Shared helper for applying an array of modifiers to an element.\n * Consolidates the previously duplicated logic in several modules:\n * - conditionalRenderer\n * - conditionalUpdater\n * - elementFactory\n *\n * Goal: single, optimized, well‑typed implementation.\n *\n * A \"modifier\" can:\n * - Return (or be) primitives → appended as text\n * - Return (or be) Node → appended (if not already a child)\n * - Return (or be) attribute objects → merged into element\n * - Be a NodeModFn invoked with (parent, index)\n * - Be a zero‑arg function producing reactive text (handled upstream in applyNodeModifier)\n *\n * Indexing:\n * - startIndex allows callers to continue an index sequence if needed.\n * - Every successfully rendered child Node increments the local index.\n */\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport interface ApplyModifiersResult<TTagName extends ElementTagName> {\n /**\n * The element passed in (for fluent patterns if desired).\n */\n element: ExpandedElement<TTagName>;\n /**\n * The next index after processing (startIndex + rendered children count).\n */\n nextIndex: number;\n /**\n * Number of child nodes appended (not counting attributes-only modifiers).\n */\n appended: number;\n}\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * Returns meta information that callers can use for continuation indexing.\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ApplyModifiersResult<TTagName> {\n if (!modifiers || modifiers.length === 0) {\n return { element, nextIndex: startIndex, appended: 0 };\n }\n\n let localIndex = startIndex;\n let appended = 0;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n appended += 1;\n }\n\n return {\n element,\n nextIndex: localIndex,\n appended\n };\n}\n\n/**\n * Convenience helper: apply modifiers and return the element (fluent style).\n * Discards meta information.\n */\nexport function applyModifiersAndReturn<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ExpandedElement<TTagName> {\n applyModifiers(element, modifiers, startIndex);\n return element;\n}\n\n/**\n * Creates an element with the specified tag name and applies modifiers to it.\n * Centralizes element creation logic used across conditionalRenderer and conditionalUpdater.\n */\nexport function createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers, 0);\n return el;\n}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { createElementWithModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { createConditionalComment } from \"../utility/dom\";\n\nexport function createConditionalElement<TTagName extends ElementTagName>(\n tagName: TTagName,\n condition: () => boolean,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> | Comment {\n const passed = condition();\n\n if (!isBrowser) {\n return passed\n ? createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>)\n : (createConditionalComment(tagName, \"ssr\") as unknown as ExpandedElement<TTagName>);\n }\n\n const conditionalInfo: ConditionalInfo<TTagName> = { condition, tagName, modifiers };\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>);\n storeConditionalInfo(el as Node, conditionalInfo);\n return el;\n }\n\n const comment = createConditionalComment(tagName);\n if (!comment) {\n throw new Error(`Failed to create conditional comment for ${tagName}`);\n }\n storeConditionalInfo(comment as Node, conditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nexport function processConditionalModifiers<TTagName extends ElementTagName>(\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): {\n condition: (() => boolean) | null;\n otherModifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n} {\n const conditionalIndex = findConditionalModifier(modifiers);\n\n if (conditionalIndex === -1) {\n return { condition: null, otherModifiers: modifiers };\n }\n\n return {\n condition: modifiers[conditionalIndex] as () => boolean,\n otherModifiers: modifiers.filter((_, index) => index !== conditionalIndex)\n };\n}\n","import { createConditionalElement, processConditionalModifiers } from \"./conditionalRenderer\";\nimport { applyModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { SVG_TAGS } from \"./tagRegistry\";\n\n/**\n * Checks if a tag name is an SVG tag.\n */\nfunction isSVGTag(tagName: string): tagName is keyof SVGElementTagNameMap {\n return (SVG_TAGS as readonly string[]).includes(tagName);\n}\n\n/**\n * Creates an element with proper namespace handling for SVG elements.\n */\nfunction createElementWithNamespace<TTagName extends ElementTagName>(\n tagName: TTagName\n): Element {\n if (isSVGTag(tagName)) {\n return document.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n return document.createElement(tagName);\n}\n\nexport function createElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> => {\n const { condition, otherModifiers } = processConditionalModifiers(modifiers);\n\n if (condition) {\n return createConditionalElement(tagName, condition, otherModifiers) as ExpandedElement<TTagName>;\n }\n\n const el = createElementWithNamespace(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, otherModifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n return el;\n };\n}\n\nexport function createTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): (...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>) => NodeModFn<TTagName> {\n return (...mods) => createElementFactory(tagName, ...mods);\n}","import { createTagBuilder } from \"./elementFactory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n // Don't overwrite non-function properties (safety check)\n if (tagName in target && typeof target[tagName] !== 'function') {\n return;\n }\n // Register HTML tags - they override SVG tags with same name\n target[tagName] = createTagBuilder(tagName);\n}\n\nfunction registerSvgTag(target: Record<string, unknown>, tagName: keyof SVGElementTagNameMap): void {\n // Some SVG tags conflict with HTML tags or DOM globals\n // Use suffix convention: a_svg, script_svg, style_svg, title_svg, text_svg, stop_\n const conflictingTags = ['a', 'script', 'style', 'title', 'text'];\n const globalConflicts = ['stop']; // 'stop' conflicts with DOM stop property\n\n let exportName: string = tagName;\n if (conflictingTags.includes(tagName)) {\n exportName = `${tagName}_svg`;\n } else if (globalConflicts.includes(tagName)) {\n exportName = `${tagName}_`;\n }\n\n if (!(exportName in target)) {\n target[exportName] = createTagBuilder(tagName as ElementTagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__nuclo_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n // Register SVG tags first with special names for conflicts\n SVG_TAGS.forEach((tagName) => registerSvgTag(target, tagName));\n\n // Then register HTML tags - these will take precedence for conflicting names\n // So 'a' will be HTML by default, and 'a_svg' will be available for SVG anchors\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\n\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { createMarkerPair, safeRemoveChild } from \"../utility/dom\";\nimport { arraysEqual } from \"../utility/arrayUtils\";\nimport { resolveRenderable } from \"../utility/renderables\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsProvider } from \"./types\";\n\nconst activeListRuntimes = new Set<ListRuntime<unknown, keyof HTMLElementTagNameMap>>();\n\nfunction renderItem<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>,\n item: TItem,\n index: number,\n): ExpandedElement<TTagName> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable<TTagName>(result, runtime.host, index);\n}\n\nfunction remove<TItem, TTagName extends ElementTagName>(record: ListItemRecord<TItem, TTagName>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>\n): void {\n const { host, startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const currentItems = runtime.itemsProvider();\n\n if (arraysEqual(runtime.lastSyncedItems, currentItems)) return;\n\n const recordsByPosition = new Map<number, ListItemRecord<TItem, TTagName>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem, TTagName>[]>();\n\n runtime.records.forEach((record) => {\n const items = availableRecords.get(record.item);\n if (items) {\n items.push(record);\n } else {\n availableRecords.set(record.item, [record]);\n }\n });\n\n currentItems.forEach((item, newIndex) => {\n if (\n newIndex < runtime.lastSyncedItems.length &&\n runtime.lastSyncedItems[newIndex] === item\n ) {\n const existingRecord = runtime.records[newIndex];\n if (existingRecord && existingRecord.item === item) {\n recordsByPosition.set(newIndex, existingRecord);\n const items = availableRecords.get(item);\n if (items) {\n const recordIndex = items.indexOf(existingRecord);\n if (recordIndex >= 0) {\n items.splice(recordIndex, 1);\n if (items.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n }\n }\n });\n\n const newRecords: Array<ListItemRecord<TItem, TTagName>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem, TTagName>>(runtime.records);\n let nextSibling: Node = endMarker;\n\n for (let i = currentItems.length - 1; i >= 0; i--) {\n const item = currentItems[i];\n let record = recordsByPosition.get(i);\n\n if (!record) {\n const availableItems = availableRecords.get(item);\n if (availableItems && availableItems.length > 0) {\n record = availableItems.shift()!;\n if (availableItems.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n\n if (record) {\n elementsToRemove.delete(record);\n } else {\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n record = { item, element };\n }\n\n newRecords.unshift(record);\n\n const recordNode = record.element as unknown as Node;\n if (recordNode.nextSibling !== nextSibling) {\n parent.insertBefore(recordNode, nextSibling);\n }\n nextSibling = recordNode;\n }\n\n elementsToRemove.forEach(remove);\n\n runtime.records = newRecords;\n runtime.lastSyncedItems = [...currentItems];\n}\n\nexport function createListRuntime<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n): ListRuntime<TItem, TTagName> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem, TTagName> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n activeListRuntimes.add(runtime as ListRuntime<unknown, keyof HTMLElementTagNameMap>);\n sync(runtime);\n\n return runtime;\n}\n\nexport function updateListRuntimes(): void {\n activeListRuntimes.forEach((runtime) => {\n if (!runtime.startMarker.isConnected || !runtime.endMarker.isConnected) {\n activeListRuntimes.delete(runtime);\n return;\n }\n\n sync(runtime);\n });\n}\n","import { isFunction, isTagLike } from \"./typeGuards\";\n\nexport function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(\n result: unknown,\n host: ExpandedElement<TTagName>,\n index: number\n): ExpandedElement<TTagName> | null {\n if (isFunction(result)) {\n const element = (result as NodeModFn<TTagName>)(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<TTagName>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<TTagName>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if ((i in a ? a[i] : undefined) !== (i in b ? b[i] : undefined)) return false;\n }\n return true;\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n */\nexport function list<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem, TTagName>,\n): NodeModFn<TTagName> {\n return (host: ExpandedElement<TTagName>, index: number) => {\n const runtime = createListRuntime(itemsProvider, render, host);\n // Return the start marker comment node\n return runtime.startMarker as any;\n };\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (onError) {\n onError(error);\n return false;\n }\n throw error;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\" ? runCondition(value, onError) : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore, createComment } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { asParentNode, withScopedInsertion } from \"../utility/domTypeHelpers\";\n\ntype WhenCondition = boolean | (() => boolean);\ntype WhenContent<TTagName extends ElementTagName = ElementTagName> = \n NodeMod<TTagName> | NodeModFn<TTagName>;\n\ninterface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\ninterface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet\n * - -1: else branch\n * - >=0: index of groups[]\n */\n activeIndex: number | -1 | null;\n update(): void;\n}\n\nconst activeWhenRuntimes = new Set<WhenRuntime<any>>();\n\n/**\n * Evaluates which condition branch should be active.\n * Returns the index of the first truthy condition, -1 for else branch, or null for no match.\n */\nfunction evaluateActiveCondition<TTagName extends ElementTagName>(\n groups: ReadonlyArray<WhenGroup<TTagName>>,\n elseContent: ReadonlyArray<WhenContent<TTagName>>\n): number | -1 | null {\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n return i;\n }\n }\n return elseContent.length > 0 ? -1 : null;\n}\n\n/**\n * Renders a single content item and returns the resulting node if any.\n */\nfunction renderContentItem<TTagName extends ElementTagName>(\n item: WhenContent<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node | null {\n if (!isFunction(item)) {\n return applyNodeModifier(host, item, index);\n }\n\n // Zero-arity functions need cache cleared\n if (isZeroArityFunction(item)) {\n modifierProbeCache.delete(item as Function);\n return applyNodeModifier(host, item, index);\n }\n\n // Non-zero-arity functions need scoped insertion to insert before endMarker\n return withScopedInsertion(host, endMarker, () => {\n const maybeNode = applyNodeModifier(host, item, index);\n // Only include nodes that weren't already inserted\n return maybeNode && !maybeNode.parentNode ? maybeNode : null;\n });\n}\n\n/**\n * Renders a list of content items and collects the resulting nodes.\n */\nfunction renderContentItems<TTagName extends ElementTagName>(\n items: ReadonlyArray<WhenContent<TTagName>>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node[] {\n const nodes: Node[] = [];\n for (const item of items) {\n const node = renderContentItem(item, host, index, endMarker);\n if (node) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\n/**\n * Main render function for when/else conditionals.\n * Evaluates conditions, clears old content, and renders the active branch.\n */\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n const newActive = evaluateActiveCondition(groups, elseContent);\n\n // No change needed\n if (newActive === runtime.activeIndex) return;\n\n // Clear previous content and update active index\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n // Nothing to render\n if (newActive === null) return;\n\n // Render the active branch\n const contentToRender = newActive >= 0 ? groups[newActive].content : elseContent;\n const nodes = renderContentItems(contentToRender, host, index, endMarker);\n\n insertNodesBefore(nodes, endMarker);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!isBrowser) {\n const comment = createComment(\"when-ssr\");\n return comment || null;\n }\n\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\");\n\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex: null,\n update: () => renderWhenContent(runtime),\n };\n\n activeWhenRuntimes.add(runtime);\n\n const parent = asParentNode(host);\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n return startMarker;\n }\n}\n\nfunction createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = (host: ExpandedElement<TTagName>, index: number): Node | null => {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: (condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.when(condition, ...content);\n return createWhenBuilderFunction(builder);\n },\n else: (...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.else(...content);\n return createWhenBuilderFunction(builder);\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\n/**\n * Updates all active when/else conditional runtimes.\n *\n * Re-evaluates all conditional branches and re-renders if the active branch has changed.\n * Automatically cleans up runtimes that throw errors during update.\n *\n * This function should be called after state changes that affect conditional expressions.\n *\n * @example\n * ```ts\n * isLoggedIn.value = true;\n * updateWhenRuntimes(); // All when() conditionals re-evaluate\n * ```\n */\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\n/**\n * Clears all active when/else conditional runtimes.\n *\n * This is typically used for cleanup or testing purposes.\n * After calling this, no when() conditionals will be tracked for updates.\n */\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\n}\n\n/**\n * Creates a conditional rendering block (when/else logic).\n *\n * Renders different content based on boolean conditions, similar to if/else statements.\n * Conditions can be static booleans or reactive functions that are re-evaluated on updates.\n *\n * @param condition - Boolean value or function returning a boolean\n * @param content - Content to render when condition is true\n * @returns A builder that allows chaining additional .when() or .else() branches\n *\n * @example\n * ```ts\n * const isLoggedIn = signal(false);\n *\n * div(\n * when(() => isLoggedIn.value,\n * span('Welcome back!')\n * )\n * .else(\n * button('Login', on('click', () => login()))\n * )\n * )\n * ```\n *\n * @example\n * ```ts\n * // Multiple conditions\n * div(\n * when(() => status.value === 'loading',\n * spinner()\n * )\n * .when(() => status.value === 'error',\n * errorMessage()\n * )\n * .else(\n * contentView()\n * )\n * )\n * ```\n */\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { createElementWithModifiers } from \"../internal/applyModifiers\";\nimport { isBrowser } from \"../utility/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"../utility/conditionalInfo\";\nimport { runCondition } from \"../utility/conditions\";\nimport { replaceNodeSafely, createConditionalComment } from \"../utility/dom\";\nimport { logError } from \"../utility/errorHandler\";\n\nfunction createElementFromConditionalInfo<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): ExpandedElement<TTagName> {\n try {\n return createElementWithModifiers(conditionalInfo.tagName, conditionalInfo.modifiers);\n } catch (error) {\n logError(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\"`, error);\n // Return a basic element without modifiers as fallback\n return document.createElement(conditionalInfo.tagName) as ExpandedElement<TTagName>;\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n logError(\"Error evaluating conditional condition\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element as Node, conditionalInfo);\n replaceNodeSafely(node, element as Node);\n } else if (!shouldShow && isElement) {\n const comment = createConditionalComment(conditionalInfo.tagName);\n if (comment) {\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n }\n}\n\nexport function updateConditionalElements(): void {\n if (!isBrowser) return;\n\n try {\n getActiveConditionalNodes().forEach((node) => {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n return;\n }\n updateConditionalNode(node as Element | Comment);\n });\n } catch (error) {\n logError(\"Error during conditional elements update\", error);\n }\n}\n","import { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements, notifyReactiveTextNodes } from \"./reactive\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditionalUpdater\";\nimport { dispatchGlobalUpdateEvent } from \"../utility/events\";\n\nconst updaters = [\n updateListRuntimes,\n updateWhenRuntimes,\n updateConditionalElements,\n notifyReactiveElements,\n notifyReactiveTextNodes,\n dispatchGlobalUpdateEvent,\n] as const;\n\nexport function update(): void {\n for (const fn of updaters) fn();\n}\n","import { logError } from \"./errorHandler\";\n\nexport function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") return;\n\n const targets: EventTarget[] = document.body ? [document.body, document] : [document];\n\n for (const target of targets) {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n logError(\"Error dispatching global update event\", error);\n }\n }\n}\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n */\n\nimport { logError } from \"./errorHandler\";\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: E) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on<TTagName extends ElementTagName = ElementTagName>(\n type: string,\n listener: (ev: Event) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>) => {\n const el = parent as unknown as HTMLElement | null | undefined;\n if (!el || typeof el.addEventListener !== \"function\") {\n return;\n }\n\n const wrapped = (ev: Event) => {\n try {\n listener.call(el, ev);\n } catch (error) {\n logError(`Error in '${type}' listener`, error);\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n };\n}\n\n/**\n * (Optional) Helper to detect an on()-produced modifier (placeholder for future use).\n */\nexport function isOnModifier(fn: unknown): boolean {\n return typeof fn === \"function\" && Object.prototype.hasOwnProperty.call(fn, \"__nucloOn\");\n}","/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (parent || document.body).appendChild(element as Node);\n return element;\n}\n","import { registerGlobalTagBuilders } from \"./tagRegistry\";\nimport { list } from \"../list\";\nimport { update } from \"./updateController\";\nimport { when } from \"../when\";\nimport { on } from \"../utility/on\";\nimport { render } from \"../utility/render\";\n\n/**\n * Initializes the nuclo runtime by exposing tag builders and utilities.\n */\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n if (typeof globalThis !== \"undefined\") {\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.render = render;\n }\n}\n\nif (typeof globalThis !== \"undefined\") {\n initializeRuntime();\n}\n"],"names":["isPrimitive","value","isNode","Node","isObject","isTagLike","isFunction","isZeroArityFunction","length","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createConditionalComment","tagName","suffix","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","insertNodesBefore","nodes","referenceNode","parent","forEach","node","newNode","insertBefore","safeInsertBefore","isNodeConnected","isConnected","contains","replaceNodeSafely","oldNode","replaceChild","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","resolver","applyValue","key","e","registerAttributeResolver","element","Element","get","set","ensureElementInfo","updateListener","listener","addEventListener","setStyleProperty","property","style","stringValue","String","assignInlineStyles","styles","Object","entries","applySingleAttribute","raw","styleValue","resolvedStyles","setValue","v","namespaceURI","setAttribute","applyAttributes","attributes","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","undefined","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","filter","_","index","some","mod","applyNodeModifier","createReactiveTextFragment","produced","createStaticTextFragment","candidate","preEvaluated","fragment","createDocumentFragment","appendChild","textNode","createTextNode","initial","arguments","str","txt","lastValue","createReactiveTextNode","activeConditionalNodes","Set","storeConditionalInfo","_conditionalInfo","add","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementWithNamespace","SVG_TAGS","includes","isSVGTag","createElementNS","createElementFactory","passed","conditionalInfo","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","exportName","registerSvgTag","registerHtmlTag","activeListRuntimes","renderItem","runtime","item","result","host","resolveRenderable","remove","sync","startMarker","endMarker","currentItems","itemsProvider","a","b","arraysEqual","lastSyncedItems","recordsByPosition","availableRecords","records","items","push","newIndex","existingRecord","recordIndex","indexOf","splice","delete","newRecords","elementsToRemove","nextSibling","availableItems","shift","unshift","recordNode","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderContentItem","callback","originalAppend","bind","originalInsert","withScopedInsertion","maybeNode","renderWhenContent","groups","elseContent","newActive","evaluateActiveCondition","activeIndex","current","next","clearBetweenMarkers","renderContentItems","content","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","updateConditionalNode","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","updaters","unregisterConditionalNode","removeEventListener","newVal","textContent","targets","body","dispatchEvent","Event","bubbles","on","type","options","ev","call","nodeModFn","initializeRuntime","registry","children","nodeToAppend","createTextNodeSafely","safeAppendChild"],"mappings":"4OAAM,SAAUA,EAAYC,GAC1B,OAAiB,OAAVA,GAAoC,iBAAVA,GAAuC,mBAAVA,CAChE,CAEM,SAAUC,EAAUD,GACxB,OAAOA,aAAiBE,IAC1B,CAEM,SAAUC,EAASH,GACvB,MAAwB,iBAAVA,GAAgC,OAAV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8BE,GAChC,IACT,CACF,CAoFyB+P,CAAqBtP,GACtC,IAAIuG,EAGF,OAFA8I,EAAe9I,CAInB,MACE8I,EAAerP,GApIvB,SAAyBwB,EAAwBxB,GAC/C,IAAKwB,IAAWxB,EAAO,OAAO,EAC9B,IAEE,OADAwB,EAAO8E,YAAYtG,IACZ,CACT,CAAE,MAAOT,GAEP,OADAF,EAAS,8BAA+BE,IACjC,CACT,CACF,CA8HMgQ,CAAgB/N,EAAQ6N,EAC1B,IAGK7N,GArBaA,CAsBtB,2MH/HM,SAAoB3C,GACxB,MAAwB,kBAAVA,CAChB"}
|
|
1
|
+
{"version":3,"file":"nuclo.umd.js","sources":["../src/utility/typeGuards.ts","../src/utility/errorHandler.ts","../src/utility/environment.ts","../src/utility/dom.ts","../src/core/reactive.ts","../src/utility/domTypeHelpers.ts","../src/core/styleManager.ts","../src/core/attributeManager.ts","../src/utility/modifierPredicates.ts","../src/core/modifierProcessor.ts","../src/utility/conditionalInfo.ts","../src/internal/applyModifiers.ts","../src/core/conditionalRenderer.ts","../src/core/elementFactory.ts","../src/core/tagRegistry.ts","../src/list/runtime.ts","../src/utility/renderables.ts","../src/utility/arrayUtils.ts","../src/list/renderer.ts","../src/utility/conditions.ts","../src/when/index.ts","../src/core/conditionalUpdater.ts","../src/core/updateController.ts","../src/utility/events.ts","../src/utility/on.ts","../src/utility/render.ts","../src/core/runtimeBootstrap.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n return value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n return value instanceof Node;\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n return isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\nexport function isFunction<T extends Function>(value: unknown): value is T {\n return typeof value === \"function\";\n}\n\nexport function isZeroArityFunction(value: unknown): value is () => unknown {\n return isFunction(value) && (value as Function).length === 0;\n}\n","/**\n * Simplified error handling for nuclo - reduced complexity for smaller bundle size\n */\n\n// Basic error logging - no complex context tracking\nexport function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n console.error(`nuclo: ${message}`, error);\n }\n}\n\n// Simplified safe execution - no complex context\nexport function safeExecute<T>(fn: () => T, fallback?: T): T | undefined {\n try {\n return fn();\n } catch (error) {\n logError(\"Operation failed\", error);\n return fallback;\n }\n}\n\n// Basic DOM error handler\nexport function handleDOMError(error: Error | unknown, operation: string): void {\n logError(`DOM ${operation} failed`, error);\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","import { isBrowser } from \"./environment\";\nimport { logError } from \"./errorHandler\";\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n if (!parent || !child) return false;\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n if (!parent || !newNode) return false;\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return document.createTextNode(String(text));\n } catch (error) {\n logError('Failed to create text node', error);\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch (error) {\n logError('Failed to create comment node', error);\n return null;\n }\n}\n\n/**\n * Creates a comment node safely with error handling.\n * Exported for use across the codebase.\n */\nexport function createComment(text: string): Comment | null {\n return createCommentSafely(text);\n}\n\n/**\n * Creates a conditional comment placeholder node.\n * In SSR environments, this will still work because we bypass the isBrowser check.\n */\nexport function createConditionalComment(tagName: string, suffix: string = \"hidden\"): Comment | null {\n // For SSR, we need to create comments even when isBrowser is false\n // This function intentionally skips the isBrowser check for SSR compatibility\n try {\n return document.createComment(`conditional-${tagName}-${suffix}`);\n } catch (error) {\n logError('Failed to create conditional comment', error);\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(node => safeInsertBefore(parent, node, referenceNode));\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach((child) => {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n\n // Prefer the built-in isConnected property\n if (typeof node.isConnected === \"boolean\") {\n return node.isConnected;\n }\n\n // Fallback for older browsers (only if in browser environment)\n if (isBrowser && typeof document !== 'undefined') {\n return document.contains(node);\n }\n\n // In SSR or when document is not available, assume disconnected\n return false;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n","import { logError, safeExecute } from \"../utility/errorHandler\";\nimport { isNodeConnected } from \"../utility/dom\";\n\ntype TextResolver = () => Primitive;\ntype AttributeResolver = () => unknown;\n\ninterface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n}\n\ninterface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\ninterface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n updateListener?: EventListener;\n}\n\nconst reactiveTextNodes = new Map<Text, ReactiveTextNodeInfo>();\nconst reactiveElements = new Map<Element, ReactiveElementInfo>();\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n let info = reactiveElements.get(el);\n if (!info) {\n info = { attributeResolvers: new Map() };\n reactiveElements.set(el, info);\n }\n return info;\n}\n\nfunction applyAttributeResolvers(el: Element, info: ReactiveElementInfo): void {\n info.attributeResolvers.forEach(({ resolver, applyValue }, key) => {\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(`Failed to update reactive attribute: ${key}`, e);\n }\n });\n}\n\n/**\n * Creates a reactive text node that automatically updates when its resolver function changes.\n *\n * The text node will be registered for reactive updates and its content will be synchronized\n * whenever notifyReactiveTextNodes() is called.\n *\n * @param resolver - Function that returns the text content (string, number, boolean, etc.)\n * @param preEvaluated - Optional pre-evaluated value to avoid calling resolver immediately\n * @returns A Text node that will reactively update its content\n *\n * @example\n * ```ts\n * const count = signal(0);\n * const textNode = createReactiveTextNode(() => `Count: ${count.value}`);\n * // Later, when count changes and notifyReactiveTextNodes() is called,\n * // the text content automatically updates\n * ```\n */\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n return document.createTextNode(\"\");\n }\n\n const initial = arguments.length > 1 ? preEvaluated : safeExecute(resolver, \"\");\n const str = initial === undefined ? \"\" : String(initial);\n const txt = document.createTextNode(str);\n\n reactiveTextNodes.set(txt, { resolver, lastValue: str });\n return txt;\n}\n\n/**\n * Registers a reactive attribute resolver for an element.\n *\n * The resolver will be called whenever the element receives an 'update' event,\n * allowing attributes to reactively update based on application state.\n *\n * @param element - The DOM element to make reactive\n * @param key - The attribute name being made reactive (e.g., 'class', 'style', 'disabled')\n * @param resolver - Function that returns the new attribute value\n * @param applyValue - Callback that applies the resolved value to the element\n *\n * @example\n * ```ts\n * const isActive = signal(false);\n * const button = document.createElement('button');\n * registerAttributeResolver(\n * button,\n * 'class',\n * () => isActive.value ? 'active' : 'inactive',\n * (value) => button.className = String(value)\n * );\n * ```\n */\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, { resolver, applyValue });\n\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(\"Failed to apply initial attribute value\", e);\n }\n\n if (!info.updateListener) {\n const listener: EventListener = () => applyAttributeResolvers(element as Element, info);\n (element as Element).addEventListener(\"update\", listener);\n info.updateListener = listener;\n }\n}\n\n/**\n * Updates all registered reactive text nodes.\n *\n * Iterates through all reactive text nodes, re-evaluates their resolver functions,\n * and updates their content if it has changed. Automatically cleans up disconnected nodes.\n *\n * This function should be called after state changes to synchronize the DOM with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * count.value++;\n * notifyReactiveTextNodes(); // All reactive text nodes update\n * ```\n */\nexport function notifyReactiveTextNodes(): void {\n reactiveTextNodes.forEach((info, node) => {\n if (!isNodeConnected(node)) {\n reactiveTextNodes.delete(node);\n return;\n }\n try {\n const raw = safeExecute(info.resolver);\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n }\n });\n}\n\n/**\n * Updates all registered reactive elements by re-evaluating their attribute resolvers.\n *\n * Iterates through all reactive elements and triggers their registered attribute resolvers\n * to update. Automatically cleans up disconnected elements and their event listeners.\n *\n * This function should be called after state changes to synchronize element attributes\n * with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * isActive.value = true;\n * notifyReactiveElements(); // All reactive attributes update\n * ```\n */\nexport function notifyReactiveElements(): void {\n reactiveElements.forEach((info, el) => {\n if (!isNodeConnected(el)) {\n if (info.updateListener) el.removeEventListener(\"update\", info.updateListener);\n reactiveElements.delete(el);\n return;\n }\n applyAttributeResolvers(el, info);\n });\n}\n","/**\n * Type-safe DOM helper utilities to reduce type assertions across the codebase.\n * These helpers provide proper typing for DOM operations while maintaining runtime safety.\n */\n\n/**\n * Safely casts an Element-like object to Node & ParentNode interface.\n * This is a common pattern needed when working with DOM manipulation.\n *\n * @param element - The element to cast\n * @returns The element typed as Node & ParentNode\n */\nexport function asParentNode<T extends Element | object>(element: T): Node & ParentNode {\n return element as unknown as Node & ParentNode;\n}\n\n/**\n * Creates a scoped DOM insertion context that temporarily redirects appendChild\n * to insertBefore at a specific reference node. This is useful for inserting\n * content at specific positions in the DOM tree.\n *\n * @param host - The host element\n * @param referenceNode - The node before which new nodes should be inserted\n * @param callback - Function to execute with the scoped context\n * @returns The result of the callback\n */\nexport function withScopedInsertion<T, THost extends Element | object>(\n host: THost,\n referenceNode: Node,\n callback: () => T\n): T {\n const parent = asParentNode(host);\n const originalAppend = parent.appendChild.bind(parent);\n const originalInsert = parent.insertBefore.bind(parent);\n\n // Temporarily override appendChild to insert before the reference node\n // TypeScript doesn't like this override but it's safe at runtime\n (parent as unknown as Record<string, unknown>).appendChild = function(node: Node): Node {\n return originalInsert(node, referenceNode);\n };\n\n try {\n return callback();\n } finally {\n // Restore original method\n (parent as unknown as Record<string, unknown>).appendChild = originalAppend;\n }\n}\n\n/**\n * Type-safe wrapper for setting CSS style properties.\n * Provides better error handling than direct CSSStyleDeclaration access.\n * Supports both camelCase and kebab-case property names.\n *\n * @param element - The element to apply styles to\n * @param property - The CSS property name (camelCase or kebab-case)\n * @param value - The value to set (string, number, or null to remove)\n * @returns true if the style was applied successfully, false otherwise\n */\nexport function setStyleProperty(\n element: HTMLElement,\n property: string,\n value: string | number | null\n): boolean {\n try {\n if (value === null || value === undefined || value === '') {\n // Use bracket notation to remove property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = '';\n return true;\n }\n\n // Convert value to string first (might throw if toString() throws)\n const stringValue = String(value);\n // Use bracket notation to set property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = stringValue;\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Type-safe wrapper for reading CSS style properties.\n *\n * @param element - The element to read styles from\n * @param property - The CSS property name\n * @returns The computed style value or empty string if not found\n */\nexport function getStyleProperty(\n element: HTMLElement,\n property: string\n): string {\n try {\n return element.style.getPropertyValue(property);\n } catch {\n return '';\n }\n}\n","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\nimport { setStyleProperty } from \"../utility/domTypeHelpers\";\nimport { logError } from \"../utility/errorHandler\";\n\ntype StyleAssignment = Partial<CSSStyleDeclaration>;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element?.style || !styles) return;\n\n for (const [property, value] of Object.entries(styles)) {\n const success = setStyleProperty(\n element as HTMLElement,\n property,\n value as string | number | null\n );\n\n if (!success) {\n // Don't try to stringify value in error message as it might throw\n logError(`Failed to set style property '${property}'`);\n }\n }\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', () => {\n try {\n return styleValue();\n } catch (error) {\n logError('Error in style resolver function', error);\n return null;\n }\n }, (resolvedStyles) => {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver, createReactiveTextNode } from \"./reactive\";\nimport { applyStyleAttribute } from \"./styleManager\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown): void => {\n if (v == null) return;\n\n // SVG elements should always use setAttribute for most attributes\n // because many SVG properties are read-only\n const isSVGElement = el instanceof Element && el.namespaceURI === 'http://www.w3.org/2000/svg';\n\n if (isSVGElement) {\n // Always use setAttribute for SVG elements\n el.setAttribute(String(key), String(v));\n } else if (key in el) {\n // For HTML elements, try to set as property first\n try {\n (el as Record<string, unknown>)[key as string] = v;\n } catch {\n // If property is read-only, fall back to setAttribute\n if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n }\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && raw.length === 0) {\n // Type narrowing: zero-arity function that returns an attribute value\n const resolver = raw as () => AttributeCandidate<TTagName>;\n registerAttributeResolver(el, String(key), resolver, setValue);\n } else {\n setValue(raw);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n applySingleAttribute(element, k, value);\n }\n}\n\nexport { createReactiveTextNode } from \"./reactive\";\n","import { isFunction, isNode, isObject } from \"./typeGuards\";\n\ntype BooleanCondition = () => boolean;\ntype ZeroArityFunction = () => unknown;\n\nconst modifierProbeCache = new WeakMap<ZeroArityFunction, { value: unknown; error: boolean }>();\n\nfunction probeOnce(fn: ZeroArityFunction): { value: unknown; error: boolean } {\n const cached = modifierProbeCache.get(fn);\n if (cached) {\n return cached;\n }\n try {\n const value = fn();\n const record = { value, error: false };\n modifierProbeCache.set(fn, record);\n return record;\n } catch {\n const record = { value: undefined, error: true };\n modifierProbeCache.set(fn, record);\n return record;\n }\n}\n\nfunction isBooleanFunction(fn: ZeroArityFunction): fn is BooleanCondition {\n const { value, error } = probeOnce(fn);\n if (error) return false;\n return typeof value === \"boolean\";\n}\n\nexport function isConditionalModifier(\n modifier: unknown,\n allModifiers: unknown[],\n currentIndex: number\n): modifier is BooleanCondition {\n if (!isFunction(modifier) || modifier.length !== 0) {\n return false;\n }\n\n // After checking length === 0, we know it's a ZeroArityFunction\n const zeroArityFn = modifier as ZeroArityFunction;\n if (!isBooleanFunction(zeroArityFn)) {\n return false;\n }\n\n const otherModifiers = allModifiers.filter((_, index) => index !== currentIndex);\n if (otherModifiers.length === 0) return false;\n\n const hasAttributesOrElements = otherModifiers.some((mod) => {\n if (isObject(mod) || isNode(mod)) return true;\n if (isFunction(mod) && mod.length > 0) return true;\n return false;\n });\n\n return hasAttributesOrElements;\n}\n\nexport function findConditionalModifier(modifiers: unknown[]): number {\n for (let i = 0; i < modifiers.length; i += 1) {\n if (isConditionalModifier(modifiers[i], modifiers, i)) {\n return i;\n }\n }\n return -1;\n}\n\nexport { modifierProbeCache };\n","import { applyAttributes } from \"./attributeManager\";\nimport { createReactiveTextNode } from \"./reactive\";\nimport { logError } from \"../utility/errorHandler\";\nimport { isFunction, isNode, isObject, isPrimitive, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { createComment } from \"../utility/dom\";\n\nexport { isConditionalModifier, findConditionalModifier } from \"../utility/modifierPredicates\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n parent: ExpandedElement<TTagName>,\n modifier: NodeModifier<TTagName>,\n index: number,\n): Node | null {\n if (modifier == null) return null;\n\n if (isFunction(modifier)) {\n // Handle zero-argument functions (reactive text)\n if (isZeroArityFunction(modifier)) {\n try {\n let record = modifierProbeCache.get(modifier);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier, record);\n }\n if (record.error) {\n return createReactiveTextFragment(index, () => \"\");\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n return createReactiveTextFragment(index, modifier as () => Primitive, v);\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n return createReactiveTextFragment(index, () => \"\");\n }\n }\n\n // Handle NodeModFn functions\n const produced = modifier(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n return createStaticTextFragment(index, produced);\n }\n if (isNode(produced)) return produced;\n if (isObject(produced)) {\n applyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n }\n return null;\n }\n\n // Handle non-function modifiers\n const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n return createStaticTextFragment(index, candidate);\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n\nfunction createReactiveTextFragment(\n index: number,\n resolver: () => Primitive,\n preEvaluated?: unknown\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = createReactiveTextNode(resolver, preEvaluated);\n fragment.appendChild(textNode);\n return fragment;\n}\n\nfunction createStaticTextFragment(index: number, value: Primitive): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = document.createTextNode(String(value));\n fragment.appendChild(textNode);\n return fragment;\n}\n","export interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {\n condition: () => boolean;\n tagName: TTagName;\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n}\n\ninterface NodeWithConditionalInfo extends Node {\n _conditionalInfo?: ConditionalInfo<keyof HTMLElementTagNameMap>;\n}\n\n/**\n * Registry of all nodes that have conditional info attached.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<Node>();\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo<TTagName extends ElementTagName>(\n node: Node,\n info: ConditionalInfo<TTagName>\n): void {\n (node as NodeWithConditionalInfo)._conditionalInfo = info as ConditionalInfo<keyof HTMLElementTagNameMap>;\n activeConditionalNodes.add(node);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n */\nexport function unregisterConditionalNode(node: Node): void {\n activeConditionalNodes.delete(node);\n}\n\n/**\n * Returns a readonly view of currently tracked conditional nodes.\n */\nexport function getActiveConditionalNodes(): ReadonlySet<Node> {\n return activeConditionalNodes;\n}\n\nexport function hasConditionalInfo(node: Node): boolean {\n return Boolean((node as NodeWithConditionalInfo)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo<keyof HTMLElementTagNameMap> | null {\n return (node as NodeWithConditionalInfo)._conditionalInfo ?? null;\n}\n","/**\n * Shared helper for applying an array of modifiers to an element.\n * Consolidates the previously duplicated logic in several modules:\n * - conditionalRenderer\n * - conditionalUpdater\n * - elementFactory\n *\n * Goal: single, optimized, well‑typed implementation.\n *\n * A \"modifier\" can:\n * - Return (or be) primitives → appended as text\n * - Return (or be) Node → appended (if not already a child)\n * - Return (or be) attribute objects → merged into element\n * - Be a NodeModFn invoked with (parent, index)\n * - Be a zero‑arg function producing reactive text (handled upstream in applyNodeModifier)\n *\n * Indexing:\n * - startIndex allows callers to continue an index sequence if needed.\n * - Every successfully rendered child Node increments the local index.\n */\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport interface ApplyModifiersResult<TTagName extends ElementTagName> {\n /**\n * The element passed in (for fluent patterns if desired).\n */\n element: ExpandedElement<TTagName>;\n /**\n * The next index after processing (startIndex + rendered children count).\n */\n nextIndex: number;\n /**\n * Number of child nodes appended (not counting attributes-only modifiers).\n */\n appended: number;\n}\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * Returns meta information that callers can use for continuation indexing.\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ApplyModifiersResult<TTagName> {\n if (!modifiers || modifiers.length === 0) {\n return { element, nextIndex: startIndex, appended: 0 };\n }\n\n let localIndex = startIndex;\n let appended = 0;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n appended += 1;\n }\n\n return {\n element,\n nextIndex: localIndex,\n appended\n };\n}\n\n/**\n * Convenience helper: apply modifiers and return the element (fluent style).\n * Discards meta information.\n */\nexport function applyModifiersAndReturn<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ExpandedElement<TTagName> {\n applyModifiers(element, modifiers, startIndex);\n return element;\n}\n\n/**\n * Creates an element with the specified tag name and applies modifiers to it.\n * Centralizes element creation logic used across conditionalRenderer and conditionalUpdater.\n */\nexport function createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers, 0);\n return el;\n}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { createElementWithModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { createConditionalComment } from \"../utility/dom\";\n\nexport function createConditionalElement<TTagName extends ElementTagName>(\n tagName: TTagName,\n condition: () => boolean,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> | Comment {\n const passed = condition();\n\n if (!isBrowser) {\n return passed\n ? createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>)\n : (createConditionalComment(tagName, \"ssr\") as unknown as ExpandedElement<TTagName>);\n }\n\n const conditionalInfo: ConditionalInfo<TTagName> = { condition, tagName, modifiers };\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>);\n storeConditionalInfo(el as Node, conditionalInfo);\n return el;\n }\n\n const comment = createConditionalComment(tagName);\n if (!comment) {\n throw new Error(`Failed to create conditional comment for ${tagName}`);\n }\n storeConditionalInfo(comment as Node, conditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nexport function processConditionalModifiers<TTagName extends ElementTagName>(\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): {\n condition: (() => boolean) | null;\n otherModifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n} {\n const conditionalIndex = findConditionalModifier(modifiers);\n\n if (conditionalIndex === -1) {\n return { condition: null, otherModifiers: modifiers };\n }\n\n return {\n condition: modifiers[conditionalIndex] as () => boolean,\n otherModifiers: modifiers.filter((_, index) => index !== conditionalIndex)\n };\n}\n","import { createConditionalElement, processConditionalModifiers } from \"./conditionalRenderer\";\nimport { applyModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { SVG_TAGS } from \"./tagRegistry\";\n\n/**\n * Checks if a tag name is an SVG tag.\n */\nfunction isSVGTag(tagName: string): tagName is keyof SVGElementTagNameMap {\n return (SVG_TAGS as readonly string[]).includes(tagName);\n}\n\n/**\n * Creates an element with proper namespace handling for SVG elements.\n */\nfunction createElementWithNamespace<TTagName extends ElementTagName>(\n tagName: TTagName\n): Element {\n if (isSVGTag(tagName)) {\n return document.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n return document.createElement(tagName);\n}\n\nexport function createElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> => {\n const { condition, otherModifiers } = processConditionalModifiers(modifiers);\n\n if (condition) {\n return createConditionalElement(tagName, condition, otherModifiers) as ExpandedElement<TTagName>;\n }\n\n const el = createElementWithNamespace(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, otherModifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n return el;\n };\n}\n\nexport function createTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): (...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>) => NodeModFn<TTagName> {\n return (...mods) => createElementFactory(tagName, ...mods);\n}","import { createTagBuilder } from \"./elementFactory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n // Don't overwrite non-function properties (safety check)\n if (tagName in target && typeof target[tagName] !== 'function') {\n return;\n }\n // Register HTML tags - they override SVG tags with same name\n target[tagName] = createTagBuilder(tagName);\n}\n\nfunction registerSvgTag(target: Record<string, unknown>, tagName: keyof SVGElementTagNameMap): void {\n // Some SVG tags conflict with HTML tags or DOM globals\n // Use suffix convention: a_svg, script_svg, style_svg, title_svg, text_svg, stop_\n const conflictingTags = ['a', 'script', 'style', 'title', 'text'];\n const globalConflicts = ['stop']; // 'stop' conflicts with DOM stop property\n\n let exportName: string = tagName;\n if (conflictingTags.includes(tagName)) {\n exportName = `${tagName}_svg`;\n } else if (globalConflicts.includes(tagName)) {\n exportName = `${tagName}_`;\n }\n\n if (!(exportName in target)) {\n target[exportName] = createTagBuilder(tagName as ElementTagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__nuclo_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n // Register SVG tags first with special names for conflicts\n SVG_TAGS.forEach((tagName) => registerSvgTag(target, tagName));\n\n // Then register HTML tags - these will take precedence for conflicting names\n // So 'a' will be HTML by default, and 'a_svg' will be available for SVG anchors\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\n\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { createMarkerPair, safeRemoveChild } from \"../utility/dom\";\nimport { arraysEqual } from \"../utility/arrayUtils\";\nimport { resolveRenderable } from \"../utility/renderables\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsProvider } from \"./types\";\n\nconst activeListRuntimes = new Set<ListRuntime<unknown, keyof HTMLElementTagNameMap>>();\n\nfunction renderItem<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>,\n item: TItem,\n index: number,\n): ExpandedElement<TTagName> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable<TTagName>(result, runtime.host, index);\n}\n\nfunction remove<TItem, TTagName extends ElementTagName>(record: ListItemRecord<TItem, TTagName>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>\n): void {\n const { host, startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const currentItems = runtime.itemsProvider();\n\n if (arraysEqual(runtime.lastSyncedItems, currentItems)) return;\n\n const recordsByPosition = new Map<number, ListItemRecord<TItem, TTagName>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem, TTagName>[]>();\n\n runtime.records.forEach((record) => {\n const items = availableRecords.get(record.item);\n if (items) {\n items.push(record);\n } else {\n availableRecords.set(record.item, [record]);\n }\n });\n\n currentItems.forEach((item, newIndex) => {\n if (\n newIndex < runtime.lastSyncedItems.length &&\n runtime.lastSyncedItems[newIndex] === item\n ) {\n const existingRecord = runtime.records[newIndex];\n if (existingRecord && existingRecord.item === item) {\n recordsByPosition.set(newIndex, existingRecord);\n const items = availableRecords.get(item);\n if (items) {\n const recordIndex = items.indexOf(existingRecord);\n if (recordIndex >= 0) {\n items.splice(recordIndex, 1);\n if (items.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n }\n }\n });\n\n const newRecords: Array<ListItemRecord<TItem, TTagName>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem, TTagName>>(runtime.records);\n let nextSibling: Node = endMarker;\n\n for (let i = currentItems.length - 1; i >= 0; i--) {\n const item = currentItems[i];\n let record = recordsByPosition.get(i);\n\n if (!record) {\n const availableItems = availableRecords.get(item);\n if (availableItems && availableItems.length > 0) {\n record = availableItems.shift()!;\n if (availableItems.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n\n if (record) {\n elementsToRemove.delete(record);\n } else {\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n record = { item, element };\n }\n\n newRecords.unshift(record);\n\n const recordNode = record.element as unknown as Node;\n if (recordNode.nextSibling !== nextSibling) {\n parent.insertBefore(recordNode, nextSibling);\n }\n nextSibling = recordNode;\n }\n\n elementsToRemove.forEach(remove);\n\n runtime.records = newRecords;\n runtime.lastSyncedItems = [...currentItems];\n}\n\nexport function createListRuntime<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n): ListRuntime<TItem, TTagName> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem, TTagName> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n activeListRuntimes.add(runtime as ListRuntime<unknown, keyof HTMLElementTagNameMap>);\n sync(runtime);\n\n return runtime;\n}\n\nexport function updateListRuntimes(): void {\n activeListRuntimes.forEach((runtime) => {\n if (!runtime.startMarker.isConnected || !runtime.endMarker.isConnected) {\n activeListRuntimes.delete(runtime);\n return;\n }\n\n sync(runtime);\n });\n}\n","import { isFunction, isTagLike } from \"./typeGuards\";\n\ntype RenderableInput<TTagName extends ElementTagName = ElementTagName> =\n | NodeModFn<TTagName>\n | ExpandedElement<TTagName>\n | Node\n | null\n | undefined;\n\nexport function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(\n result: RenderableInput<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number\n): ExpandedElement<TTagName> | null {\n if (isFunction(result)) {\n const element = result(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<TTagName>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<TTagName>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if ((i in a ? a[i] : undefined) !== (i in b ? b[i] : undefined)) return false;\n }\n return true;\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n */\nexport function list<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem, TTagName>,\n): NodeModFn<TTagName> {\n return (host: ExpandedElement<TTagName>, index: number): Comment => {\n const runtime = createListRuntime(itemsProvider, render, host);\n // Return the start marker comment node\n // NodeModFn can return NodeMod | void, and Comment is a valid Node type\n return runtime.startMarker;\n };\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (onError) {\n onError(error);\n return false;\n }\n throw error;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\" ? runCondition(value, onError) : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore, createComment } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { asParentNode, withScopedInsertion } from \"../utility/domTypeHelpers\";\n\ntype WhenCondition = boolean | (() => boolean);\ntype WhenContent<TTagName extends ElementTagName = ElementTagName> = \n NodeMod<TTagName> | NodeModFn<TTagName>;\n\ninterface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\ninterface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet\n * - -1: else branch\n * - >=0: index of groups[]\n */\n activeIndex: number | -1 | null;\n update(): void;\n}\n\nconst activeWhenRuntimes = new Set<WhenRuntime<any>>();\n\n/**\n * Evaluates which condition branch should be active.\n * Returns the index of the first truthy condition, -1 for else branch, or null for no match.\n */\nfunction evaluateActiveCondition<TTagName extends ElementTagName>(\n groups: ReadonlyArray<WhenGroup<TTagName>>,\n elseContent: ReadonlyArray<WhenContent<TTagName>>\n): number | -1 | null {\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n return i;\n }\n }\n return elseContent.length > 0 ? -1 : null;\n}\n\n/**\n * Renders a single content item and returns the resulting node if any.\n */\nfunction renderContentItem<TTagName extends ElementTagName>(\n item: WhenContent<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node | null {\n if (!isFunction(item)) {\n return applyNodeModifier(host, item, index);\n }\n\n // Zero-arity functions need cache cleared\n if (isZeroArityFunction(item)) {\n modifierProbeCache.delete(item);\n return applyNodeModifier(host, item, index);\n }\n\n // Non-zero-arity functions need scoped insertion to insert before endMarker\n return withScopedInsertion(host, endMarker, () => {\n const maybeNode = applyNodeModifier(host, item, index);\n // Only include nodes that weren't already inserted\n return maybeNode && !maybeNode.parentNode ? maybeNode : null;\n });\n}\n\n/**\n * Renders a list of content items and collects the resulting nodes.\n */\nfunction renderContentItems<TTagName extends ElementTagName>(\n items: ReadonlyArray<WhenContent<TTagName>>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node[] {\n const nodes: Node[] = [];\n for (const item of items) {\n const node = renderContentItem(item, host, index, endMarker);\n if (node) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\n/**\n * Main render function for when/else conditionals.\n * Evaluates conditions, clears old content, and renders the active branch.\n */\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n const newActive = evaluateActiveCondition(groups, elseContent);\n\n // No change needed\n if (newActive === runtime.activeIndex) return;\n\n // Clear previous content and update active index\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n // Nothing to render\n if (newActive === null) return;\n\n // Render the active branch\n const contentToRender = newActive >= 0 ? groups[newActive].content : elseContent;\n const nodes = renderContentItems(contentToRender, host, index, endMarker);\n\n insertNodesBefore(nodes, endMarker);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!isBrowser) {\n const comment = createComment(\"when-ssr\");\n return comment || null;\n }\n\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\");\n\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex: null,\n update: () => renderWhenContent(runtime),\n };\n\n activeWhenRuntimes.add(runtime);\n\n const parent = asParentNode(host);\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n return startMarker;\n }\n}\n\nfunction createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = (host: ExpandedElement<TTagName>, index: number): Node | null => {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: (condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.when(condition, ...content);\n return createWhenBuilderFunction(builder);\n },\n else: (...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.else(...content);\n return createWhenBuilderFunction(builder);\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\n/**\n * Updates all active when/else conditional runtimes.\n *\n * Re-evaluates all conditional branches and re-renders if the active branch has changed.\n * Automatically cleans up runtimes that throw errors during update.\n *\n * This function should be called after state changes that affect conditional expressions.\n *\n * @example\n * ```ts\n * isLoggedIn.value = true;\n * updateWhenRuntimes(); // All when() conditionals re-evaluate\n * ```\n */\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\n/**\n * Clears all active when/else conditional runtimes.\n *\n * This is typically used for cleanup or testing purposes.\n * After calling this, no when() conditionals will be tracked for updates.\n */\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\n}\n\n/**\n * Creates a conditional rendering block (when/else logic).\n *\n * Renders different content based on boolean conditions, similar to if/else statements.\n * Conditions can be static booleans or reactive functions that are re-evaluated on updates.\n *\n * @param condition - Boolean value or function returning a boolean\n * @param content - Content to render when condition is true\n * @returns A builder that allows chaining additional .when() or .else() branches\n *\n * @example\n * ```ts\n * const isLoggedIn = signal(false);\n *\n * div(\n * when(() => isLoggedIn.value,\n * span('Welcome back!')\n * )\n * .else(\n * button('Login', on('click', () => login()))\n * )\n * )\n * ```\n *\n * @example\n * ```ts\n * // Multiple conditions\n * div(\n * when(() => status.value === 'loading',\n * spinner()\n * )\n * .when(() => status.value === 'error',\n * errorMessage()\n * )\n * .else(\n * contentView()\n * )\n * )\n * ```\n */\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { createElementWithModifiers } from \"../internal/applyModifiers\";\nimport { isBrowser } from \"../utility/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"../utility/conditionalInfo\";\nimport { runCondition } from \"../utility/conditions\";\nimport { replaceNodeSafely, createConditionalComment } from \"../utility/dom\";\nimport { logError } from \"../utility/errorHandler\";\n\nfunction createElementFromConditionalInfo<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): ExpandedElement<TTagName> {\n try {\n return createElementWithModifiers(conditionalInfo.tagName, conditionalInfo.modifiers);\n } catch (error) {\n logError(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\"`, error);\n // Return a basic element without modifiers as fallback\n return document.createElement(conditionalInfo.tagName) as ExpandedElement<TTagName>;\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n logError(\"Error evaluating conditional condition\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element as Node, conditionalInfo);\n replaceNodeSafely(node, element as Node);\n } else if (!shouldShow && isElement) {\n const comment = createConditionalComment(conditionalInfo.tagName);\n if (comment) {\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n }\n}\n\nexport function updateConditionalElements(): void {\n if (!isBrowser) return;\n\n try {\n getActiveConditionalNodes().forEach((node) => {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n return;\n }\n updateConditionalNode(node as Element | Comment);\n });\n } catch (error) {\n logError(\"Error during conditional elements update\", error);\n }\n}\n","import { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements, notifyReactiveTextNodes } from \"./reactive\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditionalUpdater\";\nimport { dispatchGlobalUpdateEvent } from \"../utility/events\";\n\nconst updaters = [\n updateListRuntimes,\n updateWhenRuntimes,\n updateConditionalElements,\n notifyReactiveElements,\n notifyReactiveTextNodes,\n dispatchGlobalUpdateEvent,\n] as const;\n\nexport function update(): void {\n for (const fn of updaters) fn();\n}\n","import { logError } from \"./errorHandler\";\n\nexport function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") return;\n\n const targets: EventTarget[] = document.body ? [document.body, document] : [document];\n\n for (const target of targets) {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n logError(\"Error dispatching global update event\", error);\n }\n }\n}\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n */\n\nimport { logError } from \"./errorHandler\";\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: E) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on<TTagName extends ElementTagName = ElementTagName>(\n type: string,\n listener: (ev: Event) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>): void => {\n // Type guard: verify parent is an HTMLElement with addEventListener\n if (!parent || typeof (parent as HTMLElement).addEventListener !== \"function\") {\n return;\n }\n\n const el = parent as HTMLElement;\n const wrapped = (ev: Event): void => {\n try {\n listener.call(el, ev);\n } catch (error) {\n logError(`Error in '${type}' listener`, error);\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n };\n}\n\n/**\n * (Optional) Helper to detect an on()-produced modifier (placeholder for future use).\n */\nexport function isOnModifier(fn: unknown): boolean {\n return typeof fn === \"function\" && Object.prototype.hasOwnProperty.call(fn, \"__nucloOn\");\n}","/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (parent || document.body).appendChild(element as Node);\n return element;\n}\n","import { registerGlobalTagBuilders } from \"./tagRegistry\";\nimport { list } from \"../list\";\nimport { update } from \"./updateController\";\nimport { when } from \"../when\";\nimport { on } from \"../utility/on\";\nimport { render } from \"../utility/render\";\n\n/**\n * Initializes the nuclo runtime by exposing tag builders and utilities.\n */\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n if (typeof globalThis !== \"undefined\") {\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.render = render;\n }\n}\n\nif (typeof globalThis !== \"undefined\") {\n initializeRuntime();\n}\n"],"names":["isPrimitive","value","isNode","Node","isObject","isTagLike","isFunction","isZeroArityFunction","length","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createConditionalComment","tagName","suffix","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","insertNodesBefore","nodes","referenceNode","parent","forEach","node","newNode","insertBefore","safeInsertBefore","isNodeConnected","isConnected","contains","replaceNodeSafely","oldNode","replaceChild","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","resolver","applyValue","key","e","registerAttributeResolver","element","Element","get","set","ensureElementInfo","updateListener","listener","addEventListener","setStyleProperty","property","style","stringValue","String","assignInlineStyles","styles","Object","entries","applySingleAttribute","raw","styleValue","resolvedStyles","setValue","v","namespaceURI","setAttribute","applyAttributes","attributes","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","undefined","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","filter","_","index","some","mod","applyNodeModifier","createReactiveTextFragment","produced","createStaticTextFragment","candidate","preEvaluated","fragment","createDocumentFragment","appendChild","textNode","createTextNode","initial","arguments","str","txt","lastValue","createReactiveTextNode","activeConditionalNodes","Set","storeConditionalInfo","_conditionalInfo","add","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementWithNamespace","SVG_TAGS","includes","isSVGTag","createElementNS","createElementFactory","passed","conditionalInfo","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","exportName","registerSvgTag","registerHtmlTag","activeListRuntimes","renderItem","runtime","item","result","host","resolveRenderable","remove","sync","startMarker","endMarker","currentItems","itemsProvider","a","b","arraysEqual","lastSyncedItems","recordsByPosition","availableRecords","records","items","push","newIndex","existingRecord","recordIndex","indexOf","splice","delete","newRecords","elementsToRemove","nextSibling","availableItems","shift","unshift","recordNode","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderContentItem","callback","originalAppend","bind","originalInsert","withScopedInsertion","maybeNode","renderWhenContent","groups","elseContent","newActive","evaluateActiveCondition","activeIndex","current","next","clearBetweenMarkers","renderContentItems","content","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","updateConditionalNode","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","updaters","unregisterConditionalNode","removeEventListener","newVal","textContent","targets","body","dispatchEvent","Event","bubbles","on","type","options","ev","call","nodeModFn","initializeRuntime","registry","children","nodeToAppend","createTextNodeSafely","safeAppendChild"],"mappings":"4OAAM,SAAUA,EAAYC,GAC1B,OAAiB,OAAVA,GAAoC,iBAAVA,GAAuC,mBAAVA,C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AAVrP,EAAoB,CAC7B,MAAMuG,EA5Fd,SAA8BnG,GAC5B,IAAKR,EAAW,OAAO,KACvB,IACE,OAAOE,SAAS0G,eAAe5C,OAAOxD,GACxC,CAAE,MAAOb,GAEP,OADAF,EAAS,6BAA8BE,GAChC,IACT,CACF,CAoFyB+P,CAAqBtP,GACtC,IAAIuG,EAGF,OAFA8I,EAAe9I,CAInB,MACE8I,EAAerP,GApIvB,SAAyBwB,EAAwBxB,GAC/C,IAAKwB,IAAWxB,EAAO,OAAO,EAC9B,IAEE,OADAwB,EAAO8E,YAAYtG,IACZ,CACT,CAAE,MAAOT,GAEP,OADAF,EAAS,8BAA+BE,IACjC,CACT,CACF,CA8HMgQ,CAAgB/N,EAAQ6N,EAC1B,IAGK7N,GArBaA,CAsBtB,2MH/HM,SAAoB3C,GACxB,MAAwB,kBAAVA,CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifierPredicates.d.ts","sourceRoot":"","sources":["../../src/utility/modifierPredicates.ts"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"modifierPredicates.d.ts","sourceRoot":"","sources":["../../src/utility/modifierPredicates.ts"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC;AACtC,KAAK,iBAAiB,GAAG,MAAM,OAAO,CAAC;AAEvC,QAAA,MAAM,kBAAkB;WAA2C,OAAO;WAAS,OAAO;EAAK,CAAC;AAyBhG,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,OAAO,EAAE,EACvB,YAAY,EAAE,MAAM,GACnB,QAAQ,IAAI,gBAAgB,CAqB9B;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAOpE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/utility/on.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on.d.ts","sourceRoot":"","sources":["../../src/utility/on.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;GAEG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,MAAM,mBAAmB,EACnC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,OAAO,EACjD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,KAAK,GAAG,KAAK,EACvB,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,EAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"on.d.ts","sourceRoot":"","sources":["../../src/utility/on.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;GAEG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,MAAM,mBAAmB,EACnC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,OAAO,EACjD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,KAAK,GAAG,KAAK,EACvB,QAAQ,SAAS,cAAc,GAAG,cAAc,EAEhD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,EAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC;AA0BvB;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAEjD"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type RenderableInput<TTagName extends ElementTagName = ElementTagName> = NodeModFn<TTagName> | ExpandedElement<TTagName> | Node | null | undefined;
|
|
2
|
+
export declare function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(result: RenderableInput<TTagName>, host: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> | null;
|
|
3
|
+
export {};
|
|
2
4
|
//# sourceMappingURL=renderables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderables.d.ts","sourceRoot":"","sources":["../../src/utility/renderables.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChF,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"renderables.d.ts","sourceRoot":"","sources":["../../src/utility/renderables.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,IACjE,SAAS,CAAC,QAAQ,CAAC,GACnB,eAAe,CAAC,QAAQ,CAAC,GACzB,IAAI,GACJ,IAAI,GACJ,SAAS,CAAC;AAEd,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc,EAChF,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,EACjC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC/B,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC,QAAQ,CAAC,GAAG,IAAI,CAclC"}
|
package/package.json
CHANGED
package/types/core/base.d.ts
CHANGED
|
@@ -33,8 +33,8 @@ declare global {
|
|
|
33
33
|
| (() => Primitive)
|
|
34
34
|
| ExpandedElementAttributes<TTagName>
|
|
35
35
|
| ExpandedElement<TTagName>
|
|
36
|
-
|
|
|
37
|
-
| ((parent
|
|
36
|
+
| Node // Allow any DOM Node (including Comment, Text, SVGElement, etc.)
|
|
37
|
+
| ((parent: ExpandedElement<TTagName>, index: number) => Node); // Allow Node builders
|
|
38
38
|
|
|
39
39
|
export type NodeModFn<TTagName extends ElementTagName = ElementTagName> = (
|
|
40
40
|
parent: ExpandedElement<TTagName>,
|
package/types/index.d.ts
CHANGED
|
@@ -10,15 +10,15 @@ import "./features/on";
|
|
|
10
10
|
import "./features/render";
|
|
11
11
|
|
|
12
12
|
// Re-export on() helper for module-style consumers (import { on } from "nuclo")
|
|
13
|
-
export function on<K extends keyof HTMLElementEventMap>(
|
|
13
|
+
export function on<K extends keyof HTMLElementEventMap, TTagName extends ElementTagName = ElementTagName>(
|
|
14
14
|
type: K,
|
|
15
|
-
listener: (ev: HTMLElementEventMap[K]) =>
|
|
15
|
+
listener: (ev: HTMLElementEventMap[K]) => unknown,
|
|
16
16
|
options?: boolean | AddEventListenerOptions
|
|
17
|
-
): NodeModFn<
|
|
18
|
-
export function on<K extends string, E extends Event = Event>(
|
|
17
|
+
): NodeModFn<TTagName>;
|
|
18
|
+
export function on<K extends string, E extends Event = Event, TTagName extends ElementTagName = ElementTagName>(
|
|
19
19
|
type: K,
|
|
20
|
-
listener: (ev: E) =>
|
|
20
|
+
listener: (ev: E) => unknown,
|
|
21
21
|
options?: boolean | AddEventListenerOptions
|
|
22
|
-
): NodeModFn<
|
|
22
|
+
): NodeModFn<TTagName>;
|
|
23
23
|
|
|
24
24
|
export {};
|
package/types/svg/base.d.ts
CHANGED
|
@@ -77,20 +77,22 @@ declare global {
|
|
|
77
77
|
| SVGAttributes
|
|
78
78
|
| SVGElementTagNameMap[TTagName]
|
|
79
79
|
| SVGElement // Allow any SVG element as a child
|
|
80
|
-
| ((parent
|
|
80
|
+
| ((parent: SVGElementTagNameMap[TTagName], index: number) => SVGElement); // Allow SVG element builders as children
|
|
81
81
|
|
|
82
82
|
export type SVGElementModifierFn<TTagName extends keyof SVGElementTagNameMap = keyof SVGElementTagNameMap> = (
|
|
83
83
|
parent: SVGElementTagNameMap[TTagName],
|
|
84
84
|
index: number,
|
|
85
85
|
) => SVGElementModifier<TTagName> | void;
|
|
86
86
|
|
|
87
|
-
// SVG builder type
|
|
87
|
+
// SVG builder type - returns a NodeModFn-compatible function
|
|
88
|
+
// Parameters are optional to allow standalone usage (e.g., svg()() for creating detached SVG)
|
|
89
|
+
// but the function signature is compatible with NodeModFn when used as a child
|
|
88
90
|
export type ExpandedSVGElementBuilder<
|
|
89
91
|
TTagName extends keyof SVGElementTagNameMap = keyof SVGElementTagNameMap,
|
|
90
92
|
> = (
|
|
91
93
|
...rawMods: Array<SVGElementModifier<TTagName> | SVGElementModifierFn<TTagName>>
|
|
92
94
|
) => (
|
|
93
|
-
parent?: SVGElementTagNameMap[TTagName]
|
|
95
|
+
parent?: SVGElementTagNameMap[TTagName] | ExpandedElement<ElementTagName>,
|
|
94
96
|
index?: number,
|
|
95
97
|
) => SVGElementTagNameMap[TTagName];
|
|
96
98
|
}
|