@stacksjs/stx 0.2.285 → 0.2.287

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 (166) hide show
  1. package/dist/builtins/index.d.ts +4 -3
  2. package/dist/builtins/index.js +11 -11
  3. package/dist/chunk-122tyfre.js +2 -0
  4. package/dist/{chunk-0fgcnv6y.js → chunk-19nfvxfw.js} +1 -1
  5. package/dist/{chunk-f2s94353.js → chunk-1kah92n2.js} +1 -1
  6. package/dist/{chunk-90qr4f9m.js → chunk-1kms3b9d.js} +1 -1
  7. package/dist/{chunk-s2284nbk.js → chunk-1q4y74mh.js} +1 -1
  8. package/dist/{chunk-49kk0s96.js → chunk-248e84r1.js} +1 -1
  9. package/dist/{chunk-zfr4d08r.js → chunk-24ps8kft.js} +1 -1
  10. package/dist/chunk-2et5hxfv.js +2 -0
  11. package/dist/chunk-2r1rd8f0.js +2 -0
  12. package/dist/{chunk-n3qyd366.js → chunk-2tk1zkrz.js} +1 -1
  13. package/dist/{chunk-ysnk7x79.js → chunk-38ejahd9.js} +1 -1
  14. package/dist/chunk-3zv4wz87.js +2 -0
  15. package/dist/chunk-4122k1bh.js +2 -0
  16. package/dist/chunk-45az9zht.js +2 -0
  17. package/dist/{chunk-yq1d9hb3.js → chunk-4qr85f07.js} +1 -1
  18. package/dist/{chunk-9aw94jhm.js → chunk-4ww3znrr.js} +4 -4
  19. package/dist/chunk-5a19dhx5.js +2 -0
  20. package/dist/{chunk-39f40yc4.js → chunk-5kk8gsj2.js} +1 -1
  21. package/dist/{chunk-kzyhvrp8.js → chunk-5w1e3yxs.js} +1 -1
  22. package/dist/chunk-6gdycmxr.js +2 -0
  23. package/dist/{chunk-xqxg3fck.js → chunk-6hmnaza7.js} +10 -10
  24. package/dist/{chunk-zn5jgmqw.js → chunk-71t0yan0.js} +1 -1
  25. package/dist/chunk-74v15e8z.js +2 -0
  26. package/dist/{chunk-3y623mek.js → chunk-7b329e5v.js} +1 -1
  27. package/dist/{chunk-g3fy0tw8.js → chunk-866y9d8b.js} +154 -48
  28. package/dist/chunk-8fwerspy.js +2 -0
  29. package/dist/{chunk-c0an64km.js → chunk-8mjdpr94.js} +1 -1
  30. package/dist/{chunk-q68xmak4.js → chunk-92mj1t26.js} +18 -18
  31. package/dist/{chunk-f8b83xbw.js → chunk-9b22663r.js} +1 -1
  32. package/dist/chunk-9hjdgm4d.js +2 -0
  33. package/dist/{chunk-egez576q.js → chunk-9wr7zcad.js} +2 -2
  34. package/dist/{chunk-dy2y790t.js → chunk-a0nfbmeh.js} +1 -1
  35. package/dist/{chunk-7g88q9ft.js → chunk-acn1b56m.js} +2 -2
  36. package/dist/chunk-awkq3xfx.js +2 -0
  37. package/dist/{chunk-bf8wf3r2.js → chunk-b6ej2fdf.js} +2 -2
  38. package/dist/{chunk-e7jfpyqy.js → chunk-b8rrnqry.js} +1 -1
  39. package/dist/{chunk-a1g1zsbh.js → chunk-bfqfs07m.js} +1 -1
  40. package/dist/{chunk-fjkstnz3.js → chunk-bs6kapy7.js} +1 -1
  41. package/dist/{chunk-qd8ggjdx.js → chunk-btav940g.js} +1 -1
  42. package/dist/{chunk-pbk8jxe2.js → chunk-ccspd3mc.js} +1 -1
  43. package/dist/{chunk-7rxtra1g.js → chunk-csbgwaa5.js} +1 -1
  44. package/dist/chunk-d8t4sjsp.js +2 -0
  45. package/dist/chunk-dap191q2.js +2 -0
  46. package/dist/{chunk-ayrjwkyw.js → chunk-de7fye10.js} +1 -1
  47. package/dist/{chunk-2g9jwgs7.js → chunk-dgrt76d2.js} +1 -1
  48. package/dist/{chunk-9zndrzb3.js → chunk-dhh5q7qt.js} +1 -1
  49. package/dist/chunk-dsffsqnt.js +2 -0
  50. package/dist/{chunk-d0c3v7ax.js → chunk-dtq7y5ym.js} +1 -1
  51. package/dist/{chunk-w95sp0k9.js → chunk-fed3xsp9.js} +2 -2
  52. package/dist/{chunk-bxskmetn.js → chunk-ferav3bw.js} +1 -1
  53. package/dist/{chunk-a63y3aa0.js → chunk-fvhm8psm.js} +1 -1
  54. package/dist/{chunk-bz2gytfs.js → chunk-g4vpzv6b.js} +1 -1
  55. package/dist/{chunk-d34fnbpc.js → chunk-g9csmj0s.js} +1 -1
  56. package/dist/chunk-gtcrpmz1.js +2 -0
  57. package/dist/{chunk-9v5s9ax8.js → chunk-h4xh8cms.js} +1 -1
  58. package/dist/chunk-h8yqsz9m.js +2 -0
  59. package/dist/{chunk-phhzfeh9.js → chunk-hcq5dw7a.js} +1 -1
  60. package/dist/{chunk-d10btecr.js → chunk-hm0xha6c.js} +1 -1
  61. package/dist/chunk-jegt35zh.js +2 -0
  62. package/dist/{chunk-ggrzaenz.js → chunk-k56rjjc0.js} +1 -1
  63. package/dist/{chunk-ada449cq.js → chunk-kdh37tp8.js} +1 -1
  64. package/dist/{chunk-e4hhz9j3.js → chunk-kxzb4et3.js} +1 -1
  65. package/dist/{chunk-3bv8h4r6.js → chunk-mf4n3x1j.js} +1 -1
  66. package/dist/{chunk-5aq35j2e.js → chunk-mkd9kjgb.js} +1 -1
  67. package/dist/chunk-mxfh1nxg.js +2 -0
  68. package/dist/{chunk-snknv47x.js → chunk-nkb3scg6.js} +1 -1
  69. package/dist/{chunk-s67mgegv.js → chunk-nnd4wq8j.js} +1 -1
  70. package/dist/{chunk-1xfqy79h.js → chunk-nsp1cw38.js} +1 -1
  71. package/dist/chunk-p3242nck.js +2 -0
  72. package/dist/chunk-p98kfh94.js +2 -0
  73. package/dist/{chunk-t1k5dpbr.js → chunk-pkaabd8h.js} +1 -1
  74. package/dist/{chunk-t0ghjghe.js → chunk-pzm13sdc.js} +1 -1
  75. package/dist/{chunk-n32gnc22.js → chunk-q4p5k2p3.js} +1 -1
  76. package/dist/{chunk-sskbegsz.js → chunk-qc1f74ek.js} +1 -1
  77. package/dist/{chunk-nvgxjvnb.js → chunk-qpyjak7z.js} +1 -1
  78. package/dist/{chunk-0hdkedwq.js → chunk-qr82je1m.js} +1 -1
  79. package/dist/{chunk-a54n1r1q.js → chunk-qy73j6m4.js} +1 -1
  80. package/dist/{chunk-p396xrew.js → chunk-qzkhpsam.js} +1 -1
  81. package/dist/{chunk-f3hfk78e.js → chunk-r3ayvdz3.js} +1 -1
  82. package/dist/chunk-r7r66978.js +2 -0
  83. package/dist/{chunk-kpy77ys3.js → chunk-rbb7dvja.js} +1 -1
  84. package/dist/{chunk-kdrpx9ft.js → chunk-rj4kajww.js} +1 -1
  85. package/dist/{chunk-areethga.js → chunk-rp4rjjmf.js} +1 -1
  86. package/dist/{chunk-gjemavhx.js → chunk-se0p17c2.js} +1 -1
  87. package/dist/chunk-sj9pmene.js +2 -0
  88. package/dist/{chunk-a2qghr2x.js → chunk-sscwkffs.js} +1 -1
  89. package/dist/chunk-svpqxn2c.js +2 -0
  90. package/dist/chunk-t8y1ggdy.js +2 -0
  91. package/dist/{chunk-y6kw0wb7.js → chunk-tndhnk9e.js} +1 -1
  92. package/dist/{chunk-c6fw33zh.js → chunk-v5e1gxwm.js} +2 -2
  93. package/dist/{chunk-7p9ns60j.js → chunk-vrrax298.js} +1 -1
  94. package/dist/{chunk-zcmtqan3.js → chunk-wrzwgkbx.js} +3 -3
  95. package/dist/{chunk-jn6m8zf7.js → chunk-x650vjcp.js} +1 -1
  96. package/dist/{chunk-mjkfc2v6.js → chunk-xgnc1wy6.js} +1 -1
  97. package/dist/{chunk-52mh63sp.js → chunk-xpp135ad.js} +1 -1
  98. package/dist/chunk-y11cxbxd.js +3757 -0
  99. package/dist/{chunk-cvnh7dma.js → chunk-y98jsjqq.js} +1 -1
  100. package/dist/{chunk-vbdca0k1.js → chunk-ya386h70.js} +1 -1
  101. package/dist/chunk-ydrz60kr.js +2 -0
  102. package/dist/{chunk-0f1kz0x2.js → chunk-ypmqf7tm.js} +1 -1
  103. package/dist/{chunk-cb74rvec.js → chunk-z4jhj5e5.js} +1 -1
  104. package/dist/{chunk-fskfes13.js → chunk-zg75gjns.js} +1 -1
  105. package/dist/{chunk-mb518a4n.js → chunk-zqqx1qaj.js} +1 -1
  106. package/dist/cli.js +14 -14
  107. package/dist/client-script-bundler.js +7 -7
  108. package/dist/client-script.js +27 -7
  109. package/dist/component-client-factories.js +10 -5
  110. package/dist/component-processing.d.ts +13 -0
  111. package/dist/component-processing.js +37 -1
  112. package/dist/component-renderer.js +34 -15
  113. package/dist/conditionals.js +14 -3
  114. package/dist/craft-entry.js +1 -1
  115. package/dist/craft.js +1 -1
  116. package/dist/database.js +1 -1
  117. package/dist/document-shell.d.ts +1 -34
  118. package/dist/document-shell.js +19 -11
  119. package/dist/html-masking.d.ts +65 -9
  120. package/dist/html-masking.js +103 -15
  121. package/dist/misc-directives.d.ts +1 -1
  122. package/dist/misc-directives.js +48 -13
  123. package/dist/process.js +14 -4
  124. package/dist/pwa.js +2 -2
  125. package/dist/reactive-bindings.js +2 -0
  126. package/dist/runtime-globals.d.ts +7 -20
  127. package/dist/runtime-globals.js +28 -3
  128. package/dist/safe-evaluator.d.ts +15 -0
  129. package/dist/safe-evaluator.js +16 -12
  130. package/dist/server-bindings.js +21 -5
  131. package/dist/signal-processing.d.ts +17 -7
  132. package/dist/signal-processing.js +112 -43
  133. package/dist/signals-api.js +5 -2
  134. package/dist/signals.js +153 -47
  135. package/dist/ssg.js +2 -2
  136. package/dist/utils.js +23 -6
  137. package/dist/variable-extractor.js +17 -47
  138. package/dist/visual-testing.js +1 -1
  139. package/package.json +5 -5
  140. package/dist/chunk-1k957wj9.js +0 -2
  141. package/dist/chunk-43r6p08p.js +0 -2
  142. package/dist/chunk-492g6g4g.js +0 -2
  143. package/dist/chunk-60c5bvke.js +0 -2
  144. package/dist/chunk-71nr1avx.js +0 -2
  145. package/dist/chunk-7gbwa2ph.js +0 -2
  146. package/dist/chunk-8ns2r0we.js +0 -2
  147. package/dist/chunk-9rkntp0z.js +0 -3756
  148. package/dist/chunk-b29wbjs5.js +0 -2
  149. package/dist/chunk-ba6tthsm.js +0 -2
  150. package/dist/chunk-f6x9bh8n.js +0 -2
  151. package/dist/chunk-f80wwn5x.js +0 -2
  152. package/dist/chunk-fk6ssg32.js +0 -2
  153. package/dist/chunk-gkmtkzdm.js +0 -2
  154. package/dist/chunk-hzw1ekq3.js +0 -2
  155. package/dist/chunk-j03bare5.js +0 -2
  156. package/dist/chunk-jxjt1szw.js +0 -2
  157. package/dist/chunk-m2harpd3.js +0 -2
  158. package/dist/chunk-qp97dx7x.js +0 -2
  159. package/dist/chunk-stw3ej3d.js +0 -2
  160. package/dist/chunk-v4f08c2r.js +0 -2
  161. package/dist/chunk-vrvehb01.js +0 -2
  162. package/dist/chunk-y1segp76.js +0 -2
  163. package/dist/chunk-y3qng57q.js +0 -2
  164. package/dist/chunk-yqaky7fa.js +0 -2
  165. package/dist/chunk-ytgnzeeb.js +0 -2
  166. package/dist/chunk-z7cwrmgt.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Aj as K,Bj as N,Cj as O,Dj as P,Ej as Q,Fj as T,Jj as U,Kj as V,Lj as W,Mj as Y}from"./chunk-w95sp0k9.js";import{gu as J}from"./chunk-c6fw33zh.js";function $(){let w=q(Z());try{let z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(w);return z=z.replace(/\}(var |let |const |function )/g,"};$1"),z}catch{return w}}function q(w){let E=[],z=0,I="console.log(";while(z<w.length){let F=w.indexOf(I,z);if(F===-1){E.push(w.slice(z));break}E.push(w.slice(z,F));let G=1,x=F+I.length;while(x<w.length&&G>0){let B=w[x];if(B==='"'||B==="'"||B==="`"){let _=B;x++;while(x<w.length&&w[x]!==_){if(w[x]==="\\")x++;x++}x++;continue}if(B==="(")G++;else if(B===")")G--;x++}E.push("0"),z=x}return E.join("")}function Z(){return`
2
+ import{Aj as K,Bj as N,Cj as O,Dj as P,Ej as Q,Fj as T,Jj as U,Kj as V,Lj as W,Mj as Y}from"./chunk-fed3xsp9.js";import{iu as J}from"./chunk-v5e1gxwm.js";function $(){let w=q(Z());try{let z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(w);return z=z.replace(/\}(var |let |const |function )/g,"};$1"),z}catch{return w}}function q(w){let E=[],z=0,I="console.log(";while(z<w.length){let F=w.indexOf(I,z);if(F===-1){E.push(w.slice(z));break}E.push(w.slice(z,F));let G=1,x=F+I.length;while(x<w.length&&G>0){let B=w[x];if(B==='"'||B==="'"||B==="`"){let _=B;x++;while(x<w.length&&w[x]!==_){if(w[x]==="\\")x++;x++}x++;continue}if(B==="(")G++;else if(B===")")G--;x++}E.push("0"),z=x}return E.join("")}function Z(){return`
3
3
  // STX Signals Runtime (Development Build)
4
4
  console.log('[stx] signals runtime loading');
5
5
  // Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
@@ -731,7 +731,16 @@ finally {
731
731
  if (options.immediate !== false) runEffect();
732
732
  const dispose = () => {
733
733
  isDisposed = true;
734
- if (cleanup) cleanup();
734
+ // Idempotent. A removed :for row is disposed on removal, and the page
735
+ // tracker that collected its effects on first render still holds the
736
+ // same disposer, which cleanupContainer calls on SPA navigation (#1954).
737
+ // Clearing cleanup before calling it stops that second call running it
738
+ // twice.
739
+ if (cleanup) {
740
+ const pending = cleanup;
741
+ cleanup = undefined;
742
+ pending();
743
+ }
735
744
  };
736
745
  // Auto-register with active tracker
737
746
  if (activeDisposers) activeDisposers.push(dispose);
@@ -3728,9 +3737,10 @@ else {
3728
3737
  const removeGroup = (group) => {
3729
3738
  const liveNodes = liveGroupNodes(group);
3730
3739
  const liveSet = new Set(liveNodes);
3731
- liveNodes.forEach(e => { disposeSubtreeScopes(e); e.remove(); });
3740
+ liveNodes.forEach(e => { disposeSubtreeEffects(e); disposeSubtreeScopes(e); e.remove(); });
3732
3741
  group.forEach(groupNode => {
3733
3742
  if (liveSet.has(groupNode)) return;
3743
+ disposeSubtreeEffects(groupNode);
3734
3744
  disposeSubtreeScopes(groupNode);
3735
3745
  groupNode.remove();
3736
3746
  });
@@ -3815,13 +3825,15 @@ catch (e) {
3815
3825
  if (emptyTemplate) {
3816
3826
  emptyElement = emptyTemplate.cloneNode(true);
3817
3827
  parent.insertBefore(emptyElement, placeholder);
3818
- processElement(emptyElement);
3828
+ const shownEmpty = emptyElement;
3829
+ shownEmpty.__stx_effect_disposers = trackEffects(function() { processElement(shownEmpty); });
3819
3830
  }
3820
3831
  };
3821
3832
 
3822
3833
  // Helper to hide empty state
3823
3834
  const hideEmpty = () => {
3824
3835
  if (emptyElement) {
3836
+ disposeSubtreeEffects(emptyElement);
3825
3837
  emptyElement.remove();
3826
3838
  emptyElement = null;
3827
3839
  }
@@ -4092,8 +4104,11 @@ catch (e) {
4092
4104
  if (el.nodeType === 1) {
4093
4105
  var itemScope = el.__stx_for_scope || passedScope;
4094
4106
  delete el.__stx_for_scope;
4107
+ // Tracked so removeGroup can dispose the row's effects (#1954). Kept
4108
+ // off __stx_disposers, which marks a hydrated component root here
4109
+ // and in the deferred :if pass.
4095
4110
  if (!el.__stx_disposers && el.tagName !== 'SCRIPT')
4096
- processElement(el, itemScope);
4111
+ el.__stx_effect_disposers = trackEffects(function() { processElement(el, itemScope); });
4097
4112
  el.removeAttribute('x-cloak');
4098
4113
  el.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));
4099
4114
  }
@@ -4116,12 +4131,14 @@ catch (e) {
4116
4131
  const liveNodes = liveGroupNodes(group);
4117
4132
  const transitioned = new Set();
4118
4133
  liveNodes.forEach((el) => {
4134
+ disposeSubtreeEffects(el);
4119
4135
  disposeSubtreeScopes(el);
4120
4136
  if (tgLeave(el, tgName)) transitioned.add(el);
4121
4137
  else el.remove();
4122
4138
  });
4123
4139
  group.forEach((el) => {
4124
4140
  if (transitioned.has(el) || liveNodes.includes(el)) return;
4141
+ disposeSubtreeEffects(el);
4125
4142
  disposeSubtreeScopes(el);
4126
4143
  el.remove();
4127
4144
  });
@@ -4311,7 +4328,16 @@ catch (e2) {
4311
4328
  // still handled by bindFor (item removal) and cleanupContainer (SPA nav).
4312
4329
  if (currentIdx !== -1) {
4313
4330
  chain[currentIdx].el.__stx_chain_active = false;
4314
- chain[currentIdx].nodes.forEach(function (n) { if (n.parentNode) n.parentNode.removeChild(n); });
4331
+ chain[currentIdx].nodes.forEach(function (n) {
4332
+ if (!n.parentNode) return;
4333
+ // Detached nodes are out of reach of a DOM walk, so a row removed
4334
+ // while this branch is hidden could not dispose the effects it was
4335
+ // processed with (#1954). Same registry the single-element :if uses.
4336
+ var host = n.parentNode;
4337
+ if (!host.__stx_detached_if) host.__stx_detached_if = new Set();
4338
+ host.__stx_detached_if.add(n);
4339
+ host.removeChild(n);
4340
+ });
4315
4341
  }
4316
4342
 
4317
4343
  // Insert + process the newly-picked branch.
@@ -4321,7 +4347,11 @@ catch (e2) {
4321
4347
  // Insert this branch's node(s) before the placeholder's next sibling.
4322
4348
  // The anchor is captured once so the nodes stack in source order.
4323
4349
  var anchor = pick.placeholder.nextSibling;
4324
- pick.nodes.forEach(function (n) { pick.placeholder.parentNode.insertBefore(n, anchor); });
4350
+ pick.nodes.forEach(function (n) {
4351
+ var host = pick.placeholder.parentNode;
4352
+ if (host.__stx_detached_if) host.__stx_detached_if.delete(n);
4353
+ host.insertBefore(n, anchor);
4354
+ });
4325
4355
  pick.el.__stx_shown_at = performance.now();
4326
4356
  if (!pick.childrenProcessed) {
4327
4357
  pick.childrenProcessed = true;
@@ -4331,6 +4361,10 @@ catch (e2) {
4331
4361
  // to process projected slot expressions without the loop caller
4332
4362
  // scope. peek() keeps this synchronous pass from subscribing child
4333
4363
  // reads to the current chain effect.
4364
+ // Tracked on the branch element: this runs inside the chain effect,
4365
+ // where no tracker is active, so without a handle the effects of a
4366
+ // branch picked after render survive their row's removal (#1954).
4367
+ pick.el.__stx_chain_disposers = trackEffects(function () {
4334
4368
  peek(function () {
4335
4369
  var childScope = { ...globalHelpers, ...capturedComponentScope, ...(pick.capturedElementScope || {}) };
4336
4370
  // Components compiled inside any branch of an if/else-if/else
@@ -4357,6 +4391,7 @@ catch (e2) {
4357
4391
  n.querySelectorAll('[x-cloak]').forEach(function (c) { c.removeAttribute('x-cloak'); });
4358
4392
  });
4359
4393
  });
4394
+ });
4360
4395
  }
4361
4396
  }
4362
4397
 
@@ -4379,6 +4414,14 @@ catch (e2) {
4379
4414
  }
4380
4415
 
4381
4416
  const placeholder = document.createComment('stx-if');
4417
+ // Marks where this branch's rendered content ENDS (stacksjs/stx#1955).
4418
+ // Hiding used to remove only the cloned nodes, but a structural directive
4419
+ // directly inside the template renders its own output as siblings that are
4420
+ // not among those clones -- a <template :for> at the top level of a
4421
+ // <template :if> left every row on screen after the branch went false.
4422
+ // Only the template branch needs it; the single-element branch owns exactly
4423
+ // the node it was bound to.
4424
+ let endMarker = null;
4382
4425
  let isInserted = true;
4383
4426
 
4384
4427
  // Handle <template> elements specially - clone their content
@@ -4405,6 +4448,13 @@ catch (e2) {
4405
4448
  // multi-root template branch.
4406
4449
  const initialAnchor = placeholder.nextSibling;
4407
4450
  currentNodes.forEach(node => parent.insertBefore(node, initialAnchor));
4451
+ // The end of this branch's range, bound at the same time as the content
4452
+ // it closes (#1955). Needed here too, not only on re-show: the first
4453
+ // hide of a branch that was never toggled removes THIS content, and a
4454
+ // nested :for renders rows that are siblings of these clones rather than
4455
+ // among them.
4456
+ endMarker = document.createComment('stx-if-end');
4457
+ parent.insertBefore(endMarker, initialAnchor);
4408
4458
  el.remove(); // Remove the template element itself
4409
4459
  }
4410
4460
 
@@ -4470,7 +4520,7 @@ catch (e2) {
4470
4520
  hydrateComponentScopes(nodes, childScope);
4471
4521
  nodes.forEach(node => {
4472
4522
  if (!node.__stx_disposers && node.tagName !== 'SCRIPT')
4473
- processElement(node, childScope);
4523
+ node.__stx_effect_disposers = trackEffects(function() { processElement(node, childScope); });
4474
4524
  if (node.nodeType === 1) {
4475
4525
  node.removeAttribute('x-cloak');
4476
4526
  node.querySelectorAll('[x-cloak]').forEach(c => c.removeAttribute('x-cloak'));
@@ -4498,6 +4548,10 @@ catch (e2) {
4498
4548
  currentNodes = Array.from(el.content.childNodes).map(n => n.cloneNode(true));
4499
4549
  const insertionAnchor = placeholder.nextSibling;
4500
4550
  currentNodes.forEach(node => parent.insertBefore(node, insertionAnchor));
4551
+ // Bound AFTER the clones, so hiding can remove whatever a nested
4552
+ // structural directive rendered as their sibling (#1955).
4553
+ if (!endMarker) endMarker = document.createComment('stx-if-end');
4554
+ parent.insertBefore(endMarker, insertionAnchor);
4501
4555
  processTemplateNodes(currentNodes);
4502
4556
  childrenProcessed = true;
4503
4557
  // Stamp insertion time for click propagation guard
@@ -4507,8 +4561,28 @@ catch (e2) {
4507
4561
  else if (!value && isInserted) {
4508
4562
  // Remove all current nodes. Do NOT disposeSubtreeScopes \u2014 :if is a
4509
4563
  // toggle, not a permanent unmount; see the single-element branch
4510
- // below and #1737.
4511
- currentNodes.forEach(node => node.remove());
4564
+ // below and #1737. Effects are disposed, though: these clones are never
4565
+ // reused, and a re-show clones afresh, so leaving them bound only
4566
+ // accumulates work (#1954).
4567
+ //
4568
+ // Everything between the placeholder and the end marker goes, not
4569
+ // just the clones: a nested :for or :if renders siblings of its own
4570
+ // that no clone list contains (#1955).
4571
+ // Only walk the range when THIS binding inserted the content and
4572
+ // left its marker. Without that guard the walk ran to the end of the
4573
+ // parent and took a sibling <template :if> with it -- the initial
4574
+ // server-rendered state has no marker to stop at.
4575
+ if (endMarker && endMarker.parentNode === parent) {
4576
+ var doomed = placeholder.nextSibling;
4577
+ while (doomed && doomed !== endMarker) {
4578
+ var nextDoomed = doomed.nextSibling;
4579
+ disposeSubtreeEffects(doomed);
4580
+ doomed.remove();
4581
+ doomed = nextDoomed;
4582
+ }
4583
+ endMarker.remove();
4584
+ }
4585
+ currentNodes.forEach(node => { disposeSubtreeEffects(node); node.remove(); });
4512
4586
  currentNodes = [];
4513
4587
  isInserted = false;
4514
4588
  childrenProcessed = false;
@@ -4530,6 +4604,7 @@ else {
4530
4604
  console.log('[stx] bindIf INSERTING element for :if=' + expr);
4531
4605
  const insertionAnchor = placeholder.nextSibling;
4532
4606
  currentNodes.forEach(node => parent.insertBefore(node, insertionAnchor));
4607
+ if (parent && parent.__stx_detached_if) currentNodes.forEach(node => parent.__stx_detached_if.delete(node));
4533
4608
  el.__stx_shown_at = performance.now();
4534
4609
  isInserted = true;
4535
4610
  }
@@ -4545,6 +4620,13 @@ else if (!value && isInserted) {
4545
4620
  // and cleanupContainer (SPA navigation). The double-bind guards make
4546
4621
  // re-show idempotent, so toggling doesn't leak.
4547
4622
  currentNodes.forEach(node => node.remove());
4623
+ // Detached nodes are out of reach of a DOM walk, so an ancestor row or
4624
+ // branch removed while this is hidden could not dispose their effects
4625
+ // (#1954). Record them on the parent that keeps the placeholder.
4626
+ if (parent) {
4627
+ if (!parent.__stx_detached_if) parent.__stx_detached_if = new Set();
4628
+ currentNodes.forEach(node => parent.__stx_detached_if.add(node));
4629
+ }
4548
4630
  isInserted = false;
4549
4631
  console.log('[stx] bindIf REMOVED, el.isConnected:', el.isConnected);
4550
4632
  }
@@ -4563,6 +4645,14 @@ else if (!value && isInserted) {
4563
4645
  // in a :if binds a macrotask after the synchronous stx:load audit (#1773).
4564
4646
  el.__stx_if_pending = true;
4565
4647
  setTimeout(function() {
4648
+ // Removed with its row, or hidden again, before this ran. Hydrating
4649
+ // a detached element now creates effects nothing will dispose
4650
+ // (#1954). Leave it unprocessed so the next show schedules the pass.
4651
+ if (!el.isConnected) {
4652
+ childrenProcessed = false;
4653
+ el.__stx_if_pending = false;
4654
+ return;
4655
+ }
4566
4656
  var childScope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
4567
4657
  // A false single-element conditional is detached before the
4568
4658
  // DOMContentLoaded component-scope pass. When it becomes visible,
@@ -4571,8 +4661,11 @@ else if (!value && isInserted) {
4571
4661
  // the same lifecycle as components inserted by template :if.
4572
4662
  var wasTrackedBeforeConditionalHydration = !!el.__stx_disposers;
4573
4663
  hydrateComponentScopes(currentNodes, childScope);
4664
+ // Tracked on its own property so an ancestor row or branch removal
4665
+ // reaches these effects too (#1954). This runs after the enclosing
4666
+ // tracker has closed, so nothing else would collect them.
4574
4667
  if (wasTrackedBeforeConditionalHydration || !el.__stx_disposers)
4575
- processElement(el, childScope);
4668
+ el.__stx_if_disposers = trackEffects(function() { processElement(el, childScope); });
4576
4669
  // Remove x-cloak from the inserted subtree \u2014 the initial
4577
4670
  // cloak removal (after processElement on the root) already
4578
4671
  // ran before this deferred processing, so newly-inserted
@@ -7504,6 +7597,51 @@ catch (e) {
7504
7597
  // indefinitely. Now bindIf, bindFor, and cleanupContainer all funnel
7505
7598
  // through this helper so the cleanup is symmetric regardless of who
7506
7599
  // initiated the removal.
7600
+ // Dispose the EFFECTS bound inside a subtree leaving the page for good: a
7601
+ // removed :for row, a hidden template :if clone, a hidden :for empty
7602
+ // placeholder, or a container on SPA navigation (#1954).
7603
+ // disposeSubtreeScopes only releases scope registrations. Without this, the
7604
+ // effects that bound the subtree stay subscribed to every signal they read
7605
+ // and keep running, so work per update grows with every removal.
7606
+ // Descendants first, then the root, the order cleanupContainer always used.
7607
+ function disposeSubtreeEffects(root) {
7608
+ if (!root) return;
7609
+ var nodes = [];
7610
+ if (root.querySelectorAll) {
7611
+ var all = root.querySelectorAll('*');
7612
+ for (var i = 0; i < all.length; i++) nodes.push(all[i]);
7613
+ }
7614
+ nodes.push(root);
7615
+ var owned = ['__stx_disposers', '__stx_effect_disposers', '__stx_if_disposers', '__stx_chain_disposers'];
7616
+ for (var n = 0; n < nodes.length; n++) {
7617
+ var el = nodes[n];
7618
+ if (typeof el.__stx_hydration_cancel === 'function') {
7619
+ try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }
7620
+ el.__stx_hydration_cancel = null;
7621
+ }
7622
+ if (Array.isArray(el.__stx_destroy)) {
7623
+ var hooks = el.__stx_destroy;
7624
+ el.__stx_destroy = null;
7625
+ hooks.forEach(function(fn) {
7626
+ try { fn(); }
7627
+ catch (e) { console.warn('[stx] destroy hook error:', e); }
7628
+ });
7629
+ }
7630
+ if (el.__stx_detached_if) {
7631
+ var detached = el.__stx_detached_if;
7632
+ el.__stx_detached_if = null;
7633
+ detached.forEach(function(node) { disposeSubtreeEffects(node); });
7634
+ }
7635
+ for (var k = 0; k < owned.length; k++) {
7636
+ var disposeOwned = el[owned[k]];
7637
+ if (typeof disposeOwned === 'function') {
7638
+ el[owned[k]] = null;
7639
+ disposeOwned();
7640
+ }
7641
+ }
7642
+ }
7643
+ }
7644
+
7507
7645
  function disposeSubtreeScopes(root) {
7508
7646
  if (!root || !window.stx || !window.stx._scopes) return;
7509
7647
  // Build the list of nodes to inspect: root + descendants with the
@@ -7792,43 +7930,11 @@ catch (e) {
7792
7930
  if (el.__stx_scope) Object.assign(componentScope, el.__stx_scope);
7793
7931
  });
7794
7932
 
7795
- // 1. Walk all child elements \u2014 fire destroy hooks and dispose effects
7796
- container.querySelectorAll('*').forEach(function(el) {
7797
- // Cancel a still-pending island hydration trigger (#1746) so its
7798
- // observer/timer/listener doesn't fire on this detached element.
7799
- if (typeof el.__stx_hydration_cancel === 'function') {
7800
- try { el.__stx_hydration_cancel(); } catch (e) { /* noop */ }
7801
- el.__stx_hydration_cancel = null;
7802
- }
7803
- if (el.__stx_destroy && Array.isArray(el.__stx_destroy)) {
7804
- el.__stx_destroy.forEach(function(fn) {
7805
- try { fn(); }
7806
- catch (e) { console.warn('[stx] destroy hook error:', e); }
7807
- });
7808
- el.__stx_destroy = null;
7809
- }
7810
- if (el.__stx_disposers && typeof el.__stx_disposers === 'function') {
7811
- el.__stx_disposers();
7812
- el.__stx_disposers = null;
7813
- }
7814
- });
7815
-
7816
- // 2. Check container itself
7817
- if (typeof container.__stx_hydration_cancel === 'function') {
7818
- try { container.__stx_hydration_cancel(); } catch (e) { /* noop */ }
7819
- container.__stx_hydration_cancel = null;
7820
- }
7821
- if (container.__stx_destroy) {
7822
- container.__stx_destroy.forEach(function(fn) {
7823
- try { fn(); }
7824
- catch (e) { console.warn('[stx] destroy hook error:', e); }
7825
- });
7826
- container.__stx_destroy = null;
7827
- }
7828
- if (container.__stx_disposers) {
7829
- container.__stx_disposers();
7830
- container.__stx_disposers = null;
7831
- }
7933
+ // 1-2. Every descendant, then the container: cancel pending island
7934
+ // hydration (#1746), fire destroy hooks, dispose effects. Shared with
7935
+ // :for row removal and template :if hide so all three release the same
7936
+ // trackers, including the row and branch ones added for #1954.
7937
+ disposeSubtreeEffects(container);
7832
7938
  // Clear __stx_scope so _handleStxLoad's processElement guard doesn't skip it
7833
7939
  container.__stx_scope = null;
7834
7940
 
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Vi as a,Wi as b}from"./chunk-nsp1cw38.js";import"./chunk-9n0gvfrg.js";import"./chunk-4ww3znrr.js";import"./chunk-y11cxbxd.js";import"./chunk-92mj1t26.js";import"./chunk-8mjdpr94.js";import"./chunk-pkaabd8h.js";import"./chunk-xpp135ad.js";import"./chunk-wrzwgkbx.js";import"./chunk-5kk8gsj2.js";import"./chunk-38ejahd9.js";import"./chunk-ypmqf7tm.js";import"./chunk-de7fye10.js";import"./chunk-v5e1gxwm.js";import"./chunk-b6ej2fdf.js";import"./chunk-x650vjcp.js";import"./chunk-qc1f74ek.js";export{a as getStoreScript,b as clearStoreCache};
@@ -144,4 +144,4 @@ var N=new Map,Q=new Map;function T(A){if(N.set(A.name,A),A.client)Q.set(A.name,A
144
144
  console.log('[stx] Directive runtime initialized');
145
145
  })();
146
146
  `}function $(A){let B=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return A.replace(B,(C,F,H,L,J)=>{let E=(L?L.split("."):[]).reduce((M,S)=>{return M[S]=!0,M},{});return`data-stx-directive="${F}:${J}" data-stx-directive-arg="${H||""}" data-stx-directive-modifiers='${JSON.stringify(E)}'`})}
147
- export{T as Ks,V as Ls,W as Ms,X as Ns,G as Os,Y as Ps,Z as Qs,_ as Rs,$ as Ss};
147
+ export{T as Ms,V as Ns,W as Os,X as Ps,G as Qs,Y as Rs,Z as Ss,_ as Ts,$ as Us};