@fluixi/core 1.0.0-alpha.83 → 1.0.0-alpha.85

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 (182) 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-MDJLC3PE.mjs +830 -0
  9. package/dist/src/cdn/core.cjs +1365 -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-JYFZP3EZ.mjs +70 -0
  14. package/dist/src/index.cjs +1280 -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 +1393 -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-7IUN2FLI.mjs +133 -0
  24. package/dist/src/lib/client/index.cjs +956 -1
  25. package/dist/src/lib/client/index.d.ts +17 -6
  26. package/dist/src/lib/client/index.d.ts.map +1 -1
  27. package/dist/src/lib/client/index.js +26 -19
  28. package/dist/src/lib/client/index.mjs +222 -1
  29. package/dist/src/lib/client/router-NOFEMOEH.mjs +631 -0
  30. package/dist/src/lib/context/context.cjs +118 -1
  31. package/dist/src/lib/context/context.d.ts +19 -37
  32. package/dist/src/lib/context/context.d.ts.map +1 -1
  33. package/dist/src/lib/context/context.js +8 -45
  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 +1279 -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 +1393 -1
  44. package/dist/src/lib/env/index.cjs +60 -1
  45. package/dist/src/lib/env/index.d.ts +5 -5
  46. package/dist/src/lib/env/index.js +5 -5
  47. package/dist/src/lib/env/index.mjs +39 -1
  48. package/dist/src/lib/i18n/index.cjs +108 -1
  49. package/dist/src/lib/i18n/index.d.ts +31 -10
  50. package/dist/src/lib/i18n/index.d.ts.map +1 -1
  51. package/dist/src/lib/i18n/index.js +31 -10
  52. package/dist/src/lib/i18n/index.mjs +88 -1
  53. package/dist/src/lib/index.cjs +633 -1
  54. package/dist/src/lib/index.d.ts +0 -2
  55. package/dist/src/lib/index.d.ts.map +1 -1
  56. package/dist/src/lib/index.js +5 -11
  57. package/dist/src/lib/index.mjs +721 -1
  58. package/dist/src/lib/isomorphic.cjs +85 -1
  59. package/dist/src/lib/isomorphic.d.ts +41 -8
  60. package/dist/src/lib/isomorphic.d.ts.map +1 -1
  61. package/dist/src/lib/isomorphic.js +38 -5
  62. package/dist/src/lib/isomorphic.mjs +64 -1
  63. package/dist/src/lib/jsx-runtime/index.cjs +21 -1
  64. package/dist/src/lib/jsx-runtime/index.d.ts +1 -1
  65. package/dist/src/lib/jsx-runtime/index.js +1 -11
  66. package/dist/src/lib/jsx-runtime/index.mjs +4 -1
  67. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -1
  68. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -1
  69. package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -8
  70. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +15 -1
  71. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -1
  72. package/dist/src/lib/plugins/fluixi-routes-plugin.js +19 -5
  73. package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -8
  74. package/dist/src/lib/plugins/index.cjs +311 -8
  75. package/dist/src/lib/plugins/index.mjs +279 -8
  76. package/dist/src/lib/plugins/route-codegen.cjs +73 -8
  77. package/dist/src/lib/plugins/route-codegen.d.ts +0 -1
  78. package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -1
  79. package/dist/src/lib/plugins/route-codegen.js +4 -5
  80. package/dist/src/lib/plugins/route-codegen.mjs +52 -8
  81. package/dist/src/lib/plugins/route-scanner.cjs +189 -1
  82. package/dist/src/lib/plugins/route-scanner.d.ts +1 -2
  83. package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -1
  84. package/dist/src/lib/plugins/route-scanner.js +7 -8
  85. package/dist/src/lib/plugins/route-scanner.mjs +158 -1
  86. package/dist/src/lib/plugins/vite.cjs +27 -1
  87. package/dist/src/lib/plugins/vite.mjs +6 -1
  88. package/dist/src/lib/render/await.cjs +38 -1
  89. package/dist/src/lib/render/await.d.ts +18 -0
  90. package/dist/src/lib/render/await.d.ts.map +1 -1
  91. package/dist/src/lib/render/await.js +20 -2
  92. package/dist/src/lib/render/await.mjs +17 -1
  93. package/dist/src/lib/render/component.cjs +221 -1
  94. package/dist/src/lib/render/component.d.ts +3 -44
  95. package/dist/src/lib/render/component.d.ts.map +1 -1
  96. package/dist/src/lib/render/component.js +23 -55
  97. package/dist/src/lib/render/component.mjs +214 -1
  98. package/dist/src/lib/render/deferred.cjs +175 -1
  99. package/dist/src/lib/render/deferred.js +5 -5
  100. package/dist/src/lib/render/deferred.mjs +158 -1
  101. package/dist/src/lib/render/index.cjs +573 -1
  102. package/dist/src/lib/render/index.d.ts +3 -17
  103. package/dist/src/lib/render/index.d.ts.map +1 -1
  104. package/dist/src/lib/render/index.js +8 -22
  105. package/dist/src/lib/render/index.mjs +590 -1
  106. package/dist/src/lib/render/lazy.cjs +67 -1
  107. package/dist/src/lib/render/lazy.d.ts +22 -1
  108. package/dist/src/lib/render/lazy.d.ts.map +1 -1
  109. package/dist/src/lib/render/lazy.js +26 -5
  110. package/dist/src/lib/render/lazy.mjs +50 -1
  111. package/dist/src/lib/render/suspense.cjs +141 -1
  112. package/dist/src/lib/render/suspense.d.ts +40 -0
  113. package/dist/src/lib/render/suspense.d.ts.map +1 -1
  114. package/dist/src/lib/render/suspense.js +46 -6
  115. package/dist/src/lib/render/suspense.mjs +136 -1
  116. package/dist/src/lib/render/versions.cjs +35 -1
  117. package/dist/src/lib/render/versions.js +6 -6
  118. package/dist/src/lib/render/versions.mjs +14 -1
  119. package/dist/src/lib/router/data.cjs +230 -1
  120. package/dist/src/lib/router/data.d.ts +1 -13
  121. package/dist/src/lib/router/data.d.ts.map +1 -1
  122. package/dist/src/lib/router/data.js +0 -12
  123. package/dist/src/lib/router/data.mjs +214 -1
  124. package/dist/src/lib/router/index.cjs +709 -1
  125. package/dist/src/lib/router/index.d.ts +78 -23
  126. package/dist/src/lib/router/index.d.ts.map +1 -1
  127. package/dist/src/lib/router/index.js +161 -37
  128. package/dist/src/lib/router/index.mjs +722 -1
  129. package/dist/src/lib/router/transition.cjs +75 -0
  130. package/dist/src/lib/router/transition.d.ts +81 -0
  131. package/dist/src/lib/router/transition.d.ts.map +1 -0
  132. package/dist/src/lib/router/transition.js +136 -0
  133. package/dist/src/lib/router/transition.mjs +54 -0
  134. package/dist/src/lib/server/hydration.cjs +169 -1
  135. package/dist/src/lib/server/hydration.d.ts +15 -55
  136. package/dist/src/lib/server/hydration.d.ts.map +1 -1
  137. package/dist/src/lib/server/hydration.js +23 -62
  138. package/dist/src/lib/server/hydration.mjs +148 -1
  139. package/dist/src/lib/server/index.cjs +401 -11
  140. package/dist/src/lib/server/index.d.ts +30 -6
  141. package/dist/src/lib/server/index.d.ts.map +1 -1
  142. package/dist/src/lib/server/index.js +34 -11
  143. package/dist/src/lib/server/index.mjs +379 -11
  144. package/dist/src/lib/server/reactive.cjs +197 -1
  145. package/dist/src/lib/server/reactive.d.ts +18 -77
  146. package/dist/src/lib/server/reactive.d.ts.map +1 -1
  147. package/dist/src/lib/server/reactive.js +19 -78
  148. package/dist/src/lib/server/reactive.mjs +176 -1
  149. package/dist/src/lib/theme/index.cjs +110 -1
  150. package/dist/src/lib/theme/index.d.ts +19 -4
  151. package/dist/src/lib/theme/index.d.ts.map +1 -1
  152. package/dist/src/lib/theme/index.js +17 -2
  153. package/dist/src/lib/theme/index.mjs +89 -1
  154. package/dist/src/lib/utils/index.cjs +209 -1
  155. package/dist/src/lib/utils/index.d.ts +0 -93
  156. package/dist/src/lib/utils/index.d.ts.map +1 -1
  157. package/dist/src/lib/utils/index.js +0 -93
  158. package/dist/src/lib/utils/index.mjs +188 -1
  159. package/dist/src/routes.cjs +37 -1
  160. package/dist/src/routes.d.ts +1 -1
  161. package/dist/src/routes.js +2 -2
  162. package/dist/src/routes.mjs +17 -1
  163. package/dist/src/server.cjs +400 -11
  164. package/dist/src/server.d.ts +0 -1
  165. package/dist/src/server.d.ts.map +1 -1
  166. package/dist/src/server.js +0 -1
  167. package/dist/src/server.mjs +377 -11
  168. package/dist/src/utils.cjs +21 -1
  169. package/dist/src/utils.d.ts +1 -1
  170. package/dist/src/utils.js +1 -1
  171. package/dist/src/utils.mjs +4 -1
  172. package/dist/src/version.generated.cjs +26 -1
  173. package/dist/src/version.generated.d.ts +1 -1
  174. package/dist/src/version.generated.js +2 -2
  175. package/dist/src/version.generated.mjs +5 -1
  176. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  177. package/package.json +17 -16
  178. package/src/index.ts +2 -14
  179. package/dist/src/cdn/chunk-55BT3H6E.mjs +0 -1
  180. package/dist/src/cdn/router-5JJZBK4E.mjs +0 -1
  181. package/dist/src/lib/client/chunk-SM4WHBOP.mjs +0 -1
  182. package/dist/src/lib/client/router-IBD4WPQT.mjs +0 -1
@@ -1 +1,1393 @@
1
- import{signal as Io,memo as No,effect as Fo,resource as _o,createEffect as nn,createMemo as rn,createSignal as on,createResource as Vo,createRoot as sn,createComputed as an,createRenderEffect as cn,onCleanup as un,getOwner as dn,runWithOwner as ln,batch as fn,untrack as pn,createDeferred as mn,setOwner as yn}from"@fluixi/reactive/signal";import{createDebounce as Ko,createDebouncedResource as Ho,createDebouncedSignal as Uo,createSelector as gn}from"@fluixi/reactive/signal";import{readSignal as hn,reduceSignal as xn}from"@fluixi/reactive/operators";import{isServer as N}from"@fluixi/dom";import{createRoot as ct}from"@fluixi/reactive/signal";import{registerCoreVersion as De}from"@fluixi/dom";var q="1.0.0-alpha.83";import{stampVersions as J,warnOnVersionSkew as B,versions as Rn}from"@fluixi/dom";De(q);import{isDOMNode as ut,delegateEvents as Te,insert as dt}from"@fluixi/dom";import{isServer as X}from"@fluixi/dom";import{createComponent as Ie,asComponent as Ne}from"@fluixi/dom";import{untrack as Y,onCleanup as g,getOwner as M,createEffect as b,createMemo as G,createSignal as Fe,isSignal as _e,batch as Ve,runWithOwner as Q,isOwnerDisposed as je}from"@fluixi/reactive/signal";var E=Symbol.for("fluixi-lifecycle");function Z(){let e=M();if(!e)return null;if(!e[E]){let t={mounts:[],effects:[],scheduled:!1};e[E]=t}return e[E]}function ee(e){if(e.scheduled)return;if(X()){e.mounts=[],e.effects=[];return}e.scheduled=!0;let t=M();queueMicrotask(()=>{if(je(t)){e.mounts=[],e.effects=[];return}Q(t,()=>{for(let r of e.mounts)try{let n=r();typeof n=="function"&&g(n)}catch(n){console.error("Error in onMount callback:",n)}for(let r of e.effects){let n;b(()=>{n&&n(),n=r()}),g(()=>{n&&n()})}e.mounts=[],e.effects=[]})})}function S(e,t){return Ie(e,t)}function te(e,t){let r=typeof e=="function"?Y(()=>e(t)):e,n=r!=null&&(typeof r=="function"||typeof r=="object");if(n)try{r.$name=e.name}catch{}return n&&!_e(r)?Ne(r):r}function w(e,t=!0){if(X())return;let r=Z();if(r){if(!t){r.scheduled||e();return}r.mounts.push(e),ee(r)}else{if(!t){e();return}b(()=>{let n=Y(e);typeof n=="function"&&g(n)})}}function P(e){g(e)}function D(e){let t=Z();if(t)t.effects.push(e),ee(t);else{let r;b(()=>{r&&r(),r=e()}),g(()=>{r&&r()})}}function ne(e){return G(e)}function re(e){let t={current:e};return g(()=>{t.current=null}),t}function oe(e,t){let[r,n]=Fe(t);return[r,o=>{n(e(r(),o))}]}function ie(e,t,r,n){D(()=>{let i=e&&"current"in e?e.current:e;if(i)return i.addEventListener(t,r,n),()=>{i.removeEventListener(t,r,n)}})}function se(e){return e}import{createSignal as I,createMemo as Ke,createEffect as He,createRenderEffect as Ue,isSignal as ae,readChildren as $e,useContext as ze,createContext as We,createSuspenseBoundary as qe,provideSuspense as ce}from"@fluixi/reactive/signal";import{asSuspense as Je,isComponent as Be,createComponent as ue,runWithoutHydration as Xe}from"@fluixi/dom";function de(e){return typeof window>"u"?!1:typeof Node=="function"&&e instanceof Node?!0:!!(e&&typeof e=="object"&&typeof e.nodeType=="number")}function le(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function fe(e){return!!(e&&typeof e=="object"&&typeof e.then=="function"||e instanceof Promise)}function pe(e){return!!(e&&typeof e=="object"&&"type"in e&&"props"in e)}var me=We(void 0,"suspense-list");function R(e){return ue(Ye,e)}function Ye(e){let t=qe(),r=ze(me),n=r?r.register(t.inFallback):void 0;function i(u){return u==null||typeof u=="boolean"?null:typeof u=="function"&&Be(u)&&!ae(u)?u():u}let o=Xe(()=>i(e.fallback??null)),s=ce(t,()=>$e(()=>e.children)),a=(u,y)=>{if(!(y>8))if(Array.isArray(u))for(let W of u)a(W,y+1);else typeof u=="function"&&ae(u)&&a(u(),y+1)};ce(t,()=>{Ue(()=>a(s,0))});let[c,d]=I(void 0),f=fe(s);return f&&(t.increment(),s.then(u=>{d(()=>u),t.decrement()},()=>t.decrement())),Ke(()=>(n?n.showFallback():t.inFallback())?o:f?c():s)}function ye(e){return ue(Ge,e)}function Ge(e){let{revealOrder:t="together",tail:r}=e,n=[];function i(){if(t==="together"){let s=n.every(a=>!a.inFallback());n.forEach(a=>{a.setShowContent(s),a.setShowFallback(!s)})}else{let s=t==="backwards"?[...n].reverse():n,a=!1;for(let c of s)a||c.inFallback()?(a=!0,c.setShowContent(!1),c.setShowFallback(r!=="hidden")):(c.setShowContent(!0),c.setShowFallback(!1))}}let o={register:s=>{let[a,c]=I(!0),[d,f]=I(!1);return n.push({inFallback:s,setShowContent:c,setShowFallback:f}),He(()=>{s(),i()}),{showContent:a,showFallback:d}}};return me.Provider({value:o,children:e.children})}Je(R);Object.defineProperty(R,"__suspense",{value:!0,enumerable:!0});import{createComponent as Qe}from"@fluixi/dom";import{untrack as Ze,createMemo as et,createResource as tt}from"@fluixi/reactive/signal";function ge(e){if(e!=null&&(typeof e=="object"||typeof e=="function"))try{e.$lazy=!0}catch{}return e}function C(e,t){let r,n,i;function o(){return n||(n=e().then(a=>r=a.default)),n}t?.preload&&o();let s=(a=>{if(r){let c=r;return ge(Ze(()=>c(a)))}if(!i){let[c]=tt(()=>o(),{transport:!1});if(i=c,c.error)throw c.error}return et(()=>{let c=i();return c?ge(Qe(c,a)):void 0})});return s.preload=()=>o().then(()=>{}),s.$lazy=!0,s.loader=e,s}import{isServer as he}from"@fluixi/dom";import{createMemo as nt,createSignal as rt}from"@fluixi/reactive/signal";import{observeIntersection as ot}from"@fluixi/dom/utils";function xe(e,t){let r=t.export??"default",n=C(()=>e().then(o=>{let s=o[r];if(typeof s!="function")throw new Error(`deferred(): module has no '${r}' export (got ${typeof s}).`);return{default:s}}),{fallback:t.fallback});function i(o){if(t.strategy.kind==="never")return he()?n(o):null;if(he()||t.strategy.kind==="eager")return n(o);let[s,a]=rt(!1),c=()=>{n.preload().then(()=>a(!0))},d=t.strategy.kind==="visible"?it():void 0;return st(t.strategy,c,d),nt(()=>s()?n(o):d??t.fallback??null,void 0,{name:"deferred"})}return i.preload=n.preload,i}function it(){let e=document.createElement("span");return e.setAttribute("data-fx-load","visible"),e.style.display="block",e}function st(e,t,r){let n=!1,i=()=>{n||(n=!0,t())};switch(e.kind){case"idle":{let o=globalThis.requestIdleCallback;o?o(i):setTimeout(i,1);return}case"visible":{if(!r||typeof IntersectionObserver>"u"){i();return}let o=ot(r,s=>{s&&(o(),i())},{rootMargin:e.rootMargin??"0px"});return}case"interaction":{let o=()=>{for(let s of e.events)document.removeEventListener(s,o,!0);i()};for(let s of e.events)document.addEventListener(s,o,{capture:!0,passive:!0});return}case"media":{if(typeof matchMedia>"u"){i();return}let o=matchMedia(e.query);if(o.matches){i();return}let s=a=>{a.matches&&(o.removeEventListener("change",s),i())};o.addEventListener("change",s);return}default:i()}}import{createResource as at}from"@fluixi/reactive/signal";function ve(e){let t=()=>{let n=e.value;return typeof n=="function"?n():n},[r]=at(t);return()=>{if(r.loading)return e.fallback;let n=e.children;return typeof n=="function"?n(r()):n}}function Ce(e,t,r={}){if(Te(["click","input","change","submit"]),N())throw new Error("render() is for client-side only. Use renderToString() on server.");if(!t)throw new Error("Container element is required");let n;return ct(i=>{n=i;let o=typeof e=="function"?e():e;t.textContent="",J(t),B(),dt(t,()=>o)}),()=>{n&&(n(),n=void 0)}}function lt(e){return e&&typeof e=="object"&&(e._$litType$!==void 0||e._$litDirective$!==void 0)}function ft(e,t,r={}){let n=document.createElement("div");n.setAttribute("data-portal","true"),t.appendChild(n);let i=Ce(e,n,r);return()=>{i(),t.contains(n)&&t.removeChild(n)}}function pt(e){return!!(e==null||typeof e=="function"||ut(e)||lt(e)||Array.isArray(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function mt(){N()||Te(["click","input","change","submit"])}function yt(){N()}import{asProvider as gt}from"@fluixi/dom";import{createContext as ht,useContext as xt}from"@fluixi/reactive/signal";import{readChildren as vt}from"@fluixi/reactive/signal";var be=!1;function Tt(){be||(be=!0,!(typeof process<"u")&&console.warn("[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={…}>{props.children}</Context.Provider>"))}function F(e,t,r){let n=!!e?.Provider,i=n?e:e.context,o=n?t:e.value,s=n?!1:e.debug??!1;n||Tt();let a=typeof o=="function"?o():o,c=n?r:e;return i.Provider({value:a,get children(){return c?.children},debug:s})}function Ct(e){let t=h(e);return[t,n=>F(t,n.value,n)]}function Se(e,t){if(e.length===0)return vt(()=>t);let[r,n]=e[0],i=e.slice(1);return F(r,n,{get children(){return Se(i,t)}})}function bt(e){return t=>{let r=x(e);return t.children(r)}}function St(e,t){let r=x(e);return r===e.defaultValue?t():r}function h(e,t){let r=ht(e,t),n=i=>(i.debug,r.Provider({value:i.value,get children(){return i.children},debug:i.debug}));return typeof Symbol<"u"&&Symbol.for&&(n.$$typeof=Symbol.for("react.provider")),n.$$typeof=Symbol.for("react.provider"),{id:r.id,Provider:gt(n),defaultValue:e}}function x(e){let t=xt(e);return t!==void 0?t:e.defaultValue}import{createSignal as wt,createMemo as Pt}from"@fluixi/reactive/signal";import{getServerData as Rt}from"@fluixi/dom";var At="__fluixi_iso_states__",kt="__iso:";function Ot(){return globalThis[At]??=new Map}function we(e){if(typeof window>"u")return;let t=Rt();return t?t[kt+e]:void 0}function Pe(e,t){let r=we(e),n=r!==void 0?r:typeof window<"u"&&t.client?t.client():t.fallback,[i,o]=wt(n);return Ot().set(e,{server:t.server,set:o}),{value:i,set:o,key:e}}function Lt(e,t){let r=we(e)!==void 0,n=Pe(e,{server:t.server,fallback:t.fallback}),i=()=>n.value()??t.fallback,o=u=>{if(!(!t.persist||typeof localStorage>"u"))try{localStorage.setItem(t.persist,JSON.stringify(u))}catch{}},s=u=>{n.set(u),o(u)},a=(u,y)=>{s({...i(),[u]:y})},c={};for(let u of Object.keys(t.fallback))c[u]=Pt(()=>i()[u]);let d=null;return{value:i,fields:c,set:s,setField:a,ensureInit:()=>r||!t.client?Promise.resolve():(d||(d=Promise.resolve(t.client()).then(u=>{s(u)}).catch(u=>{throw d=null,u})),d),key:e}}import{isServer as Dt}from"@fluixi/dom";import{isServer as Et}from"@fluixi/dom";function Re(){return!Et()}function Ae(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,r)=>{e.set(t,String(r))},removeItem:t=>{e.delete(t)},clear:()=>e.clear(),key:t=>Array.from(e.keys())[t]??null,get length(){return e.size}}}var A=typeof localStorage<"u"?localStorage:Ae(),k={get window(){return typeof window<"u"?window:void 0},get document(){return typeof document<"u"?document:void 0}};function Mt(e,t){return Re()?e():t}import{createSignal as ke}from"@fluixi/reactive/signal";function It(e){return e?e===!0?{dark:"dark",light:"light"}:e:null}function Nt(e){let t=e.storageKey??"theme",r=e.attribute??"data-theme",n=It(e.system),i=()=>{let l=A.getItem(t);return l&&e.themes.includes(l)?l:n&&k.window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches?n.dark:n?n.light:e.default},[o,s]=ke(i()),[a,c]=ke(!1),d=l=>{k.document?.documentElement.setAttribute(r,l);try{A.setItem(t,l)}catch{}},f=l=>{if(!e.themes.includes(l))return;let Me=o();s(()=>l),d(l),e.onChange?.(l,Me),e.load&&(c(!0),e.onLoading?.(l),Promise.resolve(e.load(l)).finally(()=>{c(!1),e.onLoaded?.(l)}))};return{value:o,isLoading:a,set:f,toggle:()=>{let l=e.themes.indexOf(o());f(e.themes[(l+1)%e.themes.length])},init:()=>d(o()),headScript:()=>`<script>(function(){try{var c=${JSON.stringify({k:t,a:r,d:e.default,sys:n})},t=localStorage.getItem(c.k);if(!t&&c.sys)t=matchMedia('(prefers-color-scheme: dark)').matches?c.sys.dark:c.sys.light;if(!t)t=c.d;document.documentElement.setAttribute(c.a,t);}catch(e){}})();<\/script>`}}import{createSignal as j,createMemo as v,createResource as Ht,createEffect as K,getOwner as Ut,onCleanup as Oe,untrack as _}from"@fluixi/reactive/signal";import{insert as V,createComponent as Le,createNativeElement as O,setAttribute as m}from"@fluixi/dom";import{createContext as L,useContext as Ee}from"@fluixi/reactive/signal";import{get as oo}from"@fluixi/utils/object";import{deepEqual as so}from"@fluixi/utils/compare";import{createRouter as $t,createBrowserHistory as zt,matchRoutes as co,matchPath as uo}from"@fluixi/router";import{createMemoryHistory as po,createBrowserHistory as mo,matchRoutes as yo,matchPath as go}from"@fluixi/router";import{createResource as Kr,createSignal as jt}from"@fluixi/reactive/signal";var Ft=new Map;function _t(){Ft.clear()}function Vt(){if(typeof window>"u")return;let e=document.getElementById("__FLUIXI_HYDRATION__");e&&e.remove();let t=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,null),r=[],n;for(;n=t.nextNode();){let i=n,o=i.nodeValue||"";(o.startsWith("#")||o.startsWith("/"))&&r.push(i)}r.forEach(i=>i.remove()),_t()}typeof window<"u"&&window.addEventListener("load",()=>{setTimeout(Vt,100)});var[zr,Wr]=jt(0);var Kt=h(void 0,"route-data"),qr=Kt.Provider;import{runWithOwner as To}from"@fluixi/reactive/signal";var H=L(void 0,"router"),Wt=L(void 0,"outlet"),qt=L(void 0,"route-params"),Jt=L(void 0,"route-data");function Bt(e,t,r){let n,i=e.route.data;if(typeof i=="function"){let f=!1;Oe(()=>{f=!0});let u=Ut(),[y]=Ht(()=>i({params:r.params,location:r.location},u,()=>f));n=y}let o=()=>Jt.Provider({value:n,get children(){return qt.Provider({value:e.params,get children(){return Wt.Provider({value:{depth:t,...r},get children(){return Le(e.component,{})}})}})}});if(!n)return o();let s=n,a=()=>s.loading,[c,d]=j(_(()=>!a()));return K(()=>d(!a())),v(()=>c()?o():null)}function Xt(e){let t=e.depth+1,[r,n]=j(_(()=>e.matched()[t]?.component));return K(()=>{let i=e.matched()[t]?.component;n(()=>i)}),v(()=>{if(!r())return e.notFound?e.notFound():null;let o=_(()=>e.matched())[t];return Bt(o,t,{matched:e.matched,params:e.params,location:e.location})})}function Yt(e){return e==null?Gt():typeof e=="function"?Le(e,{}):e}function Gt(){let e=O("div");m(e,"class","fx-not-found"),m(e,"role","main"),m(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=O("h1");m(t,"style","margin:0;font-size:2.5rem;font-weight:700"),V(t,"404");let r=O("p");return m(r,"style","margin:0;opacity:.7"),V(r,"This page could not be found."),e.appendChild(t),e.appendChild(r),e}function U(e){let t=e.history??zt(),r=$t({routes:e.routes,base:e.base,history:t}),[n,i]=j(r.state()),o=r.subscribe(i);Oe(()=>{o(),r.destroy()});let s=v(()=>(n().match?.matched??[]).filter(f=>f.component)),a={router:r,location:v(()=>n().location),params:v(()=>n().match?.params??{})},c={depth:-1,matched:s,params:a.params,location:a.location,notFound:()=>Yt(e.notFound)},d;return H.Provider({value:a,get children(){return d??=Xt(c)}})}var Qt={router:{navigate:()=>{}},location:()=>({pathname:"",search:"",hash:"",query:{}}),params:()=>({})};function T(){let e=Ee(H);if(e)return e;if(typeof window>"u")return Qt;throw new Error("[router] useRouter must be used within <Router>")}function Zt(){let e=T().params;return v(()=>e(),{},{equals:(t,r)=>JSON.stringify(t)===JSON.stringify(r)})}function en(){let{location:e}=T();return new Proxy({},{get:(t,r)=>e()[r],has:(t,r)=>r in e(),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,r)=>Object.getOwnPropertyDescriptor(e(),r)})}function $(){let{router:e}=T();return(t,r)=>e.navigate(t,r)}var p=e=>typeof e=="function"?e():e,tn=new Set(["href","slot","class","className","active","activeClass","replace","children"]);function z(e){let t=Ee(H),r=()=>t?.router.navigate(p(e.href)??"",{replace:p(e.replace)}),n=O("a");m(n,"href",p(e.href)??""),e.slot&&m(n,"slot",p(e.slot));for(let o of Object.keys(e)){if(tn.has(o))continue;let s=e[o];s!=null&&typeof s!="function"&&m(n,o,String(s))}if(typeof n.addEventListener=="function")n.addEventListener("click",o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||(o.preventDefault(),r())});else{let o=p(e.className??e.class)??"";o&&m(n,"class",o)}typeof n.addEventListener=="function"&&K(()=>{let o=p(e.href)??"";n.setAttribute("href",o);let s=p(e.className??e.class)??"",a=p(e.activeClass)??"",c=p(e.active)??t?.location().pathname===o;n.className=[s,c?a:""].filter(Boolean).join(" ")});let i=e.children;return i!=null&&V(n,i),n}import{html as ei,svg as ti}from"@fluixi/dom";import{query as ri,queryAll as oi,closest as ii,addClass as si,removeClass as ai,toggleClass as ci,hasClass as ui,setAttribute as di,getAttribute as li,removeAttribute as fi,setStyles as pi,getStyle as mi,createElement as yi,removeChildren as gi,appendChildren as hi,isVisible as xi,scrollIntoView as vi,getOffset as Ti,delegate as Ci,waitForElement as bi,observeIntersection as Si,observeResize as wi}from"@fluixi/dom";import{classMap as Ri,styleMap as Ai,Island as ki,hydrateIslands as Oi,mergeProps as Li,splitProps as Ei}from"@fluixi/dom";import{Show as So,For as wo,Index as Po,Switch as Ro,Match as Ao,Dynamic as ko,ErrorBoundary as Oo,Portal as Lo,ClientOnly as Eo,NoSsr as Mo}from"@fluixi/dom";import{createStore as Ii,untrackStore as Ni,unwrap as Fi,Store as _i}from"@fluixi/reactive/store";var vn="0.0.1",Tn="Fluixi";var Jo={createComponent:S,onMount:w,onUnmount:P,createEffect:nn,createMemo:rn,createSignal:on,createContext:h,createRoot:sn,createDeferred:mn,createComputed:an,createRenderEffect:cn,createSelector:gn,onCleanup:un,getOwner:dn,runWithOwner:ln,batch:fn,untrack:pn,useContext:x,setOwner:yn,Router:U,Link:z,useRouter:T,useNavigate:$,read:hn,reduce:xn,VERSION:vn,FRAMEWORK_NAME:Tn};export{te as $component,ve as Await,Eo as ClientOnly,ko as Dynamic,Oo as ErrorBoundary,Tn as FRAMEWORK_NAME,wo as For,Po as Index,ki as Island,z as Link,Ao as Match,Mo as NoSsr,Lo as Portal,U as Router,So as Show,_i as Store,R as Suspense,ye as SuspenseList,Ro as Switch,vn as VERSION,si as addClass,hi as appendChildren,fn as batch,Ri as classMap,yt as cleanupDelegation,Mt as clientOnly,ii as closest,Se as composeProviders,S as createComponent,an as createComputed,bt as createConsumer,h as createContext,Ct as createContextWithProvider,Ko as createDebounce,Ho as createDebouncedResource,Uo as createDebouncedSignal,mn as createDeferred,nn as createEffect,Pe as createIsomorphicState,Lt as createIsomorphicStore,rn as createMemo,Ae as createMemoryStorage,F as createProvider,cn as createRenderEffect,Vo as createResource,sn as createRoot,gn as createSelector,on as createSignal,Ii as createStore,Nt as createTheme,Jo as default,xe as deferred,Ci as delegate,yi as domCreateElement,Fo as effect,k as env,li as getAttribute,Ti as getOffset,dn as getOwner,mi as getStyle,ui as hasClass,ei as html,Oi as hydrateIslands,mt as initDelegation,Re as isClient,pe as isJSXElement,le as isLitResult,de as isNode,pt as isRenderable,Dt as isServer,xi as isVisible,C as lazy,No as memo,Li as mergeProps,Si as observeIntersection,wi as observeResize,un as onCleanup,w as onMount,P as onUnmount,ft as portal,ri as query,oi as queryAll,hn as read,xn as reduce,fi as removeAttribute,gi as removeChildren,ai as removeClass,Ce as render,_o as resource,ln as runWithOwner,vi as scrollIntoView,di as setAttribute,yn as setOwner,pi as setStyles,Io as signal,Ei as splitProps,A as storage,Ai as styleMap,ti as svg,ci as toggleClass,pn as untrack,Ni as untrackStore,Fi as unwrap,se as useCallback,x as useContext,D as useEffect,ie as useEventListener,en as useLocation,ne as useMemo,$ as useNavigate,Zt as useParams,St as useProvide,oe as useReducer,re as useRef,T as useRouter,bi as waitForElement};
1
+ // src/lib/core.ts
2
+ import {
3
+ signal,
4
+ memo,
5
+ effect,
6
+ resource,
7
+ createEffect as createEffect4,
8
+ createMemo as createMemo7,
9
+ createSignal as createSignal8,
10
+ createResource as createResource6,
11
+ createRoot as createRoot3,
12
+ createComputed as createComputed2,
13
+ createRenderEffect as createRenderEffect3,
14
+ onCleanup as onCleanup3,
15
+ getOwner as getOwner3,
16
+ runWithOwner as runWithOwner3,
17
+ batch as batch2,
18
+ untrack as untrack4,
19
+ createDeferred as createDeferred2,
20
+ setOwner
21
+ } from "@fluixi/reactive/signal";
22
+ import {
23
+ createDebounce,
24
+ createDebouncedResource,
25
+ createDebouncedSignal,
26
+ createSelector
27
+ } from "@fluixi/reactive/signal";
28
+ import {
29
+ readSignal as read2,
30
+ reduceSignal as reduce
31
+ } from "@fluixi/reactive/operators";
32
+
33
+ // src/lib/render/index.ts
34
+ import { isServer as isServer3 } from "@fluixi/dom";
35
+ import { createRoot as createRoot2 } from "@fluixi/reactive/signal";
36
+
37
+ // src/lib/render/versions.ts
38
+ import { registerCoreVersion } from "@fluixi/dom";
39
+
40
+ // src/version.generated.ts
41
+ var VERSION = "1.0.0-alpha.85";
42
+
43
+ // src/lib/render/versions.ts
44
+ import { stampVersions, warnOnVersionSkew, versions } from "@fluixi/dom";
45
+ registerCoreVersion(VERSION);
46
+
47
+ // src/lib/render/index.ts
48
+ import {
49
+ isDOMNode,
50
+ delegateEvents,
51
+ insert
52
+ } from "@fluixi/dom";
53
+
54
+ // src/lib/render/component.ts
55
+ import { isServer } from "@fluixi/dom";
56
+ import {
57
+ createComponent as domCreateComponent,
58
+ asComponent
59
+ } from "@fluixi/dom";
60
+ import {
61
+ untrack,
62
+ onCleanup,
63
+ getOwner,
64
+ createEffect,
65
+ createMemo,
66
+ createSignal,
67
+ isSignal,
68
+ batch,
69
+ runWithOwner,
70
+ isOwnerDisposed
71
+ } from "@fluixi/reactive/signal";
72
+ var _LIFECYCLE = /* @__PURE__ */ Symbol.for("fluixi-lifecycle");
73
+ function getOwnerLifecycle() {
74
+ const owner = getOwner();
75
+ if (!owner) return null;
76
+ if (!owner[_LIFECYCLE]) {
77
+ const lc = { mounts: [], effects: [], scheduled: false };
78
+ owner[_LIFECYCLE] = lc;
79
+ }
80
+ return owner[_LIFECYCLE];
81
+ }
82
+ function scheduleLifecycleFlush(lc) {
83
+ if (lc.scheduled) return;
84
+ if (isServer()) {
85
+ lc.mounts = [];
86
+ lc.effects = [];
87
+ return;
88
+ }
89
+ lc.scheduled = true;
90
+ const owner = getOwner();
91
+ queueMicrotask(() => {
92
+ if (isOwnerDisposed(owner)) {
93
+ lc.mounts = [];
94
+ lc.effects = [];
95
+ return;
96
+ }
97
+ runWithOwner(owner, () => {
98
+ for (const cb of lc.mounts) {
99
+ try {
100
+ const cleanup = cb();
101
+ if (typeof cleanup === "function") {
102
+ onCleanup(cleanup);
103
+ }
104
+ } catch (e) {
105
+ console.error("Error in onMount callback:", e);
106
+ }
107
+ }
108
+ for (const cb of lc.effects) {
109
+ let cleanup;
110
+ createEffect(() => {
111
+ if (cleanup) cleanup();
112
+ cleanup = cb();
113
+ });
114
+ onCleanup(() => {
115
+ if (cleanup) cleanup();
116
+ });
117
+ }
118
+ lc.mounts = [];
119
+ lc.effects = [];
120
+ });
121
+ });
122
+ }
123
+ function createComponent(Comp, props) {
124
+ return domCreateComponent(Comp, props);
125
+ }
126
+ function $component(value, props) {
127
+ const component = typeof value === "function" ? untrack(() => value(props)) : value;
128
+ const nameable = component != null && (typeof component === "function" || typeof component === "object");
129
+ if (nameable) {
130
+ try {
131
+ component["$name"] = value.name;
132
+ } catch {
133
+ }
134
+ }
135
+ if (nameable && !isSignal(component)) {
136
+ return asComponent(component);
137
+ }
138
+ return component;
139
+ }
140
+ function onMount(fn, reactive = true) {
141
+ if (isServer()) return;
142
+ const lc = getOwnerLifecycle();
143
+ if (lc) {
144
+ if (!reactive) {
145
+ if (!lc.scheduled) {
146
+ fn();
147
+ }
148
+ return;
149
+ }
150
+ lc.mounts.push(fn);
151
+ scheduleLifecycleFlush(lc);
152
+ } else {
153
+ if (!reactive) {
154
+ fn();
155
+ return;
156
+ }
157
+ createEffect(() => {
158
+ const cleanup = untrack(fn);
159
+ if (typeof cleanup === "function") {
160
+ onCleanup(cleanup);
161
+ }
162
+ });
163
+ }
164
+ }
165
+ function onUnmount(fn) {
166
+ onCleanup(fn);
167
+ }
168
+ function useEffect(callback) {
169
+ const lc = getOwnerLifecycle();
170
+ if (lc) {
171
+ lc.effects.push(callback);
172
+ scheduleLifecycleFlush(lc);
173
+ } else {
174
+ let cleanup;
175
+ createEffect(() => {
176
+ if (cleanup) cleanup();
177
+ cleanup = callback();
178
+ });
179
+ onCleanup(() => {
180
+ if (cleanup) cleanup();
181
+ });
182
+ }
183
+ }
184
+ function useMemo(fn) {
185
+ return createMemo(fn);
186
+ }
187
+ function useRef(initialValue) {
188
+ const ref = { current: initialValue };
189
+ onCleanup(() => {
190
+ ref.current = null;
191
+ });
192
+ return ref;
193
+ }
194
+ function useReducer(reducer, initialState) {
195
+ const [state, setState] = createSignal(initialState);
196
+ const dispatch = (action2) => {
197
+ setState(reducer(state(), action2));
198
+ };
199
+ return [state, dispatch];
200
+ }
201
+ function useEventListener(target, event, handler, options) {
202
+ useEffect(() => {
203
+ const element = target && "current" in target ? target.current : target;
204
+ if (!element) return;
205
+ element.addEventListener(event, handler, options);
206
+ return () => {
207
+ element.removeEventListener(event, handler, options);
208
+ };
209
+ });
210
+ }
211
+ function useCallback(callback) {
212
+ return callback;
213
+ }
214
+
215
+ // src/lib/render/suspense.ts
216
+ import {
217
+ createSignal as createSignal2,
218
+ createMemo as createMemo2,
219
+ createEffect as createEffect2,
220
+ createRenderEffect as createRenderEffect2,
221
+ isSignal as isSignal2,
222
+ readChildren,
223
+ useContext as useContext2,
224
+ createContext as createContext2,
225
+ createSuspenseBoundary,
226
+ provideSuspense
227
+ } from "@fluixi/reactive/signal";
228
+ import {
229
+ asSuspense,
230
+ isComponent,
231
+ createComponent as createComponent2,
232
+ runWithoutHydration
233
+ } from "@fluixi/dom";
234
+ function isNode(value) {
235
+ if (typeof window === "undefined") return false;
236
+ if (typeof Node === "function" && value instanceof Node) return true;
237
+ return !!(value && typeof value === "object" && typeof value.nodeType === "number");
238
+ }
239
+ function isLitResult(value) {
240
+ if (!value || typeof value !== "object") return false;
241
+ return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
242
+ }
243
+ function isPromise(value) {
244
+ return !!(value && typeof value === "object" && typeof value.then === "function" || value instanceof Promise);
245
+ }
246
+ function isJSXElement(value) {
247
+ return !!(value && typeof value === "object" && "type" in value && "props" in value);
248
+ }
249
+ var SuspenseListContext = createContext2(void 0, "suspense-list");
250
+ function Suspense(props) {
251
+ return createComponent2(SuspenseImpl, props);
252
+ }
253
+ function SuspenseImpl(props) {
254
+ const boundary = createSuspenseBoundary();
255
+ const listCtx = useContext2(SuspenseListContext);
256
+ const listState = listCtx ? listCtx.register(boundary.inFallback) : void 0;
257
+ function instantiateOnce(val) {
258
+ if (val == null || typeof val === "boolean") return null;
259
+ if (typeof val === "function" && isComponent(val) && !isSignal2(val)) return val();
260
+ return val;
261
+ }
262
+ const fallback = runWithoutHydration(() => instantiateOnce(props.fallback ?? null));
263
+ const children = provideSuspense(boundary, () => readChildren(() => props.children));
264
+ const track = (value, depth) => {
265
+ if (depth > 8) return;
266
+ if (Array.isArray(value)) {
267
+ for (const x of value) track(x, depth + 1);
268
+ } else if (typeof value === "function" && isSignal2(value)) {
269
+ track(value(), depth + 1);
270
+ }
271
+ };
272
+ provideSuspense(boundary, () => {
273
+ createRenderEffect2(() => track(children, 0));
274
+ });
275
+ const [resolved, setResolved] = createSignal2(void 0);
276
+ const childIsPromise = isPromise(children);
277
+ if (childIsPromise) {
278
+ boundary.increment();
279
+ children.then(
280
+ (v) => {
281
+ setResolved(() => v);
282
+ boundary.decrement();
283
+ },
284
+ () => boundary.decrement()
285
+ );
286
+ }
287
+ return createMemo2(() => {
288
+ const showFallback = listState ? listState.showFallback() : boundary.inFallback();
289
+ if (showFallback) return fallback;
290
+ if (childIsPromise) return resolved();
291
+ return children;
292
+ });
293
+ }
294
+ function SuspenseList(props) {
295
+ return createComponent2(SuspenseListImpl, props);
296
+ }
297
+ function SuspenseListImpl(props) {
298
+ const { revealOrder = "together", tail } = props;
299
+ const registrations = [];
300
+ function coordinateReveal() {
301
+ if (revealOrder === "together") {
302
+ const allResolved = registrations.every((r) => !r.inFallback());
303
+ registrations.forEach((r) => {
304
+ r.setShowContent(allResolved);
305
+ r.setShowFallback(!allResolved);
306
+ });
307
+ } else {
308
+ const items = revealOrder === "backwards" ? [...registrations].reverse() : registrations;
309
+ let blocked = false;
310
+ for (const r of items) {
311
+ if (blocked || r.inFallback()) {
312
+ blocked = true;
313
+ r.setShowContent(false);
314
+ r.setShowFallback(tail !== "hidden");
315
+ } else {
316
+ r.setShowContent(true);
317
+ r.setShowFallback(false);
318
+ }
319
+ }
320
+ }
321
+ }
322
+ const coordinator = {
323
+ register: (inFallback) => {
324
+ const [showContent, setShowContent] = createSignal2(true);
325
+ const [showFallback, setShowFallback] = createSignal2(false);
326
+ registrations.push({ inFallback, setShowContent, setShowFallback });
327
+ createEffect2(() => {
328
+ inFallback();
329
+ coordinateReveal();
330
+ });
331
+ return { showContent, showFallback };
332
+ }
333
+ };
334
+ return SuspenseListContext.Provider({
335
+ value: coordinator,
336
+ children: props.children
337
+ });
338
+ }
339
+ asSuspense(Suspense);
340
+ Object.defineProperty(Suspense, "__suspense", { value: true, enumerable: true });
341
+
342
+ // src/lib/render/lazy.ts
343
+ import { createComponent as createComponent3 } from "@fluixi/dom";
344
+ import {
345
+ untrack as untrack2,
346
+ createMemo as createMemo3,
347
+ createResource as createResource2
348
+ } from "@fluixi/reactive/signal";
349
+ function fromChunk(value) {
350
+ if (value != null && (typeof value === "object" || typeof value === "function")) {
351
+ try {
352
+ value["$lazy"] = true;
353
+ } catch {
354
+ }
355
+ }
356
+ return value;
357
+ }
358
+ function lazy(loader, options) {
359
+ let resolved;
360
+ let promise;
361
+ let component;
362
+ function load() {
363
+ if (!promise) {
364
+ promise = loader().then((mod) => resolved = mod.default);
365
+ }
366
+ return promise;
367
+ }
368
+ if (options?.preload) load();
369
+ const LazyWrapper = ((props) => {
370
+ if (resolved) {
371
+ const C = resolved;
372
+ return fromChunk(untrack2(() => C(props)));
373
+ }
374
+ if (!component) {
375
+ const [resource2] = createResource2(() => load(), { transport: false });
376
+ component = resource2;
377
+ if (resource2.error) throw resource2.error;
378
+ }
379
+ return createMemo3(() => {
380
+ const C = component();
381
+ return C ? fromChunk(createComponent3(C, props)) : void 0;
382
+ });
383
+ });
384
+ LazyWrapper.preload = () => load().then(() => void 0);
385
+ LazyWrapper.$lazy = true;
386
+ LazyWrapper.loader = loader;
387
+ return LazyWrapper;
388
+ }
389
+
390
+ // src/lib/render/deferred.ts
391
+ import { isServer as isServer2 } from "@fluixi/dom";
392
+ import { createMemo as createMemo4, createSignal as createSignal3 } from "@fluixi/reactive/signal";
393
+ import { observeIntersection } from "@fluixi/dom/utils";
394
+ function deferred(loader, options) {
395
+ const exportName = options.export ?? "default";
396
+ const Lazy = lazy(
397
+ () => loader().then((mod) => {
398
+ const component = mod[exportName];
399
+ if (typeof component !== "function") {
400
+ throw new Error(
401
+ `deferred(): module has no '${exportName}' export (got ${typeof component}).`
402
+ );
403
+ }
404
+ return { default: component };
405
+ }),
406
+ { fallback: options.fallback }
407
+ );
408
+ function Deferred(props) {
409
+ if (options.strategy.kind === "never") return isServer2() ? Lazy(props) : null;
410
+ if (isServer2() || options.strategy.kind === "eager") return Lazy(props);
411
+ const [ready, setReady] = createSignal3(false);
412
+ const start = () => {
413
+ void Lazy.preload().then(() => setReady(true));
414
+ };
415
+ const anchor = options.strategy.kind === "visible" ? createAnchor() : void 0;
416
+ schedule(options.strategy, start, anchor);
417
+ return createMemo4(() => ready() ? Lazy(props) : anchor ?? options.fallback ?? null, void 0, {
418
+ name: "deferred"
419
+ });
420
+ }
421
+ Deferred.preload = Lazy.preload;
422
+ return Deferred;
423
+ }
424
+ function createAnchor() {
425
+ const el = document.createElement("span");
426
+ el.setAttribute("data-fx-load", "visible");
427
+ el.style.display = "block";
428
+ return el;
429
+ }
430
+ function schedule(strategy, start, anchor) {
431
+ let fired = false;
432
+ const once = () => {
433
+ if (fired) return;
434
+ fired = true;
435
+ start();
436
+ };
437
+ switch (strategy.kind) {
438
+ case "idle": {
439
+ const ric = globalThis.requestIdleCallback;
440
+ if (ric) ric(once);
441
+ else setTimeout(once, 1);
442
+ return;
443
+ }
444
+ case "visible": {
445
+ if (!anchor || typeof IntersectionObserver === "undefined") {
446
+ once();
447
+ return;
448
+ }
449
+ const stop = observeIntersection(
450
+ anchor,
451
+ (isIntersecting) => {
452
+ if (!isIntersecting) return;
453
+ stop();
454
+ once();
455
+ },
456
+ { rootMargin: strategy.rootMargin ?? "0px" }
457
+ );
458
+ return;
459
+ }
460
+ case "interaction": {
461
+ const handler = () => {
462
+ for (const event of strategy.events) {
463
+ document.removeEventListener(event, handler, true);
464
+ }
465
+ once();
466
+ };
467
+ for (const event of strategy.events) {
468
+ document.addEventListener(event, handler, { capture: true, passive: true });
469
+ }
470
+ return;
471
+ }
472
+ case "media": {
473
+ if (typeof matchMedia === "undefined") {
474
+ once();
475
+ return;
476
+ }
477
+ const query2 = matchMedia(strategy.query);
478
+ if (query2.matches) {
479
+ once();
480
+ return;
481
+ }
482
+ const onChange = (e) => {
483
+ if (!e.matches) return;
484
+ query2.removeEventListener("change", onChange);
485
+ once();
486
+ };
487
+ query2.addEventListener("change", onChange);
488
+ return;
489
+ }
490
+ /* c8 ignore next 3 */
491
+ default:
492
+ once();
493
+ }
494
+ }
495
+
496
+ // src/lib/render/await.ts
497
+ import { createResource as createResource3 } from "@fluixi/reactive/signal";
498
+ function Await(props) {
499
+ const fetcher = () => {
500
+ const v = props.value;
501
+ return typeof v === "function" ? v() : v;
502
+ };
503
+ const [data] = createResource3(fetcher);
504
+ return () => {
505
+ if (data.loading) return props.fallback;
506
+ const child = props.children;
507
+ return typeof child === "function" ? child(data()) : child;
508
+ };
509
+ }
510
+
511
+ // src/lib/render/index.ts
512
+ function render(code, container, options = {}) {
513
+ delegateEvents(["click", "input", "change", "submit"]);
514
+ if (isServer3()) {
515
+ throw new Error(
516
+ "render() is for client-side only. Use renderToString() on server."
517
+ );
518
+ }
519
+ if (!container) {
520
+ throw new Error("Container element is required");
521
+ }
522
+ let disposer;
523
+ createRoot2((dispose) => {
524
+ disposer = dispose;
525
+ const result = typeof code === "function" ? code() : code;
526
+ container.textContent = "";
527
+ stampVersions(container);
528
+ warnOnVersionSkew();
529
+ insert(container, () => result);
530
+ });
531
+ return () => {
532
+ if (disposer) {
533
+ disposer();
534
+ disposer = void 0;
535
+ }
536
+ };
537
+ }
538
+ function isLitTemplateResult(value) {
539
+ return value && typeof value === "object" && (value["_$litType$"] !== void 0 || value["_$litDirective$"] !== void 0);
540
+ }
541
+ function portal(code, target, options = {}) {
542
+ const container = document.createElement("div");
543
+ container.setAttribute("data-portal", "true");
544
+ target.appendChild(container);
545
+ const dispose = render(code, container, options);
546
+ return () => {
547
+ dispose();
548
+ if (target.contains(container)) {
549
+ target.removeChild(container);
550
+ }
551
+ };
552
+ }
553
+ function isRenderable(value) {
554
+ if (value == null) return true;
555
+ if (typeof value === "function") return true;
556
+ if (isDOMNode(value)) return true;
557
+ if (isLitTemplateResult(value)) return true;
558
+ if (Array.isArray(value)) return true;
559
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
560
+ return true;
561
+ }
562
+ return false;
563
+ }
564
+ function initDelegation() {
565
+ if (isServer3()) return;
566
+ delegateEvents(["click", "input", "change", "submit"]);
567
+ }
568
+ function cleanupDelegation() {
569
+ if (isServer3()) return;
570
+ }
571
+
572
+ // src/lib/context/context.ts
573
+ import { asProvider } from "@fluixi/dom";
574
+ import { createContext as createReactiveContext, useContext as useReactiveContext } from "@fluixi/reactive/signal";
575
+ import {
576
+ readChildren as readChildren2
577
+ } from "@fluixi/reactive/signal";
578
+ var _warnedEagerProvider = false;
579
+ function warnEagerProvider() {
580
+ if (_warnedEagerProvider) return;
581
+ _warnedEagerProvider = true;
582
+ if (typeof process !== "undefined" && true) return;
583
+ console.warn(
584
+ "[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={...}>{props.children}</Context.Provider>"
585
+ );
586
+ }
587
+ function createProvider(a, value, childProps) {
588
+ const isLazyForm = !!a?.Provider;
589
+ const context = isLazyForm ? a : a.context;
590
+ const rawValue = isLazyForm ? value : a.value;
591
+ const debug = isLazyForm ? false : a.debug ?? false;
592
+ if (!isLazyForm) warnEagerProvider();
593
+ const resolvedValue = typeof rawValue === "function" ? rawValue() : rawValue;
594
+ const sourceProps = isLazyForm ? childProps : a;
595
+ return context.Provider({
596
+ value: resolvedValue,
597
+ get children() {
598
+ return sourceProps?.children;
599
+ },
600
+ debug
601
+ });
602
+ }
603
+ function createContextWithProvider(defaultValue) {
604
+ const context = createContext3(defaultValue);
605
+ const provider = (props) => {
606
+ return createProvider(context, props.value, props);
607
+ };
608
+ return [context, provider];
609
+ }
610
+ function composeProviders(contexts, children) {
611
+ if (contexts.length === 0) {
612
+ return readChildren2(() => children);
613
+ }
614
+ const [context, value] = contexts[0];
615
+ const remaining = contexts.slice(1);
616
+ return createProvider(context, value, {
617
+ get children() {
618
+ return composeProviders(remaining, children);
619
+ }
620
+ });
621
+ }
622
+ function createConsumer(context) {
623
+ return (props) => {
624
+ const value = useContext3(context);
625
+ return props.children(value);
626
+ };
627
+ }
628
+ function useProvide(context, factory) {
629
+ const existing = useContext3(context);
630
+ if (existing === context.defaultValue) {
631
+ return factory();
632
+ }
633
+ return existing;
634
+ }
635
+ function createContext3(defaultValue, name) {
636
+ const context = createReactiveContext(defaultValue, name);
637
+ const Provider = (props) => {
638
+ if (props.debug === true) {
639
+ }
640
+ return context.Provider({
641
+ value: props.value,
642
+ get children() {
643
+ return props.children;
644
+ },
645
+ debug: props.debug
646
+ });
647
+ };
648
+ if (typeof Symbol !== "undefined" && Symbol.for) {
649
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
650
+ }
651
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
652
+ return {
653
+ id: context.id,
654
+ Provider: asProvider(Provider),
655
+ defaultValue
656
+ };
657
+ }
658
+ function useContext3(context) {
659
+ const value = useReactiveContext(context);
660
+ return value !== void 0 ? value : context.defaultValue;
661
+ }
662
+
663
+ // src/lib/isomorphic.ts
664
+ import { createSignal as createSignal4, createMemo as createMemo5 } from "@fluixi/reactive/signal";
665
+ import { getServerData } from "@fluixi/dom";
666
+ var REGISTRY_KEY = "__fluixi_iso_states__";
667
+ var SEED_PREFIX = "__iso:";
668
+ function registry() {
669
+ return globalThis[REGISTRY_KEY] ??= /* @__PURE__ */ new Map();
670
+ }
671
+ function readSeed(key) {
672
+ if (typeof window === "undefined") return void 0;
673
+ const data = getServerData();
674
+ return data ? data[SEED_PREFIX + key] : void 0;
675
+ }
676
+ function createIsomorphicState(key, options) {
677
+ const seed = readSeed(key);
678
+ const initial = seed !== void 0 ? seed : typeof window !== "undefined" && options.client ? options.client() : options.fallback;
679
+ const [value, set] = createSignal4(initial);
680
+ registry().set(key, { server: options.server, set });
681
+ return { value, set, key };
682
+ }
683
+ function createIsomorphicStore(key, options) {
684
+ const seeded = readSeed(key) !== void 0;
685
+ const base = createIsomorphicState(key, {
686
+ server: options.server,
687
+ fallback: options.fallback
688
+ });
689
+ const value = () => base.value() ?? options.fallback;
690
+ const persistWrite = (v) => {
691
+ if (!options.persist || typeof localStorage === "undefined") return;
692
+ try {
693
+ localStorage.setItem(options.persist, JSON.stringify(v));
694
+ } catch {
695
+ }
696
+ };
697
+ const set = (v) => {
698
+ base.set(v);
699
+ persistWrite(v);
700
+ };
701
+ const setField = (k, val) => {
702
+ set({ ...value(), [k]: val });
703
+ };
704
+ const fields = {};
705
+ for (const k of Object.keys(options.fallback)) {
706
+ fields[k] = createMemo5(() => value()[k]);
707
+ }
708
+ let initPromise = null;
709
+ const ensureInit = () => {
710
+ if (seeded || !options.client) return Promise.resolve();
711
+ if (!initPromise) {
712
+ initPromise = Promise.resolve(options.client()).then((v) => {
713
+ set(v);
714
+ }).catch((e) => {
715
+ initPromise = null;
716
+ throw e;
717
+ });
718
+ }
719
+ return initPromise;
720
+ };
721
+ return { value, fields, set, setField, ensureInit, key };
722
+ }
723
+
724
+ // src/lib/env/index.ts
725
+ import { isServer as isServer4 } from "@fluixi/dom";
726
+ import { isServer as onServer } from "@fluixi/dom";
727
+ function isClient() {
728
+ return !onServer();
729
+ }
730
+ function createMemoryStorage() {
731
+ const mem = /* @__PURE__ */ new Map();
732
+ return {
733
+ getItem: (k) => mem.has(k) ? mem.get(k) : null,
734
+ setItem: (k, v) => void mem.set(k, String(v)),
735
+ removeItem: (k) => void mem.delete(k),
736
+ clear: () => mem.clear(),
737
+ key: (i) => Array.from(mem.keys())[i] ?? null,
738
+ get length() {
739
+ return mem.size;
740
+ }
741
+ };
742
+ }
743
+ var storage = typeof localStorage !== "undefined" ? localStorage : createMemoryStorage();
744
+ var env = {
745
+ get window() {
746
+ return typeof window !== "undefined" ? window : void 0;
747
+ },
748
+ get document() {
749
+ return typeof document !== "undefined" ? document : void 0;
750
+ }
751
+ };
752
+ function clientOnly(fn, fallback) {
753
+ return isClient() ? fn() : fallback;
754
+ }
755
+
756
+ // src/lib/theme/index.ts
757
+ import { createSignal as createSignal5 } from "@fluixi/reactive/signal";
758
+ function systemMap(system) {
759
+ if (!system) return null;
760
+ if (system === true) return { dark: "dark", light: "light" };
761
+ return system;
762
+ }
763
+ function createTheme(options) {
764
+ const storageKey = options.storageKey ?? "theme";
765
+ const attribute = options.attribute ?? "data-theme";
766
+ const sys = systemMap(options.system);
767
+ const detectInitial = () => {
768
+ const stored = storage.getItem(storageKey);
769
+ if (stored && options.themes.includes(stored)) return stored;
770
+ if (sys && env.window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches) return sys.dark;
771
+ if (sys) return sys.light;
772
+ return options.default;
773
+ };
774
+ const [value, setValue] = createSignal5(detectInitial());
775
+ const [isLoading, setLoading] = createSignal5(false);
776
+ const apply = (t) => {
777
+ env.document?.documentElement.setAttribute(attribute, t);
778
+ try {
779
+ storage.setItem(storageKey, t);
780
+ } catch {
781
+ }
782
+ };
783
+ const set = (t) => {
784
+ if (!options.themes.includes(t)) return;
785
+ const prev = value();
786
+ setValue(() => t);
787
+ apply(t);
788
+ options.onChange?.(t, prev);
789
+ if (options.load) {
790
+ setLoading(true);
791
+ options.onLoading?.(t);
792
+ Promise.resolve(options.load(t)).finally(() => {
793
+ setLoading(false);
794
+ options.onLoaded?.(t);
795
+ });
796
+ }
797
+ };
798
+ const toggle = () => {
799
+ const i = options.themes.indexOf(value());
800
+ set(options.themes[(i + 1) % options.themes.length]);
801
+ };
802
+ const init = () => apply(value());
803
+ const headScript = () => {
804
+ const cfg = JSON.stringify({
805
+ k: storageKey,
806
+ a: attribute,
807
+ d: options.default,
808
+ sys
809
+ });
810
+ return `<script>(function(){try{var c=${cfg},t=localStorage.getItem(c.k);if(!t&&c.sys)t=matchMedia('(prefers-color-scheme: dark)').matches?c.sys.dark:c.sys.light;if(!t)t=c.d;document.documentElement.setAttribute(c.a,t);}catch(e){}})();<\/script>`;
811
+ };
812
+ return { value, isLoading, set, toggle, init, headScript };
813
+ }
814
+
815
+ // src/lib/router/index.ts
816
+ import {
817
+ createSignal as createSignal7,
818
+ createMemo as createMemo6,
819
+ createResource as createResource5,
820
+ createEffect as createEffect3,
821
+ getOwner as getOwner2,
822
+ onCleanup as onCleanup2,
823
+ untrack as untrack3,
824
+ flush
825
+ } from "@fluixi/reactive/signal";
826
+
827
+ // src/lib/router/transition.ts
828
+ function supportsViewTransitions() {
829
+ return typeof document !== "undefined" && typeof document.startViewTransition === "function";
830
+ }
831
+ function prefersReducedMotion() {
832
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
833
+ return false;
834
+ }
835
+ try {
836
+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
837
+ } catch {
838
+ return false;
839
+ }
840
+ }
841
+ function shouldAnimate(mode) {
842
+ return mode !== "none" && supportsViewTransitions() && !prefersReducedMotion();
843
+ }
844
+ function prepareComponents(components) {
845
+ const pending = [];
846
+ for (const component of components) {
847
+ const preload = component?.preload;
848
+ if (typeof preload === "function") {
849
+ try {
850
+ const result = preload();
851
+ if (result && typeof result.then === "function") {
852
+ pending.push(result.catch(() => void 0));
853
+ }
854
+ } catch {
855
+ }
856
+ }
857
+ }
858
+ return pending.length ? Promise.all(pending).then(() => void 0) : null;
859
+ }
860
+ function runTransition(mode, commit) {
861
+ if (!shouldAnimate(mode)) {
862
+ return Promise.resolve(commit()).then(() => void 0);
863
+ }
864
+ const start = document.startViewTransition;
865
+ try {
866
+ const transition = start.call(document, () => commit());
867
+ transition.finished?.catch(() => void 0);
868
+ transition.ready?.catch(() => void 0);
869
+ return transition.updateCallbackDone.catch(() => void 0);
870
+ } catch {
871
+ return Promise.resolve(commit()).then(() => void 0);
872
+ }
873
+ }
874
+
875
+ // src/lib/router/index.ts
876
+ import {
877
+ insert as insert2,
878
+ createComponent as createComponent4,
879
+ createNativeElement,
880
+ setAttribute
881
+ } from "@fluixi/dom";
882
+ import { createContext as createContext4, useContext as useContext4 } from "@fluixi/reactive/signal";
883
+ import { get } from "@fluixi/utils/object";
884
+ import { deepEqual } from "@fluixi/utils/compare";
885
+ import {
886
+ createRouter as createCoreRouter,
887
+ createBrowserHistory,
888
+ matchRoutes,
889
+ matchPath
890
+ } from "@fluixi/router";
891
+ import {
892
+ createMemoryHistory,
893
+ createBrowserHistory as createBrowserHistory2,
894
+ matchRoutes as matchRoutes2,
895
+ matchPath as matchPath2
896
+ } from "@fluixi/router";
897
+
898
+ // src/lib/router/data.ts
899
+ import {
900
+ createResource as createResource4,
901
+ createSignal as createSignal6
902
+ } from "@fluixi/reactive/signal";
903
+
904
+ // src/lib/server/hydration.ts
905
+ import { isServer as domIsServer } from "@fluixi/dom";
906
+ var hydrationDataMap = /* @__PURE__ */ new Map();
907
+ function clearHydrationData() {
908
+ hydrationDataMap.clear();
909
+ }
910
+ function cleanupHydration() {
911
+ if (typeof window === "undefined") {
912
+ return;
913
+ }
914
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
915
+ if (script) {
916
+ script.remove();
917
+ }
918
+ const walker = document.createTreeWalker(
919
+ document.body,
920
+ NodeFilter.SHOW_COMMENT,
921
+ null
922
+ );
923
+ const comments = [];
924
+ let node;
925
+ while (node = walker.nextNode()) {
926
+ const comment = node;
927
+ const text = comment.nodeValue || "";
928
+ if (text.startsWith("#") || text.startsWith("/")) {
929
+ comments.push(comment);
930
+ }
931
+ }
932
+ comments.forEach((comment) => comment.remove());
933
+ clearHydrationData();
934
+ }
935
+ if (typeof window !== "undefined") {
936
+ window.addEventListener("load", () => {
937
+ setTimeout(cleanupHydration, 100);
938
+ });
939
+ }
940
+
941
+ // src/lib/router/data.ts
942
+ var [revalidationVersion, setRevalidationVersion] = createSignal6(0);
943
+ var RouteDataContext = createContext3(void 0, "route-data");
944
+ var RouteDataProvider = RouteDataContext.Provider;
945
+
946
+ // src/lib/router/index.ts
947
+ import { runWithOwner as runWithOwner2 } from "@fluixi/reactive/signal";
948
+ var RouterContext = createContext4(void 0, "router");
949
+ var OutletContext = createContext4(void 0, "outlet");
950
+ var LevelParamsContext = createContext4(void 0, "route-params");
951
+ var RouteDataContext2 = createContext4(void 0, "route-data");
952
+ function renderLayer(m, depth, base) {
953
+ let data;
954
+ const loader = m.route.data;
955
+ if (typeof loader === "function") {
956
+ let cancelled = false;
957
+ onCleanup2(() => {
958
+ cancelled = true;
959
+ });
960
+ const owner = getOwner2();
961
+ const [resource2] = createResource5(
962
+ () => loader({ params: base.params, location: base.location }, owner, () => cancelled)
963
+ );
964
+ data = resource2;
965
+ }
966
+ const buildPage = () => RouteDataContext2.Provider({
967
+ value: data,
968
+ get children() {
969
+ return LevelParamsContext.Provider({
970
+ value: m.params,
971
+ get children() {
972
+ return OutletContext.Provider({
973
+ value: { depth, ...base },
974
+ get children() {
975
+ return createComponent4(m.component, {});
976
+ }
977
+ });
978
+ }
979
+ });
980
+ }
981
+ });
982
+ if (!data) return buildPage();
983
+ const res = data;
984
+ const isLoading = () => res.loading;
985
+ const [ready, setReady] = createSignal7(untrack3(() => !isLoading()));
986
+ createEffect3(() => setReady(!isLoading()));
987
+ return createMemo6(() => ready() ? buildPage() : null);
988
+ }
989
+ function renderChild(ctx) {
990
+ const childIdx = ctx.depth + 1;
991
+ const [childComp, setChildComp] = createSignal7(
992
+ untrack3(() => ctx.matched()[childIdx]?.component)
993
+ );
994
+ createEffect3(() => {
995
+ const c = ctx.matched()[childIdx]?.component;
996
+ if (untrack3(childComp) !== c) setChildComp(() => c);
997
+ });
998
+ return createMemo6(() => {
999
+ const component = childComp();
1000
+ if (!component) {
1001
+ return ctx.notFound ? ctx.notFound() : null;
1002
+ }
1003
+ const m = untrack3(() => ctx.matched())[childIdx];
1004
+ return renderLayer(m, childIdx, {
1005
+ matched: ctx.matched,
1006
+ params: ctx.params,
1007
+ location: ctx.location
1008
+ });
1009
+ });
1010
+ }
1011
+ function renderNotFound(notFound) {
1012
+ if (notFound == null) return buildDefaultNotFound();
1013
+ return typeof notFound === "function" ? createComponent4(notFound, {}) : notFound;
1014
+ }
1015
+ function buildDefaultNotFound() {
1016
+ const el = createNativeElement("div");
1017
+ setAttribute(el, "class", "fx-not-found");
1018
+ setAttribute(el, "role", "main");
1019
+ setAttribute(
1020
+ el,
1021
+ "style",
1022
+ "min-height:60vh;display:grid;place-content:center;gap:.25rem;text-align:center;font-family:system-ui,-apple-system,sans-serif"
1023
+ );
1024
+ const h1 = createNativeElement("h1");
1025
+ setAttribute(h1, "style", "margin:0;font-size:2.5rem;font-weight:700");
1026
+ insert2(h1, "404");
1027
+ const p = createNativeElement("p");
1028
+ setAttribute(p, "style", "margin:0;opacity:.7");
1029
+ insert2(p, "This page could not be found.");
1030
+ el.appendChild(h1);
1031
+ el.appendChild(p);
1032
+ return el;
1033
+ }
1034
+ var pendingTransitionMode;
1035
+ function Router(props) {
1036
+ const history = props.history ?? createBrowserHistory();
1037
+ const router = createCoreRouter({
1038
+ routes: props.routes,
1039
+ base: props.base,
1040
+ history
1041
+ });
1042
+ const [state, setState] = createSignal7(router.state());
1043
+ let navigationId = 0;
1044
+ const takeMode = () => {
1045
+ const mode = pendingTransitionMode ?? (props.transition ?? "auto");
1046
+ pendingTransitionMode = void 0;
1047
+ return mode;
1048
+ };
1049
+ const unsub = router.subscribe((next) => {
1050
+ const id = ++navigationId;
1051
+ const mode = takeMode();
1052
+ const prepared = prepareComponents(
1053
+ (next.match?.matched ?? []).map((m) => m.component).filter(Boolean)
1054
+ );
1055
+ const commit = () => {
1056
+ setState(next);
1057
+ return flush();
1058
+ };
1059
+ if (!prepared) {
1060
+ void runTransition(mode, commit);
1061
+ return;
1062
+ }
1063
+ void prepared.then(() => {
1064
+ if (id !== navigationId) return;
1065
+ return runTransition(mode, commit);
1066
+ });
1067
+ });
1068
+ onCleanup2(() => {
1069
+ unsub();
1070
+ router.destroy();
1071
+ navigationId++;
1072
+ });
1073
+ const matched = createMemo6(
1074
+ () => (state().match?.matched ?? []).filter((m) => m.component)
1075
+ );
1076
+ const ctx = {
1077
+ router,
1078
+ location: createMemo6(() => state().location),
1079
+ params: createMemo6(() => state().match?.params ?? {})
1080
+ };
1081
+ const root = {
1082
+ depth: -1,
1083
+ matched,
1084
+ params: ctx.params,
1085
+ location: ctx.location,
1086
+ // Only the root carries this: renderChild shows it when the URL matched nothing.
1087
+ notFound: () => renderNotFound(props.notFound)
1088
+ };
1089
+ let rootView;
1090
+ return RouterContext.Provider({
1091
+ value: ctx,
1092
+ get children() {
1093
+ return rootView ??= renderChild(root);
1094
+ }
1095
+ });
1096
+ }
1097
+ var _ssrRouterStub = {
1098
+ router: { navigate: () => {
1099
+ } },
1100
+ location: () => ({ pathname: "", search: "", hash: "", query: {} }),
1101
+ params: () => ({})
1102
+ };
1103
+ function useRouter() {
1104
+ const ctx = useContext4(RouterContext);
1105
+ if (ctx) return ctx;
1106
+ if (typeof window === "undefined") return _ssrRouterStub;
1107
+ throw new Error("[router] useRouter must be used within <Router>");
1108
+ }
1109
+ function useParams() {
1110
+ const params = useRouter().params;
1111
+ return createMemo6(() => params(), {}, {
1112
+ equals: (a, b) => JSON.stringify(a) === JSON.stringify(b)
1113
+ });
1114
+ }
1115
+ function useLocation() {
1116
+ const { location } = useRouter();
1117
+ return new Proxy({}, {
1118
+ get: (_t, key) => location()[key],
1119
+ has: (_t, key) => key in location(),
1120
+ ownKeys: () => Reflect.ownKeys(location()),
1121
+ getOwnPropertyDescriptor: (_t, key) => Object.getOwnPropertyDescriptor(location(), key)
1122
+ });
1123
+ }
1124
+ function useNavigate() {
1125
+ const { router } = useRouter();
1126
+ return (to, options) => {
1127
+ pendingTransitionMode = options?.transition;
1128
+ router.navigate(to, options);
1129
+ };
1130
+ }
1131
+ var read = (v) => typeof v === "function" ? v() : v;
1132
+ var LINK_OWN_PROPS = /* @__PURE__ */ new Set([
1133
+ "href",
1134
+ "slot",
1135
+ "class",
1136
+ "className",
1137
+ "active",
1138
+ "activeClass",
1139
+ "replace",
1140
+ "children"
1141
+ ]);
1142
+ function Link(props) {
1143
+ const ctx = useContext4(RouterContext);
1144
+ const navigate = () => ctx?.router.navigate(read(props.href) ?? "", { replace: read(props.replace) });
1145
+ const a = createNativeElement("a");
1146
+ setAttribute(a, "href", read(props.href) ?? "");
1147
+ if (props.slot) setAttribute(a, "slot", read(props.slot));
1148
+ for (const k of Object.keys(props)) {
1149
+ if (LINK_OWN_PROPS.has(k)) continue;
1150
+ const v = props[k];
1151
+ if (v != null && typeof v !== "function") setAttribute(a, k, String(v));
1152
+ }
1153
+ if (typeof a.addEventListener === "function") {
1154
+ a.addEventListener("click", (e) => {
1155
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
1156
+ e.preventDefault();
1157
+ navigate();
1158
+ });
1159
+ } else {
1160
+ const base = read(props.className ?? props.class) ?? "";
1161
+ if (base) setAttribute(a, "class", base);
1162
+ }
1163
+ if (typeof a.addEventListener === "function") {
1164
+ createEffect3(() => {
1165
+ const href = read(props.href) ?? "";
1166
+ a.setAttribute("href", href);
1167
+ const base = read(props.className ?? props.class) ?? "";
1168
+ const activeClass = read(props.activeClass) ?? "";
1169
+ const active = read(props.active) ?? ctx?.location().pathname === href;
1170
+ a.className = [base, active ? activeClass : ""].filter(Boolean).join(" ");
1171
+ });
1172
+ }
1173
+ const linkChildren = props.children;
1174
+ if (linkChildren != null) insert2(a, linkChildren);
1175
+ return a;
1176
+ }
1177
+
1178
+ // src/lib/core.ts
1179
+ import { html, svg } from "@fluixi/dom";
1180
+ import {
1181
+ query,
1182
+ queryAll,
1183
+ closest,
1184
+ addClass,
1185
+ removeClass,
1186
+ toggleClass,
1187
+ hasClass,
1188
+ setAttribute as setAttribute2,
1189
+ getAttribute,
1190
+ removeAttribute,
1191
+ setStyles,
1192
+ getStyle,
1193
+ createElement,
1194
+ removeChildren,
1195
+ appendChildren,
1196
+ isVisible,
1197
+ scrollIntoView,
1198
+ getOffset,
1199
+ delegate,
1200
+ waitForElement,
1201
+ observeIntersection as observeIntersection2,
1202
+ observeResize
1203
+ } from "@fluixi/dom";
1204
+ import {
1205
+ classMap,
1206
+ styleMap,
1207
+ Island,
1208
+ hydrateIslands,
1209
+ mergeProps,
1210
+ splitProps
1211
+ } from "@fluixi/dom";
1212
+
1213
+ // src/lib/control-flow.ts
1214
+ import {
1215
+ Show,
1216
+ For,
1217
+ Index,
1218
+ Switch,
1219
+ Match,
1220
+ Dynamic,
1221
+ ErrorBoundary,
1222
+ Portal,
1223
+ ClientOnly,
1224
+ NoSsr
1225
+ } from "@fluixi/dom";
1226
+
1227
+ // src/lib/core.ts
1228
+ import { createStore, untrackStore, unwrap, Store } from "@fluixi/reactive/store";
1229
+ var VERSION2 = "0.0.1";
1230
+ var FRAMEWORK_NAME = "Fluixi";
1231
+ var core_default = {
1232
+ // Core
1233
+ createComponent,
1234
+ // render,
1235
+ onMount,
1236
+ onUnmount,
1237
+ createEffect: createEffect4,
1238
+ createMemo: createMemo7,
1239
+ createSignal: createSignal8,
1240
+ createContext: createContext3,
1241
+ createRoot: createRoot3,
1242
+ createDeferred: createDeferred2,
1243
+ createComputed: createComputed2,
1244
+ createRenderEffect: createRenderEffect3,
1245
+ createSelector,
1246
+ onCleanup: onCleanup3,
1247
+ getOwner: getOwner3,
1248
+ runWithOwner: runWithOwner3,
1249
+ batch: batch2,
1250
+ untrack: untrack4,
1251
+ useContext: useContext3,
1252
+ setOwner,
1253
+ // Control Flow
1254
+ // Show,
1255
+ // For,
1256
+ // Switch,
1257
+ // Match,
1258
+ // Portal,
1259
+ // Dynamic,
1260
+ // Context
1261
+ // Provider,
1262
+ // Resources
1263
+ // createResource,
1264
+ // Router
1265
+ // createRouter,
1266
+ Router,
1267
+ Link,
1268
+ useRouter,
1269
+ useNavigate,
1270
+ read: read2,
1271
+ reduce,
1272
+ // Meta
1273
+ VERSION: VERSION2,
1274
+ FRAMEWORK_NAME
1275
+ };
1276
+ export {
1277
+ $component,
1278
+ Await,
1279
+ ClientOnly,
1280
+ Dynamic,
1281
+ ErrorBoundary,
1282
+ FRAMEWORK_NAME,
1283
+ For,
1284
+ Index,
1285
+ Island,
1286
+ Link,
1287
+ Match,
1288
+ NoSsr,
1289
+ Portal,
1290
+ Router,
1291
+ Show,
1292
+ Store,
1293
+ Suspense,
1294
+ SuspenseList,
1295
+ Switch,
1296
+ VERSION2 as VERSION,
1297
+ addClass,
1298
+ appendChildren,
1299
+ batch2 as batch,
1300
+ classMap,
1301
+ cleanupDelegation,
1302
+ clientOnly,
1303
+ closest,
1304
+ composeProviders,
1305
+ createComponent,
1306
+ createComputed2 as createComputed,
1307
+ createConsumer,
1308
+ createContext3 as createContext,
1309
+ createContextWithProvider,
1310
+ createDebounce,
1311
+ createDebouncedResource,
1312
+ createDebouncedSignal,
1313
+ createDeferred2 as createDeferred,
1314
+ createEffect4 as createEffect,
1315
+ createIsomorphicState,
1316
+ createIsomorphicStore,
1317
+ createMemo7 as createMemo,
1318
+ createMemoryStorage,
1319
+ createProvider,
1320
+ createRenderEffect3 as createRenderEffect,
1321
+ createResource6 as createResource,
1322
+ createRoot3 as createRoot,
1323
+ createSelector,
1324
+ createSignal8 as createSignal,
1325
+ createStore,
1326
+ createTheme,
1327
+ core_default as default,
1328
+ deferred,
1329
+ delegate,
1330
+ createElement as domCreateElement,
1331
+ effect,
1332
+ env,
1333
+ getAttribute,
1334
+ getOffset,
1335
+ getOwner3 as getOwner,
1336
+ getStyle,
1337
+ hasClass,
1338
+ html,
1339
+ hydrateIslands,
1340
+ initDelegation,
1341
+ isClient,
1342
+ isJSXElement,
1343
+ isLitResult,
1344
+ isNode,
1345
+ isRenderable,
1346
+ isServer4 as isServer,
1347
+ isVisible,
1348
+ lazy,
1349
+ memo,
1350
+ mergeProps,
1351
+ observeIntersection2 as observeIntersection,
1352
+ observeResize,
1353
+ onCleanup3 as onCleanup,
1354
+ onMount,
1355
+ onUnmount,
1356
+ portal,
1357
+ query,
1358
+ queryAll,
1359
+ read2 as read,
1360
+ reduce,
1361
+ removeAttribute,
1362
+ removeChildren,
1363
+ removeClass,
1364
+ render,
1365
+ resource,
1366
+ runWithOwner3 as runWithOwner,
1367
+ scrollIntoView,
1368
+ setAttribute2 as setAttribute,
1369
+ setOwner,
1370
+ setStyles,
1371
+ signal,
1372
+ splitProps,
1373
+ storage,
1374
+ styleMap,
1375
+ svg,
1376
+ toggleClass,
1377
+ untrack4 as untrack,
1378
+ untrackStore,
1379
+ unwrap,
1380
+ useCallback,
1381
+ useContext3 as useContext,
1382
+ useEffect,
1383
+ useEventListener,
1384
+ useLocation,
1385
+ useMemo,
1386
+ useNavigate,
1387
+ useParams,
1388
+ useProvide,
1389
+ useReducer,
1390
+ useRef,
1391
+ useRouter,
1392
+ waitForElement
1393
+ };