fumadocs-mdx 13.0.7 → 14.0.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.
Files changed (104) hide show
  1. package/dist/bin.cjs +927 -904
  2. package/dist/bin.js +3 -3
  3. package/dist/build-mdx-6UAK5FF5.js +8 -0
  4. package/dist/bun/index.cjs +592 -481
  5. package/dist/bun/index.d.cts +3 -2
  6. package/dist/bun/index.d.ts +3 -2
  7. package/dist/bun/index.js +12 -12
  8. package/dist/chunk-4JSFLXXT.js +8 -0
  9. package/dist/chunk-5UMZCWKV.js +17 -0
  10. package/dist/chunk-5YXP7JLN.js +138 -0
  11. package/dist/{chunk-2E2JCOSO.js → chunk-6NISOLQ6.js} +16 -44
  12. package/dist/chunk-7L2KNF6B.js +180 -0
  13. package/dist/chunk-E5DJTSIM.js +86 -0
  14. package/dist/{chunk-K5ZLPEIQ.js → chunk-FBLMK4RS.js} +9 -6
  15. package/dist/{chunk-QXHN25N3.js → chunk-OXSRIWQW.js} +7 -8
  16. package/dist/chunk-PKI7ZDA5.js +29 -0
  17. package/dist/{chunk-3J3WL7WN.js → chunk-SLY7WXTX.js} +71 -58
  18. package/dist/{chunk-ETIN2W7C.js → chunk-SRSRFOVI.js} +22 -19
  19. package/dist/chunk-TYJDYTKH.js +85 -0
  20. package/dist/chunk-XHJCLBZ4.js +406 -0
  21. package/dist/{chunk-2HXTGJBI.js → chunk-ZY6UZ7NH.js} +22 -19
  22. package/dist/config/index.cjs +79 -71
  23. package/dist/config/index.d.cts +2 -1
  24. package/dist/config/index.d.ts +2 -1
  25. package/dist/config/index.js +5 -5
  26. package/dist/index-BlVBvy-z.d.ts +8 -0
  27. package/dist/{core-HkAVGq_a.d.cts → index-D7JdSMpp.d.cts} +99 -61
  28. package/dist/{core-HkAVGq_a.d.ts → index-D7JdSMpp.d.ts} +99 -61
  29. package/dist/index-P2NNUkHn.d.cts +8 -0
  30. package/dist/index.d.cts +3 -74
  31. package/dist/index.d.ts +3 -74
  32. package/dist/load-from-file-I3ALLIVB.js +8 -0
  33. package/dist/next/index.cjs +698 -476
  34. package/dist/next/index.d.cts +11 -1
  35. package/dist/next/index.d.ts +11 -1
  36. package/dist/next/index.js +78 -281
  37. package/dist/node/loader.cjs +705 -603
  38. package/dist/node/loader.js +10 -11
  39. package/dist/plugins/index-file.cjs +471 -0
  40. package/dist/plugins/index-file.d.cts +29 -0
  41. package/dist/plugins/index-file.d.ts +29 -0
  42. package/dist/plugins/index-file.js +8 -0
  43. package/dist/plugins/json-schema.d.cts +3 -2
  44. package/dist/plugins/json-schema.d.ts +3 -2
  45. package/dist/plugins/last-modified.cjs +75 -0
  46. package/dist/plugins/last-modified.d.cts +27 -0
  47. package/dist/plugins/last-modified.d.ts +27 -0
  48. package/dist/plugins/last-modified.js +44 -0
  49. package/dist/runtime/{vite/browser.cjs → browser.cjs} +40 -53
  50. package/dist/runtime/browser.d.cts +50 -0
  51. package/dist/runtime/browser.d.ts +50 -0
  52. package/dist/runtime/browser.js +68 -0
  53. package/dist/runtime/dynamic.cjs +985 -0
  54. package/dist/runtime/dynamic.d.cts +27 -0
  55. package/dist/runtime/dynamic.d.ts +27 -0
  56. package/dist/runtime/dynamic.js +78 -0
  57. package/dist/runtime/server.cjs +173 -0
  58. package/dist/runtime/server.d.cts +161 -0
  59. package/dist/runtime/server.d.ts +161 -0
  60. package/dist/runtime/server.js +8 -0
  61. package/dist/vite/index.cjs +935 -639
  62. package/dist/vite/index.d.cts +12 -22
  63. package/dist/vite/index.d.ts +12 -22
  64. package/dist/vite/index.js +30 -221
  65. package/dist/webpack/mdx.cjs +614 -515
  66. package/dist/webpack/mdx.d.cts +9 -1
  67. package/dist/webpack/mdx.d.ts +9 -1
  68. package/dist/webpack/mdx.js +12 -17
  69. package/dist/webpack/meta.cjs +328 -234
  70. package/dist/webpack/meta.d.cts +9 -1
  71. package/dist/webpack/meta.d.ts +9 -1
  72. package/dist/webpack/meta.js +13 -15
  73. package/package.json +15 -32
  74. package/dist/build-mdx-BnJhW5O1.d.cts +0 -53
  75. package/dist/build-mdx-DNzfRRlY.d.ts +0 -53
  76. package/dist/chunk-2AQRQXSO.js +0 -119
  77. package/dist/chunk-4757L6ST.js +0 -77
  78. package/dist/chunk-CXA4JO4Z.js +0 -45
  79. package/dist/chunk-FSZMKRVH.js +0 -80
  80. package/dist/chunk-II3H5ZVZ.js +0 -77
  81. package/dist/chunk-KILFIBVW.js +0 -75
  82. package/dist/chunk-NVRDCY6Z.js +0 -30
  83. package/dist/chunk-VUEZTR2H.js +0 -26
  84. package/dist/index-D7s7kCc2.d.cts +0 -7
  85. package/dist/index-D7s7kCc2.d.ts +0 -7
  86. package/dist/load-from-file-AVYOFOI7.js +0 -7
  87. package/dist/preset-ZMP6U62C.js +0 -6
  88. package/dist/runtime/next/async.cjs +0 -760
  89. package/dist/runtime/next/async.d.cts +0 -19
  90. package/dist/runtime/next/async.d.ts +0 -19
  91. package/dist/runtime/next/async.js +0 -86
  92. package/dist/runtime/next/index.cjs +0 -136
  93. package/dist/runtime/next/index.d.cts +0 -33
  94. package/dist/runtime/next/index.d.ts +0 -33
  95. package/dist/runtime/next/index.js +0 -11
  96. package/dist/runtime/vite/browser.d.cts +0 -59
  97. package/dist/runtime/vite/browser.d.ts +0 -59
  98. package/dist/runtime/vite/browser.js +0 -11
  99. package/dist/runtime/vite/server.cjs +0 -243
  100. package/dist/runtime/vite/server.d.cts +0 -30
  101. package/dist/runtime/vite/server.d.ts +0 -30
  102. package/dist/runtime/vite/server.js +0 -111
  103. package/dist/types-By6wKOnT.d.cts +0 -45
  104. package/dist/types-DgD5Omj2.d.ts +0 -45
@@ -1,27 +1,26 @@
1
1
  import {
2
2
  createMdxLoader
3
- } from "../chunk-2E2JCOSO.js";
3
+ } from "../chunk-6NISOLQ6.js";
4
4
  import {
5
5
  createMetaLoader
6
- } from "../chunk-4757L6ST.js";
6
+ } from "../chunk-TYJDYTKH.js";
7
7
  import {
8
8
  createStandaloneConfigLoader,
9
9
  toNode
10
- } from "../chunk-ETIN2W7C.js";
11
- import "../chunk-3J3WL7WN.js";
12
- import "../chunk-K5ZLPEIQ.js";
13
- import "../chunk-VUEZTR2H.js";
10
+ } from "../chunk-SRSRFOVI.js";
11
+ import "../chunk-4JSFLXXT.js";
14
12
  import {
15
- createCore,
16
- findConfigFile
17
- } from "../chunk-2AQRQXSO.js";
13
+ _Defaults,
14
+ createCore
15
+ } from "../chunk-7L2KNF6B.js";
16
+ import "../chunk-PKI7ZDA5.js";
18
17
  import "../chunk-VWJKRQZR.js";
19
18
 
20
19
  // src/node/loader.ts
21
20
  var core = createCore({
22
21
  environment: "node",
23
- configPath: findConfigFile(),
24
- outDir: ".source"
22
+ configPath: _Defaults.configPath,
23
+ outDir: _Defaults.outDir
25
24
  });
26
25
  var configLoader = createStandaloneConfigLoader({
27
26
  core,
@@ -0,0 +1,471 @@
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/index-file.ts
31
+ var index_file_exports = {};
32
+ __export(index_file_exports, {
33
+ default: () => indexFile
34
+ });
35
+ module.exports = __toCommonJS(index_file_exports);
36
+ var import_path = __toESM(require("path"), 1);
37
+
38
+ // src/utils/codegen/index.ts
39
+ var import_node_path = __toESM(require("path"), 1);
40
+ var import_tinyglobby = require("tinyglobby");
41
+ function createCodegen({
42
+ target = "default",
43
+ outDir = "",
44
+ jsExtension = false,
45
+ globCache = /* @__PURE__ */ new Map()
46
+ }) {
47
+ let eagerImportId = 0;
48
+ const banner = ["// @ts-nocheck"];
49
+ if (target === "vite") {
50
+ banner.push('/// <reference types="vite/client" />');
51
+ }
52
+ return {
53
+ options: {
54
+ target,
55
+ outDir
56
+ },
57
+ lines: [],
58
+ addImport(statement) {
59
+ this.lines.unshift(statement);
60
+ },
61
+ async pushAsync(insert) {
62
+ for (const line of await Promise.all(insert)) {
63
+ if (line === void 0) continue;
64
+ this.lines.push(line);
65
+ }
66
+ },
67
+ async generateGlobImport(patterns, options) {
68
+ if (target === "vite") {
69
+ return this.generateViteGlobImport(patterns, options);
70
+ }
71
+ return this.generateNodeGlobImport(patterns, options);
72
+ },
73
+ generateViteGlobImport(patterns, { base, ...rest }) {
74
+ patterns = (typeof patterns === "string" ? [patterns] : patterns).map(
75
+ normalizeViteGlobPath
76
+ );
77
+ return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
78
+ {
79
+ base: normalizeViteGlobPath(import_node_path.default.relative(outDir, base)),
80
+ ...rest
81
+ },
82
+ null,
83
+ 2
84
+ )})`;
85
+ },
86
+ async generateNodeGlobImport(patterns, {
87
+ base,
88
+ eager = false,
89
+ query = {},
90
+ import: importName
91
+ }) {
92
+ const cacheKey = JSON.stringify({ patterns, base });
93
+ let files = globCache.get(cacheKey);
94
+ if (!files) {
95
+ files = (0, import_tinyglobby.glob)(patterns, {
96
+ cwd: base
97
+ });
98
+ globCache.set(cacheKey, files);
99
+ }
100
+ let code = "{";
101
+ for (const item of await files) {
102
+ const fullPath = import_node_path.default.join(base, item);
103
+ const searchParams = new URLSearchParams();
104
+ for (const [k, v] of Object.entries(query)) {
105
+ searchParams.set(k, v);
106
+ }
107
+ const importPath = this.formatImportPath(fullPath) + "?" + searchParams.toString();
108
+ if (eager) {
109
+ const name = `__fd_glob_${eagerImportId++}`;
110
+ this.lines.unshift(
111
+ importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`
112
+ );
113
+ code += `${JSON.stringify(item)}: ${name}, `;
114
+ } else {
115
+ let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
116
+ if (importName) {
117
+ line += `.then(mod => mod.${importName})`;
118
+ }
119
+ code += `${line}, `;
120
+ }
121
+ }
122
+ code += "}";
123
+ return code;
124
+ },
125
+ formatImportPath(file) {
126
+ const ext = import_node_path.default.extname(file);
127
+ let filename;
128
+ if (ext === ".ts" && jsExtension) {
129
+ filename = file.substring(0, file.length - ext.length) + ".js";
130
+ } else if (ext === ".ts") {
131
+ filename = file.substring(0, file.length - ext.length);
132
+ } else {
133
+ filename = file;
134
+ }
135
+ const importPath = slash(import_node_path.default.relative(outDir, filename));
136
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
137
+ },
138
+ toString() {
139
+ return [...banner, ...this.lines].join("\n");
140
+ }
141
+ };
142
+ }
143
+ function normalizeViteGlobPath(file) {
144
+ file = slash(file);
145
+ if (file.startsWith("./")) return file;
146
+ if (file.startsWith("/")) return `.${file}`;
147
+ return `./${file}`;
148
+ }
149
+ function slash(path4) {
150
+ const isExtendedLengthPath = path4.startsWith("\\\\?\\");
151
+ if (isExtendedLengthPath) {
152
+ return path4;
153
+ }
154
+ return path4.replaceAll("\\", "/");
155
+ }
156
+ function ident(code, tab = 1) {
157
+ return code.split("\n").map((v) => " ".repeat(tab) + v).join("\n");
158
+ }
159
+
160
+ // src/plugins/index-file.ts
161
+ var import_tinyglobby2 = require("tinyglobby");
162
+
163
+ // src/utils/codegen/cache.ts
164
+ var import_lru_cache = require("lru-cache");
165
+ var import_promises = __toESM(require("fs/promises"), 1);
166
+ var import_node_path2 = __toESM(require("path"), 1);
167
+ var map = new import_lru_cache.LRUCache({
168
+ max: 100
169
+ });
170
+ function toFullPath(file) {
171
+ if (import_node_path2.default.isAbsolute(file)) {
172
+ return import_node_path2.default.relative(process.cwd(), file);
173
+ }
174
+ return file;
175
+ }
176
+ async function readFileWithCache(file) {
177
+ const fullPath = toFullPath(file);
178
+ const cached = map.get(fullPath);
179
+ if (cached) return cached;
180
+ const read = import_promises.default.readFile(fullPath).then((s) => s.toString());
181
+ map.set(fullPath, read);
182
+ return read;
183
+ }
184
+
185
+ // src/plugins/index-file.ts
186
+ var import_crypto = require("crypto");
187
+
188
+ // src/utils/fuma-matter.ts
189
+ var import_js_yaml = require("js-yaml");
190
+ var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
191
+ function fumaMatter(input) {
192
+ const output = { matter: "", data: {}, content: input };
193
+ const match = regex.exec(input);
194
+ if (!match) {
195
+ return output;
196
+ }
197
+ output.matter = match[0];
198
+ output.content = input.slice(match[0].length);
199
+ const loaded = (0, import_js_yaml.load)(match[1]);
200
+ output.data = loaded ?? {};
201
+ return output;
202
+ }
203
+
204
+ // src/plugins/index-file.ts
205
+ function indexFile(options = {}) {
206
+ const {
207
+ target = "default",
208
+ addJsExtension,
209
+ browser = true,
210
+ dynamic = true
211
+ } = options;
212
+ let config;
213
+ let dynamicCollections;
214
+ function isDynamic(collection) {
215
+ return collection.type === "docs" && collection.docs.dynamic || collection.type === "doc" && collection.dynamic;
216
+ }
217
+ return {
218
+ name: "index-file",
219
+ config(v) {
220
+ config = v;
221
+ dynamicCollections = config.collectionList.filter(isDynamic);
222
+ },
223
+ configureServer(server) {
224
+ if (!server.watcher) return;
225
+ server.watcher.on("all", async (event, file) => {
226
+ if (dynamicCollections.length === 0) {
227
+ if (target === "vite") return;
228
+ if (target === "default" && event === "change") return;
229
+ }
230
+ const updatedCollection = config.collectionList.find(
231
+ (collection) => collection.hasFile(file)
232
+ );
233
+ if (!updatedCollection) return;
234
+ if (!isDynamic(updatedCollection)) {
235
+ if (target === "vite") return;
236
+ if (target === "default" && event === "change") return;
237
+ }
238
+ await this.core.emitAndWrite({
239
+ filterPlugin: (plugin) => plugin.name === "index-file"
240
+ });
241
+ });
242
+ },
243
+ async emit() {
244
+ const globCache = /* @__PURE__ */ new Map();
245
+ const makeCodeGen = () => createCodegen({
246
+ target,
247
+ outDir: this.outDir,
248
+ jsExtension: addJsExtension,
249
+ globCache
250
+ });
251
+ async function toEmitEntry(path4, content) {
252
+ return {
253
+ path: path4,
254
+ content: await content
255
+ };
256
+ }
257
+ const out = [
258
+ toEmitEntry(
259
+ "server.ts",
260
+ generateServerIndexFile(makeCodeGen(), config, this.configPath)
261
+ )
262
+ ];
263
+ if (dynamic)
264
+ out.push(
265
+ toEmitEntry(
266
+ "dynamic.ts",
267
+ generateDynamicIndexFile(this.core, makeCodeGen())
268
+ )
269
+ );
270
+ if (browser)
271
+ out.push(
272
+ toEmitEntry(
273
+ "browser.ts",
274
+ generateBrowserIndexFile(makeCodeGen(), config, this.configPath)
275
+ )
276
+ );
277
+ return await Promise.all(out);
278
+ }
279
+ };
280
+ }
281
+ async function generateServerIndexFile(codegen, config, configPath) {
282
+ codegen.lines.push(
283
+ `import { fromConfig } from 'fumadocs-mdx/runtime/server';`,
284
+ `import type * as Config from '${codegen.formatImportPath(configPath)}';`,
285
+ "",
286
+ `const create = fromConfig<typeof Config>();`
287
+ );
288
+ async function generateCollectionObject(collection) {
289
+ switch (collection.type) {
290
+ case "docs": {
291
+ if (collection.docs.dynamic) return;
292
+ if (collection.docs.async) {
293
+ const [metaGlob2, headGlob, bodyGlob] = await Promise.all([
294
+ generateMetaCollectionGlob(codegen, collection.meta, true),
295
+ generateDocCollectionFrontmatterGlob(
296
+ codegen,
297
+ collection.docs,
298
+ true
299
+ ),
300
+ generateDocCollectionGlob(codegen, collection.docs)
301
+ ]);
302
+ return `await create.docsLazy("${collection.name}", "${collection.dir}", ${metaGlob2}, ${headGlob}, ${bodyGlob})`;
303
+ }
304
+ const [metaGlob, docGlob] = await Promise.all([
305
+ generateMetaCollectionGlob(codegen, collection.meta, true),
306
+ generateDocCollectionGlob(codegen, collection.docs, true)
307
+ ]);
308
+ return `await create.docs("${collection.name}", "${collection.dir}", ${metaGlob}, ${docGlob})`;
309
+ }
310
+ case "doc":
311
+ if (collection.dynamic) return;
312
+ if (collection.async) {
313
+ const [headGlob, bodyGlob] = await Promise.all([
314
+ generateDocCollectionFrontmatterGlob(codegen, collection, true),
315
+ generateDocCollectionGlob(codegen, collection)
316
+ ]);
317
+ return `await create.docLazy("${collection.name}", "${collection.dir}", ${headGlob}, ${bodyGlob})`;
318
+ }
319
+ return `await create.doc("${collection.name}", "${collection.dir}", ${await generateDocCollectionGlob(
320
+ codegen,
321
+ collection,
322
+ true
323
+ )})`;
324
+ case "meta":
325
+ return `await create.meta("${collection.name}", "${collection.dir}", ${await generateMetaCollectionGlob(
326
+ codegen,
327
+ collection,
328
+ true
329
+ )})`;
330
+ }
331
+ }
332
+ await codegen.pushAsync(
333
+ config.collectionList.map(async (collection) => {
334
+ const obj = await generateCollectionObject(collection);
335
+ if (!obj) return;
336
+ return `
337
+ export const ${collection.name} = ${obj};`;
338
+ })
339
+ );
340
+ return codegen.toString();
341
+ }
342
+ async function generateDynamicIndexFile(core, codegen) {
343
+ const { configPath } = core._options;
344
+ codegen.lines.push(
345
+ `import { fromConfigDynamic } from 'fumadocs-mdx/runtime/dynamic';`,
346
+ `import * as Config from '${codegen.formatImportPath(configPath)}';`,
347
+ "",
348
+ `const create = await fromConfigDynamic(Config);`
349
+ );
350
+ async function generateCollectionObjectEntry(collection, file) {
351
+ const fullPath = import_path.default.join(collection.dir, file);
352
+ const content = await readFileWithCache(fullPath).catch(() => "");
353
+ const parsed = fumaMatter(content);
354
+ const data = await core.transformFrontmatter(
355
+ {
356
+ collection,
357
+ filePath: fullPath,
358
+ source: content
359
+ },
360
+ parsed.data
361
+ );
362
+ const hash = (0, import_crypto.createHash)("md5").update(content).digest("hex");
363
+ const infoStr = [
364
+ // make sure it's included in vercel/nft
365
+ `absolutePath: path.resolve(${JSON.stringify(fullPath)})`
366
+ ];
367
+ for (const [k, v] of Object.entries({
368
+ info: {
369
+ fullPath,
370
+ path: file
371
+ },
372
+ data,
373
+ hash
374
+ })) {
375
+ infoStr.push(`${k}: ${JSON.stringify(v)}`);
376
+ }
377
+ return `{ ${infoStr.join(", ")} }`;
378
+ }
379
+ async function generateCollectionObject(parent) {
380
+ let collection;
381
+ if (parent.type === "doc") collection = parent;
382
+ else if (parent.type === "docs") collection = parent.docs;
383
+ if (!collection || !collection.dynamic) return;
384
+ const files = await (0, import_tinyglobby2.glob)(collection.patterns, {
385
+ cwd: collection.dir
386
+ });
387
+ const entries = await Promise.all(
388
+ files.map((file) => generateCollectionObjectEntry(collection, file))
389
+ );
390
+ switch (parent.type) {
391
+ case "docs": {
392
+ const metaGlob = await generateMetaCollectionGlob(
393
+ codegen,
394
+ parent.meta,
395
+ true
396
+ );
397
+ return `await create.docs("${parent.name}", "${parent.dir}", ${metaGlob}, ${entries.join(", ")})`;
398
+ }
399
+ case "doc":
400
+ return `await create.doc("${collection.name}", "${collection.dir}", ${entries.join(", ")})`;
401
+ }
402
+ }
403
+ await codegen.pushAsync(
404
+ core.getConfig().collectionList.map(async (collection) => {
405
+ const obj = await generateCollectionObject(collection);
406
+ if (!obj) return;
407
+ return `
408
+ export const ${collection.name} = ${obj};`;
409
+ })
410
+ );
411
+ return codegen.toString();
412
+ }
413
+ async function generateBrowserIndexFile(codegen, config, configPath) {
414
+ codegen.lines.push(
415
+ `import { fromConfig } from 'fumadocs-mdx/runtime/browser';`,
416
+ `import type * as Config from '${codegen.formatImportPath(configPath)}';`,
417
+ "",
418
+ `const create = fromConfig<typeof Config>();`
419
+ );
420
+ async function generateCollectionObject(collection) {
421
+ switch (collection.type) {
422
+ case "docs": {
423
+ if (collection.docs.dynamic) return;
424
+ return generateCollectionObject(collection.docs);
425
+ }
426
+ case "doc":
427
+ if (collection.dynamic) return;
428
+ return `create.doc("${collection.name}", ${await generateDocCollectionGlob(codegen, collection)})`;
429
+ }
430
+ }
431
+ codegen.lines.push("const browserCollections = {");
432
+ await codegen.pushAsync(
433
+ config.collectionList.map(async (collection) => {
434
+ const obj = await generateCollectionObject(collection);
435
+ if (!obj) return;
436
+ return ident(`${collection.name}: ${obj},`);
437
+ })
438
+ );
439
+ codegen.lines.push("};", "export default browserCollections;");
440
+ return codegen.toString();
441
+ }
442
+ function generateDocCollectionFrontmatterGlob(codegen, collection, eager = false) {
443
+ return codegen.generateGlobImport(collection.patterns, {
444
+ query: {
445
+ collection: collection.name,
446
+ only: "frontmatter"
447
+ },
448
+ import: "frontmatter",
449
+ base: collection.dir,
450
+ eager
451
+ });
452
+ }
453
+ function generateDocCollectionGlob(codegen, collection, eager = false) {
454
+ return codegen.generateGlobImport(collection.patterns, {
455
+ query: {
456
+ collection: collection.name
457
+ },
458
+ base: collection.dir,
459
+ eager
460
+ });
461
+ }
462
+ function generateMetaCollectionGlob(codegen, collection, eager = false) {
463
+ return codegen.generateGlobImport(collection.patterns, {
464
+ query: {
465
+ collection: collection.name
466
+ },
467
+ import: "default",
468
+ base: collection.dir,
469
+ eager
470
+ });
471
+ }
@@ -0,0 +1,29 @@
1
+ import { j as Plugin } from '../index-D7JdSMpp.cjs';
2
+ import '@mdx-js/mdx';
3
+ import '@standard-schema/spec';
4
+ import 'unified';
5
+ import 'fumadocs-core/mdx-plugins';
6
+ import 'zod';
7
+ import 'chokidar';
8
+ import 'vfile';
9
+
10
+ interface IndexFilePluginOptions {
11
+ target?: 'default' | 'vite';
12
+ /**
13
+ * add `.js` extensions to imports, needed for ESM without bundler resolution
14
+ */
15
+ addJsExtension?: boolean;
16
+ /**
17
+ * Generate entry point for browser
18
+ * @defaultValue true
19
+ */
20
+ browser?: boolean;
21
+ /**
22
+ * Generate entry point for dynamic compilation
23
+ * @defaultValue true
24
+ */
25
+ dynamic?: boolean;
26
+ }
27
+ declare function indexFile(options?: IndexFilePluginOptions): Plugin;
28
+
29
+ export { type IndexFilePluginOptions, indexFile as default };
@@ -0,0 +1,29 @@
1
+ import { j as Plugin } from '../index-D7JdSMpp.js';
2
+ import '@mdx-js/mdx';
3
+ import '@standard-schema/spec';
4
+ import 'unified';
5
+ import 'fumadocs-core/mdx-plugins';
6
+ import 'zod';
7
+ import 'chokidar';
8
+ import 'vfile';
9
+
10
+ interface IndexFilePluginOptions {
11
+ target?: 'default' | 'vite';
12
+ /**
13
+ * add `.js` extensions to imports, needed for ESM without bundler resolution
14
+ */
15
+ addJsExtension?: boolean;
16
+ /**
17
+ * Generate entry point for browser
18
+ * @defaultValue true
19
+ */
20
+ browser?: boolean;
21
+ /**
22
+ * Generate entry point for dynamic compilation
23
+ * @defaultValue true
24
+ */
25
+ dynamic?: boolean;
26
+ }
27
+ declare function indexFile(options?: IndexFilePluginOptions): Plugin;
28
+
29
+ export { type IndexFilePluginOptions, indexFile as default };
@@ -0,0 +1,8 @@
1
+ import {
2
+ indexFile
3
+ } from "../chunk-XHJCLBZ4.js";
4
+ import "../chunk-PKI7ZDA5.js";
5
+ import "../chunk-VWJKRQZR.js";
6
+ export {
7
+ indexFile as default
8
+ };
@@ -1,10 +1,11 @@
1
- import { i as Plugin } from '../core-HkAVGq_a.cjs';
1
+ import { j as Plugin } from '../index-D7JdSMpp.cjs';
2
2
  import '@mdx-js/mdx';
3
3
  import '@standard-schema/spec';
4
- import 'fumadocs-core/mdx-plugins';
5
4
  import 'unified';
5
+ import 'fumadocs-core/mdx-plugins';
6
6
  import 'zod';
7
7
  import 'chokidar';
8
+ import 'vfile';
8
9
 
9
10
  interface JSONSchemaOptions {
10
11
  /**
@@ -1,10 +1,11 @@
1
- import { i as Plugin } from '../core-HkAVGq_a.js';
1
+ import { j as Plugin } from '../index-D7JdSMpp.js';
2
2
  import '@mdx-js/mdx';
3
3
  import '@standard-schema/spec';
4
- import 'fumadocs-core/mdx-plugins';
5
4
  import 'unified';
5
+ import 'fumadocs-core/mdx-plugins';
6
6
  import 'zod';
7
7
  import 'chokidar';
8
+ import 'vfile';
8
9
 
9
10
  interface JSONSchemaOptions {
10
11
  /**
@@ -0,0 +1,75 @@
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/last-modified.ts
31
+ var last_modified_exports = {};
32
+ __export(last_modified_exports, {
33
+ default: () => lastModified
34
+ });
35
+ module.exports = __toCommonJS(last_modified_exports);
36
+ var import_node_path = __toESM(require("path"), 1);
37
+ var import_tinyexec = require("tinyexec");
38
+ var cache = /* @__PURE__ */ new Map();
39
+ function lastModified(options = {}) {
40
+ const { versionControl = "git" } = options;
41
+ return {
42
+ name: "last-modified",
43
+ doc: {
44
+ async vfile(file) {
45
+ if (versionControl === "git") {
46
+ const timestamp = await getGitTimestamp(this.filePath).then(
47
+ (v) => v?.getTime()
48
+ );
49
+ if (timestamp === void 0) return;
50
+ file.data["mdx-export"] ??= [];
51
+ file.data["mdx-export"].push({
52
+ name: "lastModified",
53
+ value: timestamp
54
+ });
55
+ }
56
+ }
57
+ }
58
+ };
59
+ }
60
+ async function getGitTimestamp(file) {
61
+ const cached = cache.get(file);
62
+ if (cached) return cached;
63
+ const timePromise = (async () => {
64
+ const out = await (0, import_tinyexec.x)(
65
+ "git",
66
+ ["log", "-1", '--pretty="%ai"', import_node_path.default.relative(process.cwd(), file)],
67
+ {
68
+ throwOnError: true
69
+ }
70
+ );
71
+ return new Date(out.stdout);
72
+ })();
73
+ cache.set(file, timePromise);
74
+ return timePromise.catch(() => void 0);
75
+ }