@hussmartinez/pdf-sdk 0.3.0 → 0.4.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.
@@ -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-B70FATD2.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,74 @@ 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 "colorField.swatches": "swatches";
409
+ readonly "dialog.close": "Close";
410
+ readonly "fileDropZone.choose": "Choose a file";
411
+ readonly "fileDropZone.chooseMultiple": "Choose files";
412
+ readonly "fileDropZone.hint": "or drop it here";
413
+ readonly "fileDropZone.hintMultiple": "or drop them here";
414
+ readonly "progress.label": "Progress";
415
+ readonly "reorderableList.moved": "{label} moved to position {position} of {count}";
416
+ readonly "spinner.label": "Loading";
417
+ readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
418
+ readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
419
+ readonly "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.";
420
+ readonly "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.";
421
+ readonly "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.";
422
+ readonly "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.";
423
+ 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.";
424
+ readonly "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.";
425
+ readonly "errors.INVALID_COMMAND": "This edit couldn't be made. Please try again.";
426
+ readonly "errors.INVALID_DOCUMENT": "This project is damaged, or it isn't a PDF project.";
427
+ readonly "errors.UNSUPPORTED_FORMAT": "This project was saved by a newer version, or by another app. Update the app, and try again.";
428
+ readonly "warnings.maxPages": {
429
+ readonly $plural: "actual";
430
+ } & {
431
+ readonly one: "This document has {actual} page. Large documents may be slow.";
432
+ readonly other: "This document has {actual} pages. Large documents may be slow.";
433
+ };
434
+ readonly "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.";
435
+ readonly "warnings.maxImagePixels": "Some images are very large and may be slow to show.";
380
436
  readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
381
437
  readonly "errors.ABORTED": "The operation was cancelled.";
382
438
  readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
@@ -452,6 +508,19 @@ export declare interface PdfEditorProps extends Omit<PdfSessionProviderProps, "c
452
508
  readonly file?: Blob | PdfBytes | null;
453
509
  /** Called after the document opens, changes or closes. */
454
510
  readonly onChange?: (change: PdfEditorChange) => void;
511
+ /**
512
+ * Receives the document the download tool built, instead of the browser
513
+ * downloading it, such as to store it in the host's own storage. The
514
+ * bytes are a new buffer the host owns. If it throws or rejects, the
515
+ * editor says the PDF couldn't be saved; its error is the host's to log.
516
+ */
517
+ readonly onExport?: (bytes: Uint8Array, info: PdfExportInfo) => void | Promise<void>;
518
+ /**
519
+ * Names the download tool's file. The result is cleaned as a file name
520
+ * and given a `.pdf` extension; the opened file's name by default, or
521
+ * `"document.pdf"` (docs/adr/0009).
522
+ */
523
+ readonly downloadName?: (info: PdfDownloadNameInfo) => string;
455
524
  /**
456
525
  * Which tools are present, by id, in order, such as
457
526
  * `["pdf.undo", "pdf.redo"]`. All of {@link pdfTools} by default. Their
@@ -567,6 +636,21 @@ declare class PdfError extends SdkError<PdfErrorCode> {
567
636
  */
568
637
  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
638
 
639
+ /**
640
+ * What {@link PdfEditorProps.onExport} is given with the saved document.
641
+ *
642
+ * @public
643
+ */
644
+ export declare interface PdfExportInfo {
645
+ /**
646
+ * The name the browser download would have had: cleaned, ending in
647
+ * `.pdf`, and `"document.pdf"` when there's none.
648
+ */
649
+ readonly fileName: string;
650
+ /** The saved document's page count. */
651
+ readonly pageCount: number;
652
+ }
653
+
570
654
  /**
571
655
  * Options for {@link PdfSession.export}.
572
656
  *
@@ -671,7 +755,7 @@ declare interface PdfImageCompression {
671
755
  *
672
756
  * @public
673
757
  */
674
- declare interface PdfInsertOptions extends PdfCallOptions {
758
+ declare interface PdfInsertOptions extends PdfOpenOptions {
675
759
  /** The position of the first inserted page. Defaults to the end. */
676
760
  readonly at?: number;
677
761
  /** Zero-based indexes of the pages to insert. Defaults to every page. */
@@ -783,137 +867,6 @@ declare interface PdfLink {
783
867
  readonly url: string;
784
868
  }
785
869
 
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
870
  /**
918
871
  * Moves pages, keeping their relative order, so that the first of them ends
919
872
  * up at position `to` of the resulting plan.
@@ -927,6 +880,19 @@ declare interface PdfMovePagesCommand {
927
880
  readonly to: number;
928
881
  }
929
882
 
883
+ /**
884
+ * Options for {@link PdfSession.open}.
885
+ *
886
+ * @public
887
+ */
888
+ declare interface PdfOpenOptions extends PdfCallOptions {
889
+ /**
890
+ * The file's name, for bytes or a `Blob` that isn't a `File`. It wins over
891
+ * `File.name`, and is cleaned before it's kept (docs/adr/0009).
892
+ */
893
+ readonly name?: string;
894
+ }
895
+
930
896
  /**
931
897
  * Facts about one page of a source document.
932
898
  *
@@ -1125,7 +1091,7 @@ declare interface PdfSession {
1125
1091
  * Rejects with a `PdfError`, which the snapshot also holds; the current
1126
1092
  * document, if any, stays open.
1127
1093
  */
1128
- open(file: Blob | PdfBytes, options?: PdfCallOptions): Promise<void>;
1094
+ open(file: Blob | PdfBytes, options?: PdfOpenOptions): Promise<void>;
1129
1095
  /**
1130
1096
  * Inserts the pages of another document, as one undoable step. If the
1131
1097
  * documents held would then exceed `maxSessionSize`, the session first
@@ -1248,7 +1214,7 @@ export declare interface PdfSessionProviderProps {
1248
1214
  /** Anonymous usage events from a session the provider creates. */
1249
1215
  readonly onEvent?: (event: PdfSessionEvent) => void;
1250
1216
  /** Text overrides, typed against the English catalogue (ADR 0019). */
1251
- readonly messages?: MessageOverrides<PdfMessageCatalogue>;
1217
+ readonly messages?: MessageOverrides<PdfEditorMessageCatalogue>;
1252
1218
  /** The locale for numbers, sizes and plurals. Defaults to `"en"`. */
1253
1219
  readonly locale?: string;
1254
1220
  /** The components that use the session, such as `PdfViewer`. */
@@ -1290,7 +1256,9 @@ declare interface PdfSessionSnapshot {
1290
1256
  readonly historyTrimmed: boolean;
1291
1257
  /**
1292
1258
  * 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.
1259
+ * rotating the selection. View state: not part of the plan and never in
1260
+ * events, but undo and redo bring back the selection and current page
1261
+ * that went with each step (docs/adr/0008).
1294
1262
  */
1295
1263
  readonly selection: readonly string[];
1296
1264
  /** The key of the page the user is looking at, if a document is open. */
@@ -1343,6 +1311,13 @@ declare interface PdfSourceInfo {
1343
1311
  readonly pageCount: number;
1344
1312
  /** The size of its bytes. */
1345
1313
  readonly byteLength: number;
1314
+ /**
1315
+ * The file's name, from `File.name` or the `name` option, cleaned as
1316
+ * docs/adr/0009 describes: one path segment, without control or
1317
+ * bidirectional formatting characters, at most 128 code points. Absent
1318
+ * when there was none. Show it only as text; it never reaches `onEvent`.
1319
+ */
1320
+ readonly name?: string;
1346
1321
  }
1347
1322
 
1348
1323
  /**
@@ -1413,7 +1388,9 @@ declare interface PdfTextItem {
1413
1388
  * Keyboard: the arrow keys, Home and End move to a page, select it and show
1414
1389
  * it; with Shift they extend the selection; with Ctrl or ⌘ they move without
1415
1390
  * 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,
1391
+ * every page, and Escape keeps only the focused one. Delete and Backspace,
1392
+ * and Alt or Option with ↑ and ↓, run `onDelete` and `onMove` when given.
1393
+ * With a pointer: click,
1417
1394
  * Ctrl or ⌘ + click, and Shift + click.
1418
1395
  *
1419
1396
  * @public
@@ -1441,6 +1418,16 @@ export declare interface PdfThumbnailsProps {
1441
1418
  readonly unstyled?: boolean;
1442
1419
  /** How many thumbnails are drawn at once. Defaults to 2. */
1443
1420
  readonly concurrency?: number;
1421
+ /**
1422
+ * Runs when the user presses Delete or Backspace in the list, such as the
1423
+ * editor's delete tool. Without it, those keys do nothing here.
1424
+ */
1425
+ readonly onDelete?: () => void;
1426
+ /**
1427
+ * Runs when the user presses Alt+↑ or Alt+↓ (Option on macOS) in the list,
1428
+ * such as the editor's move tools. Without it, those keys do nothing here.
1429
+ */
1430
+ readonly onMove?: (direction: "earlier" | "later") => void;
1444
1431
  }
1445
1432
 
1446
1433
  /**
@@ -1475,6 +1462,10 @@ export declare interface PdfToolbarProps {
1475
1462
  readonly context: PdfToolContext;
1476
1463
  /** Icon components by name. */
1477
1464
  readonly icons: Readonly<Record<string, IconComponent>>;
1465
+ /** Whether the editor is saving, which tools read as `saving`. */
1466
+ readonly saving?: boolean;
1467
+ /** Whether the editor is inserting a document, which tools read as `inserting`. */
1468
+ readonly inserting?: boolean;
1478
1469
  /** Runs a tool. Defaults to running it against `context`. */
1479
1470
  readonly onRun?: (tool: PdfTool) => void;
1480
1471
  /** Extra classes on the root. */
@@ -1491,6 +1482,16 @@ export declare interface PdfToolContext {
1491
1482
  readonly session: PdfSession;
1492
1483
  /** Asks the user for a PDF and opens it, as the open tool does. */
1493
1484
  readonly chooseFile: () => void;
1485
+ /**
1486
+ * Builds the document and saves it, as the download tool does
1487
+ * (docs/adr/0009). Absent outside the editor.
1488
+ */
1489
+ readonly save?: () => void;
1490
+ /**
1491
+ * Asks the user for another PDF and inserts its pages after the current
1492
+ * page, as the insert tool does (docs/adr/0008). Absent outside the editor.
1493
+ */
1494
+ readonly chooseInsertFile?: () => void;
1494
1495
  }
1495
1496
 
1496
1497
  /**
@@ -1508,6 +1509,10 @@ export declare const pdfTools: readonly PdfTool[];
1508
1509
  export declare interface PdfToolState {
1509
1510
  /** The session's current snapshot. */
1510
1511
  readonly snapshot: PdfSessionSnapshot;
1512
+ /** Whether the editor is saving the document. Absent outside the editor. */
1513
+ readonly saving?: boolean;
1514
+ /** Whether the editor is inserting another document. Absent outside the editor. */
1515
+ readonly inserting?: boolean;
1511
1516
  }
1512
1517
 
1513
1518
  /**
@@ -1597,7 +1602,7 @@ export declare function usePdfDocument(): PdfSessionSnapshot;
1597
1602
  *
1598
1603
  * @public
1599
1604
  */
1600
- export declare function usePdfMessages(): Messages<PdfMessageCatalogue>;
1605
+ export declare function usePdfMessages(): Messages<PdfEditorMessageCatalogue>;
1601
1606
 
1602
1607
  /**
1603
1608
  * The session of the nearest `PdfSessionProvider`, to open documents, run