@stacksjs/stx 0.2.815 → 0.2.817
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-4rny8rf5.js → chunk-0h99mrb0.js} +3 -3
- package/dist/{chunk-pda7fv19.js → chunk-0jcady6w.js} +1 -1
- package/dist/chunk-0yjm4j26.js +2 -0
- package/dist/{chunk-1cxf9chb.js → chunk-133vw0ae.js} +6 -6
- package/dist/{chunk-kvz01wzc.js → chunk-17wb2x3z.js} +2 -2
- package/dist/{chunk-bmkm1c8s.js → chunk-1bgv727x.js} +37 -5
- package/dist/{chunk-eqrjfceb.js → chunk-1fc6rax4.js} +1 -1
- package/dist/chunk-1kz70290.js +2 -0
- package/dist/{chunk-0dnzcrb1.js → chunk-1wdv3zj2.js} +1 -1
- package/dist/chunk-2k3qtmn8.js +2 -0
- package/dist/{chunk-5h0p34jj.js → chunk-2p3eaj16.js} +1 -1
- package/dist/{chunk-0yf28g7v.js → chunk-2vget8rh.js} +1 -1
- package/dist/chunk-3eqs0rpv.js +2 -0
- package/dist/{chunk-080zb2qx.js → chunk-3ftaegqg.js} +1 -1
- package/dist/{chunk-w5xq1217.js → chunk-3jd5ak8h.js} +1 -1
- package/dist/{chunk-84qv8bxe.js → chunk-4ws3yz5q.js} +20 -20
- package/dist/{chunk-et8n16k2.js → chunk-4ypwqrj2.js} +1 -1
- package/dist/{chunk-cfbpvm5e.js → chunk-5efv1fhk.js} +2 -2
- package/dist/{chunk-few3k1dz.js → chunk-5gxneecs.js} +2 -2
- package/dist/{chunk-c4y1pcf6.js → chunk-5hxvhmg3.js} +4 -4
- package/dist/{chunk-k86573fe.js → chunk-6cw072n5.js} +1 -1
- package/dist/{chunk-7qarrdq6.js → chunk-7hch54b2.js} +1 -1
- package/dist/chunk-7pb9fepg.js +2 -0
- package/dist/{chunk-gebb12ak.js → chunk-7rk7wfm6.js} +6 -6
- package/dist/{chunk-ewzdsksb.js → chunk-8g8h2xwz.js} +1 -1
- package/dist/{chunk-bejj0gra.js → chunk-8h3jv8dd.js} +1 -1
- package/dist/{chunk-t4j2rw91.js → chunk-981z8va1.js} +2 -2
- package/dist/{chunk-qckgv0vz.js → chunk-9mtw71xy.js} +1 -1
- package/dist/chunk-9ttf7k5e.js +2 -0
- package/dist/{chunk-x2hc3zth.js → chunk-a350jjd3.js} +1 -1
- package/dist/{chunk-5d8123c9.js → chunk-agxjwnz0.js} +7 -7
- package/dist/chunk-ar7w1kx0.js +2 -0
- package/dist/chunk-aya8nv31.js +2 -0
- package/dist/{chunk-se251nhv.js → chunk-b5ckg7zq.js} +1 -1
- package/dist/{chunk-pr6nrg6x.js → chunk-b9ntt41z.js} +1 -1
- package/dist/{chunk-6vbtvpn4.js → chunk-ccxphr19.js} +2 -2
- package/dist/{chunk-rvb5gz33.js → chunk-cj1p3qdh.js} +1 -1
- package/dist/{chunk-t6sddfv8.js → chunk-cm5cp3m0.js} +5 -5
- package/dist/{chunk-6em1xeax.js → chunk-crmxg1c0.js} +1 -1
- package/dist/{chunk-p9y5hh4m.js → chunk-df60fpgx.js} +3 -3
- package/dist/chunk-dnemxdvy.js +2 -0
- package/dist/chunk-dnqt6y8v.js +3 -0
- package/dist/chunk-dy7yccxm.js +20 -0
- package/dist/chunk-f0bwetnx.js +421 -0
- package/dist/{chunk-1carv1dw.js → chunk-f54t0qar.js} +1 -1
- package/dist/{chunk-3ht64v1a.js → chunk-fcvyk047.js} +6 -6
- package/dist/{chunk-z1edw8fc.js → chunk-gc7pykfq.js} +2 -2
- package/dist/{chunk-7cwb7pyf.js → chunk-gtfs96f2.js} +1 -1
- package/dist/{chunk-gt0csenq.js → chunk-gzhrtymg.js} +20 -20
- package/dist/{chunk-b12wg4jp.js → chunk-hg67a15h.js} +1 -1
- package/dist/{chunk-vn5cd6av.js → chunk-hhazm0cs.js} +1 -1
- package/dist/chunk-hsmwzzy2.js +2 -0
- package/dist/{chunk-3z0e637x.js → chunk-jg9f5nqf.js} +5 -5
- package/dist/chunk-jham85mf.js +2 -0
- package/dist/chunk-jsvc264s.js +2 -0
- package/dist/{chunk-mjjfx1yp.js → chunk-jtx9x3as.js} +4 -4
- package/dist/chunk-k98nt4pk.js +2 -0
- package/dist/chunk-ka1hrt56.js +2 -0
- package/dist/{chunk-72pek719.js → chunk-kjjvs3sc.js} +1 -1
- package/dist/{chunk-dvbd5fxe.js → chunk-kvhsdyfg.js} +1 -1
- package/dist/{chunk-y7sf7aj0.js → chunk-m0x96g8e.js} +1 -1
- package/dist/chunk-m477m5dp.js +2 -0
- package/dist/{chunk-cbx7qght.js → chunk-mkr46mzz.js} +1 -1
- package/dist/{chunk-ycr9bkww.js → chunk-mmyrdbxx.js} +1 -1
- package/dist/{chunk-ybjfr7e8.js → chunk-n761hp6d.js} +2 -2
- package/dist/{chunk-c5fved0k.js → chunk-n9av365c.js} +1 -1
- package/dist/{chunk-kmr3cd71.js → chunk-nmkkfpmh.js} +7 -7
- package/dist/{chunk-bfm5cedw.js → chunk-ntn6bnjv.js} +2 -2
- package/dist/chunk-p4f1hrvn.js +2 -0
- package/dist/{chunk-tc15aznt.js → chunk-p5ez40kf.js} +1 -1
- package/dist/{chunk-8taa0exz.js → chunk-pdnyhs63.js} +1 -1
- package/dist/chunk-py244ymg.js +2 -0
- package/dist/{chunk-mmh2k7ab.js → chunk-pyytr30r.js} +5 -5
- package/dist/{chunk-r1vkk7qp.js → chunk-r5nt1bcx.js} +1 -1
- package/dist/{chunk-3ec6jf9b.js → chunk-r6dtrd7y.js} +3 -3
- package/dist/{chunk-b0yvap9e.js → chunk-rc424p1c.js} +8 -8
- package/dist/chunk-rp6b7awz.js +2 -0
- package/dist/chunk-rqfg21xk.js +2 -0
- package/dist/{chunk-m8zbae89.js → chunk-rxt4jj9b.js} +2 -2
- package/dist/chunk-rzwyaqgg.js +2 -0
- package/dist/chunk-s5pegavh.js +2 -0
- package/dist/{chunk-macvhhf0.js → chunk-sa0nkpx9.js} +2 -2
- package/dist/chunk-sj4vw93g.js +2 -0
- package/dist/chunk-snfjvd94.js +2 -0
- package/dist/{chunk-vbc8a8fh.js → chunk-t2sg2tp2.js} +2 -2
- package/dist/{chunk-m8w7rcmt.js → chunk-vbrn4w81.js} +2 -2
- package/dist/chunk-w8xvkbt9.js +2 -0
- package/dist/{chunk-hbq922er.js → chunk-x5rt4kpx.js} +1 -1
- package/dist/chunk-xbknqp19.js +2 -0
- package/dist/{chunk-q9ggx1jb.js → chunk-y3p6w1e0.js} +3 -3
- package/dist/{chunk-9k037sk6.js → chunk-yd0074ks.js} +1 -1
- package/dist/{chunk-h9cpa5jq.js → chunk-yd1zsy7t.js} +1 -1
- package/dist/chunk-yjvwp1s6.js +2 -0
- package/dist/{chunk-gb3tv53p.js → chunk-yts2b9d8.js} +2 -2
- package/dist/{chunk-3qr7dz76.js → chunk-yvqe0pzk.js} +1 -1
- package/dist/cli.js +12 -12
- package/dist/component-resolution.d.ts +33 -0
- package/dist/component-resolution.js +30 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/media/client/upload-fetch.d.ts +6 -0
- package/dist/media/client/upload-fetch.js +62 -0
- package/dist/native/bridge/protocol.d.ts +2 -1
- package/dist/native/bridge/protocol.js +27 -4
- package/dist/native/runtime/browser-screen.js +67 -2
- package/dist/native/runtime/craft-bridge.js +29 -7
- package/dist/native/runtime/craft.d.ts +14 -1
- package/dist/pwa.js +1 -1
- package/dist/runtime-injection.js +2 -0
- package/dist/ssg.js +4 -4
- package/dist/stx-virtual-ts.d.ts +26 -5
- package/dist/stx-virtual-ts.js +67 -11
- package/dist/typecheck.js +6 -4
- package/dist/types/config-types.d.ts +1 -0
- package/dist/utils.js +11 -3
- package/package.json +5 -5
- package/dist/chunk-053yyx5n.js +0 -2
- package/dist/chunk-0x02gm7d.js +0 -2
- package/dist/chunk-0xv48z98.js +0 -3
- package/dist/chunk-0ywcbka3.js +0 -2
- package/dist/chunk-1ydz2w3t.js +0 -2
- package/dist/chunk-2gcvcpt8.js +0 -2
- package/dist/chunk-2yngdnq6.js +0 -2
- package/dist/chunk-6dcc4ezx.js +0 -2
- package/dist/chunk-74ck7kk1.js +0 -20
- package/dist/chunk-74dw9yf0.js +0 -2
- package/dist/chunk-7bxk9mjy.js +0 -2
- package/dist/chunk-81pykb48.js +0 -2
- package/dist/chunk-85w7kf2j.js +0 -2
- package/dist/chunk-89pes7at.js +0 -2
- package/dist/chunk-as5ej9s8.js +0 -2
- package/dist/chunk-cea665ds.js +0 -2
- package/dist/chunk-d2vr1169.js +0 -420
- package/dist/chunk-eg95a7q7.js +0 -2
- package/dist/chunk-km00bn5z.js +0 -2
- package/dist/chunk-qfc662nf.js +0 -2
- package/dist/chunk-qxr4teqr.js +0 -2
- package/dist/chunk-rdsrc8wv.js +0 -2
- package/dist/chunk-rpw3f34s.js +0 -2
- package/dist/chunk-s7db9xc4.js +0 -2
- package/dist/chunk-tdcgskyy.js +0 -2
- package/dist/chunk-vhe6p6b0.js +0 -2
- package/dist/chunk-xd5n2qx4.js +0 -2
- package/dist/chunk-yacdg7kq.js +0 -2
- package/dist/chunk-z5b863fw.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ie,C,Y}from"./chunk-
|
|
2
|
+
import{Ie,C,Y}from"./chunk-f0bwetnx.js";import{k}from"./chunk-n761hp6d.js";import{P,En}from"./chunk-r9e0r6jx.js";import{a}from"./chunk-nmkkfpmh.js";import{he,nn,rn,sn}from"./chunk-5gxneecs.js";import{wt}from"./chunk-fcvyk047.js";import{mt,zn,Gt,ce}from"./chunk-tsvnhc0c.js";import{E,Cn}from"./chunk-c5vzr1va.js";import A from"fs";import b from"path";import x from"process";function U(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=E()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${rn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return ce(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>he(l))])],f=mt(i()),u=Gt(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return ce(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=Y({loader:"ts",target:"browser",define:C()});for(let l of p)try{let c=await Bun.file(l).text(),_=b.basename(l,".ts"),y=new Set;U(c,y);let v=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((N)=>N[2]),I=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(nn(c))c=await sn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=wt(c),c=P(c),c=En(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:_,ids:v.length===I?v:[],declared:y,code:`// Store: ${_}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return ce(h,t,f,{chunks:[]}),null;f=mt(i());let S={chunks:g};return ce(h,t,f,S),S}function R(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
|
|
4
4
|
|
|
5
5
|
`),n=`;(function(){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{pl,fl}from"./chunk-ybjfr7e8.js";import{f,A,st,d}from"./chunk-gebb12ak.js";import{V,yr,Ns,Ms,oi,ii,Ds,wr,Ne,pe,G,xr,oe,J,O,rt,Sr,li,Er,Fe,s,p,U,wn}from"./chunk-d2vr1169.js";import{n}from"./chunk-0xv48z98.js";import{se}from"./chunk-y7sf7aj0.js";import{r}from"./chunk-3vpgr6nk.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import K from"path";import{decode as on,generateThumbHash as an}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import De from"fs";function Ce(e,t,i){let o=Buffer.alloc(i),a=De.readSync(e,o,0,i,t);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let t=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let i=t(12,16);if(i==="VP8X")return(e[20]&16)!==0;if(i==="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=De.openSync(e,"r");let i=Ce(t,0,33);if(i.length>=3&&i[0]===255&&i[1]===216&&i[2]===255)return"none";if(i.length>=26&&i[0]===137&&i.toString("latin1",1,4)==="PNG"){let o=i[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(t,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(i.length>=25&&i.toString("latin1",0,4)==="RIFF"&&i.toString("latin1",8,12)==="WEBP"){if(je(i))return"possible";let o=i.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)De.closeSync(t)}}import Yt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Qt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let i=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(i.protocol==="file:"&&Yt.existsSync(mt(i)))return mt(i)}catch{}try{let i=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return i&&sn(i)?i:void 0}catch{return}}function sn(e,t=process.env){let i=e.replace(/\\/g,"/");if(i.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![t.BUN_INSTALL_CACHE_DIR,gt(t.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>i.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!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 pt!=="function")return he("node:worker_threads has no Worker in this runtime");let i=rn();if(!i)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((o,a)=>{let c;try{c=new pt(i)}catch(y){o(he(`could not start ${i}: ${Le(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:t});return}if(y.type==="result"){u(()=>o(y.value));return}let v=Error(y.error?.message??"image worker failed");if(y.error?.name)v.name=y.error.name;if(y.error?.stack)v.stack=y.error.stack;u(()=>a(v))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Le(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${Le(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var cn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),ln=[320,640,960,1280,1920],ye="/_stx/images",un=`stx:${ye}:alpha-1`,fn=`stx:${ye}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let i=K.dirname(Bun.resolveSync(e,t));while(i!==K.dirname(i)){let o=K.join(i,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}i=K.dirname(i)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=K.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let i;try{i=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${i??"unknown"}`}).join("+"),Pe}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var wt=new Set;function mn(e){return`/${e.split(K.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=K.extname(e),i=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${i||"image"}-${o}`}function $t(e,t=`stx:${ye}`){let i=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(o){let a=K.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:i(o)}:null}catch{return null}},async write(o,a){let c=K.join(e,o);await Q.promises.mkdir(K.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:i(o)}},url:i}}async function At(e,t=e){let i=await Q.promises.readdir(t,{withFileTypes:!0});i.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of i){let c=K.join(t,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!cn.has(K.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:K.relative(e,c)})}return o}function St(e,t){return e.map((i)=>({key:mn(i.relativePath),input:i.absolutePath,name:pn(i.relativePath),...hn(i.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 bn(e){let t=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),i=new Set,o=8;for(let a=0;a<t.length;a+=8)await Promise.all(t.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await on(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(yn(u.data))i.add(c)}catch{i.add(c)}}));return i}function xn(e,t){let i=[];for(let o of t){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,i.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return i}async function vn(e){let t=[],i=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await an(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));t.push(...c.filter((l)=>l!==null))}return t}function Ue(e){return K.join(e,"undecodable.json")}function $n(e){try{let t=Q.readFileSync(Ue(e),"utf-8"),i=JSON.parse(t);return i&&typeof i==="object"?i:{}}catch{return{}}}function Sn(e,t){try{Q.mkdirSync(K.dirname(Ue(e)),{recursive:!0}),Q.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function Ct(e){try{let t=Q.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function kt(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 Lo(e){let t=kt(e);return t?be().catalog.get(t):void 0}function jo(e){let t=kt(e);return t?be().transparent.has(t):!1}function Bo(e){let t=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),i=t(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:t(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<i).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Ah(e){let t=Lo(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:Bo(t).map(({format:i,srcset:o})=>({type:`image/${i}`,srcset:o})),width:t.source.width,height:t.source.height,placeholder:jo(e)?void 0:t.placeholder?.dataUrl}}function us(){let e=be();e.catalog=new Map,e.transparent=new Set}function Cn(e){let t=be();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function Ph(e,t,i={}){if(!e||!Q.existsSync(e))return us(),{count:0,fingerprint:""};if(i.offThread){let h=await ze("delivery",{publicDir:e,outputDir:t});if(h!==ke)return Cn(h.state),h.result}let o=await At(e);if(o.length===0)return us(),{count:0,fingerprint:""};let a=$n(t),c=o.filter((h)=>{let w=a[h.relativePath];if(!w)return!0;let S=Ct(h.absolutePath);return!S||S.mtimeMs!==w.mtimeMs||S.size!==w.size});if(c.length===0)return us(),{count:0,fingerprint:""};let l=$t(K.join(t,"_stx","images"),`${un}:${xt()}`),m={outDir:K.join(t,"_stx","images"),storage:$t(K.join(t,"_stx","images"),`${fn}:${xt()}`),baseUrl:ye,widths:ln,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(h){if(u=await vn(c),u.length===c.length)throw h;let w=new Set(u.map((R)=>R.relativePath)),S=!1;for(let R of c){if(w.has(R.relativePath))continue;let P=Ct(R.absolutePath);if(!P)continue;a[R.relativePath]=P,S=!0}if(S)Sn(t,a);if(u.length===0)return us(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let v=await bn(y.entries),b=xn(y.entries,v),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=v;let x=v.size===0&&b.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:b.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{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,i,o){let a=oi(e,o);if(a!==void 0)return a;for(let c of ii(e,t,i,o))if(await s(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Rn=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 He(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Rn.has(t)}function ie(e,t){let i=[];for(let[o,a]of Object.entries(e.static)){if(t.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)i.push(p(c));continue}if(a===re){i.push(p(c));continue}i.push(`${p(c)}="${wn(c,We(String(a)))}"`)}return i}function ae(e,t){let i=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(t.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){i.push(p(c));continue}if(typeof a==="object")continue;i.push(`${p(c)}="${wn(c,We(String(a)))}"`)}return i}function An(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 qe={name:"StxLink",aliases:["stx-link"],render(e,t,i){let o=An(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(wr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...ie(e,v)),u.push(...ae(e,v)),`<a ${u.join(" ")}>${t}</a>`}};var kn=new Map;function Xe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return kn.get(t)}var Pn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function Z(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}function Ie(e,t,i=!1){let o=e.serverDynamic[t];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[t];if(a!==void 0)return a!=="false"&&a!==!1;return i}function Ve(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),i=[];for(let o of t)if(o.includes(":")){let[a,c]=o.split(":"),l=Pn[a];if(l)i.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))i.push(`(max-width: ${m}px) ${c}`)}}else i.push(o);return i.join(", ")}function Ge(e,t,i,o){return t.map((a)=>`${xe(e,a,void 0,i,o)} ${a}w`).join(", ")}function In(e,t,i,o,a){return t.map((c)=>{let l=i?i*c:void 0;return`${xe(e,l,void 0,o,a)} ${c}x`}).join(", ")}function xe(e,t,i,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(t)c.push(`w_${t}`);if(i)c.push(`h_${i}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(t)c.set("w",String(t));if(i)c.set("h",String(i));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(t)c.set("width",String(t));if(i)c.set("height",String(i));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function En(e,t,i="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${i}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Ke={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,i){let o=Z(e,"src")||"",a=Lo(o),c=Z(e,"alt")||"",l=Z(e,"width")||(a?String(a.source.width):void 0),m=Z(e,"height")||(a?String(a.source.height):void 0),u=Z(e,"sizes"),y=Z(e,"srcset"),v=Z(e,"densities"),b=Z(e,"format"),C=jo(o)||Xe(o)?.transparent===!0,x=Z(e,"placeholder")||(a&&!C?"thumbhash":void 0),h=Z(e,"placeholderColor")||"#e5e7eb",w=Z(e,"provider"),S=Z(e,"class")||Z(e,"className")||"",R=Z(e,"style")||"",P=Z(e,"objectFit")||Z(e,"fit"),k=Z(e,"objectPosition")||Z(e,"position"),N=Z(e,"quality"),H=Ie(e,"lazy",!0),z=Ie(e,"preload",!1),F=Ie(e,"priority",!1),q=Z(e,"loading"),B=Z(e,"decoding")||"async",E=!!a||Ie(e,"picture",!1)||!!b,T=l?Number.parseInt(l):void 0,j=m?Number.parseInt(m):void 0,W=y||"",X="";if(a)W=a.sources[a.fallback.format]||"",X=u?Ve(u):"100vw";else if(!W&&u&&w&&w!=="local"&&w!=="static")W=Ge(o,Ze,w,b),X=Ve(u);else if(!W&&v){let I=v.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));W=In(o,I,T,w,b)}else if(u)X=Ve(u);let L=[];if(R)L.push(R);if(P)L.push(`object-fit:${P}`);if(k)L.push(`object-position:${k}`);if(T&&j)L.push(`aspect-ratio:${T}/${j}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:h}:Xe(o);if(I&&x==="color")L.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)L.push(`background-color:${I.color}`),L.push(`background-image:url(${I.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=En(T||16,j||9,h);L.push(`background-image:url(${_})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||xe(o,T,j,w,b),Y=[];if(Y.push(`src="${n(wr($e,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let le=q||(F||z?"eager":H?"lazy":"");if(le)Y.push(`loading="${n(le)}"`);if(F)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(B)}"`),S)Y.push(`class="${n(S)}"`);if(L.length>0)Y.push(`style="${n(L.join(";"))}"`);if(W)Y.push(`srcset="${n(wr(W,"fetched"))}"`);if(X)Y.push(`sizes="${n(X)}"`);let te=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(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=_n(D)+(I?`;${I}`:"");Y.push(`onload="${n(_)}"`),te.add("onload")}Y.push(...ie(e,te)),Y.push(...ae(e,te));let Te=`<img ${Y.join(" ")} />`,M="";if(z){let _=b==="webp"?"image/webp":b==="avif"?"image/avif":"";M=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${W?` imagesrcset="${n(W)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
|
|
2
|
+
import{pl,fl}from"./chunk-n761hp6d.js";import{f,A,st,d}from"./chunk-7rk7wfm6.js";import{V,yr,Os,Ns,oi,ii,Ms,wr,Ne,pe,G,xr,oe,J,O,rt,Sr,li,Cr,Fe,s,p,U,wn}from"./chunk-f0bwetnx.js";import{n}from"./chunk-dnqt6y8v.js";import{se}from"./chunk-m0x96g8e.js";import{r}from"./chunk-3vpgr6nk.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import K from"path";import{decode as on,generateThumbHash as an}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import De from"fs";function Ce(e,t,i){let o=Buffer.alloc(i),a=De.readSync(e,o,0,i,t);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let t=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let i=t(12,16);if(i==="VP8X")return(e[20]&16)!==0;if(i==="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=De.openSync(e,"r");let i=Ce(t,0,33);if(i.length>=3&&i[0]===255&&i[1]===216&&i[2]===255)return"none";if(i.length>=26&&i[0]===137&&i.toString("latin1",1,4)==="PNG"){let o=i[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(t,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(i.length>=25&&i.toString("latin1",0,4)==="RIFF"&&i.toString("latin1",8,12)==="WEBP"){if(je(i))return"possible";let o=i.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)De.closeSync(t)}}import Yt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Qt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let i=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(i.protocol==="file:"&&Yt.existsSync(mt(i)))return mt(i)}catch{}try{let i=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return i&&sn(i)?i:void 0}catch{return}}function sn(e,t=process.env){let i=e.replace(/\\/g,"/");if(i.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![t.BUN_INSTALL_CACHE_DIR,gt(t.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>i.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!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 pt!=="function")return he("node:worker_threads has no Worker in this runtime");let i=rn();if(!i)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((o,a)=>{let c;try{c=new pt(i)}catch(y){o(he(`could not start ${i}: ${Le(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:t});return}if(y.type==="result"){u(()=>o(y.value));return}let v=Error(y.error?.message??"image worker failed");if(y.error?.name)v.name=y.error.name;if(y.error?.stack)v.stack=y.error.stack;u(()=>a(v))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Le(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${Le(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var cn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),ln=[320,640,960,1280,1920],ye="/_stx/images",un=`stx:${ye}:alpha-1`,fn=`stx:${ye}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let i=K.dirname(Bun.resolveSync(e,t));while(i!==K.dirname(i)){let o=K.join(i,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}i=K.dirname(i)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=K.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let i;try{i=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${i??"unknown"}`}).join("+"),Pe}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var wt=new Set;function mn(e){return`/${e.split(K.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=K.extname(e),i=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${i||"image"}-${o}`}function $t(e,t=`stx:${ye}`){let i=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(o){let a=K.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:i(o)}:null}catch{return null}},async write(o,a){let c=K.join(e,o);await Q.promises.mkdir(K.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:i(o)}},url:i}}async function At(e,t=e){let i=await Q.promises.readdir(t,{withFileTypes:!0});i.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of i){let c=K.join(t,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!cn.has(K.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:K.relative(e,c)})}return o}function St(e,t){return e.map((i)=>({key:mn(i.relativePath),input:i.absolutePath,name:pn(i.relativePath),...hn(i.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 bn(e){let t=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),i=new Set,o=8;for(let a=0;a<t.length;a+=8)await Promise.all(t.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await on(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(yn(u.data))i.add(c)}catch{i.add(c)}}));return i}function xn(e,t){let i=[];for(let o of t){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,i.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return i}async function vn(e){let t=[],i=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await an(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));t.push(...c.filter((l)=>l!==null))}return t}function Ue(e){return K.join(e,"undecodable.json")}function $n(e){try{let t=Q.readFileSync(Ue(e),"utf-8"),i=JSON.parse(t);return i&&typeof i==="object"?i:{}}catch{return{}}}function Sn(e,t){try{Q.mkdirSync(K.dirname(Ue(e)),{recursive:!0}),Q.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function Ct(e){try{let t=Q.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function kt(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 Lo(e){let t=kt(e);return t?be().catalog.get(t):void 0}function jo(e){let t=kt(e);return t?be().transparent.has(t):!1}function Bo(e){let t=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),i=t(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:t(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<i).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Ah(e){let t=Lo(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:Bo(t).map(({format:i,srcset:o})=>({type:`image/${i}`,srcset:o})),width:t.source.width,height:t.source.height,placeholder:jo(e)?void 0:t.placeholder?.dataUrl}}function ls(){let e=be();e.catalog=new Map,e.transparent=new Set}function Cn(e){let t=be();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function Ph(e,t,i={}){if(!e||!Q.existsSync(e))return ls(),{count:0,fingerprint:""};if(i.offThread){let h=await ze("delivery",{publicDir:e,outputDir:t});if(h!==ke)return Cn(h.state),h.result}let o=await At(e);if(o.length===0)return ls(),{count:0,fingerprint:""};let a=$n(t),c=o.filter((h)=>{let w=a[h.relativePath];if(!w)return!0;let S=Ct(h.absolutePath);return!S||S.mtimeMs!==w.mtimeMs||S.size!==w.size});if(c.length===0)return ls(),{count:0,fingerprint:""};let l=$t(K.join(t,"_stx","images"),`${un}:${xt()}`),m={outDir:K.join(t,"_stx","images"),storage:$t(K.join(t,"_stx","images"),`${fn}:${xt()}`),baseUrl:ye,widths:ln,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(h){if(u=await vn(c),u.length===c.length)throw h;let w=new Set(u.map((R)=>R.relativePath)),S=!1;for(let R of c){if(w.has(R.relativePath))continue;let P=Ct(R.absolutePath);if(!P)continue;a[R.relativePath]=P,S=!0}if(S)Sn(t,a);if(u.length===0)return ls(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let v=await bn(y.entries),b=xn(y.entries,v),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=v;let x=v.size===0&&b.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:b.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{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,i,o){let a=oi(e,o);if(a!==void 0)return a;for(let c of ii(e,t,i,o))if(await s(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Rn=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 He(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Rn.has(t)}function ie(e,t){let i=[];for(let[o,a]of Object.entries(e.static)){if(t.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)i.push(p(c));continue}if(a===re){i.push(p(c));continue}i.push(`${p(c)}="${wn(c,We(String(a)))}"`)}return i}function ae(e,t){let i=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(t.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){i.push(p(c));continue}if(typeof a==="object")continue;i.push(`${p(c)}="${wn(c,We(String(a)))}"`)}return i}function An(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 qe={name:"StxLink",aliases:["stx-link"],render(e,t,i){let o=An(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(wr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...ie(e,v)),u.push(...ae(e,v)),`<a ${u.join(" ")}>${t}</a>`}};var kn=new Map;function Xe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return kn.get(t)}var Pn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function Z(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}function Ie(e,t,i=!1){let o=e.serverDynamic[t];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[t];if(a!==void 0)return a!=="false"&&a!==!1;return i}function Ve(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),i=[];for(let o of t)if(o.includes(":")){let[a,c]=o.split(":"),l=Pn[a];if(l)i.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))i.push(`(max-width: ${m}px) ${c}`)}}else i.push(o);return i.join(", ")}function Ge(e,t,i,o){return t.map((a)=>`${xe(e,a,void 0,i,o)} ${a}w`).join(", ")}function In(e,t,i,o,a){return t.map((c)=>{let l=i?i*c:void 0;return`${xe(e,l,void 0,o,a)} ${c}x`}).join(", ")}function xe(e,t,i,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(t)c.push(`w_${t}`);if(i)c.push(`h_${i}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(t)c.set("w",String(t));if(i)c.set("h",String(i));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(t)c.set("width",String(t));if(i)c.set("height",String(i));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function En(e,t,i="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${i}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Ke={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,i){let o=Z(e,"src")||"",a=Lo(o),c=Z(e,"alt")||"",l=Z(e,"width")||(a?String(a.source.width):void 0),m=Z(e,"height")||(a?String(a.source.height):void 0),u=Z(e,"sizes"),y=Z(e,"srcset"),v=Z(e,"densities"),b=Z(e,"format"),C=jo(o)||Xe(o)?.transparent===!0,x=Z(e,"placeholder")||(a&&!C?"thumbhash":void 0),h=Z(e,"placeholderColor")||"#e5e7eb",w=Z(e,"provider"),S=Z(e,"class")||Z(e,"className")||"",R=Z(e,"style")||"",P=Z(e,"objectFit")||Z(e,"fit"),k=Z(e,"objectPosition")||Z(e,"position"),N=Z(e,"quality"),H=Ie(e,"lazy",!0),z=Ie(e,"preload",!1),F=Ie(e,"priority",!1),q=Z(e,"loading"),B=Z(e,"decoding")||"async",E=!!a||Ie(e,"picture",!1)||!!b,T=l?Number.parseInt(l):void 0,j=m?Number.parseInt(m):void 0,W=y||"",X="";if(a)W=a.sources[a.fallback.format]||"",X=u?Ve(u):"100vw";else if(!W&&u&&w&&w!=="local"&&w!=="static")W=Ge(o,Ze,w,b),X=Ve(u);else if(!W&&v){let I=v.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));W=In(o,I,T,w,b)}else if(u)X=Ve(u);let L=[];if(R)L.push(R);if(P)L.push(`object-fit:${P}`);if(k)L.push(`object-position:${k}`);if(T&&j)L.push(`aspect-ratio:${T}/${j}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:h}:Xe(o);if(I&&x==="color")L.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)L.push(`background-color:${I.color}`),L.push(`background-image:url(${I.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=En(T||16,j||9,h);L.push(`background-image:url(${_})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||xe(o,T,j,w,b),Y=[];if(Y.push(`src="${n(wr($e,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let le=q||(F||z?"eager":H?"lazy":"");if(le)Y.push(`loading="${n(le)}"`);if(F)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(B)}"`),S)Y.push(`class="${n(S)}"`);if(L.length>0)Y.push(`style="${n(L.join(";"))}"`);if(W)Y.push(`srcset="${n(wr(W,"fetched"))}"`);if(X)Y.push(`sizes="${n(X)}"`);let te=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(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=_n(D)+(I?`;${I}`:"");Y.push(`onload="${n(_)}"`),te.add("onload")}Y.push(...ie(e,te)),Y.push(...ae(e,te));let Te=`<img ${Y.join(" ")} />`,M="";if(z){let _=b==="webp"?"image/webp":b==="avif"?"image/avif":"";M=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${W?` imagesrcset="${n(W)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
|
|
3
3
|
`}if(E){let I=[];if(a)for(let _ of Bo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(b==="avif"||b==="auto")){let _=xe(o,T,j,w,"avif"),ee=W?Ge(o,Ze,w,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(b==="webp"||b==="auto")){let _=xe(o,T,j,w,"webp"),ee=W?Ge(o,Ze,w,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${M}<picture>
|
|
4
4
|
${I.join(`
|
|
5
5
|
`)}
|
|
@@ -38,5 +38,5 @@ ${Te}
|
|
|
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 Bn,readFileSync as Tn}from"fs";var Oe=new Map,Bt=new Set;function Dn(e){if(Bt.has(e))return;Bt.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 jn(e){let t=process.cwd();for(let i 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(Bn(i))return i;for(let i of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(i)}catch{}return null}function Mn(e){if(Oe.has(e))return Oe.get(e);let t=jn(e);if(!t)return Dn(e),null;try{let i=JSON.parse(Tn(t,"utf8"));return Oe.set(e,i),i}catch{return null}}function Ln(e,t,i,o){let a=[];if(t.rotate)a.push(`rotate(${t.rotate*90} ${i/2} ${o/2})`);if(t.hFlip)a.push(`translate(${i} 0) scale(-1 1)`);if(t.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function zn(e,t){let i=t,o=e.icons[i],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[i];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;i=u.parent,o=e.icons[i]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Ln(o.body,a,c,l),width:c,height:l}}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 it={name:"Icon",aliases:["icon","stx-icon"],render(e,t,i){let o=ge(e,"name")??ge(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let S=o.split(":");a=S[0],c=S[1]}let l=n(ge(e,"size")||"24"),m=n(ge(e,"color")||"currentColor"),u=n(ge(e,"class")||""),y=n(ge(e,"style")||""),v=Oe.get(a)??Mn(a);if(!v)return`<!-- Icon: collection "${a}" not loaded -->`;let b=zn(v,c);if(!b)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${b.width} ${b.height}`,x=b.body;if(m!=="currentColor")x=x.replace(/currentColor/g,m);let h=u?` class="${u}"`:"",w=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${h}${w}>${x}</svg>`}};function Tt(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}function Dt(e,t){let i=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(i);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ot={name:"Suspense",aliases:["suspense"],render(e,t,i){let o=Dt(t,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Tt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Tt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}var at={name:"TransitionGroup",aliases:["transition-group"],render(e,t,i){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${t}</${a}>`}};function jt(e=ue){e.registerBuiltin(qe),e.registerBuiltin(Ke),e.registerBuiltin(Je),e.registerBuiltin(Qe),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at)}var Mt=new Map;function Un(e){let t=Mt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Mt.set(e.source,t);return t}var Lt=new WeakMap;function zt(e){let t=Lt.get(e);if(!t)t=new Set([...e].map((o)=>o.toLowerCase())),Lt.set(e,t);let i=t;return(o)=>!/[a-z]/.test(o)&&i.has(o.toLowerCase())}function Fn(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function Ut(e,t,i){let o=[],a=0,c=typeof i==="function"?i:i?(l)=>i.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Un(t);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let S=l+1+y.length;while(S<e.length&&e[S]!==">")S++;a=S+1;continue}let v=l+1+y.length,b=null,C=v,x=-1,h=!1;while(v<e.length){let S=e[v];if(b){if(S==="\\"&&v+1<e.length){v+=2;continue}if(S===b)b=null;v++;continue}if(S==='"'||S==="'"){b=S,v++;continue}if(S==="/"&&v+1<e.length&&e[v+1]===">"){x=v+2,h=!0;break}if(S===">"){x=v+1;break}v++}if(x===-1){a=l+1;continue}let w=e.slice(C,h?x-2:x-1).trim();if(h)o.push({fullMatch:e.slice(l,x),tagName:y,attributes:w,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let S=`<${y}`,R=`</${y}>`,P=1,k=x,N=-1;while(P>0&&k<e.length){let F=e.indexOf(S,k),q=e.indexOf(R,k);if(q===-1)break;if(F!==-1&&F<q){let B=e[F+S.length];if(B===" "||B===">"||B==="/"||B===`
|
|
41
|
-
`||B==="\t"){let E=Fn(e,F+S.length);if(e[E-1]!=="/")P++;k=E+1}else k=F+S.length}else{if(P--,P===0){N=q;break}k=q+R.length}}if(N===-1){a=x;continue}let H=e.slice(x,N),z=N+R.length;o.push({fullMatch:e.slice(l,z),tagName:y,attributes:w,content:H,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ct(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ft(e,t){try{let i=Buffer.from(e,"base64").toString("utf8");return JSON.parse(i)}catch{}try{let i=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(i)}catch(i){if(t?.debug)console.error("Error decoding __stx_ prop:",i);return e}}function lt(e,t){let i=0,o="",a=t;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")i++;else if(c==="}"){if(i--,i===0)return e.slice(t,a+1)}a++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(lt(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var Wn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function qn(e){return ut(e).map((t)=>[t.start,t.end])}function ut(e){let t=[],i=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,o;while((o=i.exec(e))!==null){let a=o[2]||"",c=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(a);if(!c)continue;let l=J(c[1]??c[2]??c[3]??""),m=o.index,u=m+o[0].length,y=o[1].toLowerCase();if(o[0].endsWith("/>")||Hn.has(y)){t.push({start:m,end:u,names:l});continue}let v=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),b=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");b.lastIndex=u;let C=1,x=u,h;while((h=b.exec(e))!==null)if(h[0].startsWith("</")){if(C--,C===0){x=h.index+h[0].length;break}}else if(!h[0].endsWith("/>"))C++;t.push({start:m,end:x,names:l})}return t}function Ht(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ht(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function ac(e,t){if(!/:[\w-]+=/.test(e))return e;let i=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...qn(e));let l=new Set([...rt(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function m(C){return a.some(([x,h])=>C>=x&&C<h)}let u=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,y=[],v=new Map,b=256;while((c=u.exec(i))!==null){if(m(c.index))continue;let C=c[0],x=c[2];if(!x||!x.includes(":"))continue;let h=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),w=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,S,R=x,P=!1;while((S=w.exec(x))!==null){if(xr(x,S.index,!0)?.kind==="attribute")continue;let k=S[1],N=S[2];if(pl(k))continue;if(O(N,l))continue;if(N.includes("()")&&!N.includes(".get(")||N.includes("$store")||N.includes("$ref"))continue;try{let H=Object.keys(t),z=Object.values(t),F=N.match(/^([a-zA-Z_$][\w$]*)/);if(F&&!H.includes(F[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(F[1]))continue;let q=JSON.stringify([H,N]),B=v.get(q);if(!B){if(B=Function(...H,`return (${N})`),v.size>=b)v.clear();v.set(q,B)}let E=B(...z);if(k==="class"){let T=U(Ht(E));if(T){let j=R.match(/\sclass="([^"]*)"/);if(j)R=R.replace(j[0],()=>` class="${j[1]} ${T}"`);else R=R.replace(S[0],()=>` class="${T}"`)}else R=R.replace(S[0],"");P=!0;continue}if(Wn.has(k)){if(E)R=R.replace(S[0],` ${k}`);else R=R.replace(S[0],"");P=!0;continue}if(E===null||E===void 0||E===!1)R=R.replace(S[0],"");else{let T=h&&typeof E==="object"?JSON.stringify(E):String(E),j=wn(k,T);R=R.replace(S[0],()=>` ${k}="${j}"`)}P=!0}catch(H){if(H instanceof oe)throw H;continue}}if(P){let k=c[3]?" /":"",H=`<${c[1]}${R}${k}>`;y.push({start:c.index,end:c.index+C.length,replacement:H})}}if(y.length>0){let C=Array(y.length*2+1),x=0;for(let h=0;h<y.length;h++){let{start:w,end:S,replacement:R}=y[h];C[h*2]=i.slice(x,w),C[h*2+1]=R,x=S}C[y.length*2]=i.slice(x),i=C.join("")}return i}import qt from"fs";import Xt from"path";var Zt=!1;function Xn(e,t,i,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),m=(b)=>{if(l.size===0)return!1;let C=r(b),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let h of l){let w=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${w}\\s*\\(`).test(C))return!0}return!1},u=new Set(fl),y=(b)=>{if(!b.includes("-")||b.startsWith("@")||b.startsWith(":")||b.startsWith("x-")||b.startsWith("__"))return b;if(b.startsWith("aria-")||b.startsWith("data-"))return b;return b.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},v=(b,C)=>{let x=y(b);if(c.static[x]=C,x!==b)c.staticNames[x]=b};for(let[b,C]of Object.entries(e)){let x=b.startsWith("x-")&&!u.has(b)&&!b.startsWith("x-bind:")&&!b.startsWith("x-on:")?`:${b.slice(2)}`:b;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let h=y(x.slice(6));c.serverDynamic[h]=Ft(C,i);continue}if(x.startsWith(":")){let h=y(x.slice(1)),w=C===re?h:C;if(h==="if"||h==="for"||h==="show"){c.clientReactive[h]=w;continue}if(o){c.clientReactive[h]=w;continue}if(O(w,a)){c.clientReactive[h]=w;continue}if(m(w)){c.clientReactive[h]=w;continue}try{if(!f(w)){if(i.debug)console.error(`Unsafe expression in :${h} binding: ${w}`);c.clientReactive[h]=w;continue}let S=Object.keys(t),R=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(st(w).some((z)=>!R.has(z)&&!S.includes(z)&&(!(z in globalThis)||P.has(z)))){c.clientReactive[h]=w;continue}let H=d(w,S)(...Object.values(t));if(c.serverDynamic[h]=H,h!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[h]=x.slice(1)}catch{c.clientReactive[h]=w}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let h=Zn(C,a);if(h!==null){c.clientReactive[y(x)]=h;continue}let w=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(w)try{let S=w[1];if(f(S)){let P=d(S,Object.keys(t))(...Object.values(t));v(x,P!=null?String(P):"")}else{if(i.debug)console.error(`Unsafe expression in ${x}: ${S}`);v(x,C)}}catch(S){if(i.debug)console.error(`Error evaluating expression for ${x}:`,S);v(x,C)}else{let S=C,R=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=R.exec(C))!==null)try{let k=P[1];if(!f(k)){if(i.debug)console.error(`Unsafe expression in ${x}: ${k}`);continue}let H=d(k,Object.keys(t))(...Object.values(t));S=S.replace(P[0],String(H??""))}catch(k){if(i.debug)console.error(`Error evaluating expression in ${x}:`,k)}v(x,S)}continue}v(x,C===re?"true":ct(C))}return c}function Zn(e,t){if(t.size===0)return null;let i=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(i)];if(!o.some((m)=>O(m[1],t)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Vn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Gn(e,t,i){if(!e.includes("@"))return e;if(!Vn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,t,i)}catch{return e}}function me(e){let t={},i=0,o=e.length;while(i<o){while(i<o&&/\s/.test(e[i]))i++;if(i>=o)break;let a="";while(i<o&&!/[\s=]/.test(e[i]))a+=e[i],i++;if(!a)break;while(i<o&&/\s/.test(e[i]))i++;if(i<o&&e[i]==="="){i++;while(i<o&&/\s/.test(e[i]))i++;let c="";if(i<o&&(e[i]==='"'||e[i]==="'")){let l=e[i];i++;while(i<o){let m=e[i];if(m==="\\"&&i+1<o){i++,c+=e[i],i++;continue}if(m===l){i++;break}c+=m,i++}}else if(e[i]==="{"){c=lt(e,i),i+=c.length;let l=Wt(c);if(l!==null){t[`:${a}`]=l;continue}}else while(i<o&&!/\s/.test(e[i]))c+=e[i],i++;t[a]=c}else t[a]=re}return t}function Vt(e){return Object.entries(e).map(([t,i])=>i===re?t:`${t}="${Kn(i)}"`).join(" ")}function Kn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Jn(e){let t=new Set,i=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=i.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))t.add(a)}return[...t].sort()}async function If(e,t,i,o,a){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,l=Xt.dirname(i),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let b of e.matchAll(u)){let[C,x,h]=b,w=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=h,R,P=[];while((R=w.exec(h))!==null){let[k,N,H,z]=R,F=null,q=null;if(z.startsWith(".")||z.startsWith("/")){let T=Xt.resolve(l,z);if(T.endsWith(".stx"))q=T;else{let j=`${T}.stx`;try{if(qt.statSync(j).isFile())q=j}catch{try{if(qt.statSync(T).isDirectory())F=T}catch{}}}}else F=Ns(z,l);if(!F&&!q)continue;let B=!1,E=(T,j)=>{c.set(T,j),c.set(T.toLowerCase(),j);let W=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(W,j),a.add(j)};if(H&&q)E(H,q),B=!0;else if(N){let T=N.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>{let X=W.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:W,local:W}}),j=F?yr(F):null;for(let{source:W,local:X}of T){let L=null;if(q)L=q;else if(j)L=j.get(W)??j.get(W.toLowerCase())??j.get(W.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)E(X,L),B=!0}}if(B)P.push({start:R.index,end:R.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)S=S.slice(0,P[k].start)+S.slice(P[k].end);m.push({start:b.index,end:b.index+C.length,value:`<script${x}>${S}</script>`})}if(m.length===0)return e;let y=[],v=0;for(let b of m)y.push(e.slice(v,b.start),b.value),v=b.end;return y.push(e.slice(v)),y.join("")}async function Yn(e,t,i,o,a){let c=e;if(!t.__importedComponents)t.__importedComponents=new Map;let l=t.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,v]=u,b=v.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of b){let x=C.split("/"),w=x[x.length-1].replace(/\.stx$/,""),S=w.includes("-")?w.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):w.charAt(0).toUpperCase()+w.slice(1),R=null,P=Ms(C,i,o);for(let k of P)try{if(await Bun.file(k).exists()){R=k;break}}catch{}if(R){l.set(S,R),l.set(w,R),l.set(w.toLowerCase(),R);let k=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(k,R),a.add(R),o.debug)console.log(`Imported component: ${S} -> ${R}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function Qn(e,t,i,o,a){let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let v=y.index,b=v+y[0].length-1,C=1,x=b+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let h=c.substring(b+1,x),w=x+1,S=h.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=0;continue}let R=S[1],P,k=h.slice(S[0].length),N=k.match(/^\s*,\s*/);if(N)P=k.slice(N[0].length).trim();let H={};if(P)try{H=A(P,t)}catch(T){let j=T instanceof Error?T.message:String(T);c=c.replace(c.substring(v,w),`[Error parsing component props: ${j}]`);continue}let z="",F=w,B=c.substring(w).match(/^([\s\S]*?)@endcomponent/);if(B)z=B[1].trim(),F=w+B[0].length;let E=await Fe(R,H,z,l,t,i,o,m,a);c=c.substring(0,v)+E+c.substring(F),u.lastIndex=0}return c}async function er(e,t,i,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=rr(c);if(u.size>0){let w=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...w,...u])]}let y=G(c);c=y.output;let v=rt(t);return c=await h(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await h(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(Sr)),c=await h(c,/[a-z][a-z0-9]*/,!1,Sr),c=y.restore(c),c;async function h(w,S,R,P){if(!w)return w;let k=w,N=Ut(k,S,P),H=ut(k),z=new Map;for(let B=N.length-1;B>=0;B--){let E=N[B],T=R?V(E.tagName):E.tagName,j=me(Gn(E.attributes,t,i)),W=H.filter(({start:I,end:_})=>E.startIndex>=I&&E.startIndex<_),X=W.length>0,L=new Set(v);for(let I of W)for(let _ of I.names)L.add(_);let D=Xn(j,t,o,X,L);if(typeof D.clientReactive.for==="string")for(let I of J(D.clientReactive.for))L.add(I);let ce=ue.getBuiltin(E.tagName),$e=ce?await Er(E.tagName,l,t,i,o):!1,Y=E.tagName==="Image"&&Ds([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>yr(I).has("Image"));if(ce&&!$e&&!Y){let I={context:t,filePath:i,options:o,dependencies:a},_=ce.render(D,E.content,I);if(Object.keys(D.events).length>0){let ee=Vt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Gt(_,D.clientReactive);z.set(B,_);continue}if(!R&&E.tagName.includes("-")&&!await Er(T,l,t,i,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},M=await Fe(T,le,y.restore(E.content),l,t,i,o,m,a,[...L],te,E.tagName);if(M=tr(M,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(V),_=ft(M,!0);if(I.length&&_){if(!Object.hasOwn(me(M.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))M=M.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+M.slice(_.insertPos);let ne=we(M);M=M.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+M.slice(ne.insertPos)}let ee=ft(M,!0);if(ee){let ne=me(M.slice(ee.insertPos,ee.tagEnd)),Se=we(M),Jt=me(M.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Jt,"data-stx-native-host-owner"))M=M.slice(0,Se.insertPos)+" data-stx-native-host-owner"+M.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(M);if(I){let _=Vt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");M=M.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+M.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)M=Gt(M,D.clientReactive);z.set(B,M)}if(z.size===0)return k;let F="",q=0;for(let B=0;B<N.length;B++){let E=z.get(B);if(E===void 0)continue;F+=k.slice(q,N[B].startIndex),F+=E,q=N[B].endIndex}return F+=k.slice(q),F}}function Gt(e,t){let i=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(t).filter(([v])=>!i.has(v)),c=a.filter(([v])=>!o.has(v)).map(([v])=>V(v)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let v=a.map(([C,x])=>`:${V(C)}="${x.replace(/"/g,""")}"`).join(" "),b=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${b} ${v}`+l.substring(m.insertPos)}let u=t.if;if(u)l=`<template :if="${u.replace(/"/g,""")}">${l}</template>`;let y=t.for;if(y){let v=t.key,b=v?` :key="${v.replace(/"/g,""")}"`:"";l=`<template :for="${y.replace(/"/g,""")}"${b}>${l}</template>`}return l}function tr(e,t,i=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=t.serverDynamic.class??t.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let h=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,w=h.test(l)?l.replace(h,(S,R,P,k,N)=>`${R}class="${n(`${ct(P??k??N)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+w+e.slice(c.tagEnd),c.tagEnd+=w.length-l.length,l=w}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:i,v=new Set(Object.keys(me(l))),b=new Set(["class","className"]);for(let h of Object.keys(t.static)){let w=t.staticNames[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}for(let h of Object.keys(t.serverDynamic)){let w=t.serverDynamicNames?.[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}let C=[];if(u){for(let[h,w]of Object.entries(t.static)){if(b.has(h)||w!==!0&&w!==re)continue;b.add(h),C.push(`${n(t.staticNames?.[h]??h)}="true"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!0)continue;b.add(h),C.push(`${n(t.serverDynamicNames?.[h]??h)}="true"`)}}let x=[...ie(t,b),...ae(t,b),...C];if(u){for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!1)continue;let S=t.serverDynamicNames?.[h]??h;x.push(`${n(S)}="false"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w===null||typeof w!=="object")continue;let S=JSON.stringify(w);if(S!==void 0){let R=t.serverDynamicNames?.[h]??h;x.push(`${n(R)}="${n(S)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let t=Kt(e,0);if(t)return t;let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(i)return{insertPos:i.index+1+i[1].length,tagEnd:dt(e,i.index+1+i[1].length)};return null}function ft(e,t=!1){let i=we(e);if(!i)return null;let o=e.slice(i.insertPos,i.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Kt(e,i.tagEnd+1):i;return a&&t?nr(e,a)??a:a}function nr(e,t){if(!e.includes("data-stx-native-host-root"))return null;let i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",t.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let v=e.indexOf("-->",o+4);if(v<0)return null;o=e.indexOf("<",v+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let v=new RegExp(`</${m}\\s*>`,"gi");if(v.lastIndex=y+1,!v.exec(e))return null;o=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(u,y)),b=a>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(c===void 0&&!b&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!i.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&b)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Kt(e,t){let i=t;while(i<e.length){let o=e.slice(i),a=o.match(/^\s+/);if(a){i+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",i+4);if(m===-1)return null;i=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,i+c[0].length);if(u===-1)return null;i=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:i+1+l[1].length,tagEnd:dt(e,i+1+l[1].length)}}return null}function dt(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function rr(e){let t=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=i[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of li(i[2]))t.add(a);for(let a of i[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])t.add(a[1]);if(a[3])t.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))t.add(l)}}}return t}async function ds(e,t,i,o,a){if(!Zt)jt(ue),Zt=!0;let c=await If(e,t,i,o,a);c=await Yn(c,t,i,o,a),c=await Qn(c,t,i,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Ne,(b,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let v=c;if(c=await er(y.output,t,i,o,a),c===v)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Jn(c);if(m.length>0)console.warn(`[stx] ${i}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
|
|
42
|
-
export{Lo,jo,Bo,Ah,
|
|
41
|
+
`||B==="\t"){let E=Fn(e,F+S.length);if(e[E-1]!=="/")P++;k=E+1}else k=F+S.length}else{if(P--,P===0){N=q;break}k=q+R.length}}if(N===-1){a=x;continue}let H=e.slice(x,N),z=N+R.length;o.push({fullMatch:e.slice(l,z),tagName:y,attributes:w,content:H,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ct(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ft(e,t){try{let i=Buffer.from(e,"base64").toString("utf8");return JSON.parse(i)}catch{}try{let i=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(i)}catch(i){if(t?.debug)console.error("Error decoding __stx_ prop:",i);return e}}function lt(e,t){let i=0,o="",a=t;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")i++;else if(c==="}"){if(i--,i===0)return e.slice(t,a+1)}a++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(lt(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var Wn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function qn(e){return ut(e).map((t)=>[t.start,t.end])}function ut(e){let t=[],i=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,o;while((o=i.exec(e))!==null){let a=o[2]||"",c=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(a);if(!c)continue;let l=J(c[1]??c[2]??c[3]??""),m=o.index,u=m+o[0].length,y=o[1].toLowerCase();if(o[0].endsWith("/>")||Hn.has(y)){t.push({start:m,end:u,names:l});continue}let v=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),b=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");b.lastIndex=u;let C=1,x=u,h;while((h=b.exec(e))!==null)if(h[0].startsWith("</")){if(C--,C===0){x=h.index+h[0].length;break}}else if(!h[0].endsWith("/>"))C++;t.push({start:m,end:x,names:l})}return t}function Ht(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ht(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function ac(e,t){if(!/:[\w-]+=/.test(e))return e;let i=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...qn(e));let l=new Set([...rt(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function m(C){return a.some(([x,h])=>C>=x&&C<h)}let u=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,y=[],v=new Map,b=256;while((c=u.exec(i))!==null){if(m(c.index))continue;let C=c[0],x=c[2];if(!x||!x.includes(":"))continue;let h=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),w=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,S,R=x,P=!1;while((S=w.exec(x))!==null){if(xr(x,S.index,!0)?.kind==="attribute")continue;let k=S[1],N=S[2];if(pl(k))continue;if(O(N,l))continue;if(N.includes("()")&&!N.includes(".get(")||N.includes("$store")||N.includes("$ref"))continue;try{let H=Object.keys(t),z=Object.values(t),F=N.match(/^([a-zA-Z_$][\w$]*)/);if(F&&!H.includes(F[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(F[1]))continue;let q=JSON.stringify([H,N]),B=v.get(q);if(!B){if(B=Function(...H,`return (${N})`),v.size>=b)v.clear();v.set(q,B)}let E=B(...z);if(k==="class"){let T=U(Ht(E));if(T){let j=R.match(/\sclass="([^"]*)"/);if(j)R=R.replace(j[0],()=>` class="${j[1]} ${T}"`);else R=R.replace(S[0],()=>` class="${T}"`)}else R=R.replace(S[0],"");P=!0;continue}if(Wn.has(k)){if(E)R=R.replace(S[0],` ${k}`);else R=R.replace(S[0],"");P=!0;continue}if(E===null||E===void 0||E===!1)R=R.replace(S[0],"");else{let T=h&&typeof E==="object"?JSON.stringify(E):String(E),j=wn(k,T);R=R.replace(S[0],()=>` ${k}="${j}"`)}P=!0}catch(H){if(H instanceof oe)throw H;continue}}if(P){let k=c[3]?" /":"",H=`<${c[1]}${R}${k}>`;y.push({start:c.index,end:c.index+C.length,replacement:H})}}if(y.length>0){let C=Array(y.length*2+1),x=0;for(let h=0;h<y.length;h++){let{start:w,end:S,replacement:R}=y[h];C[h*2]=i.slice(x,w),C[h*2+1]=R,x=S}C[y.length*2]=i.slice(x),i=C.join("")}return i}import qt from"fs";import Xt from"path";var Zt=!1;function Xn(e,t,i,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),m=(b)=>{if(l.size===0)return!1;let C=r(b),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let h of l){let w=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${w}\\s*\\(`).test(C))return!0}return!1},u=new Set(fl),y=(b)=>{if(!b.includes("-")||b.startsWith("@")||b.startsWith(":")||b.startsWith("x-")||b.startsWith("__"))return b;if(b.startsWith("aria-")||b.startsWith("data-"))return b;return b.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},v=(b,C)=>{let x=y(b);if(c.static[x]=C,x!==b)c.staticNames[x]=b};for(let[b,C]of Object.entries(e)){let x=b.startsWith("x-")&&!u.has(b)&&!b.startsWith("x-bind:")&&!b.startsWith("x-on:")?`:${b.slice(2)}`:b;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let h=y(x.slice(6));c.serverDynamic[h]=Ft(C,i);continue}if(x.startsWith(":")){let h=y(x.slice(1)),w=C===re?h:C;if(h==="if"||h==="for"||h==="show"){c.clientReactive[h]=w;continue}if(o){c.clientReactive[h]=w;continue}if(O(w,a)){c.clientReactive[h]=w;continue}if(m(w)){c.clientReactive[h]=w;continue}try{if(!f(w)){if(i.debug)console.error(`Unsafe expression in :${h} binding: ${w}`);c.clientReactive[h]=w;continue}let S=Object.keys(t),R=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(st(w).some((z)=>!R.has(z)&&!S.includes(z)&&(!(z in globalThis)||P.has(z)))){c.clientReactive[h]=w;continue}let H=d(w,S)(...Object.values(t));if(c.serverDynamic[h]=H,h!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[h]=x.slice(1)}catch{c.clientReactive[h]=w}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let h=Zn(C,a);if(h!==null){c.clientReactive[y(x)]=h;continue}let w=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(w)try{let S=w[1];if(f(S)){let P=d(S,Object.keys(t))(...Object.values(t));v(x,P!=null?String(P):"")}else{if(i.debug)console.error(`Unsafe expression in ${x}: ${S}`);v(x,C)}}catch(S){if(i.debug)console.error(`Error evaluating expression for ${x}:`,S);v(x,C)}else{let S=C,R=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=R.exec(C))!==null)try{let k=P[1];if(!f(k)){if(i.debug)console.error(`Unsafe expression in ${x}: ${k}`);continue}let H=d(k,Object.keys(t))(...Object.values(t));S=S.replace(P[0],String(H??""))}catch(k){if(i.debug)console.error(`Error evaluating expression in ${x}:`,k)}v(x,S)}continue}v(x,C===re?"true":ct(C))}return c}function Zn(e,t){if(t.size===0)return null;let i=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(i)];if(!o.some((m)=>O(m[1],t)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Vn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Gn(e,t,i){if(!e.includes("@"))return e;if(!Vn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,t,i)}catch{return e}}function me(e){let t={},i=0,o=e.length;while(i<o){while(i<o&&/\s/.test(e[i]))i++;if(i>=o)break;let a="";while(i<o&&!/[\s=]/.test(e[i]))a+=e[i],i++;if(!a)break;while(i<o&&/\s/.test(e[i]))i++;if(i<o&&e[i]==="="){i++;while(i<o&&/\s/.test(e[i]))i++;let c="";if(i<o&&(e[i]==='"'||e[i]==="'")){let l=e[i];i++;while(i<o){let m=e[i];if(m==="\\"&&i+1<o){i++,c+=e[i],i++;continue}if(m===l){i++;break}c+=m,i++}}else if(e[i]==="{"){c=lt(e,i),i+=c.length;let l=Wt(c);if(l!==null){t[`:${a}`]=l;continue}}else while(i<o&&!/\s/.test(e[i]))c+=e[i],i++;t[a]=c}else t[a]=re}return t}function Vt(e){return Object.entries(e).map(([t,i])=>i===re?t:`${t}="${Kn(i)}"`).join(" ")}function Kn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Jn(e){let t=new Set,i=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=i.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))t.add(a)}return[...t].sort()}async function If(e,t,i,o,a){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,l=Xt.dirname(i),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let b of e.matchAll(u)){let[C,x,h]=b,w=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=h,R,P=[];while((R=w.exec(h))!==null){let[k,N,H,z]=R,F=null,q=null;if(z.startsWith(".")||z.startsWith("/")){let T=Xt.resolve(l,z);if(T.endsWith(".stx"))q=T;else{let j=`${T}.stx`;try{if(qt.statSync(j).isFile())q=j}catch{try{if(qt.statSync(T).isDirectory())F=T}catch{}}}}else F=Os(z,l);if(!F&&!q)continue;let B=!1,E=(T,j)=>{c.set(T,j),c.set(T.toLowerCase(),j);let W=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(W,j),a.add(j)};if(H&&q)E(H,q),B=!0;else if(N){let T=N.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>{let X=W.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:W,local:W}}),j=F?yr(F):null;for(let{source:W,local:X}of T){let L=null;if(q)L=q;else if(j)L=j.get(W)??j.get(W.toLowerCase())??j.get(W.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)E(X,L),B=!0}}if(B)P.push({start:R.index,end:R.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)S=S.slice(0,P[k].start)+S.slice(P[k].end);m.push({start:b.index,end:b.index+C.length,value:`<script${x}>${S}</script>`})}if(m.length===0)return e;let y=[],v=0;for(let b of m)y.push(e.slice(v,b.start),b.value),v=b.end;return y.push(e.slice(v)),y.join("")}async function Yn(e,t,i,o,a){let c=e;if(!t.__importedComponents)t.__importedComponents=new Map;let l=t.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,v]=u,b=v.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of b){let x=C.split("/"),w=x[x.length-1].replace(/\.stx$/,""),S=w.includes("-")?w.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):w.charAt(0).toUpperCase()+w.slice(1),R=null,P=Ns(C,i,o);for(let k of P)try{if(await Bun.file(k).exists()){R=k;break}}catch{}if(R){l.set(S,R),l.set(w,R),l.set(w.toLowerCase(),R);let k=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(k,R),a.add(R),o.debug)console.log(`Imported component: ${S} -> ${R}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function Qn(e,t,i,o,a){let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let v=y.index,b=v+y[0].length-1,C=1,x=b+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let h=c.substring(b+1,x),w=x+1,S=h.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=0;continue}let R=S[1],P,k=h.slice(S[0].length),N=k.match(/^\s*,\s*/);if(N)P=k.slice(N[0].length).trim();let H={};if(P)try{H=A(P,t)}catch(T){let j=T instanceof Error?T.message:String(T);c=c.replace(c.substring(v,w),`[Error parsing component props: ${j}]`);continue}let z="",F=w,B=c.substring(w).match(/^([\s\S]*?)@endcomponent/);if(B)z=B[1].trim(),F=w+B[0].length;let E=await Fe(R,H,z,l,t,i,o,m,a);c=c.substring(0,v)+E+c.substring(F),u.lastIndex=0}return c}async function er(e,t,i,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=rr(c);if(u.size>0){let w=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...w,...u])]}let y=G(c);c=y.output;let v=rt(t);return c=await h(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await h(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(Sr)),c=await h(c,/[a-z][a-z0-9]*/,!1,Sr),c=y.restore(c),c;async function h(w,S,R,P){if(!w)return w;let k=w,N=Ut(k,S,P),H=ut(k),z=new Map;for(let B=N.length-1;B>=0;B--){let E=N[B],T=R?V(E.tagName):E.tagName,j=me(Gn(E.attributes,t,i)),W=H.filter(({start:I,end:_})=>E.startIndex>=I&&E.startIndex<_),X=W.length>0,L=new Set(v);for(let I of W)for(let _ of I.names)L.add(_);let D=Xn(j,t,o,X,L);if(typeof D.clientReactive.for==="string")for(let I of J(D.clientReactive.for))L.add(I);let ce=ue.getBuiltin(E.tagName),$e=ce?await Cr(E.tagName,l,t,i,o):!1,Y=E.tagName==="Image"&&Ms([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>yr(I).has("Image"));if(ce&&!$e&&!Y){let I={context:t,filePath:i,options:o,dependencies:a},_=ce.render(D,E.content,I);if(Object.keys(D.events).length>0){let ee=Vt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Gt(_,D.clientReactive);z.set(B,_);continue}if(!R&&E.tagName.includes("-")&&!await Cr(T,l,t,i,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},M=await Fe(T,le,y.restore(E.content),l,t,i,o,m,a,[...L],te,E.tagName);if(M=tr(M,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(V),_=ft(M,!0);if(I.length&&_){if(!Object.hasOwn(me(M.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))M=M.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+M.slice(_.insertPos);let ne=we(M);M=M.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+M.slice(ne.insertPos)}let ee=ft(M,!0);if(ee){let ne=me(M.slice(ee.insertPos,ee.tagEnd)),Se=we(M),Jt=me(M.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Jt,"data-stx-native-host-owner"))M=M.slice(0,Se.insertPos)+" data-stx-native-host-owner"+M.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(M);if(I){let _=Vt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");M=M.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+M.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)M=Gt(M,D.clientReactive);z.set(B,M)}if(z.size===0)return k;let F="",q=0;for(let B=0;B<N.length;B++){let E=z.get(B);if(E===void 0)continue;F+=k.slice(q,N[B].startIndex),F+=E,q=N[B].endIndex}return F+=k.slice(q),F}}function Gt(e,t){let i=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(t).filter(([v])=>!i.has(v)),c=a.filter(([v])=>!o.has(v)).map(([v])=>V(v)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let v=a.map(([C,x])=>`:${V(C)}="${x.replace(/"/g,""")}"`).join(" "),b=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${b} ${v}`+l.substring(m.insertPos)}let u=t.if;if(u)l=`<template :if="${u.replace(/"/g,""")}">${l}</template>`;let y=t.for;if(y){let v=t.key,b=v?` :key="${v.replace(/"/g,""")}"`:"";l=`<template :for="${y.replace(/"/g,""")}"${b}>${l}</template>`}return l}function tr(e,t,i=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=t.serverDynamic.class??t.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let h=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,w=h.test(l)?l.replace(h,(S,R,P,k,N)=>`${R}class="${n(`${ct(P??k??N)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+w+e.slice(c.tagEnd),c.tagEnd+=w.length-l.length,l=w}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:i,v=new Set(Object.keys(me(l))),b=new Set(["class","className"]);for(let h of Object.keys(t.static)){let w=t.staticNames[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}for(let h of Object.keys(t.serverDynamic)){let w=t.serverDynamicNames?.[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}let C=[];if(u){for(let[h,w]of Object.entries(t.static)){if(b.has(h)||w!==!0&&w!==re)continue;b.add(h),C.push(`${n(t.staticNames?.[h]??h)}="true"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!0)continue;b.add(h),C.push(`${n(t.serverDynamicNames?.[h]??h)}="true"`)}}let x=[...ie(t,b),...ae(t,b),...C];if(u){for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!1)continue;let S=t.serverDynamicNames?.[h]??h;x.push(`${n(S)}="false"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w===null||typeof w!=="object")continue;let S=JSON.stringify(w);if(S!==void 0){let R=t.serverDynamicNames?.[h]??h;x.push(`${n(R)}="${n(S)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let t=Kt(e,0);if(t)return t;let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(i)return{insertPos:i.index+1+i[1].length,tagEnd:dt(e,i.index+1+i[1].length)};return null}function ft(e,t=!1){let i=we(e);if(!i)return null;let o=e.slice(i.insertPos,i.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Kt(e,i.tagEnd+1):i;return a&&t?nr(e,a)??a:a}function nr(e,t){if(!e.includes("data-stx-native-host-root"))return null;let i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",t.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let v=e.indexOf("-->",o+4);if(v<0)return null;o=e.indexOf("<",v+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let v=new RegExp(`</${m}\\s*>`,"gi");if(v.lastIndex=y+1,!v.exec(e))return null;o=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(u,y)),b=a>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(c===void 0&&!b&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!i.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&b)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Kt(e,t){let i=t;while(i<e.length){let o=e.slice(i),a=o.match(/^\s+/);if(a){i+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",i+4);if(m===-1)return null;i=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,i+c[0].length);if(u===-1)return null;i=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:i+1+l[1].length,tagEnd:dt(e,i+1+l[1].length)}}return null}function dt(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function rr(e){let t=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=i[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of li(i[2]))t.add(a);for(let a of i[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])t.add(a[1]);if(a[3])t.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))t.add(l)}}}return t}async function us(e,t,i,o,a){if(!Zt)jt(ue),Zt=!0;let c=await If(e,t,i,o,a);c=await Yn(c,t,i,o,a),c=await Qn(c,t,i,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Ne,(b,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let v=c;if(c=await er(y.output,t,i,o,a),c===v)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Jn(c);if(m.length>0)console.warn(`[stx] ${i}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
|
|
42
|
+
export{Lo,jo,Bo,Ah,ls,Ph,ac,If,us};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{If,us}from"./chunk-df60fpgx.js";import"./chunk-dnqt6y8v.js";import"./chunk-m0x96g8e.js";import"./chunk-f54t0qar.js";import{kr}from"./chunk-f0bwetnx.js";import"./chunk-pdnyhs63.js";import"./chunk-m7hfcxt3.js";import{st}from"./chunk-7rk7wfm6.js";import"./chunk-r9e0r6jx.js";import"./chunk-n761hp6d.js";export{st as freeIdentifiers,us as processComponents,If as processESImports,kr as rendersAsElement};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{xe,Pt,ci,Ls,Pc,Ic,Oc,Nc,js,ui,Mc,Dc,di,hn}from"./chunk-f0bwetnx.js";import{k}from"./chunk-n761hp6d.js";import{a}from"./chunk-nmkkfpmh.js";import{wo}from"./chunk-2p3eaj16.js";import{c}from"./chunk-0rjcbqk3.js";import{existsSync as B,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=hn.filter((e)=>!ge.has(e)).sort(),te=[...k].sort(),he=[...new Set([...ee,...te])].sort(),be=new Set(ee),ye=new Set(te),Se=new Set(he),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function ke(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let f of t){if(f.offset===void 0)continue;let i=f.kind==="server"?be:ye;Y.lastIndex=0;for(let p of f.code.matchAll(Y)){let g=p.index+p[0].indexOf("{")+1;for(let d of p[1].matchAll(/[^,]+/g)){let y=d[0];if(/^\s*type\s/.test(y))continue;let b=/^\s*([A-Za-z_$][\w$]*)/.exec(y);if(!b)continue;let r=b[1];if(!Se.has(r)||i.has(r))continue;let o=f.offset+g+d.index+b[0].length-r.length,u=e.slice(0,o),S=u.split(`
|
|
3
|
+
`).length;s.push({line:S,column:o-(u.lastIndexOf(`
|
|
4
|
+
`)+1)+1,offset:o,length:r.length,name:r,kind:f.kind,message:ke(r,f.kind)})}}}return s}import E from"path";var we="@stacksjs/stx-typescript-plugin";function $e(e,t){let s=E.resolve(e);for(;;){let f=E.join(s,"tsconfig.json");if(t(f))return f;let i=E.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let f=$e(e,s);if(!f)return;let i=new Set,p=(g)=>{if(i.has(g))return;i.add(g);let d=t(g);if(!d)return;let y=d.compilerOptions?.plugins;if(Array.isArray(y)){let r=y.find((u)=>u?.name===we),o=Array.isArray(r?.libs)?r.libs.filter((u)=>typeof u==="string"):[];return r?{configPath:g,libs:o.map((u)=>E.resolve(E.dirname(g),u))}:null}let b=typeof d.extends==="string"?[d.extends]:Array.isArray(d.extends)?d.extends:[];for(let r of[...b].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let o=E.resolve(E.dirname(g),r.endsWith(".json")?r:`${r}.json`),u=p(o);if(u!==void 0)return u}return};return p(f)??void 0}function oa(e,t="",s=""){let f=e.startLine>1?`
|
|
5
|
+
`.repeat(e.startLine-1):"",i=ci(ui(e)+e.code,t),p=Ls(i.code),g=e.kind==="client"||e.kind==="plain"?Oc(t,e.code):"",d=(f+p).split(`
|
|
6
|
+
`),y=d.length,b=new Map;for(let o of i.declarations)for(let[u,S]of o.text.split(`
|
|
7
|
+
`).entries())if(d.push(S),o.origin)b.set(d.length,{...o.origin,line:e.startLine+o.origin.line-1+u,column:u===0?o.origin.column:1});d.push(g,"export {}","");let r=js(d.join(`
|
|
8
|
+
`),s);return{text:r.code,sourceLineCount:y,lineMap:b,scriptColumns:new Map([...i.columns].map(([o,u])=>[o+e.startLine-1,u])),importColumns:r.columns}}function Yg(e,t="",s=""){return oa(e,t,s).text}var ve=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function Te(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],s=new Set(k),f=[];for(let{file:i,names:p}of e){let g=JSON.stringify(i.replace(/\\/g,"/").replace(/\.ts$/,""));f.push(` export * from ${g}`);for(let d of p){if(s.has(d)||ve.has(d))continue;s.add(d),t.push(`declare const ${d}: typeof import(${g})[${JSON.stringify(d)}]`)}}return t.push("declare module '@composables' {",...f,"}"),t.join(`
|
|
9
|
+
`)}function ia(e,t,s){return`${e}.__stx_${t}${s}.ts`}function Zg(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function Dl(){return se("stx.d.ts")}function Ll(){return se("stx-module.d.ts")}function se(e){for(let t of[h.resolve(import.meta.dir,"..",e),h.resolve(import.meta.dir,"..","..",e)])if(B(t))return t;return null}var De=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function re(e){return e>=1000&&e<2000}function oe(e){let t="",s=!1,f=!1;for(let i=0;i<e.length;i++){let p=e[i];if(s){if(t+=p,f)f=!1;else if(p==="\\")f=!0;else if(p==='"')s=!1;continue}if(p==='"'){s=!0,t+=p;continue}if(p==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
|
|
10
|
+
`)i++;t+=`
|
|
11
|
+
`;continue}if(p==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=p}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Ne(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(B(r)){s=r;break}let o=h.dirname(t);if(o===t)break;t=o}if(!s)return{};let f=new Set,i=s,p,g,d=s;while(i&&!f.has(i)){f.add(i);let r;try{r=JSON.parse(oe(K(i,"utf8")))}catch{break}let o=r?.compilerOptions??{};if(!p&&o.paths&&typeof o.paths==="object")p=o.paths,d=i;if(!g&&typeof o.baseUrl==="string")g=h.resolve(h.dirname(i),o.baseUrl);if(p&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!p)return{};let y=g??h.dirname(d),b={};for(let[r,o]of Object.entries(p)){if(!Array.isArray(o))continue;b[r]=o.map((u)=>typeof u==="string"&&!h.isAbsolute(u)?h.resolve(y,u):u)}return{paths:b}}async function Qg(e,t={}){let s=t.client!==!1,f=t.server!==!1,i=t.templates!==!1,p=t.componentsDir??(i?(await a()).componentsDir:void 0),g=new Map,d=new Map,y=[],b=[],r=0,o=0,u=Dl();for(let n of e){let l=await Bun.file(n).text(),x=Pt(l).filter((m)=>{if(m.kind==="server")return f;return s}),w=Pt(l).filter((m)=>m.kind==="server").map((m)=>m.code).join(`
|
|
12
|
+
`);for(let m of ne(l,x))y.push({file:n,line:m.line,column:m.column,code:0,message:m.message,category:"error",blockKind:m.kind});if(s&&w){let m=x.filter((v)=>v.kind!=="server"),O=[...new Set(m.flatMap((v)=>Nc(w,v.code)))];if(O.length>0)d.set(n,{names:O,line:m[0].startLine,kind:m[0].kind})}let N=h.dirname(h.resolve(n)),D=i?Mc(l,{runtimeGlobals:!u,originDir:N,filePath:h.resolve(n),componentsDir:p}):null,R=D?[...D.lineMap.values()].filter((m)=>m.expression).length:0;if(x.length===0&&R===0)continue;if(b.push(n),r+=x.length,o+=R,x.forEach((m,O)=>{let v=oa(m,w,N);g.set(ia(n,m.kind,O),{virtual:v,source:v.text,origin:n,kind:m.kind})}),D&&R>0)g.set(ia(n,"template",0),{source:D.text,origin:n,kind:"template",virtual:D})}if(g.size===0)return{diagnostics:y,checkedFiles:b,blockCount:0,expressionCount:0};let S=(t.extraLibs??[]).map((n)=>h.resolve(n)),ce=ie(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,B);for(let n of ce?.libs??[])if(!S.includes(n)&&B(n))S.push(n);if(u)S.push(u);let F=u?Ll():null;if(F)S.push(F);let G=`${c()}/typecheck/__stx_globals.d.ts`,ae=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Pc(u?Ic(K(u,"utf8")):void 0),...u?[]:["declare const window: any",...k.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...xe.map((n)=>`declare const ${n}: any`)].join(`
|
|
13
|
+
`),Te(await wo())].filter(Boolean).join(`
|
|
14
|
+
`),C=`${c()}/typecheck`;await Bun.$`rm -rf ${C}`.quiet().nothrow(),await Bun.$`mkdir -p ${C}`.quiet().nothrow(),await Bun.write(G,ae);let M=new Map,le=0;for(let[n,l]of g){let x=`${le++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${C}/${x}`,l.source),M.set(x,l)}let ue={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Ne(e.length>0?h.dirname(h.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},V=async(n,l)=>{let x=`${C}/tsconfig${l===1?"":`.${l}`}.json`;await Bun.write(x,JSON.stringify({compilerOptions:ue,files:n.map((N)=>`${C}/${N}`).concat(G,...S)},null,2));let w=Bun.spawnSync(["bun","x","tsc","-p",x,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(w.stdout)+new TextDecoder().decode(w.stderr),exitCode:w.exitCode??0}},X=await V([...M.keys()],1),J=X.output,P=[],U=X.exitCode,W=0,pe=new Set(S.map((n)=>n.split("/").pop())),z=0,j=new Set,q=(n)=>{for(let l of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
|
|
15
|
+
`)){let x=l.match(De);if(!x)continue;if(W++,pe.has(x[1].split("/").pop()))z++;let[,w,N,D,R,m,O]=x,v=w.split("/").pop(),T=M.get(v);if(!T)continue;if(re(Number(m)))j.add(v);let L=Number(N),A=Number(D),Q;if(T.virtual){let _=di(T.virtual,L,A)??(T.kind!=="template"&&re(Number(m))?di(T.virtual,T.virtual.sourceLineCount,1):null);if(!_||T.kind==="template"&&!_.expression)continue;if(Dc(_,Number(m)))continue;L=_.line,A=_.column,Q=_.expression?.code.trim()}P.push({file:T.origin,line:L,column:A,code:Number(m),message:O,category:R==="error"?"error":"warning",blockKind:T.kind,expression:Q})}};q(J);let de=W,fe=z;if(j.size>0&&j.size<M.size){let n=[...M.keys()].filter((l)=>!j.has(l));q((await V(n,2)).output)}if(s)for(let[n,l]of d){if(l.names.length===0)continue;P.push({file:n,line:l.line,column:1,code:0,message:`${l.names.length===1?"1 value reaches":`${l.names.length} values reach`} this block on the implicit bridge and ${l.names.length===1?"is":"are"} untyped: ${l.names.join(", ")}. Declare them with defineClientPayload({ ${l.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:l.kind})}P.push(...y);let H=new Set,I=P.filter((n)=>{let l=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(H.has(l))return!1;return H.add(l),!0});I.sort((n,l)=>n.file.localeCompare(l.file)||n.line-l.line||n.column-l.column);let Z=fe>0&&I.length===0,me=Z||U!==0&&de===0?`${Z?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
|
|
16
|
+
${J.trim().split(`
|
|
17
|
+
`).slice(0,12).join(`
|
|
18
|
+
`)||"(no output)"}`:void 0;return{diagnostics:I,checkedFiles:b,blockCount:r,expressionCount:o,failure:me}}function em(e){return e.map((t)=>{let s=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${s}`}).join(`
|
|
19
|
+
`)}
|
|
20
|
+
export{oa,Yg,ia,Zg,Dl,Ll,Qg,em};
|