fumadocs-mdx 14.0.4 → 14.1.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/{build-mdx-W3233QBZ.js → build-mdx-RXJZQXGA.js} +2 -2
- package/dist/bun/index.d.ts +2 -2
- package/dist/bun/index.js +6 -6
- package/dist/{chunk-CGGDM5F3.js → chunk-257RZJEQ.js} +1 -1
- package/dist/{chunk-WBIHDYMN.js → chunk-2PY3JUIC.js} +4 -4
- package/dist/{chunk-KOPLIEVQ.js → chunk-7W73RILB.js} +2 -1
- package/dist/{chunk-LPX7ZO66.js → chunk-DTFUANSF.js} +1 -1
- package/dist/{chunk-K4KWUM3J.js → chunk-KWSETXYC.js} +83 -34
- package/dist/{chunk-6RPNS75C.js → chunk-OLD35ARB.js} +43 -31
- package/dist/{chunk-ED3ON275.js → chunk-STLEUNK7.js} +87 -82
- package/dist/{chunk-USWQVJWR.js → chunk-T6G5VOED.js} +21 -12
- package/dist/{chunk-NKIL543T.js → chunk-WSQ23PNV.js} +18 -20
- package/dist/{chunk-FBLMK4RS.js → chunk-Y7ISNZ7X.js} +22 -16
- package/dist/{chunk-TYJDYTKH.js → chunk-ZAYZWFWP.js} +10 -6
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +6 -5
- package/dist/{core-C3QZSdEx.d.ts → core-nagEel33.d.ts} +50 -41
- package/dist/index-BqkSNsGO.d.ts +8 -0
- package/dist/index.d.ts +2 -2
- package/dist/{load-from-file-OZ5N7DXU.js → load-from-file-FHW724YY.js} +2 -2
- package/dist/next/index.cjs +251 -201
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +21 -36
- package/dist/node/loader.js +5 -5
- package/dist/plugins/index-file.d.ts +2 -2
- package/dist/plugins/index-file.js +2 -2
- package/dist/plugins/json-schema.d.ts +2 -2
- package/dist/plugins/json-schema.js +4 -7
- package/dist/plugins/last-modified.d.ts +2 -2
- package/dist/plugins/last-modified.js +20 -13
- package/dist/runtime/browser.d.ts +2 -2
- package/dist/runtime/dynamic.d.ts +2 -2
- package/dist/runtime/dynamic.js +6 -6
- package/dist/runtime/server.d.ts +2 -2
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +16 -18
- package/dist/webpack/mdx.d.ts +1 -15
- package/dist/webpack/mdx.js +5 -5
- package/dist/webpack/meta.d.ts +1 -15
- package/dist/webpack/meta.js +5 -5
- package/package.json +14 -15
- package/dist/index-DG1I0CwF.d.ts +0 -8
package/dist/bun/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BunPlugin } from 'bun';
|
|
2
|
-
import {
|
|
2
|
+
import { h as CoreOptions } from '../core-nagEel33.js';
|
|
3
3
|
import '@mdx-js/mdx';
|
|
4
4
|
import '@standard-schema/spec';
|
|
5
5
|
import 'unified';
|
|
6
6
|
import 'fumadocs-core/mdx-plugins';
|
|
7
|
-
import '
|
|
7
|
+
import 'fumadocs-core/source/schema';
|
|
8
8
|
import 'chokidar';
|
|
9
9
|
import 'vfile';
|
|
10
10
|
import 'fumadocs-core/source';
|
package/dist/bun/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildConfig
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-OLD35ARB.js";
|
|
4
4
|
import "../chunk-S7KOJHHO.js";
|
|
5
5
|
import {
|
|
6
6
|
createMdxLoader
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-T6G5VOED.js";
|
|
8
8
|
import {
|
|
9
9
|
createMetaLoader
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-ZAYZWFWP.js";
|
|
11
11
|
import {
|
|
12
12
|
createIntegratedConfigLoader,
|
|
13
13
|
toBun
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-WSQ23PNV.js";
|
|
15
15
|
import "../chunk-4JSFLXXT.js";
|
|
16
16
|
import {
|
|
17
17
|
_Defaults,
|
|
18
18
|
createCore
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-KWSETXYC.js";
|
|
20
|
+
import "../chunk-2PY3JUIC.js";
|
|
21
21
|
import "../chunk-VWJKRQZR.js";
|
|
22
22
|
|
|
23
23
|
// src/bun/index.ts
|
|
@@ -65,7 +65,7 @@ function createCodegen({
|
|
|
65
65
|
const fullPath = path.join(base, item);
|
|
66
66
|
const searchParams = new URLSearchParams();
|
|
67
67
|
for (const [k, v] of Object.entries(query)) {
|
|
68
|
-
searchParams.set(k, v);
|
|
68
|
+
if (v !== void 0) searchParams.set(k, v);
|
|
69
69
|
}
|
|
70
70
|
const importPath = this.formatImportPath(fullPath) + "?" + searchParams.toString();
|
|
71
71
|
if (eager) {
|
|
@@ -88,10 +88,9 @@ function createCodegen({
|
|
|
88
88
|
formatImportPath(file) {
|
|
89
89
|
const ext = path.extname(file);
|
|
90
90
|
let filename;
|
|
91
|
-
if (ext === ".ts"
|
|
92
|
-
filename = file.substring(0, file.length - ext.length) + ".js";
|
|
93
|
-
} else if (ext === ".ts") {
|
|
91
|
+
if (ext === ".ts") {
|
|
94
92
|
filename = file.substring(0, file.length - ext.length);
|
|
93
|
+
if (jsExtension) filename += ".js";
|
|
95
94
|
} else {
|
|
96
95
|
filename = file;
|
|
97
96
|
}
|
|
@@ -122,5 +121,6 @@ function ident(code, tab = 1) {
|
|
|
122
121
|
|
|
123
122
|
export {
|
|
124
123
|
createCodegen,
|
|
124
|
+
slash,
|
|
125
125
|
ident
|
|
126
126
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
flattenNode,
|
|
3
3
|
remarkInclude
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Y7ISNZ7X.js";
|
|
5
5
|
|
|
6
6
|
// src/loaders/mdx/build-mdx.ts
|
|
7
7
|
import { createProcessor } from "@mdx-js/mdx";
|
|
@@ -159,6 +159,7 @@ async function buildMDX(core, collection, {
|
|
|
159
159
|
let vfile = new VFile({
|
|
160
160
|
value: source,
|
|
161
161
|
path: filePath,
|
|
162
|
+
cwd: collection?.cwd,
|
|
162
163
|
data: { frontmatter, _compiler, _getProcessor: getProcessor }
|
|
163
164
|
});
|
|
164
165
|
if (collection) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ident
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2PY3JUIC.js";
|
|
4
4
|
|
|
5
5
|
// src/utils/validation.ts
|
|
6
6
|
var ValidationError = class extends Error {
|
|
@@ -57,9 +57,10 @@ async function getPlugins(pluginOptions) {
|
|
|
57
57
|
}
|
|
58
58
|
return plugins;
|
|
59
59
|
}
|
|
60
|
-
function createCore(options
|
|
60
|
+
function createCore(options) {
|
|
61
61
|
let config;
|
|
62
62
|
let plugins;
|
|
63
|
+
const workspaces = /* @__PURE__ */ new Map();
|
|
63
64
|
async function transformMetadata({
|
|
64
65
|
collection,
|
|
65
66
|
filePath,
|
|
@@ -75,7 +76,7 @@ function createCore(options, defaultPlugins = []) {
|
|
|
75
76
|
}
|
|
76
77
|
return data;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
return {
|
|
79
80
|
/**
|
|
80
81
|
* Convenient cache store, reset when config changes
|
|
81
82
|
*/
|
|
@@ -83,15 +84,36 @@ function createCore(options, defaultPlugins = []) {
|
|
|
83
84
|
async init({ config: newConfig }) {
|
|
84
85
|
config = await newConfig;
|
|
85
86
|
this.cache.clear();
|
|
87
|
+
workspaces.clear();
|
|
86
88
|
plugins = await getPlugins([
|
|
87
89
|
postprocessPlugin(),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
options.plugins,
|
|
91
|
+
config.global.plugins
|
|
90
92
|
]);
|
|
91
93
|
for (const plugin of plugins) {
|
|
92
|
-
const out = await plugin.config?.call(
|
|
94
|
+
const out = await plugin.config?.call(this.getPluginContext(), config);
|
|
93
95
|
if (out) config = out;
|
|
94
96
|
}
|
|
97
|
+
if (!options.workspace) {
|
|
98
|
+
await Promise.all(
|
|
99
|
+
Object.entries(config.workspaces).map(async ([name, workspace]) => {
|
|
100
|
+
const core = createCore({
|
|
101
|
+
...options,
|
|
102
|
+
outDir: path.join(options.outDir, name),
|
|
103
|
+
workspace: {
|
|
104
|
+
name,
|
|
105
|
+
parent: this,
|
|
106
|
+
dir: workspace.dir
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
await core.init({ config: workspace.config });
|
|
110
|
+
workspaces.set(name, core);
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
getWorkspaces() {
|
|
116
|
+
return workspaces;
|
|
95
117
|
},
|
|
96
118
|
getOptions() {
|
|
97
119
|
return options;
|
|
@@ -108,37 +130,69 @@ function createCore(options, defaultPlugins = []) {
|
|
|
108
130
|
getPlugins() {
|
|
109
131
|
return plugins;
|
|
110
132
|
},
|
|
133
|
+
getCollections() {
|
|
134
|
+
return Array.from(config.collections.values());
|
|
135
|
+
},
|
|
136
|
+
getCollection(name) {
|
|
137
|
+
return config.collections.get(name);
|
|
138
|
+
},
|
|
111
139
|
getPluginContext() {
|
|
112
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
core: this
|
|
142
|
+
};
|
|
113
143
|
},
|
|
114
144
|
async initServer(server) {
|
|
145
|
+
const ctx = this.getPluginContext();
|
|
115
146
|
for (const plugin of plugins) {
|
|
116
|
-
await plugin.configureServer?.call(
|
|
147
|
+
await plugin.configureServer?.call(ctx, server);
|
|
148
|
+
}
|
|
149
|
+
for (const workspace of workspaces.values()) {
|
|
150
|
+
await workspace.initServer(server);
|
|
117
151
|
}
|
|
118
152
|
},
|
|
119
|
-
async emit(
|
|
120
|
-
|
|
121
|
-
plugins.map((plugin) => {
|
|
122
|
-
if (!filterPlugin(plugin) || !plugin.emit) return [];
|
|
123
|
-
return plugin.emit.call(pluginContext);
|
|
124
|
-
})
|
|
125
|
-
)).flat();
|
|
126
|
-
},
|
|
127
|
-
async emitAndWrite(emitOptions) {
|
|
153
|
+
async emit(emitOptions = {}) {
|
|
154
|
+
const { filterPlugin, filterWorkspace, write = false } = emitOptions;
|
|
128
155
|
const start = performance.now();
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
156
|
+
const ctx = this.getPluginContext();
|
|
157
|
+
const added = /* @__PURE__ */ new Set();
|
|
158
|
+
const out = {
|
|
159
|
+
entries: [],
|
|
160
|
+
workspaces: {}
|
|
161
|
+
};
|
|
162
|
+
for (const li of await Promise.all(
|
|
163
|
+
plugins.map((plugin) => {
|
|
164
|
+
if (filterPlugin && !filterPlugin(plugin) || !plugin.emit) return;
|
|
165
|
+
return plugin.emit.call(ctx);
|
|
135
166
|
})
|
|
136
|
-
)
|
|
137
|
-
|
|
167
|
+
)) {
|
|
168
|
+
if (!li) continue;
|
|
169
|
+
for (const item of li) {
|
|
170
|
+
if (added.has(item.path)) continue;
|
|
171
|
+
out.entries.push(item);
|
|
172
|
+
added.add(item.path);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (write) {
|
|
176
|
+
await Promise.all(
|
|
177
|
+
out.entries.map(async (entry) => {
|
|
178
|
+
const file = path.join(options.outDir, entry.path);
|
|
179
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
180
|
+
await fs.writeFile(file, entry.content);
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
console.log(
|
|
184
|
+
options.workspace ? `[MDX: ${options.workspace.name}] generated files in ${performance.now() - start}ms` : `[MDX] generated files in ${performance.now() - start}ms`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
for (const [name, workspace] of workspaces) {
|
|
188
|
+
if (filterWorkspace && !filterWorkspace(name)) continue;
|
|
189
|
+
out.workspaces[name] = (await workspace.emit(emitOptions)).entries;
|
|
190
|
+
}
|
|
191
|
+
return out;
|
|
138
192
|
},
|
|
139
193
|
async transformMeta(options2, data) {
|
|
140
194
|
const ctx = {
|
|
141
|
-
...
|
|
195
|
+
...this.getPluginContext(),
|
|
142
196
|
...options2
|
|
143
197
|
};
|
|
144
198
|
data = await transformMetadata(options2, data);
|
|
@@ -150,7 +204,7 @@ function createCore(options, defaultPlugins = []) {
|
|
|
150
204
|
},
|
|
151
205
|
async transformFrontmatter(options2, data) {
|
|
152
206
|
const ctx = {
|
|
153
|
-
...
|
|
207
|
+
...this.getPluginContext(),
|
|
154
208
|
...options2
|
|
155
209
|
};
|
|
156
210
|
data = await transformMetadata(options2, data);
|
|
@@ -162,7 +216,7 @@ function createCore(options, defaultPlugins = []) {
|
|
|
162
216
|
},
|
|
163
217
|
async transformVFile(options2, file) {
|
|
164
218
|
const ctx = {
|
|
165
|
-
...
|
|
219
|
+
...this.getPluginContext(),
|
|
166
220
|
...options2
|
|
167
221
|
};
|
|
168
222
|
for (const plugin of plugins) {
|
|
@@ -172,11 +226,6 @@ function createCore(options, defaultPlugins = []) {
|
|
|
172
226
|
return file;
|
|
173
227
|
}
|
|
174
228
|
};
|
|
175
|
-
const pluginContext = {
|
|
176
|
-
core,
|
|
177
|
-
...options
|
|
178
|
-
};
|
|
179
|
-
return core;
|
|
180
229
|
}
|
|
181
230
|
function postprocessPlugin() {
|
|
182
231
|
const LinkReferenceTypes = `{
|
|
@@ -191,7 +240,7 @@ function postprocessPlugin() {
|
|
|
191
240
|
const lines = [];
|
|
192
241
|
lines.push("{");
|
|
193
242
|
lines.push(" DocData: {");
|
|
194
|
-
for (const collection of this.core.
|
|
243
|
+
for (const collection of this.core.getCollections()) {
|
|
195
244
|
let postprocessOptions;
|
|
196
245
|
switch (collection.type) {
|
|
197
246
|
case "doc":
|
|
@@ -4,46 +4,57 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/config/build.ts
|
|
6
6
|
import picomatch from "picomatch";
|
|
7
|
+
import path from "path";
|
|
7
8
|
var SupportedFormats = {
|
|
8
9
|
doc: ["mdx", "md"],
|
|
9
10
|
meta: ["json", "yaml"]
|
|
10
11
|
};
|
|
11
|
-
function buildCollection(name,
|
|
12
|
-
if (
|
|
12
|
+
function buildCollection(name, collection, cwd) {
|
|
13
|
+
if (collection.type === "docs") {
|
|
13
14
|
return {
|
|
14
|
-
...
|
|
15
|
+
...collection,
|
|
16
|
+
type: "docs",
|
|
17
|
+
get dir() {
|
|
18
|
+
return this.docs.dir;
|
|
19
|
+
},
|
|
15
20
|
name,
|
|
16
|
-
meta:
|
|
17
|
-
docs:
|
|
21
|
+
meta: buildCollection(name, collection.meta, cwd),
|
|
22
|
+
docs: buildCollection(name, collection.docs, cwd),
|
|
18
23
|
hasFile(filePath) {
|
|
19
24
|
return this.docs.hasFile(filePath) || this.meta.hasFile(filePath);
|
|
20
|
-
}
|
|
25
|
+
},
|
|
26
|
+
isFileSupported(filePath) {
|
|
27
|
+
return this.docs.isFileSupported(filePath) || this.meta.isFileSupported(filePath);
|
|
28
|
+
},
|
|
29
|
+
cwd
|
|
21
30
|
};
|
|
22
31
|
}
|
|
23
|
-
return
|
|
32
|
+
return {
|
|
33
|
+
...collection,
|
|
34
|
+
...buildPrimitiveCollection(name, collection, cwd)
|
|
35
|
+
};
|
|
24
36
|
}
|
|
25
|
-
function buildPrimitiveCollection(name,
|
|
37
|
+
function buildPrimitiveCollection(name, config, cwd) {
|
|
26
38
|
const supportedFormats = SupportedFormats[config.type];
|
|
27
|
-
const patterns = files ?? [`**/*.{${supportedFormats.join(",")}}`];
|
|
28
|
-
let
|
|
39
|
+
const patterns = config.files ?? [`**/*.{${supportedFormats.join(",")}}`];
|
|
40
|
+
let matcher;
|
|
29
41
|
return {
|
|
30
|
-
|
|
42
|
+
dir: path.resolve(cwd, config.dir),
|
|
43
|
+
cwd,
|
|
31
44
|
name,
|
|
32
45
|
patterns,
|
|
33
46
|
isFileSupported(filePath) {
|
|
34
47
|
return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
|
|
35
48
|
},
|
|
36
49
|
hasFile(filePath) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
return this.isFileSupported(filePath) && matchers.some((matcher) => matcher(filePath));
|
|
50
|
+
if (!this.isFileSupported(filePath)) return false;
|
|
51
|
+
const relativePath = path.relative(this.dir, filePath);
|
|
52
|
+
if (relativePath.startsWith(`..${path.sep}`)) return false;
|
|
53
|
+
return (matcher ??= picomatch(patterns))(relativePath);
|
|
43
54
|
}
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
|
-
function buildConfig(config) {
|
|
57
|
+
function buildConfig(config, cwd = process.cwd()) {
|
|
47
58
|
const collections = /* @__PURE__ */ new Map();
|
|
48
59
|
const loaded = {};
|
|
49
60
|
for (const [k, v] of Object.entries(config)) {
|
|
@@ -51,15 +62,8 @@ function buildConfig(config) {
|
|
|
51
62
|
continue;
|
|
52
63
|
}
|
|
53
64
|
if (typeof v === "object" && "type" in v) {
|
|
54
|
-
if (v.type === "docs") {
|
|
55
|
-
collections.set(k, buildCollection(k, v));
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (v.type === "doc" || v.type === "meta") {
|
|
59
|
-
collections.set(
|
|
60
|
-
k,
|
|
61
|
-
buildCollection(k, v)
|
|
62
|
-
);
|
|
65
|
+
if (v.type === "docs" || v.type === "doc" || v.type === "meta") {
|
|
66
|
+
collections.set(k, buildCollection(k, v, cwd));
|
|
63
67
|
continue;
|
|
64
68
|
}
|
|
65
69
|
}
|
|
@@ -74,10 +78,18 @@ function buildConfig(config) {
|
|
|
74
78
|
const mdxOptionsCache = /* @__PURE__ */ new Map();
|
|
75
79
|
return {
|
|
76
80
|
global: loaded,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
collections,
|
|
82
|
+
workspaces: Object.fromEntries(
|
|
83
|
+
Object.entries(loaded.workspaces ?? {}).map(([key, value]) => {
|
|
84
|
+
return [
|
|
85
|
+
key,
|
|
86
|
+
{
|
|
87
|
+
dir: value.dir,
|
|
88
|
+
config: buildConfig(value.config, path.resolve(cwd, value.dir))
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
})
|
|
92
|
+
),
|
|
81
93
|
getMDXOptions(collection, environment = "bundler") {
|
|
82
94
|
const key = collection ? `${environment}:${collection.name}` : environment;
|
|
83
95
|
const cached = mdxOptionsCache.get(key);
|