@stacksjs/stx 0.2.444 → 0.2.445
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-yg494zzb.js → chunk-12mzd0gf.js} +1 -1
- package/dist/{chunk-w56svnna.js → chunk-1g91pegz.js} +1 -1
- package/dist/{chunk-7bc50hm4.js → chunk-2b66v3yx.js} +1 -1
- package/dist/{chunk-z0ce8mz5.js → chunk-39726w03.js} +2 -2
- package/dist/{chunk-x87j60sq.js → chunk-3wdarmh7.js} +2 -2
- package/dist/{chunk-8tket3q3.js → chunk-3yws0k28.js} +1 -1
- package/dist/{chunk-vteymh4f.js → chunk-4awtqfv7.js} +1 -1
- package/dist/{chunk-1189skf4.js → chunk-4mppjen3.js} +1 -1
- package/dist/{chunk-prz1qw2w.js → chunk-5mxr3acg.js} +1 -1
- package/dist/{chunk-vbsv4e1q.js → chunk-66czf70n.js} +1 -1
- package/dist/{chunk-y29k6k0v.js → chunk-7kyr2atb.js} +1 -1
- package/dist/{chunk-a14z0mp4.js → chunk-7v163hb5.js} +1 -1
- package/dist/{chunk-nk8wcwtw.js → chunk-8bsy7r0w.js} +1 -1
- package/dist/{chunk-7cq9k3kd.js → chunk-93wp5h7v.js} +1 -1
- package/dist/{chunk-t8fm46p6.js → chunk-97tb2m44.js} +1 -1
- package/dist/{chunk-4s0xfpsn.js → chunk-9tbevvm3.js} +1 -1
- package/dist/{chunk-yxg5v05n.js → chunk-a14zkmbp.js} +1 -1
- package/dist/{chunk-sszxyg08.js → chunk-b3e0hcw0.js} +18 -17
- package/dist/{chunk-rwrj33bt.js → chunk-b7x7099z.js} +1 -1
- package/dist/{chunk-c2yt6czn.js → chunk-cmctzee2.js} +1 -1
- package/dist/{chunk-yakw5x0h.js → chunk-csjm1z0c.js} +1 -1
- package/dist/{chunk-y3xrvykj.js → chunk-ean2kjmg.js} +2 -2
- package/dist/{chunk-kf6j2zxr.js → chunk-egaknprm.js} +5 -5
- package/dist/{chunk-2qnvrj31.js → chunk-fbhgabf2.js} +1 -1
- package/dist/{chunk-hbmr3fz6.js → chunk-frys2748.js} +1 -1
- package/dist/{chunk-1n4j4h0w.js → chunk-gmzaknjp.js} +1 -1
- package/dist/chunk-gy7t9wd0.js +2 -0
- package/dist/{chunk-dxsrq87y.js → chunk-h15q5qan.js} +1 -1
- package/dist/{chunk-wpvnynj7.js → chunk-hvawaf7a.js} +1 -1
- package/dist/{chunk-r3647v1d.js → chunk-kp7r61aj.js} +1 -1
- package/dist/{chunk-vt8heeds.js → chunk-m2k2b81v.js} +1 -1
- package/dist/{chunk-mkst2aqd.js → chunk-p2b0r3qn.js} +1 -1
- package/dist/{chunk-zhh4cccp.js → chunk-p46gy056.js} +1 -1
- package/dist/{chunk-z7ezbcaj.js → chunk-p5hrdsk9.js} +1 -1
- package/dist/{chunk-v23g5dwz.js → chunk-qzyfjyna.js} +1 -1
- package/dist/{chunk-0qsn5vsd.js → chunk-sgxjqqvd.js} +1 -1
- package/dist/{chunk-2wsfvjhe.js → chunk-sjgg6r0a.js} +1 -1
- package/dist/{chunk-nhz583np.js → chunk-t9tg1syw.js} +1 -1
- package/dist/{chunk-4n38vrh9.js → chunk-tq441vbg.js} +1 -1
- package/dist/{chunk-1bfwtrtr.js → chunk-vn09wm09.js} +1 -1
- package/dist/{chunk-zhf93rbk.js → chunk-vyw0csez.js} +1 -1
- package/dist/{chunk-4djmatx7.js → chunk-w9ebf2rb.js} +1 -1
- package/dist/{chunk-p3dqn89d.js → chunk-xex4nkgq.js} +1 -1
- package/dist/{chunk-9v2w774g.js → chunk-xgwempyb.js} +1 -1
- package/dist/{chunk-pxnwk92z.js → chunk-xr03p49w.js} +1 -1
- package/dist/{chunk-y763qg35.js → chunk-y8kz05mn.js} +1 -1
- package/dist/{chunk-2k4dryxp.js → chunk-ybk279xj.js} +1 -1
- package/dist/{chunk-4vzbt8p6.js → chunk-ycmc1zpt.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.js +2 -1
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-n54srgdv.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m}from"./chunk-2xnwsavq.js";import{R,Tt}from"./chunk-axydabse.js";import{y,ze,N,i}from"./chunk-
|
|
2
|
+
import{m}from"./chunk-2xnwsavq.js";import{R,Tt}from"./chunk-axydabse.js";import{y,ze,N,i}from"./chunk-b3e0hcw0.js";import{oe,mt,ht}from"./chunk-3yws0k28.js";import{Ae,Vt,J}from"./chunk-j7zywbq0.js";import f from"path";var l=new Map;function v(a,s){for(let n of a.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(n[1])s.add(n[1]);for(let n of a.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let r of(n[1]??"").split(",")){let o=((r.includes(":")?r.split(":").pop():r)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(o))s.add(o)}for(let n of a.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let r of(n[1]??"").split(",")){let c=r.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(c))s.add(c)}}async function Ul(a){let s;if(a)s=f.resolve(a);else{let t=await i();s=f.resolve(t.root||process.cwd(),t.storesDir||"stores")}let n=new Bun.Glob("*.ts"),r=[];try{for await(let t of n.scan({cwd:s,absolute:!0})){let e=f.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return J(l,s,"",""),null}let c=()=>[...new Set([...r,...r.flatMap((t)=>oe(t))])],o=Ae(c()),d=Vt(l,s,o);if(d!==void 0)return d||null;if(r.length===0)return J(l,s,o,""),null;let p=[];for(let t of r){let e=await Bun.file(t).text();p.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}p.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let w=p.map((t)=>t.file),u=[],g=new Set,b=N({loader:"ts",target:"browser",define:y()});for(let t of w)try{let e=await Bun.file(t).text(),x=f.basename(t,".ts");if(v(e,g),mt(e))e=await ht(e,t,{projectRoot:process.cwd(),externalizeUserModules:!1});e=ze(e),e=R(e),e=Tt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=b.transformSync(e),u.push(`// Store: ${x}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(u.length===0)return J(l,s,o,""),null;let h=u.join(`
|
|
4
4
|
|
|
5
5
|
`),S=`;(function(){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-2xnwsavq.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-
|
|
2
|
+
import"./chunk-2xnwsavq.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-b3e0hcw0.js";import"./chunk-56hvemdx.js";import"./chunk-73h7qjgq.js";import"./chunk-b5emjcf1.js";import"./chunk-cs15xqf0.js";import"./chunk-aa7w63xc.js";import"./chunk-5zpt78j4.js";import"./chunk-jwpcck1b.js";import"./chunk-7v163hb5.js";import"./chunk-dqr5n49p.js";import"./chunk-7676qzab.js";import f from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(b);var l=new Map,h=I(64),S=new Set,v=0,E=new Set(b);function W(){l.clear(),h.clear()}function R(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function P(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=O(o,v),r=h.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of E){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=R(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>k.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
|
|
3
3
|
${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let w=r.filter((s)=>!d.has(s)&&!P(o,s));if(w.length>0)console.warn(`[stx] could not bundle ${w.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let C=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
|
|
4
4
|
`),x=`<script data-stx-framework-composables>
|
|
5
5
|
;(function(){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tn,nc,es}from"./chunk-
|
|
2
|
+
import{tn,nc,es}from"./chunk-b3e0hcw0.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-7v163hb5.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import{ve}from"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{ve as freeIdentifiers,es as processComponents,nc as processESImports,tn as rendersAsElement};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pn,Oe,Ne,me,Vi,Nn,Z,q,nn,d,n,A}from"./chunk-
|
|
2
|
+
import{Pn,Oe,Ne,me,Vi,Nn,Z,q,nn,d,n,A}from"./chunk-b3e0hcw0.js";import{dirname as C,resolve as R}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(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}=Pn(o),c=await(e.renderer??((s)=>Oe(s)))(m);return{html:_(c),frontmatter:r??{}}}function k(o){let e=o,r=Z(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 v(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=Ne(p),g=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await me(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 q(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
17
|
+
${g}`}t=await q(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-7kyr2atb.js");t=await i(t)}catch{}return t}
|
|
18
18
|
export{$i};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bi,Gr,Y,Le,wt,b,Be,Fe,Bn,d,rn}from"./chunk-
|
|
2
|
+
import{Bi,Gr,Y,Le,wt,b,Be,Fe,Bn,d,rn}from"./chunk-b3e0hcw0.js";import{D}from"./chunk-yqsza22w.js";import E from"path";var j=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(j.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function ti(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var _e="private, no-store";function ni(t){return t.replace(/&#(\d+);/g,(n,e)=>O(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>O(Number.parseInt(e,16),n)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function O(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function C(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function W(){let t=D()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-7cdrpkzz.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function ri(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function vr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=ti(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:x,loadStxConfig:y}=await import("./chunk-gy7t9wd0.js"),R=await y(),g={__filename:t,__dirname:E.dirname(t)};for(let m of a){let A=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!m.includes("client")&&!m.includes('type="module"'))await h(A[1],g,t)}let S=await p(l,g,t,{...x,...R,...n},new Set),w=S.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:S.substring(0,w),afterSlot:S.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function kn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -26,5 +26,5 @@ ${i}
|
|
|
26
26
|
`));if(o.length>0)x.push(o.join(`
|
|
27
27
|
`));if(f.length>0)x.push(f.join(`
|
|
28
28
|
`));return x.push(l),x.join(`
|
|
29
|
-
`)}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function xr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function N(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!xr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(_(e,o.value,o))}}return n}function ci(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import I from"path";function ii(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function oi(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function ai(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Pt(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-
|
|
29
|
+
`)}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function xr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function N(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!xr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(_(e,o.value,o))}}return n}function ci(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import I from"path";function ii(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function oi(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function ai(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Pt(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-p2b0r3qn.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-hvawaf7a.js"),{defaultConfig:p}=await import("./chunk-y8kz05mn.js"),h=r.streamBoundaries||{},x={...p,autoShell:!1},y=Object.keys(l).map((g)=>({id:g,render:async()=>{let S=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:S},t.sourceFile,x,new Set)}})),R=new Set(y.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...y]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Gr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await N(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=Bn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Gr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=b(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?wt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(Bi(t.html,s)),context:e,cookies:r.cookies}}
|
|
30
30
|
export{ti,_e,ni,ne,C,ri,vr,kn,ge,si,re,ii,oi,ai,xr,ci,Pt};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y,Me,I,Yt,i,T}from"./chunk-
|
|
2
|
+
import{y,Me,I,Yt,i,T}from"./chunk-b3e0hcw0.js";import{Ur}from"./chunk-vyw0csez.js";import{s,be}from"./chunk-vxgtq00t.js";import{a}from"./chunk-cm875f73.js";import m from"path";import j from"fs";function pe(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function fe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function J(e,t){let r=[];for(let l of fe(e)){if(pe(l)){let u=l.position||void 0;r.push({file:t||u?.file,line:u?.line,column:u?.column,message:l.message??"",lineText:u?.lineText});continue}r.push({file:t,message:l instanceof Error?l.message:String(l)})}return r}function De(e,t){return J(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",u=r.lineText?`
|
|
3
3
|
${r.lineText.trim()}`:"";return l?`${l}: ${r.message}${u}`:`${r.message}${u}`}).join(`
|
|
4
4
|
`)}var me=10;function P(e,t,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(m.basename(e))||Ur(e,t,r)}var re=1,se=new Map,W=600,ge=100,G=new Map;async function he(e){let t=G.get(e)??0;if(t>0&&t<ge){G.set(e,t+1);return}G.set(e,1);try{let r=(await j.promises.readdir(e)).filter((p)=>p.endsWith(".js"));if(r.length<=W)return;let u=(await Promise.all(r.map(async(p)=>{try{return{name:p,at:(await j.promises.stat(m.join(e,p))).mtimeMs}}catch{return null}}))).filter((p)=>p!==null);u.sort((p,d)=>d.at-p.at);for(let p of u.slice(W)){let d=p.name.slice(0,-3);await j.promises.rm(m.join(e,`${d}.js`),{force:!0}),await j.promises.rm(m.join(e,`${d}.deps.json`),{force:!0})}A("pruned bundle cache to",W,"entries")}catch{}}function oe(e){return se.get(e)??[]}function q(e,t){if(e)se.set(e,t)}function Ma(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function A(...e){if(Ma())console.log("[stx:bundler]",...e)}var Y=[];function Di(e,t,r){Y.push({filePath:e||"<inline>",message:t,details:r})}function ft(){return Y.slice()}function gt(){Y.length=0}var H;function mu(e){H=e}function Oi(){if(H)return H;try{let e=T.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Z=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function mt(e){let t=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,r;while((r=t.exec(e))!==null){let u=r[1];if(!Z.some((d)=>d.test(u)))return A("detected user import:",u),!0}let l=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((r=l.exec(e))!==null){let u=r[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Z.some((d)=>d.test(u)))return A("detected side-effect import:",u),!0}return!1}var Jt="stx-module:",xe=/\.(?:[cm]?[jt]sx?|json)$/i;function Na(e,t){return m.relative(e,t).split(m.sep).join("/")}function La(e,t){if(t.size===0)return e;return e.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,(r,l,u,p)=>{let d=t.get(p);return d&&!p.startsWith(Jt)?`${l}${u}${d}${u}`:r})}function ja(e,t){let r=0,l=(p)=>{let d=`__stxMod${r++}`,b=JSON.stringify(p);return t.push(`var ${d} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${d} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),d},u=(p,d)=>{for(let b of p.split(",")){let M=b.trim();if(!M)continue;let c=M.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!c)continue;let n=c[1].startsWith('"')?JSON.parse(c[1]):c[1],o=c[2]??n;t.push(`var ${o} = ${d}[${JSON.stringify(n)}];`)}};return e=e.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d,b)=>{let M=b.slice(Jt.length),c=l(M),n=d.trim(),o=n.match(/^([\w$]+)\s*(?:,\s*|$)/);if(o&&!n.startsWith("{")&&!n.startsWith("*"))t.push(`var ${o[1]} = ${c}.default;`),n=n.slice(o[0].length).trim();let f=n.match(/^\*\s*as\s+([\w$]+)$/);if(f)t.push(`var ${f[1]} = ${c};`);else if(n.startsWith("{"))u(n.replace(/^\{|\}$/g,""),c);return""}),e=e.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d)=>(l(d.slice(Jt.length)),"")),e}function te(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,m.join(e,"index.ts"),m.join(e,"index.tsx"),m.join(e,"index.js"),m.join(e,"index.mjs")];for(let r of t)try{if(j.existsSync(r)&&j.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}function $e(e,t,r,l,u,p=new Map,d){let b=(c,n,o)=>{if(P(n,e,d))return null;if(!u||c!==r||!xe.test(n))return null;try{if(!j.statSync(n,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(n);let f=`${Jt}${Na(process.cwd(),n)}`;return p.set(o,f),{path:f,external:!0}},M=(c,n)=>{let o=c===r?t:m.dirname(c),f=m.resolve(o,n);return te(f)??f};return{name:"stx-client-bundle",setup(c){if(c.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(n)=>({path:n.path,external:!0})),c.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(n)=>({path:n.path,external:!0})),c.onResolve({filter:/^\//},(n)=>{let o=te(n.path);if(o){let f=b(n.importer,o,n.path);if(f)return f;if(o!==r)l.add(o);return{path:o}}return{path:n.path,external:!0}}),c.onResolve({filter:/^\.\.?\//},(n)=>{let o=M(n.importer,n.path),f=b(n.importer,o,n.path);if(f)return f;return l.add(o),{path:o}}),c.onResolve({filter:/^[@~]\//},(n)=>{let o=m.resolve(e,n.path.slice(2)),f=[o,`${o}.ts`,`${o}.tsx`,`${o}.js`,`${o}.mjs`,`${o}.jsx`,m.join(o,"index.ts"),m.join(o,"index.tsx"),m.join(o,"index.js"),m.join(o,"index.mjs")];for(let E of f)if(j.existsSync(E)&&j.statSync(E,{throwIfNoEntry:!1})?.isFile()){let N=b(n.importer,E,n.path);if(N)return N;return A(`resolved ${n.path[0]}/ import:`,n.path,"\u2192",E),l.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${n.path[0]}/ import:`,n.path),{path:o}}),u)c.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(n)=>{if(n.importer!==r)return;let o=`${Jt}npm:${n.path}`;return p.set(n.path,o),{path:o,external:!0}});c.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(n)=>{if(P(n.path,e,d))throw Error(`Server-only API source cannot be imported by a client script: ${n.path}`);let o=m.extname(n.path).toLowerCase(),f=o===".json"?"json":o===".tsx"?"tsx":o===".jsx"?"jsx":o===".ts"||o===".mts"||o===".cts"?"ts":"js";if(n.path!==r)l.add(n.path);return{contents:j.readFileSync(n.path,"utf8"),loader:f}})}}}var X=new Map,U=I(64),ne=Symbol.for("stx.client-bundle-build-queue");function Ba(e){let t=globalThis,l=(t[ne]??Promise.resolve()).then(e,e);return t[ne]=l.then(()=>{return},()=>{return}),l}async function ht(e,t,r={}){let l=r.projectRoot||process.cwd(),u=(await i(l)).serverApi,p=r.minify??!1,d=r.externalizeUserModules??!0,b=r.cacheDir||a(l,"bundle-cache"),M=new Bun.CryptoHasher("md5");M.update(`${me}\x00${Me()}\x00${JSON.stringify(u??!1)}\x00${d?"registry":"inline"}\x00${e}\x00${t}`);let c=M.digest("hex").slice(0,12),n=m.join(b,`${c}.js`),o=U.get(n);if(o){if(Yt(o.files)&&o.files.every((F)=>!P(F.path,l,u))){A("memo hit:",c);let F=o.files.map((_)=>_.path);return q(t,F),r.collectInputs?.push(...F),o.code}U.delete(n),A("memo invalidated by dep change:",c)}let f=m.join(b,`${c}.deps.json`),E=Bun.file(n);if(await E.exists()){let F=Bun.file(f),_=!1,v=null;if(await F.exists())try{let D=JSON.parse(await F.text());if(D.metadataVersion!==re||!Array.isArray(D.files))_=!1;else v=D.files,_=!0;if(v&&(!Yt(v)||v.some((k)=>P(k.path,l,u))))_=!1}catch{_=!1}if(_){if(A("cache hit:",c),v)q(t,v.map((k)=>k.path)),r.collectInputs?.push(...v.map((k)=>k.path));let D=await E.text();if(v)U.set(n,{code:D,files:v});return D}A("cache invalidated by dep change:",c)}let N=X.get(c);if(N){let F=await N;if(r.collectInputs)r.collectInputs.push(...(U.get(n)?.files??[]).map((_)=>_.path));return F}let S=Ba(()=>ye(e,t,{projectRoot:l,minify:p,cacheDir:b,hash:c,cachePath:n,depsPath:f,collectInputs:r.collectInputs,externalizeUserModules:d,serverApi:u}));X.set(c,S);try{return await S}finally{X.delete(c)}}var we=0;function Fa(e){return`${e}-${process.pid}-${++we}`}async function ye(e,t,r){let{projectRoot:l,minify:u,cacheDir:p,hash:d,cachePath:b,depsPath:M,externalizeUserModules:c}=r,n=a(l,"bundle-tmp"),o=Fa(d),f=m.join(n,`${o}.ts`),E=m.join(n,"out",o);j.mkdirSync(n,{recursive:!0}),j.mkdirSync(E,{recursive:!0});let N=m.dirname(t),S=new Set,F=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,_=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,v=s(e),{depths:D,balanced:k}=be(v),V=(w)=>!k||D[w]===0,h;while((h=F.exec(v))!==null){if(h[1])continue;if(!V(h.index))continue;if(h[2])h[2].split(",").forEach((w)=>{let g=Be(w);if(g)S.add(g)});else if(h[3])S.add(h[3])}while((h=_.exec(v))!==null){if(h[1])continue;if(!V(h.index))continue;S.add(h[2])}let ie=/^[ \t]*import\s+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((h=ie.exec(v))!==null){if(!V(h.index))continue;let w=/^\s*['"]([^'"]+)['"]/.exec(e.slice(h.index+h[0].length))?.[1];if(w&&Z.some((g)=>g.test(w)))continue;if(h[1])S.add(h[1]);if(h[2])S.add(h[2]);for(let g of(h[3]??"").split(",")){let B=g.trim();if(!B||/^type\s/.test(B))continue;let L=/\bas\s+(\w+)\s*$/.exec(B)?.[1]??/^\w+$/.exec(B)?.[0];if(L)S.add(L)}}for(let w of v.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let g of w[1].split(",")){let B=/\bas\s+(\w+)\s*$/.exec(g)?.[1]??/^\s*(\w+)\s*$/.exec(g)?.[1];if(B)S.delete(B)}let le=S.size>0?`
|
|
5
5
|
export { ${[...S].join(", ")} }`:"";await Bun.write(f,e+le),A("bundling:",d,"from:",m.basename(t));let Q=new Set,K=new Map;try{let w=await Bun.build({entrypoints:[f],outdir:E,target:"browser",format:"esm",minify:u,plugins:[$e(l,N,f,Q,c,K,r.serverApi)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...y()},root:l});if(!w.success){let R=w.logs.filter((C)=>C.level==="error").map((C)=>C.message).join(", ")||`Unable to bundle ${m.basename(t)}`,O=J(w.logs,t||void 0);if(console.warn("[stx:bundler] build failed:",R),Di(t||"",R,O),Oi()==="error")throw Error(R);return e}let g="";for(let x of w.outputs){g=await x.text();break}let B=[];for(let x of g.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let R of x[1].split(",")){let O=R.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(O){B.push([O[2],O[1]]);continue}let C=R.trim();if(/^[A-Za-z_$][\w$]*$/.test(C))B.push([C,C])}let L=[];g=ja(La(g,K),L);let ae=g.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];g=g.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let ee=`__stxBundle_${d}`,ce=B.map(([x,R])=>`${JSON.stringify(x)}: ${R}`).join(", "),ue=B.map(([x])=>`var ${x} = undefined;`).join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{St,oc,ac,cc,lc,uc,d,dc,is,pc,Xi,Gi}from"./chunk-
|
|
2
|
+
import{St,oc,ac,cc,lc,uc,d,dc,is,pc,Xi,Gi}from"./chunk-b3e0hcw0.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-7v163hb5.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{St as STX_ENGINE_BINDING_NAMES,is as convertToCommonJS,Xi as extractScriptFromTemplate,d as extractVariables,Gi as hasVariables,dc as isCompleteImport,uc as isMissingBindingFailure,cc as isModuleResolutionFailure,lc as isSyntaxFailure,pc as splitDeclaration,oc as stripTypeScript,ac as withoutStxReferrer};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V,ae}from"./chunk-
|
|
2
|
+
import{V,ae}from"./chunk-b3e0hcw0.js";import{le,S,Ke}from"./chunk-jwpcck1b.js";import{Ze,X,xe}from"./chunk-b5emjcf1.js";import{_e,ne,C,re,ai,xr,ci,Pt}from"./chunk-3wdarmh7.js";import{Vr}from"./chunk-vyw0csez.js";import{It}from"./chunk-rdq113p4.js";import H from"zlib";import{promisify as Y}from"util";var Q=Y(H.brotliCompress),Z=Y(H.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function oe(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function ie(t){if(!t)return null;let e=oe(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function At(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let s=ie(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:q(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[H.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[H.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=q(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function q(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}import J from"fs";import M from"path";var{serve:ce}=globalThis.Bun;class G{now;entries=new V(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,i){let s,c=async()=>{let r=s??await i();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${ne(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,O=async()=>{let r=await i();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return c();v=O().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):c()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function al(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=ai(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let c=It(s.routeRules),l=new G,m=Vr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,O=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,xe(o.html)),E.set(n.pattern,ae(o.html));let _=M.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let A=await Bun.file(_).text();O.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:o}=X(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ce({port:i,async fetch(n){return At(n,await le(g??S(),async()=>{let o=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[o])return t.apiRoutes[o](n);let _=await m(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=pe[h]||"application/octet-stream",B=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":B?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),y=null,U={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{U[h]=a[j+1]});break}}if(!y){let p=Ze(o)?null:r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=c(o),W=Object.keys(k).length>0;return l.respond(n,k.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=O.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...k.cache?{}:{"Cache-Control":_e}}})}}let d=xr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:a,boundaries:h,redirect:j,cookies:B,status:I,headers:z}=await Pt(u,{params:U,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:g});if(j)return ci(j,B,z);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:D}=await import("./chunk-p2b0r3qn.js"),N=new Headers({...C(),...z,"Cache-Control":"private, no-store"});for(let F of B??[])N.append("Set-Cookie",F);if(A&&!d){let F=xe(a);N.set("X-STX-Fragment","true"),N.set("X-STX-Runtime",ae(a)?"true":"false"),N.set("X-STX-Layout",F.layout),N.set("X-STX-Layout-Group",F.group)}return D(P(A&&!d?re(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:I??u.status??200,headers:N})}let w=new Headers({"Content-Type":"text/html",...C(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of B??[])w.append("Set-Cookie",P);for(let[P,D]of Object.entries(z??{}))w.set(P,D);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=xe(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ae(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(re(a,s.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(a,{status:I??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
|
|
3
3
|
export{At,al};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Yr,Zr,Qr,Du,Ln,Ou}from"./chunk-
|
|
2
|
+
import{Yr,Zr,Qr,Du,Ln,Ou}from"./chunk-b3e0hcw0.js";export{Ln as clearImageDeliveryCatalog,Du as deliveredImage,Qr as efficientDeliverySources,Yr as getImageDelivery,Zr as isTransparentImage,Ou as prepareImageDelivery};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Kc}from"./chunk-
|
|
2
|
+
import{Kc}from"./chunk-gmzaknjp.js";import"./chunk-b3e0hcw0.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-7v163hb5.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{Kc as startInteractive};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Au,zi,Pu,Hi,Ya,Za,vt,en,Iu,Qa,ec,tc,f}from"./chunk-
|
|
2
|
+
import{Au,zi,Pu,Hi,Ya,Za,vt,en,Iu,Qa,ec,tc,f}from"./chunk-b3e0hcw0.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-7v163hb5.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{vt as buildCss,Qa as extractClassNames,Za as fingerprintConfig,ec as generateCss,Iu as getCachedCSS,Au as getCssServeAsset,f as injectCss,zi as loadCssEngine,Hi as loadCssEngineConfig,en as rebuildCss,Pu as resetCssCache,Ya as resolveUserCssConfig,tc as withLinkedModuleBundles};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$t,S}from"./chunk-jwpcck1b.js";import m from"fs";import e from"path";async function an(r,o,i){if(r.__stx_runtime_config)return;let n=$t();if(n||i){r.__stx_runtime_config=n??S(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-
|
|
2
|
+
import{$t,S}from"./chunk-jwpcck1b.js";import m from"fs";import e from"path";async function an(r,o,i){if(r.__stx_runtime_config)return;let n=$t();if(n||i){r.__stx_runtime_config=n??S(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-y8kz05mn.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=S(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function vs(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jo,ll,Yo,Zo,ul,dl}from"./chunk-
|
|
2
|
+
import{Jo,ll,Yo,Zo,ul,dl}from"./chunk-cmctzee2.js";import"./chunk-b3e0hcw0.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-7v163hb5.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{dl as applySlots,ul as extractSlotContent,ll as parseSlotElement,Jo as parseSlots,Zo as processSlots,Yo as renderSlot};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yt,zr,Hr,Vr,hu,Ur}from"./chunk-
|
|
2
|
+
import{yt,zr,Hr,Vr,hu,Ur}from"./chunk-vyw0csez.js";import"./chunk-5zpt78j4.js";import"./chunk-jwpcck1b.js";import"./chunk-b5emjcf1.js";export{Hr as buildServerApi,hu as createServerApi,yt as discoverServerApi,zr as generateApiTypes,Ur as isServerApiSource,Vr as productionApiDispatcher};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m}from"./chunk-2xnwsavq.js";import{R,Tt}from"./chunk-axydabse.js";import{y,ze,N,i}from"./chunk-
|
|
2
|
+
import{m}from"./chunk-2xnwsavq.js";import{R,Tt}from"./chunk-axydabse.js";import{y,ze,N,i}from"./chunk-b3e0hcw0.js";import{oe,mt,ht}from"./chunk-3yws0k28.js";import{Ae,Vt,J}from"./chunk-j7zywbq0.js";import _ from"path";var g=new Map,v=new Map,P=["composables","functions"];function E(n){let t=_.basename(n,".ts");return t==="index"||t==="types"||n.endsWith(".d.ts")}async function G(n){if(n)return _.resolve(n);let t=`<default>:${process.cwd()}`,l=v.get(t);if(l!==void 0)return l;let s=await T();if(s!==null)v.set(t,s);return s}async function T(){let n=await i(),t=n.root||process.cwd(),l=n.composablesDir;if(l)return _.resolve(t,l);for(let s of P){let r=_.resolve(t,s);try{let c=new Bun.Glob("**/*.ts");for await(let a of c.scan({cwd:r,absolute:!0}))if(!E(a))return r}catch{}}return null}async function j(n){let t=Array.isArray(n)?n:n?[_.resolve(n)]:(await i())._layerComposableDirs??[await G()].filter((s)=>!!s),l=new Map;for(let s of t){let r=new Bun.Glob("**/*.ts");try{for await(let c of r.scan({cwd:s,absolute:!0})){let a=_.relative(s,c);if(!E(c)&&!l.has(a))l.set(a,c)}}catch{}}return{key:t.join("\x00"),files:[...l.values()].sort()}}async function Dr(n){let{files:t}=await j(n),l=N({loader:"ts",target:"browser",define:y()}),s=[];for(let r of t)try{let c=await Bun.file(r).text(),a=l.scan(c).exports.filter((d)=>d!=="default");if(a.length>0)s.push({file:r,names:a})}catch{}return s}function z(n,t){return new RegExp(`\\b${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(n)}function U(n,t,l){let s=new Map;for(let{file:d,names:f}of n)for(let u of f)if(!s.has(u))s.set(u,d);let r=(d)=>{let f=[];for(let[u,w]of s)if(z(d,u))f.push(w);return f},c=new Set,a=l.flatMap(r);while(a.length>0){let d=[];for(let f of a){if(c.has(f))continue;c.add(f);for(let u of r(t.get(f)??""))if(!c.has(u))d.push(u)}a=d}return c}async function hl(n,t,l){let{key:s,files:r}=await j(n);if(!s)return null;let c=()=>[...new Set([...r,...r.flatMap((e)=>oe(e))])],a=Ae(c());if(r.length===0)return J(g,s,a,""),null;r.sort();let d=N({loader:"ts",target:"browser",define:y()}),f=new Map,u=[];for(let e of r)try{let o=await Bun.file(e).text();f.set(e,o);let h=d.scan(o).exports.filter((p)=>p!=="default");if(h.length>0)u.push({file:e,names:h})}catch{f.set(e,"")}let w=t===void 0?new Set(r):U(u,f,l?[t,...l]:[t]);if(w.size===0)return null;let B=r.filter((e)=>w.has(e)),x=`${s}\x00${B.join("\x00")}`,M=Vt(g,x,a);if(M!==void 0)return M||null;let S=[],b=new Set,D=new Set;for(let e of B)try{let o=f.get(e)??await Bun.file(e).text(),h=_.basename(e,".ts");for(let p of o.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(p[1])D.add(p[1]);try{for(let p of d.scan(o).exports)if(p!=="default")b.add(p)}catch{}if(o=R(o),mt(o))o=await ht(o,e,{projectRoot:process.cwd(),externalizeUserModules:!1}),o=ze(o);o=Tt(o),o=o.replace(/^export\s+(default\s+)?/gm,""),o=d.transformSync(o),S.push(`// Composable: ${h}
|
|
3
3
|
${o.trim()}`)}catch(o){console.warn(`[stx] Failed to load composable ${e}:`,o)}if(S.length===0||b.size===0)return J(g,x,a,""),null;let F=[...b].map((e)=>` try { if (!(${JSON.stringify(e)} in __c)) __c[${JSON.stringify(e)}] = ${e}; } catch (e) {}`).join(`
|
|
4
4
|
`),k=JSON.stringify([...b]),C=S.join(`
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m}from"./chunk-2xnwsavq.js";import{H,St,He,ms,hs,Qi,eo,to,no,Vn,ys,ro,so,io,i}from"./chunk-
|
|
2
|
+
import{m}from"./chunk-2xnwsavq.js";import{H,St,He,ms,hs,Qi,eo,to,no,Vn,ys,ro,so,io,i}from"./chunk-b3e0hcw0.js";import{Dr}from"./chunk-97tb2m44.js";import{a}from"./chunk-cm875f73.js";import{existsSync as M,readFileSync as K}from"fs";import b from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=St.filter((e)=>!me.has(e)).sort(),ne=[...m].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 r=[];for(let u of t){if(u.offset===void 0)continue;let s=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 h of l[1].matchAll(/[^,]+/g)){let S=h[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let o=x[1];if(!xe.has(o)||s.has(o))continue;let f=u.offset+g+h.index+x[0].length-o.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;r.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:f,length:o.length,name:o,kind:u.kind,message:Se(o,u.kind)})}}}return r}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let r=T.resolve(e);for(;;){let u=T.join(r,"tsconfig.json");if(t(u))return u;let s=T.dirname(r);if(s===r)return;r=s}}function se(e,t,r){let u=we(e,r);if(!u)return;let s=new Set,l=(g)=>{if(s.has(g))return;s.add(g);let h=t(g);if(!h)return;let S=h.compilerOptions?.plugins;if(Array.isArray(S)){let o=S.find((p)=>p?.name===ke),f=Array.isArray(o?.libs)?o.libs.filter((p)=>typeof p==="string"):[];return o?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof h.extends==="string"?[h.extends]:Array.isArray(h.extends)?h.extends:[];for(let o of[...x].reverse()){if(typeof o!=="string"||!o.startsWith("."))continue;let f=T.resolve(T.dirname(g),o.endsWith(".json")?o:`${o}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Vo(e,t="",r=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",s=ys(e)+hs(ms(e.code)),l=e.kind==="client"||e.kind==="plain"?to(t,e.code):"";return Vn(`${u+s}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{oe,Ma,Di,ft,gt,mu,Oi,mt,Jt,Na,La,ja,Ba,ht,Fa}from"./chunk-
|
|
2
|
+
import{oe,Ma,Di,ft,gt,mu,Oi,mt,Jt,Na,La,ja,Ba,ht,Fa}from"./chunk-3yws0k28.js";import"./chunk-vyw0csez.js";import"./chunk-b3e0hcw0.js";import"./chunk-7676qzab.js";import"./chunk-73h7qjgq.js";import"./chunk-5zpt78j4.js";import"./chunk-7v163hb5.js";import"./chunk-jwpcck1b.js";import"./chunk-aa7w63xc.js";import"./chunk-cs15xqf0.js";import"./chunk-56hvemdx.js";import"./chunk-axydabse.js";import"./chunk-2xnwsavq.js";import"./chunk-b5emjcf1.js";import"./chunk-dqr5n49p.js";export{Jt as MODULE_SPECIFIER_PREFIX,ht as bundleClientScript,gt as clearBundleFailures,oe as clientBundleDependencies,ft as getBundleFailures,mt as hasUserImports,La as normalizeRegistrySpecifiers,Ba as queueClientBundleBuild,Di as recordBundleFailure,Na as registryIdForPath,Oi as resolveBundlerFallback,ja as rewriteRegistryImports,mu as setBundlerFallbackMode,Ma as shouldLogBundlerDiagnostics,Fa as tempBuildName};
|