@farming-labs/next 0.2.117 → 0.2.119
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/api-reference.d.mts +1 -1
- package/dist/api-reference.mjs +51 -41
- package/dist/changelog.mjs +9 -1
- package/dist/config.mjs +16 -0
- package/dist/fumadocs-api-page.d.mts +8 -0
- package/dist/fumadocs-api-page.mjs +35 -0
- package/dist/layout.mjs +1 -1
- package/package.json +6 -6
package/dist/api-reference.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocsConfig } from "@farming-labs/docs";
|
|
2
|
-
import { resolveApiReferenceConfig } from "@farming-labs/docs/
|
|
2
|
+
import { resolveApiReferenceConfig } from "@farming-labs/docs/runtime";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/api-reference.d.ts
|
package/dist/api-reference.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import DocsClientCallbacks from "./client-callbacks.mjs";
|
|
2
|
+
import FumadocsOpenAPIPage from "./fumadocs-api-page.mjs";
|
|
2
3
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
4
|
import { join, relative } from "node:path";
|
|
4
5
|
import { resolveDocsMetadataBaseUrl } from "@farming-labs/docs";
|
|
5
|
-
import { buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, createApiReferenceOperationMarkdownResponse, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveApiReferenceVersion, resolveApiReferenceVersionFromPathname } from "@farming-labs/docs/server";
|
|
6
6
|
import { ApiReference } from "@scalar/nextjs-api-reference";
|
|
7
|
+
import { buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, createApiReferenceOperationMarkdownResponse, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveApiReferenceVersion, resolveApiReferenceVersionFromPathname } from "@farming-labs/docs/runtime";
|
|
7
8
|
import { SidebarTabsDropdown } from "fumadocs-ui/components/sidebar/tabs/dropdown";
|
|
8
9
|
import Link from "next/link";
|
|
9
10
|
import { notFound } from "next/navigation";
|
|
@@ -13,7 +14,15 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
13
14
|
const ROUTE_FILE_RE = /^route\.(ts|tsx|js|jsx)$/;
|
|
14
15
|
const METHOD_RE = /export\s+(?:async\s+function|function|const)\s+(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\b/g;
|
|
15
16
|
function getNextAppDir(root) {
|
|
16
|
-
if (existsSync(
|
|
17
|
+
if (existsSync(
|
|
18
|
+
/* turbopackIgnore: true */
|
|
19
|
+
join(
|
|
20
|
+
/* turbopackIgnore: true */
|
|
21
|
+
root,
|
|
22
|
+
"src",
|
|
23
|
+
"app"
|
|
24
|
+
)
|
|
25
|
+
)) return "src/app";
|
|
17
26
|
return "app";
|
|
18
27
|
}
|
|
19
28
|
function normalizeRouteRoot(value) {
|
|
@@ -31,8 +40,17 @@ function getRoutePathBase(config) {
|
|
|
31
40
|
}
|
|
32
41
|
function resolveNextApiRouteRoot(root, config) {
|
|
33
42
|
const routeRoot = normalizeRouteRoot(config.routeRoot);
|
|
34
|
-
if (routeRoot === "app" || routeRoot.startsWith("app/") || routeRoot === "src/app" || routeRoot.startsWith("src/app/")) return join(
|
|
35
|
-
|
|
43
|
+
if (routeRoot === "app" || routeRoot.startsWith("app/") || routeRoot === "src/app" || routeRoot.startsWith("src/app/")) return join(
|
|
44
|
+
/* turbopackIgnore: true */
|
|
45
|
+
root,
|
|
46
|
+
...routeRoot.split("/")
|
|
47
|
+
);
|
|
48
|
+
return join(
|
|
49
|
+
/* turbopackIgnore: true */
|
|
50
|
+
root,
|
|
51
|
+
getNextAppDir(root),
|
|
52
|
+
...routeRoot.split("/")
|
|
53
|
+
);
|
|
36
54
|
}
|
|
37
55
|
function shouldExcludeRoute(excludes, routePath, relativeFile, relativeDir) {
|
|
38
56
|
if (excludes.length === 0) return false;
|
|
@@ -78,11 +96,24 @@ function extractMethods(source) {
|
|
|
78
96
|
return Array.from(methods);
|
|
79
97
|
}
|
|
80
98
|
function scanRouteFiles(dir) {
|
|
81
|
-
if (!existsSync(
|
|
99
|
+
if (!existsSync(
|
|
100
|
+
/* turbopackIgnore: true */
|
|
101
|
+
dir
|
|
102
|
+
)) return [];
|
|
82
103
|
const results = [];
|
|
83
|
-
for (const name of readdirSync(
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
for (const name of readdirSync(
|
|
105
|
+
/* turbopackIgnore: true */
|
|
106
|
+
dir
|
|
107
|
+
)) {
|
|
108
|
+
const full = join(
|
|
109
|
+
/* turbopackIgnore: true */
|
|
110
|
+
dir,
|
|
111
|
+
name
|
|
112
|
+
);
|
|
113
|
+
if (statSync(
|
|
114
|
+
/* turbopackIgnore: true */
|
|
115
|
+
full
|
|
116
|
+
).isDirectory()) {
|
|
86
117
|
results.push(...scanRouteFiles(full));
|
|
87
118
|
continue;
|
|
88
119
|
}
|
|
@@ -160,7 +191,11 @@ function buildApiReferenceRoutes(config) {
|
|
|
160
191
|
const excludes = apiReference.exclude;
|
|
161
192
|
const routes = [];
|
|
162
193
|
for (const file of files) {
|
|
163
|
-
const source = readFileSync(
|
|
194
|
+
const source = readFileSync(
|
|
195
|
+
/* turbopackIgnore: true */
|
|
196
|
+
file,
|
|
197
|
+
"utf-8"
|
|
198
|
+
);
|
|
164
199
|
const methods = extractMethods(source);
|
|
165
200
|
if (methods.length === 0) continue;
|
|
166
201
|
const relativeFile = relative(apiDir, file).replace(/\\/g, "/");
|
|
@@ -503,30 +538,6 @@ function flattenApiReferencePageTreeForSidebar(tree) {
|
|
|
503
538
|
children: nextChildren
|
|
504
539
|
};
|
|
505
540
|
}
|
|
506
|
-
function renderApiReferenceOperationLayout(slots) {
|
|
507
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
508
|
-
className: "fd-api-reference-operation",
|
|
509
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
510
|
-
className: "fd-api-reference-operation-main",
|
|
511
|
-
children: [
|
|
512
|
-
slots.header,
|
|
513
|
-
slots.apiPlayground,
|
|
514
|
-
slots.description ? /* @__PURE__ */ jsx("div", {
|
|
515
|
-
className: "fd-api-reference-operation-description",
|
|
516
|
-
children: slots.description
|
|
517
|
-
}) : null,
|
|
518
|
-
slots.authSchemes,
|
|
519
|
-
slots.parameters,
|
|
520
|
-
slots.body,
|
|
521
|
-
slots.responses,
|
|
522
|
-
slots.callbacks
|
|
523
|
-
]
|
|
524
|
-
}), slots.apiExample ? /* @__PURE__ */ jsx("div", {
|
|
525
|
-
className: "fd-api-reference-operation-example",
|
|
526
|
-
children: slots.apiExample
|
|
527
|
-
}) : null]
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
541
|
function withNextApiReferenceBanner(config) {
|
|
531
542
|
const apiReference = resolveApiReferenceConfig(config.apiReference);
|
|
532
543
|
if (!apiReference.enabled) return config;
|
|
@@ -617,11 +628,11 @@ function getOpenApiInfo(document) {
|
|
|
617
628
|
}
|
|
618
629
|
function createNextApiReferencePage(config) {
|
|
619
630
|
return async function NextApiReferencePage(props) {
|
|
620
|
-
const
|
|
631
|
+
const { DocsDescription, DocsPage, DocsTitle } = await import("fumadocs-ui/layouts/notebook/page");
|
|
621
632
|
const slug = (props?.params ? await props.params : void 0)?.slug ?? [];
|
|
622
633
|
const version = resolveApiReferenceVersion(resolveApiReferenceConfig(config.apiReference), slug[0]);
|
|
623
634
|
const pageSlug = version ? slug.slice(1) : slug;
|
|
624
|
-
const { info, pages,
|
|
635
|
+
const { info, pages, source } = await getNextApiReferenceSourceState(config, version?.id);
|
|
625
636
|
if (pages.length === 0) return /* @__PURE__ */ jsxs(DocsPage, {
|
|
626
637
|
full: true,
|
|
627
638
|
children: [
|
|
@@ -637,8 +648,7 @@ function createNextApiReferencePage(config) {
|
|
|
637
648
|
]
|
|
638
649
|
});
|
|
639
650
|
const page = pageSlug.length === 0 ? pages[0] : source.getPage(pageSlug);
|
|
640
|
-
if (!page || typeof page.data?.
|
|
641
|
-
const APIPage = createAPIPage(server, { content: { renderOperationLayout: renderApiReferenceOperationLayout } });
|
|
651
|
+
if (!page || typeof page.data?.getOpenAPIPageProps !== "function") notFound();
|
|
642
652
|
const currentPageIndex = pageSlug.length === 0 ? 0 : pages.findIndex((entry) => entry.url === page.url);
|
|
643
653
|
const previousPage = currentPageIndex > 0 ? pages[currentPageIndex - 1] : void 0;
|
|
644
654
|
const nextPage = currentPageIndex >= 0 && currentPageIndex < pages.length - 1 ? pages[currentPageIndex + 1] : void 0;
|
|
@@ -652,7 +662,7 @@ function createNextApiReferencePage(config) {
|
|
|
652
662
|
/* @__PURE__ */ jsx(DocsDescription, { children: typeof page.data.description === "string" && page.data.description.trim() ? page.data.description : info.description }),
|
|
653
663
|
/* @__PURE__ */ jsx("div", {
|
|
654
664
|
className: "fd-api-reference-body",
|
|
655
|
-
children: /* @__PURE__ */ jsx(
|
|
665
|
+
children: /* @__PURE__ */ jsx(FumadocsOpenAPIPage, { ...page.data.getOpenAPIPageProps() })
|
|
656
666
|
}),
|
|
657
667
|
previousPage || nextPage ? /* @__PURE__ */ jsxs("nav", {
|
|
658
668
|
className: "fd-api-reference-pagination",
|
|
@@ -756,14 +766,14 @@ async function getNextApiReferenceSourceState(config, versionId) {
|
|
|
756
766
|
baseUrl,
|
|
757
767
|
version: version?.id
|
|
758
768
|
});
|
|
759
|
-
const server = createOpenAPI({ input:
|
|
769
|
+
const server = createOpenAPI({ input: { main: document } });
|
|
760
770
|
const info = getOpenApiInfo(document);
|
|
761
771
|
const source = loader(await openapiSource(server, {
|
|
762
772
|
per: "operation",
|
|
763
773
|
groupBy: "tag",
|
|
764
|
-
name(output
|
|
774
|
+
name(output) {
|
|
765
775
|
if (output.type !== "operation") return slugifyApiReferencePageName(output.item.name);
|
|
766
|
-
const operation = (
|
|
776
|
+
const operation = (this.document?.paths?.[output.item.path])?.[output.item.method];
|
|
767
777
|
return slugifyApiReferencePageName(typeof operation?.summary === "string" && operation.summary.trim() ? operation.summary : typeof operation?.operationId === "string" && operation.operationId.trim() ? operation.operationId : `${output.item.method} ${output.item.path}`);
|
|
768
778
|
}
|
|
769
779
|
}), {
|
package/dist/changelog.mjs
CHANGED
|
@@ -42,7 +42,15 @@ function truncatePaginationDescription(value, maxLength = 110) {
|
|
|
42
42
|
}
|
|
43
43
|
function extractChangelogToc(sourcePath) {
|
|
44
44
|
try {
|
|
45
|
-
return collectDocsMarkdownSections(readFileSync(
|
|
45
|
+
return collectDocsMarkdownSections(readFileSync(
|
|
46
|
+
/* turbopackIgnore: true */
|
|
47
|
+
join(
|
|
48
|
+
/* turbopackIgnore: true */
|
|
49
|
+
process.cwd(),
|
|
50
|
+
sourcePath
|
|
51
|
+
),
|
|
52
|
+
"utf-8"
|
|
53
|
+
)).filter((heading) => heading.level >= 2 && heading.level <= 4 && heading.heading).map((heading) => ({
|
|
46
54
|
title: heading.heading,
|
|
47
55
|
url: `#${encodeURIComponent(heading.id)}`,
|
|
48
56
|
depth: heading.level
|
package/dist/config.mjs
CHANGED
|
@@ -2208,6 +2208,7 @@ function withDocs(nextConfig = {}, docsConfig) {
|
|
|
2208
2208
|
return resolvedConfig;
|
|
2209
2209
|
};
|
|
2210
2210
|
const existingTracingIncludes = nextConfig.outputFileTracingIncludes ?? {};
|
|
2211
|
+
const existingTracingExcludes = nextConfig.outputFileTracingExcludes ?? {};
|
|
2211
2212
|
const docsTraceGlob = docsContentDir.replace(/\\/g, "/").replace(/^\.?\//, "") + "/**/*";
|
|
2212
2213
|
const sitemapManifestTraceFile = DEFAULT_SITEMAP_MANIFEST_PATH;
|
|
2213
2214
|
const docsContentRoot = isAbsolute(docsContentDir) ? docsContentDir : join(root, docsContentDir);
|
|
@@ -2233,6 +2234,21 @@ function withDocs(nextConfig = {}, docsConfig) {
|
|
|
2233
2234
|
])],
|
|
2234
2235
|
[DEFAULT_MCP_ROUTE]: [...new Set([...existingTracingIncludes[DEFAULT_MCP_ROUTE] ?? [], docsTraceGlob])]
|
|
2235
2236
|
};
|
|
2237
|
+
nextConfig.outputFileTracingExcludes = {
|
|
2238
|
+
...existingTracingExcludes,
|
|
2239
|
+
"/api/docs": [...new Set([
|
|
2240
|
+
...existingTracingExcludes["/api/docs"] ?? [],
|
|
2241
|
+
"next.config.js",
|
|
2242
|
+
"next.config.mjs",
|
|
2243
|
+
"next.config.ts"
|
|
2244
|
+
])],
|
|
2245
|
+
[DEFAULT_MCP_ROUTE]: [...new Set([
|
|
2246
|
+
...existingTracingExcludes[DEFAULT_MCP_ROUTE] ?? [],
|
|
2247
|
+
"next.config.js",
|
|
2248
|
+
"next.config.mjs",
|
|
2249
|
+
"next.config.ts"
|
|
2250
|
+
])]
|
|
2251
|
+
};
|
|
2236
2252
|
return withMDX(nextConfig);
|
|
2237
2253
|
}
|
|
2238
2254
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react from "react";
|
|
2
|
+
import * as fumadocs_openapi_ui0 from "fumadocs-openapi/ui";
|
|
3
|
+
|
|
4
|
+
//#region src/fumadocs-api-page.d.ts
|
|
5
|
+
/** Client boundary for Fumadocs OpenAPI's interactive renderer. */
|
|
6
|
+
declare const FumadocsOpenAPIPage: react.FC<fumadocs_openapi_ui0.OpenAPIPageProps>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { FumadocsOpenAPIPage as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { createOpenAPIPage } from "fumadocs-openapi/ui";
|
|
5
|
+
|
|
6
|
+
//#region src/fumadocs-api-page.tsx
|
|
7
|
+
function renderApiReferenceOperationLayout(slots) {
|
|
8
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
9
|
+
className: "fd-api-reference-operation",
|
|
10
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
11
|
+
className: "fd-api-reference-operation-main",
|
|
12
|
+
children: [
|
|
13
|
+
slots.header,
|
|
14
|
+
slots.apiPlayground,
|
|
15
|
+
slots.description ? /* @__PURE__ */ jsx("div", {
|
|
16
|
+
className: "fd-api-reference-operation-description",
|
|
17
|
+
children: slots.description
|
|
18
|
+
}) : null,
|
|
19
|
+
slots.authSchemes,
|
|
20
|
+
slots.parameters,
|
|
21
|
+
slots.body,
|
|
22
|
+
slots.responses,
|
|
23
|
+
slots.callbacks
|
|
24
|
+
]
|
|
25
|
+
}), slots.apiExample ? /* @__PURE__ */ jsx("div", {
|
|
26
|
+
className: "fd-api-reference-operation-example",
|
|
27
|
+
children: slots.apiExample
|
|
28
|
+
}) : null]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Client boundary for Fumadocs OpenAPI's interactive renderer. */
|
|
32
|
+
const FumadocsOpenAPIPage = createOpenAPIPage({ content: { renderOperationLayout: renderApiReferenceOperationLayout } });
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { FumadocsOpenAPIPage as default };
|
package/dist/layout.mjs
CHANGED
|
@@ -79,7 +79,7 @@ function createNextDocsMetadata(config) {
|
|
|
79
79
|
}
|
|
80
80
|
function createNextDocsLayout(config) {
|
|
81
81
|
emitDocsTelemetryProjectEvent(config, { framework: "next" });
|
|
82
|
-
const DocsLayout = createDocsLayout(withNextApiReferenceBanner(config));
|
|
82
|
+
const DocsLayout = createDocsLayout(withNextApiReferenceBanner(config), { telemetryFramework: "next" });
|
|
83
83
|
return function NextDocsLayout({ children }) {
|
|
84
84
|
const docsCloud = resolveNextDocsCloudClientOptions(config);
|
|
85
85
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.119",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"@mdx-js/react": "^3.1.0",
|
|
92
92
|
"@next/mdx": "^16.1.6",
|
|
93
93
|
"@scalar/nextjs-api-reference": "0.10.3",
|
|
94
|
-
"fumadocs-
|
|
95
|
-
"fumadocs-
|
|
96
|
-
"fumadocs-ui": "16.
|
|
94
|
+
"fumadocs-core": "16.17.1",
|
|
95
|
+
"fumadocs-openapi": "12.4.1",
|
|
96
|
+
"fumadocs-ui": "16.17.1",
|
|
97
97
|
"gray-matter": "^4.0.3",
|
|
98
98
|
"remark-frontmatter": "^5.0.0",
|
|
99
99
|
"remark-gfm": "^4.0.1",
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
"tsdown": "^0.20.3",
|
|
110
110
|
"typescript": "^5.9.3",
|
|
111
111
|
"vitest": "^4.1.8",
|
|
112
|
-
"@farming-labs/
|
|
113
|
-
"@farming-labs/
|
|
112
|
+
"@farming-labs/docs": "0.2.119",
|
|
113
|
+
"@farming-labs/theme": "0.2.119"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"@farming-labs/docs": ">=0.2.73",
|