satteri 0.8.0 → 0.9.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 +35 -0
- package/dist/byte-writer.d.ts +31 -0
- package/dist/byte-writer.js +106 -0
- package/dist/child-stub.d.ts +17 -0
- package/dist/child-stub.js +57 -0
- package/dist/command-buffer.d.ts +23 -24
- package/dist/command-buffer.js +65 -128
- package/dist/compile.d.ts +5 -1
- package/dist/compile.js +40 -26
- package/dist/directive-types.d.ts +4 -2
- package/dist/generated/arena-layout.d.ts +37 -0
- package/dist/generated/arena-layout.js +41 -0
- package/dist/generated/wire-constants.d.ts +51 -0
- package/dist/generated/wire-constants.js +63 -0
- package/dist/handles.d.ts +21 -0
- package/dist/handles.js +1 -0
- package/dist/hast/child-stub.d.ts +18 -0
- package/dist/hast/child-stub.js +43 -0
- package/dist/hast/element-props.d.ts +2 -0
- package/dist/hast/element-props.js +23 -0
- package/dist/hast/generated/node-types.d.ts +14 -0
- package/dist/hast/generated/node-types.js +64 -0
- package/dist/hast/hast-materializer.d.ts +2 -1
- package/dist/hast/hast-materializer.js +9 -45
- package/dist/hast/hast-reader.d.ts +18 -23
- package/dist/hast/hast-reader.js +48 -115
- package/dist/hast/hast-visitor.d.ts +38 -12
- package/dist/hast/hast-visitor.js +417 -281
- package/dist/index.d.ts +10 -4
- package/dist/index.js +23 -1
- package/dist/lazy-child-resolver.d.ts +36 -0
- package/dist/lazy-child-resolver.js +95 -0
- package/dist/lazy-props.d.ts +1 -1
- package/dist/mdast/child-stub.d.ts +18 -0
- package/dist/mdast/child-stub.js +46 -0
- package/dist/mdast/column-align.d.ts +1 -0
- package/dist/mdast/column-align.js +6 -0
- package/dist/mdast/generated/layout.d.ts +19 -0
- package/dist/mdast/generated/layout.js +272 -0
- package/dist/mdast/generated/node-types.d.ts +58 -0
- package/dist/mdast/generated/node-types.js +266 -0
- package/dist/mdast/mdast-materializer.d.ts +3 -2
- package/dist/mdast/mdast-materializer.js +9 -93
- package/dist/mdast/mdast-reader.d.ts +4 -120
- package/dist/mdast/mdast-reader.js +45 -272
- package/dist/mdast/mdast-visitor.d.ts +55 -13
- package/dist/mdast/mdast-visitor.js +375 -410
- package/dist/mdx-attr.d.ts +2 -0
- package/dist/mdx-attr.js +20 -0
- package/dist/op-stream.d.ts +38 -0
- package/dist/op-stream.js +125 -0
- package/dist/phantom.d.ts +2 -0
- package/dist/phantom.js +13 -0
- package/dist/types.d.ts +34 -4
- package/dist/visitor-shared.d.ts +28 -0
- package/dist/visitor-shared.js +52 -0
- package/dist/wire-read.d.ts +27 -0
- package/dist/wire-read.js +59 -0
- package/index.js +52 -52
- package/package.json +6 -6
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// @generated by `cargo run -p satteri-layout-codegen`. Do not edit by hand.
|
|
2
|
+
/** Node-type tag -> canonical AST name. */
|
|
3
|
+
export const TYPE_NAMES = {
|
|
4
|
+
0: "root",
|
|
5
|
+
1: "paragraph",
|
|
6
|
+
2: "heading",
|
|
7
|
+
3: "thematicBreak",
|
|
8
|
+
4: "blockquote",
|
|
9
|
+
5: "list",
|
|
10
|
+
6: "listItem",
|
|
11
|
+
7: "html",
|
|
12
|
+
8: "code",
|
|
13
|
+
9: "definition",
|
|
14
|
+
10: "text",
|
|
15
|
+
11: "emphasis",
|
|
16
|
+
12: "strong",
|
|
17
|
+
13: "inlineCode",
|
|
18
|
+
14: "break",
|
|
19
|
+
15: "link",
|
|
20
|
+
16: "image",
|
|
21
|
+
17: "linkReference",
|
|
22
|
+
18: "imageReference",
|
|
23
|
+
19: "footnoteDefinition",
|
|
24
|
+
20: "footnoteReference",
|
|
25
|
+
21: "table",
|
|
26
|
+
22: "tableRow",
|
|
27
|
+
23: "tableCell",
|
|
28
|
+
24: "delete",
|
|
29
|
+
25: "yaml",
|
|
30
|
+
26: "toml",
|
|
31
|
+
27: "math",
|
|
32
|
+
28: "inlineMath",
|
|
33
|
+
30: "containerDirective",
|
|
34
|
+
31: "leafDirective",
|
|
35
|
+
32: "textDirective",
|
|
36
|
+
33: "superscript",
|
|
37
|
+
34: "subscript",
|
|
38
|
+
100: "mdxJsxFlowElement",
|
|
39
|
+
101: "mdxJsxTextElement",
|
|
40
|
+
102: "mdxFlowExpression",
|
|
41
|
+
103: "mdxTextExpression",
|
|
42
|
+
104: "mdxjsEsm",
|
|
43
|
+
};
|
|
44
|
+
/** Canonical AST name -> node-type tag. */
|
|
45
|
+
export const NAME_TO_TYPE = {
|
|
46
|
+
root: 0,
|
|
47
|
+
paragraph: 1,
|
|
48
|
+
heading: 2,
|
|
49
|
+
thematicBreak: 3,
|
|
50
|
+
blockquote: 4,
|
|
51
|
+
list: 5,
|
|
52
|
+
listItem: 6,
|
|
53
|
+
html: 7,
|
|
54
|
+
code: 8,
|
|
55
|
+
definition: 9,
|
|
56
|
+
text: 10,
|
|
57
|
+
emphasis: 11,
|
|
58
|
+
strong: 12,
|
|
59
|
+
inlineCode: 13,
|
|
60
|
+
break: 14,
|
|
61
|
+
link: 15,
|
|
62
|
+
image: 16,
|
|
63
|
+
linkReference: 17,
|
|
64
|
+
imageReference: 18,
|
|
65
|
+
footnoteDefinition: 19,
|
|
66
|
+
footnoteReference: 20,
|
|
67
|
+
table: 21,
|
|
68
|
+
tableRow: 22,
|
|
69
|
+
tableCell: 23,
|
|
70
|
+
delete: 24,
|
|
71
|
+
yaml: 25,
|
|
72
|
+
toml: 26,
|
|
73
|
+
math: 27,
|
|
74
|
+
inlineMath: 28,
|
|
75
|
+
containerDirective: 30,
|
|
76
|
+
leafDirective: 31,
|
|
77
|
+
textDirective: 32,
|
|
78
|
+
superscript: 33,
|
|
79
|
+
subscript: 34,
|
|
80
|
+
mdxJsxFlowElement: 100,
|
|
81
|
+
mdxJsxTextElement: 101,
|
|
82
|
+
mdxFlowExpression: 102,
|
|
83
|
+
mdxTextExpression: 103,
|
|
84
|
+
mdxjsEsm: 104,
|
|
85
|
+
};
|
|
86
|
+
/** Node-type tag by Rust enum variant name. */
|
|
87
|
+
export const NodeType = Object.freeze({
|
|
88
|
+
Root: 0,
|
|
89
|
+
Paragraph: 1,
|
|
90
|
+
Heading: 2,
|
|
91
|
+
ThematicBreak: 3,
|
|
92
|
+
Blockquote: 4,
|
|
93
|
+
List: 5,
|
|
94
|
+
ListItem: 6,
|
|
95
|
+
Html: 7,
|
|
96
|
+
Code: 8,
|
|
97
|
+
Definition: 9,
|
|
98
|
+
Text: 10,
|
|
99
|
+
Emphasis: 11,
|
|
100
|
+
Strong: 12,
|
|
101
|
+
InlineCode: 13,
|
|
102
|
+
Break: 14,
|
|
103
|
+
Link: 15,
|
|
104
|
+
Image: 16,
|
|
105
|
+
LinkReference: 17,
|
|
106
|
+
ImageReference: 18,
|
|
107
|
+
FootnoteDefinition: 19,
|
|
108
|
+
FootnoteReference: 20,
|
|
109
|
+
Table: 21,
|
|
110
|
+
TableRow: 22,
|
|
111
|
+
TableCell: 23,
|
|
112
|
+
Delete: 24,
|
|
113
|
+
Yaml: 25,
|
|
114
|
+
Toml: 26,
|
|
115
|
+
Math: 27,
|
|
116
|
+
InlineMath: 28,
|
|
117
|
+
ContainerDirective: 30,
|
|
118
|
+
LeafDirective: 31,
|
|
119
|
+
TextDirective: 32,
|
|
120
|
+
Superscript: 33,
|
|
121
|
+
Subscript: 34,
|
|
122
|
+
MdxJsxFlowElement: 100,
|
|
123
|
+
MdxJsxTextElement: 101,
|
|
124
|
+
MdxFlowExpression: 102,
|
|
125
|
+
MdxTextExpression: 103,
|
|
126
|
+
MdxjsEsm: 104,
|
|
127
|
+
});
|
|
128
|
+
/** Node-type tag -> Rust variant name (`typeName` diagnostics). */
|
|
129
|
+
export const NodeTypeName = {
|
|
130
|
+
0: "Root",
|
|
131
|
+
1: "Paragraph",
|
|
132
|
+
2: "Heading",
|
|
133
|
+
3: "ThematicBreak",
|
|
134
|
+
4: "Blockquote",
|
|
135
|
+
5: "List",
|
|
136
|
+
6: "ListItem",
|
|
137
|
+
7: "Html",
|
|
138
|
+
8: "Code",
|
|
139
|
+
9: "Definition",
|
|
140
|
+
10: "Text",
|
|
141
|
+
11: "Emphasis",
|
|
142
|
+
12: "Strong",
|
|
143
|
+
13: "InlineCode",
|
|
144
|
+
14: "Break",
|
|
145
|
+
15: "Link",
|
|
146
|
+
16: "Image",
|
|
147
|
+
17: "LinkReference",
|
|
148
|
+
18: "ImageReference",
|
|
149
|
+
19: "FootnoteDefinition",
|
|
150
|
+
20: "FootnoteReference",
|
|
151
|
+
21: "Table",
|
|
152
|
+
22: "TableRow",
|
|
153
|
+
23: "TableCell",
|
|
154
|
+
24: "Delete",
|
|
155
|
+
25: "Yaml",
|
|
156
|
+
26: "Toml",
|
|
157
|
+
27: "Math",
|
|
158
|
+
28: "InlineMath",
|
|
159
|
+
30: "ContainerDirective",
|
|
160
|
+
31: "LeafDirective",
|
|
161
|
+
32: "TextDirective",
|
|
162
|
+
33: "Superscript",
|
|
163
|
+
34: "Subscript",
|
|
164
|
+
100: "MdxJsxFlowElement",
|
|
165
|
+
101: "MdxJsxTextElement",
|
|
166
|
+
102: "MdxFlowExpression",
|
|
167
|
+
103: "MdxTextExpression",
|
|
168
|
+
104: "MdxjsEsm",
|
|
169
|
+
};
|
|
170
|
+
/** Names a plugin can subscribe to (every node except `root`). */
|
|
171
|
+
export const VISITOR_KEYS = new Set([
|
|
172
|
+
"paragraph",
|
|
173
|
+
"heading",
|
|
174
|
+
"thematicBreak",
|
|
175
|
+
"blockquote",
|
|
176
|
+
"list",
|
|
177
|
+
"listItem",
|
|
178
|
+
"html",
|
|
179
|
+
"code",
|
|
180
|
+
"definition",
|
|
181
|
+
"text",
|
|
182
|
+
"emphasis",
|
|
183
|
+
"strong",
|
|
184
|
+
"inlineCode",
|
|
185
|
+
"break",
|
|
186
|
+
"link",
|
|
187
|
+
"image",
|
|
188
|
+
"linkReference",
|
|
189
|
+
"imageReference",
|
|
190
|
+
"footnoteDefinition",
|
|
191
|
+
"footnoteReference",
|
|
192
|
+
"table",
|
|
193
|
+
"tableRow",
|
|
194
|
+
"tableCell",
|
|
195
|
+
"delete",
|
|
196
|
+
"yaml",
|
|
197
|
+
"toml",
|
|
198
|
+
"math",
|
|
199
|
+
"inlineMath",
|
|
200
|
+
"containerDirective",
|
|
201
|
+
"leafDirective",
|
|
202
|
+
"textDirective",
|
|
203
|
+
"superscript",
|
|
204
|
+
"subscript",
|
|
205
|
+
"mdxJsxFlowElement",
|
|
206
|
+
"mdxJsxTextElement",
|
|
207
|
+
"mdxFlowExpression",
|
|
208
|
+
"mdxTextExpression",
|
|
209
|
+
"mdxjsEsm",
|
|
210
|
+
]);
|
|
211
|
+
/** Name -> tag for the types the op-stream can encode; one lookup gates AND
|
|
212
|
+
* resolves the emit-path tag. Excluded names (see `*_OPSTREAM_EXCLUDED` in
|
|
213
|
+
* schema.rs) have no encoding — the visitor throws for them. */
|
|
214
|
+
export const MDAST_OPSTREAM_TYPES = {
|
|
215
|
+
paragraph: 1,
|
|
216
|
+
heading: 2,
|
|
217
|
+
thematicBreak: 3,
|
|
218
|
+
blockquote: 4,
|
|
219
|
+
list: 5,
|
|
220
|
+
listItem: 6,
|
|
221
|
+
html: 7,
|
|
222
|
+
code: 8,
|
|
223
|
+
definition: 9,
|
|
224
|
+
text: 10,
|
|
225
|
+
emphasis: 11,
|
|
226
|
+
strong: 12,
|
|
227
|
+
inlineCode: 13,
|
|
228
|
+
break: 14,
|
|
229
|
+
link: 15,
|
|
230
|
+
image: 16,
|
|
231
|
+
linkReference: 17,
|
|
232
|
+
imageReference: 18,
|
|
233
|
+
footnoteDefinition: 19,
|
|
234
|
+
footnoteReference: 20,
|
|
235
|
+
table: 21,
|
|
236
|
+
tableRow: 22,
|
|
237
|
+
tableCell: 23,
|
|
238
|
+
delete: 24,
|
|
239
|
+
yaml: 25,
|
|
240
|
+
toml: 26,
|
|
241
|
+
math: 27,
|
|
242
|
+
inlineMath: 28,
|
|
243
|
+
containerDirective: 30,
|
|
244
|
+
leafDirective: 31,
|
|
245
|
+
textDirective: 32,
|
|
246
|
+
superscript: 33,
|
|
247
|
+
subscript: 34,
|
|
248
|
+
mdxJsxFlowElement: 100,
|
|
249
|
+
mdxJsxTextElement: 101,
|
|
250
|
+
mdxFlowExpression: 102,
|
|
251
|
+
mdxTextExpression: 103,
|
|
252
|
+
mdxjsEsm: 104,
|
|
253
|
+
};
|
|
254
|
+
/** Names of the variable-length `custom` node types (hand-written or
|
|
255
|
+
* `Tail`-generated codec). The op-stream round-trip oracle asserts it covers
|
|
256
|
+
* every one, so a forgotten or drifted encode/decode arm fails loudly. */
|
|
257
|
+
export const MDAST_CUSTOM_TYPES = [
|
|
258
|
+
"list",
|
|
259
|
+
"listItem",
|
|
260
|
+
"table",
|
|
261
|
+
"containerDirective",
|
|
262
|
+
"leafDirective",
|
|
263
|
+
"textDirective",
|
|
264
|
+
"mdxJsxFlowElement",
|
|
265
|
+
"mdxJsxTextElement",
|
|
266
|
+
];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { Root } from "mdast";
|
|
1
2
|
import type { MdastNode } from "../types.js";
|
|
2
3
|
import type { MdastReader } from "./mdast-reader.js";
|
|
3
|
-
export declare const
|
|
4
|
+
export declare const LEAF_TYPES: ReadonlySet<number>;
|
|
4
5
|
/**
|
|
5
6
|
* Materialize a single MDAST node from a binary buffer as a lazy JS object.
|
|
6
7
|
*/
|
|
7
8
|
export declare function materializeNode(reader: MdastReader, nodeId: number): MdastNode;
|
|
8
9
|
/** Materialize the full tree from root (nodeId=0). */
|
|
9
|
-
export declare function materializeMdastTree(reader: MdastReader):
|
|
10
|
+
export declare function materializeMdastTree(reader: MdastReader): Root;
|
|
@@ -1,86 +1,21 @@
|
|
|
1
1
|
import { lazyProp, lazyGroup } from "../lazy-props.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
1: "paragraph",
|
|
5
|
-
2: "heading",
|
|
6
|
-
3: "thematicBreak",
|
|
7
|
-
4: "blockquote",
|
|
8
|
-
5: "list",
|
|
9
|
-
6: "listItem",
|
|
10
|
-
7: "html",
|
|
11
|
-
8: "code",
|
|
12
|
-
9: "definition",
|
|
13
|
-
10: "text",
|
|
14
|
-
11: "emphasis",
|
|
15
|
-
12: "strong",
|
|
16
|
-
13: "inlineCode",
|
|
17
|
-
14: "break",
|
|
18
|
-
15: "link",
|
|
19
|
-
16: "image",
|
|
20
|
-
17: "linkReference",
|
|
21
|
-
18: "imageReference",
|
|
22
|
-
19: "footnoteDefinition",
|
|
23
|
-
20: "footnoteReference",
|
|
24
|
-
21: "table",
|
|
25
|
-
22: "tableRow",
|
|
26
|
-
23: "tableCell",
|
|
27
|
-
24: "delete",
|
|
28
|
-
25: "yaml",
|
|
29
|
-
26: "toml",
|
|
30
|
-
27: "math",
|
|
31
|
-
28: "inlineMath",
|
|
32
|
-
30: "containerDirective",
|
|
33
|
-
31: "leafDirective",
|
|
34
|
-
32: "textDirective",
|
|
35
|
-
100: "mdxJsxFlowElement",
|
|
36
|
-
101: "mdxJsxTextElement",
|
|
37
|
-
102: "mdxFlowExpression",
|
|
38
|
-
103: "mdxTextExpression",
|
|
39
|
-
104: "mdxjsEsm",
|
|
40
|
-
};
|
|
2
|
+
import { TYPE_NAMES } from "./generated/node-types.js";
|
|
3
|
+
import { materializeMdastFields } from "./generated/layout.js";
|
|
41
4
|
// Leaf node types that do NOT have children.
|
|
42
5
|
// Type 9 = `definition`; type 18 = `imageReference` — leaves per mdast spec
|
|
43
6
|
// (imageReference carries `alt` as a string, not children).
|
|
44
|
-
const LEAF_TYPES = new Set([
|
|
7
|
+
export const LEAF_TYPES = new Set([
|
|
8
|
+
9, 10, 13, 7, 8, 14, 3, 16, 18, 20, 25, 26, 27, 28, 102, 103, 104,
|
|
9
|
+
]);
|
|
45
10
|
/**
|
|
46
11
|
* Add type-specific lazy properties to a node object.
|
|
47
12
|
*/
|
|
48
13
|
function addTypeProperties(node, reader, nodeId, nodeType) {
|
|
14
|
+
// Fixed-field types materialize from the generated layout table; the rest
|
|
15
|
+
// (variable-length / cross-field) stay in the hand-written switch.
|
|
16
|
+
if (materializeMdastFields(reader, node, nodeId, nodeType))
|
|
17
|
+
return;
|
|
49
18
|
switch (nodeType) {
|
|
50
|
-
case 2: // heading
|
|
51
|
-
Object.defineProperties(node, {
|
|
52
|
-
depth: lazyProp("depth", () => reader.getHeadingDepth(nodeId)),
|
|
53
|
-
});
|
|
54
|
-
break;
|
|
55
|
-
case 10: // text
|
|
56
|
-
case 13: // inlineCode
|
|
57
|
-
case 7: // html
|
|
58
|
-
case 25: // yaml
|
|
59
|
-
case 26: // toml
|
|
60
|
-
Object.defineProperties(node, {
|
|
61
|
-
value: lazyProp("value", () => reader.getTextValue(nodeId)),
|
|
62
|
-
});
|
|
63
|
-
break;
|
|
64
|
-
case 8: // code
|
|
65
|
-
lazyGroup(node, ["lang", "meta", "value"], () => reader.getCodeData(nodeId));
|
|
66
|
-
break;
|
|
67
|
-
case 27: // math
|
|
68
|
-
lazyGroup(node, ["meta", "value"], () => reader.getMathData(nodeId));
|
|
69
|
-
break;
|
|
70
|
-
case 28: // inlineMath
|
|
71
|
-
Object.defineProperties(node, {
|
|
72
|
-
value: lazyProp("value", () => reader.getMathData(nodeId).value),
|
|
73
|
-
});
|
|
74
|
-
break;
|
|
75
|
-
case 15: // link
|
|
76
|
-
lazyGroup(node, ["url", "title"], () => reader.getLinkData(nodeId));
|
|
77
|
-
break;
|
|
78
|
-
case 9: // definition
|
|
79
|
-
lazyGroup(node, ["url", "title", "identifier", "label"], () => reader.getDefinitionData(nodeId));
|
|
80
|
-
break;
|
|
81
|
-
case 16: // image
|
|
82
|
-
lazyGroup(node, ["url", "alt", "title"], () => reader.getImageData(nodeId));
|
|
83
|
-
break;
|
|
84
19
|
case 5: {
|
|
85
20
|
// list
|
|
86
21
|
const resolveList = () => {
|
|
@@ -93,18 +28,6 @@ function addTypeProperties(node, reader, nodeId, nodeType) {
|
|
|
93
28
|
case 6: // listItem
|
|
94
29
|
lazyGroup(node, ["spread", "checked"], () => reader.getListItemData(nodeId));
|
|
95
30
|
break;
|
|
96
|
-
case 17: // linkReference
|
|
97
|
-
lazyGroup(node, ["identifier", "label", "referenceType"], () => reader.getReferenceData(nodeId));
|
|
98
|
-
break;
|
|
99
|
-
case 20: // footnoteReference — no `referenceType` per mdast spec
|
|
100
|
-
lazyGroup(node, ["identifier", "label"], () => reader.getReferenceData(nodeId));
|
|
101
|
-
break;
|
|
102
|
-
case 18: // imageReference — leaf with alt (remark treats it as a void node)
|
|
103
|
-
lazyGroup(node, ["identifier", "label", "referenceType", "alt"], () => reader.getImageReferenceData(nodeId));
|
|
104
|
-
break;
|
|
105
|
-
case 19: // footnoteDefinition
|
|
106
|
-
lazyGroup(node, ["identifier", "label"], () => reader.getFootnoteDefinitionData(nodeId));
|
|
107
|
-
break;
|
|
108
31
|
case 21: // table
|
|
109
32
|
Object.defineProperties(node, {
|
|
110
33
|
align: lazyProp("align", () => reader.getTableAlign(nodeId)),
|
|
@@ -119,13 +42,6 @@ function addTypeProperties(node, reader, nodeId, nodeType) {
|
|
|
119
42
|
case 101: // mdxJsxTextElement
|
|
120
43
|
lazyGroup(node, ["name", "attributes"], () => reader.getMdxJsxElementData(nodeId));
|
|
121
44
|
break;
|
|
122
|
-
case 102: // mdxFlowExpression
|
|
123
|
-
case 103: // mdxTextExpression
|
|
124
|
-
case 104: // mdxjsEsm
|
|
125
|
-
Object.defineProperties(node, {
|
|
126
|
-
value: lazyProp("value", () => reader.getExpressionValue(nodeId)),
|
|
127
|
-
});
|
|
128
|
-
break;
|
|
129
45
|
// Nodes with no type-specific props:
|
|
130
46
|
// root(0), paragraph(1), thematicBreak(3), blockquote(4),
|
|
131
47
|
// emphasis(11), strong(12), break(14), tableRow(22), tableCell(23), delete(24)
|
|
@@ -1,44 +1,5 @@
|
|
|
1
1
|
import type { MdastNodeRaw, BufferHeader, StringRefRaw, MdxJsxAttributeUnion } from "../types.js";
|
|
2
|
-
export
|
|
3
|
-
readonly Root: 0;
|
|
4
|
-
readonly Paragraph: 1;
|
|
5
|
-
readonly Heading: 2;
|
|
6
|
-
readonly ThematicBreak: 3;
|
|
7
|
-
readonly Blockquote: 4;
|
|
8
|
-
readonly List: 5;
|
|
9
|
-
readonly ListItem: 6;
|
|
10
|
-
readonly Html: 7;
|
|
11
|
-
readonly Code: 8;
|
|
12
|
-
readonly Definition: 9;
|
|
13
|
-
readonly Text: 10;
|
|
14
|
-
readonly Emphasis: 11;
|
|
15
|
-
readonly Strong: 12;
|
|
16
|
-
readonly InlineCode: 13;
|
|
17
|
-
readonly Break: 14;
|
|
18
|
-
readonly Link: 15;
|
|
19
|
-
readonly Image: 16;
|
|
20
|
-
readonly LinkReference: 17;
|
|
21
|
-
readonly ImageReference: 18;
|
|
22
|
-
readonly FootnoteDefinition: 19;
|
|
23
|
-
readonly FootnoteReference: 20;
|
|
24
|
-
readonly Table: 21;
|
|
25
|
-
readonly TableRow: 22;
|
|
26
|
-
readonly TableCell: 23;
|
|
27
|
-
readonly Delete: 24;
|
|
28
|
-
readonly Yaml: 25;
|
|
29
|
-
readonly Toml: 26;
|
|
30
|
-
readonly Math: 27;
|
|
31
|
-
readonly InlineMath: 28;
|
|
32
|
-
readonly ContainerDirective: 30;
|
|
33
|
-
readonly LeafDirective: 31;
|
|
34
|
-
readonly TextDirective: 32;
|
|
35
|
-
readonly MdxJsxFlowElement: 100;
|
|
36
|
-
readonly MdxJsxTextElement: 101;
|
|
37
|
-
readonly MdxFlowExpression: 102;
|
|
38
|
-
readonly MdxTextExpression: 103;
|
|
39
|
-
readonly MdxjsEsm: 104;
|
|
40
|
-
}>;
|
|
41
|
-
export declare const NodeTypeName: Record<number, string>;
|
|
2
|
+
export { NodeType, NodeTypeName } from "./generated/node-types.js";
|
|
42
3
|
export declare class MdastReader {
|
|
43
4
|
#private;
|
|
44
5
|
constructor(buffer: ArrayBuffer | Uint8Array);
|
|
@@ -53,63 +14,19 @@ export declare class MdastReader {
|
|
|
53
14
|
getNode(nodeId: number): MdastNodeRaw;
|
|
54
15
|
/** Fast path: read only the type byte for a node. */
|
|
55
16
|
getNodeType(nodeId: number): number;
|
|
17
|
+
/** Fast path: read only the parent id for a node (0xffffffff at the root). */
|
|
18
|
+
getParentId(nodeId: number): number;
|
|
56
19
|
getChildIds(nodeId: number): number[];
|
|
57
20
|
/** Push child node IDs directly onto a stack array (reverse order for depth-first). */
|
|
58
21
|
pushChildIds(nodeId: number, stack: number[]): void;
|
|
59
22
|
getTypeData(nodeId: number): Uint8Array;
|
|
60
23
|
/** Read a StringRef (offset: u32 LE, len: u32 LE) from type data. */
|
|
61
24
|
readStringRef(typeData: Uint8Array, byteOffset?: number): StringRefRaw;
|
|
62
|
-
/** HeadingData: depth u8 @ 0. */
|
|
63
|
-
getHeadingDepth(nodeId: number): number;
|
|
64
25
|
/**
|
|
65
|
-
* StringRef value. Valid for Text, InlineCode, Html, Yaml, Toml
|
|
26
|
+
* StringRef value. Valid for Text, InlineCode, Html, Yaml, Toml nodes.
|
|
66
27
|
* These store a single StringRef as their type data.
|
|
67
28
|
*/
|
|
68
29
|
getTextValue(nodeId: number): string;
|
|
69
|
-
/**
|
|
70
|
-
* LinkData: url(0..8), title(8..16).
|
|
71
|
-
* Valid for Link nodes.
|
|
72
|
-
*/
|
|
73
|
-
getLinkData(nodeId: number): {
|
|
74
|
-
url: string;
|
|
75
|
-
title: string | null;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* ImageData: url(0..8), alt(8..16), title(16..24).
|
|
79
|
-
* Valid for Image nodes.
|
|
80
|
-
*/
|
|
81
|
-
getImageData(nodeId: number): {
|
|
82
|
-
url: string;
|
|
83
|
-
alt: string;
|
|
84
|
-
title: string | null;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* CodeData #[repr(C)]: lang(0..8), meta(8..16), value(16..24), fence_char(24), _pad(25..28).
|
|
88
|
-
* Valid for Code nodes.
|
|
89
|
-
*/
|
|
90
|
-
getCodeData(nodeId: number): {
|
|
91
|
-
lang: string | null;
|
|
92
|
-
meta: string | null;
|
|
93
|
-
value: string;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* MathData #[repr(C)]: meta(0..8), value(8..16).
|
|
97
|
-
* Valid for Math nodes.
|
|
98
|
-
*/
|
|
99
|
-
getMathData(nodeId: number): {
|
|
100
|
-
meta: string | null;
|
|
101
|
-
value: string;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* DefinitionData #[repr(C)]: url(0..8), title(8..16), identifier(16..24), label(24..32).
|
|
105
|
-
* Valid for Definition nodes.
|
|
106
|
-
*/
|
|
107
|
-
getDefinitionData(nodeId: number): {
|
|
108
|
-
url: string;
|
|
109
|
-
title: string | null;
|
|
110
|
-
identifier: string;
|
|
111
|
-
label: string;
|
|
112
|
-
};
|
|
113
30
|
/**
|
|
114
31
|
* ListData #[repr(C)]: start(0..4), ordered(4), spread(5), _pad(6..8).
|
|
115
32
|
* Valid for List nodes.
|
|
@@ -127,34 +44,6 @@ export declare class MdastReader {
|
|
|
127
44
|
checked: boolean | null;
|
|
128
45
|
spread: boolean;
|
|
129
46
|
};
|
|
130
|
-
/**
|
|
131
|
-
* ReferenceData #[repr(C)]: identifier(0..8), label(8..16), reference_kind(16), _pad(17..20).
|
|
132
|
-
* referenceKind: 0=shortcut, 1=collapsed, 2=full.
|
|
133
|
-
* Valid for LinkReference, ImageReference, FootnoteReference nodes.
|
|
134
|
-
*/
|
|
135
|
-
getReferenceData(nodeId: number): {
|
|
136
|
-
identifier: string;
|
|
137
|
-
label: string;
|
|
138
|
-
referenceType: string;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* ImageReference layout: 20-byte ReferenceData header + 8-byte alt StringRef.
|
|
142
|
-
* Parser-emitted image references carry alt inline; plugin-created ones
|
|
143
|
-
* may lack this suffix, in which case `alt` is empty.
|
|
144
|
-
*/
|
|
145
|
-
getImageReferenceData(nodeId: number): {
|
|
146
|
-
identifier: string;
|
|
147
|
-
label: string;
|
|
148
|
-
referenceType: string;
|
|
149
|
-
alt: string;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* FootnoteDefinitionData #[repr(C)]: identifier(0..8), label(8..16).
|
|
153
|
-
*/
|
|
154
|
-
getFootnoteDefinitionData(nodeId: number): {
|
|
155
|
-
identifier: string;
|
|
156
|
-
label: string;
|
|
157
|
-
};
|
|
158
47
|
/**
|
|
159
48
|
* TableData #[repr(C)]: align_count(0..4), then align_count bytes.
|
|
160
49
|
* Alignment bytes: 0=none, 1=left, 2=right, 3=center.
|
|
@@ -188,11 +77,6 @@ export declare class MdastReader {
|
|
|
188
77
|
name: string;
|
|
189
78
|
attributes: Record<string, string>;
|
|
190
79
|
};
|
|
191
|
-
/**
|
|
192
|
-
* ExpressionData #[repr(C)]: value StringRef (0..8).
|
|
193
|
-
* Valid for MdxFlowExpression, MdxTextExpression, MdxjsEsm.
|
|
194
|
-
*/
|
|
195
|
-
getExpressionValue(nodeId: number): string;
|
|
196
80
|
/**
|
|
197
81
|
* Walk the tree depth-first. Return false from visitor to skip children.
|
|
198
82
|
*/
|