@embededitor/free 0.0.0-stage → 1.0.1

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.
@@ -0,0 +1,1586 @@
1
+ /*! Embed Editor Free 1.0.1 | © 2026 Rohde Softwares | Free license, commercial use included, on one condition: the Embed Editor badge stays visible and unaltered. Removing, hiding or covering it infringes the license, see https://embededitor.com/license */
2
+ /** An annotation of `EditState`'s `annotations` as `annotate.add` takes it: no `id` (the editor gives it the next), its `color` optional. */
3
+ declare type AnnotatePiece = Unsaved<Extract<SavedAnnotation, {
4
+ type: 'LENS';
5
+ }>> | Unsaved<Extract<SavedAnnotation, {
6
+ type: 'LINE';
7
+ }>> | Unsaved<Extract<SavedAnnotation, {
8
+ type: 'RULER';
9
+ }>> | Unsaved<Extract<SavedAnnotation, {
10
+ type: 'SHAPE';
11
+ }>> | Unsaved<Extract<SavedAnnotation, {
12
+ type: 'TEXT';
13
+ }>>;
14
+
15
+ /**
16
+ * What the style row and the color row set, in `EditState`'s names (each annotation takes the ones it has: `read.options`
17
+ * lists them): a line's `end`, `path`, `start`, `stroke` and `weight`; a ruler's `ends`; a text's `corners`, `font`,
18
+ * `look`, `mark`, `padding` and `size`; a shape's `fill` and `kind`; a magnifier's `line`, `shape` and `zoom`; and the
19
+ * color, a hex.
20
+ */
21
+ declare type AnnotateStyle = {
22
+ color?: string;
23
+ corners?: 'ROUND' | 'SOFT' | 'SQUARE';
24
+ end?: AnnotationCap;
25
+ ends?: 'ARROW' | 'BAR' | 'NONE';
26
+ fill?: number;
27
+ font?: AnnotationFont;
28
+ line?: 'DASHED' | 'DOTTED' | 'MARKER' | 'SKETCH' | 'SOLID' | 'TRANSPARENT';
29
+ look?: 'BOX' | 'CAPTION' | 'PLAIN';
30
+ mark?: 'DOT' | 'NONE' | 'NUMBER';
31
+ padding?: 'LOOSE' | 'NORMAL' | 'TIGHT';
32
+ path?: AnnotationPath;
33
+ shape?: 'CIRCLE' | 'ROUNDED';
34
+ size?: AnnotationSize;
35
+ start?: AnnotationCap;
36
+ stroke?: AnnotationStroke;
37
+ weight?: AnnotationWeight;
38
+ zoom?: number;
39
+ };
40
+
41
+ /** Annotate's tools: what a tap or a drag on the photo makes. */
42
+ declare type AnnotateTool = 'ARROW' | 'DRAW' | 'LENS' | 'NUMBER' | 'RULER' | 'SHAPE' | 'TEXT';
43
+
44
+ /**
45
+ * An arrow added to a text or to the Numbers' list, leaving its owner's box (a text's box, a Number's badge, the list's
46
+ * block). Every value written; a state that leaves one out reads an added arrow's default (`end` a dot, a curve, medium
47
+ * thin).
48
+ */
49
+ declare type AnnotationAddedArrow = {
50
+ angle?: AnnotationAngle;
51
+ bend?: AnnotationBend;
52
+ end?: AnnotationCap;
53
+ /** Where it leaves its owner's box, a share of the box across and down (0…1). Absent or `null`: where it is drawn. */
54
+ exit?: AnnotationShare | null;
55
+ /**
56
+ * What its tip landed on, which it moves with: an annotation's `id` (its own text's too: a loop round it), or `'LIST'`
57
+ * for the list of the Numbers (`ANNOTATION_LIST_GLUE`; the list's own arrow's: a loop round it). Absent or `null`: a
58
+ * loose tip.
59
+ */
60
+ glued?: string | null;
61
+ path?: AnnotationPath;
62
+ /** Its elbow's route kept as it was drawn, as a line's (`route`). Absent: the route its ends give. */
63
+ route?: AnnotationRoute;
64
+ /** The side of what its tip was glued to, the one it was let go beside (or its glue dot's), in that one's own frame: an elbow enters it there. */
65
+ side?: AnnotationSide;
66
+ start?: AnnotationCap;
67
+ stroke?: AnnotationStroke;
68
+ to: AnnotationPoint;
69
+ weight?: AnnotationWeight;
70
+ };
71
+
72
+ /**
73
+ * The turn of an annotation's own frame on the image (an obfuscated area's too), in degrees, the sense `rotation` turns the
74
+ * image: born as the screen showed it, level on the screen, the image's whole turn and its mirror undone, then carried with
75
+ * the image as it turns, and turned by its rotate handle where it has one. A shape's `box` (an area's rect) is the rect in
76
+ * that frame, turned about its middle; a text's box, a Number's badge, the list's block, a ruler's label and a lens's frame
77
+ * stand in it, their letters never mirrored; a line's elbow (a lens's line's in its own, `lineAngle`) routes in it and a
78
+ * drawing's box stands in it; a lens's line and a text's arrow leave in it. Written in (−180°, 180°], at most 2 decimals.
79
+ * Absent: 0, the image's own frame.
80
+ */
81
+ declare type AnnotationAngle = number;
82
+
83
+ /**
84
+ * A line's curve set by hand: its bow over its length, −1…1. An elbow's: where its middle leg stands, a share of the way
85
+ * between its least end legs, 0…1. `null`: automatic (an elbow's middle leg halfway).
86
+ */
87
+ declare type AnnotationBend = number | null;
88
+
89
+ /** How a line ends: nothing, an open head, a filled head, a dot or a bar. */
90
+ declare type AnnotationCap = 'ARROW' | 'BAR' | 'DOT' | 'NONE' | 'TRIANGLE';
91
+
92
+ /** The letter, by its slug: one of the nine the editor bundles (Inter, Montserrat, Oswald, Anton, Playfair Display, Courier Prime, Caveat, Pacifico, Permanent Marker). */
93
+ declare type AnnotationFont = 'anton' | 'caveat' | 'courier-prime' | 'inter' | 'montserrat' | 'oswald' | 'pacifico' | 'permanent-marker' | 'playfair-display';
94
+
95
+ /**
96
+ * A line's path: a curve (bent on its own, or by hand: `bend`), straight, an elbow, an elbow with rounded corners, or the
97
+ * stroke drawn by hand.
98
+ */
99
+ declare type AnnotationPath = 'CURVE' | 'ELBOW' | 'FREE' | 'ROUNDED_ELBOW' | 'STRAIGHT';
100
+
101
+ /** A point of the image, in px. */
102
+ declare type AnnotationPoint = {
103
+ x: number;
104
+ y: number;
105
+ };
106
+
107
+ /**
108
+ * An elbow's route kept as it was drawn: its corners from its start to its tip, and its middle leg (along `axis`, across
109
+ * the span `from`…`to`, each end leg at least `least` long), in its own frame (the image's px turned by its angle), for the
110
+ * `bend` it was routed with.
111
+ */
112
+ declare type AnnotationRoute = {
113
+ bend: AnnotationBend;
114
+ corners: AnnotationPoint[];
115
+ middle: {
116
+ axis: 'x' | 'y';
117
+ from: number;
118
+ least: number;
119
+ to: number;
120
+ } | null;
121
+ };
122
+
123
+ /**
124
+ * Where a line's end sits on the annotation that owns it, moved there by hand: a share of that one's box across and down,
125
+ * 0…1, in that one's own frame (a text's or a lens's box laid out level and turned with the image, a shape's or a line's
126
+ * on the image, turned by its angle). The end stays on its outline.
127
+ */
128
+ declare type AnnotationShare = {
129
+ x: number;
130
+ y: number;
131
+ };
132
+
133
+ /** A side of an annotation's box, in its own frame. `null`: none. */
134
+ declare type AnnotationSide = 'BOTTOM' | 'LEFT' | 'RIGHT' | 'TOP' | null;
135
+
136
+ /** A text's or the list's size: a share of the image's shorter side, 0.02…0.065 (small 0.028, medium 0.036, large 0.05). */
137
+ declare type AnnotationSize = number;
138
+
139
+ /** A line's stroke: solid, dashed, dotted, hand-drawn or a highlighter's. */
140
+ declare type AnnotationStroke = 'DASHED' | 'DOTTED' | 'MARKER' | 'SKETCH' | 'SOLID';
141
+
142
+ /** A point of a stroke drawn by hand, in image px, with the pen's pressure there (0…1) where a pen drew it. */
143
+ declare type AnnotationStrokePoint = {
144
+ pressure?: number;
145
+ x: number;
146
+ y: number;
147
+ };
148
+
149
+ /** What sits behind a label: light, dark, or the annotation's color. */
150
+ declare type AnnotationTheme = 'ACCENT' | 'DARK' | 'LIGHT';
151
+
152
+ /** A line's weight, seven steps from extra thin to extra thick: 0.45, 0.57, 0.7 (medium thin, the default), 0.9, 1.15, 1.45 and 1.85% of the photo's shorter side. */
153
+ declare type AnnotationWeight = 'EXTRA_THICK' | 'EXTRA_THIN' | 'MEDIUM' | 'MEDIUM_THICK' | 'MEDIUM_THIN' | 'THICK' | 'THIN';
154
+
155
+ /**
156
+ * The edits a host keeps (the `state` prop, and `onProcess`'s `state`), version 3, in the units the screen shows. The
157
+ * editor writes every field, its default included (no turn is 0, no flip `false`, an adjustment at 0 is 0, Auto, the
158
+ * filter, the frame and the list are `null` while off, no areas or annotations are `[]`, a free crop's `aspectRatio` is
159
+ * `null`, `size` is `null` while none is set, `crop.scale` is 100 at the photo's largest window, `crop.intent` the
160
+ * person's crop), so a later default never changes a kept state. A state you write may leave any field out: absent reads
161
+ * as its default. Its image px are those of the size the editor works the image at (`onLoad`'s `size`).
162
+ */
163
+ export declare type EditState = {
164
+ /** The adjustments set by hand, −100…100 (Sharpness 0…100). */
165
+ adjustments?: {
166
+ blackPoint?: number;
167
+ brightness?: number;
168
+ brilliance?: number;
169
+ contrast?: number;
170
+ exposure?: number;
171
+ highlights?: number;
172
+ saturation?: number;
173
+ shadows?: number;
174
+ sharpness?: number;
175
+ vibrance?: number;
176
+ vignette?: number;
177
+ warmth?: number;
178
+ };
179
+ /**
180
+ * The Numbers' list, one block: its center, the color of its badges, its letter, size and theme, its title, a
181
+ * width set by hand (a fraction of the image's shorter side; `null`: as wide as its longest row), and how many of the
182
+ * annotations, the last in their list, draw above it (absent: none, the list over them all). `null`: no list.
183
+ */
184
+ annotationList?: {
185
+ above?: number;
186
+ /** Its block's own frame (`AnnotationAngle`). */
187
+ angle?: AnnotationAngle;
188
+ /** The arrows added to the list, as a text's (its `arrows`), leaving its block. */
189
+ arrows?: AnnotationAddedArrow[];
190
+ at: AnnotationPoint;
191
+ color?: string;
192
+ font?: AnnotationFont;
193
+ size?: AnnotationSize;
194
+ theme?: AnnotationTheme;
195
+ title?: string;
196
+ width?: number | null;
197
+ } | null;
198
+ /**
199
+ * The annotations: lines (arrows and freehand), rulers, texts (and numbers), shapes and lenses. They draw in this
200
+ * list's order, a later one on top, each whole (a ruler with its label, a text with its number and arrows), the
201
+ * Numbers' list among them where `annotationList.above` sets it. Their points are in image px, before the crop, as
202
+ * `crop`'s. Each keeps its kind, id (`a` then lowercase letters and digits), color (`#rrggbb` or `#rgb`) and geometry,
203
+ * and every value of its style, its default included; a state that leaves one out reads its default.
204
+ */
205
+ annotations?: ({
206
+ angle?: AnnotationAngle;
207
+ bend?: AnnotationBend;
208
+ color: string;
209
+ end?: AnnotationCap;
210
+ from: AnnotationPoint;
211
+ /**
212
+ * What each end landed on (`from`, `to`), which it moves with: an annotation's `id`, or `'LIST'` for the list of the
213
+ * Numbers (`ANNOTATION_LIST_GLUE`). Absent or `null`: a loose end.
214
+ */
215
+ glued?: {
216
+ from?: string | null;
217
+ to?: string | null;
218
+ };
219
+ id: string;
220
+ path?: AnnotationPath;
221
+ /** The stroke drawn by hand (`FREE`), kept when the path changes. */
222
+ points?: AnnotationStrokePoint[];
223
+ /** What it is: a pointing line (the default), or a shape's Line (`'SHAPE'`: a straight segment the Shape tool draws). */
224
+ role?: 'ARROW' | 'SHAPE';
225
+ /**
226
+ * An elbow's route kept as it was drawn, once the glue of its ends changed with no end, bend or leg moved (Detach, what
227
+ * an end was glued to deleted, "+ Text" on it, its body moved): its corners from its start to its tip and its middle
228
+ * leg, in its own frame (the image's px turned by its `angle`), for the `bend` it was routed with. It holds while its
229
+ * ends stand where its corners begin and end. Absent: the route its ends and what they are glued to give.
230
+ */
231
+ route?: AnnotationRoute;
232
+ /**
233
+ * The side of what each glued end (`from`, `to`) was glued to, the one it was let go beside (or its glue dot's), in
234
+ * that one's own frame (a text's or a lens's laid out level and turned with the image, a shape's turned by its angle on
235
+ * the image): an elbow leaves or enters it there, and keeps it. Absent or `null`: the side its point gives.
236
+ */
237
+ sides?: {
238
+ from?: AnnotationSide;
239
+ to?: AnnotationSide;
240
+ };
241
+ start?: AnnotationCap;
242
+ stroke?: AnnotationStroke;
243
+ to: AnnotationPoint;
244
+ type: 'LINE';
245
+ weight?: AnnotationWeight;
246
+ } | {
247
+ /** Its label's own frame (`AnnotationAngle`): the label turns a half turn more where it would read upside down. */
248
+ angle?: AnnotationAngle;
249
+ color: string;
250
+ ends?: 'ARROW' | 'BAR' | 'NONE';
251
+ from: AnnotationPoint;
252
+ id: string;
253
+ label?: string;
254
+ /** Its label's size, a share of the image's shorter side, 0.02…0.065 (its line keeps its weight). Default 0.028, small. */
255
+ size?: number;
256
+ stroke?: AnnotationStroke;
257
+ theme?: AnnotationTheme;
258
+ to: AnnotationPoint;
259
+ type: 'RULER';
260
+ weight?: AnnotationWeight;
261
+ } | {
262
+ /** What the text points at: a point, or another annotation. `null`: nothing. */
263
+ anchor?: {
264
+ at: AnnotationPoint;
265
+ kind: 'POINT';
266
+ } | {
267
+ id: string;
268
+ kind: 'PIECE';
269
+ } | null;
270
+ /** Its own frame (`AnnotationAngle`): its box, its badge and its letters stand in it. */
271
+ angle?: AnnotationAngle;
272
+ /** The arrows added to the text, every value written; a state that leaves one out reads an added arrow's default (`end` a dot, a curve, medium thin). */
273
+ arrows?: AnnotationAddedArrow[];
274
+ /**
275
+ * The point the text grows from (`grows`): its center where it grows both ways, else the middle of the side it is
276
+ * held by.
277
+ */
278
+ at: AnnotationPoint;
279
+ body?: string;
280
+ color: string;
281
+ /** A box's corners: square (sharp), soft, or round (a pill on one line, a card past it). Default round. */
282
+ corners?: 'SQUARE' | 'SOFT' | 'ROUND';
283
+ /**
284
+ * The side of its box facing the start of the line "+ Text" made it for (`'BOTTOM'` over the start, `'TOP'` under
285
+ * it), set as it is made: its example words center over that start and its words wrap away from it, that side
286
+ * staying put. Absent or `null` on any other text.
287
+ */
288
+ faces?: AnnotationSide;
289
+ font?: AnnotationFont;
290
+ /**
291
+ * Which way it grows from `at` as its words and size change, across and down: `'BOTH'` round its point, or away
292
+ * from the side it is held by (`'LEFT'`: its right edge held; `'RIGHT'`: its left; `'UP'`: its bottom; `'DOWN'`:
293
+ * its top). A text the Text tool made grows away from the edge it was made nearest. Default both ways.
294
+ */
295
+ grows?: {
296
+ x: 'BOTH' | 'LEFT' | 'RIGHT';
297
+ y: 'BOTH' | 'DOWN' | 'UP';
298
+ };
299
+ id: string;
300
+ /** Plain, on a box (`BOX`, the default), or `CAPTION`: filled letters in a thick outline. */
301
+ look?: 'BOX' | 'CAPTION' | 'PLAIN';
302
+ /**
303
+ * What stands before a text's title: nothing, a dot, or its number (a format: the text stays a text, out of the
304
+ * list, counted among the texts in this format by `step`). Default a dot. Read on a text only: a Number always shows
305
+ * its badge.
306
+ */
307
+ mark?: 'DOT' | 'NONE' | 'NUMBER';
308
+ /** The room a box keeps round its words: tight, normal or loose. It changes the box, never the letters. Default normal. */
309
+ padding?: 'TIGHT' | 'NORMAL' | 'LOOSE';
310
+ /** What it is: a text (the default), or a Number (the Number tool's: alone, with words, or in the list). */
311
+ role?: 'NUMBER' | 'TEXT';
312
+ size?: AnnotationSize;
313
+ /**
314
+ * Its place in its count, whatever its place in this list (what draws over what): a Number's among the Numbers
315
+ * (the list's order), a text's in the Number format among those texts. One without it counts first, in this
316
+ * list's order.
317
+ */
318
+ step?: number;
319
+ theme?: AnnotationTheme;
320
+ title?: string;
321
+ type: 'TEXT';
322
+ /** Its largest width, set by hand: a fraction of the image's shorter side. `null`: automatic. */
323
+ width?: number | null;
324
+ } | {
325
+ angle?: AnnotationAngle;
326
+ box: Rect;
327
+ color: string;
328
+ /** The opacity its inside is filled at in its color, 0 to 1: 0 (the default) its outline alone, 1 opaque. */
329
+ fill?: number;
330
+ id: string;
331
+ kind?: 'ELLIPSE' | 'RECT' | 'ROUNDED';
332
+ stroke?: AnnotationStroke;
333
+ type: 'SHAPE';
334
+ weight?: AnnotationWeight;
335
+ } | {
336
+ /** Its own frame (`AnnotationAngle`): its rim's, and the side its line leaves it by. */
337
+ angle?: AnnotationAngle;
338
+ /** The lens's center. */
339
+ at: AnnotationPoint;
340
+ bend?: AnnotationBend;
341
+ color: string;
342
+ /** How its line ends on the point it magnifies. Default `'DOT'`, the ringed dot. */
343
+ end?: AnnotationCap;
344
+ /** Where its line leaves its rim, a share of the lens's box. Absent or `null`: toward the point it magnifies. */
345
+ exit?: AnnotationShare | null;
346
+ id: string;
347
+ line?: 'DASHED' | 'DOTTED' | 'MARKER' | 'SKETCH' | 'SOLID' | 'TRANSPARENT';
348
+ /**
349
+ * Its line's own frame (`AnnotationAngle`), apart from the lens's: its elbow routes in it, born level on the screen when
350
+ * its path becomes an elbow, the lens left as it is. Absent: 0, the image's own frame.
351
+ */
352
+ lineAngle?: AnnotationAngle;
353
+ /** The point it magnifies. */
354
+ origin: AnnotationPoint;
355
+ /**
356
+ * The way its line runs. Default `'CURVE'`.
357
+ */
358
+ path?: 'CURVE' | 'ELBOW' | 'ROUNDED_ELBOW' | 'STRAIGHT';
359
+ radius: number;
360
+ shape?: 'CIRCLE' | 'ROUNDED';
361
+ /** How its line ends at the lens, touching its rim. Default `'NONE'`. */
362
+ start?: AnnotationCap;
363
+ theme?: AnnotationTheme;
364
+ type: 'LENS';
365
+ weight?: AnnotationWeight;
366
+ /** Its magnification, 1…8. */
367
+ zoom?: number;
368
+ })[];
369
+ /**
370
+ * Auto while it is on: its ruler's `amount` and the photo's default `origin` (−100…100 and 0…100), with the numbers
371
+ * the photo's analysis gave (Levels' black and white, the median and where it goes, the fill, the S-curve, the color
372
+ * gain), so a saved edit reopens as it was. `null`: off.
373
+ */
374
+ auto?: {
375
+ amount: number;
376
+ black: number;
377
+ color: number;
378
+ contrast: number;
379
+ median: number;
380
+ midtone: number;
381
+ origin: number;
382
+ shadows: number;
383
+ white: number;
384
+ } | null;
385
+ /**
386
+ * The crop, in image px, and its ratio (width / height; `null`: free). `intent`: the person's crop, the window they chose,
387
+ * unrounded, which no angle changes; `crop` is what the image turned by `rotation` holds of it (itself where it fits,
388
+ * shrunk round its center where the straightening cuts it), so reopening goes on as if the editor never closed (the
389
+ * ruler back to 0° gives back the window the person chose). Absent, or one that no longer gives `crop` at `rotation` (a
390
+ * host changed either): the crop is taken as the person's crop. `scale`: that window's Scale, in % (100 is the photo's
391
+ * largest window of the crop's ratio), for a host to read; the editor reopens from `intent`.
392
+ */
393
+ crop: {
394
+ aspectRatio?: number | null;
395
+ height: number;
396
+ intent?: Rect;
397
+ scale?: number;
398
+ width: number;
399
+ x: number;
400
+ y: number;
401
+ };
402
+ /** The filter and its intensity, 0…100. `null`: none. */
403
+ filter?: {
404
+ id: 'DRAMATIC' | 'DRAMATIC_COOL' | 'DRAMATIC_WARM' | 'MONO' | 'NOIR' | 'SILVERTONE' | 'VIVID' | 'VIVID_COOL' | 'VIVID_WARM';
405
+ intensity: number;
406
+ } | null;
407
+ /** Mirrored left to right. */
408
+ flipX?: boolean;
409
+ /** Mirrored top to bottom. */
410
+ flipY?: boolean;
411
+ /** The frame and its color (`#rrggbb`, always written; a state without it reads white). `null`: none. */
412
+ frame?: {
413
+ color?: string;
414
+ style: 'CORNER_HOOKS' | 'EDGE_CROSS' | 'EDGE_OVERLAP' | 'EDGE_SEPARATE' | 'FILM' | 'GALLERY' | 'LINE_MULTIPLE' | 'LINE_SINGLE' | 'MAT_ROUND' | 'MAT_SHARP' | 'PHOTO_CORNERS' | 'POLAROID' | 'ROUND_CORNERS';
415
+ } | null;
416
+ /**
417
+ * What the person adjusted of each mark, never the image nor the host's text: a text they wrote, where they put the
418
+ * signature (a point, or its center `x`/`y` 0…1 on the final photo), sizes, margin, spacing, angle, opacity, the
419
+ * `color` they chose (`'AUTO'` or a hex; absent while it is the host's), the `font` a text mark's letter is in (its slug;
420
+ * absent while it is the host's), and `hidden` for a free mark they took out. The
421
+ * watermark's `layout` is the one they switched it to, absent while it is the host's; its `angle`, `size` and `spacing`
422
+ * are that layout's, and the ones they gave the other layout wait under `grid` or `single` for it to show again. The
423
+ * editor writes both roles; what a role leaves out is the host's, never a default, so it stays out.
424
+ */
425
+ marks?: {
426
+ signature?: {
427
+ color?: 'AUTO' | string;
428
+ font?: AnnotationFont;
429
+ hidden?: true;
430
+ margin?: number;
431
+ opacity?: number;
432
+ position?: 'BOTTOM' | 'BOTTOM_LEFT' | 'BOTTOM_RIGHT' | 'CENTER' | 'LEFT' | 'RIGHT' | 'TOP' | 'TOP_LEFT' | 'TOP_RIGHT';
433
+ size?: number;
434
+ text?: string;
435
+ x?: number;
436
+ y?: number;
437
+ };
438
+ watermark?: {
439
+ angle?: number;
440
+ color?: 'AUTO' | string;
441
+ font?: AnnotationFont;
442
+ grid?: {
443
+ angle?: number;
444
+ size?: number;
445
+ spacing?: number;
446
+ };
447
+ hidden?: true;
448
+ layout?: 'GRID' | 'SINGLE';
449
+ opacity?: number;
450
+ single?: {
451
+ angle?: number;
452
+ size?: number;
453
+ };
454
+ size?: number;
455
+ spacing?: number;
456
+ text?: string;
457
+ };
458
+ };
459
+ /**
460
+ * The obfuscated areas, in image px: each with its shape, style, strength (0…100) and a solid area's color (`#rrggbb`)
461
+ * where they differ from a blurred square at 50 that paints black once solid. At most 64, as many as the Obfuscate tool
462
+ * draws: more is `INVALID_STATE`.
463
+ */
464
+ obfuscation?: {
465
+ /** Its rect's turn about its middle on the image (`AnnotationAngle`): born level on the screen, turned by its rotate handle, absent 0. */
466
+ angle?: AnnotationAngle;
467
+ color?: string;
468
+ height: number;
469
+ shape?: 'ELLIPSE' | 'RECT' | 'ROUNDED';
470
+ strength?: number;
471
+ style?: 'BLUR' | 'PIXELATE' | 'SOLID';
472
+ width: number;
473
+ x: number;
474
+ y: number;
475
+ }[];
476
+ /** The turn, in degrees. */
477
+ rotation?: number;
478
+ /**
479
+ * The size the crop is drawn at, in output px, set apart from the crop's own. `null`: none, the crop drawn at its own size
480
+ * (each side whole). The output never passes 16.7 MP (2^24 px).
481
+ */
482
+ size?: Size | null;
483
+ /** The shape's version: a state with one is the editor's own. The editor writes and reads 3. */
484
+ version: 3;
485
+ };
486
+
487
+ /**
488
+ * One base color per role, each the 500 of the scale the editor makes from it: a hex (`#6366f1`), `rgb()`, `hsl()` or a
489
+ * CSS color name. The only way to theme the editor: every step of a role and the text on the accent come from it
490
+ * together. A role left out takes the default.
491
+ */
492
+ export declare type EmbedEditorColors = {
493
+ /** The host's brand: the buttons that act (Save, Annotate's button while on, Choose File), what the stage selects and snaps to, and the annotations' Default color. Default yellow. */
494
+ accent?: string;
495
+ /** The value controls only: a positive value's ring, the ruler's needle, the tool marker, a slider's handle. Default yellow. */
496
+ controls?: string;
497
+ /** The editor's body: backgrounds, text, lines. Default zinc. */
498
+ surface?: string;
499
+ };
500
+
501
+ /**
502
+ * A command as `commands()` lists it, for a model to call through `run`: its name (`run`'s `command`), what it does, and
503
+ * its input as a JSON Schema (draft 2020-12; an object with no properties for a command that takes nothing).
504
+ */
505
+ export declare type EmbedEditorCommand = {
506
+ command: string;
507
+ description: string;
508
+ input: Record<string, unknown>;
509
+ };
510
+
511
+ /**
512
+ * What a command of `EmbedEditorHandle` rejects with, besides the editor's own codes (`EmbedEditorErrorCode`: Save's
513
+ * `EXPORT_FAILED` and `MARK_FAILED`): `INVALID_COMMAND`, `NOT_AVAILABLE` (a tool the props turned off or the edition
514
+ * doesn't have, or the editor was destroyed or closed; each command names its own cases) or `NOT_FOUND` (no area at that
515
+ * index, no annotation with that id). `INVALID_COMMAND` is of two kinds, its `props` naming each path from the input
516
+ * (`input.item`) either way: an input off its schema, or a command the handle doesn't have (`props` `['command']`),
517
+ * rejects at once, its `cause` the schema's own error (none for an unknown name); an input the command can't take where
518
+ * the editor stands (an area no drag would draw, a key the annotation's kind doesn't take, a size off the watermark's
519
+ * layout) rejects on the command's turn, with no `cause`. A rejected command changes nothing.
520
+ */
521
+ export declare type EmbedEditorCommandErrorCode = 'INVALID_COMMAND' | 'NOT_AVAILABLE' | 'NOT_FOUND';
522
+
523
+ /**
524
+ * What `onLoadError` and `onProcessError` receive, and `processImage` and a command reject with: its `message` is its
525
+ * `code`. `Code` is what it can be: the editor's own codes (`EmbedEditorErrorCode`) unless said; a command rejects with a
526
+ * command's code too (`EmbedEditorCommandErrorCode`).
527
+ */
528
+ export declare class EmbedEditorError<Code extends EmbedEditorCommandErrorCode | EmbedEditorErrorCode = EmbedEditorErrorCode> extends Error {
529
+ /** What failed. */
530
+ code: Code;
531
+ /**
532
+ * The props `INVALID_PROPS` names (one inside another by its path: `colors.accent`), or the paths `INVALID_COMMAND`
533
+ * names (`input.item`, or `command` for a command the handle doesn't have); empty for any other code. `cause` (the
534
+ * standard `Error` one) holds, for an `INVALID_COMMAND`, the schema's own error when the input is off its schema, and
535
+ * nothing for an unknown command or an input the command can't take where the editor stands (rejected on its turn).
536
+ */
537
+ props: string[];
538
+ constructor(code: Code, options?: {
539
+ cause?: unknown;
540
+ props?: string[];
541
+ });
542
+ }
543
+
544
+ /**
545
+ * What failed: `INVALID_PROPS` (a prop the editor can't take; the error names it), `INVALID_STATE` (a saved state it
546
+ * can't read), `LOAD_FAILED`, `MARK_FAILED` (a mark's image or letter that didn't load, or a fixed or required mark
547
+ * Save couldn't draw), `UNSUPPORTED_FORMAT`, `WEBGL_UNAVAILABLE` (the browser can't run the editor) or `EXPORT_FAILED`
548
+ * (Save couldn't make the file). The codes `onLoadError`, `onProcessError` and `processImage` give; a command rejects
549
+ * with these or with an `EmbedEditorCommandErrorCode`.
550
+ */
551
+ export declare type EmbedEditorErrorCode = 'EXPORT_FAILED' | 'INVALID_PROPS' | 'INVALID_STATE' | 'LOAD_FAILED' | 'MARK_FAILED' | 'UNSUPPORTED_FORMAT' | 'WEBGL_UNAVAILABLE';
552
+
553
+ /** What each event of `on` hands its handler. */
554
+ export declare type EmbedEditorEvents = {
555
+ /**
556
+ * The state after a step of the history lands: an edit (a command's or the person's, a drag once it is let go), an
557
+ * undo, a redo, a reset; or the ratio the host locks landing on the photo (no step to undo then). Never a gesture's
558
+ * preview while it runs, nor a command that changed nothing.
559
+ */
560
+ change: {
561
+ state: EditState;
562
+ };
563
+ /** The menu item and the tool open on the stage, once either changes. `tool` is `'ANNOTATE'` while Annotate is open. */
564
+ item: {
565
+ item: EmbedEditorMenuItem;
566
+ tool: EmbedEditorTool;
567
+ };
568
+ /** The image on screen, once per open, at the moment `onLoad` hears of it. */
569
+ load: {
570
+ file: File | null;
571
+ size: Size;
572
+ };
573
+ /** A Save that went through (its button's or `output.save`), what `onProcess` gets. */
574
+ save: {
575
+ dest: File;
576
+ state: EditState;
577
+ };
578
+ /** What is selected, once it changes (`EmbedEditorSelection`). */
579
+ select: EmbedEditorSelection;
580
+ };
581
+
582
+ /**
583
+ * The editor's commands, reads and events, from a `ref` on `EmbedEditor` or what `mountEditor` and `openEditor` return.
584
+ * Every command takes one object (none for some) and returns a Promise; the commands queue, each in call order once the
585
+ * image is on screen (`ready`) and the editor is free: no gesture held, no save on its way, no words being typed. It
586
+ * resolves once the editor rendered its result: the step is in the history and on screen (`null`, or what it made). It
587
+ * acts as the same control on screen does, with its motion and its undo step, but never as a hand: no name over the
588
+ * photo, no ruler's focus. Values and units are the saved state's (`EditState`). A command rejects with an
589
+ * `EmbedEditorError` (`EmbedEditorCommandErrorCode`, or Save's own codes) and then changes nothing. Once the editor
590
+ * leaves the page (unmounted, its `<Activity>` hidden, `destroy`, `close`), every command waiting and every one called
591
+ * after rejects `NOT_AVAILABLE`, until it is back; a command running as it leaves rejects too, though what it already
592
+ * changed stays, and changes nothing more, the editor back or not. Before the editor first mounts, a command waits for it.
593
+ */
594
+ export declare type EmbedEditorHandle = {
595
+ /**
596
+ * The adjustments, as their rulers set them, by their keys in the state's `adjustments`. Each is one undo step, none when
597
+ * nothing changes; `NOT_AVAILABLE` where `enableFinetune` turns them off. The Full's: `NOT_AVAILABLE` in the Free and the
598
+ * Lite.
599
+ */
600
+ adjust: {
601
+ /** The adjustment back to 0. */
602
+ reset: (input: {
603
+ key: keyof NonNullable<EditState['adjustments']>;
604
+ }) => Promise<null>;
605
+ /** The adjustment at `value`, −100…100 (`sharpness` 0…100), as its ruler. */
606
+ set: (input: {
607
+ key: keyof NonNullable<EditState['adjustments']>;
608
+ value: number;
609
+ }) => Promise<null>;
610
+ };
611
+ /**
612
+ * Annotate (the Full's and the Trial's; elsewhere each command rejects `NOT_AVAILABLE`), as its controls do, in
613
+ * `EditState`'s names and image px. An edit never opens Annotate, and selects what it made only while Annotate is open;
614
+ * a verb of the action bar rejects `NOT_AVAILABLE` where the bar doesn't offer it for that annotation (`read.options`
615
+ * lists what it offers), and an `id` the state lacks rejects `NOT_FOUND`. Every command rejects `NOT_AVAILABLE` while
616
+ * the host turned Annotate off (`enableAnnotate: false`).
617
+ */
618
+ annotate: {
619
+ /**
620
+ * An annotation, as a tap or a drag of its tool makes one: a `LINE` (with `points` a drawing, with `role: 'SHAPE'` a
621
+ * Shape's Line), a `RULER`, a `TEXT` (with `role: 'NUMBER'` a Number), a `SHAPE` or a `LENS`; what it leaves out
622
+ * takes its tool's last style (`setStyle`), and a text's `title` and `body` (a ruler's `label`) are typed into it.
623
+ * One undo step; resolves to its `id`. `NOT_AVAILABLE` once the photo holds the most annotations it takes.
624
+ */
625
+ add: (input: {
626
+ piece: AnnotatePiece;
627
+ }) => Promise<{
628
+ id: string;
629
+ }>;
630
+ /**
631
+ * The action bar's Add Arrow on a text, a Number or the Numbers' list (`id: 'LIST'`): an arrow from it to `to` (left
632
+ * out: where the bar points it, out of the side facing the photo's middle). One undo step; resolves to its owner's
633
+ * `id` (`'LIST'` for the list) and the arrow's place in its `arrows` (`arrow`).
634
+ */
635
+ addArrow: (input: {
636
+ id: string;
637
+ to?: {
638
+ x: number;
639
+ y: number;
640
+ };
641
+ }) => Promise<{
642
+ arrow: number;
643
+ id: string;
644
+ }>;
645
+ /** The action bar's + Leader on a magnifier on its own spot: it moves to the free spot a tap's takes, its line showing. One undo step. */
646
+ addLeader: (input: {
647
+ id: string;
648
+ }) => Promise<null>;
649
+ /**
650
+ * The action bar's + Text on an arrow, a line, a drawing, a shape or a magnifier: a text born touching it in the Text
651
+ * tool's last style, `title` and `body` typed into it. One undo step; resolves to the text's `id`.
652
+ */
653
+ addText: (input: {
654
+ body?: string;
655
+ id: string;
656
+ title?: string;
657
+ }) => Promise<{
658
+ id: string;
659
+ }>;
660
+ /** The action bar's Bring to Front: the annotation, or the Numbers' list (`id: 'LIST'`), over the ones covering it. One undo step. */
661
+ bringToFront: (input: {
662
+ id: string;
663
+ }) => Promise<null>;
664
+ /** Annotate closed, as its button: what was selected lets go. */
665
+ close: () => Promise<null>;
666
+ /**
667
+ * The action bar's Detach: a line's glued ends, or the glued tip of the arrow `arrow` of a text or of the Numbers' list
668
+ * (`id: 'LIST'`), let go where they are. One undo step.
669
+ */
670
+ detach: (input: {
671
+ arrow?: number;
672
+ id: string;
673
+ }) => Promise<null>;
674
+ /** The action bar's Duplicate: a copy a step down and right on the screen, whatever the photo's turn or mirror, with its text. One undo step; resolves to the copy's `id`. */
675
+ duplicate: (input: {
676
+ id: string;
677
+ }) => Promise<{
678
+ id: string;
679
+ }>;
680
+ /** In a List: the Numbers' words in a list placed off the photo's subject (the one `unlist` took away, if any). One undo step. */
681
+ list: () => Promise<null>;
682
+ /**
683
+ * Annotate opened, as its button: on the tool chosen last, nothing selected. Resolves once it is open (the view then
684
+ * moves to its room). `NOT_AVAILABLE` where its screens fail to load.
685
+ */
686
+ open: () => Promise<null>;
687
+ /**
688
+ * The action bar's Delete: the annotation with what it owns, the Numbers' list (`id: 'LIST'`, its Numbers staying), or
689
+ * only the arrow `arrow` of a text or of the list. One undo step.
690
+ */
691
+ remove: (input: {
692
+ arrow?: number;
693
+ id: string;
694
+ }) => Promise<null>;
695
+ /**
696
+ * Annotate opened with an annotation selected, the Numbers' list (`id: 'LIST'`), or the arrow `arrow` of a text or of
697
+ * the list, as a tap on it; `id: null` lets the selection go, and opens nothing.
698
+ */
699
+ select: (input: {
700
+ arrow?: number;
701
+ id: string | null;
702
+ }) => Promise<null>;
703
+ /** The Numbers' list's title, as its own field writes it (trimmed). One undo step. `NOT_FOUND` with no list. */
704
+ setListTitle: (input: {
705
+ title: string;
706
+ }) => Promise<null>;
707
+ /**
708
+ * The style the next annotation of `tool` (left out: the one open on Annotate's carousel) is born in, as the rows
709
+ * with nothing selected; `kind: 'LINE'` makes the Shape's next one a Line. `INVALID_COMMAND` for an option that
710
+ * annotation has none of.
711
+ */
712
+ setStyle: (input: Flat<AnnotateStyle & {
713
+ kind?: 'ELLIPSE' | 'LINE' | 'RECT' | 'ROUNDED';
714
+ tool?: AnnotateTool;
715
+ }>) => Promise<null>;
716
+ /** The theme the next annotation is born in (what sits behind its words). */
717
+ setTheme: (input: {
718
+ theme: AnnotationTheme;
719
+ }) => Promise<null>;
720
+ /** The tool a tap or a drag on the photo makes, as Annotate's carousel: what was selected lets go. */
721
+ setTool: (input: {
722
+ tool: AnnotateTool;
723
+ }) => Promise<null>;
724
+ /** Beside: the Numbers' list taken away, each Number's words back by its badge; `list` brings it back. One undo step. */
725
+ unlist: () => Promise<null>;
726
+ /**
727
+ * An annotation changed (or, with `arrow`, the arrow of a text or of the Numbers' list), as its style row, color row
728
+ * and typing do: its style, a `theme`, its words (a text's `title` and `body`, a ruler's `label`) and its geometry
729
+ * (`from`, `to`, `at`, `box`, `origin`, `radius`, `angle`, `bend`, `width`, written as given). The list (`id: 'LIST'`)
730
+ * and a Number in it set the list's color, theme, font and size with every Number's; an arrow takes its owner's
731
+ * color and no theme. One undo step. `INVALID_COMMAND` for what that annotation has none of.
732
+ */
733
+ update: (input: Flat<AnnotateStyle & {
734
+ angle?: AnnotationAngle;
735
+ arrow?: number;
736
+ at?: AnnotationPoint;
737
+ bend?: AnnotationBend;
738
+ body?: string;
739
+ box?: Rect;
740
+ from?: AnnotationPoint;
741
+ id: string;
742
+ kind?: 'ELLIPSE' | 'RECT' | 'ROUNDED';
743
+ label?: string;
744
+ origin?: AnnotationPoint;
745
+ radius?: number;
746
+ theme?: AnnotationTheme;
747
+ title?: string;
748
+ to?: AnnotationPoint;
749
+ width?: number | null;
750
+ }>) => Promise<null>;
751
+ };
752
+ /**
753
+ * Auto, as its ring, its Auto Enhance button and its ruler. Each is one undo step, none when nothing changes;
754
+ * `NOT_AVAILABLE` where `enableFinetune` turns it off. The Full's: `NOT_AVAILABLE` in the Free and the Lite.
755
+ */
756
+ auto: {
757
+ /** Auto off, as a tap on its ring: its amount kept for `on` to bring back. */
758
+ off: () => Promise<null>;
759
+ /**
760
+ * Auto on, as a tap on its ring: at the amount a tap turned it off at, or at the image's own amount once the image is
761
+ * read (it waits for the reading). `NOT_AVAILABLE` when the image can't be read or its reading takes too long.
762
+ */
763
+ on: () => Promise<null>;
764
+ /** How much Auto does, −100…100 (the state's `auto.amount`), as its ruler. `NOT_AVAILABLE` while Auto is off. */
765
+ setAmount: (input: {
766
+ value: number;
767
+ }) => Promise<null>;
768
+ };
769
+ /** Every command `run` takes, for a model's tools: its name, what it does and its input's JSON Schema. */
770
+ commands: () => EmbedEditorCommand[];
771
+ /** Adjust's crop, as its pill, its sections and its ruler set it. Each is one undo step, none when nothing changes. */
772
+ crop: {
773
+ /** The image mirrored across (`'X'`, the pill's Flip) or up and down (`'Y'`), the window staying on the photo. */
774
+ flip: (input: {
775
+ axis: 'X' | 'Y';
776
+ }) => Promise<null>;
777
+ /**
778
+ * The image turned a quarter, `'LEFT'` (the pill's Rotate) or `'RIGHT'`: the whole photo turns with its window, any
779
+ * other window stays where it is on the screen.
780
+ */
781
+ rotate: (input: {
782
+ direction: 'LEFT' | 'RIGHT';
783
+ }) => Promise<null>;
784
+ /**
785
+ * The crop zoomed round its middle to the Scale's `percent`, 100…1000 (the state's `crop.scale`: 100 the photo's
786
+ * largest window of the crop's ratio), as the Scale slider does; under the least the turned photo holds, that least.
787
+ */
788
+ scale: (input: {
789
+ percent: number;
790
+ }) => Promise<null>;
791
+ /**
792
+ * The window, in the px of the state's `crop`, as the person's crop: one past the photo moves in, one larger than it
793
+ * shrinks at its ratio. A ratio in effect stays for a window of it, and goes for any other. `NOT_AVAILABLE` for a
794
+ * window off the ratio the host locks.
795
+ */
796
+ set: (input: {
797
+ height: number;
798
+ width: number;
799
+ x: number;
800
+ y: number;
801
+ }) => Promise<null>;
802
+ /**
803
+ * Where the window goes, as Focus's menu: on the photo's subject or its middle. The window of the ratio in effect goes
804
+ * there now (no step when it is there already), and every ratio chosen next takes it. `'SUBJECT'` on a photo whose
805
+ * subject can't be read keeps the choice, moves no window and shows the editor's notice that Focus couldn't read the
806
+ * photo; it still resolves.
807
+ */
808
+ setFocus: (input: {
809
+ focus: 'CENTER' | 'SUBJECT';
810
+ }) => Promise<null>;
811
+ /**
812
+ * The ratio, by its name in the Aspect section, as a tap on it there: its largest window, where Focus places it.
813
+ * `null` frees it, the window as it is (with the Aspect section open, the one it opened on, as Free there gives
814
+ * back). The ratio in effect changes nothing. `NOT_AVAILABLE` while the host locks the ratio.
815
+ */
816
+ setRatio: (input: {
817
+ ratio: '1:1' | '1:2' | '16:9' | '2:1' | '3:4' | '4:3' | '9:16' | null;
818
+ }) => Promise<null>;
819
+ /** The image straightened to the angle Adjust's ruler shows, −45…45 degrees, the photo turning under the window. */
820
+ straighten: (input: {
821
+ angle: number;
822
+ }) => Promise<null>;
823
+ };
824
+ /** The editor itself. */
825
+ editor: {
826
+ /**
827
+ * Closes the editor as its Close button does: the host's `onClose`, or the modal's own close in `openEditor` (which
828
+ * then takes no more commands). `NOT_AVAILABLE` where there is none (`EmbedEditor` or `mountEditor` with no `onClose`).
829
+ */
830
+ close: () => Promise<null>;
831
+ };
832
+ /**
833
+ * The filter, as Filter's strip and its ruler. Each is one undo step, none when nothing changes; `NOT_AVAILABLE` where
834
+ * `enableFilter` turns it off. The Full's: `NOT_AVAILABLE` in the Free and the Lite.
835
+ */
836
+ filter: {
837
+ /** No filter, as Original in the strip. */
838
+ clear: () => Promise<null>;
839
+ /**
840
+ * A filter by its id, as a tap on it in the strip: another comes in at full strength, or at `intensity` (0…100, as
841
+ * its ruler); the one chosen already keeps its intensity, or takes `intensity` as its ruler.
842
+ */
843
+ set: (input: {
844
+ id: 'DRAMATIC' | 'DRAMATIC_COOL' | 'DRAMATIC_WARM' | 'MONO' | 'NOIR' | 'SILVERTONE' | 'VIVID' | 'VIVID_COOL' | 'VIVID_WARM';
845
+ intensity?: number;
846
+ }) => Promise<null>;
847
+ };
848
+ /**
849
+ * The frame, as Frame's strip and its row of colors. Each is one undo step, none when nothing changes; `NOT_AVAILABLE`
850
+ * where `enableFrame` turns it off. The Full's: `NOT_AVAILABLE` in the Free and the Lite.
851
+ */
852
+ frame: {
853
+ /** No frame, as None in the strip, its color kept for the next. */
854
+ clear: () => Promise<null>;
855
+ /**
856
+ * A frame by its style and its color (`#rrggbb` or `#rgb`), as a tap on its tile and one on a color: the frame's
857
+ * color now when `color` is left out (white at first).
858
+ */
859
+ set: (input: {
860
+ color?: string;
861
+ style: 'CORNER_HOOKS' | 'EDGE_CROSS' | 'EDGE_OVERLAP' | 'EDGE_SEPARATE' | 'FILM' | 'GALLERY' | 'LINE_MULTIPLE' | 'LINE_SINGLE' | 'MAT_ROUND' | 'MAT_SHARP' | 'PHOTO_CORNERS' | 'POLAROID' | 'ROUND_CORNERS';
862
+ }) => Promise<null>;
863
+ };
864
+ /** The history, as Undo, Redo and Reset on the toolbar. Each waits its turn; with nothing to take, it changes nothing. */
865
+ history: {
866
+ /** The step undone last, again. */
867
+ redo: () => Promise<null>;
868
+ /**
869
+ * Every edit taken away, as the toolbar's Reset (no confirm asked): a `state` the editor opened with too, the crop
870
+ * ratio `aspectRatio` sets or `aspectRatioLocked` holds kept. One step undo takes back.
871
+ */
872
+ reset: () => Promise<null>;
873
+ /** The last step taken back: the image and the view as they were before it. */
874
+ undo: () => Promise<null>;
875
+ };
876
+ /**
877
+ * The host's watermark and signature (the Full's), each by its role, adjusted as the person adjusts them in its item, in
878
+ * the units the state keeps them in (`EditState`'s `marks`). None opens the field a mark's text is typed in.
879
+ * `NOT_AVAILABLE` for a mark the host didn't give or made 'fixed', for what its props forbid (a logo's letter and text, a
880
+ * logo signature's color, a required mark's text and hiding), and in the Free and the Lite.
881
+ */
882
+ marks: {
883
+ /** A free mark taken out of the image and the file, as its pill's Show does. One undo step (none when it is hidden already). */
884
+ hide: (input: {
885
+ role: 'SIGNATURE' | 'WATERMARK';
886
+ }) => Promise<null>;
887
+ /**
888
+ * The signature at one of its 9 points (`position`), or with its center at a spot of the final image (`x` and `y`,
889
+ * 0…1): exactly one of them, as a drag on the stage drops it (a spot within 6% of the image's shorter side of a point
890
+ * sticks to it, and the signature stays whole on the image). One undo step.
891
+ */
892
+ place: (input: {
893
+ position?: 'BOTTOM' | 'BOTTOM_LEFT' | 'BOTTOM_RIGHT' | 'CENTER' | 'LEFT' | 'RIGHT' | 'TOP' | 'TOP_LEFT' | 'TOP_RIGHT';
894
+ role: 'SIGNATURE';
895
+ x?: number;
896
+ y?: number;
897
+ }) => Promise<null>;
898
+ /** A free mark hidden by `hide` back on the image and the file. One undo step (none when it shows already). */
899
+ show: (input: {
900
+ role: 'SIGNATURE' | 'WATERMARK';
901
+ }) => Promise<null>;
902
+ /**
903
+ * A mark adjusted as its pill does, what `input` gives changed and the rest kept, as one undo step: a watermark's
904
+ * `layout` first (the values given land in it), its `size` (1…20 in a grid, 4…60 single), `spacing` (a grid's) and
905
+ * `angle`; a signature's `size` (2…40) and `margin`; either's `opacity`, `color` (`'AUTO'` or a hex), `font` and `text`
906
+ * (as its field's Done writes it, trimmed). `INVALID_COMMAND` for a field the other mark takes (`margin` on the
907
+ * watermark, `angle`, `layout` or `spacing` on the signature), a size off its range, a spacing on a single watermark.
908
+ */
909
+ update: (input: {
910
+ angle?: number;
911
+ color?: 'AUTO' | string;
912
+ font?: AnnotationFont;
913
+ layout?: 'GRID' | 'SINGLE';
914
+ margin?: number;
915
+ opacity?: number;
916
+ role: 'SIGNATURE' | 'WATERMARK';
917
+ size?: number;
918
+ spacing?: number;
919
+ text?: string;
920
+ }) => Promise<null>;
921
+ };
922
+ /** The menu's carousel, and Adjust's sections over it. */
923
+ menu: {
924
+ /** Adjust's Scale or Aspect section closed, back to the carousel, as its Done; a ratio it still waits on lands. */
925
+ closeSection: () => Promise<null>;
926
+ /**
927
+ * Adjust's Scale (its zoom slider) or Aspect (its ratios) section opened over the carousel, as the crop pill's buttons,
928
+ * the menu going to Adjust first. The section open stays as it is. `NOT_AVAILABLE` for `'ASPECT'` while the host
929
+ * locks the ratio, and for both while Annotate is open.
930
+ */
931
+ openSection: (input: {
932
+ section: 'ASPECT' | 'SCALE';
933
+ }) => Promise<null>;
934
+ /**
935
+ * The item the menu shows, as a tap on it in the carousel (no name over the photo): its tool opens on the stage. The
936
+ * item already shown stays as it is. `NOT_AVAILABLE` for an item the props turned off or the edition doesn't have,
937
+ * and while Annotate is open (no carousel on screen then: `annotate.close` first).
938
+ */
939
+ select: (input: {
940
+ item: EmbedEditorMenuItem;
941
+ }) => Promise<null>;
942
+ /**
943
+ * An item with a ring turned off and back, as a tap on its ring: a value to zero (the straightening for `'ADJUST'`)
944
+ * and back to what it was, a filter, a frame or Auto off and back (Auto with nothing to come back to turns on at the
945
+ * image's own amount, once it is read). One undo step. `NOT_AVAILABLE` as for `select`, and for `'AUTO'` when the
946
+ * image can't be read or its reading takes too long (nothing changes then).
947
+ */
948
+ toggle: (input: {
949
+ item: 'ADJUST' | 'AUTO' | 'BLACK_POINT' | 'BRIGHTNESS' | 'BRILLIANCE' | 'CONTRAST' | 'EXPOSURE' | 'FILTER' | 'FRAME' | 'HIGHLIGHTS' | 'SATURATION' | 'SHADOWS' | 'SHARPNESS' | 'VIBRANCE' | 'VIGNETTE' | 'WARMTH';
950
+ }) => Promise<null>;
951
+ };
952
+ /**
953
+ * Obfuscate's areas (the Full's), each by its index in the state's `obfuscation` (an area has no id), in its units:
954
+ * the image's px, degrees, strength 0…100. `NOT_AVAILABLE` while the host has Obfuscate off (`enableObfuscate: false`),
955
+ * and in the Free and the Lite.
956
+ */
957
+ obfuscate: {
958
+ /**
959
+ * A new area, as a drawing on the stage makes one: the look it gives, the rest as the next area's (what Obfuscate's
960
+ * controls show with no area selected), born level on the screen unless `angle` turns it; selected once added while
961
+ * Obfuscate is open. One undo step. Resolves to its index. `NOT_AVAILABLE` with 64 areas already; `INVALID_COMMAND`
962
+ * for one a drawing never makes, a side under 1 px or nothing of it on the crop (its rect's paths in `props`).
963
+ */
964
+ add: (input: {
965
+ angle?: number;
966
+ color?: string;
967
+ height: number;
968
+ shape?: 'ELLIPSE' | 'RECT' | 'ROUNDED';
969
+ strength?: number;
970
+ style?: 'BLUR' | 'PIXELATE' | 'SOLID';
971
+ width: number;
972
+ x: number;
973
+ y: number;
974
+ }) => Promise<{
975
+ index: number;
976
+ }>;
977
+ /** The area at `index` removed, as Delete removes the selected one: the areas after it move up, nothing stays selected. One undo step. `NOT_FOUND` for no area there. */
978
+ remove: (input: {
979
+ index: number;
980
+ }) => Promise<null>;
981
+ /**
982
+ * The area at `index` selected, as a tap on it, Obfuscate opened if it isn't; `null` lets the selection go. No undo
983
+ * step. `NOT_FOUND` for no area there; `NOT_AVAILABLE` while Annotate is open (Obfuscate's stage is not on screen
984
+ * then: `annotate.close` first).
985
+ */
986
+ select: (input: {
987
+ index: number | null;
988
+ }) => Promise<null>;
989
+ /**
990
+ * The next area's look, as Obfuscate's controls set it with no area selected: what `input` gives of shape, style,
991
+ * strength and a solid area's color, the rest kept; `add` then draws in it unless its own input says otherwise. It sets
992
+ * it while an area is selected too (that area keeps its own). Session state: no undo step, never saved. `{}` changes
993
+ * nothing.
994
+ */
995
+ setLook: (input: {
996
+ color?: string;
997
+ shape?: 'ELLIPSE' | 'RECT' | 'ROUNDED';
998
+ strength?: number;
999
+ style?: 'BLUR' | 'PIXELATE' | 'SOLID';
1000
+ }) => Promise<null>;
1001
+ /**
1002
+ * The area at `index` with what `input` gives of its rect, its turn and its look, the rest as it was. It lands where
1003
+ * its drags would hold it: turned, resized and moved only as far as a handle's worth of it stays on the crop (one the
1004
+ * crop left out goes no further off). Selected once changed while Obfuscate is open. One undo step (none when nothing
1005
+ * changes). `NOT_FOUND` for no area there.
1006
+ */
1007
+ update: (input: {
1008
+ angle?: number;
1009
+ color?: string;
1010
+ height?: number;
1011
+ index: number;
1012
+ shape?: 'ELLIPSE' | 'RECT' | 'ROUNDED';
1013
+ strength?: number;
1014
+ style?: 'BLUR' | 'PIXELATE' | 'SOLID';
1015
+ width?: number;
1016
+ x?: number;
1017
+ y?: number;
1018
+ }) => Promise<null>;
1019
+ };
1020
+ /**
1021
+ * Calls `handler` with what each `name` event says (`EmbedEditorEvents`), until the function it returns is called. A
1022
+ * handler's own error is logged with `console.error`, never the editor's.
1023
+ */
1024
+ on: <Name extends keyof EmbedEditorEvents>(name: Name, handler: (payload: EmbedEditorEvents[Name]) => void) => () => void;
1025
+ /** What the edit makes. */
1026
+ output: {
1027
+ /**
1028
+ * The image as Save makes it (the output props, the marks), as a `File` of `type` (Save's type when left out), with no
1029
+ * Save: nothing goes to `onProcess`, nothing downloads. `MARK_FAILED` while a fixed or required mark can't be drawn,
1030
+ * `EXPORT_FAILED` when the file can't be made.
1031
+ */
1032
+ exportFile: (input?: {
1033
+ type?: 'image/jpeg' | 'image/png' | 'image/webp';
1034
+ }) => Promise<File>;
1035
+ /**
1036
+ * Save, as its button: the file to `onProcess` (or downloaded with none), the button's Saved moment, the modal closing
1037
+ * in `openEditor`. Resolves to what `onProcess` gets; rejects with the error `onProcessError` gets (`EXPORT_FAILED`,
1038
+ * `MARK_FAILED`), or `EXPORT_FAILED` when `onProcess` throws.
1039
+ */
1040
+ save: () => Promise<{
1041
+ dest: File;
1042
+ state: EditState;
1043
+ }>;
1044
+ };
1045
+ /**
1046
+ * The palette menu that heads every color row (Annotate's, the frame's, a mark's, a solid area's), the Full's:
1047
+ * `NOT_AVAILABLE` in the Free and the Lite.
1048
+ */
1049
+ palette: {
1050
+ /**
1051
+ * The set of colors every color row shows, as the palette menu: one of its own, or one of the photo's (`'PHOTO'`,
1052
+ * `'PHOTO_PASTEL'`, `'PHOTO_VIVID'`), whose colors fill in once read off the photo. Kept while the editor is open,
1053
+ * never saved: no undo step.
1054
+ */
1055
+ set: (input: {
1056
+ palette: 'EARTH' | 'PASTEL' | 'PHOTO' | 'PHOTO_PASTEL' | 'PHOTO_VIVID' | 'VIBRANT';
1057
+ }) => Promise<null>;
1058
+ };
1059
+ /** What the editor holds now, at once (no queue): `null` until the image is on screen (`ready`); `screenshot` alone waits its turn. */
1060
+ read: {
1061
+ /** The menu item shown. */
1062
+ item: () => EmbedEditorMenuItem | null;
1063
+ /**
1064
+ * What Annotate offers `target`, an annotation (`id`), the Numbers' list (`id: 'LIST'`), the added arrow `arrow` of a text
1065
+ * or of the list, or a tool's next one (`tool`): the commands its action bar offers it (and `annotate.list` or
1066
+ * `annotate.unlist` for a Number, `annotate.unlist` for the list), and its style row's and
1067
+ * color row's options by `annotate.update`'s names (`annotate.setStyle`'s for a tool), each with its value now and
1068
+ * the values it takes, or the `range` a slider takes it in. `null` until Annotate's screens are loaded (a moment
1069
+ * after the image is on screen, or `annotate.open`), for an `id` the state lacks, and where Annotate is off or absent
1070
+ * (the Free, the Lite).
1071
+ */
1072
+ options: (input: {
1073
+ target: {
1074
+ arrow?: number;
1075
+ id: string;
1076
+ } | {
1077
+ tool: AnnotateTool;
1078
+ };
1079
+ }) => {
1080
+ commands: string[];
1081
+ style: Record<string, {
1082
+ range: {
1083
+ max: number;
1084
+ min: number;
1085
+ };
1086
+ value: number;
1087
+ } | {
1088
+ value: number | string;
1089
+ values: readonly (number | string)[];
1090
+ }>;
1091
+ } | null;
1092
+ /** The size Save writes the image at, in px, as the size badge says. */
1093
+ outputSize: () => Size | null;
1094
+ /**
1095
+ * A picture of the edit as Save makes it (the output size, the marks; no editor around it), as a PNG `File`: all of it,
1096
+ * or an `area` of it in the output's px, shrunk to `maxSize` px on its longer side where it is larger. Unlike the other
1097
+ * reads it waits its turn, as a command does. `INVALID_COMMAND` for an area off the output, `MARK_FAILED` and
1098
+ * `EXPORT_FAILED` as `output.exportFile` (`EXPORT_FAILED` too when the picture can't be made from the export),
1099
+ * `NOT_AVAILABLE` where the browser gives no 2D canvas to draw it on.
1100
+ */
1101
+ screenshot: (input?: {
1102
+ area?: Rect;
1103
+ maxSize?: number;
1104
+ }) => Promise<File>;
1105
+ /** The menu's section showing: the carousel (`'MAIN'`), or Adjust's Scale or Aspect. */
1106
+ section: () => 'ASPECT' | 'MAIN' | 'SCALE' | null;
1107
+ /**
1108
+ * What is selected now, as the `select` event tells it: Annotate's piece, a text's added arrow or the Numbers' list
1109
+ * while Annotate is open, Obfuscate's area by its index otherwise, `null` for nothing. A piece a tap just made is
1110
+ * selected: its `id` is here for the commands that take one.
1111
+ */
1112
+ selection: () => EmbedEditorSelection;
1113
+ /** The size the editor works the image at, in px: the px of the state's coordinates (`onLoad`'s `size`). */
1114
+ size: () => Size | null;
1115
+ /** The state as Save would keep it now (`EditState`). */
1116
+ state: () => EditState | null;
1117
+ /** The tool open on the stage: the item's, or `'ANNOTATE'` while Annotate is open. */
1118
+ tool: () => EmbedEditorTool | null;
1119
+ };
1120
+ /**
1121
+ * Resolves once the image is on screen, when the commands start running; a command called before it waits for it, through
1122
+ * a load that fails too, until a new `src` (or a picked image) loads. Rejects with `NOT_AVAILABLE` if the editor is
1123
+ * destroyed, closed or leaves the page first, and once rejected it doesn't come back: an editor shown again takes
1124
+ * commands, but `ready` stays rejected.
1125
+ */
1126
+ ready: Promise<void>;
1127
+ /**
1128
+ * Any command by its name, `group.verb` as `commands()` lists it, with its input: `run({ command: 'menu.select', input:
1129
+ * { item: 'FILTER' } })` is `menu.select({ item: 'FILTER' })`. A read (`read.state`) runs in the queue here, after the
1130
+ * commands called before it, and resolves to its value.
1131
+ */
1132
+ run: (input: {
1133
+ command: string;
1134
+ input?: unknown;
1135
+ }) => Promise<unknown>;
1136
+ /** The size Save writes, as Resize's fields set it. */
1137
+ size: {
1138
+ /**
1139
+ * The size from one side (`'WIDTH'` or `'HEIGHT'`), its `value` in whole px: the other follows the crop's ratio, both
1140
+ * held to `maxWidth` and `maxHeight`. One undo step. `NOT_AVAILABLE` where Resize is off (`enableResize`, the Free
1141
+ * and the Lite).
1142
+ */
1143
+ set: (input: {
1144
+ side: 'HEIGHT' | 'WIDTH';
1145
+ value: number;
1146
+ }) => Promise<null>;
1147
+ };
1148
+ /** The view of the photo, no edit: none is an undo step. */
1149
+ view: {
1150
+ /** The original shown over the edit while `on`, as holding a press on the photo does. */
1151
+ compare: (input: {
1152
+ on: boolean;
1153
+ }) => Promise<null>;
1154
+ /**
1155
+ * Annotate's zoomed view moved by `x`, `y` px of the photo along the screen, as a scroll: more of the right and the
1156
+ * bottom for positive values, never past the photo's edge, from where the view rests (a glide before it lands
1157
+ * first; a hidden tab holds that wait until it shows). `NOT_AVAILABLE` out of Annotate.
1158
+ */
1159
+ pan: (input: {
1160
+ x: number;
1161
+ y: number;
1162
+ }) => Promise<null>;
1163
+ /** The view back to its rest, the photo whole, on the spring, as the Recenter button and Annotate's zoom chip. */
1164
+ recenter: () => Promise<null>;
1165
+ /**
1166
+ * Resolves once the view's motion rests (a refit, a command's zoom or pan): for a screenshot or a video's next step.
1167
+ * The motion follows the page's frames, so a hidden tab holds it until it shows. The person's wheel in Annotate moves
1168
+ * the view by steps, not by a motion it waits for.
1169
+ */
1170
+ settled: () => Promise<null>;
1171
+ /**
1172
+ * Annotate's view zoomed by `factor` round the photo's point `at` (its px, as the annotations'; the view's middle when
1173
+ * left out), never under the photo whole nor past 8 times it, from where the view rests (a glide before it lands
1174
+ * first; a hidden tab holds that wait until it shows). `NOT_AVAILABLE` out of Annotate.
1175
+ */
1176
+ zoom: (input: {
1177
+ at?: {
1178
+ x: number;
1179
+ y: number;
1180
+ };
1181
+ factor: number;
1182
+ }) => Promise<null>;
1183
+ };
1184
+ };
1185
+
1186
+ /** A mark's image: what the `src` prop takes. An SVG is drawn from a large raster (about 4 megapixels), sharp at the sizes a mark takes. */
1187
+ export declare type EmbedEditorMarkSource = ArrayBuffer | Blob | HTMLCanvasElement | HTMLImageElement | ImageBitmap | string | Uint8Array;
1188
+
1189
+ /**
1190
+ * A menu item, by its name: `'ADJUST'` (the crop), `'RESIZE'`, `'OBFUSCATE'`, `'FRAME'`, `'WATERMARK'`, `'SIGNATURE'`
1191
+ * (while the host's mark is there and not fixed), `'FILTER'`, `'AUTO'` and the twelve adjustments (`'EXPOSURE'`,
1192
+ * `'BRILLIANCE'`, `'HIGHLIGHTS'`, `'SHADOWS'`, `'CONTRAST'`, `'BRIGHTNESS'`, `'BLACK_POINT'`, `'SATURATION'`,
1193
+ * `'VIBRANCE'`, `'WARMTH'`, `'SHARPNESS'`, `'VIGNETTE'`). The Free and the Lite have `'ADJUST'` alone.
1194
+ */
1195
+ export declare type EmbedEditorMenuItem = 'ADJUST' | 'AUTO' | 'BLACK_POINT' | 'BRIGHTNESS' | 'BRILLIANCE' | 'CONTRAST' | 'EXPOSURE' | 'FILTER' | 'FRAME' | 'HIGHLIGHTS' | 'OBFUSCATE' | 'RESIZE' | 'SATURATION' | 'SHADOWS' | 'SHARPNESS' | 'SIGNATURE' | 'VIBRANCE' | 'VIGNETTE' | 'WARMTH' | 'WATERMARK';
1196
+
1197
+ /**
1198
+ * What `EmbedEditor` takes, and `mountEditor` and `openEditor` (without `layout`). Every prop is optional, one plain
1199
+ * value with a default, and applies live unless it says otherwise. An invalid one is `INVALID_PROPS`: the error screen
1200
+ * names it and `onLoadError` hears it, never ignored (except a `lang` code outside the list, which reads `'en-us'`). On
1201
+ * `EmbedEditor`, `data-*` and `aria-*` attributes go to its host element.
1202
+ */
1203
+ export declare type EmbedEditorProps = {
1204
+ /**
1205
+ * The color the annotations start with (Annotate's first color), drawn opaque: a hex, `rgb()`, `hsl()` or a CSS color
1206
+ * name. Default: the accent the editor paints.
1207
+ */
1208
+ annotationColor?: string;
1209
+ /** The theme the annotations start with, the back of their labels: light, dark, or their color. Default `'light'`. */
1210
+ annotationTheme?: 'accent' | 'dark' | 'light';
1211
+ /**
1212
+ * The ratio (width / height, above 0) the crop opens at: its largest window, on the photo's subject. `null` or
1213
+ * absent: free. A saved edit given in `state` opens as it was saved unless the ratio is locked. Given live, it applies
1214
+ * as one step undo can take back. Default `null`.
1215
+ */
1216
+ aspectRatio?: number | null;
1217
+ /**
1218
+ * Fixes the ratio and hides the ratio selector. With no `aspectRatio`, the ratio the image opens with is the one kept.
1219
+ * Given live, the locked ratio is where undo starts. Default `false`.
1220
+ */
1221
+ aspectRatioLocked?: boolean;
1222
+ /**
1223
+ * Whether Escape closes the editor (the modal, or inline and page with `onClose`). Off, only the Close button and Save
1224
+ * close it; Escape keeps its other jobs (a Resize field's draft, Reset's confirm, Annotate).
1225
+ * Default `true`.
1226
+ */
1227
+ closeOnEscape?: boolean;
1228
+ /** One base color per role. Default: yellow on zinc. */
1229
+ colors?: EmbedEditorColors;
1230
+ /** Shows the output size over the top right of the image for a moment after it changes. Default `true`. */
1231
+ displayBadge?: boolean;
1232
+ /**
1233
+ * The Annotate button and its mode: arrows, texts, numbers, a ruler, shapes, drawing and a lens over the image. Turned
1234
+ * off, the annotations already in the state stay, are drawn and are saved. Default `true`.
1235
+ */
1236
+ enableAnnotate?: boolean;
1237
+ /**
1238
+ * A Copy button left of Save: the image as Save makes it, on the clipboard as a PNG. Hidden where the browser can't
1239
+ * write an image there. Default `false`.
1240
+ */
1241
+ enableCopy?: boolean;
1242
+ /** The Filter tool. Turned off, a filter already in the state stays and is saved. Default `true`. */
1243
+ enableFilter?: boolean;
1244
+ /** Auto and the adjustments. Turned off, their values in the state stay and are saved. Default `true`. */
1245
+ enableFinetune?: boolean;
1246
+ /** The Frame tool. Turned off, a frame already in the state stays and is saved. Default `true`. */
1247
+ enableFrame?: boolean;
1248
+ /** The Obfuscate tool. Turned off, the areas already in the state stay and are saved. Default `true`. */
1249
+ enableObfuscate?: boolean;
1250
+ /**
1251
+ * With no `src`, the editor asks for the image: a file chosen, dropped or pasted. Off, it shows its loading screen
1252
+ * until a `src` comes. Default `true`.
1253
+ */
1254
+ enablePicker?: boolean;
1255
+ /** The Resize tool. Turned off, a size already in the state stays and is saved. Default `true`. */
1256
+ enableResize?: boolean;
1257
+ /**
1258
+ * A Share button left of Save: the image as Save makes it, in the system share sheet. Shown only where the browser can
1259
+ * share an image file. Default `false`.
1260
+ */
1261
+ enableShare?: boolean;
1262
+ /**
1263
+ * The language: a built-in one (`'en-us'`, `'es-es'`, `'pt-br'`; a code outside the list reads `'en-us'`), or the host's
1264
+ * own texts: `{ texts }` for a new language (a message it leaves out reads English), `{ extend, texts }` to change some
1265
+ * messages of a built-in one (the rest read `extend`). `locale`, a BCP 47 tag, formats the numbers: by default `extend`,
1266
+ * else `'en-us'`. Default `'en-us'`.
1267
+ */
1268
+ lang?: Lang | {
1269
+ extend?: Lang;
1270
+ locale?: string;
1271
+ texts: LangTexts;
1272
+ };
1273
+ /**
1274
+ * Where the editor sits: in the box the host gives it (`'inline'`), or over the whole viewport as the page itself
1275
+ * (`'page'`: the page behind doesn't scroll, the safe areas are kept clear). Not for `openEditor`, which is its own
1276
+ * layout. Default `'inline'`.
1277
+ */
1278
+ layout?: 'inline' | 'page';
1279
+ /** The host's logo, left of the toolbar: an image URL (`http(s):`, `data:` or `blob:`). Default none. */
1280
+ logo?: string;
1281
+ /**
1282
+ * The host's name, left of the toolbar: alone in the logo's place, or after the `logo` image when both are given. One
1283
+ * line in the editor's letters, cut with an ellipsis where it doesn't fit. Default none.
1284
+ */
1285
+ logoText?: string;
1286
+ /**
1287
+ * The output's largest height, in px (1 or more). Alone it caps the height; with `maxWidth` the output fits inside
1288
+ * both. The ratio is kept and the image is never enlarged. Default none.
1289
+ */
1290
+ maxHeight?: number;
1291
+ /**
1292
+ * The output's largest width, in px (1 or more). Alone it caps the width; with `maxHeight` the output fits inside
1293
+ * both. The ratio is kept and the image is never enlarged. Default none.
1294
+ */
1295
+ maxWidth?: number;
1296
+ /** Called when the editor closes. On `EmbedEditor` and `mountEditor`, the Close button shows only with it. */
1297
+ onClose?: () => void;
1298
+ /**
1299
+ * Called once per open, when the image is on screen: the file it came from (`null` for a canvas or an ImageBitmap) and
1300
+ * the size the editor works it at, in px. That is the image's own size up to 16,777,216 px (2^24, the area of 4096 ×
1301
+ * 4096). A larger image is worked, shown and saved at the largest size within that at its ratio (a 48 MP photo, 8064 ×
1302
+ * 6048, at 4729 × 3547), and the px of the state `onProcess` gives are that size's.
1303
+ */
1304
+ onLoad?: (res: {
1305
+ file: File | null;
1306
+ size: Size;
1307
+ }) => void;
1308
+ /**
1309
+ * Called when the image can't be opened or drawn (`WEBGL_UNAVAILABLE` for a GPU that can't build a shader a frame
1310
+ * needs), or a prop is invalid (`INVALID_PROPS`). The error screen shows it too.
1311
+ */
1312
+ onLoadError?: (error: EmbedEditorError) => void;
1313
+ /**
1314
+ * Called with what Save made and the state it was made with. Without it, Save downloads the file. If it throws, the error
1315
+ * is logged with `console.error`, Save shows it failed and the modal stays open; `onProcessError` isn't called.
1316
+ */
1317
+ onProcess?: (res: {
1318
+ dest: File;
1319
+ state: EditState;
1320
+ }) => void;
1321
+ /** Called when Save can't make the file (`EXPORT_FAILED`) or can't draw a fixed or required mark (`MARK_FAILED`). The banner over the toolbar says so too. */
1322
+ onProcessError?: (error: EmbedEditorError) => void;
1323
+ /** The JPEG and WebP quality, 0…100. Default `90`. */
1324
+ outputQuality?: number;
1325
+ /** The type Save and Share write. Default: the source's when it is one of these, a PNG otherwise. */
1326
+ outputType?: 'image/jpeg' | 'image/png' | 'image/webp';
1327
+ /** The signature over the photo. `null` or absent: none. Default `null`. */
1328
+ signature?: EmbedEditorSignature | null;
1329
+ /**
1330
+ * The image, read at open: a URL (`http(s):`, `data:`, `blob:`), a File or Blob, its bytes, an `<img>`, a canvas or an
1331
+ * ImageBitmap. `null` or absent: the editor asks for it (`enablePicker`). While the empty state, a load or the error
1332
+ * screen shows, a new one replaces the one opening; once an image is on screen, a new one is ignored, and another image
1333
+ * takes a new open (in React, a new `key`). Default `null`.
1334
+ */
1335
+ src?: ArrayBuffer | Blob | HTMLCanvasElement | HTMLImageElement | ImageBitmap | string | Uint8Array | null;
1336
+ /**
1337
+ * The edits the image opens with, read at open like `src`: a state saved before (`EditState`), a legacy editor's
1338
+ * (`PinturaState`), or none. Default `null`.
1339
+ */
1340
+ state?: EditState | PinturaState | null;
1341
+ /** The watermark over the photo. `null` or absent: none. Default `null`. */
1342
+ watermark?: EmbedEditorWatermark | null;
1343
+ };
1344
+
1345
+ /**
1346
+ * What is selected: an Obfuscate area, by its index in the state's `obfuscation`; in Annotate, an annotation
1347
+ * (`'PIECE'`, by its `id`), an arrow added to a text or to the Numbers' list (`'ARROW'`: its owner's `id`, `'LIST'` for
1348
+ * the list, and the arrow's place in its `arrows`) or the list (`'LIST'`); or nothing (`null`).
1349
+ */
1350
+ export declare type EmbedEditorSelection = number | {
1351
+ id: string;
1352
+ index: number;
1353
+ kind: 'ARROW';
1354
+ } | {
1355
+ id: string;
1356
+ kind: 'PIECE';
1357
+ } | {
1358
+ kind: 'LIST';
1359
+ } | null;
1360
+
1361
+ /**
1362
+ * The signature: says whose photo it is. Small, at one of 9 points with a margin (or where the person drags it): a text,
1363
+ * white or black as the photo under it reads or in a color chosen, or a logo in its own colors. Give `text` or `src`,
1364
+ * exactly one. Sizes are the mark's height in % of the final photo's shorter side.
1365
+ */
1366
+ export declare type EmbedEditorSignature = {
1367
+ /**
1368
+ * The text's color it opens with: 'auto' (white or black, as the photo under it reads) or a hex (`#6366f1`), `rgb()`,
1369
+ * `hsl()` or a CSS color name, as `colors` takes them. The person changes it unless it is 'fixed'. A logo keeps its own
1370
+ * colors. Default 'auto'.
1371
+ */
1372
+ color?: 'auto' | string;
1373
+ /** The text's letter, by its slug: one of the nine the editor bundles (`AnnotationFont`). A logo has none. Default 'inter'. */
1374
+ font?: AnnotationFont;
1375
+ /** 'fixed': shown, never touched. 'required': adjustable, never removed. 'free': adjustable, text editable, removable. Default 'free'. */
1376
+ lock?: 'fixed' | 'free' | 'required';
1377
+ /** The distance to the edges at the 9 points, 0…20 (the center ignores it). Default 4. */
1378
+ margin?: number;
1379
+ /** 10…100. Default 100. */
1380
+ opacity?: number;
1381
+ /** 'auto' (the emptiest corner, away from the subject) or one of the 9 points. Default 'bottom-right'. */
1382
+ position?: 'auto' | 'bottom' | 'bottom-left' | 'bottom-right' | 'center' | 'left' | 'right' | 'top' | 'top-left' | 'top-right';
1383
+ /** The height, 2…40. Default 3.5 for a text, 14 for an image. */
1384
+ size?: number;
1385
+ /** The logo. */
1386
+ src?: EmbedEditorMarkSource;
1387
+ /** The text, 1…80 characters. */
1388
+ text?: string;
1389
+ };
1390
+
1391
+ /**
1392
+ * What the stage is open for: the menu item's tool (`'CROP'` for Adjust, `'FINETUNE'` for Auto and the adjustments,
1393
+ * `'MARK'` for the watermark and the signature, the item's own name for the rest) or `'ANNOTATE'` while Annotate is open.
1394
+ */
1395
+ export declare type EmbedEditorTool = 'ANNOTATE' | 'CROP' | 'FILTER' | 'FINETUNE' | 'FRAME' | 'MARK' | 'OBFUSCATE' | 'RESIZE';
1396
+
1397
+ /**
1398
+ * The watermark: protects. Covers the photo, translucent, white or black as the photo under it reads or in a color
1399
+ * chosen, in a grid or as one centered mark. Give `text` or `src` (drawn as a silhouette in that color), exactly one.
1400
+ * Sizes are the mark's height in % of the final photo's shorter side.
1401
+ */
1402
+ export declare type EmbedEditorWatermark = {
1403
+ /**
1404
+ * Degrees, −90…90, in `layout`: the other layout, once the person switches to it, starts at its own default. Default
1405
+ * −30 in a grid, 0 for a single mark.
1406
+ */
1407
+ angle?: number;
1408
+ /**
1409
+ * The color it opens with, of its text or its image's silhouette: 'auto' (white or black, as the photo under it reads)
1410
+ * or a hex (`#6366f1`), `rgb()`, `hsl()` or a CSS color name, as `colors` takes them. The person changes it unless it
1411
+ * is 'fixed'. Default 'auto'.
1412
+ */
1413
+ color?: 'auto' | string;
1414
+ /** The text's letter, by its slug: one of the nine the editor bundles (`AnnotationFont`). A logo has none. Default 'inter'. */
1415
+ font?: AnnotationFont;
1416
+ /**
1417
+ * 'grid': repeated over the whole photo. 'single': one mark in the center. The layout it opens in: unless it is
1418
+ * 'fixed', the person can switch it. Default 'grid'.
1419
+ */
1420
+ layout?: 'grid' | 'single';
1421
+ /** 'fixed': shown, never touched. 'required': adjustable, never removed. 'free': adjustable, text editable, removable. Default 'fixed'. */
1422
+ lock?: 'fixed' | 'free' | 'required';
1423
+ /** 10…100. Default 35. */
1424
+ opacity?: number;
1425
+ /**
1426
+ * The height in `layout`: 1…20 in a grid (default 4 for a text, 8 for an image), 4…60 single (12, 24). The other
1427
+ * layout, once the person switches to it, starts at its own default.
1428
+ */
1429
+ size?: number;
1430
+ /** The grid's gap, 0…100, measured in the mark's size. Default 50. */
1431
+ spacing?: number;
1432
+ /** The image, drawn as a silhouette in `color`. */
1433
+ src?: EmbedEditorMarkSource;
1434
+ /** The text, 1…80 characters. */
1435
+ text?: string;
1436
+ };
1437
+
1438
+ /** An object type with its intersections written out as one. */
1439
+ declare type Flat<Type> = {
1440
+ [Key in keyof Type]: Type[Key];
1441
+ };
1442
+
1443
+ /** The editor's languages. */
1444
+ export declare type Lang = 'en-us' | 'es-es' | 'pt-br';
1445
+
1446
+ /**
1447
+ * The texts a host brings (`lang.texts`): any subset of the editor's messages, by key, each one a string. A message
1448
+ * with `{ name }` placeholders keeps exactly the placeholders of the English one, in whatever order the language needs.
1449
+ * The package's `i18n/en-us.json` lists every key.
1450
+ */
1451
+ export declare type LangTexts = Partial<Record<MessageKey, string>>;
1452
+
1453
+ /**
1454
+ * A message of the editor, by its key: what `lang.texts` can bring. The package's `i18n/en-us.json` has
1455
+ * each with its English text. Written out here (the d.ts carries no JSON), and held equal to the dictionary's keys by
1456
+ * src/types.spec.ts.
1457
+ */
1458
+ export declare type MessageKey = 'annotateAddArrow' | 'annotateAddGuide' | 'annotateArrow' | 'annotateAttachText' | 'annotateBeside' | 'annotateBox' | 'annotateBringToFront' | 'annotateCapArrow' | 'annotateCapBar' | 'annotateCapDot' | 'annotateCapNone' | 'annotateCapTriangle' | 'annotateColorDefault' | 'annotateCorners' | 'annotateCornersRound' | 'annotateCornersSoft' | 'annotateCornersSquare' | 'annotateDetach' | 'annotateDraw' | 'annotateDuplicate' | 'annotateEnd' | 'annotateEnds' | 'annotateFieldDescription' | 'annotateFieldTitle' | 'annotateFill' | 'annotateFillMedium' | 'annotateFillOpaque' | 'annotateFillOutline' | 'annotateFillSoft' | 'annotateFont' | 'annotateFormat' | 'annotateInList' | 'annotateLens' | 'annotateLensCircle' | 'annotateLensRounded' | 'annotateLine' | 'annotateLineDashed' | 'annotateLineDotted' | 'annotateLineSketch' | 'annotateLineSolid' | 'annotateLineTransparent' | 'annotateList' | 'annotateListTitle' | 'annotateLook' | 'annotateLookBox' | 'annotateLookCaption' | 'annotateLookPlain' | 'annotateMark' | 'annotateMarkDot' | 'annotateMenuValue' | 'annotateMenuValues' | 'annotateNumber' | 'annotateOpenFailed' | 'annotatePadding' | 'annotatePaddingLoose' | 'annotatePaddingNormal' | 'annotatePaddingTight' | 'annotatePath' | 'annotatePathCurve' | 'annotatePathElbow' | 'annotatePathFree' | 'annotatePathRoundedElbow' | 'annotatePathStraight' | 'annotateRemove' | 'annotateRuler' | 'annotateRulerLabel' | 'annotateRulerPlaceholder' | 'annotateShape' | 'annotateShapeEllipse' | 'annotateShapeLine' | 'annotateShapeRect' | 'annotateShapeRounded' | 'annotateSize' | 'annotateSizeL' | 'annotateSizeM' | 'annotateSizeNameL' | 'annotateSizeNameM' | 'annotateSizeNameS' | 'annotateSizeS' | 'annotateStart' | 'annotateStroke' | 'annotateStrokeDashed' | 'annotateStrokeDotted' | 'annotateStrokeMarker' | 'annotateStrokeSketch' | 'annotateStrokeSolid' | 'annotateText' | 'annotateTextPlaceholder' | 'annotateTheme' | 'annotateThemeAccent' | 'annotateThemeDark' | 'annotateThemeLight' | 'annotateTools' | 'annotateType' | 'annotateTypeArrow' | 'annotateTypeCustom' | 'annotateTypeDashed' | 'annotateTypeDouble' | 'annotateTypeLeader' | 'annotateTypeLine' | 'annotateTypeTrail' | 'annotateWeight' | 'annotateWeightExtraThick' | 'annotateWeightExtraThin' | 'annotateWeightMedium' | 'annotateWeightMediumThick' | 'annotateWeightMediumThin' | 'annotateWeightThick' | 'annotateWeightThin' | 'annotateZoom' | 'annotateZoomValue' | 'aspectFree' | 'autoFailed' | 'autoTimedOut' | 'autoTurnOn' | 'browserUnsupported' | 'buttonAnnotate' | 'buttonCancel' | 'buttonChooseAnother' | 'buttonChooseFile' | 'buttonClose' | 'buttonCopy' | 'buttonDone' | 'buttonFlip' | 'buttonFocus' | 'buttonRecenter' | 'buttonRedo' | 'buttonReset' | 'buttonResetConfirm' | 'buttonRotateLeft' | 'buttonSave' | 'buttonSaved' | 'buttonShare' | 'buttonUndo' | 'color' | 'colorBlack' | 'colorBlue' | 'colorCode' | 'colorCream' | 'colorCustom' | 'colorGreen' | 'colorKraft' | 'colorLavender' | 'colorMint' | 'colorMore' | 'colorNavy' | 'colorOchre' | 'colorOlive' | 'colorPaper' | 'colorPhoto' | 'colorPick' | 'colorPickFailed' | 'colorRed' | 'colorRose' | 'colorShades' | 'colorSky' | 'colorViolet' | 'colorWhite' | 'colorYellow' | 'compareOriginal' | 'cropAspectRatio' | 'cropScale' | 'dialogLabel' | 'errorCopyFailed' | 'errorExportFailed' | 'errorInvalidProps' | 'errorInvalidState' | 'errorLoadFailed' | 'errorMarkFailed' | 'errorShareFailed' | 'errorUnsupportedFormat' | 'errorWebglUnavailable' | 'filterDramatic' | 'filterDramaticCool' | 'filterDramaticWarm' | 'filterIntensity' | 'filterMono' | 'filterNoir' | 'filterOriginal' | 'filterSilvertone' | 'filterVivid' | 'filterVividCool' | 'filterVividWarm' | 'finetuneAuto' | 'finetuneBlackPoint' | 'finetuneBrightness' | 'finetuneBrilliance' | 'finetuneContrast' | 'finetuneExposure' | 'finetuneHighlights' | 'finetuneSaturation' | 'finetuneShadows' | 'finetuneSharpness' | 'finetuneVibrance' | 'finetuneVignette' | 'finetuneWarmth' | 'focusCenter' | 'focusFailed' | 'focusSubject' | 'frameCornerHooks' | 'frameEdgeCross' | 'frameEdgeOverlap' | 'frameEdgeSeparate' | 'frameFilm' | 'frameGallery' | 'frameLineMultiple' | 'frameLineSingle' | 'frameMatRound' | 'frameMatSharp' | 'frameNone' | 'framePhotoCorners' | 'framePolaroid' | 'frameRoundCorners' | 'imageCopied' | 'markAdjustment' | 'markAngle' | 'markColor' | 'markColorAuto' | 'markEditText' | 'markFailedSignature' | 'markFailedWatermark' | 'markFont' | 'markFontValue' | 'markGrid' | 'markLayout' | 'markMargin' | 'markOpacity' | 'markRetry' | 'markShow' | 'markSignature' | 'markSingle' | 'markSize' | 'markSkippedSignature' | 'markSkippedWatermark' | 'markSpacing' | 'markText' | 'markWatermark' | 'noticeAreasVisible' | 'noticeClose' | 'noticeDropped' | 'noticeDroppedAnnotations' | 'noticeDroppedAuto' | 'noticeDroppedFilter' | 'noticeDroppedFinetune' | 'noticeDroppedFrame' | 'noticeDroppedHiddenAreas' | 'noticeDroppedSignature' | 'noticeDroppedWatermark' | 'obfuscateDelete' | 'obfuscateHint' | 'obfuscateLimit' | 'obfuscateShape' | 'obfuscateShapeRound' | 'obfuscateShapeRounded' | 'obfuscateShapeSquare' | 'obfuscateStyle' | 'obfuscateStyleBlur' | 'obfuscateStylePixelate' | 'obfuscateStyleSolid' | 'palette' | 'paletteEarth' | 'palettePastel' | 'palettePhoto' | 'palettePhotoPastel' | 'palettePhotoVivid' | 'paletteVibrant' | 'pickerDescription' | 'pickerFormats' | 'pickerTitle' | 'pickerTitleTouch' | 'resetConfirmHint' | 'resizeHeight' | 'resizeWidth' | 'shareReady' | 'statusLoading' | 'toolAdjust' | 'toolFilter' | 'toolFrame' | 'toolObfuscate' | 'toolResize' | 'toolsLabel';
1459
+
1460
+ export declare const mountEditor: (element: HTMLElement, options?: EmbedEditorProps) => EmbedEditorHandle & {
1461
+ destroy: () => void;
1462
+ update: (options: EmbedEditorProps) => void;
1463
+ };
1464
+
1465
+ export declare const openEditor: (options?: Omit< EmbedEditorProps, "layout">) => EmbedEditorHandle & {
1466
+ close: () => void;
1467
+ };
1468
+
1469
+ /**
1470
+ * A state the legacy editor (Pintura) saved, as it saved it. What maps one to one onto the editor is read: the crop and
1471
+ * its ratio, its turn and flips, the redactions (as obfuscated areas, each turned by its `rotation` as the area's
1472
+ * `angle`) and the size. Its filter, adjustments and frame are dropped, as is the rest. Its crop and redactions are in
1473
+ * the image's own px, and land on the same region of the size the editor works the image at (`onLoad`'s `size`). More
1474
+ * than 64 redactions is `INVALID_STATE`, as for the editor's own state. It has no `version`: a state with one is the
1475
+ * editor's own.
1476
+ */
1477
+ export declare type PinturaState = {
1478
+ annotation?: unknown[];
1479
+ backgroundColor?: number[];
1480
+ backgroundImage?: unknown;
1481
+ colorMatrix?: Record<string, number[]>;
1482
+ convolutionMatrix?: number[] | Record<string, number[]>;
1483
+ crop?: Rect;
1484
+ cropAspectRatio?: number | null;
1485
+ cropLimitToImage?: boolean;
1486
+ cropMaxSize?: Size;
1487
+ cropMinSize?: Size;
1488
+ decoration?: unknown[];
1489
+ flipX?: boolean;
1490
+ flipY?: boolean;
1491
+ frame?: string | Record<string, unknown>;
1492
+ gamma?: number;
1493
+ metadata?: unknown;
1494
+ /** Each one turned about its middle by its `rotation` (radians, clockwise on the screen): its area's `angle`, in degrees. */
1495
+ redaction?: (Rect & {
1496
+ rotation?: number;
1497
+ })[];
1498
+ /** The turn, in radians. */
1499
+ rotation?: number;
1500
+ targetSize?: {
1501
+ height?: number;
1502
+ width?: number;
1503
+ };
1504
+ trim?: unknown;
1505
+ version?: never;
1506
+ vignette?: number;
1507
+ volume?: unknown;
1508
+ };
1509
+
1510
+ /**
1511
+ * An image processed with no editor, as Save would write it, from any `src` the editor takes (a URL, a File or Blob, its
1512
+ * bytes, an `<img>`, a canvas or an ImageBitmap): cropped (`crop`, held inside the image, the largest centered window of
1513
+ * `aspectRatio`, or the whole image), drawn at `targetSize`, within `maxWidth`/`maxHeight` and at most 16.7 MP, in
1514
+ * `outputType`. It resolves to the file (`dest`) and the state it was made with (`state`), and rejects with an
1515
+ * `EmbedEditorError`: `INVALID_PROPS` for a `src` or an option it can't take, before anything loads. That state is in the
1516
+ * px the editor works the image at, ready for the editor's `state` prop; past 16.7 MP its `crop` is not the file's px, so
1517
+ * it is never passed back as `crop`.
1518
+ */
1519
+ export declare const processImage: (src: NonNullable< EmbedEditorProps["src"]>, options?: ProcessImageOptions) => Promise<{
1520
+ dest: File;
1521
+ state: EditState;
1522
+ }>;
1523
+
1524
+ /** What `processImage` takes, every option optional. An option it can't take is `INVALID_PROPS`, before anything loads. */
1525
+ export declare type ProcessImageOptions = {
1526
+ /**
1527
+ * With no `crop`, the ratio (width / height, above 0) of the crop: its largest centered window. `null` or absent: the
1528
+ * image whole. With a `crop`, it decides only whether the returned state keeps a ratio: the crop's own shape wins
1529
+ * when it already has this ratio, and the state opens free otherwise (see `crop`).
1530
+ */
1531
+ aspectRatio?: number | null;
1532
+ /**
1533
+ * The crop, in the file's own px (the size it came at), held inside the image: one past an edge moves in, one larger
1534
+ * than the image shrinks at its ratio. Its own shape wins over `aspectRatio` in the returned state: that state's
1535
+ * ratio is `aspectRatio` when the crop already has it, `null` (free) otherwise, so reopening it never refits the
1536
+ * crop to a ratio it never had. The `state` `processImage` gives back is in the px the editor works the image at
1537
+ * instead, ready for the editor's `state` prop: past 16.7 MP they differ, so that state's `crop` is never passed back
1538
+ * here.
1539
+ */
1540
+ crop?: Rect;
1541
+ /** The output's largest height, in px (1 or more). The ratio is kept, and it never enlarges the image. */
1542
+ maxHeight?: number;
1543
+ /** The output's largest width, in px (1 or more). The ratio is kept, and it never enlarges the image. */
1544
+ maxWidth?: number;
1545
+ /** The JPEG and WebP quality, 0…100. Default `90`. */
1546
+ outputQuality?: number;
1547
+ /** The type written. Default: the source's when it is one of these, a PNG otherwise. */
1548
+ outputType?: 'image/jpeg' | 'image/png' | 'image/webp';
1549
+ /** The signature, drawn at its own values (no person adjusts it here). `null` or absent: none. */
1550
+ signature?: EmbedEditorSignature | null;
1551
+ /**
1552
+ * The box the crop is drawn into, in output px, at the crop's ratio: it may enlarge a small crop. The output never
1553
+ * passes 16,777,216 px (2^24), whatever is asked. Default: the crop's own size.
1554
+ */
1555
+ targetSize?: Size;
1556
+ /** The watermark, drawn at its own values (no person adjusts it here). `null` or absent: none. */
1557
+ watermark?: EmbedEditorWatermark | null;
1558
+ };
1559
+
1560
+ /**
1561
+ * A rectangle of the image, in px: the image's own px (the size the file came at) in a legacy state (`PinturaState`) and in
1562
+ * `processImage`'s `crop`. The editor's own state (`EditState`) is in the px of the size it works the image at instead
1563
+ * (`onLoad`'s `size`): the same px up to 16.7 MP, fewer past it.
1564
+ */
1565
+ export declare type Rect = {
1566
+ height: number;
1567
+ width: number;
1568
+ x: number;
1569
+ y: number;
1570
+ };
1571
+
1572
+ /** An annotation of `EditState`'s `annotations`. */
1573
+ declare type SavedAnnotation = NonNullable<EditState['annotations']>[number];
1574
+
1575
+ /** A size, in px. */
1576
+ export declare type Size = {
1577
+ height: number;
1578
+ width: number;
1579
+ };
1580
+
1581
+ /** An annotation with no `id` and its `color` optional. */
1582
+ declare type Unsaved<Piece> = Flat<Omit<Piece, 'color' | 'id'> & {
1583
+ color?: string;
1584
+ }>;
1585
+
1586
+ export { }