@embedpdf/plugin-stamp 3.0.0-next.14 → 3.0.0-next.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,431 @@
1
+ import { BatchResult, DeepPartial, EventHook, OperationOptions, SettingsApi } from "@embedpdf/core";
2
+ import { Annotation, AnnotationRef, BinarySource, LocalEngine, PageRef } from "@embedpdf/engine-core/runtime";
3
+ import { StampPlacement, StampPlacement as StampPlacement$1 } from "@embedpdf/plugin-annotation/contract";
4
+ //#region src/token.d.ts
5
+ declare const StampToken: import("@embedpdf/core").CapabilityToken<StampCapability>;
6
+ //#endregion
7
+ //#region src/convention.d.ts
8
+ /** The library kind every file has unless it says otherwise. */
9
+ declare const DEFAULT_LIBRARY_KIND = "stamps";
10
+ //#endregion
11
+ //#region src/persistence.d.ts
12
+ /** The persistence port: bytes by library id. */
13
+ interface StampLibraryStore {
14
+ list(): Promise<Array<{
15
+ id: string;
16
+ bytes: Uint8Array;
17
+ }>>;
18
+ put(id: string, bytes: Uint8Array): Promise<void>;
19
+ delete(id: string): Promise<void>;
20
+ }
21
+ /** An in-memory store, for tests and SSR. */
22
+ declare function memoryStampStore(): StampLibraryStore;
23
+ /**
24
+ * Bring every stored library back: each PDF is imported as-is (its title,
25
+ * registry, and PieceInfo id come from the file; the store's key is only a
26
+ * hint). Call once at boot, before seeding defaults, so "already has
27
+ * libraries" means the user's own.
28
+ */
29
+ declare function restoreStampLibraries(stamp: Pick<StampCapability, 'importLibrary'>, store: StampLibraryStore): Promise<string[]>;
30
+ /**
31
+ * Keep the store in sync from now on: every canonical change saves the
32
+ * library's PDF, a removal deletes it. `except` names libraries never to
33
+ * persist (the bundled default set, typically). Returns the unsubscribe;
34
+ * work already asked for still finishes.
35
+ *
36
+ * Each library has one line of store work, so saves never overlap and a
37
+ * delete never lands under a late save. The changes of one burst (one call
38
+ * into the plugin) are one save; the changes made while a save runs are one
39
+ * more after it.
40
+ */
41
+ declare function persistStampLibraries(stamp: Pick<StampCapability, 'exportLibrary' | 'onLibraryChanged'>, store: StampLibraryStore, options?: {
42
+ except?: readonly string[];
43
+ }): () => void;
44
+ //#endregion
45
+ //#region src/contract.d.ts
46
+ /**
47
+ * The stamp plugin: a workspace-scoped asset substrate.
48
+ *
49
+ * The design law ("documents have a home; assets ride the wire"): imported
50
+ * PDF libraries retain one canonical PDF whose catalog/page `/PieceInfo`
51
+ * carries their metadata. Per-asset PDFs and previews are derived caches used
52
+ * for placement. Standalone PNG/JPEG assets remain loose because the engine
53
+ * intentionally has no raster-to-PDF-page authoring primitive.
54
+ */
55
+ type StampAssetKind = 'stamp' | 'signature' | 'initials';
56
+ /**
57
+ * What a library file is for: the routing key a surface queries by. Open:
58
+ * the plugin defines `stamps` (the default) and `signatures`; an embedder
59
+ * may define its own (`toolbar`, `legal-seals`). Persisted in the file.
60
+ */
61
+ type StampLibraryKind = string;
62
+ /**
63
+ * How a mark is authored: drawn strokes (kept as a vector path), typed text
64
+ * in a registered font (embedded by the flatten), a raster image, or a page
65
+ * of a PDF. Ink strokes are in points, from the top-left and y down like
66
+ * every page position, any origin — the asset page is the mark's bounds.
67
+ */
68
+ type MarkSource = {
69
+ kind: 'ink';
70
+ strokes: ReadonlyArray<ReadonlyArray<{
71
+ x: number;
72
+ y: number;
73
+ }>>;
74
+ color?: string;
75
+ strokeWidth?: number;
76
+ } | {
77
+ kind: 'text';
78
+ text: string;
79
+ fontFamily: string;
80
+ color?: string;
81
+ fontSize?: number;
82
+ } | {
83
+ kind: 'image';
84
+ source: BinarySource;
85
+ } | {
86
+ kind: 'pdf';
87
+ source: BinarySource;
88
+ pageIndex?: number;
89
+ };
90
+ /**
91
+ * One asset's serializable descriptor. The bytes and the cached preview are
92
+ * deliberately not here: session state holds serializable data only, and
93
+ * binary lives in the capability and crosses only as call arguments and
94
+ * return values, mirroring the engine's own BinarySource rule.
95
+ */
96
+ interface StampAsset {
97
+ /** Derived and stable: `${libraryId}:${name}` (never allocated). */
98
+ id: string;
99
+ libraryId: string;
100
+ kind: StampAssetKind;
101
+ /**
102
+ * The stamp's identifier: the text before the first `=` in its library
103
+ * key, and the placed annotation's `/Name`: a standard name (`Approved`)
104
+ * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.
105
+ */
106
+ name: string;
107
+ /** What the picker shows and the placed annotation's default `/Subj`:
108
+ * the text after `=` in the library key (`Goedgekeurd`). */
109
+ label: string;
110
+ /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */
111
+ size: {
112
+ width: number;
113
+ height: number;
114
+ };
115
+ /** The library page that is this asset. Every asset is a page: a raster
116
+ * added to a library becomes a page carrying the image. */
117
+ page: PageRef;
118
+ /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */
119
+ subject?: string;
120
+ categories?: string[];
121
+ }
122
+ /**
123
+ * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry
124
+ * the assets, its pages the artwork, PieceInfo only what has no standard
125
+ * home. One imported PDF becomes one library; `exportLibrary` returns it.
126
+ */
127
+ interface StampLibrary {
128
+ /** PieceInfo `Id`: stable while the title is editable. */
129
+ id: string;
130
+ name: string;
131
+ /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */
132
+ kind: StampLibraryKind;
133
+ /** PieceInfo `Locale`: the language of the labels, when the library says. */
134
+ locale?: string;
135
+ categories?: string[];
136
+ /** Asset ids in display order. */
137
+ assetIds: string[];
138
+ }
139
+ /**
140
+ * The local engine stamp libraries open in, or a function that makes one. A
141
+ * function is called on the first import, not at startup, and its engine is
142
+ * destroyed with the plugin.
143
+ */
144
+ type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise<LocalEngine>);
145
+ /**
146
+ * The stamp plugin's settings. `stampPlugin(config)` registers them over
147
+ * {@link STAMP_DEFAULTS}, and `updateSettings()` changes them while the app
148
+ * runs.
149
+ */
150
+ interface StampSettings {
151
+ /**
152
+ * The engine stamp libraries open in. `null` uses the viewer's own engine,
153
+ * which is right when that engine is local. A cloud viewer passes a local
154
+ * engine, or a function that makes one:
155
+ *
156
+ * ```ts
157
+ * stampPlugin({
158
+ * assetEngine: () => import('@embedpdf/engine').then((module) => module.createLocalEngine()),
159
+ * })
160
+ * ```
161
+ */
162
+ readonly assetEngine: StampAssetEngine | null;
163
+ /** The width of a stamp's thumbnail, in device pixels. */
164
+ readonly previewWidth: number;
165
+ /**
166
+ * Fill in a dynamic stamp's form fields when it's armed or placed.
167
+ * Scripting itself is the workspace's one JavaScript switch,
168
+ * `actionsPlugin({ javascript: { enabled } })`: without the actions plugin,
169
+ * or with scripting off, a stamp is placed as it is. `false` keeps every
170
+ * stamp as reviewed, even with scripting on.
171
+ */
172
+ readonly dynamic: boolean;
173
+ }
174
+ /** What the stamp settings are when the app registers none. */
175
+ declare const STAMP_DEFAULTS: StampSettings;
176
+ /** What `stampPlugin(config)` takes: any of the settings, merged over the defaults. */
177
+ type StampConfig = DeepPartial<StampSettings>;
178
+ /**
179
+ * Which document a placing verb acts on. Left out, it is the document in
180
+ * scope (`useStamp()` inside a `<DocumentScope>`, a document plugin's
181
+ * `ctx.get(StampToken)`), else the active document.
182
+ */
183
+ interface StampDocumentOptions extends OperationOptions {
184
+ readonly documentId?: string;
185
+ }
186
+ /** `armAsset()`'s options. */
187
+ interface StampArmOptions extends StampDocumentOptions {
188
+ /** Placed width in PDF points; the stamp's own width by default. */
189
+ readonly targetWidth?: number;
190
+ }
191
+ interface CreateLibraryOptions extends OperationOptions {
192
+ /** The library's id; a fresh one when left out or taken. */
193
+ readonly id?: string;
194
+ /** What the library is for. Default `'stamps'`. */
195
+ readonly kind?: StampLibraryKind;
196
+ readonly categories?: string[];
197
+ }
198
+ interface StampLibraryPatch {
199
+ readonly name?: string;
200
+ readonly categories?: string[];
201
+ }
202
+ interface ImportLibraryOptions extends OperationOptions {
203
+ /**
204
+ * Fallback library name, applied only when the PDF carries no `/Title`
205
+ * (an Acrobat-authored or previously exported library names itself).
206
+ * Default `'Stamps'`.
207
+ */
208
+ name?: string;
209
+ /** Library categories written to catalog `/PieceInfo`. */
210
+ categories?: string[];
211
+ /** Kind stamped onto every imported asset. Default `'stamp'`. */
212
+ kind?: StampAssetKind;
213
+ /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */
214
+ libraryKind?: StampLibraryKind;
215
+ /**
216
+ * Fallback per-page labels for a plain PDF (no `/Names /Pages` registry):
217
+ * every page becomes a stamp named `Stamp<n>` with this label. Ignored
218
+ * when the PDF registers its stamps itself.
219
+ */
220
+ assetName?: (pageIndex: number) => string;
221
+ }
222
+ interface AddAssetInput {
223
+ /** Target library; omitted, a new single-asset library named after the asset. */
224
+ libraryId?: string;
225
+ /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */
226
+ name?: string;
227
+ /** Picker text and default `/Subj`. Defaults to `name`. */
228
+ label?: string;
229
+ kind?: StampAssetKind;
230
+ subject?: string;
231
+ categories?: string[];
232
+ /**
233
+ * PNG, JPEG, or single-page PDF bytes. Exactly one of `source` / `mark`. A
234
+ * raster becomes a page of the library sized to `size` (default: its
235
+ * pixels as points, 1:1) with the image flattened into it, so every asset
236
+ * is a page and every library a complete PDF.
237
+ */
238
+ source?: BinarySource;
239
+ /** An authored mark: drawn, typed, an image, or a PDF page. Exactly one of `source` / `mark`. */
240
+ mark?: MarkSource;
241
+ /** Thumbnail override for pickers (PNG/JPEG); rendered from the page otherwise. */
242
+ preview?: BinarySource;
243
+ /** Page size in PDF points for a raster source. Ignored for PDF sources (the page has one). */
244
+ size?: {
245
+ width: number;
246
+ height: number;
247
+ };
248
+ }
249
+ /** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */
250
+ type AssetFromAnnotationsInput = Omit<AddAssetInput, 'source' | 'mark' | 'size'>;
251
+ interface StampAssetPatch {
252
+ readonly label?: string;
253
+ /** `null` drops the subject override, so placements use the label. */
254
+ readonly subject?: string | null;
255
+ readonly categories?: string[];
256
+ }
257
+ /** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */
258
+ interface StampAssetPreview {
259
+ bytes: Uint8Array;
260
+ mimeType: string;
261
+ }
262
+ interface StampLibraryFilter {
263
+ readonly kind?: StampLibraryKind | readonly StampLibraryKind[];
264
+ }
265
+ interface StampAssetFilter {
266
+ readonly libraryId?: string;
267
+ readonly kind?: StampAssetKind;
268
+ readonly category?: string;
269
+ }
270
+ /** A library's bytes changed, and why: the one to save it on. */
271
+ interface StampLibraryChangedEvent {
272
+ readonly libraryId: string;
273
+ readonly reason: 'created' | 'imported' | 'updated' | 'asset-added' | 'asset-updated' | 'asset-removed' | 'removed';
274
+ }
275
+ interface StampLibraryCreatedEvent {
276
+ readonly libraryId: string;
277
+ readonly library: StampLibrary;
278
+ }
279
+ interface StampLibraryUpdatedEvent {
280
+ readonly libraryId: string;
281
+ readonly library: StampLibrary;
282
+ }
283
+ interface StampLibraryDeletedEvent {
284
+ readonly libraryId: string;
285
+ readonly library: null;
286
+ }
287
+ interface StampAssetCreatedEvent {
288
+ readonly assetId: string;
289
+ readonly libraryId: string;
290
+ readonly asset: StampAsset;
291
+ }
292
+ interface StampAssetUpdatedEvent {
293
+ readonly assetId: string;
294
+ readonly libraryId: string;
295
+ readonly asset: StampAsset;
296
+ }
297
+ interface StampAssetDeletedEvent {
298
+ readonly assetId: string;
299
+ readonly libraryId: string;
300
+ readonly asset: null;
301
+ }
302
+ /** A stamp was armed on a document, or disarmed (`asset: null`). */
303
+ interface StampArmChangedEvent {
304
+ readonly documentId: string;
305
+ readonly asset: StampAsset | null;
306
+ }
307
+ /**
308
+ * Stamp libraries and their assets, shared by every document, and placing
309
+ * them on a document. The placing verbs act on the document in scope, else
310
+ * the active one, or the one their options name (`documentId`). A library is
311
+ * a PDF (one page per asset): `exportLibrary` returns the persistence format,
312
+ * `importLibrary` reads it back. Every verb rejects with a `PluginError`, and
313
+ * every async verb takes a `signal`: cancelled, it rejects
314
+ * `operation-cancelled` and changes nothing. The settings belong to the
315
+ * plugin, not to a document.
316
+ */
317
+ interface StampCapability extends SettingsApi<StampSettings> {
318
+ listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[];
319
+ getLibrary(libraryId: string): StampLibrary | null;
320
+ /** Assets in the order a picker shows them: by library, then within it. */
321
+ listAssets(filter?: StampAssetFilter): readonly StampAsset[];
322
+ getAsset(assetId: string): StampAsset | null;
323
+ /** The cached thumbnail (the `previewWidth` setting), or null. */
324
+ getAssetPreview(assetId: string): StampAssetPreview | null;
325
+ /** A preview at any width, rendered by the asset engine and cached per width. Rejects `not-found`. */
326
+ renderAssetPreview(assetId: string, options: {
327
+ width: number;
328
+ } & OperationOptions): Promise<StampAssetPreview | null>;
329
+ /** A copy of the asset's placement bytes (a one-page PDF), or null. */
330
+ readAssetBytes(assetId: string): Uint8Array | null;
331
+ /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */
332
+ createLibrary(name: string, options?: CreateLibraryOptions): Promise<{
333
+ library: StampLibrary;
334
+ }>;
335
+ /** Rename a library or change its categories. Rejects `not-found`. Fires `onLibraryUpdated`. */
336
+ updateLibrary(libraryId: string, changes: StampLibraryPatch, options?: OperationOptions): Promise<{
337
+ library: StampLibrary;
338
+ }>;
339
+ /** Delete a library with its assets. Fires `onLibraryDeleted`. */
340
+ deleteLibrary(libraryId: string, options?: OperationOptions): Promise<void>;
341
+ /**
342
+ * A PDF becomes a library (one asset per page). Rejects `invalid-input` for
343
+ * bytes that aren't a PDF, `unsupported` without a local asset engine.
344
+ * Fires `onLibraryCreated`, then `onAssetCreated` per stamp.
345
+ */
346
+ importLibrary(source: BinarySource, options?: ImportLibraryOptions): Promise<{
347
+ library: StampLibrary;
348
+ }>;
349
+ /** The library as the PDF it is. Rejects `not-found`. */
350
+ exportLibrary(libraryId: string, options?: OperationOptions): Promise<Uint8Array>;
351
+ /**
352
+ * Add a stamp from bytes or a mark. Rejects `not-found` for an unknown
353
+ * library, `invalid-input` for bytes that aren't a picture or a taken
354
+ * identifier. Fires `onAssetCreated`.
355
+ */
356
+ createAsset(input: AddAssetInput, options?: OperationOptions): Promise<{
357
+ asset: StampAsset;
358
+ }>;
359
+ /**
360
+ * Annotations on a page of a document become one stamp, exactly as they
361
+ * look. All or nothing: a hidden annotation, one without an appearance, or
362
+ * one on another page fails the call. Rejects `permission-denied` without
363
+ * `doc.download` (see `canCreateFromAnnotations`), `not-found` for a page
364
+ * that isn't in the document.
365
+ */
366
+ createAssetFromAnnotations(page: PageRef | number, refs: readonly AnnotationRef[], input: AssetFromAnnotationsInput, options?: StampDocumentOptions): Promise<{
367
+ asset: StampAsset;
368
+ }>;
369
+ /** Change a stamp's label, subject or categories; its identifier never changes. Rejects `not-found`. */
370
+ updateAsset(assetId: string, changes: StampAssetPatch, options?: OperationOptions): Promise<{
371
+ asset: StampAsset;
372
+ }>;
373
+ /** Remove a stamp from its library. Fires `onAssetDeleted`. */
374
+ deleteAsset(assetId: string, options?: OperationOptions): Promise<void>;
375
+ /** Move a stamp to another library: a copy there, with a new id, then the original goes. */
376
+ moveAsset(assetId: string, to: {
377
+ libraryId: string;
378
+ }, options?: OperationOptions): Promise<{
379
+ asset: StampAsset;
380
+ }>;
381
+ /** Copy a stamp within its library. */
382
+ duplicateAsset(assetId: string, options?: {
383
+ label?: string;
384
+ } & OperationOptions): Promise<{
385
+ asset: StampAsset;
386
+ }>;
387
+ /**
388
+ * Arm a stamp: the next click on the document places it, with a preview
389
+ * under the pointer. Rejects `not-found` for an unknown asset,
390
+ * `permission-denied` without `annotations:create` (see `canPlace`).
391
+ * Fires `onArmChanged`.
392
+ */
393
+ armAsset(assetId: string, options?: StampArmOptions): Promise<void>;
394
+ /** Disarm the stamp without placing it. Fires `onArmChanged` when one was armed. */
395
+ disarm(documentId?: string): void;
396
+ /** The stamp the next click on the document places, or null. */
397
+ getArmedAsset(documentId?: string): StampAsset | null;
398
+ /**
399
+ * Place a stamp without the pointer, its middle on `center`, sized by its
400
+ * picture and kept on the page. Resolves `{ annotation }`. Selected only
401
+ * with `select: true`. Rejects `permission-denied` without
402
+ * `annotations:create`, `not-found` for an unknown asset or page.
403
+ */
404
+ placeAsset(assetId: string, placement: StampPlacement, options?: StampDocumentOptions): Promise<{
405
+ annotation: Annotation;
406
+ }>;
407
+ /**
408
+ * Place one stamp at the same spot on several pages (refs or indexes), or
409
+ * on `'all'`. Resolves the placed stamps, and the pages that failed.
410
+ */
411
+ placeAssetOnPages(assetId: string, pages: readonly (PageRef | number)[] | 'all', placement: Omit<StampPlacement, 'page'>, options?: StampDocumentOptions): Promise<BatchResult<Annotation, PageRef>>;
412
+ /** Whether a stamp may be armed or placed on the document (`annotations:create`). */
413
+ canPlace(documentId?: string): boolean;
414
+ /** Whether annotations of the document may become a stamp, which copies them out (`doc.download`). */
415
+ canCreateFromAnnotations(documentId?: string): boolean;
416
+ /** Whether libraries can be imported: false once an import found no local engine to open them in. */
417
+ canImport(): boolean;
418
+ readonly onLibraryCreated: EventHook<StampLibraryCreatedEvent>;
419
+ readonly onLibraryUpdated: EventHook<StampLibraryUpdatedEvent>;
420
+ readonly onLibraryDeleted: EventHook<StampLibraryDeletedEvent>;
421
+ readonly onAssetCreated: EventHook<StampAssetCreatedEvent>;
422
+ readonly onAssetUpdated: EventHook<StampAssetUpdatedEvent>;
423
+ readonly onAssetDeleted: EventHook<StampAssetDeletedEvent>;
424
+ /** A stamp was armed or disarmed on a document. */
425
+ readonly onArmChanged: EventHook<StampArmChangedEvent>;
426
+ /** A library's bytes changed (subscribe to persist). */
427
+ readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;
428
+ }
429
+ //#endregion
430
+ export { StampSettings as A, StampLibraryCreatedEvent as C, StampLibraryPatch as D, StampLibraryKind as E, DEFAULT_LIBRARY_KIND as F, StampToken as I, memoryStampStore as M, persistStampLibraries as N, StampLibraryUpdatedEvent as O, restoreStampLibraries as P, StampLibraryChangedEvent as S, StampLibraryFilter as T, StampAssetUpdatedEvent as _, MarkSource as a, StampDocumentOptions as b, StampArmOptions as c, StampAssetDeletedEvent as d, StampAssetEngine as f, StampAssetPreview as g, StampAssetPatch as h, ImportLibraryOptions as i, StampLibraryStore as j, StampPlacement$1 as k, StampAsset as l, StampAssetKind as m, AssetFromAnnotationsInput as n, STAMP_DEFAULTS as o, StampAssetFilter as p, CreateLibraryOptions as r, StampArmChangedEvent as s, AddAssetInput as t, StampAssetCreatedEvent as u, StampCapability as v, StampLibraryDeletedEvent as w, StampLibrary as x, StampConfig as y };
431
+ //# sourceMappingURL=contract-CEeBOug9.d.cts.map
@@ -1,4 +1,8 @@
1
1
  import { createCapabilityToken } from "@embedpdf/core";
2
+ //#region src/token.ts
3
+ /** The package token, created once here and re-exported by `contract.ts`. */
4
+ const StampToken = createCapabilityToken("stamp", { hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list` });
5
+ //#endregion
2
6
  //#region src/convention.ts
3
7
  function parseStampKey(key) {
4
8
  const separator = key.indexOf("=");
@@ -21,9 +25,9 @@ const BASE62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
21
25
  * identity when the library is opened and placed in Acrobat.
22
26
  */
23
27
  function customStampName(random = Math.random) {
24
- let out = "#";
25
- for (let i = 0; i < 22; i++) out += BASE62[Math.floor(random() * 62)];
26
- return out;
28
+ let name = "#";
29
+ for (let i = 0; i < 22; i++) name += BASE62[Math.floor(random() * 62)];
30
+ return name;
27
31
  }
28
32
  /** Asset ids are derived, not allocated: library id + identifier. */
29
33
  function assetIdFor(libraryId, name) {
@@ -33,8 +37,6 @@ function assetIdFor(libraryId, name) {
33
37
  const STAMP_LIBRARY_PIECEINFO_APP = "EMBD_StampLibrary";
34
38
  /** Page `/PieceInfo` application name for per-stamp data. */
35
39
  const STAMP_PIECEINFO_APP = "EMBD_Stamp";
36
- /** The `Version` both dictionaries carry. */
37
- const STAMP_PIECEINFO_VERSION = 2;
38
40
  /** The library kind every file has unless it says otherwise. */
39
41
  const DEFAULT_LIBRARY_KIND = "stamps";
40
42
  /** `/Kind` names: the two the plugin defines keep their PDF spellings; others are written as given. */
@@ -49,31 +51,36 @@ function stampKindToPdfName(kind) {
49
51
  return kind === "signature" ? "Signature" : kind === "initials" ? "Initials" : "Stamp";
50
52
  }
51
53
  /** The catalog patch: library id, categories, locale. The name is `/Title`. */
52
- function stampLibraryPieceInfo(id, opts = {}) {
54
+ function stampLibraryPieceInfo(id, options = {}) {
53
55
  return {
54
56
  Version: 2,
55
57
  Id: id,
56
- Kind: { name: libraryKindToPdfName(opts.kind ?? "stamps") },
58
+ Kind: { name: libraryKindToPdfName(options.kind ?? "stamps") },
57
59
  Name: null,
58
- Categories: opts.categories ?? null,
59
- Locale: opts.locale ?? null
60
+ Categories: options.categories ?? null,
61
+ Locale: options.locale ?? null
60
62
  };
61
63
  }
62
64
  /** The page patch: kind, an explicit `/Subj` override, categories. */
63
- function stampPieceInfo(kind, opts = {}) {
65
+ function stampPieceInfo(kind, options = {}) {
64
66
  return {
65
67
  Version: 2,
66
68
  Kind: { name: stampKindToPdfName(kind) },
67
69
  Name: null,
68
70
  Subject: null,
69
- SubjectOverride: opts.subject ?? null,
70
- Categories: opts.categories ?? null
71
+ SubjectOverride: options.subject ?? null,
72
+ Categories: options.categories ?? null
71
73
  };
72
74
  }
73
75
  //#endregion
74
- //#region src/types.ts
75
- const StampToken = createCapabilityToken("stamp");
76
+ //#region src/contract.ts
77
+ /** What the stamp settings are when the app registers none. */
78
+ const STAMP_DEFAULTS = {
79
+ assetEngine: null,
80
+ previewWidth: 256,
81
+ dynamic: true
82
+ };
76
83
  //#endregion
77
- export { STAMP_PIECEINFO_VERSION as a, libraryKindFromPdfName as c, stampKey as d, stampKindToPdfName as f, STAMP_PIECEINFO_APP as i, libraryKindToPdfName as l, stampPieceInfo as m, DEFAULT_LIBRARY_KIND as n, assetIdFor as o, stampLibraryPieceInfo as p, STAMP_LIBRARY_PIECEINFO_APP as r, customStampName as s, StampToken as t, parseStampKey as u };
84
+ export { assetIdFor as a, parseStampKey as c, stampPieceInfo as d, StampToken as f, STAMP_PIECEINFO_APP as i, stampKey as l, DEFAULT_LIBRARY_KIND as n, customStampName as o, STAMP_LIBRARY_PIECEINFO_APP as r, libraryKindFromPdfName as s, STAMP_DEFAULTS as t, stampLibraryPieceInfo as u };
78
85
 
79
- //# sourceMappingURL=contract-B79Onij2.js.map
86
+ //# sourceMappingURL=contract-CJBvneyw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-CJBvneyw.js","names":[],"sources":["../src/token.ts","../src/convention.ts","../src/contract.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { StampCapability } from './contract';\n\nexport const StampToken = createCapabilityToken<StampCapability>('stamp', {\n hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`,\n});\n","/**\n * Acrobat's stamp-library convention, interpreted in one place. A library is\n * a PDF whose `/Names /Pages` registry names each stamp page with a key of\n * the form `identifier=label`:\n *\n * - `identifier` (before the first `=`) is the stamp's durable identity\n * and becomes the placed annotation's `/Name` — a standard name such as\n * `Approved`, or a custom one such as Acrobat's `#LBGiYhk8V_oAfmqAPENiwD`;\n * - `label` (after it) is what the picker shows and the placed\n * annotation's default `/Subj`.\n *\n * The engine never interprets key text; this module does. A key without\n * `=` is its own label. `#` is never stripped: it is part of the identity.\n */\nimport type { PieceInfoPatch } from '@embedpdf/engine-core/runtime';\nimport type { StampAssetKind } from './contract';\n\nexport interface StampKey {\n name: string;\n label: string;\n}\n\nexport function parseStampKey(key: string): StampKey {\n const separator = key.indexOf('=');\n if (separator < 0) return { name: key, label: key };\n return { name: key.slice(0, separator), label: key.slice(separator + 1) };\n}\n\nexport function stampKey(name: string, label: string): string {\n return `${name}=${label}`;\n}\n\nconst BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * A fresh identifier for a stamp authored here, in Acrobat's own shape\n * (`#` + 22 base-62 characters) so a stamp created in this viewer keeps its\n * identity when the library is opened and placed in Acrobat.\n */\nexport function customStampName(random: () => number = Math.random): string {\n let name = '#';\n for (let i = 0; i < 22; i++) name += BASE62[Math.floor(random() * BASE62.length)];\n return name;\n}\n\n/** Asset ids are derived, not allocated: library id + identifier. */\nexport function assetIdFor(libraryId: string, name: string): string {\n return `${libraryId}:${name}`;\n}\n\n// ── PieceInfo: only what has no standard home ────────────────────────────────\n//\n// The title, the registry, and the artwork are standard PDF. What remains\n// (a durable library id, categories, a locale, a stamp's kind and an explicit\n// `/Subj` override) rides `/PieceInfo` under these application names, in the\n// shape below, so every write produces the dictionary the import reads.\n\n/** Catalog `/PieceInfo` application name for library-level data. */\nexport const STAMP_LIBRARY_PIECEINFO_APP = 'EMBD_StampLibrary';\n/** Page `/PieceInfo` application name for per-stamp data. */\nexport const STAMP_PIECEINFO_APP = 'EMBD_Stamp';\n/** The PieceInfo format version both dictionaries carry in `Version`. */\nexport const STAMP_PIECEINFO_VERSION = 2;\n\n/** The library kind every file has unless it says otherwise. */\nexport const DEFAULT_LIBRARY_KIND = 'stamps';\n\n/** `/Kind` names: the two the plugin defines keep their PDF spellings; others are written as given. */\nexport function libraryKindToPdfName(kind: string): string {\n return kind === 'stamps' ? 'StampLibrary' : kind === 'signatures' ? 'SignatureLibrary' : kind;\n}\n\nexport function libraryKindFromPdfName(name: string | undefined): string {\n if (!name || name === 'StampLibrary') return DEFAULT_LIBRARY_KIND;\n return name === 'SignatureLibrary' ? 'signatures' : name;\n}\n\nexport function stampKindToPdfName(kind: StampAssetKind): string {\n return kind === 'signature' ? 'Signature' : kind === 'initials' ? 'Initials' : 'Stamp';\n}\n\n/** The catalog patch: library id, categories, locale. The name is `/Title`. */\nexport function stampLibraryPieceInfo(\n id: string,\n options: { kind?: string; categories?: readonly string[]; locale?: string } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Id: id,\n Kind: { name: libraryKindToPdfName(options.kind ?? DEFAULT_LIBRARY_KIND) },\n // Format version 2 keeps the name in the PDF's /Title.\n Name: null,\n Categories: options.categories ?? null,\n Locale: options.locale ?? null,\n };\n}\n\n/** The page patch: kind, an explicit `/Subj` override, categories. */\nexport function stampPieceInfo(\n kind: StampAssetKind,\n options: { subject?: string | null; categories?: readonly string[] } = {},\n): PieceInfoPatch {\n return {\n Version: STAMP_PIECEINFO_VERSION,\n Kind: { name: stampKindToPdfName(kind) },\n // Format version 2 keeps the identifier and label in the /Names /Pages\n // key; only an explicit /Subj override has no standard home. The format\n // version 1 `Name`/`Subject` keys are cleared, so a re-imported format\n // version 1 library cannot disagree with its registry.\n Name: null,\n Subject: null,\n SubjectOverride: options.subject ?? null,\n Categories: options.categories ?? null,\n };\n}\n","/** @embedpdf/plugin-stamp/contract: the public stamp vocabulary. */\nimport type {\n BatchResult,\n DeepPartial,\n EventHook,\n OperationOptions,\n SettingsApi,\n} from '@embedpdf/core';\nimport type {\n Annotation,\n AnnotationRef,\n BinarySource,\n LocalEngine,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\nexport { StampToken } from './token';\nexport { DEFAULT_LIBRARY_KIND } from './convention';\nexport type { StampLibraryStore } from './persistence';\nexport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\n/**\n * The stamp plugin: a workspace-scoped asset substrate.\n *\n * The design law (\"documents have a home; assets ride the wire\"): imported\n * PDF libraries retain one canonical PDF whose catalog/page `/PieceInfo`\n * carries their metadata. Per-asset PDFs and previews are derived caches used\n * for placement. Standalone PNG/JPEG assets remain loose because the engine\n * intentionally has no raster-to-PDF-page authoring primitive.\n */\n\nexport type StampAssetKind = 'stamp' | 'signature' | 'initials';\n\n/**\n * What a library file is for: the routing key a surface queries by. Open:\n * the plugin defines `stamps` (the default) and `signatures`; an embedder\n * may define its own (`toolbar`, `legal-seals`). Persisted in the file.\n */\nexport type StampLibraryKind = string;\n\n/**\n * How a mark is authored: drawn strokes (kept as a vector path), typed text\n * in a registered font (embedded by the flatten), a raster image, or a page\n * of a PDF. Ink strokes are in points, from the top-left and y down like\n * every page position, any origin — the asset page is the mark's bounds.\n */\nexport type MarkSource =\n | {\n kind: 'ink';\n strokes: ReadonlyArray<ReadonlyArray<{ x: number; y: number }>>;\n color?: string;\n strokeWidth?: number;\n }\n | { kind: 'text'; text: string; fontFamily: string; color?: string; fontSize?: number }\n | { kind: 'image'; source: BinarySource }\n | { kind: 'pdf'; source: BinarySource; pageIndex?: number };\n\n/**\n * One asset's serializable descriptor. The bytes and the cached preview are\n * deliberately not here: session state holds serializable data only, and\n * binary lives in the capability and crosses only as call arguments and\n * return values, mirroring the engine's own BinarySource rule.\n */\nexport interface StampAsset {\n /** Derived and stable: `${libraryId}:${name}` (never allocated). */\n id: string;\n libraryId: string;\n kind: StampAssetKind;\n /**\n * The stamp's identifier: the text before the first `=` in its library\n * key, and the placed annotation's `/Name`: a standard name (`Approved`)\n * or a custom one (`#LBGiYhk8V_oAfmqAPENiwD`). Not display text.\n */\n name: string;\n /** What the picker shows and the placed annotation's default `/Subj`:\n * the text after `=` in the library key (`Goedgekeurd`). */\n label: string;\n /** Intrinsic size in PDF points (the source page's crop box / image pixels 1:1). */\n size: { width: number; height: number };\n /** The library page that is this asset. Every asset is a page: a raster\n * added to a library becomes a page carrying the image. */\n page: PageRef;\n /** An explicit `/Subj` override (PieceInfo); placements use `label` otherwise. */\n subject?: string;\n categories?: string[];\n}\n\n/**\n * A library is a PDF: its `/Title` is the name, its `/Names /Pages` registry\n * the assets, its pages the artwork, PieceInfo only what has no standard\n * home. One imported PDF becomes one library; `exportLibrary` returns it.\n */\nexport interface StampLibrary {\n /** PieceInfo `Id`: stable while the title is editable. */\n id: string;\n name: string;\n /** PieceInfo `Kind`: `'stamps'`, `'signatures'`, or an embedder's own. */\n kind: StampLibraryKind;\n /** PieceInfo `Locale`: the language of the labels, when the library says. */\n locale?: string;\n categories?: string[];\n /** Asset ids in display order. */\n assetIds: string[];\n}\n\n// ── settings ──────────────────────────────────────────────────────────────\n\n/**\n * The local engine stamp libraries open in, or a function that makes one. A\n * function is called on the first import, not at startup, and its engine is\n * destroyed with the plugin.\n */\nexport type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise<LocalEngine>);\n\n/**\n * The stamp plugin's settings. `stampPlugin(config)` registers them over\n * {@link STAMP_DEFAULTS}, and `updateSettings()` changes them while the app\n * runs.\n */\nexport interface StampSettings {\n /**\n * The engine stamp libraries open in. `null` uses the viewer's own engine,\n * which is right when that engine is local. A cloud viewer passes a local\n * engine, or a function that makes one:\n *\n * ```ts\n * stampPlugin({\n * assetEngine: () => import('@embedpdf/engine').then((module) => module.createLocalEngine()),\n * })\n * ```\n */\n readonly assetEngine: StampAssetEngine | null;\n /** The width of a stamp's thumbnail, in device pixels. */\n readonly previewWidth: number;\n /**\n * Fill in a dynamic stamp's form fields when it's armed or placed.\n * Scripting itself is the workspace's one JavaScript switch,\n * `actionsPlugin({ javascript: { enabled } })`: without the actions plugin,\n * or with scripting off, a stamp is placed as it is. `false` keeps every\n * stamp as reviewed, even with scripting on.\n */\n readonly dynamic: boolean;\n}\n\n/** What the stamp settings are when the app registers none. */\nexport const STAMP_DEFAULTS: StampSettings = {\n assetEngine: null,\n previewWidth: 256,\n dynamic: true,\n};\n\n/** What `stampPlugin(config)` takes: any of the settings, merged over the defaults. */\nexport type StampConfig = DeepPartial<StampSettings>;\n\n// ── verbs ─────────────────────────────────────────────────────────────────\n\n/**\n * Which document a placing verb acts on. Left out, it is the document in\n * scope (`useStamp()` inside a `<DocumentScope>`, a document plugin's\n * `ctx.get(StampToken)`), else the active document.\n */\nexport interface StampDocumentOptions extends OperationOptions {\n readonly documentId?: string;\n}\n\n/** `armAsset()`'s options. */\nexport interface StampArmOptions extends StampDocumentOptions {\n /** Placed width in PDF points; the stamp's own width by default. */\n readonly targetWidth?: number;\n}\n\nexport interface CreateLibraryOptions extends OperationOptions {\n /** The library's id; a fresh one when left out or taken. */\n readonly id?: string;\n /** What the library is for. Default `'stamps'`. */\n readonly kind?: StampLibraryKind;\n readonly categories?: string[];\n}\n\nexport interface StampLibraryPatch {\n readonly name?: string;\n readonly categories?: string[];\n}\n\nexport interface ImportLibraryOptions extends OperationOptions {\n /**\n * Fallback library name, applied only when the PDF carries no `/Title`\n * (an Acrobat-authored or previously exported library names itself).\n * Default `'Stamps'`.\n */\n name?: string;\n /** Library categories written to catalog `/PieceInfo`. */\n categories?: string[];\n /** Kind stamped onto every imported asset. Default `'stamp'`. */\n kind?: StampAssetKind;\n /** What the file is for; overrides what the file says (an Acrobat-authored set imported for a toolbar). */\n libraryKind?: StampLibraryKind;\n /**\n * Fallback per-page labels for a plain PDF (no `/Names /Pages` registry):\n * every page becomes a stamp named `Stamp<n>` with this label. Ignored\n * when the PDF registers its stamps itself.\n */\n assetName?: (pageIndex: number) => string;\n}\n\nexport interface AddAssetInput {\n /** Target library; omitted, a new single-asset library named after the asset. */\n libraryId?: string;\n /** The identifier (placed `/Name`). Omit to mint an Acrobat-style `#…` one. */\n name?: string;\n /** Picker text and default `/Subj`. Defaults to `name`. */\n label?: string;\n kind?: StampAssetKind;\n subject?: string;\n categories?: string[];\n /**\n * PNG, JPEG, or single-page PDF bytes. Exactly one of `source` / `mark`. A\n * raster becomes a page of the library sized to `size` (default: its\n * pixels as points, 1:1) with the image flattened into it, so every asset\n * is a page and every library a complete PDF.\n */\n source?: BinarySource;\n /** An authored mark: drawn, typed, an image, or a PDF page. Exactly one of `source` / `mark`. */\n mark?: MarkSource;\n /** Thumbnail override for pickers (PNG/JPEG); rendered from the page otherwise. */\n preview?: BinarySource;\n /** Page size in PDF points for a raster source. Ignored for PDF sources (the page has one). */\n size?: { width: number; height: number };\n}\n\n/** What `createAssetFromAnnotations()` takes besides the annotations: where the stamp goes and its name. */\nexport type AssetFromAnnotationsInput = Omit<AddAssetInput, 'source' | 'mark' | 'size'>;\n\nexport interface StampAssetPatch {\n readonly label?: string;\n /** `null` drops the subject override, so placements use the label. */\n readonly subject?: string | null;\n readonly categories?: string[];\n}\n\n/** A cached, browser-paintable render of an asset (PNG from import; raster assets as-is). */\nexport interface StampAssetPreview {\n bytes: Uint8Array;\n mimeType: string;\n}\n\nexport interface StampLibraryFilter {\n readonly kind?: StampLibraryKind | readonly StampLibraryKind[];\n}\nexport interface StampAssetFilter {\n readonly libraryId?: string;\n readonly kind?: StampAssetKind;\n readonly category?: string;\n}\n\n// ── events ────────────────────────────────────────────────────────────────\n\n/** A library's bytes changed, and why: the one to save it on. */\nexport interface StampLibraryChangedEvent {\n readonly libraryId: string;\n readonly reason:\n | 'created'\n | 'imported'\n | 'updated'\n | 'asset-added'\n | 'asset-updated'\n | 'asset-removed'\n | 'removed';\n}\nexport interface StampLibraryCreatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryUpdatedEvent {\n readonly libraryId: string;\n readonly library: StampLibrary;\n}\nexport interface StampLibraryDeletedEvent {\n readonly libraryId: string;\n readonly library: null;\n}\nexport interface StampAssetCreatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetUpdatedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: StampAsset;\n}\nexport interface StampAssetDeletedEvent {\n readonly assetId: string;\n readonly libraryId: string;\n readonly asset: null;\n}\n/** A stamp was armed on a document, or disarmed (`asset: null`). */\nexport interface StampArmChangedEvent {\n readonly documentId: string;\n readonly asset: StampAsset | null;\n}\n\n/**\n * Stamp libraries and their assets, shared by every document, and placing\n * them on a document. The placing verbs act on the document in scope, else\n * the active one, or the one their options name (`documentId`). A library is\n * a PDF (one page per asset): `exportLibrary` returns the persistence format,\n * `importLibrary` reads it back. Every verb rejects with a `PluginError`, and\n * every async verb takes a `signal`: cancelled, it rejects\n * `operation-cancelled` and changes nothing. The settings belong to the\n * plugin, not to a document.\n */\nexport interface StampCapability extends SettingsApi<StampSettings> {\n // ── reading ──\n listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[];\n getLibrary(libraryId: string): StampLibrary | null;\n /** Assets in the order a picker shows them: by library, then within it. */\n listAssets(filter?: StampAssetFilter): readonly StampAsset[];\n getAsset(assetId: string): StampAsset | null;\n /** The cached thumbnail (the `previewWidth` setting), or null. */\n getAssetPreview(assetId: string): StampAssetPreview | null;\n /** A preview at any width, rendered by the asset engine and cached per width. Rejects `not-found`. */\n renderAssetPreview(\n assetId: string,\n options: { width: number } & OperationOptions,\n ): Promise<StampAssetPreview | null>;\n /** A copy of the asset's placement bytes (a one-page PDF), or null. */\n readAssetBytes(assetId: string): Uint8Array | null;\n\n // ── libraries ──\n /** Create an empty library. Fires `onLibraryCreated` and `onLibraryChanged`. */\n createLibrary(name: string, options?: CreateLibraryOptions): Promise<{ library: StampLibrary }>;\n /** Rename a library or change its categories. Rejects `not-found`. Fires `onLibraryUpdated`. */\n updateLibrary(\n libraryId: string,\n changes: StampLibraryPatch,\n options?: OperationOptions,\n ): Promise<{ library: StampLibrary }>;\n /** Delete a library with its assets. Fires `onLibraryDeleted`. */\n deleteLibrary(libraryId: string, options?: OperationOptions): Promise<void>;\n /**\n * A PDF becomes a library (one asset per page). Rejects `invalid-input` for\n * bytes that aren't a PDF, `unsupported` without a local asset engine.\n * Fires `onLibraryCreated`, then `onAssetCreated` per stamp.\n */\n importLibrary(\n source: BinarySource,\n options?: ImportLibraryOptions,\n ): Promise<{ library: StampLibrary }>;\n /** The library as the PDF it is. Rejects `not-found`. */\n exportLibrary(libraryId: string, options?: OperationOptions): Promise<Uint8Array>;\n\n // ── assets ──\n /**\n * Add a stamp from bytes or a mark. Rejects `not-found` for an unknown\n * library, `invalid-input` for bytes that aren't a picture or a taken\n * identifier. Fires `onAssetCreated`.\n */\n createAsset(input: AddAssetInput, options?: OperationOptions): Promise<{ asset: StampAsset }>;\n /**\n * Annotations on a page of a document become one stamp, exactly as they\n * look. All or nothing: a hidden annotation, one without an appearance, or\n * one on another page fails the call. Rejects `permission-denied` without\n * `doc.download` (see `canCreateFromAnnotations`), `not-found` for a page\n * that isn't in the document.\n */\n createAssetFromAnnotations(\n page: PageRef | number,\n refs: readonly AnnotationRef[],\n input: AssetFromAnnotationsInput,\n options?: StampDocumentOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Change a stamp's label, subject or categories; its identifier never changes. Rejects `not-found`. */\n updateAsset(\n assetId: string,\n changes: StampAssetPatch,\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Remove a stamp from its library. Fires `onAssetDeleted`. */\n deleteAsset(assetId: string, options?: OperationOptions): Promise<void>;\n /** Move a stamp to another library: a copy there, with a new id, then the original goes. */\n moveAsset(\n assetId: string,\n to: { libraryId: string },\n options?: OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n /** Copy a stamp within its library. */\n duplicateAsset(\n assetId: string,\n options?: { label?: string } & OperationOptions,\n ): Promise<{ asset: StampAsset }>;\n\n // ── placing, on one document ──\n /**\n * Arm a stamp: the next click on the document places it, with a preview\n * under the pointer. Rejects `not-found` for an unknown asset,\n * `permission-denied` without `annotations:create` (see `canPlace`).\n * Fires `onArmChanged`.\n */\n armAsset(assetId: string, options?: StampArmOptions): Promise<void>;\n /** Disarm the stamp without placing it. Fires `onArmChanged` when one was armed. */\n disarm(documentId?: string): void;\n /** The stamp the next click on the document places, or null. */\n getArmedAsset(documentId?: string): StampAsset | null;\n /**\n * Place a stamp without the pointer, its middle on `center`, sized by its\n * picture and kept on the page. Resolves `{ annotation }`. Selected only\n * with `select: true`. Rejects `permission-denied` without\n * `annotations:create`, `not-found` for an unknown asset or page.\n */\n placeAsset(\n assetId: string,\n placement: StampPlacement,\n options?: StampDocumentOptions,\n ): Promise<{ annotation: Annotation }>;\n /**\n * Place one stamp at the same spot on several pages (refs or indexes), or\n * on `'all'`. Resolves the placed stamps, and the pages that failed.\n */\n placeAssetOnPages(\n assetId: string,\n pages: readonly (PageRef | number)[] | 'all',\n placement: Omit<StampPlacement, 'page'>,\n options?: StampDocumentOptions,\n ): Promise<BatchResult<Annotation, PageRef>>;\n /** Whether a stamp may be armed or placed on the document (`annotations:create`). */\n canPlace(documentId?: string): boolean;\n /** Whether annotations of the document may become a stamp, which copies them out (`doc.download`). */\n canCreateFromAnnotations(documentId?: string): boolean;\n /** Whether libraries can be imported: false once an import found no local engine to open them in. */\n canImport(): boolean;\n\n // ── events ──\n readonly onLibraryCreated: EventHook<StampLibraryCreatedEvent>;\n readonly onLibraryUpdated: EventHook<StampLibraryUpdatedEvent>;\n readonly onLibraryDeleted: EventHook<StampLibraryDeletedEvent>;\n readonly onAssetCreated: EventHook<StampAssetCreatedEvent>;\n readonly onAssetUpdated: EventHook<StampAssetUpdatedEvent>;\n readonly onAssetDeleted: EventHook<StampAssetDeletedEvent>;\n /** A stamp was armed or disarmed on a document. */\n readonly onArmChanged: EventHook<StampArmChangedEvent>;\n /** A library's bytes changed (subscribe to persist). */\n readonly onLibraryChanged: EventHook<StampLibraryChangedEvent>;\n}\n"],"mappings":";;;AAKA,MAAa,aAAa,sBAAuC,SAAS,EACxE,MAAM,uEACR,CAAC;;;ACeD,SAAgB,cAAc,KAAuB;CACnD,MAAM,YAAY,IAAI,QAAQ,GAAG;CACjC,IAAI,YAAY,GAAG,OAAO;EAAE,MAAM;EAAK,OAAO;CAAI;CAClD,OAAO;EAAE,MAAM,IAAI,MAAM,GAAG,SAAS;EAAG,OAAO,IAAI,MAAM,YAAY,CAAC;CAAE;AAC1E;AAEA,SAAgB,SAAS,MAAc,OAAuB;CAC5D,OAAO,GAAG,KAAK,GAAG;AACpB;AAEA,MAAM,SAAS;;;;;;AAOf,SAAgB,gBAAgB,SAAuB,KAAK,QAAgB;CAC1E,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK,QAAQ,OAAO,KAAK,MAAM,OAAO,IAAI,EAAa;CAC/E,OAAO;AACT;;AAGA,SAAgB,WAAW,WAAmB,MAAsB;CAClE,OAAO,GAAG,UAAU,GAAG;AACzB;;AAUA,MAAa,8BAA8B;;AAE3C,MAAa,sBAAsB;;AAKnC,MAAa,uBAAuB;;AAGpC,SAAgB,qBAAqB,MAAsB;CACzD,OAAO,SAAS,WAAW,iBAAiB,SAAS,eAAe,qBAAqB;AAC3F;AAEA,SAAgB,uBAAuB,MAAkC;CACvE,IAAI,CAAC,QAAQ,SAAS,gBAAgB,OAAO;CAC7C,OAAO,SAAS,qBAAqB,eAAe;AACtD;AAEA,SAAgB,mBAAmB,MAA8B;CAC/D,OAAO,SAAS,cAAc,cAAc,SAAS,aAAa,aAAa;AACjF;;AAGA,SAAgB,sBACd,IACA,UAA8E,CAAC,GAC/D;CAChB,OAAO;EACL,SAAA;EACA,IAAI;EACJ,MAAM,EAAE,MAAM,qBAAqB,QAAQ,QAAA,QAA4B,EAAE;EAEzE,MAAM;EACN,YAAY,QAAQ,cAAc;EAClC,QAAQ,QAAQ,UAAU;CAC5B;AACF;;AAGA,SAAgB,eACd,MACA,UAAuE,CAAC,GACxD;CAChB,OAAO;EACL,SAAA;EACA,MAAM,EAAE,MAAM,mBAAmB,IAAI,EAAE;EAKvC,MAAM;EACN,SAAS;EACT,iBAAiB,QAAQ,WAAW;EACpC,YAAY,QAAQ,cAAc;CACpC;AACF;;;;ACgCA,MAAa,iBAAgC;CAC3C,aAAa;CACb,cAAc;CACd,SAAS;AACX"}