@farm.js/core 0.1.22 → 0.1.24
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/agent-runtime.d.mts +3 -2
- package/dist/agent-runtime.d.ts +3 -2
- package/dist/api/route-manager.cjs +3 -2
- package/dist/api/route-manager.d.mts +3 -2
- package/dist/api/route-manager.d.ts +3 -2
- package/dist/api/route-manager.mjs +2 -1
- package/dist/api.cjs +4 -3
- package/dist/api.d.mts +4 -3
- package/dist/api.d.ts +4 -3
- package/dist/api.mjs +3 -2
- package/dist/{app-B7qKw8Ny.d.ts → app-BV-7wV5q.d.ts} +3 -3
- package/dist/{app-0e-oTC_R.d.mts → app-BZDWwwFa.d.mts} +3 -3
- package/dist/app-markdown.d.mts +4 -3
- package/dist/app-markdown.d.ts +4 -3
- package/dist/chunk-2VQKKQ6D.mjs +51 -0
- package/dist/{chunk-EGJDUF4Q.mjs → chunk-3ATMYLLJ.mjs} +6 -12
- package/dist/{chunk-HSDL2AUR.mjs → chunk-47H7VENP.mjs} +20 -32
- package/dist/{chunk-AAWTJW2G.mjs → chunk-6YSEHN46.mjs} +58 -27
- package/dist/{chunk-PUCUVI7K.mjs → chunk-72VJRKJD.mjs} +1 -1
- package/dist/{chunk-PC33YKTC.mjs → chunk-ARHWIOUZ.mjs} +128 -130
- package/dist/{chunk-2HCEC2YO.cjs → chunk-BD7FZ63M.cjs} +1 -1
- package/dist/{chunk-SPSQFO3Z.mjs → chunk-BDJNP7AQ.mjs} +9 -13
- package/dist/{chunk-X2ZUD4GI.mjs → chunk-BNSD3VDY.mjs} +1 -1
- package/dist/{chunk-GXXONIAR.cjs → chunk-DNLQMFER.cjs} +12 -16
- package/dist/{chunk-SO7CRMP6.cjs → chunk-DW34V5SM.cjs} +5 -5
- package/dist/{chunk-3NM6SRI6.mjs → chunk-F3VB7ONA.mjs} +10 -8
- package/dist/{chunk-P5HSJCXI.cjs → chunk-G6GNNB44.cjs} +291 -260
- package/dist/chunk-IK6LVLKC.cjs +51 -0
- package/dist/{chunk-B3WK4DTX.cjs → chunk-IMBMOEWT.cjs} +5 -1
- package/dist/{chunk-IILNZK5G.mjs → chunk-JHWOVJ3M.mjs} +46 -62
- package/dist/{chunk-TKNSDBBN.cjs → chunk-K3F2E6GS.cjs} +20 -1
- package/dist/{chunk-RTHIVJ2G.cjs → chunk-KCMTCM6I.cjs} +7 -8
- package/dist/{chunk-Q3PX2TGL.cjs → chunk-LQIRVSBY.cjs} +30 -40
- package/dist/chunk-LYLEZIG3.cjs +73 -0
- package/dist/{chunk-NBAHDVOJ.cjs → chunk-LYM7HY34.cjs} +20 -32
- package/dist/{chunk-K6FNHVDR.cjs → chunk-MPEYMSCF.cjs} +6 -12
- package/dist/{chunk-BHJUZ64B.cjs → chunk-QTBEAKCJ.cjs} +7 -7
- package/dist/{chunk-J6JRB2ER.mjs → chunk-S67OYZU7.mjs} +1 -1
- package/dist/chunk-SFGWNC43.mjs +97 -0
- package/dist/{chunk-EXUMQVY3.cjs → chunk-SIQMTHCZ.cjs} +258 -260
- package/dist/{chunk-AYJR42WX.cjs → chunk-UFDV5N3C.cjs} +2 -2
- package/dist/chunk-UYIHRDE4.cjs +97 -0
- package/dist/{chunk-Y4YMF2NQ.cjs → chunk-VPTDD5XF.cjs} +46 -62
- package/dist/{chunk-GKT4ONKN.mjs → chunk-VVJCWBIE.mjs} +2 -2
- package/dist/{chunk-CQHFU55R.mjs → chunk-WNUBR4CA.mjs} +5 -1
- package/dist/{chunk-CIAGU2X4.cjs → chunk-XSIRSMAS.cjs} +10 -8
- package/dist/{chunk-ONMW3EVV.mjs → chunk-YGMK6ESJ.mjs} +20 -30
- package/dist/chunk-YOZYCI6Z.mjs +73 -0
- package/dist/{chunk-HLCDYJY7.mjs → chunk-YQVSHTMR.mjs} +20 -1
- package/dist/{chunk-F5D4XEAS.mjs → chunk-ZZSRYEYU.mjs} +7 -8
- package/dist/{client-plugins-CWrhb1ir.d.mts → client-plugins-B_XzCegf.d.mts} +11 -9
- package/dist/{client-plugins-DPf0qZey.d.ts → client-plugins-CKsXQfXY.d.ts} +11 -9
- package/dist/client-plugins.d.mts +3 -2
- package/dist/client-plugins.d.ts +3 -2
- package/dist/client.d.mts +7 -6
- package/dist/client.d.ts +7 -6
- package/dist/config.d.mts +3 -2
- package/dist/config.d.ts +3 -2
- package/dist/{devtools-EZ5ORGAK.mjs → devtools-OY4SNU3P.mjs} +4 -3
- package/dist/{devtools-6DQHO7EK.cjs → devtools-UHRSZ7VA.cjs} +5 -4
- package/dist/docs.cjs +9 -6
- package/dist/docs.mjs +8 -5
- package/dist/index.cjs +23 -20
- package/dist/index.d.mts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/index.mjs +18 -15
- package/dist/instrumentation.cjs +3 -2
- package/dist/instrumentation.mjs +2 -1
- package/dist/integrations.d.mts +3 -2
- package/dist/integrations.d.ts +3 -2
- package/dist/internal/app-markdown-runtime.d.mts +3 -2
- package/dist/internal/app-markdown-runtime.d.ts +3 -2
- package/dist/internal/build-runtime.cjs +17 -14
- package/dist/internal/build-runtime.d.mts +5 -4
- package/dist/internal/build-runtime.d.ts +5 -4
- package/dist/internal/build-runtime.mjs +16 -13
- package/dist/internal/cli-runtime.cjs +10 -7
- package/dist/internal/cli-runtime.mjs +9 -6
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +3 -2
- package/dist/internal/compression-runtime.d.ts +3 -2
- package/dist/internal/config-runtime.cjs +5 -4
- package/dist/internal/config-runtime.d.mts +4 -3
- package/dist/internal/config-runtime.d.ts +4 -3
- package/dist/internal/config-runtime.mjs +4 -3
- package/dist/internal/metadata-image-runtime.cjs +3 -2
- package/dist/internal/metadata-image-runtime.mjs +2 -1
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.d.mts +9 -8
- package/dist/internal/production-runtime.d.ts +9 -8
- package/dist/layers-4PNE2HOY.cjs +18 -0
- package/dist/{layers-CJKSJGLN.mjs → layers-BRQF5ETU.mjs} +2 -1
- package/dist/{manager-NPG43N46.mjs → manager-RT733VRK.mjs} +2 -2
- package/dist/{manager-G4B2IPYE.cjs → manager-XZ5TX7AO.cjs} +3 -3
- package/dist/{metadata-CO9fRyyJ.d.mts → metadata-B08w4EYV.d.mts} +1 -1
- package/dist/{metadata-zY9wltwH.d.ts → metadata-IQEblkZp.d.ts} +1 -1
- package/dist/middleware.d.mts +5 -4
- package/dist/middleware.d.ts +5 -4
- package/dist/navigation.d.mts +6 -5
- package/dist/navigation.d.ts +6 -5
- package/dist/{nitro-TSGDUJMN.cjs → nitro-KQDU7CFE.cjs} +2 -2
- package/dist/{nitro-4LFVTT24.mjs → nitro-ZKLGOTVY.mjs} +1 -1
- package/dist/node-module-bundle-L5L7JCZ4.mjs +11 -0
- package/dist/node-module-bundle-VAFZOXMJ.cjs +11 -0
- package/dist/plugin.cjs +11 -9
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.d.ts +3 -2
- package/dist/plugin.mjs +10 -8
- package/dist/{production-runtime-CywsHwnG.d.mts → production-runtime-C3bGFEaM.d.mts} +1 -1
- package/dist/{production-runtime-lkfwujwK.d.ts → production-runtime-DRSOkc-d.d.ts} +1 -1
- package/dist/{render-plan-LVy6sGQe.d.mts → render-plan-B6CKNl4e.d.mts} +1 -1
- package/dist/{render-plan-DHF0GeWo.d.ts → render-plan-CCFuMLNS.d.ts} +1 -1
- package/dist/renderer-client.d.mts +5 -4
- package/dist/renderer-client.d.ts +5 -4
- package/dist/{request-6AkmhEYE.d.mts → request-DgD1XsTx.d.mts} +1 -1
- package/dist/{request-BYxlRqA9.d.ts → request-Dn6VURbE.d.ts} +1 -1
- package/dist/request.d.mts +4 -3
- package/dist/request.d.ts +4 -3
- package/dist/{route-rendering-Dd8Jmml7.d.mts → route-rendering-76A5I_kE.d.mts} +1 -1
- package/dist/{route-rendering-CWaKiUbS.d.ts → route-rendering-LAmQEdyG.d.ts} +1 -1
- package/dist/{router-B2m4fvve.d.ts → router-BSOOGya2.d.ts} +1 -1
- package/dist/{router-xwEE112q.d.mts → router-CnrRSa9d.d.mts} +1 -1
- package/dist/routes.d.mts +3 -2
- package/dist/routes.d.ts +3 -2
- package/dist/server-plugins.d.mts +4 -3
- package/dist/server-plugins.d.ts +4 -3
- package/dist/server.cjs +39 -26
- package/dist/server.d.mts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.mjs +24 -11
- package/dist/{spa-router-Y8rrXTVK.d.ts → spa-router-BMrSsG5b.d.ts} +2 -2
- package/dist/{spa-router-DVEHQnWo.d.mts → spa-router-DnYhWCvI.d.mts} +2 -2
- package/dist/testing.cjs +2 -1
- package/dist/testing.d.mts +3 -2
- package/dist/testing.d.ts +3 -2
- package/dist/testing.mjs +2 -1
- package/dist/{utils-DSPx34-A.d.mts → utils-ABkktwku.d.mts} +1 -1
- package/dist/{utils-Dvuny_08.d.ts → utils-C3GguS-Q.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +11 -9
- package/dist/vite.d.mts +3 -2
- package/dist/vite.d.ts +3 -2
- package/dist/vite.mjs +10 -8
- package/dist/workflows.cjs +2 -2
- package/dist/workflows.mjs +1 -1
- package/package.json +21 -11
- package/dist/layers-E4WPJNY5.cjs +0 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkXSIRSMAScjs = require('./chunk-XSIRSMAS.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -603,7 +603,7 @@ var _OpenAPIManager = class _OpenAPIManager {
|
|
|
603
603
|
this.appDir = appDirs[appDirs.length - 1];
|
|
604
604
|
this.config = config;
|
|
605
605
|
this.generator = new OpenAPIGenerator(this.appDir, config, context);
|
|
606
|
-
this.apiTypeGenerator = new (0,
|
|
606
|
+
this.apiTypeGenerator = new (0, _chunkXSIRSMAScjs.APITypeGenerator)(appDirs);
|
|
607
607
|
}
|
|
608
608
|
/**
|
|
609
609
|
* Generate OpenAPI spec from API routes
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
4
|
+
|
|
5
|
+
// src/build/node-module-bundle.ts
|
|
6
|
+
var _module = require('module');
|
|
7
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
8
|
+
var _util = require('util');
|
|
9
|
+
var NON_PACKAGE_SPECIFIER_RE = /^(?:[./\\#]|[A-Za-z]:[\\/])/;
|
|
10
|
+
function isPackageSpecifier(specifier) {
|
|
11
|
+
return !specifier.startsWith("\0") && !NON_PACKAGE_SPECIFIER_RE.test(specifier) && !_path2.default.isAbsolute(specifier);
|
|
12
|
+
}
|
|
13
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPackageSpecifier, "isPackageSpecifier");
|
|
14
|
+
var DECLARATION_FILE_RE = /\.d\.(?:[^./\\]+\.)?[cm]?ts$/;
|
|
15
|
+
function isDeclarationFile(id) {
|
|
16
|
+
return DECLARATION_FILE_RE.test(id.split("?", 1)[0]);
|
|
17
|
+
}
|
|
18
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isDeclarationFile, "isDeclarationFile");
|
|
19
|
+
var packageResolvers = /* @__PURE__ */ new Map();
|
|
20
|
+
async function resolvePackageWithoutTsconfig(source, importer, kind) {
|
|
21
|
+
const condition = kind === "require-call" ? "require" : "import";
|
|
22
|
+
let resolver = packageResolvers.get(condition);
|
|
23
|
+
if (!resolver) {
|
|
24
|
+
resolver = import("rolldown/experimental").then(
|
|
25
|
+
({ ResolverFactory }) => new ResolverFactory({
|
|
26
|
+
conditionNames: [condition, "node", "default"],
|
|
27
|
+
mainFields: ["main", "module"]
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
packageResolvers.set(condition, resolver);
|
|
31
|
+
}
|
|
32
|
+
const result = await (await resolver).async(_path2.default.dirname(importer), source);
|
|
33
|
+
return _nullishCoalesce(result.path, () => ( null));
|
|
34
|
+
}
|
|
35
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, resolvePackageWithoutTsconfig, "resolvePackageWithoutTsconfig");
|
|
36
|
+
async function bundleNodeModule(options) {
|
|
37
|
+
const { rolldown } = await import("rolldown");
|
|
38
|
+
const plugins = options.externalPackages ? [externalizePackagesPlugin()] : [];
|
|
39
|
+
plugins.push(..._nullishCoalesce(options.plugins, () => ( [])));
|
|
40
|
+
try {
|
|
41
|
+
const bundle = await rolldown({
|
|
42
|
+
cwd: options.root,
|
|
43
|
+
input: options.entry,
|
|
44
|
+
platform: "node",
|
|
45
|
+
logLevel: "silent",
|
|
46
|
+
external: options.external,
|
|
47
|
+
plugins,
|
|
48
|
+
// Package imports stay external by the path they were found at (as esbuild
|
|
49
|
+
// did), so a workspace symlink is not mistaken for a local alias target.
|
|
50
|
+
resolve: options.externalPackages ? { symlinks: false } : void 0,
|
|
51
|
+
transform: { target: options.target, jsx: { runtime: "automatic" } }
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
await bundle.write({
|
|
55
|
+
file: options.outfile,
|
|
56
|
+
format: "esm",
|
|
57
|
+
sourcemap: "inline",
|
|
58
|
+
codeSplitting: false
|
|
59
|
+
});
|
|
60
|
+
} finally {
|
|
61
|
+
await bundle.close();
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw withPlainDiagnostics(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, bundleNodeModule, "bundleNodeModule");
|
|
68
|
+
function externalizePackagesPlugin() {
|
|
69
|
+
return {
|
|
70
|
+
name: "farm-externalize-packages",
|
|
71
|
+
async resolveId(source, importer, extraOptions) {
|
|
72
|
+
if (!importer || !isPackageSpecifier(source) || _module.isBuiltin.call(void 0, source)) return null;
|
|
73
|
+
const resolved = await this.resolve(source, importer, {
|
|
74
|
+
kind: extraOptions.kind,
|
|
75
|
+
skipSelf: true
|
|
76
|
+
});
|
|
77
|
+
if (resolved && !resolved.external && !resolved.id.startsWith("\0") && !resolved.id.split(/[\\/]/).includes("node_modules") && !isDeclarationFile(resolved.id)) {
|
|
78
|
+
return resolved;
|
|
79
|
+
}
|
|
80
|
+
return { id: source, external: true };
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, externalizePackagesPlugin, "externalizePackagesPlugin");
|
|
85
|
+
function withPlainDiagnostics(error) {
|
|
86
|
+
if (!(error instanceof Error)) return error;
|
|
87
|
+
error.message = _util.stripVTControlCharacters.call(void 0, error.message);
|
|
88
|
+
if (typeof error.stack === "string") error.stack = _util.stripVTControlCharacters.call(void 0, error.stack);
|
|
89
|
+
return error;
|
|
90
|
+
}
|
|
91
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, withPlainDiagnostics, "withPlainDiagnostics");
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
exports.isDeclarationFile = isDeclarationFile; exports.resolvePackageWithoutTsconfig = resolvePackageWithoutTsconfig; exports.bundleNodeModule = bundleNodeModule;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkUYIHRDE4cjs = require('./chunk-UYIHRDE4.cjs');
|
|
6
|
+
|
|
2
7
|
|
|
3
8
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
4
9
|
|
|
@@ -146,62 +151,47 @@ function toExternalSpecifier(resolvedPath) {
|
|
|
146
151
|
return _path2.default.isAbsolute(resolvedPath) ? _url.pathToFileURL.call(void 0, resolvedPath).href : resolvedPath;
|
|
147
152
|
}
|
|
148
153
|
_chunkS3JO3N4Hcjs.__name.call(void 0, toExternalSpecifier, "toExternalSpecifier");
|
|
154
|
+
var BARE_SPECIFIER_RE = /^[^./]/;
|
|
149
155
|
function createFarmConfigResolutionPlugin(options) {
|
|
150
156
|
const configEntryChecks = /* @__PURE__ */ new Map();
|
|
151
157
|
return {
|
|
152
158
|
name: "farm-config-package-resolution",
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
configEntryChecks.set(args.importer, configEntryCheck);
|
|
162
|
-
}
|
|
163
|
-
if (!await configEntryCheck) return;
|
|
164
|
-
const resolved = await pluginBuild.resolve(FARM_CONFIG_ENTRY, {
|
|
165
|
-
importer: args.importer,
|
|
166
|
-
kind: args.kind,
|
|
167
|
-
namespace: args.namespace,
|
|
168
|
-
resolveDir: args.resolveDir,
|
|
169
|
-
pluginData: { farmConfigExternal: true }
|
|
159
|
+
async resolveId(source, importer, extraOptions) {
|
|
160
|
+
if (!importer || extraOptions.isEntry || !BARE_SPECIFIER_RE.test(source) || source.startsWith("\0") || _module.isBuiltin.call(void 0, source) || _path2.default.isAbsolute(source) || WINDOWS_ABSOLUTE_PATH_RE.test(source)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const resolveRuntimePath = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (specifier) => {
|
|
164
|
+
const resolved = await this.resolve(specifier, importer, {
|
|
165
|
+
kind: extraOptions.kind,
|
|
166
|
+
skipSelf: true
|
|
170
167
|
});
|
|
171
|
-
if (resolved
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (args.kind === "entry-point" || _path2.default.isAbsolute(args.path) || WINDOWS_ABSOLUTE_PATH_RE.test(args.path)) {
|
|
180
|
-
return;
|
|
168
|
+
if (!_optionalChain([resolved, 'optionalAccess', _ => _.id]) || !_chunkUYIHRDE4cjs.isDeclarationFile.call(void 0, resolved.id)) return _optionalChain([resolved, 'optionalAccess', _2 => _2.id]);
|
|
169
|
+
return await _asyncNullishCoalesce(await _chunkUYIHRDE4cjs.resolvePackageWithoutTsconfig.call(void 0, specifier, importer, extraOptions.kind), async () => ( void 0));
|
|
170
|
+
}, "resolveRuntimePath");
|
|
171
|
+
if (source === FARM_CORE_PACKAGE && extraOptions.kind === "import-statement") {
|
|
172
|
+
let configEntryCheck = configEntryChecks.get(importer);
|
|
173
|
+
if (!configEntryCheck) {
|
|
174
|
+
configEntryCheck = onlyImportsFarmConfigHelpers(importer, options.transform);
|
|
175
|
+
configEntryChecks.set(importer, configEntryCheck);
|
|
181
176
|
}
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
resolveDir: args.resolveDir,
|
|
188
|
-
pluginData: { farmConfigExternal: true }
|
|
189
|
-
});
|
|
190
|
-
if (resolved.errors.length > 0 || !resolved.path) {
|
|
191
|
-
return { path: args.path, external: true };
|
|
177
|
+
if (await configEntryCheck) {
|
|
178
|
+
const configEntry = await resolveRuntimePath(FARM_CONFIG_ENTRY);
|
|
179
|
+
if (configEntry) {
|
|
180
|
+
return { id: toExternalSpecifier(configEntry), external: true };
|
|
181
|
+
}
|
|
192
182
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
183
|
+
}
|
|
184
|
+
const resolvedId = await resolveRuntimePath(source);
|
|
185
|
+
if (!resolvedId) {
|
|
186
|
+
return { id: source, external: true };
|
|
187
|
+
}
|
|
188
|
+
return { id: toExternalSpecifier(resolvedId), external: true };
|
|
199
189
|
}
|
|
200
190
|
};
|
|
201
191
|
}
|
|
202
192
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmConfigResolutionPlugin, "createFarmConfigResolutionPlugin");
|
|
203
193
|
async function loadFarmConfigFile(configPath, options) {
|
|
204
|
-
const {
|
|
194
|
+
const { transform } = await import("rolldown/utils");
|
|
205
195
|
const cacheRoot = _path2.default.resolve(options.cacheRoot || options.root);
|
|
206
196
|
const configCacheDir = _path2.default.join(cacheRoot, ".farm", ".config-loader");
|
|
207
197
|
await _promises.mkdir.call(void 0, configCacheDir, { recursive: true });
|
|
@@ -209,18 +199,12 @@ async function loadFarmConfigFile(configPath, options) {
|
|
|
209
199
|
configCacheDir,
|
|
210
200
|
`farm-config-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
|
|
211
201
|
);
|
|
212
|
-
await
|
|
213
|
-
|
|
214
|
-
|
|
202
|
+
await _chunkUYIHRDE4cjs.bundleNodeModule.call(void 0, {
|
|
203
|
+
root: _path2.default.resolve(options.root),
|
|
204
|
+
entry: _path2.default.resolve(configPath),
|
|
215
205
|
outfile: modulePath,
|
|
216
|
-
bundle: true,
|
|
217
|
-
format: "esm",
|
|
218
|
-
platform: "node",
|
|
219
206
|
target: `node${process.versions.node.split(".")[0]}`,
|
|
220
|
-
plugins: [createFarmConfigResolutionPlugin({ transform })]
|
|
221
|
-
jsx: "automatic",
|
|
222
|
-
logLevel: "silent",
|
|
223
|
-
sourcemap: "inline"
|
|
207
|
+
plugins: [createFarmConfigResolutionPlugin({ transform })]
|
|
224
208
|
});
|
|
225
209
|
const moduleUrl = `${_url.pathToFileURL.call(void 0, modulePath).href}?t=${Date.now()}`;
|
|
226
210
|
try {
|
|
@@ -242,12 +226,12 @@ async function onlyImportsFarmConfigHelpers(importer, transform) {
|
|
|
242
226
|
try {
|
|
243
227
|
const source = _fs.readFileSync.call(void 0, importer, "utf8");
|
|
244
228
|
if (!source.includes(FARM_CORE_PACKAGE)) return false;
|
|
245
|
-
const transformed = await transform(source, {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
sourcefile: importer
|
|
229
|
+
const transformed = await transform(importer, source, {
|
|
230
|
+
lang: getSourceLang(importer),
|
|
231
|
+
sourceType: "module",
|
|
232
|
+
jsx: { runtime: "automatic" }
|
|
250
233
|
});
|
|
234
|
+
if (transformed.errors.length > 0) return false;
|
|
251
235
|
const references = [...transformed.code.matchAll(FARM_CORE_REFERENCE_RE)];
|
|
252
236
|
if (references.length === 0) return false;
|
|
253
237
|
const safeImportRanges = [];
|
|
@@ -268,7 +252,7 @@ async function onlyImportsFarmConfigHelpers(importer, transform) {
|
|
|
268
252
|
}
|
|
269
253
|
}
|
|
270
254
|
_chunkS3JO3N4Hcjs.__name.call(void 0, onlyImportsFarmConfigHelpers, "onlyImportsFarmConfigHelpers");
|
|
271
|
-
function
|
|
255
|
+
function getSourceLang(file) {
|
|
272
256
|
switch (_path2.default.extname(file)) {
|
|
273
257
|
case ".ts":
|
|
274
258
|
case ".mts":
|
|
@@ -282,7 +266,7 @@ function getEsbuildLoader(file) {
|
|
|
282
266
|
return "js";
|
|
283
267
|
}
|
|
284
268
|
}
|
|
285
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
269
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getSourceLang, "getSourceLang");
|
|
286
270
|
function normalizeLayerEntries(value, owner) {
|
|
287
271
|
if (value === void 0) return [];
|
|
288
272
|
if (!Array.isArray(value)) {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-ZMSZZXOR.mjs";
|
|
7
7
|
import {
|
|
8
8
|
APITypeGenerator
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F3VB7ONA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
mergeRouteRenderingDirectiveConfig
|
|
12
12
|
} from "./chunk-DAO7JGTS.mjs";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
getFarmAppDirectories,
|
|
22
22
|
getFarmSourceRoots
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-JHWOVJ3M.mjs";
|
|
24
24
|
import {
|
|
25
25
|
resolveFarmComponentExtensions
|
|
26
26
|
} from "./chunk-DAATZTKJ.mjs";
|
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
_runWithFarmI18nRequest
|
|
9
9
|
} from "./chunk-JNGIWIY6.mjs";
|
|
10
|
+
import {
|
|
11
|
+
explainMissingOptionalPeer
|
|
12
|
+
} from "./chunk-YOZYCI6Z.mjs";
|
|
10
13
|
import {
|
|
11
14
|
API_ROUTE_METHODS,
|
|
12
15
|
getAllowedAPIRouteMethods,
|
|
@@ -226,7 +229,8 @@ var _APIRouteManager = class _APIRouteManager {
|
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
}
|
|
229
|
-
handleLoadError(message,
|
|
232
|
+
handleLoadError(message, loadError) {
|
|
233
|
+
const error = explainMissingOptionalPeer(loadError, message.replace(/^Error loading /, ""));
|
|
230
234
|
logger.error(`${message}: ${error}`);
|
|
231
235
|
if (this.throwOnLoadError || error instanceof APIRouteConflictError || error instanceof AmbiguousRouteError || error instanceof NonTerminalCatchAllRouteError) {
|
|
232
236
|
throw error;
|
|
@@ -18,13 +18,15 @@ var _module = require('module');
|
|
|
18
18
|
var _path = require('path');
|
|
19
19
|
var _esmodulelexer = require('es-module-lexer');
|
|
20
20
|
var moduleLexerInitialized = false;
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
function transformJSXRoute(content,
|
|
24
|
-
_nullishCoalesce(
|
|
25
|
-
"
|
|
21
|
+
var JSX_ROUTE_LANGS = { ".jsx": "jsx", ".tsx": "tsx" };
|
|
22
|
+
var oxcTransformSync;
|
|
23
|
+
function transformJSXRoute(content, lang, filePath) {
|
|
24
|
+
_nullishCoalesce(oxcTransformSync, () => ( (oxcTransformSync = _module.createRequire.call(void 0, typeof __filename === "string" ? __filename : _chunkS3JO3N4Hcjs.define_import_meta_default.url)(
|
|
25
|
+
"rolldown/utils"
|
|
26
26
|
).transformSync)));
|
|
27
|
-
|
|
27
|
+
const result = oxcTransformSync(filePath, content, { lang, sourceType: "module" });
|
|
28
|
+
if (result.errors.length > 0) throw result.errors[0];
|
|
29
|
+
return result.code;
|
|
28
30
|
}
|
|
29
31
|
_chunkS3JO3N4Hcjs.__name.call(void 0, transformJSXRoute, "transformJSXRoute");
|
|
30
32
|
var API_CLIENT_METHOD_SEGMENTS = /* @__PURE__ */ new Set([
|
|
@@ -121,8 +123,8 @@ var _APITypeGenerator = class _APITypeGenerator {
|
|
|
121
123
|
moduleLexerInitialized = true;
|
|
122
124
|
}
|
|
123
125
|
const httpMethods = ["GET", "HEAD", "QUERY", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
|
|
124
|
-
const
|
|
125
|
-
const source =
|
|
126
|
+
const lang = JSX_ROUTE_LANGS[_path.extname.call(void 0, filePath)];
|
|
127
|
+
const source = lang ? transformJSXRoute(content, lang, filePath) : content;
|
|
126
128
|
const [, exports] = _esmodulelexer.parse.call(void 0, source);
|
|
127
129
|
const valueExports = new Set(
|
|
128
130
|
exports.filter((specifier) => !this.isTypeOnlyExportSpecifier(source, specifier.s)).map((specifier) => specifier.n)
|
|
@@ -3,10 +3,14 @@ import {
|
|
|
3
3
|
loadFarmDocsPage,
|
|
4
4
|
resolveFarmDocsContentDir,
|
|
5
5
|
toFarmDocsMarkdownPage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-47H7VENP.mjs";
|
|
7
|
+
import {
|
|
8
|
+
docsEngine,
|
|
9
|
+
loadFarmDocsEngine
|
|
10
|
+
} from "./chunk-2VQKKQ6D.mjs";
|
|
7
11
|
import {
|
|
8
12
|
resolveDocsConfig
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BDJNP7AQ.mjs";
|
|
10
14
|
import {
|
|
11
15
|
getFarmDocsAdapterConfigModule
|
|
12
16
|
} from "./chunk-VVBO3QH7.mjs";
|
|
@@ -120,21 +124,6 @@ async function createFarmDocsAdapterHandler(docs, options) {
|
|
|
120
124
|
__name(createFarmDocsAdapterHandler, "createFarmDocsAdapterHandler");
|
|
121
125
|
|
|
122
126
|
// src/docs/api.ts
|
|
123
|
-
import {
|
|
124
|
-
buildDocsAgentDiscoverySpec,
|
|
125
|
-
buildDocsConfigMap,
|
|
126
|
-
buildDocsDiagnostics as buildFarmingDocsDiagnostics,
|
|
127
|
-
buildDocsSitemapManifest,
|
|
128
|
-
performDocsSearch,
|
|
129
|
-
renderDocsAgentsDocument,
|
|
130
|
-
renderDocsLlmsTxt,
|
|
131
|
-
renderDocsMarkdownDocument,
|
|
132
|
-
renderDocsRobotsTxt,
|
|
133
|
-
renderDocsSitemapMarkdown,
|
|
134
|
-
renderDocsSitemapXml,
|
|
135
|
-
renderDocsSkillDocument
|
|
136
|
-
} from "@farming-labs/docs";
|
|
137
|
-
import { resolveApiReferenceOpenApiDiscovery } from "@farming-labs/docs/server";
|
|
138
127
|
function isRecord(value) {
|
|
139
128
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
140
129
|
}
|
|
@@ -344,7 +333,7 @@ function getDocsDiscoveryOptions(context, request) {
|
|
|
344
333
|
llms: getDocsLlmsOptions(context, request),
|
|
345
334
|
sitemap: context.docs.config.sitemap ?? true,
|
|
346
335
|
robots: context.docs.config.robots ?? true,
|
|
347
|
-
openapi: resolveApiReferenceOpenApiDiscovery(context.docs.config.apiReference),
|
|
336
|
+
openapi: docsEngine().resolveApiReferenceOpenApiDiscovery(context.docs.config.apiReference),
|
|
348
337
|
markdown: {
|
|
349
338
|
acceptHeader: true,
|
|
350
339
|
signatureAgentHeader: true
|
|
@@ -354,7 +343,7 @@ function getDocsDiscoveryOptions(context, request) {
|
|
|
354
343
|
__name(getDocsDiscoveryOptions, "getDocsDiscoveryOptions");
|
|
355
344
|
function buildSitemapManifest(context, request) {
|
|
356
345
|
const origin = new URL(request.url).origin;
|
|
357
|
-
return buildDocsSitemapManifest({
|
|
346
|
+
return docsEngine().buildDocsSitemapManifest({
|
|
358
347
|
pages: getLoadedDocsPages(context).map(toDocsSitemapPage),
|
|
359
348
|
entry: context.docs.entry,
|
|
360
349
|
siteTitle: getDocsTitle(context.docs),
|
|
@@ -363,7 +352,7 @@ function buildSitemapManifest(context, request) {
|
|
|
363
352
|
}
|
|
364
353
|
__name(buildSitemapManifest, "buildSitemapManifest");
|
|
365
354
|
function renderLlmsTxt(context, request, full) {
|
|
366
|
-
const generated = renderDocsLlmsTxt(
|
|
355
|
+
const generated = docsEngine().renderDocsLlmsTxt(
|
|
367
356
|
getLoadedDocsPages(context).map(toDocsLlmsPage),
|
|
368
357
|
getDocsLlmsOptions(context, request)
|
|
369
358
|
);
|
|
@@ -383,14 +372,14 @@ function renderSkillDocument(context, request) {
|
|
|
383
372
|
"- Sitemap XML: /api/docs?format=sitemap-xml",
|
|
384
373
|
"- Agent spec JSON: /api/docs/agent/spec"
|
|
385
374
|
].join("\n");
|
|
386
|
-
return `${renderDocsSkillDocument(getDocsDiscoveryOptions(context, request)).trim()}
|
|
375
|
+
return `${docsEngine().renderDocsSkillDocument(getDocsDiscoveryOptions(context, request)).trim()}
|
|
387
376
|
|
|
388
377
|
${farmAliases}
|
|
389
378
|
`;
|
|
390
379
|
}
|
|
391
380
|
__name(renderSkillDocument, "renderSkillDocument");
|
|
392
381
|
function renderAgentsDocument(context, request) {
|
|
393
|
-
return `${renderDocsAgentsDocument(getDocsDiscoveryOptions(context, request)).trim()}
|
|
382
|
+
return `${docsEngine().renderDocsAgentsDocument(getDocsDiscoveryOptions(context, request)).trim()}
|
|
394
383
|
`;
|
|
395
384
|
}
|
|
396
385
|
__name(renderAgentsDocument, "renderAgentsDocument");
|
|
@@ -398,7 +387,7 @@ function buildAgentSpec(context, request) {
|
|
|
398
387
|
const url = new URL(request.url);
|
|
399
388
|
const origin = url.origin;
|
|
400
389
|
const pages = discoverFarmDocsPages(context.contentDir, context.docs);
|
|
401
|
-
const spec = buildDocsAgentDiscoverySpec(getDocsDiscoveryOptions(context, request));
|
|
390
|
+
const spec = docsEngine().buildDocsAgentDiscoverySpec(getDocsDiscoveryOptions(context, request));
|
|
402
391
|
const title = getDocsTitle(context.docs);
|
|
403
392
|
return {
|
|
404
393
|
...spec,
|
|
@@ -440,7 +429,7 @@ function buildAgentSpec(context, request) {
|
|
|
440
429
|
__name(buildAgentSpec, "buildAgentSpec");
|
|
441
430
|
function buildDiagnostics(context) {
|
|
442
431
|
const pages = discoverFarmDocsPages(context.contentDir, context.docs);
|
|
443
|
-
const diagnostics =
|
|
432
|
+
const diagnostics = docsEngine().buildDocsDiagnostics(context.docs.config, {
|
|
444
433
|
entry: context.docs.entry,
|
|
445
434
|
mcp: {
|
|
446
435
|
enabled: false,
|
|
@@ -477,7 +466,7 @@ async function searchDocs(context, request, query) {
|
|
|
477
466
|
const sourcePages = loadedPages.map(toDocsSourcePage);
|
|
478
467
|
const sourcePageByUrl = new Map(sourcePages.map((page) => [page.url, page]));
|
|
479
468
|
const resultLimit = isRecord(context.docs.config.search) && typeof context.docs.config.search.maxResults === "number" ? context.docs.config.search.maxResults : void 0;
|
|
480
|
-
const results = await performDocsSearch({
|
|
469
|
+
const results = await docsEngine().performDocsSearch({
|
|
481
470
|
pages: sourcePages,
|
|
482
471
|
query,
|
|
483
472
|
search: context.docs.config.search ?? true,
|
|
@@ -498,6 +487,7 @@ async function searchDocs(context, request, query) {
|
|
|
498
487
|
}
|
|
499
488
|
__name(searchDocs, "searchDocs");
|
|
500
489
|
async function resolveAPIContext(options) {
|
|
490
|
+
await loadFarmDocsEngine();
|
|
501
491
|
const runtimeConfig = globalThis.__FARM_DOCS_RUNTIME_CONFIG__;
|
|
502
492
|
const root = options.rootDir || options.root || runtimeConfig?.root || process.cwd();
|
|
503
493
|
const srcDir = options.srcDir || runtimeConfig?.srcDir || "src";
|
|
@@ -531,7 +521,7 @@ async function handleDocsAPIGet(request, context) {
|
|
|
531
521
|
entry: context.docs.entry,
|
|
532
522
|
contentDir: context.docs.contentDir || context.docs.config.contentDir || null,
|
|
533
523
|
config: context.docs.config,
|
|
534
|
-
map: buildDocsConfigMap(context.docs.config, {
|
|
524
|
+
map: docsEngine().buildDocsConfigMap(context.docs.config, {
|
|
535
525
|
file: context.docs.configPath || "farm.config.ts"
|
|
536
526
|
})
|
|
537
527
|
});
|
|
@@ -548,7 +538,7 @@ async function handleDocsAPIGet(request, context) {
|
|
|
548
538
|
return text(renderLlmsTxt(context, request, true), "text/plain; charset=utf-8");
|
|
549
539
|
if (format === "sitemap-md") {
|
|
550
540
|
return text(
|
|
551
|
-
renderDocsSitemapMarkdown(buildSitemapManifest(context, request), {
|
|
541
|
+
docsEngine().renderDocsSitemapMarkdown(buildSitemapManifest(context, request), {
|
|
552
542
|
includeDescriptions: true
|
|
553
543
|
}),
|
|
554
544
|
"text/markdown; charset=utf-8"
|
|
@@ -557,7 +547,7 @@ async function handleDocsAPIGet(request, context) {
|
|
|
557
547
|
if (format === "sitemap-xml" || format === "sitemap") {
|
|
558
548
|
const origin = new URL(request.url).origin;
|
|
559
549
|
return text(
|
|
560
|
-
renderDocsSitemapXml(buildSitemapManifest(context, request), {
|
|
550
|
+
docsEngine().renderDocsSitemapXml(buildSitemapManifest(context, request), {
|
|
561
551
|
baseUrl: origin,
|
|
562
552
|
includeLastmod: true
|
|
563
553
|
}),
|
|
@@ -566,7 +556,7 @@ async function handleDocsAPIGet(request, context) {
|
|
|
566
556
|
}
|
|
567
557
|
if (format === "robots") {
|
|
568
558
|
return text(
|
|
569
|
-
renderDocsRobotsTxt({
|
|
559
|
+
docsEngine().renderDocsRobotsTxt({
|
|
570
560
|
entry: context.docs.entry,
|
|
571
561
|
sitemap: context.docs.config.sitemap ?? true,
|
|
572
562
|
robots: context.docs.config.robots ?? true,
|
|
@@ -581,7 +571,7 @@ async function handleDocsAPIGet(request, context) {
|
|
|
581
571
|
const page = loadFarmDocsPage(context.contentDir, context.docs, slug);
|
|
582
572
|
if (!page) return text("Docs page not found\n", "text/plain; charset=utf-8", { status: 404 });
|
|
583
573
|
return text(
|
|
584
|
-
renderDocsMarkdownDocument(toFarmDocsMarkdownPage(page), {
|
|
574
|
+
docsEngine().renderDocsMarkdownDocument(toFarmDocsMarkdownPage(page), {
|
|
585
575
|
origin: new URL(request.url).origin,
|
|
586
576
|
llms: getDocsLlmsOptions(context, request),
|
|
587
577
|
sitemap: context.docs.config.sitemap
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-LPEX4YW6.mjs";
|
|
4
|
+
|
|
5
|
+
// src/optional-peer.ts
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
import path from "path";
|
|
8
|
+
function isMissingPackageError(error, packageName) {
|
|
9
|
+
let current = error;
|
|
10
|
+
for (let depth = 0; depth < 4; depth++) {
|
|
11
|
+
if (!current || typeof current !== "object") return false;
|
|
12
|
+
const { code, message, cause } = current;
|
|
13
|
+
if ((code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") && typeof message === "string") {
|
|
14
|
+
return message.includes(`'${packageName}'`) || message.includes(`"${packageName}"`);
|
|
15
|
+
}
|
|
16
|
+
current = cause;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
__name(isMissingPackageError, "isMissingPackageError");
|
|
21
|
+
function isOptionalPeerInstalled(root, packageName) {
|
|
22
|
+
const appRequire = createRequire(path.join(root, "package.json"));
|
|
23
|
+
const requires = [appRequire];
|
|
24
|
+
try {
|
|
25
|
+
requires.push(createRequire(appRequire.resolve("@farm.js/core")));
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
return requires.some((parentRequire) => {
|
|
29
|
+
try {
|
|
30
|
+
parentRequire.resolve(`${packageName}/package.json`);
|
|
31
|
+
return true;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
__name(isOptionalPeerInstalled, "isOptionalPeerInstalled");
|
|
38
|
+
function formatOptionalPeerInstallHint(packageName, purpose, options = {}) {
|
|
39
|
+
return `Install "${packageName}" to ${purpose}: pnpm add ${options.dev ? "-D " : ""}${packageName}`;
|
|
40
|
+
}
|
|
41
|
+
__name(formatOptionalPeerInstallHint, "formatOptionalPeerInstallHint");
|
|
42
|
+
var VERCEL_OG_INSTALL_HINT = formatOptionalPeerInstallHint(
|
|
43
|
+
"@vercel/og",
|
|
44
|
+
"render OG and metadata images"
|
|
45
|
+
);
|
|
46
|
+
var APP_IMPORTED_OPTIONAL_PEERS = [
|
|
47
|
+
["@vercel/og", VERCEL_OG_INSTALL_HINT]
|
|
48
|
+
];
|
|
49
|
+
function explainMissingOptionalPeer(error, context) {
|
|
50
|
+
for (const [packageName, hint] of APP_IMPORTED_OPTIONAL_PEERS) {
|
|
51
|
+
if (isMissingPackageError(error, packageName)) {
|
|
52
|
+
return withOptionalPeerCause(
|
|
53
|
+
new Error(`${context} needs ${packageName}, which is not installed. ${hint}`),
|
|
54
|
+
error
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return error;
|
|
59
|
+
}
|
|
60
|
+
__name(explainMissingOptionalPeer, "explainMissingOptionalPeer");
|
|
61
|
+
function withOptionalPeerCause(error, cause) {
|
|
62
|
+
return Object.assign(error, { cause });
|
|
63
|
+
}
|
|
64
|
+
__name(withOptionalPeerCause, "withOptionalPeerCause");
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
isMissingPackageError,
|
|
68
|
+
isOptionalPeerInstalled,
|
|
69
|
+
formatOptionalPeerInstallHint,
|
|
70
|
+
VERCEL_OG_INSTALL_HINT,
|
|
71
|
+
explainMissingOptionalPeer,
|
|
72
|
+
withOptionalPeerCause
|
|
73
|
+
};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VERCEL_OG_INSTALL_HINT,
|
|
3
|
+
isMissingPackageError,
|
|
4
|
+
withOptionalPeerCause
|
|
5
|
+
} from "./chunk-YOZYCI6Z.mjs";
|
|
1
6
|
import {
|
|
2
7
|
omitFarmResponseBody
|
|
3
8
|
} from "./chunk-5WI2S4CO.mjs";
|
|
@@ -141,6 +146,20 @@ async function finalizeMetadataImageResponse(body, headers, options) {
|
|
|
141
146
|
});
|
|
142
147
|
}
|
|
143
148
|
__name(finalizeMetadataImageResponse, "finalizeMetadataImageResponse");
|
|
149
|
+
async function loadVercelOg() {
|
|
150
|
+
try {
|
|
151
|
+
return await import("@vercel/og");
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (!isMissingPackageError(error, "@vercel/og")) throw error;
|
|
154
|
+
throw withOptionalPeerCause(
|
|
155
|
+
new Error(
|
|
156
|
+
`Rendering a metadata image from JSX needs @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
157
|
+
),
|
|
158
|
+
error
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
__name(loadVercelOg, "loadVercelOg");
|
|
144
163
|
async function createFarmMetadataImageResponse(value, imageModule, options = {}) {
|
|
145
164
|
const method = (options.method || "GET").toUpperCase();
|
|
146
165
|
if (method !== "GET" && method !== "HEAD") {
|
|
@@ -152,7 +171,7 @@ async function createFarmMetadataImageResponse(value, imageModule, options = {})
|
|
|
152
171
|
const cacheControl = resolveCacheControl(imageModule.revalidate);
|
|
153
172
|
const explicitContentType = imageModule.contentType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
154
173
|
if (isReactElement(value) && explicitContentType !== "image/svg+xml") {
|
|
155
|
-
const { ImageResponse } = await
|
|
174
|
+
const { ImageResponse } = await loadVercelOg();
|
|
156
175
|
const element = await prepareMetadataImageNode(value);
|
|
157
176
|
const response = new ImageResponse(element, {
|
|
158
177
|
width: imageModule.size?.width || 1200,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bundleNodeModule
|
|
3
|
+
} from "./chunk-SFGWNC43.mjs";
|
|
1
4
|
import {
|
|
2
5
|
__name
|
|
3
6
|
} from "./chunk-LPEX4YW6.mjs";
|
|
4
7
|
|
|
5
8
|
// src/instrumentation.ts
|
|
6
|
-
import { build } from "esbuild";
|
|
7
9
|
import fs from "fs";
|
|
8
10
|
import path from "path";
|
|
9
11
|
import { pathToFileURL } from "url";
|
|
@@ -32,15 +34,12 @@ async function loadFarmInstrumentation(filePath, root) {
|
|
|
32
34
|
const outputDirectory = path.join(root, ".farm", ".instrumentation-loader");
|
|
33
35
|
const outputFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
34
36
|
await fs.promises.mkdir(outputDirectory, { recursive: true });
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
+
await bundleNodeModule({
|
|
38
|
+
root,
|
|
39
|
+
entry: filePath,
|
|
37
40
|
outfile: outputFile,
|
|
38
|
-
bundle: true,
|
|
39
|
-
format: "esm",
|
|
40
|
-
platform: "node",
|
|
41
41
|
target: "node20",
|
|
42
|
-
|
|
43
|
-
sourcemap: "inline"
|
|
42
|
+
externalPackages: true
|
|
44
43
|
});
|
|
45
44
|
const url = pathToFileURL(outputFile);
|
|
46
45
|
url.searchParams.set("t", String(Date.now()));
|