fumadocs-mdx 11.4.1 → 11.5.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.
@@ -3,17 +3,16 @@ import {
3
3
  getConfigHash,
4
4
  loadConfig,
5
5
  loadConfigCached
6
- } from "../chunk-IU4D6M3A.js";
7
- import "../chunk-2DJQ3DOD.js";
6
+ } from "../chunk-2C4NRJ5O.js";
7
+ import "../chunk-6ZVE73IT.js";
8
8
 
9
9
  // src/next/create.ts
10
10
  import path3 from "node:path";
11
11
 
12
12
  // src/map/index.ts
13
13
  import * as path2 from "node:path";
14
- import * as fs from "node:fs";
15
- import { writeFile } from "node:fs/promises";
16
- import grayMatter from "gray-matter";
14
+ import * as fs2 from "node:fs";
15
+ import { writeFile, rm } from "node:fs/promises";
17
16
 
18
17
  // src/map/generate.ts
19
18
  import * as path from "node:path";
@@ -32,65 +31,89 @@ function getTypeFromPath(path5) {
32
31
  // src/map/generate.ts
33
32
  async function generateJS(configPath, config, outputPath, configHash, getFrontmatter) {
34
33
  const outDir2 = path.dirname(outputPath);
35
- const imports = [
36
- {
34
+ let asyncInit = false;
35
+ const lines = [
36
+ getImportCode({
37
37
  type: "named",
38
- names: ["toRuntime"],
38
+ names: ["_runtime"],
39
39
  specifier: "fumadocs-mdx"
40
- }
40
+ }),
41
+ getImportCode({
42
+ type: "namespace",
43
+ specifier: toImportPath(configPath, outDir2),
44
+ name: "_source"
45
+ })
41
46
  ];
42
- let asyncInit = false;
43
- const lines = [];
44
47
  config._runtime.files.clear();
45
48
  const entries = Array.from(config.collections.entries());
49
+ async function getEntries(collectionName, collection, files) {
50
+ const items = files.map(async (file, i) => {
51
+ config._runtime.files.set(file.absolutePath, collectionName);
52
+ const importId = `${collectionName}_${collection.type}_${i}`;
53
+ lines.unshift(
54
+ getImportCode({
55
+ type: "namespace",
56
+ name: importId,
57
+ specifier: `${toImportPath(file.absolutePath, outDir2)}?collection=${collectionName}&hash=${configHash}`
58
+ })
59
+ );
60
+ return `{ info: ${JSON.stringify(file)}, data: ${importId} }`;
61
+ });
62
+ return Promise.all(items);
63
+ }
64
+ async function getAsyncEntries(files) {
65
+ if (!asyncInit) {
66
+ lines.unshift(
67
+ getImportCode({
68
+ type: "named",
69
+ specifier: "fumadocs-mdx/runtime/async",
70
+ names: ["_runtimeAsync", "buildConfig"]
71
+ }),
72
+ "const [err, _sourceConfig] = buildConfig(_source)",
73
+ "if (!_sourceConfig) throw new Error(err)"
74
+ );
75
+ asyncInit = true;
76
+ }
77
+ const entries2 = files.map(async (file) => {
78
+ const frontmatter = await getFrontmatter(file.absolutePath);
79
+ return JSON.stringify({
80
+ info: file,
81
+ data: frontmatter
82
+ });
83
+ });
84
+ return Promise.all(entries2);
85
+ }
46
86
  const declares = entries.map(async ([k, collection]) => {
47
- const files = await getCollectionFiles(collection);
48
- if (collection.type === "doc" && collection.async) {
49
- if (!asyncInit) {
50
- imports.push(
51
- {
52
- type: "namespace",
53
- specifier: toImportPath(configPath, outDir2),
54
- name: "_source"
55
- },
56
- {
57
- type: "named",
58
- specifier: "fumadocs-mdx/runtime/async",
59
- names: ["asyncFiles", "buildConfig"]
60
- }
87
+ if (collection.type === "docs") {
88
+ const docs = await getCollectionFiles(collection.docs);
89
+ const metas = await getCollectionFiles(collection.meta);
90
+ if (collection.docs.async) {
91
+ const docsEntries2 = (await getAsyncEntries(docs)).join(", ");
92
+ const metaEntries2 = (await getEntries(k, collection.meta, metas)).join(
93
+ ", "
61
94
  );
62
- lines.unshift(
63
- "const [err, _sourceConfig] = buildConfig(_source)",
64
- "if (err) throw new Error(err)"
65
- );
66
- asyncInit = true;
95
+ return `export const ${k} = _runtimeAsync.docs<typeof _source.${k}>([${docsEntries2}], [${metaEntries2}], "${k}", _sourceConfig)`;
67
96
  }
68
- const entries2 = files.map(async (file) => {
69
- const frontmatter = await getFrontmatter(file.absolutePath);
70
- return JSON.stringify({
71
- frontmatter,
72
- file
73
- });
74
- });
75
- return `export const ${k} = asyncFiles([${(await Promise.all(entries2)).join(", ")}], "${k}", _sourceConfig)`;
97
+ const docsEntries = (await getEntries(k, collection.docs, docs)).join(
98
+ ", "
99
+ );
100
+ const metaEntries = (await getEntries(k, collection.meta, metas)).join(
101
+ ", "
102
+ );
103
+ return `export const ${k} = _runtime.docs<typeof _source.${k}>([${docsEntries}], [${metaEntries}])`;
76
104
  }
77
- const items = files.map(async (file, i) => {
78
- config._runtime.files.set(file.absolutePath, k);
79
- const importId = `${k}_${i}`;
80
- imports.push({
81
- type: "namespace",
82
- name: importId,
83
- specifier: `${toImportPath(file.absolutePath, outDir2)}?collection=${k}&hash=${configHash}`
84
- });
85
- return `toRuntime("${collection.type}", ${importId}, ${JSON.stringify(file)})`;
86
- });
87
- const resolvedItems = await Promise.all(items);
88
- return `export const ${k} = [${resolvedItems.join(", ")}];`;
105
+ const files = await getCollectionFiles(collection);
106
+ if (collection.type === "doc" && collection.async) {
107
+ return `export const ${k} = _runtimeAsync.doc<typeof _source.${k}>([${(await getAsyncEntries(files)).join(", ")}], "${k}", _sourceConfig)`;
108
+ }
109
+ return `export const ${k} = _runtime.${collection.type}<typeof _source.${k}>([${(await getEntries(k, collection, files)).join(", ")}]);`;
89
110
  });
90
111
  const resolvedDeclares = await Promise.all(declares);
91
- return [...imports.map(getImportCode), ...lines, ...resolvedDeclares].join(
92
- "\n"
93
- );
112
+ return [
113
+ `// @ts-nocheck -- skip type checking`,
114
+ ...lines,
115
+ ...resolvedDeclares
116
+ ].join("\n");
94
117
  }
95
118
  async function getCollectionFiles(collection) {
96
119
  const files = /* @__PURE__ */ new Map();
@@ -126,79 +149,75 @@ function getImportCode(info) {
126
149
  return `import ${specifier}`;
127
150
  }
128
151
  function toImportPath(file, dir) {
129
- let importPath = path.relative(dir, file);
152
+ const ext = path.extname(file);
153
+ let importPath = path.relative(
154
+ dir,
155
+ ext === ".ts" ? file.substring(0, file.length - ext.length) : file
156
+ );
130
157
  if (!path.isAbsolute(importPath) && !importPath.startsWith(".")) {
131
158
  importPath = `./${importPath}`;
132
159
  }
133
160
  return importPath.replaceAll(path.sep, "/");
134
161
  }
135
- function generateTypes(configPath, config, outputPath) {
136
- const importPath = JSON.stringify(
137
- toImportPath(configPath, path.dirname(outputPath))
138
- );
139
- const lines = [
140
- 'import type { GetOutput } from "fumadocs-mdx/config"'
141
- ];
142
- for (const name of config.collections.keys()) {
143
- lines.push(
144
- `export declare const ${name}: GetOutput<typeof import(${importPath}).${name}>`
145
- );
146
- }
147
- return lines.join("\n");
162
+
163
+ // src/utils/read-frontmatter.ts
164
+ import * as fs from "node:fs";
165
+ import grayMatter from "gray-matter";
166
+ async function readFrontmatter(file) {
167
+ const readStream = fs.createReadStream(file, {
168
+ highWaterMark: 250
169
+ });
170
+ return new Promise((res, rej) => {
171
+ let idx = 0;
172
+ let str = "";
173
+ readStream.on("data", (_chunk) => {
174
+ const chunk = _chunk.toString();
175
+ if (idx === 0 && !chunk.startsWith("---")) {
176
+ res({});
177
+ readStream.close();
178
+ return;
179
+ }
180
+ str += chunk;
181
+ idx++;
182
+ if (str.includes("\n---")) {
183
+ res(
184
+ grayMatter({
185
+ content: str
186
+ }).data
187
+ );
188
+ readStream.close();
189
+ }
190
+ });
191
+ readStream.on("end", () => res({}));
192
+ readStream.on("error", (e) => rej(e));
193
+ });
148
194
  }
149
195
 
150
196
  // src/map/index.ts
151
197
  async function start(dev, configPath, outDir2) {
198
+ void rm(path2.resolve(outDir2, `index.js`), { force: true });
199
+ void rm(path2.resolve(outDir2, `index.d.ts`), { force: true });
152
200
  let configHash = await getConfigHash(configPath);
153
201
  let config = await loadConfigCached(configPath, configHash);
154
- const jsOut = path2.resolve(outDir2, `index.js`);
155
- const typeOut = path2.resolve(outDir2, `index.d.ts`);
202
+ const outPath = path2.resolve(outDir2, `index.ts`);
156
203
  const frontmatterCache = /* @__PURE__ */ new Map();
157
204
  let hookUpdate = false;
158
- async function readFrontmatter(file) {
159
- hookUpdate = true;
160
- const cached = frontmatterCache.get(file);
161
- if (cached) return cached;
162
- const readStream = fs.createReadStream(file, {
163
- highWaterMark: 250
164
- });
165
- return new Promise((res, rej) => {
166
- let idx = 0;
167
- let str = "";
168
- readStream.on("data", (_chunk) => {
169
- const chunk = _chunk.toString();
170
- if (idx === 0 && !chunk.startsWith("---")) {
171
- res({});
172
- readStream.close();
173
- return;
174
- }
175
- str += chunk;
176
- idx++;
177
- if (str.includes("\n---")) {
178
- res(
179
- grayMatter({
180
- content: str
181
- }).data
182
- );
183
- readStream.close();
184
- }
205
+ fs2.mkdirSync(outDir2, { recursive: true });
206
+ fs2.writeFileSync(
207
+ outPath,
208
+ await generateJS(configPath, config, outPath, configHash, (file) => {
209
+ hookUpdate = true;
210
+ const cached = frontmatterCache.get(file);
211
+ if (cached) return cached;
212
+ return readFrontmatter(file).then((res) => {
213
+ frontmatterCache.set(file, res);
214
+ return res;
185
215
  });
186
- readStream.on("end", () => res({}));
187
- readStream.on("error", (e) => rej(e));
188
- }).then((res) => {
189
- frontmatterCache.set(file, res);
190
- return res;
191
- });
192
- }
193
- fs.mkdirSync(outDir2, { recursive: true });
194
- fs.writeFileSync(
195
- jsOut,
196
- await generateJS(configPath, config, jsOut, configHash, readFrontmatter)
216
+ })
197
217
  );
198
- fs.writeFileSync(typeOut, generateTypes(configPath, config, typeOut));
199
218
  console.log("[MDX] initialized map file");
200
219
  if (dev) {
201
- const { watcher } = await import("../watcher-7ALL6XOY.js");
220
+ const { watcher } = await import("../watcher-IAZDSTU7.js");
202
221
  const instance = watcher(configPath, config);
203
222
  instance.on("ready", () => {
204
223
  console.log("[MDX] started dev server");
@@ -210,17 +229,15 @@ async function start(dev, configPath, outDir2) {
210
229
  if (isConfigFile) {
211
230
  configHash = await getConfigHash(configPath);
212
231
  config = await loadConfigCached(configPath, configHash);
213
- await writeFile(typeOut, generateTypes(configPath, config, typeOut));
214
- console.log("[MDX] Updated map types");
215
232
  }
216
233
  if (isConfigFile || event !== "change" || hookUpdate) {
217
234
  if (event === "change") frontmatterCache.delete(file);
218
235
  await writeFile(
219
- jsOut,
236
+ outPath,
220
237
  await generateJS(
221
238
  configPath,
222
239
  config,
223
- jsOut,
240
+ outPath,
224
241
  configHash,
225
242
  readFrontmatter
226
243
  )
@@ -300,12 +317,22 @@ function createMDX({
300
317
 
301
318
  // src/postinstall.ts
302
319
  import * as path4 from "node:path";
303
- import * as fs2 from "node:fs";
320
+ import * as fs3 from "node:fs";
304
321
  async function postInstall(configPath = findConfigFile()) {
305
- const typeOut = path4.resolve(".source/index.d.ts");
322
+ const jsOut = path4.resolve(".source/index.ts");
306
323
  const config = await loadConfig(configPath);
307
- fs2.mkdirSync(path4.dirname(typeOut), { recursive: true });
308
- fs2.writeFileSync(typeOut, generateTypes(configPath, config, typeOut));
324
+ const hash = await getConfigHash(configPath);
325
+ fs3.mkdirSync(path4.dirname(jsOut), { recursive: true });
326
+ fs3.writeFileSync(
327
+ jsOut,
328
+ await generateJS(
329
+ configPath,
330
+ config,
331
+ path4.resolve(".source/index.ts"),
332
+ hash,
333
+ readFrontmatter
334
+ )
335
+ );
309
336
  console.log("[MDX] types generated");
310
337
  }
311
338
  export {
@@ -157,7 +157,7 @@ var init_mdx_options = __esm({
157
157
  // src/runtime/async.ts
158
158
  var async_exports = {};
159
159
  __export(async_exports, {
160
- asyncFiles: () => asyncFiles,
160
+ _runtimeAsync: () => _runtimeAsync,
161
161
  buildConfig: () => buildConfig
162
162
  });
163
163
  module.exports = __toCommonJS(async_exports);
@@ -217,6 +217,73 @@ function remarkInclude() {
217
217
  // src/runtime/async.ts
218
218
  var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
219
219
 
220
+ // src/runtime/index.ts
221
+ var _runtime = {
222
+ doc(files) {
223
+ return files.map((file) => {
224
+ const { default: body, frontmatter, ...exports2 } = file.data;
225
+ return {
226
+ body,
227
+ ...exports2,
228
+ ...frontmatter,
229
+ _exports: file.data,
230
+ _file: file.info
231
+ };
232
+ });
233
+ },
234
+ meta(files) {
235
+ return files.map((file) => {
236
+ return {
237
+ ...file.data.default,
238
+ _file: file.info
239
+ };
240
+ });
241
+ },
242
+ docs(docs, metas) {
243
+ const parsedDocs = this.doc(docs);
244
+ const parsedMetas = this.meta(metas);
245
+ return {
246
+ docs: parsedDocs,
247
+ meta: parsedMetas,
248
+ toFumadocsSource() {
249
+ return createMDXSource(parsedDocs, parsedMetas);
250
+ }
251
+ };
252
+ }
253
+ };
254
+ function createMDXSource(docs, meta = []) {
255
+ return {
256
+ files: (rootDir) => resolveFiles({
257
+ docs,
258
+ meta,
259
+ rootDir
260
+ })
261
+ };
262
+ }
263
+ function resolveFiles({
264
+ docs,
265
+ meta,
266
+ rootDir = ""
267
+ }) {
268
+ const outputs = [];
269
+ for (const entry of docs) {
270
+ if (!entry._file.path.startsWith(rootDir)) continue;
271
+ outputs.push({
272
+ type: "page",
273
+ path: entry._file.path,
274
+ data: entry
275
+ });
276
+ }
277
+ for (const entry of meta) {
278
+ outputs.push({
279
+ type: "meta",
280
+ path: entry._file.path,
281
+ data: entry
282
+ });
283
+ }
284
+ return outputs;
285
+ }
286
+
220
287
  // src/config/build.ts
221
288
  function buildConfig(config) {
222
289
  const collections = /* @__PURE__ */ new Map();
@@ -225,12 +292,15 @@ function buildConfig(config) {
225
292
  if (!v) {
226
293
  continue;
227
294
  }
228
- if (typeof v === "object" && "_doc" in v && v._doc === "collections") {
229
- collections.set(
230
- k,
231
- v
232
- );
233
- continue;
295
+ if (typeof v === "object" && "type" in v) {
296
+ if (v.type === "docs") {
297
+ collections.set(k, v);
298
+ continue;
299
+ }
300
+ if (v.type === "doc" || v.type === "meta") {
301
+ collections.set(k, v);
302
+ continue;
303
+ }
234
304
  }
235
305
  if (k === "default") {
236
306
  globalConfig = v;
@@ -266,45 +336,59 @@ function buildConfig(config) {
266
336
  }
267
337
 
268
338
  // src/runtime/async.ts
269
- function asyncFiles(files, collection, config) {
270
- async function init() {
271
- const col = config.collections.get(collection);
272
- let mdxOptions;
273
- if (col?.type === "doc" && col.mdxOptions) {
274
- mdxOptions = col.mdxOptions;
275
- } else {
276
- const options = typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions;
277
- const remarkPlugins = options?.remarkPlugins ?? [];
278
- mdxOptions = {
279
- ...options,
280
- remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), import_mdx_plugins.remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, import_mdx_plugins.remarkStructure]
281
- };
282
- }
283
- return (0, import_mdx_remote.createCompiler)(mdxOptions);
339
+ async function initCompiler(config, collection) {
340
+ let col = config.collections.get(collection);
341
+ if (col?.type === "docs") col = col.docs;
342
+ let mdxOptions;
343
+ if (col?.type === "doc" && col.mdxOptions) {
344
+ mdxOptions = col.mdxOptions;
345
+ } else {
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
+ };
284
352
  }
285
- const initCompiler = init();
286
- return files.map(({ file, frontmatter }) => {
353
+ return (0, import_mdx_remote.createCompiler)(mdxOptions);
354
+ }
355
+ var _runtimeAsync = {
356
+ doc(files, collection, config) {
357
+ const init = initCompiler(config, collection);
358
+ return files.map(({ info: file, data: frontmatter }) => {
359
+ return {
360
+ ...frontmatter,
361
+ _file: file,
362
+ async load() {
363
+ const compiler = await init;
364
+ const out = await compiler.compile({
365
+ source: (await fs2.readFile(file.absolutePath)).toString(),
366
+ filePath: file.absolutePath
367
+ });
368
+ return {
369
+ body: out.body,
370
+ toc: out.toc,
371
+ structuredData: out.vfile.data.structuredData,
372
+ _exports: out.exports ?? {}
373
+ };
374
+ }
375
+ };
376
+ });
377
+ },
378
+ docs(docs, metas, collection, config) {
379
+ const parsedDocs = this.doc(docs, collection, config);
380
+ const parsedMetas = _runtime.meta(metas);
287
381
  return {
288
- ...frontmatter,
289
- _file: file,
290
- async load() {
291
- const compiler = await initCompiler;
292
- const out = await compiler.compile({
293
- source: (await fs2.readFile(file.absolutePath)).toString(),
294
- filePath: file.absolutePath
295
- });
296
- return {
297
- body: out.body,
298
- toc: out.toc,
299
- structuredData: out.vfile.data.structuredData,
300
- _exports: out.exports ?? {}
301
- };
382
+ docs: parsedDocs,
383
+ meta: parsedMetas,
384
+ toFumadocsSource() {
385
+ return createMDXSource(parsedDocs, parsedMetas);
302
386
  }
303
387
  };
304
- });
305
- }
388
+ }
389
+ };
306
390
  // Annotate the CommonJS export names for ESM import in node:
307
391
  0 && (module.exports = {
308
- asyncFiles,
392
+ _runtimeAsync,
309
393
  buildConfig
310
394
  });
@@ -1,15 +1,17 @@
1
- import { G as GlobalConfig, F as FileInfo } from '../build-mdx-o0kbHSlp.cjs';
2
- import { D as DocCollection, M as MetaCollection } from '../define-BB9hRiTI.cjs';
1
+ import { D as DocCollection, c as MetaCollection, d as DocsCollection, G as GlobalConfig, e as defineCollections, B as BaseCollectionEntry, M as MarkdownProps } from '../define-_brlBG8j.cjs';
3
2
  import { ProcessorOptions } from '@mdx-js/mdx';
4
- import 'zod';
3
+ import { StandardSchemaV1 } from '@standard-schema/spec';
4
+ import { RuntimeFile, _runtime } from '../index.cjs';
5
+ import { Source, PageData, MetaData } from 'fumadocs-core/source';
5
6
  import 'mdx/types';
6
7
  import 'fumadocs-core/mdx-plugins';
7
8
  import 'fumadocs-core/server';
8
9
  import 'unified';
9
10
  import 'react';
11
+ import 'zod';
10
12
 
11
13
  interface LoadedConfig {
12
- collections: Map<string, InternalDocCollection | InternalMetaCollection>;
14
+ collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
13
15
  getDefaultMDXOptions: () => Promise<ProcessorOptions>;
14
16
  global?: GlobalConfig;
15
17
  _runtime: {
@@ -19,17 +21,26 @@ interface LoadedConfig {
19
21
  files: Map<string, string>;
20
22
  };
21
23
  }
22
- type InternalDocCollection = DocCollection;
23
- type InternalMetaCollection = MetaCollection;
24
24
 
25
25
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
26
26
 
27
- /**
28
- * @internal
29
- */
30
- declare function asyncFiles(files: {
31
- file: FileInfo;
32
- frontmatter: Record<string, unknown>;
33
- }[], collection: string, config: LoadedConfig): unknown[];
27
+ interface RuntimeAsync {
28
+ doc: <C>(files: RuntimeFile[], collection: string, config: LoadedConfig) => C extends ReturnType<typeof defineCollections<'doc', infer Schema extends StandardSchemaV1, true>> ? (StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
29
+ load: () => Promise<MarkdownProps>;
30
+ })[] : never;
31
+ docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => Docs extends {
32
+ type: 'docs';
33
+ docs: unknown;
34
+ meta: unknown;
35
+ } ? {
36
+ docs: ReturnType<typeof _runtimeAsync.doc<Docs['docs']>>;
37
+ meta: ReturnType<typeof _runtime.meta<Docs['meta']>>;
38
+ toFumadocsSource: () => Source<{
39
+ pageData: ReturnType<typeof _runtimeAsync.doc<Docs['docs']>>[number] extends PageData & BaseCollectionEntry ? ReturnType<typeof _runtimeAsync.doc<Docs['docs']>>[number] : never;
40
+ metaData: ReturnType<typeof _runtime.meta<Docs['meta']>>[number] extends MetaData & BaseCollectionEntry ? ReturnType<typeof _runtime.meta<Docs['meta']>>[number] : never;
41
+ }>;
42
+ } : never;
43
+ }
44
+ declare const _runtimeAsync: RuntimeAsync;
34
45
 
35
- export { asyncFiles, buildConfig };
46
+ export { type RuntimeAsync, _runtimeAsync, buildConfig };
@@ -1,15 +1,17 @@
1
- import { G as GlobalConfig, F as FileInfo } from '../build-mdx-o0kbHSlp.js';
2
- import { D as DocCollection, M as MetaCollection } from '../define-D3l733EX.js';
1
+ import { D as DocCollection, c as MetaCollection, d as DocsCollection, G as GlobalConfig, e as defineCollections, B as BaseCollectionEntry, M as MarkdownProps } from '../define-_brlBG8j.js';
3
2
  import { ProcessorOptions } from '@mdx-js/mdx';
4
- import 'zod';
3
+ import { StandardSchemaV1 } from '@standard-schema/spec';
4
+ import { RuntimeFile, _runtime } from '../index.js';
5
+ import { Source, PageData, MetaData } from 'fumadocs-core/source';
5
6
  import 'mdx/types';
6
7
  import 'fumadocs-core/mdx-plugins';
7
8
  import 'fumadocs-core/server';
8
9
  import 'unified';
9
10
  import 'react';
11
+ import 'zod';
10
12
 
11
13
  interface LoadedConfig {
12
- collections: Map<string, InternalDocCollection | InternalMetaCollection>;
14
+ collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
13
15
  getDefaultMDXOptions: () => Promise<ProcessorOptions>;
14
16
  global?: GlobalConfig;
15
17
  _runtime: {
@@ -19,17 +21,26 @@ interface LoadedConfig {
19
21
  files: Map<string, string>;
20
22
  };
21
23
  }
22
- type InternalDocCollection = DocCollection;
23
- type InternalMetaCollection = MetaCollection;
24
24
 
25
25
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
26
26
 
27
- /**
28
- * @internal
29
- */
30
- declare function asyncFiles(files: {
31
- file: FileInfo;
32
- frontmatter: Record<string, unknown>;
33
- }[], collection: string, config: LoadedConfig): unknown[];
27
+ interface RuntimeAsync {
28
+ doc: <C>(files: RuntimeFile[], collection: string, config: LoadedConfig) => C extends ReturnType<typeof defineCollections<'doc', infer Schema extends StandardSchemaV1, true>> ? (StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
29
+ load: () => Promise<MarkdownProps>;
30
+ })[] : never;
31
+ docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => Docs extends {
32
+ type: 'docs';
33
+ docs: unknown;
34
+ meta: unknown;
35
+ } ? {
36
+ docs: ReturnType<typeof _runtimeAsync.doc<Docs['docs']>>;
37
+ meta: ReturnType<typeof _runtime.meta<Docs['meta']>>;
38
+ toFumadocsSource: () => Source<{
39
+ pageData: ReturnType<typeof _runtimeAsync.doc<Docs['docs']>>[number] extends PageData & BaseCollectionEntry ? ReturnType<typeof _runtimeAsync.doc<Docs['docs']>>[number] : never;
40
+ metaData: ReturnType<typeof _runtime.meta<Docs['meta']>>[number] extends MetaData & BaseCollectionEntry ? ReturnType<typeof _runtime.meta<Docs['meta']>>[number] : never;
41
+ }>;
42
+ } : never;
43
+ }
44
+ declare const _runtimeAsync: RuntimeAsync;
34
45
 
35
- export { asyncFiles, buildConfig };
46
+ export { type RuntimeAsync, _runtimeAsync, buildConfig };