fumadocs-mdx 13.0.4 → 13.0.6
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 +164 -133
- package/dist/bin.js +1 -1
- package/dist/bun/index.cjs +156 -132
- package/dist/bun/index.d.cts +6 -1
- package/dist/bun/index.d.ts +6 -1
- package/dist/bun/index.js +8 -11
- package/dist/{chunk-TZ5EQBFW.js → chunk-2AQRQXSO.js} +7 -1
- package/dist/chunk-2E2JCOSO.js +135 -0
- package/dist/chunk-4757L6ST.js +77 -0
- package/dist/{chunk-ZNVPB2IR.js → chunk-ETIN2W7C.js} +49 -41
- package/dist/next/index.js +2 -4
- package/dist/node/loader.cjs +146 -119
- package/dist/node/loader.js +6 -10
- package/dist/vite/index.cjs +167 -135
- package/dist/vite/index.js +9 -15
- package/dist/webpack/mdx.cjs +86 -75
- package/dist/webpack/mdx.js +3 -3
- package/dist/webpack/meta.cjs +64 -37
- package/dist/webpack/meta.js +3 -3
- package/package.json +7 -7
- package/dist/chunk-4JSFLXXT.js +0 -8
- package/dist/chunk-XYGORKQA.js +0 -130
- package/dist/chunk-YAIPHUCZ.js +0 -56
package/dist/webpack/meta.cjs
CHANGED
|
@@ -320,10 +320,12 @@ var import_node_path = __toESM(require("path"), 1);
|
|
|
320
320
|
function toWebpack(loader2) {
|
|
321
321
|
return async function(source, callback) {
|
|
322
322
|
try {
|
|
323
|
-
const result = await loader2({
|
|
323
|
+
const result = await loader2.load({
|
|
324
324
|
filePath: this.resourcePath,
|
|
325
325
|
query: (0, import_node_querystring.parse)(this.resourceQuery.slice(1)),
|
|
326
|
-
|
|
326
|
+
getSource() {
|
|
327
|
+
return source;
|
|
328
|
+
},
|
|
327
329
|
development: this.mode === "development",
|
|
328
330
|
compiler: this
|
|
329
331
|
});
|
|
@@ -452,49 +454,74 @@ function createStandaloneConfigLoader({
|
|
|
452
454
|
// src/loaders/meta.ts
|
|
453
455
|
var import_js_yaml = require("js-yaml");
|
|
454
456
|
var import_zod = require("zod");
|
|
457
|
+
|
|
458
|
+
// src/loaders/index.ts
|
|
459
|
+
var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
|
|
460
|
+
|
|
461
|
+
// src/loaders/meta.ts
|
|
455
462
|
var querySchema = import_zod.z.object({
|
|
456
463
|
collection: import_zod.z.string().optional()
|
|
457
464
|
}).loose();
|
|
458
465
|
function createMetaLoader(configLoader, resolve2 = {}) {
|
|
459
466
|
const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve2;
|
|
460
|
-
|
|
461
|
-
const isJson = filePath.endsWith(".json");
|
|
462
|
-
const parsed = querySchema.parse(query);
|
|
463
|
-
const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
|
|
464
|
-
if (!collection) return null;
|
|
465
|
-
let data;
|
|
466
|
-
try {
|
|
467
|
-
data = isJson ? JSON.parse(source) : (0, import_js_yaml.load)(source);
|
|
468
|
-
} catch (e) {
|
|
469
|
-
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
470
|
-
}
|
|
471
|
-
let schema;
|
|
472
|
-
switch (collection?.type) {
|
|
473
|
-
case "meta":
|
|
474
|
-
schema = collection.schema;
|
|
475
|
-
break;
|
|
476
|
-
case "docs":
|
|
477
|
-
schema = collection.meta.schema;
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
if (schema) {
|
|
481
|
-
data = await validate(
|
|
482
|
-
schema,
|
|
483
|
-
data,
|
|
484
|
-
{ path: filePath, source },
|
|
485
|
-
`invalid data in ${filePath}`
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
let code;
|
|
467
|
+
function stringifyOutput(isJson, data) {
|
|
489
468
|
if (isJson) {
|
|
490
|
-
|
|
469
|
+
return resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
|
|
491
470
|
} else {
|
|
492
|
-
|
|
471
|
+
return resolveYaml === "yaml" ? (0, import_js_yaml.dump)(data) : `export default ${JSON.stringify(data)}`;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
test: metaLoaderGlob,
|
|
476
|
+
async load({ filePath, query, getSource }) {
|
|
477
|
+
const parsed = querySchema.parse(query);
|
|
478
|
+
const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
|
|
479
|
+
if (!collection) return null;
|
|
480
|
+
const isJson = filePath.endsWith(".json");
|
|
481
|
+
const source = await getSource();
|
|
482
|
+
let data;
|
|
483
|
+
try {
|
|
484
|
+
data = isJson ? JSON.parse(source) : (0, import_js_yaml.load)(source);
|
|
485
|
+
} catch (e) {
|
|
486
|
+
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
487
|
+
}
|
|
488
|
+
let schema;
|
|
489
|
+
switch (collection?.type) {
|
|
490
|
+
case "meta":
|
|
491
|
+
schema = collection.schema;
|
|
492
|
+
break;
|
|
493
|
+
case "docs":
|
|
494
|
+
schema = collection.meta.schema;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
if (schema) {
|
|
498
|
+
data = await validate(
|
|
499
|
+
schema,
|
|
500
|
+
data,
|
|
501
|
+
{ path: filePath, source },
|
|
502
|
+
`invalid data in ${filePath}`
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
code: stringifyOutput(isJson, data)
|
|
507
|
+
};
|
|
508
|
+
},
|
|
509
|
+
bun: {
|
|
510
|
+
async fallback({ getSource, filePath }) {
|
|
511
|
+
const source = await getSource();
|
|
512
|
+
const isJson = filePath.endsWith(".json");
|
|
513
|
+
let data;
|
|
514
|
+
try {
|
|
515
|
+
data = isJson ? JSON.parse(source) : (0, import_js_yaml.load)(source);
|
|
516
|
+
} catch (e) {
|
|
517
|
+
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
518
|
+
}
|
|
519
|
+
return {
|
|
520
|
+
loader: "object",
|
|
521
|
+
exports: data
|
|
522
|
+
};
|
|
523
|
+
}
|
|
493
524
|
}
|
|
494
|
-
return {
|
|
495
|
-
code,
|
|
496
|
-
map: null
|
|
497
|
-
};
|
|
498
525
|
};
|
|
499
526
|
}
|
|
500
527
|
|
package/dist/webpack/meta.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMetaLoader
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-4757L6ST.js";
|
|
4
4
|
import {
|
|
5
5
|
createStandaloneConfigLoader,
|
|
6
6
|
toWebpack
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ETIN2W7C.js";
|
|
8
8
|
import {
|
|
9
9
|
createCore
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-2AQRQXSO.js";
|
|
11
11
|
|
|
12
12
|
// src/webpack/meta.ts
|
|
13
13
|
var instance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.6",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@mdx-js/mdx": "^3.1.1",
|
|
80
80
|
"@standard-schema/spec": "^1.0.0",
|
|
81
81
|
"chokidar": "^4.0.3",
|
|
82
|
-
"esbuild": "^0.25.
|
|
82
|
+
"esbuild": "^0.25.12",
|
|
83
83
|
"estree-util-value-to-estree": "^3.5.0",
|
|
84
84
|
"js-yaml": "^4.1.0",
|
|
85
85
|
"lru-cache": "^11.2.2",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"picocolors": "^1.1.1",
|
|
88
88
|
"picomatch": "^4.0.3",
|
|
89
89
|
"remark-mdx": "^3.1.1",
|
|
90
|
-
"tinyexec": "^1.0.
|
|
90
|
+
"tinyexec": "^1.0.2",
|
|
91
91
|
"tinyglobby": "^0.2.15",
|
|
92
92
|
"unified": "^11.0.5",
|
|
93
93
|
"unist-util-remove-position": "^5.0.0",
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"@types/js-yaml": "^4.0.9",
|
|
100
100
|
"@types/mdast": "^4.0.4",
|
|
101
101
|
"@types/mdx": "^2.0.13",
|
|
102
|
-
"@types/node": "^24.
|
|
102
|
+
"@types/node": "^24.10.0",
|
|
103
103
|
"@types/picomatch": "^4.0.2",
|
|
104
104
|
"@types/react": "^19.2.2",
|
|
105
|
-
"astro": "^5.
|
|
105
|
+
"astro": "^5.15.3",
|
|
106
106
|
"mdast-util-directive": "^3.1.0",
|
|
107
107
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
108
108
|
"next": "16.0.1",
|
|
@@ -112,11 +112,11 @@
|
|
|
112
112
|
"remark-stringify": "^11.0.0",
|
|
113
113
|
"rollup": "^4.52.5",
|
|
114
114
|
"vfile": "^6.0.3",
|
|
115
|
-
"vite": "^7.
|
|
115
|
+
"vite": "^7.2.0",
|
|
116
116
|
"webpack": "^5.102.1",
|
|
117
117
|
"@fumadocs/mdx-remote": "1.4.3",
|
|
118
118
|
"eslint-config-custom": "0.0.0",
|
|
119
|
-
"fumadocs-core": "16.0.
|
|
119
|
+
"fumadocs-core": "16.0.9",
|
|
120
120
|
"tsconfig": "0.0.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
package/dist/chunk-4JSFLXXT.js
DELETED
package/dist/chunk-XYGORKQA.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildMDX
|
|
3
|
-
} from "./chunk-3J3WL7WN.js";
|
|
4
|
-
import {
|
|
5
|
-
getGitTimestamp
|
|
6
|
-
} from "./chunk-VUEZTR2H.js";
|
|
7
|
-
import {
|
|
8
|
-
validate
|
|
9
|
-
} from "./chunk-TZ5EQBFW.js";
|
|
10
|
-
import {
|
|
11
|
-
fumaMatter
|
|
12
|
-
} from "./chunk-VWJKRQZR.js";
|
|
13
|
-
|
|
14
|
-
// src/loaders/mdx/index.ts
|
|
15
|
-
import { z } from "zod";
|
|
16
|
-
import fs from "fs/promises";
|
|
17
|
-
import path from "path";
|
|
18
|
-
import { createHash } from "crypto";
|
|
19
|
-
var querySchema = z.object({
|
|
20
|
-
only: z.literal(["frontmatter", "all"]).default("all"),
|
|
21
|
-
collection: z.string().optional()
|
|
22
|
-
}).loose();
|
|
23
|
-
var cacheEntry = z.object({
|
|
24
|
-
code: z.string(),
|
|
25
|
-
map: z.any().optional(),
|
|
26
|
-
hash: z.string().optional()
|
|
27
|
-
});
|
|
28
|
-
function createMdxLoader(configLoader) {
|
|
29
|
-
return async ({
|
|
30
|
-
source: value,
|
|
31
|
-
development: isDevelopment,
|
|
32
|
-
query,
|
|
33
|
-
compiler,
|
|
34
|
-
filePath
|
|
35
|
-
}) => {
|
|
36
|
-
const matter = fumaMatter(value);
|
|
37
|
-
const parsed = querySchema.parse(query);
|
|
38
|
-
const config = await configLoader.getConfig();
|
|
39
|
-
let after;
|
|
40
|
-
if (!isDevelopment && config.global.experimentalBuildCache) {
|
|
41
|
-
const cacheDir = config.global.experimentalBuildCache;
|
|
42
|
-
const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
|
|
43
|
-
const cached = await fs.readFile(path.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
|
|
44
|
-
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
45
|
-
after = async () => {
|
|
46
|
-
await fs.mkdir(cacheDir, { recursive: true });
|
|
47
|
-
await fs.writeFile(
|
|
48
|
-
path.join(cacheDir, cacheKey),
|
|
49
|
-
JSON.stringify({
|
|
50
|
-
...out,
|
|
51
|
-
hash: generateCacheHash(value)
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
|
|
57
|
-
let docCollection;
|
|
58
|
-
switch (collection?.type) {
|
|
59
|
-
case "doc":
|
|
60
|
-
docCollection = collection;
|
|
61
|
-
break;
|
|
62
|
-
case "docs":
|
|
63
|
-
docCollection = collection.docs;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
if (docCollection?.schema) {
|
|
67
|
-
matter.data = await validate(
|
|
68
|
-
docCollection.schema,
|
|
69
|
-
matter.data,
|
|
70
|
-
{
|
|
71
|
-
source: value,
|
|
72
|
-
path: filePath
|
|
73
|
-
},
|
|
74
|
-
`invalid frontmatter in ${filePath}`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
if (parsed.only === "frontmatter") {
|
|
78
|
-
return {
|
|
79
|
-
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
80
|
-
map: null
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const data = {};
|
|
84
|
-
if (config.global.lastModifiedTime === "git") {
|
|
85
|
-
data.lastModified = (await getGitTimestamp(filePath))?.getTime();
|
|
86
|
-
}
|
|
87
|
-
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
88
|
-
const compiled = await buildMDX(
|
|
89
|
-
`${getConfigHash(config)}:${parsed.collection ?? "global"}`,
|
|
90
|
-
"\n".repeat(lineOffset) + matter.content,
|
|
91
|
-
{
|
|
92
|
-
development: isDevelopment,
|
|
93
|
-
...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
|
|
94
|
-
postprocess: docCollection?.postprocess,
|
|
95
|
-
data,
|
|
96
|
-
filePath,
|
|
97
|
-
frontmatter: matter.data,
|
|
98
|
-
_compiler: compiler
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
const out = {
|
|
102
|
-
code: String(compiled.value),
|
|
103
|
-
map: compiled.map
|
|
104
|
-
};
|
|
105
|
-
await after?.();
|
|
106
|
-
return out;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
var hashes = /* @__PURE__ */ new WeakMap();
|
|
110
|
-
function getConfigHash(config) {
|
|
111
|
-
let hash = hashes.get(config);
|
|
112
|
-
if (hash) return hash;
|
|
113
|
-
hash = Date.now().toString();
|
|
114
|
-
hashes.set(config, hash);
|
|
115
|
-
return hash;
|
|
116
|
-
}
|
|
117
|
-
function generateCacheHash(input) {
|
|
118
|
-
return createHash("md5").update(input).digest("hex");
|
|
119
|
-
}
|
|
120
|
-
function countLines(s) {
|
|
121
|
-
let num = 0;
|
|
122
|
-
for (const c of s) {
|
|
123
|
-
if (c === "\n") num++;
|
|
124
|
-
}
|
|
125
|
-
return num;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export {
|
|
129
|
-
createMdxLoader
|
|
130
|
-
};
|
package/dist/chunk-YAIPHUCZ.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
validate
|
|
3
|
-
} from "./chunk-TZ5EQBFW.js";
|
|
4
|
-
|
|
5
|
-
// src/loaders/meta.ts
|
|
6
|
-
import { dump, load } from "js-yaml";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
var querySchema = z.object({
|
|
9
|
-
collection: z.string().optional()
|
|
10
|
-
}).loose();
|
|
11
|
-
function createMetaLoader(configLoader, resolve = {}) {
|
|
12
|
-
const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve;
|
|
13
|
-
return async ({ filePath, query, source }) => {
|
|
14
|
-
const isJson = filePath.endsWith(".json");
|
|
15
|
-
const parsed = querySchema.parse(query);
|
|
16
|
-
const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
|
|
17
|
-
if (!collection) return null;
|
|
18
|
-
let data;
|
|
19
|
-
try {
|
|
20
|
-
data = isJson ? JSON.parse(source) : load(source);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
23
|
-
}
|
|
24
|
-
let schema;
|
|
25
|
-
switch (collection?.type) {
|
|
26
|
-
case "meta":
|
|
27
|
-
schema = collection.schema;
|
|
28
|
-
break;
|
|
29
|
-
case "docs":
|
|
30
|
-
schema = collection.meta.schema;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
if (schema) {
|
|
34
|
-
data = await validate(
|
|
35
|
-
schema,
|
|
36
|
-
data,
|
|
37
|
-
{ path: filePath, source },
|
|
38
|
-
`invalid data in ${filePath}`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
let code;
|
|
42
|
-
if (isJson) {
|
|
43
|
-
code = resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
|
|
44
|
-
} else {
|
|
45
|
-
code = resolveYaml === "yaml" ? dump(data) : `export default ${JSON.stringify(data)}`;
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
code,
|
|
49
|
-
map: null
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
createMetaLoader
|
|
56
|
-
};
|