flexium 0.9.1 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/{DrawText-CJikXQjL.d.cts → DrawText-ccZrs3Xs.d.cts} +1 -1
- package/dist/{DrawText-Bvzl40Vi.d.ts → DrawText-ngwNNh8O.d.ts} +1 -1
- package/dist/advanced.d.cts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +1 -1
- package/dist/advanced.js.map +1 -1
- package/dist/advanced.mjs +1 -1
- package/dist/advanced.mjs.map +1 -1
- package/dist/canvas.d.cts +4 -4
- package/dist/canvas.d.ts +4 -4
- package/dist/canvas.js +1 -1
- package/dist/canvas.mjs +1 -1
- package/dist/chunk-3AWR7IKE.js +2 -0
- package/dist/chunk-3AWR7IKE.js.map +1 -0
- package/dist/chunk-3BQXIHYI.mjs +3 -0
- package/dist/chunk-3BQXIHYI.mjs.map +1 -0
- package/dist/chunk-5236IK5I.js +2 -0
- package/dist/chunk-5236IK5I.js.map +1 -0
- package/dist/{chunk-JHJHIMWD.js → chunk-63AW5ZOC.js} +2 -2
- package/dist/{chunk-JHJHIMWD.js.map → chunk-63AW5ZOC.js.map} +1 -1
- package/dist/chunk-6K44QCMT.mjs +3 -0
- package/dist/chunk-6K44QCMT.mjs.map +1 -0
- package/dist/chunk-7Q4UE442.mjs +2 -0
- package/dist/chunk-7Q4UE442.mjs.map +1 -0
- package/dist/chunk-AJT35P3Z.js +3 -0
- package/dist/chunk-AJT35P3Z.js.map +1 -0
- package/dist/chunk-AYQMU7XC.js +3 -0
- package/dist/chunk-AYQMU7XC.js.map +1 -0
- package/dist/chunk-B7VP6HBY.mjs +2 -0
- package/dist/chunk-B7VP6HBY.mjs.map +1 -0
- package/dist/{chunk-R5CS7UZG.mjs → chunk-BYHIHYRR.mjs} +2 -2
- package/dist/{chunk-R5CS7UZG.mjs.map → chunk-BYHIHYRR.mjs.map} +1 -1
- package/dist/chunk-HLPVL6EK.mjs +2 -0
- package/dist/{chunk-RUXAK74B.mjs.map → chunk-HLPVL6EK.mjs.map} +1 -1
- package/dist/{chunk-HDCPA76O.mjs → chunk-KJPIJNFH.mjs} +2 -2
- package/dist/chunk-KJPIJNFH.mjs.map +1 -0
- package/dist/chunk-PVPY55Z7.mjs +2 -0
- package/dist/{chunk-TRIEKNVZ.mjs.map → chunk-PVPY55Z7.mjs.map} +1 -1
- package/dist/chunk-Q7WT5IIF.mjs +3 -0
- package/dist/chunk-Q7WT5IIF.mjs.map +1 -0
- package/dist/chunk-S3EDPCYT.js +3 -0
- package/dist/chunk-S3EDPCYT.js.map +1 -0
- package/dist/{chunk-L4C5UBOX.js → chunk-WOHSSPKD.js} +2 -2
- package/dist/chunk-WOHSSPKD.js.map +1 -0
- package/dist/{chunk-DFG62GKW.js → chunk-WXEHDEIH.js} +2 -2
- package/dist/{chunk-DFG62GKW.js.map → chunk-WXEHDEIH.js.map} +1 -1
- package/dist/{chunk-3P6DMEGB.js → chunk-YDZ37ZZ4.js} +2 -2
- package/dist/{chunk-3P6DMEGB.js.map → chunk-YDZ37ZZ4.js.map} +1 -1
- package/dist/{components-D4WeooPi.d.ts → components-B7KQ8C-i.d.ts} +2 -2
- package/dist/{components-DZy2r6m5.d.cts → components-CxnAnbpI.d.cts} +2 -2
- package/dist/core.d.cts +48 -136
- package/dist/core.d.ts +48 -136
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/dom.d.cts +2 -2
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +1 -1
- package/dist/dom.js.map +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/dom.mjs.map +1 -1
- package/dist/{effect-BlnnM1t5.d.cts → effect-14CxUU8r.d.cts} +8 -4
- package/dist/{effect-BlnnM1t5.d.ts → effect-14CxUU8r.d.ts} +8 -4
- package/dist/effect-3LUCHSAZ.mjs +2 -0
- package/dist/effect-3LUCHSAZ.mjs.map +1 -0
- package/dist/effect-K45UU3N4.js +2 -0
- package/dist/effect-K45UU3N4.js.map +1 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interactive.d.cts +15 -10
- package/dist/interactive.d.ts +15 -10
- package/dist/interactive.js +1 -1
- package/dist/interactive.js.map +1 -1
- package/dist/interactive.mjs +1 -1
- package/dist/interactive.mjs.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/{portal-C3ESJhlv.d.ts → portal-CVqrpmHd.d.ts} +2 -2
- package/dist/{portal-CAEbiMUZ.d.cts → portal-NLlE-fNZ.d.cts} +2 -2
- package/dist/primitives/layout.js +1 -1
- package/dist/primitives/layout.mjs +1 -1
- package/dist/primitives/motion.js +1 -1
- package/dist/primitives/motion.mjs +1 -1
- package/dist/primitives/ui.d.cts +3 -3
- package/dist/primitives/ui.d.ts +3 -3
- package/dist/primitives/ui.js +1 -1
- package/dist/primitives/ui.js.map +1 -1
- package/dist/primitives/ui.mjs +1 -1
- package/dist/primitives/ui.mjs.map +1 -1
- package/dist/primitives.d.cts +4 -4
- package/dist/primitives.d.ts +4 -4
- package/dist/primitives.js +1 -1
- package/dist/primitives.js.map +1 -1
- package/dist/primitives.mjs +1 -1
- package/dist/primitives.mjs.map +1 -1
- package/dist/router.d.cts +3 -3
- package/dist/router.d.ts +3 -3
- package/dist/router.js +1 -1
- package/dist/router.mjs +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +1 -1
- package/dist/signal-2QUI7H7B.js +2 -0
- package/dist/{signal-3YZHUCLL.js.map → signal-2QUI7H7B.js.map} +1 -1
- package/dist/signal-C6936A3J.d.cts +175 -0
- package/dist/signal-C6936A3J.d.ts +175 -0
- package/dist/signal-L3ZWGOVT.mjs +2 -0
- package/dist/{signal-F2HEYB6F.mjs.map → signal-L3ZWGOVT.mjs.map} +1 -1
- package/dist/test-exports.d.cts +6 -6
- package/dist/test-exports.d.ts +6 -6
- package/dist/test-exports.js +1 -1
- package/dist/test-exports.mjs +1 -1
- package/package.json +2 -1
- package/dist/chunk-2ZHUQBNI.mjs +0 -2
- package/dist/chunk-2ZHUQBNI.mjs.map +0 -1
- package/dist/chunk-HDCPA76O.mjs.map +0 -1
- package/dist/chunk-J4CK5NRW.mjs +0 -3
- package/dist/chunk-J4CK5NRW.mjs.map +0 -1
- package/dist/chunk-JEDCNAAI.mjs +0 -3
- package/dist/chunk-JEDCNAAI.mjs.map +0 -1
- package/dist/chunk-L4C5UBOX.js.map +0 -1
- package/dist/chunk-M4ANLZ6P.js +0 -3
- package/dist/chunk-M4ANLZ6P.js.map +0 -1
- package/dist/chunk-RDA77IE6.js +0 -2
- package/dist/chunk-RDA77IE6.js.map +0 -1
- package/dist/chunk-RUXAK74B.mjs +0 -2
- package/dist/chunk-TRIEKNVZ.mjs +0 -2
- package/dist/chunk-VIVO4FHN.js +0 -3
- package/dist/chunk-VIVO4FHN.js.map +0 -1
- package/dist/chunk-XLE6SMWX.mjs +0 -3
- package/dist/chunk-XLE6SMWX.mjs.map +0 -1
- package/dist/chunk-YGMMJWAA.js +0 -3
- package/dist/chunk-YGMMJWAA.js.map +0 -1
- package/dist/signal-3YZHUCLL.js +0 -2
- package/dist/signal-Dxh9PsKr.d.cts +0 -69
- package/dist/signal-Dxh9PsKr.d.ts +0 -69
- package/dist/signal-F2HEYB6F.mjs +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/renderers/dom/events.ts","../src/renderers/dom/index.ts","../src/primitives/List/List.ts","../src/renderers/dom/node-map.ts","../src/renderers/dom/reconcile.ts","../src/renderers/dom/reactive.ts","../src/renderers/dom/render.ts","../src/renderers/dom/portal.ts"],"names":["globalListeners","NON_BUBBLING_EVENTS","nodeHandlers","dispatchEvent","event","eventType","bubbles","path","current","node","targetNode","handlers","handler","error","logError","ErrorCodes","ensureGlobalListener","eventName","capture","eventDelegator","lowerEvent","STYLE_PROPS_CONFIG","style","value","ELEMENT_MAPPING","EVENT_MAPPING","SKIP_PROPS","SVG_NAMESPACE","SVG_TAGS","SVG_ATTR_MAP","px","kebabCache","toKebabCase","str","result","letter","escapeAttrValue","transformValue","transform","updateStyles","element","oldProps","newProps","oldStyle","newStyle","key","val","type","styleRecord","propName","config","cssProp","currentValue","oldValue","newValue","transformedValue","normalizeClass","i","item","normalized","k","DOMRenderer","props","tagName","className","keys","strKey","newVal","oldVal","attrName","parent","child","beforeChild","text","domEvent","_handler","domRenderer","LIST_MARKER","isListComponent","getItemHeight","_index","calculateVisibleRangeFixed","scrollTop","viewportHeight","itemHeight","totalItems","overscan","totalHeight","start","visibleCount","end","mountListComponent","comp","mountFn","cleanupFn","mountVirtualList","mountSimpleList","each","renderItem","getKey","container","cache","getItemKey","index","disposeEffect","effect","list","currentKeys","indexSig","signal","vnode","entry","height","width","itemSize","onScroll","onVisibleRangeChange","innerContainer","scrollTopSig","prevStartIndex","prevEndIndex","handleScroll","currentScrollTop","startIndex","endIndex","visibleKeys","fnodeToNode","getNode","fnode","setNode","ReconciliationPool","mapPool","setPool","getMap","map","getSet","set","release","reconcileArrays","oldFNodes","newFNodes","nextSibling","hasOld","hasNew","cleanupReactive","fragment","newFNode","mountReactive","oldLen","newLen","SMALL_LIST_THRESHOLD","oldIdx","newIdx","currentChild","oldFNode","oldKey","newKey","patchNode","found","searchIdx","searchFNode","removeIdx","removeFNode","keyToOldFNode","seen","refNode","oldChildren","newChildren","newText","REACTIVE_BINDINGS","domUpdateQueue","isDOMUpdateScheduled","scheduleDOMUpdate","task","flushDOMUpdates","queue","registerReactiveBinding","dispose","bindings","listDispose","childNode","marker","isStateValue","sig","getStateSignal","startNode","currentNode","currentContainer","textNode","textValue","newNode","textContent","e","isSignal","currentNodes","currentFNode","currentFNodeList","c","childFNode","isFNode","component","componentInstance","createComponentInstance","resetHookIndex","root","disposeRoot","onCleanup","contextId","pushProvider","setCurrentComponent","componentProps","fn","n","currentParent","domNode","disposeProps","setupReactiveProps","ref","UNINITIALIZED","disposers","reactiveProps","prevValue","oldPropValue","children","createReactiveRoot","rootDispose","currentRootNode","isSameNode","render","createRoot","Portal","placeholder","portalContent"],"mappings":"2MAIA,IAAMA,EAAAA,CAAkB,IAAI,GAAA,CAGtBC,EAAAA,CAAsB,IAAI,GAAA,CAAI,CAClC,OAAA,CACA,MAAA,CACA,YAAA,CACA,YAAA,CACA,MAAA,CACA,QAAA,CACA,QACF,CAAC,CAAA,CAIKC,CAAAA,CAAe,IAAI,OAAA,CAKzB,SAASC,EAAAA,CAAcC,CAAAA,CAAc,CACtBA,CAAAA,CAAM,MAAA,KACbC,CAAAA,CAAYD,EAAM,IAAA,CAAK,WAAA,EAAY,CACnCE,CAAAA,CAAU,CAACL,EAAAA,CAAoB,GAAA,CAAII,CAAS,CAAA,CAI5CE,CAAAA,CAAOH,CAAAA,CAAM,YAAA,IAAe,EAAK,EAAC,CACpCI,CAAAA,CAAuBJ,CAAAA,CAAM,OAEjC,GAAIG,CAAAA,CAAK,MAAA,GAAW,CAAA,EAAKC,CAAAA,CAEvB,KAAOA,CAAAA,EACLD,CAAAA,CAAK,IAAA,CAAKC,CAAO,CAAA,CACjBA,CAAAA,CAAUA,CAAAA,CAAQ,UAAA,CAItB,QAAWC,CAAAA,IAAQF,CAAAA,CAAM,CACvB,IAAMG,CAAAA,CAAaD,CAAAA,CAEnB,GAAIC,CAAAA,GAAe,QAAA,EAAY,CAACA,CAAAA,CAAY,MAE5C,IAAMC,CAAAA,CAAWT,CAAAA,CAAa,GAAA,CAAIQ,CAAU,CAAA,CAC5C,GAAIC,CAAAA,EAAU,GAAA,CAAIN,CAAS,CAAA,CAAG,CAC5B,IAAMO,CAAAA,CAAUD,CAAAA,CAAS,GAAA,CAAIN,CAAS,CAAA,CACtC,GAAIO,CAAAA,CAAS,CACX,G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CAAA,CAEhBjF,CAAAA,CAAgB5C,CAAS,CAAA,CAErBA,CAAAA,CAAU,UAAA,CAAW,MAAA,GAAW,EAClCA,CAAAA,CAAU,WAAA,CAAYA,CAAAA,CAAU,UAAW,CAAA,CAE3CA,CAAAA,CAAU,SAAA,CAAY,EAAA,CAExB8H,CAAAA,CAAkB,IAAA,CAClB/B,CAAAA,CAAe,KACjB,CACF,CACF,CCxoBO,SAASiC,GACd3N,CAAAA,CACA2F,CAAAA,CACa,CAEb,OAAAA,CAAAA,CAAU,SAAA,CAAY,EAAA,CACf+C,CAAAA,CAAc1I,CAAAA,CAAM2F,CAAS,CACtC,CA4LO,SAASiI,EAAAA,CAAWjI,CAAAA,CAAwB,CAEjD,OAAO4H,EAAAA,CAAmB5H,CAAS,CACrC,CClOO,SAASkI,EAAAA,CAAOxK,CAAAA,CAAoB,CAEzC,GAAI,OAAO,QAAA,CAAa,GAAA,CACtB,OAAO,IAAA,CAGT,IAAMsC,EAAYtC,CAAAA,CAAM,KAAA,EAAS,QAAA,CAAS,IAAA,CAGpCyK,CAAAA,CAAc,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA,CAG/CC,CAAAA,CAA6B,IAAA,CAIjC,OAAAA,CAAAA,CAAgBrF,CAAAA,CAAcrF,CAAAA,CAAM,QAAA,CAAUsC,CAAS,CAAA,CAGvD0G,CAAAA,CAAU,IAAM,CACV0B,CAAAA,GACFxF,CAAAA,CAAgBwF,CAAa,CAAA,CACzBA,CAAAA,CAAc,UAAA,GAAepI,CAAAA,EAC/BA,CAAAA,CAAU,WAAA,CAAYoI,CAAa,CAAA,EAGzC,CAAC,EAEMD,CACT","file":"chunk-JEDCNAAI.mjs","sourcesContent":["import type { EventHandler } from '../../core/renderer'\nimport { logError, ErrorCodes } from '../../core/errors'\n\n// Map of event names to global listener status\nconst globalListeners = new Set<string>()\n\n// Events that do not bubble and must be captured\nconst NON_BUBBLING_EVENTS = new Set([\n 'focus',\n 'blur',\n 'mouseenter',\n 'mouseleave',\n 'load',\n 'unload',\n 'scroll',\n])\n\n// WeakMap to store event handlers for each node\n// Key: DOM Node, Value: Map<EventName, Handler>\nconst nodeHandlers = new WeakMap<Node, Map<string, EventHandler>>()\n\n/**\n * Global event dispatcher that handles delegation\n */\nfunction dispatchEvent(event: Event) {\n let target = event.target as Node | null\n const eventType = event.type.toLowerCase()\n const bubbles = !NON_BUBBLING_EVENTS.has(eventType)\n\n // Use composedPath if available (handles Shadow DOM and is faster)\n // Fallback to parentNode traversal for older browsers\n const path = event.composedPath?.() || []\n let current: Node | null = event.target as Node\n\n if (path.length === 0 && current) {\n // Build path manually if composedPath not available\n while (current) {\n path.push(current)\n current = current.parentNode\n }\n }\n\n for (const node of path) {\n const targetNode = node as Node\n // Stop at document or if we hit the end\n if (targetNode === document || !targetNode) break\n\n const handlers = nodeHandlers.get(targetNode)\n if (handlers?.has(eventType)) {\n const handler = handlers.get(eventType)\n if (handler) {\n try {\n handler(event)\n } catch (error) {\n logError(ErrorCodes.EVENT_HANDLER_FAILED, { eventType }, error)\n }\n if (event.cancelBubble) return\n }\n }\n\n if (!bubbles) break\n }\n}\n\n/**\n * Register a global event listener for delegation\n */\nfunction ensureGlobalListener(eventName: string) {\n // SSR guard\n if (typeof document === 'undefined') return\n\n if (!globalListeners.has(eventName)) {\n const capture = NON_BUBBLING_EVENTS.has(eventName)\n document.addEventListener(eventName, dispatchEvent, { capture })\n globalListeners.add(eventName)\n }\n}\n\n/**\n * Clear all global event listeners (useful for SSR cleanup and testing)\n */\nexport function clearGlobalListeners(): void {\n // SSR guard\n if (typeof document === 'undefined') return\n\n for (const eventName of globalListeners) {\n const capture = NON_BUBBLING_EVENTS.has(eventName)\n document.removeEventListener(eventName, dispatchEvent, { capture })\n }\n globalListeners.clear()\n}\n\n/**\n * Event Delegation System\n */\nexport const eventDelegator = {\n /**\n * Attach an event handler to a node (virtual attachment)\n */\n on(node: Node, eventName: string, handler: EventHandler) {\n // normalize event name (e.g., 'click' -> 'click')\n const lowerEvent = eventName.toLowerCase()\n\n let handlers = nodeHandlers.get(node)\n if (!handlers) {\n handlers = new Map()\n nodeHandlers.set(node, handlers)\n }\n\n handlers.set(lowerEvent, handler)\n ensureGlobalListener(lowerEvent)\n },\n\n /**\n * Detach an event handler from a node\n */\n off(node: Node, eventName: string) {\n const lowerEvent = eventName.toLowerCase()\n const handlers = nodeHandlers.get(node)\n if (handlers) {\n handlers.delete(lowerEvent)\n }\n },\n}\n","import type { Renderer, EventHandler } from '../../core/renderer'\nimport { eventDelegator } from './events'\n\n/**\n * Style property configuration for data-driven updates\n */\ninterface StylePropConfig {\n /** CSS property name to set */\n cssProp: string\n /** Transform function (e.g., px for pixel values) */\n transform?: 'px' | 'string' | 'none'\n /** Additional side effect when setting this property */\n sideEffect?: (style: CSSStyleDeclaration, value: string | undefined) => void\n}\n\n/**\n * Data-driven style property mappings\n * Maps Flexium props to CSS properties with optional transformations\n */\nconst STYLE_PROPS_CONFIG: Record<string, StylePropConfig> = {\n // Layout\n width: { cssProp: 'width', transform: 'px' },\n height: { cssProp: 'height', transform: 'px' },\n\n // Flex properties\n flexDirection: { cssProp: 'flexDirection', transform: 'none' },\n justifyContent: { cssProp: 'justifyContent', transform: 'none' },\n alignItems: { cssProp: 'alignItems', transform: 'none' },\n alignSelf: { cssProp: 'alignSelf', transform: 'none' },\n flexWrap: { cssProp: 'flexWrap', transform: 'none' },\n flex: { cssProp: 'flex', transform: 'string' },\n gap: { cssProp: 'gap', transform: 'px' },\n\n // Shorthands\n justify: { cssProp: 'justifyContent', transform: 'none' },\n align: { cssProp: 'alignItems', transform: 'none' },\n\n // Visual\n bg: { cssProp: 'backgroundColor', transform: 'none' },\n color: { cssProp: 'color', transform: 'none' },\n borderRadius: { cssProp: 'borderRadius', transform: 'px' },\n borderWidth: {\n cssProp: 'borderWidth',\n transform: 'px',\n sideEffect: (style, value) => {\n if (value !== undefined && style.borderStyle !== 'solid') {\n style.borderStyle = 'solid'\n }\n },\n },\n borderColor: { cssProp: 'borderColor', transform: 'none' },\n opacity: { cssProp: 'opacity', transform: 'string' },\n\n // Typography\n fontSize: { cssProp: 'fontSize', transform: 'px' },\n fontWeight: { cssProp: 'fontWeight', transform: 'string' },\n fontFamily: { cssProp: 'fontFamily', transform: 'none' },\n lineHeight: { cssProp: 'lineHeight', transform: 'string' },\n textAlign: { cssProp: 'textAlign', transform: 'none' },\n\n // Padding\n padding: { cssProp: 'padding', transform: 'px' },\n paddingTop: { cssProp: 'paddingTop', transform: 'px' },\n paddingRight: { cssProp: 'paddingRight', transform: 'px' },\n paddingBottom: { cssProp: 'paddingBottom', transform: 'px' },\n paddingLeft: { cssProp: 'paddingLeft', transform: 'px' },\n\n // Margin\n margin: { cssProp: 'margin', transform: 'px' },\n marginTop: { cssProp: 'marginTop', transform: 'px' },\n marginRight: { cssProp: 'marginRight', transform: 'px' },\n marginBottom: { cssProp: 'marginBottom', transform: 'px' },\n marginLeft: { cssProp: 'marginLeft', transform: 'px' },\n}\n\n/**\n * Component type to HTML element mapping\n */\nconst ELEMENT_MAPPING: Record<string, string> = {\n Row: 'div',\n Column: 'div',\n Stack: 'div',\n Text: 'span',\n Button: 'button',\n Input: 'input',\n Container: 'div',\n}\n\n/**\n * Event name mapping (platform-agnostic to DOM)\n */\nconst EVENT_MAPPING: Record<string, string> = {\n onPress: 'click',\n onHover: 'mouseenter',\n onChange: 'input',\n onFocus: 'focus',\n onBlur: 'blur',\n}\n\n/**\n * Props that should not be set as DOM attributes\n */\nconst SKIP_PROPS = new Set([\n 'children',\n 'key',\n 'ref',\n 'className',\n 'style',\n // Layout props (handled via style)\n 'width',\n 'height',\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'gap',\n 'flex',\n 'flexDirection',\n 'flexWrap',\n 'justifyContent',\n 'alignItems',\n 'alignSelf',\n // Shorthand flexbox props\n 'align',\n 'justify',\n // Visual props (handled via style)\n 'bg',\n 'color',\n 'borderRadius',\n 'borderWidth',\n 'borderColor',\n 'opacity',\n // Typography props\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'lineHeight',\n 'textAlign',\n])\n\n/**\n * SVG Namespace URI\n */\nconst SVG_NAMESPACE = 'http://www.w3.org/2000/svg'\n\n/**\n * Common SVG tags that require namespace\n */\nconst SVG_TAGS = new Set([\n 'svg',\n 'path',\n 'circle',\n 'rect',\n 'line',\n 'polyline',\n 'polygon',\n 'ellipse',\n 'g',\n 'text',\n 'tspan',\n 'defs',\n 'use',\n 'symbol',\n 'marker',\n 'linearGradient',\n 'radialGradient',\n 'stop',\n 'clipPath',\n 'pattern',\n 'mask',\n 'filter',\n])\n\n/**\n * SVG Attribute Case Mapping\n * React-like camelCase to SVG case-sensitive attributes\n */\nconst SVG_ATTR_MAP: Record<string, string> = {\n viewBox: 'viewBox',\n preserveAspectRatio: 'preserveAspectRatio',\n strokeWidth: 'stroke-width',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeDasharray: 'stroke-dasharray',\n strokeDashoffset: 'stroke-dashoffset',\n fillOpacity: 'fill-opacity',\n strokeOpacity: 'stroke-opacity',\n stopColor: 'stop-color',\n stopOpacity: 'stop-opacity',\n clipPath: 'clip-path',\n markerEnd: 'marker-end',\n markerStart: 'marker-start',\n markerMid: 'marker-mid',\n}\n\n/**\n * Convert pixel value to CSS string\n */\nfunction px(value: number | string): string {\n return typeof value === 'number' ? `${value}px` : value\n}\n\n/**\n * Cache for camelCase to kebab-case conversions\n * Avoids repeated regex operations for common CSS properties\n */\nconst kebabCache = new Map<string, string>()\n\n/**\n * Convert camelCase to kebab-case for CSS property names\n * Uses memoization for performance\n */\nfunction toKebabCase(str: string): string {\n let result = kebabCache.get(str)\n if (result === undefined) {\n result = str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)\n kebabCache.set(str, result)\n }\n return result\n}\n\n/**\n * Escape special characters in HTML attribute values to prevent XSS\n * @param value - Attribute value to escape\n * @returns Escaped value safe for HTML attributes\n */\nexport function escapeAttrValue(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n}\n\n/**\n * Transform a value based on the config type\n */\nfunction transformValue(\n value: unknown,\n transform: StylePropConfig['transform']\n): string | undefined {\n if (value === undefined || value === null) return undefined\n switch (transform) {\n case 'px':\n return px(value as number | string)\n case 'string':\n return String(value)\n case 'none':\n default:\n return value as string\n }\n}\n\n/**\n * Apply style props to DOM element efficiently\n */\nfunction updateStyles(\n element: HTMLElement | SVGElement,\n oldProps: Record<string, unknown>,\n newProps: Record<string, unknown>\n): void {\n const style = element.style\n\n // 1. Handle 'style' object prop\n const oldStyle = oldProps.style as Record<string, string> | undefined\n const newStyle = newProps.style as Record<string, string> | undefined\n\n if (oldStyle !== newStyle) {\n if (oldStyle && typeof oldStyle === 'object') {\n for (const key in oldStyle) {\n if (!newStyle || !(key in newStyle)) {\n // Convert camelCase to kebab-case for CSS property names\n style.setProperty(toKebabCase(key), '')\n }\n }\n }\n if (newStyle && typeof newStyle === 'object') {\n for (const key in newStyle) {\n const val = newStyle[key]\n if (!oldStyle || oldStyle[key] !== val) {\n // Convert camelCase to kebab-case for CSS property names\n style.setProperty(toKebabCase(key), val)\n }\n }\n }\n }\n\n // 2. Flexbox setup (display: flex)\n const type = element.getAttribute('data-flexium-type')\n const needsFlex =\n newProps.flexDirection ||\n newProps.justifyContent ||\n newProps.alignItems ||\n newProps.flexWrap ||\n newProps.gap !== undefined ||\n newProps.justify ||\n newProps.align ||\n type === 'Row' ||\n type === 'Column' ||\n type === 'Stack'\n\n if (needsFlex) {\n if (style.display !== 'flex') style.display = 'flex'\n if (type === 'Row' && style.flexDirection !== 'row')\n style.flexDirection = 'row'\n if (type === 'Column' && style.flexDirection !== 'column')\n style.flexDirection = 'column'\n }\n\n // 3. Handle Flexium specific style props - only check props that exist\n // Optimized: iterate directly without creating intermediate Set\n\n // Performance: Cache style access and avoid unnecessary checks\n const styleRecord = style as unknown as Record<string, string>\n\n // Check oldProps for removed style props\n for (const propName in oldProps) {\n if (propName in STYLE_PROPS_CONFIG && !(propName in newProps)) {\n const config = STYLE_PROPS_CONFIG[propName]\n const cssProp = config.cssProp as string\n\n // Performance: Only clear if actually set (avoid unnecessary DOM writes)\n const currentValue = styleRecord[cssProp]\n if (currentValue !== undefined && currentValue !== '') {\n styleRecord[cssProp] = ''\n }\n\n // Apply any side effects\n if (config.sideEffect) {\n config.sideEffect(style, undefined)\n }\n }\n }\n\n // Check newProps for added/updated style props\n for (const propName in newProps) {\n if (propName in STYLE_PROPS_CONFIG) {\n const oldValue = oldProps[propName]\n const newValue = newProps[propName]\n\n // Performance: Skip if value hasn't changed\n if (oldValue === newValue) continue\n\n const config = STYLE_PROPS_CONFIG[propName]\n const transformedValue = transformValue(newValue, config.transform)\n const cssProp = config.cssProp as string\n\n // Performance: Cache current value and only update if different\n const currentValue = styleRecord[cssProp]\n\n // Update the style property\n if (transformedValue === undefined) {\n // Only clear if actually set\n if (currentValue !== undefined && currentValue !== '') {\n styleRecord[cssProp] = ''\n }\n } else {\n // Only update if value actually changed\n if (currentValue !== transformedValue) {\n styleRecord[cssProp] = transformedValue\n }\n }\n\n // Apply any side effects\n if (config.sideEffect) {\n config.sideEffect(style, transformedValue)\n }\n }\n }\n}\n\n/**\n * Normalize className prop (supports string, array, object)\n * Optimized single-pass implementation without recursion overhead\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction normalizeClass(value: any): string {\n if (typeof value === 'string') return value\n if (Array.isArray(value)) {\n // Single-pass iteration without intermediate arrays\n let result = ''\n for (let i = 0; i < value.length; i++) {\n const item = value[i]\n if (!item) continue\n const normalized = typeof item === 'string' ? item : normalizeClass(item)\n if (normalized) {\n result = result ? `${result} ${normalized}` : normalized\n }\n }\n return result\n }\n if (typeof value === 'object' && value !== null) {\n // Single-pass iteration without intermediate arrays\n let result = ''\n for (const k in value) {\n if (value[k]) {\n result = result ? `${result} ${k}` : k\n }\n }\n return result\n }\n return ''\n}\n\n/**\n * DOM Renderer implementation\n */\nexport class DOMRenderer implements Renderer {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createNode(type: string, props: Record<string, any>): HTMLElement | SVGElement {\n // Map component type to HTML element\n const tagName = ELEMENT_MAPPING[type] ?? type\n\n let element: HTMLElement | SVGElement\n\n if (SVG_TAGS.has(tagName)) {\n element = document.createElementNS(SVG_NAMESPACE, tagName) as SVGElement\n } else {\n element = document.createElement(tagName)\n }\n\n // Store original type for reference\n if (ELEMENT_MAPPING[type]) {\n element.setAttribute('data-flexium-type', type)\n }\n\n // Apply all props (treat oldProps as empty)\n this.updateNode(element, {}, props)\n\n return element\n }\n\n updateNode(\n node: HTMLElement | SVGElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n oldProps: Record<string, any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newProps: Record<string, any>\n ): void {\n // 1. Handle className\n if (newProps.className !== oldProps.className) {\n const className = normalizeClass(newProps.className)\n if (node instanceof SVGElement) {\n node.setAttribute('class', className)\n } else {\n node.className = className\n }\n }\n\n // 2. Update Styles (Efficiently)\n updateStyles(node, oldProps, newProps)\n\n // 3. Handle Events & Attributes\n // We iterate over merged keys to handle additions, updates, and removals in one pass if possible\n // But separating old and new is easier for now.\n\n // Remove deleted props\n for (const key in oldProps) {\n if (!(key in newProps)) {\n // Ignore Symbols\n if (typeof key === 'symbol') continue\n\n if (key.startsWith('on')) {\n const eventName = EVENT_MAPPING[key] || key.slice(2).toLowerCase()\n this.removeEventListener(node, eventName, oldProps[key])\n } else if (!SKIP_PROPS.has(key)) {\n node.removeAttribute(key)\n }\n }\n }\n\n // Add/Update new props\n const keys = Reflect.ownKeys(newProps) // Get string and symbol keys\n for (const key of keys) {\n // Ignore Symbols (Synapse keys)\n if (typeof key === 'symbol') continue\n\n // Cast key to string for accessing record\n const strKey = key\n const newVal = newProps[strKey]\n const oldVal = oldProps[strKey]\n\n if (newVal === oldVal) continue\n\n if (strKey.startsWith('on')) {\n const eventName = EVENT_MAPPING[strKey] || strKey.slice(2).toLowerCase()\n if (oldVal) this.removeEventListener(node, eventName, oldVal)\n if (newVal) this.addEventListener(node, eventName, newVal)\n } else if (!SKIP_PROPS.has(strKey)) {\n if (newVal === null || newVal === undefined || newVal === false) {\n node.removeAttribute(strKey)\n } else if (newVal === true) {\n node.setAttribute(strKey, '')\n } else {\n // Handle SVG attributes\n const attrName = SVG_ATTR_MAP[strKey] || strKey\n\n // Escape attribute value to prevent XSS attacks\n node.setAttribute(attrName, escapeAttrValue(String(newVal)))\n }\n }\n }\n }\n\n appendChild(parent: Node, child: Node): void {\n parent.appendChild(child)\n }\n\n insertBefore(parent: Node, child: Node, beforeChild: Node | null): void {\n parent.insertBefore(child, beforeChild)\n }\n\n nextSibling(node: Node): Node | null {\n return node.nextSibling\n }\n\n removeChild(parent: Node, child: Node): void {\n // No need to manually cleanup listeners if using WeakMap in delegator\n // The nodeHandlers WeakMap will automatically release entries when node is garbage collected\n parent.removeChild(child)\n }\n\n createTextNode(text: string): Text {\n return document.createTextNode(text)\n }\n\n updateTextNode(node: Text, text: string): void {\n node.textContent = text\n }\n\n addEventListener(node: Node, event: string, handler: EventHandler): void {\n // Use Event Delegation\n // Map to DOM event name\n const domEvent = EVENT_MAPPING[event] || event\n eventDelegator.on(node, domEvent, handler)\n }\n\n removeEventListener(node: Node, event: string, _handler: EventHandler): void {\n // Use Event Delegation\n // Map to DOM event name\n const domEvent = EVENT_MAPPING[event] || event\n eventDelegator.off(node, domEvent)\n }\n}\n\n/**\n * Default DOM renderer instance\n */\nexport const domRenderer = new DOMRenderer()\n","import { signal, effect } from '../../core/signal'\nimport type { FNode } from '../../core/renderer'\nimport type {\n ListProps,\n ListComponent,\n ListCacheEntry,\n SizeConfig,\n} from './types'\n\n/** Marker symbol for List components */\nexport const LIST_MARKER = Symbol('flexium.list')\n\n/**\n * Check if a value is a ListComponent\n */\nexport function isListComponent<T>(\n value: unknown\n): value is ListComponent<T> {\n return (\n value !== null &&\n typeof value === 'object' &&\n LIST_MARKER in value &&\n (value as Record<symbol, unknown>)[LIST_MARKER] === true\n )\n}\n\n\n/**\n * List - Render lists with optional virtualization\n *\n * By default, renders all items. Set `virtual` to true for large lists\n * to only render visible items.\n *\n * @example\n * ```tsx\n * // Simple list (renders all items)\n * <List each={items}>\n * {(item, index) => <div>{item.name}</div>}\n * </List>\n *\n * // Virtual list (for large datasets)\n * <List\n * each={items}\n * virtual\n * height={400}\n * itemSize={50}\n * >\n * {(item, index) => <div>{index()}: {item.name}</div>}\n * </List>\n * ```\n */\nexport function List<T>(props: ListProps<T>): ListComponent<T> {\n const {\n each,\n children,\n virtual = false,\n height,\n width,\n itemSize,\n overscan = 3,\n getKey,\n onScroll,\n onVisibleRangeChange,\n class: className,\n style,\n } = props\n\n const component: ListComponent<T> = {\n [LIST_MARKER]: true,\n each,\n renderItem: children,\n virtual,\n height,\n width,\n itemSize,\n overscan,\n getKey,\n onScroll,\n onVisibleRangeChange,\n class: className,\n style,\n }\n\n return component\n}\n\n/**\n * Get item height based on configuration\n */\nfunction getItemHeight(config: number | SizeConfig, _index: number): number {\n if (typeof config === 'number') {\n return config\n }\n if (config.mode === 'fixed') {\n return config.itemHeight\n }\n // Variable mode - use estimated height\n return config.estimatedItemHeight\n}\n\n/**\n * Calculate visible range for fixed-height items\n */\nfunction calculateVisibleRangeFixed(\n scrollTop: number,\n viewportHeight: number,\n itemHeight: number,\n totalItems: number,\n overscan: number\n): { startIndex: number; endIndex: number; totalHeight: number } {\n const totalHeight = totalItems * itemHeight\n\n if (totalItems === 0) {\n return { startIndex: 0, endIndex: -1, totalHeight: 0 }\n }\n\n const start = Math.floor(scrollTop / itemHeight)\n const visibleCount = Math.ceil(viewportHeight / itemHeight)\n const end = start + visibleCount\n\n return {\n startIndex: Math.max(0, start - overscan),\n endIndex: Math.min(totalItems - 1, end + overscan),\n totalHeight,\n }\n}\n\n/**\n * Mount a List component to the DOM with efficient rendering.\n *\n * Handles both simple and virtual lists:\n * - Simple lists render all items immediately with key-based caching\n * - Virtual lists only render visible items for optimal performance with large datasets\n *\n * @internal Used by the reactive renderer\n * @param comp - The ListComponent to mount\n * @param parent - Parent DOM node to mount into\n * @param mountFn - Function to mount an FNode to the DOM\n * @param cleanupFn - Function to cleanup a DOM node and its bindings\n * @returns Dispose function to cleanup all list items and effects\n *\n * @example\n * ```tsx\n * // This is called automatically by mountReactive when it encounters a List:\n * <List each={items} virtual height={400} itemSize={50}>\n * {(item, index) => <Row>{index()}: {item.name}</Row>}\n * </List>\n * ```\n */\nexport function mountListComponent<T>(\n comp: ListComponent<T>,\n parent: Node,\n mountFn: (vnode: FNode) => Node | null,\n cleanupFn: (node: Node) => void\n): () => void {\n if (comp.virtual) {\n return mountVirtualList(comp, parent, mountFn, cleanupFn)\n } else {\n return mountSimpleList(comp, parent, mountFn, cleanupFn)\n }\n}\n\n/**\n * Mount a simple (non-virtual) list\n */\nfunction mountSimpleList<T>(\n comp: ListComponent<T>,\n parent: Node,\n mountFn: (vnode: FNode) => Node | null,\n cleanupFn: (node: Node) => void\n): () => void {\n const { each, renderItem, getKey, class: className, style } = comp\n\n // Create container\n const container = document.createElement('div')\n container.setAttribute('role', 'list')\n if (className) container.className = className\n if (style) {\n Object.entries(style).forEach(([key, value]) => {\n ; (container.style as unknown as Record<string, string>)[key] =\n typeof value === 'number' ? `${value}px` : value\n })\n }\n\n parent.appendChild(container)\n\n // Cache for rendered items\n const cache = new Map<string | number, { node: Node; dispose: () => void }>()\n\n // Get key for item\n const getItemKey = (item: T, index: number): string | number => {\n if (getKey) {\n return getKey(item, index)\n }\n return index\n }\n\n // Render effect\n const disposeEffect = effect(() => {\n const list = each() || []\n const currentKeys = new Set<string | number>()\n\n // Render items\n list.forEach((item, index) => {\n const key = getItemKey(item, index)\n currentKeys.add(key)\n\n if (!cache.has(key)) {\n const indexSig = signal(index)\n const vnode = renderItem(item, () => indexSig())\n const node = mountFn(vnode)\n\n if (node && node instanceof HTMLElement) {\n node.setAttribute('role', 'listitem')\n container.appendChild(node)\n\n cache.set(key, {\n node,\n dispose: () => {\n try {\n cleanupFn(node)\n } catch {\n // Ignore cleanup errors\n }\n },\n })\n }\n }\n })\n\n // Remove items no longer in list\n for (const [key, entry] of cache) {\n if (!currentKeys.has(key)) {\n entry.dispose()\n if (entry.node.parentNode === container) {\n container.removeChild(entry.node)\n }\n cache.delete(key)\n }\n }\n })\n\n // Cleanup\n return () => {\n disposeEffect()\n for (const entry of cache.values()) {\n entry.dispose()\n }\n cache.clear()\n if (container.parentNode === parent) {\n parent.removeChild(container)\n }\n }\n}\n\n/**\n * Mount a virtual (windowed) list\n */\nfunction mountVirtualList<T>(\n comp: ListComponent<T>,\n parent: Node,\n mountFn: (node: FNode) => Node | null,\n cleanupFn: (node: Node) => void\n): () => void {\n const {\n each,\n renderItem,\n height,\n width,\n itemSize,\n overscan,\n getKey,\n onScroll,\n onVisibleRangeChange,\n } = comp\n\n if (!height || !itemSize) {\n console.warn('List: height and itemSize are required when virtual is true')\n return () => { }\n }\n\n // Create container structure\n const container = document.createElement('div')\n container.style.height = typeof height === 'number' ? `${height}px` : height\n container.style.width = width\n ? typeof width === 'number'\n ? `${width}px`\n : width\n : '100%'\n container.style.overflow = 'auto'\n container.style.position = 'relative'\n\n // Accessibility attributes\n container.setAttribute('role', 'list')\n container.setAttribute('tabindex', '0')\n\n const innerContainer = document.createElement('div')\n innerContainer.style.position = 'relative'\n innerContainer.style.width = '100%'\n innerContainer.style.willChange = 'transform'\n\n container.appendChild(innerContainer)\n parent.appendChild(container)\n\n // Reactive state\n const scrollTopSig = signal(0)\n const cache = new Map<string | number, ListCacheEntry<T>>()\n\n // Track previous visible range\n let prevStartIndex = -1\n let prevEndIndex = -1\n\n // Scroll handler\n const handleScroll = () => {\n scrollTopSig.set(container.scrollTop)\n onScroll?.(container.scrollTop)\n }\n\n container.addEventListener('scroll', handleScroll, { passive: true })\n\n // Get key for item\n const getItemKey = (item: T, index: number): string | number => {\n if (getKey) {\n return getKey(item, index)\n }\n return index\n }\n\n // Main render effect\n const disposeEffect = effect(() => {\n const list = each() || []\n const currentScrollTop = scrollTopSig()\n const viewportHeight = container.clientHeight || parseFloat(String(height))\n const itemHeight = getItemHeight(itemSize, 0)\n\n // Calculate visible range\n const { startIndex, endIndex, totalHeight } = calculateVisibleRangeFixed(\n currentScrollTop,\n viewportHeight,\n itemHeight,\n list.length,\n overscan\n )\n\n // Update spacer height\n innerContainer.style.height = `${totalHeight}px`\n\n // Update ARIA attributes\n container.setAttribute('aria-rowcount', String(list.length))\n\n // Notify visible range change\n if (startIndex !== prevStartIndex || endIndex !== prevEndIndex) {\n onVisibleRangeChange?.(startIndex, endIndex)\n prevStartIndex = startIndex\n prevEndIndex = endIndex\n }\n\n // Track which keys are currently visible\n const visibleKeys = new Set<string | number>()\n\n // Render visible items\n for (let i = startIndex; i <= endIndex && i < list.length; i++) {\n const item = list[i]\n const key = getItemKey(item, i)\n visibleKeys.add(key)\n\n let entry = cache.get(key)\n\n if (!entry) {\n // Create new item\n const indexSig = signal(i)\n const vnode = renderItem(item, () => indexSig())\n const node = mountFn(vnode)\n\n if (node && node instanceof HTMLElement) {\n // Position the item\n node.style.position = 'absolute'\n node.style.top = '0'\n node.style.left = '0'\n node.style.right = '0'\n node.style.transform = `translateY(${i * itemHeight}px)`\n node.style.height = `${itemHeight}px`\n node.style.boxSizing = 'border-box'\n node.setAttribute('role', 'listitem')\n node.setAttribute('aria-rowindex', String(i + 1))\n\n innerContainer.appendChild(node)\n\n entry = {\n item,\n key,\n node,\n indexSig,\n dispose: () => {\n try {\n cleanupFn(node)\n } catch {\n // Ignore cleanup errors\n }\n },\n }\n cache.set(key, entry)\n }\n } else {\n // Update existing item position\n if (entry.indexSig.peek() !== i) {\n entry.indexSig.set(i)\n }\n const node = entry.node as HTMLElement\n node.style.transform = `translateY(${i * itemHeight}px)`\n node.setAttribute('aria-rowindex', String(i + 1))\n }\n }\n\n // Remove items no longer visible\n for (const [key, entry] of cache) {\n if (!visibleKeys.has(key)) {\n entry.dispose()\n if (entry.node.parentNode === innerContainer) {\n innerContainer.removeChild(entry.node)\n }\n cache.delete(key)\n }\n }\n })\n\n // Cleanup function\n return () => {\n disposeEffect()\n container.removeEventListener('scroll', handleScroll)\n\n for (const entry of cache.values()) {\n entry.dispose()\n }\n cache.clear()\n\n if (container.parentNode === parent) {\n parent.removeChild(container)\n }\n }\n}\n\nexport default List\n","/**\n * FNode to DOM Node mapping using WeakMap\n *\n * This replaces the _node property on FNode with a clean separation.\n * WeakMap ensures nodes are garbage collected when FNodes are no longer referenced.\n */\n\nimport type { FNode } from '../../core/renderer'\n\nconst fnodeToNode = new WeakMap<FNode, Node>()\n\n/**\n * Get the DOM node associated with an FNode\n */\nexport function getNode(fnode: FNode): Node | undefined {\n return fnodeToNode.get(fnode)\n}\n\n/**\n * Set the DOM node associated with an FNode\n */\nexport function setNode(fnode: FNode, node: Node): void {\n fnodeToNode.set(fnode, node)\n}\n\n/**\n * Check if an FNode has an associated DOM node\n */\nexport function hasNode(fnode: FNode): boolean {\n return fnodeToNode.has(fnode)\n}\n\n/**\n * Remove the DOM node association from an FNode\n */\nexport function deleteNode(fnode: FNode): boolean {\n return fnodeToNode.delete(fnode)\n}\n","import { FNode } from '../../core/renderer'\nimport { domRenderer } from './index'\nimport { mountReactive, cleanupReactive } from './reactive'\nimport { getNode, setNode } from './node-map'\n\n/**\n * Object pool for Map/Set used in reconciliation to reduce GC pressure\n * Performance: Reuse Map and Set instances instead of creating new ones\n */\nnamespace ReconciliationPool {\n const mapPool: Map<string | number | undefined, FNode>[] = []\n const setPool: Set<string | number | undefined>[] = []\n const MAX_POOL_SIZE = 10\n\n export function getMap(): Map<string | number | undefined, FNode> {\n if (mapPool.length > 0) {\n const map = mapPool.pop()!\n map.clear()\n return map\n }\n return new Map()\n }\n\n export function getSet(): Set<string | number | undefined> {\n if (setPool.length > 0) {\n const set = setPool.pop()!\n set.clear()\n return set\n }\n return new Set()\n }\n\n export function release(\n map: Map<string | number | undefined, FNode>,\n set: Set<string | number | undefined>\n ): void {\n if (mapPool.length < MAX_POOL_SIZE) {\n mapPool.push(map)\n }\n if (setPool.length < MAX_POOL_SIZE) {\n setPool.push(set)\n }\n }\n}\n\n/**\n * Reconcile two arrays of FNodes using hybrid key-based approach.\n * Simple Map lookup + position check for optimal DOM operations.\n *\n * @param parent The parent DOM node\n * @param oldFNodes The array of old FNodes (with attached DOM nodes)\n * @param newFNodes The array of new FNodes\n * @param nextSibling The node to insert before (for the end of the list)\n */\nexport function reconcileArrays(\n parent: Node,\n oldFNodes: FNode[],\n newFNodes: FNode[],\n nextSibling: Node | null\n): void {\n const hasOld = oldFNodes && oldFNodes.length > 0\n const hasNew = newFNodes && newFNodes.length > 0\n\n // Fast path: both empty\n if (!hasOld && !hasNew) return\n\n // Fast path: remove all\n if (!hasNew) {\n for (const fnode of oldFNodes) {\n const node = fnode && getNode(fnode)\n if (node) {\n cleanupReactive(node)\n domRenderer.removeChild(parent, node)\n }\n }\n return\n }\n\n // Fast path: add all\n if (!hasOld) {\n const fragment = document.createDocumentFragment()\n for (const newFNode of newFNodes) {\n const node = mountReactive(newFNode, undefined)\n if (node) {\n setNode(newFNode, node)\n fragment.appendChild(node)\n }\n }\n if (nextSibling) {\n parent.insertBefore(fragment, nextSibling)\n } else {\n parent.appendChild(fragment)\n }\n return\n }\n\n // Performance: Fast path for small lists (5 or fewer items) - avoid Map/Set overhead\n const oldLen = oldFNodes.length\n const newLen = newFNodes.length\n const SMALL_LIST_THRESHOLD = 5\n\n if (oldLen <= SMALL_LIST_THRESHOLD && newLen <= SMALL_LIST_THRESHOLD) {\n // Simple linear reconciliation for small lists\n let oldIdx = 0\n let newIdx = 0\n let currentChild = parent.firstChild\n\n while (oldIdx < oldLen || newIdx < newLen) {\n if (newIdx >= newLen) {\n // Remove remaining old nodes\n while (oldIdx < oldLen) {\n const oldFNode = oldFNodes[oldIdx++]\n const node = oldFNode && getNode(oldFNode)\n if (node) {\n cleanupReactive(node)\n domRenderer.removeChild(parent, node)\n }\n }\n break\n }\n\n if (oldIdx >= oldLen) {\n // Add remaining new nodes\n const fragment = document.createDocumentFragment()\n while (newIdx < newLen) {\n const newFNode = newFNodes[newIdx++]\n const node = mountReactive(newFNode, undefined)\n if (node) {\n setNode(newFNode, node)\n fragment.appendChild(node)\n }\n }\n if (nextSibling) {\n parent.insertBefore(fragment, nextSibling)\n } else {\n parent.appendChild(fragment)\n }\n break\n }\n\n const oldFNode = oldFNodes[oldIdx]\n const newFNode = newFNodes[newIdx]\n const oldKey = oldFNode.key ?? `__idx_${oldIdx}_${oldFNode.type}`\n const newKey = newFNode.key ?? `__idx_${newIdx}_${newFNode.type}`\n\n if (oldKey === newKey && oldFNode.type === newFNode.type) {\n // Same node: patch and advance both\n patchNode(oldFNode, newFNode)\n currentChild = currentChild?.nextSibling || null\n oldIdx++\n newIdx++\n } else {\n // Different: check if we can find matching old node\n let found = false\n for (let searchIdx = oldIdx + 1; searchIdx < oldLen; searchIdx++) {\n const searchFNode = oldFNodes[searchIdx]\n const searchKey = searchFNode.key ?? `__idx_${searchIdx}_${searchFNode.type}`\n if (searchKey === newKey && searchFNode.type === newFNode.type) {\n // Found match: remove nodes between oldIdx and searchIdx, then patch\n for (let removeIdx = oldIdx; removeIdx < searchIdx; removeIdx++) {\n const removeFNode = oldFNodes[removeIdx]\n const node = removeFNode && getNode(removeFNode)\n if (node) {\n cleanupReactive(node)\n domRenderer.removeChild(parent, node)\n }\n }\n patchNode(searchFNode, newFNode)\n oldIdx = searchIdx + 1\n newIdx++\n found = true\n break\n }\n }\n if (!found) {\n // No match: insert new node\n const node = mountReactive(newFNode, undefined)\n if (node) {\n setNode(newFNode, node)\n parent.insertBefore(node, currentChild)\n }\n newIdx++\n }\n }\n }\n return\n }\n\n // Performance: Reuse Map/Set from pool to reduce GC pressure\n const keyToOldFNode = ReconciliationPool.getMap()\n const seen = ReconciliationPool.getSet()\n\n // Build key-to-node mapping\n for (let i = 0; i < oldLen; i++) {\n const fnode = oldFNodes[i]\n // Use key if available, otherwise use index with type prefix for uniqueness\n const key = fnode.key ?? `__idx_${i}_${fnode.type}`\n keyToOldFNode.set(key, fnode)\n }\n\n // Forward pass: process new nodes\n let currentChild = parent.firstChild\n\n for (let i = 0; i < newFNodes.length; i++) {\n const newFNode = newFNodes[i]\n const key = newFNode.key ?? `__idx_${i}_${newFNode.type}`\n seen.add(key)\n\n const oldFNode = keyToOldFNode.get(key)\n\n // Determine the reference node for insertion\n // If currentChild is valid, insert before it. Otherwise append (refNode is null).\n const refNode = currentChild\n\n if (!oldFNode || oldFNode.type !== newFNode.type) {\n // New node or type changed: create and insert\n const node = mountReactive(newFNode, undefined)\n if (node) {\n setNode(newFNode, node)\n parent.insertBefore(node, refNode)\n // We inserted a new node before currentChild, so currentChild is still the next one to process\n }\n // If type changed, old node will be removed in cleanup pass\n } else {\n // Existing node: patch and maybe move\n patchNode(oldFNode, newFNode)\n\n const node = getNode(newFNode)\n if (node) {\n if (currentChild !== node) {\n // Position wrong: move to correct position (before currentChild)\n parent.insertBefore(node, refNode)\n // We moved the node here. currentChild is still the next one to process.\n } else {\n // Position correct: match!\n // Advance pointer since we consumed this node\n currentChild = currentChild?.nextSibling || null\n }\n }\n }\n }\n\n // Cleanup pass: remove nodes not in new list\n for (const [key, fnode] of keyToOldFNode) {\n const node = getNode(fnode)\n if (!seen.has(key) && node) {\n cleanupReactive(node)\n // Check if node is still attached before removing\n if (node.parentNode === parent) {\n domRenderer.removeChild(parent, node)\n }\n }\n }\n\n // Performance: Return Map/Set to pool for reuse\n ReconciliationPool.release(keyToOldFNode, seen)\n}\n\n/**\n * Patch an existing FNode with new props and children\n */\nfunction patchNode(oldFNode: FNode, newFNode: FNode) {\n const node = getNode(oldFNode) as HTMLElement\n if (!node) return\n\n // Transfer DOM reference\n setNode(newFNode, node)\n\n // Only patch element nodes (not components)\n if (typeof newFNode.type !== 'string') return\n\n // Update props\n domRenderer.updateNode(node, oldFNode.props, newFNode.props)\n\n // Update children\n const oldChildren = oldFNode.children || []\n const newChildren = newFNode.children || []\n\n if (oldChildren.length === 0 && newChildren.length === 0) return\n\n // Fast path: single text/number child\n if (\n newChildren.length === 1 &&\n (typeof newChildren[0] === 'string' || typeof newChildren[0] === 'number') &&\n node.firstChild?.nodeType === Node.TEXT_NODE &&\n node.childNodes.length === 1\n ) {\n const newText = String(newChildren[0])\n const oldText = String(oldChildren[0])\n if (oldText !== newText) {\n domRenderer.updateTextNode(node.firstChild as Text, newText)\n }\n return\n }\n\n // Recursive reconciliation for nested children\n reconcileArrays(\n node,\n oldChildren as FNode[],\n newChildren as FNode[],\n null\n )\n}\n","/**\n * Reactive DOM Rendering\n *\n * Integrates the signal system with the DOM renderer to enable fine-grained\n * reactive updates. Only the specific DOM nodes that depend on changed signals\n * will be updated, without re-rendering the entire component tree.\n */\n\nimport type { FNode } from '../../core/renderer'\nimport { effect, isSignal, onCleanup, root } from '../../core/signal'\nimport type { Signal, Computed } from '../../core/signal'\nimport { domRenderer } from './index'\nimport { isFNode } from './f'\nimport {\n pushProvider,\n} from '../../core/context'\nimport { reconcileArrays } from './reconcile'\nimport {\n isStateValue,\n getStateSignal,\n setCurrentComponent,\n createComponentInstance,\n resetHookIndex,\n} from '../../core/state'\nimport {\n isListComponent,\n mountListComponent,\n ListComponent,\n} from '../../primitives/List'\nimport { logError, ErrorCodes } from '../../core/errors'\nimport { setNode, getNode } from './node-map'\n\nconst REACTIVE_BINDINGS = new WeakMap<Node, Set<() => void>>()\n\n/**\n * DOM Update Batching System\n * Batches DOM updates using requestAnimationFrame to improve performance\n * when multiple signals update simultaneously.\n */\ntype DOMUpdateTask = () => void\n\nconst domUpdateQueue = new Set<DOMUpdateTask>()\nlet isDOMUpdateScheduled = false\n\n/**\n * Schedule a DOM update to be batched\n */\nfunction scheduleDOMUpdate(task: DOMUpdateTask): void {\n domUpdateQueue.add(task)\n if (!isDOMUpdateScheduled) {\n isDOMUpdateScheduled = true\n // Use requestAnimationFrame to batch DOM updates with browser rendering cycle\n requestAnimationFrame(() => {\n flushDOMUpdates()\n })\n }\n}\n\n/**\n * Flush all pending DOM updates\n */\nfunction flushDOMUpdates(): void {\n isDOMUpdateScheduled = false\n if (domUpdateQueue.size === 0) return\n\n // Performance: Convert Set to array for faster iteration\n const queue = Array.from(domUpdateQueue)\n domUpdateQueue.clear()\n\n // Execute all DOM updates\n for (let i = 0; i < queue.length; i++) {\n queue[i]()\n }\n}\n\n/**\n * Register a dispose function for a node's reactive bindings.\n * Ensures the bindings set exists and adds the dispose function to it.\n */\nfunction registerReactiveBinding(node: Node, dispose: () => void): void {\n let bindings = REACTIVE_BINDINGS.get(node)\n if (!bindings) {\n bindings = new Set()\n REACTIVE_BINDINGS.set(node, bindings)\n }\n bindings.add(dispose)\n}\n\n/**\n * Mount a virtual node reactively to the DOM.\n *\n * This is the core rendering function that handles all node types:\n * - FNodes (both built-in elements and function components)\n * - Strings and numbers (text nodes)\n * - Signals and computed values (reactive children)\n * - StateValues from the state() API\n * - ListComponents\n * - Arrays and fragments\n *\n * Reactive values are automatically tracked and DOM updates occur\n * only when the specific values change (fine-grained reactivity).\n *\n * @param vnode - The virtual node to mount\n * @param container - Optional parent node to append to\n * @returns The created DOM node, or null for empty/boolean values\n *\n * @example\n * ```tsx\n * // Mount a simple element\n * const node = mountReactive(<div>Hello</div>, document.body)\n *\n * // Mount a reactive signal\n * const count = signal(0)\n * mountReactive(() => <span>{count.value}</span>, container)\n * ```\n */\nexport function mountReactive(\n node:\n | FNode\n | string\n | number\n | boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Signal<any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Computed<any>\n | null\n | undefined\n | Function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | any[]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | ListComponent<any>,\n container?: Node\n): Node | null {\n // Handle null/undefined/boolean (falsy JSX values)\n if (node === null || node === undefined || typeof node === 'boolean') {\n return null\n }\n\n // Handle List component\n if (isListComponent(node)) {\n const parent = container || document.createDocumentFragment()\n\n const listDispose = mountListComponent(\n node,\n parent,\n (childNode) => mountReactive(childNode),\n cleanupReactive\n )\n\n // Create a marker for cleanup tracking\n const marker = document.createTextNode('')\n registerReactiveBinding(marker, listDispose)\n\n return container ? parent.firstChild : parent\n }\n\n // Handle StateValue (from state() API)\n if (isStateValue(node)) {\n const sig = getStateSignal(node)\n if (sig) {\n const startNode = document.createTextNode('')\n const parent = container || document.createDocumentFragment()\n domRenderer.appendChild(parent, startNode)\n\n let currentNode: Node | null = startNode\n\n const dispose = effect(() => {\n const value = sig.value\n const currentContainer = startNode.parentNode\n if (!currentContainer) return\n\n if (\n (typeof value === 'string' || typeof value === 'number') &&\n currentNode &&\n currentNode.nodeType === Node.TEXT_NODE &&\n currentNode !== startNode\n ) {\n // Performance: Batch simple text node updates\n const textNode = currentNode as Text\n const textValue = String(value)\n scheduleDOMUpdate(() => {\n domRenderer.updateTextNode(textNode, textValue)\n })\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const newNode = mountReactive(value as any)\n if (newNode) {\n if (currentNode && currentNode !== startNode) {\n if (currentNode.parentNode === currentContainer) {\n // Optimize: if both old and new are text nodes, just update content\n if (\n currentNode.nodeType === Node.TEXT_NODE &&\n newNode.nodeType === Node.TEXT_NODE\n ) {\n // Performance: Batch text node updates\n const textNode = currentNode as Text\n const textContent = newNode.textContent || ''\n scheduleDOMUpdate(() => {\n domRenderer.updateTextNode(textNode, textContent)\n })\n // Don't update currentNode reference since we reused it\n } else {\n currentContainer.replaceChild(newNode, currentNode)\n currentNode = newNode\n }\n } else {\n currentContainer.insertBefore(newNode, startNode.nextSibling)\n currentNode = newNode\n }\n } else {\n currentContainer.insertBefore(newNode, startNode.nextSibling)\n currentNode = newNode\n }\n } else {\n if (\n currentNode &&\n currentNode !== startNode &&\n currentNode.parentNode === currentContainer\n ) {\n try {\n currentContainer.removeChild(currentNode)\n } catch (e) {\n logError(ErrorCodes.DOM_CLEANUP_FAILED, { operation: 'removeChild' }, e)\n }\n }\n currentNode = startNode\n }\n }\n })\n\n registerReactiveBinding(startNode, dispose)\n\n return container ? startNode : parent\n }\n }\n\n // Handle signals and functions (reactive children)\n if (isSignal(node) || typeof node === 'function') {\n const startNode = document.createTextNode('')\n const parent = container || document.createDocumentFragment()\n domRenderer.appendChild(parent, startNode)\n\n let currentNodes: Node[] = []\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentFNode: any = null\n let currentFNodeList: FNode[] = []\n\n const dispose = effect(() => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = isSignal(node) ? (node as Signal<any>).value : (node as () => unknown)()\n const currentContainer = startNode.parentNode\n\n // Safety check: if node is detached, we can't update siblings\n if (!currentContainer) return\n\n if (Array.isArray(value)) {\n const newFNodes = value.filter((c) => c != null)\n if (currentFNodeList.length > 0) {\n const nextSibling = startNode.nextSibling\n // Note: reconcileArrays expects parent, oldFNodes, newFNodes, nextSibling\n reconcileArrays(\n currentContainer,\n currentFNodeList,\n newFNodes,\n nextSibling\n )\n } else {\n // Clean up old nodes first\n for (const childNode of currentNodes) {\n cleanupReactive(childNode)\n if (childNode.parentNode === currentContainer) {\n try {\n currentContainer.removeChild(childNode)\n } catch (e) {\n logError(ErrorCodes.DOM_CLEANUP_FAILED, { operation: 'removeChild' }, e)\n }\n }\n }\n currentNodes = []\n\n const fragment = document.createDocumentFragment()\n for (const child of newFNodes) {\n const childNode = mountReactive(child, fragment)\n if (childNode && typeof child === 'object') {\n setNode(child, childNode)\n }\n }\n currentNodes = Array.from(fragment.childNodes)\n currentContainer.insertBefore(fragment, startNode.nextSibling)\n }\n currentFNodeList = newFNodes\n currentFNode = value\n return\n }\n\n if (currentFNodeList.length > 0) {\n for (const childFNode of currentFNodeList) {\n const childNode = getNode(childFNode)\n if (childNode && childNode.parentNode === currentContainer) {\n cleanupReactive(childNode)\n try {\n currentContainer.removeChild(childNode)\n } catch (e) {\n logError(ErrorCodes.DOM_CLEANUP_FAILED, { operation: 'removeChild' }, e)\n }\n }\n }\n currentFNodeList = []\n }\n\n if (value !== currentFNode) {\n // Clean up old nodes first\n for (const childNode of currentNodes) {\n cleanupReactive(childNode)\n if (childNode.parentNode === currentContainer) {\n try {\n currentContainer.removeChild(childNode)\n } catch (e) {\n logError(ErrorCodes.DOM_CLEANUP_FAILED, { operation: 'removeChild' }, e)\n }\n }\n }\n currentNodes = []\n\n if (\n (typeof value === 'string' || typeof value === 'number')\n ) {\n const textNode = domRenderer.createTextNode(String(value))\n currentContainer.insertBefore(textNode, startNode.nextSibling)\n currentNodes = [textNode]\n } else {\n const newNode = mountReactive(value)\n if (newNode) {\n // If newNode is a fragment, track all children\n if (newNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n currentNodes = Array.from(newNode.childNodes)\n currentContainer.insertBefore(newNode, startNode.nextSibling)\n } else {\n currentContainer.insertBefore(newNode, startNode.nextSibling)\n currentNodes = [newNode]\n }\n }\n }\n currentFNode = value\n }\n })\n\n registerReactiveBinding(startNode, dispose)\n\n return container ? startNode : parent\n }\n\n if (Array.isArray(node)) {\n const fragment = document.createDocumentFragment()\n for (const child of node) {\n mountReactive(child, fragment)\n }\n if (container) {\n domRenderer.appendChild(container, fragment)\n }\n return fragment\n }\n\n // Handle text nodes\n if (typeof node === 'string' || typeof node === 'number') {\n const textNode = domRenderer.createTextNode(String(node))\n if (container) domRenderer.appendChild(container, textNode)\n return textNode\n }\n\n // Handle FNodes\n if (isFNode(node)) {\n // Handle function components\n if (typeof node.type === 'function') {\n const component = node.type\n const startNode = document.createTextNode('')\n const parent = container || document.createDocumentFragment()\n domRenderer.appendChild(parent, startNode)\n\n let currentNodes: Node[] = []\n let currentFNodeList: FNode[] = []\n\n // Create component instance for hook tracking\n const componentInstance = createComponentInstance()\n\n const dispose = effect(() => {\n try {\n // Reset hook index for each render\n resetHookIndex(componentInstance)\n\n // Use root() to track any effects created inside the component\n // These will be automatically cleaned up when disposeRoot is called\n // Use root() to track any effects created inside the component\n // These will be automatically cleaned up when disposeRoot is called\n root((disposeRoot) => {\n // Register disposeRoot to cleanup component's internal effects\n onCleanup(disposeRoot)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const contextId = (component as any)._contextId\n if (contextId) {\n pushProvider(contextId, node.props.value)\n }\n\n let result\n try {\n // Set current component for hook tracking\n setCurrentComponent(componentInstance)\n // Performance: Avoid object spread when children is undefined (reuse props object)\n const componentProps = node.children !== undefined\n ? { ...node.props, children: node.children }\n : node.props\n result = component(componentProps)\n } finally {\n // Clear current component\n setCurrentComponent(null)\n }\n\n // Attempt Reconciliation for Arrays (e.g. items.map)\n // This enables efficient list updates without full re-render\n const isArray = Array.isArray(result)\n // Check if it's a list of FNodes (elements) that we can reconcile\n // We skip reconciliation for primitives or fragments to be safe for now\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const canReconcile = isArray && (result as unknown as any[]).every(item =>\n isFNode(item) && item.type !== 'fragment'\n )\n\n if (canReconcile) {\n const parent = startNode.parentNode\n if (parent) {\n // Normalize result to FNode[] (already checked, but for type safety)\n const newFNodes = result as unknown as FNode[]\n\n // Use reconcileArrays to diff/patch the DOM\n reconcileArrays(\n parent,\n currentFNodeList,\n newFNodes,\n startNode.nextSibling\n )\n\n // Update state for next render\n currentFNodeList = newFNodes\n // Update currentNodes so we know what to remove if we switch to fallback\n currentNodes = newFNodes.map(fn => getNode(fn)).filter(n => n != null) as Node[]\n return\n }\n }\n\n // Fallback: Standard Mount (Destroy & Recreate)\n // Clean up old nodes first\n const currentParent = startNode.parentNode\n if (currentParent) {\n // If we were using reconciliation, currentFNodeList handles the nodes\n // If not, currentNodes handles them.\n // We iterate currentNodes to be safe.\n for (const childNode of currentNodes) {\n cleanupReactive(childNode)\n // Only remove if still attached (reconcileArrays might have moved them)\n if (childNode.parentNode === currentParent) {\n try {\n currentParent.removeChild(childNode)\n } catch (e) {\n logError(ErrorCodes.DOM_CLEANUP_FAILED, { operation: 'removeChild' }, e)\n }\n }\n }\n }\n currentNodes = []\n currentFNodeList = []\n\n const fragment = document.createDocumentFragment()\n mountReactive(result, fragment)\n\n if (currentParent) {\n currentNodes = Array.from(fragment.childNodes)\n currentParent.insertBefore(fragment, startNode.nextSibling)\n }\n })\n } finally {\n // No popProvider needed with Owner-based context\n }\n })\n\n registerReactiveBinding(startNode, dispose)\n\n return container ? startNode : parent\n }\n\n // Handle fragments\n if (node.type === 'fragment') {\n const fragment = document.createDocumentFragment()\n for (const child of node.children) {\n mountReactive(child, fragment)\n }\n if (container) {\n domRenderer.appendChild(container, fragment)\n }\n return fragment\n }\n\n // Handle built-in elements\n const domNode = domRenderer.createNode(node.type, node.props)\n const disposeProps = setupReactiveProps(domNode, node.props)\n if (disposeProps.length > 0) {\n REACTIVE_BINDINGS.set(domNode, new Set(disposeProps))\n }\n\n for (const child of node.children) {\n mountReactive(child, domNode)\n }\n\n if (container) {\n domRenderer.appendChild(container, domNode)\n }\n\n // Handle ref (callback or object with .current)\n const ref = node.props.ref\n if (ref) {\n if (typeof ref === 'function') {\n // Callback ref\n ref(domNode)\n registerReactiveBinding(domNode, () => {\n ref(null)\n })\n } else if (typeof ref === 'object' && 'current' in ref) {\n // Object ref (like useRef)\n ref.current = domNode\n registerReactiveBinding(domNode, () => {\n ref.current = null\n })\n }\n }\n\n return domNode\n }\n\n return null\n}\n\n// Sentinel value to detect first run\nconst UNINITIALIZED = Symbol('uninitialized')\n\nfunction setupReactiveProps(\n node: HTMLElement | SVGElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>\n): (() => void)[] {\n const disposers: (() => void)[] = []\n\n // Performance: Filter reactive props in a single pass\n // Only process props that are signals or functions (reactive props)\n // Skip event handlers (they are handled separately in updateNode)\n const reactiveProps: Array<[string, unknown]> = []\n for (const key in props) {\n // Skip event handlers (they are handled separately in updateNode)\n if (key.startsWith('on')) continue\n \n const value = props[key]\n // Only collect reactive props (signals or functions)\n if (isSignal(value) || typeof value === 'function') {\n reactiveProps.push([key, value])\n }\n }\n\n // Process only reactive props (reduces iterations)\n for (const [key, value] of reactiveProps) {\n if (isSignal(value)) {\n // Track previous value to avoid unnecessary DOM updates\n // Use sentinel for first run to ensure initial value is set\n let prevValue: unknown = UNINITIALIZED\n const dispose = effect(() => {\n const newValue = value.value\n // Only update DOM if value actually changed (always update on first run)\n if (newValue !== prevValue) {\n // Performance: Batch DOM node updates\n const oldPropValue = prevValue === UNINITIALIZED ? undefined : prevValue\n scheduleDOMUpdate(() => {\n domRenderer.updateNode(\n node,\n { [key]: oldPropValue },\n { [key]: newValue }\n )\n })\n prevValue = newValue\n }\n })\n disposers.push(dispose)\n } else {\n // value is a function (already checked in filter above)\n // Track previous value to avoid unnecessary DOM updates\n // Use sentinel for first run to ensure initial value is set\n let prevValue: unknown = UNINITIALIZED\n const dispose = effect(() => {\n try {\n // TypeScript: value is guaranteed to be a function here (checked in filter above)\n const newValue = (value as () => unknown)()\n // Only update DOM if value actually changed (always update on first run)\n if (newValue !== prevValue) {\n // Performance: Batch DOM node updates\n const oldPropValue = prevValue === UNINITIALIZED ? undefined : prevValue\n scheduleDOMUpdate(() => {\n domRenderer.updateNode(\n node,\n { [key]: oldPropValue },\n { [key]: newValue }\n )\n })\n prevValue = newValue\n }\n } catch (e) {\n logError(ErrorCodes.DOM_CLEANUP_FAILED, { operation: 'updateNode', prop: key }, e)\n }\n })\n disposers.push(dispose)\n }\n }\n return disposers\n}\n\nexport function cleanupReactive(node: Node): void {\n const bindings = REACTIVE_BINDINGS.get(node)\n if (bindings) {\n bindings.forEach((dispose) => dispose())\n REACTIVE_BINDINGS.delete(node)\n }\n if (node.childNodes && node.childNodes.length > 0) {\n const children = Array.from(node.childNodes)\n for (const child of children) {\n cleanupReactive(child)\n }\n }\n}\n\nexport function createReactiveRoot(container: HTMLElement) {\n let rootDispose: (() => void) | null = null\n let currentRootNode: Node | null = null\n let currentFNode: FNode | null = null\n\n return {\n render(node: FNode) {\n // Performance: If rendering the same node, skip cleanup (optimization for re-renders)\n const isSameNode = currentFNode === node\n\n if (!isSameNode && currentRootNode) {\n cleanupReactive(currentRootNode)\n // Performance: Use removeChild instead of innerHTML when possible (faster)\n // Only use innerHTML if container has many children\n if (container.childNodes.length === 1) {\n container.removeChild(currentRootNode)\n } else {\n container.innerHTML = ''\n }\n currentRootNode = null\n }\n\n if (rootDispose) {\n rootDispose()\n rootDispose = null\n }\n\n rootDispose = effect(() => {\n // Performance: Only clear if we have existing content and it's different\n if (!isSameNode && container.firstChild) {\n // Performance: Use removeChild for single child, innerHTML for multiple\n if (container.childNodes.length === 1) {\n container.removeChild(container.firstChild!)\n } else {\n container.innerHTML = ''\n }\n }\n currentRootNode = mountReactive(node, container)\n currentFNode = node\n })\n },\n unmount() {\n if (rootDispose) {\n rootDispose()\n rootDispose = null\n }\n cleanupReactive(container)\n // Performance: Use removeChild when possible\n if (container.childNodes.length === 1) {\n container.removeChild(container.firstChild!)\n } else {\n container.innerHTML = ''\n }\n currentRootNode = null\n currentFNode = null\n },\n }\n}\n\n/**\n * Create a reactive text node that updates when the getter returns a new value\n */\nexport function reactiveText(getText: () => string): Text {\n const textNode = document.createTextNode('')\n const dispose = effect(() => {\n const text = getText()\n // Performance: Batch text node updates\n scheduleDOMUpdate(() => {\n domRenderer.updateTextNode(textNode, text)\n })\n })\n registerReactiveBinding(textNode, dispose)\n return textNode\n}\n","/**\n * DOM Render Function\n *\n * This module provides the main render function for mounting components to the DOM.\n * It includes simple reconciliation logic for mounting and unmounting components.\n *\n * Note: This module uses reactive rendering internally via mountReactive.\n * For root-level rendering with cleanup support, use createReactiveRoot.\n */\n\nimport type { FNode, FNodeChild } from '../../core/renderer'\nimport { domRenderer } from './index'\nimport { isFNode } from './f'\nimport { mountReactive, createReactiveRoot } from './reactive'\n\n/**\n * Internal node data stored on DOM nodes\n */\ninterface NodeData {\n vnode: FNode | null\n props: Record<string, unknown>\n}\n\nconst NODE_DATA = new WeakMap<Node, NodeData>()\n\n/**\n * Render a component to a DOM container with automatic reactivity\n *\n * This function uses reactive rendering by default, which means:\n * - Signals passed as children automatically update the DOM\n * - Signals in props automatically update element properties\n * - Component functions automatically re-render when signals change\n *\n * @param vnode - Flexium node to render\n * @returns The rendered DOM node\n *\n * @example\n * const count = signal(0);\n * render(f('div', {}, [count]), document.body);\n * // The div will automatically update when count changes\n */\n/**\n * Mounts a Flexium node to a container\n * @param node - Flexium node to render\n * @param container - DOM element to mount to\n */\nexport function render(\n node: FNode | string | number | null | undefined | Function,\n container: HTMLElement\n): Node | null {\n // Clear container\n container.innerHTML = ''\n return mountReactive(node, container)\n}\n\n/**\n * Internal function to mount a node\n */\nfunction mountNode(node: FNodeChild | Function): Node | null {\n // Handle primitives\n if (node === null || node === undefined || typeof node === 'boolean') {\n return null\n }\n\n // Handle arrays (fragments)\n if (Array.isArray(node)) {\n const fragment = document.createDocumentFragment()\n for (const child of node) {\n const childNode = mountNode(child)\n if (childNode) {\n domRenderer.appendChild(fragment, childNode)\n }\n }\n return fragment\n }\n\n // Handle functions (signals or components returning functions)\n if (typeof node === 'function') {\n return mountNode(node())\n }\n\n // Handle strings/numbers\n if (typeof node === 'string' || typeof node === 'number') {\n return domRenderer.createTextNode(String(node))\n }\n\n // Handle FNodes\n if (isFNode(node)) {\n // Handle function components\n if (typeof node.type === 'function') {\n const component = node.type\n const result = component({ ...node.props, children: node.children })\n return mountNode(result)\n }\n\n // Handle fragments\n if (node.type === 'fragment') {\n const fragment = document.createDocumentFragment()\n for (const child of node.children) {\n const childNode = mountNode(child)\n if (childNode) {\n domRenderer.appendChild(fragment, childNode)\n }\n }\n return fragment\n }\n\n // Handle DOM elements\n const domNode = domRenderer.createNode(node.type, node.props)\n\n // Handle children\n for (const child of node.children) {\n const childNode = mountNode(child)\n if (childNode) {\n domRenderer.appendChild(domNode, childNode)\n }\n }\n\n return domNode\n }\n\n return null\n}\n\n/**\n * Unmount a DOM node and clean up\n */\nfunction unmount(node: Node): void {\n // Clean up children first\n const childNodes = Array.from(node.childNodes)\n for (const child of childNodes) {\n unmount(child)\n }\n\n // Remove from parent\n if (node.parentNode) {\n node.parentNode.removeChild(node)\n }\n\n // Clean up stored data\n NODE_DATA.delete(node)\n}\n\n/**\n * Update an existing DOM node with a new flexium node\n * (Simple implementation - will be enhanced with proper reconciliation later)\n */\nexport function update(\n node: HTMLElement,\n oldVNode: FNode,\n newVNode: FNode\n): void {\n // If types don't match, replace the node\n if (oldVNode.type !== newVNode.type) {\n const newNode = mountNode(newVNode)\n if (newNode && node.parentNode) {\n node.parentNode.replaceChild(newNode, node)\n }\n unmount(node)\n return\n }\n\n // Update props\n domRenderer.updateNode(node, oldVNode.props, newVNode.props)\n\n // Update stored data\n NODE_DATA.set(node, {\n vnode: newVNode,\n props: newVNode.props,\n })\n\n // Update children (simple approach for now)\n const oldChildren = oldVNode.children\n const newChildren = newVNode.children\n\n // Simple reconciliation: update/add/remove based on index\n const maxLength = Math.max(oldChildren.length, newChildren.length)\n\n for (let i = 0; i < maxLength; i++) {\n const oldChild = oldChildren[i]\n const newChild = newChildren[i]\n const childNode = node.childNodes[i]\n\n if (!newChild) {\n // Remove old child\n if (childNode) {\n unmount(childNode)\n }\n } else if (!oldChild) {\n // Add new child\n const newChildNode = mountNode(newChild)\n if (newChildNode) {\n domRenderer.appendChild(node, newChildNode)\n }\n } else if (typeof oldChild === 'string' || typeof oldChild === 'number') {\n // Update text node\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n if (oldChild !== newChild && childNode) {\n domRenderer.updateTextNode(childNode as Text, String(newChild))\n }\n } else {\n // Replace text with element\n const newChildNode = mountNode(newChild)\n if (newChildNode && childNode) {\n node.replaceChild(newChildNode, childNode)\n unmount(childNode)\n }\n }\n } else if (isFNode(oldChild)) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Replace element with text\n const newChildNode = mountNode(newChild)\n if (newChildNode && childNode) {\n node.replaceChild(newChildNode, childNode)\n unmount(childNode)\n }\n } else if (isFNode(newChild)) {\n // Update element\n if (childNode instanceof HTMLElement) {\n update(childNode, oldChild, newChild)\n }\n }\n }\n }\n}\n\n/**\n * Create a root for rendering with automatic reactivity\n *\n * This creates a root that supports fine-grained reactive updates.\n * Signals are automatically tracked and only the affected DOM nodes are updated.\n *\n * @param container - DOM element to render into\n * @returns Root object with render and unmount methods\n *\n * @example\n * const root = createRoot(document.body);\n * const count = signal(0);\n * root.render(f('div', {}, [count]));\n * // Later: count.value++ will automatically update the DOM\n */\nexport function createRoot(container: HTMLElement) {\n // Use reactive root for automatic signal tracking\n return createReactiveRoot(container)\n}\n\n","import { mountReactive, cleanupReactive } from './reactive'\nimport { onCleanup } from '../../core/signal'\n\ninterface PortalProps {\n mount?: HTMLElement\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n children: any\n}\n\n/**\n * <Portal> component renders its children into a different part of the DOM.\n * Useful for modals, tooltips, etc.\n *\n * @example\n * <Portal mount={document.body}>\n * <div class=\"modal\">...</div>\n * </Portal>\n */\nexport function Portal(props: PortalProps) {\n // SSR guard: return null placeholder on server\n if (typeof document === 'undefined') {\n return null\n }\n\n const container = props.mount || document.body\n\n // Placeholder to keep position in the VDOM tree\n const placeholder = document.createComment('portal')\n\n // We use a fragment to hold portal content references\n let portalContent: Node | null = null\n\n // Mount children to the target container\n // This runs synchronously when Portal component is executed (inside effect)\n portalContent = mountReactive(props.children, container)\n\n // Cleanup when Portal is unmounted\n onCleanup(() => {\n if (portalContent) {\n cleanupReactive(portalContent)\n if (portalContent.parentNode === container) {\n container.removeChild(portalContent)\n }\n }\n })\n\n return placeholder\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/utils.ts","../src/primitives/canvas/utils.ts","../src/primitives/canvas/renderer.ts","../src/primitives/canvas/Canvas.ts","../src/primitives/canvas/DrawRect.ts","../src/primitives/canvas/DrawCircle.ts","../src/primitives/canvas/DrawArc.ts","../src/primitives/canvas/DrawLine.ts","../src/primitives/canvas/DrawPath.ts","../src/primitives/canvas/DrawText.ts"],"names":["normalizeStyle","style","css","textStyle","isSignal","value","unwrapSignal","renderCanvasChildren","ctx","children","_width","_height","childArray","child","renderRect","renderCircle","renderPath","renderText","renderLine","renderArc","props","x","y","width","height","fill","stroke","strokeWidth","opacity","radius","d","path","text","fontSize","fontFamily","fontWeight","textAlign","textBaseline","x1","y1","x2","y2","startAngle","endAngle","counterclockwise","Canvas","id","rest","canvas","effect","onCleanup","rafId","scheduleRender","key","err","DrawRect","DrawCircle","DrawArc","DrawLine","DrawPath","DrawText"],"mappings":"iEASO,SAASA,EACdC,CAAAA,CAEqB,CACrB,GAAI,CAACA,EAAO,OAAO,EAAC,CAGpB,IAAMC,EAA2B,EAAC,CAG9BD,EAAM,OAAA,GAASC,CAAAA,CAAI,QAAUD,CAAAA,CAAM,OAAA,CAAA,CACnCA,CAAAA,CAAM,IAAA,GAAS,SAAWC,CAAAA,CAAI,IAAA,CAAOD,EAAM,IAAA,CAAA,CAC3CA,CAAAA,CAAM,gBAAeC,CAAAA,CAAI,aAAA,CAAgBD,CAAAA,CAAM,aAAA,CAAA,CAC/CA,EAAM,QAAA,GAAUC,CAAAA,CAAI,SAAWD,CAAAA,CAAM,QAAA,CAAA,CACrCA,EAAM,cAAA,GAAgBC,CAAAA,CAAI,cAAA,CAAiBD,CAAAA,CAAM,gBACjDA,CAAAA,CAAM,UAAA,GAAYC,EAAI,UAAA,CAAaD,CAAAA,CAAM,YACzCA,CAAAA,CAAM,SAAA,GAAWC,CAAAA,CAAI,SAAA,CAAYD,EAAM,SAAA,CAAA,CACvCA,CAAAA,CAAM,MAAQ,MAAA,GAAWC,CAAAA,CAAI,IAAM,CAAA,EAAGD,CAAAA,CAAM,GAAG,CAAA,EAAA,CAAA,CAAA,CAG/CA,EAAM,OAAA,GAAY,MAAA,GA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,CACd,OAAA,CAAQ,KAAA,CAAM,iDAAkDA,CAAG,EACrE,CAAC,EACL,CACF,CAAA,CACA,QAAA,CAAU,EACZ,CACF,CCxFO,SAASC,CAAAA,CAASnC,CAAAA,CAA6B,CACpD,OAAO,CACL,IAAA,CAAM,cACN,KAAA,CAAAA,CAAAA,CACA,SAAU,EACZ,CACF,CCNO,SAASoC,CAAAA,CAAWpC,CAAAA,CAA+B,CACxD,OAAO,CACL,KAAM,eAAA,CACN,KAAA,CAAAA,CAAAA,CACA,QAAA,CAAU,EACZ,CACF,CCNO,SAASqC,CAAAA,CAAQrC,EAA4B,CAClD,OAAO,CACL,IAAA,CAAM,aACN,KAAA,CAAAA,CAAAA,CACA,SAAU,EACZ,CACF,CCNO,SAASsC,CAAAA,CAAStC,CAAAA,CAA6B,CACpD,OAAO,CACL,KAAM,aAAA,CACN,KAAA,CAAAA,EACA,QAAA,CAAU,EACZ,CACF,CCNO,SAASuC,CAAAA,CAASvC,EAA6B,CACpD,OAAO,CACL,IAAA,CAAM,aAAA,CACN,KAAA,CAAAA,CAAAA,CACA,SAAU,EACZ,CACF,CCNO,SAASwC,EAASxC,CAAAA,CAA6B,CACpD,OAAO,CACL,KAAM,aAAA,CACN,KAAA,CAAAA,EACA,QAAA,CAAU,EACZ,CACF","file":"chunk-L4C5UBOX.js","sourcesContent":["/**\n * Primitive utilities\n */\n\nimport type { CommonStyle, TextStyle } from './types'\n\n/**\n * Normalize CommonStyle to CSS properties\n */\nexport function normalizeStyle(\n style?: CommonStyle | TextStyle\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n if (!style) return {}\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const css: Record<string, any> = {}\n\n // Layout\n if (style.display) css.display = style.display\n if (style.flex !== undefined) css.flex = style.flex\n if (style.flexDirection) css.flexDirection = style.flexDirection\n if (style.flexWrap) css.flexWrap = style.flexWrap\n if (style.justifyContent) css.justifyContent = style.justifyContent\n if (style.alignItems) css.alignItems = style.alignItems\n if (style.alignSelf) css.alignSelf = style.alignSelf\n if (style.gap !== undefined) css.gap = `${style.gap}px`\n\n // Spacing - padding\n if (style.padding !== undefined) css.padding = `${style.padding}px`\n if (style.paddingTop !== undefined) css.paddingTop = `${style.paddingTop}px`\n if (style.paddingRight !== undefined)\n css.paddingRight = `${style.paddingRight}px`\n if (style.paddingBottom !== undefined)\n css.paddingBottom = `${style.paddingBottom}px`\n if (style.paddingLeft !== undefined)\n css.paddingLeft = `${style.paddingLeft}px`\n if (style.paddingHorizontal !== undefined) {\n css.paddingLeft = `${style.paddingHorizontal}px`\n css.paddingRight = `${style.paddingHorizontal}px`\n }\n if (style.paddingVertical !== undefined) {\n css.paddingTop = `${style.paddingVertical}px`\n css.paddingBottom = `${style.paddingVertical}px`\n }\n\n // Spacing - margin\n if (style.margin !== undefined) css.margin = `${style.margin}px`\n if (style.marginTop !== undefined) css.marginTop = `${style.marginTop}px`\n if (style.marginRight !== undefined)\n css.marginRight = `${style.marginRight}px`\n if (style.marginBottom !== undefined)\n css.marginBottom = `${style.marginBottom}px`\n if (style.marginLeft !== undefined) css.marginLeft = `${style.marginLeft}px`\n if (style.marginHorizontal !== undefined) {\n css.marginLeft = `${style.marginHorizontal}px`\n css.marginRight = `${style.marginHorizontal}px`\n }\n if (style.marginVertical !== undefined) {\n css.marginTop = `${style.marginVertical}px`\n css.marginBottom = `${style.marginVertical}px`\n }\n\n // Sizing\n if (style.width !== undefined)\n css.width =\n typeof style.width === 'number' ? `${style.width}px` : style.width\n if (style.height !== undefined)\n css.height =\n typeof style.height === 'number' ? `${style.height}px` : style.height\n if (style.minWidth !== undefined) css.minWidth = `${style.minWidth}px`\n if (style.maxWidth !== undefined) css.maxWidth = `${style.maxWidth}px`\n if (style.minHeight !== undefined) css.minHeight = `${style.minHeight}px`\n if (style.maxHeight !== undefined) css.maxHeight = `${style.maxHeight}px`\n\n // Visual\n if (style.backgroundColor) css.backgroundColor = style.backgroundColor\n if (style.borderRadius !== undefined)\n css.borderRadius = `${style.borderRadius}px`\n if (style.borderTopLeftRadius !== undefined)\n css.borderTopLeftRadius = `${style.borderTopLeftRadius}px`\n if (style.borderTopRightRadius !== undefined)\n css.borderTopRightRadius = `${style.borderTopRightRadius}px`\n if (style.borderBottomLeftRadius !== undefined)\n css.borderBottomLeftRadius = `${style.borderBottomLeftRadius}px`\n if (style.borderBottomRightRadius !== undefined)\n css.borderBottomRightRadius = `${style.borderBottomRightRadius}px`\n if (style.opacity !== undefined) css.opacity = style.opacity\n\n // Border\n if (style.borderWidth !== undefined)\n css.borderWidth = `${style.borderWidth}px`\n if (style.borderColor) css.borderColor = style.borderColor\n if (style.borderTopWidth !== undefined)\n css.borderTopWidth = `${style.borderTopWidth}px`\n if (style.borderRightWidth !== undefined)\n css.borderRightWidth = `${style.borderRightWidth}px`\n if (style.borderBottomWidth !== undefined)\n css.borderBottomWidth = `${style.borderBottomWidth}px`\n if (style.borderLeftWidth !== undefined)\n css.borderLeftWidth = `${style.borderLeftWidth}px`\n\n // Position\n if (style.position) css.position = style.position\n if (style.top !== undefined) css.top = `${style.top}px`\n if (style.right !== undefined) css.right = `${style.right}px`\n if (style.bottom !== undefined) css.bottom = `${style.bottom}px`\n if (style.left !== undefined) css.left = `${style.left}px`\n if (style.zIndex !== undefined) css.zIndex = style.zIndex\n\n // Transform\n if (style.transform) css.transform = style.transform\n\n // Text-specific (if TextStyle)\n const textStyle = style as TextStyle\n if (textStyle.color) css.color = textStyle.color\n if (textStyle.fontSize !== undefined) css.fontSize = `${textStyle.fontSize}px`\n if (textStyle.fontWeight) css.fontWeight = textStyle.fontWeight\n if (textStyle.fontFamily) css.fontFamily = textStyle.fontFamily\n if (textStyle.fontStyle) css.fontStyle = textStyle.fontStyle\n if (textStyle.textAlign) css.textAlign = textStyle.textAlign\n if (textStyle.textDecoration) css.textDecoration = textStyle.textDecoration\n if (textStyle.lineHeight !== undefined)\n css.lineHeight = `${textStyle.lineHeight}px`\n if (textStyle.letterSpacing !== undefined)\n css.letterSpacing = `${textStyle.letterSpacing}px`\n\n return css\n}\n","/**\n * Canvas utilities\n */\n\nimport { isSignal as coreIsSignal } from '../../core/signal'\nimport type { Signal } from '../../core/signal'\n\n/**\n * Check if a value is a Signal\n */\nexport function isSignal<T>(value: T | Signal<T>): value is Signal<T> {\n // Use core isSignal which checks for SIGNAL_MARKER symbol\n // Signals are functions with properties, not plain objects\n return coreIsSignal(value)\n}\n\n/**\n * Unwrap a value that might be a Signal\n */\nexport function unwrapSignal<T>(value: T | Signal<T>): T {\n // Check for real signals first (have SIGNAL_MARKER)\n if (isSignal(value)) {\n return value.value\n }\n // Handle signal-like objects (for testing) - duck typing\n // Check if it's an object with a 'value' property\n if (\n value !== null &&\n typeof value === 'object' &&\n 'value' in value &&\n 'peek' in value\n ) {\n return (value as any).value\n }\n return value\n}\n","/**\n * Canvas renderer - renders canvas primitives to canvas context\n */\n\nimport type {\n DrawRectProps,\n DrawCircleProps,\n DrawPathProps,\n DrawTextProps,\n DrawLineProps,\n DrawArcProps,\n} from '../types'\nimport { unwrapSignal } from './utils'\n\n/**\n * Render canvas children to context\n */\nexport function renderCanvasChildren(\n ctx: CanvasRenderingContext2D,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n children: any,\n _width: number,\n _height: number\n): void {\n if (!children) return\n\n const childArray = Array.isArray(children) ? children : [children]\n\n for (const child of childArray) {\n if (!child || !child.type) continue\n\n switch (child.type) {\n case 'canvas-rect':\n renderRect(ctx, child.props)\n break\n case 'canvas-circle':\n renderCircle(ctx, child.props)\n break\n case 'canvas-path':\n renderPath(ctx, child.props)\n break\n case 'canvas-text':\n renderText(ctx, child.props)\n break\n case 'canvas-line':\n renderLine(ctx, child.props)\n break\n case 'canvas-arc':\n renderArc(ctx, child.props)\n break\n }\n }\n}\n\n/**\n * Render rectangle\n */\nfunction renderRect(ctx: CanvasRenderingContext2D, props: DrawRectProps): void {\n const x = unwrapSignal(props.x)\n const y = unwrapSignal(props.y)\n const width = unwrapSignal(props.width)\n const height = unwrapSignal(props.height)\n const fill = unwrapSignal(props.fill)\n const stroke = unwrapSignal(props.stroke)\n const strokeWidth = unwrapSignal(props.strokeWidth)\n const opacity = unwrapSignal(props.opacity)\n\n ctx.save()\n\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fillRect(x, y, width, height)\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth || 1\n ctx.strokeRect(x, y, width, height)\n }\n\n ctx.restore()\n}\n\n/**\n * Render circle\n */\nfunction renderCircle(\n ctx: CanvasRenderingContext2D,\n props: DrawCircleProps\n): void {\n const x = unwrapSignal(props.x)\n const y = unwrapSignal(props.y)\n const radius = unwrapSignal(props.radius)\n const fill = unwrapSignal(props.fill)\n const stroke = unwrapSignal(props.stroke)\n const strokeWidth = unwrapSignal(props.strokeWidth)\n const opacity = unwrapSignal(props.opacity)\n\n ctx.save()\n\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n ctx.beginPath()\n ctx.arc(x, y, radius, 0, 2 * Math.PI)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill()\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth || 1\n ctx.stroke()\n }\n\n ctx.restore()\n}\n\n/**\n * Render path\n */\nfunction renderPath(ctx: CanvasRenderingContext2D, props: DrawPathProps): void {\n const d = unwrapSignal(props.d)\n const fill = unwrapSignal(props.fill)\n const stroke = unwrapSignal(props.stroke)\n const strokeWidth = unwrapSignal(props.strokeWidth)\n const opacity = unwrapSignal(props.opacity)\n\n ctx.save()\n\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n // Parse SVG path (simplified - only supports basic commands)\n const path = new Path2D(d)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill(path)\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth || 1\n ctx.stroke(path)\n }\n\n ctx.restore()\n}\n\n/**\n * Render text\n */\nfunction renderText(ctx: CanvasRenderingContext2D, props: DrawTextProps): void {\n const x = unwrapSignal(props.x)\n const y = unwrapSignal(props.y)\n const text = unwrapSignal(props.text)\n const fill = unwrapSignal(props.fill)\n const fontSize = unwrapSignal(props.fontSize) || 12\n const fontFamily = unwrapSignal(props.fontFamily) || 'sans-serif'\n const fontWeight = unwrapSignal(props.fontWeight) || 'normal'\n const textAlign = unwrapSignal(props.textAlign) || 'left'\n const textBaseline = unwrapSignal(props.textBaseline) || 'alphabetic'\n\n ctx.save()\n\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n ctx.textAlign = textAlign\n ctx.textBaseline = textBaseline\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fillText(text, x, y)\n }\n\n ctx.restore()\n}\n\n/**\n * Render line\n */\nfunction renderLine(ctx: CanvasRenderingContext2D, props: DrawLineProps): void {\n const x1 = unwrapSignal(props.x1)\n const y1 = unwrapSignal(props.y1)\n const x2 = unwrapSignal(props.x2)\n const y2 = unwrapSignal(props.y2)\n const stroke = unwrapSignal(props.stroke) || 'black'\n const strokeWidth = unwrapSignal(props.strokeWidth) || 1\n const opacity = unwrapSignal(props.opacity)\n\n ctx.save()\n\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n ctx.beginPath()\n ctx.moveTo(x1, y1)\n ctx.lineTo(x2, y2)\n\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth\n ctx.stroke()\n\n ctx.restore()\n}\n\n/**\n * Render arc\n */\nfunction renderArc(ctx: CanvasRenderingContext2D, props: DrawArcProps): void {\n const x = unwrapSignal(props.x)\n const y = unwrapSignal(props.y)\n const radius = unwrapSignal(props.radius)\n const startAngle = unwrapSignal(props.startAngle)\n const endAngle = unwrapSignal(props.endAngle)\n const counterclockwise = unwrapSignal(props.counterclockwise) || false\n const fill = unwrapSignal(props.fill)\n const stroke = unwrapSignal(props.stroke)\n const strokeWidth = unwrapSignal(props.strokeWidth)\n const opacity = unwrapSignal(props.opacity)\n\n ctx.save()\n\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n ctx.beginPath()\n ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill()\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth || 1\n ctx.stroke()\n }\n\n ctx.restore()\n}\n","/**\n * Canvas - Declarative canvas container with JSX drawing\n *\n * Supports Signal-based reactive rendering\n *\n * @example\n * ```tsx\n * const x = signal(50)\n *\n * <Canvas width={300} height={200}>\n * <Rect x={x} y={50} width={100} height={50} fill=\"blue\" />\n * <Circle x={150} y={100} radius={30} fill=\"red\" />\n * </Canvas>\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { CanvasProps } from '../types'\nimport { normalizeStyle } from '../utils'\nimport { renderCanvasChildren } from './renderer'\n\nexport function Canvas(props: CanvasProps): FNode {\n const { width, height, children, style, id, ...rest } = props\n\n return {\n type: 'canvas',\n props: {\n ...rest,\n id,\n width,\n height,\n style: normalizeStyle(style),\n // Attach canvas renderer when element is mounted\n ref: (canvas: HTMLCanvasElement | null) => {\n if (!canvas) return\n\n // SSR guard: skip canvas rendering on server\n if (typeof requestAnimationFrame === 'undefined') return\n\n const ctx = canvas.getContext('2d')\n if (!ctx) return\n\n // Render canvas children with effect for reactivity\n // Import effect and onCleanup dynamically to avoid circular deps\n import('../../core/signal')\n .then(({ effect, onCleanup, isSignal }) => {\n let rafId: number | undefined\n\n const scheduleRender = () => {\n if (rafId !== undefined) {\n cancelAnimationFrame(rafId)\n }\n\n rafId = requestAnimationFrame(() => {\n // Clear canvas\n ctx.clearRect(0, 0, width, height)\n\n // Render all children\n renderCanvasChildren(ctx, children, width, height)\n\n rafId = undefined\n })\n }\n\n effect(() => {\n // To track signal dependencies, we need to access them in the effect\n // Walk through children and touch any signals to track dependencies\n const childArray = Array.isArray(children) ? children : [children]\n for (const child of childArray) {\n if (child && child.props) {\n // Touch each prop to track signal dependencies\n for (const key in child.props) {\n const value = child.props[key]\n // If it's a signal, access its value to track it\n if (isSignal(value)) {\n void value.value // Touch the signal to track dependency\n }\n }\n }\n }\n\n // Now schedule the actual render\n scheduleRender()\n\n // Cleanup RAF when effect is disposed\n onCleanup(() => {\n if (rafId !== undefined) {\n cancelAnimationFrame(rafId)\n rafId = undefined\n }\n })\n })\n })\n .catch((err) => {\n console.error('[Flexium Canvas] Failed to load signal module:', err)\n })\n },\n },\n children: [],\n }\n}\n","/**\n * DrawRect - Canvas rectangle primitive\n *\n * @example\n * ```tsx\n * <DrawRect x={10} y={10} width={100} height={50} fill=\"blue\" />\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { DrawRectProps } from '../types'\n\nexport function DrawRect(props: DrawRectProps): FNode {\n return {\n type: 'canvas-rect',\n props,\n children: [],\n }\n}\n","/**\n * DrawCircle - Canvas circle primitive\n *\n * @example\n * ```tsx\n * <DrawCircle x={100} y={100} radius={50} fill=\"red\" />\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { DrawCircleProps } from '../types'\n\nexport function DrawCircle(props: DrawCircleProps): FNode {\n return {\n type: 'canvas-circle',\n props,\n children: [],\n }\n}\n","/**\n * DrawArc - Canvas arc primitive\n *\n * @example\n * ```tsx\n * <DrawArc x={100} y={100} radius={50} startAngle={0} endAngle={Math.PI} fill=\"green\" />\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { DrawArcProps } from '../types'\n\nexport function DrawArc(props: DrawArcProps): FNode {\n return {\n type: 'canvas-arc',\n props,\n children: [],\n }\n}\n","/**\n * DrawLine - Canvas line primitive\n *\n * @example\n * ```tsx\n * <DrawLine x1={10} y1={10} x2={100} y2={100} stroke=\"black\" strokeWidth={2} />\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { DrawLineProps } from '../types'\n\nexport function DrawLine(props: DrawLineProps): FNode {\n return {\n type: 'canvas-line',\n props,\n children: [],\n }\n}\n","/**\n * DrawPath - Canvas path primitive\n *\n * @example\n * ```tsx\n * <DrawPath d=\"M 10 10 L 100 100\" stroke=\"black\" strokeWidth={2} />\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { DrawPathProps } from '../types'\n\nexport function DrawPath(props: DrawPathProps): FNode {\n return {\n type: 'canvas-path',\n props,\n children: [],\n }\n}\n","/**\n * DrawText - Canvas text primitive\n *\n * @example\n * ```tsx\n * <DrawText x={50} y={50} text=\"Hello Canvas\" fontSize={20} fill=\"black\" />\n * ```\n */\n\nimport type { FNode } from '../../types'\nimport type { DrawTextProps } from '../types'\n\nexport function DrawText(props: DrawTextProps): FNode {\n return {\n type: 'canvas-text',\n props,\n children: [],\n }\n}\n"]}
|
package/dist/chunk-M4ANLZ6P.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkDFG62GKW_js=require('./chunk-DFG62GKW.js'),chunkQ7IWDVJ4_js=require('./chunk-Q7IWDVJ4.js'),chunkYGMMJWAA_js=require('./chunk-YGMMJWAA.js');function F(){let t=()=>({pathname:"/",search:"",hash:"",query:{}}),e=()=>typeof window>"u"?t():{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,query:$(window.location.search)},r=chunkYGMMJWAA_js.j(e()),n=c=>{if(!(typeof window>"u")){if(N(c)){console.error("[Flexium Router] Blocked navigation to unsafe path:",c);return}window.history.pushState({},"",c),r.value=e();}},a=()=>{try{r.value=e();}catch(c){console.error("[Flexium Router] Error handling popstate:",c);}};return typeof window<"u"&&window.addEventListener("popstate",a),[r,n,()=>{typeof window<"u"&&window.removeEventListener("popstate",a);}]}function N(t){let e=t.trim().toLowerCase();return ["javascript:","data:","vbscript:","file:"].some(n=>e.startsWith(n))}function j(t){return t.replace(/<[^>]*>/g,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"")}var O=new Set(["__proto__","constructor","prototype"]);function $(t){let e=new URLSearchParams(t),r=Object.create(null);return e.forEach((n,a)=>{let i=j(a),c=j(n);i&&!O.has(i)&&(r[i]=c);}),r}function B(t,e){let r=[],n=e.replace(/:([^/]+)/g,(l,h)=>(r.push(h),"([^/]+)")),a=new RegExp(`^${n}$`),i=t.match(a);if(!i)return {matches:false,params:{}};let c={};return i.slice(1).forEach((l,h)=>{c[r[h]]=l;}),{matches:true,params:c}}function k(t){let e=[],r=Array.isArray(t)?t:[t];for(let n of r){if(!chunkQ7IWDVJ4_js.c(n))continue;let{path:a,index:i,component:c,beforeEnter:l}=n.props,h=n.children;if(!c&&!h){console.warn(`[Flexium Router] Route "${a||"(index)"}" has no component and no children. Skipping.`);continue}let R={path:a||"",index:!!i,component:c||(()=>null),children:h?k(h):[],beforeEnter:l};e.push(R);}return e}function D(t,e){for(let r of t){let n=S(r,e,"");if(n)return n}return null}function S(t,e,r){let n=r;t.path&&(n=r.replace(/\/$/,"")+"/"+t.path.replace(/^\//,""));let a=t.children.length===0,i=A(n,!a),c=e.match(i);if(c){let[l,...h]=c,R=M(n,h),o={route:t,params:R,pathname:l};if(a)return l===e?[o]:null;for(let f of t.children){let u=S(f,e,n);if(u)return [o,...u]}if(l===e){let f=t.children.find(u=>u.index);return f?[o,{route:f,params:{},pathname:l}]:[o]}}return null}function A(t,e){let r=t.replace(/:([^/]+)/g,()=>"([^/]+)");return r==="/"&&e?new RegExp("^"):new RegExp(`^${r}${e?"(?:/|$)":"$"}`)}function M(t,e){let r={},n=0;return t.replace(/:([^/]+)/g,(a,i)=>(r[i]=e[n++],"")),r}var v=chunkDFG62GKW_js.a(null),y=chunkDFG62GKW_js.a(0);function V(){let t=chunkDFG62GKW_js.b(v);if(!t)throw new Error("router() must be called within a <Router> component");return t}function et(t){let[e,r]=F(),n=Array.isArray(t.children)?t.children:[t.children],a=[],i=[];for(let o of n)chunkQ7IWDVJ4_js.c(o)&&typeof o.type=="function"&&o.type===z?i.push(o):a.push(o);let c=k(i),l=chunkYGMMJWAA_js.k(()=>{let o=e();return D(c,o.pathname)||[]}),h=chunkYGMMJWAA_js.k(()=>{let o=l();return o.length>0?o[o.length-1].params:{}}),R=new Proxy({location:e,params:h,navigate:r,matches:l},{get(o,f){let u=o[f];if(f==="location"||f==="params"||f==="matches"){let p=u,_=()=>p.value;return new Proxy(_,{apply(){return p.value},get(b,s){if(s==="value")return p.value;if(s==="peek")return p.peek;if(s===Symbol.toPrimitive||s==="toString"||s==="valueOf")return ()=>p.value;let d=p[s];if(typeof d=="function")return d.bind(p);let g=p.value;if(g!==null&&typeof g=="object"){let C=g[s];return typeof C=="function"?C.bind(g):C}return d},has(b,s){if(s==="value"||s==="peek")return true;let d=p.value;return d!==null&&typeof d=="object"?s in d:s in p},ownKeys(b){let s=p.value;return s!==null&&typeof s=="object"?Reflect.ownKeys(s):[]},getOwnPropertyDescriptor(b,s){let d=p.value;if(d!==null&&typeof d=="object"){let g=Object.getOwnPropertyDescriptor(d,s);if(g)return {...g,configurable:true}}}})}return u}});return ()=>{let o=l(),f=null;if(o.length>0){let u=o[0];u.route.beforeEnter?u.route.beforeEnter(u.params)!==false&&(f=chunkQ7IWDVJ4_js.a(y.Provider,{value:1},[chunkQ7IWDVJ4_js.a("div",{key:u.route.path,style:{display:"contents"}},[chunkQ7IWDVJ4_js.a(u.route.component,{params:u.params})])])):f=chunkQ7IWDVJ4_js.a(y.Provider,{value:1},[chunkQ7IWDVJ4_js.a("div",{key:u.route.path,style:{display:"contents"}},[chunkQ7IWDVJ4_js.a(u.route.component,{params:u.params})])]);}return chunkQ7IWDVJ4_js.a(v.Provider,{value:R},[...a,chunkQ7IWDVJ4_js.a("main",{id:"main"},[f])])}}function z(t){return null}function nt(){let t=chunkDFG62GKW_js.b(v),e=chunkDFG62GKW_js.b(y);return t?()=>{let r=t.matches();if(e>=r.length)return null;let n=r[e];if(n.route.beforeEnter&&n.route.beforeEnter(n.params)===false)return null;let a=n.route.component;return chunkQ7IWDVJ4_js.a(y.Provider,{value:e+1},[chunkQ7IWDVJ4_js.a(a,{params:n.params})])}:null}function rt(t){let e=V(),r=n=>{n.preventDefault(),e.navigate(t.to);};return chunkQ7IWDVJ4_js.a("a",{href:t.to,class:t.class,onclick:r},t.children)}
|
|
2
|
-
exports.a=F;exports.b=N;exports.c=j;exports.d=B;exports.e=k;exports.f=D;exports.g=V;exports.h=et;exports.i=z;exports.j=nt;exports.k=rt;//# sourceMappingURL=chunk-M4ANLZ6P.js.map
|
|
3
|
-
//# sourceMappingURL=chunk-M4ANLZ6P.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/core.ts","../src/router/utils.ts","../src/router/context.ts","../src/router/components.ts"],"names":["createLocation","getDefaultLoc","getLoc","parseQuery","loc","signal","navigate","path","isUnsafePath","handlePopState","error","normalizedPath","protocol","sanitizeQueryValue","value","DANGEROUS_KEYS","search","params","query","key","sanitizedKey","sanitizedValue","matchPath","pathname","routePath","paramNames","regexPath","_","paramName","regex","match","index","createRoutesFromChildren","children","routes","childArray","child","isFNode","component","beforeEnter","nestedChildren","route","matchRoutes","location","result","matchRouteBranch","parentPath","fullPath","isLeaf","matcher","compilePath","matchedPath","paramValues","paramsObj","extractParams","currentMatch","childMatches","indexRoute","c","prefix","values","i","RouterCtx","createContext","RouteDepthCtx","router","ctx","context","Router","props","nonRouteChildren","routeChildren","Route","matches","computed","m","routerContext","target","prop","_target","innerProp","signalProp","currentValue","objProp","desc","ms","matchedContent","rootMatch","f","_props","Outlet","depth","Component","Link","r","handleClick","e"],"mappings":"iKA8BO,SAASA,CAAAA,EAAyE,CAEvF,IAAMC,CAAAA,CAAgB,KAAiB,CACrC,QAAA,CAAU,GAAA,CACV,MAAA,CAAQ,EAAA,CACR,IAAA,CAAM,EAAA,CACN,KAAA,CAAO,EACT,CAAA,CAAA,CAEMC,CAAAA,CAAS,IACT,OAAO,MAAA,CAAW,GAAA,CACbD,CAAAA,GAEF,CACL,QAAA,CAAU,MAAA,CAAO,QAAA,CAAS,QAAA,CAC1B,MAAA,CAAQ,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BtB,CAEO,SAAS+D,EAAAA,CAAKxB,CAAAA,CAAkB,CACrC,IAAMyB,CAAAA,CAAI7B,GAAO,CAEX8B,CAAAA,CAAeC,CAAAA,EAAa,CAChCA,CAAAA,CAAE,cAAA,EAAe,CACjBF,CAAAA,CAAE,SAASzB,CAAAA,CAAM,EAAE,EACrB,CAAA,CAEA,OAAOmB,kBAAAA,CACL,GAAA,CACA,CACE,KAAMnB,CAAAA,CAAM,EAAA,CACZ,KAAA,CAAOA,CAAAA,CAAM,MACb,OAAA,CAAS0B,CACX,CAAA,CACA1B,CAAAA,CAAM,QACR,CACF","file":"chunk-M4ANLZ6P.js","sourcesContent":["/**\n * Router Core Module\n *\n * Provides core routing functionality including location management,\n * path matching, and navigation.\n */\n\nimport { signal, Signal } from '../core/signal'\nimport { Location } from './types'\n\n/**\n * Creates a reactive location signal and navigate function.\n *\n * The location signal automatically updates when:\n * - navigate() is called\n * - Browser back/forward buttons are used (popstate event)\n *\n * @returns Tuple of [location signal, navigate function, cleanup function]\n *\n * @example\n * ```tsx\n * const [location, navigate, cleanup] = createLocation();\n * // Access current path\n * console.log(location().pathname);\n * // Navigate to new path\n * navigate('/users/123');\n * // Cleanup when done (removes popstate listener)\n * cleanup();\n * ```\n */\nexport function createLocation(): [Signal<Location>, (path: string) => void, () => void] {\n // SSR guard: return safe defaults on server\n const getDefaultLoc = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n })\n\n const getLoc = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLoc()\n }\n return {\n pathname: window.location.pathname,\n search: window.location.search,\n hash: window.location.hash,\n query: parseQuery(window.location.search),\n }\n }\n\n const loc = signal(getLoc())\n\n const navigate = (path: string) => {\n // SSR guard\n if (typeof window === 'undefined') return\n\n // Security: Validate path to prevent javascript: and other dangerous protocols\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n loc.value = getLoc()\n }\n\n // SSR guard for popstate listener\n const handlePopState = () => {\n try {\n loc.value = getLoc()\n } catch (error) {\n console.error('[Flexium Router] Error handling popstate:', error)\n }\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('popstate', handlePopState)\n }\n\n // Cleanup function to remove listener\n const cleanup = () => {\n if (typeof window !== 'undefined') {\n window.removeEventListener('popstate', handlePopState)\n }\n }\n\n return [loc, navigate, cleanup]\n}\n\n/**\n * Check if a path contains unsafe protocols (XSS prevention)\n * @param path - Path to validate\n * @returns true if path is unsafe\n */\nexport function isUnsafePath(path: string): boolean {\n const normalizedPath = path.trim().toLowerCase()\n const unsafeProtocols = ['javascript:', 'data:', 'vbscript:', 'file:']\n return unsafeProtocols.some(protocol => normalizedPath.startsWith(protocol))\n}\n\n/**\n * Sanitize query parameter value to prevent XSS\n * @param value - Query parameter value\n * @returns Sanitized value\n */\nexport function sanitizeQueryValue(value: string): string {\n // Remove potential script tags and event handlers\n return value\n .replace(/<[^>]*>/g, '') // Remove HTML tags\n .replace(/javascript:/gi, '') // Remove javascript: protocol\n .replace(/on\\w+\\s*=/gi, '') // Remove event handlers like onclick=\n}\n\n/**\n * Parses URL search string into key-value object\n * @param search - URL search string (e.g., \"?foo=bar&baz=qux\")\n * @returns Object with query parameters\n */\n// Dangerous keys that could lead to prototype pollution\nconst DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype'])\n\nfunction parseQuery(search: string): Record<string, string> {\n const params = new URLSearchParams(search)\n // Use Object.create(null) to prevent prototype pollution\n const query: Record<string, string> = Object.create(null)\n params.forEach((value, key) => {\n // Sanitize both key and value to prevent XSS\n const sanitizedKey = sanitizeQueryValue(key)\n const sanitizedValue = sanitizeQueryValue(value)\n // Block dangerous keys to prevent prototype pollution\n if (sanitizedKey && !DANGEROUS_KEYS.has(sanitizedKey)) {\n query[sanitizedKey] = sanitizedValue\n }\n })\n return query\n}\n\n/**\n * Matches a pathname against a route pattern.\n *\n * Supports dynamic segments with `:param` syntax.\n *\n * @param pathname - Current URL pathname (e.g., \"/users/123\")\n * @param routePath - Route pattern (e.g., \"/users/:id\")\n * @returns Object with `matches` boolean and extracted `params`\n *\n * @example\n * ```tsx\n * const result = matchPath('/users/123', '/users/:id');\n * // { matches: true, params: { id: '123' } }\n * ```\n */\nexport function matchPath(\n pathname: string,\n routePath: string\n): { matches: boolean; params: Record<string, string> } {\n const paramNames: string[] = []\n const regexPath = routePath.replace(/:([^/]+)/g, (_, paramName) => {\n paramNames.push(paramName)\n return '([^/]+)'\n })\n\n const regex = new RegExp(`^${regexPath}$`)\n const match = pathname.match(regex)\n\n if (!match) {\n return { matches: false, params: {} }\n }\n\n const params: Record<string, string> = {}\n match.slice(1).forEach((value, index) => {\n params[paramNames[index]] = value\n })\n\n return { matches: true, params }\n}\n","import { RouteDef, RouteMatch } from './types'\nimport type { FNodeChild } from '../core/renderer'\nimport { isFNode } from '../renderers/dom/f'\n\n/**\n * Flatten the children of <Router> or <Route> into a route configuration tree.\n * Note: This assumes `children` are FNodes representing <Route> components.\n */\nexport function createRoutesFromChildren(children: FNodeChild): RouteDef[] {\n const routes: RouteDef[] = []\n\n const childArray = Array.isArray(children) ? children : [children]\n\n for (const child of childArray) {\n if (!isFNode(child)) {\n continue\n }\n\n const { path, index, component, beforeEnter } = child.props as {\n path?: string\n index?: boolean\n component?: Function\n beforeEnter?: (\n params: Record<string, string>\n ) => boolean | Promise<boolean>\n }\n const nestedChildren = child.children\n\n // Skip routes without a component (unless they have children as layout routes)\n if (!component && !nestedChildren) {\n console.warn(\n `[Flexium Router] Route \"${path || '(index)'}\" has no component and no children. Skipping.`\n )\n continue\n }\n\n const route: RouteDef = {\n path: path || '',\n index: !!index,\n component: component || (() => null),\n children: nestedChildren ? createRoutesFromChildren(nestedChildren) : [],\n beforeEnter,\n }\n\n routes.push(route)\n }\n\n return routes\n}\n\n/**\n * Match a URL against a route tree.\n * Returns an array of matches (from root to leaf).\n */\nexport function matchRoutes(\n routes: RouteDef[],\n location: string\n): RouteMatch[] | null {\n for (const route of routes) {\n const result = matchRouteBranch(route, location, '')\n if (result) return result\n }\n return null\n}\n\nfunction matchRouteBranch(\n route: RouteDef,\n location: string,\n parentPath: string\n): RouteMatch[] | null {\n let fullPath = parentPath\n if (route.path) {\n fullPath =\n parentPath.replace(/\\/$/, '') + '/' + route.path.replace(/^\\//, '')\n }\n\n const isLeaf = route.children.length === 0\n const matcher = compilePath(fullPath, !isLeaf)\n const match = location.match(matcher)\n\n if (match) {\n const [matchedPath, ...paramValues] = match\n const paramsObj = extractParams(fullPath, paramValues)\n\n const currentMatch: RouteMatch = {\n route,\n params: paramsObj,\n pathname: matchedPath,\n }\n\n if (isLeaf) {\n // Exact match required for leaf\n if (matchedPath === location) return [currentMatch]\n return null\n }\n\n // Has children: try to match one of them\n // If no children match, and this route is an index route?\n // Or if this route matches partially, maybe an index child matches the rest?\n\n for (const child of route.children) {\n const childMatches = matchRouteBranch(child, location, fullPath)\n if (childMatches) {\n return [currentMatch, ...childMatches]\n }\n }\n\n // If no children matched, but we matched exactly this layout route?\n // E.g. /users matches /users layout, and maybe it renders index?\n if (matchedPath === location) {\n // Check for index route\n const indexRoute = route.children.find((c) => c.index)\n if (indexRoute) {\n return [\n currentMatch,\n { route: indexRoute, params: {}, pathname: matchedPath },\n ]\n }\n // Just the layout? Maybe.\n return [currentMatch]\n }\n }\n\n return null\n}\n\nfunction compilePath(path: string, prefix: boolean): RegExp {\n const regexPath = path.replace(/:([^/]+)/g, () => '([^/]+)')\n\n // If path is exactly \"/\", and we want prefix matching, it should match everything\n if (regexPath === '/' && prefix) {\n return new RegExp('^')\n }\n\n // If prefix matching allowed, ensure we match segment boundary\n return new RegExp(`^${regexPath}${prefix ? '(?:/|$)' : '$'}`)\n}\n\nfunction extractParams(path: string, values: string[]): Record<string, string> {\n const params: Record<string, string> = {}\n let i = 0\n // Re-parse to find param names... inefficient but works\n path.replace(/:([^/]+)/g, (_, paramName) => {\n params[paramName] = values[i++]\n return ''\n })\n return params\n}\n","import { createContext } from '../core/context'\nimport { RouterContext } from './types'\n\n// Global Router Context\nexport const RouterCtx = createContext<RouterContext | null>(null)\n\n// Current Route Depth Context (for Outlet)\n// Stores the index of the current match in the `matches` array\nexport const RouteDepthCtx = createContext<number>(0)\n","import { computed, type Signal, type Computed } from '../core/signal'\nimport { createLocation } from './core'\nimport { createRoutesFromChildren, matchRoutes } from './utils'\nimport { LinkProps, RouteProps, RouterContext } from './types'\nimport { f, isFNode } from '../renderers/dom/f'\nimport { RouterCtx, RouteDepthCtx } from './context'\nimport { context } from '../core/context'\nimport type { FNodeChild } from '../core/renderer'\n\n/**\n * Get the current router context.\n * Must be called within a <Router> component.\n *\n * @example\n * ```tsx\n * const r = router()\n * r.navigate('/dashboard')\n * ```\n */\nexport function router(): RouterContext {\n const ctx = context(RouterCtx)\n if (!ctx) {\n throw new Error('router() must be called within a <Router> component')\n }\n return ctx\n}\n\nexport function Router(props: { children: FNodeChild }) {\n const [location, navigate] = createLocation()\n\n // Separate Route children from non-Route children (like Nav, etc.)\n const childArray = Array.isArray(props.children) ? props.children : [props.children]\n const nonRouteChildren: FNodeChild[] = []\n const routeChildren: FNodeChild[] = []\n\n for (const child of childArray) {\n if (isFNode(child) && typeof child.type === 'function' && child.type === Route) {\n routeChildren.push(child)\n } else {\n nonRouteChildren.push(child)\n }\n }\n\n // Parse route configuration from Route children only\n const routes = createRoutesFromChildren(routeChildren)\n\n // Compute matches\n const matches = computed(() => {\n const loc = location()\n return matchRoutes(routes, loc.pathname) || []\n })\n\n const params = computed(() => {\n const m = matches()\n if (m.length > 0) {\n return m[m.length - 1].params\n }\n return {}\n })\n\n // Create routerContext as a stable object\n // The signals (location, params, matches) are already reactive\n // We create a proxy to ensure property access is properly tracked\n // When accessing location, params, or matches, automatically read the signal's value\n // to register subscriptions (similar to how state() proxy works)\n const routerContext: RouterContext = new Proxy({\n location,\n params,\n navigate,\n matches,\n }, {\n get(target, prop) {\n const value = target[prop as keyof RouterContext]\n \n // For signal/computed properties (location, params, matches),\n // return a proxy that automatically reads the signal's value when properties are accessed\n // This makes router() work like state() - property access triggers tracking\n if (prop === 'location' || prop === 'params' || prop === 'matches') {\n const signal = value as Signal<unknown> | Computed<unknown>\n \n // Create a callable target function (like state proxy does)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const target = () => signal.value\n \n // Return a proxy that wraps the signal and automatically reads its value\n // when properties are accessed, ensuring subscriptions are registered\n // This follows the same pattern as state() proxy for consistency\n return new Proxy(target, {\n // Make the proxy callable - returns current value\n apply() {\n return signal.value\n },\n \n get(_target, innerProp) {\n // Accessing .value triggers subscription registration via signal's value getter\n if (innerProp === 'value') {\n return signal.value\n }\n \n // Allow direct access to peek() without tracking\n if (innerProp === 'peek') {\n return signal.peek\n }\n \n // Calling as function also triggers subscription\n if (innerProp === Symbol.toPrimitive || innerProp === 'toString' || innerProp === 'valueOf') {\n return () => signal.value\n }\n \n // For other signal properties (set, etc.), access them normally\n const signalProp = (signal as any)[innerProp]\n if (typeof signalProp === 'function') {\n return signalProp.bind(signal)\n }\n \n // If the signal's value is an object, access its properties\n // This enables r.location.pathname and r.params.id to work and register subscriptions\n // Note: accessing signal.value here tracks the signal in any enclosing effect\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n const obj = currentValue as Record<string | symbol, unknown>\n const objProp = obj[innerProp]\n // If it's a function (like array methods), bind it to the current value\n if (typeof objProp === 'function') {\n return objProp.bind(currentValue)\n }\n return objProp\n }\n \n return signalProp\n },\n \n // For property checks (like 'id' in params)\n has(_target, innerProp) {\n if (innerProp === 'value' || innerProp === 'peek') return true\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n return innerProp in (currentValue as object)\n }\n return innerProp in signal\n },\n \n // For Object.keys, for...in loops\n ownKeys(_target) {\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n return Reflect.ownKeys(currentValue as object)\n }\n return []\n },\n \n getOwnPropertyDescriptor(_target, innerProp) {\n const currentValue = signal.value\n if (currentValue !== null && typeof currentValue === 'object') {\n const desc = Object.getOwnPropertyDescriptor(currentValue as object, innerProp)\n if (desc) {\n return { ...desc, configurable: true }\n }\n }\n return undefined\n }\n })\n }\n \n // For navigate, return as-is\n return value\n }\n }) as RouterContext\n\n return () => {\n const ms = matches()\n\n // Matched route component (or null if no match)\n let matchedContent: FNodeChild = null\n if (ms.length > 0) {\n const rootMatch = ms[0]\n\n // Check beforeEnter guard\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, { value: 1 }, [\n f('div', { key: rootMatch.route.path, style: { display: 'contents' } }, [\n f(rootMatch.route.component, { params: rootMatch.params }),\n ]),\n ])\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, { value: 1 }, [\n f('div', { key: rootMatch.route.path, style: { display: 'contents' } }, [\n f(rootMatch.route.component, { params: rootMatch.params }),\n ]),\n ])\n }\n }\n\n // Render non-Route children (like Nav) and the matched route wrapped in main\n return f(RouterCtx.Provider, { value: routerContext }, [\n ...nonRouteChildren,\n f('main', { id: 'main' }, [matchedContent]),\n ])\n }\n}\n\n/**\n * Route configuration component.\n * Doesn't render anything directly; used by Router to build the route tree.\n */\nexport function Route(_props: RouteProps) {\n return null\n}\n\n/**\n * Renders the child route content.\n */\nexport function Outlet() {\n const router = context(RouterCtx)\n const depth = context(RouteDepthCtx) // Default 0\n\n // Safety check\n if (!router) return null\n\n return () => {\n const ms = router.matches()\n\n // Check if we have a match at this depth\n if (depth >= ms.length) return null\n\n const match = ms[depth]\n\n // Check beforeEnter guard\n if (match.route.beforeEnter) {\n const result = match.route.beforeEnter(match.params)\n if (result === false) return null\n }\n\n const Component = match.route.component\n\n // Render component and provide next depth\n return f(RouteDepthCtx.Provider, { value: depth + 1 }, [\n f(Component, { params: match.params }),\n ])\n }\n}\n\nexport function Link(props: LinkProps) {\n const r = router()\n\n const handleClick = (e: Event) => {\n e.preventDefault()\n r.navigate(props.to)\n }\n\n return f(\n 'a',\n {\n href: props.to,\n class: props.class,\n onclick: handleClick,\n },\n props.children\n )\n}\n"]}
|
package/dist/chunk-RDA77IE6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkYGMMJWAA_js=require('./chunk-YGMMJWAA.js');var P=Symbol.for("flexium.stateSignal");function K(e,r){let o=e;return o._signal=e,o._stateActions=r,o}function N(e){return {value:void 0,peek:e.peek,_signal:e,_isComputed:true}}function M(e){let r=e;return r._signal=e,r}var c=new Map,W=1e4,j=false,k=null;function G(e){k=e;}function H(){return {id:Symbol("component"),hookIndex:0,hooks:[]}}function J(e){e.hookIndex=0;}var z=new WeakMap;function R(e){if(typeof e=="string")return e;let r=z.get(e);if(r!==void 0)return r;try{let o=JSON.stringify(e);return z.set(e,o),o}catch(o){return console.warn("[Flexium] Failed to serialize state key, using fallback:",o),String(e)}}function w(){typeof process<"u"&&process.env?.NODE_ENV!=="production"&&!j&&c.size>=W&&(j=true,console.warn(`[Flexium] Global state registry has ${c.size} entries. Consider using state.delete(key) to clean up unused states, or state.clear() to reset all global states.`));}function I(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&P in e}function B(e){return I(e)?e[P]:null}function U(e,r){return I(e)?e.peek()===r:false}function q(e){return I(e)?!!e.peek():false}var E=new WeakMap,D=new WeakMap;function d(e){let r=E.get(e);if(r)return r;let o=()=>e.value,b="peek",p="valueOf",V="toString",v="toJSON",O=Symbol.toPrimitive;typeof process<"u"&&process.env?.NODE_ENV!=="production"&&typeof process<"u"&&process.env?.FLEXIUM_WARN_COMPARISON==="true";let m=new Proxy(o,{apply(){return e.value},get(i,n){if(n===P)return e;if(n===b)return e.peek;let t=e.value;if(t===null)return n===O?()=>null:n===p?()=>null:n===V?()=>"null":n===v?()=>null:void 0;if(typeof t=="object"){if(n===O)return f=>t;if(n===p)return ()=>t;if(n===V)return ()=>String(t);if(n===v)return ()=>t;let s=t[n];if(typeof s=="function"){let f=D.get(s);f||(f=new WeakMap,D.set(s,f));let y=f.get(t);return y||(y=s.bind(t),f.set(t,y)),y}return s}if(n===O)return S=>t;if(n===p)return ()=>t;if(n===V)return ()=>String(t);if(n===v)return ()=>t},has(i,n){if(n===P)return true;let t=e.value;return t===null?false:typeof t=="object"&&n in t},ownKeys(i){let n=e.value;return n===null?[]:typeof n=="object"?Reflect.ownKeys(n):[]},getOwnPropertyDescriptor(i,n){if(n===P)return {configurable:true,enumerable:false,value:e};let t=e.value;if(t!==null&&typeof t=="object"){let l=Object.getOwnPropertyDescriptor(t,n);if(l)return {...l,configurable:true}}}});return E.set(e,m),m}function g(e,r){let o=r?.key?R(r.key):void 0,b=r?.params;if(k&&!o){let a=k,u=a.hookIndex++;if(u<a.hooks.length)return a.hooks[u];let m=k;k=null;let i=g(e,r);return k=m,a.hooks.push(i),i}if(o&&c.has(o)){let a=c.get(o),u="loading"in a&&a._stateActions?.refetch!==void 0,m=a._isComputed,i=d(a._signal);if(m)return [i];if(u){let t=a._stateActions?.refetch||(()=>{}),l=chunkYGMMJWAA_js.k(()=>a.error?"error":a.loading?"loading":a.value!==void 0?"success":"idle"),S=chunkYGMMJWAA_js.k(()=>a.error),s=d(l),f=d(S);return [i,t,s,f]}return [i,t=>{typeof t=="function"?a.value=t(a.peek()):a.value=t;}]}if(typeof e=="function"){let a=e,u=b!==void 0?()=>a(b):a;if(a.constructor.name==="AsyncFunction"){let[l,S]=chunkYGMMJWAA_js.n(u,async _=>_),s=K(l,S);o&&(c.set(o,s),w());let f=d(s._signal),y=chunkYGMMJWAA_js.k(()=>s.error?"error":s.loading?"loading":s.value!==void 0?"success":"idle"),h=chunkYGMMJWAA_js.k(()=>s.error),A=d(y),C=d(h);return [f,S.refetch,A,C]}let i;try{i=u();}catch{let l=chunkYGMMJWAA_js.k(u),S=N(l);return o&&(c.set(o,S),w()),[d(l)]}if(i instanceof Promise){let[l,S]=chunkYGMMJWAA_js.n(u,async _=>_),s=K(l,S);o&&(c.set(o,s),w());let f=d(s._signal),y=chunkYGMMJWAA_js.k(()=>s.error?"error":s.loading?"loading":s.value!==void 0?"success":"idle"),h=chunkYGMMJWAA_js.k(()=>s.error),A=d(y),C=d(h);return [f,S.refetch,A,C]}let n=chunkYGMMJWAA_js.k(u),t=N(n);return o&&(c.set(o,t),w()),[d(n)]}let p=chunkYGMMJWAA_js.j(e),V=M(p);return o&&(c.set(o,V),w()),[d(p),a=>{typeof a=="function"?p.value=a(p.peek()):p.value=a;}]}g.delete=function(e){let r=R(e);return c.delete(r)};g.clear=function(){c.clear(),j=false;};g.has=function(e){let r=R(e);return c.has(r)};Object.defineProperty(g,"size",{get:()=>c.size,enumerable:true});var X=g;function Y(e){return {current:e}}exports.a=G;exports.b=H;exports.c=J;exports.d=I;exports.e=B;exports.f=U;exports.g=q;exports.h=X;exports.i=Y;//# sourceMappingURL=chunk-RDA77IE6.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-RDA77IE6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/state.ts"],"names":["STATE_SIGNAL","toStateObject","res","actions","s","toComputedStateObject","comp","toSignalStateObject","sig","globalStateRegistry","DEV_WARNING_THRESHOLD","hasWarnedAboutSize","currentComponent","setCurrentComponent","instance","createComponentInstance","resetHookIndex","keyCache","serializeKey","key","cached","serialized","error","checkRegistrySize","isStateValue","value","getStateSignal","stateValue","equals","isTruthy","proxyCache","boundFunctionCache","createStateProxy","target","PEEK_PROP","VALUE_OF_PROP","TO_STRING_PROP","TO_JSON_PROP","TO_PRIMITIVE_SYMBOL","proxy","_target","prop","currentValue","_hint","propValue","functionCache","bound","desc","state","initialValueOrFetcher","options","params","hookIndex","savedComponent","result","isAsync","isComputed","refetch","statusComputed","computed","errorComputed","statusValue","errorValue","newValue","originalFn","fn","resActions","createResource","val","testResult","signal","serializedKey","_state","ref","initialValue"],"mappings":"iEAMO,IAAMA,CAAAA,CAAe,MAAA,CAAO,GAAA,CAAI,qBAAqB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,CAAA,CAGD,IAAM+D,CAAAA,CAASxB,EAmCR,SAASyB,CAAAA,CAAOC,CAAAA,CAAsC,CAC3D,OAAO,CAAE,OAAA,CAASA,CAAa,CACjC","file":"chunk-RDA77IE6.js","sourcesContent":["import { signal, computed, createResource } from './signal'\nimport type { Signal, Computed, Resource } from './signal'\n\n/** Symbol to identify StateProxy and access underlying signal */\n// Use Symbol.for() to ensure the symbol is shared across module boundaries\n// This is important for Vite dev mode where modules may be loaded separately\nexport const STATE_SIGNAL = Symbol.for('flexium.stateSignal')\n\n/** Internal state object that may be a Signal, Computed, or Resource */\ninterface StateObject {\n value: unknown\n peek: () => unknown\n loading?: boolean\n error?: unknown\n state?: 'unresolved' | 'pending' | 'ready' | 'refreshing' | 'errored'\n latest?: unknown\n\n _stateActions?: StateActions\n _signal?: Signal<unknown> | Computed<unknown> | Resource<unknown>\n _isComputed?: boolean\n}\n\n/** Actions available for state mutation */\ninterface StateActions {\n mutate?: (value: unknown) => void\n refetch?: () => void\n}\n\n/**\n * Type-safe helper to wrap Resource as StateObject.\n * Consolidates unsafe type assertions in one place.\n * @internal\n */\nfunction toStateObject<T>(\n res: Resource<T>,\n actions: { mutate: (v: T | undefined) => void; refetch: () => void }\n): StateObject {\n const s = res as unknown as StateObject\n s._signal = res as Resource<unknown>\n s._stateActions = actions as StateActions\n return s\n}\n\n/**\n * Type-safe helper to create a computed StateObject.\n * @internal\n */\nfunction toComputedStateObject<T>(comp: Computed<T>): StateObject {\n return {\n value: undefined,\n peek: comp.peek,\n _signal: comp as Computed<unknown>,\n _isComputed: true,\n }\n}\n\n/**\n * Type-safe helper to wrap Signal as StateObject.\n * @internal\n */\nfunction toSignalStateObject<T>(sig: Signal<T>): StateObject {\n const s = sig as unknown as StateObject\n s._signal = sig as Signal<unknown>\n return s\n}\n\n// Global registry for keyed states\nconst globalStateRegistry = new Map<string, StateObject>()\n\n// Dev mode warning thresholds\nconst DEV_WARNING_THRESHOLD = 10000\nlet hasWarnedAboutSize = false\n\n// ============================================================================\n// Component Hook System - enables state() inside components\n// ============================================================================\n\ninterface ComponentInstance {\n id: symbol\n hookIndex: number\n hooks: unknown[]\n}\n\nlet currentComponent: ComponentInstance | null = null\n\n/**\n * Set the current component context for hook tracking.\n * Called by the renderer before executing a component function.\n * @internal\n */\nexport function setCurrentComponent(instance: ComponentInstance | null): void {\n currentComponent = instance\n}\n\n/**\n * Get the current component context.\n * @internal\n */\nexport function getCurrentComponent(): ComponentInstance | null {\n return currentComponent\n}\n\n/**\n * Create a new component instance for hook tracking.\n * @internal\n */\nexport function createComponentInstance(): ComponentInstance {\n return {\n id: Symbol('component'),\n hookIndex: 0,\n hooks: [],\n }\n}\n\n/**\n * Reset hook index for re-renders.\n * @internal\n */\nexport function resetHookIndex(instance: ComponentInstance): void {\n instance.hookIndex = 0\n}\n\n/** Key type - string or array of serializable values */\nexport type StateKey = string | readonly (string | number | boolean | null | undefined | object)[]\n\n// Cache for array key serialization to avoid repeated JSON.stringify calls\nconst keyCache = new WeakMap<readonly unknown[], string>()\n\n/**\n * Serialize a key to a string for registry lookup.\n * Arrays are JSON-stringified for consistent comparison.\n * Uses WeakMap cache to avoid repeated serialization of array keys.\n */\nfunction serializeKey(key: StateKey): string {\n if (typeof key === 'string') {\n return key\n }\n\n // Check cache first for array keys\n const cached = keyCache.get(key)\n if (cached !== undefined) {\n return cached\n }\n\n try {\n const serialized = JSON.stringify(key)\n keyCache.set(key, serialized)\n return serialized\n } catch (error) {\n // Handle circular references or other serialization errors\n console.warn('[Flexium] Failed to serialize state key, using fallback:', error)\n const fallback = String(key)\n return fallback\n }\n}\n\n/**\n * Check global state registry size and warn in development mode.\n * Does not enforce hard limits - use state.delete() or state.clear() for cleanup.\n * @internal\n */\nfunction checkRegistrySize(): void {\n const isDev = typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n if (\n isDev &&\n !hasWarnedAboutSize &&\n globalStateRegistry.size >= DEV_WARNING_THRESHOLD\n ) {\n hasWarnedAboutSize = true\n console.warn(\n `[Flexium] Global state registry has ${globalStateRegistry.size} entries. ` +\n `Consider using state.delete(key) to clean up unused states, ` +\n `or state.clear() to reset all global states.`\n )\n }\n}\n\n/** Action function type for state mutation */\nexport type StateAction<T> = (newValue: T | ((prev: T) => T)) => void\n\n/**\n * StateValue type - a value-like proxy that behaves like T.\n * Can be used directly in expressions and JSX.\n */\nexport type StateValue<T> = T & (() => T) & { peek(): T }\n\n/**\n * Check if a value is a StateValue (created by the state() API).\n * Useful for type guards and runtime detection of reactive state.\n * @internal\n * @param value - The value to check\n * @returns true if the value is a StateValue proxy, false otherwise\n *\n * @example\n * ```tsx\n * const count = state(0)\n * isStateValue(count) // true\n * isStateValue(5) // false\n * ```\n */\nexport function isStateValue(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n STATE_SIGNAL in value\n )\n}\n\n/**\n * Get the underlying signal from a StateValue proxy.\n * Used internally for reactive binding detection and DOM updates.\n * @internal\n * @param stateValue - The StateValue proxy to extract the signal from\n * @returns The underlying Signal if stateValue is a StateValue, null otherwise\n *\n * @example\n * ```tsx\n * const count = state(0)\n * const signal = getStateSignal(count) // Returns the internal Signal<number>\n * ```\n */\nexport function getStateSignal(stateValue: unknown): Signal<unknown> | null {\n if (isStateValue(stateValue)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (stateValue as any)[STATE_SIGNAL]\n }\n return null\n}\n\n/**\n * Compare a StateValue with a primitive value safely.\n * Handles Proxy comparison automatically by extracting the underlying value.\n * \n * @param stateValue - The StateValue to compare\n * @param value - The value to compare against\n * @returns true if the StateValue's underlying value equals the comparison value\n * \n * @example\n * ```tsx\n * const [count, setCount] = state(0)\n * \n * // ✅ Safe comparison using helper\n * if (equals(count, 5)) {\n * console.log('Count is 5')\n * }\n * \n * // ❌ Direct comparison (always false)\n * if (count === 5) { ... }\n * ```\n */\nexport function equals<T>(stateValue: StateValue<T>, value: T): boolean {\n if (!isStateValue(stateValue)) {\n return false\n }\n const actualValue = stateValue.peek()\n return actualValue === value\n}\n\n/**\n * Check if a StateValue is truthy.\n * Useful for boolean checks without explicit conversion.\n * \n * @param stateValue - The StateValue to check\n * @returns true if the underlying value is truthy\n * \n * @example\n * ```tsx\n * const [user, setUser] = state<User | null>(null)\n * \n * // ✅ Safe boolean check\n * if (isTruthy(user)) {\n * console.log('User exists:', user.name)\n * }\n * \n * // ❌ Direct check (always true for Proxy)\n * if (user) { ... }\n * ```\n */\nexport function isTruthy<T>(stateValue: StateValue<T>): boolean {\n if (!isStateValue(stateValue)) {\n return false\n }\n return Boolean(stateValue.peek())\n}\n\n/**\n * Cache for StateProxy instances to avoid repeated Proxy creation for the same signal.\n * Uses WeakMap so proxies are automatically garbage collected when signals are no longer referenced.\n */\nconst proxyCache = new WeakMap<Signal<unknown> | Computed<unknown>, StateValue<unknown>>()\n\n/**\n * Cache for bound functions to avoid repeated bind() calls.\n * Uses nested WeakMap: function -> (object -> bound function)\n * Performance: Reuse bound functions instead of creating new ones on each access\n */\nconst boundFunctionCache = new WeakMap<Function, WeakMap<object, Function>>()\n\n/**\n * Create a reactive proxy that behaves like a value but stays reactive.\n * The proxy is also callable - calling it returns the current value.\n * This ensures compatibility with code expecting getter functions.\n * \n * Performance optimization: Cache value and type checks to avoid repeated sig.value calls.\n * Performance optimization: Reuse Proxy instances for the same signal to reduce allocation overhead.\n */\nfunction createStateProxy<T>(sig: Signal<T> | Computed<T>): StateValue<T> {\n // Check cache first - reuse existing proxy if available\n const cached = proxyCache.get(sig as Signal<unknown> | Computed<unknown>)\n if (cached) {\n return cached as StateValue<T>\n }\n\n // Use an arrow function as the target so the proxy is callable but has no prototype\n // This prevents invariant violations in ownKeys trap\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const target = () => sig.value\n\n // Performance: Cache common property accessors to avoid repeated lookups\n const PEEK_PROP = 'peek'\n const VALUE_OF_PROP = 'valueOf'\n const TO_STRING_PROP = 'toString'\n const TO_JSON_PROP = 'toJSON'\n const TO_PRIMITIVE_SYMBOL = Symbol.toPrimitive\n\n // Performance: Cache dev mode check (rarely changes, so cache at proxy creation time)\n const isDev = typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n const warnComparison = isDev && typeof process !== 'undefined' && process.env?.FLEXIUM_WARN_COMPARISON === 'true'\n\n const proxy = new Proxy(target, {\n // Make the proxy callable - returns current value\n apply() {\n return sig.value\n },\n\n get(_target, prop) {\n // Performance: Check most common cases first (branch prediction optimization)\n // STATE_SIGNAL is checked first as it's used internally for reactive binding\n if (prop === STATE_SIGNAL) {\n return sig\n }\n\n // peek() is frequently accessed, check early\n if (prop === PEEK_PROP) {\n return sig.peek\n }\n\n // Performance: Early return for object property access (most common case)\n // Read value once and check type before special property checks\n // Note: accessing sig.value here tracks the signal in any enclosing effect\n const currentValue = sig.value\n\n // Early return for null (most common non-object case)\n if (currentValue === null) {\n // Still need to check special properties even for null values\n if (prop === TO_PRIMITIVE_SYMBOL) return () => null\n if (prop === VALUE_OF_PROP) return () => null\n if (prop === TO_STRING_PROP) return () => 'null'\n if (prop === TO_JSON_PROP) return () => null\n return undefined\n }\n\n // Type check once - reuse result\n const isObject = typeof currentValue === 'object'\n \n // Handle special properties for object values\n if (isObject) {\n // Check special properties first before accessing object properties\n if (prop === TO_PRIMITIVE_SYMBOL) {\n return (_hint: string) => currentValue\n }\n if (prop === VALUE_OF_PROP) {\n return () => {\n // Performance: Use cached warnComparison instead of checking env every time\n if (warnComparison) {\n // Only warn if explicitly enabled via environment variable\n // Most users should rely on ESLint rules instead\n }\n return currentValue\n }\n }\n if (prop === TO_STRING_PROP) {\n return () => String(currentValue)\n }\n if (prop === TO_JSON_PROP) {\n return () => currentValue\n }\n\n // Access object property\n const obj = currentValue as Record<string | symbol, unknown>\n const propValue = obj[prop]\n // Performance: Cache bound functions to avoid repeated bind() calls\n // If it's a function (like array methods), bind it to the current value\n if (typeof propValue === 'function') {\n // Check cache first\n let functionCache = boundFunctionCache.get(propValue)\n if (!functionCache) {\n functionCache = new WeakMap()\n boundFunctionCache.set(propValue, functionCache)\n }\n \n let bound: Function | undefined = functionCache.get(currentValue)\n if (!bound) {\n bound = propValue.bind(currentValue)\n // TypeScript: bound is guaranteed to be Function here\n functionCache.set(currentValue, bound as Function)\n }\n return bound\n }\n return propValue\n }\n\n // Handle special properties for primitive values\n if (prop === TO_PRIMITIVE_SYMBOL) {\n return (_hint: string) => currentValue\n }\n if (prop === VALUE_OF_PROP) {\n return () => {\n // Performance: Use cached warnComparison instead of checking env every time\n if (warnComparison) {\n // Only warn if explicitly enabled via environment variable\n }\n return currentValue\n }\n }\n if (prop === TO_STRING_PROP) {\n return () => String(currentValue)\n }\n if (prop === TO_JSON_PROP) {\n return () => currentValue\n }\n\n return undefined\n },\n\n // For property checks (like 'length' in array)\n has(_target, prop) {\n if (prop === STATE_SIGNAL) return true\n // Performance: Read value once\n const currentValue = sig.value\n // Performance: Early return for null\n if (currentValue === null) return false\n // Performance: Type check once\n return typeof currentValue === 'object' && prop in (currentValue as object)\n },\n\n // For Object.keys, for...in loops\n ownKeys(_target) {\n // Performance: Read value once\n const currentValue = sig.value\n // Performance: Early return for null\n if (currentValue === null) return []\n // Performance: Type check once\n if (typeof currentValue === 'object') {\n return Reflect.ownKeys(currentValue as object)\n }\n return []\n },\n\n getOwnPropertyDescriptor(_target, prop) {\n if (prop === STATE_SIGNAL) {\n return { configurable: true, enumerable: false, value: sig }\n }\n // Performance: Read value once\n const currentValue = sig.value\n // Performance: Early return for null\n if (currentValue === null) return undefined\n // Performance: Type check once\n if (typeof currentValue === 'object') {\n const desc = Object.getOwnPropertyDescriptor(currentValue as object, prop)\n if (desc) {\n // Make it configurable to satisfy Proxy invariants\n return { ...desc, configurable: true }\n }\n }\n return undefined\n },\n })\n\n // Cache the proxy for future reuse\n proxyCache.set(sig as Signal<unknown> | Computed<unknown>, proxy as StateValue<unknown>)\n\n return proxy as StateValue<T>\n}\n\n/** Async state status */\nexport type AsyncStatus = 'idle' | 'loading' | 'success' | 'error'\n\n/** Options for state() */\nexport interface StateOptions<P = unknown> {\n /**\n * Key for global state sharing. Can be a string or array.\n * Array keys are useful for hierarchical namespacing.\n * @example\n * state('light', { key: 'theme' })\n * state(null, { key: ['user', 'profile', userId] })\n */\n key?: StateKey\n /**\n * Parameters to pass to the function (for computed/async state).\n * Improves DX by making dependencies explicit.\n * @example\n * state(\n * async ({ userId }) => fetch(`/api/users/${userId}`),\n * { key: ['user', userId], params: { userId } }\n * )\n */\n params?: P\n}\n\n/**\n * Unified State API\n *\n * One function for all reactive state needs - always returns an array for consistency:\n * 1. Simple state: const [count, setCount] = state(0)\n * 2. Derived state: const [doubled] = state(() => count * 2)\n * 3. Async state: const [data, refetch, status, error] = state(async () => fetch(...))\n * 4. Global state: const [theme, setTheme] = state('light', { key: 'theme' })\n * 5. With params: const [user] = state(async (p) => fetch(`/api/${p.id}`), { params: { id } })\n *\n * @example\n * ```tsx\n * function Counter() {\n * const [count, setCount] = state(0)\n * const [doubled] = state(() => count * 2)\n * return <Button onPress={() => setCount(count + 1)}>{doubled}</Button>\n * }\n * ```\n */\n// Static methods interface for the state function\ninterface StateFunction {\n // Overloads\n <T>(initialValue: T, options?: StateOptions): [StateValue<T>, StateAction<T>]\n <T, P>(computeFn: (params: P) => T, options: StateOptions<P> & { params: P }): [StateValue<T>]\n <T>(computeFn: () => T, options?: StateOptions): [StateValue<T>]\n <T, P>(fetcher: (params: P) => Promise<T>, options: StateOptions<P> & { params: P }): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n <T>(fetcher: () => Promise<T>, options?: StateOptions): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n\n /** Delete a specific global state by key */\n delete: (key: StateKey) => boolean\n /** Clear all global states */\n clear: () => void\n /** Check if a global state exists */\n has: (key: StateKey) => boolean\n /** Current number of global states */\n readonly size: number\n}\n\n// Overload 1: Value → [StateValue, Setter]\nfunction state<T>(\n initialValue: T,\n options?: StateOptions\n): [StateValue<T>, StateAction<T>]\n\n// Overload 2: Sync function with params → [StateValue] (derived, no setter)\nfunction state<T, P>(\n computeFn: (params: P) => T,\n options: StateOptions<P> & { params: P }\n): [StateValue<T>]\n\n// Overload 3: Sync function without params → [StateValue] (derived, no setter)\nfunction state<T>(\n computeFn: () => T,\n options?: StateOptions\n): [StateValue<T>]\n\n// Overload 4: Async function with params → [StateValue, refetch, status, error]\nfunction state<T, P>(\n fetcher: (params: P) => Promise<T>,\n options: StateOptions<P> & { params: P }\n): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n\n// Overload 5: Async function without params → [StateValue, refetch, status, error]\nfunction state<T>(\n fetcher: () => Promise<T>,\n options?: StateOptions\n): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n\nfunction state<T, P = unknown>(\n initialValueOrFetcher: T | ((params?: P) => T) | ((params?: P) => Promise<T>),\n options?: StateOptions<P>\n): [StateValue<T>] | [StateValue<T>, StateAction<T>] | [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>] {\n const key = options?.key ? serializeKey(options.key) : undefined\n const params = options?.params\n\n // 0. Hook System - reuse state from previous render if inside a component\n if (currentComponent && !key) {\n const comp = currentComponent\n const hookIndex = comp.hookIndex++\n\n // Return existing hook if available\n if (hookIndex < comp.hooks.length) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return comp.hooks[hookIndex] as any\n }\n\n // Create new state and store in hooks array\n // Temporarily clear currentComponent to avoid infinite recursion\n const savedComponent = currentComponent\n currentComponent = null\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result = state(initialValueOrFetcher as any, options as any)\n currentComponent = savedComponent\n\n comp.hooks.push(result)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return result as any\n }\n\n // 1. Check Global Registry for keyed state\n if (key && globalStateRegistry.has(key)) {\n const cached = globalStateRegistry.get(key)!\n const isAsync = 'loading' in cached && cached._stateActions?.refetch !== undefined\n const isComputed = cached._isComputed\n\n const proxy = createStateProxy(cached._signal as Signal<T>)\n\n if (isComputed) {\n return [proxy] as [StateValue<T>]\n }\n\n if (isAsync) {\n const refetch = cached._stateActions?.refetch || (() => { })\n // Performance: Use computed directly instead of state() to avoid recursion\n const statusComputed = computed<AsyncStatus>(() => {\n if (cached.error) return 'error'\n if (cached.loading) return 'loading'\n if (cached.value !== undefined) return 'success'\n return 'idle'\n })\n const errorComputed = computed<unknown>(() => cached.error)\n const statusValue = createStateProxy(statusComputed)\n const errorValue = createStateProxy(errorComputed)\n return [proxy, refetch, statusValue, errorValue] as [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n }\n\n const setter: StateAction<T> = (newValue) => {\n if (typeof newValue === 'function') {\n cached.value = (newValue as (prev: T) => T)(cached.peek() as T)\n } else {\n cached.value = newValue\n }\n }\n return [proxy, setter] as [StateValue<T>, StateAction<T>]\n }\n\n // 2. Handle function input (computed or async)\n if (typeof initialValueOrFetcher === 'function') {\n const originalFn = initialValueOrFetcher as (params?: P) => T | Promise<T>\n \n // Performance: Avoid function wrapping when params is undefined\n // Reuse original function directly to avoid closure overhead\n const fn = params !== undefined\n ? () => originalFn(params)\n : (originalFn as () => T | Promise<T>)\n\n // Try to detect if it's async by checking constructor name\n // This handles `async () => ...` functions\n const isAsyncFn = originalFn.constructor.name === 'AsyncFunction'\n\n if (isAsyncFn) {\n // Async function → Resource\n const [res, resActions] = createResource(fn, async (val) => val)\n const s = toStateObject(res, resActions)\n\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n\n const proxy = createStateProxy(s._signal as Signal<T>)\n // Performance: Use computed directly instead of state() to avoid recursion\n const statusComputed = computed<AsyncStatus>(() => {\n if (s.error) return 'error'\n if (s.loading) return 'loading'\n if (s.value !== undefined) return 'success'\n return 'idle'\n })\n const errorComputed = computed<unknown>(() => s.error)\n const statusValue = createStateProxy(statusComputed)\n const errorValue = createStateProxy(errorComputed)\n\n return [proxy, resActions.refetch, statusValue, errorValue] as [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n }\n\n // Sync function → Computed\n // First, try running to check if it returns a Promise (for non-async functions that return Promise)\n let testResult: T | Promise<T>\n try {\n testResult = fn()\n } catch {\n // If it throws during initial call, treat as computed (will throw on access)\n const comp = computed(fn as () => T)\n const s = toComputedStateObject(comp)\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n return [createStateProxy(comp)] as [StateValue<T>]\n }\n\n if (testResult instanceof Promise) {\n // It's a Promise-returning function → Resource\n const [res, resActions] = createResource(fn, async (val) => val)\n const s = toStateObject(res, resActions)\n\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n\n const proxy = createStateProxy(s._signal as Signal<T>)\n // Performance: Use computed directly instead of state() to avoid recursion\n const statusComputed = computed<AsyncStatus>(() => {\n if (s.error) return 'error'\n if (s.loading) return 'loading'\n if (s.value !== undefined) return 'success'\n return 'idle'\n })\n const errorComputed = computed<unknown>(() => s.error)\n const statusValue = createStateProxy(statusComputed)\n const errorValue = createStateProxy(errorComputed)\n\n return [proxy, resActions.refetch, statusValue, errorValue] as [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>]\n }\n\n // Sync function → Computed (memoized derived value)\n const comp = computed(fn as () => T)\n const s = toComputedStateObject(comp)\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n return [createStateProxy(comp)] as [StateValue<T>]\n }\n\n // 3. Plain value → Signal with setter\n const sig = signal<T>(initialValueOrFetcher)\n const s = toSignalStateObject(sig)\n\n if (key) {\n globalStateRegistry.set(key, s)\n checkRegistrySize()\n }\n\n const proxy = createStateProxy(sig)\n const setter: StateAction<T> = (newValue) => {\n if (typeof newValue === 'function') {\n sig.value = (newValue as (prev: T) => T)(sig.peek())\n } else {\n sig.value = newValue\n }\n }\n\n return [proxy, setter] as [StateValue<T>, StateAction<T>]\n}\n\n/**\n * Delete a specific global state by key\n * @param key - The key of the state to delete\n * @returns true if the state was deleted, false if it didn't exist\n *\n * @example\n * ```ts\n * state.delete('theme')\n * state.delete(['user', 'profile', userId])\n * ```\n */\nstate.delete = function (key: StateKey): boolean {\n const serializedKey = serializeKey(key)\n return globalStateRegistry.delete(serializedKey)\n}\n\n/**\n * Clear all global states (useful for testing or resetting app)\n *\n * @example\n * ```ts\n * state.clear()\n * ```\n */\nstate.clear = function (): void {\n globalStateRegistry.clear()\n hasWarnedAboutSize = false\n}\n\n/**\n * Check if a global state exists\n * @param key - The key to check\n * @returns true if the state exists\n *\n * @example\n * ```ts\n * if (state.has('theme')) { ... }\n * ```\n */\nstate.has = function (key: StateKey): boolean {\n const serializedKey = serializeKey(key)\n return globalStateRegistry.has(serializedKey)\n}\n\n/**\n * Get the current number of global states\n */\nObject.defineProperty(state, 'size', {\n get: () => globalStateRegistry.size,\n enumerable: true,\n})\n\n// Export with proper typing (cast to include static methods)\nconst _state = state as StateFunction\nexport { _state as state }\n\n/**\n * Ref object type for DOM element references\n */\nexport interface RefObject<T> {\n current: T | null\n}\n\n/**\n * Create a ref object to hold a reference to a DOM element.\n * Use with the `ref` prop on JSX elements.\n *\n * @param initialValue - Initial value (typically null)\n * @returns A ref object with a `current` property\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const inputRef = ref<HTMLInputElement>(null)\n *\n * const focusInput = () => {\n * inputRef.current?.focus()\n * }\n *\n * return (\n * <div>\n * <input ref={inputRef} type=\"text\" />\n * <button onclick={focusInput}>Focus</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function ref<T>(initialValue: T | null): RefObject<T> {\n return { current: initialValue }\n}\n\n\n"]}
|