@illusions-lab/mdi 2.0.12 → 2.0.14

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 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, and
66
- the one-argument baseline EPUB/DOCX renderers execute in Rust and are exposed
67
- through this package. PDF uses Rust HTML as its input to a host layout adapter such as
68
- `@illusions-lab/mdi-to-pdf`; the adapter may control Chromium, but it never
69
- parses MDI or produces semantic HTML.
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 split: Rust owns MDI parsing and
98
- semantic HTML; publication profiles own EPUB/DOCX metadata and typesetting;
99
- the host owns Chromium/Electron, paper-printer integration, and application UI
100
- preferences. This keeps platform-specific pagination controls out of the
101
- parser and lets Electron supply its own PDF adapter.
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). These Node.js-only async paths map the
107
- Rust-owned IR through the publication adapters and retain configuration for
108
- metadata, chapter splitting, vertical writing, font selection, paper size,
109
- margins, and page numbers. EPUB also accepts in-memory PNG or JPEG cover art.
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
- /** Point size; requires a publication adapter that supports it. */
48
+ /** Body type size in typographic points. */
49
49
  fontSize?: number;
50
- /** Line-height multiplier; requires a publication adapter that supports it. */
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 publication-adapter roots. */
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
- * because archive generation is performed by the Node.js publication adapter.
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
- * because archive generation is performed by the Node.js publication adapter.
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 using the same profile schema as the dedicated
213
- * publication adapters. Unlike the one-argument {@link renderEpub}, this
214
- * returns a Promise and supports cover art, metadata, chapters and vertical
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. The 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
- * Map the Rust-owned IR to mdast for the publication adapters. This is a
225
- * structural conversion only: all grammar decisions have already been made
226
- * by {@link parse}, so it never reparses MDI source in JavaScript.
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. */
@@ -236,7 +231,7 @@ declare function serializeMdi(source: string): string;
236
231
  declare function renderText(source: string): string;
237
232
  /** Render plain text without discarding Rust diagnostics and source spans. */
238
233
  declare function renderTextWithDiagnostics(source: string): MdiRenderResult<string>;
239
- type MdiTextFormat = "txt" | "txt-ruby" | "narou" | "kakuyomu" | "aozora";
234
+ type MdiTextFormat = "txt" | "txt-ruby" | "narou" | "kakuyomu" | "aozora" | "note";
240
235
  /** Render a named publication-text convention through Rust. */
241
236
  declare function renderTextFormat(source: string, format: MdiTextFormat, indentPrefix?: string): string;
242
237
  /** Render a named text format without discarding Rust diagnostics and spans. */
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
- /** Point size; requires a publication adapter that supports it. */
48
+ /** Body type size in typographic points. */
49
49
  fontSize?: number;
50
- /** Line-height multiplier; requires a publication adapter that supports it. */
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 publication-adapter roots. */
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
- * because archive generation is performed by the Node.js publication adapter.
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
- * because archive generation is performed by the Node.js publication adapter.
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 using the same profile schema as the dedicated
213
- * publication adapters. Unlike the one-argument {@link renderEpub}, this
214
- * returns a Promise and supports cover art, metadata, chapters and vertical
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. The 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
- * Map the Rust-owned IR to mdast for the publication adapters. This is a
225
- * structural conversion only: all grammar decisions have already been made
226
- * by {@link parse}, so it never reparses MDI source in JavaScript.
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. */
@@ -236,7 +231,7 @@ declare function serializeMdi(source: string): string;
236
231
  declare function renderText(source: string): string;
237
232
  /** Render plain text without discarding Rust diagnostics and source spans. */
238
233
  declare function renderTextWithDiagnostics(source: string): MdiRenderResult<string>;
239
- type MdiTextFormat = "txt" | "txt-ruby" | "narou" | "kakuyomu" | "aozora";
234
+ type MdiTextFormat = "txt" | "txt-ruby" | "narou" | "kakuyomu" | "aozora" | "note";
240
235
  /** Render a named publication-text convention through Rust. */
241
236
  declare function renderTextFormat(source: string, format: MdiTextFormat, indentPrefix?: string): string;
242
237
  /** Render a named text format without discarding Rust diagnostics and spans. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@illusions-lab/mdi",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
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.12",
36
- "@illusions-lab/mdi-export-profile": "^2.0.17",
37
- "@illusions-lab/mdi-to-epub": "^2.0.27",
35
+ "@illusions-lab/mdi-core": "^2.0.14",
36
+ "@illusions-lab/mdi-export-profile": "^2.0.19",
37
+ "@illusions-lab/mdi-to-epub": "^2.0.29",
38
38
  "@types/mdast": "^4.0.0",
39
39
  "yaml": "^2.0.0"
40
40
  },