# @embedpdf/plugin-actions — ./contract/host ACTIONS_DEFAULTS [VariableDeclaration] (from packages/plugin/actions/src/contract.ts): ACTIONS_DEFAULTS: ActionsSettings ={ policy:{ goto:{ user: 'allow', hover: 'allow', lifecycle: 'allow'} , named:{ user: 'allow', hover: 'allow', lifecycle: 'allow'} , hide:{ user: 'allow', hover: 'allow', lifecycle: 'allow'} , 'reset-form':{ user: 'allow', hover: 'allow', lifecycle: 'allow'} , javascript:{ user: 'allow', hover: 'allow', lifecycle: 'allow'} , uri:{ user: 'adapter', hover: 'report', lifecycle: 'report'} , print:{ user: 'adapter', hover: 'block', lifecycle: 'block'} , 'submit-form':{ user: 'adapter', hover: 'block', lifecycle: 'block'} , } , triggers:{ document: true, page: true, annotation: true} , openSequence: 'auto', javascript:{ enabled: false, identity: null} , } ActionContext [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionContext{ readonly origin: ActionOrigin; readonly source: ActionSource; readonly event: ActionTriggerEvent; } ActionDiagnostic [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionDiagnostic{ readonly code: | 'incomplete-tree' | 'blocked' | 'no-executor' | 'no-adapter' | 'no-session-sink' | 'unresolved-target' | 'duplicate-executor' | 'executor-inert' | 'executor-failed' | 'trigger-disabled' | 'no-commit-sink' | 'trigger-failed' | 'cascade-budget' | 'open-sequence-replayed' | 'no-submit-sink' | 'no-submit-resolver' | 'submit-payload-unavailable' | 'submit-entry-unsupported' | 'reentrant-print'; readonly message: string; } ActionDiagnosticReportedEvent [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionDiagnosticReportedEvent{ readonly code: ActionDiagnostic['code']; readonly action: PdfActionType | null; readonly source: ActionSource | null; } ActionDispatchResult [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionDispatchResult{ readonly status: 'executed' | 'partial' | 'inert' | 'refused' | 'cancelled'; readonly nodes: ActionNodeResult[]; readonly diagnostics: ActionDiagnostic[]; } ActionExecutedEvent [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionExecutedEvent{ readonly tree: PdfActionTree; readonly result: ActionDispatchResult; readonly source: ActionSource; } ActionExecutor [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionExecutor = ( node: PdfActionNode, actionContext: ActionContext, ) => Promise | ActionExecutorResult; ActionExecutorResult [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionExecutorResult = |{ status: 'executed'} |{ status: 'inert'; reason: string} |{ status: 'failed'; error: string} ; ActionNodeResult [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionNodeResult{ readonly path: number[]; readonly type: PdfActionType; readonly status: ActionNodeStatus; readonly detail?: string; } ActionNodeStatus [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionNodeStatus = | 'executed' | 'blocked' | 'no-executor' | 'inert' | 'failed' | 'skipped'; ActionOrigin [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionOrigin = 'user' | 'hover' | 'lifecycle'; ActionPolicy [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionPolicy{ readonly goto: ActionPolicyRow; readonly named: ActionPolicyRow; readonly hide: ActionPolicyRow; readonly 'reset-form': ActionPolicyRow; readonly javascript: ActionPolicyRow; readonly uri: ActionPolicyRow; readonly print: ActionPolicyRow; readonly 'submit-form': ActionPolicyRow; } ActionPolicyDecision [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionPolicyDecision = 'allow' | 'adapter' | 'report' | 'block'; ActionPolicyRow [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionPolicyRow = Readonly>; ActionSource [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionSource = |{ kind: 'widget'; field: FormFieldRef; annotation: AnnotationRef; page: PageRef} |{ kind: 'link'; annotation?: AnnotationRef; page?: PageRef} |{ kind: 'outline'; item: OutlineItemRef} |{ kind: 'annotation'; annotation: AnnotationRef; page: PageRef} |{ kind: 'page'; page: PageRef} |{ kind: 'document'} |{ kind: 'api'} ; ActionStepResult [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionStepResult{ readonly source: ActionSource; readonly tree: PdfActionTree; readonly result: ActionDispatchResult; } ActionSubmitHandler [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionSubmitHandler = ( request: ActionSubmitRequest, chain:{ submitToDocumentHome: (() => Promise) | null} , ) => void | Promise; ActionSubmitRequest [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionSubmitRequest{ url: string | null; method: 'post' | 'get'; format: 'fdf' | 'html' | 'xfdf' | 'pdf'; charSet?: string; entries: FormSubmissionEntry[]; origin: ActionOrigin; event: ActionTriggerEvent; } ActionTreeSource [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionTreeSource = |{ kind: 'annotation'; annotation: AnnotationRef; page: PageRef; event?: 'activate' | PdfAnnotationEventKind; } |{ kind: 'field'; field: FormFieldRef; event: PdfFieldEventKind} |{ kind: 'page'; page: PageRef; event?: 'open' | 'close'} |{ kind: 'document'; event?: DocumentTriggerEvent} |{ kind: 'outline'; item: OutlineItemRef} ; ActionTrigger [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionTrigger = |{ type: 'activate'; annotation: AnnotationRef; page: PageRef; source?: ActionSource} |{ type: 'annotation'; event: PdfAnnotationEventKind; annotation: AnnotationRef; page: PageRef; source?: ActionSource; } |{ type: 'page'; event: 'open' | 'close' | 'visible' | 'invisible'; page: PageRef} |{ type: 'document'; event: DocumentTriggerEvent} ; ActionTriggerEvent [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionTriggerEvent = |{ type: 'activate'} |{ type: 'annotation'; event: PdfAnnotationEventKind} |{ type: 'page'; event: 'open' | 'close' | 'visible' | 'invisible'} |{ type: 'document'; event: DocumentTriggerEvent} ; ActionTriggerResult [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionTriggerResult{ readonly status: 'executed' | 'partial' | 'inert' | 'refused' | 'cancelled'; readonly steps: ActionStepResult[]; readonly diagnostics: ActionDiagnostic[]; } ActionUiAdapter [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionUiAdapter{ openUri(uri: string, options:{ isMap: boolean; origin: ActionOrigin} ): void; print(uiContext?: ActionUiContext): void; alert?(message: string, options: ActionUiContext &{ icon: number; title?: string} ): void; goToPage?(pageIndex: number, uiContext: ActionUiContext): void; } ActionUiContext [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionUiContext{ readonly origin: ActionOrigin; readonly phase: 'boot' | 'user'; } ActionsCapability [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionsCapability extends SettingsApi{ execute( tree: PdfActionTree, actionContext: ActionContext, options?: OperationOptions, ): Promise; canExecute(tree: PdfActionTree, actionContext: ActionContext): boolean; executeNamed( name: PdfNamedAction, context?: Partial, options?: OperationOptions, ): Promise; canExecuteNamed(name: PdfNamedAction, context?: Partial): boolean; readActionTree( source: ActionTreeSource, options?: OperationOptions, ): Promise; isScriptingEnabled(): boolean; dispatch(trigger: ActionTrigger, options?: OperationOptions): Promise; canDispatch(trigger: ActionTrigger): boolean; setUiAdapter(adapter: ActionUiAdapter | null): Unsubscribe; runDocumentVerb( verb: 'save' | 'print', operation: () => Promise | T, options?: OperationOptions, ): Promise; prepareClose(options?: OperationOptions): Promise; setSubmitHandler(handler: ActionSubmitHandler | null): Unsubscribe; registerExecutor(type: PdfActionType, executor: ActionExecutor): Unsubscribe; readonly onExecuted: EventHook; readonly onDiagnosticReported: EventHook; readonly onScriptDiagnosticReported: EventHook; readonly onScriptFailed: EventHook; readonly onOpenSequenceCompleted: EventHook; } ActionsConfig [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionsConfig extends DeepPartial>{ readonly javascript?: DeepPartial & ActionsScriptEnvironment; } ActionsHostCapability [InterfaceDeclaration]: export interface ActionsHostCapability extends ActionsCapability{ registerAnnotCommitSink(sink: AnnotationCommitSink): Unsubscribe; registerFormCommitSink(sink: FormCommitSink): Unsubscribe; registerFormReader(reader: FormReader): Unsubscribe; registerFormFocus(focus: FormFocus): Unsubscribe; scriptRealm?: ScriptRealmPort; createDetachedScriptRealm?(target: ScriptRealmTarget): DetachedScriptRealm; surfaceScriptResult(result: ScriptSurfaceResult): void; surfaceScriptCommit( commit: ScriptCommitSurface, context:{ origin: ActionOrigin; realm: ScriptRealmKind; source?: ActionSource} , ): void; reportPageState(report: PageStateReport): void; registerSubmitResolver(resolver: SubmitResolver): Unsubscribe; } ActionsScriptEnvironment [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionsScriptEnvironment{ readonly sandboxFactory?: ScriptSandboxFactory; readonly fileName?: () => string; readonly now?: () => number; readonly utcOffsetMinutes?: () => number; readonly randomSeed?: () => number; readonly budget?: ScriptBudget; readonly maxScriptNodesPerDispatch?: number; } ActionsScriptIdentity [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ActionsScriptIdentity = Partial | (() => Partial); ActionsSettings [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ActionsSettings{ readonly policy: ActionPolicy; readonly triggers:{ readonly document: boolean; readonly page: boolean; readonly annotation: boolean; } ; readonly openSequence: 'auto' | 'headless' | 'off'; readonly javascript:{ readonly enabled: boolean; readonly identity: ActionsScriptIdentity | null; } ; } ActionsToken [VariableDeclaration]: ActionsToken = createHostToken(PublicActionsToken) AnnotationCommitEntry [InterfaceDeclaration]: export interface AnnotationCommitEntry{ annotObjectNumber: number; page?: PageRef; patch: ScriptAnnotEffect['patch']; } AnnotationCommitResult [InterfaceDeclaration]: export interface AnnotationCommitResult{ results: Array<{ annotObjectNumber: number; status: 'applied' | 'failed' | 'skipped'; error?: string; } >; } AnnotationCommitSink [TypeAliasDeclaration]: export type AnnotationCommitSink = ( entries: AnnotationCommitEntry[], ) => Promise; DetachedScriptRealm [InterfaceDeclaration]: export interface DetachedScriptRealm extends ScriptRealmPort{ destroy(): void; } DocumentTriggerEvent [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type DocumentTriggerEvent = | 'open' | 'will-save' | 'did-save' | 'will-print' | 'did-print' | 'will-close'; FormCommitSink [TypeAliasDeclaration]: export type FormCommitSink = (effects: FormEffect[]) => Promise; FormCommitSinkResult [InterfaceDeclaration]: export interface FormCommitSinkResult{ status: 'applied' | 'failed'; error?: string; } FormFocus [TypeAliasDeclaration]: export type FormFocus = (field: string) => boolean; FormReader [TypeAliasDeclaration]: export type FormReader = () => FormSnapshot | null; HoverPump [InterfaceDeclaration] (from packages/plugin/actions/src/hover-pump.ts): export interface HoverPump{ hover(target: HoverTarget | null): void; reset(): void; } HoverTarget [InterfaceDeclaration] (from packages/plugin/actions/src/hover-pump.ts): export interface HoverTarget{ ref: AnnotationRef; page: PageRef; source?: ActionSource; events?:{ enter?: boolean; exit?: boolean} ; } OpenSequenceCompletedEvent [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface OpenSequenceCompletedEvent{ readonly result: ActionTriggerResult; } PageStateReport [InterfaceDeclaration]: export interface PageStateReport{ currentPage: PageRef | null; visiblePages: readonly PageRef[]; placed: boolean; cause: 'user' | 'programmatic'; } PdfActionNode [TypeAliasDeclaration] (from packages/engine/core/src/dto/PdfAction.ts): export type PdfActionNode = PdfActionNodeCommon & ( |{ type: 'javascript'; script: string} |{ type: 'goto'; destination: Destination} |{ type: 'uri'; uri: string; isMap: boolean} |{ type: 'named'; name: string} |{ type: 'hide'; targets: PdfActionTargetRef[]; hide: boolean} |{ type: 'reset-form'; fields: PdfActionTargetRef[] | null; exclude: boolean; } |{ type: 'goto-remote'; filePath: string} |{ type: 'goto-embedded'; filePath: string} |{ type: 'launch'; filePath: string} |{ type: 'rendition'; script?: string} |{ type: 'submit-form'; payload?: SubmitFormPayload} |{ type: 'thread'} |{ type: 'sound'} |{ type: 'movie'} |{ type: 'import-data'} |{ type: 'set-ocg-state'} |{ type: 'transition'} |{ type: 'goto-3d-view'} |{ type: 'unknown'} ); PdfActionTree [InterfaceDeclaration] (from packages/engine/core/src/dto/PdfAction.ts): export interface PdfActionTree{ root: PdfActionNode | null; incomplete: boolean; warnings: PdfActionWarning[]; } PdfActionType [TypeAliasDeclaration] (from packages/engine/core/src/dto/PdfAction.ts): export type PdfActionType = PdfActionNode['type']; PdfAnnotationEventKind [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type PdfAnnotationEventKind = | 'cursorEnter' | 'cursorExit' | 'mouseDown' | 'mouseUp' | 'focus' | 'blur'; PdfFieldEventKind [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type PdfFieldEventKind = 'keystroke' | 'format' | 'validate' | 'calculate'; PdfNamedAction [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type PdfNamedAction = | 'NextPage' | 'PrevPage' | 'FirstPage' | 'LastPage' | 'Print' | (string &{ } ); ScriptCommitSurface [InterfaceDeclaration]: export interface ScriptCommitSurface{ uiEffects: Array; diagnostics: ScriptDiagnostic[]; error?: ScriptExecutionError; } ScriptDiagnosticReportedEvent [TypeAliasDeclaration] (from packages/plugin/actions/src/contract.ts): export type ScriptDiagnosticReportedEvent = Readonly; ScriptDocument [TypeAliasDeclaration]: export type ScriptDocument = Pick; ScriptFailedEvent [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface ScriptFailedEvent{ readonly error: ScriptExecutionError; readonly source: ActionSource | null; } ScriptRealmKind [TypeAliasDeclaration]: export type ScriptRealmKind = 'document' | 'detached'; ScriptRealmPort [InterfaceDeclaration]: export interface ScriptRealmPort{ transaction(body: (transaction: ScriptTransaction) => Promise): Promise; budget: ScriptBudget; } ScriptRealmTarget [InterfaceDeclaration]: export interface ScriptRealmTarget{ doc: DocumentHandle; document(): ScriptDocument | null; bootSources(): Promise; } ScriptSurfaceResult [InterfaceDeclaration]: export interface ScriptSurfaceResult{ uiEffects: ScriptUiEffect[]; diagnostics: ScriptDiagnostic[]; error?: ScriptExecutionError; origin: ActionOrigin; phase: 'boot' | 'user'; realm: ScriptRealmKind; source?: ActionSource; } SubmitIntent [InterfaceDeclaration] (from packages/plugin/actions/src/contract.ts): export interface SubmitIntent{ readonly url: string | null; readonly fields: PdfActionTargetRef[] | null; readonly exclude: boolean; readonly includeNoValueFields: boolean; readonly format: 'fdf' | 'html' | 'xfdf' | 'pdf'; readonly method: 'post' | 'get'; readonly charSet?: string; } SubmitResolver [TypeAliasDeclaration]: export type SubmitResolver = ( intent: SubmitIntent, actionContext: ActionContext, diagnose: (diagnostic: ActionDiagnostic) => void, ) => Promise; createHoverPump [FunctionDeclaration] (from packages/plugin/actions/src/hover-pump.ts): export function createHoverPump( dispatch: (trigger: ActionTrigger) => Promise, ): HoverPump{ let delivered: HoverTarget | null = null; let desired: HoverTarget | null = null; let inFlight = false; const pump = (): void =>{ if (inFlight || sameTarget(delivered, desired)) return; inFlight = true; const from = delivered; const to = desired; delivered = to; const submissions: Array> = []; if (from && from.events?.exit !== false){ submissions.push( dispatch({ type: 'annotation', event: 'cursorExit', annotation: from.ref, page: from.page, ...(from.source ?{ source: from.source} :{ } ), } ), ); } if (to && to.events?.enter !== false){ submissions.push( dispatch({ type: 'annotation', event: 'cursorEnter', annotation: to.ref, page: to.page, ...(to.source ?{ source: to.source} :{ } ), } ), ); } void Promise.allSettled(submissions).then(() =>{ inFlight = false; pump(); } ); } ; return{ hover(target){ desired = target; pump(); } , reset(){ delivered = null; desired = null; } , } ; } eventOf [VariableDeclaration] (from packages/plugin/actions/src/contract.ts): eventOf = (trigger: ActionTrigger): ActionTriggerEvent =>{ switch (trigger.type){ case 'activate': return{ type: 'activate'} ; case 'annotation': return{ type: 'annotation', event: trigger.event} ; case 'page': return{ type: 'page', event: trigger.event} ; case 'document': return{ type: 'document', event: trigger.event} ; } } submitEntriesToUrlEncoded [VariableDeclaration] (from packages/plugin/actions/src/submit-encoding.ts): submitEntriesToUrlEncoded = (entries: FormSubmissionEntry[]): string => entries .flatMap(({ name, value} ) => value === null ? [encodeURIComponent(name)] : Array.isArray(value) ? value.map((item) => `${ encodeURIComponent(name)} =${ encodeURIComponent(item)} `) : [`${ encodeURIComponent(name)} =${ encodeURIComponent(value)} `], ) .join('&') triggerOriginOf [VariableDeclaration] (from packages/plugin/actions/src/contract.ts): triggerOriginOf = (trigger: ActionTrigger): ActionOrigin =>{ switch (trigger.type){ case 'activate': return 'user'; case 'annotation': return trigger.event === 'cursorEnter' || trigger.event === 'cursorExit' ? 'hover' : 'user'; case 'page': case 'document': return 'lifecycle'; } }