@farm.js/core 0.1.0-beta.0 → 0.1.0-beta.3
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 +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/api/route-manager.cjs +97 -5
- package/dist/api/route-manager.cjs.map +1 -1
- package/dist/api/route-manager.d.mts +3 -2
- package/dist/api/route-manager.d.ts +3 -2
- package/dist/api/route-manager.mjs +8 -8
- package/dist/api/runtime.cjs +441 -5
- package/dist/api/runtime.cjs.map +1 -1
- package/dist/api/runtime.d.mts +2 -16
- package/dist/api/runtime.d.ts +2 -16
- package/dist/api/runtime.mjs +7 -1
- package/dist/api.cjs +579 -263
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +4 -147
- package/dist/api.d.ts +4 -147
- package/dist/api.mjs +30 -20
- package/dist/{app-BiX4qb-d.d.mts → app-BB3Iu3xh.d.mts} +2 -2
- package/dist/{app-CFRNJXP1.d.ts → app-DOKxo-LH.d.ts} +2 -2
- package/dist/app-markdown.cjs +1 -1
- package/dist/app-markdown.cjs.map +1 -1
- package/dist/app-markdown.d.mts +1 -1
- package/dist/app-markdown.d.ts +1 -1
- package/dist/app-markdown.mjs +1 -1
- package/dist/cache.cjs +19 -0
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.mts +21 -1
- package/dist/cache.d.ts +21 -1
- package/dist/cache.mjs +5 -3
- 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-AGS7UJ52.mjs → chunk-45LKHSHJ.mjs} +2 -2
- package/dist/{chunk-TU4YJICB.mjs → chunk-5FW6PQ3J.mjs} +1 -1
- package/dist/{chunk-TU4YJICB.mjs.map → chunk-5FW6PQ3J.mjs.map} +1 -1
- package/dist/{chunk-TRORP7E4.mjs → chunk-5QH4IKY3.mjs} +2 -2
- package/dist/{chunk-RKI6TN3A.mjs → chunk-6VS6CKAV.mjs} +2 -2
- package/dist/chunk-6VS6CKAV.mjs.map +1 -0
- package/dist/{chunk-25D7G34K.mjs → chunk-6WXJ54TC.mjs} +4 -4
- package/dist/{chunk-3QJO55ZF.mjs → chunk-BIOIOWXZ.mjs} +5 -3
- package/dist/{chunk-3QJO55ZF.mjs.map → chunk-BIOIOWXZ.mjs.map} +1 -1
- package/dist/{chunk-QFQRHRZS.mjs → chunk-C33RALN7.mjs} +75 -11
- package/dist/chunk-C33RALN7.mjs.map +1 -0
- package/dist/{chunk-B6N4ZB2H.mjs → chunk-CSU4KJJF.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-PRNYWD7K.mjs → chunk-G5I34UA6.mjs} +67 -239
- package/dist/chunk-G5I34UA6.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-4PTK6KT4.mjs → chunk-GZWT6VI5.mjs} +22 -4
- package/dist/chunk-GZWT6VI5.mjs.map +1 -0
- package/dist/{chunk-JLWMCADZ.mjs → chunk-HZYXGV4K.mjs} +2 -2
- package/dist/chunk-JNYVN7YP.mjs +10 -0
- package/dist/chunk-JNYVN7YP.mjs.map +1 -0
- package/dist/{chunk-YHU7SS6L.mjs → chunk-LG3YINQN.mjs} +11 -11
- package/dist/chunk-LWMGIEJA.mjs +593 -0
- package/dist/chunk-LWMGIEJA.mjs.map +1 -0
- package/dist/{chunk-HXP3ZSPC.mjs → chunk-MH6FKW2I.mjs} +3 -3
- 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-6XDUHOEM.mjs → chunk-NRRFGX45.mjs} +3 -3
- package/dist/{chunk-G3B5BRDY.mjs → chunk-OHC6VCDI.mjs} +24 -25
- package/dist/{chunk-G3B5BRDY.mjs.map → chunk-OHC6VCDI.mjs.map} +1 -1
- package/dist/{chunk-S2XHZS7W.mjs → chunk-QGQX7SFC.mjs} +2 -2
- package/dist/chunk-QGQX7SFC.mjs.map +1 -0
- package/dist/{chunk-TXCFGOHW.mjs → chunk-SHRJG6OG.mjs} +25 -1
- package/dist/chunk-SHRJG6OG.mjs.map +1 -0
- package/dist/{chunk-UHE2TTLK.mjs → chunk-T543TMFY.mjs} +8 -8
- package/dist/chunk-T543TMFY.mjs.map +1 -0
- package/dist/{chunk-SXZTEK3V.mjs → chunk-UXUAWNO5.mjs} +2 -2
- package/dist/{chunk-Y2OJJD7R.mjs → chunk-XIVV5IWN.mjs} +7 -9
- package/dist/chunk-XIVV5IWN.mjs.map +1 -0
- package/dist/{chunk-CHFHNEMO.mjs → chunk-XJSHJN4M.mjs} +41 -42
- package/dist/chunk-XJSHJN4M.mjs.map +1 -0
- package/dist/{chunk-Y7A27276.mjs → chunk-XUBZ7JI4.mjs} +178 -15
- package/dist/chunk-XUBZ7JI4.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-SOU3Q3ZA.mjs → chunk-ZZ57EH5Z.mjs} +1 -1
- package/dist/chunk-ZZ57EH5Z.mjs.map +1 -0
- package/dist/{client-D_yUjVhe.d.mts → client-DiViK9yK.d.mts} +33 -7
- package/dist/{client-Dkc03WP8.d.ts → client-DpEBJbts.d.ts} +33 -7
- package/dist/{client-plugins-BZnpeTGA.d.ts → client-plugins-CTnsZz_A.d.ts} +1 -0
- package/dist/{client-plugins-g4bzuCmo.d.mts → client-plugins-Cnr0D3kk.d.mts} +1 -0
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +302 -54
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +54 -2
- package/dist/client.d.ts +54 -2
- package/dist/client.mjs +20 -16
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.mjs +1 -1
- package/dist/{devtools-AE4RVXCM.mjs → devtools-HE4FTUDN.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 +3 -1
- 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 +791 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.mjs +125 -110
- package/dist/index.mjs.map +1 -1
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/internal/build-runtime.cjs +162 -60
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +26 -25
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +1 -1
- package/dist/internal/config-runtime.cjs +1 -1
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +9 -9
- package/dist/internal/production-runtime.cjs +3 -3
- package/dist/internal/production-runtime.cjs.map +1 -1
- package/dist/internal/production-runtime.d.mts +3 -3
- package/dist/internal/production-runtime.d.ts +3 -3
- package/dist/internal/production-runtime.mjs +8 -8
- package/dist/{metadata-C9NZxMDW.d.mts → metadata-Dp8AdvsB.d.mts} +1 -1
- package/dist/{metadata-DAXRaOHx.d.ts → metadata-eoVmHoyv.d.ts} +1 -1
- package/dist/middleware.cjs +2 -2
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.mjs +3 -3
- 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 +119 -39
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +22 -21
- package/dist/{production-runtime-DRkCHUvJ.d.ts → production-runtime-BqTnUTai.d.ts} +1 -1
- package/dist/{production-runtime-flrjp_nC.d.mts → production-runtime-DtDdG9fc.d.mts} +1 -1
- 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-C1B7pSGT.d.mts +207 -0
- package/dist/runtime-CdPHt0bv.d.ts +207 -0
- package/dist/server-action-security.cjs.map +1 -1
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn-client.cjs.map +1 -1
- package/dist/server-fn-client.mjs +1 -1
- package/dist/server-fn.cjs.map +1 -1
- package/dist/server-fn.mjs +3 -3
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-query-client.cjs.map +1 -1
- package/dist/server-query-client.mjs +4 -4
- package/dist/server-query.cjs.map +1 -1
- package/dist/server-query.mjs +5 -5
- package/dist/server.cjs +148 -43
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +6 -6
- package/dist/server.d.ts +6 -6
- package/dist/server.mjs +36 -31
- package/dist/server.mjs.map +1 -1
- package/dist/testing.cjs +95 -5
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.mts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.mjs +18 -18
- package/dist/{utils-DOXXivjL.d.mts → utils-8USa5BiY.d.mts} +1 -1
- package/dist/{utils-DA1yo54_.d.ts → utils-DKJb6K6G.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 +126 -40
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +22 -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/client.d.ts +136 -13
- package/dist/chunk-4PTK6KT4.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-GZP5W4K3.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-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-AGS7UJ52.mjs.map → chunk-45LKHSHJ.mjs.map} +0 -0
- /package/dist/{chunk-TRORP7E4.mjs.map → chunk-5QH4IKY3.mjs.map} +0 -0
- /package/dist/{chunk-25D7G34K.mjs.map → chunk-6WXJ54TC.mjs.map} +0 -0
- /package/dist/{chunk-B6N4ZB2H.mjs.map → chunk-CSU4KJJF.mjs.map} +0 -0
- /package/dist/{chunk-JLWMCADZ.mjs.map → chunk-HZYXGV4K.mjs.map} +0 -0
- /package/dist/{chunk-YHU7SS6L.mjs.map → chunk-LG3YINQN.mjs.map} +0 -0
- /package/dist/{chunk-HXP3ZSPC.mjs.map → chunk-MH6FKW2I.mjs.map} +0 -0
- /package/dist/{chunk-6XDUHOEM.mjs.map → chunk-NRRFGX45.mjs.map} +0 -0
- /package/dist/{chunk-SXZTEK3V.mjs.map → chunk-UXUAWNO5.mjs.map} +0 -0
- /package/dist/{devtools-AE4RVXCM.mjs.map → devtools-HE4FTUDN.mjs.map} +0 -0
package/dist/server.cjs
CHANGED
|
@@ -118,7 +118,7 @@ function createFarmMarkdownRouteModule(input) {
|
|
|
118
118
|
...props,
|
|
119
119
|
components: {
|
|
120
120
|
...components,
|
|
121
|
-
...props?.components
|
|
121
|
+
...props?.components
|
|
122
122
|
}
|
|
123
123
|
})
|
|
124
124
|
);
|
|
@@ -635,7 +635,11 @@ async function prepareFarmWorkflowsForNitro(config) {
|
|
|
635
635
|
};
|
|
636
636
|
}
|
|
637
637
|
const handlerPath = path23.join(generatedDir, "http-handler.mjs");
|
|
638
|
-
await fs9.writeFile(
|
|
638
|
+
await fs9.writeFile(
|
|
639
|
+
handlerPath,
|
|
640
|
+
createNitroWorkflowHTTPHandler(workflowConfig, workflows),
|
|
641
|
+
"utf8"
|
|
642
|
+
);
|
|
639
643
|
const manifestPath = path23.join(generatedDir, "manifest.json");
|
|
640
644
|
await fs9.writeFile(
|
|
641
645
|
manifestPath,
|
|
@@ -709,13 +713,7 @@ function normalizeSchedule(schedule) {
|
|
|
709
713
|
return (Array.isArray(schedule) ? schedule : [schedule]).map((value) => value.trim()).filter(Boolean);
|
|
710
714
|
}
|
|
711
715
|
function resolveWorkflowDefinition(module2) {
|
|
712
|
-
const candidates = [
|
|
713
|
-
module2.default,
|
|
714
|
-
module2.workflow,
|
|
715
|
-
module2.cron,
|
|
716
|
-
module2.task,
|
|
717
|
-
module2.job
|
|
718
|
-
];
|
|
716
|
+
const candidates = [module2.default, module2.workflow, module2.cron, module2.task, module2.job];
|
|
719
717
|
for (const candidate of candidates) {
|
|
720
718
|
if (candidate && typeof candidate === "object" && typeof candidate.run === "function") {
|
|
721
719
|
return candidate;
|
|
@@ -1708,8 +1706,8 @@ function compareFarmRouteRuleSpecificity(left, right) {
|
|
|
1708
1706
|
}
|
|
1709
1707
|
function getFarmRouteRuleSpecificity(pattern) {
|
|
1710
1708
|
return normalizeRoutePattern(pattern).split("/").filter(Boolean).reduce((score, segment) => {
|
|
1711
|
-
if (segment === "**" ||
|
|
1712
|
-
if (segment === "*" ||
|
|
1709
|
+
if (segment === "**" || segment.startsWith("[[...")) return score + 1;
|
|
1710
|
+
if (segment === "*" || segment.startsWith("[...")) return score + 10;
|
|
1713
1711
|
if (/^\[.+\]$/.test(segment) || /^:.+$/.test(segment)) return score + 50;
|
|
1714
1712
|
return score + 100;
|
|
1715
1713
|
}, 0);
|
|
@@ -1770,7 +1768,7 @@ function routeRulesToHeaders(routeRules) {
|
|
|
1770
1768
|
for (const [source, rule] of Object.entries(routeRules)) {
|
|
1771
1769
|
const headers = {
|
|
1772
1770
|
...normalizeCorsHeaders(rule.cors),
|
|
1773
|
-
...rule.headers
|
|
1771
|
+
...rule.headers
|
|
1774
1772
|
};
|
|
1775
1773
|
const entries = Object.entries(headers);
|
|
1776
1774
|
if (entries.length === 0) continue;
|
|
@@ -1838,20 +1836,41 @@ function applyFarmCacheInvalidations(keys) {
|
|
|
1838
1836
|
}
|
|
1839
1837
|
}
|
|
1840
1838
|
}
|
|
1839
|
+
function encodeFarmCacheInvalidations(keys) {
|
|
1840
|
+
const normalized = Array.from(
|
|
1841
|
+
new Set(keys.filter((key) => typeof key === "string" && key.length > 0))
|
|
1842
|
+
);
|
|
1843
|
+
if (normalized.length === 0) return null;
|
|
1844
|
+
return encodeURIComponent(JSON.stringify(normalized));
|
|
1845
|
+
}
|
|
1846
|
+
function decodeFarmCacheInvalidations(value) {
|
|
1847
|
+
if (!value) return [];
|
|
1848
|
+
try {
|
|
1849
|
+
const parsed = JSON.parse(decodeURIComponent(value));
|
|
1850
|
+
return Array.isArray(parsed) ? Array.from(
|
|
1851
|
+
new Set(parsed.filter((key) => typeof key === "string" && key.length > 0))
|
|
1852
|
+
) : [];
|
|
1853
|
+
} catch {
|
|
1854
|
+
return [];
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1841
1857
|
function subscribeFarmCacheInvalidation(listener) {
|
|
1842
1858
|
const state = getFarmCacheInvalidationState();
|
|
1843
1859
|
state.listeners.add(listener);
|
|
1844
1860
|
return () => state.listeners.delete(listener);
|
|
1845
1861
|
}
|
|
1846
|
-
var FARM_CACHE_INVALIDATION_STATE, globalState;
|
|
1862
|
+
var FARM_CACHE_INVALIDATION_HEADER, FARM_CACHE_INVALIDATION_STATE, globalState;
|
|
1847
1863
|
var init_cache_invalidation = __esm({
|
|
1848
1864
|
"src/cache-invalidation.ts"() {
|
|
1849
1865
|
"use strict";
|
|
1866
|
+
FARM_CACHE_INVALIDATION_HEADER = "x-farm-cache-invalidations";
|
|
1850
1867
|
FARM_CACHE_INVALIDATION_STATE = /* @__PURE__ */ Symbol.for("farm.cacheInvalidationState");
|
|
1851
1868
|
globalState = globalThis;
|
|
1852
1869
|
__name(getFarmCacheInvalidationState, "getFarmCacheInvalidationState");
|
|
1853
1870
|
__name(notifyFarmCacheInvalidation, "notifyFarmCacheInvalidation");
|
|
1854
1871
|
__name(applyFarmCacheInvalidations, "applyFarmCacheInvalidations");
|
|
1872
|
+
__name(encodeFarmCacheInvalidations, "encodeFarmCacheInvalidations");
|
|
1873
|
+
__name(decodeFarmCacheInvalidations, "decodeFarmCacheInvalidations");
|
|
1855
1874
|
__name(subscribeFarmCacheInvalidation, "subscribeFarmCacheInvalidation");
|
|
1856
1875
|
}
|
|
1857
1876
|
});
|
|
@@ -5898,7 +5917,9 @@ function readManifest(contentDir) {
|
|
|
5898
5917
|
const manifestPath = import_node_path7.default.join(contentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST);
|
|
5899
5918
|
if (!(0, import_node_fs5.existsSync)(manifestPath)) return null;
|
|
5900
5919
|
try {
|
|
5901
|
-
const parsed = JSON.parse(
|
|
5920
|
+
const parsed = JSON.parse(
|
|
5921
|
+
(0, import_node_fs5.readFileSync)(manifestPath, "utf8")
|
|
5922
|
+
);
|
|
5902
5923
|
if (parsed.version !== 1 || !parsed.pages || typeof parsed.pages !== "object") return null;
|
|
5903
5924
|
const pages = Object.fromEntries(
|
|
5904
5925
|
Object.entries(parsed.pages).filter(
|
|
@@ -12417,16 +12438,7 @@ __export(devtools_client_exports, {
|
|
|
12417
12438
|
function parseShortcut(shortcut) {
|
|
12418
12439
|
const tokens = shortcut.toLowerCase().split("+").map((token) => token.trim()).filter(Boolean);
|
|
12419
12440
|
const key = tokens.find(
|
|
12420
|
-
(token) => ![
|
|
12421
|
-
"alt",
|
|
12422
|
-
"ctrl",
|
|
12423
|
-
"control",
|
|
12424
|
-
"meta",
|
|
12425
|
-
"cmd",
|
|
12426
|
-
"command",
|
|
12427
|
-
"mod",
|
|
12428
|
-
"shift"
|
|
12429
|
-
].includes(token)
|
|
12441
|
+
(token) => !["alt", "ctrl", "control", "meta", "cmd", "command", "mod", "shift"].includes(token)
|
|
12430
12442
|
);
|
|
12431
12443
|
if (!key) {
|
|
12432
12444
|
return null;
|
|
@@ -12736,6 +12748,7 @@ __export(server_exports, {
|
|
|
12736
12748
|
createServerQuery: () => createServerQuery,
|
|
12737
12749
|
createStorageClient: () => createStorageClient,
|
|
12738
12750
|
databaseStorage: () => databaseStorage,
|
|
12751
|
+
defineCacheKey: () => defineCacheKey,
|
|
12739
12752
|
defineConfig: () => defineConfig2,
|
|
12740
12753
|
defineStorageClient: () => defineStorageClient,
|
|
12741
12754
|
disposeStorage: () => disposeStorage,
|
|
@@ -13472,6 +13485,23 @@ __name(getActiveFarmI18nSnapshot, "getActiveFarmI18nSnapshot");
|
|
|
13472
13485
|
|
|
13473
13486
|
// src/cache.ts
|
|
13474
13487
|
init_cache_invalidation();
|
|
13488
|
+
function defineCacheKey() {
|
|
13489
|
+
return (factory) => {
|
|
13490
|
+
if (typeof factory !== "function") {
|
|
13491
|
+
throw new TypeError("defineCacheKey expects a key factory function.");
|
|
13492
|
+
}
|
|
13493
|
+
return ((...args) => {
|
|
13494
|
+
const key = factory(...args);
|
|
13495
|
+
if (typeof key !== "string" && !Array.isArray(key)) {
|
|
13496
|
+
throw new TypeError(
|
|
13497
|
+
"A defined cache key factory must return a string or structured array."
|
|
13498
|
+
);
|
|
13499
|
+
}
|
|
13500
|
+
return key;
|
|
13501
|
+
});
|
|
13502
|
+
};
|
|
13503
|
+
}
|
|
13504
|
+
__name(defineCacheKey, "defineCacheKey");
|
|
13475
13505
|
var _FarmDataCache = class _FarmDataCache {
|
|
13476
13506
|
constructor() {
|
|
13477
13507
|
this.entries = /* @__PURE__ */ new Map();
|
|
@@ -15985,7 +16015,7 @@ function mergeMetadata(base, next) {
|
|
|
15985
16015
|
__name(mergeMetadata, "mergeMetadata");
|
|
15986
16016
|
function addMetadataImageReference(metadata, reference) {
|
|
15987
16017
|
if (reference.kind === "opengraph") {
|
|
15988
|
-
const openGraph = { ...metadata.openGraph
|
|
16018
|
+
const openGraph = { ...metadata.openGraph };
|
|
15989
16019
|
if (!hasMetadataImages(openGraph.images) && !hasMetadataImages(openGraph.image)) {
|
|
15990
16020
|
openGraph.images = [
|
|
15991
16021
|
{
|
|
@@ -16002,7 +16032,7 @@ function addMetadataImageReference(metadata, reference) {
|
|
|
16002
16032
|
openGraph
|
|
16003
16033
|
};
|
|
16004
16034
|
}
|
|
16005
|
-
const twitter = { ...metadata.twitter
|
|
16035
|
+
const twitter = { ...metadata.twitter };
|
|
16006
16036
|
if (!hasMetadataImages(twitter.images)) {
|
|
16007
16037
|
twitter.images = [reference.href];
|
|
16008
16038
|
twitter.card = twitter.card || "summary_large_image";
|
|
@@ -16608,8 +16638,8 @@ var _FarmI18nRuntime = class _FarmI18nRuntime {
|
|
|
16608
16638
|
cookie: this.config.cookie,
|
|
16609
16639
|
direction: getFarmLocaleDirection(resolution.locale, this.config.direction),
|
|
16610
16640
|
messages: {
|
|
16611
|
-
...this.catalogs[this.config.fallbackLocale]
|
|
16612
|
-
...this.catalogs[resolution.locale]
|
|
16641
|
+
...this.catalogs[this.config.fallbackLocale],
|
|
16642
|
+
...this.catalogs[resolution.locale]
|
|
16613
16643
|
}
|
|
16614
16644
|
};
|
|
16615
16645
|
}
|
|
@@ -18083,11 +18113,7 @@ var _FarmApp = class _FarmApp {
|
|
|
18083
18113
|
_setDefaultFarmI18nRuntime(this.i18nRuntime);
|
|
18084
18114
|
this.viteServer = viteServer;
|
|
18085
18115
|
this.routeManager = new RouteManager(this.config, viteServer);
|
|
18086
|
-
this.serverRenderer = new ServerRenderer(
|
|
18087
|
-
this.config,
|
|
18088
|
-
this.routeManager,
|
|
18089
|
-
this.i18nRuntime
|
|
18090
|
-
);
|
|
18116
|
+
this.serverRenderer = new ServerRenderer(this.config, this.routeManager, this.i18nRuntime);
|
|
18091
18117
|
}
|
|
18092
18118
|
async initialize() {
|
|
18093
18119
|
if (process.env.FARM_VERBOSE) {
|
|
@@ -18536,6 +18562,29 @@ var fs3 = __toESM(require("fs"));
|
|
|
18536
18562
|
var path10 = __toESM(require("path"));
|
|
18537
18563
|
init_route_runtime();
|
|
18538
18564
|
|
|
18565
|
+
// src/api/runtime.ts
|
|
18566
|
+
init_cache_invalidation();
|
|
18567
|
+
|
|
18568
|
+
// src/api/endpoint.ts
|
|
18569
|
+
var import_better_call = require("better-call");
|
|
18570
|
+
var _EndpointFailure = class _EndpointFailure extends Error {
|
|
18571
|
+
constructor(code, data, options) {
|
|
18572
|
+
super(options.message);
|
|
18573
|
+
this.name = "EndpointFailure";
|
|
18574
|
+
this.code = code;
|
|
18575
|
+
this.data = data;
|
|
18576
|
+
this.status = options.status;
|
|
18577
|
+
}
|
|
18578
|
+
};
|
|
18579
|
+
__name(_EndpointFailure, "EndpointFailure");
|
|
18580
|
+
var EndpointFailure = _EndpointFailure;
|
|
18581
|
+
function isEndpointFailure(value) {
|
|
18582
|
+
return value instanceof EndpointFailure;
|
|
18583
|
+
}
|
|
18584
|
+
__name(isEndpointFailure, "isEndpointFailure");
|
|
18585
|
+
var EMPTY_ENDPOINT_MIDDLEWARE = Object.freeze([]);
|
|
18586
|
+
var EMPTY_ENDPOINT_CONTEXT = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
18587
|
+
|
|
18539
18588
|
// src/api/runtime.ts
|
|
18540
18589
|
function matchAPIRoute(routes, pathname) {
|
|
18541
18590
|
const exactRoute = routes.get(pathname);
|
|
@@ -18568,10 +18617,10 @@ __name(invokeAPIRouteEndpoint, "invokeAPIRouteEndpoint");
|
|
|
18568
18617
|
async function invokeAPIRouteEndpointInContext(endpoint, request, params) {
|
|
18569
18618
|
const farmHandler = endpoint.__handler || (isFarmContextHandler(endpoint) ? endpoint : null);
|
|
18570
18619
|
if (!farmHandler) {
|
|
18571
|
-
const
|
|
18620
|
+
const result = await endpoint(request, {
|
|
18572
18621
|
params: Promise.resolve(params)
|
|
18573
18622
|
});
|
|
18574
|
-
return normalizeRouteResponse(
|
|
18623
|
+
return normalizeRouteResponse(result);
|
|
18575
18624
|
}
|
|
18576
18625
|
const url = new URL(request.url);
|
|
18577
18626
|
const query = {};
|
|
@@ -18596,15 +18645,30 @@ async function invokeAPIRouteEndpointInContext(endpoint, request, params) {
|
|
|
18596
18645
|
if (headersValidation instanceof Response) {
|
|
18597
18646
|
return headersValidation;
|
|
18598
18647
|
}
|
|
18599
|
-
const
|
|
18648
|
+
const handlerContext = {
|
|
18600
18649
|
query: queryValidation,
|
|
18601
18650
|
body: bodyValidation,
|
|
18602
18651
|
headers: headersValidation,
|
|
18603
18652
|
request,
|
|
18604
18653
|
context: {},
|
|
18605
18654
|
params
|
|
18606
|
-
}
|
|
18607
|
-
|
|
18655
|
+
};
|
|
18656
|
+
let execution;
|
|
18657
|
+
try {
|
|
18658
|
+
execution = typeof endpoint.__farmInvoke === "function" ? await endpoint.__farmInvoke(handlerContext) : {
|
|
18659
|
+
result: await farmHandler(handlerContext),
|
|
18660
|
+
context: handlerContext.context,
|
|
18661
|
+
handlerExecuted: true,
|
|
18662
|
+
invalidations: []
|
|
18663
|
+
};
|
|
18664
|
+
} catch (error) {
|
|
18665
|
+
if (isEndpointFailure(error)) {
|
|
18666
|
+
return createEndpointFailureResponse(error);
|
|
18667
|
+
}
|
|
18668
|
+
throw error;
|
|
18669
|
+
}
|
|
18670
|
+
const response = normalizeRouteResponse(execution.result);
|
|
18671
|
+
return attachEndpointInvalidations(response, execution.invalidations);
|
|
18608
18672
|
}
|
|
18609
18673
|
__name(invokeAPIRouteEndpointInContext, "invokeAPIRouteEndpointInContext");
|
|
18610
18674
|
function normalizeRouteResponse(result) {
|
|
@@ -18624,6 +18688,40 @@ function isWebResponse2(value) {
|
|
|
18624
18688
|
return value instanceof Response || typeof value === "object" && value !== null && "headers" in value && "status" in value && typeof value.arrayBuffer === "function";
|
|
18625
18689
|
}
|
|
18626
18690
|
__name(isWebResponse2, "isWebResponse");
|
|
18691
|
+
function attachEndpointInvalidations(response, keys) {
|
|
18692
|
+
const existing = decodeFarmCacheInvalidations(
|
|
18693
|
+
response.headers.get(FARM_CACHE_INVALIDATION_HEADER)
|
|
18694
|
+
);
|
|
18695
|
+
const encoded = encodeFarmCacheInvalidations([...existing, ...keys]);
|
|
18696
|
+
if (!encoded) return response;
|
|
18697
|
+
const headers = new Headers(response.headers);
|
|
18698
|
+
headers.set(FARM_CACHE_INVALIDATION_HEADER, encoded);
|
|
18699
|
+
return new Response(response.body, {
|
|
18700
|
+
status: response.status,
|
|
18701
|
+
statusText: response.statusText,
|
|
18702
|
+
headers
|
|
18703
|
+
});
|
|
18704
|
+
}
|
|
18705
|
+
__name(attachEndpointInvalidations, "attachEndpointInvalidations");
|
|
18706
|
+
function createEndpointFailureResponse(failure) {
|
|
18707
|
+
return new Response(
|
|
18708
|
+
JSON.stringify({
|
|
18709
|
+
error: {
|
|
18710
|
+
code: failure.code,
|
|
18711
|
+
message: failure.message,
|
|
18712
|
+
data: failure.data
|
|
18713
|
+
}
|
|
18714
|
+
}),
|
|
18715
|
+
{
|
|
18716
|
+
status: failure.status,
|
|
18717
|
+
headers: {
|
|
18718
|
+
"cache-control": "no-store",
|
|
18719
|
+
"content-type": "application/json"
|
|
18720
|
+
}
|
|
18721
|
+
}
|
|
18722
|
+
);
|
|
18723
|
+
}
|
|
18724
|
+
__name(createEndpointFailureResponse, "createEndpointFailureResponse");
|
|
18627
18725
|
function isFarmContextHandler(endpoint) {
|
|
18628
18726
|
if (typeof endpoint !== "function") {
|
|
18629
18727
|
return false;
|
|
@@ -19652,7 +19750,7 @@ var _MiddlewareManager = class _MiddlewareManager {
|
|
|
19652
19750
|
if (!nestedMatch.matched) {
|
|
19653
19751
|
return { matched: false };
|
|
19654
19752
|
}
|
|
19655
|
-
const params = { ...nestedMatch.params
|
|
19753
|
+
const params = { ...nestedMatch.params };
|
|
19656
19754
|
delete params.__farmRest;
|
|
19657
19755
|
return {
|
|
19658
19756
|
matched: true,
|
|
@@ -20534,6 +20632,12 @@ function transformError(id, message) {
|
|
|
20534
20632
|
}
|
|
20535
20633
|
__name(transformError, "transformError");
|
|
20536
20634
|
|
|
20635
|
+
// package.json
|
|
20636
|
+
var version = "0.1.0-beta.3";
|
|
20637
|
+
|
|
20638
|
+
// src/version.ts
|
|
20639
|
+
var FARM_VERSION = version;
|
|
20640
|
+
|
|
20537
20641
|
// src/after.ts
|
|
20538
20642
|
var import_node_async_hooks4 = require("async_hooks");
|
|
20539
20643
|
var AFTER_STORAGE = /* @__PURE__ */ Symbol.for("@farm.js/core/after-storage");
|
|
@@ -21005,7 +21109,7 @@ function isResolvedEnvScope(value) {
|
|
|
21005
21109
|
}
|
|
21006
21110
|
__name(isResolvedEnvScope, "isResolvedEnvScope");
|
|
21007
21111
|
function isPotentialProgrammaticRouteSourceFile(normalizedFile, srcDirSlug) {
|
|
21008
|
-
return normalizedFile.startsWith(`${srcDirSlug}/`) && /\.(ts|tsx|js|jsx)$/.test(normalizedFile) &&
|
|
21112
|
+
return normalizedFile.startsWith(`${srcDirSlug}/`) && /\.(ts|tsx|js|jsx)$/.test(normalizedFile) && !normalizedFile.endsWith(".d.ts") && !normalizedFile.endsWith("/farm-routes.d.ts") && !normalizedFile.endsWith("/farm-env.d.ts") && !normalizedFile.endsWith("/lib/api.generated.ts");
|
|
21009
21113
|
}
|
|
21010
21114
|
__name(isPotentialProgrammaticRouteSourceFile, "isPotentialProgrammaticRouteSourceFile");
|
|
21011
21115
|
function fileContainsProgrammaticPageRoute(file) {
|
|
@@ -24131,7 +24235,7 @@ async function defineConfig2(config = {}) {
|
|
|
24131
24235
|
const isExposed = hostConfig === true || hostConfig === "0.0.0.0";
|
|
24132
24236
|
console.log("");
|
|
24133
24237
|
console.log(
|
|
24134
|
-
` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(
|
|
24238
|
+
` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(`v${FARM_VERSION}`)} ${pc.dim(`ready in ${elapsed}ms`)}`
|
|
24135
24239
|
);
|
|
24136
24240
|
console.log("");
|
|
24137
24241
|
console.log(
|
|
@@ -25295,7 +25399,7 @@ __name(createLoggerPlugin, "createLoggerPlugin");
|
|
|
25295
25399
|
// src/server/vite-config.ts
|
|
25296
25400
|
function mergeNoExternal(farmValue, userValue) {
|
|
25297
25401
|
if (farmValue === true || userValue === true) return true;
|
|
25298
|
-
const normalize = /* @__PURE__ */ __name((value) => value == null ? [] : Array.isArray(value) ? value : [value], "normalize");
|
|
25402
|
+
const normalize = /* @__PURE__ */ __name((value) => value == null || value === true ? [] : Array.isArray(value) ? value : [value], "normalize");
|
|
25299
25403
|
return Array.from(/* @__PURE__ */ new Set([...normalize(farmValue), ...normalize(userValue)]));
|
|
25300
25404
|
}
|
|
25301
25405
|
__name(mergeNoExternal, "mergeNoExternal");
|
|
@@ -25369,7 +25473,7 @@ function createBrandingPlugin() {
|
|
|
25369
25473
|
const pc = getColors();
|
|
25370
25474
|
console.log("");
|
|
25371
25475
|
console.log(
|
|
25372
|
-
` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(
|
|
25476
|
+
` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(`v${FARM_VERSION}`)} ${pc.dim(`ready in ${elapsed}ms`)}`
|
|
25373
25477
|
);
|
|
25374
25478
|
console.log("");
|
|
25375
25479
|
console.log(
|
|
@@ -25678,6 +25782,7 @@ __name(assertFunction, "assertFunction");
|
|
|
25678
25782
|
createServerQuery,
|
|
25679
25783
|
createStorageClient,
|
|
25680
25784
|
databaseStorage,
|
|
25785
|
+
defineCacheKey,
|
|
25681
25786
|
defineConfig,
|
|
25682
25787
|
defineStorageClient,
|
|
25683
25788
|
disposeStorage,
|