@illusions-lab/mdi 2.0.20 → 2.0.21
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/dist/internal/mdast.cjs +72 -0
- package/dist/internal/mdast.d.cts +56 -0
- package/dist/internal/mdast.d.ts +56 -0
- package/dist/internal/mdast.js +19 -0
- package/package.json +9 -5
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
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
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/internal/mdast.ts
|
|
31
|
+
var mdast_exports = {};
|
|
32
|
+
__export(mdast_exports, {
|
|
33
|
+
MDI_MDAST_PROVENANCE_VERSION: () => MDI_MDAST_PROVENANCE_VERSION,
|
|
34
|
+
parseForMdast: () => parseForMdast
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(mdast_exports);
|
|
37
|
+
var import_mdi_core = require("@illusions-lab/mdi-core");
|
|
38
|
+
|
|
39
|
+
// src/index.ts
|
|
40
|
+
var mdiCore = __toESM(require("@illusions-lab/mdi-core"), 1);
|
|
41
|
+
var import_yaml = require("yaml");
|
|
42
|
+
var {
|
|
43
|
+
getMdiTextBlocksJson,
|
|
44
|
+
resolveMdiSourceSpansJson,
|
|
45
|
+
parseMdiSyntaxJson,
|
|
46
|
+
renderHtml: renderHtmlFromRust,
|
|
47
|
+
renderEpub: renderEpubFromRust,
|
|
48
|
+
renderEpubWithProfile: renderEpubWithProfileFromRust,
|
|
49
|
+
renderDocx: renderDocxFromRust,
|
|
50
|
+
renderDocxWithProfile: renderDocxWithProfileFromRust,
|
|
51
|
+
renderText: renderTextFromRust,
|
|
52
|
+
renderTextFormat: renderTextFormatFromRust,
|
|
53
|
+
resolveExportProfileJson: resolveExportProfileJsonFromRust,
|
|
54
|
+
serializeMdi: serializeMdiFromRust
|
|
55
|
+
} = mdiCore;
|
|
56
|
+
var MDI_IR_VERSION = "1.0";
|
|
57
|
+
|
|
58
|
+
// src/internal/mdast.ts
|
|
59
|
+
var MDI_MDAST_PROVENANCE_VERSION = "1.0";
|
|
60
|
+
function parseForMdast(source) {
|
|
61
|
+
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
62
|
+
const result = JSON.parse((0, import_mdi_core.parseMdiMdastJson)(source));
|
|
63
|
+
if (result.irVersion !== MDI_IR_VERSION) {
|
|
64
|
+
throw new Error(`Unsupported MDI IR version: ${String(result.irVersion)}`);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
MDI_MDAST_PROVENANCE_VERSION,
|
|
71
|
+
parseForMdast
|
|
72
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { MdiDocument, MdiFrontmatter, MdiSourceSpan, MdiTextRange, MdiNode, MDI_IR_VERSION, MDI_SPEC_VERSION, MdiParserCapabilities, MdiDiagnostic } from '../index.cjs';
|
|
2
|
+
import '@illusions-lab/mdi-to-epub';
|
|
3
|
+
import '@illusions-lab/mdi-export-profile';
|
|
4
|
+
import 'mdast';
|
|
5
|
+
|
|
6
|
+
/** Version of Rust-owned transient mdast provenance records. */
|
|
7
|
+
declare const MDI_MDAST_PROVENANCE_VERSION: "1.0";
|
|
8
|
+
/** A projection target assigned by Rust to a source-backed IR construct. */
|
|
9
|
+
type MdiMdastProvenanceTarget = {
|
|
10
|
+
blockIndex: number;
|
|
11
|
+
channel: "blockText";
|
|
12
|
+
range: MdiTextRange;
|
|
13
|
+
} | {
|
|
14
|
+
blockIndex: number;
|
|
15
|
+
channel: "annotation";
|
|
16
|
+
annotationIndex: number;
|
|
17
|
+
range: MdiTextRange;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Transient identity and projection metadata emitted by Rust for mdast
|
|
21
|
+
* adapters. `construct.path` is valid only for this parse result; it is not a
|
|
22
|
+
* persisted document ID and must not be inferred from text or order.
|
|
23
|
+
*/
|
|
24
|
+
interface MdiMdastProvenance {
|
|
25
|
+
version: typeof MDI_MDAST_PROVENANCE_VERSION;
|
|
26
|
+
construct: {
|
|
27
|
+
path: string;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
span: MdiSourceSpan | null;
|
|
31
|
+
role: "container" | "textBearing";
|
|
32
|
+
status: "sourceBacked" | "synthetic" | "unmapped";
|
|
33
|
+
targets: MdiMdastProvenanceTarget[];
|
|
34
|
+
}
|
|
35
|
+
type MdiMdastNode = Omit<MdiNode, "children"> & {
|
|
36
|
+
mdiProvenance?: MdiMdastProvenance;
|
|
37
|
+
children?: MdiMdastNode[];
|
|
38
|
+
};
|
|
39
|
+
type MdiMdastFrontmatter = MdiFrontmatter & {
|
|
40
|
+
mdiProvenance: MdiMdastProvenance;
|
|
41
|
+
};
|
|
42
|
+
type MdiMdastDocument = Omit<MdiDocument, "frontmatter" | "children"> & {
|
|
43
|
+
frontmatter?: MdiMdastFrontmatter;
|
|
44
|
+
children: MdiMdastNode[];
|
|
45
|
+
};
|
|
46
|
+
interface MdiMdastParseResult {
|
|
47
|
+
irVersion: typeof MDI_IR_VERSION;
|
|
48
|
+
syntaxVersion: typeof MDI_SPEC_VERSION;
|
|
49
|
+
capabilities: MdiParserCapabilities;
|
|
50
|
+
document: MdiMdastDocument;
|
|
51
|
+
diagnostics: MdiDiagnostic[];
|
|
52
|
+
}
|
|
53
|
+
/** Rust-backed transport exclusively for mdast adapters. */
|
|
54
|
+
declare function parseForMdast(source: string): MdiMdastParseResult;
|
|
55
|
+
|
|
56
|
+
export { MDI_MDAST_PROVENANCE_VERSION, type MdiMdastDocument, type MdiMdastFrontmatter, type MdiMdastNode, type MdiMdastParseResult, type MdiMdastProvenance, type MdiMdastProvenanceTarget, parseForMdast };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { MdiDocument, MdiFrontmatter, MdiSourceSpan, MdiTextRange, MdiNode, MDI_IR_VERSION, MDI_SPEC_VERSION, MdiParserCapabilities, MdiDiagnostic } from '../index.js';
|
|
2
|
+
import '@illusions-lab/mdi-to-epub';
|
|
3
|
+
import '@illusions-lab/mdi-export-profile';
|
|
4
|
+
import 'mdast';
|
|
5
|
+
|
|
6
|
+
/** Version of Rust-owned transient mdast provenance records. */
|
|
7
|
+
declare const MDI_MDAST_PROVENANCE_VERSION: "1.0";
|
|
8
|
+
/** A projection target assigned by Rust to a source-backed IR construct. */
|
|
9
|
+
type MdiMdastProvenanceTarget = {
|
|
10
|
+
blockIndex: number;
|
|
11
|
+
channel: "blockText";
|
|
12
|
+
range: MdiTextRange;
|
|
13
|
+
} | {
|
|
14
|
+
blockIndex: number;
|
|
15
|
+
channel: "annotation";
|
|
16
|
+
annotationIndex: number;
|
|
17
|
+
range: MdiTextRange;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Transient identity and projection metadata emitted by Rust for mdast
|
|
21
|
+
* adapters. `construct.path` is valid only for this parse result; it is not a
|
|
22
|
+
* persisted document ID and must not be inferred from text or order.
|
|
23
|
+
*/
|
|
24
|
+
interface MdiMdastProvenance {
|
|
25
|
+
version: typeof MDI_MDAST_PROVENANCE_VERSION;
|
|
26
|
+
construct: {
|
|
27
|
+
path: string;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
span: MdiSourceSpan | null;
|
|
31
|
+
role: "container" | "textBearing";
|
|
32
|
+
status: "sourceBacked" | "synthetic" | "unmapped";
|
|
33
|
+
targets: MdiMdastProvenanceTarget[];
|
|
34
|
+
}
|
|
35
|
+
type MdiMdastNode = Omit<MdiNode, "children"> & {
|
|
36
|
+
mdiProvenance?: MdiMdastProvenance;
|
|
37
|
+
children?: MdiMdastNode[];
|
|
38
|
+
};
|
|
39
|
+
type MdiMdastFrontmatter = MdiFrontmatter & {
|
|
40
|
+
mdiProvenance: MdiMdastProvenance;
|
|
41
|
+
};
|
|
42
|
+
type MdiMdastDocument = Omit<MdiDocument, "frontmatter" | "children"> & {
|
|
43
|
+
frontmatter?: MdiMdastFrontmatter;
|
|
44
|
+
children: MdiMdastNode[];
|
|
45
|
+
};
|
|
46
|
+
interface MdiMdastParseResult {
|
|
47
|
+
irVersion: typeof MDI_IR_VERSION;
|
|
48
|
+
syntaxVersion: typeof MDI_SPEC_VERSION;
|
|
49
|
+
capabilities: MdiParserCapabilities;
|
|
50
|
+
document: MdiMdastDocument;
|
|
51
|
+
diagnostics: MdiDiagnostic[];
|
|
52
|
+
}
|
|
53
|
+
/** Rust-backed transport exclusively for mdast adapters. */
|
|
54
|
+
declare function parseForMdast(source: string): MdiMdastParseResult;
|
|
55
|
+
|
|
56
|
+
export { MDI_MDAST_PROVENANCE_VERSION, type MdiMdastDocument, type MdiMdastFrontmatter, type MdiMdastNode, type MdiMdastParseResult, type MdiMdastProvenance, type MdiMdastProvenanceTarget, parseForMdast };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MDI_IR_VERSION
|
|
3
|
+
} from "../chunk-GMS5SFZO.js";
|
|
4
|
+
|
|
5
|
+
// src/internal/mdast.ts
|
|
6
|
+
import { parseMdiMdastJson } from "@illusions-lab/mdi-core";
|
|
7
|
+
var MDI_MDAST_PROVENANCE_VERSION = "1.0";
|
|
8
|
+
function parseForMdast(source) {
|
|
9
|
+
if (typeof source !== "string") throw new TypeError("source must be a string");
|
|
10
|
+
const result = JSON.parse(parseMdiMdastJson(source));
|
|
11
|
+
if (result.irVersion !== MDI_IR_VERSION) {
|
|
12
|
+
throw new Error(`Unsupported MDI IR version: ${String(result.irVersion)}`);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
MDI_MDAST_PROVENANCE_VERSION,
|
|
18
|
+
parseForMdast
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@illusions-lab/mdi",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"description": "Thin JavaScript binding for the Rust-authoritative MDI parser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,20 +21,24 @@
|
|
|
21
21
|
"./node": {
|
|
22
22
|
"types": "./dist/node.d.ts",
|
|
23
23
|
"default": "./dist/node.js"
|
|
24
|
+
},
|
|
25
|
+
"./internal/mdast": {
|
|
26
|
+
"types": "./dist/internal/mdast.d.ts",
|
|
27
|
+
"default": "./dist/internal/mdast.js"
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"files": [
|
|
27
31
|
"dist"
|
|
28
32
|
],
|
|
29
33
|
"scripts": {
|
|
30
|
-
"build": "tsup src/index.ts src/node.ts --format esm,cjs --dts",
|
|
34
|
+
"build": "tsup src/index.ts src/node.ts src/internal/mdast.ts --format esm,cjs --dts",
|
|
31
35
|
"test": "vitest run --passWithNoTests",
|
|
32
36
|
"typecheck": "tsc --noEmit"
|
|
33
37
|
},
|
|
34
38
|
"dependencies": {
|
|
35
|
-
"@illusions-lab/mdi-core": "^2.0.
|
|
36
|
-
"@illusions-lab/mdi-export-profile": "^2.0.
|
|
37
|
-
"@illusions-lab/mdi-to-epub": "^2.0.
|
|
39
|
+
"@illusions-lab/mdi-core": "^2.0.21",
|
|
40
|
+
"@illusions-lab/mdi-export-profile": "^2.0.26",
|
|
41
|
+
"@illusions-lab/mdi-to-epub": "^2.0.36",
|
|
38
42
|
"@types/mdast": "^4.0.0",
|
|
39
43
|
"yaml": "^2.0.0"
|
|
40
44
|
},
|