textmode.js 0.3.2-beta.2 → 0.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 +5 -5
- package/dist/textmode.esm.js +841 -755
- package/dist/textmode.esm.min.js +854 -768
- package/dist/textmode.umd.js +6 -6
- package/dist/textmode.umd.min.js +7 -7
- package/dist/types/index.d.ts +1 -3
- package/dist/types/textmode/Textmodifier.d.ts +5 -43
- package/dist/types/textmode/font/TextmodeFont.d.ts +10 -1
- package/dist/types/textmode/font/typr/types.d.ts +0 -16
- package/dist/types/textmode/mixins/FontMixin.d.ts +2 -2
- package/dist/types/textmode/mixins/index.d.ts +0 -1
- package/dist/types/textmode/plugins/PluginManager.d.ts +76 -0
- package/package.json +3 -3
- package/dist/types/export/base/DataExtractor.d.ts +0 -34
- package/dist/types/export/base/FileHandler.d.ts +0 -46
- package/dist/types/export/base/index.d.ts +0 -2
- package/dist/types/export/image/ImageContentGenerator.d.ts +0 -27
- package/dist/types/export/image/ImageDataExtractor.d.ts +0 -16
- package/dist/types/export/image/ImageExporter.d.ts +0 -38
- package/dist/types/export/image/ImageFileHandler.d.ts +0 -27
- package/dist/types/export/image/index.d.ts +0 -6
- package/dist/types/export/image/types.d.ts +0 -62
- package/dist/types/export/index.d.ts +0 -3
- package/dist/types/export/svg/SVGContentGenerator.d.ts +0 -76
- package/dist/types/export/svg/SVGDataExtractor.d.ts +0 -33
- package/dist/types/export/svg/SVGExporter.d.ts +0 -31
- package/dist/types/export/svg/SVGFileHandler.d.ts +0 -25
- package/dist/types/export/svg/SVGPathGenerator.d.ts +0 -56
- package/dist/types/export/svg/index.d.ts +0 -6
- package/dist/types/export/svg/types.d.ts +0 -129
- package/dist/types/export/txt/TXTContentGenerator.d.ts +0 -14
- package/dist/types/export/txt/TXTDataExtractor.d.ts +0 -19
- package/dist/types/export/txt/TXTExporter.d.ts +0 -31
- package/dist/types/export/txt/TXTFileHandler.d.ts +0 -19
- package/dist/types/export/txt/index.d.ts +0 -5
- package/dist/types/export/txt/types.d.ts +0 -55
- package/dist/types/textmode/mixins/ExportMixin.d.ts +0 -128
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SVG-specific type definitions for the textmode.js library.
|
|
3
|
-
*/
|
|
4
|
-
import type { TextmodeFont, TextmodeGrid } from '../..';
|
|
5
|
-
/**
|
|
6
|
-
* RGBA color representation.
|
|
7
|
-
*/
|
|
8
|
-
export interface RGBA {
|
|
9
|
-
r: number;
|
|
10
|
-
g: number;
|
|
11
|
-
b: number;
|
|
12
|
-
a: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 2D position coordinates.
|
|
16
|
-
*/
|
|
17
|
-
export interface Position {
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Cell position in grid coordinates.
|
|
23
|
-
*/
|
|
24
|
-
export interface CellPosition {
|
|
25
|
-
x: number;
|
|
26
|
-
y: number;
|
|
27
|
-
cellX: number;
|
|
28
|
-
cellY: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Cell transformation data.
|
|
32
|
-
*/
|
|
33
|
-
export interface CellTransform {
|
|
34
|
-
isInverted: boolean;
|
|
35
|
-
flipHorizontal: boolean;
|
|
36
|
-
flipVertical: boolean;
|
|
37
|
-
rotation: number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Complete data for a single SVG cell.
|
|
41
|
-
*/
|
|
42
|
-
export interface SVGCellData {
|
|
43
|
-
charIndex: number;
|
|
44
|
-
primaryColor: RGBA;
|
|
45
|
-
secondaryColor: RGBA;
|
|
46
|
-
transform: CellTransform;
|
|
47
|
-
position: CellPosition;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Framebuffer data extracted for SVG generation.
|
|
51
|
-
*/
|
|
52
|
-
export interface FramebufferData {
|
|
53
|
-
characterPixels: Uint8Array;
|
|
54
|
-
primaryColorPixels: Uint8Array;
|
|
55
|
-
secondaryColorPixels: Uint8Array;
|
|
56
|
-
transformPixels: Uint8Array;
|
|
57
|
-
rotationPixels: Uint8Array;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Options for exporting the textmode content to SVG format.
|
|
61
|
-
*/
|
|
62
|
-
export type SVGExportOptions = {
|
|
63
|
-
/**
|
|
64
|
-
* The filename to save the SVG file as.
|
|
65
|
-
*
|
|
66
|
-
* If not provided, a default filename is used.
|
|
67
|
-
*/
|
|
68
|
-
filename?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Whether to include cell background rectangles in the SVG output.
|
|
71
|
-
*
|
|
72
|
-
* When `false`, only the character paths are included, creating a more compact SVG.
|
|
73
|
-
*
|
|
74
|
-
* Default is `true`.
|
|
75
|
-
*/
|
|
76
|
-
includeBackgroundRectangles?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* The drawing mode for ASCII characters.
|
|
79
|
-
*
|
|
80
|
-
* When set to `'fill'`, characters are rendered as filled shapes.
|
|
81
|
-
*
|
|
82
|
-
* When set to `'stroke'`, characters are rendered as outlines.
|
|
83
|
-
*
|
|
84
|
-
* Default is `'fill'`.
|
|
85
|
-
*/
|
|
86
|
-
drawMode?: 'fill' | 'stroke';
|
|
87
|
-
/**
|
|
88
|
-
* The stroke width to use when drawMode is set to `'stroke'`.
|
|
89
|
-
*
|
|
90
|
-
* Default is `1.0`.
|
|
91
|
-
*/
|
|
92
|
-
strokeWidth?: number;
|
|
93
|
-
/**
|
|
94
|
-
* Background color for the SVG as RGBA array `[r, g, b, a]`.
|
|
95
|
-
*
|
|
96
|
-
* Default is transparent black `[0, 0, 0, 0]`.
|
|
97
|
-
*/
|
|
98
|
-
backgroundColor?: [number, number, number, number];
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Path object interface for character glyphs.
|
|
102
|
-
*/
|
|
103
|
-
export interface GlyphPath {
|
|
104
|
-
getBoundingBox(): {
|
|
105
|
-
x1: number;
|
|
106
|
-
y1: number;
|
|
107
|
-
x2: number;
|
|
108
|
-
y2: number;
|
|
109
|
-
};
|
|
110
|
-
toSVG(): string;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Internal options used by SVG generation (with all defaults applied).
|
|
114
|
-
*/
|
|
115
|
-
export interface SVGGenerationOptions {
|
|
116
|
-
includeBackgroundRectangles: boolean;
|
|
117
|
-
drawMode: 'fill' | 'stroke';
|
|
118
|
-
strokeWidth: number;
|
|
119
|
-
backgroundColor: [number, number, number, number];
|
|
120
|
-
filename: string;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Data required for textmode rendering export (shared shape with TXT exporter)
|
|
124
|
-
*/
|
|
125
|
-
export interface TextmodeRenderingData {
|
|
126
|
-
pipeline: any;
|
|
127
|
-
grid: TextmodeGrid;
|
|
128
|
-
font: TextmodeFont;
|
|
129
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { FramebufferData } from './types';
|
|
2
|
-
import { DataExtractor } from '../base';
|
|
3
|
-
import type { TextmodeGrid } from '../../textmode/Grid';
|
|
4
|
-
import type { TextmodeFont } from '../../textmode/font';
|
|
5
|
-
/**
|
|
6
|
-
* Extracts and processes data from framebuffers for TXT generation.
|
|
7
|
-
* This class handles the conversion of raw pixel data into character arrays.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TXTDataExtractor extends DataExtractor {
|
|
10
|
-
/**
|
|
11
|
-
* Extracts character data for TXT generation
|
|
12
|
-
* @param framebufferData Framebuffer pixel data
|
|
13
|
-
* @param grid Grid information
|
|
14
|
-
* @param font Font information
|
|
15
|
-
* @param emptyCharacter Character to use for empty cells
|
|
16
|
-
* @returns 2D array of characters (rows x columns)
|
|
17
|
-
*/
|
|
18
|
-
$extractCharacterGrid(framebufferData: FramebufferData, grid: TextmodeGrid, font: TextmodeFont, emptyCharacter?: string): string[][];
|
|
19
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { TXTExportOptions, TextmodeRenderingData } 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 renderingData The textmode rendering data containing pipeline, grid, and font
|
|
21
|
-
* @param options Export options (excluding filename)
|
|
22
|
-
* @returns TXT content as string
|
|
23
|
-
*/
|
|
24
|
-
$generateTXT(renderingData: TextmodeRenderingData, options?: TXTExportOptions): string;
|
|
25
|
-
/**
|
|
26
|
-
* Exports TXT content to a downloadable file
|
|
27
|
-
* @param renderingData The textmode rendering data containing pipeline, grid, and font
|
|
28
|
-
* @param options Export options including filename
|
|
29
|
-
*/
|
|
30
|
-
$saveTXT(renderingData: TextmodeRenderingData, options?: TXTExportOptions): void;
|
|
31
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
* Ensures filename has proper extension and is valid
|
|
15
|
-
* @param filename The filename to validate and fix
|
|
16
|
-
* @returns Valid filename with .txt extension
|
|
17
|
-
*/
|
|
18
|
-
private _ensureValidFilename;
|
|
19
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
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';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TXT-specific type definitions for the textmode.js library.
|
|
3
|
-
*/
|
|
4
|
-
import type { TextmodeFont, TextmodeGrid } from '../..';
|
|
5
|
-
/**
|
|
6
|
-
* Options for exporting the textmode content to TXT format.
|
|
7
|
-
*/
|
|
8
|
-
export type TXTExportOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* The filename to save the TXT file as.
|
|
11
|
-
*
|
|
12
|
-
* If not provided, a default filename is used.
|
|
13
|
-
*/
|
|
14
|
-
filename?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Whether to preserve trailing spaces on each line.
|
|
17
|
-
*
|
|
18
|
-
* When `false`, trailing spaces are trimmed from each line.
|
|
19
|
-
*
|
|
20
|
-
* Default is `false`.
|
|
21
|
-
*/
|
|
22
|
-
preserveTrailingSpaces?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The line ending format to use *(`'lf'` for Unix/Linux, `'crlf'` for Windows)*.
|
|
25
|
-
*
|
|
26
|
-
* Default is `'lf'`.
|
|
27
|
-
*/
|
|
28
|
-
lineEnding?: 'lf' | 'crlf';
|
|
29
|
-
/**
|
|
30
|
-
* Character to use for empty cells *(when no character is rendered)*.
|
|
31
|
-
* Default is a space `' '`.
|
|
32
|
-
*/
|
|
33
|
-
emptyCharacter?: string;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Internal options used by TXT generation (with all defaults applied).
|
|
37
|
-
*/
|
|
38
|
-
export interface TXTGenerationOptions {
|
|
39
|
-
preserveTrailingSpaces: boolean;
|
|
40
|
-
lineEnding: 'lf' | 'crlf';
|
|
41
|
-
emptyCharacter: string;
|
|
42
|
-
filename: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Data required for textmode rendering export
|
|
46
|
-
*/
|
|
47
|
-
export interface TextmodeRenderingData {
|
|
48
|
-
pipeline: any;
|
|
49
|
-
grid: TextmodeGrid;
|
|
50
|
-
font: TextmodeFont;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Re-export shared types from SVG module that are also used by TXT exporter
|
|
54
|
-
*/
|
|
55
|
-
export type { FramebufferData } from '../svg/types';
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
import { type SVGExportOptions } from '../../export/svg';
|
|
3
|
-
import { type TXTExportOptions } from '../../export/txt';
|
|
4
|
-
import { type ImageExportOptions } from '../../export/image';
|
|
5
|
-
/**
|
|
6
|
-
* Interface for export capabilities that will be mixed into Textmodifier
|
|
7
|
-
*/
|
|
8
|
-
export interface ExportCapabilities {
|
|
9
|
-
/**
|
|
10
|
-
* Generate the current textmode rendering as a text string.
|
|
11
|
-
* @param options Options for text generation *(excluding filename)*
|
|
12
|
-
* @returns Textmode grid content as a string.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```javascript
|
|
16
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
17
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
18
|
-
*
|
|
19
|
-
* // Create a Textmodifier instance
|
|
20
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
21
|
-
*
|
|
22
|
-
* // Get the current rendering as a text string
|
|
23
|
-
* const textString = textmodifier.toString({
|
|
24
|
-
* preserveTrailingSpaces: false,
|
|
25
|
-
* lineEnding: 'lf'
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Print to console or use otherwise
|
|
29
|
-
* console.log(textString);
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
toString(options?: TXTExportOptions): string;
|
|
33
|
-
/**
|
|
34
|
-
* Export the current textmode rendering to a TXT file.
|
|
35
|
-
* @param options Options for TXT export
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```javascript
|
|
39
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
40
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
41
|
-
*
|
|
42
|
-
* // Create a Textmodifier instance
|
|
43
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
44
|
-
*
|
|
45
|
-
* // Export the current rendering to a TXT file
|
|
46
|
-
* textmodifier.saveStrings({
|
|
47
|
-
* filename: 'my_textmode_rendering',
|
|
48
|
-
* preserveTrailingSpaces: false
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
saveStrings(options?: TXTExportOptions): void;
|
|
53
|
-
/**
|
|
54
|
-
* Generate the current textmode rendering as an SVG string.
|
|
55
|
-
* @param options Options for SVG generation *(excluding filename)*
|
|
56
|
-
* @returns SVG content as a string.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```javascript
|
|
60
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
61
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
62
|
-
*
|
|
63
|
-
* // Create a Textmodifier instance
|
|
64
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
65
|
-
*
|
|
66
|
-
* // Get the current rendering as an SVG string
|
|
67
|
-
* const svgString = textmodifier.toSVG({
|
|
68
|
-
* includeBackgroundRectangles: true,
|
|
69
|
-
* drawMode: 'fill'
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* // Print to console or use otherwise
|
|
73
|
-
* console.log(svgString);
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
toSVG(options?: SVGExportOptions): string;
|
|
77
|
-
/**
|
|
78
|
-
* Export the current textmode rendering to an SVG file.
|
|
79
|
-
* @param options Options for SVG export
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```javascript
|
|
83
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
84
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
85
|
-
*
|
|
86
|
-
* // Create a Textmodifier instance
|
|
87
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
88
|
-
*
|
|
89
|
-
* // Export the current rendering to an SVG file
|
|
90
|
-
* textmodifier.saveSVG({
|
|
91
|
-
* filename: 'my_textmode_rendering',
|
|
92
|
-
* });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
saveSVG(options?: SVGExportOptions): void;
|
|
96
|
-
/**
|
|
97
|
-
* Export the current textmode rendering to an image file.
|
|
98
|
-
* @param options Options for image export
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```javascript
|
|
102
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
103
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
104
|
-
*
|
|
105
|
-
* // Create a Textmodifier instance
|
|
106
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
107
|
-
*
|
|
108
|
-
* // Export the current rendering to a PNG file *(default)*
|
|
109
|
-
* textmodifier.saveCanvas();
|
|
110
|
-
*
|
|
111
|
-
* // Export with custom options
|
|
112
|
-
* textmodifier.saveCanvas({
|
|
113
|
-
* filename: 'my_textmode_rendering',
|
|
114
|
-
* format: 'jpg',
|
|
115
|
-
* quality: 0.8,
|
|
116
|
-
* scale: 2.0,
|
|
117
|
-
* backgroundColor: 'white'
|
|
118
|
-
* });
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
saveCanvas(options?: ImageExportOptions): Promise<void>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Mixin that adds export capabilities to a class
|
|
125
|
-
* @param Base The base class to extend
|
|
126
|
-
* @returns Extended class with export capabilities
|
|
127
|
-
*/
|
|
128
|
-
export declare const ExportMixin: Mixin<ExportCapabilities>;
|