nuclo 0.1.39 → 0.1.40

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.
@@ -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/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","/**\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\";\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 {\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 {\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 {\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 {\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 {\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 return typeof node.isConnected === \"boolean\" ? node.isConnected : document.contains(node);\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\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\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\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\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","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\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) return;\n if (!element.style) return; // Guard against elements without style\n if (!styles) return;\n\n Object.entries(styles).forEach(([property, value]) => {\n if (value == null || value === '') {\n // Try both camelCase and kebab-case removal\n element.style!.removeProperty(property);\n // Also set to empty string as fallback\n (element.style as any)[property] = '';\n } else {\n try {\n (element.style as any)[property] = String(value);\n } catch {\n // Ignore invalid style properties\n }\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 {\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 if (key in el) {\n (el as Record<string, unknown>)[key as string] = v;\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 AnyModifier = unknown;\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: AnyModifier,\n allModifiers: AnyModifier[],\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: AnyModifier[]): 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 } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\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 if (modifier.length === 0) {\n try {\n let record = modifierProbeCache.get(modifier as Function);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier as Function, record);\n }\n if (record.error) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(() => \"\");\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(modifier as () => Primitive, v);\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier as Function, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(() => \"\");\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n }\n\n const produced = (modifier as NodeModFn<TTagName>)(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(produced));\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\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 const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(candidate));\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n","export interface ConditionalInfo {\n condition: () => boolean;\n tagName: string;\n modifiers: Array<NodeMod<any> | NodeModFn<any>>;\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(\n node: Node,\n info: ConditionalInfo\n): void {\n (node as any)._conditionalInfo = info;\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 any)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo | null {\n return ((node as any)._conditionalInfo as ConditionalInfo | undefined) ?? 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}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { applyModifiers, NodeModifier } from \"../internal/applyModifiers\";\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)\n : (document.createComment(`conditional-${tagName}-ssr`) as unknown as ExpandedElement<TTagName>);\n }\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers);\n storeConditionalInfo(el as Node, { condition, tagName, modifiers } as ConditionalInfo);\n return el;\n }\n\n const comment = document.createComment(`conditional-${tagName}-hidden`);\n storeConditionalInfo(comment as Node, { condition, tagName, modifiers } as ConditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nfunction createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers as ReadonlyArray<NodeModifier<TTagName>>, 0);\n return el;\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, NodeModifier } from \"../internal/applyModifiers\";\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 = document.createElement(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 if (!(tagName in target)) {\n target[tagName] = createTagBuilder(tagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__vc_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\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<any>>();\n\nfunction renderItem<TItem>(\n runtime: ListRuntime<TItem>,\n item: TItem,\n index: number,\n): ExpandedElement<any> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable(result, runtime.host, index);\n}\n\nfunction remove(record: ListItemRecord<unknown>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem>(runtime: ListRuntime<TItem>): 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>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem>[]>();\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>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem>>(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>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem>,\n host: ExpandedElement<any>,\n): ListRuntime<TItem> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem> = {\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);\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(\n result: unknown,\n host: ExpandedElement<any>,\n index: number\n): ExpandedElement<any> | null {\n if (isFunction(result)) {\n const element = (result as NodeModFn<any>)(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<any>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<any>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: T[], b: 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>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem>,\n): NodeModFn<any> {\n return (host: ExpandedElement<any>) => {\n const runtime = createListRuntime(itemsProvider, render, host);\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 throw error;\n }\n onError(error);\n return false;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\"\n ? runCondition(value as () => boolean, onError)\n : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction } from \"../utility/typeGuards\";\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\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n let newActive: number | -1 | null = null;\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n newActive = i;\n break;\n }\n }\n if (newActive === null && elseContent.length) {\n newActive = -1;\n }\n\n if (newActive === runtime.activeIndex) return;\n\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n if (newActive === null) return;\n\n const nodes: Node[] = [];\n\n const renderItems = (items: ReadonlyArray<WhenContent<TTagName>>): void => {\n for (const item of items) {\n if (isFunction(item)) {\n if ((item as Function).length === 0) {\n modifierProbeCache.delete(item as Function);\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n continue;\n }\n\n const realHost = host as unknown as Element & {\n appendChild: (n: Node) => Node;\n insertBefore: (n: Node, ref: Node | null) => Node;\n };\n const originalAppend = realHost.appendChild;\n (realHost as unknown as Record<string, Function>).appendChild = function (n: Node) {\n return (realHost as unknown as Record<string, Function>).insertBefore(\n n,\n endMarker\n ) as Node;\n };\n try {\n const maybeNode = applyNodeModifier(host, item, index);\n if (maybeNode && !maybeNode.parentNode) {\n nodes.push(maybeNode);\n }\n } finally {\n (realHost as unknown as Record<string, Function>).appendChild = originalAppend;\n }\n continue;\n }\n\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n }\n };\n\n if (newActive >= 0) {\n renderItems(groups[newActive].content);\n } else if (newActive === -1) {\n renderItems(elseContent);\n }\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) return document.createComment(\"when-ssr\");\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 = host as unknown as Node & ParentNode;\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\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\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 { applyModifiers } 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\";\n\nfunction createElementFromConditionalInfo(conditionalInfo: ConditionalInfo): Element {\n const element = document.createElement(conditionalInfo.tagName);\n\n try {\n applyModifiers(\n element as ExpandedElement<ElementTagName>,\n conditionalInfo.modifiers as ReadonlyArray<NodeMod<ElementTagName> | NodeModFn<ElementTagName>>,\n 0\n );\n } catch (error) {\n console.error(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\":`, error);\n }\n return element;\n}\n\nfunction createCommentPlaceholder(conditionalInfo: ConditionalInfo): Comment {\n return document.createComment(`conditional-${conditionalInfo.tagName}-hidden`);\n}\n\nfunction replaceNodeSafely(oldNode: Node, newNode: Node): void {\n if (oldNode.parentNode) {\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n } catch (error) {\n console.error(\"Error replacing conditional node:\", error);\n }\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 console.error(\"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, conditionalInfo);\n replaceNodeSafely(node, element);\n } else if (!shouldShow && isElement) {\n const comment = createCommentPlaceholder(conditionalInfo);\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\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 console.error(\"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","export function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const targets: EventTarget[] = [];\n if (document.body) {\n targets.push(document.body);\n }\n targets.push(document);\n\n targets.forEach((target) => {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n console.error(\"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\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]) => any,\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) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on(\n type: string,\n listener: (ev: Event) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<any> {\n return (parent: ExpandedElement<any>) => {\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 if (typeof console !== \"undefined\" && console.error) {\n console.error(`[nuclo:on] Error in '${type}' listener:`, error);\n }\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, \"__vcOn\");\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 View Craft 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","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","isNodeConnected","node","isConnected","contains","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","forEach","resolver","applyValue","key","e","createReactiveTextNode","preEvaluated","createTextNode","initial","arguments","length","str","undefined","String","txt","set","lastValue","registerAttributeResolver","element","Element","get","ensureElementInfo","updateListener","listener","addEventListener","assignInlineStyles","styles","style","Object","entries","property","removeProperty","applySingleAttribute","raw","styleValue","resolvedStyles","setValue","v","setAttribute","applyAttributes","attributes","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","filter","_","index","some","mod","applyNodeModifier","parent","fragment","createDocumentFragment","textNode","appendChild","produced","candidate","activeConditionalNodes","Set","storeConditionalInfo","_conditionalInfo","add","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","tagName","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementFactory","passed","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","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","insertBefore","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderWhenContent","groups","elseContent","newActive","activeIndex","current","next","clearBetweenMarkers","nodes","renderItems","realHost","originalAppend","n","maybeNode","content","referenceNode","newNode","safeInsertBefore","insertNodesBefore","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","replaceNodeSafely","oldNode","replaceChild","updateConditionalNode","conditionalInfo","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","createCommentPlaceholder","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,OAAVA,CACtC,CAEM,SAAUI,EAAaJ,GAC3B,OAAOG,EAASH,IAAU,YAAcA,CAC1C,CAMM,SAAUK,EAA+BL,GAC7C,MAAwB,mBAAVA,CAChB,CCjBM,SAAUM,EAASC,EAAiBC,GACjB,oBAAZC,SACTA,QAAQD,MAAM,UAAUD,IAAWC,EAEvC,CAGM,SAAUE,EAAeC,EAAaC,GAC1C,IACE,OAAOD,GACT,CAAE,MAAOH,GAEP,OADAF,EAAS,mBAAoBE,GACtBI,CACT,CACF,CCdO,MAAMC,EAA8B,oBAAXC,QAA8C,oBAAbC,SCO3D,SAAUC,EAAgBC,GAC9B,IAAKA,GAAOC,WAAY,OAAO,EAC/B,IAEE,OADAD,EAAMC,WAAWC,YAAYF,IACtB,CACT,CAAE,MACA,OAAO,CACT,CACF,CAqBA,SAASG,EAAoBC,GAC3B,IAAKR,EAAW,OAAO,KACvB,IACE,OAAOE,SAASO,cAAcD,EAChC,CAAE,MACA,OAAO,IACT,CACF,CAEM,SAAUE,EAAoBC,GAClC,IAAKX,EACH,MAAM,IAAIY,MAAM,oDAElB,MAAMC,EAAUN,EAAoB,GAAGI,KAAUG,KAAKC,SAASC,SAAS,IAAIC,MAAM,MAClF,IAAKJ,EACH,MAAM,IAAID,MAAM,4BAElB,OAAOC,CACT,CAEM,SAAUK,EAAiBP,GAC/B,MAAMQ,EAAaZ,EAAoB,GAAGI,SAC1C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UAAW,iBAAkB,UAAW,UAAW,cAAe,eAClE,WAAY,eAAgB,qBAAsB,cAAe,SACjE,eAAgB,SAAU,gBAAiB,IAAK,QAAS,OAAQ,iBACjE,SAAU,OAAQ,WAAY,QAAS,OAAQ,UAAW,UAAW,WACrE,iBAAkB,OAAQ,SAAU,MAAO,OAAQ,QAAS,MAAO,SACnE,SAAU,OAAQ,WAAY,QAAS,QAAS,MAAO,kCV6DvD1I,KACG4I,GAEH,OAAK5I,GAEL4I,EAASxM,QAAS7B,IAChB,GAAa,MAATA,EAAe,CACjB,IAAIsO,EAEJ,GAAqB,iBAAVtO,EAAoB,CAC7B,MAAM4F,EAnEd,SAA8BxF,GAC5B,IAAKR,EAAW,OAAO,KACvB,IACE,OAAOE,SAASsC,eAAeM,OAAOtC,GACxC,CAAE,MACA,OAAO,IACT,CACF,CA4DyBmO,CAAqBvO,GACtC,IAAI4F,EAGF,OAFA0I,EAAe1I,CAInB,MACE0I,EAAetO,GAxGvB,SAAyByF,EAAwBzF,GAC/C,IAAKyF,IAAWzF,EAAO,OAAO,EAC9B,IAEE,OADAyF,EAAOI,YAAY7F,IACZ,CACT,CAAE,MACA,OAAO,CACT,CACF,CAmGMwO,CAAgB/I,EAAQ6I,EAC1B,IAGK7I,GArBaA,CAsBtB,4HHlGM,SAAoB1G,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/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","/**\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\";\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 {\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 {\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 {\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 {\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 {\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 return typeof node.isConnected === \"boolean\" ? node.isConnected : document.contains(node);\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\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\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\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\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","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\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 if (value == null || value === '') {\n element.style.removeProperty(property);\n (element.style as unknown as Record<string, string>)[property] = '';\n } else {\n try {\n (element.style as unknown as Record<string, string>)[property] = String(value);\n } catch {\n // Ignore invalid style properties\n }\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 {\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 if (key in el) {\n (el as Record<string, unknown>)[key as string] = v;\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 } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\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 (modifier.length === 0) {\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 = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(resolver, preEvaluated);\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n}\n\nfunction createStaticTextFragment(index: number, value: Primitive): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(value));\n fragment.appendChild(comment);\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}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { applyModifiers, type NodeModifier } from \"../internal/applyModifiers\";\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)\n : (document.createComment(`conditional-${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);\n storeConditionalInfo(el as Node, conditionalInfo);\n return el;\n }\n\n const comment = document.createComment(`conditional-${tagName}-hidden`);\n storeConditionalInfo(comment as Node, conditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nfunction createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers as ReadonlyArray<NodeModifier<TTagName>>, 0);\n return el;\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\";\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 = document.createElement(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 if (!(tagName in target)) {\n target[tagName] = createTagBuilder(tagName);\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 HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\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 } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction } from \"../utility/typeGuards\";\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\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n let newActive: number | -1 | null = null;\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n newActive = i;\n break;\n }\n }\n if (newActive === null && elseContent.length) {\n newActive = -1;\n }\n\n if (newActive === runtime.activeIndex) return;\n\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n if (newActive === null) return;\n\n const nodes: Node[] = [];\n\n const renderItems = (items: ReadonlyArray<WhenContent<TTagName>>): void => {\n for (const item of items) {\n if (isFunction(item)) {\n if ((item as Function).length === 0) {\n modifierProbeCache.delete(item as Function);\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n continue;\n }\n\n const realHost = host as unknown as Element & {\n appendChild: (n: Node) => Node;\n insertBefore: (n: Node, ref: Node | null) => Node;\n };\n const originalAppend = realHost.appendChild;\n (realHost as unknown as Record<string, Function>).appendChild = function (n: Node) {\n return (realHost as unknown as Record<string, Function>).insertBefore(\n n,\n endMarker\n ) as Node;\n };\n try {\n const maybeNode = applyNodeModifier(host, item, index);\n if (maybeNode && !maybeNode.parentNode) {\n nodes.push(maybeNode);\n }\n } finally {\n (realHost as unknown as Record<string, Function>).appendChild = originalAppend;\n }\n continue;\n }\n\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n }\n };\n\n if (newActive >= 0) {\n renderItems(groups[newActive].content);\n } else if (newActive === -1) {\n renderItems(elseContent);\n }\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) return document.createComment(\"when-ssr\");\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 = host as unknown as Node & ParentNode;\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\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\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 { applyModifiers } 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\";\n\nfunction createElementFromConditionalInfo<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): ExpandedElement<TTagName> {\n const element = document.createElement(conditionalInfo.tagName) as ExpandedElement<TTagName>;\n\n try {\n applyModifiers(element, conditionalInfo.modifiers, 0);\n } catch (error) {\n console.error(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\":`, error);\n }\n return element;\n}\n\nfunction createCommentPlaceholder<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): Comment {\n return document.createComment(`conditional-${conditionalInfo.tagName}-hidden`);\n}\n\nfunction replaceNodeSafely(oldNode: Node, newNode: Node): void {\n if (oldNode.parentNode) {\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n } catch (error) {\n console.error(\"Error replacing conditional node:\", error);\n }\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 console.error(\"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 = createCommentPlaceholder(conditionalInfo);\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\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 console.error(\"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","export 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 console.error(\"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\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]) => any,\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) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on(\n type: string,\n listener: (ev: Event) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<any> {\n return (parent: ExpandedElement<any>) => {\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 if (typeof console !== \"undefined\" && console.error) {\n console.error(`[nuclo:on] Error in '${type}' listener:`, error);\n }\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","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","isNodeConnected","node","isConnected","contains","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","forEach","resolver","applyValue","key","e","registerAttributeResolver","element","Element","get","set","ensureElementInfo","updateListener","listener","addEventListener","assignInlineStyles","styles","style","property","Object","entries","removeProperty","String","applySingleAttribute","raw","styleValue","resolvedStyles","setValue","v","setAttribute","length","applyAttributes","attributes","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","undefined","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","filter","_","index","some","mod","applyNodeModifier","parent","createReactiveTextFragment","produced","createStaticTextFragment","candidate","preEvaluated","fragment","createDocumentFragment","textNode","createTextNode","initial","arguments","str","txt","lastValue","createReactiveTextNode","appendChild","activeConditionalNodes","Set","storeConditionalInfo","_conditionalInfo","add","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","tagName","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementFactory","passed","conditionalInfo","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","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","insertBefore","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderWhenContent","groups","elseContent","newActive","activeIndex","current","next","clearBetweenMarkers","nodes","renderItems","realHost","originalAppend","n","maybeNode","content","referenceNode","newNode","safeInsertBefore","insertNodesBefore","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","replaceNodeSafely","oldNode","replaceChild","updateConditionalNode","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","createCommentPlaceholder","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,OAAVA,CACtC,CAEM,SAAUI,EAAaJ,GAC3B,OAAOG,EAASH,IAAU,YAAcA,CAC1C,CAMM,SAAUK,EAA+BL,GAC7C,MAAwB,mBAAVA,CAChB,CCjBM,SAAUM,EAASC,EAAiBC,GACjB,oBAAZC,SACTA,QAAQD,MAAM,UAAUD,IAAWC,EAEvC,CAGM,SAAUE,EAAeC,EAAaC,GAC1C,IACE,OAAOD,GACT,CAAE,MAAOH,GAEP,OADAF,EAAS,mBAAoBE,GACtBI,CACT,CACF,CCdO,MAAMC,EAA8B,oBAAXC,QAA8C,oBAAbC,SCO3D,SAAUC,EAAgBC,GAC9B,IAAKA,GAAOC,WAAY,OAAO,EAC/B,IAEE,OADAD,EAAMC,WAAWC,YAAYF,IACtB,CACT,CAAE,MACA,OAAO,CACT,CACF,CAqBA,SAASG,EAAoBC,GAC3B,IAAKR,EAAW,OAAO,KACvB,IACE,OAAOE,SAASO,cAAcD,EAChC,CAAE,MACA,OAAO,IACT,CACF,CAEM,SAAUE,EAAoBC,GAClC,IAAKX,EACH,MAAM,IAAIY,MAAM,oDAElB,MAAMC,EAAUN,EAAoB,GAAGI,KAAUG,KAAKC,SAASC,SAAS,IAAIC,MAAM,MAClF,IAAKJ,EACH,MAAM,IAAID,MAAM,4BAElB,OAAOC,CACT,CAEM,SAAUK,EAAiBP,GAC/B,MAAMQ,EAAaZ,EAAoB,GAAGI,SAC1C,IAAKQ,EACH,MAAM,IAAIP,MAAM,gCAElB,MAAO,CACLQ,MAAOV,EAAoB,GAAGC,WAC9BU,IAAKF,EA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AA8BrF,GAC5B,IAAKR,EAAW,OAAO,KACvB,IACE,OAAOE,SAAS4F,eAAexC,OAAO9C,GACxC,CAAE,MACA,OAAO,IACT,CACF,CA4DyBqO,CAAqBzO,GACtC,IAAIyF,EAGF,OAFA+I,EAAe/I,CAInB,MACE+I,EAAexO,GAxGvB,SAAyBiF,EAAwBjF,GAC/C,IAAKiF,IAAWjF,EAAO,OAAO,EAC9B,IAEE,OADAiF,EAAOgB,YAAYjG,IACZ,CACT,CAAE,MACA,OAAO,CACT,CACF,CAmGM0O,CAAgBzJ,EAAQuJ,EAC1B,IAGKvJ,GArBaA,CAsBtB,6HHlGM,SAAoBlG,GACxB,MAAwB,kBAAVA,CAChB"}
@@ -1,2 +1,2 @@
1
- export declare function arraysEqual<T>(a: T[], b: T[]): boolean;
1
+ export declare function arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean;
2
2
  //# sourceMappingURL=arrayUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrayUtils.d.ts","sourceRoot":"","sources":["../../src/utility/arrayUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAOtD"}
1
+ {"version":3,"file":"arrayUtils.d.ts","sourceRoot":"","sources":["../../src/utility/arrayUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,GAAG,OAAO,CAOxE"}
@@ -1,12 +1,12 @@
1
- export interface ConditionalInfo {
1
+ export interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {
2
2
  condition: () => boolean;
3
- tagName: string;
4
- modifiers: Array<NodeMod<any> | NodeModFn<any>>;
3
+ tagName: TTagName;
4
+ modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;
5
5
  }
6
6
  /**
7
7
  * Attach conditional info to a node and register it.
8
8
  */
9
- export declare function storeConditionalInfo(node: Node, info: ConditionalInfo): void;
9
+ export declare function storeConditionalInfo<TTagName extends ElementTagName>(node: Node, info: ConditionalInfo<TTagName>): void;
10
10
  /**
11
11
  * Explicit unregister helper (optional use on teardown if needed).
12
12
  */
@@ -16,5 +16,5 @@ export declare function unregisterConditionalNode(node: Node): void;
16
16
  */
17
17
  export declare function getActiveConditionalNodes(): ReadonlySet<Node>;
18
18
  export declare function hasConditionalInfo(node: Node): boolean;
19
- export declare function getConditionalInfo(node: Node): ConditionalInfo | null;
19
+ export declare function getConditionalInfo(node: Node): ConditionalInfo<keyof HTMLElementTagNameMap> | null;
20
20
  //# sourceMappingURL=conditionalInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditionalInfo.d.ts","sourceRoot":"","sources":["../../src/utility/conditionalInfo.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;CACjD;AAQD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,eAAe,GACpB,IAAI,CAGN;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,CAAC,IAAI,CAAC,CAE7D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEtD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,GAAG,IAAI,CAErE"}
1
+ {"version":3,"file":"conditionalInfo.d.ts","sourceRoot":"","sources":["../../src/utility/conditionalInfo.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IAC/E,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC3D;AAYD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,cAAc,EAClE,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,GAC9B,IAAI,CAGN;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,CAAC,IAAI,CAAC,CAE7D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEtD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAAC,MAAM,qBAAqB,CAAC,GAAG,IAAI,CAElG"}
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/utility/conditions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AAEvD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,OAAO,EACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAUT;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAIT"}
1
+ {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/utility/conditions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AAEvD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,OAAO,EACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAUT;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAET"}
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utility/events.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,IAAI,IAAI,CAkBhD"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utility/events.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,IAAI,IAAI,CAYhD"}
@@ -1,10 +1,9 @@
1
- type AnyModifier = unknown;
2
1
  type BooleanCondition = () => boolean;
3
2
  declare const modifierProbeCache: WeakMap<Function, {
4
3
  value: unknown;
5
4
  error: boolean;
6
5
  }>;
7
- export declare function isConditionalModifier(modifier: AnyModifier, allModifiers: AnyModifier[], currentIndex: number): modifier is BooleanCondition;
8
- export declare function findConditionalModifier(modifiers: AnyModifier[]): number;
6
+ export declare function isConditionalModifier(modifier: unknown, allModifiers: unknown[], currentIndex: number): modifier is BooleanCondition;
7
+ export declare function findConditionalModifier(modifiers: unknown[]): number;
9
8
  export { modifierProbeCache };
10
9
  //# sourceMappingURL=modifierPredicates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modifierPredicates.d.ts","sourceRoot":"","sources":["../../src/utility/modifierPredicates.ts"],"names":[],"mappings":"AAEA,KAAK,WAAW,GAAG,OAAO,CAAC;AAC3B,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC;AAEtC,QAAA,MAAM,kBAAkB;WAAkC,OAAO;WAAS,OAAO;EAAK,CAAC;AAyBvF,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EACrB,YAAY,EAAE,WAAW,EAAE,EAC3B,YAAY,EAAE,MAAM,GACnB,QAAQ,IAAI,gBAAgB,CAkB9B;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,CAOxE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"modifierPredicates.d.ts","sourceRoot":"","sources":["../../src/utility/modifierPredicates.ts"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC;AAEtC,QAAA,MAAM,kBAAkB;WAAkC,OAAO;WAAS,OAAO;EAAK,CAAC;AAyBvF,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,OAAO,EAAE,EACvB,YAAY,EAAE,MAAM,GACnB,QAAQ,IAAI,gBAAgB,CAkB9B;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAOpE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function resolveRenderable(result: unknown, host: ExpandedElement<any>, index: number): ExpandedElement<any> | null;
1
+ export declare function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(result: unknown, host: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> | null;
2
2
  //# 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,CAC/B,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC,EAC1B,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAc7B"}
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,OAAO,EACf,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC/B,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC,QAAQ,CAAC,GAAG,IAAI,CAclC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuclo",
3
3
  "private": false,
4
- "version": "0.1.39",
4
+ "version": "0.1.40",
5
5
  "type": "module",
6
6
  "main": "./dist/nuclo.cjs",
7
7
  "module": "./dist/nuclo.js",
@@ -31,7 +31,7 @@
31
31
  "@types/node": "^24.9.2",
32
32
  "@vitest/coverage-v8": "3.2.4",
33
33
  "eslint": "^9.39.0",
34
- "globals": "^16.4.0",
34
+ "globals": "^16.5.0",
35
35
  "jsdom": "^27.1.0",
36
36
  "rollup": "^4.52.5",
37
37
  "tslib": "^2.8.1",