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 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
- ## Documentation
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
- MIT
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 "../satteri_napi.wasi-browser.js";
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";
@@ -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 "../satteri_napi.wasi-browser.js";
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 source_len: 36;
34
- readonly source_offset: 40;
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
  };
@@ -34,8 +34,8 @@ export const HEADER = {
34
34
  children_offset: 24,
35
35
  type_data_len: 28,
36
36
  type_data_offset: 32,
37
- source_len: 36,
38
- source_offset: 40,
37
+ string_pool_len: 36,
38
+ string_pool_offset: 40,
39
39
  node_data_count: 44,
40
40
  node_data_offset: 48,
41
41
  };
@@ -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
- /** Get the full source string (string pool). */
33
- getSource(): string;
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. */
@@ -19,7 +19,7 @@ export class HastReader {
19
19
  #view;
20
20
  #header;
21
21
  #textDecoder;
22
- #sourceCache = null;
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
- sourceLen: v.getUint32(HEADER.source_len, true),
53
- sourceOffset: v.getUint32(HEADER.source_offset, true),
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
- /** Get the full source string (string pool). */
91
- getSource() {
92
- if (this.#sourceCache === null) {
93
- const { sourceOffset, sourceLen } = this.#header;
94
- const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + sourceOffset, sourceLen);
95
- this.#sourceCache = this.#textDecoder.decode(bytes);
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.#sourceCache;
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 { sourceOffset } = this.#header;
104
- const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + sourceOffset + offset, len);
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
- getSource(): string;
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
- #sourceCache = null;
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
- sourceLen: v.getUint32(HEADER.source_len, true),
42
- sourceOffset: v.getUint32(HEADER.source_offset, true),
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
- getSource() {
77
- if (this.#sourceCache === null) {
78
- const { sourceOffset, sourceLen } = this.#header;
79
- const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + sourceOffset, sourceLen);
80
- this.#sourceCache = this.#textDecoder.decode(bytes);
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.#sourceCache;
84
+ return this.#stringPoolCache;
83
85
  }
84
86
  getString(offset, len) {
85
87
  if (len === 0)
86
88
  return "";
87
- const { sourceOffset } = this.#header;
88
- const bytes = new Uint8Array(this.#view.buffer, this.#view.byteOffset + sourceOffset + offset, len);
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
- sourceLen: number;
113
- sourceOffset: number;
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",
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.3",
88
- "@bruits/satteri-linux-arm64-gnu": "0.9.3",
89
- "@bruits/satteri-linux-x64-musl": "0.9.3",
90
- "@bruits/satteri-linux-arm64-musl": "0.9.3",
91
- "@bruits/satteri-darwin-x64": "0.9.3",
92
- "@bruits/satteri-darwin-arm64": "0.9.3",
93
- "@bruits/satteri-win32-x64-msvc": "0.9.3",
94
- "@bruits/satteri-win32-arm64-msvc": "0.9.3",
95
- "@bruits/satteri-wasm32-wasi": "0.9.3"
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",