@farm.js/core 0.1.17 → 0.1.19
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/dist/after.cjs +12 -225
- package/dist/agent-runtime.cjs +83 -2800
- package/dist/api/client.cjs +17 -4060
- package/dist/api/route-manager.cjs +34 -4354
- package/dist/api/runtime.cjs +29 -2696
- package/dist/api.cjs +88 -8434
- package/dist/app-markdown.cjs +39 -280
- package/dist/app-markdown.mjs +3 -3
- package/dist/cache.cjs +38 -1560
- package/dist/chunk-22GUSVNJ.cjs +351 -0
- package/dist/{chunk-EN7WTEAY.mjs → chunk-2ANEVVF7.mjs} +1 -1
- package/dist/chunk-2CQ74SP6.cjs +13 -0
- package/dist/{chunk-YD4J4XCI.mjs → chunk-2GNATDDE.mjs} +1 -1
- package/dist/chunk-2SJ4RQ6P.cjs +57 -0
- package/dist/chunk-3376ZTRC.cjs +1 -0
- package/dist/chunk-4PNUXIVU.cjs +472 -0
- package/dist/chunk-4PPEPOZZ.cjs +21 -0
- package/dist/chunk-4ZFL5GFN.cjs +520 -0
- package/dist/chunk-5OVTOKGH.cjs +65 -0
- package/dist/chunk-5QIKR7RR.cjs +224 -0
- package/dist/chunk-5ZSWG4UX.cjs +127 -0
- package/dist/chunk-62YJ2IEB.cjs +238 -0
- package/dist/chunk-6EODJYCX.cjs +183 -0
- package/dist/chunk-6EXBPJ24.cjs +434 -0
- package/dist/chunk-6QQDAAAZ.cjs +38 -0
- package/dist/chunk-6V4TDWEC.cjs +455 -0
- package/dist/chunk-72ADZ6GQ.cjs +19 -0
- package/dist/chunk-75BRBIFP.cjs +172 -0
- package/dist/{chunk-ZCNJKLA2.mjs → chunk-7BC6GAL7.mjs} +1 -1
- package/dist/chunk-7W3CPVXS.cjs +24 -0
- package/dist/chunk-A6WIQH5Z.cjs +31 -0
- package/dist/chunk-A777V5WU.cjs +725 -0
- package/dist/chunk-AFOD3LYZ.cjs +377 -0
- package/dist/chunk-AH7HOAQ3.cjs +151 -0
- package/dist/chunk-AMDMVWMI.cjs +39 -0
- package/dist/chunk-AORPIPNB.cjs +552 -0
- package/dist/chunk-ARJWXNQL.cjs +256 -0
- package/dist/chunk-AYJR42WX.cjs +711 -0
- package/dist/chunk-BBVSJVBZ.cjs +600 -0
- package/dist/chunk-BIDYX3SL.cjs +91 -0
- package/dist/chunk-BYODCJD6.cjs +663 -0
- package/dist/chunk-C3VRMB6H.cjs +85 -0
- package/dist/chunk-C5GUTBZK.cjs +173 -0
- package/dist/chunk-CIAGU2X4.cjs +337 -0
- package/dist/chunk-CMGMGHUZ.cjs +27 -0
- package/dist/chunk-CXP5U3RW.cjs +54 -0
- package/dist/chunk-D2ULAULS.cjs +166 -0
- package/dist/chunk-D7JTOLFK.cjs +285 -0
- package/dist/chunk-DVM4FKZL.cjs +169 -0
- package/dist/chunk-DYEJQTDN.cjs +49 -0
- package/dist/chunk-E2ROOWQC.cjs +2225 -0
- package/dist/chunk-E3UK5IIB.cjs +593 -0
- package/dist/chunk-EM6SBQKM.cjs +470 -0
- package/dist/chunk-FJSWYIR7.cjs +482 -0
- package/dist/chunk-FK6GO24V.cjs +54 -0
- package/dist/{chunk-MVIWBEJF.mjs → chunk-FVZGEVTO.mjs} +7 -7
- package/dist/chunk-FXUUWYAX.cjs +654 -0
- package/dist/chunk-G3HRIVEY.cjs +395 -0
- package/dist/chunk-G643DQCH.cjs +13 -0
- package/dist/chunk-G7HXGLEC.cjs +175 -0
- package/dist/chunk-GDSHDTJ4.cjs +152 -0
- package/dist/chunk-GPVTX3HT.cjs +1415 -0
- package/dist/chunk-H6G5INWM.cjs +1094 -0
- package/dist/{chunk-DHDVMXYK.mjs → chunk-HALDNTIV.mjs} +30 -4
- package/dist/chunk-HBTUGXHS.cjs +180 -0
- package/dist/chunk-HREOKQWT.cjs +45 -0
- package/dist/{chunk-5QOEPUYE.mjs → chunk-HSDL2AUR.mjs} +1 -1
- package/dist/chunk-I4J452B7.cjs +435 -0
- package/dist/chunk-I57LW5VZ.cjs +94 -0
- package/dist/chunk-I5YBCWQ6.cjs +40 -0
- package/dist/chunk-I7PUUDGY.cjs +389 -0
- package/dist/chunk-IAMRBF3Z.cjs +86 -0
- package/dist/chunk-IQXFRNY2.cjs +169 -0
- package/dist/chunk-ISTFC3MZ.cjs +1357 -0
- package/dist/chunk-IXTFU4PL.cjs +2355 -0
- package/dist/chunk-J3LOGE4T.cjs +42 -0
- package/dist/chunk-J7FSKED3.cjs +93 -0
- package/dist/chunk-JDNHKPTD.cjs +22 -0
- package/dist/chunk-JSROZYYO.cjs +164 -0
- package/dist/chunk-K6FNHVDR.cjs +696 -0
- package/dist/chunk-KGZIORNL.cjs +43 -0
- package/dist/chunk-KR6CKSXT.cjs +15 -0
- package/dist/chunk-KROWKCUH.cjs +185 -0
- package/dist/chunk-KVFPGF2M.cjs +46 -0
- package/dist/{chunk-TNBAYAWO.mjs → chunk-L4DVIHOC.mjs} +1 -1
- package/dist/chunk-LCCBO7PJ.cjs +46 -0
- package/dist/chunk-LIUGYUX3.cjs +22 -0
- package/dist/chunk-LTNGXMQ6.cjs +55 -0
- package/dist/chunk-M2L4MYDQ.cjs +14 -0
- package/dist/chunk-MCJLA63J.cjs +1 -0
- package/dist/chunk-MKB2EGIR.cjs +148 -0
- package/dist/chunk-MQ3H6LT5.cjs +202 -0
- package/dist/chunk-MT763TDW.cjs +43 -0
- package/dist/{chunk-XWAYMDLB.mjs → chunk-MVUREHPN.mjs} +1 -1
- package/dist/chunk-MWSK6C4J.cjs +18 -0
- package/dist/chunk-MWWVKDW3.cjs +169 -0
- package/dist/{chunk-6VQIKZZO.mjs → chunk-N255VYFP.mjs} +1 -1
- package/dist/chunk-NBAHDVOJ.cjs +2040 -0
- package/dist/chunk-NO3WWW3N.cjs +192 -0
- package/dist/chunk-NSFC3LHB.cjs +10244 -0
- package/dist/chunk-NZKJGRB3.cjs +230 -0
- package/dist/chunk-OAVTUMJP.cjs +1496 -0
- package/dist/{chunk-SXHV42UQ.mjs → chunk-OFEY6KHO.mjs} +88 -13
- package/dist/chunk-OHY2ZWUG.cjs +25 -0
- package/dist/chunk-OI6CMLWX.cjs +47 -0
- package/dist/chunk-OWOUTKIJ.cjs +558 -0
- package/dist/chunk-OX6O6WVA.cjs +74 -0
- package/dist/chunk-OXSIH4D6.cjs +476 -0
- package/dist/chunk-OYDRPBBV.cjs +453 -0
- package/dist/chunk-OYEUREB6.cjs +35 -0
- package/dist/chunk-PCOTGFSM.cjs +139 -0
- package/dist/{chunk-76DG3LF3.mjs → chunk-PGQBL5DN.mjs} +1 -1
- package/dist/chunk-PZYCPSCC.cjs +35 -0
- package/dist/chunk-QBK2AA4U.cjs +445 -0
- package/dist/{chunk-UTBVHYS3.mjs → chunk-QBPKKQTD.mjs} +2 -2
- package/dist/chunk-QBPXNZGV.cjs +487 -0
- package/dist/chunk-QNPEUFHQ.cjs +27 -0
- package/dist/chunk-QZRVZSPN.cjs +236 -0
- package/dist/chunk-R5A5KNVX.cjs +20 -0
- package/dist/chunk-R5JIFR6B.cjs +42 -0
- package/dist/chunk-R6AIILII.cjs +193 -0
- package/dist/chunk-RFYO7QUD.cjs +9 -0
- package/dist/chunk-RG3ZOTG5.cjs +34 -0
- package/dist/chunk-ROUTX2E5.cjs +390 -0
- package/dist/chunk-RTHIVJ2G.cjs +54 -0
- package/dist/chunk-S27FMYAM.cjs +644 -0
- package/dist/chunk-S3A45T7F.cjs +166 -0
- package/dist/chunk-S3JO3N4H.cjs +17 -0
- package/dist/chunk-SK35NQKK.cjs +27 -0
- package/dist/chunk-SU7MH53P.cjs +180 -0
- package/dist/chunk-SVRTJOUF.cjs +113 -0
- package/dist/chunk-SWN467MP.cjs +18 -0
- package/dist/chunk-SYQ3MOWW.cjs +73 -0
- package/dist/chunk-T5CERMEH.cjs +417 -0
- package/dist/chunk-TFAXUHWX.cjs +206 -0
- package/dist/chunk-TIWHTW3Q.cjs +24 -0
- package/dist/chunk-TKJZFIML.cjs +20 -0
- package/dist/chunk-TKNSDBBN.cjs +193 -0
- package/dist/chunk-U4KT7QP3.cjs +23 -0
- package/dist/chunk-U5BMPGS3.cjs +862 -0
- package/dist/chunk-UJ2C4ICS.cjs +277 -0
- package/dist/chunk-UQZ4AYTH.cjs +168 -0
- package/dist/chunk-US2QVW3E.cjs +36 -0
- package/dist/{chunk-QGVJVSNX.mjs → chunk-V4AICMQA.mjs} +2 -2
- package/dist/chunk-VB6UCX3V.cjs +421 -0
- package/dist/chunk-VEKFLAQM.cjs +300 -0
- package/dist/chunk-VQDBNVOO.cjs +14 -0
- package/dist/chunk-W4E7WMXE.cjs +71 -0
- package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
- package/dist/chunk-WMAPPDMM.cjs +28 -0
- package/dist/chunk-WMOGFOUJ.cjs +223 -0
- package/dist/chunk-WPYFSQKK.cjs +37 -0
- package/dist/{chunk-56DAX2BE.mjs → chunk-WZXN4R5Y.mjs} +24 -13
- package/dist/chunk-XDGMADQM.cjs +14225 -0
- package/dist/chunk-XGC343EY.cjs +443 -0
- package/dist/chunk-XSKZORAS.cjs +727 -0
- package/dist/chunk-XWAWFQFS.cjs +82 -0
- package/dist/chunk-Y4YMF2NQ.cjs +460 -0
- package/dist/chunk-Y4YWHNKU.cjs +250 -0
- package/dist/chunk-Y53ZSFN6.cjs +504 -0
- package/dist/chunk-YA6LLTIJ.cjs +411 -0
- package/dist/chunk-YFPGHF5F.cjs +202 -0
- package/dist/chunk-YJRZR7VU.cjs +28 -0
- package/dist/chunk-YTAABQEV.cjs +1 -0
- package/dist/chunk-YX3DBN4M.cjs +18 -0
- package/dist/chunk-YZTASLPQ.cjs +64 -0
- package/dist/chunk-Z5HIWVDP.cjs +2173 -0
- package/dist/chunk-ZEG3OPIB.cjs +93 -0
- package/dist/chunk-ZMN3H73H.cjs +155 -0
- package/dist/client/lifecycle.cjs +6 -35
- package/dist/client-plugins.cjs +7 -448
- package/dist/client.cjs +171 -9808
- package/dist/config.cjs +8 -36
- package/dist/cron.cjs +24 -491
- package/dist/deferred.cjs +26 -475
- package/dist/deployment.cjs +39 -210
- package/dist/devtools-5KGPDVKL.cjs +388 -0
- package/dist/{devtools-UFVTMQX5.mjs → devtools-FY5R7TQ4.mjs} +3 -3
- package/dist/devtools-client-4WAPJY5L.cjs +254 -0
- package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
- package/dist/docs.cjs +46 -5657
- package/dist/docs.mjs +5 -5
- package/dist/env-types.cjs +5 -226
- package/dist/env.cjs +21 -338
- package/dist/environment/vite.cjs +8 -372
- package/dist/environment.cjs +12 -94
- package/dist/font.cjs +13 -63
- package/dist/headers.cjs +7 -123
- package/dist/i18n/client.cjs +55 -294
- package/dist/i18n/index.cjs +22 -209
- package/dist/i18n/server.cjs +22 -745
- package/dist/image/server.cjs +13 -729
- package/dist/image/sharp.cjs +33 -171
- package/dist/image.cjs +41 -85
- package/dist/index.cjs +1151 -68080
- package/dist/index.mjs +14 -14
- package/dist/instrumentation.cjs +12 -138
- package/dist/integration-orm-55F7CII5.cjs +13 -0
- package/dist/integrations.cjs +55 -4090
- package/dist/internal/app-markdown-runtime.cjs +27 -224
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +120 -52259
- package/dist/internal/build-runtime.mjs +13 -13
- package/dist/internal/cli-runtime.cjs +67 -13811
- package/dist/internal/cli-runtime.mjs +7 -7
- package/dist/internal/client-error-overlay.cjs +80 -733
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +81 -913
- package/dist/internal/compression-runtime.cjs +8 -214
- package/dist/internal/config-runtime.cjs +42 -6547
- package/dist/internal/config-runtime.mjs +3 -3
- package/dist/internal/docs-precompiled-runtime.cjs +26 -46
- package/dist/internal/infra-analytics-runtime.cjs +10 -536
- package/dist/internal/isolated-boundary.cjs +14 -414
- package/dist/internal/metadata-image-runtime.cjs +7 -285
- package/dist/internal/product-telemetry-runtime.cjs +42 -97
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +6 -63
- package/dist/internal/production-runtime.cjs +418 -7133
- package/dist/internal/production-runtime.mjs +3 -3
- package/dist/internal/request-cookies.cjs +6 -54
- package/dist/json-ld.cjs +24 -50
- package/dist/layers-E4WPJNY5.cjs +17 -0
- package/dist/manager-G4B2IPYE.cjs +14 -0
- package/dist/markdown.cjs +21 -547
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.cjs +36 -2995
- package/dist/navigation.cjs +22 -2588
- package/dist/nitro-4I2MYLY2.cjs +652 -0
- package/dist/observability.cjs +22 -614
- package/dist/og.cjs +5 -28
- package/dist/plugin.cjs +106 -37442
- package/dist/plugin.mjs +9 -9
- package/dist/query/client.cjs +113 -449
- package/dist/query/index.cjs +26 -288
- package/dist/query/parsers.cjs +23 -247
- package/dist/query/server.cjs +36 -298
- package/dist/renderer/react/client.cjs +9 -43
- package/dist/renderer/react/server.cjs +40 -103
- package/dist/renderer/react/vite.cjs +7 -29
- package/dist/renderer-client.cjs +126 -4295
- package/dist/renderer.cjs +31 -249
- package/dist/request.cjs +5 -68
- package/dist/router.cjs +11 -474
- package/dist/routes.cjs +42 -2461
- package/dist/{schema-dev-notice-2IE2F2XI.mjs → schema-dev-notice-O67CPXJ6.mjs} +1 -1
- package/dist/schema-dev-notice-Y7MQEFGN.cjs +56 -0
- package/dist/schema.cjs +6 -33
- package/dist/search-client-G3RICOFU.cjs +13 -0
- package/dist/server-action-security.cjs +25 -541
- package/dist/server-fn-client.cjs +6 -337
- package/dist/server-fn.cjs +32 -1841
- package/dist/server-plugins.cjs +15 -884
- package/dist/server-query-client.cjs +15 -1883
- package/dist/server-query.cjs +16 -1838
- package/dist/server.cjs +296 -44681
- package/dist/server.mjs +11 -11
- package/dist/storage.cjs +57 -576
- package/dist/testing.cjs +89 -3186
- package/dist/theme/client.cjs +13 -108
- package/dist/theme/index.cjs +6 -68
- package/dist/theme/runtime.cjs +13 -78
- package/dist/theme/server.cjs +10 -179
- package/dist/version.cjs +4 -32
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +119 -37773
- package/dist/vite.mjs +9 -9
- package/dist/workflows.cjs +19 -1040
- package/package.json +1 -1
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkH6G5INWMcjs = require('./chunk-H6G5INWM.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkZEG3OPIBcjs = require('./chunk-ZEG3OPIB.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
10
|
+
|
|
11
|
+
// src/client-cache.ts
|
|
12
|
+
var invalidationTrackers = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function trackFarmClientCacheInvalidations(cache) {
|
|
14
|
+
let trackers = invalidationTrackers.get(cache);
|
|
15
|
+
if (!trackers) {
|
|
16
|
+
trackers = /* @__PURE__ */ new Set();
|
|
17
|
+
invalidationTrackers.set(cache, trackers);
|
|
18
|
+
}
|
|
19
|
+
const keys = /* @__PURE__ */ new Set();
|
|
20
|
+
trackers.add(keys);
|
|
21
|
+
return {
|
|
22
|
+
has(key) {
|
|
23
|
+
const resolved = cache.resolveKey(key);
|
|
24
|
+
for (const invalidated of keys) {
|
|
25
|
+
if (cache.resolveKey(invalidated) === resolved) return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
},
|
|
29
|
+
dispose() {
|
|
30
|
+
if (!trackers.delete(keys)) return;
|
|
31
|
+
keys.clear();
|
|
32
|
+
if (trackers.size === 0) invalidationTrackers.delete(cache);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, trackFarmClientCacheInvalidations, "trackFarmClientCacheInvalidations");
|
|
37
|
+
var cacheFinalizer = typeof FinalizationRegistry === "function" ? new FinalizationRegistry((unsubscribe) => unsubscribe()) : void 0;
|
|
38
|
+
var DEFAULT_GC_SWEEP_INTERVAL_MS = 3e4;
|
|
39
|
+
var _FarmClientDataCache = class _FarmClientDataCache {
|
|
40
|
+
constructor(options = {}) {
|
|
41
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
42
|
+
this.aliases = /* @__PURE__ */ new Map();
|
|
43
|
+
this.aliasesByTarget = /* @__PURE__ */ new Map();
|
|
44
|
+
this.invalidatedAt = /* @__PURE__ */ new Map();
|
|
45
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
46
|
+
this.inflight = /* @__PURE__ */ new Map();
|
|
47
|
+
this.pendingMetadataSweeps = /* @__PURE__ */ new Set();
|
|
48
|
+
this.gcSweepIntervalMs = _nullishCoalesce(options.gcSweepIntervalMs, () => ( DEFAULT_GC_SWEEP_INTERVAL_MS));
|
|
49
|
+
if (options.subscribeToInvalidation !== false) {
|
|
50
|
+
if (typeof WeakRef === "function") {
|
|
51
|
+
const reference = new WeakRef(this);
|
|
52
|
+
const unsubscribe = _FarmClientDataCache.subscribeWeakCache(reference);
|
|
53
|
+
_optionalChain([cacheFinalizer, 'optionalAccess', _ => _.register, 'call', _2 => _2(this, unsubscribe, reference)]);
|
|
54
|
+
this.unsubscribeInvalidation = unsubscribe;
|
|
55
|
+
} else {
|
|
56
|
+
this.unsubscribeInvalidation = _chunkZEG3OPIBcjs.subscribeFarmCacheInvalidation.call(void 0,
|
|
57
|
+
(key) => this.applyInvalidation(key, Date.now(), false)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// This closure must only capture a weak reference, never the cache itself.
|
|
63
|
+
static subscribeWeakCache(reference) {
|
|
64
|
+
const unsubscribe = _chunkZEG3OPIBcjs.subscribeFarmCacheInvalidation.call(void 0, (key) => {
|
|
65
|
+
const cache = reference.deref();
|
|
66
|
+
if (cache) cache.applyInvalidation(key, Date.now(), false);
|
|
67
|
+
else dispose();
|
|
68
|
+
});
|
|
69
|
+
function dispose() {
|
|
70
|
+
unsubscribe();
|
|
71
|
+
_optionalChain([cacheFinalizer, 'optionalAccess', _3 => _3.unregister, 'call', _4 => _4(reference)]);
|
|
72
|
+
}
|
|
73
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, dispose, "dispose");
|
|
74
|
+
return dispose;
|
|
75
|
+
}
|
|
76
|
+
get size() {
|
|
77
|
+
return this.entries.size;
|
|
78
|
+
}
|
|
79
|
+
/** @internal Attach or detach the persistence engine's observation sink. */
|
|
80
|
+
attachPersistence(sink) {
|
|
81
|
+
this.persistence = sink;
|
|
82
|
+
}
|
|
83
|
+
resolveKey(key) {
|
|
84
|
+
let resolved = key;
|
|
85
|
+
const seen = /* @__PURE__ */ new Set();
|
|
86
|
+
while (this.aliases.has(resolved) && !seen.has(resolved)) {
|
|
87
|
+
seen.add(resolved);
|
|
88
|
+
resolved = this.aliases.get(resolved);
|
|
89
|
+
}
|
|
90
|
+
return resolved;
|
|
91
|
+
}
|
|
92
|
+
get(key, now = Date.now()) {
|
|
93
|
+
const resolved = this.resolveKey(key);
|
|
94
|
+
const entry = this.entries.get(resolved);
|
|
95
|
+
if (!entry) return void 0;
|
|
96
|
+
if (entry.gcAt !== void 0 && now >= entry.gcAt) {
|
|
97
|
+
if (entry.fetching) return void 0;
|
|
98
|
+
this.entries.delete(resolved);
|
|
99
|
+
_optionalChain([this, 'access', _5 => _5.persistence, 'optionalAccess', _6 => _6.onDelete, 'call', _7 => _7(resolved)]);
|
|
100
|
+
this.sweepEntryMetadata(/* @__PURE__ */ new Set([resolved]));
|
|
101
|
+
this.emit(resolved);
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
return entry;
|
|
105
|
+
}
|
|
106
|
+
set(key, entry) {
|
|
107
|
+
const resolved = this.resolveKey(key);
|
|
108
|
+
const invalidatedAt = this.invalidatedAt.get(resolved);
|
|
109
|
+
const nextEntry = invalidatedAt !== void 0 && invalidatedAt > entry.updatedAt ? { ...entry, staleAt: 0, invalidatedAt } : { ...entry, invalidatedAt: void 0 };
|
|
110
|
+
if (invalidatedAt === void 0 || entry.updatedAt >= invalidatedAt) {
|
|
111
|
+
this.invalidatedAt.delete(resolved);
|
|
112
|
+
}
|
|
113
|
+
this.entries.set(resolved, nextEntry);
|
|
114
|
+
this.pendingMetadataSweeps.delete(resolved);
|
|
115
|
+
if (nextEntry.gcAt !== void 0) this.scheduleGcSweep();
|
|
116
|
+
_optionalChain([this, 'access', _8 => _8.persistence, 'optionalAccess', _9 => _9.onSet, 'call', _10 => _10(resolved, nextEntry)]);
|
|
117
|
+
this.emit(resolved);
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
delete(key) {
|
|
121
|
+
const resolved = this.resolveKey(key);
|
|
122
|
+
const deleted = this.entries.delete(resolved);
|
|
123
|
+
this.inflight.delete(resolved);
|
|
124
|
+
if (deleted) _optionalChain([this, 'access', _11 => _11.persistence, 'optionalAccess', _12 => _12.onDelete, 'call', _13 => _13(resolved)]);
|
|
125
|
+
if (deleted || this.pendingMetadataSweeps.has(resolved)) {
|
|
126
|
+
this.sweepEntryMetadata(/* @__PURE__ */ new Set([resolved]));
|
|
127
|
+
}
|
|
128
|
+
this.emit(resolved);
|
|
129
|
+
return deleted;
|
|
130
|
+
}
|
|
131
|
+
clear() {
|
|
132
|
+
const keys = /* @__PURE__ */ new Set([...this.entries.keys(), ...this.listeners.keys()]);
|
|
133
|
+
this.entries.clear();
|
|
134
|
+
this.aliases.clear();
|
|
135
|
+
this.aliasesByTarget.clear();
|
|
136
|
+
this.invalidatedAt.clear();
|
|
137
|
+
this.inflight.clear();
|
|
138
|
+
this.pendingMetadataSweeps.clear();
|
|
139
|
+
_optionalChain([this, 'access', _14 => _14.persistence, 'optionalAccess', _15 => _15.onClear, 'call', _16 => _16()]);
|
|
140
|
+
for (const key of keys) this.emit(key);
|
|
141
|
+
}
|
|
142
|
+
dispose() {
|
|
143
|
+
_optionalChain([this, 'access', _17 => _17.unsubscribeInvalidation, 'optionalCall', _18 => _18()]);
|
|
144
|
+
this.unsubscribeInvalidation = void 0;
|
|
145
|
+
if (this.gcTimer !== void 0) {
|
|
146
|
+
clearTimeout(this.gcTimer);
|
|
147
|
+
this.gcTimer = void 0;
|
|
148
|
+
}
|
|
149
|
+
this.clear();
|
|
150
|
+
}
|
|
151
|
+
isStale(key, now = Date.now()) {
|
|
152
|
+
const entry = this.get(key, now);
|
|
153
|
+
return !entry || entry.invalidatedAt !== void 0 || now >= entry.staleAt;
|
|
154
|
+
}
|
|
155
|
+
invalidate(key, now = Date.now()) {
|
|
156
|
+
this.applyInvalidation(key, now, true);
|
|
157
|
+
}
|
|
158
|
+
applyInvalidation(key, now, retainUnowned) {
|
|
159
|
+
const resolved = this.resolveKey(key);
|
|
160
|
+
for (const keys of _nullishCoalesce(invalidationTrackers.get(this), () => ( []))) keys.add(resolved);
|
|
161
|
+
const entry = this.entries.get(resolved);
|
|
162
|
+
const alreadyRetained = this.invalidatedAt.has(resolved);
|
|
163
|
+
if (retainUnowned || entry || alreadyRetained || this.hasMetadataOwner(resolved)) {
|
|
164
|
+
this.invalidatedAt.set(resolved, now);
|
|
165
|
+
if (!entry && !retainUnowned && !alreadyRetained) this.pendingMetadataSweeps.add(resolved);
|
|
166
|
+
}
|
|
167
|
+
if (entry) {
|
|
168
|
+
this.entries.set(resolved, {
|
|
169
|
+
...entry,
|
|
170
|
+
staleAt: 0,
|
|
171
|
+
invalidatedAt: now
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
this.emit(resolved, "invalidate");
|
|
175
|
+
}
|
|
176
|
+
hasMetadataOwner(key) {
|
|
177
|
+
const related = /* @__PURE__ */ new Set([key]);
|
|
178
|
+
for (const target of related) {
|
|
179
|
+
if (this.listeners.has(target) || this.inflight.has(target)) return true;
|
|
180
|
+
for (const alias of _nullishCoalesce(this.aliasesByTarget.get(target), () => ( []))) related.add(alias);
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
alias(alias, key) {
|
|
185
|
+
const resolved = this.resolveKey(key);
|
|
186
|
+
if (alias === resolved) return;
|
|
187
|
+
const aliasEntry = this.entries.get(alias);
|
|
188
|
+
const aliasInvalidatedAt = _nullishCoalesce(this.invalidatedAt.get(alias), () => ( _optionalChain([aliasEntry, 'optionalAccess', _19 => _19.invalidatedAt])));
|
|
189
|
+
const resolvedInvalidatedAt = this.invalidatedAt.get(resolved);
|
|
190
|
+
if (aliasEntry && !this.entries.has(resolved)) {
|
|
191
|
+
this.entries.set(resolved, aliasEntry);
|
|
192
|
+
_optionalChain([this, 'access', _20 => _20.persistence, 'optionalAccess', _21 => _21.onSet, 'call', _22 => _22(resolved, aliasEntry)]);
|
|
193
|
+
}
|
|
194
|
+
if (this.entries.delete(alias)) _optionalChain([this, 'access', _23 => _23.persistence, 'optionalAccess', _24 => _24.onDelete, 'call', _25 => _25(alias)]);
|
|
195
|
+
this.invalidatedAt.delete(alias);
|
|
196
|
+
const invalidatedAt = [aliasInvalidatedAt, resolvedInvalidatedAt].reduce(
|
|
197
|
+
(latest, value) => value === void 0 ? latest : latest === void 0 ? value : Math.max(latest, value),
|
|
198
|
+
void 0
|
|
199
|
+
);
|
|
200
|
+
const resolvedEntry = this.entries.get(resolved);
|
|
201
|
+
if (invalidatedAt !== void 0 && (!resolvedEntry || invalidatedAt > resolvedEntry.updatedAt)) {
|
|
202
|
+
this.invalidatedAt.set(resolved, invalidatedAt);
|
|
203
|
+
if (resolvedEntry) {
|
|
204
|
+
this.entries.set(resolved, {
|
|
205
|
+
...resolvedEntry,
|
|
206
|
+
staleAt: 0,
|
|
207
|
+
invalidatedAt
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
} else if (invalidatedAt !== void 0) {
|
|
211
|
+
this.invalidatedAt.delete(resolved);
|
|
212
|
+
if (_optionalChain([resolvedEntry, 'optionalAccess', _26 => _26.invalidatedAt]) !== void 0) {
|
|
213
|
+
this.entries.set(resolved, { ...resolvedEntry, invalidatedAt: void 0 });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const aliasInflight = this.inflight.get(alias);
|
|
217
|
+
if (aliasInflight && !this.inflight.has(resolved)) {
|
|
218
|
+
this.inflight.set(resolved, aliasInflight);
|
|
219
|
+
}
|
|
220
|
+
this.inflight.delete(alias);
|
|
221
|
+
if (this.pendingMetadataSweeps.delete(alias) && !this.entries.has(resolved)) {
|
|
222
|
+
this.pendingMetadataSweeps.add(resolved);
|
|
223
|
+
}
|
|
224
|
+
const previousTarget = this.aliases.get(alias);
|
|
225
|
+
if (previousTarget !== resolved) {
|
|
226
|
+
const previousResolved = previousTarget !== void 0 && this.pendingMetadataSweeps.size > 0 ? this.resolveKey(alias) : void 0;
|
|
227
|
+
this.removeAlias(alias);
|
|
228
|
+
this.aliases.set(alias, resolved);
|
|
229
|
+
let aliases = this.aliasesByTarget.get(resolved);
|
|
230
|
+
if (!aliases) this.aliasesByTarget.set(resolved, aliases = /* @__PURE__ */ new Set());
|
|
231
|
+
aliases.add(alias);
|
|
232
|
+
if (previousResolved !== void 0) this.sweepPendingEntryMetadata(previousResolved);
|
|
233
|
+
}
|
|
234
|
+
this.emit(alias);
|
|
235
|
+
this.emit(resolved, this.invalidatedAt.has(resolved) ? "invalidate" : void 0);
|
|
236
|
+
}
|
|
237
|
+
subscribe(key, listener) {
|
|
238
|
+
let listeners = this.listeners.get(key);
|
|
239
|
+
if (!listeners) {
|
|
240
|
+
listeners = /* @__PURE__ */ new Set();
|
|
241
|
+
this.listeners.set(key, listeners);
|
|
242
|
+
}
|
|
243
|
+
listeners.add(listener);
|
|
244
|
+
return () => {
|
|
245
|
+
listeners.delete(listener);
|
|
246
|
+
if (listeners.size === 0 && this.listeners.get(key) === listeners) {
|
|
247
|
+
this.listeners.delete(key);
|
|
248
|
+
this.sweepPendingEntryMetadata(key);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
getInflight(key) {
|
|
253
|
+
return this.inflight.get(this.resolveKey(key));
|
|
254
|
+
}
|
|
255
|
+
setInflight(key, promise) {
|
|
256
|
+
this.inflight.set(this.resolveKey(key), promise);
|
|
257
|
+
}
|
|
258
|
+
deleteInflight(key) {
|
|
259
|
+
const resolved = this.resolveKey(key);
|
|
260
|
+
if (this.inflight.delete(resolved)) this.sweepPendingEntryMetadata(resolved);
|
|
261
|
+
}
|
|
262
|
+
scheduleGcSweep() {
|
|
263
|
+
if (this.gcSweepIntervalMs === false || this.gcTimer !== void 0) return;
|
|
264
|
+
const timer = setTimeout(() => {
|
|
265
|
+
this.gcTimer = void 0;
|
|
266
|
+
this.sweepExpiredEntries();
|
|
267
|
+
}, this.gcSweepIntervalMs);
|
|
268
|
+
_optionalChain([timer, 'access', _27 => _27.unref, 'optionalCall', _28 => _28()]);
|
|
269
|
+
this.gcTimer = timer;
|
|
270
|
+
}
|
|
271
|
+
sweepExpiredEntries(now = Date.now()) {
|
|
272
|
+
const watched = /* @__PURE__ */ new Set();
|
|
273
|
+
for (const key of this.listeners.keys()) watched.add(this.resolveKey(key));
|
|
274
|
+
let remaining = false;
|
|
275
|
+
const swept = /* @__PURE__ */ new Set();
|
|
276
|
+
for (const [key, entry] of this.entries) {
|
|
277
|
+
if (entry.gcAt === void 0) continue;
|
|
278
|
+
if (now < entry.gcAt || entry.fetching || this.inflight.has(key) || watched.has(key)) {
|
|
279
|
+
remaining = true;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
this.entries.delete(key);
|
|
283
|
+
_optionalChain([this, 'access', _29 => _29.persistence, 'optionalAccess', _30 => _30.onDelete, 'call', _31 => _31(key)]);
|
|
284
|
+
swept.add(key);
|
|
285
|
+
}
|
|
286
|
+
if (swept.size > 0) this.sweepEntryMetadata(swept);
|
|
287
|
+
if (remaining) this.scheduleGcSweep();
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Entry eviction alone leaves the per-key metadata behind. `invalidatedAt`
|
|
291
|
+
* marks and provisional aliases are created per query invocation, so with
|
|
292
|
+
* dynamic keys they accumulate for the lifetime of the page even though the
|
|
293
|
+
* entries they describe are long gone.
|
|
294
|
+
*/
|
|
295
|
+
sweepEntryMetadata(swept) {
|
|
296
|
+
const protectedKeys = /* @__PURE__ */ new Set();
|
|
297
|
+
for (const key of swept) if (this.hasMetadataOwner(key)) protectedKeys.add(key);
|
|
298
|
+
for (const key of swept) {
|
|
299
|
+
if (this.entries.has(key)) {
|
|
300
|
+
this.pendingMetadataSweeps.delete(key);
|
|
301
|
+
} else if (protectedKeys.has(key)) {
|
|
302
|
+
this.pendingMetadataSweeps.add(key);
|
|
303
|
+
} else {
|
|
304
|
+
this.pendingMetadataSweeps.delete(key);
|
|
305
|
+
this.invalidatedAt.delete(key);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const related = /* @__PURE__ */ new Set();
|
|
309
|
+
const targets = new Set(swept);
|
|
310
|
+
for (const target of targets) {
|
|
311
|
+
for (const alias of _nullishCoalesce(this.aliasesByTarget.get(target), () => ( []))) {
|
|
312
|
+
related.add(alias);
|
|
313
|
+
targets.add(alias);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const removable = [];
|
|
317
|
+
for (const alias of related) {
|
|
318
|
+
if (this.entries.has(alias) || this.listeners.has(alias) || this.inflight.has(alias))
|
|
319
|
+
continue;
|
|
320
|
+
const resolved = this.resolveKey(alias);
|
|
321
|
+
if (!swept.has(resolved)) continue;
|
|
322
|
+
if (this.entries.has(resolved) || protectedKeys.has(resolved)) continue;
|
|
323
|
+
removable.push(alias);
|
|
324
|
+
}
|
|
325
|
+
for (const alias of removable) {
|
|
326
|
+
this.removeAlias(alias);
|
|
327
|
+
this.invalidatedAt.delete(alias);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
removeAlias(alias) {
|
|
331
|
+
const target = this.aliases.get(alias);
|
|
332
|
+
if (target === void 0) return;
|
|
333
|
+
this.aliases.delete(alias);
|
|
334
|
+
const aliases = this.aliasesByTarget.get(target);
|
|
335
|
+
_optionalChain([aliases, 'optionalAccess', _32 => _32.delete, 'call', _33 => _33(alias)]);
|
|
336
|
+
if (_optionalChain([aliases, 'optionalAccess', _34 => _34.size]) === 0) this.aliasesByTarget.delete(target);
|
|
337
|
+
}
|
|
338
|
+
sweepPendingEntryMetadata(key) {
|
|
339
|
+
if (this.pendingMetadataSweeps.size === 0) return;
|
|
340
|
+
if (key !== void 0) {
|
|
341
|
+
const resolved = this.resolveKey(key);
|
|
342
|
+
if (this.pendingMetadataSweeps.has(resolved)) {
|
|
343
|
+
this.sweepEntryMetadata(/* @__PURE__ */ new Set([resolved]));
|
|
344
|
+
}
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
this.sweepEntryMetadata(new Set(this.pendingMetadataSweeps));
|
|
348
|
+
}
|
|
349
|
+
emit(key, event) {
|
|
350
|
+
this.notifyListeners(key, event);
|
|
351
|
+
if (this.listeners.size === 0) return;
|
|
352
|
+
for (const [alias, target] of this.aliases) {
|
|
353
|
+
if (!this.listeners.has(alias)) continue;
|
|
354
|
+
if (this.resolveKey(target) === key) {
|
|
355
|
+
this.notifyListeners(alias, event);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
notifyListeners(key, event) {
|
|
360
|
+
for (const listener of _nullishCoalesce(this.listeners.get(key), () => ( []))) {
|
|
361
|
+
try {
|
|
362
|
+
listener(event);
|
|
363
|
+
} catch (error) {
|
|
364
|
+
const detail = error instanceof Error ? _nullishCoalesce(error.stack, () => ( error.message)) : String(error);
|
|
365
|
+
console.warn(`[farm:client-cache] cache listener failed: ${detail}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _FarmClientDataCache, "FarmClientDataCache");
|
|
371
|
+
var FarmClientDataCache = _FarmClientDataCache;
|
|
372
|
+
var FARM_CLIENT_DATA_CACHE = /* @__PURE__ */ Symbol.for("farm.clientDataCache");
|
|
373
|
+
var clientCacheGlobal = globalThis;
|
|
374
|
+
var sharedFarmClientDataCache = _nullishCoalesce(clientCacheGlobal[FARM_CLIENT_DATA_CACHE], () => ( (clientCacheGlobal[FARM_CLIENT_DATA_CACHE] = new FarmClientDataCache())));
|
|
375
|
+
function getFarmClientDataCache() {
|
|
376
|
+
return sharedFarmClientDataCache;
|
|
377
|
+
}
|
|
378
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmClientDataCache, "getFarmClientDataCache");
|
|
379
|
+
function normalizeFarmClientCacheKey(key) {
|
|
380
|
+
return typeof key === "string" ? key : _chunkH6G5INWMcjs.createRouteDataCacheKey.call(void 0, key);
|
|
381
|
+
}
|
|
382
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, normalizeFarmClientCacheKey, "normalizeFarmClientCacheKey");
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
exports.trackFarmClientCacheInvalidations = trackFarmClientCacheInvalidations; exports.FarmClientDataCache = FarmClientDataCache; exports.getFarmClientDataCache = getFarmClientDataCache; exports.normalizeFarmClientCacheKey = normalizeFarmClientCacheKey;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
8
|
+
|
|
9
|
+
// src/routes.server.ts
|
|
10
|
+
var _fs = require('fs');
|
|
11
|
+
var _path = require('path');
|
|
12
|
+
async function loadProgrammaticRouteManifests(options) {
|
|
13
|
+
const manifests = [];
|
|
14
|
+
const routeFiles = findProgrammaticRouteFiles(options.root, options.srcDir);
|
|
15
|
+
if (routeFiles.length === 0) return manifests;
|
|
16
|
+
const { getProgrammaticRouteManifest } = await import("./routes.cjs");
|
|
17
|
+
for (const filePath of routeFiles) {
|
|
18
|
+
const mod = await options.loadModule(filePath);
|
|
19
|
+
const manifest = getProgrammaticRouteManifest(mod);
|
|
20
|
+
if (manifest) {
|
|
21
|
+
manifests.push({ filePath, manifest });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return manifests;
|
|
25
|
+
}
|
|
26
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, loadProgrammaticRouteManifests, "loadProgrammaticRouteManifests");
|
|
27
|
+
function findProgrammaticRouteFiles(root, srcDir = "src") {
|
|
28
|
+
return findProgrammaticRouteFilesInDir(_path.join.call(void 0, root, srcDir));
|
|
29
|
+
}
|
|
30
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findProgrammaticRouteFiles, "findProgrammaticRouteFiles");
|
|
31
|
+
function findProgrammaticRouteFilesInDir(srcRoot) {
|
|
32
|
+
const files = [];
|
|
33
|
+
for (const fileName of _chunk6V4TDWECcjs.PROGRAMMATIC_ROUTE_FILE_NAMES) {
|
|
34
|
+
const filePath = _path.join.call(void 0, srcRoot, fileName);
|
|
35
|
+
if (_fs.existsSync.call(void 0, filePath)) {
|
|
36
|
+
files.push(filePath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
}
|
|
41
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findProgrammaticRouteFilesInDir, "findProgrammaticRouteFilesInDir");
|
|
42
|
+
async function discoverProgrammaticRoutePaths(root, srcDir = "src") {
|
|
43
|
+
const paths = /* @__PURE__ */ new Set();
|
|
44
|
+
const files = /* @__PURE__ */ new Set([
|
|
45
|
+
...findProgrammaticRouteFiles(root, srcDir),
|
|
46
|
+
...await findProgrammaticRouteSourceFiles(_path.join.call(void 0, root, srcDir))
|
|
47
|
+
]);
|
|
48
|
+
for (const filePath of files) {
|
|
49
|
+
const source = _fs.readFileSync.call(void 0, filePath, "utf8");
|
|
50
|
+
for (const routePath of _chunk6V4TDWECcjs.scanProgrammaticPagePaths.call(void 0, source)) {
|
|
51
|
+
paths.add(routePath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return Array.from(paths).sort();
|
|
55
|
+
}
|
|
56
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, discoverProgrammaticRoutePaths, "discoverProgrammaticRoutePaths");
|
|
57
|
+
async function findProgrammaticRouteSourceFiles(srcRoot) {
|
|
58
|
+
if (!_fs.existsSync.call(void 0, srcRoot)) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const glob = await import("fast-glob");
|
|
63
|
+
return await glob.default("**/*.{ts,tsx,js,jsx}", {
|
|
64
|
+
cwd: srcRoot,
|
|
65
|
+
absolute: true,
|
|
66
|
+
ignore: [
|
|
67
|
+
"**/*.d.ts",
|
|
68
|
+
"**/node_modules/**",
|
|
69
|
+
"**/.*/**",
|
|
70
|
+
"farm-routes.d.ts",
|
|
71
|
+
"farm-env.d.ts",
|
|
72
|
+
"lib/api.generated.ts"
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findProgrammaticRouteSourceFiles, "findProgrammaticRouteSourceFiles");
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
exports.loadProgrammaticRouteManifests = loadProgrammaticRouteManifests; exports.findProgrammaticRouteFiles = findProgrammaticRouteFiles; exports.findProgrammaticRouteFilesInDir = findProgrammaticRouteFilesInDir; exports.discoverProgrammaticRoutePaths = discoverProgrammaticRoutePaths;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkHBTUGXHScjs = require('./chunk-HBTUGXHS.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
7
|
+
|
|
8
|
+
// src/i18n/catalog.ts
|
|
9
|
+
var _promises = require('fs/promises');
|
|
10
|
+
var _icumessageformatparser = require('@formatjs/icu-messageformat-parser');
|
|
11
|
+
async function readFarmI18nCatalogs(config) {
|
|
12
|
+
if (!config.enabled) {
|
|
13
|
+
return { catalogs: {}, signatures: {} };
|
|
14
|
+
}
|
|
15
|
+
const catalogs = {};
|
|
16
|
+
for (const locale of config.locales) {
|
|
17
|
+
const filePath = _chunkHBTUGXHScjs.resolveFarmI18nMessagePath.call(void 0, config, locale);
|
|
18
|
+
let source;
|
|
19
|
+
try {
|
|
20
|
+
source = await _promises.readFile.call(void 0, filePath, "utf8");
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Unable to read Farm i18n catalog for "${locale}" at ${filePath}: ${messageOf(error)}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
let parsed;
|
|
27
|
+
try {
|
|
28
|
+
parsed = JSON.parse(source);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
throw new Error(`Invalid JSON in Farm i18n catalog ${filePath}: ${messageOf(error)}`);
|
|
31
|
+
}
|
|
32
|
+
catalogs[locale] = flattenFarmI18nCatalog(parsed, filePath);
|
|
33
|
+
}
|
|
34
|
+
const reference = catalogs[config.defaultLocale] || {};
|
|
35
|
+
const signatures = {};
|
|
36
|
+
for (const [key, message] of Object.entries(reference)) {
|
|
37
|
+
signatures[key] = analyzeFarmI18nMessage(message, `${config.defaultLocale}:${key}`);
|
|
38
|
+
}
|
|
39
|
+
validateFarmI18nCatalogs(config, catalogs, signatures);
|
|
40
|
+
return { catalogs, signatures };
|
|
41
|
+
}
|
|
42
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readFarmI18nCatalogs, "readFarmI18nCatalogs");
|
|
43
|
+
function flattenFarmI18nCatalog(input, source = "i18n catalog") {
|
|
44
|
+
if (!isPlainObject(input)) {
|
|
45
|
+
throw new Error(`${source} must contain a JSON object at its root.`);
|
|
46
|
+
}
|
|
47
|
+
const output = {};
|
|
48
|
+
const visit = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (value, segments) => {
|
|
49
|
+
if (typeof value === "string") {
|
|
50
|
+
const key = segments.join(".");
|
|
51
|
+
if (!key) throw new Error(`${source} contains an empty message key.`);
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(output, key)) {
|
|
53
|
+
throw new Error(`${source} contains duplicate message key "${key}".`);
|
|
54
|
+
}
|
|
55
|
+
output[key] = value;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!isPlainObject(value)) {
|
|
59
|
+
const key = segments.join(".") || "<root>";
|
|
60
|
+
throw new Error(`${source} message "${key}" must be a string or nested object.`);
|
|
61
|
+
}
|
|
62
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
63
|
+
if (!key.trim()) throw new Error(`${source} contains an empty message key.`);
|
|
64
|
+
visit(nested, [...segments, key]);
|
|
65
|
+
}
|
|
66
|
+
}, "visit");
|
|
67
|
+
visit(input, []);
|
|
68
|
+
return output;
|
|
69
|
+
}
|
|
70
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, flattenFarmI18nCatalog, "flattenFarmI18nCatalog");
|
|
71
|
+
function analyzeFarmI18nMessage(message, label = "message") {
|
|
72
|
+
let ast;
|
|
73
|
+
try {
|
|
74
|
+
ast = _icumessageformatparser.parse.call(void 0, message, { captureLocation: false });
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw new Error(`Invalid ICU syntax in ${label}: ${messageOf(error)}`);
|
|
77
|
+
}
|
|
78
|
+
const signature = {};
|
|
79
|
+
collectArguments(ast, signature, label);
|
|
80
|
+
return signature;
|
|
81
|
+
}
|
|
82
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, analyzeFarmI18nMessage, "analyzeFarmI18nMessage");
|
|
83
|
+
function validateFarmI18nCatalogs(config, catalogs, signatures) {
|
|
84
|
+
const referenceKeys = Object.keys(catalogs[config.defaultLocale] || {}).sort();
|
|
85
|
+
for (const locale of config.locales) {
|
|
86
|
+
const catalog = catalogs[locale] || {};
|
|
87
|
+
const localeKeys = Object.keys(catalog).sort();
|
|
88
|
+
const missing = referenceKeys.filter(
|
|
89
|
+
(key) => !Object.prototype.hasOwnProperty.call(catalog, key)
|
|
90
|
+
);
|
|
91
|
+
const extra = localeKeys.filter(
|
|
92
|
+
(key) => !Object.prototype.hasOwnProperty.call(signatures, key)
|
|
93
|
+
);
|
|
94
|
+
if (config.strict && (missing.length > 0 || extra.length > 0)) {
|
|
95
|
+
const details = [
|
|
96
|
+
missing.length ? `missing: ${missing.join(", ")}` : "",
|
|
97
|
+
extra.length ? `extra: ${extra.join(", ")}` : ""
|
|
98
|
+
].filter(Boolean).join("; ");
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Farm i18n catalog "${locale}" does not match the default catalog (${details}).`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
for (const [key, message] of Object.entries(catalog)) {
|
|
104
|
+
const actual = analyzeFarmI18nMessage(message, `${locale}:${key}`);
|
|
105
|
+
const expected = signatures[key];
|
|
106
|
+
if (!expected || sameSignature(expected, actual)) continue;
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Farm i18n message "${key}" in "${locale}" uses different variables than "${config.defaultLocale}".`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateFarmI18nCatalogs, "validateFarmI18nCatalogs");
|
|
114
|
+
function collectArguments(elements, signature, label) {
|
|
115
|
+
for (const element of elements) {
|
|
116
|
+
switch (element.type) {
|
|
117
|
+
case _icumessageformatparser.TYPE.argument:
|
|
118
|
+
addArgument(signature, element.value, "string", label);
|
|
119
|
+
break;
|
|
120
|
+
case _icumessageformatparser.TYPE.number:
|
|
121
|
+
case _icumessageformatparser.TYPE.plural:
|
|
122
|
+
addArgument(signature, element.value, "number", label);
|
|
123
|
+
break;
|
|
124
|
+
case _icumessageformatparser.TYPE.date:
|
|
125
|
+
case _icumessageformatparser.TYPE.time:
|
|
126
|
+
addArgument(signature, element.value, "date", label);
|
|
127
|
+
break;
|
|
128
|
+
case _icumessageformatparser.TYPE.select:
|
|
129
|
+
addArgument(signature, element.value, "select", label);
|
|
130
|
+
break;
|
|
131
|
+
case _icumessageformatparser.TYPE.tag:
|
|
132
|
+
addArgument(signature, element.value, "rich", label);
|
|
133
|
+
collectArguments(element.children, signature, label);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (element.type === _icumessageformatparser.TYPE.plural || element.type === _icumessageformatparser.TYPE.select) {
|
|
137
|
+
for (const option of Object.values(element.options)) {
|
|
138
|
+
collectArguments(option.value, signature, label);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, collectArguments, "collectArguments");
|
|
144
|
+
function addArgument(signature, name, kind, label) {
|
|
145
|
+
const existing = signature[name];
|
|
146
|
+
if (existing && existing !== kind) {
|
|
147
|
+
throw new Error(`Farm i18n ${label} uses variable "${name}" as both ${existing} and ${kind}.`);
|
|
148
|
+
}
|
|
149
|
+
signature[name] = kind;
|
|
150
|
+
}
|
|
151
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, addArgument, "addArgument");
|
|
152
|
+
function sameSignature(expected, actual) {
|
|
153
|
+
const expectedEntries = Object.entries(expected).sort(([a], [b]) => a.localeCompare(b));
|
|
154
|
+
const actualEntries = Object.entries(actual).sort(([a], [b]) => a.localeCompare(b));
|
|
155
|
+
return JSON.stringify(expectedEntries) === JSON.stringify(actualEntries);
|
|
156
|
+
}
|
|
157
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, sameSignature, "sameSignature");
|
|
158
|
+
function isPlainObject(value) {
|
|
159
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
160
|
+
}
|
|
161
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPlainObject, "isPlainObject");
|
|
162
|
+
function messageOf(error) {
|
|
163
|
+
return error instanceof Error ? error.message : String(error);
|
|
164
|
+
}
|
|
165
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, messageOf, "messageOf");
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
exports.readFarmI18nCatalogs = readFarmI18nCatalogs;
|