@docfuse/markdown 0.1.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.
Files changed (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/README.zh-CN.md +50 -0
  4. package/dist/Markdown-D33gcJbF.js +2116 -0
  5. package/dist/base.css +2 -0
  6. package/dist/client/chunks/client-DIoaSmq2.js +334 -0
  7. package/dist/client/chunks/gallery-BPqV7HsS.js +40 -0
  8. package/dist/client/chunks/image-BGExZy1g.js +36 -0
  9. package/dist/client/chunks/provider-DL6V8F7z.js +841 -0
  10. package/dist/client/chunks/react-runtime-ByABE9MG.js +10571 -0
  11. package/dist/client/chunks/serialized-BvfsNeRQ.js +3464 -0
  12. package/dist/client/chunks/table-DBiKAEbC.js +30 -0
  13. package/dist/client/index.js +4 -0
  14. package/dist/client/nativeBehaviors.d.ts +4 -0
  15. package/dist/client.d.ts +15 -0
  16. package/dist/compiler/analyze.d.ts +27 -0
  17. package/dist/compiler/assets.d.ts +29 -0
  18. package/dist/compiler/ast.d.ts +68 -0
  19. package/dist/compiler/createPipeline.d.ts +18 -0
  20. package/dist/compiler/defaultLabels.d.ts +28 -0
  21. package/dist/compiler/directiveValidation.d.ts +17 -0
  22. package/dist/compiler/highlighter.d.ts +3 -0
  23. package/dist/compiler/mdxModules.d.ts +19 -0
  24. package/dist/compiler/mdxPlugins.d.ts +16 -0
  25. package/dist/compiler/normalizeOptions.d.ts +16 -0
  26. package/dist/compiler/pluginPlan.d.ts +18 -0
  27. package/dist/compiler/plugins/code.d.ts +16 -0
  28. package/dist/compiler/plugins/directives.d.ts +24 -0
  29. package/dist/compiler/plugins/documentBlocks.d.ts +5 -0
  30. package/dist/compiler/plugins/tables.d.ts +5 -0
  31. package/dist/compiler/plugins.d.ts +24 -0
  32. package/dist/compiler/prepareMarkdown.d.ts +11 -0
  33. package/dist/compiler/sanitizeBoundary.d.ts +18 -0
  34. package/dist/compiler/stableJson.d.ts +2 -0
  35. package/dist/compiler/syntaxFeatures.d.ts +10 -0
  36. package/dist/compiler/types.d.ts +177 -0
  37. package/dist/components/blocks/MarkdownCodeBlock.d.ts +10 -0
  38. package/dist/components/blocks/MarkdownCopySnippet.d.ts +10 -0
  39. package/dist/components/blocks/MarkdownHeading.d.ts +13 -0
  40. package/dist/components/blocks/MarkdownImage.d.ts +16 -0
  41. package/dist/components/blocks/MarkdownTable.d.ts +12 -0
  42. package/dist/components/blocks/MarkdownTerminal.d.ts +9 -0
  43. package/dist/components/composite/MarkdownComposite.d.ts +37 -0
  44. package/dist/components/composite/MarkdownFileTree.d.ts +5 -0
  45. package/dist/components/composite/MarkdownTabs.d.ts +6 -0
  46. package/dist/components/gallery/ImageGallery.d.ts +25 -0
  47. package/dist/components/shared/MarkdownActions.d.ts +18 -0
  48. package/dist/components/shared/MarkdownDialog.d.ts +11 -0
  49. package/dist/components/shared/MarkdownFileIcon.d.ts +4 -0
  50. package/dist/components/shared/MarkdownIcon.d.ts +8 -0
  51. package/dist/components/shared/interactionConstants.d.ts +1 -0
  52. package/dist/components/shared/reactText.d.ts +14 -0
  53. package/dist/directiveValidation-BdIao7Yn.js +741 -0
  54. package/dist/file-icons/LICENSE +21 -0
  55. package/dist/file-icons/astro.svg +1 -0
  56. package/dist/file-icons/bun.svg +1 -0
  57. package/dist/file-icons/bun_light.svg +1 -0
  58. package/dist/file-icons/config.svg +1 -0
  59. package/dist/file-icons/console.svg +1 -0
  60. package/dist/file-icons/css.svg +1 -0
  61. package/dist/file-icons/database.svg +1 -0
  62. package/dist/file-icons/deno.svg +1 -0
  63. package/dist/file-icons/deno_light.svg +1 -0
  64. package/dist/file-icons/diff.svg +1 -0
  65. package/dist/file-icons/docker.svg +1 -0
  66. package/dist/file-icons/document.svg +1 -0
  67. package/dist/file-icons/download.svg +1 -0
  68. package/dist/file-icons/environment.svg +1 -0
  69. package/dist/file-icons/excel.svg +1 -0
  70. package/dist/file-icons/git.svg +1 -0
  71. package/dist/file-icons/github-actions.svg +1 -0
  72. package/dist/file-icons/go.svg +1 -0
  73. package/dist/file-icons/javascript.svg +1 -0
  74. package/dist/file-icons/json.svg +1 -0
  75. package/dist/file-icons/markdown.svg +1 -0
  76. package/dist/file-icons/nodejs.svg +1 -0
  77. package/dist/file-icons/npm.svg +1 -0
  78. package/dist/file-icons/pdf.svg +1 -0
  79. package/dist/file-icons/pnpm.svg +1 -0
  80. package/dist/file-icons/pnpm_light.svg +1 -0
  81. package/dist/file-icons/powerpoint.svg +1 -0
  82. package/dist/file-icons/python.svg +1 -0
  83. package/dist/file-icons/react.svg +1 -0
  84. package/dist/file-icons/rust.svg +1 -0
  85. package/dist/file-icons/sass.svg +1 -0
  86. package/dist/file-icons/settings.svg +1 -0
  87. package/dist/file-icons/svelte.svg +1 -0
  88. package/dist/file-icons/typescript.svg +1 -0
  89. package/dist/file-icons/vue.svg +1 -0
  90. package/dist/file-icons/word.svg +1 -0
  91. package/dist/file-icons/yaml.svg +1 -0
  92. package/dist/file-icons/yarn.svg +1 -0
  93. package/dist/index.d.ts +7 -0
  94. package/dist/index.js +6 -0
  95. package/dist/islands/gallery.d.ts +2 -0
  96. package/dist/islands/image.d.ts +2 -0
  97. package/dist/islands/options.d.ts +8 -0
  98. package/dist/islands/provider.d.ts +4 -0
  99. package/dist/islands/serialized.d.ts +4 -0
  100. package/dist/islands/table.d.ts +2 -0
  101. package/dist/islands.d.ts +13 -0
  102. package/dist/plugins-DQ-VUuCT.js +288 -0
  103. package/dist/prepareMarkdown-CHqN2JF5.js +852 -0
  104. package/dist/protocol/serializedNode.d.ts +3 -0
  105. package/dist/react/Markdown.d.ts +54 -0
  106. package/dist/react/componentMap.d.ts +172 -0
  107. package/dist/react/semanticOverrideProps.d.ts +4 -0
  108. package/dist/react/slots.d.ts +39 -0
  109. package/dist/react/urlTransform.d.ts +12 -0
  110. package/dist/server/analyze.d.ts +6 -0
  111. package/dist/server/analyze.js +132 -0
  112. package/dist/server/cache.d.ts +16 -0
  113. package/dist/server/createMarkdownRenderer.d.ts +39 -0
  114. package/dist/server.d.ts +5 -0
  115. package/dist/server.js +137 -0
  116. package/dist/shared/copyText.d.ts +2 -0
  117. package/dist/shared/fileKinds.d.ts +6 -0
  118. package/dist/theme.css +183 -0
  119. package/dist/theme.d.ts +167 -0
  120. package/dist/theme.js +228 -0
  121. package/package.json +110 -0
package/dist/theme.css ADDED
@@ -0,0 +1,183 @@
1
+ /*
2
+ * Docfuse's shared visual contract.
3
+ *
4
+ * The palette is intentionally semantic: Markdown and the site shell consume
5
+ * the same variables, while a host can override the documented values from
6
+ * `@docfuse/markdown/theme`. Content surfaces stay opaque; translucent
7
+ * material is reserved for temporary controls and overlays.
8
+ */
9
+ :root {
10
+ color-scheme: light;
11
+
12
+ --df-canvas: #f6f6f8;
13
+ --df-ink: #1d1d1f;
14
+ --df-ink-body: #363638;
15
+ --df-ink-secondary: #66666b;
16
+ --df-ink-tertiary: #737379;
17
+ --df-surface: #ffffff;
18
+ --df-surface-secondary: #f3f3f5;
19
+ --df-surface-soft: #f7f7f9;
20
+ --df-surface-elevated: #ffffff;
21
+ --df-surface-code: #f6f6f8;
22
+ --df-code-ink: #1d1d1f;
23
+ --df-docfuse-config-icon: url('./file-icons/config.svg');
24
+
25
+ /* The contract keeps these names for theme overrides. Visual rules never
26
+ draw a border; they use surfaces, inset highlights, and shadows instead. */
27
+ --df-border: transparent;
28
+ --df-border-strong: transparent;
29
+ --df-hairline: rgb(29 29 31 / 0.1);
30
+
31
+ /* Default semantic palette. Components derive interaction and status tones
32
+ from this contract instead of introducing local color constants. */
33
+ --df-accent-500: #0088ff;
34
+ --df-accent-50: color-mix(in srgb, var(--df-accent-500) 6%, white);
35
+ --df-accent-100: color-mix(in srgb, var(--df-accent-500) 10%, white);
36
+ --df-accent-200: color-mix(in srgb, var(--df-accent-500) 20%, white);
37
+ --df-accent-300: color-mix(in srgb, var(--df-accent-500) 38%, white);
38
+ --df-accent-400: color-mix(in srgb, var(--df-accent-500) 68%, white);
39
+ --df-accent-600: color-mix(in srgb, var(--df-accent-500) 88%, black);
40
+ --df-accent-700: color-mix(in srgb, var(--df-accent-500) 78%, black);
41
+ --df-accent-800: color-mix(in srgb, var(--df-accent-500) 66%, black);
42
+ --df-accent-900: color-mix(in srgb, var(--df-accent-500) 52%, black);
43
+ --df-accent-soft: color-mix(in srgb, var(--df-accent-500) 10%, white);
44
+ --df-accent-strong: #0088ff;
45
+ --df-accent-deep: color-mix(in srgb, var(--df-accent-500) 78%, black);
46
+
47
+ /* Official diagram plugins consume this shared theme contract. */
48
+ --df-diagram-surface: var(--df-surface-soft);
49
+ --df-diagram-foreground: var(--df-ink-body);
50
+ --df-diagram-accent: var(--df-accent-500);
51
+ --df-diagram-muted: var(--df-ink-secondary);
52
+ --df-diagram-line: color-mix(in srgb, var(--df-ink-body) 12%, transparent);
53
+ --df-accent-secondary: #6155f5;
54
+ --df-info: #0088ff;
55
+ --df-info-deep: #0088ff;
56
+ --df-success: #34c759;
57
+ --df-success-deep: #34c759;
58
+ --df-warning: #ff8d28;
59
+ --df-warning-deep: #ff8d28;
60
+ --df-danger: #ff383c;
61
+ --df-danger-deep: #ff383c;
62
+ --df-info-soft: color-mix(in oklab, var(--df-info) 9%, var(--df-surface));
63
+ --df-success-soft: color-mix(in oklab, var(--df-success) 9%, var(--df-surface));
64
+ --df-warning-soft: color-mix(in oklab, var(--df-warning) 9%, var(--df-surface));
65
+ --df-danger-soft: color-mix(in oklab, var(--df-danger) 9%, var(--df-surface));
66
+ --df-yellow: #ffcc00;
67
+
68
+ --df-overlay: rgb(0 0 0 / 0.42);
69
+ --df-overlay-scrim: rgb(13 13 15 / 0.9);
70
+ --df-overlay-control: rgb(255 255 255 / 0.14);
71
+ --df-overlay-ink: rgb(255 255 255 / 0.78);
72
+ --df-overlay-ink-muted: rgb(255 255 255 / 0.56);
73
+ --df-shadow-raised: 0 20px 52px rgb(29 29 31 / 0.14);
74
+ --df-shadow-raised-sm: 0 8px 22px rgb(29 29 31 / 0.09);
75
+ --df-shadow-inset: inset 0 1px 0 rgb(255 255 255 / 0.7);
76
+ --df-block-shell-shadow: 0 1px 2px rgb(29 29 31 / 0.08), 0 6px 18px rgb(29 29 31 / 0.06);
77
+
78
+ /* Terminal is always a dark surface. Traffic-light dots are macOS chrome,
79
+ not semantic status colors — do not reuse them for callouts or badges. */
80
+ --df-terminal-canvas: #1c1c1e;
81
+ --df-terminal-toolbar: #2b2b2f;
82
+ --df-terminal-ink: #f5f5f7;
83
+ --df-terminal-ink-secondary: #b9b9c0;
84
+ --df-terminal-ink-tertiary: #98989f;
85
+ --df-terminal-traffic-close: #ff5f57;
86
+ --df-terminal-traffic-minimize: #febc2e;
87
+ --df-terminal-traffic-maximize: #28c840;
88
+
89
+ --df-font-display:
90
+ -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Segoe UI',
91
+ 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
92
+ --df-font-sans:
93
+ -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', 'PingFang SC',
94
+ 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
95
+ --df-font-mono: 'SFMono-Regular', 'JetBrains Mono', Consolas, 'Liberation Mono', Menlo, monospace;
96
+ /* Typography scales with the user's root font size. Line heights stay unitless. */
97
+ --df-body-font-size: 1rem;
98
+ --df-body-line-height: 1.6;
99
+ --df-heading-line-height: 1.2;
100
+ --df-heading-1-size: 2rem;
101
+ --df-heading-2-size: 1.625rem;
102
+ --df-heading-3-size: 1.375rem;
103
+ --df-heading-4-size: 1.25rem;
104
+ --df-heading-5-size: 1.125rem;
105
+ --df-heading-6-size: 1.0625rem;
106
+ --df-reading-width: 100%;
107
+ --df-content-width: 100%;
108
+ --df-site-gutter: 2.25rem;
109
+
110
+ --df-radius-sm: 4px;
111
+ --df-radius-md: 6px;
112
+ --df-radius-lg: 8px;
113
+ --df-radius-full: 8px;
114
+
115
+ --df-duration-fast: 120ms;
116
+ --df-duration-normal: 220ms;
117
+ --df-easing-default: cubic-bezier(0.22, 1, 0.36, 1);
118
+ --df-easing-spring: cubic-bezier(0.2, 0.85, 0.25, 1);
119
+ --df-glass-blur: 18px;
120
+ /* Major layout dimensions use rem; optical geometry below intentionally uses px. */
121
+ --df-header-height: 4.25rem;
122
+ --df-sidebar-width: 17.5rem;
123
+ --df-outline-width: 18.75rem;
124
+ --df-focus-ring: 0 0 0 3px color-mix(in srgb, var(--df-accent-500) 24%, transparent);
125
+ }
126
+
127
+ html.dark,
128
+ .dark {
129
+ color-scheme: dark;
130
+
131
+ --df-canvas: #1c1c1e;
132
+ --df-ink: #f5f5f7;
133
+ --df-ink-body: #e3e3e8;
134
+ --df-ink-secondary: #b9b9c0;
135
+ --df-ink-tertiary: #98989f;
136
+ --df-surface: #232326;
137
+ --df-surface-secondary: #343438;
138
+ --df-surface-soft: #2b2b2f;
139
+ --df-surface-elevated: #3b3b40;
140
+ --df-surface-code: #202023;
141
+ --df-code-ink: #f5f5f7;
142
+ --df-hairline: rgb(255 255 255 / 0.12);
143
+
144
+ --df-accent-500: #0091ff;
145
+ --df-accent-50: color-mix(in srgb, var(--df-accent-500) 8%, var(--df-surface));
146
+ --df-accent-100: color-mix(in srgb, var(--df-accent-500) 14%, var(--df-surface));
147
+ --df-accent-200: color-mix(in srgb, var(--df-accent-500) 25%, var(--df-surface));
148
+ --df-accent-300: color-mix(in srgb, var(--df-accent-500) 42%, var(--df-surface));
149
+ --df-accent-400: color-mix(in srgb, var(--df-accent-500) 70%, var(--df-surface));
150
+ --df-accent-600: color-mix(in srgb, var(--df-accent-500) 88%, white);
151
+ --df-accent-700: color-mix(in srgb, var(--df-accent-500) 76%, white);
152
+ --df-accent-800: color-mix(in srgb, var(--df-accent-500) 62%, white);
153
+ --df-accent-900: color-mix(in srgb, var(--df-accent-500) 46%, white);
154
+ --df-accent-soft: color-mix(in srgb, var(--df-accent-500) 18%, var(--df-surface));
155
+ --df-accent-strong: #0091ff;
156
+ --df-accent-deep: color-mix(in srgb, var(--df-accent-500) 76%, white);
157
+ --df-accent-secondary: #6d7cff;
158
+ --df-info: #0091ff;
159
+ --df-info-deep: #0091ff;
160
+ --df-success: #30d158;
161
+ --df-success-deep: #30d158;
162
+ --df-warning: #ff9230;
163
+ --df-warning-deep: #ff9230;
164
+ --df-danger: #ff4245;
165
+ --df-danger-deep: #ff4245;
166
+ --df-info-soft: color-mix(in oklab, var(--df-info) 9%, var(--df-surface));
167
+ --df-success-soft: color-mix(in oklab, var(--df-success) 9%, var(--df-surface));
168
+ --df-warning-soft: color-mix(in oklab, var(--df-warning) 9%, var(--df-surface));
169
+ --df-danger-soft: color-mix(in oklab, var(--df-danger) 9%, var(--df-surface));
170
+ --df-yellow: #ffd600;
171
+ --df-overlay: rgb(0 0 0 / 0.62);
172
+ --df-shadow-raised: 0 22px 58px rgb(0 0 0 / 0.34);
173
+ --df-shadow-raised-sm: 0 10px 28px rgb(0 0 0 / 0.24);
174
+ --df-shadow-inset: inset 0 1px 0 rgb(255 255 255 / 0.08);
175
+ --df-block-shell-shadow: 0 1px 2px rgb(0 0 0 / 0.28), 0 6px 18px rgb(0 0 0 / 0.18);
176
+ --df-focus-ring: 0 0 0 3px color-mix(in srgb, var(--df-accent-500) 36%, transparent);
177
+ }
178
+
179
+ @media (max-width: 47.5rem) {
180
+ :root {
181
+ --df-site-gutter: 1.25rem;
182
+ }
183
+ }
@@ -0,0 +1,167 @@
1
+ export type MarkdownThemeMode = 'light' | 'dark';
2
+ export interface MarkdownThemeColors {
3
+ canvas: string;
4
+ foreground: string;
5
+ text: string;
6
+ muted: string;
7
+ mutedSubtle: string;
8
+ surface: string;
9
+ surfaceSecondary: string;
10
+ surfaceSoft: string;
11
+ surfaceElevated: string;
12
+ border: string;
13
+ borderStrong: string;
14
+ hairline: string;
15
+ primary: string;
16
+ primarySoft: string;
17
+ primaryForeground: string;
18
+ primaryDeep: string;
19
+ accent: string;
20
+ info: string;
21
+ infoDeep: string;
22
+ success: string;
23
+ successDeep: string;
24
+ warning: string;
25
+ warningDeep: string;
26
+ danger: string;
27
+ dangerDeep: string;
28
+ codeBackground: string;
29
+ codeForeground: string;
30
+ overlay: string;
31
+ shadow: string;
32
+ shadowSmall: string;
33
+ }
34
+ export interface MarkdownThemeTypography {
35
+ displayFont: string;
36
+ sansFont: string;
37
+ monoFont: string;
38
+ bodySize: string;
39
+ bodyLineHeight: string;
40
+ headingLineHeight: string;
41
+ heading1Size: string;
42
+ heading2Size: string;
43
+ heading3Size: string;
44
+ heading4Size: string;
45
+ heading5Size: string;
46
+ heading6Size: string;
47
+ }
48
+ export interface MarkdownThemeLayout {
49
+ readingWidth: string;
50
+ contentWidth: string;
51
+ gutter: string;
52
+ }
53
+ export interface MarkdownThemeGeometry {
54
+ radiusSmall: string;
55
+ radiusMedium: string;
56
+ radiusLarge: string;
57
+ radiusFull: string;
58
+ }
59
+ export interface MarkdownThemeMotion {
60
+ durationFast: string;
61
+ durationNormal: string;
62
+ easing: string;
63
+ }
64
+ export interface ResolvedMarkdownTheme {
65
+ colors: Record<MarkdownThemeMode, MarkdownThemeColors>;
66
+ typography: MarkdownThemeTypography;
67
+ layout: MarkdownThemeLayout;
68
+ geometry: MarkdownThemeGeometry;
69
+ motion: MarkdownThemeMotion;
70
+ }
71
+ export interface MarkdownThemeInput {
72
+ colors?: Partial<Record<MarkdownThemeMode, Partial<MarkdownThemeColors>>>;
73
+ typography?: Partial<MarkdownThemeTypography>;
74
+ layout?: Partial<MarkdownThemeLayout>;
75
+ geometry?: Partial<MarkdownThemeGeometry>;
76
+ motion?: Partial<MarkdownThemeMotion>;
77
+ }
78
+ /** Default semantic color anchors shared by Markdown and the Docfuse shell. */
79
+ export declare const DEFAULT_SEMANTIC_COLORS: {
80
+ readonly light: {
81
+ readonly blue: "#0088ff";
82
+ readonly indigo: "#6155f5";
83
+ readonly cyan: "#00c0e8";
84
+ readonly green: "#34c759";
85
+ readonly orange: "#ff8d28";
86
+ readonly red: "#ff383c";
87
+ readonly yellow: "#ffcc00";
88
+ };
89
+ readonly dark: {
90
+ readonly blue: "#0091ff";
91
+ readonly indigo: "#6d7cff";
92
+ readonly cyan: "#3cd3fe";
93
+ readonly green: "#30d158";
94
+ readonly orange: "#ff9230";
95
+ readonly red: "#ff4245";
96
+ readonly yellow: "#ffd600";
97
+ };
98
+ };
99
+ export declare const DEFAULT_MARKDOWN_THEME: ResolvedMarkdownTheme;
100
+ export declare const MARKDOWN_THEME_VARIABLES: {
101
+ readonly colors: {
102
+ readonly canvas: "--df-canvas";
103
+ readonly foreground: "--df-ink";
104
+ readonly text: "--df-ink-body";
105
+ readonly muted: "--df-ink-secondary";
106
+ readonly mutedSubtle: "--df-ink-tertiary";
107
+ readonly surface: "--df-surface";
108
+ readonly surfaceSecondary: "--df-surface-secondary";
109
+ readonly surfaceSoft: "--df-surface-soft";
110
+ readonly surfaceElevated: "--df-surface-elevated";
111
+ readonly border: "--df-border";
112
+ readonly borderStrong: "--df-border-strong";
113
+ readonly hairline: "--df-hairline";
114
+ readonly primary: "--df-accent-500";
115
+ readonly primarySoft: "--df-accent-soft";
116
+ readonly primaryForeground: "--df-accent-strong";
117
+ readonly primaryDeep: "--df-accent-deep";
118
+ readonly accent: "--df-accent-secondary";
119
+ readonly info: "--df-info";
120
+ readonly infoDeep: "--df-info-deep";
121
+ readonly success: "--df-success";
122
+ readonly successDeep: "--df-success-deep";
123
+ readonly warning: "--df-warning";
124
+ readonly warningDeep: "--df-warning-deep";
125
+ readonly danger: "--df-danger";
126
+ readonly dangerDeep: "--df-danger-deep";
127
+ readonly codeBackground: "--df-surface-code";
128
+ readonly codeForeground: "--df-code-ink";
129
+ readonly overlay: "--df-overlay";
130
+ readonly shadow: "--df-shadow-raised";
131
+ readonly shadowSmall: "--df-shadow-raised-sm";
132
+ };
133
+ readonly typography: {
134
+ readonly displayFont: "--df-font-display";
135
+ readonly sansFont: "--df-font-sans";
136
+ readonly monoFont: "--df-font-mono";
137
+ readonly bodySize: "--df-body-font-size";
138
+ readonly bodyLineHeight: "--df-body-line-height";
139
+ readonly headingLineHeight: "--df-heading-line-height";
140
+ readonly heading1Size: "--df-heading-1-size";
141
+ readonly heading2Size: "--df-heading-2-size";
142
+ readonly heading3Size: "--df-heading-3-size";
143
+ readonly heading4Size: "--df-heading-4-size";
144
+ readonly heading5Size: "--df-heading-5-size";
145
+ readonly heading6Size: "--df-heading-6-size";
146
+ };
147
+ readonly layout: {
148
+ readonly readingWidth: "--df-reading-width";
149
+ readonly contentWidth: "--df-content-width";
150
+ readonly gutter: "--df-site-gutter";
151
+ };
152
+ readonly geometry: {
153
+ readonly radiusSmall: "--df-radius-sm";
154
+ readonly radiusMedium: "--df-radius-md";
155
+ readonly radiusLarge: "--df-radius-lg";
156
+ readonly radiusFull: "--df-radius-full";
157
+ };
158
+ readonly motion: {
159
+ readonly durationFast: "--df-duration-fast";
160
+ readonly durationNormal: "--df-duration-normal";
161
+ readonly easing: "--df-easing-default";
162
+ };
163
+ };
164
+ /** Validate and complete a partial public theme contract. */
165
+ export declare function resolveMarkdownTheme(input?: MarkdownThemeInput): ResolvedMarkdownTheme;
166
+ /** Emit only the documented public variables for one resolved mode. */
167
+ export declare function markdownThemeDeclarations(theme: ResolvedMarkdownTheme, mode: MarkdownThemeMode): string;
package/dist/theme.js ADDED
@@ -0,0 +1,228 @@
1
+ const r = {
2
+ light: {
3
+ blue: "#0088ff",
4
+ indigo: "#6155f5",
5
+ cyan: "#00c0e8",
6
+ green: "#34c759",
7
+ orange: "#ff8d28",
8
+ red: "#ff383c",
9
+ yellow: "#ffcc00"
10
+ },
11
+ dark: {
12
+ blue: "#0091ff",
13
+ indigo: "#6d7cff",
14
+ cyan: "#3cd3fe",
15
+ green: "#30d158",
16
+ orange: "#ff9230",
17
+ red: "#ff4245",
18
+ yellow: "#ffd600"
19
+ }
20
+ }, g = "-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif", c = "-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif", d = {
21
+ colors: {
22
+ light: {
23
+ canvas: "#f6f6f8",
24
+ foreground: "#1d1d1f",
25
+ text: "#363638",
26
+ muted: "#66666b",
27
+ mutedSubtle: "#737379",
28
+ surface: "#ffffff",
29
+ surfaceSecondary: "#f3f3f5",
30
+ surfaceSoft: "#f7f7f9",
31
+ surfaceElevated: "#ffffff",
32
+ border: "transparent",
33
+ borderStrong: "transparent",
34
+ hairline: "rgb(29 29 31 / 0.1)",
35
+ primary: r.light.blue,
36
+ primarySoft: "color-mix(in srgb, var(--df-accent-500) 10%, white)",
37
+ primaryForeground: r.light.blue,
38
+ primaryDeep: "color-mix(in srgb, var(--df-accent-500) 78%, black)",
39
+ accent: r.light.indigo,
40
+ info: r.light.blue,
41
+ infoDeep: r.light.blue,
42
+ success: r.light.green,
43
+ successDeep: r.light.green,
44
+ warning: r.light.orange,
45
+ warningDeep: r.light.orange,
46
+ danger: r.light.red,
47
+ dangerDeep: r.light.red,
48
+ codeBackground: "#f6f6f8",
49
+ codeForeground: "#1d1d1f",
50
+ overlay: "rgb(0 0 0 / 0.42)",
51
+ shadow: "0 20px 52px rgb(29 29 31 / 0.14)",
52
+ shadowSmall: "0 8px 22px rgb(29 29 31 / 0.09)"
53
+ },
54
+ dark: {
55
+ canvas: "#1c1c1e",
56
+ foreground: "#f5f5f7",
57
+ text: "#e3e3e8",
58
+ muted: "#b9b9c0",
59
+ mutedSubtle: "#98989f",
60
+ surface: "#232326",
61
+ surfaceSecondary: "#343438",
62
+ surfaceSoft: "#2b2b2f",
63
+ surfaceElevated: "#3b3b40",
64
+ border: "transparent",
65
+ borderStrong: "transparent",
66
+ hairline: "rgb(255 255 255 / 0.12)",
67
+ primary: r.dark.blue,
68
+ primarySoft: "color-mix(in srgb, var(--df-accent-500) 18%, var(--df-surface))",
69
+ primaryForeground: r.dark.blue,
70
+ primaryDeep: "color-mix(in srgb, var(--df-accent-500) 76%, white)",
71
+ accent: r.dark.indigo,
72
+ info: r.dark.blue,
73
+ infoDeep: r.dark.blue,
74
+ success: r.dark.green,
75
+ successDeep: r.dark.green,
76
+ warning: r.dark.orange,
77
+ warningDeep: r.dark.orange,
78
+ danger: r.dark.red,
79
+ dangerDeep: r.dark.red,
80
+ codeBackground: "#202023",
81
+ codeForeground: "#f5f5f7",
82
+ overlay: "rgb(0 0 0 / 0.62)",
83
+ shadow: "0 22px 58px rgb(0 0 0 / 0.34)",
84
+ shadowSmall: "0 10px 28px rgb(0 0 0 / 0.24)"
85
+ }
86
+ },
87
+ typography: {
88
+ displayFont: g,
89
+ sansFont: c,
90
+ monoFont: "'SFMono-Regular', 'JetBrains Mono', Consolas, 'Liberation Mono', Menlo, monospace",
91
+ bodySize: "1rem",
92
+ bodyLineHeight: "1.6",
93
+ headingLineHeight: "1.2",
94
+ heading1Size: "2rem",
95
+ heading2Size: "1.625rem",
96
+ heading3Size: "1.375rem",
97
+ heading4Size: "1.25rem",
98
+ heading5Size: "1.125rem",
99
+ heading6Size: "1.0625rem"
100
+ },
101
+ layout: {
102
+ readingWidth: "100%",
103
+ contentWidth: "100%",
104
+ gutter: "2.25rem"
105
+ },
106
+ geometry: {
107
+ radiusSmall: "4px",
108
+ radiusMedium: "6px",
109
+ radiusLarge: "8px",
110
+ radiusFull: "8px"
111
+ },
112
+ motion: {
113
+ durationFast: "120ms",
114
+ durationNormal: "220ms",
115
+ easing: "cubic-bezier(0.22, 1, 0.36, 1)"
116
+ }
117
+ }, n = {
118
+ colors: {
119
+ canvas: "--df-canvas",
120
+ foreground: "--df-ink",
121
+ text: "--df-ink-body",
122
+ muted: "--df-ink-secondary",
123
+ mutedSubtle: "--df-ink-tertiary",
124
+ surface: "--df-surface",
125
+ surfaceSecondary: "--df-surface-secondary",
126
+ surfaceSoft: "--df-surface-soft",
127
+ surfaceElevated: "--df-surface-elevated",
128
+ border: "--df-border",
129
+ borderStrong: "--df-border-strong",
130
+ hairline: "--df-hairline",
131
+ primary: "--df-accent-500",
132
+ primarySoft: "--df-accent-soft",
133
+ primaryForeground: "--df-accent-strong",
134
+ primaryDeep: "--df-accent-deep",
135
+ accent: "--df-accent-secondary",
136
+ info: "--df-info",
137
+ infoDeep: "--df-info-deep",
138
+ success: "--df-success",
139
+ successDeep: "--df-success-deep",
140
+ warning: "--df-warning",
141
+ warningDeep: "--df-warning-deep",
142
+ danger: "--df-danger",
143
+ dangerDeep: "--df-danger-deep",
144
+ codeBackground: "--df-surface-code",
145
+ codeForeground: "--df-code-ink",
146
+ overlay: "--df-overlay",
147
+ shadow: "--df-shadow-raised",
148
+ shadowSmall: "--df-shadow-raised-sm"
149
+ },
150
+ typography: {
151
+ displayFont: "--df-font-display",
152
+ sansFont: "--df-font-sans",
153
+ monoFont: "--df-font-mono",
154
+ bodySize: "--df-body-font-size",
155
+ bodyLineHeight: "--df-body-line-height",
156
+ headingLineHeight: "--df-heading-line-height",
157
+ heading1Size: "--df-heading-1-size",
158
+ heading2Size: "--df-heading-2-size",
159
+ heading3Size: "--df-heading-3-size",
160
+ heading4Size: "--df-heading-4-size",
161
+ heading5Size: "--df-heading-5-size",
162
+ heading6Size: "--df-heading-6-size"
163
+ },
164
+ layout: {
165
+ readingWidth: "--df-reading-width",
166
+ contentWidth: "--df-content-width",
167
+ gutter: "--df-site-gutter"
168
+ },
169
+ geometry: {
170
+ radiusSmall: "--df-radius-sm",
171
+ radiusMedium: "--df-radius-md",
172
+ radiusLarge: "--df-radius-lg",
173
+ radiusFull: "--df-radius-full"
174
+ },
175
+ motion: {
176
+ durationFast: "--df-duration-fast",
177
+ durationNormal: "--df-duration-normal",
178
+ easing: "--df-easing-default"
179
+ }
180
+ };
181
+ function f(e, o, a) {
182
+ if (o !== void 0) {
183
+ if (!o || typeof o != "object" || Array.isArray(o))
184
+ throw new TypeError(`Markdown theme ${e} must be an object`);
185
+ for (const [t, s] of Object.entries(o)) {
186
+ if (!a.includes(t)) throw new TypeError(`Unknown Markdown theme token: ${e}.${t}`);
187
+ if (typeof s != "string" || s.trim() === "")
188
+ throw new TypeError(`Markdown theme token ${e}.${t} must be a non-empty CSS value`);
189
+ }
190
+ }
191
+ }
192
+ function l(e = {}) {
193
+ const o = ["typography", "layout", "geometry", "motion"];
194
+ f("colors.light", e.colors?.light, Object.keys(n.colors)), f("colors.dark", e.colors?.dark, Object.keys(n.colors));
195
+ for (const a of o)
196
+ f(a, e[a], Object.keys(n[a]));
197
+ return {
198
+ colors: {
199
+ light: { ...d.colors.light, ...e.colors?.light },
200
+ dark: { ...d.colors.dark, ...e.colors?.dark }
201
+ },
202
+ typography: { ...d.typography, ...e.typography },
203
+ layout: { ...d.layout, ...e.layout },
204
+ geometry: { ...d.geometry, ...e.geometry },
205
+ motion: { ...d.motion, ...e.motion }
206
+ };
207
+ }
208
+ function i(e, o) {
209
+ return Object.keys(e).map((a) => ` ${o[a]}: ${String(e[a])};`).join(`
210
+ `);
211
+ }
212
+ function u(e, o) {
213
+ return [
214
+ i(e.colors[o], n.colors),
215
+ i(e.typography, n.typography),
216
+ i(e.layout, n.layout),
217
+ i(e.geometry, n.geometry),
218
+ i(e.motion, n.motion)
219
+ ].join(`
220
+ `);
221
+ }
222
+ export {
223
+ d as DEFAULT_MARKDOWN_THEME,
224
+ r as DEFAULT_SEMANTIC_COLORS,
225
+ n as MARKDOWN_THEME_VARIABLES,
226
+ u as markdownThemeDeclarations,
227
+ l as resolveMarkdownTheme
228
+ };
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "@docfuse/markdown",
3
+ "version": "0.1.0",
4
+ "description": "An interactive, themeable Markdown renderer for technical documentation.",
5
+ "license": "MIT",
6
+ "author": "Docfuse Contributors",
7
+ "homepage": "https://docfuse.dev/markdown/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jiangxinlei/docfuse.git",
11
+ "directory": "packages/markdown"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jiangxinlei/docfuse/issues"
15
+ },
16
+ "keywords": [
17
+ "markdown",
18
+ "documentation",
19
+ "renderer",
20
+ "interactive",
21
+ "shiki"
22
+ ],
23
+ "type": "module",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./client": {
31
+ "types": "./dist/client.d.ts",
32
+ "import": "./dist/client/index.js",
33
+ "default": "./dist/client/index.js"
34
+ },
35
+ "./server": {
36
+ "types": "./dist/server.d.ts",
37
+ "import": "./dist/server.js"
38
+ },
39
+ "./server/analyze": {
40
+ "types": "./dist/server/analyze.d.ts",
41
+ "import": "./dist/server/analyze.js"
42
+ },
43
+ "./theme": {
44
+ "types": "./dist/theme.d.ts",
45
+ "import": "./dist/theme.js"
46
+ },
47
+ "./base.css": "./dist/base.css",
48
+ "./theme.css": "./dist/theme.css"
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "README.zh-CN.md"
53
+ ],
54
+ "engines": {
55
+ "node": ">=22"
56
+ },
57
+ "peerDependencies": {
58
+ "react": "^18.2.0 || ^19.0.0",
59
+ "react-dom": "^18.2.0 || ^19.0.0"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "provenance": true
64
+ },
65
+ "dependencies": {
66
+ "@mdx-js/mdx": "^3.1.0",
67
+ "@shikijs/langs": "^4.2.0",
68
+ "@shikijs/rehype": "^4.2.0",
69
+ "@shikijs/transformers": "^4.3.0",
70
+ "@shikijs/types": "^4.2.0",
71
+ "github-slugger": "^2.0.0",
72
+ "hast-util-to-jsx-runtime": "^2.3.6",
73
+ "lucide-react": "^1.31.0",
74
+ "rehype-raw": "^7.0.0",
75
+ "rehype-sanitize": "^6.0.0",
76
+ "rehype-slug": "^6.0.0",
77
+ "remark-definition-list": "^2.0.0",
78
+ "remark-directive": "^4.0.0",
79
+ "remark-gfm": "^4.0.1",
80
+ "remark-parse": "^11.0.0",
81
+ "remark-rehype": "^11.1.2",
82
+ "shiki": "^4.2.0",
83
+ "unified": "^11.0.5",
84
+ "unist-util-visit": "^5.1.0"
85
+ },
86
+ "devDependencies": {
87
+ "@tailwindcss/cli": "^4.1.11",
88
+ "@types/estree": "^1.0.9",
89
+ "@types/hast": "^3.0.4",
90
+ "@types/mdast": "^4.0.4",
91
+ "@types/node": "^22.10.0",
92
+ "@types/react": "^19.0.0",
93
+ "@types/react-dom": "^19.0.0",
94
+ "@types/unist": "^3.0.3",
95
+ "mdast-util-directive": "^3.1.0",
96
+ "mdast-util-to-hast": "^13.2.1",
97
+ "react": "^19.0.0",
98
+ "react-dom": "^19.0.0",
99
+ "tailwindcss": "^4.1.11",
100
+ "typescript": "^6.0.3",
101
+ "vite": "^6.4.3",
102
+ "vitest": "^4.1.11"
103
+ },
104
+ "scripts": {
105
+ "build": "vite build && vite build -c vite.client.config.ts && tsc -p tsconfig.build.json && tailwindcss -i ./src/tailwind.css -o ./dist/base.css --minify && node scripts/build-css.mjs",
106
+ "test:browser": "node scripts/test-browser-build.mjs",
107
+ "typecheck": "tsc --noEmit",
108
+ "test": "vitest run --root ../.. packages/markdown"
109
+ }
110
+ }