@stacksjs/stx 0.2.764 → 0.2.769

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 (184) hide show
  1. package/dist/chunk-096g00ba.js +2 -0
  2. package/dist/chunk-0ga7sn1k.js +2 -0
  3. package/dist/{chunk-admzbntt.js → chunk-0hf0mtaf.js} +2 -2
  4. package/dist/{chunk-31e7xkrt.js → chunk-0nhk9p9r.js} +1 -1
  5. package/dist/{chunk-scq0h2cs.js → chunk-1a4vpk9x.js} +2 -2
  6. package/dist/{chunk-85w2y7fy.js → chunk-1e67szzk.js} +4 -4
  7. package/dist/chunk-1nzg53pv.js +2 -0
  8. package/dist/chunk-1respkkp.js +2 -0
  9. package/dist/{chunk-w2nzevn0.js → chunk-20dsfgmq.js} +1 -1
  10. package/dist/{chunk-6h6teyxp.js → chunk-2bb4g9qr.js} +2 -2
  11. package/dist/{chunk-6eds5zjz.js → chunk-2w16z2y1.js} +2 -2
  12. package/dist/{chunk-rntegv4f.js → chunk-30kemrry.js} +5 -5
  13. package/dist/{chunk-cge03y9d.js → chunk-33jagtss.js} +2 -2
  14. package/dist/{chunk-as4s0nf5.js → chunk-342e6mhn.js} +3 -3
  15. package/dist/{chunk-n8gfetjx.js → chunk-3g8cnsbk.js} +2 -2
  16. package/dist/chunk-3k6tem86.js +2 -0
  17. package/dist/chunk-3pma2q0h.js +2 -0
  18. package/dist/chunk-4cr8bep2.js +2 -0
  19. package/dist/chunk-4ew0291t.js +2 -0
  20. package/dist/{chunk-b6dtw4j0.js → chunk-4qrr2mdd.js} +89 -88
  21. package/dist/{chunk-et831a4y.js → chunk-4rtr07x9.js} +2 -2
  22. package/dist/{chunk-t92f0qnk.js → chunk-528b302x.js} +3 -3
  23. package/dist/{chunk-6jnrpnxb.js → chunk-586xes7a.js} +2 -2
  24. package/dist/{chunk-zq5c0enz.js → chunk-5fab5wt2.js} +2 -2
  25. package/dist/chunk-5ftthxab.js +2 -0
  26. package/dist/{chunk-4b6dtyd7.js → chunk-5q97egpw.js} +45 -45
  27. package/dist/chunk-5wp7s24b.js +3 -0
  28. package/dist/{chunk-1w4a0xya.js → chunk-7s9wx19m.js} +3 -3
  29. package/dist/{chunk-mdtjjzqc.js → chunk-7vqq2w3x.js} +2 -2
  30. package/dist/{chunk-3mf27gj6.js → chunk-80gg1k0h.js} +2 -2
  31. package/dist/{chunk-b62g7wvg.js → chunk-8x4gmead.js} +5 -5
  32. package/dist/{chunk-a3azc16d.js → chunk-90n5kb78.js} +3 -3
  33. package/dist/chunk-9v21mwfs.js +2 -0
  34. package/dist/{chunk-43fhjxxj.js → chunk-9y6hbdfh.js} +4 -4
  35. package/dist/{chunk-r6ajkw2d.js → chunk-a81m2ewb.js} +2 -2
  36. package/dist/chunk-b6kfq08s.js +2 -0
  37. package/dist/chunk-b94xf9vs.js +2 -0
  38. package/dist/chunk-bjggcj45.js +2 -0
  39. package/dist/chunk-bk3b5jyw.js +2 -0
  40. package/dist/chunk-bntw35k0.js +2 -0
  41. package/dist/chunk-bt01gdaj.js +2 -0
  42. package/dist/chunk-ctmadzad.js +2 -0
  43. package/dist/chunk-cwmjqker.js +2 -0
  44. package/dist/{chunk-nr5qsgcw.js → chunk-cyd10m6m.js} +3 -3
  45. package/dist/{chunk-ay02q27h.js → chunk-cz3trbvn.js} +6 -6
  46. package/dist/{chunk-p42kp93g.js → chunk-dbpzrkmj.js} +1 -1
  47. package/dist/chunk-dbx628ra.js +2 -0
  48. package/dist/{chunk-qp0v9b0h.js → chunk-ddpt7ejx.js} +3 -3
  49. package/dist/chunk-ddwsms1t.js +2 -0
  50. package/dist/chunk-dpjf62qw.js +2 -0
  51. package/dist/chunk-e4bsnxsj.js +2 -0
  52. package/dist/{chunk-nzety7kj.js → chunk-ecakhzkq.js} +7 -7
  53. package/dist/{chunk-qf0z03k8.js → chunk-enzrpxsj.js} +2 -2
  54. package/dist/chunk-f8jwrvky.js +2 -0
  55. package/dist/{chunk-8hanmv49.js → chunk-fxy7jjnv.js} +29 -2
  56. package/dist/{chunk-47t7qsfy.js → chunk-ggvnmmv3.js} +2 -2
  57. package/dist/chunk-h8yy3y3p.js +2 -0
  58. package/dist/chunk-hddwx35m.js +2 -0
  59. package/dist/{chunk-mpaepc7n.js → chunk-hpdb8vkt.js} +78 -8
  60. package/dist/{chunk-8ge1y01k.js → chunk-hxyarbb6.js} +1 -1
  61. package/dist/chunk-hyqsvw1b.js +2 -0
  62. package/dist/{chunk-stww901w.js → chunk-j34wqxb1.js} +5 -5
  63. package/dist/{chunk-fta169tc.js → chunk-j5dd5ncz.js} +2 -2
  64. package/dist/chunk-j835421z.js +2 -0
  65. package/dist/{chunk-0d29b573.js → chunk-jd84zgn3.js} +2 -2
  66. package/dist/{chunk-42kjqjst.js → chunk-jgmmg2fw.js} +4 -4
  67. package/dist/{chunk-74y29xxs.js → chunk-knvt4bap.js} +4 -4
  68. package/dist/{chunk-54nknqzx.js → chunk-mg38q3jh.js} +5 -5
  69. package/dist/chunk-mhc72pp2.js +2 -0
  70. package/dist/{chunk-nj5azxxj.js → chunk-mkk8k3nd.js} +4 -4
  71. package/dist/{chunk-1day2nbr.js → chunk-msy46ges.js} +3 -3
  72. package/dist/{chunk-zfbekcnz.js → chunk-napd81ht.js} +3 -3
  73. package/dist/{chunk-c1b481my.js → chunk-nrh8t8re.js} +2 -2
  74. package/dist/{chunk-r3as289z.js → chunk-nsxg0t06.js} +1 -1
  75. package/dist/{chunk-14wn1c3t.js → chunk-p66fgjeb.js} +1 -1
  76. package/dist/{chunk-0nzeqc13.js → chunk-p7cvn8q9.js} +2 -2
  77. package/dist/{chunk-vkpmemb1.js → chunk-p7h4y7mk.js} +1 -1
  78. package/dist/chunk-phjfsm8d.js +2 -0
  79. package/dist/chunk-pts7jpqc.js +2 -0
  80. package/dist/{chunk-qv99gqee.js → chunk-py818vbj.js} +1 -1
  81. package/dist/{chunk-twmj9qv5.js → chunk-pzt3g2m0.js} +1 -1
  82. package/dist/{chunk-fyv2pjrx.js → chunk-q69dvpg1.js} +1 -1
  83. package/dist/chunk-qcjtfrzm.js +2 -0
  84. package/dist/{chunk-v2yd11zy.js → chunk-qdysx0fd.js} +5 -5
  85. package/dist/{chunk-3ffz7pd4.js → chunk-qr6jyd08.js} +1 -1
  86. package/dist/{chunk-ntf433nb.js → chunk-r3qez0ph.js} +14 -14
  87. package/dist/{chunk-9hbvt06e.js → chunk-rfzfk8zd.js} +6 -6
  88. package/dist/{chunk-sd3b6swd.js → chunk-rj9dcjeg.js} +1 -1
  89. package/dist/{chunk-6nm3h2vw.js → chunk-rk2v0wzs.js} +3 -3
  90. package/dist/chunk-rqpktvkn.js +2 -0
  91. package/dist/chunk-s1a69a8q.js +2 -0
  92. package/dist/{chunk-q0rfq81t.js → chunk-s5kfndxv.js} +2 -2
  93. package/dist/{chunk-dphhs29v.js → chunk-s6ss1qnq.js} +2 -2
  94. package/dist/chunk-spmbnchd.js +2 -0
  95. package/dist/{chunk-csddc2st.js → chunk-svrjbeyq.js} +1 -1
  96. package/dist/chunk-t1gk6y8z.js +2 -0
  97. package/dist/chunk-t3cdnbq1.js +2 -0
  98. package/dist/chunk-t96gj0ey.js +2 -0
  99. package/dist/{chunk-sja3ntnh.js → chunk-tykyhmyx.js} +1 -1
  100. package/dist/chunk-vcks4gwd.js +2 -0
  101. package/dist/chunk-vg6p0zst.js +2 -0
  102. package/dist/chunk-vjsyf8m1.js +2 -0
  103. package/dist/{chunk-2mckhfet.js → chunk-vp8sjx6w.js} +5 -5
  104. package/dist/chunk-vq88tjma.js +2 -0
  105. package/dist/chunk-vqa2s0v4.js +2 -0
  106. package/dist/chunk-wtqj99tg.js +2 -0
  107. package/dist/{chunk-fq3cdhc5.js → chunk-xj1k9bx9.js} +2 -2
  108. package/dist/chunk-xqa8f03q.js +2 -0
  109. package/dist/chunk-y7a0y5jq.js +2 -0
  110. package/dist/chunk-ydj0r3kw.js +2 -0
  111. package/dist/chunk-ydq170j1.js +2 -0
  112. package/dist/chunk-yz30cgyx.js +2 -0
  113. package/dist/{chunk-xmym6tre.js → chunk-yz85drm8.js} +1 -1
  114. package/dist/{chunk-4h3agcnm.js → chunk-zg43k117.js} +2 -2
  115. package/dist/{chunk-m3dr63n0.js → chunk-zj32s5na.js} +2 -2
  116. package/dist/{chunk-m15nbvck.js → chunk-zmesddf4.js} +1 -1
  117. package/dist/{chunk-dvh63p75.js → chunk-znhzrjbm.js} +2 -2
  118. package/dist/{chunk-zs8yjtaz.js → chunk-zv924m9g.js} +5 -5
  119. package/dist/cli.js +11 -11
  120. package/dist/client/signals-for-runtime.js +2 -0
  121. package/dist/client/signals-if-runtime.js +2 -0
  122. package/dist/client/signals-loop-conditional-runtime.js +66 -0
  123. package/dist/component-contract-checks.js +3 -2
  124. package/dist/craft-entry.js +2 -2
  125. package/dist/craft.js +2 -2
  126. package/dist/expressions.js +15 -0
  127. package/dist/native/event-names.js +2 -0
  128. package/dist/native/prop-names.js +2 -0
  129. package/dist/process.js +1 -1
  130. package/dist/pwa.js +3 -3
  131. package/dist/signal-processing.d.ts +12 -0
  132. package/dist/signal-processing.js +12 -1
  133. package/dist/ssg.js +2 -2
  134. package/dist/utils.js +14 -2
  135. package/package.json +5 -5
  136. package/dist/chunk-0f5276fm.js +0 -2
  137. package/dist/chunk-0kjc72hk.js +0 -2
  138. package/dist/chunk-16n128gh.js +0 -2
  139. package/dist/chunk-171bbyqv.js +0 -2
  140. package/dist/chunk-1g0g498y.js +0 -2
  141. package/dist/chunk-1z77g0j6.js +0 -2
  142. package/dist/chunk-209vqf2d.js +0 -2
  143. package/dist/chunk-2bd3b7tx.js +0 -2
  144. package/dist/chunk-33ysd18c.js +0 -2
  145. package/dist/chunk-34jqhv4k.js +0 -2
  146. package/dist/chunk-3a5nc7pm.js +0 -2
  147. package/dist/chunk-4bhbtvtm.js +0 -2
  148. package/dist/chunk-54kxajmw.js +0 -2
  149. package/dist/chunk-59r38w60.js +0 -2
  150. package/dist/chunk-62c6mgyp.js +0 -2
  151. package/dist/chunk-65h2h51z.js +0 -2
  152. package/dist/chunk-6baywk2t.js +0 -2
  153. package/dist/chunk-8k3q3ggt.js +0 -2
  154. package/dist/chunk-aav6t96n.js +0 -2
  155. package/dist/chunk-bnm7ym0g.js +0 -2
  156. package/dist/chunk-brg2ydrk.js +0 -2
  157. package/dist/chunk-c8256r1a.js +0 -2
  158. package/dist/chunk-evbxyw80.js +0 -2
  159. package/dist/chunk-f66n66c8.js +0 -2
  160. package/dist/chunk-fh1hw4zy.js +0 -2
  161. package/dist/chunk-gaatje2g.js +0 -2
  162. package/dist/chunk-m8mfav9s.js +0 -2
  163. package/dist/chunk-mkfd752v.js +0 -2
  164. package/dist/chunk-mpr6m0tj.js +0 -2
  165. package/dist/chunk-mya7gawb.js +0 -2
  166. package/dist/chunk-n9zka6dg.js +0 -2
  167. package/dist/chunk-pvx57vpw.js +0 -2
  168. package/dist/chunk-qgvez75f.js +0 -2
  169. package/dist/chunk-qhgzkpz0.js +0 -2
  170. package/dist/chunk-r0j6jkxc.js +0 -2
  171. package/dist/chunk-rafkhe18.js +0 -2
  172. package/dist/chunk-rfh99ndp.js +0 -2
  173. package/dist/chunk-rzv9xcyp.js +0 -2
  174. package/dist/chunk-sy4wqxta.js +0 -2
  175. package/dist/chunk-vvhdt94w.js +0 -2
  176. package/dist/chunk-vvj09a7b.js +0 -2
  177. package/dist/chunk-wadp2rmj.js +0 -2
  178. package/dist/chunk-wcj1zf73.js +0 -2
  179. package/dist/chunk-wwd9yfkq.js +0 -2
  180. package/dist/chunk-y0mdsbdx.js +0 -2
  181. package/dist/chunk-yvg3njph.js +0 -2
  182. package/dist/chunk-yy0edrwz.js +0 -3
  183. package/dist/chunk-z5zr9qrm.js +0 -2
  184. package/dist/chunk-zgkkfb7f.js +0 -2
@@ -45,4 +45,70 @@ export const SIGNALS_LOOP_CONDITIONAL_RUNTIME = ` // A :for row is a clone of i
45
45
  holder.content.appendChild(el);
46
46
  }
47
47
  }
48
+
49
+ // A conditional branch that holds a COMPONENT is the heaviest thing a row can
50
+ // carry and the one a row almost never shows: an inline editor for the one
51
+ // row that is open. Cloned into every row only to be parked by :if, a 200-line
52
+ // editor was a third of the time it took to draw a list, twice over (the
53
+ // clone, then the walk that gives each cloned component its own scope id).
54
+ // deferRowConditionals cannot take it (it holds a setup script, and a
55
+ // <template> in a row is cloned with its content all the same), so the row
56
+ // template keeps an EMPTY element with the same condition and the branch
57
+ // lives once, here. bindIf fills the element from it the first time the
58
+ // condition holds (materializeLazyBranch), as it would have been cloned.
59
+ var __stxLazyBranches = new Map();
60
+ var __stxLazyCounter = 0;
61
+ function shareHeavyRowBranches(root) {
62
+ if (stxHost.isNative || !root || !root.querySelectorAll || typeof document === 'undefined' || !document.createDocumentFragment) return;
63
+ var candidates = Array.prototype.slice.call(root.querySelectorAll('[data-stx-scope]'));
64
+ if (!candidates.length) return;
65
+ var branches = [];
66
+ candidates.forEach(function(component) {
67
+ for (var el = component.parentElement; el; el = el.parentElement) {
68
+ if (el.tagName === 'TEMPLATE') return;
69
+ var attr = null;
70
+ for (var a = 0; a < IF_ATTRS.length; a++) {
71
+ if (el.hasAttribute(IF_ATTRS[a])) { attr = IF_ATTRS[a]; break; }
72
+ }
73
+ if (attr) {
74
+ if (branches.indexOf(el) === -1 && eligibleHeavyBranch(el)) branches.push(el);
75
+ return;
76
+ }
77
+ if (!root.contains(el)) return;
78
+ }
79
+ });
80
+ branches.forEach(function(el) {
81
+ // An outer candidate already took this one's children with it.
82
+ if (!root.contains(el)) return;
83
+ var holder = document.createDocumentFragment();
84
+ while (el.firstChild) holder.appendChild(el.firstChild);
85
+ var id = 'lz' + (++__stxLazyCounter);
86
+ __stxLazyBranches.set(id, Array.prototype.slice.call(holder.childNodes));
87
+ el.__stx_lazy_holder = holder;
88
+ el.setAttribute('data-stx-lazy', id);
89
+ });
90
+ }
91
+ function eligibleHeavyBranch(el) {
92
+ for (var f = 0; f < FOR_ATTRS.length; f++) {
93
+ if (el.hasAttribute(FOR_ATTRS[f])) return false;
94
+ }
95
+ if (getElseAttrInfo(el)) return false;
96
+ var next = el.nextElementSibling;
97
+ if (next && (getElseAttrInfo(next) || next.tagName === 'SCRIPT')) return false;
98
+ if (el.hasAttribute('data-stx-scope') || el.hasAttribute('x-data')) return false;
99
+ return true;
100
+ }
101
+ // Fill a row's empty conditional element with a copy of its branch, with the
102
+ // component ids of THIS copy, before the branch is hydrated and bound.
103
+ function materializeLazyBranch(el) {
104
+ var id = el.getAttribute && el.getAttribute('data-stx-lazy');
105
+ if (!id) return;
106
+ el.removeAttribute('data-stx-lazy');
107
+ var source = __stxLazyBranches.get(id);
108
+ if (!source) return;
109
+ var fragment = document.createDocumentFragment();
110
+ source.forEach(function(node) { fragment.appendChild(stxHost.clone(node)); });
111
+ el.appendChild(fragment);
112
+ remapForComponentScopes([el]);
113
+ }
48
114
  `;
@@ -66,6 +66,7 @@ export function componentContractChecks(source, masked, options) {
66
66
  COMPONENT_CONTRACT_HELPERS,
67
67
  "type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;",
68
68
  "type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",
69
+ 'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;',
69
70
  'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'
70
71
  ], events = new Map, dependencies = new Map, imported = new Map, scripts = options.scriptCode(source, options.filePath), maskedScripts = stripCommentsAndLiterals(scripts);
71
72
  for (const match of scripts.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)) {
@@ -134,8 +135,8 @@ export function componentContractChecks(source, masked, options) {
134
135
  present.push(prop);
135
136
  if (!contract.props)
136
137
  continue;
137
- const code = name.startsWith(":") || name.startsWith("v-bind:") || !!model || attribute.braced ? value : attribute.value !== !0 ? JSON.stringify(value) : "true";
138
- check(position(offset, code, name), ";void ((", `) satisfies __StxProp<${contract.props}, ${JSON.stringify(prop)}>);`);
138
+ const dynamic = name.startsWith(":") || name.startsWith("v-bind:") || !!model || attribute.braced, code = dynamic ? value : attribute.value !== !0 ? JSON.stringify(value) : "true", staticBoolean = !dynamic && attribute.value !== !0 && (value === "true" || value === "false");
139
+ check(position(offset, code, name), ";void ((", `) satisfies ${staticBoolean ? "__StxStaticProp" : "__StxProp"}<${contract.props}, ${JSON.stringify(prop)}>);`);
139
140
  }
140
141
  if (contract.props) {
141
142
  const fields = [...new Set(present)].map((name) => `${JSON.stringify(name)}: undefined as any`).join(", "), expression = position(tag.offset, `<${tag.name}>`);
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{bo,ma,ha}from"./chunk-6jnrpnxb.js";import"./chunk-fz717vpc.js";import"./chunk-1w4a0xya.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import"./chunk-b6dtw4j0.js";import"./chunk-1g5fg1ys.js";import"./chunk-sd3b6swd.js";import"./chunk-c1b481my.js";import"./chunk-8hanmv49.js";import"./chunk-9hbvt06e.js";import"./chunk-ay02q27h.js";import"./chunk-ztbk9yqv.js";import"./chunk-q0rfq81t.js";import"./chunk-6nm3h2vw.js";import"./chunk-4b6dtyd7.js";import"./chunk-qf0z03k8.js";import"./chunk-b62g7wvg.js";import"./chunk-nzety7kj.js";import"./chunk-8ge1y01k.js";import"./chunk-h8yk9qm7.js";import"./chunk-kc3kt59e.js";import{lu,ya,uh,dh,ba,wo,Jr,wa,va,ph,fh,xa,Sa,ka,_a}from"./chunk-v2yd11zy.js";import"./chunk-47t7qsfy.js";import"./chunk-yy0edrwz.js";import"./chunk-vkpmemb1.js";import"./chunk-42kjqjst.js";import"./chunk-qv99gqee.js";import"./chunk-csddc2st.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{bo,ma,ha}from"./chunk-586xes7a.js";import"./chunk-fz717vpc.js";import"./chunk-7s9wx19m.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import"./chunk-4qrr2mdd.js";import"./chunk-1g5fg1ys.js";import"./chunk-rj9dcjeg.js";import"./chunk-nrh8t8re.js";import"./chunk-fxy7jjnv.js";import"./chunk-rfzfk8zd.js";import"./chunk-cz3trbvn.js";import"./chunk-ztbk9yqv.js";import"./chunk-s5kfndxv.js";import"./chunk-rk2v0wzs.js";import"./chunk-5q97egpw.js";import"./chunk-enzrpxsj.js";import"./chunk-8x4gmead.js";import"./chunk-ecakhzkq.js";import"./chunk-hxyarbb6.js";import"./chunk-h8yk9qm7.js";import"./chunk-kc3kt59e.js";import{lu,ya,dh,ph,ba,wo,Jr,wa,va,fh,gh,xa,Sa,ka,_a}from"./chunk-qdysx0fd.js";import"./chunk-ggvnmmv3.js";import"./chunk-5wp7s24b.js";import"./chunk-p7h4y7mk.js";import"./chunk-jgmmg2fw.js";import"./chunk-py818vbj.js";import"./chunk-svrjbeyq.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{lu as CRAFT_BRIDGE_SCRIPT,wo as CRAFT_COMPONENTS,wa as CRAFT_COMPONENT_RUNTIME,Jr as CRAFT_COMPONENT_STYLES,bo as NATIVE_COMPONENTS,xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ma as compileToNative,ha as createHotReloadServer,Sa as findCraftBinary,ya as generateCraftBridgeScript,V as generateCraftOptimizations,_a as getAvailableFormats,ka as getAvailableTargets,fh as getCraftComponents,G as getSSRCacheStats,ba as injectCraftBridge,uh as isCraftEnvironment,Y as prerenderForCraft,va as processCraftComponents,dh as processCraftDirective,ph as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{lu as CRAFT_BRIDGE_SCRIPT,wo as CRAFT_COMPONENTS,wa as CRAFT_COMPONENT_RUNTIME,Jr as CRAFT_COMPONENT_STYLES,bo as NATIVE_COMPONENTS,xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ma as compileToNative,ha as createHotReloadServer,Sa as findCraftBinary,ya as generateCraftBridgeScript,V as generateCraftOptimizations,_a as getAvailableFormats,ka as getAvailableTargets,gh as getCraftComponents,G as getSSRCacheStats,ba as injectCraftBridge,dh as isCraftEnvironment,Y as prerenderForCraft,va as processCraftComponents,ph as processCraftDirective,fh as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{bo,ma,ha}from"./chunk-6jnrpnxb.js";import"./chunk-fz717vpc.js";import"./chunk-1w4a0xya.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import"./chunk-b6dtw4j0.js";import"./chunk-1g5fg1ys.js";import"./chunk-sd3b6swd.js";import"./chunk-c1b481my.js";import"./chunk-8hanmv49.js";import"./chunk-9hbvt06e.js";import"./chunk-ay02q27h.js";import"./chunk-ztbk9yqv.js";import"./chunk-q0rfq81t.js";import"./chunk-6nm3h2vw.js";import"./chunk-4b6dtyd7.js";import"./chunk-qf0z03k8.js";import"./chunk-b62g7wvg.js";import"./chunk-nzety7kj.js";import"./chunk-8ge1y01k.js";import"./chunk-h8yk9qm7.js";import"./chunk-kc3kt59e.js";import{lu,ya,uh,dh,ba,wo,Jr,wa,va,ph,fh,xa,Sa,ka,_a}from"./chunk-v2yd11zy.js";import"./chunk-47t7qsfy.js";import"./chunk-yy0edrwz.js";import"./chunk-vkpmemb1.js";import"./chunk-42kjqjst.js";import"./chunk-qv99gqee.js";import"./chunk-csddc2st.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{bo,ma,ha}from"./chunk-586xes7a.js";import"./chunk-fz717vpc.js";import"./chunk-7s9wx19m.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import"./chunk-4qrr2mdd.js";import"./chunk-1g5fg1ys.js";import"./chunk-rj9dcjeg.js";import"./chunk-nrh8t8re.js";import"./chunk-fxy7jjnv.js";import"./chunk-rfzfk8zd.js";import"./chunk-cz3trbvn.js";import"./chunk-ztbk9yqv.js";import"./chunk-s5kfndxv.js";import"./chunk-rk2v0wzs.js";import"./chunk-5q97egpw.js";import"./chunk-enzrpxsj.js";import"./chunk-8x4gmead.js";import"./chunk-ecakhzkq.js";import"./chunk-hxyarbb6.js";import"./chunk-h8yk9qm7.js";import"./chunk-kc3kt59e.js";import{lu,ya,dh,ph,ba,wo,Jr,wa,va,fh,gh,xa,Sa,ka,_a}from"./chunk-qdysx0fd.js";import"./chunk-ggvnmmv3.js";import"./chunk-5wp7s24b.js";import"./chunk-p7h4y7mk.js";import"./chunk-jgmmg2fw.js";import"./chunk-py818vbj.js";import"./chunk-svrjbeyq.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{lu as CRAFT_BRIDGE_SCRIPT,wo as CRAFT_COMPONENTS,wa as CRAFT_COMPONENT_RUNTIME,Jr as CRAFT_COMPONENT_STYLES,bo as NATIVE_COMPONENTS,xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ma as compileToNative,ha as createHotReloadServer,Sa as findCraftBinary,ya as generateCraftBridgeScript,V as generateCraftOptimizations,_a as getAvailableFormats,ka as getAvailableTargets,fh as getCraftComponents,G as getSSRCacheStats,ba as injectCraftBridge,uh as isCraftEnvironment,Y as prerenderForCraft,va as processCraftComponents,dh as processCraftDirective,ph as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{lu as CRAFT_BRIDGE_SCRIPT,wo as CRAFT_COMPONENTS,wa as CRAFT_COMPONENT_RUNTIME,Jr as CRAFT_COMPONENT_STYLES,bo as NATIVE_COMPONENTS,xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ma as compileToNative,ha as createHotReloadServer,Sa as findCraftBinary,ya as generateCraftBridgeScript,V as generateCraftOptimizations,_a as getAvailableFormats,ka as getAvailableTargets,gh as getCraftComponents,G as getSSRCacheStats,ba as injectCraftBridge,dh as isCraftEnvironment,Y as prerenderForCraft,va as processCraftComponents,ph as processCraftDirective,fh as registerCraftComponent,Q as renderSSR};
@@ -470,6 +470,19 @@ const reportedUnresolvedScriptExpressions = new Set;
470
470
  function looksLikeServerValue(expression) {
471
471
  return /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(expression.trim());
472
472
  }
473
+ function isBraceLiteralInCode(source, offset, expr) {
474
+ const quote = expr[0];
475
+ if (quote !== "'" && quote !== '"' && quote !== "`")
476
+ return !1;
477
+ let count = 0;
478
+ for (let i = source.lastIndexOf(`
479
+ `, offset - 1) + 1;i < offset; i++)
480
+ if (source[i] === "\\")
481
+ i++;
482
+ else if (source[i] === quote)
483
+ count++;
484
+ return count % 2 === 1;
485
+ }
473
486
  function unresolvedServerValue(expression, filePath) {
474
487
  const key = `${filePath ?? "<unknown>"}\x00${expression}`;
475
488
  if (process.env.STX_DEBUG || !reportedUnresolvedScriptExpressions.has(key)) {
@@ -492,6 +505,8 @@ export function interpolateScriptExpressions(scriptBody, context, filePath) {
492
505
  });
493
506
  output = replaceInterpolations(output, (match, expr, offset) => {
494
507
  const trimmed = expr.trim();
508
+ if (isBraceLiteralInCode(output, offset, expr))
509
+ return match;
495
510
  if (/^__[A-Z_]+__$/.test(trimmed))
496
511
  return match;
497
512
  try {
@@ -23,6 +23,8 @@ export const NATIVE_EVENT_NAMES = {
23
23
  submitediting: "onSubmitEditing",
24
24
  "accept-completion": "onAcceptCompletion",
25
25
  acceptcompletion: "onAcceptCompletion",
26
+ "selection-change": "onSelectionChange",
27
+ selectionchange: "onSelectionChange",
26
28
  "end-editing": "onEndEditing",
27
29
  endediting: "onEndEditing",
28
30
  scroll: "onScroll",
@@ -100,6 +100,8 @@ const NATIVE_PROP_NAMES = [
100
100
  "autoScrollBottom",
101
101
  "scrollKey",
102
102
  "ghostText",
103
+ "rowHeight",
104
+ "labelFontSize",
103
105
  "pictureInPicture",
104
106
  "transitionID"
105
107
  ];
package/dist/process.js CHANGED
@@ -639,7 +639,7 @@ ${joined}` : joined;
639
639
  }, available = [
640
640
  ...layoutsIn(resolvedOptions.layoutsDir),
641
641
  ...layoutsIn(resolvedOptions.fallbackLayoutsDir)
642
- ].filter((name, index, all) => all.indexOf(name) === index).sort(), warning = `Layout not found: ${layoutPath} (referenced from ${filePath})` + (available.length > 0 ? `. Available layouts: ${available.join(", ")}` : resolvedOptions.layoutsDir ? `. No .stx layouts found in ${resolvedOptions.layoutsDir}` : "");
642
+ ].filter((name, index, all) => all.indexOf(name) === index).sort(), searched = [resolvedOptions.layoutsDir, resolvedOptions.fallbackLayoutsDir].filter((dir) => typeof dir === "string" && dir.length > 0), searchedNote = searched.length > 0 ? ` Searched: ${searched.join(", ")} (set \`layoutsDir\` to look elsewhere).` : "", warning = `Layout not found: ${layoutPath} (referenced from ${filePath})` + (available.length > 0 ? `. Available layouts: ${available.join(", ")}` : resolvedOptions.layoutsDir ? `. No .stx layouts found in ${resolvedOptions.layoutsDir}` : "") + searchedNote;
643
643
  errorLogger.log(Error(warning), { layoutPath, filePath, available }, "error");
644
644
  console.error(`[stx] ${warning}`);
645
645
  if (resolvedOptions.debug)
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Js,zt,yl,wg}from"./chunk-dvh63p75.js";import{Gs,$i,hg,yg,bg}from"./chunk-74y29xxs.js";import{gl,ml,hl,gg,mg}from"./chunk-mdtjjzqc.js";import{Ue,En,Ri}from"./chunk-ev4zxhpd.js";import{vg,xg,Sg,kg,Ys,oy}from"./chunk-et831a4y.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-fh1hw4zy.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{Js,zt,yl,vg}from"./chunk-znhzrjbm.js";import{Gs,$i,yg,bg,wg}from"./chunk-knvt4bap.js";import{gl,ml,hl,mg,hg}from"./chunk-7vqq2w3x.js";import{Ue,En,Ri}from"./chunk-ev4zxhpd.js";import{xg,Sg,kg,_g,Ys,iy}from"./chunk-4rtr07x9.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-pts7jpqc.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Js(n,t);if(a){let s=zt(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return $i(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,ml as auditBuildOutput,gl as auditConfig,re as buildPwaAssets,hl as calculateAuditResult,mg as formatAuditResult,Ri as formatSize,j as generateManifest,_ as generateManifestJson,yg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,En as generatePrecacheManifestJs,M as generatePwaIcons,Gs as generatePwaTags,Js as generateServiceWorker,wg as generateServiceWorkerAuto,hg as generateSwRegistrationScript,bg as generateThemeColorMeta,N as getExpectedIconPaths,zt as getServiceWorkerFileName,$i as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,yl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ys as pwaDirectives,vg as pwaInstallDirective,Sg as pwaOfflineDirective,kg as pwaPushDirective,xg as pwaUpdateDirective,oy as registerPwaDirectives,gg as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Js(n,t);if(a){let s=zt(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return $i(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,ml as auditBuildOutput,gl as auditConfig,re as buildPwaAssets,hl as calculateAuditResult,hg as formatAuditResult,Ri as formatSize,j as generateManifest,_ as generateManifestJson,bg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,En as generatePrecacheManifestJs,M as generatePwaIcons,Gs as generatePwaTags,Js as generateServiceWorker,vg as generateServiceWorkerAuto,yg as generateSwRegistrationScript,wg as generateThemeColorMeta,N as getExpectedIconPaths,zt as getServiceWorkerFileName,$i as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,yl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ys as pwaDirectives,xg as pwaInstallDirective,kg as pwaOfflineDirective,_g as pwaPushDirective,Sg as pwaUpdateDirective,iy as registerPwaDirectives,mg as runPwaAudit,D as validateManifest};
@@ -111,6 +111,18 @@ export declare function convertSignalDirectivesToAttributes(template: string, co
111
111
  * - elements inside `<script>` / `<style>` bodies
112
112
  */
113
113
  export declare function preEvalLiteralReactiveIfs(template: string): string;
114
+ /**
115
+ * `{{ }}` inside a JS string of a reactive attribute, within a client loop.
116
+ *
117
+ * The loop body is evaluated in the browser, where `{{ item.id }}` in an
118
+ * element's text reads the loop's `item`. The value of a `:class`, `@click`
119
+ * or other reactive attribute is not text but a JavaScript expression, and the
120
+ * runtime never looks for a placeholder inside it: `@click="pick('{{ item.id }}')"`
121
+ * passed the literal characters `{{ item.id }}` (stacksjs/stx#2140). The
122
+ * placeholder is rewritten to the expression it names, so the string becomes a
123
+ * template literal that reads the loop variable.
124
+ */
125
+ export declare function bindLoopInterpolations(html: string): string;
114
126
  /**
115
127
  * A `:for` over `<script server>` data becomes a server loop (stacksjs/stx#2051).
116
128
  *
@@ -552,6 +552,17 @@ export function preEvalLiteralReactiveIfs(template) {
552
552
  return output;
553
553
  }
554
554
  const LOOP_ATTRS = [":for", "@for", "x-for"];
555
+ export function bindLoopInterpolations(html) {
556
+ const reactive = /(\s)((?::|@|x-|v-)[\w.:-]+)\s*=\s*"([^"]*\{\{[^"]*)"/g;
557
+ return html.replace(reactive, (whole, space, name, value) => {
558
+ const bound = value.replace(/'((?:[^'\\]|\\.)*)'/g, (literal, body) => {
559
+ if (!body.includes("{{"))
560
+ return literal;
561
+ return `\`${body.replace(/`/g, "\\`").replace(/\$\{/g, "\\${").replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_, expression) => `\${${expression}}`)}\``;
562
+ });
563
+ return `${space}${name}="${bound}"`;
564
+ });
565
+ }
555
566
  export function convertServerLoopAttributesToDirectives(template, context) {
556
567
  if (!context || Object.keys(context).length === 0)
557
568
  return template;
@@ -655,7 +666,7 @@ export function convertSignalLoopsToAttributes(template, context) {
655
666
  delete nestedContext[parsed.itemVar];
656
667
  if (parsed.indexVar)
657
668
  delete nestedContext[parsed.indexVar];
658
- const convertedContent = convertSignalLoopsToAttributes(content, nestedContext), singleElementMatch = convertedContent.match(SINGLE_ELEMENT_RE);
669
+ const convertedContent = bindLoopInterpolations(convertSignalLoopsToAttributes(content, nestedContext)), singleElementMatch = convertedContent.match(SINGLE_ELEMENT_RE);
659
670
  let replacement;
660
671
  if (singleElementMatch) {
661
672
  const [, tag, attrs, innerContent] = singleElementMatch;
package/dist/ssg.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-wmnzapn8.js";import{w,Zc}from"./chunk-1w4a0xya.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import{$t,S}from"./chunk-b6dtw4j0.js";import"./chunk-1g5fg1ys.js";import"./chunk-sd3b6swd.js";import"./chunk-c1b481my.js";import{St,kt,_t,Ct,Et,Tt}from"./chunk-8hanmv49.js";import{a}from"./chunk-9hbvt06e.js";import{ks}from"./chunk-ay02q27h.js";import"./chunk-ztbk9yqv.js";import"./chunk-nr5qsgcw.js";import{he,Qt,en}from"./chunk-zq5c0enz.js";import"./chunk-q0rfq81t.js";import{y}from"./chunk-6nm3h2vw.js";import{ht,i}from"./chunk-4b6dtyd7.js";import"./chunk-qf0z03k8.js";import"./chunk-b62g7wvg.js";import{ls}from"./chunk-nzety7kj.js";import"./chunk-8ge1y01k.js";import"./chunk-h8yk9qm7.js";import{Ka,Xa,Ga}from"./chunk-7yx2ztt5.js";import{Yt,Jn,Yn}from"./chunk-wwnqbv9j.js";import{Zt}from"./chunk-fyv2pjrx.js";import"./chunk-yy0edrwz.js";import"./chunk-vkpmemb1.js";import{X,we}from"./chunk-42kjqjst.js";import"./chunk-qv99gqee.js";import"./chunk-csddc2st.js";import{l}from"./chunk-s2py8kg7.js";import{s,ge}from"./chunk-nr3pepv1.js";import D from"fs";import f from"path";import{createHash as Pt}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 It(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(Rt,(e,u,g,v)=>{let x=v.trim();if(!x)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)x=Dt(x);let p=It(x);if(!n.has(p))n.set(p,x);let P=r.integrity?` data-stx-integrity="sha384-${Pt("sha384").update(x).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let x=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!x)return t;return t.slice(0,v)+x+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function K(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let n=t[r];if(!n)continue;let o=K(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?K(n):null}async function At(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=n.resolve(t,o);if(!r(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=K(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){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-wmnzapn8.js";import{w,Zc}from"./chunk-7s9wx19m.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import{$t,S}from"./chunk-4qrr2mdd.js";import"./chunk-1g5fg1ys.js";import"./chunk-rj9dcjeg.js";import"./chunk-nrh8t8re.js";import{St,kt,_t,Ct,Et,Tt}from"./chunk-fxy7jjnv.js";import{a}from"./chunk-rfzfk8zd.js";import{ks}from"./chunk-cz3trbvn.js";import"./chunk-ztbk9yqv.js";import"./chunk-cyd10m6m.js";import{he,Qt,en}from"./chunk-5fab5wt2.js";import"./chunk-s5kfndxv.js";import{y}from"./chunk-rk2v0wzs.js";import{ht,i}from"./chunk-5q97egpw.js";import"./chunk-enzrpxsj.js";import"./chunk-8x4gmead.js";import{ls}from"./chunk-ecakhzkq.js";import"./chunk-hxyarbb6.js";import"./chunk-h8yk9qm7.js";import{Ka,Xa,Ga}from"./chunk-7yx2ztt5.js";import{Yt,Jn,Yn}from"./chunk-wwnqbv9j.js";import{Zt}from"./chunk-q69dvpg1.js";import"./chunk-5wp7s24b.js";import"./chunk-p7h4y7mk.js";import{X,we}from"./chunk-jgmmg2fw.js";import"./chunk-py818vbj.js";import"./chunk-svrjbeyq.js";import{l}from"./chunk-s2py8kg7.js";import{s,ge}from"./chunk-nr3pepv1.js";import D from"fs";import f from"path";import{createHash as Pt}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 It(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(Rt,(e,u,g,v)=>{let x=v.trim();if(!x)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)x=Dt(x);let p=It(x);if(!n.has(p))n.set(p,x);let P=r.integrity?` data-stx-integrity="sha384-${Pt("sha384").update(x).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let x=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!x)return t;return t.slice(0,v)+x+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function K(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let n=t[r];if(!n)continue;let o=K(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?K(n):null}async function At(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=n.resolve(t,o);if(!r(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=K(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){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
  `)}function q(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=ge(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(n[c.index]!==0)continue;let u=w(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=w(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(n[c.index]!==0)continue;let u=Zc(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let n=await Bun.file(t).text();r="parse";let o=Zt(n),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>n.indexOf(e.fullTag)-n.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(s(g))&&$t(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(q);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let x=await v();r="result";let p=Array.isArray(x)?{paths:x}:x;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(n){return{kind:"error",phase:r,error:n instanceof Error?n:Error(String(n))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[n,o]of Object.entries(r))this.cache.set(n,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),r={};for(let[n,o]of this.cache)r[n]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let n=D.statSync(t),o=`${this.salt}|${t}:${n.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=mt(r).some((u)=>D.existsSync(u)),c=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ls(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(r,n.dependencies??[]);if(n.hash!==e)return this.cache.delete(t),null;return n.html}set(t,r,n,o){let c=this.getHash(r,n);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:n})}}class ft{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let n=this.getFilePath(t);await D.promises.mkdir(f.dirname(n),{recursive:!0}),await Bun.write(n,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=f.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let n=await D.promises.readdir(r);for(let o of n){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await D.promises.unlink(f.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Ut(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let n=await gt(t.filePath);if(n.kind==="error")throw Error(`getStaticPaths ${n.phase} failed for ${t.pattern} (${t.filePath}): ${n.error.message}`,{cause:n.error});if(n.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=n.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}function mt(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of mt(t))if(await Bun.file(r).exists())try{let n=await import(r);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:o,...c}=n;return c}}catch(n){console.error(`Error loading data file ${r}:`,n)}return null}async function Gt(t,r,n){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
4
4
  return (async function getStaticProps() {
5
5
  ${e[1]}
@@ -37,7 +37,7 @@ ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
37
37
  ${n.join(`
38
38
  `)}
39
39
  </channel>
40
- </rss>`}async function Vt(t={}){let r=Date.now();en();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,x={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-vvhdt94w.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-aav6t96n.js"),R=await b(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-vvhdt94w.js");await d('<div class="bg-black"></div>')}catch{}St();let yt=n?.routeMiddleware?.dir||"middleware";await _t(process.cwd(),yt);let J=kt();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let xt=n?.routeMiddleware?.global||[];Ga(n?.layoutsDir,l(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:G,props:bt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=te(A),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...xt,...vt];if(nt.length>0){let B=Ct(h,G,O||{}),L=Et(B,null,void 0,{isServer:!0}),j=await Tt(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=ee(String(C),h),U=re(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
40
+ </rss>`}async function Vt(t={}){let r=Date.now();en();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,x={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-mhc72pp2.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-vq88tjma.js"),R=await b(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-mhc72pp2.js");await d('<div class="bg-black"></div>')}catch{}St();let yt=n?.routeMiddleware?.dir||"middleware";await _t(process.cwd(),yt);let J=kt();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let xt=n?.routeMiddleware?.global||[];Ga(n?.layoutsDir,l(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:G,props:bt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=te(A),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...xt,...vt];if(nt.length>0){let B=Ct(h,G,O||{}),L=Et(B,null,void 0,{isServer:!0}),j=await Tt(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=ee(String(C),h),U=re(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
41
41
  const validate = ${it[1]};
42
42
  return validate(route);
43
43
  `)({params:G})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await wt(k,G,bt,e,n);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
package/dist/utils.js CHANGED
@@ -47,7 +47,16 @@ export {
47
47
  extractVariables,
48
48
  hasVariables
49
49
  } from "./variable-extractor.js";
50
- const componentsCache = new LRUCache(500), componentResolutionCache = new LRUCache(1000), userComponentFileCache = new LRUCache(2000), realDirCache = new LRUCache(500), COMPONENT_RENDER_CACHE_BYTES = 33554432;
50
+ const componentsCache = new LRUCache(500), componentStamps = new Map;
51
+ function fileStamp(filePath) {
52
+ try {
53
+ const stat = fs.statSync(filePath);
54
+ return `${stat.size}:${stat.mtimeMs}`;
55
+ } catch {
56
+ return "";
57
+ }
58
+ }
59
+ const componentResolutionCache = new LRUCache(1000), userComponentFileCache = new LRUCache(2000), realDirCache = new LRUCache(500), COMPONENT_RENDER_CACHE_BYTES = 33554432;
51
60
  let appliedComponentRenderCacheBytes = COMPONENT_RENDER_CACHE_BYTES;
52
61
  function applyComponentRenderCacheBudget(options) {
53
62
  const configured = options.componentRenderCacheBytes;
@@ -836,12 +845,14 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
836
845
  }
837
846
  dependencies.add(componentFilePath);
838
847
  let componentContent;
839
- if (componentsCache.has(componentFilePath))
848
+ if (componentsCache.has(componentFilePath) && componentStamps.get(componentFilePath) === fileStamp(componentFilePath))
840
849
  componentContent = componentsCache.get(componentFilePath);
841
850
  else
842
851
  try {
852
+ const stamp = fileStamp(componentFilePath);
843
853
  componentContent = await Bun.file(componentFilePath).text();
844
854
  componentsCache.set(componentFilePath, componentContent);
855
+ componentStamps.set(componentFilePath, stamp);
845
856
  } catch (error) {
846
857
  const message = error instanceof Error ? error.message : String(error);
847
858
  reportUnresolvedComponent(componentPath, parentFilePath, [componentFilePath], message);
@@ -1408,6 +1419,7 @@ ${colors.dim}${context}${colors.reset}
1408
1419
  }
1409
1420
  export function clearComponentCache() {
1410
1421
  componentsCache.clear();
1422
+ componentStamps.clear();
1411
1423
  componentResolutionCache.clear();
1412
1424
  userComponentFileCache.clear();
1413
1425
  realDirCache.clear();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.764",
4
+ "version": "0.2.769",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -128,12 +128,12 @@
128
128
  "dependencies": {
129
129
  "@stacksjs/ts-css": "^0.3.11",
130
130
  "@stacksjs/clapp": "^0.2.16",
131
- "@stacksjs/desktop": "0.2.764",
132
- "@stacksjs/sanitizer": "0.2.764",
131
+ "@stacksjs/desktop": "0.2.769",
132
+ "@stacksjs/sanitizer": "0.2.769",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.764",
134
+ "bun-plugin-stx": "0.2.769",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.764",
136
+ "stx-router": "0.2.769",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{bo,ma,ha,lh}from"./chunk-6jnrpnxb.js";export{bo as NATIVE_COMPONENTS,ma as compileToNative,ha as createHotReloadServer,lh as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{zg}from"./chunk-fq3cdhc5.js";import"./chunk-zfbekcnz.js";import"./chunk-fyv2pjrx.js";import"./chunk-nr5qsgcw.js";import"./chunk-yy0edrwz.js";import"./chunk-42kjqjst.js";import"./chunk-9hbvt06e.js";import"./chunk-csddc2st.js";import"./chunk-c1b481my.js";import"./chunk-ztbk9yqv.js";import"./chunk-ay02q27h.js";import"./chunk-8hanmv49.js";import"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{zg as startProductionServer};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Js,zt,yl,wg}from"./chunk-dvh63p75.js";export{Js as generateServiceWorker,wg as generateServiceWorkerAuto,zt as getServiceWorkerFileName,yl as isWorkboxEnabled};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Fm,zm,Hm,Vm,Um}from"./chunk-zs8yjtaz.js";export{zm as createSSRSuspense,Vm as generateSuspenseCSS,Um as generateSuspenseRuntime,Fm as processSuspenseDirectives,Hm as renderSSRSuspense};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{um,dm,pm,fm,gm,mm,hm}from"./chunk-stww901w.js";export{dm as createKeepAliveCache,fm as generateKeepAliveCSS,gm as generateKeepAliveRuntime,mm as onActivated,hm as onDeactivated,um as processKeepAliveDirectives,pm as shouldCacheComponent};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Nm,Dm,Mm,Lm,jm,Bm}from"./chunk-2mckhfet.js";export{Lm as generateTransitionCSS,jm as generateTransitionRuntime,Nm as performEnter,Dm as performLeave,Bm as processTransitionAttributes,Mm as processTransitionDirectives};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{rs,sr,Tf}from"./chunk-8ge1y01k.js";import"./chunk-vkpmemb1.js";import"./chunk-nzety7kj.js";import"./chunk-42kjqjst.js";import"./chunk-qv99gqee.js";import"./chunk-9hbvt06e.js";import"./chunk-csddc2st.js";import"./chunk-c1b481my.js";import"./chunk-ztbk9yqv.js";import"./chunk-ay02q27h.js";import"./chunk-8hanmv49.js";import{At}from"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{Tf as declareBareLoopHead,At as parseLoopBinding,sr as processLoops,rs as reportDeferredLoopWarnings};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{j,Nf,Wo,a,P,Nh,Dh}from"./chunk-9hbvt06e.js";import"./chunk-csddc2st.js";import"./chunk-c1b481my.js";import"./chunk-ztbk9yqv.js";import"./chunk-ay02q27h.js";import"./chunk-8hanmv49.js";import"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{P as config,j as defaultConfig,Nh as defineStxConfig,Wo as discoverConfig,a as loadStxConfig,Nf as resolveStxDirectories,Dh as validateConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{hf,yf,he,bf,Ja,Qt,en,mh,Ya,tn,Zn,wf,vf,xf,ts,nn,Sf,rn,Za,hh}from"./chunk-zq5c0enz.js";import"./chunk-nr5qsgcw.js";import"./chunk-wmnzapn8.js";import"./chunk-9hbvt06e.js";import"./chunk-csddc2st.js";import"./chunk-c1b481my.js";import"./chunk-ztbk9yqv.js";import"./chunk-ay02q27h.js";import"./chunk-8hanmv49.js";import"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{Zn as MODULE_SPECIFIER_PREFIX,hf as bundleCacheDir,yf as bundleCacheEntryLimit,hh as bundleClientEntriesSplit,rn as bundleClientScript,en as clearBundleFailures,he as clientBundleDependencies,Qt as getBundleFailures,tn as hasUserImports,nn as moduleSubstitutionKey,vf as normalizeRegistrySpecifiers,Sf as queueClientBundleBuild,Ja as recordBundleFailure,wf as registryIdForPath,Ya as resolveBundlerFallback,xf as rewriteRegistryImports,mh as setBundlerFallbackMode,bf as shouldLogBundlerDiagnostics,Za as tempBuildName,ts as withModuleSubstitutes};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Bg}from"./chunk-a3azc16d.js";import"./chunk-4b6dtyd7.js";import"./chunk-6nm3h2vw.js";import"./chunk-h8yk9qm7.js";import"./chunk-8ge1y01k.js";import"./chunk-b62g7wvg.js";import"./chunk-qf0z03k8.js";import"./chunk-yy0edrwz.js";import"./chunk-vkpmemb1.js";import"./chunk-nzety7kj.js";import"./chunk-42kjqjst.js";import"./chunk-qv99gqee.js";import"./chunk-q0rfq81t.js";import"./chunk-9hbvt06e.js";import"./chunk-csddc2st.js";import"./chunk-c1b481my.js";import"./chunk-ztbk9yqv.js";import"./chunk-ay02q27h.js";import"./chunk-8hanmv49.js";import"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{Bg as startInteractive};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{sn,Eo,To,$o,yh,Ro}from"./chunk-nr5qsgcw.js";import"./chunk-ztbk9yqv.js";import"./chunk-8hanmv49.js";import"./chunk-1g5fg1ys.js";export{To as buildServerApi,yh as createServerApi,sn as discoverServerApi,Eo as generateApiTypes,Ro as isServerApiSource,$o as productionApiDispatcher};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Xo,Go,Jo,Yo,xs,Ss,Mh,Lh,jh,Bh,ks,Fh}from"./chunk-ay02q27h.js";import"./chunk-1w4a0xya.js";export{Fh as generateDefaultRobotsTxt,ks as generateRobotsTxt,Lh as generateSitemap,jh as generateSitemapIndex,Yo as injectSeoTags,xs as metaDirective,Xo as processMetaDirectives,Jo as processSeoDirective,Go as processStructuredData,Mh as registerSeoDirectives,Bh as scanForSitemapEntries,Ss as structuredDataDirective};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{m,ui,zc,Hc,eg,tg,ng,rg,sg,Bs,og,je,Y,Be,ig,_r,ag,Wc,gi,Fe,r,yn,qc,h,fe,Hh}from"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{fe as clearComponentCache,gi as componentClientSignalNames,ui as convertToCommonJS,h as createDetailedErrorMessage,sg as extractDirectiveNames,zc as extractScriptFromTemplate,m as extractVariables,r as fileExists,Hh as getComponentCacheStats,tg as getPositionInfo,Y as getSharedTranspiler,qc as getSourceLineInfo,rg as hasDirectives,Hc as hasVariables,ag as isHydrateTrigger,og as isJavaScriptScript,Fe as renderComponentWithSlot,yn as resolveTemplatePath,ig as scopeOnRootElement,Bs as scopeSequenceKey,je as shouldTranspileTypeScript,Wc as slotContentHasExpressions,Be as transpileTypeScript,_r as userComponentFileExists,ng as validateDirective,eg as validateTemplate};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{oo,Yi,zr,io,ao,$n,qt,Zi,Hr,Vr,co,lo,Hg,Vg,dt}from"./chunk-1day2nbr.js";export{dt as DeployError,Yi as calculateSha1,zr as collectDeployFiles,Vr as createDefaultNetlifyConfig,io as createFileManifest,oo as createNetlifyClient,Hg as deploy,Hr as detectProjectConfig,ao as filterRequiredFiles,$n as formatSize,Zi as generateNetlifyToml,qt as getTotalSize,lo as hasNetlifyConfig,Vg as initNetlify,co as writeNetlifyConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Sh,$f,Ge,nc,kh,ss,os,is}from"./chunk-b62g7wvg.js";import"./chunk-qf0z03k8.js";import"./chunk-yy0edrwz.js";import"./chunk-vkpmemb1.js";import"./chunk-qv99gqee.js";import"./chunk-b6dtw4j0.js";import"./chunk-sd3b6swd.js";import"./chunk-1g5fg1ys.js";import"./chunk-1w4a0xya.js";import"./chunk-4833k99b.js";import"./chunk-07c8rk93.js";export{kh as clearOnceStore,nc as onceStore,Ge as partialsCache,ss as processIncludes,os as processStackPushDirectives,is as processStackReplacements,Sh as resetUnscopedSignalWarnings,$f as topLevelElements};