fumadocs-typescript 5.0.0 → 5.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.
@@ -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 };
@@ -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
- };