@farm.js/core 0.1.15 → 0.1.17

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 (180) hide show
  1. package/dist/agent-runtime.d.mts +5 -2
  2. package/dist/agent-runtime.d.ts +5 -2
  3. package/dist/api/client.cjs +62 -28
  4. package/dist/api/client.d.mts +3 -2
  5. package/dist/api/client.d.ts +3 -2
  6. package/dist/api/client.mjs +3 -3
  7. package/dist/api/route-manager.cjs +69 -32
  8. package/dist/api/route-manager.d.mts +5 -2
  9. package/dist/api/route-manager.d.ts +5 -2
  10. package/dist/api/route-manager.mjs +5 -5
  11. package/dist/api/runtime.cjs +65 -29
  12. package/dist/api/runtime.d.mts +3 -2
  13. package/dist/api/runtime.d.ts +3 -2
  14. package/dist/api/runtime.mjs +6 -3
  15. package/dist/{api-client-C8d7BZNp.d.mts → api-client-Cx54IR5g.d.mts} +2 -1
  16. package/dist/{api-client-BWrEbxfO.d.ts → api-client-DykpaKcY.d.ts} +2 -1
  17. package/dist/api.cjs +106 -33
  18. package/dist/api.d.mts +7 -4
  19. package/dist/api.d.ts +7 -4
  20. package/dist/api.mjs +8 -8
  21. package/dist/{app-wIYse61b.d.ts → app-BHY_10Lm.d.ts} +3 -3
  22. package/dist/{app-B3nVSjen.d.mts → app-BMk0do23.d.mts} +3 -3
  23. package/dist/app-markdown.d.mts +6 -3
  24. package/dist/app-markdown.d.ts +6 -3
  25. package/dist/app-markdown.mjs +3 -3
  26. package/dist/cache.cjs +62 -28
  27. package/dist/cache.d.mts +11 -1
  28. package/dist/cache.d.ts +11 -1
  29. package/dist/cache.mjs +1 -1
  30. package/dist/{chunk-FOGLGRDS.mjs → chunk-4OOBRCJX.mjs} +122 -8
  31. package/dist/{chunk-JRF3C33L.mjs → chunk-56DAX2BE.mjs} +172 -53
  32. package/dist/{chunk-B76DT5Y6.mjs → chunk-57J3Y7Y3.mjs} +1 -1
  33. package/dist/{chunk-MOQNHLTS.mjs → chunk-5QOEPUYE.mjs} +5 -2
  34. package/dist/{chunk-HKLRP3BN.mjs → chunk-5SPPCN5J.mjs} +1 -1
  35. package/dist/{chunk-LUC2FAGW.mjs → chunk-6VQIKZZO.mjs} +1 -1
  36. package/dist/{chunk-7ZWL7XOU.mjs → chunk-76DG3LF3.mjs} +1 -1
  37. package/dist/{chunk-EWDK36MM.mjs → chunk-A72YEUZ3.mjs} +1 -1
  38. package/dist/{chunk-ZHOIQC6U.mjs → chunk-ATERBVHQ.mjs} +2 -2
  39. package/dist/{chunk-27JNCYEK.mjs → chunk-EN7WTEAY.mjs} +2 -2
  40. package/dist/{chunk-IGO2HEV7.mjs → chunk-F6SJAKFJ.mjs} +62 -28
  41. package/dist/{chunk-GSDIZACQ.mjs → chunk-FG5H2VCJ.mjs} +2 -2
  42. package/dist/{chunk-LZK5CXDW.mjs → chunk-KLSSO6YD.mjs} +2 -2
  43. package/dist/{chunk-KUO3GBPK.mjs → chunk-L6V3P73N.mjs} +1 -1
  44. package/dist/{chunk-FBHGHMOA.mjs → chunk-MVIWBEJF.mjs} +37 -27
  45. package/dist/{chunk-KTGFMHET.mjs → chunk-N6UROPT7.mjs} +1 -1
  46. package/dist/{chunk-NDD2YVGU.mjs → chunk-NRVGEI5I.mjs} +10 -3
  47. package/dist/{chunk-GNTPTTLA.mjs → chunk-QGVJVSNX.mjs} +5 -5
  48. package/dist/{chunk-6SCB2MXB.mjs → chunk-SXHV42UQ.mjs} +16 -1
  49. package/dist/{chunk-OWTIOHON.mjs → chunk-SYGGPS4A.mjs} +2 -2
  50. package/dist/{chunk-NC333MFA.mjs → chunk-TSWW5BVH.mjs} +7 -4
  51. package/dist/{chunk-LK6FGAQR.mjs → chunk-UDBJCUPA.mjs} +7 -4
  52. package/dist/{chunk-NJ47VORC.mjs → chunk-UTBVHYS3.mjs} +2 -2
  53. package/dist/{chunk-76MNRHTS.mjs → chunk-UUYF3CHN.mjs} +2 -2
  54. package/dist/{chunk-S3QW3BIS.mjs → chunk-WD4YXVLV.mjs} +99 -6
  55. package/dist/{chunk-W7IVHTOP.mjs → chunk-WD5PNSOB.mjs} +16 -3
  56. package/dist/{chunk-DPZUDPVJ.mjs → chunk-XP777LRD.mjs} +1 -1
  57. package/dist/{chunk-KATQ6I56.mjs → chunk-XWAYMDLB.mjs} +1 -1
  58. package/dist/{chunk-UE75PB52.mjs → chunk-YD4J4XCI.mjs} +1 -1
  59. package/dist/{chunk-Q3MDL7TM.mjs → chunk-ZCNJKLA2.mjs} +30 -11
  60. package/dist/{client-plugins-CslwYp3E.d.ts → client-plugins-C089bQhN.d.ts} +16 -4
  61. package/dist/{client-plugins-C1EgdoJM.d.mts → client-plugins-JXXmZliS.d.mts} +16 -4
  62. package/dist/client-plugins.d.mts +5 -2
  63. package/dist/client-plugins.d.ts +5 -2
  64. package/dist/client.cjs +62 -28
  65. package/dist/client.d.mts +8 -7
  66. package/dist/client.d.ts +8 -7
  67. package/dist/client.mjs +6 -6
  68. package/dist/config.d.mts +5 -2
  69. package/dist/config.d.ts +5 -2
  70. package/dist/cron.mjs +2 -2
  71. package/dist/{devtools-PCGEBRSC.mjs → devtools-UFVTMQX5.mjs} +7 -7
  72. package/dist/docs.cjs +83 -4
  73. package/dist/docs.mjs +9 -9
  74. package/dist/{route-CHBaW55F.d.ts → endpoint-1zA994xL.d.ts} +3 -128
  75. package/dist/{route-C6UClI1z.d.mts → endpoint-DAc96i93.d.mts} +3 -128
  76. package/dist/env.cjs +135 -8
  77. package/dist/env.d.mts +22 -2
  78. package/dist/env.d.ts +22 -2
  79. package/dist/env.mjs +4 -1
  80. package/dist/index.cjs +516 -105
  81. package/dist/index.d.mts +16 -15
  82. package/dist/index.d.ts +16 -15
  83. package/dist/index.mjs +46 -34
  84. package/dist/integrations.d.mts +5 -2
  85. package/dist/integrations.d.ts +5 -2
  86. package/dist/internal/app-markdown-runtime.d.mts +5 -2
  87. package/dist/internal/app-markdown-runtime.d.ts +5 -2
  88. package/dist/internal/app-markdown-runtime.mjs +2 -2
  89. package/dist/internal/build-runtime.cjs +600 -284
  90. package/dist/internal/build-runtime.d.mts +7 -4
  91. package/dist/internal/build-runtime.d.ts +7 -4
  92. package/dist/internal/build-runtime.mjs +23 -23
  93. package/dist/internal/cli-runtime.cjs +143 -33
  94. package/dist/internal/cli-runtime.mjs +13 -13
  95. package/dist/internal/client-error-overlay.cjs +1 -1
  96. package/dist/internal/client-error-overlay.mjs +1 -1
  97. package/dist/internal/compression-runtime.d.mts +5 -2
  98. package/dist/internal/compression-runtime.d.ts +5 -2
  99. package/dist/internal/config-runtime.cjs +80 -4
  100. package/dist/internal/config-runtime.d.mts +6 -3
  101. package/dist/internal/config-runtime.d.ts +6 -3
  102. package/dist/internal/config-runtime.mjs +7 -7
  103. package/dist/internal/product-telemetry-runtime.cjs +1 -1
  104. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  105. package/dist/internal/production-runtime.cjs +101 -41
  106. package/dist/internal/production-runtime.d.mts +11 -8
  107. package/dist/internal/production-runtime.d.ts +11 -8
  108. package/dist/internal/production-runtime.mjs +6 -6
  109. package/dist/markdown.cjs +16 -1
  110. package/dist/markdown.mjs +1 -1
  111. package/dist/{metadata-BsUcOEXg.d.ts → metadata-BcNJP4fq.d.ts} +1 -1
  112. package/dist/{metadata-B1bxCPUY.d.mts → metadata-C1Z9vLbb.d.mts} +1 -1
  113. package/dist/middleware.cjs +10 -3
  114. package/dist/middleware.d.mts +7 -4
  115. package/dist/middleware.d.ts +7 -4
  116. package/dist/middleware.mjs +4 -4
  117. package/dist/{nitro-ICBP5APY.mjs → nitro-CVZ36JM5.mjs} +8 -5
  118. package/dist/plugin.cjs +358 -106
  119. package/dist/plugin.d.mts +5 -2
  120. package/dist/plugin.d.ts +5 -2
  121. package/dist/plugin.mjs +19 -19
  122. package/dist/{production-runtime-BDllolVh.d.mts → production-runtime-jcrTlRTb.d.mts} +1 -1
  123. package/dist/{production-runtime-CsNn2-zx.d.ts → production-runtime-oKmC0WU-.d.ts} +1 -1
  124. package/dist/{render-plan-CNUlzylR.d.mts → render-plan-BLIfc4jt.d.mts} +1 -1
  125. package/dist/{render-plan-EG4hNFjy.d.ts → render-plan-DOB9cV-h.d.ts} +1 -1
  126. package/dist/renderer-client.cjs +62 -28
  127. package/dist/renderer-client.d.mts +5 -4
  128. package/dist/renderer-client.d.ts +5 -4
  129. package/dist/renderer-client.mjs +3 -3
  130. package/dist/{request-Blh_f7Z3.d.mts → request-Cr53NRHr.d.mts} +1 -1
  131. package/dist/{request-DsVSQVfD.d.ts → request-Dt2gNuQD.d.ts} +1 -1
  132. package/dist/request.d.mts +6 -3
  133. package/dist/request.d.ts +6 -3
  134. package/dist/route-B0XrsrFk.d.mts +128 -0
  135. package/dist/route-DOEpbyWZ.d.ts +128 -0
  136. package/dist/{route-rendering-hUETRCbM.d.ts → route-rendering-CWYd8Mv1.d.ts} +1 -1
  137. package/dist/{route-rendering-LT4XSoQK.d.mts → route-rendering-CeFBEAoZ.d.mts} +1 -1
  138. package/dist/routes.cjs +68 -31
  139. package/dist/routes.d.mts +5 -3
  140. package/dist/routes.d.ts +5 -3
  141. package/dist/routes.mjs +2 -2
  142. package/dist/server-fn-client.d.mts +3 -2
  143. package/dist/server-fn-client.d.ts +3 -2
  144. package/dist/server-fn.cjs +212 -32
  145. package/dist/server-fn.d.mts +72 -1
  146. package/dist/server-fn.d.ts +72 -1
  147. package/dist/server-fn.mjs +13 -2
  148. package/dist/server-plugins.d.mts +6 -3
  149. package/dist/server-plugins.d.ts +6 -3
  150. package/dist/server-query-client.cjs +62 -28
  151. package/dist/server-query-client.d.mts +1 -0
  152. package/dist/server-query-client.d.ts +1 -0
  153. package/dist/server-query-client.mjs +4 -4
  154. package/dist/server-query.cjs +131 -32
  155. package/dist/server-query.d.mts +6 -1
  156. package/dist/server-query.d.ts +6 -1
  157. package/dist/server-query.mjs +4 -3
  158. package/dist/server.cjs +393 -84
  159. package/dist/server.d.mts +9 -8
  160. package/dist/server.d.ts +9 -8
  161. package/dist/server.mjs +22 -22
  162. package/dist/{spa-router-csKR9Ebj.d.mts → spa-router-CQWiYGxS.d.mts} +2 -2
  163. package/dist/{spa-router-Y_2FSJQK.d.ts → spa-router-Wjiw-8hB.d.ts} +2 -2
  164. package/dist/testing.cjs +73 -32
  165. package/dist/testing.d.mts +5 -3
  166. package/dist/testing.d.ts +5 -3
  167. package/dist/testing.mjs +11 -7
  168. package/dist/{utils-jISOE9SD.d.ts → utils-B0XJmG_b.d.ts} +1 -1
  169. package/dist/{utils-DR2wfZAn.d.mts → utils-uUxF0K0P.d.mts} +1 -1
  170. package/dist/version.cjs +1 -1
  171. package/dist/version.mjs +1 -1
  172. package/dist/vite.cjs +500 -252
  173. package/dist/vite.d.mts +5 -2
  174. package/dist/vite.d.ts +5 -2
  175. package/dist/vite.mjs +19 -19
  176. package/dist/workflows.mjs +2 -2
  177. package/package.json +2 -2
  178. package/dist/{chunk-VO5SCWF5.mjs → chunk-BNGS6KJ6.mjs} +0 -0
  179. package/dist/{chunk-MUUZJLCI.mjs → chunk-EGJDUF4Q.mjs} +3 -3
  180. package/dist/{chunk-4L7SZOHZ.mjs → chunk-YHOCRI4H.mjs} +3 -3
@@ -1,7 +1,8 @@
1
1
  import { ChildProcess } from 'node:child_process';
2
- import { B as BundleResultPayload, a as FarmPlugin, v as FarmIntegration } from './client-plugins-C1EgdoJM.mjs';
2
+ import { B as BundleResultPayload, a as FarmPlugin, v as FarmIntegration } from './client-plugins-JXXmZliS.mjs';
3
3
  import './lifecycle-DK06VuKP.mjs';
4
- import './route-C6UClI1z.mjs';
4
+ import './route-B0XrsrFk.mjs';
5
+ import './endpoint-DAc96i93.mjs';
5
6
  import './cache.mjs';
6
7
  import './renderer.mjs';
7
8
  import './deployment.mjs';
@@ -28,6 +29,8 @@ import './server-fn-error-DDh14a0V.mjs';
28
29
  import 'esbuild';
29
30
  import './image-config-Duob7wER.mjs';
30
31
  import './types-Z0aotQ8w.mjs';
32
+ import './server-fn.mjs';
33
+ import './server-query.mjs';
31
34
  import './types-DQnyD3VD.mjs';
32
35
  import './font.mjs';
33
36
  import './after.mjs';
@@ -1,7 +1,8 @@
1
1
  import { ChildProcess } from 'node:child_process';
2
- import { B as BundleResultPayload, a as FarmPlugin, v as FarmIntegration } from './client-plugins-CslwYp3E.js';
2
+ import { B as BundleResultPayload, a as FarmPlugin, v as FarmIntegration } from './client-plugins-C089bQhN.js';
3
3
  import './lifecycle-DK06VuKP.js';
4
- import './route-CHBaW55F.js';
4
+ import './route-DOEpbyWZ.js';
5
+ import './endpoint-1zA994xL.js';
5
6
  import './cache.js';
6
7
  import './renderer.js';
7
8
  import './deployment.js';
@@ -28,6 +29,8 @@ import './server-fn-error-DDh14a0V.js';
28
29
  import 'esbuild';
29
30
  import './image-config-Duob7wER.js';
30
31
  import './types-Z0aotQ8w.js';
32
+ import './server-fn.js';
33
+ import './server-query.js';
31
34
  import './types-DQnyD3VD.js';
32
35
  import './font.js';
33
36
  import './after.js';
@@ -1353,6 +1353,8 @@ var _FarmDataCache = class _FarmDataCache {
1353
1353
  constructor(config = {}) {
1354
1354
  this.entries = /* @__PURE__ */ new Map();
1355
1355
  this.inflight = /* @__PURE__ */ new Map();
1356
+ /** Local entries by tag, so tag counts and pruning never scan unrelated entries. */
1357
+ this.entriesByTag = /* @__PURE__ */ new Map();
1356
1358
  this.invalidatedTagVersions = /* @__PURE__ */ new Map();
1357
1359
  this.activeGenerations = /* @__PURE__ */ new Set();
1358
1360
  this.version = 0;
@@ -1371,6 +1373,7 @@ var _FarmDataCache = class _FarmDataCache {
1371
1373
  configure(config = {}) {
1372
1374
  this.generation++;
1373
1375
  this.entries.clear();
1376
+ this.entriesByTag.clear();
1374
1377
  this.inflight.clear();
1375
1378
  this.invalidatedTagVersions.clear();
1376
1379
  this.activeGenerations.clear();
@@ -1537,14 +1540,12 @@ var _FarmDataCache = class _FarmDataCache {
1537
1540
  return entry;
1538
1541
  }
1539
1542
  delete(key) {
1540
- const deleted = this.entries.delete(key);
1541
- if (deleted) this.pruneInvalidatedTagVersions();
1543
+ const deleted = this.deleteLocalEntry(key);
1542
1544
  emitFarmEvent({ type: "cache.delete", key, deleted });
1543
1545
  return deleted;
1544
1546
  }
1545
1547
  async deleteAsync(key) {
1546
- const deleted = this.entries.delete(key);
1547
- if (deleted) this.pruneInvalidatedTagVersions();
1548
+ const deleted = this.deleteLocalEntry(key);
1548
1549
  if (this.adapter) {
1549
1550
  await this.adapter.delete(this.createAdapterKey(key));
1550
1551
  }
@@ -1555,6 +1556,7 @@ var _FarmDataCache = class _FarmDataCache {
1555
1556
  const count = this.entries.size;
1556
1557
  this.generation++;
1557
1558
  this.entries.clear();
1559
+ this.entriesByTag.clear();
1558
1560
  this.inflight.clear();
1559
1561
  this.invalidatedTagVersions.clear();
1560
1562
  this.activeGenerations.clear();
@@ -1640,23 +1642,32 @@ var _FarmDataCache = class _FarmDataCache {
1640
1642
  return cached.value;
1641
1643
  }
1642
1644
  const inflight = this.inflight.get(key);
1643
- if (inflight) {
1645
+ if (inflight && !this.wasInvalidatedSince(inflight.tags, inflight.startVersion)) {
1644
1646
  emitFarmEvent({ type: "cache.dedupe", key });
1645
- return inflight;
1647
+ return inflight.promise;
1646
1648
  }
1647
1649
  const tags = Array.from(normalizeCacheOptionsTags(options));
1648
1650
  const generation = this.generation;
1651
+ const startVersion = this.version;
1649
1652
  const promise = this.fillCacheEntry(key, producer, options, tags, generation).catch((error) => {
1650
1653
  emitFarmEvent({ type: "cache.error", key, operation: "set", error });
1651
1654
  throw error;
1652
1655
  }).finally(() => {
1653
- if (this.inflight.get(key) === promise) {
1656
+ if (this.inflight.get(key)?.promise === promise) {
1654
1657
  this.inflight.delete(key);
1655
1658
  }
1656
1659
  });
1657
- this.inflight.set(key, promise);
1660
+ this.inflight.set(key, { promise, tags, startVersion });
1658
1661
  return promise;
1659
1662
  }
1663
+ /** A fill that started before one of its tags was invalidated cannot satisfy later readers. */
1664
+ wasInvalidatedSince(tags, version) {
1665
+ for (const tag of tags) {
1666
+ const invalidatedVersion = this.invalidatedTagVersions.get(tag);
1667
+ if (invalidatedVersion !== void 0 && invalidatedVersion > version) return true;
1668
+ }
1669
+ return false;
1670
+ }
1660
1671
  async fillCacheEntry(key, producer, options, tags, generation) {
1661
1672
  const adapter = this.adapter;
1662
1673
  const namespace = this.namespace;
@@ -1697,7 +1708,7 @@ var _FarmDataCache = class _FarmDataCache {
1697
1708
  return value;
1698
1709
  } finally {
1699
1710
  this.activeGenerations.delete(activeGeneration);
1700
- this.pruneInvalidatedTagVersions();
1711
+ this.pruneInvalidatedTagVersions(activeGeneration.tags);
1701
1712
  if (leaseToken && adapter?.releaseLease) {
1702
1713
  try {
1703
1714
  await adapter.releaseLease(leaseKey, leaseToken);
@@ -1742,18 +1753,9 @@ var _FarmDataCache = class _FarmDataCache {
1742
1753
  }
1743
1754
  return void 0;
1744
1755
  }
1745
- countEntriesForTag(tag) {
1746
- let count = 0;
1747
- for (const entry of this.entries.values()) {
1748
- if (entry.tags.has(tag)) {
1749
- count++;
1750
- }
1751
- }
1752
- return count;
1753
- }
1754
1756
  countEntriesForTags(tags) {
1755
1757
  let count = 0;
1756
- for (const entry of this.entries.values()) {
1758
+ for (const entry of this.entriesByTag.get(tags[0]) ?? []) {
1757
1759
  if (tags.every((tag) => entry.tags.has(tag))) {
1758
1760
  count++;
1759
1761
  }
@@ -1761,10 +1763,10 @@ var _FarmDataCache = class _FarmDataCache {
1761
1763
  return count;
1762
1764
  }
1763
1765
  invalidateTag(normalizedTag) {
1764
- const count = this.countEntriesForTag(normalizedTag);
1766
+ const count = this.entriesByTag.get(normalizedTag)?.size ?? 0;
1765
1767
  this.invalidatedTagVersions.delete(normalizedTag);
1766
1768
  this.invalidatedTagVersions.set(normalizedTag, ++this.version);
1767
- this.pruneInvalidatedTagVersions();
1769
+ this.pruneInvalidatedTagVersions([normalizedTag]);
1768
1770
  return count;
1769
1771
  }
1770
1772
  toPublicEntry(entry) {
@@ -1794,19 +1796,51 @@ var _FarmDataCache = class _FarmDataCache {
1794
1796
  this.entries.set(key, entry);
1795
1797
  }
1796
1798
  storeLocalEntry(entry) {
1797
- this.entries.delete(entry.key);
1799
+ const removed = [];
1800
+ const replaced = this.detachLocalEntry(entry.key);
1801
+ if (replaced) removed.push(replaced);
1798
1802
  this.entries.set(entry.key, entry);
1803
+ for (const tag of entry.tags) {
1804
+ let tagged = this.entriesByTag.get(tag);
1805
+ if (!tagged) this.entriesByTag.set(tag, tagged = /* @__PURE__ */ new Set());
1806
+ tagged.add(entry);
1807
+ }
1799
1808
  while (this.entries.size > this.maxEntries) {
1800
1809
  const oldestKey = this.entries.keys().next().value;
1801
1810
  if (oldestKey === void 0) break;
1802
- this.entries.delete(oldestKey);
1811
+ removed.push(this.detachLocalEntry(oldestKey));
1803
1812
  }
1804
- this.pruneInvalidatedTagVersions();
1813
+ for (const removedEntry of removed) this.pruneInvalidatedTagVersions(removedEntry.tags);
1805
1814
  }
1806
- pruneInvalidatedTagVersions() {
1807
- tags: for (const [tag, invalidatedVersion] of this.invalidatedTagVersions) {
1808
- for (const entry of this.entries.values()) {
1809
- if (entry.tags.has(tag) && entry.createdVersion < invalidatedVersion) continue tags;
1815
+ deleteLocalEntry(key) {
1816
+ const entry = this.detachLocalEntry(key);
1817
+ if (!entry) return false;
1818
+ this.pruneInvalidatedTagVersions(entry.tags);
1819
+ return true;
1820
+ }
1821
+ detachLocalEntry(key) {
1822
+ const entry = this.entries.get(key);
1823
+ if (!entry) return void 0;
1824
+ this.entries.delete(key);
1825
+ for (const tag of entry.tags) {
1826
+ const tagged = this.entriesByTag.get(tag);
1827
+ if (!tagged) continue;
1828
+ tagged.delete(entry);
1829
+ if (tagged.size === 0) this.entriesByTag.delete(tag);
1830
+ }
1831
+ return entry;
1832
+ }
1833
+ /**
1834
+ * Drop invalidation versions that no local entry or active fill can be stale against.
1835
+ * Callers pass only the tags whose dependents just changed, so the cost is bounded by
1836
+ * the entries sharing those tags rather than by the whole cache.
1837
+ */
1838
+ pruneInvalidatedTagVersions(tags) {
1839
+ tags: for (const tag of tags) {
1840
+ const invalidatedVersion = this.invalidatedTagVersions.get(tag);
1841
+ if (invalidatedVersion === void 0) continue;
1842
+ for (const entry of this.entriesByTag.get(tag) ?? []) {
1843
+ if (entry.createdVersion < invalidatedVersion) continue tags;
1810
1844
  }
1811
1845
  for (const generation of this.activeGenerations) {
1812
1846
  if (generation.tags.has(tag) && generation.createdVersion < invalidatedVersion)
@@ -1,5 +1,6 @@
1
- export { v as APIClient, h as APIClientError, b as APIClientOptions, i as APIClientSystemError, c as APIClientWithoutIntegrationsOptions, x as ApiClients, u as RouteAPIClient, w as ServerAPIClient, S as ServerAPIClientOptions, d as ServerAPIClientWithoutIntegrationsOptions, z as createAPIClient, y as createApiClients, E as createServerAPIClient } from '../api-client-C8d7BZNp.mjs';
1
+ export { v as APIClient, h as APIClientError, b as APIClientOptions, i as APIClientSystemError, c as APIClientWithoutIntegrationsOptions, x as ApiClients, u as RouteAPIClient, w as ServerAPIClient, S as ServerAPIClientOptions, d as ServerAPIClientWithoutIntegrationsOptions, z as createAPIClient, y as createApiClients, E as createServerAPIClient } from '../api-client-Cx54IR5g.mjs';
2
2
  import '../integration-api-BbaiokCC.mjs';
3
3
  import '../client-cache-di_Nasxa.mjs';
4
4
  import '../cache.mjs';
5
- import '../route-C6UClI1z.mjs';
5
+ import '../route-B0XrsrFk.mjs';
6
+ import '../endpoint-DAc96i93.mjs';
@@ -1,5 +1,6 @@
1
- export { v as APIClient, h as APIClientError, b as APIClientOptions, i as APIClientSystemError, c as APIClientWithoutIntegrationsOptions, x as ApiClients, u as RouteAPIClient, w as ServerAPIClient, S as ServerAPIClientOptions, d as ServerAPIClientWithoutIntegrationsOptions, z as createAPIClient, y as createApiClients, E as createServerAPIClient } from '../api-client-BWrEbxfO.js';
1
+ export { v as APIClient, h as APIClientError, b as APIClientOptions, i as APIClientSystemError, c as APIClientWithoutIntegrationsOptions, x as ApiClients, u as RouteAPIClient, w as ServerAPIClient, S as ServerAPIClientOptions, d as ServerAPIClientWithoutIntegrationsOptions, z as createAPIClient, y as createApiClients, E as createServerAPIClient } from '../api-client-DykpaKcY.js';
2
2
  import '../integration-api-BbaiokCC.js';
3
3
  import '../client-cache-Deoqq-nM.js';
4
4
  import '../cache.js';
5
- import '../route-CHBaW55F.js';
5
+ import '../route-DOEpbyWZ.js';
6
+ import '../endpoint-1zA994xL.js';
@@ -3,15 +3,15 @@ import {
3
3
  createAPIClient,
4
4
  createApiClients,
5
5
  createServerAPIClient
6
- } from "../chunk-KUO3GBPK.mjs";
6
+ } from "../chunk-L6V3P73N.mjs";
7
7
  import "../chunk-72AK62H5.mjs";
8
- import "../chunk-HKLRP3BN.mjs";
8
+ import "../chunk-5SPPCN5J.mjs";
9
9
  import "../chunk-QVYLBY73.mjs";
10
10
  import "../chunk-G4MWPDSE.mjs";
11
11
  import "../chunk-O7BH5O46.mjs";
12
12
  import "../chunk-EMLAPBEM.mjs";
13
13
  import "../chunk-7LTCDQRS.mjs";
14
- import "../chunk-IGO2HEV7.mjs";
14
+ import "../chunk-F6SJAKFJ.mjs";
15
15
  import "../chunk-4SIYUGRY.mjs";
16
16
  import "../chunk-C4NCTZLM.mjs";
17
17
  import "../chunk-FUZEBRP3.mjs";
@@ -810,6 +810,8 @@ var init_cache = __esm({
810
810
  constructor(config = {}) {
811
811
  this.entries = /* @__PURE__ */ new Map();
812
812
  this.inflight = /* @__PURE__ */ new Map();
813
+ /** Local entries by tag, so tag counts and pruning never scan unrelated entries. */
814
+ this.entriesByTag = /* @__PURE__ */ new Map();
813
815
  this.invalidatedTagVersions = /* @__PURE__ */ new Map();
814
816
  this.activeGenerations = /* @__PURE__ */ new Set();
815
817
  this.version = 0;
@@ -828,6 +830,7 @@ var init_cache = __esm({
828
830
  configure(config = {}) {
829
831
  this.generation++;
830
832
  this.entries.clear();
833
+ this.entriesByTag.clear();
831
834
  this.inflight.clear();
832
835
  this.invalidatedTagVersions.clear();
833
836
  this.activeGenerations.clear();
@@ -994,14 +997,12 @@ var init_cache = __esm({
994
997
  return entry;
995
998
  }
996
999
  delete(key) {
997
- const deleted = this.entries.delete(key);
998
- if (deleted) this.pruneInvalidatedTagVersions();
1000
+ const deleted = this.deleteLocalEntry(key);
999
1001
  emitFarmEvent({ type: "cache.delete", key, deleted });
1000
1002
  return deleted;
1001
1003
  }
1002
1004
  async deleteAsync(key) {
1003
- const deleted = this.entries.delete(key);
1004
- if (deleted) this.pruneInvalidatedTagVersions();
1005
+ const deleted = this.deleteLocalEntry(key);
1005
1006
  if (this.adapter) {
1006
1007
  await this.adapter.delete(this.createAdapterKey(key));
1007
1008
  }
@@ -1012,6 +1013,7 @@ var init_cache = __esm({
1012
1013
  const count = this.entries.size;
1013
1014
  this.generation++;
1014
1015
  this.entries.clear();
1016
+ this.entriesByTag.clear();
1015
1017
  this.inflight.clear();
1016
1018
  this.invalidatedTagVersions.clear();
1017
1019
  this.activeGenerations.clear();
@@ -1097,23 +1099,32 @@ var init_cache = __esm({
1097
1099
  return cached.value;
1098
1100
  }
1099
1101
  const inflight = this.inflight.get(key);
1100
- if (inflight) {
1102
+ if (inflight && !this.wasInvalidatedSince(inflight.tags, inflight.startVersion)) {
1101
1103
  emitFarmEvent({ type: "cache.dedupe", key });
1102
- return inflight;
1104
+ return inflight.promise;
1103
1105
  }
1104
1106
  const tags = Array.from(normalizeCacheOptionsTags(options));
1105
1107
  const generation = this.generation;
1108
+ const startVersion = this.version;
1106
1109
  const promise = this.fillCacheEntry(key, producer, options, tags, generation).catch((error) => {
1107
1110
  emitFarmEvent({ type: "cache.error", key, operation: "set", error });
1108
1111
  throw error;
1109
1112
  }).finally(() => {
1110
- if (this.inflight.get(key) === promise) {
1113
+ if (this.inflight.get(key)?.promise === promise) {
1111
1114
  this.inflight.delete(key);
1112
1115
  }
1113
1116
  });
1114
- this.inflight.set(key, promise);
1117
+ this.inflight.set(key, { promise, tags, startVersion });
1115
1118
  return promise;
1116
1119
  }
1120
+ /** A fill that started before one of its tags was invalidated cannot satisfy later readers. */
1121
+ wasInvalidatedSince(tags, version) {
1122
+ for (const tag of tags) {
1123
+ const invalidatedVersion = this.invalidatedTagVersions.get(tag);
1124
+ if (invalidatedVersion !== void 0 && invalidatedVersion > version) return true;
1125
+ }
1126
+ return false;
1127
+ }
1117
1128
  async fillCacheEntry(key, producer, options, tags, generation) {
1118
1129
  const adapter = this.adapter;
1119
1130
  const namespace = this.namespace;
@@ -1154,7 +1165,7 @@ var init_cache = __esm({
1154
1165
  return value;
1155
1166
  } finally {
1156
1167
  this.activeGenerations.delete(activeGeneration);
1157
- this.pruneInvalidatedTagVersions();
1168
+ this.pruneInvalidatedTagVersions(activeGeneration.tags);
1158
1169
  if (leaseToken && adapter?.releaseLease) {
1159
1170
  try {
1160
1171
  await adapter.releaseLease(leaseKey, leaseToken);
@@ -1199,18 +1210,9 @@ var init_cache = __esm({
1199
1210
  }
1200
1211
  return void 0;
1201
1212
  }
1202
- countEntriesForTag(tag) {
1203
- let count = 0;
1204
- for (const entry of this.entries.values()) {
1205
- if (entry.tags.has(tag)) {
1206
- count++;
1207
- }
1208
- }
1209
- return count;
1210
- }
1211
1213
  countEntriesForTags(tags) {
1212
1214
  let count = 0;
1213
- for (const entry of this.entries.values()) {
1215
+ for (const entry of this.entriesByTag.get(tags[0]) ?? []) {
1214
1216
  if (tags.every((tag) => entry.tags.has(tag))) {
1215
1217
  count++;
1216
1218
  }
@@ -1218,10 +1220,10 @@ var init_cache = __esm({
1218
1220
  return count;
1219
1221
  }
1220
1222
  invalidateTag(normalizedTag) {
1221
- const count = this.countEntriesForTag(normalizedTag);
1223
+ const count = this.entriesByTag.get(normalizedTag)?.size ?? 0;
1222
1224
  this.invalidatedTagVersions.delete(normalizedTag);
1223
1225
  this.invalidatedTagVersions.set(normalizedTag, ++this.version);
1224
- this.pruneInvalidatedTagVersions();
1226
+ this.pruneInvalidatedTagVersions([normalizedTag]);
1225
1227
  return count;
1226
1228
  }
1227
1229
  toPublicEntry(entry) {
@@ -1251,19 +1253,51 @@ var init_cache = __esm({
1251
1253
  this.entries.set(key, entry);
1252
1254
  }
1253
1255
  storeLocalEntry(entry) {
1254
- this.entries.delete(entry.key);
1256
+ const removed = [];
1257
+ const replaced = this.detachLocalEntry(entry.key);
1258
+ if (replaced) removed.push(replaced);
1255
1259
  this.entries.set(entry.key, entry);
1260
+ for (const tag of entry.tags) {
1261
+ let tagged = this.entriesByTag.get(tag);
1262
+ if (!tagged) this.entriesByTag.set(tag, tagged = /* @__PURE__ */ new Set());
1263
+ tagged.add(entry);
1264
+ }
1256
1265
  while (this.entries.size > this.maxEntries) {
1257
1266
  const oldestKey = this.entries.keys().next().value;
1258
1267
  if (oldestKey === void 0) break;
1259
- this.entries.delete(oldestKey);
1268
+ removed.push(this.detachLocalEntry(oldestKey));
1260
1269
  }
1261
- this.pruneInvalidatedTagVersions();
1270
+ for (const removedEntry of removed) this.pruneInvalidatedTagVersions(removedEntry.tags);
1271
+ }
1272
+ deleteLocalEntry(key) {
1273
+ const entry = this.detachLocalEntry(key);
1274
+ if (!entry) return false;
1275
+ this.pruneInvalidatedTagVersions(entry.tags);
1276
+ return true;
1262
1277
  }
1263
- pruneInvalidatedTagVersions() {
1264
- tags: for (const [tag, invalidatedVersion] of this.invalidatedTagVersions) {
1265
- for (const entry of this.entries.values()) {
1266
- if (entry.tags.has(tag) && entry.createdVersion < invalidatedVersion) continue tags;
1278
+ detachLocalEntry(key) {
1279
+ const entry = this.entries.get(key);
1280
+ if (!entry) return void 0;
1281
+ this.entries.delete(key);
1282
+ for (const tag of entry.tags) {
1283
+ const tagged = this.entriesByTag.get(tag);
1284
+ if (!tagged) continue;
1285
+ tagged.delete(entry);
1286
+ if (tagged.size === 0) this.entriesByTag.delete(tag);
1287
+ }
1288
+ return entry;
1289
+ }
1290
+ /**
1291
+ * Drop invalidation versions that no local entry or active fill can be stale against.
1292
+ * Callers pass only the tags whose dependents just changed, so the cost is bounded by
1293
+ * the entries sharing those tags rather than by the whole cache.
1294
+ */
1295
+ pruneInvalidatedTagVersions(tags) {
1296
+ tags: for (const tag of tags) {
1297
+ const invalidatedVersion = this.invalidatedTagVersions.get(tag);
1298
+ if (invalidatedVersion === void 0) continue;
1299
+ for (const entry of this.entriesByTag.get(tag) ?? []) {
1300
+ if (entry.createdVersion < invalidatedVersion) continue tags;
1267
1301
  }
1268
1302
  for (const generation of this.activeGenerations) {
1269
1303
  if (generation.tags.has(tag) && generation.createdVersion < invalidatedVersion)
@@ -2271,6 +2305,7 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
2271
2305
  }
2272
2306
  return rendererRuntime.createElement(...args);
2273
2307
  }, "createElement");
2308
+ const markFunctionComponent = /* @__PURE__ */ __name((component) => rendererRuntime?.markFunctionComponent?.(component) ?? component, "markFunctionComponent");
2274
2309
  const Component = route.component;
2275
2310
  if (route.pending) {
2276
2311
  const PendingComponent = route.pending;
@@ -2292,7 +2327,9 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
2292
2327
  throw error;
2293
2328
  }
2294
2329
  }, "FarmProgrammaticPageContent");
2295
- const PageContent = FarmProgrammaticPageContent2;
2330
+ const PageContent = markFunctionComponent(
2331
+ FarmProgrammaticPageContent2
2332
+ );
2296
2333
  const FarmProgrammaticPage = /* @__PURE__ */ __name(function FarmProgrammaticPage2(props) {
2297
2334
  return createElement(
2298
2335
  rendererRuntime.Suspense,
@@ -2302,7 +2339,7 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
2302
2339
  createElement(PageContent, props)
2303
2340
  );
2304
2341
  }, "FarmProgrammaticPage");
2305
- return FarmProgrammaticPage;
2342
+ return markFunctionComponent(FarmProgrammaticPage);
2306
2343
  }
2307
2344
  const FarmProgrammaticPageContent = /* @__PURE__ */ __name(async function FarmProgrammaticPageContent2(props) {
2308
2345
  try {
@@ -2321,7 +2358,7 @@ function createProgrammaticPageComponent(route, rendererRuntime) {
2321
2358
  throw error;
2322
2359
  }
2323
2360
  }, "FarmProgrammaticPageContent");
2324
- return FarmProgrammaticPageContent;
2361
+ return markFunctionComponent(FarmProgrammaticPageContent);
2325
2362
  }
2326
2363
  function readProgrammaticRouteProps(route, props, resources) {
2327
2364
  if (isProgrammaticRoutePropsResolved(props)) {
@@ -2793,7 +2830,7 @@ function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
2793
2830
  wrappedHandler
2794
2831
  );
2795
2832
  endpoint.__path = path3 || void 0;
2796
- endpoint.__method = options.method || "GET";
2833
+ endpoint.__method = options.method || (path3 ? "GET" : void 0);
2797
2834
  endpoint.__autoPath = !path3;
2798
2835
  endpoint.__handler = wrappedHandler;
2799
2836
  endpoint.__farmInvoke = (ctx) => runEndpointMiddleware(middleware, ctx, handler, error, options.invalidates);
@@ -1,4 +1,4 @@
1
- import { F as FarmRouteRuntimeConfig, a as FarmPlugin } from '../client-plugins-C1EgdoJM.mjs';
1
+ import { F as FarmRouteRuntimeConfig, a as FarmPlugin } from '../client-plugins-JXXmZliS.mjs';
2
2
  import { ViteDevServer } from 'vite';
3
3
  import '../types-Z0aotQ8w.mjs';
4
4
  import { F as FarmI18nRuntime } from '../runtime-AOJge4vQ.mjs';
@@ -6,7 +6,8 @@ export { API_ROUTE_METHODS, getAllowedAPIRouteMethods, invokeAPIRouteEndpoint, i
6
6
  import { A as APIRouteMatch } from '../route-pattern-W-SsJGSp.mjs';
7
7
  export { b as APIRouteParamValue, a as APIRouteParams, m as matchAPIRoute } from '../route-pattern-W-SsJGSp.mjs';
8
8
  import '../lifecycle-DK06VuKP.mjs';
9
- import '../route-C6UClI1z.mjs';
9
+ import '../route-B0XrsrFk.mjs';
10
+ import '../endpoint-DAc96i93.mjs';
10
11
  import '../cache.mjs';
11
12
  import '../renderer.mjs';
12
13
  import '../deployment.mjs';
@@ -31,6 +32,8 @@ import '../server-action-security.mjs';
31
32
  import '../server-fn-error-DDh14a0V.mjs';
32
33
  import 'esbuild';
33
34
  import '../image-config-Duob7wER.mjs';
35
+ import '../server-fn.mjs';
36
+ import '../server-query.mjs';
34
37
  import '../types-DQnyD3VD.mjs';
35
38
  import '../font.mjs';
36
39
  import '../after.mjs';
@@ -1,4 +1,4 @@
1
- import { F as FarmRouteRuntimeConfig, a as FarmPlugin } from '../client-plugins-CslwYp3E.js';
1
+ import { F as FarmRouteRuntimeConfig, a as FarmPlugin } from '../client-plugins-C089bQhN.js';
2
2
  import { ViteDevServer } from 'vite';
3
3
  import '../types-Z0aotQ8w.js';
4
4
  import { F as FarmI18nRuntime } from '../runtime-BirxPwbZ.js';
@@ -6,7 +6,8 @@ export { API_ROUTE_METHODS, getAllowedAPIRouteMethods, invokeAPIRouteEndpoint, i
6
6
  import { A as APIRouteMatch } from '../route-pattern-W-SsJGSp.js';
7
7
  export { b as APIRouteParamValue, a as APIRouteParams, m as matchAPIRoute } from '../route-pattern-W-SsJGSp.js';
8
8
  import '../lifecycle-DK06VuKP.js';
9
- import '../route-CHBaW55F.js';
9
+ import '../route-DOEpbyWZ.js';
10
+ import '../endpoint-1zA994xL.js';
10
11
  import '../cache.js';
11
12
  import '../renderer.js';
12
13
  import '../deployment.js';
@@ -31,6 +32,8 @@ import '../server-action-security.js';
31
32
  import '../server-fn-error-DDh14a0V.js';
32
33
  import 'esbuild';
33
34
  import '../image-config-Duob7wER.js';
35
+ import '../server-fn.js';
36
+ import '../server-query.js';
34
37
  import '../types-DQnyD3VD.js';
35
38
  import '../font.js';
36
39
  import '../after.js';
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  APIRouteConflictError,
3
3
  APIRouteManager
4
- } from "../chunk-ZHOIQC6U.mjs";
5
- import "../chunk-VO5SCWF5.mjs";
4
+ } from "../chunk-ATERBVHQ.mjs";
5
+ import "../chunk-BNGS6KJ6.mjs";
6
6
  import "../chunk-CU625VAY.mjs";
7
7
  import "../chunk-JNGIWIY6.mjs";
8
8
  import "../chunk-FV45CKBC.mjs";
@@ -13,9 +13,9 @@ import {
13
13
  isWebResponse,
14
14
  normalizeRouteResponse,
15
15
  resolveAPIRouteEndpoint
16
- } from "../chunk-DPZUDPVJ.mjs";
16
+ } from "../chunk-XP777LRD.mjs";
17
17
  import "../chunk-I6XDAKWQ.mjs";
18
- import "../chunk-OWTIOHON.mjs";
18
+ import "../chunk-SYGGPS4A.mjs";
19
19
  import "../chunk-W3B4PKAW.mjs";
20
20
  import "../chunk-5WI2S4CO.mjs";
21
21
  import "../chunk-EA5K5BKU.mjs";
@@ -31,7 +31,7 @@ import {
31
31
  import "../chunk-EMLAPBEM.mjs";
32
32
  import "../chunk-7LTCDQRS.mjs";
33
33
  import "../chunk-IXUY2F5U.mjs";
34
- import "../chunk-IGO2HEV7.mjs";
34
+ import "../chunk-F6SJAKFJ.mjs";
35
35
  import "../chunk-4SIYUGRY.mjs";
36
36
  import "../chunk-C4NCTZLM.mjs";
37
37
  import "../chunk-FUZEBRP3.mjs";