@hussmartinez/image-sdk 0.3.0 → 0.4.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/dist/element.d.ts CHANGED
@@ -23,7 +23,7 @@ import { SdkError } from '@hussmartinez/sdk-core';
23
23
  * Registers `<hm-image-editor>`, or the tag you name, and returns its class
24
24
  * (docs/adr/0007, sdk-core ADR 0040): the attributes `theme`, `locale` and
25
25
  * `tools`; the properties `file`, `plan`, `filePolicy`, `assetsUrl`,
26
- * `messages`, `engine` and `processor`; the methods `open`, `execute`,
26
+ * `messages`, `engine` and `processor`; the methods `open`, `insertImage`, `execute`,
27
27
  * `export`, `undo` and `redo`; and the events `hm-image-editor-change`,
28
28
  * `-event`, `-export` and `-error`. Calling it again returns the same class.
29
29
  *
@@ -90,11 +90,11 @@ declare interface ImageCallOptions {
90
90
 
91
91
  /**
92
92
  * Every edit to an {@link ImagePlan}: plain, structured-cloneable data
93
- * (ADR 0003). Feature pull requests add their own commands to this union.
93
+ * (ADR 0003, ADR 0009).
94
94
  *
95
95
  * @public
96
96
  */
97
- declare type ImageCommand = SetCropCommand | SetOrientationCommand | SetOutputCommand | SetMetadataCommand | SetDevelopCommand | SetFilterCommand;
97
+ declare type ImageCommand = SetCropCommand | SetOrientationCommand | SetOutputCommand | SetMetadataCommand | SetDevelopCommand | SetFilterCommand | InsertLayersCommand | RemoveLayersCommand | MoveLayersCommand | UpdateLayersCommand | InsertRedactionsCommand | RemoveRedactionsCommand | MoveRedactionsCommand | UpdateRedactionsCommand | ImageInverseCommand;
98
98
 
99
99
  /**
100
100
  * A rectangle in whole pixels of the oriented source: `x` and `y` from its
@@ -149,7 +149,7 @@ export declare type ImageEditorElementEvent = "change" | "event" | "export" | "e
149
149
  *
150
150
  * @public
151
151
  */
152
- export declare type ImageEditorElementMethods = Pick<ImageEditorHandle, "open" | "execute" | "export" | "undo" | "redo">;
152
+ export declare type ImageEditorElementMethods = Pick<ImageEditorHandle, "open" | "insertImage" | "execute" | "export" | "undo" | "redo">;
153
153
 
154
154
  /**
155
155
  * The `<hm-image-editor>` element's props: its attributes, `theme`, `locale`
@@ -173,7 +173,7 @@ export declare interface ImageEditorElementProps {
173
173
  /** Where the application serves the package's `dist/assets/` directory. */
174
174
  assetsUrl?: string | URL;
175
175
  /** Text overrides, typed against the English catalogue. */
176
- messages?: MessageOverrides<ImageMessageCatalogue>;
176
+ messages?: MessageOverrides<ImageEditorMessageCatalogue>;
177
177
  engine?: ImageEngine;
178
178
  processor?: ImageProcessor;
179
179
  }
@@ -188,6 +188,12 @@ declare interface ImageEditorHandle {
188
188
  readonly session: ImageSession;
189
189
  /** Opens an image, replacing the current one once it has opened. */
190
190
  open(file: Blob): Promise<void>;
191
+ /**
192
+ * Adds an image as a layer in the middle of the image as it's shown, as
193
+ * one undoable step, and shows the layers with it selected. A file that
194
+ * can't be added is reported on the stage, as a failed open is.
195
+ */
196
+ insertImage(file: Blob): Promise<void>;
191
197
  /** Applies commands as one undoable step. */
192
198
  execute(commands: ImageCommand | readonly ImageCommand[]): void;
193
199
  /** Renders and encodes the image as it is now. */
@@ -198,6 +204,381 @@ declare interface ImageEditorHandle {
198
204
  redo(): void;
199
205
  }
200
206
 
207
+ /**
208
+ * The type of {@link imageEditorMessages}, for typing the editor's
209
+ * `messages` overrides with `MessageOverrides<ImageEditorMessageCatalogue>`.
210
+ *
211
+ * @public
212
+ */
213
+ export declare type ImageEditorMessageCatalogue = typeof imageEditorMessages;
214
+
215
+ /**
216
+ * The English message catalogue of the SDK's components: `imageMessages`,
217
+ * with sdk-core's text, errors and warnings; `@hussmartinez/ui`'s, for the
218
+ * ui components the editor renders (sdk-core ADR 0046); and the text of the
219
+ * editor, its stage, toolbar and tools, its panels and the export dialog.
220
+ *
221
+ * `ImageEditor`, `ImageEditorProvider` and `<hm-image-editor>` each build
222
+ * one `Messages` object from it, with the host's locale and overrides, and
223
+ * the editor gives the same object to its own components and to ui's.
224
+ * Override any of its keys through their `messages`, typed with
225
+ * `ImageEditorMessageCatalogue`.
226
+ *
227
+ * It's defined in the React entry, so the server-safe `.` entry and its
228
+ * `imageMessages` carry no interface text (docs/adr/0012).
229
+ *
230
+ * @public
231
+ */
232
+ export declare const imageEditorMessages: {
233
+ readonly "editor.engineUnavailable": "Image processing stopped. Reload this page or reopen the editor, then choose the image again. Unsaved edits will be lost unless your application has saved them.";
234
+ readonly "editor.label": "Image editor";
235
+ readonly "editor.preview": "Edited image preview, {width, number} × {height, number}";
236
+ readonly "editor.empty": "Open an image to start editing. It stays on this device.";
237
+ readonly "editor.choose": "Choose an image";
238
+ readonly "editor.dropHint": "or drop it here";
239
+ readonly "editor.opening": "Opening the image…";
240
+ readonly "editor.cancel": "Cancel";
241
+ readonly "editor.opened": "Image opened, {width, number} × {height, number}.";
242
+ readonly "editor.undid": "Undid {action}.";
243
+ readonly "editor.redid": "Redid {action}.";
244
+ readonly "actions.image.setCrop": "crop";
245
+ readonly "actions.image.setOrientation": "rotate or flip";
246
+ readonly "actions.image.setOutput": "size";
247
+ readonly "actions.image.setMetadata": "metadata";
248
+ readonly "actions.image.setDevelop": "adjustment";
249
+ readonly "actions.image.setFilter": "filter";
250
+ readonly "actions.image.insertLayers": "layer";
251
+ readonly "actions.image.removeLayers": "layer";
252
+ readonly "actions.image.restoreLayers": "layer";
253
+ readonly "actions.image.moveLayers": "layer order";
254
+ readonly "actions.image.setLayerOrder": "layer order";
255
+ readonly "actions.image.updateLayers": "layer change";
256
+ readonly "actions.image.insertRedactions": "redaction";
257
+ readonly "actions.image.removeRedactions": "redaction";
258
+ readonly "actions.image.restoreRedactions": "redaction";
259
+ readonly "actions.image.moveRedactions": "redaction order";
260
+ readonly "actions.image.setRedactionOrder": "redaction order";
261
+ readonly "actions.image.updateRedactions": "redaction change";
262
+ readonly "toolbar.label": "Image tools";
263
+ readonly "toolbar.groups.file": "File";
264
+ readonly "toolbar.groups.history": "History";
265
+ readonly "toolbar.groups.orientation": "Rotate";
266
+ readonly "toolbar.groups.zoom": "Zoom";
267
+ readonly "toolbar.groups.other": "More tools";
268
+ readonly "tools.open": "Open image";
269
+ readonly "tools.undo": "Undo";
270
+ readonly "tools.redo": "Redo";
271
+ readonly "tools.rotate-left": "Rotate left";
272
+ readonly "tools.rotate-right": "Rotate right";
273
+ readonly "tools.zoom-in": "Zoom in";
274
+ readonly "tools.zoom-out": "Zoom out";
275
+ readonly "tools.zoom-fit": "Fit to the stage";
276
+ readonly "tools.crop": "Crop";
277
+ readonly "tools.flip-horizontal": "Flip horizontally";
278
+ readonly "tools.flip-vertical": "Flip vertically";
279
+ readonly "toolbar.groups.crop": "Crop";
280
+ readonly "crop.frame": "Crop area";
281
+ readonly "crop.frameDescription": "{width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; with Shift, they resize it; Enter applies and Escape cancels.";
282
+ readonly "crop.size": "{width, number} × {height, number}, from {x, number}, {y, number}";
283
+ readonly "crop.panel": "Crop";
284
+ readonly "crop.x": "Left";
285
+ readonly "crop.y": "Top";
286
+ readonly "crop.width": "Width";
287
+ readonly "crop.height": "Height";
288
+ readonly "crop.aspect": "Aspect ratio";
289
+ readonly "crop.aspects.free": "Free";
290
+ readonly "crop.aspects.original": "Original";
291
+ readonly "crop.aspects.ratio": "{width}:{height}";
292
+ readonly "crop.apply": "Apply crop";
293
+ readonly "crop.cancel": "Cancel";
294
+ readonly "crop.reset": "Whole image";
295
+ readonly "crop.applied": "Cropped to {width, number} × {height, number}.";
296
+ readonly "tools.redact": "Redact";
297
+ readonly "toolbar.groups.redact": "Redact";
298
+ readonly "redact.panel": "Redact";
299
+ readonly "redact.intro": "Cover parts of the image. Only the exported image is redacted: the original stays in the editor.";
300
+ readonly "redact.add": "Add area";
301
+ readonly "redact.done": "Done";
302
+ readonly "redact.mode": "Cover with";
303
+ readonly "redact.modes.solid": "Solid colour";
304
+ readonly "redact.modes.pixelate": "Pixelation";
305
+ readonly "redact.pixelateHint": "Pixelation may not hide text. For text and numbers, use a solid colour.";
306
+ readonly "redact.colour": "Colour";
307
+ readonly "redact.colours.black": "Black";
308
+ readonly "redact.colours.white": "White";
309
+ readonly "redact.x": "Left";
310
+ readonly "redact.y": "Top";
311
+ readonly "redact.width": "Width";
312
+ readonly "redact.height": "Height";
313
+ readonly "redact.areas": "Redacted areas";
314
+ readonly "redact.none": "No areas yet. Drag across the image, or add one.";
315
+ readonly "redact.area": "Area {index, number}: {mode}, {width, number} × {height, number}";
316
+ readonly "redact.modeNames.solid": "solid colour";
317
+ readonly "redact.modeNames.pixelate": "pixelated";
318
+ readonly "redact.remove": "Remove area {index, number}";
319
+ readonly "redact.frame": "Redacted area {index, number} of {count, number}";
320
+ readonly "redact.frameDescription": "{mode}, {width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; with Shift, they resize it; Delete removes it and Escape ends redacting.";
321
+ readonly "redact.added": {
322
+ readonly $plural: "count";
323
+ } & {
324
+ readonly one: "Area added. {count} area is redacted.";
325
+ readonly other: "Area added. {count, number} areas are redacted.";
326
+ };
327
+ readonly "redact.removedLast": "Area removed. Nothing is redacted.";
328
+ readonly "redact.removed": {
329
+ readonly $plural: "count";
330
+ } & {
331
+ readonly one: "Area removed. {count} area is redacted.";
332
+ readonly other: "Area removed. {count, number} areas are redacted.";
333
+ };
334
+ readonly "tools.add-text": "Add text";
335
+ readonly "tools.add-rectangle": "Add a rectangle";
336
+ readonly "tools.add-ellipse": "Add an ellipse";
337
+ readonly "tools.add-image": "Add an image";
338
+ readonly "toolbar.groups.add": "Add";
339
+ readonly "editor.inserting": "Adding the image…";
340
+ readonly "layers.text": "Text";
341
+ readonly "layers.font": "Font";
342
+ readonly "layers.fonts.sans-serif": "Sans";
343
+ readonly "layers.fonts.serif": "Serif";
344
+ readonly "layers.fonts.monospace": "Mono";
345
+ readonly "layers.align": "Alignment";
346
+ readonly "layers.alignments.start": "Start";
347
+ readonly "layers.alignments.center": "Centre";
348
+ readonly "layers.alignments.end": "End";
349
+ readonly "layers.bold": "Bold";
350
+ readonly "layers.colour": "Colour";
351
+ readonly "layers.fill": "Fill";
352
+ readonly "layers.outline": "Outline";
353
+ readonly "layers.fillColour": "Fill colour";
354
+ readonly "layers.outlineColour": "Outline colour";
355
+ readonly "layers.outlineWidth": "Outline width";
356
+ readonly "layers.colours.black": "Black";
357
+ readonly "layers.colours.white": "White";
358
+ readonly "layers.colours.red": "Red";
359
+ readonly "layers.colours.yellow": "Yellow";
360
+ readonly "layers.colours.green": "Green";
361
+ readonly "layers.colours.blue": "Blue";
362
+ readonly "tools.layers": "Layers";
363
+ readonly "toolbar.groups.layers": "Layers";
364
+ readonly "layers.panel": "Layers";
365
+ readonly "layers.list": "Layers, the top one first";
366
+ readonly "layers.none": "No layers yet. Add text, a shape or an image from the toolbar.";
367
+ readonly "layers.kinds.text": "Text";
368
+ readonly "layers.kinds.rectangle": "Rectangle";
369
+ readonly "layers.kinds.ellipse": "Ellipse";
370
+ readonly "layers.kinds.image": "Image";
371
+ readonly "layers.visible": "Show {name}";
372
+ readonly "layers.selected": "Selected layer";
373
+ readonly "layers.moveUp": "Move up";
374
+ readonly "layers.moveDown": "Move down";
375
+ readonly "layers.mirror": "Mirror";
376
+ readonly "layers.duplicate": "Duplicate";
377
+ readonly "layers.remove": "Delete";
378
+ readonly "layers.name": "Name";
379
+ readonly "layers.x": "Left";
380
+ readonly "layers.y": "Top";
381
+ readonly "layers.width": "Width";
382
+ readonly "layers.height": "Height";
383
+ readonly "layers.rotation": "Turn, in degrees";
384
+ readonly "layers.opacity": "Opacity, in percent";
385
+ readonly "layers.done": "Done";
386
+ readonly "layers.frame": "Layer {index, number} of {count, number}: {name}";
387
+ readonly "layers.frameDescription": "{width, number} × {height, number} pixels, from {x, number}, {y, number}, turned {degrees, number}°. Arrow keys move it; with Shift, they resize it; Delete removes it and Escape closes the layers.";
388
+ readonly "layers.movedUp": "Moved {name} up. It's layer {index, number} of {count, number}.";
389
+ readonly "layers.movedDown": "Moved {name} down. It's layer {index, number} of {count, number}.";
390
+ readonly "layers.duplicated": "Duplicated {name}.";
391
+ readonly "layers.removed": "Deleted {name}.";
392
+ readonly "inspector.label": "Panels";
393
+ readonly "inspector.adjust": "Adjust";
394
+ readonly "inspector.filters": "Filters";
395
+ readonly "inspector.info": "Info";
396
+ readonly "notices.label": "Notices";
397
+ readonly "notices.dismiss": "Dismiss";
398
+ readonly "notices.colourProfile": "This image has a colour profile. Colours outside sRGB will be clipped in the exported file.";
399
+ readonly "info.panel": "Image info";
400
+ readonly "info.size": "Size";
401
+ readonly "info.sizeValue": "{width, number} × {height, number} pixels";
402
+ readonly "info.format": "Format";
403
+ readonly "info.formats.png": "PNG";
404
+ readonly "info.formats.jpeg": "JPEG";
405
+ readonly "info.formats.webp": "WebP";
406
+ readonly "info.formats.gif": "GIF";
407
+ readonly "info.formats.avif": "AVIF";
408
+ readonly "info.formats.heif": "HEIF";
409
+ readonly "info.formats.bmp": "BMP";
410
+ readonly "info.frames": "Frames";
411
+ readonly "info.fileSize": "File size";
412
+ readonly "info.fileSizeValue": "{size, fileSize}";
413
+ readonly "info.metadata": "Metadata in the file";
414
+ readonly "info.metadataNone": "None";
415
+ readonly "info.kept": "Kept on export";
416
+ readonly "info.keptNone": "Nothing";
417
+ readonly "develop.panel": "Adjust";
418
+ readonly "develop.temperature": "Temperature";
419
+ readonly "develop.tint": "Tint";
420
+ readonly "develop.exposure": "Exposure";
421
+ readonly "develop.highlights": "Highlights";
422
+ readonly "develop.shadows": "Shadows";
423
+ readonly "develop.contrast": "Contrast";
424
+ readonly "develop.saturation": "Saturation";
425
+ readonly "develop.vibrance": "Vibrance";
426
+ readonly "develop.reset": "Reset {name}";
427
+ readonly "develop.resetAll": "Reset all";
428
+ readonly "develop.wasReset": "All adjustments reset.";
429
+ readonly "filters.panel": "Filters";
430
+ readonly "filters.label": "Filter";
431
+ readonly "filters.none": "None";
432
+ readonly "filters.vivid": "Vivid";
433
+ readonly "filters.warm": "Warm";
434
+ readonly "filters.cool": "Cool";
435
+ readonly "filters.fade": "Fade";
436
+ readonly "filters.mono": "Mono";
437
+ readonly "filters.noir": "Noir";
438
+ readonly "filters.sepia": "Sepia";
439
+ readonly "filters.strength": "Strength";
440
+ readonly "toolbar.groups.export": "Export";
441
+ readonly "tools.export": "Export";
442
+ readonly "export.title": "Export image";
443
+ readonly "export.description": "The file is made on this device, and nothing is uploaded.";
444
+ readonly "export.format": "Format";
445
+ readonly "export.formats.png": "PNG";
446
+ readonly "export.formats.jpeg": "JPEG";
447
+ readonly "export.formats.webp": "WebP";
448
+ readonly "export.quality": "Quality";
449
+ readonly "export.qualityValue": "{quality, number}%";
450
+ readonly "export.size": "Size";
451
+ readonly "export.sizes.scale": "Scale";
452
+ readonly "export.sizes.fit": "Fit in a box";
453
+ readonly "export.scale": "Scale, in percent";
454
+ readonly "export.fitWidth": "Largest width";
455
+ readonly "export.fitHeight": "Largest height";
456
+ readonly "export.fields": "Details to include";
457
+ readonly "export.fieldsHint": "Only what you fill in is written to the file.";
458
+ readonly "export.field.title": "Title";
459
+ readonly "export.field.description": "Description";
460
+ readonly "export.field.artist": "Artist";
461
+ readonly "export.field.copyright": "Copyright";
462
+ readonly "export.summary": "Summary";
463
+ readonly "export.output": "{width, number} × {height, number} pixels, {format}";
464
+ readonly "export.removed": "Removed from the file";
465
+ readonly "export.removedNone": "The image had no other details to remove.";
466
+ readonly "export.redacted": {
467
+ readonly $plural: "count";
468
+ } & {
469
+ readonly one: "{count} area is redacted.";
470
+ readonly other: "{count, number} areas are redacted.";
471
+ };
472
+ readonly "export.redactedPixelated": "Pixelated areas may not hide text.";
473
+ readonly "export.kind.location": "Location";
474
+ readonly "export.kind.camera": "Camera details";
475
+ readonly "export.kind.timestamps": "Dates and times";
476
+ readonly "export.kind.thumbnail": "Embedded thumbnail";
477
+ readonly "export.kind.colourProfile": "Colour profile: colours outside sRGB are clipped";
478
+ readonly "export.kind.other": "Other metadata";
479
+ readonly "export.kept": "Kept in the file";
480
+ readonly "export.confirm": "Export";
481
+ readonly "export.cancel": "Cancel";
482
+ readonly "export.progress": "Exporting the image";
483
+ readonly "export.stop": "Stop exporting";
484
+ readonly "export.cancelled": "Export stopped.";
485
+ readonly "export.done": "Exported a {format} of {size, fileSize}.";
486
+ readonly "export.ready": "{width, number} × {height, number} pixels, {format}, {size, fileSize}";
487
+ readonly "export.download": "Download";
488
+ readonly "export.close": "Done";
489
+ readonly "colorField.swatches": "swatches";
490
+ readonly "dialog.close": "Close";
491
+ readonly "fileDropZone.choose": "Choose a file";
492
+ readonly "fileDropZone.chooseMultiple": "Choose files";
493
+ readonly "fileDropZone.hint": "or drop it here";
494
+ readonly "fileDropZone.hintMultiple": "or drop them here";
495
+ readonly "progress.label": "Progress";
496
+ readonly "spinner.label": "Loading";
497
+ readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
498
+ readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
499
+ readonly "errors.INVALID_IMAGE": "This file isn't a valid image, or it's too damaged to open.";
500
+ readonly "errors.UNSUPPORTED_FORMAT": "This image format isn't supported. Try converting the file to PNG or JPEG, then open it again.";
501
+ readonly "errors.DECODE_FAILED": "This browser can't open this kind of image. Try another browser, or convert the file to PNG or JPEG.";
502
+ readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
503
+ readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't an image project.";
504
+ readonly "errors.UNSUPPORTED_PLAN": "This image has edits this version can't show. Update the application and try again.";
505
+ readonly "errors.IMAGE_TOO_LARGE": "This image has more pixels than the editor can handle. Try a smaller version of it.";
506
+ readonly "errors.IMAGE_DIMENSION_TOO_LARGE": "This image is {actual, number} pixels across, which is over the {maximum, number}-pixel limit.";
507
+ readonly "errors.TOO_MANY_FRAMES": {
508
+ readonly $plural: "maximum";
509
+ } & {
510
+ readonly one: "This animation has {actual, number} frames, which is over the {maximum}-frame limit.";
511
+ readonly other: "This animation has {actual, number} frames, which is over the {maximum, number}-frame limit.";
512
+ };
513
+ 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.";
514
+ readonly "errors.TOO_MANY_LAYERS": {
515
+ readonly $plural: "maximum";
516
+ } & {
517
+ readonly one: "An image can have {maximum} layer. Merge or delete layers, and try again.";
518
+ readonly other: "An image can have up to {maximum, number} layers. Merge or delete layers, and try again.";
519
+ };
520
+ readonly "warnings.maxImagePixels": "This image is large, and may be slow to edit on some devices.";
521
+ readonly "warnings.maxImageDimension": "This image is very wide or tall, and may be slow to edit.";
522
+ readonly "warnings.maxFrames": {
523
+ readonly $plural: "actual";
524
+ } & {
525
+ readonly one: "This animation has {actual} frame.";
526
+ readonly other: "This animation has {actual, number} frames, and may be slow to edit and export.";
527
+ };
528
+ readonly "warnings.maxSessionSize": "The open images use {actual, fileSize} of memory. Clearing the undo history frees memory.";
529
+ readonly "warnings.maxLayers": {
530
+ readonly $plural: "actual";
531
+ } & {
532
+ readonly one: "This image has {actual} layer.";
533
+ readonly other: "This image has {actual, number} layers, and may be slow to edit and export.";
534
+ };
535
+ readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
536
+ readonly "errors.ABORTED": "The operation was cancelled.";
537
+ readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
538
+ readonly "errors.WORKER_START_FAILED": "The file processor couldn't start. Reload the page and try again.";
539
+ readonly "errors.WORKER_PROTOCOL_MISMATCH": "The file processor is out of date. Reload the page to update it.";
540
+ readonly "errors.WORKER_CRASHED": "The file processor stopped unexpectedly. Please try again.";
541
+ readonly "errors.WORKER_TERMINATED": "The operation was stopped before it finished. Please try again.";
542
+ readonly "errors.WORKER_METHOD_NOT_FOUND": "This operation isn't available. Reload the page and try again.";
543
+ readonly "errors.WORKER_DATA_NOT_CLONEABLE": "Something went wrong while processing the file. Please try again.";
544
+ readonly "errors.UNSUPPORTED_ENVIRONMENT": "This browser doesn't support a feature this tool needs. Update your browser, or try another one.";
545
+ readonly "errors.FILE_TOO_LARGE": "This file is {actual, fileSize}, which is over the {maximum, fileSize} limit.";
546
+ readonly "errors.TOO_MANY_FILES": {
547
+ readonly $plural: "maximum";
548
+ } & {
549
+ readonly one: "You can add {maximum} file at a time.";
550
+ readonly other: "You can add up to {maximum} files at a time.";
551
+ };
552
+ readonly "errors.DECODED_SIZE_TOO_LARGE": "This file expands to more than {maximum, fileSize} when opened, which is over the limit.";
553
+ readonly "errors.PROCESSING_TIME_EXCEEDED": "Processing this file took too long and was stopped.";
554
+ readonly "warnings.maxFileSize": "This file is {actual, fileSize}. Large files may be slow to process.";
555
+ readonly "warnings.maxFiles": "Adding {actual} files at once may be slow.";
556
+ readonly "warnings.maxDecodedSize": "This file is very large once opened and may be slow to process.";
557
+ readonly "warnings.maxProcessingTime": "This is taking longer than usual.";
558
+ readonly "keys.control": "Ctrl";
559
+ readonly "keys.alt": "Alt";
560
+ readonly "keys.shift": "Shift";
561
+ readonly "keys.meta": "Meta";
562
+ readonly "keys.apple.control": "\u2303";
563
+ readonly "keys.apple.alt": "\u2325";
564
+ readonly "keys.apple.shift": "\u21E7";
565
+ readonly "keys.apple.meta": "\u2318";
566
+ readonly "keys.space": "Space";
567
+ readonly "keys.enter": "Enter";
568
+ readonly "keys.escape": "Esc";
569
+ readonly "keys.tab": "Tab";
570
+ readonly "keys.delete": "Delete";
571
+ readonly "keys.backspace": "Backspace";
572
+ readonly "keys.arrowUp": "\u2191";
573
+ readonly "keys.arrowDown": "\u2193";
574
+ readonly "keys.arrowLeft": "\u2190";
575
+ readonly "keys.arrowRight": "\u2192";
576
+ readonly "keys.home": "Home";
577
+ readonly "keys.end": "End";
578
+ readonly "keys.pageUp": "Page Up";
579
+ readonly "keys.pageDown": "Page Down";
580
+ };
581
+
201
582
  /**
202
583
  * The port for reading images: probe a file's headers, decode it into a
203
584
  * source the engine holds, make thumbnails and release sources (ADR 0001,
@@ -288,6 +669,10 @@ declare class ImageError extends SdkError<ImageErrorCode> {
288
669
  * valid in its format. `details.reason` says why (`ImageDocumentRejection`).
289
670
  * A document of another format, or a later version, is `UNSUPPORTED_FORMAT`
290
671
  * instead, with `details.reason` `unknown-format` or `unknown-format-version`.
672
+ * - `UNSUPPORTED_PLAN`: a plan holds something the renderer or processor
673
+ * can't draw, such as a layer kind from a later release. Nothing is drawn
674
+ * or exported without it (ADR 0009). `details.reason` names the part:
675
+ * `layers`, `redactions` or `animation`.
291
676
  * - `IMAGE_TOO_LARGE`: an image, a frame, the canvas or the export exceeds
292
677
  * the `maxImagePixels` limit.
293
678
  * - `IMAGE_DIMENSION_TOO_LARGE`: a width or height exceeds the
@@ -303,7 +688,7 @@ declare class ImageError extends SdkError<ImageErrorCode> {
303
688
  *
304
689
  * @public
305
690
  */
306
- 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";
691
+ declare type ImageErrorCode = SdkCoreErrorCode | "INVALID_IMAGE" | "UNSUPPORTED_FORMAT" | "DECODE_FAILED" | "INVALID_COMMAND" | "INVALID_DOCUMENT" | "UNSUPPORTED_PLAN" | "IMAGE_TOO_LARGE" | "IMAGE_DIMENSION_TOO_LARGE" | "TOO_MANY_FRAMES" | "SESSION_TOO_LARGE" | "TOO_MANY_LAYERS";
307
692
 
308
693
  /**
309
694
  * The file an export produces (ADR 0001). `quality`, from 0 to 1, applies to
@@ -417,367 +802,202 @@ declare type ImageFilterPreset = (typeof FILTER_PRESETS)[number];
417
802
  declare type ImageFormat = "png" | "jpeg" | "webp" | "gif" | "avif" | "heif" | "bmp";
418
803
 
419
804
  /**
420
- * The metadata fields a user may keep on export (ADR 0005). Empty strings
421
- * mean the field isn't written.
805
+ * Another image, drawn to fill its box (ADR 0009).
422
806
  *
423
807
  * @public
424
808
  */
425
- declare interface ImageKeepableMetadata {
426
- readonly title: string;
427
- readonly description: string;
428
- readonly artist: string;
429
- readonly copyright: string;
809
+ declare interface ImageImageLayer extends ImageLayerCommon, ImageLayerBox {
810
+ readonly kind: "image";
811
+ /** The id of a registered source. */
812
+ readonly source: string;
813
+ /** The part of that source to draw, in its own pixels, or `null` for all of it. */
814
+ readonly crop: ImageCrop | null;
430
815
  }
431
816
 
432
817
  /**
433
- * The type of {@link imageLimitDefinitions}.
818
+ * Options for {@link ImageSession.insertImage}.
434
819
  *
435
820
  * @public
436
821
  */
437
- declare type ImageLimitDefinitions = typeof imageLimitDefinitions;
822
+ declare interface ImageInsertOptions {
823
+ readonly signal?: AbortSignal;
824
+ /**
825
+ * The commands that add the image to the plan, instead of the default
826
+ * layer: given the new source and the plan as it is.
827
+ */
828
+ readonly place?: (source: ImageSessionSource, plan: ImagePlan) => ImageCommand | readonly ImageCommand[];
829
+ }
438
830
 
439
831
  /**
440
- * The image SDK's limit definitions: sdk-core's core limits with image
441
- * defaults, plus five for images (ADR 0004).
442
- *
443
- * | Limit | Code | Default maximum | Default warning |
444
- * |---|---|---|---|
445
- * | `maxFileSize` | `FILE_TOO_LARGE` | 100 MB | 50 MB |
446
- * | `maxFiles` | `TOO_MANY_FILES` | 20 | none |
447
- * | `maxDecodedSize` | `DECODED_SIZE_TOO_LARGE` | 1 GB | 400 MB |
448
- * | `maxProcessingTime` | `PROCESSING_TIME_EXCEEDED` | 120 s | none |
449
- * | `maxImagePixels` | `IMAGE_TOO_LARGE` | 50 megapixels | 24 megapixels |
450
- * | `maxImageDimension` | `IMAGE_DIMENSION_TOO_LARGE` | 16,384 pixels | none |
451
- * | `maxFrames` | `TOO_MANY_FRAMES` | 300 | 100 |
452
- * | `maxSessionSize` | `SESSION_TOO_LARGE` | 1 GB | 500 MB |
453
- * | `maxLayers` | `TOO_MANY_LAYERS` | 256 | none |
454
- *
455
- * Sizes are decimal: 1 MB is 1,000,000 bytes. Decoded sizes count 4 bytes
456
- * per pixel. `maxImagePixels` is the same limit, with the same name, code
457
- * and unit, as `pdf-sdk`'s. `maxImageDimension` is a side length, in pixels.
832
+ * The commands that exist only to undo others. The reducer applies them, and
833
+ * they're plain data like every command, but the `hm-image-command` format
834
+ * doesn't include them: an inverse's shape may change between releases
835
+ * (sdk-core ADR 0045).
458
836
  *
459
837
  * @public
460
838
  */
461
- declare const imageLimitDefinitions: {
462
- readonly maxDecodedSize: {
463
- readonly default: 1000000000;
464
- readonly warning: 400000000;
465
- readonly code: "DECODED_SIZE_TOO_LARGE";
466
- readonly unit: "bytes";
467
- };
468
- readonly maxImagePixels: {
469
- readonly code: "IMAGE_TOO_LARGE";
470
- readonly unit: "pixels";
471
- readonly default: 50000000;
472
- readonly warning: 24000000;
473
- };
474
- readonly maxImageDimension: {
475
- readonly code: "IMAGE_DIMENSION_TOO_LARGE";
476
- readonly unit: "pixels";
477
- readonly default: 16384;
478
- };
479
- readonly maxFrames: {
480
- readonly code: "TOO_MANY_FRAMES";
481
- readonly unit: "count";
482
- readonly default: 300;
483
- readonly warning: 100;
484
- };
485
- readonly maxSessionSize: {
486
- readonly code: "SESSION_TOO_LARGE";
487
- readonly unit: "bytes";
488
- readonly default: 1000000000;
489
- readonly warning: 500000000;
490
- };
491
- readonly maxLayers: {
492
- readonly code: "TOO_MANY_LAYERS";
493
- readonly unit: "count";
494
- readonly default: 256;
495
- };
496
- readonly maxFileSize: {
497
- readonly code: "FILE_TOO_LARGE";
498
- readonly unit: "bytes";
499
- readonly default: 100000000;
500
- readonly warning: 50000000;
501
- };
502
- readonly maxFiles: {
503
- readonly code: "TOO_MANY_FILES";
504
- readonly unit: "count";
505
- readonly default: 20;
506
- };
507
- readonly maxProcessingTime: {
508
- readonly code: "PROCESSING_TIME_EXCEEDED";
509
- readonly unit: "milliseconds";
510
- readonly default: 120000;
511
- };
512
- };
839
+ declare type ImageInverseCommand = RestoreLayersCommand | SetLayerOrderCommand | RestoreRedactionsCommand | SetRedactionOrderCommand;
513
840
 
514
841
  /**
515
- * The names of the image SDK's limits.
842
+ * The metadata fields a user may keep on export (ADR 0005). Empty strings
843
+ * mean the field isn't written.
516
844
  *
517
845
  * @public
518
846
  */
519
- declare type ImageLimitName = keyof ImageLimitDefinitions;
847
+ declare interface ImageKeepableMetadata {
848
+ readonly title: string;
849
+ readonly description: string;
850
+ readonly artist: string;
851
+ readonly copyright: string;
852
+ }
520
853
 
521
854
  /**
522
- * The type of {@link imageMessages}, for typing a host's overrides with
523
- * `MessageOverrides<ImageMessageCatalogue>`.
855
+ * A layer over the base: text, a shape or another image (ADR 0009). Layers
856
+ * are drawn bottom to top, in the plan's order, and redactions over all of
857
+ * them.
524
858
  *
525
859
  * @public
526
860
  */
527
- declare type ImageMessageCatalogue = typeof imageMessages;
861
+ declare type ImageLayer = ImageTextLayer | ImageShapeLayer | ImageImageLayer;
528
862
 
529
863
  /**
530
- * The image SDK's English message catalogue: sdk-core's and ui's messages, and text
531
- * for every {@link ImageErrorCode} and every limit's warning. Pass it to
532
- * `createMessages` from `@hussmartinez/sdk-core`, with the host's locale and
533
- * overrides. It also has the editor's text: its labels, states,
534
- * announcements and tool names.
535
- *
536
- * Error text is looked up by code, with the error's `details` as
537
- * parameters, and never taken from `error.message` (ADR 0019).
538
- *
539
- * @example
540
- * ```ts
541
- * const messages = createMessages(imageMessages, { locale: "en", overrides: props.messages });
542
- * messages.error(error); // "This animation has 400 frames, which is over the 300-frame limit."
543
- * messages.t("warnings.maxSessionSize", { actual: 600e6 });
544
- * ```
864
+ * Where a positioned layer is: a box in whole pixels of the scene, the
865
+ * base's oriented source, mirrored or not, then turned about its centre
866
+ * (ADR 0009). The box stays
867
+ * on the pixels it covers when the image is cropped or turned.
545
868
  *
546
869
  * @public
547
870
  */
548
- declare const imageMessages: {
549
- readonly "editor.engineUnavailable": "Image processing stopped. Reload this page or reopen the editor, then choose the image again. Unsaved edits will be lost unless your application has saved them.";
550
- readonly "errors.INVALID_IMAGE": "This file isn't a valid image, or it's too damaged to open.";
551
- readonly "errors.UNSUPPORTED_FORMAT": "This image format isn't supported. Try converting the file to PNG or JPEG, then open it again.";
552
- readonly "errors.DECODE_FAILED": "This browser can't open this kind of image. Try another browser, or convert the file to PNG or JPEG.";
553
- readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
554
- readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't an image project.";
555
- readonly "errors.IMAGE_TOO_LARGE": "This image has more pixels than the editor can handle. Try a smaller version of it.";
556
- readonly "errors.IMAGE_DIMENSION_TOO_LARGE": "This image is {actual, number} pixels across, which is over the {maximum, number}-pixel limit.";
557
- readonly "errors.TOO_MANY_FRAMES": {
558
- readonly $plural: "maximum";
559
- } & {
560
- readonly one: "This animation has {actual, number} frames, which is over the {maximum}-frame limit.";
561
- readonly other: "This animation has {actual, number} frames, which is over the {maximum, number}-frame limit.";
562
- };
563
- 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.";
564
- readonly "errors.TOO_MANY_LAYERS": {
565
- readonly $plural: "maximum";
566
- } & {
567
- readonly one: "An image can have {maximum} layer. Merge or delete layers, and try again.";
568
- readonly other: "An image can have up to {maximum, number} layers. Merge or delete layers, and try again.";
569
- };
570
- readonly "warnings.maxImagePixels": "This image is large, and may be slow to edit on some devices.";
571
- readonly "warnings.maxImageDimension": "This image is very wide or tall, and may be slow to edit.";
572
- readonly "warnings.maxFrames": {
573
- readonly $plural: "actual";
574
- } & {
575
- readonly one: "This animation has {actual} frame.";
576
- readonly other: "This animation has {actual, number} frames, and may be slow to edit and export.";
577
- };
578
- readonly "warnings.maxSessionSize": "The open images use {actual, fileSize} of memory. Clearing the undo history frees memory.";
579
- readonly "warnings.maxLayers": {
580
- readonly $plural: "actual";
581
- } & {
582
- readonly one: "This image has {actual} layer.";
583
- readonly other: "This image has {actual, number} layers, and may be slow to edit and export.";
584
- };
585
- readonly "editor.label": "Image editor";
586
- readonly "editor.preview": "Edited image preview, {width, number} × {height, number}";
587
- readonly "editor.empty": "Open an image to start editing. It stays on this device.";
588
- readonly "editor.choose": "Choose an image";
589
- readonly "editor.dropHint": "or drop it here";
590
- readonly "editor.opening": "Opening the image…";
591
- readonly "editor.cancel": "Cancel";
592
- readonly "editor.opened": "Image opened, {width, number} × {height, number}.";
593
- readonly "editor.undid": "Undid {action}.";
594
- readonly "editor.redid": "Redid {action}.";
595
- readonly "actions.image.setCrop": "crop";
596
- readonly "actions.image.setOrientation": "rotate or flip";
597
- readonly "actions.image.setOutput": "size";
598
- readonly "actions.image.setMetadata": "metadata";
599
- readonly "actions.image.setDevelop": "adjustment";
600
- readonly "actions.image.setFilter": "filter";
601
- readonly "toolbar.label": "Image tools";
602
- readonly "toolbar.groups.file": "File";
603
- readonly "toolbar.groups.history": "History";
604
- readonly "toolbar.groups.orientation": "Rotate";
605
- readonly "toolbar.groups.zoom": "Zoom";
606
- readonly "toolbar.groups.other": "More tools";
607
- readonly "tools.open": "Open image";
608
- readonly "tools.undo": "Undo";
609
- readonly "tools.redo": "Redo";
610
- readonly "tools.rotate-left": "Rotate left";
611
- readonly "tools.rotate-right": "Rotate right";
612
- readonly "tools.zoom-in": "Zoom in";
613
- readonly "tools.zoom-out": "Zoom out";
614
- readonly "tools.zoom-fit": "Fit to the stage";
615
- readonly "tools.crop": "Crop";
616
- readonly "tools.flip-horizontal": "Flip horizontally";
617
- readonly "tools.flip-vertical": "Flip vertically";
618
- readonly "toolbar.groups.crop": "Crop";
619
- readonly "crop.frame": "Crop area";
620
- 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.";
621
- readonly "crop.size": "{width, number} × {height, number}, from {x, number}, {y, number}";
622
- readonly "crop.panel": "Crop";
623
- readonly "crop.x": "Left";
624
- readonly "crop.y": "Top";
625
- readonly "crop.width": "Width";
626
- readonly "crop.height": "Height";
627
- readonly "crop.aspect": "Aspect ratio";
628
- readonly "crop.aspects.free": "Free";
629
- readonly "crop.aspects.original": "Original";
630
- readonly "crop.aspects.ratio": "{width}:{height}";
631
- readonly "crop.apply": "Apply crop";
632
- readonly "crop.cancel": "Cancel";
633
- readonly "crop.reset": "Whole image";
634
- readonly "crop.applied": "Cropped to {width, number} × {height, number}.";
635
- readonly "inspector.label": "Panels";
636
- readonly "inspector.adjust": "Adjust";
637
- readonly "inspector.filters": "Filters";
638
- readonly "inspector.info": "Info";
639
- readonly "notices.label": "Notices";
640
- readonly "notices.dismiss": "Dismiss";
641
- readonly "notices.colourProfile": "This image has a colour profile. Colours outside sRGB will be clipped in the exported file.";
642
- readonly "info.panel": "Image info";
643
- readonly "info.size": "Size";
644
- readonly "info.sizeValue": "{width, number} × {height, number} pixels";
645
- readonly "info.format": "Format";
646
- readonly "info.formats.png": "PNG";
647
- readonly "info.formats.jpeg": "JPEG";
648
- readonly "info.formats.webp": "WebP";
649
- readonly "info.formats.gif": "GIF";
650
- readonly "info.formats.avif": "AVIF";
651
- readonly "info.formats.heif": "HEIF";
652
- readonly "info.formats.bmp": "BMP";
653
- readonly "info.frames": "Frames";
654
- readonly "info.fileSize": "File size";
655
- readonly "info.fileSizeValue": "{size, fileSize}";
656
- readonly "info.metadata": "Metadata in the file";
657
- readonly "info.metadataNone": "None";
658
- readonly "info.kept": "Kept on export";
659
- readonly "info.keptNone": "Nothing";
660
- readonly "develop.panel": "Adjust";
661
- readonly "develop.temperature": "Temperature";
662
- readonly "develop.tint": "Tint";
663
- readonly "develop.exposure": "Exposure";
664
- readonly "develop.highlights": "Highlights";
665
- readonly "develop.shadows": "Shadows";
666
- readonly "develop.contrast": "Contrast";
667
- readonly "develop.saturation": "Saturation";
668
- readonly "develop.vibrance": "Vibrance";
669
- readonly "develop.reset": "Reset {name}";
670
- readonly "develop.resetAll": "Reset all";
671
- readonly "develop.wasReset": "All adjustments reset.";
672
- readonly "filters.panel": "Filters";
673
- readonly "filters.label": "Filter";
674
- readonly "filters.none": "None";
675
- readonly "filters.vivid": "Vivid";
676
- readonly "filters.warm": "Warm";
677
- readonly "filters.cool": "Cool";
678
- readonly "filters.fade": "Fade";
679
- readonly "filters.mono": "Mono";
680
- readonly "filters.noir": "Noir";
681
- readonly "filters.sepia": "Sepia";
682
- readonly "filters.strength": "Strength";
683
- readonly "toolbar.groups.export": "Export";
684
- readonly "tools.export": "Export";
685
- readonly "export.title": "Export image";
686
- readonly "export.description": "The file is made on this device, and nothing is uploaded.";
687
- readonly "export.format": "Format";
688
- readonly "export.formats.png": "PNG";
689
- readonly "export.formats.jpeg": "JPEG";
690
- readonly "export.formats.webp": "WebP";
691
- readonly "export.quality": "Quality";
692
- readonly "export.qualityValue": "{quality, number}%";
693
- readonly "export.size": "Size";
694
- readonly "export.sizes.scale": "Scale";
695
- readonly "export.sizes.fit": "Fit in a box";
696
- readonly "export.scale": "Scale, in percent";
697
- readonly "export.fitWidth": "Largest width";
698
- readonly "export.fitHeight": "Largest height";
699
- readonly "export.fields": "Details to include";
700
- readonly "export.fieldsHint": "Only what you fill in is written to the file.";
701
- readonly "export.field.title": "Title";
702
- readonly "export.field.description": "Description";
703
- readonly "export.field.artist": "Artist";
704
- readonly "export.field.copyright": "Copyright";
705
- readonly "export.summary": "Summary";
706
- readonly "export.output": "{width, number} × {height, number} pixels, {format}";
707
- readonly "export.removed": "Removed from the file";
708
- readonly "export.removedNone": "The image had no other details to remove.";
709
- readonly "export.kind.location": "Location";
710
- readonly "export.kind.camera": "Camera details";
711
- readonly "export.kind.timestamps": "Dates and times";
712
- readonly "export.kind.thumbnail": "Embedded thumbnail";
713
- readonly "export.kind.colourProfile": "Colour profile: colours outside sRGB are clipped";
714
- readonly "export.kind.other": "Other metadata";
715
- readonly "export.kept": "Kept in the file";
716
- readonly "export.confirm": "Export";
717
- readonly "export.cancel": "Cancel";
718
- readonly "export.progress": "Exporting the image";
719
- readonly "export.stop": "Stop exporting";
720
- readonly "export.cancelled": "Export stopped.";
721
- readonly "export.done": "Exported a {format} of {size, fileSize}.";
722
- readonly "export.ready": "{width, number} × {height, number} pixels, {format}, {size, fileSize}";
723
- readonly "export.download": "Download";
724
- readonly "export.close": "Done";
725
- readonly "dialog.close": "Close";
726
- readonly "fileDropZone.choose": "Choose a file";
727
- readonly "fileDropZone.chooseMultiple": "Choose files";
728
- readonly "fileDropZone.hint": "or drop it here";
729
- readonly "fileDropZone.hintMultiple": "or drop them here";
730
- readonly "progress.label": "Progress";
731
- readonly "spinner.label": "Loading";
732
- readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
733
- readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
734
- readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
735
- readonly "errors.ABORTED": "The operation was cancelled.";
736
- readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
737
- readonly "errors.WORKER_START_FAILED": "The file processor couldn't start. Reload the page and try again.";
738
- readonly "errors.WORKER_PROTOCOL_MISMATCH": "The file processor is out of date. Reload the page to update it.";
739
- readonly "errors.WORKER_CRASHED": "The file processor stopped unexpectedly. Please try again.";
740
- readonly "errors.WORKER_TERMINATED": "The operation was stopped before it finished. Please try again.";
741
- readonly "errors.WORKER_METHOD_NOT_FOUND": "This operation isn't available. Reload the page and try again.";
742
- readonly "errors.WORKER_DATA_NOT_CLONEABLE": "Something went wrong while processing the file. Please try again.";
743
- readonly "errors.UNSUPPORTED_ENVIRONMENT": "This browser doesn't support a feature this tool needs. Update your browser, or try another one.";
744
- readonly "errors.FILE_TOO_LARGE": "This file is {actual, fileSize}, which is over the {maximum, fileSize} limit.";
745
- readonly "errors.TOO_MANY_FILES": {
746
- readonly $plural: "maximum";
747
- } & {
748
- readonly one: "You can add {maximum} file at a time.";
749
- readonly other: "You can add up to {maximum} files at a time.";
871
+ declare interface ImageLayerBox {
872
+ /** The box's left edge, before its rotation. May be negative. */
873
+ readonly x: number;
874
+ /** The box's top edge, before its rotation. May be negative. */
875
+ readonly y: number;
876
+ /** At least 1. */
877
+ readonly width: number;
878
+ /** At least 1. */
879
+ readonly height: number;
880
+ /** Tenths of a degree, clockwise about the box's centre: 0 to 3599. */
881
+ readonly rotation: number;
882
+ /**
883
+ * Whether the layer is mirrored left to right, about the box's own
884
+ * vertical axis, before it's turned. With a half turn, that's a mirror top
885
+ * to bottom, so one flip is all a box needs.
886
+ */
887
+ readonly flipX: boolean;
888
+ }
889
+
890
+ /**
891
+ * What every layer has (ADR 0009).
892
+ *
893
+ * @public
894
+ */
895
+ declare interface ImageLayerCommon {
896
+ /**
897
+ * Its identity: 1 to `MAX_KEY_LENGTH` code points, unique among the plan's
898
+ * layers and redactions.
899
+ */
900
+ readonly key: string;
901
+ /**
902
+ * What the layers list calls it: up to `MAX_LAYER_NAME_LENGTH` code
903
+ * points. Empty means the editor's own label for the kind.
904
+ */
905
+ readonly name: string;
906
+ /** Whether it's drawn. */
907
+ readonly visible: boolean;
908
+ /** A whole number from 0, transparent, to 100, opaque. */
909
+ readonly opacity: number;
910
+ }
911
+
912
+ /**
913
+ * The type of {@link imageLimitDefinitions}.
914
+ *
915
+ * @public
916
+ */
917
+ declare type ImageLimitDefinitions = typeof imageLimitDefinitions;
918
+
919
+ /**
920
+ * The image SDK's limit definitions: sdk-core's core limits with image
921
+ * defaults, plus five for images (ADR 0004).
922
+ *
923
+ * | Limit | Code | Default maximum | Default warning |
924
+ * |---|---|---|---|
925
+ * | `maxFileSize` | `FILE_TOO_LARGE` | 100 MB | 50 MB |
926
+ * | `maxFiles` | `TOO_MANY_FILES` | 20 | none |
927
+ * | `maxDecodedSize` | `DECODED_SIZE_TOO_LARGE` | 1 GB | 400 MB |
928
+ * | `maxProcessingTime` | `PROCESSING_TIME_EXCEEDED` | 120 s | none |
929
+ * | `maxImagePixels` | `IMAGE_TOO_LARGE` | 50 megapixels | 24 megapixels |
930
+ * | `maxImageDimension` | `IMAGE_DIMENSION_TOO_LARGE` | 16,384 pixels | none |
931
+ * | `maxFrames` | `TOO_MANY_FRAMES` | 300 | 100 |
932
+ * | `maxSessionSize` | `SESSION_TOO_LARGE` | 1 GB | 500 MB |
933
+ * | `maxLayers` | `TOO_MANY_LAYERS` | 256 | none |
934
+ *
935
+ * Sizes are decimal: 1 MB is 1,000,000 bytes. Decoded sizes count 4 bytes
936
+ * per pixel. `maxImagePixels` is the same limit, with the same name, code
937
+ * and unit, as `pdf-sdk`'s. `maxImageDimension` is a side length, in pixels.
938
+ *
939
+ * @public
940
+ */
941
+ declare const imageLimitDefinitions: {
942
+ readonly maxDecodedSize: {
943
+ readonly default: 1000000000;
944
+ readonly warning: 400000000;
945
+ readonly code: "DECODED_SIZE_TOO_LARGE";
946
+ readonly unit: "bytes";
947
+ };
948
+ readonly maxImagePixels: {
949
+ readonly code: "IMAGE_TOO_LARGE";
950
+ readonly unit: "pixels";
951
+ readonly default: 50000000;
952
+ readonly warning: 24000000;
953
+ };
954
+ readonly maxImageDimension: {
955
+ readonly code: "IMAGE_DIMENSION_TOO_LARGE";
956
+ readonly unit: "pixels";
957
+ readonly default: 16384;
958
+ };
959
+ readonly maxFrames: {
960
+ readonly code: "TOO_MANY_FRAMES";
961
+ readonly unit: "count";
962
+ readonly default: 300;
963
+ readonly warning: 100;
964
+ };
965
+ readonly maxSessionSize: {
966
+ readonly code: "SESSION_TOO_LARGE";
967
+ readonly unit: "bytes";
968
+ readonly default: 1000000000;
969
+ readonly warning: 500000000;
970
+ };
971
+ readonly maxLayers: {
972
+ readonly code: "TOO_MANY_LAYERS";
973
+ readonly unit: "count";
974
+ readonly default: 256;
975
+ };
976
+ readonly maxFileSize: {
977
+ readonly code: "FILE_TOO_LARGE";
978
+ readonly unit: "bytes";
979
+ readonly default: 100000000;
980
+ readonly warning: 50000000;
981
+ };
982
+ readonly maxFiles: {
983
+ readonly code: "TOO_MANY_FILES";
984
+ readonly unit: "count";
985
+ readonly default: 20;
986
+ };
987
+ readonly maxProcessingTime: {
988
+ readonly code: "PROCESSING_TIME_EXCEEDED";
989
+ readonly unit: "milliseconds";
990
+ readonly default: 120000;
750
991
  };
751
- readonly "errors.DECODED_SIZE_TOO_LARGE": "This file expands to more than {maximum, fileSize} when opened, which is over the limit.";
752
- readonly "errors.PROCESSING_TIME_EXCEEDED": "Processing this file took too long and was stopped.";
753
- readonly "warnings.maxFileSize": "This file is {actual, fileSize}. Large files may be slow to process.";
754
- readonly "warnings.maxFiles": "Adding {actual} files at once may be slow.";
755
- readonly "warnings.maxDecodedSize": "This file is very large once opened and may be slow to process.";
756
- readonly "warnings.maxProcessingTime": "This is taking longer than usual.";
757
- readonly "keys.control": "Ctrl";
758
- readonly "keys.alt": "Alt";
759
- readonly "keys.shift": "Shift";
760
- readonly "keys.meta": "Meta";
761
- readonly "keys.apple.control": "\u2303";
762
- readonly "keys.apple.alt": "\u2325";
763
- readonly "keys.apple.shift": "\u21E7";
764
- readonly "keys.apple.meta": "\u2318";
765
- readonly "keys.space": "Space";
766
- readonly "keys.enter": "Enter";
767
- readonly "keys.escape": "Esc";
768
- readonly "keys.tab": "Tab";
769
- readonly "keys.delete": "Delete";
770
- readonly "keys.backspace": "Backspace";
771
- readonly "keys.arrowUp": "\u2191";
772
- readonly "keys.arrowDown": "\u2193";
773
- readonly "keys.arrowLeft": "\u2190";
774
- readonly "keys.arrowRight": "\u2192";
775
- readonly "keys.home": "Home";
776
- readonly "keys.end": "End";
777
- readonly "keys.pageUp": "Page Up";
778
- readonly "keys.pageDown": "Page Down";
779
992
  };
780
993
 
994
+ /**
995
+ * The names of the image SDK's limits.
996
+ *
997
+ * @public
998
+ */
999
+ declare type ImageLimitName = keyof ImageLimitDefinitions;
1000
+
781
1001
  /**
782
1002
  * Which kinds of metadata a file carries, as presence flags, never values,
783
1003
  * so the editor can say what an export removes (ADR 0005).
@@ -826,12 +1046,19 @@ declare type ImageOutput = {
826
1046
 
827
1047
  /**
828
1048
  * The session's document: a description of the edits over an immutable
829
- * source, rendered to pixels only for display and export (ADR 0003).
1049
+ * source, rendered to pixels only for display and export (ADR 0003, ADR
1050
+ * 0009).
830
1051
  *
831
1052
  * @public
832
1053
  */
833
1054
  declare interface ImagePlan {
834
1055
  readonly base: ImageBase;
1056
+ /** The layers over the base, bottom to top, placed in the scene (ADR 0009). */
1057
+ readonly layers: readonly ImageLayer[];
1058
+ /** The redactions, applied over every layer (ADR 0010). */
1059
+ readonly redactions: readonly ImageRedaction[];
1060
+ /** The animation (ADR 0011). Always `null` until format version 4. */
1061
+ readonly animation: null;
835
1062
  readonly output: ImageOutput;
836
1063
  /** The fields the user chose to keep on export. Never a location (ADR 0005). */
837
1064
  readonly metadata: ImageKeepableMetadata;
@@ -907,6 +1134,62 @@ declare interface ImageProgressOptions extends ImageCallOptions {
907
1134
  readonly onProgress?: (fraction: number) => void;
908
1135
  }
909
1136
 
1137
+ /**
1138
+ * A region of the image that an export doesn't show (ADR 0010): a rectangle
1139
+ * in whole pixels of the scene, the base's oriented source, so it stays on
1140
+ * the pixels it covers when the image is cropped or turned (ADR 0009).
1141
+ *
1142
+ * A redaction has no opacity, visibility or rotation, and is drawn over
1143
+ * every layer. Only exports are redacted: the plan describes the redaction,
1144
+ * and the source is unchanged.
1145
+ *
1146
+ * @public
1147
+ */
1148
+ declare type ImageRedaction = (ImageRedactionRegion & {
1149
+ readonly mode: "solid";
1150
+ /** The fill, as `#rrggbb` in lower case. */
1151
+ readonly colour: string;
1152
+ }) | (ImageRedactionRegion & {
1153
+ readonly mode: "pixelate";
1154
+ });
1155
+
1156
+ /**
1157
+ * The fields of a redaction that `image.updateRedactions` may set: any but
1158
+ * its key. Setting `mode` to `pixelate` drops the colour, and setting it to
1159
+ * `solid` needs one in the same update.
1160
+ *
1161
+ * @public
1162
+ */
1163
+ declare interface ImageRedactionProps {
1164
+ readonly mode?: ImageRedaction["mode"];
1165
+ readonly x?: number;
1166
+ readonly y?: number;
1167
+ readonly width?: number;
1168
+ readonly height?: number;
1169
+ readonly colour?: string;
1170
+ }
1171
+
1172
+ /**
1173
+ * What every redaction has, whatever its mode: its identity and its region.
1174
+ *
1175
+ * @public
1176
+ */
1177
+ declare interface ImageRedactionRegion {
1178
+ /**
1179
+ * Its identity: 1 to {@link MAX_KEY_LENGTH} code points, unique among the
1180
+ * plan's layers and redactions.
1181
+ */
1182
+ readonly key: string;
1183
+ /** The region's left edge, in whole pixels of the scene. May be negative. */
1184
+ readonly x: number;
1185
+ /** The region's top edge, in whole pixels of the scene. May be negative. */
1186
+ readonly y: number;
1187
+ /** At least 1. */
1188
+ readonly width: number;
1189
+ /** At least 1. */
1190
+ readonly height: number;
1191
+ }
1192
+
910
1193
  /**
911
1194
  * Options for registering a source.
912
1195
  *
@@ -954,6 +1237,29 @@ declare interface ImageSession {
954
1237
  open(file: Blob, options?: {
955
1238
  readonly signal?: AbortSignal;
956
1239
  }): Promise<ImageSessionSource>;
1240
+ /**
1241
+ * Probes, checks and decodes another file, and adds it to the document as
1242
+ * an image layer, as one undoable step (ADR 0003, ADR 0004).
1243
+ *
1244
+ * - **Limits:** the file's own, as for `open`; `maxFiles`, counting every
1245
+ * source the session holds; and `maxSessionSize`, counting their decoded
1246
+ * bytes. When the image doesn't fit, the session first drops the oldest
1247
+ * undo steps that alone keep another image, and marks the history as
1248
+ * trimmed. If that isn't enough, nothing is dropped and it fails with
1249
+ * `SESSION_TOO_LARGE`.
1250
+ * - **Placement:** by default the image is centred on what's shown, at
1251
+ * its own size or half the composition's, whichever is smaller, over
1252
+ * every layer, and turned and mirrored back against the plan's
1253
+ * rotation and flips, so it's seen as the file is. `place` returns other commands; they must refer to the
1254
+ * source, or it's released.
1255
+ * - **Lifetime:** the session holds the source while the plan, an undo
1256
+ * or redo step, or an export in progress refers to it, and releases it
1257
+ * then.
1258
+ *
1259
+ * A failure, a cancellation, or another file opened meanwhile adds
1260
+ * nothing and releases the source.
1261
+ */
1262
+ insertImage(file: Blob, options?: ImageInsertOptions): Promise<ImageSessionSource>;
957
1263
  /**
958
1264
  * Applies commands as one undoable step. They're checked by the reducer,
959
1265
  * then the output against `maxImageDimension` and `maxImagePixels`; a
@@ -964,7 +1270,9 @@ declare interface ImageSession {
964
1270
  * Makes the document's plan equal to `plan`, as one undoable step of the
965
1271
  * commands that reach it, checked as `execute` checks them (ADR 0003). A
966
1272
  * plan equal to the current one changes nothing. A plan over another
967
- * source is `INVALID_COMMAND`. For editors whose host holds the plan.
1273
+ * source is `INVALID_COMMAND`, and so is one without `layers`,
1274
+ * `redactions` and `animation`, such as a plan stored before format
1275
+ * version 2. For editors whose host holds the plan.
968
1276
  */
969
1277
  applyPlan(plan: ImagePlan): void;
970
1278
  /**
@@ -988,7 +1296,7 @@ declare interface ImageSession {
988
1296
  readonly signal?: AbortSignal;
989
1297
  readonly onProgress?: (fraction: number) => void;
990
1298
  }): Promise<ImageSessionExport>;
991
- /** Releases the source the session holds. Later calls throw. */
1299
+ /** Releases every source the session holds. Later calls throw. */
992
1300
  destroy(): Promise<void>;
993
1301
  }
994
1302
 
@@ -1025,8 +1333,20 @@ declare interface ImageSessionSnapshot {
1025
1333
  readonly plan: ImagePlan | null;
1026
1334
  /** The document's source, or `null` before a file is open. */
1027
1335
  readonly source: ImageSessionSource | null;
1336
+ /**
1337
+ * Every source the session holds: the document's, then those of image
1338
+ * layers, including ones only the history still refers to (ADR 0004).
1339
+ */
1340
+ readonly sources: readonly ImageSessionSource[];
1028
1341
  readonly canUndo: boolean;
1029
1342
  readonly canRedo: boolean;
1343
+ /**
1344
+ * Whether undo steps were dropped to make room for an image, since the
1345
+ * document was opened: they can no longer be undone.
1346
+ */
1347
+ readonly historyTrimmed: boolean;
1348
+ /** Whether an image is being added as a layer. */
1349
+ readonly inserting: boolean;
1030
1350
  /** Whether a file is being opened. The current document stays until it's ready. */
1031
1351
  readonly opening: boolean;
1032
1352
  /** Whether an export is in progress. */
@@ -1053,6 +1373,25 @@ declare interface ImageSessionSource extends ImageSourceInfo {
1053
1373
  readonly keepable: ImageKeepableMetadata;
1054
1374
  }
1055
1375
 
1376
+ /**
1377
+ * A rectangle or an ellipse that fills its box, with a fill, a stroke drawn
1378
+ * inside the box, or both (ADR 0009).
1379
+ *
1380
+ * @public
1381
+ */
1382
+ declare interface ImageShapeLayer extends ImageLayerCommon, ImageLayerBox {
1383
+ readonly kind: "shape";
1384
+ readonly shape: (typeof LAYER_SHAPES)[number];
1385
+ /** The fill, as `#rrggbb` in lower case, or `null` for none. */
1386
+ readonly fill: string | null;
1387
+ /** The stroke, or `null` for none. A shape has a fill or a stroke. */
1388
+ readonly stroke: {
1389
+ readonly colour: string;
1390
+ /** In whole scene pixels, from 1 to `MAX_STROKE_WIDTH`. */
1391
+ readonly width: number;
1392
+ } | null;
1393
+ }
1394
+
1056
1395
  /**
1057
1396
  * A width and a height, in whole pixels.
1058
1397
  *
@@ -1080,6 +1419,27 @@ declare interface ImageSourceInfo {
1080
1419
  readonly decodedBytes: number;
1081
1420
  }
1082
1421
 
1422
+ /**
1423
+ * Text, drawn as large as fits inside its box, never distorted (ADR 0009).
1424
+ * Lines break only at line feeds. Emoji are text.
1425
+ *
1426
+ * @public
1427
+ */
1428
+ declare interface ImageTextLayer extends ImageLayerCommon, ImageLayerBox {
1429
+ readonly kind: "text";
1430
+ /**
1431
+ * Up to `MAX_LAYER_TEXT_LENGTH` code points. Control characters other
1432
+ * than a line feed, and the bidirectional embedding, override and isolate
1433
+ * controls, are refused.
1434
+ */
1435
+ readonly text: string;
1436
+ readonly font: (typeof LAYER_FONTS)[number];
1437
+ readonly bold: boolean;
1438
+ /** The text's colour, as `#rrggbb` in lower case. */
1439
+ readonly colour: string;
1440
+ readonly align: (typeof LAYER_ALIGNMENTS)[number];
1441
+ }
1442
+
1083
1443
  /**
1084
1444
  * A small rendering of a source for lists and frame strips. An `ImageBitmap`
1085
1445
  * is one; tests can supply their own. Close it when it's no longer shown.
@@ -1092,6 +1452,129 @@ declare interface ImageThumbnail {
1092
1452
  close(): void;
1093
1453
  }
1094
1454
 
1455
+ /**
1456
+ * Inserts layers at an index of the plan's layers, which are drawn bottom
1457
+ * to top (ADR 0009). Each needs a key no layer or redaction of the plan has.
1458
+ *
1459
+ * @public
1460
+ */
1461
+ declare interface InsertLayersCommand {
1462
+ readonly type: "image.insertLayers";
1463
+ /** From 0, under every layer, to the number of layers, over them all. */
1464
+ readonly at: number;
1465
+ readonly layers: readonly ImageLayer[];
1466
+ }
1467
+
1468
+ /**
1469
+ * Inserts redactions at an index of the plan's redactions (ADR 0010). Each
1470
+ * needs a key no layer or redaction of the plan has.
1471
+ *
1472
+ * @public
1473
+ */
1474
+ declare interface InsertRedactionsCommand {
1475
+ readonly type: "image.insertRedactions";
1476
+ /** From 0 to the number of redactions. */
1477
+ readonly at: number;
1478
+ readonly redactions: readonly ImageRedaction[];
1479
+ }
1480
+
1481
+ /**
1482
+ * How a text layer's lines sit in its box, by the text's own direction.
1483
+ *
1484
+ * @public
1485
+ */
1486
+ declare const LAYER_ALIGNMENTS: readonly ["start", "center", "end"];
1487
+
1488
+ /**
1489
+ * The fonts a text layer can use: the generic families, which every device
1490
+ * has, so the SDK ships and fetches none (ADR 0009). Names are part of the
1491
+ * document format.
1492
+ *
1493
+ * @public
1494
+ */
1495
+ declare const LAYER_FONTS: readonly ["sans-serif", "serif", "monospace"];
1496
+
1497
+ /**
1498
+ * The shapes a shape layer can be.
1499
+ *
1500
+ * @public
1501
+ */
1502
+ declare const LAYER_SHAPES: readonly ["rectangle", "ellipse"];
1503
+
1504
+ /**
1505
+ * Moves layers to an index of the list without them, keeping the order they
1506
+ * had: up or down the stack.
1507
+ *
1508
+ * @public
1509
+ */
1510
+ declare interface MoveLayersCommand {
1511
+ readonly type: "image.moveLayers";
1512
+ readonly keys: readonly string[];
1513
+ readonly to: number;
1514
+ }
1515
+
1516
+ /**
1517
+ * Moves redactions to an index of the list without them, keeping the order
1518
+ * they had. The order only decides how overlapping redactions look.
1519
+ *
1520
+ * @public
1521
+ */
1522
+ declare interface MoveRedactionsCommand {
1523
+ readonly type: "image.moveRedactions";
1524
+ readonly keys: readonly string[];
1525
+ readonly to: number;
1526
+ }
1527
+
1528
+ /**
1529
+ * Removes layers, by key.
1530
+ *
1531
+ * @public
1532
+ */
1533
+ declare interface RemoveLayersCommand {
1534
+ readonly type: "image.removeLayers";
1535
+ readonly keys: readonly string[];
1536
+ }
1537
+
1538
+ /**
1539
+ * Removes redactions, by key.
1540
+ *
1541
+ * @public
1542
+ */
1543
+ declare interface RemoveRedactionsCommand {
1544
+ readonly type: "image.removeRedactions";
1545
+ readonly keys: readonly string[];
1546
+ }
1547
+
1548
+ /**
1549
+ * Puts removed layers back, each at its index, by rising index. It's what
1550
+ * undoes {@link RemoveLayersCommand}: the reducer applies it, but it isn't
1551
+ * part of the portable command format (ADR 0009).
1552
+ *
1553
+ * @public
1554
+ */
1555
+ declare interface RestoreLayersCommand {
1556
+ readonly type: "image.restoreLayers";
1557
+ readonly entries: readonly {
1558
+ readonly at: number;
1559
+ readonly layer: ImageLayer;
1560
+ }[];
1561
+ }
1562
+
1563
+ /**
1564
+ * Puts removed redactions back, each at its index, by rising index. It's
1565
+ * what undoes {@link RemoveRedactionsCommand}: the reducer applies it, but
1566
+ * it isn't part of the portable command format (ADR 0009).
1567
+ *
1568
+ * @public
1569
+ */
1570
+ declare interface RestoreRedactionsCommand {
1571
+ readonly type: "image.restoreRedactions";
1572
+ readonly entries: readonly {
1573
+ readonly at: number;
1574
+ readonly redaction: ImageRedaction;
1575
+ }[];
1576
+ }
1577
+
1095
1578
  /**
1096
1579
  * Sets or removes the base's crop, in whole pixels of the oriented source.
1097
1580
  *
@@ -1123,6 +1606,18 @@ declare interface SetFilterCommand {
1123
1606
  readonly filter: ImageFilter | null;
1124
1607
  }
1125
1608
 
1609
+ /**
1610
+ * Sets the whole order of the layers: every key, once. It's what undoes
1611
+ * {@link MoveLayersCommand}: the reducer applies it, but it isn't part of
1612
+ * the portable command format (ADR 0009).
1613
+ *
1614
+ * @public
1615
+ */
1616
+ declare interface SetLayerOrderCommand {
1617
+ readonly type: "image.setLayerOrder";
1618
+ readonly keys: readonly string[];
1619
+ }
1620
+
1126
1621
  /**
1127
1622
  * Sets one metadata field to keep on export. An empty value keeps nothing.
1128
1623
  *
@@ -1154,4 +1649,44 @@ declare interface SetOutputCommand {
1154
1649
  readonly output: ImageOutput;
1155
1650
  }
1156
1651
 
1652
+ /**
1653
+ * Sets the whole order of the redactions: every key, once. It's what undoes
1654
+ * {@link MoveRedactionsCommand}: the reducer applies it, but it isn't part
1655
+ * of the portable command format (ADR 0009).
1656
+ *
1657
+ * @public
1658
+ */
1659
+ declare interface SetRedactionOrderCommand {
1660
+ readonly type: "image.setRedactionOrder";
1661
+ readonly keys: readonly string[];
1662
+ }
1663
+
1664
+ /**
1665
+ * Sets some fields of some layers: their boxes after a move, their opacity,
1666
+ * a text layer's text. `props` may hold any field of the layer's kind except
1667
+ * `key` and `kind`.
1668
+ *
1669
+ * @public
1670
+ */
1671
+ declare interface UpdateLayersCommand {
1672
+ readonly type: "image.updateLayers";
1673
+ readonly updates: readonly {
1674
+ readonly key: string;
1675
+ readonly props: Readonly<Record<string, unknown>>;
1676
+ }[];
1677
+ }
1678
+
1679
+ /**
1680
+ * Sets some fields of some redactions, such as their regions after a move.
1681
+ *
1682
+ * @public
1683
+ */
1684
+ declare interface UpdateRedactionsCommand {
1685
+ readonly type: "image.updateRedactions";
1686
+ readonly updates: readonly {
1687
+ readonly key: string;
1688
+ readonly props: ImageRedactionProps;
1689
+ }[];
1690
+ }
1691
+
1157
1692
  export { }