@farm.js/core 0.1.0-beta.97 → 0.1.0-beta.98
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.map +1 -0
- package/dist/agent-runtime.cjs +7 -3
- package/dist/agent-runtime.cjs.map +1 -0
- package/dist/agent-runtime.d.mts +2 -2
- package/dist/agent-runtime.d.ts +2 -2
- package/dist/agent-runtime.mjs +2 -1
- package/dist/agent-runtime.mjs.map +1 -1
- package/dist/api/route-manager.cjs.map +1 -0
- package/dist/api/route-manager.d.mts +2 -2
- package/dist/api/route-manager.d.ts +2 -2
- package/dist/api/runtime.cjs.map +1 -0
- package/dist/api.cjs +26 -1
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +2 -2
- package/dist/{app-CIOx3LvY.d.ts → app-CJKz2mbi.d.ts} +4 -4
- package/dist/{app-DBd6437H.d.mts → app-DMEGFLR2.d.mts} +4 -4
- package/dist/app-markdown.cjs.map +1 -0
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/cache.cjs.map +1 -0
- package/dist/{chunk-WD2EBM3I.mjs → chunk-3CQJV3NC.mjs} +2 -2
- package/dist/{chunk-I3OOUWO5.mjs → chunk-3GDRV7SG.mjs} +2 -2
- package/dist/{chunk-X4SFHKFH.mjs → chunk-6KJY25DQ.mjs} +5 -5
- package/dist/{chunk-FP5Q67FO.mjs → chunk-AAEZP2EY.mjs} +9 -9
- package/dist/{chunk-WMJGA32P.mjs → chunk-BXVOHG6B.mjs} +27 -2
- package/dist/{chunk-WMJGA32P.mjs.map → chunk-BXVOHG6B.mjs.map} +1 -1
- package/dist/{chunk-BZAIS65C.mjs → chunk-DIHNOVZZ.mjs} +40 -13
- package/dist/chunk-DIHNOVZZ.mjs.map +1 -0
- package/dist/{chunk-ISSFLGJ5.mjs → chunk-FDWECN3W.mjs} +8 -4
- package/dist/chunk-FDWECN3W.mjs.map +1 -0
- package/dist/chunk-FDWXXTWR.mjs +114 -0
- package/dist/chunk-FDWXXTWR.mjs.map +1 -0
- package/dist/{chunk-J3MPQ4MQ.mjs → chunk-IHADQ6J7.mjs} +2 -2
- package/dist/{chunk-J3MPQ4MQ.mjs.map → chunk-IHADQ6J7.mjs.map} +1 -1
- package/dist/{chunk-FSIXEIOB.mjs → chunk-L7FSTPGS.mjs} +2 -2
- package/dist/{chunk-AAC66ILR.mjs → chunk-LXXG3K2Y.mjs} +61 -2
- package/dist/chunk-LXXG3K2Y.mjs.map +1 -0
- package/dist/{chunk-GJ7W6LNK.mjs → chunk-N5RK4LK6.mjs} +3 -3
- package/dist/{chunk-WKDAA6V2.mjs → chunk-NBF56FXB.mjs} +20 -5
- package/dist/chunk-NBF56FXB.mjs.map +1 -0
- package/dist/chunk-RKUPOYQV.mjs +28 -0
- package/dist/chunk-RKUPOYQV.mjs.map +1 -0
- package/dist/{chunk-2SKCXYLB.mjs → chunk-RL3THP3L.mjs} +54 -5
- package/dist/chunk-RL3THP3L.mjs.map +1 -0
- package/dist/{chunk-52BR7LTX.mjs → chunk-STSPSJUI.mjs} +3 -3
- package/dist/{chunk-EPDIF432.mjs → chunk-UOGX6UNO.mjs} +37 -17
- package/dist/chunk-UOGX6UNO.mjs.map +1 -0
- package/dist/{chunk-YIBV77KZ.mjs → chunk-URQELPSH.mjs} +2 -2
- package/dist/{chunk-UMUWR5XA.mjs → chunk-UWQ4EEW7.mjs} +2 -2
- package/dist/{chunk-IZBX2TEU.mjs → chunk-VQG3QWWK.mjs} +2 -2
- package/dist/{chunk-D7F7YZ7L.mjs → chunk-WA77FWAO.mjs} +8 -8
- package/dist/{chunk-35NPLKQJ.mjs → chunk-XWM2C267.mjs} +21 -105
- package/dist/chunk-XWM2C267.mjs.map +1 -0
- package/dist/client/lifecycle.cjs.map +1 -0
- package/dist/client/lifecycle.mjs +2 -2
- package/dist/{client-plugins-B6-07YmP.d.mts → client-plugins-CyTLPqjP.d.mts} +38 -2
- package/dist/{client-plugins-By6MVUX-.d.ts → client-plugins-D-UgzngJ.d.ts} +38 -2
- package/dist/client-plugins.cjs +1 -1
- package/dist/client-plugins.cjs.map +1 -0
- package/dist/client-plugins.d.mts +2 -2
- package/dist/client-plugins.d.ts +2 -2
- package/dist/client-plugins.mjs +2 -2
- package/dist/client.cjs +61 -16
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +7 -7
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/cron.cjs +48 -12
- package/dist/cron.cjs.map +1 -0
- package/dist/cron.mjs +2 -1
- package/dist/deferred.cjs.map +1 -0
- package/dist/deployment.cjs.map +1 -0
- package/dist/{devtools-XWZX6CCL.mjs → devtools-KQ2PXSIC.mjs} +8 -6
- package/dist/{devtools-XWZX6CCL.mjs.map → devtools-KQ2PXSIC.mjs.map} +1 -1
- package/dist/docs.cjs +7 -3
- package/dist/docs.cjs.map +1 -0
- package/dist/docs.mjs +8 -6
- package/dist/env-types.cjs.map +1 -0
- package/dist/env.cjs.map +1 -0
- package/dist/environment/vite.cjs.map +1 -0
- package/dist/environment.cjs.map +1 -0
- package/dist/font.cjs.map +1 -0
- package/dist/headers.cjs.map +1 -0
- package/dist/i18n/client.cjs.map +1 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/server.cjs.map +1 -0
- package/dist/image/server.cjs +19 -4
- package/dist/image/server.cjs.map +1 -0
- package/dist/image/server.d.mts +6 -0
- package/dist/image/server.d.ts +6 -0
- package/dist/image/server.mjs +1 -1
- package/dist/image/sharp.cjs +1 -0
- package/dist/image/sharp.cjs.map +1 -0
- package/dist/image/sharp.mjs +1 -1
- package/dist/image.cjs.map +1 -0
- package/dist/index.cjs +370 -143
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.mjs +29 -21
- package/dist/index.mjs.map +1 -1
- package/dist/instrumentation.cjs.map +1 -0
- package/dist/{integration-orm-LLW6WZNK.mjs → integration-orm-G5BPBT5X.mjs} +3 -3
- package/dist/integrations.cjs +168 -5
- package/dist/integrations.cjs.map +1 -0
- package/dist/integrations.d.mts +2 -2
- package/dist/integrations.d.ts +2 -2
- package/dist/integrations.mjs +10 -3
- package/dist/internal/build-runtime.cjs +178 -51
- package/dist/internal/build-runtime.cjs.map +1 -0
- package/dist/internal/build-runtime.d.mts +4 -4
- package/dist/internal/build-runtime.d.ts +4 -4
- package/dist/internal/build-runtime.mjs +13 -11
- package/dist/internal/client-runtime.cjs +1 -1
- package/dist/internal/client-runtime.cjs.map +1 -0
- package/dist/internal/client-runtime.mjs +2 -2
- package/dist/internal/config-runtime.cjs +48 -42
- package/dist/internal/config-runtime.cjs.map +1 -0
- package/dist/internal/config-runtime.d.mts +3 -3
- package/dist/internal/config-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.mjs +7 -5
- package/dist/internal/isolated-boundary.cjs.map +1 -0
- package/dist/internal/metadata-image-runtime.cjs.map +1 -0
- package/dist/internal/product-telemetry-runtime.cjs +6 -2
- package/dist/internal/product-telemetry-runtime.cjs.map +1 -0
- package/dist/internal/product-telemetry-runtime.mjs +6 -2
- package/dist/internal/product-telemetry-runtime.mjs.map +1 -1
- package/dist/internal/production-node-env.cjs.map +1 -0
- package/dist/internal/production-runtime.cjs.map +1 -0
- package/dist/internal/production-runtime.d.mts +8 -8
- package/dist/internal/production-runtime.d.ts +8 -8
- package/dist/markdown.cjs.map +1 -0
- package/dist/{metadata-route-8_V3UonT.d.ts → metadata-route-BpU8K9RI.d.ts} +1 -1
- package/dist/{metadata-route-CWP_HjGU.d.mts → metadata-route-D1AYgWni.d.mts} +1 -1
- package/dist/middleware.cjs.map +1 -0
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/navigation.cjs.map +1 -0
- package/dist/{nitro-EGRNOB5P.mjs → nitro-IITKBMUI.mjs} +4 -3
- package/dist/{nitro-EGRNOB5P.mjs.map → nitro-IITKBMUI.mjs.map} +1 -1
- package/dist/observability.cjs.map +1 -0
- package/dist/plugin.cjs +143 -50
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.mjs +10 -8
- package/dist/{production-runtime-BGRH1dKG.d.mts → production-runtime-BIKA-BVT.d.mts} +2 -2
- package/dist/{production-runtime-CdmzsDax.d.ts → production-runtime-DtCUEELY.d.ts} +2 -2
- package/dist/query/client.cjs.map +1 -0
- package/dist/query/index.cjs.map +1 -0
- package/dist/query/parsers.cjs.map +1 -0
- package/dist/query/server.cjs.map +1 -0
- package/dist/{render-plan-DLxJYAA5.d.mts → render-plan-Dimb23ux.d.mts} +1 -1
- package/dist/{render-plan-0GeHiGVZ.d.ts → render-plan-rg3uiSo3.d.ts} +1 -1
- package/dist/renderer/react/client.cjs.map +1 -0
- package/dist/renderer/react/server.cjs.map +1 -0
- package/dist/renderer/react/vite.cjs.map +1 -0
- package/dist/renderer-client.cjs +26 -1
- package/dist/renderer-client.cjs.map +1 -0
- package/dist/renderer-client.d.mts +4 -4
- package/dist/renderer-client.d.ts +4 -4
- package/dist/renderer-client.mjs +2 -2
- package/dist/renderer.cjs.map +1 -0
- package/dist/{request-BstWbZ6O.d.ts → request-ColD-ChW.d.ts} +1 -1
- package/dist/{request-BCNXSXLh.d.mts → request-D5zvbU2Z.d.mts} +1 -1
- package/dist/request.cjs.map +1 -0
- package/dist/request.d.mts +3 -3
- package/dist/request.d.ts +3 -3
- package/dist/router.cjs.map +1 -0
- package/dist/routes.cjs.map +1 -0
- package/dist/routes.d.mts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/server-action-security.cjs +117 -104
- package/dist/server-action-security.cjs.map +1 -0
- package/dist/server-action-security.mjs +2 -1
- package/dist/server-fn-client.cjs.map +1 -0
- package/dist/server-fn.cjs.map +1 -0
- package/dist/server-fn.mjs +3 -2
- package/dist/server-plugins.cjs.map +1 -0
- package/dist/server-plugins.d.mts +3 -3
- package/dist/server-plugins.d.ts +3 -3
- package/dist/server-query-client.cjs +26 -1
- package/dist/server-query-client.cjs.map +1 -0
- package/dist/server-query-client.mjs +3 -3
- package/dist/server-query.cjs.map +1 -0
- package/dist/server-query.mjs +4 -3
- package/dist/server.cjs +221 -116
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.mts +8 -8
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +13 -11
- package/dist/server.mjs.map +1 -1
- package/dist/{spa-router-BeyAVSc6.d.mts → spa-router-BlilYGAN.d.mts} +1 -1
- package/dist/{spa-router-COgu4txb.d.ts → spa-router-kXORcsT_.d.ts} +1 -1
- package/dist/storage.cjs +7 -3
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.mjs +1 -1
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.mjs +2 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme/client.cjs.map +1 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/runtime.cjs.map +1 -0
- package/dist/theme/server.cjs.map +1 -0
- package/dist/{utils-DkU2c_1B.d.ts → utils-BhvF7Hhl.d.ts} +1 -1
- package/dist/{utils-DL2VwDQl.d.mts → utils-uF32evNX.d.mts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +143 -50
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.mjs +10 -8
- package/dist/{workflows-ChyK_oTu.d.mts → workflows-BantWytQ.d.mts} +7 -0
- package/dist/{workflows-ChyK_oTu.d.ts → workflows-BantWytQ.d.ts} +7 -0
- package/dist/workflows.cjs +67 -4
- package/dist/workflows.cjs.map +1 -0
- package/dist/workflows.d.mts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.mjs +2 -1
- package/package.json +17 -17
- package/dist/chunk-2SKCXYLB.mjs.map +0 -1
- package/dist/chunk-35NPLKQJ.mjs.map +0 -1
- package/dist/chunk-AAC66ILR.mjs.map +0 -1
- package/dist/chunk-BZAIS65C.mjs.map +0 -1
- package/dist/chunk-EPDIF432.mjs.map +0 -1
- package/dist/chunk-ISSFLGJ5.mjs.map +0 -1
- package/dist/chunk-WKDAA6V2.mjs.map +0 -1
- /package/dist/{chunk-WD2EBM3I.mjs.map → chunk-3CQJV3NC.mjs.map} +0 -0
- /package/dist/{chunk-I3OOUWO5.mjs.map → chunk-3GDRV7SG.mjs.map} +0 -0
- /package/dist/{chunk-X4SFHKFH.mjs.map → chunk-6KJY25DQ.mjs.map} +0 -0
- /package/dist/{chunk-FP5Q67FO.mjs.map → chunk-AAEZP2EY.mjs.map} +0 -0
- /package/dist/{chunk-FSIXEIOB.mjs.map → chunk-L7FSTPGS.mjs.map} +0 -0
- /package/dist/{chunk-GJ7W6LNK.mjs.map → chunk-N5RK4LK6.mjs.map} +0 -0
- /package/dist/{chunk-52BR7LTX.mjs.map → chunk-STSPSJUI.mjs.map} +0 -0
- /package/dist/{chunk-YIBV77KZ.mjs.map → chunk-URQELPSH.mjs.map} +0 -0
- /package/dist/{chunk-UMUWR5XA.mjs.map → chunk-UWQ4EEW7.mjs.map} +0 -0
- /package/dist/{chunk-IZBX2TEU.mjs.map → chunk-VQG3QWWK.mjs.map} +0 -0
- /package/dist/{chunk-D7F7YZ7L.mjs.map → chunk-WA77FWAO.mjs.map} +0 -0
- /package/dist/{integration-orm-LLW6WZNK.mjs.map → integration-orm-G5BPBT5X.mjs.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
FarmClientDataCache,
|
|
6
6
|
getFarmClientDataCache,
|
|
7
7
|
normalizeFarmClientCacheKey
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BXVOHG6B.mjs";
|
|
9
9
|
import {
|
|
10
10
|
resolveAPIRequestRuntime
|
|
11
11
|
} from "./chunk-YECMFULZ.mjs";
|
|
@@ -2334,4 +2334,4 @@ export {
|
|
|
2334
2334
|
settleServerFnOptimisticUpdates,
|
|
2335
2335
|
resolveServerFnInvalidateTargets
|
|
2336
2336
|
};
|
|
2337
|
-
//# sourceMappingURL=chunk-
|
|
2337
|
+
//# sourceMappingURL=chunk-VQG3QWWK.mjs.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
10
10
|
createFarmDocsLastModifiedManifest,
|
|
11
11
|
getFarmDocsRouteTypeEntries
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-URQELPSH.mjs";
|
|
13
13
|
import {
|
|
14
14
|
generateFarmDocsSearchClientRuntime,
|
|
15
15
|
isFarmDocsSearchEnabled,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
getDeployTargetForPreset,
|
|
21
21
|
hasCustomFarmRouteContext,
|
|
22
22
|
resolveDeployOutputPath
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6KJY25DQ.mjs";
|
|
24
24
|
import {
|
|
25
25
|
resolveFarmInstrumentationFile
|
|
26
26
|
} from "./chunk-5NAM3OTS.mjs";
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
resolveFarmIsolatedClientHydrationMode,
|
|
46
46
|
resolveFarmNotFoundComponentPath,
|
|
47
47
|
resolveRouteRenderingConfigFromFile
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-AAEZP2EY.mjs";
|
|
49
49
|
import {
|
|
50
50
|
farmEnvironmentFunctionsPlugin
|
|
51
51
|
} from "./chunk-V6WE6JSZ.mjs";
|
|
@@ -71,17 +71,17 @@ import {
|
|
|
71
71
|
import {
|
|
72
72
|
applyFarmWorkflowVercelCrons,
|
|
73
73
|
prepareFarmWorkflowsForNitro
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-RL3THP3L.mjs";
|
|
75
75
|
import {
|
|
76
76
|
applyFarmCronVercelCrons,
|
|
77
77
|
createFarmCronCloudflareConfig,
|
|
78
78
|
mergeScheduledTasks,
|
|
79
79
|
prepareFarmCronForNitro
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-DIHNOVZZ.mjs";
|
|
81
81
|
import {
|
|
82
82
|
getFarmIntegrationPluginServerRuntime,
|
|
83
83
|
getIntegrationProviders
|
|
84
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-LXXG3K2Y.mjs";
|
|
85
85
|
import {
|
|
86
86
|
appendMiddlewareRoutePath
|
|
87
87
|
} from "./chunk-4X57GXQA.mjs";
|
|
@@ -8515,7 +8515,7 @@ function resolveLegacyPageEntry(config, root, srcDir) {
|
|
|
8515
8515
|
__name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
|
|
8516
8516
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
8517
8517
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
8518
|
-
import("./nitro-
|
|
8518
|
+
import("./nitro-IITKBMUI.mjs"),
|
|
8519
8519
|
import("nitro")
|
|
8520
8520
|
]);
|
|
8521
8521
|
let nitroConfig = await createNitroConfig(
|
|
@@ -8608,4 +8608,4 @@ __name(buildNitro, "buildNitro");
|
|
|
8608
8608
|
export {
|
|
8609
8609
|
build
|
|
8610
8610
|
};
|
|
8611
|
-
//# sourceMappingURL=chunk-
|
|
8611
|
+
//# sourceMappingURL=chunk-WA77FWAO.mjs.map
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getRequestSourceOrigin,
|
|
3
|
+
matchesAllowedOrigin,
|
|
4
|
+
matchesHostHeader,
|
|
5
|
+
normalizeAllowedOriginPattern
|
|
6
|
+
} from "./chunk-FDWXXTWR.mjs";
|
|
1
7
|
import {
|
|
2
8
|
parseBodySizeLimit
|
|
3
9
|
} from "./chunk-ZHQMHJAV.mjs";
|
|
@@ -73,6 +79,7 @@ function isSerializedServerFnFailure(value) {
|
|
|
73
79
|
__name(isSerializedServerFnFailure, "isSerializedServerFnFailure");
|
|
74
80
|
|
|
75
81
|
// src/server-action-security.ts
|
|
82
|
+
var SERVER_ACTION_ALLOWED_ORIGINS_LABEL = "serverActions.allowedOrigins";
|
|
76
83
|
var DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1e6;
|
|
77
84
|
var _ServerActionRequestError = class _ServerActionRequestError extends Error {
|
|
78
85
|
constructor(code, status, message) {
|
|
@@ -97,7 +104,9 @@ var JAVASCRIPT_ACTION_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
97
104
|
"text/plain"
|
|
98
105
|
]);
|
|
99
106
|
function resolveServerActionsConfig(config) {
|
|
100
|
-
const allowedOrigins = (config?.allowedOrigins ?? []).map(
|
|
107
|
+
const allowedOrigins = (config?.allowedOrigins ?? []).map(
|
|
108
|
+
(value) => normalizeAllowedOriginPattern(value, SERVER_ACTION_ALLOWED_ORIGINS_LABEL)
|
|
109
|
+
);
|
|
101
110
|
const bodySizeLimit = parseBodySizeLimit(
|
|
102
111
|
config?.bodySizeLimit ?? DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT,
|
|
103
112
|
"serverActions.bodySizeLimit"
|
|
@@ -117,7 +126,7 @@ function validateServerActionRequest(request, config) {
|
|
|
117
126
|
);
|
|
118
127
|
}
|
|
119
128
|
const requestUrl = new URL(request.url);
|
|
120
|
-
const sourceOrigin =
|
|
129
|
+
const sourceOrigin = resolveSourceOrigin(request);
|
|
121
130
|
const fetchSite = request.headers.get("sec-fetch-site")?.trim().toLowerCase();
|
|
122
131
|
if (!sourceOrigin) {
|
|
123
132
|
if (fetchSite !== "same-origin") {
|
|
@@ -249,111 +258,18 @@ function getFallbackAbortController() {
|
|
|
249
258
|
return globalState[FALLBACK_ABORT_CONTROLLER_KEY];
|
|
250
259
|
}
|
|
251
260
|
__name(getFallbackAbortController, "getFallbackAbortController");
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
throw new
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
throw new TypeError(`Invalid serverActions.allowedOrigins pattern: ${JSON.stringify(value)}`);
|
|
260
|
-
}
|
|
261
|
-
return pattern;
|
|
262
|
-
}
|
|
263
|
-
if (pattern.includes("://")) {
|
|
264
|
-
let parsed;
|
|
265
|
-
try {
|
|
266
|
-
parsed = new URL(pattern);
|
|
267
|
-
} catch {
|
|
268
|
-
throw new TypeError(`Invalid serverActions.allowedOrigins value: ${JSON.stringify(value)}`);
|
|
269
|
-
}
|
|
270
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash) {
|
|
271
|
-
throw new TypeError(
|
|
272
|
-
`serverActions.allowedOrigins must contain origins without paths: ${JSON.stringify(value)}`
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
return parsed.origin;
|
|
276
|
-
}
|
|
277
|
-
if (/[/@?#]/.test(pattern)) {
|
|
278
|
-
throw new TypeError(
|
|
279
|
-
`serverActions.allowedOrigins must contain origins or hosts: ${JSON.stringify(value)}`
|
|
261
|
+
function resolveSourceOrigin(request) {
|
|
262
|
+
const result = getRequestSourceOrigin(request);
|
|
263
|
+
if (!result.ok) {
|
|
264
|
+
throw new ServerActionRequestError(
|
|
265
|
+
"INVALID_ORIGIN",
|
|
266
|
+
403,
|
|
267
|
+
result.reason === "opaque-origin" ? "Opaque origins are not allowed" : "Invalid request origin"
|
|
280
268
|
);
|
|
281
269
|
}
|
|
282
|
-
|
|
283
|
-
return new URL(`http://${pattern}`).host;
|
|
284
|
-
} catch {
|
|
285
|
-
throw new TypeError(`Invalid serverActions.allowedOrigins value: ${JSON.stringify(value)}`);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
__name(normalizeAllowedOriginPattern, "normalizeAllowedOriginPattern");
|
|
289
|
-
function getRequestSourceOrigin(request) {
|
|
290
|
-
const origin = request.headers.get("origin")?.trim();
|
|
291
|
-
if (origin) {
|
|
292
|
-
return parseSourceOrigin(origin);
|
|
293
|
-
}
|
|
294
|
-
const referer = request.headers.get("referer")?.trim();
|
|
295
|
-
if (referer) {
|
|
296
|
-
return parseSourceOrigin(referer);
|
|
297
|
-
}
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
__name(getRequestSourceOrigin, "getRequestSourceOrigin");
|
|
301
|
-
function parseSourceOrigin(value) {
|
|
302
|
-
if (value === "null") {
|
|
303
|
-
throw new ServerActionRequestError("INVALID_ORIGIN", 403, "Opaque origins are not allowed");
|
|
304
|
-
}
|
|
305
|
-
try {
|
|
306
|
-
const parsed = new URL(value);
|
|
307
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
308
|
-
throw new Error("Unsupported protocol");
|
|
309
|
-
}
|
|
310
|
-
return parsed.origin;
|
|
311
|
-
} catch {
|
|
312
|
-
throw new ServerActionRequestError("INVALID_ORIGIN", 403, "Invalid request origin");
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
__name(parseSourceOrigin, "parseSourceOrigin");
|
|
316
|
-
function matchesHostHeader(sourceOrigin, request) {
|
|
317
|
-
const host = request.headers.get("host")?.trim().toLowerCase();
|
|
318
|
-
if (!host) return false;
|
|
319
|
-
try {
|
|
320
|
-
const source = new URL(sourceOrigin);
|
|
321
|
-
const target = new URL(request.url);
|
|
322
|
-
return source.protocol === target.protocol && source.host.toLowerCase() === host;
|
|
323
|
-
} catch {
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
__name(matchesHostHeader, "matchesHostHeader");
|
|
328
|
-
function matchesAllowedOrigin(sourceOrigin, pattern) {
|
|
329
|
-
const source = new URL(sourceOrigin);
|
|
330
|
-
if (!pattern.includes("*")) {
|
|
331
|
-
return pattern.includes("://") ? source.origin === pattern : source.host === pattern;
|
|
332
|
-
}
|
|
333
|
-
const schemeEnd = pattern.indexOf("://");
|
|
334
|
-
const scheme = schemeEnd === -1 ? null : pattern.slice(0, schemeEnd + 1);
|
|
335
|
-
const hostPattern = pattern.slice(schemeEnd === -1 ? 0 : schemeEnd + 3);
|
|
336
|
-
const [wildcardHost, port] = splitHostAndPort(hostPattern);
|
|
337
|
-
const baseHost = wildcardHost.slice(2);
|
|
338
|
-
if (scheme && source.protocol !== scheme) return false;
|
|
339
|
-
if (port && getEffectivePort(source) !== port) return false;
|
|
340
|
-
if (!port && source.port) return false;
|
|
341
|
-
return source.hostname.endsWith(`.${baseHost}`) && source.hostname !== baseHost;
|
|
342
|
-
}
|
|
343
|
-
__name(matchesAllowedOrigin, "matchesAllowedOrigin");
|
|
344
|
-
function splitHostAndPort(value) {
|
|
345
|
-
const separator = value.lastIndexOf(":");
|
|
346
|
-
if (separator === -1) return [value, null];
|
|
347
|
-
return [value.slice(0, separator), value.slice(separator + 1)];
|
|
348
|
-
}
|
|
349
|
-
__name(splitHostAndPort, "splitHostAndPort");
|
|
350
|
-
function getEffectivePort(url) {
|
|
351
|
-
if (url.port) return url.port;
|
|
352
|
-
if (url.protocol === "https:") return "443";
|
|
353
|
-
if (url.protocol === "http:") return "80";
|
|
354
|
-
return "";
|
|
270
|
+
return result.origin;
|
|
355
271
|
}
|
|
356
|
-
__name(
|
|
272
|
+
__name(resolveSourceOrigin, "resolveSourceOrigin");
|
|
357
273
|
function validateActionId(actionId) {
|
|
358
274
|
if (!actionId || actionId.length > 4096 || hasControlCharacters(actionId)) {
|
|
359
275
|
throw new ServerActionRequestError("INVALID_ACTION_ID", 400, "Invalid server action id");
|
|
@@ -499,4 +415,4 @@ export {
|
|
|
499
415
|
getServerActionSignal,
|
|
500
416
|
getServerActionInvalidations
|
|
501
417
|
};
|
|
502
|
-
//# sourceMappingURL=chunk-
|
|
418
|
+
//# sourceMappingURL=chunk-XWM2C267.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server-action-security.ts","../src/server-fn-error.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { subscribeFarmCacheInvalidation, subscribeFarmCacheTask } from \"./cache-invalidation\";\nimport {\n getRequestSourceOrigin,\n matchesAllowedOrigin,\n matchesHostHeader,\n normalizeAllowedOriginPattern,\n} from \"./request-origin\";\nimport { serializeServerFnFailure, type SerializedServerFnFailure } from \"./server-fn-error\";\nimport { parseBodySizeLimit } from \"./server-http\";\n\nconst SERVER_ACTION_ALLOWED_ORIGINS_LABEL = \"serverActions.allowedOrigins\";\n\nexport const DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1_000_000;\n\nexport interface FarmServerActionsConfig {\n /** Additional trusted origins or host patterns, such as https://app.example.com. */\n allowedOrigins?: readonly string[];\n /** Maximum encoded request body size in bytes or as a size string such as \"1mb\". */\n bodySizeLimit?: number | string;\n}\n\nexport interface ResolvedFarmServerActionsConfig {\n allowedOrigins: readonly string[];\n bodySizeLimit: number;\n}\n\nexport type ServerActionRequestKind = \"javascript\" | \"form\";\n\nexport interface PreparedServerActionRequest {\n body: string | FormData;\n contentType: string;\n}\n\nexport type SanitizedServerActionError =\n | {\n name: \"ServerActionError\";\n message: \"Server function failed\";\n }\n | SerializedServerFnFailure;\n\ntype ServerActionRequestErrorCode =\n | \"BODY_TOO_LARGE\"\n | \"INVALID_ACTION_ID\"\n | \"INVALID_BODY\"\n | \"INVALID_CONTENT_LENGTH\"\n | \"INVALID_METHOD\"\n | \"INVALID_ORIGIN\"\n | \"MISSING_ORIGIN\"\n | \"UNSUPPORTED_CONTENT_TYPE\";\n\nexport class ServerActionRequestError extends Error {\n readonly code: ServerActionRequestErrorCode;\n readonly status: number;\n\n constructor(code: ServerActionRequestErrorCode, status: number, message: string) {\n super(message);\n this.name = \"ServerActionRequestError\";\n this.code = code;\n this.status = status;\n }\n}\n\ntype ServerActionExecutionContext = {\n request: Request;\n signal: AbortSignal;\n invalidations: Set<string>;\n cacheTasks: Set<Promise<void>>;\n};\n\nconst SERVER_ACTION_STORAGE_KEY = Symbol.for(\"farm.serverActionStorage\");\nconst FALLBACK_ABORT_CONTROLLER_KEY = Symbol.for(\"farm.serverActionFallbackAbortController\");\nconst FORM_ACTION_CONTENT_TYPES = new Set([\n \"application/x-www-form-urlencoded\",\n \"multipart/form-data\",\n]);\nconst JAVASCRIPT_ACTION_CONTENT_TYPES = new Set([\n \"application/octet-stream\",\n \"application/x-www-form-urlencoded\",\n \"multipart/form-data\",\n \"text/plain\",\n]);\n\ntype GlobalWithServerActionStorage = typeof globalThis & {\n [SERVER_ACTION_STORAGE_KEY]?: AsyncLocalStorage<ServerActionExecutionContext>;\n [FALLBACK_ABORT_CONTROLLER_KEY]?: AbortController;\n};\n\nexport function resolveServerActionsConfig(\n config: FarmServerActionsConfig | undefined,\n): ResolvedFarmServerActionsConfig {\n const allowedOrigins = (config?.allowedOrigins ?? []).map((value) =>\n normalizeAllowedOriginPattern(value, SERVER_ACTION_ALLOWED_ORIGINS_LABEL),\n );\n const bodySizeLimit = parseBodySizeLimit(\n config?.bodySizeLimit ?? DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT,\n \"serverActions.bodySizeLimit\",\n );\n\n return Object.freeze({\n allowedOrigins: Object.freeze(allowedOrigins),\n bodySizeLimit,\n });\n}\n\nexport function validateServerActionRequest(\n request: Request,\n config: ResolvedFarmServerActionsConfig,\n): void {\n if (request.method.toUpperCase() !== \"POST\") {\n throw new ServerActionRequestError(\n \"INVALID_METHOD\",\n 405,\n \"Server actions only accept POST requests\",\n );\n }\n\n const requestUrl = new URL(request.url);\n const sourceOrigin = resolveSourceOrigin(request);\n const fetchSite = request.headers.get(\"sec-fetch-site\")?.trim().toLowerCase();\n\n if (!sourceOrigin) {\n if (fetchSite !== \"same-origin\") {\n throw new ServerActionRequestError(\n \"MISSING_ORIGIN\",\n 403,\n \"Server action request is missing same-origin metadata\",\n );\n }\n return;\n }\n\n const matchesRequest =\n sourceOrigin === requestUrl.origin || matchesHostHeader(sourceOrigin, request);\n const matchesConfiguredOrigin = config.allowedOrigins.some((pattern) =>\n matchesAllowedOrigin(sourceOrigin, pattern),\n );\n\n if (!matchesRequest && !matchesConfiguredOrigin) {\n throw new ServerActionRequestError(\n \"INVALID_ORIGIN\",\n 403,\n \"Server action origin does not match the request origin\",\n );\n }\n\n if (fetchSite === \"cross-site\" && !matchesConfiguredOrigin) {\n throw new ServerActionRequestError(\n \"INVALID_ORIGIN\",\n 403,\n \"Cross-site server action request was rejected\",\n );\n }\n}\n\nexport async function prepareServerActionRequest(\n request: Request,\n config: ResolvedFarmServerActionsConfig,\n kind: ServerActionRequestKind,\n actionId?: string | null,\n): Promise<PreparedServerActionRequest> {\n validateServerActionRequest(request, config);\n\n if (kind === \"javascript\") {\n validateActionId(actionId);\n }\n\n const contentType = getSupportedContentType(request, kind);\n const bytes = await readBodyWithLimit(request, config.bodySizeLimit);\n\n if (kind === \"form\" || contentType === \"multipart/form-data\") {\n return {\n body: await parseFormData(request, bytes),\n contentType,\n };\n }\n\n return {\n body: new TextDecoder().decode(bytes),\n contentType,\n };\n}\n\nexport function createServerActionRequestErrorResponse(error: unknown): Response | null {\n if (!(error instanceof ServerActionRequestError)) {\n return null;\n }\n\n const headers = new Headers({\n \"cache-control\": \"no-store\",\n \"content-type\": \"text/plain; charset=utf-8\",\n \"x-content-type-options\": \"nosniff\",\n });\n if (error.status === 405) {\n headers.set(\"allow\", \"POST\");\n }\n\n return new Response(getPublicErrorMessage(error.status), {\n status: error.status,\n headers,\n });\n}\n\nexport function sanitizeServerActionError(error: unknown): SanitizedServerActionError {\n const declaredFailure = serializeServerFnFailure(error);\n if (declaredFailure) return declaredFailure;\n\n return {\n name: \"ServerActionError\",\n message: \"Server function failed\",\n };\n}\n\nexport async function runWithServerActionRequest<T>(\n request: Request,\n callback: () => T | Promise<T>,\n): Promise<T> {\n throwIfAborted(request.signal);\n const context: ServerActionExecutionContext = {\n request,\n signal: request.signal,\n invalidations: new Set(),\n cacheTasks: new Set(),\n };\n\n return getServerActionStorage().run(context, async () => {\n try {\n const result = await callback();\n await Promise.all(context.cacheTasks);\n return result;\n } catch (error) {\n await Promise.allSettled(context.cacheTasks);\n throw error;\n }\n });\n}\n\nexport function getServerActionExecutionContext(): ServerActionExecutionContext | undefined {\n return getServerActionStorage().getStore();\n}\n\nexport function getServerActionSignal(): AbortSignal {\n return getServerActionExecutionContext()?.signal ?? getFallbackAbortController().signal;\n}\n\nexport function getServerActionInvalidations(): readonly string[] {\n return Array.from(getServerActionExecutionContext()?.invalidations ?? []);\n}\n\nsubscribeFarmCacheInvalidation((key) => {\n getServerActionExecutionContext()?.invalidations.add(key);\n});\n\nsubscribeFarmCacheTask((task) => {\n getServerActionExecutionContext()?.cacheTasks.add(task);\n});\n\nfunction getServerActionStorage(): AsyncLocalStorage<ServerActionExecutionContext> {\n const globalState = globalThis as GlobalWithServerActionStorage;\n if (!globalState[SERVER_ACTION_STORAGE_KEY]) {\n globalState[SERVER_ACTION_STORAGE_KEY] = new AsyncLocalStorage<ServerActionExecutionContext>();\n }\n return globalState[SERVER_ACTION_STORAGE_KEY]!;\n}\n\nfunction getFallbackAbortController(): AbortController {\n const globalState = globalThis as GlobalWithServerActionStorage;\n if (!globalState[FALLBACK_ABORT_CONTROLLER_KEY]) {\n globalState[FALLBACK_ABORT_CONTROLLER_KEY] = new AbortController();\n }\n return globalState[FALLBACK_ABORT_CONTROLLER_KEY]!;\n}\n\n/**\n * Adapt the shared origin resolution onto the server-action error contract:\n * an unusable Origin/Referer is a 403 here, while a request that simply\n * carried neither header returns null for the caller to judge.\n */\nfunction resolveSourceOrigin(request: Request): string | null {\n const result = getRequestSourceOrigin(request);\n\n if (!result.ok) {\n throw new ServerActionRequestError(\n \"INVALID_ORIGIN\",\n 403,\n result.reason === \"opaque-origin\"\n ? \"Opaque origins are not allowed\"\n : \"Invalid request origin\",\n );\n }\n\n return result.origin;\n}\n\nfunction validateActionId(actionId?: string | null): asserts actionId is string {\n if (!actionId || actionId.length > 4096 || hasControlCharacters(actionId)) {\n throw new ServerActionRequestError(\"INVALID_ACTION_ID\", 400, \"Invalid server action id\");\n }\n}\n\nfunction hasControlCharacters(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index);\n if (code <= 31 || code === 127) return true;\n }\n return false;\n}\n\nfunction getSupportedContentType(request: Request, kind: ServerActionRequestKind): string {\n const header = request.headers.get(\"content-type\")?.trim().toLowerCase();\n const contentType = header?.split(\";\", 1)[0]?.trim() ?? \"\";\n const supported = kind === \"form\" ? FORM_ACTION_CONTENT_TYPES : JAVASCRIPT_ACTION_CONTENT_TYPES;\n\n if (!supported.has(contentType)) {\n throw new ServerActionRequestError(\n \"UNSUPPORTED_CONTENT_TYPE\",\n 415,\n \"Unsupported server action content type\",\n );\n }\n\n return contentType;\n}\n\nasync function readBodyWithLimit(request: Request, limit: number): Promise<Uint8Array> {\n const contentLength = request.headers.get(\"content-length\")?.trim();\n if (contentLength) {\n if (!/^\\d+$/.test(contentLength)) {\n throw new ServerActionRequestError(\n \"INVALID_CONTENT_LENGTH\",\n 400,\n \"Invalid content-length header\",\n );\n }\n if (Number(contentLength) > limit) {\n throw new ServerActionRequestError(\"BODY_TOO_LARGE\", 413, \"Server action body is too large\");\n }\n }\n\n throwIfAborted(request.signal);\n if (!request.body) return new Uint8Array();\n\n const reader = request.body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n const cancelBodyRead = () => {\n void reader.cancel(request.signal.reason).catch(() => {});\n };\n\n request.signal.addEventListener(\"abort\", cancelBodyRead, { once: true });\n\n try {\n while (true) {\n throwIfAborted(request.signal);\n const { done, value } = await reader.read();\n if (done) break;\n if (!value) continue;\n\n total += value.byteLength;\n if (total > limit) {\n const error = new ServerActionRequestError(\n \"BODY_TOO_LARGE\",\n 413,\n \"Server action body is too large\",\n );\n // As with API bodies, a cloned stream may wait for its untouched tee\n // branch. Cleanup must neither delay rejection nor replace its error.\n void reader.cancel(error).catch(() => {});\n throw error;\n }\n chunks.push(value);\n }\n } catch (error) {\n if (request.signal.aborted) throwIfAborted(request.signal);\n throw error;\n } finally {\n request.signal.removeEventListener(\"abort\", cancelBodyRead);\n reader.releaseLock();\n }\n\n throwIfAborted(request.signal);\n const body = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n body.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return body;\n}\n\nasync function parseFormData(request: Request, bytes: Uint8Array): Promise<FormData> {\n const body = new ArrayBuffer(bytes.byteLength);\n new Uint8Array(body).set(bytes);\n const copy = new Request(request.url, {\n method: \"POST\",\n headers: request.headers,\n body,\n });\n\n try {\n return await copy.formData();\n } catch {\n throw new ServerActionRequestError(\"INVALID_BODY\", 400, \"Invalid server action form body\");\n }\n}\n\nfunction getPublicErrorMessage(status: number): string {\n switch (status) {\n case 400:\n return \"Bad Request\";\n case 403:\n return \"Forbidden\";\n case 405:\n return \"Method Not Allowed\";\n case 413:\n return \"Payload Too Large\";\n case 415:\n return \"Unsupported Media Type\";\n default:\n return \"Server Action Request Failed\";\n }\n}\n\nfunction throwIfAborted(signal: AbortSignal): void {\n if (!signal.aborted) return;\n if (signal.reason !== undefined) throw signal.reason;\n throw new DOMException(\"The operation was aborted\", \"AbortError\");\n}\n","export const FARM_SERVER_FN_FAILURE_SYMBOL = Symbol.for(\"farm.server-fn.failure\");\n\nexport type SerializedServerFnFailure = {\n name: \"ServerFnFailure\";\n message: string;\n code: string;\n status: number;\n data: unknown;\n};\n\nexport class ServerFnFailure<\n TCode extends string = string,\n TData = unknown,\n TStatus extends number = number,\n> extends Error {\n readonly name = \"ServerFnFailure\" as const;\n readonly code: TCode;\n readonly data: TData;\n readonly status: TStatus;\n\n constructor(\n code: TCode,\n data: TData,\n options: {\n status: TStatus;\n message: string;\n },\n ) {\n super(options.message);\n this.code = code;\n this.data = data;\n this.status = options.status;\n\n Object.defineProperty(this, FARM_SERVER_FN_FAILURE_SYMBOL, {\n value: true,\n enumerable: false,\n });\n }\n}\n\nexport class ServerActionError extends Error {\n readonly name = \"ServerActionError\" as const;\n\n constructor(message = \"Server function failed\") {\n super(message);\n }\n}\n\nexport function isServerFnFailure(value: unknown): value is ServerFnFailure {\n if (!value || typeof value !== \"object\") return false;\n\n const candidate = value as Partial<ServerFnFailure> & {\n [FARM_SERVER_FN_FAILURE_SYMBOL]?: unknown;\n };\n return (\n candidate[FARM_SERVER_FN_FAILURE_SYMBOL] === true &&\n candidate.name === \"ServerFnFailure\" &&\n typeof candidate.code === \"string\" &&\n Number.isInteger(candidate.status) &&\n (candidate.status ?? 0) >= 400 &&\n (candidate.status ?? 0) <= 599\n );\n}\n\nexport function serializeServerFnFailure(value: unknown): SerializedServerFnFailure | null {\n if (!isServerFnFailure(value)) return null;\n\n return {\n name: \"ServerFnFailure\",\n message: value.message,\n code: value.code,\n status: value.status,\n data: value.data,\n };\n}\n\nexport function createServerFnTransportError(value: unknown): ServerFnFailure | ServerActionError {\n if (isSerializedServerFnFailure(value)) {\n return new ServerFnFailure(value.code, value.data, {\n status: value.status,\n message: value.message,\n });\n }\n\n const message =\n value && typeof value === \"object\" && \"message\" in value && typeof value.message === \"string\"\n ? value.message\n : \"Server function failed\";\n return new ServerActionError(message);\n}\n\nfunction isSerializedServerFnFailure(value: unknown): value is SerializedServerFnFailure {\n if (!value || typeof value !== \"object\") return false;\n\n const candidate = value as Partial<SerializedServerFnFailure>;\n return (\n candidate.name === \"ServerFnFailure\" &&\n typeof candidate.message === \"string\" &&\n typeof candidate.code === \"string\" &&\n Number.isInteger(candidate.status) &&\n (candidate.status ?? 0) >= 400 &&\n (candidate.status ?? 0) <= 599 &&\n \"data\" in candidate\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;;;ACA3B,IAAM,gCAAgC,uBAAO,IAAI,wBAAwB;AAUzE,IAAM,mBAAN,MAAM,yBAIH,MAAM;AAAA,EAMd,YACE,MACA,MACA,SAIA;AACA,UAAM,QAAQ,OAAO;AAbvB,SAAS,OAAO;AAcd,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS,QAAQ;AAEtB,WAAO,eAAe,MAAM,+BAA+B;AAAA,MACzD,OAAO;AAAA,MACP,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AACF;AAxBgB;AAJT,IAAM,kBAAN;AA8BA,IAAM,qBAAN,MAAM,2BAA0B,MAAM;AAAA,EAG3C,YAAY,UAAU,0BAA0B;AAC9C,UAAM,OAAO;AAHf,SAAS,OAAO;AAAA,EAIhB;AACF;AAN6C;AAAtC,IAAM,oBAAN;AAQA,SAAS,kBAAkB,OAA0C;AAC1E,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAEhD,QAAM,YAAY;AAGlB,SACE,UAAU,6BAA6B,MAAM,QAC7C,UAAU,SAAS,qBACnB,OAAO,UAAU,SAAS,YAC1B,OAAO,UAAU,UAAU,MAAM,MAChC,UAAU,UAAU,MAAM,QAC1B,UAAU,UAAU,MAAM;AAE/B;AAdgB;AAgBT,SAAS,yBAAyB,OAAkD;AACzF,MAAI,CAAC,kBAAkB,KAAK,EAAG,QAAO;AAEtC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,MAAM;AAAA,IACf,MAAM,MAAM;AAAA,IACZ,QAAQ,MAAM;AAAA,IACd,MAAM,MAAM;AAAA,EACd;AACF;AAVgB;AAYT,SAAS,6BAA6B,OAAqD;AAChG,MAAI,4BAA4B,KAAK,GAAG;AACtC,WAAO,IAAI,gBAAgB,MAAM,MAAM,MAAM,MAAM;AAAA,MACjD,QAAQ,MAAM;AAAA,MACd,SAAS,MAAM;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,QAAM,UACJ,SAAS,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY,WACjF,MAAM,UACN;AACN,SAAO,IAAI,kBAAkB,OAAO;AACtC;AAbgB;AAehB,SAAS,4BAA4B,OAAoD;AACvF,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAEhD,QAAM,YAAY;AAClB,SACE,UAAU,SAAS,qBACnB,OAAO,UAAU,YAAY,YAC7B,OAAO,UAAU,SAAS,YAC1B,OAAO,UAAU,UAAU,MAAM,MAChC,UAAU,UAAU,MAAM,QAC1B,UAAU,UAAU,MAAM,OAC3B,UAAU;AAEd;AAbS;;;ADhFT,IAAM,sCAAsC;AAErC,IAAM,wCAAwC;AAsC9C,IAAM,4BAAN,MAAM,kCAAiC,MAAM;AAAA,EAIlD,YAAY,MAAoC,QAAgB,SAAiB;AAC/E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAVoD;AAA7C,IAAM,2BAAN;AAmBP,IAAM,4BAA4B,uBAAO,IAAI,0BAA0B;AACvE,IAAM,gCAAgC,uBAAO,IAAI,0CAA0C;AAC3F,IAAM,4BAA4B,oBAAI,IAAI;AAAA,EACxC;AAAA,EACA;AACF,CAAC;AACD,IAAM,kCAAkC,oBAAI,IAAI;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOM,SAAS,2BACd,QACiC;AACjC,QAAM,kBAAkB,QAAQ,kBAAkB,CAAC,GAAG;AAAA,IAAI,CAAC,UACzD,8BAA8B,OAAO,mCAAmC;AAAA,EAC1E;AACA,QAAM,gBAAgB;AAAA,IACpB,QAAQ,iBAAiB;AAAA,IACzB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO;AAAA,IACnB,gBAAgB,OAAO,OAAO,cAAc;AAAA,IAC5C;AAAA,EACF,CAAC;AACH;AAfgB;AAiBT,SAAS,4BACd,SACA,QACM;AACN,MAAI,QAAQ,OAAO,YAAY,MAAM,QAAQ;AAC3C,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa,IAAI,IAAI,QAAQ,GAAG;AACtC,QAAM,eAAe,oBAAoB,OAAO;AAChD,QAAM,YAAY,QAAQ,QAAQ,IAAI,gBAAgB,GAAG,KAAK,EAAE,YAAY;AAE5E,MAAI,CAAC,cAAc;AACjB,QAAI,cAAc,eAAe;AAC/B,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA;AAAA,EACF;AAEA,QAAM,iBACJ,iBAAiB,WAAW,UAAU,kBAAkB,cAAc,OAAO;AAC/E,QAAM,0BAA0B,OAAO,eAAe;AAAA,IAAK,CAAC,YAC1D,qBAAqB,cAAc,OAAO;AAAA,EAC5C;AAEA,MAAI,CAAC,kBAAkB,CAAC,yBAAyB;AAC/C,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,cAAc,gBAAgB,CAAC,yBAAyB;AAC1D,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAhDgB;AAkDhB,eAAsB,2BACpB,SACA,QACA,MACA,UACsC;AACtC,8BAA4B,SAAS,MAAM;AAE3C,MAAI,SAAS,cAAc;AACzB,qBAAiB,QAAQ;AAAA,EAC3B;AAEA,QAAM,cAAc,wBAAwB,SAAS,IAAI;AACzD,QAAM,QAAQ,MAAM,kBAAkB,SAAS,OAAO,aAAa;AAEnE,MAAI,SAAS,UAAU,gBAAgB,uBAAuB;AAC5D,WAAO;AAAA,MACL,MAAM,MAAM,cAAc,SAAS,KAAK;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,IACpC;AAAA,EACF;AACF;AA1BsB;AA4Bf,SAAS,uCAAuC,OAAiC;AACtF,MAAI,EAAE,iBAAiB,2BAA2B;AAChD,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,IAAI,QAAQ;AAAA,IAC1B,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,0BAA0B;AAAA,EAC5B,CAAC;AACD,MAAI,MAAM,WAAW,KAAK;AACxB,YAAQ,IAAI,SAAS,MAAM;AAAA,EAC7B;AAEA,SAAO,IAAI,SAAS,sBAAsB,MAAM,MAAM,GAAG;AAAA,IACvD,QAAQ,MAAM;AAAA,IACd;AAAA,EACF,CAAC;AACH;AAlBgB;AAoBT,SAAS,0BAA0B,OAA4C;AACpF,QAAM,kBAAkB,yBAAyB,KAAK;AACtD,MAAI,gBAAiB,QAAO;AAE5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;AARgB;AAUhB,eAAsB,2BACpB,SACA,UACY;AACZ,iBAAe,QAAQ,MAAM;AAC7B,QAAM,UAAwC;AAAA,IAC5C;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB,eAAe,oBAAI,IAAI;AAAA,IACvB,YAAY,oBAAI,IAAI;AAAA,EACtB;AAEA,SAAO,uBAAuB,EAAE,IAAI,SAAS,YAAY;AACvD,QAAI;AACF,YAAM,SAAS,MAAM,SAAS;AAC9B,YAAM,QAAQ,IAAI,QAAQ,UAAU;AACpC,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,QAAQ,WAAW,QAAQ,UAAU;AAC3C,YAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;AAtBsB;AAwBf,SAAS,kCAA4E;AAC1F,SAAO,uBAAuB,EAAE,SAAS;AAC3C;AAFgB;AAIT,SAAS,wBAAqC;AACnD,SAAO,gCAAgC,GAAG,UAAU,2BAA2B,EAAE;AACnF;AAFgB;AAIT,SAAS,+BAAkD;AAChE,SAAO,MAAM,KAAK,gCAAgC,GAAG,iBAAiB,CAAC,CAAC;AAC1E;AAFgB;AAIhB,+BAA+B,CAAC,QAAQ;AACtC,kCAAgC,GAAG,cAAc,IAAI,GAAG;AAC1D,CAAC;AAED,uBAAuB,CAAC,SAAS;AAC/B,kCAAgC,GAAG,WAAW,IAAI,IAAI;AACxD,CAAC;AAED,SAAS,yBAA0E;AACjF,QAAM,cAAc;AACpB,MAAI,CAAC,YAAY,yBAAyB,GAAG;AAC3C,gBAAY,yBAAyB,IAAI,IAAI,kBAAgD;AAAA,EAC/F;AACA,SAAO,YAAY,yBAAyB;AAC9C;AANS;AAQT,SAAS,6BAA8C;AACrD,QAAM,cAAc;AACpB,MAAI,CAAC,YAAY,6BAA6B,GAAG;AAC/C,gBAAY,6BAA6B,IAAI,IAAI,gBAAgB;AAAA,EACnE;AACA,SAAO,YAAY,6BAA6B;AAClD;AANS;AAaT,SAAS,oBAAoB,SAAiC;AAC5D,QAAM,SAAS,uBAAuB,OAAO;AAE7C,MAAI,CAAC,OAAO,IAAI;AACd,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA,OAAO,WAAW,kBACd,mCACA;AAAA,IACN;AAAA,EACF;AAEA,SAAO,OAAO;AAChB;AAdS;AAgBT,SAAS,iBAAiB,UAAsD;AAC9E,MAAI,CAAC,YAAY,SAAS,SAAS,QAAQ,qBAAqB,QAAQ,GAAG;AACzE,UAAM,IAAI,yBAAyB,qBAAqB,KAAK,0BAA0B;AAAA,EACzF;AACF;AAJS;AAMT,SAAS,qBAAqB,OAAwB;AACpD,WAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,UAAM,OAAO,MAAM,WAAW,KAAK;AACnC,QAAI,QAAQ,MAAM,SAAS,IAAK,QAAO;AAAA,EACzC;AACA,SAAO;AACT;AANS;AAQT,SAAS,wBAAwB,SAAkB,MAAuC;AACxF,QAAM,SAAS,QAAQ,QAAQ,IAAI,cAAc,GAAG,KAAK,EAAE,YAAY;AACvE,QAAM,cAAc,QAAQ,MAAM,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,KAAK;AACxD,QAAM,YAAY,SAAS,SAAS,4BAA4B;AAEhE,MAAI,CAAC,UAAU,IAAI,WAAW,GAAG;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAdS;AAgBT,eAAe,kBAAkB,SAAkB,OAAoC;AACrF,QAAM,gBAAgB,QAAQ,QAAQ,IAAI,gBAAgB,GAAG,KAAK;AAClE,MAAI,eAAe;AACjB,QAAI,CAAC,QAAQ,KAAK,aAAa,GAAG;AAChC,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,QAAI,OAAO,aAAa,IAAI,OAAO;AACjC,YAAM,IAAI,yBAAyB,kBAAkB,KAAK,iCAAiC;AAAA,IAC7F;AAAA,EACF;AAEA,iBAAe,QAAQ,MAAM;AAC7B,MAAI,CAAC,QAAQ,KAAM,QAAO,IAAI,WAAW;AAEzC,QAAM,SAAS,QAAQ,KAAK,UAAU;AACtC,QAAM,SAAuB,CAAC;AAC9B,MAAI,QAAQ;AACZ,QAAM,iBAAiB,6BAAM;AAC3B,SAAK,OAAO,OAAO,QAAQ,OAAO,MAAM,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EAC1D,GAFuB;AAIvB,UAAQ,OAAO,iBAAiB,SAAS,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAEvE,MAAI;AACF,WAAO,MAAM;AACX,qBAAe,QAAQ,MAAM;AAC7B,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,UAAI,KAAM;AACV,UAAI,CAAC,MAAO;AAEZ,eAAS,MAAM;AACf,UAAI,QAAQ,OAAO;AACjB,cAAM,QAAQ,IAAI;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAGA,aAAK,OAAO,OAAO,KAAK,EAAE,MAAM,MAAM;AAAA,QAAC,CAAC;AACxC,cAAM;AAAA,MACR;AACA,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,QAAI,QAAQ,OAAO,QAAS,gBAAe,QAAQ,MAAM;AACzD,UAAM;AAAA,EACR,UAAE;AACA,YAAQ,OAAO,oBAAoB,SAAS,cAAc;AAC1D,WAAO,YAAY;AAAA,EACrB;AAEA,iBAAe,QAAQ,MAAM;AAC7B,QAAM,OAAO,IAAI,WAAW,KAAK;AACjC,MAAI,SAAS;AACb,aAAW,SAAS,QAAQ;AAC1B,SAAK,IAAI,OAAO,MAAM;AACtB,cAAU,MAAM;AAAA,EAClB;AACA,SAAO;AACT;AAhEe;AAkEf,eAAe,cAAc,SAAkB,OAAsC;AACnF,QAAM,OAAO,IAAI,YAAY,MAAM,UAAU;AAC7C,MAAI,WAAW,IAAI,EAAE,IAAI,KAAK;AAC9B,QAAM,OAAO,IAAI,QAAQ,QAAQ,KAAK;AAAA,IACpC,QAAQ;AAAA,IACR,SAAS,QAAQ;AAAA,IACjB;AAAA,EACF,CAAC;AAED,MAAI;AACF,WAAO,MAAM,KAAK,SAAS;AAAA,EAC7B,QAAQ;AACN,UAAM,IAAI,yBAAyB,gBAAgB,KAAK,iCAAiC;AAAA,EAC3F;AACF;AAde;AAgBf,SAAS,sBAAsB,QAAwB;AACrD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAfS;AAiBT,SAAS,eAAe,QAA2B;AACjD,MAAI,CAAC,OAAO,QAAS;AACrB,MAAI,OAAO,WAAW,OAAW,OAAM,OAAO;AAC9C,QAAM,IAAI,aAAa,6BAA6B,YAAY;AAClE;AAJS;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/lifecycle.ts","../../src/client/runtime-error-overlay.ts","../../src/client/plugin.ts"],"sourcesContent":["\"use client\";\n\nexport { defineClient } from \"./plugin\";\nexport type {\n FarmClientNavigationAction,\n FarmClientNavigationErrorEvent,\n FarmClientNavigationEvent,\n FarmClientNavigationLoadedEvent,\n FarmClientNavigationResolvedEvent,\n FarmClientNavigationSession,\n FarmClientPlugin,\n FarmClientPluginCloseEvent,\n FarmClientPluginRouter,\n FarmClientPluginSetupEvent,\n FarmClientPluginStateEvent,\n} from \"./plugin\";\n","\"use client\";\n\nimport {\n originalPositionFor,\n sourceContentFor,\n TraceMap,\n type SourceMapInput,\n} from \"@jridgewell/trace-mapping\";\nimport { DEFAULT_ERROR_STYLES } from \"../components/error-styles\";\nimport { FARM_VERSION } from \"../version\";\nimport { isChunkLoadError } from \"./chunk-recovery\";\n\nexport interface FarmRuntimeErrorLocation {\n href: string;\n pathname: string;\n search: string;\n hash: string;\n}\n\nexport interface FarmRuntimeErrorOverlayContext {\n phase: string;\n location: FarmRuntimeErrorLocation;\n sourceEvent?: Event;\n}\n\nexport interface FarmRuntimeErrorOverlayOptions {\n window: Window;\n farmVersion?: string;\n reload?: () => void;\n fetch?: typeof fetch;\n}\n\nexport interface FarmRuntimeErrorOverlay {\n show(error: unknown, context: FarmRuntimeErrorOverlayContext): void;\n dismiss(): void;\n destroy(): void;\n}\n\ninterface NormalizedRuntimeError {\n name: string;\n message: string;\n stack?: string;\n}\n\ninterface BrowserSourceLocation {\n url: string;\n displayPath: string;\n line: number;\n column: number;\n stackLine?: string;\n}\n\ninterface BrowserSourceLine {\n number?: number;\n content: string;\n highlight?: boolean;\n}\n\ninterface BrowserSourceFrame {\n path: string;\n line?: number;\n column?: number;\n lines: BrowserSourceLine[];\n unavailable?: boolean;\n}\n\ninterface RuntimeErrorRecord {\n error: NormalizedRuntimeError;\n context: FarmRuntimeErrorOverlayContext;\n fingerprint: string;\n occurrences: number;\n sourceLocation?: BrowserSourceLocation;\n sourceFrame: BrowserSourceFrame;\n}\n\nconst OVERLAY_STYLES = `\n:host {\n position: fixed;\n inset: 0;\n z-index: 2147483647;\n display: block;\n width: 100%;\n height: 100%;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.farm-runtime-error__viewport {\n width: 100%;\n height: 100%;\n overflow: auto;\n overscroll-behavior: contain;\n}\n\n.farm-runtime-error__viewport .farm-default-error {\n min-height: 100%;\n padding: clamp(22px, 4vh, 36px) 24px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__code {\n font-size: clamp(96px, 10vw, 120px);\n line-height: 0.92;\n}\n\n.farm-runtime-error__viewport .farm-default-error__eyebrow {\n margin-top: 22px;\n margin-bottom: 18px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__summary {\n margin-bottom: 20px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__row {\n min-height: 48px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__details {\n padding-top: 16px;\n padding-bottom: 14px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__details-header {\n margin-bottom: 8px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__source-path {\n padding-top: 9px;\n padding-bottom: 9px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__source-code {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__meta {\n margin-top: 10px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__actions {\n margin-top: 20px;\n}\n\n.farm-runtime-error__occurrences {\n display: inline-flex;\n align-items: center;\n min-height: 24px;\n margin-right: auto;\n padding: 0 8px;\n border: 1px solid var(--farm-error-line);\n color: var(--farm-error-muted);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n}\n\n.farm-runtime-error__occurrences[hidden],\n.farm-runtime-error__action[hidden] {\n display: none;\n}\n\n.farm-runtime-error__copy {\n min-width: 166px;\n}\n\n.farm-runtime-error__action:focus {\n outline: 1px solid var(--farm-error-fg);\n outline-offset: 2px;\n}\n\n.farm-runtime-error__viewport .farm-default-error__panel {\n border: 0;\n box-shadow: inset 0 0 0 0.5px var(--farm-error-line-strong);\n}\n\n.farm-runtime-error__github-icon {\n display: block;\n width: 18px;\n height: 18px;\n flex: 0 0 auto;\n margin-right: 10px;\n color: currentColor;\n}\n\n.farm-runtime-error__message-value {\n font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n}\n\n.farm-runtime-error__inline-code {\n color: var(--farm-error-source-marker);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 0.94em;\n font-weight: 600;\n line-height: inherit;\n overflow-wrap: anywhere;\n}\n\n@media (max-width: 620px) {\n .farm-runtime-error__occurrences {\n margin-right: 0;\n }\n\n .farm-runtime-error__viewport .farm-default-error__content,\n .farm-runtime-error__viewport .farm-default-error__panel,\n .farm-runtime-error__viewport .farm-default-error__details,\n .farm-runtime-error__viewport .farm-default-error__source,\n .farm-runtime-error__viewport .farm-default-error__actions {\n min-width: 0;\n max-width: 100%;\n }\n\n .farm-runtime-error__viewport .farm-default-error__actions {\n width: 100%;\n }\n\n .farm-runtime-error__viewport .farm-default-error__action {\n min-width: 0;\n }\n\n .farm-runtime-error__viewport .farm-default-error__code {\n font-size: 80px;\n }\n}\n\n@media (max-height: 760px) {\n .farm-runtime-error__viewport .farm-default-error {\n place-items: start center;\n padding-top: 12px;\n padding-bottom: 12px;\n }\n\n .farm-runtime-error__viewport .farm-default-error__code {\n font-size: 88px;\n }\n\n .farm-runtime-error__viewport .farm-default-error__eyebrow {\n margin-top: 14px;\n margin-bottom: 12px;\n }\n\n .farm-runtime-error__viewport .farm-default-error__summary {\n margin-bottom: 14px;\n }\n\n .farm-runtime-error__viewport .farm-default-error__row {\n min-height: 42px;\n }\n\n .farm-runtime-error__viewport .farm-default-error__details {\n padding-top: 12px;\n padding-bottom: 10px;\n }\n\n .farm-runtime-error__viewport .farm-default-error__actions {\n margin-top: 10px;\n }\n}\n`;\n\nconst OVERLAY_MARKUP = `\n<div class=\"farm-runtime-error__viewport\" data-farm-runtime-error-viewport>\n <main class=\"farm-default-error\" data-farm-runtime-error role=\"alertdialog\" aria-modal=\"true\" aria-labelledby=\"farm-runtime-error-title\" aria-describedby=\"farm-runtime-error-description\">\n <div class=\"farm-default-error__content\">\n <p class=\"farm-default-error__code\" aria-hidden=\"true\">500</p>\n <p class=\"farm-default-error__eyebrow\">Runtime error</p>\n <header class=\"farm-default-error__summary\">\n <h1 id=\"farm-runtime-error-title\" class=\"farm-default-error__title\">Application failed in the browser</h1>\n </header>\n <section class=\"farm-default-error__panel\" aria-label=\"Error information\">\n <div class=\"farm-default-error__row\">\n <span class=\"farm-default-error__label\">Error type</span>\n <span class=\"farm-default-error__value\" data-farm-runtime-error-type></span>\n </div>\n <div class=\"farm-default-error__row\">\n <span class=\"farm-default-error__label\">Error message</span>\n <span id=\"farm-runtime-error-description\" class=\"farm-default-error__value farm-runtime-error__message-value\" data-farm-runtime-error-message></span>\n </div>\n <div class=\"farm-default-error__row\">\n <span class=\"farm-default-error__label\">Location</span>\n <span class=\"farm-default-error__value\" data-farm-runtime-error-location></span>\n </div>\n <section class=\"farm-default-error__details\" aria-labelledby=\"farm-runtime-error-details-title\">\n <div class=\"farm-default-error__details-header\">\n <h2 id=\"farm-runtime-error-details-title\" class=\"farm-default-error__details-title\">Details</h2>\n <span class=\"farm-runtime-error__occurrences\" data-farm-runtime-error-occurrences hidden></span>\n <button class=\"farm-default-error__copy farm-runtime-error__copy\" type=\"button\" data-farm-runtime-error-copy>\n <span data-farm-runtime-error-copy-label>Copy debug report</span>\n <span class=\"farm-default-error__sr-only\" aria-live=\"polite\" data-farm-runtime-error-copy-status></span>\n </button>\n </div>\n <div data-farm-runtime-error-source></div>\n <p class=\"farm-default-error__meta\" data-farm-runtime-error-meta></p>\n </section>\n </section>\n <div class=\"farm-default-error__actions\">\n <a class=\"farm-default-error__action farm-default-error__action--primary farm-runtime-error__action\" data-farm-runtime-error-issue target=\"_blank\" rel=\"noopener noreferrer\"><svg class=\"farm-runtime-error__github-icon\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M12 .7a11.5 11.5 0 0 0-3.64 22.41c.58.1.79-.25.79-.56v-2.23c-3.22.7-3.9-1.37-3.9-1.37-.52-1.34-1.28-1.69-1.28-1.69-1.05-.72.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.7 1.26 3.36.96.1-.75.4-1.26.73-1.55-2.57-.29-5.27-1.29-5.27-5.68 0-1.26.45-2.28 1.18-3.09-.12-.29-.51-1.47.11-3.05 0 0 .96-.31 3.16 1.18A10.95 10.95 0 0 1 12 6.1c.98 0 1.95.13 2.87.39 2.2-1.49 3.16-1.18 3.16-1.18.62 1.58.23 2.76.11 3.05.74.81 1.18 1.83 1.18 3.09 0 4.4-2.71 5.38-5.29 5.67.42.36.79 1.07.79 2.16v3.27c0 .31.21.67.8.56A11.5 11.5 0 0 0 12 .7Z\" /></svg><span>Open GitHub issue</span></a>\n <button class=\"farm-default-error__action farm-runtime-error__action\" type=\"button\" data-farm-runtime-error-reload>Reload page</button>\n <button class=\"farm-default-error__action farm-runtime-error__action\" type=\"button\" data-farm-runtime-error-dismiss>Dismiss</button>\n </div>\n </div>\n </main>\n</div>\n`;\n\nclass DefaultFarmRuntimeErrorOverlay implements FarmRuntimeErrorOverlay {\n private readonly options: FarmRuntimeErrorOverlayOptions;\n private readonly document: Document;\n private readonly host: HTMLDivElement;\n private readonly shadow: ShadowRoot;\n private readonly dismissedFingerprints = new Set<string>();\n private readonly themeObserver: MutationObserver;\n private readonly colorSchemeQuery?: MediaQueryList;\n private current?: RuntimeErrorRecord;\n private previousFocus?: Element | null;\n private renderSequence = 0;\n private copyResetTimer?: number;\n private destroyed = false;\n\n constructor(options: FarmRuntimeErrorOverlayOptions) {\n this.options = options;\n this.document = options.window.document;\n this.host = this.document.createElement(\"div\");\n this.host.dataset.farmRuntimeErrorOverlay = \"\";\n this.host.hidden = true;\n this.shadow = this.host.attachShadow({ mode: \"open\" });\n this.shadow.innerHTML = `<style>${DEFAULT_ERROR_STYLES}${OVERLAY_STYLES}</style>${OVERLAY_MARKUP}`;\n\n this.getElement<HTMLButtonElement>(\"[data-farm-runtime-error-reload]\").addEventListener(\n \"click\",\n this.handleReload,\n );\n this.getElement<HTMLButtonElement>(\"[data-farm-runtime-error-dismiss]\").addEventListener(\n \"click\",\n this.handleDismiss,\n );\n this.getElement<HTMLButtonElement>(\"[data-farm-runtime-error-copy]\").addEventListener(\n \"click\",\n this.handleCopy,\n );\n this.shadow.addEventListener(\"keydown\", this.handleKeyDown);\n\n this.themeObserver = new MutationObserver(this.updateTheme);\n this.themeObserver.observe(this.document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\", \"data-theme\", \"data-color-scheme\", \"style\"],\n });\n if (this.document.body) {\n this.themeObserver.observe(this.document.body, {\n attributes: true,\n attributeFilter: [\"class\", \"data-theme\", \"data-color-scheme\", \"style\"],\n });\n }\n\n this.colorSchemeQuery = options.window.matchMedia?.(\"(prefers-color-scheme: dark)\");\n this.colorSchemeQuery?.addEventListener?.(\"change\", this.updateTheme);\n this.updateTheme();\n }\n\n show(errorLike: unknown, context: FarmRuntimeErrorOverlayContext): void {\n if (this.destroyed || isChunkLoadError(errorLike) || isChunkLoadError(context.sourceEvent)) {\n return;\n }\n\n const error = normalizeRuntimeError(errorLike);\n const sourceLocation = resolveBrowserSourceLocation(\n error,\n context.sourceEvent,\n this.options.window,\n );\n if (sourceLocation && isBrowserExtensionUrl(sourceLocation.url)) return;\n if (isRecoverableReactHydrationError(error, context, sourceLocation)) return;\n\n const fingerprint = createErrorFingerprint(error, context, sourceLocation);\n if (this.dismissedFingerprints.has(fingerprint)) return;\n\n if (this.current?.fingerprint === fingerprint) {\n this.current.occurrences += 1;\n this.renderOccurrences(this.current.occurrences);\n return;\n }\n\n const record: RuntimeErrorRecord = {\n error,\n context,\n fingerprint,\n occurrences: 1,\n sourceLocation,\n sourceFrame: createFallbackSourceFrame(error, sourceLocation),\n };\n this.current = record;\n const sequence = ++this.renderSequence;\n this.render(record);\n this.mount();\n\n if (sourceLocation) {\n void loadBrowserSourceFrame(sourceLocation, this.options)\n .then((sourceFrame) => {\n if (\n !sourceFrame ||\n this.destroyed ||\n sequence !== this.renderSequence ||\n this.current !== record\n ) {\n return;\n }\n record.sourceFrame = sourceFrame;\n this.renderSourceFrame(sourceFrame);\n this.renderIssueLink(record);\n })\n .catch(() => {});\n }\n }\n\n dismiss(): void {\n if (this.destroyed || this.host.hidden) return;\n if (this.current) this.dismissedFingerprints.add(this.current.fingerprint);\n this.host.hidden = true;\n this.renderSequence += 1;\n if (this.previousFocus instanceof HTMLElement && this.previousFocus.isConnected) {\n this.previousFocus.focus();\n }\n this.previousFocus = undefined;\n }\n\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.renderSequence += 1;\n this.themeObserver.disconnect();\n this.colorSchemeQuery?.removeEventListener?.(\"change\", this.updateTheme);\n this.shadow.removeEventListener(\"keydown\", this.handleKeyDown);\n if (this.copyResetTimer !== undefined) {\n this.options.window.clearTimeout(this.copyResetTimer);\n }\n this.host.remove();\n this.current = undefined;\n }\n\n private mount(): void {\n if (!this.host.isConnected) {\n (this.document.body || this.document.documentElement).appendChild(this.host);\n }\n const wasHidden = this.host.hidden;\n this.host.hidden = false;\n if (wasHidden) {\n this.previousFocus = this.document.activeElement;\n this.options.window.setTimeout(() => {\n if (!this.host.hidden && !this.destroyed) {\n this.getElement<HTMLAnchorElement>(\"[data-farm-runtime-error-issue]\").focus({\n preventScroll: true,\n });\n }\n }, 0);\n }\n }\n\n private render(record: RuntimeErrorRecord): void {\n this.getElement(\"[data-farm-runtime-error-type]\").textContent = formatErrorType(\n record.error,\n record.context.phase,\n );\n renderErrorMessage(\n this.getElement(\"[data-farm-runtime-error-message]\"),\n record.error.message,\n this.document,\n );\n this.getElement(\"[data-farm-runtime-error-location]\").textContent =\n `${record.context.location.pathname}${record.context.location.search}` || \"/\";\n this.getElement(\"[data-farm-runtime-error-meta]\").textContent =\n `Farm.js v${this.options.farmVersion || FARM_VERSION} · development · browser`;\n this.renderIssueLink(record);\n this.renderOccurrences(record.occurrences);\n this.renderSourceFrame(record.sourceFrame);\n this.resetCopyStatus();\n }\n\n private renderOccurrences(occurrences: number): void {\n const badge = this.getElement<HTMLElement>(\"[data-farm-runtime-error-occurrences]\");\n badge.hidden = occurrences < 2;\n badge.textContent = occurrences < 2 ? \"\" : `Repeated ×${occurrences}`;\n }\n\n private renderIssueLink(record: RuntimeErrorRecord): void {\n this.getElement<HTMLAnchorElement>(\"[data-farm-runtime-error-issue]\").href =\n createGithubIssueUrl(record, this.options.window, this.options.farmVersion || FARM_VERSION);\n }\n\n private renderSourceFrame(sourceFrame: BrowserSourceFrame): void {\n const container = this.getElement<HTMLElement>(\"[data-farm-runtime-error-source]\");\n container.replaceChildren();\n\n const source = this.document.createElement(\"div\");\n source.className = \"farm-default-error__source\";\n\n const path = this.document.createElement(\"p\");\n path.className = \"farm-default-error__source-path\";\n path.textContent = formatSourcePath(sourceFrame);\n source.appendChild(path);\n\n const pre = this.document.createElement(\"pre\");\n pre.className = \"farm-default-error__source-code\";\n pre.tabIndex = 0;\n const code = this.document.createElement(\"code\");\n for (const line of sourceFrame.lines) {\n const row = this.document.createElement(\"span\");\n row.className = `farm-default-error__source-line${line.highlight ? \" farm-default-error__source-line--active\" : \"\"}`;\n\n const gutter = this.document.createElement(\"span\");\n gutter.className = \"farm-default-error__source-gutter\";\n gutter.textContent = `${line.highlight ? \">\" : \" \"} ${line.number ?? \"\"}`;\n\n const text = this.document.createElement(\"span\");\n text.className = \"farm-default-error__source-text\";\n text.textContent = line.content || \" \";\n\n row.append(gutter, text);\n code.appendChild(row);\n }\n pre.appendChild(code);\n source.appendChild(pre);\n container.appendChild(source);\n }\n\n private readonly handleReload = () => {\n (this.options.reload || (() => this.options.window.location.reload()))();\n };\n\n private readonly handleDismiss = () => {\n this.dismiss();\n };\n\n private readonly handleCopy = async () => {\n if (!this.current) return;\n const report = createFarmRuntimeErrorDebugReport(\n this.current,\n this.options.window,\n this.options.farmVersion || FARM_VERSION,\n );\n const label = this.getElement<HTMLElement>(\"[data-farm-runtime-error-copy-label]\");\n const status = this.getElement<HTMLElement>(\"[data-farm-runtime-error-copy-status]\");\n\n try {\n await copyText(report, this.options.window, this.document);\n label.textContent = \"Copied\";\n status.textContent = \"Debug report copied\";\n if (this.copyResetTimer !== undefined) {\n this.options.window.clearTimeout(this.copyResetTimer);\n }\n this.copyResetTimer = this.options.window.setTimeout(() => this.resetCopyStatus(), 1800);\n } catch {\n status.textContent = \"Unable to copy the debug report\";\n }\n };\n\n private readonly handleKeyDown = (event: Event) => {\n const keyboardEvent = event as KeyboardEvent;\n if (keyboardEvent.key === \"Escape\") {\n keyboardEvent.preventDefault();\n this.dismiss();\n return;\n }\n if (keyboardEvent.key !== \"Tab\") return;\n\n const controls = Array.from(\n this.shadow.querySelectorAll<HTMLElement>(\"a[href], button:not([hidden]):not([disabled])\"),\n );\n if (controls.length === 0) return;\n const first = controls[0];\n const last = controls[controls.length - 1];\n const active = this.shadow.activeElement;\n\n if (keyboardEvent.shiftKey && active === first) {\n keyboardEvent.preventDefault();\n last.focus();\n } else if (!keyboardEvent.shiftKey && active === last) {\n keyboardEvent.preventDefault();\n first.focus();\n }\n };\n\n private readonly updateTheme = () => {\n this.getElement<HTMLElement>(\"[data-farm-runtime-error-viewport]\").dataset.theme =\n resolveDocumentTheme(this.document, this.options.window);\n };\n\n private resetCopyStatus(): void {\n this.getElement(\"[data-farm-runtime-error-copy-label]\").textContent = \"Copy debug report\";\n this.getElement(\"[data-farm-runtime-error-copy-status]\").textContent = \"\";\n }\n\n private getElement<T extends Element = HTMLElement>(selector: string): T {\n const element = this.shadow.querySelector<T>(selector);\n if (!element) throw new Error(`Farm runtime error overlay is missing ${selector}`);\n return element;\n }\n}\n\nexport function createFarmRuntimeErrorOverlay(\n options: FarmRuntimeErrorOverlayOptions,\n): FarmRuntimeErrorOverlay {\n return new DefaultFarmRuntimeErrorOverlay(options);\n}\n\nfunction normalizeRuntimeError(errorLike: unknown): NormalizedRuntimeError {\n if (errorLike instanceof Error) {\n return {\n name: errorLike.name || \"Error\",\n message: errorLike.message || \"An unknown browser error occurred.\",\n stack: errorLike.stack,\n };\n }\n\n if (errorLike && typeof errorLike === \"object\") {\n const error = errorLike as Record<string, unknown>;\n const name = typeof error.name === \"string\" && error.name ? error.name : \"Error\";\n const message =\n typeof error.message === \"string\" && error.message\n ? error.message\n : typeof error.reason === \"string\" && error.reason\n ? error.reason\n : stringifyUnknown(errorLike);\n return {\n name,\n message: message || \"An unknown browser error occurred.\",\n stack: typeof error.stack === \"string\" ? error.stack : undefined,\n };\n }\n\n return {\n name: \"Error\",\n message: stringifyUnknown(errorLike) || \"An unknown browser error occurred.\",\n };\n}\n\nfunction stringifyUnknown(value: unknown): string {\n if (typeof value === \"string\") return value;\n if (value == null) return \"\";\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction resolveBrowserSourceLocation(\n error: NormalizedRuntimeError,\n sourceEvent: Event | undefined,\n clientWindow: Window,\n): BrowserSourceLocation | undefined {\n if (sourceEvent && \"filename\" in sourceEvent) {\n const event = sourceEvent as ErrorEvent;\n if (event.filename && event.lineno) {\n return createSourceLocation(event.filename, event.lineno, event.colno || 1, clientWindow);\n }\n }\n\n if (!error.stack) return undefined;\n for (const stackLine of error.stack.split(\"\\n\").slice(1)) {\n const match = stackLine\n .trim()\n .match(/\\(?((?:[a-z][a-z\\d+.-]*):\\/\\/[^)\\s]+|\\/[^)\\s]+):(\\d+):(\\d+)\\)?$/i);\n if (!match) continue;\n return {\n ...createSourceLocation(match[1], Number(match[2]), Number(match[3]), clientWindow),\n stackLine: stackLine.trim(),\n };\n }\n return undefined;\n}\n\nfunction createSourceLocation(\n url: string,\n line: number,\n column: number,\n clientWindow: Window,\n): BrowserSourceLocation {\n let displayPath = url;\n try {\n const parsed = new URL(url, clientWindow.location.href);\n displayPath = parsed.origin === clientWindow.location.origin ? parsed.pathname : parsed.href;\n } catch {}\n\n return { url, displayPath, line, column };\n}\n\nfunction createFallbackSourceFrame(\n error: NormalizedRuntimeError,\n location?: BrowserSourceLocation,\n): BrowserSourceFrame {\n const firstStackLine =\n location?.stackLine || error.stack?.split(\"\\n\").find((line) => line.trim().startsWith(\"at \"));\n return {\n path: location?.displayPath || \"Browser stack\",\n line: location?.line,\n column: location?.column,\n unavailable: true,\n lines: [\n {\n number: location?.line,\n content: firstStackLine?.trim() || error.message,\n highlight: true,\n },\n ],\n };\n}\n\nasync function loadBrowserSourceFrame(\n location: BrowserSourceLocation,\n options: FarmRuntimeErrorOverlayOptions,\n): Promise<BrowserSourceFrame | undefined> {\n const request = options.fetch || options.window.fetch?.bind(options.window);\n if (!request) return undefined;\n\n let sourceUrl: URL;\n try {\n sourceUrl = new URL(location.url, options.window.location.href);\n } catch {\n return undefined;\n }\n if (\n sourceUrl.origin !== options.window.location.origin ||\n (sourceUrl.protocol !== \"http:\" && sourceUrl.protocol !== \"https:\")\n ) {\n return undefined;\n }\n\n try {\n const response = await request(sourceUrl.href, {\n headers: { Accept: \"text/plain, application/javascript\" },\n });\n if (!response.ok) return undefined;\n const source = await response.text();\n if (source.length > 1_000_000) return undefined;\n\n const mappedFrame = await createMappedSourceFrame(\n source,\n sourceUrl,\n location,\n request,\n options.window,\n );\n if (mappedFrame) return mappedFrame;\n\n return createSourceFrame(source, location.displayPath, location.line, location.column);\n } catch {\n return undefined;\n }\n}\n\nasync function createMappedSourceFrame(\n generatedSource: string,\n generatedUrl: URL,\n location: BrowserSourceLocation,\n request: typeof fetch,\n clientWindow: Window,\n): Promise<BrowserSourceFrame | undefined> {\n const traceMap = await loadTraceMap(generatedSource, generatedUrl, request, clientWindow);\n if (!traceMap) return undefined;\n\n const original = originalPositionFor(traceMap, {\n line: location.line,\n column: Math.max(0, location.column - 1),\n });\n if (!original.source || original.line == null) return undefined;\n\n const originalSource = sourceContentFor(traceMap, original.source);\n if (originalSource == null) return undefined;\n\n const originalLines = originalSource.split(/\\r?\\n/);\n const generatedLine = generatedSource.split(/\\r?\\n/)[location.line - 1] || \"\";\n const line = refineOriginalLine(generatedLine, originalLines, original.line);\n const lineContent = originalLines[line - 1] || \"\";\n const trimmedGeneratedLine = generatedLine.trim();\n const column =\n line !== original.line && trimmedGeneratedLine && lineContent.includes(trimmedGeneratedLine)\n ? lineContent.indexOf(trimmedGeneratedLine) + 1\n : (original.column ?? 0) + 1;\n\n return createSourceFrame(\n originalSource,\n formatDisplaySourceUrl(original.source, clientWindow),\n line,\n column,\n );\n}\n\nasync function loadTraceMap(\n generatedSource: string,\n generatedUrl: URL,\n request: typeof fetch,\n clientWindow: Window,\n): Promise<TraceMap | undefined> {\n const matches = Array.from(generatedSource.matchAll(/\\/\\/[#@]\\s*sourceMappingURL=([^\\s]+)/g));\n const reference = matches[matches.length - 1]?.[1];\n if (!reference) return undefined;\n\n let sourceMapJson: string;\n if (reference.startsWith(\"data:\")) {\n sourceMapJson = decodeSourceMapDataUrl(reference, clientWindow);\n } else {\n const sourceMapUrl = new URL(reference, generatedUrl);\n if (sourceMapUrl.origin !== clientWindow.location.origin) return undefined;\n const response = await request(sourceMapUrl.href, {\n headers: { Accept: \"application/json, text/plain\" },\n });\n if (!response.ok) return undefined;\n sourceMapJson = await response.text();\n if (sourceMapJson.length > 2_000_000) return undefined;\n }\n\n return new TraceMap(JSON.parse(sourceMapJson) as SourceMapInput, generatedUrl.href);\n}\n\nfunction decodeSourceMapDataUrl(value: string, clientWindow: Window): string {\n const separator = value.indexOf(\",\");\n if (separator < 0) throw new Error(\"Invalid inline source map\");\n const metadata = value.slice(0, separator);\n const payload = value.slice(separator + 1);\n if (!metadata.includes(\";base64\")) return decodeURIComponent(payload);\n\n const binary = clientWindow.atob(payload);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n return new TextDecoder().decode(bytes);\n}\n\nfunction refineOriginalLine(\n generatedLine: string,\n originalLines: string[],\n mappedLine: number,\n): number {\n const normalizedGeneratedLine = normalizeSourceLine(generatedLine);\n if (normalizedGeneratedLine.length < 8) return mappedLine;\n\n let bestMatch = mappedLine;\n let bestDistance = Number.POSITIVE_INFINITY;\n for (let index = 0; index < originalLines.length; index += 1) {\n if (normalizeSourceLine(originalLines[index]) !== normalizedGeneratedLine) continue;\n const line = index + 1;\n const distance = Math.abs(line - mappedLine);\n if (distance < bestDistance) {\n bestMatch = line;\n bestDistance = distance;\n }\n }\n return bestMatch;\n}\n\nfunction normalizeSourceLine(value: string): string {\n return value.trim().replace(/\\s+/g, \" \");\n}\n\nfunction createSourceFrame(\n source: string,\n path: string,\n line: number,\n column: number,\n): BrowserSourceFrame | undefined {\n const lines = source.split(/\\r?\\n/);\n if (line < 1 || line > lines.length) return undefined;\n const start = Math.max(1, line - 2);\n const end = Math.min(lines.length, line + 2);\n const frameLines: BrowserSourceLine[] = [];\n for (let number = start; number <= end; number += 1) {\n frameLines.push({\n number,\n content: lines[number - 1] || \" \",\n highlight: number === line,\n });\n }\n\n return { path, line, column, lines: frameLines };\n}\n\nfunction formatDisplaySourceUrl(url: string, clientWindow: Window): string {\n try {\n const parsed = new URL(url, clientWindow.location.href);\n return parsed.origin === clientWindow.location.origin ? parsed.pathname : parsed.href;\n } catch {\n return url.replace(/[?#].*$/, \"\");\n }\n}\n\nfunction isBrowserExtensionUrl(url: string): boolean {\n try {\n return [\n \"chrome-extension:\",\n \"moz-extension:\",\n \"safari-web-extension:\",\n \"ms-browser-extension:\",\n ].includes(new URL(url).protocol);\n } catch {\n return /^(?:chrome|moz|safari-web|ms-browser)-extension:\\/\\//i.test(url);\n }\n}\n\nfunction isRecoverableReactHydrationError(\n error: NormalizedRuntimeError,\n context: FarmRuntimeErrorOverlayContext,\n location?: BrowserSourceLocation,\n): boolean {\n if (context.phase !== \"window\") return false;\n\n const isKnownRecoverableMessage = [\n /^Hydration failed because the server rendered (?:text|HTML) didn't match the client\\b/i,\n /^Text content does not match server-rendered HTML\\b/i,\n /^There was an error while hydrating but React was able to recover\\b/i,\n ].some((pattern) => pattern.test(error.message));\n if (!isKnownRecoverableMessage) return false;\n\n return /(?:react-dom(?:_client)?(?:\\.development)?\\.js|react-dom\\/|throwOnHydrationMismatch|onRecoverableError)/i.test(\n `${location?.url || \"\"}\\n${error.stack || \"\"}`,\n );\n}\n\nfunction renderErrorMessage(container: Element, message: string, document: Document): void {\n const fragments: Node[] = [];\n const codePattern = /`([^`\\n]+)`|\\b[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*){2,}\\b/g;\n let offset = 0;\n\n for (const match of message.matchAll(codePattern)) {\n const index = match.index ?? 0;\n if (index > offset) fragments.push(document.createTextNode(message.slice(offset, index)));\n\n const code = document.createElement(\"code\");\n code.className = \"farm-runtime-error__inline-code\";\n code.textContent = match[1] || match[0];\n fragments.push(code);\n offset = index + match[0].length;\n }\n\n if (offset < message.length) fragments.push(document.createTextNode(message.slice(offset)));\n container.replaceChildren(...fragments);\n}\n\nfunction createErrorFingerprint(\n error: NormalizedRuntimeError,\n context: FarmRuntimeErrorOverlayContext,\n location?: BrowserSourceLocation,\n): string {\n return [\n context.phase,\n context.location.pathname,\n error.name,\n error.message,\n location?.displayPath || \"\",\n location?.line || \"\",\n error.stack?.split(\"\\n\")[1]?.trim() || \"\",\n ].join(\"\\u0000\");\n}\n\nfunction formatPhase(phase: string): string {\n return phase\n .replace(/^plugin:/, \"Plugin · \")\n .replace(/-/g, \" \")\n .replace(/\\b\\w/g, (character) => character.toUpperCase());\n}\n\nfunction formatErrorType(error: NormalizedRuntimeError, phase: string): string {\n const category =\n phase === \"hydration\"\n ? \"Hydration\"\n : phase === \"navigation\"\n ? \"Navigation\"\n : phase === \"setup\" || phase.startsWith(\"plugin:\")\n ? \"Plugin\"\n : phase === \"performance\"\n ? \"Performance\"\n : \"Runtime\";\n const name = error.name.trim() || \"Error\";\n return `${category} ${name}`;\n}\n\nfunction formatSourcePath(sourceFrame: BrowserSourceFrame): string {\n if (!sourceFrame.line) return sourceFrame.path;\n return `${sourceFrame.path}:${sourceFrame.line}:${sourceFrame.column || 1}${\n sourceFrame.unavailable ? \" · source preview unavailable\" : \"\"\n }`;\n}\n\nfunction resolveDocumentTheme(document: Document, clientWindow: Window): \"light\" | \"dark\" {\n for (const element of [document.documentElement, document.body]) {\n if (!element) continue;\n const explicit =\n element.getAttribute(\"data-theme\") || element.getAttribute(\"data-color-scheme\");\n if (explicit === \"dark\" || element.classList.contains(\"dark\")) return \"dark\";\n if (explicit === \"light\" || element.classList.contains(\"light\")) return \"light\";\n }\n\n const colorScheme = clientWindow.getComputedStyle?.(document.documentElement).colorScheme;\n if (colorScheme?.includes(\"dark\") && !colorScheme.includes(\"light\")) return \"dark\";\n return clientWindow.matchMedia?.(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\nfunction createFarmRuntimeErrorDebugReport(\n record: RuntimeErrorRecord,\n clientWindow: Window,\n farmVersion: string,\n): string {\n const source = record.sourceFrame.lines\n .map(\n (line) =>\n `${line.highlight ? \">\" : \" \"} ${line.number ? String(line.number).padStart(4, \" \") : \" \"} | ${line.content}`,\n )\n .join(\"\\n\");\n const viewport = `${clientWindow.innerWidth}×${clientWindow.innerHeight}`;\n\n return [\n \"# Farm.js client runtime debug report\",\n \"\",\n \"## Error\",\n `- Type: ${formatErrorType(record.error, record.context.phase)}`,\n `- Message: ${record.error.message}`,\n `- Phase: ${formatPhase(record.context.phase)}`,\n `- Page: ${record.context.location.href}`,\n `- Occurrences: ${record.occurrences}`,\n \"\",\n \"## Browser runtime\",\n `- Farm.js: ${farmVersion}`,\n `- User agent: ${clientWindow.navigator.userAgent}`,\n `- Viewport: ${viewport}`,\n `- Online: ${clientWindow.navigator.onLine === false ? \"no\" : \"yes\"}`,\n \"\",\n \"## Source\",\n `\\`${formatSourcePath(record.sourceFrame)}\\``,\n \"\",\n \"```text\",\n source,\n \"```\",\n \"\",\n \"## Stack trace\",\n \"```text\",\n record.error.stack || \"Stack trace unavailable.\",\n \"```\",\n \"\",\n \"## Diagnostic request\",\n \"Identify the most likely root cause from the message, source frame, and stack trace. Explain the smallest safe fix and how to verify it.\",\n ].join(\"\\n\");\n}\n\nfunction createGithubIssueUrl(\n record: RuntimeErrorRecord,\n clientWindow: Window,\n farmVersion: string,\n): string {\n const source = record.sourceFrame.lines\n .map(\n (line) =>\n `${line.highlight ? \">\" : \" \"} ${line.number ? String(line.number).padStart(4, \" \") : \" \"} | ${line.content}`,\n )\n .join(\"\\n\");\n const body = truncateText(\n [\n \"## Runtime error report\",\n \"\",\n \"> This report was prefilled by the Farm.js development error overlay. Review it and remove sensitive information before submitting.\",\n \"\",\n \"### Error\",\n `- Type: ${formatErrorType(record.error, record.context.phase)}`,\n `- Message: ${record.error.message}`,\n `- Phase: ${formatPhase(record.context.phase)}`,\n `- Page path: ${record.context.location.pathname}`,\n `- Occurrences: ${record.occurrences}`,\n `- Farm.js: ${farmVersion}`,\n `- Browser: ${clientWindow.navigator.userAgent}`,\n `- Viewport: ${clientWindow.innerWidth}×${clientWindow.innerHeight}`,\n `- Online: ${clientWindow.navigator.onLine === false ? \"no\" : \"yes\"}`,\n \"\",\n \"### Source\",\n `\\`${formatSourcePath(record.sourceFrame)}\\``,\n \"\",\n \"```text\",\n source,\n \"```\",\n \"\",\n \"### Stack trace\",\n \"```text\",\n record.error.stack || \"Stack trace unavailable.\",\n \"```\",\n \"\",\n \"### Expected behavior\",\n \"Describe what you expected to happen and the steps needed to reproduce the failure.\",\n \"\",\n \"### Diagnostic request\",\n \"Identify the most likely root cause from the message, source frame, and stack trace. Explain the smallest safe fix and how to verify it.\",\n ].join(\"\\n\"),\n 6_000,\n );\n const issueUrl = new URL(\"https://github.com/farming-labs/farm.js/issues/new\");\n issueUrl.searchParams.set(\"title\", truncateText(`[runtime error] ${record.error.message}`, 120));\n issueUrl.searchParams.set(\"body\", body);\n return issueUrl.href;\n}\n\nfunction truncateText(value: string, maxLength: number): string {\n if (value.length <= maxLength) return value;\n return `${value.slice(0, maxLength - 24)}\\n\\n[report truncated]`;\n}\n\nasync function copyText(value: string, clientWindow: Window, document: Document): Promise<void> {\n if (clientWindow.navigator.clipboard && clientWindow.isSecureContext) {\n await clientWindow.navigator.clipboard.writeText(value);\n return;\n }\n\n const area = document.createElement(\"textarea\");\n area.value = value;\n area.readOnly = true;\n area.style.position = \"fixed\";\n area.style.opacity = \"0\";\n document.body.appendChild(area);\n area.select();\n const copied = document.execCommand(\"copy\");\n area.remove();\n if (!copied) throw new Error(\"Copy command was rejected\");\n}\n","\"use client\";\n\nimport {\n createFarmRuntimeErrorOverlay,\n type FarmRuntimeErrorOverlay,\n} from \"./runtime-error-overlay\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type FarmClientPluginEnforce = \"pre\" | \"post\";\nexport type FarmClientNavigationAction = \"push\" | \"replace\" | \"pop\";\nexport type FarmClientHydrationMode = \"hydrate\" | \"render\";\n\nexport interface FarmClientLocation {\n href: string;\n pathname: string;\n search: string;\n hash: string;\n}\n\nexport interface FarmClientPluginRouter {\n navigate(href: string, options?: Record<string, unknown>): MaybePromise<void>;\n /** Re-render the current URL from fresh server data without replacing the document shell. */\n refresh?(options?: Record<string, unknown>): MaybePromise<void>;\n prefetch?(href: string): MaybePromise<void>;\n clearCache?(): void;\n getNavigationState?(): unknown;\n}\n\nexport interface FarmClientPluginMetadata {\n name: string;\n version?: string;\n}\n\nexport interface FarmClientPluginSetupEvent<TPublic = undefined> {\n plugin: FarmClientPluginMetadata;\n public: Readonly<TPublic>;\n router: FarmClientPluginRouter;\n isDev: boolean;\n isProd: boolean;\n deploymentId?: string;\n}\n\nexport interface FarmClientPluginStateEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientPluginSetupEvent<TPublic> {\n state: TState;\n}\n\nexport interface FarmClientHydrationSession {\n container: Element;\n location: FarmClientLocation;\n mode: FarmClientHydrationMode;\n startedAt: number;\n}\n\nexport interface FarmClientHydrationEvent<TState = unknown, TPublic = undefined>\n extends FarmClientPluginStateEvent<TState, TPublic>, FarmClientHydrationSession {}\n\nexport interface FarmClientHydrationCompleteEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientHydrationEvent<TState, TPublic> {\n durationMs: number;\n recovered: boolean;\n}\n\nexport interface FarmClientNavigationSession {\n id: string;\n from: FarmClientLocation | null;\n to: FarmClientLocation;\n action: FarmClientNavigationAction;\n signal: AbortSignal;\n startedAt: number;\n route?: {\n pattern?: string | null;\n params?: Record<string, string>;\n };\n}\n\nexport interface FarmClientNavigationEvent<TState = unknown, TPublic = undefined>\n extends FarmClientPluginStateEvent<TState, TPublic>, FarmClientNavigationSession {}\n\nexport interface FarmClientNavigationLoadedEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientNavigationEvent<TState, TPublic> {\n durationMs: number;\n data?: unknown;\n}\n\nexport interface FarmClientNavigationResolvedEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientNavigationEvent<TState, TPublic> {\n durationMs: number;\n}\n\nexport interface FarmClientNavigationErrorEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientNavigationResolvedEvent<TState, TPublic> {\n error: unknown;\n}\n\nexport type FarmClientPluginErrorPhase =\n | \"setup\"\n | \"hydration\"\n | \"navigation\"\n | \"window\"\n | \"unhandled-rejection\"\n | \"performance\"\n | `plugin:${string}`\n | (string & {});\n\nexport interface FarmClientPluginErrorEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientPluginStateEvent<TState, TPublic> {\n error: unknown;\n phase: FarmClientPluginErrorPhase;\n location: FarmClientLocation;\n navigation?: FarmClientNavigationSession;\n}\n\nexport interface FarmClientPerformanceEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientPluginStateEvent<TState, TPublic> {\n entry: PerformanceEntry;\n location: FarmClientLocation;\n}\n\nexport interface FarmClientPluginCloseEvent<\n TState = unknown,\n TPublic = undefined,\n> extends FarmClientPluginStateEvent<TState, TPublic> {\n reason: \"pagehide\" | \"hmr\" | \"manual\" | (string & {});\n}\n\nexport interface FarmClientPlugin<TState = unknown, TPublic = undefined> {\n setup?(event: FarmClientPluginSetupEvent<TPublic>): MaybePromise<TState>;\n hydration?: {\n before?(event: FarmClientHydrationEvent<TState, TPublic>): MaybePromise<void>;\n after?(event: FarmClientHydrationCompleteEvent<TState, TPublic>): MaybePromise<void>;\n };\n navigation?: {\n before?(event: FarmClientNavigationEvent<TState, TPublic>): MaybePromise<void>;\n loaded?(event: FarmClientNavigationLoadedEvent<TState, TPublic>): MaybePromise<void>;\n resolved?(event: FarmClientNavigationResolvedEvent<TState, TPublic>): MaybePromise<void>;\n rendered?(event: FarmClientNavigationResolvedEvent<TState, TPublic>): MaybePromise<void>;\n error?(event: FarmClientNavigationErrorEvent<TState, TPublic>): MaybePromise<void>;\n };\n error?(event: FarmClientPluginErrorEvent<TState, TPublic>): MaybePromise<void>;\n performance?(event: FarmClientPerformanceEvent<TState, TPublic>): MaybePromise<void>;\n close?(event: FarmClientPluginCloseEvent<TState, TPublic>): MaybePromise<void>;\n}\n\nexport interface FarmClientPluginRegistration<TPublic = undefined> {\n name: string;\n version?: string;\n enforce?: FarmClientPluginEnforce;\n definition: FarmClientPlugin<any, TPublic>;\n public?: TPublic;\n}\n\n/**\n * Define the lifecycle for an application's auto-discovered `src/client.ts`\n * entry. The identity helper preserves state inference while keeping the\n * module entirely in the browser bundle.\n */\nexport function defineClient<TState = unknown, TPublic = undefined>(\n definition: FarmClientPlugin<TState, TPublic>,\n): FarmClientPlugin<TState, TPublic> {\n return definition;\n}\n\nexport interface FarmClientPluginManagerOptions {\n router: FarmClientPluginRouter;\n isDev?: boolean;\n isProd?: boolean;\n deploymentId?: string;\n window?: Window;\n}\n\ninterface FarmClientPluginInstance {\n registration: FarmClientPluginRegistration<any>;\n plugin: FarmClientPlugin<any, any>;\n state: unknown;\n}\n\nconst PERFORMANCE_ENTRY_TYPES = [\n \"navigation\",\n \"paint\",\n \"largest-contentful-paint\",\n \"layout-shift\",\n \"event\",\n];\n\nexport class FarmClientPluginManager {\n private readonly registrations: FarmClientPluginRegistration[];\n private readonly options: FarmClientPluginManagerOptions;\n private readonly instances: FarmClientPluginInstance[] = [];\n private readonly performanceObservers: PerformanceObserver[] = [];\n private startPromise?: Promise<void>;\n private closePromise?: Promise<void>;\n private currentNavigation?: {\n controller: AbortController;\n session: FarmClientNavigationSession;\n };\n private navigationSequence = 0;\n private starting = false;\n private started = false;\n private closed = false;\n private readonly reportedErrors = new WeakSet<object>();\n private readonly runtimeErrorOverlay?: FarmRuntimeErrorOverlay;\n\n private readonly handleWindowError = (event: ErrorEvent) => {\n const error = event.error ?? new Error(event.message || \"Unknown browser error\");\n void this.reportError(error, \"window\", undefined, this.getLocation(), event);\n };\n\n private readonly handleUnhandledRejection = (event: PromiseRejectionEvent) => {\n void this.reportError(\n event.reason,\n \"unhandled-rejection\",\n undefined,\n this.getLocation(),\n event,\n );\n };\n\n private readonly handlePageHide = () => {\n void this.close(\"pagehide\");\n };\n\n constructor(\n registrations: readonly FarmClientPluginRegistration[],\n options: FarmClientPluginManagerOptions,\n ) {\n this.registrations = sortRegistrations(registrations);\n this.options = {\n ...options,\n isDev: options.isDev ?? false,\n isProd: options.isProd ?? !options.isDev,\n window: options.window ?? (typeof window !== \"undefined\" ? window : undefined),\n };\n if (this.options.isDev && this.options.window) {\n this.runtimeErrorOverlay = createFarmRuntimeErrorOverlay({\n window: this.options.window,\n });\n }\n }\n\n start(): Promise<void> {\n if (this.startPromise) return this.startPromise;\n\n this.startPromise = Promise.resolve().then(() => this.startInternal());\n return this.startPromise;\n }\n\n async beginHydration(input: {\n container: Element;\n mode: FarmClientHydrationMode;\n }): Promise<FarmClientHydrationSession> {\n await this.start();\n const session: FarmClientHydrationSession = {\n ...input,\n location: this.getLocation(),\n startedAt: now(),\n };\n\n await this.runHook(\"hydration.before\", (instance) =>\n instance.plugin.hydration?.before?.({\n ...this.createStateEvent(instance),\n ...session,\n }),\n );\n\n return session;\n }\n\n async completeHydration(\n session: FarmClientHydrationSession,\n options: { recovered?: boolean } = {},\n ): Promise<void> {\n await this.runHook(\"hydration.after\", (instance) =>\n instance.plugin.hydration?.after?.({\n ...this.createStateEvent(instance),\n ...session,\n durationMs: now() - session.startedAt,\n recovered: options.recovered ?? false,\n }),\n );\n }\n\n async failHydration(session: FarmClientHydrationSession, error: unknown): Promise<void> {\n await this.reportError(error, \"hydration\", undefined, session.location);\n }\n\n async beginNavigation(input: {\n from?: string | URL | FarmClientLocation | null;\n to: string | URL | FarmClientLocation;\n action: FarmClientNavigationAction;\n route?: FarmClientNavigationSession[\"route\"];\n }): Promise<FarmClientNavigationSession> {\n await this.start();\n this.currentNavigation?.controller.abort(\"superseded\");\n\n const controller = new AbortController();\n const session: FarmClientNavigationSession = {\n id: `navigation:${++this.navigationSequence}`,\n from:\n input.from === null\n ? null\n : toClientLocation(input.from ?? this.getLocation().href, this.getBaseUrl()),\n to: toClientLocation(input.to, this.getBaseUrl()),\n action: input.action,\n signal: controller.signal,\n startedAt: now(),\n route: input.route,\n };\n\n this.currentNavigation = { controller, session };\n await this.runHook(\"navigation.before\", (instance) =>\n instance.plugin.navigation?.before?.({\n ...this.createStateEvent(instance),\n ...session,\n }),\n );\n\n return session;\n }\n\n async markNavigationLoaded(session: FarmClientNavigationSession, data?: unknown): Promise<void> {\n if (session.signal.aborted) return;\n await this.runHook(\"navigation.loaded\", (instance) =>\n instance.plugin.navigation?.loaded?.({\n ...this.createStateEvent(instance),\n ...session,\n data,\n durationMs: now() - session.startedAt,\n }),\n );\n }\n\n cancelNavigation(session?: FarmClientNavigationSession, reason: unknown = \"canceled\"): void {\n const current = this.currentNavigation;\n if (!current || (session && current.session !== session)) return;\n current.controller.abort(reason);\n this.currentNavigation = undefined;\n }\n\n async resolveNavigation(session: FarmClientNavigationSession): Promise<void> {\n if (session.signal.aborted) return;\n await this.runHook(\"navigation.resolved\", (instance) =>\n instance.plugin.navigation?.resolved?.({\n ...this.createStateEvent(instance),\n ...session,\n durationMs: now() - session.startedAt,\n }),\n );\n }\n\n scheduleNavigationRendered(session: FarmClientNavigationSession): Promise<void> {\n if (session.signal.aborted) return Promise.resolve();\n const clientWindow = this.options.window;\n const schedule = clientWindow?.requestAnimationFrame\n ? (callback: () => void) =>\n clientWindow.requestAnimationFrame(() => clientWindow.requestAnimationFrame(callback))\n : (callback: () => void) => setTimeout(callback, 0);\n\n return new Promise((resolve) => {\n schedule(() => {\n if (session.signal.aborted || this.closed) {\n resolve();\n return;\n }\n void this.runHook(\"navigation.rendered\", (instance) =>\n instance.plugin.navigation?.rendered?.({\n ...this.createStateEvent(instance),\n ...session,\n durationMs: now() - session.startedAt,\n }),\n ).finally(() => {\n if (this.currentNavigation?.session === session) {\n this.currentNavigation = undefined;\n }\n resolve();\n });\n });\n });\n }\n\n async failNavigation(session: FarmClientNavigationSession, error: unknown): Promise<void> {\n if (!session.signal.aborted) {\n await this.runHook(\"navigation.error\", (instance) =>\n instance.plugin.navigation?.error?.({\n ...this.createStateEvent(instance),\n ...session,\n durationMs: now() - session.startedAt,\n error,\n }),\n );\n await this.reportError(error, \"navigation\", session, session.to);\n }\n\n if (this.currentNavigation?.session === session) {\n this.currentNavigation = undefined;\n }\n }\n\n async reportError(\n error: unknown,\n phase: FarmClientPluginErrorPhase,\n navigation?: FarmClientNavigationSession,\n location = this.getLocation(),\n sourceEvent?: Event,\n ): Promise<void> {\n if (this.closed) return;\n if (isObject(error)) {\n if (this.reportedErrors.has(error)) return;\n this.reportedErrors.add(error);\n }\n\n if (!this.started && !this.starting) await this.start();\n await this.runErrorHooks({ error, phase, navigation, location }, undefined, sourceEvent);\n }\n\n close(reason: FarmClientPluginCloseEvent[\"reason\"] = \"manual\"): Promise<void> {\n if (this.closePromise) return this.closePromise;\n this.closePromise = this.closeInternal(reason);\n return this.closePromise;\n }\n\n getPlugins(): readonly FarmClientPluginMetadata[] {\n return this.instances.map(({ registration }) => ({\n name: registration.name,\n version: registration.version,\n }));\n }\n\n private async startInternal(): Promise<void> {\n if (this.started || this.closed) return;\n this.starting = true;\n\n try {\n for (const registration of this.registrations) {\n try {\n const definition = registration.definition;\n if (!definition || typeof definition !== \"object\") {\n throw new TypeError(\n `Client plugin \"${registration.name}\" does not define a lifecycle object`,\n );\n }\n\n const instance: FarmClientPluginInstance = {\n registration,\n plugin: definition,\n state: undefined,\n };\n instance.state = await definition.setup?.(this.createSetupEvent(instance));\n this.instances.push(instance);\n } catch (error) {\n this.logHookError(registration.name, \"setup\", error);\n await this.runErrorHooks({\n error,\n phase: \"setup\",\n location: this.getLocation(),\n });\n }\n }\n\n this.started = true;\n this.installBrowserListeners();\n this.installPerformanceObservers();\n } finally {\n this.starting = false;\n }\n }\n\n private installBrowserListeners(): void {\n const clientWindow = this.options.window;\n if (!clientWindow) return;\n\n if (this.runtimeErrorOverlay || this.instances.some(({ plugin }) => plugin.error)) {\n clientWindow.addEventListener(\"error\", this.handleWindowError);\n clientWindow.addEventListener(\"unhandledrejection\", this.handleUnhandledRejection);\n }\n clientWindow.addEventListener(\"pagehide\", this.handlePageHide, {\n once: true,\n });\n }\n\n private installPerformanceObservers(): void {\n if (!this.instances.some(({ plugin }) => plugin.performance)) return;\n const Observer = typeof PerformanceObserver !== \"undefined\" ? PerformanceObserver : undefined;\n if (!Observer) return;\n\n const supported = new Set(Observer.supportedEntryTypes || []);\n for (const type of PERFORMANCE_ENTRY_TYPES) {\n if (!supported.has(type)) continue;\n try {\n const observer = new Observer((list: PerformanceObserverEntryList) => {\n for (const entry of list.getEntries()) {\n void this.runHook(\"performance\", (instance) =>\n instance.plugin.performance?.({\n ...this.createStateEvent(instance),\n entry,\n location: this.getLocation(),\n }),\n );\n }\n });\n observer.observe({ type, buffered: true });\n this.performanceObservers.push(observer);\n } catch (error) {\n void this.reportError(error, \"performance\");\n }\n }\n }\n\n private async closeInternal(reason: FarmClientPluginCloseEvent[\"reason\"]): Promise<void> {\n if (this.closed) return;\n if (this.startPromise) await this.startPromise;\n this.closed = true;\n this.currentNavigation?.controller.abort(reason);\n this.currentNavigation = undefined;\n\n const clientWindow = this.options.window;\n clientWindow?.removeEventListener(\"error\", this.handleWindowError);\n clientWindow?.removeEventListener(\"unhandledrejection\", this.handleUnhandledRejection);\n clientWindow?.removeEventListener(\"pagehide\", this.handlePageHide);\n for (const observer of this.performanceObservers) observer.disconnect();\n this.performanceObservers.length = 0;\n this.runtimeErrorOverlay?.destroy();\n\n for (const instance of [...this.instances].reverse()) {\n try {\n await instance.plugin.close?.({\n ...this.createStateEvent(instance),\n reason,\n });\n } catch (error) {\n this.logHookError(instance.registration.name, \"close\", error);\n }\n }\n }\n\n private async runHook(\n hook: string,\n invoke: (instance: FarmClientPluginInstance) => MaybePromise<void> | undefined,\n ): Promise<void> {\n for (const instance of this.instances) {\n try {\n await invoke(instance);\n } catch (error) {\n this.logHookError(instance.registration.name, hook, error);\n await this.runErrorHooks(\n {\n error,\n phase: `plugin:${hook}`,\n location: this.getLocation(),\n },\n instance,\n );\n }\n }\n }\n\n private async runErrorHooks(\n event: Pick<FarmClientPluginErrorEvent, \"error\" | \"phase\" | \"location\" | \"navigation\">,\n excluded?: FarmClientPluginInstance,\n sourceEvent?: Event,\n ): Promise<void> {\n this.runtimeErrorOverlay?.show(event.error, {\n phase: event.phase,\n location: event.location,\n sourceEvent,\n });\n for (const instance of this.instances) {\n if (instance === excluded || !instance.plugin.error) continue;\n try {\n await instance.plugin.error({\n ...this.createStateEvent(instance),\n ...event,\n });\n } catch (error) {\n this.logHookError(instance.registration.name, \"error\", error);\n }\n }\n }\n\n private createSetupEvent(\n instance: Pick<FarmClientPluginInstance, \"registration\">,\n ): FarmClientPluginSetupEvent<any> {\n return {\n plugin: {\n name: instance.registration.name,\n version: instance.registration.version,\n },\n public: readonlyPublicData(instance.registration.public),\n router: this.options.router,\n isDev: Boolean(this.options.isDev),\n isProd: Boolean(this.options.isProd),\n deploymentId: this.options.deploymentId,\n };\n }\n\n private createStateEvent(\n instance: FarmClientPluginInstance,\n ): FarmClientPluginStateEvent<any, any> {\n return {\n ...this.createSetupEvent(instance),\n state: instance.state,\n };\n }\n\n private getLocation(): FarmClientLocation {\n const href = this.options.window?.location.href ?? \"http://localhost/\";\n return toClientLocation(href, href);\n }\n\n private getBaseUrl(): string {\n return this.options.window?.location.href ?? \"http://localhost/\";\n }\n\n private logHookError(name: string, hook: string, error: unknown): void {\n console.error(`[Farm.js] Client plugin \"${name}\" failed in ${hook}:`, error);\n }\n}\n\nexport function createClientPluginManager(\n registrations: readonly FarmClientPluginRegistration[],\n options: FarmClientPluginManagerOptions,\n): FarmClientPluginManager {\n return new FarmClientPluginManager(registrations, options);\n}\n\nfunction sortRegistrations(\n registrations: readonly FarmClientPluginRegistration[],\n): FarmClientPluginRegistration[] {\n const rank = (enforce?: FarmClientPluginEnforce) =>\n enforce === \"pre\" ? 0 : enforce === \"post\" ? 2 : 1;\n return registrations\n .map((registration, index) => ({ registration, index }))\n .sort(\n (left, right) =>\n rank(left.registration.enforce) - rank(right.registration.enforce) ||\n left.index - right.index,\n )\n .map(({ registration }) => registration);\n}\n\nfunction toClientLocation(\n input: string | URL | FarmClientLocation,\n base: string,\n): FarmClientLocation {\n if (typeof input === \"object\" && \"href\" in input && \"pathname\" in input) {\n return {\n href: input.href,\n pathname: input.pathname,\n search: input.search,\n hash: input.hash,\n };\n }\n\n const url = new URL(input, base);\n return {\n href: url.href,\n pathname: url.pathname,\n search: url.search,\n hash: url.hash,\n };\n}\n\nfunction readonlyPublicData<T>(value: T | undefined): Readonly<T> {\n if (value && typeof value === \"object\") {\n return Object.freeze(value);\n }\n return value as Readonly<T>;\n}\n\nfunction now(): number {\n return typeof performance !== \"undefined\" ? performance.now() : Date.now();\n}\n\nfunction isObject(value: unknown): value is object {\n return (typeof value === \"object\" && value !== null) || typeof value === \"function\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,2BAKO;;;ACqKA,SAAS,aACd,YACmC;AACnC,SAAO;AACT;AAJgB;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
defineClient
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-UWQ4EEW7.mjs";
|
|
5
5
|
import "../chunk-FXG2PS27.mjs";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-IHADQ6J7.mjs";
|
|
7
7
|
import "../chunk-CGILA3WO.mjs";
|
|
8
8
|
export {
|
|
9
9
|
defineClient
|
|
@@ -11,7 +11,7 @@ import { FarmMarkdownUserConfig, FarmMarkdownResolvedConfig } from './markdown.m
|
|
|
11
11
|
import { FarmObservabilityUserConfig } from './observability.mjs';
|
|
12
12
|
import * as vite from 'vite';
|
|
13
13
|
import { ViteDevServer, UserConfig, Plugin, Connect } from 'vite';
|
|
14
|
-
import { j as FarmWorkflowsUserConfig, a as FarmServerConfig, F as FarmWorkflowsResolvedConfig, R as ResolvedFarmServerConfig } from './workflows-
|
|
14
|
+
import { j as FarmWorkflowsUserConfig, a as FarmServerConfig, F as FarmWorkflowsResolvedConfig, R as ResolvedFarmServerConfig } from './workflows-BantWytQ.mjs';
|
|
15
15
|
import { FarmCronUserConfig, FarmCronResolvedConfig } from './cron.mjs';
|
|
16
16
|
import { ResolvedFarmEnv, FarmEnvConfig } from './env.mjs';
|
|
17
17
|
import { b as FarmRedirectStatus } from './navigation-errors-Dvwpzaer.mjs';
|
|
@@ -25,6 +25,42 @@ import { FarmLayoutFonts } from './font.mjs';
|
|
|
25
25
|
import { _withAfterNodeMiddleware } from './after.mjs';
|
|
26
26
|
import { F as FarmIslandStrategy } from './island-CfGru1MO.mjs';
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Integration auth routes accept ordinary form posts, which browsers send
|
|
30
|
+
* cross-site without a CORS preflight. Without an origin check, a third-party
|
|
31
|
+
* page can submit credentials to an app's own sign-in route and plant an
|
|
32
|
+
* attacker-controlled session in the victim's browser (login CSRF), or drive a
|
|
33
|
+
* forced sign-out. This mirrors the server-action origin contract so both
|
|
34
|
+
* entry points reject the same requests.
|
|
35
|
+
*/
|
|
36
|
+
type IntegrationOriginRejection = "missing-origin" | "opaque-origin" | "invalid-origin" | "cross-site";
|
|
37
|
+
type IntegrationOriginResult = {
|
|
38
|
+
ok: true;
|
|
39
|
+
} | {
|
|
40
|
+
ok: false;
|
|
41
|
+
reason: IntegrationOriginRejection;
|
|
42
|
+
};
|
|
43
|
+
interface IntegrationOriginPolicy {
|
|
44
|
+
/** Extra trusted origins, using the `serverActions.allowedOrigins` pattern syntax. */
|
|
45
|
+
allowedOrigins?: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* Whether a request carrying no origin metadata at all must be rejected.
|
|
48
|
+
*
|
|
49
|
+
* Form posts always carry an Origin header in supported browsers, so
|
|
50
|
+
* state-changing POSTs default to rejecting (`true`). Top-level GET
|
|
51
|
+
* navigations legitimately arrive with no Origin and no Referer — a typed
|
|
52
|
+
* URL or a bookmark — so GET callers pass `false` to avoid breaking them.
|
|
53
|
+
*/
|
|
54
|
+
requireOriginMetadata?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve configured origin patterns once, at integration construction, so an
|
|
58
|
+
* invalid pattern fails loudly at startup instead of per request.
|
|
59
|
+
*/
|
|
60
|
+
declare function resolveIntegrationAllowedOrigins(values: readonly string[] | undefined, label: string): readonly string[];
|
|
61
|
+
declare function validateIntegrationRequestOrigin(request: Request, policy?: IntegrationOriginPolicy): IntegrationOriginResult;
|
|
62
|
+
declare function describeIntegrationOriginRejection(reason: IntegrationOriginRejection): string;
|
|
63
|
+
|
|
28
64
|
type RuntimeClientFactory<TClient> = () => TClient | Promise<TClient>;
|
|
29
65
|
type FarmIntegrationOrmSchema = SchemaDefinition<Record<string, AnyModelDefinition>>;
|
|
30
66
|
type FarmIntegrationOrmClient<TSchema extends FarmIntegrationOrmSchema> = OrmClient<TSchema>;
|
|
@@ -2269,4 +2305,4 @@ interface SSGCollectionResult {
|
|
|
2269
2305
|
ssr: string[];
|
|
2270
2306
|
}
|
|
2271
2307
|
|
|
2272
|
-
export { type BuildOptions as $, type AppRoutePattern as A, type BundleResultPayload as B, type FarmContextFactoryInput as C, type FarmIsolatedClientHydrationMode as D, type LoadingProps as E, type FarmRouteRuntimeConfig as F, type ErrorProps as G, type PagePropsWithMiddleware as H, type MetadataProps as I, type LayoutMetadataProps as J, type Page as K, type LayoutProps as L, type Metadata as M, type NitroPreset as N, type Layout as O, type ParsedRoute as P, type Loading as Q, type RouteSegment as R, type ErrorBoundary as S, type StaticPathPrimitive as T, type StaticPathParams as U, type StaticRouteParams as V, type GenerateStaticParams as W, type LayoutModule as X, type FarmRequest as Y, type FarmResponse as Z, type ServerAction as _, type FarmPlugin as a, type FarmPluginRouteRuntimePayload as a$, type SSGPage as a0, type SSGCollectionResult as a1, type FarmLayerEntry as a2, type ResolvedFarmLayer as a3, type FarmSourceRoot as a4, type ResolveFarmLayersOptions as a5, type FarmLayerResolution as a6, resolveFarmLayers as a7, getFarmSourceRoots as a8, getFarmAppDirectories as a9, resolveDeployOutputPath as aA, normalizeDeployTarget as aB, getDeployTargetForPreset as aC, getPresetForDeployTarget as aD, type FarmLayerConfig as aE, type FarmPerformanceConfig as aF, type FarmPreloadMode as aG, type FarmPreloadUserConfig as aH, type ResolvedFarmPreloadConfig as aI, type FarmCspConfig as aJ, type FarmCspDirectives as aK, type FarmCspDirectiveValue as aL, type FarmCspOptions as aM, type FarmSecurityConfig as aN, type ResolvedFarmCspConfig as aO, type FarmAuthConfig as aP, type FarmAuthDatabaseConfig as aQ, type FarmAuthEmailAndPasswordConfig as aR, type FarmAuthSessionConfig as aS, type FarmAuthUserConfig as aT, type PluginRequestContext as aU, type FarmPluginContext as aV, type FarmPluginIntegrationContext as aW, type FarmPluginLifecycle as aX, type FarmRequestPluginContext as aY, type FarmRequestStore as aZ, type FarmPluginRuntimeKind as a_, getFarmLayerAliases as aa, createFarmConfigResolutionPlugin as ab, loadFarmConfigFile as ac, type ReadonlyMiddlewareStore as ad, type FarmMiddlewareConfig as ae, type MiddlewareModule as af, type ResolvedFarmRouteRuntimeConfig as ag, type ResolvedFarmAPIConfig as ah, type ResolvedFarmDevtoolsConfig as ai, type ResolvedFarmDevIndicatorsConfig as aj, type ResolvedFarmAuthConfig as ak, type ResolvedFarmPerformanceConfig as al, type ResolvedFarmSecurityConfig as am, type APIRequestRuntime as an, manageFarmDocumentPreloads as ao, manageFarmHtmlPreloads as ap, manageFarmLinkHeaderPreloads as aq, reportFarmPreloadWarnings as ar, type OpenAPIConfig as as, definePlugin as at, FarmRuntimeShutdownError as au, PluginManager as av, resolveConfig as aw, loadConfig as ax, resolveDeployConfig as ay, resolveMigrationsConfig as az, type FarmRouteRuntime as b, type FarmIntegrationConfigInput as b$, type FarmPluginSetupContext as b0, type FarmPluginStateContext as b1, type FarmPluginRuntimeBaseEvent as b2, type FarmPluginRuntimeContextEvent as b3, type FarmPluginRuntimeBeforeEvent as b4, type FarmPluginRuntimeAfterEvent as b5, type FarmPluginRuntimeErrorEvent as b6, type FarmPluginRuntimeStartEvent as b7, type FarmPluginRuntimeCloseEvent as b8, type FarmPluginRuntimeHooks as b9, type ImageConfig as bA, type I18nConfig as bB, type MiddlewareConfig as bC, type FarmDeployConfig as bD, type ResolvedFarmDeployConfig as bE, type FarmDeployTarget as bF, type FarmIntegrationCategory as bG, type FarmIntegrationSlot as bH, type FarmIntegrationRouteParamValue as bI, type FarmIntegrationRouteParams as bJ, type FarmIntegrationRouteMethod as bK, type FarmIntegrationRouteInputSource as bL, type FarmIntegrationValidationPathSegment as bM, type FarmIntegrationRouteInput as bN, type FarmIntegrationValidationIssue as bO, type FarmIntegrationValidationErrorLike as bP, type FarmIntegrationValidationResult as bQ, type FarmIntegrationStandardValidationResult as bR, type FarmIntegrationInputSchema as bS, type FarmIntegrationRouteInputSchemas as bT, type FarmIntegrationRequestContextStore as bU, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as bV, type FarmIntegrationRouteDb as bW, type FarmIntegrationRouteStorageArgs as bX, type FarmIntegrationRouteArgs as bY, type FarmIntegrationConfigContext as bZ, type FarmIntegrationConfigDefinition as b_, type FarmPluginRuntimeRequestOptions as ba, type FarmPluginRuntimeRequestHandler as bb, type FarmPluginRuntimeSession as bc, type FarmPluginDiscoveredRoute as bd, type FarmPluginRouterHooks as be, type FarmPluginRenderHooks as bf, type FarmPluginBuildHooks as bg, type FarmPluginDevHooks as bh, type FarmPluginClientConfig as bi, type RouteDiscoveredPayload as bj, type RoutesGeneratedPayload as bk, type MiddlewareDiscoveredPayload as bl, type APIRouteDiscoveredPayload as bm, type RouteMatchPayload as bn, type RouteMatchResultPayload as bo, type RenderLifecyclePayload as bp, type APIHandlerLifecyclePayload as bq, type ErrorLifecyclePayload as br, type HMRUpdatePayload as bs, type BundleLifecyclePayload as bt, type NitroBuildLifecyclePayload as bu, type ShutdownPayload as bv, type ResolvedFarmConfig as bw, type RedirectConfig as bx, type HeaderConfig as by, type RewriteConfig as bz, type FarmRouteRegions as c, type CreateIntegrationOrmOptions as c$, type FarmIntegrationLifecycleLogLevel as c0, type FarmIntegrationLifecycleLogger as c1, type FarmIntegrationLifecycleContext as c2, type FarmIntegrationLifecycleHook as c3, type FarmIntegrationData as c4, type FarmIntegrationHandlerContext as c5, type FarmIntegrationRouteHookContext as c6, type FarmIntegrationRouteHook as c7, type FarmIntegrationRoute as c8, type FarmTypedIntegrationRoute as c9, type FarmIntegrationEndpointValue as cA, type FarmIntegrationEndpoints as cB, type FarmIntegrationEndpointsFactoryContext as cC, type FarmIntegrationEndpointsFactory as cD, createIntegrationRoute as cE, integrationRoute as cF, type DefinedIntegration as cG, defineIntegration as cH, isFarmIntegration as cI, resolveIntegrationPlugins as cJ, getIntegrationProviders as cK, isFarmIntegrationProviderComponentReference as cL, getIntegrationDocumentNavigationMatchers as cM, getIntegrationSchemas as cN, getRegisteredIntegrationRuntime as cO, getRegisteredIntegrations as cP, getRegisteredIntegrationSchemas as cQ, matchIntegrationRoute as cR, matchRegisteredIntegrationRoute as cS, getRegisteredIntegrationAPIManifest as cT, dispatchIntegrationRequest as cU, type FarmIntegrationOrmSchema as cV, type FarmIntegrationOrmClient as cW, type InferFarmIntegrationOrmField as cX, type InferFarmIntegrationOrmFields as cY, type InferFarmIntegrationOrmSchema as cZ, type InferFarmIntegrationOrmClient as c_, type FarmIntegrationRouteMiddleware as ca, type FarmIntegrationMiddleware as cb, type FarmIntegrationProviderProps as cc, type FarmIntegrationProviderComponentReference as cd, type FarmIntegrationProvider as ce, type FarmIntegrationDocumentNavigation as cf, type FarmIntegrationSchemaFieldType as cg, type FarmIntegrationSchemaReference as ch, type FarmIntegrationSchemaField as ci, type FarmIntegrationSchemaConstraint as cj, type FarmIntegrationSchemaModel as ck, type FarmIntegrationSchemaModelExtension as cl, type FarmIntegrationSchemaModelOverride as cm, type FarmIntegrationSchema as cn, defineIntegrationSchema as co, type FarmIntegrationLogPhase as cp, type FarmIntegrationLogEvent as cq, type FarmIntegrationLogger as cr, type FarmIntegrationPluginOwner as cs, type FarmIntegrationContributedPlugin as ct, type FarmIntegrationsUserConfig as cu, getFarmIntegrationPluginServerRuntime as cv, getFarmIntegrationPluginOwner as cw, type FarmIntegrationRouteFactory as cx, type FarmIntegrationRoutesFactoryContext as cy, type FarmIntegrationRoutesFactory as cz, type FarmRouteMaxDuration as d, rewriteEarlySsrRelativeImports as d$, createIntegrationOrm as d0, resolveIntegrationOrmRuntimeClient as d1, farmIntegrationSchemaToOrmSchema as d2, type IntegrationOrmModelNames as d3, DEFAULT_FARM_API_BASE_PATH as d4, type FarmAPIConfigResolverContext as d5, type FarmAPIConfigValue as d6, type FarmAPIConfig as d7, resolveFarmAPIConfig as d8, normalizeFarmAPIConfig as d9, routeRulesToHeaders as dA, routeRulesToNitroRouteRules as dB, type FarmRouteRuntimeEntryKind as dC, type FarmRouteRenderingMode as dD, type FarmRouteRuntimeManifestEntry as dE, type FarmRouteRuntimeManifest as dF, normalizeFarmRouteRuntimeConfig as dG, mergeFarmRouteRuntimeConfigs as dH, resolveFarmRouteRuntimeConfig as dI, hasFarmRouteRuntimeControls as dJ, getFarmRouteRuntimeConfig as dK, createFarmRouteRuntimeKey as dL, resolveFarmRouteRuleRuntimeConfig as dM, farmRouteRuleMatches as dN, DEFAULT_FARM_DEVTOOLS_SHORTCUT as dO, FARM_DEVTOOLS_PATH as dP, FARM_DEVTOOLS_LAUNCH_PARAM as dQ, type FarmDevtoolsConfig as dR, type FarmDevtoolsUserConfig as dS, resolveFarmDevtoolsConfig as dT, type FarmBuildActivityPosition as dU, type FarmDevIndicatorsConfig as dV, resolveFarmDevIndicatorsConfig as dW, generateFarmDevIndicatorsClientRuntime as dX, type MiddlewareConfig$1 as dY, farmI18nClientBridgePlugin as dZ, withFarmRequestTracing as d_, normalizeFarmAPIBasePath as da, getFarmAPIBaseURL as db, resolveFarmAPIRequestURL as dc, type MiddlewareContext as dd, type MiddlewareFunction as de, type RequestMiddleware as df, type RequestMiddlewareContext as dg, type MiddlewareStore as dh, type MiddlewareChain as di, type CookieJar as dj, type CookieOptions as dk, type RateLimitConfig as dl, type RateLimitIncrementResult as dm, type RateLimitStorage as dn, type RateLimitStatus as dp, type MemoryRateLimitStorageOptions as dq, type NextFunction as dr, type MiddlewareResult as ds, type FarmRouteRuleRenderMode as dt, type FarmRouteRuleRedirect as du, type FarmRouteRuleCors as dv, type FarmRouteRule as dw, type FarmRouteRules as dx, normalizeRouteRules as dy, routeRulesToRedirects as dz, type FarmAppContext as e, transformIsolatedClientBoundaryModule as e0, generateClientCachePersistenceCode as e1, resolveFarmClientCacheAdapterEntry as e2, type ClientCachePersistenceEntryCode as e3, FARM_NODE_RESPONSE_END_PENDING as e4, type PageProps as f, type PluginContextProps as g, type RouteModule as h, type FarmMdxComponents as i, type FarmMdxResolvedConfig as j, type FarmMdxComponent as k, type FarmMdxUserConfig as l, type FarmUserConfig as m, type FarmContextFactory as n, type MiddlewareProps as o, type FarmIntegration as p, type FarmConfig as q, resolveMdxConfig as r, farmPlugin as s, defineConfig as t, type FarmComponentType as u, type PageRouteParams as v, type FarmMigrationCommand as w, type FarmMigrationsConfig as x, type FarmMigrationsUserConfig as y, type ResolvedFarmMigrationsConfig as z };
|
|
2308
|
+
export { type BuildOptions as $, type AppRoutePattern as A, type BundleResultPayload as B, type FarmContextFactoryInput as C, type FarmIsolatedClientHydrationMode as D, type LoadingProps as E, type FarmRouteRuntimeConfig as F, type ErrorProps as G, type PagePropsWithMiddleware as H, type MetadataProps as I, type LayoutMetadataProps as J, type Page as K, type LayoutProps as L, type Metadata as M, type NitroPreset as N, type Layout as O, type ParsedRoute as P, type Loading as Q, type RouteSegment as R, type ErrorBoundary as S, type StaticPathPrimitive as T, type StaticPathParams as U, type StaticRouteParams as V, type GenerateStaticParams as W, type LayoutModule as X, type FarmRequest as Y, type FarmResponse as Z, type ServerAction as _, type FarmPlugin as a, type FarmPluginRouteRuntimePayload as a$, type SSGPage as a0, type SSGCollectionResult as a1, type FarmLayerEntry as a2, type ResolvedFarmLayer as a3, type FarmSourceRoot as a4, type ResolveFarmLayersOptions as a5, type FarmLayerResolution as a6, resolveFarmLayers as a7, getFarmSourceRoots as a8, getFarmAppDirectories as a9, resolveDeployOutputPath as aA, normalizeDeployTarget as aB, getDeployTargetForPreset as aC, getPresetForDeployTarget as aD, type FarmLayerConfig as aE, type FarmPerformanceConfig as aF, type FarmPreloadMode as aG, type FarmPreloadUserConfig as aH, type ResolvedFarmPreloadConfig as aI, type FarmCspConfig as aJ, type FarmCspDirectives as aK, type FarmCspDirectiveValue as aL, type FarmCspOptions as aM, type FarmSecurityConfig as aN, type ResolvedFarmCspConfig as aO, type FarmAuthConfig as aP, type FarmAuthDatabaseConfig as aQ, type FarmAuthEmailAndPasswordConfig as aR, type FarmAuthSessionConfig as aS, type FarmAuthUserConfig as aT, type PluginRequestContext as aU, type FarmPluginContext as aV, type FarmPluginIntegrationContext as aW, type FarmPluginLifecycle as aX, type FarmRequestPluginContext as aY, type FarmRequestStore as aZ, type FarmPluginRuntimeKind as a_, getFarmLayerAliases as aa, createFarmConfigResolutionPlugin as ab, loadFarmConfigFile as ac, type ReadonlyMiddlewareStore as ad, type FarmMiddlewareConfig as ae, type MiddlewareModule as af, type ResolvedFarmRouteRuntimeConfig as ag, type ResolvedFarmAPIConfig as ah, type ResolvedFarmDevtoolsConfig as ai, type ResolvedFarmDevIndicatorsConfig as aj, type ResolvedFarmAuthConfig as ak, type ResolvedFarmPerformanceConfig as al, type ResolvedFarmSecurityConfig as am, type APIRequestRuntime as an, manageFarmDocumentPreloads as ao, manageFarmHtmlPreloads as ap, manageFarmLinkHeaderPreloads as aq, reportFarmPreloadWarnings as ar, type OpenAPIConfig as as, definePlugin as at, FarmRuntimeShutdownError as au, PluginManager as av, resolveConfig as aw, loadConfig as ax, resolveDeployConfig as ay, resolveMigrationsConfig as az, type FarmRouteRuntime as b, type FarmIntegrationConfigInput as b$, type FarmPluginSetupContext as b0, type FarmPluginStateContext as b1, type FarmPluginRuntimeBaseEvent as b2, type FarmPluginRuntimeContextEvent as b3, type FarmPluginRuntimeBeforeEvent as b4, type FarmPluginRuntimeAfterEvent as b5, type FarmPluginRuntimeErrorEvent as b6, type FarmPluginRuntimeStartEvent as b7, type FarmPluginRuntimeCloseEvent as b8, type FarmPluginRuntimeHooks as b9, type ImageConfig as bA, type I18nConfig as bB, type MiddlewareConfig as bC, type FarmDeployConfig as bD, type ResolvedFarmDeployConfig as bE, type FarmDeployTarget as bF, type FarmIntegrationCategory as bG, type FarmIntegrationSlot as bH, type FarmIntegrationRouteParamValue as bI, type FarmIntegrationRouteParams as bJ, type FarmIntegrationRouteMethod as bK, type FarmIntegrationRouteInputSource as bL, type FarmIntegrationValidationPathSegment as bM, type FarmIntegrationRouteInput as bN, type FarmIntegrationValidationIssue as bO, type FarmIntegrationValidationErrorLike as bP, type FarmIntegrationValidationResult as bQ, type FarmIntegrationStandardValidationResult as bR, type FarmIntegrationInputSchema as bS, type FarmIntegrationRouteInputSchemas as bT, type FarmIntegrationRequestContextStore as bU, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as bV, type FarmIntegrationRouteDb as bW, type FarmIntegrationRouteStorageArgs as bX, type FarmIntegrationRouteArgs as bY, type FarmIntegrationConfigContext as bZ, type FarmIntegrationConfigDefinition as b_, type FarmPluginRuntimeRequestOptions as ba, type FarmPluginRuntimeRequestHandler as bb, type FarmPluginRuntimeSession as bc, type FarmPluginDiscoveredRoute as bd, type FarmPluginRouterHooks as be, type FarmPluginRenderHooks as bf, type FarmPluginBuildHooks as bg, type FarmPluginDevHooks as bh, type FarmPluginClientConfig as bi, type RouteDiscoveredPayload as bj, type RoutesGeneratedPayload as bk, type MiddlewareDiscoveredPayload as bl, type APIRouteDiscoveredPayload as bm, type RouteMatchPayload as bn, type RouteMatchResultPayload as bo, type RenderLifecyclePayload as bp, type APIHandlerLifecyclePayload as bq, type ErrorLifecyclePayload as br, type HMRUpdatePayload as bs, type BundleLifecyclePayload as bt, type NitroBuildLifecyclePayload as bu, type ShutdownPayload as bv, type ResolvedFarmConfig as bw, type RedirectConfig as bx, type HeaderConfig as by, type RewriteConfig as bz, type FarmRouteRegions as c, type FarmIntegrationOrmSchema as c$, type FarmIntegrationLifecycleLogLevel as c0, type FarmIntegrationLifecycleLogger as c1, type FarmIntegrationLifecycleContext as c2, type FarmIntegrationLifecycleHook as c3, type FarmIntegrationData as c4, type FarmIntegrationHandlerContext as c5, type FarmIntegrationRouteHookContext as c6, type FarmIntegrationRouteHook as c7, type FarmIntegrationRoute as c8, type FarmTypedIntegrationRoute as c9, type FarmIntegrationEndpointValue as cA, type FarmIntegrationEndpoints as cB, type FarmIntegrationEndpointsFactoryContext as cC, type FarmIntegrationEndpointsFactory as cD, createIntegrationRoute as cE, integrationRoute as cF, type DefinedIntegration as cG, defineIntegration as cH, isFarmIntegration as cI, resolveIntegrationPlugins as cJ, getIntegrationProviders as cK, isFarmIntegrationProviderComponentReference as cL, getIntegrationDocumentNavigationMatchers as cM, getIntegrationSchemas as cN, getRegisteredIntegrationRuntime as cO, getRegisteredIntegrations as cP, getRegisteredIntegrationSchemas as cQ, matchIntegrationRoute as cR, matchRegisteredIntegrationRoute as cS, getRegisteredIntegrationAPIManifest as cT, dispatchIntegrationRequest as cU, describeIntegrationOriginRejection as cV, resolveIntegrationAllowedOrigins as cW, validateIntegrationRequestOrigin as cX, type IntegrationOriginPolicy as cY, type IntegrationOriginRejection as cZ, type IntegrationOriginResult as c_, type FarmIntegrationRouteMiddleware as ca, type FarmIntegrationMiddleware as cb, type FarmIntegrationProviderProps as cc, type FarmIntegrationProviderComponentReference as cd, type FarmIntegrationProvider as ce, type FarmIntegrationDocumentNavigation as cf, type FarmIntegrationSchemaFieldType as cg, type FarmIntegrationSchemaReference as ch, type FarmIntegrationSchemaField as ci, type FarmIntegrationSchemaConstraint as cj, type FarmIntegrationSchemaModel as ck, type FarmIntegrationSchemaModelExtension as cl, type FarmIntegrationSchemaModelOverride as cm, type FarmIntegrationSchema as cn, defineIntegrationSchema as co, type FarmIntegrationLogPhase as cp, type FarmIntegrationLogEvent as cq, type FarmIntegrationLogger as cr, type FarmIntegrationPluginOwner as cs, type FarmIntegrationContributedPlugin as ct, type FarmIntegrationsUserConfig as cu, getFarmIntegrationPluginServerRuntime as cv, getFarmIntegrationPluginOwner as cw, type FarmIntegrationRouteFactory as cx, type FarmIntegrationRoutesFactoryContext as cy, type FarmIntegrationRoutesFactory as cz, type FarmRouteMaxDuration as d, type FarmDevIndicatorsConfig as d$, type FarmIntegrationOrmClient as d0, type InferFarmIntegrationOrmField as d1, type InferFarmIntegrationOrmFields as d2, type InferFarmIntegrationOrmSchema as d3, type InferFarmIntegrationOrmClient as d4, type CreateIntegrationOrmOptions as d5, createIntegrationOrm as d6, resolveIntegrationOrmRuntimeClient as d7, farmIntegrationSchemaToOrmSchema as d8, type IntegrationOrmModelNames as d9, type FarmRouteRuleRedirect as dA, type FarmRouteRuleCors as dB, type FarmRouteRule as dC, type FarmRouteRules as dD, normalizeRouteRules as dE, routeRulesToRedirects as dF, routeRulesToHeaders as dG, routeRulesToNitroRouteRules as dH, type FarmRouteRuntimeEntryKind as dI, type FarmRouteRenderingMode as dJ, type FarmRouteRuntimeManifestEntry as dK, type FarmRouteRuntimeManifest as dL, normalizeFarmRouteRuntimeConfig as dM, mergeFarmRouteRuntimeConfigs as dN, resolveFarmRouteRuntimeConfig as dO, hasFarmRouteRuntimeControls as dP, getFarmRouteRuntimeConfig as dQ, createFarmRouteRuntimeKey as dR, resolveFarmRouteRuleRuntimeConfig as dS, farmRouteRuleMatches as dT, DEFAULT_FARM_DEVTOOLS_SHORTCUT as dU, FARM_DEVTOOLS_PATH as dV, FARM_DEVTOOLS_LAUNCH_PARAM as dW, type FarmDevtoolsConfig as dX, type FarmDevtoolsUserConfig as dY, resolveFarmDevtoolsConfig as dZ, type FarmBuildActivityPosition as d_, DEFAULT_FARM_API_BASE_PATH as da, type FarmAPIConfigResolverContext as db, type FarmAPIConfigValue as dc, type FarmAPIConfig as dd, resolveFarmAPIConfig as de, normalizeFarmAPIConfig as df, normalizeFarmAPIBasePath as dg, getFarmAPIBaseURL as dh, resolveFarmAPIRequestURL as di, type MiddlewareContext as dj, type MiddlewareFunction as dk, type RequestMiddleware as dl, type RequestMiddlewareContext as dm, type MiddlewareStore as dn, type MiddlewareChain as dp, type CookieJar as dq, type CookieOptions as dr, type RateLimitConfig as ds, type RateLimitIncrementResult as dt, type RateLimitStorage as du, type RateLimitStatus as dv, type MemoryRateLimitStorageOptions as dw, type NextFunction as dx, type MiddlewareResult as dy, type FarmRouteRuleRenderMode as dz, type FarmAppContext as e, resolveFarmDevIndicatorsConfig as e0, generateFarmDevIndicatorsClientRuntime as e1, type MiddlewareConfig$1 as e2, farmI18nClientBridgePlugin as e3, withFarmRequestTracing as e4, rewriteEarlySsrRelativeImports as e5, transformIsolatedClientBoundaryModule as e6, generateClientCachePersistenceCode as e7, resolveFarmClientCacheAdapterEntry as e8, type ClientCachePersistenceEntryCode as e9, FARM_NODE_RESPONSE_END_PENDING as ea, type PageProps as f, type PluginContextProps as g, type RouteModule as h, type FarmMdxComponents as i, type FarmMdxResolvedConfig as j, type FarmMdxComponent as k, type FarmMdxUserConfig as l, type FarmUserConfig as m, type FarmContextFactory as n, type MiddlewareProps as o, type FarmIntegration as p, type FarmConfig as q, resolveMdxConfig as r, farmPlugin as s, defineConfig as t, type FarmComponentType as u, type PageRouteParams as v, type FarmMigrationCommand as w, type FarmMigrationsConfig as x, type FarmMigrationsUserConfig as y, type ResolvedFarmMigrationsConfig as z };
|