satteri 0.9.3 → 0.9.4
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 +4 -12
- package/dist/binding.browser.d.ts +1 -1
- package/dist/binding.browser.js +1 -1
- package/dist/generated/arena-layout.d.ts +2 -2
- package/dist/generated/arena-layout.js +2 -2
- package/dist/hast/hast-reader.d.ts +3 -2
- package/dist/hast/hast-reader.js +13 -12
- package/dist/index.d.ts +1 -1
- package/dist/mdast/mdast-reader.d.ts +3 -1
- package/dist/mdast/mdast-reader.js +13 -11
- package/dist/types.d.ts +2 -2
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Native-enhanced Markdown parsing and processing for JavaScript. Parse and compile in Rust, create flexible plugins in JavaScript.
|
|
4
4
|
|
|
5
|
+
Check out the [documentation](https://satteri.bruits.org/docs/) for [installation instructions](https://satteri.bruits.org/docs/installation/), the [API reference](https://satteri.bruits.org/docs/entry-points/), and [usage examples](https://satteri.bruits.org/docs/quick-start/), try it online on the [playground](https://satteri.bruits.org/playground), or join us on [Discord](https://discord.com/invite/84pd4QtmzA)!
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```sh
|
|
@@ -51,16 +53,6 @@ const { html } = markdownToHtml("Use `let` instead of `var`.", {
|
|
|
51
53
|
|
|
52
54
|
If you're familiar with the unified ecosystem, mdast and hast plugins are similar to remark and rehype plugins, respectively, reusing the same AST shapes.
|
|
53
55
|
|
|
54
|
-
##
|
|
55
|
-
|
|
56
|
-
This README covers the basics. The full documentation covers the complete API, the plugin system, every parser feature, and framework integration:
|
|
57
|
-
|
|
58
|
-
- **[Documentation home](https://satteri.bruits.org/docs/)** — start here
|
|
59
|
-
- [Quick start](https://satteri.bruits.org/docs/quick-start/)
|
|
60
|
-
- [Compiling](https://satteri.bruits.org/docs/compile/) — functions, options, and MDX settings
|
|
61
|
-
- [Plugins](https://satteri.bruits.org/docs/plugins/) and [Plugin API](https://satteri.bruits.org/docs/plugin-api/)
|
|
62
|
-
- [Features](https://satteri.bruits.org/docs/features/) — GFM, math, directives, and more
|
|
63
|
-
|
|
64
|
-
## License
|
|
56
|
+
## Development
|
|
65
57
|
|
|
66
|
-
|
|
58
|
+
Refer to [CONTRIBUTING.md](https://github.com/bruits/satteri/blob/main/CONTRIBUTING.md) for development setup and workflow details.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getMdastFrontmatter, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle, } from "../
|
|
1
|
+
export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getMdastFrontmatter, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle, } from "../browser.js";
|
package/dist/binding.browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @ts-nocheck — WASM browser binding has no type declarations
|
|
2
|
-
export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getMdastFrontmatter, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle, } from "../
|
|
2
|
+
export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getMdastFrontmatter, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle, } from "../browser.js";
|
|
@@ -30,8 +30,8 @@ export declare const HEADER: {
|
|
|
30
30
|
readonly children_offset: 24;
|
|
31
31
|
readonly type_data_len: 28;
|
|
32
32
|
readonly type_data_offset: 32;
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
33
|
+
readonly string_pool_len: 36;
|
|
34
|
+
readonly string_pool_offset: 40;
|
|
35
35
|
readonly node_data_count: 44;
|
|
36
36
|
readonly node_data_offset: 48;
|
|
37
37
|
};
|
|
@@ -29,8 +29,9 @@ export declare class HastReader {
|
|
|
29
29
|
getNodeData(nodeId: number): string | null;
|
|
30
30
|
get nodeCount(): number;
|
|
31
31
|
get header(): BufferHeader;
|
|
32
|
-
/**
|
|
33
|
-
|
|
32
|
+
/** The full string pool (original input + interning heap). Not the document
|
|
33
|
+
* source as written; for that, read `ctx.source` from a plugin. */
|
|
34
|
+
getStringPool(): string;
|
|
34
35
|
/** Read a substring from the string pool by byte offset and length. */
|
|
35
36
|
getString(offset: number, len: number): string;
|
|
36
37
|
/** Get position data for a node. */
|
package/dist/hast/hast-reader.js
CHANGED
|
@@ -19,7 +19,7 @@ export class HastReader {
|
|
|
19
19
|
#view;
|
|
20
20
|
#header;
|
|
21
21
|
#textDecoder;
|
|
22
|
-
#
|
|
22
|
+
#stringPoolCache = null;
|
|
23
23
|
constructor(buffer) {
|
|
24
24
|
if (buffer instanceof Uint8Array) {
|
|
25
25
|
this.#view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -49,8 +49,8 @@ export class HastReader {
|
|
|
49
49
|
childrenOffset: v.getUint32(HEADER.children_offset, true),
|
|
50
50
|
typeDataLen: v.getUint32(HEADER.type_data_len, true),
|
|
51
51
|
typeDataOffset: v.getUint32(HEADER.type_data_offset, true),
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
stringPoolLen: v.getUint32(HEADER.string_pool_len, true),
|
|
53
|
+
stringPoolOffset: v.getUint32(HEADER.string_pool_offset, true),
|
|
54
54
|
nodeDataCount: v.getUint32(HEADER.node_data_count, true),
|
|
55
55
|
nodeDataOffset: v.getUint32(HEADER.node_data_offset, true),
|
|
56
56
|
};
|
|
@@ -87,21 +87,22 @@ export class HastReader {
|
|
|
87
87
|
get header() {
|
|
88
88
|
return { ...this.#header };
|
|
89
89
|
}
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
90
|
+
/** The full string pool (original input + interning heap). Not the document
|
|
91
|
+
* source as written; for that, read `ctx.source` from a plugin. */
|
|
92
|
+
getStringPool() {
|
|
93
|
+
if (this.#stringPoolCache === null) {
|
|
94
|
+
const { stringPoolOffset, stringPoolLen } = this.#header;
|
|
95
|
+
const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + stringPoolOffset, stringPoolLen);
|
|
96
|
+
this.#stringPoolCache = this.#textDecoder.decode(bytes);
|
|
96
97
|
}
|
|
97
|
-
return this.#
|
|
98
|
+
return this.#stringPoolCache;
|
|
98
99
|
}
|
|
99
100
|
/** Read a substring from the string pool by byte offset and length. */
|
|
100
101
|
getString(offset, len) {
|
|
101
102
|
if (len === 0)
|
|
102
103
|
return "";
|
|
103
|
-
const {
|
|
104
|
-
const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset +
|
|
104
|
+
const { stringPoolOffset } = this.#header;
|
|
105
|
+
const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + stringPoolOffset + offset, len);
|
|
105
106
|
return this.#textDecoder.decode(bytes);
|
|
106
107
|
}
|
|
107
108
|
/** Get position data for a node. */
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { MdastPluginDefinition, HastPluginDefinition, MdastPluginInput, Has
|
|
|
5
5
|
export type { HastVisitorInstance, HastVisitorContext, HastFilteredVisitor, HastContent, EstreeProgram, } from "./hast/hast-visitor.js";
|
|
6
6
|
export type { MdastNode, HastNode, DataMap, Data, Position, Point, MdxJsxAttributeNode, MdxJsxExpressionAttributeNode, MdxJsxAttributeValueExpressionNode, MdxJsxAttributeUnion, MdxJsxFlowElement, MdxJsxTextElement, MdxFlowExpression, MdxTextExpression, MdxjsEsm, MdxJsxFlowElementHast, MdxJsxTextElementHast, MdxFlowExpressionHast, MdxTextExpressionHast, MdxjsEsmHast, } from "./types.js";
|
|
7
7
|
export { visitMdastHandle, resolveMdastSubscriptions } from "./mdast/mdast-visitor.js";
|
|
8
|
-
export type { MdastPluginInstance, MdastContent } from "./mdast/mdast-visitor.js";
|
|
8
|
+
export type { MdastPluginInstance, MdastVisitorContext, MdastContent, } from "./mdast/mdast-visitor.js";
|
|
9
9
|
export { visitHastHandle, resolveSubscriptions as resolveHastSubscriptions, } from "./hast/hast-visitor.js";
|
|
10
10
|
export { MdastReader } from "./mdast/mdast-reader.js";
|
|
11
11
|
export { materializeMdastTree } from "./mdast/mdast-materializer.js";
|
|
@@ -9,7 +9,9 @@ export declare class MdastReader {
|
|
|
9
9
|
getNodeData(nodeId: number): string | null;
|
|
10
10
|
get nodeCount(): number;
|
|
11
11
|
get header(): BufferHeader;
|
|
12
|
-
|
|
12
|
+
/** The full string pool (original input + interning heap). Not the document
|
|
13
|
+
* source as written; for that, read `ctx.source` from a plugin. */
|
|
14
|
+
getStringPool(): string;
|
|
13
15
|
getString(offset: number, len: number): string;
|
|
14
16
|
getNode(nodeId: number): MdastNodeRaw;
|
|
15
17
|
/** Fast path: read only the type byte for a node. */
|
|
@@ -8,7 +8,7 @@ export class MdastReader {
|
|
|
8
8
|
#view;
|
|
9
9
|
#header;
|
|
10
10
|
#textDecoder;
|
|
11
|
-
#
|
|
11
|
+
#stringPoolCache = null;
|
|
12
12
|
constructor(buffer) {
|
|
13
13
|
if (buffer instanceof Uint8Array) {
|
|
14
14
|
this.#view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -38,8 +38,8 @@ export class MdastReader {
|
|
|
38
38
|
childrenOffset: v.getUint32(HEADER.children_offset, true),
|
|
39
39
|
typeDataLen: v.getUint32(HEADER.type_data_len, true),
|
|
40
40
|
typeDataOffset: v.getUint32(HEADER.type_data_offset, true),
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
stringPoolLen: v.getUint32(HEADER.string_pool_len, true),
|
|
42
|
+
stringPoolOffset: v.getUint32(HEADER.string_pool_offset, true),
|
|
43
43
|
nodeDataCount: v.getUint32(HEADER.node_data_count, true),
|
|
44
44
|
nodeDataOffset: v.getUint32(HEADER.node_data_offset, true),
|
|
45
45
|
};
|
|
@@ -73,19 +73,21 @@ export class MdastReader {
|
|
|
73
73
|
get header() {
|
|
74
74
|
return { ...this.#header };
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
/** The full string pool (original input + interning heap). Not the document
|
|
77
|
+
* source as written; for that, read `ctx.source` from a plugin. */
|
|
78
|
+
getStringPool() {
|
|
79
|
+
if (this.#stringPoolCache === null) {
|
|
80
|
+
const { stringPoolOffset, stringPoolLen } = this.#header;
|
|
81
|
+
const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + stringPoolOffset, stringPoolLen);
|
|
82
|
+
this.#stringPoolCache = this.#textDecoder.decode(bytes);
|
|
81
83
|
}
|
|
82
|
-
return this.#
|
|
84
|
+
return this.#stringPoolCache;
|
|
83
85
|
}
|
|
84
86
|
getString(offset, len) {
|
|
85
87
|
if (len === 0)
|
|
86
88
|
return "";
|
|
87
|
-
const {
|
|
88
|
-
const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset +
|
|
89
|
+
const { stringPoolOffset } = this.#header;
|
|
90
|
+
const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + stringPoolOffset + offset, len);
|
|
89
91
|
return this.#textDecoder.decode(bytes);
|
|
90
92
|
}
|
|
91
93
|
getNode(nodeId) {
|
package/dist/types.d.ts
CHANGED
|
@@ -109,8 +109,8 @@ export interface BufferHeader {
|
|
|
109
109
|
childrenOffset: number;
|
|
110
110
|
typeDataLen: number;
|
|
111
111
|
typeDataOffset: number;
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
stringPoolLen: number;
|
|
113
|
+
stringPoolOffset: number;
|
|
114
114
|
/** Number of nodes that carry an extra JSON `data` blob. */
|
|
115
115
|
nodeDataCount: number;
|
|
116
116
|
/** Offset of the node-data section: `[id u32][len u32][bytes...]` repeated. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "satteri",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "High-performance Markdown and MDX processing",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -84,15 +84,15 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"optionalDependencies": {
|
|
87
|
-
"@bruits/satteri-linux-x64-gnu": "0.9.
|
|
88
|
-
"@bruits/satteri-linux-arm64-gnu": "0.9.
|
|
89
|
-
"@bruits/satteri-linux-x64-musl": "0.9.
|
|
90
|
-
"@bruits/satteri-linux-arm64-musl": "0.9.
|
|
91
|
-
"@bruits/satteri-darwin-x64": "0.9.
|
|
92
|
-
"@bruits/satteri-darwin-arm64": "0.9.
|
|
93
|
-
"@bruits/satteri-win32-x64-msvc": "0.9.
|
|
94
|
-
"@bruits/satteri-win32-arm64-msvc": "0.9.
|
|
95
|
-
"@bruits/satteri-wasm32-wasi": "0.9.
|
|
87
|
+
"@bruits/satteri-linux-x64-gnu": "0.9.4",
|
|
88
|
+
"@bruits/satteri-linux-arm64-gnu": "0.9.4",
|
|
89
|
+
"@bruits/satteri-linux-x64-musl": "0.9.4",
|
|
90
|
+
"@bruits/satteri-linux-arm64-musl": "0.9.4",
|
|
91
|
+
"@bruits/satteri-darwin-x64": "0.9.4",
|
|
92
|
+
"@bruits/satteri-darwin-arm64": "0.9.4",
|
|
93
|
+
"@bruits/satteri-win32-x64-msvc": "0.9.4",
|
|
94
|
+
"@bruits/satteri-win32-arm64-msvc": "0.9.4",
|
|
95
|
+
"@bruits/satteri-wasm32-wasi": "0.9.4"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
98
|
"build:binary:wasm": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --release --esm --strip --target wasm32-wasip1-threads",
|