fumadocs-openapi 9.7.3 → 10.0.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.
Files changed (151) hide show
  1. package/dist/generate-file.d.ts +3 -4
  2. package/dist/generate-file.d.ts.map +1 -1
  3. package/dist/generate-file.js +4 -34
  4. package/dist/playground/client.d.ts +43 -22
  5. package/dist/playground/client.d.ts.map +1 -1
  6. package/dist/playground/client.js +68 -63
  7. package/dist/playground/{inputs.d.ts → components/inputs.d.ts} +1 -1
  8. package/dist/playground/components/inputs.d.ts.map +1 -0
  9. package/dist/playground/{inputs.js → components/inputs.js} +7 -7
  10. package/dist/playground/components/oauth-dialog.d.ts.map +1 -0
  11. package/dist/playground/components/server-select.d.ts.map +1 -0
  12. package/dist/{ui → playground/components}/server-select.js +6 -7
  13. package/dist/playground/index.d.ts +1 -4
  14. package/dist/playground/index.d.ts.map +1 -1
  15. package/dist/playground/index.js +5 -3
  16. package/dist/playground/lazy.d.ts +2 -0
  17. package/dist/playground/lazy.d.ts.map +1 -0
  18. package/dist/playground/lazy.js +3 -0
  19. package/dist/requests/generators/index.d.ts +2 -2
  20. package/dist/requests/generators/index.d.ts.map +1 -1
  21. package/dist/requests/generators/index.js +6 -0
  22. package/dist/requests/media/adapter.d.ts +0 -6
  23. package/dist/requests/media/adapter.d.ts.map +1 -1
  24. package/dist/scalar/client.d.ts +1 -0
  25. package/dist/scalar/client.d.ts.map +1 -1
  26. package/dist/scalar/client.js +2 -3
  27. package/dist/scalar/index.d.ts +7 -6
  28. package/dist/scalar/index.d.ts.map +1 -1
  29. package/dist/scalar/index.js +17 -1
  30. package/dist/server/create.d.ts +11 -59
  31. package/dist/server/create.d.ts.map +1 -1
  32. package/dist/server/create.js +5 -14
  33. package/dist/server/source-api.d.ts +1 -1
  34. package/dist/server/source-api.d.ts.map +1 -1
  35. package/dist/server/source-api.js +1 -1
  36. package/dist/types.d.ts +12 -4
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/ui/api-page.d.ts +145 -0
  39. package/dist/ui/api-page.d.ts.map +1 -0
  40. package/dist/ui/api-page.js +120 -0
  41. package/dist/ui/client/index.d.ts +29 -0
  42. package/dist/ui/client/index.d.ts.map +1 -0
  43. package/dist/ui/client/index.js +4 -0
  44. package/dist/ui/client/storage-key.d.ts +9 -0
  45. package/dist/ui/client/storage-key.d.ts.map +1 -0
  46. package/dist/ui/client/storage-key.js +12 -0
  47. package/dist/ui/components/method-label.d.ts +1 -1
  48. package/dist/ui/contexts/api.d.ts +12 -10
  49. package/dist/ui/contexts/api.d.ts.map +1 -1
  50. package/dist/ui/contexts/api.js +53 -37
  51. package/dist/ui/contexts/api.lazy.d.ts +2 -0
  52. package/dist/ui/contexts/api.lazy.d.ts.map +1 -0
  53. package/dist/ui/contexts/api.lazy.js +3 -0
  54. package/dist/ui/contexts/operation.d.ts +20 -0
  55. package/dist/ui/contexts/operation.d.ts.map +1 -0
  56. package/dist/ui/contexts/operation.js +48 -0
  57. package/dist/ui/contexts/operation.lazy.d.ts +2 -0
  58. package/dist/ui/contexts/operation.lazy.d.ts.map +1 -0
  59. package/dist/ui/contexts/operation.lazy.js +3 -0
  60. package/dist/ui/index.d.ts +1 -8
  61. package/dist/ui/index.d.ts.map +1 -1
  62. package/dist/ui/index.js +1 -26
  63. package/dist/ui/{select-tabs.d.ts → operation/client.d.ts} +5 -2
  64. package/dist/ui/operation/client.d.ts.map +1 -0
  65. package/dist/ui/{client.js → operation/client.js} +18 -1
  66. package/dist/ui/operation/example-panel/client.d.ts +4 -0
  67. package/dist/ui/operation/example-panel/client.d.ts.map +1 -0
  68. package/dist/ui/operation/example-panel/client.js +50 -0
  69. package/dist/ui/operation/example-panel/index.d.ts +58 -0
  70. package/dist/ui/operation/example-panel/index.d.ts.map +1 -0
  71. package/dist/ui/operation/example-panel/index.js +140 -0
  72. package/dist/ui/operation/example-panel/lazy.d.ts +3 -0
  73. package/dist/ui/operation/example-panel/lazy.d.ts.map +1 -0
  74. package/dist/ui/operation/example-panel/lazy.js +4 -0
  75. package/dist/ui/operation/get-request-data.d.ts.map +1 -0
  76. package/dist/ui/operation/index.d.ts +11 -0
  77. package/dist/ui/operation/index.d.ts.map +1 -0
  78. package/dist/{render → ui}/operation/index.js +50 -24
  79. package/dist/ui/schema/client.d.ts +11 -0
  80. package/dist/ui/schema/client.d.ts.map +1 -0
  81. package/dist/{render → ui}/schema/client.js +22 -12
  82. package/dist/{render/schema/server.d.ts → ui/schema/index.d.ts} +5 -4
  83. package/dist/ui/schema/index.d.ts.map +1 -0
  84. package/dist/{render/schema/server.js → ui/schema/index.js} +11 -5
  85. package/dist/ui/schema/lazy.d.ts +2 -0
  86. package/dist/ui/schema/lazy.d.ts.map +1 -0
  87. package/dist/ui/schema/lazy.js +3 -0
  88. package/dist/utils/get-typescript-schema.d.ts +3 -2
  89. package/dist/utils/get-typescript-schema.d.ts.map +1 -1
  90. package/dist/utils/get-typescript-schema.js +12 -7
  91. package/dist/utils/lazy.d.ts +5 -0
  92. package/dist/utils/lazy.d.ts.map +1 -0
  93. package/dist/utils/lazy.js +12 -0
  94. package/dist/utils/pages/builder.d.ts +1 -1
  95. package/dist/utils/pages/builder.d.ts.map +1 -1
  96. package/dist/utils/pages/to-body.d.ts +2 -3
  97. package/dist/utils/pages/to-body.d.ts.map +1 -1
  98. package/dist/utils/pages/to-body.js +7 -7
  99. package/dist/utils/pages/to-text.d.ts.map +1 -1
  100. package/dist/utils/process-document.d.ts +1 -0
  101. package/dist/utils/process-document.d.ts.map +1 -1
  102. package/dist/utils/process-document.js +7 -2
  103. package/package.json +20 -16
  104. package/dist/playground/auth/oauth-dialog.d.ts.map +0 -1
  105. package/dist/playground/inputs.d.ts.map +0 -1
  106. package/dist/render/api-page.d.ts +0 -33
  107. package/dist/render/api-page.d.ts.map +0 -1
  108. package/dist/render/api-page.js +0 -59
  109. package/dist/render/codeblock.d.ts +0 -9
  110. package/dist/render/codeblock.d.ts.map +0 -1
  111. package/dist/render/codeblock.js +0 -14
  112. package/dist/render/heading.d.ts +0 -4
  113. package/dist/render/heading.d.ts.map +0 -1
  114. package/dist/render/heading.js +0 -6
  115. package/dist/render/markdown.d.ts +0 -5
  116. package/dist/render/markdown.d.ts.map +0 -1
  117. package/dist/render/markdown.js +0 -31
  118. package/dist/render/operation/api-example.d.ts +0 -30
  119. package/dist/render/operation/api-example.d.ts.map +0 -1
  120. package/dist/render/operation/api-example.js +0 -103
  121. package/dist/render/operation/get-request-data.d.ts.map +0 -1
  122. package/dist/render/operation/index.d.ts +0 -27
  123. package/dist/render/operation/index.d.ts.map +0 -1
  124. package/dist/render/renderer.d.ts +0 -79
  125. package/dist/render/renderer.d.ts.map +0 -1
  126. package/dist/render/renderer.js +0 -25
  127. package/dist/render/schema/client.d.ts +0 -18
  128. package/dist/render/schema/client.d.ts.map +0 -1
  129. package/dist/render/schema/index.d.ts +0 -7
  130. package/dist/render/schema/index.d.ts.map +0 -1
  131. package/dist/render/schema/index.js +0 -11
  132. package/dist/render/schema/server.d.ts.map +0 -1
  133. package/dist/render/schema/ui.d.ts +0 -16
  134. package/dist/render/schema/ui.d.ts.map +0 -1
  135. package/dist/render/schema/ui.js +0 -14
  136. package/dist/ui/client.d.ts +0 -4
  137. package/dist/ui/client.d.ts.map +0 -1
  138. package/dist/ui/contexts/code-example.d.ts +0 -24
  139. package/dist/ui/contexts/code-example.d.ts.map +0 -1
  140. package/dist/ui/contexts/code-example.js +0 -97
  141. package/dist/ui/lazy.d.ts +0 -16
  142. package/dist/ui/lazy.d.ts.map +0 -1
  143. package/dist/ui/lazy.js +0 -22
  144. package/dist/ui/select-tabs.d.ts.map +0 -1
  145. package/dist/ui/select-tabs.js +0 -20
  146. package/dist/ui/server-select.d.ts.map +0 -1
  147. /package/dist/playground/{auth → components}/oauth-dialog.d.ts +0 -0
  148. /package/dist/playground/{auth → components}/oauth-dialog.js +0 -0
  149. /package/dist/{ui → playground/components}/server-select.d.ts +0 -0
  150. /package/dist/{render → ui}/operation/get-request-data.d.ts +0 -0
  151. /package/dist/{render → ui}/operation/get-request-data.js +0 -0
@@ -1,25 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
3
- import { AccordionContent, AccordionHeader, AccordionItem, Accordions, AccordionTrigger, } from '../ui/components/accordion.js';
4
- import { API, APIExample, APIInfo, ObjectCollapsible, Property, Root, } from '../ui/index.js';
5
- import { APIPlayground } from '../playground/index.js';
6
- import { CodeExampleSelector } from '../ui/lazy.js';
7
- import { CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, } from 'fumadocs-ui/components/codeblock';
8
- export function createRenders() {
9
- return {
10
- Root,
11
- API,
12
- APIInfo: ({ children, head }) => (_jsxs(APIInfo, { children: [head, children] })),
13
- APIExample,
14
- Responses: (props) => (_jsx(Tabs, { ...props, groupId: "fumadocs_openapi_responses" })),
15
- Response: Tab,
16
- ResponseTypes: (props) => (_jsx(Accordions, { type: "single", className: "pt-2", defaultValue: props.defaultValue, children: props.children })),
17
- ResponseType: (props) => (_jsxs(AccordionItem, { value: props.label, children: [_jsx(AccordionHeader, { children: _jsx(AccordionTrigger, { children: props.label }) }), _jsx(AccordionContent, { className: "prose-no-margin", children: props.children })] })),
18
- Property,
19
- ObjectCollapsible,
20
- Requests: ({ items, children }) => (_jsxs(CodeBlockTabs, { groupId: "fumadocs_openapi_requests", defaultValue: items[0], children: [_jsx(CodeBlockTabsList, { children: items.map((item) => (_jsx(CodeBlockTabsTrigger, { value: item, children: item }, item))) }), children] })),
21
- CodeExampleSelector,
22
- Request: (props) => (_jsx(CodeBlockTab, { value: props.name, children: props.children })),
23
- APIPlayground,
24
- };
25
- }
@@ -1,18 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import type { SchemaUIData } from '../../render/schema/server.js';
3
- interface DataContextType extends SchemaUIData {
4
- readOnly?: boolean;
5
- writeOnly?: boolean;
6
- }
7
- export declare function SchemaUIProvider(props: {
8
- value: DataContextType;
9
- children: ReactNode;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- export interface SchemaUIProps {
12
- name: string;
13
- required?: boolean;
14
- as?: 'property' | 'body';
15
- }
16
- export declare function SchemaUI({ name, required, as, }: SchemaUIProps): import("react/jsx-runtime").JSX.Element;
17
- export {};
18
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/render/schema/client.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAUvE,UAAU,eAAgB,SAAQ,YAAY;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA2BD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAEA;AAUD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,QAAgB,EAChB,EAAe,GAChB,EAAE,aAAa,2CAiBf"}
@@ -1,7 +0,0 @@
1
- import { type SchemaUIOptions } from '../../render/schema/server.js';
2
- import { type SchemaUIProps } from '../../render/schema/client.js';
3
- export declare function Schema(props: SchemaUIOptions & SchemaUIProps & {
4
- readOnly?: boolean;
5
- writeOnly?: boolean;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/schema/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,MAAM,CACpB,KAAK,EAAE,eAAe,GACpB,aAAa,GAAG;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,2CAeJ"}
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { generateSchemaUI } from '../../render/schema/server.js';
3
- import { SchemaUI, SchemaUIProvider, } from '../../render/schema/client.js';
4
- export function Schema(props) {
5
- const data = generateSchemaUI(props);
6
- return (_jsx(SchemaUIProvider, { value: {
7
- ...data,
8
- readOnly: props.readOnly,
9
- writeOnly: props.writeOnly,
10
- }, children: _jsx(SchemaUI, { name: props.name, required: props.required, as: props.as }) }));
11
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/render/schema/server.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IAEvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAChC,CACI;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,OAAO,CAAC;KACnB,EAAE,CAAC;CACL,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,GACD;IACE,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;CACL,CACJ,CAAC;AAEJ,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAClC;AAED,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,YAAY,CAoP7E"}
@@ -1,16 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- export declare function ObjectCollapsible(props: {
3
- name: string;
4
- children: ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- export interface PropertyProps {
7
- name: ReactNode;
8
- type: ReactNode;
9
- required?: boolean;
10
- deprecated?: boolean;
11
- nested?: boolean;
12
- children?: ReactNode;
13
- className?: string;
14
- }
15
- export declare function Property({ name, type, required, deprecated, nested, ...props }: PropertyProps): import("react/jsx-runtime").JSX.Element;
16
- //# sourceMappingURL=ui.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/render/schema/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAWvC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAiBA;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,MAAc,EACd,GAAG,KAAK,EACT,EAAE,aAAa,2CAoCf"}
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
3
- import { cn } from 'fumadocs-ui/utils/cn';
4
- import { buttonVariants } from 'fumadocs-ui/components/ui/button';
5
- import { ChevronDown } from 'fumadocs-ui/internal/icons';
6
- import { Badge } from '../../ui/components/method-label.js';
7
- export function ObjectCollapsible(props) {
8
- return (_jsxs(Collapsible, { className: "my-2", ...props, children: [_jsxs(CollapsibleTrigger, { className: cn(buttonVariants({ color: 'secondary', size: 'sm' }), 'group px-3 py-2 data-[state=open]:rounded-b-none'), children: [props.name, _jsx(ChevronDown, { className: "size-4 text-fd-muted-foreground group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { className: "-mt-px *:bg-fd-card", children: props.children })] }));
9
- }
10
- export function Property({ name, type, required, deprecated, nested = false, ...props }) {
11
- return (_jsxs("div", { className: cn('text-sm border-t', nested
12
- ? 'p-3 border-x bg-fd-card last:rounded-b-xl first:rounded-tr-xl last:border-b'
13
- : 'py-4 first:border-t-0', props.className), children: [_jsxs("div", { className: "flex flex-wrap items-center gap-3 not-prose", children: [_jsxs("span", { className: "font-medium font-mono text-fd-primary", children: [name, required === false && (_jsx("span", { className: "text-fd-muted-foreground", children: "?" }))] }), typeof type === 'string' ? (_jsx("span", { className: "text-sm font-mono text-fd-muted-foreground", children: type })) : (type), deprecated && (_jsx(Badge, { color: "yellow", className: "ms-auto text-xs", children: "Deprecated" }))] }), _jsx("div", { className: "prose-no-margin pt-2.5 empty:hidden", children: props.children })] }));
14
- }
@@ -1,4 +0,0 @@
1
- export declare function CopyResponseTypeScript({ code }: {
2
- code: string;
3
- }): import("react/jsx-runtime").JSX.Element;
4
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CAgChE"}
@@ -1,24 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import type { CodeSample } from '../../render/operation/index.js';
3
- import type { SamplesProps } from '../../render/renderer.js';
4
- import type { RawRequestData, RequestData } from '../../requests/types.js';
5
- export declare function CodeExampleProvider({ route, examples, initialKey, children, }: {
6
- route: string;
7
- examples: {
8
- key: string;
9
- data: RawRequestData;
10
- encoded: RequestData;
11
- }[];
12
- initialKey?: string;
13
- children: ReactNode;
14
- }): import("react/jsx-runtime").JSX.Element;
15
- export declare function CodeExample(sample: CodeSample): import("react/jsx-runtime").JSX.Element | null;
16
- export declare function CodeExampleSelector({ items }: SamplesProps): import("react/jsx-runtime").JSX.Element;
17
- export declare function useRequestInitialData(): {
18
- key: string;
19
- data: RawRequestData;
20
- };
21
- export declare function useRequestDataUpdater(): {
22
- setData: (data: RawRequestData, encoded: RequestData) => void;
23
- };
24
- //# sourceMappingURL=code-example.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-example.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/code-example.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AActD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAmBpE,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,cAAc,CAAC;QACrB,OAAO,EAAE,WAAW,CAAC;KACtB,EAAE,CAAC;IACJ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CA6DA;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,kDA2C7C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY,2CAoB1D;AAgBD,wBAAgB,qBAAqB;;;EAIpC;AAED,wBAAgB,qBAAqB;oBA1KnB,cAAc,WAAW,WAAW,KAAK,IAAI;EA6K9D"}
@@ -1,97 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useEffect, useMemo, useRef, useState, } from 'react';
4
- import { useApiContext, useServerSelectContext } from '../../ui/contexts/api.js';
5
- import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
6
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
7
- import { joinURL, resolveRequestData, resolveServerUrl, withBase, } from '../../utils/url.js';
8
- const CodeExampleContext = createContext(null);
9
- export function CodeExampleProvider({ route, examples, initialKey, children, }) {
10
- const [key, setKey] = useState(initialKey ?? examples[0].key);
11
- const listeners = useRef([]);
12
- const examplesRef = useRef(examples);
13
- examplesRef.current = examples;
14
- return (_jsx(CodeExampleContext, { value: useMemo(() => ({
15
- key,
16
- route,
17
- setKey: (newKey) => {
18
- const example = examplesRef.current.find((example) => example.key === newKey);
19
- if (!example)
20
- return;
21
- setKey(newKey);
22
- for (const listener of listeners.current) {
23
- listener(example.data, example.encoded);
24
- }
25
- },
26
- getExample: (key) => {
27
- return examplesRef.current.find((example) => example.key === key);
28
- },
29
- setData: (data, encoded) => {
30
- for (const example of examplesRef.current) {
31
- if (example.key === key) {
32
- // persistent changes
33
- example.data = data;
34
- example.encoded = encoded;
35
- break;
36
- }
37
- }
38
- for (const listener of listeners.current) {
39
- listener(data, encoded);
40
- }
41
- },
42
- removeListener: (listener) => {
43
- listeners.current = listeners.current.filter((item) => item !== listener);
44
- },
45
- addListener: (listener) => {
46
- // initial call to listeners to ensure their data is the latest
47
- // this is necessary to avoid race conditions between `useEffect()`
48
- const example = examplesRef.current.find((example) => example.key === key);
49
- listener(example.data, example.encoded);
50
- listeners.current.push(listener);
51
- },
52
- }), [key, route]), children: children }));
53
- }
54
- export function CodeExample(sample) {
55
- const { shikiOptions, mediaAdapters } = useApiContext();
56
- const { getExample, key, route, addListener, removeListener } = useContext(CodeExampleContext);
57
- const { server } = useServerSelectContext();
58
- const [data, setData] = useState(() => getExample(key).encoded);
59
- useEffect(() => {
60
- const listener = (_, encoded) => setData(encoded);
61
- addListener(listener);
62
- return () => {
63
- removeListener(listener);
64
- };
65
- }, [addListener, removeListener]);
66
- const code = useMemo(() => {
67
- if (!sample.source)
68
- return;
69
- if (typeof sample.source === 'string')
70
- return sample.source;
71
- return sample.source(joinURL(withBase(server ? resolveServerUrl(server.url, server.variables) : '/', typeof window !== 'undefined'
72
- ? window.location.origin
73
- : 'https://loading'), resolveRequestData(route, data)), data, {
74
- server: sample.serverContext,
75
- mediaAdapters,
76
- });
77
- }, [mediaAdapters, sample, server, route, data]);
78
- if (!code || !sample)
79
- return null;
80
- return (_jsx(DynamicCodeBlock, { lang: sample.lang, code: code, options: shikiOptions }));
81
- }
82
- export function CodeExampleSelector({ items }) {
83
- const { key, setKey } = useContext(CodeExampleContext);
84
- const item = items.find((item) => item.value === key);
85
- return (_jsxs(Select, { value: key, onValueChange: setKey, children: [_jsx(SelectTrigger, { className: "not-prose mb-2", children: _jsx(SelectValue, { asChild: true, children: item ? _jsx(SelectDisplay, { item: item }) : null }) }), _jsx(SelectContent, { children: items.map((item) => (_jsx(SelectItem, { value: item.value, children: _jsx(SelectDisplay, { item: item }) }, item.value))) })] }));
86
- }
87
- function SelectDisplay({ item, ...props }) {
88
- return (_jsxs("div", { ...props, children: [_jsx("span", { className: "font-medium text-sm", children: item.title }), _jsx("span", { className: "text-fd-muted-foreground", children: item.description })] }));
89
- }
90
- export function useRequestInitialData() {
91
- const { getExample, key } = useContext(CodeExampleContext);
92
- return { key, data: getExample(key).data };
93
- }
94
- export function useRequestDataUpdater() {
95
- const { setData } = useContext(CodeExampleContext);
96
- return { setData };
97
- }
package/dist/ui/lazy.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { JSX } from 'react/jsx-runtime';
2
- export declare const CodeExampleProvider: (props: {
3
- route: string;
4
- examples: {
5
- key: string;
6
- data: import("../requests/types.js").RawRequestData;
7
- encoded: import("../requests/types.js").RequestData;
8
- }[];
9
- initialKey?: string;
10
- children: import("react").ReactNode;
11
- }) => JSX.Element;
12
- export declare const CodeExample: (props: import("../render/operation/index.js").CodeSample<unknown>) => JSX.Element;
13
- export declare const CodeExampleSelector: (props: import("../render/renderer.js").SamplesProps) => JSX.Element;
14
- export declare const ClientLazy: (props: import("../playground/client.js").ClientProps) => JSX.Element;
15
- export declare const ApiProvider: (props: import("./contexts/api.js").ApiProviderProps) => JSX.Element;
16
- //# sourceMappingURL=lazy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ui/lazy.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAW7C,eAAO,MAAM,mBAAmB;;;;;;;;;iBAM/B,CAAC;AAEF,eAAO,MAAM,WAAW,2EAMvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,mEAM/B,CAAC;AAEF,eAAO,MAAM,UAAU,mEAAkD,CAAC;AAE1E,eAAO,MAAM,WAAW,mEAIvB,CAAC"}
package/dist/ui/lazy.js DELETED
@@ -1,22 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { lazy } from 'react';
4
- // Waku wraps all export functions of a "use client" file in `React.lazy`, but `lazy(lazy(() => ...))` causes error.
5
- // we wrap another layer of component such that it is valid
6
- // TODO: perhaps we can remove it once Waku migrated to vite-rsc
7
- function wrap(V) {
8
- return function wrapper(props) {
9
- return _jsx(V, { ...props });
10
- };
11
- }
12
- export const CodeExampleProvider = wrap(lazy(() => import('./contexts/code-example.js').then((mod) => ({
13
- default: mod.CodeExampleProvider,
14
- }))));
15
- export const CodeExample = wrap(lazy(() => import('./contexts/code-example.js').then((mod) => ({
16
- default: mod.CodeExample,
17
- }))));
18
- export const CodeExampleSelector = wrap(lazy(() => import('./contexts/code-example.js').then((mod) => ({
19
- default: mod.CodeExampleSelector,
20
- }))));
21
- export const ClientLazy = wrap(lazy(() => import('../playground/client.js')));
22
- export const ApiProvider = wrap(lazy(() => import('./contexts/api.js').then((mod) => ({ default: mod.ApiProvider }))));
@@ -1 +0,0 @@
1
- {"version":3,"file":"select-tabs.d.ts","sourceRoot":"","sources":["../../src/ui/select-tabs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAQhC,wBAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAQA;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,uDAKA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,2CAoB5D"}
@@ -1,20 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useMemo, useState, } from 'react';
4
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
5
- import { cn } from 'fumadocs-ui/utils/cn';
6
- const Context = createContext(null);
7
- export function SelectTabs({ defaultValue, children, }) {
8
- const [type, setType] = useState(defaultValue ?? null);
9
- return (_jsx(Context, { value: useMemo(() => ({ type, setType }), [type]), children: children }));
10
- }
11
- export function SelectTab({ value, ...props }) {
12
- const ctx = useContext(Context);
13
- if (value !== ctx?.type)
14
- return;
15
- return _jsx("div", { ...props, children: props.children });
16
- }
17
- export function SelectTabTrigger({ items, ...props }) {
18
- const { type, setType } = useContext(Context);
19
- return (_jsxs(Select, { value: type ?? '', onValueChange: setType, children: [_jsx(SelectTrigger, { ...props, className: cn('not-prose w-fit', props.className), children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: items.map((type) => (_jsx(SelectItem, { value: type, children: type }, type))) })] }));
20
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"server-select.d.ts","sourceRoot":"","sources":["../../src/ui/server-select.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAgBjE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,uDAwDzE"}