textmode.export.js 1.2.1 → 1.3.0-beta.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 (98) hide show
  1. package/README.md +171 -172
  2. package/dist/textmode.export.esm.js +1376 -1243
  3. package/dist/textmode.export.umd.js +2 -2
  4. package/dist/types/exporters/base/DataExtractor.d.ts +15 -1
  5. package/dist/types/exporters/base/DataExtractor.d.ts.map +1 -1
  6. package/dist/types/exporters/base/FileHandler.d.ts +3 -0
  7. package/dist/types/exporters/base/FileHandler.d.ts.map +1 -1
  8. package/dist/types/exporters/gif/GIFExporter.d.ts +5 -2
  9. package/dist/types/exporters/gif/GIFExporter.d.ts.map +1 -1
  10. package/dist/types/exporters/gif/GIFRecorder.d.ts +3 -3
  11. package/dist/types/exporters/gif/GIFRecorder.d.ts.map +1 -1
  12. package/dist/types/exporters/gif/types.d.ts.map +1 -1
  13. package/dist/types/exporters/image/ImageExporter.d.ts +7 -2
  14. package/dist/types/exporters/image/ImageExporter.d.ts.map +1 -1
  15. package/dist/types/exporters/image/index.d.ts +1 -1
  16. package/dist/types/exporters/image/index.d.ts.map +1 -1
  17. package/dist/types/exporters/image/types.d.ts.map +1 -1
  18. package/dist/types/exporters/json/JSONDataExtractor.d.ts +16 -0
  19. package/dist/types/exporters/json/JSONDataExtractor.d.ts.map +1 -0
  20. package/dist/types/exporters/json/JSONExporter.d.ts +56 -0
  21. package/dist/types/exporters/json/JSONExporter.d.ts.map +1 -0
  22. package/dist/types/exporters/json/JSONExporter.test.d.ts +2 -0
  23. package/dist/types/exporters/json/JSONExporter.test.d.ts.map +1 -0
  24. package/dist/types/exporters/json/index.d.ts +4 -0
  25. package/dist/types/exporters/json/index.d.ts.map +1 -0
  26. package/dist/types/exporters/json/types.d.ts +135 -0
  27. package/dist/types/exporters/json/types.d.ts.map +1 -0
  28. package/dist/types/exporters/svg/SVGContentGenerator.d.ts +9 -1
  29. package/dist/types/exporters/svg/SVGContentGenerator.d.ts.map +1 -1
  30. package/dist/types/exporters/svg/SVGDataExtractor.d.ts +2 -8
  31. package/dist/types/exporters/svg/SVGDataExtractor.d.ts.map +1 -1
  32. package/dist/types/exporters/svg/SVGExporter.d.ts +3 -0
  33. package/dist/types/exporters/svg/SVGExporter.d.ts.map +1 -1
  34. package/dist/types/exporters/svg/SVGPathGenerator.d.ts +8 -4
  35. package/dist/types/exporters/svg/SVGPathGenerator.d.ts.map +1 -1
  36. package/dist/types/exporters/svg/index.d.ts +1 -1
  37. package/dist/types/exporters/svg/index.d.ts.map +1 -1
  38. package/dist/types/exporters/svg/types.d.ts.map +1 -1
  39. package/dist/types/exporters/txt/TXTExporter.d.ts +4 -0
  40. package/dist/types/exporters/txt/TXTExporter.d.ts.map +1 -1
  41. package/dist/types/exporters/txt/index.d.ts.map +1 -1
  42. package/dist/types/exporters/txt/types.d.ts.map +1 -1
  43. package/dist/types/exporters/video/VideoExporter.d.ts +5 -2
  44. package/dist/types/exporters/video/VideoExporter.d.ts.map +1 -1
  45. package/dist/types/exporters/video/VideoRecorder.d.ts +3 -3
  46. package/dist/types/exporters/video/VideoRecorder.d.ts.map +1 -1
  47. package/dist/types/exporters/video/index.d.ts +1 -1
  48. package/dist/types/exporters/video/index.d.ts.map +1 -1
  49. package/dist/types/exporters/video/types.d.ts +2 -2
  50. package/dist/types/exporters/video/types.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +10 -2
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/types/overlay/blades/Blade.d.ts +6 -1
  54. package/dist/types/overlay/blades/Blade.d.ts.map +1 -1
  55. package/dist/types/overlay/blades/GIFBlade.d.ts.map +1 -1
  56. package/dist/types/overlay/blades/ImageBlade.d.ts.map +1 -1
  57. package/dist/types/overlay/blades/JSONBlade.d.ts +15 -0
  58. package/dist/types/overlay/blades/JSONBlade.d.ts.map +1 -0
  59. package/dist/types/overlay/blades/SVGBlade.d.ts.map +1 -1
  60. package/dist/types/overlay/blades/TextBlade.d.ts.map +1 -1
  61. package/dist/types/overlay/blades/VideoBlade.d.ts.map +1 -1
  62. package/dist/types/overlay/blades/index.d.ts +1 -0
  63. package/dist/types/overlay/blades/index.d.ts.map +1 -1
  64. package/dist/types/overlay/components/actions/Button.d.ts.map +1 -1
  65. package/dist/types/overlay/components/base/Component.d.ts.map +1 -1
  66. package/dist/types/overlay/components/base/Container.d.ts.map +1 -1
  67. package/dist/types/overlay/components/base/Field.d.ts.map +1 -1
  68. package/dist/types/overlay/components/display/Header.d.ts.map +1 -1
  69. package/dist/types/overlay/components/display/StatusDisplay.d.ts.map +1 -1
  70. package/dist/types/overlay/components/inputs/CheckboxInput.d.ts.map +1 -1
  71. package/dist/types/overlay/components/inputs/NumberInput.d.ts.map +1 -1
  72. package/dist/types/overlay/components/inputs/RangeInput.d.ts.map +1 -1
  73. package/dist/types/overlay/components/inputs/SelectInput.d.ts.map +1 -1
  74. package/dist/types/overlay/components/inputs/TextInput.d.ts.map +1 -1
  75. package/dist/types/overlay/core/EventBus.d.ts +1 -0
  76. package/dist/types/overlay/core/EventBus.d.ts.map +1 -1
  77. package/dist/types/overlay/core/OverlayController.d.ts.map +1 -1
  78. package/dist/types/overlay/core/StateManager.d.ts.map +1 -1
  79. package/dist/types/overlay/formatRegistry.d.ts.map +1 -1
  80. package/dist/types/overlay/index.d.ts +1 -0
  81. package/dist/types/overlay/index.d.ts.map +1 -1
  82. package/dist/types/overlay/models/FormatDefinition.d.ts +3 -3
  83. package/dist/types/overlay/models/FormatDefinition.d.ts.map +1 -1
  84. package/dist/types/overlay/models/OverlayEvents.d.ts.map +1 -1
  85. package/dist/types/overlay/models/OverlayState.d.ts.map +1 -1
  86. package/dist/types/overlay/services/ClipboardService.d.ts +8 -2
  87. package/dist/types/overlay/services/ClipboardService.d.ts.map +1 -1
  88. package/dist/types/overlay/services/ExportService.d.ts.map +1 -1
  89. package/dist/types/overlay/services/PositionService.d.ts.map +1 -1
  90. package/dist/types/overlay/types.d.ts +3 -1
  91. package/dist/types/overlay/types.d.ts.map +1 -1
  92. package/dist/types/types.d.ts +104 -0
  93. package/dist/types/types.d.ts.map +1 -1
  94. package/dist/types/utils/pixels.d.ts +1 -0
  95. package/dist/types/utils/pixels.d.ts.map +1 -1
  96. package/dist/types/version.d.ts +2 -0
  97. package/dist/types/version.d.ts.map +1 -0
  98. package/package.json +118 -71
package/README.md CHANGED
@@ -1,172 +1,171 @@
1
- # textmode.export.js (✿◕‿◕)ノ
2
-
3
- <div align="center">
4
-
5
- | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![API](https://img.shields.io/badge/API-typedoc-3178c6?logo=typescript&logoColor=white)](docs/README.md) [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/docs/exporting.html) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
6
- |:-------------|:-------------|:-------------|
7
-
8
- </div>
9
-
10
- `textmode.export.js` is an add-on library for [`textmode.js`](https://github.com/humanbydefinition/textmode.js) that adds various export options to your `Textmodifier` instance, including:
11
- - Plain text (`.txt`)
12
- - Image files (`.png`, `.jpg`, `.webp`)
13
- - Animated image files (`.gif`)
14
- - Video files (`.webm`)
15
- - Scalable vector graphics (`.svg`)
16
-
17
- Besides exporting programatically, `textmode.export.js` also provides an overlay UI for users to easily export their creations.
18
-
19
- ## Installation
20
-
21
- ### Prerequisites
22
- - The latest `textmode.export.js` version requires `textmode.js` v0.7.0 or later.
23
-
24
- ### UMD
25
-
26
- To use `textmode.export.js` in a UMD environment, download the latest `umd` build from the [**GitHub releases page**](https://github.com/humanbydefinition/textmode.export.js/releases/) or import it directly from a CDN like [**jsDelivr**](https://www.jsdelivr.com/package/npm/textmode.export.js). The library is distributed as a single JavaScript file, which you can include in your project by adding the following script tag to your HTML file:
27
-
28
- ```html
29
- <!-- index.html -->
30
- <!DOCTYPE html>
31
- <html>
32
- <head>
33
- <title>textmode.js sketch</title>
34
-
35
- <!-- Import textmode.js from jsDelivr CDN -->
36
- <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
37
-
38
- <!-- Import textmode.export.js from jsDelivr CDN -->
39
- <script src="https://cdn.jsdelivr.net/npm/textmode.export.js@latest/dist/textmode.export.umd.js"></script>
40
- </head>
41
- <body>
42
- <script src="sketch.js"></script>
43
- </body>
44
- </html>
45
- ```
46
-
47
- ```javascript
48
- // sketch.js
49
- const t = textmode.create({
50
- width: window.innerWidth,
51
- height: window.innerHeight,
52
- fontSize: 16,
53
- frameRate: 60,
54
- plugins: [
55
- ExportPlugin
56
- ]
57
- });
58
-
59
- t.setup(() => {
60
- // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
61
- });
62
-
63
- t.draw(() => {
64
- t.background(32); // Dark gray background
65
-
66
- t.char('A');
67
- t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
68
- t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
69
-
70
- // ...add your drawing code here!
71
-
72
- if (t.frameCount === 60) {
73
- t.saveCanvas({
74
- format: 'png',
75
- filename: 'my-sketch'
76
- });
77
- }
78
- });
79
-
80
- // Control the export overlay UI at runtime
81
- // t.exportOverlay.hide(); // Hide the overlay
82
- // t.exportOverlay.show(); // Show the overlay
83
- // t.exportOverlay.toggle(); // Toggle visibility
84
-
85
- t.windowResized(() => {
86
- t.resizeCanvas(window.innerWidth, window.innerHeight);
87
- });
88
- ```
89
-
90
- #### ESM
91
-
92
- To use `textmode.export.js` in an ESM environment, you can install it via `npm`:
93
-
94
- ```bash
95
- npm install textmode.export.js
96
- ```
97
-
98
- Then, you can import it in your JavaScript or TypeScript files:
99
-
100
- ```html
101
- <!-- index.html -->
102
- <!DOCTYPE html>
103
- <html lang="en">
104
- <head>
105
- <meta charset="utf-8">
106
- <title>textmode.js sketch</title>
107
- </head>
108
- <body>
109
- <script type="module" src="./sketch.js"></script>
110
- </body>
111
- </html>
112
- ```
113
-
114
- ```javascript
115
- // sketch.js
116
- import { textmode } from 'textmode.js';
117
- import { ExportPlugin } from 'textmode.export.js';
118
-
119
- const t = textmode.create({
120
- width: window.innerWidth,
121
- height: window.innerHeight,
122
- fontSize: 16,
123
- frameRate: 60,
124
- plugins: [
125
- ExportPlugin
126
- ]
127
- });
128
-
129
- t.setup(() => {
130
- // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
131
- });
132
-
133
- t.draw(() => {
134
- t.background(32); // Dark gray background
135
-
136
- t.char('A');
137
- t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
138
- t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
139
-
140
- // ...add your drawing code here!
141
-
142
- if (t.frameCount === 60) {
143
- t.saveCanvas({
144
- format: 'png',
145
- filename: 'my-sketch'
146
- });
147
- }
148
- });
149
-
150
- // Control the export overlay UI at runtime
151
- // t.exportOverlay.hide(); // Hide the overlay
152
- // t.exportOverlay.show(); // Show the overlay
153
- // t.exportOverlay.toggle(); // Toggle visibility
154
-
155
- t.windowResized(() => {
156
- t.resizeCanvas(window.innerWidth, window.innerHeight);
157
- });
158
- ```
159
-
160
- ## Next steps
161
-
162
- Now that you have `textmode.export.js` set up, you can explore the following resources to learn more about its features and capabilities:
163
-
164
- 📚 **[Visit the Official Documentation](https://code.textmode.art/docs/exporting.html)** for a detailed guide on how to use the `textmode.export.js` and all its features.
165
-
166
- 🔍 **[Browse the TypeDoc API reference](docs/README.md)** hosted right here in the repository for in-depth API details.
167
-
168
- ## Acknowledgements
169
-
170
- `textmode.export.js` packages [`webm-writer-js`](https://github.com/thenickdude/webm-writer-js) by [**Nicholas Sherlock**](https://github.com/thenickdude) to provide WebM video export support. `webm-writer-js` is distributed under the [**WTFPL v2**](https://en.wikipedia.org/wiki/WTFPL) license.
171
-
172
- Animated GIF export relies on [`gifenc`](https://github.com/mattdesl/gifenc) by [**Matt DesLauriers**](https://github.com/mattdesl), available under the [**MIT License**](https://opensource.org/licenses/MIT).
1
+ # textmode.export.js (✿◕‿◕)ノ
2
+
3
+ <div align="center">
4
+
5
+ | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![API](https://img.shields.io/badge/API-typedoc-3178c6?logo=typescript&logoColor=white)](docs/README.md) [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/docs/exporting.html) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![GitHub-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
6
+ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+
8
+ </div>
9
+
10
+ `textmode.export.js` is an add-on library for [`textmode.js`](https://github.com/humanbydefinition/textmode.js) that adds various export options to your `Textmodifier` instance, including:
11
+
12
+ - Plain text (`.txt`)
13
+ - JSON layer data (`.json`)
14
+ - Image files (`.png`, `.jpg`, `.webp`)
15
+ - Animated image files (`.gif`)
16
+ - Video files (`.webm`)
17
+ - Scalable vector graphics (`.svg`)
18
+
19
+ Besides exporting programatically, `textmode.export.js` also provides an overlay UI for users to easily export their creations.
20
+
21
+ ## Installation
22
+
23
+ ### Prerequisites
24
+
25
+ - The latest `textmode.export.js` version requires `textmode.js` v0.7.0 or later.
26
+
27
+ ### UMD
28
+
29
+ To use `textmode.export.js` in a UMD environment, download the latest `umd` build from the [**GitHub releases page**](https://github.com/humanbydefinition/textmode.export.js/releases/) or import it directly from a CDN like [**jsDelivr**](https://www.jsdelivr.com/package/npm/textmode.export.js). The library is distributed as a single JavaScript file, which you can include in your project by adding the following script tag to your HTML file:
30
+
31
+ ```html
32
+ <!-- index.html -->
33
+ <!DOCTYPE html>
34
+ <html>
35
+ <head>
36
+ <title>textmode.js sketch</title>
37
+
38
+ <!-- Import textmode.js from jsDelivr CDN -->
39
+ <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
40
+
41
+ <!-- Import textmode.export.js from jsDelivr CDN -->
42
+ <script src="https://cdn.jsdelivr.net/npm/textmode.export.js@latest/dist/textmode.export.umd.js"></script>
43
+ </head>
44
+ <body>
45
+ <script src="sketch.js"></script>
46
+ </body>
47
+ </html>
48
+ ```
49
+
50
+ ```javascript
51
+ // sketch.js
52
+ const t = textmode.create({
53
+ width: window.innerWidth,
54
+ height: window.innerHeight,
55
+ fontSize: 16,
56
+ frameRate: 60,
57
+ plugins: [ExportPlugin],
58
+ });
59
+
60
+ t.setup(() => {
61
+ // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
62
+ });
63
+
64
+ t.draw(() => {
65
+ t.background(32); // Dark gray background
66
+
67
+ t.char('A');
68
+ t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
69
+ t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
70
+
71
+ // ...add your drawing code here!
72
+
73
+ if (t.frameCount === 60) {
74
+ t.saveCanvas({
75
+ format: 'png',
76
+ filename: 'my-sketch',
77
+ });
78
+ }
79
+ });
80
+
81
+ // Control the export overlay UI at runtime
82
+ // t.exportOverlay.hide(); // Hide the overlay
83
+ // t.exportOverlay.show(); // Show the overlay
84
+ // t.exportOverlay.toggle(); // Toggle visibility
85
+
86
+ t.windowResized(() => {
87
+ t.resizeCanvas(window.innerWidth, window.innerHeight);
88
+ });
89
+ ```
90
+
91
+ #### ESM
92
+
93
+ To use `textmode.export.js` in an ESM environment, you can install it via `npm`:
94
+
95
+ ```bash
96
+ npm install textmode.export.js
97
+ ```
98
+
99
+ Then, you can import it in your JavaScript or TypeScript files:
100
+
101
+ ```html
102
+ <!-- index.html -->
103
+ <!DOCTYPE html>
104
+ <html lang="en">
105
+ <head>
106
+ <meta charset="utf-8" />
107
+ <title>textmode.js sketch</title>
108
+ </head>
109
+ <body>
110
+ <script type="module" src="./sketch.js"></script>
111
+ </body>
112
+ </html>
113
+ ```
114
+
115
+ ```javascript
116
+ // sketch.js
117
+ import { textmode } from 'textmode.js';
118
+ import { ExportPlugin } from 'textmode.export.js';
119
+
120
+ const t = textmode.create({
121
+ width: window.innerWidth,
122
+ height: window.innerHeight,
123
+ fontSize: 16,
124
+ frameRate: 60,
125
+ plugins: [ExportPlugin],
126
+ });
127
+
128
+ t.setup(() => {
129
+ // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
130
+ });
131
+
132
+ t.draw(() => {
133
+ t.background(32); // Dark gray background
134
+
135
+ t.char('A');
136
+ t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
137
+ t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
138
+
139
+ // ...add your drawing code here!
140
+
141
+ if (t.frameCount === 60) {
142
+ t.saveCanvas({
143
+ format: 'png',
144
+ filename: 'my-sketch',
145
+ });
146
+ }
147
+ });
148
+
149
+ // Control the export overlay UI at runtime
150
+ // t.exportOverlay.hide(); // Hide the overlay
151
+ // t.exportOverlay.show(); // Show the overlay
152
+ // t.exportOverlay.toggle(); // Toggle visibility
153
+
154
+ t.windowResized(() => {
155
+ t.resizeCanvas(window.innerWidth, window.innerHeight);
156
+ });
157
+ ```
158
+
159
+ ## Next steps
160
+
161
+ Now that you have `textmode.export.js` set up, you can explore the following resources to learn more about its features and capabilities:
162
+
163
+ 📚 **[Visit the Official Documentation](https://code.textmode.art/docs/exporting.html)** for a detailed guide on how to use the `textmode.export.js` and all its features.
164
+
165
+ 🔍 **[Browse the TypeDoc API reference](docs/README.md)** hosted right here in the repository for in-depth API details.
166
+
167
+ ## Acknowledgements
168
+
169
+ `textmode.export.js` packages [`webm-writer-js`](https://github.com/thenickdude/webm-writer-js) by [**Nicholas Sherlock**](https://github.com/thenickdude) to provide WebM video export support. `webm-writer-js` is distributed under the [**WTFPL v2**](https://en.wikipedia.org/wiki/WTFPL) license.
170
+
171
+ Animated GIF export relies on [`gifenc`](https://github.com/mattdesl/gifenc) by [**Matt DesLauriers**](https://github.com/mattdesl), available under the [**MIT License**](https://opensource.org/licenses/MIT).