fumadocs-mdx 11.10.1 → 12.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.
- package/dist/bin.cjs +126 -218
- package/dist/bin.js +1 -1
- package/dist/{browser-B2G8uAF2.d.cts → browser-D5lvL8vv.d.ts} +51 -4
- package/dist/{browser-DrH7tKRi.d.ts → browser-DjWADqp8.d.cts} +51 -4
- package/dist/bun/index.cjs +274 -230
- package/dist/bun/index.js +8 -8
- package/dist/chunk-ADR6R7HM.js +29 -0
- package/dist/{chunk-UOOPSLFY.js → chunk-AUOOMFAI.js} +27 -21
- package/dist/chunk-FSZMKRVH.js +80 -0
- package/dist/{chunk-766EAFX6.js → chunk-LGYVNESJ.js} +2 -36
- package/dist/chunk-LMG6UWCL.js +167 -0
- package/dist/chunk-QAUWMR5D.js +142 -0
- package/dist/{chunk-QJCCVMBJ.js → chunk-SP7CHRTS.js} +17 -47
- package/dist/{chunk-QVZ7JH4H.js → chunk-U4MQ44TS.js} +1 -1
- package/dist/{chunk-CNKI574E.js → chunk-VXEBLM4X.js} +1 -1
- package/dist/chunk-XMFLD5J6.js +30 -0
- package/dist/chunk-ZLCSVXCD.js +10 -0
- package/dist/{chunk-XXSKWWMB.js → chunk-ZX7TM4AR.js} +4 -2
- package/dist/config/index.cjs +97 -148
- package/dist/config/index.d.cts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +48 -9
- package/dist/{define-BH4bnHQl.d.ts → define--6HQ1ehX.d.cts} +18 -3
- package/dist/{define-BH4bnHQl.d.cts → define--6HQ1ehX.d.ts} +18 -3
- package/dist/load-UUXLUBHL.js +9 -0
- package/dist/loader-mdx.cjs +336 -305
- package/dist/loader-mdx.js +8 -8
- package/dist/next/index.cjs +152 -242
- package/dist/next/index.js +52 -66
- package/dist/node/loader.cjs +274 -243
- package/dist/node/loader.js +7 -8
- package/dist/postinstall-SCSXM4IM.js +10 -0
- package/dist/{mdx-options-T73E4LQB.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +304 -204
- package/dist/runtime/next/async.d.cts +3 -3
- package/dist/runtime/next/async.d.ts +3 -3
- package/dist/runtime/next/async.js +59 -32
- package/dist/runtime/next/index.cjs +32 -21
- package/dist/runtime/next/index.d.cts +11 -7
- package/dist/runtime/next/index.d.ts +11 -7
- package/dist/runtime/next/index.js +2 -1
- package/dist/runtime/vite/browser.d.cts +2 -3
- package/dist/runtime/vite/browser.d.ts +2 -3
- package/dist/runtime/vite/server.cjs +67 -21
- package/dist/runtime/vite/server.d.cts +14 -28
- package/dist/runtime/vite/server.d.ts +14 -28
- package/dist/runtime/vite/server.js +61 -21
- package/dist/shared-0QIuV0XZ.d.ts +70 -0
- package/dist/shared-CqgMnt9h.d.cts +70 -0
- package/dist/{types-DN9KrG7R.d.ts → types-CFlQxTN8.d.ts} +10 -37
- package/dist/{types-DT83Ijs6.d.cts → types-DkGjw-Uo.d.cts} +10 -37
- package/dist/vite/index.cjs +299 -279
- package/dist/vite/index.d.cts +1 -0
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.js +15 -20
- package/dist/{watcher-4NDMOH4R.js → watcher-HGOH3APP.js} +1 -1
- package/package.json +16 -16
- package/dist/build-mdx-DnC1jKvn.d.cts +0 -46
- package/dist/build-mdx-DnC1jKvn.d.ts +0 -46
- package/dist/chunk-GBMFGEC7.js +0 -57
- package/dist/chunk-QQWCBFFE.js +0 -40
- package/dist/chunk-SMSNZ6N5.js +0 -155
- package/dist/chunk-SVTXMVLQ.js +0 -139
- package/dist/config/zod-3.cjs +0 -422
- package/dist/config/zod-3.d.cts +0 -53
- package/dist/config/zod-3.d.ts +0 -53
- package/dist/config/zod-3.js +0 -40
- package/dist/postinstall-XV4WSHZP.js +0 -9
package/dist/bin.cjs
CHANGED
|
@@ -30,86 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
-
// src/mdx
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) {
|
|
37
|
-
return (tree, file) => {
|
|
38
|
-
let title;
|
|
39
|
-
const urls = [];
|
|
40
|
-
(0, import_unist_util_visit.visit)(tree, ["heading", "link"], (node) => {
|
|
41
|
-
if (node.type === "heading" && node.depth === 1) {
|
|
42
|
-
title = flattenNode(node);
|
|
43
|
-
}
|
|
44
|
-
if (node.type !== "link") return;
|
|
45
|
-
urls.push({
|
|
46
|
-
href: node.url
|
|
47
|
-
});
|
|
48
|
-
return "skip";
|
|
49
|
-
});
|
|
50
|
-
if (title) {
|
|
51
|
-
file.data.frontmatter ??= {};
|
|
52
|
-
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
53
|
-
}
|
|
54
|
-
file.data.extractedReferences = urls;
|
|
55
|
-
for (const name of injectExports) {
|
|
56
|
-
if (!(name in file.data)) continue;
|
|
57
|
-
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function flattenNode(node) {
|
|
62
|
-
if ("children" in node)
|
|
63
|
-
return node.children.map((child) => flattenNode(child)).join("");
|
|
64
|
-
if ("value" in node) return node.value;
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
function getMdastExport(name, value) {
|
|
68
|
-
return {
|
|
69
|
-
type: "mdxjsEsm",
|
|
70
|
-
value: "",
|
|
71
|
-
data: {
|
|
72
|
-
estree: {
|
|
73
|
-
type: "Program",
|
|
74
|
-
sourceType: "module",
|
|
75
|
-
body: [
|
|
76
|
-
{
|
|
77
|
-
type: "ExportNamedDeclaration",
|
|
78
|
-
attributes: [],
|
|
79
|
-
specifiers: [],
|
|
80
|
-
source: null,
|
|
81
|
-
declaration: {
|
|
82
|
-
type: "VariableDeclaration",
|
|
83
|
-
kind: "let",
|
|
84
|
-
declarations: [
|
|
85
|
-
{
|
|
86
|
-
type: "VariableDeclarator",
|
|
87
|
-
id: {
|
|
88
|
-
type: "Identifier",
|
|
89
|
-
name
|
|
90
|
-
},
|
|
91
|
-
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
var import_unist_util_visit, import_estree_util_value_to_estree;
|
|
102
|
-
var init_remark_postprocess = __esm({
|
|
103
|
-
"src/mdx-plugins/remark-postprocess.ts"() {
|
|
104
|
-
"use strict";
|
|
105
|
-
import_unist_util_visit = require("unist-util-visit");
|
|
106
|
-
import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// src/utils/mdx-options.ts
|
|
111
|
-
var mdx_options_exports = {};
|
|
112
|
-
__export(mdx_options_exports, {
|
|
33
|
+
// src/loaders/mdx/preset.ts
|
|
34
|
+
var preset_exports = {};
|
|
35
|
+
__export(preset_exports, {
|
|
113
36
|
getDefaultMDXOptions: () => getDefaultMDXOptions
|
|
114
37
|
});
|
|
115
38
|
function pluginOption(def, options = []) {
|
|
@@ -132,13 +55,6 @@ function getDefaultMDXOptions({
|
|
|
132
55
|
_withoutBundler = false,
|
|
133
56
|
...mdxOptions
|
|
134
57
|
}) {
|
|
135
|
-
const mdxExports = [
|
|
136
|
-
"structuredData",
|
|
137
|
-
"extractedReferences",
|
|
138
|
-
"frontmatter",
|
|
139
|
-
"lastModified",
|
|
140
|
-
...valueToExport
|
|
141
|
-
];
|
|
142
58
|
const remarkPlugins = pluginOption(
|
|
143
59
|
(v) => [
|
|
144
60
|
plugins.remarkGfm,
|
|
@@ -166,10 +82,15 @@ function getDefaultMDXOptions({
|
|
|
166
82
|
plugins.remarkStructure,
|
|
167
83
|
remarkStructureOptions
|
|
168
84
|
],
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
85
|
+
() => {
|
|
86
|
+
return (_, file) => {
|
|
87
|
+
file.data["mdx-export"] ??= [];
|
|
88
|
+
for (const name of valueToExport) {
|
|
89
|
+
if (name in file.data)
|
|
90
|
+
file.data["mdx-export"].push({ name, value: file.data[name] });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
173
94
|
],
|
|
174
95
|
mdxOptions.remarkPlugins
|
|
175
96
|
);
|
|
@@ -189,11 +110,10 @@ function getDefaultMDXOptions({
|
|
|
189
110
|
};
|
|
190
111
|
}
|
|
191
112
|
var plugins;
|
|
192
|
-
var
|
|
193
|
-
"src/
|
|
113
|
+
var init_preset = __esm({
|
|
114
|
+
"src/loaders/mdx/preset.ts"() {
|
|
194
115
|
"use strict";
|
|
195
116
|
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
196
|
-
init_remark_postprocess();
|
|
197
117
|
}
|
|
198
118
|
});
|
|
199
119
|
|
|
@@ -233,7 +153,7 @@ function buildConfig(config) {
|
|
|
233
153
|
const input = this.global.mdxOptions;
|
|
234
154
|
async function uncached() {
|
|
235
155
|
const options = typeof input === "function" ? await input() : input;
|
|
236
|
-
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (
|
|
156
|
+
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_preset(), preset_exports));
|
|
237
157
|
if (options?.preset === "minimal") return options;
|
|
238
158
|
return getDefaultMDXOptions2({
|
|
239
159
|
...options,
|
|
@@ -252,39 +172,7 @@ var init_build = __esm({
|
|
|
252
172
|
}
|
|
253
173
|
});
|
|
254
174
|
|
|
255
|
-
// src/
|
|
256
|
-
function findConfigFile() {
|
|
257
|
-
return path.resolve("source.config.ts");
|
|
258
|
-
}
|
|
259
|
-
async function isZod3() {
|
|
260
|
-
try {
|
|
261
|
-
const content = JSON.parse(
|
|
262
|
-
(await fs.readFile("node_modules/zod/package.json")).toString()
|
|
263
|
-
);
|
|
264
|
-
const version = content.version;
|
|
265
|
-
return typeof version === "string" && version.startsWith("3.");
|
|
266
|
-
} catch {
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
function createCompatZodPlugin() {
|
|
271
|
-
return {
|
|
272
|
-
name: "replace-zod-import",
|
|
273
|
-
async setup(build) {
|
|
274
|
-
const usingZod3 = await isZod3();
|
|
275
|
-
if (!usingZod3) return;
|
|
276
|
-
console.warn(
|
|
277
|
-
"[Fumadocs MDX] Noticed Zod v3 in your node_modules, we recommend upgrading to Zod v4 for better compatibility."
|
|
278
|
-
);
|
|
279
|
-
build.onResolve({ filter: /^fumadocs-mdx\/config$/ }, () => {
|
|
280
|
-
return {
|
|
281
|
-
path: "fumadocs-mdx/config/zod-3",
|
|
282
|
-
external: true
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}
|
|
175
|
+
// src/loaders/config/load.ts
|
|
288
176
|
async function compileConfig(configPath, outDir) {
|
|
289
177
|
const { build } = await import("esbuild");
|
|
290
178
|
const transformed = await build({
|
|
@@ -296,7 +184,6 @@ async function compileConfig(configPath, outDir) {
|
|
|
296
184
|
platform: "node",
|
|
297
185
|
format: "esm",
|
|
298
186
|
packages: "external",
|
|
299
|
-
plugins: [createCompatZodPlugin()],
|
|
300
187
|
outExtension: {
|
|
301
188
|
".js": ".mjs"
|
|
302
189
|
},
|
|
@@ -329,8 +216,8 @@ async function getConfigHash(configPath) {
|
|
|
329
216
|
throw new Error("Cannot find config file");
|
|
330
217
|
}
|
|
331
218
|
var fs, path, import_node_url, cache;
|
|
332
|
-
var
|
|
333
|
-
"src/
|
|
219
|
+
var init_load = __esm({
|
|
220
|
+
"src/loaders/config/load.ts"() {
|
|
334
221
|
"use strict";
|
|
335
222
|
fs = __toESM(require("fs/promises"), 1);
|
|
336
223
|
path = __toESM(require("path"), 1);
|
|
@@ -384,29 +271,34 @@ ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`
|
|
|
384
271
|
}
|
|
385
272
|
});
|
|
386
273
|
|
|
387
|
-
// src/map/file-cache.ts
|
|
388
|
-
|
|
274
|
+
// src/next/map/file-cache.ts
|
|
275
|
+
function toFullPath(file) {
|
|
276
|
+
if (import_node_path.default.isAbsolute(file)) {
|
|
277
|
+
return import_node_path.default.relative(process.cwd(), file);
|
|
278
|
+
}
|
|
279
|
+
return file;
|
|
280
|
+
}
|
|
281
|
+
async function readFileWithCache(file) {
|
|
282
|
+
const fullPath = toFullPath(file);
|
|
283
|
+
const cached = map.get(fullPath);
|
|
284
|
+
if (cached) return cached;
|
|
285
|
+
const read = import_promises.default.readFile(fullPath).then((s) => s.toString());
|
|
286
|
+
map.set(fullPath, read);
|
|
287
|
+
return read;
|
|
288
|
+
}
|
|
289
|
+
function removeFileCache(file) {
|
|
290
|
+
map.delete(toFullPath(file));
|
|
291
|
+
}
|
|
292
|
+
var import_lru_cache, import_promises, import_node_path, map;
|
|
389
293
|
var init_file_cache = __esm({
|
|
390
|
-
"src/map/file-cache.ts"() {
|
|
294
|
+
"src/next/map/file-cache.ts"() {
|
|
391
295
|
"use strict";
|
|
392
296
|
import_lru_cache = require("lru-cache");
|
|
297
|
+
import_promises = __toESM(require("fs/promises"), 1);
|
|
298
|
+
import_node_path = __toESM(require("path"), 1);
|
|
393
299
|
map = new import_lru_cache.LRUCache({
|
|
394
|
-
max:
|
|
300
|
+
max: 100
|
|
395
301
|
});
|
|
396
|
-
fileCache = {
|
|
397
|
-
read(namespace, path8) {
|
|
398
|
-
return map.get(`${namespace}.${path8}`);
|
|
399
|
-
},
|
|
400
|
-
write(namespace, path8, data) {
|
|
401
|
-
map.set(`${namespace}.${path8}`, data);
|
|
402
|
-
},
|
|
403
|
-
removeCache(path8) {
|
|
404
|
-
for (const key of map.keys()) {
|
|
405
|
-
const keyPath = key.slice(key.indexOf(".") + 1);
|
|
406
|
-
if (keyPath === path8) map.delete(key);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
302
|
}
|
|
411
303
|
});
|
|
412
304
|
|
|
@@ -417,7 +309,7 @@ async function getGitTimestamp(file) {
|
|
|
417
309
|
try {
|
|
418
310
|
const out = await (0, import_tinyexec.x)(
|
|
419
311
|
"git",
|
|
420
|
-
["log", "-1", '--pretty="%ai"',
|
|
312
|
+
["log", "-1", '--pretty="%ai"', import_node_path2.default.relative(process.cwd(), file)],
|
|
421
313
|
{
|
|
422
314
|
throwOnError: true
|
|
423
315
|
}
|
|
@@ -429,11 +321,11 @@ async function getGitTimestamp(file) {
|
|
|
429
321
|
return;
|
|
430
322
|
}
|
|
431
323
|
}
|
|
432
|
-
var
|
|
324
|
+
var import_node_path2, import_tinyexec, cache2;
|
|
433
325
|
var init_git_timestamp = __esm({
|
|
434
326
|
"src/utils/git-timestamp.ts"() {
|
|
435
327
|
"use strict";
|
|
436
|
-
|
|
328
|
+
import_node_path2 = __toESM(require("path"), 1);
|
|
437
329
|
import_tinyexec = require("tinyexec");
|
|
438
330
|
cache2 = /* @__PURE__ */ new Map();
|
|
439
331
|
}
|
|
@@ -476,7 +368,7 @@ function getImportCode(info) {
|
|
|
476
368
|
return `import ${specifier}`;
|
|
477
369
|
}
|
|
478
370
|
function toImportPath(file, config) {
|
|
479
|
-
const ext =
|
|
371
|
+
const ext = import_node_path3.default.extname(file);
|
|
480
372
|
let filename;
|
|
481
373
|
if (ext === ".ts" && config.jsExtension) {
|
|
482
374
|
filename = file.substring(0, file.length - ext.length) + ".js";
|
|
@@ -487,23 +379,23 @@ function toImportPath(file, config) {
|
|
|
487
379
|
}
|
|
488
380
|
let importPath;
|
|
489
381
|
if ("relativeTo" in config) {
|
|
490
|
-
importPath =
|
|
491
|
-
if (!
|
|
382
|
+
importPath = import_node_path3.default.relative(config.relativeTo, filename);
|
|
383
|
+
if (!import_node_path3.default.isAbsolute(importPath) && !importPath.startsWith(".")) {
|
|
492
384
|
importPath = `./${importPath}`;
|
|
493
385
|
}
|
|
494
386
|
} else {
|
|
495
|
-
importPath =
|
|
387
|
+
importPath = import_node_path3.default.resolve(filename);
|
|
496
388
|
}
|
|
497
|
-
return importPath.replaceAll(
|
|
389
|
+
return importPath.replaceAll(import_node_path3.default.sep, "/");
|
|
498
390
|
}
|
|
499
391
|
function ident(code, tab = 1) {
|
|
500
392
|
return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
|
|
501
393
|
}
|
|
502
|
-
var
|
|
394
|
+
var import_node_path3;
|
|
503
395
|
var init_import_formatter = __esm({
|
|
504
396
|
"src/utils/import-formatter.ts"() {
|
|
505
397
|
"use strict";
|
|
506
|
-
|
|
398
|
+
import_node_path3 = __toESM(require("path"), 1);
|
|
507
399
|
}
|
|
508
400
|
});
|
|
509
401
|
|
|
@@ -530,12 +422,7 @@ var init_collections = __esm({
|
|
|
530
422
|
}
|
|
531
423
|
});
|
|
532
424
|
|
|
533
|
-
// src/map/generate.ts
|
|
534
|
-
async function readFileWithCache(file) {
|
|
535
|
-
const cached = fileCache.read("read-file", file);
|
|
536
|
-
if (cached) return cached;
|
|
537
|
-
return (await fs2.readFile(file)).toString();
|
|
538
|
-
}
|
|
425
|
+
// src/next/map/generate.ts
|
|
539
426
|
async function generateJS(configPath, config, importPath, configHash = false) {
|
|
540
427
|
let asyncInit = false;
|
|
541
428
|
const lines = [
|
|
@@ -562,7 +449,7 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
562
449
|
getImportCode({
|
|
563
450
|
type: "namespace",
|
|
564
451
|
name: importId,
|
|
565
|
-
specifier: `${toImportPath(file.
|
|
452
|
+
specifier: `${toImportPath(file.fullPath, importPath)}?${params.join("&")}`
|
|
566
453
|
})
|
|
567
454
|
);
|
|
568
455
|
return `{ info: ${JSON.stringify(file)}, data: ${importId} }`;
|
|
@@ -571,17 +458,17 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
571
458
|
}
|
|
572
459
|
async function getMetaEntries(collection, files) {
|
|
573
460
|
const items = files.map(async (file) => {
|
|
574
|
-
const source = await readFileWithCache(file.
|
|
575
|
-
let data = source.length === 0 ? {} : parseMetaEntry(file.
|
|
461
|
+
const source = await readFileWithCache(file.fullPath).catch(() => "");
|
|
462
|
+
let data = source.length === 0 ? {} : parseMetaEntry(file.fullPath, source);
|
|
576
463
|
if (collection?.schema) {
|
|
577
464
|
data = await validate(
|
|
578
465
|
collection.schema,
|
|
579
466
|
data,
|
|
580
467
|
{
|
|
581
468
|
source,
|
|
582
|
-
path: file.
|
|
469
|
+
path: file.fullPath
|
|
583
470
|
},
|
|
584
|
-
`invalid data in ${file.
|
|
471
|
+
`invalid data in ${file.fullPath}`
|
|
585
472
|
);
|
|
586
473
|
}
|
|
587
474
|
return JSON.stringify({
|
|
@@ -599,33 +486,40 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
599
486
|
specifier: "fumadocs-mdx/runtime/async",
|
|
600
487
|
names: ["_runtimeAsync", "buildConfig"]
|
|
601
488
|
}),
|
|
602
|
-
"const _sourceConfig = buildConfig(_source)"
|
|
489
|
+
"const _sourceConfig = buildConfig(_source)",
|
|
490
|
+
getImportCode({
|
|
491
|
+
type: "default",
|
|
492
|
+
name: "path",
|
|
493
|
+
specifier: "node:path"
|
|
494
|
+
})
|
|
603
495
|
);
|
|
604
496
|
asyncInit = true;
|
|
605
497
|
}
|
|
606
498
|
const entries2 = files.map(async (file) => {
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
);
|
|
499
|
+
const content = await readFileWithCache(file.fullPath).catch(() => "");
|
|
500
|
+
const parsed = fumaMatter(content);
|
|
610
501
|
let data = parsed.data;
|
|
611
502
|
if (collection.schema) {
|
|
612
503
|
data = await validate(
|
|
613
504
|
collection.schema,
|
|
614
505
|
parsed.data,
|
|
615
|
-
{ path: file.
|
|
616
|
-
`invalid frontmatter in ${file.
|
|
506
|
+
{ path: file.fullPath, source: parsed.content },
|
|
507
|
+
`invalid frontmatter in ${file.fullPath}`
|
|
617
508
|
);
|
|
618
509
|
}
|
|
619
510
|
let lastModified;
|
|
620
511
|
if (config.global?.lastModifiedTime === "git") {
|
|
621
|
-
lastModified = await getGitTimestamp(file.
|
|
512
|
+
lastModified = await getGitTimestamp(file.fullPath);
|
|
622
513
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
514
|
+
const hash = (0, import_node_crypto.createHash)("md5").update(content).digest("hex");
|
|
515
|
+
const infoStr = [];
|
|
516
|
+
for (const [k, v] of Object.entries({ ...file, hash })) {
|
|
517
|
+
infoStr.push(`${k}: ${JSON.stringify(v)}`);
|
|
518
|
+
}
|
|
519
|
+
infoStr.push(
|
|
520
|
+
`absolutePath: path.resolve(${JSON.stringify(file.fullPath)})`
|
|
521
|
+
);
|
|
522
|
+
return `{ info: { ${infoStr.join(", ")} }, lastModified: ${JSON.stringify(lastModified)}, data: ${JSON.stringify(data)} }`;
|
|
629
523
|
});
|
|
630
524
|
return Promise.all(entries2);
|
|
631
525
|
}
|
|
@@ -665,14 +559,14 @@ async function getCollectionFiles(collection) {
|
|
|
665
559
|
await Promise.all(
|
|
666
560
|
dirs.map(async (dir) => {
|
|
667
561
|
const result = await (0, import_tinyglobby.glob)(patterns, {
|
|
668
|
-
cwd:
|
|
669
|
-
absolute: true
|
|
562
|
+
cwd: path5.resolve(dir)
|
|
670
563
|
});
|
|
671
564
|
for (const item of result) {
|
|
672
565
|
if (!isFileSupported(item, collection)) continue;
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
566
|
+
const fullPath = path5.join(dir, item);
|
|
567
|
+
files.set(fullPath, {
|
|
568
|
+
path: item,
|
|
569
|
+
fullPath
|
|
676
570
|
});
|
|
677
571
|
}
|
|
678
572
|
})
|
|
@@ -680,7 +574,7 @@ async function getCollectionFiles(collection) {
|
|
|
680
574
|
return Array.from(files.values());
|
|
681
575
|
}
|
|
682
576
|
function parseMetaEntry(file, content) {
|
|
683
|
-
const extname2 =
|
|
577
|
+
const extname2 = path5.extname(file);
|
|
684
578
|
try {
|
|
685
579
|
if (extname2 === ".json") return JSON.parse(content);
|
|
686
580
|
if (extname2 === ".yaml") return (0, import_js_yaml2.load)(content);
|
|
@@ -691,12 +585,12 @@ function parseMetaEntry(file, content) {
|
|
|
691
585
|
}
|
|
692
586
|
throw new Error(`Unknown meta file format: ${extname2}, in ${file}.`);
|
|
693
587
|
}
|
|
694
|
-
var
|
|
588
|
+
var path5, import_node_crypto, import_tinyglobby, import_js_yaml2;
|
|
695
589
|
var init_generate = __esm({
|
|
696
|
-
"src/map/generate.ts"() {
|
|
590
|
+
"src/next/map/generate.ts"() {
|
|
697
591
|
"use strict";
|
|
698
|
-
|
|
699
|
-
|
|
592
|
+
path5 = __toESM(require("path"), 1);
|
|
593
|
+
import_node_crypto = require("crypto");
|
|
700
594
|
import_tinyglobby = require("tinyglobby");
|
|
701
595
|
init_validation();
|
|
702
596
|
init_file_cache();
|
|
@@ -708,7 +602,19 @@ var init_generate = __esm({
|
|
|
708
602
|
}
|
|
709
603
|
});
|
|
710
604
|
|
|
711
|
-
// src/
|
|
605
|
+
// src/loaders/config/index.ts
|
|
606
|
+
function findConfigFile() {
|
|
607
|
+
return import_node_path4.default.resolve("source.config.ts");
|
|
608
|
+
}
|
|
609
|
+
var import_node_path4;
|
|
610
|
+
var init_config = __esm({
|
|
611
|
+
"src/loaders/config/index.ts"() {
|
|
612
|
+
"use strict";
|
|
613
|
+
import_node_path4 = __toESM(require("path"), 1);
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
// src/next/map/watcher.ts
|
|
712
618
|
var watcher_exports = {};
|
|
713
619
|
__export(watcher_exports, {
|
|
714
620
|
watcher: () => watcher
|
|
@@ -732,17 +638,17 @@ function watcher(configPath, config, ignored) {
|
|
|
732
638
|
}
|
|
733
639
|
var import_chokidar;
|
|
734
640
|
var init_watcher = __esm({
|
|
735
|
-
"src/map/watcher.ts"() {
|
|
641
|
+
"src/next/map/watcher.ts"() {
|
|
736
642
|
"use strict";
|
|
737
643
|
import_chokidar = require("chokidar");
|
|
738
644
|
}
|
|
739
645
|
});
|
|
740
646
|
|
|
741
|
-
// src/map/index.ts
|
|
647
|
+
// src/next/map/index.ts
|
|
742
648
|
async function start(dev, configPath, outDir) {
|
|
743
649
|
let configHash = await getConfigHash(configPath);
|
|
744
650
|
let config = await loadConfig(configPath, outDir, configHash, true);
|
|
745
|
-
const outPath =
|
|
651
|
+
const outPath = path7.resolve(outDir, `index.ts`);
|
|
746
652
|
async function updateMapFile() {
|
|
747
653
|
const start3 = performance.now();
|
|
748
654
|
try {
|
|
@@ -773,14 +679,14 @@ async function start(dev, configPath, outDir) {
|
|
|
773
679
|
});
|
|
774
680
|
instance.on("all", (event, file) => {
|
|
775
681
|
if (typeof file !== "string") return;
|
|
776
|
-
const absolutePath =
|
|
682
|
+
const absolutePath = path7.resolve(file);
|
|
777
683
|
const onUpdate = async () => {
|
|
778
684
|
const isConfigFile = absolutePath === configPath;
|
|
779
685
|
if (isConfigFile) {
|
|
780
686
|
configHash = await getConfigHash(configPath);
|
|
781
687
|
config = await loadConfig(configPath, outDir, configHash, true);
|
|
782
688
|
}
|
|
783
|
-
if (event === "change")
|
|
689
|
+
if (event === "change") removeFileCache(absolutePath);
|
|
784
690
|
await updateMapFile();
|
|
785
691
|
};
|
|
786
692
|
void onUpdate();
|
|
@@ -791,13 +697,13 @@ async function start(dev, configPath, outDir) {
|
|
|
791
697
|
});
|
|
792
698
|
}
|
|
793
699
|
}
|
|
794
|
-
var
|
|
700
|
+
var path7, fs3;
|
|
795
701
|
var init_map = __esm({
|
|
796
|
-
"src/map/index.ts"() {
|
|
702
|
+
"src/next/map/index.ts"() {
|
|
797
703
|
"use strict";
|
|
798
|
-
|
|
704
|
+
path7 = __toESM(require("path"), 1);
|
|
799
705
|
fs3 = __toESM(require("fs/promises"), 1);
|
|
800
|
-
|
|
706
|
+
init_load();
|
|
801
707
|
init_generate();
|
|
802
708
|
init_file_cache();
|
|
803
709
|
init_validation();
|
|
@@ -891,24 +797,25 @@ __export(next_exports, {
|
|
|
891
797
|
});
|
|
892
798
|
async function postInstall(configPath = findConfigFile(), outDir = ".source") {
|
|
893
799
|
const config = await loadConfig(configPath, outDir, void 0, true);
|
|
894
|
-
const outPath =
|
|
895
|
-
await
|
|
896
|
-
await
|
|
800
|
+
const outPath = import_node_path5.default.join(outDir, "index.ts");
|
|
801
|
+
await import_promises2.default.rm(outDir, { recursive: true });
|
|
802
|
+
await import_promises2.default.mkdir(outDir, { recursive: true });
|
|
897
803
|
const hash = await getConfigHash(configPath);
|
|
898
|
-
await
|
|
804
|
+
await import_promises2.default.writeFile(
|
|
899
805
|
outPath,
|
|
900
806
|
await generateJS(configPath, config, { relativeTo: outDir }, hash)
|
|
901
807
|
);
|
|
902
808
|
console.log("[MDX] types generated");
|
|
903
809
|
}
|
|
904
|
-
var
|
|
810
|
+
var import_node_path5, import_promises2;
|
|
905
811
|
var init_next = __esm({
|
|
906
812
|
"src/next/index.ts"() {
|
|
907
813
|
"use strict";
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
814
|
+
init_load();
|
|
815
|
+
import_node_path5 = __toESM(require("path"), 1);
|
|
816
|
+
import_promises2 = __toESM(require("fs/promises"), 1);
|
|
911
817
|
init_generate();
|
|
818
|
+
init_config();
|
|
912
819
|
init_create();
|
|
913
820
|
}
|
|
914
821
|
});
|
|
@@ -1028,22 +935,23 @@ async function postInstall2(configPath = findConfigFile(), outDir, addJsExtensio
|
|
|
1028
935
|
const config = await loadConfig(configPath, "node_modules", void 0, true);
|
|
1029
936
|
const outFile = "source.generated.ts";
|
|
1030
937
|
if (outDir) {
|
|
1031
|
-
await
|
|
938
|
+
await import_promises3.default.mkdir(outDir, { recursive: true });
|
|
1032
939
|
}
|
|
1033
|
-
await
|
|
1034
|
-
outDir ?
|
|
940
|
+
await import_promises3.default.writeFile(
|
|
941
|
+
outDir ? import_node_path6.default.join(outDir, outFile) : outFile,
|
|
1035
942
|
entry(configPath, config, outDir ?? process.cwd(), addJsExtension)
|
|
1036
943
|
);
|
|
1037
944
|
console.log("[MDX] types generated");
|
|
1038
945
|
}
|
|
1039
|
-
var
|
|
946
|
+
var import_promises3, import_node_path6;
|
|
1040
947
|
var init_postinstall = __esm({
|
|
1041
948
|
"src/vite/postinstall.ts"() {
|
|
1042
949
|
"use strict";
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
950
|
+
init_load();
|
|
951
|
+
import_promises3 = __toESM(require("fs/promises"), 1);
|
|
952
|
+
import_node_path6 = __toESM(require("path"), 1);
|
|
1046
953
|
init_generate2();
|
|
954
|
+
init_config();
|
|
1047
955
|
}
|
|
1048
956
|
});
|
|
1049
957
|
|
package/dist/bin.js
CHANGED
|
@@ -9,7 +9,7 @@ async function start() {
|
|
|
9
9
|
const { postInstall } = await import("./next/index.js");
|
|
10
10
|
await postInstall(...args);
|
|
11
11
|
} else {
|
|
12
|
-
const { postInstall } = await import("./postinstall-
|
|
12
|
+
const { postInstall } = await import("./postinstall-SCSXM4IM.js");
|
|
13
13
|
await postInstall(...args);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,8 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createProcessor } from '@mdx-js/mdx';
|
|
2
|
+
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
3
|
+
import { TableOfContents } from 'fumadocs-core/server';
|
|
4
|
+
import { FC, ReactNode } from 'react';
|
|
5
|
+
import { MDXProps } from 'mdx/types';
|
|
6
|
+
import { E as ExtractedReference, a as DocCollection, b as DocsCollection, M as MetaCollection } from './define--6HQ1ehX.js';
|
|
4
7
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
8
|
|
|
9
|
+
type Processor = ReturnType<typeof createProcessor>;
|
|
10
|
+
interface CompilerOptions {
|
|
11
|
+
addDependency: (file: string) => void;
|
|
12
|
+
}
|
|
13
|
+
interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
|
|
14
|
+
frontmatter: Frontmatter;
|
|
15
|
+
structuredData: StructuredData;
|
|
16
|
+
toc: TableOfContents;
|
|
17
|
+
default: FC<MDXProps>;
|
|
18
|
+
/**
|
|
19
|
+
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
20
|
+
*/
|
|
21
|
+
lastModified?: Date;
|
|
22
|
+
extractedReferences?: ExtractedReference[];
|
|
23
|
+
_markdown?: string;
|
|
24
|
+
}
|
|
25
|
+
interface FumadocsDataMap {
|
|
26
|
+
/**
|
|
27
|
+
* [Fumadocs MDX] raw frontmatter, you can modify it
|
|
28
|
+
*/
|
|
29
|
+
frontmatter?: Record<string, unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* [Fumadocs MDX] additional ESM exports to write
|
|
32
|
+
*/
|
|
33
|
+
'mdx-export'?: {
|
|
34
|
+
name: string;
|
|
35
|
+
value: unknown;
|
|
36
|
+
}[];
|
|
37
|
+
extractedReferences: ExtractedReference[];
|
|
38
|
+
/**
|
|
39
|
+
* [Fumadocs MDX] The compiler object from loader
|
|
40
|
+
*/
|
|
41
|
+
_compiler?: CompilerOptions;
|
|
42
|
+
_getProcessor?: (format: 'md' | 'mdx') => Processor;
|
|
43
|
+
/**
|
|
44
|
+
* [Fumadocs MDX] Processed Markdown content before `remark-rehype`.
|
|
45
|
+
*/
|
|
46
|
+
_markdown?: string;
|
|
47
|
+
}
|
|
48
|
+
declare module 'vfile' {
|
|
49
|
+
interface DataMap extends FumadocsDataMap {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
6
53
|
type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
|
|
7
54
|
type DocMap<Frontmatter> = Record<string, (() => Promise<CompiledMDXFile<Frontmatter>>) & {
|
|
8
55
|
base: string;
|
|
@@ -48,4 +95,4 @@ interface ClientLoader<Frontmatter, Props> {
|
|
|
48
95
|
declare function createClientLoader<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
|
|
49
96
|
declare function toClientRenderer<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode): ClientRenderer<Props>;
|
|
50
97
|
|
|
51
|
-
export { type BaseCreate as B, type
|
|
98
|
+
export { type BaseCreate as B, type ClientLoader as C, type DocMap as D, type LazyDocMap as L, type MetaMap as M, type ClientLoaderOptions as a, type CompiledMDXFile as b, createClientLoader as c, fromConfigBase as f, toClientRenderer as t };
|