@ai-react-markdown/engine 2.10.1 → 2.11.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/README.md +1 -1
- package/dist/index.cjs +342 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -2
- package/dist/index.d.ts +95 -2
- package/dist/index.dev.cjs +342 -54
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +339 -54
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +339 -54
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
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,80 @@ 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
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* rehype plugin: strip the provenance credential from genuine engine
|
|
1112
|
+
* placeholders and unwrap every placeholder that lacks it.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function rehypeVerifyEngineTags(options: RehypeVerifyEngineTagsOptions): (tree: Root$1) => void;
|
|
1115
|
+
|
|
1043
1116
|
/**
|
|
1044
1117
|
* `rehypeRebaseHashLinks` — restore intra-document hash navigation after
|
|
1045
1118
|
* `rehype-sanitize` clobbers `id` attributes.
|
|
@@ -1172,6 +1245,16 @@ interface CrossChunkHandlerOptions {
|
|
|
1172
1245
|
/** Passed through to placeholder hast properties so React components can
|
|
1173
1246
|
* partition by document. */
|
|
1174
1247
|
documentId: string;
|
|
1248
|
+
/**
|
|
1249
|
+
* Per-pipeline provenance credential. When present, every placeholder
|
|
1250
|
+
* element the handlers emit carries it as `engineProvenance`, and
|
|
1251
|
+
* `rehypeVerifyEngineTags` (installed by `buildCoreRehypePlugins` when it
|
|
1252
|
+
* is given the SAME value) unwraps any placeholder that lacks it — the
|
|
1253
|
+
* sanitize schema admits the placeholder tag names, so authored raw HTML
|
|
1254
|
+
* could otherwise forge them. Optional for API compatibility: absent, the
|
|
1255
|
+
* handlers emit exactly what they always did and no verifier runs.
|
|
1256
|
+
*/
|
|
1257
|
+
provenance?: string;
|
|
1175
1258
|
}
|
|
1176
1259
|
declare function buildCrossChunkHandlers(): Handlers;
|
|
1177
1260
|
|
|
@@ -1741,6 +1824,12 @@ declare function preprocessAIMDContent(content: string, extraPreprocessors?: AIM
|
|
|
1741
1824
|
* @returns The preprocessed string with normalized LaTeX delimiters.
|
|
1742
1825
|
*/
|
|
1743
1826
|
declare function preprocessLaTeX(str: string): string;
|
|
1827
|
+
/** Why a slice fell back to the legacy path. `null` = it did not.
|
|
1828
|
+
* `mask-exhausted` is a whole-call decision the CALLER records (every
|
|
1829
|
+
* private-use code point occurs in the complete input); `restore-invariant`
|
|
1830
|
+
* is an engine defect found while restoring atoms. Output is identical for
|
|
1831
|
+
* both; only the diagnostic differs. */
|
|
1832
|
+
type DegradedReason = 'mask-exhausted' | 'restore-invariant' | null;
|
|
1744
1833
|
/**
|
|
1745
1834
|
* Append-aware `preprocessLaTeX`: one instance per streaming lineage (the
|
|
1746
1835
|
* component holds it like the smooth-stream controller). Byte-identical to
|
|
@@ -1753,6 +1842,7 @@ declare function preprocessLaTeX(str: string): string;
|
|
|
1753
1842
|
* full-reprocess fallback.
|
|
1754
1843
|
* @internal Wired by the renderer; not part of the public API.
|
|
1755
1844
|
*/
|
|
1845
|
+
/** @soak-entry latex-preprocessor */
|
|
1756
1846
|
declare function createIncrementalLatexPreprocessor(options?: {
|
|
1757
1847
|
freezeThreshold?: number;
|
|
1758
1848
|
/** Failure backoff (default on). Tests that rely on `freezeThreshold: 0`
|
|
@@ -1769,6 +1859,9 @@ declare function createIncrementalLatexPreprocessor(options?: {
|
|
|
1769
1859
|
activeLength: number;
|
|
1770
1860
|
frozenBytes: number;
|
|
1771
1861
|
}) => void;
|
|
1862
|
+
/** Test hook: called when the lineage degrades to whole-source legacy
|
|
1863
|
+
* processing, with the reason. @internal */
|
|
1864
|
+
onDegrade?: (reason: Exclude<DegradedReason, null>) => void;
|
|
1772
1865
|
}): (content: string) => string;
|
|
1773
1866
|
|
|
1774
1867
|
/**
|
|
@@ -1837,4 +1930,4 @@ type RemendPreprocessorOptions = Omit<RemendOptions, 'katex' | 'inlineKatex'>;
|
|
|
1837
1930
|
*/
|
|
1838
1931
|
declare function createRemendPreprocessor(options?: RemendPreprocessorOptions): AIMDContentPreprocessor;
|
|
1839
1932
|
|
|
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 };
|
|
1933
|
+
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, 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,80 @@ 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
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* rehype plugin: strip the provenance credential from genuine engine
|
|
1112
|
+
* placeholders and unwrap every placeholder that lacks it.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function rehypeVerifyEngineTags(options: RehypeVerifyEngineTagsOptions): (tree: Root$1) => void;
|
|
1115
|
+
|
|
1043
1116
|
/**
|
|
1044
1117
|
* `rehypeRebaseHashLinks` — restore intra-document hash navigation after
|
|
1045
1118
|
* `rehype-sanitize` clobbers `id` attributes.
|
|
@@ -1172,6 +1245,16 @@ interface CrossChunkHandlerOptions {
|
|
|
1172
1245
|
/** Passed through to placeholder hast properties so React components can
|
|
1173
1246
|
* partition by document. */
|
|
1174
1247
|
documentId: string;
|
|
1248
|
+
/**
|
|
1249
|
+
* Per-pipeline provenance credential. When present, every placeholder
|
|
1250
|
+
* element the handlers emit carries it as `engineProvenance`, and
|
|
1251
|
+
* `rehypeVerifyEngineTags` (installed by `buildCoreRehypePlugins` when it
|
|
1252
|
+
* is given the SAME value) unwraps any placeholder that lacks it — the
|
|
1253
|
+
* sanitize schema admits the placeholder tag names, so authored raw HTML
|
|
1254
|
+
* could otherwise forge them. Optional for API compatibility: absent, the
|
|
1255
|
+
* handlers emit exactly what they always did and no verifier runs.
|
|
1256
|
+
*/
|
|
1257
|
+
provenance?: string;
|
|
1175
1258
|
}
|
|
1176
1259
|
declare function buildCrossChunkHandlers(): Handlers;
|
|
1177
1260
|
|
|
@@ -1741,6 +1824,12 @@ declare function preprocessAIMDContent(content: string, extraPreprocessors?: AIM
|
|
|
1741
1824
|
* @returns The preprocessed string with normalized LaTeX delimiters.
|
|
1742
1825
|
*/
|
|
1743
1826
|
declare function preprocessLaTeX(str: string): string;
|
|
1827
|
+
/** Why a slice fell back to the legacy path. `null` = it did not.
|
|
1828
|
+
* `mask-exhausted` is a whole-call decision the CALLER records (every
|
|
1829
|
+
* private-use code point occurs in the complete input); `restore-invariant`
|
|
1830
|
+
* is an engine defect found while restoring atoms. Output is identical for
|
|
1831
|
+
* both; only the diagnostic differs. */
|
|
1832
|
+
type DegradedReason = 'mask-exhausted' | 'restore-invariant' | null;
|
|
1744
1833
|
/**
|
|
1745
1834
|
* Append-aware `preprocessLaTeX`: one instance per streaming lineage (the
|
|
1746
1835
|
* component holds it like the smooth-stream controller). Byte-identical to
|
|
@@ -1753,6 +1842,7 @@ declare function preprocessLaTeX(str: string): string;
|
|
|
1753
1842
|
* full-reprocess fallback.
|
|
1754
1843
|
* @internal Wired by the renderer; not part of the public API.
|
|
1755
1844
|
*/
|
|
1845
|
+
/** @soak-entry latex-preprocessor */
|
|
1756
1846
|
declare function createIncrementalLatexPreprocessor(options?: {
|
|
1757
1847
|
freezeThreshold?: number;
|
|
1758
1848
|
/** Failure backoff (default on). Tests that rely on `freezeThreshold: 0`
|
|
@@ -1769,6 +1859,9 @@ declare function createIncrementalLatexPreprocessor(options?: {
|
|
|
1769
1859
|
activeLength: number;
|
|
1770
1860
|
frozenBytes: number;
|
|
1771
1861
|
}) => void;
|
|
1862
|
+
/** Test hook: called when the lineage degrades to whole-source legacy
|
|
1863
|
+
* processing, with the reason. @internal */
|
|
1864
|
+
onDegrade?: (reason: Exclude<DegradedReason, null>) => void;
|
|
1772
1865
|
}): (content: string) => string;
|
|
1773
1866
|
|
|
1774
1867
|
/**
|
|
@@ -1837,4 +1930,4 @@ type RemendPreprocessorOptions = Omit<RemendOptions, 'katex' | 'inlineKatex'>;
|
|
|
1837
1930
|
*/
|
|
1838
1931
|
declare function createRemendPreprocessor(options?: RemendPreprocessorOptions): AIMDContentPreprocessor;
|
|
1839
1932
|
|
|
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 };
|
|
1933
|
+
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, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, subscribeStageTimings, transformStage, withDefs };
|