@stacksjs/stx 0.2.406 → 0.2.408

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 (211) hide show
  1. package/dist/app-service-worker.d.ts +120 -0
  2. package/dist/chunk-00g9x6w2.js +2 -0
  3. package/dist/chunk-02g67164.js +2 -0
  4. package/dist/chunk-04tgatyy.js +2 -0
  5. package/dist/{chunk-4g4yz97f.js → chunk-0a315nbf.js} +3 -3
  6. package/dist/{chunk-zwb8wv5p.js → chunk-0akydm2d.js} +1 -1
  7. package/dist/{chunk-tfy07tmv.js → chunk-0btmm4m2.js} +1 -1
  8. package/dist/{chunk-g0w8dyat.js → chunk-0c2h69k2.js} +1 -1
  9. package/dist/{chunk-aa4ss5pb.js → chunk-0pkk226n.js} +1 -1
  10. package/dist/{chunk-6de3hczw.js → chunk-0we9nw1d.js} +1 -1
  11. package/dist/chunk-178n9c40.js +2 -0
  12. package/dist/{chunk-2r399td7.js → chunk-1fs9jvpb.js} +1 -1
  13. package/dist/chunk-1hc58sh2.js +2 -0
  14. package/dist/chunk-1q4jrkhw.js +2 -0
  15. package/dist/chunk-1qembpzh.js +2 -0
  16. package/dist/chunk-1qq26zt0.js +2 -0
  17. package/dist/{chunk-7q06md6v.js → chunk-1te8k8gp.js} +1 -1
  18. package/dist/{chunk-jw6s8rkk.js → chunk-1ws3xcea.js} +2 -2
  19. package/dist/{chunk-z9a0ft6h.js → chunk-213jwgpx.js} +1 -1
  20. package/dist/{chunk-1yvx8s3v.js → chunk-26r88x1t.js} +2 -2
  21. package/dist/{chunk-k4x5we49.js → chunk-27fgag95.js} +2 -2
  22. package/dist/chunk-2c6t60vw.js +2 -0
  23. package/dist/{chunk-x7qyx7vn.js → chunk-2fw05hs2.js} +1 -1
  24. package/dist/{chunk-0seyntda.js → chunk-38wvkv3s.js} +1 -1
  25. package/dist/chunk-3w6z6tw9.js +2 -0
  26. package/dist/chunk-3za7m29m.js +2 -0
  27. package/dist/{chunk-ypw4egcv.js → chunk-4m7ajama.js} +1 -1
  28. package/dist/{chunk-g81ymdat.js → chunk-4zcbj36p.js} +2 -2
  29. package/dist/{chunk-yh9apppb.js → chunk-50pszj17.js} +1 -1
  30. package/dist/{chunk-59pakqdv.js → chunk-563shnkz.js} +2 -2
  31. package/dist/{chunk-h1yb87ep.js → chunk-5r4s9s38.js} +2 -2
  32. package/dist/chunk-603x5gb2.js +2 -0
  33. package/dist/{chunk-afwbqeb2.js → chunk-6jrczd12.js} +2 -2
  34. package/dist/{chunk-abs56gdt.js → chunk-6kd5jjwc.js} +1 -1
  35. package/dist/{chunk-ewxbx67c.js → chunk-6kdrncsx.js} +1 -1
  36. package/dist/{chunk-pkspqh0m.js → chunk-72rwcbp6.js} +1 -1
  37. package/dist/{chunk-4m4n1sfc.js → chunk-76w34xne.js} +1 -1
  38. package/dist/chunk-7ypm243n.js +2 -0
  39. package/dist/{chunk-z80v5h5h.js → chunk-8036mdat.js} +2 -2
  40. package/dist/{chunk-46zx4pt8.js → chunk-82pd4b5w.js} +1 -1
  41. package/dist/chunk-8ds7rrdc.js +2 -0
  42. package/dist/chunk-8w2mqdnv.js +2 -0
  43. package/dist/chunk-8x05b790.js +2 -0
  44. package/dist/{chunk-pqhpcxsd.js → chunk-90b2vt2n.js} +1 -1
  45. package/dist/{chunk-arjhs9bb.js → chunk-920779jx.js} +2 -2
  46. package/dist/chunk-934eeghd.js +2 -0
  47. package/dist/{chunk-245ft0zp.js → chunk-9e8t0twa.js} +1 -1
  48. package/dist/{chunk-wpsx5avz.js → chunk-9fqp72ze.js} +1 -1
  49. package/dist/chunk-9wze2290.js +2 -0
  50. package/dist/{chunk-dj658wyq.js → chunk-9xew0kgf.js} +1 -1
  51. package/dist/{chunk-ca57sg6v.js → chunk-akwd34xt.js} +2 -2
  52. package/dist/{chunk-rqr735w8.js → chunk-anydpa34.js} +1 -1
  53. package/dist/{chunk-ffdxdgep.js → chunk-aq1xq0r4.js} +2 -2
  54. package/dist/{chunk-9dap2hdv.js → chunk-avaywwsc.js} +2 -2
  55. package/dist/{chunk-36rnwhn2.js → chunk-bbt3tp6f.js} +1 -1
  56. package/dist/{chunk-n4197kjq.js → chunk-bjar18jd.js} +1 -1
  57. package/dist/{chunk-twg0y6ga.js → chunk-bjcsc6wx.js} +1 -1
  58. package/dist/{chunk-akzmq0jr.js → chunk-bn1edb1y.js} +2 -2
  59. package/dist/{chunk-503wfstj.js → chunk-btd7ds3x.js} +1 -1
  60. package/dist/{chunk-8mm86z5w.js → chunk-bwsxym3d.js} +1 -1
  61. package/dist/{chunk-c1f1vtjt.js → chunk-cj3adc77.js} +1 -1
  62. package/dist/{chunk-sjc7x8y1.js → chunk-cqchpe34.js} +396 -165
  63. package/dist/chunk-ct1jwd4r.js +2 -0
  64. package/dist/{chunk-znt6t1dz.js → chunk-ej16bgrr.js} +2 -2
  65. package/dist/{chunk-2c23jad1.js → chunk-esq1k7fj.js} +2 -2
  66. package/dist/{chunk-ayhhvep9.js → chunk-f6s7d1jq.js} +2 -2
  67. package/dist/{chunk-bds4s9d8.js → chunk-fcnrgxck.js} +1 -1
  68. package/dist/chunk-fphs5g19.js +2 -0
  69. package/dist/{chunk-stdkw5st.js → chunk-fpwzacpm.js} +1 -1
  70. package/dist/chunk-gbmeh7jg.js +3 -0
  71. package/dist/{chunk-81zw5vw5.js → chunk-gc06g35w.js} +1 -1
  72. package/dist/{chunk-rctgq5xp.js → chunk-gcvj5zdy.js} +3 -3
  73. package/dist/{chunk-1nnskved.js → chunk-gengvwb7.js} +3 -3
  74. package/dist/{chunk-63dyh42m.js → chunk-gjrgr367.js} +2 -2
  75. package/dist/{chunk-69c5rv6n.js → chunk-gna6dc48.js} +169 -169
  76. package/dist/{chunk-pyyccs6a.js → chunk-gvbf1mhs.js} +1 -1
  77. package/dist/chunk-h1r17awz.js +2 -0
  78. package/dist/chunk-ha46rg9g.js +2 -0
  79. package/dist/chunk-hcvjstmr.js +2 -0
  80. package/dist/{chunk-a01sf1sc.js → chunk-hdysywd8.js} +1 -1
  81. package/dist/{chunk-55g4qm7m.js → chunk-hx998w7n.js} +1 -1
  82. package/dist/chunk-j3r97xs5.js +2 -0
  83. package/dist/chunk-j5qeaprt.js +2 -0
  84. package/dist/chunk-jxvmf02k.js +2 -0
  85. package/dist/{chunk-8t3h7fsk.js → chunk-k80sn8d1.js} +1 -1
  86. package/dist/chunk-kajym1cx.js +2 -0
  87. package/dist/{chunk-f02g2h4p.js → chunk-kbwhs5df.js} +2 -2
  88. package/dist/{chunk-4n6ekt06.js → chunk-kmsyvaex.js} +1 -1
  89. package/dist/{chunk-4tsjysng.js → chunk-kvmx7dnb.js} +1 -1
  90. package/dist/{chunk-s1gwy2rp.js → chunk-m072c38p.js} +2 -2
  91. package/dist/{chunk-jpnja3jy.js → chunk-mgrckqww.js} +1 -1
  92. package/dist/{chunk-971yqxa2.js → chunk-mq5ewmz6.js} +1 -1
  93. package/dist/{chunk-sptvg80e.js → chunk-mrahwn5v.js} +1 -1
  94. package/dist/{chunk-vyq86x5c.js → chunk-n2swas11.js} +1 -1
  95. package/dist/{chunk-zgzzn9qk.js → chunk-n9cqrw9j.js} +1 -1
  96. package/dist/{chunk-3sea73fx.js → chunk-naw4jt7j.js} +1 -1
  97. package/dist/{chunk-1n2ng8nx.js → chunk-ny67c03k.js} +1 -1
  98. package/dist/chunk-p0m4ty6g.js +2 -0
  99. package/dist/chunk-p32x2apf.js +2 -0
  100. package/dist/{chunk-8bg1qmhg.js → chunk-p4zrvt5f.js} +1 -1
  101. package/dist/{chunk-0tnsyynz.js → chunk-p5wp0ce6.js} +2 -2
  102. package/dist/{chunk-mywrb5fy.js → chunk-pcxp4r9n.js} +1 -1
  103. package/dist/{chunk-me7ypzw9.js → chunk-pdfjy3at.js} +2 -2
  104. package/dist/chunk-pjrn29gg.js +2 -0
  105. package/dist/chunk-q738pwv6.js +2 -0
  106. package/dist/{chunk-w6n5c479.js → chunk-qmmp5kb5.js} +1 -1
  107. package/dist/{chunk-015p3jq5.js → chunk-qn5srnj3.js} +1 -1
  108. package/dist/{chunk-1vrk5y92.js → chunk-qvnbnsv9.js} +1 -1
  109. package/dist/{chunk-z8zmp74b.js → chunk-rt3cx932.js} +1025 -58
  110. package/dist/{chunk-7ba7x6jt.js → chunk-rz9f3zqz.js} +2 -2
  111. package/dist/{chunk-dxjtszaa.js → chunk-s8jd13nb.js} +1 -1
  112. package/dist/{chunk-qem2tw9r.js → chunk-s9za1vvd.js} +1 -1
  113. package/dist/{chunk-r909bddf.js → chunk-spxsw4mp.js} +1 -1
  114. package/dist/chunk-ssn5k77d.js +2 -0
  115. package/dist/chunk-sy9pfe3h.js +2 -0
  116. package/dist/{chunk-0nhpymyy.js → chunk-t1htzg9e.js} +1 -1
  117. package/dist/{chunk-rkzfwgr8.js → chunk-t1tdjjht.js} +1 -1
  118. package/dist/{chunk-1x6c4ys1.js → chunk-t5ja7qkn.js} +131 -34
  119. package/dist/{chunk-rx0cntdm.js → chunk-td08rnk3.js} +2 -2
  120. package/dist/chunk-tgadbsd4.js +2 -0
  121. package/dist/{chunk-xakdgn9h.js → chunk-tgrpp58r.js} +1 -1
  122. package/dist/{chunk-pgeh4g3a.js → chunk-tkyrk66a.js} +1 -1
  123. package/dist/chunk-tpcmn119.js +2 -0
  124. package/dist/{chunk-0n054h7w.js → chunk-v3nwkveg.js} +1 -1
  125. package/dist/{chunk-83tefmh1.js → chunk-vsbmc9kt.js} +1 -1
  126. package/dist/{chunk-qcpnfw0k.js → chunk-vx86cf4r.js} +1 -1
  127. package/dist/{chunk-yn8qq8tn.js → chunk-w6hqh4z5.js} +2 -2
  128. package/dist/{chunk-k3wcezqg.js → chunk-w9n12yzf.js} +3 -3
  129. package/dist/chunk-wkanrfb3.js +2 -0
  130. package/dist/chunk-wvegegmb.js +2 -0
  131. package/dist/{chunk-seqmzr8k.js → chunk-xq1acw1r.js} +1 -1
  132. package/dist/{chunk-vtjegbgy.js → chunk-xsng1mtq.js} +1 -1
  133. package/dist/chunk-xv9bhvye.js +12 -0
  134. package/dist/{chunk-gyccx2pr.js → chunk-z52f4zcy.js} +2 -2
  135. package/dist/{chunk-vtmhh3dp.js → chunk-z5rwnnk1.js} +2 -2
  136. package/dist/{chunk-m8bdy2wt.js → chunk-zcz9rs6p.js} +1 -1
  137. package/dist/{chunk-1phxzej9.js → chunk-zpcnbdhn.js} +2 -2
  138. package/dist/{chunk-wxkn47vk.js → chunk-zq4ssxj9.js} +1 -1
  139. package/dist/cli.js +14 -14
  140. package/dist/composables/index.d.ts +10 -1
  141. package/dist/composables/index.js +6 -1
  142. package/dist/composables/use-cached-query.d.ts +18 -0
  143. package/dist/composables/use-cached-query.js +27 -0
  144. package/dist/composables/use-offline.d.ts +18 -0
  145. package/dist/composables/use-offline.js +17 -0
  146. package/dist/composables/use-outbox.d.ts +19 -27
  147. package/dist/composables/use-outbox.js +100 -16
  148. package/dist/composables/use-query.d.ts +2 -0
  149. package/dist/composables/use-storage.d.ts +7 -3
  150. package/dist/composables/use-storage.js +22 -13
  151. package/dist/craft-entry.js +1 -1
  152. package/dist/craft.js +1 -1
  153. package/dist/database.js +1 -1
  154. package/dist/index.d.ts +10 -0
  155. package/dist/index.js +5 -0
  156. package/dist/offline/app-service-worker.d.ts +61 -13
  157. package/dist/offline/app-service-worker.js +398 -58
  158. package/dist/offline/kept-store.d.ts +67 -0
  159. package/dist/offline/kept-store.js +252 -0
  160. package/dist/offline/query-cache.d.ts +137 -0
  161. package/dist/offline/query-cache.js +260 -0
  162. package/dist/pwa.js +2 -2
  163. package/dist/runtime-globals.js +3 -0
  164. package/dist/signals.js +123 -24
  165. package/dist/ssg.js +2 -2
  166. package/dist/stx-module.d.ts +3 -0
  167. package/dist/stx.d.ts +48 -1
  168. package/dist/unresolved-identifiers.js +2 -0
  169. package/dist/visual-testing.js +1 -1
  170. package/package.json +5 -5
  171. package/stx-module.d.ts +3 -0
  172. package/stx.d.ts +48 -1
  173. package/dist/chunk-4hqaxar9.js +0 -2
  174. package/dist/chunk-4md4tj27.js +0 -3
  175. package/dist/chunk-53x9hrx3.js +0 -2
  176. package/dist/chunk-5e2d3grq.js +0 -2
  177. package/dist/chunk-5s44f83p.js +0 -2
  178. package/dist/chunk-62btdm51.js +0 -2
  179. package/dist/chunk-68gspceh.js +0 -2
  180. package/dist/chunk-6cbjhg0y.js +0 -2
  181. package/dist/chunk-8vg5tpts.js +0 -2
  182. package/dist/chunk-b26mjv83.js +0 -2
  183. package/dist/chunk-bmfg13wx.js +0 -2
  184. package/dist/chunk-ccct2hsa.js +0 -2
  185. package/dist/chunk-d8yksesg.js +0 -2
  186. package/dist/chunk-db6fm81v.js +0 -2
  187. package/dist/chunk-emx4ey5d.js +0 -2
  188. package/dist/chunk-gxc02n32.js +0 -2
  189. package/dist/chunk-hch1t137.js +0 -2
  190. package/dist/chunk-jc5kqj3t.js +0 -2
  191. package/dist/chunk-jqm6tbtb.js +0 -2
  192. package/dist/chunk-k6vz8455.js +0 -2
  193. package/dist/chunk-m7b67r66.js +0 -12
  194. package/dist/chunk-mtata78t.js +0 -2
  195. package/dist/chunk-n1yz08j4.js +0 -2
  196. package/dist/chunk-nsese4as.js +0 -2
  197. package/dist/chunk-pqskmpz0.js +0 -2
  198. package/dist/chunk-qa333652.js +0 -2
  199. package/dist/chunk-qcbn5mrw.js +0 -2
  200. package/dist/chunk-sgmqfphy.js +0 -2
  201. package/dist/chunk-wj66sab5.js +0 -2
  202. package/dist/chunk-wqgyb4zb.js +0 -2
  203. package/dist/chunk-wszdgqe3.js +0 -2
  204. package/dist/chunk-wz7ca99x.js +0 -2
  205. package/dist/chunk-xqz9dqef.js +0 -2
  206. package/dist/chunk-xvsz1qy3.js +0 -2
  207. package/dist/chunk-xw23twxw.js +0 -2
  208. package/dist/chunk-xz870mf2.js +0 -2
  209. package/dist/chunk-y3cz15x3.js +0 -2
  210. package/dist/chunk-yf0v44v8.js +0 -2
  211. package/dist/chunk-zawdn9z8.js +0 -2
@@ -1,6 +1,7 @@
1
1
  import { importsSignalDeclarations } from "./imported-signals.js";
2
2
  export const STX_RUNTIME_GLOBALS = [
3
3
  "batch",
4
+ "cachedQuery",
4
5
  "clearServerData",
5
6
  "computed",
6
7
  "configureFetch",
@@ -12,6 +13,7 @@ export const STX_RUNTIME_GLOBALS = [
12
13
  "defineStore",
13
14
  "derived",
14
15
  "effect",
16
+ "flushKeptState",
15
17
  "forgetKeptState",
16
18
  "goBack",
17
19
  "goForward",
@@ -34,6 +36,7 @@ export const STX_RUNTIME_GLOBALS = [
34
36
  "ref",
35
37
  "refresh",
36
38
  "registerStoresClient",
39
+ "setKeptScope",
37
40
  "setRouteParams",
38
41
  "state",
39
42
  "untrack",
package/dist/signals.js CHANGED
@@ -2,6 +2,8 @@ import { state, derived, effect, batch, onMount, onDestroy, isSignal, isDerived,
2
2
  import { runtimeDirectiveNamesLiteral, runtimeEventRegexLiteral, runtimeHandledXAttrsLiteral } from "./runtime-globals.js";
3
3
  import { createModelSignal } from "./component-model.js";
4
4
  import { readHydratedData, clearServerData } from "./composables/use-fetch.js";
5
+ import { createKeptStore, indexedDbBackend } from "./offline/kept-store.js";
6
+ import { createQueryCache, queryTargetMatches } from "./offline/query-cache.js";
5
7
 
6
8
  export * from "./signals-api.js";
7
9
  export function generateSignalsRuntime() {
@@ -1800,15 +1802,44 @@ else if (immediate) {
1800
1802
  var staleTime = options.staleTime || 0;
1801
1803
  var cacheTime = options.cacheTime || 300000; // 5 min default
1802
1804
  var cacheKey = options.cacheKey || (typeof url === 'function' ? null : url);
1803
- var data = state(options.initialData || null);
1804
- var loading = state(true);
1805
+ // keep: the answer is kept on the device per account (setKeptScope, or
1806
+ // options.scope) and seeds the next visit synchronously, refreshed behind.
1807
+ // true keeps it under the query's key; a string names it.
1808
+ var keepKey = options.keep ? (typeof options.keep === 'string' ? options.keep : cacheKey) : null;
1809
+ var queryTarget = function() {
1810
+ var resolved = null;
1811
+ try { resolved = typeof url === 'function' ? url() : url; } catch (e) {}
1812
+ return { key: cacheKey || keepKey || resolved || '', url: resolved };
1813
+ };
1814
+ // What is shown is the last answer with the outbox's waiting writes on
1815
+ // top, so a change made offline is not undone by a refetch.
1816
+ var base = options.initialData || null;
1817
+ var seeded = keepKey ? __stxQueries.seed(keepKey, options.scope) : undefined;
1818
+ if (seeded) base = seeded.data;
1819
+ var data = state(seeded ? __stxQueries.overlay(queryTarget(), base) : base);
1820
+ var show = function(value) {
1821
+ base = value;
1822
+ data.set(__stxQueries.overlay(queryTarget(), value));
1823
+ };
1824
+ var answered = false;
1825
+ var loading = state(!seeded);
1805
1826
  // See useFetch: loading means "nothing to show yet", isFetching means "a
1806
1827
  // request is open" \u2014 including a background refresh, which is the case that
1807
1828
  // makes the distinction necessary (#1929).
1808
1829
  var isFetching = state(true);
1809
1830
  var error = state(null);
1810
- var isStale = state(false);
1831
+ var isStale = state(!!seeded);
1811
1832
  if (options.suspense) registerSuspense(loading, error);
1833
+ // Kept too large for a synchronous read: it arrives a moment later, and
1834
+ // shows unless an answer came first.
1835
+ if (keepKey && !seeded) {
1836
+ __stxQueries.restore(keepKey, options.scope).then(function(found) {
1837
+ if (!found || answered) return;
1838
+ show(found.data);
1839
+ loading.set(false);
1840
+ isStale.set(true);
1841
+ });
1842
+ }
1812
1843
 
1813
1844
  // Per-run AbortController: a newer run aborts the previous in-flight one and
1814
1845
  // onDestroy aborts the last, so a resolved request can't write into a
@@ -1836,7 +1867,8 @@ else if (immediate) {
1836
1867
  // Check cache
1837
1868
  var cached = _queryCache[key];
1838
1869
  if (cached && (Date.now() - cached.timestamp < staleTime)) {
1839
- data.set(cached.data);
1870
+ answered = true;
1871
+ show(cached.data);
1840
1872
  if (!background) loading.set(false);
1841
1873
  isFetching.set(false);
1842
1874
  isStale.set(false);
@@ -1846,7 +1878,7 @@ else if (immediate) {
1846
1878
 
1847
1879
  // Stale-while-revalidate
1848
1880
  if (cached) {
1849
- data.set(cached.data);
1881
+ show(cached.data);
1850
1882
  isStale.set(true);
1851
1883
  }
1852
1884
 
@@ -1864,7 +1896,9 @@ else if (immediate) {
1864
1896
  try {
1865
1897
  var joinedResult = await shared.promise;
1866
1898
  var joinedTransformed = options.transform ? options.transform(joinedResult) : joinedResult;
1867
- data.set(joinedTransformed);
1899
+ answered = true;
1900
+ show(joinedTransformed);
1901
+ if (keepKey) __stxQueries.persist(keepKey, joinedTransformed, options.scope);
1868
1902
  if (background) error.set(null);
1869
1903
  isStale.set(false);
1870
1904
  if (options.onSuccess) options.onSuccess(joinedTransformed);
@@ -1918,7 +1952,9 @@ else if (immediate) {
1918
1952
  var result = await netPromise;
1919
1953
  if (__signal && __signal.aborted) return;
1920
1954
  var transformed = options.transform ? options.transform(result) : result;
1921
- data.set(transformed);
1955
+ answered = true;
1956
+ show(transformed);
1957
+ if (keepKey) __stxQueries.persist(keepKey, transformed, options.scope);
1922
1958
  if (background) error.set(null);
1923
1959
  isStale.set(false);
1924
1960
  _queryCache[key] = { data: transformed, timestamp: Date.now() };
@@ -1941,16 +1977,40 @@ finally {
1941
1977
  }
1942
1978
  };
1943
1979
 
1980
+ // A refetch nobody asked for does not set loading (see backgroundRun below).
1981
+ var backgroundRun = { background: true };
1982
+
1944
1983
  if (options.immediate !== false) {
1945
- onMount(fetchData);
1946
- }
1984
+ // Seeded from the device: the kept copy is on screen, so the first
1985
+ // fetch refreshes it behind rather than putting a spinner over it.
1986
+ onMount(function() { return seeded ? fetchData(backgroundRun) : fetchData(); });
1987
+ }
1988
+
1989
+ // The worker has a newer answer for this URL, or the outbox changed: a
1990
+ // write waiting on it is shown on top, and one that reached the server
1991
+ // stays shown until the refetch it triggers includes it.
1992
+ var unwatch = __stxQueries.watch({
1993
+ target: queryTarget,
1994
+ updated: function() {
1995
+ delete _queryCache[cacheKey || queryTarget().url];
1996
+ fetchData(backgroundRun);
1997
+ },
1998
+ outbox: function(sent) {
1999
+ if (sent) {
2000
+ base = __stxQueries.overlay(queryTarget(), base, sent.id);
2001
+ delete _queryCache[cacheKey || queryTarget().url];
2002
+ fetchData(backgroundRun);
2003
+ }
2004
+ show(base);
2005
+ }
2006
+ });
2007
+ onDestroy(unwatch);
1947
2008
 
1948
2009
  // A refetch nobody asked for does not set loading. Both of these refresh
1949
2010
  // data that is ALREADY on screen, so driving the first-load state from them
1950
2011
  // put a spinner over a populated view once a minute, forever \u2014 the reason a
1951
2012
  // polling view could not use this composable at all (#1929). Bind
1952
2013
  // isFetching for a subtle in-flight indicator.
1953
- var backgroundRun = { background: true };
1954
2014
 
1955
2015
  // refetchOnFocus \u2014 removed on destroy, like refetchInterval right below.
1956
2016
  // It used to add a listener and never remove it, so every instance leaked
@@ -6222,29 +6282,62 @@ catch (e) {} }
6222
6282
 
6223
6283
  // A value kept between visits, for a phone app between launches: the tab a
6224
6284
  // user opens right after starting the app draws last time's data at once
6225
- // and the fresh answer replaces it. Kept in localStorage under stx:kept:,
6226
- // in a scope such as the signed-in account, so one person's data is never
6227
- // shown to another. A scope of false, null or '' keeps nothing (a plain
6228
- // state), for a page or a visitor that should not leave data behind.
6229
- // forgetKeptState(scope) removes a scope's values, or every kept value.
6285
+ // and the fresh answer replaces it. Kept under stx:kept:, in a scope such as
6286
+ // the signed-in account, so one person's data is never shown to another. A
6287
+ // scope of false, null or '' keeps nothing (a plain state), for a page or a
6288
+ // visitor that should not leave data behind; no scope at all uses the one
6289
+ // given to setKeptScope. forgetKeptState(scope) removes a scope's values, or
6290
+ // every kept value.
6291
+ //
6292
+ // Stored by the kept store (offline/kept-store.ts): small values in
6293
+ // localStorage, readable on the first draw, large ones in IndexedDB, written
6294
+ // off the critical path and read back asynchronously. Values kept before it
6295
+ // are read where they are.
6230
6296
  var STX_KEPT_PREFIX = 'stx:kept:';
6297
+ var __stxKept = (${createKeptStore.toString()})(undefined, ${indexedDbBackend.toString()});
6298
+ var __stxQueries = (${createQueryCache.toString()})({ state: state, kept: __stxKept, prefix: STX_KEPT_PREFIX, matches: ${queryTargetMatches.toString()} });
6231
6299
  function stxKeptPrefix(scope) {
6232
6300
  return STX_KEPT_PREFIX + (scope === undefined || scope === null || scope === '' ? '' : String(scope) + ':');
6233
6301
  }
6234
6302
  function keptState(name, initialValue, options) {
6235
6303
  var scope = options ? options.scope : undefined;
6304
+ if (scope === undefined) scope = __stxQueries.scope();
6236
6305
  if (scope === false || scope === null || scope === '') return state(initialValue);
6237
- return useLocalStorage(stxKeptPrefix(scope) + name, initialValue);
6306
+ var key = stxKeptPrefix(scope) + name;
6307
+ var hit = __stxKept.peek(key);
6308
+ var s = state(hit ? hit.value : initialValue);
6309
+ var restored = {};
6310
+ var touched = false;
6311
+ s.subscribe(function(value) {
6312
+ if (value === restored) return;
6313
+ touched = true;
6314
+ __stxKept.set(key, value);
6315
+ });
6316
+ // Large values are kept where only an asynchronous read reaches: they
6317
+ // arrive a moment later, unless the screen set its own first.
6318
+ if (!hit) {
6319
+ __stxKept.load(key).then(function(found) {
6320
+ if (!found || touched) return;
6321
+ restored = found.value;
6322
+ s.set(found.value);
6323
+ });
6324
+ }
6325
+ return s;
6238
6326
  }
6239
6327
  function forgetKeptState(scope) {
6240
- try {
6241
- var prefix = stxKeptPrefix(scope);
6242
- for (var i = localStorage.length - 1; i >= 0; i--) {
6243
- var key = localStorage.key(i);
6244
- if (key && key.indexOf(prefix) === 0) localStorage.removeItem(key);
6245
- }
6246
- }
6247
- catch (e) {}
6328
+ return __stxKept.forget(stxKeptPrefix(scope));
6329
+ }
6330
+ // The account kept state and cached queries belong to when they name none.
6331
+ function setKeptScope(scope) {
6332
+ __stxQueries.setScope(scope);
6333
+ }
6334
+ // Finish writing what is kept (before signing out, or in a test).
6335
+ function flushKeptState() {
6336
+ return __stxKept.flush();
6337
+ }
6338
+ // A query kept per account and refreshed behind: see offline/query-cache.ts.
6339
+ function cachedQuery(key, options) {
6340
+ return __stxQueries.cachedQuery(key, options);
6248
6341
  }
6249
6342
 
6250
6343
  // Reactive cookie binding. Mirrors useLocalStorage's shape: returns a string-
@@ -7309,6 +7402,9 @@ catch (e) {} }
7309
7402
  useSessionStorage,
7310
7403
  keptState,
7311
7404
  forgetKeptState,
7405
+ setKeptScope,
7406
+ flushKeptState,
7407
+ cachedQuery,
7312
7408
  useCookie,
7313
7409
  useId,
7314
7410
  useReactiveProp,
@@ -8143,6 +8239,9 @@ else {
8143
8239
  window.useSessionStorage = useSessionStorage;
8144
8240
  window.keptState = keptState;
8145
8241
  window.forgetKeptState = forgetKeptState;
8242
+ window.setKeptScope = setKeptScope;
8243
+ window.flushKeptState = flushKeptState;
8244
+ window.cachedQuery = cachedQuery;
8146
8245
  window.useEventListener = useEventListener;
8147
8246
  window.useWebSocket = useWebSocket;
8148
8247
  window.useColorMode = useColorMode;
package/dist/ssg.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Bk as Uq,Ck as Iq,Gk as wq}from"./chunk-afwbqeb2.js";import{Hk as Eq,Ik as Tq,Jk as Dq}from"./chunk-rqr735w8.js";import{cl as _q,fl as zq,gl as Aq}from"./chunk-63dyh42m.js";import"./chunk-1nnskved.js";import"./chunk-dxjtszaa.js";import{Hr as n,Vp as C,Ym as Oq,oo as l,ro as Hq}from"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import{xt as Xq}from"./chunk-4g4yz97f.js";import{Ct as d}from"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import{hu as Bq}from"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import{Dw as Yq,Ew as Vq,Fw as jq,Gw as Gq,Hw as Lq,Iw as Nq}from"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import{bx as P}from"./chunk-x7qyx7vn.js";import X from"fs";import j from"path";import{createHash as xq}from"crypto";function yq(q){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(q).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return q}}var Pq=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Cq(q){return Bun.hash(q).toString(16)}function Qq(q,Z={}){if(!q.includes('type="stx/island"'))return{html:q,chunks:[]};let $=new Map,Q=q.replace(Pq,(J,W,_,z)=>{let L=z.trim();if(!L)return J;if(/\bdata-stx-src=/.test(_))return J;if(Z.minify)L=yq(L);let A=Cq(L);if(!$.has(A))$.set(A,L);let B=Z.integrity?` data-stx-integrity="sha384-${xq("sha384").update(L).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${A}.js"${B}${_}></script>`}),K=Array.from($,([J,W])=>({hash:J,code:W}));return{html:Q,chunks:K}}var gq=new Set(["visible","idle"]);function Zq(q){if(!q.includes("data-stx-src="))return q;let Z=new Map,$=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,Q;while((Q=$.exec(q))!==null)Z.set(Q[1],Q[2]);let K=new Set,J=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,W;while((W=J.exec(q))!==null)if(gq.has(Z.get(W[1])||""))K.add(W[2]);let _=q.lastIndexOf("</head>");if(K.size===0||_===-1)return q;let z=Array.from(K).filter((L)=>!q.includes(`rel="prefetch" href="${L}"`)).map((L)=>`<link rel="prefetch" href="${L}" as="script">`).join("");if(!z)return q;return q.slice(0,_)+z+q.slice(_)}var fq=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function h(q){let Z=q.trim();if(!Z)return null;let $=/^https?:\/\//i.test(Z)?Z:`https://${Z}`;try{return new URL($).origin+new URL($).pathname.replace(/\/$/,"")}catch{return null}}function mq(q){for(let Z of fq){let $=q[Z];if(!$)continue;let Q=h($);if(Q)return{url:Q,source:"env",via:Z}}return null}function $q(q){if(!q||typeof q!=="object")return null;let Z=q,$=Z.site?.url??Z.url??Z.app?.url;return typeof $==="string"?h($):null}async function dq(q){let{existsSync:Z}=await import("fs"),$=await import("path");for(let Q of["site.config.ts","site.config.js",".config/site.config.ts"]){let K=$.resolve(q,Q);if(!Z(K))continue;try{let J=await import(K),W=$q(J.default??J);if(W)return W}catch{}}return null}async function Kq(q={}){let Z=q.cwd??process.cwd(),$=q.env??process.env;if(q.explicit){let W=h(q.explicit);if(W)return{url:W,source:"option"}}let Q=$q(q.stxConfig);if(Q)return{url:Q,source:"stx.config",via:"site.url"};let K=await dq(Z);if(K)return{url:K,source:"site.config",via:"url"};let J=mq($);if(J)return J;return{url:"http://localhost",source:"fallback"}}function Wq(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
2
+ import{Ik as Uq,Jk as Iq,Nk as wq}from"./chunk-6jrczd12.js";import{Ok as Eq,Pk as Tq,Qk as Dq}from"./chunk-anydpa34.js";import{jl as _q,ml as zq,nl as Aq}from"./chunk-gjrgr367.js";import"./chunk-gengvwb7.js";import"./chunk-s8jd13nb.js";import{Or as n,aq as C,dn as Oq,vo as l,yo as Hq}from"./chunk-cqchpe34.js";import"./chunk-aq1xq0r4.js";import"./chunk-zcz9rs6p.js";import"./chunk-v3nwkveg.js";import"./chunk-9fqp72ze.js";import"./chunk-0btmm4m2.js";import{Et as Xq}from"./chunk-0a315nbf.js";import{Jt as d}from"./chunk-tkyrk66a.js";import"./chunk-213jwgpx.js";import"./chunk-5r4s9s38.js";import"./chunk-1te8k8gp.js";import{ou as Bq}from"./chunk-zpcnbdhn.js";import"./chunk-rz9f3zqz.js";import"./chunk-bn1edb1y.js";import"./chunk-cj3adc77.js";import"./chunk-t1htzg9e.js";import"./chunk-gbmeh7jg.js";import{Kw as Yq,Lw as Vq,Mw as jq,Nw as Gq,Ow as Lq,Pw as Nq}from"./chunk-rt3cx932.js";import"./chunk-vx86cf4r.js";import"./chunk-563shnkz.js";import{ix as P}from"./chunk-2fw05hs2.js";import X from"fs";import j from"path";import{createHash as xq}from"crypto";function yq(q){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(q).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return q}}var Pq=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Cq(q){return Bun.hash(q).toString(16)}function Qq(q,Z={}){if(!q.includes('type="stx/island"'))return{html:q,chunks:[]};let $=new Map,Q=q.replace(Pq,(J,W,_,z)=>{let L=z.trim();if(!L)return J;if(/\bdata-stx-src=/.test(_))return J;if(Z.minify)L=yq(L);let A=Cq(L);if(!$.has(A))$.set(A,L);let B=Z.integrity?` data-stx-integrity="sha384-${xq("sha384").update(L).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${A}.js"${B}${_}></script>`}),K=Array.from($,([J,W])=>({hash:J,code:W}));return{html:Q,chunks:K}}var gq=new Set(["visible","idle"]);function Zq(q){if(!q.includes("data-stx-src="))return q;let Z=new Map,$=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,Q;while((Q=$.exec(q))!==null)Z.set(Q[1],Q[2]);let K=new Set,J=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,W;while((W=J.exec(q))!==null)if(gq.has(Z.get(W[1])||""))K.add(W[2]);let _=q.lastIndexOf("</head>");if(K.size===0||_===-1)return q;let z=Array.from(K).filter((L)=>!q.includes(`rel="prefetch" href="${L}"`)).map((L)=>`<link rel="prefetch" href="${L}" as="script">`).join("");if(!z)return q;return q.slice(0,_)+z+q.slice(_)}var fq=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function h(q){let Z=q.trim();if(!Z)return null;let $=/^https?:\/\//i.test(Z)?Z:`https://${Z}`;try{return new URL($).origin+new URL($).pathname.replace(/\/$/,"")}catch{return null}}function mq(q){for(let Z of fq){let $=q[Z];if(!$)continue;let Q=h($);if(Q)return{url:Q,source:"env",via:Z}}return null}function $q(q){if(!q||typeof q!=="object")return null;let Z=q,$=Z.site?.url??Z.url??Z.app?.url;return typeof $==="string"?h($):null}async function dq(q){let{existsSync:Z}=await import("fs"),$=await import("path");for(let Q of["site.config.ts","site.config.js",".config/site.config.ts"]){let K=$.resolve(q,Q);if(!Z(K))continue;try{let J=await import(K),W=$q(J.default??J);if(W)return W}catch{}}return null}async function Kq(q={}){let Z=q.cwd??process.cwd(),$=q.env??process.env;if(q.explicit){let W=h(q.explicit);if(W)return{url:W,source:"option"}}let Q=$q(q.stxConfig);if(Q)return{url:Q,source:"stx.config",via:"site.url"};let K=await dq(Z);if(K)return{url:K,source:"site.config",via:"url"};let J=mq($);if(J)return J;return{url:"http://localhost",source:"fallback"}}function Wq(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
3
  `)}class Fq{cacheDir;cache=new Map;loaded=!1;salt;constructor(q,Z=""){this.cacheDir=q,this.salt=Z}async load(){if(this.loaded)return;let q=j.join(this.cacheDir,"build-cache.json");if(await Bun.file(q).exists())try{let Z=JSON.parse(await Bun.file(q).text());for(let[$,Q]of Object.entries(Z))this.cache.set($,Q)}catch{}this.loaded=!0}async save(){await X.promises.mkdir(this.cacheDir,{recursive:!0});let q=j.join(this.cacheDir,"build-cache.json"),Z={};for(let[$,Q]of this.cache)Z[$]=Q;await Bun.write(q,JSON.stringify(Z))}getHash(q,Z){let $=X.statSync(q),Q=`${this.salt}|${q}:${$.mtimeMs}`;for(let J of Z)if(X.existsSync(J)){let W=X.statSync(J);Q+=`:${J}:${W.mtimeMs}`}let K=0;for(let J=0;J<Q.length;J++){let W=Q.charCodeAt(J);K=(K<<5)-K+W,K=K&K}return Math.abs(K).toString(36)}get(q,Z){let $=this.cache.get(q);if(!$)return null;let Q=this.getHash(Z,$.dependencies??[]);if($.hash!==Q)return this.cache.delete(q),null;return $.html}set(q,Z,$,Q){let K=this.getHash(Z,$);this.cache.set(q,{hash:K,html:Q,generatedAt:Date.now(),dependencies:$})}}class Rq{cacheDir;constructor(q){this.cacheDir=q}getFilePath(q){let Z=q.replace(/[^a-zA-Z0-9]/g,"_")+".json";return j.join(this.cacheDir,"isr",Z)}async get(q){let Z=this.getFilePath(q);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set(q,Z){let $=this.getFilePath(q);await X.promises.mkdir(j.dirname($),{recursive:!0}),await Bun.write($,JSON.stringify(Z))}async invalidate(q){let Z=this.getFilePath(q);if(await Bun.file(Z).exists())await X.promises.unlink(Z)}async invalidatePattern(q){let Z=j.join(this.cacheDir,"isr");if(!X.existsSync(Z))return;let $=await X.promises.readdir(Z);for(let Q of $){let K=Q.replace(/_/g,"/").replace(".json","");if(q.test(K))await X.promises.unlink(j.join(Z,Q))}}async needsRevalidation(q){let Z=await this.get(q);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function pq(q){try{let $=(await Bun.file(q).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!$)return null;let Q=$[1];if(!Q.includes("getStaticPaths"))return null;let K=Q.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!K)return null;return await Function(`
4
4
  return (async function getStaticPaths() {
5
5
  ${K[1]}
@@ -41,7 +41,7 @@ ${q.map((Q)=>{let K=new URL(Q.loc,Z).href,J=` <url>
41
41
  ${$.join(`
42
42
  `)}
43
43
  </channel>
44
- </rss>`}async function rq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,failOnServerScriptError:q.failOnServerScriptError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},_=new Set,z=0,L={},A={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&X.existsSync(J.outputDir))await X.promises.rm(J.outputDir,{recursive:!0});await X.promises.mkdir(J.outputDir,{recursive:!0});let U=J.cacheSalt;if(!U){let{resolveUserCssConfig:Y,fingerprintConfig:N}=await import("./chunk-zgzzn9qk.js");try{U=N(await Y(process.cwd()))}catch{}}let{prepareImageDelivery:G}=await import("./chunk-jpnja3jy.js"),H=await G(J.publicDir,J.outputDir);if(H.count>0)console.log(`Optimized ${H.count} image(s) for responsive delivery`),U=[U,H.fingerprint].filter(Boolean).join(":");let F=new Fq(J.cacheDir,U);if(J.cache)await F.load();try{let{generateCss:Y}=await import("./chunk-zgzzn9qk.js");await Y('<div class="bg-black"></div>')}catch{}Yq();let kq=$?.routeMiddleware?.dir||"middleware";await jq(process.cwd(),kq);let p=Vq();if(p.length>0)console.log(`Loaded ${p.length} middleware: ${p.join(", ")}`);let bq=$?.routeMiddleware?.global||[];wq($?.layoutsDir,d(process.cwd()));let i=l(".",{pagesDir:J.pagesDir,pagesDirs:$?._layerPageDirs});console.log(`Found ${i.length} routes`);let g=[];for(let Y of i){let N=await uq(Y);for(let O of N)g.push({route:Y,url:O.url,params:O.params,props:O.props,revalidate:O.revalidate??J.revalidate})}W.totalPages=g.length,console.log(`Generating ${W.totalPages} pages...`);let S=[],s=[];for(let Y=0;Y<g.length;Y+=J.concurrency)s.push(g.slice(Y,Y+J.concurrency));for(let Y of s)await Promise.all(Y.map(async(N)=>{let{route:O,url:V,params:v,props:Sq,revalidate:r}=N;try{await J.hooks.onPageStart?.(V);let R=await Bun.file(O.filePath).text(),M=JJ(R),vq=M?.middleware?Array.isArray(M.middleware)?M.middleware:[M.middleware]:[],t=[...bq,...vq];if(t.length>0){let T=Gq(V,v,M||{}),k=Lq(T,null,void 0,{isServer:!0}),D=await Nq(t,k);if(D.redirect){let I=typeof D.redirect==="string"?D.redirect:D.redirect.path||D.redirect,y=QJ(String(I),V),b=ZJ(V,J);await X.promises.mkdir(j.dirname(b),{recursive:!0}),await Bun.write(b,y),W.successCount++,W.pages.push({route:V,outputPath:b,size:Buffer.byteLength(y),cached:!1}),S.push({loc:V,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${V} \u2192 redirect to ${I}`);return}if(D.abort){let I=typeof D.abort==="string"?D.abort:D.abort?.error?.message||"aborted";console.warn(` \u21B3 ${V} \u2014 middleware aborted: ${I}`);return}}let e=R.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(e)try{if(!await Function("route",`
44
+ </rss>`}async function rq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,failOnServerScriptError:q.failOnServerScriptError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},_=new Set,z=0,L={},A={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&X.existsSync(J.outputDir))await X.promises.rm(J.outputDir,{recursive:!0});await X.promises.mkdir(J.outputDir,{recursive:!0});let U=J.cacheSalt;if(!U){let{resolveUserCssConfig:Y,fingerprintConfig:N}=await import("./chunk-n9cqrw9j.js");try{U=N(await Y(process.cwd()))}catch{}}let{prepareImageDelivery:G}=await import("./chunk-mgrckqww.js"),H=await G(J.publicDir,J.outputDir);if(H.count>0)console.log(`Optimized ${H.count} image(s) for responsive delivery`),U=[U,H.fingerprint].filter(Boolean).join(":");let F=new Fq(J.cacheDir,U);if(J.cache)await F.load();try{let{generateCss:Y}=await import("./chunk-n9cqrw9j.js");await Y('<div class="bg-black"></div>')}catch{}Yq();let kq=$?.routeMiddleware?.dir||"middleware";await jq(process.cwd(),kq);let p=Vq();if(p.length>0)console.log(`Loaded ${p.length} middleware: ${p.join(", ")}`);let bq=$?.routeMiddleware?.global||[];wq($?.layoutsDir,d(process.cwd()));let i=l(".",{pagesDir:J.pagesDir,pagesDirs:$?._layerPageDirs});console.log(`Found ${i.length} routes`);let g=[];for(let Y of i){let N=await uq(Y);for(let O of N)g.push({route:Y,url:O.url,params:O.params,props:O.props,revalidate:O.revalidate??J.revalidate})}W.totalPages=g.length,console.log(`Generating ${W.totalPages} pages...`);let S=[],s=[];for(let Y=0;Y<g.length;Y+=J.concurrency)s.push(g.slice(Y,Y+J.concurrency));for(let Y of s)await Promise.all(Y.map(async(N)=>{let{route:O,url:V,params:v,props:Sq,revalidate:r}=N;try{await J.hooks.onPageStart?.(V);let R=await Bun.file(O.filePath).text(),M=JJ(R),vq=M?.middleware?Array.isArray(M.middleware)?M.middleware:[M.middleware]:[],t=[...bq,...vq];if(t.length>0){let T=Gq(V,v,M||{}),k=Lq(T,null,void 0,{isServer:!0}),D=await Nq(t,k);if(D.redirect){let I=typeof D.redirect==="string"?D.redirect:D.redirect.path||D.redirect,y=QJ(String(I),V),b=ZJ(V,J);await X.promises.mkdir(j.dirname(b),{recursive:!0}),await Bun.write(b,y),W.successCount++,W.pages.push({route:V,outputPath:b,size:Buffer.byteLength(y),cached:!1}),S.push({loc:V,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${V} \u2192 redirect to ${I}`);return}if(D.abort){let I=typeof D.abort==="string"?D.abort:D.abort?.error?.message||"aborted";console.warn(` \u21B3 ${V} \u2014 middleware aborted: ${I}`);return}}let e=R.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(e)try{if(!await Function("route",`
45
45
  const validate = ${e[1]};
46
46
  return validate(route);
47
47
  `)({params:v})){console.warn(`Validation failed for ${V}, skipping...`);return}}catch{}let E=null,qq=!1;if(J.cache){if(E=F.get(V,O.filePath),E)qq=!0,W.cachedCount++}if(!E){let T=await Mq(O,v,Sq,J,$);if(E=T.html,J.failOnIncludeError&&T.includeFailures.length>0)throw Error(`${T.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
@@ -112,6 +112,9 @@ declare module 'stx' {
112
112
  export const useSessionStorage: typeof globalThis.useSessionStorage
113
113
  export const keptState: typeof globalThis.keptState
114
114
  export const forgetKeptState: typeof globalThis.forgetKeptState
115
+ export const setKeptScope: typeof globalThis.setKeptScope
116
+ export const flushKeptState: typeof globalThis.flushKeptState
117
+ export const cachedQuery: typeof globalThis.cachedQuery
115
118
  export const useSlots: typeof globalThis.useSlots
116
119
  export const useStore: typeof globalThis.useStore
117
120
  export const useThrottle: typeof globalThis.useThrottle
package/dist/stx.d.ts CHANGED
@@ -484,7 +484,51 @@ declare function useSessionStorage<T>(_key: string, _defaultValue: T): StxSignal
484
484
  /** A value kept between visits (a phone app between launches) in a scope such as the signed-in account; a scope of false keeps nothing. */
485
485
  declare function keptState<T>(_name: string, _initialValue: T, _options?: { scope?: string | number | false | null }): StxSignal<T>
486
486
  /** Remove a scope's kept values, or every kept value. */
487
- declare function forgetKeptState(_scope?: string | number | false | null): void
487
+ declare function forgetKeptState(_scope?: string | number | false | null): Promise<void>
488
+ /** The account kept state and cached queries belong to when they name no scope. */
489
+ declare function setKeptScope(_scope: string | number | false | null | undefined): void
490
+ /** Finish writing what is kept (large values are written behind, to IndexedDB). */
491
+ declare function flushKeptState(): Promise<void>
492
+
493
+ /** Options of `cachedQuery`: see offline/query-cache.ts. */
494
+ interface StxCachedQueryOptions<T> {
495
+ /** The URL to GET (answered as JSON), or a function giving it. */
496
+ url?: string | (() => string | null | undefined)
497
+ /** Load the data some other way than a GET of `url`. */
498
+ load?: (_context: { force: boolean, url: string | null, signal?: AbortSignal }) => Promise<T>
499
+ /** How to send the GET, with current credentials. */
500
+ fetch?: (_url: string, _init: RequestInit) => Promise<Response>
501
+ /** Whose data this is, as for keptState; a function is read at every load. Default: setKeptScope's. */
502
+ scope?: string | number | false | null | (() => string | number | false | null | undefined)
503
+ /** How long an answer counts as fresh, ms. Default 0. */
504
+ staleTime?: number
505
+ initial?: T
506
+ transform?: (_raw: any) => T
507
+ /** Give up on a request after this long, ms. Default 15000. */
508
+ timeoutMs?: number
509
+ /** Fetch when created. */
510
+ immediate?: boolean
511
+ }
512
+
513
+ interface StxCachedQuery<T> {
514
+ /** The last answer, with writes still waiting in the outbox applied. */
515
+ data: StxSignal<T>
516
+ loading: StxSignal<boolean>
517
+ isFetching: StxSignal<boolean>
518
+ error: StxSignal<string | null>
519
+ /** When the data shown was fetched (ms); 0 for none. */
520
+ updatedAt: StxSignal<number>
521
+ /** Fetch when older than staleTime (or always, with force). One request for every caller. */
522
+ load: (_force?: boolean) => Promise<T>
523
+ /** Fetch now, past every cache. */
524
+ refresh: () => Promise<T>
525
+ set: (_value: T | ((_current: T) => T)) => void
526
+ invalidate: () => void
527
+ readonly key: string
528
+ }
529
+
530
+ /** Data kept per account, shown at once from last time and refreshed behind. Same key, same query. */
531
+ declare function cachedQuery<T = any>(_key: string, _options?: StxCachedQueryOptions<T>): StxCachedQuery<T>
488
532
 
489
533
  /**
490
534
  * Options accepted by the auto-imported `useCookie` global.
@@ -921,6 +965,9 @@ interface StxRuntimeRegistry {
921
965
  useSessionStorage: typeof useSessionStorage
922
966
  keptState: typeof keptState
923
967
  forgetKeptState: typeof forgetKeptState
968
+ setKeptScope: typeof setKeptScope
969
+ flushKeptState: typeof flushKeptState
970
+ cachedQuery: typeof cachedQuery
924
971
  useEventListener: typeof useEventListener
925
972
  useScrollLock: typeof useScrollLock
926
973
  useWebSocket: typeof useWebSocket
@@ -1,4 +1,5 @@
1
1
  export const SERVER_ONLY_COMPOSABLES = [
2
+ "applyOfflineUpdate",
2
3
  "broadcast",
3
4
  "cacheMedia",
4
5
  "calculateDistance",
@@ -38,6 +39,7 @@ export const SERVER_ONLY_COMPOSABLES = [
38
39
  "isWakeLockSupported",
39
40
  "isWebSocketSupported",
40
41
  "notify",
42
+ "onOfflineUpdateReady",
41
43
  "parseCookies",
42
44
  "pickColor",
43
45
  "prefetch",
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-x7qyx7vn.js";import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(await Bun.file(q).exists()){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(await Bun.file(q).exists()){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
2
+ import"./chunk-2fw05hs2.js";import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(await Bun.file(q).exists()){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(await Bun.file(q).exists()){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
3
3
  ${z(Q,G)}`}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},matchInlineSnapshot(M,X){let q=C(M);if(X===void 0)return{passed:!0,expected:q};let G=C(X);return{passed:q===G,expected:q}},getConfig(){return Y}}}function D(N={}){let Y=J(N),M=Y.getConfig();return{async compareScreenshots(X,q,G="desktop"){let Q=$.join(M.screenshotDir,G,`${X}.png`),W=$.join(M.diffDir,G,`${X}.actual.png`),Z=$.join(M.diffDir,G,`${X}.diff.png`);if(await Bun.file(Q).exists()){let F=await Bun.file(Q).arrayBuffer(),U=Buffer.from(F),_=await M.compare(q,U);if(_.match||_.diffPercentage<=M.threshold)return{viewport:G,passed:!0,baselinePath:Q};if(M.updateSnapshots)return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q};if(await B.promises.mkdir($.dirname(W),{recursive:!0}),await Bun.write(W,q),_.diffImage&&M.generateDiff)await Bun.write(Z,_.diffImage);return{viewport:G,passed:!1,baselinePath:Q,actualPath:W,diffPath:M.generateDiff?Z:void 0,diffPercentage:_.diffPercentage}}return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q}},async testViewports(X,q,G=M.viewports){let Q=[];for(let W of G){let Z=null;for(let F=0;F<M.retries;F++)try{let U=await q(W),_=await this.compareScreenshots(X,U,W.name);Q.push(_),Z=null;break}catch(U){if(Z=U,F<M.retries-1)await new Promise((_)=>setTimeout(_,100*(F+1)))}if(Z)Q.push({viewport:W.name,passed:!1,baselinePath:"",diffPercentage:100})}return Q},getSnapshotTester(){return Y}}}function L(N={}){let M=D(N).getSnapshotTester(),X=new Map;return{addStory(q){X.set(`${q.component}/${q.name}`,q)},addStories(q){for(let G of q)this.addStory(G)},getStories(){return Array.from(X.values())},getStoriesForComponent(q){return Array.from(X.values()).filter((G)=>G.component===q)},async testStory(q){let G=X.get(q);if(!G)return{name:q,passed:!1,duration:0,snapshots:[],screenshots:[],errors:[Error(`Story not found: ${q}`)]};let Q=Date.now(),W={name:q,passed:!0,duration:0,snapshots:[],screenshots:[],errors:[]};try{let Z=await G.render(),F=await M.snapshot(Z,q.replace(/\//g,"-"));if(W.snapshots.push(F),!F.passed)W.passed=!1}catch(Z){W.passed=!1,W.errors.push(Z)}return W.duration=Date.now()-Q,W},async testAllStories(){let q=[];for(let G of X.keys()){let Q=await this.testStory(G);q.push(Q)}return q},async generateStoryIndex(){let q={};for(let G of X.values()){if(!q[G.component])q[G.component]=[];q[G.component].push({name:G.name,args:G.args})}return JSON.stringify(q,null,2)}}}async function S(N,Y={}){let M={outputDir:Y.outputDir||"visual-test-report",format:Y.format||"html",title:Y.title||"Visual Test Report",includeScreenshots:Y.includeScreenshots??!0};await B.promises.mkdir(M.outputDir,{recursive:!0});let X=N.length,q=N.filter((F)=>F.passed).length,G=X-q,Q=N.reduce((F,U)=>F+U.duration,0);if(M.format==="json"){let F={title:M.title,summary:{total:X,passed:q,failed:G,duration:Q},results:N,generatedAt:new Date().toISOString()},U=$.join(M.outputDir,"report.json");return await Bun.write(U,JSON.stringify(F,null,2)),U}if(M.format==="markdown"){let F=`# ${M.title}
4
4
 
5
5
  `;F+=`## Summary
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.406",
4
+ "version": "0.2.408",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -118,12 +118,12 @@
118
118
  "dependencies": {
119
119
  "@stacksjs/ts-css": "^0.3.2",
120
120
  "@stacksjs/clapp": "^0.2.16",
121
- "@stacksjs/desktop": "0.2.406",
122
- "@stacksjs/sanitizer": "0.2.406",
121
+ "@stacksjs/desktop": "0.2.408",
122
+ "@stacksjs/sanitizer": "0.2.408",
123
123
  "@stacksjs/ts-i18n": "^0.1.11",
124
- "bun-plugin-stx": "0.2.406",
124
+ "bun-plugin-stx": "0.2.408",
125
125
  "bunfig": "^0.15.19",
126
- "stx-router": "0.2.406",
126
+ "stx-router": "0.2.408",
127
127
  "ts-broadcasting": "^0.0.11",
128
128
  "ts-images": "^0.2.22",
129
129
  "ts-syntax-highlighter": "^0.2.1"
package/stx-module.d.ts CHANGED
@@ -112,6 +112,9 @@ declare module 'stx' {
112
112
  export const useSessionStorage: typeof globalThis.useSessionStorage
113
113
  export const keptState: typeof globalThis.keptState
114
114
  export const forgetKeptState: typeof globalThis.forgetKeptState
115
+ export const setKeptScope: typeof globalThis.setKeptScope
116
+ export const flushKeptState: typeof globalThis.flushKeptState
117
+ export const cachedQuery: typeof globalThis.cachedQuery
115
118
  export const useSlots: typeof globalThis.useSlots
116
119
  export const useStore: typeof globalThis.useStore
117
120
  export const useThrottle: typeof globalThis.useThrottle
package/stx.d.ts CHANGED
@@ -484,7 +484,51 @@ declare function useSessionStorage<T>(_key: string, _defaultValue: T): StxSignal
484
484
  /** A value kept between visits (a phone app between launches) in a scope such as the signed-in account; a scope of false keeps nothing. */
485
485
  declare function keptState<T>(_name: string, _initialValue: T, _options?: { scope?: string | number | false | null }): StxSignal<T>
486
486
  /** Remove a scope's kept values, or every kept value. */
487
- declare function forgetKeptState(_scope?: string | number | false | null): void
487
+ declare function forgetKeptState(_scope?: string | number | false | null): Promise<void>
488
+ /** The account kept state and cached queries belong to when they name no scope. */
489
+ declare function setKeptScope(_scope: string | number | false | null | undefined): void
490
+ /** Finish writing what is kept (large values are written behind, to IndexedDB). */
491
+ declare function flushKeptState(): Promise<void>
492
+
493
+ /** Options of `cachedQuery`: see offline/query-cache.ts. */
494
+ interface StxCachedQueryOptions<T> {
495
+ /** The URL to GET (answered as JSON), or a function giving it. */
496
+ url?: string | (() => string | null | undefined)
497
+ /** Load the data some other way than a GET of `url`. */
498
+ load?: (_context: { force: boolean, url: string | null, signal?: AbortSignal }) => Promise<T>
499
+ /** How to send the GET, with current credentials. */
500
+ fetch?: (_url: string, _init: RequestInit) => Promise<Response>
501
+ /** Whose data this is, as for keptState; a function is read at every load. Default: setKeptScope's. */
502
+ scope?: string | number | false | null | (() => string | number | false | null | undefined)
503
+ /** How long an answer counts as fresh, ms. Default 0. */
504
+ staleTime?: number
505
+ initial?: T
506
+ transform?: (_raw: any) => T
507
+ /** Give up on a request after this long, ms. Default 15000. */
508
+ timeoutMs?: number
509
+ /** Fetch when created. */
510
+ immediate?: boolean
511
+ }
512
+
513
+ interface StxCachedQuery<T> {
514
+ /** The last answer, with writes still waiting in the outbox applied. */
515
+ data: StxSignal<T>
516
+ loading: StxSignal<boolean>
517
+ isFetching: StxSignal<boolean>
518
+ error: StxSignal<string | null>
519
+ /** When the data shown was fetched (ms); 0 for none. */
520
+ updatedAt: StxSignal<number>
521
+ /** Fetch when older than staleTime (or always, with force). One request for every caller. */
522
+ load: (_force?: boolean) => Promise<T>
523
+ /** Fetch now, past every cache. */
524
+ refresh: () => Promise<T>
525
+ set: (_value: T | ((_current: T) => T)) => void
526
+ invalidate: () => void
527
+ readonly key: string
528
+ }
529
+
530
+ /** Data kept per account, shown at once from last time and refreshed behind. Same key, same query. */
531
+ declare function cachedQuery<T = any>(_key: string, _options?: StxCachedQueryOptions<T>): StxCachedQuery<T>
488
532
 
489
533
  /**
490
534
  * Options accepted by the auto-imported `useCookie` global.
@@ -921,6 +965,9 @@ interface StxRuntimeRegistry {
921
965
  useSessionStorage: typeof useSessionStorage
922
966
  keptState: typeof keptState
923
967
  forgetKeptState: typeof forgetKeptState
968
+ setKeptScope: typeof setKeptScope
969
+ flushKeptState: typeof flushKeptState
970
+ cachedQuery: typeof cachedQuery
924
971
  useEventListener: typeof useEventListener
925
972
  useScrollLock: typeof useScrollLock
926
973
  useWebSocket: typeof useWebSocket
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{cl as a,dl as b,el as c,fl as d,gl as e,hl as f,il as g,jl as h,kl as i,ll as j,ml as k,nl as l,ol as m,pl as n,ql as o}from"./chunk-63dyh42m.js";import"./chunk-1nnskved.js";import"./chunk-dxjtszaa.js";import"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{o as tempBuildName,b as shouldLogBundlerDiagnostics,f as setBundlerFallbackMode,l as rewriteRegistryImports,g as resolveBundlerFallback,j as registryIdForPath,c as recordBundleFailure,m as queueClientBundleBuild,k as normalizeRegistrySpecifiers,h as hasUserImports,d as getBundleFailures,a as clientBundleDependencies,e as clearBundleFailures,n as bundleClientScript,i as MODULE_SPECIFIER_PREFIX};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import F from"fs";import y from"path";var U=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^<>()]*>)?\s*\(/,g=/(?:^|\n)\s*(?:import|export)\s+(?:[^'"]*?\sfrom\s+)?['"](\.[^'"]*)['"]/g,D=["",".ts",".tsx",".js",".jsx",".mts",".mjs","/index.ts","/index.js"],H=3;function k(j,q){let J=y.resolve(y.dirname(q),j);for(let Q of D){let z=J+Q;try{if(F.statSync(z).isFile())return z}catch{}}return null}function K(j,q,J=0,Q=new Set){if(!q||J>=H)return!1;for(let z of j.matchAll(g)){let Z=k(z[1],q);if(!Z||Q.has(Z))continue;Q.add(Z);let $;try{$=F.readFileSync(Z,"utf8")}catch{continue}if(U.test($))return!0;if(K($,Z,J+1,Q))return!0}return!1}var Y=["batch","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refresh","registerStoresClient","setRouteParams","state","untrack","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"],d=["onMount","onDestroy"];function p(j="const",q=[],J){let Q=q.length?Y.filter((z)=>!q.includes(z)):Y;if(J!==void 0)Q=Q.filter((z)=>{let Z=z.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${Z}(?![\\w$])`).test(J)});return`${j} { ${Q.join(", ")} } = window.stx;`}var x=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"],T={useServerData:{category:"server-only",reason:"loads and serializes request-scoped data from <script server>; clients consume it through a keyed useFetch/useAsyncData."},redirect:{category:"server-only",reason:"returns an HTTP Response for <script server>/edge/build; use navigate() on the client."},useAsyncData:{category:"browser-composable",reason:"inlined on demand from src/composables when a script references it; reachable, not a bare global."},Teleport:{category:"compile-time-directive",reason:"template tag resolved by processTeleportDirectives; not a script callable."},StxModalBuiltin:{category:"builtin-component",reason:"builtin component used as a template tag; drive open/close from the modal store."},StxToastBuiltin:{category:"builtin-component",reason:"builtin component used as a template tag; push toasts via the toast store."},useForm:{category:"browser-composable",reason:"reactive form primitive; lives in src/composables/use-form.ts and is inlined on demand when a <script client> references it (#1846)."},defineForm:{category:"browser-composable",reason:"deprecated alias of useForm, kept for a minor (#1843). Same delivery path \u2014 inlined on demand from src/composables/use-form.ts."},validateFields:{category:"isomorphic-import",reason:"pure validation helper; import it directly, not auto-delivered to <script client> (per client-api-delivery.test.ts)."},validateField:{category:"isomorphic-import",reason:"singular pure validation helper; same explicit-import boundary as validateFields."}},O=Y.filter((j)=>!x.includes(j));function P(j){if(!j)return!1;return O.some((q)=>new RegExp(`\\b${q}\\s*(?:<[^>]*>)?\\s*\\(`).test(j))}var C=[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/\s:[a-z][\w-]*\s*=\s*["']/i,/\s:(?:if|else-if|else|for|show|text|html|model)\s*=/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/],u=/\s@[a-z][\w.:-]*\s*=/i;function _(j,q){if(!j)return!1;let J=X(j);return G(J,q)}function G(j,q){if(C.some((J)=>J.test(j)))return!0;if(P(j))return!0;return M(j,q)}function M(j,q){if(!q)return!1;for(let J of j.matchAll(/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script\s*>/gi))if(K(J[1],q))return!0;return!1}function E(j,q){if(!j)return!1;let J=X(j);return u.test(J)||G(J,q)}var b=["if","else-if","elseif","else","for","show","key","text","html","model","ref"];function c(j){return b.includes(j.toLowerCase())}var V=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],f=["x-init","x-transition","x-effect","x-on"],r=[...V,...f];function h(){return`{${V.map((j)=>`'${j}':1`).join(",")}}`}var L=["class","style","text","html","show","model","if","ref"];function o(){return`{${L.map((j)=>j==="if"?"'if':1":`${j}:1`).join(",")}}`}var B=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","keydown","keyup","keypress","input","change","submit","focus","blur","scroll","resize","touchstart","touchend","touchmove","contextmenu","wheel","pointerdown","pointerup","pointermove"];function i(){return`/^(${B.join("|")})/`}function s(j){return B.some((q)=>j===q||j.startsWith(`${q}.`))}var S=65536,v=4,w=new Map;function m(){w.clear()}function X(j){if(!j)return j;if(!j.includes("<!--")&&!/<(?:pre|code)\b/i.test(j))return j;let q=j.length>=S;if(q){let z=w.get(j);if(z!==void 0)return z}let J=(z)=>z.replace(/(<[^>]*>)|([^<]+)/g,(Z,$,W)=>$??" ".repeat(W.length)),Q=j.replace(/(<pre\b[^>]*>)([\s\S]*?)(<\/pre>)/gi,(z,Z,$,W)=>Z+J($)+W).replace(/(<code\b[^>]*>)([\s\S]*?)(<\/code>)/gi,(z,Z,$,W)=>Z+J($)+W).replace(/<!--[\s\S]*?-->/g,(z)=>" ".repeat(z.length));if(q){while(w.size>=v){let z=w.keys().next();if(z.done)break;w.delete(z.value)}w.set(j,Q)}return Q}
3
- export{K as Gv,Y as Hv,d as Iv,p as Jv,x as Kv,T as Lv,O as Mv,P as Nv,_ as Ov,E as Pv,b as Qv,c as Rv,V as Sv,f as Tv,r as Uv,h as Vv,L as Wv,o as Xv,B as Yv,i as Zv,s as _v,m as $v,X as aw};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Pg as a,Qg as b,Rg as c,Sg as d,Tg as e,Ug as f}from"./chunk-g81ymdat.js";import"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{c as renderSlot,d as processSlots,a as parseSlots,b as parseSlotElement,e as extractSlotContent,f as applySlots};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ao as i,Bo as j,Co as k,Do as l,Eo as m,Fo as n,so as a,to as b,uo as c,vo as d,wo as e,xo as f,yo as g,zo as h}from"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{n as stripStxRuntimeImports,b as scanScriptTags,m as rewriteStxImportSpecifiers,k as processSignals,i as processScriptSetup,f as preEvalLiteralReactiveIfs,c as parseLoopExpression,d as hasSignalsSyntax,l as findMarkupIndexOutsideScripts,j as extractExports,h as convertSignalLoopsToAttributes,e as convertSignalDirectivesToAttributes,g as convertServerLoopAttributesToDirectives,a as clearScriptScanCache};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Mi as a,Ni as b}from"./chunk-gyccx2pr.js";import"./chunk-g0w8dyat.js";import"./chunk-63dyh42m.js";import"./chunk-1nnskved.js";import"./chunk-dxjtszaa.js";import"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{a as getStoreScript,b as clearStoreCache};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{lo as b,mo as c,no as d}from"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import{yv as a}from"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{b as rendersAsElement,c as processESImports,d as processComponents,a as freeIdentifiers};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ak as a,bk as b,ck as c,dk as d}from"./chunk-sptvg80e.js";import"./chunk-x7qyx7vn.js";export{d as default,c as createHotReloadServer,b as compileToNative,a as NATIVE_COMPONENTS};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Fr as a,Gr as b,Hr as c,Ir as d,Jr as e,Kr as f}from"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{rl as a,sl as b,tl as c,ul as d,vl as e,wl as f,xl as g}from"./chunk-1nnskved.js";import"./chunk-wpsx5avz.js";import"./chunk-pgeh4g3a.js";import"./chunk-7q06md6v.js";import"./chunk-z8zmp74b.js";import"./chunk-x7qyx7vn.js";export{e as productionApiDispatcher,g as isServerApiSource,b as generateApiTypes,a as discoverServerApi,f as createServerApi,d as createApiDispatcher,c as buildServerApi};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ye as a}from"./chunk-yn8qq8tn.js";import"./chunk-1n2ng8nx.js";import"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{a as buildApp};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Aq as w,Bq as x,Cq as y,Po as a,Ro as b,To as c,Uo as d,iq as e,jq as f,kq as g,lq as h,mq as i,nq as j,oq as k,pq as l,qq as m,rq as n,sq as o,tq as p,uq as q,vq as r,wq as s,xq as t,yq as u,zq as v}from"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{e as validateTemplate,g as validateDirective,o as userComponentFileExists,m as transpileTypeScript,q as slotContentHasExpressions,k as shouldTranspileTypeScript,n as scopeOnRootElement,u as resolveTemplatePath,s as renderComponentWithSlot,j as isJavaScriptScript,p as isHydrateTrigger,d as hasVariables,h as hasDirectives,v as getSourceLineInfo,l as getSharedTranspiler,f as getPositionInfo,y as getComponentCacheStats,t as fileExists,a as extractVariables,c as extractScriptFromTemplate,i as extractDirectiveNames,w as createDetailedErrorMessage,b as convertToCommonJS,r as componentClientSignalNames,x as clearComponentCache};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{em as c,hm as d,im as e,jm as f,km as g,lm as h,mm as i,nm as j,om as k,pm as l,qm as m,rm as n}from"./chunk-sjc7x8y1.js";import"./chunk-ffdxdgep.js";import"./chunk-m8bdy2wt.js";import{As as b,zs as a}from"./chunk-0n054h7w.js";import"./chunk-wpsx5avz.js";import"./chunk-tfy07tmv.js";import"./chunk-4g4yz97f.js";import"./chunk-pgeh4g3a.js";import"./chunk-z9a0ft6h.js";import"./chunk-h1yb87ep.js";import"./chunk-7q06md6v.js";import"./chunk-1phxzej9.js";import"./chunk-7ba7x6jt.js";import"./chunk-akzmq0jr.js";import"./chunk-c1f1vtjt.js";import"./chunk-0nhpymyy.js";import"./chunk-4md4tj27.js";import"./chunk-z8zmp74b.js";import"./chunk-qcpnfw0k.js";import"./chunk-59pakqdv.js";import"./chunk-x7qyx7vn.js";export{h as transformAutoImports,b as stripCommentsAndLiterals,e as renderVendorStyleTags,i as referencesName,n as processClientScript,g as injectBrowserCoreAutoImports,m as generateServerDataBridge,k as generateBrowserAutoImportDestructuring,j as generateAutoImportDestructuring,a as findInterpolationEnd,l as extractBridgeData,d as extractAndStripCssImports,f as STX_AUTO_IMPORTS,c as BROWSER_CORE_IMPORTS};