fumadocs-typescript 5.3.0 → 5.4.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/index.d.ts +2 -3
- package/dist/index.js +188 -52
- package/dist/{markdown-CM2iLQC-.d.ts → markdown-CcCPhMmC.d.ts} +36 -10
- package/dist/ui/index.d.ts +2 -13
- package/package.json +10 -11
- package/dist/get-simple-form-B_lm5cA2.js +0 -59
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as GeneratedDoc, c as RawTag, d as
|
|
1
|
+
import { a as GeneratedDoc, c as RawTag, d as TypescriptConfig, f as createProject, g as GenerateTypeTableOptions, h as BaseTypeTableProps, i as GenerateOptions, l as createGenerator, m as generateHash, n as ShikiOptions, o as Generator, p as Cache, r as DocEntry, s as GeneratorOptions, t as MarkdownRenderer, u as Project } from "./markdown-CcCPhMmC.js";
|
|
2
2
|
import { Root } from "mdast";
|
|
3
3
|
import { Transformer } from "unified";
|
|
4
|
-
|
|
5
4
|
//#region src/lib/remark-auto-type-table.d.ts
|
|
6
5
|
interface RemarkAutoTypeTableOptions {
|
|
7
6
|
/**
|
|
@@ -41,4 +40,4 @@ declare function remarkAutoTypeTable(config?: RemarkAutoTypeTableOptions): Trans
|
|
|
41
40
|
//#region src/cache/fs-cache.d.ts
|
|
42
41
|
declare function createFileSystemGeneratorCache(dir: string): Cache;
|
|
43
42
|
//#endregion
|
|
44
|
-
export { Cache, DocEntry, GenerateOptions, GeneratedDoc, Generator, GeneratorOptions, type MarkdownRenderer, RawTag, RemarkAutoTypeTableOptions, TypeTableProps, TypescriptConfig, createFileSystemGeneratorCache, createGenerator, createProject, generateHash, remarkAutoTypeTable };
|
|
43
|
+
export { Cache, DocEntry, GenerateOptions, GeneratedDoc, Generator, GeneratorOptions, type MarkdownRenderer, type Project, RawTag, RemarkAutoTypeTableOptions, TypeTableProps, type TypescriptConfig, createFileSystemGeneratorCache, createGenerator, createProject, generateHash, remarkAutoTypeTable };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { n as markdownRenderer, t as parseTags } from "./parse-tags-Cikh_NrX.js";
|
|
2
|
+
import { API, NodeBuilderFlags, ObjectFlags, SignatureKind, SymbolFlags, TypeFlags, isIntersectionType, isObjectType, isUnionType } from "typescript/unstable/sync";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
6
|
+
import fs$1 from "node:fs";
|
|
5
7
|
import { valueToEstree } from "estree-util-value-to-estree";
|
|
6
8
|
import { visit } from "unist-util-visit";
|
|
7
9
|
import { toEstree } from "hast-util-to-estree";
|
|
@@ -30,16 +32,150 @@ function generateHash(str) {
|
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
32
34
|
//#region package.json
|
|
33
|
-
var version = "5.
|
|
35
|
+
var version = "5.4.0";
|
|
34
36
|
//#endregion
|
|
35
|
-
//#region src/lib/
|
|
37
|
+
//#region src/lib/get-simple-form.ts
|
|
38
|
+
function getSimpleForm(type, checker, location, options = {}) {
|
|
39
|
+
const { override, shouldSimplify, noUndefined = false } = options;
|
|
40
|
+
if ((type.flags & TypeFlags.Undefined) !== 0 && noUndefined) return "";
|
|
41
|
+
const overridden = override?.({
|
|
42
|
+
checker,
|
|
43
|
+
type,
|
|
44
|
+
location
|
|
45
|
+
});
|
|
46
|
+
if (overridden) return overridden;
|
|
47
|
+
if (shouldSimplify && !shouldSimplify({
|
|
48
|
+
checker,
|
|
49
|
+
type,
|
|
50
|
+
location
|
|
51
|
+
})) return checker.typeToString(type, location, NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope);
|
|
52
|
+
const alias = type.getAliasSymbol();
|
|
53
|
+
if (alias) {
|
|
54
|
+
const args = type.getAliasTypeArguments();
|
|
55
|
+
if (args.length === 0) return alias.name;
|
|
56
|
+
const nextOptions = {
|
|
57
|
+
...options,
|
|
58
|
+
noUndefined: false
|
|
59
|
+
};
|
|
60
|
+
return `${alias.name}<${args.map((arg) => getSimpleForm(arg, checker, location, nextOptions)).join(", ")}>`;
|
|
61
|
+
}
|
|
62
|
+
if (isUnionType(type)) {
|
|
63
|
+
if (noUndefined) {
|
|
64
|
+
const members = type.getTypes().filter((t) => (t.flags & TypeFlags.Undefined) === 0);
|
|
65
|
+
if (members.length === 0) return "undefined";
|
|
66
|
+
if (members.length === 1) return getSimpleForm(members[0], checker, location, options);
|
|
67
|
+
}
|
|
68
|
+
return "union";
|
|
69
|
+
}
|
|
70
|
+
if (isIntersectionType(type)) {
|
|
71
|
+
const types = [];
|
|
72
|
+
for (const t of type.getTypes()) {
|
|
73
|
+
const str = getSimpleForm(t, checker, location, options);
|
|
74
|
+
if (str.length > 0 && str !== "never") types.unshift(str);
|
|
75
|
+
}
|
|
76
|
+
return dedupe(types).join(" & ");
|
|
77
|
+
}
|
|
78
|
+
if (isObjectType(type)) {
|
|
79
|
+
if (checker.isTupleType(type)) return "tuple";
|
|
80
|
+
if (checker.isArrayType(type)) return "array";
|
|
81
|
+
if (checker.getSignaturesOfType(type, SignatureKind.Call).length > 0) return "function";
|
|
82
|
+
return "object";
|
|
83
|
+
}
|
|
84
|
+
if ((type.flags & (TypeFlags.Primitive | TypeFlags.AnyOrUnknown | TypeFlags.Never)) === 0 && checker.getSignaturesOfType(type, SignatureKind.Call).length > 0) return "function";
|
|
85
|
+
return checker.typeToString(type, location, NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope);
|
|
86
|
+
}
|
|
87
|
+
function dedupe(arr) {
|
|
88
|
+
const dedupe = /* @__PURE__ */ new Set();
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const item of arr) if (!dedupe.has(item)) {
|
|
91
|
+
out.push(item);
|
|
92
|
+
dedupe.add(item);
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/lib/project.ts
|
|
98
|
+
function normalizePath(p) {
|
|
99
|
+
let out = path.resolve(p).replaceAll("\\", "/");
|
|
100
|
+
if (process.platform === "win32" && /^[A-Z]:/.test(out)) out = out[0].toLowerCase() + out.slice(1);
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
function readDiskFile(filePath) {
|
|
104
|
+
try {
|
|
105
|
+
return fs$1.readFileSync(filePath, "utf-8");
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
36
110
|
async function createProject(options = {}) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
111
|
+
const tsconfigPath = normalizePath(options.tsconfigPath ?? "./tsconfig.json");
|
|
112
|
+
if (!fs$1.existsSync(tsconfigPath)) throw new Error(`tsconfig file not found: ${tsconfigPath}`);
|
|
113
|
+
const dir = path.posix.dirname(tsconfigPath);
|
|
114
|
+
/** in-memory files, overriding the file system */
|
|
115
|
+
const virtualFiles = /* @__PURE__ */ new Map();
|
|
116
|
+
/** root files of the generated tsconfig */
|
|
117
|
+
const rootFiles = /* @__PURE__ */ new Set();
|
|
118
|
+
let snapshot;
|
|
119
|
+
let configPath = `${dir}/tsconfig.fumadocs-typescript.json`;
|
|
120
|
+
for (let i = 0; fs$1.existsSync(configPath); i++) configPath = `${dir}/tsconfig.fumadocs-typescript.${i}.json`;
|
|
121
|
+
function writeConfig() {
|
|
122
|
+
virtualFiles.set(configPath, JSON.stringify({
|
|
123
|
+
extends: `./${path.posix.basename(tsconfigPath)}`,
|
|
124
|
+
include: [],
|
|
125
|
+
files: Array.from(rootFiles)
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
const api = new API({
|
|
129
|
+
cwd: dir,
|
|
130
|
+
fs: { readFile: (fileName) => virtualFiles.get(normalizePath(fileName)) }
|
|
41
131
|
});
|
|
132
|
+
return {
|
|
133
|
+
api,
|
|
134
|
+
tsconfigPath,
|
|
135
|
+
getSourceFile(filePath, content) {
|
|
136
|
+
const key = normalizePath(filePath);
|
|
137
|
+
const changed = [];
|
|
138
|
+
const created = [];
|
|
139
|
+
if (content !== void 0) {
|
|
140
|
+
const current = virtualFiles.has(key) ? virtualFiles.get(key) : readDiskFile(key);
|
|
141
|
+
if (current !== content) {
|
|
142
|
+
virtualFiles.set(key, content);
|
|
143
|
+
if (current !== void 0) changed.push(key);
|
|
144
|
+
else created.push(key);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!rootFiles.has(key)) {
|
|
148
|
+
rootFiles.add(key);
|
|
149
|
+
writeConfig();
|
|
150
|
+
changed.push(configPath);
|
|
151
|
+
}
|
|
152
|
+
if (!snapshot) snapshot = api.updateSnapshot({ openProjects: [configPath] });
|
|
153
|
+
else if (changed.length > 0 || created.length > 0) {
|
|
154
|
+
const prev = snapshot;
|
|
155
|
+
snapshot = api.updateSnapshot({ fileChanges: {
|
|
156
|
+
changed: changed.length > 0 ? changed : void 0,
|
|
157
|
+
created: created.length > 0 ? created : void 0
|
|
158
|
+
} });
|
|
159
|
+
prev.dispose();
|
|
160
|
+
}
|
|
161
|
+
const project = snapshot.getProject(configPath);
|
|
162
|
+
if (!project) return;
|
|
163
|
+
const sourceFile = project.program.getSourceFile(key);
|
|
164
|
+
if (!sourceFile) return;
|
|
165
|
+
return {
|
|
166
|
+
project,
|
|
167
|
+
sourceFile
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
close() {
|
|
171
|
+
snapshot?.dispose();
|
|
172
|
+
snapshot = void 0;
|
|
173
|
+
api.close();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
42
176
|
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/lib/base.ts
|
|
43
179
|
function createGenerator(options = {}) {
|
|
44
180
|
const cache = options?.cache ? options.cache : null;
|
|
45
181
|
let instance = options?.project;
|
|
@@ -47,18 +183,6 @@ function createGenerator(options = {}) {
|
|
|
47
183
|
if (instance) return instance;
|
|
48
184
|
return instance = createProject(options);
|
|
49
185
|
}
|
|
50
|
-
function getSourceFile(project, filePath, fileContent) {
|
|
51
|
-
const ext = path.extname(filePath);
|
|
52
|
-
const fileBase = filePath.slice(0, -ext.length);
|
|
53
|
-
let i = 0;
|
|
54
|
-
let sourceFile = project.getSourceFile(filePath);
|
|
55
|
-
while (sourceFile && sourceFile.getFullText() !== fileContent) {
|
|
56
|
-
filePath = `${fileBase}.${i++}${ext}`;
|
|
57
|
-
sourceFile = project.getSourceFile(filePath);
|
|
58
|
-
}
|
|
59
|
-
if (sourceFile) return sourceFile;
|
|
60
|
-
return project.createSourceFile(filePath, fileContent, { overwrite: true });
|
|
61
|
-
}
|
|
62
186
|
return {
|
|
63
187
|
async generateDocumentation(file, name, options = {}) {
|
|
64
188
|
const fullPath = path.resolve(file.path);
|
|
@@ -69,20 +193,29 @@ function createGenerator(options = {}) {
|
|
|
69
193
|
const cached = await cache.read(cacheKey);
|
|
70
194
|
if (cached) return cached;
|
|
71
195
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
196
|
+
const loaded = (await getProject()).getSourceFile(fullPath, file.content);
|
|
197
|
+
if (!loaded) throw new Error(`failed to load ${fullPath} into TypeScript project.`);
|
|
198
|
+
const { project: tsProject, sourceFile } = loaded;
|
|
199
|
+
const { checker } = tsProject;
|
|
74
200
|
const out = [];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
201
|
+
const moduleSymbol = name ? checker.getSymbolAtLocation(sourceFile) : void 0;
|
|
202
|
+
if (moduleSymbol && name) for (const exported of checker.getExportsOfModule(moduleSymbol)) {
|
|
203
|
+
if (exported.name !== name) continue;
|
|
204
|
+
const symbol = (exported.flags & SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(exported) : exported;
|
|
205
|
+
if (symbol.declarations.length === 0) continue;
|
|
206
|
+
if (symbol.declarations.length > 1) console.warn(`export ${name} should not have more than one type declaration.`);
|
|
207
|
+
const declaration = symbol.declarations[0].resolve(tsProject);
|
|
208
|
+
if (!declaration) continue;
|
|
209
|
+
const type = checker.getTypeAtLocation(declaration);
|
|
210
|
+
if (!type) continue;
|
|
79
211
|
const entryContext = {
|
|
80
212
|
...options,
|
|
81
|
-
program:
|
|
82
|
-
|
|
213
|
+
program: tsProject,
|
|
214
|
+
checker,
|
|
215
|
+
type,
|
|
83
216
|
declaration
|
|
84
217
|
};
|
|
85
|
-
out.push(
|
|
218
|
+
out.push(generate(encodeURI(`${path.basename(file.path)}-${name}`), name, symbol, entryContext));
|
|
86
219
|
}
|
|
87
220
|
if (cache && cacheKey) await cache.write(cacheKey, out);
|
|
88
221
|
return out;
|
|
@@ -92,43 +225,48 @@ function createGenerator(options = {}) {
|
|
|
92
225
|
}
|
|
93
226
|
};
|
|
94
227
|
}
|
|
95
|
-
|
|
96
|
-
const {
|
|
97
|
-
const { declaration, program } = entryContext;
|
|
98
|
-
const comment = declaration.getSymbol()?.compilerSymbol.getDocumentationComment(program.getTypeChecker().compilerObject);
|
|
228
|
+
function generate(id, name, symbol, entryContext) {
|
|
229
|
+
const { checker, type } = entryContext;
|
|
99
230
|
const entries = [];
|
|
100
|
-
for (const prop of
|
|
101
|
-
const out =
|
|
231
|
+
for (const prop of checker.getPropertiesOfType(type)) {
|
|
232
|
+
const out = getDocEntry(prop, entryContext);
|
|
102
233
|
if (out) entries.push(out);
|
|
103
234
|
}
|
|
104
235
|
return {
|
|
105
236
|
id,
|
|
106
237
|
name,
|
|
107
|
-
description:
|
|
238
|
+
description: checker.getDocumentationCommentOfSymbol(symbol),
|
|
108
239
|
entries
|
|
109
240
|
};
|
|
110
241
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
242
|
+
function isClassType(type) {
|
|
243
|
+
return isObjectType(type) && (type.objectFlags & ObjectFlags.Class) !== 0;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Private class members (`#name`) are exposed with their escaped name (`__#1@#name`) by TypeScript.
|
|
247
|
+
*/
|
|
248
|
+
function isPrivateIdentifierName(name) {
|
|
249
|
+
return name.startsWith("#") || name.startsWith("__#");
|
|
250
|
+
}
|
|
251
|
+
function getDocEntry(prop, context) {
|
|
252
|
+
const { transform, allowInternal = false, checker, declaration } = context;
|
|
253
|
+
if (isClassType(context.type) && isPrivateIdentifierName(prop.name)) return;
|
|
254
|
+
const subType = checker.getTypeOfSymbolAtLocation(prop, declaration);
|
|
255
|
+
const isOptional = (prop.flags & SymbolFlags.Optional) !== 0;
|
|
118
256
|
const tags = [];
|
|
119
|
-
for (const tag of
|
|
120
|
-
if (!allowInternal && tag.
|
|
257
|
+
for (const tag of checker.getJsDocTagsOfSymbol(prop)) {
|
|
258
|
+
if (!allowInternal && tag.name === "internal") return;
|
|
121
259
|
tags.push({
|
|
122
|
-
name: tag.
|
|
123
|
-
text:
|
|
260
|
+
name: tag.name,
|
|
261
|
+
text: tag.text ?? ""
|
|
124
262
|
});
|
|
125
263
|
}
|
|
126
264
|
const entry = {
|
|
127
|
-
name: prop.
|
|
128
|
-
description:
|
|
265
|
+
name: prop.name,
|
|
266
|
+
description: checker.getDocumentationCommentOfSymbol(prop),
|
|
129
267
|
tags,
|
|
130
|
-
type:
|
|
131
|
-
simplifiedType: getSimpleForm(subType,
|
|
268
|
+
type: checker.typeToString(subType, declaration, NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope | NodeBuilderFlags.NoTruncation),
|
|
269
|
+
simplifiedType: getSimpleForm(subType, checker, declaration, {
|
|
132
270
|
...context.typeSimplifier,
|
|
133
271
|
noUndefined: isOptional
|
|
134
272
|
}),
|
|
@@ -151,9 +289,7 @@ async function getDocEntry(prop, context) {
|
|
|
151
289
|
if (content.length > 0) entry.typeHref = content;
|
|
152
290
|
break;
|
|
153
291
|
}
|
|
154
|
-
case "deprecated":
|
|
155
|
-
entry.deprecated = true;
|
|
156
|
-
break;
|
|
292
|
+
case "deprecated": entry.deprecated = true;
|
|
157
293
|
}
|
|
158
294
|
transform?.call(context, entry, subType, prop);
|
|
159
295
|
return entry;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { API, Checker, Project, Symbol, Type } from "typescript/unstable/sync";
|
|
2
|
+
import { Node, SourceFile } from "typescript/unstable/ast";
|
|
2
3
|
import { Nodes } from "hast";
|
|
3
4
|
import { BundledTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from "shiki";
|
|
4
|
-
|
|
5
5
|
//#region src/lib/type-table.d.ts
|
|
6
6
|
interface BaseTypeTableProps {
|
|
7
7
|
/**
|
|
@@ -52,7 +52,7 @@ declare function generateHash(str: string): string;
|
|
|
52
52
|
//#region src/lib/get-simple-form.d.ts
|
|
53
53
|
interface TypeSimplifierContext {
|
|
54
54
|
type: Type;
|
|
55
|
-
checker:
|
|
55
|
+
checker: Checker;
|
|
56
56
|
location?: Node;
|
|
57
57
|
}
|
|
58
58
|
interface TypeSimplifierOptions {
|
|
@@ -66,6 +66,32 @@ interface TypeSimplifierOptions {
|
|
|
66
66
|
noUndefined?: boolean;
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
|
+
//#region src/lib/project.d.ts
|
|
70
|
+
interface TypescriptConfig {
|
|
71
|
+
tsconfigPath?: string;
|
|
72
|
+
}
|
|
73
|
+
interface Project$1 {
|
|
74
|
+
/**
|
|
75
|
+
* The underlying `typescript/unstable/sync` API instance (a native TypeScript process).
|
|
76
|
+
*/
|
|
77
|
+
readonly api: API;
|
|
78
|
+
readonly tsconfigPath: string;
|
|
79
|
+
/**
|
|
80
|
+
* Load a source file into the project, and optionally override its content with an in-memory version.
|
|
81
|
+
*
|
|
82
|
+
* Only loaded files (and the files they import) are part of the program, similar to `tsc` with `files` set.
|
|
83
|
+
*/
|
|
84
|
+
getSourceFile(filePath: string, content?: string): {
|
|
85
|
+
project: Project;
|
|
86
|
+
sourceFile: SourceFile;
|
|
87
|
+
} | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Stop the TypeScript process.
|
|
90
|
+
*/
|
|
91
|
+
close(): void;
|
|
92
|
+
}
|
|
93
|
+
declare function createProject(options?: TypescriptConfig): Promise<Project$1>;
|
|
94
|
+
//#endregion
|
|
69
95
|
//#region src/lib/base.d.ts
|
|
70
96
|
interface GeneratedDoc {
|
|
71
97
|
/**
|
|
@@ -91,9 +117,13 @@ interface RawTag {
|
|
|
91
117
|
text: string;
|
|
92
118
|
}
|
|
93
119
|
interface EntryContext extends GenerateOptions {
|
|
120
|
+
/**
|
|
121
|
+
* The TypeScript project (from `typescript/unstable/sync`) containing the declaration.
|
|
122
|
+
*/
|
|
94
123
|
program: Project;
|
|
124
|
+
checker: Checker;
|
|
95
125
|
type: Type;
|
|
96
|
-
declaration:
|
|
126
|
+
declaration: Node;
|
|
97
127
|
}
|
|
98
128
|
type Transformer = (this: EntryContext, entry: DocEntry, propertyType: Type, propertySymbol: Symbol) => void;
|
|
99
129
|
interface GenerateOptions {
|
|
@@ -117,12 +147,8 @@ interface GeneratorOptions extends TypescriptConfig {
|
|
|
117
147
|
* @defaultValue false
|
|
118
148
|
*/
|
|
119
149
|
cache?: Cache | false;
|
|
120
|
-
project?: Project;
|
|
121
|
-
}
|
|
122
|
-
interface TypescriptConfig {
|
|
123
|
-
tsconfigPath?: string;
|
|
150
|
+
project?: Project$1;
|
|
124
151
|
}
|
|
125
|
-
declare function createProject(options?: TypescriptConfig): Promise<Project>;
|
|
126
152
|
declare function createGenerator(options?: GeneratorOptions): {
|
|
127
153
|
generateDocumentation(file: {
|
|
128
154
|
path: string;
|
|
@@ -138,4 +164,4 @@ interface MarkdownRenderer {
|
|
|
138
164
|
}
|
|
139
165
|
type ShikiOptions = Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BundledTheme>;
|
|
140
166
|
//#endregion
|
|
141
|
-
export { GeneratedDoc as a, RawTag as c,
|
|
167
|
+
export { GeneratedDoc as a, RawTag as c, TypescriptConfig as d, createProject as f, GenerateTypeTableOptions as g, BaseTypeTableProps as h, GenerateOptions as i, createGenerator as l, generateHash as m, ShikiOptions as n, Generator as o, Cache as p, DocEntry as r, GeneratorOptions as s, MarkdownRenderer as t, Project$1 as u };
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as GenerateTypeTableOptions, h as BaseTypeTableProps, n as ShikiOptions, o as Generator } from "../markdown-CcCPhMmC.js";
|
|
2
2
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
3
3
|
import { ComponentProps, ReactNode } from "react";
|
|
4
|
-
|
|
5
4
|
//#region src/ui/auto-type-table.d.ts
|
|
6
5
|
interface AutoTypeTableProps extends BaseTypeTableProps, ComponentProps<'div'> {
|
|
7
6
|
generator: Generator;
|
|
@@ -11,16 +10,6 @@ interface AutoTypeTableProps extends BaseTypeTableProps, ComponentProps<'div'> {
|
|
|
11
10
|
renderMarkdown?: (md: string) => Promise<ReactNode>;
|
|
12
11
|
renderType?: (type: string) => Promise<ReactNode>;
|
|
13
12
|
}
|
|
14
|
-
declare function AutoTypeTable({
|
|
15
|
-
generator,
|
|
16
|
-
options,
|
|
17
|
-
renderType,
|
|
18
|
-
renderMarkdown,
|
|
19
|
-
shiki,
|
|
20
|
-
name,
|
|
21
|
-
path,
|
|
22
|
-
type,
|
|
23
|
-
...props
|
|
24
|
-
}: AutoTypeTableProps): Promise<Promise<JsxRuntime.JSX.Element>[]>;
|
|
13
|
+
declare function AutoTypeTable({ generator, options, renderType, renderMarkdown, shiki, name, path, type, ...props }: AutoTypeTableProps): Promise<Promise<JsxRuntime.JSX.Element>[]>;
|
|
25
14
|
//#endregion
|
|
26
15
|
export { AutoTypeTable, AutoTypeTableProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -38,25 +38,24 @@
|
|
|
38
38
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
39
39
|
"remark": "^15.0.1",
|
|
40
40
|
"remark-rehype": "^11.1.2",
|
|
41
|
-
"shiki": "^4.3
|
|
42
|
-
"
|
|
41
|
+
"shiki": "^4.4.3",
|
|
42
|
+
"typescript": "~7.0.2",
|
|
43
43
|
"unified": "^11.0.5",
|
|
44
44
|
"unist-util-visit": "^5.1.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@mdx-js/mdx": "^3.1.1",
|
|
48
48
|
"@types/estree": "^1.0.9",
|
|
49
|
-
"@types/hast": "^3.0.
|
|
49
|
+
"@types/hast": "^3.0.5",
|
|
50
50
|
"@types/mdast": "^4.0.4",
|
|
51
|
-
"@types/node": "26.1
|
|
52
|
-
"@types/react": "^19.2.
|
|
53
|
-
"@types/react-dom": "^19.2.
|
|
51
|
+
"@types/node": "26.4.1",
|
|
52
|
+
"@types/react": "^19.2.18",
|
|
53
|
+
"@types/react-dom": "^19.2.5",
|
|
54
54
|
"mdast-util-mdx": "^3.0.0",
|
|
55
|
-
"tsdown": "0.22.
|
|
56
|
-
"typescript": "^6.0.3",
|
|
55
|
+
"tsdown": "0.22.14",
|
|
57
56
|
"vfile": "^6.0.3",
|
|
58
|
-
"fumadocs-
|
|
59
|
-
"fumadocs-
|
|
57
|
+
"fumadocs-core": "16.15.6",
|
|
58
|
+
"fumadocs-ui": "npm:@fumadocs/base-ui@16.15.6",
|
|
60
59
|
"tsconfig": "0.0.0"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { TypeFormatFlags } from "ts-morph";
|
|
2
|
-
//#region src/lib/get-simple-form.ts
|
|
3
|
-
function getSimpleForm(type, checker, location, options = {}) {
|
|
4
|
-
const { override, shouldSimplify, noUndefined = false } = options;
|
|
5
|
-
if (type.isUndefined() && noUndefined) return "";
|
|
6
|
-
const overridden = override?.({
|
|
7
|
-
checker,
|
|
8
|
-
type,
|
|
9
|
-
location
|
|
10
|
-
});
|
|
11
|
-
if (overridden) return overridden;
|
|
12
|
-
if (shouldSimplify && !shouldSimplify({
|
|
13
|
-
checker,
|
|
14
|
-
type,
|
|
15
|
-
location
|
|
16
|
-
})) return type.getText(location, TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
|
|
17
|
-
const alias = type.getAliasSymbol();
|
|
18
|
-
if (alias) {
|
|
19
|
-
const args = type.getAliasTypeArguments();
|
|
20
|
-
if (args.length === 0) return alias.getName();
|
|
21
|
-
const nextOptions = {
|
|
22
|
-
...options,
|
|
23
|
-
noUndefined: false
|
|
24
|
-
};
|
|
25
|
-
return `${alias.getName()}<${args.map((arg) => getSimpleForm(arg, checker, location, nextOptions)).join(", ")}>`;
|
|
26
|
-
}
|
|
27
|
-
if (type.isUnion()) {
|
|
28
|
-
if (noUndefined) {
|
|
29
|
-
const members = type.getUnionTypes().filter((t) => !t.isUndefined());
|
|
30
|
-
if (members.length === 0) return "undefined";
|
|
31
|
-
if (members.length === 1) return getSimpleForm(members[0], checker, location, options);
|
|
32
|
-
}
|
|
33
|
-
return "union";
|
|
34
|
-
}
|
|
35
|
-
if (type.isIntersection()) {
|
|
36
|
-
const types = [];
|
|
37
|
-
for (const t of type.getIntersectionTypes()) {
|
|
38
|
-
const str = getSimpleForm(t, checker, location, options);
|
|
39
|
-
if (str.length > 0 && str !== "never") types.unshift(str);
|
|
40
|
-
}
|
|
41
|
-
return dedupe(types).join(" & ");
|
|
42
|
-
}
|
|
43
|
-
if (type.isTuple()) return "tuple";
|
|
44
|
-
if (type.isArray() || type.isReadonlyArray()) return "array";
|
|
45
|
-
if (type.getCallSignatures().length > 0) return "function";
|
|
46
|
-
if (type.isClassOrInterface() || type.isObject()) return "object";
|
|
47
|
-
return type.getText(location, TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
|
|
48
|
-
}
|
|
49
|
-
function dedupe(arr) {
|
|
50
|
-
const dedupe = /* @__PURE__ */ new Set();
|
|
51
|
-
const out = [];
|
|
52
|
-
for (const item of arr) if (!dedupe.has(item)) {
|
|
53
|
-
out.push(item);
|
|
54
|
-
dedupe.add(item);
|
|
55
|
-
}
|
|
56
|
-
return out;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { getSimpleForm };
|