@hanzo/docs-mdx-remote 1.4.3 → 1.4.6
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/client/index.d.ts +2 -22
- package/dist/client/index.js +3 -8
- package/dist/index.d.ts +65 -62
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +125 -154
- package/dist/index.js.map +1 -0
- package/dist/render-BN7MLVDk.d.ts +24 -0
- package/dist/render-BN7MLVDk.d.ts.map +1 -0
- package/dist/render-D3Ssff59.js +34 -0
- package/dist/render-D3Ssff59.js.map +1 -0
- package/package.json +31 -28
- package/dist/chunk-5V3MNLHP.js +0 -34
package/dist/client/index.d.ts
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { FC } from 'react';
|
|
4
|
-
|
|
5
|
-
type MdxContent = FC<{
|
|
6
|
-
components?: MDXComponents;
|
|
7
|
-
}>;
|
|
8
|
-
interface Options {
|
|
9
|
-
scope?: Record<string, unknown>;
|
|
10
|
-
baseUrl?: string | URL;
|
|
11
|
-
jsxRuntime?: unknown;
|
|
12
|
-
}
|
|
13
|
-
declare function executeMdx(compiled: string, options?: Options): Promise<{
|
|
14
|
-
default: MdxContent;
|
|
15
|
-
toc?: TableOfContents;
|
|
16
|
-
}>;
|
|
17
|
-
declare function executeMdxSync(compiled: string, options?: Options): {
|
|
18
|
-
default: MdxContent;
|
|
19
|
-
toc?: TableOfContents;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { type MdxContent, executeMdx, executeMdxSync };
|
|
1
|
+
import { n as executeMdx, r as executeMdxSync, t as MdxContent } from "../render-BN7MLVDk.js";
|
|
2
|
+
export { MdxContent, executeMdx, executeMdxSync };
|
package/dist/client/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,89 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Pluggable } from
|
|
7
|
-
import {
|
|
8
|
-
import 'react';
|
|
1
|
+
import { t as MdxContent } from "./render-BN7MLVDk.js";
|
|
2
|
+
import * as Plugins from "@hanzo/docs-core/mdx-plugins";
|
|
3
|
+
import { CompileOptions } from "@mdx-js/mdx";
|
|
4
|
+
import { MDXComponents } from "mdx/types";
|
|
5
|
+
import { TableOfContents } from "@hanzo/docs-core/toc";
|
|
6
|
+
import { Pluggable } from "unified";
|
|
7
|
+
import { Compatible, VFile } from "vfile";
|
|
9
8
|
|
|
9
|
+
//#region src/utils.d.ts
|
|
10
10
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
11
11
|
/**
|
|
12
12
|
* Parse frontmatter, currently powered by `gray-matter`
|
|
13
13
|
*/
|
|
14
14
|
declare function parseFrontmatter(content: string): {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
frontmatter: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
content: string;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/compile.d.ts
|
|
21
22
|
type FumadocsPresetOptions = Omit<CompileOptions, 'remarkPlugins' | 'rehypePlugins'> & {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
preset?: 'fumadocs';
|
|
24
|
+
remarkPlugins?: ResolvePlugins;
|
|
25
|
+
rehypePlugins?: ResolvePlugins;
|
|
26
|
+
remarkHeadingOptions?: Plugins.RemarkHeadingOptions | false;
|
|
27
|
+
rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;
|
|
28
|
+
rehypeTocOptions?: Plugins.RehypeTocOptions | false;
|
|
29
|
+
remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;
|
|
30
|
+
remarkNpmOptions?: Plugins.RemarkNpmOptions | false;
|
|
31
|
+
/**
|
|
32
|
+
* The directory to find image sizes
|
|
33
|
+
*
|
|
34
|
+
* @defaultValue './public'
|
|
35
|
+
* @deprecated Use `remarkImageOptions.publicDir` instead
|
|
36
|
+
*/
|
|
37
|
+
imageDir?: string;
|
|
38
|
+
remarkImageOptions?: Plugins.RemarkImageOptions | false;
|
|
38
39
|
};
|
|
39
40
|
type CompilerOptions = (CompileOptions & {
|
|
40
|
-
|
|
41
|
+
preset: 'minimal';
|
|
41
42
|
}) | FumadocsPresetOptions;
|
|
42
43
|
interface CompileMDXOptions {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
source: string;
|
|
45
|
+
/**
|
|
46
|
+
* File path of source content
|
|
47
|
+
*/
|
|
48
|
+
filePath?: string;
|
|
49
|
+
components?: MDXComponents;
|
|
50
|
+
scope?: Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use `compiler.compileFile` instead if you doesn't need to execute output JavaScript code.
|
|
53
|
+
*/
|
|
54
|
+
skipRender?: boolean;
|
|
54
55
|
}
|
|
55
56
|
interface CompileMDXResult<TFrontmatter = Record<string, unknown>> {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
body: MdxContent;
|
|
58
|
+
frontmatter: TFrontmatter;
|
|
59
|
+
toc: TableOfContents;
|
|
60
|
+
vfile: VFile;
|
|
61
|
+
compiled: string;
|
|
62
|
+
exports: Record<string, unknown> | null;
|
|
62
63
|
}
|
|
63
64
|
declare function createCompiler(mdxOptions?: CompilerOptions): {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
render(compiled: string, scope?: Record<string, unknown>, filePath?: string): Promise<{
|
|
66
|
+
default: MdxContent;
|
|
67
|
+
toc?: TableOfContents;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Compile VFile
|
|
71
|
+
*/
|
|
72
|
+
compileFile(from: Compatible): Promise<VFile>;
|
|
73
|
+
compile<Frontmatter extends object = Record<string, unknown>>(options: CompileMDXOptions): Promise<CompileMDXResult<Frontmatter>>;
|
|
73
74
|
};
|
|
74
75
|
/**
|
|
75
76
|
* @deprecated Use `createCompiler()` API instead, this function will always create a new compiler instance.
|
|
76
77
|
*/
|
|
77
78
|
declare function compileMDX<Frontmatter extends object = Record<string, unknown>>(options: CompileMDXOptions & {
|
|
78
|
-
|
|
79
|
+
mdxOptions?: CompilerOptions;
|
|
79
80
|
}): Promise<CompileMDXResult<Frontmatter>>;
|
|
80
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/index.d.ts
|
|
81
83
|
/**
|
|
82
84
|
* @deprecated Use `compiler.render` instead
|
|
83
85
|
*/
|
|
84
86
|
declare function executeMdx(compiled: string, scope: object, baseUrl?: string | URL): Promise<{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
default: MdxContent;
|
|
88
|
+
toc?: TableOfContents;
|
|
87
89
|
}>;
|
|
88
|
-
|
|
89
|
-
export {
|
|
90
|
+
//#endregion
|
|
91
|
+
export { CompileMDXOptions, CompileMDXResult, CompilerOptions, type CompilerOptions as MDXOptions, FumadocsPresetOptions, compileMDX, createCompiler, executeMdx, parseFrontmatter };
|
|
92
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/utils.ts","../src/compile.ts","../src/index.ts"],"mappings":";;;;;;;;;KAGY,cAAA,G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AW,QAAA,UAAkB,KAAA,UAAe,OAAA,YAAmB,GAAA,GAAG,OAAA;WAuB3E,UAAA;QACH,eAAA;AAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,169 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
executeMdx
|
|
3
|
-
} from "./chunk-5V3MNLHP.js";
|
|
4
|
-
|
|
5
|
-
// src/compile.ts
|
|
1
|
+
import { t as executeMdx$1 } from "./render-D3Ssff59.js";
|
|
6
2
|
import * as Plugins from "@hanzo/docs-core/mdx-plugins";
|
|
7
3
|
import { createProcessor } from "@mdx-js/mdx";
|
|
8
|
-
|
|
9
|
-
// src/utils.ts
|
|
10
4
|
import matter from "gray-matter";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
//#region src/utils.ts
|
|
11
8
|
function pluginOption(def, options = []) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (typeof options === "function") {
|
|
16
|
-
return options(list);
|
|
17
|
-
}
|
|
18
|
-
return list;
|
|
9
|
+
const list = def(Array.isArray(options) ? options : []).filter(Boolean);
|
|
10
|
+
if (typeof options === "function") return options(list);
|
|
11
|
+
return list;
|
|
19
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse frontmatter, currently powered by `gray-matter`
|
|
15
|
+
*/
|
|
20
16
|
function parseFrontmatter(content) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const out = matter(content);
|
|
18
|
+
return {
|
|
19
|
+
frontmatter: out.data,
|
|
20
|
+
content: out.content
|
|
21
|
+
};
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/compile.ts
|
|
30
26
|
function createCompiler(mdxOptions) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
toc: exports?.toc ?? file.data.toc,
|
|
81
|
-
exports
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
};
|
|
27
|
+
let instance;
|
|
28
|
+
function getProcessor() {
|
|
29
|
+
if (instance) return instance;
|
|
30
|
+
let format = mdxOptions?.format;
|
|
31
|
+
if (!format || format === "detect") format = "mdx";
|
|
32
|
+
return instance = createProcessor({
|
|
33
|
+
...mdxOptions?.preset === "minimal" ? mdxOptions : getCompileOptions(mdxOptions),
|
|
34
|
+
format
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
async render(compiled, scope, filePath) {
|
|
39
|
+
return executeMdx$1(compiled, {
|
|
40
|
+
scope,
|
|
41
|
+
baseUrl: filePath ? pathToFileURL(filePath) : void 0,
|
|
42
|
+
jsxRuntime: mdxOptions?.development ? await import("react/jsx-dev-runtime") : void 0
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
async compileFile(from) {
|
|
46
|
+
return getProcessor().process(from);
|
|
47
|
+
},
|
|
48
|
+
async compile(options) {
|
|
49
|
+
const { scope = {}, skipRender } = options;
|
|
50
|
+
const { frontmatter, content } = parseFrontmatter(options.source);
|
|
51
|
+
const file = await this.compileFile({
|
|
52
|
+
value: content,
|
|
53
|
+
path: options.filePath,
|
|
54
|
+
data: { frontmatter }
|
|
55
|
+
});
|
|
56
|
+
const compiled = String(file);
|
|
57
|
+
const exports = !skipRender ? await this.render(compiled, scope, options.filePath) : null;
|
|
58
|
+
return {
|
|
59
|
+
vfile: file,
|
|
60
|
+
compiled,
|
|
61
|
+
frontmatter,
|
|
62
|
+
async body(props) {
|
|
63
|
+
if (!exports) throw new Error("Body cannot be rendered when `skipRender` is set to true");
|
|
64
|
+
return exports.default({ components: {
|
|
65
|
+
...options.components,
|
|
66
|
+
...props.components
|
|
67
|
+
} });
|
|
68
|
+
},
|
|
69
|
+
toc: exports?.toc ?? file.data.toc,
|
|
70
|
+
exports
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
85
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use `createCompiler()` API instead, this function will always create a new compiler instance.
|
|
77
|
+
*/
|
|
86
78
|
async function compileMDX(options) {
|
|
87
|
-
|
|
88
|
-
return compiler.compile(options);
|
|
79
|
+
return createCompiler(options.mdxOptions).compile(options);
|
|
89
80
|
}
|
|
90
|
-
function getCompileOptions({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
publicDir: imageDir,
|
|
123
|
-
...remarkImageOptions
|
|
124
|
-
}
|
|
125
|
-
] : null,
|
|
126
|
-
remarkCodeTab && remarkCodeTabOptions !== false ? [remarkCodeTab, remarkCodeTabOptions] : null,
|
|
127
|
-
remarkNpm && remarkNpmOptions !== false ? [remarkNpm, remarkNpmOptions] : null,
|
|
128
|
-
...v
|
|
129
|
-
],
|
|
130
|
-
options.remarkPlugins
|
|
131
|
-
),
|
|
132
|
-
rehypePlugins: pluginOption(
|
|
133
|
-
(v) => [
|
|
134
|
-
rehypeCode && rehypeCodeOptions !== false ? [rehypeCode, rehypeCodeOptions] : null,
|
|
135
|
-
rehypeToc && rehypeTocOptions !== false ? [rehypeToc, rehypeTocOptions] : null,
|
|
136
|
-
...v
|
|
137
|
-
],
|
|
138
|
-
options.rehypePlugins
|
|
139
|
-
)
|
|
140
|
-
};
|
|
81
|
+
function getCompileOptions({ preset: _, rehypeCodeOptions, remarkImageOptions, rehypeTocOptions, remarkHeadingOptions, remarkCodeTabOptions, remarkNpmOptions, imageDir = "./public", ...options } = {}) {
|
|
82
|
+
function getPlugin(name) {
|
|
83
|
+
return name in Plugins ? Plugins[name] : null;
|
|
84
|
+
}
|
|
85
|
+
const remarkGfm = getPlugin("remarkGfm");
|
|
86
|
+
const remarkHeading = getPlugin("remarkHeading");
|
|
87
|
+
const remarkCodeTab = getPlugin("remarkCodeTab");
|
|
88
|
+
const remarkNpm = getPlugin("remarkNpm");
|
|
89
|
+
const remarkImage = getPlugin("remarkImage");
|
|
90
|
+
const rehypeCode = getPlugin("rehypeCode");
|
|
91
|
+
const rehypeToc = getPlugin("rehypeToc");
|
|
92
|
+
return {
|
|
93
|
+
...options,
|
|
94
|
+
outputFormat: "function-body",
|
|
95
|
+
remarkPlugins: pluginOption((v) => [
|
|
96
|
+
remarkGfm,
|
|
97
|
+
remarkHeading && remarkHeadingOptions !== false ? [remarkHeading, remarkHeadingOptions] : null,
|
|
98
|
+
remarkImage && remarkImageOptions !== false ? [remarkImage, {
|
|
99
|
+
useImport: false,
|
|
100
|
+
publicDir: imageDir,
|
|
101
|
+
...remarkImageOptions
|
|
102
|
+
}] : null,
|
|
103
|
+
remarkCodeTab && remarkCodeTabOptions !== false ? [remarkCodeTab, remarkCodeTabOptions] : null,
|
|
104
|
+
remarkNpm && remarkNpmOptions !== false ? [remarkNpm, remarkNpmOptions] : null,
|
|
105
|
+
...v
|
|
106
|
+
], options.remarkPlugins),
|
|
107
|
+
rehypePlugins: pluginOption((v) => [
|
|
108
|
+
rehypeCode && rehypeCodeOptions !== false ? [rehypeCode, rehypeCodeOptions] : null,
|
|
109
|
+
rehypeToc && rehypeTocOptions !== false ? [rehypeToc, rehypeTocOptions] : null,
|
|
110
|
+
...v
|
|
111
|
+
], options.rehypePlugins)
|
|
112
|
+
};
|
|
141
113
|
}
|
|
142
114
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/index.ts
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Use `compiler.render` instead
|
|
119
|
+
*/
|
|
120
|
+
async function executeMdx(compiled, scope, baseUrl) {
|
|
121
|
+
let jsxRuntime;
|
|
122
|
+
if (process.env.NODE_ENV === "production") jsxRuntime = await import("react/jsx-runtime");
|
|
123
|
+
else jsxRuntime = await import("react/jsx-dev-runtime");
|
|
124
|
+
const fullScope = {
|
|
125
|
+
opts: {
|
|
126
|
+
...jsxRuntime,
|
|
127
|
+
baseUrl
|
|
128
|
+
},
|
|
129
|
+
...scope
|
|
130
|
+
};
|
|
131
|
+
const values = Object.values(fullScope);
|
|
132
|
+
const params = Object.keys(fullScope);
|
|
133
|
+
params.push(`return (async () => { ${compiled} })()`);
|
|
134
|
+
const hydrateFn = new Function(...params);
|
|
135
|
+
return await hydrateFn.apply(hydrateFn, values);
|
|
163
136
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
parseFrontmatter
|
|
169
|
-
};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
export { compileMDX, createCompiler, executeMdx, parseFrontmatter };
|
|
140
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["executeMdx"],"sources":["../src/utils.ts","../src/compile.ts","../src/index.ts"],"sourcesContent":["import type { Pluggable } from 'unified';\nimport matter from 'gray-matter';\n\nexport type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);\n\nexport function pluginOption(\n def: (v: Pluggable[]) => (Pluggable | false | null)[],\n options: ResolvePlugins = [],\n): Pluggable[] {\n const list = def(Array.isArray(options) ? options : []).filter(Boolean) as Pluggable[];\n\n if (typeof options === 'function') {\n return options(list);\n }\n\n return list;\n}\n\n/**\n * Parse frontmatter, currently powered by `gray-matter`\n */\nexport function parseFrontmatter(content: string) {\n const out = matter(content);\n\n return {\n frontmatter: out.data,\n content: out.content,\n };\n}\n","import * as Plugins from '@hanzo/docs-core/mdx-plugins';\nimport { type CompileOptions, createProcessor } from '@mdx-js/mdx';\nimport type { MDXComponents } from 'mdx/types';\nimport { parseFrontmatter, pluginOption, type ResolvePlugins } from './utils';\nimport type { Compatible, VFile } from 'vfile';\nimport type { TableOfContents } from '@hanzo/docs-core/toc';\nimport { executeMdx, type MdxContent } from '@/render';\nimport { pathToFileURL } from 'node:url';\n\nexport type FumadocsPresetOptions = Omit<CompileOptions, 'remarkPlugins' | 'rehypePlugins'> & {\n preset?: 'fumadocs';\n remarkPlugins?: ResolvePlugins;\n rehypePlugins?: ResolvePlugins;\n\n remarkHeadingOptions?: Plugins.RemarkHeadingOptions | false;\n rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;\n rehypeTocOptions?: Plugins.RehypeTocOptions | false;\n remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;\n remarkNpmOptions?: Plugins.RemarkNpmOptions | false;\n\n /**\n * The directory to find image sizes\n *\n * @defaultValue './public'\n * @deprecated Use `remarkImageOptions.publicDir` instead\n */\n imageDir?: string;\n\n remarkImageOptions?: Plugins.RemarkImageOptions | false;\n};\n\nexport type CompilerOptions = (CompileOptions & { preset: 'minimal' }) | FumadocsPresetOptions;\n\nexport interface CompileMDXOptions {\n source: string;\n /**\n * File path of source content\n */\n filePath?: string;\n\n components?: MDXComponents;\n scope?: Record<string, unknown>;\n\n /**\n * @deprecated Use `compiler.compileFile` instead if you doesn't need to execute output JavaScript code.\n */\n skipRender?: boolean;\n}\n\nexport interface CompileMDXResult<TFrontmatter = Record<string, unknown>> {\n body: MdxContent;\n frontmatter: TFrontmatter;\n toc: TableOfContents;\n vfile: VFile;\n\n compiled: string;\n exports: Record<string, unknown> | null;\n}\n\nexport function createCompiler(mdxOptions?: CompilerOptions) {\n let instance: ReturnType<typeof createProcessor> | undefined;\n\n function getProcessor() {\n if (instance) return instance;\n\n let format = mdxOptions?.format;\n if (!format || format === 'detect') format = 'mdx';\n\n return (instance = createProcessor({\n ...(mdxOptions?.preset === 'minimal' ? mdxOptions : getCompileOptions(mdxOptions)),\n format,\n }));\n }\n\n return {\n async render(compiled: string, scope?: Record<string, unknown>, filePath?: string) {\n return executeMdx(compiled, {\n scope,\n baseUrl: filePath ? pathToFileURL(filePath) : undefined,\n jsxRuntime: mdxOptions?.development ? await import('react/jsx-dev-runtime') : undefined,\n });\n },\n /**\n * Compile VFile\n */\n async compileFile(from: Compatible): Promise<VFile> {\n return getProcessor().process(from);\n },\n async compile<Frontmatter extends object = Record<string, unknown>>(\n options: CompileMDXOptions,\n ): Promise<CompileMDXResult<Frontmatter>> {\n const { scope = {}, skipRender } = options;\n const { frontmatter, content } = parseFrontmatter(options.source);\n\n const file = await this.compileFile({\n value: content,\n path: options.filePath,\n data: {\n frontmatter,\n },\n });\n const compiled = String(file);\n const exports = !skipRender ? await this.render(compiled, scope, options.filePath) : null;\n\n return {\n vfile: file,\n compiled,\n frontmatter: frontmatter as Frontmatter,\n async body(props) {\n if (!exports) throw new Error('Body cannot be rendered when `skipRender` is set to true');\n\n return exports.default({\n components: { ...options.components, ...props.components },\n });\n },\n toc: exports?.toc ?? (file.data.toc as TableOfContents),\n exports,\n };\n },\n };\n}\n\n/**\n * @deprecated Use `createCompiler()` API instead, this function will always create a new compiler instance.\n */\nexport async function compileMDX<Frontmatter extends object = Record<string, unknown>>(\n options: CompileMDXOptions & {\n mdxOptions?: CompilerOptions;\n },\n): Promise<CompileMDXResult<Frontmatter>> {\n const compiler = createCompiler(options.mdxOptions);\n\n return compiler.compile(options);\n}\n\nfunction getCompileOptions({\n preset: _,\n rehypeCodeOptions,\n remarkImageOptions,\n rehypeTocOptions,\n remarkHeadingOptions,\n remarkCodeTabOptions,\n remarkNpmOptions,\n imageDir = './public',\n ...options\n}: FumadocsPresetOptions = {}): CompileOptions {\n function getPlugin<K extends keyof typeof Plugins>(name: K): (typeof Plugins)[K] | null {\n return name in Plugins ? Plugins[name] : null;\n }\n const remarkGfm = getPlugin('remarkGfm');\n const remarkHeading = getPlugin('remarkHeading');\n const remarkCodeTab = getPlugin('remarkCodeTab');\n const remarkNpm = getPlugin('remarkNpm');\n const remarkImage = getPlugin('remarkImage');\n const rehypeCode = getPlugin('rehypeCode');\n const rehypeToc = getPlugin('rehypeToc');\n\n return {\n ...options,\n outputFormat: 'function-body',\n remarkPlugins: pluginOption(\n (v) => [\n remarkGfm,\n remarkHeading && remarkHeadingOptions !== false\n ? [remarkHeading, remarkHeadingOptions]\n : null,\n remarkImage && remarkImageOptions !== false\n ? [\n remarkImage,\n {\n useImport: false,\n publicDir: imageDir,\n ...remarkImageOptions,\n } satisfies Plugins.RemarkImageOptions,\n ]\n : null,\n remarkCodeTab && remarkCodeTabOptions !== false\n ? [remarkCodeTab, remarkCodeTabOptions]\n : null,\n remarkNpm && remarkNpmOptions !== false ? [remarkNpm, remarkNpmOptions] : null,\n ...v,\n ],\n options.remarkPlugins,\n ),\n rehypePlugins: pluginOption(\n (v) => [\n rehypeCode && rehypeCodeOptions !== false ? [rehypeCode, rehypeCodeOptions] : null,\n rehypeToc && rehypeTocOptions !== false ? [rehypeToc, rehypeTocOptions] : null,\n ...v,\n ],\n options.rehypePlugins,\n ),\n };\n}\n\n// backward compatible\nexport type { CompilerOptions as MDXOptions };\n","import type { TableOfContents } from '@hanzo/docs-core/toc';\nimport type { MdxContent } from '@/render';\n\nexport * from './compile';\nexport { parseFrontmatter } from './utils';\n\n/**\n * @deprecated Use `compiler.render` instead\n */\nexport async function executeMdx(compiled: string, scope: object, baseUrl?: string | URL) {\n let jsxRuntime;\n\n if (process.env.NODE_ENV === 'production') {\n jsxRuntime = await import('react/jsx-runtime');\n } else {\n jsxRuntime = await import('react/jsx-dev-runtime');\n }\n\n const fullScope = {\n opts: {\n ...jsxRuntime,\n baseUrl,\n },\n ...scope,\n };\n\n const values = Object.values(fullScope);\n const params = Object.keys(fullScope);\n params.push(`return (async () => { ${compiled} })()`);\n const hydrateFn = new Function(...params);\n\n return (await hydrateFn.apply(hydrateFn, values)) as {\n default: MdxContent;\n toc?: TableOfContents;\n };\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,aACd,KACA,UAA0B,EAAE,EACf;CACb,MAAM,OAAO,IAAI,MAAM,QAAQ,QAAQ,GAAG,UAAU,EAAE,CAAC,CAAC,OAAO,QAAQ;AAEvE,KAAI,OAAO,YAAY,WACrB,QAAO,QAAQ,KAAK;AAGtB,QAAO;;;;;AAMT,SAAgB,iBAAiB,SAAiB;CAChD,MAAM,MAAM,OAAO,QAAQ;AAE3B,QAAO;EACL,aAAa,IAAI;EACjB,SAAS,IAAI;EACd;;;;;ACgCH,SAAgB,eAAe,YAA8B;CAC3D,IAAI;CAEJ,SAAS,eAAe;AACtB,MAAI,SAAU,QAAO;EAErB,IAAI,SAAS,YAAY;A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+
import { TableOfContents } from "@hanzo/docs-core/toc";
|
|
3
|
+
import { FC } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/render.d.ts
|
|
6
|
+
type MdxContent = FC<{
|
|
7
|
+
components?: MDXComponents;
|
|
8
|
+
}>;
|
|
9
|
+
interface Options {
|
|
10
|
+
scope?: Record<string, unknown>;
|
|
11
|
+
baseUrl?: string | URL;
|
|
12
|
+
jsxRuntime?: unknown;
|
|
13
|
+
}
|
|
14
|
+
declare function executeMdx(compiled: string, options?: Options): Promise<{
|
|
15
|
+
default: MdxContent;
|
|
16
|
+
toc?: TableOfContents;
|
|
17
|
+
}>;
|
|
18
|
+
declare function executeMdxSync(compiled: string, options?: Options): {
|
|
19
|
+
default: MdxContent;
|
|
20
|
+
toc?: TableOfContents;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { executeMdx as n, executeMdxSync as r, MdxContent as t };
|
|
24
|
+
//# sourceMappingURL=render-BN7MLVDk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-BN7MLVDk.d.ts","names":[],"sources":["../src/render.ts"],"mappings":";;;;;KAKY,UAAA,GAAa,EAAA;EAAK,UAAA,GAAa,aAAA;AAAA;AAAA,UAEjC,OAAA;EACR,KAAA,GAAQ,MAAA;EACR,OAAA,YAAmB,GAAA;EACnB,UAAA;AAAA;AAAA,iBAMoB,UAAA,CAAW,QAAA,UAAkB,OAAA,GAAS,OAAA,GAAY,OAAA;WAa3D,UAAA;QACH,eAAA;AAAA;AAAA,iBAIM,cAAA,CAAe,QAAA,UAAkB,OAAA,GAAS,OAAA;EActD,OAAA,EAAS,UAAA;EACT,GAAA,GAAM,eAAA;AAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import jsxRuntimeDefault from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/render.ts
|
|
4
|
+
const AsyncFunction = Object.getPrototypeOf(executeMdx).constructor;
|
|
5
|
+
async function executeMdx(compiled, options = {}) {
|
|
6
|
+
const { opts: scopeOpts, ...scope } = options.scope ?? {};
|
|
7
|
+
const fullScope = {
|
|
8
|
+
opts: {
|
|
9
|
+
...scopeOpts,
|
|
10
|
+
...options.jsxRuntime ?? jsxRuntimeDefault,
|
|
11
|
+
baseUrl: options.baseUrl
|
|
12
|
+
},
|
|
13
|
+
...scope
|
|
14
|
+
};
|
|
15
|
+
const hydrateFn = new AsyncFunction(...Object.keys(fullScope), compiled);
|
|
16
|
+
return await hydrateFn.apply(hydrateFn, Object.values(fullScope));
|
|
17
|
+
}
|
|
18
|
+
function executeMdxSync(compiled, options = {}) {
|
|
19
|
+
const { opts: scopeOpts, ...scope } = options.scope ?? {};
|
|
20
|
+
const fullScope = {
|
|
21
|
+
opts: {
|
|
22
|
+
...scopeOpts,
|
|
23
|
+
...options.jsxRuntime ?? jsxRuntimeDefault,
|
|
24
|
+
baseUrl: options.baseUrl
|
|
25
|
+
},
|
|
26
|
+
...scope
|
|
27
|
+
};
|
|
28
|
+
const hydrateFn = new Function(...Object.keys(fullScope), compiled);
|
|
29
|
+
return hydrateFn.apply(hydrateFn, Object.values(fullScope));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { executeMdxSync as n, executeMdx as t };
|
|
34
|
+
//# sourceMappingURL=render-D3Ssff59.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-D3Ssff59.js","names":[],"sources":["../src/render.ts"],"sourcesContent":["import type { MDXComponents } from 'mdx/types';\nimport type { TableOfContents } from '@hanzo/docs-core/toc';\nimport type { FC } from 'react';\nimport jsxRuntimeDefault from 'react/jsx-runtime';\n\nexport type MdxContent = FC<{ components?: MDXComponents }>;\n\ninterface Options {\n scope?: Record<string, unknown>;\n baseUrl?: string | URL;\n jsxRuntime?: unknown;\n}\n\nconst AsyncFunction: new (...args: string[]) => (...args: unknown[]) => Promise<unknown> =\n Object.getPrototypeOf(executeMdx).constructor;\n\nexport async function executeMdx(compiled: string, options: Options = {}) {\n const { opts: scopeOpts, ...scope } = options.scope ?? {};\n const fullScope = {\n opts: {\n ...(scopeOpts as object),\n ...(options.jsxRuntime ?? jsxRuntimeDefault),\n baseUrl: options.baseUrl,\n },\n ...scope,\n };\n\n const hydrateFn = new AsyncFunction(...Object.keys(fullScope), compiled);\n return (await hydrateFn.apply(hydrateFn, Object.values(fullScope))) as {\n default: MdxContent;\n toc?: TableOfContents;\n };\n}\n\nexport function executeMdxSync(compiled: string, options: Options = {}) {\n const { opts: scopeOpts, ...scope } = options.scope ?? {};\n const fullScope = {\n opts: {\n ...(scopeOpts as object),\n ...(options.jsxRuntime ?? jsxRuntimeDefault),\n baseUrl: options.baseUrl,\n },\n ...scope,\n };\n\n const hydrateFn = new Function(...Object.keys(fullScope), compiled);\n\n return hydrateFn.apply(hydrateFn, Object.values(fullScope)) as {\n default: MdxContent;\n toc?: TableOfContents;\n };\n}\n"],"mappings":";;;AAaA,MAAM,gBACJ,OAAO,eAAe,WAAW,CAAC;AAEpC,eAAsB,WAAW,UAAkB,UAAmB,EAAE,EAAE;CACxE,MAAM,EAAE,MAAM,WAAW,GAAG,UAAU,QAAQ,SAAS,EAAE;CACzD,MAAM,YAAY;EAChB,MAAM;GACJ,GAAI;GACJ,GAAI,QAAQ,cAAc;GAC1B,SAAS,QAAQ;GAClB;EACD,GAAG;EACJ;CAED,MAAM,YAAY,IAAI,cAAc,GAAG,OAAO,KAAK,UAAU,EAAE,SAAS;AACxE,QAAQ,MAAM,UAAU,MAAM,WAAW,OAAO,OAAO,UAAU,CAAC;;AAMpE,SAAgB,eAAe,UAAkB,UAAmB,EAAE,EAAE;CACtE,MAAM,EAAE,MAAM,WAAW,GAAG,UAAU,QAAQ,SAAS,EAAE;CACzD,MAAM,YAAY;EAChB,MAAM;GACJ,GAAI;GACJ,GAAI,QAAQ,cAAc;GAC1B,SAAS,QAAQ;GAClB;EACD,GAAG;EACJ;CAED,MAAM,YAAY,IAAI,SAAS,GAAG,OAAO,KAAK,UAAU,EAAE,SAAS;AAEnE,QAAO,UAAU,MAAM,WAAW,OAAO,OAAO,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,67 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/docs-mdx-remote",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "The remote MDX files adapter for Hanzo Docs",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"Hanzo",
|
|
7
6
|
"Docs",
|
|
8
|
-
"
|
|
9
|
-
"Remote"
|
|
7
|
+
"hanzo-docs"
|
|
10
8
|
],
|
|
11
|
-
"homepage": "https://
|
|
12
|
-
"repository": "github:hanzoai/docs",
|
|
9
|
+
"homepage": "https://hanzoai.github.io/docs",
|
|
13
10
|
"license": "MIT",
|
|
14
|
-
"author": "
|
|
11
|
+
"author": "Hanzo AI",
|
|
12
|
+
"repository": "github:hanzoai/docs",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/*"
|
|
15
|
+
],
|
|
15
16
|
"type": "module",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
16
19
|
"exports": {
|
|
17
20
|
".": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
20
23
|
},
|
|
21
24
|
"./client": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
25
|
+
"types": "./dist/client/index.d.ts",
|
|
26
|
+
"import": "./dist/client/index.js"
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"dist/*"
|
|
30
|
-
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"@mdx-js/mdx": "^3.1.1",
|
|
33
34
|
"gray-matter": "^4.0.3",
|
|
34
|
-
"
|
|
35
|
+
"unified": "^11.0.5",
|
|
36
|
+
"vfile": "^6.0.3",
|
|
37
|
+
"zod": "^4.3.6"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"@types/mdx": "^2.0.13",
|
|
38
|
-
"@types/node": "
|
|
39
|
-
"@types/react": "^19.2.
|
|
40
|
-
"react": "^19.2.
|
|
41
|
+
"@types/node": "25.2.1",
|
|
42
|
+
"@types/react": "^19.2.13",
|
|
43
|
+
"react": "^19.2.4",
|
|
41
44
|
"tinyglobby": "^0.2.15",
|
|
42
|
-
"
|
|
43
|
-
"vfile": "^6.0.3",
|
|
45
|
+
"tsdown": "^0.20.3",
|
|
44
46
|
"eslint-config-custom": "0.0.0",
|
|
45
|
-
"@hanzo/docs-core": "16.
|
|
47
|
+
"@hanzo/docs-core": "16.5.3",
|
|
46
48
|
"tsconfig": "0.0.0"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
51
|
+
"@types/mdx": "*",
|
|
49
52
|
"@types/react": "*",
|
|
50
53
|
"@hanzo/docs-core": "^15.0.0 || ^16.0.0",
|
|
51
54
|
"react": "18.x.x || 19.x.x"
|
|
52
55
|
},
|
|
53
56
|
"peerDependenciesMeta": {
|
|
57
|
+
"@types/mdx": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
54
60
|
"@types/react": {
|
|
55
61
|
"optional": true
|
|
56
62
|
}
|
|
57
63
|
},
|
|
58
|
-
"publishConfig": {
|
|
59
|
-
"access": "public"
|
|
60
|
-
},
|
|
61
64
|
"scripts": {
|
|
62
|
-
"build": "
|
|
65
|
+
"build": "tsdown",
|
|
63
66
|
"clean": "rimraf dist",
|
|
64
|
-
"dev": "
|
|
67
|
+
"dev": "tsdown --watch",
|
|
65
68
|
"lint": "eslint .",
|
|
66
69
|
"types:check": "tsc --noEmit"
|
|
67
70
|
}
|
package/dist/chunk-5V3MNLHP.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/render.ts
|
|
2
|
-
import jsxRuntimeDefault from "react/jsx-runtime";
|
|
3
|
-
var AsyncFunction = Object.getPrototypeOf(executeMdx).constructor;
|
|
4
|
-
async function executeMdx(compiled, options = {}) {
|
|
5
|
-
const { opts: scopeOpts, ...scope } = options.scope ?? {};
|
|
6
|
-
const fullScope = {
|
|
7
|
-
opts: {
|
|
8
|
-
...scopeOpts,
|
|
9
|
-
...options.jsxRuntime ?? jsxRuntimeDefault,
|
|
10
|
-
baseUrl: options.baseUrl
|
|
11
|
-
},
|
|
12
|
-
...scope
|
|
13
|
-
};
|
|
14
|
-
const hydrateFn = new AsyncFunction(...Object.keys(fullScope), compiled);
|
|
15
|
-
return await hydrateFn.apply(hydrateFn, Object.values(fullScope));
|
|
16
|
-
}
|
|
17
|
-
function executeMdxSync(compiled, options = {}) {
|
|
18
|
-
const { opts: scopeOpts, ...scope } = options.scope ?? {};
|
|
19
|
-
const fullScope = {
|
|
20
|
-
opts: {
|
|
21
|
-
...scopeOpts,
|
|
22
|
-
...options.jsxRuntime ?? jsxRuntimeDefault,
|
|
23
|
-
baseUrl: options.baseUrl
|
|
24
|
-
},
|
|
25
|
-
...scope
|
|
26
|
-
};
|
|
27
|
-
const hydrateFn = new Function(...Object.keys(fullScope), compiled);
|
|
28
|
-
return hydrateFn.apply(hydrateFn, Object.values(fullScope));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
executeMdx,
|
|
33
|
-
executeMdxSync
|
|
34
|
-
};
|