@stacksjs/stx 0.2.531 → 0.2.533

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/dist/{chunk-ktmacsqc.js → chunk-01343ehq.js} +2 -2
  2. package/dist/chunk-0e5nasyf.js +2 -0
  3. package/dist/chunk-13zbt9py.js +2 -0
  4. package/dist/{chunk-9w2vmfha.js → chunk-1c4t7ncb.js} +2 -2
  5. package/dist/{chunk-gxfnmjzp.js → chunk-1xgs9gd5.js} +2 -2
  6. package/dist/{chunk-hrrxggpx.js → chunk-2bvk0qyd.js} +63 -12
  7. package/dist/{chunk-cp8f1pv4.js → chunk-2h4f37kx.js} +2 -2
  8. package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
  9. package/dist/{chunk-8n7qsr17.js → chunk-2n4je46m.js} +2 -2
  10. package/dist/{chunk-xcfhy5bj.js → chunk-33bzhsyw.js} +2 -2
  11. package/dist/{chunk-7ybgfk0m.js → chunk-3nk8cnrm.js} +2 -2
  12. package/dist/{chunk-gsxb0ry9.js → chunk-3r1m3tyr.js} +1 -1
  13. package/dist/chunk-3zs8yxy0.js +2 -0
  14. package/dist/{chunk-d3mssbgp.js → chunk-40hbpz2b.js} +5 -5
  15. package/dist/chunk-4a7v51vh.js +2 -0
  16. package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
  17. package/dist/{chunk-srcv6wvm.js → chunk-4pxc3r1p.js} +4 -4
  18. package/dist/chunk-4qts8zk7.js +2 -0
  19. package/dist/{chunk-587ehsxn.js → chunk-4r7s3862.js} +2 -2
  20. package/dist/chunk-4y2av4ev.js +2 -0
  21. package/dist/chunk-5g498pdp.js +2 -0
  22. package/dist/chunk-5gq8m2m7.js +2 -0
  23. package/dist/chunk-5wx323bm.js +2 -0
  24. package/dist/{chunk-d2r8t40y.js → chunk-66s4nhp7.js} +2 -2
  25. package/dist/{chunk-d7x6n702.js → chunk-6dtmants.js} +3 -3
  26. package/dist/chunk-6rcxtdh3.js +2 -0
  27. package/dist/{chunk-st79dqpz.js → chunk-6sd4zdtg.js} +1 -1
  28. package/dist/{chunk-zpdq0kx1.js → chunk-6tnh3cyq.js} +1 -1
  29. package/dist/chunk-6va8wt88.js +2 -0
  30. package/dist/chunk-7v2j9bmc.js +2 -0
  31. package/dist/chunk-7zgtdap7.js +2 -0
  32. package/dist/{chunk-rsy1r1t2.js → chunk-843y0pfg.js} +4 -4
  33. package/dist/{chunk-b0tmg1q1.js → chunk-8chxczpj.js} +3 -3
  34. package/dist/{chunk-b7xdk1g4.js → chunk-8m1y1kyr.js} +5 -5
  35. package/dist/chunk-90kzf313.js +2 -0
  36. package/dist/{chunk-m5c2gts6.js → chunk-93n6yv5x.js} +12 -12
  37. package/dist/chunk-94rg5s6c.js +2 -0
  38. package/dist/chunk-9674w2gm.js +2 -0
  39. package/dist/{chunk-tvssmzc2.js → chunk-9p6bt089.js} +3 -3
  40. package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
  41. package/dist/{chunk-v38kqjew.js → chunk-bxsehntq.js} +1 -1
  42. package/dist/{chunk-vg8thz41.js → chunk-c56qtne1.js} +1 -1
  43. package/dist/chunk-d1jxmhph.js +2 -0
  44. package/dist/{chunk-5tj6expd.js → chunk-d7zterbp.js} +2 -2
  45. package/dist/{chunk-mc5agc81.js → chunk-d871008z.js} +4 -4
  46. package/dist/chunk-dekpf1ry.js +2 -0
  47. package/dist/chunk-epa1c4q4.js +2 -0
  48. package/dist/{chunk-95z7yemm.js → chunk-f3q84h7b.js} +2 -2
  49. package/dist/{chunk-mwte3cbe.js → chunk-fqfqyn48.js} +4 -4
  50. package/dist/{chunk-qwpgggkj.js → chunk-gnx0fzne.js} +60 -60
  51. package/dist/chunk-gsc5t942.js +2 -0
  52. package/dist/chunk-gsm1y1kb.js +2 -0
  53. package/dist/chunk-gxedmh17.js +2 -0
  54. package/dist/{chunk-9xq5yer8.js → chunk-h4crv0by.js} +1 -1
  55. package/dist/{chunk-pr5q4wev.js → chunk-hp8g2q2n.js} +1 -1
  56. package/dist/{chunk-38w14qs7.js → chunk-hvpzy98g.js} +1 -1
  57. package/dist/chunk-j9c0yam7.js +2 -0
  58. package/dist/{chunk-12e4a0ab.js → chunk-jbfad9cc.js} +2 -2
  59. package/dist/chunk-jv3jj612.js +2 -0
  60. package/dist/chunk-jvqas8y2.js +2 -0
  61. package/dist/{chunk-z14e2qyn.js → chunk-k3v13vfr.js} +2 -2
  62. package/dist/chunk-kcs7hyep.js +2 -0
  63. package/dist/chunk-kvp0at16.js +2 -0
  64. package/dist/{chunk-31c1g3rt.js → chunk-m011s2ha.js} +3 -3
  65. package/dist/{chunk-2jk0vceh.js → chunk-m56m95gk.js} +2 -2
  66. package/dist/{chunk-7s14bthq.js → chunk-m5fw8jq1.js} +2 -2
  67. package/dist/chunk-m7jmpech.js +2 -0
  68. package/dist/chunk-m8n9wxba.js +2 -0
  69. package/dist/{chunk-fyxydww2.js → chunk-mjdyyekx.js} +2 -2
  70. package/dist/{chunk-ennxrn5g.js → chunk-nd8v4xgb.js} +5 -5
  71. package/dist/chunk-ngma9vzc.js +2 -0
  72. package/dist/{chunk-rtk6n3vh.js → chunk-ngxqydsg.js} +3 -3
  73. package/dist/{chunk-cxxcy624.js → chunk-nmy4x6dx.js} +4 -4
  74. package/dist/chunk-pz1mjgsp.js +2 -0
  75. package/dist/{chunk-er031j13.js → chunk-qfc912e5.js} +2 -2
  76. package/dist/chunk-qk3ptn6h.js +2 -0
  77. package/dist/{chunk-03wggzg8.js → chunk-qmza4327.js} +2 -2
  78. package/dist/{chunk-w3xs6kb9.js → chunk-qqr4rn9p.js} +4 -4
  79. package/dist/chunk-rx4hz615.js +2 -0
  80. package/dist/chunk-shf0hd05.js +2 -0
  81. package/dist/{chunk-3vvppnws.js → chunk-sqb6gkzf.js} +8374 -8374
  82. package/dist/chunk-t1g1sp2z.js +2 -0
  83. package/dist/{chunk-9f3m5ecs.js → chunk-tgc645pa.js} +45 -45
  84. package/dist/{chunk-2dzd2h15.js → chunk-tkvp3rz0.js} +1 -1
  85. package/dist/{chunk-458etq5a.js → chunk-tqnh98j7.js} +3 -3
  86. package/dist/chunk-tr9bjtqx.js +2 -0
  87. package/dist/{chunk-2y6tzn6d.js → chunk-ty1v368m.js} +2 -2
  88. package/dist/{chunk-fmp8dmt0.js → chunk-v4r8nzf3.js} +1 -1
  89. package/dist/{chunk-p8yh7mgr.js → chunk-v9vvzdag.js} +2 -2
  90. package/dist/{chunk-0wvsfs4s.js → chunk-vb4xxpa6.js} +2 -2
  91. package/dist/chunk-vfnerp7h.js +2 -0
  92. package/dist/{chunk-tkeabv04.js → chunk-vhfwnvmc.js} +5 -5
  93. package/dist/{chunk-15r72kw7.js → chunk-vjdj0ex3.js} +1 -1
  94. package/dist/{chunk-9pztpvvk.js → chunk-wh7xn313.js} +1 -1
  95. package/dist/chunk-wjt46tdp.js +2 -0
  96. package/dist/chunk-wxy9re1a.js +2 -0
  97. package/dist/{chunk-kwvexxey.js → chunk-x607yxrc.js} +3 -3
  98. package/dist/{chunk-3zyvhf4p.js → chunk-xey01yna.js} +1 -1
  99. package/dist/{chunk-7b2hj6nt.js → chunk-xwrbrg1q.js} +1 -1
  100. package/dist/{chunk-9sqjmd9a.js → chunk-y18yvcjb.js} +5 -5
  101. package/dist/chunk-ydtnskdv.js +2 -0
  102. package/dist/{chunk-ky25egh1.js → chunk-yw3cqy43.js} +1 -1
  103. package/dist/{chunk-tyts58ks.js → chunk-z9r3tqyr.js} +1 -1
  104. package/dist/chunk-zeve89kw.js +2 -0
  105. package/dist/cli.js +12 -12
  106. package/dist/client/signals-appearance-runtime.d.ts +2 -0
  107. package/dist/client/signals-appearance-runtime.js +283 -0
  108. package/dist/client/signals-authoring-runtime.d.ts +2 -0
  109. package/dist/client/signals-authoring-runtime.js +187 -0
  110. package/dist/client/signals-binding-utils-runtime.d.ts +2 -0
  111. package/dist/client/signals-binding-utils-runtime.js +130 -0
  112. package/dist/client/signals-bootstrap-runtime.d.ts +4 -0
  113. package/dist/client/signals-bootstrap-runtime.js +24 -0
  114. package/dist/client/signals-class-runtime.d.ts +2 -0
  115. package/dist/client/signals-class-runtime.js +69 -0
  116. package/dist/client/signals-component-api-runtime.d.ts +1 -0
  117. package/dist/client/signals-component-api-runtime.js +57 -0
  118. package/dist/client/signals-component-hydration-runtime.d.ts +2 -0
  119. package/dist/client/signals-component-hydration-runtime.js +147 -0
  120. package/dist/client/signals-component-props-runtime.d.ts +2 -0
  121. package/dist/client/signals-component-props-runtime.js +90 -0
  122. package/dist/client/signals-conditional-chain-runtime.d.ts +2 -0
  123. package/dist/client/signals-conditional-chain-runtime.js +39 -0
  124. package/dist/client/signals-conditional-component-runtime.d.ts +2 -0
  125. package/dist/client/signals-conditional-component-runtime.js +82 -0
  126. package/dist/client/signals-container-cleanup-runtime.d.ts +2 -0
  127. package/dist/client/signals-container-cleanup-runtime.js +42 -0
  128. package/dist/client/signals-context-runtime.d.ts +2 -0
  129. package/dist/client/signals-context-runtime.js +48 -0
  130. package/dist/client/signals-cookie-runtime.d.ts +2 -0
  131. package/dist/client/signals-cookie-runtime.js +56 -0
  132. package/dist/client/signals-devtools-runtime.d.ts +2 -0
  133. package/dist/client/signals-devtools-runtime.js +136 -0
  134. package/dist/client/signals-dialog-runtime.d.ts +2 -0
  135. package/dist/client/signals-dialog-runtime.js +195 -0
  136. package/dist/client/signals-dom-ready-runtime.d.ts +2 -0
  137. package/dist/client/signals-dom-ready-runtime.js +306 -0
  138. package/dist/client/signals-drawer-runtime.d.ts +2 -0
  139. package/dist/client/signals-drawer-runtime.js +39 -0
  140. package/dist/client/signals-effect-runtime.d.ts +2 -0
  141. package/dist/client/signals-effect-runtime.js +157 -0
  142. package/dist/client/signals-event-shorthand-runtime.d.ts +2 -0
  143. package/dist/client/signals-event-shorthand-runtime.js +88 -0
  144. package/dist/client/signals-expression-compiler-runtime.d.ts +2 -0
  145. package/dist/client/signals-expression-compiler-runtime.js +59 -0
  146. package/dist/client/signals-expression-runtime.d.ts +2 -0
  147. package/dist/client/signals-expression-runtime.js +67 -0
  148. package/dist/client/signals-fetch-runtime.d.ts +2 -0
  149. package/dist/client/signals-fetch-runtime.js +144 -0
  150. package/dist/client/signals-fetch-transport-runtime.d.ts +2 -0
  151. package/dist/client/signals-fetch-transport-runtime.js +216 -0
  152. package/dist/client/signals-for-runtime.d.ts +2 -0
  153. package/dist/client/signals-for-runtime.js +647 -0
  154. package/dist/client/signals-globals-runtime.d.ts +2 -0
  155. package/dist/client/signals-globals-runtime.js +66 -0
  156. package/dist/client/signals-handler-runtime.d.ts +2 -0
  157. package/dist/client/signals-handler-runtime.js +80 -0
  158. package/dist/client/signals-head-runtime.d.ts +2 -0
  159. package/dist/client/signals-head-runtime.js +92 -0
  160. package/dist/client/signals-helpers-runtime.d.ts +2 -0
  161. package/dist/client/signals-helpers-runtime.js +137 -0
  162. package/dist/client/signals-host-runtime.d.ts +9 -0
  163. package/dist/client/signals-host-runtime.js +132 -0
  164. package/dist/client/signals-hydration-audit-runtime.d.ts +2 -0
  165. package/dist/client/signals-hydration-audit-runtime.js +209 -0
  166. package/dist/client/signals-hydration-runtime.d.ts +2 -0
  167. package/dist/client/signals-hydration-runtime.js +52 -0
  168. package/dist/client/signals-if-chain-runtime.d.ts +2 -0
  169. package/dist/client/signals-if-chain-runtime.js +283 -0
  170. package/dist/client/signals-if-runtime.d.ts +2 -0
  171. package/dist/client/signals-if-runtime.js +346 -0
  172. package/dist/client/signals-kept-runtime.d.ts +2 -0
  173. package/dist/client/signals-kept-runtime.js +62 -0
  174. package/dist/client/signals-lazy-hydration-runtime.d.ts +2 -0
  175. package/dist/client/signals-lazy-hydration-runtime.js +133 -0
  176. package/dist/client/signals-lifecycle-runtime.d.ts +2 -0
  177. package/dist/client/signals-lifecycle-runtime.js +114 -0
  178. package/dist/client/signals-loop-component-remap-runtime.d.ts +2 -0
  179. package/dist/client/signals-loop-component-remap-runtime.js +66 -0
  180. package/dist/client/signals-loop-conditional-runtime.d.ts +2 -0
  181. package/dist/client/signals-loop-conditional-runtime.js +48 -0
  182. package/dist/client/signals-loop-row-runtime.d.ts +2 -0
  183. package/dist/client/signals-loop-row-runtime.js +41 -0
  184. package/dist/client/signals-manifest-hydration-runtime.d.ts +2 -0
  185. package/dist/client/signals-manifest-hydration-runtime.js +82 -0
  186. package/dist/client/signals-model-runtime.d.ts +2 -0
  187. package/dist/client/signals-model-runtime.js +156 -0
  188. package/dist/client/signals-mount-runtime.d.ts +1 -0
  189. package/dist/client/signals-mount-runtime.js +231 -0
  190. package/dist/client/signals-navigation-runtime.d.ts +2 -0
  191. package/dist/client/signals-navigation-runtime.js +198 -0
  192. package/dist/client/signals-optimistic-runtime.d.ts +2 -0
  193. package/dist/client/signals-optimistic-runtime.js +34 -0
  194. package/dist/client/signals-overlay-runtime.d.ts +2 -0
  195. package/dist/client/signals-overlay-runtime.js +352 -0
  196. package/dist/client/signals-pipe-runtime.d.ts +2 -0
  197. package/dist/client/signals-pipe-runtime.js +177 -0
  198. package/dist/client/signals-process-element-runtime.d.ts +1 -0
  199. package/dist/client/signals-process-element-runtime.js +696 -0
  200. package/dist/client/signals-proxy-runtime.d.ts +2 -0
  201. package/dist/client/signals-proxy-runtime.js +78 -0
  202. package/dist/client/signals-public-api-runtime.d.ts +1 -0
  203. package/dist/client/signals-public-api-runtime.js +120 -0
  204. package/dist/client/signals-query-runtime.d.ts +2 -0
  205. package/dist/client/signals-query-runtime.js +351 -0
  206. package/dist/client/signals-reactive-core-bootstrap-runtime.d.ts +1 -0
  207. package/dist/client/signals-reactive-core-bootstrap-runtime.js +30 -0
  208. package/dist/client/signals-reactive-runtime.d.ts +2 -0
  209. package/dist/client/signals-reactive-runtime.js +67 -0
  210. package/dist/client/signals-ref-runtime.d.ts +2 -0
  211. package/dist/client/signals-ref-runtime.js +33 -0
  212. package/dist/client/signals-scope-disposal-runtime.d.ts +2 -0
  213. package/dist/client/signals-scope-disposal-runtime.js +195 -0
  214. package/dist/client/signals-scope-traversal-runtime.d.ts +2 -0
  215. package/dist/client/signals-scope-traversal-runtime.js +42 -0
  216. package/dist/client/signals-show-runtime.d.ts +2 -0
  217. package/dist/client/signals-show-runtime.js +54 -0
  218. package/dist/client/signals-spa-load-control-runtime.d.ts +2 -0
  219. package/dist/client/signals-spa-load-control-runtime.js +42 -0
  220. package/dist/client/signals-spa-load-runtime.d.ts +2 -0
  221. package/dist/client/signals-spa-load-runtime.js +187 -0
  222. package/dist/client/signals-state-runtime.d.ts +2 -0
  223. package/dist/client/signals-state-runtime.js +125 -0
  224. package/dist/client/signals-storage-runtime.d.ts +2 -0
  225. package/dist/client/signals-storage-runtime.js +79 -0
  226. package/dist/client/signals-store-registry-runtime.d.ts +1 -0
  227. package/dist/client/signals-store-registry-runtime.js +461 -0
  228. package/dist/client/signals-style-runtime.d.ts +2 -0
  229. package/dist/client/signals-style-runtime.js +35 -0
  230. package/dist/client/signals-suspense-runtime.d.ts +2 -0
  231. package/dist/client/signals-suspense-runtime.js +59 -0
  232. package/dist/client/signals-timer-runtime.d.ts +2 -0
  233. package/dist/client/signals-timer-runtime.js +378 -0
  234. package/dist/client/signals-toast-runtime.d.ts +2 -0
  235. package/dist/client/signals-toast-runtime.js +206 -0
  236. package/dist/client/signals-tooltip-runtime.d.ts +2 -0
  237. package/dist/client/signals-tooltip-runtime.js +40 -0
  238. package/dist/client/signals-transition-group-runtime.d.ts +2 -0
  239. package/dist/client/signals-transition-group-runtime.js +92 -0
  240. package/dist/client/signals-websocket-runtime.d.ts +2 -0
  241. package/dist/client/signals-websocket-runtime.js +138 -0
  242. package/dist/craft-entry.js +2 -2
  243. package/dist/craft.js +2 -2
  244. package/dist/native/runtime/native-host.js +4 -1
  245. package/dist/pwa.js +3 -3
  246. package/dist/signals-context-runtime.d.ts +2 -0
  247. package/dist/signals-drawer-runtime.d.ts +2 -0
  248. package/dist/signals-host-runtime.d.ts +9 -0
  249. package/dist/signals-loop-conditional-runtime.d.ts +2 -0
  250. package/dist/signals-manifest-hydration-runtime.d.ts +2 -0
  251. package/dist/signals-optimistic-runtime.d.ts +2 -0
  252. package/dist/signals-overlay-runtime.d.ts +2 -0
  253. package/dist/signals-scope-disposal-runtime.d.ts +2 -0
  254. package/dist/signals-spa-load-control-runtime.d.ts +2 -0
  255. package/dist/signals-storage-runtime.d.ts +2 -0
  256. package/dist/signals.js +141 -9900
  257. package/dist/ssg.js +3 -3
  258. package/package.json +5 -5
  259. package/dist/chunk-0zmv31nc.js +0 -2
  260. package/dist/chunk-1cdanx2v.js +0 -2
  261. package/dist/chunk-1wt5fagh.js +0 -2
  262. package/dist/chunk-2936t942.js +0 -2
  263. package/dist/chunk-3dd5zxbt.js +0 -2
  264. package/dist/chunk-3v91cb0g.js +0 -2
  265. package/dist/chunk-4cyjdghc.js +0 -2
  266. package/dist/chunk-5achv4zv.js +0 -2
  267. package/dist/chunk-5yg6m30k.js +0 -2
  268. package/dist/chunk-6qzjyr8e.js +0 -2
  269. package/dist/chunk-785ckss2.js +0 -2
  270. package/dist/chunk-88kjwkza.js +0 -2
  271. package/dist/chunk-8bcvb86w.js +0 -2
  272. package/dist/chunk-8h1zg44w.js +0 -2
  273. package/dist/chunk-8jtyra19.js +0 -2
  274. package/dist/chunk-bnsz09pg.js +0 -2
  275. package/dist/chunk-c9rwnsk7.js +0 -2
  276. package/dist/chunk-csjax0ej.js +0 -2
  277. package/dist/chunk-dd31q423.js +0 -2
  278. package/dist/chunk-dptjyncv.js +0 -2
  279. package/dist/chunk-et8ejd7k.js +0 -2
  280. package/dist/chunk-g1kyy5h1.js +0 -2
  281. package/dist/chunk-h791c7sb.js +0 -2
  282. package/dist/chunk-h88jcr3k.js +0 -2
  283. package/dist/chunk-hvvbppt4.js +0 -2
  284. package/dist/chunk-j4rb9rxx.js +0 -2
  285. package/dist/chunk-ka7qdsha.js +0 -2
  286. package/dist/chunk-m4d99a9r.js +0 -2
  287. package/dist/chunk-m5gdwq1d.js +0 -2
  288. package/dist/chunk-nz5ekyxn.js +0 -2
  289. package/dist/chunk-rchwwcxy.js +0 -2
  290. package/dist/chunk-s5cb4hkj.js +0 -2
  291. package/dist/chunk-t2mjeezd.js +0 -2
  292. package/dist/chunk-vk18649m.js +0 -2
  293. package/dist/chunk-vmfw4svt.js +0 -2
  294. package/dist/chunk-wbv6vjhm.js +0 -2
  295. package/dist/chunk-wpnv0naj.js +0 -2
  296. package/dist/chunk-wv2crxm6.js +0 -2
  297. package/dist/chunk-xda69f13.js +0 -2
  298. package/dist/chunk-ym182eg0.js +0 -2
  299. package/dist/chunk-zah67v44.js +0 -2
@@ -0,0 +1,2 @@
1
+ /** Read and write proxies that preserve signal semantics in template scopes. */
2
+ export declare const SIGNALS_PROXY_RUNTIME = " // ==========================================================================\n // Auto-unwrap Signals (Feature #1)\n // ==========================================================================\n\n // Create a proxy that auto-unwraps signals when accessed.\n // For stx stores (objects with _isStxStore), recursively wrap so nested\n // signal properties auto-unwrap too \u2014 this is what makes template\n // expressions like store.someSignal (no parens) and store.x === 'y'\n // resolve to the value. Action methods on the store pass through as\n // functions because they don't carry _isSignal/_isDerived markers.\n function createAutoUnwrapProxy(scope, preserveSignal) {\n return new Proxy(scope, {\n get(target, prop) {\n const val = target[prop];\n // If it's a signal or derived, call it to get the value\n if (val && typeof val === 'function' && (val._isSignal || val._isDerived)) {\n // Loop variables are implementation-detail signals so keyed rows can\n // update reactively. In template expressions they must behave like\n // their item value, including for objects with fields named value,\n // set, or subscribe. Otherwise item.value is mistaken for the\n // signal compatibility API and resolves to the whole item object.\n if (val._isStxLoopItem) return val();\n if (preserveSignal && preserveSignal(prop, val)) return val;\n return val();\n }\n // If it's an stx store, return a recursively-unwrapping wrapper so\n // store.signalProp resolves to the value in template expressions\n if (val && typeof val === 'object' && val._isStxStore) {\n return createAutoUnwrapProxy(val, preserveSignal);\n }\n return val;\n },\n set(target, prop, value) {\n const cur = target[prop];\n if (cur && typeof cur === 'function' && cur._isSignal && typeof cur.set === 'function') {\n cur.set(value);\n return true;\n }\n target[prop] = value;\n return true;\n }\n });\n }\n\n // A proxy for the WRITE side of x-model, kept separate from the read proxy\n // on purpose.\n //\n // The read proxy returns a plain object as-is, which is right for reading \u2014\n // ordinary data should stay ordinary. But it means an assignment lands on the\n // raw object, so a signal held there gets REPLACED by the typed value rather\n // than set (#1883). Descending through a write proxy instead keeps set-trap\n // semantics all the way down, so the signal at the end of any path is set.\n function createModelWriteProxy(target) {\n return new Proxy(target, {\n get(t, prop) {\n var val = t[prop];\n if (val && typeof val === 'function' && (val._isSignal || val._isDerived)) {\n // Descend INTO the signal's value: x-model=\"form.email\" over\n // state({email}) must reach the object, not stamp a property onto\n // the signal function itself.\n var inner = val();\n return (inner && typeof inner === 'object') ? createModelWriteProxy(inner) : inner;\n }\n if (val && typeof val === 'object') return createModelWriteProxy(val);\n return val;\n },\n set(t, prop, value) {\n var cur = t[prop];\n if (cur && typeof cur === 'function' && cur._isSignal && typeof cur.set === 'function') {\n cur.set(value);\n return true;\n }\n t[prop] = value;\n return true;\n },\n });\n }\n";
@@ -0,0 +1,78 @@
1
+ export const SIGNALS_PROXY_RUNTIME = ` // ==========================================================================
2
+ // Auto-unwrap Signals (Feature #1)
3
+ // ==========================================================================
4
+
5
+ // Create a proxy that auto-unwraps signals when accessed.
6
+ // For stx stores (objects with _isStxStore), recursively wrap so nested
7
+ // signal properties auto-unwrap too \u2014 this is what makes template
8
+ // expressions like store.someSignal (no parens) and store.x === 'y'
9
+ // resolve to the value. Action methods on the store pass through as
10
+ // functions because they don't carry _isSignal/_isDerived markers.
11
+ function createAutoUnwrapProxy(scope, preserveSignal) {
12
+ return new Proxy(scope, {
13
+ get(target, prop) {
14
+ const val = target[prop];
15
+ // If it's a signal or derived, call it to get the value
16
+ if (val && typeof val === 'function' && (val._isSignal || val._isDerived)) {
17
+ // Loop variables are implementation-detail signals so keyed rows can
18
+ // update reactively. In template expressions they must behave like
19
+ // their item value, including for objects with fields named value,
20
+ // set, or subscribe. Otherwise item.value is mistaken for the
21
+ // signal compatibility API and resolves to the whole item object.
22
+ if (val._isStxLoopItem) return val();
23
+ if (preserveSignal && preserveSignal(prop, val)) return val;
24
+ return val();
25
+ }
26
+ // If it's an stx store, return a recursively-unwrapping wrapper so
27
+ // store.signalProp resolves to the value in template expressions
28
+ if (val && typeof val === 'object' && val._isStxStore) {
29
+ return createAutoUnwrapProxy(val, preserveSignal);
30
+ }
31
+ return val;
32
+ },
33
+ set(target, prop, value) {
34
+ const cur = target[prop];
35
+ if (cur && typeof cur === 'function' && cur._isSignal && typeof cur.set === 'function') {
36
+ cur.set(value);
37
+ return true;
38
+ }
39
+ target[prop] = value;
40
+ return true;
41
+ }
42
+ });
43
+ }
44
+
45
+ // A proxy for the WRITE side of x-model, kept separate from the read proxy
46
+ // on purpose.
47
+ //
48
+ // The read proxy returns a plain object as-is, which is right for reading \u2014
49
+ // ordinary data should stay ordinary. But it means an assignment lands on the
50
+ // raw object, so a signal held there gets REPLACED by the typed value rather
51
+ // than set (#1883). Descending through a write proxy instead keeps set-trap
52
+ // semantics all the way down, so the signal at the end of any path is set.
53
+ function createModelWriteProxy(target) {
54
+ return new Proxy(target, {
55
+ get(t, prop) {
56
+ var val = t[prop];
57
+ if (val && typeof val === 'function' && (val._isSignal || val._isDerived)) {
58
+ // Descend INTO the signal's value: x-model="form.email" over
59
+ // state({email}) must reach the object, not stamp a property onto
60
+ // the signal function itself.
61
+ var inner = val();
62
+ return (inner && typeof inner === 'object') ? createModelWriteProxy(inner) : inner;
63
+ }
64
+ if (val && typeof val === 'object') return createModelWriteProxy(val);
65
+ return val;
66
+ },
67
+ set(t, prop, value) {
68
+ var cur = t[prop];
69
+ if (cur && typeof cur === 'function' && cur._isSignal && typeof cur.set === 'function') {
70
+ cur.set(value);
71
+ return true;
72
+ }
73
+ t[prop] = value;
74
+ return true;
75
+ },
76
+ });
77
+ }
78
+ `;
@@ -0,0 +1 @@
1
+ export declare function signalsPublicApiRuntime(componentApiRuntime: string): string;
@@ -0,0 +1,120 @@
1
+ export function signalsPublicApiRuntime(componentApiRuntime) {
2
+ return ` // Component mount system
3
+ var mountQueue = [];
4
+
5
+ // MERGE, never replace (#1804). Three client bundles assign window.stx and
6
+ // the last one used to erase the others. Object.assign also preserves the
7
+ // object IDENTITY, which matters because the generated store runtime captures
8
+ // window.stx in a closure variable \u2014 replacing the object leaves that closure
9
+ // calling a detached one.
10
+ window.stx = Object.assign(window.stx || {}, {
11
+ hydrate: hydrateSubtree,
12
+ hydrateHost,
13
+ state,
14
+ derived,
15
+ effect,
16
+ batch,
17
+ isSignal,
18
+ isDerived,
19
+ untrack,
20
+ peek,
21
+ inject,
22
+ watchMultiple,
23
+ onMount,
24
+ onBeforeMount: onMount,
25
+ onDestroy,
26
+ onMounted: onMount,
27
+ onBeforeUnmount: onDestroy,
28
+ onUnmounted: onDestroy,
29
+ useFetch,
30
+ clearServerData,
31
+ useRef,
32
+ navigate,
33
+ refresh,
34
+ invalidateRoute,
35
+ goBack,
36
+ goForward,
37
+ useRoute,
38
+ useRouteParams,
39
+ useRouteParam,
40
+ setRouteParams,
41
+ useSearchParams,
42
+ useQuery,
43
+ useMutation,
44
+ configureFetch,
45
+ useOptimistic,
46
+ provide,
47
+ $computed,
48
+ $watch,
49
+ ref,
50
+ reactive,
51
+ computed,
52
+ watch,
53
+ watchEffect,
54
+ useDebounce,
55
+ useDebounceFn,
56
+ useDebouncedValue,
57
+ refDebounced,
58
+ useThrottle,
59
+ useThrottleFn,
60
+ useInterval,
61
+ useTimeout,
62
+ useTimeoutFn,
63
+ useToggle,
64
+ useCounter,
65
+ useClickOutside,
66
+ useFocus,
67
+ nextTick,
68
+ useAsync,
69
+ useLocalStorage,
70
+ useSessionStorage,
71
+ keptState,
72
+ forgetKeptState,
73
+ setKeptScope,
74
+ flushKeptState,
75
+ cachedQuery,
76
+ useCookie,
77
+ useId,
78
+ useReactiveProp,
79
+ useModel,
80
+ useEventListener,
81
+ useWebSocket,
82
+ useColorMode,
83
+ useDark,
84
+ useMediaQuery,
85
+ useDocumentVisibility,
86
+ useScrollLock,
87
+ usePreferredDark,
88
+ usePreferredLight,
89
+ usePreferredReducedMotion,
90
+ usePreferredContrast,
91
+ useHead,
92
+ useSeoMeta,
93
+ // Client-side no-op for definePageMeta \u2014 the real implementation registers
94
+ // page metadata (middleware / validate / etc.) at SSR/SSG time. Pages that
95
+ // call it inside a bare <script> or <script client> would otherwise hit
96
+ // ReferenceError on hydration; this shim lets shared client/server code
97
+ // call it safely.
98
+ definePageMeta: function() {},
99
+ toast,
100
+ modal,
101
+ drawer,
102
+ overlays,
103
+ alert: stxAlert,
104
+ confirm: stxConfirm,
105
+ helpers: globalHelpers,
106
+
107
+ ${componentApiRuntime}
108
+
109
+ _mountCallbacks: mountCallbacks,
110
+ _destroyCallbacks: destroyCallbacks,
111
+ _cleanupContainer: cleanupContainer,
112
+ _flushLoad: flushStxLoad,
113
+ _beginSwap: beginSwap,
114
+ _registerSuspense: registerSuspense, // <Suspense> query registration (#1742)
115
+ _tg: { enter: tgEnter, leave: tgLeave, flip: tgFlip, snapshot: tgSnapshot }, // <TransitionGroup> helpers (#1742)
116
+ _scopes: {}, // Component-level scopes
117
+ _scopeCounter: 0, // Counter for generating unique scope IDs during SPA navigation
118
+ _latestSetup: window.__stx_latestSetup || null, // Latest SFC setup function (including scripts parsed before the runtime)
119
+ _stores: new Map(), // Global store registry \u2014 survives SPA navigation`;
120
+ }
@@ -0,0 +1,2 @@
1
+ /** Query and mutation composables used by the generated client runtime. */
2
+ export declare const SIGNALS_QUERY_RUNTIME = " // ==========================================================================\n // Advanced Data Fetching (useQuery / useMutation)\n // ==========================================================================\n\n var _queryCache = {};\n // Requests currently in flight, keyed exactly like _queryCache. _queryCache\n // is written only after the body parses, so the whole in-flight window was a\n // cache miss and N components mounting together issued N identical requests\n // (#1869). Refcounted: a caller that loses interest must not cancel a\n // response another caller is still waiting on.\n var _queryInflight = {};\n var __stxQueryInstance = 0;\n\n // Suspense registry (#1742). A query created with { suspense: true } pushes\n // { el, loading, error } here at creation time (which runs during partial-scope\n // script execution, BEFORE the <Suspense> boundary inits on content-load).\n // Each boundary then CLAIMS the descendant entries for which it is the nearest\n // [data-stx-suspense] ancestor, and aggregates their loading/error signals.\n // Kept on the window (one registry per page) rather than a per-instance\n // closure so a boundary and the queries it claims agree even if the page\n // somehow has more than one runtime instance (e.g. across test files).\n function suspenseRegistry() {\n if (typeof window === 'undefined') return [];\n return window.__stx_suspense_registry || (window.__stx_suspense_registry = []);\n }\n function registerSuspense(loading, error) {\n var el = (typeof window !== 'undefined' && window.__STX_CURRENT_ELEMENT__) || null;\n suspenseRegistry().push({ el: el, loading: loading, error: error });\n }\n\n function useQuery(url, options) {\n options = options || {};\n var staleTime = options.staleTime || 0;\n var cacheTime = options.cacheTime || 300000; // 5 min default\n var cacheKey = options.cacheKey || (typeof url === 'function' ? null : url);\n // keep: the answer is kept on the device per account (setKeptScope, or\n // options.scope) and seeds the next visit synchronously, refreshed behind.\n // true keeps it under the query's key; a string names it.\n var keepKey = options.keep ? (typeof options.keep === 'string' ? options.keep : cacheKey) : null;\n var queryTarget = function() {\n var resolved = null;\n try { resolved = typeof url === 'function' ? url() : url; } catch (e) {}\n return { key: cacheKey || keepKey || resolved || '', url: resolved };\n };\n // What is shown is the last answer with the outbox's waiting writes on\n // top, so a change made offline is not undone by a refetch.\n var base = options.initialData || null;\n var seeded = keepKey ? __stxQueries.seed(keepKey, options.scope) : undefined;\n if (seeded) base = seeded.data;\n var data = state(seeded ? __stxQueries.overlay(queryTarget(), base) : base);\n var show = function(value) {\n base = value;\n data.set(__stxQueries.overlay(queryTarget(), value));\n };\n var answered = false;\n var loading = state(!seeded);\n // See useFetch: loading means \"nothing to show yet\", isFetching means \"a\n // request is open\" \u2014 including a background refresh, which is the case that\n // makes the distinction necessary (#1929).\n var isFetching = state(true);\n var error = state(null);\n var isStale = state(!!seeded);\n if (options.suspense) registerSuspense(loading, error);\n // Kept too large for a synchronous read: it arrives a moment later, and\n // shows unless an answer came first.\n if (keepKey && !seeded) {\n __stxQueries.restore(keepKey, options.scope).then(function(found) {\n if (!found || answered) return;\n show(found.data);\n loading.set(false);\n isStale.set(true);\n });\n }\n\n // Per-run AbortController: a newer run aborts the previous in-flight one and\n // onDestroy aborts the last, so a resolved request can't write into a\n // torn-down scope (#1871).\n var __stxAbort = null;\n // Identity, so dedup can tell \"another component wants this key\" from\n // \"this component asked again\". They must behave differently: joining is\n // right for the first, and wrong for the second \u2014 refetch() after a\n // mutation has to hit the network, not adopt the pre-mutation request that\n // happens to still be open (#1869).\n var __instanceId = ++__stxQueryInstance;\n // The shared entry this instance is currently attached to, so superseding\n // can release its claim without cancelling a request someone else joined.\n var __joined = null;\n\n // runOptions: { background: true } refreshes without touching loading or\n // clearing the current error. A poll must not flash a spinner over data\n // that is already on screen (#1929).\n var fetchData = async function(runOptions) {\n var background = !!(runOptions && runOptions.background);\n var resolvedUrl = typeof url === 'function' ? url() : url;\n if (!resolvedUrl) { if (!background) loading.set(false); isFetching.set(false); return; }\n var key = cacheKey || resolvedUrl;\n\n // Check cache\n var cached = _queryCache[key];\n if (cached && (Date.now() - cached.timestamp < staleTime)) {\n answered = true;\n show(cached.data);\n if (!background) loading.set(false);\n isFetching.set(false);\n isStale.set(false);\n if (options.onSuccess) options.onSuccess(cached.data);\n return;\n }\n\n // Stale-while-revalidate\n if (cached) {\n show(cached.data);\n isStale.set(true);\n }\n\n // Join a request ANOTHER instance already has open for this key. Not one\n // of our own: this instance calling refetch() means \"I want fresh data\",\n // and adopting its own pre-mutation request would silently return stale\n // data \u2014 so an own-instance run still supersedes, exactly as #1871 says.\n var shared = _queryInflight[key];\n if (shared && shared.owner !== __instanceId) {\n shared.refs++;\n __joined = shared;\n if (!background) loading.set(true);\n isFetching.set(true);\n if (!background) error.set(null);\n try {\n var joinedResult = await shared.promise;\n var joinedTransformed = options.transform ? options.transform(joinedResult) : joinedResult;\n answered = true;\n show(joinedTransformed);\n if (keepKey) __stxQueries.persist(keepKey, joinedTransformed, options.scope);\n if (background) error.set(null);\n isStale.set(false);\n if (options.onSuccess) options.onSuccess(joinedTransformed);\n }\n catch (e) {\n if (e && e.name === 'AbortError') return;\n error.set(e.message || 'Query failed');\n if (options.onError) options.onError(e);\n }\n finally {\n shared.refs--;\n if (__joined === shared) __joined = null;\n if (!background) loading.set(false);\n isFetching.set(false);\n }\n return;\n }\n\n // Superseding this instance's own run. Abort ONLY if nobody joined it \u2014\n // cancelling a request another component is waiting on would leave it\n // loading forever, which would turn #1871's fix into a worse bug.\n if (__stxAbort) {\n if (__joined && __joined.refs > 1) __joined.refs--;\n else __stxAbort.abort();\n }\n __joined = null;\n __stxAbort = (typeof AbortController !== 'undefined') ? new AbortController() : null;\n var __signal = __stxAbort ? __stxAbort.signal : undefined;\n if (!background) loading.set(true);\n isFetching.set(true);\n if (!background) error.set(null);\n try {\n var fetchOpts = { method: 'GET', headers: { 'Content-Type': 'application/json', ...__stxHeaders(options.headers) }, signal: __signal };\n // Published BEFORE it is awaited, so a caller starting in the same tick\n // finds it. The network part only \u2014 transform, cache write and\n // onSuccess stay per-caller, since each may transform differently.\n var netPromise = (async function() {\n var response = await __stxFetch('useQuery', resolvedUrl, fetchOpts);\n if (!response.ok) throw await __stxHttpError(response);\n return await response.json();\n })();\n var entry = { owner: __instanceId, refs: 1, controller: __stxAbort, promise: netPromise };\n _queryInflight[key] = entry;\n __joined = entry;\n // Cleared on settle, both ways. A settled entry left behind would turn\n // dedup into a permanent cache and no request for this key would ever\n // be issued again.\n var releaseEntry = function() { if (_queryInflight[key] === entry) delete _queryInflight[key]; };\n netPromise.then(releaseEntry, releaseEntry);\n\n var result = await netPromise;\n if (__signal && __signal.aborted) return;\n var transformed = options.transform ? options.transform(result) : result;\n answered = true;\n show(transformed);\n if (keepKey) __stxQueries.persist(keepKey, transformed, options.scope);\n if (background) error.set(null);\n isStale.set(false);\n _queryCache[key] = { data: transformed, timestamp: Date.now() };\n if (options.onSuccess) options.onSuccess(transformed);\n // Schedule cache eviction\n setTimeout(function() { delete _queryCache[key]; }, cacheTime);\n }\ncatch (e) {\n // A superseded/unmounted request rejects with AbortError \u2014 expected;\n // the run that superseded it owns the state (#1871).\n if (e && e.name === 'AbortError') return;\n error.set(e.message || 'Query failed');\n if (options.onError) options.onError(e);\n }\nfinally {\n if (!__signal || !__signal.aborted) {\n if (!background) loading.set(false);\n isFetching.set(false);\n }\n }\n };\n\n // A refetch nobody asked for does not set loading (see backgroundRun below).\n var backgroundRun = { background: true };\n\n if (options.immediate !== false) {\n // Seeded from the device: the kept copy is on screen, so the first\n // fetch refreshes it behind rather than putting a spinner over it.\n onMount(function() { return seeded ? fetchData(backgroundRun) : fetchData(); });\n }\n\n // The worker has a newer answer for this URL, or the outbox changed: a\n // write waiting on it is shown on top, and one that reached the server\n // stays shown until the refetch it triggers includes it.\n var unwatch = __stxQueries.watch({\n target: queryTarget,\n updated: function() {\n delete _queryCache[cacheKey || queryTarget().url];\n fetchData(backgroundRun);\n },\n outbox: function(sent) {\n if (sent) {\n base = __stxQueries.overlay(queryTarget(), base, sent.id);\n delete _queryCache[cacheKey || queryTarget().url];\n fetchData(backgroundRun);\n }\n show(base);\n }\n });\n onDestroy(unwatch);\n\n // A refetch nobody asked for does not set loading. Both of these refresh\n // data that is ALREADY on screen, so driving the first-load state from them\n // put a spinner over a populated view once a minute, forever \u2014 the reason a\n // polling view could not use this composable at all (#1929). Bind\n // isFetching for a subtle in-flight indicator.\n\n // refetchOnFocus \u2014 removed on destroy, like refetchInterval right below.\n // It used to add a listener and never remove it, so every instance leaked\n // one for the life of the page and each SPA navigation added more; every\n // stale listener still fired, refetching for components long gone (#1818).\n if (options.refetchOnFocus) {\n var onVisibility = function() {\n if (!document.hidden) fetchData(backgroundRun);\n };\n document.addEventListener('visibilitychange', onVisibility);\n onDestroy(function() { document.removeEventListener('visibilitychange', onVisibility); });\n }\n\n // refetchInterval: poll only while the tab is visible and (if given)\n // enabled holds; optionally stop after an error so a broken endpoint is\n // not hammered every interval in a backgrounded tab (#1870).\n if (options.refetchInterval) {\n var intervalId = setInterval(function() {\n if (typeof document !== 'undefined' && document.hidden) return;\n var en = options.enabled;\n if (typeof en === 'function' ? !en() : en === false) return;\n var p = fetchData(backgroundRun);\n if (options.stopOnError && p && typeof p.then === 'function') {\n p.then(function() { if (error()) clearInterval(intervalId); });\n }\n }, options.refetchInterval);\n onDestroy(function() { clearInterval(intervalId); });\n }\n\n // Abort an in-flight request when the owning scope is destroyed (#1871).\n onDestroy(function() { if (__stxAbort) __stxAbort.abort(); });\n\n return {\n data: data,\n loading: loading,\n isFetching: isFetching,\n error: error,\n isStale: isStale,\n refetch: fetchData,\n invalidate: function(runOptions) {\n var key = cacheKey || (typeof url === 'function' ? url() : url);\n delete _queryCache[key];\n return fetchData(runOptions);\n }\n };\n }\n\n function useMutation(url, options) {\n options = options || {};\n var data = state(null);\n var loading = state(false);\n var error = state(null);\n\n var mutate = async function(body) {\n loading.set(true);\n error.set(null);\n var previousData = data();\n\n // Optimistic update\n if (options.optimisticData) {\n var optimistic = typeof options.optimisticData === 'function' ? options.optimisticData(body) : options.optimisticData;\n data.set(optimistic);\n }\n\n try {\n var resolvedUrl = typeof url === 'function' ? url() : url;\n var fetchOpts = {\n method: options.method || 'POST',\n // A file upload is a FormData body. Stringifying it sent \"{}\", and\n // the browser has to write its own multipart Content-Type (the\n // boundary lives there), so raw bodies pass through untouched.\n headers: __stxRawBody(body) ? __stxHeaders(options.headers) : { 'Content-Type': 'application/json', ...__stxHeaders(options.headers) },\n body: typeof body === 'string' || __stxRawBody(body) ? body : JSON.stringify(body)\n };\n var response = await __stxFetch('useMutation', resolvedUrl, fetchOpts);\n if (!response.ok) throw await __stxHttpError(response);\n var result = await response.json();\n var transformed = options.transform ? options.transform(result) : result;\n data.set(transformed);\n if (options.onSuccess) options.onSuccess(transformed);\n // Invalidate related queries\n if (options.invalidateQueries) {\n options.invalidateQueries.forEach(function(key) { delete _queryCache[key]; });\n }\n return transformed;\n }\ncatch (e) {\n error.set(e.message || 'Mutation failed');\n // Rollback optimistic update\n if (options.optimisticData) data.set(previousData);\n if (options.onError) options.onError(e);\n throw e;\n }\nfinally {\n loading.set(false);\n }\n };\n\n return {\n data: data,\n loading: loading,\n error: error,\n mutate: mutate,\n reset: function() { data.set(null); error.set(null); loading.set(false); }\n };\n }\n";
@@ -0,0 +1,351 @@
1
+ export const SIGNALS_QUERY_RUNTIME = ` // ==========================================================================
2
+ // Advanced Data Fetching (useQuery / useMutation)
3
+ // ==========================================================================
4
+
5
+ var _queryCache = {};
6
+ // Requests currently in flight, keyed exactly like _queryCache. _queryCache
7
+ // is written only after the body parses, so the whole in-flight window was a
8
+ // cache miss and N components mounting together issued N identical requests
9
+ // (#1869). Refcounted: a caller that loses interest must not cancel a
10
+ // response another caller is still waiting on.
11
+ var _queryInflight = {};
12
+ var __stxQueryInstance = 0;
13
+
14
+ // Suspense registry (#1742). A query created with { suspense: true } pushes
15
+ // { el, loading, error } here at creation time (which runs during partial-scope
16
+ // script execution, BEFORE the <Suspense> boundary inits on content-load).
17
+ // Each boundary then CLAIMS the descendant entries for which it is the nearest
18
+ // [data-stx-suspense] ancestor, and aggregates their loading/error signals.
19
+ // Kept on the window (one registry per page) rather than a per-instance
20
+ // closure so a boundary and the queries it claims agree even if the page
21
+ // somehow has more than one runtime instance (e.g. across test files).
22
+ function suspenseRegistry() {
23
+ if (typeof window === 'undefined') return [];
24
+ return window.__stx_suspense_registry || (window.__stx_suspense_registry = []);
25
+ }
26
+ function registerSuspense(loading, error) {
27
+ var el = (typeof window !== 'undefined' && window.__STX_CURRENT_ELEMENT__) || null;
28
+ suspenseRegistry().push({ el: el, loading: loading, error: error });
29
+ }
30
+
31
+ function useQuery(url, options) {
32
+ options = options || {};
33
+ var staleTime = options.staleTime || 0;
34
+ var cacheTime = options.cacheTime || 300000; // 5 min default
35
+ var cacheKey = options.cacheKey || (typeof url === 'function' ? null : url);
36
+ // keep: the answer is kept on the device per account (setKeptScope, or
37
+ // options.scope) and seeds the next visit synchronously, refreshed behind.
38
+ // true keeps it under the query's key; a string names it.
39
+ var keepKey = options.keep ? (typeof options.keep === 'string' ? options.keep : cacheKey) : null;
40
+ var queryTarget = function() {
41
+ var resolved = null;
42
+ try { resolved = typeof url === 'function' ? url() : url; } catch (e) {}
43
+ return { key: cacheKey || keepKey || resolved || '', url: resolved };
44
+ };
45
+ // What is shown is the last answer with the outbox's waiting writes on
46
+ // top, so a change made offline is not undone by a refetch.
47
+ var base = options.initialData || null;
48
+ var seeded = keepKey ? __stxQueries.seed(keepKey, options.scope) : undefined;
49
+ if (seeded) base = seeded.data;
50
+ var data = state(seeded ? __stxQueries.overlay(queryTarget(), base) : base);
51
+ var show = function(value) {
52
+ base = value;
53
+ data.set(__stxQueries.overlay(queryTarget(), value));
54
+ };
55
+ var answered = false;
56
+ var loading = state(!seeded);
57
+ // See useFetch: loading means "nothing to show yet", isFetching means "a
58
+ // request is open" \u2014 including a background refresh, which is the case that
59
+ // makes the distinction necessary (#1929).
60
+ var isFetching = state(true);
61
+ var error = state(null);
62
+ var isStale = state(!!seeded);
63
+ if (options.suspense) registerSuspense(loading, error);
64
+ // Kept too large for a synchronous read: it arrives a moment later, and
65
+ // shows unless an answer came first.
66
+ if (keepKey && !seeded) {
67
+ __stxQueries.restore(keepKey, options.scope).then(function(found) {
68
+ if (!found || answered) return;
69
+ show(found.data);
70
+ loading.set(false);
71
+ isStale.set(true);
72
+ });
73
+ }
74
+
75
+ // Per-run AbortController: a newer run aborts the previous in-flight one and
76
+ // onDestroy aborts the last, so a resolved request can't write into a
77
+ // torn-down scope (#1871).
78
+ var __stxAbort = null;
79
+ // Identity, so dedup can tell "another component wants this key" from
80
+ // "this component asked again". They must behave differently: joining is
81
+ // right for the first, and wrong for the second \u2014 refetch() after a
82
+ // mutation has to hit the network, not adopt the pre-mutation request that
83
+ // happens to still be open (#1869).
84
+ var __instanceId = ++__stxQueryInstance;
85
+ // The shared entry this instance is currently attached to, so superseding
86
+ // can release its claim without cancelling a request someone else joined.
87
+ var __joined = null;
88
+
89
+ // runOptions: { background: true } refreshes without touching loading or
90
+ // clearing the current error. A poll must not flash a spinner over data
91
+ // that is already on screen (#1929).
92
+ var fetchData = async function(runOptions) {
93
+ var background = !!(runOptions && runOptions.background);
94
+ var resolvedUrl = typeof url === 'function' ? url() : url;
95
+ if (!resolvedUrl) { if (!background) loading.set(false); isFetching.set(false); return; }
96
+ var key = cacheKey || resolvedUrl;
97
+
98
+ // Check cache
99
+ var cached = _queryCache[key];
100
+ if (cached && (Date.now() - cached.timestamp < staleTime)) {
101
+ answered = true;
102
+ show(cached.data);
103
+ if (!background) loading.set(false);
104
+ isFetching.set(false);
105
+ isStale.set(false);
106
+ if (options.onSuccess) options.onSuccess(cached.data);
107
+ return;
108
+ }
109
+
110
+ // Stale-while-revalidate
111
+ if (cached) {
112
+ show(cached.data);
113
+ isStale.set(true);
114
+ }
115
+
116
+ // Join a request ANOTHER instance already has open for this key. Not one
117
+ // of our own: this instance calling refetch() means "I want fresh data",
118
+ // and adopting its own pre-mutation request would silently return stale
119
+ // data \u2014 so an own-instance run still supersedes, exactly as #1871 says.
120
+ var shared = _queryInflight[key];
121
+ if (shared && shared.owner !== __instanceId) {
122
+ shared.refs++;
123
+ __joined = shared;
124
+ if (!background) loading.set(true);
125
+ isFetching.set(true);
126
+ if (!background) error.set(null);
127
+ try {
128
+ var joinedResult = await shared.promise;
129
+ var joinedTransformed = options.transform ? options.transform(joinedResult) : joinedResult;
130
+ answered = true;
131
+ show(joinedTransformed);
132
+ if (keepKey) __stxQueries.persist(keepKey, joinedTransformed, options.scope);
133
+ if (background) error.set(null);
134
+ isStale.set(false);
135
+ if (options.onSuccess) options.onSuccess(joinedTransformed);
136
+ }
137
+ catch (e) {
138
+ if (e && e.name === 'AbortError') return;
139
+ error.set(e.message || 'Query failed');
140
+ if (options.onError) options.onError(e);
141
+ }
142
+ finally {
143
+ shared.refs--;
144
+ if (__joined === shared) __joined = null;
145
+ if (!background) loading.set(false);
146
+ isFetching.set(false);
147
+ }
148
+ return;
149
+ }
150
+
151
+ // Superseding this instance's own run. Abort ONLY if nobody joined it \u2014
152
+ // cancelling a request another component is waiting on would leave it
153
+ // loading forever, which would turn #1871's fix into a worse bug.
154
+ if (__stxAbort) {
155
+ if (__joined && __joined.refs > 1) __joined.refs--;
156
+ else __stxAbort.abort();
157
+ }
158
+ __joined = null;
159
+ __stxAbort = (typeof AbortController !== 'undefined') ? new AbortController() : null;
160
+ var __signal = __stxAbort ? __stxAbort.signal : undefined;
161
+ if (!background) loading.set(true);
162
+ isFetching.set(true);
163
+ if (!background) error.set(null);
164
+ try {
165
+ var fetchOpts = { method: 'GET', headers: { 'Content-Type': 'application/json', ...__stxHeaders(options.headers) }, signal: __signal };
166
+ // Published BEFORE it is awaited, so a caller starting in the same tick
167
+ // finds it. The network part only \u2014 transform, cache write and
168
+ // onSuccess stay per-caller, since each may transform differently.
169
+ var netPromise = (async function() {
170
+ var response = await __stxFetch('useQuery', resolvedUrl, fetchOpts);
171
+ if (!response.ok) throw await __stxHttpError(response);
172
+ return await response.json();
173
+ })();
174
+ var entry = { owner: __instanceId, refs: 1, controller: __stxAbort, promise: netPromise };
175
+ _queryInflight[key] = entry;
176
+ __joined = entry;
177
+ // Cleared on settle, both ways. A settled entry left behind would turn
178
+ // dedup into a permanent cache and no request for this key would ever
179
+ // be issued again.
180
+ var releaseEntry = function() { if (_queryInflight[key] === entry) delete _queryInflight[key]; };
181
+ netPromise.then(releaseEntry, releaseEntry);
182
+
183
+ var result = await netPromise;
184
+ if (__signal && __signal.aborted) return;
185
+ var transformed = options.transform ? options.transform(result) : result;
186
+ answered = true;
187
+ show(transformed);
188
+ if (keepKey) __stxQueries.persist(keepKey, transformed, options.scope);
189
+ if (background) error.set(null);
190
+ isStale.set(false);
191
+ _queryCache[key] = { data: transformed, timestamp: Date.now() };
192
+ if (options.onSuccess) options.onSuccess(transformed);
193
+ // Schedule cache eviction
194
+ setTimeout(function() { delete _queryCache[key]; }, cacheTime);
195
+ }
196
+ catch (e) {
197
+ // A superseded/unmounted request rejects with AbortError \u2014 expected;
198
+ // the run that superseded it owns the state (#1871).
199
+ if (e && e.name === 'AbortError') return;
200
+ error.set(e.message || 'Query failed');
201
+ if (options.onError) options.onError(e);
202
+ }
203
+ finally {
204
+ if (!__signal || !__signal.aborted) {
205
+ if (!background) loading.set(false);
206
+ isFetching.set(false);
207
+ }
208
+ }
209
+ };
210
+
211
+ // A refetch nobody asked for does not set loading (see backgroundRun below).
212
+ var backgroundRun = { background: true };
213
+
214
+ if (options.immediate !== false) {
215
+ // Seeded from the device: the kept copy is on screen, so the first
216
+ // fetch refreshes it behind rather than putting a spinner over it.
217
+ onMount(function() { return seeded ? fetchData(backgroundRun) : fetchData(); });
218
+ }
219
+
220
+ // The worker has a newer answer for this URL, or the outbox changed: a
221
+ // write waiting on it is shown on top, and one that reached the server
222
+ // stays shown until the refetch it triggers includes it.
223
+ var unwatch = __stxQueries.watch({
224
+ target: queryTarget,
225
+ updated: function() {
226
+ delete _queryCache[cacheKey || queryTarget().url];
227
+ fetchData(backgroundRun);
228
+ },
229
+ outbox: function(sent) {
230
+ if (sent) {
231
+ base = __stxQueries.overlay(queryTarget(), base, sent.id);
232
+ delete _queryCache[cacheKey || queryTarget().url];
233
+ fetchData(backgroundRun);
234
+ }
235
+ show(base);
236
+ }
237
+ });
238
+ onDestroy(unwatch);
239
+
240
+ // A refetch nobody asked for does not set loading. Both of these refresh
241
+ // data that is ALREADY on screen, so driving the first-load state from them
242
+ // put a spinner over a populated view once a minute, forever \u2014 the reason a
243
+ // polling view could not use this composable at all (#1929). Bind
244
+ // isFetching for a subtle in-flight indicator.
245
+
246
+ // refetchOnFocus \u2014 removed on destroy, like refetchInterval right below.
247
+ // It used to add a listener and never remove it, so every instance leaked
248
+ // one for the life of the page and each SPA navigation added more; every
249
+ // stale listener still fired, refetching for components long gone (#1818).
250
+ if (options.refetchOnFocus) {
251
+ var onVisibility = function() {
252
+ if (!document.hidden) fetchData(backgroundRun);
253
+ };
254
+ document.addEventListener('visibilitychange', onVisibility);
255
+ onDestroy(function() { document.removeEventListener('visibilitychange', onVisibility); });
256
+ }
257
+
258
+ // refetchInterval: poll only while the tab is visible and (if given)
259
+ // enabled holds; optionally stop after an error so a broken endpoint is
260
+ // not hammered every interval in a backgrounded tab (#1870).
261
+ if (options.refetchInterval) {
262
+ var intervalId = setInterval(function() {
263
+ if (typeof document !== 'undefined' && document.hidden) return;
264
+ var en = options.enabled;
265
+ if (typeof en === 'function' ? !en() : en === false) return;
266
+ var p = fetchData(backgroundRun);
267
+ if (options.stopOnError && p && typeof p.then === 'function') {
268
+ p.then(function() { if (error()) clearInterval(intervalId); });
269
+ }
270
+ }, options.refetchInterval);
271
+ onDestroy(function() { clearInterval(intervalId); });
272
+ }
273
+
274
+ // Abort an in-flight request when the owning scope is destroyed (#1871).
275
+ onDestroy(function() { if (__stxAbort) __stxAbort.abort(); });
276
+
277
+ return {
278
+ data: data,
279
+ loading: loading,
280
+ isFetching: isFetching,
281
+ error: error,
282
+ isStale: isStale,
283
+ refetch: fetchData,
284
+ invalidate: function(runOptions) {
285
+ var key = cacheKey || (typeof url === 'function' ? url() : url);
286
+ delete _queryCache[key];
287
+ return fetchData(runOptions);
288
+ }
289
+ };
290
+ }
291
+
292
+ function useMutation(url, options) {
293
+ options = options || {};
294
+ var data = state(null);
295
+ var loading = state(false);
296
+ var error = state(null);
297
+
298
+ var mutate = async function(body) {
299
+ loading.set(true);
300
+ error.set(null);
301
+ var previousData = data();
302
+
303
+ // Optimistic update
304
+ if (options.optimisticData) {
305
+ var optimistic = typeof options.optimisticData === 'function' ? options.optimisticData(body) : options.optimisticData;
306
+ data.set(optimistic);
307
+ }
308
+
309
+ try {
310
+ var resolvedUrl = typeof url === 'function' ? url() : url;
311
+ var fetchOpts = {
312
+ method: options.method || 'POST',
313
+ // A file upload is a FormData body. Stringifying it sent "{}", and
314
+ // the browser has to write its own multipart Content-Type (the
315
+ // boundary lives there), so raw bodies pass through untouched.
316
+ headers: __stxRawBody(body) ? __stxHeaders(options.headers) : { 'Content-Type': 'application/json', ...__stxHeaders(options.headers) },
317
+ body: typeof body === 'string' || __stxRawBody(body) ? body : JSON.stringify(body)
318
+ };
319
+ var response = await __stxFetch('useMutation', resolvedUrl, fetchOpts);
320
+ if (!response.ok) throw await __stxHttpError(response);
321
+ var result = await response.json();
322
+ var transformed = options.transform ? options.transform(result) : result;
323
+ data.set(transformed);
324
+ if (options.onSuccess) options.onSuccess(transformed);
325
+ // Invalidate related queries
326
+ if (options.invalidateQueries) {
327
+ options.invalidateQueries.forEach(function(key) { delete _queryCache[key]; });
328
+ }
329
+ return transformed;
330
+ }
331
+ catch (e) {
332
+ error.set(e.message || 'Mutation failed');
333
+ // Rollback optimistic update
334
+ if (options.optimisticData) data.set(previousData);
335
+ if (options.onError) options.onError(e);
336
+ throw e;
337
+ }
338
+ finally {
339
+ loading.set(false);
340
+ }
341
+ };
342
+
343
+ return {
344
+ data: data,
345
+ loading: loading,
346
+ error: error,
347
+ mutate: mutate,
348
+ reset: function() { data.set(null); error.set(null); loading.set(false); }
349
+ };
350
+ }
351
+ `;
@@ -0,0 +1 @@
1
+ export declare function signalsReactiveCoreBootstrapRuntime(cloakRuntime: string, expressionCompilerRuntime: string, fetchTransportRuntime: string): string;
@@ -0,0 +1,30 @@
1
+ export function signalsReactiveCoreBootstrapRuntime(cloakRuntime, expressionCompilerRuntime, fetchTransportRuntime) {
2
+ return `${cloakRuntime} // ==========================================================================
3
+ // Reactive Core
4
+ // ==========================================================================
5
+
6
+ ${expressionCompilerRuntime}
7
+ let activeEffect = null;
8
+ const effectStack = [];
9
+ const pendingEffects = new Set();
10
+ let isBatching = false;
11
+
12
+ // DevTools Phase 2 (#1747): dev-mode reactivity instrumentation. OFF by
13
+ // default \u2014 even in the dev runtime \u2014 so set()/effect-run stay zero-overhead
14
+ // until window.__stxDevtools.enable() turns counting on. The reactive graph
15
+ // (each signal's subscriber set) is always available via the _effects handle.
16
+ var __stxDevtoolsTracking = false;
17
+ var __stxDevtoolsStats = { signalSets: 0, effectRuns: 0 };
18
+ var __stxEffectId = 0;
19
+ // Phase 3 (#1747): bounded trace buffers, recorded only while tracking.
20
+ var __stxDevtoolsIfTrace = [];
21
+ var __stxDevtoolsQueries = [];
22
+ var __stxDevtoolsMutations = []; // state-change log (signal id + prev/next)
23
+ var __stxSignalId = 0;
24
+ function __stxDevtoolsNow() { return (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now(); }
25
+ function __stxDevtoolsRecordIf(rec) { if (!__stxDevtoolsTracking) return; __stxDevtoolsIfTrace.push(rec); if (__stxDevtoolsIfTrace.length > 100) __stxDevtoolsIfTrace.shift(); }
26
+ function __stxDevtoolsRecordQuery(rec) { if (!__stxDevtoolsTracking) return; __stxDevtoolsQueries.push(rec); if (__stxDevtoolsQueries.length > 100) __stxDevtoolsQueries.shift(); }
27
+ ${fetchTransportRuntime}
28
+ let activeDisposers = null; // Array | null \u2014 when non-null, effects auto-register their dispose fn
29
+ const targetMap = new WeakMap();`;
30
+ }
@@ -0,0 +1,2 @@
1
+ /** Vue-compatible reactive helpers used by the generated client runtime. */
2
+ export declare const SIGNALS_REACTIVE_RUNTIME = " // Vue-compat aliases\n var ref = state;\n\n // reactive() used to be a bare alias of state(), which made it the most\n // dangerous name in the runtime. state({n:0}) returns a SIGNAL, so the Vue\n // shape everyone reaches for silently did nothing:\n //\n // const s = reactive({ count: 0 })\n // s.count // undefined \u2014 a signal has no such property\n // s.count++ // writes an expando onto a function object\n // {{ s.count }} // renders empty, forever, with no warning\n //\n // Backed by one signal PER PROPERTY, created on first touch. That is what\n // makes a read inside an effect track only the field it read, so writing\n // b does not re-run an effect that only read a (#1885).\n var __stxReactiveProxies = new WeakMap();\n\n function reactive(target) {\n // Primitives have no properties to track. Returning them unchanged keeps\n // reactive(0) from silently becoming an object.\n if (!target || typeof target !== 'object') return target;\n var existing = __stxReactiveProxies.get(target);\n if (existing) return existing;\n\n var propSignals = Object.create(null);\n function signalFor(prop) {\n if (!propSignals[prop]) propSignals[prop] = state(target[prop]);\n return propSignals[prop];\n }\n\n var proxy = new Proxy(target, {\n get: function(t, prop, receiver) {\n // Symbols and inherited members are plumbing \u2014 toJSON, Symbol.iterator,\n // array methods. Tracking them would create a signal per method lookup\n // and make every effect depend on the whole object.\n if (typeof prop === 'symbol' || !Object.prototype.hasOwnProperty.call(t, prop))\n return Reflect.get(t, prop, receiver);\n var value = signalFor(prop)();\n // Nested objects are wrapped too, and cached in the WeakMap, so\n // identity is stable across reads \u2014 a fresh proxy each time would\n // break === comparisons and defeat keyed list reuse.\n return (value && typeof value === 'object') ? reactive(value) : value;\n },\n set: function(t, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(t, prop, value);\n var had = Object.prototype.hasOwnProperty.call(t, prop);\n t[prop] = value;\n // Write the plain target FIRST so a signal created later reads the\n // current value, then notify anyone already watching this property.\n if (propSignals[prop]) propSignals[prop].set(value);\n else if (had) signalFor(prop);\n return true;\n },\n deleteProperty: function(t, prop) {\n var had = Object.prototype.hasOwnProperty.call(t, prop);\n delete t[prop];\n if (had && propSignals[prop]) propSignals[prop].set(undefined);\n return true;\n },\n });\n\n __stxReactiveProxies.set(target, proxy);\n return proxy;\n }\n var computed = derived;\n var watch = $watch;\n var watchEffect = function(fn) { return effect(fn); };";