ant-design-x-vue-next
Version:
Ant Design X for Vue — community continuation aligned with @ant-design/x
40 lines (39 loc) • 1.52 kB
TypeScript
import { StreamCacheTokenType } from './interface';
export interface StreamCache {
pending: string;
token: StreamCacheTokenType;
processedLength: number;
completeMarkdown: string;
fence: FenceState;
}
/**
* Incremental fenced-code-block state over the processed text, updated in O(1)
* per character. Recomputing over the full accumulated text on every character
* is O(N²) and freezes the page on long single-line content such as base64
* image data URIs.
*/
interface FenceState {
inFenced: boolean;
fenceChar: string;
fenceLen: number;
lineFenceChar: string;
lineFenceLen: number;
lineFenceRunEnded: boolean;
lineTailBlank: boolean;
}
export declare const getInitialCache: () => StreamCache;
export declare const safeEncodeURIComponent: (str: string) => string;
export type IncompleteComponentMap = Partial<Record<Exclude<StreamCacheTokenType, StreamCacheTokenType.Text>, string>>;
export declare function buildIncompletePlaceholder(cache: StreamCache, options?: {
incompleteMarkdownComponentMap?: IncompleteComponentMap;
componentNames?: string[];
}): string | undefined;
/**
* Feed incremental markdown into the stream cache and return renderable output.
* Incomplete tokens are held in `pending` until closed (or replaced by placeholder).
*/
export declare function processStreamingText(cache: StreamCache, text: string, options?: {
incompleteMarkdownComponentMap?: IncompleteComponentMap;
componentNames?: string[];
}): string;
export {};