# @embedpdf/viewer-react — . ActionsToken [VariableDeclaration] (from packages/plugin/actions/src/token.ts): ActionsToken = createCapabilityToken('actions', { hint: `add actionsPlugin() from '@embedpdf/plugin-actions' to your plugins list`, promises:{ execute: true, executeNamed: true, readActionTree: true, dispatch: true, runDocumentVerb: true, prepareClose: true, } , } ) AddItemOptions [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface AddItemOptions{ readonly to: string; readonly section?: SectionName; readonly group?: string; readonly before?: string; readonly after?: string; } AnnotationToken [VariableDeclaration] (from packages/plugin/annotation/src/token.ts): AnnotationToken = createCapabilityToken('annotation', { hint: `add annotationPlugin() from '@embedpdf/plugin-annotation' to your plugins list`, promises:{ refresh: true, create: true, createFromSelection: true, update: true, delete: true, reorder: true, duplicate: true, export: true, import: true, downloadResource: true, 'links.set': true, 'links.clear': true, 'selection.update': true, 'selection.updateLink': true, 'selection.delete': true, 'selection.rotateBy': true, 'selection.resetRotation': true, 'selection.group': true, 'selection.ungroup': true, 'selection.duplicate': true, 'draft.finish': true, 'text.end': true, 'text.toggleFormat': true, 'stamps.arm': true, 'stamps.place': true, 'comments.reply': true, 'comments.setText': true, 'comments.setStatus': true, 'comments.setMarked': true, 'comments.delete': true, 'comments.deleteThread': true, } , } ) BarEdge [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type BarEdge = 'top' | 'bottom' | 'start' | 'end'; BarPlace [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type BarPlace = | BarEdge |{ readonly edge: BarEdge; readonly before?: string; readonly after?: string} | FloatPlace |{ readonly with: string} |{ readonly at: SelectionTarget} |{ readonly panel: string} ; Button [FunctionDeclaration] (from packages/viewer/react/src/viewer-components.ts): export function Button({ command, icon, label, active, onClick, className, style} : ButtonProps){ return createElement('epdf-button', { command, icon, label, active: activeOf(active), onClick, style, ...(className === undefined ?{ } :{ class: className} ), } ); } ButtonProps [InterfaceDeclaration] (from packages/viewer/react/src/viewer-components.ts): export interface ButtonProps{ command?: string; icon?: string; label?: string; active?: boolean; onClick?: (event: MouseEvent) => void; className?: string; style?: CSSProperties; } CapabilityToken [InterfaceDeclaration] (from packages/core/main/src/types.ts): export interface CapabilityToken{ readonly name: string; readonly hint?: string; readonly promises?: Readonly>; readonly __type?: T; } CommandContext [InterfaceDeclaration] (from packages/viewer/chrome/src/config/viewer-commands.ts): export interface CommandContext extends ScopedViewer{ readonly documentId: string | null; readonly appState: AppState; readonly args?: unknown; readonly signal?: AbortSignal; readonly viewer: Viewer; } CommandDefinition [InterfaceDeclaration] (from packages/viewer/chrome/src/config/viewer-commands.ts): export interface CommandDefinition extends Omit< PluginCommandDef, 'icon' | 'iconAccent' | 'allowed' | 'enabled' | 'active' | 'visible' | 'labelParams' | 'run' >{ readonly icon?: IconName | (string &{ } ); iconAccent?(context: CommandContext): IconAccent | null; allowed?(context: CommandContext): boolean; enabled?(context: CommandContext): boolean; active?(context: CommandContext): boolean; visible?(context: CommandContext): boolean; labelParams?(context: CommandContext): Readonly>; run?(context: CommandContext): void | Promise; } CommandsCapability [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface CommandsCapability extends SettingsApi{ registerCommand(definition: CommandDefinition, options?: RegisterCommandOptions): Unsubscribe; registerCommands( definitions: readonly CommandDefinition[], options?: RegisterCommandOptions, ): Unsubscribe; hasCommand(id: CommandId): boolean; getCommand(id: CommandId): CommandDefinition | null; listCommandIds(): readonly CommandId[]; resolveCommand(id: CommandId, documentId?: string): ResolvedCommand | null; listCommands(documentId?: string): readonly ResolvedCommand[]; searchCommands(query: string, documentId?: string): readonly ResolvedCommand[]; listShortcuts(): readonly{ readonly commandId: CommandId; readonly shortcut: string} []; execute(id: CommandId, options?: ExecuteOptions): Promise; canExecute(id: CommandId, documentId?: string): boolean; getRefusal(id: CommandId, documentId?: string): CommandRefusal | null; getDisabledCategories(): readonly string[]; isCategoryDisabled(category: string): boolean; disableCategory(category: string): void; enableCategory(category: string): void; setDisabledCategories(categories: readonly string[]): void; getDisabledCommands(): readonly CommandId[]; isCommandDisabled(id: CommandId): boolean; disableCommand(id: CommandId): void; enableCommand(id: CommandId): void; setDisabledCommands(ids: readonly CommandId[]): void; readonly onExecuted: EventHook; readonly onExecutionFailed: EventHook; } CommandsToken [VariableDeclaration] (from packages/plugin/commands/src/token.ts): CommandsToken = createCapabilityToken('commands', { hint: `add commandsPlugin() from '@embedpdf/plugin-commands' to your plugins list`, } ) DefaultEngineProvider [TypeAliasDeclaration] (from packages/viewer/main/src/kernel/element.ts): export type DefaultEngineProvider = (engineOption: unknown) => DoorEngine; DocumentEntry [InterfaceDeclaration] (from packages/viewer/main/src/kernel/config.ts): export interface DocumentEntry{ readonly src: Src; readonly name?: string; readonly password?: string; readonly active?: boolean; } DocumentInfo [InterfaceDeclaration] (from packages/core/main/src/types.ts): export interface DocumentInfo{ readonly id: string; readonly name?: string; readonly status: DocumentStatus; readonly pageCount: number; readonly hasUnsavedChanges: boolean; readonly passwordProvided?: boolean; readonly error?: PluginErrorInfo; readonly openRequest?: GrantOpenRequest; readonly identityRequest?: VisitorIdentityRequest; } DocumentSrc [TypeAliasDeclaration] (from packages/viewer/main/src/kernel/config.ts): export type DocumentSrc = string | Blob | ArrayBuffer | Uint8Array; DocumentsCapability [InterfaceDeclaration] (from packages/core/main/src/types.ts): export interface DocumentsCapability{ open(source: OpenSource, options?: OpenDocumentOptions): Promise; canOpenFiles(): boolean; retry(id: string, options?: RetryOptions): Promise; identify(id: string, answers: VisitorAnswers): Promise; declineIdentity(id: string): void; rename(id: string, name: string): void; openAll(documents: readonly InitialDocument[]): readonly string[]; unlock(id: string, options: UnlockOptions): Promise; close(id: string): Promise; closeAll(): Promise; setActive(id: string): void; getActiveId(): string | null; getActive(): DocumentInfo | null; list(): readonly DocumentInfo[]; get(id?: string): DocumentInfo | null; has(id: string): boolean; getCount(): number; getOrder(): readonly string[]; setOrder(ids: readonly string[]): void; move(id: string, toIndex: number): void; swap(id: string, otherId: string): void; download(id?: string, options?: DownloadOptions): Promise; downloadLayer(id?: string, options?: OperationOptions): Promise; canDownload(id?: string): boolean; preparePrint(id?: string, options?: PrintOptions): Promise; print(id?: string, options?: PrintOptions): Promise; getPrintQuality(id?: string): PrintQuality | null; canPrint(id?: string): boolean; listPages(id?: string): readonly PageInfo[]; getPage(page: PageRef | number, id?: string): PageInfo | null; getPageIndex(ref: PageRef, id?: string): number; getRevision(id?: string): number; readonly onOpened: EventHook; readonly onOpenFailed: EventHook; readonly onLocked: EventHook; readonly onClosed: EventHook; readonly onActiveChanged: EventHook; readonly onPagesChanged: EventHook; readonly onUnsavedChangesChanged: EventHook; } DocumentsToken [VariableDeclaration] (from packages/core/main/src/types.ts): DocumentsToken: CapabilityToken ={ name: 'documents'} DoorEngine [InterfaceDeclaration] (from packages/viewer/main/src/kernel/element.ts): export interface DoorEngine{ readonly engine: Engine | EngineFactory; readonly sourceOf?: SourceOf; readonly follows?: (opened: ElementSrc, next: ElementSrc) => boolean; readonly plugins?: ViewerPluginsConfig; } ElementConfig [InterfaceDeclaration] (from packages/viewer/main/src/kernel/config.ts): export interface ElementConfig extends ViewerConfigBase{ engine?: unknown; } ElementSrc [TypeAliasDeclaration] (from packages/viewer/main/src/kernel/config.ts): export type ElementSrc = DocumentSrc | OpenInput | object; EmbedPdfViewerElement [ClassDeclaration] (from packages/viewer/main/src/kernel/element.ts): export class EmbedPdfViewerElement extends ElementBase{ static observedAttributes = ['src', 'locale', 'theme']; static defaultEngineProvider: DefaultEngineProvider | null = null; #config: ElementConfig | null = null; #wrapper: HTMLDivElement | null = null; #root: Root | null = null; #shown: ElementConfig | null = null; #props: FullViewerProps | null = null; #sourceOf: SourceOf = (src) => src; #follows: DoorEngine['follows']; #viewer: Viewer | null = null; #srcDocument: SrcDocument | null = null; #closing = new Set(); #fetch: HostFetch = (url, init) =>{ const download = this.#shown?.fetch ?? globalThis.fetch; return download(url, init); } ; set config(config: ElementConfig){ this.#config = config; this.#update(); } get config(): ElementConfig{ return mergeConfig(configFromAttributes(this), this.#config); } set src(src: ElementSrc | null | undefined){ this.#change({ src} ); } get src(): ElementSrc | null{ return this.config.src ?? null; } set theme(theme: ElementConfig['theme']){ this.#change({ theme} ); } get theme(): ElementConfig['theme']{ return this.config.theme; } set locale(locale: ElementConfig['locale']){ this.#change({ locale} ); } get locale(): ElementConfig['locale']{ return this.config.locale; } set features(features: ElementConfig['features']){ this.#change({ features} ); } get features(): ElementConfig['features']{ return this.config.features; } set disable(disable: ElementConfig['disable']){ this.#change({ disable} ); } get disable(): ElementConfig['disable']{ return this.config.disable; } set readOnly(readOnly: ElementConfig['readOnly']){ this.#change({ readOnly} ); } get readOnly(): ElementConfig['readOnly']{ return this.config.readOnly; } set fetch(fetch: ElementConfig['fetch']){ this.#change({ fetch} ); } get fetch(): ElementConfig['fetch']{ return this.config.fetch; } set appState(appState: ElementConfig['appState']){ this.#change({ appState} ); } get appState(): ElementConfig['appState']{ return this.config.appState; } get viewer(): Viewer | null{ return this.#viewer; } connectedCallback(): void{ for (const property of PROPERTIES){ if (!Object.prototype.hasOwnProperty.call(this, property)) continue; const value: unknown = Reflect.get(this, property); Reflect.deleteProperty(this, property); Reflect.set(this, property, value); } if (this.hasAttribute(WRAPPED_ATTRIBUTE) && this.#config === null) return; queueMicrotask(() =>{ if (this.isConnected && !this.#root) this.#mount(); } ); } disconnectedCallback(): void{ this.#unmount(); } attributeChangedCallback(): void{ if (this.#root) this.#update(); } #change(change: Partial): void{ this.config ={ ...this.#config, ...change} ; } #update(): void{ if (!this.isConnected) return; const shown = this.#shown; if (!this.#root || !shown){ this.#mount(); return; } const next = this.config; const changed = changedConfigKeys(shown, next); if (changed.length === 0) return; if (!changed.every(isLiveConfigKey)){ this.#mount(); return; } this.#shown = next; if (changed.includes('theme')) this.#adoptSheets(next.theme); if (changed.some((key) => key !== 'src' && key !== 'fetch')){ const{ theme, locale, features, disable, readOnly, appState} = next; this.#props ={ ...this.#props!, theme, locale, features, disable, readOnly, appState} ; this.#root.render(createElement(FullViewer, this.#props)); } if (changed.includes('src')) this.#showSrc(); } #unmount(): void{ this.#viewer = null; this.#srcDocument = null; this.#closing.clear(); this.#shown = null; this.#props = null; this.#root?.unmount(); this.#root = null; } #onReady = (viewer: Viewer): void =>{ this.#viewer = viewer; this.#showSrc(); this.dispatchEvent(new CustomEvent('epdf:ready', { detail:{ viewer} } )); this.#shown?.onReady?.(viewer); } ; #onDocumentChange = (documentId: string | null): void =>{ this.dispatchEvent(new CustomEvent('epdf:documentchange', { detail:{ documentId} } )); this.#shown?.onDocumentChange?.(documentId); } ; #onPanelResize = (event: PanelResizeEvent): void =>{ this.dispatchEvent(new CustomEvent('epdf:panelresize', { detail: event} )); this.#shown?.onPanelResize?.(event); } ; #showSrc(): void{ const viewer = this.#viewer; const config = this.#shown; if (!viewer || !config || config.documents) return; const{ documents} = viewer; const previous = this.#srcDocument; if (previous && config.src != null && this.#follows?.(previous.input, config.src)) return; this.#srcDocument = null; const previousId = previous && documents.has(previous.id) ? previous.id : previous?.reserved; const position = previousId ? documents.getOrder().indexOf(previousId) : -1; let previousClosed: () => void = () =>{ } ; const closed = new Promise((resolve) => (previousClosed = resolve)); if (config.src != null) this.#openSrc(config.src, position, previous ? closed : undefined); if (previous){ const closingId = previous.id; this.#closing.add(closingId); const tried = new Set([previous.reserved, closingId]); const release = () =>{ this.#closing.delete(closingId); previousClosed(); } ; Promise.all([...tried].map((id) => documents.close(id))) .then(() => previous.opened) .then((id) => (id !== null && !tried.has(id) ? documents.close(id) : undefined)) .then(release, release); } } #openSrc(given: ElementSrc, position: number, after?: Promise): void{ const{ documents} = this.#viewer!; const src = this.#sourceOf(given); const id = this.#freeIdFor(src); const{ source, name} = documentFromSrc(src, id, after); const before = new Set(documents.getOrder()); const opening = documents.open(source, name !== undefined ?{ name} :{ } ); const reserved = documents.getOrder().find((tab) => !before.has(tab)); const opened = opening.then( ({ document} ) => document.id, () => null, ); if (!reserved) return; const shown: SrcDocument ={ reserved, id: isOpenInput(src) ? reserved : id, opened, input: src, } ; this.#srcDocument = shown; void opened.then((openedId) =>{ if (openedId !== null) shown.id = openedId; } ); if (position >= 0) documents.move(reserved, position); } #freeIdFor(src: ElementSrc): string{ const wanted = idOfSrc(src); const taken = (id: string) => this.#closing.has(id) || Boolean(this.#viewer?.documents.has(id)); let id = wanted; for (let index = 2; taken(id); index++) id = `${ wanted} #${ index} `; return id; } #adoptSheets(theme: ElementConfig['theme']): void{ const tokens = themeTokenCss(theme, ROOT); this.shadowRoot!.adoptedStyleSheets = [...adoptSheets(), ...(tokens ? [sheetOf(tokens)] : [])]; } #mount(): void{ if (!this.shadowRoot){ const shadow = this.attachShadow({ mode: 'open'} ); this.#wrapper = document.createElement('div'); this.#wrapper.setAttribute(ROOT_ATTRIBUTE, ''); shadow.appendChild(this.#wrapper); } this.#unmount(); const config = this.config; warnInvalidConfig(config); const{ src: _src, documents, engine: _engine, theme, fetch: _fetch, ...customization} = config; this.#adoptSheets(theme); this.#shown = config; const{ engine, sourceOf = (src) => src, follows, plugins} = engineOf(config); this.#sourceOf = sourceOf; this.#follows = follows; this.#props ={ engine, initialDocuments: documents && initialDocumentsOf(documents, sourceOf), fetch: this.#fetch, theme, themeTarget: this.#wrapper, components: placedComponentsOf(this), ...customization, plugins: pluginsOf(plugins, customization.plugins), onReady: this.#onReady, onDocumentChange: this.#onDocumentChange, onPanelResize: this.#onPanelResize, } ; this.#root = createRoot(this.#wrapper!); this.#root.render(createElement(FullViewer, this.#props)); } } Engine [InterfaceDeclaration] (from packages/engine/core/src/engine/Engine.ts): export interface Engine{ readonly canOpenFiles: boolean; open(input: OpenInput, options?: OpenOptions): AbortablePromise; destroy(): AbortablePromise; } EngineFactory [TypeAliasDeclaration] (from packages/engine/core/src/engine/Engine.ts): export type EngineFactory = () => Engine; EpdfButtonElement [ClassDeclaration] (from packages/viewer/main/src/kernel/components.ts): export class EpdfButtonElement extends PlacedElement{ static observedAttributes = ['command', 'icon', 'label', 'active']; get command(): string | null{ return attributeOf(this, 'command'); } set command(command: string | null){ setAttributeOf(this, 'command', command); } get icon(): string | null{ return attributeOf(this, 'icon'); } set icon(icon: string | null){ setAttributeOf(this, 'icon', icon); } get label(): string | null{ return attributeOf(this, 'label'); } set label(label: string | null){ setAttributeOf(this, 'label', label); } get active(): boolean{ return isActive(this); } set active(active: boolean){ setActive(this, active); } protected describe(root: ShadowRoot): PlacedComponent{ return{ kind: 'button', host: this, root, command: this.command, icon: this.icon, label: this.label, active: this.active, } ; } } EpdfIconElement [ClassDeclaration] (from packages/viewer/main/src/kernel/components.ts): export class EpdfIconElement extends PlacedElement{ static observedAttributes = ['name', 'size', 'label']; protected get focusable(): boolean{ return false; } get name(): string | null{ return attributeOf(this, 'name'); } set name(name: string | null){ setAttributeOf(this, 'name', name); } get size(): number | null{ const size = Number.parseFloat(attributeOf(this, 'size') ?? ''); return Number.isFinite(size) && size > 0 ? size : null; } set size(size: number | null){ setAttributeOf(this, 'size', size === null || size === undefined ? null : String(size)); } get label(): string | null{ return attributeOf(this, 'label'); } set label(label: string | null){ setAttributeOf(this, 'label', label); } protected describe(root: ShadowRoot): PlacedComponent{ return{ kind: 'icon', host: this, root, icon: this.name, size: this.size, label: this.label, } ; } } EpdfMenuElement [ClassDeclaration] (from packages/viewer/main/src/kernel/components.ts): export class EpdfMenuElement extends PlacedElement{ static observedAttributes = ['icon', 'label']; #rows: MutationObserver | null = null; get icon(): string | null{ return attributeOf(this, 'icon'); } set icon(icon: string | null){ setAttributeOf(this, 'icon', icon); } get label(): string | null{ return attributeOf(this, 'label'); } set label(label: string | null){ setAttributeOf(this, 'label', label); } connectedCallback(): void{ this.#rows ??= new MutationObserver(() => this.changed()); this.#rows.observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['command', 'icon', 'active'], } ); super.connectedCallback(); } disconnectedCallback(): void{ this.#rows?.disconnect(); super.disconnectedCallback(); } protected describe(root: ShadowRoot): PlacedComponent{ const items = [...this.children] .filter((child) => child.localName === 'epdf-menu-item') .map( (row): PlacedMenuItem => ({ command: attributeOf(row, 'command'), icon: attributeOf(row, 'icon'), label: row.textContent?.trim() ?? '', active: isActive(row), select: () => row.dispatchEvent(new CustomEvent('select', { bubbles: true} )), } ), ); return{ kind: 'menu', host: this, root, icon: this.icon, label: this.label, items} ; } } EpdfMenuItemElement [ClassDeclaration] (from packages/viewer/main/src/kernel/components.ts): export class EpdfMenuItemElement extends ElementBase{ get command(): string | null{ return attributeOf(this, 'command'); } set command(command: string | null){ setAttributeOf(this, 'command', command); } get icon(): string | null{ return attributeOf(this, 'icon'); } set icon(icon: string | null){ setAttributeOf(this, 'icon', icon); } get active(): boolean{ return isActive(this); } set active(active: boolean){ setActive(this, active); } } Feature [TypeAliasDeclaration] (from packages/viewer/chrome/src/features.ts): export type Feature ={ [Name in keyof FeatureParts]: Name | `${ Name} .${ FeatureParts[Name][number]} `; } [keyof FeatureParts]; Features [TypeAliasDeclaration] (from packages/viewer/chrome/src/features.ts): export type Features ={ readonly [Name in Feature]?: boolean} &{ readonly [yours: string]: boolean | undefined; } ; FloatPosition [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type FloatPosition = | 'top-start' | 'top' | 'top-end' | 'start' | 'end' | 'bottom-start' | 'bottom' | 'bottom-end'; FormToken [VariableDeclaration] (from packages/plugin/form/src/token.ts): FormToken = createCapabilityToken('form', { hint: `add formPlugin() from '@embedpdf/plugin-form' to your plugins list`, promises:{ setValue: true, setValues: true, importValues: true, reset: true, activateWidget: true, export: true, import: true, refresh: true, create: true, addWidget: true, duplicate: true, duplicateWidgets: true, update: true, delete: true, removeWidget: true, updateWidget: true, deleteWidget: true, reorderCalculations: true, repair: true, } , } ) I18nToken [VariableDeclaration] (from packages/plugin/i18n/src/token.ts): I18nToken = createCapabilityToken('i18n', { hint: `add i18nPlugin() from '@embedpdf/plugin-i18n' to your plugins list`, } ) Icon [FunctionDeclaration] (from packages/viewer/react/src/viewer-components.ts): export function Icon({ name, size, label, className, style} : IconProps){ return createElement('epdf-icon', { name, size, label, style, ...(className === undefined ?{ } :{ class: className} ), } ); } IconDef [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/icons.tsx): export type IconDef = IconPaths |{ readonly paths: IconPaths; readonly fill?: boolean} ; IconName [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/icons.tsx): export type IconName = keyof typeof ICON_PATHS; IconPaths [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/icons.tsx): export type IconPaths = string | readonly PathSpec[]; IconProps [InterfaceDeclaration] (from packages/viewer/react/src/viewer-components.ts): export interface IconProps{ name: string; size?: number; label?: string; className?: string; style?: CSSProperties; } Identity [InterfaceDeclaration] (from packages/engine/core/src/auth/scope/types.ts): export interface Identity{ readonly userId?: string; readonly displayName?: string; readonly email?: string; readonly title?: string; readonly organization?: string; readonly organizationalUnit?: string; readonly groupId?: string; } Importance [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type Importance = 1 | 2 | 3 | 4 | 5; InitOptions [InterfaceDeclaration] (from packages/viewer/main/src/local/config.ts): export interface InitOptions extends ViewerConfig, MountTarget{ } InteractionToken [VariableDeclaration] (from packages/plugin/interaction/src/token.ts): InteractionToken = createCapabilityToken('interaction', { hint: `add interactionPlugin() from '@embedpdf/plugin-interaction' to your plugins list`, } ) LanguageStrings [TypeAliasDeclaration] (from packages/viewer/chrome/src/locales/index.ts): export type LanguageStrings = TranslationDictionary | StringsLoader; Layout [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface Layout{ place(bar: string, place: BarPlace): Layout; addBar(id: string, bar: LayoutBar): Layout; removeBar(ids: string | readonly string[]): Layout; add(item: LayoutItem, options: AddItemOptions): Layout; remove(ids: string | readonly string[], options: RemoveItemOptions): Layout; replace(id: string, item: LayoutItem): Layout; addMenu(id: string, sections: LayoutMenu): Layout; addPanel(id: string, panel: LayoutPanel): Layout; panel(id: string, changes: LayoutPanelPatch): Layout; panels(changes: LayoutPanelPatch): Layout; removePanel(id: string): Layout; tabs(visibility: TabsVisibility): Layout; toJSON(): LayoutData; } LayoutBar [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutBar{ readonly place: BarPlace; readonly mode?: string; readonly title?: string; readonly titleKey?: string; readonly start?: LayoutSection; readonly center?: LayoutSection; readonly end?: LayoutSection; } LayoutCommandItem [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutCommandItem{ readonly command: string; readonly variants?: readonly Variant[]; readonly importance?: Importance; readonly emphasis?: Emphasis; } LayoutCustomItem [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutCustomItem{ readonly custom: string; readonly command?: string; readonly variants?: readonly string[]; readonly importance?: Importance; readonly grow?: boolean; } LayoutData [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutData{ readonly bars?: Readonly>; readonly menus?: Readonly>; readonly panels?: Readonly>; readonly tabs?: TabsVisibility; } LayoutEnv [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutEnv{ readonly size: ViewerSize; readonly width: number; readonly touch: boolean; readonly dir: 'ltr' | 'rtl'; } LayoutFunction [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutFunction = (layout: Layout, env: LayoutEnv) => Layout | LayoutData; LayoutGroup [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutGroup = readonly LayoutItem[] | LayoutGroupObject; LayoutGroupObject [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutGroupObject{ readonly id?: string; readonly items: readonly LayoutItem[]; readonly collapse?: 'menu' | 'select'; readonly shed?: boolean; readonly importance?: Importance; readonly titleKey?: string; readonly dependent?: boolean; } LayoutItem [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutItem = string | LayoutCommandItem | LayoutCustomItem; LayoutMenu [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutMenu = readonly LayoutMenuSection[]; LayoutMenuSection [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutMenuSection = | readonly string[] |{ readonly title?: string; readonly titleKey?: string; readonly items: readonly string[]; } ; LayoutOption [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutOption = Layout | LayoutData | LayoutFunction; LayoutPanel [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutPanel{ readonly side?: 'start' | 'end'; readonly title?: string; readonly titleKey?: string; readonly icon?: string; readonly present?: PanelPresentation | PanelPresentationBySize; readonly width?: number | PanelWidth; readonly resizable?: boolean; readonly open?: boolean; readonly closable?: boolean; } LayoutPanelPatch [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutPanelPatch = Partial; LayoutSection [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutSection = readonly (LayoutGroup | LayoutItem)[]; LinkToken [VariableDeclaration] (from packages/plugin/link/src/token.ts): LinkToken = createCapabilityToken('link', { hint: `add linkPlugin() from '@embedpdf/plugin-link' to your plugins list`, promises:{ readAllLinks: true, ensureLoaded: true, } , } ) LiveConfigKey [TypeAliasDeclaration] (from packages/viewer/main/src/kernel/config.ts): export type LiveConfigKey = | 'src' | 'theme' | 'locale' | 'features' | 'disable' | 'readOnly' | 'fetch' | 'appState'; LocalEngineConfig [TypeAliasDeclaration] (from packages/viewer/main/src/local/config.ts): export type LocalEngineConfig = Omit; LocalEngineRecipeOptions [InterfaceDeclaration] (from packages/engine/main/src/index.ts): export interface LocalEngineRecipeOptions extends WasmSourceOptions{ worker?: WorkerSource; encoderWorker?: EncoderWorkerSource; fallbackFonts?: RecipeFontSpec[]; fonts?: RecipeFontSpec[]; defaultFallbackFonts?: boolean; concurrency?: number; imageEncoder?: LocalImageEncoder; renderPolicy?: EngineRenderPolicy; signedDocumentPolicy?: LocalEngineOptions['signedDocumentPolicy']; runtime?: CreatePdfRuntimeOptions; } Mark [TypeAliasDeclaration] (from packages/plugin/signature/src/contract.ts): export type Mark ={ assetId: string} |{ source: BinarySource} ; MeasurementToken [VariableDeclaration] (from packages/plugin/measurement/src/token.ts): MeasurementToken = createCapabilityToken('measurement', { hint: `add measurementPlugin() from '@embedpdf/plugin-measurement' to your plugins list`, promises:{ ensureLoaded: true, setScale: true, calibrate: true, setUnit: true, setAreaUnit: true, setPrecision: true, setPreset: true, clearScale: true, createMeasurement: true, } , } ) Menu [FunctionDeclaration] (from packages/viewer/react/src/viewer-components.ts): export function Menu({ icon, label, children} : MenuProps){ return createElement('epdf-menu', { icon, label} , children); } MenuItem [FunctionDeclaration] (from packages/viewer/react/src/viewer-components.ts): export function MenuItem({ command, icon, active, onSelect, children} : MenuItemProps){ const element = useRef(null); const select = useRef(onSelect); select.current = onSelect; useEffect(() =>{ const target = element.current; if (!target) return; const onPicked = () => select.current?.(); target.addEventListener('select', onPicked); return () => target.removeEventListener('select', onPicked); } , []); return createElement( 'epdf-menu-item', { ref: element, command, icon, active: activeOf(active)} , children, ); } MenuItemProps [InterfaceDeclaration] (from packages/viewer/react/src/viewer-components.ts): export interface MenuItemProps{ command?: string; icon?: string; active?: boolean; onSelect?: () => void; children?: ReactNode; } MenuProps [InterfaceDeclaration] (from packages/viewer/react/src/viewer-components.ts): export interface MenuProps{ icon?: string; label: string; children?: ReactNode; } MetadataToken [VariableDeclaration] (from packages/plugin/metadata/src/token.ts): MetadataToken = createCapabilityToken('metadata', { hint: "add metadataPlugin() from '@embedpdf/plugin-metadata' to your plugins list", promises:{ update: true, refresh: true, ensureLoaded: true, 'custom.update': true, 'custom.refresh': true, } , } ) MountTarget [InterfaceDeclaration] (from packages/viewer/main/src/kernel/init.ts): export interface MountTarget{ target: HTMLElement | string; } NotAllowedMode [TypeAliasDeclaration] (from packages/plugin/commands/src/contract.ts): export type NotAllowedMode = 'hide' | 'disable'; PDFViewer [VariableDeclaration]: PDFViewer: (props: PDFViewerProps) => ReturnType = PDFViewerImpl PDFViewerExtras [InterfaceDeclaration] (from packages/viewer/react/src/component.ts): export interface PDFViewerExtras{ className?: string; style?: CSSProperties; children?: ReactNode; elementRef?: Ref; } PDFViewerImplProps [TypeAliasDeclaration] (from packages/viewer/react/src/component.ts): export type PDFViewerImplProps = ElementConfig & PDFViewerExtras; PDFViewerProps [TypeAliasDeclaration]: export type PDFViewerProps = ViewerConfig & PDFViewerExtras; PageEditToken [VariableDeclaration] (from packages/plugin/page-edit/src/token.ts): PageEditToken = createCapabilityToken('page-edit', { hint: `add pageEditPlugin() from '@embedpdf/plugin-page-edit' to your plugins list`, promises:{ rotateBy: true, setRotation: true, reorder: true, delete: true, insertBlank: true, insertFromBytes: true, insertFromDocument: true, duplicate: true, extract: true, } , } ) Panel [FunctionDeclaration] (from packages/viewer/react/src/slots.ts): export function Panel({ id, children} : PanelProps){ return createElement('div', { slot: `panel:${ id} `, style: CONTENTS} , children); } PanelPresentation [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type PanelPresentation = 'dock' | 'overlay' | 'sheet'; PanelPresentationBySize [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface PanelPresentationBySize{ readonly compact?: PanelPresentation; readonly medium?: PanelPresentation; readonly expanded?: PanelPresentation; } PanelProps [InterfaceDeclaration] (from packages/viewer/react/src/slots.ts): export interface PanelProps{ id: string; children?: ReactNode; } PanelResizeEvent [InterfaceDeclaration] (from packages/viewer/chrome/src/config-context.tsx): export interface PanelResizeEvent{ readonly id: string; readonly width: number; } PanelWidth [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface PanelWidth{ readonly initial?: number; readonly min?: number; readonly max?: number; } PathSpec [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/icons.tsx): export type PathSpec = | string |{ d: string; fill?: boolean | 'primary' | 'secondary'; stroke?: 'primary' | 'secondary'; strokeWidth?: number; strokeDasharray?: string; strokeOpacity?: number; fillOpacity?: number; } ; PluginName [TypeAliasDeclaration] (from packages/viewer/chrome/src/handle.ts): export type PluginName = keyof ViewerPlugins; PluginSettings [TypeAliasDeclaration] (from packages/viewer/chrome/src/plugin-settings.ts): export type PluginSettings = BuiltInSettings[Name]; ReadOnlyExceptions [InterfaceDeclaration] (from packages/viewer/chrome/src/features.ts): export interface ReadOnlyExceptions{ readonly except: readonly (Feature | (string &{ } ))[]; } RedactionToken [VariableDeclaration] (from packages/plugin/redaction/src/token.ts): RedactionToken = createCapabilityToken('redaction', { hint: `add redactionPlugin() from '@embedpdf/plugin-redaction' to your plugins list`, promises:{ markSelection: true, markArea: true, markPage: true, markMatches: true, unmark: true, clearPending: true, updateLabel: true, apply: true, applyAll: true, applyPages: true, } , } ) Region [FunctionDeclaration] (from packages/viewer/react/src/slots.ts): export function Region({ name, children} : RegionProps){ return createElement('div', { slot: name, style: CONTENTS} , children); } RegionName [TypeAliasDeclaration] (from packages/viewer/react/src/slots.ts): export type RegionName = 'header' | 'footer' | 'tabs' | 'empty'; RegionProps [InterfaceDeclaration] (from packages/viewer/react/src/slots.ts): export interface RegionProps{ name: RegionName; children?: ReactNode; } RemoveItemOptions [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface RemoveItemOptions{ readonly from: string; } RenderToken [VariableDeclaration] (from packages/plugin/render/src/token.ts): RenderToken = createCapabilityToken('render', { hint: `add renderPlugin() from '@embedpdf/plugin-render' to your plugins list`, promises:{ renderPage: true, renderThumbnail: true, renderPages: true, } , } ) ResolvedCommand [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface ResolvedCommand{ readonly id: string; readonly label: string; readonly icon?: string; readonly iconAccent?: IconAccent; readonly shortcuts: readonly string[]; readonly menu?: string; readonly enabled: boolean; readonly active: boolean; readonly pressable: boolean; readonly visible: boolean; readonly categories: readonly string[]; readonly disabledReason?: string; } ScopedViewer [InterfaceDeclaration] (from packages/viewer/chrome/src/handle.ts): export interface ScopedViewer{ get(name: Name): ViewerPlugins[Name]; get(token: CapabilityToken): Capability; tryGet(name: Name): ViewerPlugins[Name] | null; tryGet(token: CapabilityToken): Capability | null; } SearchToken [VariableDeclaration] (from packages/plugin/search/src/token.ts): SearchToken = createCapabilityToken('search', { hint: "add searchPlugin() from '@embedpdf/plugin-search' to your plugins list", promises:{ search: true, refresh: true, findAll: true, } , } ) SectionName [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type SectionName = 'start' | 'center' | 'end'; SelectionTarget [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type SelectionTarget = 'selection' | 'annotation' | 'snapshot'; SelectionToken [VariableDeclaration] (from packages/plugin/selection/src/token.ts): SelectionToken = createCapabilityToken('selection', { hint: `add selectionPlugin() from '@embedpdf/plugin-selection' to your plugins list`, promises:{ readText: true, readTextInRange: true, } , } ) ShellToken [VariableDeclaration] (from packages/plugin/shell/src/token.ts): ShellToken = createCapabilityToken('shell', { hint: `add shellPlugin() from '@embedpdf/plugin-shell' to your plugins list`, } ) SignFieldInput [InterfaceDeclaration] (from packages/plugin/signature/src/contract.ts): export interface SignFieldInput{ field: FormFieldRef; mark: Mark; signingKey?: SigningKey; timestampAuthority?: CmsSigner | null; signer?: SignatureSignerInput; appearance?: BinarySource; certify?:{ permission: DocMdpPermission} ; lock?: FieldLockSpec; } SignatureFont [InterfaceDeclaration] (from packages/viewer/chrome/src/plugin-settings.ts): export interface SignatureFont{ readonly key: string; readonly label: string; readonly url?: string; readonly data?: Uint8Array | ArrayBuffer; } SignatureMode [TypeAliasDeclaration] (from packages/plugin/signature/src/contract.ts): export type SignatureMode = 'sign' | 'visual' | 'ask'; SignatureToken [VariableDeclaration] (from packages/plugin/signature/src/token.ts): SignatureToken = createCapabilityToken('signature', { hint: `add signaturePlugin() from '@embedpdf/plugin-signature' to your plugins list`, promises:{ sign: true, prepareSignature: true, completeSignature: true, cancelPending: true, fillField: true, clearField: true, placeMark: true, refresh: true, validate: true, validateField: true, addValidationInfo: true, analyzeChanges: true, readRevision: true, } , } ) SignerPort [TypeAliasDeclaration] (from packages/core/signature/src/sign.ts): export type SignerPort = CmsSigner | RawSigner; StageToken [VariableDeclaration] (from packages/plugin/stage/src/token.ts): StageToken = createCapabilityToken('stage', { hint: `add stagePlugin() from '@embedpdf/plugin-stage' to your plugins list`, } ) StampLibraryFile [InterfaceDeclaration] (from packages/viewer/chrome/src/plugin-settings.ts): export interface StampLibraryFile{ readonly id: string; readonly url?: string; readonly data?: Uint8Array | ArrayBuffer; } StampToken [VariableDeclaration] (from packages/plugin/stamp/src/token.ts): StampToken = createCapabilityToken('stamp', { hint: `add stampPlugin() from '@embedpdf/plugin-stamp' to your plugins list`, } ) StringsLoader [TypeAliasDeclaration] (from packages/viewer/chrome/src/locales/index.ts): export type StringsLoader = () => Promise< TranslationDictionary |{ readonly default: TranslationDictionary} >; TabsVisibility [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type TabsVisibility = 'always' | 'multiple' | 'never'; ThemeConfig [InterfaceDeclaration] (from packages/viewer/chrome/src/ui/theme.tsx): export interface ThemeConfig{ preference?: ThemePreference; accent?: string; tokens?: ThemeTokens; light?: ThemeTokens; dark?: ThemeTokens; } ThemeMode [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/theme.tsx): export type ThemeMode = 'light' | 'dark'; ThemePreference [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/theme.tsx): export type ThemePreference = ThemeMode | 'system'; ThemeToken [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/theme.tsx): export type ThemeToken = (typeof THEME_TOKENS)[number]; ThemeTokens [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/theme.tsx): export type ThemeTokens ={ readonly [Name in ThemeToken]?: string} ; ToolbarItem [FunctionDeclaration] (from packages/viewer/react/src/slots.ts): export function ToolbarItem({ id, children} : ToolbarItemProps){ const element = useRef(null); const [store] = useState(() => contextStoreOf(element)); const context = useSyncExternalStore(store.subscribe, store.read, atTheTop); return createElement( ToolbarItemReactContext.Provider, { value: context} , createElement('div', { ref: element, slot: `item:${ id} `, style: CONTENTS} , children), ); } ToolbarItemContext [InterfaceDeclaration] (from packages/viewer/chrome/src/ui/item-context.ts): export interface ToolbarItemContext{ readonly orientation: 'horizontal' | 'vertical'; readonly edge: ToolbarItemEdge; readonly variant: string | null; readonly size: ViewerSize; } ToolbarItemEdge [TypeAliasDeclaration] (from packages/viewer/chrome/src/ui/item-context.ts): export type ToolbarItemEdge = 'top' | 'bottom' | 'start' | 'end' | 'float' | 'selection'; ToolbarItemProps [InterfaceDeclaration] (from packages/viewer/react/src/slots.ts): export interface ToolbarItemProps{ id: string; children?: ReactNode; } TrustPort [InterfaceDeclaration] (from packages/core/signature/src/trust.ts): export interface TrustPort{ anchors(): Promise; timestampAnchors?(): Promise; } Unsubscribe [TypeAliasDeclaration] (from packages/core/main/src/types.ts): export type Unsubscribe = () => void; Variant [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type Variant = 'icon+label' | 'icon' | 'label'; Viewer [InterfaceDeclaration] (from packages/viewer/chrome/src/handle.ts): export interface Viewer extends ScopedViewer{ readonly documents: DocumentsCapability; readonly commands: CommandsCapability; forDocument(documentId: string): ScopedViewer; watch( read: () => T, onChange: (value: T, previous: Immediate extends true ? T | undefined : T) => void, options?: WatchOptions, ): Unsubscribe; } ViewerConfig [InterfaceDeclaration] (from packages/viewer/main/src/local/config.ts): export interface ViewerConfig extends ViewerConfigBase{ engine?: Engine | EngineFactory | LocalEngineConfig; } ViewerConfigBase [InterfaceDeclaration] (from packages/viewer/main/src/kernel/config.ts): export interface ViewerConfigBase< Src = DocumentSrc, AppState = any, > extends ViewerCustomization{ src?: Src | null; documents?: readonly DocumentEntry[]; fetch?: HostFetch; } ViewerCustomization [InterfaceDeclaration] (from packages/viewer/chrome/src/viewer.tsx): export interface ViewerCustomization{ commands?: readonly CommandDefinition[]; appState?: AppState; icons?: Readonly>; strings?: Readonly>; locale?: 'auto' | (string &{ } ); features?: Features; disable?: readonly (Feature | (string &{ } ))[]; readOnly?: boolean | ReadOnlyExceptions; scope?: readonly string[] | null; identity?: Identity | null; notAllowed?: NotAllowedMode; layout?: LayoutOption; size?: 'auto' | ViewerSize; touch?: 'auto' | boolean; plugins?: ViewerPluginsConfig; fonts?: readonly ViewerFont[]; warnBeforeLeaving?: boolean; theme?: ThemePreference | ThemeConfig; onReady?: (viewer: Viewer) => void; onDocumentChange?: (documentId: string | null) => void; onPanelResize?: (event: PanelResizeEvent) => void; } ViewerFont [InterfaceDeclaration] (from packages/viewer/chrome/src/config-context.tsx): export interface ViewerFont{ readonly key: string; readonly url?: string; readonly data?: Uint8Array | ArrayBuffer; readonly familyName?: string; readonly weight?: number; readonly italic?: boolean; readonly label?: string; } ViewerPlugins [InterfaceDeclaration] (from packages/viewer/chrome/src/handle.ts): export interface ViewerPlugins{ readonly stage: StageCapability; readonly thumbnails: StageCapability; readonly render: RenderCapability; readonly link: LinkCapability; readonly selection: SelectionCapability; readonly search: SearchCapability; readonly annotation: AnnotationCapability; readonly stamp: StampCapability; readonly measurement: MeasurementCapability; readonly redaction: RedactionCapability; readonly form: FormCapability; readonly signature: SignatureCapability; readonly pageEdit: PageEditCapability; readonly metadata: MetadataCapability; readonly fonts: FontsCapability; readonly outline: OutlineCapability; readonly attachment: AttachmentCapability; readonly actions: ActionsCapability; readonly documents: DocumentsCapability; readonly interaction: InteractionCapability; readonly commands: CommandsCapability; readonly shell: ShellCapability; readonly i18n: I18nCapability; } ViewerPluginsConfig [TypeAliasDeclaration] (from packages/viewer/chrome/src/plugin-settings.ts): export type ViewerPluginsConfig ={ readonly [Name in PluginName]?: PluginSettings; } &{ readonly [name: string]: object | undefined; } ; ViewerSignatureSettings [InterfaceDeclaration] (from packages/viewer/chrome/src/plugin-settings.ts): export interface ViewerSignatureSettings{ readonly kinds?: readonly ('signature' | 'initials')[]; readonly fonts?: readonly SignatureFont[]; readonly libraries?: 'one' | 'many'; } ViewerSize [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type ViewerSize = 'compact' | 'medium' | 'expanded'; ViewerStampSettings [InterfaceDeclaration] (from packages/viewer/chrome/src/plugin-settings.ts): export interface ViewerStampSettings{ readonly standard?: boolean | string; readonly libraries?: readonly StampLibraryFile[]; readonly quick?: readonly string[]; readonly sidebar?: readonly string[]; } WatchOptions [InterfaceDeclaration] (from packages/viewer/chrome/src/handle.ts): export interface WatchOptions{ readonly immediate?: Immediate; readonly isEqual?: (left: T, right: T) => boolean; } createLayout [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function createLayout(data: LayoutData ={ } ): Layout{ return layoutOf(data, []); } createTestCertificateAuthority [FunctionDeclaration] (from packages/core/signature/src/signers/test-authority.ts): export async function createTestCertificateAuthority( options:{ commonName?: string; url?: string; now?: () => Date} ={ } , ): Promise{ ensureEngine(); const now = options.now ?? (() => new Date()); const url = (options.url ?? 'http://test-authority.example').replace(/\/$/, ''); const addresses ={ ocsp: `${ url} /ocsp`, crl: `${ url} /crl`, issuer: `${ url} /issuer`} ; const commonName = options.commonName ?? 'EmbedPDF test certificate authority'; const dates = () => ({ notBefore: new Date(now().getTime() - DAY), notAfter: new Date(now().getTime() + 365 * DAY), } ); const rootKeys = await generateSigningKeyPair('RSA-PKCS1-v1_5', 'sha256', true); const root: Issuer ={ certificate: await issueCertificate({ kind: 'authority', commonName, publicKey: rootKeys.publicKey, privateKey: rootKeys.privateKey, ...dates(), } ), privateKey: rootKeys.privateKey, } ; const responderKeys = await generateSigningKeyPair('RSA-PKCS1-v1_5', 'sha256', true); const responder: Issuer ={ certificate: await issueCertificate({ kind: 'responder', commonName: `${ commonName} (OCSP responder)`, publicKey: responderKeys.publicKey, issuer: root, ...dates(), } ), privateKey: responderKeys.privateKey, } ; const der = (certificate: pkijs.Certificate) => new Uint8Array(certificate.toSchema(true).toBER(false)); const rootDer = der(root.certificate); const issued: pkijs.Certificate[] = []; const unrevocableOnes = new Set(); const revoked = new Map(); const serialOf = (certificate: pkijs.Certificate) => new Uint8Array(certificate.serialNumber.valueBlock.valueHexView); const bySerial = (serial: Uint8Array) => issued.find((certificate) => bytesEqual(serialOf(certificate), serial)) ?? null; const answer = async (request: RevocationRequest): Promise =>{ if (!request.url.startsWith(url)){ throw new Error(`the test certificate authority does not answer at ${ request.url} `); } if (request.kind === 'issuer') return rootDer; if (request.kind === 'crl'){ return buildCrl({ issuer: root, thisUpdate: now(), nextUpdate: new Date(now().getTime() + 7 * DAY), revoked: [...revoked].map(([certificate, entry]) => ({ serialNumber: certificate.serialNumber, at: entry.at, reason: entry.reason, } )), } ); } const parsed = asn1js.fromBER(toArrayBuffer(request.body)); if (parsed.offset === -1) throw new Error('the OCSP request is not valid DER'); const asked = new pkijs.OCSPRequest({ schema: parsed.result} ).tbsRequest.requestList[0]; if (!asked) throw new Error('the OCSP request asks about no certificate'); const certificate = bySerial( new Uint8Array(asked.reqCert.serialNumber.valueBlock.valueHexView), ); const entry = certificate ? revoked.get(certificate) : undefined; return buildOcspResponse({ certificate: certificate ?? root.certificate, issuer: root.certificate, asked: asked.reqCert, signer: responder, status: !certificate ? 'unknown' : entry ?{ revokedAt: entry.at, reason: entry.reason} : 'good', producedAt: now(), thisUpdate: now(), nextUpdate: new Date(now().getTime() + HOUR), } ); } ; return{ certificate: rootDer, async issueSigner(signerOptions ={ } ){ const hash = signerOptions.hash ?? 'sha256'; const keys = await generateSigningKeyPair( signerOptions.algorithm ?? 'RSA-PKCS1-v1_5', hash, true, ); const{ unrevocable} = signerOptions; const certificate = await issueCertificate({ kind: 'signer', commonName: signerOptions.commonName ?? 'EmbedPDF test signer', publicKey: keys.publicKey, issuer: root, addresses: unrevocable ?{ issuer: addresses.issuer} : addresses, ...(unrevocable ?{ unrevocable} :{ } ), ...dates(), } ); issued.push(certificate); if (unrevocable) unrevocableOnes.add(certificate); const leaf = der(certificate); const signer = webCryptoSigner({ privateKey: keys.privateKey, certificateChain: [leaf, rootDer], hash, } ); return{ ...signer, certificate: leaf, privateKey: keys.privateKey} ; } , revocation:{ fetch: answer} , revoke(signer, revokeOptions ={ } ){ const bytes = signer instanceof Uint8Array ? signer : signer.certificate; const certificate = issued.find((candidate) => bytesEqual(der(candidate), bytes)); if (!certificate){ throw new Error('the test certificate authority did not issue this certificate'); } if (unrevocableOnes.has(certificate)){ throw new Error('this certificate was issued as one that cannot be withdrawn'); } revoked.set(certificate, { at: revokeOptions.at ?? now(), reason: revokeOptions.reason ?? null, } ); } , } ; } createTestSigner [FunctionDeclaration] (from packages/core/signature/src/signers/webcrypto.ts): export async function createTestSigner( options:{ commonName?: string; algorithm?: 'RSA-PKCS1-v1_5' | 'RSA-PSS' | 'ECDSA'; hash?: 'sha256' | 'sha384' | 'sha512'; } ={ } , ): Promise{ const{ selfSignedCertificate} = await import('./self-signed'); const hash = options.hash ?? 'sha256'; const keys = await generateSigningKeyPair(options.algorithm ?? 'RSA-PKCS1-v1_5', hash, true); const certificate = await selfSignedCertificate({ publicKey: keys.publicKey, privateKey: keys.privateKey, commonName: options.commonName ?? 'EmbedPDF test signer', hash, } ); const signer = webCryptoSigner({ privateKey: keys.privateKey, certificateChain: [certificate], hash, } ); return{ ...signer, certificate, privateKey: keys.privateKey} ; } createTestTimestampAuthority [FunctionDeclaration] (from packages/core/signature/src/signers/webcrypto.ts): export async function createTestTimestampAuthority( options:{ commonName?: string} ={ } , ): Promise{ const{ timestampAuthorityCertificate} = await import('./self-signed'); const keys = await generateSigningKeyPair('RSA-PKCS1-v1_5', 'sha256', true); const certificate = await timestampAuthorityCertificate({ publicKey: keys.publicKey, privateKey: keys.privateKey, commonName: options.commonName ?? 'EmbedPDF test timestamp authority', hash: 'sha256', } ); const authority = webCryptoSigner({ privateKey: keys.privateKey, certificateChain: [certificate], } ); const{ buildTimestampToken} = await import('../cms/timestamp'); return{ kind: 'cms', certificate, sign: ({ digest, algorithm} ) => buildTimestampToken({ digest, hash: algorithm, authority} ), } ; } defaultCommands [VariableDeclaration] (from packages/viewer/chrome/src/config/commands.ts): defaultCommands: CommandDefinition[] = [{ id: 'zoom:in', labelKey: 'commands.zoom.in', icon: 'zoomIn', shortcut: ['Mod+=', 'Mod+NumpadAdd'], run: (commandContext) => stage(commandContext)?.zoomIn(), enabled: (commandContext) => stage(commandContext)?.canZoomIn() ?? false, } , { id: 'zoom:out', labelKey: 'commands.zoom.out', icon: 'zoomOut', shortcut: ['Mod+-', 'Mod+NumpadSubtract'], run: (commandContext) => stage(commandContext)?.zoomOut(), enabled: (commandContext) => stage(commandContext)?.canZoomOut() ?? false, } , { id: 'zoom:fit-page', labelKey: 'commands.zoom.fitPage', icon: 'fitToPage', shortcut: 'Mod+0', run: (commandContext) => stage(commandContext)?.fitPage(), active: (commandContext) => stage(commandContext)?.getZoomMode() === ZoomMode.FitPage, enabled: (commandContext) => stage(commandContext) != null, } , { id: 'zoom:fit-width', labelKey: 'commands.zoom.fitWidth', icon: 'fitToWidth', shortcut: 'Mod+1', run: (commandContext) => stage(commandContext)?.fitWidth(), active: (commandContext) => stage(commandContext)?.getZoomMode() === ZoomMode.FitWidth, enabled: (commandContext) => stage(commandContext) != null, } , { id: 'zoom:automatic', labelKey: 'commands.zoom.automatic', run: (commandContext) => stage(commandContext)?.fitAutomatic(), active: (commandContext) => stage(commandContext)?.getZoomMode() === ZoomMode.Automatic, enabled: (commandContext) => stage(commandContext) != null, } , zoomLevel('zoom:50', 0.5, 'commands.zoom.p50'), zoomLevel('zoom:100', 1, 'commands.zoom.p100'), zoomLevel('zoom:150', 1.5, 'commands.zoom.p150'), zoomLevel('zoom:200', 2, 'commands.zoom.p200'), zoomLevel('zoom:400', 4, 'commands.zoom.p400'), { id: 'menu:zoom', labelKey: 'commands.zoom.menu', icon: 'zoomIn', menu: 'zoom', } , { id: 'page:next', labelKey: 'commands.page.next', icon: 'chevronRight', shortcut: 'ArrowRight', run: (commandContext) => stage(commandContext)?.nextPage(), enabled: (commandContext) => stage(commandContext)?.canGoNext() ?? false, visible: manyPages, } , { id: 'page:previous', labelKey: 'commands.page.previous', icon: 'chevronLeft', shortcut: 'ArrowLeft', run: (commandContext) => stage(commandContext)?.previousPage(), enabled: (commandContext) => stage(commandContext)?.canGoPrevious() ?? false, visible: manyPages, } , { id: 'page:first', labelKey: 'commands.page.first', shortcut: 'Home', run: (commandContext) => stage(commandContext)?.goToFirstPage(), enabled: (commandContext) => stage(commandContext)?.canGoPrevious() ?? false, visible: manyPages, } , { id: 'page:last', labelKey: 'commands.page.last', shortcut: 'End', run: (commandContext) => stage(commandContext)?.goToLastPage(), enabled: (commandContext) => stage(commandContext)?.canGoNext() ?? false, visible: manyPages, } , { id: 'page:go-to', labelKey: 'commands.page.goTo', run: (commandContext) =>{ const view = stage(commandContext); if (!view) return; const page = pageArgOf(commandContext.args); if (page === null){ commandContext.tryGet(ShellToken)?.open(GO_TO_PAGE_DIALOG, { exclusive: 'modal'} ); return; } view.goToPage(Math.min(Math.max(page, 1), view.getPageCount()) - 1); } , enabled: (commandContext) => (stage(commandContext)?.getPageCount() ?? 0) > 0, } , { id: 'tool:pan', labelKey: 'commands.pan', icon: 'hand', run: (commandContext) => interaction(commandContext)?.activateTool('pan'), active: (commandContext) => interaction(commandContext)?.getActiveToolId() === 'pan', enabled: (commandContext) => interaction(commandContext) != null, } , { id: 'tool:pointer', labelKey: 'commands.pointer', icon: 'pointer', run: (commandContext) => interaction(commandContext)?.activateTool('pointer'), active: (commandContext) => interaction(commandContext)?.getActiveToolId() === 'pointer', enabled: (commandContext) => interaction(commandContext) != null, } , { id: 'tool:zoom', labelKey: 'commands.zoom.marquee', icon: 'zoomInArea', run: (commandContext) => interaction(commandContext)?.activateTool('zoom'), active: (commandContext) => interaction(commandContext)?.getActiveToolId() === 'zoom', enabled: (commandContext) => interaction(commandContext) != null, } , { id: 'tool:snapshot', labelKey: 'commands.snapshot.tool', icon: 'screenshot', categories: ['snapshots'], allowed: (commandContext) => renderOf(commandContext)?.canSnapshot() ?? true, notAllowedKey: 'commands.notAllowed.doc-content-copy', run: (commandContext) => interaction(commandContext)?.activateTool(SNAPSHOT_TOOL), active: (commandContext) => interaction(commandContext)?.getActiveToolId() === SNAPSHOT_TOOL, enabled: (commandContext) => interaction(commandContext)?.hasTool(SNAPSHOT_TOOL) ?? false, } , { id: 'menu:document', labelKey: 'commands.menu', icon: 'menu', menu: 'document', } , { id: 'menu:view', labelKey: 'commands.viewControls', icon: 'viewSettings', menu: 'view', } , ...outlineCommands, ...attachmentCommands, ...commentCommands, ...pageCommands, openFileCommand, { id: 'document:download', labelKey: 'commands.download', icon: 'download', shortcut: 'Mod+S', categories: ['documents.download'], allowed: (commandContext) => commandContext.tryGet(DocumentsToken)?.canDownload() ?? true, notAllowedKey: 'commands.notAllowed.doc-download', run: (commandContext) =>{ if (!commandContext.tryGet(DocumentsToken)) return; Promise.resolve(standardDownload.run?.(commandContext)).catch((error: unknown) => console.warn('[embedpdf] download failed', error), ); } , enabled: (commandContext) => commandContext.documentId != null, } , { id: 'document:print', labelKey: 'commands.print', icon: 'print', shortcut: 'Mod+P', categories: ['documents.print'], allowed: (commandContext) => commandContext.tryGet(DocumentsToken)?.canPrint() ?? true, notAllowedKey: 'commands.notAllowed.doc-print', modal: PRINT_DIALOG, enabled: (commandContext) => commandContext.documentId != null, } , spread('view:single-page', 'none', 'commands.spread.none', 'singlePage'), spread('view:two-pages', 'odd', 'commands.spread.odd', 'doublePage'), spread('view:cover-page', 'even', 'commands.spread.even', 'book2'), scroll('view:scroll-vertical', 'vertical', 'commands.scroll.vertical', 'vertical'), scroll('view:scroll-horizontal', 'horizontal', 'commands.scroll.horizontal', 'horizontal'), { id: 'view:scroll-paged', labelKey: 'commands.scroll.paged', icon: 'pageByPage', run: (commandContext) => stage(commandContext)?.updateSettings({ flow: 'paged'} ), active: (commandContext) => stage(commandContext)?.getSettings().flow === 'paged', enabled: (commandContext) => stage(commandContext) != null, locked: (commandContext) => stage(commandContext)?.getLock('flow') ?? null, } , { id: 'view:rotate-clockwise', labelKey: 'commands.rotate.clockwise', icon: 'rotateClockwise', run: (commandContext) => stage(commandContext)?.rotateViewBy(90), enabled: (commandContext) => stage(commandContext) != null, locked: (commandContext) => stage(commandContext)?.getLock('viewRotation') ?? null, } , { id: 'view:rotate-counterclockwise', labelKey: 'commands.rotate.counterclockwise', icon: 'rotateCounterClockwise', run: (commandContext) => stage(commandContext)?.rotateViewBy(-90), enabled: (commandContext) => stage(commandContext) != null, locked: (commandContext) => stage(commandContext)?.getLock('viewRotation') ?? null, } , { id: 'mode:view', labelKey: 'commands.mode.view', run: (commandContext) =>{ const shell = commandContext.tryGet(ShellToken); const open = shell ? openModeSurfaceOf(shell) : null; if (open) shell?.close(open); interaction(commandContext)?.activateTool('pointer'); } , active: (commandContext) =>{ const shell = commandContext.tryGet(ShellToken); return shell ? openModeSurfaceOf(shell) === null : true; } , } , modeCommand('mode:annotate', 'commands.mode.annotate', { feature: 'annotations'} ), modeCommand('mode:shapes', 'commands.mode.shapes', { feature: 'shapes'} ), modeCommand('mode:insert', 'commands.mode.insert'), modeCommand('mode:form', 'commands.mode.form', { feature: 'forms.building'} ), modeCommand('mode:redact', 'commands.mode.redact', { feature: 'redaction'} ), modeCommand('mode:measure', 'commands.mode.measure', { feature: 'measurement'} ), tool('tool:highlight', 'highlight', 'commands.annotate.highlight', 'highlight', { feature: 'annotations.highlight', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:strikeout', 'strikeout', 'commands.annotate.strikeout', 'strikethrough', { feature: 'annotations.markup', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:underline', 'underline', 'commands.annotate.underline', 'underline', { feature: 'annotations.markup', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:squiggly', 'squiggly', 'commands.annotate.squiggly', 'squiggly', { feature: 'annotations.markup', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:ink', 'ink', 'commands.annotate.ink', 'pencilMarker', { feature: 'annotations.drawing', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:ink-highlight', 'ink-highlight', 'commands.annotate.inkHighlight', 'inkHighlighter', { feature: 'annotations.drawing', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:free-text', 'free-text', 'commands.annotate.text', 'freeText', { feature: 'annotations.text', check: CREATES_ANNOTATIONS, accent:{ primary: 'fontColor'} , } ), tool('tool:insert-text', 'insert-text', 'commands.annotate.insertText', 'insertText', { feature: 'annotations.text', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:replace-text', 'replace-text', 'commands.annotate.replaceText', 'replaceText', { feature: 'annotations.text', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:callout', 'free-text-callout', 'commands.annotate.callout', 'callout', { feature: 'annotations.text', check: CREATES_ANNOTATIONS, accent:{ primary: 'color', secondary: 'interiorColor'} , } ), tool('tool:note', 'note', 'commands.annotate.note', 'message', { feature: 'annotations.notes', check: CREATES_ANNOTATIONS, } ), tool('tool:link', 'link', 'commands.annotate.link', 'link', { feature: 'annotations.links', check: CREATES_ANNOTATIONS, } ), tool('tool:square', 'square', 'commands.shapes.rectangle', 'square', { feature: 'shapes', check: CREATES_ANNOTATIONS, accent:{ primary: 'color', secondary: 'interiorColor'} , } ), tool('tool:circle', 'circle', 'commands.shapes.circle', 'circle', { feature: 'shapes', check: CREATES_ANNOTATIONS, accent:{ primary: 'color', secondary: 'interiorColor'} , } ), tool('tool:line', 'line', 'commands.shapes.line', 'line', { feature: 'shapes', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:arrow', 'arrow', 'commands.shapes.arrow', 'lineArrow', { feature: 'shapes', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), tool('tool:polygon', 'polygon', 'commands.shapes.polygon', 'polygon', { feature: 'shapes', check: CREATES_ANNOTATIONS, accent:{ primary: 'color', secondary: 'interiorColor'} , } ), tool('tool:polyline', 'polyline', 'commands.shapes.polyline', 'zigzag', { feature: 'shapes', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), { id: 'tool:stamp', labelKey: 'commands.insert.stamp', icon: 'rubberStamp', categories: ['stamps'], ...PLACES_STAMPS, ...togglesPanel('stamps', (commandContext) => commandContext.tryGet(StampToken) != null), } , tool('tool:attachment', 'attachment', 'commands.insert.attachment', 'paperclip', { feature: 'attachments.adding', check: CREATES_ANNOTATIONS, } ), { id: 'tool:signature', labelKey: 'commands.insert.signature', icon: 'signature', categories: ['signatures.signing'], ...PLACES_STAMPS, ...togglesPanel( 'signatures', (commandContext) => commandContext.tryGet(StampToken) != null && commandContext.tryGet(SignatureToken) != null, ), } , tool('tool:image', 'image', 'commands.insert.image', 'photo', { feature: 'stamps', check: CREATES_ANNOTATIONS, } ), { id: 'form:design', labelKey: 'commands.form.design', icon: 'formDesign', categories: ['forms.building'], ...DESIGNS_FORMS, run: (commandContext) =>{ const tools = interaction(commandContext); const shell = commandContext.tryGet(ShellToken); if (!tools) return; if (isDesigningForm(commandContext)){ tools.activateTool('pointer'); shell?.close(FORM_DESIGN_PANEL); return; } if (shell && !shell.isOpen('mode:form')) shell.open('mode:form', { exclusive: 'mode'} ); tools.activateTool(FORM_DESIGN_TOOL); shell?.open(FORM_DESIGN_PANEL); } , active: isDesigningForm, enabled: (commandContext) => interaction(commandContext) != null, } , tool('tool:text-field', 'form-text', 'commands.form.textfield', 'formTextfield', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:checkbox', 'form-checkbox', 'commands.form.checkbox', 'formCheckbox', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:radio', 'form-radio', 'commands.form.radio', 'formRadio', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:combo-box', 'form-combobox', 'commands.form.select', 'formSelect', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:list-box', 'form-listbox', 'commands.form.listbox', 'formListbox', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:button', 'form-button', 'commands.form.button', 'formButton', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:signature-field', 'form-signature', 'commands.form.signature', 'signature', { feature: 'forms.building', check: DESIGNS_FORMS, } ), tool('tool:redact', 'redact', 'commands.redact.mark', 'redactArea', { feature: 'redaction', check:{ allowed: (commandContext) => commandContext.tryGet(RedactionToken)?.canMark() ?? true, notAllowedKey: 'commands.notAllowed.annotations-create', } , } ), { id: 'redaction:apply', labelKey: 'commands.redact.applyAll', icon: 'redact', categories: ['redaction'], allowed: (commandContext) => commandContext.tryGet(RedactionToken)?.canApply() ?? true, modal: REDACT_CONFIRM_DIALOG, enabled: (commandContext) =>{ const redaction = commandContext.tryGet(RedactionToken); return !!redaction && redaction.getPendingCount() > 0 && !redaction.isApplying(); } , } , { id: 'annotation:apply-redaction', labelKey: 'commands.redact.apply', labelParams: (commandContext) => ({ count: selectedMarks(commandContext).length} ), icon: 'check', categories: ['redaction'], allowed: (commandContext) => commandContext.tryGet(RedactionToken)?.canApply() ?? true, run: (commandContext) => commandContext.tryGet(ShellToken)?.open(REDACT_CONFIRM_DIALOG, { exclusive: 'modal', props:{ refs: selectedMarks(commandContext)} , } ), visible: (commandContext) => selectedMarks(commandContext).length > 0, enabled: (commandContext) =>{ const redaction = commandContext.tryGet(RedactionToken); return !!redaction && !redaction.isApplying(); } , } , { ...tool('tool:distance', 'distance', 'measurement.distance', 'distance', { feature: 'measurement', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), enabled: canMeasureNow, } , { ...tool('tool:perimeter', 'perimeter', 'measurement.perimeter', 'perimeter', { feature: 'measurement', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), enabled: canMeasureNow, } , { ...tool('tool:area', 'area', 'measurement.area', 'area', { feature: 'measurement', check: CREATES_ANNOTATIONS, accent:{ primary: 'color'} , } ), enabled: canMeasureNow, } , { id: 'measurement:calibrate', labelKey: 'measurement.calibrate', icon: 'calibrate', categories: ['measurement'], allowed: (commandContext) => commandContext.tryGet(MeasurementToken)?.canCalibrate() ?? true, notAllowedKey: 'commands.notAllowed.doc-annotate-modify', enabled: (commandContext) => commandContext.tryGet(MeasurementToken) != null, active: (commandContext) => interaction(commandContext)?.getActiveToolId() === 'calibrate', run: (commandContext) => commandContext.tryGet(MeasurementToken)?.startCalibration(), } , { id: 'annotation:cancel-creation', labelKey: 'commands.annotate.cancelCreation', shortcut: 'Escape', enabled: (commandContext) => anno(commandContext)?.draft.get() != null, run: (commandContext) => anno(commandContext)?.draft.cancel(), } , { id: 'annotation:delete', labelKey: 'commands.annotate.delete', icon: 'trash', shortcut: ['Delete', 'Backspace'], categories: ['annotations'], run: (commandContext) => void anno(commandContext)?.selection.delete(), visible: hasAnnotationSelection, enabled: (commandContext) =>{ const annotation = anno(commandContext); const selected = annotation?.selection.getSelected() ?? []; return ( selected.length > 0 && selected.every(({ ref} ) => annotation!.canDelete(ref) && annotation!.isEditable(ref)) ); } , } , { id: 'annotation:comment', labelKey: 'commands.comment', icon: 'comment', categories: ['comments'], ...togglesPanel( 'comments', (commandContext) => hasAnnotationSelection(commandContext) && !selectionSubtypes(commandContext).has('widget'), ), } , { id: 'annotation:style', labelKey: 'commands.style', icon: 'palette', categories: ['annotations'], ...togglesPanel( 'style', (commandContext) => (anno(commandContext)?.selection.getProperties().properties.length ?? 0) > 0, ), } , { id: 'annotation:stamp-from-selection', labelKey: 'commands.annotate.stampFromSelection', icon: 'rubberStampPlus', categories: ['stamps'], allowed: (commandContext) => commandContext .tryGet(StampToken) ?.canCreateFromAnnotations(commandContext.documentId ?? undefined) ?? true, notAllowedKey: 'commands.notAllowed.doc-download', run: (commandContext) =>{ const annotation = anno(commandContext); const stamp = commandContext.tryGet(StampToken); const documentId = commandContext.documentId; if (!annotation || !stamp || documentId == null) return; const dtos = annotation.selection.getSelected(); const page = dtos[0]?.ref.page; if (page === undefined) return; const i18n = commandContext.tryGet(I18nToken); const label = i18n?.t('demo.stampsCustomLabel') ?? 'Custom stamp'; const libraryName = i18n?.t('demo.stampsCustomLibrary') ?? 'My stamps'; const libraryId = CUSTOM_LIBRARY_ID; const ensureLibrary = stamp.getLibrary(libraryId) ? Promise.resolve(libraryId) : stamp .createLibrary(libraryName, { id: libraryId, categories: ['custom']} ) .then(({ library} ) => library.id); ensureLibrary .then((id) => stamp.createAssetFromAnnotations( page, dtos.map((annotation) => annotation.ref), { libraryId: id, label: `${ label} ${ stamp.listAssets({ libraryId: id} ).length + 1} `} , { documentId} , ), ) .then(async () =>{ const shell = commandContext.tryGet(ShellToken); if (!shell) return; if (!shell.isOpen('stamps')){ await commandContext .tryGet(CommandsToken) ?.execute(panelCommandOf('stamps'), { documentId} ); } shell.updateSurfaceProps('stamps', { libraryId} ); } ) .catch((error) => console.warn('[embedpdf] stamp from selection failed', error)); } , visible: (commandContext) => commandContext.tryGet(StampToken) != null && hasAnnotationSelection(commandContext) && !selectionSubtypes(commandContext).has('widget') && !selectionSubtypes(commandContext).has('redact') && new Set( (anno(commandContext)?.selection.getSelected() ?? []).map( (annotation) => annotation.ref.page.objectNumber, ), ).size === 1, } , { id: 'annotation:duplicate', labelKey: 'commands.annotate.duplicate', icon: 'duplicate', shortcut: 'Mod+D', categories: ['annotations'], allowed: (commandContext) =>{ const annotation = anno(commandContext); const own = (annotation?.selection.getSelected() ?? []).some( ({ subtype} ) => subtype !== 'widget', ); return own ? (annotation?.canCreate() ?? true) : true; } , notAllowedKey: CREATES_ANNOTATIONS.notAllowedKey, run: (commandContext) => void anno(commandContext) ?.selection.duplicate() .catch(() =>{ } ), visible: (commandContext) =>{ const annotation = anno(commandContext); const selected = annotation?.selection.getSelected() ?? []; return ( selected.length > 0 && selectionEditable(commandContext) && selected.every(({ ref} ) => annotation!.isMovable(ref)) ); } , enabled: (commandContext) => anno(commandContext)?.selection.canDuplicate() ?? false, } , { id: 'annotation:rotate-counterclockwise', labelKey: 'commands.annotate.rotateCounterclockwise', icon: 'rotateCounterClockwise', categories: ['annotations'], run: (commandContext) => void anno(commandContext) ?.selection.rotateBy(-90) .catch(() =>{ } ), visible: selectionTurnsByQuarters, } , { id: 'annotation:rotate-clockwise', labelKey: 'commands.annotate.rotateClockwise', icon: 'rotateClockwise', categories: ['annotations'], run: (commandContext) => void anno(commandContext) ?.selection.rotateBy(90) .catch(() =>{ } ), visible: selectionTurnsByQuarters, } , { id: 'annotation:group', labelKey: 'commands.annotate.group', icon: 'group', categories: ['annotations'], run: (commandContext) => void anno(commandContext)?.selection.group(), visible: (commandContext) => (anno(commandContext)?.selection.canGroup() ?? false) && selectionEditable(commandContext), } , { id: 'annotation:ungroup', labelKey: 'commands.annotate.ungroup', icon: 'ungroup', categories: ['annotations'], run: (commandContext) => void anno(commandContext)?.selection.ungroup(), visible: (commandContext) => (anno(commandContext)?.selection.canUngroup() ?? false) && selectionEditable(commandContext), } , { id: 'selection:copy', labelKey: 'commands.selection.copy', icon: 'copy', categories: ['text.copy'], allowed: (commandContext) => textSelection(commandContext)?.canCopy() ?? true, notAllowedKey: 'commands.notAllowed.doc-text-copy', visible: (commandContext) => textSelection(commandContext)?.hasSelection() ?? false, run: (commandContext) =>{ const selection = textSelection(commandContext); if (!selection) return; const copiedRange = selection.getRange(); void copySelection(selection).then( (text) =>{ if (text !== '' && sameTextRange(selection.getRange(), copiedRange)) selection.clear(); } , () =>{ } , ); } , } , markupSelection( 'selection:highlight', 'highlight', 'commands.annotate.highlight', 'highlight', 'annotations.highlight', ), markupSelection( 'selection:underline', 'underline', 'commands.annotate.underline', 'underline', 'annotations.markup', ), markupSelection( 'selection:strikeout', 'strikeout', 'commands.annotate.strikeout', 'strikethrough', 'annotations.markup', ), { id: 'snapshot:copy', labelKey: 'commands.snapshot.copy', icon: 'copy', shortcut: 'Mod+C', categories: ['snapshots'], visible: (commandContext) => snapshotOf(commandContext) != null, run: (commandContext) =>{ const render = renderOf(commandContext); const snapshot = render?.getSnapshot(); if (!render || !snapshot) return; void copyImage(snapshot.image).then( () =>{ if (render.getSnapshot() === snapshot) render.clearSnapshot(); } , () =>{ } , ); } , } , { id: 'snapshot:save', labelKey: 'commands.snapshot.save', icon: 'download', categories: ['snapshots'], visible: (commandContext) => snapshotOf(commandContext) != null, run: (commandContext) =>{ const snapshot = snapshotOf(commandContext); if (!snapshot) return; const name = snapshotFileName(commandContext, snapshot.page); snapshot.image .then((image) => image.blob()) .then((blob) => saveFile(blob, name, 'image/png')) .catch((error) => console.warn('[snippet-react] snapshot save failed', error)); } , } , { id: 'snapshot:clear', labelKey: 'commands.snapshot.clear', icon: 'x', shortcut: 'Escape', categories: ['snapshots'], visible: (commandContext) => snapshotOf(commandContext) != null, run: (commandContext) => renderOf(commandContext)?.clearSnapshot(), } , { id: 'annotation:link', labelKey: 'commands.annotate.link', icon: 'link', categories: ['annotations.links'], run: (commandContext) => commandContext.tryGet(ShellToken)?.toggle('link-editor'), active: (commandContext) => commandContext.tryGet(ShellToken)?.isOpen('link-editor') ?? false, visible: (commandContext) => selectionLink(commandContext) === null, } , { id: 'annotation:goto-link', labelKey: 'commands.annotate.gotoLink', icon: 'externalLink', run: (commandContext) =>{ const target = selectionLink(commandContext); if (target) commandContext.tryGet(LinkToken)?.activate(target); } , visible: (commandContext) => selectionLink(commandContext) != null, } , { id: 'annotation:remove-link', labelKey: 'commands.annotate.removeLink', icon: 'linkOff', categories: ['annotations.links'], run: (commandContext) => anno(commandContext)?.selection.updateLink(null), visible: (commandContext) => selectionLink(commandContext) != null, } , { id: 'help:shortcuts', labelKey: 'commands.shortcuts', shortcut: '?', modal: SHORTCUTS_DIALOG, enabled: (commandContext) => commandContext.tryGet(ShellToken) != null, } , { id: 'history:undo', labelKey: 'commands.undo', icon: 'arrowBackUp', shortcut: 'Mod+z', run: (commandContext) => commandContext.tryGet(HistoryToken)?.undo(), enabled: (commandContext) => commandContext.tryGet(HistoryToken)?.canUndo() ?? false, } , { id: 'history:redo', labelKey: 'commands.redo', icon: 'arrowForwardUp', shortcut: ['Shift+Mod+z', 'Mod+y'], run: (commandContext) => commandContext.tryGet(HistoryToken)?.redo(), enabled: (commandContext) => commandContext.tryGet(HistoryToken)?.canRedo() ?? false, } , ] defaultIcons [VariableDeclaration] (from packages/viewer/chrome/src/ui/icons.tsx): ICON_PATHS ={ ruler: ['M3 8h18v8H3z', 'M7 8v4M11 8v2M15 8v4M19 8v2'], distance: [{ d: 'M5 12H19', stroke: 'primary', strokeDasharray: '2 2'} , { d: 'M3.5 10.5a1.5 1.5 0 1 0 0 3a1.5 1.5 0 1 0 0-3M20.5 10.5a1.5 1.5 0 1 0 0 3a1.5 1.5 0 1 0 0-3', stroke: 'primary', fill: 'primary', fillOpacity: 0.25, } , ], perimeter: measurementOutline, area: [{ d: 'M5 4H19V5H20V19H19V20H5V19H4V5H5Z', fill: 'primary', fillOpacity: 0.08} , { d: 'M4.5 7.5L7.5 4.5M4.5 10.5L10.5 4.5M4.5 13.5L13.5 4.5M4.5 16.5L16.5 4.5M4.5 19.5L19.5 4.5M7.5 19.5L19.5 7.5M10.5 19.5L19.5 10.5M13.5 19.5L19.5 13.5M16.5 19.5L19.5 16.5', stroke: 'primary', strokeWidth: 0.6, strokeOpacity: 0.5, } , ...measurementOutline, ], alertTriangle: [ 'M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z', ], alignBottom: [ 'M3 19v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z', 'M11 17h2', 'M9 14h6', 'M10 11h4', ], alignCenter: ['M4 6l16 0', 'M8 12l8 0', 'M6 18l12 0'], alignLeft: ['M4 6l16 0', 'M4 12l10 0', 'M4 18l14 0'], alignMiddle: [ 'M3 19v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z', 'M11 15h2', 'M9 12h6', 'M10 9h4', ], alignRight: ['M4 6l16 0', 'M10 12l10 0', 'M6 18l14 0'], alignTop: [ 'M3 19v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z', 'M11 13h2', 'M9 10h6', 'M10 7h4', ], arrowBackUp: ['M9 14l-4 -4l4 -4', 'M5 10h11a4 4 0 1 1 0 8h-1'], arrowForwardUp: ['M15 14l4 -4l-4 -4', 'M19 10h-11a4 4 0 1 0 0 8h1'], bold: ['M7 5h6a3.5 3.5 0 0 1 0 7h-6z', 'M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7'], book: [ 'M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0', 'M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0', 'M3 6l0 13', 'M12 6l0 13', 'M21 6l0 13', ], book2: [ 'M19 4v16h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h12z', 'M19 16h-12a2 2 0 0 0 -2 2', 'M9 8h6', ], calibrate: [ 'M12 12m-7.5 0a7.5 7.5 0 1 0 15 0a7.5 7.5 0 1 0 -15 0', 'M12 2.75V7M12 17V21.25M2.75 12H7M17 12H21.25', 'M12 12m-2.5 0a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0', ], callout: [{ d: 'M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1', stroke: 'primary', fill: 'secondary', } , { d: 'M17 11v6h-9', stroke: 'primary'} , { d: 'M8 15l-2 2l2 2', stroke: 'primary'} , ], check: ['M5 12l5 5l10 -10'], chevronDown: ['M6 9l6 6l6 -6'], chevronLeft: ['M15 6l-6 6l6 6'], chevronRight: ['M9 6l6 6l-6 6'], chevronsDown: ['M7 7l5 5l5 -5', 'M7 13l5 5l5 -5'], chevronsUp: ['M7 11l5 -5l5 5', 'M7 17l5 -5l5 5'], circle: [{ d: 'M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0', stroke: 'primary', fill: 'secondary'} , ], circleCheck: ['M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0', 'M9 12l2 2l4 -4'], comment: [ 'M12 11v.01', 'M8 11v.01', 'M16 11v.01', 'M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3z', ], copy: [ 'M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z', 'M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1', ], deviceFloppy: [ 'M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2', 'M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M14 4l0 4l-6 0l0 -4', ], dots: [ 'M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0', 'M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0', 'M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0', ], doublePage: [ 'M3 3m0 1a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1zm9 -1v18', ], download: ['M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2', 'M7 11l5 5l5 -5', 'M12 4l0 12'], duplicate: [ 'M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z', 'M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1', 'M11 14h6', 'M14 11v6', ], externalLink: [ 'M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6', 'M11 13l9 -9', 'M15 4h5v5', ], eye: ['M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z', 'M9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'], file: ['M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'], fileExport: [ 'M14 3v4a1 1 0 0 0 1 1h4', 'M11.5 21h-4.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v5m-5 6h7m-3 -3l3 3l-3 3', ], fileImport: [ 'M14 3v4a1 1 0 0 0 1 1h4', 'M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3', ], filePlus: [ 'M14 3v4a1 1 0 0 0 1 1h4', 'M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z', 'M12 11l0 6', 'M9 14l6 0', ], fitToPage: [ 'M12 20h-6a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h6', 'M18 14v7', 'M18 3v7', 'M15 18l3 3l3 -3', 'M15 6l3 -3l3 3', ], fitToWidth: [ 'M4 12v-6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v6', 'M10 18h-7', 'M21 18h-7', 'M6 15l-3 3l3 3', 'M18 15l3 3l-3 3', ], formButton: [ 'M3 8a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-8', 'M8 12h8', ], formCheckbox: [ 'M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14', 'M9 12l2 2l4 -4', ], formDesign: [ 'M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2', 'M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2', 'M9 12l.01 0', 'M13 12l2 0', 'M9 16l.01 0', 'M13 16l2 0', ], formListbox: [ 'M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14', 'M11 8h6', 'M11 12h6', 'M11 16h6', 'M7 8l0 .01', 'M7 12l0 .01', 'M7 16l0 .01', ], formRadio: [{ d: 'M9 12a2 2 0 1 0 6 0a2 2 0 1 0 -6 0', fill: true} , 'M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0', ], formSelect: [ 'M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14', 'M9 11l3 3l3 -3', ], formTextfield: [ 'M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3', 'M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3', 'M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7', 'M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1', 'M17 12h.01', 'M13 12h.01', ], freeText: [{ d: 'M4 7v-2h12v2', stroke: 'primary'} , { d: 'M10 5v14', stroke: 'primary'} , { d: 'M12 19h-4', stroke: 'primary'} , { d: 'M15 13v-1h6v1', stroke: 'primary'} , { d: 'M18 12v7', stroke: 'primary'} , { d: 'M17 19h2', stroke: 'primary'} , ], fullscreen: [ 'M4 8v-2a2 2 0 0 1 2 -2h2', 'M4 16v2a2 2 0 0 0 2 2h2', 'M16 4h2a2 2 0 0 1 2 2v2', 'M16 20h2a2 2 0 0 0 2 -2v-2', ], fullscreenExit: [ 'M4 8v-2c0 -.551 .223 -1.05 .584 -1.412', 'M4 16v2a2 2 0 0 0 2 2h2', 'M16 4h2a2 2 0 0 1 2 2v2', 'M16 20h2c.545 0 1.04 -.218 1.4 -.572', 'M3 3l18 18', ], group: [ 'M3 5a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M17 5a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M3 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M17 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M5 7v10', 'M19 7v10', 'M7 5h10', 'M7 19h10', 'M8 8H12.8V11.2H16V16H11.2V12.8H8V8Z', ], hand: [ 'M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5', 'M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5', 'M14 5.5a1.5 1.5 0 0 1 3 0v6.5', 'M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47', ], highlight: [{ d: 'M4 6h16a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2H4a2 2 0 0 1 -2 -2V8a2 2 0 0 1 2 -2z', fill: 'primary', } , 'M8 16v-8a4 4 0 1 1 8 0v8', 'M8 10h8', ], horizontal: ['M7 8l-4 4l4 4', 'M17 8l4 4l-4 4', 'M3 12l18 0'], inkHighlighter: [ 'M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4', 'M12.5 5.5l4 4', 'M4.5 13.5l4 4', { d: 'M21 15v4h-8l4 -4l4 0', stroke: 'primary', fill: 'primary'} , ], insertText: [{ d: 'M3 7v-2h12v2', stroke: 'primary'} , { d: 'M9 5v14', stroke: 'primary'} , { d: 'M7 19h4', stroke: 'primary'} , { d: 'M18 15l2 2h-5', stroke: 'primary'} , { d: 'M18 19l2 -2', stroke: 'primary'} , ], italic: ['M11 5l6 0', 'M7 19l6 0', 'M14 5l-4 14'], line: [{ d: 'M20 4l-16 16', stroke: 'primary'} ], lineArrow: [{ d: 'M20 4l-16 16', stroke: 'primary'} , { d: 'M16 3h5v5', stroke: 'primary'} , ], link: [ 'M9 15l6 -6', 'M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464', 'M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463', ], linkOff: [ 'M9 15l3 -3m2 -2l1 -1', 'M11 6l.463 -.536a5 5 0 0 1 7.072 7.071l-.534 .464', 'M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463', 'M3 3l18 18', ], listTree: ['M9 6h11', 'M12 12h8', 'M15 18h5', 'M5 6v.01', 'M8 12v.01', 'M11 18v.01'], lock: [ 'M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2H5a2 2 0 0 1 -2 -2v-7a2 2 0 0 1 2 -2z', 'M7 11V7a5 5 0 0 1 10 0v4', ], marqueeSelect: [ 'M17 20h6', 'M20 17v6', 'M4 13v-2', 'M4 6v-1a1 1 0 0 1 1 -1h1', 'M6 20h-1a1 1 0 0 1 -1 -1v-1', 'M11 4h2', 'M11 20h2', 'M18 4h1a1 1 0 0 1 1 1v1', 'M20 11v2', ], menu: ['M4 8l16 0', 'M4 16l16 0'], message: [ 'M8 9h8', 'M8 13h6', 'M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12', ], pageByPage: [ 'M8 4m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z', 'M5 9l-3 3l3 3', 'M19 9l3 3l-3 3', ], pageRotateClockwise: [ 'M5 9h7a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-7a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z', 'M9 4h5a5 5 0 0 1 5 5v4', 'M16 10l3 3l3 -3', ], pageRotateCounterClockwise: [ 'M19 9h-7a1 1 0 0 0 -1 1v10a1 1 0 0 0 1 1h7a1 1 0 0 0 1 -1v-10a1 1 0 0 0 -1 -1z', 'M15 4h-5a5 5 0 0 0 -5 5v4', 'M8 10l-3 3l-3 -3', ], palette: [ 'M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25', 'M8.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0', 'M12.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0', 'M16.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0', ], paperclip: [ 'M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5', ], pencilMarker: [ 'm9.109 16.275 8.856-8.097c.812-.743.87-2.014.127-2.826s-2.014-.869-2.826-.127L6.41 13.322l-.127 2.826zM13.79 6.575l2.7 2.952', { d: 'M19.375 20.125c.569.063-4.05-.562-6.412-.437s-4.759 1.229-6.857 1.625c-1.764.687-3.404-.938-1.981-2.5', stroke: 'primary', } , ], photo: [ 'M15 8h.01', 'M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z', 'M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5', 'M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3', ], plus: ['M12 5l0 14', 'M5 12l14 0'], pointer: [ 'M7.904 17.563a1.2 1.2 0 0 0 2.228 .308l2.09 -3.093l4.907 4.907a1.067 1.067 0 0 0 1.509 0l1.047 -1.047a1.067 1.067 0 0 0 0 -1.509l-4.907 -4.907l3.113 -2.09a1.2 1.2 0 0 0 -.309 -2.228l-13.582 -3.904l3.904 13.563z', ], polygon: [{ d: 'M13.163 2.168l8.021 5.828c.694 .504 .984 1.397 .719 2.212l-3.064 9.43a1.978 1.978 0 0 1 -1.881 1.367h-9.916a1.978 1.978 0 0 1 -1.881 -1.367l-3.064 -9.43a1.978 1.978 0 0 1 .719 -2.212l8.021 -5.828a1.978 1.978 0 0 1 2.326 0z', stroke: 'primary', fill: 'secondary', } , ], print: [ 'M17 17h2a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2h-14a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h2', 'M17 9v-4a2 2 0 0 0 -2 -2h-6a2 2 0 0 0 -2 2v4', 'M7 13m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z', ], redact: [ 'M7 4h10', 'M12 4v8', 'M-7 24l12 -12', 'M-3 24l12 -12', 'M1 24l12 -12', 'M5 24l12 -12', 'M9 24l12 -12', 'M13 24l12 -12', 'M17 24l12 -12', 'M21 24l12 -12', 'M25 24l12 -12', ], redactArea: [ 'M6 20h-1a2 2 0 0 1 -2 -2v-1', 'M3 13v-3', 'M3 6v-1a2 2 0 0 1 2 -2h1', 'M10 3h3', 'M17 3h1a2 2 0 0 1 2 2v1', 'M12 10h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2v-8a2 2 0 0 1 2 -2z', 'M10 12l2 -2', 'M10 16l6 -6', 'M10 20l10 -10', 'M12 22l10 -10', 'M16 22l6 -6', 'M20 22l2 -2', ], redactCombined: [ 'M6 20h-1a2 2 0 0 1 -2 -2v-1', 'M3 13v-3', 'M20 13v-3', 'M3 6v-1a2 2 0 0 1 2 -2h1', 'M10 3h3', 'M17 3h1a2 2 0 0 1 2 2v1', 'M8 8h8', 'M12 8v7', 'M6 19l12 -12', 'M6 23l12 -12', 'M10 23l12 -12', 'M14 27l12 -12', 'M14 23l12 -12', ], redactionSidebar: [ 'M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z', 'M15 4v16', 'M7 8h5', 'M7 11h5', 'M7 14h4', ], replaceText: [{ d: 'M3 7v-2h12v2', stroke: 'primary'} , { d: 'M9 5v14', stroke: 'primary'} , { d: 'M7 19h4', stroke: 'primary'} , { d: 'M20 14l2 2h-3', stroke: 'primary'} , { d: 'M20 18l2 -2', stroke: 'primary'} , { d: 'M19 16a3 3 0 1 0 2 5.236', stroke: 'primary'} , ], rotateClockwise: ['M4.05 11a8 8 0 1 1 .5 4m-.5 5v-5h5'], rotateCounterClockwise: ['M19.95 11a8 8 0 1 0 -.5 4m.5 5v-5h-5'], rubberStamp: [ 'M21 17.85h-18c0 -4.05 1.421 -4.05 3.79 -4.05c5.21 0 1.21 -4.59 1.21 -6.8a4 4 0 1 1 8 0c0 2.21 -4 6.8 1.21 6.8c2.369 0 3.79 0 3.79 4.05', 'M5 21h14', ], rubberStampPlus: [ 'M21 17.85h-18c0 -4.05 1.421 -4.05 3.79 -4.05c5.21 0 1.21 -4.59 1.21 -6.8a4 4 0 0 1 4.9 -4.1', 'M16 10c0 1.2 -4 3.8 1.21 3.8c2.369 0 3.79 0 3.79 4.05', 'M5 21h14', 'M16 5h6', 'M19 2v6', ], save: [ 'M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2', 'M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M14 4l0 4l-6 0l0 -4', ], screenshot: [ 'M7 19a2 2 0 0 1 -2 -2', 'M5 13v-2', 'M5 7a2 2 0 0 1 2 -2', 'M11 5h2', 'M17 5a2 2 0 0 1 2 2', 'M19 11v2', 'M19 17v4', 'M21 19h-4', 'M13 19h-2', ], search: ['M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0', 'M21 21l-6 -6'], send: [ 'M10 14l11 -11', 'M21 3l-6.5 18a.55 .55 0 0 1 -1 0l-3.5 -7l-7 -3.5a.55 .55 0 0 1 0 -1l18 -6.5', ], settings: [ 'M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z', 'M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0', ], sidebar: [ 'M4 18v-12a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z', 'M10 18v-12a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z', ], signature: [ 'M3 17c3.333 -3.333 5 -6 5 -8c0 -3 -1 -3 -2 -3s-2.032 1.085 -2 3c.034 2.048 1.658 4.877 2.5 6c1.5 2 2.5 2.5 3.5 1l2 -3c.333 2.667 1.333 4 3 4c.53 0 2.639 -2 3 -2c.517 0 1.517 .667 3 2', ], singlePage: ['M5 3m0 1a1 1 0 0 1 1 -1h12a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-12a1 1 0 0 1 -1 -1z'], square: [{ d: 'M3 3m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z', stroke: 'primary', fill: 'secondary', } , ], squares: [ 'M8 10a2 2 0 0 1 2 -2h9a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-9a2 2 0 0 1 -2 -2z', 'M16 8v-3a2 2 0 0 0 -2 -2h-9a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h3', ], squiggly: [ 'M8 16v-8a4 4 0 1 1 8 0v8', 'M8 10h8', { d: 'M4 20c1.5 -1.5 3.5 -1.5 5 0s3.5 1.5 5 0 3.5 -1.5 5 0', stroke: 'primary'} , ], strikethrough: ['M8 16v-8a4 4 0 1 1 8 0v8', { d: 'M4 10h16', stroke: 'primary'} ], text: [ 'M6.5 15.5m-3.5 0a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0', 'M14 19v-10.5a3.5 3.5 0 0 1 7 0v10.5', 'M14 13h7', 'M10 12v7', ], trash: [ 'M4 7l16 0', 'M10 11l0 6', 'M14 11l0 6', 'M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12', 'M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3', ], underline: [{ d: 'M4 20h16', stroke: 'primary'} , 'M8 16v-8a4 4 0 1 1 8 0v8', 'M8 10h8'], ungroup: [ 'M4 5a1 1 0 0 1 1 -1h5a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1z', 'M13 14a1 1 0 0 1 1 -1h5a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1z', ], unlock: ['M7 11V7a5 5 0 0 1 9.9-1'], updateScale: [ 'M3.5 13.5L18.5 7.5L21.25 14.5L6.25 20.5L3.5 13.5Z', 'M8 12.8L9 15.2M11.5 11.4L12.2 13.2M15 10L16 12.4', 'M4 9.39849C4.10585 8.34804 4.487 7.34411 5.10497 6.48809C5.72294 5.63207 6.55584 4.95427 7.51957 4.52312C8.4833 4.09198 9.54373 3.92277 10.5938 4.03257C11.6438 4.14237 12.6463 4.5273 13.5 5.14849M11.5 6.00003L13.5 5.14849L12.7807 2.96999', ], vertical: ['M8 7l4 -4l4 4', 'M8 17l4 4l4 -4', 'M12 3l0 18'], viewSettings: [ 'M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M12 10.5v1.5', 'M12 16v1.5', 'M15.031 12.25l-1.299 .75', 'M10.268 15l-1.3 .75', 'M15 15.803l-1.285 -.773', 'M10.285 12.97l-1.285 -.773', 'M14 3v4a1 1 0 0 0 1 1h4', 'M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z', ], widgetEdit: [ 'M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1', 'M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415', 'M16 5l3 3', ], x: ['M18 6l-12 12', 'M6 6l12 12'], zigzag: [{ d: 'M12 2.4L21.36 11.76L2.64 12.24L12 21.6', stroke: 'primary'} ], zoomIn: ['M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0', 'M9 12h6', 'M12 9v6'], zoomInArea: [ 'M15 13v4', 'M13 15h4', 'M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0', 'M22 22l-3 -3', 'M6 18h-1a2 2 0 0 1 -2 -2v-1', 'M3 11v-1', 'M3 6v-1a2 2 0 0 1 2 -2h1', 'M10 3h1', 'M15 3h1a2 2 0 0 1 2 2v1', ], zoomOut: ['M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0', 'M9 12l6 0'], } satisfies Record defaultLayout [VariableDeclaration] (from packages/viewer/chrome/src/config/chrome.ts): defaultLayout = createLayout(DEFAULT_LAYOUT) httpRevocationSource [FunctionDeclaration] (from packages/core/signature/src/revocation/http-source.ts): export function httpRevocationSource(options: HttpRevocationSourceOptions): RevocationSource{ const{ url: route, timeoutMs = 10_000, retries = 1} = options; async function ask(request: RevocationRequest): Promise{ const send = options.fetch ?? globalThis.fetch; const details = (more: Record ={ } ) => ({ source: request.url, route, ...more, } ); const noAnswer = (why: string, cause?: unknown) => new EngineError( EngineErrorCode.Network, `${ request.url} did not answer through ${ route} : ${ why} `, { details: details(), cause} , ); const payload: RevocationRouteRequest ={ kind: request.kind, url: request.url, ...(request.kind === 'ocsp' ?{ body: toBase64(request.body)} :{ } ), } ; const timeout = new AbortController(); const timer = setTimeout(() => timeout.abort(), timeoutMs); try{ let response: Response; try{ response = await send(route, { method: 'POST', headers:{ 'content-type': 'application/json', ...options.headers} , body: JSON.stringify(payload), signal: timeout.signal, } ); } catch (error){ if (timeout.signal.aborted) throw noAnswer(`no reply within ${ timeoutMs} ms`, error); throw noAnswer((error as Error).message, error); } if (response.status >= 500 || response.status === 429){ throw noAnswer(`HTTP ${ response.status} ${ await said(response)} `); } if (!response.ok){ const refusal = await refusalOf(response); throw new EngineError( EngineErrorCode.SignatureRefused, `the route at ${ route} refused to ask ${ request.url} : ${ refusal.message ?? `HTTP ${ response.status} `} `, { details: details({ httpStatus: response.status, reason: refusal.reason} )} , ); } try{ return new Uint8Array(await response.arrayBuffer()); } catch (error){ throw noAnswer( timeout.signal.aborted ? `no reply within ${ timeoutMs} ms` : `the reply broke off: ${ (error as Error).message} `, error, ); } } finally{ clearTimeout(timer); } } return{ async fetch(request){ for (let attempt = 0; ; attempt++){ try{ return await ask(request); } catch (error){ const noAnswer = EngineError.is(error, EngineErrorCode.Network); if (!noAnswer || attempt >= retries) throw error; await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS)); } } } , } ; } httpTimestampAuthority [FunctionDeclaration] (from packages/core/signature/src/signers/timestamp-http.ts): export function httpTimestampAuthority(options: HttpTimestampAuthorityOptions): CmsSigner{ const{ url, policy, timeoutMs = 10_000, retries = 1} = options; const details = (more: Record ={ } ) => ({ authority: url, ...more} ); const refused = (message: string, more: Record, cause?: unknown) => new EngineError(EngineErrorCode.SignatureRefused, message, { details: details(more), cause} ); const wrongAnswer = (reason: CompletionRefusal, what: string) => refused(`the timestamp authority at ${ url} ${ what} `, { reason} ); async function ask(query: Uint8Array): Promise{ const send = options.fetch ?? globalThis.fetch; const noAnswer = (why: string, cause?: unknown) => new EngineError( EngineErrorCode.Network, `the timestamp authority at ${ url} did not answer: ${ why} `, { details: details(), cause} , ); const timeout = new AbortController(); const timer = setTimeout(() => timeout.abort(), timeoutMs); try{ let response: Response; try{ response = await send(url, { method: 'POST', headers:{ 'content-type': 'application/timestamp-query', ...options.headers} , body: new Uint8Array(query), signal: timeout.signal, } ); } catch (error){ if (timeout.signal.aborted) throw noAnswer(`no reply within ${ timeoutMs} ms`, error); const hint = 'document' in globalThis ? '. In a browser most authorities cannot be called directly: call yours through a route on your own server' : ''; throw noAnswer(`${ (error as Error).message} ${ hint} `, error); } if (response.status >= 500 || response.status === 429){ throw noAnswer(`HTTP ${ response.status} `); } if (!response.ok){ throw refused( `the timestamp authority at ${ url} refused the request: HTTP ${ response.status} `, { httpStatus: response.status} , ); } try{ return new Uint8Array(await response.arrayBuffer()); } catch (error){ throw noAnswer( timeout.signal.aborted ? `no reply within ${ timeoutMs} ms` : `the reply broke off: ${ (error as Error).message} `, error, ); } } finally{ clearTimeout(timer); } } return{ kind: 'cms', hash: options.hash ?? 'sha256', async sign({ digest, algorithm, subFilter} ){ if (subFilter !== 'ETSI.RFC3161'){ throw new EngineError( EngineErrorCode.InvalidArg, "a timestamp authority can't sign a document: pass it as `timestampAuthority`, or sign with `kind: 'timestamp'`", { details: details()} , ); } const [protocol, parse, timestamp, engine] = await Promise.all([ import('../cms/timestamp-protocol'), import('../cms/parse'), import('../cms/timestamp'), import('../cms/engine'), ]); const nonce = engine.randomPositiveInteger(); const query = protocol.buildTimestampRequest({ digest, algorithm, policy, nonce} ); let reply: Uint8Array; for (let attempt = 0; ; attempt++){ try{ reply = await ask(query); break; } catch (error){ const noAnswer = EngineError.is(error, EngineErrorCode.Network); if (!noAnswer || attempt >= retries) throw error; await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS)); } } let response; try{ response = protocol.readTimestampResponse(reply); } catch (error){ throw refused( `the timestamp authority at ${ url} sent a reply that can't be read: ${ (error as Error).message} `, { reason: 'malformed'} , error, ); } if (!response.granted){ const said = [response.failInfo, response.statusText].filter(Boolean).join(': '); throw refused( `the timestamp authority at ${ url} refused the request${ said ? ` (${ said} )` : ''} `, { failInfo: response.failInfo} , ); } if (!response.token) throw wrongAnswer('malformed', 'granted the request but sent no token'); let info; try{ info = timestamp.readTimestampInfo( parse.readCmsParts(response.token, 'tst-info').eContent!, ); } catch (error){ throw refused( `the timestamp authority at ${ url} sent a token that can't be read: ${ (error as Error).message} `, { reason: 'malformed'} , error, ); } if (info.imprintAlgorithm !== algorithm){ throw wrongAnswer( 'algorithm-mismatch', `stamped a ${ info.imprintAlgorithm} digest where ${ algorithm} was asked for`, ); } if (!engine.bytesEqual(info.imprint, digest)){ throw wrongAnswer('digest-mismatch', 'stamped another digest than the one it was sent'); } if (!info.nonce || !engine.bytesEqual(info.nonce, timestamp.withoutLeadingZeros(nonce))){ throw wrongAnswer( 'profile-violation', "sent a token that doesn't answer this request: its nonce is not the one sent", ); } if (policy && info.policy !== policy){ throw wrongAnswer( 'profile-violation', `issued the token under policy ${ info.policy} where ${ policy} was asked for`, ); } return response.token; } , } ; } indexedDbKeyStore [FunctionDeclaration] (from packages/core/signature/src/signers/personal.ts): export function indexedDbKeyStore( dbName: string, options:{ storeName?: string} ={ } , ): PersonalKeyStore{ const storeName = options.storeName ?? 'keys'; let opening: Promise | null = null; const open = (): Promise =>{ opening ??= 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')); } ); return opening; } ; const run = async ( mode: IDBTransactionMode, op: (store: IDBObjectStore) => IDBRequest, ): Promise =>{ const db = await open(); return new Promise((resolve, reject) =>{ const tx = db.transaction(storeName, mode); const request = op(tx.objectStore(storeName)); request.onsuccess = () => resolve(request.result); request.onerror = () => reject(request.error ?? new Error('indexedDB request failed')); } ); } ; return{ load: async (subject) => ((await run('readonly', (store) => store.get(subject))) as PersonalKeyRecord | undefined) ?? null, save: (subject, record) => run('readwrite', (store) => store.put(record, subject)).then(() => undefined), remove: (subject) => run('readwrite', (store) => store.delete(subject)).then(() => undefined), } ; } initViewer [FunctionDeclaration] (from packages/viewer/main/src/kernel/init.ts): export function initViewer(options: ElementConfig & MountTarget): EmbedPdfViewerElement{ const{ target, ...config} = options; const host = typeof target === 'string' ? document.querySelector(target) : target; if (!host) throw new Error(`[embedpdf] init: target not found: ${ String(target)} `); const element = document.createElement('embedpdf-viewer') as EmbedPdfViewerElement; element.config = config; host.appendChild(element); return element; } memoryKeyStore [FunctionDeclaration] (from packages/core/signature/src/signers/personal.ts): export function memoryKeyStore(): PersonalKeyStore{ const records = new Map(); return{ load: async (subject) => records.get(subject) ?? null, save: async (subject, record) =>{ records.set(subject, record); } , remove: async (subject) =>{ records.delete(subject); } , } ; } personalSigner [FunctionDeclaration] (from packages/core/signature/src/signers/personal.ts): export async function personalSigner(input:{ subject: string; store: PersonalKeyStore; algorithm?: 'RSA-PKCS1-v1_5' | 'RSA-PSS' | 'ECDSA'; hash?: 'sha256' | 'sha384' | 'sha512'; } ): Promise{ const{ ensureEngine} = await import('../cms/engine'); ensureEngine(); const hash = input.hash ?? 'sha256'; let record = await input.store.load(input.subject); if (!record){ const{ selfSignedCertificate} = await import('./self-signed'); const keys = await generateSigningKeyPair(input.algorithm ?? 'RSA-PKCS1-v1_5', hash, false); const certificate = await selfSignedCertificate({ publicKey: keys.publicKey, privateKey: keys.privateKey, commonName: input.subject, hash, } ); record ={ privateKey: keys.privateKey, certificate} ; await input.store.save(input.subject, record); } const signer = webCryptoSigner({ privateKey: record.privateKey, certificateChain: [record.certificate], hash, } ); return{ ...signer, certificate: record.certificate, subject: input.subject} ; } remoteSigner [FunctionDeclaration] (from packages/core/signature/src/signers/remote.ts): export function remoteSigner(input:{ sign: (request:{ digest: Uint8Array; algorithm: 'sha256' | 'sha384' | 'sha512'; subFilter: 'adbe.pkcs7.detached' | 'ETSI.CAdES.detached' | 'ETSI.RFC3161'; } ) => Promise; } ): CmsSigner{ return{ kind: 'cms', sign: (request) => input.sign(request), } ; } useCommand [FunctionDeclaration] (from packages/framework/react/src/commands.ts): export function useCommand(id: string): BoundCommand{ const commands = useCapability(CommandsToken); const documentId = useDocumentId() ?? undefined; const resolved = useKernelValue( () => commands.resolveCommand(id, documentId), resolvedCommandsEqual, ); if (resolved === null){ devWarn(`useCommand:${ id} `, `useCommand(): ${ unknownCommandWarning(id, commands.listCommandIds())} `); } return useMemo( () => boundCommandOf( resolved ?? unregisteredCommand(id), (commandId) => commands.execute(commandId, { documentId} ), { isMac: isMacPlatform()} , ), [resolved, commands, documentId, id], ); } usePDFViewer [FunctionDeclaration] (from packages/viewer/react/src/hooks.ts): export function usePDFViewer(): Viewer{ const viewer = useContext(ViewerContext); if (!viewer){ throw new Error( '[embedpdf] usePDFViewer() works in a component inside . Outside the viewer, ' + 'keep the viewer its onReady gives you.', ); } return viewer; } useToolbarItem [FunctionDeclaration] (from packages/viewer/react/src/slots.ts): export function useToolbarItem(): ToolbarItemContext{ const context = useContext(ToolbarItemReactContext); if (!context){ throw new Error( '[embedpdf] useToolbarItem() works inside a : it says where that item sits.', ); } return context; } webCryptoSigner [FunctionDeclaration] (from packages/core/signature/src/signers/webcrypto.ts): export function webCryptoSigner(input:{ privateKey: CryptoKey; certificateChain: Uint8Array[]; hash?: Exclude; } ): RawSigner{ const keyAlgorithm = input.privateKey.algorithm as RsaHashedKeyAlgorithm | EcKeyAlgorithm; let algorithm: RawSignatureAlgorithm; let hash: Exclude; switch (keyAlgorithm.name){ case 'RSASSA-PKCS1-v1_5': algorithm = 'RSA-PKCS1-v1_5'; hash = hashFromWebCrypto((keyAlgorithm as RsaHashedKeyAlgorithm).hash.name); break; case 'RSA-PSS': algorithm = 'RSA-PSS'; hash = hashFromWebCrypto((keyAlgorithm as RsaHashedKeyAlgorithm).hash.name); break; case 'ECDSA': algorithm = 'ECDSA'; hash = input.hash ?? 'sha256'; break; default: throw new Error(`unsupported WebCrypto key algorithm ${ keyAlgorithm.name} `); } return{ kind: 'raw', certificateChain: input.certificateChain, algorithm, hash, async sign(data){ const params: AlgorithmIdentifier | RsaPssParams | EcdsaParams = algorithm === 'RSA-PSS' ?{ name: 'RSA-PSS', saltLength:{ sha256: 32, sha384: 48, sha512: 64} [hash]} : algorithm === 'ECDSA' ?{ name: 'ECDSA', hash: WEBCRYPTO_HASH[hash]} :{ name: 'RSASSA-PKCS1-v1_5'} ; const copy = new Uint8Array(data.byteLength); copy.set(data); const signature = await globalThis.crypto.subtle.sign(params, input.privateKey, copy); return new Uint8Array(signature); } , } ; }