fumadocs-openapi 10.9.1 → 10.10.1

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/types.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { MediaAdapter } from "./requests/media/adapter.js";
2
1
  import { InlineCodeUsageGenerator } from "./requests/generators/index.js";
3
2
  import { boundary_d_exports } from "./ui/client/boundary.js";
4
- import { OpenAPIV3, OpenAPIV3_2 } from "./_openapi/types.js";
3
+ import { OpenAPIV3_2 } from "./_openapi/types.js";
5
4
  import { CreateAPIPageOptions } from "./ui/base.js";
6
5
  import { OpenAPIOptions } from "./server/index.js";
7
6
  import { NoReference } from "./utils/schema/index.js";
8
7
  import { DereferencedDocument } from "./utils/document/dereference.js";
9
- import { HTMLAttributes, ReactNode } from "react";
10
8
 
11
9
  //#region src/types.d.ts
12
10
  type Document = OpenAPIV3_2.Document;
@@ -17,14 +15,8 @@ type ReferenceObject = OpenAPIV3_2.ReferenceObject;
17
15
  type PathItemObject = OpenAPIV3_2.PathItemObject;
18
16
  type TagObject = OpenAPIV3_2.TagObject;
19
17
  type ServerObject = OpenAPIV3_2.ServerObject;
20
- type CallbackObject = OpenAPIV3_2.CallbackObject;
21
- type ServerVariableObject = OpenAPIV3.ServerVariableObject;
22
18
  type ResponseObject = OpenAPIV3_2.ResponseObject;
23
- type OAuth2SecurityScheme = OpenAPIV3_2.OAuth2SecurityScheme;
24
19
  type HttpMethods = OpenAPIV3_2.HttpMethods;
25
- type ExampleObject = OpenAPIV3_2.ExampleObject;
26
- type MediaTypeObject = OpenAPIV3_2.MediaTypeObject;
27
- type RequestBodyObject = OpenAPIV3_2.RequestBodyObject;
28
20
  type MethodInformation = NoReference<OperationObject> & {
29
21
  method: HttpMethods;
30
22
  'x-codeSamples'?: InlineCodeUsageGenerator[];
@@ -32,19 +24,14 @@ type MethodInformation = NoReference<OperationObject> & {
32
24
  'x-exclusiveCodeSample'?: string;
33
25
  };
34
26
  type RequireKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
35
- interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateAPIPageOptions, 'renderMarkdown' | 'generateTypeScriptDefinitions'>, 'renderCodeBlock' | 'renderHeading' | 'generateTypeScriptSchema'> {
27
+ interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateAPIPageOptions, 'renderMarkdown' | 'generateTypeScriptDefinitions' | 'renderCodeBlock' | 'mediaAdapters' | 'codeUsages'>, 'renderHeading' | 'generateTypeScriptSchema'> {
36
28
  /**
37
29
  * dereferenced schema
38
30
  */
39
31
  schema: DereferencedDocument;
40
32
  clientBoundary: typeof boundary_d_exports;
41
- mediaAdapters: Record<string, MediaAdapter>;
42
- renderHeading: (depth: number, text: string | ReactNode, props?: HTMLAttributes<HTMLHeadingElement> & {
43
- id?: string;
44
- }) => ReactNode;
45
- renderCodeBlock: (lang: string, code: string) => ReactNode;
46
33
  }
47
34
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
48
35
  type Awaitable<T> = T | Promise<T>;
49
36
  //#endregion
50
- export { Awaitable, CallbackObject, DistributiveOmit, Document, ExampleObject, HttpMethods, MediaTypeObject, MethodInformation, OAuth2SecurityScheme, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, RequestBodyObject, ResponseObject, SecuritySchemeObject, ServerObject, ServerVariableObject, TagObject };
37
+ export { Awaitable, DistributiveOmit, Document, HttpMethods, MethodInformation, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, ResponseObject, SecuritySchemeObject, ServerObject, TagObject };
package/dist/ui/base.d.ts CHANGED
@@ -147,10 +147,11 @@ interface CreateAPIPageOptions {
147
147
  children: ReactNode;
148
148
  }) => ReactNode;
149
149
  /**
150
- * replace the server-side renderer
150
+ * replace the renderer
151
151
  */
152
152
  render?: (props: APIPlaygroundProps) => ReactNode;
153
153
  };
154
+ /** @deprecated no longer used */
154
155
  renderHeading?: (props: HTMLAttributes<HTMLHeadingElement>, depth: number) => ReactNode;
155
156
  renderCodeBlock?: (props: {
156
157
  lang: string;
package/dist/ui/base.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { parseSecurities } from "../utils/schema/index.js";
2
2
  import { defaultAdapters } from "../requests/media/adapter.js";
3
+ import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
4
+ import { registerDefault } from "../requests/generators/all.js";
3
5
  import { ClientCodeBlockProvider } from "./components/codeblock.js";
4
6
  import { encodeInternalRef } from "../utils/schema/ref.js";
5
7
  import { APIPage } from "./api-page.js";
6
8
  import { pickSchema } from "../utils/schema/pick.js";
7
9
  import { PlaygroundAuthProvider } from "./client/boundary.lazy.js";
8
- import Slugger from "github-slugger";
9
10
  import * as JsxRuntime from "react/jsx-runtime";
10
11
  import { jsx } from "react/jsx-runtime";
11
- import { Heading } from "fumadocs-ui/components/heading";
12
12
  import { createRehypeCode } from "fumadocs-core/mdx-plugins/rehype-code.core";
13
13
  import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
14
14
  import defaultMdxComponents from "fumadocs-ui/mdx";
@@ -62,7 +62,6 @@ function createAPIPage(server, options) {
62
62
  let processed;
63
63
  if (typeof document === "string") processed = await server.getSchema(document);
64
64
  else processed = document;
65
- const slugger = new Slugger();
66
65
  const { ApiProvider, PlaygroundClient, SchemaUI, ServerProvider, UsageTab, UsageTabsSelector } = await import("./client/boundary.lazy.js");
67
66
  const ctx = {
68
67
  schema: processed,
@@ -76,6 +75,7 @@ function createAPIPage(server, options) {
76
75
  UsageTabsSelector
77
76
  },
78
77
  ...options,
78
+ codeUsages: options.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
79
79
  mediaAdapters: {
80
80
  ...defaultAdapters,
81
81
  ...options.mediaAdapters
@@ -85,21 +85,6 @@ function createAPIPage(server, options) {
85
85
  provider: options.playground?.provider ?? renderPlaygroundProviderDefault,
86
86
  render: options.playground?.render ?? renderPlaygroundDefault
87
87
  },
88
- renderHeading(depth, text, props) {
89
- const id = typeof text === "string" ? slugger.slug(text) : props?.id;
90
- if (!id) throw new Error("missing 'id' for non-string children");
91
- if (options.renderHeading) return options.renderHeading({
92
- id,
93
- children: text,
94
- ...props
95
- }, depth);
96
- return /* @__PURE__ */ jsx(Heading, {
97
- id,
98
- as: `h${depth}`,
99
- ...props,
100
- children: text
101
- }, id);
102
- },
103
88
  generateTypeScriptDefinitions: options.generateTypeScriptDefinitions ?? ((schema, ctx) => {
104
89
  if (options.generateTypeScriptSchema && ctx._internal_legacy) {
105
90
  const { statusCode, contentType } = ctx._internal_legacy;
@@ -122,7 +107,7 @@ function createAPIPage(server, options) {
122
107
  processor ??= createMarkdownProcessor();
123
108
  return (await processor.process({ value: text })).result;
124
109
  },
125
- async renderCodeBlock(lang, code) {
110
+ async renderCodeBlock({ lang, code }) {
126
111
  if (options.renderCodeBlock) return options.renderCodeBlock({
127
112
  lang,
128
113
  code
@@ -2,12 +2,24 @@ import { MediaAdapter } from "../../requests/media/adapter.js";
2
2
  import { PlaygroundClientOptions } from "../../playground/client.js";
3
3
  import { CodeUsageGeneratorRegistry } from "../../requests/generators/index.js";
4
4
  import { ExampleRequestItem } from "../operation/get-example-requests.js";
5
- import { FC } from "react";
5
+ import { ComponentProps, FC } from "react";
6
6
 
7
7
  //#region src/ui/client/index.d.ts
8
8
  interface APIPageClientOptions {
9
9
  playground?: PlaygroundClientOptions;
10
- operation?: OperationClientOptions;
10
+ operation?: {
11
+ APIExampleSelector?: FC<{
12
+ items: ExampleRequestItem[];
13
+ value: string | undefined;
14
+ onValueChange: (id: string) => void;
15
+ }>;
16
+ };
17
+ components?: {
18
+ Heading?: FC<ComponentProps<'h1'> & {
19
+ id: string;
20
+ depth: number;
21
+ }>;
22
+ };
11
23
  /**
12
24
  * Set a prefix for `localStorage` keys.
13
25
  *
@@ -25,13 +37,6 @@ interface APIPageClientOptions {
25
37
  */
26
38
  codeUsages?: CodeUsageGeneratorRegistry;
27
39
  }
28
- interface OperationClientOptions {
29
- APIExampleSelector?: FC<{
30
- items: ExampleRequestItem[];
31
- value: string | undefined;
32
- onValueChange: (id: string) => void;
33
- }>;
34
- }
35
40
  declare function defineClientConfig(options?: APIPageClientOptions): APIPageClientOptions;
36
41
  //#endregion
37
- export { APIPageClientOptions, OperationClientOptions, defineClientConfig };
42
+ export { APIPageClientOptions, defineClientConfig };
@@ -1,27 +1,52 @@
1
1
  "use client";
2
2
  import { cn } from "../../utils/cn.js";
3
+ import { anchorIdStartsWith } from "../../utils/auto-anchor.js";
4
+ import { AnchorSection, useAnchorId } from "../../utils/auto-anchor.client.js";
5
+ import { createContext, use, useEffect, useMemo, useState } from "react";
3
6
  import { jsx, jsxs } from "react/jsx-runtime";
4
7
  import { ChevronRight } from "lucide-react";
5
8
  import * as Primitive from "@radix-ui/react-accordion";
6
9
  //#region src/ui/components/accordion.tsx
7
- function Accordions(props) {
8
- return /* @__PURE__ */ jsx(Primitive.Root, {
9
- ...props,
10
- className: cn("divide-y divide-fd-border", props.className)
10
+ const Context = createContext(null);
11
+ function Accordions({ type, defaultValue, ...props }) {
12
+ const [value, setValue] = useState(() => type === "multiple" ? defaultValue ?? [] : defaultValue ?? "");
13
+ return /* @__PURE__ */ jsx(Context, {
14
+ value: useMemo(() => ({
15
+ type,
16
+ setValue
17
+ }), [type]),
18
+ children: /* @__PURE__ */ jsx(Primitive.Root, {
19
+ type,
20
+ value,
21
+ onValueChange: setValue,
22
+ ...props
23
+ })
11
24
  });
12
25
  }
13
- function AccordionItem(props) {
14
- return /* @__PURE__ */ jsx(Primitive.Item, {
15
- ...props,
16
- className: cn("scroll-m-20", props.className),
17
- children: props.children
26
+ function AccordionItem({ value, className, anchorSegments, ...props }) {
27
+ const ctx = use(Context);
28
+ const id = useAnchorId(anchorSegments ?? false);
29
+ useEffect(() => {
30
+ if (id && anchorIdStartsWith(window.location.hash.slice(1), id)) ctx.setValue(ctx.type === "single" ? value : [value]);
31
+ }, [
32
+ value,
33
+ id,
34
+ ctx
35
+ ]);
36
+ const content = /* @__PURE__ */ jsx(Primitive.Item, {
37
+ value,
38
+ className: cn("scroll-m-20 border-b last:border-b-0", className),
39
+ ...props
18
40
  });
41
+ return anchorSegments ? /* @__PURE__ */ jsx(AnchorSection, {
42
+ segments: anchorSegments,
43
+ children: content
44
+ }) : content;
19
45
  }
20
46
  function AccordionContent(props) {
21
47
  return /* @__PURE__ */ jsx(Primitive.Content, {
22
48
  ...props,
23
- className: cn("overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down", props.className),
24
- children: props.children
49
+ className: cn("overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down", props.className)
25
50
  });
26
51
  }
27
52
  function AccordionHeader(props) {
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
  import { useTranslations } from "../client/i18n.js";
3
3
  import { cn } from "../../utils/cn.js";
4
- import * as React from "react";
5
4
  import { jsx, jsxs } from "react/jsx-runtime";
6
5
  import { X } from "lucide-react";
7
6
  import { buttonVariants } from "fumadocs-ui/components/ui/button";
@@ -10,13 +9,14 @@ import * as DialogPrimitive from "@radix-ui/react-dialog";
10
9
  const Dialog = DialogPrimitive.Root;
11
10
  const DialogTrigger = DialogPrimitive.Trigger;
12
11
  const DialogPortal = DialogPrimitive.Portal;
13
- const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Overlay, {
14
- ref,
15
- className: cn("fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out", className),
16
- ...props
17
- }));
18
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
19
- const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => {
12
+ function DialogOverlay({ className, ref, ...props }) {
13
+ return /* @__PURE__ */ jsx(DialogPrimitive.Overlay, {
14
+ ref,
15
+ className: cn("fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out", className),
16
+ ...props
17
+ });
18
+ }
19
+ function DialogContent({ className, children, ref, ...props }) {
20
20
  const t = useTranslations();
21
21
  return /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogOverlay, {}), /* @__PURE__ */ jsxs(DialogPrimitive.Content, {
22
22
  ref,
@@ -31,29 +31,26 @@ const DialogContent = React.forwardRef(({ className, children, ...props }, ref)
31
31
  children: /* @__PURE__ */ jsx(X, {})
32
32
  })]
33
33
  })] });
34
- });
35
- DialogContent.displayName = DialogPrimitive.Content.displayName;
36
- const DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
37
- className: cn("flex flex-col gap-1.5 text-center sm:text-start", className),
38
- ...props
39
- });
40
- DialogHeader.displayName = "DialogHeader";
41
- const DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
42
- className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2", className),
43
- ...props
44
- });
45
- DialogFooter.displayName = "DialogFooter";
46
- const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Title, {
47
- ref,
48
- className: cn("text-lg font-semibold leading-none tracking-tight", className),
49
- ...props
50
- }));
51
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
52
- const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, {
53
- ref,
54
- className: cn("text-sm text-fd-muted-foreground", className),
55
- ...props
56
- }));
57
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
34
+ }
35
+ function DialogHeader({ className, ...props }) {
36
+ return /* @__PURE__ */ jsx("div", {
37
+ className: cn("flex flex-col gap-1.5 text-center sm:text-start", className),
38
+ ...props
39
+ });
40
+ }
41
+ function DialogTitle({ className, ref, ...props }) {
42
+ return /* @__PURE__ */ jsx(DialogPrimitive.Title, {
43
+ ref,
44
+ className: cn("text-lg font-semibold leading-none tracking-tight", className),
45
+ ...props
46
+ });
47
+ }
48
+ function DialogDescription({ className, ref, ...props }) {
49
+ return /* @__PURE__ */ jsx(DialogPrimitive.Description, {
50
+ ref,
51
+ className: cn("text-sm text-fd-muted-foreground", className),
52
+ ...props
53
+ });
54
+ }
58
55
  //#endregion
59
56
  export { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useApiContext } from "../contexts/api.js";
3
+ import { useAnchorId } from "../../utils/auto-anchor.client.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { Heading } from "fumadocs-ui/components/heading";
6
+ //#region src/ui/components/heading.tsx
7
+ function Heading$1({ id: _id, depth, ...props }) {
8
+ const id = useAnchorId([_id]);
9
+ const Component = useApiContext().client.components?.Heading;
10
+ if (Component) return /* @__PURE__ */ jsx(Component, {
11
+ id,
12
+ depth,
13
+ ...props
14
+ });
15
+ return /* @__PURE__ */ jsx(Heading, {
16
+ id,
17
+ as: `h${depth}`,
18
+ ...props
19
+ });
20
+ }
21
+ //#endregion
22
+ export { Heading$1 as Heading };
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
  import { cn } from "../../utils/cn.js";
3
3
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
4
- import { createContext, use, useMemo, useState } from "react";
4
+ import { anchorIdStartsWith } from "../../utils/auto-anchor.js";
5
+ import { AnchorSection, useAnchorId } from "../../utils/auto-anchor.client.js";
6
+ import { createContext, use, useEffect, useMemo, useState } from "react";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
8
  //#region src/ui/components/select-tab.tsx
7
9
  const Context = createContext(null);
@@ -15,14 +17,24 @@ function SelectTabs({ defaultValue, children }) {
15
17
  children
16
18
  });
17
19
  }
18
- function SelectTab({ value, ...props }) {
19
- if (value !== use(Context)?.value) return;
20
- return /* @__PURE__ */ jsx("div", {
21
- ...props,
22
- children: props.children
23
- });
20
+ function SelectTab({ value, anchorSegments, ...props }) {
21
+ const { value: currentValue, setValue } = use(Context);
22
+ const id = useAnchorId(anchorSegments ?? false);
23
+ useEffect(() => {
24
+ if (id && anchorIdStartsWith(window.location.hash.slice(1), id)) setValue(value);
25
+ }, [
26
+ id,
27
+ value,
28
+ setValue
29
+ ]);
30
+ if (value !== currentValue) return;
31
+ const content = /* @__PURE__ */ jsx("div", { ...props });
32
+ return anchorSegments ? /* @__PURE__ */ jsx(AnchorSection, {
33
+ segments: anchorSegments,
34
+ children: content
35
+ }) : content;
24
36
  }
25
- function SelectTabTrigger({ items, className, ...props }) {
37
+ function SelectTabTrigger({ items, className, placeholder, ...props }) {
26
38
  const { value, setValue } = use(Context);
27
39
  return /* @__PURE__ */ jsxs(Select, {
28
40
  value: value ?? "",
@@ -30,7 +42,10 @@ function SelectTabTrigger({ items, className, ...props }) {
30
42
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
31
43
  className: cn("not-prose w-fit min-w-0 *:min-w-0", className),
32
44
  ...props,
33
- children: /* @__PURE__ */ jsx(SelectValue, { children: value && items.find((item) => item.value === value)?.label })
45
+ children: /* @__PURE__ */ jsx(SelectValue, {
46
+ placeholder,
47
+ children: value && items.find((item) => item.value === value)?.label
48
+ })
34
49
  }), /* @__PURE__ */ jsx(SelectContent, { children: items.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, {
35
50
  value,
36
51
  children: label
@@ -21,16 +21,10 @@ function useServerContext() {
21
21
  function ApiProvider({ children, shikiOptions, client, schemes }) {
22
22
  return /* @__PURE__ */ jsx(ApiContext, {
23
23
  value: useMemo(() => {
24
- let codeUsages;
25
- if (client.codeUsages) codeUsages = createCodeUsageGeneratorRegistry(client.codeUsages);
26
- else {
27
- codeUsages = createCodeUsageGeneratorRegistry();
28
- registerDefault(codeUsages);
29
- }
30
24
  return {
31
25
  shikiOptions,
32
26
  client,
33
- codeUsages,
27
+ codeUsages: client.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
34
28
  schemes,
35
29
  mediaAdapters: {
36
30
  ...defaultAdapters,
@@ -1,3 +1,4 @@
1
+ import { APIPageClientOptions } from "./client/index.js";
1
2
  import { ApiPageProps } from "./api-page.js";
2
3
  import { CreateAPIPageOptions } from "./base.js";
3
4
  import { Document } from "../types.js";
@@ -11,7 +12,7 @@ interface ClientApiPagePayload {
11
12
  bundled: Document;
12
13
  proxyUrl?: string;
13
14
  }
14
- type CreateClientAPIPageOptions = Omit<Partial<CreateAPIPageOptions>, 'generateTypeScriptSchema'>;
15
+ type CreateClientAPIPageOptions = Partial<Omit<CreateAPIPageOptions, 'generateTypeScriptSchema' | 'client'> & Omit<APIPageClientOptions, 'mediaAdapters' | 'codeUsages'>>;
15
16
  /**
16
17
  * Create `<APIPage />` for non-RSC environment, note that this may be unstable, and doesn't support the full set of features.
17
18
  */
@@ -1,15 +1,16 @@
1
+ "use client";
1
2
  import { parseSecurities } from "../utils/schema/index.js";
2
3
  import { defaultAdapters } from "../requests/media/adapter.js";
4
+ import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
5
+ import { registerDefault } from "../requests/generators/all.js";
3
6
  import { ClientCodeBlock, ClientCodeBlockProvider } from "./components/codeblock.js";
4
7
  import { AuthProvider } from "../playground/auth.js";
5
8
  import { dereferenceDocument } from "../utils/document/dereference.js";
6
9
  import { APIPage } from "./api-page.js";
7
10
  import { boundary_exports } from "./client/boundary.js";
8
- import { slug } from "github-slugger";
9
11
  import { Children, useMemo } from "react";
10
12
  import * as JsxRuntime from "react/jsx-runtime";
11
13
  import { jsx } from "react/jsx-runtime";
12
- import { Heading } from "fumadocs-ui/components/heading";
13
14
  import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
14
15
  import defaultMdxComponents from "fumadocs-ui/mdx";
15
16
  import { remark } from "remark";
@@ -80,7 +81,9 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
80
81
  shikiOptions,
81
82
  generateTypeScriptDefinitions,
82
83
  clientBoundary: boundary_exports,
84
+ client: options,
83
85
  ...options,
86
+ codeUsages: options.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
84
87
  mediaAdapters: {
85
88
  ...defaultAdapters,
86
89
  ...options.mediaAdapters
@@ -90,35 +93,14 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
90
93
  provider: options.playground?.provider ?? renderPlaygroundProviderDefault,
91
94
  render: options.playground?.render ?? renderPlaygroundDefault
92
95
  },
93
- renderHeading(depth, text, props) {
94
- const id = typeof text === "string" ? slug(text) : props?.id;
95
- if (!id) throw new Error("missing 'id' for non-string children");
96
- if (options.renderHeading) return options.renderHeading({
97
- id,
98
- children: text,
99
- ...props
100
- }, depth);
101
- return /* @__PURE__ */ jsx(Heading, {
102
- id,
103
- as: `h${depth}`,
104
- ...props,
105
- children: text
106
- }, id);
107
- },
108
96
  renderMarkdown(text) {
109
97
  if (options.renderMarkdown) return options.renderMarkdown(text);
110
98
  processor ??= createMarkdownProcessor();
111
99
  return processor.processSync({ value: text }).result;
112
100
  },
113
- renderCodeBlock(lang, code) {
114
- if (options.renderCodeBlock) return options.renderCodeBlock({
115
- lang,
116
- code
117
- });
118
- return /* @__PURE__ */ jsx(ClientCodeBlock, {
119
- lang,
120
- code
121
- });
101
+ renderCodeBlock(props) {
102
+ if (options.renderCodeBlock) return options.renderCodeBlock(props);
103
+ return /* @__PURE__ */ jsx(ClientCodeBlock, { ...props });
122
104
  }
123
105
  }), [payload.proxyUrl, processed]);
124
106
  return /* @__PURE__ */ jsx(ClientCodeBlockProvider, {
@@ -56,7 +56,7 @@ function CopyTypeScriptPanel({ name, code, className }) {
56
56
  const t = useTranslations();
57
57
  const useTypeText = t.useTypeInTypeScript.replace("{name}", name);
58
58
  return /* @__PURE__ */ jsxs("div", {
59
- className: cn("flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose mb-4 last:mb-0", className),
59
+ className: cn("flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose", className),
60
60
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
61
61
  className: "font-medium text-sm mb-2",
62
62
  children: t.typeScriptDefinitions