textmode.js 0.1.0 → 0.1.1

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.
Files changed (31) hide show
  1. package/README.md +111 -2
  2. package/dist/textmode.esm.js +1556 -2112
  3. package/dist/textmode.umd.js +18 -16
  4. package/dist/types/export/base/DataExtractor.d.ts +33 -0
  5. package/dist/types/export/base/FileHandler.d.ts +60 -0
  6. package/dist/types/export/base/index.d.ts +2 -0
  7. package/dist/types/export/image/ImageContentGenerator.d.ts +27 -0
  8. package/dist/types/export/image/ImageDataExtractor.d.ts +15 -0
  9. package/dist/types/export/image/ImageExporter.d.ts +44 -0
  10. package/dist/types/export/image/ImageFileHandler.d.ts +51 -0
  11. package/dist/types/export/image/index.d.ts +6 -0
  12. package/dist/types/export/image/types.d.ts +57 -0
  13. package/dist/types/export/index.d.ts +3 -0
  14. package/dist/types/export/svg/SVGContentGenerator.d.ts +7 -6
  15. package/dist/types/export/svg/SVGDataExtractor.d.ts +7 -38
  16. package/dist/types/export/svg/SVGFileHandler.d.ts +2 -19
  17. package/dist/types/export/svg/index.d.ts +1 -1
  18. package/dist/types/export/svg/types.d.ts +0 -19
  19. package/dist/types/export/txt/TXTContentGenerator.d.ts +14 -0
  20. package/dist/types/export/txt/TXTDataExtractor.d.ts +18 -0
  21. package/dist/types/export/txt/TXTExporter.d.ts +31 -0
  22. package/dist/types/export/txt/TXTFileHandler.d.ts +24 -0
  23. package/dist/types/export/txt/index.d.ts +5 -0
  24. package/dist/types/export/txt/types.d.ts +40 -0
  25. package/dist/types/index.d.ts +2 -1
  26. package/dist/types/textmode/ConversionPipeline.d.ts +1 -0
  27. package/dist/types/textmode/Textmodifier.d.ts +108 -0
  28. package/dist/types/textmode/converters/Converter.d.ts +16 -1
  29. package/dist/types/textmode/font/TextmodeFont.d.ts +3 -1
  30. package/dist/types/textmode/font/typr/Typr.min.d.ts +19 -0
  31. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ import type { FramebufferData } from '../svg/types';
2
+ /**
3
+ * Base class for data extraction from textmode framebuffers.
4
+ * Provides common functionality shared between different export formats.
5
+ */
6
+ export declare abstract class DataExtractor {
7
+ /**
8
+ * Extracts pixel data from all framebuffers needed for export
9
+ * @param pipeline The conversion pipeline containing framebuffers
10
+ * @returns Object containing all pixel data arrays
11
+ */
12
+ extractFramebufferData(pipeline: any): FramebufferData;
13
+ /**
14
+ * Gets character index from character framebuffer pixels
15
+ * @param characterPixels Character framebuffer pixel data
16
+ * @param pixelIndex Index in the pixel array (already multiplied by 4 for RGBA)
17
+ * @param charactersLength Total number of available characters
18
+ * @returns Character index
19
+ */
20
+ protected getCharacterIndex(characterPixels: Uint8Array, pixelIndex: number): number;
21
+ /**
22
+ * Converts raw pixel data to RGBA color object
23
+ * @param pixels Pixel data array
24
+ * @param index Pixel index (already multiplied by 4 for RGBA)
25
+ * @returns RGBA color object with r, g, b, a properties
26
+ */
27
+ protected pixelsToRGBA(pixels: Uint8Array, index: number): {
28
+ r: number;
29
+ g: number;
30
+ b: number;
31
+ a: number;
32
+ };
33
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Base class for file handling operations.
3
+ * Provides common functionality for downloading files in the browser.
4
+ */
5
+ export declare abstract class FileHandler {
6
+ /**
7
+ * Creates a downloadable blob from content
8
+ * @param content The content to include in the blob
9
+ * @param mimeType The MIME type for the blob
10
+ * @returns Blob object containing the content
11
+ */
12
+ protected createBlob(content: string, mimeType: string): Blob;
13
+ /**
14
+ * Creates a data URL from content
15
+ * @param content The content to convert
16
+ * @param mimeType The MIME type for the blob
17
+ * @returns Data URL string
18
+ */
19
+ protected createDataURL(content: string, mimeType: string): string;
20
+ /**
21
+ * Downloads content as a file
22
+ * @param content The content to download
23
+ * @param filename The filename (with extension)
24
+ * @param mimeType The MIME type for the content
25
+ */
26
+ protected downloadFile(content: string, filename: string, mimeType: string): void;
27
+ /**
28
+ * Generates a timestamp string for filenames
29
+ * @returns Formatted timestamp string
30
+ */
31
+ protected generateTimestamp(): string;
32
+ /**
33
+ * Generates a date-time string for filenames (alternative format)
34
+ * @returns Formatted date and time string
35
+ */
36
+ protected generateDateTimeString(): {
37
+ date: string;
38
+ time: string;
39
+ };
40
+ /**
41
+ * Validates and sanitizes filename for safety and compatibility
42
+ * @param filename The filename to validate
43
+ * @returns Sanitized filename
44
+ */
45
+ protected sanitizeFilename(filename: string): string;
46
+ /**
47
+ * Ensures filename has the correct extension
48
+ * @param filename The filename to check
49
+ * @param expectedExtension The expected file extension (with dot)
50
+ * @returns Filename with correct extension
51
+ */
52
+ protected ensureFileExtension(filename: string, expectedExtension: string): string;
53
+ /**
54
+ * Generates a default filename with prefix and timestamp
55
+ * @param prefix The prefix for the filename
56
+ * @param extension The file extension (with dot)
57
+ * @returns Generated filename
58
+ */
59
+ protected generateDefaultFilename(prefix: string, extension: string): string;
60
+ }
@@ -0,0 +1,2 @@
1
+ export { DataExtractor } from './DataExtractor';
2
+ export { FileHandler } from './FileHandler';
@@ -0,0 +1,27 @@
1
+ import type { ImageGenerationOptions } from './types';
2
+ /**
3
+ * Content generator for image export.
4
+ * Handles the conversion of canvas data to different image formats.
5
+ */
6
+ export declare class ImageContentGenerator {
7
+ /**
8
+ * Generates image data from canvas
9
+ * @param canvas The canvas containing the image data
10
+ * @param options Generation options with format, quality, etc.
11
+ * @returns Data URL string containing the image data
12
+ */
13
+ generateImageData(canvas: HTMLCanvasElement, options: ImageGenerationOptions): string;
14
+ /**
15
+ * Generates image blob from canvas
16
+ * @param canvas The canvas containing the image data
17
+ * @param options Generation options with format, quality, etc.
18
+ * @returns Promise that resolves to a Blob containing the image data
19
+ */
20
+ generateImageBlob(canvas: HTMLCanvasElement, options: ImageGenerationOptions): Promise<Blob>;
21
+ /**
22
+ * Gets the MIME type for a given image format
23
+ * @param format The image format
24
+ * @returns The corresponding MIME type
25
+ */
26
+ private getMimeType;
27
+ }
@@ -0,0 +1,15 @@
1
+ import { DataExtractor } from '../base/DataExtractor';
2
+ /**
3
+ * Data extractor for image export.
4
+ * Captures the current visual state of the textmode canvas for image generation.
5
+ */
6
+ export declare class ImageDataExtractor extends DataExtractor {
7
+ /**
8
+ * Captures the current state of the textmode canvas as image data
9
+ * @param textmodeCanvas The TextmodeCanvas instance to capture from
10
+ * @param scale Scale factor for the output image
11
+ * @param backgroundColor Background color for formats that don't support transparency
12
+ * @returns Canvas element containing the captured image data
13
+ */
14
+ captureCanvasData(textmodeCanvas: any, scale?: number, backgroundColor?: string): HTMLCanvasElement;
15
+ }
@@ -0,0 +1,44 @@
1
+ import type { ImageExportOptions } from './types';
2
+ /**
3
+ * Main image exporter for the textmode.js library.
4
+ * Orchestrates the image export process by coordinating canvas capture,
5
+ * format conversion, and file handling.
6
+ */
7
+ export declare class ImageExporter {
8
+ private dataExtractor;
9
+ private contentGenerator;
10
+ private fileHandler;
11
+ constructor();
12
+ /**
13
+ * Applies default values to image export options
14
+ * @param options User-provided options
15
+ * @returns Complete options with defaults applied
16
+ */
17
+ private applyDefaultOptions;
18
+ /**
19
+ * Validates export options and browser support
20
+ * @param options The options to validate
21
+ * @throws Error if options are invalid or format is not supported
22
+ */
23
+ private validateOptions;
24
+ /**
25
+ * Generates image data from textmode rendering without saving to file
26
+ * @param textmodifier The textmodifier instance containing the canvas
27
+ * @param options Export options (excluding filename)
28
+ * @returns Data URL string containing the image data
29
+ */
30
+ generateImage(textmodifier: any, options?: Omit<ImageExportOptions, 'filename'>): string;
31
+ /**
32
+ * Generates image blob from textmode rendering without saving to file
33
+ * @param textmodifier The textmodifier instance containing the canvas
34
+ * @param options Export options (excluding filename)
35
+ * @returns Promise that resolves to a Blob containing the image data
36
+ */
37
+ generateImageBlob(textmodifier: any, options?: Omit<ImageExportOptions, 'filename'>): Promise<Blob>;
38
+ /**
39
+ * Exports image to a downloadable file
40
+ * @param textmodifier The textmodifier instance containing the canvas
41
+ * @param options Export options including filename
42
+ */
43
+ saveImage(textmodifier: any, options?: ImageExportOptions): Promise<void>;
44
+ }
@@ -0,0 +1,51 @@
1
+ import { FileHandler } from '../base/FileHandler';
2
+ import type { ImageFormat } from './types';
3
+ /**
4
+ * File handler for image export operations.
5
+ * Manages saving image files to disk with proper MIME types and extensions.
6
+ */
7
+ export declare class ImageFileHandler extends FileHandler {
8
+ /**
9
+ * Saves image content as a downloadable file
10
+ * @param content The image content (data URL or blob)
11
+ * @param filename The filename (without extension)
12
+ * @param format The image format
13
+ */
14
+ saveImage(content: string | Blob, filename: string, format: ImageFormat): void;
15
+ /**
16
+ * Saves image from data URL
17
+ * @param dataURL The data URL containing image data
18
+ * @param filename The complete filename with extension
19
+ */
20
+ private saveImageFromDataURL;
21
+ /**
22
+ * Saves image from blob
23
+ * @param blob The blob containing image data
24
+ * @param filename The complete filename with extension
25
+ */
26
+ private saveImageFromBlob;
27
+ /**
28
+ * Generates a default filename for image export
29
+ * @param format The image format for the file extension
30
+ * @returns Generated filename with timestamp
31
+ */
32
+ generateDefaultImageFilename(format?: ImageFormat): string;
33
+ /**
34
+ * Validates if the browser supports saving files in the specified format
35
+ * @param format The image format to validate
36
+ * @returns True if the format is supported for saving
37
+ */
38
+ validateSaveSupport(format: ImageFormat): boolean;
39
+ /**
40
+ * Gets the MIME type for the specified image format
41
+ * @param format The image format
42
+ * @returns The MIME type string
43
+ */
44
+ getMimeType(format: ImageFormat): string;
45
+ /**
46
+ * Gets the file extension for the specified image format
47
+ * @param format The image format
48
+ * @returns The file extension (including the dot)
49
+ */
50
+ getFileExtension(format: ImageFormat): string;
51
+ }
@@ -0,0 +1,6 @@
1
+ export { ImageExporter } from './ImageExporter';
2
+ export { ImageDataExtractor } from './ImageDataExtractor';
3
+ export { ImageContentGenerator } from './ImageContentGenerator';
4
+ export { ImageFileHandler } from './ImageFileHandler';
5
+ export type { ImageExportOptions, ImageGenerationOptions, ImageFormat } from './types';
6
+ export { IMAGE_MIME_TYPES, IMAGE_EXTENSIONS } from './types';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Image-specific type definitions for the textmode.js library.
3
+ */
4
+ /**
5
+ * Supported image formats for export.
6
+ */
7
+ export type ImageFormat = 'png' | 'jpg' | 'webp';
8
+ /**
9
+ * Options for exporting the textmode content to image format.
10
+ */
11
+ export type ImageExportOptions = {
12
+ /**
13
+ * The filename to save the image file as (without extension).
14
+ * If not provided, a default filename is used.
15
+ */
16
+ filename?: string;
17
+ /**
18
+ * The image format to export ('png', 'jpg', or 'webp').
19
+ * Default is 'png'.
20
+ */
21
+ format?: ImageFormat;
22
+ /**
23
+ * Image quality for lossy formats (jpg, webp).
24
+ * Range: 0.0 to 1.0, where 1.0 is highest quality.
25
+ * Default is 1.0. Ignored for PNG format.
26
+ */
27
+ quality?: number;
28
+ /**
29
+ * Scale factor for the output image.
30
+ * 1.0 = original size, 2.0 = double size, 0.5 = half size.
31
+ * Default is 1.0.
32
+ */
33
+ scale?: number;
34
+ /**
35
+ * Background color for formats that don't support transparency (jpg).
36
+ * Format: CSS color string or 'transparent' for PNG/WebP.
37
+ * Default is 'black'.
38
+ */
39
+ backgroundColor?: string;
40
+ };
41
+ /**
42
+ * Internal options used by image generation (with all defaults applied).
43
+ */
44
+ export interface ImageGenerationOptions {
45
+ format: ImageFormat;
46
+ quality: number;
47
+ scale: number;
48
+ backgroundColor: string;
49
+ }
50
+ /**
51
+ * MIME type mapping for image formats.
52
+ */
53
+ export declare const IMAGE_MIME_TYPES: Record<ImageFormat, string>;
54
+ /**
55
+ * File extension mapping for image formats.
56
+ */
57
+ export declare const IMAGE_EXTENSIONS: Record<ImageFormat, string>;
@@ -0,0 +1,3 @@
1
+ export type { SVGExportOptions } from './svg';
2
+ export type { TXTExportOptions } from './txt';
3
+ export type { ImageExportOptions } from './image/types';
@@ -1,4 +1,5 @@
1
- import type { SVGCellData, GridInfo, FontInfo, SVGGenerationOptions } from './types';
1
+ import type { SVGCellData, SVGGenerationOptions } from './types';
2
+ import type { TextmodeFont, TextmodeGrid } from '../../Textmode';
2
3
  /**
3
4
  * Generates SVG content and markup from processed cell data.
4
5
  * This class handles the creation of SVG elements, groups, and styling.
@@ -11,7 +12,7 @@ export declare class SVGContentGenerator {
11
12
  * @param gridInfo Grid dimensions
12
13
  * @returns SVG header string
13
14
  */
14
- generateSVGHeader(gridInfo: GridInfo): string;
15
+ generateSVGHeader(gridInfo: TextmodeGrid): string;
15
16
  /**
16
17
  * Generates the SVG footer
17
18
  * @returns SVG footer string
@@ -23,7 +24,7 @@ export declare class SVGContentGenerator {
23
24
  * @param options SVG generation options
24
25
  * @returns Background rectangle SVG string or empty string
25
26
  */
26
- generateBackground(gridInfo: GridInfo, options: SVGGenerationOptions): string;
27
+ generateBackground(gridInfo: TextmodeGrid, options: SVGGenerationOptions): string;
27
28
  /**
28
29
  * Converts RGBA object to CSS color string
29
30
  * @param color RGBA color object
@@ -62,16 +63,16 @@ export declare class SVGContentGenerator {
62
63
  * @param options SVG generation options
63
64
  * @returns Complete cell SVG content
64
65
  */
65
- generateCellContent(cellData: SVGCellData, gridInfo: GridInfo, fontInfo: FontInfo, options: SVGGenerationOptions): string;
66
+ generateCellContent(cellData: SVGCellData, gridInfo: TextmodeGrid, fontInfo: TextmodeFont, options: SVGGenerationOptions): string;
66
67
  /**
67
68
  * Generates the complete SVG content from cell data
68
69
  * @param cellDataArray Array of cell data
69
- * @param gridInfo Grid information
70
+ * @param grid Grid information
70
71
  * @param fontInfo Font information
71
72
  * @param options SVG generation options
72
73
  * @returns Complete SVG string
73
74
  */
74
- generateSVGContent(cellDataArray: SVGCellData[], gridInfo: GridInfo, fontInfo: FontInfo, options: SVGGenerationOptions): string;
75
+ generateSVGContent(cellDataArray: SVGCellData[], grid: TextmodeGrid, fontInfo: TextmodeFont, options: SVGGenerationOptions): string;
75
76
  /**
76
77
  * Optimizes SVG content by removing empty elements and unnecessary whitespace
77
78
  * @param svgContent Raw SVG content
@@ -1,34 +1,11 @@
1
- import type { FramebufferData, SVGCellData, GridInfo, FontInfo } from './types';
1
+ import type { FramebufferData, SVGCellData } from './types';
2
+ import { DataExtractor } from '../base';
3
+ import type { TextmodeGrid } from '../../Textmode';
2
4
  /**
3
5
  * Extracts and processes data from framebuffers for SVG generation.
4
6
  * This class handles the conversion of raw pixel data into structured data objects.
5
7
  */
6
- export declare class SVGDataExtractor {
7
- /**
8
- * Extracts pixel data from all framebuffers needed for SVG export
9
- * @param pipeline The conversion pipeline containing framebuffers
10
- * @returns Object containing all pixel data arrays
11
- */
12
- extractFramebufferData(pipeline: any): FramebufferData;
13
- /**
14
- * Extracts grid information from the grid object
15
- * @param grid The textmode grid object
16
- * @returns Grid information object
17
- */
18
- extractGridInfo(grid: any): GridInfo;
19
- /**
20
- * Extracts font information from the font object
21
- * @param font The textmode font object
22
- * @returns Font information object
23
- */
24
- extractFontInfo(font: any): FontInfo;
25
- /**
26
- * Converts raw pixel data to RGBA color object
27
- * @param pixels Pixel data array
28
- * @param index Pixel index (already multiplied by 4 for RGBA)
29
- * @returns RGBA color object
30
- */
31
- private pixelsToRGBA;
8
+ export declare class SVGDataExtractor extends DataExtractor {
32
9
  /**
33
10
  * Extracts transform data from transform pixels
34
11
  * @param transformPixels Transform framebuffer pixels
@@ -48,17 +25,9 @@ export declare class SVGDataExtractor {
48
25
  /**
49
26
  * Processes all grid cells and extracts SVG cell data
50
27
  * @param framebufferData Raw pixel data from framebuffers
51
- * @param gridInfo Grid information
52
- * @param fontInfo Font information
28
+ * @param grid Grid information
29
+ * @param font Font information
53
30
  * @returns Array of SVG cell data objects
54
31
  */
55
- extractSVGCellData(framebufferData: FramebufferData, gridInfo: GridInfo, fontInfo: FontInfo): SVGCellData[];
56
- /**
57
- * Validates that all required data is present for SVG generation
58
- * @param framebufferData Framebuffer data
59
- * @param gridInfo Grid information
60
- * @param fontInfo Font information
61
- * @returns True if all data is valid, false otherwise
62
- */
63
- validateExportData(framebufferData: FramebufferData, gridInfo: GridInfo, fontInfo: FontInfo): boolean;
32
+ extractSVGCellData(framebufferData: FramebufferData, grid: TextmodeGrid): SVGCellData[];
64
33
  }
@@ -1,8 +1,9 @@
1
+ import { FileHandler } from '../base/FileHandler.js';
1
2
  /**
2
3
  * Handles SVG file operations including download and save functionality.
3
4
  * This class manages the creation of downloadable SVG files and blob handling.
4
5
  */
5
- export declare class SVGFileHandler {
6
+ export declare class SVGFileHandler extends FileHandler {
6
7
  /**
7
8
  * Generates a default filename for SVG export
8
9
  * @param prefix Optional prefix for the filename
@@ -39,22 +40,4 @@ export declare class SVGFileHandler {
39
40
  * @param filename Optional filename (will generate if not provided)
40
41
  */
41
42
  saveSVG(svgContent: string, filename?: string): void;
42
- /**
43
- * Gets the size of the SVG content in bytes
44
- * @param svgContent The SVG content string
45
- * @returns Size in bytes
46
- */
47
- getSVGSize(svgContent: string): number;
48
- /**
49
- * Formats file size in human-readable format
50
- * @param bytes Size in bytes
51
- * @returns Formatted size string
52
- */
53
- formatFileSize(bytes: number): string;
54
- /**
55
- * Validates SVG content before saving
56
- * @param svgContent The SVG content to validate
57
- * @returns True if valid, false otherwise
58
- */
59
- validateSVGContent(svgContent: string): boolean;
60
43
  }
@@ -3,4 +3,4 @@ export { SVGDataExtractor } from './SVGDataExtractor';
3
3
  export { SVGContentGenerator } from './SVGContentGenerator';
4
4
  export { SVGPathGenerator } from './SVGPathGenerator';
5
5
  export { SVGFileHandler } from './SVGFileHandler';
6
- export type { SVGExportOptions, SVGGenerationOptions, SVGCellData, GridInfo, FontInfo, FramebufferData, RGBA, Position, CellPosition, CellTransform, GlyphPath } from './types';
6
+ export type { SVGExportOptions, SVGGenerationOptions, SVGCellData, FramebufferData, RGBA, Position, CellPosition, CellTransform, GlyphPath } from './types';
@@ -45,25 +45,6 @@ export interface SVGCellData {
45
45
  transform: CellTransform;
46
46
  position: CellPosition;
47
47
  }
48
- /**
49
- * Grid dimensions and cell sizing information.
50
- */
51
- export interface GridInfo {
52
- cols: number;
53
- rows: number;
54
- width: number;
55
- height: number;
56
- cellWidth: number;
57
- cellHeight: number;
58
- }
59
- /**
60
- * Font information needed for SVG generation.
61
- */
62
- export interface FontInfo {
63
- fontSize: number;
64
- fontData: any;
65
- characters: any[];
66
- }
67
48
  /**
68
49
  * Framebuffer data extracted for SVG generation.
69
50
  */
@@ -0,0 +1,14 @@
1
+ import type { TXTGenerationOptions } from './types';
2
+ /**
3
+ * Generates TXT content from character grid data.
4
+ * This class handles the conversion of character arrays into formatted text strings.
5
+ */
6
+ export declare class TXTContentGenerator {
7
+ /**
8
+ * Generates TXT content from a 2D character array
9
+ * @param characterGrid 2D array of characters (rows x columns)
10
+ * @param options Generation options
11
+ * @returns TXT content as string
12
+ */
13
+ generateTXTContent(characterGrid: string[][], options: TXTGenerationOptions): string;
14
+ }
@@ -0,0 +1,18 @@
1
+ import type { FramebufferData } from './types';
2
+ import { DataExtractor } from '../base';
3
+ import type { TextmodeFont, TextmodeGrid } from '../../Textmode';
4
+ /**
5
+ * Extracts and processes data from framebuffers for TXT generation.
6
+ * This class handles the conversion of raw pixel data into character arrays.
7
+ */
8
+ export declare class TXTDataExtractor extends DataExtractor {
9
+ /**
10
+ * Extracts character data for TXT generation
11
+ * @param framebufferData Framebuffer pixel data
12
+ * @param grid Grid information
13
+ * @param font Font information
14
+ * @param emptyCharacter Character to use for empty cells
15
+ * @returns 2D array of characters (rows x columns)
16
+ */
17
+ extractCharacterGrid(framebufferData: FramebufferData, grid: TextmodeGrid, font: TextmodeFont, emptyCharacter?: string): string[][];
18
+ }
@@ -0,0 +1,31 @@
1
+ import type { TXTExportOptions } from './types';
2
+ /**
3
+ * Main TXT exporter for the textmode.js library.
4
+ * Orchestrates the TXT export process by coordinating data extraction,
5
+ * content generation, and file handling.
6
+ */
7
+ export declare class TXTExporter {
8
+ private dataExtractor;
9
+ private contentGenerator;
10
+ private fileHandler;
11
+ constructor();
12
+ /**
13
+ * Applies default values to TXT export options
14
+ * @param options User-provided options
15
+ * @returns Complete options with defaults applied
16
+ */
17
+ private applyDefaultOptions;
18
+ /**
19
+ * Generates TXT content from textmode rendering data without saving to file
20
+ * @param textmodifier The textmodifier instance containing rendering data
21
+ * @param options Export options (excluding filename)
22
+ * @returns TXT content as string
23
+ */
24
+ generateTXT(textmodifier: any, options?: Omit<TXTExportOptions, 'filename'>): string;
25
+ /**
26
+ * Exports TXT content to a downloadable file
27
+ * @param textmodifier The textmodifier instance containing rendering data
28
+ * @param options Export options including filename
29
+ */
30
+ saveTXT(textmodifier: any, options?: TXTExportOptions): void;
31
+ }
@@ -0,0 +1,24 @@
1
+ import { FileHandler } from '../base/FileHandler.js';
2
+ /**
3
+ * Handles file operations for TXT export.
4
+ * This class manages the saving of TXT content to downloadable files.
5
+ */
6
+ export declare class TXTFileHandler extends FileHandler {
7
+ /**
8
+ * Saves TXT content as a downloadable file
9
+ * @param content The TXT content to save
10
+ * @param filename The filename to use for the download
11
+ */
12
+ saveTXT(content: string, filename: string): void;
13
+ /**
14
+ * Generates a default filename for TXT export
15
+ * @returns Default filename with timestamp
16
+ */
17
+ generateDefaultFilename(): string;
18
+ /**
19
+ * Ensures filename has proper extension and is valid
20
+ * @param filename The filename to validate and fix
21
+ * @returns Valid filename with .txt extension
22
+ */
23
+ private ensureValidFilename;
24
+ }
@@ -0,0 +1,5 @@
1
+ export { TXTExporter } from './TXTExporter';
2
+ export { TXTDataExtractor } from './TXTDataExtractor';
3
+ export { TXTContentGenerator } from './TXTContentGenerator';
4
+ export { TXTFileHandler } from './TXTFileHandler';
5
+ export type { TXTExportOptions, TXTGenerationOptions, FramebufferData } from './types';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * TXT-specific type definitions for the textmode.js library.
3
+ */
4
+ /**
5
+ * Options for exporting the textmode content to TXT format.
6
+ */
7
+ export type TXTExportOptions = {
8
+ /**
9
+ * The filename to save the TXT file as. If not provided, a default filename is used.
10
+ */
11
+ filename?: string;
12
+ /**
13
+ * Whether to preserve trailing spaces on each line.
14
+ * When false, trailing spaces are trimmed from each line.
15
+ * Default is `false`.
16
+ */
17
+ preserveTrailingSpaces?: boolean;
18
+ /**
19
+ * The line ending format to use (`'lf'` for Unix/Linux, `'crlf'` for Windows).
20
+ * Default is `'lf'`.
21
+ */
22
+ lineEnding?: 'lf' | 'crlf';
23
+ /**
24
+ * Character to use for empty cells (when no character is rendered).
25
+ * Default is a space `' '`.
26
+ */
27
+ emptyCharacter?: string;
28
+ };
29
+ /**
30
+ * Internal options used by TXT generation (with all defaults applied).
31
+ */
32
+ export interface TXTGenerationOptions {
33
+ preserveTrailingSpaces: boolean;
34
+ lineEnding: 'lf' | 'crlf';
35
+ emptyCharacter: string;
36
+ }
37
+ /**
38
+ * Re-export shared types from SVG module that are also used by TXT exporter
39
+ */
40
+ export type { FramebufferData } from '../svg/types';
@@ -5,7 +5,8 @@ export { TextmodeCanvas } from './textmode/Canvas';
5
5
  export { TextmodeGrid } from './textmode/Grid';
6
6
  export type { TextmodeOptions } from './textmode/Textmodifier';
7
7
  export type { TextmodeCharacter } from './textmode/font';
8
- export type { SVGExportOptions } from './export/svg';
8
+ /** All types related to export options for different formats. */
9
+ export * as ExportOptions from './export';
9
10
  export { TextmodeConversionPipeline } from './textmode/ConversionPipeline';
10
11
  export { TextmodeErrorLevel } from './errors/ErrorHandler';
11
12
  /** Contains all converters that can be added to a rendering pipeline to shape the textmode output. */
@@ -64,6 +64,7 @@ export declare class TextmodeConversionPipeline {
64
64
  * @ignore
65
65
  */
66
66
  resize(): void;
67
+ hasEnabledConverters(): boolean;
67
68
  /** Returns the character framebuffer containing the combined result of all converters. @ignore */
68
69
  get characterFramebuffer(): Framebuffer;
69
70
  /** Returns the primary color framebuffer containing the combined result of all converters. @ignore */