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
@@ -1,269 +0,0 @@
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/async.ts
31
- var async_exports = {};
32
- __export(async_exports, {
33
- _runtimeAsync: () => _runtimeAsync,
34
- buildConfig: () => buildConfig
35
- });
36
- module.exports = __toCommonJS(async_exports);
37
- var import_mdx_remote = require("@fumadocs/mdx-remote");
38
-
39
- // src/mdx-plugins/remark-include.ts
40
- var import_unist_util_visit = require("unist-util-visit");
41
- var path = __toESM(require("path"), 1);
42
- var fs = __toESM(require("fs/promises"), 1);
43
- var import_gray_matter = __toESM(require("gray-matter"), 1);
44
- function flattenNode(node) {
45
- if ("children" in node)
46
- return node.children.map((child) => flattenNode(child)).join("");
47
- if ("value" in node) return node.value;
48
- return "";
49
- }
50
- function remarkInclude() {
51
- const TagName = "include";
52
- async function update(tree, file, processor, compiler) {
53
- const queue = [];
54
- (0, import_unist_util_visit.visit)(
55
- tree,
56
- ["mdxJsxFlowElement", "mdxJsxTextElement"],
57
- (node, _, parent) => {
58
- let specifier;
59
- const params = {};
60
- if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === TagName) {
61
- const value = flattenNode(node);
62
- if (value.length > 0) {
63
- for (const attr of node.attributes) {
64
- if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
65
- params[attr.name] = attr.value;
66
- }
67
- }
68
- specifier = value;
69
- }
70
- }
71
- if (!specifier) return;
72
- const targetPath = path.resolve(
73
- "cwd" in params ? process.cwd() : path.dirname(file),
74
- specifier
75
- );
76
- const asCode = params.lang || !specifier.endsWith(".md") && !specifier.endsWith(".mdx");
77
- queue.push(
78
- fs.readFile(targetPath).then(async (content) => {
79
- compiler?.addDependency(targetPath);
80
- if (asCode) {
81
- const lang = params.lang ?? path.extname(specifier).slice(1);
82
- Object.assign(node, {
83
- type: "code",
84
- lang,
85
- meta: params.meta,
86
- value: content.toString(),
87
- data: {}
88
- });
89
- return;
90
- }
91
- const parsed = processor.parse((0, import_gray_matter.default)(content).content);
92
- await update(parsed, targetPath, processor, compiler);
93
- Object.assign(
94
- parent && parent.type === "paragraph" ? parent : node,
95
- parsed
96
- );
97
- }).catch((e) => {
98
- console.warn(`failed to read file: ${targetPath}`, e);
99
- })
100
- );
101
- return "skip";
102
- }
103
- );
104
- await Promise.all(queue);
105
- }
106
- return async (tree, file) => {
107
- await update(tree, file.path, this, file.data._compiler);
108
- };
109
- }
110
-
111
- // src/runtime/async.ts
112
- var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
113
-
114
- // src/runtime/index.ts
115
- var _runtime = {
116
- doc(files) {
117
- return files.map((file) => {
118
- const { default: body, frontmatter, ...exports2 } = file.data;
119
- return {
120
- body,
121
- ...exports2,
122
- ...frontmatter,
123
- _exports: file.data,
124
- _file: file.info
125
- };
126
- });
127
- },
128
- meta(files) {
129
- return files.map((file) => {
130
- return {
131
- ...file.data,
132
- _file: file.info
133
- };
134
- });
135
- },
136
- docs(docs, metas) {
137
- const parsedDocs = this.doc(docs);
138
- const parsedMetas = this.meta(metas);
139
- return {
140
- docs: parsedDocs,
141
- meta: parsedMetas,
142
- toFumadocsSource() {
143
- return createMDXSource(parsedDocs, parsedMetas);
144
- }
145
- };
146
- }
147
- };
148
- function createMDXSource(docs, meta = []) {
149
- return {
150
- files: () => resolveFiles({
151
- docs,
152
- meta
153
- })
154
- };
155
- }
156
- function resolveFiles({ docs, meta }) {
157
- const outputs = [];
158
- for (const entry of docs) {
159
- outputs.push({
160
- type: "page",
161
- path: entry._file.path,
162
- data: entry
163
- });
164
- }
165
- for (const entry of meta) {
166
- outputs.push({
167
- type: "meta",
168
- path: entry._file.path,
169
- data: entry
170
- });
171
- }
172
- return outputs;
173
- }
174
-
175
- // src/config/build.ts
176
- function buildConfig(config) {
177
- const collections = /* @__PURE__ */ new Map();
178
- let globalConfig;
179
- for (const [k, v] of Object.entries(config)) {
180
- if (!v) {
181
- continue;
182
- }
183
- if (typeof v === "object" && "type" in v) {
184
- if (v.type === "docs") {
185
- collections.set(k, v);
186
- continue;
187
- }
188
- if (v.type === "doc" || v.type === "meta") {
189
- collections.set(k, v);
190
- continue;
191
- }
192
- }
193
- if (k === "default") {
194
- globalConfig = v;
195
- continue;
196
- }
197
- return [
198
- `Unknown export "${k}", you can only export collections from source configuration file.`,
199
- null
200
- ];
201
- }
202
- return [
203
- null,
204
- {
205
- global: globalConfig,
206
- collections
207
- }
208
- ];
209
- }
210
-
211
- // src/runtime/async.ts
212
- async function initCompiler(config, collection) {
213
- let mdxOptions;
214
- const col = config.collections.get(collection);
215
- if (col?.type === "doc") mdxOptions = col.mdxOptions;
216
- else if (col?.type === "docs")
217
- mdxOptions = col.docs?.mdxOptions;
218
- if (!mdxOptions) {
219
- config._mdx_async ??= {};
220
- config._mdx_async.cachedMdxOptions ??= typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions ?? {};
221
- mdxOptions = config._mdx_async.cachedMdxOptions;
222
- }
223
- const remarkPlugins = mdxOptions.remarkPlugins ?? [];
224
- return (0, import_mdx_remote.createCompiler)({
225
- ...mdxOptions,
226
- remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), import_mdx_plugins.remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, import_mdx_plugins.remarkStructure]
227
- });
228
- }
229
- var _runtimeAsync = {
230
- doc(files, collection, config) {
231
- const init = initCompiler(config, collection);
232
- return files.map(({ info: file, data, content }) => {
233
- return {
234
- ...data,
235
- _file: file,
236
- content,
237
- async load() {
238
- const compiler = await init;
239
- const out = await compiler.compile({
240
- source: content,
241
- filePath: file.absolutePath
242
- });
243
- return {
244
- body: out.body,
245
- toc: out.toc,
246
- structuredData: out.vfile.data.structuredData,
247
- _exports: out.exports ?? {}
248
- };
249
- }
250
- };
251
- });
252
- },
253
- docs(docs, metas, collection, config) {
254
- const parsedDocs = this.doc(docs, collection, config);
255
- const parsedMetas = _runtime.meta(metas);
256
- return {
257
- docs: parsedDocs,
258
- meta: parsedMetas,
259
- toFumadocsSource() {
260
- return createMDXSource(parsedDocs, parsedMetas);
261
- }
262
- };
263
- }
264
- };
265
- // Annotate the CommonJS export names for ESM import in node:
266
- 0 && (module.exports = {
267
- _runtimeAsync,
268
- buildConfig
269
- });
@@ -1,18 +0,0 @@
1
- import { L as LoadedConfig, a as RuntimeAsync } from '../types-BNrQHCj5.cjs';
2
- import '../define-BaW0PQDJ.cjs';
3
- import '@mdx-js/mdx';
4
- import 'mdx/types';
5
- import 'fumadocs-core/mdx-plugins';
6
- import 'fumadocs-core/server';
7
- import 'unified';
8
- import 'react';
9
- import 'zod';
10
- import '@standard-schema/spec';
11
- import 'fumadocs-core/source';
12
- import '@fumadocs/mdx-remote';
13
-
14
- declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
15
-
16
- declare const _runtimeAsync: RuntimeAsync;
17
-
18
- export { _runtimeAsync, buildConfig };
@@ -1,18 +0,0 @@
1
- import { L as LoadedConfig, a as RuntimeAsync } from '../types-DEduCvIT.js';
2
- import '../define-BaW0PQDJ.js';
3
- import '@mdx-js/mdx';
4
- import 'mdx/types';
5
- import 'fumadocs-core/mdx-plugins';
6
- import 'fumadocs-core/server';
7
- import 'unified';
8
- import 'react';
9
- import 'zod';
10
- import '@standard-schema/spec';
11
- import 'fumadocs-core/source';
12
- import '@fumadocs/mdx-remote';
13
-
14
- declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
15
-
16
- declare const _runtimeAsync: RuntimeAsync;
17
-
18
- export { _runtimeAsync, buildConfig };
@@ -1,73 +0,0 @@
1
- import {
2
- _runtime,
3
- createMDXSource
4
- } from "../chunk-VFALQK6O.js";
5
- import {
6
- buildConfig
7
- } from "../chunk-DRVUBK5B.js";
8
- import {
9
- remarkInclude
10
- } from "../chunk-MK7EXW7O.js";
11
-
12
- // src/runtime/async.ts
13
- import { createCompiler } from "@fumadocs/mdx-remote";
14
- import {
15
- remarkStructure
16
- } from "fumadocs-core/mdx-plugins";
17
- async function initCompiler(config, collection) {
18
- let mdxOptions;
19
- const col = config.collections.get(collection);
20
- if (col?.type === "doc") mdxOptions = col.mdxOptions;
21
- else if (col?.type === "docs")
22
- mdxOptions = col.docs?.mdxOptions;
23
- if (!mdxOptions) {
24
- config._mdx_async ??= {};
25
- config._mdx_async.cachedMdxOptions ??= typeof config.global?.mdxOptions === "function" ? await config.global.mdxOptions() : config.global?.mdxOptions ?? {};
26
- mdxOptions = config._mdx_async.cachedMdxOptions;
27
- }
28
- const remarkPlugins = mdxOptions.remarkPlugins ?? [];
29
- return createCompiler({
30
- ...mdxOptions,
31
- remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, remarkStructure]
32
- });
33
- }
34
- var _runtimeAsync = {
35
- doc(files, collection, config) {
36
- const init = initCompiler(config, collection);
37
- return files.map(({ info: file, data, content }) => {
38
- return {
39
- ...data,
40
- _file: file,
41
- content,
42
- async load() {
43
- const compiler = await init;
44
- const out = await compiler.compile({
45
- source: content,
46
- filePath: file.absolutePath
47
- });
48
- return {
49
- body: out.body,
50
- toc: out.toc,
51
- structuredData: out.vfile.data.structuredData,
52
- _exports: out.exports ?? {}
53
- };
54
- }
55
- };
56
- });
57
- },
58
- docs(docs, metas, collection, config) {
59
- const parsedDocs = this.doc(docs, collection, config);
60
- const parsedMetas = _runtime.meta(metas);
61
- return {
62
- docs: parsedDocs,
63
- meta: parsedMetas,
64
- toFumadocsSource() {
65
- return createMDXSource(parsedDocs, parsedMetas);
66
- }
67
- };
68
- }
69
- };
70
- export {
71
- _runtimeAsync,
72
- buildConfig
73
- };
@@ -1,100 +0,0 @@
1
- import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig, F as FileInfo, b as MarkdownProps, B as BaseCollectionEntry } from './define-BaW0PQDJ.cjs';
2
- import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { Source, PageData, MetaData } from 'fumadocs-core/source';
4
- import { ProcessorOptions } from '@mdx-js/mdx';
5
- import { MDXOptions } from '@fumadocs/mdx-remote';
6
-
7
- interface LoadedConfig {
8
- collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
9
- global?: GlobalConfig;
10
- _mdx_loader?: {
11
- cachedProcessorOptions?: ProcessorOptions;
12
- };
13
- _mdx_async?: {
14
- cachedMdxOptions?: MDXOptions;
15
- };
16
- }
17
-
18
- interface RuntimeFile {
19
- info: FileInfo;
20
- data: Record<string, unknown>;
21
- }
22
- interface AsyncRuntimeFile {
23
- info: FileInfo;
24
- data: Record<string, unknown>;
25
- content: string;
26
- }
27
- type DocOut<Schema extends StandardSchemaV1> = Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
28
- type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
29
- interface Runtime {
30
- doc: <C>(files: RuntimeFile[]) => C extends {
31
- type: 'doc';
32
- _type: {
33
- schema: infer Schema extends StandardSchemaV1;
34
- };
35
- } ? DocOut<Schema>[] : never;
36
- meta: <C>(files: RuntimeFile[]) => C extends {
37
- type: 'meta';
38
- _type: {
39
- schema: infer Schema extends StandardSchemaV1;
40
- };
41
- } ? MetaOut<Schema>[] : never;
42
- docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends {
43
- type: 'docs';
44
- docs: {
45
- type: 'doc';
46
- _type: {
47
- schema: infer DocSchema extends StandardSchemaV1;
48
- };
49
- };
50
- meta: {
51
- type: 'meta';
52
- _type: {
53
- schema: infer MetaSchema extends StandardSchemaV1;
54
- };
55
- };
56
- } ? {
57
- docs: DocOut<DocSchema>[];
58
- meta: MetaOut<MetaSchema>[];
59
- toFumadocsSource: () => Source<{
60
- pageData: DocOut<DocSchema> extends PageData ? DocOut<DocSchema> : never;
61
- metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
62
- }>;
63
- } : never;
64
- }
65
- type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
66
- content: string;
67
- load: () => Promise<MarkdownProps>;
68
- };
69
- interface RuntimeAsync {
70
- doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends {
71
- type: 'doc';
72
- _type: {
73
- schema: infer Schema extends StandardSchemaV1;
74
- };
75
- } ? AsyncDocOut<Schema>[] : never;
76
- docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
77
- type: 'docs';
78
- docs: {
79
- type: 'doc';
80
- _type: {
81
- schema: infer DocSchema extends StandardSchemaV1;
82
- };
83
- };
84
- meta: {
85
- type: 'meta';
86
- _type: {
87
- schema: infer MetaSchema extends StandardSchemaV1;
88
- };
89
- };
90
- } ? {
91
- docs: AsyncDocOut<DocSchema>[];
92
- meta: MetaOut<MetaSchema>[];
93
- toFumadocsSource: () => Source<{
94
- pageData: AsyncDocOut<DocSchema> extends PageData ? AsyncDocOut<DocSchema> : never;
95
- metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
96
- }>;
97
- } : never;
98
- }
99
-
100
- export type { LoadedConfig as L, Runtime as R, RuntimeAsync as a };
@@ -1,100 +0,0 @@
1
- import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig, F as FileInfo, b as MarkdownProps, B as BaseCollectionEntry } from './define-BaW0PQDJ.js';
2
- import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { Source, PageData, MetaData } from 'fumadocs-core/source';
4
- import { ProcessorOptions } from '@mdx-js/mdx';
5
- import { MDXOptions } from '@fumadocs/mdx-remote';
6
-
7
- interface LoadedConfig {
8
- collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
9
- global?: GlobalConfig;
10
- _mdx_loader?: {
11
- cachedProcessorOptions?: ProcessorOptions;
12
- };
13
- _mdx_async?: {
14
- cachedMdxOptions?: MDXOptions;
15
- };
16
- }
17
-
18
- interface RuntimeFile {
19
- info: FileInfo;
20
- data: Record<string, unknown>;
21
- }
22
- interface AsyncRuntimeFile {
23
- info: FileInfo;
24
- data: Record<string, unknown>;
25
- content: string;
26
- }
27
- type DocOut<Schema extends StandardSchemaV1> = Omit<MarkdownProps, keyof StandardSchemaV1.InferOutput<Schema>> & StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
28
- type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
29
- interface Runtime {
30
- doc: <C>(files: RuntimeFile[]) => C extends {
31
- type: 'doc';
32
- _type: {
33
- schema: infer Schema extends StandardSchemaV1;
34
- };
35
- } ? DocOut<Schema>[] : never;
36
- meta: <C>(files: RuntimeFile[]) => C extends {
37
- type: 'meta';
38
- _type: {
39
- schema: infer Schema extends StandardSchemaV1;
40
- };
41
- } ? MetaOut<Schema>[] : never;
42
- docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends {
43
- type: 'docs';
44
- docs: {
45
- type: 'doc';
46
- _type: {
47
- schema: infer DocSchema extends StandardSchemaV1;
48
- };
49
- };
50
- meta: {
51
- type: 'meta';
52
- _type: {
53
- schema: infer MetaSchema extends StandardSchemaV1;
54
- };
55
- };
56
- } ? {
57
- docs: DocOut<DocSchema>[];
58
- meta: MetaOut<MetaSchema>[];
59
- toFumadocsSource: () => Source<{
60
- pageData: DocOut<DocSchema> extends PageData ? DocOut<DocSchema> : never;
61
- metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
62
- }>;
63
- } : never;
64
- }
65
- type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
66
- content: string;
67
- load: () => Promise<MarkdownProps>;
68
- };
69
- interface RuntimeAsync {
70
- doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends {
71
- type: 'doc';
72
- _type: {
73
- schema: infer Schema extends StandardSchemaV1;
74
- };
75
- } ? AsyncDocOut<Schema>[] : never;
76
- docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
77
- type: 'docs';
78
- docs: {
79
- type: 'doc';
80
- _type: {
81
- schema: infer DocSchema extends StandardSchemaV1;
82
- };
83
- };
84
- meta: {
85
- type: 'meta';
86
- _type: {
87
- schema: infer MetaSchema extends StandardSchemaV1;
88
- };
89
- };
90
- } ? {
91
- docs: AsyncDocOut<DocSchema>[];
92
- meta: MetaOut<MetaSchema>[];
93
- toFumadocsSource: () => Source<{
94
- pageData: AsyncDocOut<DocSchema> extends PageData ? AsyncDocOut<DocSchema> : never;
95
- metaData: MetaOut<MetaSchema> extends MetaData ? MetaOut<MetaSchema> : never;
96
- }>;
97
- } : never;
98
- }
99
-
100
- export type { LoadedConfig as L, Runtime as R, RuntimeAsync as a };
@@ -1,24 +0,0 @@
1
- // src/map/watcher.ts
2
- import { watch } from "chokidar";
3
- function watcher(configPath, config) {
4
- const deps = [configPath];
5
- function add(dir) {
6
- if (Array.isArray(dir)) deps.push(...dir);
7
- else deps.push(dir);
8
- }
9
- for (const collection of config.collections.values()) {
10
- if (collection.type === "docs") {
11
- add(collection.docs.dir);
12
- add(collection.meta.dir);
13
- } else {
14
- add(collection.dir);
15
- }
16
- }
17
- return watch(deps, {
18
- ignoreInitial: true,
19
- persistent: true
20
- });
21
- }
22
- export {
23
- watcher
24
- };