fumadocs-mdx 11.6.11 → 11.7.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/{chunk-64MMPGML.js → chunk-2CSSQTP6.js} +1 -10
- package/dist/{chunk-SXOJYWZ3.js → chunk-2KBRPMAM.js} +1 -1
- package/dist/{chunk-6PDS7MUA.js → chunk-C5INPAZJ.js} +4 -4
- package/dist/{chunk-DRVUBK5B.js → chunk-GWR7KMRU.js} +13 -1
- package/dist/chunk-OWZSTKKX.js +58 -0
- package/dist/{chunk-22SBT5SQ.js → chunk-ZOWJF3OH.js} +6 -6
- package/dist/config/index.cjs +4 -19
- package/dist/config/index.d.cts +3 -7
- package/dist/config/index.d.ts +3 -7
- package/dist/config/index.js +7 -13
- package/dist/{types-DVeuYiq5.d.cts → define-CCrinVBZ.d.cts} +37 -119
- package/dist/{types-DVeuYiq5.d.ts → define-CCrinVBZ.d.ts} +37 -119
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/loader-mdx.cjs +155 -134
- package/dist/loader-mdx.js +7 -10
- package/dist/mdx-options-UDV5WEFU.js +6 -0
- package/dist/next/index.cjs +253 -85
- package/dist/next/index.js +49 -63
- package/dist/runtime/async.cjs +167 -15
- package/dist/runtime/async.d.cts +5 -6
- package/dist/runtime/async.d.ts +5 -6
- package/dist/runtime/async.js +24 -15
- package/dist/runtime/vite.cjs +150 -0
- package/dist/runtime/vite.d.cts +71 -0
- package/dist/runtime/vite.d.ts +71 -0
- package/dist/runtime/vite.js +123 -0
- package/dist/{types-HIdjlLo0.d.ts → types-C0bKwtAx.d.ts} +38 -50
- package/dist/{types-BcUhOIxN.d.cts → types-CnslxmoO.d.cts} +38 -50
- package/dist/vite/index.cjs +385 -134
- package/dist/vite/index.d.cts +12 -3
- package/dist/vite/index.d.ts +12 -3
- package/dist/vite/index.js +165 -20
- package/package.json +20 -10
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// src/runtime/vite.ts
|
|
2
|
+
import { createElement, lazy } from "react";
|
|
3
|
+
function fromConfig() {
|
|
4
|
+
function normalize(entries) {
|
|
5
|
+
const out = {};
|
|
6
|
+
for (const k in entries) {
|
|
7
|
+
const mappedK = k.startsWith("./") ? k.slice(2) : k;
|
|
8
|
+
out[mappedK] = entries[k];
|
|
9
|
+
}
|
|
10
|
+
return out;
|
|
11
|
+
}
|
|
12
|
+
function mapPageData(entry) {
|
|
13
|
+
const { toc, structuredData } = entry;
|
|
14
|
+
return {
|
|
15
|
+
...entry.frontmatter,
|
|
16
|
+
default: entry.default,
|
|
17
|
+
toc,
|
|
18
|
+
structuredData,
|
|
19
|
+
_exports: entry
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
doc(_, glob) {
|
|
24
|
+
return normalize(glob);
|
|
25
|
+
},
|
|
26
|
+
meta(_, glob) {
|
|
27
|
+
return normalize(glob);
|
|
28
|
+
},
|
|
29
|
+
docs(_, { doc, meta }) {
|
|
30
|
+
return {
|
|
31
|
+
doc: normalize(doc),
|
|
32
|
+
meta: normalize(meta)
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
source(doc, meta) {
|
|
36
|
+
const virtualFiles = [];
|
|
37
|
+
for (const [file, content] of Object.entries(doc)) {
|
|
38
|
+
virtualFiles.push({
|
|
39
|
+
type: "page",
|
|
40
|
+
path: file,
|
|
41
|
+
data: mapPageData(content)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
for (const [file, content] of Object.entries(meta)) {
|
|
45
|
+
virtualFiles.push({
|
|
46
|
+
type: "meta",
|
|
47
|
+
path: file,
|
|
48
|
+
data: content
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
files: virtualFiles
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
async sourceAsync(doc, meta) {
|
|
56
|
+
const virtualFiles = [];
|
|
57
|
+
for (const [file, content] of Object.entries(doc)) {
|
|
58
|
+
virtualFiles.push({
|
|
59
|
+
type: "page",
|
|
60
|
+
path: file,
|
|
61
|
+
data: mapPageData(await content())
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
for (const [file, content] of Object.entries(meta)) {
|
|
65
|
+
virtualFiles.push({
|
|
66
|
+
type: "meta",
|
|
67
|
+
path: file,
|
|
68
|
+
data: await content()
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
files: virtualFiles
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
var loaderStore = /* @__PURE__ */ new Map();
|
|
78
|
+
function createClientLoader(files, options) {
|
|
79
|
+
const { id = "", component } = options;
|
|
80
|
+
const store = loaderStore.get(id) ?? {
|
|
81
|
+
preloaded: /* @__PURE__ */ new Map()
|
|
82
|
+
};
|
|
83
|
+
loaderStore.set(id, store);
|
|
84
|
+
let renderer;
|
|
85
|
+
return {
|
|
86
|
+
async preload(path) {
|
|
87
|
+
const loaded = await files[path]();
|
|
88
|
+
store.preloaded.set(path, loaded);
|
|
89
|
+
return loaded;
|
|
90
|
+
},
|
|
91
|
+
getComponent(path) {
|
|
92
|
+
renderer ??= toClientRenderer(files, component, {
|
|
93
|
+
cache: store.preloaded
|
|
94
|
+
});
|
|
95
|
+
return renderer[path];
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function toClientRenderer(files, component, options = {}) {
|
|
100
|
+
const { cache } = options;
|
|
101
|
+
const renderer = {};
|
|
102
|
+
for (const k in files) {
|
|
103
|
+
const OnDemand = lazy(async () => {
|
|
104
|
+
const loaded = await files[k]();
|
|
105
|
+
return { default: (props) => component(loaded, props) };
|
|
106
|
+
});
|
|
107
|
+
if (cache) {
|
|
108
|
+
renderer[k] = (props) => {
|
|
109
|
+
const cached = cache.get(k);
|
|
110
|
+
if (!cached) return createElement(OnDemand, props);
|
|
111
|
+
return component(cached, props);
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
renderer[k] = OnDemand;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return renderer;
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
createClientLoader,
|
|
121
|
+
fromConfig,
|
|
122
|
+
toClientRenderer
|
|
123
|
+
};
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
import { F as FileInfo, M as MarkdownProps, B as BaseCollectionEntry, L as LoadedConfig } from './types-DVeuYiq5.js';
|
|
2
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
2
|
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
3
|
+
import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig } from './define-CCrinVBZ.js';
|
|
4
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
5
|
+
import { FC } from 'react';
|
|
6
|
+
import { MDXProps } from 'mdx/types';
|
|
7
|
+
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
8
|
+
import { TableOfContents } from 'fumadocs-core/server';
|
|
4
9
|
|
|
10
|
+
interface LoadedConfig {
|
|
11
|
+
collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
|
|
12
|
+
global?: GlobalConfig;
|
|
13
|
+
getDefaultMDXOptions(): Promise<ProcessorOptions>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface BaseCollectionEntry {
|
|
17
|
+
/**
|
|
18
|
+
* Raw file path of collection entry, including absolute path (not normalized).
|
|
19
|
+
*/
|
|
20
|
+
_file: FileInfo;
|
|
21
|
+
}
|
|
22
|
+
interface FileInfo {
|
|
23
|
+
path: string;
|
|
24
|
+
absolutePath: string;
|
|
25
|
+
}
|
|
26
|
+
interface MarkdownProps {
|
|
27
|
+
body: FC<MDXProps>;
|
|
28
|
+
structuredData: StructuredData;
|
|
29
|
+
toc: TableOfContents;
|
|
30
|
+
_exports: Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
33
|
+
*/
|
|
34
|
+
lastModified?: Date;
|
|
35
|
+
}
|
|
5
36
|
interface RuntimeFile {
|
|
6
37
|
info: FileInfo;
|
|
7
38
|
data: Record<string, unknown>;
|
|
@@ -21,33 +52,9 @@ type DocOut<Schema extends StandardSchemaV1> = Override<MarkdownProps & {
|
|
|
21
52
|
type Override<A, B> = Omit<A, keyof B> & B;
|
|
22
53
|
type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
|
|
23
54
|
interface Runtime {
|
|
24
|
-
doc: <C>(files: RuntimeFile[]) => C extends
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
schema: infer Schema extends StandardSchemaV1;
|
|
28
|
-
};
|
|
29
|
-
} ? DocOut<Schema>[] : never;
|
|
30
|
-
meta: <C>(files: RuntimeFile[]) => C extends {
|
|
31
|
-
type: 'meta';
|
|
32
|
-
_type: {
|
|
33
|
-
schema: infer Schema extends StandardSchemaV1;
|
|
34
|
-
};
|
|
35
|
-
} ? MetaOut<Schema>[] : never;
|
|
36
|
-
docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends {
|
|
37
|
-
type: 'docs';
|
|
38
|
-
docs: {
|
|
39
|
-
type: 'doc';
|
|
40
|
-
_type: {
|
|
41
|
-
schema: infer DocSchema extends StandardSchemaV1;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
meta: {
|
|
45
|
-
type: 'meta';
|
|
46
|
-
_type: {
|
|
47
|
-
schema: infer MetaSchema extends StandardSchemaV1;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
} ? {
|
|
55
|
+
doc: <C>(files: RuntimeFile[]) => C extends DocCollection<infer Schema, false> ? DocOut<Schema>[] : never;
|
|
56
|
+
meta: <C>(files: RuntimeFile[]) => C extends MetaCollection<infer Schema> ? MetaOut<Schema>[] : never;
|
|
57
|
+
docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends DocsCollection<infer DocSchema, infer MetaSchema, false> ? {
|
|
51
58
|
docs: DocOut<DocSchema>[];
|
|
52
59
|
meta: MetaOut<MetaSchema>[];
|
|
53
60
|
toFumadocsSource: () => Source<{
|
|
@@ -61,27 +68,8 @@ type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput
|
|
|
61
68
|
load: () => Promise<MarkdownProps>;
|
|
62
69
|
};
|
|
63
70
|
interface RuntimeAsync {
|
|
64
|
-
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends
|
|
65
|
-
|
|
66
|
-
_type: {
|
|
67
|
-
schema: infer Schema extends StandardSchemaV1;
|
|
68
|
-
};
|
|
69
|
-
} ? AsyncDocOut<Schema>[] : never;
|
|
70
|
-
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
|
|
71
|
-
type: 'docs';
|
|
72
|
-
docs: {
|
|
73
|
-
type: 'doc';
|
|
74
|
-
_type: {
|
|
75
|
-
schema: infer DocSchema extends StandardSchemaV1;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
meta: {
|
|
79
|
-
type: 'meta';
|
|
80
|
-
_type: {
|
|
81
|
-
schema: infer MetaSchema extends StandardSchemaV1;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
} ? {
|
|
71
|
+
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
|
|
72
|
+
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends DocsCollection<infer DocSchema, infer MetaSchema, true> ? {
|
|
85
73
|
docs: AsyncDocOut<DocSchema>[];
|
|
86
74
|
meta: MetaOut<MetaSchema>[];
|
|
87
75
|
toFumadocsSource: () => Source<{
|
|
@@ -91,4 +79,4 @@ interface RuntimeAsync {
|
|
|
91
79
|
} : never;
|
|
92
80
|
}
|
|
93
81
|
|
|
94
|
-
export type { Runtime as R, RuntimeAsync as a };
|
|
82
|
+
export type { BaseCollectionEntry as B, LoadedConfig as L, Runtime as R, RuntimeAsync as a };
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
import { F as FileInfo, M as MarkdownProps, B as BaseCollectionEntry, L as LoadedConfig } from './types-DVeuYiq5.cjs';
|
|
2
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
2
|
import { Source, PageData, MetaData } from 'fumadocs-core/source';
|
|
3
|
+
import { D as DocCollection, M as MetaCollection, a as DocsCollection, G as GlobalConfig } from './define-CCrinVBZ.cjs';
|
|
4
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
5
|
+
import { FC } from 'react';
|
|
6
|
+
import { MDXProps } from 'mdx/types';
|
|
7
|
+
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
8
|
+
import { TableOfContents } from 'fumadocs-core/server';
|
|
4
9
|
|
|
10
|
+
interface LoadedConfig {
|
|
11
|
+
collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
|
|
12
|
+
global?: GlobalConfig;
|
|
13
|
+
getDefaultMDXOptions(): Promise<ProcessorOptions>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface BaseCollectionEntry {
|
|
17
|
+
/**
|
|
18
|
+
* Raw file path of collection entry, including absolute path (not normalized).
|
|
19
|
+
*/
|
|
20
|
+
_file: FileInfo;
|
|
21
|
+
}
|
|
22
|
+
interface FileInfo {
|
|
23
|
+
path: string;
|
|
24
|
+
absolutePath: string;
|
|
25
|
+
}
|
|
26
|
+
interface MarkdownProps {
|
|
27
|
+
body: FC<MDXProps>;
|
|
28
|
+
structuredData: StructuredData;
|
|
29
|
+
toc: TableOfContents;
|
|
30
|
+
_exports: Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
33
|
+
*/
|
|
34
|
+
lastModified?: Date;
|
|
35
|
+
}
|
|
5
36
|
interface RuntimeFile {
|
|
6
37
|
info: FileInfo;
|
|
7
38
|
data: Record<string, unknown>;
|
|
@@ -21,33 +52,9 @@ type DocOut<Schema extends StandardSchemaV1> = Override<MarkdownProps & {
|
|
|
21
52
|
type Override<A, B> = Omit<A, keyof B> & B;
|
|
22
53
|
type MetaOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry;
|
|
23
54
|
interface Runtime {
|
|
24
|
-
doc: <C>(files: RuntimeFile[]) => C extends
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
schema: infer Schema extends StandardSchemaV1;
|
|
28
|
-
};
|
|
29
|
-
} ? DocOut<Schema>[] : never;
|
|
30
|
-
meta: <C>(files: RuntimeFile[]) => C extends {
|
|
31
|
-
type: 'meta';
|
|
32
|
-
_type: {
|
|
33
|
-
schema: infer Schema extends StandardSchemaV1;
|
|
34
|
-
};
|
|
35
|
-
} ? MetaOut<Schema>[] : never;
|
|
36
|
-
docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends {
|
|
37
|
-
type: 'docs';
|
|
38
|
-
docs: {
|
|
39
|
-
type: 'doc';
|
|
40
|
-
_type: {
|
|
41
|
-
schema: infer DocSchema extends StandardSchemaV1;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
meta: {
|
|
45
|
-
type: 'meta';
|
|
46
|
-
_type: {
|
|
47
|
-
schema: infer MetaSchema extends StandardSchemaV1;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
} ? {
|
|
55
|
+
doc: <C>(files: RuntimeFile[]) => C extends DocCollection<infer Schema, false> ? DocOut<Schema>[] : never;
|
|
56
|
+
meta: <C>(files: RuntimeFile[]) => C extends MetaCollection<infer Schema> ? MetaOut<Schema>[] : never;
|
|
57
|
+
docs: <C>(docs: RuntimeFile[], metas: RuntimeFile[]) => C extends DocsCollection<infer DocSchema, infer MetaSchema, false> ? {
|
|
51
58
|
docs: DocOut<DocSchema>[];
|
|
52
59
|
meta: MetaOut<MetaSchema>[];
|
|
53
60
|
toFumadocsSource: () => Source<{
|
|
@@ -61,27 +68,8 @@ type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput
|
|
|
61
68
|
load: () => Promise<MarkdownProps>;
|
|
62
69
|
};
|
|
63
70
|
interface RuntimeAsync {
|
|
64
|
-
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends
|
|
65
|
-
|
|
66
|
-
_type: {
|
|
67
|
-
schema: infer Schema extends StandardSchemaV1;
|
|
68
|
-
};
|
|
69
|
-
} ? AsyncDocOut<Schema>[] : never;
|
|
70
|
-
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends {
|
|
71
|
-
type: 'docs';
|
|
72
|
-
docs: {
|
|
73
|
-
type: 'doc';
|
|
74
|
-
_type: {
|
|
75
|
-
schema: infer DocSchema extends StandardSchemaV1;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
meta: {
|
|
79
|
-
type: 'meta';
|
|
80
|
-
_type: {
|
|
81
|
-
schema: infer MetaSchema extends StandardSchemaV1;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
} ? {
|
|
71
|
+
doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
|
|
72
|
+
docs: <C>(docs: AsyncRuntimeFile[], metas: RuntimeFile[], collection: string, config: LoadedConfig) => C extends DocsCollection<infer DocSchema, infer MetaSchema, true> ? {
|
|
85
73
|
docs: AsyncDocOut<DocSchema>[];
|
|
86
74
|
meta: MetaOut<MetaSchema>[];
|
|
87
75
|
toFumadocsSource: () => Source<{
|
|
@@ -91,4 +79,4 @@ interface RuntimeAsync {
|
|
|
91
79
|
} : never;
|
|
92
80
|
}
|
|
93
81
|
|
|
94
|
-
export type { Runtime as R, RuntimeAsync as a };
|
|
82
|
+
export type { BaseCollectionEntry as B, LoadedConfig as L, Runtime as R, RuntimeAsync as a };
|