@windrun-huaiin/third-ui 22.0.1 → 23.0.0
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/fuma/server/features/base.d.ts +2 -0
- package/dist/fuma/server/features/base.js +13 -0
- package/dist/fuma/server/features/base.mjs +11 -0
- package/dist/fuma/server/features/code.d.ts +3 -0
- package/dist/fuma/server/features/code.js +66 -0
- package/dist/fuma/server/features/code.mjs +64 -0
- package/dist/fuma/server/features/math.d.ts +2 -0
- package/dist/fuma/server/features/math.js +14 -0
- package/dist/fuma/server/features/math.mjs +12 -0
- package/dist/fuma/server/features/mermaid.d.ts +2 -0
- package/dist/fuma/server/features/mermaid.js +13 -0
- package/dist/fuma/server/features/mermaid.mjs +11 -0
- package/dist/fuma/server/features/type-table.d.ts +2 -0
- package/dist/fuma/server/features/type-table.js +12 -0
- package/dist/fuma/server/features/type-table.mjs +10 -0
- package/dist/fuma/server/features/widgets.d.ts +2 -0
- package/dist/fuma/server/features/widgets.js +26 -0
- package/dist/fuma/server/features/widgets.mjs +24 -0
- package/dist/fuma/server/optional-features.d.ts +6 -8
- package/dist/fuma/server/optional-features.js +13 -107
- package/dist/fuma/server/optional-features.mjs +6 -104
- package/dist/fuma/server/site-mdx-base.d.ts +13 -0
- package/dist/fuma/server/site-mdx-base.js +32 -0
- package/dist/fuma/server/site-mdx-base.mjs +29 -0
- package/dist/fuma/server/site-mdx-components.d.ts +1 -1
- package/dist/fuma/server/site-mdx-components.js +7 -8
- package/dist/fuma/server/site-mdx-components.mjs +8 -9
- package/dist/fuma/server/site-mdx-fallbacks.d.ts +18 -0
- package/dist/fuma/server/site-mdx-fallbacks.js +49 -0
- package/dist/fuma/server/site-mdx-fallbacks.mjs +45 -0
- package/dist/fuma/server/site-mdx-features/code.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/code.js +7 -0
- package/dist/fuma/server/site-mdx-features/code.mjs +1 -0
- package/dist/fuma/server/site-mdx-features/math.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/math.js +7 -0
- package/dist/fuma/server/site-mdx-features/math.mjs +1 -0
- package/dist/fuma/server/site-mdx-features/mermaid.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/mermaid.js +7 -0
- package/dist/fuma/server/site-mdx-features/mermaid.mjs +1 -0
- package/dist/fuma/server/site-mdx-features/type-table.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/type-table.js +7 -0
- package/dist/fuma/server/site-mdx-features/type-table.mjs +1 -0
- package/dist/fuma/server/site-mdx-presets.d.ts +2 -1
- package/dist/fuma/server/site-mdx-presets.js +22 -13
- package/dist/fuma/server/site-mdx-presets.mjs +22 -12
- package/dist/fuma/share/markdown-component-map.js +43 -29
- package/dist/fuma/share/markdown-component-map.mjs +42 -28
- package/package.json +29 -4
- package/src/fuma/server/features/base.tsx +23 -0
- package/src/fuma/server/features/code.tsx +104 -0
- package/src/fuma/server/features/math.ts +16 -0
- package/src/fuma/server/features/mermaid.tsx +21 -0
- package/src/fuma/server/features/type-table.ts +12 -0
- package/src/fuma/server/features/widgets.tsx +34 -0
- package/src/fuma/server/optional-features.tsx +6 -168
- package/src/fuma/server/site-mdx-base.tsx +62 -0
- package/src/fuma/server/site-mdx-components.tsx +10 -12
- package/src/fuma/server/site-mdx-fallbacks.tsx +122 -0
- package/src/fuma/server/site-mdx-features/code.ts +1 -0
- package/src/fuma/server/site-mdx-features/math.ts +1 -0
- package/src/fuma/server/site-mdx-features/mermaid.ts +1 -0
- package/src/fuma/server/site-mdx-features/type-table.ts +1 -0
- package/src/fuma/server/site-mdx-presets.ts +52 -1
- package/src/fuma/share/markdown-component-map.tsx +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MDXComponents } from 'mdx/types';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type
|
|
3
|
+
import { type SiteMdxFeature } from './site-mdx-presets';
|
|
4
4
|
export interface SiteMdxComponentsOptions {
|
|
5
5
|
imageFallbackSrc?: string;
|
|
6
6
|
cdnBaseUrl?: string;
|
|
@@ -4,15 +4,14 @@ var siteMdxPresets = require('./site-mdx-presets.js');
|
|
|
4
4
|
|
|
5
5
|
function createSiteMdxComponents(options) {
|
|
6
6
|
const { additionalComponents, cdnBaseUrl, features = siteMdxPresets.DEFAULT_SITE_MDX_FEATURES, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
|
|
7
|
-
const featureMap = siteMdxPresets.createSiteFeatureComponentMap({
|
|
8
|
-
cdnBaseUrl,
|
|
9
|
-
iconMap,
|
|
10
|
-
imageFallbackSrc,
|
|
11
|
-
watermarkEnabled,
|
|
12
|
-
watermarkText,
|
|
13
|
-
});
|
|
14
7
|
return function getMDXComponents(components) {
|
|
15
|
-
return siteMdxPresets.
|
|
8
|
+
return siteMdxPresets.createComposedSiteMdxComponents(features, {
|
|
9
|
+
cdnBaseUrl,
|
|
10
|
+
iconMap,
|
|
11
|
+
imageFallbackSrc,
|
|
12
|
+
watermarkEnabled,
|
|
13
|
+
watermarkText,
|
|
14
|
+
}, additionalComponents, components);
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { DEFAULT_SITE_MDX_FEATURES,
|
|
1
|
+
import { DEFAULT_SITE_MDX_FEATURES, createComposedSiteMdxComponents } from './site-mdx-presets.mjs';
|
|
2
2
|
|
|
3
3
|
function createSiteMdxComponents(options) {
|
|
4
4
|
const { additionalComponents, cdnBaseUrl, features = DEFAULT_SITE_MDX_FEATURES, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
|
|
5
|
-
const featureMap = createSiteFeatureComponentMap({
|
|
6
|
-
cdnBaseUrl,
|
|
7
|
-
iconMap,
|
|
8
|
-
imageFallbackSrc,
|
|
9
|
-
watermarkEnabled,
|
|
10
|
-
watermarkText,
|
|
11
|
-
});
|
|
12
5
|
return function getMDXComponents(components) {
|
|
13
|
-
return
|
|
6
|
+
return createComposedSiteMdxComponents(features, {
|
|
7
|
+
cdnBaseUrl,
|
|
8
|
+
iconMap,
|
|
9
|
+
imageFallbackSrc,
|
|
10
|
+
watermarkEnabled,
|
|
11
|
+
watermarkText,
|
|
12
|
+
}, additionalComponents, components);
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
15
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
type MissingFeatureBlockProps = ComponentPropsWithoutRef<'div'> & {
|
|
3
|
+
feature: string;
|
|
4
|
+
component: string;
|
|
5
|
+
};
|
|
6
|
+
type MissingFeatureInlineProps = ComponentPropsWithoutRef<'span'> & {
|
|
7
|
+
feature: string;
|
|
8
|
+
component: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function MissingMdxFeatureBlock({ feature, component, children, className, ...props }: MissingFeatureBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function MissingMdxFeatureInline({ feature, component, children, className, ...props }: MissingFeatureInlineProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function createMissingMdxFeatureComponents(): {
|
|
13
|
+
MathBlock: (props: ComponentPropsWithoutRef<"div">) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
InlineMath: (props: ComponentPropsWithoutRef<"span">) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
Mermaid: (props: ComponentPropsWithoutRef<"div">) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
TypeTable: (props: ComponentPropsWithoutRef<"div">) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
function renderChildren(children) {
|
|
7
|
+
if (children == null || children === '') {
|
|
8
|
+
return jsxRuntime.jsx("span", { className: "italic text-fd-muted-foreground", children: "No fallback content." });
|
|
9
|
+
}
|
|
10
|
+
return children;
|
|
11
|
+
}
|
|
12
|
+
function hasChildren(children) {
|
|
13
|
+
return children != null && children !== '';
|
|
14
|
+
}
|
|
15
|
+
function getDisplayProps(props) {
|
|
16
|
+
return Object.entries(props)
|
|
17
|
+
.filter(([, value]) => typeof value === 'string' ||
|
|
18
|
+
typeof value === 'number' ||
|
|
19
|
+
typeof value === 'boolean')
|
|
20
|
+
.map(([key, value]) => [key, String(value)]);
|
|
21
|
+
}
|
|
22
|
+
function MissingMdxFeatureBlock(_a) {
|
|
23
|
+
var { feature, component, children, className } = _a, props = tslib.__rest(_a, ["feature", "component", "children", "className"]);
|
|
24
|
+
const displayProps = getDisplayProps(props);
|
|
25
|
+
return (jsxRuntime.jsxs("div", { className: [
|
|
26
|
+
'my-4 rounded-xl border border-red-300 bg-red-50/80 p-4 text-sm text-red-950 shadow-sm dark:border-red-800/80 dark:bg-red-950/30 dark:text-red-100',
|
|
27
|
+
className,
|
|
28
|
+
].filter(Boolean).join(' '), children: [jsxRuntime.jsxs("div", { className: "mb-2 flex flex-wrap items-center gap-2 font-medium", children: [jsxRuntime.jsx("span", { children: "MDX feature not enabled" }), jsxRuntime.jsx("code", { className: "rounded bg-red-100 px-1.5 py-0.5 text-xs dark:bg-red-900/60", children: feature }), jsxRuntime.jsx("code", { className: "rounded bg-red-100 px-1.5 py-0.5 text-xs dark:bg-red-900/60", children: component })] }), displayProps.length > 0 && (jsxRuntime.jsx("div", { className: "mb-2 flex flex-wrap gap-1.5 text-xs", children: displayProps.map(([key, value]) => (jsxRuntime.jsxs("span", { className: "rounded-md border border-red-200 bg-white/60 px-1.5 py-0.5 font-mono dark:border-red-900/70 dark:bg-black/20", children: [key, "=", value] }, key))) })), jsxRuntime.jsx("div", { className: "whitespace-pre-wrap break-words rounded-lg border border-red-200 bg-white/70 p-3 font-mono text-xs text-red-900 dark:border-red-900/70 dark:bg-black/20 dark:text-red-100", children: renderChildren(children) })] }));
|
|
29
|
+
}
|
|
30
|
+
function MissingMdxFeatureInline(_a) {
|
|
31
|
+
var { feature, component, children, className } = _a, props = tslib.__rest(_a, ["feature", "component", "children", "className"]);
|
|
32
|
+
const displayProps = getDisplayProps(props);
|
|
33
|
+
return (jsxRuntime.jsxs("span", { className: [
|
|
34
|
+
'inline-flex max-w-full items-center gap-1 rounded-md border border-red-300 bg-red-50 px-1.5 py-0.5 text-sm text-red-900 dark:border-red-800 dark:bg-red-950/40 dark:text-red-100',
|
|
35
|
+
className,
|
|
36
|
+
].filter(Boolean).join(' '), title: `MDX feature not enabled: ${feature} (${component})`, children: [jsxRuntime.jsx("span", { className: "font-medium", children: component }), displayProps.map(([key, value]) => (jsxRuntime.jsxs("span", { className: "font-mono text-xs opacity-80", children: [key, "=", value] }, key))), hasChildren(children) && (jsxRuntime.jsx("span", { className: "font-mono text-xs opacity-80", children: children }))] }));
|
|
37
|
+
}
|
|
38
|
+
function createMissingMdxFeatureComponents() {
|
|
39
|
+
return {
|
|
40
|
+
MathBlock: (props) => (jsxRuntime.jsx(MissingMdxFeatureBlock, Object.assign({}, props, { feature: "math", component: "MathBlock" }))),
|
|
41
|
+
InlineMath: (props) => (jsxRuntime.jsx(MissingMdxFeatureInline, Object.assign({}, props, { feature: "math", component: "InlineMath" }))),
|
|
42
|
+
Mermaid: (props) => (jsxRuntime.jsx(MissingMdxFeatureBlock, Object.assign({}, props, { feature: "diagram renderer", component: "Mermaid" }))),
|
|
43
|
+
TypeTable: (props) => (jsxRuntime.jsx(MissingMdxFeatureBlock, Object.assign({}, props, { feature: "API table renderer", component: "TypeTable" }))),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.MissingMdxFeatureBlock = MissingMdxFeatureBlock;
|
|
48
|
+
exports.MissingMdxFeatureInline = MissingMdxFeatureInline;
|
|
49
|
+
exports.createMissingMdxFeatureComponents = createMissingMdxFeatureComponents;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function renderChildren(children) {
|
|
5
|
+
if (children == null || children === '') {
|
|
6
|
+
return jsx("span", { className: "italic text-fd-muted-foreground", children: "No fallback content." });
|
|
7
|
+
}
|
|
8
|
+
return children;
|
|
9
|
+
}
|
|
10
|
+
function hasChildren(children) {
|
|
11
|
+
return children != null && children !== '';
|
|
12
|
+
}
|
|
13
|
+
function getDisplayProps(props) {
|
|
14
|
+
return Object.entries(props)
|
|
15
|
+
.filter(([, value]) => typeof value === 'string' ||
|
|
16
|
+
typeof value === 'number' ||
|
|
17
|
+
typeof value === 'boolean')
|
|
18
|
+
.map(([key, value]) => [key, String(value)]);
|
|
19
|
+
}
|
|
20
|
+
function MissingMdxFeatureBlock(_a) {
|
|
21
|
+
var { feature, component, children, className } = _a, props = __rest(_a, ["feature", "component", "children", "className"]);
|
|
22
|
+
const displayProps = getDisplayProps(props);
|
|
23
|
+
return (jsxs("div", { className: [
|
|
24
|
+
'my-4 rounded-xl border border-red-300 bg-red-50/80 p-4 text-sm text-red-950 shadow-sm dark:border-red-800/80 dark:bg-red-950/30 dark:text-red-100',
|
|
25
|
+
className,
|
|
26
|
+
].filter(Boolean).join(' '), children: [jsxs("div", { className: "mb-2 flex flex-wrap items-center gap-2 font-medium", children: [jsx("span", { children: "MDX feature not enabled" }), jsx("code", { className: "rounded bg-red-100 px-1.5 py-0.5 text-xs dark:bg-red-900/60", children: feature }), jsx("code", { className: "rounded bg-red-100 px-1.5 py-0.5 text-xs dark:bg-red-900/60", children: component })] }), displayProps.length > 0 && (jsx("div", { className: "mb-2 flex flex-wrap gap-1.5 text-xs", children: displayProps.map(([key, value]) => (jsxs("span", { className: "rounded-md border border-red-200 bg-white/60 px-1.5 py-0.5 font-mono dark:border-red-900/70 dark:bg-black/20", children: [key, "=", value] }, key))) })), jsx("div", { className: "whitespace-pre-wrap break-words rounded-lg border border-red-200 bg-white/70 p-3 font-mono text-xs text-red-900 dark:border-red-900/70 dark:bg-black/20 dark:text-red-100", children: renderChildren(children) })] }));
|
|
27
|
+
}
|
|
28
|
+
function MissingMdxFeatureInline(_a) {
|
|
29
|
+
var { feature, component, children, className } = _a, props = __rest(_a, ["feature", "component", "children", "className"]);
|
|
30
|
+
const displayProps = getDisplayProps(props);
|
|
31
|
+
return (jsxs("span", { className: [
|
|
32
|
+
'inline-flex max-w-full items-center gap-1 rounded-md border border-red-300 bg-red-50 px-1.5 py-0.5 text-sm text-red-900 dark:border-red-800 dark:bg-red-950/40 dark:text-red-100',
|
|
33
|
+
className,
|
|
34
|
+
].filter(Boolean).join(' '), title: `MDX feature not enabled: ${feature} (${component})`, children: [jsx("span", { className: "font-medium", children: component }), displayProps.map(([key, value]) => (jsxs("span", { className: "font-mono text-xs opacity-80", children: [key, "=", value] }, key))), hasChildren(children) && (jsx("span", { className: "font-mono text-xs opacity-80", children: children }))] }));
|
|
35
|
+
}
|
|
36
|
+
function createMissingMdxFeatureComponents() {
|
|
37
|
+
return {
|
|
38
|
+
MathBlock: (props) => (jsx(MissingMdxFeatureBlock, Object.assign({}, props, { feature: "math", component: "MathBlock" }))),
|
|
39
|
+
InlineMath: (props) => (jsx(MissingMdxFeatureInline, Object.assign({}, props, { feature: "math", component: "InlineMath" }))),
|
|
40
|
+
Mermaid: (props) => (jsx(MissingMdxFeatureBlock, Object.assign({}, props, { feature: "diagram renderer", component: "Mermaid" }))),
|
|
41
|
+
TypeTable: (props) => (jsx(MissingMdxFeatureBlock, Object.assign({}, props, { feature: "API table renderer", component: "TypeTable" }))),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { MissingMdxFeatureBlock, MissingMdxFeatureInline, createMissingMdxFeatureComponents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCodeMdxComponents } from '../features/code';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCodeMdxComponents } from '../features/code.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMathMdxComponents } from '../features/math';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMathMdxComponents } from '../features/math.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMermaidMdxComponents } from '../features/mermaid';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMermaidMdxComponents } from '../features/mermaid.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTypeTableMdxComponents } from '../features/type-table';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTypeTableMdxComponents } from '../features/type-table.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MDXComponents } from 'mdx/types';
|
|
2
2
|
import { SiteX } from '../site-x';
|
|
3
3
|
import type { SiteMdxComponentsOptions } from './site-mdx-components';
|
|
4
|
-
|
|
4
|
+
export type SiteMdxFeature = 'base' | 'code' | 'math' | 'mermaid' | 'type-table';
|
|
5
5
|
export declare const DEFAULT_SITE_MDX_FEATURES: SiteMdxFeature[];
|
|
6
6
|
export declare function createSiteFeatureComponentMap(options: SiteMdxComponentsOptions): {
|
|
7
7
|
base: {
|
|
@@ -192,3 +192,4 @@ export declare function createSiteFeatureComponentMap(options: SiteMdxComponents
|
|
|
192
192
|
'type-table': MDXComponents;
|
|
193
193
|
};
|
|
194
194
|
export declare function composeSiteMdxComponents(features: readonly SiteMdxFeature[], featureMap: Record<SiteMdxFeature, MDXComponents>, additionalComponents?: MDXComponents, components?: MDXComponents): MDXComponents;
|
|
195
|
+
export declare function createComposedSiteMdxComponents(features: readonly SiteMdxFeature[], options: SiteMdxComponentsOptions, additionalComponents?: MDXComponents, components?: MDXComponents): MDXComponents;
|
|
@@ -5,7 +5,12 @@ var tabs = require('fumadocs-ui/components/tabs');
|
|
|
5
5
|
var callout = require('fumadocs-ui/components/callout');
|
|
6
6
|
var files = require('fumadocs-ui/components/files');
|
|
7
7
|
var accordion = require('fumadocs-ui/components/accordion');
|
|
8
|
-
var
|
|
8
|
+
var base = require('./features/base.js');
|
|
9
|
+
var code = require('./features/code.js');
|
|
10
|
+
var math = require('./features/math.js');
|
|
11
|
+
var mermaid = require('./features/mermaid.js');
|
|
12
|
+
var typeTable = require('./features/type-table.js');
|
|
13
|
+
var widgets = require('./features/widgets.js');
|
|
9
14
|
var siteX = require('../site-x.js');
|
|
10
15
|
|
|
11
16
|
const defaultFumaUiComponents = {
|
|
@@ -25,22 +30,26 @@ const DEFAULT_SITE_MDX_FEATURES = [
|
|
|
25
30
|
'mermaid',
|
|
26
31
|
'type-table',
|
|
27
32
|
];
|
|
28
|
-
function
|
|
33
|
+
function createSiteFeatureComponents(feature, options) {
|
|
29
34
|
const { cdnBaseUrl, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
|
|
30
|
-
|
|
31
|
-
base:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
|
|
35
|
+
switch (feature) {
|
|
36
|
+
case 'base':
|
|
37
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultFumaUiComponents), { SiteX: siteX.SiteX }), base.createBaseMdxComponents(imageFallbackSrc)), widgets.createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc));
|
|
38
|
+
case 'code':
|
|
39
|
+
return code.createCodeMdxComponents(iconMap);
|
|
40
|
+
case 'math':
|
|
41
|
+
return math.createMathMdxComponents();
|
|
42
|
+
case 'mermaid':
|
|
43
|
+
return mermaid.createMermaidMdxComponents(watermarkEnabled, watermarkText);
|
|
44
|
+
case 'type-table':
|
|
45
|
+
return typeTable.createTypeTableMdxComponents();
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
|
-
function
|
|
48
|
+
function createComposedSiteMdxComponents(features, options, additionalComponents, components) {
|
|
39
49
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultMdxComponents), features.reduce((acc, feature) => {
|
|
40
|
-
return Object.assign(Object.assign({}, acc),
|
|
50
|
+
return Object.assign(Object.assign({}, acc), createSiteFeatureComponents(feature, options));
|
|
41
51
|
}, {})), additionalComponents), components);
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
exports.DEFAULT_SITE_MDX_FEATURES = DEFAULT_SITE_MDX_FEATURES;
|
|
45
|
-
exports.
|
|
46
|
-
exports.createSiteFeatureComponentMap = createSiteFeatureComponentMap;
|
|
55
|
+
exports.createComposedSiteMdxComponents = createComposedSiteMdxComponents;
|
|
@@ -3,7 +3,12 @@ import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
|
|
|
3
3
|
import { Callout } from 'fumadocs-ui/components/callout';
|
|
4
4
|
import { Files, Folder, File } from 'fumadocs-ui/components/files';
|
|
5
5
|
import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
6
|
-
import {
|
|
6
|
+
import { createBaseMdxComponents } from './features/base.mjs';
|
|
7
|
+
import { createCodeMdxComponents } from './features/code.mjs';
|
|
8
|
+
import { createMathMdxComponents } from './features/math.mjs';
|
|
9
|
+
import { createMermaidMdxComponents } from './features/mermaid.mjs';
|
|
10
|
+
import { createTypeTableMdxComponents } from './features/type-table.mjs';
|
|
11
|
+
import { createWidgetMdxComponents } from './features/widgets.mjs';
|
|
7
12
|
import { SiteX } from '../site-x.mjs';
|
|
8
13
|
|
|
9
14
|
const defaultFumaUiComponents = {
|
|
@@ -23,20 +28,25 @@ const DEFAULT_SITE_MDX_FEATURES = [
|
|
|
23
28
|
'mermaid',
|
|
24
29
|
'type-table',
|
|
25
30
|
];
|
|
26
|
-
function
|
|
31
|
+
function createSiteFeatureComponents(feature, options) {
|
|
27
32
|
const { cdnBaseUrl, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
|
|
28
|
-
|
|
29
|
-
base:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'
|
|
34
|
-
|
|
33
|
+
switch (feature) {
|
|
34
|
+
case 'base':
|
|
35
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultFumaUiComponents), { SiteX }), createBaseMdxComponents(imageFallbackSrc)), createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc));
|
|
36
|
+
case 'code':
|
|
37
|
+
return createCodeMdxComponents(iconMap);
|
|
38
|
+
case 'math':
|
|
39
|
+
return createMathMdxComponents();
|
|
40
|
+
case 'mermaid':
|
|
41
|
+
return createMermaidMdxComponents(watermarkEnabled, watermarkText);
|
|
42
|
+
case 'type-table':
|
|
43
|
+
return createTypeTableMdxComponents();
|
|
44
|
+
}
|
|
35
45
|
}
|
|
36
|
-
function
|
|
46
|
+
function createComposedSiteMdxComponents(features, options, additionalComponents, components) {
|
|
37
47
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultMdxComponents), features.reduce((acc, feature) => {
|
|
38
|
-
return Object.assign(Object.assign({}, acc),
|
|
48
|
+
return Object.assign(Object.assign({}, acc), createSiteFeatureComponents(feature, options));
|
|
39
49
|
}, {})), additionalComponents), components);
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
export { DEFAULT_SITE_MDX_FEATURES,
|
|
52
|
+
export { DEFAULT_SITE_MDX_FEATURES, createComposedSiteMdxComponents };
|
|
@@ -3,77 +3,91 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var utils = require('@windrun-huaiin/lib/utils');
|
|
6
|
-
var
|
|
7
|
-
var imageZoom = require('../heavy/image-zoom.js');
|
|
8
|
-
require('katex');
|
|
9
|
-
require('@windrun-huaiin/base-ui/icons');
|
|
10
|
-
require('next-themes');
|
|
11
|
-
require('roughjs');
|
|
12
|
-
require('react');
|
|
13
|
-
require('@windrun-huaiin/base-ui/lib');
|
|
6
|
+
var React = require('react');
|
|
14
7
|
|
|
8
|
+
const ImageZoom = React.lazy(() => Promise.resolve().then(function () { return require('../heavy/image-zoom.js'); }).then((mod) => ({ default: mod.ImageZoom })));
|
|
15
9
|
function normalizeMarkdownProps(props) {
|
|
16
10
|
const { class: legacyClassName, className } = props, restProps = tslib.__rest(props, ["class", "className"]);
|
|
17
11
|
return Object.assign(Object.assign({}, restProps), { className: utils.cn(typeof legacyClassName === 'string' ? legacyClassName : undefined, className) });
|
|
18
12
|
}
|
|
19
|
-
const baseMarkdownComponents =
|
|
13
|
+
const baseMarkdownComponents = {
|
|
14
|
+
a: (_a) => {
|
|
20
15
|
var _b, _c;
|
|
21
16
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
22
17
|
return (jsxRuntime.jsx("a", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('underline underline-offset-4 transition hover:opacity-80', normalizeMarkdownProps(props).className, className), target: (_b = props.target) !== null && _b !== void 0 ? _b : '_blank', rel: (_c = props.rel) !== null && _c !== void 0 ? _c : 'noreferrer noopener' })));
|
|
23
|
-
},
|
|
18
|
+
},
|
|
19
|
+
blockquote: (_a) => {
|
|
24
20
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
25
21
|
return (jsxRuntime.jsx("blockquote", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border-l-2 border-border pl-4 text-muted-foreground', normalizeMarkdownProps(props).className, className) })));
|
|
26
|
-
},
|
|
22
|
+
},
|
|
23
|
+
code: (_a) => {
|
|
27
24
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
28
25
|
return (jsxRuntime.jsx("code", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.9em]', normalizeMarkdownProps(props).className, className) })));
|
|
29
|
-
},
|
|
26
|
+
},
|
|
27
|
+
h1: (_a) => {
|
|
30
28
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
31
29
|
return (jsxRuntime.jsx("h1", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-2xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
32
|
-
},
|
|
30
|
+
},
|
|
31
|
+
h2: (_a) => {
|
|
33
32
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
34
33
|
return (jsxRuntime.jsx("h2", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
35
|
-
},
|
|
34
|
+
},
|
|
35
|
+
h3: (_a) => {
|
|
36
36
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
37
37
|
return (jsxRuntime.jsx("h3", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-lg font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
38
|
-
},
|
|
38
|
+
},
|
|
39
|
+
h4: (_a) => {
|
|
39
40
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
40
41
|
return (jsxRuntime.jsx("h4", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-base font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
41
|
-
},
|
|
42
|
+
},
|
|
43
|
+
h5: (_a) => {
|
|
42
44
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
43
45
|
return (jsxRuntime.jsx("h5", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
44
|
-
},
|
|
46
|
+
},
|
|
47
|
+
h6: (_a) => {
|
|
45
48
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
46
49
|
return (jsxRuntime.jsx("h6", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
47
|
-
},
|
|
50
|
+
},
|
|
51
|
+
hr: (_a) => {
|
|
48
52
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
49
53
|
return (jsxRuntime.jsx("hr", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border-border', normalizeMarkdownProps(props).className, className) })));
|
|
50
|
-
},
|
|
54
|
+
},
|
|
55
|
+
img: (_a) => {
|
|
51
56
|
var { className, alt, src } = _a, props = tslib.__rest(_a, ["className", "alt", "src"]);
|
|
52
|
-
return (jsxRuntime.jsx(
|
|
53
|
-
},
|
|
57
|
+
return (jsxRuntime.jsx(ImageZoom, Object.assign({}, normalizeMarkdownProps(props), { alt: typeof alt === 'string' ? alt : '', src: typeof src === 'string' ? src : '', className: utils.cn('overflow-hidden rounded-2xl', normalizeMarkdownProps(props).className, className) })));
|
|
58
|
+
},
|
|
59
|
+
li: (_a) => {
|
|
54
60
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
55
61
|
return (jsxRuntime.jsx("li", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
56
|
-
},
|
|
62
|
+
},
|
|
63
|
+
ol: (_a) => {
|
|
57
64
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
58
65
|
return (jsxRuntime.jsx("ol", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('list-decimal space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
59
|
-
},
|
|
66
|
+
},
|
|
67
|
+
p: (_a) => {
|
|
60
68
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
61
69
|
return (jsxRuntime.jsx("p", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
62
|
-
},
|
|
70
|
+
},
|
|
71
|
+
pre: (_a) => {
|
|
63
72
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
64
73
|
return (jsxRuntime.jsx("pre", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('overflow-x-auto rounded-2xl border border-border bg-muted px-4 py-3 text-sm', normalizeMarkdownProps(props).className, className) })));
|
|
65
|
-
},
|
|
74
|
+
},
|
|
75
|
+
table: (_a) => {
|
|
66
76
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
67
77
|
return (jsxRuntime.jsx("div", { className: "overflow-x-auto", children: jsxRuntime.jsx("table", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('w-full border-collapse text-sm', normalizeMarkdownProps(props).className, className) })) }));
|
|
68
|
-
},
|
|
78
|
+
},
|
|
79
|
+
td: (_a) => {
|
|
69
80
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
70
81
|
return (jsxRuntime.jsx("td", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border border-border px-3 py-2 align-top', normalizeMarkdownProps(props).className, className) })));
|
|
71
|
-
},
|
|
82
|
+
},
|
|
83
|
+
th: (_a) => {
|
|
72
84
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
73
85
|
return (jsxRuntime.jsx("th", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border border-border px-3 py-2 text-left font-medium', normalizeMarkdownProps(props).className, className) })));
|
|
74
|
-
},
|
|
86
|
+
},
|
|
87
|
+
ul: (_a) => {
|
|
75
88
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
76
89
|
return (jsxRuntime.jsx("ul", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('list-disc space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
77
|
-
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
78
92
|
|
|
79
93
|
exports.baseMarkdownComponents = baseMarkdownComponents;
|
|
@@ -1,77 +1,91 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { cn } from '@windrun-huaiin/lib/utils';
|
|
4
|
-
import
|
|
5
|
-
import { ImageZoom } from '../heavy/image-zoom.mjs';
|
|
6
|
-
import 'katex';
|
|
7
|
-
import '@windrun-huaiin/base-ui/icons';
|
|
8
|
-
import 'next-themes';
|
|
9
|
-
import 'roughjs';
|
|
10
|
-
import 'react';
|
|
11
|
-
import '@windrun-huaiin/base-ui/lib';
|
|
4
|
+
import { lazy } from 'react';
|
|
12
5
|
|
|
6
|
+
const ImageZoom = lazy(() => import('../heavy/image-zoom.mjs').then((mod) => ({ default: mod.ImageZoom })));
|
|
13
7
|
function normalizeMarkdownProps(props) {
|
|
14
8
|
const { class: legacyClassName, className } = props, restProps = __rest(props, ["class", "className"]);
|
|
15
9
|
return Object.assign(Object.assign({}, restProps), { className: cn(typeof legacyClassName === 'string' ? legacyClassName : undefined, className) });
|
|
16
10
|
}
|
|
17
|
-
const baseMarkdownComponents =
|
|
11
|
+
const baseMarkdownComponents = {
|
|
12
|
+
a: (_a) => {
|
|
18
13
|
var _b, _c;
|
|
19
14
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
20
15
|
return (jsx("a", Object.assign({}, normalizeMarkdownProps(props), { className: cn('underline underline-offset-4 transition hover:opacity-80', normalizeMarkdownProps(props).className, className), target: (_b = props.target) !== null && _b !== void 0 ? _b : '_blank', rel: (_c = props.rel) !== null && _c !== void 0 ? _c : 'noreferrer noopener' })));
|
|
21
|
-
},
|
|
16
|
+
},
|
|
17
|
+
blockquote: (_a) => {
|
|
22
18
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
23
19
|
return (jsx("blockquote", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border-l-2 border-border pl-4 text-muted-foreground', normalizeMarkdownProps(props).className, className) })));
|
|
24
|
-
},
|
|
20
|
+
},
|
|
21
|
+
code: (_a) => {
|
|
25
22
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
26
23
|
return (jsx("code", Object.assign({}, normalizeMarkdownProps(props), { className: cn('rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.9em]', normalizeMarkdownProps(props).className, className) })));
|
|
27
|
-
},
|
|
24
|
+
},
|
|
25
|
+
h1: (_a) => {
|
|
28
26
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
29
27
|
return (jsx("h1", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-2xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
30
|
-
},
|
|
28
|
+
},
|
|
29
|
+
h2: (_a) => {
|
|
31
30
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
32
31
|
return (jsx("h2", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
33
|
-
},
|
|
32
|
+
},
|
|
33
|
+
h3: (_a) => {
|
|
34
34
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
35
35
|
return (jsx("h3", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-lg font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
36
|
-
},
|
|
36
|
+
},
|
|
37
|
+
h4: (_a) => {
|
|
37
38
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
38
39
|
return (jsx("h4", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-base font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
39
|
-
},
|
|
40
|
+
},
|
|
41
|
+
h5: (_a) => {
|
|
40
42
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
41
43
|
return (jsx("h5", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
42
|
-
},
|
|
44
|
+
},
|
|
45
|
+
h6: (_a) => {
|
|
43
46
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
44
47
|
return (jsx("h6", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
45
|
-
},
|
|
48
|
+
},
|
|
49
|
+
hr: (_a) => {
|
|
46
50
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
47
51
|
return (jsx("hr", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border-border', normalizeMarkdownProps(props).className, className) })));
|
|
48
|
-
},
|
|
52
|
+
},
|
|
53
|
+
img: (_a) => {
|
|
49
54
|
var { className, alt, src } = _a, props = __rest(_a, ["className", "alt", "src"]);
|
|
50
55
|
return (jsx(ImageZoom, Object.assign({}, normalizeMarkdownProps(props), { alt: typeof alt === 'string' ? alt : '', src: typeof src === 'string' ? src : '', className: cn('overflow-hidden rounded-2xl', normalizeMarkdownProps(props).className, className) })));
|
|
51
|
-
},
|
|
56
|
+
},
|
|
57
|
+
li: (_a) => {
|
|
52
58
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
53
59
|
return (jsx("li", Object.assign({}, normalizeMarkdownProps(props), { className: cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
54
|
-
},
|
|
60
|
+
},
|
|
61
|
+
ol: (_a) => {
|
|
55
62
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
56
63
|
return (jsx("ol", Object.assign({}, normalizeMarkdownProps(props), { className: cn('list-decimal space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
57
|
-
},
|
|
64
|
+
},
|
|
65
|
+
p: (_a) => {
|
|
58
66
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
59
67
|
return (jsx("p", Object.assign({}, normalizeMarkdownProps(props), { className: cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
60
|
-
},
|
|
68
|
+
},
|
|
69
|
+
pre: (_a) => {
|
|
61
70
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
62
71
|
return (jsx("pre", Object.assign({}, normalizeMarkdownProps(props), { className: cn('overflow-x-auto rounded-2xl border border-border bg-muted px-4 py-3 text-sm', normalizeMarkdownProps(props).className, className) })));
|
|
63
|
-
},
|
|
72
|
+
},
|
|
73
|
+
table: (_a) => {
|
|
64
74
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
65
75
|
return (jsx("div", { className: "overflow-x-auto", children: jsx("table", Object.assign({}, normalizeMarkdownProps(props), { className: cn('w-full border-collapse text-sm', normalizeMarkdownProps(props).className, className) })) }));
|
|
66
|
-
},
|
|
76
|
+
},
|
|
77
|
+
td: (_a) => {
|
|
67
78
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
68
79
|
return (jsx("td", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border border-border px-3 py-2 align-top', normalizeMarkdownProps(props).className, className) })));
|
|
69
|
-
},
|
|
80
|
+
},
|
|
81
|
+
th: (_a) => {
|
|
70
82
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
71
83
|
return (jsx("th", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border border-border px-3 py-2 text-left font-medium', normalizeMarkdownProps(props).className, className) })));
|
|
72
|
-
},
|
|
84
|
+
},
|
|
85
|
+
ul: (_a) => {
|
|
73
86
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
74
87
|
return (jsx("ul", Object.assign({}, normalizeMarkdownProps(props), { className: cn('list-disc space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
75
|
-
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
76
90
|
|
|
77
91
|
export { baseMarkdownComponents };
|