@stacksjs/stx 0.2.527 → 0.2.528
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-hqvdm4h9.js → chunk-07abr1v4.js} +1 -1
- package/dist/chunk-0d9rx3n4.js +2 -0
- package/dist/chunk-0fna7gd0.js +2 -0
- package/dist/chunk-0gzm7em2.js +2 -0
- package/dist/chunk-0ksq0e6s.js +2 -0
- package/dist/{chunk-4c1afy15.js → chunk-0rt5ec7a.js} +2 -2
- package/dist/{chunk-365ktg70.js → chunk-0ytm2ecf.js} +6 -6
- package/dist/{chunk-802qf0vz.js → chunk-1e7g79x4.js} +1 -1
- package/dist/{chunk-2h25j8se.js → chunk-1r5zd4a9.js} +3 -3
- package/dist/{chunk-8xpyzcq2.js → chunk-1s7qdv2h.js} +3 -3
- package/dist/{chunk-er7y8hk9.js → chunk-1v6yyvxf.js} +2 -2
- package/dist/{chunk-jcmgj8kk.js → chunk-21rm5kv6.js} +2 -2
- package/dist/{chunk-kp4mzspk.js → chunk-299xbyhn.js} +4 -4
- package/dist/chunk-2bwhc8ea.js +2 -0
- package/dist/chunk-2kjxd3v1.js +2 -0
- package/dist/{chunk-3y8ykqpx.js → chunk-2m5mx0x8.js} +1 -1
- package/dist/{chunk-01rz8h7x.js → chunk-2twfqcxm.js} +2 -2
- package/dist/{chunk-dne8n6h3.js → chunk-2y82wf9d.js} +2 -2
- package/dist/{chunk-8fb1mqw1.js → chunk-346zc43s.js} +1 -1
- package/dist/{chunk-3s9s1mdt.js → chunk-35j1evvy.js} +3 -3
- package/dist/{chunk-bqz4wenr.js → chunk-3cn7973z.js} +1 -1
- package/dist/chunk-3j02tj5n.js +2 -0
- package/dist/{chunk-eacd5755.js → chunk-3j9de8yh.js} +1 -1
- package/dist/chunk-3v2bf157.js +2 -0
- package/dist/{chunk-yexnqmz3.js → chunk-44e5tk5g.js} +2 -2
- package/dist/{chunk-5hmpecme.js → chunk-4625sykb.js} +3 -3
- package/dist/chunk-4bfdyf1s.js +2 -0
- package/dist/{chunk-1835r718.js → chunk-52mjjszq.js} +2 -2
- package/dist/{chunk-fxxrrq9n.js → chunk-58jyc7kp.js} +3 -3
- package/dist/{chunk-yxdyh23k.js → chunk-5tyes97j.js} +2 -2
- package/dist/chunk-62s4jb6m.js +2 -0
- package/dist/{chunk-jbvg29t0.js → chunk-6k7spr38.js} +5 -5
- package/dist/{chunk-e62nw7zk.js → chunk-6t0rq51y.js} +2 -2
- package/dist/chunk-6ywr110f.js +2 -0
- package/dist/chunk-70cr8xzz.js +2 -0
- package/dist/{chunk-bq7a2bn4.js → chunk-7e7mcrf9.js} +5 -5
- package/dist/{chunk-gynes6rm.js → chunk-7p0zerfj.js} +8 -8
- package/dist/{chunk-ygetbydb.js → chunk-869wyw0j.js} +6 -6
- package/dist/{chunk-gbfap7rv.js → chunk-8m3k43d3.js} +6 -6
- package/dist/{chunk-bb4agtjs.js → chunk-8rxammgf.js} +2 -2
- package/dist/{chunk-qrntkbfy.js → chunk-93cf01s9.js} +1 -1
- package/dist/{chunk-c57j92td.js → chunk-9mjy16pw.js} +2 -2
- package/dist/chunk-ad0czgpa.js +2 -0
- package/dist/chunk-axjzqh7v.js +2 -0
- package/dist/chunk-bqah6yhk.js +2 -0
- package/dist/chunk-byr1derh.js +2 -0
- package/dist/{chunk-04h0z6z9.js → chunk-cen7wkv8.js} +2 -2
- package/dist/{chunk-tkagcknf.js → chunk-csbft3wz.js} +2 -2
- package/dist/{chunk-67actssw.js → chunk-d8ramz4s.js} +2 -2
- package/dist/chunk-dvph69ej.js +2 -0
- package/dist/{chunk-dqe0cvyp.js → chunk-dx23ntmm.js} +1 -1
- package/dist/chunk-e0p7p7p2.js +2 -0
- package/dist/chunk-e1c9gypy.js +2 -0
- package/dist/chunk-eh3nvr2g.js +2 -0
- package/dist/{chunk-qt6f70d8.js → chunk-etdx3fye.js} +17 -7
- package/dist/{chunk-x81vcxzs.js → chunk-f1n4e4jy.js} +2 -2
- package/dist/{chunk-s9mq9x2k.js → chunk-f5pmyxtn.js} +5 -5
- package/dist/chunk-fanmabb0.js +2 -0
- package/dist/chunk-fdbtr4my.js +2 -0
- package/dist/chunk-fhsy7dc5.js +2 -0
- package/dist/chunk-fjd5ka6v.js +2 -0
- package/dist/{chunk-2j04bc8c.js → chunk-fk45zc1b.js} +4 -4
- package/dist/chunk-fq5xecrx.js +2 -0
- package/dist/chunk-gaz311xs.js +2 -0
- package/dist/chunk-gbb8dze1.js +2 -0
- package/dist/{chunk-hktvv0hd.js → chunk-ggb57j6c.js} +2 -2
- package/dist/chunk-gkzvxt62.js +2 -0
- package/dist/chunk-gmx73f50.js +2 -0
- package/dist/chunk-h80p2gkn.js +2 -0
- package/dist/{chunk-h6q8jafh.js → chunk-hbwmmt91.js} +2 -2
- package/dist/{chunk-g6c8d3f5.js → chunk-he404gbh.js} +4 -4
- package/dist/chunk-hmk2x1t8.js +2 -0
- package/dist/{chunk-hjxfg4bv.js → chunk-j19b6d9m.js} +9 -9
- package/dist/chunk-j1tbfabt.js +2 -0
- package/dist/chunk-j7615qvy.js +33 -0
- package/dist/{chunk-n34kagea.js → chunk-jj8ssn0d.js} +2 -2
- package/dist/chunk-jkd0c82m.js +2 -0
- package/dist/chunk-jnpyzq5m.js +2 -0
- package/dist/chunk-jwx0h9qb.js +2 -0
- package/dist/{chunk-2bv5g3rf.js → chunk-jya4r00e.js} +6 -6
- package/dist/chunk-k4p80n25.js +2 -0
- package/dist/chunk-kg4navnh.js +2 -0
- package/dist/chunk-kpbpmmdk.js +2 -0
- package/dist/{chunk-1aw9qbdf.js → chunk-kpns3659.js} +167 -18
- package/dist/{chunk-v9yx1kva.js → chunk-mftzhj7x.js} +2 -2
- package/dist/chunk-mh7k2ps4.js +2837 -0
- package/dist/{chunk-vzedh4wk.js → chunk-my4s7k0x.js} +7 -7
- package/dist/{chunk-e5hqhzbx.js → chunk-n48v0cma.js} +2 -2
- package/dist/chunk-nc1wcdfs.js +2 -0
- package/dist/{chunk-1c407nky.js → chunk-p8c5g5n2.js} +5 -5
- package/dist/chunk-pkwed7dt.js +2 -0
- package/dist/{chunk-d0k39nsg.js → chunk-qtvth7eg.js} +3 -3
- package/dist/chunk-r0n937ex.js +2 -0
- package/dist/chunk-rypj5y6d.js +2 -0
- package/dist/chunk-syde729h.js +2 -0
- package/dist/chunk-t3mg529n.js +2 -0
- package/dist/{chunk-vp827ah7.js → chunk-v2zxxjqn.js} +5 -5
- package/dist/chunk-v70hfs6d.js +2 -0
- package/dist/chunk-vfc4fg8v.js +2 -0
- package/dist/chunk-vrdg365w.js +2 -0
- package/dist/chunk-w5kx0qzg.js +2 -0
- package/dist/{chunk-s691cnew.js → chunk-w9srfsfk.js} +1 -1
- package/dist/chunk-wg7jz0ta.js +2 -0
- package/dist/{chunk-zv0vgamy.js → chunk-wn5zjs5m.js} +2 -2
- package/dist/{chunk-3ynfz6h8.js → chunk-wqxdx2td.js} +2 -2
- package/dist/{chunk-4dgbr7mm.js → chunk-wv9es0ra.js} +3 -3
- package/dist/{chunk-xx2pk2ay.js → chunk-x1tzt7yc.js} +4 -4
- package/dist/{chunk-9z1hxkxe.js → chunk-xg08g7xd.js} +4 -4
- package/dist/{chunk-gte0wmh8.js → chunk-xpvvne6r.js} +5 -5
- package/dist/{chunk-nfsx6bjj.js → chunk-xw45r9b5.js} +1 -1
- package/dist/{chunk-fesb4h31.js → chunk-y0c1srgj.js} +5 -5
- package/dist/chunk-y4b60ke0.js +2 -0
- package/dist/{chunk-4hz4g5ym.js → chunk-yh3p86qa.js} +2 -2
- package/dist/chunk-yqh6dny3.js +2 -0
- package/dist/chunk-zfct5zbe.js +2 -0
- package/dist/{chunk-x8mp9yvn.js → chunk-zw029e7n.js} +3 -3
- package/dist/chunk-zw2xxaza.js +2 -0
- package/dist/cli.js +13 -13
- package/dist/client-parameter-bindings.d.ts +14 -0
- package/dist/client-parameter-bindings.js +75 -5
- package/dist/client-script.js +26 -0
- package/dist/composable-loader.js +32 -2
- package/dist/composables/use-router.js +4 -3
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/includes.js +5 -3
- package/dist/pwa.js +3 -3
- package/dist/runtime-injection.js +6 -0
- package/dist/signals.js +11 -1
- package/dist/ssg.js +3 -3
- package/dist/types/config-types.d.ts +13 -0
- package/package.json +5 -5
- package/dist/chunk-0eptxhzy.js +0 -2
- package/dist/chunk-1mkyksne.js +0 -2
- package/dist/chunk-1zz2n4ks.js +0 -2
- package/dist/chunk-2bx2ara9.js +0 -2
- package/dist/chunk-38x0j2tz.js +0 -2
- package/dist/chunk-3c9t71pc.js +0 -2
- package/dist/chunk-3kxh9rsp.js +0 -2
- package/dist/chunk-3vqabd10.js +0 -2
- package/dist/chunk-490f2x2r.js +0 -2
- package/dist/chunk-4k65naeg.js +0 -2
- package/dist/chunk-5c1qesrs.js +0 -2
- package/dist/chunk-5j0fm4jy.js +0 -2837
- package/dist/chunk-7kc1kvqj.js +0 -33
- package/dist/chunk-7sbp7fh9.js +0 -2
- package/dist/chunk-9c86wgnk.js +0 -2
- package/dist/chunk-9jvdqjjb.js +0 -2
- package/dist/chunk-9pvectyv.js +0 -2
- package/dist/chunk-9s3tf3m3.js +0 -2
- package/dist/chunk-arjd987g.js +0 -2
- package/dist/chunk-avq5209p.js +0 -2
- package/dist/chunk-azt3h9fz.js +0 -2
- package/dist/chunk-b0bgprzs.js +0 -2
- package/dist/chunk-b42pdbmp.js +0 -2
- package/dist/chunk-bdr76feh.js +0 -2
- package/dist/chunk-c08wyf6x.js +0 -2
- package/dist/chunk-cdzf37ck.js +0 -2
- package/dist/chunk-cwnqjdys.js +0 -2
- package/dist/chunk-cxdcb0m5.js +0 -2
- package/dist/chunk-d81rv3bn.js +0 -2
- package/dist/chunk-fh5rp6wb.js +0 -2
- package/dist/chunk-fq7h8s3y.js +0 -2
- package/dist/chunk-gmpm0mw2.js +0 -2
- package/dist/chunk-gty89j8s.js +0 -2
- package/dist/chunk-hfns8btd.js +0 -2
- package/dist/chunk-hmyyq2hh.js +0 -2
- package/dist/chunk-j49qp4z7.js +0 -2
- package/dist/chunk-kkn0m1eg.js +0 -2
- package/dist/chunk-kxvtyh05.js +0 -2
- package/dist/chunk-mcx90969.js +0 -2
- package/dist/chunk-n1mww6x2.js +0 -2
- package/dist/chunk-n5z38q4m.js +0 -2
- package/dist/chunk-n7xgf1v9.js +0 -2
- package/dist/chunk-njpxfd44.js +0 -2
- package/dist/chunk-p5pna1sn.js +0 -2
- package/dist/chunk-qky9zfvx.js +0 -2
- package/dist/chunk-rn2w32kh.js +0 -2
- package/dist/chunk-rv50x1hm.js +0 -2
- package/dist/chunk-s9w4f0pb.js +0 -2
- package/dist/chunk-sy5s02tw.js +0 -2
- package/dist/chunk-tf239jvd.js +0 -2
- package/dist/chunk-vc1m5fr9.js +0 -2
- package/dist/chunk-vck6xky6.js +0 -2
- package/dist/chunk-vhhcdk5q.js +0 -2
- package/dist/chunk-vww5a3k9.js +0 -2
- package/dist/chunk-z6nm6rf1.js +0 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{y}from"./chunk-5tyes97j.js";import{I,At}from"./chunk-ba88n1j7.js";import{Ho,m,h,w,Ve,L,o}from"./chunk-mh7k2ps4.js";import{ie,yt,bt}from"./chunk-4625sykb.js";import{Ie,qt,pt,H}from"./chunk-2fb4yx25.js";import S from"path";var C=new Map,D=new Map,k=m(64),A=new Map,X=["composables","functions"];function U(t){let n=S.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function Z(t){if(t)return S.resolve(t);let n=`<default>:${process.cwd()}`,a=A.get(n);if(a!==void 0)return a;let e=await q();if(e!==null)A.set(n,e);return e}async function q(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return S.resolve(n,a);for(let e of X){let s=S.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!U(c))return s}catch{}}return null}async function z(t){let n=Array.isArray(t)?t:t?[S.resolve(t)]:(await o())._layerComposableDirs??[await Z()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=S.relative(e,d);if(!U(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function Lr(t){let{files:n}=await z(t),a=L({loader:"ts",target:"browser",define:w()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((p)=>p!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function Q(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function G(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):Q(t,s))e.add(s);return e}var T=m(64);function V(t,n){let a=h(t,n.size),e=T.get(a);if(e)return e;let s;try{s=Ho(t,n)}catch{s=G(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let p of c[1].split(",")){let g=p.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(g&&n.has(g))s.add(g)}return T.set(a,s),s}function Y(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of G(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of V(u,d))l.push(e.get(f));return l},p=new Set,g=a.flatMap((u,l)=>l===0?s(u):c(u));while(g.length>0){let u=[];for(let l of g){if(p.has(l))continue;p.add(l);for(let f of c(n.get(l)??""))if(!p.has(f))u.push(f)}g=u}return p}async function Nl(t,n,a){let{key:e,files:s}=await z(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>ie(r))])],c=Ie(d());if(s.length===0)return H(C,e,c,""),null;s.sort();let p=L({loader:"ts",target:"browser",define:w()}),g=pt(D,e,c);if(!g){let r=new Map,i=[];for(let _ of s)try{let x=await Bun.file(_).text();r.set(_,x);let b=p.scan(x).exports.filter((W)=>W!=="default");if(b.length>0)i.push({file:_,names:b})}catch{r.set(_,"")}g=H(D,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=g,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=h(r.join("\x00"),e,r.length,c),_=k.get(i);if(f=_??Y(l,u,r),!_)k.set(i,f)}if(f.size===0)return null;let E=s.filter((r)=>f.has(r)),B=`${e}\x00${E.join("\x00")}`,F=pt(C,B,c);if(F!==void 0)return F||null;let M=[],v=new Set,R=new Set;for(let r of E)try{let i=u.get(r)??await Bun.file(r).text(),_=S.basename(r,".ts");for(let b of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(b[1])R.add(b[1]);let x=[];try{for(let b of p.scan(i).exports)if(b!=="default")v.add(b),x.push(b)}catch{}if(i=I(i),yt(i))i=await bt(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),i=Ve(i);i=At(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=p.transformSync(i),M.push(`// Composable: ${_}
|
|
3
|
+
${i.trim()}`)}catch(i){console.warn(`[stx] Failed to load composable ${r}:`,i)}if(M.length===0||v.size===0)return H(C,B,c,""),null;let J=[...v].map((r)=>` try { if (!(${JSON.stringify(r)} in __c)) __c[${JSON.stringify(r)}] = ${r}; } catch (e) {}`).join(`
|
|
4
|
+
`),j=JSON.stringify([...v]),N=M.join(`
|
|
5
|
+
|
|
6
|
+
`),K=y.filter((r)=>!R.has(r)&&new RegExp(`\\b${r}\\b`).test(N)).map((r)=>`var ${r} = __stx[${JSON.stringify(r)}];`).join(`
|
|
7
|
+
`),P=JSON.stringify(new Bun.CryptoHasher("md5").update(`${j}\x00${N}`).digest("hex").slice(0,12)),O=`;(function(){
|
|
8
|
+
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
|
+
if (__bundles[${P}]) return;
|
|
10
|
+
__bundles[${P}] = true;
|
|
11
|
+
var __published = window.__stxComposableGlobals || (window.__stxComposableGlobals = {});
|
|
12
|
+
window.__composables = window.__composables || {};
|
|
13
|
+
var __c = window.__composables;
|
|
14
|
+
var __stx = window.stx || {};
|
|
15
|
+
${K}
|
|
16
|
+
${N}
|
|
17
|
+
${J}
|
|
18
|
+
var __names = ${j};
|
|
19
|
+
for (var __i = 0; __i < __names.length; __i++) {
|
|
20
|
+
var __n = __names[__i];
|
|
21
|
+
if (!(__n in __c) || __published[__n]) continue;
|
|
22
|
+
var __takenByBuiltin = !!(window.stx && __n in window.stx);
|
|
23
|
+
if (__takenByBuiltin || __n in window) {
|
|
24
|
+
console.warn('[stx] composable "' + __n + '" is not available as a bare identifier: '
|
|
25
|
+
+ (__takenByBuiltin ? 'a built-in of that name already exists' : 'window already defines that property')
|
|
26
|
+
+ '. Rename it, or use: import { ' + __n + ' } from "@composables"');
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
window[__n] = __c[__n];
|
|
30
|
+
__published[__n] = true;
|
|
31
|
+
}
|
|
32
|
+
})();`;return c=Ie(d()),H(C,B,c,O),O}function Ll(){C.clear(),qt(),D.clear(),k.clear(),A.clear()}
|
|
33
|
+
export{Lr,Nl,Ll};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import I from"fs";import u from"path";import V from"os";import x from"crypto";import{generatePlaceholder as C,processImage as D}from"ts-images";var j=[320,640,768,1024,1280,1536,1920],B=["webp","jpeg"],F=80,O=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],L={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},w=null,v=!1;async function p(){if(v)return w;v=!0;try{let t=await import("sharp");return w=t.default||t,w}catch{return null}}async function Nt(){return await p()!==null}async function J(){return!0}async function se(t,e={}){let{widths:a=j,formats:r=B,quality:n=F,fit:i="cover",placeholder:m="none",outputDir:o=".stx/images",baseUrl:b="/images"}=e,h,g;if(typeof t==="string"){if(g=t,!await Bun.file(t).exists())throw new In(`Image not found: ${t}`,"NOT_FOUND");h=await Bun.file(t).arrayBuffer().then((s)=>Buffer.from(s))}else g="buffer-input",h=t;let y=x.createHash("sha256").update(h).digest("hex").slice(0,12),k=await Pn(h),{width:c,height:S}=k,P=c/S;await I.promises.mkdir(o,{recursive:!0});let E=[],R=u.basename(g,u.extname(g)),l=a.filter((s)=>s<=c);if(!l.includes(c)&&c<=Math.max(...a))l.push(c);l.sort((s,f)=>s-f);for(let s of l){let f=Math.round(s/P);for(let d of r){let U=`${R}-${s}w-${y}.${d}`,A=u.join(o,U),T=`${b}/${U}`,q=await
|
|
3
|
-
export{j,B,F,Nt,J,se,Pn,
|
|
2
|
+
import I from"fs";import u from"path";import V from"os";import x from"crypto";import{generatePlaceholder as C,processImage as D}from"ts-images";var j=[320,640,768,1024,1280,1536,1920],B=["webp","jpeg"],F=80,O=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],L={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},w=null,v=!1;async function p(){if(v)return w;v=!0;try{let t=await import("sharp");return w=t.default||t,w}catch{return null}}async function Nt(){return await p()!==null}async function J(){return!0}async function se(t,e={}){let{widths:a=j,formats:r=B,quality:n=F,fit:i="cover",placeholder:m="none",outputDir:o=".stx/images",baseUrl:b="/images"}=e,h,g;if(typeof t==="string"){if(g=t,!await Bun.file(t).exists())throw new In(`Image not found: ${t}`,"NOT_FOUND");h=await Bun.file(t).arrayBuffer().then((s)=>Buffer.from(s))}else g="buffer-input",h=t;let y=x.createHash("sha256").update(h).digest("hex").slice(0,12),k=await Pn(h),{width:c,height:S}=k,P=c/S;await I.promises.mkdir(o,{recursive:!0});let E=[],R=u.basename(g,u.extname(g)),l=a.filter((s)=>s<=c);if(!l.includes(c)&&c<=Math.max(...a))l.push(c);l.sort((s,f)=>s-f);for(let s of l){let f=Math.round(s/P);for(let d of r){let U=`${R}-${s}w-${y}.${d}`,A=u.join(o,U),T=`${b}/${U}`,q=await aa(h,{width:s,height:f,format:d,quality:n,fit:i});await Bun.write(A,q),E.push({path:A,url:T,width:s,height:f,format:d,size:q.length})}}let M;if(m!=="none")M=await _(h,m);return{src:g,variants:E,placeholder:M,width:c,height:S,aspectRatio:P,hash:y}}async function Pn(t){let e=typeof t==="string"?Buffer.from(await Bun.file(t).arrayBuffer()):t,a=await p();if(a){let n=await a(e).metadata();return{width:n.width||0,height:n.height||0,format:n.format||"unknown",hasAlpha:n.hasAlpha}}return N(e)}function N(t){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let e=t.readUInt32BE(16),a=t.readUInt32BE(20);return{width:e,height:a,format:"png",hasAlpha:!0}}if(t[0]===255&&t[1]===216){let e=2;while(e<t.length){if(t[e]!==255)break;let a=t[e+1];if(a>=192&&a<=207&&a!==196&&a!==200&&a!==204){let n=t.readUInt16BE(e+5);return{width:t.readUInt16BE(e+7),height:n,format:"jpeg",hasAlpha:!1}}let r=t.readUInt16BE(e+2);e+=2+r}}if(t.toString("utf8",0,4)==="RIFF"&&t.toString("utf8",8,12)==="WEBP"){let e=t.toString("utf8",12,16);if(e==="VP8 "){let a=t.readUInt16LE(26)&16383,r=t.readUInt16LE(28)&16383;return{width:a,height:r,format:"webp",hasAlpha:!1}}if(e==="VP8L"){let a=t.readUInt32LE(21),r=(a&16383)+1,n=(a>>14&16383)+1;return{width:r,height:n,format:"webp",hasAlpha:!0}}}if(t.toString("utf8",0,3)==="GIF"){let e=t.readUInt16LE(6),a=t.readUInt16LE(8);return{width:e,height:a,format:"gif",hasAlpha:!0}}throw new In("Unable to parse image dimensions","PARSE_ERROR")}async function aa(t,e){let a=await p();if(a){let n=a(t).resize(e.width,e.height,{fit:e.fit});switch(e.format){case"webp":n=n.webp({quality:e.quality});break;case"avif":n=n.avif({quality:e.quality});break;case"jpeg":n=n.jpeg({quality:e.quality});break;case"png":n=n.png({quality:e.quality});break}return n.toBuffer()}let r=u.join(V.tmpdir(),`stx-img-${x.randomBytes(8).toString("hex")}.${e.format}`);try{return await D({input:t,output:r,format:e.format,quality:e.quality,resize:{width:e.width,height:e.height,fit:e.fit}}),Buffer.from(await Bun.file(r).arrayBuffer())}finally{await I.promises.unlink(r).catch(()=>{})}}async function _(t,e){let a=await p();if(e==="blur"&&a){let m=(await a(t).resize(20).blur(10).toBuffer()).toString("base64"),o=await Pn(t);return`data:${L[o.format]||"image/jpeg"};base64,${m}`}if(e==="dominant-color"&&a){let{dominant:i}=await a(t).resize(1,1).toBuffer().then(async(m)=>{let o=await a(m).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${i.r}, ${i.g}, ${i.b})`}let r=await Pn(t),n=u.join(V.tmpdir(),`stx-ph-${x.randomBytes(8).toString("hex")}.${r.format==="unknown"?"bin":r.format}`);try{await Bun.write(n,t);let i=e==="blur"?"blur":e==="thumbhash"?"thumbhash":"dominant-color",o=await C(n,{strategy:i,width:i==="thumbhash"?void 0:32});if(e==="dominant-color"&&o.dominantColor)return o.dominantColor;if(o.dataURL)return o.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await I.promises.unlink(n).catch(()=>{})}}function Pe(t,e){return(e?t.filter((r)=>r.format===e):t).sort((r,n)=>r.width-n.width).map((r)=>`${r.url} ${r.width}w`).join(", ")}function ut(t){if(!t||Object.keys(t).length===0)return"100vw";return Object.entries(t).sort((a,r)=>{let n=Number.parseInt(a[0].replace(/\D/g,""))||0;return(Number.parseInt(r[0].replace(/\D/g,""))||0)-n}).map(([a,r])=>`(max-width: ${a}) ${r}`).join(", ")+", 100vw"}function Lt(t){let e=t.filter((r)=>r.format==="jpeg");if(e.length===0)return t[Math.floor(t.length/2)];let a=e.sort((r,n)=>r.width-n.width);return a[Math.floor(a.length/2)]}function jt(t){let e=new Map;for(let a of t){let r=e.get(a.format)||[];r.push(a),e.set(a.format,r)}return e}function Bt(t){let e=u.extname(t).toLowerCase();return O.includes(e)}function z(t){return L[t]||"application/octet-stream"}function Ft(t){return t.reduce((e,a)=>e+a.size,0)}function zt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;return`${(t/1048576).toFixed(2)} MB`}class In extends Error{code;constructor(t,e){super(t);this.name="ImageProcessingError",this.code=e}}
|
|
3
|
+
export{j,B,F,Nt,J,se,Pn,aa,Pe,ut,Lt,jt,Bt,z,Ft,zt,In};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{u,ps,li,di,Tc,Rc,Ac,Pc,Ic,Oc,Ue,L,We,Dc,Xn,Mc,gi,Nc,qe,r,Gn,mi,g,ee,Yd}from"./chunk-mh7k2ps4.js";import"./chunk-58jyc7kp.js";import"./chunk-9mjy16pw.js";import"./chunk-299xbyhn.js";import"./chunk-w9srfsfk.js";import"./chunk-6k4f583z.js";import"./chunk-8m3k43d3.js";import"./chunk-7p0zerfj.js";import"./chunk-0ytm2ecf.js";import"./chunk-ba88n1j7.js";import"./chunk-5tyes97j.js";import"./chunk-kpns3659.js";import"./chunk-e6y6s7q8.js";export{ee as clearComponentCache,Nc as componentClientSignalNames,ps as convertToCommonJS,g as createDetailedErrorMessage,Ic as extractDirectiveNames,li as extractScriptFromTemplate,u as extractVariables,r as fileExists,Yd as getComponentCacheStats,Rc as getPositionInfo,L as getSharedTranspiler,mi as getSourceLineInfo,Pc as hasDirectives,di as hasVariables,Mc as isHydrateTrigger,Oc as isJavaScriptScript,qe as renderComponentWithSlot,Gn as resolveTemplatePath,Dc as scopeOnRootElement,Ue as shouldTranspileTypeScript,gi as slotContentHasExpressions,We as transpileTypeScript,Xn as userComponentFileExists,Ac as validateDirective,Tc as validateTemplate};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Io}from"./chunk-
|
|
2
|
+
import{Io}from"./chunk-qtvth7eg.js";import{d}from"./chunk-yn2d8x8m.js";var vd=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -931,7 +931,7 @@ else if (data.type === 'event' && data.method) {
|
|
|
931
931
|
}
|
|
932
932
|
})();
|
|
933
933
|
</script>
|
|
934
|
-
`.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function
|
|
934
|
+
`.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function xd(){return!1}function Sd(e,r={}){let a=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(a,(i,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return ko(t)})}function Co(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let a=ko(r);if(e.includes("</head>"))return e.replace("</head>",`${a}
|
|
935
935
|
</head>`);if(e.includes("<body"))return e.replace(/(<body[^>]*>)/,`$1
|
|
936
936
|
${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(e,r)=>{let a=e.checked?"checked":"",i=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
937
937
|
<input type="checkbox" class="craft-checkbox" ${a} ${i}>
|
|
@@ -1365,7 +1365,7 @@ ${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
</style>
|
|
1368
|
-
`,
|
|
1368
|
+
`,kd=`
|
|
1369
1369
|
<script id="craft-component-runtime">
|
|
1370
1370
|
(function() {
|
|
1371
1371
|
if (window.__stxCraftComponentRuntime) return;
|
|
@@ -2955,7 +2955,7 @@ ${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2955
2955
|
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${h(e.icon)}"${a}></span>`:""}
|
|
2956
2956
|
<span class="craft-sidebar-item-label">${C(e.label)}</span>
|
|
2957
2957
|
${e.badge?`<span class="craft-sidebar-item-badge">${C(e.badge)}</span>`:""}
|
|
2958
|
-
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function K(e){let r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(e){return C(e).replace(/`/g,"`")}function Z(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ee(e,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let n=String(t).replace(/"/g,""");i.push(`${s}="${n}"`)}return i.join(" ")}function
|
|
2958
|
+
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function K(e){let r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(e){return C(e).replace(/`/g,"`")}function Z(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ee(e,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let n=String(t).replace(/"/g,""");i.push(`${s}="${n}"`)}return i.join(" ")}function Cd(e,r){zr[e]=r}function Ed(){return{...zr}}import{existsSync as z,mkdirSync as v,copyFileSync as k,chmodSync as T}from"fs";import{join as o,basename as te}from"path";import{spawn as E,execSync as re}from"child_process";import{tmpdir as M,homedir as q,platform as ae}from"os";async function _o(e){let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||P(),format:e.format||"app",error:`Input file not found: ${e.input}`};let a=e.target||P(),i=e.format||ue(a),s=e.output||o(process.cwd(),"dist","native");if(!z(s))v(s,{recursive:!0});let t=await Io(e.input,{context:e.context,options:{isDev:!1}});if(t=Co(t,{debug:e.verbose}),t=$o(t),!t.includes("craft-component-styles")){if(t.includes("</head>"))t=t.replace("</head>",`${Eo}
|
|
2959
2959
|
</head>`)}let n=e.name||te(e.input,".stx"),c=e.version||"1.0.0",l=e.craftPath||await fe();if(!l)return{success:!1,target:a,format:i,error:"Craft binary not found. Please install Craft or specify craftPath."};if(e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${a}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${l}`);let f;switch(a){case"macos":f=await ie(t,n,c,s,i,e,l);break;case"windows":f=await oe(t,n,c,s,i,e,l);break;case"linux":f=await ce(t,n,c,s,i,e,l);break;case"ios":f=await de(t,n,c,s,e,l);break;case"android":f=await le(t,n,c,s,e,l);break;default:f={success:!1,target:a,format:i,error:`Unsupported target: ${a}`}}return f.duration=Date.now()-r,f}catch(a){return{success:!1,target:e.target||P(),format:e.format||"app",error:a.message,duration:Date.now()-r}}}async function ie(e,r,a,i,s,t,n){let c=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,l=o(i,`${r}.app`),f=o(l,"Contents"),p=o(f,"MacOS"),u=o(f,"Resources");v(p,{recursive:!0}),v(u,{recursive:!0});let x=o(u,"index.html");await Bun.write(x,e);let b="";if(t.sidebar?.enabled&&t.sidebar?.config)b=o(u,"sidebar-config.json"),await Bun.write(b,JSON.stringify(t.sidebar.config));let g=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",m=t.menubarOnly??t.systemTray;if((t.bundleStyle||(await se(n)?"executable":"launcher"))==="executable"){let S=o(p,r);k(n,S),T(S,493);let w={html:"index.html",title:t.window?.title||r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(m)w.menubarOnly=!0;else if(t.systemTray)w.systemTray=!0;if(t.window?.frameless)w.frameless=!0;if(t.window?.transparent)w.transparent=!0;if(t.window?.alwaysOnTop)w.alwaysOnTop=!0;if(t.window?.resizable===!1)w.resizable=!1;await Bun.write(o(u,"craft.json"),`${JSON.stringify(w,null,2)}
|
|
2960
2960
|
`)}else{let S=o(p,"craft");k(n,S),T(S,493);let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",U=`#!/bin/bash
|
|
2961
2961
|
set -euo pipefail
|
|
@@ -3018,5 +3018,5 @@ Exec=${a.toLowerCase()}
|
|
|
3018
3018
|
Terminal=false
|
|
3019
3019
|
Categories=Utility;
|
|
3020
3020
|
Icon=${a.toLowerCase()}
|
|
3021
|
-
`;d("fs").writeFileSync(o(n,`${a.toLowerCase()}.desktop`),b);let g=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(d("fs").writeFileSync(o(n,`${a.toLowerCase()}.png`),g),i.icon&&z(i.icon))k(i.icon,o(n,`${a.toLowerCase()}.png`));let m=E("appimagetool",[n,r],{env:{...process.env,ARCH:"x86_64"}});m.on("close",(y)=>{if(d("fs").rmSync(t,{recursive:!0,force:!0}),y===0)T(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${y}. Install from https://appimage.github.io/appimagetool/`})}),m.on("error",(y)=>{d("fs").rmSync(t,{recursive:!0,force:!0}),s({success:!1,error:`appimagetool not found: ${y.message}`})})}catch(t){s({success:!1,error:t.message})}})}function To(){return[P()]}function Ro(e){switch(e){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var he={buildNative:_o,getAvailableTargets:To,getAvailableFormats:Ro,detectPlatform:P}
|
|
3022
|
-
export{
|
|
3021
|
+
`;d("fs").writeFileSync(o(n,`${a.toLowerCase()}.desktop`),b);let g=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(d("fs").writeFileSync(o(n,`${a.toLowerCase()}.png`),g),i.icon&&z(i.icon))k(i.icon,o(n,`${a.toLowerCase()}.png`));let m=E("appimagetool",[n,r],{env:{...process.env,ARCH:"x86_64"}});m.on("close",(y)=>{if(d("fs").rmSync(t,{recursive:!0,force:!0}),y===0)T(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${y}. Install from https://appimage.github.io/appimagetool/`})}),m.on("error",(y)=>{d("fs").rmSync(t,{recursive:!0,force:!0}),s({success:!1,error:`appimagetool not found: ${y.message}`})})}catch(t){s({success:!1,error:t.message})}})}function To(){return[P()]}function Ro(e){switch(e){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var he={buildNative:_o,getAvailableTargets:To,getAvailableFormats:Ro,detectPlatform:P},$d=he;
|
|
3022
|
+
export{vd,ko,xd,Sd,Co,zr,Eo,kd,$o,Cd,Ed,_o,To,Ro,$d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ll,dl,ul,pl,oa,fl,gl,ml,hl,yl,bl,wl}from"./chunk-yh3p86qa.js";export{bl as Broadcast,wl as BroadcastServer,oa as broadcast,hl as broadcastPresence,ml as broadcastPrivate,yl as channel,ll as getBroadcastServer,pl as loadChannels,dl as startBroadcasting,ul as stopBroadcasting,fl as toUser,gl as toUsers};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ie,Ka,Fo,mt,ht,Td,zo,yt,Qt,Xa,Ga,Ja,Ya,bt,Za}from"./chunk-4625sykb.js";import"./chunk-he404gbh.js";import"./chunk-2hc5mbw8.js";import"./chunk-mh7k2ps4.js";import"./chunk-58jyc7kp.js";import"./chunk-9mjy16pw.js";import"./chunk-299xbyhn.js";import"./chunk-w9srfsfk.js";import"./chunk-6k4f583z.js";import"./chunk-8m3k43d3.js";import"./chunk-7p0zerfj.js";import"./chunk-0ytm2ecf.js";import"./chunk-ba88n1j7.js";import"./chunk-5tyes97j.js";import"./chunk-kpns3659.js";import"./chunk-e6y6s7q8.js";export{Qt as MODULE_SPECIFIER_PREFIX,bt as bundleClientScript,ht as clearBundleFailures,ie as clientBundleDependencies,mt as getBundleFailures,yt as hasUserImports,Ga as normalizeRegistrySpecifiers,Ya as queueClientBundleBuild,Fo as recordBundleFailure,Xa as registryIdForPath,zo as resolveBundlerFallback,Ja as rewriteRegistryImports,Td as setBundlerFallbackMode,Ka as shouldLogBundlerDiagnostics,Za as tempBuildName};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Gd,_c,be,pi,Jd,ms,hs,ys}from"./chunk-mh7k2ps4.js";import"./chunk-58jyc7kp.js";import"./chunk-9mjy16pw.js";import"./chunk-299xbyhn.js";import"./chunk-w9srfsfk.js";import"./chunk-6k4f583z.js";import"./chunk-8m3k43d3.js";import"./chunk-7p0zerfj.js";import"./chunk-0ytm2ecf.js";import"./chunk-ba88n1j7.js";import"./chunk-5tyes97j.js";import"./chunk-kpns3659.js";import"./chunk-e6y6s7q8.js";export{Jd as clearOnceStore,pi as onceStore,be as partialsCache,ms as processIncludes,hs as processStackPushDirectives,ys as processStackReplacements,Gd as resetUnscopedSignalWarnings,_c as topLevelElements};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function Bs(e,t){let a=e.filter((i)=>!b(i.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let i of a){let c=[];for(let l of i.params){let d=i.pattern.includes(`:${l}?`)?"?":"";c.push(`${l}${d}: string`)}let s=c.join("; ");r.push(` '${i.pattern}': { ${s} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
|
|
3
3
|
`),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function Fs(e,t,a){let r=process.cwd(),n=w.relative(r,a),o=e.filter((c)=>!b(c.pattern)),i=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let c of o){let s=w.relative(r,c.filePath).replace(/\\/g,"/"),l=JSON.stringify(c.params),d=c.layout?`, layout: '${w.relative(r,c.layout).replace(/\\/g,"/")}'`:"";i.push(` { pattern: '${c.pattern}', filePath: '${s}', isDynamic: ${c.isDynamic}, params: ${l}${d} },`)}i.push("] as const",""),i.push("export type RouteName = typeof routes[number]['pattern']",""),p.mkdirSync(t,{recursive:!0}),p.writeFileSync(w.join(t,"routes.ts"),i.join(`
|
|
4
|
-
`))}import D from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),I=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),j=new RegExp(`\\.(?:${I})$`),E=`(?![^/]*\\.(?:${I})$)`;function Qe(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&j.test(r)}function R(e,t){let r=D.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(D.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function G(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function xn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function lr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return G(a,t)}import K from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(K.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Sn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=G(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Bs(this.routes,s),Fs(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function dr(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function ur(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Bc(e){k=e.replace(/\/$/,"")}function Fc(e,t,a={}){f[e]={path:t,name:e,params:a}}function zc(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function kn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Hc(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Vc(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Uc(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Wc(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Fi(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function zi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Hi(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function zs(e,t){v.set(e,t)}function Vi(e){return v.get(e)}function qc(e){return v.has(e)}function et(){v.clear()}function tt(){return Array.from(v.keys())}async function nt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")zs(o,s);else if(typeof s==="function")zs(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function W(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function rt(e,t,a,r=""){return{path:e,params:t,query:W(r),fullPath:r?`${e}?${r}`:e,meta:a}}function st(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Fi(a,i):zi(),storage:Hi(),state:{},request:a,responseHeaders:i}}async function ot(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=Vi(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function pr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function ke(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||pr(n)}}var A,T;function V(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
|
|
4
|
+
`))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),j=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function Qe(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&j.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function G(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function xn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function lr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return G(a,t)}import K from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(K.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function B(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...B(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Sn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=B(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=G(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Bs(this.routes,s),Fs(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function dr(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function ur(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Fc(e){k=e.replace(/\/$/,"")}function zc(e,t,a={}){f[e]={path:t,name:e,params:a}}function Hc(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function kn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Vc(){for(let e of Object.keys(f))delete f[e];k=""}import F from"fs";import U from"path";function Uc(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Wc(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function qc(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function zi(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Hi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Vi(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function zs(e,t){v.set(e,t)}function Ui(e){return v.get(e)}function Kc(e){return v.has(e)}function et(){v.clear()}function tt(){return Array.from(v.keys())}async function nt(e,t="middleware"){let a=U.resolve(e,t);if(!F.existsSync(a))return;let r=F.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")zs(o,s);else if(typeof s==="function")zs(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function W(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function rt(e,t,a,r=""){return{path:e,params:t,query:W(r),fullPath:r?`${e}?${r}`:e,meta:a}}function st(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?zi(a,i):Hi(),storage:Vi(),state:{},request:a,responseHeaders:i}}async function ot(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=Ui(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function pr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function ke(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||pr(n)}}var A,T;function z(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
|
|
5
5
|
;(function(){
|
|
6
6
|
'use strict';
|
|
7
7
|
var ROUTER_REV=7;
|
|
8
8
|
if(window.__stxRouter&&window.__stxRouter.__rev===ROUTER_REV)return;
|
|
9
9
|
|
|
10
10
|
// \u2500\u2500 Configuration \u2500\u2500
|
|
11
|
-
var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false,prefetchCacheMax:50,routeFocus:true,announceRoute:true,interceptForms:false,cssLoadTimeout:1500,scrollRestoration:true,screens:'auto',screenLimit:8,navDuration:350,swipeBack:true,swipeEdge:20,prefetchVisible:true,prefetchVisibleMax:12,revalidate:true,revalidateAfter:3000};
|
|
11
|
+
var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false,prefetchCacheMax:50,routeFocus:true,announceRoute:true,interceptForms:false,cssLoadTimeout:1500,scrollRestoration:true,screens:'auto',screenLimit:8,navDuration:350,swipeBack:true,swipeEdge:20,prefetchVisible:true,prefetchVisibleMax:12,revalidate:true,revalidateAfter:3000,keepOpening:true};
|
|
12
12
|
var o=Object.assign({},defaults,window.__stxRouterConfig||{},window.STX_ROUTER_OPTIONS||{});
|
|
13
13
|
var containerSel=o.container;
|
|
14
14
|
var debug=!!o.debug;
|
|
@@ -88,8 +88,14 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
88
88
|
function rememberScroll(){
|
|
89
89
|
if(active&&active.el&&!active.el.hasAttribute(HIDDEN))saveScroll(active);
|
|
90
90
|
if(!restoreScroll)return;
|
|
91
|
+
// The window's position as the swap began, like the scrollers' below.
|
|
92
|
+
// Read now it is wrong: the outgoing page has been replaced by one still
|
|
93
|
+
// filling in, a few hundred pixels tall, and the window has clamped to it
|
|
94
|
+
// -- every entry was filed at 0,0 and Back went to the top.
|
|
95
|
+
var win=winSnap||[window.pageXOffset||window.scrollX||0,window.pageYOffset||window.scrollY||0];
|
|
96
|
+
winSnap=undefined;
|
|
91
97
|
try{
|
|
92
|
-
window.sessionStorage.setItem(SCROLL_STORE+scrollToken,
|
|
98
|
+
window.sessionStorage.setItem(SCROLL_STORE+scrollToken,win[0]+','+win[1]);
|
|
93
99
|
// Taken as the swap began when there is one: by the time the history
|
|
94
100
|
// is written the outgoing page's scrollers have been replaced.
|
|
95
101
|
var inner=innerSnap!==undefined?innerSnap:innerScroll(activeRoot());
|
|
@@ -100,16 +106,76 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
100
106
|
}
|
|
101
107
|
var pendingInner=null;
|
|
102
108
|
var innerSnap;
|
|
109
|
+
var winSnap;
|
|
110
|
+
function snapScroll(){
|
|
111
|
+
innerSnap=innerScroll(activeRoot());
|
|
112
|
+
winSnap=[window.pageXOffset||window.scrollX||0,window.pageYOffset||window.scrollY||0];
|
|
113
|
+
}
|
|
103
114
|
function readInner(token){
|
|
104
115
|
try{return JSON.parse(window.sessionStorage.getItem(SCROLL_STORE+token+':i')||'null')}catch(e){return null}
|
|
105
116
|
}
|
|
106
117
|
// One place decides where a swap leaves the viewport, so the fragment path
|
|
107
118
|
// and the whole-document path cannot drift apart.
|
|
119
|
+
// A page put back by Back is often shorter when it is swapped in than when
|
|
120
|
+
// it was left: its lists are drawn from data that is still on its way (or
|
|
121
|
+
// from a store a moment later), so scrollTo clamps to the little there is
|
|
122
|
+
// and the place is lost -- Back always landed at the top of a long page.
|
|
123
|
+
// For a moment after, hold the position: try again each time the page
|
|
124
|
+
// changes size. The person scrolling, a key, a tap, the page scrolling
|
|
125
|
+
// itself, the next navigation or four seconds (a page whose data is slow
|
|
126
|
+
// to come) end the hold.
|
|
127
|
+
var scrollHold=null;
|
|
128
|
+
var HOLD_ENDERS=['wheel','touchstart','keydown','pointerdown'];
|
|
129
|
+
function releaseScrollHold(){
|
|
130
|
+
if(!scrollHold)return;
|
|
131
|
+
var h=scrollHold;scrollHold=null;
|
|
132
|
+
if(h.ro)h.ro.disconnect();
|
|
133
|
+
clearTimeout(h.timer);
|
|
134
|
+
// The window and root the hold was made on: by the time its timer fires
|
|
135
|
+
// the document may be another one.
|
|
136
|
+
if(h.onScroll)h.win.removeEventListener('scroll',h.onScroll);
|
|
137
|
+
if(h.anchor!==null&&h.root)h.root.style.overflowAnchor=h.anchor;
|
|
138
|
+
HOLD_ENDERS.forEach(function(n){h.win.removeEventListener(n,h.stop,true)});
|
|
139
|
+
}
|
|
140
|
+
function holdScroll(x,y){
|
|
141
|
+
releaseScrollHold();
|
|
142
|
+
var reached=function(){return Math.abs((window.pageYOffset||window.scrollY||0)-y)<2};
|
|
143
|
+
if(typeof ResizeObserver!=='function')return;
|
|
144
|
+
var h={stop:releaseScrollHold,ro:null,timer:0,onScroll:null,anchor:null,win:window,root:document.documentElement};
|
|
145
|
+
// Scroll anchoring off while held: content filling in above the place
|
|
146
|
+
// would otherwise carry the window down with it (Chrome keeps what is
|
|
147
|
+
// on screen in view), and Back landed thousands of pixels past it.
|
|
148
|
+
var rootStyle=document.documentElement&&document.documentElement.style;
|
|
149
|
+
if(rootStyle){h.anchor=rootStyle.overflowAnchor||'';rootStyle.overflowAnchor='none'}
|
|
150
|
+
h.ro=new ResizeObserver(function(){
|
|
151
|
+
// Held for the whole window even once reached: a page that is tall
|
|
152
|
+
// enough when it is put back is often still drawing, above the place
|
|
153
|
+
// as much as below it.
|
|
154
|
+
if(scrollHold!==h||reached())return;
|
|
155
|
+
window.scrollTo({left:x,top:y,behavior:'instant'});
|
|
156
|
+
});
|
|
157
|
+
h.ro.observe(document.body||document.documentElement);
|
|
158
|
+
h.timer=setTimeout(releaseScrollHold,4000);
|
|
159
|
+
HOLD_ENDERS.forEach(function(n){window.addEventListener(n,h.stop,{capture:true,passive:true})});
|
|
160
|
+
// Moved by something else (a scrollbar dragged, the page scrolling to
|
|
161
|
+
// what it wants to show): theirs wins. Only the clamp to a page still
|
|
162
|
+
// too short, at its very end, is the hold's own business.
|
|
163
|
+
h.onScroll=function(){
|
|
164
|
+
var at=window.pageYOffset||window.scrollY||0;
|
|
165
|
+
var end=Math.max(0,(document.documentElement.scrollHeight||0)-(window.innerHeight||0));
|
|
166
|
+
if(Math.abs(at-y)<2||(at<y&&at>=end-1))return;
|
|
167
|
+
releaseScrollHold();
|
|
168
|
+
};
|
|
169
|
+
window.addEventListener('scroll',h.onScroll,{passive:true});
|
|
170
|
+
scrollHold=h;
|
|
171
|
+
}
|
|
108
172
|
function applyScroll(hash){
|
|
173
|
+
releaseScrollHold();
|
|
109
174
|
if(pendingScroll){
|
|
110
175
|
var at=pendingScroll;
|
|
111
176
|
pendingScroll=null;
|
|
112
177
|
window.scrollTo({left:at[0],top:at[1],behavior:'instant'});
|
|
178
|
+
holdScroll(at[0],at[1]);
|
|
113
179
|
// Again once the page has bound: a scroller's content is often drawn
|
|
114
180
|
// by a :for that has not run yet, and a box with nothing in it cannot
|
|
115
181
|
// be scrolled anywhere.
|
|
@@ -138,7 +204,7 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
138
204
|
if(known){
|
|
139
205
|
var saved=readScroll(scrollToken);
|
|
140
206
|
if(saved&&(saved[0]||saved[1])){
|
|
141
|
-
var restoreAt=function(){window.scrollTo({left:saved[0],top:saved[1],behavior:'instant'})};
|
|
207
|
+
var restoreAt=function(){window.scrollTo({left:saved[0],top:saved[1],behavior:'instant'});holdScroll(saved[0],saved[1])};
|
|
142
208
|
if(document.readyState==='complete')restoreAt();
|
|
143
209
|
else window.addEventListener('load',restoreAt,{once:true});
|
|
144
210
|
}
|
|
@@ -341,8 +407,9 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
341
407
|
var progDelay=null;
|
|
342
408
|
function startProgress(){
|
|
343
409
|
if(!o.progress||!progEl)return;
|
|
344
|
-
|
|
345
|
-
|
|
410
|
+
// Already counting for this tap (it waited on a prefetch, then went on
|
|
411
|
+
// to swap): keep the bar where it is rather than start it again.
|
|
412
|
+
if(progTimer||progDelay)return;
|
|
346
413
|
progDelay=setTimeout(function(){
|
|
347
414
|
progDelay=null;
|
|
348
415
|
setProgress(8);
|
|
@@ -1045,6 +1112,8 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1045
1112
|
return fetch(url,init);
|
|
1046
1113
|
}
|
|
1047
1114
|
function navigate(url,pushState,force){
|
|
1115
|
+
releaseScrollHold();
|
|
1116
|
+
winSnap=undefined;
|
|
1048
1117
|
var ctx=navCtxNext||{};
|
|
1049
1118
|
navCtxNext=null;
|
|
1050
1119
|
if(pushState&&typeof pushState==='object'){if(pushState.instant)instantNext=true;pushState=pushState.replace?'replace':true}
|
|
@@ -1081,6 +1150,14 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1081
1150
|
var awaitedKey=cacheKey(url);
|
|
1082
1151
|
if(o.cache&&!force&&!cache[awaitedKey]&&prefetching[awaitedKey]&&prefetching[awaitedKey].then){
|
|
1083
1152
|
awaitingKey=awaitedKey;
|
|
1153
|
+
// Answer the tap now, not when the prefetch lands. The page it asked
|
|
1154
|
+
// for is on the way, but until then nothing on screen said so: no
|
|
1155
|
+
// loading class, no progress bar. On a server a second or two away
|
|
1156
|
+
// (the hover started the fetch a moment before the click) a link read
|
|
1157
|
+
// as dead, and was clicked again, and again (hq.training's Calendar).
|
|
1158
|
+
// The navigation this hands over to keeps both going and ends them.
|
|
1159
|
+
document.body.classList.add(o.loadingClass);
|
|
1160
|
+
startProgress();
|
|
1084
1161
|
return prefetching[awaitedKey].then(function(){
|
|
1085
1162
|
if(awaitingKey!==awaitedKey)return false;
|
|
1086
1163
|
awaitingKey='';
|
|
@@ -1140,9 +1217,15 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1140
1217
|
return swapWith(html,targetPath);
|
|
1141
1218
|
}).catch(failed).finally(done);
|
|
1142
1219
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1220
|
+
var cached=cache[targetPath];
|
|
1221
|
+
var swapCached=function(){
|
|
1222
|
+
if(stale())return false;
|
|
1223
|
+
pendingContainerAttrs=attrsCache[targetPath]||'';
|
|
1224
|
+
pendingLayoutDecl=null;
|
|
1225
|
+
return swapWith(cached,targetPath);
|
|
1226
|
+
};
|
|
1227
|
+
var loading=beforeSwap(cached,url);
|
|
1228
|
+
return (loading?loading.then(function(ok){if(!ok){if(!stale())recoverUnbound(url,ctx);return false}return swapCached()}):Promise.resolve(swapCached())).then(function(swapped){
|
|
1146
1229
|
if(swapped===false)return false;
|
|
1147
1230
|
applyTitle(titleCache[targetPath]);
|
|
1148
1231
|
// Shown from the cache at once; asked again behind it, so a page that
|
|
@@ -1206,6 +1289,14 @@ else {
|
|
|
1206
1289
|
if(!result||stale())return false;
|
|
1207
1290
|
if(result.isFragment)result.html=fragmentMarker(result.runtime)+result.html;
|
|
1208
1291
|
if(o.cache)setCache(targetPath,result.html,result.layout,result.layoutGroup,result.title,result.containerAttrs);
|
|
1292
|
+
var loading=beforeSwap(result.html,url);
|
|
1293
|
+
return loading?loading.then(function(ok){
|
|
1294
|
+
if(ok||stale())return result;
|
|
1295
|
+
recoverUnbound(url,ctx);
|
|
1296
|
+
return null;
|
|
1297
|
+
}):result;
|
|
1298
|
+
}).then(function(result){
|
|
1299
|
+
if(!result||stale())return false;
|
|
1209
1300
|
pendingContainerAttrs=result.isFragment?(result.containerAttrs||''):'';
|
|
1210
1301
|
pendingLayoutDecl=result.isFragment?null:{layout:result.layout||'',group:result.layoutGroup||''};
|
|
1211
1302
|
return Promise.resolve(swapWith(result.html,targetPath)).then(function(swapped){
|
|
@@ -1738,7 +1829,7 @@ else {
|
|
|
1738
1829
|
var useScreens=screensOn();
|
|
1739
1830
|
function startFragSwap(){
|
|
1740
1831
|
if(ctx.id&&ctx.id!==navSeq)return Promise.resolve(false);
|
|
1741
|
-
if(pushState!==false)
|
|
1832
|
+
if(pushState!==false)snapScroll();
|
|
1742
1833
|
if(useScreens)settleAnimation();
|
|
1743
1834
|
else if(window.stx&&window.stx._cleanupContainer)window.stx._cleanupContainer(currentContent);
|
|
1744
1835
|
return new Promise(function(resolve,reject){
|
|
@@ -2207,7 +2298,7 @@ else {
|
|
|
2207
2298
|
|
|
2208
2299
|
function startSwap(){
|
|
2209
2300
|
if(ctx.id&&ctx.id!==navSeq)return Promise.resolve(false);
|
|
2210
|
-
if(pushState!==false)
|
|
2301
|
+
if(pushState!==false)snapScroll();
|
|
2211
2302
|
setDirection(ctx.direction);
|
|
2212
2303
|
// A whole document is written into the container as it is, so retained
|
|
2213
2304
|
// screens go first: they would otherwise outlive the page they belong to.
|
|
@@ -2980,7 +3071,7 @@ else {
|
|
|
2980
3071
|
sightObserver.unobserve(en.target);
|
|
2981
3072
|
if(sightCount>=o.prefetchVisibleMax)return;
|
|
2982
3073
|
sightCount++;
|
|
2983
|
-
prefetchLink(en.target);
|
|
3074
|
+
prefetchLink(en.target,false,true);
|
|
2984
3075
|
});
|
|
2985
3076
|
});
|
|
2986
3077
|
sightCount=0;
|
|
@@ -3293,14 +3384,24 @@ else {
|
|
|
3293
3384
|
// prefetch has finished waits for that answer instead of asking again.
|
|
3294
3385
|
// 'fresh' refetches a page that is cached, for an entry restored from an
|
|
3295
3386
|
// earlier launch that is shown at once and replaced behind it.
|
|
3296
|
-
|
|
3387
|
+
// 'glance' is a link that merely came into view (prefetchVisible): its
|
|
3388
|
+
// page is fetched, but its module bundles are left for an intent (a hover,
|
|
3389
|
+
// a touch) or the tap itself, which waits for them (beforeSwap). Each page
|
|
3390
|
+
// links bundles of its own, hq.training's ~4.7MB of script apiece, and a
|
|
3391
|
+
// screen with a dozen links in view used to download and evaluate every
|
|
3392
|
+
// one of them on arrival, competing with the page being read.
|
|
3393
|
+
function prefetchLink(link,fresh,glance){
|
|
3297
3394
|
// Same opt-out set as the click path. Without it, hovering a link the
|
|
3298
3395
|
// router is not allowed to claim still fired a real GET at it \u2014 a
|
|
3299
3396
|
// logout or OAuth URL was requested on hover alone.
|
|
3300
3397
|
if(isRouterExcluded(link))return;
|
|
3301
3398
|
var href=withCurrentLocale(link.getAttribute('href'));
|
|
3302
3399
|
var key=cacheKey(href);
|
|
3303
|
-
if(
|
|
3400
|
+
if(cache[key]&&!fresh){if(!glance)loadModuleRegistries(cache[key],href);return}
|
|
3401
|
+
if(prefetching[key]){
|
|
3402
|
+
if(!glance)prefetching[key].then(function(){if(cache[key])loadModuleRegistries(cache[key],href)});
|
|
3403
|
+
return;
|
|
3404
|
+
}
|
|
3304
3405
|
var eager=link.getAttribute('data-stx-prefetch')==='eager';
|
|
3305
3406
|
var wantsFragment=shouldUseFragmentResponse();
|
|
3306
3407
|
prefetching[key]=fetch(href,{headers:wantsFragment?{'X-STX-Router':'true','Accept':'text/html'}:{'Accept':'text/html'}}).then(function(r){
|
|
@@ -3311,7 +3412,7 @@ else {
|
|
|
3311
3412
|
if(eager)keepPage(key,result);
|
|
3312
3413
|
}
|
|
3313
3414
|
if(result){
|
|
3314
|
-
loadModuleRegistries(result.html,href);
|
|
3415
|
+
if(!glance)loadModuleRegistries(result.html,href);
|
|
3315
3416
|
// Its stylesheet too, so the tap never waits on cssLoadTimeout for a
|
|
3316
3417
|
// sheet it could have had all along. Added unapplied (media=print),
|
|
3317
3418
|
// as a navigation adds it; the swap makes it live.
|
|
@@ -3364,14 +3465,41 @@ else {
|
|
|
3364
3465
|
// registers modules, once, so loading it early changes nothing but timing,
|
|
3365
3466
|
// and the tap then finds every script it needs already here: the swap runs
|
|
3366
3467
|
// in one task and the first visit to a tab paints whole, like the second.
|
|
3468
|
+
//
|
|
3469
|
+
// The composables bundle too (also stx's own /_stx/modules.<hash>.js): it
|
|
3470
|
+
// only registers what is not registered yet. Answers a promise for the
|
|
3471
|
+
// files still on their way, or null when there are none.
|
|
3367
3472
|
function loadModuleRegistries(html,base){
|
|
3473
|
+
var waits=[];
|
|
3368
3474
|
html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>','gi'),function(m,attrs){
|
|
3369
|
-
if(!/(?:^|\\s)data-stx-modules(?:[\\s=]|$)/i.test(attrs))return m;
|
|
3370
3475
|
var srcMatch=attrs.match(/\\bsrc\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))/i);
|
|
3371
3476
|
var src=srcMatch&&(srcMatch[1]||srcMatch[2]||srcMatch[3]);
|
|
3372
|
-
if(src)
|
|
3477
|
+
if(!src)return m;
|
|
3478
|
+
if(!/(?:^|\\s)data-stx-modules(?:[\\s=]|$)/i.test(attrs)&&!isModuleBundle(src))return m;
|
|
3479
|
+
var pending=loadExternalScript(src,base);
|
|
3480
|
+
if(pending)waits.push(pending);
|
|
3373
3481
|
return m;
|
|
3374
3482
|
});
|
|
3483
|
+
return waits.length?Promise.all(waits):null;
|
|
3484
|
+
}
|
|
3485
|
+
// A page swapped in before its module bundles have loaded is drawn bare
|
|
3486
|
+
// (everything behind :if and x-cloak) and bound a network round trip
|
|
3487
|
+
// later: the main area went blank for a moment on every page the router
|
|
3488
|
+
// had not prefetched -- Back to the page the app opened on, a link it never
|
|
3489
|
+
// hovered. Waiting for them first keeps the outgoing page up, under the
|
|
3490
|
+
// progress bar, and lets the swap, its scripts and the first paint happen
|
|
3491
|
+
// in one task. Capped, so a bundle that hangs costs a delay, not the page.
|
|
3492
|
+
// Null when there is nothing to wait for, so a cached page still swaps in
|
|
3493
|
+
// the task of the tap that asked for it.
|
|
3494
|
+
// Answers false when a bundle failed: that page cannot bind, and is
|
|
3495
|
+
// recovered (recoverUnbound) rather than swapped in bare.
|
|
3496
|
+
function beforeSwap(html,base){
|
|
3497
|
+
var waits=loadModuleRegistries(html,base);
|
|
3498
|
+
if(!waits)return null;
|
|
3499
|
+
return Promise.race([
|
|
3500
|
+
waits.then(function(results){return results.indexOf(false)===-1}),
|
|
3501
|
+
new Promise(function(resolve){setTimeout(function(){resolve(true)},4000)}),
|
|
3502
|
+
]);
|
|
3375
3503
|
}
|
|
3376
3504
|
|
|
3377
3505
|
// Links marked data-stx-prefetch="eager", fetched once the page is idle, so
|
|
@@ -3402,6 +3530,25 @@ else {
|
|
|
3402
3530
|
else setTimeout(run,100);
|
|
3403
3531
|
}
|
|
3404
3532
|
|
|
3533
|
+
// The page the app was opened on came as a whole document, so it is the
|
|
3534
|
+
// one page the cache never holds: Back to it went to the server and left
|
|
3535
|
+
// the page being read on screen under the new address until it answered
|
|
3536
|
+
// (a second or more on a distant server). Once the page is idle its
|
|
3537
|
+
// fragment is fetched, the same request a link to it would make, so Back
|
|
3538
|
+
// is a swap like every other.
|
|
3539
|
+
function keepOpeningPage(){
|
|
3540
|
+
if(!o.cache||!shouldUseFragmentResponse())return;
|
|
3541
|
+
var c=navigator.connection;
|
|
3542
|
+
if(c&&(c.saveData||/2g/.test(c.effectiveType||'')))return;
|
|
3543
|
+
var url=location.pathname+location.search;
|
|
3544
|
+
var key=cacheKey(url);
|
|
3545
|
+
// Late by design, so it can find the page gone (a test's document torn
|
|
3546
|
+
// down, a full navigation begun): never let that throw from a timer.
|
|
3547
|
+
var run=function(){try{if(!cache[key]&&!prefetching[key])revalidate(key,url)}catch(e){}};
|
|
3548
|
+
if(window.requestIdleCallback)window.requestIdleCallback(run,{timeout:3000});
|
|
3549
|
+
else setTimeout(run,1500);
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3405
3552
|
if(o.prefetch){
|
|
3406
3553
|
// A mouse hovers before it clicks. A finger does not hover, but it
|
|
3407
3554
|
// touches down a tap's length before the click: start the fetch there.
|
|
@@ -3689,8 +3836,10 @@ else {
|
|
|
3689
3836
|
restoreKeptPages();
|
|
3690
3837
|
prefetchEager();
|
|
3691
3838
|
observeLinks();
|
|
3839
|
+
// The runtime's first stx:load has usually gone by when this runs.
|
|
3840
|
+
if(o.prefetch&&o.keepOpening!==false)keepOpeningPage();
|
|
3692
3841
|
}
|
|
3693
3842
|
|
|
3694
3843
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
3695
3844
|
})();
|
|
3696
|
-
`}function Ce(){if(A)return A;return A=q(
|
|
3845
|
+
`}function Ce(){if(A)return A;return A=q(z(X()),!0),A}function Xc(){if(T)return T;return T=q(X()),T}export{Bs,Fs,Qe,G,xn,lr,Sn,dr,ur,Fc,zc,Hc,kn,Vc,Uc,Wc,qc,zi,Hi,Vi,zs,Ui,Kc,et,tt,nt,rt,st,ot,pr,ke,Ce,Xc};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p,l}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{p,l}from"./chunk-0ytm2ecf.js";import{b}from"./chunk-mh7k2ps4.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=x(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let c=i.lastIndexOf(u);if(c!==-1)i.splice(c);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let c=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),h=g||w.has(u)?-1:N(t,u,s);if(h===-1)o.push({start:n,end:s,slotName:c,element:m}),e=s;else o.push({start:n,end:h,slotName:c,element:m+t.slice(s,h)}),e=h;continue}if(!g&&!w.has(u)){if(i.push(u),u==="script"||u==="style"){let c=t.toLowerCase().indexOf(`</${u}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let c=i.lastIndexOf(g);if(c!==-1)i.splice(c);e=s;continue}if(g==="template"&&i.length===0){let c=a.match(r);if(c){let m=y(t,s);if(m!==-1){let h=c[1]||c[2]||c[3];o.push({start:n,end:m,slotName:h,content:t.slice(s,m-11).trim(),propsBinding:c[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!w.has(g)){if(i.push(g),g==="script"||g==="style"){let c=t.toLowerCase().indexOf(`</${g}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function ca(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Sl(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function la(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((c)=>c.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return b(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return l(t,Object.keys(o))(...Object.values(o))}catch{return}}async function da(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",c=f||"",m={},h=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,S;while((S=h.exec(c))!==null){let E=S[1],R=S[2];m[E]=k(R,i)}return await la(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function kl(t){let o=ca(t);return{defaultSlot:o.default,namedSlots:o.named}}async function Cl(t,o,i,r){return await da(t,{default:o,named:i},r)}
|
|
3
|
+
export{ca,Sl,la,da,kl,Cl};
|