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