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.
- package/dist/bin.cjs +1728 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +16 -0
- 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 +857 -0
- package/dist/bun/index.d.cts +13 -0
- package/dist/bun/index.d.ts +13 -0
- package/dist/bun/index.js +62 -0
- package/dist/chunk-3J3WL7WN.js +160 -0
- package/dist/chunk-CXA4JO4Z.js +45 -0
- package/dist/chunk-EELYB2XC.js +207 -0
- package/dist/chunk-FSZMKRVH.js +80 -0
- package/dist/chunk-II3H5ZVZ.js +77 -0
- package/dist/chunk-JVZFH6ND.js +40 -0
- package/dist/chunk-K5ZLPEIQ.js +207 -0
- package/dist/{chunk-VFALQK6O.js → chunk-KILFIBVW.js} +21 -12
- package/dist/chunk-NVRDCY6Z.js +30 -0
- package/dist/chunk-U4MQ44TS.js +53 -0
- package/dist/chunk-VWJKRQZR.js +19 -0
- package/dist/chunk-XQ5O7IPO.js +128 -0
- package/dist/chunk-XZY2AWJI.js +81 -0
- package/dist/chunk-YVCR6FUH.js +82 -0
- package/dist/config/index.cjs +232 -128
- package/dist/config/index.d.cts +4 -6
- package/dist/config/index.d.ts +4 -6
- package/dist/config/index.js +26 -19
- package/dist/core-B6j6Fxse.d.cts +218 -0
- package/dist/core-B6j6Fxse.d.ts +218 -0
- package/dist/index.cjs +0 -76
- package/dist/index.d.cts +73 -20
- package/dist/index.d.ts +73 -20
- package/dist/index.js +0 -10
- package/dist/load-MNG3CLET.js +7 -0
- package/dist/next/index.cjs +567 -314
- package/dist/next/index.d.cts +9 -12
- package/dist/next/index.d.ts +9 -12
- package/dist/next/index.js +238 -211
- package/dist/node/loader.cjs +922 -0
- package/dist/node/loader.d.cts +5 -0
- package/dist/node/loader.d.ts +5 -0
- package/dist/node/loader.js +33 -0
- 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/{mdx-options-CAU273O3.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +715 -0
- package/dist/runtime/next/async.d.cts +21 -0
- package/dist/runtime/next/async.d.ts +21 -0
- package/dist/runtime/next/async.js +89 -0
- package/dist/runtime/next/index.cjs +136 -0
- package/dist/runtime/next/index.d.cts +33 -0
- package/dist/runtime/next/index.d.ts +33 -0
- package/dist/runtime/next/index.js +11 -0
- package/dist/runtime/vite/browser.cjs +107 -0
- package/dist/runtime/vite/browser.d.cts +59 -0
- package/dist/runtime/vite/browser.d.ts +59 -0
- package/dist/runtime/vite/browser.js +11 -0
- package/dist/runtime/vite/server.cjs +243 -0
- package/dist/runtime/vite/server.d.cts +30 -0
- package/dist/runtime/vite/server.d.ts +30 -0
- package/dist/runtime/vite/server.js +111 -0
- package/dist/types-AGzTfBmf.d.ts +45 -0
- package/dist/types-DKGMoay5.d.cts +45 -0
- package/dist/vite/index.cjs +1185 -0
- package/dist/vite/index.d.cts +45 -0
- package/dist/vite/index.d.ts +45 -0
- package/dist/vite/index.js +297 -0
- package/dist/webpack/index.cjs +957 -0
- package/dist/{loader-mdx.d.cts → webpack/index.d.cts} +3 -6
- package/dist/{loader-mdx.d.ts → webpack/index.d.ts} +3 -6
- package/dist/webpack/index.js +44 -0
- package/loader-mdx.cjs +1 -1
- package/package.json +86 -29
- package/bin.js +0 -5
- package/dist/chunk-2ZOW45YZ.js +0 -63
- package/dist/chunk-DRVUBK5B.js +0 -39
- package/dist/chunk-HFLDWPJA.js +0 -62
- package/dist/chunk-IOENRFUX.js +0 -112
- package/dist/chunk-MK7EXW7O.js +0 -75
- package/dist/define-BaW0PQDJ.d.cts +0 -201
- package/dist/define-BaW0PQDJ.d.ts +0 -201
- package/dist/loader-mdx.cjs +0 -527
- package/dist/loader-mdx.js +0 -162
- package/dist/runtime/async.cjs +0 -269
- package/dist/runtime/async.d.cts +0 -18
- package/dist/runtime/async.d.ts +0 -18
- package/dist/runtime/async.js +0 -73
- package/dist/types-BNrQHCj5.d.cts +0 -100
- package/dist/types-DEduCvIT.d.ts +0 -100
- package/dist/watcher-IAZDSTU7.js +0 -24
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/runtime/vite/server.ts
|
|
31
|
+
var server_exports = {};
|
|
32
|
+
__export(server_exports, {
|
|
33
|
+
createClientLoader: () => createClientLoader,
|
|
34
|
+
fromConfig: () => fromConfig,
|
|
35
|
+
fromConfigBase: () => fromConfigBase,
|
|
36
|
+
toClientRenderer: () => toClientRenderer
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(server_exports);
|
|
39
|
+
|
|
40
|
+
// src/runtime/vite/base.ts
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
function fromConfigBase() {
|
|
43
|
+
function normalize(entries, base) {
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const k in entries) {
|
|
46
|
+
const mappedK = k.startsWith("./") ? k.slice(2) : k;
|
|
47
|
+
if (base) Object.assign(entries[k], { base });
|
|
48
|
+
out[mappedK] = entries[k];
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
doc(_, base, glob) {
|
|
54
|
+
return normalize(glob, base);
|
|
55
|
+
},
|
|
56
|
+
meta(_, base, glob) {
|
|
57
|
+
return normalize(glob, base);
|
|
58
|
+
},
|
|
59
|
+
docLazy(_, base, head, body) {
|
|
60
|
+
return {
|
|
61
|
+
base,
|
|
62
|
+
head: normalize(head),
|
|
63
|
+
body: normalize(body)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
var loaderStore = /* @__PURE__ */ new Map();
|
|
69
|
+
function createClientLoader(files, options) {
|
|
70
|
+
const { id = "", component } = options;
|
|
71
|
+
let renderer;
|
|
72
|
+
const store = loaderStore.get(id) ?? {
|
|
73
|
+
preloaded: /* @__PURE__ */ new Map()
|
|
74
|
+
};
|
|
75
|
+
loaderStore.set(id, store);
|
|
76
|
+
function getRenderer() {
|
|
77
|
+
if (renderer) return renderer;
|
|
78
|
+
renderer = {};
|
|
79
|
+
for (const k in files) {
|
|
80
|
+
const OnDemand = (0, import_react.lazy)(async () => {
|
|
81
|
+
const loaded = await files[k]();
|
|
82
|
+
return { default: (props) => component(loaded, props) };
|
|
83
|
+
});
|
|
84
|
+
renderer[k] = (props) => {
|
|
85
|
+
const cached = store.preloaded.get(k);
|
|
86
|
+
if (!cached) return (0, import_react.createElement)(OnDemand, props);
|
|
87
|
+
return component(cached, props);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return renderer;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
async preload(path2) {
|
|
94
|
+
const loaded = await files[path2]();
|
|
95
|
+
store.preloaded.set(path2, loaded);
|
|
96
|
+
return loaded;
|
|
97
|
+
},
|
|
98
|
+
getRenderer,
|
|
99
|
+
getComponent(path2) {
|
|
100
|
+
return getRenderer()[path2];
|
|
101
|
+
},
|
|
102
|
+
useContent(path2, props) {
|
|
103
|
+
const Comp = this.getComponent(path2);
|
|
104
|
+
return (0, import_react.createElement)(Comp, props);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function toClientRenderer(files, component) {
|
|
109
|
+
return createClientLoader(files, { component }).getRenderer();
|
|
110
|
+
}
|
|
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
|
+
|
|
142
|
+
// src/runtime/vite/server.ts
|
|
143
|
+
function fromConfig() {
|
|
144
|
+
const base = fromConfigBase();
|
|
145
|
+
function fileInfo(file, base2) {
|
|
146
|
+
return {
|
|
147
|
+
path: file,
|
|
148
|
+
fullPath: path.join(base2, file)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function mapDocData(entry) {
|
|
152
|
+
return {
|
|
153
|
+
body: entry.default,
|
|
154
|
+
toc: entry.toc,
|
|
155
|
+
extractedReferences: entry.extractedReferences,
|
|
156
|
+
structuredData: entry.structuredData,
|
|
157
|
+
lastModified: entry.lastModified,
|
|
158
|
+
_exports: entry
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function mapPageData(info, entry) {
|
|
162
|
+
return {
|
|
163
|
+
...mapDocData(entry),
|
|
164
|
+
...entry.frontmatter,
|
|
165
|
+
...createDocMethods(info, async () => entry)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function mapPageDataLazy(info, head, content) {
|
|
169
|
+
return {
|
|
170
|
+
...head,
|
|
171
|
+
...createDocMethods(info, content),
|
|
172
|
+
async load() {
|
|
173
|
+
return mapDocData(await content());
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function mapMetaData(info, content) {
|
|
178
|
+
return {
|
|
179
|
+
info,
|
|
180
|
+
...content
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
...base,
|
|
185
|
+
async sourceAsync(doc, meta) {
|
|
186
|
+
const virtualFiles = [
|
|
187
|
+
...Object.entries(doc).map(async ([file, content]) => {
|
|
188
|
+
const info = fileInfo(file, content.base);
|
|
189
|
+
return {
|
|
190
|
+
type: "page",
|
|
191
|
+
path: file,
|
|
192
|
+
absolutePath: info.fullPath,
|
|
193
|
+
data: mapPageData(info, await content())
|
|
194
|
+
};
|
|
195
|
+
}),
|
|
196
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
197
|
+
const info = fileInfo(file, content.base);
|
|
198
|
+
return {
|
|
199
|
+
type: "meta",
|
|
200
|
+
path: info.path,
|
|
201
|
+
absolutePath: info.fullPath,
|
|
202
|
+
data: mapMetaData(info, await content())
|
|
203
|
+
};
|
|
204
|
+
})
|
|
205
|
+
];
|
|
206
|
+
return {
|
|
207
|
+
files: await Promise.all(virtualFiles)
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
async sourceLazy(doc, meta) {
|
|
211
|
+
const virtualFiles = [
|
|
212
|
+
...Object.entries(doc.head).map(async ([file, frontmatter]) => {
|
|
213
|
+
const info = fileInfo(file, doc.base);
|
|
214
|
+
return {
|
|
215
|
+
type: "page",
|
|
216
|
+
path: info.path,
|
|
217
|
+
absolutePath: info.fullPath,
|
|
218
|
+
data: mapPageDataLazy(info, await frontmatter(), doc.body[file])
|
|
219
|
+
};
|
|
220
|
+
}),
|
|
221
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
222
|
+
const info = fileInfo(file, content.base);
|
|
223
|
+
return {
|
|
224
|
+
type: "meta",
|
|
225
|
+
path: info.path,
|
|
226
|
+
absolutePath: info.fullPath,
|
|
227
|
+
data: mapMetaData(info, await content())
|
|
228
|
+
};
|
|
229
|
+
})
|
|
230
|
+
];
|
|
231
|
+
return {
|
|
232
|
+
files: await Promise.all(virtualFiles)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
238
|
+
0 && (module.exports = {
|
|
239
|
+
createClientLoader,
|
|
240
|
+
fromConfig,
|
|
241
|
+
fromConfigBase,
|
|
242
|
+
toClientRenderer
|
|
243
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
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';
|
|
6
|
+
import '@standard-schema/spec';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
8
|
+
import '@mdx-js/mdx';
|
|
9
|
+
import 'unified';
|
|
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';
|
|
17
|
+
|
|
18
|
+
interface ServerCreate<Config> extends BaseCreate<Config> {
|
|
19
|
+
sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: DocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
|
|
20
|
+
pageData: DocCollectionEntry<DocOut>;
|
|
21
|
+
metaData: MetaCollectionEntry<MetaOut>;
|
|
22
|
+
}>>;
|
|
23
|
+
sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
|
|
24
|
+
pageData: AsyncDocCollectionEntry<DocOut>;
|
|
25
|
+
metaData: MetaCollectionEntry<MetaOut>;
|
|
26
|
+
}>>;
|
|
27
|
+
}
|
|
28
|
+
declare function fromConfig<Config>(): ServerCreate<Config>;
|
|
29
|
+
|
|
30
|
+
export { BaseCreate, DocMap, LazyDocMap, MetaMap, type ServerCreate, fromConfig };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
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';
|
|
6
|
+
import '@standard-schema/spec';
|
|
7
|
+
import 'fumadocs-core/mdx-plugins';
|
|
8
|
+
import '@mdx-js/mdx';
|
|
9
|
+
import 'unified';
|
|
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';
|
|
17
|
+
|
|
18
|
+
interface ServerCreate<Config> extends BaseCreate<Config> {
|
|
19
|
+
sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: DocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
|
|
20
|
+
pageData: DocCollectionEntry<DocOut>;
|
|
21
|
+
metaData: MetaCollectionEntry<MetaOut>;
|
|
22
|
+
}>>;
|
|
23
|
+
sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: MetaMap<MetaOut>) => Promise<Source<{
|
|
24
|
+
pageData: AsyncDocCollectionEntry<DocOut>;
|
|
25
|
+
metaData: MetaCollectionEntry<MetaOut>;
|
|
26
|
+
}>>;
|
|
27
|
+
}
|
|
28
|
+
declare function fromConfig<Config>(): ServerCreate<Config>;
|
|
29
|
+
|
|
30
|
+
export { BaseCreate, DocMap, LazyDocMap, MetaMap, type ServerCreate, fromConfig };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDocMethods
|
|
3
|
+
} from "../../chunk-NVRDCY6Z.js";
|
|
4
|
+
import {
|
|
5
|
+
createClientLoader,
|
|
6
|
+
fromConfigBase,
|
|
7
|
+
toClientRenderer
|
|
8
|
+
} from "../../chunk-II3H5ZVZ.js";
|
|
9
|
+
|
|
10
|
+
// src/runtime/vite/server.ts
|
|
11
|
+
import * as path from "path";
|
|
12
|
+
function fromConfig() {
|
|
13
|
+
const base = fromConfigBase();
|
|
14
|
+
function fileInfo(file, base2) {
|
|
15
|
+
return {
|
|
16
|
+
path: file,
|
|
17
|
+
fullPath: path.join(base2, file)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function mapDocData(entry) {
|
|
21
|
+
return {
|
|
22
|
+
body: entry.default,
|
|
23
|
+
toc: entry.toc,
|
|
24
|
+
extractedReferences: entry.extractedReferences,
|
|
25
|
+
structuredData: entry.structuredData,
|
|
26
|
+
lastModified: entry.lastModified,
|
|
27
|
+
_exports: entry
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function mapPageData(info, entry) {
|
|
31
|
+
return {
|
|
32
|
+
...mapDocData(entry),
|
|
33
|
+
...entry.frontmatter,
|
|
34
|
+
...createDocMethods(info, async () => entry)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function mapPageDataLazy(info, head, content) {
|
|
38
|
+
return {
|
|
39
|
+
...head,
|
|
40
|
+
...createDocMethods(info, content),
|
|
41
|
+
async load() {
|
|
42
|
+
return mapDocData(await content());
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function mapMetaData(info, content) {
|
|
47
|
+
return {
|
|
48
|
+
info,
|
|
49
|
+
...content
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
...base,
|
|
54
|
+
async sourceAsync(doc, meta) {
|
|
55
|
+
const virtualFiles = [
|
|
56
|
+
...Object.entries(doc).map(async ([file, content]) => {
|
|
57
|
+
const info = fileInfo(file, content.base);
|
|
58
|
+
return {
|
|
59
|
+
type: "page",
|
|
60
|
+
path: file,
|
|
61
|
+
absolutePath: info.fullPath,
|
|
62
|
+
data: mapPageData(info, await content())
|
|
63
|
+
};
|
|
64
|
+
}),
|
|
65
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
66
|
+
const info = fileInfo(file, content.base);
|
|
67
|
+
return {
|
|
68
|
+
type: "meta",
|
|
69
|
+
path: info.path,
|
|
70
|
+
absolutePath: info.fullPath,
|
|
71
|
+
data: mapMetaData(info, await content())
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
];
|
|
75
|
+
return {
|
|
76
|
+
files: await Promise.all(virtualFiles)
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
async sourceLazy(doc, meta) {
|
|
80
|
+
const virtualFiles = [
|
|
81
|
+
...Object.entries(doc.head).map(async ([file, frontmatter]) => {
|
|
82
|
+
const info = fileInfo(file, doc.base);
|
|
83
|
+
return {
|
|
84
|
+
type: "page",
|
|
85
|
+
path: info.path,
|
|
86
|
+
absolutePath: info.fullPath,
|
|
87
|
+
data: mapPageDataLazy(info, await frontmatter(), doc.body[file])
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
90
|
+
...Object.entries(meta).map(async ([file, content]) => {
|
|
91
|
+
const info = fileInfo(file, content.base);
|
|
92
|
+
return {
|
|
93
|
+
type: "meta",
|
|
94
|
+
path: info.path,
|
|
95
|
+
absolutePath: info.fullPath,
|
|
96
|
+
data: mapMetaData(info, await content())
|
|
97
|
+
};
|
|
98
|
+
})
|
|
99
|
+
];
|
|
100
|
+
return {
|
|
101
|
+
files: await Promise.all(virtualFiles)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
createClientLoader,
|
|
108
|
+
fromConfig,
|
|
109
|
+
fromConfigBase,
|
|
110
|
+
toClientRenderer
|
|
111
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
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';
|
|
5
|
+
|
|
6
|
+
interface RuntimeFile {
|
|
7
|
+
info: FileInfo;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
interface AsyncRuntimeFile {
|
|
11
|
+
info: FileInfo & {
|
|
12
|
+
hash?: string;
|
|
13
|
+
absolutePath?: string;
|
|
14
|
+
};
|
|
15
|
+
data: Record<string, unknown>;
|
|
16
|
+
lastModified?: Date;
|
|
17
|
+
}
|
|
18
|
+
type DocOut<Schema extends StandardSchemaV1 = StandardSchemaV1> = DocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>;
|
|
19
|
+
type MetaOut<Schema extends StandardSchemaV1 = StandardSchemaV1> = MetaCollectionEntry<StandardSchemaV1.InferOutput<Schema>>;
|
|
20
|
+
interface Runtime {
|
|
21
|
+
doc: <C>(files: RuntimeFile[]) => C extends DocCollection<infer Schema, false> ? DocOut<Schema>[] : never;
|
|
22
|
+
meta: <C>(files: RuntimeFile[]) => C extends MetaCollection<infer Schema> ? MetaOut<Schema>[] : never;
|
|
23
|
+
docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends DocsCollection<infer DocSchema, infer MetaSchema, false> ? {
|
|
24
|
+
docs: DocOut<DocSchema>[];
|
|
25
|
+
meta: MetaOut<MetaSchema>[];
|
|
26
|
+
toFumadocsSource: () => Source<{
|
|
27
|
+
pageData: DocOut<DocSchema> extends PageData ? DocOut<DocSchema> : never;
|
|
28
|
+
metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
|
|
29
|
+
}>;
|
|
30
|
+
} : never;
|
|
31
|
+
}
|
|
32
|
+
type AsyncDocOut<Schema extends StandardSchemaV1 = StandardSchemaV1> = AsyncDocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>;
|
|
33
|
+
interface RuntimeAsync {
|
|
34
|
+
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
|
|
35
|
+
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends DocsCollection<infer DocSchema, infer MetaSchema, true> ? {
|
|
36
|
+
docs: AsyncDocOut<DocSchema>[];
|
|
37
|
+
meta: MetaOut<MetaSchema>[];
|
|
38
|
+
toFumadocsSource: () => Source<{
|
|
39
|
+
pageData: AsyncDocOut<DocSchema> extends PageData ? AsyncDocOut<DocSchema> : never;
|
|
40
|
+
metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
|
|
41
|
+
}>;
|
|
42
|
+
} : never;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { AsyncRuntimeFile as A, DocOut as D, MetaOut as M, Runtime as R, RuntimeFile as a, AsyncDocOut as b, RuntimeAsync as c };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
3
|
+
import { L as LoadedConfig, b as DocCollection, c as DocsCollection, M as MetaCollection } from './core-B6j6Fxse.cjs';
|
|
4
|
+
import { FileInfo, AsyncDocCollectionEntry, MetaCollectionEntry, DocCollectionEntry } from './index.cjs';
|
|
5
|
+
|
|
6
|
+
interface RuntimeFile {
|
|
7
|
+
info: FileInfo;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
interface AsyncRuntimeFile {
|
|
11
|
+
info: FileInfo & {
|
|
12
|
+
hash?: string;
|
|
13
|
+
absolutePath?: string;
|
|
14
|
+
};
|
|
15
|
+
data: Record<string, unknown>;
|
|
16
|
+
lastModified?: Date;
|
|
17
|
+
}
|
|
18
|
+
type DocOut<Schema extends StandardSchemaV1 = StandardSchemaV1> = DocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>;
|
|
19
|
+
type MetaOut<Schema extends StandardSchemaV1 = StandardSchemaV1> = MetaCollectionEntry<StandardSchemaV1.InferOutput<Schema>>;
|
|
20
|
+
interface Runtime {
|
|
21
|
+
doc: <C>(files: RuntimeFile[]) => C extends DocCollection<infer Schema, false> ? DocOut<Schema>[] : never;
|
|
22
|
+
meta: <C>(files: RuntimeFile[]) => C extends MetaCollection<infer Schema> ? MetaOut<Schema>[] : never;
|
|
23
|
+
docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends DocsCollection<infer DocSchema, infer MetaSchema, false> ? {
|
|
24
|
+
docs: DocOut<DocSchema>[];
|
|
25
|
+
meta: MetaOut<MetaSchema>[];
|
|
26
|
+
toFumadocsSource: () => Source<{
|
|
27
|
+
pageData: DocOut<DocSchema> extends PageData ? DocOut<DocSchema> : never;
|
|
28
|
+
metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
|
|
29
|
+
}>;
|
|
30
|
+
} : never;
|
|
31
|
+
}
|
|
32
|
+
type AsyncDocOut<Schema extends StandardSchemaV1 = StandardSchemaV1> = AsyncDocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>;
|
|
33
|
+
interface RuntimeAsync {
|
|
34
|
+
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
|
|
35
|
+
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends DocsCollection<infer DocSchema, infer MetaSchema, true> ? {
|
|
36
|
+
docs: AsyncDocOut<DocSchema>[];
|
|
37
|
+
meta: MetaOut<MetaSchema>[];
|
|
38
|
+
toFumadocsSource: () => Source<{
|
|
39
|
+
pageData: AsyncDocOut<DocSchema> extends PageData ? AsyncDocOut<DocSchema> : never;
|
|
40
|
+
metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
|
|
41
|
+
}>;
|
|
42
|
+
} : never;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { AsyncRuntimeFile as A, DocOut as D, MetaOut as M, Runtime as R, RuntimeFile as a, AsyncDocOut as b, RuntimeAsync as c };
|