@fluixi/core 1.0.0-alpha.82 → 1.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/cdn/core.global.js +2 -1
  2. package/dist/cli/generate.cjs +4117 -292
  3. package/dist/cli/generate.mjs +4122 -292
  4. package/dist/cli/index.cjs +4117 -292
  5. package/dist/cli/index.mjs +4122 -292
  6. package/dist/cli/run.cjs +63 -1
  7. package/dist/cli/run.mjs +39 -1
  8. package/dist/src/cdn/chunk-VNLCQBFQ.mjs +747 -0
  9. package/dist/src/cdn/core.cjs +1279 -1
  10. package/dist/src/cdn/core.d.ts +3 -3
  11. package/dist/src/cdn/core.js +3 -3
  12. package/dist/src/cdn/core.mjs +642 -1
  13. package/dist/src/cdn/router-WMN2AA7E.mjs +66 -0
  14. package/dist/src/index.cjs +1201 -1
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +1 -11
  17. package/dist/src/index.mjs +1313 -1
  18. package/dist/src/jsx-dev-runtime.cjs +26 -1
  19. package/dist/src/jsx-dev-runtime.mjs +24 -1
  20. package/dist/src/jsx-runtime.cjs +26 -1
  21. package/dist/src/jsx-runtime.js +0 -9
  22. package/dist/src/jsx-runtime.mjs +24 -1
  23. package/dist/src/lib/client/chunk-2C2KDDQV.mjs +133 -0
  24. package/dist/src/lib/client/index.cjs +870 -1
  25. package/dist/src/lib/client/index.d.ts +10 -14
  26. package/dist/src/lib/client/index.d.ts.map +1 -1
  27. package/dist/src/lib/client/index.js +36 -21
  28. package/dist/src/lib/client/index.mjs +222 -1
  29. package/dist/src/lib/client/router-X526HSWQ.mjs +548 -0
  30. package/dist/src/lib/context/context.cjs +118 -1
  31. package/dist/src/lib/context/context.d.ts +20 -38
  32. package/dist/src/lib/context/context.d.ts.map +1 -1
  33. package/dist/src/lib/context/context.js +10 -47
  34. package/dist/src/lib/context/context.mjs +99 -1
  35. package/dist/src/lib/context/index.cjs +120 -1
  36. package/dist/src/lib/context/index.mjs +99 -1
  37. package/dist/src/lib/control-flow.cjs +35 -1
  38. package/dist/src/lib/control-flow.mjs +25 -1
  39. package/dist/src/lib/core.cjs +1200 -1
  40. package/dist/src/lib/core.d.ts +0 -2
  41. package/dist/src/lib/core.d.ts.map +1 -1
  42. package/dist/src/lib/core.js +14 -48
  43. package/dist/src/lib/core.mjs +1313 -1
  44. package/dist/src/lib/env/index.cjs +60 -1
  45. package/dist/src/lib/env/index.d.ts +7 -8
  46. package/dist/src/lib/env/index.d.ts.map +1 -1
  47. package/dist/src/lib/env/index.js +14 -9
  48. package/dist/src/lib/env/index.mjs +39 -1
  49. package/dist/src/lib/i18n/index.cjs +108 -1
  50. package/dist/src/lib/i18n/index.d.ts +31 -10
  51. package/dist/src/lib/i18n/index.d.ts.map +1 -1
  52. package/dist/src/lib/i18n/index.js +31 -10
  53. package/dist/src/lib/i18n/index.mjs +88 -1
  54. package/dist/src/lib/index.cjs +633 -1
  55. package/dist/src/lib/index.d.ts +0 -2
  56. package/dist/src/lib/index.d.ts.map +1 -1
  57. package/dist/src/lib/index.js +5 -11
  58. package/dist/src/lib/index.mjs +721 -1
  59. package/dist/src/lib/isomorphic.cjs +85 -1
  60. package/dist/src/lib/isomorphic.d.ts +41 -8
  61. package/dist/src/lib/isomorphic.d.ts.map +1 -1
  62. package/dist/src/lib/isomorphic.js +38 -5
  63. package/dist/src/lib/isomorphic.mjs +64 -1
  64. package/dist/src/lib/jsx-runtime/index.cjs +21 -1
  65. package/dist/src/lib/jsx-runtime/index.d.ts +1 -1
  66. package/dist/src/lib/jsx-runtime/index.js +1 -11
  67. package/dist/src/lib/jsx-runtime/index.mjs +4 -1
  68. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -1
  69. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -1
  70. package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -8
  71. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +15 -1
  72. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -1
  73. package/dist/src/lib/plugins/fluixi-routes-plugin.js +19 -5
  74. package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -8
  75. package/dist/src/lib/plugins/index.cjs +311 -8
  76. package/dist/src/lib/plugins/index.mjs +279 -8
  77. package/dist/src/lib/plugins/route-codegen.cjs +73 -8
  78. package/dist/src/lib/plugins/route-codegen.d.ts +0 -1
  79. package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -1
  80. package/dist/src/lib/plugins/route-codegen.js +4 -5
  81. package/dist/src/lib/plugins/route-codegen.mjs +52 -8
  82. package/dist/src/lib/plugins/route-scanner.cjs +189 -1
  83. package/dist/src/lib/plugins/route-scanner.d.ts +1 -2
  84. package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -1
  85. package/dist/src/lib/plugins/route-scanner.js +7 -8
  86. package/dist/src/lib/plugins/route-scanner.mjs +158 -1
  87. package/dist/src/lib/plugins/vite.cjs +27 -1
  88. package/dist/src/lib/plugins/vite.mjs +6 -1
  89. package/dist/src/lib/render/await.cjs +38 -1
  90. package/dist/src/lib/render/await.d.ts +18 -0
  91. package/dist/src/lib/render/await.d.ts.map +1 -1
  92. package/dist/src/lib/render/await.js +20 -2
  93. package/dist/src/lib/render/await.mjs +17 -1
  94. package/dist/src/lib/render/component.cjs +221 -1
  95. package/dist/src/lib/render/component.d.ts +3 -44
  96. package/dist/src/lib/render/component.d.ts.map +1 -1
  97. package/dist/src/lib/render/component.js +32 -59
  98. package/dist/src/lib/render/component.mjs +214 -1
  99. package/dist/src/lib/render/deferred.cjs +175 -1
  100. package/dist/src/lib/render/deferred.d.ts.map +1 -1
  101. package/dist/src/lib/render/deferred.js +8 -8
  102. package/dist/src/lib/render/deferred.mjs +158 -1
  103. package/dist/src/lib/render/index.cjs +573 -1
  104. package/dist/src/lib/render/index.d.ts +3 -17
  105. package/dist/src/lib/render/index.d.ts.map +1 -1
  106. package/dist/src/lib/render/index.js +12 -26
  107. package/dist/src/lib/render/index.mjs +590 -1
  108. package/dist/src/lib/render/lazy.cjs +67 -1
  109. package/dist/src/lib/render/lazy.d.ts +22 -1
  110. package/dist/src/lib/render/lazy.d.ts.map +1 -1
  111. package/dist/src/lib/render/lazy.js +47 -8
  112. package/dist/src/lib/render/lazy.mjs +50 -1
  113. package/dist/src/lib/render/suspense.cjs +141 -1
  114. package/dist/src/lib/render/suspense.d.ts +40 -0
  115. package/dist/src/lib/render/suspense.d.ts.map +1 -1
  116. package/dist/src/lib/render/suspense.js +47 -7
  117. package/dist/src/lib/render/suspense.mjs +136 -1
  118. package/dist/src/lib/render/versions.cjs +35 -1
  119. package/dist/src/lib/render/versions.js +6 -6
  120. package/dist/src/lib/render/versions.mjs +14 -1
  121. package/dist/src/lib/router/data.cjs +230 -1
  122. package/dist/src/lib/router/data.d.ts +1 -13
  123. package/dist/src/lib/router/data.d.ts.map +1 -1
  124. package/dist/src/lib/router/data.js +1 -13
  125. package/dist/src/lib/router/data.mjs +214 -1
  126. package/dist/src/lib/router/index.cjs +627 -1
  127. package/dist/src/lib/router/index.d.ts +62 -10
  128. package/dist/src/lib/router/index.d.ts.map +1 -1
  129. package/dist/src/lib/router/index.js +90 -39
  130. package/dist/src/lib/router/index.mjs +639 -1
  131. package/dist/src/lib/server/hydration.cjs +169 -1
  132. package/dist/src/lib/server/hydration.d.ts +15 -55
  133. package/dist/src/lib/server/hydration.d.ts.map +1 -1
  134. package/dist/src/lib/server/hydration.js +23 -62
  135. package/dist/src/lib/server/hydration.mjs +148 -1
  136. package/dist/src/lib/server/index.cjs +401 -11
  137. package/dist/src/lib/server/index.d.ts +30 -6
  138. package/dist/src/lib/server/index.d.ts.map +1 -1
  139. package/dist/src/lib/server/index.js +34 -11
  140. package/dist/src/lib/server/index.mjs +379 -11
  141. package/dist/src/lib/server/reactive.cjs +197 -1
  142. package/dist/src/lib/server/reactive.d.ts +18 -77
  143. package/dist/src/lib/server/reactive.d.ts.map +1 -1
  144. package/dist/src/lib/server/reactive.js +19 -78
  145. package/dist/src/lib/server/reactive.mjs +176 -1
  146. package/dist/src/lib/theme/index.cjs +110 -1
  147. package/dist/src/lib/theme/index.d.ts +19 -4
  148. package/dist/src/lib/theme/index.d.ts.map +1 -1
  149. package/dist/src/lib/theme/index.js +17 -2
  150. package/dist/src/lib/theme/index.mjs +89 -1
  151. package/dist/src/lib/utils/index.cjs +209 -1
  152. package/dist/src/lib/utils/index.d.ts +0 -93
  153. package/dist/src/lib/utils/index.d.ts.map +1 -1
  154. package/dist/src/lib/utils/index.js +0 -93
  155. package/dist/src/lib/utils/index.mjs +188 -1
  156. package/dist/src/routes.cjs +37 -1
  157. package/dist/src/routes.d.ts +1 -1
  158. package/dist/src/routes.js +2 -2
  159. package/dist/src/routes.mjs +17 -1
  160. package/dist/src/server.cjs +400 -11
  161. package/dist/src/server.d.ts +0 -1
  162. package/dist/src/server.d.ts.map +1 -1
  163. package/dist/src/server.js +0 -1
  164. package/dist/src/server.mjs +377 -11
  165. package/dist/src/utils.cjs +21 -1
  166. package/dist/src/utils.d.ts +1 -1
  167. package/dist/src/utils.js +1 -1
  168. package/dist/src/utils.mjs +4 -1
  169. package/dist/src/version.generated.cjs +26 -1
  170. package/dist/src/version.generated.d.ts +1 -1
  171. package/dist/src/version.generated.js +2 -2
  172. package/dist/src/version.generated.mjs +5 -1
  173. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  174. package/package.json +17 -16
  175. package/src/index.ts +2 -14
  176. package/dist/src/cdn/chunk-RN7C7HNS.mjs +0 -1
  177. package/dist/src/cdn/router-QB3W43UQ.mjs +0 -1
  178. package/dist/src/lib/client/chunk-FT22BLCQ.mjs +0 -1
  179. package/dist/src/lib/client/router-IH7JYMRU.mjs +0 -1
@@ -1 +1,870 @@
1
- "use strict";var H=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Oe=Object.prototype.hasOwnProperty;var R=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},_e=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Le(t))!Oe.call(e,r)&&r!==n&&H(e,r,{get:()=>t[r],enumerable:!(o=ke(t,r))||o.enumerable});return e};var Me=e=>_e(H({},"__esModule",{value:!0}),e);function J(){return Y}function F(e){Y=e}function G(e,t){O.set(e,t)}function Q(e){return O.get(e)}function De(){O.clear()}function Z(){if(typeof window>"u")return!1;let e=document.getElementById("__FLUIXI_HYDRATION__");if(!e||e.getAttribute("type")!=="application/json")return!1;try{let t=e.textContent||"{}",n=JSON.parse(t);for(let[o,r]of Object.entries(n))O.set(o,r);return!0}catch(t){return console.error("Failed to deserialize hydration data:",t),!1}}function j(){if(typeof window>"u")return;let e=document.getElementById("__FLUIXI_HYDRATION__");e&&e.remove();let t=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,null),n=[],o;for(;o=t.nextNode();){let r=o,i=r.nodeValue||"";(i.startsWith("#")||i.startsWith("/"))&&n.push(r)}n.forEach(r=>r.remove()),De()}function ee(){return typeof window>"u"}var Y,O,I=R(()=>{"use strict";Y=!1,O=new Map;typeof window<"u"&&window.addEventListener("load",()=>{setTimeout(j,100)})});function _(e,t){let n,o,r;function i(){return o||(o=e().then(s=>n=s.default)),o}t?.preload&&i();let a=(s=>{if(n){let d=n;return(0,w.untrack)(()=>d(s))}if(!r){let[d]=(0,w.createResource)(()=>i(),{transport:!1});if(r=d,d.error)throw d.error}return(0,w.createMemo)(()=>{let d=r();return d?(0,w.untrack)(()=>d(s)):void 0},void 0,{name:"lazy"})});return a.preload=()=>i().then(()=>{}),a.$lazy=!0,a.loader=e,a}var w,M=R(()=>{"use strict";w=require("@fluixi/reactive/signal")});function se(e){let t=(0,U.createContext)(e),n=o=>(o.debug,t.Provider({value:o.value,get children(){return o.children},debug:o.debug}));return typeof Symbol<"u"&&Symbol.for&&(n.$$typeof=Symbol.for("react.provider")),n.$$typeof=Symbol.for("react.provider"),{id:t.id,Provider:(0,ae.asProvider)(n),defaultValue:e}}var ae,U,Ve,ce=R(()=>{"use strict";ae=require("@fluixi/dom"),U=require("@fluixi/reactive/signal"),Ve=require("@fluixi/reactive/signal")});function ue(e,t){return async(...n)=>{let o=t+":"+JSON.stringify(n);if(J()||typeof window<"u"){let i=Q(o);if(i!==void 0)return i}if(E.has(o))return E.get(o);if(A.has(o))return A.get(o);let r=Promise.resolve(e(...n)).then(i=>(E.set(o,i),A.delete(o),ee()&&G(o,i),i),i=>{throw A.delete(o),i});return A.set(o,r),r}}function de(e){let t=typeof e=="string"?n=>n.startsWith(e):e;for(let n of E.keys())t(n)&&(E.delete(n),$e.add(n));Ue(n=>n+1)}function fe(e,t){let[n]=(0,k.createResource)(t||(()=>!0),e);return n}function le(e){return $.has(e)||$.set(e,(0,k.createSignal)(void 0)),$.get(e)}function z(e,t){let n=t||e.name||"action",o=async r=>{let[,i]=le(n),a=()=>i(void 0),s=()=>o(r);i({input:r,pending:!0,clear:a,retry:s});try{let d=await e(r);return i({input:r,result:d,pending:!1,clear:a,retry:s}),d}catch(d){throw i({input:r,error:d,pending:!1,clear:a,retry:s}),d}};return o.url=n,o.with=r=>z((...i)=>e(r,...i),t),o}function pe(e){let[t]=le(e.url);return t}function ye(e){return e}var k,E,A,gn,Ue,$e,$,ze,hn,me=R(()=>{"use strict";k=require("@fluixi/reactive/signal");I();ce();E=new Map,A=new Map;[gn,Ue]=(0,k.createSignal)(0),$e=new Set;$=new Map;ze=se(),hn=ze.Provider});var Se={};W(Se,{A:()=>at,Form:()=>st,Link:()=>we,Outlet:()=>Be,Redirect:()=>Ye,Router:()=>Xe,action:()=>z,cache:()=>ue,createAsync:()=>fe,createBrowserHistory:()=>v.createBrowserHistory,createMemoryHistory:()=>v.createMemoryHistory,lazy:()=>_,matchPath:()=>v.matchPath,matchRoutes:()=>v.matchRoutes,preloadRoutes:()=>ct,revalidate:()=>de,runWithOwner:()=>Re.runWithOwner,select:()=>nt,useAction:()=>ye,useLevelParams:()=>Ge,useLinkNavigation:()=>rt,useLocation:()=>q,useMatch:()=>et,useNavigate:()=>be,useParam:()=>Qe,useParamSelector:()=>Ze,useParams:()=>K,useRouteData:()=>ot,useRouter:()=>D,useSearchParams:()=>tt,useSubmission:()=>pe});function Ke(e,t,n){let o,r=e.route.data;if(typeof r=="function"){let T=!1;(0,c.onCleanup)(()=>{T=!0});let l=(0,c.getOwner)(),[S]=(0,c.createResource)(()=>r({params:n.params,location:n.location},l,()=>T));o=S}let i=()=>Ce.Provider({value:o,get children(){return ve.Provider({value:e.params,get children(){return xe.Provider({value:{depth:t,...n},get children(){return(0,u.createComponent)(e.component,{})}})}})}});if(!o)return i();let a=o,s=()=>a.loading,[d,m]=(0,c.createSignal)((0,c.untrack)(()=>!s()));return(0,c.createEffect)(()=>m(!s())),(0,c.createMemo)(()=>d()?i():null)}function Te(e){let t=e.depth+1,[n,o]=(0,c.createSignal)((0,c.untrack)(()=>e.matched()[t]?.component));return(0,c.createEffect)(()=>{let r=e.matched()[t]?.component;o(()=>r)}),(0,c.createMemo)(()=>{if(!n())return e.notFound?e.notFound():null;let i=(0,c.untrack)(()=>e.matched())[t];return Ke(i,t,{matched:e.matched,params:e.params,location:e.location})})}function qe(e){return e==null?We():typeof e=="function"?(0,u.createComponent)(e,{}):e}function We(){let e=(0,u.createNativeElement)("div");(0,u.setAttribute)(e,"class","fx-not-found"),(0,u.setAttribute)(e,"role","main"),(0,u.setAttribute)(e,"style","min-height:60vh;display:grid;place-content:center;gap:.25rem;text-align:center;font-family:system-ui,-apple-system,sans-serif");let t=(0,u.createNativeElement)("h1");(0,u.setAttribute)(t,"style","margin:0;font-size:2.5rem;font-weight:700"),(0,u.insert)(t,"404");let n=(0,u.createNativeElement)("p");return(0,u.setAttribute)(n,"style","margin:0;opacity:.7"),(0,u.insert)(n,"This page could not be found."),e.appendChild(t),e.appendChild(n),e}function Xe(e){let t=e.history??(0,x.createBrowserHistory)(),n=(0,x.createRouter)({routes:e.routes,base:e.base,history:t}),[o,r]=(0,c.createSignal)(n.state()),i=n.subscribe(r);(0,c.onCleanup)(()=>{i(),n.destroy()});let a=(0,c.createMemo)(()=>(o().match?.matched??[]).filter(T=>T.component)),s={router:n,location:(0,c.createMemo)(()=>o().location),params:(0,c.createMemo)(()=>o().match?.params??{})},d={depth:-1,matched:a,params:s.params,location:s.location,notFound:()=>qe(e.notFound)},m;return L.Provider({value:s,get children(){return m??=Te(d)}})}function Be(){let e=(0,y.useContext)(xe);return e?Te(e):null}function Ye(e){let t=(0,y.useContext)(L);if(t&&typeof window<"u"){let n=!1;(0,c.onCleanup)(()=>n=!0),queueMicrotask(()=>{n||t.router.navigate(e.to,{replace:e.replace!==!1})})}return null}function D(){let e=(0,y.useContext)(L);if(e)return e;if(typeof window>"u")return Je;throw new Error("[router] useRouter must be used within <Router>")}function K(){let e=D().params;return(0,c.createMemo)(()=>e(),{},{equals:(t,n)=>JSON.stringify(t)===JSON.stringify(n)})}function Ge(){return(0,y.useContext)(ve)??{}}function Qe(e){let t=K();return(0,c.createMemo)(()=>t()[e])}function Ze(e,t){let n=K();return(0,c.createMemo)(()=>e(n()),void 0,t?{equals:t}:void 0)}function et(e){let t=q();return(0,c.createMemo)(()=>(0,x.matchPath)(typeof e=="function"?e():e,t.pathname))}function tt(){let e=q(),t=be();return[(0,c.createMemo)(()=>e.query),(r,i)=>{let a=new URLSearchParams(e.search);for(let[d,m]of Object.entries(r))m===null?a.delete(d):a.set(d,m);let s=a.toString();t(e.pathname+(s?`?${s}`:""),i)}]}function nt(e,t){let n=(o,r)=>(0,he.deepEqual)(o,r);return t!==void 0?(0,c.createMemo)(()=>(0,ge.get)(e(),t),void 0,{equals:n}):(0,c.createMemo)(e,void 0,{equals:n})}function q(){let{location:e}=D();return new Proxy({},{get:(t,n)=>e()[n],has:(t,n)=>n in e(),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>Object.getOwnPropertyDescriptor(e(),n)})}function rt(e={}){let t=(0,y.useContext)(L);return n=>{if(!t||n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey)return;let r=n.target?.closest?.("a");if(!r||!r.getAttribute("href")||r.target&&r.target!=="_self"||r.hasAttribute("download")||/(^|\s)external(\s|$)/.test(r.getAttribute("rel")??""))return;let i=new URL(r.href);i.protocol!=="http:"&&i.protocol!=="https:"||i.origin===window.location.origin&&(i.hash&&i.pathname===window.location.pathname&&i.search===window.location.search||e.shouldNavigate&&!e.shouldNavigate(i,r)||(n.preventDefault(),t.router.navigate(i.pathname+i.search+i.hash,{replace:e.replace})))}}function be(){let{router:e}=D();return(t,n)=>e.navigate(t,n)}function ot(){return(0,y.useContext)(Ce)??(()=>{})}function we(e){let t=(0,y.useContext)(L),n=typeof document>"u",o=()=>t?.router.navigate(g(e.href)??"",{replace:g(e.replace)}),r=(0,u.createNativeElement)("a");(0,u.setAttribute)(r,"href",g(e.href)??""),e.slot&&(0,u.setAttribute)(r,"slot",g(e.slot));for(let a of Object.keys(e)){if(it.has(a))continue;let s=e[a];s!=null&&typeof s!="function"&&(0,u.setAttribute)(r,a,String(s))}if(typeof r.addEventListener=="function")r.addEventListener("click",a=>{a.metaKey||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),o())});else{let a=g(e.className??e.class)??"";a&&(0,u.setAttribute)(r,"class",a)}typeof r.addEventListener=="function"&&(0,c.createEffect)(()=>{let a=g(e.href)??"";r.setAttribute("href",a);let s=g(e.className??e.class)??"",d=g(e.activeClass)??"",m=g(e.active)??t?.location().pathname===a;r.className=[s,m?d:""].filter(Boolean).join(" ")});let i=e.children;return i!=null&&(0,u.insert)(r,i),r}function st(e){let t=e.action,n=e.className??e.class,o=t.url??"",r=(0,u.createNativeElement)("form");(0,u.setAttribute)(r,"method","post"),o&&(0,u.setAttribute)(r,"action",o),n&&(0,u.setAttribute)(r,"class",n);for(let a of Object.keys(e)){if(a==="action"||a==="children"||a==="class"||a==="className")continue;let s=e[a];s!=null&&typeof s!="function"&&(0,u.setAttribute)(r,a,String(s))}typeof r.addEventListener=="function"&&r.addEventListener("submit",a=>{a.preventDefault();let s={};new FormData(r).forEach((d,m)=>{s[m]=d}),Promise.resolve(t(s)).catch(()=>{})});let i=e.children;return i!=null&&(0,u.insert)(r,i),r}async function ct(e,t){let n=(0,x.matchRoutes)(e,t);if(!n)return;let o=[];for(let r of n.matched){let i=r.component;i&&typeof i.preload=="function"&&o.push(i.preload())}await Promise.all(o)}var c,u,y,ge,he,x,v,Re,L,xe,ve,Ce,Je,g,it,at,Pe=R(()=>{"use strict";c=require("@fluixi/reactive/signal"),u=require("@fluixi/dom"),y=require("@fluixi/reactive/signal"),ge=require("@fluixi/utils/object"),he=require("@fluixi/utils/compare"),x=require("@fluixi/router"),v=require("@fluixi/router");me();M();Re=require("@fluixi/reactive/signal"),L=(0,y.createContext)(),xe=(0,y.createContext)(),ve=(0,y.createContext)(),Ce=(0,y.createContext)();Je={router:{navigate:()=>{}},location:()=>({pathname:"",search:"",hash:"",query:{}}),params:()=>({})};g=e=>typeof e=="function"?e():e,it=new Set(["href","slot","class","className","active","activeClass","replace","children"]);at=we});var lt={};W(lt,{hydrate:()=>Ae.hydrate,mount:()=>ut,startClient:()=>dt});module.exports=Me(lt);var N=require("@fluixi/dom");var B=require("@fluixi/dom");var X="1.0.0-alpha.82";var b=require("@fluixi/dom");(0,B.registerCoreVersion)(X);I();var oe=require("@fluixi/reactive/signal");var P=require("@fluixi/dom");var te=require("@fluixi/dom"),p=require("@fluixi/reactive/signal");var f=require("@fluixi/reactive/signal"),h=require("@fluixi/dom");function ne(e){return!!(e&&typeof e=="object"&&typeof e.then=="function"||e instanceof Promise)}var Ne=(0,f.createContext)();function V(e){return(0,h.createComponent)(He,e)}function He(e){let t=(0,f.createSuspenseBoundary)(),n=(0,f.useContext)(Ne),o=n?n.register(t.inFallback):void 0;function r(l){return l==null||typeof l=="boolean"?null:typeof l=="function"&&(0,h.isComponent)(l)&&!(0,f.isSignal)(l)?l():l}let i=(0,h.runWithoutHydration)(()=>r(e.fallback??null)),a=(0,f.provideSuspense)(t,()=>(0,f.readChildren)(()=>e.children)),s=(l,S)=>{if(!(S>8))if(Array.isArray(l))for(let Ee of l)s(Ee,S+1);else typeof l=="function"&&(0,f.isSignal)(l)&&s(l(),S+1)};(0,f.provideSuspense)(t,()=>{(0,f.createRenderEffect)(()=>s(a,0))});let[d,m]=(0,f.createSignal)(void 0),T=ne(a);return T&&(t.increment(),a.then(l=>{m(()=>l),t.decrement()},()=>t.decrement())),(0,f.createMemo)(()=>(o?o.showFallback():t.inFallback())?i:T?d():a)}(0,h.asSuspense)(V);Object.defineProperty(V,"__suspense",{value:!0,enumerable:!0});M();var re=require("@fluixi/reactive/signal"),Fe=require("@fluixi/dom/utils");M();var je=require("@fluixi/reactive/signal");var Ie=typeof window>"u";function ie(e,t,n={}){if((0,P.delegateEvents)(["click","input","change","submit"]),Ie)throw new Error("render() is for client-side only. Use renderToString() on server.");if(!t)throw new Error("Container element is required");let o;return(0,oe.createRoot)(r=>{o=r;let i=typeof e=="function"?e():e;t.textContent="",(0,b.stampVersions)(t),(0,b.warnOnVersionSkew)(),(0,P.insert)(t,()=>i)}),()=>{o&&(o(),o=void 0)}}var C=require("@fluixi/head"),Ae=require("@fluixi/dom");function ut(e,t){if(!t)throw new Error("Container element not found for mount()");(0,N.render)(()=>e(),t)}async function dt(e,t={}){let n=typeof t.root=="string"?document.querySelector(t.root):t.root??document.querySelector("#app");if(!n)throw new Error(`[Fluixi] Mount container not found: ${t.root??"#app"}`);let o=!!document.getElementById("__FLUIXI_HYDRATION__")||!!t.routes&&n.firstElementChild!=null,r=t.hydrate??o,i=(0,C.createHead)();if((0,C.setActiveHead)(i),(0,C.stripHeadMarker)(n),r){if(t.routes&&t.routes.length){let{preloadRoutes:a}=await Promise.resolve().then(()=>(Pe(),Se));await a(t.routes,window.location.pathname)}Z(),F(!0),(0,N.hydrate)(()=>e(),n),ft(),setTimeout(()=>{F(!1),j()},100)}else ie(()=>e(),n);(0,C.mountHead)(i)}function ft(){if(typeof window>"u")return;let e=window;typeof e.__FX_REPLAY_STOP__=="function"&&e.__FX_REPLAY_STOP__();let t=e.__FX_REPLAY__;if(e.__FX_REPLAY__=void 0,e.__FX_REPLAY_STOP__=void 0,!(!Array.isArray(t)||t.length===0))for(let n of t){let o=n&&n.target;if(!o||o.isConnected===!1||typeof o.dispatchEvent!="function")continue;let r=n.type,i=r==="click"?new MouseEvent(r,{bubbles:!0,cancelable:!0}):new Event(r,{bubbles:!0,cancelable:!0});o.dispatchEvent(i)}}
1
+ /*! @fluixi/core v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+
24
+ // src/lib/server/hydration.ts
25
+ function isHydrating() {
26
+ return hydrating;
27
+ }
28
+ function setHydrating(state) {
29
+ hydrating = state;
30
+ }
31
+ function setHydrationData(key, data) {
32
+ hydrationDataMap.set(key, data);
33
+ }
34
+ function getHydrationData(key) {
35
+ return hydrationDataMap.get(key);
36
+ }
37
+ function clearHydrationData() {
38
+ hydrationDataMap.clear();
39
+ }
40
+ function deserializeHydrationData() {
41
+ if (typeof window === "undefined") {
42
+ return false;
43
+ }
44
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
45
+ if (!script || script.getAttribute("type") !== "application/json") {
46
+ return false;
47
+ }
48
+ try {
49
+ const json = script.textContent || "{}";
50
+ const data = JSON.parse(json);
51
+ for (const [key, value] of Object.entries(data)) {
52
+ hydrationDataMap.set(key, value);
53
+ }
54
+ return true;
55
+ } catch (error) {
56
+ console.error("Failed to deserialize hydration data:", error);
57
+ return false;
58
+ }
59
+ }
60
+ function cleanupHydration() {
61
+ if (typeof window === "undefined") {
62
+ return;
63
+ }
64
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
65
+ if (script) {
66
+ script.remove();
67
+ }
68
+ const walker = document.createTreeWalker(
69
+ document.body,
70
+ NodeFilter.SHOW_COMMENT,
71
+ null
72
+ );
73
+ const comments = [];
74
+ let node;
75
+ while (node = walker.nextNode()) {
76
+ const comment = node;
77
+ const text = comment.nodeValue || "";
78
+ if (text.startsWith("#") || text.startsWith("/")) {
79
+ comments.push(comment);
80
+ }
81
+ }
82
+ comments.forEach((comment) => comment.remove());
83
+ clearHydrationData();
84
+ }
85
+ function isServerEnvironment() {
86
+ return (0, import_dom3.isServer)();
87
+ }
88
+ var import_dom3, hydrating, hydrationDataMap;
89
+ var init_hydration = __esm({
90
+ "src/lib/server/hydration.ts"() {
91
+ "use strict";
92
+ import_dom3 = require("@fluixi/dom");
93
+ hydrating = false;
94
+ hydrationDataMap = /* @__PURE__ */ new Map();
95
+ if (typeof window !== "undefined") {
96
+ window.addEventListener("load", () => {
97
+ setTimeout(cleanupHydration, 100);
98
+ });
99
+ }
100
+ }
101
+ });
102
+
103
+ // src/lib/render/lazy.ts
104
+ function fromChunk(value) {
105
+ if (value != null && (typeof value === "object" || typeof value === "function")) {
106
+ try {
107
+ value["$lazy"] = true;
108
+ } catch {
109
+ }
110
+ }
111
+ return value;
112
+ }
113
+ function lazy(loader, options) {
114
+ let resolved;
115
+ let promise;
116
+ let component;
117
+ function load() {
118
+ if (!promise) {
119
+ promise = loader().then((mod) => resolved = mod.default);
120
+ }
121
+ return promise;
122
+ }
123
+ if (options?.preload) load();
124
+ const LazyWrapper = ((props) => {
125
+ if (resolved) {
126
+ const C = resolved;
127
+ return fromChunk((0, import_signal3.untrack)(() => C(props)));
128
+ }
129
+ if (!component) {
130
+ const [resource] = (0, import_signal3.createResource)(() => load(), { transport: false });
131
+ component = resource;
132
+ if (resource.error) throw resource.error;
133
+ }
134
+ return (0, import_signal3.createMemo)(() => {
135
+ const C = component();
136
+ return C ? fromChunk((0, import_dom7.createComponent)(C, props)) : void 0;
137
+ });
138
+ });
139
+ LazyWrapper.preload = () => load().then(() => void 0);
140
+ LazyWrapper.$lazy = true;
141
+ LazyWrapper.loader = loader;
142
+ return LazyWrapper;
143
+ }
144
+ var import_dom7, import_signal3;
145
+ var init_lazy = __esm({
146
+ "src/lib/render/lazy.ts"() {
147
+ "use strict";
148
+ import_dom7 = require("@fluixi/dom");
149
+ import_signal3 = require("@fluixi/reactive/signal");
150
+ }
151
+ });
152
+
153
+ // src/lib/context/context.ts
154
+ function createContext3(defaultValue, name) {
155
+ const context = (0, import_signal7.createContext)(defaultValue, name);
156
+ const Provider = (props) => {
157
+ if (props.debug === true) {
158
+ }
159
+ return context.Provider({
160
+ value: props.value,
161
+ get children() {
162
+ return props.children;
163
+ },
164
+ debug: props.debug
165
+ });
166
+ };
167
+ if (typeof Symbol !== "undefined" && Symbol.for) {
168
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
169
+ }
170
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
171
+ return {
172
+ id: context.id,
173
+ Provider: (0, import_dom11.asProvider)(Provider),
174
+ defaultValue
175
+ };
176
+ }
177
+ var import_dom11, import_signal7, import_signal8;
178
+ var init_context = __esm({
179
+ "src/lib/context/context.ts"() {
180
+ "use strict";
181
+ import_dom11 = require("@fluixi/dom");
182
+ import_signal7 = require("@fluixi/reactive/signal");
183
+ import_signal8 = require("@fluixi/reactive/signal");
184
+ }
185
+ });
186
+
187
+ // src/lib/router/data.ts
188
+ function cache(fn, name) {
189
+ return async (...args) => {
190
+ const key = name + ":" + JSON.stringify(args);
191
+ if (isHydrating() || typeof window !== "undefined") {
192
+ const hydrated = getHydrationData(key);
193
+ if (hydrated !== void 0) {
194
+ return hydrated;
195
+ }
196
+ }
197
+ if (globalCache.has(key)) {
198
+ return globalCache.get(key);
199
+ }
200
+ if (inflightRequests.has(key)) {
201
+ return inflightRequests.get(key);
202
+ }
203
+ const promise = Promise.resolve(fn(...args)).then(
204
+ (val) => {
205
+ globalCache.set(key, val);
206
+ inflightRequests.delete(key);
207
+ if (isServerEnvironment()) {
208
+ setHydrationData(key, val);
209
+ }
210
+ return val;
211
+ },
212
+ (err) => {
213
+ inflightRequests.delete(key);
214
+ throw err;
215
+ }
216
+ );
217
+ inflightRequests.set(key, promise);
218
+ return promise;
219
+ };
220
+ }
221
+ function revalidate(key) {
222
+ const predicate = typeof key === "string" ? (k) => k.startsWith(key) : key;
223
+ for (const k of globalCache.keys()) {
224
+ if (predicate(k)) {
225
+ globalCache.delete(k);
226
+ revalidationKeys.add(k);
227
+ }
228
+ }
229
+ setRevalidationVersion((v) => v + 1);
230
+ }
231
+ function createAsync(fetcher, source) {
232
+ const [data] = (0, import_signal9.createResource)(source || (() => true), fetcher);
233
+ return data;
234
+ }
235
+ function getSubmissionSignal(url) {
236
+ if (!submissionState.has(url)) {
237
+ submissionState.set(
238
+ url,
239
+ (0, import_signal9.createSignal)(void 0)
240
+ );
241
+ }
242
+ return submissionState.get(url);
243
+ }
244
+ function action(fn, name) {
245
+ const actionUrl = name || fn.name || "action";
246
+ const submit = async (input) => {
247
+ const [, setSubmission] = getSubmissionSignal(actionUrl);
248
+ const clear = () => setSubmission(void 0);
249
+ const retry = () => submit(input);
250
+ setSubmission({
251
+ input,
252
+ // Approximate type for tracking
253
+ pending: true,
254
+ clear,
255
+ retry
256
+ });
257
+ try {
258
+ const result = await fn(input);
259
+ setSubmission({
260
+ input,
261
+ result,
262
+ pending: false,
263
+ clear,
264
+ retry
265
+ });
266
+ return result;
267
+ } catch (error) {
268
+ setSubmission({
269
+ input,
270
+ error,
271
+ pending: false,
272
+ clear,
273
+ retry
274
+ });
275
+ throw error;
276
+ }
277
+ };
278
+ submit.url = actionUrl;
279
+ submit.with = (args) => action((...a) => fn(args, ...a), name);
280
+ return submit;
281
+ }
282
+ function useSubmission(actionFn) {
283
+ const [submission] = getSubmissionSignal(actionFn.url);
284
+ return submission;
285
+ }
286
+ function useAction(actionFn) {
287
+ return actionFn;
288
+ }
289
+ var import_signal9, globalCache, inflightRequests, revalidationVersion, setRevalidationVersion, revalidationKeys, submissionState, RouteDataContext, RouteDataProvider;
290
+ var init_data = __esm({
291
+ "src/lib/router/data.ts"() {
292
+ "use strict";
293
+ import_signal9 = require("@fluixi/reactive/signal");
294
+ init_hydration();
295
+ init_context();
296
+ globalCache = /* @__PURE__ */ new Map();
297
+ inflightRequests = /* @__PURE__ */ new Map();
298
+ [revalidationVersion, setRevalidationVersion] = (0, import_signal9.createSignal)(0);
299
+ revalidationKeys = /* @__PURE__ */ new Set();
300
+ submissionState = /* @__PURE__ */ new Map();
301
+ RouteDataContext = createContext3(void 0, "route-data");
302
+ RouteDataProvider = RouteDataContext.Provider;
303
+ }
304
+ });
305
+
306
+ // src/lib/router/index.ts
307
+ var router_exports = {};
308
+ __export(router_exports, {
309
+ A: () => A,
310
+ Form: () => Form,
311
+ Link: () => Link,
312
+ Outlet: () => Outlet,
313
+ Redirect: () => Redirect,
314
+ Router: () => Router,
315
+ action: () => action,
316
+ cache: () => cache,
317
+ createAsync: () => createAsync,
318
+ createBrowserHistory: () => import_router2.createBrowserHistory,
319
+ createMemoryHistory: () => import_router2.createMemoryHistory,
320
+ lazy: () => lazy,
321
+ matchPath: () => import_router2.matchPath,
322
+ matchRoutes: () => import_router2.matchRoutes,
323
+ preloadRoutes: () => preloadRoutes,
324
+ revalidate: () => revalidate,
325
+ runWithOwner: () => import_signal12.runWithOwner,
326
+ select: () => select,
327
+ useAction: () => useAction,
328
+ useLevelParams: () => useLevelParams,
329
+ useLinkNavigation: () => useLinkNavigation,
330
+ useLocation: () => useLocation,
331
+ useMatch: () => useMatch,
332
+ useNavigate: () => useNavigate,
333
+ useParam: () => useParam,
334
+ useParamSelector: () => useParamSelector,
335
+ useParams: () => useParams,
336
+ useRouteData: () => useRouteData,
337
+ useRouter: () => useRouter,
338
+ useSearchParams: () => useSearchParams,
339
+ useSubmission: () => useSubmission
340
+ });
341
+ function renderLayer(m, depth, base) {
342
+ let data;
343
+ const loader = m.route.data;
344
+ if (typeof loader === "function") {
345
+ let cancelled = false;
346
+ (0, import_signal10.onCleanup)(() => {
347
+ cancelled = true;
348
+ });
349
+ const owner = (0, import_signal10.getOwner)();
350
+ const [resource] = (0, import_signal10.createResource)(
351
+ () => loader({ params: base.params, location: base.location }, owner, () => cancelled)
352
+ );
353
+ data = resource;
354
+ }
355
+ const buildPage = () => RouteDataContext2.Provider({
356
+ value: data,
357
+ get children() {
358
+ return LevelParamsContext.Provider({
359
+ value: m.params,
360
+ get children() {
361
+ return OutletContext.Provider({
362
+ value: { depth, ...base },
363
+ get children() {
364
+ return (0, import_dom12.createComponent)(m.component, {});
365
+ }
366
+ });
367
+ }
368
+ });
369
+ }
370
+ });
371
+ if (!data) return buildPage();
372
+ const res = data;
373
+ const isLoading = () => res.loading;
374
+ const [ready, setReady] = (0, import_signal10.createSignal)((0, import_signal10.untrack)(() => !isLoading()));
375
+ (0, import_signal10.createEffect)(() => setReady(!isLoading()));
376
+ return (0, import_signal10.createMemo)(() => ready() ? buildPage() : null);
377
+ }
378
+ function renderChild(ctx) {
379
+ const childIdx = ctx.depth + 1;
380
+ const [childComp, setChildComp] = (0, import_signal10.createSignal)(
381
+ (0, import_signal10.untrack)(() => ctx.matched()[childIdx]?.component)
382
+ );
383
+ (0, import_signal10.createEffect)(() => {
384
+ const c = ctx.matched()[childIdx]?.component;
385
+ setChildComp(() => c);
386
+ });
387
+ return (0, import_signal10.createMemo)(() => {
388
+ const component = childComp();
389
+ if (!component) {
390
+ return ctx.notFound ? ctx.notFound() : null;
391
+ }
392
+ const m = (0, import_signal10.untrack)(() => ctx.matched())[childIdx];
393
+ return renderLayer(m, childIdx, {
394
+ matched: ctx.matched,
395
+ params: ctx.params,
396
+ location: ctx.location
397
+ });
398
+ });
399
+ }
400
+ function renderNotFound(notFound) {
401
+ if (notFound == null) return buildDefaultNotFound();
402
+ return typeof notFound === "function" ? (0, import_dom12.createComponent)(notFound, {}) : notFound;
403
+ }
404
+ function buildDefaultNotFound() {
405
+ const el = (0, import_dom12.createNativeElement)("div");
406
+ (0, import_dom12.setAttribute)(el, "class", "fx-not-found");
407
+ (0, import_dom12.setAttribute)(el, "role", "main");
408
+ (0, import_dom12.setAttribute)(
409
+ el,
410
+ "style",
411
+ "min-height:60vh;display:grid;place-content:center;gap:.25rem;text-align:center;font-family:system-ui,-apple-system,sans-serif"
412
+ );
413
+ const h1 = (0, import_dom12.createNativeElement)("h1");
414
+ (0, import_dom12.setAttribute)(h1, "style", "margin:0;font-size:2.5rem;font-weight:700");
415
+ (0, import_dom12.insert)(h1, "404");
416
+ const p = (0, import_dom12.createNativeElement)("p");
417
+ (0, import_dom12.setAttribute)(p, "style", "margin:0;opacity:.7");
418
+ (0, import_dom12.insert)(p, "This page could not be found.");
419
+ el.appendChild(h1);
420
+ el.appendChild(p);
421
+ return el;
422
+ }
423
+ function Router(props) {
424
+ const history = props.history ?? (0, import_router.createBrowserHistory)();
425
+ const router = (0, import_router.createRouter)({
426
+ routes: props.routes,
427
+ base: props.base,
428
+ history
429
+ });
430
+ const [state, setState] = (0, import_signal10.createSignal)(router.state());
431
+ const unsub = router.subscribe(setState);
432
+ (0, import_signal10.onCleanup)(() => {
433
+ unsub();
434
+ router.destroy();
435
+ });
436
+ const matched = (0, import_signal10.createMemo)(
437
+ () => (state().match?.matched ?? []).filter((m) => m.component)
438
+ );
439
+ const ctx = {
440
+ router,
441
+ location: (0, import_signal10.createMemo)(() => state().location),
442
+ params: (0, import_signal10.createMemo)(() => state().match?.params ?? {})
443
+ };
444
+ const root = {
445
+ depth: -1,
446
+ matched,
447
+ params: ctx.params,
448
+ location: ctx.location,
449
+ // Only the root carries this: renderChild shows it when the URL matched nothing.
450
+ notFound: () => renderNotFound(props.notFound)
451
+ };
452
+ let rootView;
453
+ return RouterContext.Provider({
454
+ value: ctx,
455
+ get children() {
456
+ return rootView ??= renderChild(root);
457
+ }
458
+ });
459
+ }
460
+ function Outlet() {
461
+ const ctx = (0, import_signal11.useContext)(OutletContext);
462
+ if (!ctx) return null;
463
+ return renderChild(ctx);
464
+ }
465
+ function Redirect(props) {
466
+ const ctx = (0, import_signal11.useContext)(RouterContext);
467
+ if (ctx && typeof window !== "undefined") {
468
+ let cancelled = false;
469
+ (0, import_signal10.onCleanup)(() => cancelled = true);
470
+ queueMicrotask(() => {
471
+ if (!cancelled) ctx.router.navigate(props.to, { replace: props.replace !== false });
472
+ });
473
+ }
474
+ return null;
475
+ }
476
+ function useRouter() {
477
+ const ctx = (0, import_signal11.useContext)(RouterContext);
478
+ if (ctx) return ctx;
479
+ if (typeof window === "undefined") return _ssrRouterStub;
480
+ throw new Error("[router] useRouter must be used within <Router>");
481
+ }
482
+ function useParams() {
483
+ const params = useRouter().params;
484
+ return (0, import_signal10.createMemo)(() => params(), {}, {
485
+ equals: (a, b) => JSON.stringify(a) === JSON.stringify(b)
486
+ });
487
+ }
488
+ function useLevelParams() {
489
+ return (0, import_signal11.useContext)(LevelParamsContext) ?? {};
490
+ }
491
+ function useParam(key) {
492
+ const params = useParams();
493
+ return (0, import_signal10.createMemo)(() => params()[key]);
494
+ }
495
+ function useParamSelector(selector, equals) {
496
+ const params = useParams();
497
+ return (0, import_signal10.createMemo)(
498
+ () => selector(params()),
499
+ void 0,
500
+ equals ? { equals } : void 0
501
+ );
502
+ }
503
+ function useMatch(path) {
504
+ const location = useLocation();
505
+ return (0, import_signal10.createMemo)(
506
+ () => (0, import_router.matchPath)(typeof path === "function" ? path() : path, location.pathname)
507
+ );
508
+ }
509
+ function useSearchParams() {
510
+ const location = useLocation();
511
+ const navigate = useNavigate();
512
+ const params = (0, import_signal10.createMemo)(() => location.query);
513
+ const setParams = (next, options) => {
514
+ const current = new URLSearchParams(location.search);
515
+ for (const [k, v] of Object.entries(next)) {
516
+ if (v === null) current.delete(k);
517
+ else current.set(k, v);
518
+ }
519
+ const search = current.toString();
520
+ navigate(location.pathname + (search ? `?${search}` : ""), options);
521
+ };
522
+ return [params, setParams];
523
+ }
524
+ function select(source, key) {
525
+ const equals = (a, b) => (0, import_compare.deepEqual)(a, b);
526
+ if (key !== void 0) {
527
+ return (0, import_signal10.createMemo)(
528
+ () => (0, import_object.get)(source(), key),
529
+ void 0,
530
+ { equals }
531
+ );
532
+ }
533
+ return (0, import_signal10.createMemo)(source, void 0, { equals });
534
+ }
535
+ function useLocation() {
536
+ const { location } = useRouter();
537
+ return new Proxy({}, {
538
+ get: (_t, key) => location()[key],
539
+ has: (_t, key) => key in location(),
540
+ ownKeys: () => Reflect.ownKeys(location()),
541
+ getOwnPropertyDescriptor: (_t, key) => Object.getOwnPropertyDescriptor(location(), key)
542
+ });
543
+ }
544
+ function useLinkNavigation(options = {}) {
545
+ const ctx = (0, import_signal11.useContext)(RouterContext);
546
+ return (event) => {
547
+ if (!ctx || event.defaultPrevented || event.button !== 0) return;
548
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
549
+ const target = event.target;
550
+ const anchor = target?.closest?.("a");
551
+ if (!anchor || !anchor.getAttribute("href")) return;
552
+ if (anchor.target && anchor.target !== "_self") return;
553
+ if (anchor.hasAttribute("download")) return;
554
+ if (/(^|\s)external(\s|$)/.test(anchor.getAttribute("rel") ?? "")) return;
555
+ const url = new URL(anchor.href);
556
+ if (url.protocol !== "http:" && url.protocol !== "https:") return;
557
+ if (url.origin !== window.location.origin) return;
558
+ if (url.hash && url.pathname === window.location.pathname && url.search === window.location.search) return;
559
+ if (options.shouldNavigate && !options.shouldNavigate(url, anchor)) return;
560
+ event.preventDefault();
561
+ ctx.router.navigate(url.pathname + url.search + url.hash, { replace: options.replace });
562
+ };
563
+ }
564
+ function useNavigate() {
565
+ const { router } = useRouter();
566
+ return (to, options) => router.navigate(to, options);
567
+ }
568
+ function useRouteData() {
569
+ const acc = (0, import_signal11.useContext)(RouteDataContext2);
570
+ return acc ?? (() => void 0);
571
+ }
572
+ function Link(props) {
573
+ const ctx = (0, import_signal11.useContext)(RouterContext);
574
+ const navigate = () => ctx?.router.navigate(read(props.href) ?? "", { replace: read(props.replace) });
575
+ const a = (0, import_dom12.createNativeElement)("a");
576
+ (0, import_dom12.setAttribute)(a, "href", read(props.href) ?? "");
577
+ if (props.slot) (0, import_dom12.setAttribute)(a, "slot", read(props.slot));
578
+ for (const k of Object.keys(props)) {
579
+ if (LINK_OWN_PROPS.has(k)) continue;
580
+ const v = props[k];
581
+ if (v != null && typeof v !== "function") (0, import_dom12.setAttribute)(a, k, String(v));
582
+ }
583
+ if (typeof a.addEventListener === "function") {
584
+ a.addEventListener("click", (e) => {
585
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
586
+ e.preventDefault();
587
+ navigate();
588
+ });
589
+ } else {
590
+ const base = read(props.className ?? props.class) ?? "";
591
+ if (base) (0, import_dom12.setAttribute)(a, "class", base);
592
+ }
593
+ if (typeof a.addEventListener === "function") {
594
+ (0, import_signal10.createEffect)(() => {
595
+ const href = read(props.href) ?? "";
596
+ a.setAttribute("href", href);
597
+ const base = read(props.className ?? props.class) ?? "";
598
+ const activeClass = read(props.activeClass) ?? "";
599
+ const active = read(props.active) ?? ctx?.location().pathname === href;
600
+ a.className = [base, active ? activeClass : ""].filter(Boolean).join(" ");
601
+ });
602
+ }
603
+ const linkChildren = props.children;
604
+ if (linkChildren != null) (0, import_dom12.insert)(a, linkChildren);
605
+ return a;
606
+ }
607
+ function Form(props) {
608
+ const action2 = props.action;
609
+ const cls = props.className ?? props.class;
610
+ const url = action2.url ?? "";
611
+ const form = (0, import_dom12.createNativeElement)("form");
612
+ (0, import_dom12.setAttribute)(form, "method", "post");
613
+ if (url) (0, import_dom12.setAttribute)(form, "action", url);
614
+ if (cls) (0, import_dom12.setAttribute)(form, "class", cls);
615
+ for (const k of Object.keys(props)) {
616
+ if (k === "action" || k === "children" || k === "class" || k === "className") continue;
617
+ const v = props[k];
618
+ if (v != null && typeof v !== "function") (0, import_dom12.setAttribute)(form, k, String(v));
619
+ }
620
+ if (typeof form.addEventListener === "function") {
621
+ form.addEventListener("submit", (e) => {
622
+ e.preventDefault();
623
+ const data = {};
624
+ new FormData(form).forEach((v, k) => {
625
+ data[k] = v;
626
+ });
627
+ Promise.resolve(action2(data)).catch(() => {
628
+ });
629
+ });
630
+ }
631
+ const children = props.children;
632
+ if (children != null) (0, import_dom12.insert)(form, children);
633
+ return form;
634
+ }
635
+ async function preloadRoutes(routes, pathname) {
636
+ const match = (0, import_router.matchRoutes)(routes, pathname);
637
+ if (!match) return;
638
+ const loads = [];
639
+ for (const m of match.matched) {
640
+ const c = m.component;
641
+ if (c && typeof c.preload === "function") loads.push(c.preload());
642
+ }
643
+ await Promise.all(loads);
644
+ }
645
+ var import_signal10, import_dom12, import_signal11, import_object, import_compare, import_router, import_router2, import_signal12, RouterContext, OutletContext, LevelParamsContext, RouteDataContext2, _ssrRouterStub, read, LINK_OWN_PROPS, A;
646
+ var init_router = __esm({
647
+ "src/lib/router/index.ts"() {
648
+ "use strict";
649
+ import_signal10 = require("@fluixi/reactive/signal");
650
+ import_dom12 = require("@fluixi/dom");
651
+ import_signal11 = require("@fluixi/reactive/signal");
652
+ import_object = require("@fluixi/utils/object");
653
+ import_compare = require("@fluixi/utils/compare");
654
+ import_router = require("@fluixi/router");
655
+ import_router2 = require("@fluixi/router");
656
+ init_data();
657
+ init_lazy();
658
+ import_signal12 = require("@fluixi/reactive/signal");
659
+ RouterContext = (0, import_signal11.createContext)(void 0, "router");
660
+ OutletContext = (0, import_signal11.createContext)(void 0, "outlet");
661
+ LevelParamsContext = (0, import_signal11.createContext)(void 0, "route-params");
662
+ RouteDataContext2 = (0, import_signal11.createContext)(void 0, "route-data");
663
+ _ssrRouterStub = {
664
+ router: { navigate: () => {
665
+ } },
666
+ location: () => ({ pathname: "", search: "", hash: "", query: {} }),
667
+ params: () => ({})
668
+ };
669
+ read = (v) => typeof v === "function" ? v() : v;
670
+ LINK_OWN_PROPS = /* @__PURE__ */ new Set([
671
+ "href",
672
+ "slot",
673
+ "class",
674
+ "className",
675
+ "active",
676
+ "activeClass",
677
+ "replace",
678
+ "children"
679
+ ]);
680
+ A = Link;
681
+ }
682
+ });
683
+
684
+ // src/lib/client/index.ts
685
+ var index_exports = {};
686
+ __export(index_exports, {
687
+ hydrate: () => import_dom14.hydrate,
688
+ mount: () => mount,
689
+ startClient: () => startClient
690
+ });
691
+ module.exports = __toCommonJS(index_exports);
692
+ var import_dom13 = require("@fluixi/dom");
693
+
694
+ // src/lib/render/versions.ts
695
+ var import_dom = require("@fluixi/dom");
696
+
697
+ // src/version.generated.ts
698
+ var VERSION = "1.0.0-alpha.84";
699
+
700
+ // src/lib/render/versions.ts
701
+ var import_dom2 = require("@fluixi/dom");
702
+ (0, import_dom.registerCoreVersion)(VERSION);
703
+
704
+ // src/lib/client/index.ts
705
+ init_hydration();
706
+
707
+ // src/lib/render/index.ts
708
+ var import_dom9 = require("@fluixi/dom");
709
+ var import_signal6 = require("@fluixi/reactive/signal");
710
+ var import_dom10 = require("@fluixi/dom");
711
+
712
+ // src/lib/render/component.ts
713
+ var import_dom4 = require("@fluixi/dom");
714
+ var import_dom5 = require("@fluixi/dom");
715
+ var import_signal = require("@fluixi/reactive/signal");
716
+ function createComponent(Comp, props) {
717
+ return (0, import_dom5.createComponent)(Comp, props);
718
+ }
719
+
720
+ // src/lib/render/suspense.ts
721
+ var import_signal2 = require("@fluixi/reactive/signal");
722
+ var import_dom6 = require("@fluixi/dom");
723
+ function isPromise(value) {
724
+ return !!(value && typeof value === "object" && typeof value.then === "function" || value instanceof Promise);
725
+ }
726
+ var SuspenseListContext = (0, import_signal2.createContext)(void 0, "suspense-list");
727
+ function Suspense(props) {
728
+ return (0, import_dom6.createComponent)(SuspenseImpl, props);
729
+ }
730
+ function SuspenseImpl(props) {
731
+ const boundary = (0, import_signal2.createSuspenseBoundary)();
732
+ const listCtx = (0, import_signal2.useContext)(SuspenseListContext);
733
+ const listState = listCtx ? listCtx.register(boundary.inFallback) : void 0;
734
+ function instantiateOnce(val) {
735
+ if (val == null || typeof val === "boolean") return null;
736
+ if (typeof val === "function" && (0, import_dom6.isComponent)(val) && !(0, import_signal2.isSignal)(val)) return val();
737
+ return val;
738
+ }
739
+ const fallback = (0, import_dom6.runWithoutHydration)(() => instantiateOnce(props.fallback ?? null));
740
+ const children = (0, import_signal2.provideSuspense)(boundary, () => (0, import_signal2.readChildren)(() => props.children));
741
+ const track = (value, depth) => {
742
+ if (depth > 8) return;
743
+ if (Array.isArray(value)) {
744
+ for (const x of value) track(x, depth + 1);
745
+ } else if (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
746
+ track(value(), depth + 1);
747
+ }
748
+ };
749
+ (0, import_signal2.provideSuspense)(boundary, () => {
750
+ (0, import_signal2.createRenderEffect)(() => track(children, 0));
751
+ });
752
+ const [resolved, setResolved] = (0, import_signal2.createSignal)(void 0);
753
+ const childIsPromise = isPromise(children);
754
+ if (childIsPromise) {
755
+ boundary.increment();
756
+ children.then(
757
+ (v) => {
758
+ setResolved(() => v);
759
+ boundary.decrement();
760
+ },
761
+ () => boundary.decrement()
762
+ );
763
+ }
764
+ return (0, import_signal2.createMemo)(() => {
765
+ const showFallback = listState ? listState.showFallback() : boundary.inFallback();
766
+ if (showFallback) return fallback;
767
+ if (childIsPromise) return resolved();
768
+ return children;
769
+ });
770
+ }
771
+ (0, import_dom6.asSuspense)(Suspense);
772
+ Object.defineProperty(Suspense, "__suspense", { value: true, enumerable: true });
773
+
774
+ // src/lib/render/index.ts
775
+ init_lazy();
776
+
777
+ // src/lib/render/deferred.ts
778
+ var import_dom8 = require("@fluixi/dom");
779
+ var import_signal4 = require("@fluixi/reactive/signal");
780
+ var import_utils = require("@fluixi/dom/utils");
781
+ init_lazy();
782
+
783
+ // src/lib/render/await.ts
784
+ var import_signal5 = require("@fluixi/reactive/signal");
785
+
786
+ // src/lib/render/index.ts
787
+ function render(code, container, options = {}) {
788
+ (0, import_dom10.delegateEvents)(["click", "input", "change", "submit"]);
789
+ if ((0, import_dom9.isServer)()) {
790
+ throw new Error(
791
+ "render() is for client-side only. Use renderToString() on server."
792
+ );
793
+ }
794
+ if (!container) {
795
+ throw new Error("Container element is required");
796
+ }
797
+ let disposer;
798
+ (0, import_signal6.createRoot)((dispose) => {
799
+ disposer = dispose;
800
+ const result = typeof code === "function" ? code() : code;
801
+ container.textContent = "";
802
+ (0, import_dom2.stampVersions)(container);
803
+ (0, import_dom2.warnOnVersionSkew)();
804
+ (0, import_dom10.insert)(container, () => result);
805
+ });
806
+ return () => {
807
+ if (disposer) {
808
+ disposer();
809
+ disposer = void 0;
810
+ }
811
+ };
812
+ }
813
+
814
+ // src/lib/client/index.ts
815
+ var import_signal13 = require("@fluixi/reactive/signal");
816
+ var import_head = require("@fluixi/head");
817
+ var import_dom14 = require("@fluixi/dom");
818
+ function mount(App, container) {
819
+ if (!container) {
820
+ throw new Error("Container element not found for mount()");
821
+ }
822
+ (0, import_dom13.render)(() => App(), container);
823
+ }
824
+ var rootOf = (App) => (0, import_signal13.createMemo)(() => createComponent(App));
825
+ async function startClient(App, options = {}) {
826
+ const container = typeof options.root === "string" ? document.querySelector(options.root) : options.root ?? document.querySelector("#app");
827
+ if (!container) {
828
+ throw new Error(
829
+ `[Fluixi] Mount container not found: ${options.root ?? "#app"}`
830
+ );
831
+ }
832
+ const hasServerDom = !!document.getElementById("__FLUIXI_HYDRATION__") || !!options.routes && container.firstElementChild != null;
833
+ const shouldHydrate = options.hydrate ?? hasServerDom;
834
+ const head = (0, import_head.createHead)();
835
+ (0, import_head.setActiveHead)(head);
836
+ (0, import_head.stripHeadMarker)(container);
837
+ if (shouldHydrate) {
838
+ if (options.routes && options.routes.length) {
839
+ const { preloadRoutes: preloadRoutes2 } = await Promise.resolve().then(() => (init_router(), router_exports));
840
+ await preloadRoutes2(options.routes, window.location.pathname);
841
+ }
842
+ deserializeHydrationData();
843
+ setHydrating(true);
844
+ (0, import_dom13.hydrate)(rootOf(App), container);
845
+ replayEvents();
846
+ setTimeout(() => {
847
+ setHydrating(false);
848
+ cleanupHydration();
849
+ }, 100);
850
+ } else {
851
+ render(rootOf(App), container);
852
+ }
853
+ (0, import_head.mountHead)(head);
854
+ }
855
+ function replayEvents() {
856
+ if (typeof window === "undefined") return;
857
+ const w = window;
858
+ if (typeof w.__FX_REPLAY_STOP__ === "function") w.__FX_REPLAY_STOP__();
859
+ const queue = w.__FX_REPLAY__;
860
+ w.__FX_REPLAY__ = void 0;
861
+ w.__FX_REPLAY_STOP__ = void 0;
862
+ if (!Array.isArray(queue) || queue.length === 0) return;
863
+ for (const rec of queue) {
864
+ const target = rec && rec.target;
865
+ if (!target || target.isConnected === false || typeof target.dispatchEvent !== "function") continue;
866
+ const type = rec.type;
867
+ const ev = type === "click" ? new MouseEvent(type, { bubbles: true, cancelable: true }) : new Event(type, { bubbles: true, cancelable: true });
868
+ target.dispatchEvent(ev);
869
+ }
870
+ }