@stacksjs/stx 0.2.531 → 0.2.532
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-c9rwnsk7.js → chunk-0p9pwd61.js} +1 -1
- package/dist/{chunk-rsy1r1t2.js → chunk-0pebjkzx.js} +2 -2
- package/dist/{chunk-tyts58ks.js → chunk-1945hk44.js} +1 -1
- package/dist/{chunk-88kjwkza.js → chunk-28xtazwz.js} +1 -1
- package/dist/{chunk-785ckss2.js → chunk-29qwmthc.js} +1 -1
- package/dist/{chunk-ym182eg0.js → chunk-323cxa69.js} +1 -1
- package/dist/chunk-375zp0vr.js +2 -0
- package/dist/{chunk-csjax0ej.js → chunk-3w49r16x.js} +1 -1
- package/dist/{chunk-hrrxggpx.js → chunk-4gt0r98p.js} +61 -10
- package/dist/{chunk-b0tmg1q1.js → chunk-4xxhprts.js} +1 -1
- package/dist/{chunk-mc5agc81.js → chunk-664503e6.js} +1 -1
- package/dist/{chunk-4cyjdghc.js → chunk-8gmb3k1p.js} +1 -1
- package/dist/chunk-a15yzfc6.js +2 -0
- package/dist/{chunk-wv2crxm6.js → chunk-d4155ec5.js} +1 -1
- package/dist/{chunk-cxxcy624.js → chunk-ee4wwr89.js} +2 -2
- package/dist/{chunk-m5gdwq1d.js → chunk-f2q5bckn.js} +1 -1
- package/dist/chunk-fhx35529.js +2 -0
- package/dist/{chunk-mwte3cbe.js → chunk-g060jncp.js} +1 -1
- package/dist/{chunk-qwpgggkj.js → chunk-g5t10z04.js} +18 -18
- package/dist/{chunk-fmp8dmt0.js → chunk-grb3kfya.js} +1 -1
- package/dist/{chunk-tvssmzc2.js → chunk-gvw8wh29.js} +1 -1
- package/dist/chunk-h1y5q942.js +2 -0
- package/dist/{chunk-bnsz09pg.js → chunk-heq5c0gd.js} +1 -1
- package/dist/{chunk-srcv6wvm.js → chunk-hp1tnxzb.js} +2 -2
- package/dist/chunk-j3b24e77.js +2 -0
- package/dist/{chunk-w3xs6kb9.js → chunk-j8pacd7m.js} +2 -2
- package/dist/{chunk-5yg6m30k.js → chunk-jpck8nm5.js} +1 -1
- package/dist/{chunk-d3mssbgp.js → chunk-khwj964t.js} +4 -4
- package/dist/{chunk-9f3m5ecs.js → chunk-m2v04c6v.js} +5 -5
- package/dist/{chunk-dptjyncv.js → chunk-ng2sdph7.js} +1 -1
- package/dist/{chunk-s5cb4hkj.js → chunk-qs3p7sc6.js} +1 -1
- package/dist/{chunk-6qzjyr8e.js → chunk-rk4mttds.js} +1 -1
- package/dist/{chunk-xda69f13.js → chunk-rma3bv36.js} +1 -1
- package/dist/{chunk-et8ejd7k.js → chunk-rp5a91ak.js} +1 -1
- package/dist/{chunk-v38kqjew.js → chunk-rs46hksk.js} +1 -1
- package/dist/{chunk-z14e2qyn.js → chunk-rwn3b21z.js} +1 -1
- package/dist/{chunk-3dd5zxbt.js → chunk-sp5x96rn.js} +1 -1
- package/dist/{chunk-7b2hj6nt.js → chunk-stbsqy7e.js} +1 -1
- package/dist/{chunk-5achv4zv.js → chunk-t61j834x.js} +1 -1
- package/dist/{chunk-m5c2gts6.js → chunk-t6769zcy.js} +1 -1
- package/dist/{chunk-8h1zg44w.js → chunk-v2vg5jqq.js} +1 -1
- package/dist/chunk-w6ecbk3y.js +2 -0
- package/dist/{chunk-j4rb9rxx.js → chunk-wfbr3txe.js} +1 -1
- package/dist/{chunk-nz5ekyxn.js → chunk-wwny5dk9.js} +1 -1
- package/dist/{chunk-8jtyra19.js → chunk-x55avrcf.js} +1 -1
- package/dist/{chunk-95z7yemm.js → chunk-xb0785wp.js} +1 -1
- package/dist/{chunk-8n7qsr17.js → chunk-xdtz2v5r.js} +1 -1
- package/dist/{chunk-ktmacsqc.js → chunk-y4qks0bd.js} +1 -1
- package/dist/{chunk-cp8f1pv4.js → chunk-y7ds4qyb.js} +1 -1
- package/dist/{chunk-1wt5fagh.js → chunk-yts2745t.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/runtime/native-host.js +4 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-1cdanx2v.js +0 -2
- package/dist/chunk-3v91cb0g.js +0 -2
- package/dist/chunk-g1kyy5h1.js +0 -2
- package/dist/chunk-hvvbppt4.js +0 -2
- package/dist/chunk-ka7qdsha.js +0 -2
- package/dist/chunk-vk18649m.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fd,Co,za,gd,md,hd,yd,bd,Ha,Va,wd,vd,xd,Sd}from"./chunk-
|
|
2
|
+
import{fd,Co,za,gd,md,hd,yd,bd,Ha,Va,wd,vd,xd,Sd}from"./chunk-g060jncp.js";import"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{za as SUSPENSE_RESOLVER_RUNTIME,Co as buildSuspenseResolveScript,bd as createStreamRenderer,hd as extractStreamBoundaries,Sd as generateHydrationRuntime,Va as islandDirective,vd as processSectionDirectives,md as processStreamDirectives,wd as registerStreamingDirectives,gd as renderStreamingPage,fd as streamTemplate,yd as streamTemplateSimple,xd as streamToResponse,Ha as streamingSuspenseDirective};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fn,Le,Be,ye,ei,Wn,Q,X,ln,d,n,R}from"./chunk-
|
|
2
|
+
import{Fn,Le,Be,ye,ei,Wn,Q,X,ln,d,n,R}from"./chunk-g5t10z04.js";import{dirname as k,resolve as _}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function C(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(s,p){let u;while((u=s.exec(o))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:m}=Fn(o),c=await(e.renderer??((s)=>Le(s)))(m);return{html:C(c),frontmatter:r??{}}}function v(o){let e=o,r=Q(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],f=u[0],g=i.includes("server");if(p(l))s.push(f);else if(g)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let g=l.index+l[0].length,x=t.indexOf("</script>",g);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let g=f.length-1;g>=0;g--)t=t.substring(0,f[g].start)+t.substring(f[g].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function M(o,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -14,5 +14,5 @@ ${c.join(`
|
|
|
14
14
|
`)}`}else{if(r.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=Be(p),g=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await ye(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
|
|
15
15
|
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${g}
|
|
16
16
|
$1`);else t+=`
|
|
17
|
-
${g}`}t=await X(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
17
|
+
${g}`}t=await X(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-yts2745t.js");t=await i(t)}catch{}return t}
|
|
18
18
|
export{Oo};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
|
|
3
|
-
`),n;try{let{bundleClientScript:t}=await import("./chunk-
|
|
3
|
+
`),n;try{let{bundleClientScript:t}=await import("./chunk-v2vg5jqq.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-t94z65ry.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-ng2sdph7.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-zpftj8s8.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
|
|
4
4
|
`)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Yd,wc,ds,us,ci,li,ps,gs,Xn,vc,di,ui,xc,We}from"./chunk-
|
|
2
|
+
import{Yd,wc,ds,us,ci,li,ps,gs,Xn,vc,di,ui,xc,We}from"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{Yd as clearScriptScanCache,ps as convertServerLoopAttributesToDirectives,ci as convertSignalDirectivesToAttributes,gs as convertSignalLoopsToAttributes,vc as extractExports,ui as findMarkupIndexOutsideScripts,us as hasSignalsSyntax,ds as parseLoopExpression,li as preEvalLiteralReactiveIfs,Xn as processScriptSetup,di as processSignals,xc as rewriteStxImportSpecifiers,wc as scanScriptTags,We as stripStxRuntimeImports};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rs,ss,os,Gd,qn,Jd}from"./chunk-
|
|
2
|
+
import{rs,ss,os,Gd,qn,Jd}from"./chunk-g5t10z04.js";export{qn as clearImageDeliveryCatalog,Gd as deliveredImage,os as efficientDeliverySources,rs as getImageDelivery,ss as isTransparentImage,Jd as prepareImageDelivery};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zs,Hs,tt,J,kn,ur,Cn,pr,fr,Vc,Uc,Wc,En,qc,Kc,Xc,Gc,Ui,Wi,qi,Vs,Ki,Jc,nt,rt,st,ot,it,at,Ee,Yc}from"./chunk-
|
|
2
|
+
import{zs,Hs,tt,J,kn,ur,Cn,pr,fr,Vc,Uc,Wc,En,qc,Kc,Xc,Gc,Ui,Wi,qi,Vs,Ki,Jc,nt,rt,st,ot,it,at,Ee,Yc}from"./chunk-4gt0r98p.js";export{Cn as Router,Xc as abortNavigation,ur as bracketPathToRegex,nt as clearMiddleware,Wi as createClientCookieManager,it as createMiddlewareContext,ot as createRouteLocation,Ui as createServerCookieManager,qi as createStorageManager,Gc as defineMiddleware,Uc as defineRoute,Wc as defineRoutes,pr as findErrorPage,fr as formatRoutes,Hs as generateRouteManifest,zs as generateRouteTypes,Ki as getMiddleware,rt as getMiddlewareNames,Ee as getRouterScript,Yc as getRouterScriptDev,Jc as hasMiddleware,tt as isFileRequestPath,st as loadMiddlewareFromDirectory,kn as matchRoute,Kc as navigateTo,J as patternToRegex,Vs as registerMiddleware,qc as resetRoutes,En as route,at as runMiddleware,Vc as setAppUrl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xi,Gi}from"./chunk-m2v04c6v.js";import"./chunk-gvw8wh29.js";import"./chunk-xb0785wp.js";import"./chunk-zzphh8g9.js";import"./chunk-q6e45gnw.js";import"./chunk-4xxhprts.js";import"./chunk-0dqxnx20.js";import"./chunk-stbsqy7e.js";import{co}from"./chunk-hp1tnxzb.js";import"./chunk-p8qr0q85.js";import"./chunk-38w14qs7.js";import"./chunk-rs46hksk.js";import"./chunk-jjwg83xv.js";import"./chunk-2y6tzn6d.js";import"./chunk-rwn3b21z.js";import"./chunk-15r72kw7.js";import"./chunk-rtk6n3vh.js";import"./chunk-7s14bthq.js";import"./chunk-90wh9zzy.js";import"./chunk-b7xdk1g4.js";import"./chunk-xcfhy5bj.js";import"./chunk-9a73re8k.js";import"./chunk-y7ds4qyb.js";import"./chunk-xab6b4mt.js";import"./chunk-03wggzg8.js";import"./chunk-ennxrn5g.js";import"./chunk-yn3kp3qy.js";import"./chunk-g12j8ahm.js";import"./chunk-xdtz2v5r.js";import"./chunk-3vvppnws.js";import"./chunk-g060jncp.js";import"./chunk-0pebjkzx.js";import"./chunk-458etq5a.js";import"./chunk-wk85dz07.js";import"./chunk-664503e6.js";import"./chunk-ee4wwr89.js";import"./chunk-azb58ven.js";import{ye,sn,on,X,d,n,Zn,R,o,de}from"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{Zn as buildWebComponents,on as cacheTemplate,sn as checkCache,co as classifyAllScripts,Xi as createMiddleware,Gi as createRoute,R as defaultConfig,d as extractVariables,X as injectRouterScript,o as loadStxConfig,ye as processClientScript,n as processDirectives,de as readMarkdownFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R,Fc,o,A,tu,nu}from"./chunk-
|
|
2
|
+
import{R,Fc,o,A,tu,nu}from"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{A as config,R as defaultConfig,tu as defineStxConfig,o as loadStxConfig,Fc as resolveStxDirectories,nu as validateConfig};
|
|
@@ -141,7 +141,13 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
141
141
|
releaseScrollHold();
|
|
142
142
|
var reached=function(){return Math.abs((window.pageYOffset||window.scrollY||0)-y)<2};
|
|
143
143
|
if(typeof ResizeObserver!=='function')return;
|
|
144
|
-
var h={stop:releaseScrollHold,ro:null,timer:0,onScroll:null,anchor:null,win:window,root:document.documentElement};
|
|
144
|
+
var h={stop:releaseScrollHold,ro:null,timer:0,onScroll:null,anchor:null,win:window,root:document.documentElement,seen:{}};
|
|
145
|
+
// Every place the page was at while the hold kept it: where the hold put
|
|
146
|
+
// it, and where the page's own height clamped it as it grew and shrank.
|
|
147
|
+
// Their scroll events arrive a frame later, when the height they were
|
|
148
|
+
// clamped to may be gone, so they are recognised by place, not by height.
|
|
149
|
+
var note=function(){h.seen[Math.round(window.pageYOffset||window.scrollY||0)]=true};
|
|
150
|
+
note();
|
|
145
151
|
// Scroll anchoring off while held: content filling in above the place
|
|
146
152
|
// would otherwise carry the window down with it (Chrome keeps what is
|
|
147
153
|
// on screen in view), and Back landed thousands of pixels past it.
|
|
@@ -151,8 +157,11 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
151
157
|
// Held for the whole window even once reached: a page that is tall
|
|
152
158
|
// enough when it is put back is often still drawing, above the place
|
|
153
159
|
// as much as below it.
|
|
154
|
-
if(scrollHold!==h
|
|
160
|
+
if(scrollHold!==h)return;
|
|
161
|
+
note();
|
|
162
|
+
if(reached())return;
|
|
155
163
|
window.scrollTo({left:x,top:y,behavior:'instant'});
|
|
164
|
+
note();
|
|
156
165
|
});
|
|
157
166
|
h.ro.observe(document.body||document.documentElement);
|
|
158
167
|
h.timer=setTimeout(releaseScrollHold,4000);
|
|
@@ -163,7 +172,7 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
163
172
|
h.onScroll=function(){
|
|
164
173
|
var at=window.pageYOffset||window.scrollY||0;
|
|
165
174
|
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;
|
|
175
|
+
if(Math.abs(at-y)<2||(at<y&&at>=end-1)||h.seen[Math.round(at)])return;
|
|
167
176
|
releaseScrollHold();
|
|
168
177
|
};
|
|
169
178
|
window.addEventListener('scroll',h.onScroll,{passive:true});
|
|
@@ -752,6 +761,35 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
752
761
|
var scopeId=root.getAttribute('data-stx-scope');
|
|
753
762
|
return !!scopeId&&code.indexOf(scopeId)!==-1;
|
|
754
763
|
}
|
|
764
|
+
// A script inside an :if (or :else) template runs when the branch is
|
|
765
|
+
// drawn: on a whole page the browser runs it as the runtime clones the
|
|
766
|
+
// template into the page, which is how a component used under :if gets its
|
|
767
|
+
// scope. A fragment's scripts are all turned into inert placeholders, and
|
|
768
|
+
// one inside template.content is out of the router's reach, so it never ran
|
|
769
|
+
// at all: the component's markup appeared with no setup behind it (an
|
|
770
|
+
// <OuraRecovery :if> on a page reached by a link stayed empty). Such a
|
|
771
|
+
// placeholder is made a live script again, so the branch runs it exactly as
|
|
772
|
+
// a whole page would. Loop templates keep theirs inert: bindFor runs those per
|
|
773
|
+
// row. Returns the slots it handed over, for runFragScripts to leave alone.
|
|
774
|
+
function armBranchScripts(root,slots){
|
|
775
|
+
if(!root||!root.querySelectorAll)return slots;
|
|
776
|
+
root.querySelectorAll('template').forEach(function(template){
|
|
777
|
+
if(hasLoopAttr(template)||!template.content)return;
|
|
778
|
+
template.content.querySelectorAll('script[type="application/stx-pending"][data-stx-route-script]').forEach(function(script){
|
|
779
|
+
if(script.hasAttribute('data-stx-scoped')&&loopOwnsScopedScript(script,script.textContent||''))return;
|
|
780
|
+
slots[script.getAttribute('data-stx-route-script')]=true;
|
|
781
|
+
// A new element, not the placeholder untyped: a script parsed by
|
|
782
|
+
// innerHTML is marked as already run, and so is every clone of it.
|
|
783
|
+
var live=script.ownerDocument.createElement('script');
|
|
784
|
+
var names=script.getAttributeNames?script.getAttributeNames():Array.prototype.map.call(script.attributes,function(a){return a.name});
|
|
785
|
+
names.forEach(function(name){if(name!=='type')live.setAttribute(name,script.getAttribute(name))});
|
|
786
|
+
live.textContent=script.textContent;
|
|
787
|
+
script.parentNode.replaceChild(live,script);
|
|
788
|
+
});
|
|
789
|
+
armBranchScripts(template.content,slots);
|
|
790
|
+
});
|
|
791
|
+
return slots;
|
|
792
|
+
}
|
|
755
793
|
// A component scope script names the root it binds in data-stx-owner (#1958).
|
|
756
794
|
// On navigation it runs only for a root that just ARRIVED: one swapped in
|
|
757
795
|
// with the new content, which is not bound yet. A layout component that
|
|
@@ -1189,6 +1227,7 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1189
1227
|
isNavigating=false;navAbort=null;
|
|
1190
1228
|
document.body.classList.remove(o.loadingClass);finishProgress();
|
|
1191
1229
|
settleDirection();
|
|
1230
|
+
if(openingUrl&&location.pathname+location.search!==openingUrl)keepOpeningPage();
|
|
1192
1231
|
}
|
|
1193
1232
|
function stale(){return id!==navSeq}
|
|
1194
1233
|
// A failed fetch keeps the app: the destination shows a way to try again
|
|
@@ -1667,6 +1706,7 @@ else {
|
|
|
1667
1706
|
return '<scr'+'ipt type="application/stx-pending" data-stx-route-script="'+slot+'"'
|
|
1668
1707
|
+(scoped?' data-stx-scoped':'')
|
|
1669
1708
|
+(runDecl?' data-stx-run="'+runDecl.toLowerCase()+'"':'')
|
|
1709
|
+
+(ownerDecl?' data-stx-owner="'+ownerDecl+'"':'')
|
|
1670
1710
|
+'>'+code+'<\\/scr'+'ipt>';
|
|
1671
1711
|
}
|
|
1672
1712
|
return '';
|
|
@@ -1727,6 +1767,7 @@ else {
|
|
|
1727
1767
|
if(scr)scr.cattrs=pendingContainerAttrs;
|
|
1728
1768
|
applyContainerAttrs(host,pendingContainerAttrs);
|
|
1729
1769
|
currentContent.innerHTML=cleanFrag;
|
|
1770
|
+
var branchSlots=armBranchScripts(currentContent,{});
|
|
1730
1771
|
// Remove old page scripts
|
|
1731
1772
|
qsa('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
1732
1773
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
|
@@ -1753,6 +1794,10 @@ else {
|
|
|
1753
1794
|
fragScripts.forEach(function(entry){
|
|
1754
1795
|
var code=entry.text;
|
|
1755
1796
|
log('[router] exec script len:', code.length, 'has __stx_setup:', code.indexOf('__stx_setup')>-1);
|
|
1797
|
+
if(branchSlots&&branchSlots[entry.slot]){
|
|
1798
|
+
log('[router] leaving a branch script to its :if');
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1756
1801
|
var placeholder=qs('script[data-stx-route-script="'+entry.slot+'"]');
|
|
1757
1802
|
var nestedScopedTemplate=false;
|
|
1758
1803
|
var scopedLoopSetup=false;
|
|
@@ -3537,14 +3582,22 @@ else {
|
|
|
3537
3582
|
// The page the app was opened on came as a whole document, so it is the
|
|
3538
3583
|
// one page the cache never holds: Back to it went to the server and left
|
|
3539
3584
|
// the page being read on screen under the new address until it answered
|
|
3540
|
-
// (a second or more on a distant server). Once the
|
|
3541
|
-
// fragment is fetched, the same request a link
|
|
3542
|
-
// is a swap like every other.
|
|
3585
|
+
// (a second or more on a distant server). Once the router has taken the
|
|
3586
|
+
// person somewhere else its fragment is fetched, the same request a link
|
|
3587
|
+
// to it would make, so Back is a swap like every other.
|
|
3588
|
+
//
|
|
3589
|
+
// Not before: the fragment is answered no-store, and a document that has
|
|
3590
|
+
// fetched a no-store response is kept out of the back/forward cache. Done
|
|
3591
|
+
// on load, it cost the opening page its instant restore when the person
|
|
3592
|
+
// left the app and came back (a full-document Back). A router navigation
|
|
3593
|
+
// has already fetched one, so after it nothing more is lost.
|
|
3594
|
+
var openingUrl=location.pathname+location.search;
|
|
3543
3595
|
function keepOpeningPage(){
|
|
3544
|
-
|
|
3596
|
+
var url=openingUrl;
|
|
3597
|
+
openingUrl='';
|
|
3598
|
+
if(!url||!o.prefetch||o.keepOpening===false||!o.cache||!shouldUseFragmentResponse())return;
|
|
3545
3599
|
var c=navigator.connection;
|
|
3546
3600
|
if(c&&(c.saveData||/2g/.test(c.effectiveType||'')))return;
|
|
3547
|
-
var url=location.pathname+location.search;
|
|
3548
3601
|
var key=cacheKey(url);
|
|
3549
3602
|
// Late by design, so it can find the page gone (a test's document torn
|
|
3550
3603
|
// down, a full navigation begun): never let that throw from a timer.
|
|
@@ -3840,8 +3893,6 @@ else {
|
|
|
3840
3893
|
restoreKeptPages();
|
|
3841
3894
|
prefetchEager();
|
|
3842
3895
|
observeLinks();
|
|
3843
|
-
// The runtime's first stx:load has usually gone by when this runs.
|
|
3844
|
-
if(o.prefetch&&o.keepOpening!==false)keepOpeningPage();
|
|
3845
3896
|
}
|
|
3846
3897
|
|
|
3847
3898
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y}from"./chunk-5tj6expd.js";import{q,Ue,is,as,ti,ni,ri,si,Kn,cs,oi,ii,ai,_t,o}from"./chunk-
|
|
2
|
+
import{y}from"./chunk-5tj6expd.js";import{q,Ue,is,as,ti,ni,ri,si,Kn,cs,oi,ii,ai,_t,o}from"./chunk-g5t10z04.js";import{Br}from"./chunk-y7ds4qyb.js";import{a}from"./chunk-4cmqjmqr.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=_t.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function sa(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=cs(e)+as(is(e.code)),l=e.kind==="client"||e.kind==="plain"?ri(t,e.code):"";return Kn(`${u+i}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nn,ce}from"./chunk-azb58ven.js";import{m,rn,w,je,o,A}from"./chunk-
|
|
2
|
+
import{nn,ce}from"./chunk-azb58ven.js";import{m,rn,w,je,o,A}from"./chunk-g5t10z04.js";import{Jr}from"./chunk-ee4wwr89.js";import{s,ve}from"./chunk-7wfh2hqy.js";import{a}from"./chunk-4cmqjmqr.js";import h from"path";import v from"fs";var pe=10;function V(e,n,i){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(h.basename(e))||Jr(e,n,i)}var ne=1,re=new Map,W=600,fe=100,P=new Map;async function me(e){let n=P.get(e)??0;if(n>0&&n<fe){P.set(e,n+1);return}P.set(e,1);try{let i=(await v.promises.readdir(e)).filter((u)=>u.endsWith(".js"));if(i.length<=W)return;let g=(await Promise.all(i.map(async(u)=>{try{return{name:u,at:(await v.promises.stat(h.join(e,u))).mtimeMs}}catch{return null}}))).filter((u)=>u!==null);g.sort((u,l)=>l.at-u.at);for(let u of g.slice(W)){let l=u.name.slice(0,-3);await v.promises.rm(h.join(e,`${l}.js`),{force:!0}),await v.promises.rm(h.join(e,`${l}.deps.json`),{force:!0})}I("pruned bundle cache to",W,"entries")}catch{}}function ae(e){return re.get(e)??[]}function X(e,n){if(e)re.set(e,n)}function Ja(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function I(...e){if(Ja())console.log("[stx:bundler]",...e)}var Z=[];function Vo(e,n,i){Z.push({filePath:e||"<inline>",message:n,details:i})}function yt(){return Z.slice()}function bt(){Z.length=0}var q;function Pd(e){q=e}function Uo(){if(q)return q;try{let e=A.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var H=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function wt(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,i;while((i=n.exec(e))!==null){let g=i[1];if(!H.some((l)=>l.test(g)))return I("detected user import:",g),!0}let c=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((i=c.exec(e))!==null){let g=i[1];if(/\.css(?:\?.*)?$/.test(g))continue;if(!H.some((l)=>l.test(g)))return I("detected side-effect import:",g),!0}return!1}var tn="stx-module:",ge=/\.(?:[cm]?[jt]sx?|json)$/i;function Ya(e,n){return h.relative(e,n).split(h.sep).join("/")}function Za(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(i,c,g,u)=>{let l=n.get(u);return l&&!u.startsWith(tn)?`${c}${g}${l}${g}`:i})}function Qa(e,n){let i=0,c=(u)=>{let l=`__stxMod${i++}`,S=JSON.stringify(u);return n.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${S}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(S)} + " is not registered on this page (#1957)");`),l},g=(u,l)=>{for(let S of u.split(",")){let M=S.trim();if(!M)continue;let f=M.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;let t=f[1].startsWith('"')?JSON.parse(f[1]):f[1],r=f[2]??t;n.push(`var ${r} = ${l}[${JSON.stringify(t)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(u,l,S)=>{let M=S.slice(tn.length),f=c(M),t=l.trim(),r=t.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!t.startsWith("{")&&!t.startsWith("*"))n.push(`var ${r[1]} = ${f}.default;`),t=t.slice(r[0].length).trim();let d=t.match(/^\*\s*as\s+([\w$]+)$/);if(d)n.push(`var ${d[1]} = ${f};`);else if(t.startsWith("{"))g(t.replace(/^\{|\}$/g,""),f);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(u,l)=>(c(l.slice(tn.length)),"")),e}function ee(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,h.join(e,"index.ts"),h.join(e,"index.tsx"),h.join(e,"index.js"),h.join(e,"index.mjs")];for(let i of n)try{if(v.existsSync(i)&&v.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return}function he(e,n,i,c,g,u=new Map,l){let S=(f,t,r)=>{if(V(t,e,l))return null;if(!g||f!==i||!ge.test(t))return null;try{if(!v.statSync(t,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(t);let d=`${tn}${Ya(process.cwd(),t)}`;return u.set(r,d),{path:d,external:!0}},M=(f,t)=>{let r=f===i?n:h.dirname(f),d=h.resolve(r,t);return ee(d)??d};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(t)=>({path:t.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(t)=>({path:t.path,external:!0})),f.onResolve({filter:/^\//},(t)=>{let r=ee(t.path);if(r){let d=S(t.importer,r,t.path);if(d)return d;if(r!==i)c.add(r);return{path:r}}return{path:t.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(t)=>{let r=M(t.importer,t.path),d=S(t.importer,r,t.path);if(d)return d;return c.add(r),{path:r}}),f.onResolve({filter:/^[@~]\//},(t)=>{let r=h.resolve(e,t.path.slice(2)),d=[r,`${r}.ts`,`${r}.tsx`,`${r}.js`,`${r}.mjs`,`${r}.jsx`,h.join(r,"index.ts"),h.join(r,"index.tsx"),h.join(r,"index.js"),h.join(r,"index.mjs")];for(let E of d)if(v.existsSync(E)&&v.statSync(E,{throwIfNoEntry:!1})?.isFile()){let C=S(t.importer,E,t.path);if(C)return C;return I(`resolved ${t.path[0]}/ import:`,t.path,"\u2192",E),c.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${t.path[0]}/ import:`,t.path),{path:r}}),g)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(t)=>{if(t.importer!==i)return;let r=`${tn}npm:${t.path}`;return u.set(t.path,r),{path:r,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(t)=>{if(V(t.path,e,l))throw Error(`Server-only API source cannot be imported by a client script: ${t.path}`);let r=h.extname(t.path).toLowerCase(),d=r===".json"?"json":r===".tsx"?"tsx":r===".jsx"?"jsx":r===".ts"||r===".mts"||r===".cts"?"ts":"js";if(t.path!==i)c.add(t.path);return{contents:v.readFileSync(t.path,"utf8"),loader:d}})}}}var G=new Map,L=m(64),te=Symbol.for("stx.client-bundle-build-queue");function ec(e){let n=globalThis,c=(n[te]??Promise.resolve()).then(e,e);return n[te]=c.then(()=>{return},()=>{return}),c}async function vt(e,n,i={}){let c=i.projectRoot||process.cwd(),g=(await o(c)).serverApi,u=i.minify??!1,l=i.externalizeUserModules??!0,S=i.expose?.length?[...new Set(i.expose)].sort():void 0,M=i.cacheDir||a(c,"bundle-cache"),f=new Bun.CryptoHasher("md5");f.update(`${pe}\x00${je()}\x00${JSON.stringify(g??!1)}\x00${l?"registry":"inline"}\x00${S?S.join(","):"*"}\x00${e}\x00${n}`);let t=f.digest("hex").slice(0,12),r=h.join(M,`${t}.js`),d=L.get(r);if(d){if(rn(d.files)&&d.files.every((N)=>!V(N.path,c,g))){I("memo hit:",t);let N=d.files.map((B)=>B.path);return X(n,N),i.collectInputs?.push(...N),d.code}L.delete(r),I("memo invalidated by dep change:",t)}let E=h.join(M,`${t}.deps.json`),C=Bun.file(r);if(await C.exists()){let N=Bun.file(E),B=!1,R=null;if(await N.exists())try{let O=JSON.parse(await N.text());if(O.metadataVersion!==ne||!Array.isArray(O.files))B=!1;else R=O.files,B=!0;if(R&&(!rn(R)||R.some((D)=>V(D.path,c,g))))B=!1}catch{B=!1}if(B){if(I("cache hit:",t),R)X(n,R.map((D)=>D.path)),i.collectInputs?.push(...R.map((D)=>D.path));let O=await C.text();if(R)L.set(r,{code:O,files:R});return O}I("cache invalidated by dep change:",t)}let _=G.get(t);if(_){let N=await _;if(i.collectInputs)i.collectInputs.push(...(L.get(r)?.files??[]).map((B)=>B.path));return N}let z=ec(()=>$e(e,n,{projectRoot:c,minify:u,cacheDir:M,hash:t,cachePath:r,depsPath:E,collectInputs:i.collectInputs,externalizeUserModules:l,serverApi:g,expose:S,throwOnFailure:i.throwOnFailure}));G.set(t,z);try{return await z}finally{G.delete(t)}}var xe=0;function tc(e){return`${e}-${process.pid}-${++xe}`}async function $e(e,n,i){let{projectRoot:c,minify:g,cacheDir:u,hash:l,cachePath:S,depsPath:M,externalizeUserModules:f}=i,t=a(c,"bundle-tmp"),r=tc(l),d=h.join(t,`${r}.ts`),E=h.join(t,"out",r);v.mkdirSync(t,{recursive:!0}),v.mkdirSync(E,{recursive:!0});let C=h.dirname(n),_=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,N=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,B=s(e),{depths:R,balanced:O}=ve(B),D=(j)=>!O||R[j]===0,y;while((y=z.exec(B))!==null){if(y[1])continue;if(!D(y.index))continue;if(y[2])y[2].split(",").forEach((j)=>{let p=we(j);if(p)_.add(p)});else if(y[3])_.add(y[3])}while((y=N.exec(B))!==null){if(y[1])continue;if(!D(y.index))continue;_.add(y[2])}let se=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((y=se.exec(B))!==null){if(!D(y.index))continue;let j=/^\s*['"]([^'"]+)['"]/.exec(e.slice(y.index+y[0].length))?.[1];if(j&&H.some((p)=>p.test(j)))continue;if(y[1])_.add(y[1]);if(y[2])_.add(y[2]);for(let p of(y[3]??"").split(",")){let b=p.trim();if(!b||/^type\s/.test(b))continue;let U=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(U)_.add(U)}}for(let j of B.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let p of j[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(p)?.[1]??/^\s*(\w+)\s*$/.exec(p)?.[1];if(b)_.delete(b)}let ie=_.size>0?`
|
|
3
3
|
export { ${[..._].join(", ")} }`:"";await Bun.write(d,e+ie),I("bundling:",l,"from:",h.basename(n));let Y=new Set,Q=new Map;try{let j=await Bun.build({entrypoints:[d],outdir:E,target:"browser",format:"esm",minify:g?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[he(c,C,d,Y,f,Q,i.serverApi)],define:{"process.env.NODE_ENV":g?'"production"':'"development"',...w()},root:c});if(!j.success){let F=j.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${h.basename(n)}`,k=nn(j.logs,n||void 0);if(console.warn("[stx:bundler] build failed:",F),Vo(n||"",F,k),i.throwOnFailure||Uo()==="error")throw Error(F);return e}let p="";for(let x of j.outputs){p=await x.text();break}let b=[];for(let x of p.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let F of x[1].split(",")){let k=F.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k){b.push([k[2],k[1]]);continue}let T=F.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))b.push([T,T])}if(i.expose){let x=new Set(i.expose);for(let F=b.length-1;F>=0;F--)if(!x.has(b[F][0]))b.splice(F,1)}let U=[];p=Qa(Za(p,Q),U);let oe=p.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(p=p.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),g&&p)try{p=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(p)}catch{}let K=`__stxBundle_${l}`,le=b.map(([x,F])=>`${JSON.stringify(x)}: ${F}`).join(", "),ue=b.map(([x])=>`var ${x} = undefined;`).join(`
|
|
4
4
|
`),de=b.map(([x])=>`${x} = ${K}[${JSON.stringify(x)}];`).join(`
|
|
5
5
|
`);if(p=`${oe.join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nl}from"./chunk-
|
|
2
|
+
import{nl}from"./chunk-gvw8wh29.js";import"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{nl as startInteractive};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{xt,Kr,Xr,Gr,Id,Jr}from"./chunk-ee4wwr89.js";import"./chunk-kwvexxey.js";import"./chunk-p8yh7mgr.js";import"./chunk-4gt0r98p.js";export{Xr as buildServerApi,Id as createServerApi,xt as discoverServerApi,Kr as generateApiTypes,Jr as isServerApiSource,Gr as productionApiDispatcher};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{pn,Ts}from"./chunk-
|
|
2
|
+
import{pn,Ts}from"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";export{Ts as generateRuntimeConfigTypes,pn as prepareRuntimeConfig};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{J}from"./chunk-
|
|
2
|
+
import{J}from"./chunk-4gt0r98p.js";import{ue,C}from"./chunk-p8yh7mgr.js";import{Ei}from"./chunk-kwvexxey.js";import{a}from"./chunk-4cmqjmqr.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function xt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Kr(s,l){let o=a(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:p}=J(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Xr(s,l,o={}){let i=xt(s,o);await Kr(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...J(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Gr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Id(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=xt(s,o);return await Kr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=xt(s,o);await Kr(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...J(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Gr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Id(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=xt(s,o);return await Kr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=xt(s,o);await Kr(s,t);let{loadStxConfig:e}=await import("./chunk-3w49r16x.js"),p=C((await e(s)).runtimeConfig);return await ue(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Jr(s,l,o){if(Ei(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
|
|
6
6
|
export{xt,Kr,Xr,Gr,Id,Jr};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{X,xs,Ss,ks,n}from"./chunk-
|
|
2
|
+
import{X,xs,Ss,ks,n}from"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{X as injectRouterScript,n as processDirectives,xs as processJsonDirective,Ss as processOnceDirective,ks as validateClientScript};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ul}from"./chunk-stbsqy7e.js";import"./chunk-hp1tnxzb.js";import"./chunk-3vvppnws.js";import"./chunk-ee4wwr89.js";import"./chunk-g5t10z04.js";import"./chunk-kg77xs08.js";import"./chunk-bpr4bkde.js";import"./chunk-kwvexxey.js";import"./chunk-y4qks0bd.js";import"./chunk-p8yh7mgr.js";import"./chunk-2dzd2h15.js";import"./chunk-9sqjmd9a.js";import"./chunk-tkeabv04.js";import"./chunk-6v1gwdbv.js";import"./chunk-5tj6expd.js";import"./chunk-4gt0r98p.js";import"./chunk-gxfnmjzp.js";export{ul as buildForProduction};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{b,d,n,g,R}from"./chunk-
|
|
2
|
+
import{b,d,n,g,R}from"./chunk-g5t10z04.js";import q from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},C=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,s;O.lastIndex=0;while((s=O.exec(e))!==null){if(s.index>o){let a=e.slice(o,s.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=s[1],i=s[2];t.push({type:"suspense",name:r,content:i}),o=s.index+s[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function fd(e,t={},o={}){let s={...R,...o,streaming:{...M,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:q.dirname(e)};if(m.trim())await d(m,y,e);let T=z(c),u=new Set;if(!T.some((h)=>h.type==="suspense")){let h=s.streaming?.strategy||"auto",S=new RegExp(C.source,"g");if(!(h!=="manual"&&S.test(c))){let p=await n(c,y,e,s,u);for(let x=0;x<p.length;x+=r)i.enqueue(p.slice(x,x+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],x=new RegExp(C.source,"g"),f;while((f=x.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let E=0;for(let _ of p){if(_.start>E){let k=c.slice(E,_.start);if(k.trim()){let D=await n(k,y,e,s,u);i.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let I=await n(_.content,y,e,s,u);i.enqueue(I),await new Promise((k)=>setTimeout(k,0)),E=_.end}if(E<c.length){let _=c.slice(E);if(_.trim()){let I=await n(_,y,e,s,u);i.enqueue(I)}}}}else{let h=new Map;for(let l of T)if(l.type==="shell"||l.type==="content"){let p=await n(l.content,y,e,s,u);i.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;i.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),h.set(l.name,n(l.content,y,e,s,u))}i.enqueue(`
|
|
5
5
|
<script>
|