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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/contract/host.cjs +13 -1
  2. package/dist/contract/host.cjs.map +1 -1
  3. package/dist/contract/host.d.cts +3 -7
  4. package/dist/contract/host.d.ts +3 -7
  5. package/dist/contract/host.js +10 -3
  6. package/dist/contract/host.js.map +1 -1
  7. package/dist/contract-BTPW8b4L.d.cts +557 -0
  8. package/dist/contract-Cn-7mBY8.d.ts +557 -0
  9. package/dist/contract-CwN3NAXU.js +175 -0
  10. package/dist/contract-CwN3NAXU.js.map +1 -0
  11. package/dist/contract-_HB_UliT.cjs +210 -0
  12. package/dist/contract-_HB_UliT.cjs.map +1 -0
  13. package/dist/contract.cjs +5 -4
  14. package/dist/contract.d.cts +2 -3
  15. package/dist/contract.d.ts +2 -3
  16. package/dist/contract.js +2 -3
  17. package/dist/host-contract-BbODswDs.d.ts +165 -0
  18. package/dist/host-contract-D22Gz-qt.d.cts +165 -0
  19. package/dist/index.cjs +1588 -1072
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +11 -9
  22. package/dist/index.d.ts +11 -9
  23. package/dist/index.js +1586 -1072
  24. package/dist/index.js.map +1 -1
  25. package/package.json +7 -11
  26. package/dist/contract-C1K3H4RP.cjs +0 -89
  27. package/dist/contract-C1K3H4RP.cjs.map +0 -1
  28. package/dist/contract-COk-w3Fo.d.ts +0 -50
  29. package/dist/contract-DAem-EST.js +0 -78
  30. package/dist/contract-DAem-EST.js.map +0 -1
  31. package/dist/contract-Os5y4NaD.d.cts +0 -50
  32. package/dist/internal.cjs +0 -3
  33. package/dist/internal.d.cts +0 -3
  34. package/dist/internal.d.ts +0 -3
  35. package/dist/internal.js +0 -2
  36. package/dist/types-BXJLAKXi.cjs +0 -52
  37. package/dist/types-BXJLAKXi.cjs.map +0 -1
  38. package/dist/types-D-DoiESj.d.cts +0 -504
  39. package/dist/types-D-DoiESj.d.ts +0 -504
  40. package/dist/types-DgBMy5nE.js +0 -35
  41. package/dist/types-DgBMy5nE.js.map +0 -1
@@ -0,0 +1,557 @@
1
+ import { DeepPartial, EventHook, OperationOptions, SettingsApi, Unsubscribe } from "@embedpdf/core";
2
+ import { AnnotationRef, FormFieldRef, FormSubmissionEntry, FormSubmissionReceipt, OutlineItemRef, PageRef, PdfActionNode, PdfActionNode as PdfActionNode$1, PdfActionTargetRef, PdfActionTree, PdfActionTree as PdfActionTree$1, PdfActionType, PdfActionType as PdfActionType$1 } from "@embedpdf/engine-core/runtime";
3
+ import { ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptIdentity, ScriptSandboxFactory } from "@embedpdf/core-acrojs";
4
+ //#region src/token.d.ts
5
+ declare const ActionsToken: import("@embedpdf/core").CapabilityToken<ActionsCapability>;
6
+ //#endregion
7
+ //#region src/hover-pump.d.ts
8
+ /** One hoverable target, as a feed sees it. `events` lets a feed that knows
9
+ * which trees exist (a folded model, a fill item) skip the inert half of a
10
+ * pair; omitted flags default to true. */
11
+ interface HoverTarget {
12
+ ref: AnnotationRef;
13
+ page: PageRef;
14
+ /** Optional provenance hint forwarded on the trigger (widget/link feeds). */
15
+ source?: ActionSource;
16
+ events?: {
17
+ enter?: boolean;
18
+ exit?: boolean;
19
+ };
20
+ }
21
+ interface HoverPump {
22
+ /** Report where the pointer is now (null = nowhere interesting). */
23
+ hover(target: HoverTarget | null): void;
24
+ /** Forget everything without dispatching (teardown; document switch). */
25
+ reset(): void;
26
+ }
27
+ /**
28
+ * The one hover state machine every event plane shares: per pointer feed,
29
+ * `{ delivered, desired, inFlight }`. On each settle it delivers the
30
+ * transition `delivered → desired` as `Exit(delivered)` then
31
+ * `Enter(desired)`, submitted back to back synchronously: dispatch takes its
32
+ * queue slot before returning, so a slow resolution can never split or
33
+ * reorder the pair. Under pressure intermediate targets are skipped by
34
+ * design: the pointer sweeping A→B→C while A's exit is in flight delivers
35
+ * `Exit(A) → Enter(C)`, never a stale `Enter(B)`.
36
+ */
37
+ declare function createHoverPump(dispatch: (trigger: ActionTrigger) => Promise<ActionTriggerResult>): HoverPump;
38
+ //#endregion
39
+ //#region src/submit-encoding.d.ts
40
+ /**
41
+ * Encode a resolved submission dataset as `application/x-www-form-urlencoded`
42
+ * (UTF-8 — the one encoding this helper speaks; a `/CharSet` other than
43
+ * utf-8 is the handler's problem). A name-only entry (`value === null`, the
44
+ * IncludeNoValueFields shape) encodes as a bare name; a multi-select list
45
+ * box repeats the name per value, the HTML-form convention.
46
+ *
47
+ * Pure and dependency-free on purpose: a convenience for embedder handlers,
48
+ * never called by the plugin itself (the plugin never touches a network).
49
+ */
50
+ declare const submitEntriesToUrlEncoded: (entries: FormSubmissionEntry[]) => string;
51
+ //#endregion
52
+ //#region src/contract.d.ts
53
+ /** Why a dispatch happened: `'user'` for a real activation gesture,
54
+ * `'hover'` for pointer enter and exit, `'lifecycle'` for page and document
55
+ * events. The policy decides per type and origin. */
56
+ type ActionOrigin = 'user' | 'hover' | 'lifecycle';
57
+ /** Who initiated the dispatch. Fields are required where an executor needs
58
+ * them: the JavaScript executor builds `event.target` from the widget
59
+ * source's `field`. Provenance only: policy never reads it. */
60
+ type ActionSource = {
61
+ kind: 'widget';
62
+ field: FormFieldRef;
63
+ annotation: AnnotationRef;
64
+ page: PageRef;
65
+ } | {
66
+ kind: 'link';
67
+ annotation?: AnnotationRef;
68
+ page?: PageRef;
69
+ } |
70
+ /** An outline item the user followed: its /A, run as a link's is. */
71
+ {
72
+ kind: 'outline';
73
+ item: OutlineItemRef;
74
+ } |
75
+ /** A non-widget annotation's own /AA event (E/X on squares, stamps, …). */
76
+ {
77
+ kind: 'annotation';
78
+ annotation: AnnotationRef;
79
+ page: PageRef;
80
+ } |
81
+ /** A page /AA tree (O/C) inside a page-trigger fan-out. */
82
+ {
83
+ kind: 'page';
84
+ page: PageRef;
85
+ } |
86
+ /** The document-open sequence (openDestination / OpenAction). */
87
+ {
88
+ kind: 'document';
89
+ } | {
90
+ kind: 'api';
91
+ };
92
+ /** The document lifecycle vocabulary: `open` (the document-open sequence)
93
+ * plus the five catalog `/AA` verbs (ISO 32000-2 Table 200: /WC, /WS, /DS,
94
+ * /WP, /DP). Whoever owns the verb dispatches them; `runDocumentVerb` is the
95
+ * serialized door for save and print, `prepareClose` for close. */
96
+ type DocumentTriggerEvent = 'open' | 'will-save' | 'did-save' | 'will-print' | 'did-print' | 'will-close';
97
+ /** Trigger provenance, derived beside {@link triggerOriginOf}: the
98
+ * executor-visible "which event fired" (cursorEnter and cursorExit are both
99
+ * `origin: 'hover'`; this carries the difference). */
100
+ type ActionTriggerEvent = {
101
+ scope: 'activate';
102
+ } | {
103
+ scope: 'annotation';
104
+ name: PdfAnnotationEventKind;
105
+ } | {
106
+ scope: 'page';
107
+ name: 'open' | 'close' | 'visible' | 'invisible';
108
+ } | {
109
+ scope: 'document';
110
+ name: DocumentTriggerEvent;
111
+ };
112
+ /** The four field-level /AA scripts (ISO Table 198: K F V C). */
113
+ type PdfFieldEventKind = 'keystroke' | 'format' | 'validate' | 'calculate';
114
+ /** The Named verbs the viewer interprets (ISO Table 215's four page verbs
115
+ * plus Adobe's `Print`); any other name is accepted and reported inert. */
116
+ type PdfNamedAction = 'NextPage' | 'PrevPage' | 'FirstPage' | 'LastPage' | 'Print' | (string & {});
117
+ /**
118
+ * Where an action tree lives, for {@link ActionsCapability.getActionTree}.
119
+ * Each arm names its own event vocabulary; the annotation arm defaults to
120
+ * the /A click tree, the page and document arms to their open trees.
121
+ */
122
+ type ActionTreeSource = {
123
+ kind: 'annotation';
124
+ annotation: AnnotationRef;
125
+ page: PageRef;
126
+ event?: 'activate' | PdfAnnotationEventKind;
127
+ } | {
128
+ kind: 'field';
129
+ field: FormFieldRef;
130
+ event: PdfFieldEventKind;
131
+ } | {
132
+ kind: 'page';
133
+ page: PageRef;
134
+ event?: 'open' | 'close';
135
+ } | {
136
+ kind: 'document';
137
+ event?: DocumentTriggerEvent;
138
+ } |
139
+ /** An outline item's /A. */
140
+ {
141
+ kind: 'outline';
142
+ item: OutlineItemRef;
143
+ };
144
+ /** The document-open sequence has run (once per document). */
145
+ interface OpenSequenceCompletedEvent {
146
+ readonly result: ActionTriggerResult;
147
+ }
148
+ interface ActionContext {
149
+ origin: ActionOrigin;
150
+ source: ActionSource;
151
+ event: ActionTriggerEvent;
152
+ }
153
+ /** The six annotation /AA pointer and focus events (ISO 32000-2 Table 197:
154
+ * /E /X /D /U /Fo /Bl). The page-lifecycle events (/PO /PC /PV /PI) are not
155
+ * here: they fan out from page triggers, never from per-annotation dispatch. */
156
+ type PdfAnnotationEventKind = 'cursorEnter' | 'cursorExit' | 'mouseDown' | 'mouseUp' | 'focus' | 'blur';
157
+ /**
158
+ * Trigger vocabulary: what a feed reports. The dispatcher resolves trees,
159
+ * derives the origin ({@link triggerOriginOf}) and fans out. `source` on the
160
+ * annotation-addressed arms is an optional provenance hint from first-party
161
+ * feeds (a widget feed passes its field ref so the JavaScript executor can
162
+ * anchor `event.target`); policy never reads it and it cannot change origin.
163
+ */
164
+ type ActionTrigger = {
165
+ scope: 'activate';
166
+ ref: AnnotationRef;
167
+ page: PageRef;
168
+ source?: ActionSource;
169
+ } | {
170
+ scope: 'annotation';
171
+ event: PdfAnnotationEventKind;
172
+ ref: AnnotationRef;
173
+ page: PageRef;
174
+ source?: ActionSource;
175
+ } | {
176
+ scope: 'page';
177
+ event: 'open' | 'close' | 'visible' | 'invisible';
178
+ page: PageRef;
179
+ } | {
180
+ scope: 'document';
181
+ event: DocumentTriggerEvent;
182
+ };
183
+ /** Trigger → provenance descriptor (the {@link ActionContext.event} axis). */
184
+ declare const eventOf: (trigger: ActionTrigger) => ActionTriggerEvent;
185
+ /** The one origin mapping, derived by the dispatcher and never claimed by a
186
+ * caller: a feed cannot launder a hover into a user gesture. */
187
+ declare const triggerOriginOf: (trigger: ActionTrigger) => ActionOrigin;
188
+ type ActionNodeStatus = 'executed' | 'blocked' | 'no-executor' | 'inert' | 'failed' | 'skipped';
189
+ interface ActionNodeResult {
190
+ /** Node address as child indexes from the root ([] = root, [0] = root.next[0]…). */
191
+ path: number[];
192
+ type: PdfActionType;
193
+ status: ActionNodeStatus;
194
+ detail?: string;
195
+ }
196
+ interface ActionDiagnostic {
197
+ 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';
198
+ message: string;
199
+ }
200
+ /**
201
+ * One logical dispatch transaction's outcome. Document-lifetime work is not
202
+ * rolled back: an earlier successful reset or script write survives a later
203
+ * failure; `status: 'partial'` says so, and `nodes` carries the per-node
204
+ * truth. `'cancelled'`: the caller's signal fired while the tree ran, so the
205
+ * walk stopped before its next node and no navigation or external effect
206
+ * fired.
207
+ */
208
+ interface ActionDispatchResult {
209
+ status: 'executed' | 'partial' | 'inert' | 'refused' | 'cancelled';
210
+ nodes: ActionNodeResult[];
211
+ diagnostics: ActionDiagnostic[];
212
+ }
213
+ /**
214
+ * One tree's execution inside a trigger: its true source, its true tree, its
215
+ * own node results (`path`s are real walk paths, never prefixed).
216
+ * `onExecuted` fires once per step with exactly this tree and a context
217
+ * built from this source, so fan-out never merges trees in the event.
218
+ */
219
+ interface ActionStepResult {
220
+ source: ActionSource;
221
+ tree: PdfActionTree;
222
+ result: ActionDispatchResult;
223
+ }
224
+ /**
225
+ * What `dispatch(trigger)` returns: the aggregate plus per-step truth. A step
226
+ * failure never skips sibling steps (a broken annotation /PC must not cancel
227
+ * the page's /C); deferred navigation and external effects flush per step,
228
+ * not per trigger.
229
+ */
230
+ interface ActionTriggerResult {
231
+ /** `'cancelled'`: the caller's signal fired before or while the trigger ran. */
232
+ status: 'executed' | 'partial' | 'inert' | 'refused' | 'cancelled';
233
+ steps: ActionStepResult[];
234
+ /** Trigger-level diagnostics (disabled family, resolution failure);
235
+ * per-node diagnostics live inside each step's `result`. */
236
+ diagnostics: ActionDiagnostic[];
237
+ }
238
+ /** Actions ran: one tree, whatever started it (a click, a page, the document, your code). */
239
+ interface ActionExecutedEvent {
240
+ readonly tree: PdfActionTree;
241
+ readonly result: ActionDispatchResult;
242
+ /** What started them. */
243
+ readonly source: ActionSource;
244
+ }
245
+ /**
246
+ * An action was blocked, reported or couldn't run. `action` is its type and
247
+ * `source` what started it; both are `null` for a diagnostic about no one
248
+ * action (a trigger family turned off, an executor replaced). The result of
249
+ * the run that reported it lists the same diagnostic with its message.
250
+ */
251
+ interface ActionDiagnosticReportedEvent {
252
+ readonly code: ActionDiagnostic['code'];
253
+ readonly action: PdfActionType | null;
254
+ readonly source: ActionSource | null;
255
+ }
256
+ /**
257
+ * A script was stopped from doing something, such as reaching the network,
258
+ * or used something the viewer doesn't support.
259
+ */
260
+ type ScriptDiagnosticReportedEvent = Readonly<ScriptDiagnostic>;
261
+ /**
262
+ * A script threw an error. `source` is what started it, or `null` for a
263
+ * script no action started: a form field's keystroke, format, validate or
264
+ * calculate script, or a stamp's template.
265
+ */
266
+ interface ScriptFailedEvent {
267
+ readonly error: ScriptExecutionError;
268
+ readonly source: ActionSource | null;
269
+ }
270
+ /** The decision per type and origin. `allow` executes; `adapter` routes
271
+ * through the type's port (the UI adapter; for `submit-form`, the sink
272
+ * chain: embedder handler → the document's home → blocked); `report`
273
+ * records a blocked node without executing; `block` refuses. The `launch`,
274
+ * `goto-remote`, `goto-embedded` and media types are fixed `'never'` and
275
+ * not configurable. */
276
+ type ActionPolicyDecision = 'allow' | 'adapter' | 'report' | 'block';
277
+ type ActionPolicyRow = Readonly<Record<ActionOrigin, ActionPolicyDecision>>;
278
+ interface ActionPolicy {
279
+ readonly goto: ActionPolicyRow;
280
+ readonly named: ActionPolicyRow;
281
+ readonly hide: ActionPolicyRow;
282
+ readonly 'reset-form': ActionPolicyRow;
283
+ readonly javascript: ActionPolicyRow;
284
+ readonly uri: ActionPolicyRow;
285
+ /** The Named `Print` verb, owned by policy and the UI adapter, never the
286
+ * stage. (An Acrobat-compatible extension: ISO 32000-2 Table 215 defines
287
+ * only the four page verbs; an unrecognized name "shall take no action".) */
288
+ readonly print: ActionPolicyRow;
289
+ /** SubmitForm: `'adapter'` routes through the sink chain. Default: user
290
+ * origin only; hover and lifecycle submits stay blocked. */
291
+ readonly 'submit-form': ActionPolicyRow;
292
+ }
293
+ /** Who scripts think the user is: fields over the document's user, or a function that returns them. */
294
+ type ActionsScriptIdentity = Partial<ScriptIdentity> | (() => Partial<ScriptIdentity>);
295
+ /**
296
+ * The actions plugin's settings. `actionsPlugin(config)` registers them over
297
+ * {@link ACTIONS_DEFAULTS}, and `updateSettings()` changes them for every
298
+ * document while the app runs. `policy`, `triggers` and
299
+ * `javascript.identity` apply to the next action; `javascript.enabled`
300
+ * applies to the documents opened after the change (a document's script
301
+ * engine starts when it opens); `openSequence` applies until a document's
302
+ * opening actions have run.
303
+ */
304
+ interface ActionsSettings {
305
+ /** The rules: per kind of action and per origin. Rows merge, so a change names only what it changes. */
306
+ readonly policy: ActionPolicy;
307
+ /** Run the actions of the `document`, its `page`s, or `annotation`s. A click on a link or button always runs. */
308
+ readonly triggers: {
309
+ readonly document: boolean;
310
+ readonly page: boolean;
311
+ readonly annotation: boolean;
312
+ };
313
+ /**
314
+ * When the document's opening actions run (the open destination, then the
315
+ * catalog /OpenAction, then the first page's /O). `'auto'` runs them once
316
+ * at the first sign of a person: a UI adapter installing, or a first
317
+ * click; the first page's /O then comes from the Stage's page report.
318
+ * `'headless'` runs them as the document opens, for an app without a
319
+ * Stage; `'off'` never runs them.
320
+ */
321
+ readonly openSequence: 'auto' | 'headless' | 'off';
322
+ readonly javascript: {
323
+ /** Run the document's JavaScript. Off by default: no script engine ever loads. */
324
+ readonly enabled: boolean;
325
+ /** Who scripts think the user is, on top of the document's user. `null`: the document's user. */
326
+ readonly identity: ActionsScriptIdentity | null;
327
+ };
328
+ }
329
+ /** What the actions settings are when the app registers none. */
330
+ declare const ACTIONS_DEFAULTS: ActionsSettings;
331
+ /**
332
+ * The script environment, given once when the plugin is registered: not a
333
+ * setting, because a document's script engine is built with it when the
334
+ * document opens.
335
+ */
336
+ interface ActionsScriptEnvironment {
337
+ /** Override the lazy QuickJS factory (tests or another isolated VM). */
338
+ readonly sandboxFactory?: ScriptSandboxFactory;
339
+ readonly fileName?: () => string;
340
+ /** Injected deterministic transaction environment. */
341
+ readonly now?: () => number;
342
+ readonly utcOffsetMinutes?: () => number;
343
+ readonly randomSeed?: () => number;
344
+ readonly budget?: ScriptBudget;
345
+ /**
346
+ * The deterministic aggregate: the most JavaScript nodes one dispatch may
347
+ * run (default 16). A /Next chain shares it instead of multiplying the
348
+ * per-run time budget, and a count stays deterministic where a wall-clock
349
+ * aggregate would not. Once exhausted, the remaining JavaScript nodes
350
+ * report inert with a budget reason.
351
+ */
352
+ readonly maxScriptNodesPerDispatch?: number;
353
+ }
354
+ /**
355
+ * What `actionsPlugin(config)` takes: any of the settings, merged over the
356
+ * defaults, and the script environment beside `javascript`'s settings.
357
+ */
358
+ interface ActionsConfig extends DeepPartial<Omit<ActionsSettings, 'javascript'>> {
359
+ readonly javascript?: DeepPartial<ActionsSettings['javascript']> & ActionsScriptEnvironment;
360
+ }
361
+ type ActionExecutorResult = {
362
+ status: 'executed';
363
+ } | {
364
+ status: 'inert';
365
+ reason: string;
366
+ } | {
367
+ status: 'failed';
368
+ error: string;
369
+ };
370
+ /** One node of one registered type, executed in dispatch order. Executors
371
+ * never see the tree or the capability, so an executor cannot cascade into
372
+ * further dispatches. */
373
+ type ActionExecutor = (node: PdfActionNode, actionContext: ActionContext) => Promise<ActionExecutorResult> | ActionExecutorResult;
374
+ /** The origin and phase every script-produced UI request carries: the
375
+ * default adapter's visibility matrix keys on it; embedder adapters receive
376
+ * everything and decide for themselves. */
377
+ interface ActionUiContext {
378
+ origin: ActionOrigin;
379
+ /** Script-model axis: `'boot'` = name-tree/document-open boot scripts. */
380
+ phase: 'boot' | 'user';
381
+ }
382
+ interface ActionUiAdapter {
383
+ /** A URI action to open; `isMap` is the /IsMap flag. */
384
+ openUri(uri: string, options: {
385
+ isMap: boolean;
386
+ origin: ActionOrigin;
387
+ }): void;
388
+ /** The Named `Print` verb and script `print()` requests (authority-gated
389
+ * upstream: `doc.print` refusals never reach the adapter). */
390
+ print(uiContext?: ActionUiContext): void;
391
+ /** Script `app.alert`: the one alert port for every script origin. */
392
+ alert?(message: string, options: ActionUiContext & {
393
+ icon: number;
394
+ title?: string;
395
+ }): void;
396
+ /** Script `this.pageNum = n` navigation requests. */
397
+ gotoPage?(page: number, uiContext: ActionUiContext): void;
398
+ }
399
+ /**
400
+ * A normalized submit intent, one shape for both sources: a SubmitForm action
401
+ * node's extracted payload, or a script `doc.submitForm()` effect
402
+ * (include-mode names, `exclude` false). Resolving it into a dataset is the
403
+ * form plugin's job (it owns the field plane), through the registered
404
+ * resolver.
405
+ */
406
+ interface SubmitIntent {
407
+ url: string | null;
408
+ /** ISO 32000-2 Table 239 targets (names and object numbers mixed); `null`
409
+ * is the whole eligible form. */
410
+ fields: PdfActionTargetRef[] | null;
411
+ exclude: boolean;
412
+ includeNoValueFields: boolean;
413
+ format: 'fdf' | 'html' | 'xfdf' | 'pdf';
414
+ method: 'post' | 'get';
415
+ /** Raw ISO Table 240 word (0 for scripted submits without one). */
416
+ flagsRaw: number;
417
+ charSet?: string;
418
+ }
419
+ /**
420
+ * The resolved dataset a sink receives. Entries carry the ISO semantics
421
+ * already applied (descendants, the unconditional NoExport veto, push-button
422
+ * and unsupported exclusion, diagnosed and never silent); the document's
423
+ * declared routing survives as metadata. The stack never fetches `url`: an
424
+ * embedder handler that chooses to must validate it (protocol and
425
+ * destination allowlists) before any network call.
426
+ */
427
+ interface ActionSubmitRequest {
428
+ url: string | null;
429
+ method: 'post' | 'get';
430
+ format: 'fdf' | 'html' | 'xfdf' | 'pdf';
431
+ flagsRaw: number;
432
+ charSet?: string;
433
+ entries: FormSubmissionEntry[];
434
+ origin: ActionOrigin;
435
+ event: ActionTriggerEvent;
436
+ }
437
+ /**
438
+ * The first sink of the chain: the embedder's application. Installing it is
439
+ * the consent (it receives nothing the embedder could not already compute
440
+ * from `forms.list()` under `doc.forms.read`, so no submit scope gates it).
441
+ * Contract: synchronous acceptance marks the node `executed` ("handed to the
442
+ * embedder", not "delivered"); a synchronous throw marks it `failed`; a
443
+ * returned promise is not awaited, and a later rejection only emits a
444
+ * diagnostic. `submitToDocumentHome` lets a handler compose with the second
445
+ * sink (present only when the document has a submit-capable home).
446
+ */
447
+ type ActionSubmitHandler = (request: ActionSubmitRequest, chain: {
448
+ submitToDocumentHome: (() => Promise<FormSubmissionReceipt>) | null;
449
+ }) => void | Promise<void>;
450
+ /**
451
+ * The public capability, for embedders and chrome. Each `can*` twin takes the
452
+ * same arguments as its verb and answers "would the dispatcher accept this
453
+ * and attempt execution" (per-node truth lives in the result's `nodes`). Its
454
+ * settings (`getSettings`, `updateSettings`, `resetSettings`,
455
+ * `onSettingsChanged`) belong to the plugin, not to a document: a change
456
+ * reaches every open document.
457
+ */
458
+ interface ActionsCapability extends SettingsApi<ActionsSettings> {
459
+ /**
460
+ * Run a resolved tree on the dispatch queue and fire `onExecuted`; a
461
+ * failing node is reported in the result, not thrown. Rejects
462
+ * `operation-cancelled` when `options.signal` fires: before the tree
463
+ * starts, nothing runs; while it runs, it stops before its next node.
464
+ */
465
+ execute(tree: PdfActionTree, actionContext: ActionContext, options?: OperationOptions): Promise<ActionDispatchResult>;
466
+ /** The tree is complete and its root node's policy decision is `allow` or `adapter`. */
467
+ canExecute(tree: PdfActionTree, actionContext: ActionContext): boolean;
468
+ /**
469
+ * Run one Named verb (`NextPage`, `Print`, …) as a user-origin action
470
+ * without building a tree — the programmatic twin of a Named link click.
471
+ * `context` overrides the default `{ origin: 'user', source: { kind: 'api' } }`.
472
+ * Rejects `operation-cancelled` like `execute()`.
473
+ */
474
+ executeNamed(name: PdfNamedAction, context?: Partial<ActionContext>, options?: OperationOptions): Promise<ActionDispatchResult>;
475
+ /**
476
+ * Whether the rules would run this Named verb from `context` (a click from
477
+ * your code by default); `'Print'` also needs `doc.print`.
478
+ */
479
+ canExecuteNamed(name: PdfNamedAction, context?: Partial<ActionContext>): boolean;
480
+ /**
481
+ * Read the /A or /AA tree behind a source straight from the document
482
+ * (`null` when absent). This is the raw tree: dispatch-time rules such as
483
+ * ISO 32000-2 Table 197's "/A shadows /AA U" are not applied here. Rejects
484
+ * `operation-cancelled` when `options.signal` fires.
485
+ */
486
+ getActionTree(source: ActionTreeSource, options?: OperationOptions): Promise<PdfActionTree | null>;
487
+ /** Did `javascript.enabled` take effect — a script realm exists for this
488
+ * document. */
489
+ isScriptingEnabled(): boolean;
490
+ /**
491
+ * Report a trigger. Submission is synchronous: the queue slot is taken
492
+ * before this returns, so two dispatch calls execute in call order even
493
+ * when their resolutions race; all reads happen inside the queued
494
+ * operation. Never rejects: resolution failures come back as `refused`
495
+ * with a `trigger-failed` diagnostic, and a fired `options.signal` as
496
+ * `cancelled`, so `void dispatch(...)` is safe.
497
+ */
498
+ dispatch(trigger: ActionTrigger, options?: OperationOptions): Promise<ActionTriggerResult>;
499
+ /** The trigger's family is enabled (the `triggers` setting). */
500
+ canDispatch(trigger: ActionTrigger): boolean;
501
+ /** Identity-safe port install: the returned disposer clears the slot only
502
+ * while this adapter is still current; `null` force-clears. Installing an
503
+ * adapter fires an armed document-open sequence. */
504
+ setUiAdapter(adapter: ActionUiAdapter | null): Unsubscribe;
505
+ /**
506
+ * Run one embedder-owned document verb as one serialized queue operation:
507
+ * the document-open sequence if it is still armed → the before-event tree
508
+ * (/WS, /WP) → `operation()` → the after-event tree (/DS, /DP). Two
509
+ * concurrent calls never interleave their phases. A before-event failure
510
+ * never cancels the operation; `operation()` throwing skips the
511
+ * after-event and rethrows; the whole body honors `triggers.document:
512
+ * false` (trees skipped, operation still runs); print verbs hold the
513
+ * document-print latch, so nested `doc.print()` calls are suppressed with
514
+ * a `reentrant-print` diagnostic. The queue is held for the operation's
515
+ * duration on purpose: that is the serialization (/WS mutations are in the
516
+ * bytes a save operation pulls). `options.signal` firing before
517
+ * `operation()` starts skips it and rejects `operation-cancelled`; once it
518
+ * has started, it finishes, and so does the after-event.
519
+ */
520
+ runDocumentVerb<T>(verb: 'save' | 'print', operation: () => Promise<T> | T, options?: OperationOptions): Promise<T>;
521
+ /**
522
+ * The cooperative /WC door: runs the catalog will-close tree (after the
523
+ * document-open sequence) and resolves when its effects are committed.
524
+ * Call `documents.close()` after this resolves. Scripts never run inside
525
+ * teardown, so closing without this call skips /WC (unlike Acrobat); it is
526
+ * not an error. Never rejects, like `dispatch()`.
527
+ */
528
+ prepareClose(options?: OperationOptions): Promise<ActionTriggerResult>;
529
+ /**
530
+ * The first sink of the submit chain (an identity-safe slot like the UI
531
+ * adapter, but installing it does not fire the document-open sequence).
532
+ * With no handler and no submit-capable document home, submits block with
533
+ * a `no-submit-sink` diagnostic.
534
+ */
535
+ setSubmitHandler(handler: ActionSubmitHandler | null): Unsubscribe;
536
+ /**
537
+ * Interpret (or override) one action type from application code: the same
538
+ * door the stage and form plugins use for GoTo, Named, Hide and ResetForm.
539
+ * Deterministic last-wins on duplicates (a `duplicate-executor` diagnostic
540
+ * is reported); the disposer removes the entry only while it is still the
541
+ * current one.
542
+ */
543
+ registerExecutor(type: PdfActionType, executor: ActionExecutor): Unsubscribe;
544
+ /** Actions ran, whatever started them: one event per tree. */
545
+ readonly onExecuted: EventHook<ActionExecutedEvent>;
546
+ /** An action was blocked, reported or couldn't run; also dispatch, sink and budget problems. */
547
+ readonly onDiagnosticReported: EventHook<ActionDiagnosticReportedEvent>;
548
+ /** A script was stopped from doing something, or used something the viewer doesn't support. */
549
+ readonly onScriptDiagnosticReported: EventHook<ScriptDiagnosticReportedEvent>;
550
+ /** A script run ended with an error. */
551
+ readonly onScriptFailed: EventHook<ScriptFailedEvent>;
552
+ /** The document-open sequence ran (OpenAction / open destination). */
553
+ readonly onOpenSequenceCompleted: EventHook<OpenSequenceCompletedEvent>;
554
+ }
555
+ //#endregion
556
+ export { DocumentTriggerEvent as A, SubmitIntent as B, ActionUiAdapter as C, ActionsScriptEnvironment as D, ActionsConfig as E, PdfAnnotationEventKind as F, HoverTarget as G, triggerOriginOf as H, PdfFieldEventKind as I, createHoverPump as K, PdfNamedAction as L, PdfActionNode$1 as M, PdfActionTree$1 as N, ActionsScriptIdentity as O, PdfActionType$1 as P, ScriptDiagnosticReportedEvent as R, ActionTriggerResult as S, ActionsCapability as T, submitEntriesToUrlEncoded as U, eventOf as V, HoverPump as W, ActionSubmitHandler as _, ActionDispatchResult as a, ActionTrigger as b, ActionExecutorResult as c, ActionOrigin as d, ActionPolicy as f, ActionStepResult as g, ActionSource as h, ActionDiagnosticReportedEvent as i, OpenSequenceCompletedEvent as j, ActionsSettings as k, ActionNodeResult as l, ActionPolicyRow as m, ActionContext as n, ActionExecutedEvent as o, ActionPolicyDecision as p, ActionsToken as q, ActionDiagnostic as r, ActionExecutor as s, ACTIONS_DEFAULTS as t, ActionNodeStatus as u, ActionSubmitRequest as v, ActionUiContext as w, ActionTriggerEvent as x, ActionTreeSource as y, ScriptFailedEvent as z };
557
+ //# sourceMappingURL=contract-Cn-7mBY8.d.ts.map