@stacksjs/stx 0.2.532 → 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 (298) hide show
  1. package/dist/{chunk-y4qks0bd.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-4gt0r98p.js → chunk-2bvk0qyd.js} +2 -2
  7. package/dist/{chunk-y7ds4qyb.js → chunk-2h4f37kx.js} +2 -2
  8. package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
  9. package/dist/{chunk-xdtz2v5r.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-khwj964t.js → chunk-40hbpz2b.js} +3 -3
  15. package/dist/chunk-4a7v51vh.js +2 -0
  16. package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
  17. package/dist/{chunk-hp1tnxzb.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-0pebjkzx.js → chunk-843y0pfg.js} +4 -4
  33. package/dist/{chunk-4xxhprts.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-t6769zcy.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-gvw8wh29.js → chunk-9p6bt089.js} +3 -3
  40. package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
  41. package/dist/{chunk-rs46hksk.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-664503e6.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-xb0785wp.js → chunk-f3q84h7b.js} +2 -2
  49. package/dist/{chunk-g060jncp.js → chunk-fqfqyn48.js} +4 -4
  50. package/dist/{chunk-g5t10z04.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-rwn3b21z.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-ee4wwr89.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-j8pacd7m.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-m2v04c6v.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-grb3kfya.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-stbsqy7e.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-1945hk44.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/pwa.js +3 -3
  245. package/dist/signals-context-runtime.d.ts +2 -0
  246. package/dist/signals-drawer-runtime.d.ts +2 -0
  247. package/dist/signals-host-runtime.d.ts +9 -0
  248. package/dist/signals-loop-conditional-runtime.d.ts +2 -0
  249. package/dist/signals-manifest-hydration-runtime.d.ts +2 -0
  250. package/dist/signals-optimistic-runtime.d.ts +2 -0
  251. package/dist/signals-overlay-runtime.d.ts +2 -0
  252. package/dist/signals-scope-disposal-runtime.d.ts +2 -0
  253. package/dist/signals-spa-load-control-runtime.d.ts +2 -0
  254. package/dist/signals-storage-runtime.d.ts +2 -0
  255. package/dist/signals.js +141 -9900
  256. package/dist/ssg.js +3 -3
  257. package/package.json +5 -5
  258. package/dist/chunk-0p9pwd61.js +0 -2
  259. package/dist/chunk-0zmv31nc.js +0 -2
  260. package/dist/chunk-28xtazwz.js +0 -2
  261. package/dist/chunk-2936t942.js +0 -2
  262. package/dist/chunk-29qwmthc.js +0 -2
  263. package/dist/chunk-323cxa69.js +0 -2
  264. package/dist/chunk-375zp0vr.js +0 -2
  265. package/dist/chunk-3w49r16x.js +0 -2
  266. package/dist/chunk-8bcvb86w.js +0 -2
  267. package/dist/chunk-8gmb3k1p.js +0 -2
  268. package/dist/chunk-a15yzfc6.js +0 -2
  269. package/dist/chunk-d4155ec5.js +0 -2
  270. package/dist/chunk-dd31q423.js +0 -2
  271. package/dist/chunk-f2q5bckn.js +0 -2
  272. package/dist/chunk-fhx35529.js +0 -2
  273. package/dist/chunk-h1y5q942.js +0 -2
  274. package/dist/chunk-h791c7sb.js +0 -2
  275. package/dist/chunk-h88jcr3k.js +0 -2
  276. package/dist/chunk-heq5c0gd.js +0 -2
  277. package/dist/chunk-j3b24e77.js +0 -2
  278. package/dist/chunk-jpck8nm5.js +0 -2
  279. package/dist/chunk-m4d99a9r.js +0 -2
  280. package/dist/chunk-ng2sdph7.js +0 -2
  281. package/dist/chunk-qs3p7sc6.js +0 -2
  282. package/dist/chunk-rchwwcxy.js +0 -2
  283. package/dist/chunk-rk4mttds.js +0 -2
  284. package/dist/chunk-rma3bv36.js +0 -2
  285. package/dist/chunk-rp5a91ak.js +0 -2
  286. package/dist/chunk-sp5x96rn.js +0 -2
  287. package/dist/chunk-t2mjeezd.js +0 -2
  288. package/dist/chunk-t61j834x.js +0 -2
  289. package/dist/chunk-v2vg5jqq.js +0 -2
  290. package/dist/chunk-vmfw4svt.js +0 -2
  291. package/dist/chunk-w6ecbk3y.js +0 -2
  292. package/dist/chunk-wbv6vjhm.js +0 -2
  293. package/dist/chunk-wfbr3txe.js +0 -2
  294. package/dist/chunk-wpnv0naj.js +0 -2
  295. package/dist/chunk-wwny5dk9.js +0 -2
  296. package/dist/chunk-x55avrcf.js +0 -2
  297. package/dist/chunk-yts2745t.js +0 -2
  298. package/dist/chunk-zah67v44.js +0 -2
@@ -0,0 +1,231 @@
1
+ export const SIGNALS_MOUNT_RUNTIME = ` mountEl: function(selector, setupFn) {
2
+ function doMount() {
3
+ var root = document.querySelector(selector);
4
+ if (!root) { console.warn('[stx] mountEl: element not found:', selector); return; }
5
+
6
+ // Set component context for defineProps/defineEmits (Phase 4)
7
+ var prevProps = window.__STX_CURRENT_PROPS__;
8
+ var prevEl = window.__STX_CURRENT_ELEMENT__;
9
+ var propsAttr = root.getAttribute && root.getAttribute('data-stx-props');
10
+ window.__STX_CURRENT_PROPS__ = root.__stx_props || (propsAttr ? JSON.parse(propsAttr) : {});
11
+ window.__STX_CURRENT_ELEMENT__ = root;
12
+
13
+ var mountStart = mountCallbacks.length;
14
+ var destroyStart = destroyCallbacks.length;
15
+
16
+ // The setup's hooks are collected off the global queues below, so an
17
+ // outer flush's destroy sink must not catch them first (see mount).
18
+ var outerSink = activeDestroySink;
19
+ activeDestroySink = null;
20
+ var scope;
21
+ try { scope = setupFn(); }
22
+ finally { activeDestroySink = outerSink; }
23
+
24
+ // Restore previous context (supports nested components)
25
+ window.__STX_CURRENT_PROPS__ = prevProps;
26
+ window.__STX_CURRENT_ELEMENT__ = prevEl;
27
+
28
+ var localMountHooks = mountCallbacks.splice(mountStart);
29
+ var localDestroyHooks = destroyCallbacks.splice(destroyStart);
30
+
31
+ if (typeof scope === 'object' && scope !== null) {
32
+ scope.$el = root;
33
+ scope.$refs = scope.$refs || {};
34
+ root.__stx_scope = scope;
35
+ }
36
+
37
+ var disposeEffects = trackEffects(function() {
38
+ processElement(root, { ...componentScope, ...(scope || {}) });
39
+ });
40
+ root.__stx_disposers = disposeEffects;
41
+
42
+ root.removeAttribute('x-cloak');
43
+ root.querySelectorAll('[x-cloak]').forEach(function(el) { el.removeAttribute('x-cloak'); });
44
+
45
+ // Through runMountCallbacks, so an onDestroy called inside one of
46
+ // them lands here too rather than on the global queue (#1958).
47
+ runMountCallbacks(localMountHooks, localDestroyHooks);
48
+
49
+ root.__stx_destroy = localDestroyHooks;
50
+ }
51
+
52
+ if (document.readyState === 'loading') {
53
+ mountQueue.push(doMount);
54
+ }
55
+ else {
56
+ doMount();
57
+ }
58
+ },
59
+ mount: function(setupFn) {
60
+ console.log('[mount] called');
61
+ // Capture script reference synchronously (only valid during execution)
62
+ var scriptEl = document.currentScript;
63
+
64
+ function doMount() {
65
+ // Auto-mount scripts are emitted after their component template. Other
66
+ // generated helper scripts can sit between the rendered root and this
67
+ // script, so walk past script/style siblings before selecting the root.
68
+ // Router-injected page scripts are marked data-stx-page and must use the
69
+ // content-container fallback below instead.
70
+ var isSpaPageScript = scriptEl && scriptEl.hasAttribute
71
+ && scriptEl.hasAttribute('data-stx-page')
72
+ && !scriptEl.hasAttribute('data-stx-positioned');
73
+ var root = null;
74
+ if (scriptEl && !isSpaPageScript) {
75
+ var previous = scriptEl.previousElementSibling;
76
+ while (previous && (previous.tagName === 'SCRIPT' || previous.tagName === 'STYLE'))
77
+ previous = previous.previousElementSibling;
78
+
79
+ var next = scriptEl.nextElementSibling;
80
+ while (next && (next.tagName === 'SCRIPT' || next.tagName === 'STYLE'))
81
+ next = next.nextElementSibling;
82
+
83
+ root = previous || next || scriptEl.parentElement;
84
+ }
85
+
86
+ // SPA fallback: during router navigation, script is appended to body>
87
+ // (not inside the content container), so nextElementSibling won't find the page content.
88
+ // Only use fallback when we genuinely couldn't find a suitable root element.
89
+ // Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
90
+ // with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
91
+
92
+ // An x-data root that initScope has not claimed yet is not ours to mount.
93
+ //
94
+ // The element carries its own state expression and the reactive runtime
95
+ // owns it; data-stx-scope is on it from the server, but the id is not
96
+ // in stx._scopes until initScope runs, which on a navigation happens
97
+ // later in the stx:load handler. Mounting it in the meantime binds its
98
+ // whole subtree against whatever scope the mounting script brought.
99
+ //
100
+ // That is what a layout script did after every SPA navigation. Its own
101
+ // re-executed script now lands inside the content container next to the
102
+ // incoming page, so previousElementSibling resolved to the *page's*
103
+ // x-data root; mount() adopted it and ran processElement over it with the
104
+ // sidebar's scope. Every :for template inside was consumed against a
105
+ // scope holding none of the page's data, and bindFor replaces each
106
+ // template with its stx-for anchor on that single pass \u2014 so the markup a
107
+ // retry needed was gone, and the effect had read no signal to re-run on.
108
+ // The list stayed empty for the life of the page while its state sat
109
+ // fully populated beside it. Cold loads never hit it: there the page's
110
+ // own script mounts first, with the right scope.
111
+ //
112
+ // Registered scopes are left alone, so an element the reactive runtime
113
+ // has already initialised keeps whatever behaviour it had.
114
+ function awaitingReactiveInit(el) {
115
+ if (!el || !el.hasAttribute || !el.hasAttribute('data-stx-xdata'))
116
+ return false;
117
+ var id = el.getAttribute('data-stx-scope');
118
+ return !(id && window.stx && window.stx._scopes && window.stx._scopes[id]);
119
+ }
120
+
121
+ var needsFallback = !root || root === document.body
122
+ || (root && root.tagName === 'SCRIPT')
123
+ || awaitingReactiveInit(root);
124
+ if (needsFallback) {
125
+ var routerOpts = window.STX_ROUTER_OPTIONS || window.__stxRouterConfig || {};
126
+ var container = document.querySelector('[data-stx-content]')
127
+ || document.querySelector('[data-stx-router-container]')
128
+ || (routerOpts.container ? document.querySelector(routerOpts.container) : null)
129
+ || document.querySelector('main')
130
+ || document.querySelector('#content');
131
+ if (container) {
132
+ // Use the container itself as root \u2014 process ALL content inside it
133
+ root = container;
134
+ // But if a specific child is already mounted, find first unmounted one instead
135
+ var hasMount = false;
136
+ var children = container.children;
137
+ for (var ci = 0; ci < children.length; ci++) {
138
+ if (children[ci].__stx_scope) { hasMount = true; break; }
139
+ }
140
+ if (hasMount) for (var ci = 0; ci < children.length; ci++) {
141
+ var candidate = children[ci];
142
+ if (candidate.__stx_scope || candidate.tagName === 'SCRIPT') continue;
143
+ if (awaitingReactiveInit(candidate)) continue;
144
+ root = candidate;
145
+ break;
146
+ }
147
+ }
148
+ }
149
+
150
+ // The fallback can still land on one (a container whose only unmounted
151
+ // child is the incoming page). Processing the container instead is safe:
152
+ // processElement skips [data-stx-scope] children, so the reactive
153
+ // runtime keeps its subtree and binds it with the right scope.
154
+ if (awaitingReactiveInit(root)) {
155
+ var reactiveOwnerParent = root.parentElement;
156
+ root = reactiveOwnerParent && reactiveOwnerParent !== document.body ? reactiveOwnerParent : null;
157
+ }
158
+
159
+ if (!root) { console.warn('[stx] mount: no root element found'); return; }
160
+
161
+ // Set component context for defineProps/defineEmits (Phase 4)
162
+ var prevProps = window.__STX_CURRENT_PROPS__;
163
+ var prevEl = window.__STX_CURRENT_ELEMENT__;
164
+ var propsAttr = root.getAttribute && root.getAttribute('data-stx-props');
165
+ window.__STX_CURRENT_PROPS__ = root.__stx_props || (propsAttr ? JSON.parse(propsAttr) : {});
166
+ window.__STX_CURRENT_ELEMENT__ = root;
167
+
168
+ // Track lifecycle hooks registered during setup
169
+ var mountStart = mountCallbacks.length;
170
+ var destroyStart = destroyCallbacks.length;
171
+
172
+ // Run setup function \u2014 returns scope object with declarations
173
+ //
174
+ // With no outer destroy sink (#1958). This can run inside another
175
+ // component's onMount, where runMountCallbacks has pointed onDestroy at
176
+ // THAT component's queue. The setup's own teardown (a composable such
177
+ // as useEventListener registers its removal with onDestroy) must land
178
+ // on the global queue, where the splice below collects it for this
179
+ // root. Otherwise it belonged to the outer component and outlived this
180
+ // root: mounted on a :for row, removing the row left its listener in.
181
+ var outerSink = activeDestroySink;
182
+ activeDestroySink = null;
183
+ var scope;
184
+ try { scope = setupFn(); }
185
+ finally { activeDestroySink = outerSink; }
186
+ console.log('[mount] root:', root.tagName, 'scope keys:', scope ? Object.keys(scope).slice(0, 10) : 'null');
187
+
188
+ // Restore previous context (supports nested components)
189
+ window.__STX_CURRENT_PROPS__ = prevProps;
190
+ window.__STX_CURRENT_ELEMENT__ = prevEl;
191
+
192
+ // Capture mount/destroy hooks added during setup
193
+ var localMountHooks = mountCallbacks.splice(mountStart);
194
+ var localDestroyHooks = destroyCallbacks.splice(destroyStart);
195
+
196
+ // Register scope
197
+ if (typeof scope === 'object' && scope !== null) {
198
+ scope.$el = root;
199
+ scope.$refs = scope.$refs || {};
200
+ root.__stx_scope = scope; // Store isolated scope on element
201
+ Object.assign(componentScope, scope); // Keep for backwards compat
202
+ }
203
+
204
+ // Walk DOM and bind directives, tracking effects for cleanup
205
+ var disposeEffects = trackEffects(function() {
206
+ processElement(root, { ...componentScope, ...(scope || {}) });
207
+ });
208
+ root.__stx_disposers = disposeEffects;
209
+
210
+ // Remove x-cloak after bindings are applied (prevents FOUC)
211
+ root.removeAttribute('x-cloak');
212
+ root.querySelectorAll('[x-cloak]').forEach(function(el) { el.removeAttribute('x-cloak'); });
213
+
214
+ // Fire mount hooks
215
+ // Through runMountCallbacks, so an onDestroy called inside one of
216
+ // them lands here too rather than on the global queue (#1958).
217
+ runMountCallbacks(localMountHooks, localDestroyHooks);
218
+
219
+ // Store cleanup on element for auto-destroy
220
+ root.__stx_destroy = localDestroyHooks;
221
+ }
222
+
223
+ var isRoutedMount = scriptEl && scriptEl.hasAttribute
224
+ && scriptEl.hasAttribute('data-stx-page');
225
+ if (document.readyState === 'loading' || isRoutedMount) {
226
+ mountQueue.push(doMount);
227
+ }
228
+ else {
229
+ doMount();
230
+ }
231
+ }`;
@@ -0,0 +1,2 @@
1
+ /** Client-side navigation, route params, and search params runtime. */
2
+ export declare const SIGNALS_NAVIGATION_RUNTIME = " // ==========================================================================\n // Navigation API\n // ==========================================================================\n\n // Second argument is an options object: { replace, reload, instant }.\n //\n // It used to be a bare forceReload boolean while the shipped declaration\n // promised { replace?: boolean } \u2014 so the one call the type system invited,\n // navigate(url, { replace: true }), took the truthy branch and did a full\n // document load that PUSHED a history entry: the opposite of replace, at the\n // cost of the SPA router, with no error (#1807).\n //\n // A bare boolean is still accepted and still means \"full reload\", because\n // that was the real shipped behaviour and docs and examples contain it.\n function navigate(url, options) {\n var opts = (options && typeof options === 'object') ? options : { reload: !!options };\n var replace = !!opts.replace;\n var reload = !!(opts.reload || opts.forceReload);\n if (!reload && window.stxRouter && typeof window.stxRouter.navigate === 'function') {\n var routed = { replace: replace };\n if (opts.instant) routed.instant = true;\n window.stxRouter.navigate(url, routed);\n return;\n }\n if (replace) window.location.replace(url);\n else window.location.href = url;\n }\n\n // Re-run the CURRENT route against the server and swap the result, keeping\n // every client signal on the page alive.\n //\n // The router grew refresh()/invalidate() for this, but they lived only on\n // window.stxRouter \u2014 nothing in the authoring surface reached them, so a\n // <script client> block still had no way to say \"the mutation changed what\n // the server rendered\". Apps kept calling location.reload() and threw away\n // the state the SPA exists to preserve. See #1850.\n //\n // Degrades to a real reload when the router is absent (a page that never\n // booted it, or a mid-boot call), mirroring how navigate() falls through to\n // window.location.\n function refresh() {\n if (window.stxRouter && typeof window.stxRouter.refresh === 'function')\n return window.stxRouter.refresh();\n window.location.reload();\n return Promise.resolve(false);\n }\n\n // Expire a cached route so the NEXT visit re-fetches it, without navigating\n // now. Pairs with refresh(): refresh the page you are on, invalidate the ones\n // your mutation also changed.\n function invalidateRoute(url) {\n if (window.stxRouter && typeof window.stxRouter.invalidate === 'function')\n window.stxRouter.invalidate(url);\n }\n\n function goBack() { window.history.back(); }\n function goForward() { window.history.forward(); }\n\n // Route params \u2014 set by server injection or parsed from URL on client navigation\n var _routeParams = state({});\n\n // setRouteParams: called by the server-injected script to set initial params\n function setRouteParams(params) {\n var nextParams = params || {};\n _routeParams.set(nextParams);\n window.__stx_rp = nextParams;\n if (window.stx) window.stx._rp = nextParams;\n }\n\n // Listen for SPA navigation to update params\n window.addEventListener('stx:navigate', function(e) {\n // The destination fragment's data-stx-route-params script runs after this\n // event and before stx:load. Reset first so a static route can never inherit\n // params from the dynamic route that preceded it.\n var nextParams = e.detail\n && Object.prototype.hasOwnProperty.call(e.detail, 'params')\n ? e.detail.params\n : {};\n setRouteParams(nextParams);\n });\n\n // Apply any server-injected params (set before runtime loaded)\n if ((window.stx && window.stx._rp) || window.__stx_rp) {\n _routeParams.set(window.stx?._rp || window.__stx_rp);\n }\n\n function useRoute() {\n return {\n get path() { return window.location.pathname; },\n get fullPath() { return window.location.pathname + window.location.search + window.location.hash; },\n get hash() { return window.location.hash; },\n get query() {\n var params = {};\n new URLSearchParams(window.location.search).forEach(function(v, k) { params[k] = v; });\n return params;\n },\n get params() { return _routeParams(); }\n };\n }\n\n // Exported from src/runtime.ts, whose whole stated purpose is client-facing\n // APIs that hide window internals \u2014 but never published on window.stx, so a\n // client script importing them destructured undefined and threw on use. The\n // capability was always here behind useRoute().params; only the documented\n // names were unreachable (stacksjs/stx#1843).\n function useRouteParams() {\n return _routeParams();\n }\n\n function useRouteParam(name, fallback) {\n var value = _routeParams()[name];\n return value === undefined ? fallback : value;\n }\n\n function keptHistoryState(wasPushed) {\n var current = window.history.state;\n if (!current || typeof current !== 'object') return wasPushed ? { __stxPushed: true } : {};\n var copy = {};\n for (var key in current) copy[key] = current[key];\n return copy;\n }\n function useSearchParams() {\n var params = state(Object.fromEntries(new URLSearchParams(window.location.search)));\n var syncFromUrl = function() {\n params.set(Object.fromEntries(new URLSearchParams(window.location.search)));\n };\n window.addEventListener('popstate', syncFromUrl);\n window.addEventListener('stx:navigate', syncFromUrl);\n // Own-property reads only. The backing object comes from Object.fromEntries,\n // so it inherits Object.prototype \u2014 an unguarded params()[key] returned a\n // FUNCTION for 'toString', 'constructor', 'valueOf' and friends, which is\n // neither a string nor undefined and matches no declared return type.\n var own = function(key) {\n var current = params();\n return Object.prototype.hasOwnProperty.call(current, key);\n };\n // pushState by default; replaceState when the caller asks for it (#1825).\n //\n // The canonical reason to delete a param is to CONSUME a one-shot value \u2014\n // an OAuth callback result, ?checkout=success, a flash token \u2014 and the\n // point of consuming it is that it must not survive a Back press. Under\n // pushState the pre-delete URL, the one still carrying the param, becomes\n // the previous entry, so Back replays the callback and whatever consuming\n // it triggered runs again.\n //\n // Default stays pushState so nothing that works today changes, and the\n // option is spelled { replace } to match navigate(), which already takes it.\n var commit = function(url, options) {\n // A plain truthy read of the replace property looks equivalent and is\n // not: it asks whether the value HAS a replace property, and every string\n // has String.prototype.replace \u2014 so delete(key, 'push') would have\n // replaced, the exact opposite of what it reads as. Requiring an object\n // also keeps this identical to the module implementation in\n // composables/use-router.ts; with optional chaining alone the two\n // disagreed on the empty string, which short-circuits in one and hits\n // String.prototype.replace in the other.\n //\n // NB: no backticks anywhere in this block. This runtime is assembled as a\n // template literal, so a backtick in a COMMENT ends the string and the\n // rest of the runtime is parsed as code.\n var replace = !!(options && typeof options === 'object' && options.replace);\n // Pushed entries are marked as the router marks them, and a replaced\n // one stays what it was, so Back knows whether it stays in the app.\n var wasPushed = !!(window.history.state && window.history.state.__stxPushed);\n // A replaced entry keeps the state it had: the router's scroll token,\n // its depth and tab are in there, and an entry stripped of them was\n // restored to the top on Back and miscounted by the tab bar.\n if (replace)\n window.history.replaceState(keptHistoryState(wasPushed), '', url);\n else\n window.history.pushState({ __stxPushed: true }, '', url);\n syncFromUrl();\n };\n return {\n data: params,\n get: function(key) { return own(key) ? params()[key] : undefined; },\n has: own,\n set: function(key, value, options) {\n var url = new URL(window.location.href);\n url.searchParams.set(key, value);\n commit(url, options);\n },\n // delete and has were DECLARED but absent, so the compiler endorsed calls\n // that threw in the browser; setAll and data were present but undeclared\n // (#1806). Deleting writes history the same way set does, for consistency.\n 'delete': function(key, options) {\n var url = new URL(window.location.href);\n url.searchParams['delete'](key);\n commit(url, options);\n },\n setAll: function(obj, options) {\n var url = new URL(window.location.href);\n Object.keys(obj).forEach(function(k) { url.searchParams.set(k, obj[k]); });\n commit(url, options);\n }\n };\n }\n";
@@ -0,0 +1,198 @@
1
+ export const SIGNALS_NAVIGATION_RUNTIME = ` // ==========================================================================
2
+ // Navigation API
3
+ // ==========================================================================
4
+
5
+ // Second argument is an options object: { replace, reload, instant }.
6
+ //
7
+ // It used to be a bare forceReload boolean while the shipped declaration
8
+ // promised { replace?: boolean } \u2014 so the one call the type system invited,
9
+ // navigate(url, { replace: true }), took the truthy branch and did a full
10
+ // document load that PUSHED a history entry: the opposite of replace, at the
11
+ // cost of the SPA router, with no error (#1807).
12
+ //
13
+ // A bare boolean is still accepted and still means "full reload", because
14
+ // that was the real shipped behaviour and docs and examples contain it.
15
+ function navigate(url, options) {
16
+ var opts = (options && typeof options === 'object') ? options : { reload: !!options };
17
+ var replace = !!opts.replace;
18
+ var reload = !!(opts.reload || opts.forceReload);
19
+ if (!reload && window.stxRouter && typeof window.stxRouter.navigate === 'function') {
20
+ var routed = { replace: replace };
21
+ if (opts.instant) routed.instant = true;
22
+ window.stxRouter.navigate(url, routed);
23
+ return;
24
+ }
25
+ if (replace) window.location.replace(url);
26
+ else window.location.href = url;
27
+ }
28
+
29
+ // Re-run the CURRENT route against the server and swap the result, keeping
30
+ // every client signal on the page alive.
31
+ //
32
+ // The router grew refresh()/invalidate() for this, but they lived only on
33
+ // window.stxRouter \u2014 nothing in the authoring surface reached them, so a
34
+ // <script client> block still had no way to say "the mutation changed what
35
+ // the server rendered". Apps kept calling location.reload() and threw away
36
+ // the state the SPA exists to preserve. See #1850.
37
+ //
38
+ // Degrades to a real reload when the router is absent (a page that never
39
+ // booted it, or a mid-boot call), mirroring how navigate() falls through to
40
+ // window.location.
41
+ function refresh() {
42
+ if (window.stxRouter && typeof window.stxRouter.refresh === 'function')
43
+ return window.stxRouter.refresh();
44
+ window.location.reload();
45
+ return Promise.resolve(false);
46
+ }
47
+
48
+ // Expire a cached route so the NEXT visit re-fetches it, without navigating
49
+ // now. Pairs with refresh(): refresh the page you are on, invalidate the ones
50
+ // your mutation also changed.
51
+ function invalidateRoute(url) {
52
+ if (window.stxRouter && typeof window.stxRouter.invalidate === 'function')
53
+ window.stxRouter.invalidate(url);
54
+ }
55
+
56
+ function goBack() { window.history.back(); }
57
+ function goForward() { window.history.forward(); }
58
+
59
+ // Route params \u2014 set by server injection or parsed from URL on client navigation
60
+ var _routeParams = state({});
61
+
62
+ // setRouteParams: called by the server-injected script to set initial params
63
+ function setRouteParams(params) {
64
+ var nextParams = params || {};
65
+ _routeParams.set(nextParams);
66
+ window.__stx_rp = nextParams;
67
+ if (window.stx) window.stx._rp = nextParams;
68
+ }
69
+
70
+ // Listen for SPA navigation to update params
71
+ window.addEventListener('stx:navigate', function(e) {
72
+ // The destination fragment's data-stx-route-params script runs after this
73
+ // event and before stx:load. Reset first so a static route can never inherit
74
+ // params from the dynamic route that preceded it.
75
+ var nextParams = e.detail
76
+ && Object.prototype.hasOwnProperty.call(e.detail, 'params')
77
+ ? e.detail.params
78
+ : {};
79
+ setRouteParams(nextParams);
80
+ });
81
+
82
+ // Apply any server-injected params (set before runtime loaded)
83
+ if ((window.stx && window.stx._rp) || window.__stx_rp) {
84
+ _routeParams.set(window.stx?._rp || window.__stx_rp);
85
+ }
86
+
87
+ function useRoute() {
88
+ return {
89
+ get path() { return window.location.pathname; },
90
+ get fullPath() { return window.location.pathname + window.location.search + window.location.hash; },
91
+ get hash() { return window.location.hash; },
92
+ get query() {
93
+ var params = {};
94
+ new URLSearchParams(window.location.search).forEach(function(v, k) { params[k] = v; });
95
+ return params;
96
+ },
97
+ get params() { return _routeParams(); }
98
+ };
99
+ }
100
+
101
+ // Exported from src/runtime.ts, whose whole stated purpose is client-facing
102
+ // APIs that hide window internals \u2014 but never published on window.stx, so a
103
+ // client script importing them destructured undefined and threw on use. The
104
+ // capability was always here behind useRoute().params; only the documented
105
+ // names were unreachable (stacksjs/stx#1843).
106
+ function useRouteParams() {
107
+ return _routeParams();
108
+ }
109
+
110
+ function useRouteParam(name, fallback) {
111
+ var value = _routeParams()[name];
112
+ return value === undefined ? fallback : value;
113
+ }
114
+
115
+ function keptHistoryState(wasPushed) {
116
+ var current = window.history.state;
117
+ if (!current || typeof current !== 'object') return wasPushed ? { __stxPushed: true } : {};
118
+ var copy = {};
119
+ for (var key in current) copy[key] = current[key];
120
+ return copy;
121
+ }
122
+ function useSearchParams() {
123
+ var params = state(Object.fromEntries(new URLSearchParams(window.location.search)));
124
+ var syncFromUrl = function() {
125
+ params.set(Object.fromEntries(new URLSearchParams(window.location.search)));
126
+ };
127
+ window.addEventListener('popstate', syncFromUrl);
128
+ window.addEventListener('stx:navigate', syncFromUrl);
129
+ // Own-property reads only. The backing object comes from Object.fromEntries,
130
+ // so it inherits Object.prototype \u2014 an unguarded params()[key] returned a
131
+ // FUNCTION for 'toString', 'constructor', 'valueOf' and friends, which is
132
+ // neither a string nor undefined and matches no declared return type.
133
+ var own = function(key) {
134
+ var current = params();
135
+ return Object.prototype.hasOwnProperty.call(current, key);
136
+ };
137
+ // pushState by default; replaceState when the caller asks for it (#1825).
138
+ //
139
+ // The canonical reason to delete a param is to CONSUME a one-shot value \u2014
140
+ // an OAuth callback result, ?checkout=success, a flash token \u2014 and the
141
+ // point of consuming it is that it must not survive a Back press. Under
142
+ // pushState the pre-delete URL, the one still carrying the param, becomes
143
+ // the previous entry, so Back replays the callback and whatever consuming
144
+ // it triggered runs again.
145
+ //
146
+ // Default stays pushState so nothing that works today changes, and the
147
+ // option is spelled { replace } to match navigate(), which already takes it.
148
+ var commit = function(url, options) {
149
+ // A plain truthy read of the replace property looks equivalent and is
150
+ // not: it asks whether the value HAS a replace property, and every string
151
+ // has String.prototype.replace \u2014 so delete(key, 'push') would have
152
+ // replaced, the exact opposite of what it reads as. Requiring an object
153
+ // also keeps this identical to the module implementation in
154
+ // composables/use-router.ts; with optional chaining alone the two
155
+ // disagreed on the empty string, which short-circuits in one and hits
156
+ // String.prototype.replace in the other.
157
+ //
158
+ // NB: no backticks anywhere in this block. This runtime is assembled as a
159
+ // template literal, so a backtick in a COMMENT ends the string and the
160
+ // rest of the runtime is parsed as code.
161
+ var replace = !!(options && typeof options === 'object' && options.replace);
162
+ // Pushed entries are marked as the router marks them, and a replaced
163
+ // one stays what it was, so Back knows whether it stays in the app.
164
+ var wasPushed = !!(window.history.state && window.history.state.__stxPushed);
165
+ // A replaced entry keeps the state it had: the router's scroll token,
166
+ // its depth and tab are in there, and an entry stripped of them was
167
+ // restored to the top on Back and miscounted by the tab bar.
168
+ if (replace)
169
+ window.history.replaceState(keptHistoryState(wasPushed), '', url);
170
+ else
171
+ window.history.pushState({ __stxPushed: true }, '', url);
172
+ syncFromUrl();
173
+ };
174
+ return {
175
+ data: params,
176
+ get: function(key) { return own(key) ? params()[key] : undefined; },
177
+ has: own,
178
+ set: function(key, value, options) {
179
+ var url = new URL(window.location.href);
180
+ url.searchParams.set(key, value);
181
+ commit(url, options);
182
+ },
183
+ // delete and has were DECLARED but absent, so the compiler endorsed calls
184
+ // that threw in the browser; setAll and data were present but undeclared
185
+ // (#1806). Deleting writes history the same way set does, for consistency.
186
+ 'delete': function(key, options) {
187
+ var url = new URL(window.location.href);
188
+ url.searchParams['delete'](key);
189
+ commit(url, options);
190
+ },
191
+ setAll: function(obj, options) {
192
+ var url = new URL(window.location.href);
193
+ Object.keys(obj).forEach(function(k) { url.searchParams.set(k, obj[k]); });
194
+ commit(url, options);
195
+ }
196
+ };
197
+ }
198
+ `;
@@ -0,0 +1,2 @@
1
+ /** Optimistic state overlay used by the generated client runtime. */
2
+ export declare const SIGNALS_OPTIMISTIC_RUNTIME = " // ==========================================================================\n // Optimistic State (useOptimistic) \u2014 stacksjs/stx#1742\n // ==========================================================================\n // Mirrors signals-api.ts useOptimistic. Shows base + pending actions while an\n // async action is in flight; the overlay is discarded the moment base changes\n // (server confirmed). Returns [optimistic, addOptimistic]. addOptimistic\n // returns a settle() to roll back; pass a promise as the 2nd arg to auto-settle.\n function useOptimistic(base, reducer) {\n var readBase = (typeof base === 'function') ? base : function() { return base; };\n var pending = state([]);\n var optimistic = derived(function() {\n return pending().reduce(function(acc, entry) { return reducer(acc, entry.action); }, readBase());\n });\n var primed = false;\n effect(function() {\n readBase(); // track base only\n if (!primed) { primed = true; return; }\n if (peek(function() { return pending().length; })) pending.set([]);\n });\n function addOptimistic(action, settleWhen) {\n var entry = { action: action };\n pending.set(pending().concat([entry]));\n var settle = function() {\n var next = pending().filter(function(e) { return e !== entry; });\n if (next.length !== pending().length) pending.set(next);\n };\n if (settleWhen && typeof settleWhen.then === 'function') {\n Promise.resolve(settleWhen).then(settle, settle);\n }\n return settle;\n }\n return [optimistic, addOptimistic];\n }\n";
@@ -0,0 +1,34 @@
1
+ export const SIGNALS_OPTIMISTIC_RUNTIME = ` // ==========================================================================
2
+ // Optimistic State (useOptimistic) \u2014 stacksjs/stx#1742
3
+ // ==========================================================================
4
+ // Mirrors signals-api.ts useOptimistic. Shows base + pending actions while an
5
+ // async action is in flight; the overlay is discarded the moment base changes
6
+ // (server confirmed). Returns [optimistic, addOptimistic]. addOptimistic
7
+ // returns a settle() to roll back; pass a promise as the 2nd arg to auto-settle.
8
+ function useOptimistic(base, reducer) {
9
+ var readBase = (typeof base === 'function') ? base : function() { return base; };
10
+ var pending = state([]);
11
+ var optimistic = derived(function() {
12
+ return pending().reduce(function(acc, entry) { return reducer(acc, entry.action); }, readBase());
13
+ });
14
+ var primed = false;
15
+ effect(function() {
16
+ readBase(); // track base only
17
+ if (!primed) { primed = true; return; }
18
+ if (peek(function() { return pending().length; })) pending.set([]);
19
+ });
20
+ function addOptimistic(action, settleWhen) {
21
+ var entry = { action: action };
22
+ pending.set(pending().concat([entry]));
23
+ var settle = function() {
24
+ var next = pending().filter(function(e) { return e !== entry; });
25
+ if (next.length !== pending().length) pending.set(next);
26
+ };
27
+ if (settleWhen && typeof settleWhen.then === 'function') {
28
+ Promise.resolve(settleWhen).then(settle, settle);
29
+ }
30
+ return settle;
31
+ }
32
+ return [optimistic, addOptimistic];
33
+ }
34
+ `;
@@ -0,0 +1,2 @@
1
+ /** Shared overlay stack and modal facade used by the generated client runtime. */
2
+ export declare const SIGNALS_OVERLAY_RUNTIME = " // \u2500\u2500 Overlay stack \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n //\n // One stack for everything that takes over the page: stxAlert/stxConfirm,\n // the runtime modal and drawer, @stacksjs/components' Dialog and Drawer, and\n // anything an app draws itself (window.stx.overlays). Each of those used to\n // keep its own listener, its own scroll lock and its own idea of whether it\n // was on top, so with one open over another a single Escape closed both, two\n // Tab traps fought over focus, and the first to close unlocked the page under\n // the one still open (stacksjs/stx#2057; #1998 fixed the same thing for the\n // confirm dialogs alone).\n //\n // Only the topmost overlay answers Escape and owns Tab. The page is locked\n // from the first open to the last close. Focus moves into an overlay when it\n // opens and back to whatever opened it when it closes.\n //\n // A popup - a menu, a listbox, a popover - goes on the same stack as a\n // non-modal layer (modal: false). It takes Escape while it is on top, so one\n // Escape inside a dialog closes the menu and leaves the dialog, but it does\n // not lock the page, trap Tab or move focus: those follow the topmost MODAL\n // layer. Each popup used to listen for Escape on the document itself, and\n // whichever listener was registered first won.\n var _overlays = [];\n var _overlayScroll = null;\n var _overlayInerted = [];\n var _overlayListening = false;\n var _OVERLAY_FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n function _overlayTop() {\n return _overlays.length ? _overlays[_overlays.length - 1] : null;\n }\n\n // The layer that owns Tab and the page lock: the topmost modal one.\n function _overlayTopModal() {\n for (var i = _overlays.length - 1; i >= 0; i--) {\n if (_overlays[i].modal) return _overlays[i];\n }\n return null;\n }\n\n function _overlayIndex(id) {\n for (var i = 0; i < _overlays.length; i++) {\n if (_overlays[i].id === id) return i;\n }\n return -1;\n }\n\n // The panel is asked for, not held: a component's panel may not be rendered\n // yet on the frame it opens, and may be replaced while open.\n function _overlayPanel(entry) {\n var panel = entry && entry.panel;\n try {\n // A selector is looked up each time, like a function: the element it\n // names may be rendered after the overlay opens, or replaced while open.\n if (typeof panel === 'string') panel = document.querySelector(panel);\n else if (typeof panel === 'function') panel = panel();\n }\n catch (_e) { panel = null; }\n return panel || entry.root || null;\n }\n\n function _overlayShown(nodes) {\n return Array.prototype.filter.call(nodes, function(el) {\n return el.offsetParent !== null || el === document.activeElement;\n });\n }\n\n function _overlayFocusable(panel) {\n return _overlayShown(panel.querySelectorAll(_OVERLAY_FOCUSABLE));\n }\n\n // One listener for every overlay, in the bubble phase: a widget inside an\n // overlay that consumes Escape (a menu closing itself) calls preventDefault\n // and the overlay leaves it alone.\n function _overlayKey(e) {\n var top = _overlayTop();\n if (!top) return;\n if (e.key === 'Escape') {\n if (e.defaultPrevented || !top.onEscape) return;\n e.preventDefault();\n top.onEscape();\n return;\n }\n if (e.key !== 'Tab') return;\n var trap = _overlayTopModal();\n if (!trap) return;\n var panel = _overlayPanel(trap);\n if (!panel) return;\n var items = _overlayFocusable(panel);\n if (!items.length) {\n e.preventDefault();\n if (panel.focus) panel.focus();\n return;\n }\n var first = items[0];\n var last = items[items.length - 1];\n var active = document.activeElement;\n if (!panel.contains(active)) {\n e.preventDefault();\n (e.shiftKey ? last : first).focus();\n return;\n }\n if (e.shiftKey && active === first) {\n e.preventDefault();\n last.focus();\n }\n else if (!e.shiftKey && active === last) {\n e.preventDefault();\n first.focus();\n }\n }\n\n // Lock, listen and inert to match the stack after any change.\n function _overlaySync() {\n for (var i = 0; i < _overlayInerted.length; i++) {\n try { _overlayInerted[i].inert = false; }\n catch (_e) { /* element may be gone */ }\n }\n _overlayInerted = [];\n\n var top = _overlayTop();\n var modal = _overlayTopModal();\n if (!modal && _overlayScroll) {\n document.body.style.overflow = _overlayScroll.body;\n document.documentElement.style.overflow = _overlayScroll.html;\n document.body.style.paddingRight = _overlayScroll.pad;\n _overlayScroll = null;\n }\n if (!top) {\n if (_overlayScroll) {\n document.body.style.overflow = _overlayScroll.body;\n document.documentElement.style.overflow = _overlayScroll.html;\n document.body.style.paddingRight = _overlayScroll.pad;\n _overlayScroll = null;\n }\n if (_overlayListening) {\n document.removeEventListener('keydown', _overlayKey);\n _overlayListening = false;\n }\n return;\n }\n\n if (modal && !_overlayScroll) {\n _overlayScroll = {\n body: document.body.style.overflow,\n html: document.documentElement.style.overflow,\n pad: document.body.style.paddingRight\n };\n // The scrollbar's width comes back as padding, so the page does not jump\n // sideways when it disappears.\n var gap = window.innerWidth - document.documentElement.clientWidth;\n if (gap > 0) {\n var existing = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;\n document.body.style.paddingRight = (existing + gap) + 'px';\n }\n document.body.style.overflow = 'hidden';\n document.documentElement.style.overflow = 'hidden';\n }\n if (!_overlayListening) {\n document.addEventListener('keydown', _overlayKey);\n _overlayListening = true;\n }\n\n // An overlay given a z-index stacks by the order it opened in, not by\n // where it sits in the document: one lifted into the body early (a sheet\n // mounted before the sheet it later opens over) drew underneath. Set on\n // every change, so what stays open closes up when one under it closes. A\n // closed overlay keeps its last value, so it slides away above the one\n // it was over.\n for (var z = 0; z < _overlays.length; z++) {\n var layer = _overlays[z];\n if (typeof layer.zIndex === 'number' && layer.root && layer.root.style) layer.root.style.zIndex = String(layer.zIndex + z);\n }\n\n // inert, rather than aria-hidden, takes the page behind out of the tab\n // order and the accessibility tree together (#1998). Only behind an\n // overlay that is a child of the body element - one the runtime appended,\n // or one an app lifted there - or one opened inside such an overlay (a\n // dialog in a sheet's content). An overlay rendered inside the page's own\n // markup would go inert with the page; its Tab trap is what holds it.\n var root = _overlayInertRoot(modal);\n if (root) {\n var kids = document.body.children;\n for (var k = 0; k < kids.length; k++) {\n var kid = kids[k];\n if (kid === root || kid.inert) continue;\n try {\n kid.inert = true;\n _overlayInerted.push(kid);\n }\n catch (_e) { /* inert unsupported; the Tab trap still holds */ }\n }\n }\n }\n\n // The child of the body that keeps the rest of the page inert while this\n // modal layer is on top: its own root when that is in the body, or the\n // root of the open overlay it sits inside. A dialog opened from a sheet's\n // content is not itself in the body, and the page behind the sheet used to\n // come back to the keyboard and screen readers while it was up.\n function _overlayInertRoot(modal) {\n if (!modal) return null;\n var el = modal.root || _overlayPanel(modal);\n while (el && el.parentNode && el.parentNode !== document.body) el = el.parentNode;\n if (!el || el.parentNode !== document.body) return null;\n if (el === modal.root) return el;\n for (var i = 0; i < _overlays.length; i++) {\n if (_overlays[i] !== modal && _overlays[i].root === el) return el;\n }\n return null;\n }\n\n // The next chance to act, whichever comes first: rAF is suspended in a\n // background tab, so a timer races it.\n function _overlaySoon(callback) {\n var done = false;\n var once = function() {\n if (done) return;\n done = true;\n callback();\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(once);\n setTimeout(once, 32);\n }\n\n // Retried, because focus() on an element that is not displayed yet is a\n // silent no-op. Stops once the overlay has closed.\n function _overlayFocusIn(entry, attempts) {\n if (_overlayIndex(entry.id) === -1) return;\n var target = null;\n try { target = typeof entry.initialFocus === 'function' ? entry.initialFocus() : entry.initialFocus; }\n catch (_e) { target = null; }\n var panel = _overlayPanel(entry);\n // An [autofocus] that is not shown (behind a :show, a player in a\n // dialog that is showing something else) cannot take focus: skipped, or\n // focus went nowhere and the panel's first control never got it.\n if (!target && panel) target = _overlayShown(panel.querySelectorAll('[autofocus]'))[0] || _overlayFocusable(panel)[0] || panel;\n if (target && target.focus) target.focus();\n if (target && document.activeElement === target) return;\n if (attempts > 0) _overlaySoon(function() { _overlayFocusIn(entry, attempts - 1); });\n }\n\n var overlays = {\n /**\n * Put an overlay on top. Calling it again for an open id updates its\n * options and nothing else, so it is safe from an effect that re-runs.\n *\n * options: modal (default true; false for a popup, which takes Escape\n * while on top but does not lock, trap or move focus), panel (an element,\n * a selector, or a function returning one; focus stays inside it), root (the overlay's outermost element, if it is not the panel),\n * zIndex (a base: the root's z-index becomes it plus the overlay's place\n * in the stack, so a later overlay draws over an earlier one wherever it\n * sits in the document), onEscape (leave out for one that must be answered), initialFocus\n * (element or function; defaults to [autofocus], then the first focusable,\n * then the panel), opener (where focus goes back; defaults to whatever had\n * it), restoreFocus (default true).\n */\n open: function(id, options) {\n var opts = options || {};\n var at = _overlayIndex(id);\n if (at !== -1) {\n var existing = _overlays[at];\n for (var key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) existing[key] = opts[key];\n }\n _overlaySync();\n return;\n }\n var isModal = opts.modal !== false;\n var entry = {\n id: id,\n modal: isModal,\n panel: opts.panel,\n root: opts.root || null,\n zIndex: typeof opts.zIndex === 'number' ? opts.zIndex : null,\n onEscape: opts.onEscape || null,\n initialFocus: opts.initialFocus || null,\n // A popup hands focus back itself, to its own trigger, and only when\n // focus was inside it; a modal layer always does.\n restoreFocus: opts.restoreFocus !== undefined ? opts.restoreFocus !== false : isModal,\n opener: opts.opener !== undefined ? opts.opener : document.activeElement\n };\n _overlays.push(entry);\n _overlaySync();\n // Synchronously first, so a caller that asserts focus straight after\n // opening sees it; then retried for a panel that is not displayed yet.\n // A popup keeps focus where its own keyboard handling puts it.\n if (isModal || opts.initialFocus) _overlayFocusIn(entry, 10);\n },\n /** Take an overlay off the stack, wherever it is in it. */\n close: function(id) {\n var at = _overlayIndex(id);\n if (at === -1) return;\n var wasTop = at === _overlays.length - 1;\n var entry = _overlays.splice(at, 1)[0];\n _overlaySync();\n // Only the overlay that had the keyboard gives it back. Closing one\n // underneath (its owner went away) must not pull focus out of the top.\n var opener = entry.opener;\n if (wasTop && entry.restoreFocus && opener && opener.isConnected !== false && typeof opener.focus === 'function') {\n try { opener.focus(); }\n catch (_e) { /* gone; nothing to give focus back to */ }\n }\n },\n /** Whether this overlay is the one that has the keyboard. */\n isTop: function(id) {\n var top = _overlayTop();\n return !!top && top.id === id;\n },\n /** Open overlay ids, outermost first. */\n list: function() {\n return _overlays.map(function(o) { return o.id; });\n }\n };\n\n // \u2500\u2500 Modal system \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n var modal = {\n open: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (!el) { console.warn('[stx:modal] Modal \"' + id + '\" not found'); return; }\n el.style.display = 'flex';\n // Force reflow then animate\n void el.offsetHeight;\n el.setAttribute('data-stx-modal-open', '');\n // The lock, Escape for the topmost and the Tab trap come from the\n // overlay stack, shared with every other overlay (stacksjs/stx#2057).\n // Each modal used to bind its own Escape and set body overflow itself,\n // so two open closed together and the first to close unlocked the page.\n overlays.open('stx-modal:' + id, {\n panel: el,\n onEscape: el.getAttribute('data-close-escape') !== 'false' ? function() { modal.close(id); } : null\n });\n if (el.getAttribute('data-close-backdrop') !== 'false') {\n el.onclick = function(e) { if (e.target === el) modal.close(id); };\n }\n },\n close: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (!el) return;\n el.removeAttribute('data-stx-modal-open');\n el.onclick = null;\n overlays.close('stx-modal:' + id);\n setTimeout(function() {\n if (!el.hasAttribute('data-stx-modal-open')) el.style.display = 'none';\n }, 200);\n },\n toggle: function(id) {\n var el = document.querySelector('[data-stx-modal=\"' + id + '\"]');\n if (el && el.hasAttribute('data-stx-modal-open')) modal.close(id);\n else modal.open(id);\n }\n };\n";