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.
- package/README.md +11 -2
- package/dist/textmode.document.esm.js +1 -0
- package/dist/textmode.export.esm.js +1 -1
- package/dist/textmode.export.umd.js +1 -1
- package/dist/types/document/constants.d.ts +32 -0
- package/dist/types/document/decode-shapes.d.ts +4 -0
- package/dist/types/document/decode.d.ts +5 -0
- package/dist/types/document/index.d.ts +13 -0
- package/dist/types/document/parse.d.ts +3 -0
- package/dist/types/document/types.d.ts +209 -0
- package/dist/types/document/validation.d.ts +37 -0
- package/dist/types/exporters/base/FileHandler.d.ts +1 -14
- package/dist/types/exporters/base/FilenamePolicy.d.ts +6 -0
- package/dist/types/exporters/base/LayerTarget.d.ts +0 -2
- package/dist/types/exporters/base/frame-sequence/ExclusiveCaptureGate.d.ts +7 -0
- package/dist/types/exporters/{video/VideoFrameSchedule.d.ts → base/frame-sequence/FrameSchedule.d.ts} +2 -2
- package/dist/types/exporters/{video/VideoFrameDriver.d.ts → base/frame-sequence/FrameSequenceDriver.d.ts} +5 -11
- package/dist/types/exporters/base/frame-sequence/errors.d.ts +12 -0
- package/dist/types/exporters/base/frame-sequence/index.d.ts +5 -0
- package/dist/types/exporters/base/frame-sequence/types.d.ts +20 -0
- package/dist/types/exporters/base/frame-sequence/withAbortableTimeout.d.ts +1 -0
- package/dist/types/exporters/base/index.d.ts +3 -0
- package/dist/types/exporters/gif/GIFExporter.d.ts +1 -1
- package/dist/types/exporters/gif/index.d.ts +0 -1
- package/dist/types/exporters/gif/types.d.ts +0 -10
- package/dist/types/exporters/image/types.d.ts +0 -2
- package/dist/types/exporters/json/JSONExporter.d.ts +2 -2
- package/dist/types/exporters/json/types.d.ts +14 -204
- package/dist/types/exporters/svg/types.d.ts +1 -3
- package/dist/types/exporters/txt/types.d.ts +0 -2
- package/dist/types/exporters/video/VideoExporter.d.ts +1 -2
- package/dist/types/exporters/video/errors.d.ts +1 -0
- package/dist/types/exporters/video/types.d.ts +3 -35
- package/dist/types/exporters/zip/FrameSerializerRegistry.d.ts +4 -0
- package/dist/types/exporters/zip/ZIPArchiveWriter.d.ts +21 -0
- package/dist/types/exporters/zip/ZIPExporter.d.ts +32 -0
- package/dist/types/exporters/zip/ZIPManifest.d.ts +12 -0
- package/dist/types/exporters/zip/errors.d.ts +13 -0
- package/dist/types/exporters/zip/index.d.ts +3 -0
- package/dist/types/exporters/zip/types.d.ts +170 -0
- package/dist/types/index.d.ts +5 -24
- package/dist/types/runtime/TextmodeExportController.d.ts +3 -0
- package/dist/types/types.d.ts +43 -24
- package/package.json +50 -11
- package/protocol/textmode-document/2.0/SPECIFICATION.md +233 -0
- package/protocol/textmode-document/2.0/fixture.d.ts +3 -0
- package/protocol/textmode-document/2.0/fixtures/textmode-document-all-v2.json +94 -0
- package/protocol/textmode-document/2.0/fixtures/textmode-document-create-integration-v2.json +112 -0
- package/protocol/textmode-document/2.0/fixtures/textmode-document-selected-v2.json +86 -0
- package/protocol/textmode-document/2.0/fixtures/textmode-layer-all-v1.1.json +46 -0
- package/protocol/textmode-document/2.0/fixtures/textmode-layer-selected-v1.json +38 -0
- package/protocol/textmode-document/2.0/textmode-document-2.0.schema.d.ts +3 -0
- package/protocol/textmode-document/2.0/textmode-document-2.0.schema.json +171 -0
- package/dist/types/exporters/gif/GIFRecorder.d.ts +0 -23
package/dist/types/index.d.ts
CHANGED
|
@@ -15,27 +15,6 @@
|
|
|
15
15
|
* or use the built-in export overlay. For recipes and format trade-offs, read
|
|
16
16
|
* the [Exporting guide](/docs/exporting).
|
|
17
17
|
*
|
|
18
|
-
* @categoryDescription Workflow
|
|
19
|
-
* Install the plugin and use the export helpers added to a textmode.js sketch.
|
|
20
|
-
*
|
|
21
|
-
* @categoryDescription Canvas capture
|
|
22
|
-
* Export a still image from the rendered canvas.
|
|
23
|
-
*
|
|
24
|
-
* @categoryDescription GIF export
|
|
25
|
-
* Capture deterministic frames and encode an animated GIF.
|
|
26
|
-
*
|
|
27
|
-
* @categoryDescription Video export
|
|
28
|
-
* Capture deterministic frames and encode MP4 or WebM video with Mediabunny.
|
|
29
|
-
*
|
|
30
|
-
* @categoryDescription Layer data export
|
|
31
|
-
* Export selected-layer text or vector data as TXT or SVG.
|
|
32
|
-
*
|
|
33
|
-
* @categoryDescription JSON document data
|
|
34
|
-
* Export selected-layer or full-stack document data as JSON.
|
|
35
|
-
*
|
|
36
|
-
* @categoryDescription Overlay
|
|
37
|
-
* Configure and control the built-in export overlay.
|
|
38
|
-
*
|
|
39
18
|
* @showCategories
|
|
40
19
|
*/
|
|
41
20
|
import type { TextmodePlugin } from 'textmode.js';
|
|
@@ -45,15 +24,17 @@ export type { TextmodeExportAPI, ExportOverlayController } from './types';
|
|
|
45
24
|
export type { ImageExportOptions } from './exporters/image';
|
|
46
25
|
export type { SVGExportOptions } from './exporters/svg';
|
|
47
26
|
export type { TXTExportOptions } from './exporters/txt';
|
|
48
|
-
export
|
|
27
|
+
export { TEXTMODE_DOCUMENT_FORMAT, TEXTMODE_DOCUMENT_FORMAT_VERSION, TEXTMODE_OBJECT_ROWS_ENCODING } from './document';
|
|
28
|
+
export type { JSONExportTarget, TextmodeDocumentJSON, TextmodeDocumentTarget } from './document';
|
|
29
|
+
export type { JSONExportColorMode, JSONExportOptions } from './exporters/json';
|
|
49
30
|
export type { GIFExportOptions, GIFExportProgress } from './exporters/gif';
|
|
31
|
+
export { ZIPExportError } from './exporters/zip';
|
|
32
|
+
export type { ZIPCaptureOptions, ZIPExportErrorCode, ZIPExportOptions, ZIPExportProgress, ZIPExportState, ZIPFrameFormat, ZIPFrameOptionsMap, } from './exporters/zip';
|
|
50
33
|
export type { VideoBitrateMode, VideoExportFormat, VideoExportOptions, VideoExportPhase, VideoExportProgress, VideoHardwareAcceleration, VideoQuality, VideoQualityLevel, VideoSaveDestination, VideoRecordingState, } from './exporters/video';
|
|
51
34
|
export type { LayerExportOptions } from './exporters/base';
|
|
52
35
|
/**
|
|
53
36
|
* Default export plugin instance for the standard textmode.js workflow.
|
|
54
37
|
*
|
|
55
|
-
* @category Workflow
|
|
56
|
-
*
|
|
57
38
|
* @see {@link https://code.textmode.art/api/textmode.export.js/variables/ExportPlugin | ExportPlugin API reference}
|
|
58
39
|
*/
|
|
59
40
|
export declare const ExportPlugin: TextmodePlugin;
|
|
@@ -12,6 +12,7 @@ export declare class TextmodeExportController {
|
|
|
12
12
|
readonly api: TextmodeExportAPI;
|
|
13
13
|
private readonly _registerPostDrawHook;
|
|
14
14
|
private readonly _activeOperations;
|
|
15
|
+
private readonly _captureGate;
|
|
15
16
|
private readonly _overlayController;
|
|
16
17
|
private readonly _stopOverlayRefresh;
|
|
17
18
|
private _disposed;
|
|
@@ -19,6 +20,8 @@ export declare class TextmodeExportController {
|
|
|
19
20
|
dispose(): void;
|
|
20
21
|
private _createOverlayAPI;
|
|
21
22
|
private _runOperation;
|
|
23
|
+
private _runCaptureOperation;
|
|
24
|
+
private _emitZIPGateError;
|
|
22
25
|
private _assertLive;
|
|
23
26
|
}
|
|
24
27
|
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -4,51 +4,40 @@ import type { SVGExportOptions } from './exporters/svg';
|
|
|
4
4
|
import type { GIFExportOptions } from './exporters/gif';
|
|
5
5
|
import type { VideoExportOptions } from './exporters/video';
|
|
6
6
|
import type { JSONExportOptions, TextmodeDocumentJSON } from './exporters/json';
|
|
7
|
+
import type { ZIPExportOptions } from './exporters/zip';
|
|
7
8
|
/**
|
|
8
9
|
* Default TXT export fields controlled by the export overlay.
|
|
9
10
|
*
|
|
10
|
-
* @category Overlay
|
|
11
|
-
*
|
|
12
11
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/TXTOverlayDefaults | TXTOverlayDefaults API reference}
|
|
13
12
|
*/
|
|
14
13
|
export type TXTOverlayDefaults = Pick<TXTExportOptions, 'preserveTrailingSpaces' | 'emptyCharacter'>;
|
|
15
14
|
/**
|
|
16
15
|
* Default JSON export fields controlled by the export overlay.
|
|
17
16
|
*
|
|
18
|
-
* @category Overlay
|
|
19
|
-
*
|
|
20
17
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONOverlayDefaults | JSONOverlayDefaults API reference}
|
|
21
18
|
*/
|
|
22
19
|
export type JSONOverlayDefaults = Pick<JSONExportOptions, 'target' | 'pretty' | 'includeMetadata' | 'colorMode'>;
|
|
23
20
|
/**
|
|
24
21
|
* Default image export fields controlled by the export overlay.
|
|
25
22
|
*
|
|
26
|
-
* @category Overlay
|
|
27
|
-
*
|
|
28
23
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/ImageOverlayDefaults | ImageOverlayDefaults API reference}
|
|
29
24
|
*/
|
|
30
25
|
export type ImageOverlayDefaults = Pick<ImageExportOptions, 'format' | 'scale'>;
|
|
31
26
|
/**
|
|
32
27
|
* Default SVG export fields controlled by the export overlay.
|
|
33
28
|
*
|
|
34
|
-
* @category Overlay
|
|
35
|
-
*
|
|
36
29
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/SVGOverlayDefaults | SVGOverlayDefaults API reference}
|
|
37
30
|
*/
|
|
38
31
|
export type SVGOverlayDefaults = Pick<SVGExportOptions, 'includeBackgroundRectangles' | 'drawMode' | 'strokeWidth'>;
|
|
39
32
|
/**
|
|
40
33
|
* Default GIF export fields controlled by the export overlay.
|
|
41
34
|
*
|
|
42
|
-
* @category Overlay
|
|
43
|
-
*
|
|
44
35
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/GIFOverlayDefaults | GIFOverlayDefaults API reference}
|
|
45
36
|
*/
|
|
46
37
|
export type GIFOverlayDefaults = Pick<GIFExportOptions, 'frameCount' | 'frameRate' | 'scale' | 'repeat'>;
|
|
47
38
|
/**
|
|
48
39
|
* Default video export fields controlled by the export overlay.
|
|
49
40
|
*
|
|
50
|
-
* @category Overlay
|
|
51
|
-
*
|
|
52
41
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/VideoOverlayDefaults | VideoOverlayDefaults API reference}
|
|
53
42
|
*/
|
|
54
43
|
export type VideoOverlayDefaults = Pick<VideoExportOptions, 'format' | 'frameCount' | 'frameRate' | 'quality' | 'hardwareAcceleration' | 'keyFrameInterval' | 'transparent'>;
|
|
@@ -62,8 +51,6 @@ export type VideoOverlayDefaults = Pick<VideoExportOptions, 'format' | 'frameCou
|
|
|
62
51
|
* {@link ExportOverlayController.getDefaults} and
|
|
63
52
|
* {@link ExportOverlayController.setDefaults}.
|
|
64
53
|
*
|
|
65
|
-
* @category Overlay
|
|
66
|
-
*
|
|
67
54
|
* @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/ExportDefaults | ExportDefaults API reference}
|
|
68
55
|
*/
|
|
69
56
|
export type ExportDefaults = {
|
|
@@ -87,8 +74,6 @@ export type ExportDefaults = {
|
|
|
87
74
|
* format's curated defaults. Top-level `format` changes the overlay's selected
|
|
88
75
|
* format. Omitted keys keep their current value.
|
|
89
76
|
*
|
|
90
|
-
* @category Overlay
|
|
91
|
-
*
|
|
92
77
|
* @example
|
|
93
78
|
* ```ts
|
|
94
79
|
* t.exportOverlay.setDefaults({ format: 'image', image: { scale: 2 }, gif: { frameRate: 30 } });
|
|
@@ -107,8 +92,6 @@ export type ExportDefaultsPatch = {
|
|
|
107
92
|
* `auto` means the overlay is using the library default offset from the
|
|
108
93
|
* textmode canvas. `custom` means the user or runtime API has moved it.
|
|
109
94
|
*
|
|
110
|
-
* @category Overlay
|
|
111
|
-
*
|
|
112
95
|
* @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/ExportOverlayPosition | ExportOverlayPosition API reference}
|
|
113
96
|
*/
|
|
114
97
|
export interface ExportOverlayPosition {
|
|
@@ -119,8 +102,6 @@ export interface ExportOverlayPosition {
|
|
|
119
102
|
/**
|
|
120
103
|
* Canvas-relative placement coordinates for the export overlay UI.
|
|
121
104
|
*
|
|
122
|
-
* @category Overlay
|
|
123
|
-
*
|
|
124
105
|
* @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/ExportOverlayPositionInput | ExportOverlayPositionInput API reference}
|
|
125
106
|
*/
|
|
126
107
|
export interface ExportOverlayPositionInput {
|
|
@@ -130,8 +111,6 @@ export interface ExportOverlayPositionInput {
|
|
|
130
111
|
/**
|
|
131
112
|
* Controller for managing the export overlay UI visibility at runtime.
|
|
132
113
|
*
|
|
133
|
-
* @category Overlay
|
|
134
|
-
*
|
|
135
114
|
* @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/ExportOverlayController | ExportOverlayController API reference}
|
|
136
115
|
*/
|
|
137
116
|
export interface ExportOverlayController {
|
|
@@ -281,8 +260,6 @@ export interface ExportOverlayController {
|
|
|
281
260
|
/**
|
|
282
261
|
* Runtime export helpers that `ExportPlugin` attaches to the `Textmodifier` instance.
|
|
283
262
|
*
|
|
284
|
-
* @category Workflow
|
|
285
|
-
*
|
|
286
263
|
* @example
|
|
287
264
|
* {@includeCode ../examples/ExportPlugin/layerTargets/sketch.js}
|
|
288
265
|
*
|
|
@@ -503,4 +480,46 @@ export interface TextmodeExportAPI {
|
|
|
503
480
|
* @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeExportAPI#tovideoblob | TextmodeExportAPI.toVideoBlob API reference}
|
|
504
481
|
*/
|
|
505
482
|
toVideoBlob(options?: VideoExportOptions): Promise<Blob>;
|
|
483
|
+
/**
|
|
484
|
+
* Captures and downloads a deterministic frame sequence as a ZIP archive.
|
|
485
|
+
*
|
|
486
|
+
* The archive contains a versioned manifest followed by one-based, zero-padded frame files. ZIP export is available
|
|
487
|
+
* through code only and does not appear in the export overlay.
|
|
488
|
+
*
|
|
489
|
+
* @param options Required archive format, deterministic capture controls, and per-frame exporter options.
|
|
490
|
+
* @returns A promise that resolves after the archive download is initiated.
|
|
491
|
+
* @throws {Error} When validation, capture, serialization, archive writing, or download fails.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* await t.saveZip({
|
|
496
|
+
* format: 'png',
|
|
497
|
+
* filename: 'orbit-frames',
|
|
498
|
+
* frameCount: 120,
|
|
499
|
+
* frameRate: 30,
|
|
500
|
+
* frameOptions: { scale: 2 },
|
|
501
|
+
* });
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeExportAPI#savezip | TextmodeExportAPI.saveZip API reference}
|
|
505
|
+
*/
|
|
506
|
+
saveZip(options: ZIPExportOptions): Promise<void>;
|
|
507
|
+
/**
|
|
508
|
+
* Captures a deterministic frame sequence as an in-memory ZIP archive without downloading it.
|
|
509
|
+
*
|
|
510
|
+
* Peak memory includes the completed ZIP because this method returns a `Blob`; individual uncompressed frame
|
|
511
|
+
* payloads are serialized and released sequentially.
|
|
512
|
+
*
|
|
513
|
+
* @param options Required archive format, deterministic capture controls, and per-frame exporter options.
|
|
514
|
+
* @returns The completed `application/zip` blob.
|
|
515
|
+
* @throws {Error} When validation, capture, serialization, archive writing, or cancellation fails.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```ts
|
|
519
|
+
* const archive = await t.toZipBlob({ format: 'svg', frameCount: 60, frameRate: 24 });
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeExportAPI#tozipblob | TextmodeExportAPI.toZipBlob API reference}
|
|
523
|
+
*/
|
|
524
|
+
toZipBlob(options: ZIPExportOptions): Promise<Blob>;
|
|
506
525
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.export.js",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Export plugin for textmode.js - Save
|
|
3
|
+
"version": "1.9.0-beta.2",
|
|
4
|
+
"description": "Export plugin for textmode.js - Save images, GIFs, videos, SVG, JSON, text, and ZIP frame sequences.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devEngines": {
|
|
7
7
|
"runtime": {
|
|
8
8
|
"name": "node",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": ">=24.0.0",
|
|
10
10
|
"onFail": "error"
|
|
11
11
|
},
|
|
12
12
|
"packageManager": {
|
|
@@ -23,6 +23,38 @@
|
|
|
23
23
|
"types": "./dist/types/index.d.ts",
|
|
24
24
|
"import": "./dist/textmode.export.esm.js",
|
|
25
25
|
"require": "./dist/textmode.export.umd.js"
|
|
26
|
+
},
|
|
27
|
+
"./document": {
|
|
28
|
+
"types": "./dist/types/document/index.d.ts",
|
|
29
|
+
"import": "./dist/textmode.document.esm.js"
|
|
30
|
+
},
|
|
31
|
+
"./schema": {
|
|
32
|
+
"types": "./protocol/textmode-document/2.0/textmode-document-2.0.schema.d.ts",
|
|
33
|
+
"default": "./protocol/textmode-document/2.0/textmode-document-2.0.schema.json"
|
|
34
|
+
},
|
|
35
|
+
"./document/schema/2.0": {
|
|
36
|
+
"types": "./protocol/textmode-document/2.0/textmode-document-2.0.schema.d.ts",
|
|
37
|
+
"default": "./protocol/textmode-document/2.0/textmode-document-2.0.schema.json"
|
|
38
|
+
},
|
|
39
|
+
"./document/fixtures/2.0/textmode-document-selected-v2.json": {
|
|
40
|
+
"types": "./protocol/textmode-document/2.0/fixture.d.ts",
|
|
41
|
+
"default": "./protocol/textmode-document/2.0/fixtures/textmode-document-selected-v2.json"
|
|
42
|
+
},
|
|
43
|
+
"./document/fixtures/2.0/textmode-document-all-v2.json": {
|
|
44
|
+
"types": "./protocol/textmode-document/2.0/fixture.d.ts",
|
|
45
|
+
"default": "./protocol/textmode-document/2.0/fixtures/textmode-document-all-v2.json"
|
|
46
|
+
},
|
|
47
|
+
"./document/fixtures/2.0/textmode-document-create-integration-v2.json": {
|
|
48
|
+
"types": "./protocol/textmode-document/2.0/fixture.d.ts",
|
|
49
|
+
"default": "./protocol/textmode-document/2.0/fixtures/textmode-document-create-integration-v2.json"
|
|
50
|
+
},
|
|
51
|
+
"./document/fixtures/2.0/textmode-layer-selected-v1.json": {
|
|
52
|
+
"types": "./protocol/textmode-document/2.0/fixture.d.ts",
|
|
53
|
+
"default": "./protocol/textmode-document/2.0/fixtures/textmode-layer-selected-v1.json"
|
|
54
|
+
},
|
|
55
|
+
"./document/fixtures/2.0/textmode-layer-all-v1.1.json": {
|
|
56
|
+
"types": "./protocol/textmode-document/2.0/fixture.d.ts",
|
|
57
|
+
"default": "./protocol/textmode-document/2.0/fixtures/textmode-layer-all-v1.1.json"
|
|
26
58
|
}
|
|
27
59
|
},
|
|
28
60
|
"sideEffects": [
|
|
@@ -30,15 +62,17 @@
|
|
|
30
62
|
"./dist/textmode.export.umd.js"
|
|
31
63
|
],
|
|
32
64
|
"files": [
|
|
33
|
-
"dist"
|
|
65
|
+
"dist",
|
|
66
|
+
"protocol/textmode-document/2.0"
|
|
34
67
|
],
|
|
35
68
|
"scripts": {
|
|
36
69
|
"prebuild": "npm run clean",
|
|
37
70
|
"clean": "rm -rf dist",
|
|
38
71
|
"dev": "textmode-build dev --port 5174 --host",
|
|
39
72
|
"build:bundle": "textmode-build build",
|
|
73
|
+
"build:document": "vite build --config vite.document.config.ts",
|
|
40
74
|
"build:types": "textmode-types build",
|
|
41
|
-
"build": "npm run build:bundle && npm run build:types",
|
|
75
|
+
"build": "npm run build:bundle && npm run build:document && npm run build:types",
|
|
42
76
|
"check": "npm run format:check && npm run lint && npm run lint:markdown && npm run typecheck && npm run docs:check && npm run test && npm run build && npm run types:verify",
|
|
43
77
|
"docs:links:add": "textmode-docs links add",
|
|
44
78
|
"docs:api:check": "textmode-docs api-check",
|
|
@@ -63,20 +97,23 @@
|
|
|
63
97
|
"textmode.js": "^0.18.0"
|
|
64
98
|
},
|
|
65
99
|
"dependencies": {
|
|
100
|
+
"fflate": "0.8.3",
|
|
66
101
|
"gifenc": "^1.0.1",
|
|
67
|
-
"mediabunny": "1.
|
|
102
|
+
"mediabunny": "1.56.1"
|
|
68
103
|
},
|
|
69
104
|
"devDependencies": {
|
|
70
|
-
"@textmode/build": "^0.1.
|
|
105
|
+
"@textmode/build": "^0.1.1",
|
|
71
106
|
"@textmode/docs": "^0.3.0",
|
|
72
|
-
"@textmode/lint": "^0.1.
|
|
107
|
+
"@textmode/lint": "^0.1.2",
|
|
73
108
|
"@textmode/release": "^0.2.0",
|
|
74
|
-
"@textmode/tsconfig": "^0.2.
|
|
75
|
-
"@types/node": "^
|
|
109
|
+
"@textmode/tsconfig": "^0.2.2",
|
|
110
|
+
"@types/node": "^26.4.1",
|
|
111
|
+
"ajv": "^8.20.0",
|
|
112
|
+
"ajv-formats": "^3.0.1",
|
|
76
113
|
"textmode.js": "^0.18.0",
|
|
77
114
|
"typescript": "^6.0.3",
|
|
78
115
|
"vite-plugin-css-injected-by-js": "^5.0.2",
|
|
79
|
-
"vitest": "^
|
|
116
|
+
"vitest": "^5.0.0"
|
|
80
117
|
},
|
|
81
118
|
"keywords": [
|
|
82
119
|
"textmode",
|
|
@@ -94,6 +131,8 @@
|
|
|
94
131
|
"png",
|
|
95
132
|
"jpg",
|
|
96
133
|
"webp",
|
|
134
|
+
"zip",
|
|
135
|
+
"frame-sequence",
|
|
97
136
|
"creative-coding",
|
|
98
137
|
"canvas"
|
|
99
138
|
],
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Textmode document format 2.0
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
This document defines `textmode.document` version `2.0.0`. The JSON Schema is
|
|
6
|
+
published beside this specification and through the `textmode.export.js/schema`
|
|
7
|
+
and `textmode.export.js/document/schema/2.0` package subpaths. The schema's
|
|
8
|
+
`$id` is a stable identifier, not a hosted download URL. The runtime codec is
|
|
9
|
+
available from the ESM-only `textmode.export.js/document` subpath. The five
|
|
10
|
+
canonical JSON fixtures in this directory are available through subpaths such
|
|
11
|
+
as `textmode.export.js/document/fixtures/2.0/textmode-document-selected-v2.json`.
|
|
12
|
+
Use the JSON import mechanism required by your runtime or bundler.
|
|
13
|
+
|
|
14
|
+
The format represents editable cell data. It does not represent final rendered
|
|
15
|
+
pixels, post-processing, an editor project, or authored animation.
|
|
16
|
+
|
|
17
|
+
## Encoding
|
|
18
|
+
|
|
19
|
+
A textmode document is a UTF-8 JSON object. Producers should follow the I-JSON
|
|
20
|
+
profile in RFC 7493:
|
|
21
|
+
|
|
22
|
+
- object member names are unique;
|
|
23
|
+
- integers remain within the interoperable safe range;
|
|
24
|
+
- non-finite numbers are not emitted;
|
|
25
|
+
- timestamps use an uppercase, timezone-qualified RFC 3339 representation.
|
|
26
|
+
|
|
27
|
+
The media type is `application/json`. `.textmode.json` is a suggested filename
|
|
28
|
+
suffix; existing exporter downloads use `.json` by default. Extensions and
|
|
29
|
+
media types are discovery hints; consumers must route a decoded object using
|
|
30
|
+
its `format` member.
|
|
31
|
+
|
|
32
|
+
## Root discriminator
|
|
33
|
+
|
|
34
|
+
Every v2 document contains:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"format": "textmode.document",
|
|
39
|
+
"formatVersion": "2.0.0",
|
|
40
|
+
"target": "selected"
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`target` is an on-disk shape discriminator:
|
|
45
|
+
|
|
46
|
+
- `selected` contains one cell snapshot in `layer`;
|
|
47
|
+
- `all` contains a layer stack in `layers`.
|
|
48
|
+
|
|
49
|
+
It is not an instruction to an exporter and must not be extended with temporal
|
|
50
|
+
values such as `animation`. Authored animation requires a distinct document or
|
|
51
|
+
container format.
|
|
52
|
+
|
|
53
|
+
## Version compatibility
|
|
54
|
+
|
|
55
|
+
The version is SemVer-shaped for release communication. Version 2 does not
|
|
56
|
+
define reader negotiation or a formal extension mechanism. Consumers therefore
|
|
57
|
+
accept only explicitly tested versions and migrations; they must not assume an
|
|
58
|
+
unknown `2.x` version is compatible.
|
|
59
|
+
|
|
60
|
+
For a supported version, consumers ignore unknown ordinary object members.
|
|
61
|
+
They reject unknown values of tagged members such as `format`, `target`, and
|
|
62
|
+
`encoding` because those values change interpretation.
|
|
63
|
+
|
|
64
|
+
Version 2 does not define `extensionsUsed`, `extensionsRequired`, extension
|
|
65
|
+
namespacing, or an extension registry. A later revision must define those
|
|
66
|
+
rules before claiming extension compatibility.
|
|
67
|
+
|
|
68
|
+
## Selected cell snapshot
|
|
69
|
+
|
|
70
|
+
The `selected` shape contains:
|
|
71
|
+
|
|
72
|
+
- legacy grid pixel extent in `canvas`;
|
|
73
|
+
- logical grid dimensions and cell metrics in `grid`;
|
|
74
|
+
- an informational source ID and complete cell rows in `layer`.
|
|
75
|
+
|
|
76
|
+
This shape is a cell snapshot, not a lossless layer document. It does not carry
|
|
77
|
+
visibility, opacity, blend mode, offsets, layer rotation, or font identity.
|
|
78
|
+
|
|
79
|
+
## Layer stack
|
|
80
|
+
|
|
81
|
+
The `all` shape contains one or more layers. Each layer includes:
|
|
82
|
+
|
|
83
|
+
- informational ID;
|
|
84
|
+
- visibility and opacity;
|
|
85
|
+
- blend mode name;
|
|
86
|
+
- x/y offsets and z rotation;
|
|
87
|
+
- logical grid and cell metrics;
|
|
88
|
+
- complete cell rows.
|
|
89
|
+
|
|
90
|
+
The order of `layers` is the stack order emitted by the producer.
|
|
91
|
+
|
|
92
|
+
## Canvas field
|
|
93
|
+
|
|
94
|
+
The v2 field named `canvas` is the grid pixel extent, not necessarily the HTML
|
|
95
|
+
canvas or final output surface. Its values obey:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
canvas.width = grid.cols × grid.cellWidth
|
|
99
|
+
canvas.height = grid.rows × grid.cellHeight
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For an `all` document, the root extent is derived from the first layer's grid.
|
|
103
|
+
Consumers must not infer composite placement or clipping from this field.
|
|
104
|
+
|
|
105
|
+
A future major format may replace this legacy name with `gridPixelSize`; v2
|
|
106
|
+
semantics must not be changed in place.
|
|
107
|
+
|
|
108
|
+
## Cell encoding
|
|
109
|
+
|
|
110
|
+
Version 2 defines one encoding:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"encoding": "object-rows-v1",
|
|
115
|
+
"rows": []
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The encoding is dense and row-major:
|
|
120
|
+
|
|
121
|
+
- `rows.length` equals `grid.rows`;
|
|
122
|
+
- every row length equals `grid.cols`;
|
|
123
|
+
- a cell's `x` equals its array index within the row;
|
|
124
|
+
- a cell's `y` equals the row index;
|
|
125
|
+
- every grid coordinate is present, including transparent cells.
|
|
126
|
+
|
|
127
|
+
Consumers reject coordinate disagreement rather than silently repairing or
|
|
128
|
+
reordering cells.
|
|
129
|
+
|
|
130
|
+
## Glyph identity
|
|
131
|
+
|
|
132
|
+
`character` contains a non-empty, bounded, well-formed Unicode glyph string.
|
|
133
|
+
Vector fonts commonly use one Unicode scalar, while tileset maps may use an
|
|
134
|
+
extended grapheme cluster containing combining marks, variation selectors, or
|
|
135
|
+
zero-width joiners. Unpaired surrogates are invalid. The default codec budget
|
|
136
|
+
is 64 Unicode scalar values per glyph string.
|
|
137
|
+
|
|
138
|
+
No Unicode normalization is implied. Consumers preserve the string exactly and
|
|
139
|
+
apply product-specific representability rules after protocol decoding.
|
|
140
|
+
|
|
141
|
+
## Colors
|
|
142
|
+
|
|
143
|
+
Foreground and background colors use either:
|
|
144
|
+
|
|
145
|
+
- `#RRGGBB`, whose alpha is implicitly 255;
|
|
146
|
+
- `#RRGGBBAA`;
|
|
147
|
+
- `{ "r": 0, "g": 0, "b": 0, "a": 255 }` with integer channels from
|
|
148
|
+
0 through 255.
|
|
149
|
+
|
|
150
|
+
The canonical decoder normalizes colors to RGBA channel objects.
|
|
151
|
+
|
|
152
|
+
A cell is visually empty only when both foreground and background alpha are
|
|
153
|
+
zero. A space with a visible background remains meaningful cell data.
|
|
154
|
+
|
|
155
|
+
## Transforms
|
|
156
|
+
|
|
157
|
+
Every cell contains:
|
|
158
|
+
|
|
159
|
+
- `invert`: boolean;
|
|
160
|
+
- `flipX`: boolean;
|
|
161
|
+
- `flipY`: boolean;
|
|
162
|
+
- `rotation`: finite degrees.
|
|
163
|
+
|
|
164
|
+
The canonical decoder normalizes rotation into `[0, 360)`. It therefore
|
|
165
|
+
normalizes both `360` and `-360` to `0` and `-90` to `270`.
|
|
166
|
+
|
|
167
|
+
Consumers must reject unsupported meaningful transforms instead of
|
|
168
|
+
approximating them. In particular, swapping foreground and background is not a
|
|
169
|
+
general replacement for inversion when alpha is present.
|
|
170
|
+
|
|
171
|
+
## Metadata
|
|
172
|
+
|
|
173
|
+
Metadata is optional and informational:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"createdAt": "2026-08-28T12:00:00.000Z",
|
|
178
|
+
"generator": {
|
|
179
|
+
"name": "textmode.export.js",
|
|
180
|
+
"version": "1.8.1"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`generator.name` identifies the producer and is not restricted to
|
|
186
|
+
`textmode.export.js`. If metadata is present, `createdAt` must be a real
|
|
187
|
+
calendar date and time in the uppercase, timezone-qualified RFC 3339 profile:
|
|
188
|
+
seconds are required, fractional seconds are optional, and leap seconds are
|
|
189
|
+
not supported in version 2. The decoder preserves valid timestamps as written.
|
|
190
|
+
|
|
191
|
+
Consumers must not use metadata to select executable behavior, fetch resources,
|
|
192
|
+
or bypass document validation.
|
|
193
|
+
|
|
194
|
+
## Safety limits
|
|
195
|
+
|
|
196
|
+
The shared codec enforces structural safety limits and accepts caller-supplied
|
|
197
|
+
budgets. Product-specific policy belongs to the product. For example,
|
|
198
|
+
`create.textmode.art` may accept fewer cells than another document consumer.
|
|
199
|
+
|
|
200
|
+
Consumers should:
|
|
201
|
+
|
|
202
|
+
- check file bytes before reading;
|
|
203
|
+
- cap total layers and total decoded cells;
|
|
204
|
+
- use checked multiplication for grid dimensions;
|
|
205
|
+
- bound identifiers and metadata strings;
|
|
206
|
+
- parse large files away from latency-sensitive UI work;
|
|
207
|
+
- abort work when the owning import session is cancelled.
|
|
208
|
+
|
|
209
|
+
Documents never authorize URL fetching, font installation, or code execution.
|
|
210
|
+
|
|
211
|
+
## Legacy migration
|
|
212
|
+
|
|
213
|
+
The compatibility decoder recognizes:
|
|
214
|
+
|
|
215
|
+
- `textmode.layer@1.0.0` as a selected cell snapshot;
|
|
216
|
+
- `textmode.layer@1.1.0` as a layer stack.
|
|
217
|
+
|
|
218
|
+
Both migrate to the canonical v2 union and return a migration warning. Callers
|
|
219
|
+
may disable legacy decoding.
|
|
220
|
+
|
|
221
|
+
## JSON Schema and runtime decoder
|
|
222
|
+
|
|
223
|
+
The JSON Schema describes the portable structure and is suitable for
|
|
224
|
+
documentation and general tooling. The runtime decoder remains authoritative
|
|
225
|
+
for:
|
|
226
|
+
|
|
227
|
+
- cross-field row and grid invariants;
|
|
228
|
+
- grid pixel extent equality;
|
|
229
|
+
- total resource budgets;
|
|
230
|
+
- well-formed and bounded glyph-string validation;
|
|
231
|
+
- rotation and color normalization;
|
|
232
|
+
- legacy migration;
|
|
233
|
+
- stable error codes and JSON paths.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "textmode.document",
|
|
3
|
+
"formatVersion": "2.0.0",
|
|
4
|
+
"target": "all",
|
|
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": "B",
|
|
32
|
+
"foreground": "#ffffffff",
|
|
33
|
+
"background": "#000000ff",
|
|
34
|
+
"transform": {
|
|
35
|
+
"invert": true,
|
|
36
|
+
"flipX": false,
|
|
37
|
+
"flipY": false,
|
|
38
|
+
"rotation": -90
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "accent",
|
|
47
|
+
"visible": false,
|
|
48
|
+
"opacity": 0.5,
|
|
49
|
+
"blendMode": "multiply",
|
|
50
|
+
"offsetX": -2,
|
|
51
|
+
"offsetY": 3,
|
|
52
|
+
"rotationZ": 15,
|
|
53
|
+
"grid": {
|
|
54
|
+
"cols": 2,
|
|
55
|
+
"rows": 1,
|
|
56
|
+
"cellWidth": 4,
|
|
57
|
+
"cellHeight": 8
|
|
58
|
+
},
|
|
59
|
+
"cells": {
|
|
60
|
+
"encoding": "object-rows-v1",
|
|
61
|
+
"rows": [
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
"x": 0,
|
|
65
|
+
"y": 0,
|
|
66
|
+
"character": "C",
|
|
67
|
+
"foreground": "#ff000080",
|
|
68
|
+
"background": "#00000000",
|
|
69
|
+
"transform": {
|
|
70
|
+
"invert": false,
|
|
71
|
+
"flipX": true,
|
|
72
|
+
"flipY": false,
|
|
73
|
+
"rotation": 45
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"x": 1,
|
|
78
|
+
"y": 0,
|
|
79
|
+
"character": " ",
|
|
80
|
+
"foreground": "#00000000",
|
|
81
|
+
"background": "#123456ff",
|
|
82
|
+
"transform": {
|
|
83
|
+
"invert": false,
|
|
84
|
+
"flipX": false,
|
|
85
|
+
"flipY": true,
|
|
86
|
+
"rotation": 0
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|