@stacksjs/stx 0.2.880 → 0.2.881
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-nysbdr4r.js → chunk-002zrse4.js} +1 -1
- package/dist/{chunk-hmntqqyd.js → chunk-1zkymrw0.js} +4 -4
- package/dist/chunk-2cvwjtjh.js +16 -0
- package/dist/{chunk-egjmb32c.js → chunk-2gg3vjks.js} +4 -4
- package/dist/{chunk-cad7e5q1.js → chunk-345waetq.js} +1 -1
- package/dist/{chunk-tgzs1kbj.js → chunk-45jpwbzd.js} +1 -1
- package/dist/{chunk-w2kdhm7k.js → chunk-4frh1qg5.js} +1 -1
- package/dist/{chunk-p746twww.js → chunk-51qyxm0y.js} +1 -1
- package/dist/{chunk-2haf7t5h.js → chunk-5hrx1p6g.js} +1 -1
- package/dist/chunk-5mwzea5d.js +2 -0
- package/dist/{chunk-7bsrnpmh.js → chunk-8nqyyj1h.js} +3 -3
- package/dist/chunk-8qr3cmpb.js +2 -0
- package/dist/chunk-909tgpxp.js +2 -0
- package/dist/{chunk-3zds0gmd.js → chunk-95j7y1rt.js} +1 -1
- package/dist/{chunk-k40e0ete.js → chunk-9fvjr9dd.js} +1 -1
- package/dist/{chunk-kn9tqjgv.js → chunk-9yx7cbhz.js} +1 -1
- package/dist/{chunk-9cbf0seq.js → chunk-9zj3xztb.js} +1 -1
- package/dist/{chunk-v3747589.js → chunk-asv4b65m.js} +1 -1
- package/dist/{chunk-1avy0p8v.js → chunk-bhc25n2n.js} +1 -1
- package/dist/{chunk-b7d3n4aw.js → chunk-brp8np3t.js} +1 -1
- package/dist/{chunk-z9ffr9gy.js → chunk-czzehcxs.js} +4 -4
- package/dist/{chunk-3wb82rxw.js → chunk-d8qt6hjg.js} +2 -2
- package/dist/{chunk-y7e61pz3.js → chunk-dfbbkjz6.js} +1 -1
- package/dist/chunk-dv0cpmat.js +2 -0
- package/dist/{chunk-7dq6ebvp.js → chunk-dze7f9vv.js} +1 -1
- package/dist/{chunk-kna1bdm2.js → chunk-ekdhjm8p.js} +4 -4
- package/dist/{chunk-ce0zbpr5.js → chunk-etavf6mr.js} +1 -1
- package/dist/{chunk-a5gnxdfe.js → chunk-f6ac0gbe.js} +1 -1
- package/dist/{chunk-k206d3pn.js → chunk-fwhr3jda.js} +1 -1
- package/dist/{chunk-qfwk93fk.js → chunk-fxhgj8tp.js} +1 -1
- package/dist/chunk-g5q0wgzk.js +2 -0
- package/dist/{chunk-4r2rfdmr.js → chunk-gad3ebgr.js} +1 -1
- package/dist/{chunk-t9hxyvvc.js → chunk-gmbw1xhm.js} +2 -2
- package/dist/{chunk-qxcc0aar.js → chunk-gs6geqeg.js} +1 -1
- package/dist/chunk-h26mpqrh.js +2 -0
- package/dist/{chunk-ew3vs3jq.js → chunk-hnxwqamj.js} +1 -1
- package/dist/{chunk-5eftxrvv.js → chunk-jc74097x.js} +1 -1
- package/dist/{chunk-93jhfbeg.js → chunk-jqvc2wbz.js} +1 -1
- package/dist/{chunk-vm42j29z.js → chunk-k52126rh.js} +1 -1
- package/dist/chunk-k7ffxfgp.js +3 -0
- package/dist/{chunk-cjv89tnb.js → chunk-kyh32kma.js} +1 -1
- package/dist/{chunk-awp8a3t4.js → chunk-m91jj8nq.js} +1 -1
- package/dist/{chunk-5p3825qw.js → chunk-my3yv4sg.js} +1 -1
- package/dist/{chunk-rzcdwybt.js → chunk-ndqq991c.js} +1 -1
- package/dist/{chunk-gm67jt8p.js → chunk-nj1ssjtd.js} +1 -1
- package/dist/{chunk-p55a910x.js → chunk-njza56wn.js} +6 -6
- package/dist/{chunk-mygsektn.js → chunk-nnynrb97.js} +1 -1
- package/dist/{chunk-f7znj9xg.js → chunk-pm27mcfp.js} +1 -1
- package/dist/{chunk-ws9kr80x.js → chunk-pstbfz5g.js} +1 -1
- package/dist/chunk-pw9qqcw3.js +2 -0
- package/dist/{chunk-1r612xxs.js → chunk-q1jjgg4w.js} +1 -1
- package/dist/{chunk-az8b0726.js → chunk-r32ddrvn.js} +2 -2
- package/dist/{chunk-xf0xacc9.js → chunk-smkerejj.js} +5 -5
- package/dist/{chunk-pm4rpc4a.js → chunk-sq6werer.js} +1 -1
- package/dist/{chunk-2d68p12e.js → chunk-v5cah9pt.js} +1 -1
- package/dist/chunk-v8ea76j6.js +2 -0
- package/dist/{chunk-qn6y5ttj.js → chunk-vxw92h3q.js} +1 -1
- package/dist/{chunk-ec5q4nnw.js → chunk-w53p65hy.js} +2 -2
- package/dist/{chunk-qd9v1v8z.js → chunk-wfthd3n5.js} +1 -1
- package/dist/{chunk-k6c5t9we.js → chunk-xf6snj8e.js} +1 -1
- package/dist/{chunk-rdxph1tp.js → chunk-xfhxfcvk.js} +1 -1
- package/dist/{chunk-19k15mfc.js → chunk-yffqfgjx.js} +1 -1
- package/dist/{chunk-0m4c42qt.js → chunk-ym0cdk7m.js} +2 -2
- package/dist/{chunk-g83ph305.js → chunk-ypsf5y5g.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/dev-server/ts-css.js +3 -3
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-3jp5z1qj.js +0 -2
- package/dist/chunk-3q0w0bzd.js +0 -16
- package/dist/chunk-83b9k17j.js +0 -2
- package/dist/chunk-hkx51atf.js +0 -2
- package/dist/chunk-rnrdngnn.js +0 -2
- package/dist/chunk-swz0xprw.js +0 -2
- package/dist/chunk-tka73egx.js +0 -2
- package/dist/chunk-v9h2bbhf.js +0 -2
- package/dist/chunk-v9mxhch2.js +0 -2
- package/dist/chunk-xz4v9tg1.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xt,St,kt}from"./chunk-zek9t5za.js";import"./chunk-00tq7ghn.js";import"./chunk-hxhmhw23.js";import"./chunk-s29hp1qw.js";import"./chunk-a60ztvnp.js";import{h}from"./chunk-
|
|
2
|
+
import{xt,St,kt}from"./chunk-zek9t5za.js";import"./chunk-00tq7ghn.js";import"./chunk-hxhmhw23.js";import"./chunk-s29hp1qw.js";import"./chunk-a60ztvnp.js";import{h}from"./chunk-njza56wn.js";import"./chunk-86nsbxep.js";import"./chunk-6t04tqvh.js";import"./chunk-yffqfgjx.js";import{tn,vo,nn,ga,vt,ma,xo,rn,ya,sn}from"./chunk-g2xy0z0e.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()=>{ma("Config file changed, restarting...");try{await e.onChange()}catch(p){vt(`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 nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,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:at(),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,f=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:f,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 at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,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:dt(),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 dt(){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 lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),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:ut(),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,mt),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 ut(){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 lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),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:ut(),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,mt),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 ut(){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-8qr3cmpb.js"),p={},u=y(n);if(u)try{await h(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=y(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 gt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=y(e);if(!r)return null;let s={};if(await h(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 gt(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 ft(t,a.source,c);return b(t,e.path,{props:c})}async function ft(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-8qr3cmpb.js"),c={...r},n=y(e);if(n)try{await h(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:y(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 y(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 rn(t);St(t,r);let s=sn(t.config,r);kt(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 g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return yt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return ht(t,g,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}`,f=ya(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await rn(t);St(t,m);let g=sn(t.config,m);if(kt(t,g),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()=>{f(),p.stop()}}}async function yt(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",f,i=n.searchParams.get("props");if(i)try{f=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,f);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 ht(t,e,r){let s=bt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function bt(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,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-s29hp1qw.js";import"./chunk-86nsbxep.js";import"./chunk-00tq7ghn.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-
|
|
2
|
+
import"./chunk-s29hp1qw.js";import"./chunk-86nsbxep.js";import"./chunk-00tq7ghn.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-njza56wn.js";import"./chunk-6t04tqvh.js";import"./chunk-yffqfgjx.js";import"./chunk-h63ma36g.js";import"./chunk-nnynrb97.js";import{l}from"./chunk-s7xywsqd.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Lo,jh,Bh}from"./chunk-xf6snj8e.js";import"./chunk-kyh32kma.js";import"./chunk-45jpwbzd.js";import"./chunk-9f31gs4m.js";import"./chunk-ym0cdk7m.js";import"./chunk-1zkymrw0.js";import"./chunk-v1s838fe.js";import"./chunk-nb6erf75.js";import"./chunk-w53p65hy.js";import"./chunk-nnynrb97.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-h2tq6cbr.js";import"./chunk-agd2b928.js";import"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{Bh as clearComposableCache,jh as getComposableScript,Lo as listComposableModules};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{On,Vi}from"./chunk-
|
|
2
|
+
import{On,Vi}from"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";export{Vi as generateRuntimeConfigTypes,On as prepareRuntimeConfig};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{d,m,N,p,ee}from"./chunk-86nsbxep.js";import{T}from"./chunk-s29hp1qw.js";import{G,Ws,Ue,j,Ht,Dr,Ge,Xe,s,y,Oe,P}from"./chunk-
|
|
2
|
+
import{d,m,N,p,ee}from"./chunk-86nsbxep.js";import{T}from"./chunk-s29hp1qw.js";import{G,Ws,Ue,j,Ht,Dr,Ge,Xe,s,y,Oe,P}from"./chunk-njza56wn.js";import{wt}from"./chunk-00tq7ghn.js";import{M}from"./chunk-hxhmhw23.js";import{fe}from"./chunk-t94y8g35.js";import{U,ct}from"./chunk-care745q.js";import{I,Ln}from"./chunk-ws2h92mm.js";import A from"path";import{existsSync as ye}from"fs";function ae(c,e){let a=0;for(let r=e;r<c.length;r++){let b=c[r];if(b==="("||b==="["||b==="{")a++;else if(b===")"||b==="]"||b==="}")a--;else if(b===","&&a===0)return r}return-1}function $e(c,e,a){let r=c,b=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),n=b.exec(r);while(n){let u=n.index,t=u+n[0].length-1,C=1,W=t+1;while(W<r.length&&C>0){if(r[W]==="(")C++;else if(r[W]===")")C--;W++}if(C!==0)break;let ie=r.substring(t+1,W-1),B=`${a}(${ie})`;r=r.substring(0,u)+B+r.substring(W),b.lastIndex=u+B.length,n=b.exec(r)}return r}function Ee(c){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(c)}function he(c){let e=c,a=[],r=new Set,b=0,n=0,u=e.length,t=(B)=>{n++;while(n<u){if(e[n]==="\\"){n+=2;continue}if(e[n]===B){n++;return}n++}},C=()=>{n++;while(n<u){if(e[n]==="\\"){n+=2;continue}if(e[n]==="`"){n++;return}if(e[n]==="$"&&e[n+1]==="{"){n+=2;let B=1;while(n<u&&B>0)if(e[n]==="{")B++,n++;else if(e[n]==="}")B--,n++;else if(e[n]==="'"||e[n]==='"')t(e[n]);else if(e[n]==="`")C();else n++;continue}n++}},W=()=>{if(e[n]==="/"&&e[n+1]==="/"){while(n<u&&e[n]!==`
|
|
3
3
|
`)n++;return!0}if(e[n]==="/"&&e[n+1]==="*"){n+=2;while(n<u-1&&!(e[n]==="*"&&e[n+1]==="/"))n++;return n+=2,!0}return!1},ie=()=>{if(b!==0)return;let B=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(B){let H=B[2];if(!r.has(H))a.push(H),r.add(H);return}let se=e.slice(n).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(se){let H=se[1];if(!r.has(H))a.push(H),r.add(H);return}let Y=e.slice(n).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let H=Y[1];if(!r.has(H))a.push(H),r.add(H)}};while(n<u){if(W())continue;if(e[n]==="'"||e[n]==='"'){t(e[n]);continue}if(e[n]==="`"){C();continue}if(e[n]==="{"){b++,n++;continue}if(e[n]==="}"){b--,n++;continue}if(b===0&&/[a-z]/i.test(e[n])&&(n===0||/\s|[;{}()]/.test(e[n-1])))ie();n++}return a.join(", ")}function ve(c,e=""){let a=he(c).split(",").map((r)=>r.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${wt("var",a)}
|
|
@@ -44,10 +44,10 @@ ${n}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return a+c+r}function Me(c,e){if(U(c)){let n=U(c).tag.match(/data-stx-scope="([^"]*)"/);if(n)return{html:c,mergedIntoExisting:n[1],stamped:!0,root:"body"};return{html:ct(c,(u,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=Ht(c),r=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(r){let b=r[1]+r[2],n=r[1].slice(1),u=b.match(/data-stx-scope="([^"]*)"/);if(u)return{html:c,mergedIntoExisting:u[1],stamped:!0,root:n};let t=c.slice(0,a),C=r[1],W=r[2];return{html:`${t}${C} data-stx-scope="${e}"${W}${c.slice(a+r[0].length)}`,mergedIntoExisting:null,stamped:!0,root:n}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Te=0;function ue(c,e){let a=A.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),r=e.__stx_scope_seq;return r?`stx_scope_${a}_${++r.n}_${r.key}`:`stx_scope_${a}_${++Te}`}var le=new Set,pe=new Set;function sy(){le.clear(),pe.clear()}var Ae=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function ag(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),r=[],b=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,u;while((u=n.exec(a))!==null){let t=u[1]==="/",C=u[2],W=u[3]==="/"||Ae.has(C.toLowerCase());if(t){b=Math.max(0,b-1);continue}if(b===0)r.push(C);if(!W)b++}return r}function me(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var at=new T(500),Ac=new Set;function oy(){Ac.clear()}function Ce(c){if(c.__onceStore instanceof Set)return c.__onceStore;return Ac}async function xs(c,e,a,r,b,n=new Set){let u=r.partialsDir||A.join(A.dirname(a),"partials");if(u&&!A.isAbsolute(u))u=A.resolve(process.cwd(),u);let t=$e(c,"@partial","@include"),C=Ce(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(f,v,h)=>{let g=v.trim(),i=`${a}:${g}`;if(C.has(i))return"";return C.add(i),v});{let f=/@includeIf\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")")i--;x++}if(i!==0)break;let l=t.substring(g+1,x-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){f.lastIndex=x;continue}let D=o[1],z=W(D,u,a),E="";if(z&&await Bun.file(z).exists())b.add(z),E=`@include(${l})`;t=t.substring(0,h)+E+t.substring(x),f.lastIndex=0}}for(let[f,v]of[["@includeWhen",!1],["@includeUnless",!0]]){let h=new RegExp(`${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=h.exec(t))!==null){let i=g.index,x=i+g[0].length-1,l=1,o=x+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let D=t.substring(x+1,o-1),z=ae(D,0);if(z===-1){h.lastIndex=o;continue}let E=D.substring(0,z).trim(),V=D.substring(z+1).trim(),F=V.match(/^\s*['"]([^'"]+)['"]/);if(!F){h.lastIndex=o;continue}let _=F[1],q=V.substring(F[0].length),O,R=ae(q,0);if(R!==-1)O=q.substring(R+1).trim();try{let k=`Boolean(${E})`,L;if(m(k)){let oe=p(k,Object.keys(e));L=Boolean(oe(...Object.values(e)))}else L=Boolean(d(k,e));let te=v?!L:L,re="";if(te){let oe=W(_,u,a);if(oe&&await Bun.file(oe).exists())b.add(oe);re=`@include('${_}'${O?`, ${O}`:""})`}t=t.substring(0,i)+re+t.substring(o),h.lastIndex=0}catch(k){let L=k instanceof Error?k.message:String(k),te=y("Include",`Error evaluating ${f} condition: ${L}`,a,c,i);t=t.substring(0,i)+te+t.substring(o),h.lastIndex=0}}}{let f=/@each\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")"){if(i--,i===0)break}x++}if(i!==0)break;let l=t.substring(g+1,x),o=t.substring(h,x+1),D=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!D){f.lastIndex=0,t=t.replace(o,"");continue}let[,z,E,V,F]=D;try{let _,q=E.trim();if(m(q))_=p(q,Object.keys(e))(...Object.values(e));else _=d(q,e);let O="";if(Array.isArray(_)&&_.length>0)for(let R of _){let k={...e,[V]:R},L=await se(z,k,c,h);O+=L}else if(F)O=await se(F,{},c,h);t=t.substring(0,h)+O+t.substring(x+1),f.lastIndex=0}catch(_){let q=_ instanceof Error?_.message:String(_);t=t.substring(0,h)+y("Each",`Error in @each: ${q}`,a,c,h)+t.substring(x+1),f.lastIndex=0}}}{let f=/@includeFirst\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")"){if(i--,i===0)break}x++}if(i!==0)break;let l=t.substring(g+1,x),o=t.substring(h,x+1),D=l.match(/^\s*(\[[^\]]+\])/);if(!D){f.lastIndex=0,t=t.replace(o,"");continue}let z=D[1],E=l.slice(D[0].length),V,F=E.match(/^\s*,\s*\{/);if(F){E=E.slice(F[0].length-1);let O=1,R=1;while(R<E.length&&O>0){if(E[R]==="{")O++;else if(E[R]==="}"){if(O--,O===0)break}R++}V=E.substring(0,R+1),E=E.slice(R+1)}let _,q=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(q)_=q[1];try{let O=JSON.parse(z.replace(/'/g,'"')),R={};if(V)try{R=N(V,e)}catch(L){let te=L instanceof Error?L.message:String(L);if(r.debug){let re=y("Include",`Error parsing includeFirst variables: ${te}`,a,c,h,o);t=t.replace(o,()=>re)}else t=t.replace(o,()=>_||"");continue}let k=!1;for(let L of O){let te=W(L,u,a);if(!te)continue;if(await s(te)){let re=await se(L,R,c,h);t=t.replace(o,()=>re),k=!0;break}}if(!k)if(_!==void 0)t=t.replace(o,()=>_);else if(r.debug){let L=y("Include",`None of the includeFirst paths exist: ${z}`,a,c,h,o);t=t.replace(o,()=>L)}else t=t.replace(o,"")}catch(O){let R=O instanceof Error?O.message:String(O),k=y("Include",`Error processing @includeFirst: ${R}`,a,c,h,o);t=t.replace(o,()=>k)}f.lastIndex=0}}function W(f,v,h){try{let g=f;if(!f.endsWith(".stx"))g=`${f}.stx`;let i=A.resolve(v),x=A.resolve(A.dirname(h)),l;if(!g.startsWith("./")&&!g.startsWith("../")){for(let F of r._layerPartialDirs??[]){let _=A.resolve(F,g);if(_.startsWith(`${A.resolve(F)}${A.sep}`)&&ye(_))return _}l=A.resolve(v,g)}else l=A.resolve(x,g);let o=A.normalize(l),D=o.startsWith(i+A.sep)||o===i,z=o.startsWith(x+A.sep)||o===x,E=!1,V=A.dirname(x);if(o.startsWith(V+A.sep)){if(!A.relative(V,o).split(A.sep).some((O)=>O.startsWith(".")&&O!=="."&&O!==".."))E=!0}if(!D&&!z&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${f}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${x}`),null;return o}catch(g){return console.error(`Error resolving path ${f}: ${g}`),null}}let ie=A.resolve(a);n.add(ie);function B(f,v,h,g){return r.onIncludeError?.({includePath:f,templatePath:a,message:v,partialsDir:u}),y("Include",v,a,h,g)}async function se(f,v={},h,g){let i=W(f,u,a);if(!i)return B(f,`Could not resolve path for include: ${f}`,h,g);let x=A.resolve(i);if(n.has(x)){let l=[...n,x].map((o)=>A.basename(o)).join(" -> ");return B(f,`Circular include detected: ${l}`,h,g)}try{b.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(S){let K=S instanceof Error?S.message:String(S);return B(f,`Error loading include file ${f}: ${K}`,h,g)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:S}=await import("./chunk-
|
|
47
|
+
})();`;return a+c+r}function Me(c,e){if(U(c)){let n=U(c).tag.match(/data-stx-scope="([^"]*)"/);if(n)return{html:c,mergedIntoExisting:n[1],stamped:!0,root:"body"};return{html:ct(c,(u,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=Ht(c),r=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(r){let b=r[1]+r[2],n=r[1].slice(1),u=b.match(/data-stx-scope="([^"]*)"/);if(u)return{html:c,mergedIntoExisting:u[1],stamped:!0,root:n};let t=c.slice(0,a),C=r[1],W=r[2];return{html:`${t}${C} data-stx-scope="${e}"${W}${c.slice(a+r[0].length)}`,mergedIntoExisting:null,stamped:!0,root:n}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Te=0;function ue(c,e){let a=A.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),r=e.__stx_scope_seq;return r?`stx_scope_${a}_${++r.n}_${r.key}`:`stx_scope_${a}_${++Te}`}var le=new Set,pe=new Set;function sy(){le.clear(),pe.clear()}var Ae=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function ag(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),r=[],b=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,u;while((u=n.exec(a))!==null){let t=u[1]==="/",C=u[2],W=u[3]==="/"||Ae.has(C.toLowerCase());if(t){b=Math.max(0,b-1);continue}if(b===0)r.push(C);if(!W)b++}return r}function me(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var at=new T(500),Ac=new Set;function oy(){Ac.clear()}function Ce(c){if(c.__onceStore instanceof Set)return c.__onceStore;return Ac}async function xs(c,e,a,r,b,n=new Set){let u=r.partialsDir||A.join(A.dirname(a),"partials");if(u&&!A.isAbsolute(u))u=A.resolve(process.cwd(),u);let t=$e(c,"@partial","@include"),C=Ce(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(f,v,h)=>{let g=v.trim(),i=`${a}:${g}`;if(C.has(i))return"";return C.add(i),v});{let f=/@includeIf\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")")i--;x++}if(i!==0)break;let l=t.substring(g+1,x-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){f.lastIndex=x;continue}let D=o[1],z=W(D,u,a),E="";if(z&&await Bun.file(z).exists())b.add(z),E=`@include(${l})`;t=t.substring(0,h)+E+t.substring(x),f.lastIndex=0}}for(let[f,v]of[["@includeWhen",!1],["@includeUnless",!0]]){let h=new RegExp(`${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=h.exec(t))!==null){let i=g.index,x=i+g[0].length-1,l=1,o=x+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let D=t.substring(x+1,o-1),z=ae(D,0);if(z===-1){h.lastIndex=o;continue}let E=D.substring(0,z).trim(),V=D.substring(z+1).trim(),F=V.match(/^\s*['"]([^'"]+)['"]/);if(!F){h.lastIndex=o;continue}let _=F[1],q=V.substring(F[0].length),O,R=ae(q,0);if(R!==-1)O=q.substring(R+1).trim();try{let k=`Boolean(${E})`,L;if(m(k)){let oe=p(k,Object.keys(e));L=Boolean(oe(...Object.values(e)))}else L=Boolean(d(k,e));let te=v?!L:L,re="";if(te){let oe=W(_,u,a);if(oe&&await Bun.file(oe).exists())b.add(oe);re=`@include('${_}'${O?`, ${O}`:""})`}t=t.substring(0,i)+re+t.substring(o),h.lastIndex=0}catch(k){let L=k instanceof Error?k.message:String(k),te=y("Include",`Error evaluating ${f} condition: ${L}`,a,c,i);t=t.substring(0,i)+te+t.substring(o),h.lastIndex=0}}}{let f=/@each\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")"){if(i--,i===0)break}x++}if(i!==0)break;let l=t.substring(g+1,x),o=t.substring(h,x+1),D=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!D){f.lastIndex=0,t=t.replace(o,"");continue}let[,z,E,V,F]=D;try{let _,q=E.trim();if(m(q))_=p(q,Object.keys(e))(...Object.values(e));else _=d(q,e);let O="";if(Array.isArray(_)&&_.length>0)for(let R of _){let k={...e,[V]:R},L=await se(z,k,c,h);O+=L}else if(F)O=await se(F,{},c,h);t=t.substring(0,h)+O+t.substring(x+1),f.lastIndex=0}catch(_){let q=_ instanceof Error?_.message:String(_);t=t.substring(0,h)+y("Each",`Error in @each: ${q}`,a,c,h)+t.substring(x+1),f.lastIndex=0}}}{let f=/@includeFirst\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")"){if(i--,i===0)break}x++}if(i!==0)break;let l=t.substring(g+1,x),o=t.substring(h,x+1),D=l.match(/^\s*(\[[^\]]+\])/);if(!D){f.lastIndex=0,t=t.replace(o,"");continue}let z=D[1],E=l.slice(D[0].length),V,F=E.match(/^\s*,\s*\{/);if(F){E=E.slice(F[0].length-1);let O=1,R=1;while(R<E.length&&O>0){if(E[R]==="{")O++;else if(E[R]==="}"){if(O--,O===0)break}R++}V=E.substring(0,R+1),E=E.slice(R+1)}let _,q=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(q)_=q[1];try{let O=JSON.parse(z.replace(/'/g,'"')),R={};if(V)try{R=N(V,e)}catch(L){let te=L instanceof Error?L.message:String(L);if(r.debug){let re=y("Include",`Error parsing includeFirst variables: ${te}`,a,c,h,o);t=t.replace(o,()=>re)}else t=t.replace(o,()=>_||"");continue}let k=!1;for(let L of O){let te=W(L,u,a);if(!te)continue;if(await s(te)){let re=await se(L,R,c,h);t=t.replace(o,()=>re),k=!0;break}}if(!k)if(_!==void 0)t=t.replace(o,()=>_);else if(r.debug){let L=y("Include",`None of the includeFirst paths exist: ${z}`,a,c,h,o);t=t.replace(o,()=>L)}else t=t.replace(o,"")}catch(O){let R=O instanceof Error?O.message:String(O),k=y("Include",`Error processing @includeFirst: ${R}`,a,c,h,o);t=t.replace(o,()=>k)}f.lastIndex=0}}function W(f,v,h){try{let g=f;if(!f.endsWith(".stx"))g=`${f}.stx`;let i=A.resolve(v),x=A.resolve(A.dirname(h)),l;if(!g.startsWith("./")&&!g.startsWith("../")){for(let F of r._layerPartialDirs??[]){let _=A.resolve(F,g);if(_.startsWith(`${A.resolve(F)}${A.sep}`)&&ye(_))return _}l=A.resolve(v,g)}else l=A.resolve(x,g);let o=A.normalize(l),D=o.startsWith(i+A.sep)||o===i,z=o.startsWith(x+A.sep)||o===x,E=!1,V=A.dirname(x);if(o.startsWith(V+A.sep)){if(!A.relative(V,o).split(A.sep).some((O)=>O.startsWith(".")&&O!=="."&&O!==".."))E=!0}if(!D&&!z&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${f}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${x}`),null;return o}catch(g){return console.error(`Error resolving path ${f}: ${g}`),null}}let ie=A.resolve(a);n.add(ie);function B(f,v,h,g){return r.onIncludeError?.({includePath:f,templatePath:a,message:v,partialsDir:u}),y("Include",v,a,h,g)}async function se(f,v={},h,g){let i=W(f,u,a);if(!i)return B(f,`Could not resolve path for include: ${f}`,h,g);let x=A.resolve(i);if(n.has(x)){let l=[...n,x].map((o)=>A.basename(o)).join(" -> ");return B(f,`Circular include detected: ${l}`,h,g)}try{b.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(S){let K=S instanceof Error?S.message:String(S);return B(f,`Error loading include file ${f}: ${K}`,h,g)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:S}=await import("./chunk-v8ea76j6.js");l=S(l,e)}if(l&&(r.debug||!I()&&!Ln()))try{let{warnUnbalancedTags:S}=await import("./chunk-w5zzwe2f.js");S(l,i)}catch{}try{let{processESImports:S}=await import("./chunk-q1jjgg4w.js");l=await S(l,e,i,r,b)}catch(S){if(r.debug)console.warn(`[stx] partial ES import extraction skipped for ${i}:`,S instanceof Error?S.message:S)}let o=l,D=j(o);if(D)o=D.content.trim();let E=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),V="";if(E)V=`<style${E[1]}>${E[2]}</style>`;let F=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(S,K,w)=>{if(!me(K))return"";return F.push({attrs:K,body:w}),`__STX_DATA_BLOCK_${F.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let _={...e};_.__stx_signals_gate=Oe(l,i);for(let[S,K]of Object.entries(v))_[S]=K;let q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,O=[...l.matchAll(q)].sort((S,K)=>{let w=(S[1]||"").includes("server"),X=(K[1]||"").includes("server");return Number(X)-Number(w)}),R="",k=null,L=!1,te=!1;for(let S of O){let K=S[1]||"",w=S[2]||"";if(me(K))continue;let X=K.includes("server"),be=Ge(K);if(!X&&!/\bsrc\s*=/i.test(K))Ue(w,i,r.strict);if(!X&&w.trim()){let{interpolateScriptExpressions:Z}=await import("./chunk-gs6geqeg.js");w=Z(w,_,f)}let ce="";try{let{extractAndStripCssImports:Z,renderVendorStyleTags:Q}=await import("./chunk-v5cah9pt.js"),ne=Z(w,{filePath:i,projectRoot:process.cwd()});w=ne.code,ce=Q(ne.styles)}catch(Z){if(r.debug)console.warn(`[stx] vendor-css extractor skipped for ${i}:`,Z instanceof Error?Z.message:Z)}if(be&&w.trim())w=Xe(w);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-v5cah9pt.js");w=Q(w).code;let{hasUserImports:ne,bundleClientScript:Se}=await import("./chunk-95j7y1rt.js");if(ne(w))w=await Se(w,i,{projectRoot:process.cwd()})}catch(Q){if(r.debug)console.warn(`[stx] bundler skipped for ${i}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:Z}=await import("./chunk-my3yv4sg.js");w=Z(w)}let de=Ee(w);if(!X){let{extractBridgeData:Z,generateServerDataBridge:Q}=await import("./chunk-v5cah9pt.js"),ne=Q(w,Z(_));if(ne)w=`${ne}
|
|
48
48
|
${w}`}if(de&&!X){L=!0,k=ue(i,e);let Z=M(w),Q=ge(Z,k);R+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${k}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:Z}=await import("./chunk-
|
|
50
|
-
`}}if(F.length>0){let{interpolateScriptExpressions:S}=await import("./chunk-
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:Z}=await import("./chunk-k52126rh.js");await Z(w,_,i)}catch(Z){if(r.debug)console.warn(`Warning: Could not extract variables from server script in ${i}:`,Z)}if(!X&&!de){let Z=K.replace(/\bclient\b/i,"").trim();k=ue(i,e);let Q=M(w),ne=ge(Q,k);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(ne))te=!0;R+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${k}"${Z?` ${Z}`:""}>${ne}</script>
|
|
50
|
+
`}}if(F.length>0){let{interpolateScriptExpressions:S}=await import("./chunk-gs6geqeg.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(K,w)=>{let X=F[Number(w)];return`<script${X.attrs}>${S(X.body,_,f)}</script>`})}if(k){let S=Me(o,k);if(o=S.html,S.mergedIntoExisting){let w=k,X=S.mergedIntoExisting;R=R.split(`'${w}'`).join(`'${X}'`).split(`"${w}"`).join(`"${X}"`),k=X}else if(!S.stamped&&L&&!le.has(i))le.add(i),console.warn(`[stx] ${A.relative(process.cwd(),i)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(S.stamped&&S.root!=="body"&&(L||te)&&!pe.has(i)){let w=ag(o);if(w.length>1)pe.add(i),console.warn(`[stx] ${A.relative(process.cwd(),i)} declares ${L?"signals":"bindings"} and has ${w.length} top-level elements (${w.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let K=S.stamped&&S.root!==null&&Dr(S.root);R=ke(R,K?k:null)}if(o.includes("@include")||o.includes("@partial"))o=await xs(o,_,i,r,b,n);let{processLoops:re,reportDeferredLoopWarnings:oe}=await import("./chunk-nj1ssjtd.js"),J=re(o,_,i,void 0,!0);J=fe(J,_,i),J=oe(J);let{processMetaDirectives:xe,processSeoDirective:_e,processStructuredData:we}=await import("./chunk-78zgmqhd.js");if(J=xe(J,_,i,r),J=we(J,_,i),J=_e(J,_,i,r),J=P(J,_,i),V)J+=`
|
|
51
51
|
`+V;if(R)J+=`
|
|
52
52
|
`+R;return J}catch(l){if(l instanceof ee)throw l;let o=l instanceof Error?l.message:String(l);return B(f,`Error processing include ${f}: ${o}`,h,g)}}let Y=/@include\s*\(/g,H;while((H=Y.exec(t))!==null){let f=H.index,v=f+H[0].length-1,h=1,g=v+1;while(g<t.length&&h>0){if(t[g]==="(")h++;else if(t[g]===")")h--;g++}if(h!==0)break;let i=t.substring(f,g),x=t.substring(v+1,g-1),l=x.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=g;continue}let o=l[1],D,z=x.substring(l[0].length),E=ae(z,0);if(E!==-1)D=z.substring(E+1).trim();let V={};if(D)try{V=N(D,e)}catch(_){let q=_ instanceof Error?_.message:String(_);t=t.replace(i,y("Include",`Error parsing include variables for ${o}: ${q}`,a,c,f)),Y.lastIndex=0;continue}let F=await se(o,V,c,f);t=t.substring(0,f)+F+t.substring(g),Y.lastIndex=0}return t}function Ss(c,e){let a=c;function r(b,n,u,t){let C=b,W=!0;while(W){W=!1;let ie=new RegExp(`@${n}\\(['"]([^'"]+)['"]\\)`),B=C.match(ie);if(!B||B.index===void 0)break;let se=B.index,Y=B[1],H=se+B[0].length,f=new RegExp(`@${n}\\(`),v=new RegExp(`@${u}(?![a-z])`),h=1,g=H,i=-1;while(h>0&&g<C.length){let l=C.slice(g),o=l.match(f),D=l.match(v),z=o?g+o.index:1/0,E=D?g+D.index:1/0;if(z<E)h++,g=z+(o[0].length||1);else if(E<1/0){if(h--,h===0){i=E;break}g=E+u.length+1}else break}if(i===-1)break;let x=C.slice(H,i);if(!e[Y])e[Y]=[];if(t)e[Y].unshift(x);else e[Y].push(x);C=C.substring(0,se)+C.substring(i+`@${u}`.length),W=!0}return C}return a=r(a,"push","endpush",!1),a=r(a,"prepend","endprepend",!0),a}function ks(c,e){return c.replace(/@stack\(['"]([^'"]+)['"]\)/g,(a,r)=>{if(!e[r]||e[r].length===0)return"";return e[r].join(`
|
|
53
53
|
`)})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{wn,Go,Xo,Jo,ey,Yo}from"./chunk-
|
|
2
|
+
import{wn,Go,Xo,Jo,ey,Yo}from"./chunk-45jpwbzd.js";import"./chunk-ssg6ne5b.js";import"./chunk-agd2b928.js";import"./chunk-6t04tqvh.js";export{Xo as buildServerApi,ey as createServerApi,wn as discoverServerApi,Go as generateApiTypes,Yo as isServerApiSource,Jo as productionApiDispatcher};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{gu,Um,mu,hu,Wm,qm}from"./chunk-
|
|
2
|
+
import{gu,Um,mu,hu,Wm,qm}from"./chunk-m91jj8nq.js";import"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{qm as applySlots,Wm as extractSlotContent,Um as parseSlotElement,gu as parseSlots,hu as processSlots,mu as renderSlot};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fa,Ou,Qn,ah,Nu,Mu,Du,ch}from"./chunk-
|
|
2
|
+
import{Fa,Ou,Qn,ah,Nu,Mu,Du,ch}from"./chunk-pm27mcfp.js";import"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{Qn as Validator,Ou as defineForm,Nu as processErrorDirective,Mu as processErrorsDirective,ch as processFormValidationDirectives,Du as processHasErrorsDirective,Fa as useForm,ah as v};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ti,ni,ri,iy,_s,ay}from"./chunk-
|
|
2
|
+
import{ti,ni,ri,iy,_s,ay}from"./chunk-345waetq.js";export{_s as clearImageDeliveryCatalog,iy as deliveredImage,ri as efficientDeliverySources,ti as getImageDelivery,ni as isTransparentImage,ay as prepareImageDelivery};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{km}from"./chunk-002zrse4.js";import"./chunk-8nqyyj1h.js";import"./chunk-9zj3xztb.js";import"./chunk-45jpwbzd.js";import"./chunk-k7ffxfgp.js";import"./chunk-1zkymrw0.js";import"./chunk-w53p65hy.js";import"./chunk-nnynrb97.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-h2tq6cbr.js";import"./chunk-agd2b928.js";import"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{km as startProductionServer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P}from"./chunk-
|
|
2
|
+
import{P}from"./chunk-njza56wn.js";import{i}from"./chunk-2gg3vjks.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}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{j,cl,no,$n,h,qe,Ke}from"./chunk-
|
|
2
|
+
import{j,cl,no,$n,h,qe,Ke}from"./chunk-njza56wn.js";import{_r,ut,W}from"./chunk-w53p65hy.js";import{gr,i}from"./chunk-2gg3vjks.js";import{$e}from"./chunk-1zkymrw0.js";import{ra}from"./chunk-xpbakn6t.js";function y(s){return s.endsWith(".md")||s.endsWith(".markdown")}function C(s){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(n,p){let g;while((g=n.exec(s))!==null){let t=g.index,o=t+g[0].length;if(p?.some((l)=>t>=l.start&&o<=l.end))continue;e.push({start:t,end:o})}}if(e.length===0)return s;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=s.slice(a,n.start),c+=`@raw${s.slice(n.start,n.end)}@endraw`,a=n.end}return c+=s.slice(a),c}async function b(s,e={}){let{data:r,content:m}=_r(s),a=await(e.renderer??((n)=>ut(n)))(m);return{html:C(a),frontmatter:r??{}}}import{dirname as k,resolve as R}from"path";function v(s){let e=s,r=j(s);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(o)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(o),g;while((g=m.exec(s))!==null){let o=g[1],l=g[2],d=g[0],u=o.includes("server");if(p(l))n.push(d);else if(u)a.push(l);else c.push(d)}let t=e;{let o=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=o.exec(t))!==null){let u=l.index+l[0].length,f=t.indexOf("</script>",u);if(f===-1)continue;d.push({start:l.index,end:f+9}),o.lastIndex=f+9}for(let u=d.length-1;u>=0;u--)t=t.substring(0,d[u].start)+t.substring(d[u].end)}for(let o of c)t=t.replace(o,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function M(s,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -12,5 +12,5 @@ ${s}
|
|
|
12
12
|
</html>`}async function bc(s,e={}){let r=R(s),m=Bun.file(r);if(!await m.exists())throw Error(`Template file not found: ${r}`);let c=await m.text(),a=null;if(y(r)){let n=await b(c,{renderer:e.markdownRenderer});c=n.html,a=n.frontmatter}if(a)e={...e,context:{...a,...e.context||{}}};if(e.layout){let n=R(e.layout),p=Bun.file(n);if(!await p.exists())throw Error(`Layout template not found: ${n}`);let{layout:g,injectCSS:t,...o}=e,l={...e.context||{}};$n(l);let d=await w(c,r,{...o,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),u=await p.text(),f={...l,content:d},x={...o,context:f,injectCSS:t};return w(u,n,x)}return w(c,r,e)}async function w(s,e,r={}){let{templateContent:m,serverScripts:c,clientScripts:a}=v(s),n={...W,...r.options},p={__filename:e,__dirname:k(e),__stx:{},__stx_options:n,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...no(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let o of c)await h(o,p,e);let g=new Set,t=m;if(t=await i(t,p,e,n,g),cl(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),a.length>0)t+=`
|
|
13
13
|
${a.join(`
|
|
14
14
|
`)}`}else{if(r.processClientScripts!==!1&&a.length>0){let o=p.__stx_event_bindings||[],l=qe(p),d=await Promise.all(a.map(async(x)=>{let _=x.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(_))return x;let S=x.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!S)return x;return await Ke(S[1],{eventBindings:o,templateContent:t,serverData:l,filePath:e})})),f=[await gr(d,{...n,buildMode:"compile"}),...d].filter(Boolean).join(`
|
|
15
|
-
`);t=ra(t,f)}t=await $e(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:o}=await import("./chunk-
|
|
15
|
+
`);t=ra(t,f)}t=await $e(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:o}=await import("./chunk-xfhxfcvk.js");t=await o(t)}catch{}return t}
|
|
16
16
|
export{bc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Re,io,Ug,Ty,Wg,$y,Pn,g,Y,ie,In,Oe,qg,zi,Kg,Ry,P,Hi,Gg,Ay,O,Py}from"./chunk-
|
|
2
|
+
import{Re,io,Ug,Ty,Wg,$y,Pn,g,Y,ie,In,Oe,qg,zi,Kg,Ry,P,Hi,Gg,Ay,O,Py}from"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{Gg as applyFilters,$y as clearCustomFilters,qg as clientLoopScopes,io as defaultFilters,In as escapeAttributeValue,g as escapeHtml,Y as escapeHtmlValue,ie as escapeInterpolatedHtmlValue,O as evaluateExpression,Re as findMustacheEnd,Wg as getAllFilters,Kg as interpolateScriptAttributes,zi as interpolateScriptExpressions,Ry as interpolateScriptsInTemplate,P as processExpressions,Hi as processExpressionsChunked,Ug as registerFilter,Ty as registerFilters,Pn as replaceInterpolations,Ay as resetRejectedExpressionWarnings,Py as unescapeHtml,Oe as usesSignalsInScript};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ga,Xa,Ja,Ya,Yh}from"./chunk-sq6werer.js";import"./chunk-e362e615.js";import"./chunk-gmbw1xhm.js";import"./chunk-kee5a3ce.js";import"./chunk-2gg3vjks.js";import"./chunk-2cvwjtjh.js";import"./chunk-ekdhjm8p.js";import"./chunk-c0g30cjs.js";import"./chunk-345waetq.js";import"./chunk-k7ffxfgp.js";import"./chunk-9yx7cbhz.js";import"./chunk-t94y8g35.js";import"./chunk-ym0cdk7m.js";import"./chunk-1zkymrw0.js";import"./chunk-v1s838fe.js";import"./chunk-jc74097x.js";import"./chunk-nb6erf75.js";import"./chunk-w53p65hy.js";import"./chunk-nnynrb97.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-h2tq6cbr.js";import"./chunk-agd2b928.js";import"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{Ga as buildNative,Yh as default,Xa as findCraftBinary,Ya as getAvailableFormats,Ja as getAvailableTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{De}from"./chunk-a60ztvnp.js";import{E}from"./chunk-00tq7ghn.js";import{M,jn}from"./chunk-hxhmhw23.js";import{A,oe}from"./chunk-
|
|
2
|
+
import{De}from"./chunk-a60ztvnp.js";import{E}from"./chunk-00tq7ghn.js";import{M,jn}from"./chunk-hxhmhw23.js";import{A,oe}from"./chunk-njza56wn.js";import{a}from"./chunk-w53p65hy.js";import{Ce,hn,yn,bn}from"./chunk-kyh32kma.js";import{Pt}from"./chunk-ym0cdk7m.js";import{Tt,er,ln,be}from"./chunk-97kgrevs.js";import{I,et}from"./chunk-ws2h92mm.js";import C from"fs";import b from"path";import x from"process";function B(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=I()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${yn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return be(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>Ce(l))])],f=Tt(i()),u=ln(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return be(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=oe({loader:"ts",target:"browser",define:A()});for(let l of p)try{let c=await Bun.file(l).text(),k=b.basename(l,".ts"),_=new Set;B(c,_);let y=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((U)=>U[2]),N=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(hn(c))c=await bn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=Pt(c),c=M(c),c=jn(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:k,ids:y.length===N?y:[],declared:_,code:`// Store: ${k}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return be(h,t,f,{chunks:[]}),null;f=Tt(i());let S={chunks:g};return be(h,t,f,S),S}function R(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
|
|
4
4
|
|
|
5
5
|
`),n=`;(function(){
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{el,s,ke}from"./chunk-
|
|
2
|
+
import{el,s,ke}from"./chunk-njza56wn.js";import{ft}from"./chunk-6c1vm6bs.js";import{l}from"./chunk-s7xywsqd.js";import o from"fs";import u from"path";var fg=new Map,m=new Map;async function dy(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function py(e){m.delete(e)}function fy(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function gy(e){x=e}async function gg(e=!1){let t=x??await import("./chunk-rw5sxr5a.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function mg(){if(S===null){let{getRouterScript:e}=await import("./chunk-1z6rrqvm.js");S=e()}return S}var y={};async function my(e,t=!1){let n=e==="runtime"?await gg(t):await mg(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,c=new Map,p=0;function C(e){return l(process.cwd(),"module-bundles",`${e}.js`)}function hy(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=c.get(t),i=n!==void 0;if(i)c.delete(t),p-=n.length*2;c.set(t,e),p+=e.length*2;while(c.size>1&&(c.size>E||p>T)){let r=c.keys().next().value;p-=c.get(r).length*2,c.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(u.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function fi(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=c.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function yy(){m.clear(),ke(),el(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Sr(e,t){try{if(!t.cachePath)return null;let n=u.resolve(t.cachePath),i=u.join(n,`${Os(e)}.html`),r=u.join(n,`${Os(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==ft())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function kr(e,t,n,i){try{if(!i.cachePath)return;let r=u.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=u.join(r,`${Os(e)}.html`),a=u.join(r,`${Os(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:ft(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),fg.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function Os(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
3
|
export{fg,dy,py,fy,gy,gg,mg,my,hy,fi,yy,Sr,kr,Os};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{h,y,g}from"./chunk-
|
|
2
|
+
import{h,y,g}from"./chunk-njza56wn.js";import{W}from"./chunk-w53p65hy.js";import{i}from"./chunk-2gg3vjks.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function lh(e,t={},o={}){let n={...W,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await h(p,f,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,f,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],b=new RegExp(T.source,"g"),m;while((m=b.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,f,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(d.name,i(d.content,f,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mt,Tg,$g,Rg,Ag,Pg,h,Ig,Di,Og,hl,yl}from"./chunk-
|
|
2
|
+
import{mt,Tg,$g,Rg,Ag,Pg,h,Ig,Di,Og,hl,yl}from"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{mt as STX_ENGINE_BINDING_NAMES,Di as convertToCommonJS,hl as extractScriptFromTemplate,h as extractVariables,yl as hasVariables,Ig as isCompleteImport,Pg as isMissingBindingFailure,Rg as isModuleResolutionFailure,Ag as isSyntaxFailure,Og as splitDeclaration,Tg as stripTypeScript,$g as withoutStxReferrer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fr,Fe}from"./chunk-9f31gs4m.js";import{G,S,Pr,Js,A}from"./chunk-p55a910x.js";import{a,L}from"./chunk-ec5q4nnw.js";import{Yo}from"./chunk-tgzs1kbj.js";import{Z}from"./chunk-nb6erf75.js";import{ft}from"./chunk-6c1vm6bs.js";import{l}from"./chunk-s7xywsqd.js";import{t,C}from"./chunk-yh2hnt3m.js";import d from"path";import j from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as St}from"crypto";var vt=12;function X(e,n,s){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(e))||Yo(e,n,s)}var ct=2;function Kf(e){let n=process.env.STX_BUNDLE_CACHE_DIR?.trim();return n?d.resolve(n):l(e,"bundle-cache")}function rt(e,n){let s=e;for(let i of Bt(n))if(i!==d.sep)s=s.split(i).join("\x00root");return s}var it=new Map;function Bt(e){let n=d.resolve(e),s=it.get(n);if(!s){let i=n;try{i=j.realpathSync(n)}catch{}s=[...new Set([n,i])].sort((c,p)=>p.length-c.length),it.set(n,s)}return s}function jt(e,n){try{let s=j.statSync(e),i=d.resolve(n),c=e.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,e):e,...c?{inRoot:!0}:{},mtimeMs:s.mtimeMs,size:s.size,hash:Bun.hash(j.readFileSync(e)).toString(36)}}catch{return null}}function ut(e,n){return e.inRoot?d.join(d.resolve(n),e.path):e.path}function Et(e,n){for(let s of e){let i=ut(s,n);try{let c=j.statSync(i);if(c.size!==s.size)return!1;if(c.mtimeMs!==s.mtimeMs&&Bun.hash(j.readFileSync(i)).toString(36)!==s.hash)return!1}catch{return!1}}return!0}var dt=new Map,_t=100;function Gf(e=process.env){let n=Number(e.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(n)&&n>=1?Math.floor(n):2000}var q=new Map;async function Mt(e){let n=q.get(e)??0;if(n>0&&n<_t){q.set(e,n+1);return}q.set(e,1);try{let s=(await j.promises.readdir(e)).filter((o)=>o.endsWith(".js")),i=Gf();if(s.length<=i)return;let p=(await Promise.all(s.map(async(o)=>{try{return{name:o,at:(await j.promises.stat(d.join(e,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,b)=>b.at-o.at);for(let o of p.slice(i)){let b=o.name.slice(0,-3);await j.promises.rm(d.join(e,`${b}.js`),{force:!0}),await j.promises.rm(d.join(e,`${b}.deps.json`),{force:!0})}N("pruned bundle cache to",i,"entries")}catch{}}function Ce(e){return dt.get(e)??[]}function Y(e,n){if(e)dt.set(e,n)}function Xf(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function N(...e){if(Xf())console.log("[stx:bundler]",...e)}var et=[];function kc(e,n,s){et.push({filePath:e||"<inline>",message:n,details:s})}function gn(){return et.slice()}function mn(){et.length=0}var K;function Zh(e){K=e}function _c(){if(K)return K;try{let e=L.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var tt=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function hn(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,s;while((s=n.exec(e))!==null){let c=s[1];if(!tt.some((o)=>o.test(c)))return N("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((s=i.exec(e))!==null){let c=s[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!tt.some((o)=>o.test(c)))return N("detected side-effect import:",c),!0}return!1}var pr="stx-module:",Rt=/\.(?:[cm]?[jt]sx?|json)$/i;function Jf(e,n){return d.relative(e,n).split(d.sep).join("/")}function Yf(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(s,i,c,p)=>{let o=n.get(p);return o&&!p.startsWith(pr)?`${i}${c}${o}${c}`:s})}function Zf(e,n){let s=0,i=(p)=>{let o=`__stxMod${s++}`,b=JSON.stringify(p);return n.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let b of p.split(",")){let I=b.trim();if(!I)continue;let M=I.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!M)continue;let w=M[1].startsWith('"')?JSON.parse(M[1]):M[1],f=M[2]??w;n.push(`var ${f} = ${o}[${JSON.stringify(w)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,b)=>{let I=b.slice(pr.length),M=i(I),w=o.trim(),f=w.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!w.startsWith("{")&&!w.startsWith("*"))n.push(`var ${f[1]} = ${M}.default;`),w=w.slice(f[0].length).trim();let v=w.match(/^\*\s*as\s+([\w$]+)$/);if(v)n.push(`var ${v[1]} = ${M};`);else if(w.startsWith("{"))c(w.replace(/^\{|\}$/g,""),M);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(pr.length)),"")),e}function ot(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,d.join(e,"index.ts"),d.join(e,"index.tsx"),d.join(e,"index.js"),d.join(e,"index.mjs")];for(let s of n)try{if(j.existsSync(s)&&j.statSync(s,{throwIfNoEntry:!1})?.isFile())return s}catch{}return}var H=new lt;function ws(e,n){let s=new Bun.CryptoHasher("md5");for(let[i,c]of[...e].sort(([p],[o])=>p<o?-1:p>o?1:0))s.update(`${i}\x00${c}\x00`);return H.run({modules:e,key:s.digest("hex").slice(0,12)},n)}var pt=new lt;function Qf(e){return pt.run(!0,e)}function eg(){return pt.getStore()===!0}function Cc(e){if(!eg())return;throw Error(`The client script of ${e} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function yn(){return H.getStore()?.key??""}function mt(e,n,s,i,c,p,o=new Map,b,I,M){let w=new Map([[s,i],...M??[]]),f=(B)=>B!==void 0&&w.has(B),v=(B,r,u)=>{if(X(r,e,b))return null;if(!p||!f(B)||!Rt.test(r))return null;try{if(!j.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let E=`${pr}${Jf(process.cwd(),r)}`;return o.set(u,E),{path:E,external:!0}},y=(B,r)=>{let u=f(B)?n:d.dirname(B),E=d.resolve(u,r);return ot(E)??E};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^\//},(r)=>{if(f(r.path))return{path:r.path};let u=ot(r.path);if(u){let E=v(r.importer,u,r.path);if(E)return E;if(!f(u))c.add(u);return{path:u}}return{path:r.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(r)=>{let u=y(r.importer,r.path),E=v(r.importer,u,r.path);if(E)return E;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(r)=>{let u=d.resolve(e,r.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let h of E)if(j.existsSync(h)&&j.statSync(h,{throwIfNoEntry:!1})?.isFile()){let D=v(r.importer,h,r.path);if(D)return D;return N(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",h),c.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(!f(r.importer))return;let u=`${pr}npm:${r.path}`;return o.set(r.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(w.has(r.path))return{contents:w.get(r.path),loader:"ts"};if(X(r.path,e,b))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let u=d.extname(r.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(r.path))c.add(r.path);let h=I?.get(r.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:j.readFileSync(r.path,"utf8"),loader:E}})}}}var Q=new Map,V=S(64),at=Symbol.for("stx.client-bundle-build-queue");function tg(e){let n=globalThis,i=(n[at]??Promise.resolve()).then(e,e);return n[at]=i.then(()=>{return},()=>{return}),i}async function bn(e,n,s={}){let i=s.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=s.minify??!1,o=s.externalizeUserModules??!0,b=s.expose?.length?[...new Set(s.expose)].sort():void 0,I=s.cacheDir||Kf(i),M=H.getStore(),w=new Bun.CryptoHasher("md5");w.update(`${vt}\x00${ft()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${b?b.join(","):"*"}\x00${p?"minified":"readable"}\x00${M?.key??""}\x00${rt(e,i)}\x00${rt(n,i)}`);let f=w.digest("hex").slice(0,12),v=d.join(I,`${f}.js`),y=V.get(v);if(y){if(Js(y.files)&&y.files.every((h)=>!X(h.path,i,c))){N("memo hit:",f);let h=y.files.map((D)=>D.path);return Y(n,h),s.collectInputs?.push(...h),y.code}V.delete(v),N("memo invalidated by dep change:",f)}let B=d.join(I,`${f}.deps.json`),r=Bun.file(v);if(await r.exists()){let h=Bun.file(B),D=!1,k=null;if(await h.exists())try{let O=JSON.parse(await h.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Et(O.files,i))k=Pr(O.files.map((g)=>ut(g,i))),D=k.length===O.files.length&&!k.some((g)=>X(g.path,i,c))}catch{D=!1}if(D){if(N("cache hit:",f),k)Y(n,k.map((U)=>U.path)),s.collectInputs?.push(...k.map((U)=>U.path));let O=await r.text(),g=new Date;if(j.promises.utimes(v,g,g).catch(()=>{}),k)V.set(v,{code:O,files:k});return O}N("cache invalidated by dep change:",f)}let u=Q.get(f);if(u){let h=await u;if(s.collectInputs)s.collectInputs.push(...(V.get(v)?.files??[]).map((D)=>D.path));return h}Cc(n);let E=tg(()=>Ft(e,n,{projectRoot:i,minify:p,cacheDir:I,hash:f,cachePath:v,depsPath:B,collectInputs:s.collectInputs,externalizeUserModules:o,serverApi:c,expose:b,throwOnFailure:s.throwOnFailure,substitutes:M?.modules}));Q.set(f,E);try{return await E}finally{Q.delete(f)}}function Ec(e){return`${e}-${process.pid}-${St()}`}async function Qh(e,n){let{projectRoot:s}=n,i=Ec(new Bun.CryptoHasher("md5").update([...e.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(s,"bundle-tmp"),"out",i);j.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,b=0;for(let[f,v]of e){let y=d.join(s,`.stx-split-${i}-${b++}.ts`);p.set(y,v),o.set(d.basename(y).replace(/\.ts$/,""),f)}let[I,M]=[...p][0],w=new Set;Cc(n.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[mt(s,d.dirname(n.filePath),I,M,w,!1,new Map,void 0,H.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...A()},root:s});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let B=d.basename(y.path);if(y.kind==="entry-point"){let r=o.get(B.replace(/\.js$/,""));if(r!==void 0)v.entries.set(r,await y.text())}else if(y.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await y.text())}return n.collectInputs?.push(...w),v}finally{try{j.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Ft(e,n,s){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:b,depsPath:I,externalizeUserModules:M}=s,w=l(i,"bundle-tmp"),f=Ec(o),v=d.join(i,`.stx-client-${f}.ts`),y=d.join(w,"out",f);j.mkdirSync(y,{recursive:!0});let B=d.dirname(n),r=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=t(e),{depths:D,balanced:k}=C(h),O=(R)=>!k||D[R]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((R)=>{let m=It(R);if(m)r.add(m)});else if(g[3])r.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;r.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!O(g.index))continue;let R=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(R&&tt.some((m)=>m.test(R)))continue;if(g[1])r.add(g[1]);if(g[2])r.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let P=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(P)r.add(P)}}for(let R of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of R[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)r.delete(_)}let gt=r.size>0?`
|
|
2
|
+
import{fr,Fe}from"./chunk-9f31gs4m.js";import{G,S,Pr,Js,A}from"./chunk-njza56wn.js";import{a,L}from"./chunk-w53p65hy.js";import{Yo}from"./chunk-45jpwbzd.js";import{Z}from"./chunk-nb6erf75.js";import{ft}from"./chunk-6c1vm6bs.js";import{l}from"./chunk-s7xywsqd.js";import{t,C}from"./chunk-yh2hnt3m.js";import d from"path";import j from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as St}from"crypto";var vt=12;function X(e,n,s){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(e))||Yo(e,n,s)}var ct=2;function Kf(e){let n=process.env.STX_BUNDLE_CACHE_DIR?.trim();return n?d.resolve(n):l(e,"bundle-cache")}function rt(e,n){let s=e;for(let i of Bt(n))if(i!==d.sep)s=s.split(i).join("\x00root");return s}var it=new Map;function Bt(e){let n=d.resolve(e),s=it.get(n);if(!s){let i=n;try{i=j.realpathSync(n)}catch{}s=[...new Set([n,i])].sort((c,p)=>p.length-c.length),it.set(n,s)}return s}function jt(e,n){try{let s=j.statSync(e),i=d.resolve(n),c=e.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,e):e,...c?{inRoot:!0}:{},mtimeMs:s.mtimeMs,size:s.size,hash:Bun.hash(j.readFileSync(e)).toString(36)}}catch{return null}}function ut(e,n){return e.inRoot?d.join(d.resolve(n),e.path):e.path}function Et(e,n){for(let s of e){let i=ut(s,n);try{let c=j.statSync(i);if(c.size!==s.size)return!1;if(c.mtimeMs!==s.mtimeMs&&Bun.hash(j.readFileSync(i)).toString(36)!==s.hash)return!1}catch{return!1}}return!0}var dt=new Map,_t=100;function Gf(e=process.env){let n=Number(e.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(n)&&n>=1?Math.floor(n):2000}var q=new Map;async function Mt(e){let n=q.get(e)??0;if(n>0&&n<_t){q.set(e,n+1);return}q.set(e,1);try{let s=(await j.promises.readdir(e)).filter((o)=>o.endsWith(".js")),i=Gf();if(s.length<=i)return;let p=(await Promise.all(s.map(async(o)=>{try{return{name:o,at:(await j.promises.stat(d.join(e,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,b)=>b.at-o.at);for(let o of p.slice(i)){let b=o.name.slice(0,-3);await j.promises.rm(d.join(e,`${b}.js`),{force:!0}),await j.promises.rm(d.join(e,`${b}.deps.json`),{force:!0})}N("pruned bundle cache to",i,"entries")}catch{}}function Ce(e){return dt.get(e)??[]}function Y(e,n){if(e)dt.set(e,n)}function Xf(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function N(...e){if(Xf())console.log("[stx:bundler]",...e)}var et=[];function kc(e,n,s){et.push({filePath:e||"<inline>",message:n,details:s})}function gn(){return et.slice()}function mn(){et.length=0}var K;function Zh(e){K=e}function _c(){if(K)return K;try{let e=L.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var tt=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function hn(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,s;while((s=n.exec(e))!==null){let c=s[1];if(!tt.some((o)=>o.test(c)))return N("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((s=i.exec(e))!==null){let c=s[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!tt.some((o)=>o.test(c)))return N("detected side-effect import:",c),!0}return!1}var pr="stx-module:",Rt=/\.(?:[cm]?[jt]sx?|json)$/i;function Jf(e,n){return d.relative(e,n).split(d.sep).join("/")}function Yf(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(s,i,c,p)=>{let o=n.get(p);return o&&!p.startsWith(pr)?`${i}${c}${o}${c}`:s})}function Zf(e,n){let s=0,i=(p)=>{let o=`__stxMod${s++}`,b=JSON.stringify(p);return n.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let b of p.split(",")){let I=b.trim();if(!I)continue;let M=I.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!M)continue;let w=M[1].startsWith('"')?JSON.parse(M[1]):M[1],f=M[2]??w;n.push(`var ${f} = ${o}[${JSON.stringify(w)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,b)=>{let I=b.slice(pr.length),M=i(I),w=o.trim(),f=w.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!w.startsWith("{")&&!w.startsWith("*"))n.push(`var ${f[1]} = ${M}.default;`),w=w.slice(f[0].length).trim();let v=w.match(/^\*\s*as\s+([\w$]+)$/);if(v)n.push(`var ${v[1]} = ${M};`);else if(w.startsWith("{"))c(w.replace(/^\{|\}$/g,""),M);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(pr.length)),"")),e}function ot(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,d.join(e,"index.ts"),d.join(e,"index.tsx"),d.join(e,"index.js"),d.join(e,"index.mjs")];for(let s of n)try{if(j.existsSync(s)&&j.statSync(s,{throwIfNoEntry:!1})?.isFile())return s}catch{}return}var H=new lt;function ws(e,n){let s=new Bun.CryptoHasher("md5");for(let[i,c]of[...e].sort(([p],[o])=>p<o?-1:p>o?1:0))s.update(`${i}\x00${c}\x00`);return H.run({modules:e,key:s.digest("hex").slice(0,12)},n)}var pt=new lt;function Qf(e){return pt.run(!0,e)}function eg(){return pt.getStore()===!0}function Cc(e){if(!eg())return;throw Error(`The client script of ${e} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function yn(){return H.getStore()?.key??""}function mt(e,n,s,i,c,p,o=new Map,b,I,M){let w=new Map([[s,i],...M??[]]),f=(B)=>B!==void 0&&w.has(B),v=(B,r,u)=>{if(X(r,e,b))return null;if(!p||!f(B)||!Rt.test(r))return null;try{if(!j.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let E=`${pr}${Jf(process.cwd(),r)}`;return o.set(u,E),{path:E,external:!0}},y=(B,r)=>{let u=f(B)?n:d.dirname(B),E=d.resolve(u,r);return ot(E)??E};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^\//},(r)=>{if(f(r.path))return{path:r.path};let u=ot(r.path);if(u){let E=v(r.importer,u,r.path);if(E)return E;if(!f(u))c.add(u);return{path:u}}return{path:r.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(r)=>{let u=y(r.importer,r.path),E=v(r.importer,u,r.path);if(E)return E;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(r)=>{let u=d.resolve(e,r.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let h of E)if(j.existsSync(h)&&j.statSync(h,{throwIfNoEntry:!1})?.isFile()){let D=v(r.importer,h,r.path);if(D)return D;return N(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",h),c.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(!f(r.importer))return;let u=`${pr}npm:${r.path}`;return o.set(r.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(w.has(r.path))return{contents:w.get(r.path),loader:"ts"};if(X(r.path,e,b))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let u=d.extname(r.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(r.path))c.add(r.path);let h=I?.get(r.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:j.readFileSync(r.path,"utf8"),loader:E}})}}}var Q=new Map,V=S(64),at=Symbol.for("stx.client-bundle-build-queue");function tg(e){let n=globalThis,i=(n[at]??Promise.resolve()).then(e,e);return n[at]=i.then(()=>{return},()=>{return}),i}async function bn(e,n,s={}){let i=s.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=s.minify??!1,o=s.externalizeUserModules??!0,b=s.expose?.length?[...new Set(s.expose)].sort():void 0,I=s.cacheDir||Kf(i),M=H.getStore(),w=new Bun.CryptoHasher("md5");w.update(`${vt}\x00${ft()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${b?b.join(","):"*"}\x00${p?"minified":"readable"}\x00${M?.key??""}\x00${rt(e,i)}\x00${rt(n,i)}`);let f=w.digest("hex").slice(0,12),v=d.join(I,`${f}.js`),y=V.get(v);if(y){if(Js(y.files)&&y.files.every((h)=>!X(h.path,i,c))){N("memo hit:",f);let h=y.files.map((D)=>D.path);return Y(n,h),s.collectInputs?.push(...h),y.code}V.delete(v),N("memo invalidated by dep change:",f)}let B=d.join(I,`${f}.deps.json`),r=Bun.file(v);if(await r.exists()){let h=Bun.file(B),D=!1,k=null;if(await h.exists())try{let O=JSON.parse(await h.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Et(O.files,i))k=Pr(O.files.map((g)=>ut(g,i))),D=k.length===O.files.length&&!k.some((g)=>X(g.path,i,c))}catch{D=!1}if(D){if(N("cache hit:",f),k)Y(n,k.map((U)=>U.path)),s.collectInputs?.push(...k.map((U)=>U.path));let O=await r.text(),g=new Date;if(j.promises.utimes(v,g,g).catch(()=>{}),k)V.set(v,{code:O,files:k});return O}N("cache invalidated by dep change:",f)}let u=Q.get(f);if(u){let h=await u;if(s.collectInputs)s.collectInputs.push(...(V.get(v)?.files??[]).map((D)=>D.path));return h}Cc(n);let E=tg(()=>Ft(e,n,{projectRoot:i,minify:p,cacheDir:I,hash:f,cachePath:v,depsPath:B,collectInputs:s.collectInputs,externalizeUserModules:o,serverApi:c,expose:b,throwOnFailure:s.throwOnFailure,substitutes:M?.modules}));Q.set(f,E);try{return await E}finally{Q.delete(f)}}function Ec(e){return`${e}-${process.pid}-${St()}`}async function Qh(e,n){let{projectRoot:s}=n,i=Ec(new Bun.CryptoHasher("md5").update([...e.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(s,"bundle-tmp"),"out",i);j.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,b=0;for(let[f,v]of e){let y=d.join(s,`.stx-split-${i}-${b++}.ts`);p.set(y,v),o.set(d.basename(y).replace(/\.ts$/,""),f)}let[I,M]=[...p][0],w=new Set;Cc(n.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[mt(s,d.dirname(n.filePath),I,M,w,!1,new Map,void 0,H.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...A()},root:s});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let B=d.basename(y.path);if(y.kind==="entry-point"){let r=o.get(B.replace(/\.js$/,""));if(r!==void 0)v.entries.set(r,await y.text())}else if(y.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await y.text())}return n.collectInputs?.push(...w),v}finally{try{j.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Ft(e,n,s){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:b,depsPath:I,externalizeUserModules:M}=s,w=l(i,"bundle-tmp"),f=Ec(o),v=d.join(i,`.stx-client-${f}.ts`),y=d.join(w,"out",f);j.mkdirSync(y,{recursive:!0});let B=d.dirname(n),r=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=t(e),{depths:D,balanced:k}=C(h),O=(R)=>!k||D[R]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((R)=>{let m=It(R);if(m)r.add(m)});else if(g[3])r.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;r.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!O(g.index))continue;let R=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(R&&tt.some((m)=>m.test(R)))continue;if(g[1])r.add(g[1]);if(g[2])r.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let P=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(P)r.add(P)}}for(let R of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of R[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)r.delete(_)}let gt=r.size>0?`
|
|
3
3
|
export { ${[...r].join(", ")} }`:"";N("bundling:",o,"from:",d.basename(n));let nt=new Set,st=new Map;try{let R=await Bun.build({entrypoints:[v],outdir:y,target:"browser",format:"esm",minify:c?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[mt(i,B,v,e+gt,nt,M,st,s.serverApi,s.substitutes)],define:{"process.env.NODE_ENV":c?'"production"':'"development"',...A()},root:i});if(!R.success){let F=R.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${d.basename(n)}`,z=fr(R.logs,n||void 0);if(console.warn("[stx:bundler] build failed:",F),kc(n||"",F,z),s.throwOnFailure||_c()==="error")throw Error(F);return e}let m="";for(let x of R.outputs){m=await x.text();break}let _=[];for(let x of m.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let F of x[1].split(",")){let z=F.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){_.push([z[2],z[1]]);continue}let T=F.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))_.push([T,T])}if(s.expose){let x=new Set(s.expose);for(let F=_.length-1;F>=0;F--)if(!x.has(_[F][0]))_.splice(F,1)}let P=[];m=Zf(Yf(m,st),P);let ht=m.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(m=m.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),c&&m)try{m=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(m)}catch{}let xt=Z(m),W=`__stxBundle_${o}`,yt=new Set(G(e,!0).split(",").map((x)=>x.trim())),$t=_.map(([x,F])=>`get ${JSON.stringify(x)}() { return ${F} }${yt.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${F}) { ${F} = __stxValue_${F} }`:""}`).join(", "),bt=_.map(([x])=>`var ${x} = undefined;`).join(`
|
|
4
4
|
`),wt=_.map(([x])=>`${x} = ${W}[${JSON.stringify(x)}];`).join(`
|
|
5
5
|
`);if(m=`${ht.join(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,p}from"./chunk-86nsbxep.js";import{se,B,g}from"./chunk-
|
|
2
|
+
import{m,p}from"./chunk-86nsbxep.js";import{se,B,g}from"./chunk-njza56wn.js";function z(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function Z(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let f=t.indexOf("-->",s+4);n=f===-1?t.length:f+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function L(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let f=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=f||N.has(c)?-1:Z(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!f&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function j(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",f=u[2].toLowerCase();if(c){let l=i.lastIndexOf(f);if(l!==-1)i.splice(l);e=s;continue}if(f==="template"&&i.length===0){let l=a.match(r);if(l){let h=z(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(f)){if(i.push(f),f==="script"||f==="style"){let l=t.toLowerCase().indexOf(`</${f}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function gu(t){let o={default:"",named:new Map},i=t,r=j(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=L(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Um(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function mu(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of c){let[d,l]=f.split(":").map((S)=>S.trim()),h=l||d;if(s[h]=o[d],o[d]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=I(e,s,a,u)}return e}function I(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(B(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!B(s,r))return e;let a=_(s,o);if(a===void 0)return e;return g(String(a??""))}catch{return`{{ ${n} }}`}})}function _(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!m(t))return;return p(t,Object.keys(o))(...Object.values(o))}catch{return}}async function hu(t,o,i,r){let e=t;e=await W(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,f)=>{let d=o.named.get(u),l=f?.trim()||"",h=c||"",S={},E=[],C=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=C.exec(h))!==null){let w=b[1],x=b[2];S[w]=_(x,i),E.push([w,x])}if(r!==void 0&&d?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=d.propsBinding.trim(),x=se(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let M=E.map(([A,P])=>{let O=S[A],R;try{R=O===void 0?void 0:JSON.stringify(O)}catch{}return`${JSON.stringify(A)}:(${R??P})`}).join(","),v=g(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${g(`${y} in [{${M}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${v}">${d.content}</template>`}return await mu(d,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let f=c?.trim()||"";return o.default||f}),e}async function W(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function Wm(t){let o=gu(t);return{defaultSlot:o.default,namedSlots:o.named}}async function qm(t,o,i,r,e){return await hu(t,{default:o,named:i},r,e)}
|
|
3
3
|
export{gu,Um,mu,hu,Wm,qm};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{uy,Ts,ci,$s,wr,li,ui,dg,Rs,As,Ps,di,Ic,pg,Pt}from"./chunk-
|
|
2
|
+
import{uy,Ts,ci,$s,wr,li,ui,dg,Rs,As,Ps,di,Ic,pg,Pt}from"./chunk-ym0cdk7m.js";import"./chunk-1zkymrw0.js";import"./chunk-v1s838fe.js";import"./chunk-w53p65hy.js";import"./chunk-nnynrb97.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-h2tq6cbr.js";import"./chunk-agd2b928.js";import{G}from"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{dg as bindLoopInterpolations,uy as clearScriptScanCache,Rs as convertServerLoopAttributesToDirectives,li as convertSignalDirectivesToAttributes,As as convertSignalLoopsToAttributes,wr as extractClientSignalNames,G as extractExports,Ic as findMarkupIndexOutsideScripts,$s as hasSignalsSyntax,ci as parseLoopExpression,ui as preEvalLiteralReactiveIfs,Ps as processScriptSetup,di as processSignals,pg as rewriteStxImportSpecifiers,Ts as scanScriptTags,Pt as stripStxRuntimeImports};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ae,mt,Ut,Ys,Zs,Se,$i,Cn,rl,sl,Ri,ol,il,eo,Pi,Ii,al,Oi}from"./chunk-
|
|
2
|
+
import{Ae,mt,Ut,Ys,Zs,Se,$i,Cn,rl,sl,Ri,ol,il,eo,Pi,Ii,al,Oi}from"./chunk-njza56wn.js";import{E}from"./chunk-00tq7ghn.js";import{a}from"./chunk-w53p65hy.js";import{Lo}from"./chunk-xf6snj8e.js";import{l}from"./chunk-s7xywsqd.js";import{existsSync as G,readFileSync as U}from"fs";import h from"path";var ke=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),oe=mt.filter((e)=>!ke.has(e)).sort(),ce=[...E].sort(),ve=[...new Set([...oe,...ce])].sort(),$e=new Set(oe),De=new Set(ce),Te=new Set(ve),re=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Ce(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ae(e,t){let o=[];for(let d of t){if(d.offset===void 0)continue;let i=d.kind==="server"?$e:De;re.lastIndex=0;for(let c of d.code.matchAll(re)){let m=c.index+c[0].indexOf("{")+1;for(let f of c[1].matchAll(/[^,]+/g)){let k=f[0];if(/^\s*type\s/.test(k))continue;let S=/^\s*([A-Za-z_$][\w$]*)/.exec(k);if(!S)continue;let s=S[1];if(!Te.has(s)||i.has(s))continue;let u=d.offset+m+f.index+S[0].length-s.length,g=e.slice(0,u),v=g.split(`
|
|
3
3
|
`).length;o.push({line:v,column:u-(g.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:u,length:s.length,name:s,kind:d.kind,message:Ce(s,d.kind)})}}}return o}import M from"path";var Ee="@stacksjs/stx-typescript-plugin";function Oe(e,t){let o=M.resolve(e);for(;;){let d=M.join(o,"tsconfig.json");if(t(d))return d;let i=M.dirname(o);if(i===o)return;o=i}}function le(e,t,o){let d=Oe(e,o);if(!d)return;let i=new Set,c=(m)=>{if(i.has(m))return;i.add(m);let f=t(m);if(!f)return;let k=f.compilerOptions?.plugins;if(Array.isArray(k)){let s=k.find((g)=>g?.name===Ee),u=Array.isArray(s?.libs)?s.libs.filter((g)=>typeof g==="string"):[];return s?{configPath:m,libs:u.map((g)=>M.resolve(M.dirname(m),g))}:null}let S=typeof f.extends==="string"?[f.extends]:Array.isArray(f.extends)?f.extends:[];for(let s of[...S].reverse()){if(typeof s!=="string"||!s.startsWith("."))continue;let u=M.resolve(M.dirname(m),s.endsWith(".json")?s:`${s}.json`),g=c(u);if(g!==void 0)return g}return};return c(d)??void 0}function Ra(e,t="",o="",d=t,i){let c=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",m=$i(Pi(e)+e.code,d),f=e.kind==="client"&&i?i.project(m.code):void 0,k=Cn(f?.code??m.code),S=e.kind==="client"||e.kind==="plain"?ol(t,e.code):"",s=(c+k).split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Es,lg,si,ug}from"./chunk-
|
|
2
|
+
import{Es,lg,si,ug}from"./chunk-9yx7cbhz.js";import"./chunk-t94y8g35.js";import"./chunk-ym0cdk7m.js";import"./chunk-1zkymrw0.js";import"./chunk-v1s838fe.js";import"./chunk-w53p65hy.js";import"./chunk-nnynrb97.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-h2tq6cbr.js";import"./chunk-agd2b928.js";import{Vt}from"./chunk-njza56wn.js";import"./chunk-yffqfgjx.js";import"./chunk-6t04tqvh.js";import"./chunk-86nsbxep.js";import"./chunk-hxhmhw23.js";import"./chunk-a60ztvnp.js";import"./chunk-s29hp1qw.js";import"./chunk-00tq7ghn.js";export{ug as declareBareLoopHead,Vt as parseLoopBinding,lg as processLoops,si as processLoopsAsync,Es as reportDeferredLoopWarnings};
|