satteri 0.10.5 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +11 -0
  2. package/dist/arena-reader.d.ts +13 -0
  3. package/dist/arena-reader.js +104 -0
  4. package/dist/binding.browser.d.ts +1 -1
  5. package/dist/binding.browser.js +1 -1
  6. package/dist/binding.d.ts +1 -1
  7. package/dist/binding.js +1 -1
  8. package/dist/byte-writer.d.ts +0 -18
  9. package/dist/byte-writer.js +6 -30
  10. package/dist/child-stub.d.ts +0 -17
  11. package/dist/child-stub.js +6 -22
  12. package/dist/command-buffer.d.ts +5 -26
  13. package/dist/command-buffer.js +28 -39
  14. package/dist/compile-options.d.ts +11 -0
  15. package/dist/compile-options.js +101 -0
  16. package/dist/compile-types.d.ts +342 -0
  17. package/dist/compile-types.js +1 -0
  18. package/dist/compile.d.ts +22 -328
  19. package/dist/compile.js +133 -383
  20. package/dist/directive-types.d.ts +1 -0
  21. package/dist/directive-types.js +1 -6
  22. package/dist/generated/arena-layout.d.ts +6 -4
  23. package/dist/generated/arena-layout.js +6 -7
  24. package/dist/generated/fused-wire.d.ts +3 -0
  25. package/dist/generated/fused-wire.js +229 -0
  26. package/dist/generated/parse-options.d.ts +1 -0
  27. package/dist/generated/parse-options.js +1 -5
  28. package/dist/generated/wire-constants.d.ts +4 -0
  29. package/dist/generated/wire-constants.js +34 -42
  30. package/dist/handles.d.ts +0 -7
  31. package/dist/hast/child-stub.d.ts +1 -8
  32. package/dist/hast/child-stub.js +14 -13
  33. package/dist/hast/element-props.d.ts +13 -0
  34. package/dist/hast/element-props.js +52 -6
  35. package/dist/hast/generated/node-types.d.ts +1 -9
  36. package/dist/hast/generated/node-types.js +1 -9
  37. package/dist/hast/generated/walk-decode.d.ts +10 -0
  38. package/dist/hast/generated/walk-decode.js +61 -0
  39. package/dist/hast/hast-materializer.d.ts +3 -10
  40. package/dist/hast/hast-materializer.js +73 -47
  41. package/dist/hast/hast-reader.d.ts +9 -38
  42. package/dist/hast/hast-reader.js +82 -271
  43. package/dist/hast/hast-visitor.d.ts +29 -16
  44. package/dist/hast/hast-visitor.js +200 -508
  45. package/dist/hast/hast-walk.d.ts +18 -0
  46. package/dist/hast/hast-walk.js +264 -0
  47. package/dist/index.d.ts +5 -5
  48. package/dist/index.js +4 -12
  49. package/dist/lazy-child-resolver.d.ts +1 -21
  50. package/dist/lazy-child-resolver.js +11 -32
  51. package/dist/materializer-cache.d.ts +5 -29
  52. package/dist/materializer-cache.js +29 -101
  53. package/dist/mdast/child-stub.d.ts +1 -12
  54. package/dist/mdast/child-stub.js +18 -28
  55. package/dist/mdast/column-align.d.ts +1 -1
  56. package/dist/mdast/column-align.js +0 -2
  57. package/dist/mdast/generated/layout.d.ts +0 -16
  58. package/dist/mdast/generated/layout.js +6 -47
  59. package/dist/mdast/generated/node-types.d.ts +1 -9
  60. package/dist/mdast/generated/node-types.js +3 -9
  61. package/dist/mdast/mdast-materializer.d.ts +3 -11
  62. package/dist/mdast/mdast-materializer.js +91 -63
  63. package/dist/mdast/mdast-reader.d.ts +15 -63
  64. package/dist/mdast/mdast-reader.js +132 -269
  65. package/dist/mdast/mdast-visitor.d.ts +23 -15
  66. package/dist/mdast/mdast-visitor.js +189 -294
  67. package/dist/mdast/mdast-walk.d.ts +13 -0
  68. package/dist/mdast/mdast-walk.js +144 -0
  69. package/dist/mdx-attr.js +0 -3
  70. package/dist/mdx-types.js +1 -6
  71. package/dist/op-stream.d.ts +4 -15
  72. package/dist/op-stream.js +31 -20
  73. package/dist/phantom.d.ts +0 -1
  74. package/dist/phantom.js +1 -9
  75. package/dist/plugin-pipeline.d.ts +32 -0
  76. package/dist/plugin-pipeline.js +177 -0
  77. package/dist/plugin.d.ts +14 -8
  78. package/dist/plugin.js +5 -10
  79. package/dist/types.d.ts +0 -1
  80. package/dist/visitor-node.d.ts +12 -0
  81. package/dist/visitor-node.js +23 -0
  82. package/dist/visitor-shared.d.ts +26 -30
  83. package/dist/visitor-shared.js +34 -36
  84. package/dist/wire-read.d.ts +0 -22
  85. package/dist/wire-read.js +3 -24
  86. package/index.d.ts +19 -10
  87. package/index.js +56 -53
  88. package/package.json +6 -12
  89. package/dist/string-pool.d.ts +0 -13
  90. package/dist/string-pool.js +0 -91
@@ -0,0 +1,101 @@
1
+ import { ENABLE_ATTRIBUTES, ENABLE_DEFINITION_LIST, ENABLE_DIRECTIVE, ENABLE_FOOTNOTES, ENABLE_GFM, ENABLE_HEADING_ATTRIBUTES, ENABLE_MATH, ENABLE_MATH_MULTI_DOLLAR, ENABLE_PLUSES_DELIMITED_METADATA_BLOCKS, ENABLE_SMART_DASHES, ENABLE_SMART_ELLIPSES, ENABLE_SMART_PUNCTUATION, ENABLE_SMART_QUOTES, ENABLE_STRIKETHROUGH, ENABLE_SUBSCRIPT, ENABLE_SUPERSCRIPT, ENABLE_TABLES, ENABLE_TASKLISTS, ENABLE_WIKILINKS, ENABLE_YAML_STYLE_METADATA_BLOCKS, } from "./generated/parse-options.js";
2
+ const GFM_PARSE_OPTIONS = ENABLE_TABLES | ENABLE_STRIKETHROUGH | ENABLE_TASKLISTS | ENABLE_GFM;
3
+ const FRONTMATTER_PARSE_OPTIONS = ENABLE_YAML_STYLE_METADATA_BLOCKS | ENABLE_PLUSES_DELIMITED_METADATA_BLOCKS;
4
+ export const DEFAULT_PARSE_OPTIONS = GFM_PARSE_OPTIONS | ENABLE_FOOTNOTES | FRONTMATTER_PARSE_OPTIONS;
5
+ function featuresToParseOptions(features) {
6
+ let options = 0;
7
+ const { gfm } = features;
8
+ if (typeof gfm === "object") {
9
+ options |= GFM_PARSE_OPTIONS;
10
+ if (gfm.footnotes !== false)
11
+ options |= ENABLE_FOOTNOTES;
12
+ }
13
+ else if (gfm ?? true) {
14
+ options |= GFM_PARSE_OPTIONS | ENABLE_FOOTNOTES;
15
+ }
16
+ if (features.frontmatter ?? true)
17
+ options |= FRONTMATTER_PARSE_OPTIONS;
18
+ const { math } = features;
19
+ if (typeof math === "object") {
20
+ options |= math.singleDollarTextMath === false ? ENABLE_MATH_MULTI_DOLLAR : ENABLE_MATH;
21
+ }
22
+ else if (math) {
23
+ options |= ENABLE_MATH;
24
+ }
25
+ if (features.headingAttributes)
26
+ options |= ENABLE_HEADING_ATTRIBUTES;
27
+ if (features.attributes)
28
+ options |= ENABLE_ATTRIBUTES;
29
+ if (features.directive)
30
+ options |= ENABLE_DIRECTIVE;
31
+ if (features.superscript)
32
+ options |= ENABLE_SUPERSCRIPT;
33
+ if (features.subscript)
34
+ options |= ENABLE_SUBSCRIPT;
35
+ if (features.wikilinks)
36
+ options |= ENABLE_WIKILINKS;
37
+ if (features.definitionList)
38
+ options |= ENABLE_DEFINITION_LIST;
39
+ const smartPunctuation = features.smartPunctuation;
40
+ if (typeof smartPunctuation === "object") {
41
+ if (smartPunctuation.quotes ?? true)
42
+ options |= ENABLE_SMART_QUOTES;
43
+ if (smartPunctuation.dashes ?? true)
44
+ options |= ENABLE_SMART_DASHES;
45
+ if (smartPunctuation.ellipses ?? true)
46
+ options |= ENABLE_SMART_ELLIPSES;
47
+ }
48
+ else if (smartPunctuation) {
49
+ options |= ENABLE_SMART_PUNCTUATION;
50
+ }
51
+ return options;
52
+ }
53
+ export function featuresToNative(features) {
54
+ if (!features)
55
+ return { parseOptions: DEFAULT_PARSE_OPTIONS, convertOptions: undefined };
56
+ let convertOptions;
57
+ const { gfm } = features;
58
+ if (typeof gfm === "object" && typeof gfm.footnotes === "object") {
59
+ const { label, backContent, backLabel, clobberPrefix } = gfm.footnotes;
60
+ convertOptions = {};
61
+ if (label !== undefined)
62
+ convertOptions.footnoteLabel = label;
63
+ if (backContent !== undefined)
64
+ convertOptions.footnoteBackContent = backContent;
65
+ if (backLabel !== undefined)
66
+ convertOptions.footnoteBackLabel = backLabel;
67
+ if (clobberPrefix !== undefined)
68
+ convertOptions.clobberPrefix = clobberPrefix;
69
+ }
70
+ if (features.rawHtml !== undefined) {
71
+ // Conversion options must carry rawHtml so tree APIs and compile pipelines apply the same reparse.
72
+ convertOptions = convertOptions ?? {};
73
+ convertOptions.rawHtml = features.rawHtml;
74
+ }
75
+ return { parseOptions: featuresToParseOptions(features), convertOptions };
76
+ }
77
+ const MDX_NATIVE_OPTION_KEYS = [
78
+ "optimizeStatic",
79
+ "jsxImportSource",
80
+ "jsx",
81
+ "jsxRuntime",
82
+ "development",
83
+ "providerImportSource",
84
+ "pragma",
85
+ "pragmaFrag",
86
+ "pragmaImportSource",
87
+ "outputFormat",
88
+ "elementAttributeNameCase",
89
+ "stylePropertyNameCase",
90
+ ];
91
+ export function mdxOptionsToNative(opts) {
92
+ let result;
93
+ const copyOption = (key) => {
94
+ const value = opts[key];
95
+ if (value === undefined || (key === "optimizeStatic" && !value))
96
+ return;
97
+ (result ??= {})[key] = value;
98
+ };
99
+ MDX_NATIVE_OPTION_KEYS.forEach(copyOption);
100
+ return result;
101
+ }
@@ -0,0 +1,342 @@
1
+ import type { HastPluginList, MdastPluginList } from "./plugin.js";
2
+ import type { Data } from "./types.js";
3
+ /** Configuration for static subtree collapsing during MDX compilation. */
4
+ export interface OptimizeStaticConfig {
5
+ component: string;
6
+ prop: string;
7
+ wrapPropValue?: boolean;
8
+ ignoreElements?: string[];
9
+ }
10
+ /** Granular smart-punctuation toggles. Omitted fields default to true. */
11
+ export interface SmartPunctuationOptions {
12
+ /** Replace straight quotes with curly/smart quotes. Default: true. */
13
+ quotes?: boolean;
14
+ /** Replace `--`/`---` with en-dash/em-dash. Default: true. */
15
+ dashes?: boolean;
16
+ /** Replace `...` with ellipsis (`…`). Default: true. */
17
+ ellipses?: boolean;
18
+ }
19
+ /**
20
+ * Per-backref callback. Invoked once per anchor in the footnotes section
21
+ * with 1-based `referenceNumber` and `rerunIndex` (1 on the first backref
22
+ * to that definition, 2 on the second, and so on). Must return the final
23
+ * string used as the backref content or `aria-label`.
24
+ */
25
+ export type FootnoteBackrefCallback = (referenceNumber: number, rerunIndex: number) => string;
26
+ /**
27
+ * i18n strings for the GFM footnotes section. Mirrors `footnoteLabel`,
28
+ * `footnoteBackLabel`, and `footnoteBackContent` from remark-rehype.
29
+ *
30
+ * `backContent` and `backLabel` each accept either a template string with
31
+ * the `{reference}` placeholder (substituted with `1` or `1-2` to match
32
+ * remark-rehype's default suffix), or a callback receiving the raw
33
+ * `(referenceNumber, rerunIndex)` pair.
34
+ *
35
+ * Passing this object enables footnotes. To turn them off, use
36
+ * `gfm: { footnotes: false }`.
37
+ */
38
+ export interface FootnoteOptions {
39
+ /** `<h2>` label opening the footnotes section. Default: `"Footnotes"`. */
40
+ label?: string;
41
+ /**
42
+ * Backref `<a>` content. Default: `"↩"`.
43
+ *
44
+ * Template form: the string is used as-is, and a `<sup>K</sup>` marker
45
+ * is auto-appended on reruns (k > 1). Callback form: returns the full
46
+ * content for each backref; no auto-sup is added.
47
+ */
48
+ backContent?: string | FootnoteBackrefCallback;
49
+ /**
50
+ * Backref `aria-label`. Default: `"Back to reference {reference}"`.
51
+ *
52
+ * Template form: `{reference}` becomes `n` for the first backref, `n-K`
53
+ * for subsequent ones. Callback form: returns the `aria-label` string
54
+ * for each backref.
55
+ */
56
+ backLabel?: string | FootnoteBackrefCallback;
57
+ /** Prefix applied to footnote IDs to prevent DOM clobbering. Default: `"user-content-"`. */
58
+ clobberPrefix?: string;
59
+ }
60
+ /** Granular GFM toggles, nested under {@link Features.gfm}. */
61
+ export interface GfmOptions {
62
+ /**
63
+ * Enable GFM footnotes (`[^id]`). Default: true.
64
+ *
65
+ * Pass `false` to drop footnote parsing while keeping the rest of GFM;
66
+ * pass an object to enable footnotes with custom i18n strings (see
67
+ * {@link FootnoteOptions}).
68
+ */
69
+ footnotes?: boolean | FootnoteOptions;
70
+ }
71
+ /** Granular math toggles, nested under {@link Features.math}. */
72
+ export interface MathOptions {
73
+ /**
74
+ * Treat single-dollar runs (`$ ... $`) as inline math. Default: true.
75
+ *
76
+ * Set `false` to keep single `$` as literal text while still parsing
77
+ * `$$ ... $$` display math. Mirrors `singleDollarTextMath` from
78
+ * remark-math.
79
+ */
80
+ singleDollarTextMath?: boolean;
81
+ }
82
+ /** Parser feature toggles. All default to their documented value when omitted. */
83
+ export interface Features {
84
+ /**
85
+ * GFM: tables, footnotes, strikethrough, task lists. Default: true.
86
+ *
87
+ * Pass an options object for granular control:
88
+ * ```ts
89
+ * gfm: { footnotes: false } // skip footnotes only
90
+ * gfm: { footnotes: { label: "Notes" } } // localize footnotes
91
+ * ```
92
+ */
93
+ gfm?: boolean | GfmOptions;
94
+ /** Frontmatter: YAML (`--- ... ---`) and TOML (`+++ ... +++`). Default: true. */
95
+ frontmatter?: boolean;
96
+ /**
97
+ * Math blocks and inline math. Default: false.
98
+ *
99
+ * Pass an options object for granular control:
100
+ * ```ts
101
+ * math: { singleDollarTextMath: false } // $$..$$ only, $..$ literal
102
+ * ```
103
+ */
104
+ math?: boolean | MathOptions;
105
+ /**
106
+ * Heading attributes (`# text { #id .class }`). Default: false.
107
+ *
108
+ * @deprecated Use {@link Features.attributes}, which reads heading attributes
109
+ * as well as attributes on other elements.
110
+ */
111
+ headingAttributes?: boolean;
112
+ /**
113
+ * Curly-brace attributes (`{#id .class key=value}`) on fenced code blocks
114
+ * (` ```js {.class} `), inline elements (`*em*{.class}`), and paragraphs,
115
+ * list items, lists, blockquotes, tables, table cells and thematic breaks,
116
+ * as well as on headings. Default: false.
117
+ */
118
+ attributes?: boolean;
119
+ /** Colon-delimited container directive blocks (`:::`). Default: false. */
120
+ directive?: boolean;
121
+ /** Superscript (`^super^`). Default: false. */
122
+ superscript?: boolean;
123
+ /** Subscript (`~sub~`). Default: false. */
124
+ subscript?: boolean;
125
+ /** Obsidian-style wikilinks (`[[link]]`). Default: false. */
126
+ wikilinks?: boolean;
127
+ /** Definition lists (a term line then a `: definition`). Default: false. */
128
+ definitionList?: boolean;
129
+ /**
130
+ * Smart punctuation à la SmartyPants. Default: false.
131
+ *
132
+ * Pass `true` to enable all categories, or an options object for granular control:
133
+ * ```ts
134
+ * smartPunctuation: { dashes: false } // quotes + ellipses only
135
+ * ```
136
+ */
137
+ smartPunctuation?: boolean | SmartPunctuationOptions;
138
+ /**
139
+ * Parse raw HTML embedded in Markdown into real HAST element nodes.
140
+ * Default: false.
141
+ *
142
+ * By default, inline and block HTML is kept as opaque `raw` nodes
143
+ * (re-emitted verbatim on stringify). With `rawHtml: true`, the tree is
144
+ * reparsed so raw HTML becomes structured `element`/`text`/`comment` nodes
145
+ * with normalized properties, including tags that open in one raw block
146
+ * and close in another. Positions are not preserved through the reparse.
147
+ */
148
+ rawHtml?: boolean;
149
+ }
150
+ export interface CompileOptions {
151
+ /** MDAST plugins, in run order. A nested array runs its own plugins, in
152
+ * their own order, at the array's position. */
153
+ mdastPlugins?: MdastPluginList;
154
+ /** HAST plugins, in run order. Nests like `mdastPlugins`. */
155
+ hastPlugins?: HastPluginList;
156
+ features?: Features;
157
+ /**
158
+ * The document being processed, surfaced to plugins as `ctx.fileURL`. Must
159
+ * be a `URL` (e.g. Astro's `fileURL`); convert a filesystem path with Node's
160
+ * `pathToFileURL` before passing it.
161
+ */
162
+ fileURL?: URL;
163
+ /**
164
+ * Initial document-level data bag, seeding `ctx.data` before any plugin runs.
165
+ * It is the same object plugins mutate and the caller reads back as
166
+ * `result.data`, so values flow both into and out of a compile. Defaults to a
167
+ * fresh empty object. Used by reference and mutated in place, so pass a
168
+ * throwaway object per compile rather than a shared one.
169
+ */
170
+ data?: Data;
171
+ }
172
+ /**
173
+ * JS/JSX output options, accepted by both {@link mdxToJs} and
174
+ * {@link markdownToJs}. Exported on its own so wrappers can expose the codegen
175
+ * knobs without the shared pipeline fields.
176
+ */
177
+ export interface MdxOnlyOptions {
178
+ optimizeStatic?: OptimizeStaticConfig;
179
+ /** Place to import automatic JSX runtimes from (e.g. "react", "preact"). Default: "react". */
180
+ jsxImportSource?: string;
181
+ /** Whether to keep JSX instead of compiling it to functions. Default: false. */
182
+ jsx?: boolean;
183
+ /** JSX runtime: "automatic" (default) or "classic". */
184
+ jsxRuntime?: "automatic" | "classic";
185
+ /** Enable development mode. Default: false. */
186
+ development?: boolean;
187
+ /** Place to import the component provider from. */
188
+ providerImportSource?: string;
189
+ /** Pragma for JSX in classic runtime (default: "React.createElement"). */
190
+ pragma?: string;
191
+ /** Pragma for JSX fragments in classic runtime (default: "React.Fragment"). */
192
+ pragmaFrag?: string;
193
+ /** Where to import the pragma from in classic runtime (default: "react"). */
194
+ pragmaImportSource?: string;
195
+ /**
196
+ * Output format: "program" (default) or "function-body".
197
+ *
198
+ * - `"program"`: ES module with `import`/`export` statements.
199
+ * - `"function-body"`: Function body that reads runtime from `arguments[0]`
200
+ * and returns `{ default: MDXContent, ...exports }`. Suitable for
201
+ * `new Function()` or `evaluate()`.
202
+ */
203
+ outputFormat?: "program" | "function-body";
204
+ /**
205
+ * Casing for HTML/SVG attribute names on plain (rehype-produced) elements.
206
+ *
207
+ * - `"react"` (default): `className`, `htmlFor`, `strokeLinecap`, `xmlLang`.
208
+ * - `"html"`: `class`, `for`, `stroke-linecap`, `xml:lang`.
209
+ *
210
+ * Does not affect attributes on user-written MDX JSX; those are emitted as
211
+ * the author wrote them.
212
+ */
213
+ elementAttributeNameCase?: "react" | "html";
214
+ /**
215
+ * Casing for keys in `style` objects parsed from `style="…"` strings on
216
+ * plain (rehype-produced) elements.
217
+ *
218
+ * - `"dom"` (default): `{backgroundColor: …, WebkitLineClamp: …}`.
219
+ * - `"css"`: `{"background-color": …, "-webkit-line-clamp": …}`.
220
+ */
221
+ stylePropertyNameCase?: "dom" | "css";
222
+ }
223
+ export interface MdxCompileOptions extends CompileOptions, MdxOnlyOptions {
224
+ }
225
+ export interface MarkdownToJsOptions extends CompileOptions, MdxOnlyOptions {
226
+ }
227
+ /** Frontmatter block extracted from the parsed Markdown/MDX source. */
228
+ export interface Frontmatter {
229
+ /** Delimiter syntax used for the block. */
230
+ kind: "yaml" | "toml";
231
+ /** Raw content between the delimiters (`---`/`+++` lines excluded). */
232
+ value: string;
233
+ }
234
+ /** Result of {@link markdownToHtml}. */
235
+ export interface MarkdownToHtmlResult {
236
+ /** Rendered HTML string. */
237
+ html: string;
238
+ /** Frontmatter block at the start of the document, or `null` if none. */
239
+ frontmatter: Frontmatter | null;
240
+ /** Document-level data bag shared with plugins via `ctx.data`; the seeded `data` option if provided, else a fresh `{}`. */
241
+ data: Data;
242
+ }
243
+ /** Result of {@link mdxToJs}. */
244
+ export interface MdxToJsResult {
245
+ /** Compiled JavaScript module source. */
246
+ code: string;
247
+ /** Frontmatter block at the start of the document, or `null` if none. */
248
+ frontmatter: Frontmatter | null;
249
+ /** Document-level data bag shared with plugins via `ctx.data`; the seeded `data` option if provided, else a fresh `{}`. */
250
+ data: Data;
251
+ }
252
+ /** Result of {@link markdownToJs}. */
253
+ export interface MarkdownToJsResult {
254
+ /** Compiled JavaScript module source. */
255
+ code: string;
256
+ /** Frontmatter block at the start of the document, or `null` if none. */
257
+ frontmatter: Frontmatter | null;
258
+ /** Document-level data bag shared with plugins via `ctx.data`; the seeded `data` option if provided, else a fresh `{}`. */
259
+ data: Data;
260
+ }
261
+ export interface EvaluateOptions extends Omit<MdxCompileOptions, "jsx" | "outputFormat"> {
262
+ Fragment: unknown;
263
+ jsx: (type: unknown, props: unknown, key?: unknown) => unknown;
264
+ jsxs: (type: unknown, props: unknown, key?: unknown) => unknown;
265
+ jsxDEV?: (type: unknown, props: unknown, key: unknown, isStaticChildren: boolean, source: unknown, self: unknown) => unknown;
266
+ useMDXComponents?: () => Record<string, unknown>;
267
+ }
268
+ /** Options for the step-by-step tree functions. */
269
+ export interface TreeOptions {
270
+ features?: Features;
271
+ /**
272
+ * Record `position` on every node. Default: `true`.
273
+ *
274
+ * A unist position is three objects per node and roughly half a materialized
275
+ * tree's memory, on top of the parser's line-index build. Pass `false` when
276
+ * nothing downstream reads `node.position`.
277
+ */
278
+ position?: boolean;
279
+ }
280
+ /** Options for the tree functions that stop at mdast. */
281
+ export interface MdastTreeOptions extends TreeOptions {
282
+ /** MDAST plugins, in run order. A nested array runs its own plugins, in
283
+ * their own order, at the array's position. */
284
+ mdastPlugins?: MdastPluginList;
285
+ /** The document being processed, surfaced to plugins as `ctx.fileURL`. */
286
+ fileURL?: URL;
287
+ /** Initial document-level data bag, seeding `ctx.data` before any plugin
288
+ * runs. Used by reference and mutated in place. */
289
+ data?: Data;
290
+ }
291
+ /** Options for the tree functions that run through to hast. */
292
+ export interface HastTreeOptions extends MdastTreeOptions {
293
+ /** HAST plugins, in run order. Nests like `mdastPlugins`. */
294
+ hastPlugins?: HastPluginList;
295
+ }
296
+ export interface HtmlToHastOptions {
297
+ /**
298
+ * Parse as a fragment, so the returned `root` holds the string's own
299
+ * top-level nodes instead of an implied `<html>`/`<head>`/`<body>`.
300
+ *
301
+ * @default false
302
+ */
303
+ fragment?: boolean;
304
+ /**
305
+ * The namespace a fragment's own top-level content parses in. `"svg"` reads
306
+ * it as foreign content, so `<circle />` self-closes and lands in the SVG
307
+ * namespace instead of being treated as an unknown HTML element.
308
+ *
309
+ * Ignored without `fragment: true`: a document always starts in HTML.
310
+ *
311
+ * @default "html"
312
+ */
313
+ space?: "html" | "svg";
314
+ }
315
+ type CombineAsync<A> = "async" extends A ? "async" : "maybe" extends A ? "maybe" : "sync";
316
+ type AnyFn = (...args: never[]) => unknown;
317
+ type ReturnsPromise<F> = F extends AnyFn ? [Extract<ReturnType<F>, Promise<unknown>>] extends [never] ? "sync" : [Exclude<ReturnType<F>, Promise<unknown>>] extends [never] ? "async" : "maybe" : "sync";
318
+ type FieldIsAsync<V> = V extends AnyFn ? ReturnsPromise<V> : V extends {
319
+ visit: infer F;
320
+ } ? ReturnsPromise<F> : V extends ReadonlyArray<infer Item> ? Item extends {
321
+ visit: infer F;
322
+ } ? ReturnsPromise<F> : "sync" : "sync";
323
+ type AnyVisitorAsync<P> = {
324
+ [K in keyof P]-?: FieldIsAsync<NonNullable<P[K]>>;
325
+ }[keyof P];
326
+ type IsPluginAsync<P> = P extends unknown ? CombineAsync<AnyVisitorAsync<P>> : never;
327
+ type ResolveInput<P, D extends readonly unknown[] = [0, 0, 0, 0, 0, 0, 0, 0]> = D extends readonly [
328
+ unknown,
329
+ ...infer Rest
330
+ ] ? P extends ReadonlyArray<infer Item> ? ResolveInput<Item, Rest> : P extends (...args: never[]) => infer Def ? ResolveInput<Def, Rest> : P : never;
331
+ type AnyInputAsync<Ps> = Ps extends ReadonlyArray<infer P> ? CombineAsync<IsPluginAsync<ResolveInput<P>>> : "sync";
332
+ type PluginBearingOptions = {
333
+ mdastPlugins?: MdastPluginList;
334
+ hastPlugins?: HastPluginList;
335
+ };
336
+ type OptionsAsync<O extends PluginBearingOptions> = CombineAsync<AnyInputAsync<NonNullable<O["mdastPlugins"]>> | AnyInputAsync<NonNullable<O["hastPlugins"]>>>;
337
+ export type ResultFor<O extends PluginBearingOptions, R> = {
338
+ sync: R;
339
+ async: Promise<R>;
340
+ maybe: R | Promise<R>;
341
+ }[OptionsAsync<O>];
342
+ export {};
@@ -0,0 +1 @@
1
+ export {};