fumadocs-typescript 5.2.0 → 5.2.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,12 +1,19 @@
|
|
|
1
1
|
import { TypeFormatFlags } from "ts-morph";
|
|
2
2
|
//#region src/lib/get-simple-form.ts
|
|
3
|
-
function getSimpleForm(
|
|
4
|
-
const { type } = ctx;
|
|
3
|
+
function getSimpleForm(type, checker, location, options = {}) {
|
|
5
4
|
const { override, shouldSimplify, noUndefined = false } = options;
|
|
6
5
|
if (type.isUndefined() && noUndefined) return "";
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
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);
|
|
10
17
|
const alias = type.getAliasSymbol();
|
|
11
18
|
if (alias) {
|
|
12
19
|
const args = type.getAliasTypeArguments();
|
|
@@ -15,28 +22,29 @@ function getSimpleForm(ctx, options = {}) {
|
|
|
15
22
|
...options,
|
|
16
23
|
noUndefined: false
|
|
17
24
|
};
|
|
18
|
-
return `${alias.getName()}<${args.map((arg) => getSimpleForm(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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";
|
|
22
34
|
}
|
|
23
|
-
if (type.isUnion()) return "union";
|
|
24
35
|
if (type.isIntersection()) {
|
|
25
36
|
const types = [];
|
|
26
37
|
for (const t of type.getIntersectionTypes()) {
|
|
27
|
-
const str = getSimpleForm(
|
|
28
|
-
...ctx,
|
|
29
|
-
type: t
|
|
30
|
-
}, options);
|
|
38
|
+
const str = getSimpleForm(t, checker, location, options);
|
|
31
39
|
if (str.length > 0 && str !== "never") types.unshift(str);
|
|
32
40
|
}
|
|
33
41
|
return dedupe(types).join(" & ");
|
|
34
42
|
}
|
|
35
|
-
if (type.isTuple()) return "
|
|
43
|
+
if (type.isTuple()) return "tuple";
|
|
36
44
|
if (type.isArray() || type.isReadonlyArray()) return "array";
|
|
37
45
|
if (type.getCallSignatures().length > 0) return "function";
|
|
38
46
|
if (type.isClassOrInterface() || type.isObject()) return "object";
|
|
39
|
-
return type.getText(
|
|
47
|
+
return type.getText(location, TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
|
|
40
48
|
}
|
|
41
49
|
function dedupe(arr) {
|
|
42
50
|
const dedupe = /* @__PURE__ */ new Set();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as GeneratedDoc, c as RawTag, d as createProject, f as Cache, h as GenerateTypeTableOptions, i as GenerateOptions, l as TypescriptConfig, m as BaseTypeTableProps, n as ShikiOptions, o as Generator, p as generateHash, r as DocEntry, s as GeneratorOptions, t as MarkdownRenderer, u as createGenerator } from "./markdown-
|
|
1
|
+
import { a as GeneratedDoc, c as RawTag, d as createProject, f as Cache, h as GenerateTypeTableOptions, i as GenerateOptions, l as TypescriptConfig, m as BaseTypeTableProps, n as ShikiOptions, o as Generator, p as generateHash, r as DocEntry, s as GeneratorOptions, t as MarkdownRenderer, u as createGenerator } from "./markdown-cnIFnWzR.js";
|
|
2
2
|
import { Root } from "mdast";
|
|
3
3
|
import { Transformer } from "unified";
|
|
4
4
|
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ function generateHash(str) {
|
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region package.json
|
|
33
|
-
var version = "5.2.
|
|
33
|
+
var version = "5.2.1";
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/lib/base.ts
|
|
36
36
|
async function createProject(options = {}) {
|
|
@@ -110,7 +110,7 @@ async function generate(id, name, entryContext) {
|
|
|
110
110
|
}
|
|
111
111
|
async function getDocEntry(prop, context) {
|
|
112
112
|
const { ts } = await import("ts-morph");
|
|
113
|
-
const { getSimpleForm } = await import("./get-simple-form-
|
|
113
|
+
const { getSimpleForm } = await import("./get-simple-form-Bya17G4R.js");
|
|
114
114
|
const { transform, allowInternal = false, program } = context;
|
|
115
115
|
if (context.type.isClass() && prop.getName().startsWith("#")) return;
|
|
116
116
|
const subType = prop.getTypeAtLocation(context.declaration);
|
|
@@ -128,12 +128,8 @@ async function getDocEntry(prop, context) {
|
|
|
128
128
|
description: ts.displayPartsToString(prop.compilerSymbol.getDocumentationComment(program.getTypeChecker().compilerObject)),
|
|
129
129
|
tags,
|
|
130
130
|
type: subType.getText(context.declaration, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts.TypeFormatFlags.NoTruncation),
|
|
131
|
-
simplifiedType: getSimpleForm({
|
|
132
|
-
|
|
133
|
-
checker: program.getTypeChecker(),
|
|
134
|
-
location: context.declaration
|
|
135
|
-
}, {
|
|
136
|
-
...context.typeSimplifer,
|
|
131
|
+
simplifiedType: getSimpleForm(subType, program.getTypeChecker(), context.declaration, {
|
|
132
|
+
...context.typeSimplifier,
|
|
137
133
|
noUndefined: isOptional
|
|
138
134
|
}),
|
|
139
135
|
required: !isOptional,
|
|
@@ -57,9 +57,9 @@ interface TypeSimplifierContext {
|
|
|
57
57
|
}
|
|
58
58
|
interface TypeSimplifierOptions {
|
|
59
59
|
/**
|
|
60
|
-
* whether the
|
|
60
|
+
* whether the simplified names should be preferred over the type names.
|
|
61
61
|
*
|
|
62
|
-
* Default: always prefer
|
|
62
|
+
* Default: always prefer simplified ones.
|
|
63
63
|
*/
|
|
64
64
|
shouldSimplify?: (ctx: TypeSimplifierContext) => boolean;
|
|
65
65
|
override?: (ctx: TypeSimplifierContext) => string | undefined;
|
|
@@ -107,7 +107,7 @@ interface GenerateOptions {
|
|
|
107
107
|
* Modify output property entry
|
|
108
108
|
*/
|
|
109
109
|
transform?: Transformer;
|
|
110
|
-
|
|
110
|
+
typeSimplifier?: TypeSimplifierOptions;
|
|
111
111
|
}
|
|
112
112
|
type Generator = ReturnType<typeof createGenerator>;
|
|
113
113
|
interface GeneratorOptions extends TypescriptConfig {
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as GenerateTypeTableOptions, m as BaseTypeTableProps, n as ShikiOptions, o as Generator } from "../markdown-
|
|
1
|
+
import { h as GenerateTypeTableOptions, m as BaseTypeTableProps, n as ShikiOptions, o as Generator } from "../markdown-cnIFnWzR.js";
|
|
2
2
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
3
3
|
import { ComponentProps, ReactNode } from "react";
|
|
4
4
|
|
package/dist/ui/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
|
4
4
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
7
|
-
import "server-only";
|
|
8
7
|
//#region src/ui/auto-type-table.tsx
|
|
9
8
|
async function AutoTypeTable({ generator, options, renderType, renderMarkdown, shiki, name, path, type, ...props }) {
|
|
10
9
|
if (!renderType || !renderMarkdown) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -50,12 +50,11 @@
|
|
|
50
50
|
"@types/react-dom": "^19.2.3",
|
|
51
51
|
"mdast-util-mdx": "^3.0.0",
|
|
52
52
|
"shiki": "^4.0.2",
|
|
53
|
-
"tsdown": "0.21.
|
|
54
|
-
"typescript": "^
|
|
53
|
+
"tsdown": "0.21.6",
|
|
54
|
+
"typescript": "^6.0.2",
|
|
55
55
|
"vfile": "^6.0.3",
|
|
56
|
-
"
|
|
57
|
-
"fumadocs-
|
|
58
|
-
"fumadocs-ui": "16.7.0",
|
|
56
|
+
"fumadocs-core": "16.7.8",
|
|
57
|
+
"fumadocs-ui": "16.7.8",
|
|
59
58
|
"tsconfig": "0.0.0"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
@@ -93,7 +92,7 @@
|
|
|
93
92
|
"build": "tsdown",
|
|
94
93
|
"clean": "rimraf dist",
|
|
95
94
|
"dev": "tsdown --watch",
|
|
96
|
-
"lint": "
|
|
95
|
+
"lint": "oxlint .",
|
|
97
96
|
"types:check": "tsc --noEmit"
|
|
98
97
|
}
|
|
99
98
|
}
|