textmode.js 0.1.6-beta.6 → 0.1.7

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 (37) hide show
  1. package/dist/textmode.esm.js +1197 -1168
  2. package/dist/textmode.esm.min.js +1237 -1208
  3. package/dist/textmode.umd.js +56 -18
  4. package/dist/textmode.umd.min.js +56 -18
  5. package/dist/types/errors/Error.d.ts +3 -5
  6. package/dist/types/errors/ErrorHandler.d.ts +3 -3
  7. package/dist/types/export/base/DataExtractor.d.ts +3 -3
  8. package/dist/types/export/base/FileHandler.d.ts +6 -6
  9. package/dist/types/export/image/ImageContentGenerator.d.ts +3 -3
  10. package/dist/types/export/image/ImageDataExtractor.d.ts +1 -1
  11. package/dist/types/export/image/ImageExporter.d.ts +8 -8
  12. package/dist/types/export/image/ImageFileHandler.d.ts +3 -15
  13. package/dist/types/export/svg/SVGContentGenerator.d.ts +11 -11
  14. package/dist/types/export/svg/SVGDataExtractor.d.ts +3 -3
  15. package/dist/types/export/svg/SVGExporter.d.ts +6 -6
  16. package/dist/types/export/svg/SVGFileHandler.d.ts +3 -3
  17. package/dist/types/export/svg/SVGPathGenerator.d.ts +5 -6
  18. package/dist/types/export/txt/TXTContentGenerator.d.ts +1 -1
  19. package/dist/types/export/txt/TXTDataExtractor.d.ts +1 -1
  20. package/dist/types/export/txt/TXTExporter.d.ts +6 -6
  21. package/dist/types/export/txt/TXTFileHandler.d.ts +2 -2
  22. package/dist/types/rendering/webgl/Framebuffer.d.ts +8 -8
  23. package/dist/types/rendering/webgl/Renderer.d.ts +35 -35
  24. package/dist/types/rendering/webgl/Shader.d.ts +14 -14
  25. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +10 -10
  26. package/dist/types/rendering/webgl/geometries/Line.d.ts +1 -1
  27. package/dist/types/rendering/webgl/geometries/Rectangle.d.ts +2 -2
  28. package/dist/types/textmode/Canvas.d.ts +9 -7
  29. package/dist/types/textmode/ConversionPipeline.d.ts +23 -15
  30. package/dist/types/textmode/Grid.d.ts +6 -6
  31. package/dist/types/textmode/Textmodifier.d.ts +15 -16
  32. package/dist/types/textmode/converters/BrightnessConverter.d.ts +8 -8
  33. package/dist/types/textmode/converters/Converter.d.ts +5 -5
  34. package/dist/types/textmode/converters/FeatureConverter.d.ts +6 -6
  35. package/dist/types/textmode/font/TextmodeFont.d.ts +8 -8
  36. package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +1 -1
  37. package/package.json +1 -1
@@ -11,27 +11,29 @@ export type CaptureSource = HTMLCanvasElement | HTMLVideoElement;
11
11
  */
12
12
  export declare class TextmodeCanvas {
13
13
  private _canvas;
14
- private captureSource;
14
+ private _captureSource;
15
15
  private _isStandalone;
16
- private resizeObserver?;
16
+ private _resizeObserver?;
17
17
  onTransformChange?: () => void;
18
18
  constructor(captureSource: CaptureSource, isStandalone?: boolean, opts?: TextmodeOptions);
19
- private createCanvas;
20
- private positionOverlayCanvas;
21
- resize(width?: number, height?: number): void;
19
+ private _createCanvas;
20
+ private _positionOverlayCanvas;
21
+ $resize(width?: number, height?: number): void;
22
22
  /**
23
23
  * Get the WebGL context for the overlay canvas
24
24
  */
25
- getWebGLContext(): WebGL2RenderingContext | WebGLRenderingContext;
25
+ $getWebGLContext(): WebGL2RenderingContext | WebGLRenderingContext;
26
26
  /**
27
27
  * Set up ResizeObserver to monitor for CSS transform changes
28
+ *
29
+ * note: might be redundant and can be deleted?
28
30
  */
29
31
  private setupTransformObserver;
30
32
  /**
31
33
  * Dispose of this TextmodeCanvas and clean up all resources.
32
34
  * This method is idempotent and safe to call multiple times.
33
35
  */
34
- dispose(): void;
36
+ $dispose(): void;
35
37
  get canvas(): HTMLCanvasElement;
36
38
  get width(): number;
37
39
  get height(): number;
@@ -11,14 +11,12 @@ import type { TextmodeGrid } from "./Grid";
11
11
  * color adjustments, transformations, and more.
12
12
  */
13
13
  export declare class TextmodeConversionPipeline {
14
- private renderer;
15
- private font;
16
- private grid;
17
- private converters;
18
- /** Pre-configured brightness converter for easy access */
19
- readonly brightness: TextmodeBrightnessConverter;
20
- /** Pre-configured custom converter for easy access */
21
- readonly custom: TextmodeConverter;
14
+ private _renderer;
15
+ private _font;
16
+ private _grid;
17
+ private _converters;
18
+ private _brightness;
19
+ private _custom;
22
20
  private _resultFramebuffer;
23
21
  private _asciiShader;
24
22
  private _characterFramebuffer;
@@ -39,7 +37,7 @@ export declare class TextmodeConversionPipeline {
39
37
  * @param sourceFramebuffer The source framebuffer to convert.
40
38
  * @ignore
41
39
  */
42
- render(sourceFramebuffer: Framebuffer): void;
40
+ $render(sourceFramebuffer: Framebuffer): void;
43
41
  /**
44
42
  * Adds a new converter to the pipeline.
45
43
  * @param converter The converter instance to add.
@@ -57,15 +55,11 @@ export declare class TextmodeConversionPipeline {
57
55
  * @param converter The converter instance to remove.
58
56
  */
59
57
  remove(converter: TextmodeConverter): void;
60
- /**
61
- * Returns the framebuffer containing the textmode conversion result.
62
- */
63
- get texture(): Framebuffer;
64
58
  /**
65
59
  * Resizes all internal framebuffers.
66
60
  * @ignore
67
61
  */
68
- resize(): void;
62
+ $resize(): void;
69
63
  /**
70
64
  * Checks if any converter in the pipeline is enabled.
71
65
  * @returns `true` if any converter is enabled, `false` otherwise.
@@ -83,7 +77,9 @@ export declare class TextmodeConversionPipeline {
83
77
  * Dispose of all resources used by this conversion pipeline.
84
78
  * This method is idempotent and safe to call multiple times.
85
79
  */
86
- dispose(): void;
80
+ $dispose(): void;
81
+ /** Returns the framebuffer containing the textmode conversion result.*/
82
+ get texture(): Framebuffer;
87
83
  /** Returns the character framebuffer containing the combined result of all converters. */
88
84
  get characterFramebuffer(): Framebuffer;
89
85
  /** Returns the primary color framebuffer containing the combined result of all converters. */
@@ -94,4 +90,16 @@ export declare class TextmodeConversionPipeline {
94
90
  get rotationFramebuffer(): Framebuffer;
95
91
  /** Returns the transform framebuffer containing the combined result of all converters. */
96
92
  get transformFramebuffer(): Framebuffer;
93
+ /**
94
+ * Returns the pre-defined brightness converter that is part of the pipeline by default.
95
+ *
96
+ * This converter can also be removed from the pipeline via `pipeline.remove(pipeline.brightness)`.
97
+ */
98
+ get brightness(): TextmodeBrightnessConverter;
99
+ /**
100
+ * Returns the pre-defined custom converter that is part of the pipeline by default.
101
+ *
102
+ * This converter can also be removed from the pipeline via `pipeline.remove(pipeline.custom)`.
103
+ */
104
+ get custom(): TextmodeConverter;
97
105
  }
@@ -34,7 +34,7 @@ export declare class TextmodeGrid {
34
34
  * Reset the grid to the default number of columns and rows based on the current canvas dimensions, and the grid cell dimensions.
35
35
  * @ignore
36
36
  */
37
- reset(): void;
37
+ $reset(): void;
38
38
  /**
39
39
  * Reset the total grid width & height, and the offset to the outer canvas.
40
40
  */
@@ -45,7 +45,7 @@ export declare class TextmodeGrid {
45
45
  * @param newCellHeight The new cell height.
46
46
  * @ignore
47
47
  */
48
- resizeCellPixelDimensions(newCellWidth: number, newCellHeight: number): void;
48
+ $resizeCellPixelDimensions(newCellWidth: number, newCellHeight: number): void;
49
49
  /**
50
50
  * Re-assign the grid dimensions and resize the grid.
51
51
  *
@@ -54,25 +54,25 @@ export declare class TextmodeGrid {
54
54
  * @param newRows The new number of rows.
55
55
  * @ignore
56
56
  */
57
- resizeGridDimensions(newCols: number, newRows: number): void;
57
+ $resizeGridDimensions(newCols: number, newRows: number): void;
58
58
  /**
59
59
  * Make the grid dimensions flexible again, and `reset()` the grid.
60
60
  * @ignore
61
61
  */
62
- resetGridDimensions(): void;
62
+ $resetGridDimensions(): void;
63
63
  /**
64
64
  * Update the canvas used by the grid, and reset the grid dimensions.
65
65
  * @param canvas The new canvas element to use for the grid.
66
66
  * @ignore
67
67
  */
68
- resize(): void;
68
+ $resize(): void;
69
69
  /**
70
70
  * Gets or sets whether the grid dimensions *(columns and rows)* are fixed or responsive based on the canvas dimensions.
71
71
  * @param value Optional. `true` to make the grid dimensions fixed, or `false` to make them responsive. If not provided, returns the current state.
72
72
  * @returns If no parameter is provided, returns `true` if the grid dimensions are fixed, or `false` if they are responsive.
73
73
  * @ignore
74
74
  */
75
- fixedDimensions(value?: boolean): boolean | void;
75
+ $fixedDimensions(value?: boolean): boolean | void;
76
76
  /** Returns the width of each cell in the grid. */
77
77
  get cellWidth(): number;
78
78
  /** Returns the height of each cell in the grid. */
@@ -44,7 +44,7 @@ declare class TextmodifierCore implements TextmodifierContext {
44
44
  _renderer: GLRenderer;
45
45
  _font: TextmodeFont;
46
46
  _pipeline: TextmodeConversionPipeline;
47
- textmodeCanvas: TextmodeCanvas;
47
+ _canvas: TextmodeCanvas;
48
48
  _grid: TextmodeGrid;
49
49
  }
50
50
  declare const Textmodifier_base: typeof TextmodifierCore;
@@ -56,27 +56,26 @@ declare const Textmodifier_base: typeof TextmodifierCore;
56
56
  */
57
57
  export declare class Textmodifier extends Textmodifier_base {
58
58
  /** The element to capture content from (optional for standalone mode) */
59
- private captureSource;
59
+ private _captureSource;
60
60
  /** Canvas framebuffer for capturing source content */
61
61
  private _canvasFramebuffer;
62
- private resizeObserver;
62
+ private _resizeObserver;
63
63
  private _mode;
64
64
  private _frameRateLimit;
65
- private animationFrameId;
66
- private lastFrameTime;
67
- private frameInterval;
65
+ private _animationFrameId;
66
+ private _lastFrameTime;
67
+ private _frameInterval;
68
68
  private _isLooping;
69
69
  private _frameRate;
70
- private lastRenderTime;
70
+ private _lastRenderTime;
71
71
  private _frameCount;
72
- private frameTimeHistory;
73
- private frameTimeHistorySize;
72
+ private _frameTimeHistory;
73
+ private _frameTimeHistorySize;
74
74
  private _isDisposed;
75
75
  private _standalone;
76
76
  private _drawCallback;
77
77
  private _resizedCallback;
78
78
  private _windowResizeListener;
79
- private _printDebug;
80
79
  constructor(source?: CaptureSource | null, opts?: TextmodeOptions);
81
80
  /**
82
81
  * Static factory method for creating and initializing a Textmodifier instance.
@@ -85,7 +84,7 @@ export declare class Textmodifier extends Textmodifier_base {
85
84
  * @ignore
86
85
  */
87
86
  static create<T extends Textmodifier>(source?: CaptureSource | null, opts?: TextmodeOptions): Promise<T>;
88
- setupEventListeners(): void;
87
+ $setupEventListeners(): void;
89
88
  /**
90
89
  * Apply textmode rendering to the canvas.
91
90
  *
@@ -125,20 +124,20 @@ export declare class Textmodifier extends Textmodifier_base {
125
124
  * ```
126
125
  */
127
126
  render(): void;
128
- private resize;
127
+ private _resize;
129
128
  /**
130
129
  * Start automatic rendering
131
130
  */
132
- startAutoRendering(): void;
131
+ private _startAutoRendering;
133
132
  /**
134
133
  * Update FPS measurement - works for both auto and manual modes
135
134
  * Uses a rolling average for smoother frame rate reporting
136
135
  */
137
- private measureFrameRate;
136
+ private _measureFrameRate;
138
137
  /**
139
138
  * Stop automatic rendering
140
139
  */
141
- private stopAutoRendering;
140
+ private _stopAutoRendering;
142
141
  /**
143
142
  * Update the rendering mode.
144
143
  *
@@ -387,7 +386,6 @@ export declare class Textmodifier extends Textmodifier_base {
387
386
  * ```
388
387
  */
389
388
  destroy(): void;
390
- debug(bool: boolean): void;
391
389
  /** Get the current grid object used for rendering. */
392
390
  get grid(): TextmodeGrid;
393
391
  /** Get the current font object used for rendering. */
@@ -404,6 +402,7 @@ export declare class Textmodifier extends Textmodifier_base {
404
402
  get width(): number;
405
403
  /** Get the height of the canvas. */
406
404
  get height(): number;
405
+ get canvas(): TextmodeCanvas;
407
406
  /** Check if the instance has been disposed/destroyed. */
408
407
  get isDisposed(): boolean;
409
408
  }
@@ -31,12 +31,12 @@ export declare const BRIGHTNESS_DEFAULT_OPTIONS: {
31
31
  * Converter that maps brightness values from a source texture to ASCII characters.
32
32
  */
33
33
  export declare class TextmodeBrightnessConverter extends TextmodeFeatureConverter {
34
- private sampleShader;
35
- private colorFillShader;
36
- private charMappingShader;
37
- private transformFillShader;
38
- private rotationFillShader;
39
- private sampleFramebuffer;
34
+ private _sampleShader;
35
+ private _colorFillShader;
36
+ private _charMappingShader;
37
+ private _transformFillShader;
38
+ private _rotationFillShader;
39
+ private _sampleFramebuffer;
40
40
  /**
41
41
  * Creates a new TextmodeBrightnessConverter instance.
42
42
  * @param renderer Renderer instance for texture creation
@@ -45,8 +45,8 @@ export declare class TextmodeBrightnessConverter extends TextmodeFeatureConverte
45
45
  * @ignore
46
46
  */
47
47
  constructor(renderer: GLRenderer, fontManager: TextmodeFont, grid: TextmodeGrid);
48
- convert(framebuffer: Framebuffer): void;
49
- resize(): void;
48
+ $convert(framebuffer: Framebuffer): void;
49
+ $resize(): void;
50
50
  /**
51
51
  * Sets the brightness range for ASCII character mapping.
52
52
  *
@@ -6,9 +6,9 @@ import type { TextmodeGrid } from "../Grid";
6
6
  * Base class for all textmode converters.
7
7
  */
8
8
  export declare class TextmodeConverter {
9
- protected renderer: GLRenderer;
10
- protected fontManager: TextmodeFont;
11
- protected grid: TextmodeGrid;
9
+ protected _renderer: GLRenderer;
10
+ protected _fontManager: TextmodeFont;
11
+ protected _grid: TextmodeGrid;
12
12
  protected _characterFramebuffer: Framebuffer;
13
13
  protected _primaryColorFramebuffer: Framebuffer;
14
14
  protected _secondaryColorFramebuffer: Framebuffer;
@@ -28,7 +28,7 @@ export declare class TextmodeConverter {
28
28
  * Resizes all internal framebuffers to match the grid dimensions.
29
29
  * @ignore
30
30
  */
31
- resize(): void;
31
+ $resize(): void;
32
32
  /**
33
33
  * Enables or disables the converter.
34
34
  * @param enabled Whether to enable or disable the converter.
@@ -46,7 +46,7 @@ export declare class TextmodeConverter {
46
46
  * Dispose of all framebuffers used by this converter.
47
47
  * This method is idempotent and safe to call multiple times.
48
48
  */
49
- dispose(): void;
49
+ $dispose(): void;
50
50
  /** Returns the framebuffer containing character data. */
51
51
  get characterFramebuffer(): Framebuffer;
52
52
  /** Returns the framebuffer containing primary color data. */
@@ -8,14 +8,14 @@ import type { Framebuffer } from "../../rendering/webgl/Framebuffer";
8
8
  * Abstract base class for all feature-based textmode converters like `'brightness'`.
9
9
  */
10
10
  export declare abstract class TextmodeFeatureConverter extends TextmodeConverter {
11
- protected palette: ColorPalette;
11
+ protected _palette: ColorPalette;
12
12
  protected constructor(renderer: GLRenderer, fontManager: TextmodeFont, grid: TextmodeGrid, options?: any);
13
13
  /**
14
14
  * Converts the source framebuffer to the target format.
15
15
  * @param sourceFramebuffer The source framebuffer to convert.
16
16
  * @ignore
17
17
  */
18
- abstract convert(sourceFramebuffer: Framebuffer): void;
18
+ abstract $convert(sourceFramebuffer: Framebuffer): void;
19
19
  /**
20
20
  * Sets the characters used for mapping.
21
21
  * @param characters The characters to use for mapping, usually ordered from darkest to brightest.
@@ -82,25 +82,25 @@ export declare abstract class TextmodeFeatureConverter extends TextmodeConverter
82
82
  * @param a Alpha component (0-255).
83
83
  * @returns Normalized RGBA array [r, g, b, a] (0-1 range) or null if invalid.
84
84
  */
85
- private parseColor;
85
+ private _parseColor;
86
86
  /**
87
87
  * Helper method to set color mode with validation.
88
88
  * @param mode The color mode to set.
89
89
  * @param optionKey The option key to set in _options.
90
90
  * @param errorMessage The error message to show if validation fails.
91
91
  */
92
- private setColorMode;
92
+ private _setColorMode;
93
93
  /**
94
94
  * Helper method to set boolean options with validation.
95
95
  * @param value The boolean or number value to set.
96
96
  * @param optionKey The option key to set in _options.
97
97
  * @param displayName The display name for error messages.
98
98
  */
99
- private setBooleanOption;
99
+ private _setBooleanOption;
100
100
  /**
101
101
  * Parses a hex color string and returns RGBA values.
102
102
  * @param hex Hex color string (e.g., '#FF0000', '#F00', 'FF0000', 'F00').
103
103
  * @returns RGBA array [r, g, b, a] or null if invalid.
104
104
  */
105
- private parseHexColor;
105
+ private _parseHexColor;
106
106
  }
@@ -34,20 +34,20 @@ export declare class TextmodeFont {
34
34
  * @returns Promise that resolves when initialization is complete
35
35
  * @ignore
36
36
  */
37
- initialize(fontSource?: string | URL): Promise<void>;
37
+ $initialize(fontSource?: string | URL): Promise<void>;
38
38
  /**
39
39
  * Sets the font size for rendering.
40
40
  * @param size The font size to set. If undefined, returns the current font size.
41
41
  * @ignore
42
42
  */
43
- setFontSize(size: number | undefined): void | number;
43
+ $setFontSize(size: number | undefined): void | number;
44
44
  /**
45
45
  * Loads a new font from a file path.
46
46
  * @param fontPath Path to the .otf or .ttf font file
47
47
  * @returns Promise that resolves when font loading is complete
48
48
  * @ignore
49
49
  */
50
- loadFont(fontPath: string): Promise<void>;
50
+ $loadFont(fontPath: string): Promise<void>;
51
51
  /**
52
52
  * Loads a FontFace from a font buffer.
53
53
  * @param fontBuffer ArrayBuffer containing font data
@@ -76,6 +76,11 @@ export declare class TextmodeFont {
76
76
  * @returns `true` if all characters exist in the font, `false` otherwise.
77
77
  */
78
78
  hasAllCharacters(str: string): boolean;
79
+ /**
80
+ * Dispose of all resources used by this font manager.
81
+ * This method is idempotent and safe to call multiple times.
82
+ */
83
+ $dispose(): void;
79
84
  /**
80
85
  * Returns the WebGL framebuffer containing the font texture atlas.
81
86
  * @ignore
@@ -92,11 +97,6 @@ export declare class TextmodeFont {
92
97
  width: number;
93
98
  height: number;
94
99
  };
95
- /**
96
- * Dispose of all resources used by this font manager.
97
- * This method is idempotent and safe to call multiple times.
98
- */
99
- dispose(): void;
100
100
  /** Returns the font size used for rendering. */
101
101
  get fontSize(): number;
102
102
  /** Returns the Typr.js font object. @ignore */
@@ -26,7 +26,7 @@ export interface TextmodifierContext {
26
26
  /** Conversion pipeline @ignore */
27
27
  readonly _pipeline: TextmodeConversionPipeline;
28
28
  /** Canvas management @ignore */
29
- readonly textmodeCanvas: TextmodeCanvas;
29
+ readonly _canvas: TextmodeCanvas;
30
30
  /** Grid management @ignore */
31
31
  readonly _grid: TextmodeGrid;
32
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textmode.js",
3
- "version": "0.1.6-beta.6",
3
+ "version": "0.1.7",
4
4
  "description": "Apply real-time ASCII conversion to any HTML canvas.",
5
5
  "type": "module",
6
6
  "types": "./dist/types/index.d.ts",