@stacksjs/stx 0.2.684 → 0.2.686
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-2ajbhefk.js → chunk-078as147.js} +1 -1
- package/dist/{chunk-cv10vetd.js → chunk-0nt17nas.js} +2 -2
- package/dist/{chunk-jwxr8rya.js → chunk-0y2hkbc6.js} +1 -1
- package/dist/{chunk-2yphax0x.js → chunk-1rgjy80j.js} +2 -2
- package/dist/chunk-1x0pf3sw.js +2 -0
- package/dist/chunk-31jvtxpx.js +2 -0
- package/dist/{chunk-a20ytcth.js → chunk-4cksc4n3.js} +1 -1
- package/dist/{chunk-1q8cx10w.js → chunk-4dzh6g52.js} +1 -1
- package/dist/{chunk-3ntkdmm9.js → chunk-4j9p27kn.js} +1 -1
- package/dist/chunk-4ntt6d6q.js +2 -0
- package/dist/{chunk-x145xm5r.js → chunk-51fqvchq.js} +6 -6
- package/dist/{chunk-pkcd41b9.js → chunk-58m0kfb3.js} +1 -1
- package/dist/{chunk-yxx4866s.js → chunk-5ahrdnm0.js} +1 -1
- package/dist/{chunk-1y50gat7.js → chunk-5tbey00z.js} +2 -2
- package/dist/{chunk-sa574ehw.js → chunk-67v3rh14.js} +3 -3
- package/dist/{chunk-vf8kma48.js → chunk-6te346zf.js} +1 -1
- package/dist/chunk-71d927c6.js +2 -0
- package/dist/chunk-7gprzmd9.js +2 -0
- package/dist/chunk-7w7e24e9.js +2 -0
- package/dist/{chunk-hk6w3zhm.js → chunk-840waqpm.js} +1 -1
- package/dist/{chunk-rwzmfx1g.js → chunk-90ggz2m1.js} +1 -1
- package/dist/{chunk-mhsshvg1.js → chunk-9c3x72qy.js} +1 -1
- package/dist/chunk-9rv27cdd.js +2 -0
- package/dist/chunk-a1r3jbt4.js +2 -0
- package/dist/{chunk-q28n3hyy.js → chunk-a7hcwkjz.js} +2 -2
- package/dist/chunk-av02901t.js +2 -0
- package/dist/{chunk-5h618jv3.js → chunk-bg6t69qq.js} +1 -1
- package/dist/{chunk-2ar5g9pa.js → chunk-bz3zn6f7.js} +2 -2
- package/dist/chunk-c0fkhe6t.js +2 -0
- package/dist/{chunk-mwxz9kbh.js → chunk-cge9pgyb.js} +2 -2
- package/dist/{chunk-hm69jxmh.js → chunk-cjf01cp4.js} +3 -3
- package/dist/{chunk-w1wzydvp.js → chunk-ct0ee0fr.js} +3 -3
- package/dist/{chunk-8jxqg7kb.js → chunk-d26nb6zy.js} +1 -1
- package/dist/{chunk-sz9xjmx0.js → chunk-d9esaahz.js} +2 -2
- package/dist/{chunk-wyvcxjb8.js → chunk-dbxq6fd7.js} +1 -1
- package/dist/{chunk-jayacz7s.js → chunk-dnbdxbkb.js} +11 -11
- package/dist/{chunk-98xp87m0.js → chunk-dv8a3gp8.js} +1 -1
- package/dist/{chunk-7kzwpskb.js → chunk-dxcn65hq.js} +3 -3
- package/dist/chunk-ebmcecyh.js +2 -0
- package/dist/chunk-ejphs9fs.js +2 -0
- package/dist/chunk-em77nd40.js +2 -0
- package/dist/chunk-exbs8qm6.js +2 -0
- package/dist/{chunk-273mr301.js → chunk-f4fxj7xg.js} +1 -1
- package/dist/{chunk-gwyx2pwf.js → chunk-ffwvbqkp.js} +1 -1
- package/dist/{chunk-ps5v9vm3.js → chunk-fndg9ar3.js} +1 -1
- package/dist/{chunk-dr1em45p.js → chunk-fw12pvmr.js} +5 -5
- package/dist/chunk-gyye3mcb.js +2 -0
- package/dist/chunk-hqj28381.js +3 -0
- package/dist/{chunk-2a1eeywj.js → chunk-hx787tfa.js} +1 -1
- package/dist/{chunk-54mq30ag.js → chunk-hxnvcvkz.js} +1 -1
- package/dist/{chunk-jv7dk4dq.js → chunk-j7phk6kh.js} +1 -1
- package/dist/chunk-jdhdae0h.js +2 -0
- package/dist/{chunk-zt5hp5w5.js → chunk-jgxzbthg.js} +1 -1
- package/dist/chunk-jmjjjgy4.js +2 -0
- package/dist/{chunk-39g00f1z.js → chunk-jq4h969v.js} +1 -1
- package/dist/chunk-k8b4fme9.js +2 -0
- package/dist/{chunk-6e60jp4a.js → chunk-kq1hmpgb.js} +1 -1
- package/dist/{chunk-n11mcrmk.js → chunk-kqzrm2ym.js} +12 -12
- package/dist/{chunk-gymmbbzc.js → chunk-kypwg2ws.js} +21 -9
- package/dist/{chunk-pvn0fc7j.js → chunk-mkaw0bn4.js} +1 -1
- package/dist/{chunk-mhjnz2rh.js → chunk-n4qp4q2x.js} +3 -3
- package/dist/{chunk-49c5v5fh.js → chunk-n93krbsx.js} +1 -1
- package/dist/{chunk-zxqgr2n6.js → chunk-pf25jb54.js} +7 -7
- package/dist/chunk-q4jpjjdc.js +2 -0
- package/dist/{chunk-w28wc7mv.js → chunk-r0ys9aqa.js} +5 -5
- package/dist/{chunk-9wa3t87n.js → chunk-r21m7gsd.js} +1 -1
- package/dist/chunk-rz0kkfd3.js +2 -0
- package/dist/{chunk-8t0fpc9h.js → chunk-s84zv8ky.js} +1 -1
- package/dist/chunk-t2eadw9a.js +2 -0
- package/dist/{chunk-6q1cv39j.js → chunk-v6wa51js.js} +3 -3
- package/dist/{chunk-btdxdmew.js → chunk-vewm4kr8.js} +1 -1
- package/dist/{chunk-xjx1xbey.js → chunk-vnnwp1cg.js} +1 -1
- package/dist/{chunk-nvbkt6a3.js → chunk-w0zrp51m.js} +1 -1
- package/dist/{chunk-t9hx6cr0.js → chunk-x828kq22.js} +1 -1
- package/dist/{chunk-fv1k21jx.js → chunk-xp2cn23j.js} +1 -1
- package/dist/{chunk-p9jkv2y0.js → chunk-xw0cqb5m.js} +36 -36
- package/dist/{chunk-gkmh0xys.js → chunk-ydad3kq5.js} +1 -1
- package/dist/{chunk-qv0zkqem.js → chunk-yf42bhjw.js} +2 -2
- package/dist/{chunk-jkywbfb0.js → chunk-yft8yn6y.js} +2 -2
- package/dist/{chunk-nbjyed3q.js → chunk-ygb33q5w.js} +1 -1
- package/dist/{chunk-15tkxrfe.js → chunk-ymjpqt50.js} +1 -1
- package/dist/{chunk-8gbp2p7c.js → chunk-yqgrjf9q.js} +1 -1
- package/dist/{chunk-12760frv.js → chunk-ywpyxqn5.js} +3 -3
- package/dist/chunk-z0r4vm2m.js +2 -0
- package/dist/{chunk-vfsapkh9.js → chunk-z10ffhzy.js} +8 -8
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- package/dist/process.js +2 -2
- package/dist/pwa.js +2 -2
- package/dist/ssg.js +6 -6
- package/dist/types/config-types.d.ts +1 -0
- package/package.json +5 -5
- package/dist/chunk-1yb1haw7.js +0 -2
- package/dist/chunk-2vm6pbj6.js +0 -2
- package/dist/chunk-6rzbn1nb.js +0 -2
- package/dist/chunk-75ftntkm.js +0 -2
- package/dist/chunk-8bwa63m3.js +0 -2
- package/dist/chunk-8y7tpjfs.js +0 -2
- package/dist/chunk-910s13rr.js +0 -2
- package/dist/chunk-97zv3gpm.js +0 -2
- package/dist/chunk-9md86rzc.js +0 -2
- package/dist/chunk-aftam4we.js +0 -2
- package/dist/chunk-bpf3xxng.js +0 -3
- package/dist/chunk-ehvjbag8.js +0 -2
- package/dist/chunk-nfkaeycg.js +0 -2
- package/dist/chunk-p9228zqe.js +0 -2
- package/dist/chunk-pqg3ghvh.js +0 -2
- package/dist/chunk-tq2m6m3j.js +0 -2
- package/dist/chunk-x8w54snc.js +0 -2
- package/dist/chunk-xpqcr7yj.js +0 -2
- package/dist/chunk-xy16pnty.js +0 -2
- package/dist/chunk-yps3rpny.js +0 -2
- package/dist/chunk-ysra569w.js +0 -2
- package/dist/chunk-zhe25pab.js +0 -2
- package/dist/chunk-zr2vnj6g.js +0 -2
|
@@ -12,6 +12,10 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
12
12
|
var o=Object.assign({},defaults,window.__stxRouterConfig||{},window.STX_ROUTER_OPTIONS||{});
|
|
13
13
|
var containerSel=o.container;
|
|
14
14
|
var debug=!!o.debug;
|
|
15
|
+
function pagePath(){return location.pathname+location.search}
|
|
16
|
+
// location already points at the destination when popstate fires. Keep the
|
|
17
|
+
// document we actually rendered so a native anchor visit does not remount it.
|
|
18
|
+
var renderedPage=pagePath();
|
|
15
19
|
function log(){if(debug&&typeof console!=='undefined'&&console.log)console.log.apply(console,arguments)}
|
|
16
20
|
|
|
17
21
|
// Shorthands for the document-rooted queries this script makes ~33 times.
|
|
@@ -1258,7 +1262,7 @@ import x from"fs";import u from"path";import p from"fs";import w from"path";var
|
|
|
1258
1262
|
isNavigating=false;navAbort=null;
|
|
1259
1263
|
document.body.classList.remove(o.loadingClass);finishProgress();
|
|
1260
1264
|
settleDirection();
|
|
1261
|
-
if(openingUrl&&
|
|
1265
|
+
if(openingUrl&&pagePath()!==openingUrl)keepOpeningPage();
|
|
1262
1266
|
}
|
|
1263
1267
|
function stale(){return id!==navSeq}
|
|
1264
1268
|
// A failed fetch keeps the app: the destination shows a way to try again
|
|
@@ -1806,6 +1810,7 @@ else {
|
|
|
1806
1810
|
// Remove old page scripts
|
|
1807
1811
|
qsa('script[data-stx-page]').forEach(function(s){s.remove()});
|
|
1808
1812
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
|
1813
|
+
renderedPage=cacheKey(url);
|
|
1809
1814
|
if(scr)screenCommit(scr,url+(hash||''));
|
|
1810
1815
|
refreshCurrentLinks();
|
|
1811
1816
|
applyScroll(hash);
|
|
@@ -2267,6 +2272,7 @@ else {
|
|
|
2267
2272
|
|
|
2268
2273
|
// Push history state (before active link updates so location.pathname is current)
|
|
2269
2274
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
|
2275
|
+
renderedPage=cacheKey(url);
|
|
2270
2276
|
|
|
2271
2277
|
// Update active nav links
|
|
2272
2278
|
refreshCurrentLinks();
|
|
@@ -2508,7 +2514,7 @@ else {
|
|
|
2508
2514
|
// are hidden (off the page, so out of reach of a DOM walk) goes with them.
|
|
2509
2515
|
if(host.__stx_detached_if){el.__stx_detached_if=host.__stx_detached_if;host.__stx_detached_if=null}
|
|
2510
2516
|
if(!curTab)curTab=currentTabId();
|
|
2511
|
-
active=newEntry(
|
|
2517
|
+
active=newEntry(pagePath()+location.hash,scrollToken,histDepth);
|
|
2512
2518
|
active.el=el;
|
|
2513
2519
|
active.cattrs=hostAttrString(host);
|
|
2514
2520
|
active.shown=++shownSeq;
|
|
@@ -2692,6 +2698,7 @@ else {
|
|
|
2692
2698
|
// told it is on screen again (stx:screen-shown) so it can refresh whatever
|
|
2693
2699
|
// may have gone stale while it was hidden.
|
|
2694
2700
|
function showRetained(to,dir,opts){
|
|
2701
|
+
renderedPage=cacheKey(to.url);
|
|
2695
2702
|
opts=opts||{};
|
|
2696
2703
|
settleAnimation();
|
|
2697
2704
|
var from=active,host=getContainer();
|
|
@@ -3285,7 +3292,7 @@ else {
|
|
|
3285
3292
|
}
|
|
3286
3293
|
|
|
3287
3294
|
function formTargetUrl(form,submitter){
|
|
3288
|
-
return formAttrOf(form,submitter,'formaction','action')||(
|
|
3295
|
+
return formAttrOf(form,submitter,'formaction','action')||(pagePath());
|
|
3289
3296
|
}
|
|
3290
3297
|
|
|
3291
3298
|
function formMethodOf(form,submitter){
|
|
@@ -3430,8 +3437,13 @@ else {
|
|
|
3430
3437
|
var target=(tabs[curTab]||[])[depth];
|
|
3431
3438
|
if(target&&target.el&&target.token===scrollToken&&target!==active){showRetained(target,dir==='replace'?'pop':dir,{settled:settled===target});return}
|
|
3432
3439
|
}
|
|
3440
|
+
if(renderedPage===pagePath()){
|
|
3441
|
+
applyScroll(location.hash);
|
|
3442
|
+
refreshCurrentLinks();
|
|
3443
|
+
return;
|
|
3444
|
+
}
|
|
3433
3445
|
navCtxNext={direction:dir};
|
|
3434
|
-
navigate(
|
|
3446
|
+
navigate(pagePath()+location.hash,false);
|
|
3435
3447
|
});
|
|
3436
3448
|
|
|
3437
3449
|
// \u2500\u2500 Offline stand-in \u2500\u2500
|
|
@@ -3443,9 +3455,9 @@ else {
|
|
|
3443
3455
|
var standIn=document.querySelector('meta[name="stx-offline-fallback"]');
|
|
3444
3456
|
if(standIn&&shouldUseFragmentResponse()){
|
|
3445
3457
|
standIn.remove();
|
|
3446
|
-
var wanted=
|
|
3458
|
+
var wanted=pagePath();
|
|
3447
3459
|
fetch(wanted,{headers:{'X-STX-Router':'true','Accept':'text/html'}}).then(function(r){
|
|
3448
|
-
if(r.ok&&r.headers.get('X-STX-Fragment')==='true'&&
|
|
3460
|
+
if(r.ok&&r.headers.get('X-STX-Fragment')==='true'&&pagePath()===wanted)
|
|
3449
3461
|
navigate(wanted+location.hash,false,true);
|
|
3450
3462
|
}).catch(function(){});
|
|
3451
3463
|
}
|
|
@@ -3633,7 +3645,7 @@ else {
|
|
|
3633
3645
|
// on load, it cost the opening page its instant restore when the person
|
|
3634
3646
|
// left the app and came back (a full-document Back). A router navigation
|
|
3635
3647
|
// has already fetched one, so after it nothing more is lost.
|
|
3636
|
-
var openingUrl=
|
|
3648
|
+
var openingUrl=pagePath();
|
|
3637
3649
|
function keepOpeningPage(){
|
|
3638
3650
|
var url=openingUrl;
|
|
3639
3651
|
openingUrl='';
|
|
@@ -3901,12 +3913,12 @@ else {
|
|
|
3901
3913
|
// had rather than adding a second code path. 'replace' because a refresh
|
|
3902
3914
|
// is not a new place \u2014 it must not add a history entry you can go Back to.
|
|
3903
3915
|
refresh:function(){
|
|
3904
|
-
return navigate(
|
|
3916
|
+
return navigate(pagePath()+location.hash,'replace',true);
|
|
3905
3917
|
},
|
|
3906
3918
|
// Expire ONE entry, so a mutation can invalidate just the page it affected
|
|
3907
3919
|
// and let the next visit re-fetch, instead of throwing the whole cache away.
|
|
3908
3920
|
invalidate:function(url){
|
|
3909
|
-
evictCache(cacheKey(url||(
|
|
3921
|
+
evictCache(cacheKey(url||(pagePath())));
|
|
3910
3922
|
},
|
|
3911
3923
|
clearCache:function(){for(var k in cache)delete cache[k];for(var lk in layoutCache)delete layoutCache[lk];for(var gk in layoutGroupCache)delete layoutGroupCache[gk];cacheOrder.length=0},
|
|
3912
3924
|
// Switch to the tab whose link points at href, as a tap on it would:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_o,Co,vt,le,tr,ns,nr,rs,ss,Ml,Ll,jl,rr,Bl,Fl,zl,Hl,Ca,Ea,Ta,Eo,$a,Vl,wt,xt,St,kt,_t,Ct,Ze,Ul}from"./chunk-
|
|
2
|
+
import{_o,Co,vt,le,tr,ns,nr,rs,ss,Ml,Ll,jl,rr,Bl,Fl,zl,Hl,Ca,Ea,Ta,Eo,$a,Vl,wt,xt,St,kt,_t,Ct,Ze,Ul}from"./chunk-kypwg2ws.js";export{nr as Router,zl as abortNavigation,ns as bracketPathToRegex,wt as clearMiddleware,Ea as createClientCookieManager,_t as createMiddlewareContext,kt as createRouteLocation,Ca as createServerCookieManager,Ta as createStorageManager,Hl as defineMiddleware,Ll as defineRoute,jl as defineRoutes,rs as findErrorPage,ss as formatRoutes,Co as generateRouteManifest,_o as generateRouteTypes,$a as getMiddleware,xt as getMiddlewareNames,Ze as getRouterScript,Ul as getRouterScriptDev,Vl as hasMiddleware,vt as isFileRequestPath,St as loadMiddlewareFromDirectory,tr as matchRoute,Fl as navigateTo,le as patternToRegex,Eo as registerMiddleware,Bl as resetRoutes,rr as route,Ct as runMiddleware,Ml as setAppUrl};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{gc,mc}from"./chunk-gtktv6nn.js";import{j,cs,ls,us,To,$o,ar,Ie,de,K,ps,oe,X,H,et,lr,Io,pr,je,n,d,V,mn}from"./chunk-p9jkv2y0.js";import{p,E,tt,u}from"./chunk-w28wc7mv.js";import{re}from"./chunk-2a1eeywj.js";import{r}from"./chunk-9tg4995v.js";import{f}from"./chunk-b7e07ybq.js";import{createHash as Ct}from"crypto";import ee from"fs";import Q from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import Te from"fs";function Ce(e,t,s){let i=Buffer.alloc(s),o=Te.readSync(e,i,0,s,t);return i.subarray(0,o)}function De(e){if(e.length<25)return!1;let t=(i,o)=>String.fromCharCode(...e.subarray(i,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let s=t(12,16);if(s==="VP8X")return(e[20]&16)!==0;if(s==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=Te.openSync(e,"r");let s=Ce(t,0,33);if(s.length>=3&&s[0]===255&&s[1]===216&&s[2]===255)return"none";if(s.length>=26&&s[0]===137&&s.toString("latin1",1,4)==="PNG"){let i=s[25];if(i===4||i===6)return"possible";let o=8;for(let a=0;a<64;a++){let c=Ce(t,o,8);if(c.length<8)return"unknown";let g=c.toString("latin1",4,8);if(g==="tRNS")return"possible";if(g==="IDAT"||g==="IEND")return"none";o+=12+c.readUInt32BE(0)}return"unknown"}if(s.length>=25&&s.toString("latin1",0,4)==="RIFF"&&s.toString("latin1",8,12)==="WEBP"){if(De(s))return"possible";let i=s.toString("latin1",12,16);return i==="VP8 "||i==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Te.closeSync(t)}}import Jt from"fs";import Re from"os";import{join as dt}from"path";import{fileURLToPath as gt}from"url";import{Worker as mt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function en(){Ae--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let s=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(s.protocol==="file:"&&Jt.existsSync(gt(s)))return gt(s)}catch{}try{let s=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return s&&rn(s)?s:void 0}catch{return}}function rn(e,t=process.env){let s=e.replace(/\\/g,"/");if(s.split("/").some((o)=>/@\d[^/]*@@@\d+$/.test(o)))return!1;return![t.BUN_INSTALL_CACHE_DIR,dt(t.BUN_INSTALL||dt(Re.homedir(),".bun"),"install","cache")].filter((o)=>!!o).map((o)=>`${o.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((o)=>s.startsWith(o))}var pt=!1;function pe(e){if(!pt)pt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return pe("node:worker_threads has no Worker in this runtime");let s=nn();if(!s)return pe("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((i,o)=>{let a;try{a=new mt(s)}catch(h){i(pe(`could not start ${s}: ${Le(h)}`));return}let c=!1,g=!1,l=(h)=>{if(g)return;g=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>i(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>o(v))}),a.on("error",(h)=>{l(()=>c?o(h instanceof Error?h:Error(Le(h)||"image worker crashed")):i(pe(`the worker failed before it was ready: ${Le(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):i(pe(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],he="/_stx/images",ln=`stx:${he}:alpha-1`,un=`stx:${he}:opaque-1`,fn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function dn(e,t){let s=Q.dirname(Bun.resolveSync(e,t));while(s!==Q.dirname(s)){let i=Q.join(s,"package.json");if(ee.existsSync(i)){let o=JSON.parse(ee.readFileSync(i,"utf8"));if(o.name===e)return o.version}s=Q.dirname(s)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=Q.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=fn.map((t)=>{let s;try{s=e?dn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${s??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function ye(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function gn(e){return`/${e.split(Q.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=Q.extname(e),s=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),i=Ct("sha256").update(e).digest("hex").slice(0,8);return`${s||"image"}-${i}`}function wt(e,t=`stx:${he}`){let s=(i)=>`${he}/${i.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(i){let o=Q.join(e,i);try{let a=await ee.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:s(i)}:null}catch{return null}},async write(i,o){let a=Q.join(e,i);await ee.promises.mkdir(Q.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await ee.promises.writeFile(c,o),await ee.promises.rename(c,a),{bytes:o.byteLength,path:a,url:s(i)}},url:s}}async function Rt(e,t=e){let s=await ee.promises.readdir(t,{withFileTypes:!0});s.sort((o,a)=>o.name.localeCompare(a.name));let i=[];for(let o of s){let a=Q.join(t,o.name);if(o.isDirectory()){i.push(...await Rt(e,a));continue}if(!o.isFile()||!an.has(Q.extname(o.name).toLowerCase()))continue;i.push({absolutePath:a,relativePath:Q.relative(e,a)})}return i}function $t(e,t){return e.map((s)=>({key:gn(s.relativePath),input:s.absolutePath,name:pn(s.relativePath),...hn(s.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return Me(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,o])=>o.fallback.format==="png"),s=new Set,i=8;for(let o=0;o<t.length;o+=8)await Promise.all(t.slice(o,o+8).map(async([a,c])=>{let g=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await ee.promises.readFile(g?.path??c.fallback.path)));if(yn(l.data))s.add(a)}catch{s.add(a)}}));return s}function bn(e,t){let s=[];for(let i of t){let o=e[i],a=o?.variants.filter((g)=>g.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((g)=>{let l;try{return l=ee.openSync(g.path,"r"),!De(Ce(l,0,32))}catch{return!0}finally{if(l!==void 0)ee.closeSync(l)}}))continue;if(o.variants=o.variants.filter((g)=>g.format!=="webp"),delete o.sources.webp,s.push(i),!vt.has(i))vt.add(i),console.warn(`[stx-images] ${i} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return s}async function vn(e){let t=[],s=8;for(let i=0;i<e.length;i+=8){let o=e.slice(i,i+8),a=await Promise.all(o.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function Ue(e){return Q.join(e,"undecodable.json")}function wn(e){try{let t=ee.readFileSync(Ue(e),"utf-8"),s=JSON.parse(t);return s&&typeof s==="object"?s:{}}catch{return{}}}function $n(e,t){try{ee.mkdirSync(Q.dirname(Ue(e)),{recursive:!0}),ee.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=ee.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function At(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function so(e){let t=At(e);return t?ye().catalog.get(t):void 0}function oo(e){let t=At(e);return t?ye().transparent.has(t):!1}function io(e){let t=(i)=>e.variants.filter((o)=>o.format===i).reduce((o,a)=>o+a.bytes,0),s=t(e.fallback.format);return["avif","webp"].map((i)=>({format:i,srcset:e.sources[i]||"",bytes:t(i)})).filter((i)=>i.srcset&&i.bytes>0&&i.bytes<s).sort((i,o)=>i.bytes-o.bytes).map(({format:i,srcset:o})=>({format:i,srcset:o}))}function hp(e){let t=so(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:io(t).map(({format:s,srcset:i})=>({type:`image/${s}`,srcset:i})),width:t.source.width,height:t.source.height,placeholder:oo(e)?void 0:t.placeholder?.dataUrl}}function Hr(){let e=ye();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=ye();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function yp(e,t,s={}){if(!e||!ee.existsSync(e))return Hr(),{count:0,fingerprint:""};if(s.offThread){let m=await ze("delivery",{publicDir:e,outputDir:t});if(m!==ke)return Sn(m.state),m.result}let i=await Rt(e);if(i.length===0)return Hr(),{count:0,fingerprint:""};let o=wn(t),a=i.filter((m)=>{let b=o[m.relativePath];if(!b)return!0;let w=St(m.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return Hr(),{count:0,fingerprint:""};let c=wt(Q.join(t,"_stx","images"),`${ln}:${xt()}`),g={outDir:Q.join(t,"_stx","images"),storage:wt(Q.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:he,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await yt({...g,entries:$t(a,c)})}catch(m){if(l=await vn(a),l.length===a.length)throw m;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=St(C.absolutePath);if(!k)continue;o[C.relativePath]=k,w=!0}if(w)$n(t,o);if(l.length===0)return Hr(),{count:0,fingerprint:""};h=await yt({...g,entries:$t(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=ye();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:Ct("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,s,i){let o=To(e,i);if(o!==void 0)return o;for(let a of $o(e,t,s,i))if(await n(a))return a;return null}}var le=new kt;function R(e){return V(e)}var se="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Fe(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function ie(e,t){let s=[];for(let[i,o]of Object.entries(e.static)){if(t.has(i))continue;let a=e.staticNames?.[i]??i;if(typeof o==="boolean"){if(o)s.push(d(a));continue}if(o===se){s.push(d(a));continue}s.push(`${d(a)}="${mn(a,We(String(o)))}"`)}return s}function ae(e,t){let s=[];for(let[i,o]of Object.entries(e.serverDynamic??{})){if(t.has(i))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[i]??i;if(o===!0){s.push(d(a));continue}if(typeof o==="object")continue;s.push(`${d(a)}="${mn(a,We(String(o)))}"`)}return s}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var He={name:"StxLink",aliases:["stx-link"],render(e,t,s){let i=Rn(e),o=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",g=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(i.reactive)l.push(`:href="${R(i.value)}"`);else l.push(`href="${R(ar(i.value,"navigable"))}"`);if(o)l.push(`class="${R(o)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),g)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...ie(e,v)),l.push(...ae(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function qe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Xe=[320,640,768,1024,1280,1536,1920];function J(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let s=e.static[t];if(typeof s==="string")return s;return}function _e(e,t,s=!1){let i=e.serverDynamic[t];if(i!==void 0)return i!==!1&&i!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return s}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),s=[];for(let i of t)if(i.includes(":")){let[o,a]=i.split(":"),c=kn[o];if(c)s.push(`(max-width: ${c}px) ${a}`);else{let g=Number.parseInt(o);if(!Number.isNaN(g))s.push(`(max-width: ${g}px) ${a}`)}}else s.push(i);return s.join(", ")}function Ve(e,t,s,i){return t.map((o)=>`${xe(e,o,void 0,s,i)} ${o}w`).join(", ")}function Pn(e,t,s,i,o){return t.map((a)=>{let c=s?s*a:void 0;return`${xe(e,c,void 0,i,o)} ${a}x`}).join(", ")}function xe(e,t,s,i,o){if(!i||i==="local"||i==="static")return e;if(i==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(s)a.push(`h_${s}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(i==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(s)a.set("h",String(s));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(i==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(s)a.set("height",String(s));if(o)a.set("format",o);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,s="#e5e7eb"){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${s}"/></svg>`;return`data:image/svg+xml;base64,${btoa(i)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,s){let i=J(e,"src")||"",o=so(i),a=J(e,"alt")||"",c=J(e,"width")||(o?String(o.source.width):void 0),g=J(e,"height")||(o?String(o.source.height):void 0),l=J(e,"sizes"),h=J(e,"srcset"),v=J(e,"densities"),y=J(e,"format"),S=oo(i)||qe(i)?.transparent===!0,x=J(e,"placeholder")||(o&&!S?"thumbhash":void 0),m=J(e,"placeholderColor")||"#e5e7eb",b=J(e,"provider"),w=J(e,"class")||J(e,"className")||"",C=J(e,"style")||"",k=J(e,"objectFit")||J(e,"fit"),A=J(e,"objectPosition")||J(e,"position"),I=J(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),q=J(e,"loading"),N=J(e,"decoding")||"async",_=!!o||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=g?Number.parseInt(g):void 0,z=h||"",G="";if(o)z=o.sources[o.fallback.format]||"",G=l?Ze(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(i,Xe,b,y),G=Ze(l);else if(!z&&v){let P=v.split(/\s+/).map((F)=>Number.parseFloat(F.replace("x","")));z=Pn(i,P,O,b,y)}else if(l)G=Ze(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:m}:qe(i);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let F=In(O||16,B||9,m);D.push(`background-image:url(${F})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let we=o?.fallback.url||xe(i,O,B,b,y),Y=[];if(Y.push(`src="${R(ar(we,"fetched"))}"`),Y.push(`alt="${R(a)}"`),c)Y.push(`width="${R(c)}"`);if(g)Y.push(`height="${R(g)}"`);let ne=q||(L||M?"eager":U?"lazy":"");if(ne)Y.push(`loading="${R(ne)}"`);if(L)Y.push('fetchpriority="high"');if(Y.push(`decoding="${R(N)}"`),w)Y.push(`class="${R(w)}"`);if(D.length>0)Y.push(`style="${R(D.join(";"))}"`);if(z)Y.push(`srcset="${R(ar(z,"fetched"))}"`);if(G)Y.push(`sizes="${R(G)}"`);let $e=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",F=_n(W)+(P?`;${P}`:"");Y.push(`onload="${R(F)}"`),$e.add("onload")}Y.push(...ie(e,$e)),Y.push(...ae(e,$e));let T=`<img ${Y.join(" ")} />`,Z="";if(M){let F=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(we)}"${F?` type="${F}"`:""}${z?` imagesrcset="${R(z)}"`:""}${G?` imagesizes="${R(G)}"`:""} />
|
|
3
|
-
`}if(_){let P=[];if(o)for(let F of io(o))P.push(`<source type="image/${F.format}" srcset="${R(F.srcset)}"${
|
|
2
|
+
import{gc,mc}from"./chunk-gtktv6nn.js";import{j,cs,ls,us,To,$o,ar,Ie,de,G,ps,oe,X,H,et,lr,Io,pr,je,n,d,V,mn}from"./chunk-xw0cqb5m.js";import{p,E,tt,u}from"./chunk-r0ys9aqa.js";import{re}from"./chunk-hx787tfa.js";import{r}from"./chunk-9tg4995v.js";import{f}from"./chunk-b7e07ybq.js";import{createHash as Ct}from"crypto";import ee from"fs";import Q from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import Te from"fs";function Ce(e,t,s){let i=Buffer.alloc(s),o=Te.readSync(e,i,0,s,t);return i.subarray(0,o)}function De(e){if(e.length<25)return!1;let t=(i,o)=>String.fromCharCode(...e.subarray(i,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let s=t(12,16);if(s==="VP8X")return(e[20]&16)!==0;if(s==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=Te.openSync(e,"r");let s=Ce(t,0,33);if(s.length>=3&&s[0]===255&&s[1]===216&&s[2]===255)return"none";if(s.length>=26&&s[0]===137&&s.toString("latin1",1,4)==="PNG"){let i=s[25];if(i===4||i===6)return"possible";let o=8;for(let a=0;a<64;a++){let c=Ce(t,o,8);if(c.length<8)return"unknown";let g=c.toString("latin1",4,8);if(g==="tRNS")return"possible";if(g==="IDAT"||g==="IEND")return"none";o+=12+c.readUInt32BE(0)}return"unknown"}if(s.length>=25&&s.toString("latin1",0,4)==="RIFF"&&s.toString("latin1",8,12)==="WEBP"){if(De(s))return"possible";let i=s.toString("latin1",12,16);return i==="VP8 "||i==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Te.closeSync(t)}}import Jt from"fs";import Re from"os";import{join as dt}from"path";import{fileURLToPath as gt}from"url";import{Worker as mt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function en(){Ae--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let s=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(s.protocol==="file:"&&Jt.existsSync(gt(s)))return gt(s)}catch{}try{let s=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return s&&rn(s)?s:void 0}catch{return}}function rn(e,t=process.env){let s=e.replace(/\\/g,"/");if(s.split("/").some((o)=>/@\d[^/]*@@@\d+$/.test(o)))return!1;return![t.BUN_INSTALL_CACHE_DIR,dt(t.BUN_INSTALL||dt(Re.homedir(),".bun"),"install","cache")].filter((o)=>!!o).map((o)=>`${o.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((o)=>s.startsWith(o))}var pt=!1;function pe(e){if(!pt)pt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return pe("node:worker_threads has no Worker in this runtime");let s=nn();if(!s)return pe("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((i,o)=>{let a;try{a=new mt(s)}catch(h){i(pe(`could not start ${s}: ${Le(h)}`));return}let c=!1,g=!1,l=(h)=>{if(g)return;g=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>i(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>o(v))}),a.on("error",(h)=>{l(()=>c?o(h instanceof Error?h:Error(Le(h)||"image worker crashed")):i(pe(`the worker failed before it was ready: ${Le(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):i(pe(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],he="/_stx/images",ln=`stx:${he}:alpha-1`,un=`stx:${he}:opaque-1`,fn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function dn(e,t){let s=Q.dirname(Bun.resolveSync(e,t));while(s!==Q.dirname(s)){let i=Q.join(s,"package.json");if(ee.existsSync(i)){let o=JSON.parse(ee.readFileSync(i,"utf8"));if(o.name===e)return o.version}s=Q.dirname(s)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=Q.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=fn.map((t)=>{let s;try{s=e?dn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${s??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function ye(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function gn(e){return`/${e.split(Q.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=Q.extname(e),s=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),i=Ct("sha256").update(e).digest("hex").slice(0,8);return`${s||"image"}-${i}`}function wt(e,t=`stx:${he}`){let s=(i)=>`${he}/${i.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(i){let o=Q.join(e,i);try{let a=await ee.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:s(i)}:null}catch{return null}},async write(i,o){let a=Q.join(e,i);await ee.promises.mkdir(Q.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await ee.promises.writeFile(c,o),await ee.promises.rename(c,a),{bytes:o.byteLength,path:a,url:s(i)}},url:s}}async function Rt(e,t=e){let s=await ee.promises.readdir(t,{withFileTypes:!0});s.sort((o,a)=>o.name.localeCompare(a.name));let i=[];for(let o of s){let a=Q.join(t,o.name);if(o.isDirectory()){i.push(...await Rt(e,a));continue}if(!o.isFile()||!an.has(Q.extname(o.name).toLowerCase()))continue;i.push({absolutePath:a,relativePath:Q.relative(e,a)})}return i}function $t(e,t){return e.map((s)=>({key:gn(s.relativePath),input:s.absolutePath,name:pn(s.relativePath),...hn(s.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return Me(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,o])=>o.fallback.format==="png"),s=new Set,i=8;for(let o=0;o<t.length;o+=8)await Promise.all(t.slice(o,o+8).map(async([a,c])=>{let g=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await ee.promises.readFile(g?.path??c.fallback.path)));if(yn(l.data))s.add(a)}catch{s.add(a)}}));return s}function bn(e,t){let s=[];for(let i of t){let o=e[i],a=o?.variants.filter((g)=>g.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((g)=>{let l;try{return l=ee.openSync(g.path,"r"),!De(Ce(l,0,32))}catch{return!0}finally{if(l!==void 0)ee.closeSync(l)}}))continue;if(o.variants=o.variants.filter((g)=>g.format!=="webp"),delete o.sources.webp,s.push(i),!vt.has(i))vt.add(i),console.warn(`[stx-images] ${i} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return s}async function vn(e){let t=[],s=8;for(let i=0;i<e.length;i+=8){let o=e.slice(i,i+8),a=await Promise.all(o.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function Ue(e){return Q.join(e,"undecodable.json")}function wn(e){try{let t=ee.readFileSync(Ue(e),"utf-8"),s=JSON.parse(t);return s&&typeof s==="object"?s:{}}catch{return{}}}function $n(e,t){try{ee.mkdirSync(Q.dirname(Ue(e)),{recursive:!0}),ee.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=ee.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function At(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function so(e){let t=At(e);return t?ye().catalog.get(t):void 0}function oo(e){let t=At(e);return t?ye().transparent.has(t):!1}function io(e){let t=(i)=>e.variants.filter((o)=>o.format===i).reduce((o,a)=>o+a.bytes,0),s=t(e.fallback.format);return["avif","webp"].map((i)=>({format:i,srcset:e.sources[i]||"",bytes:t(i)})).filter((i)=>i.srcset&&i.bytes>0&&i.bytes<s).sort((i,o)=>i.bytes-o.bytes).map(({format:i,srcset:o})=>({format:i,srcset:o}))}function hp(e){let t=so(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:io(t).map(({format:s,srcset:i})=>({type:`image/${s}`,srcset:i})),width:t.source.width,height:t.source.height,placeholder:oo(e)?void 0:t.placeholder?.dataUrl}}function Hr(){let e=ye();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=ye();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function yp(e,t,s={}){if(!e||!ee.existsSync(e))return Hr(),{count:0,fingerprint:""};if(s.offThread){let m=await ze("delivery",{publicDir:e,outputDir:t});if(m!==ke)return Sn(m.state),m.result}let i=await Rt(e);if(i.length===0)return Hr(),{count:0,fingerprint:""};let o=wn(t),a=i.filter((m)=>{let b=o[m.relativePath];if(!b)return!0;let w=St(m.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return Hr(),{count:0,fingerprint:""};let c=wt(Q.join(t,"_stx","images"),`${ln}:${xt()}`),g={outDir:Q.join(t,"_stx","images"),storage:wt(Q.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:he,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await yt({...g,entries:$t(a,c)})}catch(m){if(l=await vn(a),l.length===a.length)throw m;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=St(C.absolutePath);if(!k)continue;o[C.relativePath]=k,w=!0}if(w)$n(t,o);if(l.length===0)return Hr(),{count:0,fingerprint:""};h=await yt({...g,entries:$t(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=ye();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:Ct("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,s,i){let o=To(e,i);if(o!==void 0)return o;for(let a of $o(e,t,s,i))if(await n(a))return a;return null}}var le=new kt;function R(e){return V(e)}var se="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Fe(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function ie(e,t){let s=[];for(let[i,o]of Object.entries(e.static)){if(t.has(i))continue;let a=e.staticNames?.[i]??i;if(typeof o==="boolean"){if(o)s.push(d(a));continue}if(o===se){s.push(d(a));continue}s.push(`${d(a)}="${mn(a,We(String(o)))}"`)}return s}function ae(e,t){let s=[];for(let[i,o]of Object.entries(e.serverDynamic??{})){if(t.has(i))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[i]??i;if(o===!0){s.push(d(a));continue}if(typeof o==="object")continue;s.push(`${d(a)}="${mn(a,We(String(o)))}"`)}return s}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var He={name:"StxLink",aliases:["stx-link"],render(e,t,s){let i=Rn(e),o=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",g=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(i.reactive)l.push(`:href="${R(i.value)}"`);else l.push(`href="${R(ar(i.value,"navigable"))}"`);if(o)l.push(`class="${R(o)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),g)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...ie(e,v)),l.push(...ae(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function qe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Xe=[320,640,768,1024,1280,1536,1920];function J(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let s=e.static[t];if(typeof s==="string")return s;return}function _e(e,t,s=!1){let i=e.serverDynamic[t];if(i!==void 0)return i!==!1&&i!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return s}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),s=[];for(let i of t)if(i.includes(":")){let[o,a]=i.split(":"),c=kn[o];if(c)s.push(`(max-width: ${c}px) ${a}`);else{let g=Number.parseInt(o);if(!Number.isNaN(g))s.push(`(max-width: ${g}px) ${a}`)}}else s.push(i);return s.join(", ")}function Ve(e,t,s,i){return t.map((o)=>`${xe(e,o,void 0,s,i)} ${o}w`).join(", ")}function Pn(e,t,s,i,o){return t.map((a)=>{let c=s?s*a:void 0;return`${xe(e,c,void 0,i,o)} ${a}x`}).join(", ")}function xe(e,t,s,i,o){if(!i||i==="local"||i==="static")return e;if(i==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(s)a.push(`h_${s}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(i==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(s)a.set("h",String(s));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(i==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(s)a.set("height",String(s));if(o)a.set("format",o);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,s="#e5e7eb"){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${s}"/></svg>`;return`data:image/svg+xml;base64,${btoa(i)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,s){let i=J(e,"src")||"",o=so(i),a=J(e,"alt")||"",c=J(e,"width")||(o?String(o.source.width):void 0),g=J(e,"height")||(o?String(o.source.height):void 0),l=J(e,"sizes"),h=J(e,"srcset"),v=J(e,"densities"),y=J(e,"format"),S=oo(i)||qe(i)?.transparent===!0,x=J(e,"placeholder")||(o&&!S?"thumbhash":void 0),m=J(e,"placeholderColor")||"#e5e7eb",b=J(e,"provider"),w=J(e,"class")||J(e,"className")||"",C=J(e,"style")||"",k=J(e,"objectFit")||J(e,"fit"),A=J(e,"objectPosition")||J(e,"position"),I=J(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),q=J(e,"loading"),N=J(e,"decoding")||"async",_=!!o||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=g?Number.parseInt(g):void 0,z=h||"",K="";if(o)z=o.sources[o.fallback.format]||"",K=l?Ze(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(i,Xe,b,y),K=Ze(l);else if(!z&&v){let P=v.split(/\s+/).map((F)=>Number.parseFloat(F.replace("x","")));z=Pn(i,P,O,b,y)}else if(l)K=Ze(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:m}:qe(i);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let F=In(O||16,B||9,m);D.push(`background-image:url(${F})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let we=o?.fallback.url||xe(i,O,B,b,y),Y=[];if(Y.push(`src="${R(ar(we,"fetched"))}"`),Y.push(`alt="${R(a)}"`),c)Y.push(`width="${R(c)}"`);if(g)Y.push(`height="${R(g)}"`);let ne=q||(L||M?"eager":U?"lazy":"");if(ne)Y.push(`loading="${R(ne)}"`);if(L)Y.push('fetchpriority="high"');if(Y.push(`decoding="${R(N)}"`),w)Y.push(`class="${R(w)}"`);if(D.length>0)Y.push(`style="${R(D.join(";"))}"`);if(z)Y.push(`srcset="${R(ar(z,"fetched"))}"`);if(K)Y.push(`sizes="${R(K)}"`);let $e=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",F=_n(W)+(P?`;${P}`:"");Y.push(`onload="${R(F)}"`),$e.add("onload")}Y.push(...ie(e,$e)),Y.push(...ae(e,$e));let T=`<img ${Y.join(" ")} />`,Z="";if(M){let F=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(we)}"${F?` type="${F}"`:""}${z?` imagesrcset="${R(z)}"`:""}${K?` imagesizes="${R(K)}"`:""} />
|
|
3
|
+
`}if(_){let P=[];if(o)for(let F of io(o))P.push(`<source type="image/${F.format}" srcset="${R(F.srcset)}"${K?` sizes="${R(K)}"`:""} />`);if(!o&&(y==="avif"||y==="auto")){let F=xe(i,O,B,b,"avif"),te=z?Ve(i,Xe,b,"avif"):`${F}`;P.push(`<source type="image/avif" srcset="${R(te)}"${K?` sizes="${R(K)}"`:""} />`)}if(!o&&(y==="webp"||y==="auto")){let F=xe(i,O,B,b,"webp"),te=z?Ve(i,Xe,b,"webp"):`${F}`;P.push(`<source type="image/webp" srcset="${R(te)}"${K?` sizes="${R(K)}"`:""} />`)}return`${Z}<picture>
|
|
4
4
|
${P.join(`
|
|
5
5
|
`)}
|
|
6
6
|
${T}
|
|
@@ -38,5 +38,5 @@ ${T}
|
|
|
38
38
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
39
39
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
40
40
|
</style>`}};import{existsSync as On,readFileSync as Bn}from"fs";var Oe=new Map,Ot=new Set;function Tn(e){if(Ot.has(e))return;Ot.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Dn(e){let t=process.cwd();for(let s of[`${t}/node_modules/@iconify-json/${e}/icons.json`,`${t}/pantry/@iconify-json/${e}/icons.json`,`${t}/node_modules/@iconify/json/json/${e}.json`,`${t}/pantry/@iconify/json/json/${e}.json`])if(On(s))return s;for(let s of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return f.resolve(s)}catch{}return null}function jn(e){if(Oe.has(e))return Oe.get(e);let t=Dn(e);if(!t)return Tn(e),null;try{let s=JSON.parse(Bn(t,"utf8"));return Oe.set(e,s.icons),s.icons}catch{return null}}function ge(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);if(e.static[t]!==void 0)return String(e.static[t]);if(e.clientReactive[t]!==void 0)return e.clientReactive[t];return}var st={name:"Icon",aliases:["icon","stx-icon"],render(e,t,s){let i=ge(e,"name")??ge(e,"icon");if(!i)return"<!-- Icon: missing name/icon prop -->";let o="lucide",a=i;if(i.includes(":")){let k=i.split(":");o=k[0],a=k[1]}let c=R(ge(e,"size")||"24"),g=R(ge(e,"color")||"currentColor"),l=R(ge(e,"class")||""),h=R(ge(e,"style")||""),v=Oe.get(o)??jn(o);if(!v)return`<!-- Icon: collection "${o}" not loaded -->`;let y=v[a];if(!y)return`<!-- Icon: "${a}" not found in ${o} -->`;let S=y.width||24,x=y.height||24,m=`0 0 ${S} ${x}`,b=y.body;if(g!=="currentColor")b=b.replace(/currentColor/g,g);let w=l?` class="${l}"`:"",C=h?` style="${h}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${c}" viewBox="${m}" fill="none"${w}${C}>${b}</svg>`}};function Bt(e,...t){for(let s of t){if(e.serverDynamic[s]!==void 0)return String(e.serverDynamic[s]);let i=e.static[s];if(typeof i==="string")return i}return}function Tt(e,t){let s=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),i=e.match(s);if(!i)return{region:null,rest:e};return{region:i[2],rest:e.replace(i[0],"")}}var it={name:"Suspense",aliases:["suspense"],render(e,t,s){let i=Tt(t,"fallback"),o=i.rest,a=Tt(o,"error"),c=a.rest,g=i.region??Bt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',l=a.region??Bt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${g}</div><div data-stx-suspense-error hidden>${l}</div><div data-stx-suspense-content hidden>${c}</div></div>`}};function Be(e,...t){for(let s of t){if(e.serverDynamic[s]!==void 0)return String(e.serverDynamic[s]);let i=e.static[s];if(typeof i==="string")return i}return}var ot={name:"TransitionGroup",aliases:["transition-group"],render(e,t,s){let i=(Be(e,"name")||"v").replace(/["'<>]/g,""),o=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",a=Be(e,"class"),c=Be(e,"id"),g=[`data-stx-transition-group="${i}"`,a?`class="${a}"`:"",c?`id="${c}"`:""].filter(Boolean).join(" ");return`<${o} ${g}>${t}</${o}>`}};function Dt(e=le){e.registerBuiltin(He),e.registerBuiltin(Ge),e.registerBuiltin(Ke),e.registerBuiltin(Ye),e.registerBuiltin(Qe),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot)}var jt=new Map;function Mn(e){let t=jt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),jt.set(e.source,t);return t}var Mt=new WeakMap;function Lt(e){let t=Mt.get(e);if(!t)t=new Set([...e].map((i)=>i.toLowerCase())),Mt.set(e,t);let s=t;return(i)=>!/[a-z]/.test(i)&&s.has(i.toLowerCase())}function Ln(e,t){let s="";for(let i=t;i<e.length;i++){let o=e[i];if(s){if(o==="\\")i++;else if(o===s)s=""}else if(o==='"'||o==="'")s=o;else if(o===">")return i}return e.length}function zt(e,t,s){let i=[],o=0,a=typeof s==="function"?s:s?(c)=>s.has(c.toLowerCase()):void 0;while(o<e.length){let c=e.indexOf("<",o);if(c===-1)break;let g=Mn(t);g.lastIndex=c+1;let l=g.exec(e);if(!l){o=c+1;continue}let h=l[1];if(a&&a(h)){let w=c+1+h.length;while(w<e.length&&e[w]!==">")w++;o=w+1;continue}let v=c+1+h.length,y=null,S=v,x=-1,m=!1;while(v<e.length){let w=e[v];if(y){if(w==="\\"&&v+1<e.length){v+=2;continue}if(w===y)y=null;v++;continue}if(w==='"'||w==="'"){y=w,v++;continue}if(w==="/"&&v+1<e.length&&e[v+1]===">"){x=v+2,m=!0;break}if(w===">"){x=v+1;break}v++}if(x===-1){o=c+1;continue}let b=e.slice(S,m?x-2:x-1).trim();if(m)i.push({fullMatch:e.slice(c,x),tagName:h,attributes:b,content:"",startIndex:c,endIndex:x,isSelfClosing:!0}),o=x;else{let w=`<${h}`,C=`</${h}>`,k=1,A=x,I=-1;while(k>0&&A<e.length){let L=e.indexOf(w,A),q=e.indexOf(C,A);if(q===-1)break;if(L!==-1&&L<q){let N=e[L+w.length];if(N===" "||N===">"||N==="/"||N===`
|
|
41
|
-
`||N==="\t"){let _=Ln(e,L+w.length);if(e[_-1]!=="/")k++;A=_+1}else A=L+w.length}else{if(k--,k===0){I=q;break}A=q+C.length}}if(I===-1){o=x;continue}let U=e.slice(x,I),M=I+C.length;i.push({fullMatch:e.slice(c,M),tagName:h,attributes:b,content:U,startIndex:c,endIndex:M,isSelfClosing:!1}),o=M}}return i}function at(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,t){try{let s=Buffer.from(e,"base64").toString("utf8");return JSON.parse(s)}catch{}try{let s=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(s)}catch(s){if(t?.debug)console.error("Error decoding __stx_ prop:",s);return e}}function ct(e,t){let s=0,i="",o=t;while(o<e.length){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'"||a==="`")i=a;else if(a==="{")s++;else if(a==="}"){if(s--,s===0)return e.slice(t,o+1)}o++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(ct(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return lt(e).map((t)=>[t.start,t.end])}function lt(e){let t=[],s=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,i;while((i=s.exec(e))!==null){let o=i[2]||"",a=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(o);if(!a)continue;let c=X(a[1]??a[2]??a[3]??""),g=i.index,l=g+i[0].length,h=i[1].toLowerCase();if(i[0].endsWith("/>")||Un.has(h)){t.push({start:g,end:l,names:c});continue}let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");y.lastIndex=l;let S=1,x=l,m;while((m=y.exec(e))!==null)if(m[0].startsWith("</")){if(S--,S===0){x=m.index+m[0].length;break}}else if(!m[0].endsWith("/>"))S++;t.push({start:g,end:x,names:c})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function la(e,t){if(!/:[\w-]+=/.test(e))return e;let s=e,i=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,o=[],a;while((a=i.exec(e))!==null)o.push([a.index,a.index+a[0].length]);o.push(...Wn(e));let c=new Set([...et(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function g(S){return o.some(([x,m])=>S>=x&&S<m)}let l=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,h=[],v=new Map,y=256;while((a=l.exec(s))!==null){if(g(a.index))continue;let S=a[0],x=a[2];if(!x||!x.includes(":"))continue;let m=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,w,C=x,k=!1;while((w=b.exec(x))!==null){if(ps(x,w.index,!0)?.kind==="attribute")continue;let A=w[1],I=w[2];if(gc(A))continue;if(H(I,c))continue;if(I.includes("()")&&!I.includes(".get(")||I.includes("$store")||I.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=I.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let q=JSON.stringify([U,I]),N=v.get(q);if(!N){if(N=Function(...U,`return (${I})`),v.size>=y)v.clear();v.set(q,N)}let _=N(...M);if(A==="class"){let O=V(Ft(_));if(O){let B=C.match(/\sclass="([^"]*)"/);if(B)C=C.replace(B[0],()=>` class="${B[1]} ${O}"`);else C=C.replace(w[0],()=>` class="${O}"`)}else C=C.replace(w[0],"");k=!0;continue}if(zn.has(A)){if(_)C=C.replace(w[0],` ${A}`);else C=C.replace(w[0],"");k=!0;continue}if(_===null||_===void 0||_===!1)C=C.replace(w[0],"");else{let O=m&&typeof _==="object"?JSON.stringify(_):String(_),B=mn(A,O);C=C.replace(w[0],()=>` ${A}="${B}"`)}k=!0}catch(U){if(U instanceof oe)throw U;continue}}if(k){let A=a[3]?" /":"",U=`<${a[1]}${C}${A}>`;h.push({start:a.index,end:a.index+S.length,replacement:U})}}if(h.length>0){let S=Array(h.length*2+1),x=0;for(let m=0;m<h.length;m++){let{start:b,end:w,replacement:C}=h[m];S[m*2]=s.slice(x,b),S[m*2+1]=C,x=w}S[h.length*2]=s.slice(x),s=S.join("")}return s}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,s,i=!1,o=new Set){let a={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},c=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),g=(y)=>{if(c.size===0)return!1;let S=r(y),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&c.has(x))return!0;for(let m of c){let b=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(S))return!0}return!1},l=new Set(mc),h=(y)=>{if(!y.includes("-")||y.startsWith("@")||y.startsWith(":")||y.startsWith("x-")||y.startsWith("__"))return y;if(y.startsWith("aria-")||y.startsWith("data-"))return y;return y.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},v=(y,S)=>{let x=h(y);if(a.static[x]=S,x!==y)a.staticNames[x]=y};for(let[y,S]of Object.entries(e)){let x=y.startsWith("x-")&&!l.has(y)&&!y.startsWith("x-bind:")&&!y.startsWith("x-on:")?`:${y.slice(2)}`:y;if(x.startsWith("@")){a.events[x]=S;continue}if(x.startsWith("__stx_")){let m=h(x.slice(6));a.serverDynamic[m]=Ut(S,s);continue}if(x.startsWith(":")){let m=h(x.slice(1)),b=S===se?m:S;if(m==="if"||m==="for"||m==="show"){a.clientReactive[m]=b;continue}if(i){a.clientReactive[m]=b;continue}if(H(b,o)){a.clientReactive[m]=b;continue}if(g(b)){a.clientReactive[m]=b;continue}try{if(!p(b)){if(s.debug)console.error(`Unsafe expression in :${m} binding: ${b}`);a.clientReactive[m]=b;continue}let w=Object.keys(t),C=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(tt(b).some((M)=>!C.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){a.clientReactive[m]=b;continue}let U=u(b,w)(...Object.values(t));if(a.serverDynamic[m]=U,m!==x.slice(1)&&a.serverDynamicNames)a.serverDynamicNames[m]=x.slice(1)}catch{a.clientReactive[m]=b}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let m=Hn(S,o);if(m!==null){a.clientReactive[h(x)]=m;continue}let b=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(p(w)){let k=u(w,Object.keys(t))(...Object.values(t));v(x,k!=null?String(k):"")}else{if(s.debug)console.error(`Unsafe expression in ${x}: ${w}`);v(x,S)}}catch(w){if(s.debug)console.error(`Error evaluating expression for ${x}:`,w);v(x,S)}else{let w=S,C=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=C.exec(S))!==null)try{let A=k[1];if(!p(A)){if(s.debug)console.error(`Unsafe expression in ${x}: ${A}`);continue}let U=u(A,Object.keys(t))(...Object.values(t));w=w.replace(k[0],String(U??""))}catch(A){if(s.debug)console.error(`Error evaluating expression in ${x}:`,A)}v(x,w)}continue}v(x,S===se?"true":at(S))}return a}function Hn(e,t){if(t.size===0)return null;let s=/\{\{\s*([\s\S]+?)\s*\}\}/g,i=[...e.matchAll(s)];if(!i.some((g)=>H(g[1],t)))return null;let o=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(o&&i.length===1)return o[1];let a="",c=0;for(let g of i)a+=e.slice(c,g.index).replace(/[`\\$]/g,(l)=>`\\${l}`),a+=`\${${g[1]}}`,c=g.index+g[0].length;return a+=e.slice(c).replace(/[`\\$]/g,(g)=>`\\${g}`),`\`${a}\``}var qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,s){if(!e.includes("@"))return e;if(!qn.some(([o,a])=>o.test(e)&&e.includes(a)))return e;try{return re(e,t,s)}catch{return e}}function me(e){let t={},s=0,i=e.length;while(s<i){while(s<i&&/\s/.test(e[s]))s++;if(s>=i)break;let o="";while(s<i&&!/[\s=]/.test(e[s]))o+=e[s],s++;if(!o)break;while(s<i&&/\s/.test(e[s]))s++;if(s<i&&e[s]==="="){s++;while(s<i&&/\s/.test(e[s]))s++;let a="";if(s<i&&(e[s]==='"'||e[s]==="'")){let c=e[s];s++;while(s<i){let g=e[s];if(g==="\\"&&s+1<i){s++,a+=e[s],s++;continue}if(g===c){s++;break}a+=g,s++}}else if(e[s]==="{"){a=ct(e,s),s+=a.length;let c=Wt(a);if(c!==null){t[`:${o}`]=c;continue}}else while(s<i&&!/\s/.test(e[s]))a+=e[s],s++;t[o]=a}else t[o]=se}return t}function Zt(e){return Object.entries(e).map(([t,s])=>s===se?t:`${t}="${Zn(s)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Vn(e){let t=new Set,s=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,i;while((i=s.exec(e))!==null){let o=i[1];if(le.isBuiltin(o))t.add(o)}return[...t].sort()}async function $l(e,t,s,i,o){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let a=t.__importedComponents,c=qt.dirname(s),g=[],l=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(l)){let[S,x,m]=y,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=m,C,k=[];while((C=b.exec(m))!==null){let[A,I,U,M]=C,L=null,q=null;if(M.startsWith(".")||M.startsWith("/")){let O=qt.resolve(c,M);if(O.endsWith(".stx"))q=O;else{let B=`${O}.stx`;try{if(Ht.statSync(B).isFile())q=B}catch{try{if(Ht.statSync(O).isDirectory())L=O}catch{}}}}else L=ls(M,c);if(!L&&!q)continue;let N=!1,_=(O,B)=>{a.set(O,B),a.set(O.toLowerCase(),B);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.set(z,B),o.add(B)};if(U&&q)_(U,q),N=!0;else if(I){let O=I.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let G=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(G)return{source:G[1],local:G[2]};return{source:z,local:z}}),B=L?cs(L):null;for(let{source:z,local:G}of O){let D=null;if(q)D=q;else if(B)D=B.get(z)??B.get(z.toLowerCase())??B.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)_(G,D),N=!0}}if(N)k.push({start:C.index,end:C.index+A.length})}if(k.length===0)continue;for(let A=k.length-1;A>=0;A--)w=w.slice(0,k[A].start)+w.slice(k[A].end);g.push({start:y.index,end:y.index+S.length,value:`<script${x}>${w}</script>`})}if(g.length===0)return e;let h=[],v=0;for(let y of g)h.push(e.slice(v,y.start),y.value),v=y.end;return h.push(e.slice(v)),h.join("")}async function Gn(e,t,s,i,o){let a=e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,g=/@import\s*\(\s*([^)]+)\s*\)/g,l;while((l=g.exec(a))!==null){let[h,v]=l,y=v.split(",").map((S)=>S.trim().replace(/^['"]|['"]$/g,"")).filter((S)=>S.length>0);for(let S of y){let x=S.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((A)=>A.charAt(0).toUpperCase()+A.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),C=null,k=us(S,s,i);for(let A of k)try{if(await Bun.file(A).exists()){C=A;break}}catch{}if(C){c.set(w,C),c.set(b,C),c.set(b.toLowerCase(),C);let A=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(c.set(A,C),o.add(C),i.debug)console.log(`Imported component: ${w} -> ${C}`)}else if(i.debug)console.warn(`Could not resolve imported component: ${S}`)}a=a.replace(h,""),g.lastIndex=0}return a}async function Kn(e,t,s,i,o){let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=/@component\s*\(/g,h;while((h=l.exec(a))!==null){let v=h.index,y=v+h[0].length-1,S=1,x=y+1;while(x<a.length&&S>0){if(a[x]==="(")S++;else if(a[x]===")"){if(S--,S===0)break}x++}if(S!==0)break;let m=a.substring(y+1,x),b=x+1,w=m.match(/^\s*['"]([^'"]+)['"]/);if(!w){l.lastIndex=0;continue}let C=w[1],k,A=m.slice(w[0].length),I=A.match(/^\s*,\s*/);if(I)k=A.slice(I[0].length).trim();let U={};if(k)try{U=E(k,t)}catch(O){let B=O instanceof Error?O.message:String(O);a=a.replace(a.substring(v,b),`[Error parsing component props: ${B}]`);continue}let M="",L=b,N=a.substring(b).match(/^([\s\S]*?)@endcomponent/);if(N)M=N[1].trim(),L=b+N[0].length;let _=await je(C,U,M,c,t,s,i,g,o);a=a.substring(0,v)+_+a.substring(L),l.lastIndex=0}return a}async function Jn(e,t,s,i,o){if(!e)return e;let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=er(a);if(l.size>0){let b=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...b,...l])]}let h=K(a);a=h.output;let v=et(t);return a=await m(a,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),a=await m(a,/[A-Z][a-zA-Z0-9]*/,!0,Lt(lr)),a=await m(a,/[a-z][a-z0-9]*/,!1,lr),a=h.restore(a),a;async function m(b,w,C,k){if(!b)return b;let A=b,I=zt(A,w,k),U=lt(A),M=new Map;for(let N=I.length-1;N>=0;N--){let _=I[N],O=C?j(_.tagName):_.tagName,B=me(Xn(_.attributes,t,s)),z=U.filter(({start:Z,end:P})=>_.startIndex>=Z&&_.startIndex<P),G=z.length>0,D=new Set(v);for(let Z of z)for(let P of Z.names)D.add(P);let W=Fn(B,t,i,G,D);if(typeof W.clientReactive.for==="string")for(let Z of X(W.clientReactive.for))D.add(Z);let ce=le.getBuiltin(_.tagName),we=ce?await pr(_.tagName,c,t,s,i):!1;if(ce&&!we){let Z={context:t,filePath:s,options:i,dependencies:o},P=ce.render(W,_.content,Z);if(Object.keys(W.events).length>0){let F=Zt(W.events);P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${F}`)}if(Object.keys(W.clientReactive).length>0)P=Vt(P,W.clientReactive);M.set(N,P);continue}if(!C&&_.tagName.includes("-")&&!await pr(O,c,t,s,i))continue;let Y={};for(let[Z,P]of Object.entries(W.static))Y[Z]=P;for(let[Z,P]of Object.entries(W.serverDynamic))Y[Z]=P;let ne={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},T=await je(O,Y,h.restore(_.content),c,t,s,i,g,o,[...D],ne,_.tagName);if(T=Yn(T,W,ne.declaredProps,ne.consumedProps,i._nativeHostAttrs),i._nativeHostAttrs){let Z=ne.reactiveProps.filter((te)=>!ne.consumedProps.has(te)&&!["if","for","show","key","ref"].includes(te)).map(j),P=ut(T,!0);if(Z.length&&P){if(!Object.hasOwn(me(T.slice(P.insertPos,P.tagEnd)),"data-stx-native-host-root"))T=T.slice(0,P.insertPos)+' data-stx-native-host-root="true"'+T.slice(P.insertPos);let te=ve(T);T=T.slice(0,te.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+T.slice(te.insertPos)}let F=ut(T,!0);if(F){let te=me(T.slice(F.insertPos,F.tagEnd)),Se=ve(T),Kt=me(T.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(te,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))T=T.slice(0,Se.insertPos)+" data-stx-native-host-owner"+T.slice(Se.insertPos)}}if(Object.keys(W.events).length>0){let Z=ve(T);if(Z){let P=Zt(W.events),F=Object.keys(W.events).map((te)=>te.replace(/^@/,"").split(".")[0]).join(" ");T=T.substring(0,Z.insertPos)+` data-stx-parent-events="${F}" ${P}`+T.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)T=Vt(T,W.clientReactive);M.set(N,T)}if(M.size===0)return A;let L="",q=0;for(let N=0;N<I.length;N++){let _=M.get(N);if(_===void 0)continue;L+=A.slice(q,I[N].startIndex),L+=_,q=I[N].endIndex}return L+=A.slice(q),L}}function Vt(e,t){let s=new Set(["if","for"]),i=new Set(["show"]),o=Object.entries(t).filter(([v])=>!s.has(v)),a=o.filter(([v])=>!i.has(v)).map(([v])=>j(v)).join(" "),c=e,g=o.length>0?ve(c):null;if(g){let v=o.map(([S,x])=>`:${j(S)}="${x.replace(/"/g,""")}"`).join(" "),y=a?` data-stx-parent-bindings="${a}"`:"";c=c.substring(0,g.insertPos)+`${y} ${v}`+c.substring(g.insertPos)}let l=t.if;if(l)c=`<template :if="${l.replace(/"/g,""")}">${c}</template>`;let h=t.for;if(h){let v=t.key,y=v?` :key="${v.replace(/"/g,""")}"`:"";c=`<template :for="${h.replace(/"/g,""")}"${y}>${c}</template>`}return c}function Yn(e,t,s=new Set,i=new Set,o=!1){let a=ut(e,o);if(!a)return e;let c=e.slice(a.insertPos,a.tagEnd),g=t.serverDynamic.class??t.static.class;if(o&&typeof g==="string"&&g&&!i.has("class")){let m=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=m.test(c)?c.replace(m,(w,C,k,A,I)=>`${C}class="${R(`${at(k??A??I)} ${g}`)}"`):` class="${R(g)}"${c}`;e=e.slice(0,a.insertPos)+b+e.slice(a.tagEnd),a.tagEnd+=b.length-c.length,c=b}let l=o||/\bdata-native(?:\s|=)/i.test(c),h=l?i:s,v=new Set(Object.keys(me(c))),y=new Set(["class","className"]);for(let m of Object.keys(t.static)){let b=t.staticNames[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}for(let m of Object.keys(t.serverDynamic)){let b=t.serverDynamicNames?.[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}let S=[];if(l){for(let[m,b]of Object.entries(t.static)){if(y.has(m)||b!==!0&&b!==se)continue;y.add(m),S.push(`${R(t.staticNames?.[m]??m)}="true"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!0)continue;y.add(m),S.push(`${R(t.serverDynamicNames?.[m]??m)}="true"`)}}let x=[...ie(t,y),...ae(t,y),...S];if(l){for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!1)continue;let w=t.serverDynamicNames?.[m]??m;x.push(`${R(w)}="false"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let C=t.serverDynamicNames?.[m]??m;x.push(`${R(C)}="${R(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,a.insertPos)} ${x.join(" ")}${e.slice(a.insertPos)}`}function ve(e){let t=Gt(e,0);if(t)return t;let s=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(s)return{insertPos:s.index+1+s[1].length,tagEnd:ft(e,s.index+1+s[1].length)};return null}function ut(e,t=!1){let s=ve(e);if(!s)return null;let i=e.slice(s.insertPos,s.tagEnd),o=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(i)?Gt(e,s.tagEnd+1):s;return o&&t?Qn(e,o)??o:o}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),i=e.lastIndexOf("<",t.insertPos),o=0,a;while(i>=0&&i<e.length){if(e.startsWith("<!--",i)){let v=e.indexOf("-->",i+4);if(v<0)return null;i=e.indexOf("<",v+3);continue}let c=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(i));if(!c){i=e.indexOf("<",i+1);continue}let g=c[2].toLowerCase(),l=i+c[0].length,h=ft(e,l);if(c[1]){if(o--,a!==void 0&&o<a)a=void 0;if(o<=0)return null}else if(g==="script"||g==="style"){let v=new RegExp(`</${g}\\s*>`,"gi");if(v.lastIndex=h+1,!v.exec(e))return null;i=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(l,h)),y=o>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(a===void 0&&!y&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:l,tagEnd:h};if(!s.has(g)&&e[h-1]!=="/"){if(o++,a===void 0&&y)a=o}else if(o===0)return null}i=e.indexOf("<",h+1)}return null}function Gt(e,t){let s=t;while(s<e.length){let i=e.slice(s),o=i.match(/^\s+/);if(o){s+=o[0].length;continue}if(i.startsWith("<!--")){let g=e.indexOf("-->",s+4);if(g===-1)return null;s=g+3;continue}let a=i.match(/^<(script|style)\b[^>]*>/i);if(a){let g=`</${a[1].toLowerCase()}>`,l=e.toLowerCase().indexOf(g,s+a[0].length);if(l===-1)return null;s=l+g.length;continue}let c=i.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!c)return null;return{insertPos:s+1+c[1].length,tagEnd:ft(e,s+1+c[1].length)}}return null}function ft(e,t){let s="";for(let i=t;i<e.length;i++){let o=e[i];if(s){if(o==="\\")i++;else if(o===s)s=""}else if(o==='"'||o==="'")s=o;else if(o===">")return i}return e.length}function er(e){let t=new Set;for(let s of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=s[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let o of Io(s[2]))t.add(o);for(let o of s[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(o[1])t.add(o[1]);if(o[3])t.add(o[3]);for(let a of(o[2]??"").split(",")){let c=a.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}}}return t}async function Vr(e,t,s,i,o){if(!Xt)Dt(le),Xt=!0;let a=await $l(e,t,s,i,o);a=await Gn(a,t,s,i,o),a=await Kn(a,t,s,i,o);let c=[];for(let g=0;g<3;g++){let l=c.length,h=de(a,Ie,(y,S)=>`\x00STX_COMPONENT_COMMENT_${l+S}\x00`,`STX_COMPONENT_COMMENT:${l}`);c.push(...h.tokens);let v=a;if(a=await Jn(h.output,t,s,i,o),a===v)break}if(c.length>0)a=a.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(g,l)=>c[Number(l)]??"");if(i.debug){let g=Vn(a);if(g.length>0)console.warn(`[stx] ${s}: unresolved component tag(s) after render passes: ${g.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return a}
|
|
41
|
+
`||N==="\t"){let _=Ln(e,L+w.length);if(e[_-1]!=="/")k++;A=_+1}else A=L+w.length}else{if(k--,k===0){I=q;break}A=q+C.length}}if(I===-1){o=x;continue}let U=e.slice(x,I),M=I+C.length;i.push({fullMatch:e.slice(c,M),tagName:h,attributes:b,content:U,startIndex:c,endIndex:M,isSelfClosing:!1}),o=M}}return i}function at(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,t){try{let s=Buffer.from(e,"base64").toString("utf8");return JSON.parse(s)}catch{}try{let s=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(s)}catch(s){if(t?.debug)console.error("Error decoding __stx_ prop:",s);return e}}function ct(e,t){let s=0,i="",o=t;while(o<e.length){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'"||a==="`")i=a;else if(a==="{")s++;else if(a==="}"){if(s--,s===0)return e.slice(t,o+1)}o++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(ct(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return lt(e).map((t)=>[t.start,t.end])}function lt(e){let t=[],s=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,i;while((i=s.exec(e))!==null){let o=i[2]||"",a=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(o);if(!a)continue;let c=X(a[1]??a[2]??a[3]??""),g=i.index,l=g+i[0].length,h=i[1].toLowerCase();if(i[0].endsWith("/>")||Un.has(h)){t.push({start:g,end:l,names:c});continue}let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");y.lastIndex=l;let S=1,x=l,m;while((m=y.exec(e))!==null)if(m[0].startsWith("</")){if(S--,S===0){x=m.index+m[0].length;break}}else if(!m[0].endsWith("/>"))S++;t.push({start:g,end:x,names:c})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function la(e,t){if(!/:[\w-]+=/.test(e))return e;let s=e,i=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,o=[],a;while((a=i.exec(e))!==null)o.push([a.index,a.index+a[0].length]);o.push(...Wn(e));let c=new Set([...et(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function g(S){return o.some(([x,m])=>S>=x&&S<m)}let l=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,h=[],v=new Map,y=256;while((a=l.exec(s))!==null){if(g(a.index))continue;let S=a[0],x=a[2];if(!x||!x.includes(":"))continue;let m=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,w,C=x,k=!1;while((w=b.exec(x))!==null){if(ps(x,w.index,!0)?.kind==="attribute")continue;let A=w[1],I=w[2];if(gc(A))continue;if(H(I,c))continue;if(I.includes("()")&&!I.includes(".get(")||I.includes("$store")||I.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=I.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let q=JSON.stringify([U,I]),N=v.get(q);if(!N){if(N=Function(...U,`return (${I})`),v.size>=y)v.clear();v.set(q,N)}let _=N(...M);if(A==="class"){let O=V(Ft(_));if(O){let B=C.match(/\sclass="([^"]*)"/);if(B)C=C.replace(B[0],()=>` class="${B[1]} ${O}"`);else C=C.replace(w[0],()=>` class="${O}"`)}else C=C.replace(w[0],"");k=!0;continue}if(zn.has(A)){if(_)C=C.replace(w[0],` ${A}`);else C=C.replace(w[0],"");k=!0;continue}if(_===null||_===void 0||_===!1)C=C.replace(w[0],"");else{let O=m&&typeof _==="object"?JSON.stringify(_):String(_),B=mn(A,O);C=C.replace(w[0],()=>` ${A}="${B}"`)}k=!0}catch(U){if(U instanceof oe)throw U;continue}}if(k){let A=a[3]?" /":"",U=`<${a[1]}${C}${A}>`;h.push({start:a.index,end:a.index+S.length,replacement:U})}}if(h.length>0){let S=Array(h.length*2+1),x=0;for(let m=0;m<h.length;m++){let{start:b,end:w,replacement:C}=h[m];S[m*2]=s.slice(x,b),S[m*2+1]=C,x=w}S[h.length*2]=s.slice(x),s=S.join("")}return s}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,s,i=!1,o=new Set){let a={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},c=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),g=(y)=>{if(c.size===0)return!1;let S=r(y),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&c.has(x))return!0;for(let m of c){let b=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(S))return!0}return!1},l=new Set(mc),h=(y)=>{if(!y.includes("-")||y.startsWith("@")||y.startsWith(":")||y.startsWith("x-")||y.startsWith("__"))return y;if(y.startsWith("aria-")||y.startsWith("data-"))return y;return y.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},v=(y,S)=>{let x=h(y);if(a.static[x]=S,x!==y)a.staticNames[x]=y};for(let[y,S]of Object.entries(e)){let x=y.startsWith("x-")&&!l.has(y)&&!y.startsWith("x-bind:")&&!y.startsWith("x-on:")?`:${y.slice(2)}`:y;if(x.startsWith("@")){a.events[x]=S;continue}if(x.startsWith("__stx_")){let m=h(x.slice(6));a.serverDynamic[m]=Ut(S,s);continue}if(x.startsWith(":")){let m=h(x.slice(1)),b=S===se?m:S;if(m==="if"||m==="for"||m==="show"){a.clientReactive[m]=b;continue}if(i){a.clientReactive[m]=b;continue}if(H(b,o)){a.clientReactive[m]=b;continue}if(g(b)){a.clientReactive[m]=b;continue}try{if(!p(b)){if(s.debug)console.error(`Unsafe expression in :${m} binding: ${b}`);a.clientReactive[m]=b;continue}let w=Object.keys(t),C=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(tt(b).some((M)=>!C.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){a.clientReactive[m]=b;continue}let U=u(b,w)(...Object.values(t));if(a.serverDynamic[m]=U,m!==x.slice(1)&&a.serverDynamicNames)a.serverDynamicNames[m]=x.slice(1)}catch{a.clientReactive[m]=b}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let m=Hn(S,o);if(m!==null){a.clientReactive[h(x)]=m;continue}let b=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(p(w)){let k=u(w,Object.keys(t))(...Object.values(t));v(x,k!=null?String(k):"")}else{if(s.debug)console.error(`Unsafe expression in ${x}: ${w}`);v(x,S)}}catch(w){if(s.debug)console.error(`Error evaluating expression for ${x}:`,w);v(x,S)}else{let w=S,C=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=C.exec(S))!==null)try{let A=k[1];if(!p(A)){if(s.debug)console.error(`Unsafe expression in ${x}: ${A}`);continue}let U=u(A,Object.keys(t))(...Object.values(t));w=w.replace(k[0],String(U??""))}catch(A){if(s.debug)console.error(`Error evaluating expression in ${x}:`,A)}v(x,w)}continue}v(x,S===se?"true":at(S))}return a}function Hn(e,t){if(t.size===0)return null;let s=/\{\{\s*([\s\S]+?)\s*\}\}/g,i=[...e.matchAll(s)];if(!i.some((g)=>H(g[1],t)))return null;let o=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(o&&i.length===1)return o[1];let a="",c=0;for(let g of i)a+=e.slice(c,g.index).replace(/[`\\$]/g,(l)=>`\\${l}`),a+=`\${${g[1]}}`,c=g.index+g[0].length;return a+=e.slice(c).replace(/[`\\$]/g,(g)=>`\\${g}`),`\`${a}\``}var qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,s){if(!e.includes("@"))return e;if(!qn.some(([o,a])=>o.test(e)&&e.includes(a)))return e;try{return re(e,t,s)}catch{return e}}function me(e){let t={},s=0,i=e.length;while(s<i){while(s<i&&/\s/.test(e[s]))s++;if(s>=i)break;let o="";while(s<i&&!/[\s=]/.test(e[s]))o+=e[s],s++;if(!o)break;while(s<i&&/\s/.test(e[s]))s++;if(s<i&&e[s]==="="){s++;while(s<i&&/\s/.test(e[s]))s++;let a="";if(s<i&&(e[s]==='"'||e[s]==="'")){let c=e[s];s++;while(s<i){let g=e[s];if(g==="\\"&&s+1<i){s++,a+=e[s],s++;continue}if(g===c){s++;break}a+=g,s++}}else if(e[s]==="{"){a=ct(e,s),s+=a.length;let c=Wt(a);if(c!==null){t[`:${o}`]=c;continue}}else while(s<i&&!/\s/.test(e[s]))a+=e[s],s++;t[o]=a}else t[o]=se}return t}function Zt(e){return Object.entries(e).map(([t,s])=>s===se?t:`${t}="${Zn(s)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Vn(e){let t=new Set,s=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,i;while((i=s.exec(e))!==null){let o=i[1];if(le.isBuiltin(o))t.add(o)}return[...t].sort()}async function $l(e,t,s,i,o){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let a=t.__importedComponents,c=qt.dirname(s),g=[],l=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(l)){let[S,x,m]=y,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=m,C,k=[];while((C=b.exec(m))!==null){let[A,I,U,M]=C,L=null,q=null;if(M.startsWith(".")||M.startsWith("/")){let O=qt.resolve(c,M);if(O.endsWith(".stx"))q=O;else{let B=`${O}.stx`;try{if(Ht.statSync(B).isFile())q=B}catch{try{if(Ht.statSync(O).isDirectory())L=O}catch{}}}}else L=ls(M,c);if(!L&&!q)continue;let N=!1,_=(O,B)=>{a.set(O,B),a.set(O.toLowerCase(),B);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.set(z,B),o.add(B)};if(U&&q)_(U,q),N=!0;else if(I){let O=I.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let K=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(K)return{source:K[1],local:K[2]};return{source:z,local:z}}),B=L?cs(L):null;for(let{source:z,local:K}of O){let D=null;if(q)D=q;else if(B)D=B.get(z)??B.get(z.toLowerCase())??B.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)_(K,D),N=!0}}if(N)k.push({start:C.index,end:C.index+A.length})}if(k.length===0)continue;for(let A=k.length-1;A>=0;A--)w=w.slice(0,k[A].start)+w.slice(k[A].end);g.push({start:y.index,end:y.index+S.length,value:`<script${x}>${w}</script>`})}if(g.length===0)return e;let h=[],v=0;for(let y of g)h.push(e.slice(v,y.start),y.value),v=y.end;return h.push(e.slice(v)),h.join("")}async function Gn(e,t,s,i,o){let a=e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,g=/@import\s*\(\s*([^)]+)\s*\)/g,l;while((l=g.exec(a))!==null){let[h,v]=l,y=v.split(",").map((S)=>S.trim().replace(/^['"]|['"]$/g,"")).filter((S)=>S.length>0);for(let S of y){let x=S.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((A)=>A.charAt(0).toUpperCase()+A.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),C=null,k=us(S,s,i);for(let A of k)try{if(await Bun.file(A).exists()){C=A;break}}catch{}if(C){c.set(w,C),c.set(b,C),c.set(b.toLowerCase(),C);let A=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(c.set(A,C),o.add(C),i.debug)console.log(`Imported component: ${w} -> ${C}`)}else if(i.debug)console.warn(`Could not resolve imported component: ${S}`)}a=a.replace(h,""),g.lastIndex=0}return a}async function Kn(e,t,s,i,o){let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=/@component\s*\(/g,h;while((h=l.exec(a))!==null){let v=h.index,y=v+h[0].length-1,S=1,x=y+1;while(x<a.length&&S>0){if(a[x]==="(")S++;else if(a[x]===")"){if(S--,S===0)break}x++}if(S!==0)break;let m=a.substring(y+1,x),b=x+1,w=m.match(/^\s*['"]([^'"]+)['"]/);if(!w){l.lastIndex=0;continue}let C=w[1],k,A=m.slice(w[0].length),I=A.match(/^\s*,\s*/);if(I)k=A.slice(I[0].length).trim();let U={};if(k)try{U=E(k,t)}catch(O){let B=O instanceof Error?O.message:String(O);a=a.replace(a.substring(v,b),`[Error parsing component props: ${B}]`);continue}let M="",L=b,N=a.substring(b).match(/^([\s\S]*?)@endcomponent/);if(N)M=N[1].trim(),L=b+N[0].length;let _=await je(C,U,M,c,t,s,i,g,o);a=a.substring(0,v)+_+a.substring(L),l.lastIndex=0}return a}async function Jn(e,t,s,i,o){if(!e)return e;let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=er(a);if(l.size>0){let b=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...b,...l])]}let h=G(a);a=h.output;let v=et(t);return a=await m(a,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),a=await m(a,/[A-Z][a-zA-Z0-9]*/,!0,Lt(lr)),a=await m(a,/[a-z][a-z0-9]*/,!1,lr),a=h.restore(a),a;async function m(b,w,C,k){if(!b)return b;let A=b,I=zt(A,w,k),U=lt(A),M=new Map;for(let N=I.length-1;N>=0;N--){let _=I[N],O=C?j(_.tagName):_.tagName,B=me(Xn(_.attributes,t,s)),z=U.filter(({start:Z,end:P})=>_.startIndex>=Z&&_.startIndex<P),K=z.length>0,D=new Set(v);for(let Z of z)for(let P of Z.names)D.add(P);let W=Fn(B,t,i,K,D);if(typeof W.clientReactive.for==="string")for(let Z of X(W.clientReactive.for))D.add(Z);let ce=le.getBuiltin(_.tagName),we=ce?await pr(_.tagName,c,t,s,i):!1;if(ce&&!we){let Z={context:t,filePath:s,options:i,dependencies:o},P=ce.render(W,_.content,Z);if(Object.keys(W.events).length>0){let F=Zt(W.events);P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${F}`)}if(Object.keys(W.clientReactive).length>0)P=Vt(P,W.clientReactive);M.set(N,P);continue}if(!C&&_.tagName.includes("-")&&!await pr(O,c,t,s,i))continue;let Y={};for(let[Z,P]of Object.entries(W.static))Y[Z]=P;for(let[Z,P]of Object.entries(W.serverDynamic))Y[Z]=P;let ne={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},T=await je(O,Y,h.restore(_.content),c,t,s,i,g,o,[...D],ne,_.tagName);if(T=Yn(T,W,ne.declaredProps,ne.consumedProps,i._nativeHostAttrs),i._nativeHostAttrs){let Z=ne.reactiveProps.filter((te)=>!ne.consumedProps.has(te)&&!["if","for","show","key","ref"].includes(te)).map(j),P=ut(T,!0);if(Z.length&&P){if(!Object.hasOwn(me(T.slice(P.insertPos,P.tagEnd)),"data-stx-native-host-root"))T=T.slice(0,P.insertPos)+' data-stx-native-host-root="true"'+T.slice(P.insertPos);let te=ve(T);T=T.slice(0,te.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+T.slice(te.insertPos)}let F=ut(T,!0);if(F){let te=me(T.slice(F.insertPos,F.tagEnd)),Se=ve(T),Kt=me(T.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(te,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))T=T.slice(0,Se.insertPos)+" data-stx-native-host-owner"+T.slice(Se.insertPos)}}if(Object.keys(W.events).length>0){let Z=ve(T);if(Z){let P=Zt(W.events),F=Object.keys(W.events).map((te)=>te.replace(/^@/,"").split(".")[0]).join(" ");T=T.substring(0,Z.insertPos)+` data-stx-parent-events="${F}" ${P}`+T.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)T=Vt(T,W.clientReactive);M.set(N,T)}if(M.size===0)return A;let L="",q=0;for(let N=0;N<I.length;N++){let _=M.get(N);if(_===void 0)continue;L+=A.slice(q,I[N].startIndex),L+=_,q=I[N].endIndex}return L+=A.slice(q),L}}function Vt(e,t){let s=new Set(["if","for"]),i=new Set(["show"]),o=Object.entries(t).filter(([v])=>!s.has(v)),a=o.filter(([v])=>!i.has(v)).map(([v])=>j(v)).join(" "),c=e,g=o.length>0?ve(c):null;if(g){let v=o.map(([S,x])=>`:${j(S)}="${x.replace(/"/g,""")}"`).join(" "),y=a?` data-stx-parent-bindings="${a}"`:"";c=c.substring(0,g.insertPos)+`${y} ${v}`+c.substring(g.insertPos)}let l=t.if;if(l)c=`<template :if="${l.replace(/"/g,""")}">${c}</template>`;let h=t.for;if(h){let v=t.key,y=v?` :key="${v.replace(/"/g,""")}"`:"";c=`<template :for="${h.replace(/"/g,""")}"${y}>${c}</template>`}return c}function Yn(e,t,s=new Set,i=new Set,o=!1){let a=ut(e,o);if(!a)return e;let c=e.slice(a.insertPos,a.tagEnd),g=t.serverDynamic.class??t.static.class;if(o&&typeof g==="string"&&g&&!i.has("class")){let m=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=m.test(c)?c.replace(m,(w,C,k,A,I)=>`${C}class="${R(`${at(k??A??I)} ${g}`)}"`):` class="${R(g)}"${c}`;e=e.slice(0,a.insertPos)+b+e.slice(a.tagEnd),a.tagEnd+=b.length-c.length,c=b}let l=o||/\bdata-native(?:\s|=)/i.test(c),h=l?i:s,v=new Set(Object.keys(me(c))),y=new Set(["class","className"]);for(let m of Object.keys(t.static)){let b=t.staticNames[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}for(let m of Object.keys(t.serverDynamic)){let b=t.serverDynamicNames?.[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}let S=[];if(l){for(let[m,b]of Object.entries(t.static)){if(y.has(m)||b!==!0&&b!==se)continue;y.add(m),S.push(`${R(t.staticNames?.[m]??m)}="true"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!0)continue;y.add(m),S.push(`${R(t.serverDynamicNames?.[m]??m)}="true"`)}}let x=[...ie(t,y),...ae(t,y),...S];if(l){for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!1)continue;let w=t.serverDynamicNames?.[m]??m;x.push(`${R(w)}="false"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let C=t.serverDynamicNames?.[m]??m;x.push(`${R(C)}="${R(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,a.insertPos)} ${x.join(" ")}${e.slice(a.insertPos)}`}function ve(e){let t=Gt(e,0);if(t)return t;let s=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(s)return{insertPos:s.index+1+s[1].length,tagEnd:ft(e,s.index+1+s[1].length)};return null}function ut(e,t=!1){let s=ve(e);if(!s)return null;let i=e.slice(s.insertPos,s.tagEnd),o=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(i)?Gt(e,s.tagEnd+1):s;return o&&t?Qn(e,o)??o:o}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),i=e.lastIndexOf("<",t.insertPos),o=0,a;while(i>=0&&i<e.length){if(e.startsWith("<!--",i)){let v=e.indexOf("-->",i+4);if(v<0)return null;i=e.indexOf("<",v+3);continue}let c=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(i));if(!c){i=e.indexOf("<",i+1);continue}let g=c[2].toLowerCase(),l=i+c[0].length,h=ft(e,l);if(c[1]){if(o--,a!==void 0&&o<a)a=void 0;if(o<=0)return null}else if(g==="script"||g==="style"){let v=new RegExp(`</${g}\\s*>`,"gi");if(v.lastIndex=h+1,!v.exec(e))return null;i=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(l,h)),y=o>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(a===void 0&&!y&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:l,tagEnd:h};if(!s.has(g)&&e[h-1]!=="/"){if(o++,a===void 0&&y)a=o}else if(o===0)return null}i=e.indexOf("<",h+1)}return null}function Gt(e,t){let s=t;while(s<e.length){let i=e.slice(s),o=i.match(/^\s+/);if(o){s+=o[0].length;continue}if(i.startsWith("<!--")){let g=e.indexOf("-->",s+4);if(g===-1)return null;s=g+3;continue}let a=i.match(/^<(script|style)\b[^>]*>/i);if(a){let g=`</${a[1].toLowerCase()}>`,l=e.toLowerCase().indexOf(g,s+a[0].length);if(l===-1)return null;s=l+g.length;continue}let c=i.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!c)return null;return{insertPos:s+1+c[1].length,tagEnd:ft(e,s+1+c[1].length)}}return null}function ft(e,t){let s="";for(let i=t;i<e.length;i++){let o=e[i];if(s){if(o==="\\")i++;else if(o===s)s=""}else if(o==='"'||o==="'")s=o;else if(o===">")return i}return e.length}function er(e){let t=new Set;for(let s of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=s[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let o of Io(s[2]))t.add(o);for(let o of s[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(o[1])t.add(o[1]);if(o[3])t.add(o[3]);for(let a of(o[2]??"").split(",")){let c=a.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}}}return t}async function Vr(e,t,s,i,o){if(!Xt)Dt(le),Xt=!0;let a=await $l(e,t,s,i,o);a=await Gn(a,t,s,i,o),a=await Kn(a,t,s,i,o);let c=[];for(let g=0;g<3;g++){let l=c.length,h=de(a,Ie,(y,S)=>`\x00STX_COMPONENT_COMMENT_${l+S}\x00`,`STX_COMPONENT_COMMENT:${l}`);c.push(...h.tokens);let v=a;if(a=await Jn(h.output,t,s,i,o),a===v)break}if(c.length>0)a=a.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(g,l)=>c[Number(l)]??"");if(i.debug){let g=Vn(a);if(g.length>0)console.warn(`[stx] ${s}: unresolved component tag(s) after render passes: ${g.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return a}
|
|
42
42
|
export{so,oo,io,hp,Hr,yp,la,$l,Vr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bt}from"./chunk-
|
|
2
|
+
import{Bt}from"./chunk-kq1hmpgb.js";function Rs(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=Bt(e),i=`
|
|
3
3
|
<!-- stx PWA Meta Tags -->
|
|
4
4
|
<link rel="manifest" href="/manifest.json">
|
|
5
5
|
<meta name="theme-color" content="${a(r?.themeColor||"#000000")}">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{l,p,E,u,U}from"./chunk-
|
|
2
|
+
import{l,p,E,u,U}from"./chunk-r0ys9aqa.js";import{L,is,B,Pe,ue,ur,Me,Le,n,m,we,x}from"./chunk-xw0cqb5m.js";import{st}from"./chunk-gtktv6nn.js";import{T}from"./chunk-6beg47t4.js";import{re}from"./chunk-hx787tfa.js";import{K,Ge}from"./chunk-yft8yn6y.js";import{C,wn}from"./chunk-078as147.js";import A from"path";import{existsSync as St}from"fs";function at(a,t){let c=0;for(let i=t;i<a.length;i++){let S=a[i];if(S==="("||S==="["||S==="{")c++;else if(S===")"||S==="]"||S==="}")c--;else if(S===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,S=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=S.exec(i);while(s){let f=s.index,e=f+s[0].length-1,D=1,Z=e+1;while(Z<i.length&&D>0){if(i[Z]==="(")D++;else if(i[Z]===")")D--;Z++}if(D!==0)break;let it=i.substring(e+1,Z-1),j=`${c}(${it})`;i=i.substring(0,f)+j+i.substring(Z),S.lastIndex=f+j.length,s=S.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,S=0,s=0,f=t.length,e=(j)=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]===j){s++;return}s++}},D=()=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]==="`"){s++;return}if(t[s]==="$"&&t[s+1]==="{"){s+=2;let j=1;while(s<f&&j>0)if(t[s]==="{")j++,s++;else if(t[s]==="}")j--,s++;else if(t[s]==="'"||t[s]==='"')e(t[s]);else if(t[s]==="`")D();else s++;continue}s++}},Z=()=>{if(t[s]==="/"&&t[s+1]==="/"){while(s<f&&t[s]!==`
|
|
3
3
|
`)s++;return!0}if(t[s]==="/"&&t[s+1]==="*"){s+=2;while(s<f-1&&!(t[s]==="*"&&t[s+1]==="/"))s++;return s+=2,!0}return!1},it=()=>{if(S!==0)return;let j=t.slice(s).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let H=j[2];if(!i.has(H))c.push(H),i.add(H);return}let et=t.slice(s).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let H=et[1];if(!i.has(H))c.push(H),i.add(H);return}let Y=t.slice(s).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let H=Y[1];if(!i.has(H))c.push(H),i.add(H)}};while(s<f){if(Z())continue;if(t[s]==="'"||t[s]==='"'){e(t[s]);continue}if(t[s]==="`"){D();continue}if(t[s]==="{"){S++,s++;continue}if(t[s]==="}"){S--,s++;continue}if(S===0&&/[a-z]/i.test(t[s])&&(s===0||/\s|[;{}()]/.test(t[s-1])))it();s++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${st("var",c)}
|
|
@@ -44,11 +44,11 @@ ${s}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(K(a)){let S=K(a).tag.match(/data-stx-scope="([^"]*)"/);if(S)return{html:a,mergedIntoExisting:S[1],stamped:!0,root:"body"};return{html:Ge(a,(s,f)=>`<body${f} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],S=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:S};let f=c[1],e=c[2],D=c[3];return{html:`${f}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:S}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function gp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Tl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],S=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,f;while((f=s.exec(c))!==null){let e=f[1]==="/",D=f[2],Z=f[3]==="/"||Tt.has(D.toLowerCase());if(e){S=Math.max(0,S-1);continue}if(S===0)i.push(D);if(!Z)S++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Ke=new B(500),ca=new Set;function mp(){ca.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return ca}async function Br(a,t,c,i,S,s=new Set){let f=i.partialsDir||A.join(A.dirname(c),"partials");if(f&&!A.isAbsolute(f))f=A.resolve(process.cwd(),f);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,k,_)=>{let g=k.trim(),r=`${c}:${g}`;if(D.has(r))return"";return D.add(r),k});{let h=/@includeIf\s*\(/g,k;while((k=h.exec(e))!==null){let _=k.index,g=_+k[0].length-1,r=1,w=g+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")")r--;w++}if(r!==0)break;let d=e.substring(g+1,w-1),o=d.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=w;continue}let O=o[1],W=Z(O,f,c),R="";if(W&&await Bun.file(W).exists())S.add(W),R=`@include(${d})`;e=e.substring(0,_)+R+e.substring(w),h.lastIndex=0}}for(let[h,k]of[["@includeWhen",!1],["@includeUnless",!0]]){let _=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=_.exec(e))!==null){let r=g.index,w=r+g[0].length-1,d=1,o=w+1;while(o<e.length&&d>0){if(e[o]==="(")d++;else if(e[o]===")")d--;o++}if(d!==0)break;let O=e.substring(w+1,o-1),W=at(O,0);if(W===-1){_.lastIndex=o;continue}let R=O.substring(0,W).trim(),V=O.substring(W+1).trim(),z=V.match(/^\s*['"]([^'"]+)['"]/);if(!z){_.lastIndex=o;continue}let b=z[1],J=V.substring(z[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${R})`,P;if(p(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=k?!P:P,rt="";if(tt){let ot=Z(b,f,c);if(ot&&await Bun.file(ot).exists())S.add(ot);rt=`@include('${b}'${N?`, ${N}`:""})`}e=e.substring(0,r)+rt+e.substring(o),_.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=m("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),_.lastIndex=0}}}{let h=/@each\s*\(/g,k;while((k=h.exec(e))!==null){let _=k.index,g=_+k[0].length-1,r=1,w=g+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let d=e.substring(g+1,w),o=e.substring(_,w+1),O=d.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,R,V,z]=O;try{let b,J=R.trim();if(p(J))b=u(J,Object.keys(t))(...Object.values(t));else b=l(J,t);let N="";if(Array.isArray(b)&&b.length>0)for(let I of b){let M={...t,[V]:I},P=await et(W,M,a,_);N+=P}else if(z)N=await et(z,{},a,_);e=e.substring(0,_)+N+e.substring(w+1),h.lastIndex=0}catch(b){let J=b instanceof Error?b.message:String(b);e=e.substring(0,_)+m("Each",`Error in @each: ${J}`,c,a,_)+e.substring(w+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,k;while((k=h.exec(e))!==null){let _=k.index,g=_+k[0].length-1,r=1,w=g+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let d=e.substring(g+1,w),o=e.substring(_,w+1),O=d.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],R=d.slice(O[0].length),V,z=R.match(/^\s*,\s*\{/);if(z){R=R.slice(z[0].length-1);let N=1,I=1;while(I<R.length&&N>0){if(R[I]==="{")N++;else if(R[I]==="}"){if(N--,N===0)break}I++}V=R.substring(0,I+1),R=R.slice(I+1)}let b,J=R.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)b=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(V)try{I=E(V,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let rt=m("Include",`Error parsing includeFirst variables: ${tt}`,c,a,_,o);e=e.replace(o,()=>rt)}else e=e.replace(o,()=>b||"");continue}let M=!1;for(let P of N){let tt=Z(P,f,c);if(!tt)continue;if(await n(tt)){let rt=await et(P,I,a,_);e=e.replace(o,()=>rt),M=!0;break}}if(!M)if(b!==void 0)e=e.replace(o,()=>b);else if(i.debug){let P=m("Include",`None of the includeFirst paths exist: ${W}`,c,a,_,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=m("Include",`Error processing @includeFirst: ${I}`,c,a,_,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function Z(h,k,_){try{let g=h;if(!h.endsWith(".stx"))g=`${h}.stx`;let r=A.resolve(k),w=A.resolve(A.dirname(_)),d;if(!g.startsWith("./")&&!g.startsWith("../")){for(let z of i._layerPartialDirs??[]){let b=A.resolve(z,g);if(b.startsWith(`${A.resolve(z)}${A.sep}`)&&St(b))return b}d=A.resolve(k,g)}else d=A.resolve(w,g);let o=A.normalize(d),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(w+A.sep)||o===w,R=!1,V=A.dirname(w);if(o.startsWith(V+A.sep)){if(!A.relative(V,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))R=!0}if(!O&&!W&&!R)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${w}`),null;return o}catch(g){return console.error(`Error resolving path ${h}: ${g}`),null}}let it=A.resolve(c);s.add(it);function j(h,k,_,g){return i.onIncludeError?.({includePath:h,templatePath:c,message:k,partialsDir:f}),m("Include",k,c,_,g)}async function et(h,k={},_,g){let r=Z(h,f,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,_,g);let w=A.resolve(r);if(s.has(w)){let d=[...s,w].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${d}`,_,g)}try{S.add(r);let d;if(!d)try{d=await Bun.file(r).text()}catch(v){let q=v instanceof Error?v.message:String(v);return j(h,`Error loading include file ${h}: ${q}`,_,g)}if(d)d=d.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(d&&d.includes("@stream")){let{processStreamDirectives:v}=await import("./chunk-ejphs9fs.js");d=v(d,t)}if(d&&(i.debug||!C()&&!wn()))try{let{warnUnbalancedTags:v}=await import("./chunk-23efje42.js");v(d,r)}catch{}try{let{processESImports:v}=await import("./chunk-em77nd40.js");d=await v(d,t,r,i,S)}catch(v){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,v instanceof Error?v.message:v)}let o=d,O=ue(o);if(O)o=O.content.trim();let R=d.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),V="";if(R)V=`<style${R[1]}>${R[2]}</style>`;let z=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(v,q,y)=>{if(!ft(q))return"";return z.push({attrs:q,body:y}),`__STX_DATA_BLOCK_${z.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let b={...t};b.__stx_signals_gate=we(d,r);for(let[v,q]of Object.entries(k))b[v]=q;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,N=[...d.matchAll(J)].sort((v,q)=>{let y=(v[1]||"").includes("server"),X=(q[1]||"").includes("server");return Number(X)-Number(y)}),I="",M=null,P=!1,tt=!1;for(let v of N){let q=v[1]||"",y=v[2]||"";if(ft(q))continue;let X=q.includes("server"),wt=Me(q);if(!X&&!/\bsrc\s*=/i.test(q))Pe(y,r,i.strict);if(!X&&y.trim()){let{interpolateScriptExpressions:F}=await import("./chunk-dbxq6fd7.js");y=F(y,b,h)}let ct="";try{let{extractAndStripCssImports:F,renderVendorStyleTags:Q}=await import("./chunk-4cksc4n3.js"),nt=F(y,{filePath:r,projectRoot:process.cwd()});y=nt.code,ct=Q(nt.styles)}catch(F){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,F instanceof Error?F.message:F)}if(wt&&y.trim())y=Le(y);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-4cksc4n3.js");y=Q(y).code;let{hasUserImports:nt,bundleClientScript:bt}=await import("./chunk-yqgrjf9q.js");if(nt(y))y=await bt(y,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:F}=await import("./chunk-4j9p27kn.js");y=F(y)}let dt=$t(y);if(!X){let{extractBridgeData:F,generateServerDataBridge:Q}=await import("./chunk-4cksc4n3.js"),nt=Q(y,F(b));if(nt)y=`${nt}
|
|
48
48
|
${y}`}if(dt&&!X){P=!0,M=ut(r,t);let F=T(y),Q=gt(F,M);I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-
|
|
50
|
-
`}}if(z.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-
|
|
51
|
-
`+V;if(I)
|
|
52
|
-
`+I;return
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-7gprzmd9.js");await F(y,b,r)}catch(F){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,F)}if(!X&&!dt){let F=q.replace(/\bclient\b/i,"").trim();M=ut(r,t);let Q=T(y),nt=gt(Q,M);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(nt))tt=!0;I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}"${F?` ${F}`:""}>${nt}</script>
|
|
50
|
+
`}}if(z.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-dbxq6fd7.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(q,y)=>{let X=z[Number(y)];return`<script${X.attrs}>${v(X.body,b,h)}</script>`})}if(M){let v=It(o,M);if(o=v.html,v.mergedIntoExisting){let y=M,X=v.mergedIntoExisting;I=I.split(`'${y}'`).join(`'${X}'`).split(`"${y}"`).join(`"${X}"`),M=X}else if(!v.stamped&&P&&!lt.has(r))lt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(v.stamped&&v.root!=="body"&&(P||tt)&&!pt.has(r)){let y=Tl(o);if(y.length>1)pt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares ${P?"signals":"bindings"} and has ${y.length} top-level elements (${y.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let q=v.stamped&&v.root!==null&&ur(v.root);I=Rt(I,q?M:null)}if(o.includes("@include")||o.includes("@partial"))o=await Br(o,b,r,i,S,s);let{processLoops:rt,reportDeferredLoopWarnings:ot}=await import("./chunk-gyye3mcb.js"),G=rt(o,b,r,void 0,!0);G=re(G,b,r),G=ot(G);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-d26nb6zy.js");if(G=ht(G,b,r,i),G=_t(G,b,r),G=xt(G,b,r,i),G=x(G,b,r),V)G+=`
|
|
51
|
+
`+V;if(I)G+=`
|
|
52
|
+
`+I;return G}catch(d){if(d instanceof U)throw d;let o=d instanceof Error?d.message:String(d);return j(h,`Error processing include ${h}: ${o}`,_,g)}}let Y=/@include\s*\(/g,H;while((H=Y.exec(e))!==null){let h=H.index,k=h+H[0].length-1,_=1,g=k+1;while(g<e.length&&_>0){if(e[g]==="(")_++;else if(e[g]===")")_--;g++}if(_!==0)break;let r=e.substring(h,g),w=e.substring(k+1,g-1),d=w.match(/^\s*['"]([^'"]+)['"]/);if(!d){Y.lastIndex=g;continue}let o=d[1],O,W=w.substring(d[0].length),R=at(W,0);if(R!==-1)O=W.substring(R+1).trim();let V={};if(O)try{V=E(O,t)}catch(b){let J=b instanceof Error?b.message:String(b);e=e.replace(r,m("Include",`Error parsing include variables for ${o}: ${J}`,c,a,h)),Y.lastIndex=0;continue}let z=await et(o,V,a,h);e=e.substring(0,h)+z+e.substring(g),Y.lastIndex=0}return e}function Fr(a,t){let c=a;function i(S,s,f,e){let D=S,Z=!0;while(Z){Z=!1;let it=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),j=D.match(it);if(!j||j.index===void 0)break;let et=j.index,Y=j[1],H=et+j[0].length,h=new RegExp(`@${s}\\(`),k=new RegExp(`@${f}(?![a-z])`),_=1,g=H,r=-1;while(_>0&&g<D.length){let d=D.slice(g),o=d.match(h),O=d.match(k),W=o?g+o.index:1/0,R=O?g+O.index:1/0;if(W<R)_++,g=W+(o[0].length||1);else if(R<1/0){if(_--,_===0){r=R;break}g=R+f.length+1}else break}if(r===-1)break;let w=D.slice(H,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(w);else t[Y].push(w);D=D.substring(0,et)+D.substring(r+`@${f}`.length),Z=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function zr(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
54
|
-
export{gp,Tl,
|
|
54
|
+
export{gp,Tl,Ke,ca,mp,Br,Fr,zr};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ou}from"./chunk-9c3x72qy.js";import"./chunk-d9esaahz.js";import"./chunk-cge9pgyb.js";import"./chunk-0nt17nas.js";import"./chunk-fw12pvmr.js";import"./chunk-1rgjy80j.js";import"./chunk-0y2hkbc6.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import"./chunk-xw0cqb5m.js";import"./chunk-bg6t69qq.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{Ou as startProductionServer};
|