fumadocs-mdx 14.0.3 → 14.1.0
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 +9 -9
- package/dist/{chunk-KOPLIEVQ.js → chunk-7W73RILB.js} +2 -1
- package/dist/{chunk-LPX7ZO66.js → chunk-DTFUANSF.js} +1 -1
- package/dist/{chunk-Q5OSGLJL.js → chunk-K7N6GD4M.js} +1 -1
- package/dist/{chunk-6RPNS75C.js → chunk-OLD35ARB.js} +43 -31
- package/dist/{chunk-WBIHDYMN.js → chunk-PW2AZGGD.js} +3 -4
- package/dist/{chunk-USWQVJWR.js → chunk-T6G5VOED.js} +21 -12
- package/dist/{chunk-DKA3EWZH.js → chunk-VITVHHR6.js} +88 -84
- package/dist/{chunk-GB4W3YCZ.js → chunk-VKSHE52K.js} +85 -35
- package/dist/{chunk-OLL7FM7W.js → chunk-WAAWFNDX.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-X5ggQtBM.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 +253 -202
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +22 -37
- 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 +3 -3
- package/dist/plugins/last-modified.js +23 -15
- package/dist/runtime/browser.d.ts +2 -2
- package/dist/runtime/dynamic.d.ts +2 -2
- package/dist/runtime/dynamic.js +7 -7
- package/dist/runtime/server.d.ts +2 -2
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +19 -21
- 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 +13 -14
- 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 { C as CoreOptions } from '../core-
|
|
2
|
+
import { C as CoreOptions } from '../core-X5ggQtBM.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,24 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildConfig
|
|
3
|
+
} from "../chunk-OLD35ARB.js";
|
|
4
|
+
import "../chunk-S7KOJHHO.js";
|
|
1
5
|
import {
|
|
2
6
|
createMdxLoader
|
|
3
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-T6G5VOED.js";
|
|
4
8
|
import {
|
|
5
9
|
createMetaLoader
|
|
6
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-ZAYZWFWP.js";
|
|
7
11
|
import {
|
|
8
12
|
createIntegratedConfigLoader,
|
|
9
13
|
toBun
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import {
|
|
12
|
-
buildConfig
|
|
13
|
-
} from "../chunk-6RPNS75C.js";
|
|
14
|
+
} from "../chunk-WAAWFNDX.js";
|
|
14
15
|
import "../chunk-4JSFLXXT.js";
|
|
15
16
|
import {
|
|
16
17
|
_Defaults,
|
|
17
18
|
createCore
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-VKSHE52K.js";
|
|
20
|
+
import "../chunk-PW2AZGGD.js";
|
|
20
21
|
import "../chunk-VWJKRQZR.js";
|
|
21
|
-
import "../chunk-WBIHDYMN.js";
|
|
22
22
|
|
|
23
23
|
// src/bun/index.ts
|
|
24
24
|
import { pathToFileURL } from "url";
|
|
@@ -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) {
|
|
@@ -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);
|
|
@@ -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
|
}
|
|
@@ -12,14 +12,15 @@ import path from "path";
|
|
|
12
12
|
import { createHash } from "crypto";
|
|
13
13
|
var querySchema = z.object({
|
|
14
14
|
only: z.literal(["frontmatter", "all"]).default("all"),
|
|
15
|
-
collection: z.string().optional()
|
|
15
|
+
collection: z.string().optional(),
|
|
16
|
+
workspace: z.string().optional()
|
|
16
17
|
}).loose();
|
|
17
18
|
var cacheEntry = z.object({
|
|
18
19
|
code: z.string(),
|
|
19
20
|
map: z.any().optional(),
|
|
20
21
|
hash: z.string().optional()
|
|
21
22
|
});
|
|
22
|
-
function createMdxLoader(
|
|
23
|
+
function createMdxLoader({ getCore }) {
|
|
23
24
|
return {
|
|
24
25
|
test: mdxLoaderGlob,
|
|
25
26
|
async load({
|
|
@@ -29,14 +30,22 @@ function createMdxLoader(configLoader) {
|
|
|
29
30
|
compiler,
|
|
30
31
|
filePath
|
|
31
32
|
}) {
|
|
32
|
-
|
|
33
|
+
let core = await getCore();
|
|
33
34
|
const value = await getSource();
|
|
34
35
|
const matter = fumaMatter(value);
|
|
35
|
-
const
|
|
36
|
+
const {
|
|
37
|
+
collection: collectionName,
|
|
38
|
+
workspace,
|
|
39
|
+
only
|
|
40
|
+
} = querySchema.parse(query);
|
|
41
|
+
if (workspace) {
|
|
42
|
+
core = core.getWorkspaces().get(workspace) ?? core;
|
|
43
|
+
}
|
|
36
44
|
let after;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
45
|
+
const { experimentalBuildCache = false } = core.getConfig().global;
|
|
46
|
+
if (!isDevelopment && experimentalBuildCache) {
|
|
47
|
+
const cacheDir = experimentalBuildCache;
|
|
48
|
+
const cacheKey = `${collectionName ?? "global"}_${generateCacheHash(filePath)}`;
|
|
40
49
|
const cached = await fs.readFile(path.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
|
|
41
50
|
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
42
51
|
after = async () => {
|
|
@@ -50,7 +59,7 @@ function createMdxLoader(configLoader) {
|
|
|
50
59
|
);
|
|
51
60
|
};
|
|
52
61
|
}
|
|
53
|
-
const collection =
|
|
62
|
+
const collection = collectionName ? core.getCollection(collectionName) : void 0;
|
|
54
63
|
let docCollection;
|
|
55
64
|
switch (collection?.type) {
|
|
56
65
|
case "doc":
|
|
@@ -61,20 +70,20 @@ function createMdxLoader(configLoader) {
|
|
|
61
70
|
break;
|
|
62
71
|
}
|
|
63
72
|
if (docCollection) {
|
|
64
|
-
matter.data = await
|
|
73
|
+
matter.data = await core.transformFrontmatter(
|
|
65
74
|
{ collection: docCollection, filePath, source: value },
|
|
66
75
|
matter.data
|
|
67
76
|
);
|
|
68
77
|
}
|
|
69
|
-
if (
|
|
78
|
+
if (only === "frontmatter") {
|
|
70
79
|
return {
|
|
71
80
|
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
72
81
|
map: null
|
|
73
82
|
};
|
|
74
83
|
}
|
|
75
84
|
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
76
|
-
const { buildMDX } = await import("./build-mdx-
|
|
77
|
-
const compiled = await buildMDX(
|
|
85
|
+
const { buildMDX } = await import("./build-mdx-RXJZQXGA.js");
|
|
86
|
+
const compiled = await buildMDX(core, docCollection, {
|
|
78
87
|
isDevelopment,
|
|
79
88
|
source: "\n".repeat(lineOffset) + matter.content,
|
|
80
89
|
filePath,
|