fumadocs-mdx 12.0.3 → 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.
- package/dist/bin.cjs +1116 -359
- package/dist/bin.js +4 -4
- package/dist/build-mdx-CCNr86q6.d.ts +53 -0
- package/dist/build-mdx-D-r3_eQL.d.cts +53 -0
- package/dist/bun/index.cjs +196 -52
- package/dist/bun/index.d.cts +8 -3
- package/dist/bun/index.d.ts +8 -3
- package/dist/bun/index.js +19 -10
- package/dist/{chunk-QAUWMR5D.js → chunk-3J3WL7WN.js} +23 -5
- package/dist/{chunk-6Y5JDZHD.js → chunk-CXA4JO4Z.js} +1 -21
- package/dist/chunk-EELYB2XC.js +207 -0
- package/dist/{chunk-46UPKP5R.js → chunk-II3H5ZVZ.js} +5 -5
- package/dist/{chunk-LGYVNESJ.js → chunk-JVZFH6ND.js} +6 -22
- package/dist/{chunk-LMG6UWCL.js → chunk-K5ZLPEIQ.js} +56 -16
- package/dist/{chunk-OMAMTKDE.js → chunk-KILFIBVW.js} +3 -12
- package/dist/chunk-NVRDCY6Z.js +30 -0
- package/dist/{chunk-RMDXSZYE.js → chunk-XQ5O7IPO.js} +31 -24
- package/dist/chunk-XZY2AWJI.js +81 -0
- package/dist/{chunk-VXEBLM4X.js → chunk-YVCR6FUH.js} +1 -1
- package/dist/config/index.cjs +56 -16
- package/dist/config/index.d.cts +2 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -1
- package/dist/{define-DJbJduHy.d.ts → core-B6j6Fxse.d.cts} +89 -2
- package/dist/{define-DJbJduHy.d.cts → core-B6j6Fxse.d.ts} +89 -2
- package/dist/index.cjs +0 -109
- package/dist/index.d.cts +75 -9
- package/dist/index.d.ts +75 -9
- package/dist/index.js +0 -11
- package/dist/{load-UUXLUBHL.js → load-MNG3CLET.js} +1 -3
- package/dist/next/index.cjs +298 -234
- package/dist/next/index.d.cts +2 -11
- package/dist/next/index.d.ts +2 -11
- package/dist/next/index.js +177 -141
- package/dist/node/loader.cjs +228 -85
- package/dist/node/loader.js +19 -9
- package/dist/plugins/json-schema.cjs +162 -0
- package/dist/plugins/json-schema.d.cts +24 -0
- package/dist/plugins/json-schema.d.ts +24 -0
- package/dist/plugins/json-schema.js +78 -0
- package/dist/runtime/next/async.cjs +108 -70
- package/dist/runtime/next/async.d.cts +9 -6
- package/dist/runtime/next/async.d.ts +9 -6
- package/dist/runtime/next/async.js +8 -18
- package/dist/runtime/next/index.cjs +25 -14
- package/dist/runtime/next/index.d.cts +11 -8
- package/dist/runtime/next/index.d.ts +11 -8
- package/dist/runtime/next/index.js +2 -2
- package/dist/runtime/vite/browser.cjs +7 -3
- package/dist/runtime/vite/browser.d.cts +56 -7
- package/dist/runtime/vite/browser.d.ts +56 -7
- package/dist/runtime/vite/browser.js +2 -1
- package/dist/runtime/vite/server.cjs +40 -34
- package/dist/runtime/vite/server.d.cts +13 -10
- package/dist/runtime/vite/server.d.ts +13 -10
- package/dist/runtime/vite/server.js +8 -23
- package/dist/{types-TeHjsmja.d.ts → types-AGzTfBmf.d.ts} +3 -10
- package/dist/{types-BRx1QsIJ.d.cts → types-DKGMoay5.d.cts} +3 -10
- package/dist/vite/index.cjs +443 -249
- package/dist/vite/index.d.cts +23 -10
- package/dist/vite/index.d.ts +23 -10
- package/dist/vite/index.js +213 -36
- package/dist/{loader-mdx.cjs → webpack/index.cjs} +268 -82
- package/dist/{loader-mdx.d.ts → webpack/index.d.cts} +1 -0
- package/dist/{loader-mdx.d.cts → webpack/index.d.ts} +1 -0
- package/dist/webpack/index.js +44 -0
- package/loader-mdx.cjs +1 -1
- package/package.json +30 -16
- package/dist/browser-BupUnhpC.d.ts +0 -98
- package/dist/browser-R0x9IPaQ.d.cts +0 -98
- package/dist/chunk-ADR6R7HM.js +0 -29
- package/dist/chunk-IQAEAI4P.js +0 -66
- package/dist/chunk-XMFLD5J6.js +0 -30
- package/dist/chunk-ZLCSVXCD.js +0 -10
- package/dist/chunk-ZX7TM4AR.js +0 -127
- package/dist/loader-mdx.js +0 -25
- package/dist/postinstall-SCSXM4IM.js +0 -10
- package/dist/shared-CfiiRctw.d.ts +0 -70
- package/dist/shared-fFqiuWJC.d.cts +0 -70
- package/dist/watcher-HGOH3APP.js +0 -22
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
_runtime,
|
|
3
3
|
createMDXSource
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-KILFIBVW.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import {
|
|
9
|
-
readFileWithCache
|
|
10
|
-
} from "../../chunk-ADR6R7HM.js";
|
|
6
|
+
createDocMethods
|
|
7
|
+
} from "../../chunk-NVRDCY6Z.js";
|
|
11
8
|
import {
|
|
12
9
|
buildConfig
|
|
13
10
|
} from "../../chunk-U4MQ44TS.js";
|
|
14
11
|
import {
|
|
15
12
|
buildMDX
|
|
16
|
-
} from "../../chunk-
|
|
17
|
-
import "../../chunk-
|
|
13
|
+
} from "../../chunk-3J3WL7WN.js";
|
|
14
|
+
import "../../chunk-K5ZLPEIQ.js";
|
|
18
15
|
import {
|
|
19
16
|
fumaMatter
|
|
20
17
|
} from "../../chunk-VWJKRQZR.js";
|
|
@@ -22,6 +19,7 @@ import {
|
|
|
22
19
|
// src/runtime/next/async.ts
|
|
23
20
|
import { executeMdx } from "@fumadocs/mdx-remote/client";
|
|
24
21
|
import { pathToFileURL } from "url";
|
|
22
|
+
import fs from "fs/promises";
|
|
25
23
|
function getDocCollection(config, collection) {
|
|
26
24
|
const col = config.collections.get(collection);
|
|
27
25
|
if (col?.type === "doc" && col.mdxOptions) return col;
|
|
@@ -39,7 +37,7 @@ var _runtimeAsync = {
|
|
|
39
37
|
async function compileAndLoad() {
|
|
40
38
|
if (cachedResult) return cachedResult;
|
|
41
39
|
const mdxOptions = await initMdxOptions;
|
|
42
|
-
const raw = await
|
|
40
|
+
const raw = (await fs.readFile(info.fullPath)).toString();
|
|
43
41
|
const { content } = fumaMatter(raw);
|
|
44
42
|
const compiled = await buildMDX(collectionName, content, {
|
|
45
43
|
...mdxOptions,
|
|
@@ -58,15 +56,7 @@ var _runtimeAsync = {
|
|
|
58
56
|
}
|
|
59
57
|
return {
|
|
60
58
|
...data,
|
|
61
|
-
info,
|
|
62
|
-
async getText(type) {
|
|
63
|
-
if (type === "raw") {
|
|
64
|
-
return readFileWithCache(info.fullPath);
|
|
65
|
-
}
|
|
66
|
-
const out = await compileAndLoad();
|
|
67
|
-
if (typeof out._markdown !== "string") missingProcessedMarkdown();
|
|
68
|
-
return out._markdown;
|
|
69
|
-
},
|
|
59
|
+
...createDocMethods(info, () => compileAndLoad()),
|
|
70
60
|
async load() {
|
|
71
61
|
const out = await compileAndLoad();
|
|
72
62
|
return {
|
|
@@ -35,13 +35,32 @@ __export(next_exports, {
|
|
|
35
35
|
resolveFiles: () => resolveFiles
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(next_exports);
|
|
38
|
-
var fs = __toESM(require("fs/promises"), 1);
|
|
39
38
|
|
|
40
39
|
// src/runtime/shared.ts
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
41
|
+
function createDocMethods(info, load) {
|
|
42
|
+
return {
|
|
43
|
+
info,
|
|
44
|
+
async getText(type) {
|
|
45
|
+
if (type === "raw") {
|
|
46
|
+
return (await import_promises.default.readFile(info.fullPath)).toString();
|
|
47
|
+
}
|
|
48
|
+
const data = await load();
|
|
49
|
+
if (typeof data._markdown !== "string")
|
|
50
|
+
throw new Error(
|
|
51
|
+
"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
|
|
52
|
+
);
|
|
53
|
+
return data._markdown;
|
|
54
|
+
},
|
|
55
|
+
async getMDAST() {
|
|
56
|
+
const data = await load();
|
|
57
|
+
if (!data._mdast)
|
|
58
|
+
throw new Error(
|
|
59
|
+
"getMDAST() requires `includeMDAST` to be enabled in your collection config."
|
|
60
|
+
);
|
|
61
|
+
return JSON.parse(data._mdast);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
// src/runtime/next/index.ts
|
|
@@ -49,9 +68,7 @@ var _runtime = {
|
|
|
49
68
|
doc(files) {
|
|
50
69
|
return files.map((file) => {
|
|
51
70
|
const data = file.data;
|
|
52
|
-
const filePath = file.info.fullPath;
|
|
53
71
|
return {
|
|
54
|
-
info: file.info,
|
|
55
72
|
_exports: data,
|
|
56
73
|
body: data.default,
|
|
57
74
|
lastModified: data.lastModified,
|
|
@@ -59,13 +76,7 @@ var _runtime = {
|
|
|
59
76
|
structuredData: data.structuredData,
|
|
60
77
|
extractedReferences: data.extractedReferences,
|
|
61
78
|
...data.frontmatter,
|
|
62
|
-
|
|
63
|
-
if (type === "raw") {
|
|
64
|
-
return (await fs.readFile(filePath)).toString();
|
|
65
|
-
}
|
|
66
|
-
if (typeof data._markdown !== "string") missingProcessedMarkdown();
|
|
67
|
-
return data._markdown;
|
|
68
|
-
}
|
|
79
|
+
...createDocMethods(file.info, () => Promise.resolve(data))
|
|
69
80
|
};
|
|
70
81
|
});
|
|
71
82
|
},
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { F as FileInfo } from '../../shared-fFqiuWJC.cjs';
|
|
2
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import '../../
|
|
6
|
-
import 'fumadocs-core/mdx-plugins';
|
|
7
|
-
import 'fumadocs-core/server';
|
|
8
|
-
import 'react';
|
|
9
|
-
import 'mdx/types';
|
|
2
|
+
import { R as Runtime } from '../../types-DKGMoay5.cjs';
|
|
3
|
+
export { b as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, c as RuntimeAsync, a as RuntimeFile } from '../../types-DKGMoay5.cjs';
|
|
4
|
+
import { FileInfo } from '../../index.cjs';
|
|
10
5
|
import '@standard-schema/spec';
|
|
6
|
+
import '../../core-B6j6Fxse.cjs';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
11
8
|
import '@mdx-js/mdx';
|
|
12
9
|
import 'unified';
|
|
13
10
|
import 'zod';
|
|
11
|
+
import 'chokidar';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdx/types';
|
|
14
|
+
import 'mdast';
|
|
15
|
+
import '../../build-mdx-D-r3_eQL.cjs';
|
|
16
|
+
import 'react';
|
|
14
17
|
|
|
15
18
|
declare const _runtime: Runtime;
|
|
16
19
|
interface AnyCollectionEntry {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { F as FileInfo } from '../../shared-CfiiRctw.js';
|
|
2
1
|
import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import '../../
|
|
6
|
-
import 'fumadocs-core/mdx-plugins';
|
|
7
|
-
import 'fumadocs-core/server';
|
|
8
|
-
import 'react';
|
|
9
|
-
import 'mdx/types';
|
|
2
|
+
import { R as Runtime } from '../../types-AGzTfBmf.js';
|
|
3
|
+
export { b as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, c as RuntimeAsync, a as RuntimeFile } from '../../types-AGzTfBmf.js';
|
|
4
|
+
import { FileInfo } from '../../index.js';
|
|
10
5
|
import '@standard-schema/spec';
|
|
6
|
+
import '../../core-B6j6Fxse.js';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
11
8
|
import '@mdx-js/mdx';
|
|
12
9
|
import 'unified';
|
|
13
10
|
import 'zod';
|
|
11
|
+
import 'chokidar';
|
|
12
|
+
import 'fumadocs-core/toc';
|
|
13
|
+
import 'mdx/types';
|
|
14
|
+
import 'mdast';
|
|
15
|
+
import '../../build-mdx-CCNr86q6.js';
|
|
16
|
+
import 'react';
|
|
14
17
|
|
|
15
18
|
declare const _runtime: Runtime;
|
|
16
19
|
interface AnyCollectionEntry {
|
|
@@ -22,12 +22,13 @@ var browser_exports = {};
|
|
|
22
22
|
__export(browser_exports, {
|
|
23
23
|
createClientLoader: () => createClientLoader,
|
|
24
24
|
fromConfig: () => fromConfigBase,
|
|
25
|
+
fromConfigBase: () => fromConfigBase,
|
|
25
26
|
toClientRenderer: () => toClientRenderer
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(browser_exports);
|
|
28
|
-
var import_react = require("react");
|
|
29
29
|
|
|
30
30
|
// src/runtime/vite/base.ts
|
|
31
|
+
var import_react = require("react");
|
|
31
32
|
function fromConfigBase() {
|
|
32
33
|
function normalize(entries, base) {
|
|
33
34
|
const out = {};
|
|
@@ -54,8 +55,6 @@ function fromConfigBase() {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
// src/runtime/vite/browser.ts
|
|
59
58
|
var loaderStore = /* @__PURE__ */ new Map();
|
|
60
59
|
function createClientLoader(files, options) {
|
|
61
60
|
const { id = "", component } = options;
|
|
@@ -89,6 +88,10 @@ function createClientLoader(files, options) {
|
|
|
89
88
|
getRenderer,
|
|
90
89
|
getComponent(path) {
|
|
91
90
|
return getRenderer()[path];
|
|
91
|
+
},
|
|
92
|
+
useContent(path, props) {
|
|
93
|
+
const Comp = this.getComponent(path);
|
|
94
|
+
return (0, import_react.createElement)(Comp, props);
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
}
|
|
@@ -99,5 +102,6 @@ function toClientRenderer(files, component) {
|
|
|
99
102
|
0 && (module.exports = {
|
|
100
103
|
createClientLoader,
|
|
101
104
|
fromConfig,
|
|
105
|
+
fromConfigBase,
|
|
102
106
|
toClientRenderer
|
|
103
107
|
});
|
|
@@ -1,10 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
1
|
+
import { b as DocCollection, c as DocsCollection, M as MetaCollection } from '../../core-B6j6Fxse.cjs';
|
|
2
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
+
import { C as CompiledMDXProperties } from '../../build-mdx-D-r3_eQL.cjs';
|
|
4
|
+
import { ReactNode, FC } from 'react';
|
|
4
5
|
import 'fumadocs-core/mdx-plugins';
|
|
5
|
-
import '
|
|
6
|
-
import 'mdx/types';
|
|
7
|
-
import '../../define-DJbJduHy.cjs';
|
|
8
|
-
import '@standard-schema/spec';
|
|
6
|
+
import '@mdx-js/mdx';
|
|
9
7
|
import 'unified';
|
|
10
8
|
import 'zod';
|
|
9
|
+
import 'chokidar';
|
|
10
|
+
import 'fumadocs-core/toc';
|
|
11
|
+
import 'mdx/types';
|
|
12
|
+
|
|
13
|
+
type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
|
|
14
|
+
type DocMap<Frontmatter> = Record<string, (() => Promise<CompiledMDXFile<Frontmatter>>) & {
|
|
15
|
+
base: string;
|
|
16
|
+
}>;
|
|
17
|
+
type MetaMap<Data> = Record<string, (() => Promise<Data>) & {
|
|
18
|
+
base: string;
|
|
19
|
+
}>;
|
|
20
|
+
interface LazyDocMap<Frontmatter> {
|
|
21
|
+
base: string;
|
|
22
|
+
head: Record<string, () => Promise<Frontmatter>>;
|
|
23
|
+
body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
24
|
+
}
|
|
25
|
+
interface BaseCreate<Config> {
|
|
26
|
+
doc: <Name extends keyof Config>(name: Name, base: string, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
27
|
+
docLazy: <Name extends keyof Config>(name: Name, base: string, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
28
|
+
meta: <Name extends keyof Config>(name: Name, base: string, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? MetaMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
29
|
+
}
|
|
30
|
+
declare function fromConfigBase<Config>(): BaseCreate<Config>;
|
|
31
|
+
interface ClientLoaderOptions<Frontmatter, Props> {
|
|
32
|
+
/**
|
|
33
|
+
* Loader ID (usually your collection name)
|
|
34
|
+
*
|
|
35
|
+
* The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
|
|
36
|
+
*
|
|
37
|
+
* We use loader ID to share cache between multiple instances of client loader.
|
|
38
|
+
*
|
|
39
|
+
* @defaultValue ''
|
|
40
|
+
*/
|
|
41
|
+
id?: string;
|
|
42
|
+
component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode;
|
|
43
|
+
}
|
|
44
|
+
interface ClientLoader<Frontmatter, Props> {
|
|
45
|
+
preload: (path: string) => Promise<CompiledMDXFile<Frontmatter>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a component that renders content with `React.lazy`.
|
|
48
|
+
*/
|
|
49
|
+
getComponent: (path: string) => FC<Props>;
|
|
50
|
+
/**
|
|
51
|
+
* Get react nodes that renders content with `React.lazy`.
|
|
52
|
+
*/
|
|
53
|
+
useContent: (path: string, props: Props) => ReactNode;
|
|
54
|
+
getRenderer: () => Record<string, FC<Props>>;
|
|
55
|
+
}
|
|
56
|
+
declare function createClientLoader<Frontmatter, Props extends object = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
|
|
57
|
+
declare function toClientRenderer<Frontmatter, Props extends object = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode): Record<string, FC<Props>>;
|
|
58
|
+
|
|
59
|
+
export { type BaseCreate, type ClientLoader, type ClientLoaderOptions, type CompiledMDXFile, type DocMap, type LazyDocMap, type MetaMap, createClientLoader, fromConfigBase as fromConfig, fromConfigBase, toClientRenderer };
|
|
@@ -1,10 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
1
|
+
import { b as DocCollection, c as DocsCollection, M as MetaCollection } from '../../core-B6j6Fxse.js';
|
|
2
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
+
import { C as CompiledMDXProperties } from '../../build-mdx-CCNr86q6.js';
|
|
4
|
+
import { ReactNode, FC } from 'react';
|
|
4
5
|
import 'fumadocs-core/mdx-plugins';
|
|
5
|
-
import '
|
|
6
|
-
import 'mdx/types';
|
|
7
|
-
import '../../define-DJbJduHy.js';
|
|
8
|
-
import '@standard-schema/spec';
|
|
6
|
+
import '@mdx-js/mdx';
|
|
9
7
|
import 'unified';
|
|
10
8
|
import 'zod';
|
|
9
|
+
import 'chokidar';
|
|
10
|
+
import 'fumadocs-core/toc';
|
|
11
|
+
import 'mdx/types';
|
|
12
|
+
|
|
13
|
+
type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
|
|
14
|
+
type DocMap<Frontmatter> = Record<string, (() => Promise<CompiledMDXFile<Frontmatter>>) & {
|
|
15
|
+
base: string;
|
|
16
|
+
}>;
|
|
17
|
+
type MetaMap<Data> = Record<string, (() => Promise<Data>) & {
|
|
18
|
+
base: string;
|
|
19
|
+
}>;
|
|
20
|
+
interface LazyDocMap<Frontmatter> {
|
|
21
|
+
base: string;
|
|
22
|
+
head: Record<string, () => Promise<Frontmatter>>;
|
|
23
|
+
body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
24
|
+
}
|
|
25
|
+
interface BaseCreate<Config> {
|
|
26
|
+
doc: <Name extends keyof Config>(name: Name, base: string, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
27
|
+
docLazy: <Name extends keyof Config>(name: Name, base: string, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
28
|
+
meta: <Name extends keyof Config>(name: Name, base: string, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? MetaMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
29
|
+
}
|
|
30
|
+
declare function fromConfigBase<Config>(): BaseCreate<Config>;
|
|
31
|
+
interface ClientLoaderOptions<Frontmatter, Props> {
|
|
32
|
+
/**
|
|
33
|
+
* Loader ID (usually your collection name)
|
|
34
|
+
*
|
|
35
|
+
* The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
|
|
36
|
+
*
|
|
37
|
+
* We use loader ID to share cache between multiple instances of client loader.
|
|
38
|
+
*
|
|
39
|
+
* @defaultValue ''
|
|
40
|
+
*/
|
|
41
|
+
id?: string;
|
|
42
|
+
component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode;
|
|
43
|
+
}
|
|
44
|
+
interface ClientLoader<Frontmatter, Props> {
|
|
45
|
+
preload: (path: string) => Promise<CompiledMDXFile<Frontmatter>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a component that renders content with `React.lazy`.
|
|
48
|
+
*/
|
|
49
|
+
getComponent: (path: string) => FC<Props>;
|
|
50
|
+
/**
|
|
51
|
+
* Get react nodes that renders content with `React.lazy`.
|
|
52
|
+
*/
|
|
53
|
+
useContent: (path: string, props: Props) => ReactNode;
|
|
54
|
+
getRenderer: () => Record<string, FC<Props>>;
|
|
55
|
+
}
|
|
56
|
+
declare function createClientLoader<Frontmatter, Props extends object = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
|
|
57
|
+
declare function toClientRenderer<Frontmatter, Props extends object = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode): Record<string, FC<Props>>;
|
|
58
|
+
|
|
59
|
+
export { type BaseCreate, type ClientLoader, type ClientLoaderOptions, type CompiledMDXFile, type DocMap, type LazyDocMap, type MetaMap, createClientLoader, fromConfigBase as fromConfig, fromConfigBase, toClientRenderer };
|
|
@@ -32,11 +32,13 @@ var server_exports = {};
|
|
|
32
32
|
__export(server_exports, {
|
|
33
33
|
createClientLoader: () => createClientLoader,
|
|
34
34
|
fromConfig: () => fromConfig,
|
|
35
|
+
fromConfigBase: () => fromConfigBase,
|
|
35
36
|
toClientRenderer: () => toClientRenderer
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(server_exports);
|
|
38
39
|
|
|
39
40
|
// src/runtime/vite/base.ts
|
|
41
|
+
var import_react = require("react");
|
|
40
42
|
function fromConfigBase() {
|
|
41
43
|
function normalize(entries, base) {
|
|
42
44
|
const out = {};
|
|
@@ -63,22 +65,6 @@ function fromConfigBase() {
|
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
// src/runtime/vite/server.ts
|
|
68
|
-
var path = __toESM(require("path"), 1);
|
|
69
|
-
|
|
70
|
-
// src/runtime/shared.ts
|
|
71
|
-
function missingProcessedMarkdown() {
|
|
72
|
-
throw new Error(
|
|
73
|
-
"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// src/runtime/vite/server.ts
|
|
78
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
79
|
-
|
|
80
|
-
// src/runtime/vite/browser.ts
|
|
81
|
-
var import_react = require("react");
|
|
82
68
|
var loaderStore = /* @__PURE__ */ new Map();
|
|
83
69
|
function createClientLoader(files, options) {
|
|
84
70
|
const { id = "", component } = options;
|
|
@@ -112,6 +98,10 @@ function createClientLoader(files, options) {
|
|
|
112
98
|
getRenderer,
|
|
113
99
|
getComponent(path2) {
|
|
114
100
|
return getRenderer()[path2];
|
|
101
|
+
},
|
|
102
|
+
useContent(path2, props) {
|
|
103
|
+
const Comp = this.getComponent(path2);
|
|
104
|
+
return (0, import_react.createElement)(Comp, props);
|
|
115
105
|
}
|
|
116
106
|
};
|
|
117
107
|
}
|
|
@@ -119,6 +109,36 @@ function toClientRenderer(files, component) {
|
|
|
119
109
|
return createClientLoader(files, { component }).getRenderer();
|
|
120
110
|
}
|
|
121
111
|
|
|
112
|
+
// src/runtime/vite/server.ts
|
|
113
|
+
var path = __toESM(require("path"), 1);
|
|
114
|
+
|
|
115
|
+
// src/runtime/shared.ts
|
|
116
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
117
|
+
function createDocMethods(info, load) {
|
|
118
|
+
return {
|
|
119
|
+
info,
|
|
120
|
+
async getText(type) {
|
|
121
|
+
if (type === "raw") {
|
|
122
|
+
return (await import_promises.default.readFile(info.fullPath)).toString();
|
|
123
|
+
}
|
|
124
|
+
const data = await load();
|
|
125
|
+
if (typeof data._markdown !== "string")
|
|
126
|
+
throw new Error(
|
|
127
|
+
"getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
|
|
128
|
+
);
|
|
129
|
+
return data._markdown;
|
|
130
|
+
},
|
|
131
|
+
async getMDAST() {
|
|
132
|
+
const data = await load();
|
|
133
|
+
if (!data._mdast)
|
|
134
|
+
throw new Error(
|
|
135
|
+
"getMDAST() requires `includeMDAST` to be enabled in your collection config."
|
|
136
|
+
);
|
|
137
|
+
return JSON.parse(data._mdast);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
122
142
|
// src/runtime/vite/server.ts
|
|
123
143
|
function fromConfig() {
|
|
124
144
|
const base = fromConfigBase();
|
|
@@ -141,31 +161,16 @@ function fromConfig() {
|
|
|
141
161
|
function mapPageData(info, entry) {
|
|
142
162
|
return {
|
|
143
163
|
...mapDocData(entry),
|
|
144
|
-
|
|
145
|
-
async
|
|
146
|
-
if (type === "raw") {
|
|
147
|
-
return (await import_promises.default.readFile(info.fullPath)).toString();
|
|
148
|
-
}
|
|
149
|
-
if (typeof entry._markdown !== "string") missingProcessedMarkdown();
|
|
150
|
-
return entry._markdown;
|
|
151
|
-
},
|
|
152
|
-
...entry.frontmatter
|
|
164
|
+
...entry.frontmatter,
|
|
165
|
+
...createDocMethods(info, async () => entry)
|
|
153
166
|
};
|
|
154
167
|
}
|
|
155
168
|
function mapPageDataLazy(info, head, content) {
|
|
156
169
|
return {
|
|
157
170
|
...head,
|
|
158
|
-
info,
|
|
171
|
+
...createDocMethods(info, content),
|
|
159
172
|
async load() {
|
|
160
173
|
return mapDocData(await content());
|
|
161
|
-
},
|
|
162
|
-
async getText(type) {
|
|
163
|
-
if (type === "raw") {
|
|
164
|
-
return (await import_promises.default.readFile(info.fullPath)).toString();
|
|
165
|
-
}
|
|
166
|
-
const entry = await content();
|
|
167
|
-
if (typeof entry._markdown !== "string") missingProcessedMarkdown();
|
|
168
|
-
return entry._markdown;
|
|
169
174
|
}
|
|
170
175
|
};
|
|
171
176
|
}
|
|
@@ -233,5 +238,6 @@ function fromConfig() {
|
|
|
233
238
|
0 && (module.exports = {
|
|
234
239
|
createClientLoader,
|
|
235
240
|
fromConfig,
|
|
241
|
+
fromConfigBase,
|
|
236
242
|
toClientRenderer
|
|
237
243
|
});
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { B as BaseCreate, D as DocMap, M as MetaMap, L as LazyDocMap } from '../../browser-R0x9IPaQ.cjs';
|
|
2
|
-
export { C as ClientLoader, a as ClientLoaderOptions, b as CompiledMDXFile, c as createClientLoader, t as toClientRenderer } from '../../browser-R0x9IPaQ.cjs';
|
|
3
1
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import 'react';
|
|
9
|
-
import 'mdx/types';
|
|
10
|
-
import '../../define-DJbJduHy.cjs';
|
|
2
|
+
import { BaseCreate, DocMap, MetaMap, LazyDocMap } from './browser.cjs';
|
|
3
|
+
export { ClientLoader, ClientLoaderOptions, CompiledMDXFile, createClientLoader, fromConfig as fromConfigBase, toClientRenderer } from './browser.cjs';
|
|
4
|
+
import { DocCollectionEntry, MetaCollectionEntry, AsyncDocCollectionEntry } from '../../index.cjs';
|
|
5
|
+
import '../../core-B6j6Fxse.cjs';
|
|
11
6
|
import '@standard-schema/spec';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
8
|
+
import '@mdx-js/mdx';
|
|
12
9
|
import 'unified';
|
|
13
10
|
import 'zod';
|
|
11
|
+
import 'chokidar';
|
|
12
|
+
import '../../build-mdx-D-r3_eQL.cjs';
|
|
13
|
+
import 'fumadocs-core/toc';
|
|
14
|
+
import 'react';
|
|
15
|
+
import 'mdx/types';
|
|
16
|
+
import 'mdast';
|
|
14
17
|
|
|
15
18
|
interface ServerCreate<Config> extends BaseCreate<Config> {
|
|
16
19
|
sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: DocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
|
|
@@ -24,4 +27,4 @@ interface ServerCreate<Config> extends BaseCreate<Config> {
|
|
|
24
27
|
}
|
|
25
28
|
declare function fromConfig<Config>(): ServerCreate<Config>;
|
|
26
29
|
|
|
27
|
-
export { DocMap, LazyDocMap, MetaMap, type ServerCreate, fromConfig };
|
|
30
|
+
export { BaseCreate, DocMap, LazyDocMap, MetaMap, type ServerCreate, fromConfig };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { B as BaseCreate, D as DocMap, M as MetaMap, L as LazyDocMap } from '../../browser-BupUnhpC.js';
|
|
2
|
-
export { C as ClientLoader, a as ClientLoaderOptions, b as CompiledMDXFile, c as createClientLoader, t as toClientRenderer } from '../../browser-BupUnhpC.js';
|
|
3
1
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import 'react';
|
|
9
|
-
import 'mdx/types';
|
|
10
|
-
import '../../define-DJbJduHy.js';
|
|
2
|
+
import { BaseCreate, DocMap, MetaMap, LazyDocMap } from './browser.js';
|
|
3
|
+
export { ClientLoader, ClientLoaderOptions, CompiledMDXFile, createClientLoader, fromConfig as fromConfigBase, toClientRenderer } from './browser.js';
|
|
4
|
+
import { DocCollectionEntry, MetaCollectionEntry, AsyncDocCollectionEntry } from '../../index.js';
|
|
5
|
+
import '../../core-B6j6Fxse.js';
|
|
11
6
|
import '@standard-schema/spec';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
8
|
+
import '@mdx-js/mdx';
|
|
12
9
|
import 'unified';
|
|
13
10
|
import 'zod';
|
|
11
|
+
import 'chokidar';
|
|
12
|
+
import '../../build-mdx-CCNr86q6.js';
|
|
13
|
+
import 'fumadocs-core/toc';
|
|
14
|
+
import 'react';
|
|
15
|
+
import 'mdx/types';
|
|
16
|
+
import 'mdast';
|
|
14
17
|
|
|
15
18
|
interface ServerCreate<Config> extends BaseCreate<Config> {
|
|
16
19
|
sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: DocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
|
|
@@ -24,4 +27,4 @@ interface ServerCreate<Config> extends BaseCreate<Config> {
|
|
|
24
27
|
}
|
|
25
28
|
declare function fromConfig<Config>(): ServerCreate<Config>;
|
|
26
29
|
|
|
27
|
-
export { DocMap, LazyDocMap, MetaMap, type ServerCreate, fromConfig };
|
|
30
|
+
export { BaseCreate, DocMap, LazyDocMap, MetaMap, type ServerCreate, fromConfig };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDocMethods
|
|
3
|
+
} from "../../chunk-NVRDCY6Z.js";
|
|
1
4
|
import {
|
|
2
5
|
createClientLoader,
|
|
3
6
|
fromConfigBase,
|
|
4
7
|
toClientRenderer
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import {
|
|
7
|
-
missingProcessedMarkdown
|
|
8
|
-
} from "../../chunk-ZLCSVXCD.js";
|
|
8
|
+
} from "../../chunk-II3H5ZVZ.js";
|
|
9
9
|
|
|
10
10
|
// src/runtime/vite/server.ts
|
|
11
11
|
import * as path from "path";
|
|
12
|
-
import fs from "fs/promises";
|
|
13
12
|
function fromConfig() {
|
|
14
13
|
const base = fromConfigBase();
|
|
15
14
|
function fileInfo(file, base2) {
|
|
@@ -31,31 +30,16 @@ function fromConfig() {
|
|
|
31
30
|
function mapPageData(info, entry) {
|
|
32
31
|
return {
|
|
33
32
|
...mapDocData(entry),
|
|
34
|
-
|
|
35
|
-
async
|
|
36
|
-
if (type === "raw") {
|
|
37
|
-
return (await fs.readFile(info.fullPath)).toString();
|
|
38
|
-
}
|
|
39
|
-
if (typeof entry._markdown !== "string") missingProcessedMarkdown();
|
|
40
|
-
return entry._markdown;
|
|
41
|
-
},
|
|
42
|
-
...entry.frontmatter
|
|
33
|
+
...entry.frontmatter,
|
|
34
|
+
...createDocMethods(info, async () => entry)
|
|
43
35
|
};
|
|
44
36
|
}
|
|
45
37
|
function mapPageDataLazy(info, head, content) {
|
|
46
38
|
return {
|
|
47
39
|
...head,
|
|
48
|
-
info,
|
|
40
|
+
...createDocMethods(info, content),
|
|
49
41
|
async load() {
|
|
50
42
|
return mapDocData(await content());
|
|
51
|
-
},
|
|
52
|
-
async getText(type) {
|
|
53
|
-
if (type === "raw") {
|
|
54
|
-
return (await fs.readFile(info.fullPath)).toString();
|
|
55
|
-
}
|
|
56
|
-
const entry = await content();
|
|
57
|
-
if (typeof entry._markdown !== "string") missingProcessedMarkdown();
|
|
58
|
-
return entry._markdown;
|
|
59
43
|
}
|
|
60
44
|
};
|
|
61
45
|
}
|
|
@@ -122,5 +106,6 @@ function fromConfig() {
|
|
|
122
106
|
export {
|
|
123
107
|
createClientLoader,
|
|
124
108
|
fromConfig,
|
|
109
|
+
fromConfigBase,
|
|
125
110
|
toClientRenderer
|
|
126
111
|
};
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { F as FileInfo, D as DocCollectionEntry, M as MetaCollectionEntry, A as AsyncDocCollectionEntry } from './shared-CfiiRctw.js';
|
|
6
|
-
|
|
7
|
-
interface LoadedConfig {
|
|
8
|
-
collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
|
|
9
|
-
global: GlobalConfig;
|
|
10
|
-
getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
|
|
11
|
-
}
|
|
3
|
+
import { L as LoadedConfig, b as DocCollection, c as DocsCollection, M as MetaCollection } from './core-B6j6Fxse.js';
|
|
4
|
+
import { FileInfo, AsyncDocCollectionEntry, MetaCollectionEntry, DocCollectionEntry } from './index.js';
|
|
12
5
|
|
|
13
6
|
interface RuntimeFile {
|
|
14
7
|
info: FileInfo;
|
|
@@ -49,4 +42,4 @@ interface RuntimeAsync {
|
|
|
49
42
|
} : never;
|
|
50
43
|
}
|
|
51
44
|
|
|
52
|
-
export type { AsyncRuntimeFile as A, DocOut as D,
|
|
45
|
+
export type { AsyncRuntimeFile as A, DocOut as D, MetaOut as M, Runtime as R, RuntimeFile as a, AsyncDocOut as b, RuntimeAsync as c };
|