@hussmartinez/image-sdk 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +65 -2
- package/dist/assets/image/render.worker.js +1 -0
- package/dist/element.d.ts +1127 -0
- package/dist/element.js +129 -0
- package/dist/element.js.map +1 -0
- package/dist/index.d.ts +1704 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/lazy/inline-worker-BVCwAPZU.js +30 -0
- package/dist/lazy/inline-worker-BVCwAPZU.js.map +1 -0
- package/dist/react.d.ts +1452 -0
- package/dist/react.js +2 -0
- package/dist/shared/core-cKo2m54U.js +1420 -0
- package/dist/shared/core-cKo2m54U.js.map +1 -0
- package/dist/shared/editor-Dv5EU2YJ.js +1617 -0
- package/dist/shared/editor-Dv5EU2YJ.js.map +1 -0
- package/dist/styles.css +312 -0
- package/formats/hm-image-command/v1.schema.json +102 -0
- package/formats/hm-image-plan/v1.schema.json +328 -0
- package/package.json +116 -3
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,1452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React editor of the image SDK: `ImageEditor`, its building blocks and hooks.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* A client entry: it starts with `"use client"`, which the build keeps
|
|
6
|
+
* (ADR 0007). React and React DOM 18.3 or later are optional peer
|
|
7
|
+
* dependencies. Hosts import `@hussmartinez/ui/styles.css` once, then this
|
|
8
|
+
* package's `styles.css` (sdk-core ADR 0036).
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { FilePolicy } from '@hussmartinez/sdk-core';
|
|
14
|
+
import { FilePolicyOverrides } from '@hussmartinez/sdk-core';
|
|
15
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
16
|
+
import { IconComponent } from '@hussmartinez/ui/react';
|
|
17
|
+
import { MessageOverrides } from '@hussmartinez/sdk-core';
|
|
18
|
+
import type { Messages } from '@hussmartinez/sdk-core';
|
|
19
|
+
import { ReactNode } from 'react';
|
|
20
|
+
import { RefAttributes } from 'react';
|
|
21
|
+
import { SdkCoreErrorCode } from '@hussmartinez/sdk-core';
|
|
22
|
+
import { SdkError } from '@hussmartinez/sdk-core';
|
|
23
|
+
import type { ShortcutRegistry } from '@hussmartinez/sdk-core';
|
|
24
|
+
import type { Store } from '@hussmartinez/sdk-core';
|
|
25
|
+
import type { Tool } from '@hussmartinez/sdk-core';
|
|
26
|
+
import type { ToolRegistry } from '@hussmartinez/sdk-core';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An EXIF orientation, 1 to 8: how the stored pixels must be turned to be
|
|
30
|
+
* upright. 1 means they already are (ADR 0005).
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
declare type ExifOrientation = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The filter presets (ADR 0006). Names are part of the document format:
|
|
38
|
+
* presets are only ever added.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
declare const FILTER_PRESETS: readonly ["vivid", "warm", "cool", "fade", "mono", "noir", "sepia"];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The Adjust panel (docs/adr/0006, docs/adr/0007): a slider per develop
|
|
46
|
+
* adjustment, in the order they're applied, from −100 to 100. A slider's
|
|
47
|
+
* gesture previews on the stage and is one undo step when it ends; each
|
|
48
|
+
* slider resets to 0 with its button, or by double-clicking it, and "Reset
|
|
49
|
+
* all" resets every one in one step.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare function ImageAdjustPanel(props: ImageAdjustPanelProps): ReactNode;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Props of {@link ImageAdjustPanel}.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare interface ImageAdjustPanelProps {
|
|
61
|
+
readonly className?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The crop frame's geometry (docs/adr/0007): pure functions over crops in
|
|
66
|
+
* whole pixels of the oriented source, which the editor's frame, keys and
|
|
67
|
+
* fields share, so every way of cropping gives the same result.
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* An aspect ratio the crop panel offers: free, the source's own, or width
|
|
71
|
+
* over height.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
declare type ImageAspect = "free" | "original" | readonly [number, number];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The image being edited: a source, its crop and orientation, and its
|
|
79
|
+
* develop adjustments and filter.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
declare interface ImageBase {
|
|
84
|
+
/** The id of a registered source. */
|
|
85
|
+
readonly source: string;
|
|
86
|
+
/** The crop, or `null` for the whole image. */
|
|
87
|
+
readonly crop: ImageCrop | null;
|
|
88
|
+
readonly orientation: ImageOrientation_2;
|
|
89
|
+
readonly develop: ImageDevelop;
|
|
90
|
+
/** The filter, or `null` for none. */
|
|
91
|
+
readonly filter: ImageFilter | null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Options every port call accepts.
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
declare interface ImageCallOptions {
|
|
100
|
+
/**
|
|
101
|
+
* Cancels the call. It then rejects with an `ImageError` whose code is
|
|
102
|
+
* `ABORTED`, `TIMEOUT`, or the code of an `SdkError` given as the abort
|
|
103
|
+
* reason, such as `PROCESSING_TIME_EXCEEDED`.
|
|
104
|
+
*/
|
|
105
|
+
readonly signal?: AbortSignal;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Every edit to an {@link ImagePlan}: plain, structured-cloneable data
|
|
110
|
+
* (ADR 0003). Feature pull requests add their own commands to this union.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
declare type ImageCommand = SetCropCommand | SetOrientationCommand | SetOutputCommand | SetMetadataCommand | SetDevelopCommand | SetFilterCommand;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A rectangle in whole pixels of the oriented source: `x` and `y` from its
|
|
118
|
+
* top left, `width` and `height` at least 1 (ADR 0003).
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
declare interface ImageCrop {
|
|
123
|
+
readonly x: number;
|
|
124
|
+
readonly y: number;
|
|
125
|
+
readonly width: number;
|
|
126
|
+
readonly height: number;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The crop panel (docs/adr/0007): the crop's position and size in source
|
|
131
|
+
* pixels as number fields, the aspect presets, and Apply, Cancel and Whole
|
|
132
|
+
* image. It's the alternative to dragging the frame (WCAG 2.5.7), shown while
|
|
133
|
+
* cropping.
|
|
134
|
+
*
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export declare function ImageCropPanel(props: ImageCropPanelProps): ReactNode;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Props of {@link ImageCropPanel}.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare interface ImageCropPanelProps {
|
|
145
|
+
readonly className?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The base's tonal and colour adjustments (ADR 0006). Each is an integer
|
|
150
|
+
* from -100 to 100, where 0 is unchanged, applied in this order.
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
declare interface ImageDevelop {
|
|
155
|
+
/** Warmer (positive) or cooler (negative). */
|
|
156
|
+
readonly temperature: number;
|
|
157
|
+
/** Toward magenta (positive) or green (negative). */
|
|
158
|
+
readonly tint: number;
|
|
159
|
+
/** In fiftieths of a stop: 100 is two stops brighter. */
|
|
160
|
+
readonly exposure: number;
|
|
161
|
+
readonly highlights: number;
|
|
162
|
+
readonly shadows: number;
|
|
163
|
+
readonly contrast: number;
|
|
164
|
+
readonly saturation: number;
|
|
165
|
+
/** Saturation weighted toward the least saturated colours. */
|
|
166
|
+
readonly vibrance: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The image editor (docs/adr/0007): a toolbar and a stage over an image
|
|
171
|
+
* session, with the family's shortcuts while focus is inside it. It creates
|
|
172
|
+
* its engine, processor and session unless you pass them, and destroys only
|
|
173
|
+
* what it created. Import `@hussmartinez/ui/styles.css` once, then this
|
|
174
|
+
* package's `styles.css`: ui's stylesheet carries the focus rings and target
|
|
175
|
+
* sizes the editor's accessibility relies on (sdk-core ADR 0036).
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* <ImageEditor initialFile={file} onChange={(plan) => save(plan)} />
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
export declare const ImageEditor: ForwardRefExoticComponent<ImageEditorProps & RefAttributes<ImageEditorHandle>>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* What a ref to {@link ImageEditor} gives the host.
|
|
188
|
+
*
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
191
|
+
export declare interface ImageEditorHandle {
|
|
192
|
+
/** The editor's session, for state and commands beyond the handle's. */
|
|
193
|
+
readonly session: ImageSession;
|
|
194
|
+
/** Opens an image, replacing the current one once it has opened. */
|
|
195
|
+
open(file: Blob): Promise<void>;
|
|
196
|
+
/** Applies commands as one undoable step. */
|
|
197
|
+
execute(commands: ImageCommand | readonly ImageCommand[]): void;
|
|
198
|
+
/** Renders and encodes the image as it is now. */
|
|
199
|
+
export(format: ImageExportFormat): Promise<ImageSessionExport>;
|
|
200
|
+
/** Undoes the last edit, if there is one. */
|
|
201
|
+
undo(): void;
|
|
202
|
+
/** Redoes the last undone edit, if there is one. */
|
|
203
|
+
redo(): void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The parts of `ImageEditor` that take extra classes through `classNames`.
|
|
208
|
+
*
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
export declare type ImageEditorPart = "root" | "toolbar" | "stage" | "inspector";
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Props of {@link ImageEditor}. The session props are the provider's: pass
|
|
215
|
+
* a `session` of your own over your `engine`, or let the editor create one.
|
|
216
|
+
*
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
export declare interface ImageEditorProps extends Omit<ImageEditorProviderProps, "children"> {
|
|
220
|
+
/** An image to open on mount. Images the user opens in the editor replace it. */
|
|
221
|
+
readonly initialFile?: Blob;
|
|
222
|
+
/**
|
|
223
|
+
* The plan, for a host that holds it: the controlled form. When it changes,
|
|
224
|
+
* the editor applies it as one undoable step (`session.applyPlan`). Use it
|
|
225
|
+
* with `onChange`, which gets the plans the editor makes.
|
|
226
|
+
*/
|
|
227
|
+
readonly plan?: ImagePlan;
|
|
228
|
+
/** Called with the plan after each committed edit, open, undo or redo, never during a gesture. */
|
|
229
|
+
readonly onChange?: (plan: ImagePlan) => void;
|
|
230
|
+
/** Which tools are present, by id, in order. All of them by default. */
|
|
231
|
+
readonly tools?: readonly string[];
|
|
232
|
+
/** The toolbar's groups, as tool ids. */
|
|
233
|
+
readonly toolbar?: readonly (readonly string[])[];
|
|
234
|
+
/** Icon components by name, over ui's. */
|
|
235
|
+
readonly icons?: Readonly<Record<string, IconComponent>>;
|
|
236
|
+
/** Extra classes on the root. */
|
|
237
|
+
readonly className?: string;
|
|
238
|
+
/** Extra classes on each part. */
|
|
239
|
+
readonly classNames?: Readonly<Partial<Record<ImageEditorPart, string>>>;
|
|
240
|
+
/** Drop the visual styles, keeping layout and accessibility. */
|
|
241
|
+
readonly unstyled?: boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Takes the exported file instead of the export dialog's download button;
|
|
244
|
+
* the dialog closes once it's called.
|
|
245
|
+
*/
|
|
246
|
+
readonly onExport?: (blob: Blob, details: ImageSessionExport) => void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Provides an image session, its engine, the stage's view and the SDK's
|
|
251
|
+
* text to the components below it: `ImageStage`, `ImageToolbar` and the
|
|
252
|
+
* hooks (docs/adr/0007). `ImageEditor` renders one itself.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* <ImageEditorProvider locale="de" messages={{ "editor.empty": "Öffnen Sie ein Bild." }}>
|
|
257
|
+
* <ImageToolbar />
|
|
258
|
+
* <ImageStage />
|
|
259
|
+
* </ImageEditorProvider>
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
export declare function ImageEditorProvider(props: ImageEditorProviderProps): ReactNode;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Props of {@link ImageEditorProvider}.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export declare interface ImageEditorProviderProps {
|
|
272
|
+
/**
|
|
273
|
+
* The engine that probes, decodes and holds images, and draws the stage.
|
|
274
|
+
* Defaults to the SDK's own, created with `assetsUrl`. A session of your own
|
|
275
|
+
* must use this engine.
|
|
276
|
+
*/
|
|
277
|
+
readonly engine?: ImageEngine;
|
|
278
|
+
/** The processor for exports. Defaults to the SDK's own, on the engine. */
|
|
279
|
+
readonly processor?: ImageProcessor;
|
|
280
|
+
/** A session of your own, over `engine`, instead of one the provider creates. */
|
|
281
|
+
readonly session?: ImageSession;
|
|
282
|
+
/**
|
|
283
|
+
* Where the application serves the package's `dist/assets/` directory, for
|
|
284
|
+
* the engine the provider creates (docs/adr/0002).
|
|
285
|
+
*/
|
|
286
|
+
readonly assetsUrl?: string | URL;
|
|
287
|
+
/** File limits for a session the provider creates (docs/adr/0004). */
|
|
288
|
+
readonly filePolicy?: ImageFilePolicyOverrides;
|
|
289
|
+
/** Anonymous usage events from a session the provider creates. */
|
|
290
|
+
readonly onEvent?: (event: ImageSessionEvent) => void;
|
|
291
|
+
/** Text overrides, typed against the English catalogue (ADR 0019). */
|
|
292
|
+
readonly messages?: MessageOverrides<ImageMessageCatalogue>;
|
|
293
|
+
/** The locale for numbers and plurals. Defaults to `"en"`. */
|
|
294
|
+
readonly locale?: string;
|
|
295
|
+
/** The components that use the session, such as `ImageStage`. */
|
|
296
|
+
readonly children?: ReactNode;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* The editor's own state, outside the session and its history
|
|
301
|
+
* (docs/adr/0007): the active tool, a crop in progress, and a gesture's
|
|
302
|
+
* transient plan, which the stage renders instead of the session's.
|
|
303
|
+
*
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
export declare interface ImageEditorState {
|
|
307
|
+
/** The tool that takes over the stage, such as `crop`, or `null`. */
|
|
308
|
+
readonly tool: "crop" | null;
|
|
309
|
+
/** The crop being made, in whole pixels of the oriented source, and its aspect. */
|
|
310
|
+
readonly crop: {
|
|
311
|
+
readonly pending: ImageCrop;
|
|
312
|
+
readonly aspect: ImageAspect;
|
|
313
|
+
} | null;
|
|
314
|
+
/**
|
|
315
|
+
* A gesture's plan while it runs: the session's plan with the gesture's
|
|
316
|
+
* change, which isn't an edit until the gesture ends.
|
|
317
|
+
*/
|
|
318
|
+
readonly preview: ImagePlan | null;
|
|
319
|
+
/** The dialog the editor shows over the stage, such as `export`, or `null`. */
|
|
320
|
+
readonly dialog: "export" | null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The port for reading images: probe a file's headers, decode it into a
|
|
325
|
+
* source the engine holds, make thumbnails and release sources (ADR 0001,
|
|
326
|
+
* ADR 0002, ADR 0003, ADR 0008). The SDK's own adapter probes with its own
|
|
327
|
+
* readers and decodes with `createImageBitmap`, both in its render worker;
|
|
328
|
+
* hosts can pass their own to the editor's `engine` prop, and every
|
|
329
|
+
* implementation must pass the engine's contract tests.
|
|
330
|
+
*
|
|
331
|
+
* `register` checks a file's own limits, from `filePolicy`, against the
|
|
332
|
+
* engine's own probe before decoding it, so a host can't decode past them by
|
|
333
|
+
* passing a probe of another file. Session-wide limits, such as
|
|
334
|
+
* `maxSessionSize`, are the session's (ADR 0004).
|
|
335
|
+
*
|
|
336
|
+
* Failures reject with `ImageError`: `INVALID_IMAGE` for a malformed file,
|
|
337
|
+
* one whose headers claim more than its data holds, or one whose decoded
|
|
338
|
+
* size differs from the probe's; `UNSUPPORTED_FORMAT` for one the probe
|
|
339
|
+
* can't bound; `DECODE_FAILED` when the browser can't decode it; and
|
|
340
|
+
* sdk-core's codes for cancellation and worker failures.
|
|
341
|
+
*
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
344
|
+
declare interface ImageEngine {
|
|
345
|
+
/** Reads a file's headers and metadata, without decoding it. */
|
|
346
|
+
probe(file: Blob, options?: ImageCallOptions): Promise<ImageProbe>;
|
|
347
|
+
/**
|
|
348
|
+
* Decodes a probed file into a source with the given id, upright. The
|
|
349
|
+
* decoded size must equal the probe's oriented size, or the call rejects
|
|
350
|
+
* with `INVALID_IMAGE` and keeps nothing. A file over one of
|
|
351
|
+
* `filePolicy`'s per-file limits rejects with that limit's code, before
|
|
352
|
+
* anything decodes it. An id already in use is a
|
|
353
|
+
* `TypeError`.
|
|
354
|
+
*/
|
|
355
|
+
register(id: string, file: Blob, probe: ImageProbe, options?: ImageRegisterOptions): Promise<ImageSourceInfo>;
|
|
356
|
+
/**
|
|
357
|
+
* A rendering of a source that fits inside `maxSize` × `maxSize`, keeping
|
|
358
|
+
* its aspect ratio and never enlarging it. An unknown id is a `TypeError`.
|
|
359
|
+
*/
|
|
360
|
+
thumbnail(id: string, maxSize: number, options?: ImageCallOptions): Promise<ImageThumbnail>;
|
|
361
|
+
/** Frees a source's pixels. Releasing an unknown id does nothing. */
|
|
362
|
+
release(id: string): Promise<void>;
|
|
363
|
+
/** Releases the engine, its sources and its worker. Pending calls reject, and later calls throw. */
|
|
364
|
+
destroy(): Promise<void>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The error `@hussmartinez/image-sdk` throws and rejects with, with a stable
|
|
369
|
+
* `code`, structured `details` and the underlying error as `cause`. Show
|
|
370
|
+
* users the text for its code from {@link imageMessages}, never its
|
|
371
|
+
* `message`, which is for developers and may contain text from the file.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```ts
|
|
375
|
+
* try {
|
|
376
|
+
* await session.open(file);
|
|
377
|
+
* } catch (error) {
|
|
378
|
+
* if (isImageError(error, "DECODE_FAILED")) {
|
|
379
|
+
* suggestConvertingToPng();
|
|
380
|
+
* } else {
|
|
381
|
+
* show(messages.error(error));
|
|
382
|
+
* }
|
|
383
|
+
* }
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @public
|
|
387
|
+
*/
|
|
388
|
+
declare class ImageError extends SdkError<ImageErrorCode> {
|
|
389
|
+
/** Always `"ImageError"`, which survives minification and worker boundaries. */
|
|
390
|
+
readonly name = "ImageError";
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Error codes of `@hussmartinez/image-sdk`: sdk-core's own codes, such as
|
|
395
|
+
* `ABORTED`, `WORKER_CRASHED` and `FILE_TOO_LARGE`, plus the image SDK's
|
|
396
|
+
* (ADR 0001, ADR 0004). They never change meaning once released.
|
|
397
|
+
*
|
|
398
|
+
* - `INVALID_IMAGE`: the file is malformed, its headers claim more than its
|
|
399
|
+
* data can carry or less than its decoder would produce, or its decoded
|
|
400
|
+
* size differs from what its headers declare.
|
|
401
|
+
* - `UNSUPPORTED_FORMAT`: the format isn't recognised, its bound can't be
|
|
402
|
+
* read, or the browser can't encode the requested export format.
|
|
403
|
+
* `details.format` names it.
|
|
404
|
+
* - `DECODE_FAILED`: the browser couldn't decode a file the SDK probed,
|
|
405
|
+
* usually because it lacks the format. `details.format` names it.
|
|
406
|
+
* - `INVALID_COMMAND`: an edit command doesn't apply to the plan, such as a
|
|
407
|
+
* crop outside its source. `details.reason` says why, as a stable token
|
|
408
|
+
* (`ImageCommandRejection`).
|
|
409
|
+
* - `INVALID_DOCUMENT`: a plan document, such as a saved project, isn't
|
|
410
|
+
* valid in its format. `details.reason` says why (`ImageDocumentRejection`).
|
|
411
|
+
* A document of another format, or a later version, is `UNSUPPORTED_FORMAT`
|
|
412
|
+
* instead, with `details.reason` `unknown-format` or `unknown-format-version`.
|
|
413
|
+
* - `IMAGE_TOO_LARGE`: an image, a frame, the canvas or the export exceeds
|
|
414
|
+
* the `maxImagePixels` limit.
|
|
415
|
+
* - `IMAGE_DIMENSION_TOO_LARGE`: a width or height exceeds the
|
|
416
|
+
* `maxImageDimension` limit.
|
|
417
|
+
* - `TOO_MANY_FRAMES`: an animation exceeds the `maxFrames` limit.
|
|
418
|
+
* - `SESSION_TOO_LARGE`: the decoded images the session holds exceed the
|
|
419
|
+
* `maxSessionSize` limit.
|
|
420
|
+
* - `TOO_MANY_LAYERS`: the layer plan exceeds the `maxLayers` limit.
|
|
421
|
+
*
|
|
422
|
+
* Limit codes carry `details` with the `limit`, its `maximum`, the `actual`
|
|
423
|
+
* value and the `unit`. Other codes' `details` name the format involved,
|
|
424
|
+
* and a `reason`, never data from the file.
|
|
425
|
+
*
|
|
426
|
+
* @public
|
|
427
|
+
*/
|
|
428
|
+
declare type ImageErrorCode = SdkCoreErrorCode | "INVALID_IMAGE" | "UNSUPPORTED_FORMAT" | "DECODE_FAILED" | "INVALID_COMMAND" | "INVALID_DOCUMENT" | "IMAGE_TOO_LARGE" | "IMAGE_DIMENSION_TOO_LARGE" | "TOO_MANY_FRAMES" | "SESSION_TOO_LARGE" | "TOO_MANY_LAYERS";
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* The export dialog (docs/adr/0007). Export is irreversible, so it shows a
|
|
432
|
+
* summary before anything is written: the output's size and format, the
|
|
433
|
+
* metadata the source carried that the file won't, and the fields the user
|
|
434
|
+
* chose to keep. Then a progress bar that can stop the export, and a
|
|
435
|
+
* download button, which gets focus, with the file's size.
|
|
436
|
+
*
|
|
437
|
+
* It opens when the editor state's `dialog` is `export`, as the export tool
|
|
438
|
+
* sets it. On Export, the chosen size and fields become one undoable step
|
|
439
|
+
* of the plan, so the plan records what was exported. A format the browser
|
|
440
|
+
* can't encode shows the catalogue's text, and keeps the choices.
|
|
441
|
+
*
|
|
442
|
+
* @public
|
|
443
|
+
*/
|
|
444
|
+
export declare function ImageExportDialog(props: ImageExportDialogProps): ReactNode;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Props of {@link ImageExportDialog}.
|
|
448
|
+
*
|
|
449
|
+
* @public
|
|
450
|
+
*/
|
|
451
|
+
export declare interface ImageExportDialogProps {
|
|
452
|
+
/**
|
|
453
|
+
* Takes the exported file instead of the dialog's download button: the
|
|
454
|
+
* dialog closes once it's called.
|
|
455
|
+
*/
|
|
456
|
+
readonly onExport?: (blob: Blob, details: ImageSessionExport) => void;
|
|
457
|
+
/** The downloaded file's name, without its extension. Defaults to `image`. */
|
|
458
|
+
readonly fileName?: string;
|
|
459
|
+
/** Extra classes on the dialog. */
|
|
460
|
+
readonly className?: string;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* The file an export produces (ADR 0001). `quality`, from 0 to 1, applies to
|
|
465
|
+
* the lossy formats; it defaults to 0.92. WebP is encoded only where the
|
|
466
|
+
* browser can, and otherwise rejects with `UNSUPPORTED_FORMAT`.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
*/
|
|
470
|
+
declare type ImageExportFormat = {
|
|
471
|
+
readonly type: "png";
|
|
472
|
+
} | {
|
|
473
|
+
readonly type: "jpeg";
|
|
474
|
+
readonly quality?: number;
|
|
475
|
+
} | {
|
|
476
|
+
readonly type: "webp";
|
|
477
|
+
readonly quality?: number;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* One export: a plan over sources registered with the same engine, and the
|
|
482
|
+
* output format. The plan's kept metadata goes into the file, and nothing
|
|
483
|
+
* else does (ADR 0005).
|
|
484
|
+
*
|
|
485
|
+
* @public
|
|
486
|
+
*/
|
|
487
|
+
declare interface ImageExportJob {
|
|
488
|
+
readonly plan: ImagePlan;
|
|
489
|
+
readonly format: ImageExportFormat;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Options for exporting.
|
|
494
|
+
*
|
|
495
|
+
* @public
|
|
496
|
+
*/
|
|
497
|
+
declare interface ImageExportOptions extends ImageProgressOptions {
|
|
498
|
+
/**
|
|
499
|
+
* The limits the output canvas is checked against before it's allocated:
|
|
500
|
+
* `maxImageDimension` and `maxImagePixels` (ADR 0004). The defaults of
|
|
501
|
+
* `imageLimits` when omitted.
|
|
502
|
+
*/
|
|
503
|
+
readonly filePolicy?: ImageFilePolicy;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* A resolved file policy for the image SDK. Violations throw
|
|
508
|
+
* {@link ImageError}.
|
|
509
|
+
*
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
512
|
+
declare type ImageFilePolicy = FilePolicy<ImageLimitDefinitions>;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* A host's `filePolicy`: a new maximum, or `{ maximum, warning }`, for any of
|
|
516
|
+
* the image SDK's limits. `Infinity` disables a maximum, which removes a
|
|
517
|
+
* protection against hostile files, or disables a warning. Unknown limit
|
|
518
|
+
* names throw `TypeError` when the policy is resolved.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```ts
|
|
522
|
+
* // Large scans: raise the pixel and decoded sizes together.
|
|
523
|
+
* const filePolicy: ImageFilePolicyOverrides = {
|
|
524
|
+
* maxImagePixels: 100_000_000,
|
|
525
|
+
* maxDecodedSize: { maximum: 2e9, warning: 800e6 },
|
|
526
|
+
* };
|
|
527
|
+
* ```
|
|
528
|
+
*
|
|
529
|
+
* @public
|
|
530
|
+
*/
|
|
531
|
+
declare type ImageFilePolicyOverrides = FilePolicyOverrides<ImageLimitDefinitions>;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* A filter preset and its strength, an integer from 0 (no effect) to 100.
|
|
535
|
+
*
|
|
536
|
+
* @public
|
|
537
|
+
*/
|
|
538
|
+
declare interface ImageFilter {
|
|
539
|
+
readonly preset: ImageFilterPreset;
|
|
540
|
+
readonly strength: number;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* The Filters panel (docs/adr/0006, docs/adr/0007): the presets, "None"
|
|
545
|
+
* first, as one choice, each one undo step; and the chosen preset's
|
|
546
|
+
* strength, whose slider gesture is one undo step.
|
|
547
|
+
*
|
|
548
|
+
* @public
|
|
549
|
+
*/
|
|
550
|
+
export declare function ImageFilterPanel(props: ImageFilterPanelProps): ReactNode;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Props of {@link ImageFilterPanel}.
|
|
554
|
+
*
|
|
555
|
+
* @public
|
|
556
|
+
*/
|
|
557
|
+
export declare interface ImageFilterPanelProps {
|
|
558
|
+
readonly className?: string;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* A filter preset's name.
|
|
563
|
+
*
|
|
564
|
+
* @public
|
|
565
|
+
*/
|
|
566
|
+
declare type ImageFilterPreset = (typeof FILTER_PRESETS)[number];
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* The formats the probe recognises, by their signature bytes (ADR 0001).
|
|
570
|
+
*
|
|
571
|
+
* @public
|
|
572
|
+
*/
|
|
573
|
+
declare type ImageFormat = "png" | "jpeg" | "webp" | "gif" | "avif" | "heif" | "bmp";
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* The components of the icons the editor's tools name, from ui's set
|
|
577
|
+
* (sdk-core ADR 0030). A host's `icons` prop overrides any of them.
|
|
578
|
+
*
|
|
579
|
+
* @public
|
|
580
|
+
*/
|
|
581
|
+
export declare const imageIcons: Readonly<Record<string, IconComponent>>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* The metadata fields a user may keep on export (ADR 0005). Empty strings
|
|
585
|
+
* mean the field isn't written.
|
|
586
|
+
*
|
|
587
|
+
* @public
|
|
588
|
+
*/
|
|
589
|
+
declare interface ImageKeepableMetadata {
|
|
590
|
+
readonly title: string;
|
|
591
|
+
readonly description: string;
|
|
592
|
+
readonly artist: string;
|
|
593
|
+
readonly copyright: string;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* The type of {@link imageLimitDefinitions}.
|
|
598
|
+
*
|
|
599
|
+
* @public
|
|
600
|
+
*/
|
|
601
|
+
declare type ImageLimitDefinitions = typeof imageLimitDefinitions;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* The image SDK's limit definitions: sdk-core's core limits with image
|
|
605
|
+
* defaults, plus five for images (ADR 0004).
|
|
606
|
+
*
|
|
607
|
+
* | Limit | Code | Default maximum | Default warning |
|
|
608
|
+
* |---|---|---|---|
|
|
609
|
+
* | `maxFileSize` | `FILE_TOO_LARGE` | 100 MB | 50 MB |
|
|
610
|
+
* | `maxFiles` | `TOO_MANY_FILES` | 20 | none |
|
|
611
|
+
* | `maxDecodedSize` | `DECODED_SIZE_TOO_LARGE` | 1 GB | 400 MB |
|
|
612
|
+
* | `maxProcessingTime` | `PROCESSING_TIME_EXCEEDED` | 120 s | none |
|
|
613
|
+
* | `maxImagePixels` | `IMAGE_TOO_LARGE` | 50 megapixels | 24 megapixels |
|
|
614
|
+
* | `maxImageDimension` | `IMAGE_DIMENSION_TOO_LARGE` | 16,384 pixels | none |
|
|
615
|
+
* | `maxFrames` | `TOO_MANY_FRAMES` | 300 | 100 |
|
|
616
|
+
* | `maxSessionSize` | `SESSION_TOO_LARGE` | 1 GB | 500 MB |
|
|
617
|
+
* | `maxLayers` | `TOO_MANY_LAYERS` | 256 | none |
|
|
618
|
+
*
|
|
619
|
+
* Sizes are decimal: 1 MB is 1,000,000 bytes. Decoded sizes count 4 bytes
|
|
620
|
+
* per pixel. `maxImagePixels` is the same limit, with the same name, code
|
|
621
|
+
* and unit, as `pdf-sdk`'s. `maxImageDimension` is a side length, in pixels.
|
|
622
|
+
*
|
|
623
|
+
* @public
|
|
624
|
+
*/
|
|
625
|
+
declare const imageLimitDefinitions: {
|
|
626
|
+
readonly maxDecodedSize: {
|
|
627
|
+
readonly default: 1000000000;
|
|
628
|
+
readonly warning: 400000000;
|
|
629
|
+
readonly code: "DECODED_SIZE_TOO_LARGE";
|
|
630
|
+
readonly unit: "bytes";
|
|
631
|
+
};
|
|
632
|
+
readonly maxImagePixels: {
|
|
633
|
+
readonly code: "IMAGE_TOO_LARGE";
|
|
634
|
+
readonly unit: "pixels";
|
|
635
|
+
readonly default: 50000000;
|
|
636
|
+
readonly warning: 24000000;
|
|
637
|
+
};
|
|
638
|
+
readonly maxImageDimension: {
|
|
639
|
+
readonly code: "IMAGE_DIMENSION_TOO_LARGE";
|
|
640
|
+
readonly unit: "pixels";
|
|
641
|
+
readonly default: 16384;
|
|
642
|
+
};
|
|
643
|
+
readonly maxFrames: {
|
|
644
|
+
readonly code: "TOO_MANY_FRAMES";
|
|
645
|
+
readonly unit: "count";
|
|
646
|
+
readonly default: 300;
|
|
647
|
+
readonly warning: 100;
|
|
648
|
+
};
|
|
649
|
+
readonly maxSessionSize: {
|
|
650
|
+
readonly code: "SESSION_TOO_LARGE";
|
|
651
|
+
readonly unit: "bytes";
|
|
652
|
+
readonly default: 1000000000;
|
|
653
|
+
readonly warning: 500000000;
|
|
654
|
+
};
|
|
655
|
+
readonly maxLayers: {
|
|
656
|
+
readonly code: "TOO_MANY_LAYERS";
|
|
657
|
+
readonly unit: "count";
|
|
658
|
+
readonly default: 256;
|
|
659
|
+
};
|
|
660
|
+
readonly maxFileSize: {
|
|
661
|
+
readonly code: "FILE_TOO_LARGE";
|
|
662
|
+
readonly unit: "bytes";
|
|
663
|
+
readonly default: 100000000;
|
|
664
|
+
readonly warning: 50000000;
|
|
665
|
+
};
|
|
666
|
+
readonly maxFiles: {
|
|
667
|
+
readonly code: "TOO_MANY_FILES";
|
|
668
|
+
readonly unit: "count";
|
|
669
|
+
readonly default: 20;
|
|
670
|
+
};
|
|
671
|
+
readonly maxProcessingTime: {
|
|
672
|
+
readonly code: "PROCESSING_TIME_EXCEEDED";
|
|
673
|
+
readonly unit: "milliseconds";
|
|
674
|
+
readonly default: 120000;
|
|
675
|
+
};
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* The names of the image SDK's limits.
|
|
680
|
+
*
|
|
681
|
+
* @public
|
|
682
|
+
*/
|
|
683
|
+
declare type ImageLimitName = keyof ImageLimitDefinitions;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* The type of {@link imageMessages}, for typing a host's overrides with
|
|
687
|
+
* `MessageOverrides<ImageMessageCatalogue>`.
|
|
688
|
+
*
|
|
689
|
+
* @public
|
|
690
|
+
*/
|
|
691
|
+
declare type ImageMessageCatalogue = typeof imageMessages;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* The image SDK's English message catalogue: sdk-core's and ui's messages, and text
|
|
695
|
+
* for every {@link ImageErrorCode} and every limit's warning. Pass it to
|
|
696
|
+
* `createMessages` from `@hussmartinez/sdk-core`, with the host's locale and
|
|
697
|
+
* overrides. It also has the editor's text: its labels, states,
|
|
698
|
+
* announcements and tool names.
|
|
699
|
+
*
|
|
700
|
+
* Error text is looked up by code, with the error's `details` as
|
|
701
|
+
* parameters, and never taken from `error.message` (ADR 0019).
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```ts
|
|
705
|
+
* const messages = createMessages(imageMessages, { locale: "en", overrides: props.messages });
|
|
706
|
+
* messages.error(error); // "This animation has 400 frames, which is over the 300-frame limit."
|
|
707
|
+
* messages.t("warnings.maxSessionSize", { actual: 600e6 });
|
|
708
|
+
* ```
|
|
709
|
+
*
|
|
710
|
+
* @public
|
|
711
|
+
*/
|
|
712
|
+
declare const imageMessages: {
|
|
713
|
+
readonly "errors.INVALID_IMAGE": "This file isn't a valid image, or it's too damaged to open.";
|
|
714
|
+
readonly "errors.UNSUPPORTED_FORMAT": "This image format isn't supported. Try converting the file to PNG or JPEG, then open it again.";
|
|
715
|
+
readonly "errors.DECODE_FAILED": "This browser can't open this kind of image. Try another browser, or convert the file to PNG or JPEG.";
|
|
716
|
+
readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
|
|
717
|
+
readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't an image project.";
|
|
718
|
+
readonly "errors.IMAGE_TOO_LARGE": "This image has more pixels than the editor can handle. Try a smaller version of it.";
|
|
719
|
+
readonly "errors.IMAGE_DIMENSION_TOO_LARGE": "This image is {actual, number} pixels across, which is over the {maximum, number}-pixel limit.";
|
|
720
|
+
readonly "errors.TOO_MANY_FRAMES": {
|
|
721
|
+
readonly $plural: "maximum";
|
|
722
|
+
} & {
|
|
723
|
+
readonly one: "This animation has {actual, number} frames, which is over the {maximum}-frame limit.";
|
|
724
|
+
readonly other: "This animation has {actual, number} frames, which is over the {maximum, number}-frame limit.";
|
|
725
|
+
};
|
|
726
|
+
readonly "errors.SESSION_TOO_LARGE": "The open images would use {actual, fileSize} of memory, which is over the {maximum, fileSize} limit. Close an image, or clear the undo history, and try again.";
|
|
727
|
+
readonly "errors.TOO_MANY_LAYERS": {
|
|
728
|
+
readonly $plural: "maximum";
|
|
729
|
+
} & {
|
|
730
|
+
readonly one: "An image can have {maximum} layer. Merge or delete layers, and try again.";
|
|
731
|
+
readonly other: "An image can have up to {maximum, number} layers. Merge or delete layers, and try again.";
|
|
732
|
+
};
|
|
733
|
+
readonly "warnings.maxImagePixels": "This image is large, and may be slow to edit on some devices.";
|
|
734
|
+
readonly "warnings.maxImageDimension": "This image is very wide or tall, and may be slow to edit.";
|
|
735
|
+
readonly "warnings.maxFrames": {
|
|
736
|
+
readonly $plural: "actual";
|
|
737
|
+
} & {
|
|
738
|
+
readonly one: "This animation has {actual} frame.";
|
|
739
|
+
readonly other: "This animation has {actual, number} frames, and may be slow to edit and export.";
|
|
740
|
+
};
|
|
741
|
+
readonly "warnings.maxSessionSize": "The open images use {actual, fileSize} of memory. Clearing the undo history frees memory.";
|
|
742
|
+
readonly "warnings.maxLayers": {
|
|
743
|
+
readonly $plural: "actual";
|
|
744
|
+
} & {
|
|
745
|
+
readonly one: "This image has {actual} layer.";
|
|
746
|
+
readonly other: "This image has {actual, number} layers, and may be slow to edit and export.";
|
|
747
|
+
};
|
|
748
|
+
readonly "editor.label": "Image editor";
|
|
749
|
+
readonly "editor.preview": "Edited image preview, {width, number} × {height, number}";
|
|
750
|
+
readonly "editor.empty": "Open an image to start editing. It stays on this device.";
|
|
751
|
+
readonly "editor.choose": "Choose an image";
|
|
752
|
+
readonly "editor.dropHint": "or drop it here";
|
|
753
|
+
readonly "editor.opening": "Opening the image…";
|
|
754
|
+
readonly "editor.cancel": "Cancel";
|
|
755
|
+
readonly "editor.opened": "Image opened, {width, number} × {height, number}.";
|
|
756
|
+
readonly "editor.undid": "Undid {action}.";
|
|
757
|
+
readonly "editor.redid": "Redid {action}.";
|
|
758
|
+
readonly "actions.image.setCrop": "crop";
|
|
759
|
+
readonly "actions.image.setOrientation": "rotate or flip";
|
|
760
|
+
readonly "actions.image.setOutput": "size";
|
|
761
|
+
readonly "actions.image.setMetadata": "metadata";
|
|
762
|
+
readonly "actions.image.setDevelop": "adjustment";
|
|
763
|
+
readonly "actions.image.setFilter": "filter";
|
|
764
|
+
readonly "toolbar.label": "Image tools";
|
|
765
|
+
readonly "toolbar.groups.file": "File";
|
|
766
|
+
readonly "toolbar.groups.history": "History";
|
|
767
|
+
readonly "toolbar.groups.orientation": "Rotate";
|
|
768
|
+
readonly "toolbar.groups.zoom": "Zoom";
|
|
769
|
+
readonly "toolbar.groups.other": "More tools";
|
|
770
|
+
readonly "tools.open": "Open image";
|
|
771
|
+
readonly "tools.undo": "Undo";
|
|
772
|
+
readonly "tools.redo": "Redo";
|
|
773
|
+
readonly "tools.rotate-left": "Rotate left";
|
|
774
|
+
readonly "tools.rotate-right": "Rotate right";
|
|
775
|
+
readonly "tools.zoom-in": "Zoom in";
|
|
776
|
+
readonly "tools.zoom-out": "Zoom out";
|
|
777
|
+
readonly "tools.zoom-fit": "Fit to the stage";
|
|
778
|
+
readonly "tools.crop": "Crop";
|
|
779
|
+
readonly "tools.flip-horizontal": "Flip horizontally";
|
|
780
|
+
readonly "tools.flip-vertical": "Flip vertically";
|
|
781
|
+
readonly "toolbar.groups.crop": "Crop";
|
|
782
|
+
readonly "crop.frame": "Crop area";
|
|
783
|
+
readonly "crop.frameDescription": "{width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; with Alt, they resize it; Enter applies and Escape cancels.";
|
|
784
|
+
readonly "crop.size": "{width, number} × {height, number}, from {x, number}, {y, number}";
|
|
785
|
+
readonly "crop.panel": "Crop";
|
|
786
|
+
readonly "crop.x": "Left";
|
|
787
|
+
readonly "crop.y": "Top";
|
|
788
|
+
readonly "crop.width": "Width";
|
|
789
|
+
readonly "crop.height": "Height";
|
|
790
|
+
readonly "crop.aspect": "Aspect ratio";
|
|
791
|
+
readonly "crop.aspects.free": "Free";
|
|
792
|
+
readonly "crop.aspects.original": "Original";
|
|
793
|
+
readonly "crop.aspects.ratio": "{width}:{height}";
|
|
794
|
+
readonly "crop.apply": "Apply crop";
|
|
795
|
+
readonly "crop.cancel": "Cancel";
|
|
796
|
+
readonly "crop.reset": "Whole image";
|
|
797
|
+
readonly "crop.applied": "Cropped to {width, number} × {height, number}.";
|
|
798
|
+
readonly "inspector.label": "Panels";
|
|
799
|
+
readonly "inspector.adjust": "Adjust";
|
|
800
|
+
readonly "inspector.filters": "Filters";
|
|
801
|
+
readonly "develop.panel": "Adjust";
|
|
802
|
+
readonly "develop.temperature": "Temperature";
|
|
803
|
+
readonly "develop.tint": "Tint";
|
|
804
|
+
readonly "develop.exposure": "Exposure";
|
|
805
|
+
readonly "develop.highlights": "Highlights";
|
|
806
|
+
readonly "develop.shadows": "Shadows";
|
|
807
|
+
readonly "develop.contrast": "Contrast";
|
|
808
|
+
readonly "develop.saturation": "Saturation";
|
|
809
|
+
readonly "develop.vibrance": "Vibrance";
|
|
810
|
+
readonly "develop.reset": "Reset {name}";
|
|
811
|
+
readonly "develop.resetAll": "Reset all";
|
|
812
|
+
readonly "develop.wasReset": "All adjustments reset.";
|
|
813
|
+
readonly "filters.panel": "Filters";
|
|
814
|
+
readonly "filters.label": "Filter";
|
|
815
|
+
readonly "filters.none": "None";
|
|
816
|
+
readonly "filters.vivid": "Vivid";
|
|
817
|
+
readonly "filters.warm": "Warm";
|
|
818
|
+
readonly "filters.cool": "Cool";
|
|
819
|
+
readonly "filters.fade": "Fade";
|
|
820
|
+
readonly "filters.mono": "Mono";
|
|
821
|
+
readonly "filters.noir": "Noir";
|
|
822
|
+
readonly "filters.sepia": "Sepia";
|
|
823
|
+
readonly "filters.strength": "Strength";
|
|
824
|
+
readonly "toolbar.groups.export": "Export";
|
|
825
|
+
readonly "tools.export": "Export";
|
|
826
|
+
readonly "export.title": "Export image";
|
|
827
|
+
readonly "export.description": "The file is made on this device, and nothing is uploaded.";
|
|
828
|
+
readonly "export.format": "Format";
|
|
829
|
+
readonly "export.formats.png": "PNG";
|
|
830
|
+
readonly "export.formats.jpeg": "JPEG";
|
|
831
|
+
readonly "export.formats.webp": "WebP";
|
|
832
|
+
readonly "export.quality": "Quality";
|
|
833
|
+
readonly "export.size": "Size";
|
|
834
|
+
readonly "export.sizes.scale": "Scale";
|
|
835
|
+
readonly "export.sizes.fit": "Fit in a box";
|
|
836
|
+
readonly "export.scale": "Scale, in percent";
|
|
837
|
+
readonly "export.fitWidth": "Largest width";
|
|
838
|
+
readonly "export.fitHeight": "Largest height";
|
|
839
|
+
readonly "export.fields": "Details to include";
|
|
840
|
+
readonly "export.fieldsHint": "Only what you fill in is written to the file.";
|
|
841
|
+
readonly "export.field.title": "Title";
|
|
842
|
+
readonly "export.field.description": "Description";
|
|
843
|
+
readonly "export.field.artist": "Artist";
|
|
844
|
+
readonly "export.field.copyright": "Copyright";
|
|
845
|
+
readonly "export.summary": "Summary";
|
|
846
|
+
readonly "export.output": "{width, number} × {height, number} pixels, {format}";
|
|
847
|
+
readonly "export.removed": "Removed from the file";
|
|
848
|
+
readonly "export.removedNone": "The image had no other details to remove.";
|
|
849
|
+
readonly "export.kind.location": "Location";
|
|
850
|
+
readonly "export.kind.camera": "Camera details";
|
|
851
|
+
readonly "export.kind.timestamps": "Dates and times";
|
|
852
|
+
readonly "export.kind.thumbnail": "Embedded thumbnail";
|
|
853
|
+
readonly "export.kind.colourProfile": "Colour profile: colours outside sRGB are clipped";
|
|
854
|
+
readonly "export.kind.other": "Other metadata";
|
|
855
|
+
readonly "export.kept": "Kept in the file";
|
|
856
|
+
readonly "export.confirm": "Export";
|
|
857
|
+
readonly "export.cancel": "Cancel";
|
|
858
|
+
readonly "export.progress": "Exporting the image";
|
|
859
|
+
readonly "export.stop": "Stop exporting";
|
|
860
|
+
readonly "export.cancelled": "Export stopped.";
|
|
861
|
+
readonly "export.done": "Exported a {format} of {size, fileSize}.";
|
|
862
|
+
readonly "export.ready": "{width, number} × {height, number} pixels, {format}, {size, fileSize}";
|
|
863
|
+
readonly "export.download": "Download";
|
|
864
|
+
readonly "export.close": "Done";
|
|
865
|
+
readonly "dialog.close": "Close";
|
|
866
|
+
readonly "fileDropZone.choose": "Choose a file";
|
|
867
|
+
readonly "fileDropZone.chooseMultiple": "Choose files";
|
|
868
|
+
readonly "fileDropZone.hint": "or drop it here";
|
|
869
|
+
readonly "fileDropZone.hintMultiple": "or drop them here";
|
|
870
|
+
readonly "progress.label": "Progress";
|
|
871
|
+
readonly "spinner.label": "Loading";
|
|
872
|
+
readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
|
|
873
|
+
readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
|
|
874
|
+
readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
|
|
875
|
+
readonly "errors.ABORTED": "The operation was cancelled.";
|
|
876
|
+
readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
|
|
877
|
+
readonly "errors.WORKER_START_FAILED": "The file processor couldn't start. Reload the page and try again.";
|
|
878
|
+
readonly "errors.WORKER_PROTOCOL_MISMATCH": "The file processor is out of date. Reload the page to update it.";
|
|
879
|
+
readonly "errors.WORKER_CRASHED": "The file processor stopped unexpectedly. Please try again.";
|
|
880
|
+
readonly "errors.WORKER_TERMINATED": "The operation was stopped before it finished. Please try again.";
|
|
881
|
+
readonly "errors.WORKER_METHOD_NOT_FOUND": "This operation isn't available. Reload the page and try again.";
|
|
882
|
+
readonly "errors.WORKER_DATA_NOT_CLONEABLE": "Something went wrong while processing the file. Please try again.";
|
|
883
|
+
readonly "errors.UNSUPPORTED_ENVIRONMENT": "This browser doesn't support a feature this tool needs. Update your browser, or try another one.";
|
|
884
|
+
readonly "errors.FILE_TOO_LARGE": "This file is {actual, fileSize}, which is over the {maximum, fileSize} limit.";
|
|
885
|
+
readonly "errors.TOO_MANY_FILES": {
|
|
886
|
+
readonly $plural: "maximum";
|
|
887
|
+
} & {
|
|
888
|
+
readonly one: "You can add {maximum} file at a time.";
|
|
889
|
+
readonly other: "You can add up to {maximum} files at a time.";
|
|
890
|
+
};
|
|
891
|
+
readonly "errors.DECODED_SIZE_TOO_LARGE": "This file expands to more than {maximum, fileSize} when opened, which is over the limit.";
|
|
892
|
+
readonly "errors.PROCESSING_TIME_EXCEEDED": "Processing this file took too long and was stopped.";
|
|
893
|
+
readonly "warnings.maxFileSize": "This file is {actual, fileSize}. Large files may be slow to process.";
|
|
894
|
+
readonly "warnings.maxFiles": "Adding {actual} files at once may be slow.";
|
|
895
|
+
readonly "warnings.maxDecodedSize": "This file is very large once opened and may be slow to process.";
|
|
896
|
+
readonly "warnings.maxProcessingTime": "This is taking longer than usual.";
|
|
897
|
+
readonly "keys.control": "Ctrl";
|
|
898
|
+
readonly "keys.alt": "Alt";
|
|
899
|
+
readonly "keys.shift": "Shift";
|
|
900
|
+
readonly "keys.meta": "Meta";
|
|
901
|
+
readonly "keys.apple.control": "\u2303";
|
|
902
|
+
readonly "keys.apple.alt": "\u2325";
|
|
903
|
+
readonly "keys.apple.shift": "\u21E7";
|
|
904
|
+
readonly "keys.apple.meta": "\u2318";
|
|
905
|
+
readonly "keys.space": "Space";
|
|
906
|
+
readonly "keys.enter": "Enter";
|
|
907
|
+
readonly "keys.escape": "Esc";
|
|
908
|
+
readonly "keys.tab": "Tab";
|
|
909
|
+
readonly "keys.delete": "Delete";
|
|
910
|
+
readonly "keys.backspace": "Backspace";
|
|
911
|
+
readonly "keys.arrowUp": "\u2191";
|
|
912
|
+
readonly "keys.arrowDown": "\u2193";
|
|
913
|
+
readonly "keys.arrowLeft": "\u2190";
|
|
914
|
+
readonly "keys.arrowRight": "\u2192";
|
|
915
|
+
readonly "keys.home": "Home";
|
|
916
|
+
readonly "keys.end": "End";
|
|
917
|
+
readonly "keys.pageUp": "Page Up";
|
|
918
|
+
readonly "keys.pageDown": "Page Down";
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Which kinds of metadata a file carries, as presence flags, never values,
|
|
923
|
+
* so the editor can say what an export removes (ADR 0005).
|
|
924
|
+
*
|
|
925
|
+
* @public
|
|
926
|
+
*/
|
|
927
|
+
declare interface ImageMetadataPresence {
|
|
928
|
+
readonly location: boolean;
|
|
929
|
+
readonly camera: boolean;
|
|
930
|
+
readonly timestamps: boolean;
|
|
931
|
+
readonly thumbnail: boolean;
|
|
932
|
+
readonly colourProfile: boolean;
|
|
933
|
+
/** Any other field, such as maker notes or unknown tags. */
|
|
934
|
+
readonly other: boolean;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* The plan's own rotation and flips, applied after the crop. They're user
|
|
939
|
+
* edits, separate from the file's EXIF orientation, which decoding has
|
|
940
|
+
* already applied (ADR 0005).
|
|
941
|
+
*
|
|
942
|
+
* @public
|
|
943
|
+
*/
|
|
944
|
+
declare interface ImageOrientation_2 {
|
|
945
|
+
readonly rotate: ImageRotation;
|
|
946
|
+
/** Mirrors left to right, after the rotation. */
|
|
947
|
+
readonly flipX: boolean;
|
|
948
|
+
/** Mirrors top to bottom, after the rotation. */
|
|
949
|
+
readonly flipY: boolean;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* The export's size: the composition scaled by a factor up to 1, or fitted
|
|
954
|
+
* inside a box without enlarging it.
|
|
955
|
+
*
|
|
956
|
+
* @public
|
|
957
|
+
*/
|
|
958
|
+
declare type ImageOutput = {
|
|
959
|
+
readonly kind: "scale";
|
|
960
|
+
readonly scale: number;
|
|
961
|
+
} | {
|
|
962
|
+
readonly kind: "fit";
|
|
963
|
+
readonly width: number;
|
|
964
|
+
readonly height: number;
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* The session's document: a description of the edits over an immutable
|
|
969
|
+
* source, rendered to pixels only for display and export (ADR 0003).
|
|
970
|
+
*
|
|
971
|
+
* @public
|
|
972
|
+
*/
|
|
973
|
+
declare interface ImagePlan {
|
|
974
|
+
readonly base: ImageBase;
|
|
975
|
+
readonly output: ImageOutput;
|
|
976
|
+
/** The fields the user chose to keep on export. Never a location (ADR 0005). */
|
|
977
|
+
readonly metadata: ImageKeepableMetadata;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* What the probe learned about a file before anything decodes it (ADR 0001,
|
|
982
|
+
* ADR 0004, ADR 0005). Limits are checked against it.
|
|
983
|
+
*
|
|
984
|
+
* @public
|
|
985
|
+
*/
|
|
986
|
+
declare interface ImageProbe {
|
|
987
|
+
readonly format: ImageFormat;
|
|
988
|
+
/** The size of the stored pixels, before orientation. */
|
|
989
|
+
readonly stored: ImageSize;
|
|
990
|
+
/** The upright size, after orientation: the size the decoder must return. */
|
|
991
|
+
readonly oriented: ImageSize;
|
|
992
|
+
/** The EXIF or `irot`/`imir` orientation; 1 when there's none. */
|
|
993
|
+
readonly orientation: ExifOrientation;
|
|
994
|
+
/** 1 for a still image, otherwise the number of frames the probe walked. */
|
|
995
|
+
readonly frames: number;
|
|
996
|
+
readonly hasAlpha: boolean;
|
|
997
|
+
/**
|
|
998
|
+
* The most pixels the decoder can produce for the file: frames × the
|
|
999
|
+
* oriented size for most formats, and for AVIF and HEIF the sum over every
|
|
1000
|
+
* item decoded with the primary, such as grid tiles and auxiliary planes.
|
|
1001
|
+
* A file with an orientation counts one more oriented frame, which the
|
|
1002
|
+
* worker needs when it applies the orientation itself (ADR 0005).
|
|
1003
|
+
* Never a count declared by one header (ADR 0001).
|
|
1004
|
+
*/
|
|
1005
|
+
readonly decodedPixelBound: number;
|
|
1006
|
+
readonly metadata: ImageMetadataPresence;
|
|
1007
|
+
/** The keepable fields the file carries, length-limited, shown only as text. */
|
|
1008
|
+
readonly keepable: ImageKeepableMetadata;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* The port for exporting: render a plan at its output size and encode it
|
|
1013
|
+
* (ADR 0001, ADR 0003, ADR 0008). It renders sources registered with its
|
|
1014
|
+
* engine, so the SDK's own adapter shares the engine's render worker; hosts
|
|
1015
|
+
* can pass their own to the editor's `processor` prop, and every
|
|
1016
|
+
* implementation must pass the processor's contract tests.
|
|
1017
|
+
*
|
|
1018
|
+
* Failures reject with `ImageError` for cancellation, worker failures and
|
|
1019
|
+
* formats the browser can't encode, and `TypeError` for a plan whose source
|
|
1020
|
+
* isn't registered.
|
|
1021
|
+
*
|
|
1022
|
+
* @public
|
|
1023
|
+
*/
|
|
1024
|
+
declare interface ImageProcessor {
|
|
1025
|
+
/**
|
|
1026
|
+
* Renders and encodes a plan, and returns the file. It writes only the
|
|
1027
|
+
* plan's kept metadata, and never a location, a camera's details,
|
|
1028
|
+
* timestamps, a thumbnail or an orientation. An output over `filePolicy`'s
|
|
1029
|
+
* `maxImageDimension` or `maxImagePixels` rejects with that limit's code
|
|
1030
|
+
* before anything is drawn.
|
|
1031
|
+
*/
|
|
1032
|
+
export(job: ImageExportJob, options?: ImageExportOptions): Promise<Blob>;
|
|
1033
|
+
/** Releases the processor. Pending calls reject, and later calls throw. */
|
|
1034
|
+
destroy(): Promise<void>;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Options for long calls, which report how far they've got.
|
|
1039
|
+
*
|
|
1040
|
+
* @public
|
|
1041
|
+
*/
|
|
1042
|
+
declare interface ImageProgressOptions extends ImageCallOptions {
|
|
1043
|
+
/**
|
|
1044
|
+
* Called with the fraction done, from 0 to 1. It only moves forward, and
|
|
1045
|
+
* it's called with 1 before the call resolves.
|
|
1046
|
+
*/
|
|
1047
|
+
readonly onProgress?: (fraction: number) => void;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Options for registering a source.
|
|
1052
|
+
*
|
|
1053
|
+
* @public
|
|
1054
|
+
*/
|
|
1055
|
+
declare interface ImageRegisterOptions extends ImageProgressOptions {
|
|
1056
|
+
/**
|
|
1057
|
+
* The limits checked against the engine's own probe of the file before
|
|
1058
|
+
* anything decodes it: `maxFileSize`, `maxImageDimension`,
|
|
1059
|
+
* `maxImagePixels`, `maxFrames` and `maxDecodedSize` (ADR 0004). The
|
|
1060
|
+
* defaults of `imageLimits` when omitted. The session checks the same
|
|
1061
|
+
* policy first, so this is defence in depth for hosts that use the engine
|
|
1062
|
+
* directly.
|
|
1063
|
+
*/
|
|
1064
|
+
readonly filePolicy?: ImageFilePolicy;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* A quarter-turn rotation, clockwise, in degrees.
|
|
1069
|
+
*
|
|
1070
|
+
* @public
|
|
1071
|
+
*/
|
|
1072
|
+
declare type ImageRotation = 0 | 90 | 180 | 270;
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* An image editing session (ADR 0003, ADR 0008): one document, its plan
|
|
1076
|
+
* over the source it opened, edited by commands with undo and redo, and
|
|
1077
|
+
* exported through its processor.
|
|
1078
|
+
*
|
|
1079
|
+
* @public
|
|
1080
|
+
*/
|
|
1081
|
+
declare interface ImageSession {
|
|
1082
|
+
getSnapshot(): ImageSessionSnapshot;
|
|
1083
|
+
/** Calls the listener after every change. Returns a function that unsubscribes. */
|
|
1084
|
+
subscribe(listener: () => void): () => void;
|
|
1085
|
+
/**
|
|
1086
|
+
* Probes, checks and decodes a file, and makes it the document, with a new
|
|
1087
|
+
* plan and an empty history; the previous source is released (ADR 0003,
|
|
1088
|
+
* ADR 0004). The newest open wins: an open that finishes after a later one
|
|
1089
|
+
* started applies nothing, releases its source and rejects with
|
|
1090
|
+
* `ABORTED`. A failed or cancelled open leaves the current document as it
|
|
1091
|
+
* was.
|
|
1092
|
+
*/
|
|
1093
|
+
open(file: Blob, options?: {
|
|
1094
|
+
readonly signal?: AbortSignal;
|
|
1095
|
+
}): Promise<ImageSessionSource>;
|
|
1096
|
+
/**
|
|
1097
|
+
* Applies commands as one undoable step. They're checked by the reducer,
|
|
1098
|
+
* then the output against `maxImageDimension` and `maxImagePixels`; a
|
|
1099
|
+
* failure throws `ImageError` and changes nothing.
|
|
1100
|
+
*/
|
|
1101
|
+
execute(commands: ImageCommand | readonly ImageCommand[]): void;
|
|
1102
|
+
/**
|
|
1103
|
+
* Makes the document's plan equal to `plan`, as one undoable step of the
|
|
1104
|
+
* commands that reach it, checked as `execute` checks them (ADR 0003). A
|
|
1105
|
+
* plan equal to the current one changes nothing. A plan over another
|
|
1106
|
+
* source is `INVALID_COMMAND`. For editors whose host holds the plan.
|
|
1107
|
+
*/
|
|
1108
|
+
applyPlan(plan: ImagePlan): void;
|
|
1109
|
+
/**
|
|
1110
|
+
* Runs `fn`, and records every step it executes as one undoable step, for
|
|
1111
|
+
* a gesture such as dragging a crop handle (ADR 0003). `fn` must be
|
|
1112
|
+
* synchronous.
|
|
1113
|
+
*/
|
|
1114
|
+
group<T>(fn: () => T): T;
|
|
1115
|
+
/** Undoes the last step. Returns whether there was one. */
|
|
1116
|
+
undo(): boolean;
|
|
1117
|
+
/** Redoes the last undone step. Returns whether there was one. */
|
|
1118
|
+
redo(): boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* Renders and encodes the document (ADR 0003). An export that finishes
|
|
1121
|
+
* after another file was opened rejects with `ABORTED`.
|
|
1122
|
+
*/
|
|
1123
|
+
export(format: ImageExportFormat, options?: {
|
|
1124
|
+
readonly signal?: AbortSignal;
|
|
1125
|
+
readonly onProgress?: (fraction: number) => void;
|
|
1126
|
+
}): Promise<ImageSessionExport>;
|
|
1127
|
+
/** Releases the source the session holds. Later calls throw. */
|
|
1128
|
+
destroy(): Promise<void>;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* An anonymous usage event for the host's `onEvent` (ADR 0003). It never
|
|
1133
|
+
* carries file names, pixels, text the user typed or metadata values.
|
|
1134
|
+
*
|
|
1135
|
+
* @public
|
|
1136
|
+
*/
|
|
1137
|
+
declare interface ImageSessionEvent {
|
|
1138
|
+
readonly type: "open" | "execute" | "undo" | "redo" | "export";
|
|
1139
|
+
readonly outcome: "done" | "failed" | "cancelled";
|
|
1140
|
+
/** The types of the commands applied or undone. */
|
|
1141
|
+
readonly commands: readonly ImageCommand["type"][];
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* What an export produced, and what the summary before a download shows
|
|
1146
|
+
* (ADR 0003, ADR 0005).
|
|
1147
|
+
*
|
|
1148
|
+
* @public
|
|
1149
|
+
*/
|
|
1150
|
+
declare interface ImageSessionExport {
|
|
1151
|
+
readonly blob: Blob;
|
|
1152
|
+
readonly width: number;
|
|
1153
|
+
readonly height: number;
|
|
1154
|
+
/**
|
|
1155
|
+
* The kinds of metadata the source carried that the file doesn't: every
|
|
1156
|
+
* kind, since exports keep only the fields the user chose, which are
|
|
1157
|
+
* never these. Empty when the source carried none.
|
|
1158
|
+
*/
|
|
1159
|
+
readonly removed: readonly (keyof ImageMetadataPresence)[];
|
|
1160
|
+
/** The fields the user kept, which the file carries. */
|
|
1161
|
+
readonly kept: readonly (keyof ImageKeepableMetadata)[];
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* The session's state, for `useSyncExternalStore`: a new object on every
|
|
1166
|
+
* change (ADR 0003).
|
|
1167
|
+
*
|
|
1168
|
+
* @public
|
|
1169
|
+
*/
|
|
1170
|
+
declare interface ImageSessionSnapshot {
|
|
1171
|
+
/** `empty` until a file opens; `opening` while the first one is; then `ready`. */
|
|
1172
|
+
readonly status: "empty" | "opening" | "ready";
|
|
1173
|
+
/** The document, or `null` before a file is open. */
|
|
1174
|
+
readonly plan: ImagePlan | null;
|
|
1175
|
+
/** The document's source, or `null` before a file is open. */
|
|
1176
|
+
readonly source: ImageSessionSource | null;
|
|
1177
|
+
readonly canUndo: boolean;
|
|
1178
|
+
readonly canRedo: boolean;
|
|
1179
|
+
/** Whether a file is being opened. The current document stays until it's ready. */
|
|
1180
|
+
readonly opening: boolean;
|
|
1181
|
+
/** Whether an export is in progress. */
|
|
1182
|
+
readonly exporting: boolean;
|
|
1183
|
+
/** The limits the last open, edit or export came near: at or above their warnings. */
|
|
1184
|
+
readonly warnings: readonly ImageLimitName[];
|
|
1185
|
+
/** The last failure, until the next successful open, edit or export. */
|
|
1186
|
+
readonly error: ImageError | null;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* The document's source, as the editor shows it: its size and format, and
|
|
1191
|
+
* what metadata the file carried, which the export summary reports as
|
|
1192
|
+
* removed unless the user kept it (ADR 0005).
|
|
1193
|
+
*
|
|
1194
|
+
* @public
|
|
1195
|
+
*/
|
|
1196
|
+
declare interface ImageSessionSource extends ImageSourceInfo {
|
|
1197
|
+
/** Which kinds of metadata the file carried, never their values. */
|
|
1198
|
+
readonly metadata: ImageMetadataPresence;
|
|
1199
|
+
/** The fields the user may choose to keep, as the file had them. */
|
|
1200
|
+
readonly keepable: ImageKeepableMetadata;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* A width and a height, in whole pixels.
|
|
1205
|
+
*
|
|
1206
|
+
* @public
|
|
1207
|
+
*/
|
|
1208
|
+
declare interface ImageSize {
|
|
1209
|
+
readonly width: number;
|
|
1210
|
+
readonly height: number;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* A source the session holds, without its pixels: what the snapshot shows
|
|
1215
|
+
* (ADR 0003). Its size is the oriented size.
|
|
1216
|
+
*
|
|
1217
|
+
* @public
|
|
1218
|
+
*/
|
|
1219
|
+
declare interface ImageSourceInfo {
|
|
1220
|
+
readonly id: string;
|
|
1221
|
+
readonly format: ImageFormat;
|
|
1222
|
+
readonly width: number;
|
|
1223
|
+
readonly height: number;
|
|
1224
|
+
readonly frames: number;
|
|
1225
|
+
readonly hasAlpha: boolean;
|
|
1226
|
+
/** The bytes the decoded source takes in the worker: frames × width × height × 4. */
|
|
1227
|
+
readonly decodedBytes: number;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* The editor's stage (docs/adr/0007): the preview canvas, drawn by the
|
|
1232
|
+
* engine's render worker, with the designed states around it. With no image
|
|
1233
|
+
* it's a drop zone with a button to choose one; while an image opens, a
|
|
1234
|
+
* spinner with a cancel button over the current one; after a failure, the
|
|
1235
|
+
* catalogue's text for it.
|
|
1236
|
+
*
|
|
1237
|
+
* The canvas is `role="img"`, named with the image's size, and isn't in the
|
|
1238
|
+
* tab order. It's created in an effect, never rendered by React: a canvas
|
|
1239
|
+
* transferred to a worker can't be transferred again, and StrictMode mounts
|
|
1240
|
+
* effects twice.
|
|
1241
|
+
*
|
|
1242
|
+
* @public
|
|
1243
|
+
*/
|
|
1244
|
+
export declare function ImageStage(props: ImageStageProps): ReactNode;
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Props of {@link ImageStage}.
|
|
1248
|
+
*
|
|
1249
|
+
* @public
|
|
1250
|
+
*/
|
|
1251
|
+
export declare interface ImageStageProps {
|
|
1252
|
+
/** Extra classes on the stage. */
|
|
1253
|
+
readonly className?: string;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* A small rendering of a source for lists and frame strips. An `ImageBitmap`
|
|
1258
|
+
* is one; tests can supply their own. Close it when it's no longer shown.
|
|
1259
|
+
*
|
|
1260
|
+
* @public
|
|
1261
|
+
*/
|
|
1262
|
+
declare interface ImageThumbnail {
|
|
1263
|
+
readonly width: number;
|
|
1264
|
+
readonly height: number;
|
|
1265
|
+
close(): void;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* One of the editor's tools (docs/adr/0007, sdk-core ADR 0009).
|
|
1270
|
+
*
|
|
1271
|
+
* @public
|
|
1272
|
+
*/
|
|
1273
|
+
export declare type ImageTool = Tool<ImageToolState, ImageToolContext, undefined>;
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* The editor's toolbar (docs/adr/0007): ui's Toolbar, one group per toolbar
|
|
1277
|
+
* group of the registry, one button per tool, disabled when it can't run,
|
|
1278
|
+
* with the tool's shortcuts as `aria-keyshortcuts`.
|
|
1279
|
+
*
|
|
1280
|
+
* @public
|
|
1281
|
+
*/
|
|
1282
|
+
export declare function ImageToolbar(props: ImageToolbarProps): ReactNode;
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Props of {@link ImageToolbar}.
|
|
1286
|
+
*
|
|
1287
|
+
* @public
|
|
1288
|
+
*/
|
|
1289
|
+
export declare interface ImageToolbarProps {
|
|
1290
|
+
/** The editor's tools, from `createToolRegistry`. */
|
|
1291
|
+
readonly registry: ToolRegistry<ImageTool>;
|
|
1292
|
+
/** The editor's shortcuts, for each button's `aria-keyshortcuts`. */
|
|
1293
|
+
readonly shortcuts?: ShortcutRegistry;
|
|
1294
|
+
/** What the tools run against. */
|
|
1295
|
+
readonly context: ImageToolContext;
|
|
1296
|
+
/** Icon components by name, over the SDK's own. */
|
|
1297
|
+
readonly icons: Readonly<Record<string, IconComponent>>;
|
|
1298
|
+
readonly className?: string;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* What a tool runs against.
|
|
1303
|
+
*
|
|
1304
|
+
* @public
|
|
1305
|
+
*/
|
|
1306
|
+
export declare interface ImageToolContext {
|
|
1307
|
+
readonly session: ImageSession;
|
|
1308
|
+
readonly view: Store<{
|
|
1309
|
+
readonly zoom: number;
|
|
1310
|
+
readonly pan: {
|
|
1311
|
+
readonly x: number;
|
|
1312
|
+
readonly y: number;
|
|
1313
|
+
};
|
|
1314
|
+
}>;
|
|
1315
|
+
/** The editor's own state, which tools such as crop take over. */
|
|
1316
|
+
readonly editor: Store<ImageEditorState>;
|
|
1317
|
+
/** Asks the user for an image, as the open tool does. */
|
|
1318
|
+
readonly chooseFile: () => void;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* Every tool the editor knows, in their default order (docs/adr/0007).
|
|
1323
|
+
*
|
|
1324
|
+
* @public
|
|
1325
|
+
*/
|
|
1326
|
+
export declare const imageTools: readonly ImageTool[];
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* What a tool reads to decide whether it's available, enabled or active.
|
|
1330
|
+
*
|
|
1331
|
+
* @public
|
|
1332
|
+
*/
|
|
1333
|
+
export declare interface ImageToolState {
|
|
1334
|
+
readonly snapshot: ImageSessionSnapshot;
|
|
1335
|
+
readonly editor: ImageEditorState;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* The stage's zoom and pan: view state, outside the session and its history
|
|
1340
|
+
* (ADR 0003, docs/adr/0007). Zoom 1 fits the image to the stage.
|
|
1341
|
+
*
|
|
1342
|
+
* @public
|
|
1343
|
+
*/
|
|
1344
|
+
export declare interface ImageViewState {
|
|
1345
|
+
readonly zoom: number;
|
|
1346
|
+
readonly pan: {
|
|
1347
|
+
readonly x: number;
|
|
1348
|
+
readonly y: number;
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* Sets or removes the base's crop, in whole pixels of the oriented source.
|
|
1354
|
+
*
|
|
1355
|
+
* @public
|
|
1356
|
+
*/
|
|
1357
|
+
declare interface SetCropCommand {
|
|
1358
|
+
readonly type: "image.setCrop";
|
|
1359
|
+
readonly crop: ImageCrop | null;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Sets some of the base's develop adjustments; the others keep their values
|
|
1364
|
+
* (ADR 0006).
|
|
1365
|
+
*
|
|
1366
|
+
* @public
|
|
1367
|
+
*/
|
|
1368
|
+
declare interface SetDevelopCommand {
|
|
1369
|
+
readonly type: "image.setDevelop";
|
|
1370
|
+
readonly values: Partial<ImageDevelop>;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* Sets the base's filter preset and strength, or removes it with `null`.
|
|
1375
|
+
*
|
|
1376
|
+
* @public
|
|
1377
|
+
*/
|
|
1378
|
+
declare interface SetFilterCommand {
|
|
1379
|
+
readonly type: "image.setFilter";
|
|
1380
|
+
readonly filter: ImageFilter | null;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Sets one metadata field to keep on export. An empty value keeps nothing.
|
|
1385
|
+
*
|
|
1386
|
+
* @public
|
|
1387
|
+
*/
|
|
1388
|
+
declare interface SetMetadataCommand {
|
|
1389
|
+
readonly type: "image.setMetadata";
|
|
1390
|
+
readonly field: keyof ImageKeepableMetadata;
|
|
1391
|
+
readonly value: string;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Sets the base's rotation and flips.
|
|
1396
|
+
*
|
|
1397
|
+
* @public
|
|
1398
|
+
*/
|
|
1399
|
+
declare interface SetOrientationCommand {
|
|
1400
|
+
readonly type: "image.setOrientation";
|
|
1401
|
+
readonly orientation: ImageOrientation_2;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* Sets the export's size.
|
|
1406
|
+
*
|
|
1407
|
+
* @public
|
|
1408
|
+
*/
|
|
1409
|
+
declare interface SetOutputCommand {
|
|
1410
|
+
readonly type: "image.setOutput";
|
|
1411
|
+
readonly output: ImageOutput;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* The session's snapshot, re-rendering whenever it changes, through
|
|
1416
|
+
* `useSyncExternalStore`, so it's safe with concurrent and server rendering.
|
|
1417
|
+
*
|
|
1418
|
+
* @public
|
|
1419
|
+
*/
|
|
1420
|
+
export declare function useImageDocument(): ImageSessionSnapshot;
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* The editor's own state: the active tool, a crop in progress, and a
|
|
1424
|
+
* gesture's transient plan (docs/adr/0007).
|
|
1425
|
+
*
|
|
1426
|
+
* @public
|
|
1427
|
+
*/
|
|
1428
|
+
export declare function useImageEditorState(): readonly [ImageEditorState, Store<ImageEditorState>];
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* The SDK's text for the provider's locale and overrides (ADR 0019).
|
|
1432
|
+
*
|
|
1433
|
+
* @public
|
|
1434
|
+
*/
|
|
1435
|
+
export declare function useImageMessages(): Messages<ImageMessageCatalogue>;
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* The session of the nearest `ImageEditorProvider`, to open images, run
|
|
1439
|
+
* commands, undo and export.
|
|
1440
|
+
*
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
export declare function useImageSession(): ImageSession;
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* The stage's zoom and pan, and the store to change them (docs/adr/0007).
|
|
1447
|
+
*
|
|
1448
|
+
* @public
|
|
1449
|
+
*/
|
|
1450
|
+
export declare function useImageView(): readonly [ImageViewState, Store<ImageViewState>];
|
|
1451
|
+
|
|
1452
|
+
export { }
|