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