@farm.js/core 0.1.0-beta.1 → 0.1.0-beta.4
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.
- package/README.md +1 -1
- package/dist/agent-runtime.d.mts +2 -1
- package/dist/agent-runtime.d.ts +2 -1
- package/dist/api/route-manager.cjs +410 -15
- package/dist/api/route-manager.cjs.map +1 -1
- package/dist/api/route-manager.d.mts +4 -2
- package/dist/api/route-manager.d.ts +4 -2
- package/dist/api/route-manager.mjs +9 -8
- package/dist/api/runtime.cjs +748 -9
- package/dist/api/runtime.cjs.map +1 -1
- package/dist/api/runtime.d.mts +3 -16
- package/dist/api/runtime.d.ts +3 -16
- package/dist/api/runtime.mjs +8 -1
- package/dist/api.cjs +1243 -342
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +5 -147
- package/dist/api.d.ts +5 -147
- package/dist/api.mjs +51 -21
- package/dist/{app-CFRNJXP1.d.ts → app-BjN-da13.d.ts} +38 -3
- package/dist/{app-BiX4qb-d.d.mts → app-CakAr8Be.d.mts} +38 -3
- package/dist/app-markdown.cjs +1 -1
- package/dist/app-markdown.cjs.map +1 -1
- package/dist/app-markdown.d.mts +2 -1
- package/dist/app-markdown.d.ts +2 -1
- package/dist/app-markdown.mjs +1 -1
- package/dist/cache.cjs +414 -12
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.mts +120 -6
- package/dist/cache.d.ts +120 -6
- package/dist/cache.mjs +11 -3
- package/dist/{chunk-Y7A27276.mjs → chunk-2CUKEMVR.mjs} +349 -15
- package/dist/chunk-2CUKEMVR.mjs.map +1 -0
- package/dist/{chunk-QF4PHCMA.mjs → chunk-2ED5Q2GH.mjs} +3 -3
- package/dist/chunk-2ED5Q2GH.mjs.map +1 -0
- package/dist/{chunk-GZP5W4K3.mjs → chunk-32W4QEJP.mjs} +1 -1
- package/dist/chunk-32W4QEJP.mjs.map +1 -0
- package/dist/{chunk-TRORP7E4.mjs → chunk-3U3ZUQAQ.mjs} +2 -2
- package/dist/{chunk-25D7G34K.mjs → chunk-65A7QIKI.mjs} +5 -5
- package/dist/{chunk-25D7G34K.mjs.map → chunk-65A7QIKI.mjs.map} +1 -1
- package/dist/{chunk-G3B5BRDY.mjs → chunk-AJWRO5WE.mjs} +539 -61
- package/dist/chunk-AJWRO5WE.mjs.map +1 -0
- package/dist/chunk-ALCLXXTY.mjs +187 -0
- package/dist/chunk-ALCLXXTY.mjs.map +1 -0
- package/dist/{chunk-CHFHNEMO.mjs → chunk-AOBXKNS5.mjs} +627 -84
- package/dist/chunk-AOBXKNS5.mjs.map +1 -0
- package/dist/{chunk-B6N4ZB2H.mjs → chunk-C2ROET2V.mjs} +3 -3
- package/dist/{chunk-JN3UU635.mjs → chunk-EJ7T4TPB.mjs} +2 -2
- package/dist/chunk-EJ7T4TPB.mjs.map +1 -0
- package/dist/{chunk-ZJQNATYV.mjs → chunk-FRPWCMMG.mjs} +3 -3
- package/dist/chunk-FRPWCMMG.mjs.map +1 -0
- package/dist/{chunk-QM6VV26B.mjs → chunk-GQVGIUSN.mjs} +3 -3
- package/dist/{chunk-QM6VV26B.mjs.map → chunk-GQVGIUSN.mjs.map} +1 -1
- package/dist/{chunk-UREJA4GZ.mjs → chunk-GXASWWJU.mjs} +1 -1
- package/dist/{chunk-UREJA4GZ.mjs.map → chunk-GXASWWJU.mjs.map} +1 -1
- package/dist/{chunk-3QJO55ZF.mjs → chunk-HNIQFZKB.mjs} +5 -3
- package/dist/{chunk-3QJO55ZF.mjs.map → chunk-HNIQFZKB.mjs.map} +1 -1
- package/dist/{chunk-PRNYWD7K.mjs → chunk-JDEOUK5V.mjs} +67 -239
- package/dist/chunk-JDEOUK5V.mjs.map +1 -0
- package/dist/{chunk-O3HADRW6.mjs → chunk-MIUW47JX.mjs} +2 -2
- package/dist/{chunk-O3HADRW6.mjs.map → chunk-MIUW47JX.mjs.map} +1 -1
- package/dist/{chunk-UHE2TTLK.mjs → chunk-NM3CRAAL.mjs} +9 -8
- package/dist/chunk-NM3CRAAL.mjs.map +1 -0
- package/dist/chunk-PFE6GMNE.mjs +603 -0
- package/dist/chunk-PFE6GMNE.mjs.map +1 -0
- package/dist/{chunk-S2XHZS7W.mjs → chunk-QGQX7SFC.mjs} +2 -2
- package/dist/chunk-QGQX7SFC.mjs.map +1 -0
- package/dist/{chunk-RKI6TN3A.mjs → chunk-QM746KUO.mjs} +9 -2
- package/dist/chunk-QM746KUO.mjs.map +1 -0
- package/dist/chunk-RBRLLZL5.mjs +81 -0
- package/dist/chunk-RBRLLZL5.mjs.map +1 -0
- package/dist/{chunk-HXP3ZSPC.mjs → chunk-SADGIRS2.mjs} +3 -3
- package/dist/{chunk-6XDUHOEM.mjs → chunk-TQAEEJB4.mjs} +3 -3
- package/dist/{chunk-AGS7UJ52.mjs → chunk-UB5UOSHB.mjs} +24 -12
- package/dist/chunk-UB5UOSHB.mjs.map +1 -0
- package/dist/{chunk-SXZTEK3V.mjs → chunk-UXUAWNO5.mjs} +2 -2
- package/dist/chunk-V3XURYJO.mjs +756 -0
- package/dist/chunk-V3XURYJO.mjs.map +1 -0
- package/dist/{chunk-TU4YJICB.mjs → chunk-VVKWFZAH.mjs} +41 -16
- package/dist/chunk-VVKWFZAH.mjs.map +1 -0
- package/dist/{chunk-JLWMCADZ.mjs → chunk-VY2UYN5R.mjs} +24 -4
- package/dist/chunk-VY2UYN5R.mjs.map +1 -0
- package/dist/{chunk-QFQRHRZS.mjs → chunk-W2CRQFF6.mjs} +151 -23
- package/dist/chunk-W2CRQFF6.mjs.map +1 -0
- package/dist/chunk-W4UIVMVI.mjs +10 -0
- package/dist/chunk-W4UIVMVI.mjs.map +1 -0
- package/dist/{chunk-Y2OJJD7R.mjs → chunk-XIVV5IWN.mjs} +7 -9
- package/dist/chunk-XIVV5IWN.mjs.map +1 -0
- package/dist/{chunk-OYXO65LI.mjs → chunk-YW7OBE6Q.mjs} +4 -4
- package/dist/chunk-YW7OBE6Q.mjs.map +1 -0
- package/dist/{chunk-YHU7SS6L.mjs → chunk-Z5CQMP54.mjs} +11 -11
- package/dist/{chunk-SOU3Q3ZA.mjs → chunk-ZZ57EH5Z.mjs} +1 -1
- package/dist/chunk-ZZ57EH5Z.mjs.map +1 -0
- package/dist/{client-D_yUjVhe.d.mts → client-BT1mFQas.d.mts} +55 -10
- package/dist/{client-Dkc03WP8.d.ts → client-Nn0q4eO4.d.ts} +55 -10
- package/dist/{client-plugins-BZnpeTGA.d.ts → client-plugins-Cw4qUGsw.d.ts} +7 -0
- package/dist/{client-plugins-g4bzuCmo.d.mts → client-plugins-DQQ1adXM.d.mts} +7 -0
- package/dist/client-plugins.d.mts +2 -1
- package/dist/client-plugins.d.ts +2 -1
- package/dist/client.cjs +922 -91
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +121 -3
- package/dist/client.d.ts +121 -3
- package/dist/client.mjs +23 -16
- package/dist/config.d.mts +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.mjs +1 -1
- package/dist/{devtools-AE4RVXCM.mjs → devtools-LVC3VB5P.mjs} +10 -10
- package/dist/{devtools-client-6WPY2AQU.mjs → devtools-client-3XRTBND5.mjs} +2 -11
- package/dist/devtools-client-3XRTBND5.mjs.map +1 -0
- package/dist/docs.cjs +14 -2
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.mjs +10 -10
- package/dist/i18n/server.cjs +2 -2
- package/dist/i18n/server.cjs.map +1 -1
- package/dist/i18n/server.mjs +1 -1
- package/dist/index.cjs +2852 -463
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.mjs +152 -109
- package/dist/index.mjs.map +1 -1
- package/dist/integrations.d.mts +2 -1
- package/dist/integrations.d.ts +2 -1
- package/dist/internal/build-runtime.cjs +1616 -149
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +4 -3
- package/dist/internal/build-runtime.d.ts +4 -3
- package/dist/internal/build-runtime.mjs +27 -25
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +1 -1
- package/dist/internal/config-runtime.cjs +13 -2
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +3 -2
- package/dist/internal/config-runtime.d.ts +3 -2
- package/dist/internal/config-runtime.mjs +9 -9
- package/dist/internal/production-runtime.cjs +285 -9
- package/dist/internal/production-runtime.cjs.map +1 -1
- package/dist/internal/production-runtime.d.mts +4 -4
- package/dist/internal/production-runtime.d.ts +4 -4
- package/dist/internal/production-runtime.mjs +10 -8
- package/dist/{metadata-DAXRaOHx.d.ts → metadata-BAPg_Nmo.d.ts} +1 -1
- package/dist/{metadata-C9NZxMDW.d.mts → metadata-_6i9oFG3.d.mts} +1 -1
- package/dist/middleware.cjs +2 -2
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +4 -3
- package/dist/middleware.d.ts +4 -3
- package/dist/middleware.mjs +3 -3
- package/dist/navigation.cjs +40 -15
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.mjs +3 -3
- package/dist/{nitro-KME62MWG.mjs → nitro-QO5LV6QK.mjs} +11 -13
- package/dist/{nitro-KME62MWG.mjs.map → nitro-QO5LV6QK.mjs.map} +1 -1
- package/dist/plugin.cjs +1032 -92
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +2 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.mjs +23 -21
- package/dist/{production-runtime-DRkCHUvJ.d.ts → production-runtime-BoJDc5mc.d.ts} +1 -1
- package/dist/{production-runtime-flrjp_nC.d.mts → production-runtime-DPfgMV9Y.d.mts} +1 -1
- package/dist/routes.cjs +276 -6
- package/dist/routes.cjs.map +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.mjs +4 -4
- package/dist/runtime-9nQjVM7X.d.mts +206 -0
- package/dist/runtime-DgeS2skB.d.ts +206 -0
- package/dist/server-action-security.cjs +28 -10
- package/dist/server-action-security.cjs.map +1 -1
- package/dist/server-action-security.d.mts +2 -1
- package/dist/server-action-security.d.ts +2 -1
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn-client.cjs.map +1 -1
- package/dist/server-fn-client.d.mts +1 -0
- package/dist/server-fn-client.d.ts +1 -0
- package/dist/server-fn-client.mjs +1 -1
- package/dist/server-fn.cjs +785 -3
- package/dist/server-fn.cjs.map +1 -1
- package/dist/server-fn.d.mts +10 -1
- package/dist/server-fn.d.ts +10 -1
- package/dist/server-fn.mjs +6 -3
- package/dist/server-plugins.d.mts +3 -2
- package/dist/server-plugins.d.ts +3 -2
- package/dist/server-query-client.cjs +278 -7
- package/dist/server-query-client.cjs.map +1 -1
- package/dist/server-query-client.mjs +4 -4
- package/dist/server-query.cjs +381 -10
- package/dist/server-query.cjs.map +1 -1
- package/dist/server-query.mjs +5 -5
- package/dist/server.cjs +1233 -118
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +8 -7
- package/dist/server.d.ts +8 -7
- package/dist/server.mjs +53 -33
- package/dist/server.mjs.map +1 -1
- package/dist/testing.cjs +436 -25
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.mts +4 -3
- package/dist/testing.d.ts +4 -3
- package/dist/testing.mjs +19 -18
- package/dist/testing.mjs.map +1 -1
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/{utils-DOXXivjL.d.mts → utils-CHXlMDkg.d.mts} +1 -1
- package/dist/{utils-DA1yo54_.d.ts → utils-Drsyz1Vj.d.ts} +1 -1
- package/dist/version.cjs +36 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +8 -0
- package/dist/version.mjs.map +1 -0
- package/dist/vite.cjs +1039 -93
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +23 -21
- package/dist/workflows.cjs +6 -8
- package/dist/workflows.cjs.map +1 -1
- package/dist/workflows.mjs +1 -1
- package/package.json +12 -5
- package/types/api.d.ts +44 -0
- package/types/client.d.ts +220 -16
- package/dist/chunk-4PTK6KT4.mjs +0 -364
- package/dist/chunk-4PTK6KT4.mjs.map +0 -1
- package/dist/chunk-AGS7UJ52.mjs.map +0 -1
- package/dist/chunk-CHFHNEMO.mjs.map +0 -1
- package/dist/chunk-EVGBEZDF.mjs +0 -215
- package/dist/chunk-EVGBEZDF.mjs.map +0 -1
- package/dist/chunk-G3B5BRDY.mjs.map +0 -1
- package/dist/chunk-GZP5W4K3.mjs.map +0 -1
- package/dist/chunk-JLWMCADZ.mjs.map +0 -1
- package/dist/chunk-JN3UU635.mjs.map +0 -1
- package/dist/chunk-OYXO65LI.mjs.map +0 -1
- package/dist/chunk-PRNYWD7K.mjs.map +0 -1
- package/dist/chunk-QF4PHCMA.mjs.map +0 -1
- package/dist/chunk-QFQRHRZS.mjs.map +0 -1
- package/dist/chunk-RKI6TN3A.mjs.map +0 -1
- package/dist/chunk-S2XHZS7W.mjs.map +0 -1
- package/dist/chunk-SOU3Q3ZA.mjs.map +0 -1
- package/dist/chunk-TU4YJICB.mjs.map +0 -1
- package/dist/chunk-TXCFGOHW.mjs +0 -42
- package/dist/chunk-TXCFGOHW.mjs.map +0 -1
- package/dist/chunk-UHE2TTLK.mjs.map +0 -1
- package/dist/chunk-Y2OJJD7R.mjs.map +0 -1
- package/dist/chunk-Y7A27276.mjs.map +0 -1
- package/dist/chunk-ZJQNATYV.mjs.map +0 -1
- package/dist/devtools-client-6WPY2AQU.mjs.map +0 -1
- /package/dist/{chunk-TRORP7E4.mjs.map → chunk-3U3ZUQAQ.mjs.map} +0 -0
- /package/dist/{chunk-B6N4ZB2H.mjs.map → chunk-C2ROET2V.mjs.map} +0 -0
- /package/dist/{chunk-HXP3ZSPC.mjs.map → chunk-SADGIRS2.mjs.map} +0 -0
- /package/dist/{chunk-6XDUHOEM.mjs.map → chunk-TQAEEJB4.mjs.map} +0 -0
- /package/dist/{chunk-SXZTEK3V.mjs.map → chunk-UXUAWNO5.mjs.map} +0 -0
- /package/dist/{chunk-YHU7SS6L.mjs.map → chunk-Z5CQMP54.mjs.map} +0 -0
- /package/dist/{devtools-AE4RVXCM.mjs.map → devtools-LVC3VB5P.mjs.map} +0 -0
package/dist/cache.cjs
CHANGED
|
@@ -22,17 +22,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var cache_exports = {};
|
|
23
23
|
__export(cache_exports, {
|
|
24
24
|
FarmDataCache: () => FarmDataCache,
|
|
25
|
+
applyFarmCacheInvalidationTargets: () => applyFarmCacheInvalidationTargets,
|
|
25
26
|
applyFarmCacheInvalidations: () => applyFarmCacheInvalidations,
|
|
27
|
+
configureFarmCache: () => configureFarmCache,
|
|
26
28
|
createFarmCacheKey: () => createFarmCacheKey,
|
|
27
29
|
createPathCacheTag: () => createPathCacheTag,
|
|
28
30
|
createRouteDataCacheKey: () => createRouteDataCacheKey,
|
|
29
31
|
createRouteDataCacheTag: () => createRouteDataCacheTag,
|
|
32
|
+
defineCacheKey: () => defineCacheKey,
|
|
30
33
|
getFarmDataCache: () => getFarmDataCache,
|
|
31
34
|
invalidate: () => invalidate,
|
|
32
35
|
invalidateRouteData: () => invalidateRouteData,
|
|
33
36
|
normalizeRevalidatePath: () => normalizeRevalidatePath,
|
|
34
37
|
revalidatePath: () => revalidatePath,
|
|
35
38
|
revalidateTag: () => revalidateTag,
|
|
39
|
+
storageCacheAdapter: () => storageCacheAdapter,
|
|
36
40
|
unstable_cache: () => unstable_cache,
|
|
37
41
|
updateTag: () => updateTag
|
|
38
42
|
});
|
|
@@ -158,7 +162,8 @@ var FARM_CACHE_INVALIDATION_STATE = /* @__PURE__ */ Symbol.for("farm.cacheInvali
|
|
|
158
162
|
var globalState = globalThis;
|
|
159
163
|
function getFarmCacheInvalidationState() {
|
|
160
164
|
return globalState[FARM_CACHE_INVALIDATION_STATE] ?? (globalState[FARM_CACHE_INVALIDATION_STATE] = {
|
|
161
|
-
listeners: /* @__PURE__ */ new Set()
|
|
165
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
166
|
+
taskListeners: /* @__PURE__ */ new Set()
|
|
162
167
|
});
|
|
163
168
|
}
|
|
164
169
|
__name(getFarmCacheInvalidationState, "getFarmCacheInvalidationState");
|
|
@@ -169,6 +174,12 @@ function notifyFarmCacheInvalidation(key) {
|
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
__name(notifyFarmCacheInvalidation, "notifyFarmCacheInvalidation");
|
|
177
|
+
function notifyFarmCacheTask(task) {
|
|
178
|
+
for (const listener of getFarmCacheInvalidationState().taskListeners) {
|
|
179
|
+
listener(task);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
__name(notifyFarmCacheTask, "notifyFarmCacheTask");
|
|
172
183
|
function applyFarmCacheInvalidations(keys) {
|
|
173
184
|
if (!Array.isArray(keys)) return;
|
|
174
185
|
for (const key of keys) {
|
|
@@ -190,12 +201,109 @@ function getActiveFarmI18nSnapshot() {
|
|
|
190
201
|
__name(getActiveFarmI18nSnapshot, "getActiveFarmI18nSnapshot");
|
|
191
202
|
|
|
192
203
|
// src/cache.ts
|
|
204
|
+
function defineCacheKey() {
|
|
205
|
+
return (factory) => {
|
|
206
|
+
if (typeof factory !== "function") {
|
|
207
|
+
throw new TypeError("defineCacheKey expects a key factory function.");
|
|
208
|
+
}
|
|
209
|
+
return ((...args) => {
|
|
210
|
+
const key = factory(...args);
|
|
211
|
+
if (typeof key !== "string" && !Array.isArray(key)) {
|
|
212
|
+
throw new TypeError(
|
|
213
|
+
"A defined cache key factory must return a string or structured array."
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return key;
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
__name(defineCacheKey, "defineCacheKey");
|
|
221
|
+
function storageCacheAdapter(storage, options = {}) {
|
|
222
|
+
if (!storage || typeof storage.getItem !== "function" || typeof storage.setItem !== "function") {
|
|
223
|
+
throw new TypeError("storageCacheAdapter expects a compatible storage client.");
|
|
224
|
+
}
|
|
225
|
+
const base = normalizeCacheNamespace(options.base || "farm-cache");
|
|
226
|
+
const entryKey = /* @__PURE__ */ __name((key) => `${base}:entry:${key}`, "entryKey");
|
|
227
|
+
const tagKey = /* @__PURE__ */ __name((tag) => `${base}:tag:${tag}`, "tagKey");
|
|
228
|
+
return {
|
|
229
|
+
name: "storage",
|
|
230
|
+
get: /* @__PURE__ */ __name((key) => storage.getItem(entryKey(key)), "get"),
|
|
231
|
+
set: /* @__PURE__ */ __name(async (key, entry) => {
|
|
232
|
+
await storage.setItem(entryKey(key), entry);
|
|
233
|
+
}, "set"),
|
|
234
|
+
delete: /* @__PURE__ */ __name(async (key) => {
|
|
235
|
+
await storage.removeItem(entryKey(key));
|
|
236
|
+
}, "delete"),
|
|
237
|
+
clear: storage.clear ? async () => {
|
|
238
|
+
await storage.clear(base);
|
|
239
|
+
} : void 0,
|
|
240
|
+
getTagVersions: /* @__PURE__ */ __name(async (tags) => {
|
|
241
|
+
const versions = await Promise.all(
|
|
242
|
+
tags.map(async (tag) => {
|
|
243
|
+
const value = await storage.getItem(tagKey(tag));
|
|
244
|
+
return [tag, normalizeAdapterVersion(value)];
|
|
245
|
+
})
|
|
246
|
+
);
|
|
247
|
+
return Object.fromEntries(versions);
|
|
248
|
+
}, "getTagVersions"),
|
|
249
|
+
invalidateTags: /* @__PURE__ */ __name(async (tags) => {
|
|
250
|
+
await Promise.all(
|
|
251
|
+
tags.map(async (tag) => {
|
|
252
|
+
const key = tagKey(tag);
|
|
253
|
+
const current = normalizeAdapterVersion(await storage.getItem(key));
|
|
254
|
+
await storage.setItem(key, Math.max(Date.now(), current + 1));
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
}, "invalidateTags")
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
__name(storageCacheAdapter, "storageCacheAdapter");
|
|
193
261
|
var _FarmDataCache = class _FarmDataCache {
|
|
194
|
-
constructor() {
|
|
262
|
+
constructor(config = {}) {
|
|
195
263
|
this.entries = /* @__PURE__ */ new Map();
|
|
196
264
|
this.inflight = /* @__PURE__ */ new Map();
|
|
197
265
|
this.invalidatedTagVersions = /* @__PURE__ */ new Map();
|
|
198
266
|
this.version = 0;
|
|
267
|
+
this.namespace = "farm";
|
|
268
|
+
this.local = true;
|
|
269
|
+
this.lease = {
|
|
270
|
+
enabled: true,
|
|
271
|
+
ttlMs: 1e4,
|
|
272
|
+
waitTimeoutMs: 1e4,
|
|
273
|
+
pollIntervalMs: 25
|
|
274
|
+
};
|
|
275
|
+
this.configure(config);
|
|
276
|
+
}
|
|
277
|
+
configure(config = {}) {
|
|
278
|
+
this.adapter = config.adapter;
|
|
279
|
+
this.namespace = normalizeCacheNamespace(config.namespace || "farm");
|
|
280
|
+
this.local = !config.adapter;
|
|
281
|
+
this.lease = config.lease === false ? { ...this.lease, enabled: false } : {
|
|
282
|
+
enabled: true,
|
|
283
|
+
ttlMs: normalizePositiveDuration(config.lease?.ttlMs, 1e4, "cache.lease.ttlMs"),
|
|
284
|
+
waitTimeoutMs: normalizePositiveDuration(
|
|
285
|
+
config.lease?.waitTimeoutMs,
|
|
286
|
+
1e4,
|
|
287
|
+
"cache.lease.waitTimeoutMs"
|
|
288
|
+
),
|
|
289
|
+
pollIntervalMs: normalizePositiveDuration(
|
|
290
|
+
config.lease?.pollIntervalMs,
|
|
291
|
+
25,
|
|
292
|
+
"cache.lease.pollIntervalMs"
|
|
293
|
+
)
|
|
294
|
+
};
|
|
295
|
+
if (!this.local) {
|
|
296
|
+
this.entries.clear();
|
|
297
|
+
this.inflight.clear();
|
|
298
|
+
this.invalidatedTagVersions.clear();
|
|
299
|
+
this.version = 0;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
get adapterName() {
|
|
303
|
+
return this.adapter?.name || (this.adapter ? "custom" : "memory");
|
|
304
|
+
}
|
|
305
|
+
get hasAdapter() {
|
|
306
|
+
return this.adapter !== void 0;
|
|
199
307
|
}
|
|
200
308
|
get size() {
|
|
201
309
|
return this.entries.size;
|
|
@@ -231,6 +339,45 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
231
339
|
});
|
|
232
340
|
return this.toPublicEntry(entry);
|
|
233
341
|
}
|
|
342
|
+
async getEntryAsync(key, options = {}) {
|
|
343
|
+
if (this.local) {
|
|
344
|
+
const localEntry = this.getEntry(key, options);
|
|
345
|
+
if (localEntry) return localEntry;
|
|
346
|
+
}
|
|
347
|
+
if (!this.adapter) {
|
|
348
|
+
return this.local ? void 0 : this.getEntry(key, options);
|
|
349
|
+
}
|
|
350
|
+
const entry = await this.adapter.get(this.createAdapterKey(key));
|
|
351
|
+
if (!entry) {
|
|
352
|
+
emitFarmEvent({ type: "cache.miss", key });
|
|
353
|
+
return void 0;
|
|
354
|
+
}
|
|
355
|
+
assertFarmCacheEntry(entry, key);
|
|
356
|
+
const stale = await this.isAdapterEntryStale(entry, options.now);
|
|
357
|
+
if (stale) {
|
|
358
|
+
emitFarmEvent({
|
|
359
|
+
type: "cache.stale",
|
|
360
|
+
key,
|
|
361
|
+
tags: [...entry.tags],
|
|
362
|
+
revalidate: entry.revalidate
|
|
363
|
+
});
|
|
364
|
+
if (!options.allowStale) {
|
|
365
|
+
emitFarmEvent({ type: "cache.miss", key, reason: "stale" });
|
|
366
|
+
return void 0;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
emitFarmEvent({
|
|
370
|
+
type: "cache.hit",
|
|
371
|
+
key,
|
|
372
|
+
tags: [...entry.tags],
|
|
373
|
+
revalidate: entry.revalidate,
|
|
374
|
+
stale
|
|
375
|
+
});
|
|
376
|
+
if (this.local && !stale) {
|
|
377
|
+
this.hydrateLocalEntry(entry);
|
|
378
|
+
}
|
|
379
|
+
return { ...entry, key };
|
|
380
|
+
}
|
|
234
381
|
set(key, value, options = {}) {
|
|
235
382
|
const tags = /* @__PURE__ */ new Set();
|
|
236
383
|
for (const tag of options.tags ?? []) {
|
|
@@ -243,6 +390,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
243
390
|
key,
|
|
244
391
|
value,
|
|
245
392
|
tags,
|
|
393
|
+
tagVersions: void 0,
|
|
246
394
|
createdAt: options.createdAt ?? Date.now(),
|
|
247
395
|
createdVersion: ++this.version,
|
|
248
396
|
revalidate: normalizeRevalidate(options.revalidate)
|
|
@@ -256,11 +404,45 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
256
404
|
});
|
|
257
405
|
return this.toPublicEntry(entry);
|
|
258
406
|
}
|
|
407
|
+
async setAsync(key, value, options = {}, tagVersions) {
|
|
408
|
+
const tags = normalizeCacheOptionsTags(options);
|
|
409
|
+
const capturedVersions = tagVersions ?? await this.getAdapterTagVersions(Array.from(tags.values()));
|
|
410
|
+
const entry = {
|
|
411
|
+
key,
|
|
412
|
+
value,
|
|
413
|
+
tags: Array.from(tags),
|
|
414
|
+
tagVersions: capturedVersions,
|
|
415
|
+
createdAt: options.createdAt ?? Date.now(),
|
|
416
|
+
createdVersion: ++this.version,
|
|
417
|
+
revalidate: normalizeRevalidate(options.revalidate)
|
|
418
|
+
};
|
|
419
|
+
if (this.local) {
|
|
420
|
+
this.hydrateLocalEntry(entry);
|
|
421
|
+
}
|
|
422
|
+
if (this.adapter) {
|
|
423
|
+
await this.adapter.set(this.createAdapterKey(key), entry);
|
|
424
|
+
}
|
|
425
|
+
emitFarmEvent({
|
|
426
|
+
type: "cache.set",
|
|
427
|
+
key,
|
|
428
|
+
tags: [...entry.tags],
|
|
429
|
+
revalidate: entry.revalidate
|
|
430
|
+
});
|
|
431
|
+
return entry;
|
|
432
|
+
}
|
|
259
433
|
delete(key) {
|
|
260
434
|
const deleted = this.entries.delete(key);
|
|
261
435
|
emitFarmEvent({ type: "cache.delete", key, deleted });
|
|
262
436
|
return deleted;
|
|
263
437
|
}
|
|
438
|
+
async deleteAsync(key) {
|
|
439
|
+
const deleted = this.entries.delete(key);
|
|
440
|
+
if (this.adapter) {
|
|
441
|
+
await this.adapter.delete(this.createAdapterKey(key));
|
|
442
|
+
}
|
|
443
|
+
emitFarmEvent({ type: "cache.delete", key, deleted: this.adapter ? true : deleted });
|
|
444
|
+
return this.adapter ? true : deleted;
|
|
445
|
+
}
|
|
264
446
|
clear() {
|
|
265
447
|
const count = this.entries.size;
|
|
266
448
|
this.entries.clear();
|
|
@@ -269,6 +451,10 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
269
451
|
this.version = 0;
|
|
270
452
|
emitFarmEvent({ type: "cache.clear", count });
|
|
271
453
|
}
|
|
454
|
+
async clearAsync() {
|
|
455
|
+
this.clear();
|
|
456
|
+
await this.adapter?.clear?.();
|
|
457
|
+
}
|
|
272
458
|
isStale(entry, now = Date.now()) {
|
|
273
459
|
if (typeof entry.revalidate === "number" && entry.revalidate > 0 && now - entry.createdAt >= entry.revalidate * 1e3) {
|
|
274
460
|
return true;
|
|
@@ -281,6 +467,12 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
281
467
|
}
|
|
282
468
|
return false;
|
|
283
469
|
}
|
|
470
|
+
async isStaleAsync(entry, now = Date.now()) {
|
|
471
|
+
if (this.adapter) {
|
|
472
|
+
return this.isAdapterEntryStale(entry, now);
|
|
473
|
+
}
|
|
474
|
+
return this.isStale(entry, now);
|
|
475
|
+
}
|
|
284
476
|
revalidateTag(tag, options = {}) {
|
|
285
477
|
const normalized = normalizeCacheTag(tag);
|
|
286
478
|
const count = this.invalidateTag(normalized);
|
|
@@ -289,6 +481,15 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
289
481
|
);
|
|
290
482
|
return count;
|
|
291
483
|
}
|
|
484
|
+
async revalidateTagAsync(tag, options = {}) {
|
|
485
|
+
const normalized = normalizeCacheTag(tag);
|
|
486
|
+
const count = this.invalidateTag(normalized);
|
|
487
|
+
await this.adapter?.invalidateTags?.([this.createAdapterTag(normalized)]);
|
|
488
|
+
emitFarmEvent(
|
|
489
|
+
options.source === "updateTag" ? { type: "cache.updateTag", tag: normalized, count } : { type: "cache.revalidateTag", tag: normalized, profile: options.profile, count }
|
|
490
|
+
);
|
|
491
|
+
return count;
|
|
492
|
+
}
|
|
292
493
|
revalidatePath(routePath) {
|
|
293
494
|
const normalizedPath = normalizeRevalidatePath(routePath);
|
|
294
495
|
const pathTag = createPathCacheTag(normalizedPath);
|
|
@@ -305,8 +506,25 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
305
506
|
}
|
|
306
507
|
return count;
|
|
307
508
|
}
|
|
509
|
+
async revalidatePathAsync(routePath) {
|
|
510
|
+
const normalizedPath = normalizeRevalidatePath(routePath);
|
|
511
|
+
const pathTag = createPathCacheTag(normalizedPath);
|
|
512
|
+
const pprCount = this.countEntriesForTags([pathTag, "ppr"]);
|
|
513
|
+
const count = this.invalidateTag(pathTag);
|
|
514
|
+
await this.adapter?.invalidateTags?.([this.createAdapterTag(pathTag)]);
|
|
515
|
+
emitFarmEvent({ type: "cache.revalidatePath", path: normalizedPath, count });
|
|
516
|
+
if (pprCount > 0) {
|
|
517
|
+
emitFarmEvent({
|
|
518
|
+
type: "ppr.shell.invalidated",
|
|
519
|
+
route: normalizedPath,
|
|
520
|
+
reason: "revalidatePath",
|
|
521
|
+
count: pprCount
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return count;
|
|
525
|
+
}
|
|
308
526
|
async getOrSet(key, producer, options = {}) {
|
|
309
|
-
const cached = this.
|
|
527
|
+
const cached = await this.getEntryAsync(key);
|
|
310
528
|
if (cached) {
|
|
311
529
|
return cached.value;
|
|
312
530
|
}
|
|
@@ -315,10 +533,8 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
315
533
|
emitFarmEvent({ type: "cache.dedupe", key });
|
|
316
534
|
return inflight;
|
|
317
535
|
}
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
return value;
|
|
321
|
-
}).catch((error) => {
|
|
536
|
+
const tags = Array.from(normalizeCacheOptionsTags(options));
|
|
537
|
+
const promise = this.fillCacheEntry(key, producer, options, tags).catch((error) => {
|
|
322
538
|
emitFarmEvent({ type: "cache.error", key, operation: "set", error });
|
|
323
539
|
throw error;
|
|
324
540
|
}).finally(() => {
|
|
@@ -327,6 +543,40 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
327
543
|
this.inflight.set(key, promise);
|
|
328
544
|
return promise;
|
|
329
545
|
}
|
|
546
|
+
async fillCacheEntry(key, producer, options, tags) {
|
|
547
|
+
const leaseKey = `${this.namespace}:lease:${key}`;
|
|
548
|
+
let leaseToken;
|
|
549
|
+
if (this.adapter?.acquireLease && this.adapter.releaseLease && this.lease.enabled) {
|
|
550
|
+
leaseToken = await this.adapter.acquireLease(leaseKey, this.lease.ttlMs);
|
|
551
|
+
if (!leaseToken) {
|
|
552
|
+
const shared = await this.waitForAdapterEntry(key);
|
|
553
|
+
if (shared) {
|
|
554
|
+
emitFarmEvent({ type: "cache.dedupe", key });
|
|
555
|
+
return shared.value;
|
|
556
|
+
}
|
|
557
|
+
leaseToken = await this.adapter.acquireLease(leaseKey, this.lease.ttlMs);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
try {
|
|
561
|
+
const initialTagVersions = await this.getAdapterTagVersions(tags);
|
|
562
|
+
const value = await producer();
|
|
563
|
+
await this.setAsync(key, value, options, initialTagVersions);
|
|
564
|
+
return value;
|
|
565
|
+
} finally {
|
|
566
|
+
if (leaseToken && this.adapter?.releaseLease) {
|
|
567
|
+
await this.adapter.releaseLease(leaseKey, leaseToken);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
async waitForAdapterEntry(key) {
|
|
572
|
+
const deadline = Date.now() + this.lease.waitTimeoutMs;
|
|
573
|
+
while (Date.now() < deadline) {
|
|
574
|
+
await delay(this.lease.pollIntervalMs);
|
|
575
|
+
const entry = await this.getEntryAsync(key);
|
|
576
|
+
if (entry) return entry;
|
|
577
|
+
}
|
|
578
|
+
return void 0;
|
|
579
|
+
}
|
|
330
580
|
countEntriesForTag(tag) {
|
|
331
581
|
let count = 0;
|
|
332
582
|
for (const entry of this.entries.values()) {
|
|
@@ -354,11 +604,53 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
354
604
|
key: entry.key,
|
|
355
605
|
value: entry.value,
|
|
356
606
|
tags: Array.from(entry.tags),
|
|
607
|
+
tagVersions: entry.tagVersions,
|
|
357
608
|
createdAt: entry.createdAt,
|
|
358
609
|
createdVersion: entry.createdVersion,
|
|
359
610
|
revalidate: entry.revalidate
|
|
360
611
|
};
|
|
361
612
|
}
|
|
613
|
+
hydrateLocalEntry(entry) {
|
|
614
|
+
this.entries.set(entry.key, {
|
|
615
|
+
key: entry.key,
|
|
616
|
+
value: entry.value,
|
|
617
|
+
tags: new Set(entry.tags.map(normalizeCacheTag)),
|
|
618
|
+
tagVersions: entry.tagVersions,
|
|
619
|
+
createdAt: entry.createdAt,
|
|
620
|
+
createdVersion: entry.createdVersion ?? ++this.version,
|
|
621
|
+
revalidate: normalizeRevalidate(entry.revalidate)
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
createAdapterKey(key) {
|
|
625
|
+
return `${this.namespace}:entry:${key}`;
|
|
626
|
+
}
|
|
627
|
+
createAdapterTag(tag) {
|
|
628
|
+
return `${this.namespace}:tag:${tag}`;
|
|
629
|
+
}
|
|
630
|
+
async getAdapterTagVersions(tags) {
|
|
631
|
+
if (!this.adapter?.getTagVersions || tags.length === 0) return {};
|
|
632
|
+
const normalized = tags.map(normalizeCacheTag);
|
|
633
|
+
const physicalTags = normalized.map((tag) => this.createAdapterTag(tag));
|
|
634
|
+
const versions = await this.adapter.getTagVersions(physicalTags);
|
|
635
|
+
return Object.fromEntries(
|
|
636
|
+
normalized.map((tag, index) => [
|
|
637
|
+
tag,
|
|
638
|
+
normalizeAdapterVersion(versions[physicalTags[index]])
|
|
639
|
+
])
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
async isAdapterEntryStale(entry, now = Date.now()) {
|
|
643
|
+
if (typeof entry.revalidate === "number" && entry.revalidate > 0 && now - entry.createdAt >= entry.revalidate * 1e3) {
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
const currentVersions = await this.getAdapterTagVersions(entry.tags);
|
|
647
|
+
for (const tag of entry.tags) {
|
|
648
|
+
if (normalizeAdapterVersion(currentVersions[tag]) > normalizeAdapterVersion(entry.tagVersions?.[tag])) {
|
|
649
|
+
return true;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
362
654
|
};
|
|
363
655
|
__name(_FarmDataCache, "FarmDataCache");
|
|
364
656
|
var FarmDataCache = _FarmDataCache;
|
|
@@ -371,6 +663,10 @@ function getFarmDataCache() {
|
|
|
371
663
|
return sharedFarmDataCache;
|
|
372
664
|
}
|
|
373
665
|
__name(getFarmDataCache, "getFarmDataCache");
|
|
666
|
+
function configureFarmCache(config) {
|
|
667
|
+
sharedFarmDataCache.configure(config);
|
|
668
|
+
}
|
|
669
|
+
__name(configureFarmCache, "configureFarmCache");
|
|
374
670
|
function unstable_cache(fn, keyParts = [], options = {}) {
|
|
375
671
|
return async (...args) => {
|
|
376
672
|
const locale = getActiveFarmI18nSnapshot()?.locale;
|
|
@@ -386,30 +682,71 @@ function unstable_cache(fn, keyParts = [], options = {}) {
|
|
|
386
682
|
}
|
|
387
683
|
__name(unstable_cache, "unstable_cache");
|
|
388
684
|
function revalidateTag(_tag, _profile) {
|
|
389
|
-
getFarmDataCache()
|
|
685
|
+
const cache = getFarmDataCache();
|
|
686
|
+
if (cache.hasAdapter) {
|
|
687
|
+
const task = cache.revalidateTagAsync(_tag, {
|
|
688
|
+
source: "revalidateTag",
|
|
689
|
+
profile: _profile
|
|
690
|
+
}).then(() => void 0);
|
|
691
|
+
notifyFarmCacheTask(task);
|
|
692
|
+
return task;
|
|
693
|
+
}
|
|
694
|
+
cache.revalidateTag(_tag, {
|
|
390
695
|
source: "revalidateTag",
|
|
391
696
|
profile: _profile
|
|
392
697
|
});
|
|
393
698
|
}
|
|
394
699
|
__name(revalidateTag, "revalidateTag");
|
|
395
700
|
function updateTag(tag) {
|
|
396
|
-
|
|
701
|
+
const cache = getFarmDataCache();
|
|
702
|
+
if (cache.hasAdapter) {
|
|
703
|
+
const task = cache.revalidateTagAsync(tag, { source: "updateTag" }).then(() => void 0);
|
|
704
|
+
notifyFarmCacheTask(task);
|
|
705
|
+
return task;
|
|
706
|
+
}
|
|
707
|
+
cache.revalidateTag(tag, { source: "updateTag" });
|
|
397
708
|
}
|
|
398
709
|
__name(updateTag, "updateTag");
|
|
399
710
|
function revalidatePath(routePath) {
|
|
400
|
-
getFarmDataCache()
|
|
711
|
+
const cache = getFarmDataCache();
|
|
712
|
+
if (cache.hasAdapter) {
|
|
713
|
+
const task = cache.revalidatePathAsync(routePath).then(() => void 0);
|
|
714
|
+
notifyFarmCacheTask(task);
|
|
715
|
+
return task;
|
|
716
|
+
}
|
|
717
|
+
cache.revalidatePath(routePath);
|
|
401
718
|
}
|
|
402
719
|
__name(revalidatePath, "revalidatePath");
|
|
403
720
|
function invalidate(key) {
|
|
404
721
|
const clientKey = createRouteDataCacheKey(key);
|
|
405
|
-
|
|
722
|
+
const task = updateTag(createRouteDataCacheTag(key));
|
|
406
723
|
notifyFarmCacheInvalidation(clientKey);
|
|
724
|
+
return task;
|
|
407
725
|
}
|
|
408
726
|
__name(invalidate, "invalidate");
|
|
409
727
|
function invalidateRouteData(key) {
|
|
410
|
-
invalidate(key);
|
|
728
|
+
return invalidate(key);
|
|
411
729
|
}
|
|
412
730
|
__name(invalidateRouteData, "invalidateRouteData");
|
|
731
|
+
async function applyFarmCacheInvalidationTargets(targets) {
|
|
732
|
+
if (!Array.isArray(targets)) {
|
|
733
|
+
throw new TypeError("Cache invalidations must resolve to an array of targets.");
|
|
734
|
+
}
|
|
735
|
+
const clientKeys = [];
|
|
736
|
+
for (const target of targets) {
|
|
737
|
+
assertFarmCacheInvalidationTarget(target);
|
|
738
|
+
if ("key" in target) {
|
|
739
|
+
await invalidate(target.key);
|
|
740
|
+
clientKeys.push(createRouteDataCacheKey(target.key));
|
|
741
|
+
} else if ("path" in target) {
|
|
742
|
+
await revalidatePath(target.path);
|
|
743
|
+
} else {
|
|
744
|
+
await updateTag(target.tag);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return Array.from(new Set(clientKeys));
|
|
748
|
+
}
|
|
749
|
+
__name(applyFarmCacheInvalidationTargets, "applyFarmCacheInvalidationTargets");
|
|
413
750
|
function createPathCacheTag(routePath) {
|
|
414
751
|
return `path:${normalizeRevalidatePath(routePath)}`;
|
|
415
752
|
}
|
|
@@ -470,6 +807,67 @@ function normalizeCacheTag(tag) {
|
|
|
470
807
|
return normalized;
|
|
471
808
|
}
|
|
472
809
|
__name(normalizeCacheTag, "normalizeCacheTag");
|
|
810
|
+
function normalizeCacheNamespace(namespace) {
|
|
811
|
+
if (typeof namespace !== "string") {
|
|
812
|
+
throw new TypeError("Cache namespace must be a string.");
|
|
813
|
+
}
|
|
814
|
+
const normalized = namespace.trim().replace(/:+$/g, "");
|
|
815
|
+
if (!normalized) {
|
|
816
|
+
throw new Error("Cache namespace cannot be empty.");
|
|
817
|
+
}
|
|
818
|
+
return normalized;
|
|
819
|
+
}
|
|
820
|
+
__name(normalizeCacheNamespace, "normalizeCacheNamespace");
|
|
821
|
+
function normalizeAdapterVersion(value) {
|
|
822
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
823
|
+
}
|
|
824
|
+
__name(normalizeAdapterVersion, "normalizeAdapterVersion");
|
|
825
|
+
function normalizePositiveDuration(value, fallback, name) {
|
|
826
|
+
if (value === void 0) return fallback;
|
|
827
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
828
|
+
throw new TypeError(`${name} must be a positive number of milliseconds.`);
|
|
829
|
+
}
|
|
830
|
+
return Math.floor(value);
|
|
831
|
+
}
|
|
832
|
+
__name(normalizePositiveDuration, "normalizePositiveDuration");
|
|
833
|
+
function delay(ms) {
|
|
834
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
835
|
+
}
|
|
836
|
+
__name(delay, "delay");
|
|
837
|
+
function normalizeCacheOptionsTags(options) {
|
|
838
|
+
const tags = /* @__PURE__ */ new Set();
|
|
839
|
+
for (const tag of options.tags ?? []) {
|
|
840
|
+
tags.add(normalizeCacheTag(tag));
|
|
841
|
+
}
|
|
842
|
+
for (const routePath of options.paths ?? []) {
|
|
843
|
+
tags.add(createPathCacheTag(routePath));
|
|
844
|
+
}
|
|
845
|
+
return tags;
|
|
846
|
+
}
|
|
847
|
+
__name(normalizeCacheOptionsTags, "normalizeCacheOptionsTags");
|
|
848
|
+
function assertFarmCacheEntry(entry, expectedKey) {
|
|
849
|
+
if (!entry || typeof entry !== "object" || entry.key !== expectedKey || !Array.isArray(entry.tags) || typeof entry.createdAt !== "number") {
|
|
850
|
+
throw new TypeError(
|
|
851
|
+
`Cache adapter returned an invalid entry for ${JSON.stringify(expectedKey)}.`
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
__name(assertFarmCacheEntry, "assertFarmCacheEntry");
|
|
856
|
+
function assertFarmCacheInvalidationTarget(target) {
|
|
857
|
+
if (!target || typeof target !== "object") {
|
|
858
|
+
throw new TypeError("Cache invalidation targets must be { key }, { path }, or { tag }.");
|
|
859
|
+
}
|
|
860
|
+
if ("key" in target) {
|
|
861
|
+
const key = target.key;
|
|
862
|
+
if (typeof key === "string" || Array.isArray(key)) return;
|
|
863
|
+
} else if ("path" in target && typeof target.path === "string") {
|
|
864
|
+
return;
|
|
865
|
+
} else if ("tag" in target && typeof target.tag === "string") {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
throw new TypeError("Cache invalidation targets must contain a string/array key, path, or tag.");
|
|
869
|
+
}
|
|
870
|
+
__name(assertFarmCacheInvalidationTarget, "assertFarmCacheInvalidationTarget");
|
|
473
871
|
function getFunctionCacheIdentity(fn) {
|
|
474
872
|
if (fn.name) {
|
|
475
873
|
return `name:${fn.name}`;
|
|
@@ -526,17 +924,21 @@ __name(stableSerialize, "stableSerialize");
|
|
|
526
924
|
// Annotate the CommonJS export names for ESM import in node:
|
|
527
925
|
0 && (module.exports = {
|
|
528
926
|
FarmDataCache,
|
|
927
|
+
applyFarmCacheInvalidationTargets,
|
|
529
928
|
applyFarmCacheInvalidations,
|
|
929
|
+
configureFarmCache,
|
|
530
930
|
createFarmCacheKey,
|
|
531
931
|
createPathCacheTag,
|
|
532
932
|
createRouteDataCacheKey,
|
|
533
933
|
createRouteDataCacheTag,
|
|
934
|
+
defineCacheKey,
|
|
534
935
|
getFarmDataCache,
|
|
535
936
|
invalidate,
|
|
536
937
|
invalidateRouteData,
|
|
537
938
|
normalizeRevalidatePath,
|
|
538
939
|
revalidatePath,
|
|
539
940
|
revalidateTag,
|
|
941
|
+
storageCacheAdapter,
|
|
540
942
|
unstable_cache,
|
|
541
943
|
updateTag
|
|
542
944
|
});
|