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
|
@@ -30,86 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/mdx
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) {
|
|
37
|
-
return (tree, file) => {
|
|
38
|
-
let title;
|
|
39
|
-
const urls = [];
|
|
40
|
-
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
41
|
-
if (node.type === "heading" && node.depth === 1) {
|
|
42
|
-
title = flattenNode2(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 flattenNode2(node) {
|
|
62
|
-
if ("children" in node)
|
|
63
|
-
return node.children.map((child) => flattenNode2(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_visit2, 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_visit2 = 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
|
|
|
@@ -206,25 +126,36 @@ __export(async_exports, {
|
|
|
206
126
|
module.exports = __toCommonJS(async_exports);
|
|
207
127
|
|
|
208
128
|
// src/runtime/next/index.ts
|
|
209
|
-
var
|
|
210
|
-
|
|
129
|
+
var fs = __toESM(require("fs/promises"), 1);
|
|
130
|
+
|
|
131
|
+
// src/runtime/shared.ts
|
|
132
|
+
function missingProcessedMarkdown() {
|
|
133
|
+
throw new Error(
|
|
134
|
+
"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/runtime/next/index.ts
|
|
211
139
|
var _runtime = {
|
|
212
140
|
doc(files) {
|
|
213
141
|
return files.map((file) => {
|
|
214
|
-
const
|
|
142
|
+
const data = file.data;
|
|
143
|
+
const filePath = file.info.fullPath;
|
|
215
144
|
return {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
145
|
+
info: file.info,
|
|
146
|
+
_exports: data,
|
|
147
|
+
body: data.default,
|
|
148
|
+
lastModified: data.lastModified,
|
|
149
|
+
toc: data.toc,
|
|
150
|
+
structuredData: data.structuredData,
|
|
151
|
+
extractedReferences: data.extractedReferences,
|
|
152
|
+
...data.frontmatter,
|
|
153
|
+
async getText(type) {
|
|
154
|
+
if (type === "raw") {
|
|
155
|
+
return (await fs.readFile(filePath)).toString();
|
|
156
|
+
}
|
|
157
|
+
if (typeof data._markdown !== "string") missingProcessedMarkdown();
|
|
158
|
+
return data._markdown;
|
|
228
159
|
}
|
|
229
160
|
};
|
|
230
161
|
});
|
|
@@ -232,8 +163,8 @@ var _runtime = {
|
|
|
232
163
|
meta(files) {
|
|
233
164
|
return files.map((file) => {
|
|
234
165
|
return {
|
|
235
|
-
|
|
236
|
-
|
|
166
|
+
info: file.info,
|
|
167
|
+
...file.data
|
|
237
168
|
};
|
|
238
169
|
});
|
|
239
170
|
},
|
|
@@ -262,26 +193,26 @@ function resolveFiles({ docs, meta }) {
|
|
|
262
193
|
for (const entry of docs) {
|
|
263
194
|
outputs.push({
|
|
264
195
|
type: "page",
|
|
265
|
-
absolutePath: entry.
|
|
266
|
-
path: entry.
|
|
196
|
+
absolutePath: entry.info.fullPath,
|
|
197
|
+
path: entry.info.path,
|
|
267
198
|
data: entry
|
|
268
199
|
});
|
|
269
200
|
}
|
|
270
201
|
for (const entry of meta) {
|
|
271
202
|
outputs.push({
|
|
272
203
|
type: "meta",
|
|
273
|
-
absolutePath: entry.
|
|
274
|
-
path: entry.
|
|
204
|
+
absolutePath: entry.info.fullPath,
|
|
205
|
+
path: entry.info.path,
|
|
275
206
|
data: entry
|
|
276
207
|
});
|
|
277
208
|
}
|
|
278
209
|
return outputs;
|
|
279
210
|
}
|
|
280
211
|
|
|
281
|
-
// src/
|
|
212
|
+
// src/loaders/mdx/build-mdx.ts
|
|
282
213
|
var import_mdx = require("@mdx-js/mdx");
|
|
283
214
|
|
|
284
|
-
// src/mdx
|
|
215
|
+
// src/loaders/mdx/remark-include.ts
|
|
285
216
|
var import_unified = require("unified");
|
|
286
217
|
var import_unist_util_visit = require("unist-util-visit");
|
|
287
218
|
var path = __toESM(require("path"), 1);
|
|
@@ -303,11 +234,32 @@ function fumaMatter(input) {
|
|
|
303
234
|
return output;
|
|
304
235
|
}
|
|
305
236
|
|
|
306
|
-
// src/mdx
|
|
237
|
+
// src/loaders/mdx/remark-include.ts
|
|
307
238
|
var import_remark_parse = __toESM(require("remark-parse"), 1);
|
|
308
239
|
var import_remark_mdx = __toESM(require("remark-mdx"), 1);
|
|
309
240
|
var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
310
|
-
var
|
|
241
|
+
var ElementLikeTypes = [
|
|
242
|
+
"mdxJsxFlowElement",
|
|
243
|
+
"mdxJsxTextElement",
|
|
244
|
+
"containerDirective",
|
|
245
|
+
"textDirective",
|
|
246
|
+
"leafDirective"
|
|
247
|
+
];
|
|
248
|
+
function isElementLike(node) {
|
|
249
|
+
return ElementLikeTypes.includes(node.type);
|
|
250
|
+
}
|
|
251
|
+
function parseElementAttributes(element) {
|
|
252
|
+
if (Array.isArray(element.attributes)) {
|
|
253
|
+
const attributes = {};
|
|
254
|
+
for (const attr of element.attributes) {
|
|
255
|
+
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
256
|
+
attributes[attr.name] = attr.value;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return attributes;
|
|
260
|
+
}
|
|
261
|
+
return element.attributes ?? {};
|
|
262
|
+
}
|
|
311
263
|
function flattenNode(node) {
|
|
312
264
|
if ("children" in node)
|
|
313
265
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
@@ -324,21 +276,31 @@ function parseSpecifier(specifier) {
|
|
|
324
276
|
}
|
|
325
277
|
function extractSection(root, section) {
|
|
326
278
|
let nodes;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
279
|
+
let capturingHeadingContent = false;
|
|
280
|
+
(0, import_unist_util_visit.visit)(root, (node) => {
|
|
281
|
+
if (node.type === "heading") {
|
|
282
|
+
if (capturingHeadingContent) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
if (node.data?.hProperties?.id === section) {
|
|
286
|
+
capturingHeadingContent = true;
|
|
287
|
+
nodes = [node];
|
|
288
|
+
return "skip";
|
|
289
|
+
}
|
|
290
|
+
return;
|
|
333
291
|
}
|
|
334
|
-
if (
|
|
335
|
-
nodes
|
|
336
|
-
|
|
292
|
+
if (capturingHeadingContent) {
|
|
293
|
+
nodes?.push(node);
|
|
294
|
+
return "skip";
|
|
337
295
|
}
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
296
|
+
if (isElementLike(node) && node.name === "section") {
|
|
297
|
+
const attributes = parseElementAttributes(node);
|
|
298
|
+
if (attributes.id === section) {
|
|
299
|
+
nodes = node.children;
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
342
304
|
if (nodes)
|
|
343
305
|
return {
|
|
344
306
|
type: "root",
|
|
@@ -370,55 +332,52 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
370
332
|
data: {}
|
|
371
333
|
};
|
|
372
334
|
}
|
|
373
|
-
const
|
|
335
|
+
const parser = (data._getProcessor ?? getDefaultProcessor)(
|
|
374
336
|
ext === ".mdx" ? "mdx" : "md"
|
|
375
337
|
);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
338
|
+
const parsed = fumaMatter(content);
|
|
339
|
+
let mdast = parser.parse({
|
|
340
|
+
path: file,
|
|
341
|
+
value: parsed.content,
|
|
342
|
+
data: { frontmatter: parsed.data }
|
|
343
|
+
});
|
|
379
344
|
if (heading) {
|
|
380
|
-
const extracted = extractSection(
|
|
345
|
+
const extracted = extractSection(
|
|
346
|
+
await (0, import_unified.unified)().use(import_mdx_plugins.remarkHeading).run(mdast),
|
|
347
|
+
heading
|
|
348
|
+
);
|
|
381
349
|
if (!extracted)
|
|
382
350
|
throw new Error(
|
|
383
|
-
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag.`
|
|
351
|
+
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag, or a :::section directive with remark-directive configured.`
|
|
384
352
|
);
|
|
385
|
-
|
|
353
|
+
mdast = extracted;
|
|
386
354
|
}
|
|
387
|
-
await update(
|
|
388
|
-
return
|
|
355
|
+
await update(mdast, path.dirname(file), data);
|
|
356
|
+
return mdast;
|
|
389
357
|
}
|
|
390
358
|
async function update(tree, directory, data) {
|
|
391
359
|
const queue = [];
|
|
392
|
-
(0, import_unist_util_visit.visit)(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
Object.assign(
|
|
414
|
-
parent && parent.type === "paragraph" ? parent : node,
|
|
415
|
-
replace
|
|
416
|
-
);
|
|
417
|
-
})
|
|
418
|
-
);
|
|
419
|
-
return "skip";
|
|
420
|
-
}
|
|
421
|
-
);
|
|
360
|
+
(0, import_unist_util_visit.visit)(tree, ElementLikeTypes, (_node, _, parent) => {
|
|
361
|
+
const node = _node;
|
|
362
|
+
if (node.name !== TagName) return;
|
|
363
|
+
const specifier = flattenNode(node);
|
|
364
|
+
if (specifier.length === 0) return "skip";
|
|
365
|
+
const attributes = parseElementAttributes(node);
|
|
366
|
+
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
367
|
+
const file = path.resolve(
|
|
368
|
+
"cwd" in attributes ? process.cwd() : directory,
|
|
369
|
+
relativePath
|
|
370
|
+
);
|
|
371
|
+
queue.push(
|
|
372
|
+
embedContent(file, section, attributes, data).then((replace) => {
|
|
373
|
+
Object.assign(
|
|
374
|
+
parent && parent.type === "paragraph" ? parent : node,
|
|
375
|
+
replace
|
|
376
|
+
);
|
|
377
|
+
})
|
|
378
|
+
);
|
|
379
|
+
return "skip";
|
|
380
|
+
});
|
|
422
381
|
await Promise.all(queue);
|
|
423
382
|
}
|
|
424
383
|
return async (tree, file) => {
|
|
@@ -431,26 +390,126 @@ function getDefaultProcessor(format) {
|
|
|
431
390
|
return mdProcessor.use(import_remark_mdx.default);
|
|
432
391
|
}
|
|
433
392
|
|
|
434
|
-
// src/
|
|
435
|
-
var
|
|
393
|
+
// src/loaders/mdx/remark-postprocess.ts
|
|
394
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
395
|
+
var import_mdast_util_to_markdown = require("mdast-util-to-markdown");
|
|
396
|
+
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
397
|
+
function remarkPostprocess({
|
|
398
|
+
includeProcessedMarkdown = false,
|
|
399
|
+
valueToExport = []
|
|
400
|
+
} = {}) {
|
|
401
|
+
return (tree, file) => {
|
|
402
|
+
let title;
|
|
403
|
+
const urls = [];
|
|
404
|
+
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
405
|
+
if (node.type === "heading" && node.depth === 1) {
|
|
406
|
+
title = flattenNode2(node);
|
|
407
|
+
}
|
|
408
|
+
if (node.type !== "link") return;
|
|
409
|
+
urls.push({
|
|
410
|
+
href: node.url
|
|
411
|
+
});
|
|
412
|
+
return "skip";
|
|
413
|
+
});
|
|
414
|
+
if (title) {
|
|
415
|
+
file.data.frontmatter ??= {};
|
|
416
|
+
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
417
|
+
}
|
|
418
|
+
file.data.extractedReferences = urls;
|
|
419
|
+
if (includeProcessedMarkdown) {
|
|
420
|
+
file.data._markdown = (0, import_mdast_util_to_markdown.toMarkdown)(tree, {
|
|
421
|
+
...this.data("settings"),
|
|
422
|
+
// from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
|
|
423
|
+
extensions: this.data("toMarkdownExtensions") || []
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
for (const { name, value } of file.data["mdx-export"] ?? []) {
|
|
427
|
+
tree.children.unshift(getMdastExport(name, value));
|
|
428
|
+
}
|
|
429
|
+
for (const name of valueToExport) {
|
|
430
|
+
if (!(name in file.data)) continue;
|
|
431
|
+
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function getMdastExport(name, value) {
|
|
436
|
+
return {
|
|
437
|
+
type: "mdxjsEsm",
|
|
438
|
+
value: "",
|
|
439
|
+
data: {
|
|
440
|
+
estree: {
|
|
441
|
+
type: "Program",
|
|
442
|
+
sourceType: "module",
|
|
443
|
+
body: [
|
|
444
|
+
{
|
|
445
|
+
type: "ExportNamedDeclaration",
|
|
446
|
+
attributes: [],
|
|
447
|
+
specifiers: [],
|
|
448
|
+
source: null,
|
|
449
|
+
declaration: {
|
|
450
|
+
type: "VariableDeclaration",
|
|
451
|
+
kind: "let",
|
|
452
|
+
declarations: [
|
|
453
|
+
{
|
|
454
|
+
type: "VariableDeclarator",
|
|
455
|
+
id: {
|
|
456
|
+
type: "Identifier",
|
|
457
|
+
name
|
|
458
|
+
},
|
|
459
|
+
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
]
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
function flattenNode2(node) {
|
|
470
|
+
if ("children" in node)
|
|
471
|
+
return node.children.map((child) => flattenNode2(child)).join("");
|
|
472
|
+
if ("value" in node) return node.value;
|
|
473
|
+
return "";
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// src/loaders/mdx/build-mdx.ts
|
|
477
|
+
var cache = /* @__PURE__ */ new Map();
|
|
436
478
|
async function buildMDX(cacheKey, source, options) {
|
|
437
479
|
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
438
480
|
function getProcessor(format) {
|
|
439
481
|
const key = `${cacheKey}:${format}`;
|
|
440
|
-
let processor =
|
|
482
|
+
let processor = cache.get(key);
|
|
441
483
|
if (!processor) {
|
|
442
484
|
processor = (0, import_mdx.createProcessor)({
|
|
443
485
|
outputFormat: "program",
|
|
444
486
|
...rest,
|
|
445
|
-
remarkPlugins: [
|
|
487
|
+
remarkPlugins: [
|
|
488
|
+
remarkInclude,
|
|
489
|
+
...rest.remarkPlugins ?? [],
|
|
490
|
+
[
|
|
491
|
+
remarkPostprocess,
|
|
492
|
+
{
|
|
493
|
+
...options.postprocess,
|
|
494
|
+
valueToExport: [
|
|
495
|
+
...options.postprocess?.valueToExport ?? [],
|
|
496
|
+
"structuredData",
|
|
497
|
+
"extractedReferences",
|
|
498
|
+
"frontmatter",
|
|
499
|
+
"lastModified",
|
|
500
|
+
"_markdown"
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
]
|
|
504
|
+
],
|
|
446
505
|
format
|
|
447
506
|
});
|
|
448
|
-
|
|
507
|
+
cache.set(key, processor);
|
|
449
508
|
}
|
|
450
509
|
return processor;
|
|
451
510
|
}
|
|
452
511
|
return getProcessor(
|
|
453
|
-
options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
|
|
512
|
+
options.format ?? (filePath.endsWith(".mdx") ? "mdx" : "md")
|
|
454
513
|
).process({
|
|
455
514
|
value: source,
|
|
456
515
|
path: filePath,
|
|
@@ -467,6 +526,28 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
467
526
|
var import_client = require("@fumadocs/mdx-remote/client");
|
|
468
527
|
var import_node_url = require("url");
|
|
469
528
|
|
|
529
|
+
// src/next/map/file-cache.ts
|
|
530
|
+
var import_lru_cache = require("lru-cache");
|
|
531
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
532
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
533
|
+
var map = new import_lru_cache.LRUCache({
|
|
534
|
+
max: 100
|
|
535
|
+
});
|
|
536
|
+
function toFullPath(file) {
|
|
537
|
+
if (import_node_path.default.isAbsolute(file)) {
|
|
538
|
+
return import_node_path.default.relative(process.cwd(), file);
|
|
539
|
+
}
|
|
540
|
+
return file;
|
|
541
|
+
}
|
|
542
|
+
async function readFileWithCache(file) {
|
|
543
|
+
const fullPath = toFullPath(file);
|
|
544
|
+
const cached = map.get(fullPath);
|
|
545
|
+
if (cached) return cached;
|
|
546
|
+
const read = import_promises.default.readFile(fullPath).then((s) => s.toString());
|
|
547
|
+
map.set(fullPath, read);
|
|
548
|
+
return read;
|
|
549
|
+
}
|
|
550
|
+
|
|
470
551
|
// src/config/build.ts
|
|
471
552
|
function buildConfig(config) {
|
|
472
553
|
const collections = /* @__PURE__ */ new Map();
|
|
@@ -503,7 +584,7 @@ function buildConfig(config) {
|
|
|
503
584
|
const input = this.global.mdxOptions;
|
|
504
585
|
async function uncached() {
|
|
505
586
|
const options = typeof input === "function" ? await input() : input;
|
|
506
|
-
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (
|
|
587
|
+
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_preset(), preset_exports));
|
|
507
588
|
if (options?.preset === "minimal") return options;
|
|
508
589
|
return getDefaultMDXOptions2({
|
|
509
590
|
...options,
|
|
@@ -518,41 +599,60 @@ function buildConfig(config) {
|
|
|
518
599
|
}
|
|
519
600
|
|
|
520
601
|
// src/runtime/next/async.ts
|
|
521
|
-
|
|
602
|
+
function getDocCollection(config, collection) {
|
|
522
603
|
const col = config.collections.get(collection);
|
|
523
|
-
if (col?.type === "doc" && col.mdxOptions) return col
|
|
524
|
-
if (col?.type === "docs" && col.docs.mdxOptions) return col.docs
|
|
525
|
-
|
|
604
|
+
if (col?.type === "doc" && col.mdxOptions) return col;
|
|
605
|
+
if (col?.type === "docs" && col.docs.mdxOptions) return col.docs;
|
|
606
|
+
}
|
|
607
|
+
async function getOptions(config, collection) {
|
|
608
|
+
return collection?.mdxOptions ?? await config.getDefaultMDXOptions("remote");
|
|
526
609
|
}
|
|
527
610
|
var _runtimeAsync = {
|
|
528
|
-
doc(files,
|
|
611
|
+
doc(files, collectionName, config) {
|
|
612
|
+
const collection = getDocCollection(config, collectionName);
|
|
529
613
|
const initMdxOptions = getOptions(config, collection);
|
|
530
|
-
return files.map(({ info
|
|
614
|
+
return files.map(({ info, data, lastModified }) => {
|
|
615
|
+
let cachedResult;
|
|
616
|
+
async function compileAndLoad() {
|
|
617
|
+
if (cachedResult) return cachedResult;
|
|
618
|
+
const mdxOptions = await initMdxOptions;
|
|
619
|
+
const raw = await readFileWithCache(info.fullPath);
|
|
620
|
+
const { content } = fumaMatter(raw);
|
|
621
|
+
const compiled = await buildMDX(collectionName, content, {
|
|
622
|
+
...mdxOptions,
|
|
623
|
+
development: false,
|
|
624
|
+
frontmatter: data,
|
|
625
|
+
postprocess: collection?.postprocess,
|
|
626
|
+
data: {
|
|
627
|
+
lastModified
|
|
628
|
+
},
|
|
629
|
+
filePath: info.fullPath
|
|
630
|
+
});
|
|
631
|
+
const result = await (0, import_client.executeMdx)(String(compiled.value), {
|
|
632
|
+
baseUrl: (0, import_node_url.pathToFileURL)(info.fullPath)
|
|
633
|
+
});
|
|
634
|
+
return cachedResult = result;
|
|
635
|
+
}
|
|
531
636
|
return {
|
|
532
637
|
...data,
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
638
|
+
info,
|
|
639
|
+
async getText(type) {
|
|
640
|
+
if (type === "raw") {
|
|
641
|
+
return readFileWithCache(info.fullPath);
|
|
642
|
+
}
|
|
643
|
+
const out = await compileAndLoad();
|
|
644
|
+
if (typeof out._markdown !== "string") missingProcessedMarkdown();
|
|
645
|
+
return out._markdown;
|
|
536
646
|
},
|
|
537
647
|
async load() {
|
|
538
|
-
const
|
|
539
|
-
const out = await buildMDX(collection, content.body, {
|
|
540
|
-
...mdxOptions,
|
|
541
|
-
development: false,
|
|
542
|
-
frontmatter: data,
|
|
543
|
-
data: {
|
|
544
|
-
lastModified
|
|
545
|
-
},
|
|
546
|
-
filePath: file.absolutePath
|
|
547
|
-
});
|
|
548
|
-
const { default: body, ...rest } = await (0, import_client.executeMdx)(String(out), {
|
|
549
|
-
baseUrl: (0, import_node_url.pathToFileURL)(file.absolutePath)
|
|
550
|
-
});
|
|
648
|
+
const out = await compileAndLoad();
|
|
551
649
|
return {
|
|
552
|
-
|
|
553
|
-
body,
|
|
554
|
-
|
|
555
|
-
|
|
650
|
+
_exports: out,
|
|
651
|
+
body: out.default,
|
|
652
|
+
lastModified,
|
|
653
|
+
toc: out.toc,
|
|
654
|
+
extractedReferences: out.extractedReferences,
|
|
655
|
+
structuredData: out.structuredData
|
|
556
656
|
};
|
|
557
657
|
}
|
|
558
658
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { L as LoadedConfig,
|
|
1
|
+
import { L as LoadedConfig, c as RuntimeAsync } from '../../types-DkGjw-Uo.cjs';
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
3
|
import 'fumadocs-core/source';
|
|
4
|
-
import '../../define
|
|
4
|
+
import '../../define--6HQ1ehX.cjs';
|
|
5
5
|
import 'fumadocs-core/mdx-plugins';
|
|
6
6
|
import '@mdx-js/mdx';
|
|
7
7
|
import 'unified';
|
|
8
8
|
import 'zod';
|
|
9
|
-
import '../../
|
|
9
|
+
import '../../shared-CqgMnt9h.cjs';
|
|
10
10
|
import 'fumadocs-core/server';
|
|
11
11
|
import 'react';
|
|
12
12
|
import 'mdx/types';
|