@ai-react-markdown/engine 2.10.1 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -319,6 +319,10 @@ interface FreezeScanResult {
319
319
  interface FreezeScanCheckpoint {
320
320
  readonly '~freezeScanCheckpoint'?: never;
321
321
  }
322
+ /**
323
+ * @soak-entry freeze-scanner-resume
324
+ * @soak-entry freeze-direction
325
+ */
322
326
  declare function computeFreezeBoundary(text: string, options: FreezeBoundaryOptions, resume?: FreezeScanCheckpoint | null): FreezeScanResult;
323
327
 
324
328
  /**
@@ -494,6 +498,7 @@ interface AdvanceResult {
494
498
  boundary: number;
495
499
  nextState: IncrementalParseState;
496
500
  }
501
+ /** @soak-entry incremental-parse */
497
502
  declare function advanceIncrementalParse(prev: IncrementalParseState | null, content: string, options: AdvanceOptions): AdvanceResult;
498
503
 
499
504
  /**
@@ -580,6 +585,7 @@ interface DefLabelScanner {
580
585
  * parse is indistinguishable from a parse whose sets came out equal).
581
586
  * Production callers never pass it.
582
587
  */
588
+ /** @soak-entry definition-label-scanner */
583
589
  declare function createDefLabelScanner(parse?: (source: string) => DefLabels): DefLabelScanner;
584
590
 
585
591
  /**
@@ -1033,13 +1039,83 @@ type RemarkRehypeOptions = NonNullable<PipelineOptions['remarkRehypeOptions']>;
1033
1039
  /** The always-on remark chain with plugin-gated extras spliced at their
1034
1040
  * contractual positions. ORDER IS LOAD-BEARING — see the arbiter suite. */
1035
1041
  declare function buildCoreRemarkPlugins(enginePlugins: readonly AIMarkdownEnginePlugin[]): RemarkPlugins;
1042
+ interface CoreRehypePluginsOptions {
1043
+ /**
1044
+ * Per-pipeline provenance credential. Installs `rehypeVerifyEngineTags`
1045
+ * between `rehypeRaw` and `rehypeSanitize` so that only placeholder
1046
+ * elements stamped with this exact value by the cross-chunk handlers
1047
+ * survive; put the SAME value in the remark-rehype options
1048
+ * (`CrossChunkHandlerOptions.provenance`). Omitting `options` keeps the
1049
+ * chain exactly as before — no verifier — which is the documented
1050
+ * escape-hatch behaviour for hand-assembled pipelines; the shipped
1051
+ * renderer always passes a credential.
1052
+ */
1053
+ provenance: string;
1054
+ }
1036
1055
  /** The rehype chain. `clobberPrefix` namespaces ids per instance; pass ''
1037
1056
  * for unprefixed output (test harnesses). */
1038
- declare function buildCoreRehypePlugins(sanitizeSchema: SanitizeSchema, clobberPrefix: string): RehypePlugins;
1057
+ declare function buildCoreRehypePlugins(sanitizeSchema: SanitizeSchema, clobberPrefix: string, options?: CoreRehypePluginsOptions): RehypePlugins;
1039
1058
  /** Base remark-rehype options (before the standalone/coordinated handler
1040
1059
  * merge that `MarkdownContent`'s pipeline memo layers on top). */
1041
1060
  declare function buildCoreRemarkRehypeOptions(enableDefinitionList: boolean): RemarkRehypeOptions;
1042
1061
 
1062
+ /**
1063
+ * Provenance verifier for the engine's internal placeholder elements.
1064
+ *
1065
+ * The cross-chunk handlers (`customMdastHandlers.ts`) emit three custom hast
1066
+ * elements — `footnote-sup`, `cross-chunk-link`, `cross-chunk-image` — that
1067
+ * the sanitize schema must admit so they can reach their React placeholders.
1068
+ * Admitting the tag names admits them from AUTHORED raw HTML too: a document
1069
+ * can write `<footnote-sup label="a">` and, after `rehypeRaw` + sanitize, it
1070
+ * arrives at the placeholder with a `label`, takes the `fnref-a` anchor the
1071
+ * footer's backref points to, and pollutes the block dependency sets.
1072
+ *
1073
+ * Two layers tell a genuine instance from a forged one:
1074
+ *
1075
+ * 1. The property-NAME channel. `hast-util-raw` re-emits existing element
1076
+ * nodes as parser tokens without passing the tokenizer, so a camelCase
1077
+ * property written by a handler survives verbatim; authored raw HTML goes
1078
+ * through the tokenizer and every attribute name comes back lowercased
1079
+ * (`engineProvenance="x"` → `engineprovenance`). Authored HTML therefore
1080
+ * cannot produce the property this plugin reads. (Pinned in the test.)
1081
+ * 2. The property VALUE: a per-pipeline credential the handlers stamp and
1082
+ * this plugin checks, so a future upstream change that preserved authored
1083
+ * attribute case would still leave the value to guess.
1084
+ *
1085
+ * Runs after `rehypeRaw` and before `rehypeSanitize` (see `pluginChain.ts`):
1086
+ * genuine instances lose the credential and pass; every other instance is
1087
+ * unwrapped — replaced by its children, removed when it has none — which is
1088
+ * what `hast-util-sanitize` does to a disallowed element.
1089
+ *
1090
+ * The walk is index-controlled on purpose. `unist-util-visit` with a splice
1091
+ * in the visitor is easy to get wrong (returning SKIP or an index after
1092
+ * replacing a node skips the first exposed child or revisits a sibling); an
1093
+ * explicit loop that does not advance after a splice inspects the exposed
1094
+ * children next, so forged-wrapping-genuine, genuine-wrapping-forged,
1095
+ * forged-inside-forged and adjacent forged instances all resolve.
1096
+ *
1097
+ * @module components/rehypeVerifyEngineTags
1098
+ */
1099
+
1100
+ /** The three placeholder tag names the handlers emit. Keep in sync with the
1101
+ * sanitize schema's `crossChunkTags` and core's `PLACEHOLDER_TAGS`. */
1102
+ declare const ENGINE_PLACEHOLDER_TAGS: ReadonlySet<string>;
1103
+ /** The property the handlers stamp. camelCase is load-bearing (layer 1). */
1104
+ declare const ENGINE_PROVENANCE_PROPERTY = "engineProvenance";
1105
+ interface RehypeVerifyEngineTagsOptions {
1106
+ /** The credential the handlers were given. The empty string accepts
1107
+ * nothing (fail closed); it is never a valid credential. */
1108
+ provenance: string;
1109
+ /** Capture ancestry only when the final a/img schema needs it. Data is
1110
+ * recorded after verification, never taken from authored attributes. */
1111
+ referenceAncestors?: boolean;
1112
+ }
1113
+ /**
1114
+ * rehype plugin: strip the provenance credential from genuine engine
1115
+ * placeholders and unwrap every placeholder that lacks it.
1116
+ */
1117
+ declare function rehypeVerifyEngineTags(options: RehypeVerifyEngineTagsOptions): (tree: Root$1) => void;
1118
+
1043
1119
  /**
1044
1120
  * `rehypeRebaseHashLinks` — restore intra-document hash navigation after
1045
1121
  * `rehype-sanitize` clobbers `id` attributes.
@@ -1172,6 +1248,16 @@ interface CrossChunkHandlerOptions {
1172
1248
  /** Passed through to placeholder hast properties so React components can
1173
1249
  * partition by document. */
1174
1250
  documentId: string;
1251
+ /**
1252
+ * Per-pipeline provenance credential. When present, every placeholder
1253
+ * element the handlers emit carries it as `engineProvenance`, and
1254
+ * `rehypeVerifyEngineTags` (installed by `buildCoreRehypePlugins` when it
1255
+ * is given the SAME value) unwraps any placeholder that lacks it — the
1256
+ * sanitize schema admits the placeholder tag names, so authored raw HTML
1257
+ * could otherwise forge them. Optional for API compatibility: absent, the
1258
+ * handlers emit exactly what they always did and no verifier runs.
1259
+ */
1260
+ provenance?: string;
1175
1261
  }
1176
1262
  declare function buildCrossChunkHandlers(): Handlers;
1177
1263
 
@@ -1232,6 +1318,21 @@ type UrlAttrTag = 'a' | 'img';
1232
1318
  */
1233
1319
  declare function sanitizeCrossChunkUrl(rawUrl: string, key: UrlAttrKey, tagName: UrlAttrTag, urlTransform: UrlTransform, schema: SanitizeSchema): string | null;
1234
1320
 
1321
+ /** Resolve the final element, not just its URL: placeholders reach React
1322
+ * after the normal rehype passes, so their a/img must apply those passes too.
1323
+ * The marker represents already-rendered link children and distinguishes
1324
+ * sanitizer unwrapping from stripping the element with its contents. */
1325
+ declare function resolveCrossChunkReference(input: {
1326
+ tagName: 'a' | 'img';
1327
+ url: string;
1328
+ title?: string;
1329
+ alt?: string;
1330
+ node?: Pick<Element, 'children' | 'position' | 'data'>;
1331
+ }, schema: SanitizeSchema, urlTransform: UrlTransform, clobberPrefix: string): {
1332
+ element: Element | null;
1333
+ keepChildren: boolean;
1334
+ };
1335
+
1235
1336
  /**
1236
1337
  * The five shipped engine plugins and the default set.
1237
1338
  *
@@ -1741,6 +1842,12 @@ declare function preprocessAIMDContent(content: string, extraPreprocessors?: AIM
1741
1842
  * @returns The preprocessed string with normalized LaTeX delimiters.
1742
1843
  */
1743
1844
  declare function preprocessLaTeX(str: string): string;
1845
+ /** Why a slice fell back to the legacy path. `null` = it did not.
1846
+ * `mask-exhausted` is a whole-call decision the CALLER records (every
1847
+ * private-use code point occurs in the complete input); `restore-invariant`
1848
+ * is an engine defect found while restoring atoms. Output is identical for
1849
+ * both; only the diagnostic differs. */
1850
+ type DegradedReason = 'mask-exhausted' | 'restore-invariant' | null;
1744
1851
  /**
1745
1852
  * Append-aware `preprocessLaTeX`: one instance per streaming lineage (the
1746
1853
  * component holds it like the smooth-stream controller). Byte-identical to
@@ -1753,6 +1860,7 @@ declare function preprocessLaTeX(str: string): string;
1753
1860
  * full-reprocess fallback.
1754
1861
  * @internal Wired by the renderer; not part of the public API.
1755
1862
  */
1863
+ /** @soak-entry latex-preprocessor */
1756
1864
  declare function createIncrementalLatexPreprocessor(options?: {
1757
1865
  freezeThreshold?: number;
1758
1866
  /** Failure backoff (default on). Tests that rely on `freezeThreshold: 0`
@@ -1769,6 +1877,9 @@ declare function createIncrementalLatexPreprocessor(options?: {
1769
1877
  activeLength: number;
1770
1878
  frozenBytes: number;
1771
1879
  }) => void;
1880
+ /** Test hook: called when the lineage degrades to whole-source legacy
1881
+ * processing, with the reason. @internal */
1882
+ onDegrade?: (reason: Exclude<DegradedReason, null>) => void;
1772
1883
  }): (content: string) => string;
1773
1884
 
1774
1885
  /**
@@ -1837,4 +1948,4 @@ type RemendPreprocessorOptions = Omit<RemendOptions, 'katex' | 'inlineKatex'>;
1837
1948
  */
1838
1949
  declare function createRemendPreprocessor(options?: RemendPreprocessorOptions): AIMDContentPreprocessor;
1839
1950
 
1840
- export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, lastMeaningfulIdx, measureStage, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, removeComments, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, subscribeStageTimings, transformStage, withDefs };
1951
+ export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CoreRehypePluginsOptions, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, ENGINE_PLACEHOLDER_TAGS, ENGINE_PROVENANCE_PROPERTY, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RehypeVerifyEngineTagsOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, lastMeaningfulIdx, measureStage, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, rehypeVerifyEngineTags, removeComments, resolveCrossChunkReference, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, subscribeStageTimings, transformStage, withDefs };
package/dist/index.d.ts CHANGED
@@ -319,6 +319,10 @@ interface FreezeScanResult {
319
319
  interface FreezeScanCheckpoint {
320
320
  readonly '~freezeScanCheckpoint'?: never;
321
321
  }
322
+ /**
323
+ * @soak-entry freeze-scanner-resume
324
+ * @soak-entry freeze-direction
325
+ */
322
326
  declare function computeFreezeBoundary(text: string, options: FreezeBoundaryOptions, resume?: FreezeScanCheckpoint | null): FreezeScanResult;
323
327
 
324
328
  /**
@@ -494,6 +498,7 @@ interface AdvanceResult {
494
498
  boundary: number;
495
499
  nextState: IncrementalParseState;
496
500
  }
501
+ /** @soak-entry incremental-parse */
497
502
  declare function advanceIncrementalParse(prev: IncrementalParseState | null, content: string, options: AdvanceOptions): AdvanceResult;
498
503
 
499
504
  /**
@@ -580,6 +585,7 @@ interface DefLabelScanner {
580
585
  * parse is indistinguishable from a parse whose sets came out equal).
581
586
  * Production callers never pass it.
582
587
  */
588
+ /** @soak-entry definition-label-scanner */
583
589
  declare function createDefLabelScanner(parse?: (source: string) => DefLabels): DefLabelScanner;
584
590
 
585
591
  /**
@@ -1033,13 +1039,83 @@ type RemarkRehypeOptions = NonNullable<PipelineOptions['remarkRehypeOptions']>;
1033
1039
  /** The always-on remark chain with plugin-gated extras spliced at their
1034
1040
  * contractual positions. ORDER IS LOAD-BEARING — see the arbiter suite. */
1035
1041
  declare function buildCoreRemarkPlugins(enginePlugins: readonly AIMarkdownEnginePlugin[]): RemarkPlugins;
1042
+ interface CoreRehypePluginsOptions {
1043
+ /**
1044
+ * Per-pipeline provenance credential. Installs `rehypeVerifyEngineTags`
1045
+ * between `rehypeRaw` and `rehypeSanitize` so that only placeholder
1046
+ * elements stamped with this exact value by the cross-chunk handlers
1047
+ * survive; put the SAME value in the remark-rehype options
1048
+ * (`CrossChunkHandlerOptions.provenance`). Omitting `options` keeps the
1049
+ * chain exactly as before — no verifier — which is the documented
1050
+ * escape-hatch behaviour for hand-assembled pipelines; the shipped
1051
+ * renderer always passes a credential.
1052
+ */
1053
+ provenance: string;
1054
+ }
1036
1055
  /** The rehype chain. `clobberPrefix` namespaces ids per instance; pass ''
1037
1056
  * for unprefixed output (test harnesses). */
1038
- declare function buildCoreRehypePlugins(sanitizeSchema: SanitizeSchema, clobberPrefix: string): RehypePlugins;
1057
+ declare function buildCoreRehypePlugins(sanitizeSchema: SanitizeSchema, clobberPrefix: string, options?: CoreRehypePluginsOptions): RehypePlugins;
1039
1058
  /** Base remark-rehype options (before the standalone/coordinated handler
1040
1059
  * merge that `MarkdownContent`'s pipeline memo layers on top). */
1041
1060
  declare function buildCoreRemarkRehypeOptions(enableDefinitionList: boolean): RemarkRehypeOptions;
1042
1061
 
1062
+ /**
1063
+ * Provenance verifier for the engine's internal placeholder elements.
1064
+ *
1065
+ * The cross-chunk handlers (`customMdastHandlers.ts`) emit three custom hast
1066
+ * elements — `footnote-sup`, `cross-chunk-link`, `cross-chunk-image` — that
1067
+ * the sanitize schema must admit so they can reach their React placeholders.
1068
+ * Admitting the tag names admits them from AUTHORED raw HTML too: a document
1069
+ * can write `<footnote-sup label="a">` and, after `rehypeRaw` + sanitize, it
1070
+ * arrives at the placeholder with a `label`, takes the `fnref-a` anchor the
1071
+ * footer's backref points to, and pollutes the block dependency sets.
1072
+ *
1073
+ * Two layers tell a genuine instance from a forged one:
1074
+ *
1075
+ * 1. The property-NAME channel. `hast-util-raw` re-emits existing element
1076
+ * nodes as parser tokens without passing the tokenizer, so a camelCase
1077
+ * property written by a handler survives verbatim; authored raw HTML goes
1078
+ * through the tokenizer and every attribute name comes back lowercased
1079
+ * (`engineProvenance="x"` → `engineprovenance`). Authored HTML therefore
1080
+ * cannot produce the property this plugin reads. (Pinned in the test.)
1081
+ * 2. The property VALUE: a per-pipeline credential the handlers stamp and
1082
+ * this plugin checks, so a future upstream change that preserved authored
1083
+ * attribute case would still leave the value to guess.
1084
+ *
1085
+ * Runs after `rehypeRaw` and before `rehypeSanitize` (see `pluginChain.ts`):
1086
+ * genuine instances lose the credential and pass; every other instance is
1087
+ * unwrapped — replaced by its children, removed when it has none — which is
1088
+ * what `hast-util-sanitize` does to a disallowed element.
1089
+ *
1090
+ * The walk is index-controlled on purpose. `unist-util-visit` with a splice
1091
+ * in the visitor is easy to get wrong (returning SKIP or an index after
1092
+ * replacing a node skips the first exposed child or revisits a sibling); an
1093
+ * explicit loop that does not advance after a splice inspects the exposed
1094
+ * children next, so forged-wrapping-genuine, genuine-wrapping-forged,
1095
+ * forged-inside-forged and adjacent forged instances all resolve.
1096
+ *
1097
+ * @module components/rehypeVerifyEngineTags
1098
+ */
1099
+
1100
+ /** The three placeholder tag names the handlers emit. Keep in sync with the
1101
+ * sanitize schema's `crossChunkTags` and core's `PLACEHOLDER_TAGS`. */
1102
+ declare const ENGINE_PLACEHOLDER_TAGS: ReadonlySet<string>;
1103
+ /** The property the handlers stamp. camelCase is load-bearing (layer 1). */
1104
+ declare const ENGINE_PROVENANCE_PROPERTY = "engineProvenance";
1105
+ interface RehypeVerifyEngineTagsOptions {
1106
+ /** The credential the handlers were given. The empty string accepts
1107
+ * nothing (fail closed); it is never a valid credential. */
1108
+ provenance: string;
1109
+ /** Capture ancestry only when the final a/img schema needs it. Data is
1110
+ * recorded after verification, never taken from authored attributes. */
1111
+ referenceAncestors?: boolean;
1112
+ }
1113
+ /**
1114
+ * rehype plugin: strip the provenance credential from genuine engine
1115
+ * placeholders and unwrap every placeholder that lacks it.
1116
+ */
1117
+ declare function rehypeVerifyEngineTags(options: RehypeVerifyEngineTagsOptions): (tree: Root$1) => void;
1118
+
1043
1119
  /**
1044
1120
  * `rehypeRebaseHashLinks` — restore intra-document hash navigation after
1045
1121
  * `rehype-sanitize` clobbers `id` attributes.
@@ -1172,6 +1248,16 @@ interface CrossChunkHandlerOptions {
1172
1248
  /** Passed through to placeholder hast properties so React components can
1173
1249
  * partition by document. */
1174
1250
  documentId: string;
1251
+ /**
1252
+ * Per-pipeline provenance credential. When present, every placeholder
1253
+ * element the handlers emit carries it as `engineProvenance`, and
1254
+ * `rehypeVerifyEngineTags` (installed by `buildCoreRehypePlugins` when it
1255
+ * is given the SAME value) unwraps any placeholder that lacks it — the
1256
+ * sanitize schema admits the placeholder tag names, so authored raw HTML
1257
+ * could otherwise forge them. Optional for API compatibility: absent, the
1258
+ * handlers emit exactly what they always did and no verifier runs.
1259
+ */
1260
+ provenance?: string;
1175
1261
  }
1176
1262
  declare function buildCrossChunkHandlers(): Handlers;
1177
1263
 
@@ -1232,6 +1318,21 @@ type UrlAttrTag = 'a' | 'img';
1232
1318
  */
1233
1319
  declare function sanitizeCrossChunkUrl(rawUrl: string, key: UrlAttrKey, tagName: UrlAttrTag, urlTransform: UrlTransform, schema: SanitizeSchema): string | null;
1234
1320
 
1321
+ /** Resolve the final element, not just its URL: placeholders reach React
1322
+ * after the normal rehype passes, so their a/img must apply those passes too.
1323
+ * The marker represents already-rendered link children and distinguishes
1324
+ * sanitizer unwrapping from stripping the element with its contents. */
1325
+ declare function resolveCrossChunkReference(input: {
1326
+ tagName: 'a' | 'img';
1327
+ url: string;
1328
+ title?: string;
1329
+ alt?: string;
1330
+ node?: Pick<Element, 'children' | 'position' | 'data'>;
1331
+ }, schema: SanitizeSchema, urlTransform: UrlTransform, clobberPrefix: string): {
1332
+ element: Element | null;
1333
+ keepChildren: boolean;
1334
+ };
1335
+
1235
1336
  /**
1236
1337
  * The five shipped engine plugins and the default set.
1237
1338
  *
@@ -1741,6 +1842,12 @@ declare function preprocessAIMDContent(content: string, extraPreprocessors?: AIM
1741
1842
  * @returns The preprocessed string with normalized LaTeX delimiters.
1742
1843
  */
1743
1844
  declare function preprocessLaTeX(str: string): string;
1845
+ /** Why a slice fell back to the legacy path. `null` = it did not.
1846
+ * `mask-exhausted` is a whole-call decision the CALLER records (every
1847
+ * private-use code point occurs in the complete input); `restore-invariant`
1848
+ * is an engine defect found while restoring atoms. Output is identical for
1849
+ * both; only the diagnostic differs. */
1850
+ type DegradedReason = 'mask-exhausted' | 'restore-invariant' | null;
1744
1851
  /**
1745
1852
  * Append-aware `preprocessLaTeX`: one instance per streaming lineage (the
1746
1853
  * component holds it like the smooth-stream controller). Byte-identical to
@@ -1753,6 +1860,7 @@ declare function preprocessLaTeX(str: string): string;
1753
1860
  * full-reprocess fallback.
1754
1861
  * @internal Wired by the renderer; not part of the public API.
1755
1862
  */
1863
+ /** @soak-entry latex-preprocessor */
1756
1864
  declare function createIncrementalLatexPreprocessor(options?: {
1757
1865
  freezeThreshold?: number;
1758
1866
  /** Failure backoff (default on). Tests that rely on `freezeThreshold: 0`
@@ -1769,6 +1877,9 @@ declare function createIncrementalLatexPreprocessor(options?: {
1769
1877
  activeLength: number;
1770
1878
  frozenBytes: number;
1771
1879
  }) => void;
1880
+ /** Test hook: called when the lineage degrades to whole-source legacy
1881
+ * processing, with the reason. @internal */
1882
+ onDegrade?: (reason: Exclude<DegradedReason, null>) => void;
1772
1883
  }): (content: string) => string;
1773
1884
 
1774
1885
  /**
@@ -1837,4 +1948,4 @@ type RemendPreprocessorOptions = Omit<RemendOptions, 'katex' | 'inlineKatex'>;
1837
1948
  */
1838
1949
  declare function createRemendPreprocessor(options?: RemendPreprocessorOptions): AIMDContentPreprocessor;
1839
1950
 
1840
- export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, lastMeaningfulIdx, measureStage, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, removeComments, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, subscribeStageTimings, transformStage, withDefs };
1951
+ export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CoreRehypePluginsOptions, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, ENGINE_PLACEHOLDER_TAGS, ENGINE_PROVENANCE_PROPERTY, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RehypeVerifyEngineTagsOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, lastMeaningfulIdx, measureStage, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, rehypeVerifyEngineTags, removeComments, resolveCrossChunkReference, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, subscribeStageTimings, transformStage, withDefs };