fumadocs-mdx 13.0.0 → 13.0.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.
- package/dist/bin.cjs +294 -257
- package/dist/{build-mdx-CzrQDBRZ.d.ts → build-mdx-CCNr86q6.d.ts} +1 -1
- package/dist/{build-mdx-BHG-_uxo.d.cts → build-mdx-D-r3_eQL.d.cts} +1 -1
- package/dist/bun/index.cjs +114 -34
- package/dist/bun/index.d.cts +8 -3
- package/dist/bun/index.d.ts +8 -3
- package/dist/bun/index.js +20 -10
- package/dist/{chunk-6Y5JDZHD.js → chunk-CXA4JO4Z.js} +1 -21
- package/dist/chunk-EELYB2XC.js +207 -0
- package/dist/{chunk-CEA6MYJU.js → chunk-XQ5O7IPO.js} +29 -27
- package/dist/chunk-XZY2AWJI.js +81 -0
- package/dist/{chunk-XV5Z4BFL.js → chunk-YVCR6FUH.js} +1 -1
- package/dist/config/index.d.cts +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/{define-BCNh3n4O.d.cts → core-B6j6Fxse.d.cts} +101 -38
- package/dist/{define-bck_EB4t.d.ts → core-B6j6Fxse.d.ts} +101 -38
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/next/index.cjs +195 -163
- package/dist/next/index.js +79 -71
- package/dist/node/loader.cjs +120 -35
- package/dist/node/loader.js +10 -5
- package/dist/plugins/json-schema.cjs +103 -2
- package/dist/plugins/json-schema.d.cts +12 -4
- package/dist/plugins/json-schema.d.ts +12 -4
- package/dist/plugins/json-schema.js +40 -2
- package/dist/runtime/next/async.d.cts +4 -4
- package/dist/runtime/next/async.d.ts +4 -4
- package/dist/runtime/next/async.js +3 -3
- package/dist/runtime/next/index.d.cts +5 -5
- package/dist/runtime/next/index.d.ts +5 -5
- package/dist/runtime/vite/browser.d.cts +3 -3
- package/dist/runtime/vite/browser.d.ts +3 -3
- package/dist/runtime/vite/server.d.cts +3 -3
- package/dist/runtime/vite/server.d.ts +3 -3
- package/dist/{types-1cCFEzWt.d.ts → types-AGzTfBmf.d.ts} +1 -1
- package/dist/{types-D5NhXTJY.d.cts → types-DKGMoay5.d.cts} +1 -1
- package/dist/vite/index.cjs +145 -108
- package/dist/vite/index.js +53 -45
- package/dist/{loader-mdx.cjs → webpack/index.cjs} +151 -58
- package/dist/webpack/index.js +44 -0
- package/loader-mdx.cjs +1 -1
- package/package.json +4 -3
- package/dist/chunk-4MAYA5QX.js +0 -44
- package/dist/chunk-HI62EXSB.js +0 -127
- package/dist/loader-mdx.js +0 -39
- package/dist/plugins/index.cjs +0 -78
- package/dist/plugins/index.d.cts +0 -7
- package/dist/plugins/index.d.ts +0 -7
- package/dist/plugins/index.js +0 -6
- package/dist/remark-postprocess-K233ZVBK.d.cts +0 -22
- package/dist/remark-postprocess-K233ZVBK.d.ts +0 -22
- package/dist/watcher-WXJDWRZY.js +0 -22
- /package/dist/{loader-mdx.d.cts → webpack/index.d.cts} +0 -0
- /package/dist/{loader-mdx.d.ts → webpack/index.d.ts} +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/utils/collections.ts
|
|
2
|
+
import picomatch from "picomatch";
|
|
3
|
+
import { glob } from "tinyglobby";
|
|
4
|
+
import path from "path";
|
|
5
|
+
var SupportedFormats = {
|
|
6
|
+
doc: ["mdx", "md"],
|
|
7
|
+
meta: ["json", "yaml"]
|
|
8
|
+
};
|
|
9
|
+
function getGlobPatterns(collection) {
|
|
10
|
+
if (collection.files) return collection.files;
|
|
11
|
+
return [`**/*.{${SupportedFormats[collection.type].join(",")}}`];
|
|
12
|
+
}
|
|
13
|
+
function isFileSupported(filePath, collection) {
|
|
14
|
+
return SupportedFormats[collection.type].some(
|
|
15
|
+
(format) => filePath.endsWith(`.${format}`)
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function createCollectionMatcher(core) {
|
|
19
|
+
const CacheKey = "collection-matcher";
|
|
20
|
+
return {
|
|
21
|
+
scan(config) {
|
|
22
|
+
const scanned = [];
|
|
23
|
+
function scan(name, collection) {
|
|
24
|
+
const patterns = getGlobPatterns(collection);
|
|
25
|
+
for (const dir of Array.isArray(collection.dir) ? collection.dir : [collection.dir]) {
|
|
26
|
+
scanned.push({
|
|
27
|
+
name,
|
|
28
|
+
collection,
|
|
29
|
+
matcher: picomatch(patterns, {
|
|
30
|
+
cwd: dir
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const [name, collection] of config.collections) {
|
|
36
|
+
if (collection.type === "docs") {
|
|
37
|
+
scan(name, collection.meta);
|
|
38
|
+
scan(name, collection.docs);
|
|
39
|
+
} else {
|
|
40
|
+
scan(name, collection);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return scanned;
|
|
44
|
+
},
|
|
45
|
+
getFileCollection(file) {
|
|
46
|
+
const scanned = core.cache.get(CacheKey) ?? this.scan(core.getConfig());
|
|
47
|
+
core.cache.set(CacheKey, scanned);
|
|
48
|
+
for (const item of scanned) {
|
|
49
|
+
if (isFileSupported(file, item.collection) && item.matcher(file))
|
|
50
|
+
return { name: item.name, collection: item.collection };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function getCollectionFiles(collection) {
|
|
56
|
+
const files = /* @__PURE__ */ new Map();
|
|
57
|
+
const dirs = Array.isArray(collection.dir) ? collection.dir : [collection.dir];
|
|
58
|
+
const patterns = getGlobPatterns(collection);
|
|
59
|
+
await Promise.all(
|
|
60
|
+
dirs.map(async (dir) => {
|
|
61
|
+
const result = await glob(patterns, {
|
|
62
|
+
cwd: path.resolve(dir)
|
|
63
|
+
});
|
|
64
|
+
for (const item of result) {
|
|
65
|
+
if (!isFileSupported(item, collection)) continue;
|
|
66
|
+
const fullPath = path.join(dir, item);
|
|
67
|
+
files.set(fullPath, {
|
|
68
|
+
path: item,
|
|
69
|
+
fullPath
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
return Array.from(files.values());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
getGlobPatterns,
|
|
79
|
+
createCollectionMatcher,
|
|
80
|
+
getCollectionFiles
|
|
81
|
+
};
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { A as AnyCollection, B as BaseCollection,
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-B6j6Fxse.cjs';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
|
-
export { P as PostprocessOptions } from '../remark-postprocess-K233ZVBK.cjs';
|
|
5
4
|
import '@standard-schema/spec';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import '@mdx-js/mdx';
|
|
8
7
|
import 'zod';
|
|
8
|
+
import 'chokidar';
|
|
9
9
|
|
|
10
10
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
11
11
|
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { A as AnyCollection, B as BaseCollection,
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-B6j6Fxse.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
|
-
export { P as PostprocessOptions } from '../remark-postprocess-K233ZVBK.js';
|
|
5
4
|
import '@standard-schema/spec';
|
|
6
5
|
import 'fumadocs-core/mdx-plugins';
|
|
7
6
|
import '@mdx-js/mdx';
|
|
8
7
|
import 'zod';
|
|
8
|
+
import 'chokidar';
|
|
9
9
|
|
|
10
10
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
11
11
|
|
|
@@ -3,7 +3,28 @@ import * as plugins from 'fumadocs-core/mdx-plugins';
|
|
|
3
3
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
4
4
|
import { Pluggable } from 'unified';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import {
|
|
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
|
+
}
|
|
7
28
|
|
|
8
29
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
9
30
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
@@ -23,6 +44,9 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
|
|
|
23
44
|
};
|
|
24
45
|
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, _withoutBundler, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
25
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Zod 4 schema
|
|
49
|
+
*/
|
|
26
50
|
declare const metaSchema: z.ZodObject<{
|
|
27
51
|
title: z.ZodOptional<z.ZodString>;
|
|
28
52
|
pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -31,6 +55,9 @@ declare const metaSchema: z.ZodObject<{
|
|
|
31
55
|
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
32
56
|
icon: z.ZodOptional<z.ZodString>;
|
|
33
57
|
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* Zod 4 schema
|
|
60
|
+
*/
|
|
34
61
|
declare const frontmatterSchema: z.ZodObject<{
|
|
35
62
|
title: z.ZodString;
|
|
36
63
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -39,42 +66,6 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
39
66
|
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
40
67
|
}, z.core.$strip>;
|
|
41
68
|
|
|
42
|
-
interface LoadedConfig {
|
|
43
|
-
collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
|
|
44
|
-
global: GlobalConfig;
|
|
45
|
-
getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type Awaitable<T> = T | Promise<T>;
|
|
49
|
-
interface EmitEntry {
|
|
50
|
-
/**
|
|
51
|
-
* path relative to output directory
|
|
52
|
-
*/
|
|
53
|
-
path: string;
|
|
54
|
-
content: string;
|
|
55
|
-
}
|
|
56
|
-
interface PluginContext {
|
|
57
|
-
environment: 'next' | 'vite';
|
|
58
|
-
configPath: string;
|
|
59
|
-
outDir: string;
|
|
60
|
-
}
|
|
61
|
-
interface Plugin {
|
|
62
|
-
/**
|
|
63
|
-
* on config loaded
|
|
64
|
-
*/
|
|
65
|
-
config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;
|
|
66
|
-
/**
|
|
67
|
-
* Generate files (e.g. types, index file, or JSON schemas)
|
|
68
|
-
*/
|
|
69
|
-
emit?: (this: PluginContext) => EmitEntry[] | Promise<EmitEntry[]>;
|
|
70
|
-
}
|
|
71
|
-
type PluginOption = Awaitable<Plugin | Plugin[] | false>;
|
|
72
|
-
declare function createPluginHandler(context: PluginContext, defaultPlugins?: PluginOption[]): {
|
|
73
|
-
init(config: LoadedConfig): Promise<LoadedConfig>;
|
|
74
|
-
emit(): Promise<EmitEntry[]>;
|
|
75
|
-
emitAndWrite(): Promise<void>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
69
|
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
79
70
|
type AnyCollection = DocsCollection | DocCollection | MetaCollection;
|
|
80
71
|
interface BaseCollection {
|
|
@@ -152,4 +143,76 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
152
143
|
}): DocsCollection<DocSchema, MetaSchema, Async>;
|
|
153
144
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
154
145
|
|
|
155
|
-
|
|
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 };
|
|
@@ -3,7 +3,28 @@ import * as plugins from 'fumadocs-core/mdx-plugins';
|
|
|
3
3
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
4
4
|
import { Pluggable } from 'unified';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import {
|
|
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
|
+
}
|
|
7
28
|
|
|
8
29
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
9
30
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
@@ -23,6 +44,9 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
|
|
|
23
44
|
};
|
|
24
45
|
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, remarkNpmOptions, _withoutBundler, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
25
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Zod 4 schema
|
|
49
|
+
*/
|
|
26
50
|
declare const metaSchema: z.ZodObject<{
|
|
27
51
|
title: z.ZodOptional<z.ZodString>;
|
|
28
52
|
pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -31,6 +55,9 @@ declare const metaSchema: z.ZodObject<{
|
|
|
31
55
|
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
32
56
|
icon: z.ZodOptional<z.ZodString>;
|
|
33
57
|
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* Zod 4 schema
|
|
60
|
+
*/
|
|
34
61
|
declare const frontmatterSchema: z.ZodObject<{
|
|
35
62
|
title: z.ZodString;
|
|
36
63
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -39,42 +66,6 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
39
66
|
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
40
67
|
}, z.core.$strip>;
|
|
41
68
|
|
|
42
|
-
interface LoadedConfig {
|
|
43
|
-
collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
|
|
44
|
-
global: GlobalConfig;
|
|
45
|
-
getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type Awaitable<T> = T | Promise<T>;
|
|
49
|
-
interface EmitEntry {
|
|
50
|
-
/**
|
|
51
|
-
* path relative to output directory
|
|
52
|
-
*/
|
|
53
|
-
path: string;
|
|
54
|
-
content: string;
|
|
55
|
-
}
|
|
56
|
-
interface PluginContext {
|
|
57
|
-
environment: 'next' | 'vite';
|
|
58
|
-
configPath: string;
|
|
59
|
-
outDir: string;
|
|
60
|
-
}
|
|
61
|
-
interface Plugin {
|
|
62
|
-
/**
|
|
63
|
-
* on config loaded
|
|
64
|
-
*/
|
|
65
|
-
config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;
|
|
66
|
-
/**
|
|
67
|
-
* Generate files (e.g. types, index file, or JSON schemas)
|
|
68
|
-
*/
|
|
69
|
-
emit?: (this: PluginContext) => EmitEntry[] | Promise<EmitEntry[]>;
|
|
70
|
-
}
|
|
71
|
-
type PluginOption = Awaitable<Plugin | Plugin[] | false>;
|
|
72
|
-
declare function createPluginHandler(context: PluginContext, defaultPlugins?: PluginOption[]): {
|
|
73
|
-
init(config: LoadedConfig): Promise<LoadedConfig>;
|
|
74
|
-
emit(): Promise<EmitEntry[]>;
|
|
75
|
-
emitAndWrite(): Promise<void>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
69
|
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
79
70
|
type AnyCollection = DocsCollection | DocCollection | MetaCollection;
|
|
80
71
|
interface BaseCollection {
|
|
@@ -152,4 +143,76 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
|
|
|
152
143
|
}): DocsCollection<DocSchema, MetaSchema, Async>;
|
|
153
144
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
154
145
|
|
|
155
|
-
|
|
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.d.cts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
2
2
|
import { TOCItemType } from 'fumadocs-core/toc';
|
|
3
3
|
import { MDXContent } from 'mdx/types';
|
|
4
|
-
import { E as ExtractedReference } from './
|
|
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';
|
|
5
6
|
import { Root } from 'mdast';
|
|
6
|
-
import { C as CompiledMDXProperties } from './build-mdx-
|
|
7
|
+
import { C as CompiledMDXProperties } from './build-mdx-D-r3_eQL.cjs';
|
|
8
|
+
import '@standard-schema/spec';
|
|
7
9
|
import '@mdx-js/mdx';
|
|
10
|
+
import 'unified';
|
|
11
|
+
import 'zod';
|
|
12
|
+
import 'chokidar';
|
|
8
13
|
import 'react';
|
|
9
14
|
|
|
10
15
|
interface FileInfo {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
2
2
|
import { TOCItemType } from 'fumadocs-core/toc';
|
|
3
3
|
import { MDXContent } from 'mdx/types';
|
|
4
|
-
import { E as ExtractedReference } from './
|
|
4
|
+
import { E as ExtractedReference } from './core-B6j6Fxse.js';
|
|
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.js';
|
|
5
6
|
import { Root } from 'mdast';
|
|
6
|
-
import { C as CompiledMDXProperties } from './build-mdx-
|
|
7
|
+
import { C as CompiledMDXProperties } from './build-mdx-CCNr86q6.js';
|
|
8
|
+
import '@standard-schema/spec';
|
|
7
9
|
import '@mdx-js/mdx';
|
|
10
|
+
import 'unified';
|
|
11
|
+
import 'zod';
|
|
12
|
+
import 'chokidar';
|
|
8
13
|
import 'react';
|
|
9
14
|
|
|
10
15
|
interface FileInfo {
|