@stacksjs/stx 0.2.762 → 0.2.765

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 (246) hide show
  1. package/dist/chunk-01484snf.js +2 -0
  2. package/dist/{chunk-b51p56k5.js → chunk-07c8rk93.js} +2 -2
  3. package/dist/chunk-09cera09.js +2 -0
  4. package/dist/{chunk-zhrz4zvw.js → chunk-0d29b573.js} +4 -4
  5. package/dist/chunk-0f5276fm.js +2 -0
  6. package/dist/{chunk-8yyq3nfg.js → chunk-0nzeqc13.js} +2 -2
  7. package/dist/chunk-16n128gh.js +2 -0
  8. package/dist/chunk-171bbyqv.js +2 -0
  9. package/dist/{chunk-dnsf934e.js → chunk-1day2nbr.js} +5 -5
  10. package/dist/chunk-1g0g498y.js +2 -0
  11. package/dist/{chunk-x5seqmrv.js → chunk-1g5fg1ys.js} +2 -2
  12. package/dist/chunk-1qppvj48.js +2 -0
  13. package/dist/{chunk-tpfxvw4q.js → chunk-1w4a0xya.js} +14 -14
  14. package/dist/chunk-1z77g0j6.js +2 -0
  15. package/dist/chunk-2hbwpm36.js +177 -0
  16. package/dist/{chunk-rh2qth8r.js → chunk-2mckhfet.js} +5 -5
  17. package/dist/chunk-31e7xkrt.js +2 -0
  18. package/dist/chunk-3ffz7pd4.js +2 -0
  19. package/dist/{chunk-37y8sg48.js → chunk-3mf27gj6.js} +2 -2
  20. package/dist/{chunk-gwjh981q.js → chunk-49w4cbqb.js} +7 -7
  21. package/dist/chunk-4bhbtvtm.js +2 -0
  22. package/dist/{chunk-18chz0q4.js → chunk-4m3666pm.js} +1 -1
  23. package/dist/{chunk-xtwc2dbk.js → chunk-4tppbw4r.js} +2 -2
  24. package/dist/{chunk-rmk8efc3.js → chunk-4yk7zngj.js} +109 -109
  25. package/dist/{chunk-rj3p5fdy.js → chunk-51dxp9w9.js} +3 -3
  26. package/dist/chunk-59r38w60.js +2 -0
  27. package/dist/chunk-5ttj2c0h.js +2 -0
  28. package/dist/chunk-5x312c05.js +2 -0
  29. package/dist/chunk-65h2h51z.js +2 -0
  30. package/dist/chunk-6ch8t3d9.js +3 -0
  31. package/dist/{chunk-tshpcvcy.js → chunk-6h6teyxp.js} +2 -2
  32. package/dist/{chunk-319aez2f.js → chunk-6jnrpnxb.js} +3 -3
  33. package/dist/chunk-6rd0zz6k.js +2 -0
  34. package/dist/{chunk-8y54tpbr.js → chunk-74y29xxs.js} +5 -5
  35. package/dist/{chunk-t1shvfhm.js → chunk-7aw9qm74.js} +47 -47
  36. package/dist/chunk-7bvhpdqv.js +2 -0
  37. package/dist/{chunk-0fs9kx0h.js → chunk-7yx2ztt5.js} +2 -2
  38. package/dist/{chunk-f8p8ggvw.js → chunk-8hanmv49.js} +4 -4
  39. package/dist/{chunk-j1tsda22.js → chunk-8prk7e1z.js} +10 -10
  40. package/dist/{chunk-nm9tnxnw.js → chunk-8zgvr0fw.js} +5 -5
  41. package/dist/{chunk-pqbxa0r7.js → chunk-a2yptg7r.js} +2 -2
  42. package/dist/{chunk-qystt1qc.js → chunk-a627f39k.js} +1 -1
  43. package/dist/{chunk-ds6mbfdq.js → chunk-as4s0nf5.js} +3 -3
  44. package/dist/chunk-axxd53tn.js +2 -0
  45. package/dist/{chunk-evxp3wmv.js → chunk-ay02q27h.js} +7 -7
  46. package/dist/{chunk-2eamszdq.js → chunk-ay5g5cbk.js} +2 -2
  47. package/dist/chunk-b8ar6431.js +2 -0
  48. package/dist/{chunk-yb71b2d6.js → chunk-b8hsvzqb.js} +2 -2
  49. package/dist/chunk-bnm7ym0g.js +2 -0
  50. package/dist/{chunk-0sd4td6z.js → chunk-bnwkytme.js} +3 -3
  51. package/dist/chunk-brg2ydrk.js +2 -0
  52. package/dist/chunk-bwkw2dw3.js +2 -0
  53. package/dist/chunk-c0fwppzc.js +2 -0
  54. package/dist/{chunk-8rk79ha1.js → chunk-c1b481my.js} +2 -2
  55. package/dist/chunk-c5kpc7rn.js +2 -0
  56. package/dist/{chunk-59k4xb92.js → chunk-c5mbhfff.js} +5 -5
  57. package/dist/chunk-c8256r1a.js +2 -0
  58. package/dist/chunk-cap6exxx.js +2 -0
  59. package/dist/{chunk-mbe4gqd3.js → chunk-ccedry39.js} +2 -2
  60. package/dist/chunk-cft1sprt.js +2 -0
  61. package/dist/{chunk-qjbcp3tc.js → chunk-cswar3zs.js} +3 -3
  62. package/dist/{chunk-t2cq4bpe.js → chunk-dphhs29v.js} +6 -6
  63. package/dist/chunk-dt0deg4z.js +2 -0
  64. package/dist/{chunk-jgk5j35w.js → chunk-dvh63p75.js} +4 -4
  65. package/dist/{chunk-932zx5q4.js → chunk-dxk5r71v.js} +6 -6
  66. package/dist/{chunk-d96xddt9.js → chunk-e1e5xf8z.js} +13 -13
  67. package/dist/{chunk-w2pch5xn.js → chunk-e645nk33.js} +2 -2
  68. package/dist/{chunk-qpb80r4b.js → chunk-efr9dgt6.js} +2 -2
  69. package/dist/chunk-ejqr5cva.js +2 -0
  70. package/dist/{chunk-fxmc5006.js → chunk-et831a4y.js} +2 -2
  71. package/dist/{chunk-5yhv5eqq.js → chunk-ev4zxhpd.js} +2 -2
  72. package/dist/chunk-evbxyw80.js +2 -0
  73. package/dist/chunk-f66n66c8.js +2 -0
  74. package/dist/chunk-f6h8yagj.js +2 -0
  75. package/dist/{chunk-y8pftjg8.js → chunk-fjbhtakz.js} +1 -1
  76. package/dist/chunk-fpsm2qed.js +2 -0
  77. package/dist/{chunk-v1ff2dfp.js → chunk-fta169tc.js} +3 -3
  78. package/dist/{chunk-a222bwpc.js → chunk-ftt3r7wh.js} +5 -5
  79. package/dist/{chunk-48g9wez2.js → chunk-fz717vpc.js} +29 -29
  80. package/dist/chunk-fzf7yfpn.js +2 -0
  81. package/dist/chunk-gaatje2g.js +2 -0
  82. package/dist/{chunk-b0z2n941.js → chunk-h8yk9qm7.js} +2 -2
  83. package/dist/chunk-hfcmbbkq.js +2 -0
  84. package/dist/{chunk-3mz088mb.js → chunk-jb1c4e49.js} +2 -2
  85. package/dist/chunk-jhz0dvqz.js +2 -0
  86. package/dist/chunk-k54pgbzm.js +2 -0
  87. package/dist/{chunk-r8zhed35.js → chunk-kc3kt59e.js} +2 -2
  88. package/dist/chunk-kkx2gqk8.js +2 -0
  89. package/dist/{chunk-rqd6b2nc.js → chunk-knzp4c6m.js} +3 -3
  90. package/dist/{chunk-m3z13f59.js → chunk-kwy0spcd.js} +3 -3
  91. package/dist/{chunk-b7x8b83z.js → chunk-m15nbvck.js} +1 -1
  92. package/dist/{chunk-wby7qzha.js → chunk-m3dr63n0.js} +3 -3
  93. package/dist/{chunk-eb6p3p62.js → chunk-mdtjjzqc.js} +2 -2
  94. package/dist/{chunk-epa73jvs.js → chunk-mmcqgwk7.js} +2 -2
  95. package/dist/{chunk-02c46de1.js → chunk-mpaepc7n.js} +165 -42
  96. package/dist/{chunk-0kq0k4pg.js → chunk-n5dd6rpt.js} +2 -2
  97. package/dist/{chunk-jyp2mmts.js → chunk-n8gfetjx.js} +2 -2
  98. package/dist/chunk-n9zka6dg.js +2 -0
  99. package/dist/{chunk-bvctccab.js → chunk-nj5azxxj.js} +3 -3
  100. package/dist/{chunk-42zqmcnc.js → chunk-nr3pepv1.js} +3 -3
  101. package/dist/{chunk-r1tp2gnr.js → chunk-p42kp93g.js} +1 -1
  102. package/dist/{chunk-2zd51tj4.js → chunk-pqgk9mxp.js} +2 -2
  103. package/dist/chunk-pvx57vpw.js +2 -0
  104. package/dist/{chunk-fhpsf4z7.js → chunk-q22hwm64.js} +5 -5
  105. package/dist/chunk-qcz104h3.js +2 -0
  106. package/dist/chunk-qgvez75f.js +2 -0
  107. package/dist/{chunk-y4mp1rra.js → chunk-qv2k0qb1.js} +94 -94
  108. package/dist/{chunk-k2ex94n8.js → chunk-qv99gqee.js} +1 -1
  109. package/dist/chunk-r0j6jkxc.js +2 -0
  110. package/dist/{chunk-ben8bjnk.js → chunk-rv0yth27.js} +4 -4
  111. package/dist/chunk-rzh4xgb4.js +2 -0
  112. package/dist/chunk-rzv9xcyp.js +2 -0
  113. package/dist/{chunk-4tgn1frg.js → chunk-s2py8kg7.js} +2 -2
  114. package/dist/chunk-s922mx0k.js +2 -0
  115. package/dist/{chunk-rd33qkfs.js → chunk-s9m2gfns.js} +7 -7
  116. package/dist/{chunk-xt034729.js → chunk-scq0h2cs.js} +6 -6
  117. package/dist/{chunk-ak93e1zz.js → chunk-stww901w.js} +5 -5
  118. package/dist/chunk-sy4wqxta.js +2 -0
  119. package/dist/chunk-szdm8wfn.js +2 -0
  120. package/dist/chunk-t424gvwc.js +2 -0
  121. package/dist/{chunk-yk456jp4.js → chunk-t6d7m4tf.js} +7 -7
  122. package/dist/{chunk-mdvtermb.js → chunk-t70s45hc.js} +2 -2
  123. package/dist/{chunk-dvpk4c1y.js → chunk-t8cgxk8w.js} +2 -2
  124. package/dist/{chunk-edhxg3rz.js → chunk-tqf8a258.js} +56 -56
  125. package/dist/{chunk-9k8ztdcc.js → chunk-vkpmemb1.js} +2 -2
  126. package/dist/chunk-vtvaa8y9.js +2 -0
  127. package/dist/chunk-vvj09a7b.js +2 -0
  128. package/dist/{chunk-rxm1mjkb.js → chunk-vvm38ysm.js} +1 -1
  129. package/dist/chunk-vwjy6491.js +2 -0
  130. package/dist/{chunk-736ex6r5.js → chunk-vy1weqvj.js} +4 -4
  131. package/dist/chunk-w2nzevn0.js +2 -0
  132. package/dist/chunk-wadp2rmj.js +2 -0
  133. package/dist/{chunk-k9247v28.js → chunk-wb2ej5by.js} +1 -1
  134. package/dist/chunk-wbkcwj27.js +2 -0
  135. package/dist/{chunk-2typf9dh.js → chunk-wp4nqnn7.js} +1 -1
  136. package/dist/chunk-wzp8y0a4.js +2 -0
  137. package/dist/chunk-xc1he6hs.js +2 -0
  138. package/dist/{chunk-m6rzsbas.js → chunk-xcstrdhp.js} +4 -4
  139. package/dist/{chunk-cdcrd33m.js → chunk-ysfeg3cn.js} +2 -2
  140. package/dist/chunk-ytzzth34.js +2 -0
  141. package/dist/{chunk-xgnmgjpv.js → chunk-z6sg0dq3.js} +4 -4
  142. package/dist/{chunk-k9wr8xf5.js → chunk-zfaa5xn5.js} +6 -6
  143. package/dist/chunk-zhxg6b64.js +2 -0
  144. package/dist/{chunk-rha8sv1h.js → chunk-zjar9jdd.js} +2 -2
  145. package/dist/{chunk-89801pjp.js → chunk-zs8yjtaz.js} +5 -5
  146. package/dist/{chunk-q3azy64b.js → chunk-ztbk9yqv.js} +4 -4
  147. package/dist/cli.js +19 -19
  148. package/dist/client/signals-bootstrap-runtime.js +1 -1
  149. package/dist/client/signals-class-runtime.js +5 -5
  150. package/dist/client/signals-dom-ready-runtime.js +1 -0
  151. package/dist/client/signals-expression-runtime.js +118 -0
  152. package/dist/client/signals-for-runtime.js +7 -7
  153. package/dist/client/signals-if-chain-runtime.js +3 -3
  154. package/dist/client/signals-if-runtime.js +7 -7
  155. package/dist/client/signals-model-runtime.js +1 -1
  156. package/dist/client/signals-process-element-runtime.js +12 -8
  157. package/dist/client/signals-show-runtime.js +1 -1
  158. package/dist/client/signals-style-runtime.js +1 -1
  159. package/dist/composables/index.d.ts +2 -0
  160. package/dist/composables/index.js +1 -0
  161. package/dist/composables/use-virtual-list.d.ts +24 -0
  162. package/dist/composables/use-virtual-list.js +76 -0
  163. package/dist/config.js +3 -0
  164. package/dist/craft-entry.js +2 -2
  165. package/dist/craft.js +2 -2
  166. package/dist/document-shell.d.ts +10 -1
  167. package/dist/document-shell.js +1 -1
  168. package/dist/expressions.js +19 -0
  169. package/dist/index.d.ts +1 -1
  170. package/dist/native/compiler/render-screen.d.ts +2 -8
  171. package/dist/native/compiler/render-screen.js +3 -10
  172. package/dist/native/event-names.js +2 -0
  173. package/dist/native/primitives-dir.d.ts +13 -0
  174. package/dist/native/primitives-dir.js +14 -0
  175. package/dist/native/prop-names.js +1 -0
  176. package/dist/process.js +1 -1
  177. package/dist/pwa.js +3 -3
  178. package/dist/ssg.js +8 -8
  179. package/dist/state-management.d.ts +22 -0
  180. package/dist/types/config-types.d.ts +2 -0
  181. package/dist/unresolved-identifiers.js +1 -0
  182. package/dist/utils.js +20 -2
  183. package/package.json +5 -5
  184. package/stx.d.ts +4 -0
  185. package/dist/chunk-00nz3pas.js +0 -2
  186. package/dist/chunk-05jdq9tw.js +0 -177
  187. package/dist/chunk-0cajfv7y.js +0 -2
  188. package/dist/chunk-13v3vgb6.js +0 -2
  189. package/dist/chunk-1p8t2ekg.js +0 -2
  190. package/dist/chunk-1rcntvgx.js +0 -2
  191. package/dist/chunk-1w5gtkd6.js +0 -2
  192. package/dist/chunk-28vtqwxh.js +0 -2
  193. package/dist/chunk-298gj90a.js +0 -2
  194. package/dist/chunk-2gn6smrq.js +0 -2
  195. package/dist/chunk-2wq0h5ye.js +0 -2
  196. package/dist/chunk-3wxb7mfb.js +0 -2
  197. package/dist/chunk-528cn6qm.js +0 -2
  198. package/dist/chunk-5x0g7e9y.js +0 -2
  199. package/dist/chunk-633a53wg.js +0 -2
  200. package/dist/chunk-6b737vch.js +0 -2
  201. package/dist/chunk-72ns4q88.js +0 -2
  202. package/dist/chunk-86cg9qqm.js +0 -2
  203. package/dist/chunk-8czxtjwm.js +0 -2
  204. package/dist/chunk-8h5mqs28.js +0 -2
  205. package/dist/chunk-940wny2b.js +0 -2
  206. package/dist/chunk-9fh4ah7t.js +0 -2
  207. package/dist/chunk-a81rt2t4.js +0 -3
  208. package/dist/chunk-ad9dt9rk.js +0 -2
  209. package/dist/chunk-ak4w2emd.js +0 -2
  210. package/dist/chunk-b8dtz3v8.js +0 -2
  211. package/dist/chunk-cenvzm5q.js +0 -2
  212. package/dist/chunk-d49pst1m.js +0 -2
  213. package/dist/chunk-dj0qy19b.js +0 -2
  214. package/dist/chunk-e2q79dfs.js +0 -2
  215. package/dist/chunk-ebxncrd8.js +0 -2
  216. package/dist/chunk-fht1zs1r.js +0 -2
  217. package/dist/chunk-fjfrgef4.js +0 -2
  218. package/dist/chunk-fmk9hjht.js +0 -2
  219. package/dist/chunk-fxnk5ee8.js +0 -2
  220. package/dist/chunk-j1z7tgdp.js +0 -2
  221. package/dist/chunk-jq1698j4.js +0 -2
  222. package/dist/chunk-k0jkpw0q.js +0 -2
  223. package/dist/chunk-k469ym7a.js +0 -2
  224. package/dist/chunk-m5740sd3.js +0 -2
  225. package/dist/chunk-mdw96yhg.js +0 -2
  226. package/dist/chunk-mebf9vwb.js +0 -2
  227. package/dist/chunk-p2se8s6r.js +0 -2
  228. package/dist/chunk-p7zrz0wb.js +0 -2
  229. package/dist/chunk-pdnyfk2v.js +0 -2
  230. package/dist/chunk-qfhjtz2q.js +0 -2
  231. package/dist/chunk-r5tsewzd.js +0 -2
  232. package/dist/chunk-rnvrtcz6.js +0 -2
  233. package/dist/chunk-s36cpnxa.js +0 -2
  234. package/dist/chunk-tfy1m821.js +0 -2
  235. package/dist/chunk-vc3ppphz.js +0 -2
  236. package/dist/chunk-vttx66q0.js +0 -2
  237. package/dist/chunk-vxs07119.js +0 -2
  238. package/dist/chunk-x1x69g3s.js +0 -2
  239. package/dist/chunk-x8hz5gzb.js +0 -2
  240. package/dist/chunk-xfdtym3s.js +0 -2
  241. package/dist/chunk-y6mqq78g.js +0 -2
  242. package/dist/chunk-ycttwgpg.js +0 -2
  243. package/dist/chunk-yd6x9226.js +0 -2
  244. package/dist/chunk-yn3kff5k.js +0 -2
  245. package/dist/chunk-ynjm2tm0.js +0 -2
  246. package/dist/chunk-zpjdp0he.js +0 -2
@@ -2,6 +2,7 @@ export const SIGNALS_EXPRESSION_RUNTIME = ` // Setup accessors refer to lexical
2
2
  // copies preserve those accessors so rows and event closures do not freeze
3
3
  // their setup-time values. Data properties retain ordinary spread semantics.
4
4
  function assignTemplateScope(target, ...sources) {
5
+ if (target === componentScope) __stxScopeGen++;
5
6
  for (var source of sources) {
6
7
  if (!source) continue;
7
8
  for (var key of Object.keys(source)) {
@@ -13,9 +14,126 @@ export const SIGNALS_EXPRESSION_RUNTIME = ` // Setup accessors refer to lexical
13
14
  }
14
15
  return target;
15
16
  }
17
+ // The page-wide compatibility scope is rewritten as each component mounts:
18
+ // every name a component declares is assigned into it, so by the end it holds
19
+ // the LAST instance's. A scope merged earlier kept the names of its own
20
+ // moment (a copy froze them), and a handler or binding that runs later relies
21
+ // on that: three instances of one component each press their own button. A
22
+ // view reads its sources live, so it is handed a snapshot of this one, taken
23
+ // once per rewrite rather than once per merge.
24
+ let __stxScopeGen = 0;
25
+ let __stxSnapshot = { source: null, generation: -1, copy: null };
26
+ function snapshotOfPageScope() {
27
+ if (__stxSnapshot.source !== componentScope || __stxSnapshot.generation !== __stxScopeGen) {
28
+ __stxSnapshot = { source: componentScope, generation: __stxScopeGen, copy: assignTemplateScope({}, componentScope) };
29
+ }
30
+ return __stxSnapshot.copy;
31
+ }
32
+ // A merged scope is a LAYERED VIEW over its sources, never a copy of them.
33
+ //
34
+ // Every binding, listener and conditional of every row took its own copy of
35
+ // the whole page scope - globals, every component's names, the row's - and a
36
+ // page with a few hundred names paid about 75 microseconds for each: 2,300
37
+ // copies to draw 60 rows of a to-do list, 90% of the time it took. The view
38
+ // costs one small object and a proxy, so the price of a merge no longer grows
39
+ // with the size of the page. Later sources shadow earlier ones, as they did;
40
+ // a write, a defineProperty or a delete lands on the view's own layer and
41
+ // never reaches a source. Sources stay live, so a name registered after the
42
+ // view was made is visible through it (a copy froze the names of its moment).
43
+ const __STX_LAYERS = Symbol('stx.layers');
44
+ const __STX_HIDDEN = Symbol('stx.hidden');
45
+ const __stxIsEnumerable = Object.prototype.propertyIsEnumerable;
46
+ // The layer that holds name, or null: the view's own properties first, then
47
+ // the sources from last to first. A deleted name is found nowhere.
48
+ function __stxLayerOf(own, name) {
49
+ const hidden = own[__STX_HIDDEN];
50
+ if (hidden !== undefined && hidden.has(name)) return null;
51
+ if (__stxIsEnumerable.call(own, name)) return own;
52
+ const layers = own[__STX_LAYERS];
53
+ for (let i = layers.length - 1; i >= 0; i--) {
54
+ if (__stxIsEnumerable.call(layers[i], name)) return layers[i];
55
+ }
56
+ return null;
57
+ }
58
+ const __stxScopeHandler = {
59
+ get(own, name) {
60
+ if (typeof name === 'symbol') return own[name];
61
+ const layer = __stxLayerOf(own, name);
62
+ return layer === null ? own[name] : layer[name];
63
+ },
64
+ has(own, name) {
65
+ if (typeof name === 'symbol') return name in own;
66
+ return __stxLayerOf(own, name) !== null || name in own;
67
+ },
68
+ set(own, name, value) {
69
+ if (typeof name !== 'symbol' && own[__STX_HIDDEN] !== undefined) own[__STX_HIDDEN].delete(name);
70
+ own[name] = value;
71
+ return true;
72
+ },
73
+ defineProperty(own, name, descriptor) {
74
+ if (typeof name !== 'symbol' && own[__STX_HIDDEN] !== undefined) own[__STX_HIDDEN].delete(name);
75
+ return Reflect.defineProperty(own, name, descriptor);
76
+ },
77
+ deleteProperty(own, name) {
78
+ delete own[name];
79
+ if (typeof name !== 'symbol' && __stxLayerOf(own, name) !== null) {
80
+ if (own[__STX_HIDDEN] === undefined) Object.defineProperty(own, __STX_HIDDEN, { value: new Set(), configurable: true });
81
+ own[__STX_HIDDEN].add(name);
82
+ }
83
+ return true;
84
+ },
85
+ ownKeys(own) {
86
+ const keys = new Set();
87
+ const layers = own[__STX_LAYERS];
88
+ for (let i = 0; i < layers.length; i++) {
89
+ const names = Object.keys(layers[i]);
90
+ for (let k = 0; k < names.length; k++) keys.add(names[k]);
91
+ }
92
+ const mine = Object.keys(own);
93
+ for (let k = 0; k < mine.length; k++) keys.add(mine[k]);
94
+ const hidden = own[__STX_HIDDEN];
95
+ if (hidden !== undefined) hidden.forEach(function(name) { keys.delete(name); });
96
+ return Array.from(keys);
97
+ },
98
+ getOwnPropertyDescriptor(own, name) {
99
+ if (typeof name === 'symbol') return Reflect.getOwnPropertyDescriptor(own, name);
100
+ const layer = __stxLayerOf(own, name);
101
+ if (layer === null) return undefined;
102
+ const descriptor = Object.getOwnPropertyDescriptor(layer, name);
103
+ descriptor.configurable = true;
104
+ if ('value' in descriptor) descriptor.writable = true;
105
+ return descriptor;
106
+ },
107
+ };
16
108
  function mergeTemplateScopes(...sources) {
17
109
  return assignTemplateScope({}, ...sources);
18
110
  }
111
+ // The view, for the hot paths that only READ the result (see above).
112
+ function layerTemplateScopes(...sources) {
113
+ const layers = [];
114
+ for (let i = 0; i < sources.length; i++) {
115
+ let source = sources[i];
116
+ if (!source) continue;
117
+ if (source === componentScope) source = snapshotOfPageScope();
118
+ const inner = source[__STX_LAYERS];
119
+ // A view made of views stays one level deep: take its layers and its own
120
+ // properties as layers of the new one. A view with deleted names cannot
121
+ // be taken apart (the layers beneath still hold them), so it is a layer.
122
+ if (inner !== undefined && source[__STX_HIDDEN] === undefined) {
123
+ const ownLayer = __stxOwnOf.get(source);
124
+ for (let k = 0; k < inner.length; k++) layers.push(inner[k]);
125
+ layers.push(ownLayer);
126
+ }
127
+ else layers.push(source);
128
+ }
129
+ const own = {};
130
+ Object.defineProperty(own, __STX_LAYERS, { value: layers, configurable: true });
131
+ const view = new Proxy(own, __stxScopeHandler);
132
+ __stxOwnOf.set(view, own);
133
+ return view;
134
+ }
135
+ // The own layer of a view, to read through it when a view is a source.
136
+ const __stxOwnOf = new WeakMap();
19
137
 
20
138
  let componentScope = { $refs: {} };
21
139
 
@@ -26,7 +26,7 @@ export const SIGNALS_FOR_RUNTIME = ` function bindFor(el, passedScope = compone
26
26
  }
27
27
  slotCallerScope = receiver && receiver.__stx_parent_scope
28
28
  || findElementScope(el) || passedScope;
29
- const bindingScope = mergeTemplateScopes(slotCallerScope);
29
+ const bindingScope = layerTemplateScopes(slotCallerScope);
30
30
  slotScopeInfo.names.concat(['__stx_slot_value']).forEach(function(name) { delete bindingScope[name]; });
31
31
  readSlotBindings = __stxCompileScoped(bindingScope, ['__stx_slot_value'],
32
32
  'const ' + slotScopeInfo.binding + ' = __stx_slot_value; return {' + slotScopeInfo.names.join(',') + '};');
@@ -208,7 +208,7 @@ else {
208
208
  return expression;
209
209
  }
210
210
  // Use passedScope instead of componentScope to preserve context through nested processing
211
- var scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
211
+ var scope = layerTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
212
212
  const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
213
213
  if (typeof prop !== 'string') return false;
214
214
  return expressionCallsSignal(expression, prop)
@@ -230,7 +230,7 @@ catch (e) {
230
230
  const evalLazy = (expression, extraScope = {}) => {
231
231
  try {
232
232
  if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;
233
- var scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
233
+ var scope = layerTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
234
234
  const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
235
235
  if (typeof prop !== 'string') return false;
236
236
  return expressionCallsSignal(expression, prop)
@@ -301,8 +301,8 @@ catch (e) {
301
301
  const indexSignal = state(index);
302
302
 
303
303
  const itemScope = slotScopeInfo
304
- ? mergeTemplateScopes(globalHelpers, slotCallerScope)
305
- : mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}));
304
+ ? layerTemplateScopes(globalHelpers, slotCallerScope)
305
+ : layerTemplateScopes(globalHelpers, passedScope, (capturedScope || {}));
306
306
  Object.defineProperty(itemScope, itemName, { value: itemSignal, writable: true, enumerable: true, configurable: true });
307
307
  if (slotScopeInfo) {
308
308
  slotScopeInfo.names.forEach(function(name) {
@@ -357,7 +357,7 @@ catch (e) {
357
357
  try {
358
358
  const rowScope = { [itemName]: item };
359
359
  rowScope[indexName || '_idx'] = index;
360
- const scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), rowScope);
360
+ const scope = layerTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), rowScope);
361
361
  const unwrapScope = createExpressionAutoUnwrapProxy(scope, keyExpr);
362
362
  const fn = __stxCompileScoped(unwrapScope, [], 'return ' + keyExpr);
363
363
  const key = fn(...__stxArgs(fn, unwrapScope));
@@ -451,7 +451,7 @@ catch (e) {
451
451
  var rootInScope = true;
452
452
  var rootVal;
453
453
  try {
454
- var diagMerged = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}));
454
+ var diagMerged = layerTemplateScopes(globalHelpers, passedScope, (capturedScope || {}));
455
455
  var firstIdent = listExpr.match(/^[A-Za-z_$][\\w$]*/);
456
456
  rootName = firstIdent ? firstIdent[0] : '?';
457
457
  rootInScope = Object.prototype.hasOwnProperty.call(diagMerged, rootName);
@@ -12,7 +12,7 @@ export const SIGNALS_IF_CHAIN_RUNTIME = ` // Reactive if/else-if/else chain. A
12
12
  var parent = head.parentNode;
13
13
  if (!parent) { console.warn('[STX] bindIfChain: head element has no parent, skipping'); return; }
14
14
 
15
- var capturedComponentScope = mergeTemplateScopes(passedScope);
15
+ var capturedComponentScope = layerTemplateScopes(passedScope);
16
16
 
17
17
  // Detach every branch up-front, leaving a positional placeholder comment
18
18
  // so reinsertion preserves source order. Mark each as a chain member so
@@ -79,7 +79,7 @@ export const SIGNALS_IF_CHAIN_RUNTIME = ` // Reactive if/else-if/else chain. A
79
79
  function evalBranch(b) {
80
80
  var expression = b.expr;
81
81
  if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;
82
- var scope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (b.capturedElementScope || {}));
82
+ var scope = layerTemplateScopes(globalHelpers, capturedComponentScope, (b.capturedElementScope || {}));
83
83
  try {
84
84
  var unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
85
85
  // Compiled over the names the expression mentions (see __stxCompileScoped).
@@ -247,7 +247,7 @@ catch (e) { /* a disposer of its own is not this branch's problem */ }
247
247
  // branch picked after render survive their row's removal (#1954).
248
248
  pick.el.__stx_chain_disposers = trackEffects(function () {
249
249
  peek(function () {
250
- var childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (pick.capturedElementScope || {}));
250
+ var childScope = layerTemplateScopes(globalHelpers, capturedComponentScope, (pick.capturedElementScope || {}));
251
251
  // Components compiled inside any branch of an if/else-if/else
252
252
  // chain carry scoped setup scripts with them. Branch nodes are
253
253
  // detached before those scripts can execute, so simply
@@ -42,7 +42,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
42
42
  // Capture BOTH element scope AND passedScope NOW before anything changes
43
43
  // passedScope may contain @for iteration variables or parent component signals
44
44
  const capturedElementScope = findElementScope(el);
45
- const capturedComponentScope = mergeTemplateScopes(passedScope);
45
+ const capturedComponentScope = layerTemplateScopes(passedScope);
46
46
 
47
47
  preserveConditionalComponentScopes(el, capturedComponentScope);
48
48
  stxHost.insert(parent, placeholder, el);
@@ -72,7 +72,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
72
72
  return expression;
73
73
  }
74
74
  try {
75
- var scope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
75
+ var scope = layerTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
76
76
  const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
77
77
  const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
78
78
  return fn(...__stxArgs(fn, unwrapScope));
@@ -80,7 +80,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
80
80
  catch (e1) {
81
81
  try {
82
82
  // Retry without the unwrap proxy so call-syntax (signal()) works.
83
- const scope2 = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
83
+ const scope2 = layerTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
84
84
  const fn2 = __stxCompileScoped(scope2, [], 'return ' + expression + '');
85
85
  return fn2(...__stxArgs(fn2, scope2));
86
86
  }
@@ -99,7 +99,7 @@ catch (e2) {
99
99
  const processChildrenWithScope = () => {
100
100
  // Build the combined scope for children - no need to modify global componentScope
101
101
  // Just pass the scope explicitly to processElement
102
- const childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
102
+ const childScope = layerTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
103
103
 
104
104
 
105
105
  Array.from(el.childNodes).forEach(child => processElement(child, childScope));
@@ -113,7 +113,7 @@ catch (e2) {
113
113
  // inserted and left inert, so bindings such as :text and {{ expression }}
114
114
  // leaked into the rendered UI until the condition toggled.
115
115
  const processTemplateNodes = (nodes) => {
116
- const childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
116
+ const childScope = layerTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
117
117
  // Components compiled inside a <template :if> carry setup scripts in the
118
118
  // template content. Browser-cloned scripts are inert, so register their
119
119
  // scopes and forwarded props before walking the inserted branch. This is
@@ -132,7 +132,7 @@ catch (e2) {
132
132
 
133
133
  // Evaluate the :if expression \u2014 use direct signal read for simple refs,
134
134
  // falling back to evalExpr for complex expressions
135
- const fullScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
135
+ const fullScope = layerTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
136
136
  const directSignal = fullScope[expr];
137
137
 
138
138
  effect(() => {
@@ -304,7 +304,7 @@ else if (!value && isInserted) {
304
304
  detachedBranches.add(resume);
305
305
  return;
306
306
  }
307
- var childScope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
307
+ var childScope = layerTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
308
308
  // A false single-element conditional is detached before the
309
309
  // DOMContentLoaded component-scope pass. When it becomes visible,
310
310
  // hydrate any component roots in the restored subtree first so
@@ -4,7 +4,7 @@ export const SIGNALS_MODEL_RUNTIME = ` function bindModel(el, expr, passedScope
4
4
  const tag = el.tagName.toLowerCase();
5
5
  const type = el.type;
6
6
  const modifiers = attrName.split('.').slice(1);
7
- const capturedScope = mergeTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
7
+ const capturedScope = layerTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
8
8
  const coerceValue = (value) => {
9
9
  var next = value;
10
10
  if (modifiers.includes('trim') && typeof next === 'string') next = next.trim();
@@ -42,14 +42,14 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
42
42
  if (el.hasAttribute('x-data') || el.hasAttribute('data-stx-xdata') || el.__stx_scope) {
43
43
  var xdScope = el.__stx_scope || (findElementScope(el) || {});
44
44
  if (xdScope && Object.keys(xdScope).length > 0) {
45
- scope = mergeTemplateScopes(scope, xdScope);
45
+ scope = layerTemplateScopes(scope, xdScope);
46
46
  }
47
47
  }
48
48
  // v-memo / @memo \u2014 skip re-processing if dependency values haven't changed
49
49
  if (el.hasAttribute('data-stx-memo')) {
50
50
  var memoExpr = el.getAttribute('data-stx-memo');
51
51
  try {
52
- var memoScope = mergeTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
52
+ var memoScope = layerTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
53
53
  var memoFn = __stxCompileScoped(memoScope, [], 'return ' + memoExpr);
54
54
  var memoVals = JSON.stringify(memoFn(...__stxArgs(memoFn, memoScope)));
55
55
  if (el.__stx_memo_prev === memoVals) {
@@ -83,7 +83,7 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
83
83
  // Capture scope NOW before effects run asynchronously
84
84
  // Use the passed scope parameter (not global componentScope) to preserve context
85
85
  // through nested @if/@for processing where componentScope may be restored
86
- const capturedScope = el.__stx_slot_scope || mergeTemplateScopes(globalHelpers, scope, (findElementScope(parentEl) || {}));
86
+ const capturedScope = el.__stx_slot_scope || layerTemplateScopes(globalHelpers, scope, (findElementScope(parentEl) || {}));
87
87
  parts.forEach(part => {
88
88
  const match = part.match(/^\\{\\{\\s*([\\s\\S]+?)\\s*\\}\\}$/);
89
89
  if (match) {
@@ -215,7 +215,7 @@ else if (part) {
215
215
 
216
216
  // Capture scope once for all attribute bindings on this element
217
217
  // Use the passed scope parameter to preserve context through nested processing
218
- const attrCapturedScope = mergeTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
218
+ const attrCapturedScope = layerTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
219
219
 
220
220
  // Keep the conditional owners captured while the element is in the tree.
221
221
  // Walking parents on each update loses an outer owner when an inner :if
@@ -437,7 +437,11 @@ catch (e2) {
437
437
  }
438
438
  return;
439
439
  }
440
- if (attrName.startsWith('aria-') && typeof v === 'boolean') {
440
+ // aria-* and data-* carry a STRING: the platform's boolean attribute
441
+ // is presence, which cannot say "false" and wrote data-open="" for
442
+ // true, so a [data-open='true'] selector never matched. React renders
443
+ // both as "true" / "false", and so does this.
444
+ if ((attrName.startsWith('aria-') || attrName.startsWith('data-')) && typeof v === 'boolean') {
441
445
  stxHost.setAttribute(el, attrName, String(v));
442
446
  }
443
447
  else if (typeof v === 'boolean') {
@@ -577,8 +581,8 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
577
581
  // Capture scope at setup time so @for loop variables are available when event fires
578
582
  const isForwardedComponentEvent = !!(el.__stx_parent_scope && parentEventNames.includes(eventName));
579
583
  let eventCapturedScope = isForwardedComponentEvent
580
- ? mergeTemplateScopes(globalHelpers, el.__stx_parent_scope)
581
- : mergeTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
584
+ ? layerTemplateScopes(globalHelpers, el.__stx_parent_scope)
585
+ : layerTemplateScopes(globalHelpers, scope, (findElementScope(el) || {}));
582
586
 
583
587
  stxHost.listen(el, eventName, (event) => {
584
588
  // A forwarded handler belongs to the caller, whose scope can be
@@ -587,7 +591,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
587
591
  // page's scope and only later handed its real caller, so
588
592
  // @pick="pickFromBank" found nothing and did nothing. Read it now.
589
593
  if (isForwardedComponentEvent && el.__stx_parent_scope)
590
- eventCapturedScope = mergeTemplateScopes(globalHelpers, el.__stx_parent_scope);
594
+ eventCapturedScope = layerTemplateScopes(globalHelpers, el.__stx_parent_scope);
591
595
  // Vue-style component listeners fall through to the rendered native
592
596
  // root unless the child emits the same event. Signal components use
593
597
  // a scope wrapper, so native events arrive here from a descendant.
@@ -2,7 +2,7 @@ export const SIGNALS_SHOW_RUNTIME = ` function bindShow(el, expr, passedScope =
2
2
  if (el.__stx_show_bound) return;
3
3
  el.__stx_show_bound = true;
4
4
 
5
- const capturedScope = mergeTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
5
+ const capturedScope = layerTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
6
6
 
7
7
  // Check if the expression is a simple signal reference (most common case for :show)
8
8
  const directSignal = capturedScope[expr];
@@ -1,6 +1,6 @@
1
1
  export const SIGNALS_STYLE_RUNTIME = ` function bindStyle(el, expr, passedScope = componentScope, isVisible) {
2
2
  // Capture scope at setup time - use passed scope to preserve context
3
- const capturedScope = mergeTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
3
+ const capturedScope = layerTemplateScopes(globalHelpers, passedScope, (findElementScope(el) || {}));
4
4
 
5
5
  const evalExpr = () => {
6
6
  // Mirror bindClass: first try the auto-unwrap proxy (so an expression
@@ -447,6 +447,8 @@ export { defineForm, useForm } from './use-form';
447
447
  // Inline AI-style ghost text for a text field: debounce, abort, stale discard, accept.
448
448
  // Demand-bundled for client scripts like useForm.
449
449
  export { useCompletion, type Completion, type CompletionContext, type CompletionMeta, type UseCompletionOptions } from './use-completion';
450
+ // A long list drawn through a window of its rows. Demand-bundled for client scripts.
451
+ export { useVirtualList, type UseVirtualList, type UseVirtualListOptions, type VirtualRow } from './use-virtual-list';
450
452
  // Authenticated server broadcasts, demand-bundled for client scripts.
451
453
  export { useBroadcastStream, type BroadcastStreamFrame, type BroadcastStreamClientOptions } from './use-broadcast-stream';
452
454
  // Breathing exercises: a step-by-step pacer and generated ambient sound,
@@ -239,6 +239,7 @@ export {
239
239
  } from "./use-color-mode.js";
240
240
  export { defineForm, useForm } from "./use-form.js";
241
241
  export { useCompletion } from "./use-completion.js";
242
+ export { useVirtualList } from "./use-virtual-list.js";
242
243
  export { useBroadcastStream } from "./use-broadcast-stream.js";
243
244
  export {
244
245
  useBreathPacer
@@ -0,0 +1,24 @@
1
+ import type { Signal } from '../signals-api';
2
+ export declare function useVirtualList<T>(source: Signal<T[]> | (() => T[]) | T[], options: UseVirtualListOptions): UseVirtualList<T>;
3
+ export declare interface VirtualRow<T> {
4
+ index: number
5
+ data: T
6
+ }
7
+ export declare interface UseVirtualListOptions {
8
+ itemHeight: number | ((index: number) => number)
9
+ overscan?: number
10
+ height?: number
11
+ }
12
+ export declare interface UseVirtualList<T> {
13
+ list: () => VirtualRow<T>[]
14
+ start: () => number
15
+ end: () => number
16
+ totalHeight: () => number
17
+ offsetTop: () => number
18
+ onScroll: (event: { target?: unknown } | null | undefined) => void
19
+ measure: (element: { clientHeight?: number, scrollTop?: number } | null | undefined) => void
20
+ containerStyle: () => string
21
+ wrapperStyle: () => string
22
+ scrollTo: (index: number, scroller?: { scrollTop: number } | null) => void
23
+ scrollTop: () => number
24
+ }
@@ -0,0 +1,76 @@
1
+ import { derived, state } from "../signals-api.js";
2
+ export function useVirtualList(source, options) {
3
+ const overscan = Math.max(0, options.overscan ?? 5), scrollTop = state(0), viewport = state(options.height && options.height > 0 ? options.height : 0), items = () => {
4
+ const value = typeof source === "function" ? source() : source;
5
+ return Array.isArray(value) ? value : [];
6
+ }, fixed = typeof options.itemHeight === "number" ? Math.max(1, options.itemHeight) : 0, heightAt = (index) => fixed > 0 ? fixed : Math.max(1, options.itemHeight(index));
7
+ let prefix = [0], prefixFor = -1;
8
+ const offsetOf = (index, count) => {
9
+ if (fixed > 0)
10
+ return index * fixed;
11
+ if (prefixFor !== count) {
12
+ prefix = [0];
13
+ for (let i = 0;i < count; i++)
14
+ prefix.push(prefix[i] + heightAt(i));
15
+ prefixFor = count;
16
+ }
17
+ return prefix[Math.min(Math.max(index, 0), count)];
18
+ }, indexAt = (position, count) => {
19
+ if (count === 0)
20
+ return 0;
21
+ if (fixed > 0)
22
+ return Math.min(count - 1, Math.max(0, Math.floor(position / fixed)));
23
+ offsetOf(0, count);
24
+ let low = 0, high = count - 1;
25
+ while (low < high) {
26
+ const mid = low + high + 1 >> 1;
27
+ if (prefix[mid] <= position)
28
+ low = mid;
29
+ else
30
+ high = mid - 1;
31
+ }
32
+ return low;
33
+ }, total = derived(() => offsetOf(items().length, items().length)), start = derived(() => {
34
+ const count = items().length;
35
+ return Math.max(0, indexAt(scrollTop(), count) - overscan);
36
+ }, { equals: (a, b) => a === b }), end = derived(() => {
37
+ const count = items().length;
38
+ if (count === 0)
39
+ return 0;
40
+ const height = viewport() > 0 ? viewport() : 600;
41
+ return Math.min(count, indexAt(scrollTop() + height, count) + 1 + overscan);
42
+ }, { equals: (a, b) => a === b }), list = derived(() => {
43
+ const all = items(), rows = [];
44
+ for (let index = start();index < end(); index++)
45
+ rows.push({ index, data: all[index] });
46
+ return rows;
47
+ }), offsetTop = derived(() => offsetOf(start(), items().length)), measure = (element) => {
48
+ if (!element)
49
+ return;
50
+ if (!options.height && typeof element.clientHeight === "number" && element.clientHeight > 0)
51
+ viewport.set(element.clientHeight);
52
+ if (typeof element.scrollTop === "number")
53
+ scrollTop.set(Math.max(0, element.scrollTop));
54
+ };
55
+ return {
56
+ list,
57
+ start,
58
+ end,
59
+ totalHeight: total,
60
+ offsetTop,
61
+ onScroll: (event) => {
62
+ const target = event && event.target;
63
+ measure(target);
64
+ },
65
+ measure,
66
+ containerStyle: () => `overflow-y:auto;position:relative;${viewport() > 0 ? `height:${viewport()}px;` : ""}`,
67
+ wrapperStyle: () => `height:${total()}px;padding-top:${offsetTop()}px;box-sizing:border-box;`,
68
+ scrollTo: (index, scroller) => {
69
+ const position = offsetOf(Math.min(Math.max(0, index), Math.max(0, items().length - 1)), items().length);
70
+ if (scroller)
71
+ scroller.scrollTop = position;
72
+ scrollTop.set(position);
73
+ },
74
+ scrollTop: () => scrollTop()
75
+ };
76
+ }
package/dist/config.js CHANGED
@@ -8,6 +8,7 @@ import { stxRouterDirective } from "./client/directive.js";
8
8
  import { heatmapDirective } from "./heatmap.js";
9
9
  import { markdownDirectiveHandler } from "./markdown.js";
10
10
  import { imgDirective } from "./media/image/directive.js";
11
+ import { nativePrimitivesDir } from "./native/primitives-dir.js";
11
12
  import { videoDirective } from "./media/video/directive.js";
12
13
  import { pwaDirectives } from "./pwa/directives.js";
13
14
  import { metaDirective, structuredDataDirective } from "./seo.js";
@@ -611,6 +612,8 @@ export async function loadStxConfig(cwd) {
611
612
  loaded._pluginComponentDirs = pluginComponentDirs;
612
613
  loaded._pluginPageDirs = pluginPageDirs;
613
614
  }
615
+ if (loaded.nativePrimitives !== !1)
616
+ loaded._nativePrimitivesFallback = { dir: nativePrimitivesDir(), except: ["Button", "Checkbox", "Switch", "TextInput", "Image", "Video"] };
614
617
  return loaded;
615
618
  })();
616
619
  _cwdConfigCache.set(effectiveCwd, promise);
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-y4mp1rra.js";import"./chunk-x5seqmrv.js";import"./chunk-dvpk4c1y.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-edhxg3rz.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-yb71b2d6.js";import"./chunk-rd33qkfs.js";import"./chunk-t1shvfhm.js";import"./chunk-xgnmgjpv.js";import"./chunk-gwjh981q.js";import"./chunk-yk456jp4.js";import"./chunk-m3z13f59.js";import"./chunk-b0z2n941.js";import"./chunk-r8zhed35.js";import{cu,ha,lh,uh,ya,bo,Xr,ba,wa,dh,ph,va,xa,Sa,ka}from"./chunk-d96xddt9.js";import"./chunk-m6rzsbas.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import"./chunk-rqd6b2nc.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-6jnrpnxb.js";import"./chunk-fz717vpc.js";import"./chunk-1w4a0xya.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import"./chunk-qv2k0qb1.js";import"./chunk-1g5fg1ys.js";import"./chunk-t8cgxk8w.js";import"./chunk-c1b481my.js";import"./chunk-8hanmv49.js";import"./chunk-tqf8a258.js";import"./chunk-ay02q27h.js";import"./chunk-ztbk9yqv.js";import"./chunk-b8hsvzqb.js";import"./chunk-s9m2gfns.js";import"./chunk-7aw9qm74.js";import"./chunk-z6sg0dq3.js";import"./chunk-49w4cbqb.js";import"./chunk-t6d7m4tf.js";import"./chunk-kwy0spcd.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-e1e5xf8z.js";import"./chunk-xcstrdhp.js";import"./chunk-6ch8t3d9.js";import"./chunk-vkpmemb1.js";import"./chunk-dxk5r71v.js";import"./chunk-qv99gqee.js";import"./chunk-knzp4c6m.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{cu as CRAFT_BRIDGE_SCRIPT,bo as CRAFT_COMPONENTS,ba as CRAFT_COMPONENT_RUNTIME,Xr as CRAFT_COMPONENT_STYLES,yo as NATIVE_COMPONENTS,va as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ga as compileToNative,ma as createHotReloadServer,xa as findCraftBinary,ha as generateCraftBridgeScript,V as generateCraftOptimizations,ka as getAvailableFormats,Sa as getAvailableTargets,ph as getCraftComponents,G as getSSRCacheStats,ya as injectCraftBridge,lh as isCraftEnvironment,Y as prerenderForCraft,wa as processCraftComponents,uh as processCraftDirective,dh 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,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};