textmode.export.js 1.8.1 → 1.9.0-beta.2

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 (54) hide show
  1. package/README.md +11 -2
  2. package/dist/textmode.document.esm.js +1 -0
  3. package/dist/textmode.export.esm.js +1 -1
  4. package/dist/textmode.export.umd.js +1 -1
  5. package/dist/types/document/constants.d.ts +32 -0
  6. package/dist/types/document/decode-shapes.d.ts +4 -0
  7. package/dist/types/document/decode.d.ts +5 -0
  8. package/dist/types/document/index.d.ts +13 -0
  9. package/dist/types/document/parse.d.ts +3 -0
  10. package/dist/types/document/types.d.ts +209 -0
  11. package/dist/types/document/validation.d.ts +37 -0
  12. package/dist/types/exporters/base/FileHandler.d.ts +1 -14
  13. package/dist/types/exporters/base/FilenamePolicy.d.ts +6 -0
  14. package/dist/types/exporters/base/LayerTarget.d.ts +0 -2
  15. package/dist/types/exporters/base/frame-sequence/ExclusiveCaptureGate.d.ts +7 -0
  16. package/dist/types/exporters/{video/VideoFrameSchedule.d.ts → base/frame-sequence/FrameSchedule.d.ts} +2 -2
  17. package/dist/types/exporters/{video/VideoFrameDriver.d.ts → base/frame-sequence/FrameSequenceDriver.d.ts} +5 -11
  18. package/dist/types/exporters/base/frame-sequence/errors.d.ts +12 -0
  19. package/dist/types/exporters/base/frame-sequence/index.d.ts +5 -0
  20. package/dist/types/exporters/base/frame-sequence/types.d.ts +20 -0
  21. package/dist/types/exporters/base/frame-sequence/withAbortableTimeout.d.ts +1 -0
  22. package/dist/types/exporters/base/index.d.ts +3 -0
  23. package/dist/types/exporters/gif/GIFExporter.d.ts +1 -1
  24. package/dist/types/exporters/gif/index.d.ts +0 -1
  25. package/dist/types/exporters/gif/types.d.ts +0 -10
  26. package/dist/types/exporters/image/types.d.ts +0 -2
  27. package/dist/types/exporters/json/JSONExporter.d.ts +2 -2
  28. package/dist/types/exporters/json/types.d.ts +14 -204
  29. package/dist/types/exporters/svg/types.d.ts +1 -3
  30. package/dist/types/exporters/txt/types.d.ts +0 -2
  31. package/dist/types/exporters/video/VideoExporter.d.ts +1 -2
  32. package/dist/types/exporters/video/errors.d.ts +1 -0
  33. package/dist/types/exporters/video/types.d.ts +3 -35
  34. package/dist/types/exporters/zip/FrameSerializerRegistry.d.ts +4 -0
  35. package/dist/types/exporters/zip/ZIPArchiveWriter.d.ts +21 -0
  36. package/dist/types/exporters/zip/ZIPExporter.d.ts +32 -0
  37. package/dist/types/exporters/zip/ZIPManifest.d.ts +12 -0
  38. package/dist/types/exporters/zip/errors.d.ts +13 -0
  39. package/dist/types/exporters/zip/index.d.ts +3 -0
  40. package/dist/types/exporters/zip/types.d.ts +170 -0
  41. package/dist/types/index.d.ts +5 -24
  42. package/dist/types/runtime/TextmodeExportController.d.ts +3 -0
  43. package/dist/types/types.d.ts +43 -24
  44. package/package.json +50 -11
  45. package/protocol/textmode-document/2.0/SPECIFICATION.md +233 -0
  46. package/protocol/textmode-document/2.0/fixture.d.ts +3 -0
  47. package/protocol/textmode-document/2.0/fixtures/textmode-document-all-v2.json +94 -0
  48. package/protocol/textmode-document/2.0/fixtures/textmode-document-create-integration-v2.json +112 -0
  49. package/protocol/textmode-document/2.0/fixtures/textmode-document-selected-v2.json +86 -0
  50. package/protocol/textmode-document/2.0/fixtures/textmode-layer-all-v1.1.json +46 -0
  51. package/protocol/textmode-document/2.0/fixtures/textmode-layer-selected-v1.json +38 -0
  52. package/protocol/textmode-document/2.0/textmode-document-2.0.schema.d.ts +3 -0
  53. package/protocol/textmode-document/2.0/textmode-document-2.0.schema.json +171 -0
  54. package/dist/types/exporters/gif/GIFRecorder.d.ts +0 -23
@@ -0,0 +1,112 @@
1
+ {
2
+ "format": "textmode.document",
3
+ "formatVersion": "2.0.0",
4
+ "target": "selected",
5
+ "metadata": {
6
+ "createdAt": "2026-09-21T12:00:00.000Z",
7
+ "generator": {
8
+ "name": "textmode.export.js",
9
+ "version": "1.8.1"
10
+ }
11
+ },
12
+ "canvas": {
13
+ "width": 24,
14
+ "height": 16
15
+ },
16
+ "grid": {
17
+ "cols": 3,
18
+ "rows": 2,
19
+ "cellWidth": 8,
20
+ "cellHeight": 8
21
+ },
22
+ "layer": {
23
+ "id": "base",
24
+ "cells": {
25
+ "encoding": "object-rows-v1",
26
+ "rows": [
27
+ [
28
+ {
29
+ "x": 0,
30
+ "y": 0,
31
+ "character": "A",
32
+ "foreground": "#ff000080",
33
+ "background": "#00000000",
34
+ "transform": {
35
+ "invert": false,
36
+ "flipX": false,
37
+ "flipY": false,
38
+ "rotation": 0
39
+ }
40
+ },
41
+ {
42
+ "x": 1,
43
+ "y": 0,
44
+ "character": "😀",
45
+ "foreground": { "r": 0, "g": 255, "b": 0, "a": 255 },
46
+ "background": { "r": 0, "g": 0, "b": 255, "a": 96 },
47
+ "transform": {
48
+ "invert": false,
49
+ "flipX": true,
50
+ "flipY": false,
51
+ "rotation": 360
52
+ }
53
+ },
54
+ {
55
+ "x": 2,
56
+ "y": 0,
57
+ "character": "é",
58
+ "foreground": "#ffffffff",
59
+ "background": "#223344cc",
60
+ "transform": {
61
+ "invert": false,
62
+ "flipX": true,
63
+ "flipY": true,
64
+ "rotation": 45
65
+ }
66
+ }
67
+ ],
68
+ [
69
+ {
70
+ "x": 0,
71
+ "y": 1,
72
+ "character": " ",
73
+ "foreground": "#00000000",
74
+ "background": "#123456ff",
75
+ "transform": {
76
+ "invert": false,
77
+ "flipX": false,
78
+ "flipY": true,
79
+ "rotation": 90
80
+ }
81
+ },
82
+ {
83
+ "x": 1,
84
+ "y": 1,
85
+ "character": "X",
86
+ "foreground": "#00000000",
87
+ "background": "#00000000",
88
+ "transform": {
89
+ "invert": false,
90
+ "flipX": false,
91
+ "flipY": false,
92
+ "rotation": 0
93
+ }
94
+ },
95
+ {
96
+ "x": 2,
97
+ "y": 1,
98
+ "character": "Z",
99
+ "foreground": "#abcdef40",
100
+ "background": "#10203020",
101
+ "transform": {
102
+ "invert": false,
103
+ "flipX": false,
104
+ "flipY": true,
105
+ "rotation": 270
106
+ }
107
+ }
108
+ ]
109
+ ]
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,86 @@
1
+ {
2
+ "format": "textmode.document",
3
+ "formatVersion": "2.0.0",
4
+ "target": "selected",
5
+ "metadata": {
6
+ "createdAt": "2026-08-28T12:00:00.000Z",
7
+ "generator": {
8
+ "name": "textmode.export.js",
9
+ "version": "1.8.1"
10
+ }
11
+ },
12
+ "canvas": {
13
+ "width": 16,
14
+ "height": 16
15
+ },
16
+ "grid": {
17
+ "cols": 2,
18
+ "rows": 2,
19
+ "cellWidth": 8,
20
+ "cellHeight": 8
21
+ },
22
+ "layer": {
23
+ "id": "base",
24
+ "cells": {
25
+ "encoding": "object-rows-v1",
26
+ "rows": [
27
+ [
28
+ {
29
+ "x": 0,
30
+ "y": 0,
31
+ "character": "A",
32
+ "foreground": "#ff0000ff",
33
+ "background": "#000000ff",
34
+ "transform": {
35
+ "invert": false,
36
+ "flipX": false,
37
+ "flipY": false,
38
+ "rotation": 0
39
+ }
40
+ },
41
+ {
42
+ "x": 1,
43
+ "y": 0,
44
+ "character": "😀",
45
+ "foreground": { "r": 0, "g": 255, "b": 0, "a": 255 },
46
+ "background": { "r": 0, "g": 0, "b": 255, "a": 128 },
47
+ "transform": {
48
+ "invert": false,
49
+ "flipX": true,
50
+ "flipY": false,
51
+ "rotation": 360
52
+ }
53
+ }
54
+ ],
55
+ [
56
+ {
57
+ "x": 0,
58
+ "y": 1,
59
+ "character": " ",
60
+ "foreground": "#00000000",
61
+ "background": "#123456ff",
62
+ "transform": {
63
+ "invert": false,
64
+ "flipX": false,
65
+ "flipY": true,
66
+ "rotation": 90
67
+ }
68
+ },
69
+ {
70
+ "x": 1,
71
+ "y": 1,
72
+ "character": "X",
73
+ "foreground": "#00000000",
74
+ "background": "#00000000",
75
+ "transform": {
76
+ "invert": false,
77
+ "flipX": false,
78
+ "flipY": false,
79
+ "rotation": 0
80
+ }
81
+ }
82
+ ]
83
+ ]
84
+ }
85
+ }
86
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "https://textmode.art/schemas/textmode-layer-1.0.schema.json",
3
+ "format": "textmode.layer",
4
+ "formatVersion": "1.1.0",
5
+ "canvas": {
6
+ "width": 8,
7
+ "height": 8
8
+ },
9
+ "layers": [
10
+ {
11
+ "id": "base",
12
+ "visible": true,
13
+ "opacity": 1,
14
+ "blendMode": "normal",
15
+ "offsetX": 0,
16
+ "offsetY": 0,
17
+ "rotationZ": 0,
18
+ "grid": {
19
+ "cols": 1,
20
+ "rows": 1,
21
+ "cellWidth": 8,
22
+ "cellHeight": 8
23
+ },
24
+ "cells": {
25
+ "encoding": "object-rows-v1",
26
+ "rows": [
27
+ [
28
+ {
29
+ "x": 0,
30
+ "y": 0,
31
+ "character": "A",
32
+ "foreground": "#ffffffff",
33
+ "background": "#000000ff",
34
+ "transform": {
35
+ "invert": false,
36
+ "flipX": false,
37
+ "flipY": false,
38
+ "rotation": 0
39
+ }
40
+ }
41
+ ]
42
+ ]
43
+ }
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "https://textmode.art/schemas/textmode-layer-1.0.schema.json",
3
+ "format": "textmode.layer",
4
+ "formatVersion": "1.0.0",
5
+ "canvas": {
6
+ "width": 8,
7
+ "height": 8
8
+ },
9
+ "grid": {
10
+ "cols": 1,
11
+ "rows": 1,
12
+ "cellWidth": 8,
13
+ "cellHeight": 8
14
+ },
15
+ "layer": {
16
+ "id": "base",
17
+ "cells": {
18
+ "encoding": "object-rows-v1",
19
+ "rows": [
20
+ [
21
+ {
22
+ "x": 0,
23
+ "y": 0,
24
+ "character": "A",
25
+ "foreground": "#ffffffff",
26
+ "background": "#000000ff",
27
+ "transform": {
28
+ "invert": false,
29
+ "flipX": false,
30
+ "flipY": false,
31
+ "rotation": 0
32
+ }
33
+ }
34
+ ]
35
+ ]
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,3 @@
1
+ declare const schema: Readonly<Record<string, unknown>>;
2
+
3
+ export default schema;
@@ -0,0 +1,171 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://textmode.art/schemas/textmode-document-2.0.schema.json",
4
+ "title": "Textmode document 2.0",
5
+ "description": "Editable textmode cell snapshots and layer stacks.",
6
+ "oneOf": [{ "$ref": "#/$defs/selectedDocument" }, { "$ref": "#/$defs/allDocument" }],
7
+ "$defs": {
8
+ "positiveSafeInteger": {
9
+ "type": "integer",
10
+ "minimum": 1,
11
+ "maximum": 9007199254740991
12
+ },
13
+ "canvas": {
14
+ "type": "object",
15
+ "required": ["width", "height"],
16
+ "properties": {
17
+ "width": { "$ref": "#/$defs/positiveSafeInteger" },
18
+ "height": { "$ref": "#/$defs/positiveSafeInteger" }
19
+ },
20
+ "additionalProperties": true
21
+ },
22
+ "grid": {
23
+ "type": "object",
24
+ "required": ["cols", "rows", "cellWidth", "cellHeight"],
25
+ "properties": {
26
+ "cols": { "$ref": "#/$defs/positiveSafeInteger" },
27
+ "rows": { "$ref": "#/$defs/positiveSafeInteger" },
28
+ "cellWidth": { "$ref": "#/$defs/positiveSafeInteger" },
29
+ "cellHeight": { "$ref": "#/$defs/positiveSafeInteger" }
30
+ },
31
+ "additionalProperties": true
32
+ },
33
+ "rgba": {
34
+ "type": "object",
35
+ "required": ["r", "g", "b", "a"],
36
+ "properties": {
37
+ "r": { "type": "integer", "minimum": 0, "maximum": 255 },
38
+ "g": { "type": "integer", "minimum": 0, "maximum": 255 },
39
+ "b": { "type": "integer", "minimum": 0, "maximum": 255 },
40
+ "a": { "type": "integer", "minimum": 0, "maximum": 255 }
41
+ },
42
+ "additionalProperties": true
43
+ },
44
+ "color": {
45
+ "oneOf": [
46
+ { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}(?:[0-9A-Fa-f]{2})?$" },
47
+ { "$ref": "#/$defs/rgba" }
48
+ ]
49
+ },
50
+ "transform": {
51
+ "type": "object",
52
+ "required": ["invert", "flipX", "flipY", "rotation"],
53
+ "properties": {
54
+ "invert": { "type": "boolean" },
55
+ "flipX": { "type": "boolean" },
56
+ "flipY": { "type": "boolean" },
57
+ "rotation": { "type": "number" }
58
+ },
59
+ "additionalProperties": true
60
+ },
61
+ "cell": {
62
+ "type": "object",
63
+ "required": ["x", "y", "character", "foreground", "background", "transform"],
64
+ "properties": {
65
+ "x": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
66
+ "y": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
67
+ "character": {
68
+ "type": "string",
69
+ "minLength": 1,
70
+ "maxLength": 64
71
+ },
72
+ "foreground": { "$ref": "#/$defs/color" },
73
+ "background": { "$ref": "#/$defs/color" },
74
+ "transform": { "$ref": "#/$defs/transform" }
75
+ },
76
+ "additionalProperties": true
77
+ },
78
+ "cells": {
79
+ "type": "object",
80
+ "required": ["encoding", "rows"],
81
+ "properties": {
82
+ "encoding": { "const": "object-rows-v1" },
83
+ "rows": {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "array",
87
+ "items": { "$ref": "#/$defs/cell" }
88
+ }
89
+ }
90
+ },
91
+ "additionalProperties": true
92
+ },
93
+ "metadata": {
94
+ "type": "object",
95
+ "required": ["createdAt", "generator"],
96
+ "properties": {
97
+ "createdAt": {
98
+ "type": "string",
99
+ "format": "date-time",
100
+ "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$"
101
+ },
102
+ "generator": {
103
+ "type": "object",
104
+ "required": ["name", "version"],
105
+ "properties": {
106
+ "name": { "type": "string", "minLength": 1 },
107
+ "version": { "type": "string", "minLength": 1 }
108
+ },
109
+ "additionalProperties": true
110
+ }
111
+ },
112
+ "additionalProperties": true
113
+ },
114
+ "selectedLayer": {
115
+ "type": "object",
116
+ "required": ["id", "cells"],
117
+ "properties": {
118
+ "id": { "type": "string", "minLength": 1 },
119
+ "cells": { "$ref": "#/$defs/cells" }
120
+ },
121
+ "additionalProperties": true
122
+ },
123
+ "stackLayer": {
124
+ "type": "object",
125
+ "required": ["id", "visible", "opacity", "blendMode", "offsetX", "offsetY", "rotationZ", "grid", "cells"],
126
+ "properties": {
127
+ "id": { "type": "string", "minLength": 1 },
128
+ "visible": { "type": "boolean" },
129
+ "opacity": { "type": "number", "minimum": 0, "maximum": 1 },
130
+ "blendMode": { "type": "string", "minLength": 1 },
131
+ "offsetX": { "type": "number" },
132
+ "offsetY": { "type": "number" },
133
+ "rotationZ": { "type": "number" },
134
+ "grid": { "$ref": "#/$defs/grid" },
135
+ "cells": { "$ref": "#/$defs/cells" }
136
+ },
137
+ "additionalProperties": true
138
+ },
139
+ "selectedDocument": {
140
+ "type": "object",
141
+ "required": ["format", "formatVersion", "target", "canvas", "grid", "layer"],
142
+ "properties": {
143
+ "format": { "const": "textmode.document" },
144
+ "formatVersion": { "const": "2.0.0" },
145
+ "target": { "const": "selected" },
146
+ "metadata": { "$ref": "#/$defs/metadata" },
147
+ "canvas": { "$ref": "#/$defs/canvas" },
148
+ "grid": { "$ref": "#/$defs/grid" },
149
+ "layer": { "$ref": "#/$defs/selectedLayer" }
150
+ },
151
+ "additionalProperties": true
152
+ },
153
+ "allDocument": {
154
+ "type": "object",
155
+ "required": ["format", "formatVersion", "target", "canvas", "layers"],
156
+ "properties": {
157
+ "format": { "const": "textmode.document" },
158
+ "formatVersion": { "const": "2.0.0" },
159
+ "target": { "const": "all" },
160
+ "metadata": { "$ref": "#/$defs/metadata" },
161
+ "canvas": { "$ref": "#/$defs/canvas" },
162
+ "layers": {
163
+ "type": "array",
164
+ "minItems": 1,
165
+ "items": { "$ref": "#/$defs/stackLayer" }
166
+ }
167
+ },
168
+ "additionalProperties": true
169
+ }
170
+ }
171
+ }
@@ -1,23 +0,0 @@
1
- import type { PostDrawSubscription } from '../video/VideoFrameDriver';
2
- import type { GIFExportProgress, GIFFrame, GIFGenerationOptions } from './types';
3
- /**
4
- * Records frames from a canvas for GIF generation.
5
- * Captures frames at specified intervals using textmode.js post-draw hooks.
6
- */
7
- export declare class GIFRecorder {
8
- /** Reusable canvas for frame scaling */
9
- private _canvas?;
10
- /** Reusable 2D context for frame scaling */
11
- private _ctx?;
12
- /**
13
- * Records a sequence of frames from the provided canvas.
14
- *
15
- * @param canvas - Source canvas to capture frames from
16
- * @param options - Frame generation options (rate, count, scale)
17
- * @param registerPostDrawHook - Hook registration function from textmode.js API
18
- * @param onProgress - Optional callback for recording progress updates
19
- * @returns Promise resolving to array of captured frames
20
- * @throws {Error} If frame capture fails
21
- */
22
- $record(canvas: HTMLCanvasElement, options: GIFGenerationOptions, registerPostDrawHook: PostDrawSubscription, onProgress?: (progress: GIFExportProgress) => void): Promise<GIFFrame[]>;
23
- }