fumadocs-mdx 11.6.0 → 13.0.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 (93) hide show
  1. package/dist/bin.cjs +1728 -0
  2. package/dist/bin.d.cts +1 -0
  3. package/dist/bin.d.ts +1 -0
  4. package/dist/bin.js +16 -0
  5. package/dist/build-mdx-CCNr86q6.d.ts +53 -0
  6. package/dist/build-mdx-D-r3_eQL.d.cts +53 -0
  7. package/dist/bun/index.cjs +857 -0
  8. package/dist/bun/index.d.cts +13 -0
  9. package/dist/bun/index.d.ts +13 -0
  10. package/dist/bun/index.js +62 -0
  11. package/dist/chunk-3J3WL7WN.js +160 -0
  12. package/dist/chunk-CXA4JO4Z.js +45 -0
  13. package/dist/chunk-EELYB2XC.js +207 -0
  14. package/dist/chunk-FSZMKRVH.js +80 -0
  15. package/dist/chunk-II3H5ZVZ.js +77 -0
  16. package/dist/chunk-JVZFH6ND.js +40 -0
  17. package/dist/chunk-K5ZLPEIQ.js +207 -0
  18. package/dist/{chunk-VFALQK6O.js → chunk-KILFIBVW.js} +21 -12
  19. package/dist/chunk-NVRDCY6Z.js +30 -0
  20. package/dist/chunk-U4MQ44TS.js +53 -0
  21. package/dist/chunk-VWJKRQZR.js +19 -0
  22. package/dist/chunk-XQ5O7IPO.js +128 -0
  23. package/dist/chunk-XZY2AWJI.js +81 -0
  24. package/dist/chunk-YVCR6FUH.js +82 -0
  25. package/dist/config/index.cjs +232 -128
  26. package/dist/config/index.d.cts +4 -6
  27. package/dist/config/index.d.ts +4 -6
  28. package/dist/config/index.js +26 -19
  29. package/dist/core-B6j6Fxse.d.cts +218 -0
  30. package/dist/core-B6j6Fxse.d.ts +218 -0
  31. package/dist/index.cjs +0 -76
  32. package/dist/index.d.cts +73 -20
  33. package/dist/index.d.ts +73 -20
  34. package/dist/index.js +0 -10
  35. package/dist/load-MNG3CLET.js +7 -0
  36. package/dist/next/index.cjs +567 -314
  37. package/dist/next/index.d.cts +9 -12
  38. package/dist/next/index.d.ts +9 -12
  39. package/dist/next/index.js +238 -211
  40. package/dist/node/loader.cjs +922 -0
  41. package/dist/node/loader.d.cts +5 -0
  42. package/dist/node/loader.d.ts +5 -0
  43. package/dist/node/loader.js +33 -0
  44. package/dist/plugins/json-schema.cjs +162 -0
  45. package/dist/plugins/json-schema.d.cts +24 -0
  46. package/dist/plugins/json-schema.d.ts +24 -0
  47. package/dist/plugins/json-schema.js +78 -0
  48. package/dist/{mdx-options-CAU273O3.js → preset-ZMP6U62C.js} +1 -1
  49. package/dist/runtime/next/async.cjs +715 -0
  50. package/dist/runtime/next/async.d.cts +21 -0
  51. package/dist/runtime/next/async.d.ts +21 -0
  52. package/dist/runtime/next/async.js +89 -0
  53. package/dist/runtime/next/index.cjs +136 -0
  54. package/dist/runtime/next/index.d.cts +33 -0
  55. package/dist/runtime/next/index.d.ts +33 -0
  56. package/dist/runtime/next/index.js +11 -0
  57. package/dist/runtime/vite/browser.cjs +107 -0
  58. package/dist/runtime/vite/browser.d.cts +59 -0
  59. package/dist/runtime/vite/browser.d.ts +59 -0
  60. package/dist/runtime/vite/browser.js +11 -0
  61. package/dist/runtime/vite/server.cjs +243 -0
  62. package/dist/runtime/vite/server.d.cts +30 -0
  63. package/dist/runtime/vite/server.d.ts +30 -0
  64. package/dist/runtime/vite/server.js +111 -0
  65. package/dist/types-AGzTfBmf.d.ts +45 -0
  66. package/dist/types-DKGMoay5.d.cts +45 -0
  67. package/dist/vite/index.cjs +1185 -0
  68. package/dist/vite/index.d.cts +45 -0
  69. package/dist/vite/index.d.ts +45 -0
  70. package/dist/vite/index.js +297 -0
  71. package/dist/webpack/index.cjs +957 -0
  72. package/dist/{loader-mdx.d.cts → webpack/index.d.cts} +3 -6
  73. package/dist/{loader-mdx.d.ts → webpack/index.d.ts} +3 -6
  74. package/dist/webpack/index.js +44 -0
  75. package/loader-mdx.cjs +1 -1
  76. package/package.json +86 -29
  77. package/bin.js +0 -5
  78. package/dist/chunk-2ZOW45YZ.js +0 -63
  79. package/dist/chunk-DRVUBK5B.js +0 -39
  80. package/dist/chunk-HFLDWPJA.js +0 -62
  81. package/dist/chunk-IOENRFUX.js +0 -112
  82. package/dist/chunk-MK7EXW7O.js +0 -75
  83. package/dist/define-BaW0PQDJ.d.cts +0 -201
  84. package/dist/define-BaW0PQDJ.d.ts +0 -201
  85. package/dist/loader-mdx.cjs +0 -527
  86. package/dist/loader-mdx.js +0 -162
  87. package/dist/runtime/async.cjs +0 -269
  88. package/dist/runtime/async.d.cts +0 -18
  89. package/dist/runtime/async.d.ts +0 -18
  90. package/dist/runtime/async.js +0 -73
  91. package/dist/types-BNrQHCj5.d.cts +0 -100
  92. package/dist/types-DEduCvIT.d.ts +0 -100
  93. package/dist/watcher-IAZDSTU7.js +0 -24
@@ -0,0 +1,218 @@
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import * as plugins from 'fumadocs-core/mdx-plugins';
3
+ import { ProcessorOptions } from '@mdx-js/mdx';
4
+ import { Pluggable } from 'unified';
5
+ import { z } from 'zod';
6
+ import { FSWatcher } from 'chokidar';
7
+
8
+ interface ExtractedReference {
9
+ href: string;
10
+ }
11
+ interface PostprocessOptions {
12
+ _format: 'md' | 'mdx';
13
+ /**
14
+ * Properties to export from `vfile.data`
15
+ */
16
+ valueToExport?: string[];
17
+ /**
18
+ * stringify MDAST and export via `_markdown`.
19
+ */
20
+ includeProcessedMarkdown?: boolean;
21
+ /**
22
+ * store MDAST and export via `_mdast`.
23
+ */
24
+ includeMDAST?: boolean | {
25
+ removePosition?: boolean;
26
+ };
27
+ }
28
+
29
+ type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
30
+ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
31
+ rehypePlugins?: ResolvePlugins;
32
+ remarkPlugins?: ResolvePlugins;
33
+ /**
34
+ * Properties to export from `vfile.data`
35
+ */
36
+ valueToExport?: string[];
37
+ remarkStructureOptions?: plugins.StructureOptions | false;
38
+ remarkHeadingOptions?: plugins.RemarkHeadingOptions;
39
+ remarkImageOptions?: plugins.RemarkImageOptions | false;
40
+ remarkCodeTabOptions?: plugins.RemarkCodeTabOptions | false;
41
+ remarkNpmOptions?: plugins.RemarkNpmOptions | false;
42
+ rehypeCodeOptions?: plugins.RehypeCodeOptions | false;
43
+ _withoutBundler?: boolean;
44
+ };
45
+ declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, _withoutBundler, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
46
+
47
+ /**
48
+ * Zod 4 schema
49
+ */
50
+ declare const metaSchema: z.ZodObject<{
51
+ title: z.ZodOptional<z.ZodString>;
52
+ pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ root: z.ZodOptional<z.ZodBoolean>;
55
+ defaultOpen: z.ZodOptional<z.ZodBoolean>;
56
+ icon: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>;
58
+ /**
59
+ * Zod 4 schema
60
+ */
61
+ declare const frontmatterSchema: z.ZodObject<{
62
+ title: z.ZodString;
63
+ description: z.ZodOptional<z.ZodString>;
64
+ icon: z.ZodOptional<z.ZodString>;
65
+ full: z.ZodOptional<z.ZodBoolean>;
66
+ _openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
67
+ }, z.core.$strip>;
68
+
69
+ type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
70
+ type AnyCollection = DocsCollection | DocCollection | MetaCollection;
71
+ interface BaseCollection {
72
+ /**
73
+ * Directories to scan
74
+ */
75
+ dir: string | string[];
76
+ /**
77
+ * what files to include/exclude (glob patterns)
78
+ *
79
+ * Include all files if not specified
80
+ */
81
+ files?: string[];
82
+ }
83
+ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
84
+ type: 'meta';
85
+ schema?: CollectionSchema<Schema, {
86
+ path: string;
87
+ source: string;
88
+ }>;
89
+ }
90
+ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
91
+ type: 'doc';
92
+ postprocess?: Partial<PostprocessOptions>;
93
+ mdxOptions?: ProcessorOptions;
94
+ /**
95
+ * Load files with async
96
+ */
97
+ async?: Async;
98
+ schema?: CollectionSchema<Schema, {
99
+ path: string;
100
+ source: string;
101
+ }>;
102
+ }
103
+ interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
104
+ type: 'docs';
105
+ dir: string;
106
+ docs: DocCollection<DocSchema, Async>;
107
+ meta: MetaCollection<MetaSchema>;
108
+ }
109
+ type GlobalConfigMDXOptions = ({
110
+ preset?: 'fumadocs';
111
+ } & DefaultMDXOptions) | ({
112
+ preset: 'minimal';
113
+ } & ProcessorOptions);
114
+ interface GlobalConfig {
115
+ plugins?: PluginOption[];
116
+ /**
117
+ * Configure global MDX options
118
+ */
119
+ mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
120
+ /**
121
+ * Fetch last modified time with specified version control
122
+ * @defaultValue 'none'
123
+ */
124
+ lastModifiedTime?: 'git' | 'none';
125
+ /**
126
+ * specify a directory to access & store cache (disabled during development mode).
127
+ *
128
+ * The cache will never be updated, delete the cache folder to clean.
129
+ */
130
+ experimentalBuildCache?: string;
131
+ }
132
+ declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: DocCollection<Schema, Async>): DocCollection<Schema, Async>;
133
+ declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: MetaCollection<Schema>): MetaCollection<Schema>;
134
+ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema, Async extends boolean = false>(options: {
135
+ /**
136
+ * The content directory to scan files
137
+ *
138
+ * @defaultValue 'content/docs'
139
+ */
140
+ dir?: string;
141
+ docs?: Omit<DocCollection<DocSchema, Async>, 'dir' | 'type'>;
142
+ meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
143
+ }): DocsCollection<DocSchema, MetaSchema, Async>;
144
+ declare function defineConfig(config?: GlobalConfig): GlobalConfig;
145
+
146
+ interface ConfigLoader {
147
+ getConfig: () => LoadedConfig | Promise<LoadedConfig>;
148
+ }
149
+ interface LoadedConfig {
150
+ collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
151
+ global: GlobalConfig;
152
+ getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
153
+ }
154
+
155
+ type Awaitable<T> = T | Promise<T>;
156
+ interface EmitEntry {
157
+ /**
158
+ * path relative to output directory
159
+ */
160
+ path: string;
161
+ content: string;
162
+ }
163
+ interface PluginContext extends CoreOptions {
164
+ core: Core;
165
+ }
166
+ interface Plugin {
167
+ name?: string;
168
+ /**
169
+ * on config loaded/updated
170
+ */
171
+ config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;
172
+ /**
173
+ * Generate files (e.g. types, index file, or JSON schemas)
174
+ */
175
+ emit?: (this: PluginContext) => Awaitable<EmitEntry[]>;
176
+ /**
177
+ * Configure Fumadocs dev server
178
+ */
179
+ configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;
180
+ }
181
+ type PluginOption = Awaitable<Plugin | Plugin[] | false>;
182
+ interface ServerContext {
183
+ /**
184
+ * the file watcher, by default all content files are watched, along with other files.
185
+ *
186
+ * make sure to filter when listening to events
187
+ */
188
+ watcher?: FSWatcher;
189
+ }
190
+ interface CoreOptions {
191
+ environment: string;
192
+ configPath: string;
193
+ outDir: string;
194
+ }
195
+ interface EmitOptions {
196
+ /**
197
+ * filter the plugins to run emit
198
+ */
199
+ filterPlugin?: (plugin: Plugin) => boolean;
200
+ }
201
+ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[]): {
202
+ _options: CoreOptions;
203
+ getPluginContext(): PluginContext;
204
+ /**
205
+ * Convenient cache store, reset when config changes
206
+ */
207
+ cache: Map<string, unknown>;
208
+ init({ config: newConfig }: {
209
+ config: Awaitable<LoadedConfig>;
210
+ }): Promise</*elided*/ any>;
211
+ getConfig(): LoadedConfig;
212
+ creatConfigLoader(): ConfigLoader;
213
+ initServer(server: ServerContext): Promise<void>;
214
+ emitAndWrite({ filterPlugin, }?: EmitOptions): Promise<void>;
215
+ };
216
+ type Core = ReturnType<typeof createCore>;
217
+
218
+ export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type LoadedConfig as L, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type CollectionSchema as a, type DocCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, defineConfig as f, getDefaultMDXOptions as g, frontmatterSchema as h, type Plugin as i, type EmitEntry as j, type PluginContext as k, type PluginOption as l, metaSchema as m, type EmitOptions as n, createCore as o, type Core as p };
@@ -0,0 +1,218 @@
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import * as plugins from 'fumadocs-core/mdx-plugins';
3
+ import { ProcessorOptions } from '@mdx-js/mdx';
4
+ import { Pluggable } from 'unified';
5
+ import { z } from 'zod';
6
+ import { FSWatcher } from 'chokidar';
7
+
8
+ interface ExtractedReference {
9
+ href: string;
10
+ }
11
+ interface PostprocessOptions {
12
+ _format: 'md' | 'mdx';
13
+ /**
14
+ * Properties to export from `vfile.data`
15
+ */
16
+ valueToExport?: string[];
17
+ /**
18
+ * stringify MDAST and export via `_markdown`.
19
+ */
20
+ includeProcessedMarkdown?: boolean;
21
+ /**
22
+ * store MDAST and export via `_mdast`.
23
+ */
24
+ includeMDAST?: boolean | {
25
+ removePosition?: boolean;
26
+ };
27
+ }
28
+
29
+ type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
30
+ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
31
+ rehypePlugins?: ResolvePlugins;
32
+ remarkPlugins?: ResolvePlugins;
33
+ /**
34
+ * Properties to export from `vfile.data`
35
+ */
36
+ valueToExport?: string[];
37
+ remarkStructureOptions?: plugins.StructureOptions | false;
38
+ remarkHeadingOptions?: plugins.RemarkHeadingOptions;
39
+ remarkImageOptions?: plugins.RemarkImageOptions | false;
40
+ remarkCodeTabOptions?: plugins.RemarkCodeTabOptions | false;
41
+ remarkNpmOptions?: plugins.RemarkNpmOptions | false;
42
+ rehypeCodeOptions?: plugins.RehypeCodeOptions | false;
43
+ _withoutBundler?: boolean;
44
+ };
45
+ declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, _withoutBundler, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
46
+
47
+ /**
48
+ * Zod 4 schema
49
+ */
50
+ declare const metaSchema: z.ZodObject<{
51
+ title: z.ZodOptional<z.ZodString>;
52
+ pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ root: z.ZodOptional<z.ZodBoolean>;
55
+ defaultOpen: z.ZodOptional<z.ZodBoolean>;
56
+ icon: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>;
58
+ /**
59
+ * Zod 4 schema
60
+ */
61
+ declare const frontmatterSchema: z.ZodObject<{
62
+ title: z.ZodString;
63
+ description: z.ZodOptional<z.ZodString>;
64
+ icon: z.ZodOptional<z.ZodString>;
65
+ full: z.ZodOptional<z.ZodBoolean>;
66
+ _openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
67
+ }, z.core.$strip>;
68
+
69
+ type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
70
+ type AnyCollection = DocsCollection | DocCollection | MetaCollection;
71
+ interface BaseCollection {
72
+ /**
73
+ * Directories to scan
74
+ */
75
+ dir: string | string[];
76
+ /**
77
+ * what files to include/exclude (glob patterns)
78
+ *
79
+ * Include all files if not specified
80
+ */
81
+ files?: string[];
82
+ }
83
+ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
84
+ type: 'meta';
85
+ schema?: CollectionSchema<Schema, {
86
+ path: string;
87
+ source: string;
88
+ }>;
89
+ }
90
+ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
91
+ type: 'doc';
92
+ postprocess?: Partial<PostprocessOptions>;
93
+ mdxOptions?: ProcessorOptions;
94
+ /**
95
+ * Load files with async
96
+ */
97
+ async?: Async;
98
+ schema?: CollectionSchema<Schema, {
99
+ path: string;
100
+ source: string;
101
+ }>;
102
+ }
103
+ interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
104
+ type: 'docs';
105
+ dir: string;
106
+ docs: DocCollection<DocSchema, Async>;
107
+ meta: MetaCollection<MetaSchema>;
108
+ }
109
+ type GlobalConfigMDXOptions = ({
110
+ preset?: 'fumadocs';
111
+ } & DefaultMDXOptions) | ({
112
+ preset: 'minimal';
113
+ } & ProcessorOptions);
114
+ interface GlobalConfig {
115
+ plugins?: PluginOption[];
116
+ /**
117
+ * Configure global MDX options
118
+ */
119
+ mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
120
+ /**
121
+ * Fetch last modified time with specified version control
122
+ * @defaultValue 'none'
123
+ */
124
+ lastModifiedTime?: 'git' | 'none';
125
+ /**
126
+ * specify a directory to access & store cache (disabled during development mode).
127
+ *
128
+ * The cache will never be updated, delete the cache folder to clean.
129
+ */
130
+ experimentalBuildCache?: string;
131
+ }
132
+ declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: DocCollection<Schema, Async>): DocCollection<Schema, Async>;
133
+ declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: MetaCollection<Schema>): MetaCollection<Schema>;
134
+ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema, Async extends boolean = false>(options: {
135
+ /**
136
+ * The content directory to scan files
137
+ *
138
+ * @defaultValue 'content/docs'
139
+ */
140
+ dir?: string;
141
+ docs?: Omit<DocCollection<DocSchema, Async>, 'dir' | 'type'>;
142
+ meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
143
+ }): DocsCollection<DocSchema, MetaSchema, Async>;
144
+ declare function defineConfig(config?: GlobalConfig): GlobalConfig;
145
+
146
+ interface ConfigLoader {
147
+ getConfig: () => LoadedConfig | Promise<LoadedConfig>;
148
+ }
149
+ interface LoadedConfig {
150
+ collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
151
+ global: GlobalConfig;
152
+ getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
153
+ }
154
+
155
+ type Awaitable<T> = T | Promise<T>;
156
+ interface EmitEntry {
157
+ /**
158
+ * path relative to output directory
159
+ */
160
+ path: string;
161
+ content: string;
162
+ }
163
+ interface PluginContext extends CoreOptions {
164
+ core: Core;
165
+ }
166
+ interface Plugin {
167
+ name?: string;
168
+ /**
169
+ * on config loaded/updated
170
+ */
171
+ config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;
172
+ /**
173
+ * Generate files (e.g. types, index file, or JSON schemas)
174
+ */
175
+ emit?: (this: PluginContext) => Awaitable<EmitEntry[]>;
176
+ /**
177
+ * Configure Fumadocs dev server
178
+ */
179
+ configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;
180
+ }
181
+ type PluginOption = Awaitable<Plugin | Plugin[] | false>;
182
+ interface ServerContext {
183
+ /**
184
+ * the file watcher, by default all content files are watched, along with other files.
185
+ *
186
+ * make sure to filter when listening to events
187
+ */
188
+ watcher?: FSWatcher;
189
+ }
190
+ interface CoreOptions {
191
+ environment: string;
192
+ configPath: string;
193
+ outDir: string;
194
+ }
195
+ interface EmitOptions {
196
+ /**
197
+ * filter the plugins to run emit
198
+ */
199
+ filterPlugin?: (plugin: Plugin) => boolean;
200
+ }
201
+ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[]): {
202
+ _options: CoreOptions;
203
+ getPluginContext(): PluginContext;
204
+ /**
205
+ * Convenient cache store, reset when config changes
206
+ */
207
+ cache: Map<string, unknown>;
208
+ init({ config: newConfig }: {
209
+ config: Awaitable<LoadedConfig>;
210
+ }): Promise</*elided*/ any>;
211
+ getConfig(): LoadedConfig;
212
+ creatConfigLoader(): ConfigLoader;
213
+ initServer(server: ServerContext): Promise<void>;
214
+ emitAndWrite({ filterPlugin, }?: EmitOptions): Promise<void>;
215
+ };
216
+ type Core = ReturnType<typeof createCore>;
217
+
218
+ export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DefaultMDXOptions as D, type ExtractedReference as E, type GlobalConfig as G, type LoadedConfig as L, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type CollectionSchema as a, type DocCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, defineConfig as f, getDefaultMDXOptions as g, frontmatterSchema as h, type Plugin as i, type EmitEntry as j, type PluginContext as k, type PluginOption as l, metaSchema as m, type EmitOptions as n, createCore as o, type Core as p };
package/dist/index.cjs CHANGED
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
6
  var __copyProps = (to, from, except, desc) => {
11
7
  if (from && typeof from === "object" || typeof from === "function") {
12
8
  for (let key of __getOwnPropNames(from))
@@ -19,76 +15,4 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
15
 
20
16
  // src/index.ts
21
17
  var index_exports = {};
22
- __export(index_exports, {
23
- _runtime: () => _runtime,
24
- createMDXSource: () => createMDXSource,
25
- resolveFiles: () => resolveFiles
26
- });
27
18
  module.exports = __toCommonJS(index_exports);
28
-
29
- // src/runtime/index.ts
30
- var _runtime = {
31
- doc(files) {
32
- return files.map((file) => {
33
- const { default: body, frontmatter, ...exports2 } = file.data;
34
- return {
35
- body,
36
- ...exports2,
37
- ...frontmatter,
38
- _exports: file.data,
39
- _file: file.info
40
- };
41
- });
42
- },
43
- meta(files) {
44
- return files.map((file) => {
45
- return {
46
- ...file.data,
47
- _file: file.info
48
- };
49
- });
50
- },
51
- docs(docs, metas) {
52
- const parsedDocs = this.doc(docs);
53
- const parsedMetas = this.meta(metas);
54
- return {
55
- docs: parsedDocs,
56
- meta: parsedMetas,
57
- toFumadocsSource() {
58
- return createMDXSource(parsedDocs, parsedMetas);
59
- }
60
- };
61
- }
62
- };
63
- function createMDXSource(docs, meta = []) {
64
- return {
65
- files: () => resolveFiles({
66
- docs,
67
- meta
68
- })
69
- };
70
- }
71
- function resolveFiles({ docs, meta }) {
72
- const outputs = [];
73
- for (const entry of docs) {
74
- outputs.push({
75
- type: "page",
76
- path: entry._file.path,
77
- data: entry
78
- });
79
- }
80
- for (const entry of meta) {
81
- outputs.push({
82
- type: "meta",
83
- path: entry._file.path,
84
- data: entry
85
- });
86
- }
87
- return outputs;
88
- }
89
- // Annotate the CommonJS export names for ESM import in node:
90
- 0 && (module.exports = {
91
- _runtime,
92
- createMDXSource,
93
- resolveFiles
94
- });
package/dist/index.d.cts CHANGED
@@ -1,26 +1,79 @@
1
- import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { B as BaseCollectionEntry } from './define-BaW0PQDJ.cjs';
3
- import { R as Runtime } from './types-BNrQHCj5.cjs';
1
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
+ import { TOCItemType } from 'fumadocs-core/toc';
3
+ import { MDXContent } from 'mdx/types';
4
+ import { E as ExtractedReference } from './core-B6j6Fxse.cjs';
5
+ export { p as Core, C as CoreOptions, j as EmitEntry, n as EmitOptions, i as Plugin, k as PluginContext, l as PluginOption, S as ServerContext, o as createCore } from './core-B6j6Fxse.cjs';
6
+ import { Root } from 'mdast';
7
+ import { C as CompiledMDXProperties } from './build-mdx-D-r3_eQL.cjs';
8
+ import '@standard-schema/spec';
4
9
  import '@mdx-js/mdx';
5
- import 'mdx/types';
6
- import 'fumadocs-core/mdx-plugins';
7
- import 'fumadocs-core/server';
8
10
  import 'unified';
9
- import 'react';
10
11
  import 'zod';
11
- import '@standard-schema/spec';
12
- import '@fumadocs/mdx-remote';
12
+ import 'chokidar';
13
+ import 'react';
13
14
 
14
- declare const _runtime: Runtime;
15
- declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
16
- pageData: Doc;
17
- metaData: Meta;
18
- }>;
19
- interface ResolveOptions {
20
- docs: BaseCollectionEntry[];
21
- meta: BaseCollectionEntry[];
22
- rootDir?: string;
15
+ interface FileInfo {
16
+ /**
17
+ * virtualized path for Source API
18
+ */
19
+ path: string;
20
+ /**
21
+ * the file path in file system
22
+ */
23
+ fullPath: string;
24
+ }
25
+ interface DocData {
26
+ /**
27
+ * Compiled MDX content (as component)
28
+ */
29
+ body: MDXContent;
30
+ /**
31
+ * table of contents generated from content.
32
+ */
33
+ toc: TOCItemType[];
34
+ /**
35
+ * structured data for document search indexing.
36
+ */
37
+ structuredData: StructuredData;
38
+ /**
39
+ * Raw exports from the compiled MDX file.
40
+ */
41
+ _exports: Record<string, unknown>;
42
+ /**
43
+ * Last modified date of document file, obtained from version control.
44
+ *
45
+ * Only available when `lastModifiedTime` is enabled on global config.
46
+ */
47
+ lastModified?: Date;
48
+ /**
49
+ * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
50
+ */
51
+ extractedReferences?: ExtractedReference[];
52
+ }
53
+ interface DocMethods {
54
+ /**
55
+ * file info
56
+ */
57
+ info: FileInfo;
58
+ /**
59
+ * get document as text.
60
+ *
61
+ * - `type: raw` - read the original content from file system.
62
+ * - `type: processed` - get the processed Markdown content, only available when `includeProcessedMarkdown` is enabled on collection config.
63
+ */
64
+ getText: (type: 'raw' | 'processed') => Promise<string>;
65
+ getMDAST: () => Promise<Root>;
23
66
  }
24
- declare function resolveFiles({ docs, meta }: ResolveOptions): VirtualFile[];
67
+ type MetaCollectionEntry<Data> = Data & {
68
+ /**
69
+ * file info
70
+ */
71
+ info: FileInfo;
72
+ };
73
+ type DocCollectionEntry<Frontmatter> = DocData & DocMethods & Frontmatter;
74
+ type AsyncDocCollectionEntry<Frontmatter> = DocMethods & {
75
+ load: () => Promise<DocData>;
76
+ } & Frontmatter;
77
+ declare function createDocMethods(info: FileInfo, load: () => Promise<CompiledMDXProperties<any>>): DocMethods;
25
78
 
26
- export { _runtime, createMDXSource, resolveFiles };
79
+ export { type AsyncDocCollectionEntry, type DocCollectionEntry, type DocData, type DocMethods, ExtractedReference, type FileInfo, type MetaCollectionEntry, createDocMethods };