@hussmartinez/pdf-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.
@@ -1 +1 @@
1
- {"version":3,"file":"processing-worker-Dy5JQHXJ.js","names":["ProcessingWorker"],"sources":["../../src/adapters/qpdf/processing-worker.ts"],"sourcesContent":["import ProcessingWorker from \"../../workers/processing.worker.ts?worker&inline\";\n\n/** Starts the inlined processing worker, from its own lazy chunk. */\nexport function createInlineWorker(): Worker {\n return new ProcessingWorker({ name: \"hm-pdf-processing\" });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,qBAA6B;CAC3C,OAAO,IAAIA,cAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3D"}
1
+ {"version":3,"file":"processing-worker-DIP9ck2l.js","names":["ProcessingWorker"],"sources":["../../src/adapters/qpdf/processing-worker.ts"],"sourcesContent":["import ProcessingWorker from \"../../workers/processing.worker.ts?worker&inline\";\n\n/** Starts the inlined processing worker, from its own lazy chunk. */\nexport function createInlineWorker(): Worker {\n return new ProcessingWorker({ name: \"hm-pdf-processing\" });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,qBAA6B;CAC3C,OAAO,IAAIA,cAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3D"}
package/dist/react.d.ts CHANGED
@@ -222,6 +222,18 @@ declare interface PdfDocumentHandle {
222
222
  destroy(): Promise<void>;
223
223
  }
224
224
 
225
+ /**
226
+ * What {@link PdfEditorProps.downloadName} is given to name a download.
227
+ *
228
+ * @public
229
+ */
230
+ export declare interface PdfDownloadNameInfo {
231
+ /** The opened file's name, cleaned (docs/adr/0009), if it had one. */
232
+ readonly sourceName?: string;
233
+ /** The page count of the document being saved. */
234
+ readonly pageCount: number;
235
+ }
236
+
225
237
  /**
226
238
  * The complete editor: a document's pages beside it as thumbnails, with
227
239
  * designed states for no document, opening and a failed open (ADR 0014).
@@ -268,6 +280,11 @@ export declare interface PdfEditorChange {
268
280
  readonly reason: "open" | "edit" | "close";
269
281
  /** The document's page count after the change; 0 once it's closed. */
270
282
  readonly pageCount: number;
283
+ /**
284
+ * On `open`, the opened file's name, cleaned (docs/adr/0009), if it had
285
+ * one: from `File.name` or the `name` option. Show it only as text.
286
+ */
287
+ readonly fileName?: string;
271
288
  }
272
289
 
273
290
  /**
@@ -278,8 +295,11 @@ export declare interface PdfEditorChange {
278
295
  export declare interface PdfEditorHandle {
279
296
  /** The editor's session, for commands and state beyond the handle's. */
280
297
  readonly session: PdfSession;
281
- /** Opens a document, replacing the current one once it has opened. */
282
- open(file: Blob | PdfBytes): Promise<void>;
298
+ /**
299
+ * Opens a document, replacing the current one once it has opened. Pass
300
+ * `name` with bytes or a plain `Blob`; a `File` gives its own.
301
+ */
302
+ open(file: Blob | PdfBytes, options?: PdfOpenOptions): Promise<void>;
283
303
  /** Builds the document as it is now. The result is a new buffer the caller owns. */
284
304
  export(options?: PdfExportOptions): Promise<Uint8Array>;
285
305
  /** Undoes the last edit, if there is one. */
@@ -299,44 +319,22 @@ export declare interface PdfEditorHandle {
299
319
  export declare type PdfEditorMessageCatalogue = typeof pdfEditorMessages;
300
320
 
301
321
  /**
302
- * The editor's English message catalogue: the SDK's own, which includes
303
- * sdk-core's, and `@hussmartinez/ui`'s, for the ui components the editor
304
- * renders (sdk-core ADR 0046). The editor builds one `Messages` object from
305
- * it, with the host's locale and overrides, and gives the same object to
306
- * its own components and to ui's.
322
+ * The English message catalogue of the SDK's components: `pdfMessages`,
323
+ * with sdk-core's text, errors and warnings; `@hussmartinez/ui`'s, for the
324
+ * ui components the editor renders (sdk-core ADR 0046); and the text of the
325
+ * editor, its toolbar and tools, the viewer and the thumbnails.
307
326
  *
308
- * It's defined in the React entry, so the headless `.` entry and its
309
- * `pdfMessages` don't carry ui's text.
327
+ * `PdfEditor` and `PdfSessionProvider` each build one `Messages` object from
328
+ * it, with the host's locale and overrides, and the editor gives the same
329
+ * object to its own components and to ui's. Override any of its keys through
330
+ * their `messages` prop, typed with `PdfEditorMessageCatalogue`.
331
+ *
332
+ * It's defined in the React entry, so the server-safe `.` entry and its
333
+ * `pdfMessages` carry no interface text (docs/adr/0010).
310
334
  *
311
335
  * @public
312
336
  */
313
337
  export declare const pdfEditorMessages: {
314
- readonly "dialog.close": "Close";
315
- readonly "fileDropZone.choose": "Choose a file";
316
- readonly "fileDropZone.chooseMultiple": "Choose files";
317
- readonly "fileDropZone.hint": "or drop it here";
318
- readonly "fileDropZone.hintMultiple": "or drop them here";
319
- readonly "progress.label": "Progress";
320
- readonly "spinner.label": "Loading";
321
- readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
322
- readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
323
- readonly "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.";
324
- readonly "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.";
325
- readonly "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.";
326
- readonly "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.";
327
- readonly "errors.SESSION_TOO_LARGE": "The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.";
328
- readonly "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.";
329
- readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
330
- readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't a PDF project.";
331
- readonly "errors.UNSUPPORTED_FORMAT": "This project was saved by a newer version, or by another app. Update the app, and try again.";
332
- readonly "warnings.maxPages": {
333
- readonly $plural: "actual";
334
- } & {
335
- readonly one: "This document has {actual} page. Large documents may be slow.";
336
- readonly other: "This document has {actual} pages. Large documents may be slow.";
337
- };
338
- readonly "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.";
339
- readonly "warnings.maxImagePixels": "Some images are very large and may be slow to show.";
340
338
  readonly "viewer.label": "Document";
341
339
  readonly "viewer.empty": "No document is open.";
342
340
  readonly "viewer.page": "Page {page} of {count}";
@@ -367,16 +365,72 @@ export declare const pdfEditorMessages: {
367
365
  readonly one: "Rotated {count} page.";
368
366
  readonly other: "Rotated {count} pages.";
369
367
  };
368
+ readonly "editor.deleted": {
369
+ readonly $plural: "count";
370
+ } & {
371
+ readonly one: "Deleted {count} page.";
372
+ readonly other: "Deleted {count} pages.";
373
+ };
374
+ readonly "editor.moved": {
375
+ readonly $plural: "count";
376
+ } & {
377
+ readonly one: "Moved {count} page to position {position}.";
378
+ readonly other: "Moved {count} pages to position {position}.";
379
+ };
380
+ readonly "editor.inserted": {
381
+ readonly $plural: "count";
382
+ } & {
383
+ readonly one: "Inserted {count} page after page {page}.";
384
+ readonly other: "Inserted {count} pages after page {page}.";
385
+ };
386
+ readonly "editor.historyTrimmed": "To make room for the inserted document, your earliest edits can no longer be undone.";
387
+ readonly "editor.saving": "Preparing the PDF…";
388
+ readonly "editor.cancelSave": "Cancel";
389
+ readonly "editor.saved": "Saved {name}.";
390
+ readonly "editor.ready": "The PDF is ready.";
391
+ readonly "editor.saveFailed": "The PDF couldn't be saved. Please try again.";
370
392
  readonly "toolbar.label": "PDF tools";
371
393
  readonly "toolbar.groups.file": "File";
372
394
  readonly "toolbar.groups.history": "History";
373
395
  readonly "toolbar.groups.pages": "Pages";
396
+ readonly "toolbar.groups.save": "Save";
374
397
  readonly "toolbar.groups.other": "More tools";
375
398
  readonly "tools.open": "Open a PDF";
376
399
  readonly "tools.undo": "Undo";
377
400
  readonly "tools.redo": "Redo";
378
401
  readonly "tools.rotate-left": "Rotate left";
379
402
  readonly "tools.rotate-right": "Rotate right";
403
+ readonly "tools.delete-pages": "Delete pages";
404
+ readonly "tools.download": "Download";
405
+ readonly "tools.insert-pages": "Insert pages";
406
+ readonly "tools.move-earlier": "Move earlier";
407
+ readonly "tools.move-later": "Move later";
408
+ readonly "dialog.close": "Close";
409
+ readonly "fileDropZone.choose": "Choose a file";
410
+ readonly "fileDropZone.chooseMultiple": "Choose files";
411
+ readonly "fileDropZone.hint": "or drop it here";
412
+ readonly "fileDropZone.hintMultiple": "or drop them here";
413
+ readonly "progress.label": "Progress";
414
+ readonly "spinner.label": "Loading";
415
+ readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
416
+ readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
417
+ readonly "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.";
418
+ readonly "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.";
419
+ readonly "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.";
420
+ readonly "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.";
421
+ readonly "errors.SESSION_TOO_LARGE": "The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.";
422
+ readonly "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.";
423
+ readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
424
+ readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't a PDF project.";
425
+ readonly "errors.UNSUPPORTED_FORMAT": "This project was saved by a newer version, or by another app. Update the app, and try again.";
426
+ readonly "warnings.maxPages": {
427
+ readonly $plural: "actual";
428
+ } & {
429
+ readonly one: "This document has {actual} page. Large documents may be slow.";
430
+ readonly other: "This document has {actual} pages. Large documents may be slow.";
431
+ };
432
+ readonly "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.";
433
+ readonly "warnings.maxImagePixels": "Some images are very large and may be slow to show.";
380
434
  readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
381
435
  readonly "errors.ABORTED": "The operation was cancelled.";
382
436
  readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
@@ -452,6 +506,19 @@ export declare interface PdfEditorProps extends Omit<PdfSessionProviderProps, "c
452
506
  readonly file?: Blob | PdfBytes | null;
453
507
  /** Called after the document opens, changes or closes. */
454
508
  readonly onChange?: (change: PdfEditorChange) => void;
509
+ /**
510
+ * Receives the document the download tool built, instead of the browser
511
+ * downloading it, such as to store it in the host's own storage. The
512
+ * bytes are a new buffer the host owns. If it throws or rejects, the
513
+ * editor says the PDF couldn't be saved; its error is the host's to log.
514
+ */
515
+ readonly onExport?: (bytes: Uint8Array, info: PdfExportInfo) => void | Promise<void>;
516
+ /**
517
+ * Names the download tool's file. The result is cleaned as a file name
518
+ * and given a `.pdf` extension; the opened file's name by default, or
519
+ * `"document.pdf"` (docs/adr/0009).
520
+ */
521
+ readonly downloadName?: (info: PdfDownloadNameInfo) => string;
455
522
  /**
456
523
  * Which tools are present, by id, in order, such as
457
524
  * `["pdf.undo", "pdf.redo"]`. All of {@link pdfTools} by default. Their
@@ -567,6 +634,21 @@ declare class PdfError extends SdkError<PdfErrorCode> {
567
634
  */
568
635
  declare type PdfErrorCode = SdkCoreErrorCode | "INVALID_PDF" | "PASSWORD_REQUIRED" | "PROCESSING_FAILED" | "TOO_MANY_PAGES" | "SESSION_TOO_LARGE" | "IMAGE_TOO_LARGE" | "INVALID_COMMAND" | "INVALID_DOCUMENT" | "UNSUPPORTED_FORMAT";
569
636
 
637
+ /**
638
+ * What {@link PdfEditorProps.onExport} is given with the saved document.
639
+ *
640
+ * @public
641
+ */
642
+ export declare interface PdfExportInfo {
643
+ /**
644
+ * The name the browser download would have had: cleaned, ending in
645
+ * `.pdf`, and `"document.pdf"` when there's none.
646
+ */
647
+ readonly fileName: string;
648
+ /** The saved document's page count. */
649
+ readonly pageCount: number;
650
+ }
651
+
570
652
  /**
571
653
  * Options for {@link PdfSession.export}.
572
654
  *
@@ -671,7 +753,7 @@ declare interface PdfImageCompression {
671
753
  *
672
754
  * @public
673
755
  */
674
- declare interface PdfInsertOptions extends PdfCallOptions {
756
+ declare interface PdfInsertOptions extends PdfOpenOptions {
675
757
  /** The position of the first inserted page. Defaults to the end. */
676
758
  readonly at?: number;
677
759
  /** Zero-based indexes of the pages to insert. Defaults to every page. */
@@ -783,137 +865,6 @@ declare interface PdfLink {
783
865
  readonly url: string;
784
866
  }
785
867
 
786
- /**
787
- * The type of {@link pdfMessages}, for typing a host's overrides with
788
- * `MessageOverrides<PdfMessageCatalogue>`.
789
- *
790
- * @public
791
- */
792
- declare type PdfMessageCatalogue = typeof pdfMessages;
793
-
794
- /**
795
- * The PDF SDK's English message catalogue: sdk-core's messages, and text for
796
- * every {@link PdfErrorCode} and every limit's warning. Pass it to
797
- * `createMessages` from `@hussmartinez/sdk-core`, with the host's locale and
798
- * overrides.
799
- *
800
- * Error text is looked up by code, with the error's `details` as
801
- * parameters, and never taken from `error.message` (ADR 0019).
802
- *
803
- * @example
804
- * ```ts
805
- * const messages = createMessages(pdfMessages, { locale: "en", overrides: props.messages });
806
- * messages.error(error); // "This document has 6,200 pages, which is over the 5,000-page limit."
807
- * messages.t("warnings.maxPages", { actual: 1_200 });
808
- * ```
809
- *
810
- * @public
811
- */
812
- declare const pdfMessages: {
813
- readonly "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.";
814
- readonly "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.";
815
- readonly "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.";
816
- readonly "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.";
817
- readonly "errors.SESSION_TOO_LARGE": "The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.";
818
- readonly "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.";
819
- readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
820
- readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't a PDF project.";
821
- readonly "errors.UNSUPPORTED_FORMAT": "This project was saved by a newer version, or by another app. Update the app, and try again.";
822
- readonly "warnings.maxPages": {
823
- readonly $plural: "actual";
824
- } & {
825
- readonly one: "This document has {actual} page. Large documents may be slow.";
826
- readonly other: "This document has {actual} pages. Large documents may be slow.";
827
- };
828
- readonly "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.";
829
- readonly "warnings.maxImagePixels": "Some images are very large and may be slow to show.";
830
- readonly "viewer.label": "Document";
831
- readonly "viewer.empty": "No document is open.";
832
- readonly "viewer.page": "Page {page} of {count}";
833
- readonly "viewer.webLink": "Link to {destination}, opens in a new tab";
834
- readonly "viewer.emailLink": "Email {destination}";
835
- readonly "thumbnails.label": "Pages";
836
- readonly "thumbnails.page": "Page {page} of {count}";
837
- readonly "thumbnails.number": "{page}";
838
- readonly "editor.label": "PDF editor";
839
- readonly "editor.start.title": "Open a PDF to get started";
840
- readonly "editor.start.retryTitle": "Try another PDF";
841
- readonly "editor.start.choose": "Choose a PDF";
842
- readonly "editor.start.retry": "Choose another PDF";
843
- readonly "editor.start.hint": "Or drop one here. Your file stays on this device and is never uploaded.";
844
- readonly "editor.opening": "Opening the PDF…";
845
- readonly "editor.opened": {
846
- readonly $plural: "count";
847
- } & {
848
- readonly one: "Opened a PDF with {count} page.";
849
- readonly other: "Opened a PDF with {count} pages.";
850
- };
851
- readonly "editor.closed": "The PDF was closed.";
852
- readonly "editor.undone": "Undone.";
853
- readonly "editor.redone": "Redone.";
854
- readonly "editor.rotated": {
855
- readonly $plural: "count";
856
- } & {
857
- readonly one: "Rotated {count} page.";
858
- readonly other: "Rotated {count} pages.";
859
- };
860
- readonly "toolbar.label": "PDF tools";
861
- readonly "toolbar.groups.file": "File";
862
- readonly "toolbar.groups.history": "History";
863
- readonly "toolbar.groups.pages": "Pages";
864
- readonly "toolbar.groups.other": "More tools";
865
- readonly "tools.open": "Open a PDF";
866
- readonly "tools.undo": "Undo";
867
- readonly "tools.redo": "Redo";
868
- readonly "tools.rotate-left": "Rotate left";
869
- readonly "tools.rotate-right": "Rotate right";
870
- readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
871
- readonly "errors.ABORTED": "The operation was cancelled.";
872
- readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
873
- readonly "errors.WORKER_START_FAILED": "The file processor couldn't start. Reload the page and try again.";
874
- readonly "errors.WORKER_PROTOCOL_MISMATCH": "The file processor is out of date. Reload the page to update it.";
875
- readonly "errors.WORKER_CRASHED": "The file processor stopped unexpectedly. Please try again.";
876
- readonly "errors.WORKER_TERMINATED": "The operation was stopped before it finished. Please try again.";
877
- readonly "errors.WORKER_METHOD_NOT_FOUND": "This operation isn't available. Reload the page and try again.";
878
- readonly "errors.WORKER_DATA_NOT_CLONEABLE": "Something went wrong while processing the file. Please try again.";
879
- readonly "errors.UNSUPPORTED_ENVIRONMENT": "This browser doesn't support a feature this tool needs. Update your browser, or try another one.";
880
- readonly "errors.FILE_TOO_LARGE": "This file is {actual, fileSize}, which is over the {maximum, fileSize} limit.";
881
- readonly "errors.TOO_MANY_FILES": {
882
- readonly $plural: "maximum";
883
- } & {
884
- readonly one: "You can add {maximum} file at a time.";
885
- readonly other: "You can add up to {maximum} files at a time.";
886
- };
887
- readonly "errors.DECODED_SIZE_TOO_LARGE": "This file expands to more than {maximum, fileSize} when opened, which is over the limit.";
888
- readonly "errors.PROCESSING_TIME_EXCEEDED": "Processing this file took too long and was stopped.";
889
- readonly "warnings.maxFileSize": "This file is {actual, fileSize}. Large files may be slow to process.";
890
- readonly "warnings.maxFiles": "Adding {actual} files at once may be slow.";
891
- readonly "warnings.maxDecodedSize": "This file is very large once opened and may be slow to process.";
892
- readonly "warnings.maxProcessingTime": "This is taking longer than usual.";
893
- readonly "keys.control": "Ctrl";
894
- readonly "keys.alt": "Alt";
895
- readonly "keys.shift": "Shift";
896
- readonly "keys.meta": "Meta";
897
- readonly "keys.apple.control": "\u2303";
898
- readonly "keys.apple.alt": "\u2325";
899
- readonly "keys.apple.shift": "\u21E7";
900
- readonly "keys.apple.meta": "\u2318";
901
- readonly "keys.space": "Space";
902
- readonly "keys.enter": "Enter";
903
- readonly "keys.escape": "Esc";
904
- readonly "keys.tab": "Tab";
905
- readonly "keys.delete": "Delete";
906
- readonly "keys.backspace": "Backspace";
907
- readonly "keys.arrowUp": "\u2191";
908
- readonly "keys.arrowDown": "\u2193";
909
- readonly "keys.arrowLeft": "\u2190";
910
- readonly "keys.arrowRight": "\u2192";
911
- readonly "keys.home": "Home";
912
- readonly "keys.end": "End";
913
- readonly "keys.pageUp": "Page Up";
914
- readonly "keys.pageDown": "Page Down";
915
- };
916
-
917
868
  /**
918
869
  * Moves pages, keeping their relative order, so that the first of them ends
919
870
  * up at position `to` of the resulting plan.
@@ -927,6 +878,19 @@ declare interface PdfMovePagesCommand {
927
878
  readonly to: number;
928
879
  }
929
880
 
881
+ /**
882
+ * Options for {@link PdfSession.open}.
883
+ *
884
+ * @public
885
+ */
886
+ declare interface PdfOpenOptions extends PdfCallOptions {
887
+ /**
888
+ * The file's name, for bytes or a `Blob` that isn't a `File`. It wins over
889
+ * `File.name`, and is cleaned before it's kept (docs/adr/0009).
890
+ */
891
+ readonly name?: string;
892
+ }
893
+
930
894
  /**
931
895
  * Facts about one page of a source document.
932
896
  *
@@ -1125,7 +1089,7 @@ declare interface PdfSession {
1125
1089
  * Rejects with a `PdfError`, which the snapshot also holds; the current
1126
1090
  * document, if any, stays open.
1127
1091
  */
1128
- open(file: Blob | PdfBytes, options?: PdfCallOptions): Promise<void>;
1092
+ open(file: Blob | PdfBytes, options?: PdfOpenOptions): Promise<void>;
1129
1093
  /**
1130
1094
  * Inserts the pages of another document, as one undoable step. If the
1131
1095
  * documents held would then exceed `maxSessionSize`, the session first
@@ -1248,7 +1212,7 @@ export declare interface PdfSessionProviderProps {
1248
1212
  /** Anonymous usage events from a session the provider creates. */
1249
1213
  readonly onEvent?: (event: PdfSessionEvent) => void;
1250
1214
  /** Text overrides, typed against the English catalogue (ADR 0019). */
1251
- readonly messages?: MessageOverrides<PdfMessageCatalogue>;
1215
+ readonly messages?: MessageOverrides<PdfEditorMessageCatalogue>;
1252
1216
  /** The locale for numbers, sizes and plurals. Defaults to `"en"`. */
1253
1217
  readonly locale?: string;
1254
1218
  /** The components that use the session, such as `PdfViewer`. */
@@ -1290,7 +1254,9 @@ declare interface PdfSessionSnapshot {
1290
1254
  readonly historyTrimmed: boolean;
1291
1255
  /**
1292
1256
  * The keys of the selected pages, in plan order. Tools act on them, such as
1293
- * rotating the selection. View state: not undoable, and never in events.
1257
+ * rotating the selection. View state: not part of the plan and never in
1258
+ * events, but undo and redo bring back the selection and current page
1259
+ * that went with each step (docs/adr/0008).
1294
1260
  */
1295
1261
  readonly selection: readonly string[];
1296
1262
  /** The key of the page the user is looking at, if a document is open. */
@@ -1343,6 +1309,13 @@ declare interface PdfSourceInfo {
1343
1309
  readonly pageCount: number;
1344
1310
  /** The size of its bytes. */
1345
1311
  readonly byteLength: number;
1312
+ /**
1313
+ * The file's name, from `File.name` or the `name` option, cleaned as
1314
+ * docs/adr/0009 describes: one path segment, without control or
1315
+ * bidirectional formatting characters, at most 128 code points. Absent
1316
+ * when there was none. Show it only as text; it never reaches `onEvent`.
1317
+ */
1318
+ readonly name?: string;
1346
1319
  }
1347
1320
 
1348
1321
  /**
@@ -1413,7 +1386,9 @@ declare interface PdfTextItem {
1413
1386
  * Keyboard: the arrow keys, Home and End move to a page, select it and show
1414
1387
  * it; with Shift they extend the selection; with Ctrl or ⌘ they move without
1415
1388
  * selecting, and Space then adds or removes the page. Ctrl or ⌘ + A selects
1416
- * every page, and Escape keeps only the focused one. With a pointer: click,
1389
+ * every page, and Escape keeps only the focused one. Delete and Backspace,
1390
+ * and Alt or Option with ↑ and ↓, run `onDelete` and `onMove` when given.
1391
+ * With a pointer: click,
1417
1392
  * Ctrl or ⌘ + click, and Shift + click.
1418
1393
  *
1419
1394
  * @public
@@ -1441,6 +1416,16 @@ export declare interface PdfThumbnailsProps {
1441
1416
  readonly unstyled?: boolean;
1442
1417
  /** How many thumbnails are drawn at once. Defaults to 2. */
1443
1418
  readonly concurrency?: number;
1419
+ /**
1420
+ * Runs when the user presses Delete or Backspace in the list, such as the
1421
+ * editor's delete tool. Without it, those keys do nothing here.
1422
+ */
1423
+ readonly onDelete?: () => void;
1424
+ /**
1425
+ * Runs when the user presses Alt+↑ or Alt+↓ (Option on macOS) in the list,
1426
+ * such as the editor's move tools. Without it, those keys do nothing here.
1427
+ */
1428
+ readonly onMove?: (direction: "earlier" | "later") => void;
1444
1429
  }
1445
1430
 
1446
1431
  /**
@@ -1475,6 +1460,10 @@ export declare interface PdfToolbarProps {
1475
1460
  readonly context: PdfToolContext;
1476
1461
  /** Icon components by name. */
1477
1462
  readonly icons: Readonly<Record<string, IconComponent>>;
1463
+ /** Whether the editor is saving, which tools read as `saving`. */
1464
+ readonly saving?: boolean;
1465
+ /** Whether the editor is inserting a document, which tools read as `inserting`. */
1466
+ readonly inserting?: boolean;
1478
1467
  /** Runs a tool. Defaults to running it against `context`. */
1479
1468
  readonly onRun?: (tool: PdfTool) => void;
1480
1469
  /** Extra classes on the root. */
@@ -1491,6 +1480,16 @@ export declare interface PdfToolContext {
1491
1480
  readonly session: PdfSession;
1492
1481
  /** Asks the user for a PDF and opens it, as the open tool does. */
1493
1482
  readonly chooseFile: () => void;
1483
+ /**
1484
+ * Builds the document and saves it, as the download tool does
1485
+ * (docs/adr/0009). Absent outside the editor.
1486
+ */
1487
+ readonly save?: () => void;
1488
+ /**
1489
+ * Asks the user for another PDF and inserts its pages after the current
1490
+ * page, as the insert tool does (docs/adr/0008). Absent outside the editor.
1491
+ */
1492
+ readonly chooseInsertFile?: () => void;
1494
1493
  }
1495
1494
 
1496
1495
  /**
@@ -1508,6 +1507,10 @@ export declare const pdfTools: readonly PdfTool[];
1508
1507
  export declare interface PdfToolState {
1509
1508
  /** The session's current snapshot. */
1510
1509
  readonly snapshot: PdfSessionSnapshot;
1510
+ /** Whether the editor is saving the document. Absent outside the editor. */
1511
+ readonly saving?: boolean;
1512
+ /** Whether the editor is inserting another document. Absent outside the editor. */
1513
+ readonly inserting?: boolean;
1511
1514
  }
1512
1515
 
1513
1516
  /**
@@ -1597,7 +1600,7 @@ export declare function usePdfDocument(): PdfSessionSnapshot;
1597
1600
  *
1598
1601
  * @public
1599
1602
  */
1600
- export declare function usePdfMessages(): Messages<PdfMessageCatalogue>;
1603
+ export declare function usePdfMessages(): Messages<PdfEditorMessageCatalogue>;
1601
1604
 
1602
1605
  /**
1603
1606
  * The session of the nearest `PdfSessionProvider`, to open documents, run