flexium 0.16.2 → 0.16.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/dist/chunk-EROGYZGA.js +2 -0
- package/dist/chunk-EROGYZGA.js.map +1 -0
- package/dist/chunk-FU4W2BKL.mjs +2 -0
- package/dist/chunk-FU4W2BKL.mjs.map +1 -0
- package/dist/chunk-HBBTT5I5.mjs +2 -0
- package/dist/chunk-HBBTT5I5.mjs.map +1 -0
- package/dist/chunk-HUE2TOCR.js +2 -0
- package/dist/chunk-HUE2TOCR.js.map +1 -0
- package/dist/chunk-JNWUZKHF.js +2 -0
- package/dist/chunk-JNWUZKHF.js.map +1 -0
- package/dist/chunk-PPPU2XSA.mjs +2 -0
- package/dist/chunk-PPPU2XSA.mjs.map +1 -0
- package/dist/chunk-S5DHAAMO.mjs +2 -0
- package/dist/chunk-S5DHAAMO.mjs.map +1 -0
- package/dist/chunk-W5IZRDRK.mjs +2 -0
- package/dist/chunk-W5IZRDRK.mjs.map +1 -0
- package/dist/chunk-WWTSQR6W.js +2 -0
- package/dist/chunk-WWTSQR6W.js.map +1 -0
- package/dist/chunk-ZJZRDYA2.js +2 -0
- package/dist/chunk-ZJZRDYA2.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/css.js +1 -1
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +1 -1
- package/dist/css.mjs.map +1 -1
- package/dist/dom.d.cts +1 -1
- package/dist/dom.d.ts +1 -1
- 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/index.d.cts +9 -1
- package/dist/index.d.ts +9 -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/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/router.mjs +1 -1
- package/dist/router.mjs.map +1 -1
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- 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/{types-CxlS2F2j.d.cts → types-C5UPsdAS.d.cts} +1 -1
- package/dist/{types-CxlS2F2j.d.ts → types-C5UPsdAS.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/ref.ts"],"names":["useRef","initialValue","hook"],"mappings":"iEA2BO,SAASA,CAAAA,CAAUC,CAAAA,CAA4C,CACpE,OAAOC,kBAAAA,CAAK,KAAO,CACjB,OAAA,CAASD,CACX,CAAA,CAAE,CACJ","file":"chunk-EROGYZGA.js","sourcesContent":["import { hook } from './hook'\nimport type { RefObject } from './types'\n\n/**\n * Creates a mutable ref object that persists across renders\n *\n * @example\n * ```tsx\n * function InputWithFocus() {\n * const inputRef = useRef<HTMLInputElement>()\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 Input</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRef<T>(initialValue: T): RefObject<T>\nexport function useRef<T>(initialValue: T | null): RefObject<T | null>\nexport function useRef<T = undefined>(): RefObject<T | undefined>\nexport function useRef<T>(initialValue?: T): RefObject<T | undefined> {\n return hook(() => ({\n current: initialValue\n }))\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function C(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return "fx-"+(t>>>0).toString(36)}var W=new Set(["animationIterationCount","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridArea","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","fontWeight","lineClamp","lineHeight","opacity","order","orphans","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"]);function K(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function P(e,t){return typeof t=="number"&&t!==0&&!W.has(e)?t+"px":String(t)}function k(e,t){let n="",r="";for(let i in e){let a=e[i];if(a!=null)if(i.startsWith("&")){let l=i.replace(/&/g,t);r+=k(a,l);}else if(i.startsWith("@"))r+=`${i}{${k(a,t)}}`;else {if(typeof a=="object")continue;n+=`${K(i)}:${P(i,a)};`;}}let s="";return n&&(s=`${t}{${n}}`),s+=r,s}function z(e,t){let n="";for(let r in t){let s=t[r],i="";for(let a in s){let l=s[a];l!=null&&typeof l!="object"&&(i+=`${K(a)}:${P(a,l)};`);}n+=`${r}{${i}}`;}return `@keyframes ${e}{${n}}`}var g=new Map,v=[],m=null;function M(){return typeof document<"u"&&"adoptedStyleSheets"in document&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype}function E(){return M()?(m||(m=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,m]),m):null}function V(e,t){if(g.has(e))return;g.set(e,true);let n=E();if(n)try{n.insertRule(t,n.cssRules.length);}catch(r){process.env.NODE_ENV!=="production"&&console.warn("[flexium/css] Invalid CSS rule:",t,r);}else v.push(t);}function O(e){return g.has(e)}function D(){return v.join("")}function H(){let e=D();return e?`<style data-flexium-css>${e}</style>`:""}function L(){v=[],g=new Map,m=null;}function A(){if(typeof document>"u")return;let e=document.querySelector("style[data-flexium-css]");if(e){let t=e.textContent||"",n=/\.fx-[a-z0-9]+/g,r;for(;(r=n.exec(t))!==null;){let s=r[0].slice(1);g.set(s,true);}}}M()&&A();function S(e){let t=JSON.stringify(e),n=C(t);if(O(n))return n;let r=k(e,"."+n);return V(n,r),n}function N(...e){return e.filter(Boolean).join(" ")}function q(e,t){let{base:n,variants:r,defaultVariants:s,compoundVariants:i}=t,a=S(n),l=new Map;function I(d,c){let h=`${d}:${c}`,f=l.get(h);return !f&&r?.[d]?.[c]&&(f=S(r[d][c]),l.set(h,f)),f||""}let T=new Map;function $(d){let{children:c,className:h,...f}=d,u={},j={};for(let o in f)r&&o in r?u[o]=f[o]??s?.[o]:j[o]=f[o];if(s)for(let o in s)o in u||(u[o]=String(s[o]));let w=[];for(let[o,x]of Object.entries(u))if(x){let y=I(o,String(x));y&&w.push(y);}if(i)for(let o of i){let{css:x,...y}=o,R=true;for(let[b,p]of Object.entries(y))if(u[b]!==p){R=false;break}if(R){let b=JSON.stringify(y),p=T.get(b);p||(p=S(x),T.set(b,p)),w.push(p);}}let F=N(a,...w,h);return {type:e,props:{...j,className:F},children:Array.isArray(c)?c:c!=null?[c]:[],key:void 0}}return $.displayName=`Styled(${e})`,$}function G(e){let t=JSON.stringify(e),n=C(t);if(O(n))return n;let r=z(n,e);return V(n,r),n}export{D as a,H as b,L as c,A as d,S as e,N as f,q as g,G as h};//# sourceMappingURL=chunk-FU4W2BKL.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-FU4W2BKL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/css/runtime/hash.ts","../src/css/runtime/serialize.ts","../src/css/runtime/sheet.ts","../src/css/css.ts","../src/css/styled.ts","../src/css/keyframes.ts"],"names":["hash","str","h","i","unitlessProperties","toKebabCase","match","addUnit","property","value","serialize","styles","selector","properties","nested","key","nestedSelector","result","serializeKeyframes","name","keyframes","frames","prop","cache","serverStyles","browserSheet","supportsAdoptedStyleSheets","getBrowserSheet","insert","css","sheet","e","has","getStyles","getStyleTag","resetStyles","hydrateStyles","styleTag","text","classRegex","className","cssText","cx","classes","styled","tag","config","base","variants","defaultVariants","compoundVariants","baseClass","variantCache","getVariantClass","variantName","variantValue","cacheKey","compoundCache","StyledComponent","props","children","userClassName","rest","variantProps","elementProps","variantClasses","vc","compound","compoundStyles","conditions","matches","compoundClass","finalClassName","definition"],"mappings":"AAIO,SAASA,CAAAA,CAAKC,EAAqB,CACxC,IAAIC,EAAI,IAAA,CACR,IAAA,IAASC,EAAI,CAAA,CAAGA,CAAAA,CAAIF,EAAI,MAAA,CAAQE,CAAAA,EAAAA,CAC9BD,GAAMA,CAAAA,EAAK,CAAA,EAAKA,EAAKD,CAAAA,CAAI,UAAA,CAAWE,CAAC,CAAA,CAEvC,OAAO,KAAA,CAAA,CAASD,IAAM,CAAA,EAAG,QAAA,CAAS,EAAE,CACtC,CCLA,IAAME,CAAAA,CAAqB,IAAI,IAAI,CACjC,yBAAA,CACA,oBACA,kBAAA,CACA,kBAAA,CACA,UACA,cAAA,CACA,iBAAA,CACA,cACA,SAAA,CACA,MAAA,CACA,UAAA,CACA,cAAA,CACA,YAAA,CACA,cAAA,CACA,YACA,UAAA,CACA,SAAA,CACA,aACA,aAAA,CACA,cAAA,CACA,aACA,eAAA,CACA,gBAAA,CACA,kBACA,YAAA,CACA,WAAA,CACA,aACA,SAAA,CACA,OAAA,CACA,UACA,SAAA,CACA,QAAA,CACA,SACA,MAAA,CACA,aAAA,CACA,cAAA,CACA,aAAA,CACA,iBAAA,CACA,kBAAA,CACA,mBACA,eAAA,CACA,aACF,CAAC,CAAA,CAKM,SAASC,EAAYJ,CAAAA,CAAqB,CAC/C,OAAOA,CAAAA,CAAI,OAAA,CAAQ,SAAWK,CAAAA,EAAU,GAAA,CAAMA,EAAM,WAAA,EAAa,CACnE,CAKO,SAASC,CAAAA,CAAQC,CAAAA,CAAkBC,CAAAA,CAAyB,CACjE,OAAI,OAAOA,CAAAA,EAAU,UAAYA,CAAAA,GAAU,CAAA,EAAK,CAACL,CAAAA,CAAmB,GAAA,CAAII,CAAQ,CAAA,CACvEC,CAAAA,CAAQ,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,EACN,KAAA,CAAO,CAAE,GAAGmB,CAAAA,CAAc,SAAA,CAAWQ,CAAe,CAAA,CACpD,QAAA,CAAU,MAAM,OAAA,CAAQZ,CAAQ,CAAA,CAAIA,CAAAA,CAAWA,CAAAA,EAAY,IAAA,CAAO,CAACA,CAAQ,CAAA,CAAI,EAAC,CAChF,GAAA,CAAK,MACP,CACF,CAGA,OAAAF,CAAAA,CAAgB,WAAA,CAAc,UAAUb,CAAG,CAAA,CAAA,CAAA,CAEpCa,CACT,CChJO,SAAStC,EAAUqD,CAAAA,CAAwC,CAEhE,IAAM1D,CAAAA,CAAM,IAAA,CAAK,SAAA,CAAU0D,CAAU,CAAA,CAC/BtD,CAAAA,CAAOnB,EAAKe,CAAG,CAAA,CAGrB,GAAIiB,CAAAA,CAAIb,CAAI,EACV,OAAOA,CAAAA,CAIT,IAAMsB,CAAAA,CAAUvB,CAAAA,CAAmBC,EAAMsD,CAAsD,CAAA,CAC/F,OAAA7C,CAAAA,CAAOT,CAAAA,CAAMsB,CAAO,CAAA,CAEbtB,CACT","file":"chunk-FU4W2BKL.mjs","sourcesContent":["/**\n * Generate a hash for a style object\n * Uses djb2 algorithm for fast, low-collision hashing\n */\nexport function hash(str: string): string {\n let h = 5381\n for (let i = 0; i < str.length; i++) {\n h = ((h << 5) + h) ^ str.charCodeAt(i)\n }\n return 'fx-' + (h >>> 0).toString(36)\n}\n","import type { StyleObject, CSSValue } from '../types'\n\n/**\n * Properties that should not have 'px' auto-added\n */\nconst unitlessProperties = new Set([\n 'animationIterationCount',\n 'borderImageOutset',\n 'borderImageSlice',\n 'borderImageWidth',\n 'boxFlex',\n 'boxFlexGroup',\n 'boxOrdinalGroup',\n 'columnCount',\n 'columns',\n 'flex',\n 'flexGrow',\n 'flexPositive',\n 'flexShrink',\n 'flexNegative',\n 'flexOrder',\n 'gridArea',\n 'gridRow',\n 'gridRowEnd',\n 'gridRowSpan',\n 'gridRowStart',\n 'gridColumn',\n 'gridColumnEnd',\n 'gridColumnSpan',\n 'gridColumnStart',\n 'fontWeight',\n 'lineClamp',\n 'lineHeight',\n 'opacity',\n 'order',\n 'orphans',\n 'tabSize',\n 'widows',\n 'zIndex',\n 'zoom',\n 'fillOpacity',\n 'floodOpacity',\n 'stopOpacity',\n 'strokeDasharray',\n 'strokeDashoffset',\n 'strokeMiterlimit',\n 'strokeOpacity',\n 'strokeWidth',\n])\n\n/**\n * Convert camelCase to kebab-case\n */\nexport function toKebabCase(str: string): string {\n return str.replace(/[A-Z]/g, (match) => '-' + match.toLowerCase())\n}\n\n/**\n * Add unit to numeric values where appropriate\n */\nexport function addUnit(property: string, value: CSSValue): string {\n if (typeof value === 'number' && value !== 0 && !unitlessProperties.has(property)) {\n return value + 'px'\n }\n return String(value)\n}\n\n/**\n * Serialize a style object to CSS string\n */\nexport function serialize(styles: StyleObject, selector: string): string {\n let properties = ''\n let nested = ''\n\n for (const key in styles) {\n const value = styles[key]\n\n if (value === undefined || value === null) {\n continue\n }\n\n if (key.startsWith('&')) {\n // Nested selector: &:hover, &::before, & > div\n const nestedSelector = key.replace(/&/g, selector)\n nested += serialize(value as StyleObject, nestedSelector)\n } else if (key.startsWith('@')) {\n // At-rule: @media, @supports, @container\n nested += `${key}{${serialize(value as StyleObject, selector)}}`\n } else if (typeof value === 'object') {\n // Skip invalid nested objects without & or @\n continue\n } else {\n // Regular CSS property\n properties += `${toKebabCase(key)}:${addUnit(key, value)};`\n }\n }\n\n let result = ''\n if (properties) {\n result = `${selector}{${properties}}`\n }\n result += nested\n\n return result\n}\n\n/**\n * Serialize keyframes to CSS string\n */\nexport function serializeKeyframes(\n name: string,\n keyframes: Record<string, Record<string, CSSValue>>\n): string {\n let frames = ''\n\n for (const key in keyframes) {\n const styles = keyframes[key]\n let properties = ''\n\n for (const prop in styles) {\n const value = styles[prop]\n if (value !== undefined && value !== null && typeof value !== 'object') {\n properties += `${toKebabCase(prop)}:${addUnit(prop, value)};`\n }\n }\n\n frames += `${key}{${properties}}`\n }\n\n return `@keyframes ${name}{${frames}}`\n}\n","/**\n * StyleSheet manager\n * Uses adoptedStyleSheets for efficient style injection\n * Falls back to server-side collection when not available (SSR, jsdom)\n */\n\n// Cache to track which styles have been inserted\nlet cache = new Map<string, boolean>()\n\n// Server-side collected styles\nlet serverStyles: string[] = []\n\n// Browser stylesheet (lazy initialized)\nlet browserSheet: CSSStyleSheet | null = null\n\n/**\n * Check if adoptedStyleSheets is supported\n */\nfunction supportsAdoptedStyleSheets(): boolean {\n return (\n typeof document !== 'undefined' &&\n 'adoptedStyleSheets' in document &&\n typeof CSSStyleSheet !== 'undefined' &&\n 'replaceSync' in CSSStyleSheet.prototype\n )\n}\n\nfunction getBrowserSheet(): CSSStyleSheet | null {\n if (!supportsAdoptedStyleSheets()) {\n return null\n }\n\n if (!browserSheet) {\n browserSheet = new CSSStyleSheet()\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, browserSheet]\n }\n return browserSheet\n}\n\n/**\n * Insert a CSS rule\n */\nexport function insert(hash: string, css: string): void {\n if (cache.has(hash)) {\n return\n }\n\n cache.set(hash, true)\n\n const sheet = getBrowserSheet()\n if (sheet) {\n try {\n sheet.insertRule(css, sheet.cssRules.length)\n } catch (e) {\n // Handle invalid CSS gracefully in development\n if (process.env.NODE_ENV !== 'production') {\n console.warn('[flexium/css] Invalid CSS rule:', css, e)\n }\n }\n } else {\n // Server-side or unsupported environment: collect styles\n serverStyles.push(css)\n }\n}\n\n/**\n * Check if a hash is already in the cache\n */\nexport function has(hash: string): boolean {\n return cache.has(hash)\n}\n\n/**\n * Get all collected styles for SSR\n */\nexport function getStyles(): string {\n return serverStyles.join('')\n}\n\n/**\n * Get styles as a style tag for SSR\n */\nexport function getStyleTag(): string {\n const styles = getStyles()\n if (!styles) return ''\n return `<style data-flexium-css>${styles}</style>`\n}\n\n/**\n * Reset collected styles and cache (for SSR between requests or testing)\n */\nexport function resetStyles(): void {\n serverStyles = []\n cache = new Map()\n browserSheet = null\n}\n\n/**\n * Hydrate styles on the client\n * Call this after SSR to sync the cache with server-rendered styles\n */\nexport function hydrateStyles(): void {\n if (typeof document === 'undefined') return\n\n const styleTag = document.querySelector('style[data-flexium-css]')\n if (styleTag) {\n // Parse and cache existing styles\n const text = styleTag.textContent || ''\n const classRegex = /\\.fx-[a-z0-9]+/g\n let match\n while ((match = classRegex.exec(text)) !== null) {\n const hash = match[0].slice(1) // Remove the dot\n cache.set(hash, true)\n }\n }\n}\n\n// Auto-hydrate on client (only if adoptedStyleSheets is supported)\nif (supportsAdoptedStyleSheets()) {\n hydrateStyles()\n}\n","import type { StyleObject } from './types'\nimport { hash } from './runtime/hash'\nimport { serialize } from './runtime/serialize'\nimport { insert, has } from './runtime/sheet'\n\n/**\n * Create a CSS class from a style object\n *\n * @example\n * ```tsx\n * const buttonClass = css({\n * padding: '8px 16px',\n * backgroundColor: 'blue',\n * color: 'white',\n * '&:hover': {\n * backgroundColor: 'darkblue'\n * }\n * })\n *\n * <button className={buttonClass}>Click me</button>\n * ```\n */\nexport function css(styles: StyleObject): string {\n // Generate unique hash from style object\n const key = JSON.stringify(styles)\n const className = hash(key)\n\n // Skip if already inserted\n if (has(className)) {\n return className\n }\n\n // Serialize and insert CSS\n const cssText = serialize(styles, '.' + className)\n insert(className, cssText)\n\n return className\n}\n\n/**\n * Combine multiple class names, filtering out falsy values\n *\n * @example\n * ```tsx\n * const className = cx(\n * baseClass,\n * isActive && activeClass,\n * variant === 'primary' && primaryClass\n * )\n * ```\n */\nexport function cx(\n ...classes: (string | boolean | null | undefined)[]\n): string {\n return classes.filter(Boolean).join(' ')\n}\n","import type { StyleObject, VariantConfig, StyledConfig } from './types'\nimport type { FNode } from '../dom/types'\nimport { css, cx } from './css'\n\n// HTML element tag names\ntype HTMLTag = 'a' | 'abbr' | 'address' | 'area' | 'article' | 'aside' | 'audio' |\n 'b' | 'base' | 'bdi' | 'bdo' | 'blockquote' | 'body' | 'br' | 'button' |\n 'canvas' | 'caption' | 'cite' | 'code' | 'col' | 'colgroup' |\n 'data' | 'datalist' | 'dd' | 'del' | 'details' | 'dfn' | 'dialog' | 'div' | 'dl' | 'dt' |\n 'em' | 'embed' |\n 'fieldset' | 'figcaption' | 'figure' | 'footer' | 'form' |\n 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'head' | 'header' | 'hgroup' | 'hr' | 'html' |\n 'i' | 'iframe' | 'img' | 'input' | 'ins' |\n 'kbd' |\n 'label' | 'legend' | 'li' | 'link' |\n 'main' | 'map' | 'mark' | 'menu' | 'meta' | 'meter' |\n 'nav' | 'noscript' |\n 'object' | 'ol' | 'optgroup' | 'option' | 'output' |\n 'p' | 'picture' | 'pre' | 'progress' |\n 'q' |\n 'rp' | 'rt' | 'ruby' |\n 's' | 'samp' | 'script' | 'search' | 'section' | 'select' | 'slot' | 'small' | 'source' | 'span' | 'strong' | 'style' | 'sub' | 'summary' | 'sup' | 'svg' |\n 'table' | 'tbody' | 'td' | 'template' | 'textarea' | 'tfoot' | 'th' | 'thead' | 'time' | 'title' | 'tr' | 'track' |\n 'u' | 'ul' |\n 'var' | 'video' |\n 'wbr'\n\n/**\n * Create a styled component with variant support\n *\n * @example\n * ```tsx\n * const Button = styled('button', {\n * base: {\n * padding: '8px 16px',\n * border: 'none',\n * borderRadius: 4,\n * cursor: 'pointer'\n * },\n * variants: {\n * variant: {\n * primary: { backgroundColor: 'blue', color: 'white' },\n * secondary: { backgroundColor: 'gray', color: 'black' }\n * },\n * size: {\n * sm: { padding: '4px 8px', fontSize: 12 },\n * md: { padding: '8px 16px', fontSize: 14 },\n * lg: { padding: '12px 24px', fontSize: 16 }\n * }\n * },\n * defaultVariants: {\n * variant: 'primary',\n * size: 'md'\n * }\n * })\n *\n * // Usage\n * <Button variant=\"secondary\" size=\"lg\">Click me</Button>\n * ```\n */\nexport function styled<\n T extends HTMLTag,\n V extends VariantConfig = Record<string, never>\n>(\n tag: T,\n config: StyledConfig<V>\n): StyledComponent<T, V> {\n const { base, variants, defaultVariants, compoundVariants } = config\n\n // Pre-compute base class\n const baseClass = css(base)\n\n // Cache for variant classes\n const variantCache = new Map<string, string>()\n\n // Get or create variant class\n function getVariantClass(variantName: string, variantValue: string): string {\n const cacheKey = `${variantName}:${variantValue}`\n let className = variantCache.get(cacheKey)\n\n if (!className && variants?.[variantName]?.[variantValue]) {\n className = css(variants[variantName][variantValue])\n variantCache.set(cacheKey, className)\n }\n\n return className || ''\n }\n\n // Compound variant cache\n const compoundCache = new Map<string, string>()\n\n function StyledComponent(props: StyledComponentProps<V>): FNode {\n const { children, className: userClassName, ...rest } = props as any\n\n // Separate variant props from element props\n const variantProps: Record<string, string> = {}\n const elementProps: Record<string, any> = {}\n\n for (const key in rest) {\n if (variants && key in variants) {\n variantProps[key] = rest[key] ?? (defaultVariants as any)?.[key]\n } else {\n elementProps[key] = rest[key]\n }\n }\n\n // Apply default variants for missing props\n if (defaultVariants) {\n for (const key in defaultVariants) {\n if (!(key in variantProps)) {\n variantProps[key] = String(defaultVariants[key as keyof typeof defaultVariants])\n }\n }\n }\n\n // Collect variant classes\n const variantClasses: string[] = []\n for (const [name, value] of Object.entries(variantProps)) {\n if (value) {\n const vc = getVariantClass(name, String(value))\n if (vc) variantClasses.push(vc)\n }\n }\n\n // Check compound variants\n if (compoundVariants) {\n for (const compound of compoundVariants) {\n const { css: compoundStyles, ...conditions } = compound\n\n // Check if all conditions match\n let matches = true\n for (const [key, value] of Object.entries(conditions)) {\n if (variantProps[key] !== value) {\n matches = false\n break\n }\n }\n\n if (matches) {\n // Generate cache key from conditions\n const cacheKey = JSON.stringify(conditions)\n let compoundClass = compoundCache.get(cacheKey)\n\n if (!compoundClass) {\n compoundClass = css(compoundStyles)\n compoundCache.set(cacheKey, compoundClass)\n }\n\n variantClasses.push(compoundClass)\n }\n }\n }\n\n // Combine all classes\n const finalClassName = cx(baseClass, ...variantClasses, userClassName)\n\n // Return FNode element\n return {\n type: tag,\n props: { ...elementProps, className: finalClassName },\n children: Array.isArray(children) ? children : children != null ? [children] : [],\n key: undefined\n }\n }\n\n // Mark as styled component\n StyledComponent.displayName = `Styled(${tag})`\n\n return StyledComponent as unknown as StyledComponent<T, V>\n}\n\n// Types\ntype StyledComponent<\n T extends HTMLTag,\n V extends VariantConfig\n> = {\n (props: StyledComponentProps<V>): FNode\n displayName: string\n}\n\ntype StyledComponentProps<V extends VariantConfig> = {\n [K in keyof V]?: keyof V[K]\n} & {\n children?: any\n className?: string\n [key: string]: any\n}\n","import type { KeyframeDefinition, CSSValue } from './types'\nimport { hash } from './runtime/hash'\nimport { serializeKeyframes } from './runtime/serialize'\nimport { insert, has } from './runtime/sheet'\n\n/**\n * Create a keyframes animation\n *\n * @example\n * ```tsx\n * const fadeIn = keyframes({\n * from: { opacity: 0 },\n * to: { opacity: 1 }\n * })\n *\n * const slideIn = keyframes({\n * '0%': { transform: 'translateX(-100%)' },\n * '100%': { transform: 'translateX(0)' }\n * })\n *\n * const className = css({\n * animation: `${fadeIn} 0.3s ease-in-out`\n * })\n * ```\n */\nexport function keyframes(definition: KeyframeDefinition): string {\n // Generate unique name from keyframe definition\n const key = JSON.stringify(definition)\n const name = hash(key)\n\n // Skip if already inserted\n if (has(name)) {\n return name\n }\n\n // Serialize and insert keyframes\n const cssText = serializeKeyframes(name, definition as Record<string, Record<string, CSSValue>>)\n insert(name, cssText)\n\n return name\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1,b}from'./chunk-NABWFBEA.mjs';import {c}from'./chunk-CB6CIG76.mjs';import {b as b$1}from'./chunk-NRPWBHKP.mjs';import {e,g,a,h as h$1,b as b$2}from'./chunk-WHRUAZR4.mjs';function Q(e,n,...t){return {type:e,props:n||{},children:t,key:n?.key}}var p=null,w=new WeakMap,h=null;function U(e,n,t={}){let{state:o,onHydrated:r,onMismatch:a}=t;p=n.firstChild;try{let i;typeof e=="function"&&!$(e)?i={type:e,props:{},children:[],key:void 0}:i=e,F(i,n),r?.();}catch(i){console.warn("[Flexium] Hydration mismatch, falling back to full render:",i),a?.(i),n.innerHTML="",import('./render-Z4FL7ORX.mjs').then(({render:l})=>{l(e,n);});}finally{p=null;}}function $(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function F(e,n){if(e==null||typeof e=="boolean")return H(),null;if(typeof e=="string"||typeof e=="number")return Y(String(e));if(Array.isArray(e)){let t=[];for(let o of e){let r=F(o,n);r&&(Array.isArray(r)?t.push(...r):t.push(r));}return t}if(typeof e=="function")return V({type:e,props:{},children:[],key:void 0},n);if(typeof e=="object"&&$(e)){if(typeof e.type=="string")return Z(e);if(typeof e.type=="function")return V(e,n)}return null}function H(){for(;p&&p.nodeType===Node.TEXT_NODE&&(!p.textContent||p.textContent.trim()==="");)p=p.nextSibling;}function Y(e){H();let n=p;if(!n)return null;if(n.nodeType!==Node.TEXT_NODE){if(e.trim()==="")return null;throw new Error(`Hydration mismatch: expected text node "${e}", got ${n.nodeName}`)}return p=n.nextSibling,n}function Z(e){H();let n=p,t=e.type;if(!n||n.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${t}>, got ${n?.nodeName||"nothing"}`);if(n.tagName.toLowerCase()!==t.toLowerCase())throw new Error(`Hydration mismatch: expected <${t}>, got <${n.tagName.toLowerCase()}>`);if(e.props){for(let[o,r]of Object.entries(e.props))if(o==="ref")typeof r=="function"?r(n):r&&typeof r=="object"&&"current"in r&&(r.current=n);else if(o.startsWith("on")&&typeof r=="function"){let a=o.slice(2).toLowerCase();n.addEventListener(a,r),n.__eventHandlers||(n.__eventHandlers={}),n.__eventHandlers[a]=r;}}if(p=n.nextSibling,e.children&&e.children.length>0){let o=p;p=n.firstChild;for(let r of e.children)F(r,n);p=o;}return n}function V(e,n){let t=e.type,o={...e.props};e.children&&e.children.length>0&&(o.children=e.children.length===1?e.children[0]:e.children);let r=t._contextId,a$2=r!==void 0,i;a$2&&(i=g(r,o.value)),w.has(n)||w.set(n,new Map);let l=w.get(n),C=e.key!==void 0,u;if(C)u=e.key;else {let c=0,y=t.name||"anonymous";l.forEach((v,x)=>{typeof x=="string"&&x.startsWith(`__auto_${y}_`)&&c++;}),u=`__auto_${y}_${c}`;}let s={hooks:[],hookIndex:0,nodes:[],parent:n,fnode:e,props:o,key:u,children:new Set,parentInstance:h||void 0};h&&h.children.add(s),l.set(u,s);let d=h;h=s;try{let c=a(s,()=>t(o)),y=F(c,n);s.nodes=y?Array.isArray(y)?y:[y]:[];let v=!0,x=()=>{let X=s.props,B=a(s,()=>t(X));if(v){v=!1;return}if(s.nodes.length===0){let g=a$1(B,n);s.nodes=g?Array.isArray(g)?g:[g]:[];return}let m=s.nodes[0].parentNode;if(!m)return;let E=document.createComment("flexium-marker"),L=s.nodes[s.nodes.length-1];L.nextSibling?m.insertBefore(E,L.nextSibling):m.appendChild(E),s.children.clear();let q=document.createElement("div"),N=a$1(B,q,m),G=N?Array.isArray(N)?N:[N]:[],J=b(s.nodes,G,m,E);m.removeChild(E),s.nodes=J;};return s.renderFn=x,b$1(x),s.nodes}finally{h=d,a$2&&h$1(r,i);}}var ee={register:()=>{},hasBoundary:false},P=new e(ee);function D(){let[e]=c(P);return e}function j(e){let{fallback:n,children:t}=e,o=b$2(()=>new Set),[,r]=c(0),[a,i]=c(false),C={register:s=>{o.has(s)||(o.add(s),r(d=>d+1),i(true),s.finally(()=>{o.delete(s),r(d=>{let c=d-1;return c===0&&i(false),c});}));},hasBoundary:true},u=a?n:t;return {type:P.Provider,props:{value:C},children:[u],key:void 0}}function W(e){let{fallback:n,onError:t,children:o,resetKey:r}=e,[a,i]=c({error:null,info:null}),l=b$2(()=>({current:r}));r!==l.current&&(l.current=r,a.error!==null&&i({error:null,info:null}));if(a.error)return typeof n=="function"?n(a.error,a.info):n;try{return o}finally{}}function K(e){let n=null,t=null,o=null,r=a=>{if(n)return n(a);if(o)throw o;let i=D();return t||(t=e().then(l=>{n=l.default;}).catch(l=>{o=l instanceof Error?l:new Error(String(l));})),i.hasBoundary&&i.register(t),null};return r._lazy=true,r._loader=e,r}export{Q as a,U as b,j as c,W as d,K as e};//# sourceMappingURL=chunk-HBBTT5I5.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-HBBTT5I5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","newNodes","renderNode","nodeParent","marker","lastNode","tempContainer","newNodesArray","reconciledNodes","reconcile","unsafeEffect","popContext","defaultValue","SuspenseCtx","Context","suspenseContext","use","Suspense","fallback","pendingSet","hook","setPendingCount","showFallback","setShowFallback","contextValue","promise","c","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"0LAKO,SAASA,CAAAA,CACZC,CAAAA,CACAC,CAAAA,CAAAA,GACGC,CAAAA,CACE,CACL,OAAO,CACH,IAAA,CAAAF,CAAAA,CACA,KAAA,CAAOC,CAAAA,EAAS,GAChB,QAAA,CAAAC,CAAAA,CACA,GAAA,CAAKD,CAAAA,EAAO,GAChB,CACJ,CCRA,IACIE,CAAAA,CAA+B,IAAA,CAkC7BC,EAA2B,IAAI,OAAA,CACjCC,CAAAA,CAAwD,KAarD,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CACrB,CACN,GAAM,CAAE,MAAAC,CAAAA,CAAO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AAA,CAAgB,OAAA,GAC/BA,CAAAA,CAAgB,OAAA,CAAUH,EACtBC,CAAAA,CAAW,KAAA,GAAU,MACvBC,CAAAA,CAAc,CAAE,MAAO,IAAA,CAAM,IAAA,CAAM,IAAK,CAAC,CAAA,CAAA,CAqB7C,GAAID,CAAAA,CAAW,MACb,OAAI,OAAOd,CAAAA,EAAa,UAAA,CACfA,CAAAA,CAASc,CAAAA,CAAW,MAAOA,CAAAA,CAAW,IAAK,EAE7Cd,CAAAA,CAMT,GAAI,CAEF,OAAOjE,CACT,CAAA,OAAE,CAEF,CACF,CCtFO,SAASkF,EACdC,CAAAA,CACkB,CAElB,IAAIC,CAAAA,CAA8C,IAAA,CAC9CZ,CAAAA,CAA+B,KAC/B1D,CAAAA,CAAsB,IAAA,CAGpBuE,EAAetF,CAAAA,EAAyB,CAE5C,GAAIqF,CAAAA,CACF,OAAOA,CAAAA,CAASrF,CAAK,CAAA,CAIvB,GAAIe,EACF,MAAMA,CAAAA,CAIR,IAAMwE,CAAAA,CAAWxB,CAAAA,GAGjB,OAAKU,CAAAA,GACHA,CAAAA,CAAUW,CAAAA,EAAO,CACd,IAAA,CAAKI,GAAU,CACdH,CAAAA,CAAWG,EAAO,QACpB,CAAC,EACA,KAAA,CAAMC,CAAAA,EAAO,CACZ1E,CAAAA,CAAQ0E,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,OAAOA,CAAG,CAAC,EAC5D,CAAC,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASd,CAAO,CAAA,CAIpB,IACT,EAGC,OAACa,CAAAA,CAAiC,MAAQ,IAAA,CACzCA,CAAAA,CAAiC,OAAA,CAAUF,CAAAA,CAEtCE,CACT","file":"chunk-HBBTT5I5.mjs","sourcesContent":["import type { FNode } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): FNode {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\nimport { renderNode, reconcile } from './render'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n /**\n * Serialized state from server\n * Typically embedded in HTML as JSON script tag\n */\n state?: SerializedState\n\n /**\n * Called when hydration completes successfully\n */\n onHydrated?: () => void\n\n /**\n * Called when hydration fails (falls back to full render)\n */\n onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (same as render.ts)\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void\n children: Set<DOMComponentInstance>\n parentInstance?: DOMComponentInstance\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n app: FNodeChild | (() => FNodeChild),\n container: HTMLElement,\n options: HydrateOptions = {}\n): void {\n const { state, onHydrated, onMismatch } = options\n\n // Store state for rehydration\n hydrationState = state || null\n\n // Initialize hydration mode\n isHydrating = true\n hydrationCursor = container.firstChild\n\n try {\n // Normalize input\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n // Hydrate the tree\n hydrateNode(fnode, container)\n\n onHydrated?.()\n } catch (error) {\n // Hydration mismatch - fall back to full render\n console.warn('[Flexium] Hydration mismatch, falling back to full render:', error)\n onMismatch?.(error as Error)\n\n // Clear and re-render\n container.innerHTML = ''\n // Import dynamically to avoid circular deps\n import('./render').then(({ render }) => {\n render(app, container)\n })\n } finally {\n isHydrating = false\n hydrationCursor = null\n hydrationState = null\n }\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n // Null/undefined/boolean -> skip empty text nodes\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n // Server might have rendered an empty text node\n skipEmptyTextNodes()\n return null\n }\n\n // String/number -> expect text node\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return hydrateTextNode(String(fnode))\n }\n\n // Array -> hydrate each child\n if (Array.isArray(fnode)) {\n const nodes: Node[] = []\n for (const child of fnode) {\n const result = hydrateNode(child, parent)\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result)\n } else {\n nodes.push(result)\n }\n }\n }\n return nodes\n }\n\n // Function (standalone) -> wrap in FNode and hydrate\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return hydrateComponent(wrappedFnode, parent)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n if (typeof fnode.type === 'string') {\n return hydrateElement(fnode)\n }\n\n if (typeof fnode.type === 'function') {\n return hydrateComponent(fnode, parent)\n }\n }\n\n return null\n}\n\nfunction skipEmptyTextNodes(): void {\n while (\n hydrationCursor &&\n hydrationCursor.nodeType === Node.TEXT_NODE &&\n (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n ) {\n hydrationCursor = hydrationCursor.nextSibling\n }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n skipEmptyTextNodes()\n\n const current = hydrationCursor\n\n if (!current) {\n // No node to hydrate - this is okay for conditional rendering\n return null\n }\n\n if (current.nodeType !== Node.TEXT_NODE) {\n // Try to find a text node nearby (whitespace handling)\n if (text.trim() === '') {\n return null\n }\n throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n }\n\n // Update cursor\n hydrationCursor = current.nextSibling\n\n return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n skipEmptyTextNodes()\n\n const current = hydrationCursor as Element\n const tag = fnode.type as string\n\n // Validate element type\n if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n }\n\n if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n }\n\n // Attach event handlers and refs (don't modify DOM structure)\n if (fnode.props) {\n for (const [key, value] of Object.entries(fnode.props)) {\n if (key === 'ref') {\n if (typeof value === 'function') {\n value(current)\n } else if (value && typeof value === 'object' && 'current' in value) {\n value.current = current\n }\n } else if (key.startsWith('on') && typeof value === 'function') {\n const eventName = key.slice(2).toLowerCase()\n current.addEventListener(eventName, value as EventListener)\n\n // Store for reconciliation\n if (!(current as any).__eventHandlers) {\n (current as any).__eventHandlers = {}\n }\n (current as any).__eventHandlers[eventName] = value\n }\n }\n }\n\n // Move cursor past this element\n hydrationCursor = current.nextSibling\n\n // Hydrate children\n if (fnode.children && fnode.children.length > 0) {\n const savedCursor = hydrationCursor\n\n hydrationCursor = current.firstChild\n\n for (const child of fnode.children) {\n hydrateNode(child, current as HTMLElement)\n }\n\n hydrationCursor = savedCursor\n }\n\n return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n const Component = fnode.type as Function\n\n // Merge props\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Handle context providers\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Generate key (same logic as render.ts)\n if (!hydratedInstanceRegistry.has(parent)) {\n hydratedInstanceRegistry.set(parent, new Map())\n }\n const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n const hasExplicitKey = fnode.key !== undefined\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n let instanceCount = 0\n const componentName = (Component as any).name || 'anonymous'\n parentRegistry.forEach((_, k) => {\n if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n instanceCount++\n }\n })\n key = `__auto_${componentName}_${instanceCount}`\n }\n\n // Create component instance\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode,\n props,\n key,\n children: new Set(),\n parentInstance: currentHydratingInstance || undefined\n }\n\n if (currentHydratingInstance) {\n currentHydratingInstance.children.add(instance)\n }\n\n parentRegistry.set(key, instance)\n\n const previousHydratingInstance = currentHydratingInstance\n currentHydratingInstance = instance\n\n try {\n // First render during hydration - just match DOM\n const result = runWithComponent(instance, () => Component(props))\n const nodes = hydrateNode(result, parent)\n instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n // Set up reactive re-rendering for future updates\n let isFirstRender = true\n const renderFn = () => {\n // Re-render with reconciliation (same logic as render.ts)\n const currentProps = instance.props\n\n // Always run the component to establish reactive tracking\n const result = runWithComponent(instance, () => Component(currentProps))\n\n if (isFirstRender) {\n isFirstRender = false\n return // Skip DOM manipulation on first render, already done during hydration\n }\n\n if (instance.nodes.length === 0) {\n const newNodes = renderNode(result, parent)\n instance.nodes = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n return\n }\n\n const firstNode = instance.nodes[0]\n const nodeParent = firstNode.parentNode as HTMLElement\n\n if (!nodeParent) {\n return\n }\n\n const marker = document.createComment('flexium-marker')\n const lastNode = instance.nodes[instance.nodes.length - 1]\n if (lastNode.nextSibling) {\n nodeParent.insertBefore(marker, lastNode.nextSibling)\n } else {\n nodeParent.appendChild(marker)\n }\n\n instance.children.clear()\n\n const tempContainer = document.createElement('div')\n const newNodes = renderNode(result, tempContainer, nodeParent)\n const newNodesArray = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n\n const reconciledNodes = reconcile(instance.nodes, newNodesArray, nodeParent, marker)\n\n nodeParent.removeChild(marker)\n\n instance.nodes = reconciledNodes\n }\n\n instance.renderFn = renderFn\n unsafeEffect(renderFn)\n\n return instance.nodes\n } finally {\n currentHydratingInstance = previousHydratingInstance\n\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n const [value] = use(SuspenseCtx)\n return value\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n const { fallback, children } = props\n\n // Track pending promises using hook for mutable Set\n const pendingSet = hook(() => new Set<Promise<any>>())\n const [, setPendingCount] = use(0)\n const [showFallback, setShowFallback] = use(false)\n\n // Register function for lazy components\n const register = (promise: Promise<any>) => {\n if (!pendingSet.has(promise)) {\n // Add to pending set\n pendingSet.add(promise)\n setPendingCount(c => c + 1)\n setShowFallback(true)\n\n // Wait for resolution\n promise.finally(() => {\n pendingSet.delete(promise)\n setPendingCount(c => {\n const newCount = c - 1\n if (newCount === 0) {\n setShowFallback(false)\n }\n return newCount\n })\n })\n }\n }\n\n const contextValue: SuspenseContextValue = {\n register,\n hasBoundary: true\n }\n\n // Render fallback or children based on pending state\n const content = showFallback ? fallback : children\n\n // Wrap content with Suspense context provider\n return {\n type: SuspenseCtx.Provider,\n props: { value: contextValue },\n children: [content],\n key: undefined\n } as any\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack for error messages\nlet componentNameStack: string[] = []\n\nexport function pushComponentName(name: string): void {\n componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n return componentNameStack\n .map(name => ` at ${name}`)\n .reverse()\n .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nlet errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n * fallback={(error, info) => <div>Error: {error.message}</div>}\n * onError={(error, info) => console.error(error)}\n * >\n * <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n const { fallback, onError, children, resetKey } = props\n\n // Error state\n const [errorState, setErrorState] = use<{\n error: Error | null\n info: ErrorInfo | null\n }>({ error: null, info: null })\n\n // Track reset key changes to clear error\n const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n if (resetKey !== prevResetKeyRef.current) {\n prevResetKeyRef.current = resetKey\n if (errorState.error !== null) {\n setErrorState({ error: null, info: null })\n }\n }\n\n // Error boundary instance\n const boundaryInstance: ErrorBoundaryInstance = {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n const info: ErrorInfo = {\n componentStack: getComponentStack(),\n phase\n }\n\n // Call error callback\n onError?.(error, info)\n\n // Update error state (triggers re-render with fallback)\n setErrorState({ error, info })\n }\n }\n\n // If we have an error, render fallback\n if (errorState.error) {\n if (typeof fallback === 'function') {\n return fallback(errorState.error, errorState.info!)\n }\n return fallback\n }\n\n // Push boundary onto stack for children to use\n pushErrorBoundary(boundaryInstance)\n\n try {\n // Return children - they will be rendered with this boundary active\n return children\n } finally {\n popErrorBoundary()\n }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function lazy<P = {}>(\n loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n // Shared state across all instances\n let resolved: ((props: P) => FNodeChild) | null = null\n let promise: Promise<any> | null = null\n let error: Error | null = null\n\n // The wrapper component\n const LazyWrapper = (props: P): FNodeChild => {\n // If already resolved, render immediately\n if (resolved) {\n return resolved(props)\n }\n\n // If error occurred, throw it (will be caught by ErrorBoundary)\n if (error) {\n throw error\n }\n\n // Get suspense context\n const suspense = suspenseContext()\n\n // Start loading if not already\n if (!promise) {\n promise = loader()\n .then(module => {\n resolved = module.default\n })\n .catch(err => {\n error = err instanceof Error ? err : new Error(String(err))\n })\n }\n\n // Register with suspense boundary if available\n if (suspense.hasBoundary) {\n suspense.register(promise)\n }\n\n // Return null - Suspense will show fallback\n return null\n }\n\n // Mark as lazy component\n ;(LazyWrapper as LazyComponent<P>)._lazy = true\n ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n return LazyWrapper as LazyComponent<P>\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkVNYPOCV7_js=require('./chunk-VNYPOCV7.js');var $={"&":"&","<":"<",">":">",'"':""","'":"'"},F=/[&<>"']/g;function l(e){return String(e).replace(F,r=>$[r])}function a(e){return l(e)}var f=false,d=null,h=0;function I(){return f}function b(){f=true,d=new Map,h=0;}function S(){f=false;let e=Object.fromEntries(d||new Map);return d=null,{states:e}}function x(){return `fid-${h++}`}var T=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),v=new Set(["disabled","checked","readonly","required","hidden","selected","autofocus","autoplay","controls","loop","muted","multiple","open","defer","async","novalidate"]),A={className:"class",htmlFor:"for"};function R(e,r={}){let{hydrate:n=true}=r;b();try{let t;typeof e=="function"&&!N(e)?t={type:e,props:{},children:[],key:void 0}:t=e;let o=p(t,n),i=S();return {html:o,state:i}}catch(t){throw S(),t}}function E(e){let{html:r}=R(e,{hydrate:false});return r}function N(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function p(e,r){if(e==null||typeof e=="boolean")return "";if(typeof e=="string"||typeof e=="number")return l(String(e));if(Array.isArray(e))return e.map(n=>p(n,r)).join("");if(typeof e=="function")return C({type:e,props:{},children:[]},r);if(typeof e=="object"&&N(e)){if(typeof e.type=="string")return w(e,r);if(typeof e.type=="function")return C(e,r)}return ""}function w(e,r){let n=e.type,t=j(e.props,r);if(e.props?.dangerouslySetInnerHTML){let i=e.props.dangerouslySetInnerHTML.__html||"";return `<${n}${t}>${i}</${n}>`}if(T.has(n))return `<${n}${t}>`;let o=(e.children||[]).map(i=>p(i,r)).join("");return `<${n}${t}>${o}</${n}>`}function j(e,r){if(!e)return "";let n=[];if(r){let t=x();n.push(`data-fid="${t}"`);}for(let[t,o]of Object.entries(e)){if(t.startsWith("on")||t==="ref"||t==="key"||t==="children"||t==="dangerouslySetInnerHTML"||o==null)continue;let i=A[t]||t;if(t==="style"&&typeof o=="object"){let c=Object.entries(o).filter(([,s])=>s!=null).map(([s,u])=>`${k(s)}:${u}`).join(";");c&&n.push(`style="${a(c)}"`);continue}if(v.has(i)){o&&n.push(i);continue}o!==false&&n.push(`${i}="${a(String(o))}"`);}return n.length?" "+n.join(" "):""}function C(e,r){let n=e.type,t={...e.props};e.children&&e.children.length>0&&(t.children=e.children.length===1?e.children[0]:e.children);let o=n._contextId,i=o!==void 0,c;i&&(c=chunkVNYPOCV7_js.g(o,t.value));let s={hooks:[],hookIndex:0};try{let u=chunkVNYPOCV7_js.a(s,()=>n(t));return p(u,r)}finally{i&&chunkVNYPOCV7_js.h(o,c);}}function k(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}exports.a=I;exports.b=R;exports.c=E;//# sourceMappingURL=chunk-HUE2TOCR.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-HUE2TOCR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/escape.ts","../src/server/serverState.ts","../src/server/renderToString.ts"],"names":["ESCAPE_MAP","ESCAPE_REGEX","escapeHtml","str","char","escapeAttribute","isServerRendering","serverStateCollector","hydrationIdCounter","getIsServer","enterServerRender","exitServerRender","states","generateHydrationId","VOID_ELEMENTS","BOOLEAN_ATTRS","ATTR_ALIASES","renderToString","app","options","hydrate","fnode","isFNode","html","renderNodeToString","state","error","renderToStaticMarkup","value","includeHydrationMarkers","child","renderComponentToString","renderElementToString","tag","attrs","renderAttributes","innerHTML","childrenHtml","props","parts","fid","key","attrName","styleStr","v","k","kebabCase","Component","contextId","isProvider","prevContextValue","pushContext","instance","result","runWithComponent","popContext"],"mappings":"iEAAA,IAAMA,EAAqC,CACzC,GAAA,CAAK,OAAA,CACL,GAAA,CAAK,OACL,GAAA,CAAK,MAAA,CACL,GAAA,CAAK,QAAA,CACL,IAAK,QACP,CAAA,CAEMC,CAAAA,CAAe,UAAA,CAEd,SAASC,C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AAA,CAAqB,CACtC,OAAOA,CAAAA,CAAI,OAAA,CAAQ,WAAY,KAAK,CAAA,CAAE,aACxC","file":"chunk-HUE2TOCR.js","sourcesContent":["const ESCAPE_MAP: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n}\n\nconst ESCAPE_REGEX = /[&<>\"']/g\n\nexport function escapeHtml(str: string): string {\n return String(str).replace(ESCAPE_REGEX, char => ESCAPE_MAP[char])\n}\n\nexport function escapeAttribute(str: string): string {\n return escapeHtml(str)\n}\n","import type { SerializedState } from './types'\n\nlet isServerRendering = false\nlet serverStateCollector: Map<string, unknown> | null = null\nlet hydrationIdCounter = 0\n\nexport function getIsServer(): boolean {\n return isServerRendering\n}\n\nexport function enterServerRender(): void {\n isServerRendering = true\n serverStateCollector = new Map()\n hydrationIdCounter = 0\n}\n\nexport function exitServerRender(): SerializedState {\n isServerRendering = false\n const states = Object.fromEntries(serverStateCollector || new Map())\n serverStateCollector = null\n\n return { states }\n}\n\nexport function collectServerState(key: string, value: unknown): void {\n if (serverStateCollector) {\n serverStateCollector.set(key, value)\n }\n}\n\nexport function generateHydrationId(): string {\n return `fid-${hydrationIdCounter++}`\n}\n\nexport function resetHydrationIdCounter(): void {\n hydrationIdCounter = 0\n}\n","import type { FNode, FNodeChild } from '../dom/types'\nimport type { SSROptions, SSRResult } from './types'\nimport { escapeHtml, escapeAttribute } from './escape'\nimport {\n enterServerRender,\n exitServerRender,\n generateHydrationId\n} from './serverState'\nimport { runWithComponent, ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\n\n// Self-closing HTML tags\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n])\n\n// Attributes that should be rendered as boolean\nconst BOOLEAN_ATTRS = new Set([\n 'disabled', 'checked', 'readonly', 'required', 'hidden',\n 'selected', 'autofocus', 'autoplay', 'controls', 'loop', 'muted',\n 'multiple', 'open', 'defer', 'async', 'novalidate'\n])\n\n// Attributes that need special handling\nconst ATTR_ALIASES: Record<string, string> = {\n className: 'class',\n htmlFor: 'for'\n}\n\n/**\n * Render component tree to HTML string with hydration markers\n */\nexport function renderToString(\n app: FNodeChild | (() => FNodeChild),\n options: SSROptions = {}\n): SSRResult {\n const { hydrate = true } = options\n\n enterServerRender()\n\n try {\n // Normalize input - wrap function in FNode if needed\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n const html = renderNodeToString(fnode, hydrate)\n const state = exitServerRender()\n\n return { html, state }\n } catch (error) {\n exitServerRender()\n throw error\n }\n}\n\n/**\n * Render component tree to static HTML (no hydration markers)\n * Use for email templates, static pages, etc.\n */\nexport function renderToStaticMarkup(app: FNodeChild | (() => FNodeChild)): string {\n const { html } = renderToString(app, { hydrate: false })\n return html\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction renderNodeToString(fnode: FNodeChild, includeHydrationMarkers: boolean): string {\n // Null/undefined/boolean -> empty string\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n return ''\n }\n\n // String/number -> escaped text\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return escapeHtml(String(fnode))\n }\n\n // Array -> concatenate children\n if (Array.isArray(fnode)) {\n return fnode.map(child => renderNodeToString(child, includeHydrationMarkers)).join('')\n }\n\n // Function (standalone) -> wrap in FNode and render\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return renderComponentToString(wrappedFnode, includeHydrationMarkers)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n // HTML element\n if (typeof fnode.type === 'string') {\n return renderElementToString(fnode, includeHydrationMarkers)\n }\n\n // Function component\n if (typeof fnode.type === 'function') {\n return renderComponentToString(fnode, includeHydrationMarkers)\n }\n }\n\n return ''\n}\n\nfunction renderElementToString(fnode: FNode, includeHydrationMarkers: boolean): string {\n const tag = fnode.type as string\n const attrs = renderAttributes(fnode.props, includeHydrationMarkers)\n\n // Handle dangerouslySetInnerHTML\n if (fnode.props?.dangerouslySetInnerHTML) {\n const innerHTML = fnode.props.dangerouslySetInnerHTML.__html || ''\n return `<${tag}${attrs}>${innerHTML}</${tag}>`\n }\n\n // Void elements (self-closing)\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrs}>`\n }\n\n // Render children\n const childrenHtml = (fnode.children || [])\n .map(child => renderNodeToString(child, includeHydrationMarkers))\n .join('')\n\n return `<${tag}${attrs}>${childrenHtml}</${tag}>`\n}\n\nfunction renderAttributes(props: Record<string, any>, includeHydrationMarkers: boolean): string {\n if (!props) return ''\n\n const parts: string[] = []\n\n // Add hydration ID if needed\n if (includeHydrationMarkers) {\n const fid = generateHydrationId()\n parts.push(`data-fid=\"${fid}\"`)\n }\n\n for (const [key, value] of Object.entries(props)) {\n // Skip event handlers, refs, and internal props\n if (key.startsWith('on') || key === 'ref' || key === 'key' || key === 'children') continue\n if (key === 'dangerouslySetInnerHTML') continue\n\n // Skip undefined/null values\n if (value === undefined || value === null) continue\n\n // Handle aliased attributes\n const attrName = ATTR_ALIASES[key] || key\n\n // Handle style object\n if (key === 'style' && typeof value === 'object') {\n const styleStr = Object.entries(value)\n .filter(([, v]) => v !== null && v !== undefined)\n .map(([k, v]) => `${kebabCase(k)}:${v}`)\n .join(';')\n if (styleStr) {\n parts.push(`style=\"${escapeAttribute(styleStr)}\"`)\n }\n continue\n }\n\n // Handle boolean attributes\n if (BOOLEAN_ATTRS.has(attrName)) {\n if (value) parts.push(attrName)\n continue\n }\n\n // Handle false boolean values - skip entirely\n if (value === false) continue\n\n // Regular attribute\n parts.push(`${attrName}=\"${escapeAttribute(String(value))}\"`)\n }\n\n return parts.length ? ' ' + parts.join(' ') : ''\n}\n\nfunction renderComponentToString(fnode: FNode, includeHydrationMarkers: boolean): string {\n const Component = fnode.type as Function\n\n // Merge props with children\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Check if this is a Context Provider\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Create minimal component instance for server (hooks support)\n const instance: ComponentInstance = {\n hooks: [],\n hookIndex: 0\n }\n\n try {\n // Run component with hook context\n const result = runWithComponent(instance, () => Component(props))\n\n // Render result\n return renderNodeToString(result, includeHydrationMarkers)\n } finally {\n // Restore context if it was a provider\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n\nfunction kebabCase(str: string): string {\n return str.replace(/([A-Z])/g, '-$1').toLowerCase()\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkTHUSQSDY_js=require('./chunk-THUSQSDY.js'),chunkLOKMOGSA_js=require('./chunk-LOKMOGSA.js'),chunk3CKIHQIE_js=require('./chunk-3CKIHQIE.js'),chunkVNYPOCV7_js=require('./chunk-VNYPOCV7.js');function Q(e,n,...t){return {type:e,props:n||{},children:t,key:n?.key}}var p=null,w=new WeakMap,h=null;function U(e,n,t={}){let{state:o,onHydrated:r,onMismatch:a}=t;p=n.firstChild;try{let i;typeof e=="function"&&!$(e)?i={type:e,props:{},children:[],key:void 0}:i=e,F(i,n),r?.();}catch(i){console.warn("[Flexium] Hydration mismatch, falling back to full render:",i),a?.(i),n.innerHTML="",import('./render-IBWAHNEZ.js').then(({render:l})=>{l(e,n);});}finally{p=null;}}function $(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function F(e,n){if(e==null||typeof e=="boolean")return H(),null;if(typeof e=="string"||typeof e=="number")return Y(String(e));if(Array.isArray(e)){let t=[];for(let o of e){let r=F(o,n);r&&(Array.isArray(r)?t.push(...r):t.push(r));}return t}if(typeof e=="function")return V({type:e,props:{},children:[],key:void 0},n);if(typeof e=="object"&&$(e)){if(typeof e.type=="string")return Z(e);if(typeof e.type=="function")return V(e,n)}return null}function H(){for(;p&&p.nodeType===Node.TEXT_NODE&&(!p.textContent||p.textContent.trim()==="");)p=p.nextSibling;}function Y(e){H();let n=p;if(!n)return null;if(n.nodeType!==Node.TEXT_NODE){if(e.trim()==="")return null;throw new Error(`Hydration mismatch: expected text node "${e}", got ${n.nodeName}`)}return p=n.nextSibling,n}function Z(e){H();let n=p,t=e.type;if(!n||n.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${t}>, got ${n?.nodeName||"nothing"}`);if(n.tagName.toLowerCase()!==t.toLowerCase())throw new Error(`Hydration mismatch: expected <${t}>, got <${n.tagName.toLowerCase()}>`);if(e.props){for(let[o,r]of Object.entries(e.props))if(o==="ref")typeof r=="function"?r(n):r&&typeof r=="object"&&"current"in r&&(r.current=n);else if(o.startsWith("on")&&typeof r=="function"){let a=o.slice(2).toLowerCase();n.addEventListener(a,r),n.__eventHandlers||(n.__eventHandlers={}),n.__eventHandlers[a]=r;}}if(p=n.nextSibling,e.children&&e.children.length>0){let o=p;p=n.firstChild;for(let r of e.children)F(r,n);p=o;}return n}function V(e,n){let t=e.type,o={...e.props};e.children&&e.children.length>0&&(o.children=e.children.length===1?e.children[0]:e.children);let r=t._contextId,a=r!==void 0,i;a&&(i=chunkVNYPOCV7_js.g(r,o.value)),w.has(n)||w.set(n,new Map);let l=w.get(n),C=e.key!==void 0,u;if(C)u=e.key;else {let c=0,y=t.name||"anonymous";l.forEach((v,x)=>{typeof x=="string"&&x.startsWith(`__auto_${y}_`)&&c++;}),u=`__auto_${y}_${c}`;}let s={hooks:[],hookIndex:0,nodes:[],parent:n,fnode:e,props:o,key:u,children:new Set,parentInstance:h||void 0};h&&h.children.add(s),l.set(u,s);let d=h;h=s;try{let c=chunkVNYPOCV7_js.a(s,()=>t(o)),y=F(c,n);s.nodes=y?Array.isArray(y)?y:[y]:[];let v=!0,x=()=>{let X=s.props,B=chunkVNYPOCV7_js.a(s,()=>t(X));if(v){v=!1;return}if(s.nodes.length===0){let g=chunkTHUSQSDY_js.a(B,n);s.nodes=g?Array.isArray(g)?g:[g]:[];return}let m=s.nodes[0].parentNode;if(!m)return;let E=document.createComment("flexium-marker"),L=s.nodes[s.nodes.length-1];L.nextSibling?m.insertBefore(E,L.nextSibling):m.appendChild(E),s.children.clear();let q=document.createElement("div"),N=chunkTHUSQSDY_js.a(B,q,m),G=N?Array.isArray(N)?N:[N]:[],J=chunkTHUSQSDY_js.b(s.nodes,G,m,E);m.removeChild(E),s.nodes=J;};return s.renderFn=x,chunk3CKIHQIE_js.b(x),s.nodes}finally{h=d,a&&chunkVNYPOCV7_js.h(r,i);}}var ee={register:()=>{},hasBoundary:false},P=new chunkVNYPOCV7_js.e(ee);function D(){let[e]=chunkLOKMOGSA_js.c(P);return e}function j(e){let{fallback:n,children:t}=e,o=chunkVNYPOCV7_js.b(()=>new Set),[,r]=chunkLOKMOGSA_js.c(0),[a,i]=chunkLOKMOGSA_js.c(false),C={register:s=>{o.has(s)||(o.add(s),r(d=>d+1),i(true),s.finally(()=>{o.delete(s),r(d=>{let c=d-1;return c===0&&i(false),c});}));},hasBoundary:true},u=a?n:t;return {type:P.Provider,props:{value:C},children:[u],key:void 0}}function W(e){let{fallback:n,onError:t,children:o,resetKey:r}=e,[a,i]=chunkLOKMOGSA_js.c({error:null,info:null}),l=chunkVNYPOCV7_js.b(()=>({current:r}));r!==l.current&&(l.current=r,a.error!==null&&i({error:null,info:null}));if(a.error)return typeof n=="function"?n(a.error,a.info):n;try{return o}finally{}}function K(e){let n=null,t=null,o=null,r=a=>{if(n)return n(a);if(o)throw o;let i=D();return t||(t=e().then(l=>{n=l.default;}).catch(l=>{o=l instanceof Error?l:new Error(String(l));})),i.hasBoundary&&i.register(t),null};return r._lazy=true,r._loader=e,r}exports.a=Q;exports.b=U;exports.c=j;exports.d=W;exports.e=K;//# sourceMappingURL=chunk-JNWUZKHF.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-JNWUZKHF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","newNodes","renderNode","nodeParent","marker","lastNode","tempContainer","newNodesArray","reconciledNodes","reconcile","unsafeEffect","popContext","defaultValue","SuspenseCtx","Context","suspenseContext","use","Suspense","fallback","pendingSet","hook","setPendingCount","showFallback","setShowFallback","contextValue","promise","c","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"iNAKO,SAASA,CAAAA,CACZC,CAAAA,CACAC,CAAAA,CAAAA,GACGC,CAAAA,CACE,CACL,OAAO,CACH,IAAA,CAAAF,CAAAA,CACA,KAAA,CAAOC,CAAAA,EAAS,GAChB,QAAA,CAAAC,CAAAA,CACA,GAAA,CAAKD,CAAAA,EAAO,GAChB,CACJ,CCRA,IACIE,CAAAA,CAA+B,IAAA,CAkC7BC,EAA2B,IAAI,OAAA,CACjCC,CAAAA,CAAwD,KAarD,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CACrB,CACN,GAAM,CAAE,MAAAC,CAAAA,CAAO,UAAA,CAAAC,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,CAAAA,CAAgB,OAAA,GAC/BA,CAAAA,CAAgB,OAAA,CAAUH,EACtBC,CAAAA,CAAW,KAAA,GAAU,MACvBC,CAAAA,CAAc,CAAE,MAAO,IAAA,CAAM,IAAA,CAAM,IAAK,CAAC,CAAA,CAAA,CAqB7C,GAAID,CAAAA,CAAW,MACb,OAAI,OAAOd,CAAAA,EAAa,UAAA,CACfA,CAAAA,CAASc,CAAAA,CAAW,MAAOA,CAAAA,CAAW,IAAK,EAE7Cd,CAAAA,CAMT,GAAI,CAEF,OAAOjE,CACT,CAAA,OAAE,CAEF,CACF,CCtFO,SAASkF,EACdC,CAAAA,CACkB,CAElB,IAAIC,CAAAA,CAA8C,IAAA,CAC9CZ,CAAAA,CAA+B,KAC/B1D,CAAAA,CAAsB,IAAA,CAGpBuE,EAAetF,CAAAA,EAAyB,CAE5C,GAAIqF,CAAAA,CACF,OAAOA,CAAAA,CAASrF,CAAK,CAAA,CAIvB,GAAIe,EACF,MAAMA,CAAAA,CAIR,IAAMwE,CAAAA,CAAWxB,CAAAA,GAGjB,OAAKU,CAAAA,GACHA,CAAAA,CAAUW,CAAAA,EAAO,CACd,IAAA,CAAKI,GAAU,CACdH,CAAAA,CAAWG,EAAO,QACpB,CAAC,EACA,KAAA,CAAMC,CAAAA,EAAO,CACZ1E,CAAAA,CAAQ0E,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,OAAOA,CAAG,CAAC,EAC5D,CAAC,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASd,CAAO,CAAA,CAIpB,IACT,EAGC,OAACa,CAAAA,CAAiC,MAAQ,IAAA,CACzCA,CAAAA,CAAiC,OAAA,CAAUF,CAAAA,CAEtCE,CACT","file":"chunk-JNWUZKHF.js","sourcesContent":["import type { FNode } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): FNode {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\nimport { renderNode, reconcile } from './render'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n /**\n * Serialized state from server\n * Typically embedded in HTML as JSON script tag\n */\n state?: SerializedState\n\n /**\n * Called when hydration completes successfully\n */\n onHydrated?: () => void\n\n /**\n * Called when hydration fails (falls back to full render)\n */\n onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (same as render.ts)\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void\n children: Set<DOMComponentInstance>\n parentInstance?: DOMComponentInstance\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n app: FNodeChild | (() => FNodeChild),\n container: HTMLElement,\n options: HydrateOptions = {}\n): void {\n const { state, onHydrated, onMismatch } = options\n\n // Store state for rehydration\n hydrationState = state || null\n\n // Initialize hydration mode\n isHydrating = true\n hydrationCursor = container.firstChild\n\n try {\n // Normalize input\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n // Hydrate the tree\n hydrateNode(fnode, container)\n\n onHydrated?.()\n } catch (error) {\n // Hydration mismatch - fall back to full render\n console.warn('[Flexium] Hydration mismatch, falling back to full render:', error)\n onMismatch?.(error as Error)\n\n // Clear and re-render\n container.innerHTML = ''\n // Import dynamically to avoid circular deps\n import('./render').then(({ render }) => {\n render(app, container)\n })\n } finally {\n isHydrating = false\n hydrationCursor = null\n hydrationState = null\n }\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n // Null/undefined/boolean -> skip empty text nodes\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n // Server might have rendered an empty text node\n skipEmptyTextNodes()\n return null\n }\n\n // String/number -> expect text node\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return hydrateTextNode(String(fnode))\n }\n\n // Array -> hydrate each child\n if (Array.isArray(fnode)) {\n const nodes: Node[] = []\n for (const child of fnode) {\n const result = hydrateNode(child, parent)\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result)\n } else {\n nodes.push(result)\n }\n }\n }\n return nodes\n }\n\n // Function (standalone) -> wrap in FNode and hydrate\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return hydrateComponent(wrappedFnode, parent)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n if (typeof fnode.type === 'string') {\n return hydrateElement(fnode)\n }\n\n if (typeof fnode.type === 'function') {\n return hydrateComponent(fnode, parent)\n }\n }\n\n return null\n}\n\nfunction skipEmptyTextNodes(): void {\n while (\n hydrationCursor &&\n hydrationCursor.nodeType === Node.TEXT_NODE &&\n (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n ) {\n hydrationCursor = hydrationCursor.nextSibling\n }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n skipEmptyTextNodes()\n\n const current = hydrationCursor\n\n if (!current) {\n // No node to hydrate - this is okay for conditional rendering\n return null\n }\n\n if (current.nodeType !== Node.TEXT_NODE) {\n // Try to find a text node nearby (whitespace handling)\n if (text.trim() === '') {\n return null\n }\n throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n }\n\n // Update cursor\n hydrationCursor = current.nextSibling\n\n return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n skipEmptyTextNodes()\n\n const current = hydrationCursor as Element\n const tag = fnode.type as string\n\n // Validate element type\n if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n }\n\n if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n }\n\n // Attach event handlers and refs (don't modify DOM structure)\n if (fnode.props) {\n for (const [key, value] of Object.entries(fnode.props)) {\n if (key === 'ref') {\n if (typeof value === 'function') {\n value(current)\n } else if (value && typeof value === 'object' && 'current' in value) {\n value.current = current\n }\n } else if (key.startsWith('on') && typeof value === 'function') {\n const eventName = key.slice(2).toLowerCase()\n current.addEventListener(eventName, value as EventListener)\n\n // Store for reconciliation\n if (!(current as any).__eventHandlers) {\n (current as any).__eventHandlers = {}\n }\n (current as any).__eventHandlers[eventName] = value\n }\n }\n }\n\n // Move cursor past this element\n hydrationCursor = current.nextSibling\n\n // Hydrate children\n if (fnode.children && fnode.children.length > 0) {\n const savedCursor = hydrationCursor\n\n hydrationCursor = current.firstChild\n\n for (const child of fnode.children) {\n hydrateNode(child, current as HTMLElement)\n }\n\n hydrationCursor = savedCursor\n }\n\n return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n const Component = fnode.type as Function\n\n // Merge props\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Handle context providers\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Generate key (same logic as render.ts)\n if (!hydratedInstanceRegistry.has(parent)) {\n hydratedInstanceRegistry.set(parent, new Map())\n }\n const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n const hasExplicitKey = fnode.key !== undefined\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n let instanceCount = 0\n const componentName = (Component as any).name || 'anonymous'\n parentRegistry.forEach((_, k) => {\n if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n instanceCount++\n }\n })\n key = `__auto_${componentName}_${instanceCount}`\n }\n\n // Create component instance\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode,\n props,\n key,\n children: new Set(),\n parentInstance: currentHydratingInstance || undefined\n }\n\n if (currentHydratingInstance) {\n currentHydratingInstance.children.add(instance)\n }\n\n parentRegistry.set(key, instance)\n\n const previousHydratingInstance = currentHydratingInstance\n currentHydratingInstance = instance\n\n try {\n // First render during hydration - just match DOM\n const result = runWithComponent(instance, () => Component(props))\n const nodes = hydrateNode(result, parent)\n instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n // Set up reactive re-rendering for future updates\n let isFirstRender = true\n const renderFn = () => {\n // Re-render with reconciliation (same logic as render.ts)\n const currentProps = instance.props\n\n // Always run the component to establish reactive tracking\n const result = runWithComponent(instance, () => Component(currentProps))\n\n if (isFirstRender) {\n isFirstRender = false\n return // Skip DOM manipulation on first render, already done during hydration\n }\n\n if (instance.nodes.length === 0) {\n const newNodes = renderNode(result, parent)\n instance.nodes = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n return\n }\n\n const firstNode = instance.nodes[0]\n const nodeParent = firstNode.parentNode as HTMLElement\n\n if (!nodeParent) {\n return\n }\n\n const marker = document.createComment('flexium-marker')\n const lastNode = instance.nodes[instance.nodes.length - 1]\n if (lastNode.nextSibling) {\n nodeParent.insertBefore(marker, lastNode.nextSibling)\n } else {\n nodeParent.appendChild(marker)\n }\n\n instance.children.clear()\n\n const tempContainer = document.createElement('div')\n const newNodes = renderNode(result, tempContainer, nodeParent)\n const newNodesArray = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n\n const reconciledNodes = reconcile(instance.nodes, newNodesArray, nodeParent, marker)\n\n nodeParent.removeChild(marker)\n\n instance.nodes = reconciledNodes\n }\n\n instance.renderFn = renderFn\n unsafeEffect(renderFn)\n\n return instance.nodes\n } finally {\n currentHydratingInstance = previousHydratingInstance\n\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n const [value] = use(SuspenseCtx)\n return value\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n const { fallback, children } = props\n\n // Track pending promises using hook for mutable Set\n const pendingSet = hook(() => new Set<Promise<any>>())\n const [, setPendingCount] = use(0)\n const [showFallback, setShowFallback] = use(false)\n\n // Register function for lazy components\n const register = (promise: Promise<any>) => {\n if (!pendingSet.has(promise)) {\n // Add to pending set\n pendingSet.add(promise)\n setPendingCount(c => c + 1)\n setShowFallback(true)\n\n // Wait for resolution\n promise.finally(() => {\n pendingSet.delete(promise)\n setPendingCount(c => {\n const newCount = c - 1\n if (newCount === 0) {\n setShowFallback(false)\n }\n return newCount\n })\n })\n }\n }\n\n const contextValue: SuspenseContextValue = {\n register,\n hasBoundary: true\n }\n\n // Render fallback or children based on pending state\n const content = showFallback ? fallback : children\n\n // Wrap content with Suspense context provider\n return {\n type: SuspenseCtx.Provider,\n props: { value: contextValue },\n children: [content],\n key: undefined\n } as any\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack for error messages\nlet componentNameStack: string[] = []\n\nexport function pushComponentName(name: string): void {\n componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n return componentNameStack\n .map(name => ` at ${name}`)\n .reverse()\n .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nlet errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n * fallback={(error, info) => <div>Error: {error.message}</div>}\n * onError={(error, info) => console.error(error)}\n * >\n * <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n const { fallback, onError, children, resetKey } = props\n\n // Error state\n const [errorState, setErrorState] = use<{\n error: Error | null\n info: ErrorInfo | null\n }>({ error: null, info: null })\n\n // Track reset key changes to clear error\n const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n if (resetKey !== prevResetKeyRef.current) {\n prevResetKeyRef.current = resetKey\n if (errorState.error !== null) {\n setErrorState({ error: null, info: null })\n }\n }\n\n // Error boundary instance\n const boundaryInstance: ErrorBoundaryInstance = {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n const info: ErrorInfo = {\n componentStack: getComponentStack(),\n phase\n }\n\n // Call error callback\n onError?.(error, info)\n\n // Update error state (triggers re-render with fallback)\n setErrorState({ error, info })\n }\n }\n\n // If we have an error, render fallback\n if (errorState.error) {\n if (typeof fallback === 'function') {\n return fallback(errorState.error, errorState.info!)\n }\n return fallback\n }\n\n // Push boundary onto stack for children to use\n pushErrorBoundary(boundaryInstance)\n\n try {\n // Return children - they will be rendered with this boundary active\n return children\n } finally {\n popErrorBoundary()\n }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function lazy<P = {}>(\n loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n // Shared state across all instances\n let resolved: ((props: P) => FNodeChild) | null = null\n let promise: Promise<any> | null = null\n let error: Error | null = null\n\n // The wrapper component\n const LazyWrapper = (props: P): FNodeChild => {\n // If already resolved, render immediately\n if (resolved) {\n return resolved(props)\n }\n\n // If error occurred, throw it (will be caught by ErrorBoundary)\n if (error) {\n throw error\n }\n\n // Get suspense context\n const suspense = suspenseContext()\n\n // Start loading if not already\n if (!promise) {\n promise = loader()\n .then(module => {\n resolved = module.default\n })\n .catch(err => {\n error = err instanceof Error ? err : new Error(String(err))\n })\n }\n\n // Register with suspense boundary if available\n if (suspense.hasBoundary) {\n suspense.register(promise)\n }\n\n // Return null - Suspense will show fallback\n return null\n }\n\n // Mark as lazy component\n ;(LazyWrapper as LazyComponent<P>)._lazy = true\n ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n return LazyWrapper as LazyComponent<P>\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/ref.ts"],"names":["useRef","initialValue","hook"],"mappings":"qCA2BO,SAASA,CAAAA,CAAUC,CAAAA,CAA4C,CACpE,OAAOC,CAAAA,CAAK,KAAO,CACjB,OAAA,CAASD,CACX,CAAA,CAAE,CACJ","file":"chunk-PPPU2XSA.mjs","sourcesContent":["import { hook } from './hook'\nimport type { RefObject } from './types'\n\n/**\n * Creates a mutable ref object that persists across renders\n *\n * @example\n * ```tsx\n * function InputWithFocus() {\n * const inputRef = useRef<HTMLInputElement>()\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 Input</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRef<T>(initialValue: T): RefObject<T>\nexport function useRef<T>(initialValue: T | null): RefObject<T | null>\nexport function useRef<T = undefined>(): RefObject<T | undefined>\nexport function useRef<T>(initialValue?: T): RefObject<T | undefined> {\n return hook(() => ({\n current: initialValue\n }))\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {g,a as a$1,h as h$1}from'./chunk-WHRUAZR4.mjs';var $={"&":"&","<":"<",">":">",'"':""","'":"'"},F=/[&<>"']/g;function l(e){return String(e).replace(F,r=>$[r])}function a(e){return l(e)}var f=false,d=null,h=0;function I(){return f}function b(){f=true,d=new Map,h=0;}function S(){f=false;let e=Object.fromEntries(d||new Map);return d=null,{states:e}}function x(){return `fid-${h++}`}var T=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),v=new Set(["disabled","checked","readonly","required","hidden","selected","autofocus","autoplay","controls","loop","muted","multiple","open","defer","async","novalidate"]),A={className:"class",htmlFor:"for"};function R(e,r={}){let{hydrate:n=true}=r;b();try{let t;typeof e=="function"&&!N(e)?t={type:e,props:{},children:[],key:void 0}:t=e;let o=p(t,n),i=S();return {html:o,state:i}}catch(t){throw S(),t}}function E(e){let{html:r}=R(e,{hydrate:false});return r}function N(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function p(e,r){if(e==null||typeof e=="boolean")return "";if(typeof e=="string"||typeof e=="number")return l(String(e));if(Array.isArray(e))return e.map(n=>p(n,r)).join("");if(typeof e=="function")return C({type:e,props:{},children:[]},r);if(typeof e=="object"&&N(e)){if(typeof e.type=="string")return w(e,r);if(typeof e.type=="function")return C(e,r)}return ""}function w(e,r){let n=e.type,t=j(e.props,r);if(e.props?.dangerouslySetInnerHTML){let i=e.props.dangerouslySetInnerHTML.__html||"";return `<${n}${t}>${i}</${n}>`}if(T.has(n))return `<${n}${t}>`;let o=(e.children||[]).map(i=>p(i,r)).join("");return `<${n}${t}>${o}</${n}>`}function j(e,r){if(!e)return "";let n=[];if(r){let t=x();n.push(`data-fid="${t}"`);}for(let[t,o]of Object.entries(e)){if(t.startsWith("on")||t==="ref"||t==="key"||t==="children"||t==="dangerouslySetInnerHTML"||o==null)continue;let i=A[t]||t;if(t==="style"&&typeof o=="object"){let c=Object.entries(o).filter(([,s])=>s!=null).map(([s,u])=>`${k(s)}:${u}`).join(";");c&&n.push(`style="${a(c)}"`);continue}if(v.has(i)){o&&n.push(i);continue}o!==false&&n.push(`${i}="${a(String(o))}"`);}return n.length?" "+n.join(" "):""}function C(e,r){let n=e.type,t={...e.props};e.children&&e.children.length>0&&(t.children=e.children.length===1?e.children[0]:e.children);let o=n._contextId,i=o!==void 0,c;i&&(c=g(o,t.value));let s={hooks:[],hookIndex:0};try{let u=a$1(s,()=>n(t));return p(u,r)}finally{i&&h$1(o,c);}}function k(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}export{I as a,R as b,E as c};//# sourceMappingURL=chunk-S5DHAAMO.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-S5DHAAMO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/escape.ts","../src/server/serverState.ts","../src/server/renderToString.ts"],"names":["ESCAPE_MAP","ESCAPE_REGEX","escapeHtml","str","char","escapeAttribute","isServerRendering","serverStateCollector","hydrationIdCounter","getIsServer","enterServerRender","exitServerRender","states","generateHydrationId","VOID_ELEMENTS","BOOLEAN_ATTRS","ATTR_ALIASES","renderToString","app","options","hydrate","fnode","isFNode","html","renderNodeToString","state","error","renderToStaticMarkup","value","includeHydrationMarkers","child","renderComponentToString","renderElementToString","tag","attrs","renderAttributes","innerHTML","childrenHtml","props","parts","fid","key","attrName","styleStr","v","k","kebabCase","Component","contextId","isProvider","prevContextValue","pushContext","instance","result","runWithComponent","popContext"],"mappings":"uDAAA,IAAMA,EAAqC,CACzC,GAAA,CAAK,OAAA,CACL,GAAA,CAAK,OACL,GAAA,CAAK,MAAA,CACL,GAAA,CAAK,QAAA,CACL,IAAK,QACP,CAAA,CAEMC,CAAAA,CAAe,UAAA,CAEd,SAASC,CAAAA,CAAWC,CAAAA,CAAqB,CAC9C,OAAO,OAAOA,CAAG,CAAA,CAAE,OAAA,CAAQF,CAAAA,CAAcG,GAAQJ,CAAAA,CAAWI,CAAI,CAAC,CACnE,CAEO,SAASC,CAAAA,CAAgBF,EAAqB,CACnD,OAAOD,EAAWC,CAAG,CACvB,CCdA,IAAIG,EAAoB,KAAA,CACpBC,CAAAA,CAAoD,IAAA,CACpDC,CAAAA,CAAqB,EAElB,SAASC,CAAAA,EAAuB,CACrC,OAAOH,CACT,CAEO,SAASI,CAAAA,EAA0B,CACxCJ,EAAoB,IAAA,CACpBC,CAAAA,CAAuB,IAAI,GAAA,CAC3BC,EAAqB,EACvB,CAEO,SAASG,CAAAA,EAAoC,CAClDL,CAAAA,CAAoB,KAAA,CACpB,IAAMM,CAAAA,CAAS,OAAO,WAAA,CAAYL,CAAAA,EAAwB,IAAI,GAAK,CAAA,CACnE,OAAAA,CAAAA,CAAuB,IAAA,CAEhB,CAAE,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AM,SAAS,MAAA,GAAW,CAAA,CACvCA,CAAAA,CAAM,QAAA,CAAS,CAAC,CAAA,CAChBA,CAAAA,CAAM,QAAA,CAAA,CAIZ,IAAM2B,EAAaD,CAAAA,CAAkB,UAAA,CAC/BE,CAAAA,CAAaD,CAAAA,GAAc,OAC7BE,CAAAA,CAEAD,CAAAA,GACFC,CAAAA,CAAmBC,CAAAA,CAAYH,EAAWV,CAAAA,CAAM,KAAK,GAIvD,IAAMc,CAAAA,CAA8B,CAClC,KAAA,CAAO,EAAC,CACR,SAAA,CAAW,CACb,CAAA,CAEA,GAAI,CAEF,IAAMC,EAASC,GAAAA,CAAiBF,CAAAA,CAAU,IAAML,CAAAA,CAAUT,CAAK,CAAC,CAAA,CAGhE,OAAOd,CAAAA,CAAmB6B,CAAAA,CAAQxB,CAAuB,CAC3D,CAAA,OAAE,CAEIoB,CAAAA,EACFM,IAAWP,CAAAA,CAAWE,CAAgB,EAE1C,CACF,CAEA,SAASJ,CAAAA,CAAU3C,CAAAA,CAAqB,CACtC,OAAOA,CAAAA,CAAI,OAAA,CAAQ,WAAY,KAAK,CAAA,CAAE,aACxC","file":"chunk-S5DHAAMO.mjs","sourcesContent":["const ESCAPE_MAP: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n}\n\nconst ESCAPE_REGEX = /[&<>\"']/g\n\nexport function escapeHtml(str: string): string {\n return String(str).replace(ESCAPE_REGEX, char => ESCAPE_MAP[char])\n}\n\nexport function escapeAttribute(str: string): string {\n return escapeHtml(str)\n}\n","import type { SerializedState } from './types'\n\nlet isServerRendering = false\nlet serverStateCollector: Map<string, unknown> | null = null\nlet hydrationIdCounter = 0\n\nexport function getIsServer(): boolean {\n return isServerRendering\n}\n\nexport function enterServerRender(): void {\n isServerRendering = true\n serverStateCollector = new Map()\n hydrationIdCounter = 0\n}\n\nexport function exitServerRender(): SerializedState {\n isServerRendering = false\n const states = Object.fromEntries(serverStateCollector || new Map())\n serverStateCollector = null\n\n return { states }\n}\n\nexport function collectServerState(key: string, value: unknown): void {\n if (serverStateCollector) {\n serverStateCollector.set(key, value)\n }\n}\n\nexport function generateHydrationId(): string {\n return `fid-${hydrationIdCounter++}`\n}\n\nexport function resetHydrationIdCounter(): void {\n hydrationIdCounter = 0\n}\n","import type { FNode, FNodeChild } from '../dom/types'\nimport type { SSROptions, SSRResult } from './types'\nimport { escapeHtml, escapeAttribute } from './escape'\nimport {\n enterServerRender,\n exitServerRender,\n generateHydrationId\n} from './serverState'\nimport { runWithComponent, ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\n\n// Self-closing HTML tags\nconst VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\n])\n\n// Attributes that should be rendered as boolean\nconst BOOLEAN_ATTRS = new Set([\n 'disabled', 'checked', 'readonly', 'required', 'hidden',\n 'selected', 'autofocus', 'autoplay', 'controls', 'loop', 'muted',\n 'multiple', 'open', 'defer', 'async', 'novalidate'\n])\n\n// Attributes that need special handling\nconst ATTR_ALIASES: Record<string, string> = {\n className: 'class',\n htmlFor: 'for'\n}\n\n/**\n * Render component tree to HTML string with hydration markers\n */\nexport function renderToString(\n app: FNodeChild | (() => FNodeChild),\n options: SSROptions = {}\n): SSRResult {\n const { hydrate = true } = options\n\n enterServerRender()\n\n try {\n // Normalize input - wrap function in FNode if needed\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n const html = renderNodeToString(fnode, hydrate)\n const state = exitServerRender()\n\n return { html, state }\n } catch (error) {\n exitServerRender()\n throw error\n }\n}\n\n/**\n * Render component tree to static HTML (no hydration markers)\n * Use for email templates, static pages, etc.\n */\nexport function renderToStaticMarkup(app: FNodeChild | (() => FNodeChild)): string {\n const { html } = renderToString(app, { hydrate: false })\n return html\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction renderNodeToString(fnode: FNodeChild, includeHydrationMarkers: boolean): string {\n // Null/undefined/boolean -> empty string\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n return ''\n }\n\n // String/number -> escaped text\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return escapeHtml(String(fnode))\n }\n\n // Array -> concatenate children\n if (Array.isArray(fnode)) {\n return fnode.map(child => renderNodeToString(child, includeHydrationMarkers)).join('')\n }\n\n // Function (standalone) -> wrap in FNode and render\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return renderComponentToString(wrappedFnode, includeHydrationMarkers)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n // HTML element\n if (typeof fnode.type === 'string') {\n return renderElementToString(fnode, includeHydrationMarkers)\n }\n\n // Function component\n if (typeof fnode.type === 'function') {\n return renderComponentToString(fnode, includeHydrationMarkers)\n }\n }\n\n return ''\n}\n\nfunction renderElementToString(fnode: FNode, includeHydrationMarkers: boolean): string {\n const tag = fnode.type as string\n const attrs = renderAttributes(fnode.props, includeHydrationMarkers)\n\n // Handle dangerouslySetInnerHTML\n if (fnode.props?.dangerouslySetInnerHTML) {\n const innerHTML = fnode.props.dangerouslySetInnerHTML.__html || ''\n return `<${tag}${attrs}>${innerHTML}</${tag}>`\n }\n\n // Void elements (self-closing)\n if (VOID_ELEMENTS.has(tag)) {\n return `<${tag}${attrs}>`\n }\n\n // Render children\n const childrenHtml = (fnode.children || [])\n .map(child => renderNodeToString(child, includeHydrationMarkers))\n .join('')\n\n return `<${tag}${attrs}>${childrenHtml}</${tag}>`\n}\n\nfunction renderAttributes(props: Record<string, any>, includeHydrationMarkers: boolean): string {\n if (!props) return ''\n\n const parts: string[] = []\n\n // Add hydration ID if needed\n if (includeHydrationMarkers) {\n const fid = generateHydrationId()\n parts.push(`data-fid=\"${fid}\"`)\n }\n\n for (const [key, value] of Object.entries(props)) {\n // Skip event handlers, refs, and internal props\n if (key.startsWith('on') || key === 'ref' || key === 'key' || key === 'children') continue\n if (key === 'dangerouslySetInnerHTML') continue\n\n // Skip undefined/null values\n if (value === undefined || value === null) continue\n\n // Handle aliased attributes\n const attrName = ATTR_ALIASES[key] || key\n\n // Handle style object\n if (key === 'style' && typeof value === 'object') {\n const styleStr = Object.entries(value)\n .filter(([, v]) => v !== null && v !== undefined)\n .map(([k, v]) => `${kebabCase(k)}:${v}`)\n .join(';')\n if (styleStr) {\n parts.push(`style=\"${escapeAttribute(styleStr)}\"`)\n }\n continue\n }\n\n // Handle boolean attributes\n if (BOOLEAN_ATTRS.has(attrName)) {\n if (value) parts.push(attrName)\n continue\n }\n\n // Handle false boolean values - skip entirely\n if (value === false) continue\n\n // Regular attribute\n parts.push(`${attrName}=\"${escapeAttribute(String(value))}\"`)\n }\n\n return parts.length ? ' ' + parts.join(' ') : ''\n}\n\nfunction renderComponentToString(fnode: FNode, includeHydrationMarkers: boolean): string {\n const Component = fnode.type as Function\n\n // Merge props with children\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Check if this is a Context Provider\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Create minimal component instance for server (hooks support)\n const instance: ComponentInstance = {\n hooks: [],\n hookIndex: 0\n }\n\n try {\n // Run component with hook context\n const result = runWithComponent(instance, () => Component(props))\n\n // Render result\n return renderNodeToString(result, includeHydrationMarkers)\n } finally {\n // Restore context if it was a provider\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n\nfunction kebabCase(str: string): string {\n return str.replace(/([A-Z])/g, '-$1').toLowerCase()\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,c}from'./chunk-CB6CIG76.mjs';import {e}from'./chunk-WHRUAZR4.mjs';import {a as a$1}from'./chunk-RUYGSYEV.mjs';function D(t){if(!t)return {};if(typeof URLSearchParams<"u"){let e=new URLSearchParams(t),r={};return e.forEach((n,o)=>r[o]=n),r}return t.substring(1).split("&").reduce((e,r)=>{let[n,o]=r.split("=");return n&&(e[decodeURIComponent(n)]=decodeURIComponent(o||"")),e},{})}function N(t){return !!(t.length>2048||t.includes("__proto__")||t.includes("constructor")||/^\s*javascript:/i.test(t))}function g(t){let e=[];return t.forEach(r=>{if(!r)return;let{path:n,component:o,children:i,beforeEnter:f}=r.props||{},u={path:n||"/",component:o,beforeEnter:f};if(i){let c=Array.isArray(i)?i:[i];u.children=g(c);}!u.children&&r.children&&r.children.length>0&&(u.children=g(r.children)),e.push(u);}),e}function E(t,e){for(let r of t){let n=r.path,o=U(n,e);if(o)return [{route:r,params:o.params,pathname:o.path}]}return null}function U(t,e){let r=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(r.length!==n.length)return null;let o={};for(let i=0;i<r.length;i++){let f=r[i],u=n[i];if(f.startsWith(":")){let c=f.slice(1);o[c]=u;}else if(f!==u)return null}return {params:o,path:e}}var L=new e(null),p=new e(0),j=()=>({pathname:"/",search:"",hash:"",query:{}}),w=()=>typeof window>"u"?j():{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,query:D(window.location.search)},l=null,R=null,F=false;function h(){if(l&&R)return [l,R];l=a(w());let t=e=>{l&&(l.pathname=e.pathname,l.search=e.search,l.hash=e.hash,l.query=e.query);};return R=e=>{if(typeof window>"u")return;if(N(e)){console.error("[Flexium Router] Blocked navigation to unsafe path:",e);return}window.history.pushState({},"",e);let r=w();t(r);},typeof window<"u"&&!F&&(window.addEventListener("popstate",()=>{t(w());}),F=true),[l,R]}function y(){let[t]=c(L);if(!t)throw new Error("useRouter() must be called within a <Routes> component");return t}function P(){let[,t]=h();return t}function q(){return y().params}function _(){let[t]=h();return t.query}function x(t){return null}function A(t){return t&&typeof t=="object"&&("type"in t||Array.isArray(t))}function Q(t){let[e,r]=h(),n=Array.isArray(t.children)?t.children:[t.children],o=n.filter(s=>A(s)&&s.type===x),i=n.filter(s=>!A(s)||s.type!==x),f=g(o),u=e.pathname,c=E(f,u)||[],S=c.length>0?c[c.length-1].params:{},T={location:e,navigate:r,matches:c,params:S},C=null;if(c.length>0){let s=c[0],b=s.route.component,d=u;s.route.beforeEnter?s.route.beforeEnter(s.params)!==false&&(C=a$1(p.Provider,{value:1,key:d,children:a$1(b,{params:s.params,key:d})})):C=a$1(p.Provider,{value:1,key:d,children:a$1(b,{params:s.params,key:d})});}return a$1(L.Provider,{value:T,children:[...i,C]})}function B(){let t=y(),[e]=c(p),r=e??0,[n]=c(()=>t.matches);if(r>=n.length)return null;let o=n[r],i=o.route.component;return o.route.beforeEnter&&o.route.beforeEnter(o.params)===false?null:a$1(p.Provider,{value:r+1,children:a$1(i,{params:o.params})})}function M(t){let e=P();return a$1("a",{href:t.to,class:t.class,onclick:r=>{r.preventDefault(),e(t.to);},children:t.children})}export{h as a,y as b,P as c,q as d,_ as e,x as f,Q as g,B as h,M as i};//# sourceMappingURL=chunk-W5IZRDRK.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-W5IZRDRK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/utils.ts","../src/router/router.ts","../src/router/dom/Route.tsx","../src/router/dom/Routes.tsx","../src/router/dom/Outlet.tsx","../src/router/dom/Link.tsx"],"names":["parseQuery","search","params","result","value","key","accumulator","part","isUnsafePath","path","createRoutesFromChildren","children","routes","child","component","subChildren","beforeEnter","route","nestedChildren","matchRoutes","locationPathname","routePath","matchResult","matchPath","locationPath","routeSegments","locationSegments","routeSegment","locationSegment","RouterCtx","Context","RouteDepthCtx","getDefaultLocation","getCurrentLocation","globalLocation","globalNavigate","popstateListenerAttached","useLocation","reactive","updateLocation","newLocation","useRouter","routerContext","use","useNavigate","navigate","useParams","useQuery","location","Route","_props","isFNode","node","Routes","props","currentLocation","childrenList","routeNodes","otherChildren","routeDefinitions","currentPath","matches","matchedContent","rootMatch","Component","routeKey","jsx","Outlet","depthValue","depth","match","Link","event"],"mappings":"wHAGA,SAASA,CAAAA,CAAWC,EAAwC,CAC1D,GAAI,CAACA,CAAAA,CAAQ,OAAO,EAAC,CACrB,GAAI,OAAO,eAAA,CAAoB,GAAA,CAAa,CAC1C,IAAMC,CAAAA,CAAS,IAAI,eAAA,CAAgBD,CAAM,CAAA,CACnCE,CAAAA,CAAiC,EAAC,CACxC,OAAAD,CAAAA,CAAO,OAAA,CAAQ,CAACE,CAAAA,CAAOC,CAAAA,GAAQF,EAAOE,CAAG,CAAA,CAAID,CAAK,CAAA,CAC3CD,CACT,CACA,OAAOF,CAAAA,CACJ,UAAU,CAAC,CAAA,CACX,MAAM,GAAG,CAAA,CACT,MAAA,CAAO,CAACK,CAAAA,CAAaC,CAAAA,GAAS,CAC7B,GAAM,CAACF,EAAKD,CAAK,CAAA,CAAIG,EAAK,KAAA,CAAM,GAAG,EACnC,OAAIF,CAAAA,GAAKC,EAAY,kBAAA,CAAmBD,CAAG,CAAC,CAAA,CAAI,kBAAA,CAAmBD,GAAS,EAAE,CAAA,CAAA,CACvEE,CACT,CAAA,CAAG,EAA4B,CACnC,CAEA,SAASE,EAAaC,CAAAA,CAAuB,CAK3C,OAHI,CAAA,EAAAA,CAAAA,CAAK,MAAA,CAAS,IAAA,EACdA,CAAAA,CAAK,QAAA,CAAS,WAAW,CAAA,EAAKA,CAAAA,CAAK,SAAS,aAAa,CAAA,EAEzD,mBAAmB,IAAA,CAAKA,CAAI,CAAA,CAElC,CAGA,SAASC,CAAAA,CAAyBC,EAAoC,CACpE,IAAMC,EAA4B,EAAC,CAEnC,OAAAD,CAAAA,CAAS,OAAA,CAAQE,GAAS,CACxB,GAAI,CAACA,CAAAA,CAAO,OAMZ,GAAM,CAAE,IAAA,CAAAJ,EAAM,SAAA,CAAAK,CAAAA,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,IAAA,CAIzDJ,GAAAA,CAAEnC,CAAAA,CAAc,QAAA,CAAU,CAC7B,KAAA,CAAOsC,CAAAA,CAAQ,EACf,QAAA,CAAUH,GAAAA,CAAEF,EAAW,CAAE,MAAA,CAAQM,EAAM,MAAO,CAAC,CACnD,CAAC,CACL,CCtBO,SAASC,CAAAA,CAAKjB,EAAkB,CACnC,IAAMT,CAAAA,CAAWD,CAAAA,EAAY,CAC7B,OAAOsB,IAAE,GAAA,CAAK,CACV,KAAMZ,CAAAA,CAAM,EAAA,CACZ,MAAOA,CAAAA,CAAM,KAAA,CACb,OAAA,CAAUkB,CAAAA,EAAiB,CACvBA,CAAAA,CAAM,gBAAe,CACrB3B,CAAAA,CAASS,EAAM,EAAE,EACrB,EACA,QAAA,CAAUA,CAAAA,CAAM,QACpB,CAAC,CACL","file":"chunk-W5IZRDRK.mjs","sourcesContent":["import { RouteDefinition, RouteMatch } from './types'\n\n// Simple query parser (native URLSearchParams fallback) - internal use only\nfunction parseQuery(search: string): Record<string, string> {\n if (!search) return {}\n if (typeof URLSearchParams !== 'undefined') {\n const params = new URLSearchParams(search)\n const result: Record<string, string> = {}\n params.forEach((value, key) => result[key] = value)\n return result\n }\n return search\n .substring(1)\n .split('&')\n .reduce((accumulator, part) => {\n const [key, value] = part.split('=')\n if (key) accumulator[decodeURIComponent(key)] = decodeURIComponent(value || '')\n return accumulator\n }, {} as Record<string, string>)\n}\n\nfunction isUnsafePath(path: string): boolean {\n // Prevent prototype pollution or massive strings\n if (path.length > 2048) return true\n if (path.includes('__proto__') || path.includes('constructor')) return true\n // Basic XSS check for javascript: protocol\n if (/^\\s*javascript:/i.test(path)) return true\n return false\n}\n\n// Convert children FNodes to RouteDefinitions - internal use only\nfunction createRoutesFromChildren(children: any[]): RouteDefinition[] {\n const routes: RouteDefinition[] = []\n\n children.forEach(child => {\n if (!child) return\n\n // Assuming child is an FNode-like object (config)\n // In Flexium, Route component returns null, but 'createNode' isn't called here.\n // We are traversing the props passed to Router.\n\n const { path, component, children: subChildren, beforeEnter } = child.props || {}\n\n const route: RouteDefinition = {\n path: path || '/',\n component: component,\n beforeEnter\n }\n\n if (subChildren) {\n // If subChildren is array\n const nestedChildren = Array.isArray(subChildren) ? subChildren : [subChildren]\n // We expect the children of a Route to be other Routes\n // However, the 'children' prop in JSX might be the Route components themselves.\n route.children = createRoutesFromChildren(nestedChildren)\n }\n\n // Also check child.children if props.children is empty (direct FNode structure)\n if (!route.children && child.children && child.children.length > 0) {\n route.children = createRoutesFromChildren(child.children)\n }\n\n routes.push(route)\n })\n return routes\n}\n\n// Simple Matcher - internal use only\nfunction matchRoutes(routes: RouteDefinition[], locationPathname: string): RouteMatch[] | null {\n // We want to find the best matching branch\n\n for (const route of routes) {\n // 1. Match current segment\n // Simple exact match or parameter match logic needed?\n // Let's implement simple param matching: /user/:id\n\n const routePath = route.path\n\n const matchResult = matchPath(routePath, locationPathname)\n if (matchResult) {\n return [{ route, params: matchResult.params, pathname: matchResult.path }]\n }\n }\n return null\n}\n\nfunction matchPath(routePath: string, locationPath: string) {\n // 1. Split into segments\n const routeSegments = routePath.split('/').filter(Boolean)\n const locationSegments = locationPath.split('/').filter(Boolean)\n\n if (routeSegments.length !== locationSegments.length) return null\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSegment = routeSegments[i]\n const locationSegment = locationSegments[i]\n\n if (routeSegment.startsWith(':')) {\n const key = routeSegment.slice(1)\n params[key] = locationSegment\n } else if (routeSegment !== locationSegment) {\n return null\n }\n }\n\n return { params, path: locationPath }\n}\n\n// Export only what's needed by other router files\nexport { parseQuery, isUnsafePath, createRoutesFromChildren, matchRoutes }\n","import { reactive } from '../core/reactive'\nimport { Context } from '../core/context'\nimport { use } from '../core/use'\nimport type { Location, RouterContext } from './types'\nimport { parseQuery, isUnsafePath } from './utils'\n\n// Contexts\nexport const RouterCtx = new Context<RouterContext>(null as any)\nexport const RouteDepthCtx = new Context<number>(0)\n\n// Helper functions\nconst getDefaultLocation = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n})\n\nconst getCurrentLocation = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLocation()\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// Global singleton location state\nlet globalLocation: Location | null = null\nlet globalNavigate: ((path: string) => void) | null = null\nlet popstateListenerAttached = false\n\n// Create location state and navigation (singleton pattern)\nexport function useLocation(): [Location, (path: string) => void] {\n // Return existing singleton if already created\n if (globalLocation && globalNavigate) {\n return [globalLocation, globalNavigate]\n }\n\n // Create a reactive location object (only once)\n globalLocation = reactive<Location>(getCurrentLocation())\n\n const updateLocation = (newLocation: Location) => {\n if (!globalLocation) return\n globalLocation.pathname = newLocation.pathname\n globalLocation.search = newLocation.search\n globalLocation.hash = newLocation.hash\n globalLocation.query = newLocation.query\n }\n\n globalNavigate = (path: string) => {\n if (typeof window === 'undefined') return\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n const newLocation = getCurrentLocation()\n updateLocation(newLocation)\n }\n\n // Listen to popstate (only once)\n if (typeof window !== 'undefined' && !popstateListenerAttached) {\n window.addEventListener('popstate', () => {\n updateLocation(getCurrentLocation())\n })\n popstateListenerAttached = true\n }\n\n return [globalLocation, globalNavigate]\n}\n\n// Router hook - returns full router context\nexport function useRouter(): RouterContext {\n const [routerContext] = use(RouterCtx)\n if (!routerContext) {\n throw new Error('useRouter() must be called within a <Routes> component')\n }\n return routerContext\n}\n\n// Navigate hook - returns navigate function\nexport function useNavigate(): (path: string) => void {\n const [, navigate] = useLocation()\n return navigate\n}\n\n// Params hook - returns route params\nexport function useParams<T extends Record<string, string> = Record<string, string>>(): T {\n const router = useRouter()\n return router.params as T\n}\n\n// Query hook - returns query params\nexport function useQuery<T extends Record<string, string> = Record<string, string>>(): T {\n const [location] = useLocation()\n return location.query as T\n}\n","import type { RouteProps } from '../types'\n\nexport function Route(_props: RouteProps) {\n return null\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { FNode, FNodeChild } from '../../dom/types'\nimport { RouterCtx, RouteDepthCtx, useLocation } from '../router'\nimport { createRoutesFromChildren, matchRoutes } from '../utils'\nimport { Route } from './Route'\n\nfunction isFNode(node: any): node is FNode {\n return node && typeof node === 'object' && ('type' in node || Array.isArray(node))\n}\n\nexport function Routes(props: { children: FNodeChild }) {\n const [currentLocation, navigate] = useLocation()\n\n // Parse children to find <Route> definitions and other content\n let childrenList: any[] = Array.isArray(props.children) ? props.children : [props.children]\n\n // Separate routes from other children (like Nav components)\n const routeNodes = childrenList.filter(child => isFNode(child) && child.type === Route)\n const otherChildren = childrenList.filter(child => !isFNode(child) || child.type !== Route)\n\n // Create route definitions\n const routeDefinitions = createRoutesFromChildren(routeNodes)\n\n // DIRECT access to currentLocation.pathname\n // This should trigger reactive tracking in the component's effect context\n const currentPath = currentLocation.pathname\n const matches = matchRoutes(routeDefinitions, currentPath) || []\n const params = matches.length > 0 ? matches[matches.length - 1].params : {}\n\n const routerContext = {\n location: currentLocation,\n navigate,\n matches: matches,\n params: params\n }\n\n // Render matched component\n let matchedContent: FNodeChild = null\n\n if (matches.length > 0) {\n const rootMatch = matches[0]\n const Component = rootMatch.route.component\n\n // Use pathname as key to force re-mount on route change\n const routeKey = currentPath\n\n // Guard Check\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n }\n\n return f(RouterCtx.Provider, {\n value: routerContext,\n children: [...otherChildren, matchedContent]\n })\n}\n","import { use } from '../../core/use'\nimport { jsx as f } from '../../jsx-runtime'\nimport { RouteDepthCtx, useRouter } from '../router'\n\nexport function Outlet() {\n const routerContext = useRouter()\n const [depthValue] = use(RouteDepthCtx)\n const depth = depthValue ?? 0\n\n const [matches] = use(() => routerContext.matches)\n\n if (depth >= matches.length) return null\n\n const match = matches[depth]\n const Component = match.route.component\n\n // Guard\n if (match.route.beforeEnter) {\n if (match.route.beforeEnter(match.params) === false) return null\n }\n\n // Render next level\n return f(RouteDepthCtx.Provider, {\n value: depth + 1,\n children: f(Component, { params: match.params })\n })\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { LinkProps } from '../types'\nimport { useNavigate } from '../router'\n\nexport function Link(props: LinkProps) {\n const navigate = useNavigate()\n return f('a', {\n href: props.to,\n class: props.class,\n onclick: (event: Event) => {\n event.preventDefault()\n navigate(props.to)\n },\n children: props.children\n })\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkLOKMOGSA_js=require('./chunk-LOKMOGSA.js'),chunkVNYPOCV7_js=require('./chunk-VNYPOCV7.js'),chunkTFXBDC6C_js=require('./chunk-TFXBDC6C.js');function D(t){if(!t)return {};if(typeof URLSearchParams<"u"){let e=new URLSearchParams(t),r={};return e.forEach((n,o)=>r[o]=n),r}return t.substring(1).split("&").reduce((e,r)=>{let[n,o]=r.split("=");return n&&(e[decodeURIComponent(n)]=decodeURIComponent(o||"")),e},{})}function N(t){return !!(t.length>2048||t.includes("__proto__")||t.includes("constructor")||/^\s*javascript:/i.test(t))}function g(t){let e=[];return t.forEach(r=>{if(!r)return;let{path:n,component:o,children:i,beforeEnter:f}=r.props||{},u={path:n||"/",component:o,beforeEnter:f};if(i){let c=Array.isArray(i)?i:[i];u.children=g(c);}!u.children&&r.children&&r.children.length>0&&(u.children=g(r.children)),e.push(u);}),e}function E(t,e){for(let r of t){let n=r.path,o=U(n,e);if(o)return [{route:r,params:o.params,pathname:o.path}]}return null}function U(t,e){let r=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(r.length!==n.length)return null;let o={};for(let i=0;i<r.length;i++){let f=r[i],u=n[i];if(f.startsWith(":")){let c=f.slice(1);o[c]=u;}else if(f!==u)return null}return {params:o,path:e}}var L=new chunkVNYPOCV7_js.e(null),p=new chunkVNYPOCV7_js.e(0),j=()=>({pathname:"/",search:"",hash:"",query:{}}),w=()=>typeof window>"u"?j():{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,query:D(window.location.search)},l=null,R=null,F=false;function h(){if(l&&R)return [l,R];l=chunkLOKMOGSA_js.a(w());let t=e=>{l&&(l.pathname=e.pathname,l.search=e.search,l.hash=e.hash,l.query=e.query);};return R=e=>{if(typeof window>"u")return;if(N(e)){console.error("[Flexium Router] Blocked navigation to unsafe path:",e);return}window.history.pushState({},"",e);let r=w();t(r);},typeof window<"u"&&!F&&(window.addEventListener("popstate",()=>{t(w());}),F=true),[l,R]}function y(){let[t]=chunkLOKMOGSA_js.c(L);if(!t)throw new Error("useRouter() must be called within a <Routes> component");return t}function P(){let[,t]=h();return t}function q(){return y().params}function _(){let[t]=h();return t.query}function x(t){return null}function A(t){return t&&typeof t=="object"&&("type"in t||Array.isArray(t))}function Q(t){let[e,r]=h(),n=Array.isArray(t.children)?t.children:[t.children],o=n.filter(s=>A(s)&&s.type===x),i=n.filter(s=>!A(s)||s.type!==x),f=g(o),u=e.pathname,c=E(f,u)||[],S=c.length>0?c[c.length-1].params:{},T={location:e,navigate:r,matches:c,params:S},C=null;if(c.length>0){let s=c[0],b=s.route.component,d=u;s.route.beforeEnter?s.route.beforeEnter(s.params)!==false&&(C=chunkTFXBDC6C_js.a(p.Provider,{value:1,key:d,children:chunkTFXBDC6C_js.a(b,{params:s.params,key:d})})):C=chunkTFXBDC6C_js.a(p.Provider,{value:1,key:d,children:chunkTFXBDC6C_js.a(b,{params:s.params,key:d})});}return chunkTFXBDC6C_js.a(L.Provider,{value:T,children:[...i,C]})}function B(){let t=y(),[e]=chunkLOKMOGSA_js.c(p),r=e??0,[n]=chunkLOKMOGSA_js.c(()=>t.matches);if(r>=n.length)return null;let o=n[r],i=o.route.component;return o.route.beforeEnter&&o.route.beforeEnter(o.params)===false?null:chunkTFXBDC6C_js.a(p.Provider,{value:r+1,children:chunkTFXBDC6C_js.a(i,{params:o.params})})}function M(t){let e=P();return chunkTFXBDC6C_js.a("a",{href:t.to,class:t.class,onclick:r=>{r.preventDefault(),e(t.to);},children:t.children})}exports.a=h;exports.b=y;exports.c=P;exports.d=q;exports.e=_;exports.f=x;exports.g=Q;exports.h=B;exports.i=M;//# sourceMappingURL=chunk-WWTSQR6W.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-WWTSQR6W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/utils.ts","../src/router/router.ts","../src/router/dom/Route.tsx","../src/router/dom/Routes.tsx","../src/router/dom/Outlet.tsx","../src/router/dom/Link.tsx"],"names":["parseQuery","search","params","result","value","key","accumulator","part","isUnsafePath","path","createRoutesFromChildren","children","routes","child","component","subChildren","beforeEnter","route","nestedChildren","matchRoutes","locationPathname","routePath","matchResult","matchPath","locationPath","routeSegments","locationSegments","routeSegment","locationSegment","RouterCtx","Context","RouteDepthCtx","getDefaultLocation","getCurrentLocation","globalLocation","globalNavigate","popstateListenerAttached","useLocation","reactive","updateLocation","newLocation","useRouter","routerContext","use","useNavigate","navigate","useParams","useQuery","location","Route","_props","isFNode","node","Routes","props","currentLocation","childrenList","routeNodes","otherChildren","routeDefinitions","currentPath","matches","matchedContent","rootMatch","Component","routeKey","jsx","Outlet","depthValue","depth","match","Link","event"],"mappings":"iKAGA,SAASA,CAAAA,CAAWC,EAAwC,CAC1D,GAAI,CAACA,CAAAA,CAAQ,OAAO,EAAC,CACrB,GAAI,OAAO,eAAA,CAAoB,GAAA,CAAa,CAC1C,IAAMC,CAAAA,CAAS,IAAI,eAAA,CAAgBD,CAAM,CAAA,CACnCE,CAAAA,CAAiC,EAAC,CACxC,OAAAD,CAAAA,CAAO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AA,CACb,OAAA,CAAUkB,CAAAA,EAAiB,CACvBA,CAAAA,CAAM,gBAAe,CACrB3B,CAAAA,CAASS,EAAM,EAAE,EACrB,EACA,QAAA,CAAUA,CAAAA,CAAM,QACpB,CAAC,CACL","file":"chunk-WWTSQR6W.js","sourcesContent":["import { RouteDefinition, RouteMatch } from './types'\n\n// Simple query parser (native URLSearchParams fallback) - internal use only\nfunction parseQuery(search: string): Record<string, string> {\n if (!search) return {}\n if (typeof URLSearchParams !== 'undefined') {\n const params = new URLSearchParams(search)\n const result: Record<string, string> = {}\n params.forEach((value, key) => result[key] = value)\n return result\n }\n return search\n .substring(1)\n .split('&')\n .reduce((accumulator, part) => {\n const [key, value] = part.split('=')\n if (key) accumulator[decodeURIComponent(key)] = decodeURIComponent(value || '')\n return accumulator\n }, {} as Record<string, string>)\n}\n\nfunction isUnsafePath(path: string): boolean {\n // Prevent prototype pollution or massive strings\n if (path.length > 2048) return true\n if (path.includes('__proto__') || path.includes('constructor')) return true\n // Basic XSS check for javascript: protocol\n if (/^\\s*javascript:/i.test(path)) return true\n return false\n}\n\n// Convert children FNodes to RouteDefinitions - internal use only\nfunction createRoutesFromChildren(children: any[]): RouteDefinition[] {\n const routes: RouteDefinition[] = []\n\n children.forEach(child => {\n if (!child) return\n\n // Assuming child is an FNode-like object (config)\n // In Flexium, Route component returns null, but 'createNode' isn't called here.\n // We are traversing the props passed to Router.\n\n const { path, component, children: subChildren, beforeEnter } = child.props || {}\n\n const route: RouteDefinition = {\n path: path || '/',\n component: component,\n beforeEnter\n }\n\n if (subChildren) {\n // If subChildren is array\n const nestedChildren = Array.isArray(subChildren) ? subChildren : [subChildren]\n // We expect the children of a Route to be other Routes\n // However, the 'children' prop in JSX might be the Route components themselves.\n route.children = createRoutesFromChildren(nestedChildren)\n }\n\n // Also check child.children if props.children is empty (direct FNode structure)\n if (!route.children && child.children && child.children.length > 0) {\n route.children = createRoutesFromChildren(child.children)\n }\n\n routes.push(route)\n })\n return routes\n}\n\n// Simple Matcher - internal use only\nfunction matchRoutes(routes: RouteDefinition[], locationPathname: string): RouteMatch[] | null {\n // We want to find the best matching branch\n\n for (const route of routes) {\n // 1. Match current segment\n // Simple exact match or parameter match logic needed?\n // Let's implement simple param matching: /user/:id\n\n const routePath = route.path\n\n const matchResult = matchPath(routePath, locationPathname)\n if (matchResult) {\n return [{ route, params: matchResult.params, pathname: matchResult.path }]\n }\n }\n return null\n}\n\nfunction matchPath(routePath: string, locationPath: string) {\n // 1. Split into segments\n const routeSegments = routePath.split('/').filter(Boolean)\n const locationSegments = locationPath.split('/').filter(Boolean)\n\n if (routeSegments.length !== locationSegments.length) return null\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSegment = routeSegments[i]\n const locationSegment = locationSegments[i]\n\n if (routeSegment.startsWith(':')) {\n const key = routeSegment.slice(1)\n params[key] = locationSegment\n } else if (routeSegment !== locationSegment) {\n return null\n }\n }\n\n return { params, path: locationPath }\n}\n\n// Export only what's needed by other router files\nexport { parseQuery, isUnsafePath, createRoutesFromChildren, matchRoutes }\n","import { reactive } from '../core/reactive'\nimport { Context } from '../core/context'\nimport { use } from '../core/use'\nimport type { Location, RouterContext } from './types'\nimport { parseQuery, isUnsafePath } from './utils'\n\n// Contexts\nexport const RouterCtx = new Context<RouterContext>(null as any)\nexport const RouteDepthCtx = new Context<number>(0)\n\n// Helper functions\nconst getDefaultLocation = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n})\n\nconst getCurrentLocation = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLocation()\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// Global singleton location state\nlet globalLocation: Location | null = null\nlet globalNavigate: ((path: string) => void) | null = null\nlet popstateListenerAttached = false\n\n// Create location state and navigation (singleton pattern)\nexport function useLocation(): [Location, (path: string) => void] {\n // Return existing singleton if already created\n if (globalLocation && globalNavigate) {\n return [globalLocation, globalNavigate]\n }\n\n // Create a reactive location object (only once)\n globalLocation = reactive<Location>(getCurrentLocation())\n\n const updateLocation = (newLocation: Location) => {\n if (!globalLocation) return\n globalLocation.pathname = newLocation.pathname\n globalLocation.search = newLocation.search\n globalLocation.hash = newLocation.hash\n globalLocation.query = newLocation.query\n }\n\n globalNavigate = (path: string) => {\n if (typeof window === 'undefined') return\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n const newLocation = getCurrentLocation()\n updateLocation(newLocation)\n }\n\n // Listen to popstate (only once)\n if (typeof window !== 'undefined' && !popstateListenerAttached) {\n window.addEventListener('popstate', () => {\n updateLocation(getCurrentLocation())\n })\n popstateListenerAttached = true\n }\n\n return [globalLocation, globalNavigate]\n}\n\n// Router hook - returns full router context\nexport function useRouter(): RouterContext {\n const [routerContext] = use(RouterCtx)\n if (!routerContext) {\n throw new Error('useRouter() must be called within a <Routes> component')\n }\n return routerContext\n}\n\n// Navigate hook - returns navigate function\nexport function useNavigate(): (path: string) => void {\n const [, navigate] = useLocation()\n return navigate\n}\n\n// Params hook - returns route params\nexport function useParams<T extends Record<string, string> = Record<string, string>>(): T {\n const router = useRouter()\n return router.params as T\n}\n\n// Query hook - returns query params\nexport function useQuery<T extends Record<string, string> = Record<string, string>>(): T {\n const [location] = useLocation()\n return location.query as T\n}\n","import type { RouteProps } from '../types'\n\nexport function Route(_props: RouteProps) {\n return null\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { FNode, FNodeChild } from '../../dom/types'\nimport { RouterCtx, RouteDepthCtx, useLocation } from '../router'\nimport { createRoutesFromChildren, matchRoutes } from '../utils'\nimport { Route } from './Route'\n\nfunction isFNode(node: any): node is FNode {\n return node && typeof node === 'object' && ('type' in node || Array.isArray(node))\n}\n\nexport function Routes(props: { children: FNodeChild }) {\n const [currentLocation, navigate] = useLocation()\n\n // Parse children to find <Route> definitions and other content\n let childrenList: any[] = Array.isArray(props.children) ? props.children : [props.children]\n\n // Separate routes from other children (like Nav components)\n const routeNodes = childrenList.filter(child => isFNode(child) && child.type === Route)\n const otherChildren = childrenList.filter(child => !isFNode(child) || child.type !== Route)\n\n // Create route definitions\n const routeDefinitions = createRoutesFromChildren(routeNodes)\n\n // DIRECT access to currentLocation.pathname\n // This should trigger reactive tracking in the component's effect context\n const currentPath = currentLocation.pathname\n const matches = matchRoutes(routeDefinitions, currentPath) || []\n const params = matches.length > 0 ? matches[matches.length - 1].params : {}\n\n const routerContext = {\n location: currentLocation,\n navigate,\n matches: matches,\n params: params\n }\n\n // Render matched component\n let matchedContent: FNodeChild = null\n\n if (matches.length > 0) {\n const rootMatch = matches[0]\n const Component = rootMatch.route.component\n\n // Use pathname as key to force re-mount on route change\n const routeKey = currentPath\n\n // Guard Check\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n }\n\n return f(RouterCtx.Provider, {\n value: routerContext,\n children: [...otherChildren, matchedContent]\n })\n}\n","import { use } from '../../core/use'\nimport { jsx as f } from '../../jsx-runtime'\nimport { RouteDepthCtx, useRouter } from '../router'\n\nexport function Outlet() {\n const routerContext = useRouter()\n const [depthValue] = use(RouteDepthCtx)\n const depth = depthValue ?? 0\n\n const [matches] = use(() => routerContext.matches)\n\n if (depth >= matches.length) return null\n\n const match = matches[depth]\n const Component = match.route.component\n\n // Guard\n if (match.route.beforeEnter) {\n if (match.route.beforeEnter(match.params) === false) return null\n }\n\n // Render next level\n return f(RouteDepthCtx.Provider, {\n value: depth + 1,\n children: f(Component, { params: match.params })\n })\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { LinkProps } from '../types'\nimport { useNavigate } from '../router'\n\nexport function Link(props: LinkProps) {\n const navigate = useNavigate()\n return f('a', {\n href: props.to,\n class: props.class,\n onclick: (event: Event) => {\n event.preventDefault()\n navigate(props.to)\n },\n children: props.children\n })\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';function C(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return "fx-"+(t>>>0).toString(36)}var W=new Set(["animationIterationCount","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridArea","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","fontWeight","lineClamp","lineHeight","opacity","order","orphans","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"]);function K(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function P(e,t){return typeof t=="number"&&t!==0&&!W.has(e)?t+"px":String(t)}function k(e,t){let n="",r="";for(let i in e){let a=e[i];if(a!=null)if(i.startsWith("&")){let l=i.replace(/&/g,t);r+=k(a,l);}else if(i.startsWith("@"))r+=`${i}{${k(a,t)}}`;else {if(typeof a=="object")continue;n+=`${K(i)}:${P(i,a)};`;}}let s="";return n&&(s=`${t}{${n}}`),s+=r,s}function z(e,t){let n="";for(let r in t){let s=t[r],i="";for(let a in s){let l=s[a];l!=null&&typeof l!="object"&&(i+=`${K(a)}:${P(a,l)};`);}n+=`${r}{${i}}`;}return `@keyframes ${e}{${n}}`}var g=new Map,v=[],m=null;function M(){return typeof document<"u"&&"adoptedStyleSheets"in document&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype}function E(){return M()?(m||(m=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,m]),m):null}function V(e,t){if(g.has(e))return;g.set(e,true);let n=E();if(n)try{n.insertRule(t,n.cssRules.length);}catch(r){process.env.NODE_ENV!=="production"&&console.warn("[flexium/css] Invalid CSS rule:",t,r);}else v.push(t);}function O(e){return g.has(e)}function D(){return v.join("")}function H(){let e=D();return e?`<style data-flexium-css>${e}</style>`:""}function L(){v=[],g=new Map,m=null;}function A(){if(typeof document>"u")return;let e=document.querySelector("style[data-flexium-css]");if(e){let t=e.textContent||"",n=/\.fx-[a-z0-9]+/g,r;for(;(r=n.exec(t))!==null;){let s=r[0].slice(1);g.set(s,true);}}}M()&&A();function S(e){let t=JSON.stringify(e),n=C(t);if(O(n))return n;let r=k(e,"."+n);return V(n,r),n}function N(...e){return e.filter(Boolean).join(" ")}function q(e,t){let{base:n,variants:r,defaultVariants:s,compoundVariants:i}=t,a=S(n),l=new Map;function I(d,c){let h=`${d}:${c}`,f=l.get(h);return !f&&r?.[d]?.[c]&&(f=S(r[d][c]),l.set(h,f)),f||""}let T=new Map;function $(d){let{children:c,className:h,...f}=d,u={},j={};for(let o in f)r&&o in r?u[o]=f[o]??s?.[o]:j[o]=f[o];if(s)for(let o in s)o in u||(u[o]=String(s[o]));let w=[];for(let[o,x]of Object.entries(u))if(x){let y=I(o,String(x));y&&w.push(y);}if(i)for(let o of i){let{css:x,...y}=o,R=true;for(let[b,p]of Object.entries(y))if(u[b]!==p){R=false;break}if(R){let b=JSON.stringify(y),p=T.get(b);p||(p=S(x),T.set(b,p)),w.push(p);}}let F=N(a,...w,h);return {type:e,props:{...j,className:F},children:Array.isArray(c)?c:c!=null?[c]:[],key:void 0}}return $.displayName=`Styled(${e})`,$}function G(e){let t=JSON.stringify(e),n=C(t);if(O(n))return n;let r=z(n,e);return V(n,r),n}exports.a=D;exports.b=H;exports.c=L;exports.d=A;exports.e=S;exports.f=N;exports.g=q;exports.h=G;//# sourceMappingURL=chunk-ZJZRDYA2.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-ZJZRDYA2.js.map
|