@illusions-lab/mdi 2.0.12 → 2.0.13
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 +19 -14
- package/dist/index.d.cts +12 -17
- package/dist/index.d.ts +12 -17
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -62,11 +62,12 @@ unsupported version.
|
|
|
62
62
|
|
|
63
63
|
## Rendering
|
|
64
64
|
|
|
65
|
-
Rendering starts from the same Rust IR. Canonical MDI, plain text, HTML,
|
|
66
|
-
|
|
67
|
-
through this package. PDF uses Rust HTML
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
Rendering starts from the same Rust IR. Canonical MDI, plain text, HTML, EPUB,
|
|
66
|
+
and DOCX—including profile-configured EPUB and DOCX—execute in Rust and are
|
|
67
|
+
exposed through this package. PDF uses Rust-prepared HTML, print CSS, page
|
|
68
|
+
geometry, and header/footer data as input to a host such as
|
|
69
|
+
`@illusions-lab/mdi-to-pdf`. The host launches Chromium, but it never parses
|
|
70
|
+
MDI or decides publication settings.
|
|
70
71
|
|
|
71
72
|
Browser WebAssembly cannot start Chromium. Browser code sends Rust-rendered
|
|
72
73
|
HTML to a server or desktop host when it needs PDF output.
|
|
@@ -94,25 +95,28 @@ Rust-authoritative parser rather than accepting mutable JavaScript IR. This
|
|
|
94
95
|
keeps the source spans and error codes predictable and prevents JavaScript from
|
|
95
96
|
becoming a second syntax implementation.
|
|
96
97
|
|
|
97
|
-
Configuration ownership is deliberately
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
Configuration ownership is deliberately clear: Rust validates publication
|
|
99
|
+
profiles and applies EPUB/DOCX metadata, typography, page geometry, and
|
|
100
|
+
numbering. For PDF, Rust also prepares the print HTML and resolved page data;
|
|
101
|
+
the host owns only Chromium/Electron process control, printer integration, and
|
|
102
|
+
application UI preferences. This keeps layout behavior consistent without
|
|
103
|
+
putting application concerns into the parser.
|
|
102
104
|
|
|
103
105
|
### Configured EPUB and DOCX
|
|
104
106
|
|
|
105
107
|
For publication output, pass an export profile to the overloads (or use the
|
|
106
|
-
explicit `WithProfile` functions).
|
|
107
|
-
|
|
108
|
-
metadata, chapter splitting, vertical writing, font
|
|
109
|
-
margins, and page numbers. EPUB also accepts in-memory
|
|
108
|
+
explicit `WithProfile` functions). The Promise-shaped API is retained for
|
|
109
|
+
compatibility, while profile validation and archive generation both run in
|
|
110
|
+
Rust. It supports metadata, chapter splitting, vertical writing, font
|
|
111
|
+
selection, paper size, margins, and page numbers. EPUB also accepts in-memory
|
|
112
|
+
PNG or JPEG cover art.
|
|
110
113
|
|
|
111
114
|
```ts
|
|
112
115
|
import { renderDocxWithProfile, renderEpubWithProfile } from "@illusions-lab/mdi";
|
|
113
116
|
|
|
114
117
|
const epub = await renderEpubWithProfile(source, {
|
|
115
118
|
profile: {
|
|
119
|
+
layout: { system: "japanese-publisher" },
|
|
116
120
|
metadata: { title: "Book", author: "Author" },
|
|
117
121
|
typesetting: { writingMode: "vertical", fontFamily: "Noto Serif JP" },
|
|
118
122
|
epub: { chapterSplitLevel: "h1" },
|
|
@@ -121,6 +125,7 @@ const epub = await renderEpubWithProfile(source, {
|
|
|
121
125
|
});
|
|
122
126
|
|
|
123
127
|
const docx = await renderDocxWithProfile(source, {
|
|
128
|
+
layout: { system: "word" },
|
|
124
129
|
pagination: { pageSize: "A5", margins: { top: 12, bottom: 12, left: 14, right: 14 } },
|
|
125
130
|
});
|
|
126
131
|
```
|
package/dist/index.d.cts
CHANGED
|
@@ -45,9 +45,9 @@ type MdiDocxExportProfile = ExportProfile & {
|
|
|
45
45
|
date?: string;
|
|
46
46
|
verticalWriting?: boolean;
|
|
47
47
|
fontFamily?: string;
|
|
48
|
-
/**
|
|
48
|
+
/** Body type size in typographic points. */
|
|
49
49
|
fontSize?: number;
|
|
50
|
-
/**
|
|
50
|
+
/** Baseline multiplier, for example 1.5 for one-and-a-half spacing. */
|
|
51
51
|
lineSpacing?: number;
|
|
52
52
|
textIndent?: number;
|
|
53
53
|
pageSize?: NonNullable<ExportProfile["pagination"]>["pageSize"];
|
|
@@ -113,7 +113,7 @@ interface MdiDocument {
|
|
|
113
113
|
frontmatter?: MdiFrontmatter;
|
|
114
114
|
children: MdiNode[];
|
|
115
115
|
}
|
|
116
|
-
/** Resolved front matter attached to mdast
|
|
116
|
+
/** Resolved front matter attached to mdast compatibility roots. */
|
|
117
117
|
interface MdiPublicationFrontmatter {
|
|
118
118
|
mdi: string;
|
|
119
119
|
title?: string;
|
|
@@ -192,7 +192,7 @@ declare function prepareRender(source: string): MdiSyntaxParseResult;
|
|
|
192
192
|
declare function renderEpub(source: string): Uint8Array;
|
|
193
193
|
/**
|
|
194
194
|
* Build a profile-configured EPUB 3 archive. This overload is asynchronous
|
|
195
|
-
*
|
|
195
|
+
* for backward compatibility; validation and archive generation run in Rust.
|
|
196
196
|
*/
|
|
197
197
|
declare function renderEpub(source: string, options: MdiEpubExportOptions): Promise<Uint8Array>;
|
|
198
198
|
/** Build a baseline Rust EPUB while retaining diagnostics for an export UI. */
|
|
@@ -202,32 +202,27 @@ declare function renderEpubWithDiagnostics(source: string, options: MdiEpubExpor
|
|
|
202
202
|
declare function renderDocx(source: string): Uint8Array;
|
|
203
203
|
/**
|
|
204
204
|
* Build a profile-configured DOCX archive. This overload is asynchronous
|
|
205
|
-
*
|
|
205
|
+
* for backward compatibility; validation and OOXML generation run in Rust.
|
|
206
206
|
*/
|
|
207
207
|
declare function renderDocx(source: string, profile: MdiDocxExportProfile): Promise<Uint8Array>;
|
|
208
208
|
/** Build a baseline Rust DOCX while retaining diagnostics for an export UI. */
|
|
209
209
|
declare function renderDocxWithDiagnostics(source: string): MdiRenderResult<Uint8Array>;
|
|
210
210
|
declare function renderDocxWithDiagnostics(source: string, profile: MdiDocxExportProfile): Promise<MdiRenderResult<Uint8Array>>;
|
|
211
211
|
/**
|
|
212
|
-
* Build a configured EPUB
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* writing.
|
|
212
|
+
* Build a configured EPUB in Rust. Unlike the one-argument
|
|
213
|
+
* {@link renderEpub}, this returns a Promise for API compatibility and
|
|
214
|
+
* supports cover art, metadata, chapters and vertical writing.
|
|
216
215
|
*/
|
|
217
216
|
declare function renderEpubWithProfile(source: string, options?: MdiEpubExportOptions): Promise<Uint8Array>;
|
|
218
217
|
/**
|
|
219
|
-
* Build a configured DOCX using the shared print profile.
|
|
218
|
+
* Build a configured DOCX in Rust using the shared print profile. The profile
|
|
220
219
|
* supports metadata, writing mode, paper size, margins and page numbers.
|
|
221
220
|
*/
|
|
222
221
|
declare function renderDocxWithProfile(source: string, profile?: MdiDocxExportProfile): Promise<Uint8Array>;
|
|
223
222
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*/
|
|
228
|
-
/**
|
|
229
|
-
* Convert a Rust-owned MDI document IR into mdast for publication adapters.
|
|
230
|
-
* This performs no parsing and preserves the adapter node conventions.
|
|
223
|
+
* Convert a Rust-owned MDI document IR into mdast for unified compatibility
|
|
224
|
+
* workflows. This performs no parsing and preserves the established mdast
|
|
225
|
+
* node conventions.
|
|
231
226
|
*/
|
|
232
227
|
declare function toPublicationMdast(document: MdiDocument): MdiPublicationRoot;
|
|
233
228
|
/** Parse and normalize complete `.mdi` source with Rust's serializer. */
|
package/dist/index.d.ts
CHANGED
|
@@ -45,9 +45,9 @@ type MdiDocxExportProfile = ExportProfile & {
|
|
|
45
45
|
date?: string;
|
|
46
46
|
verticalWriting?: boolean;
|
|
47
47
|
fontFamily?: string;
|
|
48
|
-
/**
|
|
48
|
+
/** Body type size in typographic points. */
|
|
49
49
|
fontSize?: number;
|
|
50
|
-
/**
|
|
50
|
+
/** Baseline multiplier, for example 1.5 for one-and-a-half spacing. */
|
|
51
51
|
lineSpacing?: number;
|
|
52
52
|
textIndent?: number;
|
|
53
53
|
pageSize?: NonNullable<ExportProfile["pagination"]>["pageSize"];
|
|
@@ -113,7 +113,7 @@ interface MdiDocument {
|
|
|
113
113
|
frontmatter?: MdiFrontmatter;
|
|
114
114
|
children: MdiNode[];
|
|
115
115
|
}
|
|
116
|
-
/** Resolved front matter attached to mdast
|
|
116
|
+
/** Resolved front matter attached to mdast compatibility roots. */
|
|
117
117
|
interface MdiPublicationFrontmatter {
|
|
118
118
|
mdi: string;
|
|
119
119
|
title?: string;
|
|
@@ -192,7 +192,7 @@ declare function prepareRender(source: string): MdiSyntaxParseResult;
|
|
|
192
192
|
declare function renderEpub(source: string): Uint8Array;
|
|
193
193
|
/**
|
|
194
194
|
* Build a profile-configured EPUB 3 archive. This overload is asynchronous
|
|
195
|
-
*
|
|
195
|
+
* for backward compatibility; validation and archive generation run in Rust.
|
|
196
196
|
*/
|
|
197
197
|
declare function renderEpub(source: string, options: MdiEpubExportOptions): Promise<Uint8Array>;
|
|
198
198
|
/** Build a baseline Rust EPUB while retaining diagnostics for an export UI. */
|
|
@@ -202,32 +202,27 @@ declare function renderEpubWithDiagnostics(source: string, options: MdiEpubExpor
|
|
|
202
202
|
declare function renderDocx(source: string): Uint8Array;
|
|
203
203
|
/**
|
|
204
204
|
* Build a profile-configured DOCX archive. This overload is asynchronous
|
|
205
|
-
*
|
|
205
|
+
* for backward compatibility; validation and OOXML generation run in Rust.
|
|
206
206
|
*/
|
|
207
207
|
declare function renderDocx(source: string, profile: MdiDocxExportProfile): Promise<Uint8Array>;
|
|
208
208
|
/** Build a baseline Rust DOCX while retaining diagnostics for an export UI. */
|
|
209
209
|
declare function renderDocxWithDiagnostics(source: string): MdiRenderResult<Uint8Array>;
|
|
210
210
|
declare function renderDocxWithDiagnostics(source: string, profile: MdiDocxExportProfile): Promise<MdiRenderResult<Uint8Array>>;
|
|
211
211
|
/**
|
|
212
|
-
* Build a configured EPUB
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* writing.
|
|
212
|
+
* Build a configured EPUB in Rust. Unlike the one-argument
|
|
213
|
+
* {@link renderEpub}, this returns a Promise for API compatibility and
|
|
214
|
+
* supports cover art, metadata, chapters and vertical writing.
|
|
216
215
|
*/
|
|
217
216
|
declare function renderEpubWithProfile(source: string, options?: MdiEpubExportOptions): Promise<Uint8Array>;
|
|
218
217
|
/**
|
|
219
|
-
* Build a configured DOCX using the shared print profile.
|
|
218
|
+
* Build a configured DOCX in Rust using the shared print profile. The profile
|
|
220
219
|
* supports metadata, writing mode, paper size, margins and page numbers.
|
|
221
220
|
*/
|
|
222
221
|
declare function renderDocxWithProfile(source: string, profile?: MdiDocxExportProfile): Promise<Uint8Array>;
|
|
223
222
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*/
|
|
228
|
-
/**
|
|
229
|
-
* Convert a Rust-owned MDI document IR into mdast for publication adapters.
|
|
230
|
-
* This performs no parsing and preserves the adapter node conventions.
|
|
223
|
+
* Convert a Rust-owned MDI document IR into mdast for unified compatibility
|
|
224
|
+
* workflows. This performs no parsing and preserves the established mdast
|
|
225
|
+
* node conventions.
|
|
231
226
|
*/
|
|
232
227
|
declare function toPublicationMdast(document: MdiDocument): MdiPublicationRoot;
|
|
233
228
|
/** Parse and normalize complete `.mdi` source with Rust's serializer. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@illusions-lab/mdi",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"description": "Thin JavaScript binding for the Rust-authoritative MDI parser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"typecheck": "tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@illusions-lab/mdi-core": "^2.0.
|
|
36
|
-
"@illusions-lab/mdi-export-profile": "^2.0.
|
|
37
|
-
"@illusions-lab/mdi-to-epub": "^2.0.
|
|
35
|
+
"@illusions-lab/mdi-core": "^2.0.13",
|
|
36
|
+
"@illusions-lab/mdi-export-profile": "^2.0.18",
|
|
37
|
+
"@illusions-lab/mdi-to-epub": "^2.0.28",
|
|
38
38
|
"@types/mdast": "^4.0.0",
|
|
39
39
|
"yaml": "^2.0.0"
|
|
40
40
|
},
|