fumadocs-mdx 14.0.4 → 14.1.1

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 (42) hide show
  1. package/dist/{build-mdx-W3233QBZ.js → build-mdx-RXJZQXGA.js} +2 -2
  2. package/dist/bun/index.d.ts +2 -2
  3. package/dist/bun/index.js +6 -6
  4. package/dist/{chunk-CGGDM5F3.js → chunk-257RZJEQ.js} +1 -1
  5. package/dist/{chunk-WBIHDYMN.js → chunk-2PY3JUIC.js} +4 -4
  6. package/dist/{chunk-KOPLIEVQ.js → chunk-7W73RILB.js} +2 -1
  7. package/dist/{chunk-LPX7ZO66.js → chunk-DTFUANSF.js} +1 -1
  8. package/dist/{chunk-K4KWUM3J.js → chunk-KWSETXYC.js} +83 -34
  9. package/dist/{chunk-6RPNS75C.js → chunk-OLD35ARB.js} +43 -31
  10. package/dist/{chunk-ED3ON275.js → chunk-STLEUNK7.js} +87 -82
  11. package/dist/{chunk-USWQVJWR.js → chunk-T6G5VOED.js} +21 -12
  12. package/dist/{chunk-NKIL543T.js → chunk-WSQ23PNV.js} +18 -20
  13. package/dist/{chunk-FBLMK4RS.js → chunk-Y7ISNZ7X.js} +22 -16
  14. package/dist/{chunk-TYJDYTKH.js → chunk-ZAYZWFWP.js} +10 -6
  15. package/dist/config/index.d.ts +2 -2
  16. package/dist/config/index.js +6 -5
  17. package/dist/{core-C3QZSdEx.d.ts → core-nagEel33.d.ts} +50 -41
  18. package/dist/index-BqkSNsGO.d.ts +8 -0
  19. package/dist/index.d.ts +2 -2
  20. package/dist/{load-from-file-OZ5N7DXU.js → load-from-file-FHW724YY.js} +2 -2
  21. package/dist/next/index.cjs +251 -201
  22. package/dist/next/index.d.ts +2 -2
  23. package/dist/next/index.js +21 -36
  24. package/dist/node/loader.js +5 -5
  25. package/dist/plugins/index-file.d.ts +2 -2
  26. package/dist/plugins/index-file.js +2 -2
  27. package/dist/plugins/json-schema.d.ts +2 -2
  28. package/dist/plugins/json-schema.js +4 -7
  29. package/dist/plugins/last-modified.d.ts +2 -2
  30. package/dist/plugins/last-modified.js +20 -13
  31. package/dist/runtime/browser.d.ts +2 -2
  32. package/dist/runtime/dynamic.d.ts +2 -2
  33. package/dist/runtime/dynamic.js +6 -6
  34. package/dist/runtime/server.d.ts +2 -2
  35. package/dist/vite/index.d.ts +2 -2
  36. package/dist/vite/index.js +16 -18
  37. package/dist/webpack/mdx.d.ts +1 -15
  38. package/dist/webpack/mdx.js +5 -5
  39. package/dist/webpack/meta.d.ts +1 -15
  40. package/dist/webpack/meta.js +5 -5
  41. package/package.json +14 -15
  42. package/dist/index-DG1I0CwF.d.ts +0 -8
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  remarkInclude
3
- } from "../chunk-FBLMK4RS.js";
3
+ } from "../chunk-Y7ISNZ7X.js";
4
4
  import {
5
5
  applyMdxPreset
6
6
  } from "../chunk-S7KOJHHO.js";
7
7
  import "../chunk-VWJKRQZR.js";
8
8
 
9
- // src/config/zod-4.ts
9
+ // ../core/dist/source/schema.js
10
10
  import { z } from "zod";
11
11
  var metaSchema = z.object({
12
12
  title: z.string().optional(),
@@ -14,9 +14,10 @@ var metaSchema = z.object({
14
14
  description: z.string().optional(),
15
15
  root: z.boolean().optional(),
16
16
  defaultOpen: z.boolean().optional(),
17
+ collapsible: z.boolean().optional(),
17
18
  icon: z.string().optional()
18
19
  });
19
- var frontmatterSchema = z.object({
20
+ var pageSchema = z.object({
20
21
  title: z.string(),
21
22
  description: z.string().optional(),
22
23
  icon: z.string().optional(),
@@ -37,7 +38,7 @@ function defineDocs(options) {
37
38
  docs: defineCollections({
38
39
  type: "doc",
39
40
  dir,
40
- schema: frontmatterSchema,
41
+ schema: pageSchema,
41
42
  ...options?.docs
42
43
  }),
43
44
  meta: defineCollections({
@@ -56,7 +57,7 @@ export {
56
57
  defineCollections,
57
58
  defineConfig,
58
59
  defineDocs,
59
- frontmatterSchema,
60
+ pageSchema as frontmatterSchema,
60
61
  metaSchema,
61
62
  remarkInclude
62
63
  };
@@ -2,7 +2,7 @@ import { ProcessorOptions } from '@mdx-js/mdx';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  import { Pluggable } from 'unified';
4
4
  import * as Plugins from 'fumadocs-core/mdx-plugins';
5
- import { z } from 'zod';
5
+ import { pageSchema, metaSchema } from 'fumadocs-core/source/schema';
6
6
  import { FSWatcher } from 'chokidar';
7
7
  import { VFile } from 'vfile';
8
8
  import { PageData, MetaData, Source } from 'fumadocs-core/source';
@@ -33,28 +33,6 @@ type MDXPresetOptions = ({
33
33
  */
34
34
  declare function applyMdxPreset(options?: MDXPresetOptions): (environment: BuildEnvironment) => Promise<ProcessorOptions>;
35
35
 
36
- /**
37
- * Zod 4 schema
38
- */
39
- declare const metaSchema: z.ZodObject<{
40
- title: z.ZodOptional<z.ZodString>;
41
- pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
42
- description: z.ZodOptional<z.ZodString>;
43
- root: z.ZodOptional<z.ZodBoolean>;
44
- defaultOpen: z.ZodOptional<z.ZodBoolean>;
45
- icon: z.ZodOptional<z.ZodString>;
46
- }, z.core.$strip>;
47
- /**
48
- * Zod 4 schema
49
- */
50
- declare const frontmatterSchema: z.ZodObject<{
51
- title: z.ZodString;
52
- description: z.ZodOptional<z.ZodString>;
53
- icon: z.ZodOptional<z.ZodString>;
54
- full: z.ZodOptional<z.ZodBoolean>;
55
- _openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
56
- }, z.core.$strip>;
57
-
58
36
  interface ExtractedReference {
59
37
  href: string;
60
38
  }
@@ -128,10 +106,12 @@ interface GlobalConfig {
128
106
  plugins?: PluginOption[];
129
107
  /**
130
108
  * Configure global MDX options
131
- *
132
- * @remarks `MDXPresetOptions`
133
109
  */
134
110
  mdxOptions?: MDXPresetOptions | (() => Promise<MDXPresetOptions>);
111
+ workspaces?: Record<string, {
112
+ dir: string;
113
+ config: Record<string, unknown>;
114
+ }>;
135
115
  /**
136
116
  * specify a directory to access & store cache (disabled during development mode).
137
117
  *
@@ -141,7 +121,7 @@ interface GlobalConfig {
141
121
  }
142
122
  declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: DocCollection<Schema>): DocCollection<Schema>;
143
123
  declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: MetaCollection<Schema>): MetaCollection<Schema>;
144
- declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema>(options: {
124
+ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof pageSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema>(options: {
145
125
  /**
146
126
  * The content directory to scan files
147
127
  *
@@ -155,25 +135,31 @@ declare function defineConfig(config?: GlobalConfig): GlobalConfig;
155
135
 
156
136
  type BuildEnvironment = 'bundler' | 'runtime';
157
137
  interface LoadedConfig {
158
- collectionList: CollectionItem[];
159
- getCollection(name: string): CollectionItem | undefined;
138
+ collections: Map<string, CollectionItem>;
160
139
  global: GlobalConfig;
161
140
  getMDXOptions(collection?: DocCollectionItem, environment?: BuildEnvironment): ProcessorOptions | Promise<ProcessorOptions>;
141
+ workspaces: Record<string, {
142
+ dir: string;
143
+ config: LoadedConfig;
144
+ }>;
162
145
  }
163
146
  type CollectionItem = MetaCollectionItem | DocCollectionItem | DocsCollectionItem;
164
- type PrimitiveCollectionItem<T extends DocCollection | MetaCollection> = Omit<T, 'files'> & {
147
+ interface PrimitiveCollectionItem {
165
148
  name: string;
149
+ cwd: string;
150
+ /**
151
+ * content directory (absolute)
152
+ */
153
+ dir: string;
166
154
  hasFile: (filePath: string) => boolean;
167
155
  isFileSupported: (filePath: string) => boolean;
168
156
  patterns: string[];
169
- };
170
- type MetaCollectionItem = PrimitiveCollectionItem<MetaCollection>;
171
- type DocCollectionItem = PrimitiveCollectionItem<DocCollection>;
172
- interface DocsCollectionItem extends DocsCollection {
173
- name: string;
157
+ }
158
+ type MetaCollectionItem = PrimitiveCollectionItem & Omit<MetaCollection, 'files' | 'dir'>;
159
+ type DocCollectionItem = PrimitiveCollectionItem & Omit<DocCollection, 'files' | 'dir'>;
160
+ interface DocsCollectionItem extends Omit<DocsCollection, 'dir' | 'meta' | 'docs'>, Omit<PrimitiveCollectionItem, 'patterns'> {
174
161
  meta: MetaCollectionItem;
175
162
  docs: DocCollectionItem;
176
- hasFile: (filePath: string) => boolean;
177
163
  }
178
164
 
179
165
  type MetaCollectionEntry<Data> = Data & MetaMethods;
@@ -249,7 +235,7 @@ interface EmitEntry {
249
235
  path: string;
250
236
  content: string;
251
237
  }
252
- interface PluginContext extends CoreOptions {
238
+ interface PluginContext {
253
239
  core: Core;
254
240
  }
255
241
  type CompilationContext<Collection> = PluginContext & TransformOptions<Collection>;
@@ -289,7 +275,7 @@ interface Plugin extends IndexFilePlugin {
289
275
  vfile?: (this: CompilationContext<DocCollectionItem>, file: VFile) => Awaitable<VFile | void>;
290
276
  };
291
277
  }
292
- type PluginOption = Awaitable<Plugin | PluginOption[] | false>;
278
+ type PluginOption = Awaitable<Plugin | PluginOption[] | false | undefined>;
293
279
  interface ServerContext {
294
280
  /**
295
281
  * the file watcher, by default all content files are watched, along with other files.
@@ -302,18 +288,39 @@ interface CoreOptions {
302
288
  environment: string;
303
289
  configPath: string;
304
290
  outDir: string;
291
+ plugins?: PluginOption[];
292
+ /**
293
+ * the workspace info if this instance is created as a workspace
294
+ */
295
+ workspace?: {
296
+ parent: Core;
297
+ name: string;
298
+ dir: string;
299
+ };
305
300
  }
306
301
  interface EmitOptions {
307
302
  /**
308
303
  * filter the plugins to run emit
309
304
  */
310
305
  filterPlugin?: (plugin: Plugin) => boolean;
306
+ /**
307
+ * filter the workspaces to run emit
308
+ */
309
+ filterWorkspace?: (workspace: string) => boolean;
310
+ /**
311
+ * write files
312
+ */
313
+ write?: boolean;
314
+ }
315
+ interface EmitOutput {
316
+ entries: EmitEntry[];
317
+ workspaces: Record<string, EmitEntry[]>;
311
318
  }
312
319
  declare const _Defaults: {
313
320
  configPath: string;
314
321
  outDir: string;
315
322
  };
316
- declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[]): {
323
+ declare function createCore(options: CoreOptions): {
317
324
  /**
318
325
  * Convenient cache store, reset when config changes
319
326
  */
@@ -321,6 +328,7 @@ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[
321
328
  init({ config: newConfig }: {
322
329
  config: Awaitable<LoadedConfig>;
323
330
  }): Promise<void>;
331
+ getWorkspaces(): Map<string, /*elided*/ any>;
324
332
  getOptions(): CoreOptions;
325
333
  getConfig(): LoadedConfig;
326
334
  /**
@@ -328,14 +336,15 @@ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[
328
336
  */
329
337
  getCompiledConfigPath(): string;
330
338
  getPlugins(): Plugin[];
339
+ getCollections(): CollectionItem[];
340
+ getCollection(name: string): CollectionItem | undefined;
331
341
  getPluginContext(): PluginContext;
332
342
  initServer(server: ServerContext): Promise<void>;
333
- emit({ filterPlugin }?: EmitOptions): Promise<EmitEntry[]>;
334
- emitAndWrite(emitOptions?: EmitOptions): Promise<void>;
343
+ emit(emitOptions?: EmitOptions): Promise<EmitOutput>;
335
344
  transformMeta(options: TransformOptions<MetaCollectionItem>, data: unknown): Promise<unknown>;
336
345
  transformFrontmatter(options: TransformOptions<DocCollectionItem>, data: Record<string, unknown>): Promise<Record<string, unknown>>;
337
346
  transformVFile(options: TransformOptions<DocCollectionItem>, file: VFile): Promise<VFile>;
338
347
  };
339
348
  type Core = ReturnType<typeof createCore>;
340
349
 
341
- export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DocCollection as D, type ExtractedReference as E, toFumadocsSource as F, type GlobalConfig as G, indexFile as H, type IndexFilePluginOptions as I, type IndexFilePlugin as J, type MetaCollection as M, type PostprocessOptions as P, type ServerOptions as S, type TransformOptions as T, _Defaults as _, type CollectionSchema as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, type DefaultMDXOptions as f, type MDXPresetOptions as g, applyMdxPreset as h, frontmatterSchema as i, type Plugin as j, type AsyncDocCollectionEntry as k, type AsyncDocsCollectionEntry as l, metaSchema as m, type EmitEntry as n, type PluginContext as o, type CompilationContext as p, type PluginOption as q, type ServerContext as r, type EmitOptions as s, createCore as t, type Core as u, type MetaCollectionEntry as v, type DocCollectionEntry as w, type DocsCollectionEntry as x, type ServerCreate as y, server as z };
350
+ export { type AnyCollection as A, type BaseCollection as B, type CollectionSchema as C, type DocCollection as D, type ExtractedReference as E, indexFile as F, type GlobalConfig as G, type IndexFilePlugin as H, type IndexFilePluginOptions as I, type MetaCollection as M, type PostprocessOptions as P, type ServerOptions as S, type TransformOptions as T, _Defaults as _, type DocsCollection as a, defineDocs as b, defineConfig as c, defineCollections as d, type DefaultMDXOptions as e, type MDXPresetOptions as f, applyMdxPreset as g, type CoreOptions as h, type Plugin as i, type AsyncDocCollectionEntry as j, type AsyncDocsCollectionEntry as k, type EmitEntry as l, type PluginContext as m, type CompilationContext as n, type PluginOption as o, type ServerContext as p, type EmitOptions as q, type EmitOutput as r, createCore as s, type Core as t, type MetaCollectionEntry as u, type DocCollectionEntry as v, type DocsCollectionEntry as w, type ServerCreate as x, server as y, toFumadocsSource as z };
@@ -0,0 +1,8 @@
1
+ interface WebpackLoaderOptions {
2
+ absoluteCompiledConfigPath: string;
3
+ configPath: string;
4
+ outDir: string;
5
+ isDev: boolean;
6
+ }
7
+
8
+ export type { WebpackLoaderOptions as W };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { p as CompilationContext, u as Core, C as CoreOptions, n as EmitEntry, s as EmitOptions, E as ExtractedReference, j as Plugin, o as PluginContext, q as PluginOption, r as ServerContext, T as TransformOptions, _ as _Defaults, t as createCore } from './core-C3QZSdEx.js';
1
+ export { n as CompilationContext, t as Core, h as CoreOptions, l as EmitEntry, q as EmitOptions, r as EmitOutput, E as ExtractedReference, i as Plugin, m as PluginContext, o as PluginOption, p as ServerContext, T as TransformOptions, _ as _Defaults, s as createCore } from './core-nagEel33.js';
2
2
  import { createProcessor } from '@mdx-js/mdx';
3
3
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
4
4
  import { TOCItemType } from 'fumadocs-core/toc';
@@ -6,7 +6,7 @@ import { FC } from 'react';
6
6
  import { MDXProps } from 'mdx/types';
7
7
  import '@standard-schema/spec';
8
8
  import 'unified';
9
- import 'zod';
9
+ import 'fumadocs-core/source/schema';
10
10
  import 'chokidar';
11
11
  import 'vfile';
12
12
  import 'fumadocs-core/source';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  loadConfig
3
- } from "./chunk-LPX7ZO66.js";
4
- import "./chunk-6RPNS75C.js";
3
+ } from "./chunk-DTFUANSF.js";
4
+ import "./chunk-OLD35ARB.js";
5
5
  import "./chunk-S7KOJHHO.js";
6
6
  export {
7
7
  loadConfig