# @embedpdf/vue — ./stamp AssetFromAnnotationsInput [TypeAliasDeclaration] (from packages/plugin/stamp/src/contract.ts): export type AssetFromAnnotationsInput = Omit; ByteStore [InterfaceDeclaration] (from packages/framework/web/src/byte-store.ts): export interface ByteStore{ list(): Promise>; put(id: string, bytes: Uint8Array): Promise; delete(id: string): Promise; } CreateAssetInput [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface CreateAssetInput{ libraryId?: string; name?: string; label?: string; kind?: StampAssetKind; subject?: string; categories?: string[]; source?: BinarySource; mark?: MarkSource; preview?: BinarySource; size?:{ width: number; height: number} ; } CreateLibraryOptions [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface CreateLibraryOptions extends OperationOptions{ readonly id?: string; readonly kind?: StampLibraryKind; readonly categories?: string[]; } DEFAULT_LIBRARY_KIND [VariableDeclaration] (from packages/plugin/stamp/src/convention.ts): DEFAULT_LIBRARY_KIND = 'stamps' ImportLibraryOptions [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface ImportLibraryOptions extends OperationOptions{ id?: string; name?: string; categories?: string[]; assetKind?: StampAssetKind; libraryKind?: StampLibraryKind; assetName?: (pageIndex: number) => string; } MarkSource [TypeAliasDeclaration] (from packages/plugin/stamp/src/contract.ts): export type MarkSource = |{ kind: 'ink'; strokes: ReadonlyArray>; color?: string; strokeWidth?: number; } |{ kind: 'text'; text: string; fontFamily: string; color?: string; fontSize?: number} |{ kind: 'image'; source: BinarySource} |{ kind: 'pdf'; source: BinarySource; pageIndex?: number} ; STAMP_DEFAULTS [VariableDeclaration] (from packages/plugin/stamp/src/contract.ts): STAMP_DEFAULTS: StampSettings ={ assetEngine: null, fonts: [], previewWidth: 256, dynamic: true, } StampArmChangedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampArmChangedEvent{ readonly documentId: string; readonly asset: StampAsset | null; } StampArmOptions [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampArmOptions extends StampDocumentOptions{ readonly targetWidth?: number; } StampAsset [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAsset{ readonly id: string; readonly libraryId: string; readonly kind: StampAssetKind; readonly name: string; readonly label: string; readonly size:{ width: number; height: number} ; readonly page: PageRef; readonly subject?: string; readonly categories?: string[]; } StampAssetCreatedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAssetCreatedEvent{ readonly assetId: string; readonly libraryId: string; readonly asset: StampAsset; } StampAssetDeletedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAssetDeletedEvent{ readonly assetId: string; readonly libraryId: string; readonly asset: null; } StampAssetEngine [TypeAliasDeclaration] (from packages/plugin/stamp/src/contract.ts): export type StampAssetEngine = LocalEngine | (() => LocalEngine | Promise); StampAssetFilter [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAssetFilter{ readonly libraryId?: string; readonly kind?: StampAssetKind; readonly category?: string; } StampAssetKind [TypeAliasDeclaration] (from packages/plugin/stamp/src/contract.ts): export type StampAssetKind = 'stamp' | 'signature' | 'initials'; StampAssetPatch [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAssetPatch{ readonly label?: string; readonly subject?: string | null; readonly categories?: string[]; } StampAssetPreview [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAssetPreview{ readonly bytes: Uint8Array; readonly mimeType: string; } StampAssetUpdatedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampAssetUpdatedEvent{ readonly assetId: string; readonly libraryId: string; readonly asset: StampAsset; } StampCapability [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampCapability extends SettingsApi{ listLibraries(filter?: StampLibraryFilter): readonly StampLibrary[]; getLibrary(libraryId: string): StampLibrary | null; listAssets(filter?: StampAssetFilter): readonly StampAsset[]; getAsset(assetId: string): StampAsset | null; getAssetPreview(assetId: string): StampAssetPreview | null; renderAssetPreview( assetId: string, options:{ width: number} & OperationOptions, ): Promise; getAssetBytes(assetId: string): Uint8Array | null; createLibrary(name: string, options?: CreateLibraryOptions): Promise<{ library: StampLibrary} >; updateLibrary( libraryId: string, changes: StampLibraryPatch, options?: OperationOptions, ): Promise<{ library: StampLibrary} >; deleteLibrary(libraryId: string, options?: OperationOptions): Promise; importLibrary( source: BinarySource, options?: ImportLibraryOptions, ): Promise<{ library: StampLibrary} >; exportLibrary(libraryId: string, options?: OperationOptions): Promise; createAsset(input: CreateAssetInput, options?: OperationOptions): Promise<{ asset: StampAsset} >; createAssetFromAnnotations( page: PageRef | number, refs: readonly AnnotationRef[], input: AssetFromAnnotationsInput, options?: StampDocumentOptions, ): Promise<{ asset: StampAsset} >; updateAsset( assetId: string, changes: StampAssetPatch, options?: OperationOptions, ): Promise<{ asset: StampAsset} >; deleteAsset(assetId: string, options?: OperationOptions): Promise; moveAsset( assetId: string, to:{ libraryId: string} , options?: OperationOptions, ): Promise<{ asset: StampAsset} >; duplicateAsset( assetId: string, options?:{ label?: string} & OperationOptions, ): Promise<{ asset: StampAsset} >; armAsset(assetId: string, options?: StampArmOptions): Promise; disarm(documentId?: string): void; getArmedAsset(documentId?: string): StampAsset | null; placeAsset( assetId: string, placement: StampPlacement, options?: StampDocumentOptions, ): Promise<{ annotation: Annotation} >; placeAssetOnPages( assetId: string, pages: readonly (PageRef | number)[] | 'all', placement: Omit, options?: StampDocumentOptions, ): Promise>; canPlace(documentId?: string): boolean; canCreateFromAnnotations(documentId?: string): boolean; canImport(): boolean; readonly onLibraryCreated: EventHook; readonly onLibraryUpdated: EventHook; readonly onLibraryDeleted: EventHook; readonly onAssetCreated: EventHook; readonly onAssetUpdated: EventHook; readonly onAssetDeleted: EventHook; readonly onArmChanged: EventHook; readonly onLibraryChanged: EventHook; } StampConfig [TypeAliasDeclaration] (from packages/plugin/stamp/src/contract.ts): export type StampConfig = DeepPartial; StampDocumentOptions [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampDocumentOptions extends OperationOptions{ readonly documentId?: string; } StampFont [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampFont{ readonly key: string; readonly load: () => Promise; } StampLibrary [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibrary{ readonly id: string; readonly name: string; readonly kind: StampLibraryKind; readonly locale?: string; readonly categories?: string[]; readonly assetIds: string[]; } StampLibraryChangedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibraryChangedEvent{ readonly libraryId: string; readonly type: | 'created' | 'imported' | 'updated' | 'asset-created' | 'asset-updated' | 'asset-deleted' | 'deleted'; } StampLibraryCreatedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibraryCreatedEvent{ readonly libraryId: string; readonly library: StampLibrary; } StampLibraryDeletedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibraryDeletedEvent{ readonly libraryId: string; readonly library: null; } StampLibraryFilter [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibraryFilter{ readonly kind?: StampLibraryKind | readonly StampLibraryKind[]; } StampLibraryKind [TypeAliasDeclaration] (from packages/plugin/stamp/src/contract.ts): export type StampLibraryKind = string; StampLibraryPatch [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibraryPatch{ readonly name?: string; readonly categories?: string[]; } StampLibraryStore [InterfaceDeclaration] (from packages/plugin/stamp/src/persistence.ts): export interface StampLibraryStore{ list(): Promise>; put(id: string, bytes: Uint8Array): Promise; delete(id: string): Promise; } StampLibraryUpdatedEvent [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampLibraryUpdatedEvent{ readonly libraryId: string; readonly library: StampLibrary; } StampPlacement [InterfaceDeclaration] (from packages/plugin/annotation/src/contract.ts): export interface StampPlacement{ readonly page: PageRef | number; readonly center: Point; readonly targetWidth?: number; readonly rotation?: number; readonly select?: boolean; } StampSettings [InterfaceDeclaration] (from packages/plugin/stamp/src/contract.ts): export interface StampSettings{ readonly assetEngine: StampAssetEngine | null; readonly fonts: readonly StampFont[]; readonly previewWidth: number; readonly dynamic: boolean; } StampState [InterfaceDeclaration] (from packages/plugin/stamp/src/state.ts): export interface StampState{ readonly armedAsset: StampAsset | null; } StampToken [VariableDeclaration] (from packages/plugin/stamp/src/token.ts): StampToken = createCapabilityToken('stamp', { hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`, } ) indexedDbByteStore [FunctionDeclaration] (from packages/framework/web/src/byte-store.ts): export function indexedDbByteStore( dbName: string, options: IndexedDbByteStoreOptions ={ } , ): ByteStore{ const storeName = options.storeName ?? 'bytes'; const open = (): Promise => new Promise((resolve, reject) =>{ const request = indexedDB.open(dbName, 1); request.onupgradeneeded = () =>{ if (!request.result.objectStoreNames.contains(storeName)){ request.result.createObjectStore(storeName); } } ; request.onsuccess = () => resolve(request.result); request.onerror = () => reject(request.error ?? new Error('indexedDB.open failed')); } ); const run = async ( mode: IDBTransactionMode, body: (store: IDBObjectStore) => IDBRequest, ): Promise =>{ const db = await open(); try{ return await new Promise((resolve, reject) =>{ const request = body(db.transaction(storeName, mode).objectStore(storeName)); request.onsuccess = () => resolve(request.result); request.onerror = () => reject(request.error ?? new Error('indexedDB request failed')); } ); } finally{ db.close(); } } ; return{ list: async () =>{ const keys = await run('readonly', (store) => store.getAllKeys()); const values = await run('readonly', (store) => store.getAll()); return keys.map((key, i) => ({ id: String(key), bytes: new Uint8Array(values[i])} )); } , put: (id, bytes) => run('readwrite', (store) => store.put(new Uint8Array(bytes), id)).then(() => undefined), delete: (id) => run('readwrite', (store) => store.delete(id)).then(() => undefined), } ; } memoryStampStore [FunctionDeclaration] (from packages/plugin/stamp/src/persistence.ts): export function memoryStampStore(): StampLibraryStore{ const rows = new Map(); return{ list: async () => [...rows.entries()].map(([id, bytes]) => ({ id, bytes} )), put: async (id, bytes) =>{ rows.set(id, new Uint8Array(bytes)); } , delete: async (id) =>{ rows.delete(id); } , } ; } persistStampLibraries [FunctionDeclaration] (from packages/plugin/stamp/src/persistence.ts): export function persistStampLibraries( stamp: Pick, store: StampLibraryStore, options:{ except?: readonly string[]} ={ } , ): () => void{ const except = new Set(options.except ?? []); const lines = new Map(); const run = (libraryId: string, step: Step): void =>{ const line = lines.get(libraryId); if (line){ if (line.started) line.next = step; else line.step = step; return; } const fresh ={ step, started: false, next: null as Step | null} ; lines.set(libraryId, fresh); void Promise.resolve().then(async () =>{ fresh.started = true; try{ if (fresh.step === 'save') await store.put(libraryId, await stamp.exportLibrary(libraryId)); else await store.delete(libraryId); } catch (error){ const doing = fresh.step === 'save' ? 'persisting' : 'deleting stored'; globalThis.console?.warn(`[stamp] ${ doing} library '${ libraryId} ' failed:`, error); } lines.delete(libraryId); if (fresh.next) run(libraryId, fresh.next); } ); } ; return stamp.onLibraryChanged(({ libraryId, type} ) =>{ if (except.has(libraryId)) return; run(libraryId, type === 'deleted' ? 'delete' : 'save'); } ); } restoreStampLibraries [FunctionDeclaration] (from packages/plugin/stamp/src/persistence.ts): export async function restoreStampLibraries( stamp: Pick, store: StampLibraryStore, ): Promise{ const restored: string[] = []; for (const{ id, bytes} of await store.list()){ try{ restored.push((await stamp.importLibrary(bytes)).library.id); } catch (error){ globalThis.console?.warn(`[stamp] stored library '${ id} ' could not be restored:`, error); } } return restored; } stampPlugin [VariableDeclaration] (from packages/plugin/stamp/src/stamp.plugin.ts): stampPlugin = (config?: StampConfig) => definePlugin({ id: 'stamp', token: StampToken, scope: 'workspace', optional: [AnnotationToken, ActionsToken], state: initialStampModel, settings:{ defaults: STAMP_DEFAULTS, registered: config, whole: ['assetEngine', 'fonts']} , create: createStampController, inScope: (stamp, documentId) =>{ const scoped = (options?: Options) => ({ ...options, documentId: options?.documentId ?? documentId, } ); return{ ...stamp, createAssetFromAnnotations: (page, refs, input, options) => stamp.createAssetFromAnnotations(page, refs, input, scoped(options)), armAsset: (assetId, options) => stamp.armAsset(assetId, scoped(options)), disarm: (target = documentId) => stamp.disarm(target), getArmedAsset: (target = documentId) => stamp.getArmedAsset(target), placeAsset: (assetId, placement, options) => stamp.placeAsset(assetId, placement, scoped(options)), placeAssetOnPages: (assetId, pages, placement, options) => stamp.placeAssetOnPages(assetId, pages, placement, scoped(options)), canPlace: (target = documentId) => stamp.canPlace(target), canCreateFromAnnotations: (target = documentId) => stamp.canCreateFromAnnotations(target), } ; } , } ) stampState [VariableDeclaration] (from packages/plugin/stamp/src/state.ts): stampState = defineState(StampToken, { read: (stamp): StampState => ({ armedAsset: stamp.getArmedAsset(), } ), empty:{ armedAsset: null, } , } ) useStamp [FunctionDeclaration]: export function useStamp(): StampCapability{ return useCapability(StampToken); } useStampAssetPreviewUrl [FunctionDeclaration]: export function useStampAssetPreviewUrl( assetId: MaybeRefOrGetter, ): Readonly>{ const preview = useOptionalSelector( StampToken, (stamp) =>{ const id = toValue(assetId); return id ? stamp.getAssetPreview(id) : null; } , null, ); const url = shallowRef(null); watch( preview, (current, _previous, onCleanup) =>{ if (!current){ url.value = null; return; } const objectUrl = objectUrlOf(current); url.value = objectUrl.url; onCleanup(() =>{ objectUrl.revoke(); url.value = null; } ); } , { immediate: true} , ); return url; } useStampAssets [FunctionDeclaration]: export function useStampAssets( filter?: MaybeRefOrGetter, ): Readonly>{ return useSelector(StampToken, (stamp) => stamp.listAssets(toValue(filter)), shallowEqual); } useStampEvent [FunctionDeclaration]: export function useStampEvent( select: (stamp: StampCapability) => EventHook, handler: (event: Event) => void, ): void{ useCapabilityEvent(StampToken, select, handler); } useStampLibraries [FunctionDeclaration]: export function useStampLibraries( filter?: MaybeRefOrGetter, ): Readonly>{ return useSelector(StampToken, (stamp) => stamp.listLibraries(toValue(filter)), shallowEqual); } useStampSettings [VariableDeclaration]: useStampSettings = settingsComposable(StampToken) useStampState [VariableDeclaration]: useStampState = stateComposable(stampState)