mr-md 1.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/README.md +24 -0
- package/dist/builder.d.ts +169 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +545 -0
- package/dist/client/app.js +314 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/renderer/blocks.d.ts +15 -0
- package/dist/renderer/blocks.d.ts.map +1 -0
- package/dist/renderer/blocks.js +365 -0
- package/dist/renderer/html.d.ts +8 -0
- package/dist/renderer/html.d.ts.map +1 -0
- package/dist/renderer/html.js +141 -0
- package/dist/renderer/index.d.ts +4 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +381 -0
- package/dist/renderer/markdown.d.ts +13 -0
- package/dist/renderer/markdown.d.ts.map +1 -0
- package/dist/renderer/markdown.js +143 -0
- package/dist/renderer/utils.d.ts +10 -0
- package/dist/renderer/utils.d.ts.map +1 -0
- package/dist/renderer/utils.js +59 -0
- package/dist/styles/theme.css +1258 -0
- package/dist/types.d.ts +207 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/package.json +62 -0
- package/src/builder.ts +708 -0
- package/src/client/app.js +314 -0
- package/src/index.ts +34 -0
- package/src/renderer/blocks.ts +452 -0
- package/src/renderer/html.ts +163 -0
- package/src/renderer/index.ts +401 -0
- package/src/renderer/markdown.ts +193 -0
- package/src/renderer/utils.ts +84 -0
- package/src/styles/theme.css +1258 -0
- package/src/types.ts +288 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// ─── Block Types ─────────────────────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
export type BlockType =
|
|
4
|
+
| "heading"
|
|
5
|
+
| "markdown"
|
|
6
|
+
| "section"
|
|
7
|
+
| "important"
|
|
8
|
+
| "note"
|
|
9
|
+
| "warning"
|
|
10
|
+
| "tip"
|
|
11
|
+
| "simulation"
|
|
12
|
+
| "animation"
|
|
13
|
+
| "media"
|
|
14
|
+
| "youtube"
|
|
15
|
+
| "latex"
|
|
16
|
+
| "columns"
|
|
17
|
+
| "quiz"
|
|
18
|
+
| "divider"
|
|
19
|
+
| "code";
|
|
20
|
+
|
|
21
|
+
export interface BaseBlock {
|
|
22
|
+
type: BlockType;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Markdown content blocks
|
|
26
|
+
export interface HeadingBlock extends BaseBlock {
|
|
27
|
+
type: "heading";
|
|
28
|
+
src: string; // path to .md file or inline markdown
|
|
29
|
+
title?: string; // override title extracted from md
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface MarkdownBlock extends BaseBlock {
|
|
33
|
+
type: "markdown";
|
|
34
|
+
src: string; // path to .md file or inline markdown
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SectionBlock extends BaseBlock {
|
|
38
|
+
type: "section";
|
|
39
|
+
src: string; // path to .md file or inline markdown
|
|
40
|
+
label?: string; // override sidebar label
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CalloutBlock extends BaseBlock {
|
|
44
|
+
type: "important" | "warning" | "tip" | "note";
|
|
45
|
+
src: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface CodeBlock extends BaseBlock {
|
|
49
|
+
type: "code";
|
|
50
|
+
src: string;
|
|
51
|
+
lang?: string;
|
|
52
|
+
label?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type BlockAccent =
|
|
56
|
+
| "neutral"
|
|
57
|
+
| "blue"
|
|
58
|
+
| "teal"
|
|
59
|
+
| "amber"
|
|
60
|
+
| "rose"
|
|
61
|
+
| "violet";
|
|
62
|
+
|
|
63
|
+
export interface CaptionedBlock {
|
|
64
|
+
label?: string;
|
|
65
|
+
caption?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Interactive blocks
|
|
69
|
+
export interface SimulationBlock extends BaseBlock, CaptionedBlock {
|
|
70
|
+
type: "simulation";
|
|
71
|
+
src: string; // path to .js file or inline JS
|
|
72
|
+
props?: Record<string, unknown>; // passed to the sim as window.__simProps
|
|
73
|
+
tunables?: Record<string, SimulationControl>;
|
|
74
|
+
dependencies?: string[]; // external CDN scripts loaded before the simulation
|
|
75
|
+
height?: number; // iframe height, default 400
|
|
76
|
+
controls?: "interactive" | "observe";
|
|
77
|
+
accent?: BlockAccent;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface AnimationBlock extends BaseBlock, CaptionedBlock {
|
|
81
|
+
type: "animation";
|
|
82
|
+
src: string; // path to .js file or inline JS
|
|
83
|
+
loop?: boolean;
|
|
84
|
+
height?: number;
|
|
85
|
+
accent?: BlockAccent;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type MediaKind = "image" | "video" | "audio";
|
|
89
|
+
|
|
90
|
+
export interface MediaBlock extends BaseBlock, CaptionedBlock {
|
|
91
|
+
type: "media";
|
|
92
|
+
src: string;
|
|
93
|
+
kind: MediaKind;
|
|
94
|
+
alt?: string;
|
|
95
|
+
credit?: string;
|
|
96
|
+
poster?: string;
|
|
97
|
+
controls?: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface YouTubeBlock extends BaseBlock, CaptionedBlock {
|
|
101
|
+
type: "youtube";
|
|
102
|
+
id: string;
|
|
103
|
+
start?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface LatexBlock extends BaseBlock, CaptionedBlock {
|
|
107
|
+
type: "latex";
|
|
108
|
+
tex: string;
|
|
109
|
+
display?: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ColumnItem {
|
|
113
|
+
src?: string;
|
|
114
|
+
markdown?: string;
|
|
115
|
+
latex?: string;
|
|
116
|
+
width?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ColumnsBlock extends BaseBlock, CaptionedBlock {
|
|
120
|
+
type: "columns";
|
|
121
|
+
columns: ColumnItem[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface QuizBlock extends BaseBlock, CaptionedBlock {
|
|
125
|
+
type: "quiz";
|
|
126
|
+
src: string; // path to .json file or inline json
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface DividerBlock extends BaseBlock {
|
|
130
|
+
type: "divider";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type Block =
|
|
134
|
+
| HeadingBlock
|
|
135
|
+
| MarkdownBlock
|
|
136
|
+
| SectionBlock
|
|
137
|
+
| CalloutBlock
|
|
138
|
+
| CodeBlock
|
|
139
|
+
| SimulationBlock
|
|
140
|
+
| AnimationBlock
|
|
141
|
+
| MediaBlock
|
|
142
|
+
| YouTubeBlock
|
|
143
|
+
| LatexBlock
|
|
144
|
+
| ColumnsBlock
|
|
145
|
+
| QuizBlock
|
|
146
|
+
| DividerBlock;
|
|
147
|
+
|
|
148
|
+
// ─── Lesson Schema ────────────────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
export interface LessonMeta {
|
|
151
|
+
title: string;
|
|
152
|
+
slug: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
tags?: string[];
|
|
155
|
+
author?: string;
|
|
156
|
+
status?: "read" | "unread" | "locked";
|
|
157
|
+
parentSlug?: string;
|
|
158
|
+
prevSlug?: string;
|
|
159
|
+
prevTitle?: string;
|
|
160
|
+
nextSlug?: string;
|
|
161
|
+
nextTitle?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface Lesson {
|
|
165
|
+
meta: LessonMeta;
|
|
166
|
+
blocks: Block[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface LessonPreset {
|
|
170
|
+
layout?: "lesson" | "article" | "lab";
|
|
171
|
+
density?: "comfortable" | "compact";
|
|
172
|
+
tone?: "scholarly" | "studio" | "minimal";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ─── Quiz Schema (for .json files) ───────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
export interface QuizQuestion {
|
|
178
|
+
q: string;
|
|
179
|
+
options: string[];
|
|
180
|
+
answer: number; // index of correct option
|
|
181
|
+
explanation?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface QuizFile {
|
|
185
|
+
questions: QuizQuestion[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ─── Build Options ────────────────────────────────────────────────────────────
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Global configuration for building a lesson or chapter.
|
|
192
|
+
* Passed to `lesson(title, options)` or `chapter(title, options)`.
|
|
193
|
+
*/
|
|
194
|
+
export interface BuildOptions {
|
|
195
|
+
/** Directory where the generated HTML file will be written. Default: `'./out'` */
|
|
196
|
+
outDir?: string;
|
|
197
|
+
/** Base path for resolving local files like `.md`, `.js`, `.json`. Default: `'.'` */
|
|
198
|
+
contentBase?: string;
|
|
199
|
+
/** Light or dark mode. `auto` respects user system preferences. Default: `'auto'` */
|
|
200
|
+
theme?: "light" | "dark" | "auto";
|
|
201
|
+
/** Visual color palette of the generated page. Default: `'ink'` */
|
|
202
|
+
palette?: "ink" | "field" | "ember";
|
|
203
|
+
/** Custom CSS font-family string (e.g. `'Inter, sans-serif'`). */
|
|
204
|
+
font?: string;
|
|
205
|
+
/** Path to a favicon. */
|
|
206
|
+
favicon?: string;
|
|
207
|
+
/** Custom raw HTML to inject into the `<head>` tag. */
|
|
208
|
+
head?: string;
|
|
209
|
+
/** Preset for layout, density, and tone. */
|
|
210
|
+
preset?: LessonPreset;
|
|
211
|
+
/** If true, throws errors on missing files and invalid blocks to prevent silent failures. Default: `true` */
|
|
212
|
+
strict?: boolean;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Configuration for simulation blocks */
|
|
216
|
+
export interface SimulationOptions {
|
|
217
|
+
props?: Record<string, unknown>;
|
|
218
|
+
tunables?: Record<string, SimulationControl>;
|
|
219
|
+
height?: number;
|
|
220
|
+
label?: string;
|
|
221
|
+
caption?: string;
|
|
222
|
+
controls?: SimulationBlock["controls"];
|
|
223
|
+
accent?: BlockAccent;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface SimulationConfig extends SimulationOptions {
|
|
227
|
+
dependencies?: string[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Represents a single interactive control in a simulation (e.g., a slider) */
|
|
231
|
+
export interface SimulationControl {
|
|
232
|
+
label?: string;
|
|
233
|
+
min?: number;
|
|
234
|
+
max?: number;
|
|
235
|
+
step?: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface AnimationOptions {
|
|
239
|
+
loop?: boolean;
|
|
240
|
+
height?: number;
|
|
241
|
+
label?: string;
|
|
242
|
+
caption?: string;
|
|
243
|
+
accent?: BlockAccent;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface MediaOptions {
|
|
247
|
+
kind?: MediaKind;
|
|
248
|
+
alt?: string;
|
|
249
|
+
label?: string;
|
|
250
|
+
caption?: string;
|
|
251
|
+
credit?: string;
|
|
252
|
+
poster?: string;
|
|
253
|
+
controls?: boolean;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface YouTubeOptions {
|
|
257
|
+
start?: number;
|
|
258
|
+
label?: string;
|
|
259
|
+
caption?: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface LatexOptions {
|
|
263
|
+
display?: boolean;
|
|
264
|
+
label?: string;
|
|
265
|
+
caption?: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface ColumnsOptions {
|
|
269
|
+
label?: string;
|
|
270
|
+
caption?: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// ─── Chapter Schema ──────────────────────────────────────────────────────────
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Represents a logical grouping of multiple lessons.
|
|
277
|
+
*/
|
|
278
|
+
export interface ChapterMeta {
|
|
279
|
+
title: string;
|
|
280
|
+
slug: string;
|
|
281
|
+
description?: string;
|
|
282
|
+
status?: "completed" | "active" | "locked";
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface Chapter {
|
|
286
|
+
meta: ChapterMeta;
|
|
287
|
+
lessons: Lesson[];
|
|
288
|
+
}
|