fumadocs-mdx 11.6.0 → 13.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 +1728 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +16 -0
- package/dist/build-mdx-CCNr86q6.d.ts +53 -0
- package/dist/build-mdx-D-r3_eQL.d.cts +53 -0
- package/dist/bun/index.cjs +857 -0
- package/dist/bun/index.d.cts +13 -0
- package/dist/bun/index.d.ts +13 -0
- package/dist/bun/index.js +62 -0
- package/dist/chunk-3J3WL7WN.js +160 -0
- package/dist/chunk-CXA4JO4Z.js +45 -0
- package/dist/chunk-EELYB2XC.js +207 -0
- package/dist/chunk-FSZMKRVH.js +80 -0
- package/dist/chunk-II3H5ZVZ.js +77 -0
- package/dist/chunk-JVZFH6ND.js +40 -0
- package/dist/chunk-K5ZLPEIQ.js +207 -0
- package/dist/{chunk-VFALQK6O.js → chunk-KILFIBVW.js} +21 -12
- package/dist/chunk-NVRDCY6Z.js +30 -0
- package/dist/chunk-U4MQ44TS.js +53 -0
- package/dist/chunk-VWJKRQZR.js +19 -0
- package/dist/chunk-XQ5O7IPO.js +128 -0
- package/dist/chunk-XZY2AWJI.js +81 -0
- package/dist/chunk-YVCR6FUH.js +82 -0
- package/dist/config/index.cjs +232 -128
- package/dist/config/index.d.cts +4 -6
- package/dist/config/index.d.ts +4 -6
- package/dist/config/index.js +26 -19
- package/dist/core-B6j6Fxse.d.cts +218 -0
- package/dist/core-B6j6Fxse.d.ts +218 -0
- package/dist/index.cjs +0 -76
- package/dist/index.d.cts +73 -20
- package/dist/index.d.ts +73 -20
- package/dist/index.js +0 -10
- package/dist/load-MNG3CLET.js +7 -0
- package/dist/next/index.cjs +567 -314
- package/dist/next/index.d.cts +9 -12
- package/dist/next/index.d.ts +9 -12
- package/dist/next/index.js +238 -211
- package/dist/node/loader.cjs +922 -0
- package/dist/node/loader.d.cts +5 -0
- package/dist/node/loader.d.ts +5 -0
- package/dist/node/loader.js +33 -0
- package/dist/plugins/json-schema.cjs +162 -0
- package/dist/plugins/json-schema.d.cts +24 -0
- package/dist/plugins/json-schema.d.ts +24 -0
- package/dist/plugins/json-schema.js +78 -0
- package/dist/{mdx-options-CAU273O3.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +715 -0
- package/dist/runtime/next/async.d.cts +21 -0
- package/dist/runtime/next/async.d.ts +21 -0
- package/dist/runtime/next/async.js +89 -0
- package/dist/runtime/next/index.cjs +136 -0
- package/dist/runtime/next/index.d.cts +33 -0
- package/dist/runtime/next/index.d.ts +33 -0
- package/dist/runtime/next/index.js +11 -0
- package/dist/runtime/vite/browser.cjs +107 -0
- package/dist/runtime/vite/browser.d.cts +59 -0
- package/dist/runtime/vite/browser.d.ts +59 -0
- package/dist/runtime/vite/browser.js +11 -0
- package/dist/runtime/vite/server.cjs +243 -0
- package/dist/runtime/vite/server.d.cts +30 -0
- package/dist/runtime/vite/server.d.ts +30 -0
- package/dist/runtime/vite/server.js +111 -0
- package/dist/types-AGzTfBmf.d.ts +45 -0
- package/dist/types-DKGMoay5.d.cts +45 -0
- package/dist/vite/index.cjs +1185 -0
- package/dist/vite/index.d.cts +45 -0
- package/dist/vite/index.d.ts +45 -0
- package/dist/vite/index.js +297 -0
- package/dist/webpack/index.cjs +957 -0
- package/dist/{loader-mdx.d.cts → webpack/index.d.cts} +3 -6
- package/dist/{loader-mdx.d.ts → webpack/index.d.ts} +3 -6
- package/dist/webpack/index.js +44 -0
- package/loader-mdx.cjs +1 -1
- package/package.json +86 -29
- package/bin.js +0 -5
- package/dist/chunk-2ZOW45YZ.js +0 -63
- package/dist/chunk-DRVUBK5B.js +0 -39
- package/dist/chunk-HFLDWPJA.js +0 -62
- package/dist/chunk-IOENRFUX.js +0 -112
- package/dist/chunk-MK7EXW7O.js +0 -75
- package/dist/define-BaW0PQDJ.d.cts +0 -201
- package/dist/define-BaW0PQDJ.d.ts +0 -201
- package/dist/loader-mdx.cjs +0 -527
- package/dist/loader-mdx.js +0 -162
- package/dist/runtime/async.cjs +0 -269
- package/dist/runtime/async.d.cts +0 -18
- package/dist/runtime/async.d.ts +0 -18
- package/dist/runtime/async.js +0 -73
- package/dist/types-BNrQHCj5.d.cts +0 -100
- package/dist/types-DEduCvIT.d.ts +0 -100
- package/dist/watcher-IAZDSTU7.js +0 -24
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toNode
|
|
3
|
+
} from "../chunk-YVCR6FUH.js";
|
|
4
|
+
import {
|
|
5
|
+
createMdxLoader
|
|
6
|
+
} from "../chunk-XQ5O7IPO.js";
|
|
7
|
+
import "../chunk-3J3WL7WN.js";
|
|
8
|
+
import "../chunk-K5ZLPEIQ.js";
|
|
9
|
+
import {
|
|
10
|
+
createCore,
|
|
11
|
+
findConfigFile,
|
|
12
|
+
staticConfig
|
|
13
|
+
} from "../chunk-EELYB2XC.js";
|
|
14
|
+
import "../chunk-VWJKRQZR.js";
|
|
15
|
+
|
|
16
|
+
// src/node/loader.ts
|
|
17
|
+
var core = createCore({
|
|
18
|
+
environment: "node",
|
|
19
|
+
configPath: findConfigFile(),
|
|
20
|
+
outDir: ".source"
|
|
21
|
+
});
|
|
22
|
+
var load = toNode(
|
|
23
|
+
createMdxLoader(
|
|
24
|
+
staticConfig({
|
|
25
|
+
core,
|
|
26
|
+
buildConfig: true
|
|
27
|
+
})
|
|
28
|
+
),
|
|
29
|
+
(filePath) => filePath.endsWith(".md") || filePath.endsWith(".mdx")
|
|
30
|
+
);
|
|
31
|
+
export {
|
|
32
|
+
load
|
|
33
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/plugins/json-schema.ts
|
|
31
|
+
var json_schema_exports = {};
|
|
32
|
+
__export(json_schema_exports, {
|
|
33
|
+
default: () => jsonSchema
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(json_schema_exports);
|
|
36
|
+
var import_zod = require("zod");
|
|
37
|
+
|
|
38
|
+
// src/utils/collections.ts
|
|
39
|
+
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
40
|
+
var import_tinyglobby = require("tinyglobby");
|
|
41
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
42
|
+
var SupportedFormats = {
|
|
43
|
+
doc: ["mdx", "md"],
|
|
44
|
+
meta: ["json", "yaml"]
|
|
45
|
+
};
|
|
46
|
+
function getGlobPatterns(collection) {
|
|
47
|
+
if (collection.files) return collection.files;
|
|
48
|
+
return [`**/*.{${SupportedFormats[collection.type].join(",")}}`];
|
|
49
|
+
}
|
|
50
|
+
function isFileSupported(filePath, collection) {
|
|
51
|
+
return SupportedFormats[collection.type].some(
|
|
52
|
+
(format) => filePath.endsWith(`.${format}`)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function createCollectionMatcher(core) {
|
|
56
|
+
const CacheKey = "collection-matcher";
|
|
57
|
+
return {
|
|
58
|
+
scan(config) {
|
|
59
|
+
const scanned = [];
|
|
60
|
+
function scan(name, collection) {
|
|
61
|
+
const patterns = getGlobPatterns(collection);
|
|
62
|
+
for (const dir of Array.isArray(collection.dir) ? collection.dir : [collection.dir]) {
|
|
63
|
+
scanned.push({
|
|
64
|
+
name,
|
|
65
|
+
collection,
|
|
66
|
+
matcher: (0, import_picomatch.default)(patterns, {
|
|
67
|
+
cwd: dir
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const [name, collection] of config.collections) {
|
|
73
|
+
if (collection.type === "docs") {
|
|
74
|
+
scan(name, collection.meta);
|
|
75
|
+
scan(name, collection.docs);
|
|
76
|
+
} else {
|
|
77
|
+
scan(name, collection);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return scanned;
|
|
81
|
+
},
|
|
82
|
+
getFileCollection(file) {
|
|
83
|
+
const scanned = core.cache.get(CacheKey) ?? this.scan(core.getConfig());
|
|
84
|
+
core.cache.set(CacheKey, scanned);
|
|
85
|
+
for (const item of scanned) {
|
|
86
|
+
if (isFileSupported(file, item.collection) && item.matcher(file))
|
|
87
|
+
return { name: item.name, collection: item.collection };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/plugins/json-schema.ts
|
|
94
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
95
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
96
|
+
function jsonSchema({
|
|
97
|
+
insert = false
|
|
98
|
+
} = {}) {
|
|
99
|
+
let config;
|
|
100
|
+
function getSchemaPath(name) {
|
|
101
|
+
return `json-schema/${name}.json`;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
config(v) {
|
|
105
|
+
config = v;
|
|
106
|
+
},
|
|
107
|
+
configureServer(server) {
|
|
108
|
+
if (!server.watcher || !insert) return;
|
|
109
|
+
const matcher = createCollectionMatcher(this.core);
|
|
110
|
+
server.watcher.on("add", async (file) => {
|
|
111
|
+
const match = matcher.getFileCollection(file);
|
|
112
|
+
if (!match || match.collection.type !== "meta") return;
|
|
113
|
+
const { name } = match;
|
|
114
|
+
const parent = config.collections.get(name);
|
|
115
|
+
let obj;
|
|
116
|
+
try {
|
|
117
|
+
const content = (await import_promises.default.readFile(file)).toString();
|
|
118
|
+
obj = content.length > 0 ? JSON.parse(content) : {};
|
|
119
|
+
} catch {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if ("$schema" in obj) return;
|
|
123
|
+
const schemaPath = import_node_path2.default.join(
|
|
124
|
+
this.outDir,
|
|
125
|
+
getSchemaPath(parent?.type === "docs" ? `${name}.meta` : name)
|
|
126
|
+
);
|
|
127
|
+
const updated = {
|
|
128
|
+
$schema: import_node_path2.default.relative(import_node_path2.default.dirname(file), schemaPath),
|
|
129
|
+
...obj
|
|
130
|
+
};
|
|
131
|
+
await import_promises.default.writeFile(file, JSON.stringify(updated, null, 2));
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
emit() {
|
|
135
|
+
const files = [];
|
|
136
|
+
function onSchema(name, schema) {
|
|
137
|
+
files.push({
|
|
138
|
+
path: getSchemaPath(name),
|
|
139
|
+
content: JSON.stringify(
|
|
140
|
+
import_zod.z.toJSONSchema(schema, {
|
|
141
|
+
io: "input",
|
|
142
|
+
unrepresentable: "any"
|
|
143
|
+
})
|
|
144
|
+
)
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
for (const [name, collection] of config.collections) {
|
|
148
|
+
if (collection.type === "docs") {
|
|
149
|
+
if (collection.meta.schema instanceof import_zod.z.ZodType) {
|
|
150
|
+
onSchema(`${name}.meta`, collection.meta.schema);
|
|
151
|
+
}
|
|
152
|
+
if (collection.docs.schema instanceof import_zod.z.ZodType) {
|
|
153
|
+
onSchema(`${name}.docs`, collection.docs.schema);
|
|
154
|
+
}
|
|
155
|
+
} else if (collection.schema instanceof import_zod.z.ZodType) {
|
|
156
|
+
onSchema(name, collection.schema);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return files;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { i as Plugin } from '../core-B6j6Fxse.cjs';
|
|
2
|
+
import '@standard-schema/spec';
|
|
3
|
+
import 'fumadocs-core/mdx-plugins';
|
|
4
|
+
import '@mdx-js/mdx';
|
|
5
|
+
import 'unified';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import 'chokidar';
|
|
8
|
+
|
|
9
|
+
interface JSONSchemaOptions {
|
|
10
|
+
/**
|
|
11
|
+
* insert `$schema` field to JSON files on creation.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue false
|
|
14
|
+
*/
|
|
15
|
+
insert?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate JSON schemas locally for collection schemas
|
|
19
|
+
*
|
|
20
|
+
* note: **it only works with Zod**
|
|
21
|
+
*/
|
|
22
|
+
declare function jsonSchema({ insert, }?: JSONSchemaOptions): Plugin;
|
|
23
|
+
|
|
24
|
+
export { type JSONSchemaOptions, jsonSchema as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { i as Plugin } from '../core-B6j6Fxse.js';
|
|
2
|
+
import '@standard-schema/spec';
|
|
3
|
+
import 'fumadocs-core/mdx-plugins';
|
|
4
|
+
import '@mdx-js/mdx';
|
|
5
|
+
import 'unified';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import 'chokidar';
|
|
8
|
+
|
|
9
|
+
interface JSONSchemaOptions {
|
|
10
|
+
/**
|
|
11
|
+
* insert `$schema` field to JSON files on creation.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue false
|
|
14
|
+
*/
|
|
15
|
+
insert?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate JSON schemas locally for collection schemas
|
|
19
|
+
*
|
|
20
|
+
* note: **it only works with Zod**
|
|
21
|
+
*/
|
|
22
|
+
declare function jsonSchema({ insert, }?: JSONSchemaOptions): Plugin;
|
|
23
|
+
|
|
24
|
+
export { type JSONSchemaOptions, jsonSchema as default };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCollectionMatcher
|
|
3
|
+
} from "../chunk-XZY2AWJI.js";
|
|
4
|
+
|
|
5
|
+
// src/plugins/json-schema.ts
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import fs from "fs/promises";
|
|
8
|
+
import path from "path";
|
|
9
|
+
function jsonSchema({
|
|
10
|
+
insert = false
|
|
11
|
+
} = {}) {
|
|
12
|
+
let config;
|
|
13
|
+
function getSchemaPath(name) {
|
|
14
|
+
return `json-schema/${name}.json`;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
config(v) {
|
|
18
|
+
config = v;
|
|
19
|
+
},
|
|
20
|
+
configureServer(server) {
|
|
21
|
+
if (!server.watcher || !insert) return;
|
|
22
|
+
const matcher = createCollectionMatcher(this.core);
|
|
23
|
+
server.watcher.on("add", async (file) => {
|
|
24
|
+
const match = matcher.getFileCollection(file);
|
|
25
|
+
if (!match || match.collection.type !== "meta") return;
|
|
26
|
+
const { name } = match;
|
|
27
|
+
const parent = config.collections.get(name);
|
|
28
|
+
let obj;
|
|
29
|
+
try {
|
|
30
|
+
const content = (await fs.readFile(file)).toString();
|
|
31
|
+
obj = content.length > 0 ? JSON.parse(content) : {};
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if ("$schema" in obj) return;
|
|
36
|
+
const schemaPath = path.join(
|
|
37
|
+
this.outDir,
|
|
38
|
+
getSchemaPath(parent?.type === "docs" ? `${name}.meta` : name)
|
|
39
|
+
);
|
|
40
|
+
const updated = {
|
|
41
|
+
$schema: path.relative(path.dirname(file), schemaPath),
|
|
42
|
+
...obj
|
|
43
|
+
};
|
|
44
|
+
await fs.writeFile(file, JSON.stringify(updated, null, 2));
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
emit() {
|
|
48
|
+
const files = [];
|
|
49
|
+
function onSchema(name, schema) {
|
|
50
|
+
files.push({
|
|
51
|
+
path: getSchemaPath(name),
|
|
52
|
+
content: JSON.stringify(
|
|
53
|
+
z.toJSONSchema(schema, {
|
|
54
|
+
io: "input",
|
|
55
|
+
unrepresentable: "any"
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
for (const [name, collection] of config.collections) {
|
|
61
|
+
if (collection.type === "docs") {
|
|
62
|
+
if (collection.meta.schema instanceof z.ZodType) {
|
|
63
|
+
onSchema(`${name}.meta`, collection.meta.schema);
|
|
64
|
+
}
|
|
65
|
+
if (collection.docs.schema instanceof z.ZodType) {
|
|
66
|
+
onSchema(`${name}.docs`, collection.docs.schema);
|
|
67
|
+
}
|
|
68
|
+
} else if (collection.schema instanceof z.ZodType) {
|
|
69
|
+
onSchema(name, collection.schema);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return files;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
jsonSchema as default
|
|
78
|
+
};
|