fumadocs-mdx 11.5.4 → 11.5.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.
@@ -1,22 +1,21 @@
1
1
  import {
2
2
  buildConfig
3
- } from "./chunk-6ZVE73IT.js";
3
+ } from "./chunk-SLCPEEMF.js";
4
4
 
5
5
  // src/utils/config.ts
6
- import { createHash } from "node:crypto";
7
- import * as fs from "node:fs";
6
+ import * as fs from "node:fs/promises";
8
7
  import * as path from "node:path";
9
8
  import { pathToFileURL } from "node:url";
10
9
  function findConfigFile() {
11
10
  return path.resolve("source.config.ts");
12
11
  }
13
12
  var cache = null;
14
- async function compileConfig(configPath) {
13
+ async function compileConfig(configPath, outDir) {
15
14
  const { build } = await import("esbuild");
16
15
  const transformed = await build({
17
16
  entryPoints: [{ in: configPath, out: "source.config" }],
18
17
  bundle: true,
19
- outdir: ".source",
18
+ outdir: outDir,
20
19
  target: "node18",
21
20
  write: true,
22
21
  platform: "node",
@@ -35,9 +34,9 @@ async function loadConfig(configPath, hash, build = false) {
35
34
  if (cache && cache.hash === hash) {
36
35
  return await cache.config;
37
36
  }
38
- if (build) await compileConfig(configPath);
37
+ if (build) await compileConfig(configPath, ".source");
39
38
  const url = pathToFileURL(path.resolve(".source/source.config.mjs"));
40
- const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
39
+ const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
41
40
  const [err, config2] = buildConfig(
42
41
  // every call to `loadConfig` will cause the previous cache to be ignored
43
42
  loaded
@@ -49,12 +48,11 @@ async function loadConfig(configPath, hash, build = false) {
49
48
  return await config;
50
49
  }
51
50
  async function getConfigHash(configPath) {
52
- const hash = createHash("md5");
53
- const rs = fs.createReadStream(configPath);
54
- for await (const chunk of rs) {
55
- hash.update(chunk);
51
+ const stats = await fs.stat(configPath).catch(() => void 0);
52
+ if (stats) {
53
+ return stats.mtime.getTime().toString();
56
54
  }
57
- return hash.digest("hex");
55
+ throw new Error("Cannot find config file");
58
56
  }
59
57
 
60
58
  export {
@@ -25,23 +25,11 @@ function buildConfig(config) {
25
25
  null
26
26
  ];
27
27
  }
28
- let cachedMdxOptions;
29
28
  return [
30
29
  null,
31
30
  {
32
31
  global: globalConfig,
33
32
  collections,
34
- async getDefaultMDXOptions() {
35
- if (cachedMdxOptions) return cachedMdxOptions;
36
- const { getDefaultMDXOptions } = await import("./mdx-options-CAU273O3.js");
37
- const mdxOptions = globalConfig?.mdxOptions ?? {};
38
- if (typeof mdxOptions === "function") {
39
- cachedMdxOptions = getDefaultMDXOptions(await mdxOptions());
40
- } else {
41
- cachedMdxOptions = getDefaultMDXOptions(mdxOptions);
42
- }
43
- return cachedMdxOptions;
44
- },
45
33
  _runtime: {
46
34
  files: /* @__PURE__ */ new Map()
47
35
  }
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
2
  import { B as BaseCollectionEntry } from './define-DxwgTgV6.cjs';
3
- import { R as Runtime } from './types-8ecOBKxa.cjs';
4
- export { a as RuntimeFile } from './types-8ecOBKxa.cjs';
3
+ import { R as Runtime } from './types-BIA23Xld.cjs';
4
+ export { a as RuntimeFile } from './types-BIA23Xld.cjs';
5
5
  import '@mdx-js/mdx';
6
6
  import 'mdx/types';
7
7
  import 'fumadocs-core/mdx-plugins';
@@ -10,6 +10,7 @@ import 'unified';
10
10
  import 'react';
11
11
  import 'zod';
12
12
  import '@standard-schema/spec';
13
+ import '@fumadocs/mdx-remote';
13
14
 
14
15
  declare const _runtime: Runtime;
15
16
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
2
  import { B as BaseCollectionEntry } from './define-DxwgTgV6.js';
3
- import { R as Runtime } from './types-BQ1vyPw8.js';
4
- export { a as RuntimeFile } from './types-BQ1vyPw8.js';
3
+ import { R as Runtime } from './types-2R3kLFSi.js';
4
+ export { a as RuntimeFile } from './types-2R3kLFSi.js';
5
5
  import '@mdx-js/mdx';
6
6
  import 'mdx/types';
7
7
  import 'fumadocs-core/mdx-plugins';
@@ -10,6 +10,7 @@ import 'unified';
10
10
  import 'react';
11
11
  import 'zod';
12
12
  import '@standard-schema/spec';
13
+ import '@fumadocs/mdx-remote';
13
14
 
14
15
  declare const _runtime: Runtime;
15
16
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
@@ -165,8 +165,7 @@ var import_node_querystring = require("querystring");
165
165
  var import_gray_matter2 = __toESM(require("gray-matter"), 1);
166
166
 
167
167
  // src/utils/config.ts
168
- var import_node_crypto = require("crypto");
169
- var fs = __toESM(require("fs"), 1);
168
+ var fs = __toESM(require("fs/promises"), 1);
170
169
  var path = __toESM(require("path"), 1);
171
170
  var import_node_url = require("url");
172
171
 
@@ -197,23 +196,11 @@ function buildConfig(config) {
197
196
  null
198
197
  ];
199
198
  }
200
- let cachedMdxOptions;
201
199
  return [
202
200
  null,
203
201
  {
204
202
  global: globalConfig,
205
203
  collections,
206
- async getDefaultMDXOptions() {
207
- if (cachedMdxOptions) return cachedMdxOptions;
208
- const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
209
- const mdxOptions = globalConfig?.mdxOptions ?? {};
210
- if (typeof mdxOptions === "function") {
211
- cachedMdxOptions = getDefaultMDXOptions2(await mdxOptions());
212
- } else {
213
- cachedMdxOptions = getDefaultMDXOptions2(mdxOptions);
214
- }
215
- return cachedMdxOptions;
216
- },
217
204
  _runtime: {
218
205
  files: /* @__PURE__ */ new Map()
219
206
  }
@@ -223,12 +210,12 @@ function buildConfig(config) {
223
210
 
224
211
  // src/utils/config.ts
225
212
  var cache = null;
226
- async function compileConfig(configPath) {
213
+ async function compileConfig(configPath, outDir) {
227
214
  const { build } = await import("esbuild");
228
215
  const transformed = await build({
229
216
  entryPoints: [{ in: configPath, out: "source.config" }],
230
217
  bundle: true,
231
- outdir: ".source",
218
+ outdir: outDir,
232
219
  target: "node18",
233
220
  write: true,
234
221
  platform: "node",
@@ -247,9 +234,9 @@ async function loadConfig(configPath, hash, build = false) {
247
234
  if (cache && cache.hash === hash) {
248
235
  return await cache.config;
249
236
  }
250
- if (build) await compileConfig(configPath);
237
+ if (build) await compileConfig(configPath, ".source");
251
238
  const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
252
- const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
239
+ const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
253
240
  const [err, config2] = buildConfig(
254
241
  // every call to `loadConfig` will cause the previous cache to be ignored
255
242
  loaded
@@ -261,12 +248,11 @@ async function loadConfig(configPath, hash, build = false) {
261
248
  return await config;
262
249
  }
263
250
  async function getConfigHash(configPath) {
264
- const hash = (0, import_node_crypto.createHash)("md5");
265
- const rs = fs.createReadStream(configPath);
266
- for await (const chunk of rs) {
267
- hash.update(chunk);
251
+ const stats = await fs.stat(configPath).catch(() => void 0);
252
+ if (stats) {
253
+ return stats.mtime.getTime().toString();
268
254
  }
269
- return hash.digest("hex");
255
+ throw new Error("Cannot find config file");
270
256
  }
271
257
 
272
258
  // src/utils/build-mdx.ts
@@ -446,7 +432,14 @@ async function loader(source, callback) {
446
432
  if (collection && collection.type !== "doc") {
447
433
  collection = void 0;
448
434
  }
449
- const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
435
+ let mdxOptions = collection?.mdxOptions;
436
+ if (!mdxOptions) {
437
+ const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
438
+ config._mdx_loader ??= {};
439
+ const extendedOptions = config.global?.mdxOptions;
440
+ config._mdx_loader.cachedProcessorOptions ??= typeof extendedOptions === "function" ? getDefaultMDXOptions2(await extendedOptions()) : getDefaultMDXOptions2(extendedOptions ?? {});
441
+ mdxOptions = config._mdx_loader.cachedProcessorOptions;
442
+ }
450
443
  if (collection?.schema) {
451
444
  matter2.data = await validate(
452
445
  collection.schema,
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  getConfigHash,
3
3
  loadConfig
4
- } from "./chunk-2FUWXPXA.js";
4
+ } from "./chunk-R6U7CJLB.js";
5
5
  import {
6
6
  validate
7
7
  } from "./chunk-KGLACICA.js";
8
8
  import {
9
9
  remarkInclude
10
10
  } from "./chunk-PY2KKTR2.js";
11
- import "./chunk-6ZVE73IT.js";
11
+ import "./chunk-SLCPEEMF.js";
12
12
 
13
13
  // src/loader-mdx.ts
14
14
  import * as path2 from "node:path";
@@ -102,7 +102,14 @@ async function loader(source, callback) {
102
102
  if (collection && collection.type !== "doc") {
103
103
  collection = void 0;
104
104
  }
105
- const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
105
+ let mdxOptions = collection?.mdxOptions;
106
+ if (!mdxOptions) {
107
+ const { getDefaultMDXOptions } = await import("./mdx-options-CAU273O3.js");
108
+ config._mdx_loader ??= {};
109
+ const extendedOptions = config.global?.mdxOptions;
110
+ config._mdx_loader.cachedProcessorOptions ??= typeof extendedOptions === "function" ? getDefaultMDXOptions(await extendedOptions()) : getDefaultMDXOptions(extendedOptions ?? {});
111
+ mdxOptions = config._mdx_loader.cachedProcessorOptions;
112
+ }
106
113
  if (collection?.schema) {
107
114
  matter.data = await validate(
108
115
  collection.schema,
@@ -30,130 +30,6 @@ 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-plugins/remark-exports.ts
34
- function remarkMdxExport({ values }) {
35
- return (tree, vfile) => {
36
- for (const name of values) {
37
- if (!(name in vfile.data)) return;
38
- tree.children.unshift(getMdastExport(name, vfile.data[name]));
39
- }
40
- };
41
- }
42
- function getMdastExport(name, value) {
43
- return {
44
- type: "mdxjsEsm",
45
- value: "",
46
- data: {
47
- estree: {
48
- type: "Program",
49
- sourceType: "module",
50
- body: [
51
- {
52
- type: "ExportNamedDeclaration",
53
- specifiers: [],
54
- source: null,
55
- declaration: {
56
- type: "VariableDeclaration",
57
- kind: "let",
58
- declarations: [
59
- {
60
- type: "VariableDeclarator",
61
- id: {
62
- type: "Identifier",
63
- name
64
- },
65
- init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
66
- }
67
- ]
68
- }
69
- }
70
- ]
71
- }
72
- }
73
- };
74
- }
75
- var import_estree_util_value_to_estree;
76
- var init_remark_exports = __esm({
77
- "src/mdx-plugins/remark-exports.ts"() {
78
- "use strict";
79
- import_estree_util_value_to_estree = require("estree-util-value-to-estree");
80
- }
81
- });
82
-
83
- // src/utils/mdx-options.ts
84
- var mdx_options_exports = {};
85
- __export(mdx_options_exports, {
86
- getDefaultMDXOptions: () => getDefaultMDXOptions
87
- });
88
- function pluginOption(def, options = []) {
89
- const list = def(Array.isArray(options) ? options : []).filter(
90
- Boolean
91
- );
92
- if (typeof options === "function") {
93
- return options(list);
94
- }
95
- return list;
96
- }
97
- function getDefaultMDXOptions({
98
- valueToExport = [],
99
- rehypeCodeOptions,
100
- remarkImageOptions,
101
- remarkHeadingOptions,
102
- remarkStructureOptions,
103
- remarkCodeTabOptions,
104
- ...mdxOptions
105
- }) {
106
- const mdxExports = [
107
- "structuredData",
108
- "frontmatter",
109
- "lastModified",
110
- ...valueToExport
111
- ];
112
- const remarkPlugins = pluginOption(
113
- (v) => [
114
- plugins.remarkGfm,
115
- [
116
- plugins.remarkHeading,
117
- {
118
- generateToc: false,
119
- ...remarkHeadingOptions
120
- }
121
- ],
122
- remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
123
- // Fumadocs 14 compatibility
124
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && plugins.remarkCodeTab,
125
- ...v,
126
- remarkStructureOptions !== false && [
127
- plugins.remarkStructure,
128
- remarkStructureOptions
129
- ],
130
- [remarkMdxExport, { values: mdxExports }]
131
- ],
132
- mdxOptions.remarkPlugins
133
- );
134
- const rehypePlugins = pluginOption(
135
- (v) => [
136
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
137
- ...v,
138
- [plugins.rehypeToc]
139
- ],
140
- mdxOptions.rehypePlugins
141
- );
142
- return {
143
- ...mdxOptions,
144
- remarkPlugins,
145
- rehypePlugins
146
- };
147
- }
148
- var plugins;
149
- var init_mdx_options = __esm({
150
- "src/utils/mdx-options.ts"() {
151
- "use strict";
152
- plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
153
- init_remark_exports();
154
- }
155
- });
156
-
157
33
  // src/map/watcher.ts
158
34
  var watcher_exports = {};
159
35
  __export(watcher_exports, {
@@ -199,8 +75,7 @@ module.exports = __toCommonJS(next_exports);
199
75
  var import_node_path2 = __toESM(require("path"), 1);
200
76
 
201
77
  // src/utils/config.ts
202
- var import_node_crypto = require("crypto");
203
- var fs = __toESM(require("fs"), 1);
78
+ var fs = __toESM(require("fs/promises"), 1);
204
79
  var path = __toESM(require("path"), 1);
205
80
  var import_node_url = require("url");
206
81
 
@@ -231,23 +106,11 @@ function buildConfig(config) {
231
106
  null
232
107
  ];
233
108
  }
234
- let cachedMdxOptions;
235
109
  return [
236
110
  null,
237
111
  {
238
112
  global: globalConfig,
239
113
  collections,
240
- async getDefaultMDXOptions() {
241
- if (cachedMdxOptions) return cachedMdxOptions;
242
- const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
243
- const mdxOptions = globalConfig?.mdxOptions ?? {};
244
- if (typeof mdxOptions === "function") {
245
- cachedMdxOptions = getDefaultMDXOptions2(await mdxOptions());
246
- } else {
247
- cachedMdxOptions = getDefaultMDXOptions2(mdxOptions);
248
- }
249
- return cachedMdxOptions;
250
- },
251
114
  _runtime: {
252
115
  files: /* @__PURE__ */ new Map()
253
116
  }
@@ -260,12 +123,12 @@ function findConfigFile() {
260
123
  return path.resolve("source.config.ts");
261
124
  }
262
125
  var cache = null;
263
- async function compileConfig(configPath) {
126
+ async function compileConfig(configPath, outDir2) {
264
127
  const { build } = await import("esbuild");
265
128
  const transformed = await build({
266
129
  entryPoints: [{ in: configPath, out: "source.config" }],
267
130
  bundle: true,
268
- outdir: ".source",
131
+ outdir: outDir2,
269
132
  target: "node18",
270
133
  write: true,
271
134
  platform: "node",
@@ -284,9 +147,9 @@ async function loadConfig(configPath, hash, build = false) {
284
147
  if (cache && cache.hash === hash) {
285
148
  return await cache.config;
286
149
  }
287
- if (build) await compileConfig(configPath);
150
+ if (build) await compileConfig(configPath, ".source");
288
151
  const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
289
- const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
152
+ const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
290
153
  const [err, config2] = buildConfig(
291
154
  // every call to `loadConfig` will cause the previous cache to be ignored
292
155
  loaded
@@ -298,12 +161,11 @@ async function loadConfig(configPath, hash, build = false) {
298
161
  return await config;
299
162
  }
300
163
  async function getConfigHash(configPath) {
301
- const hash = (0, import_node_crypto.createHash)("md5");
302
- const rs = fs.createReadStream(configPath);
303
- for await (const chunk of rs) {
304
- hash.update(chunk);
164
+ const stats = await fs.stat(configPath).catch(() => void 0);
165
+ if (stats) {
166
+ return stats.mtime.getTime().toString();
305
167
  }
306
- return hash.digest("hex");
168
+ throw new Error("Cannot find config file");
307
169
  }
308
170
 
309
171
  // src/map/index.ts
@@ -367,10 +229,10 @@ ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
367
229
  var map = /* @__PURE__ */ new Map();
368
230
  var fileCache = {
369
231
  read(namespace, path6) {
370
- return map.get(`${namespace}.${path6}}`);
232
+ return map.get(`${namespace}.${path6}`);
371
233
  },
372
234
  write(namespace, path6, data) {
373
- map.set(`${namespace}.${path6}}`, data);
235
+ map.set(`${namespace}.${path6}`, data);
374
236
  },
375
237
  removeCache(path6) {
376
238
  for (const key of map.keys()) {
@@ -2,11 +2,11 @@ import {
2
2
  findConfigFile,
3
3
  getConfigHash,
4
4
  loadConfig
5
- } from "../chunk-2FUWXPXA.js";
5
+ } from "../chunk-R6U7CJLB.js";
6
6
  import {
7
7
  validate
8
8
  } from "../chunk-KGLACICA.js";
9
- import "../chunk-6ZVE73IT.js";
9
+ import "../chunk-SLCPEEMF.js";
10
10
 
11
11
  // src/next/create.ts
12
12
  import path3 from "node:path";
@@ -34,10 +34,10 @@ function getTypeFromPath(path5) {
34
34
  var map = /* @__PURE__ */ new Map();
35
35
  var fileCache = {
36
36
  read(namespace, path5) {
37
- return map.get(`${namespace}.${path5}}`);
37
+ return map.get(`${namespace}.${path5}`);
38
38
  },
39
39
  write(namespace, path5, data) {
40
- map.set(`${namespace}.${path5}}`, data);
40
+ map.set(`${namespace}.${path5}`, data);
41
41
  },
42
42
  removeCache(path5) {
43
43
  for (const key of map.keys()) {
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,130 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
27
  ));
31
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
29
 
33
- // src/mdx-plugins/remark-exports.ts
34
- function remarkMdxExport({ values }) {
35
- return (tree, vfile) => {
36
- for (const name of values) {
37
- if (!(name in vfile.data)) return;
38
- tree.children.unshift(getMdastExport(name, vfile.data[name]));
39
- }
40
- };
41
- }
42
- function getMdastExport(name, value) {
43
- return {
44
- type: "mdxjsEsm",
45
- value: "",
46
- data: {
47
- estree: {
48
- type: "Program",
49
- sourceType: "module",
50
- body: [
51
- {
52
- type: "ExportNamedDeclaration",
53
- specifiers: [],
54
- source: null,
55
- declaration: {
56
- type: "VariableDeclaration",
57
- kind: "let",
58
- declarations: [
59
- {
60
- type: "VariableDeclarator",
61
- id: {
62
- type: "Identifier",
63
- name
64
- },
65
- init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
66
- }
67
- ]
68
- }
69
- }
70
- ]
71
- }
72
- }
73
- };
74
- }
75
- var import_estree_util_value_to_estree;
76
- var init_remark_exports = __esm({
77
- "src/mdx-plugins/remark-exports.ts"() {
78
- "use strict";
79
- import_estree_util_value_to_estree = require("estree-util-value-to-estree");
80
- }
81
- });
82
-
83
- // src/utils/mdx-options.ts
84
- var mdx_options_exports = {};
85
- __export(mdx_options_exports, {
86
- getDefaultMDXOptions: () => getDefaultMDXOptions
87
- });
88
- function pluginOption(def, options = []) {
89
- const list = def(Array.isArray(options) ? options : []).filter(
90
- Boolean
91
- );
92
- if (typeof options === "function") {
93
- return options(list);
94
- }
95
- return list;
96
- }
97
- function getDefaultMDXOptions({
98
- valueToExport = [],
99
- rehypeCodeOptions,
100
- remarkImageOptions,
101
- remarkHeadingOptions,
102
- remarkStructureOptions,
103
- remarkCodeTabOptions,
104
- ...mdxOptions
105
- }) {
106
- const mdxExports = [
107
- "structuredData",
108
- "frontmatter",
109
- "lastModified",
110
- ...valueToExport
111
- ];
112
- const remarkPlugins = pluginOption(
113
- (v) => [
114
- plugins.remarkGfm,
115
- [
116
- plugins.remarkHeading,
117
- {
118
- generateToc: false,
119
- ...remarkHeadingOptions
120
- }
121
- ],
122
- remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
123
- // Fumadocs 14 compatibility
124
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && plugins.remarkCodeTab,
125
- ...v,
126
- remarkStructureOptions !== false && [
127
- plugins.remarkStructure,
128
- remarkStructureOptions
129
- ],
130
- [remarkMdxExport, { values: mdxExports }]
131
- ],
132
- mdxOptions.remarkPlugins
133
- );
134
- const rehypePlugins = pluginOption(
135
- (v) => [
136
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
137
- ...v,
138
- [plugins.rehypeToc]
139
- ],
140
- mdxOptions.rehypePlugins
141
- );
142
- return {
143
- ...mdxOptions,
144
- remarkPlugins,
145
- rehypePlugins
146
- };
147
- }
148
- var plugins;
149
- var init_mdx_options = __esm({
150
- "src/utils/mdx-options.ts"() {
151
- "use strict";
152
- plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
153
- init_remark_exports();
154
- }
155
- });
156
-
157
30
  // src/runtime/async.ts
158
31
  var async_exports = {};
159
32
  __export(async_exports, {
@@ -311,23 +184,11 @@ function buildConfig(config) {
311
184
  null
312
185
  ];
313
186
  }
314
- let cachedMdxOptions;
315
187
  return [
316
188
  null,
317
189
  {
318
190
  global: globalConfig,
319
191
  collections,
320
- async getDefaultMDXOptions() {
321
- if (cachedMdxOptions) return cachedMdxOptions;
322
- const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
323
- const mdxOptions = globalConfig?.mdxOptions ?? {};
324
- if (typeof mdxOptions === "function") {
325
- cachedMdxOptions = getDefaultMDXOptions2(await mdxOptions());
326
- } else {
327
- cachedMdxOptions = getDefaultMDXOptions2(mdxOptions);
328
- }
329
- return cachedMdxOptions;
330
- },
331
192
  _runtime: {
332
193
  files: /* @__PURE__ */ new Map()
333
194
  }
@@ -343,14 +204,15 @@ async function initCompiler(config, collection) {
343
204
  else if (col?.type === "docs")
344
205
  mdxOptions = col.docs?.mdxOptions;
345
206
  if (!mdxOptions) {
346
- const options = typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions;
347
- const remarkPlugins = options?.remarkPlugins ?? [];
348
- mdxOptions = {
349
- ...options,
350
- remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), import_mdx_plugins.remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, import_mdx_plugins.remarkStructure]
351
- };
207
+ config._mdx_async ??= {};
208
+ config._mdx_async.cachedMdxOptions ??= typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions ?? {};
209
+ mdxOptions = config._mdx_async.cachedMdxOptions;
352
210
  }
353
- return (0, import_mdx_remote.createCompiler)(mdxOptions);
211
+ const remarkPlugins = mdxOptions.remarkPlugins ?? [];
212
+ return (0, import_mdx_remote.createCompiler)({
213
+ ...mdxOptions,
214
+ remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), import_mdx_plugins.remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, import_mdx_plugins.remarkStructure]
215
+ });
354
216
  }
355
217
  var _runtimeAsync = {
356
218
  doc(files, collection, config) {
@@ -1,4 +1,4 @@
1
- import { L as LoadedConfig, b as RuntimeAsync } from '../types-8ecOBKxa.cjs';
1
+ import { L as LoadedConfig, b as RuntimeAsync } from '../types-BIA23Xld.cjs';
2
2
  import '../define-DxwgTgV6.cjs';
3
3
  import '@mdx-js/mdx';
4
4
  import 'mdx/types';
@@ -9,6 +9,7 @@ import 'react';
9
9
  import 'zod';
10
10
  import '@standard-schema/spec';
11
11
  import 'fumadocs-core/source';
12
+ import '@fumadocs/mdx-remote';
12
13
 
13
14
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
14
15
 
@@ -1,4 +1,4 @@
1
- import { L as LoadedConfig, b as RuntimeAsync } from '../types-BQ1vyPw8.js';
1
+ import { L as LoadedConfig, b as RuntimeAsync } from '../types-2R3kLFSi.js';
2
2
  import '../define-DxwgTgV6.js';
3
3
  import '@mdx-js/mdx';
4
4
  import 'mdx/types';
@@ -9,6 +9,7 @@ import 'react';
9
9
  import 'zod';
10
10
  import '@standard-schema/spec';
11
11
  import 'fumadocs-core/source';
12
+ import '@fumadocs/mdx-remote';
12
13
 
13
14
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
14
15
 
@@ -7,7 +7,7 @@ import {
7
7
  } from "../chunk-PY2KKTR2.js";
8
8
  import {
9
9
  buildConfig
10
- } from "../chunk-6ZVE73IT.js";
10
+ } from "../chunk-SLCPEEMF.js";
11
11
 
12
12
  // src/runtime/async.ts
13
13
  import { createCompiler } from "@fumadocs/mdx-remote";
@@ -22,14 +22,15 @@ async function initCompiler(config, collection) {
22
22
  else if (col?.type === "docs")
23
23
  mdxOptions = col.docs?.mdxOptions;
24
24
  if (!mdxOptions) {
25
- const options = typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions;
26
- const remarkPlugins = options?.remarkPlugins ?? [];
27
- mdxOptions = {
28
- ...options,
29
- remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, remarkStructure]
30
- };
25
+ config._mdx_async ??= {};
26
+ config._mdx_async.cachedMdxOptions ??= typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions ?? {};
27
+ mdxOptions = config._mdx_async.cachedMdxOptions;
31
28
  }
32
- return createCompiler(mdxOptions);
29
+ const remarkPlugins = mdxOptions.remarkPlugins ?? [];
30
+ return createCompiler({
31
+ ...mdxOptions,
32
+ remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, remarkStructure]
33
+ });
33
34
  }
34
35
  var _runtimeAsync = {
35
36
  doc(files, collection, config) {
@@ -2,10 +2,10 @@ import { D as DocCollection, b as MetaCollection, c as DocsCollection, G as Glob
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
+ import { MDXOptions } from '@fumadocs/mdx-remote';
5
6
 
6
7
  interface LoadedConfig {
7
8
  collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
8
- getDefaultMDXOptions: () => Promise<ProcessorOptions>;
9
9
  global?: GlobalConfig;
10
10
  _runtime: {
11
11
  /**
@@ -13,6 +13,12 @@ interface LoadedConfig {
13
13
  */
14
14
  files: Map<string, string>;
15
15
  };
16
+ _mdx_loader?: {
17
+ cachedProcessorOptions?: ProcessorOptions;
18
+ };
19
+ _mdx_async?: {
20
+ cachedMdxOptions?: MDXOptions;
21
+ };
16
22
  }
17
23
 
18
24
  interface RuntimeFile {
@@ -2,10 +2,10 @@ import { D as DocCollection, b as MetaCollection, c as DocsCollection, G as Glob
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
+ import { MDXOptions } from '@fumadocs/mdx-remote';
5
6
 
6
7
  interface LoadedConfig {
7
8
  collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
8
- getDefaultMDXOptions: () => Promise<ProcessorOptions>;
9
9
  global?: GlobalConfig;
10
10
  _runtime: {
11
11
  /**
@@ -13,6 +13,12 @@ interface LoadedConfig {
13
13
  */
14
14
  files: Map<string, string>;
15
15
  };
16
+ _mdx_loader?: {
17
+ cachedProcessorOptions?: ProcessorOptions;
18
+ };
19
+ _mdx_async?: {
20
+ cachedMdxOptions?: MDXOptions;
21
+ };
16
22
  }
17
23
 
18
24
  interface RuntimeFile {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.5.4",
3
+ "version": "11.5.6",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -51,21 +51,21 @@
51
51
  "fast-glob": "^3.3.3",
52
52
  "gray-matter": "^4.0.3",
53
53
  "unist-util-visit": "^5.0.0",
54
- "zod": "^3.24.1"
54
+ "zod": "^3.24.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/cross-spawn": "^6.0.6",
58
58
  "@types/mdast": "^4.0.3",
59
59
  "@types/mdx": "^2.0.13",
60
- "@types/react": "^19.0.8",
60
+ "@types/react": "^19.0.9",
61
61
  "mdast-util-mdx-jsx": "^3.2.0",
62
- "next": "^15.1.6",
62
+ "next": "^15.1.7",
63
63
  "unified": "^11.0.5",
64
64
  "vfile": "^6.0.3",
65
65
  "webpack": "^5.97.1",
66
66
  "@fumadocs/mdx-remote": "1.2.0",
67
67
  "eslint-config-custom": "0.0.0",
68
- "fumadocs-core": "15.0.7",
68
+ "fumadocs-core": "15.0.9",
69
69
  "tsconfig": "0.0.0"
70
70
  },
71
71
  "peerDependencies": {