fumadocs-typescript 4.0.8 → 4.0.10
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.js +40 -31
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -91,11 +91,13 @@ import path2 from "path";
|
|
|
91
91
|
|
|
92
92
|
// src/lib/get-simple-form.ts
|
|
93
93
|
import * as ts from "ts-morph";
|
|
94
|
-
function getSimpleForm(type, checker, noUndefined = false) {
|
|
94
|
+
function getSimpleForm(type, checker, noUndefined = false, location) {
|
|
95
95
|
if (type.isUndefined() && noUndefined) return "";
|
|
96
96
|
const alias = type.getAliasSymbol();
|
|
97
|
-
if (alias
|
|
98
|
-
|
|
97
|
+
if (alias) {
|
|
98
|
+
const args = type.getAliasTypeArguments();
|
|
99
|
+
if (args.length === 0) return alias.getName();
|
|
100
|
+
return `${alias.getName()}<${args.map((arg) => getSimpleForm(arg, checker)).join(", ")}>`;
|
|
99
101
|
}
|
|
100
102
|
if (type.isUnion()) {
|
|
101
103
|
const types = [];
|
|
@@ -105,7 +107,7 @@ function getSimpleForm(type, checker, noUndefined = false) {
|
|
|
105
107
|
}
|
|
106
108
|
return types.length > 0 ? (
|
|
107
109
|
// boolean | null will become true | false | null, need to ensure it's still returned as boolean
|
|
108
|
-
types.join(" | ").replace("true | false", "boolean")
|
|
110
|
+
dedupe(types).join(" | ").replace("true | false", "boolean")
|
|
109
111
|
) : "never";
|
|
110
112
|
}
|
|
111
113
|
if (type.isIntersection()) {
|
|
@@ -114,7 +116,7 @@ function getSimpleForm(type, checker, noUndefined = false) {
|
|
|
114
116
|
const str = getSimpleForm(t, checker, noUndefined);
|
|
115
117
|
if (str.length > 0 && str !== "never") types.unshift(str);
|
|
116
118
|
}
|
|
117
|
-
return types.join(" & ");
|
|
119
|
+
return dedupe(types).join(" & ");
|
|
118
120
|
}
|
|
119
121
|
if (type.isTuple()) {
|
|
120
122
|
const elements = type.getTupleElements().map((t) => getSimpleForm(t, checker)).join(", ");
|
|
@@ -130,10 +132,21 @@ function getSimpleForm(type, checker, noUndefined = false) {
|
|
|
130
132
|
return "object";
|
|
131
133
|
}
|
|
132
134
|
return type.getText(
|
|
133
|
-
|
|
134
|
-
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
|
|
135
|
+
location,
|
|
136
|
+
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
|
|
135
137
|
);
|
|
136
138
|
}
|
|
139
|
+
function dedupe(arr) {
|
|
140
|
+
const dedupe2 = /* @__PURE__ */ new Set();
|
|
141
|
+
const out = [];
|
|
142
|
+
for (const item of arr) {
|
|
143
|
+
if (!dedupe2.has(item)) {
|
|
144
|
+
out.push(item);
|
|
145
|
+
dedupe2.add(item);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
137
150
|
|
|
138
151
|
// src/lib/base.ts
|
|
139
152
|
function createGenerator(config) {
|
|
@@ -141,7 +154,7 @@ function createGenerator(config) {
|
|
|
141
154
|
const options = config instanceof Project2 ? {
|
|
142
155
|
project: config
|
|
143
156
|
} : config;
|
|
144
|
-
const cacheType = (_a = options == null ? void 0 : options.cache) != null ? _a : "fs";
|
|
157
|
+
const cacheType = (_a = options == null ? void 0 : options.cache) != null ? _a : process.env.NODE_ENV !== "development" ? "fs" : false;
|
|
145
158
|
const cache = cacheType === "fs" ? createCache() : null;
|
|
146
159
|
let instance;
|
|
147
160
|
function getProject() {
|
|
@@ -203,12 +216,12 @@ function generate(program, name, declaration, { allowInternal = false, transform
|
|
|
203
216
|
};
|
|
204
217
|
}
|
|
205
218
|
function getDocEntry(prop, context) {
|
|
206
|
-
var _a
|
|
219
|
+
var _a;
|
|
207
220
|
const { transform, program } = context;
|
|
208
221
|
if (context.type.isClass() && prop.getName().startsWith("#")) {
|
|
209
222
|
return;
|
|
210
223
|
}
|
|
211
|
-
const subType =
|
|
224
|
+
const subType = prop.getTypeAtLocation(context.declaration);
|
|
212
225
|
const isOptional = prop.isOptional();
|
|
213
226
|
const tags = prop.getJsDocTags().map(
|
|
214
227
|
(tag) => ({
|
|
@@ -216,10 +229,16 @@ function getDocEntry(prop, context) {
|
|
|
216
229
|
text: ts2.displayPartsToString(tag.getText())
|
|
217
230
|
})
|
|
218
231
|
);
|
|
219
|
-
let
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
232
|
+
let simplifiedType = getSimpleForm(
|
|
233
|
+
subType,
|
|
234
|
+
program.getTypeChecker(),
|
|
235
|
+
isOptional,
|
|
236
|
+
context.declaration
|
|
237
|
+
);
|
|
238
|
+
const remarksTag = tags.find((tag) => tag.name === "remarks");
|
|
239
|
+
if (remarksTag) {
|
|
240
|
+
const match = (_a = new RegExp("^`(?<name>.+)`").exec(remarksTag.text)) == null ? void 0 : _a[1];
|
|
241
|
+
if (match) simplifiedType = match;
|
|
223
242
|
}
|
|
224
243
|
const entry = {
|
|
225
244
|
name: prop.getName(),
|
|
@@ -229,29 +248,17 @@ function getDocEntry(prop, context) {
|
|
|
229
248
|
)
|
|
230
249
|
),
|
|
231
250
|
tags,
|
|
232
|
-
type
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
program.getTypeChecker(),
|
|
236
|
-
isOptional
|
|
251
|
+
type: subType.getText(
|
|
252
|
+
context.declaration,
|
|
253
|
+
ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts2.TypeFormatFlags.NoTruncation
|
|
237
254
|
),
|
|
255
|
+
simplifiedType,
|
|
238
256
|
required: !isOptional,
|
|
239
257
|
deprecated: tags.some((tag) => tag.name === "deprecated")
|
|
240
258
|
};
|
|
241
259
|
transform == null ? void 0 : transform.call(context, entry, subType, prop);
|
|
242
260
|
return entry;
|
|
243
261
|
}
|
|
244
|
-
function getFullType(type) {
|
|
245
|
-
var _a, _b;
|
|
246
|
-
let typeName = type.getText(
|
|
247
|
-
void 0,
|
|
248
|
-
ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts2.TypeFormatFlags.NoTruncation | ts2.TypeFormatFlags.InTypeAlias
|
|
249
|
-
);
|
|
250
|
-
if (type.getAliasSymbol() && type.getAliasTypeArguments().length === 0) {
|
|
251
|
-
typeName = (_b = (_a = type.getAliasSymbol()) == null ? void 0 : _a.getEscapedName()) != null ? _b : typeName;
|
|
252
|
-
}
|
|
253
|
-
return typeName;
|
|
254
|
-
}
|
|
255
262
|
|
|
256
263
|
// src/lib/mdx.ts
|
|
257
264
|
import * as path3 from "path";
|
|
@@ -266,9 +273,11 @@ ${doc.description}
|
|
|
266
273
|
|
|
267
274
|
<div className="flex flex-row items-center gap-4">
|
|
268
275
|
<code className="text-sm">${c.name}</code>
|
|
269
|
-
<code className="text-fd-muted-foreground">{${JSON.stringify(c.
|
|
276
|
+
<code className="text-fd-muted-foreground">{${JSON.stringify(c.simplifiedType)}}</code>
|
|
270
277
|
</div>
|
|
271
278
|
|
|
279
|
+
Full Type: <code className="text-fd-muted-foreground">{${JSON.stringify(c.type)}}</code>
|
|
280
|
+
|
|
272
281
|
${c.description || "No Description"}
|
|
273
282
|
|
|
274
283
|
${c.tags.map((tag) => `- ${tag.name}:
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
7
7
|
"fumadocs",
|
|
8
8
|
"Docs"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://fumadocs.
|
|
10
|
+
"homepage": "https://fumadocs.dev",
|
|
11
11
|
"repository": "github:fuma-nama/fumadocs",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": "Fuma Nama",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
34
34
|
"remark": "^15.0.1",
|
|
35
35
|
"remark-rehype": "^11.1.2",
|
|
36
|
-
"tinyglobby": "^0.2.
|
|
37
|
-
"ts-morph": "^
|
|
36
|
+
"tinyglobby": "^0.2.15",
|
|
37
|
+
"ts-morph": "^27.0.0",
|
|
38
38
|
"unist-util-visit": "^5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@types/estree": "^1.0.8",
|
|
43
43
|
"@types/hast": "^3.0.4",
|
|
44
44
|
"@types/mdast": "^4.0.3",
|
|
45
|
-
"@types/node": "24.
|
|
46
|
-
"@types/react": "19.1.
|
|
45
|
+
"@types/node": "24.5.2",
|
|
46
|
+
"@types/react": "19.1.14",
|
|
47
47
|
"@types/react-dom": "19.1.9",
|
|
48
48
|
"typescript": "^5.9.2",
|
|
49
49
|
"unified": "^11.0.5",
|
|
50
50
|
"eslint-config-custom": "0.0.0",
|
|
51
|
-
"fumadocs-core": "15.
|
|
52
|
-
"fumadocs-ui": "15.
|
|
51
|
+
"fumadocs-core": "15.8.2",
|
|
52
|
+
"fumadocs-ui": "15.8.2",
|
|
53
53
|
"tsconfig": "0.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|