satteri 0.3.5 → 0.5.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.
@@ -1 +1 @@
1
- export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, 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 "../satteri_napi.wasi-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, 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 "../satteri_napi.wasi-browser.js";
package/dist/binding.d.ts CHANGED
@@ -1 +1 @@
1
- export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle, } from "../index.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 "../index.js";
package/dist/binding.js CHANGED
@@ -1 +1 @@
1
- export { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle, } from "../index.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 "../index.js";
package/dist/compile.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { MdastPluginDefinition, HastPluginDefinition } from "./plugin.js";
1
+ import type { MdastPluginInput, HastPluginInput } from "./plugin.js";
2
2
  import type { MdastNode, HastNode } from "./types.js";
3
3
  /** Configuration for static subtree collapsing during MDX compilation. */
4
4
  export interface OptimizeStaticConfig {
@@ -45,12 +45,20 @@ export interface Features {
45
45
  smartPunctuation?: boolean | SmartPunctuationOptions;
46
46
  }
47
47
  export interface CompileOptions {
48
- mdastPlugins?: MdastPluginDefinition[];
49
- hastPlugins?: HastPluginDefinition[];
48
+ mdastPlugins?: MdastPluginInput[];
49
+ hastPlugins?: HastPluginInput[];
50
50
  features?: Features;
51
51
  filename?: string;
52
52
  }
53
- export interface MdxCompileOptions extends CompileOptions {
53
+ /**
54
+ * MDX-only compile options.
55
+ *
56
+ * These are the fields specific to MDX compilation, separate from the shared
57
+ * pipeline options in {@link CompileOptions}. Useful for wrappers (Vite/Rollup
58
+ * plugins, framework integrations) that want to expose MDX-specific knobs
59
+ * without re-exposing the shared pipeline fields.
60
+ */
61
+ export interface MdxOnlyOptions {
54
62
  optimizeStatic?: OptimizeStaticConfig;
55
63
  /** Place to import automatic JSX runtimes from (e.g. "react", "preact"). Default: "react". */
56
64
  jsxImportSource?: string;
@@ -78,8 +86,50 @@ export interface MdxCompileOptions extends CompileOptions {
78
86
  */
79
87
  outputFormat?: "program" | "function-body";
80
88
  }
81
- export declare function markdownToHtml(source: string, options?: CompileOptions): string | Promise<string>;
82
- export declare function mdxToJs(source: string, options?: MdxCompileOptions): string | Promise<string>;
89
+ export interface MdxCompileOptions extends CompileOptions, MdxOnlyOptions {
90
+ }
91
+ /** Frontmatter block extracted from the parsed Markdown/MDX source. */
92
+ export interface Frontmatter {
93
+ /** Delimiter syntax used for the block. */
94
+ kind: "yaml" | "toml";
95
+ /** Raw content between the delimiters (`---`/`+++` lines excluded). */
96
+ value: string;
97
+ }
98
+ /** Result of {@link markdownToHtml}. */
99
+ export interface MarkdownToHtmlResult {
100
+ /** Rendered HTML string. */
101
+ html: string;
102
+ /** Frontmatter block at the start of the document, or `null` if none. */
103
+ frontmatter: Frontmatter | null;
104
+ }
105
+ /** Result of {@link mdxToJs}. */
106
+ export interface MdxToJsResult {
107
+ /** Compiled JavaScript module source. */
108
+ code: string;
109
+ /** Frontmatter block at the start of the document, or `null` if none. */
110
+ frontmatter: Frontmatter | null;
111
+ }
112
+ type AnyFn = (...args: any[]) => unknown;
113
+ type ReturnsPromise<F> = F extends AnyFn ? Extract<ReturnType<F>, Promise<unknown>> extends never ? false : true : false;
114
+ type FieldIsAsync<V> = V extends AnyFn ? ReturnsPromise<V> : V extends {
115
+ visit: infer F;
116
+ } ? ReturnsPromise<F> : V extends ReadonlyArray<infer Item> ? Item extends {
117
+ visit: infer F;
118
+ } ? ReturnsPromise<F> : false : false;
119
+ type AnyVisitorAsync<P> = {
120
+ [K in keyof P]-?: FieldIsAsync<NonNullable<P[K]>>;
121
+ }[keyof P];
122
+ type IsPluginAsync<P> = true extends AnyVisitorAsync<P> ? true : false;
123
+ type ResolveInput<P> = P extends () => infer D ? D : P;
124
+ type AnyInputAsync<Ps> = Ps extends ReadonlyArray<infer P> ? true extends IsPluginAsync<ResolveInput<P>> ? true : false : false;
125
+ type OptionsAsync<O> = (O extends {
126
+ mdastPlugins: infer Ps;
127
+ } ? AnyInputAsync<Ps> : false) extends true ? true : (O extends {
128
+ hastPlugins: infer Ps;
129
+ } ? AnyInputAsync<Ps> : false) extends true ? true : false;
130
+ type ResultFor<O, R> = OptionsAsync<O> extends true ? Promise<R> : R;
131
+ export declare function markdownToHtml<O extends CompileOptions>(source: string, options?: O): ResultFor<O, MarkdownToHtmlResult>;
132
+ export declare function mdxToJs<O extends MdxCompileOptions>(source: string, options?: O): ResultFor<O, MdxToJsResult>;
83
133
  export interface EvaluateOptions extends Omit<MdxCompileOptions, "jsx" | "outputFormat"> {
84
134
  Fragment: unknown;
85
135
  jsx: (type: unknown, props: unknown, key?: unknown) => unknown;
@@ -115,3 +165,4 @@ export declare function markdownToHast(source: string, options?: {
115
165
  export declare function mdxToHast(source: string, options?: {
116
166
  features?: Features;
117
167
  }): HastNode;
168
+ export {};
package/dist/compile.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { visitHastHandle, resolveSubscriptions } from "./hast/hast-visitor.js";
2
2
  import { visitMdastHandle, resolveMdastSubscriptions, } from "./mdast/mdast-visitor.js";
3
- import { parseToHtml, compileMdx, createHastHandle, createMdxHastHandle, renderHandle, compileHandle, applyCommandsToHandle, dropHandle, createMdastHandle, createMdxMdastHandle, applyCommandsToMdastHandle, convertMdastToHastHandle, applyCommandsAndConvertToHastHandle, getHandleSource, serializeHandle, } from "#binding";
3
+ import { createHastHandle, createMdxHastHandle, renderHandle, compileHandle, dropHandle, createMdastHandle, createMdxMdastHandle, applyCommandsToMdastHandle, convertMdastToHastHandle, getHandleSource, getMdastFrontmatter, serializeHandle, } from "#binding";
4
4
  import { MdastReader } from "./mdast/mdast-reader.js";
5
5
  import { materializeMdastTree } from "./mdast/mdast-materializer.js";
6
6
  import { HastReader } from "./hast/hast-reader.js";
@@ -41,7 +41,8 @@ function runMdastPluginsOnHandle(handle, plugins, filename) {
41
41
  const runNext = () => {
42
42
  while (i < plugins.length) {
43
43
  const idx = i++;
44
- const plugin = plugins[idx];
44
+ const raw = plugins[idx];
45
+ const plugin = typeof raw === "function" ? raw() : raw;
45
46
  const subs = resolveMdastSubscriptions(plugin);
46
47
  const result = visitMdastHandle(handle, plugin, subs, () => getHandleSource(handle), filename);
47
48
  if (result instanceof Promise) {
@@ -72,8 +73,9 @@ function runHastPluginsOnHandle(handle, plugins, source, filename) {
72
73
  let i = 0;
73
74
  const runNext = () => {
74
75
  while (i < plugins.length) {
75
- const plugin = plugins[i];
76
+ const raw = plugins[i];
76
77
  i++;
78
+ const plugin = typeof raw === "function" ? raw() : raw;
77
79
  const subs = resolveSubscriptions(plugin);
78
80
  const result = visitHastHandle(handle, plugin, subs, source, filename);
79
81
  if (result instanceof Promise) {
@@ -123,52 +125,41 @@ function mdxOptionsToNative(opts) {
123
125
  export function markdownToHtml(source, options = {}) {
124
126
  const { mdastPlugins = [], hastPlugins = [], features, filename = "<unknown>" } = options;
125
127
  const nativeFeatures = featuresToNative(features);
126
- // TODO: When there's no plugins, we shouldn't go through all the steps below, we could just call parseToHtml directly.
127
- // However right now pulldown-cmark's HTML output is super different from our target (unified's). So until that's fixed, we'll do the slower pipeline
128
- const handleResult = createHastHandleFromMdast(source, mdastPlugins, false, filename, nativeFeatures);
129
- const finish = (hastHandle) => {
130
- const asyncResult = runHastPluginsOnHandle(hastHandle, hastPlugins, source, filename);
131
- if (asyncResult instanceof Promise) {
132
- return asyncResult.then(() => {
133
- const html = renderHandle(hastHandle);
134
- dropHandle(hastHandle);
135
- return html;
136
- });
137
- }
138
- const html = renderHandle(hastHandle);
139
- dropHandle(hastHandle);
140
- return html;
128
+ const result = createHastHandleFromMdast(source, mdastPlugins, false, filename, nativeFeatures);
129
+ const render = (h, frontmatter) => {
130
+ const html = renderHandle(h);
131
+ dropHandle(h);
132
+ return { html, frontmatter };
141
133
  };
142
- if (handleResult instanceof Promise) {
143
- return handleResult.then(finish);
144
- }
145
- return finish(handleResult);
134
+ const runHastThenRender = (r) => {
135
+ const hastResult = runHastPluginsOnHandle(r.hastHandle, hastPlugins, source, filename);
136
+ if (hastResult instanceof Promise)
137
+ return hastResult.then(() => render(r.hastHandle, r.frontmatter));
138
+ return render(r.hastHandle, r.frontmatter);
139
+ };
140
+ if (result instanceof Promise)
141
+ return result.then(runHastThenRender);
142
+ return runHastThenRender(result);
146
143
  }
147
144
  export function mdxToJs(source, options = {}) {
148
145
  const { mdastPlugins = [], hastPlugins = [], features, filename = "<unknown>", ...mdxFields } = options;
149
146
  const mdxOptions = mdxOptionsToNative(mdxFields);
150
147
  const nativeFeatures = featuresToNative(features);
151
- if (mdastPlugins.length === 0 && hastPlugins.length === 0) {
152
- return compileMdx(source, mdxOptions, nativeFeatures);
153
- }
154
- const handleResult = createHastHandleFromMdast(source, mdastPlugins, true, filename, nativeFeatures);
155
- const finish = (hastHandle) => {
156
- const asyncResult = runHastPluginsOnHandle(hastHandle, hastPlugins, source, filename);
157
- if (asyncResult instanceof Promise) {
158
- return asyncResult.then(() => {
159
- const js = compileHandle(hastHandle, mdxOptions);
160
- dropHandle(hastHandle);
161
- return js;
162
- });
163
- }
164
- const js = compileHandle(hastHandle, mdxOptions);
165
- dropHandle(hastHandle);
166
- return js;
148
+ const result = createHastHandleFromMdast(source, mdastPlugins, true, filename, nativeFeatures);
149
+ const compile = (h, frontmatter) => {
150
+ const code = compileHandle(h, mdxOptions);
151
+ dropHandle(h);
152
+ return { code, frontmatter };
167
153
  };
168
- if (handleResult instanceof Promise) {
169
- return handleResult.then(finish);
170
- }
171
- return finish(handleResult);
154
+ const runHastThenCompile = (r) => {
155
+ const hastResult = runHastPluginsOnHandle(r.hastHandle, hastPlugins, source, filename);
156
+ if (hastResult instanceof Promise)
157
+ return hastResult.then(() => compile(r.hastHandle, r.frontmatter));
158
+ return compile(r.hastHandle, r.frontmatter);
159
+ };
160
+ if (result instanceof Promise)
161
+ return result.then(runHastThenCompile);
162
+ return runHastThenCompile(result);
172
163
  }
173
164
  /**
174
165
  * Compile and evaluate MDX in one step.
@@ -184,37 +175,44 @@ export function mdxToJs(source, options = {}) {
184
175
  export function evaluate(source, options) {
185
176
  const { Fragment, jsx, jsxs, jsxDEV, useMDXComponents, ...compileOpts } = options;
186
177
  const runtime = { Fragment, jsx, jsxs, jsxDEV, useMDXComponents };
187
- const code = mdxToJs(source, { ...compileOpts, outputFormat: "function-body" });
188
- if (code instanceof Promise) {
189
- return code.then((resolved) => new Function(resolved)(runtime));
178
+ const result = mdxToJs(source, { ...compileOpts, outputFormat: "function-body" });
179
+ if (result instanceof Promise) {
180
+ return result.then((resolved) => new Function(resolved.code)(runtime));
190
181
  }
191
- return new Function(code)(runtime);
182
+ return new Function(result.code)(runtime);
192
183
  }
193
- // Pipeline: parse → mdast plugins → hast conversion → hast plugins
194
- // All arenas stay in Rust. No intermediate buffer copies to JS.
195
- /** Parse + mdast plugins + convert to HAST handle. */
184
+ function readFrontmatter(handle) {
185
+ const raw = getMdastFrontmatter(handle);
186
+ return raw ? { kind: raw.kind === "toml" ? "toml" : "yaml", value: raw.value } : null;
187
+ }
188
+ /** Parse, run mdast plugins, capture frontmatter, then convert to HAST.
189
+ * Frontmatter is read from the post-plugin MDAST so visitor mutations to
190
+ * the yaml/toml node are reflected in the returned value. */
196
191
  function createHastHandleFromMdast(source, mdastPlugins, mdx, filename,
197
192
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
198
193
  nativeFeatures) {
199
- if (mdastPlugins.length === 0) {
200
- return mdx
201
- ? createMdxHastHandle(source, nativeFeatures)
202
- : createHastHandle(source, nativeFeatures);
203
- }
204
194
  const mdastHandle = mdx
205
195
  ? createMdxMdastHandle(source, nativeFeatures)
206
196
  : createMdastHandle(source, nativeFeatures);
197
+ if (mdastPlugins.length === 0) {
198
+ const frontmatter = readFrontmatter(mdastHandle);
199
+ const hastHandle = convertMdastToHastHandle(mdastHandle);
200
+ return { hastHandle, frontmatter };
201
+ }
207
202
  const mdastResult = runMdastPluginsOnHandle(mdastHandle, mdastPlugins, filename);
208
- const convert = (r) => {
203
+ // Splits the previous fused apply+convert call so we can read frontmatter
204
+ // off the mutated MDAST handle before the conversion consumes it.
205
+ const finalize = (r) => {
209
206
  if (r.pendingCommands) {
210
- return applyCommandsAndConvertToHastHandle(r.handle, r.pendingCommands);
207
+ applyCommandsToMdastHandle(r.handle, r.pendingCommands);
211
208
  }
212
- return convertMdastToHastHandle(r.handle);
209
+ const frontmatter = readFrontmatter(r.handle);
210
+ const hastHandle = convertMdastToHastHandle(r.handle);
211
+ return { hastHandle, frontmatter };
213
212
  };
214
- if (mdastResult instanceof Promise) {
215
- return mdastResult.then(convert);
216
- }
217
- return convert(mdastResult);
213
+ if (mdastResult instanceof Promise)
214
+ return mdastResult.then(finalize);
215
+ return finalize(mdastResult);
218
216
  }
219
217
  // Step-by-step API: individual pipeline stages with materialized trees
220
218
  /** Parse Markdown source into a materialized mdast tree. */
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { markdownToHtml, mdxToJs, evaluate, markdownToMdast, mdxToMdast, markdownToHast, mdxToHast, } from "./compile.js";
2
- export type { CompileOptions, MdxCompileOptions, EvaluateOptions, OptimizeStaticConfig, Features, SmartPunctuationOptions, } from "./compile.js";
2
+ export type { CompileOptions, MdxCompileOptions, MdxOnlyOptions, EvaluateOptions, OptimizeStaticConfig, Features, SmartPunctuationOptions, Frontmatter, MarkdownToHtmlResult, MdxToJsResult, } from "./compile.js";
3
3
  export { defineMdastPlugin, defineHastPlugin } from "./plugin.js";
4
- export type { MdastPluginDefinition, HastPluginDefinition } from "./plugin.js";
4
+ export type { MdastPluginDefinition, HastPluginDefinition, MdastPluginInput, HastPluginInput, } from "./plugin.js";
5
5
  export type { HastVisitorInstance, HastVisitorContext, HastFilteredVisitor, EstreeProgram, } from "./hast/hast-visitor.js";
6
6
  export type { MdastNode, HastNode, Position, Point, MdxJsxAttributeNode, MdxJsxExpressionAttributeNode, MdxJsxAttributeValueExpressionNode, MdxJsxAttributeUnion, } from "./types.js";
7
7
  export { visitMdastHandle, resolveMdastSubscriptions } from "./mdast/mdast-visitor.js";
package/dist/plugin.d.ts CHANGED
@@ -6,5 +6,15 @@ export type MdastPluginDefinition = MdastPluginInstance & {
6
6
  export type HastPluginDefinition = HastVisitorInstance & {
7
7
  name: string;
8
8
  };
9
- export declare function defineMdastPlugin(definition: MdastPluginDefinition): MdastPluginDefinition;
10
- export declare function defineHastPlugin(definition: HastPluginDefinition): HastPluginDefinition;
9
+ /**
10
+ * Entry accepted by `mdastPlugins`: a definition reused across documents,
11
+ * or a factory called once per compile so closures reset per document.
12
+ */
13
+ export type MdastPluginInput = MdastPluginDefinition | (() => MdastPluginDefinition);
14
+ /**
15
+ * Entry accepted by `hastPlugins`: a definition reused across documents,
16
+ * or a factory called once per compile so closures reset per document.
17
+ */
18
+ export type HastPluginInput = HastPluginDefinition | (() => HastPluginDefinition);
19
+ export declare function defineMdastPlugin<P extends MdastPluginDefinition>(definition: P): P;
20
+ export declare function defineHastPlugin<P extends HastPluginDefinition>(definition: P): P;
package/dist/plugin.js CHANGED
@@ -1,3 +1,6 @@
1
+ // Generic so the inferred plugin type preserves each visitor's *actual* return
2
+ // type. That lets call sites of `markdownToHtml`/`mdxToJs` distinguish sync
3
+ // plugins from async ones in their conditional return type.
1
4
  export function defineMdastPlugin(definition) {
2
5
  if (!definition.name) {
3
6
  throw new Error("Plugin definition must have a name");
package/index.d.ts CHANGED
@@ -48,6 +48,12 @@ export declare function dropHandle(handle: AnyHandle): void
48
48
  */
49
49
  export declare function getHandleSource(handle: AnyHandle): string
50
50
 
51
+ /**
52
+ * Return the first YAML or TOML frontmatter block in the MDAST arena, if any.
53
+ * Walks the root node's direct children and returns the first yaml/toml literal.
54
+ */
55
+ export declare function getMdastFrontmatter(handle: MdastHandle): JsFrontmatter | null
56
+
51
57
  /**
52
58
  * Read the node_data JSON blob for a node. Returns null if none is set.
53
59
  * Works for both MDAST and HAST handles.
@@ -78,6 +84,14 @@ export interface JsFeatures {
78
84
  smartPunctuationOptions?: JsSmartPunctuationOptions
79
85
  }
80
86
 
87
+ /** Frontmatter extracted from an MDAST arena. */
88
+ export interface JsFrontmatter {
89
+ /** Either `"yaml"` or `"toml"`. */
90
+ kind: string
91
+ /** Raw frontmatter content between the delimiters (no `---`/`+++` lines). */
92
+ value: string
93
+ }
94
+
81
95
  /** MDX compile options passed from JavaScript. */
82
96
  export interface JsMdxOptions {
83
97
  /**
@@ -169,9 +183,9 @@ export declare function parseToHtml(source: string, features?: JsFeatures | unde
169
183
  export declare function renderHandle(handle: HastHandle): string
170
184
 
171
185
  /**
172
- * Serialize a handle's arena to a binary buffer. Works for both MDAST
173
- * (read-only snapshot for the JS visitor) and HAST (fallback path for
174
- * `transformRoot`) — the kind tag is embedded in the buffer header.
186
+ * Serialize a handle's arena to the wire-format buffer JS instantiates a
187
+ * reader from. The kind tag in the header tells the JS side whether to
188
+ * pick `MdastReader` or `HastReader`.
175
189
  */
176
190
  export declare function serializeHandle(handle: AnyHandle): Uint8Array
177
191
 
package/index.js CHANGED
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('@bruits/satteri-android-arm64')
83
83
  const bindingPackageVersion = require('@bruits/satteri-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@bruits/satteri-android-arm-eabi')
99
99
  const bindingPackageVersion = require('@bruits/satteri-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -118,8 +118,8 @@ function requireNative() {
118
118
  try {
119
119
  const binding = require('@bruits/satteri-win32-x64-gnu')
120
120
  const bindingPackageVersion = require('@bruits/satteri-win32-x64-gnu/package.json').version
121
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
123
  }
124
124
  return binding
125
125
  } catch (e) {
@@ -134,8 +134,8 @@ function requireNative() {
134
134
  try {
135
135
  const binding = require('@bruits/satteri-win32-x64-msvc')
136
136
  const bindingPackageVersion = require('@bruits/satteri-win32-x64-msvc/package.json').version
137
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
139
139
  }
140
140
  return binding
141
141
  } catch (e) {
@@ -151,8 +151,8 @@ function requireNative() {
151
151
  try {
152
152
  const binding = require('@bruits/satteri-win32-ia32-msvc')
153
153
  const bindingPackageVersion = require('@bruits/satteri-win32-ia32-msvc/package.json').version
154
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
156
156
  }
157
157
  return binding
158
158
  } catch (e) {
@@ -167,8 +167,8 @@ function requireNative() {
167
167
  try {
168
168
  const binding = require('@bruits/satteri-win32-arm64-msvc')
169
169
  const bindingPackageVersion = require('@bruits/satteri-win32-arm64-msvc/package.json').version
170
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
172
  }
173
173
  return binding
174
174
  } catch (e) {
@@ -186,8 +186,8 @@ function requireNative() {
186
186
  try {
187
187
  const binding = require('@bruits/satteri-darwin-universal')
188
188
  const bindingPackageVersion = require('@bruits/satteri-darwin-universal/package.json').version
189
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
191
191
  }
192
192
  return binding
193
193
  } catch (e) {
@@ -202,8 +202,8 @@ function requireNative() {
202
202
  try {
203
203
  const binding = require('@bruits/satteri-darwin-x64')
204
204
  const bindingPackageVersion = require('@bruits/satteri-darwin-x64/package.json').version
205
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
207
207
  }
208
208
  return binding
209
209
  } catch (e) {
@@ -218,8 +218,8 @@ function requireNative() {
218
218
  try {
219
219
  const binding = require('@bruits/satteri-darwin-arm64')
220
220
  const bindingPackageVersion = require('@bruits/satteri-darwin-arm64/package.json').version
221
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
223
  }
224
224
  return binding
225
225
  } catch (e) {
@@ -238,8 +238,8 @@ function requireNative() {
238
238
  try {
239
239
  const binding = require('@bruits/satteri-freebsd-x64')
240
240
  const bindingPackageVersion = require('@bruits/satteri-freebsd-x64/package.json').version
241
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
243
243
  }
244
244
  return binding
245
245
  } catch (e) {
@@ -254,8 +254,8 @@ function requireNative() {
254
254
  try {
255
255
  const binding = require('@bruits/satteri-freebsd-arm64')
256
256
  const bindingPackageVersion = require('@bruits/satteri-freebsd-arm64/package.json').version
257
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
259
259
  }
260
260
  return binding
261
261
  } catch (e) {
@@ -275,8 +275,8 @@ function requireNative() {
275
275
  try {
276
276
  const binding = require('@bruits/satteri-linux-x64-musl')
277
277
  const bindingPackageVersion = require('@bruits/satteri-linux-x64-musl/package.json').version
278
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
280
280
  }
281
281
  return binding
282
282
  } catch (e) {
@@ -291,8 +291,8 @@ function requireNative() {
291
291
  try {
292
292
  const binding = require('@bruits/satteri-linux-x64-gnu')
293
293
  const bindingPackageVersion = require('@bruits/satteri-linux-x64-gnu/package.json').version
294
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
296
  }
297
297
  return binding
298
298
  } catch (e) {
@@ -309,8 +309,8 @@ function requireNative() {
309
309
  try {
310
310
  const binding = require('@bruits/satteri-linux-arm64-musl')
311
311
  const bindingPackageVersion = require('@bruits/satteri-linux-arm64-musl/package.json').version
312
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
314
314
  }
315
315
  return binding
316
316
  } catch (e) {
@@ -325,8 +325,8 @@ function requireNative() {
325
325
  try {
326
326
  const binding = require('@bruits/satteri-linux-arm64-gnu')
327
327
  const bindingPackageVersion = require('@bruits/satteri-linux-arm64-gnu/package.json').version
328
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
330
  }
331
331
  return binding
332
332
  } catch (e) {
@@ -343,8 +343,8 @@ function requireNative() {
343
343
  try {
344
344
  const binding = require('@bruits/satteri-linux-arm-musleabihf')
345
345
  const bindingPackageVersion = require('@bruits/satteri-linux-arm-musleabihf/package.json').version
346
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
348
348
  }
349
349
  return binding
350
350
  } catch (e) {
@@ -359,8 +359,8 @@ function requireNative() {
359
359
  try {
360
360
  const binding = require('@bruits/satteri-linux-arm-gnueabihf')
361
361
  const bindingPackageVersion = require('@bruits/satteri-linux-arm-gnueabihf/package.json').version
362
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
364
  }
365
365
  return binding
366
366
  } catch (e) {
@@ -377,8 +377,8 @@ function requireNative() {
377
377
  try {
378
378
  const binding = require('@bruits/satteri-linux-loong64-musl')
379
379
  const bindingPackageVersion = require('@bruits/satteri-linux-loong64-musl/package.json').version
380
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
382
382
  }
383
383
  return binding
384
384
  } catch (e) {
@@ -393,8 +393,8 @@ function requireNative() {
393
393
  try {
394
394
  const binding = require('@bruits/satteri-linux-loong64-gnu')
395
395
  const bindingPackageVersion = require('@bruits/satteri-linux-loong64-gnu/package.json').version
396
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
398
  }
399
399
  return binding
400
400
  } catch (e) {
@@ -411,8 +411,8 @@ function requireNative() {
411
411
  try {
412
412
  const binding = require('@bruits/satteri-linux-riscv64-musl')
413
413
  const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-musl/package.json').version
414
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
416
416
  }
417
417
  return binding
418
418
  } catch (e) {
@@ -427,8 +427,8 @@ function requireNative() {
427
427
  try {
428
428
  const binding = require('@bruits/satteri-linux-riscv64-gnu')
429
429
  const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-gnu/package.json').version
430
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
432
  }
433
433
  return binding
434
434
  } catch (e) {
@@ -444,8 +444,8 @@ function requireNative() {
444
444
  try {
445
445
  const binding = require('@bruits/satteri-linux-ppc64-gnu')
446
446
  const bindingPackageVersion = require('@bruits/satteri-linux-ppc64-gnu/package.json').version
447
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
449
  }
450
450
  return binding
451
451
  } catch (e) {
@@ -460,8 +460,8 @@ function requireNative() {
460
460
  try {
461
461
  const binding = require('@bruits/satteri-linux-s390x-gnu')
462
462
  const bindingPackageVersion = require('@bruits/satteri-linux-s390x-gnu/package.json').version
463
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
465
  }
466
466
  return binding
467
467
  } catch (e) {
@@ -480,8 +480,8 @@ function requireNative() {
480
480
  try {
481
481
  const binding = require('@bruits/satteri-openharmony-arm64')
482
482
  const bindingPackageVersion = require('@bruits/satteri-openharmony-arm64/package.json').version
483
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
485
485
  }
486
486
  return binding
487
487
  } catch (e) {
@@ -496,8 +496,8 @@ function requireNative() {
496
496
  try {
497
497
  const binding = require('@bruits/satteri-openharmony-x64')
498
498
  const bindingPackageVersion = require('@bruits/satteri-openharmony-x64/package.json').version
499
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
501
501
  }
502
502
  return binding
503
503
  } catch (e) {
@@ -512,8 +512,8 @@ function requireNative() {
512
512
  try {
513
513
  const binding = require('@bruits/satteri-openharmony-arm')
514
514
  const bindingPackageVersion = require('@bruits/satteri-openharmony-arm/package.json').version
515
- if (bindingPackageVersion !== '0.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
- throw new Error(`Native binding package version mismatch, expected 0.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '0.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 0.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
517
517
  }
518
518
  return binding
519
519
  } catch (e) {
@@ -562,6 +562,14 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
562
562
  }
563
563
  }
564
564
 
565
+ if (!nativeBinding && globalThis.process?.versions?.['webcontainer']) {
566
+ try {
567
+ nativeBinding = require('./webcontainer-fallback.cjs');
568
+ } catch (err) {
569
+ loadErrors.push(err)
570
+ }
571
+ }
572
+
565
573
  if (!nativeBinding) {
566
574
  if (loadErrors.length > 0) {
567
575
  throw new Error(
@@ -579,7 +587,7 @@ if (!nativeBinding) {
579
587
  throw new Error(`Failed to load native binding`)
580
588
  }
581
589
 
582
- const { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle } = nativeBinding
590
+ const { applyCommandsAndConvertToHastHandle, applyCommandsToHandle, applyCommandsToMdastHandle, compileHandle, compileMdx, convertMdastToHastHandle, createHastHandle, createMdastHandle, createMdxHastHandle, createMdxMdastHandle, dropHandle, getHandleSource, getMdastFrontmatter, getNodeData, mdastTextContentHandle, parseEsm, parseExpression, parseToHtml, renderHandle, serializeHandle, setNodeData, textContentHandle, walkHandle, walkMdastHandle } = nativeBinding
583
591
  export { applyCommandsAndConvertToHastHandle }
584
592
  export { applyCommandsToHandle }
585
593
  export { applyCommandsToMdastHandle }
@@ -592,6 +600,7 @@ export { createMdxHastHandle }
592
600
  export { createMdxMdastHandle }
593
601
  export { dropHandle }
594
602
  export { getHandleSource }
603
+ export { getMdastFrontmatter }
595
604
  export { getNodeData }
596
605
  export { mdastTextContentHandle }
597
606
  export { parseEsm }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "satteri",
3
- "version": "0.3.5",
3
+ "version": "0.5.0",
4
4
  "description": "High-performance Markdown and MDX processing",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,8 @@
14
14
  "satteri_napi.wasi.cjs",
15
15
  "satteri_napi.wasi-browser.js",
16
16
  "wasi-worker.mjs",
17
- "wasi-worker-browser.mjs"
17
+ "wasi-worker-browser.mjs",
18
+ "webcontainer-fallback.cjs"
18
19
  ],
19
20
  "type": "module",
20
21
  "main": "./dist/index.js",
@@ -78,17 +79,21 @@
78
79
  ]
79
80
  },
80
81
  "optionalDependencies": {
81
- "@bruits/satteri-linux-x64-gnu": "0.3.5",
82
- "@bruits/satteri-darwin-x64": "0.3.5",
83
- "@bruits/satteri-darwin-arm64": "0.3.5",
84
- "@bruits/satteri-win32-x64-msvc": "0.3.5",
85
- "@bruits/satteri-wasm32-wasi": "0.3.5"
82
+ "@bruits/satteri-linux-x64-gnu": "0.5.0",
83
+ "@bruits/satteri-darwin-x64": "0.5.0",
84
+ "@bruits/satteri-darwin-arm64": "0.5.0",
85
+ "@bruits/satteri-win32-x64-msvc": "0.5.0",
86
+ "@bruits/satteri-wasm32-wasi": "0.5.0"
86
87
  },
87
88
  "scripts": {
88
89
  "build:wasm": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --release --esm --strip --target wasm32-wasip1-threads",
90
+ "postbuild:wasm": "node patch-binding.js",
89
91
  "build:native": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --release --esm --strip",
92
+ "postbuild:native": "node patch-binding.js",
90
93
  "build:native:cross": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --release --esm --strip --cross-compile",
94
+ "postbuild:native:cross": "node patch-binding.js",
91
95
  "build:native:debug": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --esm",
96
+ "postbuild:native:debug": "node patch-binding.js",
92
97
  "build:ts": "tsc --project tsconfig.build.json",
93
98
  "build": "pnpm build:native && pnpm build:ts",
94
99
  "artifacts": "napi create-npm-dirs && napi artifacts",
@@ -69,6 +69,7 @@ export const createMdxHastHandle = __napiModule.exports.createMdxHastHandle
69
69
  export const createMdxMdastHandle = __napiModule.exports.createMdxMdastHandle
70
70
  export const dropHandle = __napiModule.exports.dropHandle
71
71
  export const getHandleSource = __napiModule.exports.getHandleSource
72
+ export const getMdastFrontmatter = __napiModule.exports.getMdastFrontmatter
72
73
  export const getNodeData = __napiModule.exports.getNodeData
73
74
  export const mdastTextContentHandle = __napiModule.exports.mdastTextContentHandle
74
75
  export const parseEsm = __napiModule.exports.parseEsm
@@ -120,6 +120,7 @@ module.exports.createMdxHastHandle = __napiModule.exports.createMdxHastHandle
120
120
  module.exports.createMdxMdastHandle = __napiModule.exports.createMdxMdastHandle
121
121
  module.exports.dropHandle = __napiModule.exports.dropHandle
122
122
  module.exports.getHandleSource = __napiModule.exports.getHandleSource
123
+ module.exports.getMdastFrontmatter = __napiModule.exports.getMdastFrontmatter
123
124
  module.exports.getNodeData = __napiModule.exports.getNodeData
124
125
  module.exports.mdastTextContentHandle = __napiModule.exports.mdastTextContentHandle
125
126
  module.exports.parseEsm = __napiModule.exports.parseEsm
@@ -0,0 +1,23 @@
1
+ // Adapted from https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/webcontainer-fallback.cjs
2
+
3
+ const fs = require("node:fs");
4
+ const childProcess = require("node:child_process");
5
+
6
+ const pkg = require("./package.json");
7
+ const version = pkg.version;
8
+
9
+ const baseDir = `/tmp/satteri-${version}`;
10
+ const bindingEntry = `${baseDir}/node_modules/@bruits/satteri-wasm32-wasi/satteri_napi.wasi.cjs`;
11
+
12
+ if (!fs.existsSync(bindingEntry)) {
13
+ const bindingPkg = `@bruits/satteri-wasm32-wasi@${version}`;
14
+ fs.rmSync(baseDir, { recursive: true, force: true });
15
+ fs.mkdirSync(baseDir, { recursive: true });
16
+ console.log(`[satteri] Downloading ${bindingPkg} on WebContainer...`);
17
+ childProcess.execFileSync("pnpm", ["i", bindingPkg], {
18
+ cwd: baseDir,
19
+ stdio: "inherit",
20
+ });
21
+ }
22
+
23
+ module.exports = require(bindingEntry);