@stacksjs/stx 0.2.337 → 0.2.339
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/app-shell.js +9 -8
- package/dist/caching.d.ts +1 -18
- package/dist/caching.js +2 -21
- package/dist/{chunk-97yd8erh.js → chunk-066yt1hy.js} +1 -1
- package/dist/chunk-09fb200s.js +2 -0
- package/dist/chunk-0b3cqgyr.js +2 -0
- package/dist/chunk-0tky87hx.js +2 -0
- package/dist/{chunk-dwjcmxez.js → chunk-0xgc5t3y.js} +1 -1
- package/dist/{chunk-v5d0xj8c.js → chunk-156j37tv.js} +3 -3
- package/dist/{chunk-3g2j4eh8.js → chunk-191bg6nt.js} +1 -1
- package/dist/{chunk-w52p79xs.js → chunk-1q6xc3m2.js} +1 -1
- package/dist/{chunk-apsmgvrk.js → chunk-22hch2me.js} +1 -1
- package/dist/{chunk-9btdax2s.js → chunk-28q3vycz.js} +1 -1
- package/dist/{chunk-dfymexrx.js → chunk-2gc4cevb.js} +1 -1
- package/dist/{chunk-tp6wkx7g.js → chunk-2tjk867y.js} +1 -1
- package/dist/chunk-408rnn07.js +2 -0
- package/dist/chunk-48d9ey9k.js +2 -0
- package/dist/chunk-58j32d7n.js +2 -0
- package/dist/{chunk-5ep11kvc.js → chunk-5g6rprcy.js} +1 -1
- package/dist/{chunk-er3adkx7.js → chunk-5qsg9q46.js} +1 -1
- package/dist/chunk-63h3pg9g.js +2 -0
- package/dist/{chunk-jyq43tp9.js → chunk-63xv0h5e.js} +1 -1
- package/dist/{chunk-7rf71ecp.js → chunk-64qg8jes.js} +2 -2
- package/dist/chunk-6av24ywm.js +2 -0
- package/dist/{chunk-as5j2s4h.js → chunk-6n1qbh78.js} +1 -1
- package/dist/chunk-6qe53wjc.js +2 -0
- package/dist/chunk-7157az6e.js +2 -0
- package/dist/{chunk-akdryjck.js → chunk-799s9mwc.js} +2 -2
- package/dist/{chunk-g3cyygvf.js → chunk-7a21q2q4.js} +1 -1
- package/dist/chunk-7qawmh8w.js +30 -0
- package/dist/{chunk-x5y9r3f2.js → chunk-7r79j1hs.js} +1 -1
- package/dist/{chunk-yjkaqxtc.js → chunk-7r80apc5.js} +1 -1
- package/dist/{chunk-vjp1sg5y.js → chunk-86v2rps7.js} +1 -1
- package/dist/{chunk-fckan25d.js → chunk-97ej3abh.js} +1 -1
- package/dist/{chunk-w3d5xrdy.js → chunk-a26hcag1.js} +1 -1
- package/dist/chunk-a2nsmczq.js +2 -0
- package/dist/chunk-ar0fcmpj.js +2 -0
- package/dist/{chunk-5sqbd646.js → chunk-aved735s.js} +2 -2
- package/dist/{chunk-f6sejeg3.js → chunk-axqfm9b4.js} +1 -1
- package/dist/{chunk-9kb0qv47.js → chunk-ay336sqb.js} +1 -1
- package/dist/{chunk-vcdt10ke.js → chunk-az4mq459.js} +1 -1
- package/dist/chunk-azhpwmty.js +2 -0
- package/dist/chunk-b3pn6dh5.js +2 -0
- package/dist/{chunk-gwrrs1qh.js → chunk-b4cabzk9.js} +1 -1
- package/dist/{chunk-1ybanbh4.js → chunk-c3xmcsvd.js} +10 -10
- package/dist/chunk-ca6t6nnn.js +2 -0
- package/dist/{chunk-64kky38b.js → chunk-chkbvqq2.js} +3 -3
- package/dist/{chunk-hv8j33px.js → chunk-d3kjaae0.js} +1 -1
- package/dist/{chunk-s9hsxhb5.js → chunk-d6yyzpsv.js} +174 -72
- package/dist/chunk-d72ps148.js +2 -0
- package/dist/{chunk-bafd6h7t.js → chunk-d7zxg9bp.js} +2 -2
- package/dist/{chunk-3n9rvrk1.js → chunk-dekxwgc2.js} +1 -1
- package/dist/{chunk-tjhzxbxa.js → chunk-deqnt1w5.js} +1 -1
- package/dist/chunk-e0r2hndd.js +2 -0
- package/dist/{chunk-bkwg5cgq.js → chunk-e2emz8yb.js} +1 -1
- package/dist/chunk-e4sgv8p0.js +2 -0
- package/dist/chunk-eb1v7f55.js +2 -0
- package/dist/{chunk-f5wernak.js → chunk-eq2j7w8p.js} +1 -1
- package/dist/chunk-evk1dzpg.js +2 -0
- package/dist/{chunk-8wqz2s4j.js → chunk-fa2mg49t.js} +2 -2
- package/dist/chunk-fx5m9d3t.js +2 -0
- package/dist/{chunk-yrj8gad9.js → chunk-gz6mszbx.js} +2 -2
- package/dist/{chunk-evmc7vhg.js → chunk-h0y4mb2m.js} +1 -1
- package/dist/{chunk-psazw7p1.js → chunk-hrdd26r4.js} +1 -1
- package/dist/chunk-jwa2jhd8.js +2 -0
- package/dist/{chunk-peqad61h.js → chunk-jx03a693.js} +1 -1
- package/dist/{chunk-pt4xht7s.js → chunk-k3dtvay1.js} +1 -1
- package/dist/{chunk-xgj1jw4p.js → chunk-kdhrk7x5.js} +1 -1
- package/dist/{chunk-xt7bsyj7.js → chunk-m11pb9cx.js} +1 -1
- package/dist/{chunk-p4bmz9x3.js → chunk-m46edxtt.js} +1 -1
- package/dist/chunk-mjf3xmxn.js +3 -0
- package/dist/chunk-mpbbfrpk.js +2 -0
- package/dist/{chunk-459qxwp1.js → chunk-mys0rat0.js} +1 -1
- package/dist/{chunk-evakht2n.js → chunk-n6eetz4r.js} +2 -2
- package/dist/{chunk-wx3kf6tm.js → chunk-nvp546bb.js} +1 -1
- package/dist/chunk-nwz43t6d.js +2 -0
- package/dist/chunk-p1cddybx.js +2 -0
- package/dist/chunk-pqtype7s.js +2 -0
- package/dist/{chunk-nzbdgx7d.js → chunk-pswhshrp.js} +3 -3
- package/dist/chunk-pvtnhx3j.js +2 -0
- package/dist/{chunk-c21x8w2q.js → chunk-q0srntf6.js} +1 -1
- package/dist/chunk-q1xcd8jg.js +3 -0
- package/dist/{chunk-rb69qb49.js → chunk-q9ckfwhh.js} +1 -1
- package/dist/{chunk-wxpwt67g.js → chunk-qtc28zy1.js} +1 -1
- package/dist/{chunk-6ex0t14b.js → chunk-r10fypcd.js} +1 -1
- package/dist/{chunk-b1w30x36.js → chunk-rkykwy3z.js} +1 -1
- package/dist/{chunk-3nv5h7jd.js → chunk-rzayq0ht.js} +1 -1
- package/dist/{chunk-zp5z8qwy.js → chunk-sntjqyqq.js} +1 -1
- package/dist/{chunk-09xhvt5p.js → chunk-stbns4bg.js} +1 -1
- package/dist/{chunk-tf3b833n.js → chunk-t00ga194.js} +1 -1
- package/dist/{chunk-557n2zx7.js → chunk-t8ctvjqe.js} +1 -1
- package/dist/{chunk-58jwsgr1.js → chunk-tr1174hz.js} +1 -1
- package/dist/{chunk-3k4wcezp.js → chunk-tr41gn5j.js} +1 -1
- package/dist/{chunk-wmgpb6b6.js → chunk-tr9ynxdw.js} +1 -1
- package/dist/{chunk-3405q9eb.js → chunk-tsmdmf5h.js} +1 -1
- package/dist/{chunk-b9w95df7.js → chunk-tvc2xwen.js} +1 -1
- package/dist/{chunk-at9knbt1.js → chunk-tzywy1s7.js} +1 -1
- package/dist/{chunk-sy44sx1e.js → chunk-vafj091j.js} +79 -79
- package/dist/{chunk-jc3t5y1y.js → chunk-vaggjvsm.js} +1 -1
- package/dist/chunk-vhzc08aa.js +2 -0
- package/dist/{chunk-qcf4506g.js → chunk-vxt5c5aq.js} +1 -1
- package/dist/{chunk-when7sgs.js → chunk-w72v0ab1.js} +1 -1
- package/dist/{chunk-qnx0eb8x.js → chunk-wb90259a.js} +1 -1
- package/dist/{chunk-3ys2esa2.js → chunk-wdq75f5k.js} +1 -1
- package/dist/chunk-wdvee4kr.js +17 -0
- package/dist/chunk-wqyfz0y6.js +2 -0
- package/dist/chunk-wwzzyqcg.js +2 -0
- package/dist/chunk-x2pzekhq.js +2 -0
- package/dist/{chunk-meqcxfpr.js → chunk-x48crnwa.js} +1 -1
- package/dist/{chunk-t77fg77q.js → chunk-x4vhn880.js} +1 -1
- package/dist/{chunk-zyb5gfr0.js → chunk-xe6zmdfq.js} +1 -1
- package/dist/{chunk-0dz59qg5.js → chunk-xhznr05n.js} +2 -2
- package/dist/chunk-xnpdkd13.js +2 -0
- package/dist/{chunk-jkyvk4x6.js → chunk-xy4jt4ek.js} +1 -1
- package/dist/{chunk-m93qtfxw.js → chunk-y8vj3rtt.js} +1 -1
- package/dist/{chunk-t2h8prxq.js → chunk-yne23w3c.js} +1 -1
- package/dist/{chunk-eeg62zy4.js → chunk-zfz3s2gd.js} +2 -2
- package/dist/{chunk-wv9v9mj9.js → chunk-zj039s33.js} +1 -1
- package/dist/{chunk-gy9a83n9.js → chunk-zm8b6e9n.js} +1 -1
- package/dist/chunk-zqtrg15a.js +2 -0
- package/dist/chunk-zzfpwxpp.js +2 -0
- package/dist/cli.js +14 -14
- package/dist/client-script-bundler.js +10 -8
- package/dist/config.js +1 -0
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/engine-fingerprint.d.ts +17 -0
- package/dist/engine-fingerprint.js +23 -0
- package/dist/pwa.js +2 -2
- package/dist/runtime-injection.js +2 -0
- package/dist/ssg.js +2 -2
- package/dist/types/config-types.d.ts +8 -0
- package/dist/variable-extractor.d.ts +1 -0
- package/dist/variable-extractor.js +8 -0
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-06qm6p8r.js +0 -2
- package/dist/chunk-0e8x9jkb.js +0 -2
- package/dist/chunk-0tc5p1ty.js +0 -2
- package/dist/chunk-1xqe92jv.js +0 -2
- package/dist/chunk-1ybaz0a1.js +0 -2
- package/dist/chunk-20e4pcq1.js +0 -2
- package/dist/chunk-2wn5db49.js +0 -2
- package/dist/chunk-3376d979.js +0 -2
- package/dist/chunk-42tgak9b.js +0 -2
- package/dist/chunk-45bmthfs.js +0 -2
- package/dist/chunk-4bcax4rv.js +0 -2
- package/dist/chunk-623b1j9c.js +0 -2
- package/dist/chunk-6ym84983.js +0 -30
- package/dist/chunk-96q01emr.js +0 -2
- package/dist/chunk-994aga02.js +0 -3
- package/dist/chunk-btqmqzay.js +0 -2
- package/dist/chunk-bv65tr40.js +0 -2
- package/dist/chunk-ch06z00p.js +0 -2
- package/dist/chunk-cs9w9kwy.js +0 -2
- package/dist/chunk-czh7agd6.js +0 -2
- package/dist/chunk-gab2hnk7.js +0 -2
- package/dist/chunk-h3w1y4q7.js +0 -2
- package/dist/chunk-hphhqwn5.js +0 -2
- package/dist/chunk-j3b8cnss.js +0 -17
- package/dist/chunk-jv70d481.js +0 -2
- package/dist/chunk-jxqf4y2y.js +0 -2
- package/dist/chunk-k14sz6cz.js +0 -2
- package/dist/chunk-mppr5jht.js +0 -2
- package/dist/chunk-pp2ssem6.js +0 -2
- package/dist/chunk-sfaj3res.js +0 -2
- package/dist/chunk-tbynnx22.js +0 -2
- package/dist/chunk-tgsj4g9k.js +0 -2
- package/dist/chunk-thfpfk45.js +0 -2
- package/dist/chunk-wj8sx4fx.js +0 -2
- package/dist/chunk-wnnv5d1t.js +0 -2
- package/dist/chunk-xzhvnk8r.js +0 -2
- package/dist/chunk-y97yx6ap.js +0 -2
|
@@ -1,19 +1,108 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`),
|
|
4
|
-
`))}var
|
|
2
|
+
import{rw as v$,sw as G}from"./chunk-5g6rprcy.js";function y($){return $.split(/[\\/]/).filter(Boolean).slice(0,-1).some((O)=>F.includes(O))}function A($){return y($.replace(/^\//,""))}var F;var C=G(()=>{F=["components","layouts","partials","emails"]});import W from"fs";import E from"path";function H($,U){let O=$.filter((K)=>!A(K.pattern)),I=["// Auto-generated by STX - do not edit"];if(O.length===0)I.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{I.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let K of O){let V=[];for(let X of K.params){let Y=K.pattern.includes(`:${X}?`)?"?":"";V.push(`${X}${Y}: string`)}let J=V.join("; ");I.push(` '${K.pattern}': { ${J} }`)}I.push(" }","}","","export {}","")}let B=I.join(`
|
|
3
|
+
`),L=E.join(U,"route-types.d.ts");try{if(W.existsSync(L)&&W.readFileSync(L,"utf8")===B)return;W.mkdirSync(U,{recursive:!0}),W.writeFileSync(L,B)}catch{}}function q($,U,O){let I=process.cwd(),B=E.relative(I,O),L=$.filter((V)=>!A(V.pattern)),K=["// Auto-generated by stx \u2014 do not edit",`// Source: ${B||"pages"}/`,"","export const routes = ["];for(let V of L){let J=E.relative(I,V.filePath).replace(/\\/g,"/"),X=JSON.stringify(V.params),Y=V.layout?`, layout: '${E.relative(I,V.layout).replace(/\\/g,"/")}'`:"";K.push(` { pattern: '${V.pattern}', filePath: '${J}', isDynamic: ${V.isDynamic}, params: ${X}${Y} },`)}K.push("] as const",""),K.push("export type RouteName = typeof routes[number]['pattern']",""),W.mkdirSync(U,{recursive:!0}),W.writeFileSync(E.join(U,"routes.ts"),K.join(`
|
|
4
|
+
`))}var f=G(()=>{C()});import i from"path";function N($,U){let I=i.relative(U,$).replace(/\.(stx|md)$/,"");if(I=I.split(i.sep).join("/"),I==="index")return"/";if(I.endsWith("/index"))I=I.slice(0,-6);return I=I.replace(/\[\[([^\]]+)\]\]/g,":$1?"),I=I.replace(/\[([^\]]+)\]/g,":$1"),I=I.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${I}`}function j($){let U=[],O="",I=0;while(I<$.length){let B=$.slice(I),L=/^\/:([^/?*]+)\?/.exec(B);if(L){U.push(L[1]),O+="(?:/([^/]+))?",I+=L[0].length;continue}let K=/^:([^/?*]+)\*/.exec(B);if(K){U.push(K[1]),O+="(.+)",I+=K[0].length;continue}let V=/^:([^/?*]+)/.exec(B);if(V){U.push(V[1]),O+="([^/]+)",I+=V[0].length;continue}O+=$[I].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),I+=1}return{regex:new RegExp(`^${O}$`),params:U}}function o($,U){let O=$===""?"/":$;for(let I of U){let B=O.match(I.regex);if(B){let L={};return I.params.forEach((K,V)=>{L[K]=B[V+1]}),{route:I,params:L}}}return null}function r($){let U=$.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return j(U)}var g=()=>{};import b$ from"fs";import d from"path";function R($,U){let O=[],I=d.dirname($);while(I.startsWith(U)||I===U){let B=d.join(I,"_layout.stx");if(b$.existsSync(B))O.unshift(B);if(I===U)break;I=d.dirname(I)}return O}var m=()=>{};import S from"fs";import Q from"path";function t($,U){let O=[];if(!S.existsSync($))return O;let I=S.readdirSync($,{withFileTypes:!0});for(let B of I){let L=Q.join($,B.name);if(B.isDirectory()){if(B.name.startsWith("."))continue;if(F.includes(B.name))continue;O.push(...t(L,U))}else if(B.isFile()){let K=Q.extname(B.name);if(U.includes(K)){if(B.name.startsWith("_")&&B.name!=="_layout.stx")continue;if(B.name==="_layout.stx")continue;O.push(L)}}}return O}class b{routes;pagesDir;pagesDirs;config;constructor($,U={}){this.config=U;let O=U.pagesDirs&&U.pagesDirs.length>0?U.pagesDirs:[U.pagesDir||"pages"];this.pagesDirs=O.map((J)=>Q.resolve($,J)),this.pagesDir=this.pagesDirs[0];let I=U.extensions||[".stx"],B=(J)=>{let X=Q.resolve($,J);try{return S.realpathSync(X)}catch{return X}},L=(U.exclude??[]).filter((J)=>typeof J==="string"&&J.trim()!=="").map(B),K=(J)=>{if(L.length===0)return!1;let X=B(J);return L.some((Y)=>X===Y||X.startsWith(`${Y}${Q.sep}`))},V=new Set;this.routes=[];for(let J of this.pagesDirs){let X=t(J,I).filter((Z)=>!K(Z)),Y=new Map;for(let Z of X){let _=N(Z,J),z=U.pagesDirs?_.replace(/:[\w]+/g,":param"):_;if(U.pagesDirs&&Y.has(z))throw Error(`Conflicting layer pages for ${_}: ${Y.get(z)} and ${Z}`);if(Y.set(z,Z),V.has(z))continue;V.add(z);let{regex:S$,params:s}=j(_),D=U.layouts!==!1?R(Z,J):[];this.routes.push({pattern:_,regex:S$,params:s,filePath:Z,isDynamic:s.length>0,layout:D.length>0?D[D.length-1]:void 0})}}if(this.routes.sort((J,X)=>{if(!J.isDynamic&&X.isDynamic)return-1;if(J.isDynamic&&!X.isDynamic)return 1;let Y=J.pattern.split("/").length,Z=X.pattern.split("/").length;if(Y!==Z)return Z-Y;return J.pattern.localeCompare(X.pattern)}),U.emit!==!1){let J=Q.resolve($,U.stateDir||process.env.STX_DIR?.trim()||".stx");H(this.routes,J),q(this.routes,J,this.pagesDir)}}match($){let U=$===""?"/":$;for(let O of this.routes){let I=U.match(O.regex);if(I){let B={};return O.params.forEach((L,K)=>{B[L]=I[K+1]}),{route:O,params:B}}}return null}resolve($,U){let O=this.routes.find((B)=>B.pattern===$||B.filePath.includes($));if(!O)return"#not-found";let I=O.pattern;if(U)for(let[B,L]of Object.entries(U))I=I.replace(`:${B}`,encodeURIComponent(L));return I}addRoute($){this.routes.push($),this.routes.sort((U,O)=>{if(!U.isDynamic&&O.isDynamic)return-1;if(U.isDynamic&&!O.isDynamic)return 1;return U.pattern.localeCompare(O.pattern)})}getLayout($){return $.layout??null}}function a($,U){return new b($,U)}function e($,U){let O=[`${U}.stx`,"error.stx"];for(let I of O){let B=Q.join($,I);if(S.existsSync(B))return B}return null}function $$($,U){return $.map((O)=>{let I=Q.relative(U,O.filePath),B=O.isDynamic?" (dynamic)":"";return`${O.pattern} \u2192 ${I}${B}`})}var U$=G(()=>{f();g();m();C()});function I$($){x=$.replace(/\/$/,"")}function O$($,U,O={}){M[$]={path:U,name:$,params:O}}function B$($){for(let[U,O]of Object.entries($))if(typeof O==="string")M[U]={path:O,name:U};else M[U]={...O,name:U}}function J$($,U={},O=!1){let I=M[$];if(!I)return console.warn(`Route [${$}] not defined.`),"#undefined-route";let B={...I.params,...U},L=I.path;L=L.replace(/:(\w+)/g,(V,J)=>{let X=B[J];if(X===void 0)return console.warn(`Missing parameter [${J}] for route [${$}].`),`:${J}`;return delete B[J],encodeURIComponent(String(X))});let K=Object.entries(B);if(K.length>0){let V=K.map(([J,X])=>`${encodeURIComponent(J)}=${encodeURIComponent(String(X))}`).join("&");L+=(L.includes("?")?"&":"?")+V}return O&&x?`${x}${L}`:L}function K$(){for(let $ of Object.keys(M))delete M[$];x=""}var M,x="";var L$=G(()=>{M={}});import V$ from"fs";import X$ from"path";function Y$($,U={}){return{type:"redirect",path:$,options:{replace:U.replace??!1,external:U.external??!1,redirectCode:U.redirectCode??302}}}function Z$($){return{type:"abort",error:typeof $==="string"?{statusCode:500,message:$}:$}}function G$($,U={}){return{handler:$,mode:U.mode??"universal"}}function h($){let U={};if(!$)return U;let O=$.split(";");for(let I of O){let[B,...L]=I.split("=");if(B){let K=B.trim(),V=L.join("=").trim();if(K)U[K]=decodeURIComponent(V)}}return U}function k($,U,O={}){let I=`${encodeURIComponent($)}=${encodeURIComponent(U)}`;if(O.expires){let B=typeof O.expires==="number"?new Date(Date.now()+O.expires*1000):O.expires;I+=`; Expires=${B.toUTCString()}`}if(O.path)I+=`; Path=${O.path}`;if(O.domain)I+=`; Domain=${O.domain}`;if(O.secure)I+="; Secure";if(O.httpOnly)I+="; HttpOnly";if(O.sameSite)I+=`; SameSite=${O.sameSite}`;return I}function c($,U){let O=$.headers.get("cookie")||"",I=h(O);return{get(B){return I[B]},set(B,L,K={}){I[B]=L,U.append("Set-Cookie",k(B,L,K))},delete(B){delete I[B],U.append("Set-Cookie",k(B,"",{expires:new Date(0),path:"/"}))},getAll(){return{...I}}}}function l(){return{get($){if(typeof document>"u")return;return h(document.cookie)[$]},set($,U,O={}){if(typeof document>"u")return;document.cookie=k($,U,O)},delete($){if(typeof document>"u")return;document.cookie=k($,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return h(document.cookie)}}}function u(){let $=typeof window<"u"&&typeof window.localStorage<"u";return{get(U){if(!$)return null;try{return window.localStorage.getItem(U)}catch{return null}},set(U,O){if(!$)return;try{window.localStorage.setItem(U,O)}catch{}},remove(U){if(!$)return;try{window.localStorage.removeItem(U)}catch{}},isAvailable(){return $}}}function v($,U){T.set($,U)}function p($){return T.get($)}function Q$($){return T.has($)}function W$(){T.clear()}function M$(){return Array.from(T.keys())}async function _$($,U="middleware"){let O=X$.resolve($,U);if(!V$.existsSync(O))return;let I=V$.readdirSync(O);for(let B of I){if(!B.endsWith(".ts")&&!B.endsWith(".js"))continue;if(B.includes(".test.")||B.includes(".spec."))continue;let L=B.replace(/\.(ts|js)$/,""),K=X$.join(O,B);try{let J=(await import(K)).default;if(J&&typeof J.handler==="function")v(L,J);else if(typeof J==="function")v(L,{handler:J,mode:"universal"})}catch(V){console.warn(`Failed to load middleware '${L}' from ${K}:`,V)}}}function x$($){let U={};if(!$)return U;let O=new URLSearchParams($);for(let[I,B]of O)U[I]=B;return U}function z$($,U,O,I=""){return{path:$,params:U,query:x$(I),fullPath:I?`${$}?${I}`:$,meta:O}}function F$($,U,O,I){let B=I?.isServer??typeof window>"u",L=!B,K=new Headers;return{to:$,from:U,isClient:L,isServer:B,cookies:B&&O?c(O,K):l(),storage:u(),state:{},request:O,responseHeaders:K}}async function A$($,U){let O=Array.isArray($)?$:[$],I=U.isServer;for(let B of O){let L=p(B);if(!L)return console.error(`Route middleware '${B}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${B}' is not registered`}},state:U.state,responseHeaders:U.responseHeaders};if(L.mode==="server"&&!I)continue;try{let K=await L.handler(U);if(K){if(K.type==="redirect")return{passed:!1,redirect:K,state:U.state,responseHeaders:U.responseHeaders};if(K.type==="abort")return{passed:!1,abort:K,state:U.state,responseHeaders:U.responseHeaders}}}catch(K){return console.error(`Error in middleware '${B}':`,K),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:K instanceof Error?K.message:"Middleware error"}},state:U.state,responseHeaders:U.responseHeaders}}}return{passed:!0,state:U.state,responseHeaders:U.responseHeaders}}var T;var E$=G(()=>{T=new Map});function n($){let O=$.replace(/\\/g,"/").split("/").filter(Boolean),I=O.lastIndexOf("layouts"),B=I>=0?O[I+1]:O.at(-1);if(!B)return"app";return B.replace(/\.stx$/i,"")||"app"}function j$($){let U=$.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),O=$.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),I=$.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),B=U?.[1]||I?.[1]||"";return{layout:B,group:O?.[1]||n(B)}}var T$=()=>{};function k$($){let U=[],O="log(",I=0;while(I<$.length){let B=$.indexOf("log(",I);if(B===-1){U.push($.slice(I));break}let L=B>0?$[B-1]:" ",K=/\bfunction\s+$/.test($.slice(Math.max(0,B-16),B));if(/[\w$.]/.test(L)||K){U.push($.slice(I,B+4)),I=B+4;continue}U.push($.slice(I,B));let V=1,J=B+4;while(J<$.length&&V>0){let X=$[J];if(X==='"'||X==="'"||X==="`"){let Y=X;J++;while(J<$.length&&$[J]!==Y){if($[J]==="\\")J++;J++}J++;continue}if(X==="(")V++;else if(X===")")V--;J++}U.push("0"),I=J}return U.join("")}function C$($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function H$(){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};
|
|
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};
|
|
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;
|
|
15
15
|
function log(){if(debug&&typeof console!=='undefined'&&console.log)console.log.apply(console,arguments)}
|
|
16
16
|
|
|
17
|
+
// Shorthands for the document-rooted queries this script makes ~33 times.
|
|
18
|
+
// Every page carries these bytes, and the budget in
|
|
19
|
+
// scripts/performance-budgets.ts is what noticed.
|
|
20
|
+
var LAYOUT_META='meta[name="stx-layout"]';
|
|
21
|
+
var LAYOUT_GROUP_META='meta[name="stx-layout-group"]';
|
|
22
|
+
var BUILD_META='meta[name="stx-build"]';
|
|
23
|
+
function qs(sel){return document.querySelector(sel)}
|
|
24
|
+
function qsa(sel){return document.querySelectorAll(sel)}
|
|
25
|
+
function ce(tag){return document.createElement(tag)}
|
|
26
|
+
function dhead(){return document.head}
|
|
27
|
+
|
|
28
|
+
// \u2500\u2500 Scroll position \u2500\u2500
|
|
29
|
+
// Forward navigation goes to the top, or to the hash. Back and forward return
|
|
30
|
+
// to where the entry was left -- the browser cannot do that for us, because
|
|
31
|
+
// by the time it would restore, the content of the entry has not been fetched
|
|
32
|
+
// yet, so it clamps to whatever height the outgoing page happened to have.
|
|
33
|
+
// history.scrollRestoration therefore goes to manual and the positions are
|
|
34
|
+
// kept here, keyed by a token written into each history entry (two entries
|
|
35
|
+
// for the same URL keep their own positions, which is the point).
|
|
36
|
+
//
|
|
37
|
+
// Manual restoration also takes the browser's reload behaviour away, so the
|
|
38
|
+
// positions are mirrored into sessionStorage: a reload, or a return to the
|
|
39
|
+
// tab, finds the entry's token already in history.state and restores from
|
|
40
|
+
// there. sessionStorage is per tab and dies with it, same as the history.
|
|
41
|
+
var SCROLL_TOKEN='__stxScroll';
|
|
42
|
+
var SCROLL_STORE='stx:scroll:';
|
|
43
|
+
var scrollSeq=0;
|
|
44
|
+
var pendingScroll=null;
|
|
45
|
+
var restoreScroll=!!o.scrollRestoration;
|
|
46
|
+
function newScrollToken(){return 's'+(++scrollSeq)+'-'+Date.now()}
|
|
47
|
+
var scrollToken=(history.state&&history.state[SCROLL_TOKEN])||newScrollToken();
|
|
48
|
+
// sessionStorage is the only store: it is synchronous, it is per tab, it dies
|
|
49
|
+
// with the tab exactly as the history does, and it is the one that survives a
|
|
50
|
+
// reload. A private window that refuses it degrades to scrolling to the top.
|
|
51
|
+
function readScroll(token){
|
|
52
|
+
try{
|
|
53
|
+
var parts=(window.sessionStorage.getItem(SCROLL_STORE+token)||'').split(',');
|
|
54
|
+
return parts.length===2?[parseFloat(parts[0])||0,parseFloat(parts[1])||0]:null;
|
|
55
|
+
}catch(e){return null}
|
|
56
|
+
}
|
|
57
|
+
// Called while the outgoing entry is still the current one, so the position
|
|
58
|
+
// read here belongs to the token being written.
|
|
59
|
+
function rememberScroll(){
|
|
60
|
+
if(!restoreScroll)return;
|
|
61
|
+
try{window.sessionStorage.setItem(SCROLL_STORE+scrollToken,(window.pageXOffset||window.scrollX||0)+','+(window.pageYOffset||window.scrollY||0))}catch(e){}
|
|
62
|
+
}
|
|
63
|
+
// One place decides where a swap leaves the viewport, so the fragment path
|
|
64
|
+
// and the whole-document path cannot drift apart.
|
|
65
|
+
function applyScroll(hash){
|
|
66
|
+
if(pendingScroll){
|
|
67
|
+
var at=pendingScroll;
|
|
68
|
+
pendingScroll=null;
|
|
69
|
+
window.scrollTo({left:at[0],top:at[1],behavior:'instant'});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if(o.scrollToTop&&!hash){window.scrollTo({top:0,behavior:'instant'});return}
|
|
73
|
+
if(hash){var el=qs(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
|
|
74
|
+
}
|
|
75
|
+
// Keeps whatever another script put in the entry; only adds the token.
|
|
76
|
+
function stampScrollToken(){
|
|
77
|
+
var state={};
|
|
78
|
+
var current=history.state;
|
|
79
|
+
if(current&&typeof current==='object')for(var key in current)state[key]=current[key];
|
|
80
|
+
state[SCROLL_TOKEN]=scrollToken;
|
|
81
|
+
try{history.replaceState(state,'',location.href)}catch(e){}
|
|
82
|
+
}
|
|
83
|
+
if(restoreScroll){
|
|
84
|
+
try{history.scrollRestoration='manual'}catch(e){}
|
|
85
|
+
// A token already in the entry means this document is a reload or a
|
|
86
|
+
// restore of an entry visited before, so its position is worth asking for.
|
|
87
|
+
var known=history.state&&history.state[SCROLL_TOKEN];
|
|
88
|
+
if(known){
|
|
89
|
+
var saved=readScroll(scrollToken);
|
|
90
|
+
if(saved&&(saved[0]||saved[1])){
|
|
91
|
+
var restoreAt=function(){window.scrollTo({left:saved[0],top:saved[1],behavior:'instant'})};
|
|
92
|
+
if(document.readyState==='complete')restoreAt();
|
|
93
|
+
else window.addEventListener('load',restoreAt,{once:true});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else{
|
|
97
|
+
stampScrollToken();
|
|
98
|
+
}
|
|
99
|
+
// A reload or a link out of the app never calls writeHistory, so this is
|
|
100
|
+
// the only chance to record where the page was left. pagehide fires for
|
|
101
|
+
// both, and unlike beforeunload it does not keep the page out of the
|
|
102
|
+
// back/forward cache.
|
|
103
|
+
window.addEventListener('pagehide',rememberScroll);
|
|
104
|
+
}
|
|
105
|
+
|
|
17
106
|
// Replace, never merge: absent payloads must forget the outgoing page's data.
|
|
18
107
|
// Run at the committed swap, not during prefetch or a superseded navigation.
|
|
19
108
|
function hydrateServerData(html){
|
|
@@ -36,7 +125,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
36
125
|
// Conservative on purpose: act only when BOTH ids are known. A missing id is
|
|
37
126
|
// "no information", never "mismatch", so statically hosted output (no headers)
|
|
38
127
|
// and older servers behave exactly as before.
|
|
39
|
-
var buildMeta=
|
|
128
|
+
var buildMeta=qs(BUILD_META);
|
|
40
129
|
var loadedBuild=buildMeta?(buildMeta.getAttribute('content')||''):'';
|
|
41
130
|
window.__stxBuild=loadedBuild;
|
|
42
131
|
function isBuildSkew(incoming){
|
|
@@ -184,7 +273,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
184
273
|
function parseContainerAttrs(attrStr){
|
|
185
274
|
var map={};
|
|
186
275
|
if(!attrStr)return map;
|
|
187
|
-
var probe=
|
|
276
|
+
var probe=ce('div');
|
|
188
277
|
probe.innerHTML='<i '+attrStr+'></i>';
|
|
189
278
|
var src=probe.firstChild;
|
|
190
279
|
// getAttributeNames first: it is the same standard DOM answer and it is
|
|
@@ -273,7 +362,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
273
362
|
}
|
|
274
363
|
|
|
275
364
|
function getContainer(){
|
|
276
|
-
return
|
|
365
|
+
return qs(containerSel)||qs('[data-stx-content]')||qs('main');
|
|
277
366
|
}
|
|
278
367
|
|
|
279
368
|
// \u2500\u2500 Navigation \u2500\u2500
|
|
@@ -357,7 +446,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
357
446
|
// navigation. Scripts without an owner are unaffected.
|
|
358
447
|
function ownerStays(owner){
|
|
359
448
|
if(!owner)return false;
|
|
360
|
-
var root=
|
|
449
|
+
var root=qs('[data-stx-scope="'+owner+'"]');
|
|
361
450
|
return !root||typeof root.__stx_disposers==='function';
|
|
362
451
|
}
|
|
363
452
|
function hashScript(code){
|
|
@@ -524,7 +613,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
524
613
|
if(!key||loadedExternalScripts[key])return null;
|
|
525
614
|
loadedExternalScripts[key]=1;
|
|
526
615
|
return new Promise(function(resolve){
|
|
527
|
-
var el=
|
|
616
|
+
var el=ce('script');
|
|
528
617
|
el.src=key;
|
|
529
618
|
// Deliberately NOT data-stx-page: both swap paths clear those on every
|
|
530
619
|
// navigation, which would sweep this away and \u2014 since it is never loaded
|
|
@@ -533,12 +622,12 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
533
622
|
el.setAttribute('data-stx-external','');
|
|
534
623
|
el.onload=function(){resolve()};
|
|
535
624
|
el.onerror=function(){log('[router] container script failed:',key);resolve()};
|
|
536
|
-
|
|
625
|
+
dhead().appendChild(el);
|
|
537
626
|
});
|
|
538
627
|
}
|
|
539
628
|
|
|
540
629
|
// Record scripts from the initial page load
|
|
541
|
-
|
|
630
|
+
qsa('script').forEach(function(s){
|
|
542
631
|
var text=s.textContent||'';
|
|
543
632
|
if(s.hasAttribute('src'))rememberExternalScript(s.getAttribute('src'));
|
|
544
633
|
else if(text.trim())executedScriptHashes[hashScript(text)]=1;
|
|
@@ -565,17 +654,17 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
565
654
|
return part?part.replace(/\\.stx$/i,''):'app';
|
|
566
655
|
}
|
|
567
656
|
function getCurrentLayoutGroup(){
|
|
568
|
-
var meta=
|
|
657
|
+
var meta=qs(LAYOUT_GROUP_META);
|
|
569
658
|
if(meta&&meta.getAttribute('content'))return meta.getAttribute('content');
|
|
570
|
-
var layout=
|
|
659
|
+
var layout=qs(LAYOUT_META);
|
|
571
660
|
return defaultLayoutGroup(layout?layout.getAttribute('content'):'');
|
|
572
661
|
}
|
|
573
662
|
function getDocLayoutGroup(doc,layout){
|
|
574
|
-
var meta=doc&&doc.querySelector?doc.querySelector(
|
|
663
|
+
var meta=doc&&doc.querySelector?doc.querySelector(LAYOUT_GROUP_META):null;
|
|
575
664
|
return meta&&meta.getAttribute('content')?meta.getAttribute('content'):defaultLayoutGroup(layout||'');
|
|
576
665
|
}
|
|
577
666
|
function checkLayoutChange(newLayout,targetUrl,newGroup){
|
|
578
|
-
var currentLayout=
|
|
667
|
+
var currentLayout=qs(LAYOUT_META);
|
|
579
668
|
var curLayoutName=currentLayout?currentLayout.getAttribute('content'):'';
|
|
580
669
|
var curGroup=getCurrentLayoutGroup();
|
|
581
670
|
var nextGroup=newGroup||defaultLayoutGroup(newLayout);
|
|
@@ -604,9 +693,14 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
604
693
|
// through swap() to each of the three history sites would have been the
|
|
605
694
|
// alternative (#1807).
|
|
606
695
|
function writeHistory(mode,href){
|
|
607
|
-
|
|
608
|
-
|
|
696
|
+
// The position belongs to the entry being left, and scrollToken still
|
|
697
|
+
// names it here.
|
|
698
|
+
rememberScroll();
|
|
699
|
+
if(mode==='replace'){history.replaceState(tokenState(),'',href);return}
|
|
700
|
+
scrollToken=newScrollToken();
|
|
701
|
+
history.pushState(tokenState(),'',href);
|
|
609
702
|
}
|
|
703
|
+
function tokenState(){var state={};state[SCROLL_TOKEN]=scrollToken;return state}
|
|
610
704
|
|
|
611
705
|
// Second arg accepts the legacy pushState boolean OR an options object
|
|
612
706
|
// { replace }. Callers inside this file still pass the boolean.
|
|
@@ -628,7 +722,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
|
|
|
628
722
|
|
|
629
723
|
if(t.pathname===location.pathname&&t.hash){
|
|
630
724
|
if(pushState!==false)writeHistory(pushState,t.href);
|
|
631
|
-
var el=
|
|
725
|
+
var el=qs(t.hash);
|
|
632
726
|
if(el)el.scrollIntoView({behavior:'smooth'});
|
|
633
727
|
return Promise.resolve(true);
|
|
634
728
|
}
|
|
@@ -773,7 +867,7 @@ else {
|
|
|
773
867
|
function routeAnnouncer(){
|
|
774
868
|
var el=document.getElementById('stx-route-announcer');
|
|
775
869
|
if(el)return el;
|
|
776
|
-
el=
|
|
870
|
+
el=ce('div');
|
|
777
871
|
el.id='stx-route-announcer';
|
|
778
872
|
el.setAttribute('aria-live','polite');
|
|
779
873
|
el.setAttribute('role','status');
|
|
@@ -806,7 +900,7 @@ else {
|
|
|
806
900
|
function focusAfterNavigation(hash){
|
|
807
901
|
if(o.routeFocus===false)return;
|
|
808
902
|
var target=null;
|
|
809
|
-
if(hash){try{target=
|
|
903
|
+
if(hash){try{target=qs(hash)}catch(e){target=null}}
|
|
810
904
|
if(!target)target=getContainer();
|
|
811
905
|
if(!target||!target.focus)return;
|
|
812
906
|
// The container is not naturally focusable. tabindex="-1" makes it
|
|
@@ -829,7 +923,7 @@ else {
|
|
|
829
923
|
// be the last one, every navigation, not just the first time it is seen.
|
|
830
924
|
function findGeneratedCss(abs){
|
|
831
925
|
var found=null;
|
|
832
|
-
|
|
926
|
+
qsa('head link[data-css][href]').forEach(function(link){
|
|
833
927
|
if(new URL(link.getAttribute('href'),location.href).href!==abs)return;
|
|
834
928
|
// Collapse duplicates, so moving one copy to the end can never leave an
|
|
835
929
|
// older copy of the same sheet behind to fight it.
|
|
@@ -858,7 +952,7 @@ else {
|
|
|
858
952
|
if(link.__stxCssReady)pending.push(link.__stxCssReady);
|
|
859
953
|
return;
|
|
860
954
|
}
|
|
861
|
-
link=
|
|
955
|
+
link=ce('link');
|
|
862
956
|
link.setAttribute('data-css','generated');
|
|
863
957
|
link.setAttribute('rel','stylesheet');
|
|
864
958
|
link.setAttribute('href',new URL(href,location.href).href===abs?href:abs);
|
|
@@ -879,7 +973,7 @@ else {
|
|
|
879
973
|
link.onerror=function(){finish(true)};
|
|
880
974
|
});
|
|
881
975
|
pending.push(link.__stxCssReady);
|
|
882
|
-
|
|
976
|
+
dhead().appendChild(link);
|
|
883
977
|
});
|
|
884
978
|
return pending.length?Promise.all(pending).then(function(results){return results.every(function(ok){return ok!==false})}):null;
|
|
885
979
|
}
|
|
@@ -915,7 +1009,7 @@ else {
|
|
|
915
1009
|
link.removeAttribute('data-stx-css-pending');
|
|
916
1010
|
link.removeAttribute('media');
|
|
917
1011
|
}
|
|
918
|
-
|
|
1012
|
+
dhead().appendChild(link);
|
|
919
1013
|
});
|
|
920
1014
|
}
|
|
921
1015
|
|
|
@@ -1028,18 +1122,18 @@ else {
|
|
|
1028
1122
|
});
|
|
1029
1123
|
cleanFrag=cleanFrag.replace(new RegExp('<!--stx-held-script-(\\\\d+)-->','g'),function(m,i){return heldScripts[Number(i)]});
|
|
1030
1124
|
// Remove old page styles (not css \u2014 that gets merged)
|
|
1031
|
-
|
|
1125
|
+
qsa('style[data-stx-page]').forEach(function(s){s.remove()});
|
|
1032
1126
|
// Merge css CSS from fragment into existing css style
|
|
1033
1127
|
if(fragCss){
|
|
1034
|
-
var curCss=
|
|
1128
|
+
var curCss=qs('head style[data-css]');
|
|
1035
1129
|
if(curCss){
|
|
1036
1130
|
var merged=mergeCss(curCss.textContent||'',fragCss);
|
|
1037
1131
|
if(merged)curCss.textContent=merged;
|
|
1038
1132
|
}else{
|
|
1039
|
-
var cw=
|
|
1133
|
+
var cw=ce('style');
|
|
1040
1134
|
cw.setAttribute('data-css','generated');
|
|
1041
1135
|
cw.textContent=fragCss;
|
|
1042
|
-
|
|
1136
|
+
dhead().appendChild(cw);
|
|
1043
1137
|
}
|
|
1044
1138
|
}
|
|
1045
1139
|
// Already present ones are MOVED last, not skipped \u2014 see
|
|
@@ -1047,10 +1141,10 @@ else {
|
|
|
1047
1141
|
promoteGeneratedCss(fragCssHrefs,location.href);
|
|
1048
1142
|
// Add new page styles
|
|
1049
1143
|
fragStyles.forEach(function(s){
|
|
1050
|
-
var el=
|
|
1144
|
+
var el=ce('style');
|
|
1051
1145
|
el.textContent=s.css;
|
|
1052
1146
|
el.setAttribute('data-stx-page','');
|
|
1053
|
-
|
|
1147
|
+
dhead().appendChild(el);
|
|
1054
1148
|
});
|
|
1055
1149
|
// Swap content \u2014 apply the destination container's own attributes first
|
|
1056
1150
|
// so the incoming markup lands in a correctly-laid-out container instead
|
|
@@ -1058,11 +1152,10 @@ else {
|
|
|
1058
1152
|
applyContainerAttrs(currentContent,pendingContainerAttrs);
|
|
1059
1153
|
currentContent.innerHTML=cleanFrag;
|
|
1060
1154
|
// Remove old page scripts
|
|
1061
|
-
|
|
1155
|
+
qsa('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
1062
1156
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
|
1063
1157
|
refreshCurrentLinks();
|
|
1064
|
-
|
|
1065
|
-
else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
|
|
1158
|
+
applyScroll(hash);
|
|
1066
1159
|
window.dispatchEvent(new CustomEvent('stx:navigate',{detail:{url:url}}));
|
|
1067
1160
|
// Before page scripts run, so a page that focuses its own control on
|
|
1068
1161
|
// mount still wins \u2014 its script executes after this.
|
|
@@ -1072,7 +1165,7 @@ else {
|
|
|
1072
1165
|
setTimeout(announceRoute,0);
|
|
1073
1166
|
// Execute page scripts FIRST \u2014 they define setup functions and set _latestSetup
|
|
1074
1167
|
log('[router] frag scripts:', fragScripts.length);
|
|
1075
|
-
|
|
1168
|
+
qsa('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
1076
1169
|
// The page's module registry first (#1957), setups last. A fragment
|
|
1077
1170
|
// lists its scripts in document order, and the registry is emitted
|
|
1078
1171
|
// after the content it serves: a component that imports a package ran
|
|
@@ -1084,11 +1177,11 @@ else {
|
|
|
1084
1177
|
fragScripts.forEach(function(entry){
|
|
1085
1178
|
var code=entry.text;
|
|
1086
1179
|
log('[router] exec script len:', code.length, 'has __stx_setup:', code.indexOf('__stx_setup')>-1);
|
|
1087
|
-
var placeholder=
|
|
1180
|
+
var placeholder=qs('script[data-stx-route-script="'+entry.slot+'"]');
|
|
1088
1181
|
var nestedScopedTemplate=false;
|
|
1089
1182
|
var scopedLoopSetup=false;
|
|
1090
1183
|
if(entry.scoped&&placeholder){
|
|
1091
|
-
|
|
1184
|
+
qsa('template').forEach(function(template){
|
|
1092
1185
|
if(template.contains(placeholder)||(template.content&&template.content.contains(placeholder)))
|
|
1093
1186
|
nestedScopedTemplate=true;
|
|
1094
1187
|
});
|
|
@@ -1131,7 +1224,7 @@ else {
|
|
|
1131
1224
|
return;
|
|
1132
1225
|
}
|
|
1133
1226
|
executedScriptHashes[h]=1;
|
|
1134
|
-
var ns=
|
|
1227
|
+
var ns=ce('script');
|
|
1135
1228
|
var hasImport=hasStaticImport(code);
|
|
1136
1229
|
if(hasImport){
|
|
1137
1230
|
ns.type='module';
|
|
@@ -1194,7 +1287,7 @@ else {
|
|
|
1194
1287
|
var doc=parser.parseFromString(html,'text/html');
|
|
1195
1288
|
// Full documents carry the build id as a meta rather than a header, and
|
|
1196
1289
|
// this path also serves cached HTML, so check here too (#1772).
|
|
1197
|
-
var docBuildMeta=doc.querySelector(
|
|
1290
|
+
var docBuildMeta=doc.querySelector(BUILD_META);
|
|
1198
1291
|
var docBuild=docBuildMeta?(docBuildMeta.getAttribute('content')||''):'';
|
|
1199
1292
|
if(isBuildSkew(docBuild)){reloadForSkew(url,docBuild);return Promise.resolve(false)}
|
|
1200
1293
|
// Same hand-off as the fragment path, for the same reason (#1809, #1839).
|
|
@@ -1228,12 +1321,12 @@ else {
|
|
|
1228
1321
|
// \u2500\u2500 Swap <head> styles \u2500\u2500
|
|
1229
1322
|
// Inject new styles FIRST, then remove old to prevent unstyled flash
|
|
1230
1323
|
var keepIds={'stx-view-transitions':1,'stx-r-css':1};
|
|
1231
|
-
var curStyles=
|
|
1324
|
+
var curStyles=qsa('head style');
|
|
1232
1325
|
var newStyles=doc.querySelectorAll('head style');
|
|
1233
1326
|
|
|
1234
1327
|
// Merge css styles instead of replacing \u2014 persistent elements
|
|
1235
1328
|
// (nav, footer) outside <main> still need their utility classes
|
|
1236
|
-
var curCss=
|
|
1329
|
+
var curCss=qs('head style[data-css]');
|
|
1237
1330
|
var newCss=null;
|
|
1238
1331
|
newStyles.forEach(function(s){if(s.getAttribute('data-css'))newCss=s});
|
|
1239
1332
|
|
|
@@ -1245,20 +1338,20 @@ else {
|
|
|
1245
1338
|
var incoming=[];
|
|
1246
1339
|
newStyles.forEach(function(s){
|
|
1247
1340
|
if(!keepIds[s.id]&&!s.getAttribute('data-css')){
|
|
1248
|
-
var ns=
|
|
1341
|
+
var ns=ce('style');
|
|
1249
1342
|
ns.textContent=s.textContent;
|
|
1250
1343
|
ns.setAttribute('data-stx-incoming','');
|
|
1251
|
-
|
|
1344
|
+
dhead().appendChild(ns);
|
|
1252
1345
|
incoming.push(ns);
|
|
1253
1346
|
}
|
|
1254
1347
|
});
|
|
1255
1348
|
|
|
1256
1349
|
// If no existing css but new page has one, add it
|
|
1257
1350
|
if(!curCss&&newCss){
|
|
1258
|
-
var ns=
|
|
1351
|
+
var ns=ce('style');
|
|
1259
1352
|
ns.textContent=newCss.textContent;
|
|
1260
1353
|
ns.setAttribute('data-css',newCss.getAttribute('data-css'));
|
|
1261
|
-
|
|
1354
|
+
dhead().appendChild(ns);
|
|
1262
1355
|
}
|
|
1263
1356
|
|
|
1264
1357
|
// Remove old styles (except persistent ones, css, and incoming)
|
|
@@ -1285,7 +1378,7 @@ else {
|
|
|
1285
1378
|
try{docBase=new URL(url,location.href).href}catch(e){docBase=location.href}
|
|
1286
1379
|
var linkSel='link[rel="stylesheet"],link[rel="preconnect"]';
|
|
1287
1380
|
var curLinks={};
|
|
1288
|
-
|
|
1381
|
+
qsa('head '+linkSel).forEach(function(l){var h=l.getAttribute('href');if(h)curLinks[new URL(h,location.href).href]=1});
|
|
1289
1382
|
doc.querySelectorAll('head '+linkSel).forEach(function(l){
|
|
1290
1383
|
var href=l.getAttribute('href');
|
|
1291
1384
|
if(!href)return;
|
|
@@ -1295,9 +1388,9 @@ else {
|
|
|
1295
1388
|
var abs=new URL(href,docBase).href;
|
|
1296
1389
|
if(curLinks[abs])return;
|
|
1297
1390
|
curLinks[abs]=1;
|
|
1298
|
-
var nl=
|
|
1391
|
+
var nl=ce('link');
|
|
1299
1392
|
Array.from(l.attributes).forEach(function(a){nl.setAttribute(a.name,a.value)});
|
|
1300
|
-
|
|
1393
|
+
dhead().appendChild(nl);
|
|
1301
1394
|
});
|
|
1302
1395
|
// After every other stylesheet link, so the destination's complete
|
|
1303
1396
|
// utility sheet is last in the cascade.
|
|
@@ -1311,8 +1404,8 @@ else {
|
|
|
1311
1404
|
var declaredLayout=pendingLayoutDecl;
|
|
1312
1405
|
pendingLayoutDecl=null;
|
|
1313
1406
|
if(newBody){
|
|
1314
|
-
var newMeta=doc.querySelector(
|
|
1315
|
-
var curMeta=
|
|
1407
|
+
var newMeta=doc.querySelector(LAYOUT_META);
|
|
1408
|
+
var curMeta=qs(LAYOUT_META);
|
|
1316
1409
|
var curLayout=curMeta?curMeta.getAttribute('content'):'';
|
|
1317
1410
|
// The server's answer wins over the document's metas. We are only here
|
|
1318
1411
|
// because checkLayoutChange already said the group changed, based on
|
|
@@ -1380,16 +1473,16 @@ else {
|
|
|
1380
1473
|
// Copy body attributes (class, data-stx, etc.)
|
|
1381
1474
|
Array.from(newBody.attributes).forEach(function(attr){document.body.setAttribute(attr.name,attr.value)});
|
|
1382
1475
|
// Update layout meta tag
|
|
1383
|
-
var oldMeta=
|
|
1384
|
-
var freshMeta=doc.querySelector(
|
|
1476
|
+
var oldMeta=qs(LAYOUT_META);
|
|
1477
|
+
var freshMeta=doc.querySelector(LAYOUT_META);
|
|
1385
1478
|
if(oldMeta&&freshMeta)oldMeta.setAttribute('content',freshMeta.getAttribute('content')||'');
|
|
1386
|
-
else if(freshMeta){var m=
|
|
1387
|
-
var oldGroupMeta=
|
|
1388
|
-
var freshGroupMeta=doc.querySelector(
|
|
1479
|
+
else if(freshMeta){var m=ce('meta');m.name='stx-layout';m.content=freshMeta.getAttribute('content')||'';dhead().appendChild(m)}
|
|
1480
|
+
var oldGroupMeta=qs(LAYOUT_GROUP_META);
|
|
1481
|
+
var freshGroupMeta=doc.querySelector(LAYOUT_GROUP_META);
|
|
1389
1482
|
if(oldGroupMeta&&freshGroupMeta)oldGroupMeta.setAttribute('content',freshGroupMeta.getAttribute('content')||'');
|
|
1390
|
-
else if(freshGroupMeta){var gm=
|
|
1483
|
+
else if(freshGroupMeta){var gm=ce('meta');gm.name='stx-layout-group';gm.content=freshGroupMeta.getAttribute('content')||'';dhead().appendChild(gm)}
|
|
1391
1484
|
// Update container reference for script execution below
|
|
1392
|
-
currentContent=
|
|
1485
|
+
currentContent=qs(containerSel)||qs('main')||document.body;
|
|
1393
1486
|
} else {
|
|
1394
1487
|
// Same layout \u2014 swap only container content. Carry the destination
|
|
1395
1488
|
// container's attributes across too (same reason as the fragment path:
|
|
@@ -1408,7 +1501,7 @@ else {
|
|
|
1408
1501
|
|
|
1409
1502
|
// \u2500\u2500 Load new external <head> scripts \u2500\u2500
|
|
1410
1503
|
var loadedSrcs={};
|
|
1411
|
-
|
|
1504
|
+
qsa('head script[src]').forEach(function(s){loadedSrcs[s.src]=1});
|
|
1412
1505
|
var extPromises=[];
|
|
1413
1506
|
doc.querySelectorAll('head script[src]').forEach(function(s){
|
|
1414
1507
|
if(isSharedClientScript(s))return;
|
|
@@ -1418,11 +1511,11 @@ else {
|
|
|
1418
1511
|
if(loadedSrcs[src])return;
|
|
1419
1512
|
loadedSrcs[src]=1;
|
|
1420
1513
|
extPromises.push(new Promise(function(resolve,reject){
|
|
1421
|
-
var ns=
|
|
1514
|
+
var ns=ce('script');
|
|
1422
1515
|
ns.src=src;
|
|
1423
1516
|
ns.onload=resolve;
|
|
1424
1517
|
ns.onerror=reject;
|
|
1425
|
-
|
|
1518
|
+
dhead().appendChild(ns);
|
|
1426
1519
|
}));
|
|
1427
1520
|
});
|
|
1428
1521
|
|
|
@@ -1436,7 +1529,7 @@ else {
|
|
|
1436
1529
|
|
|
1437
1530
|
// \u2500\u2500 Script re-execution \u2500\u2500
|
|
1438
1531
|
// Remove previously injected page scripts
|
|
1439
|
-
|
|
1532
|
+
qsa('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
1440
1533
|
|
|
1441
1534
|
var scripts=routedBodyScripts.slice();
|
|
1442
1535
|
function addScript(text, runAlways, slot, owner){
|
|
@@ -1520,8 +1613,7 @@ else {
|
|
|
1520
1613
|
refreshCurrentLinks();
|
|
1521
1614
|
|
|
1522
1615
|
// Scroll
|
|
1523
|
-
|
|
1524
|
-
else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
|
|
1616
|
+
applyScroll(hash);
|
|
1525
1617
|
|
|
1526
1618
|
// Update title
|
|
1527
1619
|
var newTitle=doc.querySelector('title');
|
|
@@ -1582,7 +1674,7 @@ else {
|
|
|
1582
1674
|
if(!runAlways&&!isSetup&&executedScriptHashes[h])return;
|
|
1583
1675
|
executedScriptHashes[h]=1;
|
|
1584
1676
|
// Wrap scripts with import statements as modules (Bug 3 fix)
|
|
1585
|
-
var ns=
|
|
1677
|
+
var ns=ce('script');
|
|
1586
1678
|
if(hasImport){
|
|
1587
1679
|
ns.type='module';
|
|
1588
1680
|
}
|
|
@@ -1595,7 +1687,7 @@ else {
|
|
|
1595
1687
|
var alreadyScoped=runsAlways(typeof entry==='string'?'':entry.run,text);
|
|
1596
1688
|
ns.textContent=(hasImport||alreadyScoped)?text:'{'+text+'}';
|
|
1597
1689
|
ns.setAttribute('data-stx-page','');
|
|
1598
|
-
var placeholder=entry.slot?
|
|
1690
|
+
var placeholder=entry.slot?qs('script[data-stx-route-script="'+entry.slot+'"]'):null;
|
|
1599
1691
|
if(placeholder&&placeholder.parentNode){
|
|
1600
1692
|
ns.setAttribute('data-stx-positioned','');
|
|
1601
1693
|
placeholder.parentNode.replaceChild(ns,placeholder);
|
|
@@ -1887,6 +1979,16 @@ else {
|
|
|
1887
1979
|
|
|
1888
1980
|
// \u2500\u2500 Back/forward \u2500\u2500
|
|
1889
1981
|
window.addEventListener('popstate',function(){
|
|
1982
|
+
// Nothing has scrolled yet (restoration is manual), so the viewport still
|
|
1983
|
+
// shows the entry being left: save it under its own token before adopting
|
|
1984
|
+
// the popped entry's, and hand the swap the position to land on.
|
|
1985
|
+
rememberScroll();
|
|
1986
|
+
if(restoreScroll){
|
|
1987
|
+
var popped=history.state&&history.state[SCROLL_TOKEN];
|
|
1988
|
+
scrollToken=popped||newScrollToken();
|
|
1989
|
+
if(!popped)stampScrollToken();
|
|
1990
|
+
pendingScroll=readScroll(scrollToken);
|
|
1991
|
+
}
|
|
1890
1992
|
navigate(location.pathname+location.search+location.hash,false);
|
|
1891
1993
|
});
|
|
1892
1994
|
|
|
@@ -1953,7 +2055,7 @@ else {
|
|
|
1953
2055
|
}
|
|
1954
2056
|
|
|
1955
2057
|
function updateNav(){
|
|
1956
|
-
|
|
2058
|
+
qsa('nav a[href], #mobileNav a[href], [data-stx-nav] a[href]').forEach(function(a){
|
|
1957
2059
|
if(!a.hasAttribute('data-stx-link'))return;
|
|
1958
2060
|
var st=linkState(a.getAttribute('href'),a.getAttribute('data-stx-active-match'));
|
|
1959
2061
|
if(!st)return;
|
|
@@ -1974,7 +2076,7 @@ else {
|
|
|
1974
2076
|
|
|
1975
2077
|
function updateActiveLinks(){
|
|
1976
2078
|
// Update active classes on <stx-link> elements (and legacy data-stx-link)
|
|
1977
|
-
var links=
|
|
2079
|
+
var links=qsa('[data-stx-link]');
|
|
1978
2080
|
links.forEach(function(link){
|
|
1979
2081
|
var st=linkState(link.getAttribute('to')||link.getAttribute('href')||'',link.getAttribute('data-stx-active-match'));
|
|
1980
2082
|
if(!st)return;
|
|
@@ -2016,7 +2118,7 @@ else {
|
|
|
2016
2118
|
// the cascade, or opt out entirely with viewTransitions:false.
|
|
2017
2119
|
function injectStyles(){
|
|
2018
2120
|
if(!document.getElementById('stx-r-css')){
|
|
2019
|
-
var s=
|
|
2121
|
+
var s=ce('style');s.id='stx-r-css';
|
|
2020
2122
|
// Strip characters that could escape our CSS block and inject new
|
|
2021
2123
|
// declarations: ; { } ( ) " ' \\ < > plus whitespace control chars.
|
|
2022
2124
|
// This keeps the value safe to concat into a stylesheet even if a
|
|
@@ -2038,10 +2140,10 @@ else {
|
|
|
2038
2140
|
css+='@media (prefers-reduced-motion: reduce){::view-transition-old(root),::view-transition-new(root){animation-duration:0s;animation-name:none}}';
|
|
2039
2141
|
}
|
|
2040
2142
|
s.textContent=css;
|
|
2041
|
-
|
|
2143
|
+
dhead().appendChild(s);
|
|
2042
2144
|
}
|
|
2043
2145
|
if(o.progress&&!document.getElementById('stx-router-progress')){
|
|
2044
|
-
var el=
|
|
2146
|
+
var el=ce('div');
|
|
2045
2147
|
el.id='stx-router-progress';
|
|
2046
2148
|
el.setAttribute('role','progressbar');
|
|
2047
2149
|
el.setAttribute('aria-hidden','true');
|
|
@@ -2058,7 +2160,7 @@ else {
|
|
|
2058
2160
|
|
|
2059
2161
|
function injectViewTransitionCSS(){
|
|
2060
2162
|
if(document.getElementById('stx-view-transitions'))return;
|
|
2061
|
-
var s=
|
|
2163
|
+
var s=ce('style');s.id='stx-view-transitions';
|
|
2062
2164
|
s.textContent='::view-transition-group(root){animation:none}::view-transition-old(root){animation:none}::view-transition-new(root){animation:none}main,#app-content,[data-stx-content]{view-transition-name:stx-content}::view-transition-old(stx-content){animation:stx-fade-out .15s ease-out both}::view-transition-new(stx-content){animation:stx-fade-in .15s ease-in .1s both}@keyframes stx-fade-out{from{opacity:1}to{opacity:0}}@keyframes stx-fade-in{from{opacity:0}to{opacity:1}}::view-transition{background:transparent}::view-transition-group(stx-content){background:inherit;overflow:hidden}';
|
|
2063
2165
|
(document.head||document.documentElement).appendChild(s);
|
|
2064
2166
|
}
|
|
@@ -2115,5 +2217,5 @@ else {
|
|
|
2115
2217
|
|
|
2116
2218
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
2117
2219
|
})();
|
|
2118
|
-
`),
|
|
2119
|
-
export{
|
|
2220
|
+
`}function q$(){if(w)return w;return w=C$(k$(H$())),w}function N$(){if(P)return P;return P=C$(H$()),P}var w,P;var R$=()=>{};var w$={};v$(w$,{setAppUrl:()=>I$,runMiddleware:()=>A$,route:()=>J$,resolveLayoutChain:()=>R,resetRoutes:()=>K$,registerMiddleware:()=>v,patternToRegex:()=>j,navigateTo:()=>Y$,matchRoute:()=>o,loadMiddlewareFromDirectory:()=>_$,isNonPageRoutePattern:()=>A,isNonPageRoutePath:()=>y,hasMiddleware:()=>Q$,getRouterScriptDev:()=>N$,getRouterScript:()=>q$,getMiddlewareNames:()=>M$,getMiddleware:()=>p,generateRouteTypes:()=>H,generateRouteManifest:()=>q,formatRoutes:()=>$$,findErrorPage:()=>e,filePathToPattern:()=>N,extractLayoutMetadata:()=>j$,deriveLayoutGroup:()=>n,defineRoutes:()=>B$,defineRoute:()=>O$,defineMiddleware:()=>G$,createStorageManager:()=>u,createServerCookieManager:()=>c,createRouter:()=>a,createRouteLocation:()=>z$,createMiddlewareContext:()=>F$,createClientCookieManager:()=>l,clearMiddleware:()=>W$,bracketPathToRegex:()=>r,abortNavigation:()=>Z$,Router:()=>b,NON_PAGE_DIRS:()=>F});var P$=G(()=>{U$();g();L$();E$();m();T$();f();C();R$()});
|
|
2221
|
+
export{F as xv,y as yv,A as zv,H as Av,q as Bv,N as Cv,j as Dv,o as Ev,r as Fv,R as Gv,b as Hv,a as Iv,e as Jv,$$ as Kv,I$ as Lv,O$ as Mv,B$ as Nv,J$ as Ov,K$ as Pv,Y$ as Qv,Z$ as Rv,G$ as Sv,c as Tv,l as Uv,u as Vv,v as Wv,p as Xv,Q$ as Yv,W$ as Zv,M$ as _v,_$ as $v,z$ as aw,F$ as bw,A$ as cw,n as dw,j$ as ew,T$ as fw,q$ as gw,N$ as hw,w$ as iw,P$ as jw};
|