@stacksjs/stx 0.2.701 → 0.2.704
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-db29j1pc.js → chunk-085ahtvv.js} +1 -1
- package/dist/{chunk-pdeg77hy.js → chunk-220jxx8e.js} +1 -1
- package/dist/{chunk-0vpk16gq.js → chunk-2gzrx4ma.js} +7 -7
- package/dist/chunk-2nj9hgan.js +2 -0
- package/dist/{chunk-cq21rc0g.js → chunk-2nqt1m3m.js} +2 -2
- package/dist/{chunk-x3hw124a.js → chunk-2xtzzx00.js} +1 -1
- package/dist/chunk-3fwj83yq.js +2 -0
- package/dist/chunk-3k6k0rrj.js +2 -0
- package/dist/{chunk-zzgc9dhz.js → chunk-41s97r8a.js} +1 -1
- package/dist/{chunk-nvtk2198.js → chunk-49d8ymjf.js} +1 -1
- package/dist/{chunk-fx2y2wv7.js → chunk-4j49zf6y.js} +10 -10
- package/dist/{chunk-edjgkheg.js → chunk-4t9cggwf.js} +1 -1
- package/dist/{chunk-r6q8m9wz.js → chunk-5j5pv2yp.js} +1 -1
- package/dist/chunk-5ym5r2p6.js +2 -0
- package/dist/{chunk-vm4ab62v.js → chunk-6jvah29c.js} +1 -1
- package/dist/{chunk-a2z5emw7.js → chunk-6ws799sk.js} +1 -1
- package/dist/{chunk-0ztgcyvw.js → chunk-7defwkm1.js} +1 -1
- package/dist/{chunk-6y2vagad.js → chunk-7xv4xa3c.js} +5 -5
- package/dist/{chunk-yw4bs6fh.js → chunk-82q904k7.js} +1 -1
- package/dist/{chunk-g15vfggh.js → chunk-85j04fbh.js} +3 -3
- package/dist/chunk-8dhve9jr.js +2 -0
- package/dist/chunk-8ksv8fxp.js +2 -0
- package/dist/{chunk-55mcxp2b.js → chunk-91mv8zwk.js} +2 -2
- package/dist/{chunk-h2jbgvfs.js → chunk-9j1s520t.js} +5 -5
- package/dist/{chunk-4zsykpm6.js → chunk-9jejxz01.js} +2 -2
- package/dist/{chunk-csrahdyk.js → chunk-a7y23bhb.js} +2 -2
- package/dist/{chunk-12n3tyb2.js → chunk-ae1mpb01.js} +1 -1
- package/dist/{chunk-hc8p4hdr.js → chunk-ak7n6tan.js} +1 -1
- package/dist/{chunk-dyx9zcwy.js → chunk-argjxtx9.js} +1 -1
- package/dist/{chunk-emymxrhc.js → chunk-bh9sjtr2.js} +1 -1
- package/dist/{chunk-mpxnqpyw.js → chunk-ddw8tpdd.js} +1 -1
- package/dist/{chunk-3qtbdrfc.js → chunk-er1hq0jx.js} +1 -1
- package/dist/{chunk-kqkfs9a7.js → chunk-fts29w33.js} +3 -3
- package/dist/{chunk-6vd0vpsj.js → chunk-g31b830p.js} +1 -1
- package/dist/chunk-g4qf1r5f.js +2 -0
- package/dist/chunk-gjsmny7t.js +2 -0
- package/dist/{chunk-y9qbnvq4.js → chunk-gmceftkr.js} +1 -1
- package/dist/chunk-gnt776x9.js +2 -0
- package/dist/{chunk-fkxt007p.js → chunk-h0m8ccfk.js} +9 -9
- package/dist/chunk-ha4vb9a6.js +2 -0
- package/dist/{chunk-yft8yn6y.js → chunk-jkywbfb0.js} +2 -2
- package/dist/{chunk-r27qnema.js → chunk-jp19632h.js} +1 -1
- package/dist/{chunk-hckj9ejj.js → chunk-kw4afzfh.js} +5 -5
- package/dist/{chunk-8mpszaz7.js → chunk-m5k44pc8.js} +1 -1
- package/dist/{chunk-6r5p7p4t.js → chunk-mdnj45xm.js} +2 -2
- package/dist/{chunk-45es05ph.js → chunk-n2ema4wf.js} +2 -2
- package/dist/{chunk-avvngqyb.js → chunk-ndj868mf.js} +1 -1
- package/dist/{chunk-a51avg0f.js → chunk-pd1b2701.js} +3 -3
- package/dist/{chunk-tzvy4pms.js → chunk-qc8dad8g.js} +1 -1
- package/dist/{chunk-0h8k4jbx.js → chunk-qg2hpx3z.js} +1 -1
- package/dist/chunk-qnarcxbe.js +2 -0
- package/dist/{chunk-3e350ywf.js → chunk-qpb02n0q.js} +7 -7
- package/dist/chunk-rba5qbnv.js +2 -0
- package/dist/chunk-rdjqhj99.js +2 -0
- package/dist/{chunk-mt39bh7e.js → chunk-sphfqm8e.js} +4 -4
- package/dist/{chunk-r7m0y6wk.js → chunk-t0bn8qgj.js} +1 -1
- package/dist/{chunk-1rsfpx9h.js → chunk-t4jr8adw.js} +36 -36
- package/dist/{chunk-9qj87w6v.js → chunk-t8ezn4vq.js} +1 -1
- package/dist/{chunk-asr5yx4s.js → chunk-td2s7pz1.js} +1 -1
- package/dist/chunk-tr2qb2dw.js +2 -0
- package/dist/chunk-v8cwgw0g.js +2 -0
- package/dist/{chunk-dg3p7esg.js → chunk-vdr96n1d.js} +11 -11
- package/dist/{chunk-qzkm3ekg.js → chunk-vznwhbm8.js} +1 -1
- package/dist/{chunk-06dv852k.js → chunk-w7e28p74.js} +3 -3
- package/dist/{chunk-hbs0140f.js → chunk-xxz6bkw4.js} +1 -1
- package/dist/{chunk-7wgezbch.js → chunk-yeqszxaz.js} +4 -4
- package/dist/chunk-yg406pd5.js +2 -0
- package/dist/{chunk-meesnrhz.js → chunk-yrvctbgh.js} +2 -2
- package/dist/chunk-yyx89zxs.js +2 -0
- package/dist/chunk-z0x54ynx.js +3 -0
- package/dist/{chunk-dcqjdbkp.js → chunk-z9csfarm.js} +1 -1
- package/dist/{chunk-qe0h2e7e.js → chunk-z9j93yk8.js} +1 -1
- package/dist/chunk-zvz0k84z.js +2 -0
- package/dist/cli.js +9 -9
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/html-to-ir.js +16 -0
- package/dist/native/compiler/ir.d.ts +1 -0
- package/dist/native/prop-names.js +1 -0
- package/dist/native/runtime/native-host.d.ts +1 -1
- package/dist/native/runtime/native-host.js +3 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +8 -8
- package/package.json +5 -5
- package/dist/chunk-2v86a093.js +0 -2
- package/dist/chunk-3sr52w0c.js +0 -2
- package/dist/chunk-3w2b2t27.js +0 -2
- package/dist/chunk-3yb6j6wb.js +0 -2
- package/dist/chunk-4fhawjhe.js +0 -2
- package/dist/chunk-5jw550wk.js +0 -2
- package/dist/chunk-84sfk1ab.js +0 -2
- package/dist/chunk-a3rhve9y.js +0 -2
- package/dist/chunk-amcsa9xc.js +0 -2
- package/dist/chunk-k2hrwk7d.js +0 -3
- package/dist/chunk-kbvtnx10.js +0 -2
- package/dist/chunk-pe086860.js +0 -2
- package/dist/chunk-pksz8dq4.js +0 -2
- package/dist/chunk-s58y73kg.js +0 -2
- package/dist/chunk-sx3gnrpe.js +0 -2
- package/dist/chunk-tmhs3hev.js +0 -2
- package/dist/chunk-vdpmppe9.js +0 -2
- package/dist/chunk-vwdy0xyz.js +0 -2
- package/dist/chunk-zfjqw81c.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-
|
|
2
|
+
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-2nqt1m3m.js";import"./chunk-k7pmzreg.js";import{g}from"./chunk-t4jr8adw.js";import"./chunk-xc03cdet.js";import"./chunk-3392k9vm.js";import"./chunk-ddw8tpdd.js";import{Ft,zs,zt,Ei,ot,Ti,Hs,Ht,Ri,Vt}from"./chunk-wqe98032.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Ti("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-qnarcxbe.js"),p={},u=h(n);if(u)try{await g(u,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-qnarcxbe.js"),c={...r},n=h(e);if(n)try{await g(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
561
|
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Ht(t);at(t,r);let s=Vt(t.config,r);ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=Ri(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await Ht(t);at(t,m);let f=Vt(t.config,m);if(ct(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function t(n){if(!n||typeof n!=="object")return!1;let i=n;return typeof i.message==="string"&&(i.name==="BuildMessage"||i.name==="ResolveMessage"||("position"in i))}function o(n){if(n&&typeof n==="object"&&Array.isArray(n.errors))return n.errors;return[n]}function
|
|
2
|
+
function t(n){if(!n||typeof n!=="object")return!1;let i=n;return typeof i.message==="string"&&(i.name==="BuildMessage"||i.name==="ResolveMessage"||("position"in i))}function o(n){if(n&&typeof n==="object"&&Array.isArray(n.errors))return n.errors;return[n]}function Kn(n,i){let e=[];for(let r of o(n)){if(t(r)){let s=r.position||void 0;e.push({file:i||s?.file,line:s?.line,column:s?.column,message:r.message??"",lineText:s?.lineText});continue}e.push({file:i,message:r instanceof Error?r.message:String(r)})}return e}function Te(n,i){return Kn(n,i).map((e)=>{let r=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",s=e.lineText?`
|
|
3
3
|
${e.lineText.trim()}`:"";return r?`${r}: ${e.message}${s}`:`${e.message}${s}`}).join(`
|
|
4
|
-
`)}export{
|
|
4
|
+
`)}export{Kn,Te};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S}from"./chunk-
|
|
2
|
+
import{S}from"./chunk-2nqt1m3m.js";import{T,Sn}from"./chunk-k7pmzreg.js";import{k,J}from"./chunk-t4jr8adw.js";import{i}from"./chunk-7xv4xa3c.js";import{Ee,Zt,Qt,en}from"./chunk-sphfqm8e.js";import{ht}from"./chunk-kw4afzfh.js";import{pt,Dn,qt,ae}from"./chunk-98yf0aq9.js";import{C,Cr}from"./chunk-csx3zne1.js";import p from"path";var a=new Map;function _(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function $m(c){let n;if(c)n=p.resolve(c);else{let t=await i();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Qt()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ae(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ee(t))])],f=pt(l()),d=qt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return ae(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let x=u.map((t)=>t.file),m=[],g=new Set,y=J({loader:"ts",target:"browser",define:k()});for(let t of x)try{let e=await Bun.file(t).text(),v=p.basename(t,".ts");if(_(e,g),Zt(e))e=await en(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=Sn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=y.transformSync(e),m.push(`// Store: ${v}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ae(a,s,f,""),null;let h=m.join(`
|
|
4
4
|
|
|
5
5
|
`),w=`;(function(){
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Kc,Gc}from"./chunk-cq21rc0g.js";import{j,bs,vs,ws,zo,Ho,pr,Ie,de,G,Ss,oe,X,H,et,gr,qo,yr,je,n,d,V,hn}from"./chunk-1rsfpx9h.js";import{p,E,tt,u}from"./chunk-xc03cdet.js";import{re}from"./chunk-cbdyns7r.js";import{r}from"./chunk-hkmewh5h.js";import{f}from"./chunk-b7e07ybq.js";import{createHash as Ct}from"crypto";import ee from"fs";import Q from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import Te from"fs";function Ce(e,t,s){let i=Buffer.alloc(s),o=Te.readSync(e,i,0,s,t);return i.subarray(0,o)}function De(e){if(e.length<25)return!1;let t=(i,o)=>String.fromCharCode(...e.subarray(i,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let s=t(12,16);if(s==="VP8X")return(e[20]&16)!==0;if(s==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=Te.openSync(e,"r");let s=Ce(t,0,33);if(s.length>=3&&s[0]===255&&s[1]===216&&s[2]===255)return"none";if(s.length>=26&&s[0]===137&&s.toString("latin1",1,4)==="PNG"){let i=s[25];if(i===4||i===6)return"possible";let o=8;for(let a=0;a<64;a++){let c=Ce(t,o,8);if(c.length<8)return"unknown";let g=c.toString("latin1",4,8);if(g==="tRNS")return"possible";if(g==="IDAT"||g==="IEND")return"none";o+=12+c.readUInt32BE(0)}return"unknown"}if(s.length>=25&&s.toString("latin1",0,4)==="RIFF"&&s.toString("latin1",8,12)==="WEBP"){if(De(s))return"possible";let i=s.toString("latin1",12,16);return i==="VP8 "||i==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Te.closeSync(t)}}import Jt from"fs";import Re from"os";import{join as dt}from"path";import{fileURLToPath as gt}from"url";import{Worker as mt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function en(){Ae--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let s=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(s.protocol==="file:"&&Jt.existsSync(gt(s)))return gt(s)}catch{}try{let s=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return s&&rn(s)?s:void 0}catch{return}}function rn(e,t=process.env){let s=e.replace(/\\/g,"/");if(s.split("/").some((o)=>/@\d[^/]*@@@\d+$/.test(o)))return!1;return![t.BUN_INSTALL_CACHE_DIR,dt(t.BUN_INSTALL||dt(Re.homedir(),".bun"),"install","cache")].filter((o)=>!!o).map((o)=>`${o.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((o)=>s.startsWith(o))}var pt=!1;function pe(e){if(!pt)pt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return pe("node:worker_threads has no Worker in this runtime");let s=nn();if(!s)return pe("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((i,o)=>{let a;try{a=new mt(s)}catch(h){i(pe(`could not start ${s}: ${Le(h)}`));return}let c=!1,g=!1,l=(h)=>{if(g)return;g=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>i(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>o(v))}),a.on("error",(h)=>{l(()=>c?o(h instanceof Error?h:Error(Le(h)||"image worker crashed")):i(pe(`the worker failed before it was ready: ${Le(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):i(pe(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],he="/_stx/images",ln=`stx:${he}:alpha-1`,un=`stx:${he}:opaque-1`,fn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function dn(e,t){let s=Q.dirname(Bun.resolveSync(e,t));while(s!==Q.dirname(s)){let i=Q.join(s,"package.json");if(ee.existsSync(i)){let o=JSON.parse(ee.readFileSync(i,"utf8"));if(o.name===e)return o.version}s=Q.dirname(s)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=Q.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=fn.map((t)=>{let s;try{s=e?dn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${s??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function ye(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function gn(e){return`/${e.split(Q.sep).map(encodeURIComponent).join("/")}`}function mn(e){let t=Q.extname(e),s=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),i=Ct("sha256").update(e).digest("hex").slice(0,8);return`${s||"image"}-${i}`}function wt(e,t=`stx:${he}`){let s=(i)=>`${he}/${i.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(i){let o=Q.join(e,i);try{let a=await ee.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:s(i)}:null}catch{return null}},async write(i,o){let a=Q.join(e,i);await ee.promises.mkdir(Q.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await ee.promises.writeFile(c,o),await ee.promises.rename(c,a),{bytes:o.byteLength,path:a,url:s(i)}},url:s}}async function Rt(e,t=e){let s=await ee.promises.readdir(t,{withFileTypes:!0});s.sort((o,a)=>o.name.localeCompare(a.name));let i=[];for(let o of s){let a=Q.join(t,o.name);if(o.isDirectory()){i.push(...await Rt(e,a));continue}if(!o.isFile()||!an.has(Q.extname(o.name).toLowerCase()))continue;i.push({absolutePath:a,relativePath:Q.relative(e,a)})}return i}function $t(e,t){return e.map((s)=>({key:gn(s.relativePath),input:s.absolutePath,name:mn(s.relativePath),...pn(s.absolutePath)?{options:{storage:t}}:{}}))}function pn(e){return Me(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,o])=>o.fallback.format==="png"),s=new Set,i=8;for(let o=0;o<t.length;o+=8)await Promise.all(t.slice(o,o+8).map(async([a,c])=>{let g=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await ee.promises.readFile(g?.path??c.fallback.path)));if(yn(l.data))s.add(a)}catch{s.add(a)}}));return s}function bn(e,t){let s=[];for(let i of t){let o=e[i],a=o?.variants.filter((g)=>g.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((g)=>{let l;try{return l=ee.openSync(g.path,"r"),!De(Ce(l,0,32))}catch{return!0}finally{if(l!==void 0)ee.closeSync(l)}}))continue;if(o.variants=o.variants.filter((g)=>g.format!=="webp"),delete o.sources.webp,s.push(i),!vt.has(i))vt.add(i),console.warn(`[stx-images] ${i} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return s}async function vn(e){let t=[],s=8;for(let i=0;i<e.length;i+=8){let o=e.slice(i,i+8),a=await Promise.all(o.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function Ue(e){return Q.join(e,"undecodable.json")}function wn(e){try{let t=ee.readFileSync(Ue(e),"utf-8"),s=JSON.parse(t);return s&&typeof s==="object"?s:{}}catch{return{}}}function $n(e,t){try{ee.mkdirSync(Q.dirname(Ue(e)),{recursive:!0}),ee.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=ee.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function At(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function vo(e){let t=At(e);return t?ye().catalog.get(t):void 0}function wo(e){let t=At(e);return t?ye().transparent.has(t):!1}function xo(e){let t=(i)=>e.variants.filter((o)=>o.format===i).reduce((o,a)=>o+a.bytes,0),s=t(e.fallback.format);return["avif","webp"].map((i)=>({format:i,srcset:e.sources[i]||"",bytes:t(i)})).filter((i)=>i.srcset&&i.bytes>0&&i.bytes<s).sort((i,o)=>i.bytes-o.bytes).map(({format:i,srcset:o})=>({format:i,srcset:o}))}function eh(e){let t=vo(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:xo(t).map(({format:s,srcset:i})=>({type:`image/${s}`,srcset:i})),width:t.source.width,height:t.source.height,placeholder:wo(e)?void 0:t.placeholder?.dataUrl}}function Yr(){let e=ye();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=ye();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function th(e,t,s={}){if(!e||!ee.existsSync(e))return Yr(),{count:0,fingerprint:""};if(s.offThread){let m=await ze("delivery",{publicDir:e,outputDir:t});if(m!==ke)return Sn(m.state),m.result}let i=await Rt(e);if(i.length===0)return Yr(),{count:0,fingerprint:""};let o=wn(t),a=i.filter((m)=>{let b=o[m.relativePath];if(!b)return!0;let w=St(m.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return Yr(),{count:0,fingerprint:""};let c=wt(Q.join(t,"_stx","images"),`${ln}:${xt()}`),g={outDir:Q.join(t,"_stx","images"),storage:wt(Q.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:he,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await yt({...g,entries:$t(a,c)})}catch(m){if(l=await vn(a),l.length===a.length)throw m;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=St(C.absolutePath);if(!k)continue;o[C.relativePath]=k,w=!0}if(w)$n(t,o);if(l.length===0)return Yr(),{count:0,fingerprint:""};h=await yt({...g,entries:$t(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=ye();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:Ct("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,s,i){let o=zo(e,i);if(o!==void 0)return o;for(let a of Ho(e,t,s,i))if(await n(a))return a;return null}}var le=new kt;function R(e){return V(e)}var se="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Fe(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function ie(e,t){let s=[];for(let[i,o]of Object.entries(e.static)){if(t.has(i))continue;let a=e.staticNames?.[i]??i;if(typeof o==="boolean"){if(o)s.push(d(a));continue}if(o===se){s.push(d(a));continue}s.push(`${d(a)}="${hn(a,We(String(o)))}"`)}return s}function ae(e,t){let s=[];for(let[i,o]of Object.entries(e.serverDynamic??{})){if(t.has(i))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[i]??i;if(o===!0){s.push(d(a));continue}if(typeof o==="object")continue;s.push(`${d(a)}="${hn(a,We(String(o)))}"`)}return s}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var He={name:"StxLink",aliases:["stx-link"],render(e,t,s){let i=Rn(e),o=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",g=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(i.reactive)l.push(`:href="${R(i.value)}"`);else l.push(`href="${R(pr(i.value,"navigable"))}"`);if(o)l.push(`class="${R(o)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),g)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...ie(e,v)),l.push(...ae(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function qe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Xe=[320,640,768,1024,1280,1536,1920];function J(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let s=e.static[t];if(typeof s==="string")return s;return}function _e(e,t,s=!1){let i=e.serverDynamic[t];if(i!==void 0)return i!==!1&&i!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return s}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),s=[];for(let i of t)if(i.includes(":")){let[o,a]=i.split(":"),c=kn[o];if(c)s.push(`(max-width: ${c}px) ${a}`);else{let g=Number.parseInt(o);if(!Number.isNaN(g))s.push(`(max-width: ${g}px) ${a}`)}}else s.push(i);return s.join(", ")}function Ve(e,t,s,i){return t.map((o)=>`${xe(e,o,void 0,s,i)} ${o}w`).join(", ")}function Pn(e,t,s,i,o){return t.map((a)=>{let c=s?s*a:void 0;return`${xe(e,c,void 0,i,o)} ${a}x`}).join(", ")}function xe(e,t,s,i,o){if(!i||i==="local"||i==="static")return e;if(i==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(s)a.push(`h_${s}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(i==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(s)a.set("h",String(s));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(i==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(s)a.set("height",String(s));if(o)a.set("format",o);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,s="#e5e7eb"){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${s}"/></svg>`;return`data:image/svg+xml;base64,${btoa(i)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,s){let i=J(e,"src")||"",o=vo(i),a=J(e,"alt")||"",c=J(e,"width")||(o?String(o.source.width):void 0),g=J(e,"height")||(o?String(o.source.height):void 0),l=J(e,"sizes"),h=J(e,"srcset"),v=J(e,"densities"),y=J(e,"format"),S=wo(i)||qe(i)?.transparent===!0,x=J(e,"placeholder")||(o&&!S?"thumbhash":void 0),m=J(e,"placeholderColor")||"#e5e7eb",b=J(e,"provider"),w=J(e,"class")||J(e,"className")||"",C=J(e,"style")||"",k=J(e,"objectFit")||J(e,"fit"),A=J(e,"objectPosition")||J(e,"position"),I=J(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),q=J(e,"loading"),N=J(e,"decoding")||"async",_=!!o||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=g?Number.parseInt(g):void 0,z=h||"",K="";if(o)z=o.sources[o.fallback.format]||"",K=l?Ze(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(i,Xe,b,y),K=Ze(l);else if(!z&&v){let P=v.split(/\s+/).map((F)=>Number.parseFloat(F.replace("x","")));z=Pn(i,P,O,b,y)}else if(l)K=Ze(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:m}:qe(i);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let F=In(O||16,B||9,m);D.push(`background-image:url(${F})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let we=o?.fallback.url||xe(i,O,B,b,y),Y=[];if(Y.push(`src="${R(pr(we,"fetched"))}"`),Y.push(`alt="${R(a)}"`),c)Y.push(`width="${R(c)}"`);if(g)Y.push(`height="${R(g)}"`);let ne=q||(L||M?"eager":U?"lazy":"");if(ne)Y.push(`loading="${R(ne)}"`);if(L)Y.push('fetchpriority="high"');if(Y.push(`decoding="${R(N)}"`),w)Y.push(`class="${R(w)}"`);if(D.length>0)Y.push(`style="${R(D.join(";"))}"`);if(z)Y.push(`srcset="${R(pr(z,"fetched"))}"`);if(K)Y.push(`sizes="${R(K)}"`);let $e=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",F=_n(W)+(P?`;${P}`:"");Y.push(`onload="${R(F)}"`),$e.add("onload")}Y.push(...ie(e,$e)),Y.push(...ae(e,$e));let T=`<img ${Y.join(" ")} />`,Z="";if(M){let F=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(we)}"${F?` type="${F}"`:""}${z?` imagesrcset="${R(z)}"`:""}${K?` imagesizes="${R(K)}"`:""} />
|
|
3
|
-
`}if(_){let P=[];if(o)for(let F of xo(o))P.push(`<source type="image/${F.format}" srcset="${R(F.srcset)}"${
|
|
2
|
+
import{Gc,Kc}from"./chunk-2nqt1m3m.js";import{j,bs,vs,ws,zo,Ho,pr,Ie,de,K,Ss,oe,X,H,et,gr,qo,yr,je,n,d,V,hn}from"./chunk-t4jr8adw.js";import{p,E,tt,u}from"./chunk-xc03cdet.js";import{re}from"./chunk-cbdyns7r.js";import{r}from"./chunk-hkmewh5h.js";import{f}from"./chunk-b7e07ybq.js";import{createHash as Ct}from"crypto";import ee from"fs";import Q from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import Te from"fs";function Ce(e,t,s){let i=Buffer.alloc(s),o=Te.readSync(e,i,0,s,t);return i.subarray(0,o)}function De(e){if(e.length<25)return!1;let t=(i,o)=>String.fromCharCode(...e.subarray(i,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let s=t(12,16);if(s==="VP8X")return(e[20]&16)!==0;if(s==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=Te.openSync(e,"r");let s=Ce(t,0,33);if(s.length>=3&&s[0]===255&&s[1]===216&&s[2]===255)return"none";if(s.length>=26&&s[0]===137&&s.toString("latin1",1,4)==="PNG"){let i=s[25];if(i===4||i===6)return"possible";let o=8;for(let a=0;a<64;a++){let c=Ce(t,o,8);if(c.length<8)return"unknown";let g=c.toString("latin1",4,8);if(g==="tRNS")return"possible";if(g==="IDAT"||g==="IEND")return"none";o+=12+c.readUInt32BE(0)}return"unknown"}if(s.length>=25&&s.toString("latin1",0,4)==="RIFF"&&s.toString("latin1",8,12)==="WEBP"){if(De(s))return"possible";let i=s.toString("latin1",12,16);return i==="VP8 "||i==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Te.closeSync(t)}}import Jt from"fs";import Re from"os";import{join as dt}from"path";import{fileURLToPath as gt}from"url";import{Worker as mt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function en(){Ae--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let s=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(s.protocol==="file:"&&Jt.existsSync(gt(s)))return gt(s)}catch{}try{let s=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return s&&rn(s)?s:void 0}catch{return}}function rn(e,t=process.env){let s=e.replace(/\\/g,"/");if(s.split("/").some((o)=>/@\d[^/]*@@@\d+$/.test(o)))return!1;return![t.BUN_INSTALL_CACHE_DIR,dt(t.BUN_INSTALL||dt(Re.homedir(),".bun"),"install","cache")].filter((o)=>!!o).map((o)=>`${o.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((o)=>s.startsWith(o))}var pt=!1;function pe(e){if(!pt)pt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return pe("node:worker_threads has no Worker in this runtime");let s=nn();if(!s)return pe("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((i,o)=>{let a;try{a=new mt(s)}catch(h){i(pe(`could not start ${s}: ${Le(h)}`));return}let c=!1,g=!1,l=(h)=>{if(g)return;g=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>i(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>o(v))}),a.on("error",(h)=>{l(()=>c?o(h instanceof Error?h:Error(Le(h)||"image worker crashed")):i(pe(`the worker failed before it was ready: ${Le(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):i(pe(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],he="/_stx/images",ln=`stx:${he}:alpha-1`,un=`stx:${he}:opaque-1`,fn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function dn(e,t){let s=Q.dirname(Bun.resolveSync(e,t));while(s!==Q.dirname(s)){let i=Q.join(s,"package.json");if(ee.existsSync(i)){let o=JSON.parse(ee.readFileSync(i,"utf8"));if(o.name===e)return o.version}s=Q.dirname(s)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=Q.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=fn.map((t)=>{let s;try{s=e?dn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${s??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function ye(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function gn(e){return`/${e.split(Q.sep).map(encodeURIComponent).join("/")}`}function mn(e){let t=Q.extname(e),s=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),i=Ct("sha256").update(e).digest("hex").slice(0,8);return`${s||"image"}-${i}`}function wt(e,t=`stx:${he}`){let s=(i)=>`${he}/${i.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(i){let o=Q.join(e,i);try{let a=await ee.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:s(i)}:null}catch{return null}},async write(i,o){let a=Q.join(e,i);await ee.promises.mkdir(Q.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await ee.promises.writeFile(c,o),await ee.promises.rename(c,a),{bytes:o.byteLength,path:a,url:s(i)}},url:s}}async function Rt(e,t=e){let s=await ee.promises.readdir(t,{withFileTypes:!0});s.sort((o,a)=>o.name.localeCompare(a.name));let i=[];for(let o of s){let a=Q.join(t,o.name);if(o.isDirectory()){i.push(...await Rt(e,a));continue}if(!o.isFile()||!an.has(Q.extname(o.name).toLowerCase()))continue;i.push({absolutePath:a,relativePath:Q.relative(e,a)})}return i}function $t(e,t){return e.map((s)=>({key:gn(s.relativePath),input:s.absolutePath,name:mn(s.relativePath),...pn(s.absolutePath)?{options:{storage:t}}:{}}))}function pn(e){return Me(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,o])=>o.fallback.format==="png"),s=new Set,i=8;for(let o=0;o<t.length;o+=8)await Promise.all(t.slice(o,o+8).map(async([a,c])=>{let g=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await ee.promises.readFile(g?.path??c.fallback.path)));if(yn(l.data))s.add(a)}catch{s.add(a)}}));return s}function bn(e,t){let s=[];for(let i of t){let o=e[i],a=o?.variants.filter((g)=>g.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((g)=>{let l;try{return l=ee.openSync(g.path,"r"),!De(Ce(l,0,32))}catch{return!0}finally{if(l!==void 0)ee.closeSync(l)}}))continue;if(o.variants=o.variants.filter((g)=>g.format!=="webp"),delete o.sources.webp,s.push(i),!vt.has(i))vt.add(i),console.warn(`[stx-images] ${i} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return s}async function vn(e){let t=[],s=8;for(let i=0;i<e.length;i+=8){let o=e.slice(i,i+8),a=await Promise.all(o.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function Ue(e){return Q.join(e,"undecodable.json")}function wn(e){try{let t=ee.readFileSync(Ue(e),"utf-8"),s=JSON.parse(t);return s&&typeof s==="object"?s:{}}catch{return{}}}function $n(e,t){try{ee.mkdirSync(Q.dirname(Ue(e)),{recursive:!0}),ee.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=ee.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function At(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function vo(e){let t=At(e);return t?ye().catalog.get(t):void 0}function wo(e){let t=At(e);return t?ye().transparent.has(t):!1}function xo(e){let t=(i)=>e.variants.filter((o)=>o.format===i).reduce((o,a)=>o+a.bytes,0),s=t(e.fallback.format);return["avif","webp"].map((i)=>({format:i,srcset:e.sources[i]||"",bytes:t(i)})).filter((i)=>i.srcset&&i.bytes>0&&i.bytes<s).sort((i,o)=>i.bytes-o.bytes).map(({format:i,srcset:o})=>({format:i,srcset:o}))}function eh(e){let t=vo(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:xo(t).map(({format:s,srcset:i})=>({type:`image/${s}`,srcset:i})),width:t.source.width,height:t.source.height,placeholder:wo(e)?void 0:t.placeholder?.dataUrl}}function Yr(){let e=ye();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=ye();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function th(e,t,s={}){if(!e||!ee.existsSync(e))return Yr(),{count:0,fingerprint:""};if(s.offThread){let m=await ze("delivery",{publicDir:e,outputDir:t});if(m!==ke)return Sn(m.state),m.result}let i=await Rt(e);if(i.length===0)return Yr(),{count:0,fingerprint:""};let o=wn(t),a=i.filter((m)=>{let b=o[m.relativePath];if(!b)return!0;let w=St(m.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return Yr(),{count:0,fingerprint:""};let c=wt(Q.join(t,"_stx","images"),`${ln}:${xt()}`),g={outDir:Q.join(t,"_stx","images"),storage:wt(Q.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:he,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await yt({...g,entries:$t(a,c)})}catch(m){if(l=await vn(a),l.length===a.length)throw m;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=St(C.absolutePath);if(!k)continue;o[C.relativePath]=k,w=!0}if(w)$n(t,o);if(l.length===0)return Yr(),{count:0,fingerprint:""};h=await yt({...g,entries:$t(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=ye();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:Ct("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,s,i){let o=zo(e,i);if(o!==void 0)return o;for(let a of Ho(e,t,s,i))if(await n(a))return a;return null}}var le=new kt;function R(e){return V(e)}var se="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Fe(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function ie(e,t){let s=[];for(let[i,o]of Object.entries(e.static)){if(t.has(i))continue;let a=e.staticNames?.[i]??i;if(typeof o==="boolean"){if(o)s.push(d(a));continue}if(o===se){s.push(d(a));continue}s.push(`${d(a)}="${hn(a,We(String(o)))}"`)}return s}function ae(e,t){let s=[];for(let[i,o]of Object.entries(e.serverDynamic??{})){if(t.has(i))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[i]??i;if(o===!0){s.push(d(a));continue}if(typeof o==="object")continue;s.push(`${d(a)}="${hn(a,We(String(o)))}"`)}return s}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var He={name:"StxLink",aliases:["stx-link"],render(e,t,s){let i=Rn(e),o=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",g=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(i.reactive)l.push(`:href="${R(i.value)}"`);else l.push(`href="${R(pr(i.value,"navigable"))}"`);if(o)l.push(`class="${R(o)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),g)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...ie(e,v)),l.push(...ae(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function qe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Xe=[320,640,768,1024,1280,1536,1920];function J(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let s=e.static[t];if(typeof s==="string")return s;return}function _e(e,t,s=!1){let i=e.serverDynamic[t];if(i!==void 0)return i!==!1&&i!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return s}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),s=[];for(let i of t)if(i.includes(":")){let[o,a]=i.split(":"),c=kn[o];if(c)s.push(`(max-width: ${c}px) ${a}`);else{let g=Number.parseInt(o);if(!Number.isNaN(g))s.push(`(max-width: ${g}px) ${a}`)}}else s.push(i);return s.join(", ")}function Ve(e,t,s,i){return t.map((o)=>`${xe(e,o,void 0,s,i)} ${o}w`).join(", ")}function Pn(e,t,s,i,o){return t.map((a)=>{let c=s?s*a:void 0;return`${xe(e,c,void 0,i,o)} ${a}x`}).join(", ")}function xe(e,t,s,i,o){if(!i||i==="local"||i==="static")return e;if(i==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(s)a.push(`h_${s}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(i==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(s)a.set("h",String(s));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(i==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(s)a.set("height",String(s));if(o)a.set("format",o);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,s="#e5e7eb"){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${s}"/></svg>`;return`data:image/svg+xml;base64,${btoa(i)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,s){let i=J(e,"src")||"",o=vo(i),a=J(e,"alt")||"",c=J(e,"width")||(o?String(o.source.width):void 0),g=J(e,"height")||(o?String(o.source.height):void 0),l=J(e,"sizes"),h=J(e,"srcset"),v=J(e,"densities"),y=J(e,"format"),S=wo(i)||qe(i)?.transparent===!0,x=J(e,"placeholder")||(o&&!S?"thumbhash":void 0),m=J(e,"placeholderColor")||"#e5e7eb",b=J(e,"provider"),w=J(e,"class")||J(e,"className")||"",C=J(e,"style")||"",k=J(e,"objectFit")||J(e,"fit"),A=J(e,"objectPosition")||J(e,"position"),I=J(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),q=J(e,"loading"),N=J(e,"decoding")||"async",_=!!o||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=g?Number.parseInt(g):void 0,z=h||"",G="";if(o)z=o.sources[o.fallback.format]||"",G=l?Ze(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(i,Xe,b,y),G=Ze(l);else if(!z&&v){let P=v.split(/\s+/).map((F)=>Number.parseFloat(F.replace("x","")));z=Pn(i,P,O,b,y)}else if(l)G=Ze(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:m}:qe(i);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let F=In(O||16,B||9,m);D.push(`background-image:url(${F})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let we=o?.fallback.url||xe(i,O,B,b,y),Y=[];if(Y.push(`src="${R(pr(we,"fetched"))}"`),Y.push(`alt="${R(a)}"`),c)Y.push(`width="${R(c)}"`);if(g)Y.push(`height="${R(g)}"`);let ne=q||(L||M?"eager":U?"lazy":"");if(ne)Y.push(`loading="${R(ne)}"`);if(L)Y.push('fetchpriority="high"');if(Y.push(`decoding="${R(N)}"`),w)Y.push(`class="${R(w)}"`);if(D.length>0)Y.push(`style="${R(D.join(";"))}"`);if(z)Y.push(`srcset="${R(pr(z,"fetched"))}"`);if(G)Y.push(`sizes="${R(G)}"`);let $e=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",F=_n(W)+(P?`;${P}`:"");Y.push(`onload="${R(F)}"`),$e.add("onload")}Y.push(...ie(e,$e)),Y.push(...ae(e,$e));let T=`<img ${Y.join(" ")} />`,Z="";if(M){let F=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(we)}"${F?` type="${F}"`:""}${z?` imagesrcset="${R(z)}"`:""}${G?` imagesizes="${R(G)}"`:""} />
|
|
3
|
+
`}if(_){let P=[];if(o)for(let F of xo(o))P.push(`<source type="image/${F.format}" srcset="${R(F.srcset)}"${G?` sizes="${R(G)}"`:""} />`);if(!o&&(y==="avif"||y==="auto")){let F=xe(i,O,B,b,"avif"),te=z?Ve(i,Xe,b,"avif"):`${F}`;P.push(`<source type="image/avif" srcset="${R(te)}"${G?` sizes="${R(G)}"`:""} />`)}if(!o&&(y==="webp"||y==="auto")){let F=xe(i,O,B,b,"webp"),te=z?Ve(i,Xe,b,"webp"):`${F}`;P.push(`<source type="image/webp" srcset="${R(te)}"${G?` sizes="${R(G)}"`:""} />`)}return`${Z}<picture>
|
|
4
4
|
${P.join(`
|
|
5
5
|
`)}
|
|
6
6
|
${T}
|
|
@@ -38,5 +38,5 @@ ${T}
|
|
|
38
38
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
39
39
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
40
40
|
</style>`}};import{existsSync as On,readFileSync as Bn}from"fs";var Oe=new Map,Ot=new Set;function Tn(e){if(Ot.has(e))return;Ot.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Dn(e){let t=process.cwd();for(let s of[`${t}/node_modules/@iconify-json/${e}/icons.json`,`${t}/pantry/@iconify-json/${e}/icons.json`,`${t}/node_modules/@iconify/json/json/${e}.json`,`${t}/pantry/@iconify/json/json/${e}.json`])if(On(s))return s;for(let s of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return f.resolve(s)}catch{}return null}function jn(e){if(Oe.has(e))return Oe.get(e);let t=Dn(e);if(!t)return Tn(e),null;try{let s=JSON.parse(Bn(t,"utf8"));return Oe.set(e,s.icons),s.icons}catch{return null}}function ge(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);if(e.static[t]!==void 0)return String(e.static[t]);if(e.clientReactive[t]!==void 0)return e.clientReactive[t];return}var st={name:"Icon",aliases:["icon","stx-icon"],render(e,t,s){let i=ge(e,"name")??ge(e,"icon");if(!i)return"<!-- Icon: missing name/icon prop -->";let o="lucide",a=i;if(i.includes(":")){let k=i.split(":");o=k[0],a=k[1]}let c=R(ge(e,"size")||"24"),g=R(ge(e,"color")||"currentColor"),l=R(ge(e,"class")||""),h=R(ge(e,"style")||""),v=Oe.get(o)??jn(o);if(!v)return`<!-- Icon: collection "${o}" not loaded -->`;let y=v[a];if(!y)return`<!-- Icon: "${a}" not found in ${o} -->`;let S=y.width||24,x=y.height||24,m=`0 0 ${S} ${x}`,b=y.body;if(g!=="currentColor")b=b.replace(/currentColor/g,g);let w=l?` class="${l}"`:"",C=h?` style="${h}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${c}" viewBox="${m}" fill="none"${w}${C}>${b}</svg>`}};function Bt(e,...t){for(let s of t){if(e.serverDynamic[s]!==void 0)return String(e.serverDynamic[s]);let i=e.static[s];if(typeof i==="string")return i}return}function Tt(e,t){let s=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),i=e.match(s);if(!i)return{region:null,rest:e};return{region:i[2],rest:e.replace(i[0],"")}}var it={name:"Suspense",aliases:["suspense"],render(e,t,s){let i=Tt(t,"fallback"),o=i.rest,a=Tt(o,"error"),c=a.rest,g=i.region??Bt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',l=a.region??Bt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${g}</div><div data-stx-suspense-error hidden>${l}</div><div data-stx-suspense-content hidden>${c}</div></div>`}};function Be(e,...t){for(let s of t){if(e.serverDynamic[s]!==void 0)return String(e.serverDynamic[s]);let i=e.static[s];if(typeof i==="string")return i}return}var ot={name:"TransitionGroup",aliases:["transition-group"],render(e,t,s){let i=(Be(e,"name")||"v").replace(/["'<>]/g,""),o=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",a=Be(e,"class"),c=Be(e,"id"),g=[`data-stx-transition-group="${i}"`,a?`class="${a}"`:"",c?`id="${c}"`:""].filter(Boolean).join(" ");return`<${o} ${g}>${t}</${o}>`}};function Dt(e=le){e.registerBuiltin(He),e.registerBuiltin(Ge),e.registerBuiltin(Ke),e.registerBuiltin(Ye),e.registerBuiltin(Qe),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot)}var jt=new Map;function Mn(e){let t=jt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),jt.set(e.source,t);return t}var Mt=new WeakMap;function Lt(e){let t=Mt.get(e);if(!t)t=new Set([...e].map((i)=>i.toLowerCase())),Mt.set(e,t);let s=t;return(i)=>!/[a-z]/.test(i)&&s.has(i.toLowerCase())}function Ln(e,t){let s="";for(let i=t;i<e.length;i++){let o=e[i];if(s){if(o==="\\")i++;else if(o===s)s=""}else if(o==='"'||o==="'")s=o;else if(o===">")return i}return e.length}function zt(e,t,s){let i=[],o=0,a=typeof s==="function"?s:s?(c)=>s.has(c.toLowerCase()):void 0;while(o<e.length){let c=e.indexOf("<",o);if(c===-1)break;let g=Mn(t);g.lastIndex=c+1;let l=g.exec(e);if(!l){o=c+1;continue}let h=l[1];if(a&&a(h)){let w=c+1+h.length;while(w<e.length&&e[w]!==">")w++;o=w+1;continue}let v=c+1+h.length,y=null,S=v,x=-1,m=!1;while(v<e.length){let w=e[v];if(y){if(w==="\\"&&v+1<e.length){v+=2;continue}if(w===y)y=null;v++;continue}if(w==='"'||w==="'"){y=w,v++;continue}if(w==="/"&&v+1<e.length&&e[v+1]===">"){x=v+2,m=!0;break}if(w===">"){x=v+1;break}v++}if(x===-1){o=c+1;continue}let b=e.slice(S,m?x-2:x-1).trim();if(m)i.push({fullMatch:e.slice(c,x),tagName:h,attributes:b,content:"",startIndex:c,endIndex:x,isSelfClosing:!0}),o=x;else{let w=`<${h}`,C=`</${h}>`,k=1,A=x,I=-1;while(k>0&&A<e.length){let L=e.indexOf(w,A),q=e.indexOf(C,A);if(q===-1)break;if(L!==-1&&L<q){let N=e[L+w.length];if(N===" "||N===">"||N==="/"||N===`
|
|
41
|
-
`||N==="\t"){let _=Ln(e,L+w.length);if(e[_-1]!=="/")k++;A=_+1}else A=L+w.length}else{if(k--,k===0){I=q;break}A=q+C.length}}if(I===-1){o=x;continue}let U=e.slice(x,I),M=I+C.length;i.push({fullMatch:e.slice(c,M),tagName:h,attributes:b,content:U,startIndex:c,endIndex:M,isSelfClosing:!1}),o=M}}return i}function at(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,t){try{let s=Buffer.from(e,"base64").toString("utf8");return JSON.parse(s)}catch{}try{let s=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(s)}catch(s){if(t?.debug)console.error("Error decoding __stx_ prop:",s);return e}}function ct(e,t){let s=0,i="",o=t;while(o<e.length){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'"||a==="`")i=a;else if(a==="{")s++;else if(a==="}"){if(s--,s===0)return e.slice(t,o+1)}o++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(ct(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return lt(e).map((t)=>[t.start,t.end])}function lt(e){let t=[],s=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,i;while((i=s.exec(e))!==null){let o=i[2]||"",a=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(o);if(!a)continue;let c=X(a[1]??a[2]??a[3]??""),g=i.index,l=g+i[0].length,h=i[1].toLowerCase();if(i[0].endsWith("/>")||Un.has(h)){t.push({start:g,end:l,names:c});continue}let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");y.lastIndex=l;let S=1,x=l,m;while((m=y.exec(e))!==null)if(m[0].startsWith("</")){if(S--,S===0){x=m.index+m[0].length;break}}else if(!m[0].endsWith("/>"))S++;t.push({start:g,end:x,names:c})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function Ha(e,t){if(!/:[\w-]+=/.test(e))return e;let s=e,i=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,o=[],a;while((a=i.exec(e))!==null)o.push([a.index,a.index+a[0].length]);o.push(...Wn(e));let c=new Set([...et(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function g(S){return o.some(([x,m])=>S>=x&&S<m)}let l=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,h=[],v=new Map,y=256;while((a=l.exec(s))!==null){if(g(a.index))continue;let S=a[0],x=a[2];if(!x||!x.includes(":"))continue;let m=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,w,C=x,k=!1;while((w=b.exec(x))!==null){if(Ss(x,w.index,!0)?.kind==="attribute")continue;let A=w[1],I=w[2];if(Kc(A))continue;if(H(I,c))continue;if(I.includes("()")&&!I.includes(".get(")||I.includes("$store")||I.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=I.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let q=JSON.stringify([U,I]),N=v.get(q);if(!N){if(N=Function(...U,`return (${I})`),v.size>=y)v.clear();v.set(q,N)}let _=N(...M);if(A==="class"){let O=V(Ft(_));if(O){let B=C.match(/\sclass="([^"]*)"/);if(B)C=C.replace(B[0],()=>` class="${B[1]} ${O}"`);else C=C.replace(w[0],()=>` class="${O}"`)}else C=C.replace(w[0],"");k=!0;continue}if(zn.has(A)){if(_)C=C.replace(w[0],` ${A}`);else C=C.replace(w[0],"");k=!0;continue}if(_===null||_===void 0||_===!1)C=C.replace(w[0],"");else{let O=m&&typeof _==="object"?JSON.stringify(_):String(_),B=hn(A,O);C=C.replace(w[0],()=>` ${A}="${B}"`)}k=!0}catch(U){if(U instanceof oe)throw U;continue}}if(k){let A=a[3]?" /":"",U=`<${a[1]}${C}${A}>`;h.push({start:a.index,end:a.index+S.length,replacement:U})}}if(h.length>0){let S=Array(h.length*2+1),x=0;for(let m=0;m<h.length;m++){let{start:b,end:w,replacement:C}=h[m];S[m*2]=s.slice(x,b),S[m*2+1]=C,x=w}S[h.length*2]=s.slice(x),s=S.join("")}return s}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,s,i=!1,o=new Set){let a={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},c=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),g=(y)=>{if(c.size===0)return!1;let S=r(y),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&c.has(x))return!0;for(let m of c){let b=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(S))return!0}return!1},l=new Set(Gc),h=(y)=>{if(!y.includes("-")||y.startsWith("@")||y.startsWith(":")||y.startsWith("x-")||y.startsWith("__"))return y;if(y.startsWith("aria-")||y.startsWith("data-"))return y;return y.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},v=(y,S)=>{let x=h(y);if(a.static[x]=S,x!==y)a.staticNames[x]=y};for(let[y,S]of Object.entries(e)){let x=y.startsWith("x-")&&!l.has(y)&&!y.startsWith("x-bind:")&&!y.startsWith("x-on:")?`:${y.slice(2)}`:y;if(x.startsWith("@")){a.events[x]=S;continue}if(x.startsWith("__stx_")){let m=h(x.slice(6));a.serverDynamic[m]=Ut(S,s);continue}if(x.startsWith(":")){let m=h(x.slice(1)),b=S===se?m:S;if(m==="if"||m==="for"||m==="show"){a.clientReactive[m]=b;continue}if(i){a.clientReactive[m]=b;continue}if(H(b,o)){a.clientReactive[m]=b;continue}if(g(b)){a.clientReactive[m]=b;continue}try{if(!p(b)){if(s.debug)console.error(`Unsafe expression in :${m} binding: ${b}`);a.clientReactive[m]=b;continue}let w=Object.keys(t),C=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(tt(b).some((M)=>!C.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){a.clientReactive[m]=b;continue}let U=u(b,w)(...Object.values(t));if(a.serverDynamic[m]=U,m!==x.slice(1)&&a.serverDynamicNames)a.serverDynamicNames[m]=x.slice(1)}catch{a.clientReactive[m]=b}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let m=Hn(S,o);if(m!==null){a.clientReactive[h(x)]=m;continue}let b=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(p(w)){let k=u(w,Object.keys(t))(...Object.values(t));v(x,k!=null?String(k):"")}else{if(s.debug)console.error(`Unsafe expression in ${x}: ${w}`);v(x,S)}}catch(w){if(s.debug)console.error(`Error evaluating expression for ${x}:`,w);v(x,S)}else{let w=S,C=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=C.exec(S))!==null)try{let A=k[1];if(!p(A)){if(s.debug)console.error(`Unsafe expression in ${x}: ${A}`);continue}let U=u(A,Object.keys(t))(...Object.values(t));w=w.replace(k[0],String(U??""))}catch(A){if(s.debug)console.error(`Error evaluating expression in ${x}:`,A)}v(x,w)}continue}v(x,S===se?"true":at(S))}return a}function Hn(e,t){if(t.size===0)return null;let s=/\{\{\s*([\s\S]+?)\s*\}\}/g,i=[...e.matchAll(s)];if(!i.some((g)=>H(g[1],t)))return null;let o=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(o&&i.length===1)return o[1];let a="",c=0;for(let g of i)a+=e.slice(c,g.index).replace(/[`\\$]/g,(l)=>`\\${l}`),a+=`\${${g[1]}}`,c=g.index+g[0].length;return a+=e.slice(c).replace(/[`\\$]/g,(g)=>`\\${g}`),`\`${a}\``}var qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,s){if(!e.includes("@"))return e;if(!qn.some(([o,a])=>o.test(e)&&e.includes(a)))return e;try{return re(e,t,s)}catch{return e}}function me(e){let t={},s=0,i=e.length;while(s<i){while(s<i&&/\s/.test(e[s]))s++;if(s>=i)break;let o="";while(s<i&&!/[\s=]/.test(e[s]))o+=e[s],s++;if(!o)break;while(s<i&&/\s/.test(e[s]))s++;if(s<i&&e[s]==="="){s++;while(s<i&&/\s/.test(e[s]))s++;let a="";if(s<i&&(e[s]==='"'||e[s]==="'")){let c=e[s];s++;while(s<i){let g=e[s];if(g==="\\"&&s+1<i){s++,a+=e[s],s++;continue}if(g===c){s++;break}a+=g,s++}}else if(e[s]==="{"){a=ct(e,s),s+=a.length;let c=Wt(a);if(c!==null){t[`:${o}`]=c;continue}}else while(s<i&&!/\s/.test(e[s]))a+=e[s],s++;t[o]=a}else t[o]=se}return t}function Zt(e){return Object.entries(e).map(([t,s])=>s===se?t:`${t}="${Zn(s)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Vn(e){let t=new Set,s=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,i;while((i=s.exec(e))!==null){let o=i[1];if(le.isBuiltin(o))t.add(o)}return[...t].sort()}async function pf(e,t,s,i,o){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let a=t.__importedComponents,c=qt.dirname(s),g=[],l=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(l)){let[S,x,m]=y,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=m,C,k=[];while((C=b.exec(m))!==null){let[A,I,U,M]=C,L=null,q=null;if(M.startsWith(".")||M.startsWith("/")){let O=qt.resolve(c,M);if(O.endsWith(".stx"))q=O;else{let B=`${O}.stx`;try{if(Ht.statSync(B).isFile())q=B}catch{try{if(Ht.statSync(O).isDirectory())L=O}catch{}}}}else L=vs(M,c);if(!L&&!q)continue;let N=!1,_=(O,B)=>{a.set(O,B),a.set(O.toLowerCase(),B);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.set(z,B),o.add(B)};if(U&&q)_(U,q),N=!0;else if(I){let O=I.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let K=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(K)return{source:K[1],local:K[2]};return{source:z,local:z}}),B=L?bs(L):null;for(let{source:z,local:K}of O){let D=null;if(q)D=q;else if(B)D=B.get(z)??B.get(z.toLowerCase())??B.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)_(K,D),N=!0}}if(N)k.push({start:C.index,end:C.index+A.length})}if(k.length===0)continue;for(let A=k.length-1;A>=0;A--)w=w.slice(0,k[A].start)+w.slice(k[A].end);g.push({start:y.index,end:y.index+S.length,value:`<script${x}>${w}</script>`})}if(g.length===0)return e;let h=[],v=0;for(let y of g)h.push(e.slice(v,y.start),y.value),v=y.end;return h.push(e.slice(v)),h.join("")}async function Gn(e,t,s,i,o){let a=e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,g=/@import\s*\(\s*([^)]+)\s*\)/g,l;while((l=g.exec(a))!==null){let[h,v]=l,y=v.split(",").map((S)=>S.trim().replace(/^['"]|['"]$/g,"")).filter((S)=>S.length>0);for(let S of y){let x=S.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((A)=>A.charAt(0).toUpperCase()+A.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),C=null,k=ws(S,s,i);for(let A of k)try{if(await Bun.file(A).exists()){C=A;break}}catch{}if(C){c.set(w,C),c.set(b,C),c.set(b.toLowerCase(),C);let A=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(c.set(A,C),o.add(C),i.debug)console.log(`Imported component: ${w} -> ${C}`)}else if(i.debug)console.warn(`Could not resolve imported component: ${S}`)}a=a.replace(h,""),g.lastIndex=0}return a}async function Kn(e,t,s,i,o){let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=/@component\s*\(/g,h;while((h=l.exec(a))!==null){let v=h.index,y=v+h[0].length-1,S=1,x=y+1;while(x<a.length&&S>0){if(a[x]==="(")S++;else if(a[x]===")"){if(S--,S===0)break}x++}if(S!==0)break;let m=a.substring(y+1,x),b=x+1,w=m.match(/^\s*['"]([^'"]+)['"]/);if(!w){l.lastIndex=0;continue}let C=w[1],k,A=m.slice(w[0].length),I=A.match(/^\s*,\s*/);if(I)k=A.slice(I[0].length).trim();let U={};if(k)try{U=E(k,t)}catch(O){let B=O instanceof Error?O.message:String(O);a=a.replace(a.substring(v,b),`[Error parsing component props: ${B}]`);continue}let M="",L=b,N=a.substring(b).match(/^([\s\S]*?)@endcomponent/);if(N)M=N[1].trim(),L=b+N[0].length;let _=await je(C,U,M,c,t,s,i,g,o);a=a.substring(0,v)+_+a.substring(L),l.lastIndex=0}return a}async function Jn(e,t,s,i,o){if(!e)return e;let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=er(a);if(l.size>0){let b=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...b,...l])]}let h=G(a);a=h.output;let v=et(t);return a=await m(a,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),a=await m(a,/[A-Z][a-zA-Z0-9]*/,!0,Lt(gr)),a=await m(a,/[a-z][a-z0-9]*/,!1,gr),a=h.restore(a),a;async function m(b,w,C,k){if(!b)return b;let A=b,I=zt(A,w,k),U=lt(A),M=new Map;for(let N=I.length-1;N>=0;N--){let _=I[N],O=C?j(_.tagName):_.tagName,B=me(Xn(_.attributes,t,s)),z=U.filter(({start:Z,end:P})=>_.startIndex>=Z&&_.startIndex<P),K=z.length>0,D=new Set(v);for(let Z of z)for(let P of Z.names)D.add(P);let W=Fn(B,t,i,K,D);if(typeof W.clientReactive.for==="string")for(let Z of X(W.clientReactive.for))D.add(Z);let ce=le.getBuiltin(_.tagName),we=ce?await yr(_.tagName,c,t,s,i):!1;if(ce&&!we){let Z={context:t,filePath:s,options:i,dependencies:o},P=ce.render(W,_.content,Z);if(Object.keys(W.events).length>0){let F=Zt(W.events);P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${F}`)}if(Object.keys(W.clientReactive).length>0)P=Vt(P,W.clientReactive);M.set(N,P);continue}if(!C&&_.tagName.includes("-")&&!await yr(O,c,t,s,i))continue;let Y={};for(let[Z,P]of Object.entries(W.static))Y[Z]=P;for(let[Z,P]of Object.entries(W.serverDynamic))Y[Z]=P;let ne={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},T=await je(O,Y,h.restore(_.content),c,t,s,i,g,o,[...D],ne,_.tagName);if(T=Yn(T,W,ne.declaredProps,ne.consumedProps,i._nativeHostAttrs),i._nativeHostAttrs){let Z=ne.reactiveProps.filter((te)=>!ne.consumedProps.has(te)&&!["if","for","show","key","ref"].includes(te)).map(j),P=ut(T,!0);if(Z.length&&P){if(!Object.hasOwn(me(T.slice(P.insertPos,P.tagEnd)),"data-stx-native-host-root"))T=T.slice(0,P.insertPos)+' data-stx-native-host-root="true"'+T.slice(P.insertPos);let te=ve(T);T=T.slice(0,te.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+T.slice(te.insertPos)}let F=ut(T,!0);if(F){let te=me(T.slice(F.insertPos,F.tagEnd)),Se=ve(T),Kt=me(T.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(te,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))T=T.slice(0,Se.insertPos)+" data-stx-native-host-owner"+T.slice(Se.insertPos)}}if(Object.keys(W.events).length>0){let Z=ve(T);if(Z){let P=Zt(W.events),F=Object.keys(W.events).map((te)=>te.replace(/^@/,"").split(".")[0]).join(" ");T=T.substring(0,Z.insertPos)+` data-stx-parent-events="${F}" ${P}`+T.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)T=Vt(T,W.clientReactive);M.set(N,T)}if(M.size===0)return A;let L="",q=0;for(let N=0;N<I.length;N++){let _=M.get(N);if(_===void 0)continue;L+=A.slice(q,I[N].startIndex),L+=_,q=I[N].endIndex}return L+=A.slice(q),L}}function Vt(e,t){let s=new Set(["if","for"]),i=new Set(["show"]),o=Object.entries(t).filter(([v])=>!s.has(v)),a=o.filter(([v])=>!i.has(v)).map(([v])=>j(v)).join(" "),c=e,g=o.length>0?ve(c):null;if(g){let v=o.map(([S,x])=>`:${j(S)}="${x.replace(/"/g,""")}"`).join(" "),y=a?` data-stx-parent-bindings="${a}"`:"";c=c.substring(0,g.insertPos)+`${y} ${v}`+c.substring(g.insertPos)}let l=t.if;if(l)c=`<template :if="${l.replace(/"/g,""")}">${c}</template>`;let h=t.for;if(h){let v=t.key,y=v?` :key="${v.replace(/"/g,""")}"`:"";c=`<template :for="${h.replace(/"/g,""")}"${y}>${c}</template>`}return c}function Yn(e,t,s=new Set,i=new Set,o=!1){let a=ut(e,o);if(!a)return e;let c=e.slice(a.insertPos,a.tagEnd),g=t.serverDynamic.class??t.static.class;if(o&&typeof g==="string"&&g&&!i.has("class")){let m=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=m.test(c)?c.replace(m,(w,C,k,A,I)=>`${C}class="${R(`${at(k??A??I)} ${g}`)}"`):` class="${R(g)}"${c}`;e=e.slice(0,a.insertPos)+b+e.slice(a.tagEnd),a.tagEnd+=b.length-c.length,c=b}let l=o||/\bdata-native(?:\s|=)/i.test(c),h=l?i:s,v=new Set(Object.keys(me(c))),y=new Set(["class","className"]);for(let m of Object.keys(t.static)){let b=t.staticNames[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}for(let m of Object.keys(t.serverDynamic)){let b=t.serverDynamicNames?.[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}let S=[];if(l){for(let[m,b]of Object.entries(t.static)){if(y.has(m)||b!==!0&&b!==se)continue;y.add(m),S.push(`${R(t.staticNames?.[m]??m)}="true"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!0)continue;y.add(m),S.push(`${R(t.serverDynamicNames?.[m]??m)}="true"`)}}let x=[...ie(t,y),...ae(t,y),...S];if(l){for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!1)continue;let w=t.serverDynamicNames?.[m]??m;x.push(`${R(w)}="false"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let C=t.serverDynamicNames?.[m]??m;x.push(`${R(C)}="${R(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,a.insertPos)} ${x.join(" ")}${e.slice(a.insertPos)}`}function ve(e){let t=Gt(e,0);if(t)return t;let s=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(s)return{insertPos:s.index+1+s[1].length,tagEnd:ft(e,s.index+1+s[1].length)};return null}function ut(e,t=!1){let s=ve(e);if(!s)return null;let i=e.slice(s.insertPos,s.tagEnd),o=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(i)?Gt(e,s.tagEnd+1):s;return o&&t?Qn(e,o)??o:o}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),i=e.lastIndexOf("<",t.insertPos),o=0,a;while(i>=0&&i<e.length){if(e.startsWith("<!--",i)){let v=e.indexOf("-->",i+4);if(v<0)return null;i=e.indexOf("<",v+3);continue}let c=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(i));if(!c){i=e.indexOf("<",i+1);continue}let g=c[2].toLowerCase(),l=i+c[0].length,h=ft(e,l);if(c[1]){if(o--,a!==void 0&&o<a)a=void 0;if(o<=0)return null}else if(g==="script"||g==="style"){let v=new RegExp(`</${g}\\s*>`,"gi");if(v.lastIndex=h+1,!v.exec(e))return null;i=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(l,h)),y=o>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(a===void 0&&!y&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:l,tagEnd:h};if(!s.has(g)&&e[h-1]!=="/"){if(o++,a===void 0&&y)a=o}else if(o===0)return null}i=e.indexOf("<",h+1)}return null}function Gt(e,t){let s=t;while(s<e.length){let i=e.slice(s),o=i.match(/^\s+/);if(o){s+=o[0].length;continue}if(i.startsWith("<!--")){let g=e.indexOf("-->",s+4);if(g===-1)return null;s=g+3;continue}let a=i.match(/^<(script|style)\b[^>]*>/i);if(a){let g=`</${a[1].toLowerCase()}>`,l=e.toLowerCase().indexOf(g,s+a[0].length);if(l===-1)return null;s=l+g.length;continue}let c=i.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!c)return null;return{insertPos:s+1+c[1].length,tagEnd:ft(e,s+1+c[1].length)}}return null}function ft(e,t){let s="";for(let i=t;i<e.length;i++){let o=e[i];if(s){if(o==="\\")i++;else if(o===s)s=""}else if(o==='"'||o==="'")s=o;else if(o===">")return i}return e.length}function er(e){let t=new Set;for(let s of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=s[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let o of qo(s[2]))t.add(o);for(let o of s[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(o[1])t.add(o[1]);if(o[3])t.add(o[3]);for(let a of(o[2]??"").split(",")){let c=a.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}}}return t}async function Zr(e,t,s,i,o){if(!Xt)Dt(le),Xt=!0;let a=await pf(e,t,s,i,o);a=await Gn(a,t,s,i,o),a=await Kn(a,t,s,i,o);let c=[];for(let g=0;g<3;g++){let l=c.length,h=de(a,Ie,(y,S)=>`\x00STX_COMPONENT_COMMENT_${l+S}\x00`,`STX_COMPONENT_COMMENT:${l}`);c.push(...h.tokens);let v=a;if(a=await Jn(h.output,t,s,i,o),a===v)break}if(c.length>0)a=a.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(g,l)=>c[Number(l)]??"");if(i.debug){let g=Vn(a);if(g.length>0)console.warn(`[stx] ${s}: unresolved component tag(s) after render passes: ${g.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return a}
|
|
41
|
+
`||N==="\t"){let _=Ln(e,L+w.length);if(e[_-1]!=="/")k++;A=_+1}else A=L+w.length}else{if(k--,k===0){I=q;break}A=q+C.length}}if(I===-1){o=x;continue}let U=e.slice(x,I),M=I+C.length;i.push({fullMatch:e.slice(c,M),tagName:h,attributes:b,content:U,startIndex:c,endIndex:M,isSelfClosing:!1}),o=M}}return i}function at(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,t){try{let s=Buffer.from(e,"base64").toString("utf8");return JSON.parse(s)}catch{}try{let s=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(s)}catch(s){if(t?.debug)console.error("Error decoding __stx_ prop:",s);return e}}function ct(e,t){let s=0,i="",o=t;while(o<e.length){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'"||a==="`")i=a;else if(a==="{")s++;else if(a==="}"){if(s--,s===0)return e.slice(t,o+1)}o++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(ct(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return lt(e).map((t)=>[t.start,t.end])}function lt(e){let t=[],s=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,i;while((i=s.exec(e))!==null){let o=i[2]||"",a=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(o);if(!a)continue;let c=X(a[1]??a[2]??a[3]??""),g=i.index,l=g+i[0].length,h=i[1].toLowerCase();if(i[0].endsWith("/>")||Un.has(h)){t.push({start:g,end:l,names:c});continue}let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");y.lastIndex=l;let S=1,x=l,m;while((m=y.exec(e))!==null)if(m[0].startsWith("</")){if(S--,S===0){x=m.index+m[0].length;break}}else if(!m[0].endsWith("/>"))S++;t.push({start:g,end:x,names:c})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function Ha(e,t){if(!/:[\w-]+=/.test(e))return e;let s=e,i=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,o=[],a;while((a=i.exec(e))!==null)o.push([a.index,a.index+a[0].length]);o.push(...Wn(e));let c=new Set([...et(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function g(S){return o.some(([x,m])=>S>=x&&S<m)}let l=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,h=[],v=new Map,y=256;while((a=l.exec(s))!==null){if(g(a.index))continue;let S=a[0],x=a[2];if(!x||!x.includes(":"))continue;let m=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,w,C=x,k=!1;while((w=b.exec(x))!==null){if(Ss(x,w.index,!0)?.kind==="attribute")continue;let A=w[1],I=w[2];if(Gc(A))continue;if(H(I,c))continue;if(I.includes("()")&&!I.includes(".get(")||I.includes("$store")||I.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=I.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let q=JSON.stringify([U,I]),N=v.get(q);if(!N){if(N=Function(...U,`return (${I})`),v.size>=y)v.clear();v.set(q,N)}let _=N(...M);if(A==="class"){let O=V(Ft(_));if(O){let B=C.match(/\sclass="([^"]*)"/);if(B)C=C.replace(B[0],()=>` class="${B[1]} ${O}"`);else C=C.replace(w[0],()=>` class="${O}"`)}else C=C.replace(w[0],"");k=!0;continue}if(zn.has(A)){if(_)C=C.replace(w[0],` ${A}`);else C=C.replace(w[0],"");k=!0;continue}if(_===null||_===void 0||_===!1)C=C.replace(w[0],"");else{let O=m&&typeof _==="object"?JSON.stringify(_):String(_),B=hn(A,O);C=C.replace(w[0],()=>` ${A}="${B}"`)}k=!0}catch(U){if(U instanceof oe)throw U;continue}}if(k){let A=a[3]?" /":"",U=`<${a[1]}${C}${A}>`;h.push({start:a.index,end:a.index+S.length,replacement:U})}}if(h.length>0){let S=Array(h.length*2+1),x=0;for(let m=0;m<h.length;m++){let{start:b,end:w,replacement:C}=h[m];S[m*2]=s.slice(x,b),S[m*2+1]=C,x=w}S[h.length*2]=s.slice(x),s=S.join("")}return s}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,s,i=!1,o=new Set){let a={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},c=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),g=(y)=>{if(c.size===0)return!1;let S=r(y),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&c.has(x))return!0;for(let m of c){let b=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(S))return!0}return!1},l=new Set(Kc),h=(y)=>{if(!y.includes("-")||y.startsWith("@")||y.startsWith(":")||y.startsWith("x-")||y.startsWith("__"))return y;if(y.startsWith("aria-")||y.startsWith("data-"))return y;return y.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},v=(y,S)=>{let x=h(y);if(a.static[x]=S,x!==y)a.staticNames[x]=y};for(let[y,S]of Object.entries(e)){let x=y.startsWith("x-")&&!l.has(y)&&!y.startsWith("x-bind:")&&!y.startsWith("x-on:")?`:${y.slice(2)}`:y;if(x.startsWith("@")){a.events[x]=S;continue}if(x.startsWith("__stx_")){let m=h(x.slice(6));a.serverDynamic[m]=Ut(S,s);continue}if(x.startsWith(":")){let m=h(x.slice(1)),b=S===se?m:S;if(m==="if"||m==="for"||m==="show"){a.clientReactive[m]=b;continue}if(i){a.clientReactive[m]=b;continue}if(H(b,o)){a.clientReactive[m]=b;continue}if(g(b)){a.clientReactive[m]=b;continue}try{if(!p(b)){if(s.debug)console.error(`Unsafe expression in :${m} binding: ${b}`);a.clientReactive[m]=b;continue}let w=Object.keys(t),C=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(tt(b).some((M)=>!C.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){a.clientReactive[m]=b;continue}let U=u(b,w)(...Object.values(t));if(a.serverDynamic[m]=U,m!==x.slice(1)&&a.serverDynamicNames)a.serverDynamicNames[m]=x.slice(1)}catch{a.clientReactive[m]=b}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let m=Hn(S,o);if(m!==null){a.clientReactive[h(x)]=m;continue}let b=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(p(w)){let k=u(w,Object.keys(t))(...Object.values(t));v(x,k!=null?String(k):"")}else{if(s.debug)console.error(`Unsafe expression in ${x}: ${w}`);v(x,S)}}catch(w){if(s.debug)console.error(`Error evaluating expression for ${x}:`,w);v(x,S)}else{let w=S,C=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=C.exec(S))!==null)try{let A=k[1];if(!p(A)){if(s.debug)console.error(`Unsafe expression in ${x}: ${A}`);continue}let U=u(A,Object.keys(t))(...Object.values(t));w=w.replace(k[0],String(U??""))}catch(A){if(s.debug)console.error(`Error evaluating expression in ${x}:`,A)}v(x,w)}continue}v(x,S===se?"true":at(S))}return a}function Hn(e,t){if(t.size===0)return null;let s=/\{\{\s*([\s\S]+?)\s*\}\}/g,i=[...e.matchAll(s)];if(!i.some((g)=>H(g[1],t)))return null;let o=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(o&&i.length===1)return o[1];let a="",c=0;for(let g of i)a+=e.slice(c,g.index).replace(/[`\\$]/g,(l)=>`\\${l}`),a+=`\${${g[1]}}`,c=g.index+g[0].length;return a+=e.slice(c).replace(/[`\\$]/g,(g)=>`\\${g}`),`\`${a}\``}var qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,s){if(!e.includes("@"))return e;if(!qn.some(([o,a])=>o.test(e)&&e.includes(a)))return e;try{return re(e,t,s)}catch{return e}}function me(e){let t={},s=0,i=e.length;while(s<i){while(s<i&&/\s/.test(e[s]))s++;if(s>=i)break;let o="";while(s<i&&!/[\s=]/.test(e[s]))o+=e[s],s++;if(!o)break;while(s<i&&/\s/.test(e[s]))s++;if(s<i&&e[s]==="="){s++;while(s<i&&/\s/.test(e[s]))s++;let a="";if(s<i&&(e[s]==='"'||e[s]==="'")){let c=e[s];s++;while(s<i){let g=e[s];if(g==="\\"&&s+1<i){s++,a+=e[s],s++;continue}if(g===c){s++;break}a+=g,s++}}else if(e[s]==="{"){a=ct(e,s),s+=a.length;let c=Wt(a);if(c!==null){t[`:${o}`]=c;continue}}else while(s<i&&!/\s/.test(e[s]))a+=e[s],s++;t[o]=a}else t[o]=se}return t}function Zt(e){return Object.entries(e).map(([t,s])=>s===se?t:`${t}="${Zn(s)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Vn(e){let t=new Set,s=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,i;while((i=s.exec(e))!==null){let o=i[1];if(le.isBuiltin(o))t.add(o)}return[...t].sort()}async function pf(e,t,s,i,o){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let a=t.__importedComponents,c=qt.dirname(s),g=[],l=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(l)){let[S,x,m]=y,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=m,C,k=[];while((C=b.exec(m))!==null){let[A,I,U,M]=C,L=null,q=null;if(M.startsWith(".")||M.startsWith("/")){let O=qt.resolve(c,M);if(O.endsWith(".stx"))q=O;else{let B=`${O}.stx`;try{if(Ht.statSync(B).isFile())q=B}catch{try{if(Ht.statSync(O).isDirectory())L=O}catch{}}}}else L=vs(M,c);if(!L&&!q)continue;let N=!1,_=(O,B)=>{a.set(O,B),a.set(O.toLowerCase(),B);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.set(z,B),o.add(B)};if(U&&q)_(U,q),N=!0;else if(I){let O=I.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let G=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(G)return{source:G[1],local:G[2]};return{source:z,local:z}}),B=L?bs(L):null;for(let{source:z,local:G}of O){let D=null;if(q)D=q;else if(B)D=B.get(z)??B.get(z.toLowerCase())??B.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)_(G,D),N=!0}}if(N)k.push({start:C.index,end:C.index+A.length})}if(k.length===0)continue;for(let A=k.length-1;A>=0;A--)w=w.slice(0,k[A].start)+w.slice(k[A].end);g.push({start:y.index,end:y.index+S.length,value:`<script${x}>${w}</script>`})}if(g.length===0)return e;let h=[],v=0;for(let y of g)h.push(e.slice(v,y.start),y.value),v=y.end;return h.push(e.slice(v)),h.join("")}async function Gn(e,t,s,i,o){let a=e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,g=/@import\s*\(\s*([^)]+)\s*\)/g,l;while((l=g.exec(a))!==null){let[h,v]=l,y=v.split(",").map((S)=>S.trim().replace(/^['"]|['"]$/g,"")).filter((S)=>S.length>0);for(let S of y){let x=S.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((A)=>A.charAt(0).toUpperCase()+A.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),C=null,k=ws(S,s,i);for(let A of k)try{if(await Bun.file(A).exists()){C=A;break}}catch{}if(C){c.set(w,C),c.set(b,C),c.set(b.toLowerCase(),C);let A=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(c.set(A,C),o.add(C),i.debug)console.log(`Imported component: ${w} -> ${C}`)}else if(i.debug)console.warn(`Could not resolve imported component: ${S}`)}a=a.replace(h,""),g.lastIndex=0}return a}async function Kn(e,t,s,i,o){let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=/@component\s*\(/g,h;while((h=l.exec(a))!==null){let v=h.index,y=v+h[0].length-1,S=1,x=y+1;while(x<a.length&&S>0){if(a[x]==="(")S++;else if(a[x]===")"){if(S--,S===0)break}x++}if(S!==0)break;let m=a.substring(y+1,x),b=x+1,w=m.match(/^\s*['"]([^'"]+)['"]/);if(!w){l.lastIndex=0;continue}let C=w[1],k,A=m.slice(w[0].length),I=A.match(/^\s*,\s*/);if(I)k=A.slice(I[0].length).trim();let U={};if(k)try{U=E(k,t)}catch(O){let B=O instanceof Error?O.message:String(O);a=a.replace(a.substring(v,b),`[Error parsing component props: ${B}]`);continue}let M="",L=b,N=a.substring(b).match(/^([\s\S]*?)@endcomponent/);if(N)M=N[1].trim(),L=b+N[0].length;let _=await je(C,U,M,c,t,s,i,g,o);a=a.substring(0,v)+_+a.substring(L),l.lastIndex=0}return a}async function Jn(e,t,s,i,o){if(!e)return e;let a=e,c=i.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let g=t.__processedComponents,l=er(a);if(l.size>0){let b=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...b,...l])]}let h=K(a);a=h.output;let v=et(t);return a=await m(a,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),a=await m(a,/[A-Z][a-zA-Z0-9]*/,!0,Lt(gr)),a=await m(a,/[a-z][a-z0-9]*/,!1,gr),a=h.restore(a),a;async function m(b,w,C,k){if(!b)return b;let A=b,I=zt(A,w,k),U=lt(A),M=new Map;for(let N=I.length-1;N>=0;N--){let _=I[N],O=C?j(_.tagName):_.tagName,B=me(Xn(_.attributes,t,s)),z=U.filter(({start:Z,end:P})=>_.startIndex>=Z&&_.startIndex<P),G=z.length>0,D=new Set(v);for(let Z of z)for(let P of Z.names)D.add(P);let W=Fn(B,t,i,G,D);if(typeof W.clientReactive.for==="string")for(let Z of X(W.clientReactive.for))D.add(Z);let ce=le.getBuiltin(_.tagName),we=ce?await yr(_.tagName,c,t,s,i):!1;if(ce&&!we){let Z={context:t,filePath:s,options:i,dependencies:o},P=ce.render(W,_.content,Z);if(Object.keys(W.events).length>0){let F=Zt(W.events);P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${F}`)}if(Object.keys(W.clientReactive).length>0)P=Vt(P,W.clientReactive);M.set(N,P);continue}if(!C&&_.tagName.includes("-")&&!await yr(O,c,t,s,i))continue;let Y={};for(let[Z,P]of Object.entries(W.static))Y[Z]=P;for(let[Z,P]of Object.entries(W.serverDynamic))Y[Z]=P;let ne={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},T=await je(O,Y,h.restore(_.content),c,t,s,i,g,o,[...D],ne,_.tagName);if(T=Yn(T,W,ne.declaredProps,ne.consumedProps,i._nativeHostAttrs),i._nativeHostAttrs){let Z=ne.reactiveProps.filter((te)=>!ne.consumedProps.has(te)&&!["if","for","show","key","ref"].includes(te)).map(j),P=ut(T,!0);if(Z.length&&P){if(!Object.hasOwn(me(T.slice(P.insertPos,P.tagEnd)),"data-stx-native-host-root"))T=T.slice(0,P.insertPos)+' data-stx-native-host-root="true"'+T.slice(P.insertPos);let te=ve(T);T=T.slice(0,te.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+T.slice(te.insertPos)}let F=ut(T,!0);if(F){let te=me(T.slice(F.insertPos,F.tagEnd)),Se=ve(T),Kt=me(T.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(te,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))T=T.slice(0,Se.insertPos)+" data-stx-native-host-owner"+T.slice(Se.insertPos)}}if(Object.keys(W.events).length>0){let Z=ve(T);if(Z){let P=Zt(W.events),F=Object.keys(W.events).map((te)=>te.replace(/^@/,"").split(".")[0]).join(" ");T=T.substring(0,Z.insertPos)+` data-stx-parent-events="${F}" ${P}`+T.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)T=Vt(T,W.clientReactive);M.set(N,T)}if(M.size===0)return A;let L="",q=0;for(let N=0;N<I.length;N++){let _=M.get(N);if(_===void 0)continue;L+=A.slice(q,I[N].startIndex),L+=_,q=I[N].endIndex}return L+=A.slice(q),L}}function Vt(e,t){let s=new Set(["if","for"]),i=new Set(["show"]),o=Object.entries(t).filter(([v])=>!s.has(v)),a=o.filter(([v])=>!i.has(v)).map(([v])=>j(v)).join(" "),c=e,g=o.length>0?ve(c):null;if(g){let v=o.map(([S,x])=>`:${j(S)}="${x.replace(/"/g,""")}"`).join(" "),y=a?` data-stx-parent-bindings="${a}"`:"";c=c.substring(0,g.insertPos)+`${y} ${v}`+c.substring(g.insertPos)}let l=t.if;if(l)c=`<template :if="${l.replace(/"/g,""")}">${c}</template>`;let h=t.for;if(h){let v=t.key,y=v?` :key="${v.replace(/"/g,""")}"`:"";c=`<template :for="${h.replace(/"/g,""")}"${y}>${c}</template>`}return c}function Yn(e,t,s=new Set,i=new Set,o=!1){let a=ut(e,o);if(!a)return e;let c=e.slice(a.insertPos,a.tagEnd),g=t.serverDynamic.class??t.static.class;if(o&&typeof g==="string"&&g&&!i.has("class")){let m=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=m.test(c)?c.replace(m,(w,C,k,A,I)=>`${C}class="${R(`${at(k??A??I)} ${g}`)}"`):` class="${R(g)}"${c}`;e=e.slice(0,a.insertPos)+b+e.slice(a.tagEnd),a.tagEnd+=b.length-c.length,c=b}let l=o||/\bdata-native(?:\s|=)/i.test(c),h=l?i:s,v=new Set(Object.keys(me(c))),y=new Set(["class","className"]);for(let m of Object.keys(t.static)){let b=t.staticNames[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}for(let m of Object.keys(t.serverDynamic)){let b=t.serverDynamicNames?.[m]??m;if(v.has(b)||h.has(m)||!l&&!Fe(b))y.add(m)}let S=[];if(l){for(let[m,b]of Object.entries(t.static)){if(y.has(m)||b!==!0&&b!==se)continue;y.add(m),S.push(`${R(t.staticNames?.[m]??m)}="true"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!0)continue;y.add(m),S.push(`${R(t.serverDynamicNames?.[m]??m)}="true"`)}}let x=[...ie(t,y),...ae(t,y),...S];if(l){for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b!==!1)continue;let w=t.serverDynamicNames?.[m]??m;x.push(`${R(w)}="false"`)}for(let[m,b]of Object.entries(t.serverDynamic)){if(y.has(m)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let C=t.serverDynamicNames?.[m]??m;x.push(`${R(C)}="${R(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,a.insertPos)} ${x.join(" ")}${e.slice(a.insertPos)}`}function ve(e){let t=Gt(e,0);if(t)return t;let s=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(s)return{insertPos:s.index+1+s[1].length,tagEnd:ft(e,s.index+1+s[1].length)};return null}function ut(e,t=!1){let s=ve(e);if(!s)return null;let i=e.slice(s.insertPos,s.tagEnd),o=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(i)?Gt(e,s.tagEnd+1):s;return o&&t?Qn(e,o)??o:o}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),i=e.lastIndexOf("<",t.insertPos),o=0,a;while(i>=0&&i<e.length){if(e.startsWith("<!--",i)){let v=e.indexOf("-->",i+4);if(v<0)return null;i=e.indexOf("<",v+3);continue}let c=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(i));if(!c){i=e.indexOf("<",i+1);continue}let g=c[2].toLowerCase(),l=i+c[0].length,h=ft(e,l);if(c[1]){if(o--,a!==void 0&&o<a)a=void 0;if(o<=0)return null}else if(g==="script"||g==="style"){let v=new RegExp(`</${g}\\s*>`,"gi");if(v.lastIndex=h+1,!v.exec(e))return null;i=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(l,h)),y=o>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(a===void 0&&!y&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:l,tagEnd:h};if(!s.has(g)&&e[h-1]!=="/"){if(o++,a===void 0&&y)a=o}else if(o===0)return null}i=e.indexOf("<",h+1)}return null}function Gt(e,t){let s=t;while(s<e.length){let i=e.slice(s),o=i.match(/^\s+/);if(o){s+=o[0].length;continue}if(i.startsWith("<!--")){let g=e.indexOf("-->",s+4);if(g===-1)return null;s=g+3;continue}let a=i.match(/^<(script|style)\b[^>]*>/i);if(a){let g=`</${a[1].toLowerCase()}>`,l=e.toLowerCase().indexOf(g,s+a[0].length);if(l===-1)return null;s=l+g.length;continue}let c=i.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!c)return null;return{insertPos:s+1+c[1].length,tagEnd:ft(e,s+1+c[1].length)}}return null}function ft(e,t){let s="";for(let i=t;i<e.length;i++){let o=e[i];if(s){if(o==="\\")i++;else if(o===s)s=""}else if(o==='"'||o==="'")s=o;else if(o===">")return i}return e.length}function er(e){let t=new Set;for(let s of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=s[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let o of qo(s[2]))t.add(o);for(let o of s[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(o[1])t.add(o[1]);if(o[3])t.add(o[3]);for(let a of(o[2]??"").split(",")){let c=a.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}}}return t}async function Zr(e,t,s,i,o){if(!Xt)Dt(le),Xt=!0;let a=await pf(e,t,s,i,o);a=await Gn(a,t,s,i,o),a=await Kn(a,t,s,i,o);let c=[];for(let g=0;g<3;g++){let l=c.length,h=de(a,Ie,(y,S)=>`\x00STX_COMPONENT_COMMENT_${l+S}\x00`,`STX_COMPONENT_COMMENT:${l}`);c.push(...h.tokens);let v=a;if(a=await Jn(h.output,t,s,i,o),a===v)break}if(c.length>0)a=a.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(g,l)=>c[Number(l)]??"");if(i.debug){let g=Vn(a);if(g.length>0)console.warn(`[stx] ${s}: unresolved component tag(s) after render passes: ${g.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return a}
|
|
42
42
|
export{vo,wo,xo,eh,Yr,th,Ha,pf,Zr};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yn,ri}from"./chunk-
|
|
2
|
+
import{yn,ri}from"./chunk-ddw8tpdd.js";import"./chunk-3392k9vm.js";export{ri as generateRuntimeConfigTypes,yn as prepareRuntimeConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nh,ff,Co,Qr,er,Eo,To,es,ts,ns,$o,Va,gf,ht}from"./chunk-
|
|
2
|
+
import{nh,ff,Co,Qr,er,Eo,To,es,ts,ns,$o,Va,gf,ht}from"./chunk-kw4afzfh.js";import"./chunk-9j1s520t.js";import"./chunk-vfjenjez.js";import"./chunk-7xv4xa3c.js";import"./chunk-7defwkm1.js";import"./chunk-2p34qf9c.js";import"./chunk-fgr56q3w.js";import"./chunk-p78v88ng.js";import"./chunk-m4j9gedb.js";import{L}from"./chunk-t4jr8adw.js";import"./chunk-ddw8tpdd.js";import"./chunk-3392k9vm.js";import"./chunk-xc03cdet.js";import"./chunk-k7pmzreg.js";import"./chunk-2nqt1m3m.js";export{nh as clearScriptScanCache,es as convertServerLoopAttributesToDirectives,Eo as convertSignalDirectivesToAttributes,ts as convertSignalLoopsToAttributes,er as extractClientSignalNames,L as extractExports,Va as findMarkupIndexOutsideScripts,Qr as hasSignalsSyntax,Co as parseLoopExpression,To as preEvalLiteralReactiveIfs,ns as processScriptSetup,$o as processSignals,gf as rewriteStxImportSpecifiers,ff as scanScriptTags,ht as stripStxRuntimeImports};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xn,o}from"./chunk-h0m8ccfk.js";import"./chunk-yeqszxaz.js";import"./chunk-bsr9wnq4.js";import"./chunk-yrvctbgh.js";import"./chunk-qpb02n0q.js";import"./chunk-pd1b2701.js";import"./chunk-cbdyns7r.js";import"./chunk-kw4afzfh.js";import{ye}from"./chunk-9j1s520t.js";import"./chunk-vfjenjez.js";import"./chunk-t8ezn4vq.js";import"./chunk-7xv4xa3c.js";import"./chunk-7defwkm1.js";import"./chunk-2p34qf9c.js";import"./chunk-fgr56q3w.js";import"./chunk-p78v88ng.js";import"./chunk-m4j9gedb.js";import{Pe,Es,Ts}from"./chunk-t4jr8adw.js";import"./chunk-ddw8tpdd.js";import"./chunk-3392k9vm.js";import"./chunk-xc03cdet.js";import"./chunk-k7pmzreg.js";import"./chunk-2nqt1m3m.js";export{Xn as buildModulesTag,ye as injectRouterScript,o as processDirectives,Es as processJsonDirective,Ts as processOnceDirective,Pe as validateClientScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{l,p,E,u,U}from"./chunk-xc03cdet.js";import{L,hs,B,Pe,ue,mr,Me,Le,n,m,we,x}from"./chunk-
|
|
2
|
+
import{l,p,E,u,U}from"./chunk-xc03cdet.js";import{L,hs,B,Pe,ue,mr,Me,Le,n,m,we,x}from"./chunk-t4jr8adw.js";import{st}from"./chunk-2nqt1m3m.js";import{T}from"./chunk-k7pmzreg.js";import{re}from"./chunk-cbdyns7r.js";import{G,Ke}from"./chunk-jkywbfb0.js";import{C,xn}from"./chunk-csx3zne1.js";import A from"path";import{existsSync as St}from"fs";function at(a,t){let c=0;for(let i=t;i<a.length;i++){let S=a[i];if(S==="("||S==="["||S==="{")c++;else if(S===")"||S==="]"||S==="}")c--;else if(S===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,S=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=S.exec(i);while(s){let f=s.index,e=f+s[0].length-1,D=1,Z=e+1;while(Z<i.length&&D>0){if(i[Z]==="(")D++;else if(i[Z]===")")D--;Z++}if(D!==0)break;let it=i.substring(e+1,Z-1),j=`${c}(${it})`;i=i.substring(0,f)+j+i.substring(Z),S.lastIndex=f+j.length,s=S.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,S=0,s=0,f=t.length,e=(j)=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]===j){s++;return}s++}},D=()=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]==="`"){s++;return}if(t[s]==="$"&&t[s+1]==="{"){s+=2;let j=1;while(s<f&&j>0)if(t[s]==="{")j++,s++;else if(t[s]==="}")j--,s++;else if(t[s]==="'"||t[s]==='"')e(t[s]);else if(t[s]==="`")D();else s++;continue}s++}},Z=()=>{if(t[s]==="/"&&t[s+1]==="/"){while(s<f&&t[s]!==`
|
|
3
3
|
`)s++;return!0}if(t[s]==="/"&&t[s+1]==="*"){s+=2;while(s<f-1&&!(t[s]==="*"&&t[s+1]==="/"))s++;return s+=2,!0}return!1},it=()=>{if(S!==0)return;let j=t.slice(s).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let H=j[2];if(!i.has(H))c.push(H),i.add(H);return}let et=t.slice(s).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let H=et[1];if(!i.has(H))c.push(H),i.add(H);return}let Y=t.slice(s).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let H=Y[1];if(!i.has(H))c.push(H),i.add(H)}};while(s<f){if(Z())continue;if(t[s]==="'"||t[s]==='"'){e(t[s]);continue}if(t[s]==="`"){D();continue}if(t[s]==="{"){S++,s++;continue}if(t[s]==="}"){S--,s++;continue}if(S===0&&/[a-z]/i.test(t[s])&&(s===0||/\s|[;{}()]/.test(t[s-1])))it();s++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${st("var",c)}
|
|
@@ -44,11 +44,11 @@ ${s}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(G(a)){let S=G(a).tag.match(/data-stx-scope="([^"]*)"/);if(S)return{html:a,mergedIntoExisting:S[1],stamped:!0,root:"body"};return{html:Ke(a,(s,f)=>`<body${f} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],S=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:S};let f=c[1],e=c[2],D=c[3];return{html:`${f}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:S}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function Zm(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function df(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],S=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,f;while((f=s.exec(c))!==null){let e=f[1]==="/",D=f[2],Z=f[3]==="/"||Tt.has(D.toLowerCase());if(e){S=Math.max(0,S-1);continue}if(S===0)i.push(D);if(!Z)S++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Ge=new B(500),za=new Set;function Qm(){za.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return za}async function Kr(a,t,c,i,S,s=new Set){let f=i.partialsDir||A.join(A.dirname(c),"partials");if(f&&!A.isAbsolute(f))f=A.resolve(process.cwd(),f);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,k,_)=>{let g=k.trim(),r=`${c}:${g}`;if(D.has(r))return"";return D.add(r),k});{let h=/@includeIf\s*\(/g,k;while((k=h.exec(e))!==null){let _=k.index,g=_+k[0].length-1,r=1,w=g+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")")r--;w++}if(r!==0)break;let d=e.substring(g+1,w-1),o=d.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=w;continue}let O=o[1],W=Z(O,f,c),R="";if(W&&await Bun.file(W).exists())S.add(W),R=`@include(${d})`;e=e.substring(0,_)+R+e.substring(w),h.lastIndex=0}}for(let[h,k]of[["@includeWhen",!1],["@includeUnless",!0]]){let _=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=_.exec(e))!==null){let r=g.index,w=r+g[0].length-1,d=1,o=w+1;while(o<e.length&&d>0){if(e[o]==="(")d++;else if(e[o]===")")d--;o++}if(d!==0)break;let O=e.substring(w+1,o-1),W=at(O,0);if(W===-1){_.lastIndex=o;continue}let R=O.substring(0,W).trim(),V=O.substring(W+1).trim(),z=V.match(/^\s*['"]([^'"]+)['"]/);if(!z){_.lastIndex=o;continue}let b=z[1],q=V.substring(z[0].length),N,I=at(q,0);if(I!==-1)N=q.substring(I+1).trim();try{let M=`Boolean(${R})`,P;if(p(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=k?!P:P,rt="";if(tt){let ot=Z(b,f,c);if(ot&&await Bun.file(ot).exists())S.add(ot);rt=`@include('${b}'${N?`, ${N}`:""})`}e=e.substring(0,r)+rt+e.substring(o),_.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=m("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),_.lastIndex=0}}}{let h=/@each\s*\(/g,k;while((k=h.exec(e))!==null){let _=k.index,g=_+k[0].length-1,r=1,w=g+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let d=e.substring(g+1,w),o=e.substring(_,w+1),O=d.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,R,V,z]=O;try{let b,q=R.trim();if(p(q))b=u(q,Object.keys(t))(...Object.values(t));else b=l(q,t);let N="";if(Array.isArray(b)&&b.length>0)for(let I of b){let M={...t,[V]:I},P=await et(W,M,a,_);N+=P}else if(z)N=await et(z,{},a,_);e=e.substring(0,_)+N+e.substring(w+1),h.lastIndex=0}catch(b){let q=b instanceof Error?b.message:String(b);e=e.substring(0,_)+m("Each",`Error in @each: ${q}`,c,a,_)+e.substring(w+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,k;while((k=h.exec(e))!==null){let _=k.index,g=_+k[0].length-1,r=1,w=g+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let d=e.substring(g+1,w),o=e.substring(_,w+1),O=d.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],R=d.slice(O[0].length),V,z=R.match(/^\s*,\s*\{/);if(z){R=R.slice(z[0].length-1);let N=1,I=1;while(I<R.length&&N>0){if(R[I]==="{")N++;else if(R[I]==="}"){if(N--,N===0)break}I++}V=R.substring(0,I+1),R=R.slice(I+1)}let b,q=R.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(q)b=q[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(V)try{I=E(V,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let rt=m("Include",`Error parsing includeFirst variables: ${tt}`,c,a,_,o);e=e.replace(o,()=>rt)}else e=e.replace(o,()=>b||"");continue}let M=!1;for(let P of N){let tt=Z(P,f,c);if(!tt)continue;if(await n(tt)){let rt=await et(P,I,a,_);e=e.replace(o,()=>rt),M=!0;break}}if(!M)if(b!==void 0)e=e.replace(o,()=>b);else if(i.debug){let P=m("Include",`None of the includeFirst paths exist: ${W}`,c,a,_,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=m("Include",`Error processing @includeFirst: ${I}`,c,a,_,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function Z(h,k,_){try{let g=h;if(!h.endsWith(".stx"))g=`${h}.stx`;let r=A.resolve(k),w=A.resolve(A.dirname(_)),d;if(!g.startsWith("./")&&!g.startsWith("../")){for(let z of i._layerPartialDirs??[]){let b=A.resolve(z,g);if(b.startsWith(`${A.resolve(z)}${A.sep}`)&&St(b))return b}d=A.resolve(k,g)}else d=A.resolve(w,g);let o=A.normalize(d),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(w+A.sep)||o===w,R=!1,V=A.dirname(w);if(o.startsWith(V+A.sep)){if(!A.relative(V,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))R=!0}if(!O&&!W&&!R)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${w}`),null;return o}catch(g){return console.error(`Error resolving path ${h}: ${g}`),null}}let it=A.resolve(c);s.add(it);function j(h,k,_,g){return i.onIncludeError?.({includePath:h,templatePath:c,message:k,partialsDir:f}),m("Include",k,c,_,g)}async function et(h,k={},_,g){let r=Z(h,f,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,_,g);let w=A.resolve(r);if(s.has(w)){let d=[...s,w].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${d}`,_,g)}try{S.add(r);let d;if(!d)try{d=await Bun.file(r).text()}catch(v){let K=v instanceof Error?v.message:String(v);return j(h,`Error loading include file ${h}: ${K}`,_,g)}if(d)d=d.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(d&&d.includes("@stream")){let{processStreamDirectives:v}=await import("./chunk-3fwj83yq.js");d=v(d,t)}if(d&&(i.debug||!C()&&!xn()))try{let{warnUnbalancedTags:v}=await import("./chunk-mv4wfsc5.js");v(d,r)}catch{}try{let{processESImports:v}=await import("./chunk-yg406pd5.js");d=await v(d,t,r,i,S)}catch(v){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,v instanceof Error?v.message:v)}let o=d,O=ue(o);if(O)o=O.content.trim();let R=d.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),V="";if(R)V=`<style${R[1]}>${R[2]}</style>`;let z=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(v,K,y)=>{if(!ft(K))return"";return z.push({attrs:K,body:y}),`__STX_DATA_BLOCK_${z.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let b={...t};b.__stx_signals_gate=we(d,r);for(let[v,K]of Object.entries(k))b[v]=K;let q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,N=[...d.matchAll(q)].sort((v,K)=>{let y=(v[1]||"").includes("server"),X=(K[1]||"").includes("server");return Number(X)-Number(y)}),I="",M=null,P=!1,tt=!1;for(let v of N){let K=v[1]||"",y=v[2]||"";if(ft(K))continue;let X=K.includes("server"),wt=Me(K);if(!X&&!/\bsrc\s*=/i.test(K))Pe(y,r,i.strict);if(!X&&y.trim()){let{interpolateScriptExpressions:F}=await import("./chunk-m5k44pc8.js");y=F(y,b,h)}let ct="";try{let{extractAndStripCssImports:F,renderVendorStyleTags:Q}=await import("./chunk-ak7n6tan.js"),nt=F(y,{filePath:r,projectRoot:process.cwd()});y=nt.code,ct=Q(nt.styles)}catch(F){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,F instanceof Error?F.message:F)}if(wt&&y.trim())y=Le(y);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-ak7n6tan.js");y=Q(y).code;let{hasUserImports:nt,bundleClientScript:bt}=await import("./chunk-gmceftkr.js");if(nt(y))y=await bt(y,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:F}=await import("./chunk-qg2hpx3z.js");y=F(y)}let dt=$t(y);if(!X){let{extractBridgeData:F,generateServerDataBridge:Q}=await import("./chunk-ak7n6tan.js"),nt=Q(y,F(b));if(nt)y=`${nt}
|
|
48
48
|
${y}`}if(dt&&!X){P=!0,M=ut(r,t);let F=T(y),Q=gt(F,M);I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-
|
|
50
|
-
`}}if(z.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-
|
|
51
|
-
`+V;if(I)
|
|
52
|
-
`+I;return
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-td2s7pz1.js");await F(y,b,r)}catch(F){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,F)}if(!X&&!dt){let F=K.replace(/\bclient\b/i,"").trim();M=ut(r,t);let Q=T(y),nt=gt(Q,M);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(nt))tt=!0;I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}"${F?` ${F}`:""}>${nt}</script>
|
|
50
|
+
`}}if(z.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-m5k44pc8.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(K,y)=>{let X=z[Number(y)];return`<script${X.attrs}>${v(X.body,b,h)}</script>`})}if(M){let v=It(o,M);if(o=v.html,v.mergedIntoExisting){let y=M,X=v.mergedIntoExisting;I=I.split(`'${y}'`).join(`'${X}'`).split(`"${y}"`).join(`"${X}"`),M=X}else if(!v.stamped&&P&&!lt.has(r))lt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(v.stamped&&v.root!=="body"&&(P||tt)&&!pt.has(r)){let y=df(o);if(y.length>1)pt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares ${P?"signals":"bindings"} and has ${y.length} top-level elements (${y.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let K=v.stamped&&v.root!==null&&mr(v.root);I=Rt(I,K?M:null)}if(o.includes("@include")||o.includes("@partial"))o=await Kr(o,b,r,i,S,s);let{processLoops:rt,reportDeferredLoopWarnings:ot}=await import("./chunk-gjsmny7t.js"),J=rt(o,b,r,void 0,!0);J=re(J,b,r),J=ot(J);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-w9kak6aj.js");if(J=ht(J,b,r,i),J=_t(J,b,r),J=xt(J,b,r,i),J=x(J,b,r),V)J+=`
|
|
51
|
+
`+V;if(I)J+=`
|
|
52
|
+
`+I;return J}catch(d){if(d instanceof U)throw d;let o=d instanceof Error?d.message:String(d);return j(h,`Error processing include ${h}: ${o}`,_,g)}}let Y=/@include\s*\(/g,H;while((H=Y.exec(e))!==null){let h=H.index,k=h+H[0].length-1,_=1,g=k+1;while(g<e.length&&_>0){if(e[g]==="(")_++;else if(e[g]===")")_--;g++}if(_!==0)break;let r=e.substring(h,g),w=e.substring(k+1,g-1),d=w.match(/^\s*['"]([^'"]+)['"]/);if(!d){Y.lastIndex=g;continue}let o=d[1],O,W=w.substring(d[0].length),R=at(W,0);if(R!==-1)O=W.substring(R+1).trim();let V={};if(O)try{V=E(O,t)}catch(b){let q=b instanceof Error?b.message:String(b);e=e.replace(r,m("Include",`Error parsing include variables for ${o}: ${q}`,c,a,h)),Y.lastIndex=0;continue}let z=await et(o,V,a,h);e=e.substring(0,h)+z+e.substring(g),Y.lastIndex=0}return e}function Xr(a,t){let c=a;function i(S,s,f,e){let D=S,Z=!0;while(Z){Z=!1;let it=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),j=D.match(it);if(!j||j.index===void 0)break;let et=j.index,Y=j[1],H=et+j[0].length,h=new RegExp(`@${s}\\(`),k=new RegExp(`@${f}(?![a-z])`),_=1,g=H,r=-1;while(_>0&&g<D.length){let d=D.slice(g),o=d.match(h),O=d.match(k),W=o?g+o.index:1/0,R=O?g+O.index:1/0;if(W<R)_++,g=W+(o[0].length||1);else if(R<1/0){if(_--,_===0){r=R;break}g=R+f.length+1}else break}if(r===-1)break;let w=D.slice(H,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(w);else t[Y].push(w);D=D.substring(0,et)+D.substring(r+`@${f}`.length),Z=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function Jr(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
54
|
-
export{Zm,df,
|
|
54
|
+
export{Zm,df,Ge,za,Qm,Kr,Xr,Jr};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{hg}from"./chunk-z9j93yk8.js";import"./chunk-h0m8ccfk.js";import"./chunk-yeqszxaz.js";import"./chunk-bsr9wnq4.js";import"./chunk-yrvctbgh.js";import"./chunk-qpb02n0q.js";import"./chunk-pd1b2701.js";import"./chunk-cbdyns7r.js";import"./chunk-kw4afzfh.js";import"./chunk-9j1s520t.js";import"./chunk-vfjenjez.js";import"./chunk-t8ezn4vq.js";import"./chunk-7xv4xa3c.js";import"./chunk-7defwkm1.js";import"./chunk-2p34qf9c.js";import"./chunk-fgr56q3w.js";import"./chunk-p78v88ng.js";import"./chunk-m4j9gedb.js";import"./chunk-t4jr8adw.js";import"./chunk-ddw8tpdd.js";import"./chunk-3392k9vm.js";import"./chunk-xc03cdet.js";import"./chunk-k7pmzreg.js";import"./chunk-2nqt1m3m.js";export{hg as startInteractive};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{eo,Am,Pm}from"./chunk-t0bn8qgj.js";import"./chunk-sphfqm8e.js";import"./chunk-91mv8zwk.js";import"./chunk-n2ema4wf.js";import"./chunk-kw4afzfh.js";import"./chunk-9j1s520t.js";import"./chunk-vfjenjez.js";import"./chunk-7xv4xa3c.js";import"./chunk-7defwkm1.js";import"./chunk-2p34qf9c.js";import"./chunk-fgr56q3w.js";import"./chunk-p78v88ng.js";import"./chunk-m4j9gedb.js";import"./chunk-t4jr8adw.js";import"./chunk-ddw8tpdd.js";import"./chunk-3392k9vm.js";import"./chunk-xc03cdet.js";import"./chunk-k7pmzreg.js";import"./chunk-2nqt1m3m.js";export{Pm as clearComposableCache,Am as getComposableScript,eo as listComposableModules};
|