@stacksjs/stx 0.2.250 → 0.2.252
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-3rs2etjv.js → chunk-0na9rn3e.js} +1 -1
- package/dist/{chunk-ypgmke1m.js → chunk-0sj6nj4d.js} +1 -1
- package/dist/{chunk-8g7acryv.js → chunk-1b1fwf1e.js} +1 -1
- package/dist/{chunk-2tdg6dkd.js → chunk-1b3pey4n.js} +1 -1
- package/dist/{chunk-e27qwbj8.js → chunk-3ej56pch.js} +1 -1
- package/dist/{chunk-pj5ahn52.js → chunk-4zpmg5ct.js} +1 -1
- package/dist/{chunk-j5wp00fs.js → chunk-5qy49drk.js} +1 -1
- package/dist/{chunk-17zb5sdn.js → chunk-6jay0ejd.js} +1 -1
- package/dist/{chunk-yzjrtq3k.js → chunk-7hrttzad.js} +16 -16
- package/dist/{chunk-0thzzef1.js → chunk-81e0mjtz.js} +1 -1
- package/dist/{chunk-ys59ganx.js → chunk-95t702td.js} +1 -1
- package/dist/{chunk-51wgz0xg.js → chunk-9dagx91q.js} +1 -1
- package/dist/{chunk-7tbepz6d.js → chunk-9qn3f7tp.js} +98 -7
- package/dist/{chunk-de9r2yhn.js → chunk-a8yc5svy.js} +1 -1
- package/dist/chunk-ay40p1k6.js +2 -0
- package/dist/{chunk-t60sskkr.js → chunk-bmxqkast.js} +46 -5
- package/dist/{chunk-tv59qkyk.js → chunk-bs3n1zt2.js} +1 -1
- package/dist/{chunk-dm3wagpw.js → chunk-c06970qq.js} +9 -9
- package/dist/{chunk-hsmd7q0n.js → chunk-c6k8yfwa.js} +1 -1
- package/dist/{chunk-xyxh8nwd.js → chunk-cg6v2ff1.js} +1 -1
- package/dist/{chunk-59bmhwch.js → chunk-cjk6zcgz.js} +1 -1
- package/dist/{chunk-ettkbnvm.js → chunk-ck11f0w4.js} +1 -1
- package/dist/{chunk-2rq32e9t.js → chunk-cxvmws79.js} +1 -1
- package/dist/{chunk-eez474bd.js → chunk-dde4fvwg.js} +1 -1
- package/dist/{chunk-5864xxx9.js → chunk-djkwdpcb.js} +1 -1
- package/dist/{chunk-w4hpp2q7.js → chunk-dkrgh8gv.js} +1 -1
- package/dist/{chunk-fqy71v2e.js → chunk-f1m5a48z.js} +1 -1
- package/dist/{chunk-dadn4tgg.js → chunk-f7ye3z1y.js} +1 -1
- package/dist/{chunk-cwfd9z9w.js → chunk-fcgewg4k.js} +1 -1
- package/dist/{chunk-2xkqwatw.js → chunk-fmj97bm8.js} +2 -2
- package/dist/{chunk-kpf2c85z.js → chunk-gn21yx6c.js} +1 -1
- package/dist/{chunk-00qcqjda.js → chunk-h3cvkas0.js} +1 -1
- package/dist/{chunk-8a25zrth.js → chunk-kwz1hy66.js} +1 -1
- package/dist/{chunk-0jdxe23c.js → chunk-m1qf02qz.js} +1 -1
- package/dist/{chunk-zcc9pxva.js → chunk-m8y2hnqk.js} +1 -1
- package/dist/{chunk-z4dffsr3.js → chunk-nm1mh7ay.js} +1 -1
- package/dist/chunk-nrkkxkzb.js +2 -0
- package/dist/{chunk-rrwrczr5.js → chunk-pctsgktp.js} +1 -1
- package/dist/{chunk-vknx6nvv.js → chunk-pfhm9kh8.js} +1 -1
- package/dist/{chunk-wb34r474.js → chunk-pt25jgqd.js} +1 -1
- package/dist/{chunk-9z5cbn7k.js → chunk-sd0rmt49.js} +1 -1
- package/dist/{chunk-e4pb02w6.js → chunk-t0dq8bsd.js} +1 -1
- package/dist/{chunk-81vzysty.js → chunk-thermrhq.js} +1 -1
- package/dist/{chunk-wqxyrh79.js → chunk-v0tdgxs9.js} +2 -2
- package/dist/{chunk-yhrr7k23.js → chunk-vn7stdg9.js} +1 -1
- package/dist/{chunk-s29q9nt0.js → chunk-xsze8fa2.js} +1 -1
- package/dist/{chunk-5jww9gpz.js → chunk-xw1x7nkg.js} +1 -1
- package/dist/{chunk-vpmw7990.js → chunk-zrhbc7jj.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +46 -5
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-9fpaygtf.js +0 -2
- package/dist/chunk-w6mbb5qk.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ou as Ae,Pu as u}from"./chunk-b9691w0f.js";function _(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>
|
|
3
|
-
`),s=y.join(t,"route-types.d.ts");try{if(d.existsSync(s)&&d.readFileSync(s,"utf8")===n)return;d.mkdirSync(t,{recursive:!0}),d.writeFileSync(s,n)}catch{}}function S(e,t,a){let r=process.cwd(),n=y.relative(r,a),s=e.filter((i)=>!
|
|
4
|
-
`))}var F=u(()=>{b()});import V from"path";function k(e,t){let r=V.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(V.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 v(e){let t=[],a="",r=0;while(r<e.length){let n=e.slice(r),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),a+="(?:/([^/]+))?",r+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),a+="(.+)",r+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),a+="([^/]+)",r+=i[0].length;continue}a+=e[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:t}}function W(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let s={};return r.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:r,params:s}}}return null}function D(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}var I=()=>{};import xe from"fs";import M from"path";function A(e,t){let a=[],r=M.dirname(e);while(r.startsWith(t)||r===t){let n=M.join(r,"_layout.stx");if(xe.existsSync(n))a.unshift(n);if(r===t)break;r=M.dirname(r)}return a}var N=()=>{};import P from"fs";import h from"path";function K(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=h.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(
|
|
2
|
+
import{Ou as Ae,Pu as u}from"./chunk-b9691w0f.js";function _(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>g.includes(a))}function m(e){return _(e.replace(/^\//,""))}var g;var b=u(()=>{g=["components","layouts","partials","emails"]});import d from"fs";import y from"path";function x(e,t){let a=e.filter((o)=>!m(o.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 o of a){let i=[];for(let c of o.params){let f=o.pattern.includes(`:${c}?`)?"?":"";i.push(`${c}${f}: string`)}let l=i.join("; ");r.push(` '${o.pattern}': { ${l} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
|
|
3
|
+
`),s=y.join(t,"route-types.d.ts");try{if(d.existsSync(s)&&d.readFileSync(s,"utf8")===n)return;d.mkdirSync(t,{recursive:!0}),d.writeFileSync(s,n)}catch{}}function S(e,t,a){let r=process.cwd(),n=y.relative(r,a),s=e.filter((i)=>!m(i.pattern)),o=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let i of s){let l=y.relative(r,i.filePath).replace(/\\/g,"/"),c=JSON.stringify(i.params),f=i.layout?`, layout: '${y.relative(r,i.layout).replace(/\\/g,"/")}'`:"";o.push(` { pattern: '${i.pattern}', filePath: '${l}', isDynamic: ${i.isDynamic}, params: ${c}${f} },`)}o.push("] as const",""),o.push("export type RouteName = typeof routes[number]['pattern']",""),d.mkdirSync(t,{recursive:!0}),d.writeFileSync(y.join(t,"routes.ts"),o.join(`
|
|
4
|
+
`))}var F=u(()=>{b()});import V from"path";function k(e,t){let r=V.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(V.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 v(e){let t=[],a="",r=0;while(r<e.length){let n=e.slice(r),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),a+="(?:/([^/]+))?",r+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),a+="(.+)",r+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),a+="([^/]+)",r+=i[0].length;continue}a+=e[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:t}}function W(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let s={};return r.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:r,params:s}}}return null}function D(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}var I=()=>{};import xe from"fs";import M from"path";function A(e,t){let a=[],r=M.dirname(e);while(r.startsWith(t)||r===t){let n=M.join(r,"_layout.stx");if(xe.existsSync(n))a.unshift(n);if(r===t)break;r=M.dirname(r)}return a}var N=()=>{};import P from"fs";import h from"path";function K(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=h.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(g.includes(n.name))continue;a.push(...K(s,t))}else if(n.isFile()){let o=h.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(s)}}}return a}class C{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((o)=>h.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let i=K(o,r);for(let l of i){let c=k(l,o);if(n.has(c))continue;n.add(c);let{regex:f,params:H}=v(c),O=t.layouts!==!1?A(l,o):[];this.routes.push({pattern:c,regex:f,params:H,filePath:l,isDynamic:H.length>0,layout:O.length>0?O[O.length-1]:void 0})}}this.routes.sort((o,i)=>{if(!o.isDynamic&&i.isDynamic)return-1;if(o.isDynamic&&!i.isDynamic)return 1;let l=o.pattern.split("/").length,c=i.pattern.split("/").length;if(l!==c)return c-l;return o.pattern.localeCompare(i.pattern)});let s=h.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");x(this.routes,s),S(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((s,o)=>{n[s]=r[o+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,s]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(s));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 z(e,t){return new C(e,t)}function $(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=h.join(e,r);if(P.existsSync(n))return n}return null}function Y(e,t){return e.map((a)=>{let r=h.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var J=u(()=>{F();I();N();b()});function Z(e){T=e.replace(/\/$/,"")}function Q(e,t,a={}){p[e]={path:t,name:e,params:a}}function ee(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")p[t]={path:a,name:t};else p[t]={...a,name:t}}function te(e,t={},a=!1){let r=p[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},s=r.path;s=s.replace(/:(\w+)/g,(i,l)=>{let c=n[l];if(c===void 0)return console.warn(`Missing parameter [${l}] for route [${e}].`),`:${l}`;return delete n[l],encodeURIComponent(String(c))});let o=Object.entries(n);if(o.length>0){let i=o.map(([l,c])=>`${encodeURIComponent(l)}=${encodeURIComponent(String(c))}`).join("&");s+=(s.includes("?")?"&":"?")+i}return a&&T?`${T}${s}`:s}function re(){for(let e of Object.keys(p))delete p[e];T=""}var p,T="";var ae=u(()=>{p={}});import ne from"fs";import oe from"path";function se(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function ie(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function le(e,t={}){return{handler:e,mode:t.mode??"universal"}}function B(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...s]=r.split("=");if(n){let o=n.trim(),i=s.join("=").trim();if(o)t[o]=decodeURIComponent(i)}}return t}function E(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 G(e,t){let a=e.headers.get("cookie")||"",r=B(a);return{get(n){return r[n]},set(n,s,o={}){r[n]=s,t.append("Set-Cookie",E(n,s,o))},delete(n){delete r[n],t.append("Set-Cookie",E(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function X(){return{get(e){if(typeof document>"u")return;return B(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=E(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=E(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return B(document.cookie)}}}function U(){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}}}function R(e,t){w.set(e,t)}function j(e){return w.get(e)}function ce(e){return w.has(e)}function ue(){w.clear()}function de(){return Array.from(w.keys())}async function he(e,t="middleware"){let a=oe.resolve(e,t);if(!ne.existsSync(a))return;let r=ne.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let s=n.replace(/\.(ts|js)$/,""),o=oe.join(a,n);try{let l=(await import(o)).default;if(l&&typeof l.handler==="function")R(s,l);else if(typeof l==="function")R(s,{handler:l,mode:"universal"})}catch(i){console.warn(`Failed to load middleware '${s}' from ${o}:`,i)}}}function Se(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function pe(e,t,a,r=""){return{path:e,params:t,query:Se(r),fullPath:r?`${e}?${r}`:e,meta:a}}function fe(e,t,a,r){let n=r?.isServer??typeof window>"u",s=!n,o=new Headers;return{to:e,from:t,isClient:s,isServer:n,cookies:n&&a?G(a,o):X(),storage:U(),state:{},request:a,responseHeaders:o}}async function ge(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let s=j(n);if(!s)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(s.mode==="server"&&!r)continue;try{let o=await s.handler(t);if(o){if(o.type==="redirect")return{passed:!1,redirect:o,state:t.state,responseHeaders:t.responseHeaders};if(o.type==="abort")return{passed:!1,abort:o,state:t.state,responseHeaders:t.responseHeaders}}}catch(o){return console.error(`Error in middleware '${n}':`,o),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:o instanceof Error?o.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}var w;var me=u(()=>{w=new Map});function q(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 ye(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]||q(n)}}var ve=()=>{};function ke(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function we(){if(L)return L;return L=ke(`
|
|
5
5
|
;(function(){
|
|
6
6
|
'use strict';
|
|
7
7
|
var ROUTER_REV=7;
|
|
@@ -372,10 +372,68 @@ import{Ou as Ae,Pu as u}from"./chunk-b9691w0f.js";function _(e){return e.split(/
|
|
|
372
372
|
function fragmentMarker(declared){
|
|
373
373
|
return '<!--stx-fragment'+(declared==='true'?' rt=1':declared==='false'?' rt=0':'')+'-->';
|
|
374
374
|
}
|
|
375
|
+
// \u2500\u2500 External scripts inside the routed container \u2500\u2500
|
|
376
|
+
//
|
|
377
|
+
// A page whose x-data factory lives in its own file \u2014 a
|
|
378
|
+
// <script src="dashboard-xdata.js"> sitting inside [data-stx-content] \u2014 lost that
|
|
379
|
+
// file on every SPA navigation. Both swap paths dropped it: the fragment
|
|
380
|
+
// path's regex sees an empty body and returns '', and the full-document path
|
|
381
|
+
// removed it outright. The inline scripts beside it were re-executed with
|
|
382
|
+
// care; the external ones were deleted.
|
|
383
|
+
//
|
|
384
|
+
// The result was a screen that rendered on a cold load and came back empty
|
|
385
|
+
// after a click, reporting "dashboardXData is not defined" with every binding
|
|
386
|
+
// in the container left unevaluated \u2014 because nothing had defined it since
|
|
387
|
+
// the file was thrown away.
|
|
388
|
+
//
|
|
389
|
+
// Loaded once per URL, never re-run. What these files define is a global that
|
|
390
|
+
// outlives the navigation, so a second execution buys nothing and costs
|
|
391
|
+
// whatever side effects the file has: a mount helper firing again on every
|
|
392
|
+
// click through the same page is its own bug.
|
|
393
|
+
var loadedExternalScripts={};
|
|
394
|
+
// The base is resolved first because callers pass what they have: the
|
|
395
|
+
// fragment path knows only the path it navigated to ('/reports/disk'), and
|
|
396
|
+
// new URL(src, '/reports/disk') throws \u2014 a base must be absolute. Silently
|
|
397
|
+
// returning '' there meant the file was never requested, which is the bug
|
|
398
|
+
// this whole block exists to fix, reintroduced one level down.
|
|
399
|
+
function externalScriptKey(src,base){
|
|
400
|
+
try{
|
|
401
|
+
var absoluteBase=base?new URL(base,location.href).href:location.href;
|
|
402
|
+
return new URL(src,absoluteBase).href;
|
|
403
|
+
}catch(e){return ''}
|
|
404
|
+
}
|
|
405
|
+
function rememberExternalScript(src,base){
|
|
406
|
+
var key=externalScriptKey(src,base);
|
|
407
|
+
if(key)loadedExternalScripts[key]=1;
|
|
408
|
+
return key;
|
|
409
|
+
}
|
|
410
|
+
// Returns a promise, or null when there is nothing to wait for \u2014 an already
|
|
411
|
+
// loaded file, or an unparseable src. Resolves rather than rejects on error:
|
|
412
|
+
// one 404 must not stop the rest of the page hydrating, matching what the
|
|
413
|
+
// head-script path already does by sending failures to execScripts too.
|
|
414
|
+
function loadExternalScript(src,base){
|
|
415
|
+
var key=externalScriptKey(src,base);
|
|
416
|
+
if(!key||loadedExternalScripts[key])return null;
|
|
417
|
+
loadedExternalScripts[key]=1;
|
|
418
|
+
return new Promise(function(resolve){
|
|
419
|
+
var el=document.createElement('script');
|
|
420
|
+
el.src=key;
|
|
421
|
+
// Deliberately NOT data-stx-page: both swap paths clear those on every
|
|
422
|
+
// navigation, which would sweep this away and \u2014 since it is never loaded
|
|
423
|
+
// twice \u2014 leave the document without it. These are loaded once and stay,
|
|
424
|
+
// the same as the external head scripts beside them.
|
|
425
|
+
el.setAttribute('data-stx-external','');
|
|
426
|
+
el.onload=function(){resolve()};
|
|
427
|
+
el.onerror=function(){log('[router] container script failed:',key);resolve()};
|
|
428
|
+
document.head.appendChild(el);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
375
432
|
// Record scripts from the initial page load
|
|
376
433
|
document.querySelectorAll('script').forEach(function(s){
|
|
377
434
|
var text=s.textContent||'';
|
|
378
|
-
if(
|
|
435
|
+
if(s.hasAttribute('src'))rememberExternalScript(s.getAttribute('src'));
|
|
436
|
+
else if(text.trim())executedScriptHashes[hashScript(text)]=1;
|
|
379
437
|
});
|
|
380
438
|
function cacheKey(url){
|
|
381
439
|
// Base is the CURRENT document, not the origin root: a relative key like
|
|
@@ -679,6 +737,7 @@ else {
|
|
|
679
737
|
var fragStyles=[];
|
|
680
738
|
var fragCrosswindHrefs=[];
|
|
681
739
|
var fragCrosswindCSS=null;
|
|
740
|
+
var fragExternalScripts=[];
|
|
682
741
|
var cleanFrag=html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/scr'+'ipt>','gi'),function(m,attrs,code){
|
|
683
742
|
// A data block is not code, and everything below this line assumes it
|
|
684
743
|
// is: the body gets stashed in fragScripts, re-emitted as a pending
|
|
@@ -696,6 +755,12 @@ else {
|
|
|
696
755
|
var typeMatch=attrs.match(/\\btype\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))/i);
|
|
697
756
|
var scriptType=((typeMatch&&(typeMatch[1]||typeMatch[2]||typeMatch[3]))||'').trim().toLowerCase();
|
|
698
757
|
if(scriptType&&scriptType!=='text/javascript'&&scriptType!=='application/javascript'&&scriptType!=='module')return m;
|
|
758
|
+
// An external script has no body, so every check below reads it as
|
|
759
|
+
// nothing to run and the fragment loses it. Queue it instead; the
|
|
760
|
+
// file is where the page's factory usually lives.
|
|
761
|
+
var srcMatch=attrs.match(/\\bsrc\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))/i);
|
|
762
|
+
var fragSrc=srcMatch&&(srcMatch[1]||srcMatch[2]||srcMatch[3]);
|
|
763
|
+
if(fragSrc){fragExternalScripts.push(fragSrc);return ''}
|
|
699
764
|
if(code&&code.trim()&&!isSignalsRuntimeScript({hasAttribute:function(name){return name==='data-stx-runtime'&&attrs.indexOf('data-stx-runtime')!==-1}},code)){
|
|
700
765
|
var slot='fragment-'+(++fragScriptId);
|
|
701
766
|
var scoped=/(?:^|\\s)data-stx-scoped(?:\\s|=|$)/i.test(attrs);
|
|
@@ -783,6 +848,7 @@ else {
|
|
|
783
848
|
log('[router] frag scripts:', fragScripts.length);
|
|
784
849
|
document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
785
850
|
fragScripts.sort(function(a,b){return (a.setupName?1:0)-(b.setupName?1:0)});
|
|
851
|
+
function runFragScripts(){
|
|
786
852
|
fragScripts.forEach(function(entry){
|
|
787
853
|
var code=entry.text;
|
|
788
854
|
log('[router] exec script len:', code.length, 'has __stx_setup:', code.indexOf('__stx_setup')>-1);
|
|
@@ -851,6 +917,20 @@ else {
|
|
|
851
917
|
log('[router] scripts done. _latestSetup:', !!(window.stx&&window.stx._latestSetup));
|
|
852
918
|
// THEN fire stx:load \u2014 now _latestSetup is set and processElement has the right scope
|
|
853
919
|
window.dispatchEvent(new Event('stx:load'));
|
|
920
|
+
}
|
|
921
|
+
// The container's own files first, for the same reason as the
|
|
922
|
+
// full-document path: the inline scripts call into them. Only awaited
|
|
923
|
+
// when something actually has to load, so a fragment with no external
|
|
924
|
+
// scripts \u2014 every fragment before this change \u2014 still runs its inline
|
|
925
|
+
// scripts in the same synchronous turn and nothing about its timing
|
|
926
|
+
// moves.
|
|
927
|
+
var fragPending=[];
|
|
928
|
+
fragExternalScripts.forEach(function(src){
|
|
929
|
+
var pending=loadExternalScript(src,url);
|
|
930
|
+
if(pending)fragPending.push(pending);
|
|
931
|
+
});
|
|
932
|
+
if(fragPending.length)Promise.all(fragPending).then(runFragScripts).catch(runFragScripts);
|
|
933
|
+
else runFragScripts();
|
|
854
934
|
}
|
|
855
935
|
return new Promise(function(resolve,reject){
|
|
856
936
|
function completeFragSwap(){
|
|
@@ -1007,12 +1087,15 @@ else {
|
|
|
1007
1087
|
// scripts as placeholders so re-execution keeps document.currentScript
|
|
1008
1088
|
// beside the component template it owns.
|
|
1009
1089
|
var routedBodyScripts=[];
|
|
1090
|
+
var routedExternalScripts=[];
|
|
1010
1091
|
var routedBodyScriptId=0;
|
|
1011
1092
|
function prepareRoutedBodyScripts(root){
|
|
1012
1093
|
if(!root)return;
|
|
1013
1094
|
root.querySelectorAll('script').forEach(function(s){
|
|
1014
1095
|
var text=s.textContent||'';
|
|
1015
|
-
|
|
1096
|
+
// Not discarded: queued against docBase, so a relative src resolves
|
|
1097
|
+
// against the page being navigated to rather than the current URL.
|
|
1098
|
+
if(s.hasAttribute('src')){routedExternalScripts.push(s.getAttribute('src'));s.remove();return}
|
|
1016
1099
|
var type=(s.getAttribute('type')||'').trim().toLowerCase();
|
|
1017
1100
|
var executable=!type||type==='text/javascript'||type==='application/javascript'||type==='module';
|
|
1018
1101
|
if(!executable||!text.trim())return;
|
|
@@ -1076,6 +1159,14 @@ else {
|
|
|
1076
1159
|
}));
|
|
1077
1160
|
});
|
|
1078
1161
|
|
|
1162
|
+
// Before the inline scripts, and through the same barrier: an inline
|
|
1163
|
+
// script's whole reason for existing is often to call into one of these,
|
|
1164
|
+
// so running it first would fail exactly the way this bug did.
|
|
1165
|
+
routedExternalScripts.forEach(function(src){
|
|
1166
|
+
var pending=loadExternalScript(src,docBase);
|
|
1167
|
+
if(pending)extPromises.push(pending);
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1079
1170
|
// \u2500\u2500 Script re-execution \u2500\u2500
|
|
1080
1171
|
// Remove previously injected page scripts
|
|
1081
1172
|
document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
@@ -1685,5 +1776,5 @@ else {
|
|
|
1685
1776
|
|
|
1686
1777
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
1687
1778
|
})();
|
|
1688
|
-
`),L}var L;var be=()=>{};var Ce={};Ae(Ce,{setAppUrl:()=>Z,runMiddleware:()=>
|
|
1689
|
-
export{
|
|
1779
|
+
`),L}var L;var be=()=>{};var Ce={};Ae(Ce,{setAppUrl:()=>Z,runMiddleware:()=>ge,route:()=>te,resolveLayoutChain:()=>A,resetRoutes:()=>re,registerMiddleware:()=>R,patternToRegex:()=>v,navigateTo:()=>se,matchRoute:()=>W,loadMiddlewareFromDirectory:()=>he,isNonPageRoutePattern:()=>m,isNonPageRoutePath:()=>_,hasMiddleware:()=>ce,getRouterScript:()=>we,getMiddlewareNames:()=>de,getMiddleware:()=>j,generateRouteTypes:()=>x,generateRouteManifest:()=>S,formatRoutes:()=>Y,findErrorPage:()=>$,filePathToPattern:()=>k,extractLayoutMetadata:()=>ye,deriveLayoutGroup:()=>q,defineRoutes:()=>ee,defineRoute:()=>Q,defineMiddleware:()=>le,createStorageManager:()=>U,createServerCookieManager:()=>G,createRouter:()=>z,createRouteLocation:()=>pe,createMiddlewareContext:()=>fe,createClientCookieManager:()=>X,clearMiddleware:()=>ue,bracketPathToRegex:()=>D,abortNavigation:()=>ie,Router:()=>C,NON_PAGE_DIRS:()=>g});var Te=u(()=>{J();I();ae();me();N();ve();F();b();be()});
|
|
1780
|
+
export{g as Vt,_ as Wt,m as Xt,x as Yt,S as Zt,k as _t,v as $t,W as au,D as bu,A as cu,C as du,z as eu,$ as fu,Y as gu,Z as hu,Q as iu,ee as ju,te as ku,re as lu,se as mu,ie as nu,le as ou,G as pu,X as qu,U as ru,R as su,j as tu,ce as uu,ue as vu,de as wu,he as xu,pe as yu,fe as zu,ge as Au,q as Bu,ye as Cu,ve as Du,we as Eu,Ce as Fu,Te as Gu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Af as e,Bf as f,Cf as g,Df as h,yf as c,zf as d}from"./chunk-
|
|
2
|
+
import{Af as e,Bf as f,Cf as g,Df as h,yf as c,zf as d}from"./chunk-5qy49drk.js";import{Nf as a,Qf as b}from"./chunk-95t702td.js";import"./chunk-thermrhq.js";import"./chunk-9n0gvfrg.js";import"./chunk-7hrttzad.js";import"./chunk-vr4ycjqv.js";import"./chunk-cbj5a2tk.js";import"./chunk-fmw1mscr.js";import"./chunk-wfsf3vmh.js";import"./chunk-pctsgktp.js";import"./chunk-q0sgqw4m.js";import"./chunk-ecncwde8.js";import"./chunk-fdd1ccv6.js";import"./chunk-yjrdr27z.js";import"./chunk-rrxm5s7d.js";import"./chunk-9qn3f7tp.js";import"./chunk-zpkdfbyp.js";import"./chunk-b9691w0f.js";export{d as virtualPathFor,g as typecheckStxFiles,e as sourcePathFor,h as formatTypecheckDiagnostics,f as findRuntimeTypeDeclarations,b as extractTemplateExpressions,a as extractScriptBlocks,c as buildVirtualSource};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wg as a}from"./chunk-t0dq8bsd.js";import"./chunk-m1qf02qz.js";import"./chunk-7hrttzad.js";import"./chunk-vr4ycjqv.js";import"./chunk-cbj5a2tk.js";import"./chunk-fmw1mscr.js";import"./chunk-wfsf3vmh.js";import"./chunk-pctsgktp.js";import"./chunk-q0sgqw4m.js";import"./chunk-ecncwde8.js";import"./chunk-fdd1ccv6.js";import"./chunk-yjrdr27z.js";import"./chunk-rrxm5s7d.js";import"./chunk-9qn3f7tp.js";import"./chunk-zpkdfbyp.js";import"./chunk-b9691w0f.js";export{a as startProductionServer};
|
|
@@ -6859,8 +6859,39 @@ else {
|
|
|
6859
6859
|
// Only use fallback when we genuinely couldn't find a suitable root element.
|
|
6860
6860
|
// Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
|
|
6861
6861
|
// with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
|
|
6862
|
+
|
|
6863
|
+
// An x-data root that initScope has not claimed yet is not ours to mount.
|
|
6864
|
+
//
|
|
6865
|
+
// The element carries its own state expression and the reactive runtime
|
|
6866
|
+
// owns it; data-stx-scope is on it from the server, but the id is not
|
|
6867
|
+
// in stx._scopes until initScope runs, which on a navigation happens
|
|
6868
|
+
// later in the stx:load handler. Mounting it in the meantime binds its
|
|
6869
|
+
// whole subtree against whatever scope the mounting script brought.
|
|
6870
|
+
//
|
|
6871
|
+
// That is what a layout script did after every SPA navigation. Its own
|
|
6872
|
+
// re-executed script now lands inside the content container next to the
|
|
6873
|
+
// incoming page, so previousElementSibling resolved to the *page's*
|
|
6874
|
+
// x-data root; mount() adopted it and ran processElement over it with the
|
|
6875
|
+
// sidebar's scope. Every :for template inside was consumed against a
|
|
6876
|
+
// scope holding none of the page's data, and bindFor replaces each
|
|
6877
|
+
// template with its stx-for anchor on that single pass \u2014 so the markup a
|
|
6878
|
+
// retry needed was gone, and the effect had read no signal to re-run on.
|
|
6879
|
+
// The list stayed empty for the life of the page while its state sat
|
|
6880
|
+
// fully populated beside it. Cold loads never hit it: there the page's
|
|
6881
|
+
// own script mounts first, with the right scope.
|
|
6882
|
+
//
|
|
6883
|
+
// Registered scopes are left alone, so an element the reactive runtime
|
|
6884
|
+
// has already initialised keeps whatever behaviour it had.
|
|
6885
|
+
function awaitingReactiveInit(el) {
|
|
6886
|
+
if (!el || !el.hasAttribute || !el.hasAttribute('data-stx-xdata'))
|
|
6887
|
+
return false;
|
|
6888
|
+
var id = el.getAttribute('data-stx-scope');
|
|
6889
|
+
return !(id && window.stx && window.stx._scopes && window.stx._scopes[id]);
|
|
6890
|
+
}
|
|
6891
|
+
|
|
6862
6892
|
var needsFallback = !root || root === document.body
|
|
6863
|
-
|| (root && root.tagName === 'SCRIPT')
|
|
6893
|
+
|| (root && root.tagName === 'SCRIPT')
|
|
6894
|
+
|| awaitingReactiveInit(root);
|
|
6864
6895
|
if (needsFallback) {
|
|
6865
6896
|
var routerOpts = window.STX_ROUTER_OPTIONS || window.__stxRouterConfig || {};
|
|
6866
6897
|
var container = document.querySelector('[data-stx-content]')
|
|
@@ -6878,14 +6909,24 @@ else {
|
|
|
6878
6909
|
if (children[ci].__stx_scope) { hasMount = true; break; }
|
|
6879
6910
|
}
|
|
6880
6911
|
if (hasMount) for (var ci = 0; ci < children.length; ci++) {
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6912
|
+
var candidate = children[ci];
|
|
6913
|
+
if (candidate.__stx_scope || candidate.tagName === 'SCRIPT') continue;
|
|
6914
|
+
if (awaitingReactiveInit(candidate)) continue;
|
|
6915
|
+
root = candidate;
|
|
6916
|
+
break;
|
|
6885
6917
|
}
|
|
6886
6918
|
}
|
|
6887
6919
|
}
|
|
6888
6920
|
|
|
6921
|
+
// The fallback can still land on one (a container whose only unmounted
|
|
6922
|
+
// child is the incoming page). Processing the container instead is safe:
|
|
6923
|
+
// processElement skips [data-stx-scope] children, so the reactive
|
|
6924
|
+
// runtime keeps its subtree and binds it with the right scope.
|
|
6925
|
+
if (awaitingReactiveInit(root)) {
|
|
6926
|
+
var reactiveOwnerParent = root.parentElement;
|
|
6927
|
+
root = reactiveOwnerParent && reactiveOwnerParent !== document.body ? reactiveOwnerParent : null;
|
|
6928
|
+
}
|
|
6929
|
+
|
|
6889
6930
|
if (!root) { console.warn('[stx] mount: no root element found'); return; }
|
|
6890
6931
|
|
|
6891
6932
|
// Set component context for defineProps/defineEmits (Phase 4)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$k as b,_k as a,al as c,bl as d,cl as e,dl as f,el as g,fl as h,gl as i,hl as j}from"./chunk-
|
|
2
|
+
import{$k as b,_k as a,al as c,bl as d,cl as e,dl as f,el as g,fl as h,gl as i,hl as j}from"./chunk-4zpmg5ct.js";import"./chunk-0ha9e1wt.js";import"./chunk-7hrttzad.js";import"./chunk-vr4ycjqv.js";import"./chunk-cbj5a2tk.js";import"./chunk-fmw1mscr.js";import"./chunk-wfsf3vmh.js";import"./chunk-pctsgktp.js";import"./chunk-q0sgqw4m.js";import"./chunk-ecncwde8.js";import"./chunk-fdd1ccv6.js";import"./chunk-yjrdr27z.js";import"./chunk-rrxm5s7d.js";import"./chunk-9qn3f7tp.js";import"./chunk-zpkdfbyp.js";import"./chunk-b9691w0f.js";export{b as shouldLogBundlerDiagnostics,f as setBundlerFallbackMode,g as resolveBundlerFallback,c as recordBundleFailure,i as queueClientBundleBuild,h as hasUserImports,d as getBundleFailures,a as clientBundleDependencies,e as clearBundleFailures,j as bundleClientScript};
|