@stacksjs/stx 0.2.720 → 0.2.721
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/README.md +6 -0
- package/dist/{chunk-ve78svbr.js → chunk-0w8azt6t.js} +1 -1
- package/dist/{chunk-y0bepgyh.js → chunk-1hs03zas.js} +1 -1
- package/dist/{chunk-qvwwpnyk.js → chunk-1nfc0jpn.js} +3 -3
- package/dist/{chunk-jh8b3f9w.js → chunk-2b10kvbk.js} +1 -1
- package/dist/{chunk-b8a8900p.js → chunk-2b6stk0d.js} +1 -1
- package/dist/{chunk-9vx6et01.js → chunk-2mspmqhf.js} +1 -1
- package/dist/{chunk-8deed4r2.js → chunk-2qfks56q.js} +1 -1
- package/dist/{chunk-43anje0a.js → chunk-3n66yz7y.js} +1 -1
- package/dist/chunk-3ps6h76g.js +2 -0
- package/dist/{chunk-5bm0nh5f.js → chunk-4af3dzhn.js} +2 -2
- package/dist/{chunk-hsqqhjhr.js → chunk-4ny1bdx8.js} +1 -1
- package/dist/{chunk-8csv4s4f.js → chunk-4r2r33na.js} +3 -3
- package/dist/{chunk-pz837t6v.js → chunk-4yc4trws.js} +1 -1
- package/dist/chunk-57t61q5j.js +2 -0
- package/dist/{chunk-mhpek1hj.js → chunk-5eggkcv7.js} +1 -1
- package/dist/{chunk-rm9rmyh2.js → chunk-79ks83bq.js} +1 -1
- package/dist/chunk-7cn6cr0n.js +2 -0
- package/dist/{chunk-hp957nrn.js → chunk-7n411x4f.js} +2 -2
- package/dist/{chunk-57ecpsqy.js → chunk-8bpj8v6c.js} +1 -1
- package/dist/{chunk-kbw75yd7.js → chunk-aq251vv0.js} +1 -1
- package/dist/{chunk-pqrgaahp.js → chunk-azbf5z87.js} +3 -3
- package/dist/{chunk-9v16zd8h.js → chunk-bex4ffwc.js} +1 -1
- package/dist/{chunk-0wfbhs15.js → chunk-bkt3mtfc.js} +1 -1
- package/dist/chunk-cdwbfbqn.js +2 -0
- package/dist/{chunk-0ktg5dw9.js → chunk-dkr1mv9g.js} +1 -1
- package/dist/{chunk-a82dg51h.js → chunk-dn2qgw58.js} +1 -1
- package/dist/{chunk-ejp4d8cq.js → chunk-fgymbm74.js} +1 -1
- package/dist/{chunk-rfb00eqz.js → chunk-g03r429d.js} +5 -5
- package/dist/{chunk-hpg5bjzb.js → chunk-g6trc7av.js} +1 -1
- package/dist/{chunk-ty5rncss.js → chunk-ga1w4cf0.js} +1 -1
- package/dist/{chunk-e13vngat.js → chunk-h58h5z2g.js} +1 -1
- package/dist/{chunk-6h0n7h97.js → chunk-hrxt6mb1.js} +2 -2
- package/dist/chunk-j4emk3cs.js +2 -0
- package/dist/{chunk-kxp881ch.js → chunk-j6z9js8n.js} +1 -1
- package/dist/{chunk-009y9zkg.js → chunk-jf8s7pwc.js} +1 -1
- package/dist/{chunk-jtf6sxgd.js → chunk-jzqy3crv.js} +1 -1
- package/dist/chunk-kd85e532.js +3 -0
- package/dist/{chunk-znknf1jt.js → chunk-kdxj7m84.js} +5 -5
- package/dist/{chunk-r1t5dcsn.js → chunk-m2tsxk59.js} +1 -1
- package/dist/chunk-m436z7rz.js +2 -0
- package/dist/{chunk-nb65s3b5.js → chunk-m96swv2f.js} +4 -4
- package/dist/{chunk-kn92y5yd.js → chunk-mj236yzm.js} +2 -2
- package/dist/{chunk-dffe3vx2.js → chunk-n7j6atmv.js} +1 -1
- package/dist/{chunk-pcsgj3a5.js → chunk-nftg75ja.js} +1 -1
- package/dist/{chunk-2rj4t9wz.js → chunk-nwdyt27p.js} +1 -1
- package/dist/{chunk-m7hbk341.js → chunk-pg4brvfc.js} +1 -1
- package/dist/{chunk-2f3zw2wy.js → chunk-pqahncbx.js} +1 -1
- package/dist/chunk-qftdkt5g.js +2 -0
- package/dist/{chunk-2gg3apz0.js → chunk-qxpd0n87.js} +1 -1
- package/dist/{chunk-n0bw2kzs.js → chunk-r0znxg0q.js} +1 -1
- package/dist/chunk-rhxw3jff.js +2 -0
- package/dist/chunk-sbw7re1b.js +2 -0
- package/dist/{chunk-0azq3w1a.js → chunk-sqzb3x5z.js} +6 -6
- package/dist/{chunk-gwq82dpy.js → chunk-t3j3my0p.js} +4 -4
- package/dist/{chunk-11k6atcw.js → chunk-t84nam1w.js} +1 -1
- package/dist/{chunk-5rjfaj0b.js → chunk-tpwqcjte.js} +2 -2
- package/dist/{chunk-zc116ep8.js → chunk-v0vgfh63.js} +1 -1
- package/dist/{chunk-04xtzbf6.js → chunk-v1ps8ydq.js} +1 -1
- package/dist/chunk-vq4d9345.js +2 -0
- package/dist/{chunk-bpds7e9v.js → chunk-wtdgt09t.js} +1 -1
- package/dist/{chunk-1xt84h16.js → chunk-xx0kkk8r.js} +1 -1
- package/dist/{chunk-xhpf68p4.js → chunk-xyndw2gv.js} +1 -1
- package/dist/{chunk-xvkqa756.js → chunk-yaqb1eft.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-backend.d.ts +1 -0
- package/dist/native-backend.js +16 -1
- package/dist/native-build.js +2 -2
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-2sjvj2gb.js +0 -2
- package/dist/chunk-4m1zv168.js +0 -2
- package/dist/chunk-5awvckb2.js +0 -2
- package/dist/chunk-5dvb2e8f.js +0 -2
- package/dist/chunk-6r1wzzt3.js +0 -2
- package/dist/chunk-ddxrb5zk.js +0 -2
- package/dist/chunk-g9vag1n2.js +0 -2
- package/dist/chunk-hgrtnyp3.js +0 -2
- package/dist/chunk-jy8m3dah.js +0 -3
- package/dist/chunk-sey2x612.js +0 -2
- package/dist/chunk-y7b9kqz8.js +0 -2
package/README.md
CHANGED
|
@@ -1053,3 +1053,9 @@ application logic runs in a bundled Bun backend. STX selects Pantry's official
|
|
|
1053
1053
|
host while omitting Craft's separate headless scripting engine. Install a Craft
|
|
1054
1054
|
release that includes this profile; builds fail if the requested profile is
|
|
1055
1055
|
missing. The default `full` profile continues to support Craft scripts.
|
|
1056
|
+
|
|
1057
|
+
A backend entry can export `async function shutdown()` to finish local writes
|
|
1058
|
+
when the native host quits, receives a termination signal, or closes its lifetime
|
|
1059
|
+
pipe. STX stops serving requests, awaits the hook once, and exits. The hook has a
|
|
1060
|
+
two second deadline; a failure or timeout exits with status 1. Craft must allow
|
|
1061
|
+
its backend a graceful exit (Craft 0.0.370 or newer) before forcing termination.
|
|
@@ -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-2mspmqhf.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-8t9em8md.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-fgymbm74.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-n6carvxa.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,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qe}from"./chunk-2mqzpzy7.js";import{gt,Bn}from"./chunk-k93mp66m.js";import{Ne,pn,Dc,Mc}from"./chunk-
|
|
2
|
+
import{Qe}from"./chunk-2mqzpzy7.js";import{gt,Bn}from"./chunk-k93mp66m.js";import{Ne,pn,Dc,Mc}from"./chunk-sqzb3x5z.js";import{kr,_r,Cr,Tr,ke}from"./chunk-zkx2m308.js";import{O}from"./chunk-rbmt5w9v.js";import{ai}from"./chunk-xyndw2gv.js";import{y}from"./chunk-hrxt6mb1.js";import{i}from"./chunk-g03r429d.js";import{j,a}from"./chunk-tpwqcjte.js";import{ic}from"./chunk-3fwdxxh1.js";import{$n,Ue,Ce,Xi,Ji,Rn}from"./chunk-4r2r33na.js";import{nn,yo}from"./chunk-bkt3mtfc.js";import{An}from"./chunk-dnqzrktd.js";import{Xt,Gn,Xn}from"./chunk-9adx6f4k.js";import{G}from"./chunk-t3j3my0p.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Bn():gt(),o=J(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function V(){let n=Qe(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,o={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Dc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Ne(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...j,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=$n(b)+Ue(b),P=Mc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:P,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:pn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Rg(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=ke(e.app?.head,{known:Tr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=An(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)nn(o,w);if(e.runtimeConfig)O(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=G(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let s of B){let f=T(s.pattern),H=f.rendering==="prerender";if(H&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Cr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=kr(t.html,u);if(g.htmlAttrs)t.html=_r(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),H){let p=await Rn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ce(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),I=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),k.push({pattern:s.pattern,compiledPath:z,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:H}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(o,d);if(m.existsSync(E)){let{copied:s,bytes:f}=Z(E,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let F=Xn(o);if(F){let{copied:s,bytes:f}=Z(F,c.join(r,"public",Gn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Xt}/`)}let N={runtime:v.filename,router:x.filename},C=Xi(k,N,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await yo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await ai(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(ic(e._layerGraph),null,2));Ji(C,r);let K=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:N,outputDir:r,duration:K}}
|
|
4
4
|
export{Rg};
|