@illusions-lab/mdi 2.0.16 → 2.0.18
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 -0
- package/dist/{chunk-BF7UFCZO.js → chunk-WEJ62HS6.js} +23 -14
- package/dist/index.cjs +45 -13
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +3 -1
- package/dist/node.cjs +28 -7
- package/dist/node.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -25,6 +25,25 @@ console.log(result.document);
|
|
|
25
25
|
console.log(result.diagnostics);
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
### Browser initialization
|
|
29
|
+
|
|
30
|
+
Browser applications must initialize the Rust WebAssembly module once before
|
|
31
|
+
using the otherwise synchronous APIs. Repeated calls return the same pending
|
|
32
|
+
initialization and are safe during hot reload or shared application startup:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { initializeMdi, parse, serializeMdi } from "@illusions-lab/mdi";
|
|
36
|
+
|
|
37
|
+
await initializeMdi();
|
|
38
|
+
const parsed = parse("{東京|とうきょう} ^12^");
|
|
39
|
+
const canonical = serializeMdi("{東京|とうきょう} ^12^");
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Vite and other browser-condition-aware bundlers select the web loader and emit
|
|
43
|
+
its WASM asset automatically. Node.js keeps its existing eager, synchronous
|
|
44
|
+
WASM loading behavior; `initializeMdi()` resolves immediately there, so shared
|
|
45
|
+
startup code can call it in both environments.
|
|
46
|
+
|
|
28
47
|
## What the binding does
|
|
29
48
|
|
|
30
49
|
The package has deliberately narrow responsibilities:
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
parseMdiSyntaxJson,
|
|
4
|
-
renderHtml as renderHtmlFromRust,
|
|
5
|
-
renderEpub as renderEpubFromRust,
|
|
6
|
-
renderEpubWithProfile as renderEpubWithProfileFromRust,
|
|
7
|
-
renderDocx as renderDocxFromRust,
|
|
8
|
-
renderDocxWithProfile as renderDocxWithProfileFromRust,
|
|
9
|
-
renderText as renderTextFromRust,
|
|
10
|
-
renderTextFormat as renderTextFormatFromRust,
|
|
11
|
-
serializeMdi as serializeMdiFromRust
|
|
12
|
-
} from "@illusions-lab/mdi-core";
|
|
13
|
-
import {
|
|
14
|
-
requireLayoutSystem
|
|
15
|
-
} from "@illusions-lab/mdi-export-profile";
|
|
2
|
+
import * as mdiCore from "@illusions-lab/mdi-core";
|
|
16
3
|
import { parse as parseYaml } from "yaml";
|
|
4
|
+
var {
|
|
5
|
+
parseMdiSyntaxJson,
|
|
6
|
+
renderHtml: renderHtmlFromRust,
|
|
7
|
+
renderEpub: renderEpubFromRust,
|
|
8
|
+
renderEpubWithProfile: renderEpubWithProfileFromRust,
|
|
9
|
+
renderDocx: renderDocxFromRust,
|
|
10
|
+
renderDocxWithProfile: renderDocxWithProfileFromRust,
|
|
11
|
+
renderText: renderTextFromRust,
|
|
12
|
+
renderTextFormat: renderTextFormatFromRust,
|
|
13
|
+
resolveExportProfileJson: resolveExportProfileJsonFromRust,
|
|
14
|
+
serializeMdi: serializeMdiFromRust
|
|
15
|
+
} = mdiCore;
|
|
16
|
+
function initializeMdi() {
|
|
17
|
+
return mdiCore.initializeMdiCore();
|
|
18
|
+
}
|
|
19
|
+
function requireLayoutSystem(profile) {
|
|
20
|
+
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
21
|
+
throw new Error("Export profile must be an object");
|
|
22
|
+
}
|
|
23
|
+
resolveExportProfileJsonFromRust(JSON.stringify(profile), void 0, true);
|
|
24
|
+
}
|
|
17
25
|
var MDI_SPEC_VERSION = "2.0";
|
|
18
26
|
var MDI_IR_VERSION = "1.0";
|
|
19
27
|
function parse(source) {
|
|
@@ -355,6 +363,7 @@ function renderTextFormatWithDiagnostics(source, format, indentPrefix = "") {
|
|
|
355
363
|
var parseMdiSyntax = parse;
|
|
356
364
|
|
|
357
365
|
export {
|
|
366
|
+
initializeMdi,
|
|
358
367
|
MDI_SPEC_VERSION,
|
|
359
368
|
MDI_IR_VERSION,
|
|
360
369
|
parse,
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -22,6 +32,7 @@ var index_exports = {};
|
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
MDI_IR_VERSION: () => MDI_IR_VERSION,
|
|
24
34
|
MDI_SPEC_VERSION: () => MDI_SPEC_VERSION,
|
|
35
|
+
initializeMdi: () => initializeMdi,
|
|
25
36
|
parse: () => parse,
|
|
26
37
|
parseMdiSyntax: () => parseMdiSyntax,
|
|
27
38
|
prepareRender: () => prepareRender,
|
|
@@ -41,14 +52,34 @@ __export(index_exports, {
|
|
|
41
52
|
toPublicationMdast: () => toPublicationMdast
|
|
42
53
|
});
|
|
43
54
|
module.exports = __toCommonJS(index_exports);
|
|
44
|
-
var
|
|
45
|
-
var import_mdi_export_profile = require("@illusions-lab/mdi-export-profile");
|
|
55
|
+
var mdiCore = __toESM(require("@illusions-lab/mdi-core"), 1);
|
|
46
56
|
var import_yaml = require("yaml");
|
|
57
|
+
var {
|
|
58
|
+
parseMdiSyntaxJson,
|
|
59
|
+
renderHtml: renderHtmlFromRust,
|
|
60
|
+
renderEpub: renderEpubFromRust,
|
|
61
|
+
renderEpubWithProfile: renderEpubWithProfileFromRust,
|
|
62
|
+
renderDocx: renderDocxFromRust,
|
|
63
|
+
renderDocxWithProfile: renderDocxWithProfileFromRust,
|
|
64
|
+
renderText: renderTextFromRust,
|
|
65
|
+
renderTextFormat: renderTextFormatFromRust,
|
|
66
|
+
resolveExportProfileJson: resolveExportProfileJsonFromRust,
|
|
67
|
+
serializeMdi: serializeMdiFromRust
|
|
68
|
+
} = mdiCore;
|
|
69
|
+
function initializeMdi() {
|
|
70
|
+
return mdiCore.initializeMdiCore();
|
|
71
|
+
}
|
|
72
|
+
function requireLayoutSystem(profile) {
|
|
73
|
+
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
74
|
+
throw new Error("Export profile must be an object");
|
|
75
|
+
}
|
|
76
|
+
resolveExportProfileJsonFromRust(JSON.stringify(profile), void 0, true);
|
|
77
|
+
}
|
|
47
78
|
var MDI_SPEC_VERSION = "2.0";
|
|
48
79
|
var MDI_IR_VERSION = "1.0";
|
|
49
80
|
function parse(source) {
|
|
50
81
|
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
51
|
-
const result = JSON.parse(
|
|
82
|
+
const result = JSON.parse(parseMdiSyntaxJson(source));
|
|
52
83
|
if (result.irVersion !== MDI_IR_VERSION) {
|
|
53
84
|
throw new Error(`Unsupported MDI IR version: ${String(result.irVersion)}`);
|
|
54
85
|
}
|
|
@@ -57,7 +88,7 @@ function parse(source) {
|
|
|
57
88
|
function renderHtml(source, options) {
|
|
58
89
|
assertSource(source);
|
|
59
90
|
assertHtmlOptions(options);
|
|
60
|
-
const html = (
|
|
91
|
+
const html = renderHtmlFromRust(source);
|
|
61
92
|
return options?.bodyOnly ? htmlBody(html) : html;
|
|
62
93
|
}
|
|
63
94
|
function renderHtmlWithDiagnostics(source, options) {
|
|
@@ -74,7 +105,7 @@ function renderEpub(source, options) {
|
|
|
74
105
|
assertEpubOptions(options);
|
|
75
106
|
return renderEpubWithProfile(source, options);
|
|
76
107
|
}
|
|
77
|
-
return (
|
|
108
|
+
return renderEpubFromRust(source);
|
|
78
109
|
}
|
|
79
110
|
function renderEpubWithDiagnostics(source, options) {
|
|
80
111
|
return options === void 0 ? renderWithDiagnostics(source, () => renderEpub(source)) : renderWithDiagnosticsAsync(source, () => renderEpub(source, options));
|
|
@@ -85,7 +116,7 @@ function renderDocx(source, profile) {
|
|
|
85
116
|
assertPlainObject(profile, "profile");
|
|
86
117
|
return renderDocxWithProfile(source, profile);
|
|
87
118
|
}
|
|
88
|
-
return (
|
|
119
|
+
return renderDocxFromRust(source);
|
|
89
120
|
}
|
|
90
121
|
function renderDocxWithDiagnostics(source, profile) {
|
|
91
122
|
return profile === void 0 ? renderWithDiagnostics(source, () => renderDocx(source)) : renderWithDiagnosticsAsync(source, () => renderDocx(source, profile));
|
|
@@ -94,9 +125,9 @@ async function renderEpubWithProfile(source, options = {}) {
|
|
|
94
125
|
assertSource(source);
|
|
95
126
|
assertEpubOptions(options);
|
|
96
127
|
const normalized = normalizeEpubOptions(options);
|
|
97
|
-
|
|
128
|
+
requireLayoutSystem(normalized.profile);
|
|
98
129
|
const cover = normalized.cover;
|
|
99
|
-
return (
|
|
130
|
+
return renderEpubWithProfileFromRust(
|
|
100
131
|
source,
|
|
101
132
|
JSON.stringify(normalized.profile),
|
|
102
133
|
cover?.data ?? new Uint8Array(),
|
|
@@ -107,8 +138,8 @@ async function renderDocxWithProfile(source, profile = {}) {
|
|
|
107
138
|
assertSource(source);
|
|
108
139
|
assertPlainObject(profile, "profile");
|
|
109
140
|
const normalized = normalizeDocxProfile(profile);
|
|
110
|
-
|
|
111
|
-
return (
|
|
141
|
+
requireLayoutSystem(normalized);
|
|
142
|
+
return renderDocxWithProfileFromRust(source, JSON.stringify(normalized));
|
|
112
143
|
}
|
|
113
144
|
function toPublicationMdast(document) {
|
|
114
145
|
const children = document.children.map(toPublicationMdastNode);
|
|
@@ -364,11 +395,11 @@ function defined(value) {
|
|
|
364
395
|
}
|
|
365
396
|
function serializeMdi(source) {
|
|
366
397
|
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
367
|
-
return (
|
|
398
|
+
return serializeMdiFromRust(source);
|
|
368
399
|
}
|
|
369
400
|
function renderText(source) {
|
|
370
401
|
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
371
|
-
return (
|
|
402
|
+
return renderTextFromRust(source);
|
|
372
403
|
}
|
|
373
404
|
function renderTextWithDiagnostics(source) {
|
|
374
405
|
return renderWithDiagnostics(source, () => renderText(source));
|
|
@@ -377,7 +408,7 @@ function renderTextFormat(source, format, indentPrefix = "") {
|
|
|
377
408
|
if (typeof source !== "string" || typeof indentPrefix !== "string") {
|
|
378
409
|
throw new TypeError("source and indentPrefix must be strings");
|
|
379
410
|
}
|
|
380
|
-
return (
|
|
411
|
+
return renderTextFormatFromRust(source, format, indentPrefix);
|
|
381
412
|
}
|
|
382
413
|
function renderTextFormatWithDiagnostics(source, format, indentPrefix = "") {
|
|
383
414
|
return renderWithDiagnostics(source, () => renderTextFormat(source, format, indentPrefix));
|
|
@@ -387,6 +418,7 @@ var parseMdiSyntax = parse;
|
|
|
387
418
|
0 && (module.exports = {
|
|
388
419
|
MDI_IR_VERSION,
|
|
389
420
|
MDI_SPEC_VERSION,
|
|
421
|
+
initializeMdi,
|
|
390
422
|
parse,
|
|
391
423
|
parseMdiSyntax,
|
|
392
424
|
prepareRender,
|
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,15 @@ import { ExportProfile } from '@illusions-lab/mdi-export-profile';
|
|
|
4
4
|
export { ExportProfile } from '@illusions-lab/mdi-export-profile';
|
|
5
5
|
import { Root } from 'mdast';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the shared MDI core runtime exactly once.
|
|
9
|
+
*
|
|
10
|
+
* Browser applications must await this before calling the synchronous parse
|
|
11
|
+
* or serialization APIs. In Node.js the WASM binding is loaded eagerly, so
|
|
12
|
+
* this remains a harmless resolved promise for portable application setup.
|
|
13
|
+
*/
|
|
14
|
+
declare function initializeMdi(): Promise<void>;
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
17
|
* Options for a configured EPUB export. The profile controls metadata,
|
|
9
18
|
* chapter splitting and typography; `cover` supplies the actual image data.
|
|
@@ -239,4 +248,4 @@ declare function renderTextFormatWithDiagnostics(source: string, format: MdiText
|
|
|
239
248
|
/** @deprecated Use {@link parse}; it now parses the complete document. */
|
|
240
249
|
declare const parseMdiSyntax: typeof parse;
|
|
241
250
|
|
|
242
|
-
export { MDI_IR_VERSION, MDI_SPEC_VERSION, type MdiDiagnostic, type MdiDocument, type MdiDocxExportProfile, type MdiEpubExportOptions, type MdiFrontmatter, type MdiHeading, type MdiHtmlRenderOptions, type MdiNode, type MdiParserCapabilities, type MdiPublicationFrontmatter, type MdiPublicationRoot, type MdiRenderResult, type MdiRubyReading, type MdiSourceSpan, type MdiSyntaxDocument, type MdiSyntaxParseResult, type MdiTextFormat, parse, parseMdiSyntax, prepareRender, renderDocx, renderDocxWithDiagnostics, renderDocxWithProfile, renderEpub, renderEpubWithDiagnostics, renderEpubWithProfile, renderHtml, renderHtmlWithDiagnostics, renderText, renderTextFormat, renderTextFormatWithDiagnostics, renderTextWithDiagnostics, serializeMdi, toPublicationMdast };
|
|
251
|
+
export { MDI_IR_VERSION, MDI_SPEC_VERSION, type MdiDiagnostic, type MdiDocument, type MdiDocxExportProfile, type MdiEpubExportOptions, type MdiFrontmatter, type MdiHeading, type MdiHtmlRenderOptions, type MdiNode, type MdiParserCapabilities, type MdiPublicationFrontmatter, type MdiPublicationRoot, type MdiRenderResult, type MdiRubyReading, type MdiSourceSpan, type MdiSyntaxDocument, type MdiSyntaxParseResult, type MdiTextFormat, initializeMdi, parse, parseMdiSyntax, prepareRender, renderDocx, renderDocxWithDiagnostics, renderDocxWithProfile, renderEpub, renderEpubWithDiagnostics, renderEpubWithProfile, renderHtml, renderHtmlWithDiagnostics, renderText, renderTextFormat, renderTextFormatWithDiagnostics, renderTextWithDiagnostics, serializeMdi, toPublicationMdast };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,15 @@ import { ExportProfile } from '@illusions-lab/mdi-export-profile';
|
|
|
4
4
|
export { ExportProfile } from '@illusions-lab/mdi-export-profile';
|
|
5
5
|
import { Root } from 'mdast';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the shared MDI core runtime exactly once.
|
|
9
|
+
*
|
|
10
|
+
* Browser applications must await this before calling the synchronous parse
|
|
11
|
+
* or serialization APIs. In Node.js the WASM binding is loaded eagerly, so
|
|
12
|
+
* this remains a harmless resolved promise for portable application setup.
|
|
13
|
+
*/
|
|
14
|
+
declare function initializeMdi(): Promise<void>;
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
17
|
* Options for a configured EPUB export. The profile controls metadata,
|
|
9
18
|
* chapter splitting and typography; `cover` supplies the actual image data.
|
|
@@ -239,4 +248,4 @@ declare function renderTextFormatWithDiagnostics(source: string, format: MdiText
|
|
|
239
248
|
/** @deprecated Use {@link parse}; it now parses the complete document. */
|
|
240
249
|
declare const parseMdiSyntax: typeof parse;
|
|
241
250
|
|
|
242
|
-
export { MDI_IR_VERSION, MDI_SPEC_VERSION, type MdiDiagnostic, type MdiDocument, type MdiDocxExportProfile, type MdiEpubExportOptions, type MdiFrontmatter, type MdiHeading, type MdiHtmlRenderOptions, type MdiNode, type MdiParserCapabilities, type MdiPublicationFrontmatter, type MdiPublicationRoot, type MdiRenderResult, type MdiRubyReading, type MdiSourceSpan, type MdiSyntaxDocument, type MdiSyntaxParseResult, type MdiTextFormat, parse, parseMdiSyntax, prepareRender, renderDocx, renderDocxWithDiagnostics, renderDocxWithProfile, renderEpub, renderEpubWithDiagnostics, renderEpubWithProfile, renderHtml, renderHtmlWithDiagnostics, renderText, renderTextFormat, renderTextFormatWithDiagnostics, renderTextWithDiagnostics, serializeMdi, toPublicationMdast };
|
|
251
|
+
export { MDI_IR_VERSION, MDI_SPEC_VERSION, type MdiDiagnostic, type MdiDocument, type MdiDocxExportProfile, type MdiEpubExportOptions, type MdiFrontmatter, type MdiHeading, type MdiHtmlRenderOptions, type MdiNode, type MdiParserCapabilities, type MdiPublicationFrontmatter, type MdiPublicationRoot, type MdiRenderResult, type MdiRubyReading, type MdiSourceSpan, type MdiSyntaxDocument, type MdiSyntaxParseResult, type MdiTextFormat, initializeMdi, parse, parseMdiSyntax, prepareRender, renderDocx, renderDocxWithDiagnostics, renderDocxWithProfile, renderEpub, renderEpubWithDiagnostics, renderEpubWithProfile, renderHtml, renderHtmlWithDiagnostics, renderText, renderTextFormat, renderTextFormatWithDiagnostics, renderTextWithDiagnostics, serializeMdi, toPublicationMdast };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MDI_IR_VERSION,
|
|
3
3
|
MDI_SPEC_VERSION,
|
|
4
|
+
initializeMdi,
|
|
4
5
|
parse,
|
|
5
6
|
parseMdiSyntax,
|
|
6
7
|
prepareRender,
|
|
@@ -18,10 +19,11 @@ import {
|
|
|
18
19
|
renderTextWithDiagnostics,
|
|
19
20
|
serializeMdi,
|
|
20
21
|
toPublicationMdast
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-WEJ62HS6.js";
|
|
22
23
|
export {
|
|
23
24
|
MDI_IR_VERSION,
|
|
24
25
|
MDI_SPEC_VERSION,
|
|
26
|
+
initializeMdi,
|
|
25
27
|
parse,
|
|
26
28
|
parseMdiSyntax,
|
|
27
29
|
prepareRender,
|
package/dist/node.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/node.ts
|
|
@@ -28,13 +38,24 @@ __export(node_exports, {
|
|
|
28
38
|
module.exports = __toCommonJS(node_exports);
|
|
29
39
|
|
|
30
40
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
var import_mdi_export_profile = require("@illusions-lab/mdi-export-profile");
|
|
41
|
+
var mdiCore = __toESM(require("@illusions-lab/mdi-core"), 1);
|
|
33
42
|
var import_yaml = require("yaml");
|
|
43
|
+
var {
|
|
44
|
+
parseMdiSyntaxJson,
|
|
45
|
+
renderHtml: renderHtmlFromRust,
|
|
46
|
+
renderEpub: renderEpubFromRust,
|
|
47
|
+
renderEpubWithProfile: renderEpubWithProfileFromRust,
|
|
48
|
+
renderDocx: renderDocxFromRust,
|
|
49
|
+
renderDocxWithProfile: renderDocxWithProfileFromRust,
|
|
50
|
+
renderText: renderTextFromRust,
|
|
51
|
+
renderTextFormat: renderTextFormatFromRust,
|
|
52
|
+
resolveExportProfileJson: resolveExportProfileJsonFromRust,
|
|
53
|
+
serializeMdi: serializeMdiFromRust
|
|
54
|
+
} = mdiCore;
|
|
34
55
|
var MDI_IR_VERSION = "1.0";
|
|
35
56
|
function parse(source) {
|
|
36
57
|
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
37
|
-
const result = JSON.parse(
|
|
58
|
+
const result = JSON.parse(parseMdiSyntaxJson(source));
|
|
38
59
|
if (result.irVersion !== MDI_IR_VERSION) {
|
|
39
60
|
throw new Error(`Unsupported MDI IR version: ${String(result.irVersion)}`);
|
|
40
61
|
}
|
|
@@ -43,7 +64,7 @@ function parse(source) {
|
|
|
43
64
|
function renderHtml(source, options) {
|
|
44
65
|
assertSource(source);
|
|
45
66
|
assertHtmlOptions(options);
|
|
46
|
-
const html = (
|
|
67
|
+
const html = renderHtmlFromRust(source);
|
|
47
68
|
return options?.bodyOnly ? htmlBody(html) : html;
|
|
48
69
|
}
|
|
49
70
|
function assertSource(source) {
|
|
@@ -68,10 +89,10 @@ function assertPlainObject(value, label) {
|
|
|
68
89
|
}
|
|
69
90
|
|
|
70
91
|
// src/node.ts
|
|
71
|
-
var
|
|
92
|
+
var import_mdi_export_profile = require("@illusions-lab/mdi-export-profile");
|
|
72
93
|
function preparePdfExport(source, profile) {
|
|
73
94
|
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
74
|
-
if (profile !== void 0) (0,
|
|
95
|
+
if (profile !== void 0) (0, import_mdi_export_profile.requireLayoutSystem)(profile);
|
|
75
96
|
const writingMode = parse(source).document.frontmatter?.entries.find(
|
|
76
97
|
(entry) => entry.key === "writing-mode" || entry.key === "writingMode"
|
|
77
98
|
)?.value;
|
|
@@ -83,7 +104,7 @@ function preparePdfExport(source, profile) {
|
|
|
83
104
|
}
|
|
84
105
|
function preparePdfExportWithDiagnostics(source, profile) {
|
|
85
106
|
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
86
|
-
if (profile !== void 0) (0,
|
|
107
|
+
if (profile !== void 0) (0, import_mdi_export_profile.requireLayoutSystem)(profile);
|
|
87
108
|
const parsed = parse(source);
|
|
88
109
|
const writingMode = parsed.document.frontmatter?.entries.find(
|
|
89
110
|
(entry) => entry.key === "writing-mode" || entry.key === "writingMode"
|
package/dist/node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@illusions-lab/mdi",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
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.18",
|
|
36
|
+
"@illusions-lab/mdi-export-profile": "^2.0.23",
|
|
37
|
+
"@illusions-lab/mdi-to-epub": "^2.0.33",
|
|
38
38
|
"@types/mdast": "^4.0.0",
|
|
39
39
|
"yaml": "^2.0.0"
|
|
40
40
|
},
|