textmode.export.js 1.9.0-beta.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 (32) hide show
  1. package/README.md +4 -0
  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/LayerTarget.d.ts +0 -2
  13. package/dist/types/exporters/gif/types.d.ts +0 -4
  14. package/dist/types/exporters/image/types.d.ts +0 -2
  15. package/dist/types/exporters/json/types.d.ts +14 -204
  16. package/dist/types/exporters/svg/types.d.ts +1 -3
  17. package/dist/types/exporters/txt/types.d.ts +0 -2
  18. package/dist/types/exporters/video/types.d.ts +0 -20
  19. package/dist/types/exporters/zip/errors.d.ts +0 -1
  20. package/dist/types/exporters/zip/types.d.ts +0 -7
  21. package/dist/types/index.d.ts +3 -27
  22. package/dist/types/types.d.ts +0 -28
  23. package/package.json +46 -10
  24. package/protocol/textmode-document/2.0/SPECIFICATION.md +233 -0
  25. package/protocol/textmode-document/2.0/fixture.d.ts +3 -0
  26. package/protocol/textmode-document/2.0/fixtures/textmode-document-all-v2.json +94 -0
  27. package/protocol/textmode-document/2.0/fixtures/textmode-document-create-integration-v2.json +112 -0
  28. package/protocol/textmode-document/2.0/fixtures/textmode-document-selected-v2.json +86 -0
  29. package/protocol/textmode-document/2.0/fixtures/textmode-layer-all-v1.1.json +46 -0
  30. package/protocol/textmode-document/2.0/fixtures/textmode-layer-selected-v1.json +38 -0
  31. package/protocol/textmode-document/2.0/textmode-document-2.0.schema.d.ts +3 -0
  32. package/protocol/textmode-document/2.0/textmode-document-2.0.schema.json +171 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Canonical format discriminator for textmode document files.
3
+ *
4
+ * @see {@link https://code.textmode.art/api/textmode.export.js/variables/TEXTMODE_DOCUMENT_FORMAT | TEXTMODE_DOCUMENT_FORMAT API reference}
5
+ */
6
+ export declare const TEXTMODE_DOCUMENT_FORMAT: "textmode.document";
7
+ /**
8
+ * Current textmode document schema revision.
9
+ *
10
+ * @see {@link https://code.textmode.art/api/textmode.export.js/variables/TEXTMODE_DOCUMENT_FORMAT_VERSION | TEXTMODE_DOCUMENT_FORMAT_VERSION API reference}
11
+ */
12
+ export declare const TEXTMODE_DOCUMENT_FORMAT_VERSION: "2.0.0";
13
+ /** Legacy format discriminator accepted by the compatibility decoder. */
14
+ export declare const LEGACY_TEXTMODE_LAYER_FORMAT: "textmode.layer";
15
+ /** Legacy selected-layer schema revision. */
16
+ export declare const LEGACY_TEXTMODE_SELECTED_VERSION: "1.0.0";
17
+ /** Legacy layer-stack schema revision. */
18
+ export declare const LEGACY_TEXTMODE_ALL_VERSION: "1.1.0";
19
+ /**
20
+ * Canonical dense row encoding used by textmode document v2.
21
+ *
22
+ * @see {@link https://code.textmode.art/api/textmode.export.js/variables/TEXTMODE_OBJECT_ROWS_ENCODING | TEXTMODE_OBJECT_ROWS_ENCODING API reference}
23
+ */
24
+ export declare const TEXTMODE_OBJECT_ROWS_ENCODING: "object-rows-v1";
25
+ /** Default protocol safety limits. Product-specific limits belong to callers. */
26
+ export declare const DEFAULT_TEXTMODE_DOCUMENT_LIMITS: {
27
+ readonly maxCells: 16777216;
28
+ readonly maxLayers: 4096;
29
+ readonly maxLayerIdLength: 1024;
30
+ readonly maxCharacterLength: 64;
31
+ readonly maxMetadataStringLength: 4096;
32
+ };
@@ -0,0 +1,4 @@
1
+ import type { DecodeContext, UnknownRecord } from './validation';
2
+ import type { CanonicalTextmodeAllDocument, CanonicalTextmodeSelectedDocument } from './types';
3
+ export declare function decodeSelectedDocument(root: UnknownRecord, context: DecodeContext): CanonicalTextmodeSelectedDocument;
4
+ export declare function decodeAllDocument(root: UnknownRecord, context: DecodeContext): CanonicalTextmodeAllDocument;
@@ -0,0 +1,5 @@
1
+ import type { TextmodeDocumentDecodeOptions, TextmodeDocumentDecodeResult, TextmodeDocumentParseResult } from './types';
2
+ /** Decode a parsed JSON value into the canonical textmode document union. */
3
+ export declare function decodeTextmodeDocument(value: unknown, options?: TextmodeDocumentDecodeOptions): TextmodeDocumentDecodeResult;
4
+ /** Parse JSON syntax and decode its value in one convenience call. */
5
+ export declare function parseTextmodeDocumentJSON(json: string, options?: TextmodeDocumentDecodeOptions): TextmodeDocumentParseResult;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Dependency-free textmode document protocol codec.
3
+ *
4
+ * This entry point contains no DOM, renderer, textmode.js, or media encoder
5
+ * dependencies. It decodes every valid v2 document variant; product-specific
6
+ * import policy belongs to callers.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { DEFAULT_TEXTMODE_DOCUMENT_LIMITS, LEGACY_TEXTMODE_ALL_VERSION, LEGACY_TEXTMODE_LAYER_FORMAT, LEGACY_TEXTMODE_SELECTED_VERSION, TEXTMODE_DOCUMENT_FORMAT, TEXTMODE_DOCUMENT_FORMAT_VERSION, TEXTMODE_OBJECT_ROWS_ENCODING, } from './constants';
11
+ export { decodeTextmodeDocument, parseTextmodeDocumentJSON } from './decode';
12
+ export { parseJSON } from './parse';
13
+ export type { CanonicalTextmodeAllDocument, CanonicalTextmodeCell, CanonicalTextmodeCellCollection, CanonicalTextmodeDocument, CanonicalTextmodeDocumentLayer, CanonicalTextmodeSelectedDocument, JSONCellCollection, JSONCellTransform, JSONColorValue, JSONDocumentFormat, JSONDocumentVersion, JSONExportMetadata, JSONExportTarget, JSONLayerGrid, JSONObjectRowCell, JSONObjectRowsCellCollection, JSONParseResult, JSONRGBAColor, LegacyTextmodeAllDocumentJSON, LegacyTextmodeSelectedDocumentJSON, TextmodeAllDocumentJSON, TextmodeDocumentDecodeOptions, TextmodeDocumentDecodeResult, TextmodeDocumentCell, TextmodeDocumentCellCollection, TextmodeDocumentCellTransform, TextmodeDocumentColor, TextmodeDocumentError, TextmodeDocumentErrorCode, TextmodeDocumentFormat, TextmodeDocumentGrid, TextmodeDocumentJSON, TextmodeDocumentLayer, TextmodeDocumentLimits, TextmodeDocumentMetadata, TextmodeDocumentParseResult, TextmodeDocumentRGBAColor, TextmodeDocumentTarget, TextmodeDocumentVersion, TextmodeDocumentWarning, TextmodeSelectedDocumentJSON, TextmodeSelectedDocumentLayer, } from './types';
@@ -0,0 +1,3 @@
1
+ import type { JSONParseResult } from './types';
2
+ /** Parse JSON syntax once before routing the resulting value by discriminator. */
3
+ export declare function parseJSON(json: string): JSONParseResult;
@@ -0,0 +1,209 @@
1
+ import type { LEGACY_TEXTMODE_ALL_VERSION, LEGACY_TEXTMODE_LAYER_FORMAT, LEGACY_TEXTMODE_SELECTED_VERSION, TEXTMODE_DOCUMENT_FORMAT, TEXTMODE_DOCUMENT_FORMAT_VERSION, TEXTMODE_OBJECT_ROWS_ENCODING } from './constants';
2
+ /**
3
+ * Scope encoded by a textmode document.
4
+ *
5
+ * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/TextmodeDocumentTarget | TextmodeDocumentTarget API reference}
6
+ */
7
+ export type TextmodeDocumentTarget = 'selected' | 'all';
8
+ /** Format discriminator encoded in a document. */
9
+ export type TextmodeDocumentFormat = typeof TEXTMODE_DOCUMENT_FORMAT;
10
+ /** Current on-disk format version, independent of the npm package version. */
11
+ export type TextmodeDocumentVersion = typeof TEXTMODE_DOCUMENT_FORMAT_VERSION;
12
+ /** RGBA color channels, each an integer from 0 through 255. */
13
+ export interface TextmodeDocumentRGBAColor {
14
+ r: number;
15
+ g: number;
16
+ b: number;
17
+ a: number;
18
+ }
19
+ /** On-disk color notation; decoded colors use RGBA channels. */
20
+ export type TextmodeDocumentColor = string | TextmodeDocumentRGBAColor;
21
+ /** Per-cell transform in degrees. */
22
+ export interface TextmodeDocumentCellTransform {
23
+ invert: boolean;
24
+ flipX: boolean;
25
+ flipY: boolean;
26
+ rotation: number;
27
+ }
28
+ /** Cell at its redundant row-major x/y coordinates. */
29
+ export interface TextmodeDocumentCell {
30
+ x: number;
31
+ y: number;
32
+ character: string;
33
+ foreground: TextmodeDocumentColor;
34
+ background: TextmodeDocumentColor;
35
+ transform: TextmodeDocumentCellTransform;
36
+ }
37
+ /** Dense row-major cell collection. */
38
+ export interface TextmodeDocumentCellCollection {
39
+ encoding: typeof TEXTMODE_OBJECT_ROWS_ENCODING;
40
+ rows: TextmodeDocumentCell[][];
41
+ }
42
+ /** Logical grid dimensions and pixel extent of each cell. */
43
+ export interface TextmodeDocumentGrid {
44
+ cols: number;
45
+ rows: number;
46
+ cellWidth: number;
47
+ cellHeight: number;
48
+ }
49
+ /** Optional producer information; it does not control decoding behavior. */
50
+ export interface TextmodeDocumentMetadata {
51
+ createdAt: string;
52
+ generator: {
53
+ name: string;
54
+ version: string;
55
+ };
56
+ }
57
+ /**
58
+ * Scope selected by the JSON exporter.
59
+ *
60
+ * @deprecated Use TextmodeDocumentTarget.
61
+ * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONExportTarget | JSONExportTarget API reference}
62
+ */
63
+ export type JSONExportTarget = TextmodeDocumentTarget;
64
+ /** @deprecated Use TextmodeDocumentFormat. */
65
+ export type JSONDocumentFormat = TextmodeDocumentFormat;
66
+ /** @deprecated Use TextmodeDocumentVersion. */
67
+ export type JSONDocumentVersion = TextmodeDocumentVersion;
68
+ /** @deprecated Use TextmodeDocumentRGBAColor. */
69
+ export type JSONRGBAColor = TextmodeDocumentRGBAColor;
70
+ /** @deprecated Use TextmodeDocumentColor. */
71
+ export type JSONColorValue = TextmodeDocumentColor;
72
+ /** @deprecated Use TextmodeDocumentCellTransform. */
73
+ export type JSONCellTransform = TextmodeDocumentCellTransform;
74
+ /** @deprecated Use TextmodeDocumentCell. */
75
+ export type JSONObjectRowCell = TextmodeDocumentCell;
76
+ /** @deprecated Use TextmodeDocumentCellCollection. */
77
+ export type JSONObjectRowsCellCollection = TextmodeDocumentCellCollection;
78
+ /** @deprecated Use TextmodeDocumentCellCollection. */
79
+ export type JSONCellCollection = TextmodeDocumentCellCollection;
80
+ /** @deprecated Use TextmodeDocumentGrid. */
81
+ export type JSONLayerGrid = TextmodeDocumentGrid;
82
+ /** @deprecated Use TextmodeDocumentMetadata. */
83
+ export type JSONExportMetadata = TextmodeDocumentMetadata;
84
+ export interface TextmodeSelectedDocumentLayer {
85
+ id: string;
86
+ cells: JSONCellCollection;
87
+ }
88
+ export interface TextmodeSelectedDocumentJSON {
89
+ format: JSONDocumentFormat;
90
+ formatVersion: JSONDocumentVersion;
91
+ target: 'selected';
92
+ metadata?: JSONExportMetadata;
93
+ canvas: {
94
+ width: number;
95
+ height: number;
96
+ };
97
+ grid: JSONLayerGrid;
98
+ layer: TextmodeSelectedDocumentLayer;
99
+ }
100
+ export interface TextmodeDocumentLayer {
101
+ id: string;
102
+ visible: boolean;
103
+ opacity: number;
104
+ blendMode: string;
105
+ offsetX: number;
106
+ offsetY: number;
107
+ rotationZ: number;
108
+ grid: JSONLayerGrid;
109
+ cells: JSONCellCollection;
110
+ }
111
+ export interface TextmodeAllDocumentJSON {
112
+ format: JSONDocumentFormat;
113
+ formatVersion: JSONDocumentVersion;
114
+ target: 'all';
115
+ metadata?: JSONExportMetadata;
116
+ canvas: {
117
+ width: number;
118
+ height: number;
119
+ };
120
+ layers: TextmodeDocumentLayer[];
121
+ }
122
+ /**
123
+ * JSON document produced by the selected-layer or layer-stack exporter.
124
+ *
125
+ * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/TextmodeDocumentJSON | TextmodeDocumentJSON API reference}
126
+ */
127
+ export type TextmodeDocumentJSON = TextmodeSelectedDocumentJSON | TextmodeAllDocumentJSON;
128
+ export interface CanonicalTextmodeCell extends Omit<JSONObjectRowCell, 'foreground' | 'background' | 'transform'> {
129
+ foreground: JSONRGBAColor;
130
+ background: JSONRGBAColor;
131
+ transform: JSONCellTransform;
132
+ }
133
+ export interface CanonicalTextmodeCellCollection {
134
+ encoding: typeof TEXTMODE_OBJECT_ROWS_ENCODING;
135
+ rows: CanonicalTextmodeCell[][];
136
+ }
137
+ export interface CanonicalTextmodeSelectedDocument extends Omit<TextmodeSelectedDocumentJSON, 'layer'> {
138
+ layer: {
139
+ id: string;
140
+ cells: CanonicalTextmodeCellCollection;
141
+ };
142
+ }
143
+ export interface CanonicalTextmodeDocumentLayer extends Omit<TextmodeDocumentLayer, 'cells'> {
144
+ cells: CanonicalTextmodeCellCollection;
145
+ }
146
+ export interface CanonicalTextmodeAllDocument extends Omit<TextmodeAllDocumentJSON, 'layers'> {
147
+ layers: CanonicalTextmodeDocumentLayer[];
148
+ }
149
+ export type CanonicalTextmodeDocument = CanonicalTextmodeSelectedDocument | CanonicalTextmodeAllDocument;
150
+ export interface TextmodeDocumentLimits {
151
+ maxCells?: number;
152
+ maxLayers?: number;
153
+ maxLayerIdLength?: number;
154
+ maxCharacterLength?: number;
155
+ maxMetadataStringLength?: number;
156
+ }
157
+ export interface TextmodeDocumentDecodeOptions {
158
+ limits?: TextmodeDocumentLimits;
159
+ acceptLegacy?: boolean;
160
+ }
161
+ export type TextmodeDocumentErrorCode = 'INVALID_JSON' | 'INVALID_DOCUMENT' | 'UNSUPPORTED_FORMAT' | 'UNSUPPORTED_VERSION' | 'UNSUPPORTED_TARGET' | 'UNSUPPORTED_ENCODING' | 'LIMIT_EXCEEDED';
162
+ export interface TextmodeDocumentError {
163
+ code: TextmodeDocumentErrorCode;
164
+ message: string;
165
+ path?: string;
166
+ }
167
+ export interface TextmodeDocumentWarning {
168
+ code: 'LEGACY_DOCUMENT_MIGRATED';
169
+ message: string;
170
+ }
171
+ export type JSONParseResult = {
172
+ ok: true;
173
+ value: unknown;
174
+ } | {
175
+ ok: false;
176
+ error: TextmodeDocumentError;
177
+ };
178
+ export type TextmodeDocumentDecodeResult = {
179
+ ok: true;
180
+ document: CanonicalTextmodeDocument;
181
+ warnings: TextmodeDocumentWarning[];
182
+ } | {
183
+ ok: false;
184
+ error: TextmodeDocumentError;
185
+ };
186
+ export type TextmodeDocumentParseResult = TextmodeDocumentDecodeResult;
187
+ export interface LegacyTextmodeSelectedDocumentJSON {
188
+ $schema?: string;
189
+ format: typeof LEGACY_TEXTMODE_LAYER_FORMAT;
190
+ formatVersion: typeof LEGACY_TEXTMODE_SELECTED_VERSION;
191
+ metadata?: JSONExportMetadata;
192
+ canvas: {
193
+ width: number;
194
+ height: number;
195
+ };
196
+ grid: JSONLayerGrid;
197
+ layer: TextmodeSelectedDocumentLayer;
198
+ }
199
+ export interface LegacyTextmodeAllDocumentJSON {
200
+ $schema?: string;
201
+ format: typeof LEGACY_TEXTMODE_LAYER_FORMAT;
202
+ formatVersion: typeof LEGACY_TEXTMODE_ALL_VERSION;
203
+ metadata?: JSONExportMetadata;
204
+ canvas: {
205
+ width: number;
206
+ height: number;
207
+ };
208
+ layers: TextmodeDocumentLayer[];
209
+ }
@@ -0,0 +1,37 @@
1
+ import type { JSONExportMetadata, JSONLayerGrid, JSONRGBAColor, TextmodeDocumentDecodeResult, TextmodeDocumentError, TextmodeDocumentErrorCode, TextmodeDocumentLimits } from './types';
2
+ export type UnknownRecord = Record<string, unknown>;
3
+ export type ResolvedLimits = Required<TextmodeDocumentLimits>;
4
+ export type DecodeContext = {
5
+ limits: ResolvedLimits;
6
+ remainingCells: number;
7
+ };
8
+ export declare class DocumentDecodeFailure extends Error {
9
+ readonly detail: TextmodeDocumentError;
10
+ constructor(detail: TextmodeDocumentError);
11
+ }
12
+ export declare function decodeColor(value: unknown, path: string): JSONRGBAColor;
13
+ export declare function decodeCanvas(value: unknown, path: string): {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ export declare function decodeGrid(value: unknown, path: string): JSONLayerGrid;
18
+ export declare function decodeMetadata(value: unknown, path: string, limits: ResolvedLimits): JSONExportMetadata;
19
+ export declare function decodeLayerId(value: unknown, path: string, limits: ResolvedLimits): string;
20
+ export declare function assertCanvasMatchesGrid(canvas: {
21
+ width: number;
22
+ height: number;
23
+ }, grid: JSONLayerGrid, path: string): void;
24
+ export declare function resolveLimits(limits: TextmodeDocumentLimits | undefined): ResolvedLimits;
25
+ export declare function checkedProduct(left: number, right: number, path: string): number;
26
+ export declare function normalizeRotation(rotation: number): number;
27
+ export declare function requireRecord(value: unknown, path: string): UnknownRecord;
28
+ export declare function requireArray(value: unknown, path: string): unknown[];
29
+ export declare function requireString(value: unknown, path: string): string;
30
+ export declare function requireBoundedString(value: unknown, path: string, maxLength: number): string;
31
+ export declare function requireCharacter(value: unknown, path: string, limits: ResolvedLimits): string;
32
+ export declare function requireBoolean(value: unknown, path: string): boolean;
33
+ export declare function requireFiniteNumber(value: unknown, path: string): number;
34
+ export declare function requireNumberInRange(value: unknown, path: string, minimum: number, maximum: number): number;
35
+ export declare function requireSafeInteger(value: unknown, path: string): number;
36
+ export declare function failure(code: TextmodeDocumentErrorCode, message: string, path?: string): TextmodeDocumentDecodeResult;
37
+ export declare function fail(code: TextmodeDocumentErrorCode, message: string, path?: string): never;
@@ -4,8 +4,6 @@ import type { TextmodeLayer } from 'textmode.js';
4
4
  /**
5
5
  * Shared option for exporters that read layer framebuffer data.
6
6
  *
7
- * @category Layer data export
8
- *
9
7
  * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/LayerExportOptions | LayerExportOptions API reference}
10
8
  */
11
9
  export interface LayerExportOptions {
@@ -3,8 +3,6 @@ export type GIFRecordingState = 'idle' | 'recording' | 'encoding' | 'completed'
3
3
  /**
4
4
  * Progress information emitted while deterministic frames are captured and encoded as an animated GIF.
5
5
  *
6
- * @category GIF export
7
- *
8
6
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/GIFExportProgress | GIFExportProgress API reference}
9
7
  */
10
8
  export type GIFExportProgress = {
@@ -36,8 +34,6 @@ export type GIFExportProgress = {
36
34
  /**
37
35
  * Options for capturing deterministic textmode frames as an animated GIF.
38
36
  *
39
- * @category GIF export
40
- *
41
37
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/GIFExportOptions | GIFExportOptions API reference}
42
38
  */
43
39
  export type GIFExportOptions = {
@@ -8,8 +8,6 @@ export type ImageFormat = 'png' | 'jpg' | 'webp';
8
8
  /**
9
9
  * Options for exporting the textmode content to image format.
10
10
  *
11
- * @category Canvas capture
12
- *
13
11
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/ImageExportOptions | ImageExportOptions API reference}
14
12
  */
15
13
  export type ImageExportOptions = {
@@ -1,225 +1,37 @@
1
1
  import type { LayerExportOptions } from '../base';
2
+ import type { JSONCellTransform, JSONExportTarget, JSONRGBAColor } from '../../document';
2
3
  /**
3
- * Target scope for JSON export.
4
- *
5
- * @category JSON document data
6
- *
7
- * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONExportTarget | JSONExportTarget API reference}
8
- */
9
- export type JSONExportTarget = 'selected' | 'all';
10
- /**
11
- * Canonical JSON document format identifier.
12
- *
13
- * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONDocumentFormat | JSONDocumentFormat API reference}
14
- */
15
- export type JSONDocumentFormat = 'textmode.document';
16
- /**
17
- * Canonical JSON document format version.
18
- *
19
- * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONDocumentVersion | JSONDocumentVersion API reference}
20
- */
21
- export type JSONDocumentVersion = '2.0.0';
22
- /**
23
- * Supported JSON color output modes.
24
- *
25
- * @category JSON document data
4
+ * Color representation written by the JSON exporter: hexadecimal strings or
5
+ * RGBA channel objects.
26
6
  *
27
7
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONExportColorMode | JSONExportColorMode API reference}
28
8
  */
29
9
  export type JSONExportColorMode = 'hex' | 'rgba';
10
+ export type { JSONCellCollection, JSONCellTransform, JSONColorValue, JSONDocumentFormat, JSONDocumentVersion, JSONExportMetadata, JSONExportTarget, JSONLayerGrid, JSONObjectRowCell, JSONObjectRowsCellCollection, JSONRGBAColor, TextmodeAllDocumentJSON, TextmodeDocumentJSON, TextmodeDocumentLayer, TextmodeSelectedDocumentJSON, TextmodeSelectedDocumentLayer, } from '../../document';
30
11
  /**
31
- * RGBA color representation used in JSON exports.
32
- *
33
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/JSONRGBAColor | JSONRGBAColor API reference}
34
- */
35
- export interface JSONRGBAColor {
36
- r: number;
37
- g: number;
38
- b: number;
39
- a: number;
40
- }
41
- /**
42
- * Color value used in the exported JSON document.
43
- *
44
- * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONColorValue | JSONColorValue API reference}
45
- */
46
- export type JSONColorValue = string | JSONRGBAColor;
47
- /**
48
- * Cell transform data for JSON exports.
49
- *
50
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/JSONCellTransform | JSONCellTransform API reference}
51
- */
52
- export interface JSONCellTransform {
53
- invert: boolean;
54
- flipX: boolean;
55
- flipY: boolean;
56
- rotation: number;
57
- }
58
- /**
59
- * Rich per-cell representation for readable JSON exports.
60
- *
61
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/JSONObjectRowCell | JSONObjectRowCell API reference}
62
- */
63
- export interface JSONObjectRowCell {
64
- x: number;
65
- y: number;
66
- character: string;
67
- foreground: JSONColorValue;
68
- background: JSONColorValue;
69
- transform: JSONCellTransform;
70
- }
71
- /**
72
- * Row-based cell encoding.
73
- *
74
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/JSONObjectRowsCellCollection | JSONObjectRowsCellCollection API reference}
75
- */
76
- export interface JSONObjectRowsCellCollection {
77
- encoding: 'object-rows-v1';
78
- rows: JSONObjectRowCell[][];
79
- }
80
- /**
81
- * Supported JSON cell collection variants.
82
- *
83
- * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONCellCollection | JSONCellCollection API reference}
84
- */
85
- export type JSONCellCollection = JSONObjectRowsCellCollection;
86
- /**
87
- * Grid dimensions exported for a layer.
88
- *
89
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/JSONLayerGrid | JSONLayerGrid API reference}
90
- */
91
- export interface JSONLayerGrid {
92
- cols: number;
93
- rows: number;
94
- cellWidth: number;
95
- cellHeight: number;
96
- }
97
- /**
98
- * Optional export metadata.
99
- *
100
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/JSONExportMetadata | JSONExportMetadata API reference}
101
- */
102
- export interface JSONExportMetadata {
103
- createdAt: string;
104
- generator: {
105
- name: 'textmode.export.js';
106
- version: string;
107
- };
108
- }
109
- /**
110
- * Selected-layer entry in a JSON document export.
111
- *
112
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeSelectedDocumentLayer | TextmodeSelectedDocumentLayer API reference}
113
- */
114
- export interface TextmodeSelectedDocumentLayer {
115
- id: string;
116
- cells: JSONCellCollection;
117
- }
118
- /**
119
- * Selected-layer document exported by the JSON exporter.
120
- *
121
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeSelectedDocumentJSON | TextmodeSelectedDocumentJSON API reference}
122
- */
123
- export interface TextmodeSelectedDocumentJSON {
124
- format: JSONDocumentFormat;
125
- formatVersion: JSONDocumentVersion;
126
- target: 'selected';
127
- metadata?: JSONExportMetadata;
128
- canvas: {
129
- width: number;
130
- height: number;
131
- };
132
- grid: JSONLayerGrid;
133
- layer: TextmodeSelectedDocumentLayer;
134
- }
135
- /**
136
- * Single layer entry in an all-layers JSON export.
137
- *
138
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeDocumentLayer | TextmodeDocumentLayer API reference}
139
- */
140
- export interface TextmodeDocumentLayer {
141
- id: string;
142
- visible: boolean;
143
- opacity: number;
144
- blendMode: string;
145
- offsetX: number;
146
- offsetY: number;
147
- rotationZ: number;
148
- grid: JSONLayerGrid;
149
- cells: JSONCellCollection;
150
- }
151
- /**
152
- * Layer stack document exported by the JSON exporter.
153
- *
154
- * @see {@link https://code.textmode.art/api/textmode.export.js/interfaces/TextmodeAllDocumentJSON | TextmodeAllDocumentJSON API reference}
155
- */
156
- export interface TextmodeAllDocumentJSON {
157
- format: JSONDocumentFormat;
158
- formatVersion: JSONDocumentVersion;
159
- target: 'all';
160
- metadata?: JSONExportMetadata;
161
- canvas: {
162
- width: number;
163
- height: number;
164
- };
165
- layers: TextmodeDocumentLayer[];
166
- }
167
- /**
168
- * JSON document exported by the JSON exporter.
169
- *
170
- * @category JSON document data
171
- *
172
- * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/TextmodeDocumentJSON | TextmodeDocumentJSON API reference}
173
- */
174
- export type TextmodeDocumentJSON = TextmodeSelectedDocumentJSON | TextmodeAllDocumentJSON;
175
- /**
176
- * Options for exporting the textmode content to JSON format.
177
- *
178
- * @category JSON document data
12
+ * Options for exporting textmode content to JSON.
179
13
  *
180
14
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/JSONExportOptions | JSONExportOptions API reference}
181
15
  */
182
16
  export type JSONExportOptions = LayerExportOptions & {
183
17
  /**
184
- * Scope of the JSON export.
185
- *
186
- * Use `'selected'` to export one layer, or `'all'` to export the base layer and every user-created layer.
187
- *
188
- * Defaults to `'selected'`.
18
+ * Export one selected layer or the complete layer stack.
19
+ * Defaults to `selected`.
189
20
  */
190
21
  target?: JSONExportTarget;
191
- /**
192
- * The filename to save the JSON file as.
193
- *
194
- * If not provided, a default filename is used.
195
- */
22
+ /** Filename used by the download helper. A default name is used when omitted. */
196
23
  filename?: string;
197
24
  /**
198
- * Pretty-print the generated JSON.
199
- *
200
- * When set to `true`, output uses two-space indentation.
201
- * When set to a number, that value is used as indentation width.
202
- * When `false`, the output is minified.
203
- *
204
- * Defaults to `true`.
25
+ * Pretty-print with two spaces when `true`, use the given indentation width
26
+ * when numeric, or produce compact JSON when `false`. Defaults to `true`.
205
27
  */
206
28
  pretty?: boolean | number;
207
- /**
208
- * Color representation used for foreground and background values.
209
- *
210
- * Defaults to `'hex'`.
211
- */
29
+ /** Foreground and background color representation. Defaults to `hex`. */
212
30
  colorMode?: JSONExportColorMode;
213
- /**
214
- * Whether to include export metadata such as timestamp and generator details.
215
- *
216
- * Defaults to `true`.
217
- */
31
+ /** Include the creation timestamp and generator metadata. Defaults to `true`. */
218
32
  includeMetadata?: boolean;
219
33
  };
220
- /**
221
- * Internal options used by JSON generation (with all defaults applied).
222
- */
34
+ /** Internal JSON generation options after defaults have been applied. */
223
35
  export interface JSONGenerationOptions {
224
36
  target: JSONExportTarget;
225
37
  pretty: boolean | number;
@@ -228,9 +40,7 @@ export interface JSONGenerationOptions {
228
40
  filename?: string;
229
41
  layer?: LayerExportOptions['layer'];
230
42
  }
231
- /**
232
- * Internal extracted cell data used while building the JSON document.
233
- */
43
+ /** Internal framebuffer cell data used while building a document. */
234
44
  export interface JSONCellData {
235
45
  x: number;
236
46
  y: number;
@@ -1,4 +1,4 @@
1
- import type { LayerExportOptions } from '../base';
1
+ import type { LayerExportOptions } from '../base/LayerTarget';
2
2
  /**
3
3
  * RGBA color representation.
4
4
  */
@@ -54,8 +54,6 @@ export interface FramebufferData {
54
54
  /**
55
55
  * Options for exporting the textmode content to SVG format.
56
56
  *
57
- * @category Layer data export
58
- *
59
57
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/SVGExportOptions | SVGExportOptions API reference}
60
58
  */
61
59
  export type SVGExportOptions = LayerExportOptions & {
@@ -2,8 +2,6 @@ import type { LayerExportOptions } from '../base';
2
2
  /**
3
3
  * Options for exporting the textmode content to TXT format.
4
4
  *
5
- * @category Layer data export
6
- *
7
5
  * @see {@link https://code.textmode.art/api/textmode.export.js/type-aliases/TXTExportOptions | TXTExportOptions API reference}
8
6
  */
9
7
  export type TXTExportOptions = LayerExportOptions & {