@ai-react-markdown/core 1.3.0 → 1.4.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 +72 -10
- package/dist/index.cjs +1211 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +156 -3
- package/dist/index.d.ts +156 -3
- package/dist/index.js +1211 -91
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { JSX, ComponentType, PropsWithChildren, CSSProperties } from 'react';
|
|
3
|
-
import { Element } from 'hast';
|
|
2
|
+
import { JSX, ComponentType, PropsWithChildren, CSSProperties, FC } from 'react';
|
|
3
|
+
import { Element, ElementContent } from 'hast';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Public types for the local Markdown wrapper. Ported 1:1 from react-markdown
|
|
@@ -93,6 +93,18 @@ interface AIMarkdownRenderConfig {
|
|
|
93
93
|
* @default true
|
|
94
94
|
*/
|
|
95
95
|
readonly blockMemoEnabled: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Default `true`. Controls Direction A: whether `<AIMarkdown>` (standalone
|
|
98
|
+
* mode) protects orphan `footnoteDefinition` nodes from being silently
|
|
99
|
+
* dropped by `mdast-util-to-hast` when no corresponding `footnoteReference`
|
|
100
|
+
* exists. Implemented via a custom `footnoteDefinition` handler that
|
|
101
|
+
* proactively registers the label in `state.footnoteOrder`.
|
|
102
|
+
*
|
|
103
|
+
* When `<AIMarkdown>` is wrapped in `<AIMarkdownDocuments>`, this field
|
|
104
|
+
* is ignored — the wrapper's `preserveOrphanReferences` prop overrides
|
|
105
|
+
* unconditionally for all chunks under it.
|
|
106
|
+
*/
|
|
107
|
+
readonly preserveOrphanReferences: boolean;
|
|
96
108
|
}
|
|
97
109
|
/**
|
|
98
110
|
* Sensible default configuration with all extensions and optimizations enabled.
|
|
@@ -103,6 +115,7 @@ declare const defaultAIMarkdownRenderConfig: Readonly<{
|
|
|
103
115
|
extraSyntaxSupported: readonly AIMarkdownRenderExtraSyntax[];
|
|
104
116
|
displayOptimizeAbilities: readonly AIMarkdownRenderDisplayOptimizeAbility[];
|
|
105
117
|
blockMemoEnabled: true;
|
|
118
|
+
preserveOrphanReferences: true;
|
|
106
119
|
}>;
|
|
107
120
|
/**
|
|
108
121
|
* Arbitrary metadata that consumers can pass through a dedicated React context.
|
|
@@ -202,6 +215,14 @@ interface AIMarkdownRenderState<TConfig extends AIMarkdownRenderConfig = AIMarkd
|
|
|
202
215
|
* always win.
|
|
203
216
|
*/
|
|
204
217
|
documentId: string;
|
|
218
|
+
/**
|
|
219
|
+
* Per-document URI-safe id prefix used by all clobberable attributes
|
|
220
|
+
* (`id="…"` / `href="#…"`). Derived once by the provider as
|
|
221
|
+
* `${encodeURIComponent(documentId)}-user-content-` and exposed here so
|
|
222
|
+
* downstream consumers (placeholder components, cross-chunk anchor logic)
|
|
223
|
+
* read a single canonical source instead of recomputing locally.
|
|
224
|
+
*/
|
|
225
|
+
clobberPrefix: string;
|
|
205
226
|
/** Active render configuration. */
|
|
206
227
|
config: TConfig;
|
|
207
228
|
}
|
|
@@ -726,6 +747,138 @@ type AIMDContentPreprocessor = (content: string) => string;
|
|
|
726
747
|
*/
|
|
727
748
|
declare function useStableValue<T>(value: T): T;
|
|
728
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Cross-chunk shared state. Holds per-chunk contributions (refs, defs,
|
|
752
|
+
* linkDefs) keyed by Symbol identity allocated via useId reactId, with
|
|
753
|
+
* refcount + microtask-deferred reclamation for React Strict Mode safety.
|
|
754
|
+
*
|
|
755
|
+
* @module components/documentRegistry
|
|
756
|
+
*/
|
|
757
|
+
|
|
758
|
+
interface FootnoteDef {
|
|
759
|
+
/** Already-normalized identifier (uppercase). Used as dictionary key for
|
|
760
|
+
* case-insensitive cross-chunk lookups. */
|
|
761
|
+
identifier: string;
|
|
762
|
+
/** mdast's case-folded identifier — the exact string mdast-util-to-hast
|
|
763
|
+
* emits in `<li id="${clobberPrefix}fn-${sourceIdentifier}">` and that
|
|
764
|
+
* `FootnoteSupNumber` mirrors in its anchor href. Needed so the aggregate
|
|
765
|
+
* footer's `<li id>` and backref href match the inline `<sup>`'s href
|
|
766
|
+
* exactly (otherwise hash navigation breaks). Optional so unit-test
|
|
767
|
+
* fixtures don't need to fabricate it; production data always supplies it. */
|
|
768
|
+
sourceIdentifier?: string;
|
|
769
|
+
/** Content extracted from the source markdown footnote definition. */
|
|
770
|
+
contentSource: string;
|
|
771
|
+
/** Per-def hast body (the def's mdast children after mdast-util-to-hast
|
|
772
|
+
* conversion). Drives AggregateFootnotesIfLast to render the consolidated
|
|
773
|
+
* footer at the end of each document's last chunk. Optional so unit-test
|
|
774
|
+
* fixtures can build minimal FootnoteDef objects without producing hast. */
|
|
775
|
+
bodyHast?: ElementContent[];
|
|
776
|
+
}
|
|
777
|
+
interface LinkDef {
|
|
778
|
+
/** Already-normalized identifier (uppercase). */
|
|
779
|
+
identifier: string;
|
|
780
|
+
url: string;
|
|
781
|
+
title?: string;
|
|
782
|
+
}
|
|
783
|
+
type RefKind = 'footnote' | 'link' | 'image';
|
|
784
|
+
interface RefRecord {
|
|
785
|
+
/** Already-normalized identifier (uppercase). */
|
|
786
|
+
label: string;
|
|
787
|
+
/** Which markdown reference space this entry belongs to. Footnote refs,
|
|
788
|
+
* link refs, and image refs occupy disjoint namespaces in GFM, so they
|
|
789
|
+
* must be filtered separately when computing footnote numbers / refcounts. */
|
|
790
|
+
kind: RefKind;
|
|
791
|
+
referenceType?: 'full' | 'collapsed' | 'shortcut';
|
|
792
|
+
}
|
|
793
|
+
interface ChunkData {
|
|
794
|
+
refs: RefRecord[];
|
|
795
|
+
defs: Map<string, FootnoteDef>;
|
|
796
|
+
linkDefs: Map<string, LinkDef>;
|
|
797
|
+
ownFootnoteLabels: Set<string>;
|
|
798
|
+
ownLinkLabels: Set<string>;
|
|
799
|
+
}
|
|
800
|
+
interface Registry {
|
|
801
|
+
/** Chunk mount-order Symbol list. **Read-only from outside the registry.**
|
|
802
|
+
* Direct mutation (`.push`, `.splice`, index assignment) corrupts
|
|
803
|
+
* footnote numbering, "last chunk" detection, and eviction. Use the
|
|
804
|
+
* `allocateSymbol` / `releaseSymbol` / `registerChunk` API instead. */
|
|
805
|
+
readonly chunkOrder: readonly symbol[];
|
|
806
|
+
/** Chunk Symbol → contribution payload. **Read-only from outside.**
|
|
807
|
+
* Use `contributeChunkData` / `contributeLabels` / `registerChunk` to
|
|
808
|
+
* publish; direct `.set` / `.delete` bypasses version bumps and
|
|
809
|
+
* subscriber wake-ups. */
|
|
810
|
+
readonly chunkData: ReadonlyMap<symbol, ChunkData>;
|
|
811
|
+
/** Union of own-def labels across all chunks. PASS 0.5 phantom-injection
|
|
812
|
+
* driver. **Read-only from outside.** The registry derives this from
|
|
813
|
+
* per-chunk contributions; direct mutation breaks the derivation. */
|
|
814
|
+
readonly labelSet: {
|
|
815
|
+
readonly footnoteLabels: ReadonlySet<string>;
|
|
816
|
+
readonly linkLabels: ReadonlySet<string>;
|
|
817
|
+
};
|
|
818
|
+
/** Monotonic version counter bumped by every mutation. **Read-only from
|
|
819
|
+
* outside** — consumers should observe via `subscribe`, not by writing. */
|
|
820
|
+
readonly version: number;
|
|
821
|
+
/** Allocate (or reuse, for Strict Mode remount) the chunk Symbol for
|
|
822
|
+
* `reactId` AND publish this chunk's own def labels (footnotes + links)
|
|
823
|
+
* in one call. Canonical pair API used by `MarkdownContent`'s allocate
|
|
824
|
+
* effect — combining the two reduces the pair to a single registry
|
|
825
|
+
* version step, which downstream consumers see as one wake-up rather
|
|
826
|
+
* than two (the second was already coalesced by microtask, but this
|
|
827
|
+
* keeps the version monotonic-by-1-per-mount which makes debugging
|
|
828
|
+
* easier). The granular `allocateSymbol` / `contributeLabels` methods
|
|
829
|
+
* remain available for tests that need to exercise each step. */
|
|
830
|
+
registerChunk(reactId: string, footnotes: Set<string>, links: Set<string>): symbol;
|
|
831
|
+
allocateSymbol(reactId: string): symbol;
|
|
832
|
+
releaseSymbol(reactId: string): void;
|
|
833
|
+
contributeLabels(symbol: symbol, footnotes: Set<string>, links: Set<string>): void;
|
|
834
|
+
contributeChunkData(symbol: symbol, data: ChunkData): void;
|
|
835
|
+
subscribe(cb: () => void): () => void;
|
|
836
|
+
canonicalFootnoteFor(label: string): symbol | null;
|
|
837
|
+
canonicalLinkFor(label: string): symbol | null;
|
|
838
|
+
globalNumber(label: string): number | null;
|
|
839
|
+
resolveLinkDef(label: string): LinkDef | null;
|
|
840
|
+
getRefsForLabel(label: string): number;
|
|
841
|
+
/** Map a chunk-local footnote-ref occurrence index (1-based, as emitted by
|
|
842
|
+
* `customMdastHandlers`) to the corresponding document-wide occurrence
|
|
843
|
+
* index across all chunks. Used by `FootnoteSupNumber` to build a unique
|
|
844
|
+
* `id="fnref-X-N"` for each ref instance and by `AggregateFootnotesIfLast`
|
|
845
|
+
* to enumerate per-occurrence backrefs. Returns `null` if the ref isn't
|
|
846
|
+
* registered yet (registry mid-flight). */
|
|
847
|
+
globalOccurrenceForRef(chunkSym: symbol, label: string, localOccurrence: number): number | null;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Optional outer wrapper enabling cross-chunk coordination for any
|
|
852
|
+
* `<AIMarkdown>` instances rendered as descendants. Each unique
|
|
853
|
+
* `documentId` partitions its own Registry.
|
|
854
|
+
*
|
|
855
|
+
* Without this wrapper, `<AIMarkdown>` instances render independently
|
|
856
|
+
* (current behavior). With it, multiple chunks sharing a `documentId`
|
|
857
|
+
* coordinate footnote numbering, linkReference/imageReference resolution,
|
|
858
|
+
* and anchor jumps across chunks.
|
|
859
|
+
*
|
|
860
|
+
* @module components/AIMarkdownDocuments
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
interface AIMarkdownDocumentsProps extends PropsWithChildren {
|
|
864
|
+
/**
|
|
865
|
+
* Default `true`. Unconditionally controls orphan-reference protection
|
|
866
|
+
* for all chunks under this wrapper, overriding their individual
|
|
867
|
+
* `config.preserveOrphanReferences`. Does not control cross-chunk
|
|
868
|
+
* coordination itself (that's gated by wrapper presence + `documentId`).
|
|
869
|
+
*/
|
|
870
|
+
preserveOrphanReferences?: boolean;
|
|
871
|
+
}
|
|
872
|
+
declare const AIMarkdownDocuments: FC<AIMarkdownDocumentsProps>;
|
|
873
|
+
/**
|
|
874
|
+
* Returns the registry for the given `documentId`, or `null` if:
|
|
875
|
+
* - `<AIMarkdown>` is not inside an `<AIMarkdownDocuments>` wrapper, OR
|
|
876
|
+
* - `documentId` is undefined / empty string.
|
|
877
|
+
*
|
|
878
|
+
* Callers should treat `null` as "no coordination; run standalone path."
|
|
879
|
+
*/
|
|
880
|
+
declare function useDocumentRegistry(documentId: string | undefined): Registry | null;
|
|
881
|
+
|
|
729
882
|
/**
|
|
730
883
|
* Props for the `<AIMarkdown>` component.
|
|
731
884
|
*
|
|
@@ -804,4 +957,4 @@ interface AIMarkdownProps<TConfig extends AIMarkdownRenderConfig = AIMarkdownRen
|
|
|
804
957
|
declare const AIMarkdownComponent: <TConfig extends AIMarkdownRenderConfig = AIMarkdownRenderConfig, TRenderData extends AIMarkdownMetadata = AIMarkdownMetadata>({ streaming, content, fontSize, contentPreprocessors, customComponents, defaultConfig, config, metadata, Typography, ExtraStyles, variant, colorScheme, documentId, }: AIMarkdownProps<TConfig, TRenderData>) => react_jsx_runtime.JSX.Element;
|
|
805
958
|
declare const _default: typeof AIMarkdownComponent;
|
|
806
959
|
|
|
807
|
-
export { type AIMDContentPreprocessor, type AIMarkdownColorScheme, type AIMarkdownCustomComponents, type AIMarkdownExtraStylesComponent, type AIMarkdownExtraStylesProps, type AIMarkdownMetadata, type AIMarkdownProps, type AIMarkdownRenderConfig, AIMarkdownRenderDisplayOptimizeAbility, AIMarkdownRenderExtraSyntax, type AIMarkdownRenderState, type AIMarkdownTypographyComponent, type AIMarkdownTypographyProps, type AIMarkdownVariant, type PartialDeep, _default as default, defaultAIMarkdownRenderConfig, useAIMarkdownMetadata, useAIMarkdownRenderState, useStableValue };
|
|
960
|
+
export { type AIMDContentPreprocessor, type AIMarkdownColorScheme, type AIMarkdownCustomComponents, AIMarkdownDocuments, type AIMarkdownDocumentsProps, type AIMarkdownExtraStylesComponent, type AIMarkdownExtraStylesProps, type AIMarkdownMetadata, type AIMarkdownProps, type AIMarkdownRenderConfig, AIMarkdownRenderDisplayOptimizeAbility, AIMarkdownRenderExtraSyntax, type AIMarkdownRenderState, type AIMarkdownTypographyComponent, type AIMarkdownTypographyProps, type AIMarkdownVariant, type ChunkData, type FootnoteDef, type LinkDef, type PartialDeep, type RefKind, type RefRecord, type Registry, _default as default, defaultAIMarkdownRenderConfig, useAIMarkdownMetadata, useAIMarkdownRenderState, useDocumentRegistry, useStableValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { JSX, ComponentType, PropsWithChildren, CSSProperties } from 'react';
|
|
3
|
-
import { Element } from 'hast';
|
|
2
|
+
import { JSX, ComponentType, PropsWithChildren, CSSProperties, FC } from 'react';
|
|
3
|
+
import { Element, ElementContent } from 'hast';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Public types for the local Markdown wrapper. Ported 1:1 from react-markdown
|
|
@@ -93,6 +93,18 @@ interface AIMarkdownRenderConfig {
|
|
|
93
93
|
* @default true
|
|
94
94
|
*/
|
|
95
95
|
readonly blockMemoEnabled: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Default `true`. Controls Direction A: whether `<AIMarkdown>` (standalone
|
|
98
|
+
* mode) protects orphan `footnoteDefinition` nodes from being silently
|
|
99
|
+
* dropped by `mdast-util-to-hast` when no corresponding `footnoteReference`
|
|
100
|
+
* exists. Implemented via a custom `footnoteDefinition` handler that
|
|
101
|
+
* proactively registers the label in `state.footnoteOrder`.
|
|
102
|
+
*
|
|
103
|
+
* When `<AIMarkdown>` is wrapped in `<AIMarkdownDocuments>`, this field
|
|
104
|
+
* is ignored — the wrapper's `preserveOrphanReferences` prop overrides
|
|
105
|
+
* unconditionally for all chunks under it.
|
|
106
|
+
*/
|
|
107
|
+
readonly preserveOrphanReferences: boolean;
|
|
96
108
|
}
|
|
97
109
|
/**
|
|
98
110
|
* Sensible default configuration with all extensions and optimizations enabled.
|
|
@@ -103,6 +115,7 @@ declare const defaultAIMarkdownRenderConfig: Readonly<{
|
|
|
103
115
|
extraSyntaxSupported: readonly AIMarkdownRenderExtraSyntax[];
|
|
104
116
|
displayOptimizeAbilities: readonly AIMarkdownRenderDisplayOptimizeAbility[];
|
|
105
117
|
blockMemoEnabled: true;
|
|
118
|
+
preserveOrphanReferences: true;
|
|
106
119
|
}>;
|
|
107
120
|
/**
|
|
108
121
|
* Arbitrary metadata that consumers can pass through a dedicated React context.
|
|
@@ -202,6 +215,14 @@ interface AIMarkdownRenderState<TConfig extends AIMarkdownRenderConfig = AIMarkd
|
|
|
202
215
|
* always win.
|
|
203
216
|
*/
|
|
204
217
|
documentId: string;
|
|
218
|
+
/**
|
|
219
|
+
* Per-document URI-safe id prefix used by all clobberable attributes
|
|
220
|
+
* (`id="…"` / `href="#…"`). Derived once by the provider as
|
|
221
|
+
* `${encodeURIComponent(documentId)}-user-content-` and exposed here so
|
|
222
|
+
* downstream consumers (placeholder components, cross-chunk anchor logic)
|
|
223
|
+
* read a single canonical source instead of recomputing locally.
|
|
224
|
+
*/
|
|
225
|
+
clobberPrefix: string;
|
|
205
226
|
/** Active render configuration. */
|
|
206
227
|
config: TConfig;
|
|
207
228
|
}
|
|
@@ -726,6 +747,138 @@ type AIMDContentPreprocessor = (content: string) => string;
|
|
|
726
747
|
*/
|
|
727
748
|
declare function useStableValue<T>(value: T): T;
|
|
728
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Cross-chunk shared state. Holds per-chunk contributions (refs, defs,
|
|
752
|
+
* linkDefs) keyed by Symbol identity allocated via useId reactId, with
|
|
753
|
+
* refcount + microtask-deferred reclamation for React Strict Mode safety.
|
|
754
|
+
*
|
|
755
|
+
* @module components/documentRegistry
|
|
756
|
+
*/
|
|
757
|
+
|
|
758
|
+
interface FootnoteDef {
|
|
759
|
+
/** Already-normalized identifier (uppercase). Used as dictionary key for
|
|
760
|
+
* case-insensitive cross-chunk lookups. */
|
|
761
|
+
identifier: string;
|
|
762
|
+
/** mdast's case-folded identifier — the exact string mdast-util-to-hast
|
|
763
|
+
* emits in `<li id="${clobberPrefix}fn-${sourceIdentifier}">` and that
|
|
764
|
+
* `FootnoteSupNumber` mirrors in its anchor href. Needed so the aggregate
|
|
765
|
+
* footer's `<li id>` and backref href match the inline `<sup>`'s href
|
|
766
|
+
* exactly (otherwise hash navigation breaks). Optional so unit-test
|
|
767
|
+
* fixtures don't need to fabricate it; production data always supplies it. */
|
|
768
|
+
sourceIdentifier?: string;
|
|
769
|
+
/** Content extracted from the source markdown footnote definition. */
|
|
770
|
+
contentSource: string;
|
|
771
|
+
/** Per-def hast body (the def's mdast children after mdast-util-to-hast
|
|
772
|
+
* conversion). Drives AggregateFootnotesIfLast to render the consolidated
|
|
773
|
+
* footer at the end of each document's last chunk. Optional so unit-test
|
|
774
|
+
* fixtures can build minimal FootnoteDef objects without producing hast. */
|
|
775
|
+
bodyHast?: ElementContent[];
|
|
776
|
+
}
|
|
777
|
+
interface LinkDef {
|
|
778
|
+
/** Already-normalized identifier (uppercase). */
|
|
779
|
+
identifier: string;
|
|
780
|
+
url: string;
|
|
781
|
+
title?: string;
|
|
782
|
+
}
|
|
783
|
+
type RefKind = 'footnote' | 'link' | 'image';
|
|
784
|
+
interface RefRecord {
|
|
785
|
+
/** Already-normalized identifier (uppercase). */
|
|
786
|
+
label: string;
|
|
787
|
+
/** Which markdown reference space this entry belongs to. Footnote refs,
|
|
788
|
+
* link refs, and image refs occupy disjoint namespaces in GFM, so they
|
|
789
|
+
* must be filtered separately when computing footnote numbers / refcounts. */
|
|
790
|
+
kind: RefKind;
|
|
791
|
+
referenceType?: 'full' | 'collapsed' | 'shortcut';
|
|
792
|
+
}
|
|
793
|
+
interface ChunkData {
|
|
794
|
+
refs: RefRecord[];
|
|
795
|
+
defs: Map<string, FootnoteDef>;
|
|
796
|
+
linkDefs: Map<string, LinkDef>;
|
|
797
|
+
ownFootnoteLabels: Set<string>;
|
|
798
|
+
ownLinkLabels: Set<string>;
|
|
799
|
+
}
|
|
800
|
+
interface Registry {
|
|
801
|
+
/** Chunk mount-order Symbol list. **Read-only from outside the registry.**
|
|
802
|
+
* Direct mutation (`.push`, `.splice`, index assignment) corrupts
|
|
803
|
+
* footnote numbering, "last chunk" detection, and eviction. Use the
|
|
804
|
+
* `allocateSymbol` / `releaseSymbol` / `registerChunk` API instead. */
|
|
805
|
+
readonly chunkOrder: readonly symbol[];
|
|
806
|
+
/** Chunk Symbol → contribution payload. **Read-only from outside.**
|
|
807
|
+
* Use `contributeChunkData` / `contributeLabels` / `registerChunk` to
|
|
808
|
+
* publish; direct `.set` / `.delete` bypasses version bumps and
|
|
809
|
+
* subscriber wake-ups. */
|
|
810
|
+
readonly chunkData: ReadonlyMap<symbol, ChunkData>;
|
|
811
|
+
/** Union of own-def labels across all chunks. PASS 0.5 phantom-injection
|
|
812
|
+
* driver. **Read-only from outside.** The registry derives this from
|
|
813
|
+
* per-chunk contributions; direct mutation breaks the derivation. */
|
|
814
|
+
readonly labelSet: {
|
|
815
|
+
readonly footnoteLabels: ReadonlySet<string>;
|
|
816
|
+
readonly linkLabels: ReadonlySet<string>;
|
|
817
|
+
};
|
|
818
|
+
/** Monotonic version counter bumped by every mutation. **Read-only from
|
|
819
|
+
* outside** — consumers should observe via `subscribe`, not by writing. */
|
|
820
|
+
readonly version: number;
|
|
821
|
+
/** Allocate (or reuse, for Strict Mode remount) the chunk Symbol for
|
|
822
|
+
* `reactId` AND publish this chunk's own def labels (footnotes + links)
|
|
823
|
+
* in one call. Canonical pair API used by `MarkdownContent`'s allocate
|
|
824
|
+
* effect — combining the two reduces the pair to a single registry
|
|
825
|
+
* version step, which downstream consumers see as one wake-up rather
|
|
826
|
+
* than two (the second was already coalesced by microtask, but this
|
|
827
|
+
* keeps the version monotonic-by-1-per-mount which makes debugging
|
|
828
|
+
* easier). The granular `allocateSymbol` / `contributeLabels` methods
|
|
829
|
+
* remain available for tests that need to exercise each step. */
|
|
830
|
+
registerChunk(reactId: string, footnotes: Set<string>, links: Set<string>): symbol;
|
|
831
|
+
allocateSymbol(reactId: string): symbol;
|
|
832
|
+
releaseSymbol(reactId: string): void;
|
|
833
|
+
contributeLabels(symbol: symbol, footnotes: Set<string>, links: Set<string>): void;
|
|
834
|
+
contributeChunkData(symbol: symbol, data: ChunkData): void;
|
|
835
|
+
subscribe(cb: () => void): () => void;
|
|
836
|
+
canonicalFootnoteFor(label: string): symbol | null;
|
|
837
|
+
canonicalLinkFor(label: string): symbol | null;
|
|
838
|
+
globalNumber(label: string): number | null;
|
|
839
|
+
resolveLinkDef(label: string): LinkDef | null;
|
|
840
|
+
getRefsForLabel(label: string): number;
|
|
841
|
+
/** Map a chunk-local footnote-ref occurrence index (1-based, as emitted by
|
|
842
|
+
* `customMdastHandlers`) to the corresponding document-wide occurrence
|
|
843
|
+
* index across all chunks. Used by `FootnoteSupNumber` to build a unique
|
|
844
|
+
* `id="fnref-X-N"` for each ref instance and by `AggregateFootnotesIfLast`
|
|
845
|
+
* to enumerate per-occurrence backrefs. Returns `null` if the ref isn't
|
|
846
|
+
* registered yet (registry mid-flight). */
|
|
847
|
+
globalOccurrenceForRef(chunkSym: symbol, label: string, localOccurrence: number): number | null;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Optional outer wrapper enabling cross-chunk coordination for any
|
|
852
|
+
* `<AIMarkdown>` instances rendered as descendants. Each unique
|
|
853
|
+
* `documentId` partitions its own Registry.
|
|
854
|
+
*
|
|
855
|
+
* Without this wrapper, `<AIMarkdown>` instances render independently
|
|
856
|
+
* (current behavior). With it, multiple chunks sharing a `documentId`
|
|
857
|
+
* coordinate footnote numbering, linkReference/imageReference resolution,
|
|
858
|
+
* and anchor jumps across chunks.
|
|
859
|
+
*
|
|
860
|
+
* @module components/AIMarkdownDocuments
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
interface AIMarkdownDocumentsProps extends PropsWithChildren {
|
|
864
|
+
/**
|
|
865
|
+
* Default `true`. Unconditionally controls orphan-reference protection
|
|
866
|
+
* for all chunks under this wrapper, overriding their individual
|
|
867
|
+
* `config.preserveOrphanReferences`. Does not control cross-chunk
|
|
868
|
+
* coordination itself (that's gated by wrapper presence + `documentId`).
|
|
869
|
+
*/
|
|
870
|
+
preserveOrphanReferences?: boolean;
|
|
871
|
+
}
|
|
872
|
+
declare const AIMarkdownDocuments: FC<AIMarkdownDocumentsProps>;
|
|
873
|
+
/**
|
|
874
|
+
* Returns the registry for the given `documentId`, or `null` if:
|
|
875
|
+
* - `<AIMarkdown>` is not inside an `<AIMarkdownDocuments>` wrapper, OR
|
|
876
|
+
* - `documentId` is undefined / empty string.
|
|
877
|
+
*
|
|
878
|
+
* Callers should treat `null` as "no coordination; run standalone path."
|
|
879
|
+
*/
|
|
880
|
+
declare function useDocumentRegistry(documentId: string | undefined): Registry | null;
|
|
881
|
+
|
|
729
882
|
/**
|
|
730
883
|
* Props for the `<AIMarkdown>` component.
|
|
731
884
|
*
|
|
@@ -804,4 +957,4 @@ interface AIMarkdownProps<TConfig extends AIMarkdownRenderConfig = AIMarkdownRen
|
|
|
804
957
|
declare const AIMarkdownComponent: <TConfig extends AIMarkdownRenderConfig = AIMarkdownRenderConfig, TRenderData extends AIMarkdownMetadata = AIMarkdownMetadata>({ streaming, content, fontSize, contentPreprocessors, customComponents, defaultConfig, config, metadata, Typography, ExtraStyles, variant, colorScheme, documentId, }: AIMarkdownProps<TConfig, TRenderData>) => react_jsx_runtime.JSX.Element;
|
|
805
958
|
declare const _default: typeof AIMarkdownComponent;
|
|
806
959
|
|
|
807
|
-
export { type AIMDContentPreprocessor, type AIMarkdownColorScheme, type AIMarkdownCustomComponents, type AIMarkdownExtraStylesComponent, type AIMarkdownExtraStylesProps, type AIMarkdownMetadata, type AIMarkdownProps, type AIMarkdownRenderConfig, AIMarkdownRenderDisplayOptimizeAbility, AIMarkdownRenderExtraSyntax, type AIMarkdownRenderState, type AIMarkdownTypographyComponent, type AIMarkdownTypographyProps, type AIMarkdownVariant, type PartialDeep, _default as default, defaultAIMarkdownRenderConfig, useAIMarkdownMetadata, useAIMarkdownRenderState, useStableValue };
|
|
960
|
+
export { type AIMDContentPreprocessor, type AIMarkdownColorScheme, type AIMarkdownCustomComponents, AIMarkdownDocuments, type AIMarkdownDocumentsProps, type AIMarkdownExtraStylesComponent, type AIMarkdownExtraStylesProps, type AIMarkdownMetadata, type AIMarkdownProps, type AIMarkdownRenderConfig, AIMarkdownRenderDisplayOptimizeAbility, AIMarkdownRenderExtraSyntax, type AIMarkdownRenderState, type AIMarkdownTypographyComponent, type AIMarkdownTypographyProps, type AIMarkdownVariant, type ChunkData, type FootnoteDef, type LinkDef, type PartialDeep, type RefKind, type RefRecord, type Registry, _default as default, defaultAIMarkdownRenderConfig, useAIMarkdownMetadata, useAIMarkdownRenderState, useDocumentRegistry, useStableValue };
|