@stacksjs/stx 0.2.433 → 0.2.435

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 (72) hide show
  1. package/dist/{chunk-vbb02yfw.js → chunk-07msc1vh.js} +1 -1
  2. package/dist/{chunk-2psf6w7b.js → chunk-0dznqr6k.js} +1 -1
  3. package/dist/{chunk-f4m0n9hr.js → chunk-0z8xzxfc.js} +1 -1
  4. package/dist/{chunk-b1qa6444.js → chunk-1534j0n1.js} +1 -1
  5. package/dist/{chunk-bge8ptbd.js → chunk-19wv5pne.js} +1 -1
  6. package/dist/{chunk-eaa5rxst.js → chunk-1yj3p63h.js} +1 -1
  7. package/dist/{chunk-sw8j8rnc.js → chunk-2et1dj7c.js} +18 -18
  8. package/dist/{chunk-7ynzah39.js → chunk-4012xfcj.js} +2 -2
  9. package/dist/{chunk-61r70km9.js → chunk-4h9rz30n.js} +1 -1
  10. package/dist/{chunk-sce9mzjk.js → chunk-5p4n22fg.js} +1 -1
  11. package/dist/{chunk-rf4xssb2.js → chunk-5tk57ys5.js} +1 -1
  12. package/dist/{chunk-gnghq9yc.js → chunk-5zahqrb4.js} +30 -21
  13. package/dist/{chunk-b8r87s8q.js → chunk-776ks4wf.js} +1 -1
  14. package/dist/{chunk-7g7500r7.js → chunk-893f4hrd.js} +2 -2
  15. package/dist/chunk-8tsw7knf.js +12 -0
  16. package/dist/{chunk-82kf8t4n.js → chunk-a64dan1y.js} +1 -1
  17. package/dist/{chunk-3yrg4kfm.js → chunk-a9b5dmc9.js} +1 -1
  18. package/dist/chunk-cmbbd7ps.js +2 -0
  19. package/dist/{chunk-r7xbp439.js → chunk-d308ypdw.js} +1 -1
  20. package/dist/{chunk-b9a5hkm2.js → chunk-ecbmrwc3.js} +2 -2
  21. package/dist/{chunk-tdx1srqq.js → chunk-etfmz6p7.js} +1 -1
  22. package/dist/{chunk-pd0qtjj1.js → chunk-f3mg21zr.js} +1 -1
  23. package/dist/{chunk-a16fcrd1.js → chunk-feray2ev.js} +1 -1
  24. package/dist/{chunk-kvzbmn2x.js → chunk-fgwb8b88.js} +1 -1
  25. package/dist/{chunk-vswb4bcb.js → chunk-gsa2vky0.js} +1 -1
  26. package/dist/{chunk-xhnn2yj8.js → chunk-hghcmsep.js} +1 -1
  27. package/dist/{chunk-xdv4d3vt.js → chunk-k04yan0c.js} +1 -1
  28. package/dist/{chunk-zf4zdasc.js → chunk-mcw143mv.js} +1 -1
  29. package/dist/{chunk-d5xnsqj9.js → chunk-nyvrb6eh.js} +1 -1
  30. package/dist/{chunk-yr7b4x3y.js → chunk-pa2fxxrt.js} +1 -1
  31. package/dist/{chunk-jadv7091.js → chunk-phns4nad.js} +1 -1
  32. package/dist/{chunk-51a50b67.js → chunk-pqmzy39h.js} +1 -1
  33. package/dist/{chunk-cqwbzm5r.js → chunk-pxygk16f.js} +1 -1
  34. package/dist/chunk-qz3sxfjr.js +2 -0
  35. package/dist/chunk-raqqxty4.js +17 -0
  36. package/dist/{chunk-q0vpbe85.js → chunk-rf7n3776.js} +1 -1
  37. package/dist/{chunk-p07v3har.js → chunk-rnmkg4hc.js} +1 -1
  38. package/dist/{chunk-adgn0e36.js → chunk-sfytxcwt.js} +1 -1
  39. package/dist/{chunk-yqtqqsaa.js → chunk-sp8qsp66.js} +1 -1
  40. package/dist/{chunk-zaz9phx6.js → chunk-tt5nw557.js} +5 -5
  41. package/dist/{chunk-d347pv7p.js → chunk-vsvgqdre.js} +1 -1
  42. package/dist/{chunk-ssrcvz36.js → chunk-vw8a7yfw.js} +1 -1
  43. package/dist/{chunk-dkbcfevd.js → chunk-w4qe1yfn.js} +1 -1
  44. package/dist/{chunk-ec32acc4.js → chunk-wwbqqzxv.js} +1 -1
  45. package/dist/{chunk-f0f7qv7t.js → chunk-x7dtm6js.js} +1 -1
  46. package/dist/{chunk-848mx840.js → chunk-xy1hvcc7.js} +1 -1
  47. package/dist/chunk-y36vq63a.js +2 -0
  48. package/dist/{chunk-52pc79vk.js → chunk-ypy48knb.js} +1 -1
  49. package/dist/{chunk-720pm5yj.js → chunk-zmexq8hg.js} +1 -1
  50. package/dist/chunk-zyrt05fv.js +2 -0
  51. package/dist/{chunk-z5vkrfn5.js → chunk-zzys2tcw.js} +1 -1
  52. package/dist/cli.js +8 -8
  53. package/dist/client-script-bundler.js +27 -1
  54. package/dist/composables/index.d.ts +2 -0
  55. package/dist/composables/index.js +1 -0
  56. package/dist/craft-entry.js +1 -1
  57. package/dist/craft.js +1 -1
  58. package/dist/native/compiler/html-to-ir.js +2 -0
  59. package/dist/native/runtime/native-host.js +1 -0
  60. package/dist/pwa.js +1 -1
  61. package/dist/runtime-globals.d.ts +2 -1
  62. package/dist/runtime-globals.js +1 -1
  63. package/dist/signals.js +29 -20
  64. package/dist/ssg.js +2 -2
  65. package/dist/unresolved-identifiers.js +1 -0
  66. package/package.json +5 -5
  67. package/dist/chunk-2q95we1n.js +0 -17
  68. package/dist/chunk-7wfa6665.js +0 -2
  69. package/dist/chunk-epf4s6qm.js +0 -2
  70. package/dist/chunk-wg36jd98.js +0 -2
  71. package/dist/chunk-ynzyzrqs.js +0 -12
  72. package/dist/chunk-zt89wcns.js +0 -2
@@ -239,7 +239,8 @@ export declare function runtimeDirectiveNamesLiteral(): string;
239
239
  /**
240
240
  * Event names a bare `:name` or `@name` is read as a listener for.
241
241
  *
242
- * Prefix-matched, so `click` also covers `click.stop` and `click.prevent`.
242
+ * A dot starts event modifiers, so `click.stop` matches but `scroll-target`
243
+ * remains an attribute binding.
243
244
  */
244
245
  export declare const RUNTIME_EVENT_NAMES: readonly string[];
245
246
  /** The `EVENT_RE` the generated runtime embeds, as JS source. */
@@ -251,7 +251,7 @@ export const RUNTIME_EVENT_NAMES = [
251
251
  "pointermove"
252
252
  ];
253
253
  export function runtimeEventRegexLiteral() {
254
- return `/^(${RUNTIME_EVENT_NAMES.join("|")})/`;
254
+ return `/^(${RUNTIME_EVENT_NAMES.join("|")})(?:\\.|$)/`;
255
255
  }
256
256
  export function isRuntimeEventName(name) {
257
257
  return RUNTIME_EVENT_NAMES.some((event) => name === event || name.startsWith(`${event}.`));
package/dist/signals.js CHANGED
@@ -82,6 +82,8 @@ console.log('[stx] entering IIFE');
82
82
  var stxHost = window.__stx_host || {
83
83
  setText: function(node, value) { node.textContent = value; },
84
84
  setAttribute: function(node, name, value) {
85
+ if (value === false) { node.removeAttribute(name); return; }
86
+ if (value === true) { node.setAttribute(name, ''); return; }
85
87
  var next = value;
86
88
  if (typeof value === 'object' && value !== null) {
87
89
  try { next = JSON.stringify(value); }
@@ -91,8 +93,17 @@ console.log('[stx] entering IIFE');
91
93
  },
92
94
  removeAttribute: function(node, name) { node.removeAttribute(name); },
93
95
  setStyle: function(node, value) {
94
- if (typeof value === 'object' && value !== null) Object.assign(node.style, value);
95
- else if (typeof value === 'string') node.style.cssText = value;
96
+ if (typeof value === 'object' && value !== null) {
97
+ Object.assign(node.style, value);
98
+ if (Object.prototype.hasOwnProperty.call(value, 'display')) node.__stx_display = value.display || '';
99
+ }
100
+ else if (typeof value === 'string') {
101
+ node.style.cssText = value;
102
+ node.__stx_display = node.style.display || '';
103
+ }
104
+ // Reactive style updates must not clear the display:none owned by :show.
105
+ // This also keeps the latest explicit display for when the gate opens.
106
+ if (node.__stx_visible === false) node.style.display = 'none';
96
107
  },
97
108
 
98
109
  // Structural operations, for the bindings that build rows rather than
@@ -143,6 +154,7 @@ console.log('[stx] entering IIFE');
143
154
  node.__stx_display = (d && d !== 'none') ? d : '';
144
155
  }
145
156
  var was = node.style.display !== 'none';
157
+ node.__stx_visible = visible;
146
158
  node.style.display = visible ? node.__stx_display : 'none';
147
159
  return was;
148
160
  },
@@ -2711,23 +2723,16 @@ catch (e) {
2711
2723
  value = undefined;
2712
2724
  }
2713
2725
 
2714
- // ARIA states are strings, unlike HTML boolean attributes.
2726
+ // Preserve native prop types; the DOM host reflects boolean presence
2727
+ // and serializes structured values at its own boundary.
2715
2728
  if (name.startsWith('aria-') && typeof value === 'boolean') {
2716
- el.setAttribute(name, String(value));
2717
- }
2718
- else if (value === false || value === null || value === undefined) {
2719
- el.removeAttribute(name);
2729
+ stxHost.setAttribute(el, name, String(value));
2720
2730
  }
2721
- else if (value === true) {
2722
- el.setAttribute(name, '');
2731
+ else if (value === null || value === undefined) {
2732
+ stxHost.removeAttribute(el, name);
2723
2733
  }
2724
2734
  else {
2725
- var serialized = value;
2726
- if (typeof value === 'object') {
2727
- try { serialized = JSON.stringify(value); }
2728
- catch (e) { serialized = String(value); }
2729
- }
2730
- el.setAttribute(name, serialized);
2735
+ stxHost.setAttribute(el, name, value);
2731
2736
  }
2732
2737
  // The component setup scope is already registered for normal and
2733
2738
  // cloned signal components. Update its prop signal directly so object
@@ -3326,13 +3331,13 @@ catch (e2) {
3326
3331
  return;
3327
3332
  }
3328
3333
  if (attrName.startsWith('aria-') && typeof v === 'boolean') {
3329
- el.setAttribute(attrName, String(v));
3334
+ stxHost.setAttribute(el, attrName, String(v));
3330
3335
  }
3331
- else if (v === false || v === null || v === undefined) {
3332
- stxHost.removeAttribute(el, attrName);
3336
+ else if (typeof v === 'boolean') {
3337
+ stxHost.setAttribute(el, attrName, v);
3333
3338
  }
3334
- else if (v === true) {
3335
- el.setAttribute(attrName, '');
3339
+ else if (v === null || v === undefined) {
3340
+ stxHost.removeAttribute(el, attrName);
3336
3341
  }
3337
3342
  else {
3338
3343
  var attrValue = v;
@@ -4903,6 +4908,10 @@ catch (e) {
4903
4908
  var FOR_ATTRS = [':for', 'x-for', '@for'];
4904
4909
  function deferRowConditionals(root) {
4905
4910
  if (!root || !root.querySelectorAll || typeof document === 'undefined' || !document.createElement) return;
4911
+ // Inert HTML template content is a DOM allocation optimisation. Native
4912
+ // hosts already clone recorded descriptors and bind conditions through
4913
+ // their host operations; their document facade has no template content.
4914
+ if (!document.createElement('template').content) return;
4906
4915
  // A walk, not a selector: escaping ':' and '@' in an attribute selector
4907
4916
  // through this generated source is easy to get wrong, and wrong throws.
4908
4917
  var candidates = Array.prototype.slice.call(root.querySelectorAll('*'));
package/dist/ssg.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-b9wpgn7b.js";import"./chunk-8x47zcfa.js";import{Qe,et,tt,nt,rt,st}from"./chunk-pxqs3psa.js";import"./chunk-eaa5rxst.js";import"./chunk-axydabse.js";import{f,je,M,q,n,i}from"./chunk-sw8j8rnc.js";import"./chunk-721yq8qx.js";import{Yn}from"./chunk-my3jkpv7.js";import"./chunk-ptjqacjd.js";import"./chunk-720pm5yj.js";import"./chunk-114zdbnd.js";import"./chunk-t7x753ga.js";import"./chunk-2psf6w7b.js";import{oe,ft,gt}from"./chunk-2q95we1n.js";import{$i,Ei,Ti}from"./chunk-ccq35xp7.js";import{dt,Xt,Gt}from"./chunk-yd50awqp.js";import"./chunk-8wkja2z2.js";import{a}from"./chunk-wtms9jhs.js";import x from"fs";import g from"path";import{createHash as $t}from"crypto";function Dt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Rt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function kt(t){return Bun.hash(t).toString(16)}function lt(t,s={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let o=new Map,r=t.replace(Rt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(s.minify)h=Dt(h);let S=kt(h);if(!o.has(S))o.set(S,h);let P=s.integrity?` data-stx-integrity="sha384-${$t("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(o,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Ct=new Set(["visible","idle"]);function ut(t){if(!t.includes("data-stx-src="))return t;let s=new Map,o=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=o.exec(t))!==null)s.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Ct.has(s.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function J(t){let s=t.trim();if(!s)return null;let o=/^https?:\/\//i.test(s)?s:`https://${s}`;try{return new URL(o).origin+new URL(o).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let s of Et){let o=t[s];if(!o)continue;let r=J(o);if(r)return{url:r,source:"env",via:s}}return null}function pt(t){if(!t||typeof t!=="object")return null;let s=t,o=s.site?.url??s.url??s.app?.url;return typeof o==="string"?J(o):null}async function Bt(t){let{existsSync:s}=await import("fs"),o=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=o.resolve(t,r);if(!s(c))continue;try{let e=await import(c),l=pt(e.default??e);if(l)return l}catch{}}return null}async function ht(t={}){let s=t.cwd??process.cwd(),o=t.env??process.env;if(t.explicit){let l=J(t.explicit);if(l)return{url:l,source:"option"}}let r=pt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(s);if(c)return{url:c,source:"site.config",via:"url"};let e=It(o);if(e)return e;return{url:"http://localhost",source:"fallback"}}function mt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
2
+ import"./chunk-b9wpgn7b.js";import"./chunk-8x47zcfa.js";import{Qe,et,tt,nt,rt,st}from"./chunk-pxqs3psa.js";import"./chunk-1yj3p63h.js";import"./chunk-axydabse.js";import{f,je,M,q,n,i}from"./chunk-2et1dj7c.js";import"./chunk-721yq8qx.js";import{Yn}from"./chunk-my3jkpv7.js";import"./chunk-ptjqacjd.js";import"./chunk-zmexq8hg.js";import"./chunk-114zdbnd.js";import"./chunk-t7x753ga.js";import"./chunk-0dznqr6k.js";import{oe,ft,gt}from"./chunk-raqqxty4.js";import{$i,Ei,Ti}from"./chunk-ccq35xp7.js";import{dt,Xt,Gt}from"./chunk-yd50awqp.js";import"./chunk-8wkja2z2.js";import{a}from"./chunk-wtms9jhs.js";import x from"fs";import g from"path";import{createHash as $t}from"crypto";function Dt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Rt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function kt(t){return Bun.hash(t).toString(16)}function lt(t,s={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let o=new Map,r=t.replace(Rt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(s.minify)h=Dt(h);let S=kt(h);if(!o.has(S))o.set(S,h);let P=s.integrity?` data-stx-integrity="sha384-${$t("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(o,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Ct=new Set(["visible","idle"]);function ut(t){if(!t.includes("data-stx-src="))return t;let s=new Map,o=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=o.exec(t))!==null)s.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Ct.has(s.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function J(t){let s=t.trim();if(!s)return null;let o=/^https?:\/\//i.test(s)?s:`https://${s}`;try{return new URL(o).origin+new URL(o).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let s of Et){let o=t[s];if(!o)continue;let r=J(o);if(r)return{url:r,source:"env",via:s}}return null}function pt(t){if(!t||typeof t!=="object")return null;let s=t,o=s.site?.url??s.url??s.app?.url;return typeof o==="string"?J(o):null}async function Bt(t){let{existsSync:s}=await import("fs"),o=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=o.resolve(t,r);if(!s(c))continue;try{let e=await import(c),l=pt(e.default??e);if(l)return l}catch{}}return null}async function ht(t={}){let s=t.cwd??process.cwd(),o=t.env??process.env;if(t.explicit){let l=J(t.explicit);if(l)return{url:l,source:"option"}}let r=pt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(s);if(c)return{url:c,source:"site.config",via:"url"};let e=It(o);if(e)return e;return{url:"http://localhost",source:"fallback"}}function mt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
3
  `)}class wt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,s=""){this.cacheDir=t,this.salt=s}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let s=JSON.parse(await Bun.file(t).text());for(let[o,r]of Object.entries(s))this.cache.set(o,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),s={};for(let[o,r]of this.cache)s[o]=r;await Bun.write(t,JSON.stringify(s))}getHash(t,s){let o=x.statSync(t),r=`${this.salt}|${t}:${o.mtimeMs}`;for(let e of s)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,s){let o=this.cache.get(t);if(!o)return null;let r=this.getHash(s,o.dependencies??[]);if(o.hash!==r)return this.cache.delete(t),null;return o.html}set(t,s,o,r){let c=this.getHash(s,o);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:o})}}class yt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let s=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",s)}async get(t){let s=this.getFilePath(t);if(!await Bun.file(s).exists())return null;try{return JSON.parse(await Bun.file(s).text())}catch{return null}}async set(t,s){let o=this.getFilePath(t);await x.promises.mkdir(g.dirname(o),{recursive:!0}),await Bun.write(o,JSON.stringify(s))}async invalidate(t){let s=this.getFilePath(t);if(await Bun.file(s).exists())await x.promises.unlink(s)}async invalidatePattern(t){let s=g.join(this.cacheDir,"isr");if(!x.existsSync(s))return;let o=await x.promises.readdir(s);for(let r of o){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(s,r))}}async needsRevalidation(t){let s=await this.get(t);if(!s)return!0;return Date.now()>s.revalidateAfter}}async function jt(t){try{let o=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let r=o[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
4
4
  return (async function getStaticPaths() {
5
5
  ${c[1]}
@@ -41,7 +41,7 @@ ${t.map((r)=>{let c=new URL(r.loc,s).href,e=` <url>
41
41
  ${o.join(`
42
42
  `)}
43
43
  </channel>
44
- </rss>`}async function zt(t={}){let s=Date.now();gt();let o=await i(process.cwd()),r=o.build||{},c=await ht({explicit:t.domain||r.domain,stxConfig:o});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(mt());let e={router:t.router??o?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||o?.partialsDir||"",componentsDir:t.componentsDir||o?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-cqwbzm5r.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-r7xbp439.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new wt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-cqwbzm5r.js");await u('<div class="bg-black"></div>')}catch{}Qe();let xt=o?.routeMiddleware?.dir||"middleware";await tt(process.cwd(),xt);let H=et();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=o?.routeMiddleware?.global||[];Ti(o?.layoutsDir,a(process.cwd()));let K=M(".",{pagesDir:e.pagesDir,pagesDirs:o?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ft(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:bt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),Pt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],it=[...vt,...Pt];if(it.length>0){let C=nt(d,L,F||{}),O=rt(C,null,void 0,{isServer:!0}),E=await st(it,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let at=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(at)try{if(!await Function("route",`
44
+ </rss>`}async function zt(t={}){let s=Date.now();gt();let o=await i(process.cwd()),r=o.build||{},c=await ht({explicit:t.domain||r.domain,stxConfig:o});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(mt());let e={router:t.router??o?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||o?.partialsDir||"",componentsDir:t.componentsDir||o?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-pxygk16f.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-d308ypdw.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new wt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-pxygk16f.js");await u('<div class="bg-black"></div>')}catch{}Qe();let xt=o?.routeMiddleware?.dir||"middleware";await tt(process.cwd(),xt);let H=et();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=o?.routeMiddleware?.global||[];Ti(o?.layoutsDir,a(process.cwd()));let K=M(".",{pagesDir:e.pagesDir,pagesDirs:o?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ft(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:bt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),Pt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],it=[...vt,...Pt];if(it.length>0){let C=nt(d,L,F||{}),O=rt(C,null,void 0,{isServer:!0}),E=await st(it,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let at=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(at)try{if(!await Function("route",`
45
45
  const validate = ${at[1]};
46
46
  return validate(route);
47
47
  `)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ot=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ot=!0,l.cachedCount++}if(!k){let C=await St(v,L,bt,e,o);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
@@ -65,6 +65,7 @@ export const SERVER_ONLY_COMPOSABLES = [
65
65
  "useBattery",
66
66
  "useBreakpoint",
67
67
  "useBroadcastChannel",
68
+ "useBroadcastStream",
68
69
  "useChannel",
69
70
  "useChildListObserver",
70
71
  "useClipboard",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.433",
4
+ "version": "0.2.435",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -122,12 +122,12 @@
122
122
  "dependencies": {
123
123
  "@stacksjs/ts-css": "^0.3.2",
124
124
  "@stacksjs/clapp": "^0.2.16",
125
- "@stacksjs/desktop": "0.2.433",
126
- "@stacksjs/sanitizer": "0.2.433",
125
+ "@stacksjs/desktop": "0.2.435",
126
+ "@stacksjs/sanitizer": "0.2.435",
127
127
  "@stacksjs/ts-i18n": "^0.1.11",
128
- "bun-plugin-stx": "0.2.433",
128
+ "bun-plugin-stx": "0.2.435",
129
129
  "bunfig": "^0.15.19",
130
- "stx-router": "0.2.433",
130
+ "stx-router": "0.2.435",
131
131
  "ts-broadcasting": "^0.0.11",
132
132
  "ts-images": "^0.2.22",
133
133
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,17 +0,0 @@
1
- // @bun
2
- import{y,Me,I,Yt,i,T}from"./chunk-sw8j8rnc.js";import{Vr}from"./chunk-2psf6w7b.js";import{s,be}from"./chunk-3pxp0r0a.js";import{a}from"./chunk-wtms9jhs.js";import f from"path";import b from"fs";function de(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function pe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function z(e,t){let r=[];for(let l of pe(e)){if(de(l)){let u=l.position||void 0;r.push({file:t||u?.file,line:u?.line,column:u?.column,message:l.message??"",lineText:u?.lineText});continue}r.push({file:t,message:l instanceof Error?l.message:String(l)})}return r}function De(e,t){return z(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",u=r.lineText?`
3
- ${r.lineText.trim()}`:"";return l?`${l}: ${r.message}${u}`:`${r.message}${u}`}).join(`
4
- `)}var me=9;function J(e,t,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(f.basename(e))||Vr(e,t,r)}var re=1,se=new Map,P=600,fe=100,V=new Map;async function ge(e){let t=V.get(e)??0;if(t>0&&t<fe){V.set(e,t+1);return}V.set(e,1);try{let r=(await b.promises.readdir(e)).filter((p)=>p.endsWith(".js"));if(r.length<=P)return;let u=(await Promise.all(r.map(async(p)=>{try{return{name:p,at:(await b.promises.stat(f.join(e,p))).mtimeMs}}catch{return null}}))).filter((p)=>p!==null);u.sort((p,d)=>d.at-p.at);for(let p of u.slice(P)){let d=p.name.slice(0,-3);await b.promises.rm(f.join(e,`${d}.js`),{force:!0}),await b.promises.rm(f.join(e,`${d}.deps.json`),{force:!0})}F("pruned bundle cache to",P,"entries")}catch{}}function oe(e){return se.get(e)??[]}function G(e,t){if(e)se.set(e,t)}function Oa(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function F(...e){if(Oa())console.log("[stx:bundler]",...e)}var q=[];function Ii(e,t,r){q.push({filePath:e||"<inline>",message:t,details:r})}function ft(){return q.slice()}function gt(){q.length=0}var X;function gu(e){X=e}function Di(){if(X)return X;try{let e=T.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var ee=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function mt(e){let t=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,r;while((r=t.exec(e))!==null){let u=r[1];if(!ee.some((d)=>d.test(u)))return F("detected user import:",u),!0}let l=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((r=l.exec(e))!==null){let u=r[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!ee.some((d)=>d.test(u)))return F("detected side-effect import:",u),!0}return!1}var Jt="stx-module:",he=/\.(?:[cm]?[jt]sx?|json)$/i;function Ma(e,t){return f.relative(e,t).split(f.sep).join("/")}function Na(e,t){if(t.size===0)return e;return e.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,(r,l,u,p)=>{let d=t.get(p);return d&&!p.startsWith(Jt)?`${l}${u}${d}${u}`:r})}function La(e,t){let r=0,l=(p)=>{let d=`__stxMod${r++}`,x=JSON.stringify(p);return t.push(`var ${d} = globalThis.__stxModules && globalThis.__stxModules[${x}];`,`if (${d} === undefined) throw new Error("[stx] module " + ${JSON.stringify(x)} + " is not registered on this page (#1957)");`),d},u=(p,d)=>{for(let x of p.split(",")){let v=x.trim();if(!v)continue;let c=v.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!c)continue;let n=c[1].startsWith('"')?JSON.parse(c[1]):c[1],o=c[2]??n;t.push(`var ${o} = ${d}[${JSON.stringify(n)}];`)}};return e=e.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d,x)=>{let v=x.slice(Jt.length),c=l(v),n=d.trim(),o=n.match(/^([\w$]+)\s*(?:,\s*|$)/);if(o&&!n.startsWith("{")&&!n.startsWith("*"))t.push(`var ${o[1]} = ${c}.default;`),n=n.slice(o[0].length).trim();let m=n.match(/^\*\s*as\s+([\w$]+)$/);if(m)t.push(`var ${m[1]} = ${c};`);else if(n.startsWith("{"))u(n.replace(/^\{|\}$/g,""),c);return""}),e=e.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d)=>(l(d.slice(Jt.length)),"")),e}function te(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,f.join(e,"index.ts"),f.join(e,"index.tsx"),f.join(e,"index.js"),f.join(e,"index.mjs")];for(let r of t)try{if(b.existsSync(r)&&b.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}function xe(e,t,r,l,u,p=new Map,d){let x=(c,n,o)=>{if(J(n,e,d))return null;if(!u||c!==r||!he.test(n))return null;try{if(!b.statSync(n,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(n);let m=`${Jt}${Ma(process.cwd(),n)}`;return p.set(o,m),{path:m,external:!0}},v=(c,n)=>{let o=c===r?t:f.dirname(c),m=f.resolve(o,n);return te(m)??m};return{name:"stx-client-bundle",setup(c){if(c.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(n)=>({path:n.path,external:!0})),c.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(n)=>({path:n.path,external:!0})),c.onResolve({filter:/^\//},(n)=>{let o=te(n.path);if(o){let m=x(n.importer,o,n.path);if(m)return m;if(o!==r)l.add(o);return{path:o}}return{path:n.path,external:!0}}),c.onResolve({filter:/^\.\.?\//},(n)=>{let o=v(n.importer,n.path),m=x(n.importer,o,n.path);if(m)return m;return l.add(o),{path:o}}),c.onResolve({filter:/^[@~]\//},(n)=>{let o=f.resolve(e,n.path.slice(2)),m=[o,`${o}.ts`,`${o}.tsx`,`${o}.js`,`${o}.mjs`,`${o}.jsx`,f.join(o,"index.ts"),f.join(o,"index.tsx"),f.join(o,"index.js"),f.join(o,"index.mjs")];for(let w of m)if(b.existsSync(w)&&b.statSync(w,{throwIfNoEntry:!1})?.isFile()){let N=x(n.importer,w,n.path);if(N)return N;return F(`resolved ${n.path[0]}/ import:`,n.path,"\u2192",w),l.add(w),{path:w}}return console.warn(`[stx:bundler] could not resolve ${n.path[0]}/ import:`,n.path),{path:o}}),u)c.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(n)=>{if(n.importer!==r)return;let o=`${Jt}npm:${n.path}`;return p.set(n.path,o),{path:o,external:!0}});c.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(n)=>{if(J(n.path,e,d))throw Error(`Server-only API source cannot be imported by a client script: ${n.path}`);let o=f.extname(n.path).toLowerCase(),m=o===".json"?"json":o===".tsx"?"tsx":o===".jsx"?"jsx":o===".ts"||o===".mts"||o===".cts"?"ts":"js";if(n.path!==r)l.add(n.path);return{contents:b.readFileSync(n.path,"utf8"),loader:m}})}}}var W=new Map,O=I(64),ne=Symbol.for("stx.client-bundle-build-queue");function ja(e){let t=globalThis,l=(t[ne]??Promise.resolve()).then(e,e);return t[ne]=l.then(()=>{return},()=>{return}),l}async function ht(e,t,r={}){let l=r.projectRoot||process.cwd(),u=(await i(l)).serverApi,p=r.minify??!1,d=r.externalizeUserModules??!0,x=r.cacheDir||a(l,"bundle-cache"),v=new Bun.CryptoHasher("md5");v.update(`${me}\x00${Me()}\x00${JSON.stringify(u??!1)}\x00${d?"registry":"inline"}\x00${e}\x00${t}`);let c=v.digest("hex").slice(0,12),n=f.join(x,`${c}.js`),o=O.get(n);if(o){if(Yt(o.files)&&o.files.every((E)=>!J(E.path,l,u))){F("memo hit:",c);let E=o.files.map((S)=>S.path);return G(t,E),r.collectInputs?.push(...E),o.code}O.delete(n),F("memo invalidated by dep change:",c)}let m=f.join(x,`${c}.deps.json`),w=Bun.file(n);if(await w.exists()){let E=Bun.file(m),S=!1,B=null;if(await E.exists())try{let D=JSON.parse(await E.text());if(D.metadataVersion!==re||!Array.isArray(D.files))S=!1;else B=D.files,S=!0;if(B&&(!Yt(B)||B.some((k)=>J(k.path,l,u))))S=!1}catch{S=!1}if(S){if(F("cache hit:",c),B)G(t,B.map((k)=>k.path)),r.collectInputs?.push(...B.map((k)=>k.path));let D=await w.text();if(B)O.set(n,{code:D,files:B});return D}F("cache invalidated by dep change:",c)}let N=W.get(c);if(N){let E=await N;if(r.collectInputs)r.collectInputs.push(...(O.get(n)?.files??[]).map((S)=>S.path));return E}let _=ja(()=>ye(e,t,{projectRoot:l,minify:p,cacheDir:x,hash:c,cachePath:n,depsPath:m,collectInputs:r.collectInputs,externalizeUserModules:d,serverApi:u}));W.set(c,_);try{return await _}finally{W.delete(c)}}var $e=0;function Ba(e){return`${e}-${process.pid}-${++$e}`}async function ye(e,t,r){let{projectRoot:l,minify:u,cacheDir:p,hash:d,cachePath:x,depsPath:v,externalizeUserModules:c}=r,n=a(l,"bundle-tmp"),o=Ba(d),m=f.join(n,`${o}.ts`),w=f.join(n,"out",o);b.mkdirSync(n,{recursive:!0}),b.mkdirSync(w,{recursive:!0});let N=f.dirname(t),_=new Set,E=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,S=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,B=s(e),{depths:D,balanced:k}=be(B),H=(j)=>!k||D[j]===0,M;while((M=E.exec(B))!==null){if(M[1])continue;if(!H(M.index))continue;if(M[2])M[2].split(",").forEach((j)=>{let h=we(j);if(h)_.add(h)});else if(M[3])_.add(M[3])}while((M=S.exec(B))!==null){if(M[1])continue;if(!H(M.index))continue;_.add(M[2])}let ie=_.size>0?`
5
- export { ${[..._].join(", ")} }`:"";await Bun.write(m,e+ie),F("bundling:",d,"from:",f.basename(t));let Z=new Set,Y=new Map;try{let j=await Bun.build({entrypoints:[m],outdir:w,target:"browser",format:"esm",minify:u,plugins:[xe(l,N,m,Z,c,Y,r.serverApi)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...y()},root:l});if(!j.success){let R=j.logs.filter((C)=>C.level==="error").map((C)=>C.message).join(", ")||`Unable to bundle ${f.basename(t)}`,L=z(j.logs,t||void 0);if(console.warn("[stx:bundler] build failed:",R),Ii(t||"",R,L),Di()==="error")throw Error(R);return e}let h="";for(let g of j.outputs){h=await g.text();break}let A=[];for(let g of h.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let R of g[1].split(",")){let L=R.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(L){A.push([L[2],L[1]]);continue}let C=R.trim();if(/^[A-Za-z_$][\w$]*$/.test(C))A.push([C,C])}let Q=[];h=La(Na(h,Y),Q);let ae=h.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];h=h.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let K=`__stxBundle_${d}`,le=A.map(([g,R])=>`${JSON.stringify(g)}: ${R}`).join(", "),ce=A.map(([g])=>`var ${g} = undefined;`).join(`
6
- `),ue=A.map(([g])=>`${g} = ${K}[${JSON.stringify(g)}];`).join(`
7
- `);if(h=`${ae.join(`
8
- `)}
9
- ${ce}
10
- var ${K} = (function() {
11
- ${Q.join(`
12
- `)}
13
- ${h}
14
- return { ${le} };
15
- })();
16
- ${ue}`.trim(),F("bundled:",d,"output:",h.length,"bytes"),_.size>0&&A.length===0)return console.warn(`[stx:bundler] dropped every binding for ${f.basename(t)} (${d}); serving the unbundled source and not caching this result`),e;b.mkdirSync(p,{recursive:!0}),await Bun.write(x,h);let U=Array.from(Z).map((g)=>{try{return{path:g,mtimeMs:b.statSync(g).mtimeMs}}catch{return null}}).filter((g)=>g!==null);return await Bun.write(v,JSON.stringify({metadataVersion:re,files:U})),G(t,U.map((g)=>g.path)),r.collectInputs?.push(...U.map((g)=>g.path)),O.set(x,{code:h,files:U}),await ge(p),h}catch(j){let h=z(j,t||void 0),A=De(j,t||void 0);if(console.warn(`[stx:bundler] error: ${A}`),Ii(t||"",A,h),Di()==="error")throw j;return e}finally{try{b.rmSync(m,{force:!0}),b.rmSync(w,{recursive:!0,force:!0})}catch{}}}function we(e){let t=e.trim();if(!t)return null;let r=t.indexOf("=");if(r!==-1)t=t.slice(0,r).trim();let l=t.indexOf(":");if(l!==-1)t=t.slice(l+1).trim();if(t.startsWith("..."))t=t.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(t)?t:null}
17
- export{De,oe,Oa,Ii,ft,gt,gu,Di,mt,Jt,Ma,Na,La,ja,ht,Ba};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ol}from"./chunk-3yrg4kfm.js";import"./chunk-7ynzah39.js";import"./chunk-2psf6w7b.js";import"./chunk-sw8j8rnc.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-720pm5yj.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-eaa5rxst.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{ol as startProductionServer};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Io,Do}from"./chunk-zaz9phx6.js";import"./chunk-thx147nq.js";import"./chunk-9w5nse46.js";import"./chunk-b8r87s8q.js";import"./chunk-5vwg3h5g.js";import"./chunk-82kf8t4n.js";import"./chunk-xhnn2yj8.js";import"./chunk-spx27cs4.js";import"./chunk-b8dbq51z.js";import"./chunk-bge8ptbd.js";import"./chunk-3yrg4kfm.js";import{ei}from"./chunk-7ynzah39.js";import"./chunk-3rbz496d.js";import"./chunk-24e7qjb8.js";import"./chunk-f4m0n9hr.js";import"./chunk-hc9242wm.js";import"./chunk-dtvwes4f.js";import"./chunk-p4wvc7wx.js";import"./chunk-4wf68rht.js";import"./chunk-nvht5259.js";import"./chunk-s28eh0jn.js";import"./chunk-51a50b67.js";import"./chunk-j1q65enz.js";import"./chunk-4xemkkm8.js";import"./chunk-bjnvymb7.js";import"./chunk-w2085fwx.js";import"./chunk-zfzcedw4.js";import"./chunk-3hmy75tw.js";import"./chunk-tdx1srqq.js";import"./chunk-gnghq9yc.js";import"./chunk-a16fcrd1.js";import"./chunk-b9a5hkm2.js";import"./chunk-ccq35xp7.js";import"./chunk-2q95we1n.js";import"./chunk-2psf6w7b.js";import{me,Zt,Qt,q,d,n,Wn,A,i,ce}from"./chunk-sw8j8rnc.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-720pm5yj.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-eaa5rxst.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Wn as buildWebComponents,Qt as cacheTemplate,Zt as checkCache,ei as classifyAllScripts,Io as createMiddleware,Do as createRoute,A as defaultConfig,d as extractVariables,q as injectRouterScript,i as loadStxConfig,me as processClientScript,n as processDirectives,ce as readMarkdownFile};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Kc}from"./chunk-xhnn2yj8.js";import"./chunk-7ynzah39.js";import"./chunk-gnghq9yc.js";import"./chunk-2psf6w7b.js";import"./chunk-sw8j8rnc.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-720pm5yj.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-eaa5rxst.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Kc as buildForProduction};
@@ -1,12 +0,0 @@
1
- // @bun
2
- import"./chunk-eaa5rxst.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-sw8j8rnc.js";import"./chunk-b9wpgn7b.js";import"./chunk-8x47zcfa.js";import"./chunk-pxqs3psa.js";import"./chunk-721yq8qx.js";import"./chunk-my3jkpv7.js";import"./chunk-t7x753ga.js";import"./chunk-ptjqacjd.js";import"./chunk-720pm5yj.js";import"./chunk-114zdbnd.js";import"./chunk-8wkja2z2.js";import f from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(b);var l=new Map,h=I(64),S=new Set,v=0,E=new Set(b);function W(){l.clear(),h.clear()}function R(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function P(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=O(o,v),r=h.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of E){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=R(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>k.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
- ${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let w=r.filter((s)=>!d.has(s)&&!P(o,s));if(w.length>0)console.warn(`[stx] could not bundle ${w.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let C=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
- `),x=`<script data-stx-framework-composables>
5
- ;(function(){
6
- var __s = window.stx = window.stx || {};
7
- ${m.join(`
8
-
9
- `)}
10
- ${C}
11
- })();
12
- </script>`;return l.set(t,x),x}function A(o){S.clear();for(let n of o)S.add(n);v++}export{A as __setRuntimeOwnedForTest,W as clearFrameworkComposableCache,U as getFrameworkComposableScript,M as referencedFrameworkComposables,R as selectComposableFiles};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{tn,tc,Qr}from"./chunk-sw8j8rnc.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-720pm5yj.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import{ve}from"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-eaa5rxst.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{ve as freeIdentifiers,Qr as processComponents,tc as processESImports,tn as rendersAsElement};