@stacksjs/stx 0.2.531 → 0.2.533

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 (299) hide show
  1. package/dist/{chunk-ktmacsqc.js → chunk-01343ehq.js} +2 -2
  2. package/dist/chunk-0e5nasyf.js +2 -0
  3. package/dist/chunk-13zbt9py.js +2 -0
  4. package/dist/{chunk-9w2vmfha.js → chunk-1c4t7ncb.js} +2 -2
  5. package/dist/{chunk-gxfnmjzp.js → chunk-1xgs9gd5.js} +2 -2
  6. package/dist/{chunk-hrrxggpx.js → chunk-2bvk0qyd.js} +63 -12
  7. package/dist/{chunk-cp8f1pv4.js → chunk-2h4f37kx.js} +2 -2
  8. package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
  9. package/dist/{chunk-8n7qsr17.js → chunk-2n4je46m.js} +2 -2
  10. package/dist/{chunk-xcfhy5bj.js → chunk-33bzhsyw.js} +2 -2
  11. package/dist/{chunk-7ybgfk0m.js → chunk-3nk8cnrm.js} +2 -2
  12. package/dist/{chunk-gsxb0ry9.js → chunk-3r1m3tyr.js} +1 -1
  13. package/dist/chunk-3zs8yxy0.js +2 -0
  14. package/dist/{chunk-d3mssbgp.js → chunk-40hbpz2b.js} +5 -5
  15. package/dist/chunk-4a7v51vh.js +2 -0
  16. package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
  17. package/dist/{chunk-srcv6wvm.js → chunk-4pxc3r1p.js} +4 -4
  18. package/dist/chunk-4qts8zk7.js +2 -0
  19. package/dist/{chunk-587ehsxn.js → chunk-4r7s3862.js} +2 -2
  20. package/dist/chunk-4y2av4ev.js +2 -0
  21. package/dist/chunk-5g498pdp.js +2 -0
  22. package/dist/chunk-5gq8m2m7.js +2 -0
  23. package/dist/chunk-5wx323bm.js +2 -0
  24. package/dist/{chunk-d2r8t40y.js → chunk-66s4nhp7.js} +2 -2
  25. package/dist/{chunk-d7x6n702.js → chunk-6dtmants.js} +3 -3
  26. package/dist/chunk-6rcxtdh3.js +2 -0
  27. package/dist/{chunk-st79dqpz.js → chunk-6sd4zdtg.js} +1 -1
  28. package/dist/{chunk-zpdq0kx1.js → chunk-6tnh3cyq.js} +1 -1
  29. package/dist/chunk-6va8wt88.js +2 -0
  30. package/dist/chunk-7v2j9bmc.js +2 -0
  31. package/dist/chunk-7zgtdap7.js +2 -0
  32. package/dist/{chunk-rsy1r1t2.js → chunk-843y0pfg.js} +4 -4
  33. package/dist/{chunk-b0tmg1q1.js → chunk-8chxczpj.js} +3 -3
  34. package/dist/{chunk-b7xdk1g4.js → chunk-8m1y1kyr.js} +5 -5
  35. package/dist/chunk-90kzf313.js +2 -0
  36. package/dist/{chunk-m5c2gts6.js → chunk-93n6yv5x.js} +12 -12
  37. package/dist/chunk-94rg5s6c.js +2 -0
  38. package/dist/chunk-9674w2gm.js +2 -0
  39. package/dist/{chunk-tvssmzc2.js → chunk-9p6bt089.js} +3 -3
  40. package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
  41. package/dist/{chunk-v38kqjew.js → chunk-bxsehntq.js} +1 -1
  42. package/dist/{chunk-vg8thz41.js → chunk-c56qtne1.js} +1 -1
  43. package/dist/chunk-d1jxmhph.js +2 -0
  44. package/dist/{chunk-5tj6expd.js → chunk-d7zterbp.js} +2 -2
  45. package/dist/{chunk-mc5agc81.js → chunk-d871008z.js} +4 -4
  46. package/dist/chunk-dekpf1ry.js +2 -0
  47. package/dist/chunk-epa1c4q4.js +2 -0
  48. package/dist/{chunk-95z7yemm.js → chunk-f3q84h7b.js} +2 -2
  49. package/dist/{chunk-mwte3cbe.js → chunk-fqfqyn48.js} +4 -4
  50. package/dist/{chunk-qwpgggkj.js → chunk-gnx0fzne.js} +60 -60
  51. package/dist/chunk-gsc5t942.js +2 -0
  52. package/dist/chunk-gsm1y1kb.js +2 -0
  53. package/dist/chunk-gxedmh17.js +2 -0
  54. package/dist/{chunk-9xq5yer8.js → chunk-h4crv0by.js} +1 -1
  55. package/dist/{chunk-pr5q4wev.js → chunk-hp8g2q2n.js} +1 -1
  56. package/dist/{chunk-38w14qs7.js → chunk-hvpzy98g.js} +1 -1
  57. package/dist/chunk-j9c0yam7.js +2 -0
  58. package/dist/{chunk-12e4a0ab.js → chunk-jbfad9cc.js} +2 -2
  59. package/dist/chunk-jv3jj612.js +2 -0
  60. package/dist/chunk-jvqas8y2.js +2 -0
  61. package/dist/{chunk-z14e2qyn.js → chunk-k3v13vfr.js} +2 -2
  62. package/dist/chunk-kcs7hyep.js +2 -0
  63. package/dist/chunk-kvp0at16.js +2 -0
  64. package/dist/{chunk-31c1g3rt.js → chunk-m011s2ha.js} +3 -3
  65. package/dist/{chunk-2jk0vceh.js → chunk-m56m95gk.js} +2 -2
  66. package/dist/{chunk-7s14bthq.js → chunk-m5fw8jq1.js} +2 -2
  67. package/dist/chunk-m7jmpech.js +2 -0
  68. package/dist/chunk-m8n9wxba.js +2 -0
  69. package/dist/{chunk-fyxydww2.js → chunk-mjdyyekx.js} +2 -2
  70. package/dist/{chunk-ennxrn5g.js → chunk-nd8v4xgb.js} +5 -5
  71. package/dist/chunk-ngma9vzc.js +2 -0
  72. package/dist/{chunk-rtk6n3vh.js → chunk-ngxqydsg.js} +3 -3
  73. package/dist/{chunk-cxxcy624.js → chunk-nmy4x6dx.js} +4 -4
  74. package/dist/chunk-pz1mjgsp.js +2 -0
  75. package/dist/{chunk-er031j13.js → chunk-qfc912e5.js} +2 -2
  76. package/dist/chunk-qk3ptn6h.js +2 -0
  77. package/dist/{chunk-03wggzg8.js → chunk-qmza4327.js} +2 -2
  78. package/dist/{chunk-w3xs6kb9.js → chunk-qqr4rn9p.js} +4 -4
  79. package/dist/chunk-rx4hz615.js +2 -0
  80. package/dist/chunk-shf0hd05.js +2 -0
  81. package/dist/{chunk-3vvppnws.js → chunk-sqb6gkzf.js} +8374 -8374
  82. package/dist/chunk-t1g1sp2z.js +2 -0
  83. package/dist/{chunk-9f3m5ecs.js → chunk-tgc645pa.js} +45 -45
  84. package/dist/{chunk-2dzd2h15.js → chunk-tkvp3rz0.js} +1 -1
  85. package/dist/{chunk-458etq5a.js → chunk-tqnh98j7.js} +3 -3
  86. package/dist/chunk-tr9bjtqx.js +2 -0
  87. package/dist/{chunk-2y6tzn6d.js → chunk-ty1v368m.js} +2 -2
  88. package/dist/{chunk-fmp8dmt0.js → chunk-v4r8nzf3.js} +1 -1
  89. package/dist/{chunk-p8yh7mgr.js → chunk-v9vvzdag.js} +2 -2
  90. package/dist/{chunk-0wvsfs4s.js → chunk-vb4xxpa6.js} +2 -2
  91. package/dist/chunk-vfnerp7h.js +2 -0
  92. package/dist/{chunk-tkeabv04.js → chunk-vhfwnvmc.js} +5 -5
  93. package/dist/{chunk-15r72kw7.js → chunk-vjdj0ex3.js} +1 -1
  94. package/dist/{chunk-9pztpvvk.js → chunk-wh7xn313.js} +1 -1
  95. package/dist/chunk-wjt46tdp.js +2 -0
  96. package/dist/chunk-wxy9re1a.js +2 -0
  97. package/dist/{chunk-kwvexxey.js → chunk-x607yxrc.js} +3 -3
  98. package/dist/{chunk-3zyvhf4p.js → chunk-xey01yna.js} +1 -1
  99. package/dist/{chunk-7b2hj6nt.js → chunk-xwrbrg1q.js} +1 -1
  100. package/dist/{chunk-9sqjmd9a.js → chunk-y18yvcjb.js} +5 -5
  101. package/dist/chunk-ydtnskdv.js +2 -0
  102. package/dist/{chunk-ky25egh1.js → chunk-yw3cqy43.js} +1 -1
  103. package/dist/{chunk-tyts58ks.js → chunk-z9r3tqyr.js} +1 -1
  104. package/dist/chunk-zeve89kw.js +2 -0
  105. package/dist/cli.js +12 -12
  106. package/dist/client/signals-appearance-runtime.d.ts +2 -0
  107. package/dist/client/signals-appearance-runtime.js +283 -0
  108. package/dist/client/signals-authoring-runtime.d.ts +2 -0
  109. package/dist/client/signals-authoring-runtime.js +187 -0
  110. package/dist/client/signals-binding-utils-runtime.d.ts +2 -0
  111. package/dist/client/signals-binding-utils-runtime.js +130 -0
  112. package/dist/client/signals-bootstrap-runtime.d.ts +4 -0
  113. package/dist/client/signals-bootstrap-runtime.js +24 -0
  114. package/dist/client/signals-class-runtime.d.ts +2 -0
  115. package/dist/client/signals-class-runtime.js +69 -0
  116. package/dist/client/signals-component-api-runtime.d.ts +1 -0
  117. package/dist/client/signals-component-api-runtime.js +57 -0
  118. package/dist/client/signals-component-hydration-runtime.d.ts +2 -0
  119. package/dist/client/signals-component-hydration-runtime.js +147 -0
  120. package/dist/client/signals-component-props-runtime.d.ts +2 -0
  121. package/dist/client/signals-component-props-runtime.js +90 -0
  122. package/dist/client/signals-conditional-chain-runtime.d.ts +2 -0
  123. package/dist/client/signals-conditional-chain-runtime.js +39 -0
  124. package/dist/client/signals-conditional-component-runtime.d.ts +2 -0
  125. package/dist/client/signals-conditional-component-runtime.js +82 -0
  126. package/dist/client/signals-container-cleanup-runtime.d.ts +2 -0
  127. package/dist/client/signals-container-cleanup-runtime.js +42 -0
  128. package/dist/client/signals-context-runtime.d.ts +2 -0
  129. package/dist/client/signals-context-runtime.js +48 -0
  130. package/dist/client/signals-cookie-runtime.d.ts +2 -0
  131. package/dist/client/signals-cookie-runtime.js +56 -0
  132. package/dist/client/signals-devtools-runtime.d.ts +2 -0
  133. package/dist/client/signals-devtools-runtime.js +136 -0
  134. package/dist/client/signals-dialog-runtime.d.ts +2 -0
  135. package/dist/client/signals-dialog-runtime.js +195 -0
  136. package/dist/client/signals-dom-ready-runtime.d.ts +2 -0
  137. package/dist/client/signals-dom-ready-runtime.js +306 -0
  138. package/dist/client/signals-drawer-runtime.d.ts +2 -0
  139. package/dist/client/signals-drawer-runtime.js +39 -0
  140. package/dist/client/signals-effect-runtime.d.ts +2 -0
  141. package/dist/client/signals-effect-runtime.js +157 -0
  142. package/dist/client/signals-event-shorthand-runtime.d.ts +2 -0
  143. package/dist/client/signals-event-shorthand-runtime.js +88 -0
  144. package/dist/client/signals-expression-compiler-runtime.d.ts +2 -0
  145. package/dist/client/signals-expression-compiler-runtime.js +59 -0
  146. package/dist/client/signals-expression-runtime.d.ts +2 -0
  147. package/dist/client/signals-expression-runtime.js +67 -0
  148. package/dist/client/signals-fetch-runtime.d.ts +2 -0
  149. package/dist/client/signals-fetch-runtime.js +144 -0
  150. package/dist/client/signals-fetch-transport-runtime.d.ts +2 -0
  151. package/dist/client/signals-fetch-transport-runtime.js +216 -0
  152. package/dist/client/signals-for-runtime.d.ts +2 -0
  153. package/dist/client/signals-for-runtime.js +647 -0
  154. package/dist/client/signals-globals-runtime.d.ts +2 -0
  155. package/dist/client/signals-globals-runtime.js +66 -0
  156. package/dist/client/signals-handler-runtime.d.ts +2 -0
  157. package/dist/client/signals-handler-runtime.js +80 -0
  158. package/dist/client/signals-head-runtime.d.ts +2 -0
  159. package/dist/client/signals-head-runtime.js +92 -0
  160. package/dist/client/signals-helpers-runtime.d.ts +2 -0
  161. package/dist/client/signals-helpers-runtime.js +137 -0
  162. package/dist/client/signals-host-runtime.d.ts +9 -0
  163. package/dist/client/signals-host-runtime.js +132 -0
  164. package/dist/client/signals-hydration-audit-runtime.d.ts +2 -0
  165. package/dist/client/signals-hydration-audit-runtime.js +209 -0
  166. package/dist/client/signals-hydration-runtime.d.ts +2 -0
  167. package/dist/client/signals-hydration-runtime.js +52 -0
  168. package/dist/client/signals-if-chain-runtime.d.ts +2 -0
  169. package/dist/client/signals-if-chain-runtime.js +283 -0
  170. package/dist/client/signals-if-runtime.d.ts +2 -0
  171. package/dist/client/signals-if-runtime.js +346 -0
  172. package/dist/client/signals-kept-runtime.d.ts +2 -0
  173. package/dist/client/signals-kept-runtime.js +62 -0
  174. package/dist/client/signals-lazy-hydration-runtime.d.ts +2 -0
  175. package/dist/client/signals-lazy-hydration-runtime.js +133 -0
  176. package/dist/client/signals-lifecycle-runtime.d.ts +2 -0
  177. package/dist/client/signals-lifecycle-runtime.js +114 -0
  178. package/dist/client/signals-loop-component-remap-runtime.d.ts +2 -0
  179. package/dist/client/signals-loop-component-remap-runtime.js +66 -0
  180. package/dist/client/signals-loop-conditional-runtime.d.ts +2 -0
  181. package/dist/client/signals-loop-conditional-runtime.js +48 -0
  182. package/dist/client/signals-loop-row-runtime.d.ts +2 -0
  183. package/dist/client/signals-loop-row-runtime.js +41 -0
  184. package/dist/client/signals-manifest-hydration-runtime.d.ts +2 -0
  185. package/dist/client/signals-manifest-hydration-runtime.js +82 -0
  186. package/dist/client/signals-model-runtime.d.ts +2 -0
  187. package/dist/client/signals-model-runtime.js +156 -0
  188. package/dist/client/signals-mount-runtime.d.ts +1 -0
  189. package/dist/client/signals-mount-runtime.js +231 -0
  190. package/dist/client/signals-navigation-runtime.d.ts +2 -0
  191. package/dist/client/signals-navigation-runtime.js +198 -0
  192. package/dist/client/signals-optimistic-runtime.d.ts +2 -0
  193. package/dist/client/signals-optimistic-runtime.js +34 -0
  194. package/dist/client/signals-overlay-runtime.d.ts +2 -0
  195. package/dist/client/signals-overlay-runtime.js +352 -0
  196. package/dist/client/signals-pipe-runtime.d.ts +2 -0
  197. package/dist/client/signals-pipe-runtime.js +177 -0
  198. package/dist/client/signals-process-element-runtime.d.ts +1 -0
  199. package/dist/client/signals-process-element-runtime.js +696 -0
  200. package/dist/client/signals-proxy-runtime.d.ts +2 -0
  201. package/dist/client/signals-proxy-runtime.js +78 -0
  202. package/dist/client/signals-public-api-runtime.d.ts +1 -0
  203. package/dist/client/signals-public-api-runtime.js +120 -0
  204. package/dist/client/signals-query-runtime.d.ts +2 -0
  205. package/dist/client/signals-query-runtime.js +351 -0
  206. package/dist/client/signals-reactive-core-bootstrap-runtime.d.ts +1 -0
  207. package/dist/client/signals-reactive-core-bootstrap-runtime.js +30 -0
  208. package/dist/client/signals-reactive-runtime.d.ts +2 -0
  209. package/dist/client/signals-reactive-runtime.js +67 -0
  210. package/dist/client/signals-ref-runtime.d.ts +2 -0
  211. package/dist/client/signals-ref-runtime.js +33 -0
  212. package/dist/client/signals-scope-disposal-runtime.d.ts +2 -0
  213. package/dist/client/signals-scope-disposal-runtime.js +195 -0
  214. package/dist/client/signals-scope-traversal-runtime.d.ts +2 -0
  215. package/dist/client/signals-scope-traversal-runtime.js +42 -0
  216. package/dist/client/signals-show-runtime.d.ts +2 -0
  217. package/dist/client/signals-show-runtime.js +54 -0
  218. package/dist/client/signals-spa-load-control-runtime.d.ts +2 -0
  219. package/dist/client/signals-spa-load-control-runtime.js +42 -0
  220. package/dist/client/signals-spa-load-runtime.d.ts +2 -0
  221. package/dist/client/signals-spa-load-runtime.js +187 -0
  222. package/dist/client/signals-state-runtime.d.ts +2 -0
  223. package/dist/client/signals-state-runtime.js +125 -0
  224. package/dist/client/signals-storage-runtime.d.ts +2 -0
  225. package/dist/client/signals-storage-runtime.js +79 -0
  226. package/dist/client/signals-store-registry-runtime.d.ts +1 -0
  227. package/dist/client/signals-store-registry-runtime.js +461 -0
  228. package/dist/client/signals-style-runtime.d.ts +2 -0
  229. package/dist/client/signals-style-runtime.js +35 -0
  230. package/dist/client/signals-suspense-runtime.d.ts +2 -0
  231. package/dist/client/signals-suspense-runtime.js +59 -0
  232. package/dist/client/signals-timer-runtime.d.ts +2 -0
  233. package/dist/client/signals-timer-runtime.js +378 -0
  234. package/dist/client/signals-toast-runtime.d.ts +2 -0
  235. package/dist/client/signals-toast-runtime.js +206 -0
  236. package/dist/client/signals-tooltip-runtime.d.ts +2 -0
  237. package/dist/client/signals-tooltip-runtime.js +40 -0
  238. package/dist/client/signals-transition-group-runtime.d.ts +2 -0
  239. package/dist/client/signals-transition-group-runtime.js +92 -0
  240. package/dist/client/signals-websocket-runtime.d.ts +2 -0
  241. package/dist/client/signals-websocket-runtime.js +138 -0
  242. package/dist/craft-entry.js +2 -2
  243. package/dist/craft.js +2 -2
  244. package/dist/native/runtime/native-host.js +4 -1
  245. package/dist/pwa.js +3 -3
  246. package/dist/signals-context-runtime.d.ts +2 -0
  247. package/dist/signals-drawer-runtime.d.ts +2 -0
  248. package/dist/signals-host-runtime.d.ts +9 -0
  249. package/dist/signals-loop-conditional-runtime.d.ts +2 -0
  250. package/dist/signals-manifest-hydration-runtime.d.ts +2 -0
  251. package/dist/signals-optimistic-runtime.d.ts +2 -0
  252. package/dist/signals-overlay-runtime.d.ts +2 -0
  253. package/dist/signals-scope-disposal-runtime.d.ts +2 -0
  254. package/dist/signals-spa-load-control-runtime.d.ts +2 -0
  255. package/dist/signals-storage-runtime.d.ts +2 -0
  256. package/dist/signals.js +141 -9900
  257. package/dist/ssg.js +3 -3
  258. package/package.json +5 -5
  259. package/dist/chunk-0zmv31nc.js +0 -2
  260. package/dist/chunk-1cdanx2v.js +0 -2
  261. package/dist/chunk-1wt5fagh.js +0 -2
  262. package/dist/chunk-2936t942.js +0 -2
  263. package/dist/chunk-3dd5zxbt.js +0 -2
  264. package/dist/chunk-3v91cb0g.js +0 -2
  265. package/dist/chunk-4cyjdghc.js +0 -2
  266. package/dist/chunk-5achv4zv.js +0 -2
  267. package/dist/chunk-5yg6m30k.js +0 -2
  268. package/dist/chunk-6qzjyr8e.js +0 -2
  269. package/dist/chunk-785ckss2.js +0 -2
  270. package/dist/chunk-88kjwkza.js +0 -2
  271. package/dist/chunk-8bcvb86w.js +0 -2
  272. package/dist/chunk-8h1zg44w.js +0 -2
  273. package/dist/chunk-8jtyra19.js +0 -2
  274. package/dist/chunk-bnsz09pg.js +0 -2
  275. package/dist/chunk-c9rwnsk7.js +0 -2
  276. package/dist/chunk-csjax0ej.js +0 -2
  277. package/dist/chunk-dd31q423.js +0 -2
  278. package/dist/chunk-dptjyncv.js +0 -2
  279. package/dist/chunk-et8ejd7k.js +0 -2
  280. package/dist/chunk-g1kyy5h1.js +0 -2
  281. package/dist/chunk-h791c7sb.js +0 -2
  282. package/dist/chunk-h88jcr3k.js +0 -2
  283. package/dist/chunk-hvvbppt4.js +0 -2
  284. package/dist/chunk-j4rb9rxx.js +0 -2
  285. package/dist/chunk-ka7qdsha.js +0 -2
  286. package/dist/chunk-m4d99a9r.js +0 -2
  287. package/dist/chunk-m5gdwq1d.js +0 -2
  288. package/dist/chunk-nz5ekyxn.js +0 -2
  289. package/dist/chunk-rchwwcxy.js +0 -2
  290. package/dist/chunk-s5cb4hkj.js +0 -2
  291. package/dist/chunk-t2mjeezd.js +0 -2
  292. package/dist/chunk-vk18649m.js +0 -2
  293. package/dist/chunk-vmfw4svt.js +0 -2
  294. package/dist/chunk-wbv6vjhm.js +0 -2
  295. package/dist/chunk-wpnv0naj.js +0 -2
  296. package/dist/chunk-wv2crxm6.js +0 -2
  297. package/dist/chunk-xda69f13.js +0 -2
  298. package/dist/chunk-ym182eg0.js +0 -2
  299. package/dist/chunk-zah67v44.js +0 -2
@@ -0,0 +1,647 @@
1
+ export const SIGNALS_FOR_RUNTIME = ` function bindFor(el, passedScope = componentScope, attrName = '@for') {
2
+ if (el.__stx_for_bound) return;
3
+ el.__stx_for_bound = true;
4
+ const expr = el.getAttribute(attrName);
5
+ // Support: "item in list", "item, index in list", "(item, index) in list"
6
+ const match = expr.match(/^\\s*\\(?\\s*(\\w+)(?:\\s*,\\s*(\\w+))?\\s*\\)?\\s+(?:in|of)\\s+(.+)\\s*$/);
7
+
8
+ if (!match) {
9
+ console.warn('[STX] Invalid ' + attrName + ':', expr);
10
+ return;
11
+ }
12
+
13
+ const [, itemName, indexName, listExpr] = match;
14
+ let parent = el.parentNode;
15
+
16
+ // Guard: if element has no parent, it's detached - skip processing
17
+ if (!parent) {
18
+ console.warn('[STX] bindFor: element has no parent, skipping');
19
+ return;
20
+ }
21
+
22
+ const placeholder = stxHost.anchor('stx-for');
23
+ const isTemplate = el.tagName === 'TEMPLATE';
24
+ const componentSetupTemplates = [];
25
+ if (!isTemplate && el.hasAttribute('data-stx-scope')) {
26
+ const componentScopeId = el.getAttribute('data-stx-scope');
27
+ const componentTemplateScopeId = el.getAttribute('data-stx-template-scope') || componentScopeId;
28
+ let setupSibling = el.nextSibling;
29
+ while (setupSibling) {
30
+ const nextSetupSibling = setupSibling.nextSibling;
31
+ if (setupSibling.nodeType === Node.TEXT_NODE && !(setupSibling.textContent || '').trim()) {
32
+ setupSibling = nextSetupSibling;
33
+ continue;
34
+ }
35
+ if (setupSibling.nodeType === Node.COMMENT_NODE) {
36
+ setupSibling = nextSetupSibling;
37
+ continue;
38
+ }
39
+ if (setupSibling.nodeType === Node.ELEMENT_NODE
40
+ && setupSibling.tagName === 'SCRIPT'
41
+ && setupSibling.hasAttribute('data-stx-scoped')
42
+ && ((setupSibling.textContent || '').indexOf(componentScopeId) !== -1
43
+ || (componentTemplateScopeId && (setupSibling.textContent || '').indexOf(componentTemplateScopeId) !== -1))) {
44
+ componentSetupTemplates.push(stxHost.clone(setupSibling));
45
+ stxHost.remove(setupSibling);
46
+ setupSibling = nextSetupSibling;
47
+ continue;
48
+ }
49
+ break;
50
+ }
51
+ }
52
+
53
+ // Check if element also has @if / :if - need to handle together
54
+ const ifExpr = el.getAttribute('@if') || el.getAttribute(':if');
55
+
56
+ // Feature #3: Check for @loading and @empty siblings/content
57
+ const loadingExpr = el.getAttribute('@loading');
58
+ const emptyExpr = el.getAttribute('@empty');
59
+
60
+ // Look for sibling elements with @for-loading or @for-empty
61
+ let loadingTemplate = null;
62
+ let emptyTemplate = null;
63
+
64
+ // Check next siblings for @for-loading and @for-empty
65
+ let sibling = el.nextElementSibling;
66
+ while (sibling) {
67
+ if (sibling.hasAttribute('@for-loading')) {
68
+ loadingTemplate = stxHost.clone(sibling);
69
+ loadingTemplate.removeAttribute('@for-loading');
70
+ stxHost.remove(sibling);
71
+ sibling = el.nextElementSibling;
72
+ continue;
73
+ }
74
+ if (sibling.hasAttribute('@for-empty')) {
75
+ emptyTemplate = stxHost.clone(sibling);
76
+ emptyTemplate.removeAttribute('@for-empty');
77
+ stxHost.remove(sibling);
78
+ sibling = el.nextElementSibling;
79
+ continue;
80
+ }
81
+ break;
82
+ }
83
+
84
+ // Capture the scope NOW before element is removed from DOM
85
+ const capturedScope = findElementScope(el) || findElementScope(parent);
86
+
87
+ stxHost.insert(parent, placeholder, el);
88
+ // Component setup scripts execute while the server-rendered loop source is
89
+ // still in the document. That source becomes a template, not a live
90
+ // instance, so reclaim all registered scopes before removing it. Every
91
+ // rendered iteration receives remapped setup scripts and fresh scopes.
92
+ disposeSubtreeScopes(el);
93
+ stxHost.remove(el);
94
+
95
+ // Capture :key expression BEFORE removing the attribute
96
+ const keyExpr = el.getAttribute(':key') || el.getAttribute('x-bind:key');
97
+
98
+ // For <template> elements, use the content; otherwise clone the element
99
+ let templateContent;
100
+ if (isTemplate) {
101
+ templateContent = el.content;
102
+ deferRowConditionals(templateContent);
103
+ }
104
+ else {
105
+ // Before the source is cloned into the row template, so that clone does
106
+ // not build the conditional elements either.
107
+ deferRowConditionals(el);
108
+ const wrapper = stxHost.clone(el);
109
+ wrapper.removeAttribute('@for');
110
+ wrapper.removeAttribute(':for');
111
+ wrapper.removeAttribute('x-for');
112
+ wrapper.removeAttribute('@loading');
113
+ wrapper.removeAttribute('@empty');
114
+ wrapper.removeAttribute(':key');
115
+ wrapper.removeAttribute('x-bind:key');
116
+ // Also remove @if / :if / x-if - we'll handle it inline
117
+ if (ifExpr) { wrapper.removeAttribute('@if'); wrapper.removeAttribute(':if'); wrapper.removeAttribute('x-if'); }
118
+ templateContent = wrapper;
119
+ }
120
+
121
+ let currentElements = [];
122
+ // One entry per list item, each holding EVERY node that item rendered.
123
+ // currentElements stays flat for transition snapshots, but the keyed
124
+ // diff below must pair a key with all of its nodes: a template row
125
+ // routinely yields several (an element plus its surrounding text nodes),
126
+ // and indexing a flat list by key position then paired the wrong node
127
+ // with each key, leaving the list rotated after an update.
128
+ let currentGroups = [];
129
+ let currentKeys = [];
130
+ let loadingElement = null;
131
+ let emptyElement = null;
132
+
133
+ // A <template :for> can contain another structural directive. That
134
+ // nested directive replaces its source node with a placeholder and owns
135
+ // additional live siblings around that placeholder. Track an explicit
136
+ // boundary for every template iteration so keyed reuse moves the complete
137
+ // live range, including nodes created by nested :for / :if bindings.
138
+ // Moving only the original cloned nodes pulled static siblings past the
139
+ // nested range on the next outer update (header, then rows became rows,
140
+ // then header).
141
+ const liveGroupNodes = (group) => {
142
+ if (!isTemplate || !group || group.length < 2) return group || [];
143
+ const start = group[0];
144
+ const end = group[group.length - 1];
145
+ if (!start || !end || start.parentNode !== parent || end.parentNode !== parent)
146
+ return group.filter(groupNode => groupNode && groupNode.parentNode === parent);
147
+
148
+ const nodes = [];
149
+ let currentNode = start;
150
+ while (currentNode) {
151
+ nodes.push(currentNode);
152
+ if (currentNode === end) break;
153
+ currentNode = currentNode.nextSibling;
154
+ }
155
+ return nodes;
156
+ };
157
+
158
+ const removeGroup = (group) => {
159
+ const liveNodes = liveGroupNodes(group);
160
+ const liveSet = new Set(liveNodes);
161
+ liveNodes.forEach(e => { disposeSubtreeEffects(e); disposeSubtreeScopes(e); stxHost.remove(e); });
162
+ group.forEach(groupNode => {
163
+ if (liveSet.has(groupNode)) return;
164
+ disposeSubtreeEffects(groupNode);
165
+ disposeSubtreeScopes(groupNode);
166
+ stxHost.remove(groupNode);
167
+ });
168
+ };
169
+
170
+ const clearRenderedItems = () => {
171
+ currentGroups.forEach(removeGroup);
172
+ currentElements = [];
173
+ currentGroups = [];
174
+ currentKeys = [];
175
+ };
176
+
177
+ // Helper to evaluate with captured scope (auto-unwraps signals)
178
+ // NOTE: This eagerly reads ALL signals in scope \u2014 use evalLazy inside effects
179
+ // to avoid over-broad dependency tracking.
180
+ const evalExpr = (expression, extraScope = {}) => {
181
+ try {
182
+ // Skip placeholder expressions like __TITLE__ (build-time placeholders)
183
+ if (/^__[A-Z_]+__$/.test(expression.trim())) {
184
+ return expression;
185
+ }
186
+ // Use passedScope instead of componentScope to preserve context through nested processing
187
+ const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };
188
+ const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
189
+ if (typeof prop !== 'string') return false;
190
+ return expressionCallsSignal(expression, prop)
191
+ || expressionUsesSignalApi(expression, prop);
192
+ });
193
+ const fn = __stxCompileScoped(scope, [], 'return ' + expression);
194
+ return fn(...__stxArgs(fn, unwrapScope));
195
+ }
196
+ catch (e) {
197
+ if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
198
+ return '';
199
+ }
200
+ };
201
+
202
+ // Lazy eval: uses with() so only variables ACTUALLY ACCESSED by the expression
203
+ // trigger signal reads. This prevents unrelated signals (like modalOpen) from
204
+ // being tracked as dependencies when we only care about the list signal.
205
+ const evalLazy = (expression, extraScope = {}) => {
206
+ try {
207
+ if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;
208
+ const scope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}), ...extraScope };
209
+ const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
210
+ if (typeof prop !== 'string') return false;
211
+ return expressionCallsSignal(expression, prop)
212
+ || expressionUsesSignalApi(expression, prop);
213
+ });
214
+ // Compiled over the names the expression mentions (__stxCompileScoped),
215
+ // so only those are read and register as dependencies. It used with()
216
+ // over the proxy, which JavaScriptCore resolves through proxy traps on
217
+ // every identifier - 36x slower than V8 for a list of message rows.
218
+ const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
219
+ return fn(...__stxArgs(fn, unwrapScope));
220
+ } catch (e) {
221
+ if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
222
+ return '';
223
+ }
224
+ };
225
+
226
+ // Helper to show loading state
227
+ const showLoading = () => {
228
+ hideLoading();
229
+ hideEmpty();
230
+ if (loadingTemplate) {
231
+ loadingElement = stxHost.clone(loadingTemplate);
232
+ stxHost.insert(parent, loadingElement, placeholder);
233
+ }
234
+ };
235
+
236
+ // Helper to hide loading state
237
+ const hideLoading = () => {
238
+ if (loadingElement) {
239
+ stxHost.remove(loadingElement);
240
+ loadingElement = null;
241
+ }
242
+ };
243
+
244
+ // Helper to show empty state
245
+ const showEmpty = () => {
246
+ hideLoading();
247
+ hideEmpty();
248
+ if (emptyTemplate) {
249
+ emptyElement = stxHost.clone(emptyTemplate);
250
+ stxHost.insert(parent, emptyElement, placeholder);
251
+ const shownEmpty = emptyElement;
252
+ shownEmpty.__stx_effect_disposers = trackEffects(function() { processElement(shownEmpty); });
253
+ }
254
+ };
255
+
256
+ // Helper to hide empty state
257
+ const hideEmpty = () => {
258
+ if (emptyElement) {
259
+ // A string @empty renders a text node, which has no subtree to dispose.
260
+ if (emptyElement.nodeType === 1) disposeSubtreeEffects(emptyElement);
261
+ stxHost.remove(emptyElement);
262
+ emptyElement = null;
263
+ }
264
+ };
265
+
266
+ // Helper: create DOM element(s) for a single list item.
267
+ // The item is wrapped in a signal so bindings track it reactively. The pair
268
+ // rides on the returned group, so reuse always reaches the signals the
269
+ // bindings of THAT row actually read. A Map from key to signals could not:
270
+ // two rows sharing a key overwrote each other in it, and the row that
271
+ // reused the surviving entry was then bound to a signal nothing updated.
272
+ const createItemElements = (item, index, key) => {
273
+ const itemSignal = state(item);
274
+ itemSignal._isStxLoopItem = true;
275
+ const indexSignal = state(index);
276
+
277
+ const itemScope = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };
278
+ itemScope[itemName] = itemSignal;
279
+ if (indexName) itemScope[indexName] = indexSignal;
280
+
281
+ const elements = [];
282
+ if (isTemplate) {
283
+ elements.push(stxHost.anchor('stx-for-item-start'));
284
+ Array.from(templateContent.childNodes).forEach(node => {
285
+ const clone = stxHost.clone(node);
286
+ if (clone.nodeType === 1) {
287
+ // Structural directives need a live parent. Keep the iteration
288
+ // scope on the clone until the keyed diff inserts it, then bind.
289
+ clone.__stx_for_scope = itemScope;
290
+ markLoopRow(clone, itemName, itemSignal);
291
+ }
292
+ elements.push(clone);
293
+ });
294
+ elements.push(stxHost.anchor('stx-for-item-end'));
295
+ } else {
296
+ const clone = stxHost.clone(templateContent);
297
+ clone.__stx_for_scope = itemScope;
298
+ markLoopRow(clone, itemName, itemSignal);
299
+ elements.push(clone);
300
+ componentSetupTemplates.forEach(function(setupTemplate) {
301
+ elements.push(stxHost.clone(setupTemplate));
302
+ });
303
+ }
304
+ remapForComponentScopes(elements);
305
+ elements.__stx_signals = { item: itemSignal, index: indexSignal };
306
+ return elements;
307
+ };
308
+
309
+ // Helper: compute key for an item
310
+ const getItemKey = (item, index) => {
311
+ if (!keyExpr) return String(index);
312
+ try {
313
+ const scope = { [itemName]: item };
314
+ if (indexName) scope[indexName] = index;
315
+ const fn = __stxCompile([itemName, indexName || '_idx'], 'return ' + keyExpr);
316
+ return String(fn(item, index));
317
+ } catch (e) {
318
+ return String(index);
319
+ }
320
+ };
321
+
322
+ effect(() => {
323
+ parent = followPlaceholder(placeholder, parent);
324
+ // Use evalLazy for the list expression \u2014 only tracks the list signal,
325
+ // not every signal in the component scope. This prevents unrelated
326
+ // signals (modalOpen, menuOpen, etc.) from triggering a full rebuild.
327
+ // Check loading state if @loading attribute provided (Feature #3)
328
+ if (loadingExpr) {
329
+ const isLoading = evalLazy(loadingExpr);
330
+ if (isLoading) {
331
+ // Dispose scopes registered by items before they leave the DOM (#1727).
332
+ clearRenderedItems();
333
+ showLoading();
334
+ return;
335
+ }
336
+ }
337
+
338
+ hideLoading();
339
+
340
+ // Evaluate list with LAZY tracking \u2014 only the list signal is tracked
341
+ let list = evalLazy(listExpr);
342
+
343
+ // Tolerate parens-on-signal in the list expression.
344
+ // :for="x in store.signal" --> works (bare-ref, auto-unwrapped)
345
+ // :for="x in store.signal()" --> silently iterated zero, because
346
+ // the proxy unwraps the signal to
347
+ // the array on access, then the
348
+ // trailing call throws TypeError
349
+ // which evalLazy's catch swallows.
350
+ // Retry without the trailing parens so both forms succeed.
351
+ //
352
+ // This runtime is emitted as a TEMPLATE LITERAL, so every backslash here
353
+ // must be DOUBLED to survive into the shipped string. A regex literal
354
+ // crosses only that one layer (doubled escapes ship intact). A
355
+ // new RegExp('...') string crosses a SECOND layer too \u2014 the browser's
356
+ // string-literal parse strips the escapes again \u2014 collapsing the pattern
357
+ // to a bare-letter match that never fires (stacksjs/stx#1748). So use a
358
+ // regex literal, not new RegExp(string), for patterns with backslashes.
359
+ var trailingParens = /\\(\\s*\\)\\s*$/;
360
+ if (!Array.isArray(list) && trailingParens.test(listExpr)) {
361
+ list = evalLazy(listExpr.replace(trailingParens, ''));
362
+ }
363
+ // Second-chance fallback: if the retry returned a signal /
364
+ // derived function (the proxy failed to auto-unwrap, which
365
+ // can happen when the resolved owning object lacks the
366
+ // _isStxStore marker \u2014 e.g. ad-hoc objects, locally-imported
367
+ // shapes), call it manually. Defensive: cheap when it would
368
+ // already be an array, useful when the proxy missed.
369
+ if (!Array.isArray(list) && typeof list === 'function' && (list._isSignal || list._isDerived)) {
370
+ try { list = list(); } catch { /* swallow - the warning below surfaces it */ }
371
+ }
372
+
373
+ // If there's an @if condition, check it
374
+ if (ifExpr) {
375
+ const ifValue = evalLazy(ifExpr);
376
+ if (!ifValue) {
377
+ // Dispose scopes registered by items before they leave the DOM (#1727).
378
+ clearRenderedItems();
379
+ hideEmpty();
380
+ return;
381
+ }
382
+ }
383
+
384
+ if (!Array.isArray(list)) {
385
+ // Silent return here used to mask a class of real misuse:
386
+ // most often a signal call that threw mid-expression, or a
387
+ // :for over undefined from a typo. One warn line saves a lot
388
+ // of "list rendered no rows despite the data being there"
389
+ // debugging cycles.
390
+ //
391
+ // Diagnostic: dump the scope identifiers so the caller can see
392
+ // whether the expression's root identifier was in scope at all
393
+ // (and if so, what type it was and whether it carried the
394
+ // _isStxStore marker). Only fires on the warn path, which is
395
+ // rare, so the extra Object.keys / spread cost is negligible.
396
+ var diagScope;
397
+ var rootName = '?';
398
+ var rootInScope = true;
399
+ var rootVal;
400
+ try {
401
+ var diagMerged = { ...globalHelpers, ...passedScope, ...(capturedScope || {}) };
402
+ var firstIdent = listExpr.match(/^[A-Za-z_$][\\w$]*/);
403
+ rootName = firstIdent ? firstIdent[0] : '?';
404
+ rootInScope = Object.prototype.hasOwnProperty.call(diagMerged, rootName);
405
+ rootVal = rootInScope ? diagMerged[rootName] : '<NOT-IN-SCOPE>';
406
+ var rootKeys = (rootVal && typeof rootVal === 'object')
407
+ ? Object.keys(rootVal).slice(0, 8).join(',')
408
+ : '-';
409
+ diagScope = '[root=' + rootName + ' inScope=' + rootInScope + ' type=' + (typeof rootVal) + ' isStxStore=' + !!(rootVal && rootVal._isStxStore) + ' keys=' + rootKeys + ']';
410
+ }
411
+ catch (_e) { diagScope = '[diag-error]'; rootInScope = true; }
412
+
413
+ /*
414
+ * Name the cause rather than guessing at it (stacksjs/stx#2051).
415
+ *
416
+ * This used to end with "If this is a signal call, try the bare
417
+ * reference" every single time. In the most common failure the
418
+ * identifier is not a signal at all -- it is a bare name the client
419
+ * scope has never heard of, usually a declaration from a
420
+ * script-server block, which :for cannot see because it is expanded
421
+ * on the client. The hint sent people to the wrong layer: one app
422
+ * read it, concluded the signals-and-:for pattern was unreliable, and
423
+ * was rebuilt on hand-written getElementById wiring.
424
+ *
425
+ * The scope dump already answered the question -- inScope=false was
426
+ * right there, ahead of the guess -- so lead with it, and keep the
427
+ * signal advice for when the value really is a signal, which is the
428
+ * one case where it applies.
429
+ */
430
+ var advice;
431
+ if (!rootInScope) {
432
+ advice = 'Nothing named ' + rootName + ' is in the client scope. A script-server declaration is not available here: :for is expanded on the client. '
433
+ + 'Either wrap it in state() inside a script-client block, or iterate it with the server-side @foreach(' + rootName + ' as item).';
434
+ }
435
+ else if (typeof rootVal === 'function' && (rootVal._isSignal || rootVal._isDerived)) {
436
+ advice = rootName + ' is a signal, so try the bare reference: ' + rootName + ' instead of ' + rootName + '().';
437
+ }
438
+ else {
439
+ advice = rootName + ' resolved to a ' + (typeof rootVal) + ', not an array.';
440
+ }
441
+ console.warn('[STX] :for expected an array; got ' + (list === '' ? 'empty/error' : typeof list) + ' for expression "' + listExpr + '". ' + diagScope + ' ' + advice);
442
+ return;
443
+ }
444
+
445
+ // Check empty state (Feature #3)
446
+ if (list.length === 0) {
447
+ // Dispose scopes registered by items before they leave the DOM (#1727).
448
+ clearRenderedItems();
449
+ if (emptyExpr) {
450
+ const emptyContent = evalLazy(emptyExpr);
451
+ // Held in the same slot the @for-empty template uses, so hideEmpty
452
+ // takes it away when the list fills and a second empty render
453
+ // replaces it instead of stacking another one. It used to go into
454
+ // currentElements, which teardown does not walk -- it walks
455
+ // currentGroups -- so the text stayed in the document forever: an
456
+ // empty list that filled read "Nothing herea".
457
+ hideEmpty();
458
+ if (emptyContent && typeof emptyContent === 'string') {
459
+ emptyElement = document.createTextNode(emptyContent);
460
+ stxHost.insert(parent, emptyElement, placeholder);
461
+ }
462
+ } else if (emptyTemplate) {
463
+ showEmpty();
464
+ }
465
+ return;
466
+ }
467
+
468
+ hideEmpty();
469
+
470
+ // \u2500\u2500 <TransitionGroup> detection (#1742) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
471
+ // Active only when the list's parent is a [data-stx-transition-group]
472
+ // AND it has already rendered once (no enter animation on first mount).
473
+ // tgReady gates ALL animation work, so plain :for lists are untouched.
474
+ var tgIsGroup = !!(parent && parent.hasAttribute && parent.hasAttribute('data-stx-transition-group'));
475
+ var tgName = tgIsGroup ? (parent.getAttribute('data-stx-transition-group') || 'v') : null;
476
+ var tgReady = tgIsGroup && !!parent.__stx_tg_init;
477
+ var tgFirst = tgReady ? tgSnapshot(currentElements) : null;
478
+
479
+ // \u2500\u2500 Key-based diffing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
480
+ // Build new key list
481
+ const newKeys = list.map((item, i) => getItemKey(item, i));
482
+
483
+ // Build old key \u2192 element(s) map
484
+ const oldKeyMap = new Map();
485
+ for (let i = 0; i < currentKeys.length; i++) {
486
+ const k = currentKeys[i];
487
+ if (!oldKeyMap.has(k)) oldKeyMap.set(k, []);
488
+ oldKeyMap.get(k).push(currentGroups[i] || []);
489
+ }
490
+
491
+ // Build new element list, reusing existing DOM nodes by key
492
+ const newElements = [];
493
+ const newGroups = [];
494
+ // Keys seen in THIS pass, for the duplicate warning only. Reuse is decided
495
+ // by whether a group under the key is still unconsumed, not by whether the
496
+ // key has been seen: gating it on the key made every duplicate occurrence
497
+ // build a NEW group, while the removal pass below skipped the key as used
498
+ // and left the old ones in the document. The list grew by one row on every
499
+ // update, without bound, and the first duplicate stayed bound to a signal
500
+ // the reconciliation never wrote to.
501
+ const seenKeys = new Set();
502
+ let warnedDuplicateKey = false;
503
+
504
+ // Minimal-move reconciliation.
505
+ //
506
+ // Every reused row used to be round-tripped through a DocumentFragment,
507
+ // and appendChild into a fragment DETACHES the node from the document
508
+ // first. Removing a focused node blurs it and resets activeElement, so a
509
+ // list could not contain a field the user was typing in: any write to the
510
+ // backing array kicked them out of it, losing caret, selection and undo
511
+ // history. It happened for every row unconditionally, including rows that
512
+ // had not moved, and unkeyed loops took the same path because getItemKey
513
+ // falls back to the index (#1882).
514
+ //
515
+ // The cursor walks the existing rendering in order. A node already at the
516
+ // cursor is left ENTIRELY alone \u2014 an unchanged list now performs zero DOM
517
+ // operations \u2014 and a node that genuinely has to move is moved with
518
+ // insertBefore, which relocates it without a detach/reattach cycle.
519
+ let cursor = null;
520
+ for (let ci = 0; ci < currentGroups.length && !cursor; ci++) {
521
+ const seed = liveGroupNodes(currentGroups[ci] || []);
522
+ if (seed.length) cursor = seed[0];
523
+ }
524
+
525
+ for (let i = 0; i < list.length; i++) {
526
+ const key = newKeys[i];
527
+ const existing = oldKeyMap.get(key);
528
+
529
+ if (seenKeys.has(key) && !warnedDuplicateKey) {
530
+ warnedDuplicateKey = true;
531
+ console.warn('[STX] :for has more than one item with the key ' + key + '. Rows are matched in order, so give each item a key of its own.');
532
+ }
533
+ seenKeys.add(key);
534
+
535
+ if (existing && existing.length > 0) {
536
+ // Reuse this item's nodes \u2014 move the whole group into position, in
537
+ // order, so a multi-node row stays contiguous and correctly ordered.
538
+ // A structural directive may intentionally have detached one of the
539
+ // group's nodes. Its own placeholder owns reinsertion, so keyed reuse
540
+ // must not resurrect that hidden node.
541
+ const group = existing.shift();
542
+ const liveNodes = liveGroupNodes(group);
543
+ for (let li = 0; li < liveNodes.length; li++) {
544
+ const groupNode = liveNodes[li];
545
+ if (groupNode === cursor) {
546
+ // Already exactly where it belongs. Touching it here is what
547
+ // used to blur it, so the correct action is to do nothing.
548
+ cursor = cursor.nextSibling;
549
+ }
550
+ else {
551
+ // Moves without detaching. The cursor does not advance: this node
552
+ // is now behind it, and the cursor still marks the next position
553
+ // to fill.
554
+ stxHost.insert(parent, groupNode, cursor || placeholder);
555
+ }
556
+ }
557
+ newElements.push(...group);
558
+ newGroups.push(group);
559
+ // Update the item signal so bindings re-evaluate with new data.
560
+ // This is the fix for #1669 \u2014 without this, reused elements show
561
+ // stale data because the old bindings captured the old item via closure.
562
+ const signals = group.__stx_signals;
563
+ if (signals) {
564
+ signals.item.set(list[i]);
565
+ signals.index.set(i);
566
+ }
567
+ } else {
568
+ // New item \u2014 create DOM elements with a fresh item signal
569
+ const elements = createItemElements(list[i], i, key);
570
+ elements.forEach(el => {
571
+ // Before the cursor, not before the placeholder: a new row inserted
572
+ // in the MIDDLE of the list must land at its own position, without
573
+ // forcing every row after it to be moved to get back in order.
574
+ stxHost.insert(parent, el, cursor || placeholder);
575
+ if (tgReady && el.isConnected) tgEnter(el, tgName);
576
+ });
577
+ hydrateComponentScopes(elements, elements.find(function(node) {
578
+ return node && node.__stx_for_scope;
579
+ })?.__stx_for_scope || passedScope);
580
+ elements.forEach(el => {
581
+ if (el.nodeType === 1) {
582
+ var itemScope = el.__stx_for_scope || passedScope;
583
+ delete el.__stx_for_scope;
584
+ // Tracked so removeGroup can dispose the row's effects (#1954). Kept
585
+ // off __stx_disposers, which marks a hydrated component root here
586
+ // and in the deferred :if pass.
587
+ if (!el.__stx_disposers && el.tagName !== 'SCRIPT')
588
+ el.__stx_effect_disposers = trackEffects(function() { processElement(el, itemScope); });
589
+ el.removeAttribute('x-cloak');
590
+ el.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));
591
+ }
592
+ });
593
+ newElements.push(...elements);
594
+ newGroups.push(elements);
595
+ }
596
+ }
597
+
598
+ // Remove old elements whose keys are no longer in the list.
599
+ // Dispose any scopes registered inside removed items before the
600
+ // remove() call (#1727).
601
+ // Whatever is still in here was not consumed above -- either the key left
602
+ // the list, or the list now has fewer rows under that key than it did.
603
+ // The test used to be "this key was never used", which could not see the
604
+ // second case, so a duplicate key's leftover rows stayed on screen.
605
+ for (const groups of oldKeyMap.values()) {
606
+ if (groups.length > 0) {
607
+ // In a transition group, run the leave animation and let it remove the
608
+ // node; otherwise remove immediately. Scopes are disposed up-front
609
+ // either way (their destroy hooks shouldn't wait on a CSS transition).
610
+ groups.forEach((group) => {
611
+ if (tgReady) {
612
+ const liveNodes = liveGroupNodes(group);
613
+ const transitioned = new Set();
614
+ liveNodes.forEach((el) => {
615
+ disposeSubtreeEffects(el);
616
+ disposeSubtreeScopes(el);
617
+ if (tgLeave(el, tgName)) transitioned.add(el);
618
+ else stxHost.remove(el);
619
+ });
620
+ group.forEach((el) => {
621
+ if (transitioned.has(el) || liveNodes.includes(el)) return;
622
+ disposeSubtreeEffects(el);
623
+ disposeSubtreeScopes(el);
624
+ stxHost.remove(el);
625
+ });
626
+ }
627
+ else {
628
+ removeGroup(group);
629
+ }
630
+ });
631
+ // The row's signals went with its group, so there is no key-indexed
632
+ // map left to prune here.
633
+ }
634
+ }
635
+
636
+ currentElements = newElements;
637
+ currentGroups = newGroups;
638
+ currentKeys = newKeys;
639
+
640
+ // \u2500\u2500 <TransitionGroup> play (#1742) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
641
+ // FLIP the surviving elements from their snapshotted positions, then mark
642
+ // the group rendered so the next update animates.
643
+ if (tgReady && tgFirst) tgFlip(newElements, tgFirst, tgName);
644
+ if (tgIsGroup) parent.__stx_tg_init = true;
645
+ });
646
+ }
647
+ `;
@@ -0,0 +1,2 @@
1
+ /** Browser-global aliases used by the generated client runtime. */
2
+ export declare const SIGNALS_GLOBALS_RUNTIME = " // Also expose globally for convenience\n window.state = state;\n window.derived = derived;\n window.effect = effect;\n window.batch = batch;\n window.onMount = onMount;\n window.onDestroy = onDestroy;\n window.useFetch = useFetch;\n window.clearServerData = clearServerData;\n window.useRef = useRef;\n window.navigate = navigate;\n window.goBack = goBack;\n window.goForward = goForward;\n window.useRoute = useRoute;\n window.useSearchParams = useSearchParams;\n window.useQuery = useQuery;\n window.useMutation = useMutation;\n window.provide = provide;\n window.$computed = $computed;\n window.$watch = $watch;\n window.useDebounce = useDebounce;\n window.useDebouncedValue = useDebouncedValue;\n window.useThrottle = useThrottle;\n window.useInterval = useInterval;\n window.useTimeout = useTimeout;\n window.useToggle = useToggle;\n window.useCounter = useCounter;\n window.useClickOutside = useClickOutside;\n window.useFocus = useFocus;\n window.nextTick = nextTick;\n window.useAsync = useAsync;\n window.useLocalStorage = useLocalStorage;\n // Paired with the line above. Both are in STX_RUNTIME_GLOBALS, so a\n // <script client> block gets either via the setup destructure \u2014 but code\n // that reads the bare window global directly (a plain <script>, or a\n // bundled module that wasn't rewritten) found useLocalStorage defined and\n // useSessionStorage undefined.\n window.useSessionStorage = useSessionStorage;\n window.keptState = keptState;\n window.forgetKeptState = forgetKeptState;\n window.setKeptScope = setKeptScope;\n window.flushKeptState = flushKeptState;\n window.cachedQuery = cachedQuery;\n window.useEventListener = useEventListener;\n window.useWebSocket = useWebSocket;\n window.useColorMode = useColorMode;\n window.useDark = useDark;\n window.useHead = useHead;\n window.useSeoMeta = useSeoMeta;\n window.toast = toast;\n window.modal = modal;\n window.drawer = drawer;\n window.stxAlert = stxAlert;\n window.stxConfirm = stxConfirm;\n window.defineStore = window.stx.defineStore;\n window.useStore = window.stx.useStore;\n window.ref = state;\n window.reactive = reactive;\n window.computed = derived;\n window.watch = $watch;\n window.watchEffect = function(fn) { return effect(fn); };\n\n // Note: SPA Router and View Transitions CSS are provided by the canonical\n // router script (packages/router/src/client.ts) which is injected alongside\n // the signals runtime or via the @stxRouter directive.\n";