@farming-labs/next 0.2.118 → 0.2.120
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 +2 -1
- package/dist/api-reference.mjs +15 -33
- package/dist/config.mjs +3 -1
- package/dist/fumadocs-api-page.d.mts +11 -0
- package/dist/fumadocs-api-page.mjs +49 -0
- package/dist/fumadocs-renderer.d.mts +13 -0
- package/dist/fumadocs-renderer.mjs +13 -0
- package/dist/layout.mjs +1 -1
- package/package.json +11 -6
package/dist/api-reference.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FumadocsApiReferenceRendererOptions, fumadocsRenderer } from "./fumadocs-renderer.mjs";
|
|
1
2
|
import { DocsConfig } from "@farming-labs/docs";
|
|
2
3
|
import { resolveApiReferenceConfig } from "@farming-labs/docs/runtime";
|
|
3
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -43,4 +44,4 @@ declare function createNextApiReferenceLayout(config: DocsConfig): (props: {
|
|
|
43
44
|
declare function getNextApiReferenceSourceState(config: DocsConfig, versionId?: string): Promise<NextApiReferenceSourceState>;
|
|
44
45
|
declare function getNextApiReferenceMode(config: DocsConfig): "farming-labs" | "fumadocs" | "scalar";
|
|
45
46
|
//#endregion
|
|
46
|
-
export { NextApiReferenceSourceState, buildNextOpenApiDocument, createNextApiReference, createNextApiReferenceLayout, createNextApiReferencePage, flattenApiReferencePageTreeForSidebar, getNextApiReferenceMode, getNextApiReferenceSourceState, resolveApiReferenceConfig, withNextApiReferenceBanner };
|
|
47
|
+
export { type FumadocsApiReferenceRendererOptions, NextApiReferenceSourceState, buildNextOpenApiDocument, createNextApiReference, createNextApiReferenceLayout, createNextApiReferencePage, flattenApiReferencePageTreeForSidebar, fumadocsRenderer, getNextApiReferenceMode, getNextApiReferenceSourceState, resolveApiReferenceConfig, withNextApiReferenceBanner };
|
package/dist/api-reference.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import DocsClientCallbacks from "./client-callbacks.mjs";
|
|
2
|
+
import FumadocsOpenAPIPage from "./fumadocs-api-page.mjs";
|
|
3
|
+
import { fumadocsRenderer } from "./fumadocs-renderer.mjs";
|
|
2
4
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
5
|
import { join, relative } from "node:path";
|
|
4
6
|
import { resolveDocsMetadataBaseUrl } from "@farming-labs/docs";
|
|
@@ -537,30 +539,6 @@ function flattenApiReferencePageTreeForSidebar(tree) {
|
|
|
537
539
|
children: nextChildren
|
|
538
540
|
};
|
|
539
541
|
}
|
|
540
|
-
function renderApiReferenceOperationLayout(slots) {
|
|
541
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
542
|
-
className: "fd-api-reference-operation",
|
|
543
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
544
|
-
className: "fd-api-reference-operation-main",
|
|
545
|
-
children: [
|
|
546
|
-
slots.header,
|
|
547
|
-
slots.apiPlayground,
|
|
548
|
-
slots.description ? /* @__PURE__ */ jsx("div", {
|
|
549
|
-
className: "fd-api-reference-operation-description",
|
|
550
|
-
children: slots.description
|
|
551
|
-
}) : null,
|
|
552
|
-
slots.authSchemes,
|
|
553
|
-
slots.parameters,
|
|
554
|
-
slots.body,
|
|
555
|
-
slots.responses,
|
|
556
|
-
slots.callbacks
|
|
557
|
-
]
|
|
558
|
-
}), slots.apiExample ? /* @__PURE__ */ jsx("div", {
|
|
559
|
-
className: "fd-api-reference-operation-example",
|
|
560
|
-
children: slots.apiExample
|
|
561
|
-
}) : null]
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
542
|
function withNextApiReferenceBanner(config) {
|
|
565
543
|
const apiReference = resolveApiReferenceConfig(config.apiReference);
|
|
566
544
|
if (!apiReference.enabled) return config;
|
|
@@ -651,11 +629,11 @@ function getOpenApiInfo(document) {
|
|
|
651
629
|
}
|
|
652
630
|
function createNextApiReferencePage(config) {
|
|
653
631
|
return async function NextApiReferencePage(props) {
|
|
654
|
-
const
|
|
632
|
+
const { DocsDescription, DocsPage, DocsTitle } = await import("fumadocs-ui/layouts/notebook/page");
|
|
655
633
|
const slug = (props?.params ? await props.params : void 0)?.slug ?? [];
|
|
656
634
|
const version = resolveApiReferenceVersion(resolveApiReferenceConfig(config.apiReference), slug[0]);
|
|
657
635
|
const pageSlug = version ? slug.slice(1) : slug;
|
|
658
|
-
const { info, pages,
|
|
636
|
+
const { info, pages, source } = await getNextApiReferenceSourceState(config, version?.id);
|
|
659
637
|
if (pages.length === 0) return /* @__PURE__ */ jsxs(DocsPage, {
|
|
660
638
|
full: true,
|
|
661
639
|
children: [
|
|
@@ -671,8 +649,7 @@ function createNextApiReferencePage(config) {
|
|
|
671
649
|
]
|
|
672
650
|
});
|
|
673
651
|
const page = pageSlug.length === 0 ? pages[0] : source.getPage(pageSlug);
|
|
674
|
-
if (!page || typeof page.data?.
|
|
675
|
-
const APIPage = createAPIPage(server, { content: { renderOperationLayout: renderApiReferenceOperationLayout } });
|
|
652
|
+
if (!page || typeof page.data?.getOpenAPIPageProps !== "function") notFound();
|
|
676
653
|
const currentPageIndex = pageSlug.length === 0 ? 0 : pages.findIndex((entry) => entry.url === page.url);
|
|
677
654
|
const previousPage = currentPageIndex > 0 ? pages[currentPageIndex - 1] : void 0;
|
|
678
655
|
const nextPage = currentPageIndex >= 0 && currentPageIndex < pages.length - 1 ? pages[currentPageIndex + 1] : void 0;
|
|
@@ -686,7 +663,7 @@ function createNextApiReferencePage(config) {
|
|
|
686
663
|
/* @__PURE__ */ jsx(DocsDescription, { children: typeof page.data.description === "string" && page.data.description.trim() ? page.data.description : info.description }),
|
|
687
664
|
/* @__PURE__ */ jsx("div", {
|
|
688
665
|
className: "fd-api-reference-body",
|
|
689
|
-
children: /* @__PURE__ */ jsx(
|
|
666
|
+
children: /* @__PURE__ */ jsx(FumadocsOpenAPIPage, { ...page.data.getOpenAPIPageProps() })
|
|
690
667
|
}),
|
|
691
668
|
previousPage || nextPage ? /* @__PURE__ */ jsxs("nav", {
|
|
692
669
|
className: "fd-api-reference-pagination",
|
|
@@ -790,14 +767,19 @@ async function getNextApiReferenceSourceState(config, versionId) {
|
|
|
790
767
|
baseUrl,
|
|
791
768
|
version: version?.id
|
|
792
769
|
});
|
|
793
|
-
const
|
|
770
|
+
const fumadocsOptions = apiReference.renderer === "fumadocs" ? apiReference.rendererOptions : void 0;
|
|
771
|
+
const server = createOpenAPI({
|
|
772
|
+
input: { main: document },
|
|
773
|
+
disableCache: typeof fumadocsOptions?.disableCache === "boolean" ? fumadocsOptions.disableCache : void 0,
|
|
774
|
+
proxyUrl: typeof fumadocsOptions?.proxyUrl === "string" ? fumadocsOptions.proxyUrl : void 0
|
|
775
|
+
});
|
|
794
776
|
const info = getOpenApiInfo(document);
|
|
795
777
|
const source = loader(await openapiSource(server, {
|
|
796
778
|
per: "operation",
|
|
797
779
|
groupBy: "tag",
|
|
798
|
-
name(output
|
|
780
|
+
name(output) {
|
|
799
781
|
if (output.type !== "operation") return slugifyApiReferencePageName(output.item.name);
|
|
800
|
-
const operation = (
|
|
782
|
+
const operation = (this.document?.paths?.[output.item.path])?.[output.item.method];
|
|
801
783
|
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}`);
|
|
802
784
|
}
|
|
803
785
|
}), {
|
|
@@ -819,4 +801,4 @@ function getNextApiReferenceMode(config) {
|
|
|
819
801
|
}
|
|
820
802
|
|
|
821
803
|
//#endregion
|
|
822
|
-
export { buildNextOpenApiDocument, createNextApiReference, createNextApiReferenceLayout, createNextApiReferencePage, flattenApiReferencePageTreeForSidebar, getNextApiReferenceMode, getNextApiReferenceSourceState, resolveApiReferenceConfig, withNextApiReferenceBanner };
|
|
804
|
+
export { buildNextOpenApiDocument, createNextApiReference, createNextApiReferenceLayout, createNextApiReferencePage, flattenApiReferencePageTreeForSidebar, fumadocsRenderer, getNextApiReferenceMode, getNextApiReferenceSourceState, resolveApiReferenceConfig, withNextApiReferenceBanner };
|
package/dist/config.mjs
CHANGED
|
@@ -731,11 +731,13 @@ function readApiReferenceConfig(root) {
|
|
|
731
731
|
const enabledMatch = block.match(/enabled\s*:\s*(true|false)/);
|
|
732
732
|
const pathMatch = block.match(/path\s*:\s*["']([^"']+)["']/);
|
|
733
733
|
const rendererMatch = block.match(/renderer\s*:\s*["'](farming-labs|fumadocs|scalar)["']/);
|
|
734
|
+
const rendererConfigNameMatch = extractObjectLiteral(block, "renderer")?.match(/name\s*:\s*["'](farming-labs|fumadocs|scalar)["']/);
|
|
735
|
+
const usesFumadocsRendererHelper = /renderer\s*:\s*fumadocsRenderer\s*\(/.test(block);
|
|
734
736
|
const routeRootMatch = block.match(/routeRoot\s*:\s*["']([^"']+)["']/);
|
|
735
737
|
return {
|
|
736
738
|
enabled: enabledMatch ? enabledMatch[1] !== "false" : true,
|
|
737
739
|
path: pathMatch?.[1]?.replace(/^\/+|\/+$/g, "") || "api-reference",
|
|
738
|
-
renderer: rendererMatch?.[1] ?? "farming-labs",
|
|
740
|
+
renderer: rendererMatch?.[1] ?? rendererConfigNameMatch?.[1] ?? (usesFumadocsRendererHelper ? "fumadocs" : void 0) ?? "farming-labs",
|
|
739
741
|
routeRoot: routeRootMatch?.[1]?.replace(/^\/+|\/+$/g, "") || "api"
|
|
740
742
|
};
|
|
741
743
|
} catch {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DocsConfig } from "@farming-labs/docs";
|
|
2
|
+
import * as react from "react";
|
|
3
|
+
import * as fumadocs_openapi_ui0 from "fumadocs-openapi/ui";
|
|
4
|
+
import { CreateOpenAPIPageOptions } from "fumadocs-openapi/ui";
|
|
5
|
+
|
|
6
|
+
//#region src/fumadocs-api-page.d.ts
|
|
7
|
+
declare function resolveFumadocsOpenAPIPageOptions(config: DocsConfig): CreateOpenAPIPageOptions;
|
|
8
|
+
/** Client boundary for Fumadocs OpenAPI's interactive renderer. */
|
|
9
|
+
declare const FumadocsOpenAPIPage: react.FC<fumadocs_openapi_ui0.OpenAPIPageProps>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { FumadocsOpenAPIPage as default, resolveFumadocsOpenAPIPageOptions };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import docsConfig from "@farming-labs/next-internal-docs-config";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createOpenAPIPage } from "fumadocs-openapi/ui";
|
|
6
|
+
|
|
7
|
+
//#region src/fumadocs-api-page.tsx
|
|
8
|
+
function renderApiReferenceOperationLayout(slots) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: "fd-api-reference-operation",
|
|
11
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
12
|
+
className: "fd-api-reference-operation-main",
|
|
13
|
+
children: [
|
|
14
|
+
slots.header,
|
|
15
|
+
slots.apiPlayground,
|
|
16
|
+
slots.description ? /* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: "fd-api-reference-operation-description",
|
|
18
|
+
children: slots.description
|
|
19
|
+
}) : null,
|
|
20
|
+
slots.authSchemes,
|
|
21
|
+
slots.parameters,
|
|
22
|
+
slots.body,
|
|
23
|
+
slots.responses,
|
|
24
|
+
slots.callbacks
|
|
25
|
+
]
|
|
26
|
+
}), slots.apiExample ? /* @__PURE__ */ jsx("div", {
|
|
27
|
+
className: "fd-api-reference-operation-example",
|
|
28
|
+
children: slots.apiExample
|
|
29
|
+
}) : null]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function resolveFumadocsOpenAPIPageOptions(config) {
|
|
33
|
+
const renderer = config.apiReference && typeof config.apiReference === "object" ? config.apiReference.renderer : void 0;
|
|
34
|
+
const pageOptions = { ...renderer && typeof renderer === "object" && renderer.name === "fumadocs" ? renderer.options : void 0 };
|
|
35
|
+
delete pageOptions.disableCache;
|
|
36
|
+
delete pageOptions.proxyUrl;
|
|
37
|
+
return {
|
|
38
|
+
...pageOptions,
|
|
39
|
+
content: {
|
|
40
|
+
renderOperationLayout: renderApiReferenceOperationLayout,
|
|
41
|
+
...pageOptions.content
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Client boundary for Fumadocs OpenAPI's interactive renderer. */
|
|
46
|
+
const FumadocsOpenAPIPage = createOpenAPIPage(resolveFumadocsOpenAPIPageOptions(docsConfig));
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { FumadocsOpenAPIPage as default, resolveFumadocsOpenAPIPageOptions };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ApiReferenceRendererConfig } from "@farming-labs/docs";
|
|
2
|
+
import { CreateOpenAPIPageOptions } from "fumadocs-openapi/ui";
|
|
3
|
+
import { OpenAPIOptions } from "fumadocs-openapi/server";
|
|
4
|
+
|
|
5
|
+
//#region src/fumadocs-renderer.d.ts
|
|
6
|
+
/** Options supported by the bundled Fumadocs OpenAPI renderer. */
|
|
7
|
+
type FumadocsApiReferenceRendererOptions = CreateOpenAPIPageOptions & Pick<OpenAPIOptions, "disableCache" | "proxyUrl">;
|
|
8
|
+
/**
|
|
9
|
+
* Configure the bundled Fumadocs OpenAPI renderer with fully typed upstream options.
|
|
10
|
+
*/
|
|
11
|
+
declare function fumadocsRenderer(options?: FumadocsApiReferenceRendererOptions): ApiReferenceRendererConfig;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { FumadocsApiReferenceRendererOptions, fumadocsRenderer };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/fumadocs-renderer.ts
|
|
2
|
+
/**
|
|
3
|
+
* Configure the bundled Fumadocs OpenAPI renderer with fully typed upstream options.
|
|
4
|
+
*/
|
|
5
|
+
function fumadocsRenderer(options = {}) {
|
|
6
|
+
return {
|
|
7
|
+
name: "fumadocs",
|
|
8
|
+
options: { ...options }
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { fumadocsRenderer };
|
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.120",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"default": "./dist/api-reference.mjs"
|
|
30
30
|
},
|
|
31
31
|
"./api-reference.css": "./styles/api-reference.css",
|
|
32
|
+
"./fumadocs-renderer": {
|
|
33
|
+
"types": "./dist/fumadocs-renderer.d.mts",
|
|
34
|
+
"import": "./dist/fumadocs-renderer.mjs",
|
|
35
|
+
"default": "./dist/fumadocs-renderer.mjs"
|
|
36
|
+
},
|
|
32
37
|
"./api": {
|
|
33
38
|
"types": "./dist/api.d.mts",
|
|
34
39
|
"import": "./dist/api.mjs",
|
|
@@ -91,9 +96,9 @@
|
|
|
91
96
|
"@mdx-js/react": "^3.1.0",
|
|
92
97
|
"@next/mdx": "^16.1.6",
|
|
93
98
|
"@scalar/nextjs-api-reference": "0.10.3",
|
|
94
|
-
"fumadocs-
|
|
95
|
-
"fumadocs-
|
|
96
|
-
"fumadocs-ui": "16.
|
|
99
|
+
"fumadocs-core": "16.17.1",
|
|
100
|
+
"fumadocs-openapi": "12.4.1",
|
|
101
|
+
"fumadocs-ui": "16.17.1",
|
|
97
102
|
"gray-matter": "^4.0.3",
|
|
98
103
|
"remark-frontmatter": "^5.0.0",
|
|
99
104
|
"remark-gfm": "^4.0.1",
|
|
@@ -109,8 +114,8 @@
|
|
|
109
114
|
"tsdown": "^0.20.3",
|
|
110
115
|
"typescript": "^5.9.3",
|
|
111
116
|
"vitest": "^4.1.8",
|
|
112
|
-
"@farming-labs/docs": "0.2.
|
|
113
|
-
"@farming-labs/theme": "0.2.
|
|
117
|
+
"@farming-labs/docs": "0.2.120",
|
|
118
|
+
"@farming-labs/theme": "0.2.120"
|
|
114
119
|
},
|
|
115
120
|
"peerDependencies": {
|
|
116
121
|
"@farming-labs/docs": ">=0.2.73",
|