From 5b07135f0c1470afe0bd0c9575547564c166eae5 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Fri, 14 Aug 2026 11:27:17 -0400 Subject: [PATCH 01/10] add warnings flag --- packages/satteri/src/compile.ts | 29 +++++++++++++++++------ packages/vite-plugin-satteri/src/index.ts | 6 ++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/satteri/src/compile.ts b/packages/satteri/src/compile.ts index 37547592..9e5f790c 100644 --- a/packages/satteri/src/compile.ts +++ b/packages/satteri/src/compile.ts @@ -156,6 +156,7 @@ function runMdastPluginsOnHandle( handle: MdastHandle, plugins: MdastPluginDefinition[], fileURL: URL | undefined, + warnings: boolean, data: Data, sourceFormat: SourceFormat, collectLast = false, @@ -187,7 +188,7 @@ function runMdastPluginsOnHandle( } markHandleMutated(handle); const dropped = applyCommandsToMdastHandle(handle, r.commandBuffer); - if (dropped) warnDroppedTransforms(plugin as { name?: string }, dropped, "mdast"); + if (warnings && dropped) warnDroppedTransforms(plugin as { name?: string }, dropped, "mdast"); }; return result instanceof Promise ? result.then(apply) : apply(result); }; @@ -228,6 +229,7 @@ function runHastPluginsCollectLast( plugins: HastPluginDefinition[], source: string, fileURL: URL | undefined, + warnings: boolean, data: Data, sourceFormat: SourceFormat, ): CollectedHastCommands | Promise { @@ -256,7 +258,7 @@ function runHastPluginsCollectLast( const result = visitHastHandle(handle, plugin, subs, source, fileURL, data, sourceFormat); const warnIfDropped = (dropped: number): void => { - if (dropped) warnDroppedTransforms(plugin, dropped, "hast"); + if (warnings && dropped) warnDroppedTransforms(plugin, dropped, "hast"); }; if (result instanceof Promise) { return result.then((dropped) => { @@ -474,6 +476,10 @@ export interface CompileOptions { * `pathToFileURL` before passing it. */ fileURL?: URL; + /** + * ... + */ + warnings?: boolean; /** * Initial document-level data bag, seeding `ctx.data` before any plugin runs. * It is the same object plugins mutate and the caller reads back as @@ -647,7 +653,7 @@ export function markdownToHtml( source: string, options: CompileOptions = {}, ): MarkdownToHtmlResult | Promise { - const { features, fileURL, data = {} } = options; + const { features, fileURL, warnings = true, data = {} } = options; const mdastPlugins = normalizePlugins(options.mdastPlugins ?? [], "mdastPlugins"); const hastPlugins = normalizePlugins(options.hastPlugins ?? [], "hastPlugins"); const hastMayHaveStubs = hastPlugins.length > 0; @@ -678,6 +684,7 @@ export function markdownToHtml( mdastHandle, mdastPlugins, fileURL, + warnings, data, "markdown", true, @@ -693,7 +700,7 @@ export function markdownToHtml( commands, nativeConvertOptions, ); - if (droppedTransforms && r.lastPlugin) + if (warnings && droppedTransforms && r.lastPlugin) warnDroppedTransforms(r.lastPlugin, droppedTransforms, "mdast"); return { html, @@ -722,6 +729,7 @@ export function markdownToHtml( mdastPlugins, false, fileURL, + warnings, nativeFeatures, nativeConvertOptions, data, @@ -741,6 +749,7 @@ export function markdownToHtml( hastPlugins, source, fileURL, + warnings, data, "markdown", ); @@ -769,7 +778,7 @@ export function markdownToHtml( let html: string; if (collected.commands.length > 0) { const result = applyCommandsAndRenderHandle(h, collected.commands); - if (result.droppedTransforms && collected.lastPlugin) + if (warnings && result.droppedTransforms && collected.lastPlugin) warnDroppedTransforms(collected.lastPlugin, result.droppedTransforms, "hast"); html = result.html; } else { @@ -824,6 +833,7 @@ function toJsImpl( hastPlugins: hastInput = [], features, fileURL, + warnings = true, data = {}, ...mdxFields } = options; @@ -862,6 +872,7 @@ function toJsImpl( mdastHandle, mdastPlugins, fileURL, + warnings, data, mdx ? "mdx" : "markdown", true, @@ -875,7 +886,7 @@ function toJsImpl( mdxOptions, nativeConvertOptions, ); - if (droppedTransforms && r.lastPlugin) + if (warnings && droppedTransforms && r.lastPlugin) warnDroppedTransforms(r.lastPlugin, droppedTransforms, "mdast"); return { code, @@ -904,6 +915,7 @@ function toJsImpl( mdastPlugins, mdx, fileURL, + warnings, nativeFeatures, nativeConvertOptions, data, @@ -918,6 +930,7 @@ function toJsImpl( hastPlugins, source, fileURL, + warnings, data, mdx ? "mdx" : "markdown", ); @@ -946,7 +959,7 @@ function toJsImpl( let code: string; if (collected.commands.length > 0) { const result = applyCommandsAndCompileHandle(h, collected.commands, mdxOptions); - if (result.droppedTransforms && collected.lastPlugin) + if (warnings && result.droppedTransforms && collected.lastPlugin) warnDroppedTransforms(collected.lastPlugin, result.droppedTransforms, "hast"); code = result.code; } else { @@ -1019,6 +1032,7 @@ function createHastHandleFromMdast( mdastPlugins: MdastPluginDefinition[], mdx: boolean, fileURL: URL | undefined, + warnings: boolean, // eslint-disable-next-line @typescript-eslint/no-explicit-any nativeFeatures: any, // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -1072,6 +1086,7 @@ function createHastHandleFromMdast( mdastHandle, mdastPlugins, fileURL, + warnings, data, sourceFormat, ); diff --git a/packages/vite-plugin-satteri/src/index.ts b/packages/vite-plugin-satteri/src/index.ts index e4c983c3..4d092b04 100644 --- a/packages/vite-plugin-satteri/src/index.ts +++ b/packages/vite-plugin-satteri/src/index.ts @@ -43,6 +43,8 @@ export interface VitePluginSatteriOptions { hastPlugins?: HastPluginList; /** Parser feature toggles (gfm, frontmatter, math, …). Shared across .md and .mdx. */ features?: Features; + /** Display warnings about dropped transformations. Default: true. */ + warnings?: boolean; } const MD_RE = /\.md(?:\?|$)/; @@ -56,7 +58,7 @@ function parseFrontmatter(fm: Frontmatter | null): unknown { } export default function vitePluginSatteri(options: VitePluginSatteriOptions = {}): Plugin { - const { markdown = true, mdx = true, mdastPlugins, hastPlugins, features } = options; + const { markdown = true, mdx = true, mdastPlugins, hastPlugins, features, warnings = true } = options; const mdxEnabled = mdx !== false; const mdxOptions: MdxOptions = typeof mdx === "object" ? mdx : {}; @@ -81,6 +83,7 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} const isDev = mdxOptions.development ?? viteConfig?.command === "serve"; const opts: MdxCompileOptions = { fileURL, + warnings, development: isDev, ...(mdastPlugins ? { mdastPlugins } : {}), ...(hastPlugins ? { hastPlugins } : {}), @@ -108,6 +111,7 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} const opts: CompileOptions = { fileURL, + warnings, ...(mdastPlugins ? { mdastPlugins } : {}), ...(hastPlugins ? { hastPlugins } : {}), ...(features ? { features } : {}), From b69d159892eb9dd52f69979a7ddcfa68a6c1008d Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Sat, 15 Aug 2026 12:47:58 -0400 Subject: [PATCH 02/10] test + docs + changeset --- .sampo/changesets/pompous-count-tuoni.md | 6 ++++ packages/satteri-expressive-code/src/index.ts | 2 +- packages/satteri/src/compile.ts | 30 +++++++++---------- .../satteri/test/nested-transforms.test.ts | 2 ++ packages/vite-plugin-satteri/src/index.ts | 19 ++++++++---- website/content/docs/features.md | 2 +- website/content/docs/options.md | 15 +++++----- website/content/docs/plugin-api.md | 3 +- 8 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 .sampo/changesets/pompous-count-tuoni.md diff --git a/.sampo/changesets/pompous-count-tuoni.md b/.sampo/changesets/pompous-count-tuoni.md new file mode 100644 index 00000000..9d663275 --- /dev/null +++ b/.sampo/changesets/pompous-count-tuoni.md @@ -0,0 +1,6 @@ +--- +npm/satteri: patch +npm/vite-plugin-satteri: patch +--- + +Added `warnings` option to allow opting out of warnings about dropped transforms. diff --git a/packages/satteri-expressive-code/src/index.ts b/packages/satteri-expressive-code/src/index.ts index d8b55b71..5f652c4e 100644 --- a/packages/satteri-expressive-code/src/index.ts +++ b/packages/satteri-expressive-code/src/index.ts @@ -169,7 +169,7 @@ function fileURLToFilePath(fileURL: URL | undefined): string { * * @example * ```ts - * const html = await markdownToHtml(source, { + * const html = markdownToHtml(source, { * hastPlugins: [expressiveCode({ themes: ['github-dark'] })], * }) * ``` diff --git a/packages/satteri/src/compile.ts b/packages/satteri/src/compile.ts index 9e5f790c..8b8d467c 100644 --- a/packages/satteri/src/compile.ts +++ b/packages/satteri/src/compile.ts @@ -156,8 +156,8 @@ function runMdastPluginsOnHandle( handle: MdastHandle, plugins: MdastPluginDefinition[], fileURL: URL | undefined, - warnings: boolean, data: Data, + warnings: boolean, sourceFormat: SourceFormat, collectLast = false, ): MdastPipelineResult | Promise { @@ -229,8 +229,8 @@ function runHastPluginsCollectLast( plugins: HastPluginDefinition[], source: string, fileURL: URL | undefined, - warnings: boolean, data: Data, + warnings: boolean, sourceFormat: SourceFormat, ): CollectedHastCommands | Promise { let i = 0; @@ -476,10 +476,6 @@ export interface CompileOptions { * `pathToFileURL` before passing it. */ fileURL?: URL; - /** - * ... - */ - warnings?: boolean; /** * Initial document-level data bag, seeding `ctx.data` before any plugin runs. * It is the same object plugins mutate and the caller reads back as @@ -488,6 +484,8 @@ export interface CompileOptions { * throwaway object per compile rather than a shared one. */ data?: Data; + /** Display warnings about dropped transforms. Default: true. */ + warnings?: boolean; } /** @@ -653,7 +651,7 @@ export function markdownToHtml( source: string, options: CompileOptions = {}, ): MarkdownToHtmlResult | Promise { - const { features, fileURL, warnings = true, data = {} } = options; + const { features, fileURL, data = {}, warnings = true } = options; const mdastPlugins = normalizePlugins(options.mdastPlugins ?? [], "mdastPlugins"); const hastPlugins = normalizePlugins(options.hastPlugins ?? [], "hastPlugins"); const hastMayHaveStubs = hastPlugins.length > 0; @@ -684,8 +682,8 @@ export function markdownToHtml( mdastHandle, mdastPlugins, fileURL, - warnings, data, + warnings, "markdown", true, ); @@ -729,10 +727,10 @@ export function markdownToHtml( mdastPlugins, false, fileURL, - warnings, nativeFeatures, nativeConvertOptions, data, + warnings, trackPositions, ); @@ -749,8 +747,8 @@ export function markdownToHtml( hastPlugins, source, fileURL, - warnings, data, + warnings, "markdown", ); } catch (err) { @@ -833,8 +831,8 @@ function toJsImpl( hastPlugins: hastInput = [], features, fileURL, - warnings = true, data = {}, + warnings = true, ...mdxFields } = options; const mdastPlugins = normalizePlugins(mdastInput, "mdastPlugins"); @@ -872,8 +870,8 @@ function toJsImpl( mdastHandle, mdastPlugins, fileURL, - warnings, data, + warnings, mdx ? "mdx" : "markdown", true, ); @@ -915,10 +913,10 @@ function toJsImpl( mdastPlugins, mdx, fileURL, - warnings, nativeFeatures, nativeConvertOptions, data, + warnings, trackPositions, ); @@ -930,8 +928,8 @@ function toJsImpl( hastPlugins, source, fileURL, - warnings, data, + warnings, mdx ? "mdx" : "markdown", ); } catch (err) { @@ -1032,12 +1030,12 @@ function createHastHandleFromMdast( mdastPlugins: MdastPluginDefinition[], mdx: boolean, fileURL: URL | undefined, - warnings: boolean, // eslint-disable-next-line @typescript-eslint/no-explicit-any nativeFeatures: any, // eslint-disable-next-line @typescript-eslint/no-explicit-any nativeConvertOptions: any, data: Data, + warnings: boolean, trackPositions: boolean, ): HastWithFrontmatter | Promise { if (mdastPlugins.length === 0) { @@ -1086,8 +1084,8 @@ function createHastHandleFromMdast( mdastHandle, mdastPlugins, fileURL, - warnings, data, + warnings, sourceFormat, ); diff --git a/packages/satteri/test/nested-transforms.test.ts b/packages/satteri/test/nested-transforms.test.ts index 49983fd6..e23b7f2d 100644 --- a/packages/satteri/test/nested-transforms.test.ts +++ b/packages/satteri/test/nested-transforms.test.ts @@ -113,6 +113,8 @@ test("a stranded HAST transform is dropped with a warning, like MDAST", () => { }, }, }); + markdownToHtml("# *Hi*", { hastPlugins: [plugin], warnings: false }); + expect(warn).toHaveBeenCalledTimes(0); const { html } = markdownToHtml("# *Hi*", { hastPlugins: [plugin] }); expect(html.trim()).toBe(""); // heading + its em gone, no throw expect(warn).toHaveBeenCalledTimes(1); diff --git a/packages/vite-plugin-satteri/src/index.ts b/packages/vite-plugin-satteri/src/index.ts index 4d092b04..a13fe2b4 100644 --- a/packages/vite-plugin-satteri/src/index.ts +++ b/packages/vite-plugin-satteri/src/index.ts @@ -43,7 +43,7 @@ export interface VitePluginSatteriOptions { hastPlugins?: HastPluginList; /** Parser feature toggles (gfm, frontmatter, math, …). Shared across .md and .mdx. */ features?: Features; - /** Display warnings about dropped transformations. Default: true. */ + /** Display warnings about dropped transforms. Default: true. */ warnings?: boolean; } @@ -58,7 +58,14 @@ function parseFrontmatter(fm: Frontmatter | null): unknown { } export default function vitePluginSatteri(options: VitePluginSatteriOptions = {}): Plugin { - const { markdown = true, mdx = true, mdastPlugins, hastPlugins, features, warnings = true } = options; + const { + markdown = true, + mdx = true, + mdastPlugins, + hastPlugins, + features, + warnings = true, + } = options; const mdxEnabled = mdx !== false; const mdxOptions: MdxOptions = typeof mdx === "object" ? mdx : {}; @@ -83,7 +90,7 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} const isDev = mdxOptions.development ?? viteConfig?.command === "serve"; const opts: MdxCompileOptions = { fileURL, - warnings, + warnings, development: isDev, ...(mdastPlugins ? { mdastPlugins } : {}), ...(hastPlugins ? { hastPlugins } : {}), @@ -103,7 +110,7 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} ? { pragmaImportSource: mdxOptions.pragmaImportSource } : {}), }; - const { code: mdxCode, frontmatter } = await mdxToJs(source, opts); + const { code: mdxCode, frontmatter } = mdxToJs(source, opts); const fm = parseFrontmatter(frontmatter); const code = `export const frontmatter = ${JSON.stringify(fm)};\n${mdxCode}`; return { code, map: null }; @@ -111,12 +118,12 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} const opts: CompileOptions = { fileURL, - warnings, + warnings, ...(mdastPlugins ? { mdastPlugins } : {}), ...(hastPlugins ? { hastPlugins } : {}), ...(features ? { features } : {}), }; - const { html, frontmatter } = await markdownToHtml(source, opts); + const { html, frontmatter } = markdownToHtml(source, opts); const fm = parseFrontmatter(frontmatter); const code = `const html = ${JSON.stringify(html)};\n` + diff --git a/website/content/docs/features.md b/website/content/docs/features.md index 22fb12fe..7d8adc4d 100644 --- a/website/content/docs/features.md +++ b/website/content/docs/features.md @@ -185,7 +185,7 @@ MDX treats `{...}` as a JavaScript expression, which normally collides with the # Welcome {name} ``` -A `{...}` that *is* valid JavaScript stays an expression even when it looks like attributes: `{hidden}`, `{level=2}` and `{title="Home"}` evaluate rather than apply — silently, and unlike in plain Markdown. Add a `#`/`.` shorthand to force attributes; `{#id hidden}` applies both. +A `{...}` that _is_ valid JavaScript stays an expression even when it looks like attributes: `{hidden}`, `{level=2}` and `{title="Home"}` evaluate rather than apply — silently, and unlike in plain Markdown. Add a `#`/`.` shorthand to force attributes; `{#id hidden}` applies both. ## Directives diff --git a/website/content/docs/options.md b/website/content/docs/options.md index 05f9e775..85628983 100644 --- a/website/content/docs/options.md +++ b/website/content/docs/options.md @@ -9,13 +9,14 @@ Options for Sätteri's [entry points](/docs/entry-points/). `CompileOptions` is ## CompileOptions -| Option | Type | Notes | -| -------------- | ----------------- | --------------------------------------------------------------------------------------------- | -| `mdastPlugins` | `MdastPluginList` | MDAST plugins, factories that return one, or arrays of either. See [Plugins](/docs/plugins/). | -| `hastPlugins` | `HastPluginList` | HAST plugins, factories, or arrays of either. | -| `features` | `Features` | Parser extensions. See [Features](/docs/features/). | -| `fileURL` | `URL` | The document's URL, surfaced to plugins as `ctx.fileURL`. | -| `data` | `Data` | Initial [data bag](#data). | +| Option | Type | Notes | +| -------------- | ----------------- | ---------------------------------------------------------------------------------------------------- | +| `mdastPlugins` | `MdastPluginList` | MDAST plugins, factories that return one, or arrays of either. See [Plugins](/docs/plugins/). | +| `hastPlugins` | `HastPluginList` | HAST plugins, factories, or arrays of either. | +| `features` | `Features` | Parser extensions. See [Features](/docs/features/). | +| `fileURL` | `URL` | The document's URL, surfaced to plugins as `ctx.fileURL`. | +| `data` | `Data` | Initial [data bag](#data). | +| `warnings` | `boolean` | Display warnings about [dropped transforms](/docs/plugin-api#how-transforms-compose). Default: true. | ### fileURL diff --git a/website/content/docs/plugin-api.md b/website/content/docs/plugin-api.md index bffa9c4f..cbb35344 100644 --- a/website/content/docs/plugin-api.md +++ b/website/content/docs/plugin-api.md @@ -62,7 +62,6 @@ const headingAnchors = () => { markdownToHtml(source, { mdastPlugins: [headingAnchors] }); ``` - ### Source positions Visitors read `node.position` (the `{ start, end }` source range) only when the plugin opts in with `options: { position: true }`. Tracking positions adds a measurable parsing cost (~15% of parse), so it is off by default. `node.position` is `undefined` unless some plugin in the pipeline requests it. @@ -426,6 +425,6 @@ Each Sätteri plugin walks the tree **once** — there is no re-walking until th - **Passed-through children keep their identity.** When a visitor returns a replacement that reuses the original children (e.g. `{ ...node, children: [...node.children] }`), those children are spliced back unchanged, so a transform queued on a nested one in the same pass still applies. This is what lets a single `containerDirective` visitor turn both an outer `:::note` and a nested `:::tip` into asides in one go. - **A plugin's own freshly-built nodes are not re-walked by that plugin.** A brand-new node a visitor returns isn't visited again by the same plugin. Produce its final shape directly, or hand it to a later plugin — every plugin runs over the fully materialized output of the ones before it. -- **Dropping a subtree drops the transforms queued inside it.** If one visitor removes or replaces a node while another queued a transform on something inside that subtree, the orphaned transform is dropped and a warning is logged. Usually that's intended; the warning catches the cases where it isn't. +- **Dropping a subtree drops the transforms queued inside it.** If one visitor removes or replaces a node while another queued a transform on something inside that subtree, the orphaned transform is dropped and a warning is logged. Usually that's intended; the warning catches the cases where it isn't. (These can be silenced with the [`warnings` option](/docs/options#compileoptions).) - **Nodes from another document throw.** Handing a context method a node kept from a previous compile — or an mdast node inside a hast plugin — fails the compile. Keep nodes around within a document freely; don't carry them across. - **A few contradictory combinations throw.** Replacing a node with new content that reuses that same node while another plugin edits something inside it in the same pass, two replacements that each reuse the other's node, and inserting a sibling next to the root. Replacing, removing, or wrapping the root itself — say, via `ctx.parent()` on a top-level node — works fine. From a1cf69a2fb81fcfac20d17aed443bef1d0b2a59b Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Sat, 15 Aug 2026 13:11:58 -0400 Subject: [PATCH 03/10] add note to vite page --- website/content/docs/vite.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/website/content/docs/vite.md b/website/content/docs/vite.md index 3748da80..dc8b40c1 100644 --- a/website/content/docs/vite.md +++ b/website/content/docs/vite.md @@ -79,13 +79,14 @@ By default, the plugin compiles MDX with `development: true` in `serve` so React ## Options -| Option | Type | Default | Effect | -| -------------- | ----------------------- | ------- | -------------------------------------------------------------- | -| `markdown` | `boolean` | `true` | Process `.md` files. | -| `mdx` | `boolean \| MdxOptions` | `true` | Process `.mdx` files. Pass an object to configure the compile. | -| `mdastPlugins` | `MdastPluginList` | — | MDAST-stage plugins, shared across `.md` and `.mdx`. | -| `hastPlugins` | `HastPluginList` | — | HAST-stage plugins, shared across `.md` and `.mdx`. | -| `features` | `Features` | — | Parser toggles. See [Features](/docs/features/). | +| Option | Type | Default | Effect | +| -------------- | ----------------------- | ------- | ------------------------------------------------------------------------------------- | +| `markdown` | `boolean` | `true` | Process `.md` files. | +| `mdx` | `boolean \| MdxOptions` | `true` | Process `.mdx` files. Pass an object to configure the compile. | +| `mdastPlugins` | `MdastPluginList` | — | MDAST-stage plugins, shared across `.md` and `.mdx`. | +| `hastPlugins` | `HastPluginList` | — | HAST-stage plugins, shared across `.md` and `.mdx`. | +| `features` | `Features` | — | Parser toggles. See [Features](/docs/features/). | +| `warnings` | `boolean` | `true` | Display warnings about [dropped transforms](/docs/plugin-api#how-transforms-compose). | `MdxOptions` mirrors Sätteri's MDX options minus `outputFormat`. The plugin always emits an ES module so Vite can import it. From 6a573d7a5517e64f8de11bb20bb2d293906be120 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Tue, 18 Aug 2026 12:32:10 -0400 Subject: [PATCH 04/10] restore awaits, didn't understand plugins could be async --- packages/satteri-expressive-code/src/index.ts | 2 +- packages/vite-plugin-satteri/src/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/satteri-expressive-code/src/index.ts b/packages/satteri-expressive-code/src/index.ts index 5f652c4e..d8b55b71 100644 --- a/packages/satteri-expressive-code/src/index.ts +++ b/packages/satteri-expressive-code/src/index.ts @@ -169,7 +169,7 @@ function fileURLToFilePath(fileURL: URL | undefined): string { * * @example * ```ts - * const html = markdownToHtml(source, { + * const html = await markdownToHtml(source, { * hastPlugins: [expressiveCode({ themes: ['github-dark'] })], * }) * ``` diff --git a/packages/vite-plugin-satteri/src/index.ts b/packages/vite-plugin-satteri/src/index.ts index a13fe2b4..dd8f531d 100644 --- a/packages/vite-plugin-satteri/src/index.ts +++ b/packages/vite-plugin-satteri/src/index.ts @@ -110,7 +110,7 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} ? { pragmaImportSource: mdxOptions.pragmaImportSource } : {}), }; - const { code: mdxCode, frontmatter } = mdxToJs(source, opts); + const { code: mdxCode, frontmatter } = await mdxToJs(source, opts); const fm = parseFrontmatter(frontmatter); const code = `export const frontmatter = ${JSON.stringify(fm)};\n${mdxCode}`; return { code, map: null }; @@ -123,7 +123,7 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} ...(hastPlugins ? { hastPlugins } : {}), ...(features ? { features } : {}), }; - const { html, frontmatter } = markdownToHtml(source, opts); + const { html, frontmatter } = await markdownToHtml(source, opts); const fm = parseFrontmatter(frontmatter); const code = `const html = ${JSON.stringify(html)};\n` + From 26e5101f64ad927981a5395fee1c1db28afabf9c Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Tue, 18 Aug 2026 12:36:28 -0400 Subject: [PATCH 05/10] lint + format --- packages/satteri/CHANGELOG.md | 92 ++++++++++------ packages/satteri/index.js | 104 +++++++++--------- packages/satteri/src/hast/hast-visitor.ts | 40 ++++--- packages/satteri/src/materializer-cache.ts | 6 +- packages/satteri/src/mdast/mdast-visitor.ts | 39 +++++-- .../test/conformance/definition-list.test.ts | 5 +- packages/vite-plugin-satteri/CHANGELOG.md | 14 ++- pnpm-workspace.yaml | 2 +- website/content/docs/plugin-api.md | 2 +- 9 files changed, 181 insertions(+), 123 deletions(-) diff --git a/packages/satteri/CHANGELOG.md b/packages/satteri/CHANGELOG.md index 6fc282ee..232b3a29 100644 --- a/packages/satteri/CHANGELOG.md +++ b/packages/satteri/CHANGELOG.md @@ -5,94 +5,106 @@ ### Patch changes - [1b09752](https://github.com/bruits/satteri/commit/1b09752d04b7e5494b583250330089a6401b377d) Added `{ fragment: true }` to `htmlToHast`, which parses the string as a fragment so the returned `root` holds its own top-level nodes instead of an implied ``/``/``. - + Pass `space: "svg"` alongside it to read the fragment as foreign content, so `` self-closes and camel-cased tags like `clipPath` keep their casing instead of parsing as unknown HTML elements. - + ```ts import { htmlToHast } from "satteri"; - + const tree = htmlToHast("

hi

", { fragment: true }); // { type: "root", children: [{ type: "element", tagName: "p", ... }] } - + const icon = htmlToHast(``, { fragment: true, space: "svg" }); ``` - — Thanks @Princesseuh! + + — Thanks @Princesseuh! ## 0.10.0 — 2026-08-18 ### Minor changes - [137ff48](https://github.com/bruits/satteri/commit/137ff48da7d4a7422cadb3c82b9b7e987aa87e23) Nodes handed to plugins are shared and now frozen: writing to a node's fields, `position`, `properties`/`attributes`, or `children` throws a `TypeError` instead of silently corrupting what later plugins see; go through the context methods to make changes. - + Keeping a node around after your visitor ran now works: it reads as the tree looked at that moment, instead of always throwing. The error only remains if you never read the node's content before the tree changed. Trees returned by `markdownToMdast`/`mdxToMdast`/`markdownToHast`/`mdxToHast` are your own data and stay fully mutable. — Thanks @Princesseuh! + - [e53e725](https://github.com/bruits/satteri/commit/e53e725e3eca758b5c65364b583c06a96d515510) Added a way to run a plugin only on some documents: a plugin factory now receives the file's `fileURL`, `sourceFormat`, `source` and `data`, and can return `null`, `undefined` or `false` to be left out for that document. Those skip values are also accepted anywhere a plugin entry can appear. - + ```js const onlyChangelogs = (ctx) => ctx.fileURL?.pathname.endsWith("/CHANGELOG.md") ? rewriteVersions : null; - + markdownToHtml(source, { mdastPlugins: [onlyChangelogs, myPlugin] }); ``` - + Anything else in a plugin list now fails with an error naming the option and what it expected. — Thanks @Princesseuh! + - [2b85f56](https://github.com/bruits/satteri/commit/2b85f5602fc3340eef9faa3e41c66ff0a03ec8af) Adds `{ raw }` support to `wrapNode()` in HAST plugins: the HTML is parsed and the node is wrapped in the resulting element. — Thanks @Princesseuh! - [d8b7172](https://github.com/bruits/satteri/commit/d8b71724ba3a6bfcad24265c5b1d021b1de1eaa0) Adds a `definitionList` feature (off by default) that renders definition lists to `
`/`
`/`
`. - + New `descriptionList` / `descriptionTerm` / `descriptionDetails` nodes are available to plugins when this option is enabled. - + ```text Apple : Pomaceous fruit. : A tech company. ``` - — Thanks @lolifamily for your first contribution 🎉! + + — Thanks @lolifamily for your first contribution 🎉! + - [d8639d6](https://github.com/bruits/satteri/commit/d8639d64efa50f2adf2f88f6a4928559d2a30836) Added a `rawHtml` feature that reparses raw HTML embedded in Markdown into real HAST nodes. Enable it with `features: { rawHtml: true }` on any entry point; it is applied during the MDAST→HAST conversion, so `markdownToHast`, `markdownToHtml`, and the plugin pipelines all reparse identically, and hast plugins always see the reparsed elements. - + The whole tree is reparsed through the HTML parser, so a tag opened in one raw block and closed in another is resolved against the surrounding Markdown. Attributes are normalized into typed hast properties (`class` → `className: [...]`, `disabled` → `true`, `tabindex` → number, `data-foo-bar` → `dataFooBar`). `htmlToHast` normalizes properties the same way. - + MDX nodes are passed through the reparse rather than dropped: each JSX element/expression is preserved in place while the surrounding raw HTML is still resolved around it. So `mdxToHast(source, { features: { rawHtml: true } })` keeps its MDX content. - + ```ts import { markdownToHast } from "satteri"; - + const tree = markdownToHast(`
\n\n**hi**\n\n
`, { features: { rawHtml: true }, }); //
is a real element wrapping

hi

``` - — Thanks @IEvangelist for your first contribution 🎉! + + — Thanks @IEvangelist for your first contribution 🎉! + - [166419c](https://github.com/bruits/satteri/commit/166419cf912b3639abedfcb87ee8059920e5b221) Added `markdownToJs`, the plain-Markdown counterpart to `mdxToJs`: MDX syntax like `{...}` stays literal text. - + ```ts import { markdownToJs } from "satteri"; - + const { code } = markdownToJs("Hello {world}"); ``` - + HTML in the source is dropped. Pass `features: { rawHtml: true }` to parse it into real elements instead. — Thanks @Princesseuh! + - [eeb7f07](https://github.com/bruits/satteri/commit/eeb7f0778a7af229fd592dd027ddfe0723ba2b26) Source positions are now opt-in per plugin via `options: { position: true }`, and `node.position` is `undefined` in visitors otherwise. — Thanks @Princesseuh! - [c9ea0c9](https://github.com/bruits/satteri/commit/c9ea0c9e59d7e71afb6be97b378e787b0f3c96a8) Adds user-defined MDAST node types. A plugin can create a node with any `type` string, render it as an element through `data.hName` (or as text from a `value`), and reach every one of them from the new `custom` visitor key. Content nested inside a custom node stays visible to other plugins and to the HTML output. — Thanks @Princesseuh! - [8df3f76](https://github.com/bruits/satteri/commit/8df3f765b2df9cbfa1aa4130a126b9315e431c14) Added support for nested arrays in `mdastPlugins` and `hastPlugins`, so a package can export a bundle of plugins that you pass without spreading it. A bundle's plugins run in their own order, at the bundle's position. A factory can return a bundle as well as a single plugin, giving its plugins state they share with each other and reset per document. - + ```js import { typography } from "some-package"; // an array of plugins - + markdownToHtml(source, { mdastPlugins: [typography, myPlugin] }); ``` - — Thanks @Princesseuh! + + — Thanks @Princesseuh! + - [53fa9a9](https://github.com/bruits/satteri/commit/53fa9a9575f41eb858cf50b4298aea3a0c5f0f73) `ctx.replaceNode(node, newNode)` now accepts an array of nodes as well as a single node, matching `insertBefore`, `insertAfter`, `prependChild`, `appendChild` and `insertChildAt`. The nodes take the target's place in order, so `ctx.replaceNode(node, [a, b])` leaves `a` and `b` where `node` was. This works on both the MDAST and HAST visitor contexts. — Thanks @Princesseuh! - [2ac113e](https://github.com/bruits/satteri/commit/2ac113e9851dfd15340a999f9a1e829a9d2b0f8f) Added `position: false` to `markdownToMdast`, `mdxToMdast`, `markdownToHast`, and `mdxToHast`, which skips recording `node.position`. On a 1 MB document that halves both the time to build a tree and the memory it occupies, so it is worth passing whenever nothing downstream reads positions. - + ```ts const tree = markdownToMdast(source, { position: false }); ``` - — Thanks @Princesseuh! + + — Thanks @Princesseuh! + - [63fbb77](https://github.com/bruits/satteri/commit/63fbb77a16b88d4df4928ed07e943752e87fff17) Plugins now splice strings with a single shape, `{ raw: string, mdxExpressions?: boolean }`, accepted by visitor return values and every structural mutator (`replace`, `insertBefore`, `insertAfter`, `prependChild`, `appendChild`, `wrapNode`). The string is re-parsed in place of the node. - + `mdxExpressions` (default `true`) controls what `{…}` means when the document is MDX: live expressions by default, or literal text with `mdxExpressions: false` — the right choice when injecting generated HTML whose braces are not expressions, like a Mermaid decision node `C{JWT valid?}` or math renderer output. Plain Markdown has no expressions, so the option is a no-op there. - + `{ rawHtml: string }` is deprecated; it keeps working and behaves exactly like `{ raw, mdxExpressions: false }`. - + ```ts defineMdastPlugin({ code(node) { @@ -101,16 +113,20 @@ }, }); ``` - — Thanks @Princesseuh! + + — Thanks @Princesseuh! + - [d8639d6](https://github.com/bruits/satteri/commit/d8639d64efa50f2adf2f88f6a4928559d2a30836) Added `htmlToHast`, which parses an HTML string into a HAST tree (elements, text, comments, doctype) with the same spec-compliant parsing a browser does. The result is a `root` wrapping the implied `` subtree. - + ```ts import { htmlToHast } from "satteri"; - + const tree = htmlToHast("

hi

"); // { type: "root", children: [{ type: "element", tagName: "html", ... }] } ``` - — Thanks @IEvangelist for your first contribution 🎉! + + — Thanks @IEvangelist for your first contribution 🎉! + - [6050fc4](https://github.com/bruits/satteri/commit/6050fc40a3b546f08817277c9adb816ec9bfe938) Adds `before`/`after` lifecycle hooks to plugins that run exactly once per document. — Thanks @Princesseuh! ### Patch changes @@ -129,8 +145,9 @@ - [ac2b172](https://github.com/bruits/satteri/commit/ac2b17274772147a15863439c0484861f656cc13) Fixed a bare URL or email not linking when a character reference supplies its first character, as in `http://example.com`. — Thanks @Princesseuh! - [a27c06d](https://github.com/bruits/satteri/commit/a27c06db317606172a4dab5675de0b265793acb8) Fixed MDX line comments and `import`/`export` blocks swallowing the lines after them in files that use lone carriage returns as line endings. — Thanks @Princesseuh! - [137ff48](https://github.com/bruits/satteri/commit/137ff48da7d4a7422cadb3c82b9b7e987aa87e23) Editing a node that belongs to a different document (a node kept from a previous compile, or an mdast node used in a hast plugin) now fails the compile with `invalid node id`. A few pathological edits now throw `unsupported patch shape`, most notably replacing a node with new content that reuses that same node while another plugin edits something inside it in the same pass, and inserting a sibling next to the root. - + Edits to nodes that another plugin removed in the same pass are still just dropped with a warning, and replacing, removing, or wrapping the root keeps working. — Thanks @Princesseuh! + - [d6dbbad](https://github.com/bruits/satteri/commit/d6dbbad1d47e43f10391b3e00792078da49bdfc7) Fixed an email overlapping a `www.` link swallowing the link, like `user@www.example.org` after an unclosed bracket. — Thanks @Princesseuh! - [be2c1a1](https://github.com/bruits/satteri/commit/be2c1a168fdcc548b0c39980a3e4be1634acae8d) Fixed emphasis being parsed around a `~` when GFM is disabled, so `a*~*` now stays plain text. — Thanks @Princesseuh! - [a27c06d](https://github.com/bruits/satteri/commit/a27c06db317606172a4dab5675de0b265793acb8) Fixed GFM autolinks losing their positions when smart punctuation is enabled. — Thanks @Princesseuh! @@ -143,7 +160,7 @@ - [9094edd](https://github.com/bruits/satteri/commit/9094edd70cbf49f28444838afc7c489ddf068c09) Improved `markdownToMdast` and `markdownToHast` performance by reading each node from the wire buffer once while building the tree. — Thanks @Princesseuh! - [eeb7f07](https://github.com/bruits/satteri/commit/eeb7f0778a7af229fd592dd027ddfe0723ba2b26) Faster parsing, MDX compilation, and plugin execution. — Thanks @Princesseuh! - [f0c24d7](https://github.com/bruits/satteri/commit/f0c24d768f151fd1d171a1ebc1dd5170820588f8) Improved HAST property types in plugins: `node.properties.href`, `className`, `start` and every other known property are now typed individually, so reading one no longer needs a `typeof` guard to narrow it. - + ```ts element: { filter: ["a"], @@ -154,7 +171,9 @@ }, } ``` - — Thanks @Princesseuh! + + — Thanks @Princesseuh! + - [2ac113e](https://github.com/bruits/satteri/commit/2ac113e9851dfd15340a999f9a1e829a9d2b0f8f) Walking a tree from `markdownToMdast`, `mdxToMdast`, `markdownToHast`, `mdxToHast`, or `htmlToHast` is roughly 4x faster. — Thanks @Princesseuh! - [1126ad0](https://github.com/bruits/satteri/commit/1126ad0dc303de1f3f3eeccfb8355bd0b99d2eb9) Fixed a tight definition list gluing a definition's continuation paragraph onto the first block with no separator. — Thanks @Princesseuh! - [5a581ad](https://github.com/bruits/satteri/commit/5a581ad8eae90a7eef102d7727b7fe9f6a7d1893) Fixed a vertical tab or form feed standing in for a space in an ATX heading opener, a task list marker, an HTML tag, or a link or footnote label. — Thanks @Princesseuh! @@ -178,8 +197,9 @@ - [8df3f76](https://github.com/bruits/satteri/commit/8df3f765b2df9cbfa1aa4130a126b9315e431c14) Fixed `markdownToHtml`, `mdxToJs` and `markdownToJs` being typed as synchronous when a plugin list mixed sync and async plugins. The result is now correctly typed as a `Promise`. — Thanks @Princesseuh! - [9a164f1](https://github.com/bruits/satteri/commit/9a164f110f2d01c525f9f5c03376508bd227e860) Fixes footnotes being ignored inside directives. A footnote reference nested in a rendered directive (e.g. `:::note … [^id] … :::`) now works like anywhere else (it renders as a footnote link and its definition appears in the footnotes section) instead of being left as literal `[^id]` text. — Thanks @Princesseuh! - [2b85f56](https://github.com/bruits/satteri/commit/2b85f5602fc3340eef9faa3e41c66ff0a03ec8af) Fixed `wrapNode()` silently misplacing or dropping the node when given a parent that cannot hold children: an `html` node, a leaf-shaped custom node, or a void element like ``. These now throw an error explaining what to use instead, and `parentNode` only accepts parent-capable nodes in TypeScript, so most of them are caught before running. - + Wrapping in a container is unchanged: `blockquote` and friends, a HAST element, an MDX JSX element, a custom node declaring a `children` array, and the root itself all keep working. — Thanks @Princesseuh! + - [46e2572](https://github.com/bruits/satteri/commit/46e25721656ec01fe494b62a3c2a5a48f1e45dfb) Fixed a `{` inside an MDX link destination or title raising a parse error when the tail holds an escaped or quoted `)`, as in `[a](\){)`, and stopped a link tail forming from a `[` that is backslash-escaped, inside a code span, already wrapped by another link, or in an earlier block. — Thanks @Princesseuh! - [58add58](https://github.com/bruits/satteri/commit/58add589d8d9dc1c9a774e07519f0e3e7119df34) Fixed nodes created from raw string splices reporting garbage positions; they now report no position, like other plugin-created nodes. — Thanks @Princesseuh! - [9bb585d](https://github.com/bruits/satteri/commit/9bb585d90298f647c4b85babe520e92b5b40c527) Fixed edits to a node another plugin removed being dropped silently instead of with the documented warning. — Thanks @Princesseuh! diff --git a/packages/satteri/index.js b/packages/satteri/index.js index 4f3d4619..f4668a6d 100644 --- a/packages/satteri/index.js +++ b/packages/satteri/index.js @@ -81,8 +81,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-android-arm64') const bindingPackageVersion = require('@bruits/satteri-android-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -97,8 +97,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-android-arm-eabi') const bindingPackageVersion = require('@bruits/satteri-android-arm-eabi/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -118,8 +118,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-x64-gnu') const bindingPackageVersion = require('@bruits/satteri-win32-x64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -134,8 +134,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-x64-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-x64-msvc/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -151,8 +151,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-ia32-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-ia32-msvc/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -167,8 +167,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-arm64-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-arm64-msvc/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -186,8 +186,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-universal') const bindingPackageVersion = require('@bruits/satteri-darwin-universal/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -202,8 +202,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-x64') const bindingPackageVersion = require('@bruits/satteri-darwin-x64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -218,8 +218,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-arm64') const bindingPackageVersion = require('@bruits/satteri-darwin-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -238,8 +238,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-freebsd-x64') const bindingPackageVersion = require('@bruits/satteri-freebsd-x64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -254,8 +254,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-freebsd-arm64') const bindingPackageVersion = require('@bruits/satteri-freebsd-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -275,8 +275,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-x64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-x64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -291,8 +291,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-x64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-x64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -309,8 +309,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-arm64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -325,8 +325,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-arm64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -343,8 +343,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm-musleabihf') const bindingPackageVersion = require('@bruits/satteri-linux-arm-musleabihf/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -359,8 +359,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm-gnueabihf') const bindingPackageVersion = require('@bruits/satteri-linux-arm-gnueabihf/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -377,8 +377,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-loong64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-loong64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -393,8 +393,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-loong64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-loong64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -411,8 +411,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-riscv64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -427,8 +427,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-riscv64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -444,8 +444,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-ppc64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-ppc64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -460,8 +460,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-s390x-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-s390x-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -480,8 +480,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-arm64') const bindingPackageVersion = require('@bruits/satteri-openharmony-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -496,8 +496,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-x64') const bindingPackageVersion = require('@bruits/satteri-openharmony-x64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -512,8 +512,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-arm') const bindingPackageVersion = require('@bruits/satteri-openharmony-arm/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { diff --git a/packages/satteri/src/hast/hast-visitor.ts b/packages/satteri/src/hast/hast-visitor.ts index 79bc4bea..09242d11 100644 --- a/packages/satteri/src/hast/hast-visitor.ts +++ b/packages/satteri/src/hast/hast-visitor.ts @@ -269,7 +269,12 @@ function hastReusedId(node: unknown, refs: NodeRefs): number | undefined { /** Emit a set-children command in place: a root-wrapped child list, the shape * `Patch::SetChildren` splices in. Reused children become refs. */ -function emitHastChildrenCommand(buffer: CommandBuffer, id: number, children: unknown, refs: NodeRefs): boolean { +function emitHastChildrenCommand( + buffer: CommandBuffer, + id: number, + children: unknown, + refs: NodeRefs, +): boolean { if (!Array.isArray(children)) return false; return buffer.emitOpstreamCommand(CMD_SET_CHILDREN, id, () => { buffer.open(HAST_ROOT); @@ -285,7 +290,13 @@ function emitHastChildrenCommand(buffer: CommandBuffer, id: number, children: un * payload directly into the command buffer (no intermediate copy). HAST * content is always a declarative node (no raw escape hatch), so it * compiles or it's a hard error. */ -function emitHastTree(buffer: CommandBuffer, op: StructuralOp, id: number, node: HastNode, refs: NodeRefs): void { +function emitHastTree( + buffer: CommandBuffer, + op: StructuralOp, + id: number, + node: HastNode, + refs: NodeRefs, +): void { const ok = buffer.emitOpstreamCommand(STRUCTURAL_CMD[op], id, () => emitHastOp(buffer, node, true, refs), ); @@ -418,7 +429,8 @@ class HastVisitorContextImpl implements HastVisitorContext { // The last node carries the `replace` so refs back to the target still splice. let previous: HastContent | undefined; for (const n of newNode) { - if (previous !== undefined) emitHastTree(this.#commandBuffer, "insertBefore", id, previous, this.#refs); + if (previous !== undefined) + emitHastTree(this.#commandBuffer, "insertBefore", id, previous, this.#refs); previous = n; } if (previous === undefined) { @@ -444,12 +456,14 @@ class HastVisitorContextImpl implements HastVisitorContext { insertBefore(node: HastNode, newNode: HastContent | HastContent[]): void { const id = requireNid(node, "insertBefore", this.#refs); - for (const n of asArray(newNode)) emitHastTree(this.#commandBuffer, "insertBefore", id, n, this.#refs); + for (const n of asArray(newNode)) + emitHastTree(this.#commandBuffer, "insertBefore", id, n, this.#refs); } insertAfter(node: HastNode, newNode: HastContent | HastContent[]): void { const id = requireNid(node, "insertAfter", this.#refs); - for (const n of asArray(newNode)) emitHastTree(this.#commandBuffer, "insertAfter", id, n, this.#refs); + for (const n of asArray(newNode)) + emitHastTree(this.#commandBuffer, "insertAfter", id, n, this.#refs); } wrapNode( @@ -470,12 +484,14 @@ class HastVisitorContextImpl implements HastVisitorContext { prependChild(node: HastNode, childNode: HastContent | HastContent[]): void { const id = requireNid(node, "prependChild", this.#refs); - for (const n of asArray(childNode)) emitHastTree(this.#commandBuffer, "prependChild", id, n, this.#refs); + for (const n of asArray(childNode)) + emitHastTree(this.#commandBuffer, "prependChild", id, n, this.#refs); } appendChild(node: HastNode, childNode: HastContent | HastContent[]): void { const id = requireNid(node, "appendChild", this.#refs); - for (const n of asArray(childNode)) emitHastTree(this.#commandBuffer, "appendChild", id, n, this.#refs); + for (const n of asArray(childNode)) + emitHastTree(this.#commandBuffer, "appendChild", id, n, this.#refs); } insertChildAt(node: HastNode, index: number, childNode: HastContent | HastContent[]): void { @@ -562,9 +578,7 @@ class HastVisitorContextImpl implements HastVisitorContext { parent>(node: Readonly): Readonly; parent(node: Readonly): Readonly | undefined; parent(node: Readonly): Readonly | undefined { - const parentId = this.#resolver.parentIdOf( - requireNid(node as HastNode, "parent", this.#refs), - ); + const parentId = this.#resolver.parentIdOf(requireNid(node as HastNode, "parent", this.#refs)); if (parentId === undefined) return undefined; const byId = (this.#parentsById ??= new Map()); let parent = byId.get(parentId); @@ -1134,11 +1148,7 @@ class HastLazyChildResolver extends LazyChildResolver { return new HastReader(wire); } - protected override materializeNode( - reader: HastReader, - nodeId: number, - refs: NodeRefs, - ): HastNode { + protected override materializeNode(reader: HastReader, nodeId: number, refs: NodeRefs): HastNode { return materializeHastNode(reader, nodeId, true, refs); } diff --git a/packages/satteri/src/materializer-cache.ts b/packages/satteri/src/materializer-cache.ts index d9985d50..922c0c62 100644 --- a/packages/satteri/src/materializer-cache.ts +++ b/packages/satteri/src/materializer-cache.ts @@ -119,7 +119,11 @@ export function createMaterializer { + function readerCache( + reader: TReader, + frozen: boolean, + refs: NodeRefs | undefined, + ): ReaderCache { let cache = readerCaches.get(reader); if (cache === undefined) { cache = { diff --git a/packages/satteri/src/mdast/mdast-visitor.ts b/packages/satteri/src/mdast/mdast-visitor.ts index 0b7a874d..6b4feb8c 100644 --- a/packages/satteri/src/mdast/mdast-visitor.ts +++ b/packages/satteri/src/mdast/mdast-visitor.ts @@ -220,12 +220,14 @@ export class MdastVisitorContext { insertBefore(node: Readonly, newNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "insertBefore", this.#refs); - for (const n of asArray(newNode)) emitMdastTree(this.#commandBuffer, "insertBefore", id, n, false, this.#refs); + for (const n of asArray(newNode)) + emitMdastTree(this.#commandBuffer, "insertBefore", id, n, false, this.#refs); } insertAfter(node: Readonly, newNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "insertAfter", this.#refs); - for (const n of asArray(newNode)) emitMdastTree(this.#commandBuffer, "insertAfter", id, n, false, this.#refs); + for (const n of asArray(newNode)) + emitMdastTree(this.#commandBuffer, "insertAfter", id, n, false, this.#refs); } /** @@ -247,12 +249,14 @@ export class MdastVisitorContext { prependChild(node: Readonly, childNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "prependChild", this.#refs); - for (const n of asArray(childNode)) emitMdastTree(this.#commandBuffer, "prependChild", id, n, false, this.#refs); + for (const n of asArray(childNode)) + emitMdastTree(this.#commandBuffer, "prependChild", id, n, false, this.#refs); } appendChild(node: Readonly, childNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "appendChild", this.#refs); - for (const n of asArray(childNode)) emitMdastTree(this.#commandBuffer, "appendChild", id, n, false, this.#refs); + for (const n of asArray(childNode)) + emitMdastTree(this.#commandBuffer, "appendChild", id, n, false, this.#refs); } /** Insert one node or an array at `index`; clamps (`0` or less prepends, past the end appends). */ @@ -374,9 +378,7 @@ export class MdastVisitorContext { parent>(node: Readonly): Readonly; parent(node: Readonly): Readonly | undefined; parent(node: Readonly): Readonly | undefined { - const parentId = this.#resolver.parentIdOf( - requireNid(node as MdastNode, "parent", this.#refs), - ); + const parentId = this.#resolver.parentIdOf(requireNid(node as MdastNode, "parent", this.#refs)); if (parentId === undefined) return undefined; const byId = (this.#parentsById ??= new Map()); let parent = byId.get(parentId); @@ -765,7 +767,12 @@ function reusedId(node: unknown, refs: NodeRefs): number | undefined { /** Emit a set-children command in place: a root-wrapped child list, the shape * `Patch::SetChildren` splices in. Reused children become refs. */ -function emitMdastChildrenCommand(buffer: CommandBuffer, id: number, children: unknown, refs: NodeRefs): boolean { +function emitMdastChildrenCommand( + buffer: CommandBuffer, + id: number, + children: unknown, + refs: NodeRefs, +): boolean { if (!Array.isArray(children)) return false; return buffer.emitOpstreamCommand(CMD_SET_CHILDREN, id, () => { buffer.open(MDAST_ROOT); @@ -800,7 +807,13 @@ function emitMdastRootOp(w: OpWriter, n: Record, refs: NodeRefs return true; } -function emitMdastOp(w: OpWriter, node: unknown, isRoot: boolean, forReplace: boolean, refs: NodeRefs): boolean { +function emitMdastOp( + w: OpWriter, + node: unknown, + isRoot: boolean, + forReplace: boolean, + refs: NodeRefs, +): boolean { if (node === null || typeof node !== "object") return false; if (!isRoot) { const id = reusedId(node, refs); @@ -1084,7 +1097,13 @@ export function visitMdastHandle( deferred ??= []; deferred.push({ nodeId, promise: result, originalNode: node }); } else { - applyMdastVisitResult(result as MdastVisitorResult, nodeId, returnBuffer, resolver.refs, node); + applyMdastVisitResult( + result as MdastVisitorResult, + nodeId, + returnBuffer, + resolver.refs, + node, + ); } } diff --git a/packages/satteri/test/conformance/definition-list.test.ts b/packages/satteri/test/conformance/definition-list.test.ts index df196292..25f3b308 100644 --- a/packages/satteri/test/conformance/definition-list.test.ts +++ b/packages/satteri/test/conformance/definition-list.test.ts @@ -521,7 +521,10 @@ function satteriMdastShape(md: string): NodeShape[] { } function collapseTagWhitespace(h: string): string { - return h.replace(/>\s+<").replace(/\s+<\//g, "\s+<") + .replace(/\s+<\//g, " { diff --git a/packages/vite-plugin-satteri/CHANGELOG.md b/packages/vite-plugin-satteri/CHANGELOG.md index 31123616..ee29c40b 100644 --- a/packages/vite-plugin-satteri/CHANGELOG.md +++ b/packages/vite-plugin-satteri/CHANGELOG.md @@ -11,23 +11,25 @@ ### Minor changes - [e53e725](https://github.com/bruits/satteri/commit/e53e725e3eca758b5c65364b583c06a96d515510) Added a way to run a plugin only on some documents: a plugin factory now receives the file's `fileURL`, `sourceFormat`, `source` and `data`, and can return `null`, `undefined` or `false` to be left out for that document. Those skip values are also accepted anywhere a plugin entry can appear. - + ```js const onlyChangelogs = (ctx) => ctx.fileURL?.pathname.endsWith("/CHANGELOG.md") ? rewriteVersions : null; - + markdownToHtml(source, { mdastPlugins: [onlyChangelogs, myPlugin] }); ``` - + Anything else in a plugin list now fails with an error naming the option and what it expected. — Thanks @Princesseuh! + - [8df3f76](https://github.com/bruits/satteri/commit/8df3f765b2df9cbfa1aa4130a126b9315e431c14) Added support for nested arrays in `mdastPlugins` and `hastPlugins`, so a package can export a bundle of plugins that you pass without spreading it. A bundle's plugins run in their own order, at the bundle's position. A factory can return a bundle as well as a single plugin, giving its plugins state they share with each other and reset per document. - + ```js import { typography } from "some-package"; // an array of plugins - + markdownToHtml(source, { mdastPlugins: [typography, myPlugin] }); ``` - — Thanks @Princesseuh! + + — Thanks @Princesseuh! ### Patch changes diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 25708a1b..2ada96eb 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -12,7 +12,7 @@ allowBuilds: minimumReleaseAgeExclude: - satteri - - '@bruits/*' + - "@bruits/*" supportedArchitectures: cpu: diff --git a/website/content/docs/plugin-api.md b/website/content/docs/plugin-api.md index baf40333..6c2b4187 100644 --- a/website/content/docs/plugin-api.md +++ b/website/content/docs/plugin-api.md @@ -494,7 +494,7 @@ To share state across visits within a document, close over a variable in the sur Each Sätteri plugin walks the tree **once** — there is no re-walking until the tree stops changing. Within that single pass: - **Passed-through children keep their identity.** When a visitor returns a replacement that reuses the original children (e.g. `{ ...node, children: [...node.children] }`), those children are spliced back unchanged, so a transform queued on a nested one in the same pass still applies. This is what lets a single `containerDirective` visitor turn both an outer `:::note` and a nested `:::tip` into asides in one go. -- **A plugin's own freshly-built nodes are not re-walked by that plugin.** A brand-new node a visitor returns isn't visited again by the same plugin. Produce its final shape directly, or hand it to a later plugin — every plugin runs over the fully materialized output of the ones before it. A `before` hook is the exception: it lands before the walk, so nodes it builds *are* visited. +- **A plugin's own freshly-built nodes are not re-walked by that plugin.** A brand-new node a visitor returns isn't visited again by the same plugin. Produce its final shape directly, or hand it to a later plugin — every plugin runs over the fully materialized output of the ones before it. A `before` hook is the exception: it lands before the walk, so nodes it builds _are_ visited. - **Dropping a subtree drops the transforms queued inside it.** If one visitor removes or replaces a node while another queued a transform on something inside that subtree, the orphaned transform is dropped and a warning is logged. Usually that's intended; the warning catches the cases where it isn't. (These can be silenced with the [`warnings` option](/docs/options#compileoptions).) - **Nodes from another document throw.** Handing a context method a node kept from a previous compile — or an mdast node inside a hast plugin — fails the compile. Keep nodes around within a document freely; don't carry them across. - **A few contradictory combinations throw.** Replacing a node with new content that reuses that same node while another plugin edits something inside it in the same pass, two replacements that each reuse the other's node, and inserting a sibling next to the root. Replacing, removing, or wrapping the root itself — say, via `ctx.parent()` on a top-level node — works fine. From 89cbff5e90e12d7cc3054549ab1229f029f94b28 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Tue, 18 Aug 2026 23:52:04 -0400 Subject: [PATCH 06/10] Revert "lint + format" This reverts commit 26e5101f64ad927981a5395fee1c1db28afabf9c. --- packages/satteri/CHANGELOG.md | 92 ++++++---------- packages/satteri/index.js | 104 +++++++++--------- packages/satteri/src/hast/hast-visitor.ts | 40 +++---- packages/satteri/src/materializer-cache.ts | 6 +- packages/satteri/src/mdast/mdast-visitor.ts | 39 ++----- .../test/conformance/definition-list.test.ts | 5 +- packages/vite-plugin-satteri/CHANGELOG.md | 14 +-- pnpm-workspace.yaml | 2 +- website/content/docs/plugin-api.md | 2 +- 9 files changed, 123 insertions(+), 181 deletions(-) diff --git a/packages/satteri/CHANGELOG.md b/packages/satteri/CHANGELOG.md index e8cc182f..d433aa8a 100644 --- a/packages/satteri/CHANGELOG.md +++ b/packages/satteri/CHANGELOG.md @@ -21,106 +21,94 @@ ### Patch changes - [1b09752](https://github.com/bruits/satteri/commit/1b09752d04b7e5494b583250330089a6401b377d) Added `{ fragment: true }` to `htmlToHast`, which parses the string as a fragment so the returned `root` holds its own top-level nodes instead of an implied ``/``/``. - + Pass `space: "svg"` alongside it to read the fragment as foreign content, so `` self-closes and camel-cased tags like `clipPath` keep their casing instead of parsing as unknown HTML elements. - + ```ts import { htmlToHast } from "satteri"; - + const tree = htmlToHast("

hi

", { fragment: true }); // { type: "root", children: [{ type: "element", tagName: "p", ... }] } - + const icon = htmlToHast(``, { fragment: true, space: "svg" }); ``` - - — Thanks @Princesseuh! + — Thanks @Princesseuh! ## 0.10.0 — 2026-08-18 ### Minor changes - [137ff48](https://github.com/bruits/satteri/commit/137ff48da7d4a7422cadb3c82b9b7e987aa87e23) Nodes handed to plugins are shared and now frozen: writing to a node's fields, `position`, `properties`/`attributes`, or `children` throws a `TypeError` instead of silently corrupting what later plugins see; go through the context methods to make changes. - + Keeping a node around after your visitor ran now works: it reads as the tree looked at that moment, instead of always throwing. The error only remains if you never read the node's content before the tree changed. Trees returned by `markdownToMdast`/`mdxToMdast`/`markdownToHast`/`mdxToHast` are your own data and stay fully mutable. — Thanks @Princesseuh! - - [e53e725](https://github.com/bruits/satteri/commit/e53e725e3eca758b5c65364b583c06a96d515510) Added a way to run a plugin only on some documents: a plugin factory now receives the file's `fileURL`, `sourceFormat`, `source` and `data`, and can return `null`, `undefined` or `false` to be left out for that document. Those skip values are also accepted anywhere a plugin entry can appear. - + ```js const onlyChangelogs = (ctx) => ctx.fileURL?.pathname.endsWith("/CHANGELOG.md") ? rewriteVersions : null; - + markdownToHtml(source, { mdastPlugins: [onlyChangelogs, myPlugin] }); ``` - + Anything else in a plugin list now fails with an error naming the option and what it expected. — Thanks @Princesseuh! - - [2b85f56](https://github.com/bruits/satteri/commit/2b85f5602fc3340eef9faa3e41c66ff0a03ec8af) Adds `{ raw }` support to `wrapNode()` in HAST plugins: the HTML is parsed and the node is wrapped in the resulting element. — Thanks @Princesseuh! - [d8b7172](https://github.com/bruits/satteri/commit/d8b71724ba3a6bfcad24265c5b1d021b1de1eaa0) Adds a `definitionList` feature (off by default) that renders definition lists to `
`/`
`/`
`. - + New `descriptionList` / `descriptionTerm` / `descriptionDetails` nodes are available to plugins when this option is enabled. - + ```text Apple : Pomaceous fruit. : A tech company. ``` - - — Thanks @lolifamily for your first contribution 🎉! - + — Thanks @lolifamily for your first contribution 🎉! - [d8639d6](https://github.com/bruits/satteri/commit/d8639d64efa50f2adf2f88f6a4928559d2a30836) Added a `rawHtml` feature that reparses raw HTML embedded in Markdown into real HAST nodes. Enable it with `features: { rawHtml: true }` on any entry point; it is applied during the MDAST→HAST conversion, so `markdownToHast`, `markdownToHtml`, and the plugin pipelines all reparse identically, and hast plugins always see the reparsed elements. - + The whole tree is reparsed through the HTML parser, so a tag opened in one raw block and closed in another is resolved against the surrounding Markdown. Attributes are normalized into typed hast properties (`class` → `className: [...]`, `disabled` → `true`, `tabindex` → number, `data-foo-bar` → `dataFooBar`). `htmlToHast` normalizes properties the same way. - + MDX nodes are passed through the reparse rather than dropped: each JSX element/expression is preserved in place while the surrounding raw HTML is still resolved around it. So `mdxToHast(source, { features: { rawHtml: true } })` keeps its MDX content. - + ```ts import { markdownToHast } from "satteri"; - + const tree = markdownToHast(`
\n\n**hi**\n\n
`, { features: { rawHtml: true }, }); //
is a real element wrapping

hi

``` - - — Thanks @IEvangelist for your first contribution 🎉! - + — Thanks @IEvangelist for your first contribution 🎉! - [166419c](https://github.com/bruits/satteri/commit/166419cf912b3639abedfcb87ee8059920e5b221) Added `markdownToJs`, the plain-Markdown counterpart to `mdxToJs`: MDX syntax like `{...}` stays literal text. - + ```ts import { markdownToJs } from "satteri"; - + const { code } = markdownToJs("Hello {world}"); ``` - + HTML in the source is dropped. Pass `features: { rawHtml: true }` to parse it into real elements instead. — Thanks @Princesseuh! - - [eeb7f07](https://github.com/bruits/satteri/commit/eeb7f0778a7af229fd592dd027ddfe0723ba2b26) Source positions are now opt-in per plugin via `options: { position: true }`, and `node.position` is `undefined` in visitors otherwise. — Thanks @Princesseuh! - [c9ea0c9](https://github.com/bruits/satteri/commit/c9ea0c9e59d7e71afb6be97b378e787b0f3c96a8) Adds user-defined MDAST node types. A plugin can create a node with any `type` string, render it as an element through `data.hName` (or as text from a `value`), and reach every one of them from the new `custom` visitor key. Content nested inside a custom node stays visible to other plugins and to the HTML output. — Thanks @Princesseuh! - [8df3f76](https://github.com/bruits/satteri/commit/8df3f765b2df9cbfa1aa4130a126b9315e431c14) Added support for nested arrays in `mdastPlugins` and `hastPlugins`, so a package can export a bundle of plugins that you pass without spreading it. A bundle's plugins run in their own order, at the bundle's position. A factory can return a bundle as well as a single plugin, giving its plugins state they share with each other and reset per document. - + ```js import { typography } from "some-package"; // an array of plugins - + markdownToHtml(source, { mdastPlugins: [typography, myPlugin] }); ``` - - — Thanks @Princesseuh! - + — Thanks @Princesseuh! - [53fa9a9](https://github.com/bruits/satteri/commit/53fa9a9575f41eb858cf50b4298aea3a0c5f0f73) `ctx.replaceNode(node, newNode)` now accepts an array of nodes as well as a single node, matching `insertBefore`, `insertAfter`, `prependChild`, `appendChild` and `insertChildAt`. The nodes take the target's place in order, so `ctx.replaceNode(node, [a, b])` leaves `a` and `b` where `node` was. This works on both the MDAST and HAST visitor contexts. — Thanks @Princesseuh! - [2ac113e](https://github.com/bruits/satteri/commit/2ac113e9851dfd15340a999f9a1e829a9d2b0f8f) Added `position: false` to `markdownToMdast`, `mdxToMdast`, `markdownToHast`, and `mdxToHast`, which skips recording `node.position`. On a 1 MB document that halves both the time to build a tree and the memory it occupies, so it is worth passing whenever nothing downstream reads positions. - + ```ts const tree = markdownToMdast(source, { position: false }); ``` - - — Thanks @Princesseuh! - + — Thanks @Princesseuh! - [63fbb77](https://github.com/bruits/satteri/commit/63fbb77a16b88d4df4928ed07e943752e87fff17) Plugins now splice strings with a single shape, `{ raw: string, mdxExpressions?: boolean }`, accepted by visitor return values and every structural mutator (`replace`, `insertBefore`, `insertAfter`, `prependChild`, `appendChild`, `wrapNode`). The string is re-parsed in place of the node. - + `mdxExpressions` (default `true`) controls what `{…}` means when the document is MDX: live expressions by default, or literal text with `mdxExpressions: false` — the right choice when injecting generated HTML whose braces are not expressions, like a Mermaid decision node `C{JWT valid?}` or math renderer output. Plain Markdown has no expressions, so the option is a no-op there. - + `{ rawHtml: string }` is deprecated; it keeps working and behaves exactly like `{ raw, mdxExpressions: false }`. - + ```ts defineMdastPlugin({ code(node) { @@ -129,20 +117,16 @@ }, }); ``` - - — Thanks @Princesseuh! - + — Thanks @Princesseuh! - [d8639d6](https://github.com/bruits/satteri/commit/d8639d64efa50f2adf2f88f6a4928559d2a30836) Added `htmlToHast`, which parses an HTML string into a HAST tree (elements, text, comments, doctype) with the same spec-compliant parsing a browser does. The result is a `root` wrapping the implied `` subtree. - + ```ts import { htmlToHast } from "satteri"; - + const tree = htmlToHast("

hi

"); // { type: "root", children: [{ type: "element", tagName: "html", ... }] } ``` - - — Thanks @IEvangelist for your first contribution 🎉! - + — Thanks @IEvangelist for your first contribution 🎉! - [6050fc4](https://github.com/bruits/satteri/commit/6050fc40a3b546f08817277c9adb816ec9bfe938) Adds `before`/`after` lifecycle hooks to plugins that run exactly once per document. — Thanks @Princesseuh! ### Patch changes @@ -161,9 +145,8 @@ - [ac2b172](https://github.com/bruits/satteri/commit/ac2b17274772147a15863439c0484861f656cc13) Fixed a bare URL or email not linking when a character reference supplies its first character, as in `http://example.com`. — Thanks @Princesseuh! - [a27c06d](https://github.com/bruits/satteri/commit/a27c06db317606172a4dab5675de0b265793acb8) Fixed MDX line comments and `import`/`export` blocks swallowing the lines after them in files that use lone carriage returns as line endings. — Thanks @Princesseuh! - [137ff48](https://github.com/bruits/satteri/commit/137ff48da7d4a7422cadb3c82b9b7e987aa87e23) Editing a node that belongs to a different document (a node kept from a previous compile, or an mdast node used in a hast plugin) now fails the compile with `invalid node id`. A few pathological edits now throw `unsupported patch shape`, most notably replacing a node with new content that reuses that same node while another plugin edits something inside it in the same pass, and inserting a sibling next to the root. - + Edits to nodes that another plugin removed in the same pass are still just dropped with a warning, and replacing, removing, or wrapping the root keeps working. — Thanks @Princesseuh! - - [d6dbbad](https://github.com/bruits/satteri/commit/d6dbbad1d47e43f10391b3e00792078da49bdfc7) Fixed an email overlapping a `www.` link swallowing the link, like `user@www.example.org` after an unclosed bracket. — Thanks @Princesseuh! - [be2c1a1](https://github.com/bruits/satteri/commit/be2c1a168fdcc548b0c39980a3e4be1634acae8d) Fixed emphasis being parsed around a `~` when GFM is disabled, so `a*~*` now stays plain text. — Thanks @Princesseuh! - [a27c06d](https://github.com/bruits/satteri/commit/a27c06db317606172a4dab5675de0b265793acb8) Fixed GFM autolinks losing their positions when smart punctuation is enabled. — Thanks @Princesseuh! @@ -176,7 +159,7 @@ - [9094edd](https://github.com/bruits/satteri/commit/9094edd70cbf49f28444838afc7c489ddf068c09) Improved `markdownToMdast` and `markdownToHast` performance by reading each node from the wire buffer once while building the tree. — Thanks @Princesseuh! - [eeb7f07](https://github.com/bruits/satteri/commit/eeb7f0778a7af229fd592dd027ddfe0723ba2b26) Faster parsing, MDX compilation, and plugin execution. — Thanks @Princesseuh! - [f0c24d7](https://github.com/bruits/satteri/commit/f0c24d768f151fd1d171a1ebc1dd5170820588f8) Improved HAST property types in plugins: `node.properties.href`, `className`, `start` and every other known property are now typed individually, so reading one no longer needs a `typeof` guard to narrow it. - + ```ts element: { filter: ["a"], @@ -187,9 +170,7 @@ }, } ``` - - — Thanks @Princesseuh! - + — Thanks @Princesseuh! - [2ac113e](https://github.com/bruits/satteri/commit/2ac113e9851dfd15340a999f9a1e829a9d2b0f8f) Walking a tree from `markdownToMdast`, `mdxToMdast`, `markdownToHast`, `mdxToHast`, or `htmlToHast` is roughly 4x faster. — Thanks @Princesseuh! - [1126ad0](https://github.com/bruits/satteri/commit/1126ad0dc303de1f3f3eeccfb8355bd0b99d2eb9) Fixed a tight definition list gluing a definition's continuation paragraph onto the first block with no separator. — Thanks @Princesseuh! - [5a581ad](https://github.com/bruits/satteri/commit/5a581ad8eae90a7eef102d7727b7fe9f6a7d1893) Fixed a vertical tab or form feed standing in for a space in an ATX heading opener, a task list marker, an HTML tag, or a link or footnote label. — Thanks @Princesseuh! @@ -213,9 +194,8 @@ - [8df3f76](https://github.com/bruits/satteri/commit/8df3f765b2df9cbfa1aa4130a126b9315e431c14) Fixed `markdownToHtml`, `mdxToJs` and `markdownToJs` being typed as synchronous when a plugin list mixed sync and async plugins. The result is now correctly typed as a `Promise`. — Thanks @Princesseuh! - [9a164f1](https://github.com/bruits/satteri/commit/9a164f110f2d01c525f9f5c03376508bd227e860) Fixes footnotes being ignored inside directives. A footnote reference nested in a rendered directive (e.g. `:::note … [^id] … :::`) now works like anywhere else (it renders as a footnote link and its definition appears in the footnotes section) instead of being left as literal `[^id]` text. — Thanks @Princesseuh! - [2b85f56](https://github.com/bruits/satteri/commit/2b85f5602fc3340eef9faa3e41c66ff0a03ec8af) Fixed `wrapNode()` silently misplacing or dropping the node when given a parent that cannot hold children: an `html` node, a leaf-shaped custom node, or a void element like ``. These now throw an error explaining what to use instead, and `parentNode` only accepts parent-capable nodes in TypeScript, so most of them are caught before running. - + Wrapping in a container is unchanged: `blockquote` and friends, a HAST element, an MDX JSX element, a custom node declaring a `children` array, and the root itself all keep working. — Thanks @Princesseuh! - - [46e2572](https://github.com/bruits/satteri/commit/46e25721656ec01fe494b62a3c2a5a48f1e45dfb) Fixed a `{` inside an MDX link destination or title raising a parse error when the tail holds an escaped or quoted `)`, as in `[a](\){)`, and stopped a link tail forming from a `[` that is backslash-escaped, inside a code span, already wrapped by another link, or in an earlier block. — Thanks @Princesseuh! - [58add58](https://github.com/bruits/satteri/commit/58add589d8d9dc1c9a774e07519f0e3e7119df34) Fixed nodes created from raw string splices reporting garbage positions; they now report no position, like other plugin-created nodes. — Thanks @Princesseuh! - [9bb585d](https://github.com/bruits/satteri/commit/9bb585d90298f647c4b85babe520e92b5b40c527) Fixed edits to a node another plugin removed being dropped silently instead of with the documented warning. — Thanks @Princesseuh! diff --git a/packages/satteri/index.js b/packages/satteri/index.js index f4668a6d..4f3d4619 100644 --- a/packages/satteri/index.js +++ b/packages/satteri/index.js @@ -81,8 +81,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-android-arm64') const bindingPackageVersion = require('@bruits/satteri-android-arm64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -97,8 +97,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-android-arm-eabi') const bindingPackageVersion = require('@bruits/satteri-android-arm-eabi/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -118,8 +118,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-x64-gnu') const bindingPackageVersion = require('@bruits/satteri-win32-x64-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -134,8 +134,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-x64-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-x64-msvc/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -151,8 +151,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-ia32-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-ia32-msvc/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -167,8 +167,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-arm64-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-arm64-msvc/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -186,8 +186,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-universal') const bindingPackageVersion = require('@bruits/satteri-darwin-universal/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -202,8 +202,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-x64') const bindingPackageVersion = require('@bruits/satteri-darwin-x64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -218,8 +218,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-arm64') const bindingPackageVersion = require('@bruits/satteri-darwin-arm64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -238,8 +238,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-freebsd-x64') const bindingPackageVersion = require('@bruits/satteri-freebsd-x64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -254,8 +254,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-freebsd-arm64') const bindingPackageVersion = require('@bruits/satteri-freebsd-arm64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -275,8 +275,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-x64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-x64-musl/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -291,8 +291,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-x64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-x64-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -309,8 +309,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-arm64-musl/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -325,8 +325,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-arm64-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -343,8 +343,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm-musleabihf') const bindingPackageVersion = require('@bruits/satteri-linux-arm-musleabihf/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -359,8 +359,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm-gnueabihf') const bindingPackageVersion = require('@bruits/satteri-linux-arm-gnueabihf/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -377,8 +377,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-loong64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-loong64-musl/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -393,8 +393,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-loong64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-loong64-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -411,8 +411,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-riscv64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-musl/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -427,8 +427,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-riscv64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -444,8 +444,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-ppc64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-ppc64-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -460,8 +460,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-s390x-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-s390x-gnu/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -480,8 +480,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-arm64') const bindingPackageVersion = require('@bruits/satteri-openharmony-arm64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -496,8 +496,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-x64') const bindingPackageVersion = require('@bruits/satteri-openharmony-x64/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -512,8 +512,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-arm') const bindingPackageVersion = require('@bruits/satteri-openharmony-arm/package.json').version - if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { diff --git a/packages/satteri/src/hast/hast-visitor.ts b/packages/satteri/src/hast/hast-visitor.ts index 09242d11..79bc4bea 100644 --- a/packages/satteri/src/hast/hast-visitor.ts +++ b/packages/satteri/src/hast/hast-visitor.ts @@ -269,12 +269,7 @@ function hastReusedId(node: unknown, refs: NodeRefs): number | undefined { /** Emit a set-children command in place: a root-wrapped child list, the shape * `Patch::SetChildren` splices in. Reused children become refs. */ -function emitHastChildrenCommand( - buffer: CommandBuffer, - id: number, - children: unknown, - refs: NodeRefs, -): boolean { +function emitHastChildrenCommand(buffer: CommandBuffer, id: number, children: unknown, refs: NodeRefs): boolean { if (!Array.isArray(children)) return false; return buffer.emitOpstreamCommand(CMD_SET_CHILDREN, id, () => { buffer.open(HAST_ROOT); @@ -290,13 +285,7 @@ function emitHastChildrenCommand( * payload directly into the command buffer (no intermediate copy). HAST * content is always a declarative node (no raw escape hatch), so it * compiles or it's a hard error. */ -function emitHastTree( - buffer: CommandBuffer, - op: StructuralOp, - id: number, - node: HastNode, - refs: NodeRefs, -): void { +function emitHastTree(buffer: CommandBuffer, op: StructuralOp, id: number, node: HastNode, refs: NodeRefs): void { const ok = buffer.emitOpstreamCommand(STRUCTURAL_CMD[op], id, () => emitHastOp(buffer, node, true, refs), ); @@ -429,8 +418,7 @@ class HastVisitorContextImpl implements HastVisitorContext { // The last node carries the `replace` so refs back to the target still splice. let previous: HastContent | undefined; for (const n of newNode) { - if (previous !== undefined) - emitHastTree(this.#commandBuffer, "insertBefore", id, previous, this.#refs); + if (previous !== undefined) emitHastTree(this.#commandBuffer, "insertBefore", id, previous, this.#refs); previous = n; } if (previous === undefined) { @@ -456,14 +444,12 @@ class HastVisitorContextImpl implements HastVisitorContext { insertBefore(node: HastNode, newNode: HastContent | HastContent[]): void { const id = requireNid(node, "insertBefore", this.#refs); - for (const n of asArray(newNode)) - emitHastTree(this.#commandBuffer, "insertBefore", id, n, this.#refs); + for (const n of asArray(newNode)) emitHastTree(this.#commandBuffer, "insertBefore", id, n, this.#refs); } insertAfter(node: HastNode, newNode: HastContent | HastContent[]): void { const id = requireNid(node, "insertAfter", this.#refs); - for (const n of asArray(newNode)) - emitHastTree(this.#commandBuffer, "insertAfter", id, n, this.#refs); + for (const n of asArray(newNode)) emitHastTree(this.#commandBuffer, "insertAfter", id, n, this.#refs); } wrapNode( @@ -484,14 +470,12 @@ class HastVisitorContextImpl implements HastVisitorContext { prependChild(node: HastNode, childNode: HastContent | HastContent[]): void { const id = requireNid(node, "prependChild", this.#refs); - for (const n of asArray(childNode)) - emitHastTree(this.#commandBuffer, "prependChild", id, n, this.#refs); + for (const n of asArray(childNode)) emitHastTree(this.#commandBuffer, "prependChild", id, n, this.#refs); } appendChild(node: HastNode, childNode: HastContent | HastContent[]): void { const id = requireNid(node, "appendChild", this.#refs); - for (const n of asArray(childNode)) - emitHastTree(this.#commandBuffer, "appendChild", id, n, this.#refs); + for (const n of asArray(childNode)) emitHastTree(this.#commandBuffer, "appendChild", id, n, this.#refs); } insertChildAt(node: HastNode, index: number, childNode: HastContent | HastContent[]): void { @@ -578,7 +562,9 @@ class HastVisitorContextImpl implements HastVisitorContext { parent>(node: Readonly): Readonly; parent(node: Readonly): Readonly | undefined; parent(node: Readonly): Readonly | undefined { - const parentId = this.#resolver.parentIdOf(requireNid(node as HastNode, "parent", this.#refs)); + const parentId = this.#resolver.parentIdOf( + requireNid(node as HastNode, "parent", this.#refs), + ); if (parentId === undefined) return undefined; const byId = (this.#parentsById ??= new Map()); let parent = byId.get(parentId); @@ -1148,7 +1134,11 @@ class HastLazyChildResolver extends LazyChildResolver { return new HastReader(wire); } - protected override materializeNode(reader: HastReader, nodeId: number, refs: NodeRefs): HastNode { + protected override materializeNode( + reader: HastReader, + nodeId: number, + refs: NodeRefs, + ): HastNode { return materializeHastNode(reader, nodeId, true, refs); } diff --git a/packages/satteri/src/materializer-cache.ts b/packages/satteri/src/materializer-cache.ts index 922c0c62..d9985d50 100644 --- a/packages/satteri/src/materializer-cache.ts +++ b/packages/satteri/src/materializer-cache.ts @@ -119,11 +119,7 @@ export function createMaterializer { + function readerCache(reader: TReader, frozen: boolean, refs: NodeRefs | undefined): ReaderCache { let cache = readerCaches.get(reader); if (cache === undefined) { cache = { diff --git a/packages/satteri/src/mdast/mdast-visitor.ts b/packages/satteri/src/mdast/mdast-visitor.ts index 6b4feb8c..0b7a874d 100644 --- a/packages/satteri/src/mdast/mdast-visitor.ts +++ b/packages/satteri/src/mdast/mdast-visitor.ts @@ -220,14 +220,12 @@ export class MdastVisitorContext { insertBefore(node: Readonly, newNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "insertBefore", this.#refs); - for (const n of asArray(newNode)) - emitMdastTree(this.#commandBuffer, "insertBefore", id, n, false, this.#refs); + for (const n of asArray(newNode)) emitMdastTree(this.#commandBuffer, "insertBefore", id, n, false, this.#refs); } insertAfter(node: Readonly, newNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "insertAfter", this.#refs); - for (const n of asArray(newNode)) - emitMdastTree(this.#commandBuffer, "insertAfter", id, n, false, this.#refs); + for (const n of asArray(newNode)) emitMdastTree(this.#commandBuffer, "insertAfter", id, n, false, this.#refs); } /** @@ -249,14 +247,12 @@ export class MdastVisitorContext { prependChild(node: Readonly, childNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "prependChild", this.#refs); - for (const n of asArray(childNode)) - emitMdastTree(this.#commandBuffer, "prependChild", id, n, false, this.#refs); + for (const n of asArray(childNode)) emitMdastTree(this.#commandBuffer, "prependChild", id, n, false, this.#refs); } appendChild(node: Readonly, childNode: MdastContent | MdastContent[]): void { const id = requireNid(node as MdastNode, "appendChild", this.#refs); - for (const n of asArray(childNode)) - emitMdastTree(this.#commandBuffer, "appendChild", id, n, false, this.#refs); + for (const n of asArray(childNode)) emitMdastTree(this.#commandBuffer, "appendChild", id, n, false, this.#refs); } /** Insert one node or an array at `index`; clamps (`0` or less prepends, past the end appends). */ @@ -378,7 +374,9 @@ export class MdastVisitorContext { parent>(node: Readonly): Readonly; parent(node: Readonly): Readonly | undefined; parent(node: Readonly): Readonly | undefined { - const parentId = this.#resolver.parentIdOf(requireNid(node as MdastNode, "parent", this.#refs)); + const parentId = this.#resolver.parentIdOf( + requireNid(node as MdastNode, "parent", this.#refs), + ); if (parentId === undefined) return undefined; const byId = (this.#parentsById ??= new Map()); let parent = byId.get(parentId); @@ -767,12 +765,7 @@ function reusedId(node: unknown, refs: NodeRefs): number | undefined { /** Emit a set-children command in place: a root-wrapped child list, the shape * `Patch::SetChildren` splices in. Reused children become refs. */ -function emitMdastChildrenCommand( - buffer: CommandBuffer, - id: number, - children: unknown, - refs: NodeRefs, -): boolean { +function emitMdastChildrenCommand(buffer: CommandBuffer, id: number, children: unknown, refs: NodeRefs): boolean { if (!Array.isArray(children)) return false; return buffer.emitOpstreamCommand(CMD_SET_CHILDREN, id, () => { buffer.open(MDAST_ROOT); @@ -807,13 +800,7 @@ function emitMdastRootOp(w: OpWriter, n: Record, refs: NodeRefs return true; } -function emitMdastOp( - w: OpWriter, - node: unknown, - isRoot: boolean, - forReplace: boolean, - refs: NodeRefs, -): boolean { +function emitMdastOp(w: OpWriter, node: unknown, isRoot: boolean, forReplace: boolean, refs: NodeRefs): boolean { if (node === null || typeof node !== "object") return false; if (!isRoot) { const id = reusedId(node, refs); @@ -1097,13 +1084,7 @@ export function visitMdastHandle( deferred ??= []; deferred.push({ nodeId, promise: result, originalNode: node }); } else { - applyMdastVisitResult( - result as MdastVisitorResult, - nodeId, - returnBuffer, - resolver.refs, - node, - ); + applyMdastVisitResult(result as MdastVisitorResult, nodeId, returnBuffer, resolver.refs, node); } } diff --git a/packages/satteri/test/conformance/definition-list.test.ts b/packages/satteri/test/conformance/definition-list.test.ts index 149094cb..cc75cc9d 100644 --- a/packages/satteri/test/conformance/definition-list.test.ts +++ b/packages/satteri/test/conformance/definition-list.test.ts @@ -521,10 +521,7 @@ function satteriMdastShape(md: string): NodeShape[] { } function collapseTagWhitespace(h: string): string { - return h - .replace(/>\s+<") - .replace(/\s+<\//g, "\s+<").replace(/\s+<\//g, " { diff --git a/packages/vite-plugin-satteri/CHANGELOG.md b/packages/vite-plugin-satteri/CHANGELOG.md index b8c1572c..924716ac 100644 --- a/packages/vite-plugin-satteri/CHANGELOG.md +++ b/packages/vite-plugin-satteri/CHANGELOG.md @@ -23,25 +23,23 @@ ### Minor changes - [e53e725](https://github.com/bruits/satteri/commit/e53e725e3eca758b5c65364b583c06a96d515510) Added a way to run a plugin only on some documents: a plugin factory now receives the file's `fileURL`, `sourceFormat`, `source` and `data`, and can return `null`, `undefined` or `false` to be left out for that document. Those skip values are also accepted anywhere a plugin entry can appear. - + ```js const onlyChangelogs = (ctx) => ctx.fileURL?.pathname.endsWith("/CHANGELOG.md") ? rewriteVersions : null; - + markdownToHtml(source, { mdastPlugins: [onlyChangelogs, myPlugin] }); ``` - + Anything else in a plugin list now fails with an error naming the option and what it expected. — Thanks @Princesseuh! - - [8df3f76](https://github.com/bruits/satteri/commit/8df3f765b2df9cbfa1aa4130a126b9315e431c14) Added support for nested arrays in `mdastPlugins` and `hastPlugins`, so a package can export a bundle of plugins that you pass without spreading it. A bundle's plugins run in their own order, at the bundle's position. A factory can return a bundle as well as a single plugin, giving its plugins state they share with each other and reset per document. - + ```js import { typography } from "some-package"; // an array of plugins - + markdownToHtml(source, { mdastPlugins: [typography, myPlugin] }); ``` - - — Thanks @Princesseuh! + — Thanks @Princesseuh! ### Patch changes diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2ada96eb..25708a1b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -12,7 +12,7 @@ allowBuilds: minimumReleaseAgeExclude: - satteri - - "@bruits/*" + - '@bruits/*' supportedArchitectures: cpu: diff --git a/website/content/docs/plugin-api.md b/website/content/docs/plugin-api.md index 6c2b4187..baf40333 100644 --- a/website/content/docs/plugin-api.md +++ b/website/content/docs/plugin-api.md @@ -494,7 +494,7 @@ To share state across visits within a document, close over a variable in the sur Each Sätteri plugin walks the tree **once** — there is no re-walking until the tree stops changing. Within that single pass: - **Passed-through children keep their identity.** When a visitor returns a replacement that reuses the original children (e.g. `{ ...node, children: [...node.children] }`), those children are spliced back unchanged, so a transform queued on a nested one in the same pass still applies. This is what lets a single `containerDirective` visitor turn both an outer `:::note` and a nested `:::tip` into asides in one go. -- **A plugin's own freshly-built nodes are not re-walked by that plugin.** A brand-new node a visitor returns isn't visited again by the same plugin. Produce its final shape directly, or hand it to a later plugin — every plugin runs over the fully materialized output of the ones before it. A `before` hook is the exception: it lands before the walk, so nodes it builds _are_ visited. +- **A plugin's own freshly-built nodes are not re-walked by that plugin.** A brand-new node a visitor returns isn't visited again by the same plugin. Produce its final shape directly, or hand it to a later plugin — every plugin runs over the fully materialized output of the ones before it. A `before` hook is the exception: it lands before the walk, so nodes it builds *are* visited. - **Dropping a subtree drops the transforms queued inside it.** If one visitor removes or replaces a node while another queued a transform on something inside that subtree, the orphaned transform is dropped and a warning is logged. Usually that's intended; the warning catches the cases where it isn't. (These can be silenced with the [`warnings` option](/docs/options#compileoptions).) - **Nodes from another document throw.** Handing a context method a node kept from a previous compile — or an mdast node inside a hast plugin — fails the compile. Keep nodes around within a document freely; don't carry them across. - **A few contradictory combinations throw.** Replacing a node with new content that reuses that same node while another plugin edits something inside it in the same pass, two replacements that each reuse the other's node, and inserting a sibling next to the root. Replacing, removing, or wrapping the root itself — say, via `ctx.parent()` on a top-level node — works fine. From a25fb45f4466e74afbcc87c32c936f9b5ffce221 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Tue, 18 Aug 2026 23:54:02 -0400 Subject: [PATCH 07/10] revert unrelated formatting change --- website/content/docs/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/docs/features.md b/website/content/docs/features.md index f9465149..e9a738be 100644 --- a/website/content/docs/features.md +++ b/website/content/docs/features.md @@ -200,7 +200,7 @@ MDX treats `{...}` as a JavaScript expression, which normally collides with the # Welcome {name} ``` -A `{...}` that _is_ valid JavaScript stays an expression even when it looks like attributes: `{hidden}`, `{level=2}` and `{title="Home"}` evaluate rather than apply — silently, and unlike in plain Markdown. Add a `#`/`.` shorthand to force attributes; `{#id hidden}` applies both. +A `{...}` that *is* valid JavaScript stays an expression even when it looks like attributes: `{hidden}`, `{level=2}` and `{title="Home"}` evaluate rather than apply — silently, and unlike in plain Markdown. Add a `#`/`.` shorthand to force attributes; `{#id hidden}` applies both. ## Directives From b337db08dd834dcd0a53afff96b0a6e25b2300ea Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Thu, 20 Aug 2026 21:33:14 -0400 Subject: [PATCH 08/10] move warnings flag to plugins option --- .sampo/changesets/pompous-count-tuoni.md | 2 +- packages/satteri/src/compile.ts | 43 ++++++++----------- packages/satteri/src/visitor-shared.ts | 2 + .../satteri/test/nested-transforms.test.ts | 13 +++++- packages/vite-plugin-satteri/src/index.ts | 13 +----- website/content/docs/options.md | 15 +++---- website/content/docs/plugin-api.md | 2 +- website/content/docs/vite.md | 15 +++---- 8 files changed, 49 insertions(+), 56 deletions(-) diff --git a/.sampo/changesets/pompous-count-tuoni.md b/.sampo/changesets/pompous-count-tuoni.md index 9d663275..65ed5b9e 100644 --- a/.sampo/changesets/pompous-count-tuoni.md +++ b/.sampo/changesets/pompous-count-tuoni.md @@ -3,4 +3,4 @@ npm/satteri: patch npm/vite-plugin-satteri: patch --- -Added `warnings` option to allow opting out of warnings about dropped transforms. +Added `warnings` plugin option to allow opting out of warnings about dropped transforms. diff --git a/packages/satteri/src/compile.ts b/packages/satteri/src/compile.ts index f35d663e..b6878fef 100644 --- a/packages/satteri/src/compile.ts +++ b/packages/satteri/src/compile.ts @@ -75,6 +75,7 @@ import { markHandleMutated } from "./lazy-child-resolver.js"; import { HastReader } from "./hast/hast-reader.js"; import { materializeHastTree } from "./hast/hast-materializer.js"; import type { MdastNode, HastNode, Data, SourceFormat } from "./types.js"; +import type { PluginOptions } from "./visitor-shared.js"; const GFM_PARSE_OPTIONS = ENABLE_TABLES | ENABLE_STRIKETHROUGH | ENABLE_TASKLISTS | ENABLE_GFM; const FRONTMATTER_PARSE_OPTIONS = @@ -167,7 +168,7 @@ type MdastPipelineResult = { pendingCommands?: Uint8Array; /** The plugin whose commands were deferred, for dropped-transform warning * attribution after the fused apply. */ - lastPlugin?: { name?: string }; + lastPlugin?: { name?: string; options?: PluginOptions }; }; /** Free a handle's arena. A plugin's visitor can hand child stubs to user code; @@ -179,10 +180,12 @@ function releaseHandle(handle: AnyHandle, invalidateStubs: boolean): void { } function warnDroppedTransforms( - plugin: { name?: string }, + plugin: { name?: string; options?: PluginOptions }, dropped: number, kind: "mdast" | "hast", ): void { + if (plugin.options && !plugin.options.warnings) return; + const name = plugin.name ?? ""; const noun = dropped === 1 ? "transform" : "transforms"; console.warn( @@ -214,7 +217,6 @@ function runMdastPluginsOnHandle( plugins: MdastPluginDefinition[], fileURL: URL | undefined, data: Data, - warnings: boolean, sourceFormat: SourceFormat, collectLast = false, ): MdastPipelineResult | Promise { @@ -234,12 +236,17 @@ function runMdastPluginsOnHandle( if (!r.hasMutations) return; if (collectLast && isLastPlugin && isFinalPass) { out.pendingCommands = r.commandBuffer; - out.lastPlugin = plugin as { name?: string }; + out.lastPlugin = plugin as { name?: string; options?: PluginOptions }; return; } markHandleMutated(handle); const dropped = applyCommandsToMdastHandle(handle, r.commandBuffer); - if (warnings && dropped) warnDroppedTransforms(plugin as { name?: string }, dropped, "mdast"); + if (dropped) + warnDroppedTransforms( + plugin as { name?: string; options?: PluginOptions }, + dropped, + "mdast", + ); }; const before = typeof plugin.before === "function" ? plugin.before : undefined; @@ -304,7 +311,7 @@ type CollectedHastCommands = { commands: Uint8Array; /** The plugin whose commands were collected, for dropped-transform warning * attribution after the fused apply. */ - lastPlugin: { name?: string } | null; + lastPlugin: { name?: string; options?: PluginOptions } | null; }; const NO_HAST_COMMANDS: CollectedHastCommands = { @@ -322,7 +329,6 @@ function runHastPluginsCollectLast( source: string, fileURL: URL | undefined, data: Data, - warnings: boolean, sourceFormat: SourceFormat, ): CollectedHastCommands | Promise { let i = 0; @@ -343,7 +349,7 @@ function runHastPluginsCollectLast( if (finalPass === undefined) continue; const warnIfDropped = (dropped: number): void => { - if (warnings && dropped) warnDroppedTransforms(plugin, dropped, "hast"); + if (dropped) warnDroppedTransforms(plugin, dropped, "hast"); }; // Threaded like `data`: one context per pass, since a resolver is epoch-bound. const diagnostics: HastDiagnostic[] = []; @@ -619,8 +625,6 @@ export interface CompileOptions { * throwaway object per compile rather than a shared one. */ data?: Data; - /** Display warnings about dropped transforms. Default: true. */ - warnings?: boolean; } /** @@ -786,7 +790,7 @@ export function markdownToHtml( source: string, options: CompileOptions = {}, ): MarkdownToHtmlResult | Promise { - const { features, fileURL, data = {}, warnings = true } = options; + const { features, fileURL, data = {} } = options; const mdastPlugins = normalizePlugins( options.mdastPlugins ?? [], "mdastPlugins", @@ -831,7 +835,6 @@ export function markdownToHtml( mdastPlugins, fileURL, data, - warnings, "markdown", true, ); @@ -846,7 +849,7 @@ export function markdownToHtml( commands, nativeConvertOptions, ); - if (warnings && droppedTransforms && r.lastPlugin) + if (droppedTransforms && r.lastPlugin) warnDroppedTransforms(r.lastPlugin, droppedTransforms, "mdast"); return { html, @@ -878,7 +881,6 @@ export function markdownToHtml( parseOptions, nativeConvertOptions, data, - warnings, trackPositions, ); @@ -896,7 +898,6 @@ export function markdownToHtml( source, fileURL, data, - warnings, "markdown", ); } catch (err) { @@ -924,7 +925,7 @@ export function markdownToHtml( let html: string; if (collected.commands.length > 0) { const result = applyCommandsAndRenderHandle(h, collected.commands); - if (warnings && result.droppedTransforms && collected.lastPlugin) + if (result.droppedTransforms && collected.lastPlugin) warnDroppedTransforms(collected.lastPlugin, result.droppedTransforms, "hast"); html = result.html; } else { @@ -982,7 +983,6 @@ function toJsImpl( features, fileURL, data = {}, - warnings = true, ...mdxFields } = options; const sourceFormat: SourceFormat = mdx ? "mdx" : "markdown"; @@ -1035,7 +1035,6 @@ function toJsImpl( mdastPlugins, fileURL, data, - warnings, mdx ? "mdx" : "markdown", true, ); @@ -1048,7 +1047,7 @@ function toJsImpl( mdxOptions, nativeConvertOptions, ); - if (warnings && droppedTransforms && r.lastPlugin) + if (droppedTransforms && r.lastPlugin) warnDroppedTransforms(r.lastPlugin, droppedTransforms, "mdast"); return { code, @@ -1080,7 +1079,6 @@ function toJsImpl( parseOptions, nativeConvertOptions, data, - warnings, trackPositions, ); @@ -1093,7 +1091,6 @@ function toJsImpl( source, fileURL, data, - warnings, mdx ? "mdx" : "markdown", ); } catch (err) { @@ -1121,7 +1118,7 @@ function toJsImpl( let code: string; if (collected.commands.length > 0) { const result = applyCommandsAndCompileHandle(h, collected.commands, mdxOptions); - if (warnings && result.droppedTransforms && collected.lastPlugin) + if (result.droppedTransforms && collected.lastPlugin) warnDroppedTransforms(collected.lastPlugin, result.droppedTransforms, "hast"); code = result.code; } else { @@ -1197,7 +1194,6 @@ function createHastHandleFromMdast( parseOptions: number, nativeConvertOptions: NativeConvertOptions | undefined, data: Data, - warnings: boolean, trackPositions: boolean, ): HastWithFrontmatter | Promise { if (mdastPlugins.length === 0) { @@ -1242,7 +1238,6 @@ function createHastHandleFromMdast( mdastPlugins, fileURL, data, - warnings, sourceFormat, ); diff --git a/packages/satteri/src/visitor-shared.ts b/packages/satteri/src/visitor-shared.ts index 3b73ffb4..d0125ce2 100644 --- a/packages/satteri/src/visitor-shared.ts +++ b/packages/satteri/src/visitor-shared.ts @@ -15,6 +15,8 @@ export interface PluginOptions { * (~15% faster parse), and `node.position` is `undefined`. */ position?: boolean; + /** Display warnings about dropped transforms. Default: true. */ + warnings?: boolean; } const EMPTY_BYTES = new Uint8Array(0); diff --git a/packages/satteri/test/nested-transforms.test.ts b/packages/satteri/test/nested-transforms.test.ts index d79936ab..f283b065 100644 --- a/packages/satteri/test/nested-transforms.test.ts +++ b/packages/satteri/test/nested-transforms.test.ts @@ -66,6 +66,7 @@ test("dropping a stranded transform warns, naming the plugin", () => { try { const plugin = defineMdastPlugin({ name: "remove-outer", + options: { warnings: false }, containerDirective(node, ctx) { if (node.name === "note") { ctx.removeNode(node); @@ -77,6 +78,11 @@ test("dropping a stranded transform warns, naming the plugin", () => { }, }); markdownToHtml(nestedDirectives, { features, mdastPlugins: [plugin] }); + expect(warn).toHaveBeenCalledTimes(0); + markdownToHtml(nestedDirectives, { + features, + mdastPlugins: [{ ...plugin, options: { warnings: true } }], + }); expect(warn).toHaveBeenCalledTimes(1); const message = warn.mock.calls[0]?.[0] as string; expect(message).toContain('plugin "remove-outer"'); @@ -95,6 +101,7 @@ test("a stranded HAST transform is dropped with a warning, like MDAST", () => { // queued in the same pass. const plugin = defineHastPlugin({ name: "remove-heading", + options: { warnings: false }, element: { filter: ["h1", "em"], visit(node, ctx) { @@ -113,9 +120,11 @@ test("a stranded HAST transform is dropped with a warning, like MDAST", () => { }, }, }); - markdownToHtml("# *Hi*", { hastPlugins: [plugin], warnings: false }); + markdownToHtml(nestedDirectives, { features, mdastPlugins: [plugin] }); expect(warn).toHaveBeenCalledTimes(0); - const { html } = markdownToHtml("# *Hi*", { hastPlugins: [plugin] }); + const { html } = markdownToHtml("# *Hi*", { + hastPlugins: [{ ...plugin, options: { warnings: true } }], + }); expect(html.trim()).toBe(""); // heading + its em gone, no throw expect(warn).toHaveBeenCalledTimes(1); const message = warn.mock.calls[0]?.[0] as string; diff --git a/packages/vite-plugin-satteri/src/index.ts b/packages/vite-plugin-satteri/src/index.ts index dd8f531d..e4c983c3 100644 --- a/packages/vite-plugin-satteri/src/index.ts +++ b/packages/vite-plugin-satteri/src/index.ts @@ -43,8 +43,6 @@ export interface VitePluginSatteriOptions { hastPlugins?: HastPluginList; /** Parser feature toggles (gfm, frontmatter, math, …). Shared across .md and .mdx. */ features?: Features; - /** Display warnings about dropped transforms. Default: true. */ - warnings?: boolean; } const MD_RE = /\.md(?:\?|$)/; @@ -58,14 +56,7 @@ function parseFrontmatter(fm: Frontmatter | null): unknown { } export default function vitePluginSatteri(options: VitePluginSatteriOptions = {}): Plugin { - const { - markdown = true, - mdx = true, - mdastPlugins, - hastPlugins, - features, - warnings = true, - } = options; + const { markdown = true, mdx = true, mdastPlugins, hastPlugins, features } = options; const mdxEnabled = mdx !== false; const mdxOptions: MdxOptions = typeof mdx === "object" ? mdx : {}; @@ -90,7 +81,6 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} const isDev = mdxOptions.development ?? viteConfig?.command === "serve"; const opts: MdxCompileOptions = { fileURL, - warnings, development: isDev, ...(mdastPlugins ? { mdastPlugins } : {}), ...(hastPlugins ? { hastPlugins } : {}), @@ -118,7 +108,6 @@ export default function vitePluginSatteri(options: VitePluginSatteriOptions = {} const opts: CompileOptions = { fileURL, - warnings, ...(mdastPlugins ? { mdastPlugins } : {}), ...(hastPlugins ? { hastPlugins } : {}), ...(features ? { features } : {}), diff --git a/website/content/docs/options.md b/website/content/docs/options.md index d2585bae..bc2b9c35 100644 --- a/website/content/docs/options.md +++ b/website/content/docs/options.md @@ -9,14 +9,13 @@ Options for Sätteri's [entry points](/docs/entry-points/). `CompileOptions` is ## CompileOptions -| Option | Type | Notes | -| -------------- | ----------------- | ----------------------------------------------------------------------------------------------------- | -| `mdastPlugins` | `MdastPluginList` | MDAST-stage plugins. See [What an entry can be](/docs/plugins/#what-an-entry-can-be). | -| `hastPlugins` | `HastPluginList` | HAST-stage plugins, same entry shapes as `mdastPlugins`. | -| `features` | `Features` | Parser extensions. See [Features](/docs/features/). | -| `fileURL` | `URL` | The document's URL, surfaced to plugins as `ctx.fileURL`. | -| `data` | `Data` | Initial [data bag](#data). | -| `warnings` | `boolean` | Display warnings about [dropped transforms](/docs/plugin-api/#how-transforms-compose). Default: true. | +| Option | Type | Notes | +| -------------- | ----------------- | ------------------------------------------------------------------------------------- | +| `mdastPlugins` | `MdastPluginList` | MDAST-stage plugins. See [What an entry can be](/docs/plugins/#what-an-entry-can-be). | +| `hastPlugins` | `HastPluginList` | HAST-stage plugins, same entry shapes as `mdastPlugins`. | +| `features` | `Features` | Parser extensions. See [Features](/docs/features/). | +| `fileURL` | `URL` | The document's URL, surfaced to plugins as `ctx.fileURL`. | +| `data` | `Data` | Initial [data bag](#data). | ### fileURL diff --git a/website/content/docs/plugin-api.md b/website/content/docs/plugin-api.md index baf40333..1f574cd4 100644 --- a/website/content/docs/plugin-api.md +++ b/website/content/docs/plugin-api.md @@ -495,6 +495,6 @@ Each Sätteri plugin walks the tree **once** — there is no re-walking until th - **Passed-through children keep their identity.** When a visitor returns a replacement that reuses the original children (e.g. `{ ...node, children: [...node.children] }`), those children are spliced back unchanged, so a transform queued on a nested one in the same pass still applies. This is what lets a single `containerDirective` visitor turn both an outer `:::note` and a nested `:::tip` into asides in one go. - **A plugin's own freshly-built nodes are not re-walked by that plugin.** A brand-new node a visitor returns isn't visited again by the same plugin. Produce its final shape directly, or hand it to a later plugin — every plugin runs over the fully materialized output of the ones before it. A `before` hook is the exception: it lands before the walk, so nodes it builds *are* visited. -- **Dropping a subtree drops the transforms queued inside it.** If one visitor removes or replaces a node while another queued a transform on something inside that subtree, the orphaned transform is dropped and a warning is logged. Usually that's intended; the warning catches the cases where it isn't. (These can be silenced with the [`warnings` option](/docs/options#compileoptions).) +- **Dropping a subtree drops the transforms queued inside it.** If one visitor removes or replaces a node while another queued a transform on something inside that subtree, the orphaned transform is dropped and a warning is logged. Usually that's intended; the warning catches the cases where it isn't. Warnings can be silenced with `options: { warnings: false }` for the plugin in question. - **Nodes from another document throw.** Handing a context method a node kept from a previous compile — or an mdast node inside a hast plugin — fails the compile. Keep nodes around within a document freely; don't carry them across. - **A few contradictory combinations throw.** Replacing a node with new content that reuses that same node while another plugin edits something inside it in the same pass, two replacements that each reuse the other's node, and inserting a sibling next to the root. Replacing, removing, or wrapping the root itself — say, via `ctx.parent()` on a top-level node — works fine. diff --git a/website/content/docs/vite.md b/website/content/docs/vite.md index 566268d7..e668f9d7 100644 --- a/website/content/docs/vite.md +++ b/website/content/docs/vite.md @@ -79,14 +79,13 @@ By default, the plugin compiles MDX with `development: true` in `serve` so React ## Options -| Option | Type | Default | Effect | -| -------------- | ----------------------- | ------- | ------------------------------------------------------------------------------------- | -| `markdown` | `boolean` | `true` | Process `.md` files. | -| `mdx` | `boolean \| MdxOptions` | `true` | Process `.mdx` files. Pass an object to configure the compile. | -| `mdastPlugins` | `MdastPluginList` | — | MDAST-stage plugins, shared across `.md` and `.mdx`. | -| `hastPlugins` | `HastPluginList` | — | HAST-stage plugins, shared across `.md` and `.mdx`. | -| `features` | `Features` | — | Parser toggles. See [Features](/docs/features/). | -| `warnings` | `boolean` | `true` | Display warnings about [dropped transforms](/docs/plugin-api#how-transforms-compose). | +| Option | Type | Default | Effect | +| -------------- | ----------------------- | ------- | -------------------------------------------------------------- | +| `markdown` | `boolean` | `true` | Process `.md` files. | +| `mdx` | `boolean \| MdxOptions` | `true` | Process `.mdx` files. Pass an object to configure the compile. | +| `mdastPlugins` | `MdastPluginList` | — | MDAST-stage plugins, shared across `.md` and `.mdx`. | +| `hastPlugins` | `HastPluginList` | — | HAST-stage plugins, shared across `.md` and `.mdx`. | +| `features` | `Features` | — | Parser toggles. See [Features](/docs/features/). | `MdxOptions` mirrors Sätteri's MDX options minus `outputFormat`. The plugin always emits an ES module so Vite can import it. From fcdeafd9e667b36586ce508a4116cda8ca5026d4 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Thu, 20 Aug 2026 21:40:24 -0400 Subject: [PATCH 09/10] revert unrelated changes --- packages/satteri/index.js | 104 ++++++++++++++++---------------- website/content/docs/options.md | 14 ++--- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/packages/satteri/index.js b/packages/satteri/index.js index 4f3d4619..f4668a6d 100644 --- a/packages/satteri/index.js +++ b/packages/satteri/index.js @@ -81,8 +81,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-android-arm64') const bindingPackageVersion = require('@bruits/satteri-android-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -97,8 +97,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-android-arm-eabi') const bindingPackageVersion = require('@bruits/satteri-android-arm-eabi/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -118,8 +118,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-x64-gnu') const bindingPackageVersion = require('@bruits/satteri-win32-x64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -134,8 +134,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-x64-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-x64-msvc/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -151,8 +151,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-ia32-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-ia32-msvc/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -167,8 +167,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-win32-arm64-msvc') const bindingPackageVersion = require('@bruits/satteri-win32-arm64-msvc/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -186,8 +186,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-universal') const bindingPackageVersion = require('@bruits/satteri-darwin-universal/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -202,8 +202,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-x64') const bindingPackageVersion = require('@bruits/satteri-darwin-x64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -218,8 +218,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-darwin-arm64') const bindingPackageVersion = require('@bruits/satteri-darwin-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -238,8 +238,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-freebsd-x64') const bindingPackageVersion = require('@bruits/satteri-freebsd-x64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -254,8 +254,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-freebsd-arm64') const bindingPackageVersion = require('@bruits/satteri-freebsd-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -275,8 +275,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-x64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-x64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -291,8 +291,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-x64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-x64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -309,8 +309,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-arm64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -325,8 +325,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-arm64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -343,8 +343,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm-musleabihf') const bindingPackageVersion = require('@bruits/satteri-linux-arm-musleabihf/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -359,8 +359,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-arm-gnueabihf') const bindingPackageVersion = require('@bruits/satteri-linux-arm-gnueabihf/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -377,8 +377,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-loong64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-loong64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -393,8 +393,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-loong64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-loong64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -411,8 +411,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-riscv64-musl') const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-musl/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -427,8 +427,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-riscv64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-riscv64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -444,8 +444,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-ppc64-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-ppc64-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -460,8 +460,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-linux-s390x-gnu') const bindingPackageVersion = require('@bruits/satteri-linux-s390x-gnu/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -480,8 +480,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-arm64') const bindingPackageVersion = require('@bruits/satteri-openharmony-arm64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -496,8 +496,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-x64') const bindingPackageVersion = require('@bruits/satteri-openharmony-x64/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -512,8 +512,8 @@ function requireNative() { try { const binding = require('@bruits/satteri-openharmony-arm') const bindingPackageVersion = require('@bruits/satteri-openharmony-arm/package.json').version - if (bindingPackageVersion !== '0.9.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 0.9.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { diff --git a/website/content/docs/options.md b/website/content/docs/options.md index bc2b9c35..a937331b 100644 --- a/website/content/docs/options.md +++ b/website/content/docs/options.md @@ -9,13 +9,13 @@ Options for Sätteri's [entry points](/docs/entry-points/). `CompileOptions` is ## CompileOptions -| Option | Type | Notes | -| -------------- | ----------------- | ------------------------------------------------------------------------------------- | -| `mdastPlugins` | `MdastPluginList` | MDAST-stage plugins. See [What an entry can be](/docs/plugins/#what-an-entry-can-be). | -| `hastPlugins` | `HastPluginList` | HAST-stage plugins, same entry shapes as `mdastPlugins`. | -| `features` | `Features` | Parser extensions. See [Features](/docs/features/). | -| `fileURL` | `URL` | The document's URL, surfaced to plugins as `ctx.fileURL`. | -| `data` | `Data` | Initial [data bag](#data). | +| Option | Type | Notes | +| -------------- | ----------------- | --------------------------------------------------------------------------------------------- | +| `mdastPlugins` | `MdastPluginList` | MDAST-stage plugins. See [What an entry can be](/docs/plugins/#what-an-entry-can-be). | +| `hastPlugins` | `HastPluginList` | HAST-stage plugins, same entry shapes as `mdastPlugins`. | +| `features` | `Features` | Parser extensions. See [Features](/docs/features/). | +| `fileURL` | `URL` | The document's URL, surfaced to plugins as `ctx.fileURL`. | +| `data` | `Data` | Initial [data bag](#data). | ### fileURL From f9800df2ff6a8bd7965acd1658e6d9964f8a711d Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Thu, 20 Aug 2026 23:39:03 -0400 Subject: [PATCH 10/10] update changeset --- .sampo/changesets/pompous-count-tuoni.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.sampo/changesets/pompous-count-tuoni.md b/.sampo/changesets/pompous-count-tuoni.md index 65ed5b9e..dfb3a280 100644 --- a/.sampo/changesets/pompous-count-tuoni.md +++ b/.sampo/changesets/pompous-count-tuoni.md @@ -1,6 +1,5 @@ --- npm/satteri: patch -npm/vite-plugin-satteri: patch --- Added `warnings` plugin option to allow opting out of warnings about dropped transforms.