@stacksjs/stx 0.2.667 → 0.2.669
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-ec9ztgxx.js → chunk-03wssg2z.js} +1 -1
- package/dist/{chunk-r883qzmx.js → chunk-0q0tpmr5.js} +1 -1
- package/dist/chunk-0zrskbkk.js +2 -0
- package/dist/{chunk-8gy90n5q.js → chunk-144yp2bw.js} +1 -1
- package/dist/{chunk-b54s3qde.js → chunk-1cnwcn01.js} +1 -1
- package/dist/{chunk-mekhzhes.js → chunk-1mz8fw0m.js} +4 -4
- package/dist/chunk-21jz51jg.js +2 -0
- package/dist/chunk-2bspyg11.js +2 -0
- package/dist/{chunk-f62hpbw8.js → chunk-43r0hjne.js} +1 -1
- package/dist/{chunk-t886718q.js → chunk-4b1ed4qv.js} +1 -1
- package/dist/chunk-5hqrw558.js +2 -0
- package/dist/{chunk-bj2xzkv6.js → chunk-5j970c0z.js} +1 -1
- package/dist/{chunk-b42p0kvz.js → chunk-5pe26hxm.js} +1 -1
- package/dist/{chunk-an6y1v5h.js → chunk-604yfrmq.js} +1 -1
- package/dist/{chunk-j045bcpb.js → chunk-679tc0c4.js} +1 -1
- package/dist/{chunk-fbcp9hm4.js → chunk-7n7078xp.js} +1 -1
- package/dist/chunk-7nsb5pxp.js +2 -0
- package/dist/chunk-7tp1j22e.js +2 -0
- package/dist/{chunk-qrq88ng0.js → chunk-87bs5f18.js} +1 -1
- package/dist/{chunk-mn3mc6ax.js → chunk-8rx1bves.js} +1 -1
- package/dist/{chunk-wpsm2p9x.js → chunk-8w9z30yx.js} +1 -1
- package/dist/{chunk-bey0cjrp.js → chunk-9hngzqp5.js} +1 -1
- package/dist/{chunk-bs7hq5a3.js → chunk-ackk8wq5.js} +1 -1
- package/dist/{chunk-gjck0t32.js → chunk-b5ktzth7.js} +5 -5
- package/dist/{chunk-gfmw85vw.js → chunk-b7vz9m5q.js} +1 -1
- package/dist/{chunk-yphmswg3.js → chunk-bmd035rk.js} +1 -1
- package/dist/{chunk-wfjq9ww1.js → chunk-cca86043.js} +1 -1
- package/dist/{chunk-6jwey47v.js → chunk-d2zzqfgq.js} +2 -2
- package/dist/{chunk-6h06rqmj.js → chunk-d5d1b6w0.js} +1 -1
- package/dist/{chunk-4htp92hr.js → chunk-e7wxt37f.js} +1 -1
- package/dist/{chunk-jzy0pqez.js → chunk-ea7ekakt.js} +4 -4
- package/dist/{chunk-4701f9eh.js → chunk-ev0t17cq.js} +1 -1
- package/dist/{chunk-rns1e0c5.js → chunk-fpbff6s1.js} +1 -1
- package/dist/{chunk-n5r1xek6.js → chunk-gea2ty3e.js} +1 -1
- package/dist/{chunk-ydf4fmr6.js → chunk-gmgdmsdz.js} +1 -1
- package/dist/{chunk-ghsmfkq9.js → chunk-hesyghn7.js} +1 -1
- package/dist/chunk-hnx88y3p.js +130 -0
- package/dist/{chunk-sgj6dt85.js → chunk-j10smv8e.js} +1 -1
- package/dist/{chunk-znb4y12p.js → chunk-jf1vs526.js} +2 -2
- package/dist/{chunk-dvrndj0q.js → chunk-jsqh5fyn.js} +1 -1
- package/dist/{chunk-85sa9q09.js → chunk-jz6t1nes.js} +1 -1
- package/dist/{chunk-bexp6dsp.js → chunk-kd6qactf.js} +2 -2
- package/dist/{chunk-w51q85zg.js → chunk-ken0q08p.js} +5 -5
- package/dist/chunk-kff0hgg5.js +2 -0
- package/dist/chunk-m1ggzh60.js +2 -0
- package/dist/{chunk-fwwt7nrc.js → chunk-mezzmwc5.js} +1 -1
- package/dist/chunk-msm3gqay.js +2 -0
- package/dist/{chunk-qxsvd26z.js → chunk-ndhkwfyq.js} +1 -1
- package/dist/{chunk-t226hswj.js → chunk-nt7jxmpy.js} +1 -1
- package/dist/{chunk-hjn7qqrq.js → chunk-nx6d1hj7.js} +1 -1
- package/dist/{chunk-fsef9nvs.js → chunk-nytb5e4v.js} +2 -2
- package/dist/{chunk-4qh789bq.js → chunk-nzj3a6mj.js} +1 -1
- package/dist/{chunk-c7d09931.js → chunk-p23sz4rr.js} +6 -6
- package/dist/{chunk-1y5ampxc.js → chunk-p5sjezzx.js} +1 -1
- package/dist/{chunk-ndffc344.js → chunk-xrdrwrfe.js} +1 -1
- package/dist/chunk-y1kaq1cd.js +2 -0
- package/dist/{chunk-1ffjj2c6.js → chunk-ynyssmdy.js} +2 -2
- package/dist/{chunk-hc70e121.js → chunk-ys3tmk8w.js} +1 -1
- package/dist/{chunk-crcypbbq.js → chunk-ywqs7x8g.js} +1 -1
- package/dist/{chunk-zx2vhrps.js → chunk-zshhn7nz.js} +1 -1
- package/dist/{chunk-j7mr8h2w.js → chunk-ztp2rgpp.js} +2 -2
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/headwind-to-style.js +24 -1
- package/dist/native/compiler/html-to-ir.js +44 -2
- package/dist/native/compiler/layout-chrome.js +51 -4
- package/dist/native/runtime/jsc-globals.d.ts +20 -0
- package/dist/native/runtime/jsc-globals.js +52 -0
- package/dist/native/testing.d.ts +0 -1
- package/dist/native/testing.js +31 -4
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-0syr525r.js +0 -2
- package/dist/chunk-2265dwpm.js +0 -2
- package/dist/chunk-4s284y6c.js +0 -2
- package/dist/chunk-7y2htsr8.js +0 -2
- package/dist/chunk-bheh3z8r.js +0 -2
- package/dist/chunk-dq42tzg1.js +0 -2
- package/dist/chunk-fmzhrwt1.js +0 -2
- package/dist/chunk-fqhmee37.js +0 -129
- package/dist/chunk-hqwr25qg.js +0 -2
- package/dist/chunk-m72b5043.js +0 -2
- package/dist/chunk-w1qvq9jf.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import{g}from"./chunk-
|
|
2
|
+
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import{g}from"./chunk-p23sz4rr.js";import"./chunk-2dp7hyv7.js";import"./chunk-1sr6c0nk.js";import"./chunk-144yp2bw.js";import{Bt,$s,Ft,ai,ot,ci,Rs,zt,ui,Ht}from"./chunk-pn1ehs6a.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()=>{ci("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-y1kaq1cd.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-y1kaq1cd.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 zt(t);at(t,r);let s=Ht(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=ui(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);at(t,m);let f=Ht(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,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_o,Ea,r,Et,te,S,Ae,on,Pe,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Oe,Ne,ms,Le,n,pn,m,d,F,K,ve,k,_}from"./chunk-
|
|
2
|
+
import{_o,Ea,r,Et,te,S,Ae,on,Pe,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Oe,Ne,ms,Le,n,pn,m,d,F,K,ve,k,_}from"./chunk-p23sz4rr.js";import{l,p,E,t,re,z,a,we,zo,D,hn,Ho,Mt,Vo,ec,pr,tc,rt,nc,fr,rc,yn,Uo,sc,gr,hr,xe,Wo}from"./chunk-2dp7hyv7.js";import{Ot}from"./chunk-1sr6c0nk.js";import{gn}from"./chunk-144yp2bw.js";import{h}from"./chunk-ztp2rgpp.js";import{er,ts}from"./chunk-365vg0eg.js";import{ua,da,Yn,Xe,pa,R}from"./chunk-nytb5e4v.js";import{mo,ho,yo,bo}from"./chunk-fzqj1mjz.js";import{oa,Br}from"./chunk-nx6d1hj7.js";import{Dr,Mr,Lr}from"./chunk-1mz8fw0m.js";import{Nr,qn}from"./chunk-nzj3a6mj.js";import{Fr,io,ao,zr,Hr,co}from"./chunk-ynyssmdy.js";import{Zs}from"./chunk-prf164ct.js";import{ee,no,ro,so}from"./chunk-ka8befem.js";import{Gn,ge,aa,Kn,ca}from"./chunk-ea7ekakt.js";import{U,Ge}from"./chunk-bnn7pd62.js";import{fa,ga}from"./chunk-nt7jxmpy.js";import{C,bn,qo}from"./chunk-fbtv2k1p.js";import fs from"fs";import ce from"path";function lt(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -854,13 +854,13 @@ ${I}
|
|
|
854
854
|
</style>`;o=o.replace(x,P),v.lastIndex=0}catch(I){}}}return o}import it from"path";var cs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ls=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ds(c,e){if(!e||!c.includes("/"))return c;let u=it.dirname(e);return c.replace(cs,(o,g,i,f)=>{let v=it.resolve(u,f);return`${g}${i}${v.split(it.sep).join("/")}${i}`})}function dn(c,e){if(!e||!c.includes("<script"))return c;return c.replace(ls,(u,o,g,i)=>`${o}${ds(g,e)}${i}`)}var _e="<!--PARENT_CONTENT_PLACEHOLDER-->";function fn(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Sn(c,e){let u=c.length,o=e,g=!0,i=[],f=(v)=>v+9<=u&&c[v]==="<"&&c[v+1]==="/"&&(c[v+2]==="s"||c[v+2]==="S")&&(c[v+3]==="c"||c[v+3]==="C")&&(c[v+4]==="r"||c[v+4]==="R")&&(c[v+5]==="i"||c[v+5]==="I")&&(c[v+6]==="p"||c[v+6]==="P")&&(c[v+7]==="t"||c[v+7]==="T")&&(c[v+8]===">"||/\s/.test(c[v+8]));while(o<u){let v=c[o];if(f(o))return o;if(v==="/"&&c[o+1]==="/"){if(o=c.indexOf(`
|
|
855
855
|
`,o+2),o===-1)return-1;o+=1,g=!0;continue}if(v==="/"&&c[o+1]==="*"){let y=c.indexOf("*/",o+2);if(y===-1)return-1;o=y+2,g=!0;continue}if(v==="/"&&g){let y=o+1,x=!1;while(y<u){let b=c[y];if(b==="\\"){y+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){y++;break}else if(b===`
|
|
856
856
|
`){y=-1;break}y++}if(y===-1){o++,g=!1;continue}while(y<u&&/[a-z]/.test(c[y]))y++;o=y,g=!1;continue}if(v==="'"||v==='"'){let y=v;o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]===y){o++;break}if(c[o]===`
|
|
857
|
-
`)break;o++}g=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}if(i.length===0)g=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,g=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let g=o.index+o[0].length,i=c.indexOf("</script>",g);if(i===-1)return null;let f=c.indexOf(">",i);if(f===-1)return null;return{start:o.index,end:f+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-
|
|
857
|
+
`)break;o++}g=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}if(i.length===0)g=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,g=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let g=o.index+o[0].length,i=c.indexOf("</script>",g);if(i===-1)return null;let f=c.indexOf(">",i);if(f===-1)return null;return{start:o.index,end:f+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-jsqh5fyn.js");return`<script ${c} src="${o(e)}"></script>`}async function Hn(c,e,u){try{let{registeredModuleIdsIn:o,buildModuleRegistryScript:g}=await r("stx/client-module-registry",()=>import("./chunk-xrdrwrfe.js")),i=[],f=await g(o(...c),{minify:qo(e.buildMode),collectInputs:i});for(let v of i)u?.add(v);if(!f)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-jsqh5fyn.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(f)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${f.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ys(c,e=""){let u=$n(c,"data-stx-runtime");if(!u)return c;let o=Gn(c);if(o===-1||o===u.start){if(!e)return c;return c.slice(0,u.end)+e+c.slice(u.end)}if(o<u.start)return c.slice(0,o)+c.slice(u.start,u.end)+e+`
|
|
858
858
|
`+c.slice(o,u.start)+c.slice(u.end);let g=c.slice(u.start,u.end),i=c.slice(0,u.start)+c.slice(u.end),f=Gn(i);if(f===-1)return g+e+`
|
|
859
859
|
`+i;return i.slice(0,f)+g+e+`
|
|
860
860
|
`+i.slice(f)}function vs(c){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return c.replace(e,(u,o,g)=>{let i=c.slice(0,g);return i.lastIndexOf("<")>i.lastIndexOf(">")?`{{${o}}}`:`{<!--stx-literal-->{${o}}}`})}async function s(c,e,u,o,g){if(o.ssr===!1&&!o.autoShell&&o.buildMode==="spa")return c;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=ve(c,u);let i=!e.__stxProcessingDepth;ln(e);for(let f of o._layerGraph?.configDependencies??[])g.add(f);if(i&&o.runtimeConfig)await gn(e,u,o.runtimeConfig);if(i)za(e),e.__stx_scope_seq??={n:0,key:ms(String(e.__filename??u))},e.__stx_head_injections=Vo(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((o.debug||!C()&&!bn())&&u&&u.endsWith(".stx"))Zs(c,u);try{return await te.timeAsync("template-processing",async()=>{let f=await bs(c,e,u,o,g);if(i)f=Ao(f);if(i&&o.autoShell&&o.buildMode!=="compile"){let v=xe(o.app?.head,{known:hr,source:"app.head"}),x=(e.__stx_runtime_head||null)??Wo(),b=(e.__stx_head_raw||"").trim(),w,T=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(T)w=T[1].trim(),b=b.replace(T[0],"").trim();let A=e.__sections?.title,O=A?k(A,e,u):void 0,M=x.title||w||O,I=!x.title&&(!!w||!!O),P=x.meta||[],N=new Set(P.map((G)=>rt(G)).filter(Boolean)),V={...v,...M&&{title:M},meta:[...(v.meta||[]).filter((G)=>!N.has(rt(G))),...P],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
|
|
861
861
|
`),...x.htmlAttrs&&{htmlAttrs:nc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},X=Uo(f);if(f=gr(f,V,{...I&&{titleIsHtml:!0},...o.app?.colorMode&&{colorMode:o.app.colorMode}},X),X)f=sc(f,v),f=fr(f,V.htmlAttrs);let L=f.match(/<!-- stx-layout: ([^ ]+) -->/);if(L&&f.includes("<head")){let G=L[1],J=ts(G);f=f.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
|
|
862
862
|
<meta name="stx-layout" content="${fn(G)}">
|
|
863
|
-
<meta name="stx-layout-group" content="${fn(J)}">`)}let j=f.match(/function (__stx_setup_\w+)\(/),H=j?U(f):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){f=Ge(f,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");f=f.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(f);if(y!==null)v.beforeClose.push(y);let x=tn(f);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!f.includes("data-stx-offline"))v.beforeClose.push(nn);f=ec(f,v);let b=o.app?.colorMode;if(b)f=pr(f,b)}if(i)if($n(f,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-
|
|
863
|
+
<meta name="stx-layout-group" content="${fn(J)}">`)}let j=f.match(/function (__stx_setup_\w+)\(/),H=j?U(f):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){f=Ge(f,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");f=f.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(f);if(y!==null)v.beforeClose.push(y);let x=tn(f);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!f.includes("data-stx-offline"))v.beforeClose.push(nn);f=ec(f,v);let b=o.app?.colorMode;if(b)f=pr(f,b)}if(i)if($n(f,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-m1ggzh60.js")),M=o.storesDir,I=await O(M);if(I)b=`<script data-stx-stores>${I}</script>`,x=await mn("data-stx-stores",I,o)??b}catch{}y=await Hn([f,b],o,g);try{let{getFrameworkComposableScript:O}=await r("stx/framework-composables",()=>import("./chunk-jz6t1nes.js"));T=await O(f)}catch{}try{let{getComposableScript:O}=await r("stx/composable-loader",()=>import("./chunk-0zrskbkk.js")),M=o.composablesDir,I=[y,b,T].filter((N)=>N!==null),P=await O(o._layerComposableDirs??M,f,I);if(P)w=await mn('data-stx-scoped data-stx-run="always" data-stx-composables',P,o)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${P}</script>`}catch{}let A=[y,x,w,T].filter((O)=>O!==null).map((O)=>`
|
|
864
864
|
${O}`).join("");f=ys(f,A)}else{let y=await Hn([f],o,g);if(y){let x=f.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)f=f.slice(0,x)+y+`
|
|
865
865
|
`+f.slice(x)}}if(i)f=tc(f);if(i&&e.__stx_inject_css!==!1)f=await h(f,void 0,o.buildMode==="serve",!0);else if(i)f=an(f);if(f=f.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),f=vs(f),i&&e.__stx_runtime_config)f=Ot(f,e.__stx_runtime_config);if(i&&!e.__stx_defer_server_data){let v=cr(e);if(v){let y=/<head\b[^>]*>/i.exec(f),x=y?y.index+y[0].length:0;f=f.slice(0,x)+v+f.slice(x)}}return f})}catch(f){if(f instanceof z)throw f;let v=f instanceof Error?f.message:String(f),y=new re(`Template processing failed: ${v}`,u,void 0,void 0,c.substring(0,200)+(c.length>200?"...":""));if(D.log(y,{filePath:u,context:e}),hn.logDetailedError(y,{filePath:u,template:c.substring(0,500)}),C()&&!o.debug)console.error(`[stx] ${ce.relative(process.cwd(),u)||u}: ${y.message}`);if(o.debug)throw y;return zo.createFallbackContent("Template Processing",y)}}async function bs(c,e,u,o,g){let i=process.cwd(),f={...o,partialsDir:o.partialsDir&&!ce.isAbsolute(o.partialsDir)?ce.resolve(i,o.partialsDir):o.partialsDir,componentsDir:o.componentsDir&&!ce.isAbsolute(o.componentsDir)?ce.resolve(i,o.componentsDir):o.componentsDir,layoutsDir:o.layoutsDir&&!ce.isAbsolute(o.layoutsDir)?ce.resolve(i,o.layoutsDir):o.layoutsDir},v=f,y=c;await ks(u,e),xs(e,v),y=await we(()=>zt(y,e,u,v),y,(L)=>{D.log(L,{filePath:u,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${u}: ${L.message}`)}),y=y.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=le(y,Pe,(L,j)=>`\x00STX_HTML_COMMENT_${j}\x00`);y=x.output;let b=x.tokens,w=(L)=>b.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(j,H)=>b[Number(H)]??""),T="\x00STX_ESCAPED_AT\x00",A="\x00STX_ESC_MUSTACHE_OPEN\x00",O="\x00STX_ESC_MUSTACHE_CLOSE\x00";y=y.replace(/@@/g,T),y=y.replace(/@\{\{([\s\S]*?)\}\}/g,(L,j)=>`${A}${j}${O}`),y=Jt(y),y=await un(y,u,g);let M={};y=Mr(y,M);let I={...e.__sections||{}},P="",N=mt(gt(c)),V=/@nolayout\b/.test(y)||N===!1;if(/@nolayout\b/.test(y))y=y.replace(/@nolayout\b\s*/g,"");let X=y.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(X)P=X[1],y=y.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(P=N,!/@section\s*\(/.test(y))y=`@section('content')
|
|
866
866
|
${y.trim()}
|
|
@@ -869,7 +869,7 @@ ${y.trim()}
|
|
|
869
869
|
@endsection`}}if(P&&y.includes("<script")){let L=q(y),j=L.scripts.map((H)=>vn(H,u)??H);y=or(L.output,j)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,j,H)=>(I[j]=H,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,j,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return L;try{let G=l(H.trim(),e);if(G===void 0)return L;let Y=(e.__stx_inline_section_values??=[]).push(G)-1;return I[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return L}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,j,H)=>{if(H.includes("@parent"))I[j]=H.replace("@parent",_e);else I[j]=H.trim();return""}),e.__sections=I,y=y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,j,H)=>I[j]||H||""),!("slot"in e)||e.slot===void 0)y=y.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||"");if(y=Lr(y,M),P){let L=[],j=q(y),H=le(j.output,on,(G,J)=>`\x00STX_ORPHAN_STYLE_${J}\x00`);if(y=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(G,J,Y)=>{let ne=J==="SCRIPT"?vn(j.scripts[Number(Y)],u):H.tokens[Number(Y)];if(ne)L.push(ne);return""}),L.length>0){let G=L.join(`
|
|
870
870
|
`);I.content=I.content?`${I.content}
|
|
871
871
|
${G}`:G,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,g.add(P);else L=await we(()=>pn(P,u,f,g),null,()=>{throw new re(`Failed to resolve layout path: ${P}`,u,void 0,void 0,`Layout referenced from ${u}`)});if(!L){let ne=(oe)=>{if(!oe)return[];try{let ae=ce.isAbsolute(oe)?oe:ce.resolve(process.cwd(),oe);return fs.readdirSync(ae).filter((ue)=>ue.endsWith(".stx")).map((ue)=>ue.replace(/\.stx$/,""))}catch{return[]}},se=[...ne(f.layoutsDir),...ne(f.fallbackLayoutsDir)].filter((oe,ae,ue)=>ue.indexOf(oe)===ae).sort(),de=`Layout not found: ${P} (referenced from ${u})`+(se.length>0?`. Available layouts: ${se.join(", ")}`:f.layoutsDir?`. No .stx layouts found in ${f.layoutsDir}`:"");if(D.log(Error(de),{layoutPath:P,filePath:u,available:se},"error"),console.error(`[stx] ${de}`),f.debug)throw new re(de,u);return y}let j=await we(()=>Bun.file(L).text(),"",()=>{throw new re(`Failed to read layout file: ${L}`,u,void 0,void 0,"Layout content could not be loaded")});j=dn(j,L);let H=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(f.debug)console.log(`Found nested layout: ${H[1]} in ${L}`);let ne={},se=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ae,ue,ke)=>(ne[ue]=ke.trim(),""));for(let[ae,ue]of Object.entries(ne))if(I[ae]&&I[ae].includes(_e)){let ke=I[ae].indexOf(_e);I[ae]=I[ae].slice(0,ke)+ue+I[ae].slice(ke+_e.length)}else if(!I[ae])I[ae]=ue;let de={...e,__sections:I},oe=`@layout('${H[1]}')${se}`;return await s(oe,de,L,f,g)}let G=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),J=Mr(G,M),Y={};return J=J.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ne,se,de)=>(Y[se]=de.trim(),`@slot('${se}')`)),J=J.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ne,se,de)=>{if(I[se]){let oe=I[se];if(oe.includes(_e)){let ae=Y[se]||"",ue=oe.indexOf(_e);oe=oe.slice(0,ue)+ae+oe.slice(ue+_e.length)}return oe}return de||""}),J=ws(J,I),J=J.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||""),J=Lr(J,M),e.__originalFilePath=u,y=await kn(J,e,L,f,g),y=`<!-- stx-layout: ${P} -->
|
|
872
|
-
${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,g)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[g,i]of Object.entries(process.env))if(g.startsWith(u)&&i!==void 0)o[g]=i;c.$env=o}async function ks(c,e){await we(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:g}=await r("stx/signal-processing",()=>import("./chunk-
|
|
872
|
+
${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,g)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[g,i]of Object.entries(process.env))if(g.startsWith(u)&&i!==void 0)o[g]=i;c.$env=o}async function ks(c,e){await we(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:g}=await r("stx/signal-processing",()=>import("./chunk-ackk8wq5.js")),i=[],f=!C()&&!bn();for(let y of g(c)){let x=y.attrs;if(!/\bserver\b/.test(x))continue;let b=y.start+y.fullMatch.indexOf(">")+1,w=Sn(c,b);if(w===-1)continue;let T=c.slice(b,w);if(!T.trim())continue;let A=Ss(x)??u,O={index:y.start,length:w+9-y.start};try{let{extractVariables:M}=await r("stx/variable-extractor",()=>import("./chunk-9hngzqp5.js"));await M(T,e,A,{preserveExisting:!0,onFailure:(I)=>{if(I.kind==="unknown")return;if(o?.onServerScriptError?.({sourcePath:A,kind:I.kind,message:I.message}),!f)return;i.push({...O,markup:xn(A,I.kind,I.message)})}})}catch(M){let I=M instanceof Error?M:Error(String(M));if(D.log(I,{filePath:A,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${A}: ${I.message}`),f)i.push({...O,markup:xn(A,"unknown",I.message)})}}if(i.length===0)return c;let v=c;for(let y of i.sort((x,b)=>b.index-x.index))v=v.slice(0,y.index)+y.markup+v.slice(y.index+y.length);return v}async function Es(c,e,u){try{let{interpolateScriptsInTemplate:o}=await r("stx/expressions",()=>import("./chunk-zshhn7nz.js"));return o(c,e,{skipServer:!0})}catch(o){let g=o instanceof Error?o:Error(String(o));return D.log(g,{filePath:u,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${u}: ${g.message}`),c}}async function kn(c,e,u,o,g){let i=c,f=o;if(i=await $s(i,e,u,o),i=await Bt(i,e,u),i=await Ft(i,e,u),i=await Es(i,e,u),i=await At(i,e,u,f),ve(i))i=io(i,e),i=Hr(i,e),i=zr(i,e);i=ao(i);let{processStreamDirectives:v}=await r("stx/streaming",()=>import("./chunk-5hqrw558.js"));i=v(i,e),i=qn(i,e,u,f,!0),i=await en(i,e,u,f,g),i=await Br(i,e,u,f,g),i=ua(i,e,u,f);let{processDeferDirectives:y}=await r("stx/defer",()=>import("./chunk-2f17h17f.js"));i=y(i,e,u);let{processTeleportDirectives:x}=await r("stx/teleport",()=>import("./chunk-wq712sw1.js"));i=x(i,e,u);let{processTransitionDirectives:b,processTransitionAttributes:w}=await r("stx/transitions",()=>import("./chunk-k2pa44rf.js"));i=b(i,e,u),i=w(i);let{processErrorBoundaryDirectives:T,stripRenderFailedMarkers:A}=await r("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));i=T(i,e,u),i=A(i);let{processSuspenseDirectives:O}=await r("stx/suspense",()=>import("./chunk-weqc0ssb.js"));i=O(i,e,u);let{processAsyncDirectives:M}=await r("stx/async-components",()=>import("./chunk-67kj14at.js"));i=M(i,e,u);let{processKeepAliveDirectives:I}=await r("stx/keep-alive",()=>import("./chunk-6vzktvyw.js"));i=I(i,e,u);let{processVirtualListDirectives:P,processVirtualGridDirectives:N,processInfiniteListDirectives:V}=await r("stx/virtual-scrolling",()=>import("./chunk-sf0wsq74.js"));i=P(i,e,u),i=N(i,e,u),i=V(i,e,u);let{processPartialHydrationDirectives:X,processStaticDirectives:L}=await r("stx/partial-hydration",()=>import("./chunk-9szxxgv5.js"));i=X(i,e,u),i=L(i);let{processComputedDirectives:j,processWatchDirectives:H}=await r("stx/computed",()=>import("./chunk-1xdzcy9d.js"));i=j(i,e,u),i=H(i,e,u);let{processFormValidationDirectives:G}=await r("stx/forms-validation",()=>import("./chunk-604yfrmq.js"));i=G(i,e,u);let{processHeadDirective:J,processTitleDirective:Y,processMetaDirective:ne,resetHead:se}=await r("stx/head",()=>import("./chunk-e1fetwbr.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)se();let de=J(i);if(i=de.content,de.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${de.headContent}
|
|
873
873
|
`;if(i=Y(i,e),i=ne(i,e,u),i=Xt(i),i=no(i,e),i=Ct(i),i=Ut(i),i=await Dr(i,e,u,f,g),i=await Br(i,e,u,f,g),e.__stxProcessingDepth===1)i=Ha(i,e);if(i=i.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),i=Ao(i),i=ee(i,e,u),i=Nr(i),i=La(i,e,{filePath:u,buildMode:f.buildMode}),i=ro(i,e),i=so(i,e),i=ze(i,e),i=Nt(i,e),i=Ht(i,e),i=await bt(i,e,u,f),i=await pa(i,e,u),i=await fa(i,e,u,f),i=ga(i,e,u,f),i=mo(i,e,u,f),i=ho(i,e,u),i=yo(i,e,u,f),i=_t(i,e,u,f),i=ps(i,e),i=gs(i),i=ja(i),!f.skipEventDirectives)i=Ea(i,e,u);if(i=vt(i,e,u),f.debug){let B=/\bx-data\s*=/.test(i),W=Fr(c);if(B&&W)console.warn(`[stx] ${u}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
874
874
|
Both work on the same page, but they manage separate scopes.
|
|
875
875
|
Prefer signals (state/derived/effect) for new components.`)}i=oa(i,e),i=await k(i,e,u),i=Ba(i),i=Fa(i),i=pt(i);let{processXElementDirectives:oe}=await r("stx/x-element",()=>import("./chunk-zhxdpzga.js"));i=oe(i);let ae=e.__originalFilePath||u,ue=Oe(e);if(i=await co(i,f,ae,ue),i=Pt(i,e),i=await Wt(i,e,u,f),f.media?.image?.autoSiblings){let B=f.publicDir||"public",{rewriteImagesWithSiblings:W}=await r("stx/image-optimization/auto-sibling",()=>import("./chunk-shpc1ttk.js"));i=await W(i,{publicDir:B})}if(f.seo?.enabled)i=bo(i,e,f);let ke=(B,W,Z=!0)=>{if(!W)return B;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),ie=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(B),fe=ie?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(ie[0]):null;if(he&&ie&&fe){if(Z){let Ce=ie.index+fe.index;B=B.slice(0,Ce)+he[0]+B.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return B}if(/<\/head>/i.test(B))return B.replace(/<\/head>/i,`${W}
|
|
@@ -883,6 +883,6 @@ ${lt()}
|
|
|
883
883
|
`+Ce}else i=i.replace("</head>",`${W}
|
|
884
884
|
</head>`)}else if(i.includes("<body"))i=i.replace(/<body([^>]*)>/,`<body$1>
|
|
885
885
|
${W}`);else i=W+`
|
|
886
|
-
`+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-
|
|
886
|
+
`+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-ackk8wq5.js")),W=[];for(let Z of B(i)){if(!/\bserver\b/i.test(Z.attrs))continue;let he=Z.start+Z.fullMatch.indexOf(">")+1,ie=Sn(i,he);if(ie===-1)continue;let fe=ie+9;while(fe<i.length&&/\s/.test(i[fe]))fe++;W.push({start:Z.start,end:fe})}if(W.length>0){let Z=Array(W.length+1),he=0;for(let ie=0;ie<W.length;ie++){let{start:fe,end:Ce}=W[ie];Z[ie]=i.slice(he,fe),he=Ce}Z[W.length]=i.slice(he),i=Z.join("")}}let at=us(i,u);if(at.hasScoped)i=at.html;let Rn=e.__stx_event_bindings||[],Ke=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(i),{scanScriptTags:Dn}=await r("stx/signal-processing",()=>import("./chunk-ackk8wq5.js"));for(let B of Dn(i,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:B.fullMatch,attrs:B.attrs,content:B.body});for(let{match:B,attrs:W,content:Z}of ct){Ke=!0;let he=Z;Ae(Z,u,o.strict,e.__originalFilePath);let ie=await Ne(Z,{eventBindings:Rn,attrs:W,hasColonDirectives:Mn,templateContent:c,filePath:u,projectRoot:process.cwd(),production:qo(o.buildMode),serverData:ue});i=i.replace(B,()=>ie)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let B=e.__stx_event_bindings||[];if(B.length>0){let W=_o(B);if(W){let Z=i.lastIndexOf("</body>");i=Z===-1?i+W:i.slice(0,Z)+W+`
|
|
887
887
|
`+i.slice(Z)}e.__stx_event_bindings=[]}}if(!ge(i)&&aa(i))i=await Kn(i,f);if(i=ca(i),f.csp?.enabled&&f.csp.useNonce&&typeof e.cspNonce==="string")i=$t(i,e.cspNonce);return i}
|
|
888
888
|
export{gt,Te,ta,Ys,Hn,s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Pc,ki,Iu,Ic,Oc,Ou,Nu}from"./chunk-bmd035rk.js";import"./chunk-679tc0c4.js";import"./chunk-4b1ed4qv.js";import"./chunk-03wssg2z.js";import"./chunk-md2jn67b.js";import"./chunk-ynyssmdy.js";import"./chunk-ea7ekakt.js";import"./chunk-p472crv1.js";import"./chunk-nytb5e4v.js";import"./chunk-nt7jxmpy.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{$t,Fl}from"./chunk-p23sz4rr.js";import"./chunk-144yp2bw.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Pc as buildVirtualSource,$t as extractScriptBlocks,Fl as extractTemplateExpressions,Ic as findRuntimeTypeDeclarations,Oc as findStxModuleDeclarations,Nu as formatTypecheckDiagnostics,Iu as sourcePathFor,Ou as typecheckStxFiles,ki as virtualPathFor};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Bd,Fd}from"./chunk-ndhkwfyq.js";import"./chunk-4b1ed4qv.js";import"./chunk-03wssg2z.js";import"./chunk-md2jn67b.js";import"./chunk-ynyssmdy.js";import"./chunk-ea7ekakt.js";import"./chunk-p472crv1.js";import"./chunk-nytb5e4v.js";import"./chunk-nt7jxmpy.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-p23sz4rr.js";import"./chunk-144yp2bw.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Fd as clearStoreCache,Bd as getStoreScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-p23sz4rr.js";import{s}from"./chunk-ken0q08p.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hi,Vi,Ui,Wi,tp}from"./chunk-e7wxt37f.js";import"./chunk-d2zzqfgq.js";import"./chunk-yfvm7q6t.js";import"./chunk-ken0q08p.js";import"./chunk-ztp2rgpp.js";import"./chunk-prf164ct.js";import"./chunk-nzj3a6mj.js";import"./chunk-1mz8fw0m.js";import"./chunk-nx6d1hj7.js";import"./chunk-ka8befem.js";import"./chunk-ynyssmdy.js";import"./chunk-ea7ekakt.js";import"./chunk-p472crv1.js";import"./chunk-87bs5f18.js";import"./chunk-nytb5e4v.js";import"./chunk-nt7jxmpy.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-p23sz4rr.js";import"./chunk-144yp2bw.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Hi as buildNative,tp as default,Vi as findCraftBinary,Wi as getAvailableFormats,Ui as getAvailableTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-pxdww4rb.js";import{T,vn}from"./chunk-ce6zddpf.js";import{S,G}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-pxdww4rb.js";import{T,vn}from"./chunk-ce6zddpf.js";import{S,G}from"./chunk-p23sz4rr.js";import{o}from"./chunk-nytb5e4v.js";import{Ce,Xt,Jt,Yt}from"./chunk-4b1ed4qv.js";import{ht}from"./chunk-ynyssmdy.js";import{pt,In,Wt,se}from"./chunk-npa7gze7.js";import{C,yr}from"./chunk-fbtv2k1p.js";import p from"path";var a=new Map;function A(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 i of(s[1]??"").split(",")){let l=((i.includes(":")?i.split(":").pop():i)??"").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 i of(s[1]??"").split(",")){let r=i.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Bd(c){let n;if(c)n=p.resolve(c);else{let t=await o();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Jt()}`,i=new Bun.Glob("*.ts"),r=[];try{for await(let t of i.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 se(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ce(t))])],f=pt(l()),d=Wt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return se(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 y=u.map((t)=>t.file),m=[],g=new Set,v=G({loader:"ts",target:"browser",define:S()});for(let t of y)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),Xt(e))e=await Yt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=vn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return se(a,s,f,""),null;let h=m.join(`
|
|
4
4
|
|
|
5
5
|
`),w=`;(function(){
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{E,t,a}from"./chunk-2dp7hyv7.js";import{K}from"./chunk-
|
|
2
|
+
import{E,t,a}from"./chunk-2dp7hyv7.js";import{K}from"./chunk-p23sz4rr.js";import{fo}from"./chunk-a3d0g4mr.js";import C from"path";var S;async function J(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var P={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function G(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function Y(e,s){if({...P,...s.i18n}.cache&&v[e]){let r=v[e],l=s.i18n?.cacheMaxAge??0;if(!G(r,l))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=T(e,s).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function T(e,s){let i={...P,...s.i18n},n=C.isAbsolute(i.translationsDir)?i.translationsDir:C.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await J(),l=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:te(i.format)}):await Z(e,i,n);if(l===void 0){let u=e!==i.defaultLocale?await T(i.defaultLocale,s):{};if(i.cache)v[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=l;if(i.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return T(i.defaultLocale,s);return{}}}async function Z(e,s,i){let n=C.join(i,`${e}${Q(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let l=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return X(l);if(s.format==="json")return JSON.parse(l);throw r}catch{return}}}function Q(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function X(e){let s={},i=e.split(`
|
|
3
3
|
`),n=[{obj:s,indent:-1}];for(let r of i){let l=r.replace(/#.*$/,"").trimEnd();if(!l.trim())continue;let c=l.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,o=l.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(o){let[,,g,p]=o,f=g.trim(),m=p.trim();if(m==="")u[f]={},n.push({obj:u[f],indent:c});else u[f]=ee(m)}}return s}function ee(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let s=e.toLowerCase();if(s==="true"||s==="yes")return!0;if(s==="false"||s==="no")return!1;if(s==="null"||s==="~")return null;let i=Number(e);if(!Number.isNaN(i)&&e!=="")return i;return e}function te(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function re(e,s){return Y(e,s)}function ne(e,s){for(let i of e){let n=i.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(s===c)return r[2];continue}let l=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(l){let c=Number.parseInt(l[1],10),u=l[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(l[2],10);if(s>=c&&s<=u)return l[3];continue}}if(e.length===2)return s===1?e[0].trim():e[1].trim();if(s<e.length)return e[s].trim();return e[e.length-1].trim()}function ie(e,s={}){return j(e,s)}function j(e,s){let i="",n=0;while(n<e.length)if(e[n]==="{"){let r=se(e,n);if(r===-1){i+=e[n],n++;continue}let l=e.slice(n+1,r);i+=ae(l,s),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")i+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")i+=e[n+1],n+=2;else i+=e[n],n++;else i+=e[n],n++;return i}function se(e,s){let i=0;for(let n=s;n<e.length;n++)if(e[n]==="{")i++;else if(e[n]==="}"){if(i--,i===0)return n}return-1}function ae(e,s){let i=oe(e);if(i.length===0)return`{${e}}`;let n=i[0].trim(),r=s[n];if(i.length===1)return r!==void 0?String(r):`{${n}}`;switch(i[1].trim().toLowerCase()){case"plural":return le(r,i.slice(2).join(","),s);case"select":return ue(r,i.slice(2).join(","));case"selectordinal":return de(r,i.slice(2).join(","));case"number":return pe(r,i[2]?.trim());case"date":return fe(r,i[2]?.trim());case"time":return me(r,i[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function oe(e){let s=[],i="",n=0;for(let r=0;r<e.length;r++){let l=e[r];if(l==="{")n++,i+=l;else if(l==="}")n--,i+=l;else if(l===","&&n===0)s.push(i),i="";else i+=l}if(i)s.push(i);return s}function le(e,s,i){let n=Number(e)||0,r=I(s),l=`=${n}`;if(r[l])return R(r[l],n,i);let c=ce(n);if(r[c])return R(r[c],n,i);if(r.other)return R(r.other,n,i);return String(n)}function R(e,s,i){let n=e.replace(/#/g,String(s));return j(n,i)}function ce(e){let s=Math.abs(e),i=Math.floor(s),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(i===1&&n===0)return"one";return"other"}function ue(e,s){let i=String(e||""),n=I(s);if(n[i])return n[i];return n.other||String(e)}function de(e,s){let i=Number(e)||0,n=I(s),r=ge(i);if(n[r])return n[r].replace(/#/g,String(i));if(n.other)return n.other.replace(/#/g,String(i));return String(i)}function ge(e){let s=Math.abs(e),i=s%10,n=s%100;if(i===1&&n!==11)return"one";if(i===2&&n!==12)return"two";if(i===3&&n!==13)return"few";return"other"}function I(e){let s={},i=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=i.exec(e);while(n!==null)s[n[1]]=n[2],n=i.exec(e);return s}function pe(e,s){let i=Number(e);if(Number.isNaN(i))return String(e);switch(s){case"integer":return Math.floor(i).toLocaleString();case"percent":return`${(i*100).toFixed(0)}%`;case"currency":return i.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return i.toLocaleString()}}function fe(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return i.toLocaleDateString(void 0,n)}function me(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return i.toLocaleTimeString(void 0,n)}function be(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,s,i=!0,n={}){let r=e.split("."),l=s;for(let u of r){if(l===void 0||l===null)break;l=l[u]}if(l===void 0||l===null)return i?e:"";let c=String(l);if(be(c))return ie(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),o=c.split("|");c=ne(o,u)}for(let[u,o]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),()=>String(o))}return c}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),he=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function q(e){if(!e)return"ltr";let s=e.trim().toLowerCase().replace(/_/g,"-").split("-"),i=s[0];if(!i)return"ltr";let n=s[1]?.length===4?s[1]:void 0;if(n)return he.has(n)?"rtl":"ltr";if(s.length>1&&D.has(`${i}-${s[1]}`))return"rtl";return D.has(i)?"rtl":"ltr"}async function fa(e,s,i,n){let r=e,l=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...P,...n.i18n},u=await re(c.locale,n);s.__translations=u,s.__locale=c.locale,s.__i18nConfig=c,r=await F(r,l,async(p,f,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>E(m,s)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}let y=O(f,u,c.fallbackToKey,b);return y?K(r,h,y,!1,p.length):w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return a("Translate",`Error in @translate('${f}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let p=[...r.matchAll(o)];console.warn(`Found ${p.length} @translate matches`),p.forEach((f,m)=>console.warn(`Match ${m}: ${f[0]}, Key: ${f[1]}, Params: ${f[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(p,f,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>E(m,s)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return K(r,w,O(f,u,c.fallbackToKey,h),!1,p.length)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return a("Translate",`Error in @translate('${f}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,s,i){let n=[];return e.replace(s,(l,...c)=>{let u=i(l,...c).then((o)=>({match:l,replacement:o}));return n.push(u),l}),(await Promise.all(n)).reduce((l,{match:c,replacement:u})=>l.replace(c,()=>u),e)}function _(e,s){if(!e||q(e)!=="rtl")return!1;return!s||s.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function U(e,s){let i=new RegExp(`\\b${s}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!i)return null;return i[2]??i[3]??i[4]??null}function ga(e,s,i,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,o)=>{let p={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${o||p} -->`});let l=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(l,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,o)=>`<span id="${`desc-${u}`}" class="sr-only">${o}</span>`),r}function ye(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function xe(e){let s=new Map,i=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,l,c)=>{let u=s.get(c);if(!u)u=`stx-a11y-component-${s.size}`,s.set(c,u);return`<${l}${u}`}),n=new Map([...s.entries()].map(([r,l])=>[l,r]));return{protectedSource:i,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(l,c,u)=>{let o=n.get(u);return o?`<${c}${o}`:l})}}function we(e,s){let i=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))i.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let l=/<button([^>]*)>\s*<\/button>/gi;r=l.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=l.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),M=r.index,N=e.substring(0,M),Se=e.substring(M),H=(N.match(/<label\b/gi)||[]).length,z=(N.match(/<\/label>/gi)||[]).length,W=H>z;if(!B&&!W)i.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let o=/<h([1-6])[^>]*>/gi,g=[];r=o.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=o.exec(e);let p=0;for(let d of g){if(p>0&&d>p+1)i.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${p} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});p=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))i.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let f=e.match(/<html\b([^>]*)>/i);if(f&&_(U(f[1],"lang"),U(f[1],"dir")))i.push({type:"missing-dir",element:f[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(U(r[1],"role"))&&!/<th\b/i.test(d))i.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))i.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)i.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))i.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))i.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return i}async function Ae(e,s){let{protectedSource:i}=xe(e);if(!ye())return we(i,s);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=i,r.querySelectorAll("img").forEach((o)=>{if(!o.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${o.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((o)=>{if(!(o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby")||o.textContent&&o.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${o.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((o)=>{let g=o.getAttribute("id"),p=g&&r.querySelector(`label[for="${g}"]`),f=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),m=o.closest("label")!==null;if(!p&&!f&&!m)n.push({type:"input-missing-label",element:`<${o.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let l=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let o of l){let g=Number.parseInt(o.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${o.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(i.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&_(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((o)=>{let g=o.textContent&&o.textContent.trim().length>0,p=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),f=o.hasAttribute("title"),m=o.querySelector("img[alt]");if(!g&&!p&&!f&&!m)n.push({type:"link-missing-text",element:`<${o.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),i.includes("<nav")||i.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((o)=>{if(V(o.getAttribute("role")))return;let g=o.querySelector("caption");if(!o.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!o.hasAttribute("aria-label")&&!o.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((o)=>{let g=o.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${o.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((o)=>{if(!o.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${o.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((o)=>{if(Number.parseInt(o.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${o.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((o)=>{if(!o.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${o.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),i.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((o)=>{if(!o.hasAttribute("title")&&!o.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${s}:`,r)}return n}async function ma(e,s={}){let i={},{recursive:n=!0,ignorePaths:r=[]}=s,l=Array.isArray(e)?e:[e],c=await fo(l,{recursive:n,ignorePaths:r}),u=[];for(let o of c)try{let g=await Bun.file(o).text();if(o.endsWith("good-a11y.stx"))continue;let p=await Ae(g,o);if(u.push(o),p.length>0)i[o]=p}catch(g){console.error(`Error scanning ${o}:`,g)}return{results:i,scannedFiles:u}}var ha={name:"a11y",handler:(e,s,i,n)=>{if(!s.length)return e;let r=s[0].replace(/['"]/g,""),l=s.length>1?s[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${l||u} -->${e}`},hasEndTag:!1},ya={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
|
|
4
4
|
export{fa,ga,ma,ha,ya};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lc,uc}from"./chunk-pxdww4rb.js";import{j,ss,os,is,So,ko,sr,Pe,le,q,cs,ne,be,ue,Qe,ir,To,lr,Le,n,d,F,fn}from"./chunk-c7d09931.js";import{p,E,tt,u}from"./chunk-2dp7hyv7.js";import{ee}from"./chunk-ka8befem.js";import{i}from"./chunk-qjtpxsyx.js";import{f}from"./chunk-b7e07ybq.js";import{createHash as Ct}from"crypto";import Y from"fs";import J 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,r){let s=Buffer.alloc(r),o=Te.readSync(e,s,0,r,t);return s.subarray(0,o)}function De(e){if(e.length<25)return!1;let t=(s,o)=>String.fromCharCode(...e.subarray(s,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function je(e){let t;try{t=Te.openSync(e,"r");let r=Ce(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===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(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(De(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="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 r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(gt(r)))return gt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.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)=>r.startsWith(o))}var pt=!1;function me(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 Me(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,o)=>{let a;try{a=new mt(r)}catch(h){s(me(`could not start ${r}: ${Me(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(()=>s(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(Me(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${Me(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):s(me(`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],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],_e;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let o=JSON.parse(Y.readFileSync(s,"utf8"));if(o.name===e)return o.version}r=J.dirname(r)}return}function xt(){if(_e!==void 0)return _e;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return _e=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),_e}var bt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=Ct("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function wt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let o=J.join(e,s);try{let a=await Y.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:r(s)}:null}catch{return null}},async write(s,o){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,o),await Y.promises.rename(c,a),{bytes:o.byteLength,path:a,url:r(s)}},url:r}}async function Rt(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((o,a)=>o.name.localeCompare(a.name));let s=[];for(let o of r){let a=J.join(t,o.name);if(o.isDirectory()){s.push(...await Rt(e,a));continue}if(!o.isFile()||!an.has(J.extname(o.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function $t(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return je(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"),r=new Set,s=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 Y.promises.readFile(g?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let o=e[s],a=o?.variants.filter((g)=>g.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((g)=>{let l;try{return l=Y.openSync(g.path,"r"),!De(Ce(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(o.variants=o.variants.filter((g)=>g.format!=="webp"),delete o.sources.webp,r.push(s),!vt.has(s))vt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let o=e.slice(s,s+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 J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(Ue(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(Ue(e)),{recursive:!0}),Y.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=Y.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 Qs(e){let t=At(e);return t?he().catalog.get(t):void 0}function eo(e){let t=At(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((o)=>o.format===s).reduce((o,a)=>o+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,o)=>s.bytes-o.bytes).map(({format:s,srcset:o})=>({format:s,srcset:o}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let m=await ze("delivery",{publicDir:e,outputDir:t});if(m!==ke)return Sn(m.state),m.result}let s=await Rt(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let o=wn(t),a=s.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 jr(),{count:0,fingerprint:""};let c=wt(J.join(t,"_stx","images"),`${ln}:${xt()}`),g={outDir:J.join(t,"_stx","images"),storage:wt(J.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:pe,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 jr(),{count:0,fingerprint:""};h=await yt({...g,entries:$t(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();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,r,s){let o=So(e,s);if(o!==void 0)return o;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var ae=new kt;function R(e){return F(e)}var re="\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 se(e,t){let r=[];for(let[s,o]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof o==="boolean"){if(o)r.push(d(a));continue}if(o===re){r.push(d(a));continue}r.push(`${d(a)}="${fn(a,We(String(o)))}"`)}return r}function ie(e,t){let r=[];for(let[s,o]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(o===!0){r.push(d(a));continue}if(typeof o==="object")continue;r.push(`${d(a)}="${fn(a,We(String(o)))}"`)}return r}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,r){let s=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(s.reactive)l.push(`:href="${R(s.value)}"`);else l.push(`href="${R(sr(s.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(...se(e,v)),l.push(...ie(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 G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function Ie(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return r}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[o,a]=s.split(":"),c=kn[o];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let g=Number.parseInt(o);if(!Number.isNaN(g))r.push(`(max-width: ${g}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((o)=>`${ye(e,o,void 0,r,s)} ${o}w`).join(", ")}function Pn(e,t,r,s,o){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,o)} ${a}x`}).join(", ")}function ye(e,t,r,s,o){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));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,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",o=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(o?String(o.source.width):void 0),g=G(e,"height")||(o?String(o.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||qe(s)?.transparent===!0,x=G(e,"placeholder")||(o&&!S?"thumbhash":void 0),m=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",C=G(e,"style")||"",k=G(e,"objectFit")||G(e,"fit"),A=G(e,"objectPosition")||G(e,"position"),I=G(e,"quality"),U=Ie(e,"lazy",!0),M=Ie(e,"preload",!1),L=Ie(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",_=!!o||Ie(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=g?Number.parseInt(g):void 0,z=h||"",V="";if(o)z=o.sources[o.fallback.format]||"",V=l?Ze(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,Xe,b,y),V=Ze(l);else if(!z&&v){let P=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,P,O,b,y)}else if(l)V=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=[],oe=x==="blur"||x==="color"||x==="thumbhash";if(oe&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:m}:qe(s);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 H=In(O||16,B||9,m);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!oe&&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||ye(s,O,B,b,y),K=[];if(K.push(`src="${R(sr(we,"fetched"))}"`),K.push(`alt="${R(a)}"`),c)K.push(`width="${R(c)}"`);if(g)K.push(`height="${R(g)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${R(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${R(N)}"`),w)K.push(`class="${R(w)}"`);if(D.length>0)K.push(`style="${R(D.join(";"))}"`);if(z)K.push(`srcset="${R(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${R(V)}"`);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:"",H=_n(W)+(P?`;${P}`:"");K.push(`onload="${R(H)}"`),$e.add("onload")}K.push(...se(e,$e)),K.push(...ie(e,$e));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(we)}"${H?` type="${H}"`:""}${z?` imagesrcset="${R(z)}"`:""}${V?` imagesizes="${R(V)}"`:""} />
|
|
2
|
+
import{lc,uc}from"./chunk-pxdww4rb.js";import{j,ss,os,is,So,ko,sr,Pe,le,q,cs,ne,be,ue,Qe,ir,To,lr,Le,n,d,F,fn}from"./chunk-p23sz4rr.js";import{p,E,tt,u}from"./chunk-2dp7hyv7.js";import{ee}from"./chunk-ka8befem.js";import{i}from"./chunk-qjtpxsyx.js";import{f}from"./chunk-b7e07ybq.js";import{createHash as Ct}from"crypto";import Y from"fs";import J 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,r){let s=Buffer.alloc(r),o=Te.readSync(e,s,0,r,t);return s.subarray(0,o)}function De(e){if(e.length<25)return!1;let t=(s,o)=>String.fromCharCode(...e.subarray(s,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function je(e){let t;try{t=Te.openSync(e,"r");let r=Ce(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===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(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(De(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="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 r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(gt(r)))return gt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.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)=>r.startsWith(o))}var pt=!1;function me(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 Me(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,o)=>{let a;try{a=new mt(r)}catch(h){s(me(`could not start ${r}: ${Me(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(()=>s(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(Me(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${Me(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):s(me(`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],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],_e;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let o=JSON.parse(Y.readFileSync(s,"utf8"));if(o.name===e)return o.version}r=J.dirname(r)}return}function xt(){if(_e!==void 0)return _e;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return _e=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),_e}var bt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=Ct("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function wt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let o=J.join(e,s);try{let a=await Y.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:r(s)}:null}catch{return null}},async write(s,o){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,o),await Y.promises.rename(c,a),{bytes:o.byteLength,path:a,url:r(s)}},url:r}}async function Rt(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((o,a)=>o.name.localeCompare(a.name));let s=[];for(let o of r){let a=J.join(t,o.name);if(o.isDirectory()){s.push(...await Rt(e,a));continue}if(!o.isFile()||!an.has(J.extname(o.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function $t(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return je(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"),r=new Set,s=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 Y.promises.readFile(g?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let o=e[s],a=o?.variants.filter((g)=>g.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((g)=>{let l;try{return l=Y.openSync(g.path,"r"),!De(Ce(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(o.variants=o.variants.filter((g)=>g.format!=="webp"),delete o.sources.webp,r.push(s),!vt.has(s))vt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let o=e.slice(s,s+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 J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(Ue(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(Ue(e)),{recursive:!0}),Y.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=Y.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 Qs(e){let t=At(e);return t?he().catalog.get(t):void 0}function eo(e){let t=At(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((o)=>o.format===s).reduce((o,a)=>o+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,o)=>s.bytes-o.bytes).map(({format:s,srcset:o})=>({format:s,srcset:o}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let m=await ze("delivery",{publicDir:e,outputDir:t});if(m!==ke)return Sn(m.state),m.result}let s=await Rt(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let o=wn(t),a=s.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 jr(),{count:0,fingerprint:""};let c=wt(J.join(t,"_stx","images"),`${ln}:${xt()}`),g={outDir:J.join(t,"_stx","images"),storage:wt(J.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:pe,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 jr(),{count:0,fingerprint:""};h=await yt({...g,entries:$t(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();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,r,s){let o=So(e,s);if(o!==void 0)return o;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var ae=new kt;function R(e){return F(e)}var re="\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 se(e,t){let r=[];for(let[s,o]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof o==="boolean"){if(o)r.push(d(a));continue}if(o===re){r.push(d(a));continue}r.push(`${d(a)}="${fn(a,We(String(o)))}"`)}return r}function ie(e,t){let r=[];for(let[s,o]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(o===!0){r.push(d(a));continue}if(typeof o==="object")continue;r.push(`${d(a)}="${fn(a,We(String(o)))}"`)}return r}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,r){let s=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(s.reactive)l.push(`:href="${R(s.value)}"`);else l.push(`href="${R(sr(s.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(...se(e,v)),l.push(...ie(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 G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function Ie(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return r}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[o,a]=s.split(":"),c=kn[o];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let g=Number.parseInt(o);if(!Number.isNaN(g))r.push(`(max-width: ${g}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((o)=>`${ye(e,o,void 0,r,s)} ${o}w`).join(", ")}function Pn(e,t,r,s,o){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,o)} ${a}x`}).join(", ")}function ye(e,t,r,s,o){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));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,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",o=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(o?String(o.source.width):void 0),g=G(e,"height")||(o?String(o.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||qe(s)?.transparent===!0,x=G(e,"placeholder")||(o&&!S?"thumbhash":void 0),m=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",C=G(e,"style")||"",k=G(e,"objectFit")||G(e,"fit"),A=G(e,"objectPosition")||G(e,"position"),I=G(e,"quality"),U=Ie(e,"lazy",!0),M=Ie(e,"preload",!1),L=Ie(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",_=!!o||Ie(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=g?Number.parseInt(g):void 0,z=h||"",V="";if(o)z=o.sources[o.fallback.format]||"",V=l?Ze(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,Xe,b,y),V=Ze(l);else if(!z&&v){let P=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,P,O,b,y)}else if(l)V=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=[],oe=x==="blur"||x==="color"||x==="thumbhash";if(oe&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:m}:qe(s);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 H=In(O||16,B||9,m);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!oe&&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||ye(s,O,B,b,y),K=[];if(K.push(`src="${R(sr(we,"fetched"))}"`),K.push(`alt="${R(a)}"`),c)K.push(`width="${R(c)}"`);if(g)K.push(`height="${R(g)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${R(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${R(N)}"`),w)K.push(`class="${R(w)}"`);if(D.length>0)K.push(`style="${R(D.join(";"))}"`);if(z)K.push(`srcset="${R(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${R(V)}"`);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:"",H=_n(W)+(P?`;${P}`:"");K.push(`onload="${R(H)}"`),$e.add("onload")}K.push(...se(e,$e)),K.push(...ie(e,$e));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(we)}"${H?` type="${H}"`:""}${z?` imagesrcset="${R(z)}"`:""}${V?` imagesizes="${R(V)}"`:""} />
|
|
3
3
|
`}if(_){let P=[];if(o)for(let H of to(o))P.push(`<source type="image/${H.format}" srcset="${R(H.srcset)}"${V?` sizes="${R(V)}"`:""} />`);if(!o&&(y==="avif"||y==="auto")){let H=ye(s,O,B,b,"avif"),Q=z?Ve(s,Xe,b,"avif"):`${H}`;P.push(`<source type="image/avif" srcset="${R(Q)}"${V?` sizes="${R(V)}"`:""} />`)}if(!o&&(y==="webp"||y==="auto")){let H=ye(s,O,B,b,"webp"),Q=z?Ve(s,Xe,b,"webp"):`${H}`;P.push(`<source type="image/webp" srcset="${R(Q)}"${V?` sizes="${R(V)}"`:""} />`)}return`${Z}<picture>
|
|
4
4
|
${P.join(`
|
|
5
5
|
`)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,a}from"./chunk-2dp7hyv7.js";import{n,pn,m}from"./chunk-
|
|
2
|
+
import{t,a}from"./chunk-2dp7hyv7.js";import{n,pn,m}from"./chunk-p23sz4rr.js";import{Ye}from"./chunk-365vg0eg.js";import{Xr,Jr}from"./chunk-fzqj1mjz.js";import{va,go,Gr,Kr}from"./chunk-04kg16qs.js";import{ha,ya}from"./chunk-nt7jxmpy.js";import{bt}from"./chunk-3hxd5td3.js";import{nn,Ca,tr,nr}from"./chunk-zhf01af3.js";import{f}from"./chunk-b7e07ybq.js";import{Ts}from"./chunk-qv6axke4.js";import Q from"fs";import j from"path";import{loadConfigWithResult as Ht}from"bunfig";var B={duration:300,delay:0,ease:"ease",direction:"both"};function nt(e,r={}){let{duration:i,delay:l,ease:s,direction:c,custom:d}={...B,...r};if(e==="custom"&&d)return d;switch(e){case"fade":return`${c==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
3
3
|
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
4
4
|
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${c==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
5
5
|
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
@@ -1307,6 +1307,6 @@ ${y}
|
|
|
1307
1307
|
customElements.define('${r}', ${d});
|
|
1308
1308
|
`}async function Qe(e,r,i,l){if(r.length<1)return a("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let s=r[0].replace(/['"]/g,""),d=(i.__stx_options||{}).componentsDir||"components",p=q.isAbsolute(d)?[q.join(d,`${s}.stx`),q.join(q.dirname(l),`${s}.stx`)]:[q.join(q.dirname(l),d,`${s}.stx`),q.join(process.cwd(),d,`${s}.stx`),q.join(q.dirname(l),`${s}.stx`)],u=null;for(let h of p)if(await n(h)){u=await Bun.file(h).text();break}if(!u)return a("WebComponent",`Component file not found: ${s}.stx`,t.FILE_NOT_FOUND);let g=Ft(u,s);return`<script type="module">
|
|
1309
1309
|
${qt(g)}
|
|
1310
|
-
</script>`}var N={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:nn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Ie,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Qe,hasEndTag:!1,description:"Include a web component in the template"},ha,ya,Xr,Jr,De,ke,Ae,Pe,_e,Oe,Fe,$e,...Ts],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Ut(e,r,i){let l=r||"pages";if(e)return{root:e,pagesDir:l};let s=i||process.cwd(),c=j.join(s,"resources","views"),d=j.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:l};return{root:".",pagesDir:l}}var et=new Set,ue=["partialsDir","componentsDir","layoutsDir"],Se=new WeakMap;function Bt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let l=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return l===s||l.startsWith(`${s}/`)}function Rl(e,r){let i=!e.root,l=Ut(e.root,e.pagesDir,r);if(e.root=l.root,e.pagesDir=l.pagesDir,i&&l.root!=="."){let s=`${r}::${l.root}`;if(!et.has(s))et.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${l.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Se.has(e)){let s={};for(let c of ue){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Se.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of ue){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Bt(d,s))continue;e[c]=j.join(s,d)}}for(let s of ue){let c=e[s];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[s]=j.resolve(r,c)}return e}function Jt(e,r){let i=Se.get(e);for(let l of ue){let s=e[l];if(typeof s!=="string"||!s)continue;let c=j.isAbsolute(s)?s:j.join(r,s);if(Q.existsSync(c))continue;let d=i?.[l]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(l)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Kt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Gt(e){if(Ca(e.stateDir),e.stateDir=tr(),e.cachePath=nr(e.cachePath),e.build)e.build.cacheDir=nr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=nr(e.media.cache.directory);if(e.story)e.story.outDir=nr(e.story.outDir)}var K=null,Y=new Map,de=new Map,se=null;async function po(e,r=Ht){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function o(e){let r=e?j.resolve(e):process.cwd(),i=de.get(r);if(i&&i.signature!==Gr(i.graph)){let c=Y.get(r);if(Y.delete(r),de.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-1y5ampxc.js"),{partialsCache:p}=await import("./chunk-n5r1xek6.js");if(d(),p.clear(),c&&i.configSignature===Kr(i.graph)){let u=c.then(async(g)=>{let y={...i.graph};await go(y,r),de.set(r,{graph:y,signature:Gr(y),configSignature:Kr(y)});let h={...g,_layerGraph:y};if(!e)K=h;return h});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let l=Y.get(r);if(l)return l;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await po({name:"ui",cwd:j.join(r,"config"),defaultConfig:N,errorPolicy:"throw",verbose:!1});u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:N,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await va(r,N);u=v.config,de.set(r,{graph:v.graph,signature:Gr(v.graph),configSignature:Kr(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-02ymqwmj.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-sgj6dt85.js");await b(r,u.runtimeConfig)}Kt(u),Gt(u),Rl(u,r),Jt(u,r);let g=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{f.resolve(b,{paths:[r]}),g.push(b)}catch{}}let h=[...u.plugins??[],...g];if(h.length>0){let{pluginManager:v}=await import("./chunk-fcn71bq1.js"),b=[],x=[];for(let P of h){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,E;try{let w=f.resolve(S,{paths:[r]});k=await import(w),E=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),E=j.dirname(w)}let I=k.default||k;if(!v.has(I.name))await v.register(I,u);if(I.components){let w=Array.isArray(I.components)?I.components:[I.components];for(let C of w)b.push(j.resolve(E,C))}if(I.pages){let w=j.resolve(E,I.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(I.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:E,config:u};await I.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${I.name||S}
|
|
1310
|
+
</script>`}var N={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:nn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Ie,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Qe,hasEndTag:!1,description:"Include a web component in the template"},ha,ya,Xr,Jr,De,ke,Ae,Pe,_e,Oe,Fe,$e,...Ts],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Ut(e,r,i){let l=r||"pages";if(e)return{root:e,pagesDir:l};let s=i||process.cwd(),c=j.join(s,"resources","views"),d=j.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:l};return{root:".",pagesDir:l}}var et=new Set,ue=["partialsDir","componentsDir","layoutsDir"],Se=new WeakMap;function Bt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let l=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return l===s||l.startsWith(`${s}/`)}function Rl(e,r){let i=!e.root,l=Ut(e.root,e.pagesDir,r);if(e.root=l.root,e.pagesDir=l.pagesDir,i&&l.root!=="."){let s=`${r}::${l.root}`;if(!et.has(s))et.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${l.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Se.has(e)){let s={};for(let c of ue){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Se.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of ue){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Bt(d,s))continue;e[c]=j.join(s,d)}}for(let s of ue){let c=e[s];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[s]=j.resolve(r,c)}return e}function Jt(e,r){let i=Se.get(e);for(let l of ue){let s=e[l];if(typeof s!=="string"||!s)continue;let c=j.isAbsolute(s)?s:j.join(r,s);if(Q.existsSync(c))continue;let d=i?.[l]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(l)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Kt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Gt(e){if(Ca(e.stateDir),e.stateDir=tr(),e.cachePath=nr(e.cachePath),e.build)e.build.cacheDir=nr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=nr(e.media.cache.directory);if(e.story)e.story.outDir=nr(e.story.outDir)}var K=null,Y=new Map,de=new Map,se=null;async function po(e,r=Ht){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function o(e){let r=e?j.resolve(e):process.cwd(),i=de.get(r);if(i&&i.signature!==Gr(i.graph)){let c=Y.get(r);if(Y.delete(r),de.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-p5sjezzx.js"),{partialsCache:p}=await import("./chunk-gea2ty3e.js");if(d(),p.clear(),c&&i.configSignature===Kr(i.graph)){let u=c.then(async(g)=>{let y={...i.graph};await go(y,r),de.set(r,{graph:y,signature:Gr(y),configSignature:Kr(y)});let h={...g,_layerGraph:y};if(!e)K=h;return h});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let l=Y.get(r);if(l)return l;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await po({name:"ui",cwd:j.join(r,"config"),defaultConfig:N,errorPolicy:"throw",verbose:!1});u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:N,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await va(r,N);u=v.config,de.set(r,{graph:v.graph,signature:Gr(v.graph),configSignature:Kr(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-02ymqwmj.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-j10smv8e.js");await b(r,u.runtimeConfig)}Kt(u),Gt(u),Rl(u,r),Jt(u,r);let g=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{f.resolve(b,{paths:[r]}),g.push(b)}catch{}}let h=[...u.plugins??[],...g];if(h.length>0){let{pluginManager:v}=await import("./chunk-fcn71bq1.js"),b=[],x=[];for(let P of h){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,E;try{let w=f.resolve(S,{paths:[r]});k=await import(w),E=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),E=j.dirname(w)}let I=k.default||k;if(!v.has(I.name))await v.register(I,u);if(I.components){let w=Array.isArray(I.components)?I.components:[I.components];for(let C of w)b.push(j.resolve(E,C))}if(I.pages){let w=j.resolve(E,I.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(I.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:E,config:u};await I.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${I.name||S}
|
|
1311
1311
|
`)}catch(k){console.warn(`[stx] Failed to load plugin ${S}:`,k.message)}}u._pluginComponentDirs=b,u._pluginPageDirs=x}return u})();if(Y.set(r,s),s.catch(()=>{if(Y.get(r)===s)Y.delete(r)}),!e)se=s,s.then((c)=>{K=c}).catch(()=>{});return s}var R=new Proxy(N,{get(e,r){if(K&&r in K)return K[r];if(!se)o().catch((i)=>{console.warn("[stx] Failed to load config file:",i?.message||i)});return e[r]}});function xp(e){return e}function Sp(e){let r=[],i=[];if(e.partialsDir!==void 0&&typeof e.partialsDir!=="string")r.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(e.componentsDir!==void 0&&typeof e.componentsDir!=="string")r.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(e.cache!==void 0&&typeof e.cache!=="boolean")r.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(e.debug!==void 0&&typeof e.debug!=="boolean")r.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(e.streaming){if(e.streaming.bufferSize!==void 0){if(typeof e.streaming.bufferSize!=="number"||e.streaming.bufferSize<=0)r.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(e.streaming.timeout!==void 0){if(typeof e.streaming.timeout!=="number"||e.streaming.timeout<=0)r.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(e.streaming.strategy!==void 0){let l=["auto","manual","sections"];if(!l.includes(e.streaming.strategy))r.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.i18n){if(e.i18n.format!==void 0){let l=["json","yaml","yml","js"];if(!l.includes(e.i18n.format))r.push({path:"i18n.format",message:`i18n.format must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.animation){if(e.animation.defaultDuration!==void 0){if(typeof e.animation.defaultDuration!=="number"||e.animation.defaultDuration<0)r.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(e.animation.staggerDelay!==void 0){if(typeof e.animation.staggerDelay!=="number"||e.animation.staggerDelay<0)r.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(e.a11y){if(e.a11y.level!==void 0){let l=["AA","AAA"];if(!l.includes(e.a11y.level))r.push({path:"a11y.level",message:`a11y.level must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.hydration){if(e.hydration.mode!==void 0){let l=["progressive","islands"];if(!l.includes(e.hydration.mode))r.push({path:"hydration.mode",message:`hydration.mode must be one of: ${l.join(", ")}`,severity:"error"})}if(e.hydration.preload!==void 0){let l=["none","eager","lazy"];if(!l.includes(e.hydration.preload))r.push({path:"hydration.preload",message:`hydration.preload must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.customDirectives)if(!Array.isArray(e.customDirectives))r.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else e.customDirectives.forEach((l,s)=>{if(!l.name||typeof l.name!=="string")r.push({path:`customDirectives[${s}].name`,message:"Custom directive must have a name string",severity:"error"});if(!l.handler||typeof l.handler!=="function")r.push({path:`customDirectives[${s}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(e.middleware)if(!Array.isArray(e.middleware))r.push({path:"middleware",message:"middleware must be an array",severity:"error"});else e.middleware.forEach((l,s)=>{if(!l.name||typeof l.name!=="string")r.push({path:`middleware[${s}].name`,message:"Middleware must have a name string",severity:"error"});if(!l.handler||typeof l.handler!=="function")r.push({path:`middleware[${s}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!l.timing||!["before","after"].includes(l.timing))r.push({path:`middleware[${s}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(e.debug===!0&&e.cache===!0)i.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(e.seo?.enabled===!0&&!e.seo?.defaultConfig?.title)i.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(e.pwa){if(e.pwa.enabled===!0&&!e.pwa.manifest?.name)r.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(e.pwa.manifest?.display!==void 0){let l=["fullscreen","standalone","minimal-ui","browser"];if(!l.includes(e.pwa.manifest.display))r.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.manifest?.orientation!==void 0){let l=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!l.includes(e.pwa.manifest.orientation))r.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.routes){let l=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];e.pwa.routes.forEach((s,c)=>{if(!s.pattern||typeof s.pattern!=="string")r.push({path:`pwa.routes[${c}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!l.includes(s.strategy))r.push({path:`pwa.routes[${c}].strategy`,message:`PWA route strategy must be one of: ${l.join(", ")}`,severity:"error"});if(s.maxAgeSeconds!==void 0&&(typeof s.maxAgeSeconds!=="number"||s.maxAgeSeconds<0))r.push({path:`pwa.routes[${c}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(s.maxEntries!==void 0&&(typeof s.maxEntries!=="number"||s.maxEntries<1))r.push({path:`pwa.routes[${c}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(e.pwa.icons?.sizes){if(!Array.isArray(e.pwa.icons.sizes))r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(e.pwa.icons.sizes.filter((s)=>typeof s!=="number"||s<16||s>1024).length>0)r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(e.pwa.icons?.purpose){let l=["any","maskable","monochrome"];if(e.pwa.icons.purpose.filter((c)=>!l.includes(c)).length>0)r.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.enabled===!0&&!e.pwa.icons?.src)i.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(e.pwa.enabled===!0&&!e.pwa.manifest?.themeColor)i.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:r.length===0,errors:r,warnings:i}}
|
|
1312
1312
|
export{ua,da,Yn,Xe,pa,qr,N,Rl,po,o,R,xp,Sp};
|