fumadocs-mdx 11.5.1 → 11.5.2

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.
@@ -2,19 +2,17 @@ import {
2
2
  buildConfig
3
3
  } from "./chunk-6ZVE73IT.js";
4
4
 
5
- // src/utils/config-cache.ts
5
+ // src/utils/config.ts
6
6
  import { createHash } from "node:crypto";
7
7
  import * as fs from "node:fs";
8
-
9
- // src/utils/load-config.ts
10
8
  import * as path from "node:path";
11
9
  import { pathToFileURL } from "node:url";
12
10
  function findConfigFile() {
13
11
  return path.resolve("source.config.ts");
14
12
  }
15
- async function loadConfig(configPath) {
13
+ var cache = /* @__PURE__ */ new Map();
14
+ async function compileConfig(configPath) {
16
15
  const { build } = await import("esbuild");
17
- const url = pathToFileURL(path.resolve(".source/source.config.mjs"));
18
16
  const transformed = await build({
19
17
  entryPoints: [{ in: configPath, out: "source.config" }],
20
18
  bundle: true,
@@ -32,23 +30,22 @@ async function loadConfig(configPath) {
32
30
  if (transformed.errors.length > 0) {
33
31
  throw new Error("failed to compile configuration file");
34
32
  }
35
- const loaded = await import(`${url.href}?hash=${Date.now().toString()}`);
36
- const [err, config] = buildConfig(
37
- // every call to `loadConfig` will cause the previous cache to be ignored
38
- loaded
39
- );
40
- if (err !== null) throw new Error(err);
41
- return config;
42
33
  }
43
-
44
- // src/utils/config-cache.ts
45
- var cache = /* @__PURE__ */ new Map();
46
- async function loadConfigCached(configPath, hash) {
34
+ async function loadConfig(configPath, hash, build = false) {
47
35
  const cached = cache.get(configPath);
48
36
  if (cached && cached.hash === hash) {
49
37
  return await cached.config;
50
38
  }
51
- const config = loadConfig(configPath);
39
+ if (build) await compileConfig(configPath);
40
+ const url = pathToFileURL(path.resolve(".source/source.config.mjs"));
41
+ const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
42
+ const [err, config2] = buildConfig(
43
+ // every call to `loadConfig` will cause the previous cache to be ignored
44
+ loaded
45
+ );
46
+ if (err !== null) throw new Error(err);
47
+ return config2;
48
+ });
52
49
  cache.set(configPath, { config, hash });
53
50
  return await config;
54
51
  }
@@ -64,6 +61,5 @@ async function getConfigHash(configPath) {
64
61
  export {
65
62
  findConfigFile,
66
63
  loadConfig,
67
- loadConfigCached,
68
64
  getConfigHash
69
65
  };
@@ -68,15 +68,21 @@ function defineCollections(options) {
68
68
  };
69
69
  }
70
70
  function defineDocs(options) {
71
+ if (!options)
72
+ console.warn(
73
+ "[`source.config.ts`] Deprecated: please pass options to `defineDocs()` and specify a `dir`."
74
+ );
71
75
  const dir = options?.dir ?? "content/docs";
72
76
  return {
73
77
  type: "docs",
78
+ // @ts-expect-error -- internal type inferring
74
79
  docs: defineCollections({
75
80
  type: "doc",
76
81
  dir,
77
82
  schema: frontmatterSchema,
78
83
  ...options?.docs
79
84
  }),
85
+ // @ts-expect-error -- internal type inferring
80
86
  meta: defineCollections({
81
87
  type: "meta",
82
88
  dir,
@@ -1,4 +1,4 @@
1
- export { b as BaseCollection, B as BaseCollectionEntry, i as DefaultMDXOptions, D as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, I as InferSchema, a as InferSchemaType, M as MarkdownProps, c as MetaCollection, T as TransformContext, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, j as getDefaultMDXOptions, m as metaSchema } from '../define-_brlBG8j.cjs';
1
+ export { b as BaseCollection, B as BaseCollectionEntry, i as DefaultMDXOptions, D as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, I as InferSchema, a as InferSchemaType, M as MarkdownProps, c as MetaCollection, T as TransformContext, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, j as getDefaultMDXOptions, m as metaSchema } from '../define-B4aTedg-.cjs';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@mdx-js/mdx';
@@ -1,4 +1,4 @@
1
- export { b as BaseCollection, B as BaseCollectionEntry, i as DefaultMDXOptions, D as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, I as InferSchema, a as InferSchemaType, M as MarkdownProps, c as MetaCollection, T as TransformContext, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, j as getDefaultMDXOptions, m as metaSchema } from '../define-_brlBG8j.js';
1
+ export { b as BaseCollection, B as BaseCollectionEntry, i as DefaultMDXOptions, D as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, I as InferSchema, a as InferSchemaType, M as MarkdownProps, c as MetaCollection, T as TransformContext, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, j as getDefaultMDXOptions, m as metaSchema } from '../define-B4aTedg-.js';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@mdx-js/mdx';
@@ -33,15 +33,21 @@ function defineCollections(options) {
33
33
  };
34
34
  }
35
35
  function defineDocs(options) {
36
+ if (!options)
37
+ console.warn(
38
+ "[`source.config.ts`] Deprecated: please pass options to `defineDocs()` and specify a `dir`."
39
+ );
36
40
  const dir = options?.dir ?? "content/docs";
37
41
  return {
38
42
  type: "docs",
43
+ // @ts-expect-error -- internal type inferring
39
44
  docs: defineCollections({
40
45
  type: "doc",
41
46
  dir,
42
47
  schema: frontmatterSchema,
43
48
  ...options?.docs
44
49
  }),
50
+ // @ts-expect-error -- internal type inferring
45
51
  meta: defineCollections({
46
52
  type: "meta",
47
53
  dir,
@@ -168,10 +168,11 @@ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Asyn
168
168
  */
169
169
  async?: Async;
170
170
  }
171
- interface DocsCollection {
171
+ interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
172
172
  type: 'docs';
173
- docs: DocCollection;
174
- meta: MetaCollection;
173
+ dir: string | string[];
174
+ docs: DocCollection<DocSchema, Async>;
175
+ meta: MetaCollection<MetaSchema>;
175
176
  }
176
177
  declare function defineCollections<T extends 'doc' | 'meta', Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: {
177
178
  type: T;
@@ -182,19 +183,30 @@ declare function defineCollections<T extends 'doc' | 'meta', Schema extends Stan
182
183
  schema: Schema;
183
184
  };
184
185
  };
185
- declare function defineDocs<DocData extends StandardSchemaV1 = typeof frontmatterSchema, MetaData extends StandardSchemaV1 = typeof metaSchema, DocAsync extends boolean = false>(options?: {
186
+ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema, Async extends boolean = false>(options?: {
186
187
  /**
187
188
  * The directory to scan files
188
189
  *
189
190
  * @defaultValue 'content/docs'
190
191
  */
191
192
  dir?: string | string[];
192
- docs?: Omit<DocCollection<DocData, DocAsync>, 'dir' | 'type'>;
193
- meta?: Omit<MetaCollection<MetaData>, 'dir' | 'type'>;
193
+ docs?: Omit<DocCollection<DocSchema, Async>, 'dir' | 'type'>;
194
+ meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
194
195
  }): {
195
196
  type: 'docs';
196
- docs: ReturnType<typeof defineCollections<'doc', DocData, DocAsync>>;
197
- meta: ReturnType<typeof defineCollections<'meta', MetaData, false>>;
197
+ docs: {
198
+ type: 'doc';
199
+ _type: {
200
+ schema: DocSchema;
201
+ async: Async;
202
+ };
203
+ };
204
+ meta: {
205
+ type: 'meta';
206
+ _type: {
207
+ schema: MetaSchema;
208
+ };
209
+ };
198
210
  };
199
211
  declare function defineConfig(config?: GlobalConfig): GlobalConfig;
200
212
 
@@ -168,10 +168,11 @@ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Asyn
168
168
  */
169
169
  async?: Async;
170
170
  }
171
- interface DocsCollection {
171
+ interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
172
172
  type: 'docs';
173
- docs: DocCollection;
174
- meta: MetaCollection;
173
+ dir: string | string[];
174
+ docs: DocCollection<DocSchema, Async>;
175
+ meta: MetaCollection<MetaSchema>;
175
176
  }
176
177
  declare function defineCollections<T extends 'doc' | 'meta', Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: {
177
178
  type: T;
@@ -182,19 +183,30 @@ declare function defineCollections<T extends 'doc' | 'meta', Schema extends Stan
182
183
  schema: Schema;
183
184
  };
184
185
  };
185
- declare function defineDocs<DocData extends StandardSchemaV1 = typeof frontmatterSchema, MetaData extends StandardSchemaV1 = typeof metaSchema, DocAsync extends boolean = false>(options?: {
186
+ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema, Async extends boolean = false>(options?: {
186
187
  /**
187
188
  * The directory to scan files
188
189
  *
189
190
  * @defaultValue 'content/docs'
190
191
  */
191
192
  dir?: string | string[];
192
- docs?: Omit<DocCollection<DocData, DocAsync>, 'dir' | 'type'>;
193
- meta?: Omit<MetaCollection<MetaData>, 'dir' | 'type'>;
193
+ docs?: Omit<DocCollection<DocSchema, Async>, 'dir' | 'type'>;
194
+ meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
194
195
  }): {
195
196
  type: 'docs';
196
- docs: ReturnType<typeof defineCollections<'doc', DocData, DocAsync>>;
197
- meta: ReturnType<typeof defineCollections<'meta', MetaData, false>>;
197
+ docs: {
198
+ type: 'doc';
199
+ _type: {
200
+ schema: DocSchema;
201
+ async: Async;
202
+ };
203
+ };
204
+ meta: {
205
+ type: 'meta';
206
+ _type: {
207
+ schema: MetaSchema;
208
+ };
209
+ };
198
210
  };
199
211
  declare function defineConfig(config?: GlobalConfig): GlobalConfig;
200
212
 
package/dist/index.d.cts CHANGED
@@ -1,34 +1,16 @@
1
- import { Source, PageData, MetaData, VirtualFile } from 'fumadocs-core/source';
2
- import { F as FileInfo, e as defineCollections, M as MarkdownProps, B as BaseCollectionEntry } from './define-_brlBG8j.cjs';
3
- import { StandardSchemaV1 } from '@standard-schema/spec';
1
+ import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
+ import { B as BaseCollectionEntry } from './define-B4aTedg-.cjs';
3
+ import { R as Runtime } from './types-C214DTNR.cjs';
4
+ export { a as RuntimeFile } from './types-C214DTNR.cjs';
4
5
  import '@mdx-js/mdx';
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 '@standard-schema/spec';
10
12
  import 'zod';
11
13
 
12
- interface RuntimeFile {
13
- info: FileInfo;
14
- data: Record<string, unknown>;
15
- }
16
- interface Runtime {
17
- doc: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'doc', infer Schema extends StandardSchemaV1, false>> ? (Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
18
- meta: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'meta', infer Schema extends StandardSchemaV1, false>> ? (StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
19
- docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[]) => Docs extends {
20
- type: 'docs';
21
- docs: unknown;
22
- meta: unknown;
23
- } ? {
24
- docs: ReturnType<typeof _runtime.doc<Docs['docs']>>;
25
- meta: ReturnType<typeof _runtime.meta<Docs['meta']>>;
26
- toFumadocsSource: () => Source<{
27
- pageData: ReturnType<typeof _runtime.doc<Docs['docs']>>[number] extends PageData & BaseCollectionEntry ? ReturnType<typeof _runtime.doc<Docs['docs']>>[number] : never;
28
- metaData: ReturnType<typeof _runtime.meta<Docs['meta']>>[number] extends MetaData & BaseCollectionEntry ? ReturnType<typeof _runtime.meta<Docs['meta']>>[number] : never;
29
- }>;
30
- } : never;
31
- }
32
14
  declare const _runtime: Runtime;
33
15
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
34
16
  pageData: Doc;
@@ -41,4 +23,4 @@ interface ResolveOptions {
41
23
  }
42
24
  declare function resolveFiles({ docs, meta, rootDir, }: ResolveOptions): VirtualFile[];
43
25
 
44
- export { type Runtime, type RuntimeFile, _runtime, createMDXSource, resolveFiles };
26
+ export { _runtime, createMDXSource, resolveFiles };
package/dist/index.d.ts CHANGED
@@ -1,34 +1,16 @@
1
- import { Source, PageData, MetaData, VirtualFile } from 'fumadocs-core/source';
2
- import { F as FileInfo, e as defineCollections, M as MarkdownProps, B as BaseCollectionEntry } from './define-_brlBG8j.js';
3
- import { StandardSchemaV1 } from '@standard-schema/spec';
1
+ import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
+ import { B as BaseCollectionEntry } from './define-B4aTedg-.js';
3
+ import { R as Runtime } from './types-qPYo6njm.js';
4
+ export { a as RuntimeFile } from './types-qPYo6njm.js';
4
5
  import '@mdx-js/mdx';
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 '@standard-schema/spec';
10
12
  import 'zod';
11
13
 
12
- interface RuntimeFile {
13
- info: FileInfo;
14
- data: Record<string, unknown>;
15
- }
16
- interface Runtime {
17
- doc: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'doc', infer Schema extends StandardSchemaV1, false>> ? (Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
18
- meta: <C>(files: RuntimeFile[]) => C extends ReturnType<typeof defineCollections<'meta', infer Schema extends StandardSchemaV1, false>> ? (StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry)[] : never;
19
- docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[]) => Docs extends {
20
- type: 'docs';
21
- docs: unknown;
22
- meta: unknown;
23
- } ? {
24
- docs: ReturnType<typeof _runtime.doc<Docs['docs']>>;
25
- meta: ReturnType<typeof _runtime.meta<Docs['meta']>>;
26
- toFumadocsSource: () => Source<{
27
- pageData: ReturnType<typeof _runtime.doc<Docs['docs']>>[number] extends PageData & BaseCollectionEntry ? ReturnType<typeof _runtime.doc<Docs['docs']>>[number] : never;
28
- metaData: ReturnType<typeof _runtime.meta<Docs['meta']>>[number] extends MetaData & BaseCollectionEntry ? ReturnType<typeof _runtime.meta<Docs['meta']>>[number] : never;
29
- }>;
30
- } : never;
31
- }
32
14
  declare const _runtime: Runtime;
33
15
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
34
16
  pageData: Doc;
@@ -41,4 +23,4 @@ interface ResolveOptions {
41
23
  }
42
24
  declare function resolveFiles({ docs, meta, rootDir, }: ResolveOptions): VirtualFile[];
43
25
 
44
- export { type Runtime, type RuntimeFile, _runtime, createMDXSource, resolveFiles };
26
+ export { _runtime, createMDXSource, resolveFiles };
@@ -164,11 +164,9 @@ var path4 = __toESM(require("path"), 1);
164
164
  var import_node_querystring = require("querystring");
165
165
  var import_gray_matter2 = __toESM(require("gray-matter"), 1);
166
166
 
167
- // src/utils/config-cache.ts
167
+ // src/utils/config.ts
168
168
  var import_node_crypto = require("crypto");
169
169
  var fs = __toESM(require("fs"), 1);
170
-
171
- // src/utils/load-config.ts
172
170
  var path = __toESM(require("path"), 1);
173
171
  var import_node_url = require("url");
174
172
 
@@ -223,10 +221,10 @@ function buildConfig(config) {
223
221
  ];
224
222
  }
225
223
 
226
- // src/utils/load-config.ts
227
- async function loadConfig(configPath) {
224
+ // src/utils/config.ts
225
+ var cache = /* @__PURE__ */ new Map();
226
+ async function compileConfig(configPath) {
228
227
  const { build } = await import("esbuild");
229
- const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
230
228
  const transformed = await build({
231
229
  entryPoints: [{ in: configPath, out: "source.config" }],
232
230
  bundle: true,
@@ -244,23 +242,22 @@ async function loadConfig(configPath) {
244
242
  if (transformed.errors.length > 0) {
245
243
  throw new Error("failed to compile configuration file");
246
244
  }
247
- const loaded = await import(`${url.href}?hash=${Date.now().toString()}`);
248
- const [err, config] = buildConfig(
249
- // every call to `loadConfig` will cause the previous cache to be ignored
250
- loaded
251
- );
252
- if (err !== null) throw new Error(err);
253
- return config;
254
245
  }
255
-
256
- // src/utils/config-cache.ts
257
- var cache = /* @__PURE__ */ new Map();
258
- async function loadConfigCached(configPath, hash) {
246
+ async function loadConfig(configPath, hash, build = false) {
259
247
  const cached = cache.get(configPath);
260
248
  if (cached && cached.hash === hash) {
261
249
  return await cached.config;
262
250
  }
263
- const config = loadConfig(configPath);
251
+ if (build) await compileConfig(configPath);
252
+ const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
253
+ const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
254
+ const [err, config2] = buildConfig(
255
+ // every call to `loadConfig` will cause the previous cache to be ignored
256
+ loaded
257
+ );
258
+ if (err !== null) throw new Error(err);
259
+ return config2;
260
+ });
264
261
  cache.set(configPath, { config, hash });
265
262
  return await config;
266
263
  }
@@ -328,32 +325,26 @@ function remarkInclude() {
328
325
 
329
326
  // src/utils/build-mdx.ts
330
327
  var cache2 = /* @__PURE__ */ new Map();
331
- function cacheKey(group, format) {
332
- return `${group}:${format}`;
333
- }
334
- function buildMDX(group, configHash, source, options = {}) {
328
+ async function buildMDX(cacheKey, source, options = {}) {
335
329
  const { filePath, frontmatter, data, ...rest } = options;
336
330
  let format = options.format;
337
331
  if (!format && filePath) {
338
332
  format = filePath.endsWith(".mdx") ? "mdx" : "md";
339
333
  }
340
334
  format ??= "mdx";
341
- const key = cacheKey(group, format);
335
+ const key = `${cacheKey}:${format}`;
342
336
  let cached = cache2.get(key);
343
- if (cached === void 0 || cached.configHash !== configHash) {
344
- cached = {
345
- processor: (0, import_mdx.createProcessor)({
346
- outputFormat: "program",
347
- development: process.env.NODE_ENV === "development",
348
- ...rest,
349
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
350
- format
351
- }),
352
- configHash
353
- };
337
+ if (cached === void 0) {
338
+ cached = (0, import_mdx.createProcessor)({
339
+ outputFormat: "program",
340
+ development: process.env.NODE_ENV === "development",
341
+ ...rest,
342
+ remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
343
+ format
344
+ });
354
345
  cache2.set(key, cached);
355
346
  }
356
- return cached.processor.process({
347
+ return cached.process({
357
348
  value: source,
358
349
  path: filePath,
359
350
  data: {
@@ -418,7 +409,7 @@ async function loader(source, callback) {
418
409
  hash: configHash = await getConfigHash(_ctx.configPath),
419
410
  collection: collectionId
420
411
  } = parseQuery(this.resourceQuery);
421
- const config = await loadConfigCached(_ctx.configPath, configHash);
412
+ const config = await loadConfig(_ctx.configPath, configHash);
422
413
  let collection = collectionId !== void 0 ? config.collections.get(collectionId) : void 0;
423
414
  if (collection && collection.type === "docs") collection = collection.docs;
424
415
  if (collection && collection.type !== "doc") {
@@ -431,8 +422,7 @@ async function loader(source, callback) {
431
422
  schema = schema({
432
423
  async buildMDX(v, options = mdxOptions) {
433
424
  const res = await buildMDX(
434
- collectionId ?? "global",
435
- configHash,
425
+ `${configHash}:${collectionId ?? "global"}`,
436
426
  v,
437
427
  options
438
428
  );
@@ -465,8 +455,7 @@ async function loader(source, callback) {
465
455
  this.mode === "development" ? lines(source) - lines(matter2.content) : 0
466
456
  );
467
457
  const file = await buildMDX(
468
- collectionId ?? "global",
469
- configHash,
458
+ `${configHash}:${collectionId ?? "global"}`,
470
459
  lineOffset + matter2.content,
471
460
  {
472
461
  development: this.mode === "development",
@@ -1,10 +1,10 @@
1
+ import {
2
+ getConfigHash,
3
+ loadConfig
4
+ } from "./chunk-USWGH3VH.js";
1
5
  import {
2
6
  remarkInclude
3
7
  } from "./chunk-PY2KKTR2.js";
4
- import {
5
- getConfigHash,
6
- loadConfigCached
7
- } from "./chunk-2C4NRJ5O.js";
8
8
  import "./chunk-6ZVE73IT.js";
9
9
 
10
10
  // src/loader-mdx.ts
@@ -15,32 +15,26 @@ import grayMatter from "gray-matter";
15
15
  // src/utils/build-mdx.ts
16
16
  import { createProcessor } from "@mdx-js/mdx";
17
17
  var cache = /* @__PURE__ */ new Map();
18
- function cacheKey(group, format) {
19
- return `${group}:${format}`;
20
- }
21
- function buildMDX(group, configHash, source, options = {}) {
18
+ async function buildMDX(cacheKey, source, options = {}) {
22
19
  const { filePath, frontmatter, data, ...rest } = options;
23
20
  let format = options.format;
24
21
  if (!format && filePath) {
25
22
  format = filePath.endsWith(".mdx") ? "mdx" : "md";
26
23
  }
27
24
  format ??= "mdx";
28
- const key = cacheKey(group, format);
25
+ const key = `${cacheKey}:${format}`;
29
26
  let cached = cache.get(key);
30
- if (cached === void 0 || cached.configHash !== configHash) {
31
- cached = {
32
- processor: createProcessor({
33
- outputFormat: "program",
34
- development: process.env.NODE_ENV === "development",
35
- ...rest,
36
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
37
- format
38
- }),
39
- configHash
40
- };
27
+ if (cached === void 0) {
28
+ cached = createProcessor({
29
+ outputFormat: "program",
30
+ development: process.env.NODE_ENV === "development",
31
+ ...rest,
32
+ remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
33
+ format
34
+ });
41
35
  cache.set(key, cached);
42
36
  }
43
- return cached.processor.process({
37
+ return cached.process({
44
38
  value: source,
45
39
  path: filePath,
46
40
  data: {
@@ -105,7 +99,7 @@ async function loader(source, callback) {
105
99
  hash: configHash = await getConfigHash(_ctx.configPath),
106
100
  collection: collectionId
107
101
  } = parseQuery(this.resourceQuery);
108
- const config = await loadConfigCached(_ctx.configPath, configHash);
102
+ const config = await loadConfig(_ctx.configPath, configHash);
109
103
  let collection = collectionId !== void 0 ? config.collections.get(collectionId) : void 0;
110
104
  if (collection && collection.type === "docs") collection = collection.docs;
111
105
  if (collection && collection.type !== "doc") {
@@ -118,8 +112,7 @@ async function loader(source, callback) {
118
112
  schema = schema({
119
113
  async buildMDX(v, options = mdxOptions) {
120
114
  const res = await buildMDX(
121
- collectionId ?? "global",
122
- configHash,
115
+ `${configHash}:${collectionId ?? "global"}`,
123
116
  v,
124
117
  options
125
118
  );
@@ -152,8 +145,7 @@ async function loader(source, callback) {
152
145
  this.mode === "development" ? lines(source) - lines(matter.content) : 0
153
146
  );
154
147
  const file = await buildMDX(
155
- collectionId ?? "global",
156
- configHash,
148
+ `${configHash}:${collectionId ?? "global"}`,
157
149
  lineOffset + matter.content,
158
150
  {
159
151
  development: this.mode === "development",
@@ -198,7 +198,9 @@ module.exports = __toCommonJS(next_exports);
198
198
  // src/next/create.ts
199
199
  var import_node_path2 = __toESM(require("path"), 1);
200
200
 
201
- // src/utils/load-config.ts
201
+ // src/utils/config.ts
202
+ var import_node_crypto = require("crypto");
203
+ var fs = __toESM(require("fs"), 1);
202
204
  var path = __toESM(require("path"), 1);
203
205
  var import_node_url = require("url");
204
206
 
@@ -253,13 +255,13 @@ function buildConfig(config) {
253
255
  ];
254
256
  }
255
257
 
256
- // src/utils/load-config.ts
258
+ // src/utils/config.ts
257
259
  function findConfigFile() {
258
260
  return path.resolve("source.config.ts");
259
261
  }
260
- async function loadConfig(configPath) {
262
+ var cache = /* @__PURE__ */ new Map();
263
+ async function compileConfig(configPath) {
261
264
  const { build } = await import("esbuild");
262
- const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
263
265
  const transformed = await build({
264
266
  entryPoints: [{ in: configPath, out: "source.config" }],
265
267
  bundle: true,
@@ -277,30 +279,22 @@ async function loadConfig(configPath) {
277
279
  if (transformed.errors.length > 0) {
278
280
  throw new Error("failed to compile configuration file");
279
281
  }
280
- const loaded = await import(`${url.href}?hash=${Date.now().toString()}`);
281
- const [err, config] = buildConfig(
282
- // every call to `loadConfig` will cause the previous cache to be ignored
283
- loaded
284
- );
285
- if (err !== null) throw new Error(err);
286
- return config;
287
282
  }
288
-
289
- // src/map/index.ts
290
- var path3 = __toESM(require("path"), 1);
291
- var fs3 = __toESM(require("fs"), 1);
292
- var import_promises = require("fs/promises");
293
-
294
- // src/utils/config-cache.ts
295
- var import_node_crypto = require("crypto");
296
- var fs = __toESM(require("fs"), 1);
297
- var cache = /* @__PURE__ */ new Map();
298
- async function loadConfigCached(configPath, hash) {
283
+ async function loadConfig(configPath, hash, build = false) {
299
284
  const cached = cache.get(configPath);
300
285
  if (cached && cached.hash === hash) {
301
286
  return await cached.config;
302
287
  }
303
- const config = loadConfig(configPath);
288
+ if (build) await compileConfig(configPath);
289
+ const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
290
+ const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
291
+ const [err, config2] = buildConfig(
292
+ // every call to `loadConfig` will cause the previous cache to be ignored
293
+ loaded
294
+ );
295
+ if (err !== null) throw new Error(err);
296
+ return config2;
297
+ });
304
298
  cache.set(configPath, { config, hash });
305
299
  return await config;
306
300
  }
@@ -313,6 +307,10 @@ async function getConfigHash(configPath) {
313
307
  return hash.digest("hex");
314
308
  }
315
309
 
310
+ // src/map/index.ts
311
+ var path3 = __toESM(require("path"), 1);
312
+ var fs3 = __toESM(require("fs/promises"), 1);
313
+
316
314
  // src/map/generate.ts
317
315
  var path2 = __toESM(require("path"), 1);
318
316
  var import_fast_glob = __toESM(require("fast-glob"), 1);
@@ -494,27 +492,37 @@ async function readFrontmatter(file) {
494
492
 
495
493
  // src/map/index.ts
496
494
  async function start(dev, configPath, outDir2) {
497
- void (0, import_promises.rm)(path3.resolve(outDir2, `index.js`), { force: true });
498
- void (0, import_promises.rm)(path3.resolve(outDir2, `index.d.ts`), { force: true });
495
+ void fs3.rm(path3.resolve(outDir2, `index.js`), { force: true });
496
+ void fs3.rm(path3.resolve(outDir2, `index.d.ts`), { force: true });
497
+ await fs3.mkdir(outDir2, { recursive: true });
499
498
  let configHash = await getConfigHash(configPath);
500
- let config = await loadConfigCached(configPath, configHash);
499
+ let config = await loadConfig(configPath, configHash, true);
501
500
  const outPath = path3.resolve(outDir2, `index.ts`);
502
501
  const frontmatterCache = /* @__PURE__ */ new Map();
503
502
  let hookUpdate = false;
504
- fs3.mkdirSync(outDir2, { recursive: true });
505
- fs3.writeFileSync(
506
- outPath,
507
- await generateJS(configPath, config, outPath, configHash, (file) => {
508
- hookUpdate = true;
509
- const cached = frontmatterCache.get(file);
510
- if (cached) return cached;
511
- return readFrontmatter(file).then((res) => {
512
- frontmatterCache.set(file, res);
513
- return res;
514
- });
515
- })
516
- );
517
- console.log("[MDX] initialized map file");
503
+ async function readFrontmatterWithCache(file) {
504
+ hookUpdate = true;
505
+ const cached = frontmatterCache.get(file);
506
+ if (cached) return cached;
507
+ const res = await readFrontmatter(file);
508
+ frontmatterCache.set(file, res);
509
+ return res;
510
+ }
511
+ async function updateMapFile() {
512
+ await fs3.writeFile(
513
+ outPath,
514
+ await generateJS(
515
+ configPath,
516
+ config,
517
+ outPath,
518
+ configHash,
519
+ readFrontmatterWithCache
520
+ )
521
+ );
522
+ }
523
+ console.time(`[MDX] initialize map file`);
524
+ await updateMapFile();
525
+ console.timeEnd(`[MDX] initialize map file`);
518
526
  if (dev) {
519
527
  const { watcher: watcher2 } = await Promise.resolve().then(() => (init_watcher(), watcher_exports));
520
528
  const instance = watcher2(configPath, config);
@@ -527,20 +535,11 @@ async function start(dev, configPath, outDir2) {
527
535
  const isConfigFile = path3.resolve(file) === configPath;
528
536
  if (isConfigFile) {
529
537
  configHash = await getConfigHash(configPath);
530
- config = await loadConfigCached(configPath, configHash);
538
+ config = await loadConfig(configPath, configHash, true);
531
539
  }
532
540
  if (isConfigFile || event !== "change" || hookUpdate) {
533
541
  if (event === "change") frontmatterCache.delete(file);
534
- await (0, import_promises.writeFile)(
535
- outPath,
536
- await generateJS(
537
- configPath,
538
- config,
539
- outPath,
540
- configHash,
541
- readFrontmatter
542
- )
543
- );
542
+ await updateMapFile();
544
543
  console.log("[MDX] Updated map file");
545
544
  }
546
545
  };
@@ -619,8 +618,8 @@ var path5 = __toESM(require("path"), 1);
619
618
  var fs4 = __toESM(require("fs"), 1);
620
619
  async function postInstall(configPath = findConfigFile()) {
621
620
  const jsOut = path5.resolve(".source/index.ts");
622
- const config = await loadConfig(configPath);
623
621
  const hash = await getConfigHash(configPath);
622
+ const config = await loadConfig(configPath, hash, true);
624
623
  fs4.mkdirSync(path5.dirname(jsOut), { recursive: true });
625
624
  fs4.writeFileSync(
626
625
  jsOut,
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  findConfigFile,
3
3
  getConfigHash,
4
- loadConfig,
5
- loadConfigCached
6
- } from "../chunk-2C4NRJ5O.js";
4
+ loadConfig
5
+ } from "../chunk-USWGH3VH.js";
7
6
  import "../chunk-6ZVE73IT.js";
8
7
 
9
8
  // src/next/create.ts
@@ -11,8 +10,7 @@ import path3 from "node:path";
11
10
 
12
11
  // src/map/index.ts
13
12
  import * as path2 from "node:path";
14
- import * as fs2 from "node:fs";
15
- import { writeFile, rm } from "node:fs/promises";
13
+ import * as fs2 from "node:fs/promises";
16
14
 
17
15
  // src/map/generate.ts
18
16
  import * as path from "node:path";
@@ -195,27 +193,37 @@ async function readFrontmatter(file) {
195
193
 
196
194
  // src/map/index.ts
197
195
  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 });
196
+ void fs2.rm(path2.resolve(outDir2, `index.js`), { force: true });
197
+ void fs2.rm(path2.resolve(outDir2, `index.d.ts`), { force: true });
198
+ await fs2.mkdir(outDir2, { recursive: true });
200
199
  let configHash = await getConfigHash(configPath);
201
- let config = await loadConfigCached(configPath, configHash);
200
+ let config = await loadConfig(configPath, configHash, true);
202
201
  const outPath = path2.resolve(outDir2, `index.ts`);
203
202
  const frontmatterCache = /* @__PURE__ */ new Map();
204
203
  let hookUpdate = false;
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;
215
- });
216
- })
217
- );
218
- console.log("[MDX] initialized map file");
204
+ async function readFrontmatterWithCache(file) {
205
+ hookUpdate = true;
206
+ const cached = frontmatterCache.get(file);
207
+ if (cached) return cached;
208
+ const res = await readFrontmatter(file);
209
+ frontmatterCache.set(file, res);
210
+ return res;
211
+ }
212
+ async function updateMapFile() {
213
+ await fs2.writeFile(
214
+ outPath,
215
+ await generateJS(
216
+ configPath,
217
+ config,
218
+ outPath,
219
+ configHash,
220
+ readFrontmatterWithCache
221
+ )
222
+ );
223
+ }
224
+ console.time(`[MDX] initialize map file`);
225
+ await updateMapFile();
226
+ console.timeEnd(`[MDX] initialize map file`);
219
227
  if (dev) {
220
228
  const { watcher } = await import("../watcher-IAZDSTU7.js");
221
229
  const instance = watcher(configPath, config);
@@ -228,20 +236,11 @@ async function start(dev, configPath, outDir2) {
228
236
  const isConfigFile = path2.resolve(file) === configPath;
229
237
  if (isConfigFile) {
230
238
  configHash = await getConfigHash(configPath);
231
- config = await loadConfigCached(configPath, configHash);
239
+ config = await loadConfig(configPath, configHash, true);
232
240
  }
233
241
  if (isConfigFile || event !== "change" || hookUpdate) {
234
242
  if (event === "change") frontmatterCache.delete(file);
235
- await writeFile(
236
- outPath,
237
- await generateJS(
238
- configPath,
239
- config,
240
- outPath,
241
- configHash,
242
- readFrontmatter
243
- )
244
- );
243
+ await updateMapFile();
245
244
  console.log("[MDX] Updated map file");
246
245
  }
247
246
  };
@@ -320,8 +319,8 @@ import * as path4 from "node:path";
320
319
  import * as fs3 from "node:fs";
321
320
  async function postInstall(configPath = findConfigFile()) {
322
321
  const jsOut = path4.resolve(".source/index.ts");
323
- const config = await loadConfig(configPath);
324
322
  const hash = await getConfigHash(configPath);
323
+ const config = await loadConfig(configPath, hash, true);
325
324
  fs3.mkdirSync(path4.dirname(jsOut), { recursive: true });
326
325
  fs3.writeFileSync(
327
326
  jsOut,
@@ -337,12 +337,12 @@ function buildConfig(config) {
337
337
 
338
338
  // src/runtime/async.ts
339
339
  async function initCompiler(config, collection) {
340
- let col = config.collections.get(collection);
341
- if (col?.type === "docs") col = col.docs;
342
340
  let mdxOptions;
343
- if (col?.type === "doc" && col.mdxOptions) {
344
- mdxOptions = col.mdxOptions;
345
- } else {
341
+ const col = config.collections.get(collection);
342
+ if (col?.type === "doc") mdxOptions = col.mdxOptions;
343
+ else if (col?.type === "docs")
344
+ mdxOptions = col.docs?.mdxOptions;
345
+ if (!mdxOptions) {
346
346
  const options = typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions;
347
347
  const remarkPlugins = options?.remarkPlugins ?? [];
348
348
  mdxOptions = {
@@ -1,46 +1,17 @@
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';
2
- import { ProcessorOptions } from '@mdx-js/mdx';
3
- import { StandardSchemaV1 } from '@standard-schema/spec';
4
- import { RuntimeFile, _runtime } from '../index.cjs';
5
- import { Source, PageData, MetaData } from 'fumadocs-core/source';
1
+ import { L as LoadedConfig, b as RuntimeAsync } from '../types-C214DTNR.cjs';
2
+ import '../define-B4aTedg-.cjs';
3
+ import '@mdx-js/mdx';
6
4
  import 'mdx/types';
7
5
  import 'fumadocs-core/mdx-plugins';
8
6
  import 'fumadocs-core/server';
9
7
  import 'unified';
10
8
  import 'react';
9
+ import '@standard-schema/spec';
11
10
  import 'zod';
12
-
13
- interface LoadedConfig {
14
- collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
15
- getDefaultMDXOptions: () => Promise<ProcessorOptions>;
16
- global?: GlobalConfig;
17
- _runtime: {
18
- /**
19
- * Absolute file path and their associated collections
20
- */
21
- files: Map<string, string>;
22
- };
23
- }
11
+ import 'fumadocs-core/source';
24
12
 
25
13
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
26
14
 
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
15
  declare const _runtimeAsync: RuntimeAsync;
45
16
 
46
- export { type RuntimeAsync, _runtimeAsync, buildConfig };
17
+ export { _runtimeAsync, buildConfig };
@@ -1,46 +1,17 @@
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';
2
- import { ProcessorOptions } from '@mdx-js/mdx';
3
- import { StandardSchemaV1 } from '@standard-schema/spec';
4
- import { RuntimeFile, _runtime } from '../index.js';
5
- import { Source, PageData, MetaData } from 'fumadocs-core/source';
1
+ import { L as LoadedConfig, b as RuntimeAsync } from '../types-qPYo6njm.js';
2
+ import '../define-B4aTedg-.js';
3
+ import '@mdx-js/mdx';
6
4
  import 'mdx/types';
7
5
  import 'fumadocs-core/mdx-plugins';
8
6
  import 'fumadocs-core/server';
9
7
  import 'unified';
10
8
  import 'react';
9
+ import '@standard-schema/spec';
11
10
  import 'zod';
12
-
13
- interface LoadedConfig {
14
- collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
15
- getDefaultMDXOptions: () => Promise<ProcessorOptions>;
16
- global?: GlobalConfig;
17
- _runtime: {
18
- /**
19
- * Absolute file path and their associated collections
20
- */
21
- files: Map<string, string>;
22
- };
23
- }
11
+ import 'fumadocs-core/source';
24
12
 
25
13
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
26
14
 
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
15
  declare const _runtimeAsync: RuntimeAsync;
45
16
 
46
- export { type RuntimeAsync, _runtimeAsync, buildConfig };
17
+ export { _runtimeAsync, buildConfig };
@@ -16,12 +16,12 @@ import {
16
16
  remarkStructure
17
17
  } from "fumadocs-core/mdx-plugins";
18
18
  async function initCompiler(config, collection) {
19
- let col = config.collections.get(collection);
20
- if (col?.type === "docs") col = col.docs;
21
19
  let mdxOptions;
22
- if (col?.type === "doc" && col.mdxOptions) {
23
- mdxOptions = col.mdxOptions;
24
- } else {
20
+ const col = config.collections.get(collection);
21
+ if (col?.type === "doc") mdxOptions = col.mdxOptions;
22
+ else if (col?.type === "docs")
23
+ mdxOptions = col.docs?.mdxOptions;
24
+ if (!mdxOptions) {
25
25
  const options = typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions;
26
26
  const remarkPlugins = options?.remarkPlugins ?? [];
27
27
  mdxOptions = {
@@ -0,0 +1,94 @@
1
+ import { D as DocCollection, c as MetaCollection, d as DocsCollection, G as GlobalConfig, F as FileInfo, M as MarkdownProps, B as BaseCollectionEntry } from './define-B4aTedg-.cjs';
2
+ import { StandardSchemaV1 } from '@standard-schema/spec';
3
+ import { Source, PageData, MetaData } from 'fumadocs-core/source';
4
+ import { ProcessorOptions } from '@mdx-js/mdx';
5
+
6
+ interface LoadedConfig {
7
+ collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
8
+ getDefaultMDXOptions: () => Promise<ProcessorOptions>;
9
+ global?: GlobalConfig;
10
+ _runtime: {
11
+ /**
12
+ * Absolute file path and their associated collections
13
+ */
14
+ files: Map<string, string>;
15
+ };
16
+ }
17
+
18
+ interface RuntimeFile {
19
+ info: FileInfo;
20
+ data: Record<string, unknown>;
21
+ }
22
+ type DocOut<Schema extends StandardSchemaV1> = Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
23
+ type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
24
+ interface Runtime {
25
+ doc: <C>(files: RuntimeFile[]) => C extends {
26
+ type: 'doc';
27
+ _type: {
28
+ schema: infer Schema extends StandardSchemaV1;
29
+ };
30
+ } ? DocOut<Schema>[] : never;
31
+ meta: <C>(files: RuntimeFile[]) => C extends {
32
+ type: 'meta';
33
+ _type: {
34
+ schema: infer Schema extends StandardSchemaV1;
35
+ };
36
+ } ? MetaOut<Schema>[] : never;
37
+ docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[]) => Docs extends {
38
+ type: 'docs';
39
+ docs: {
40
+ type: 'doc';
41
+ _type: {
42
+ schema: infer DocSchema extends StandardSchemaV1;
43
+ };
44
+ };
45
+ meta: {
46
+ type: 'meta';
47
+ _type: {
48
+ schema: infer MetaSchema extends StandardSchemaV1;
49
+ };
50
+ };
51
+ } ? {
52
+ docs: DocOut<DocSchema>[];
53
+ meta: MetaOut<MetaSchema>[];
54
+ toFumadocsSource: () => Source<{
55
+ pageData: DocOut<DocSchema> extends PageData ? DocOut<DocSchema> : never;
56
+ metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
57
+ }>;
58
+ } : never;
59
+ }
60
+ type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
61
+ load: () => Promise<MarkdownProps>;
62
+ };
63
+ interface RuntimeAsync {
64
+ doc: <C>(files: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
65
+ type: 'doc';
66
+ _type: {
67
+ schema: infer Schema extends StandardSchemaV1;
68
+ };
69
+ } ? AsyncDocOut<Schema>[] : never;
70
+ docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => Docs extends {
71
+ type: 'docs';
72
+ docs: {
73
+ type: 'doc';
74
+ _type: {
75
+ schema: infer DocSchema extends StandardSchemaV1;
76
+ };
77
+ };
78
+ meta: {
79
+ type: 'meta';
80
+ _type: {
81
+ schema: infer MetaSchema extends StandardSchemaV1;
82
+ };
83
+ };
84
+ } ? {
85
+ docs: AsyncDocOut<DocSchema>[];
86
+ meta: MetaOut<MetaSchema>[];
87
+ toFumadocsSource: () => Source<{
88
+ pageData: AsyncDocOut<DocSchema> extends PageData ? AsyncDocOut<DocSchema> : never;
89
+ metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
90
+ }>;
91
+ } : never;
92
+ }
93
+
94
+ export type { LoadedConfig as L, Runtime as R, RuntimeFile as a, RuntimeAsync as b };
@@ -0,0 +1,94 @@
1
+ import { D as DocCollection, c as MetaCollection, d as DocsCollection, G as GlobalConfig, F as FileInfo, M as MarkdownProps, B as BaseCollectionEntry } from './define-B4aTedg-.js';
2
+ import { StandardSchemaV1 } from '@standard-schema/spec';
3
+ import { Source, PageData, MetaData } from 'fumadocs-core/source';
4
+ import { ProcessorOptions } from '@mdx-js/mdx';
5
+
6
+ interface LoadedConfig {
7
+ collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
8
+ getDefaultMDXOptions: () => Promise<ProcessorOptions>;
9
+ global?: GlobalConfig;
10
+ _runtime: {
11
+ /**
12
+ * Absolute file path and their associated collections
13
+ */
14
+ files: Map<string, string>;
15
+ };
16
+ }
17
+
18
+ interface RuntimeFile {
19
+ info: FileInfo;
20
+ data: Record<string, unknown>;
21
+ }
22
+ type DocOut<Schema extends StandardSchemaV1> = Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
23
+ type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
24
+ interface Runtime {
25
+ doc: <C>(files: RuntimeFile[]) => C extends {
26
+ type: 'doc';
27
+ _type: {
28
+ schema: infer Schema extends StandardSchemaV1;
29
+ };
30
+ } ? DocOut<Schema>[] : never;
31
+ meta: <C>(files: RuntimeFile[]) => C extends {
32
+ type: 'meta';
33
+ _type: {
34
+ schema: infer Schema extends StandardSchemaV1;
35
+ };
36
+ } ? MetaOut<Schema>[] : never;
37
+ docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[]) => Docs extends {
38
+ type: 'docs';
39
+ docs: {
40
+ type: 'doc';
41
+ _type: {
42
+ schema: infer DocSchema extends StandardSchemaV1;
43
+ };
44
+ };
45
+ meta: {
46
+ type: 'meta';
47
+ _type: {
48
+ schema: infer MetaSchema extends StandardSchemaV1;
49
+ };
50
+ };
51
+ } ? {
52
+ docs: DocOut<DocSchema>[];
53
+ meta: MetaOut<MetaSchema>[];
54
+ toFumadocsSource: () => Source<{
55
+ pageData: DocOut<DocSchema> extends PageData ? DocOut<DocSchema> : never;
56
+ metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
57
+ }>;
58
+ } : never;
59
+ }
60
+ type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
61
+ load: () => Promise<MarkdownProps>;
62
+ };
63
+ interface RuntimeAsync {
64
+ doc: <C>(files: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
65
+ type: 'doc';
66
+ _type: {
67
+ schema: infer Schema extends StandardSchemaV1;
68
+ };
69
+ } ? AsyncDocOut<Schema>[] : never;
70
+ docs: <Docs>(docs: RuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => Docs extends {
71
+ type: 'docs';
72
+ docs: {
73
+ type: 'doc';
74
+ _type: {
75
+ schema: infer DocSchema extends StandardSchemaV1;
76
+ };
77
+ };
78
+ meta: {
79
+ type: 'meta';
80
+ _type: {
81
+ schema: infer MetaSchema extends StandardSchemaV1;
82
+ };
83
+ };
84
+ } ? {
85
+ docs: AsyncDocOut<DocSchema>[];
86
+ meta: MetaOut<MetaSchema>[];
87
+ toFumadocsSource: () => Source<{
88
+ pageData: AsyncDocOut<DocSchema> extends PageData ? AsyncDocOut<DocSchema> : never;
89
+ metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
90
+ }>;
91
+ } : never;
92
+ }
93
+
94
+ export type { LoadedConfig as L, Runtime as R, RuntimeFile as a, RuntimeAsync as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.5.1",
3
+ "version": "11.5.2",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -66,9 +66,9 @@
66
66
  "vfile": "^6.0.3",
67
67
  "webpack": "^5.97.1",
68
68
  "@fumadocs/mdx-remote": "1.2.0",
69
- "fumadocs-core": "15.0.3",
70
- "tsconfig": "0.0.0",
71
- "eslint-config-custom": "0.0.0"
69
+ "eslint-config-custom": "0.0.0",
70
+ "fumadocs-core": "15.0.5",
71
+ "tsconfig": "0.0.0"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@fumadocs/mdx-remote": "^1.2.0",