fumadocs-typescript 5.0.0 → 5.1.0
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/base-Dvhn4vZx.d.ts +114 -0
- package/dist/index.d.ts +40 -32
- package/dist/index.js +296 -412
- package/dist/parse-tags-B09hzgIX.js +68 -0
- package/dist/ui/index.d.ts +26 -15
- package/dist/ui/index.js +44 -82
- package/package.json +28 -26
- package/dist/base-C72MF-7Q.d.ts +0 -110
- package/dist/chunk-H4DZJVYN.js +0 -142
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { remark } from "remark";
|
|
2
|
+
import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
|
|
3
|
+
import { createRehypeCode } from "fumadocs-core/mdx-plugins/rehype-code.core";
|
|
4
|
+
import remarkRehype from "remark-rehype";
|
|
5
|
+
import { highlightHast } from "fumadocs-core/highlight/core";
|
|
6
|
+
import { configDefault } from "fumadocs-core/highlight";
|
|
7
|
+
|
|
8
|
+
//#region src/markdown.ts
|
|
9
|
+
function markdownRenderer(shiki = configDefault) {
|
|
10
|
+
const processor = remark().use(remarkGfm).use(remarkRehype).use(createRehypeCode(shiki), {
|
|
11
|
+
lazy: true,
|
|
12
|
+
langs: ["ts", "tsx"],
|
|
13
|
+
transformers: [],
|
|
14
|
+
parseMetaString: void 0
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
async renderTypeToHast(type) {
|
|
18
|
+
return {
|
|
19
|
+
type: "element",
|
|
20
|
+
tagName: "span",
|
|
21
|
+
properties: { class: "shiki" },
|
|
22
|
+
children: [{
|
|
23
|
+
type: "element",
|
|
24
|
+
tagName: "code",
|
|
25
|
+
properties: {},
|
|
26
|
+
children: (await highlightHast(type, {
|
|
27
|
+
config: shiki,
|
|
28
|
+
lang: "ts",
|
|
29
|
+
structure: "inline"
|
|
30
|
+
})).children
|
|
31
|
+
}]
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
renderMarkdownToHast(md) {
|
|
35
|
+
md = md.replace(/{@link (?<link>[^}]*)}/g, "$1");
|
|
36
|
+
return processor.run(processor.parse(md));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/lib/parse-tags.ts
|
|
43
|
+
/**
|
|
44
|
+
* Parse tags, only returns recognized fields.
|
|
45
|
+
*/
|
|
46
|
+
function parseTags(tags) {
|
|
47
|
+
const typed = {};
|
|
48
|
+
for (const { name: key, text } of tags) {
|
|
49
|
+
if (key === "default" || key === "defaultValue") {
|
|
50
|
+
typed.default = text;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (key === "param") {
|
|
54
|
+
const [param, description] = text.split("-", 2);
|
|
55
|
+
typed.params ??= [];
|
|
56
|
+
typed.params.push({
|
|
57
|
+
name: param.trim(),
|
|
58
|
+
description: description.trim()
|
|
59
|
+
});
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (key === "returns") typed.returns = text;
|
|
63
|
+
}
|
|
64
|
+
return typed;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { markdownRenderer as n, parseTags as t };
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { i as Generator, l as BaseTypeTableProps, u as GenerateTypeTableOptions } from "../base-Dvhn4vZx.js";
|
|
2
|
+
import * as runtime from "react/jsx-runtime";
|
|
3
|
+
import "server-only";
|
|
4
|
+
import { ResolvedShikiConfig } from "fumadocs-core/highlight/config";
|
|
5
|
+
import { ReactNode } from "react";
|
|
5
6
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
//#region src/ui/auto-type-table.d.ts
|
|
8
|
+
interface JSXMarkdownRenderer {
|
|
9
|
+
renderMarkdown: (md: string) => Promise<ReactNode>;
|
|
10
|
+
renderType: (type: string) => Promise<ReactNode>;
|
|
11
|
+
}
|
|
12
|
+
interface AutoTypeTableProps extends BaseTypeTableProps, Partial<JSXMarkdownRenderer> {
|
|
13
|
+
generator: Generator;
|
|
14
|
+
/** Shiki configuration when using default `renderMarkdown` & `renderType` */
|
|
15
|
+
shiki?: ResolvedShikiConfig;
|
|
16
|
+
options?: GenerateTypeTableOptions;
|
|
17
|
+
}
|
|
18
|
+
declare function AutoTypeTable({
|
|
19
|
+
generator,
|
|
20
|
+
options,
|
|
21
|
+
renderType,
|
|
22
|
+
renderMarkdown,
|
|
23
|
+
shiki,
|
|
24
|
+
...props
|
|
25
|
+
}: AutoTypeTableProps): Promise<Promise<runtime.JSX.Element>[]>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { AutoTypeTable, AutoTypeTableProps };
|
package/dist/ui/index.js
CHANGED
|
@@ -1,89 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
__objRest,
|
|
4
|
-
__spreadProps,
|
|
5
|
-
__spreadValues,
|
|
6
|
-
parseTags,
|
|
7
|
-
renderMarkdownToHast,
|
|
8
|
-
renderTypeToHast
|
|
9
|
-
} from "../chunk-H4DZJVYN.js";
|
|
10
|
-
|
|
11
|
-
// src/ui/auto-type-table.tsx
|
|
12
|
-
import {
|
|
13
|
-
TypeTable
|
|
14
|
-
} from "fumadocs-ui/components/type-table";
|
|
1
|
+
import { n as markdownRenderer, t as parseTags } from "../parse-tags-B09hzgIX.js";
|
|
2
|
+
import { TypeTable } from "fumadocs-ui/components/type-table";
|
|
15
3
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
16
4
|
import * as runtime from "react/jsx-runtime";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
17
6
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
18
7
|
import "server-only";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
type: yield renderType(entry.simplifiedType),
|
|
49
|
-
typeDescription: yield renderType(entry.type),
|
|
50
|
-
description: yield renderMarkdown(entry.description),
|
|
51
|
-
default: tags.default ? yield renderType(tags.default) : void 0,
|
|
52
|
-
parameters: paramNodes,
|
|
53
|
-
required: entry.required,
|
|
54
|
-
deprecated: entry.deprecated,
|
|
55
|
-
returns: tags.returns ? yield renderMarkdown(tags.returns) : void 0
|
|
56
|
-
}
|
|
57
|
-
];
|
|
58
|
-
}));
|
|
59
|
-
return /* @__PURE__ */ jsx2(
|
|
60
|
-
TypeTable,
|
|
61
|
-
{
|
|
62
|
-
type: Object.fromEntries(yield Promise.all(entries))
|
|
63
|
-
},
|
|
64
|
-
item.name
|
|
65
|
-
);
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
8
|
+
|
|
9
|
+
//#region src/ui/auto-type-table.tsx
|
|
10
|
+
async function AutoTypeTable({ generator, options = {}, renderType, renderMarkdown, shiki, ...props }) {
|
|
11
|
+
if (!renderType || !renderMarkdown) {
|
|
12
|
+
const renderer = markdownRenderer(shiki);
|
|
13
|
+
renderType ??= async (v) => toJsx(await renderer.renderTypeToHast(v));
|
|
14
|
+
renderMarkdown ??= async (v) => toJsx(await renderer.renderMarkdownToHast(v));
|
|
15
|
+
}
|
|
16
|
+
return (await generator.generateTypeTable(props, options)).map(async (item) => {
|
|
17
|
+
const entries = item.entries.map(async (entry) => {
|
|
18
|
+
const tags = parseTags(entry.tags);
|
|
19
|
+
const paramNodes = [];
|
|
20
|
+
for (const param of tags.params ?? []) paramNodes.push({
|
|
21
|
+
name: param.name,
|
|
22
|
+
description: param.description ? await renderMarkdown(param.description) : void 0
|
|
23
|
+
});
|
|
24
|
+
return [entry.name, {
|
|
25
|
+
type: await renderType(entry.simplifiedType),
|
|
26
|
+
typeDescription: await renderType(entry.type),
|
|
27
|
+
description: await renderMarkdown(entry.description),
|
|
28
|
+
default: tags.default ? await renderType(tags.default) : void 0,
|
|
29
|
+
parameters: paramNodes,
|
|
30
|
+
required: entry.required,
|
|
31
|
+
deprecated: entry.deprecated,
|
|
32
|
+
returns: tags.returns ? await renderMarkdown(tags.returns) : void 0
|
|
33
|
+
}];
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ jsx(TypeTable, { type: Object.fromEntries(await Promise.all(entries)) }, item.name);
|
|
36
|
+
});
|
|
68
37
|
}
|
|
69
38
|
function toJsx(hast) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return toJsx(yield renderTypeToHast(type));
|
|
80
|
-
});
|
|
39
|
+
return toJsxRuntime(hast, {
|
|
40
|
+
Fragment: runtime.Fragment,
|
|
41
|
+
jsx: runtime.jsx,
|
|
42
|
+
jsxs: runtime.jsxs,
|
|
43
|
+
components: {
|
|
44
|
+
...defaultMdxComponents,
|
|
45
|
+
img: void 0
|
|
46
|
+
}
|
|
47
|
+
});
|
|
81
48
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
export {
|
|
88
|
-
AutoTypeTable
|
|
89
|
-
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { AutoTypeTable };
|
package/package.json
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"Docs",
|
|
6
7
|
"NextJs",
|
|
7
|
-
"fumadocs"
|
|
8
|
-
"Docs"
|
|
8
|
+
"fumadocs"
|
|
9
9
|
],
|
|
10
10
|
"homepage": "https://fumadocs.dev",
|
|
11
|
-
"repository": "github:fuma-nama/fumadocs",
|
|
12
11
|
"license": "MIT",
|
|
13
12
|
"author": "Fuma Nama",
|
|
13
|
+
"repository": "github:fuma-nama/fumadocs",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/*"
|
|
16
|
+
],
|
|
14
17
|
"type": "module",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
15
20
|
"exports": {
|
|
16
21
|
".": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
19
24
|
},
|
|
20
25
|
"./ui": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
26
|
+
"types": "./dist/ui/index.d.ts",
|
|
27
|
+
"import": "./dist/ui/index.js"
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"dist/*"
|
|
29
|
-
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
30
33
|
"dependencies": {
|
|
31
34
|
"estree-util-value-to-estree": "^3.5.0",
|
|
32
35
|
"hast-util-to-estree": "^3.1.3",
|
|
@@ -35,27 +38,29 @@
|
|
|
35
38
|
"remark-rehype": "^11.1.2",
|
|
36
39
|
"tinyglobby": "^0.2.15",
|
|
37
40
|
"ts-morph": "^27.0.2",
|
|
38
|
-
"
|
|
41
|
+
"unified": "^11.0.5",
|
|
42
|
+
"unist-util-visit": "^5.1.0"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"@mdx-js/mdx": "^3.1.1",
|
|
42
46
|
"@types/estree": "^1.0.8",
|
|
43
47
|
"@types/hast": "^3.0.4",
|
|
44
48
|
"@types/mdast": "^4.0.4",
|
|
45
|
-
"@types/node": "
|
|
46
|
-
"@types/react": "^19.2.
|
|
49
|
+
"@types/node": "25.1.0",
|
|
50
|
+
"@types/react": "^19.2.10",
|
|
47
51
|
"@types/react-dom": "^19.2.3",
|
|
52
|
+
"tsdown": "^0.19.0",
|
|
48
53
|
"typescript": "^5.9.3",
|
|
49
|
-
"unified": "^11.0.5",
|
|
50
54
|
"eslint-config-custom": "0.0.0",
|
|
51
|
-
"fumadocs-core": "
|
|
52
|
-
"fumadocs-ui": "
|
|
55
|
+
"fumadocs-core": "17.0.0",
|
|
56
|
+
"fumadocs-ui": "17.0.0",
|
|
53
57
|
"tsconfig": "0.0.0"
|
|
54
58
|
},
|
|
55
59
|
"peerDependencies": {
|
|
56
60
|
"@types/react": "*",
|
|
57
|
-
"fumadocs-core": "^
|
|
58
|
-
"fumadocs-ui": "^
|
|
61
|
+
"fumadocs-core": "^16.5.0",
|
|
62
|
+
"fumadocs-ui": "^16.5.0",
|
|
63
|
+
"react": "*",
|
|
59
64
|
"typescript": "*"
|
|
60
65
|
},
|
|
61
66
|
"peerDependenciesMeta": {
|
|
@@ -66,13 +71,10 @@
|
|
|
66
71
|
"optional": true
|
|
67
72
|
}
|
|
68
73
|
},
|
|
69
|
-
"publishConfig": {
|
|
70
|
-
"access": "public"
|
|
71
|
-
},
|
|
72
74
|
"scripts": {
|
|
73
|
-
"build": "
|
|
75
|
+
"build": "tsdown",
|
|
74
76
|
"clean": "rimraf dist",
|
|
75
|
-
"dev": "
|
|
77
|
+
"dev": "tsdown --watch",
|
|
76
78
|
"lint": "eslint .",
|
|
77
79
|
"types:check": "tsc --noEmit"
|
|
78
80
|
}
|
package/dist/base-C72MF-7Q.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Project, Type, ExportedDeclarations, Symbol } from 'ts-morph';
|
|
2
|
-
|
|
3
|
-
interface TypescriptConfig {
|
|
4
|
-
files?: string[];
|
|
5
|
-
tsconfigPath?: string;
|
|
6
|
-
/** A root directory to resolve relative path entries in the config file to. e.g. outDir */
|
|
7
|
-
basePath?: string;
|
|
8
|
-
}
|
|
9
|
-
declare function createProject(options?: TypescriptConfig): Project;
|
|
10
|
-
|
|
11
|
-
interface BaseTypeTableProps {
|
|
12
|
-
/**
|
|
13
|
-
* The path to source TypeScript file.
|
|
14
|
-
*/
|
|
15
|
-
path?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Exported type name to generate from.
|
|
18
|
-
*/
|
|
19
|
-
name?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Set the type to generate from.
|
|
22
|
-
*
|
|
23
|
-
* When used with `name`, it generates the type with `name` as export name.
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* export const myName = MyType;
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* When `type` contains multiple lines, `export const` is not added.
|
|
30
|
-
* You need to export it manually, and specify the type name with `name`.
|
|
31
|
-
*
|
|
32
|
-
* ```tsx
|
|
33
|
-
* <AutoTypeTable
|
|
34
|
-
* path="./file.ts"
|
|
35
|
-
* type={`import { ReactNode } from "react"
|
|
36
|
-
* export const MyName = ReactNode`}
|
|
37
|
-
* name="MyName"
|
|
38
|
-
* />
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
type?: string;
|
|
42
|
-
}
|
|
43
|
-
interface GenerateTypeTableOptions extends GenerateOptions {
|
|
44
|
-
/**
|
|
45
|
-
* base path to resolve `path` prop
|
|
46
|
-
*/
|
|
47
|
-
basePath?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface Cache {
|
|
51
|
-
read: (key: string) => unknown | undefined | Promise<unknown | undefined>;
|
|
52
|
-
write: (key: string, value: unknown) => void | Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface GeneratedDoc {
|
|
56
|
-
name: string;
|
|
57
|
-
description: string;
|
|
58
|
-
entries: DocEntry[];
|
|
59
|
-
}
|
|
60
|
-
interface DocEntry {
|
|
61
|
-
name: string;
|
|
62
|
-
description: string;
|
|
63
|
-
type: string;
|
|
64
|
-
simplifiedType: string;
|
|
65
|
-
tags: RawTag[];
|
|
66
|
-
required: boolean;
|
|
67
|
-
deprecated: boolean;
|
|
68
|
-
}
|
|
69
|
-
interface RawTag {
|
|
70
|
-
name: string;
|
|
71
|
-
text: string;
|
|
72
|
-
}
|
|
73
|
-
interface EntryContext {
|
|
74
|
-
program: Project;
|
|
75
|
-
transform?: Transformer;
|
|
76
|
-
type: Type;
|
|
77
|
-
declaration: ExportedDeclarations;
|
|
78
|
-
}
|
|
79
|
-
type Transformer = (this: EntryContext, entry: DocEntry, propertyType: Type, propertySymbol: Symbol) => void;
|
|
80
|
-
interface GenerateOptions {
|
|
81
|
-
/**
|
|
82
|
-
* Allow fields with `@internal` tag
|
|
83
|
-
*
|
|
84
|
-
* @defaultValue false
|
|
85
|
-
*/
|
|
86
|
-
allowInternal?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Modify output property entry
|
|
89
|
-
*/
|
|
90
|
-
transform?: Transformer;
|
|
91
|
-
}
|
|
92
|
-
type Generator = ReturnType<typeof createGenerator>;
|
|
93
|
-
interface GeneratorOptions extends TypescriptConfig {
|
|
94
|
-
/**
|
|
95
|
-
* cache results, note that some options are not marked as dependency.
|
|
96
|
-
*
|
|
97
|
-
* @defaultValue false
|
|
98
|
-
*/
|
|
99
|
-
cache?: Cache | false;
|
|
100
|
-
project?: Project;
|
|
101
|
-
}
|
|
102
|
-
declare function createGenerator(config?: GeneratorOptions | Project): {
|
|
103
|
-
generateDocumentation(file: {
|
|
104
|
-
path: string;
|
|
105
|
-
content?: string;
|
|
106
|
-
}, name: string | undefined, options?: GenerateOptions): Promise<GeneratedDoc[]>;
|
|
107
|
-
generateTypeTable(props: BaseTypeTableProps, options?: GenerateTypeTableOptions): Promise<GeneratedDoc[]>;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export { type BaseTypeTableProps as B, type Cache as C, type DocEntry as D, type GenerateTypeTableOptions as G, type RawTag as R, type Generator as a, type GeneratedDoc as b, createProject as c, type GenerateOptions as d, type GeneratorOptions as e, createGenerator as f };
|
package/dist/chunk-H4DZJVYN.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/markdown.ts
|
|
54
|
-
import { remark } from "remark";
|
|
55
|
-
import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
|
|
56
|
-
import {
|
|
57
|
-
rehypeCode
|
|
58
|
-
} from "fumadocs-core/mdx-plugins/rehype-code";
|
|
59
|
-
import remarkRehype from "remark-rehype";
|
|
60
|
-
import { getHighlighter } from "fumadocs-core/highlight";
|
|
61
|
-
var shikiOptions = {
|
|
62
|
-
lazy: true,
|
|
63
|
-
langs: ["ts", "tsx"],
|
|
64
|
-
// disable default transformers & meta parser
|
|
65
|
-
transformers: [],
|
|
66
|
-
parseMetaString: void 0,
|
|
67
|
-
themes: {
|
|
68
|
-
light: "github-light",
|
|
69
|
-
dark: "github-dark"
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var processor = remark().use(remarkGfm).use(remarkRehype).use(rehypeCode, shikiOptions);
|
|
73
|
-
function renderTypeToHast(type) {
|
|
74
|
-
return __async(this, null, function* () {
|
|
75
|
-
const highlighter = yield getHighlighter("js", {
|
|
76
|
-
langs: ["ts"],
|
|
77
|
-
themes: Object.values(shikiOptions.themes)
|
|
78
|
-
});
|
|
79
|
-
const nodes = highlighter.codeToHast(type, {
|
|
80
|
-
lang: "ts",
|
|
81
|
-
structure: "inline",
|
|
82
|
-
themes: shikiOptions.themes,
|
|
83
|
-
defaultColor: false
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
type: "element",
|
|
87
|
-
tagName: "span",
|
|
88
|
-
properties: {
|
|
89
|
-
class: "shiki"
|
|
90
|
-
},
|
|
91
|
-
children: [
|
|
92
|
-
{
|
|
93
|
-
type: "element",
|
|
94
|
-
tagName: "code",
|
|
95
|
-
properties: {},
|
|
96
|
-
children: nodes.children
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function renderMarkdownToHast(md) {
|
|
103
|
-
return __async(this, null, function* () {
|
|
104
|
-
md = md.replace(new RegExp("{@link (?<link>[^}]*)}", "g"), "$1");
|
|
105
|
-
return processor.run(processor.parse(md));
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/lib/parse-tags.ts
|
|
110
|
-
function parseTags(tags) {
|
|
111
|
-
var _a;
|
|
112
|
-
const typed = {};
|
|
113
|
-
for (const { name: key, text } of tags) {
|
|
114
|
-
if (key === "default" || key === "defaultValue") {
|
|
115
|
-
typed.default = text;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (key === "param") {
|
|
119
|
-
const [param, description] = text.split("-", 2);
|
|
120
|
-
(_a = typed.params) != null ? _a : typed.params = [];
|
|
121
|
-
typed.params.push({
|
|
122
|
-
name: param.trim(),
|
|
123
|
-
description: description.trim()
|
|
124
|
-
});
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (key === "returns") {
|
|
128
|
-
typed.returns = text;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return typed;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
__spreadValues,
|
|
136
|
-
__spreadProps,
|
|
137
|
-
__objRest,
|
|
138
|
-
__async,
|
|
139
|
-
renderTypeToHast,
|
|
140
|
-
renderMarkdownToHast,
|
|
141
|
-
parseTags
|
|
142
|
-
};
|