@nicomatt69/streamdown-tty 2.1.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/CHANGELOG.md +113 -0
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/dist/adapters/index.d.ts +185 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/ai-sdk-adapter.d.ts +113 -0
- package/dist/ai-sdk-adapter.d.ts.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/core/index.d.ts +209 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/math-renderer.d.ts +40 -0
- package/dist/core/math-renderer.d.ts.map +1 -0
- package/dist/core/parser.d.ts +139 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/protocol.d.ts +319 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/remend-tty.d.ts +68 -0
- package/dist/core/remend-tty.d.ts.map +1 -0
- package/dist/core/renderer.d.ts +286 -0
- package/dist/core/renderer.d.ts.map +1 -0
- package/dist/errors.d.ts +131 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/events.d.ts +185 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12921 -0
- package/dist/parser/streaming-parser.d.ts +81 -0
- package/dist/parser/streaming-parser.d.ts.map +1 -0
- package/dist/performance.d.ts +139 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/plugin-system-inline.d.ts +116 -0
- package/dist/plugins/plugin-system-inline.d.ts.map +1 -0
- package/dist/plugins/plugin-system.d.ts +65 -0
- package/dist/plugins/plugin-system.d.ts.map +1 -0
- package/dist/plugins/rehype/harden.d.ts +15 -0
- package/dist/plugins/rehype/harden.d.ts.map +1 -0
- package/dist/plugins/rehype/index.d.ts +5 -0
- package/dist/plugins/rehype/index.d.ts.map +1 -0
- package/dist/plugins/remark/index.d.ts +6 -0
- package/dist/plugins/remark/index.d.ts.map +1 -0
- package/dist/plugins/remark/math.d.ts +7 -0
- package/dist/plugins/remark/math.d.ts.map +1 -0
- package/dist/plugins/remark/mermaid.d.ts +7 -0
- package/dist/plugins/remark/mermaid.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +72 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/renderer/ansi-renderer.d.ts +76 -0
- package/dist/renderer/ansi-renderer.d.ts.map +1 -0
- package/dist/renderers/index.d.ts +7 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/math-renderer.d.ts +49 -0
- package/dist/renderers/math-renderer.d.ts.map +1 -0
- package/dist/renderers/mermaid-ascii.d.ts +14 -0
- package/dist/renderers/mermaid-ascii.d.ts.map +1 -0
- package/dist/renderers/mermaid-renderer.d.ts +79 -0
- package/dist/renderers/mermaid-renderer.d.ts.map +1 -0
- package/dist/renderers/shiki-ansi.d.ts +48 -0
- package/dist/renderers/shiki-ansi.d.ts.map +1 -0
- package/dist/renderers/table-ascii.d.ts +30 -0
- package/dist/renderers/table-ascii.d.ts.map +1 -0
- package/dist/renderers/unicode-math.d.ts +29 -0
- package/dist/renderers/unicode-math.d.ts.map +1 -0
- package/dist/security/ansi-sanitizer.d.ts +71 -0
- package/dist/security/ansi-sanitizer.d.ts.map +1 -0
- package/dist/security/chunk-processor.d.ts +81 -0
- package/dist/security/chunk-processor.d.ts.map +1 -0
- package/dist/security/index.d.ts +6 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/input-validator.d.ts +55 -0
- package/dist/security/input-validator.d.ts.map +1 -0
- package/dist/stream-protocol.d.ts +61 -0
- package/dist/stream-protocol.d.ts.map +1 -0
- package/dist/streamdown-compat.d.ts +72 -0
- package/dist/streamdown-compat.d.ts.map +1 -0
- package/dist/streaming/stream-stats.d.ts +97 -0
- package/dist/streaming/stream-stats.d.ts.map +1 -0
- package/dist/streaming-integration.d.ts +71 -0
- package/dist/streaming-integration.d.ts.map +1 -0
- package/dist/themes/index.d.ts +59 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +168 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/plugin-types.d.ts +5 -0
- package/dist/types/plugin-types.d.ts.map +1 -0
- package/dist/types/stream-events.d.ts +71 -0
- package/dist/types/stream-events.d.ts.map +1 -0
- package/dist/utils/blessed-syntax-highlighter.d.ts +124 -0
- package/dist/utils/blessed-syntax-highlighter.d.ts.map +1 -0
- package/dist/utils/enhanced-table-renderer.d.ts +77 -0
- package/dist/utils/enhanced-table-renderer.d.ts.map +1 -0
- package/dist/utils/formatting.d.ts +100 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/math-unicode-renderer.d.ts +38 -0
- package/dist/utils/math-unicode-renderer.d.ts.map +1 -0
- package/dist/utils/mermaid-ascii-renderer.d.ts +20 -0
- package/dist/utils/mermaid-ascii-renderer.d.ts.map +1 -0
- package/dist/utils/mermaid-ascii.d.ts +53 -0
- package/dist/utils/mermaid-ascii.d.ts.map +1 -0
- package/dist/utils/shiki-ansi-renderer.d.ts +29 -0
- package/dist/utils/shiki-ansi-renderer.d.ts.map +1 -0
- package/dist/utils/syntax-highlighter.d.ts +87 -0
- package/dist/utils/syntax-highlighter.d.ts.map +1 -0
- package/dist/utils/table-formatter-inline.d.ts +37 -0
- package/dist/utils/table-formatter-inline.d.ts.map +1 -0
- package/dist/utils/table.d.ts +35 -0
- package/dist/utils/table.d.ts.map +1 -0
- package/dist/widgets/stream-indicator.d.ts +130 -0
- package/dist/widgets/stream-indicator.d.ts.map +1 -0
- package/package.json +129 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ParsedToken } from '../types';
|
|
2
|
+
export declare class StreamingMarkdownParser {
|
|
3
|
+
private buffer;
|
|
4
|
+
private tokens;
|
|
5
|
+
private parseIncomplete;
|
|
6
|
+
constructor(parseIncomplete?: boolean);
|
|
7
|
+
/**
|
|
8
|
+
* Add chunk to buffer and parse
|
|
9
|
+
*/
|
|
10
|
+
addChunk(chunk: string): ParsedToken[];
|
|
11
|
+
/**
|
|
12
|
+
* Preprocess text to handle HTML entities and custom tags
|
|
13
|
+
* NOTE: ANSI codes are preserved for terminal color rendering
|
|
14
|
+
*/
|
|
15
|
+
private preprocessText;
|
|
16
|
+
/**
|
|
17
|
+
* Parse current buffer for blessed rendering
|
|
18
|
+
*/
|
|
19
|
+
parse(): ParsedToken[];
|
|
20
|
+
/**
|
|
21
|
+
* Process tokens with enhanced diagram detection
|
|
22
|
+
*/
|
|
23
|
+
private processTokensWithDiagramDetection;
|
|
24
|
+
/**
|
|
25
|
+
* Check if code looks like mermaid syntax
|
|
26
|
+
*/
|
|
27
|
+
private looksLikeMermaidCode;
|
|
28
|
+
/**
|
|
29
|
+
* Convert table token to markdown format
|
|
30
|
+
*/
|
|
31
|
+
private convertTableTokenToMarkdown;
|
|
32
|
+
/**
|
|
33
|
+
* Parse inline formatting from text that wasn't processed by marked.js
|
|
34
|
+
*/
|
|
35
|
+
private parseInlineFromText;
|
|
36
|
+
/**
|
|
37
|
+
* Process tokens to extract inline formatting
|
|
38
|
+
*/
|
|
39
|
+
private processInlineTokens;
|
|
40
|
+
/**
|
|
41
|
+
* Flatten inline tokens recursively
|
|
42
|
+
*/
|
|
43
|
+
private flattenInlineTokens;
|
|
44
|
+
/**
|
|
45
|
+
* Parse partial/incomplete markdown
|
|
46
|
+
*/
|
|
47
|
+
private parsePartial;
|
|
48
|
+
/**
|
|
49
|
+
* Parse a single line that might be incomplete
|
|
50
|
+
*/
|
|
51
|
+
private parseIncompleteLine;
|
|
52
|
+
/**
|
|
53
|
+
* Handle incomplete markdown patterns
|
|
54
|
+
*/
|
|
55
|
+
private handleIncompleteMarkdown;
|
|
56
|
+
/**
|
|
57
|
+
* Parse inline formatting (bold, italic, code, links)
|
|
58
|
+
*/
|
|
59
|
+
private parseInlineFormatting;
|
|
60
|
+
/**
|
|
61
|
+
* Convert marked tokens to our format
|
|
62
|
+
*/
|
|
63
|
+
private convertTokens;
|
|
64
|
+
/**
|
|
65
|
+
* Convert a single marked token
|
|
66
|
+
*/
|
|
67
|
+
private convertToken;
|
|
68
|
+
/**
|
|
69
|
+
* Clear buffer
|
|
70
|
+
*/
|
|
71
|
+
clear(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Get current buffer
|
|
74
|
+
*/
|
|
75
|
+
getBuffer(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get current tokens
|
|
78
|
+
*/
|
|
79
|
+
getTokens(): ParsedToken[];
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=streaming-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-parser.d.ts","sourceRoot":"","sources":["../../src/parser/streaming-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAKlD,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,eAAe,CAAU;gBAErB,eAAe,GAAE,OAAc;IAU3C;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE;IAO7C;;;OAGG;IACH,OAAO,CAAC,cAAc;IAmCtB;;OAEG;IACI,KAAK,IAAI,WAAW,EAAE;IAoB7B;;OAEG;IACH,OAAO,CAAC,iCAAiC;IA2BzC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAqCnC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyE3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAoC3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;OAEG;IACH,OAAO,CAAC,YAAY;IAepB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+C3B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAwBhC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;OAEG;IACH,OAAO,CAAC,aAAa;IAiBrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAqHpB;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;OAEG;IACI,SAAS,IAAI,MAAM;IAI1B;;OAEG;IACI,SAAS,IAAI,WAAW,EAAE;CAGlC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Monitoring
|
|
3
|
+
*
|
|
4
|
+
* This module provides lightweight performance tracking for streamtty operations,
|
|
5
|
+
* including parse/render times, memory usage, and performance warnings.
|
|
6
|
+
*/
|
|
7
|
+
import { StreamttyEventEmitter } from './events';
|
|
8
|
+
export interface PerformanceMetrics {
|
|
9
|
+
operation: string;
|
|
10
|
+
startTime: number;
|
|
11
|
+
endTime?: number;
|
|
12
|
+
duration?: number;
|
|
13
|
+
memoryBefore?: NodeJS.MemoryUsage;
|
|
14
|
+
memoryAfter?: NodeJS.MemoryUsage;
|
|
15
|
+
memoryDelta?: NodeJS.MemoryUsage;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export interface PerformanceThresholds {
|
|
19
|
+
parseTime: number;
|
|
20
|
+
renderTime: number;
|
|
21
|
+
memoryUsage: number;
|
|
22
|
+
chunkSize: number;
|
|
23
|
+
tokenCount: number;
|
|
24
|
+
}
|
|
25
|
+
export interface PerformanceConfig {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
thresholds: PerformanceThresholds;
|
|
28
|
+
sampleRate: number;
|
|
29
|
+
maxHistorySize: number;
|
|
30
|
+
enableWarnings: boolean;
|
|
31
|
+
enableMemoryTracking: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare class PerformanceMonitor {
|
|
34
|
+
private config;
|
|
35
|
+
private metrics;
|
|
36
|
+
private activeOperations;
|
|
37
|
+
private eventEmitter;
|
|
38
|
+
private sampleCounter;
|
|
39
|
+
constructor(config?: Partial<PerformanceConfig>, eventEmitter?: StreamttyEventEmitter);
|
|
40
|
+
/**
|
|
41
|
+
* Start timing an operation
|
|
42
|
+
*/
|
|
43
|
+
startOperation(operation: string, metadata?: Record<string, any>): string;
|
|
44
|
+
/**
|
|
45
|
+
* End timing an operation
|
|
46
|
+
*/
|
|
47
|
+
endOperation(operationId: string): PerformanceMetrics | null;
|
|
48
|
+
/**
|
|
49
|
+
* Measure a function execution
|
|
50
|
+
*/
|
|
51
|
+
measure<T>(operation: string, fn: () => Promise<T>, metadata?: Record<string, any>): Promise<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Measure synchronous function execution
|
|
54
|
+
*/
|
|
55
|
+
measureSync<T>(operation: string, fn: () => T, metadata?: Record<string, any>): T;
|
|
56
|
+
/**
|
|
57
|
+
* Get performance statistics
|
|
58
|
+
*/
|
|
59
|
+
getStats(operation?: string): {
|
|
60
|
+
totalOperations: number;
|
|
61
|
+
averageDuration: number;
|
|
62
|
+
minDuration: number;
|
|
63
|
+
maxDuration: number;
|
|
64
|
+
slowOperations: number;
|
|
65
|
+
memoryUsage: {
|
|
66
|
+
current: NodeJS.MemoryUsage;
|
|
67
|
+
peak: number;
|
|
68
|
+
average: number;
|
|
69
|
+
};
|
|
70
|
+
recentMetrics: PerformanceMetrics[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Get operation breakdown
|
|
74
|
+
*/
|
|
75
|
+
getOperationBreakdown(): Record<string, {
|
|
76
|
+
count: number;
|
|
77
|
+
averageDuration: number;
|
|
78
|
+
totalDuration: number;
|
|
79
|
+
slowCount: number;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Clear metrics history
|
|
83
|
+
*/
|
|
84
|
+
clearMetrics(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Update configuration
|
|
87
|
+
*/
|
|
88
|
+
updateConfig(config: Partial<PerformanceConfig>): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get current configuration
|
|
91
|
+
*/
|
|
92
|
+
getConfig(): PerformanceConfig;
|
|
93
|
+
/**
|
|
94
|
+
* Check if operation should be sampled
|
|
95
|
+
*/
|
|
96
|
+
private shouldSample;
|
|
97
|
+
/**
|
|
98
|
+
* Add metric to history
|
|
99
|
+
*/
|
|
100
|
+
private addMetric;
|
|
101
|
+
/**
|
|
102
|
+
* Check if operation exceeds thresholds
|
|
103
|
+
*/
|
|
104
|
+
private checkThresholds;
|
|
105
|
+
/**
|
|
106
|
+
* Check if operation is slow
|
|
107
|
+
*/
|
|
108
|
+
private isSlowOperation;
|
|
109
|
+
/**
|
|
110
|
+
* Get threshold for operation type
|
|
111
|
+
*/
|
|
112
|
+
private getThresholdForOperation;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Performance utilities
|
|
116
|
+
*/
|
|
117
|
+
export declare class PerformanceUtils {
|
|
118
|
+
/**
|
|
119
|
+
* Format duration in human-readable format
|
|
120
|
+
*/
|
|
121
|
+
static formatDuration(ms: number): string;
|
|
122
|
+
/**
|
|
123
|
+
* Format memory usage in human-readable format
|
|
124
|
+
*/
|
|
125
|
+
static formatMemory(bytes: number): string;
|
|
126
|
+
/**
|
|
127
|
+
* Create a performance report
|
|
128
|
+
*/
|
|
129
|
+
static createReport(monitor: PerformanceMonitor): string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Global performance monitor instance
|
|
133
|
+
*/
|
|
134
|
+
export declare const globalPerformanceMonitor: PerformanceMonitor;
|
|
135
|
+
/**
|
|
136
|
+
* Decorator for automatic performance tracking
|
|
137
|
+
*/
|
|
138
|
+
export declare function trackPerformance(operation: string, metadata?: Record<string, any>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
139
|
+
//# sourceMappingURL=performance.d.ts.map
|
|
@@ -0,0 +1 @@
|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AAS,IAAI,iBAAiB;IAI9B;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,SAAS;IASjB;;OAEG;IACH,OAAO,CAAC,eAAe;IAkEvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACH,OAAO,CAAC,wBAAwB;CASjC;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAUzC;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAa1C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM;CA6BzD;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,oBAA2B,CAAC;AAEjE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAChE,QAAQ,GAAG,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAqBjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline Plugin System for StreamTTY
|
|
3
|
+
* Minimal but powerful plugin architecture
|
|
4
|
+
*/
|
|
5
|
+
import { ParsedToken } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Plugin context - passed to all hooks
|
|
8
|
+
*/
|
|
9
|
+
export interface PluginContext {
|
|
10
|
+
isStreaming: boolean;
|
|
11
|
+
totalChunksProcessed: number;
|
|
12
|
+
lastChunkSize: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Plugin definition
|
|
16
|
+
*/
|
|
17
|
+
export interface StreamPlugin {
|
|
18
|
+
name: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
onInit?(): Promise<void>;
|
|
22
|
+
onDestroy?(): Promise<void>;
|
|
23
|
+
onChunk?(chunk: string, ctx: PluginContext): Promise<string>;
|
|
24
|
+
onTokens?(tokens: ParsedToken[], ctx: PluginContext): Promise<ParsedToken[]>;
|
|
25
|
+
onRender?(content: string, ctx: PluginContext): Promise<string>;
|
|
26
|
+
onError?(error: Error, ctx: PluginContext): Promise<void>;
|
|
27
|
+
onComplete?(stats: StreamStats, ctx: PluginContext): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Plugin registry and executor
|
|
31
|
+
*/
|
|
32
|
+
export declare class PluginRegistry {
|
|
33
|
+
private plugins;
|
|
34
|
+
private context;
|
|
35
|
+
private initialized;
|
|
36
|
+
constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Register a plugin
|
|
39
|
+
*/
|
|
40
|
+
register(plugin: StreamPlugin): void;
|
|
41
|
+
/**
|
|
42
|
+
* Unregister a plugin
|
|
43
|
+
*/
|
|
44
|
+
unregister(name: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Initialize all plugins
|
|
47
|
+
*/
|
|
48
|
+
init(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Destroy all plugins
|
|
51
|
+
*/
|
|
52
|
+
destroy(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Execute onChunk hooks
|
|
55
|
+
*/
|
|
56
|
+
executeChunk(chunk: string): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Execute onTokens hooks
|
|
59
|
+
*/
|
|
60
|
+
executeTokens(tokens: ParsedToken[]): Promise<ParsedToken[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Execute onRender hooks
|
|
63
|
+
*/
|
|
64
|
+
executeRender(content: string): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute onError hooks
|
|
67
|
+
*/
|
|
68
|
+
executeError(error: Error): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Execute onComplete hooks
|
|
71
|
+
*/
|
|
72
|
+
executeComplete(stats: StreamStats): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Get plugin by name
|
|
75
|
+
*/
|
|
76
|
+
get(name: string): StreamPlugin | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* List all plugins
|
|
79
|
+
*/
|
|
80
|
+
list(): StreamPlugin[];
|
|
81
|
+
/**
|
|
82
|
+
* Check if plugin exists
|
|
83
|
+
*/
|
|
84
|
+
has(name: string): boolean;
|
|
85
|
+
}
|
|
86
|
+
import { StreamStats } from '../streaming/stream-stats';
|
|
87
|
+
/**
|
|
88
|
+
* Math rendering plugin
|
|
89
|
+
*/
|
|
90
|
+
export declare const mathPlugin: StreamPlugin;
|
|
91
|
+
/**
|
|
92
|
+
* Mermaid rendering plugin
|
|
93
|
+
*/
|
|
94
|
+
export declare const mermaidPlugin: StreamPlugin;
|
|
95
|
+
/**
|
|
96
|
+
* Security/sanitization plugin
|
|
97
|
+
*/
|
|
98
|
+
export declare const securityPlugin: StreamPlugin;
|
|
99
|
+
/**
|
|
100
|
+
* Syntax highlighting plugin
|
|
101
|
+
*/
|
|
102
|
+
export declare const syntaxHighlightPlugin: StreamPlugin;
|
|
103
|
+
/**
|
|
104
|
+
* Create default plugin registry with built-in plugins
|
|
105
|
+
*/
|
|
106
|
+
export declare function createDefaultRegistry(): PluginRegistry;
|
|
107
|
+
/**
|
|
108
|
+
* Preset plugin configurations
|
|
109
|
+
*/
|
|
110
|
+
export declare const PLUGIN_PRESETS: {
|
|
111
|
+
minimal: StreamPlugin[];
|
|
112
|
+
standard: StreamPlugin[];
|
|
113
|
+
full: StreamPlugin[];
|
|
114
|
+
ai: StreamPlugin[];
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=plugin-system-inline.d.ts.map
|
|
@@ -0,0 +1 @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
|
+
import { ParsedToken, RenderContext } from '../types';
|
|
2
|
+
import { TTYPlugin, PluginContext, TTYPluggableList, HookPhase, HookFunction, PluginResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin system manager
|
|
5
|
+
* Handles plugin registration, loading, and execution
|
|
6
|
+
*/
|
|
7
|
+
export declare class PluginSystem {
|
|
8
|
+
private remarkPlugins;
|
|
9
|
+
private rehypePlugins;
|
|
10
|
+
private builtInPlugins;
|
|
11
|
+
private hooks;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Initialize hook maps
|
|
15
|
+
*/
|
|
16
|
+
private initializeHooks;
|
|
17
|
+
/**
|
|
18
|
+
* Register a built-in plugin
|
|
19
|
+
*/
|
|
20
|
+
registerBuiltIn(plugin: TTYPlugin): void;
|
|
21
|
+
/**
|
|
22
|
+
* Load plugins from pluggable list
|
|
23
|
+
*/
|
|
24
|
+
loadPlugins(remarkPlugins?: TTYPluggableList, rehypePlugins?: TTYPluggableList): void;
|
|
25
|
+
/**
|
|
26
|
+
* Load a single plugin
|
|
27
|
+
*/
|
|
28
|
+
private loadPlugin;
|
|
29
|
+
/**
|
|
30
|
+
* Process markdown through remark plugins (pre-parse)
|
|
31
|
+
*/
|
|
32
|
+
processRemark(markdown: string, context: RenderContext): Promise<PluginResult<string>>;
|
|
33
|
+
/**
|
|
34
|
+
* Process tokens through rehype plugins (post-parse)
|
|
35
|
+
*/
|
|
36
|
+
processRehype(tokens: ParsedToken[], context: RenderContext): Promise<PluginResult<ParsedToken[]>>;
|
|
37
|
+
/**
|
|
38
|
+
* Get plugins sorted by priority
|
|
39
|
+
*/
|
|
40
|
+
private getSortedPlugins;
|
|
41
|
+
/**
|
|
42
|
+
* Register a hook
|
|
43
|
+
*/
|
|
44
|
+
registerHook(phase: HookPhase, hook: HookFunction): void;
|
|
45
|
+
/**
|
|
46
|
+
* Execute hooks for a phase
|
|
47
|
+
*/
|
|
48
|
+
executeHooks(phase: HookPhase, data: any, context: PluginContext): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Clear all plugins
|
|
51
|
+
*/
|
|
52
|
+
clear(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get registered plugin count
|
|
55
|
+
*/
|
|
56
|
+
getPluginCount(): {
|
|
57
|
+
remark: number;
|
|
58
|
+
rehype: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Singleton plugin system instance
|
|
63
|
+
*/
|
|
64
|
+
export declare const pluginSystem: PluginSystem;
|
|
65
|
+
//# sourceMappingURL=plugin-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-system.d.ts","sourceRoot":"","sources":["../../src/plugins/plugin-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EACH,SAAS,EAGT,aAAa,EAEb,gBAAgB,EAEhB,SAAS,EACT,YAAY,EAEZ,YAAY,EACf,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,aAAa,CAA+C;IACpE,OAAO,CAAC,aAAa,CAA+C;IACpE,OAAO,CAAC,cAAc,CAAqC;IAC3D,OAAO,CAAC,KAAK,CAA6C;;IAM1D;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIxC;;OAEG;IACH,WAAW,CACP,aAAa,CAAC,EAAE,gBAAgB,EAChC,aAAa,CAAC,EAAE,gBAAgB,GACjC,IAAI;IAcP;;OAEG;IACH,OAAO,CAAC,UAAU;IA+ClB;;OAEG;IACG,aAAa,CACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,aAAa,GACvB,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IA4BhC;;OAEG;IACG,aAAa,CACf,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,EAAE,aAAa,GACvB,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;IA4BvC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;IAMxD;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAerF;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,cAAc,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAMvD;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RehypePlugin } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Rehype plugin for TTY security hardening
|
|
4
|
+
* Validates and sanitizes tokens for safe rendering
|
|
5
|
+
*/
|
|
6
|
+
export declare const rehypeHarden: RehypePlugin;
|
|
7
|
+
/**
|
|
8
|
+
* Harden configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface HardenConfig {
|
|
11
|
+
allowedLinkPrefixes?: string[];
|
|
12
|
+
allowedImagePrefixes?: string[];
|
|
13
|
+
stripDangerousAnsi?: boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=harden.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harden.d.ts","sourceRoot":"","sources":["../../../src/plugins/rehype/harden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAC;AA8DvD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,YAkB1B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/rehype/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/remark/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/plugins/remark/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,YAuBxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../src/plugins/remark/mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,YAW3B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ParsedToken, RenderContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin type matching Streamdown's remark/rehype pattern
|
|
4
|
+
*/
|
|
5
|
+
export type PluginType = 'remark' | 'rehype';
|
|
6
|
+
/**
|
|
7
|
+
* Plugin hook phases
|
|
8
|
+
*/
|
|
9
|
+
export type HookPhase = 'pre-parse' | 'post-parse' | 'pre-render' | 'post-render';
|
|
10
|
+
/**
|
|
11
|
+
* Base plugin interface
|
|
12
|
+
*/
|
|
13
|
+
export interface TTYPlugin {
|
|
14
|
+
name: string;
|
|
15
|
+
type: PluginType;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
priority?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Remark plugin - processes markdown before parsing
|
|
21
|
+
*/
|
|
22
|
+
export interface RemarkPlugin extends TTYPlugin {
|
|
23
|
+
type: 'remark';
|
|
24
|
+
process(markdown: string, context: PluginContext): string | Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Rehype plugin - processes tokens after parsing
|
|
28
|
+
*/
|
|
29
|
+
export interface RehypePlugin extends TTYPlugin {
|
|
30
|
+
type: 'rehype';
|
|
31
|
+
process(tokens: ParsedToken[], context: PluginContext): ParsedToken[] | Promise<ParsedToken[]>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Plugin context passed to processors
|
|
35
|
+
*/
|
|
36
|
+
export interface PluginContext {
|
|
37
|
+
renderContext: RenderContext;
|
|
38
|
+
metadata: Map<string, any>;
|
|
39
|
+
options: PluginOptions;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Plugin configuration options
|
|
43
|
+
*/
|
|
44
|
+
export interface PluginOptions {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Pluggable list matching remark/rehype pattern
|
|
49
|
+
*/
|
|
50
|
+
export type TTYPluggableList = Array<TTYPluggable>;
|
|
51
|
+
export type TTYPluggable = TTYPlugin | [TTYPlugin, PluginOptions] | string;
|
|
52
|
+
/**
|
|
53
|
+
* Hook function type
|
|
54
|
+
*/
|
|
55
|
+
export type HookFunction = (data: any, context: PluginContext) => any | Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* Plugin registry entry
|
|
58
|
+
*/
|
|
59
|
+
export interface PluginRegistryEntry {
|
|
60
|
+
plugin: TTYPlugin;
|
|
61
|
+
options: PluginOptions;
|
|
62
|
+
hooks: Map<HookPhase, HookFunction[]>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Plugin execution result
|
|
66
|
+
*/
|
|
67
|
+
export interface PluginResult<T> {
|
|
68
|
+
data: T;
|
|
69
|
+
errors?: Error[];
|
|
70
|
+
warnings?: string[];
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC3C,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/E;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC3C,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAClG;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAEnD,MAAM,MAAM,YAAY,GAClB,SAAS,GACT,CAAC,SAAS,EAAE,aAAa,CAAC,GAC1B,MAAM,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CACvB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,aAAa,KACrB,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ParsedToken, RenderContext } from '../types/index.js';
|
|
2
|
+
export declare class ANSIRenderer {
|
|
3
|
+
private context;
|
|
4
|
+
private defaultStyles;
|
|
5
|
+
constructor(context: RenderContext);
|
|
6
|
+
/**
|
|
7
|
+
* Render tokens to ANSI output
|
|
8
|
+
*/
|
|
9
|
+
render(tokens: ParsedToken[]): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Write to output stream
|
|
12
|
+
*/
|
|
13
|
+
private write;
|
|
14
|
+
/**
|
|
15
|
+
* Render a line of inline tokens
|
|
16
|
+
*/
|
|
17
|
+
private renderInlineLine;
|
|
18
|
+
/**
|
|
19
|
+
* Render a single token
|
|
20
|
+
*/
|
|
21
|
+
private renderToken;
|
|
22
|
+
/**
|
|
23
|
+
* Render heading
|
|
24
|
+
*/
|
|
25
|
+
private renderHeading;
|
|
26
|
+
/**
|
|
27
|
+
* Render text/paragraph
|
|
28
|
+
*/
|
|
29
|
+
private renderText;
|
|
30
|
+
/**
|
|
31
|
+
* Render code block
|
|
32
|
+
*/
|
|
33
|
+
private renderCodeBlock;
|
|
34
|
+
/**
|
|
35
|
+
* Render blockquote
|
|
36
|
+
*/
|
|
37
|
+
private renderBlockquote;
|
|
38
|
+
/**
|
|
39
|
+
* Render list item
|
|
40
|
+
*/
|
|
41
|
+
private renderListItem;
|
|
42
|
+
/**
|
|
43
|
+
* Render horizontal rule
|
|
44
|
+
*/
|
|
45
|
+
private renderHorizontalRule;
|
|
46
|
+
/**
|
|
47
|
+
* Render table
|
|
48
|
+
*/
|
|
49
|
+
private renderTable;
|
|
50
|
+
/**
|
|
51
|
+
* Render mermaid diagram
|
|
52
|
+
*/
|
|
53
|
+
private renderMermaid;
|
|
54
|
+
/**
|
|
55
|
+
* Format inline styles
|
|
56
|
+
*/
|
|
57
|
+
private formatInlineStyles;
|
|
58
|
+
/**
|
|
59
|
+
* Highlight code
|
|
60
|
+
*/
|
|
61
|
+
private highlightCode;
|
|
62
|
+
/**
|
|
63
|
+
* Convert color name to ANSI code
|
|
64
|
+
*/
|
|
65
|
+
private colorToAnsi;
|
|
66
|
+
/**
|
|
67
|
+
* Get heading style based on depth
|
|
68
|
+
*/
|
|
69
|
+
private getHeadingStyle;
|
|
70
|
+
/**
|
|
71
|
+
* Get default styles
|
|
72
|
+
*/
|
|
73
|
+
private getDefaultStyles;
|
|
74
|
+
}
|
|
75
|
+
export { ANSIRenderer as BlessedRenderer };
|
|
76
|
+
//# sourceMappingURL=ansi-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi-renderer.d.ts","sourceRoot":"","sources":["../../src/renderer/ansi-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAA6B,MAAM,mBAAmB,CAAC;AAyC1F,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,aAAa,CAAiB;gBAE1B,OAAO,EAAE,aAAa;IAKlC;;OAEG;IACU,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBzD;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA4BxB;;OAEG;YACW,WAAW;IA8DzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;OAEG;IACH,OAAO,CAAC,UAAU;IAUlB;;OAEG;IACH,OAAO,CAAC,eAAe;IAwBvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAgBtB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAK5B;;OAEG;IACH,OAAO,CAAC,WAAW;IA6BnB;;OAEG;YACW,aAAa;IAuB3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyB1B;;OAEG;IACH,OAAO,CAAC,aAAa;IA0BrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAsBzB;AAGD,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renderers index - export all inline renderers
|
|
3
|
+
*/
|
|
4
|
+
export { renderMathToUnicode, renderMathBlock, renderMathInline, processMathInText, containsMath } from './unicode-math.js';
|
|
5
|
+
export { renderMermaidToASCII, containsMermaid } from './mermaid-ascii.js';
|
|
6
|
+
export { renderTableToASCII, renderMarkdownTableToASCII, isMarkdownTable, extractTable, type TableRenderOptions } from './table-ascii.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/renderers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACb,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,oBAAoB,EACpB,eAAe,EAChB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAA"}
|