@embedpdf/plugin-annotation 3.0.0 → 3.2.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.
Files changed (31) hide show
  1. package/dist/contract/host.cjs +2 -2
  2. package/dist/contract/host.d.cts +3 -3
  3. package/dist/contract/host.d.ts +3 -3
  4. package/dist/contract/host.js +2 -2
  5. package/dist/{contract-OwgW3JE8.js → contract-BrvLUGi2.js} +73 -80
  6. package/dist/contract-BrvLUGi2.js.map +1 -0
  7. package/dist/{contract-BK2g1Rem.d.ts → contract-CQfRsCVj.d.ts} +89 -17
  8. package/dist/{contract-CBYEqnev.d.cts → contract-DkxvCGXL.d.cts} +89 -17
  9. package/dist/{contract-BtAl3Yo2.cjs → contract-X3gZNpwu.cjs} +78 -79
  10. package/dist/contract-X3gZNpwu.cjs.map +1 -0
  11. package/dist/contract.cjs +1 -1
  12. package/dist/contract.d.cts +2 -2
  13. package/dist/contract.d.ts +2 -2
  14. package/dist/contract.js +1 -1
  15. package/dist/{host-contract-COF2Prd-.d.ts → host-contract-BSH_muud.d.cts} +35 -6
  16. package/dist/{host-contract-BzM2upsA.cjs → host-contract-C7vx6wTQ.cjs} +2 -2
  17. package/dist/host-contract-C7vx6wTQ.cjs.map +1 -0
  18. package/dist/{host-contract-CSKiuu3g.js → host-contract-CDp5skzD.js} +2 -2
  19. package/dist/host-contract-CDp5skzD.js.map +1 -0
  20. package/dist/{host-contract-CxOrR_pp.d.cts → host-contract-DU3CxFE1.d.ts} +35 -6
  21. package/dist/index.cjs +486 -80
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +3 -3
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +488 -82
  26. package/dist/index.js.map +1 -1
  27. package/package.json +12 -12
  28. package/dist/contract-BtAl3Yo2.cjs.map +0 -1
  29. package/dist/contract-OwgW3JE8.js.map +0 -1
  30. package/dist/host-contract-BzM2upsA.cjs.map +0 -1
  31. package/dist/host-contract-CSKiuu3g.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { BatchResult, DeepPartial, EventHook, EventOrigin, OperationOptions, PluginErrorInfo, ResourceStatus, SettingsApi, Unsubscribe } from "@embedpdf/core";
1
+ import { BatchResult, DeepPartial, EventHook, EventOrigin, HistoryOptions, OperationOptions, PluginErrorInfo, ResourceStatus, SettingsApi, Unsubscribe } from "@embedpdf/core";
2
2
  import { MountableFontProgram } from "@embedpdf/plugin-fonts/contract";
3
3
  import { AnnotationTransfer } from "@embedpdf/engine-core/public";
4
4
  import { Annotation, Annotation as Annotation$1, AnnotationBundle, AnnotationBundle as AnnotationBundle$1, AnnotationDraft, AnnotationDraft as AnnotationDraft$1, AnnotationImportDrop, AnnotationImportDrop as AnnotationImportDrop$1, AnnotationImportOptions, AnnotationImportOptions as AnnotationImportOptions$1, AnnotationPatch, AnnotationPatch as AnnotationPatch$1, AnnotationPosition, AnnotationPosition as AnnotationPosition$1, AnnotationRef, AnnotationRef as AnnotationRef$1, AnnotationResourceRole, AnnotationResourceRole as AnnotationResourceRole$1, AnnotationResources, AnnotationResources as AnnotationResources$1, AnnotationSubtype, AnnotationSubtype as AnnotationSubtype$1, AttachmentContent, AttachmentFileSource, AttachmentFileSource as AttachmentFileSource$1, BinarySource, Color, CommentThread, CommentThread as CommentThread$1, CommentThreadReview, PageRef, PdfActionTree, PdfLinkTarget, PdfLinkTarget as PdfLinkTarget$1, ReviewStatus, RichTextBody, RichTextParagraph, WidgetAppearance } from "@embedpdf/engine-core/runtime";
@@ -155,9 +155,10 @@ type ToolDefaultsFor<K extends ToolAuthoringKind> = ToolDraftOf<K> & (K extends
155
155
  interface AnnotationToolDefinition<K extends ToolAuthoringKind = ToolAuthoringKind> {
156
156
  /** Stable tool id — the value passed to `activateTool` and the `defaults` key. */
157
157
  id: string;
158
- /** Inherit `subtype` / `fieldsKind` / `cursor` / `enables` / `source` /
159
- * `selection` / `intent` / `ink` / `meta`
160
- * from an existing tool id (a built-in or another entry). Own fields win. */
158
+ /** Start from a copy of a tool defined before this entry: a built-in, an
159
+ * earlier entry, or a tool registered while the app runs. The copy takes
160
+ * everything but its `meta`, and own fields win. A later change to that
161
+ * tool doesn't reach this one. */
161
162
  extends?: string;
162
163
  /** The routing kind this tool authors — the core's client kind (the geometry
163
164
  * it draws + the props key). Usually the PDF subtype, but not always:
@@ -235,7 +236,8 @@ interface AnnotationToolDefinition<K extends ToolAuthoringKind = ToolAuthoringKi
235
236
  */
236
237
  afterCreate?: Partial<AfterCreateSettings>;
237
238
  /** Your own data, such as a label and an icon for a toolbar that builds itself
238
- * from the tool table. The plugin keeps it and never reads it. */
239
+ * from the tool table. The plugin keeps it and never reads it, and a tool
240
+ * made with `extends` starts without it. */
239
241
  meta?: Record<string, unknown>;
240
242
  }
241
243
  interface BuiltinToolKindMap {
@@ -450,9 +452,10 @@ interface AfterCreateSettings {
450
452
  */
451
453
  interface AnnotationSettings {
452
454
  /**
453
- * Change the built-in tools or add your own. An entry with a built-in's id
454
- * changes it (`{ id: 'ink', defaults: { strokeWidth: 6 } }`), a new id adds
455
- * a tool, and `extends` starts from another tool.
455
+ * Change the built-in tools or add your own, entry by entry in order. An
456
+ * entry with a tool's id changes only that tool
457
+ * (`{ id: 'ink', defaults: { strokeWidth: 6 } }`), a new id adds a tool, and
458
+ * `extends` starts from a copy of a tool listed before it, without its `meta`.
456
459
  */
457
460
  readonly tools: readonly AnnotationToolInput[];
458
461
  readonly afterCreate: AfterCreateSettings;
@@ -728,6 +731,25 @@ interface AnnotationImportResult {
728
731
  /** What was left out, and why, in bundle order. */
729
732
  readonly dropped: readonly AnnotationImportDrop[];
730
733
  }
734
+ /** How `duplicate()` copies: where the copies go, and whether they are selected. */
735
+ interface AnnotationDuplicateOptions {
736
+ /** The page the copies go on, as a ref or an index. Left out: each on its own page. */
737
+ readonly page?: PageRef | number;
738
+ /** How far each copy moves, in page points: `x` to the right, `y` down. Left out: not at all. */
739
+ readonly offset?: {
740
+ readonly x: number;
741
+ readonly y: number;
742
+ };
743
+ /** Select the copies as they show. */
744
+ readonly select?: boolean;
745
+ }
746
+ /** What `duplicate()` did: the copies, and what was left out. */
747
+ interface AnnotationDuplicateResult {
748
+ /** The copies as the engine wrote them, in the order the originals were named. */
749
+ readonly annotations: readonly Annotation[];
750
+ /** What was left out, and why, in the same order. */
751
+ readonly dropped: readonly AnnotationImportDrop[];
752
+ }
731
753
  /** Which annotations `export()` takes. */
732
754
  interface AnnotationExportSelection {
733
755
  /** These annotations, with what they point at and their replies. */
@@ -781,6 +803,24 @@ interface AnnotationSelectionCapability {
781
803
  canGroup(): boolean;
782
804
  /** Whether the selection holds a group that can be split. */
783
805
  canUngroup(): boolean;
806
+ /**
807
+ * Copy the selected annotations beside the originals and select the
808
+ * copies, as one step to undo. They land 10 points right and down, or left
809
+ * or up where that keeps them on the page; `offset` places them yourself.
810
+ * A selected group is copied as a group of its own. Resolves
811
+ * `{ annotations, dropped }`, as `duplicate()` on the plugin does.
812
+ */
813
+ duplicate(options?: OperationOptions & {
814
+ offset?: {
815
+ readonly x: number;
816
+ readonly y: number;
817
+ };
818
+ }): Promise<AnnotationDuplicateResult>;
819
+ /**
820
+ * Whether the selection can be copied: something is selected, the user may
821
+ * create annotations, and nothing selected is locked.
822
+ */
823
+ canDuplicate(): boolean;
784
824
  /**
785
825
  * Where a menu attaches: the selection's page and the box around it, or
786
826
  * `null` with nothing selected, or while a gesture moves, resizes or turns it.
@@ -821,7 +861,11 @@ interface AnnotationToolsCapability {
821
861
  list(): readonly AnnotationTool[];
822
862
  /** One tool, or `null`. */
823
863
  get(id: string): AnnotationTool | null;
824
- /** Add a tool while the app runs, or replace the one with the same id. Returns a function that removes it. */
864
+ /**
865
+ * Add or change a tool while the app runs: one more entry after the `tools`
866
+ * setting's. Returns a function that takes it back: a tool it added goes
867
+ * away, a tool it changed goes back to what it was.
868
+ */
825
869
  register(tool: AnnotationToolInput): Unsubscribe;
826
870
  /** The fields a tool's next annotation starts with: its defaults over the engine's. The same object until they change. */
827
871
  getDefaults(id: string): ToolDefaults;
@@ -990,9 +1034,9 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
990
1034
  * beside them (a stamp's `appearance`, a file attachment's `file`). It
991
1035
  * shows at once; resolves `{ annotation }` with the engine's record.
992
1036
  * `select` selects it, as drawing it would; without it, code never changes
993
- * the selection. A read of another annotation makes the same one again (a
994
- * copy): its own fields are written, and where it is comes from `page`.
995
- * Rejects `permission-denied` without `annotations:create`, `not-found` for
1037
+ * the selection. A read of another annotation is written as it is, its
1038
+ * name included, and where it is comes from `page`; `duplicate()` makes a
1039
+ * copy. Rejects `permission-denied` without `annotations:create`, `not-found` for
996
1040
  * a page that isn't in the document or an unknown `tool`, `invalid-input`
997
1041
  * for a kind the engine doesn't know or a value a write can't make (another
998
1042
  * app's beveled border).
@@ -1038,6 +1082,18 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
1038
1082
  * there. Widgets paint above every annotation and are ordered by the form.
1039
1083
  */
1040
1084
  reorder(refs: readonly AnnotationRef[], position: AnnotationPosition, options?: OperationOptions): Promise<void>;
1085
+ /**
1086
+ * Copy annotations in this document, as one change: the copies show at
1087
+ * once, and it is one step to undo. A copy carries its original's fields,
1088
+ * with its drawing, its file and its link; it has its own ref and name, and
1089
+ * the user is its author. Copies keep the links between them (a copied
1090
+ * group is a group of its own); a reply comes only when it is named.
1091
+ * `select` selects the copies. Resolves `{ annotations, dropped }`. Rejects
1092
+ * `permission-denied` without `annotations:create`, `not-found` for an
1093
+ * annotation or a page that isn't in the document, `invalid-input` for
1094
+ * another plugin's record (a form field's box).
1095
+ */
1096
+ duplicate(refs: readonly AnnotationRef[], options?: AnnotationDuplicateOptions & OperationOptions): Promise<AnnotationDuplicateResult>;
1041
1097
  /**
1042
1098
  * Take annotations out as a bundle, with the bytes they carry (a stamp's
1043
1099
  * drawing, an attached file): every annotation, a selection of them (with
@@ -1047,11 +1103,13 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
1047
1103
  export(selection?: AnnotationExportSelection, options?: OperationOptions): Promise<AnnotationBundle>;
1048
1104
  /**
1049
1105
  * Put a bundle's annotations into this document, as one change: they show
1050
- * once it's done. Resolves `{ annotations, refMap, dropped }`. Rejects
1051
- * `permission-denied` without `annotations:create` (and, for the default
1106
+ * once the engine wrote them, and it is one step to undo. `history: false`
1107
+ * keeps it out of undo and redo, for what your app loads by itself.
1108
+ * Resolves `{ annotations, refMap, dropped }`. Rejects `permission-denied`
1109
+ * without `annotations:create` (and, for the default
1052
1110
  * `attribution: 'restore'`, `doc.annotate.import`).
1053
1111
  */
1054
- import(bundle: AnnotationBundle, options?: AnnotationImportOptions & OperationOptions): Promise<AnnotationImportResult>;
1112
+ import(bundle: AnnotationBundle, options?: AnnotationImportOptions & OperationOptions & HistoryOptions): Promise<AnnotationImportResult>;
1055
1113
  /**
1056
1114
  * Download a stamp's drawing (`'appearance'`) or an attachment's file
1057
1115
  * (`'file'`): the bytes `create()` takes to make it again. Rejects
@@ -1082,12 +1140,26 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
1082
1140
  * popups: the permission for each of them and their `locked` flags.
1083
1141
  */
1084
1142
  canDelete(ref: AnnotationRef): boolean;
1143
+ /**
1144
+ * Whether the user may copy these annotations: the right to create them
1145
+ * (`annotations:create`), and none of them locked, since its copy would be
1146
+ * locked too. `false` for one that can't be copied (a form field's box).
1147
+ * `duplicate()` from code copies a locked one all the same.
1148
+ */
1149
+ canDuplicate(refs: readonly AnnotationRef[]): boolean;
1085
1150
  /**
1086
1151
  * Whether the `editable` setting lets people change this annotation by
1087
1152
  * hand; `false` for one the document doesn't have. Whether a change would
1088
1153
  * succeed is `canUpdate()` and `canDelete()`.
1089
1154
  */
1090
1155
  isEditable(ref: AnnotationRef): boolean;
1156
+ /**
1157
+ * Whether this is an annotation people move: `false` for one that sits on
1158
+ * text (a highlight, a caret, a redaction of words), which stays where its
1159
+ * text is, and for one the document doesn't have. Whether a move would
1160
+ * succeed now is `canUpdate()` and `isEditable()`.
1161
+ */
1162
+ isMovable(ref: AnnotationRef): boolean;
1091
1163
  /** Stop a drag, or a polygon in progress. */
1092
1164
  cancel(): void;
1093
1165
  /** An annotation was added, once the engine saved it. */
@@ -1165,5 +1237,5 @@ interface FilePromptRequest {
1165
1237
  */
1166
1238
  type FilePickerProvider = (request: FilePromptRequest) => Promise<AttachmentFileSource | null>;
1167
1239
  //#endregion
1168
- export { Color as $, AnnotationResources$1 as A, AnnotationState as At, AnnotationTool as B, ResolvedGhost as Bt, AnnotationPatch$1 as C, StampPlacement as Ct, AnnotationRef$1 as D, ThreadDeleteResult as Dt, AnnotationProperty$1 as E, TextItem as Et, AnnotationSelectionChangedEvent as F, AnnotationToolInput as Ft, ArmedStampInfo as G, ToolDefaultsFor as Gt, AnnotationTransfer as H, SelectionAuthoring as Ht, AnnotationSettings as I, DEFAULT_TOOLS as It, AttachmentFileSource$1 as J, TextFormat as Jt, ArmedStampPreview as K, EditorSelection as Kt, AnnotationStampsCapability as L, GhostPolicy as Lt, AnnotationRotationAnchor as M, AnnotationToken as Mt, AnnotationSelectionAnchor as N, ARMED_STAMP_TOOL_ID as Nt, AnnotationReorderedEvent as O, ToolDefaults as Ot, AnnotationSelectionCapability as P, AnnotationToolDefinition as Pt, ClickCreate$1 as Q, AnnotationSubtype$1 as R, InkAuthoringOptions as Rt, AnnotationOption as S, StampInput as St, AnnotationProperties as T, TextAlign as Tt, AnnotationUpdatedEvent as U, StampSourceSpec as Ut, AnnotationToolsCapability as V, ResolvedTool as Vt, AnnotationWriteFailedEvent as W, ToolAuthoringKind as Wt, BlendMode as X, Behavior as Y, TextSelection as Yt, ChromeSettings as Z, AnnotationHoverChangedEvent as _, MarkupSubtype as _t, AnnotationBundle$1 as a, EditableKind as at, AnnotationImportResult as b, ReviewStatus as bt, AnnotationCreatedEvent as c, FilePickerProvider as ct, AnnotationDraftCapability as d, HandleRole as dt, CommentThread$1 as et, AnnotationDraftChangedEvent as f, ImageGhost as ft, AnnotationFlags$1 as g, LinkNavItem as gt, AnnotationFilter as h, LineStyle as ht, AnnotationAnchor as i, CreationDraft as it, AnnotationResyncedEvent as j, annotationState as jt, AnnotationResourceRole$1 as k, ToolDefaultsChangedEvent as kt, AnnotationDeletedEvent as l, FilePromptRequest as lt, AnnotationExportSelection as m, LineEndings as mt, AfterCreateSettings as n, CommentThreadReview as nt, AnnotationCapability as o, EditableKinds$1 as ot, AnnotationEditingChangedEvent as p, LineEnding as pt, AttachmentContent as q, Face as qt, Annotation$1 as r, CommentsCapability as rt, AnnotationConfig as s, FieldValues$1 as st, ANNOTATION_DEFAULTS as t, CommentThreadChangedEvent as tt, AnnotationDraft$1 as u, FlagKey as ut, AnnotationImportDrop$1 as v, MeasurementIntent as vt, AnnotationPosition$1 as w, StampPreviewProvider as wt, AnnotationLinksCapability as x, SnapSettings$1 as xt, AnnotationImportOptions$1 as y, PdfLinkTarget$1 as yt, AnnotationTextCapability as z, PromptSourceSpec as zt };
1169
- //# sourceMappingURL=contract-BK2g1Rem.d.ts.map
1240
+ export { ChromeSettings as $, AnnotationReorderedEvent as A, ToolDefaults as At, AnnotationSubtype$1 as B, InkAuthoringOptions as Bt, AnnotationLinksCapability as C, SnapSettings$1 as Ct, AnnotationProperties as D, TextAlign as Dt, AnnotationPosition$1 as E, StampPreviewProvider as Et, AnnotationSelectionAnchor as F, ARMED_STAMP_TOOL_ID as Ft, AnnotationUpdatedEvent as G, StampSourceSpec as Gt, AnnotationTool as H, ResolvedGhost as Ht, AnnotationSelectionCapability as I, AnnotationToolDefinition as It, ArmedStampPreview as J, EditorSelection as Jt, AnnotationWriteFailedEvent as K, ToolAuthoringKind as Kt, AnnotationSelectionChangedEvent as L, AnnotationToolInput as Lt, AnnotationResources$1 as M, AnnotationState as Mt, AnnotationResyncedEvent as N, annotationState as Nt, AnnotationProperty$1 as O, TextItem as Ot, AnnotationRotationAnchor as P, AnnotationToken as Pt, BlendMode as Q, AnnotationSettings as R, DEFAULT_TOOLS as Rt, AnnotationImportResult as S, ReviewStatus as St, AnnotationPatch$1 as T, StampPlacement as Tt, AnnotationToolsCapability as U, ResolvedTool as Ut, AnnotationTextCapability as V, PromptSourceSpec as Vt, AnnotationTransfer as W, SelectionAuthoring as Wt, AttachmentFileSource$1 as X, TextFormat as Xt, AttachmentContent as Y, Face as Yt, Behavior as Z, TextSelection as Zt, AnnotationFilter as _, LineStyle as _t, AnnotationBundle$1 as a, CommentsCapability as at, AnnotationImportDrop$1 as b, MeasurementIntent as bt, AnnotationCreatedEvent as c, EditableKinds$1 as ct, AnnotationDraftCapability as d, FilePromptRequest as dt, ClickCreate$1 as et, AnnotationDraftChangedEvent as f, FlagKey as ft, AnnotationExportSelection as g, LineEndings as gt, AnnotationEditingChangedEvent as h, LineEnding as ht, AnnotationAnchor as i, CommentThreadReview as it, AnnotationResourceRole$1 as j, ToolDefaultsChangedEvent as jt, AnnotationRef$1 as k, ThreadDeleteResult as kt, AnnotationDeletedEvent as l, FieldValues$1 as lt, AnnotationDuplicateResult as m, ImageGhost as mt, AfterCreateSettings as n, CommentThread$1 as nt, AnnotationCapability as o, CreationDraft as ot, AnnotationDuplicateOptions as p, HandleRole as pt, ArmedStampInfo as q, ToolDefaultsFor as qt, Annotation$1 as r, CommentThreadChangedEvent as rt, AnnotationConfig as s, EditableKind as st, ANNOTATION_DEFAULTS as t, Color as tt, AnnotationDraft$1 as u, FilePickerProvider as ut, AnnotationFlags$1 as v, LinkNavItem as vt, AnnotationOption as w, StampInput as wt, AnnotationImportOptions$1 as x, PdfLinkTarget$1 as xt, AnnotationHoverChangedEvent as y, MarkupSubtype as yt, AnnotationStampsCapability as z, GhostPolicy as zt };
1241
+ //# sourceMappingURL=contract-CQfRsCVj.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { AnnotationFlags, AnnotationFlags as AnnotationFlags$1, AnnotationOption, AnnotationProperty, AnnotationProperty as AnnotationProperty$1, BlendMode, ClickCreate, ClickCreate as ClickCreate$1, CreationDraftAnchor, EditableKind, EditableKinds, EditableKinds as EditableKinds$1, FieldValues, FieldValues as FieldValues$1, FlagKey, HandleRole, InkStraightenOptions, KindName, LineEnding, LineEndings, MeasurementIntent, Rect, RichTextRange, RichTextStyleDelta, RotationAnchor, SnapSettings, SnapSettings as SnapSettings$1, TextAlign, ViewEnv } from "@embedpdf/core-annotation";
2
- import { BatchResult, DeepPartial, EventHook, EventOrigin, OperationOptions, PluginErrorInfo, ResourceStatus, SettingsApi, Unsubscribe } from "@embedpdf/core";
2
+ import { BatchResult, DeepPartial, EventHook, EventOrigin, HistoryOptions, OperationOptions, PluginErrorInfo, ResourceStatus, SettingsApi, Unsubscribe } from "@embedpdf/core";
3
3
  import { Point as Point$1 } from "@embedpdf/core-geometry";
4
4
  import { MountableFontProgram } from "@embedpdf/plugin-fonts/contract";
5
5
  import { Annotation, Annotation as Annotation$1, AnnotationBundle, AnnotationBundle as AnnotationBundle$1, AnnotationDraft, AnnotationDraft as AnnotationDraft$1, AnnotationImportDrop, AnnotationImportDrop as AnnotationImportDrop$1, AnnotationImportOptions, AnnotationImportOptions as AnnotationImportOptions$1, AnnotationPatch, AnnotationPatch as AnnotationPatch$1, AnnotationPosition, AnnotationPosition as AnnotationPosition$1, AnnotationRef, AnnotationRef as AnnotationRef$1, AnnotationResourceRole, AnnotationResourceRole as AnnotationResourceRole$1, AnnotationResources, AnnotationResources as AnnotationResources$1, AnnotationSubtype, AnnotationSubtype as AnnotationSubtype$1, AttachmentContent, AttachmentFileSource, AttachmentFileSource as AttachmentFileSource$1, BinarySource, Color, CommentThread, CommentThread as CommentThread$1, CommentThreadReview, PageRef, PdfActionTree, PdfLinkTarget, PdfLinkTarget as PdfLinkTarget$1, ReviewStatus, RichTextBody, RichTextParagraph, WidgetAppearance } from "@embedpdf/engine-core/runtime";
@@ -155,9 +155,10 @@ type ToolDefaultsFor<K extends ToolAuthoringKind> = ToolDraftOf<K> & (K extends
155
155
  interface AnnotationToolDefinition<K extends ToolAuthoringKind = ToolAuthoringKind> {
156
156
  /** Stable tool id — the value passed to `activateTool` and the `defaults` key. */
157
157
  id: string;
158
- /** Inherit `subtype` / `fieldsKind` / `cursor` / `enables` / `source` /
159
- * `selection` / `intent` / `ink` / `meta`
160
- * from an existing tool id (a built-in or another entry). Own fields win. */
158
+ /** Start from a copy of a tool defined before this entry: a built-in, an
159
+ * earlier entry, or a tool registered while the app runs. The copy takes
160
+ * everything but its `meta`, and own fields win. A later change to that
161
+ * tool doesn't reach this one. */
161
162
  extends?: string;
162
163
  /** The routing kind this tool authors — the core's client kind (the geometry
163
164
  * it draws + the props key). Usually the PDF subtype, but not always:
@@ -235,7 +236,8 @@ interface AnnotationToolDefinition<K extends ToolAuthoringKind = ToolAuthoringKi
235
236
  */
236
237
  afterCreate?: Partial<AfterCreateSettings>;
237
238
  /** Your own data, such as a label and an icon for a toolbar that builds itself
238
- * from the tool table. The plugin keeps it and never reads it. */
239
+ * from the tool table. The plugin keeps it and never reads it, and a tool
240
+ * made with `extends` starts without it. */
239
241
  meta?: Record<string, unknown>;
240
242
  }
241
243
  interface BuiltinToolKindMap {
@@ -450,9 +452,10 @@ interface AfterCreateSettings {
450
452
  */
451
453
  interface AnnotationSettings {
452
454
  /**
453
- * Change the built-in tools or add your own. An entry with a built-in's id
454
- * changes it (`{ id: 'ink', defaults: { strokeWidth: 6 } }`), a new id adds
455
- * a tool, and `extends` starts from another tool.
455
+ * Change the built-in tools or add your own, entry by entry in order. An
456
+ * entry with a tool's id changes only that tool
457
+ * (`{ id: 'ink', defaults: { strokeWidth: 6 } }`), a new id adds a tool, and
458
+ * `extends` starts from a copy of a tool listed before it, without its `meta`.
456
459
  */
457
460
  readonly tools: readonly AnnotationToolInput[];
458
461
  readonly afterCreate: AfterCreateSettings;
@@ -728,6 +731,25 @@ interface AnnotationImportResult {
728
731
  /** What was left out, and why, in bundle order. */
729
732
  readonly dropped: readonly AnnotationImportDrop[];
730
733
  }
734
+ /** How `duplicate()` copies: where the copies go, and whether they are selected. */
735
+ interface AnnotationDuplicateOptions {
736
+ /** The page the copies go on, as a ref or an index. Left out: each on its own page. */
737
+ readonly page?: PageRef | number;
738
+ /** How far each copy moves, in page points: `x` to the right, `y` down. Left out: not at all. */
739
+ readonly offset?: {
740
+ readonly x: number;
741
+ readonly y: number;
742
+ };
743
+ /** Select the copies as they show. */
744
+ readonly select?: boolean;
745
+ }
746
+ /** What `duplicate()` did: the copies, and what was left out. */
747
+ interface AnnotationDuplicateResult {
748
+ /** The copies as the engine wrote them, in the order the originals were named. */
749
+ readonly annotations: readonly Annotation[];
750
+ /** What was left out, and why, in the same order. */
751
+ readonly dropped: readonly AnnotationImportDrop[];
752
+ }
731
753
  /** Which annotations `export()` takes. */
732
754
  interface AnnotationExportSelection {
733
755
  /** These annotations, with what they point at and their replies. */
@@ -781,6 +803,24 @@ interface AnnotationSelectionCapability {
781
803
  canGroup(): boolean;
782
804
  /** Whether the selection holds a group that can be split. */
783
805
  canUngroup(): boolean;
806
+ /**
807
+ * Copy the selected annotations beside the originals and select the
808
+ * copies, as one step to undo. They land 10 points right and down, or left
809
+ * or up where that keeps them on the page; `offset` places them yourself.
810
+ * A selected group is copied as a group of its own. Resolves
811
+ * `{ annotations, dropped }`, as `duplicate()` on the plugin does.
812
+ */
813
+ duplicate(options?: OperationOptions & {
814
+ offset?: {
815
+ readonly x: number;
816
+ readonly y: number;
817
+ };
818
+ }): Promise<AnnotationDuplicateResult>;
819
+ /**
820
+ * Whether the selection can be copied: something is selected, the user may
821
+ * create annotations, and nothing selected is locked.
822
+ */
823
+ canDuplicate(): boolean;
784
824
  /**
785
825
  * Where a menu attaches: the selection's page and the box around it, or
786
826
  * `null` with nothing selected, or while a gesture moves, resizes or turns it.
@@ -821,7 +861,11 @@ interface AnnotationToolsCapability {
821
861
  list(): readonly AnnotationTool[];
822
862
  /** One tool, or `null`. */
823
863
  get(id: string): AnnotationTool | null;
824
- /** Add a tool while the app runs, or replace the one with the same id. Returns a function that removes it. */
864
+ /**
865
+ * Add or change a tool while the app runs: one more entry after the `tools`
866
+ * setting's. Returns a function that takes it back: a tool it added goes
867
+ * away, a tool it changed goes back to what it was.
868
+ */
825
869
  register(tool: AnnotationToolInput): Unsubscribe;
826
870
  /** The fields a tool's next annotation starts with: its defaults over the engine's. The same object until they change. */
827
871
  getDefaults(id: string): ToolDefaults;
@@ -990,9 +1034,9 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
990
1034
  * beside them (a stamp's `appearance`, a file attachment's `file`). It
991
1035
  * shows at once; resolves `{ annotation }` with the engine's record.
992
1036
  * `select` selects it, as drawing it would; without it, code never changes
993
- * the selection. A read of another annotation makes the same one again (a
994
- * copy): its own fields are written, and where it is comes from `page`.
995
- * Rejects `permission-denied` without `annotations:create`, `not-found` for
1037
+ * the selection. A read of another annotation is written as it is, its
1038
+ * name included, and where it is comes from `page`; `duplicate()` makes a
1039
+ * copy. Rejects `permission-denied` without `annotations:create`, `not-found` for
996
1040
  * a page that isn't in the document or an unknown `tool`, `invalid-input`
997
1041
  * for a kind the engine doesn't know or a value a write can't make (another
998
1042
  * app's beveled border).
@@ -1038,6 +1082,18 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
1038
1082
  * there. Widgets paint above every annotation and are ordered by the form.
1039
1083
  */
1040
1084
  reorder(refs: readonly AnnotationRef[], position: AnnotationPosition, options?: OperationOptions): Promise<void>;
1085
+ /**
1086
+ * Copy annotations in this document, as one change: the copies show at
1087
+ * once, and it is one step to undo. A copy carries its original's fields,
1088
+ * with its drawing, its file and its link; it has its own ref and name, and
1089
+ * the user is its author. Copies keep the links between them (a copied
1090
+ * group is a group of its own); a reply comes only when it is named.
1091
+ * `select` selects the copies. Resolves `{ annotations, dropped }`. Rejects
1092
+ * `permission-denied` without `annotations:create`, `not-found` for an
1093
+ * annotation or a page that isn't in the document, `invalid-input` for
1094
+ * another plugin's record (a form field's box).
1095
+ */
1096
+ duplicate(refs: readonly AnnotationRef[], options?: AnnotationDuplicateOptions & OperationOptions): Promise<AnnotationDuplicateResult>;
1041
1097
  /**
1042
1098
  * Take annotations out as a bundle, with the bytes they carry (a stamp's
1043
1099
  * drawing, an attached file): every annotation, a selection of them (with
@@ -1047,11 +1103,13 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
1047
1103
  export(selection?: AnnotationExportSelection, options?: OperationOptions): Promise<AnnotationBundle>;
1048
1104
  /**
1049
1105
  * Put a bundle's annotations into this document, as one change: they show
1050
- * once it's done. Resolves `{ annotations, refMap, dropped }`. Rejects
1051
- * `permission-denied` without `annotations:create` (and, for the default
1106
+ * once the engine wrote them, and it is one step to undo. `history: false`
1107
+ * keeps it out of undo and redo, for what your app loads by itself.
1108
+ * Resolves `{ annotations, refMap, dropped }`. Rejects `permission-denied`
1109
+ * without `annotations:create` (and, for the default
1052
1110
  * `attribution: 'restore'`, `doc.annotate.import`).
1053
1111
  */
1054
- import(bundle: AnnotationBundle, options?: AnnotationImportOptions & OperationOptions): Promise<AnnotationImportResult>;
1112
+ import(bundle: AnnotationBundle, options?: AnnotationImportOptions & OperationOptions & HistoryOptions): Promise<AnnotationImportResult>;
1055
1113
  /**
1056
1114
  * Download a stamp's drawing (`'appearance'`) or an attachment's file
1057
1115
  * (`'file'`): the bytes `create()` takes to make it again. Rejects
@@ -1082,12 +1140,26 @@ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
1082
1140
  * popups: the permission for each of them and their `locked` flags.
1083
1141
  */
1084
1142
  canDelete(ref: AnnotationRef): boolean;
1143
+ /**
1144
+ * Whether the user may copy these annotations: the right to create them
1145
+ * (`annotations:create`), and none of them locked, since its copy would be
1146
+ * locked too. `false` for one that can't be copied (a form field's box).
1147
+ * `duplicate()` from code copies a locked one all the same.
1148
+ */
1149
+ canDuplicate(refs: readonly AnnotationRef[]): boolean;
1085
1150
  /**
1086
1151
  * Whether the `editable` setting lets people change this annotation by
1087
1152
  * hand; `false` for one the document doesn't have. Whether a change would
1088
1153
  * succeed is `canUpdate()` and `canDelete()`.
1089
1154
  */
1090
1155
  isEditable(ref: AnnotationRef): boolean;
1156
+ /**
1157
+ * Whether this is an annotation people move: `false` for one that sits on
1158
+ * text (a highlight, a caret, a redaction of words), which stays where its
1159
+ * text is, and for one the document doesn't have. Whether a move would
1160
+ * succeed now is `canUpdate()` and `isEditable()`.
1161
+ */
1162
+ isMovable(ref: AnnotationRef): boolean;
1091
1163
  /** Stop a drag, or a polygon in progress. */
1092
1164
  cancel(): void;
1093
1165
  /** An annotation was added, once the engine saved it. */
@@ -1165,5 +1237,5 @@ interface FilePromptRequest {
1165
1237
  */
1166
1238
  type FilePickerProvider = (request: FilePromptRequest) => Promise<AttachmentFileSource | null>;
1167
1239
  //#endregion
1168
- export { Color as $, AnnotationResources$1 as A, AnnotationState as At, AnnotationTool as B, ResolvedGhost as Bt, AnnotationPatch$1 as C, StampPlacement as Ct, AnnotationRef$1 as D, ThreadDeleteResult as Dt, AnnotationProperty$1 as E, TextItem as Et, AnnotationSelectionChangedEvent as F, AnnotationToolInput as Ft, ArmedStampInfo as G, ToolDefaultsFor as Gt, AnnotationTransfer as H, SelectionAuthoring as Ht, AnnotationSettings as I, DEFAULT_TOOLS as It, AttachmentFileSource$1 as J, TextFormat as Jt, ArmedStampPreview as K, EditorSelection as Kt, AnnotationStampsCapability as L, GhostPolicy as Lt, AnnotationRotationAnchor as M, AnnotationToken as Mt, AnnotationSelectionAnchor as N, ARMED_STAMP_TOOL_ID as Nt, AnnotationReorderedEvent as O, ToolDefaults as Ot, AnnotationSelectionCapability as P, AnnotationToolDefinition as Pt, ClickCreate$1 as Q, AnnotationSubtype$1 as R, InkAuthoringOptions as Rt, AnnotationOption as S, StampInput as St, AnnotationProperties as T, TextAlign as Tt, AnnotationUpdatedEvent as U, StampSourceSpec as Ut, AnnotationToolsCapability as V, ResolvedTool as Vt, AnnotationWriteFailedEvent as W, ToolAuthoringKind as Wt, BlendMode as X, Behavior as Y, TextSelection as Yt, ChromeSettings as Z, AnnotationHoverChangedEvent as _, MarkupSubtype as _t, AnnotationBundle$1 as a, EditableKind as at, AnnotationImportResult as b, ReviewStatus as bt, AnnotationCreatedEvent as c, FilePickerProvider as ct, AnnotationDraftCapability as d, HandleRole as dt, CommentThread$1 as et, AnnotationDraftChangedEvent as f, ImageGhost as ft, AnnotationFlags$1 as g, LinkNavItem as gt, AnnotationFilter as h, LineStyle as ht, AnnotationAnchor as i, CreationDraft as it, AnnotationResyncedEvent as j, annotationState as jt, AnnotationResourceRole$1 as k, ToolDefaultsChangedEvent as kt, AnnotationDeletedEvent as l, FilePromptRequest as lt, AnnotationExportSelection as m, LineEndings as mt, AfterCreateSettings as n, CommentThreadReview as nt, AnnotationCapability as o, EditableKinds$1 as ot, AnnotationEditingChangedEvent as p, LineEnding as pt, AttachmentContent as q, Face as qt, Annotation$1 as r, CommentsCapability as rt, AnnotationConfig as s, FieldValues$1 as st, ANNOTATION_DEFAULTS as t, CommentThreadChangedEvent as tt, AnnotationDraft$1 as u, FlagKey as ut, AnnotationImportDrop$1 as v, MeasurementIntent as vt, AnnotationPosition$1 as w, StampPreviewProvider as wt, AnnotationLinksCapability as x, SnapSettings$1 as xt, AnnotationImportOptions$1 as y, PdfLinkTarget$1 as yt, AnnotationTextCapability as z, PromptSourceSpec as zt };
1169
- //# sourceMappingURL=contract-CBYEqnev.d.cts.map
1240
+ export { ChromeSettings as $, AnnotationReorderedEvent as A, ToolDefaults as At, AnnotationSubtype$1 as B, InkAuthoringOptions as Bt, AnnotationLinksCapability as C, SnapSettings$1 as Ct, AnnotationProperties as D, TextAlign as Dt, AnnotationPosition$1 as E, StampPreviewProvider as Et, AnnotationSelectionAnchor as F, ARMED_STAMP_TOOL_ID as Ft, AnnotationUpdatedEvent as G, StampSourceSpec as Gt, AnnotationTool as H, ResolvedGhost as Ht, AnnotationSelectionCapability as I, AnnotationToolDefinition as It, ArmedStampPreview as J, EditorSelection as Jt, AnnotationWriteFailedEvent as K, ToolAuthoringKind as Kt, AnnotationSelectionChangedEvent as L, AnnotationToolInput as Lt, AnnotationResources$1 as M, AnnotationState as Mt, AnnotationResyncedEvent as N, annotationState as Nt, AnnotationProperty$1 as O, TextItem as Ot, AnnotationRotationAnchor as P, AnnotationToken as Pt, BlendMode as Q, AnnotationSettings as R, DEFAULT_TOOLS as Rt, AnnotationImportResult as S, ReviewStatus as St, AnnotationPatch$1 as T, StampPlacement as Tt, AnnotationToolsCapability as U, ResolvedTool as Ut, AnnotationTextCapability as V, PromptSourceSpec as Vt, AnnotationTransfer as W, SelectionAuthoring as Wt, AttachmentFileSource$1 as X, TextFormat as Xt, AttachmentContent as Y, Face as Yt, Behavior as Z, TextSelection as Zt, AnnotationFilter as _, LineStyle as _t, AnnotationBundle$1 as a, CommentsCapability as at, AnnotationImportDrop$1 as b, MeasurementIntent as bt, AnnotationCreatedEvent as c, EditableKinds$1 as ct, AnnotationDraftCapability as d, FilePromptRequest as dt, ClickCreate$1 as et, AnnotationDraftChangedEvent as f, FlagKey as ft, AnnotationExportSelection as g, LineEndings as gt, AnnotationEditingChangedEvent as h, LineEnding as ht, AnnotationAnchor as i, CommentThreadReview as it, AnnotationResourceRole$1 as j, ToolDefaultsChangedEvent as jt, AnnotationRef$1 as k, ThreadDeleteResult as kt, AnnotationDeletedEvent as l, FieldValues$1 as lt, AnnotationDuplicateResult as m, ImageGhost as mt, AfterCreateSettings as n, CommentThread$1 as nt, AnnotationCapability as o, CreationDraft as ot, AnnotationDuplicateOptions as p, HandleRole as pt, ArmedStampInfo as q, ToolDefaultsFor as qt, Annotation$1 as r, CommentThreadChangedEvent as rt, AnnotationConfig as s, EditableKind as st, ANNOTATION_DEFAULTS as t, Color as tt, AnnotationDraft$1 as u, FilePickerProvider as ut, AnnotationFlags$1 as v, LinkNavItem as vt, AnnotationOption as w, StampInput as wt, AnnotationImportOptions$1 as x, PdfLinkTarget$1 as xt, AnnotationHoverChangedEvent as y, MarkupSubtype as yt, AnnotationStampsCapability as z, GhostPolicy as zt };
1241
+ //# sourceMappingURL=contract-DkxvCGXL.d.cts.map
@@ -13,6 +13,7 @@ const AnnotationToken = (0, _embedpdf_core.createCapabilityToken)("annotation",
13
13
  update: true,
14
14
  delete: true,
15
15
  reorder: true,
16
+ duplicate: true,
16
17
  export: true,
17
18
  import: true,
18
19
  downloadResource: true,
@@ -25,6 +26,7 @@ const AnnotationToken = (0, _embedpdf_core.createCapabilityToken)("annotation",
25
26
  "selection.resetRotation": true,
26
27
  "selection.group": true,
27
28
  "selection.ungroup": true,
29
+ "selection.duplicate": true,
28
30
  "draft.finish": true,
29
31
  "text.end": true,
30
32
  "text.toggleFormat": true,
@@ -484,28 +486,52 @@ function mergeDefaults(left, right) {
484
486
  ...right
485
487
  } : right ?? left;
486
488
  }
487
- /** Overlay a same-id override onto a base definition (configure a built-in). */
488
- function mergeDef(base, over) {
489
+ /**
490
+ * A tool from `definition`, starting from `base` when it has one: the base's
491
+ * kind, behavior and defaults, with the definition's own fields over them. The
492
+ * base's `meta` stays behind, since it says which button the base is.
493
+ */
494
+ function toolFrom(definition, base) {
495
+ const subtype = definition.subtype ?? base?.subtype ?? definition.id;
489
496
  return {
490
- ...base,
491
- ...over,
492
- enables: over.enables ?? base.enables,
493
- meta: base.meta || over.meta ? {
494
- ...base.meta,
495
- ...over.meta
497
+ id: definition.id,
498
+ subtype,
499
+ preset: definition.preset ?? definition.id,
500
+ fieldsKind: definition.fieldsKind ?? base?.fieldsKind ?? subtype,
501
+ cursor: definition.cursor ?? base?.cursor ?? "crosshair",
502
+ enables: new Set(definition.enables ?? (base ? [...base.enables] : [])),
503
+ defaults: mergeDefaults(base?.defaults, definition.defaults),
504
+ flags: base?.flags || definition.flags ? {
505
+ ...base?.flags,
506
+ ...definition.flags
496
507
  } : void 0,
497
- defaults: mergeDefaults(base.defaults, over.defaults),
498
- flags: base.flags || over.flags ? {
499
- ...base.flags,
500
- ...over.flags
508
+ source: definition.source ?? base?.source,
509
+ selection: definition.selection ?? base?.selection,
510
+ ink: base?.ink || definition.ink ? {
511
+ ...base?.ink,
512
+ ...definition.ink
501
513
  } : void 0,
502
- ink: base.ink || over.ink ? {
503
- ...base.ink,
504
- ...over.ink
514
+ upright: definition.upright ?? base?.upright ?? false,
515
+ clickCreate: definition.clickCreate ?? base?.clickCreate ?? false,
516
+ ghost: resolveGhost(definition.ghost ?? base?.ghost ?? false),
517
+ afterCreate: base?.afterCreate || definition.afterCreate ? {
518
+ ...base?.afterCreate,
519
+ ...definition.afterCreate
505
520
  } : void 0,
506
- afterCreate: base.afterCreate || over.afterCreate ? {
507
- ...base.afterCreate,
508
- ...over.afterCreate
521
+ capture: CAPTURE_TOOLS.has(definition.id) || (base?.capture ?? false),
522
+ meta: definition.meta
523
+ };
524
+ }
525
+ /** `tool` with a change for its id merged over it: the same tool, `meta` included. */
526
+ function changeTool(tool, change) {
527
+ return {
528
+ ...toolFrom({
529
+ ...change,
530
+ preset: change.preset ?? tool.preset
531
+ }, tool),
532
+ meta: tool.meta || change.meta ? {
533
+ ...tool.meta,
534
+ ...change.meta
509
535
  } : void 0
510
536
  };
511
537
  }
@@ -517,68 +543,35 @@ function validateDefaults(tool) {
517
543
  for (const key of Object.keys(tool.defaults)) if (!keys.has(key)) throw new Error(`[annotation] tool '${tool.id}' does not support default '${key}' for '${tool.subtype}'`);
518
544
  }
519
545
  /**
520
- * Resolve {@link DEFAULT_TOOLS} + embedder overrides into the ready-to-use table.
521
- * A same-id override merges over the built-in; a new id adds a tool; `extends`
522
- * inherits from an already-defined tool. Keyed by id, so lookups are O(1).
546
+ * Apply one tool entry to `tools` and return the tool it leaves under its id.
547
+ * An entry with `extends` makes a tool from a copy of that tool as it is now,
548
+ * in place of any tool with its id; an entry whose id is taken changes that
549
+ * tool; any other entry adds one. A copy is a copy: a later change to the tool
550
+ * it came from doesn't reach it.
523
551
  */
524
- function buildToolRegistry(overrides = []) {
525
- const defs = /* @__PURE__ */ new Map();
526
- for (const definition of DEFAULT_TOOLS) defs.set(definition.id, definition);
527
- for (const override of overrides) {
528
- const previous = defs.get(override.id);
529
- defs.set(override.id, previous ? mergeDef(previous, override) : override);
552
+ function applyTool(tools, entry) {
553
+ let tool;
554
+ if (entry.extends) {
555
+ const base = tools.get(entry.extends);
556
+ if (!base) throw new Error(`[annotation] tool '${entry.id}' extends '${entry.extends}', which isn't defined before it`);
557
+ tool = toolFrom(entry, base);
558
+ } else {
559
+ const current = tools.get(entry.id);
560
+ tool = current ? changeTool(current, entry) : toolFrom(entry);
530
561
  }
531
- const out = /* @__PURE__ */ new Map();
532
- const resolving = /* @__PURE__ */ new Set();
533
- const resolve = (id) => {
534
- const cached = out.get(id);
535
- if (cached) return cached;
536
- const definition = defs.get(id);
537
- if (!definition) throw new Error(`[annotation] tool '${id}' extends an unknown tool`);
538
- let base;
539
- if (definition.extends && definition.extends !== id && !resolving.has(definition.extends)) {
540
- resolving.add(id);
541
- base = resolve(definition.extends);
542
- resolving.delete(id);
543
- }
544
- const subtype = definition.subtype ?? base?.subtype ?? definition.id;
545
- const resolved = {
546
- id: definition.id,
547
- subtype,
548
- preset: definition.preset ?? definition.id,
549
- fieldsKind: definition.fieldsKind ?? base?.fieldsKind ?? subtype,
550
- cursor: definition.cursor ?? base?.cursor ?? "crosshair",
551
- enables: new Set(definition.enables ?? (base ? [...base.enables] : [])),
552
- defaults: mergeDefaults(base?.defaults, definition.defaults),
553
- flags: base?.flags || definition.flags ? {
554
- ...base?.flags,
555
- ...definition.flags
556
- } : void 0,
557
- source: definition.source ?? base?.source,
558
- selection: definition.selection ?? base?.selection,
559
- ink: base?.ink || definition.ink ? {
560
- ...base?.ink,
561
- ...definition.ink
562
- } : void 0,
563
- upright: definition.upright ?? base?.upright ?? false,
564
- clickCreate: definition.clickCreate ?? base?.clickCreate ?? false,
565
- ghost: resolveGhost(definition.ghost ?? base?.ghost ?? false),
566
- afterCreate: base?.afterCreate || definition.afterCreate ? {
567
- ...base?.afterCreate,
568
- ...definition.afterCreate
569
- } : void 0,
570
- capture: CAPTURE_TOOLS.has(definition.id) || (base?.capture ?? false),
571
- meta: base?.meta || definition.meta ? {
572
- ...base?.meta,
573
- ...definition.meta
574
- } : void 0
575
- };
576
- validateDefaults(resolved);
577
- out.set(id, resolved);
578
- return resolved;
579
- };
580
- for (const id of defs.keys()) resolve(id);
581
- return out;
562
+ validateDefaults(tool);
563
+ tools.set(tool.id, tool);
564
+ return tool;
565
+ }
566
+ /**
567
+ * The tool table: {@link DEFAULT_TOOLS}, then `entries`, each applied in order
568
+ * by {@link applyTool}. So a change to a built-in reaches only that built-in, and
569
+ * an entry's `extends` sees the tool as the entries before it left it.
570
+ */
571
+ function buildToolRegistry(entries = []) {
572
+ const tools = /* @__PURE__ */ new Map();
573
+ for (const entry of [...DEFAULT_TOOLS, ...entries]) applyTool(tools, entry);
574
+ return tools;
582
575
  }
583
576
  //#endregion
584
577
  //#region src/contract.ts
@@ -676,6 +669,12 @@ Object.defineProperty(exports, "annotationState", {
676
669
  return annotationState;
677
670
  }
678
671
  });
672
+ Object.defineProperty(exports, "applyTool", {
673
+ enumerable: true,
674
+ get: function() {
675
+ return applyTool;
676
+ }
677
+ });
679
678
  Object.defineProperty(exports, "buildToolRegistry", {
680
679
  enumerable: true,
681
680
  get: function() {
@@ -689,4 +688,4 @@ Object.defineProperty(exports, "toolTouchOf", {
689
688
  }
690
689
  });
691
690
 
692
- //# sourceMappingURL=contract-BtAl3Yo2.cjs.map
691
+ //# sourceMappingURL=contract-X3gZNpwu.cjs.map