@stacksjs/stx 0.2.669 → 0.2.671

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.
Files changed (92) hide show
  1. package/dist/{chunk-144yp2bw.js → chunk-10np2c03.js} +1 -1
  2. package/dist/{chunk-nytb5e4v.js → chunk-11c5q4h7.js} +2 -2
  3. package/dist/{chunk-nzj3a6mj.js → chunk-1pw1nvta.js} +1 -1
  4. package/dist/{chunk-9hngzqp5.js → chunk-1s6j0k3c.js} +1 -1
  5. package/dist/{chunk-5pe26hxm.js → chunk-1yf17fzh.js} +1 -1
  6. package/dist/{chunk-1mz8fw0m.js → chunk-1zeerj7e.js} +4 -4
  7. package/dist/{chunk-p23sz4rr.js → chunk-2j996te9.js} +6 -6
  8. package/dist/{chunk-8rx1bves.js → chunk-2jqthnya.js} +1 -1
  9. package/dist/{chunk-jsqh5fyn.js → chunk-3gcpv242.js} +1 -1
  10. package/dist/{chunk-hesyghn7.js → chunk-435ww2a2.js} +1 -1
  11. package/dist/{chunk-jf1vs526.js → chunk-48cx52vd.js} +2 -2
  12. package/dist/{chunk-xrdrwrfe.js → chunk-6z3d3t00.js} +1 -1
  13. package/dist/{chunk-4b1ed4qv.js → chunk-7fk5ygvh.js} +1 -1
  14. package/dist/{chunk-679tc0c4.js → chunk-7k3v1qv8.js} +1 -1
  15. package/dist/chunk-7s44ew85.js +2 -0
  16. package/dist/{chunk-5j970c0z.js → chunk-9ah1zsch.js} +1 -1
  17. package/dist/chunk-a92b91a7.js +2 -0
  18. package/dist/chunk-av3qvakg.js +130 -0
  19. package/dist/{chunk-ys3tmk8w.js → chunk-bjrx38kf.js} +1 -1
  20. package/dist/{chunk-d5d1b6w0.js → chunk-c836tm9c.js} +1 -1
  21. package/dist/{chunk-bmd035rk.js → chunk-d21ag28g.js} +1 -1
  22. package/dist/chunk-dnszn1xb.js +2 -0
  23. package/dist/chunk-e5dvqb47.js +2 -0
  24. package/dist/{chunk-fpbff6s1.js → chunk-eky3cdcg.js} +1 -1
  25. package/dist/{chunk-e7wxt37f.js → chunk-erpjegf6.js} +1 -1
  26. package/dist/{chunk-604yfrmq.js → chunk-ey3wv3qq.js} +1 -1
  27. package/dist/{chunk-b7vz9m5q.js → chunk-gfa140m0.js} +1 -1
  28. package/dist/chunk-ggxkpxfm.js +2 -0
  29. package/dist/{chunk-87bs5f18.js → chunk-j2318qfk.js} +1 -1
  30. package/dist/{chunk-kd6qactf.js → chunk-jcrk8xn6.js} +2 -2
  31. package/dist/{chunk-ea7ekakt.js → chunk-k35fd0mn.js} +4 -4
  32. package/dist/{chunk-ndhkwfyq.js → chunk-k5wpdg44.js} +1 -1
  33. package/dist/{chunk-ynyssmdy.js → chunk-kezhxaye.js} +2 -2
  34. package/dist/{chunk-j10smv8e.js → chunk-kjfnym5y.js} +1 -1
  35. package/dist/{chunk-ev0t17cq.js → chunk-kjrrxwj0.js} +1 -1
  36. package/dist/chunk-m0e0n317.js +2 -0
  37. package/dist/{chunk-nt7jxmpy.js → chunk-m6zpcyhm.js} +1 -1
  38. package/dist/{chunk-b5ktzth7.js → chunk-mehp1sma.js} +5 -5
  39. package/dist/{chunk-mezzmwc5.js → chunk-mnyf1jq8.js} +1 -1
  40. package/dist/{chunk-0q0tpmr5.js → chunk-nhh8b7xj.js} +1 -1
  41. package/dist/{chunk-gmgdmsdz.js → chunk-nm7h30yt.js} +1 -1
  42. package/dist/{chunk-cca86043.js → chunk-pe470p36.js} +1 -1
  43. package/dist/{chunk-ackk8wq5.js → chunk-pjgnvpks.js} +1 -1
  44. package/dist/chunk-qzfcy37r.js +2 -0
  45. package/dist/{chunk-ywqs7x8g.js → chunk-r3e1avhs.js} +1 -1
  46. package/dist/{chunk-ztp2rgpp.js → chunk-s45a5axx.js} +2 -2
  47. package/dist/chunk-t8w6h94x.js +2 -0
  48. package/dist/{chunk-nx6d1hj7.js → chunk-ttszb0qr.js} +1 -1
  49. package/dist/{chunk-43r0hjne.js → chunk-v0v2xnk7.js} +1 -1
  50. package/dist/chunk-vy35p3qj.js +2 -0
  51. package/dist/{chunk-ken0q08p.js → chunk-w63hh78w.js} +5 -5
  52. package/dist/{chunk-1cnwcn01.js → chunk-wj9njs0n.js} +1 -1
  53. package/dist/{chunk-jz6t1nes.js → chunk-wmkmj8d3.js} +1 -1
  54. package/dist/chunk-wqgz7vqp.js +2 -0
  55. package/dist/{chunk-8w9z30yx.js → chunk-wytkp0ss.js} +1 -1
  56. package/dist/{chunk-03wssg2z.js → chunk-x3s7wxm6.js} +1 -1
  57. package/dist/{chunk-7n7078xp.js → chunk-x5tgasp8.js} +1 -1
  58. package/dist/{chunk-d2zzqfgq.js → chunk-ym09kjfr.js} +2 -2
  59. package/dist/{chunk-p5sjezzx.js → chunk-z7t0ds1f.js} +1 -1
  60. package/dist/{chunk-gea2ty3e.js → chunk-zcv5vjq3.js} +1 -1
  61. package/dist/{chunk-zshhn7nz.js → chunk-zg08y45x.js} +1 -1
  62. package/dist/cli.js +7 -7
  63. package/dist/craft-entry.js +1 -1
  64. package/dist/craft.js +1 -1
  65. package/dist/native/compiler/component-mapping.js +2 -0
  66. package/dist/native/compiler/headwind-to-style.d.ts +3 -1
  67. package/dist/native/compiler/headwind-to-style.js +11 -8
  68. package/dist/native/compiler/html-to-ir.js +2 -1
  69. package/dist/native/compiler/ir.d.ts +1 -0
  70. package/dist/native/components/primitives.d.ts +18 -0
  71. package/dist/native/components/primitives.js +1 -0
  72. package/dist/native/index.d.ts +2 -0
  73. package/dist/native/primitives/NativeSegmentedControl.stx +5 -0
  74. package/dist/native/prop-names.js +8 -1
  75. package/dist/native/runtime/browser-renderer.js +23 -1
  76. package/dist/native/runtime/craft-bridge.js +2 -1
  77. package/dist/native/runtime/native-host.js +54 -7
  78. package/dist/native/runtime/web-storage.js +41 -8
  79. package/dist/pwa.js +1 -1
  80. package/dist/ssg.js +2 -2
  81. package/package.json +2 -2
  82. package/dist/chunk-0zrskbkk.js +0 -2
  83. package/dist/chunk-21jz51jg.js +0 -2
  84. package/dist/chunk-2bspyg11.js +0 -2
  85. package/dist/chunk-5hqrw558.js +0 -2
  86. package/dist/chunk-7nsb5pxp.js +0 -2
  87. package/dist/chunk-7tp1j22e.js +0 -2
  88. package/dist/chunk-hnx88y3p.js +0 -130
  89. package/dist/chunk-kff0hgg5.js +0 -2
  90. package/dist/chunk-m1ggzh60.js +0 -2
  91. package/dist/chunk-msm3gqay.js +0 -2
  92. package/dist/chunk-y1kaq1cd.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-p23sz4rr.js";import"./chunk-1sr6c0nk.js";import"./chunk-144yp2bw.js";import"./chunk-a3d0g4mr.js";import"./chunk-nt7jxmpy.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l 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||c(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=l.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"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.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(`
2
+ import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-2j996te9.js";import"./chunk-1sr6c0nk.js";import"./chunk-10np2c03.js";import"./chunk-a3d0g4mr.js";import"./chunk-m6zpcyhm.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l 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||c(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=l.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"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.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};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{yn}from"./chunk-2dp7hyv7.js";import{W,Pe,ce,Rt,At,cr,g,Ya,Mo,F,_}from"./chunk-p23sz4rr.js";import{H}from"./chunk-fbtv2k1p.js";var V=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function B(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(V.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var q=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function _i(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=Pe(t,s);if(a>s){i=a;continue}let o=W(t,s);if(o>s){let c=t.slice(s,o),u=q.exec(c);if(u){let l=B(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function G(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function U(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function X(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=U(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=G(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||z.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!X(o,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let x=m[1]==="/";if(!x&&(m[2]||"").trimEnd().endsWith("/"))continue;if(f+=x?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:m.index,tagName:a}}return null}return null}var ut="private, no-store";function Ci(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function Se(t){return t.headers.get("X-STX-Router")==="true"}function J(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function O(t){return{Vary:J(t,"X-STX-Router")}}import A from"path";var K="stx-page-head:",Y=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,C={dev:null,prod:null};function Z(){let t=H()?"dev":"prod",n=C[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-028ee6q5.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;C[t]=`<script>${r()}</script>`}catch{C[t]=""}return C[t]}async function Ei(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=A.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=A.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function js(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=_i(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)o.push(u[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:x,defaultConfig:y,loadStxConfig:R}=await import("./chunk-7tp1j22e.js"),S=await R(),p={__filename:t,__dirname:A.dirname(t)};for(let d of a){let w=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(w&&!d.includes("client")&&!d.includes('type="module"'))await x(w[1],p,t)}let b=await m(l,p,t,{...y,...S,...n},new Set),h=b.indexOf(f);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:b.substring(0,h),afterSlot:b.substring(h+f.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function $r(t,n,e){let r,i="",s=n.match(Y);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Z(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
2
+ import{yn}from"./chunk-2dp7hyv7.js";import{W,Pe,ce,Rt,At,cr,g,Ya,Mo,F,_}from"./chunk-2j996te9.js";import{H}from"./chunk-fbtv2k1p.js";var V=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function B(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(V.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var q=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function _i(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=Pe(t,s);if(a>s){i=a;continue}let o=W(t,s);if(o>s){let c=t.slice(s,o),u=q.exec(c);if(u){let l=B(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function G(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function U(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function X(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=U(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=G(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||z.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!X(o,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let x=m[1]==="/";if(!x&&(m[2]||"").trimEnd().endsWith("/"))continue;if(f+=x?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:m.index,tagName:a}}return null}return null}var ut="private, no-store";function Ci(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function Se(t){return t.headers.get("X-STX-Router")==="true"}function J(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function O(t){return{Vary:J(t,"X-STX-Router")}}import A from"path";var K="stx-page-head:",Y=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,C={dev:null,prod:null};function Z(){let t=H()?"dev":"prod",n=C[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-028ee6q5.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;C[t]=`<script>${r()}</script>`}catch{C[t]=""}return C[t]}async function Ei(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=A.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=A.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function js(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=_i(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)o.push(u[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:x,defaultConfig:y,loadStxConfig:R}=await import("./chunk-dnszn1xb.js"),S=await R(),p={__filename:t,__dirname:A.dirname(t)};for(let d of a){let w=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(w&&!d.includes("client")&&!d.includes('type="module"'))await x(w[1],p,t)}let b=await m(l,p,t,{...y,...S,...n},new Set),h=b.indexOf(f);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:b.substring(0,h),afterSlot:b.substring(h+f.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function $r(t,n,e){let r,i="",s=n.match(Y);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Z(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -27,5 +27,5 @@ ${o}
27
27
  `));if(i.length>0)S.push(i.filter((p)=>!c.has(p)).join(`
28
28
  `));if(x.length>0)S.push(x.filter((p)=>!c.has(p)).join(`
29
29
  `));return S.push(m),S.join(`
30
- `)}import E from"fs";import I from"path";function $i(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Ri(t,n){let e=I.join(n,"manifest.json");E.writeFileSync(e,JSON.stringify(t,null,2))}function Ai(t){let n=I.join(t,"manifest.json");if(!E.existsSync(n))return null;try{let e=E.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function k(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function tt(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Bs(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function D(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Bs(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await tt(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=et(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function et(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(k(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(k(e,i.value,i))}}return n}function Pi(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function kn(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await nt(t,n),a=Rt(r),o=At(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-5hqrw558.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-y1kaq1cd.js"),{defaultConfig:m}=await import("./chunk-1cnwcn01.js"),x=r.streamBoundaries||{},y={...m,autoShell:!1},R=Object.keys(l).map((p)=>({id:p,render:async()=>{let b=typeof x[p]==="function"?await x[p]():void 0;return f(l[p],{...r,$boundary:b},t.sourceFile,y,new Set)}})),S=new Set(R.map((p)=>p.id));u=[...(u||[]).filter((p)=>!S.has(p.id)),...R]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:o}}async function nt(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Mo(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await g(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await D(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=cr(e);if(!c)return o;let u=o.indexOf("</head>");return u<0?c+o:o.slice(0,u)+c+o.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Mo(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=_(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?F(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(Ya(t.html,s)),context:e,cookies:r.cookies}}
30
+ `)}import E from"fs";import I from"path";function $i(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Ri(t,n){let e=I.join(n,"manifest.json");E.writeFileSync(e,JSON.stringify(t,null,2))}function Ai(t){let n=I.join(t,"manifest.json");if(!E.existsSync(n))return null;try{let e=E.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function k(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function tt(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Bs(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function D(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Bs(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await tt(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=et(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function et(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(k(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(k(e,i.value,i))}}return n}function Pi(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function kn(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await nt(t,n),a=Rt(r),o=At(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-e5dvqb47.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-a92b91a7.js"),{defaultConfig:m}=await import("./chunk-wj9njs0n.js"),x=r.streamBoundaries||{},y={...m,autoShell:!1},R=Object.keys(l).map((p)=>({id:p,render:async()=>{let b=typeof x[p]==="function"?await x[p]():void 0;return f(l[p],{...r,$boundary:b},t.sourceFile,y,new Set)}})),S=new Set(R.map((p)=>p.id));u=[...(u||[]).filter((p)=>!S.has(p.id)),...R]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:o}}async function nt(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Mo(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await g(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await D(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=cr(e);if(!c)return o;let u=o.indexOf("</head>");return u<0?c+o:o.slice(0,u)+c+o.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Mo(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=_(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?F(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(Ya(t.html,s)),context:e,cookies:r.cookies}}
31
31
  export{_i,ut,Ci,Se,O,Ei,js,$r,He,Ti,ke,$i,Ri,Ai,Bs,Pi,kn};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-ywqs7x8g.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-280p4q7a.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-5j970c0z.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-hvtzw1jh.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-r3e1avhs.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-280p4q7a.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-9ah1zsch.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-hvtzw1jh.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
4
4
  `)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{zn,Ee}from"./chunk-md2jn67b.js";import{L,y,rr,as,S}from"./chunk-p23sz4rr.js";import{o,R}from"./chunk-nytb5e4v.js";import{Js}from"./chunk-03wssg2z.js";import{Ze}from"./chunk-2zzc7006.js";import{c}from"./chunk-zhf01af3.js";import{i,et}from"./chunk-qjtpxsyx.js";import d from"path";import b from"fs";import{AsyncLocalStorage as ht}from"async_hooks";var xt=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Js(t,e,n)}var at=2;function ll(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function st(t,e){let n=t;for(let r of $t(e))if(r!==d.sep)n=n.split(r).join("\x00root");return n}var rt=new Map;function $t(t){let e=d.resolve(t),n=rt.get(e);if(!n){let r=e;try{r=b.realpathSync(e)}catch{}n=[...new Set([e,r])].sort((u,m)=>m.length-u.length),rt.set(e,n)}return n}function yt(t,e){try{let n=b.statSync(t),r=d.resolve(e),u=t.startsWith(`${r}${d.sep}`);return{path:u?d.relative(r,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function bt(t,e){for(let n of t){let r=ct(n,e);try{let u=b.statSync(r);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(r)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,wt=100;function ul(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function St(t){let e=G.get(t)??0;if(e>0&&e<wt){G.set(t,e+1);return}G.set(t,1);try{let n=(await b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),r=ul();if(n.length<=r)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,w)=>w.at-l.at);for(let l of m.slice(r)){let w=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${w}.js`),{force:!0}),await b.promises.rm(d.join(t,`${w}.deps.json`),{force:!0})}C("pruned bundle cache to",r,"entries")}catch{}}function Ce(t){return lt.get(t)??[]}function q(t,e){if(t)lt.set(t,e)}function dl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(dl())console.log("[stx:bundler]",...t)}var Y=[];function Qi(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Gt(){return Y.slice()}function Kt(){Y.length=0}var Z;function rp(t){Z=t}function ea(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Xt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let r=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=r.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Fn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function pl(t,e){return d.relative(t,e).split(d.sep).join("/")}function fl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,r,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Fn)?`${r}${u}${l}${u}`:n})}function gl(t,e){let n=0,r=(m)=>{let l=`__stxMod${n++}`,w=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let w of m.split(",")){let F=w.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],s=j[2]??p;e.push(`var ${s} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,w)=>{let F=w.slice(Fn.length),j=r(F),p=l.trim(),s=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(s&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${s[1]} = ${j}.default;`),p=p.slice(s[0].length).trim();let a=p.match(/^\*\s*as\s+([\w$]+)$/);if(a)e.push(`var ${a[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(r(l.slice(Fn.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new ht;function qs(t,e){let n=new Bun.CryptoHasher("md5");for(let[r,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${r}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Jt(){return K.getStore()?.key??""}function Bt(t,e,n,r,u,m=new Map,l,w){let F=(p,s,a)=>{if(X(s,t,l))return null;if(!u||p!==n||!vt.test(s))return null;try{if(!b.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}r.add(s);let h=`${Fn}${pl(process.cwd(),s)}`;return m.set(a,h),{path:h,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),h=d.resolve(a,s);return it(h)??h};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{let a=it(s.path);if(a){let h=F(s.importer,a,s.path);if(h)return h;if(a!==n)r.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),h=F(s.importer,a,s.path);if(h)return h;return r.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),h=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let I of h)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(s.importer,I,s.path);if(E)return E;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",I),r.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Fn}npm:${s.path}`;return m.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(X(s.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),h=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)r.add(s.path);let I=w?.get(s.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(s.path,"utf8"),loader:h}})}}}var H=new Map,z=y(64),ot=Symbol.for("stx.client-bundle-build-queue");function ml(t){let e=globalThis,r=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=r.then(()=>{return},()=>{return}),r}async function Yt(t,e,n={}){let r=n.projectRoot||process.cwd(),u=(await o(r)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||ll(r),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${xt}\x00${Ze()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${st(t,r)}\x00${st(e,r)}`);let s=p.digest("hex").slice(0,12),a=d.join(F,`${s}.js`),h=z.get(a);if(h){if(as(h.files)&&h.files.every((M)=>!X(M.path,r,u))){C("memo hit:",s);let M=h.files.map((A)=>A.path);return q(e,M),n.collectInputs?.push(...M),h.code}z.delete(a),C("memo invalidated by dep change:",s)}let I=d.join(F,`${s}.deps.json`),E=Bun.file(a);if(await E.exists()){let M=Bun.file(I),A=!1,O=null;if(await M.exists())try{let D=JSON.parse(await M.text());if(D.metadataVersion===at&&Array.isArray(D.files)&&bt(D.files,r))O=rr(D.files.map((g)=>ct(g,r))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,r,u))}catch{A=!1}if(A){if(C("cache hit:",s),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),g=new Date;if(b.promises.utimes(a,g,g).catch(()=>{}),O)z.set(a,{code:D,files:O});return D}C("cache invalidated by dep change:",s)}let P=H.get(s);if(P){let M=await P;if(n.collectInputs)n.collectInputs.push(...(z.get(a)?.files??[]).map((A)=>A.path));return M}let V=ml(()=>Et(t,e,{projectRoot:r,minify:m,cacheDir:F,hash:s,cachePath:a,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:w,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(s,V);try{return await V}finally{H.delete(s)}}var jt=0;function hl(t){return`${t}-${process.pid}-${++jt}`}async function Et(t,e,n){let{projectRoot:r,minify:u,cacheDir:m,hash:l,cachePath:w,depsPath:F,externalizeUserModules:j}=n,p=c(r,"bundle-tmp"),s=hl(l),a=d.join(p,`${s}.ts`),h=d.join(p,"out",s);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(h,{recursive:!0});let I=d.dirname(e),E=new Set,P=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=i(t),{depths:A,balanced:O}=et(M),D=(B)=>!O||A[B]===0,g;while((g=P.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((B)=>{let f=_t(B);if(f)E.add(f)});else if(g[3])E.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;E.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!D(g.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(g[1])E.add(g[1]);if(g[2])E.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let U=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(U)E.add(U)}}for(let B of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let ut=E.size>0?`
2
+ import{zn,Ee}from"./chunk-md2jn67b.js";import{L,y,rr,as,S}from"./chunk-2j996te9.js";import{o,R}from"./chunk-11c5q4h7.js";import{Js}from"./chunk-x3s7wxm6.js";import{Ze}from"./chunk-2zzc7006.js";import{c}from"./chunk-zhf01af3.js";import{i,et}from"./chunk-qjtpxsyx.js";import d from"path";import b from"fs";import{AsyncLocalStorage as ht}from"async_hooks";var xt=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Js(t,e,n)}var at=2;function ll(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function st(t,e){let n=t;for(let r of $t(e))if(r!==d.sep)n=n.split(r).join("\x00root");return n}var rt=new Map;function $t(t){let e=d.resolve(t),n=rt.get(e);if(!n){let r=e;try{r=b.realpathSync(e)}catch{}n=[...new Set([e,r])].sort((u,m)=>m.length-u.length),rt.set(e,n)}return n}function yt(t,e){try{let n=b.statSync(t),r=d.resolve(e),u=t.startsWith(`${r}${d.sep}`);return{path:u?d.relative(r,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function bt(t,e){for(let n of t){let r=ct(n,e);try{let u=b.statSync(r);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(r)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,wt=100;function ul(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function St(t){let e=G.get(t)??0;if(e>0&&e<wt){G.set(t,e+1);return}G.set(t,1);try{let n=(await b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),r=ul();if(n.length<=r)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,w)=>w.at-l.at);for(let l of m.slice(r)){let w=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${w}.js`),{force:!0}),await b.promises.rm(d.join(t,`${w}.deps.json`),{force:!0})}C("pruned bundle cache to",r,"entries")}catch{}}function Ce(t){return lt.get(t)??[]}function q(t,e){if(t)lt.set(t,e)}function dl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(dl())console.log("[stx:bundler]",...t)}var Y=[];function Qi(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Gt(){return Y.slice()}function Kt(){Y.length=0}var Z;function rp(t){Z=t}function ea(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Xt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let r=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=r.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Fn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function pl(t,e){return d.relative(t,e).split(d.sep).join("/")}function fl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,r,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Fn)?`${r}${u}${l}${u}`:n})}function gl(t,e){let n=0,r=(m)=>{let l=`__stxMod${n++}`,w=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let w of m.split(",")){let F=w.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],s=j[2]??p;e.push(`var ${s} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,w)=>{let F=w.slice(Fn.length),j=r(F),p=l.trim(),s=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(s&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${s[1]} = ${j}.default;`),p=p.slice(s[0].length).trim();let a=p.match(/^\*\s*as\s+([\w$]+)$/);if(a)e.push(`var ${a[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(r(l.slice(Fn.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new ht;function qs(t,e){let n=new Bun.CryptoHasher("md5");for(let[r,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${r}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Jt(){return K.getStore()?.key??""}function Bt(t,e,n,r,u,m=new Map,l,w){let F=(p,s,a)=>{if(X(s,t,l))return null;if(!u||p!==n||!vt.test(s))return null;try{if(!b.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}r.add(s);let h=`${Fn}${pl(process.cwd(),s)}`;return m.set(a,h),{path:h,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),h=d.resolve(a,s);return it(h)??h};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{let a=it(s.path);if(a){let h=F(s.importer,a,s.path);if(h)return h;if(a!==n)r.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),h=F(s.importer,a,s.path);if(h)return h;return r.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),h=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let I of h)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(s.importer,I,s.path);if(E)return E;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",I),r.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Fn}npm:${s.path}`;return m.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(X(s.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),h=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)r.add(s.path);let I=w?.get(s.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(s.path,"utf8"),loader:h}})}}}var H=new Map,z=y(64),ot=Symbol.for("stx.client-bundle-build-queue");function ml(t){let e=globalThis,r=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=r.then(()=>{return},()=>{return}),r}async function Yt(t,e,n={}){let r=n.projectRoot||process.cwd(),u=(await o(r)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||ll(r),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${xt}\x00${Ze()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${st(t,r)}\x00${st(e,r)}`);let s=p.digest("hex").slice(0,12),a=d.join(F,`${s}.js`),h=z.get(a);if(h){if(as(h.files)&&h.files.every((M)=>!X(M.path,r,u))){C("memo hit:",s);let M=h.files.map((A)=>A.path);return q(e,M),n.collectInputs?.push(...M),h.code}z.delete(a),C("memo invalidated by dep change:",s)}let I=d.join(F,`${s}.deps.json`),E=Bun.file(a);if(await E.exists()){let M=Bun.file(I),A=!1,O=null;if(await M.exists())try{let D=JSON.parse(await M.text());if(D.metadataVersion===at&&Array.isArray(D.files)&&bt(D.files,r))O=rr(D.files.map((g)=>ct(g,r))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,r,u))}catch{A=!1}if(A){if(C("cache hit:",s),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),g=new Date;if(b.promises.utimes(a,g,g).catch(()=>{}),O)z.set(a,{code:D,files:O});return D}C("cache invalidated by dep change:",s)}let P=H.get(s);if(P){let M=await P;if(n.collectInputs)n.collectInputs.push(...(z.get(a)?.files??[]).map((A)=>A.path));return M}let V=ml(()=>Et(t,e,{projectRoot:r,minify:m,cacheDir:F,hash:s,cachePath:a,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:w,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(s,V);try{return await V}finally{H.delete(s)}}var jt=0;function hl(t){return`${t}-${process.pid}-${++jt}`}async function Et(t,e,n){let{projectRoot:r,minify:u,cacheDir:m,hash:l,cachePath:w,depsPath:F,externalizeUserModules:j}=n,p=c(r,"bundle-tmp"),s=hl(l),a=d.join(p,`${s}.ts`),h=d.join(p,"out",s);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(h,{recursive:!0});let I=d.dirname(e),E=new Set,P=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=i(t),{depths:A,balanced:O}=et(M),D=(B)=>!O||A[B]===0,g;while((g=P.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((B)=>{let f=_t(B);if(f)E.add(f)});else if(g[3])E.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;E.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!D(g.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(g[1])E.add(g[1]);if(g[2])E.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let U=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(U)E.add(U)}}for(let B of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let ut=E.size>0?`
3
3
  export { ${[...E].join(", ")} }`:"";await Bun.write(a,t+ut),C("bundling:",l,"from:",d.basename(e));let tt=new Set,nt=new Map;try{let B=await Bun.build({entrypoints:[a],outdir:h,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[Bt(r,I,a,tt,j,nt,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...S()},root:r});if(!B.success){let _=B.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${d.basename(e)}`,k=zn(B.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",_),Qi(e||"",_,k),n.throwOnFailure||ea()==="error")throw Error(_);return t}let f="";for(let x of B.outputs){f=await x.text();break}let v=[];for(let x of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let _ of x[1].split(",")){let k=_.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k){v.push([k[2],k[1]]);continue}let N=_.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))v.push([N,N])}if(n.expose){let x=new Set(n.expose);for(let _=v.length-1;_>=0;_--)if(!x.has(v[_][0]))v.splice(_,1)}let U=[];f=gl(fl(f,nt),U);let dt=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${l}`,pt=new Set(L(t,!0).split(",").map((x)=>x.trim())),ft=v.map(([x,_])=>`get ${JSON.stringify(x)}() { return ${_} }${pt.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${_}) { ${_} = __stxValue_${_} }`:""}`).join(", "),mt=v.map(([x])=>`var ${x} = undefined;`).join(`
4
4
  `),gt=v.map(([x])=>`${x} = ${J}[${JSON.stringify(x)}];`).join(`
5
5
  `);if(f=`${dt.join(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{x}from"./chunk-pxdww4rb.js";import{T,vn}from"./chunk-ce6zddpf.js";import{rn,y,b,S,G}from"./chunk-p23sz4rr.js";import{o}from"./chunk-nytb5e4v.js";import{Ce,Xt,Jt,Yt}from"./chunk-4b1ed4qv.js";import{ht}from"./chunk-ynyssmdy.js";import{pt,In,Wt,se}from"./chunk-npa7gze7.js";import{C,yr}from"./chunk-fbtv2k1p.js";import w from"path";var v=new Map,k=new Map,A=y(64),E=new Map,Z=["composables","functions"];function z(t){let n=w.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function q(t){if(t)return w.resolve(t);let n=`<default>:${process.cwd()}`,a=E.get(n);if(a!==void 0)return a;let e=await Q();if(e!==null)E.set(n,e);return e}async function Q(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return w.resolve(n,a);for(let e of Z){let s=w.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!z(c))return s}catch{}}return null}async function J(t){let n=Array.isArray(t)?t:t?[w.resolve(t)]:(await o())._layerComposableDirs??[await q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=w.relative(e,d);if(!z(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function zs(t){let{files:n}=await J(t),a=G({loader:"ts",target:"browser",define:S()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((m)=>m!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function V(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function L(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):V(t,s))e.add(s);return e}var U=y(64);function Y(t,n){let a=b(t,n.size),e=U.get(a);if(e)return e;let s;try{s=rn(t,n)}catch{s=L(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let m of c[1].split(",")){let p=m.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(p&&n.has(p))s.add(p)}return U.set(a,s),s}function ee(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of L(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of Y(u,d))l.push(e.get(f));return l},m=new Set,p=a.flatMap((u,l)=>l===0?s(u):c(u));while(p.length>0){let u=[];for(let l of p){if(m.has(l))continue;m.add(l);for(let f of c(n.get(l)??""))if(!m.has(f))u.push(f)}p=u}return m}async function zd(t,n,a){let{key:e,files:s}=await J(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>Ce(r))])],c=pt(d());if(s.length===0)return se(v,e,c,""),null;s.sort();let m=G({loader:"ts",target:"browser",define:S()}),p=Wt(k,e,c);if(!p){let r=new Map,i=[];for(let g of s)try{let h=await Bun.file(g).text();r.set(g,h);let _=m.scan(h).exports.filter((X)=>X!=="default");if(_.length>0)i.push({file:g,names:_})}catch{r.set(g,"")}p=se(k,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=p,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=b(r.join("\x00"),e,r.length,c),g=A.get(i);if(f=g??ee(l,u,r),!g)A.set(i,f)}if(f.size===0)return null;let I=s.filter((r)=>f.has(r)),M=`${e}\x00${I.join("\x00")}\x00${Jt()}`,F=Wt(v,M,c);if(F!==void 0)return F||null;let N=[],B=new Set,R=new Set;for(let r of I)try{let i=u.get(r)??await Bun.file(r).text(),g=w.basename(r,".ts");for(let _ of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(_[1])R.add(_[1]);let h=[];try{for(let _ of m.scan(i).exports)if(_!=="default")B.add(_),h.push(_)}catch{}if(i=T(i),Xt(i))i=await Yt(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:h}),i=ht(i);i=vn(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=m.transformSync(i),N.push(`// Composable: ${g}
2
+ import{x}from"./chunk-pxdww4rb.js";import{T,vn}from"./chunk-ce6zddpf.js";import{rn,y,b,S,G}from"./chunk-2j996te9.js";import{o}from"./chunk-11c5q4h7.js";import{Ce,Xt,Jt,Yt}from"./chunk-7fk5ygvh.js";import{ht}from"./chunk-kezhxaye.js";import{pt,In,Wt,se}from"./chunk-npa7gze7.js";import{C,yr}from"./chunk-fbtv2k1p.js";import w from"path";var v=new Map,k=new Map,A=y(64),E=new Map,Z=["composables","functions"];function z(t){let n=w.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function q(t){if(t)return w.resolve(t);let n=`<default>:${process.cwd()}`,a=E.get(n);if(a!==void 0)return a;let e=await Q();if(e!==null)E.set(n,e);return e}async function Q(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return w.resolve(n,a);for(let e of Z){let s=w.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!z(c))return s}catch{}}return null}async function J(t){let n=Array.isArray(t)?t:t?[w.resolve(t)]:(await o())._layerComposableDirs??[await q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=w.relative(e,d);if(!z(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function zs(t){let{files:n}=await J(t),a=G({loader:"ts",target:"browser",define:S()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((m)=>m!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function V(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function L(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):V(t,s))e.add(s);return e}var U=y(64);function Y(t,n){let a=b(t,n.size),e=U.get(a);if(e)return e;let s;try{s=rn(t,n)}catch{s=L(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let m of c[1].split(",")){let p=m.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(p&&n.has(p))s.add(p)}return U.set(a,s),s}function ee(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of L(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of Y(u,d))l.push(e.get(f));return l},m=new Set,p=a.flatMap((u,l)=>l===0?s(u):c(u));while(p.length>0){let u=[];for(let l of p){if(m.has(l))continue;m.add(l);for(let f of c(n.get(l)??""))if(!m.has(f))u.push(f)}p=u}return m}async function zd(t,n,a){let{key:e,files:s}=await J(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>Ce(r))])],c=pt(d());if(s.length===0)return se(v,e,c,""),null;s.sort();let m=G({loader:"ts",target:"browser",define:S()}),p=Wt(k,e,c);if(!p){let r=new Map,i=[];for(let g of s)try{let h=await Bun.file(g).text();r.set(g,h);let _=m.scan(h).exports.filter((X)=>X!=="default");if(_.length>0)i.push({file:g,names:_})}catch{r.set(g,"")}p=se(k,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=p,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=b(r.join("\x00"),e,r.length,c),g=A.get(i);if(f=g??ee(l,u,r),!g)A.set(i,f)}if(f.size===0)return null;let I=s.filter((r)=>f.has(r)),M=`${e}\x00${I.join("\x00")}\x00${Jt()}`,F=Wt(v,M,c);if(F!==void 0)return F||null;let N=[],B=new Set,R=new Set;for(let r of I)try{let i=u.get(r)??await Bun.file(r).text(),g=w.basename(r,".ts");for(let _ of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(_[1])R.add(_[1]);let h=[];try{for(let _ of m.scan(i).exports)if(_!=="default")B.add(_),h.push(_)}catch{}if(i=T(i),Xt(i))i=await Yt(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:h}),i=ht(i);i=vn(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=m.transformSync(i),N.push(`// Composable: ${g}
3
3
  ${i.trim()}`)}catch(i){console.warn(`[stx] Failed to load composable ${r}:`,i)}if(N.length===0||B.size===0)return se(v,M,c,""),null;let H=[...B].map((r)=>` try { if (!(${JSON.stringify(r)} in __c)) __c[${JSON.stringify(r)}] = ${r}; } catch (e) {}`).join(`
4
4
  `),j=JSON.stringify([...B]),D=N.join(`
5
5
 
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Hi,Vi,Ui,Wi,tp}from"./chunk-erpjegf6.js";import"./chunk-ym09kjfr.js";import"./chunk-yfvm7q6t.js";import"./chunk-w63hh78w.js";import"./chunk-s45a5axx.js";import"./chunk-prf164ct.js";import"./chunk-1pw1nvta.js";import"./chunk-1zeerj7e.js";import"./chunk-ttszb0qr.js";import"./chunk-ka8befem.js";import"./chunk-kezhxaye.js";import"./chunk-k35fd0mn.js";import"./chunk-p472crv1.js";import"./chunk-j2318qfk.js";import"./chunk-11c5q4h7.js";import"./chunk-m6zpcyhm.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-2j996te9.js";import"./chunk-10np2c03.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Hi as buildNative,tp as default,Vi as findCraftBinary,Wi as getAvailableFormats,Ui as getAvailableTargets};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ye,Io,Oo,Kl,Pt,Wa,No,qa,$p,Oe,dn,Ne}from"./chunk-p23sz4rr.js";import{Za,i}from"./chunk-qjtpxsyx.js";import"./chunk-144yp2bw.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{ye as BROWSER_CORE_IMPORTS,Kl as STX_AUTO_IMPORTS,Io as extractAndStripCssImports,Oe as extractBridgeData,Za as findInterpolationEnd,qa as generateAutoImportDestructuring,$p as generateBrowserAutoImportDestructuring,dn as generateServerDataBridge,Pt as injectBrowserCoreAutoImports,Ne as processClientScript,No as referencesName,Oo as renderVendorStyleTags,i as stripCommentsAndLiterals,Wa as transformAutoImports};
2
+ import{ye,Io,Oo,Kl,Pt,Wa,No,qa,$p,Oe,dn,Ne}from"./chunk-2j996te9.js";import{Za,i}from"./chunk-qjtpxsyx.js";import"./chunk-10np2c03.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{ye as BROWSER_CORE_IMPORTS,Kl as STX_AUTO_IMPORTS,Io as extractAndStripCssImports,Oe as extractBridgeData,Za as findInterpolationEnd,qa as generateAutoImportDestructuring,$p as generateBrowserAutoImportDestructuring,dn as generateServerDataBridge,Pt as injectBrowserCoreAutoImports,Ne as processClientScript,No as referencesName,Oo as renderVendorStyleTags,i as stripCommentsAndLiterals,Wa as transformAutoImports};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Hn,s}from"./chunk-w63hh78w.js";import"./chunk-s45a5axx.js";import"./chunk-prf164ct.js";import"./chunk-1pw1nvta.js";import"./chunk-1zeerj7e.js";import"./chunk-ttszb0qr.js";import"./chunk-ka8befem.js";import"./chunk-kezhxaye.js";import{me}from"./chunk-k35fd0mn.js";import"./chunk-p472crv1.js";import"./chunk-j2318qfk.js";import"./chunk-11c5q4h7.js";import"./chunk-m6zpcyhm.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{Ae,ps,gs}from"./chunk-2j996te9.js";import"./chunk-10np2c03.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Hn as buildModulesTag,me as injectRouterScript,s as processDirectives,ps as processJsonDirective,gs as processOnceDirective,Ae as validateClientScript};