@embedpdf/plugin-form 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.
Files changed (47) hide show
  1. package/dist/contract/host.cjs +29 -2
  2. package/dist/contract/host.cjs.map +1 -0
  3. package/dist/contract/host.d.cts +3 -2
  4. package/dist/contract/host.d.ts +3 -2
  5. package/dist/contract/host.js +14 -2
  6. package/dist/contract/host.js.map +1 -0
  7. package/dist/contract-BwcgtCOD.d.ts +566 -0
  8. package/dist/contract-CU0jrI_D.cjs +56 -0
  9. package/dist/contract-CU0jrI_D.cjs.map +1 -0
  10. package/dist/contract-D-yQxw3H.d.cts +566 -0
  11. package/dist/contract-DcncvPcF.js +45 -0
  12. package/dist/contract-DcncvPcF.js.map +1 -0
  13. package/dist/contract.cjs +17 -6
  14. package/dist/contract.d.cts +2 -8
  15. package/dist/contract.d.ts +2 -8
  16. package/dist/contract.js +2 -7
  17. package/dist/controller-CS6tV2m1.cjs +514 -0
  18. package/dist/controller-CS6tV2m1.cjs.map +1 -0
  19. package/dist/controller-Sr5M_8G8.js +497 -0
  20. package/dist/controller-Sr5M_8G8.js.map +1 -0
  21. package/dist/host-contract-1epLfK1S.d.cts +87 -0
  22. package/dist/host-contract-BRYUbpT_.d.ts +87 -0
  23. package/dist/index.cjs +2916 -1205
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +46 -17
  26. package/dist/index.d.ts +46 -17
  27. package/dist/index.js +2895 -1206
  28. package/dist/index.js.map +1 -1
  29. package/dist/scripting.cjs +3 -484
  30. package/dist/scripting.d.cts +58 -22
  31. package/dist/scripting.d.ts +58 -22
  32. package/dist/scripting.js +1 -482
  33. package/package.json +14 -13
  34. package/dist/contract.cjs.map +0 -1
  35. package/dist/contract.js.map +0 -1
  36. package/dist/internal.cjs +0 -4
  37. package/dist/internal.d.cts +0 -3
  38. package/dist/internal.d.ts +0 -3
  39. package/dist/internal.js +0 -3
  40. package/dist/scripting.cjs.map +0 -1
  41. package/dist/scripting.js.map +0 -1
  42. package/dist/types-Bpc32Qmx.d.cts +0 -309
  43. package/dist/types-C1uIIYfn.cjs +0 -16
  44. package/dist/types-C1uIIYfn.cjs.map +0 -1
  45. package/dist/types-DRirhZKr.d.ts +0 -309
  46. package/dist/types-DkQmmcTG.js +0 -12
  47. package/dist/types-DkQmmcTG.js.map +0 -1
@@ -1,309 +0,0 @@
1
- import { ActionContext, ActionDiagnostic, ActionOrigin, ActionSubmitRequest, ActionTriggerResult, PdfAnnotationEventKind, SubmitIntent } from "@embedpdf/plugin-actions/contract";
2
- import { AnnotationPropsPatch, ClickCreate } from "@embedpdf/plugin-annotation/contract";
3
- import { AnnotationRef, FormDataExport, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldFamily, FormFieldOption, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairOptions, FormRepairResult, FormSetValueResult, FormSnapshot, PdfActionTargetRef, WidgetAppearance } from "@embedpdf/engine-core/runtime";
4
- import { ScriptDiagnostic, ScriptExecutionError, ScriptUiEffect } from "@embedpdf/core-acrojs";
5
- //#region src/core/model.d.ts
6
- /** A content-space box (top-left origin, y-down, PDF points). */
7
- interface Box {
8
- x: number;
9
- y: number;
10
- width: number;
11
- height: number;
12
- }
13
- /** Stable client key for a field: object number when durable, else FQN. */
14
- type FieldKey = string;
15
- declare const fieldKeyOf: (field: {
16
- fieldObjectNumber: number;
17
- name: string;
18
- }) => FieldKey;
19
- interface Model {
20
- /** Engine truth; replaced wholesale on refresh, patched on write-backs. */
21
- snapshot: FormSnapshot | null;
22
- /** fieldKey → index into snapshot.fields. */
23
- byKey: Record<FieldKey, number>;
24
- /** annotObjectNumber → index into snapshot.fields (widget → field join). */
25
- byWidget: Record<number, number>;
26
- /** Fields with an in-flight engine write (disables their controls). */
27
- writing: Record<FieldKey, true>;
28
- /**
29
- * Widget geometry per page: annotObjectNumber → content-space box. Fed by
30
- * the shell from the WIDGET plane (one annotations read per page); value
31
- * writes never move widgets, so this survives snapshot refreshes and is
32
- * only cleared on structural form events.
33
- */
34
- geom: Record<number, Record<number, Box> | undefined>;
35
- /** Bumped on every change — cheap equality for memoized projections. */
36
- seq: number;
37
- }
38
- /** A widget hit: the annotation under the point and the field it belongs to. */
39
- interface WidgetHit {
40
- annotObjectNumber: number;
41
- field: FormFieldDTO;
42
- /** The widget's content-space box. */
43
- box: Box;
44
- }
45
- //#endregion
46
- //#region src/core/fill-items.d.ts
47
- interface FillItemBase {
48
- key: FieldKey;
49
- /** Widget identity — joins to the annotation plane. */
50
- annotObjectNumber: number;
51
- box: Box;
52
- /** Read-only field or write in flight: render, don't accept input. */
53
- disabled: boolean;
54
- /** Accessible name: /TU when present, else the fully qualified name. */
55
- label: string;
56
- }
57
- type FillItem = FillItemBase & ({
58
- control: 'text';
59
- value: string;
60
- multiline: boolean;
61
- password: boolean;
62
- maxLength: number | null;
63
- comb: boolean;
64
- } | {
65
- control: 'toggle';
66
- kind: 'checkbox' | 'radio';
67
- checked: boolean;
68
- onState: string;
69
- } | {
70
- control: 'choice';
71
- kind: 'combo' | 'list';
72
- edit: boolean;
73
- multi: boolean;
74
- options: FormFieldOption[];
75
- selected: string[];
76
- } | {
77
- control: 'button';
78
- } |
79
- /**
80
- * A signature field's widget. `signed` = it carries a `/V` (a signature
81
- * dictionary): the field is final and its appearance sealed — the
82
- * control inspects rather than signs. Unsigned: "sign here" — the
83
- * signing act itself belongs to the signature plugin.
84
- */
85
- {
86
- control: 'signature';
87
- signed: boolean;
88
- });
89
- //#endregion
90
- //#region src/tools.d.ts
91
- /** The families the palette can author (push buttons are not authorable). */
92
- type AuthorableFormFamily = Exclude<FormFieldFamily, 'pushbutton' | 'unknown'>;
93
- interface FormToolDef {
94
- id: string;
95
- /** The field family `placeField` commits (the FORM plane's vocabulary). */
96
- family: AuthorableFormFamily;
97
- /** The client kind the ANNOTATION registry routes on (props panel).
98
- * Not a PDF subtype — every widget is PDF `widget`; this is the view. */
99
- visualKind: 'widget-text' | 'widget-choice' | 'widget-toggle' | 'widget-box';
100
- /** What a bare click places (box policies only — fields are boxes). */
101
- clickCreate: Extract<ClickCreate, {
102
- width: number;
103
- }>;
104
- /** Seed drawing defaults: a placed field is VISIBLE (white box, gray
105
- * border) and restylable per tool through the shared style panel. */
106
- defaults: AnnotationPropsPatch;
107
- cursor: string;
108
- }
109
- declare const FORM_TOOLS: readonly FormToolDef[];
110
- declare const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef>;
111
- //#endregion
112
- //#region src/types.d.ts
113
- interface FormState {
114
- model: Model;
115
- }
116
- /** The scripting switch moved to `actionsPlugin({ javascript })` (D8). */
117
- interface FormPluginOptions {}
118
- type FormCommitStatus = 'applied' | 'unchanged' | 'rejected' | 'failed';
119
- interface FormCommitResult {
120
- status: FormCommitStatus;
121
- scripted: boolean;
122
- effectsResult: FormEffectsResult | null;
123
- uiEffects: FormUiEffect[];
124
- diagnostics: ScriptDiagnostic[];
125
- error?: ScriptExecutionError;
126
- }
127
- /**
128
- * One DOM-free UI request produced by the curated Acrobat scripting surface.
129
- * `phase` says WHO asked: `'boot'` = a document-open script (Adobe's
130
- * version-check boilerplate lives here — embedders typically suppress these
131
- * nags), `'user'` = a script triggered by the user's own interaction (a
132
- * validation alert — show it).
133
- */
134
- type FormUiEffect = ScriptUiEffect & {
135
- /** WHO asked, script-model axis: `'boot'` = a name-tree/document-open boot
136
- * script, `'user'` = a runtime script. */
137
- phase: 'boot' | 'user';
138
- /**
139
- * The dispatch-origin axis (present when the script ran inside an action
140
- * dispatch): a lifecycle `/OpenAction` script is NOT a name-tree boot
141
- * script — the two axes are deliberately separate. Providers use this for
142
- * the default visibility matrix (suppress lifecycle alerts, block
143
- * non-user print); embedder handlers receive it and may decide otherwise.
144
- */
145
- origin?: ActionOrigin;
146
- };
147
- /** Input for {@link FormCapability.placeField}. */
148
- interface PlaceFieldInput {
149
- family: AuthorableFormFamily;
150
- pageObjectNumber: number;
151
- /** Content-space LOGICAL field box (no visual padding semantics). */
152
- box: Box;
153
- /** Widget styling in the engine vocabulary (`WidgetAppearance`). Convert a
154
- * tool's flat CSS defaults with `widgetAppearanceFromProps` from
155
- * `@embedpdf/plugin-annotation`. Omitted → the engine's bare defaults. */
156
- appearance?: WidgetAppearance;
157
- }
158
- /** What {@link FormCapability.placeField} created. */
159
- interface PlacedField {
160
- field: FormFieldDTO;
161
- /** The widget placed on the requested page (join key to the annotation
162
- * plane for auto-selection), or null when the engine reported none. */
163
- widget: FormFieldDTO['widgets'][number] | null;
164
- }
165
- type FormAction = {
166
- type: 'SET_MODEL';
167
- model: Model;
168
- };
169
- /**
170
- * The form plugin's public capability: the FIELD plane. Widgets stay
171
- * annotations (geometry/appearance live there); this surface owns values,
172
- * interchange, and the fill-mode projection.
173
- */
174
- interface FormCapability {
175
- /** The current reconciled form state (null until the first load lands). */
176
- snapshot(): FormSnapshot | null;
177
- /** Re-read the form from the engine (imports/repair/remote bursts). */
178
- refresh(): Promise<void>;
179
- /** Fill controls for one page — content-space, framework-agnostic. */
180
- fillItems(pageObjectNumber: number): FillItem[];
181
- /**
182
- * The fill control for ONE widget, by annotation object number — the join
183
- * the annotation-plane render layer uses (its RenderItem carries the live
184
- * box, so this item's `box` is advisory). Reference-stable per model change.
185
- * Null until the snapshot lands, or for families with no fill control.
186
- */
187
- fillItem(annotObjectNumber: number): FillItem | null;
188
- /** Make sure a page's widget geometry is loaded (idempotent, lazy). */
189
- ensureGeom(pageObjectNumber: number): void;
190
- field(key: FieldKey): FormFieldDTO | null;
191
- fieldForWidget(annotObjectNumber: number): FormFieldDTO | null;
192
- /**
193
- * The widget under a content-space point on a page (any family), with
194
- * its field — the hit test a sibling plugin runs on a pointer sample
195
- * before deciding what a click means (a mark dropped over a signature
196
- * field). The model's own geometry answers when it is loaded; until then
197
- * the annotation plane's live boxes do, so the first click on a page
198
- * already resolves. The smallest containing widget wins.
199
- */
200
- widgetAt(pageObjectNumber: number, point: {
201
- x: number;
202
- y: number;
203
- }): WidgetHit | null;
204
- /** Commit a text value (call on blur/Enter — keystrokes stay local). */
205
- setText(key: FieldKey, value: string): Promise<void>;
206
- /** Toggle a checkbox/radio widget by its on-state; null clears the group. */
207
- toggle(key: FieldKey, onState: string | null): Promise<void>;
208
- /** Select choice options by export value. */
209
- choose(key: FieldKey, values: string[]): Promise<void>;
210
- /** Commit one originating-client value transaction, including K/V/C/F scripts when enabled. */
211
- commitValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormCommitResult>;
212
- /**
213
- * Execute one widget's `/A` activation. With the actions plugin installed
214
- * the FULL tree is delegated to its dispatcher (Hide/ResetForm buttons work
215
- * even with scripting off) — `kind: 'dispatched'`; without it, today's
216
- * scripting-transaction path runs — `kind: 'form'`.
217
- */
218
- activateWidget(key: FieldKey, annotationRef: AnnotationRef): Promise<WidgetActivationResult>;
219
- /**
220
- * Report one widget DOM event (pointer enter/leave, down/up, focus/blur).
221
- * With the actions plugin present the matching `/AA` tree dispatches
222
- * (hover rides the shared coalescing pump; `/A` shadows `/AA U` per ISO
223
- * Table 197); without it — or without a tree — this is a cheap no-op.
224
- * Fire-and-forget by design: results surface via the actions events.
225
- */
226
- notifyWidgetEvent(key: FieldKey, ref: AnnotationRef, event: PdfAnnotationEventKind): void;
227
- /** Restore a field to its /DV default. */
228
- reset(key: FieldKey): Promise<void>;
229
- /** Raw engine passthrough for anything the sugar above doesn't cover. */
230
- setValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormSetValueResult>;
231
- exportData(format?: FormDataFormat): Promise<FormDataExport>;
232
- importData(data: Uint8Array | ArrayBuffer, format?: FormDataFormat): Promise<FormImportResult>;
233
- repair(options?: FormRepairOptions): Promise<FormRepairResult>;
234
- /**
235
- * Create a field of `family` with one styled widget at a content-space box
236
- * — the palette tools' commit, and the programmatic authoring entry (works
237
- * with NO annotation plugin: a pure `doc.forms` call). The box is clamped
238
- * to the page; sizing policy (click default vs drag rect) is the caller's.
239
- * The field gets a deterministic auto-name (`text_1`, …; rename in the
240
- * field panel). Resolves AFTER the annotation plane (when present) has
241
- * re-read the page, so the returned widget is immediately selectable.
242
- */
243
- placeField(input: PlaceFieldInput): Promise<PlacedField>;
244
- /** The page's content box (`{0,0,w,h}`) — page-bound placement math. */
245
- pageBox(pageObjectNumber: number): Box | null;
246
- /** Field-plane properties: name, required, options, default value. */
247
- updateField(key: FieldKey, patch: FormFieldPatch): Promise<void>;
248
- /** Delete the field and every widget of it (cascades on the page). */
249
- deleteField(key: FieldKey): Promise<void>;
250
- /** Unlink one widget: it stays as an inert annotation, the field survives. */
251
- detachWidget(key: FieldKey, annotObjectNumber: number): Promise<void>;
252
- /**
253
- * The twins (permissions.md): would the family's verbs succeed now for
254
- * this session? `canRead` — the form model hydrates at all (false = the
255
- * hydration gate left it empty by right); `canFill` — value writes
256
- * (`setText`/`toggle`/`choose`/`reset`; also fused into every
257
- * `FillItem.disabled`); `canDesign` — the field-design family
258
- * (`placeField`/`updateField`/`deleteField`/`detachWidget`).
259
- */
260
- canRead(): boolean;
261
- canFill(): boolean;
262
- canDesign(): boolean;
263
- }
264
- /** What one widget activation did — which world handled it (see
265
- * {@link FormCapability.activateWidget}). Both framework call sites ignore
266
- * the value today; chrome that cares can discriminate on `kind`. */
267
- type WidgetActivationResult = {
268
- kind: 'form';
269
- result: FormCommitResult;
270
- } | {
271
- kind: 'dispatched';
272
- result: ActionTriggerResult;
273
- };
274
- /**
275
- * HOST lens — plugin-to-plugin only (the actions plugin's interim
276
- * `javascript` / `reset-form` executors). Import the token from
277
- * `@embedpdf/plugin-form/contract/host`, never from application code.
278
- */
279
- interface FormHostCapability extends FormCapability {
280
- /**
281
- * Execute one ResetForm action: resolve targets against the live snapshot
282
- * with the shared ISO selection (`null` = every field; a parent NAME
283
- * selects its descendants too; `exclude` = complement; a resolution
284
- * yielding zero refs never reaches the engine), reset as ONE engine
285
- * batch, refresh, then recalculate when scripting is enabled (Acrobat's
286
- * behaviour). `origin` (default `'user'`) is preserved through
287
- * recalculation surfacing — a lifecycle ResetForm's alerts stay lifecycle.
288
- */
289
- resetFormAction(fields: PdfActionTargetRef[] | null, exclude: boolean, origin?: ActionOrigin): Promise<FormCommitResult>;
290
- /**
291
- * The submit dataset resolver (Phase 4, D7): fresh engine read + the pure
292
- * ISO builder (`field-selection.ts`). Registered with the actions plugin
293
- * as THE resolver for both action-node and script submits.
294
- */
295
- resolveSubmitDataset(intent: SubmitIntent, ctx: ActionContext, diagnose: (diagnostic: ActionDiagnostic) => void): Promise<ActionSubmitRequest>;
296
- /** The form DOCUMENT-commit sink (D3): engine `applyEffects` + snapshot
297
- * reconciliation. Sink contract: never throws, never enqueues, never
298
- * touches the script host — callable under a held host transaction. */
299
- commitScriptFormEffects(effects: FormEffect[]): Promise<FormEffectsResult>;
300
- }
301
- /**
302
- * The form capability token. Typed to the full {@link FormHostCapability}
303
- * here (the package internals + the `/internal` entry use this view). The
304
- * package root re-exports the SAME token narrowed to {@link FormCapability}.
305
- */
306
- declare const FormToken: import("@embedpdf/core").CapabilityToken<FormHostCapability>;
307
- //#endregion
308
- export { FillItem as _, FormHostCapability as a, WidgetHit as b, FormToken as c, PlacedField as d, WidgetActivationResult as f, FormToolDef as g, FORM_TOOL_BY_ID as h, FormCommitStatus as i, FormUiEffect as l, FORM_TOOLS as m, FormCapability as n, FormPluginOptions as o, AuthorableFormFamily as p, FormCommitResult as r, FormState as s, FormAction as t, PlaceFieldInput as u, Box as v, fieldKeyOf as x, FieldKey as y };
309
- //# sourceMappingURL=types-DRirhZKr.d.ts.map
@@ -1,12 +0,0 @@
1
- import { createCapabilityToken } from "@embedpdf/core";
2
- //#region src/types.ts
3
- /**
4
- * The form capability token. Typed to the full {@link FormHostCapability}
5
- * here (the package internals + the `/internal` entry use this view). The
6
- * package root re-exports the SAME token narrowed to {@link FormCapability}.
7
- */
8
- const FormToken = createCapabilityToken("form");
9
- //#endregion
10
- export { FormToken as t };
11
-
12
- //# sourceMappingURL=types-DkQmmcTG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DkQmmcTG.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n AnnotationRef,\n FormDataExport,\n FormDataFormat,\n FormFieldDTO,\n FormFieldFamily,\n FormFieldPatch,\n FormFieldRef,\n FormFieldValue,\n FormImportResult,\n FormRepairOptions,\n FormRepairResult,\n FormSetValueResult,\n FormEffect,\n FormEffectsResult,\n FormSnapshot,\n PdfActionTargetRef,\n WidgetAppearance,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSubmitRequest,\n ActionTriggerResult,\n PdfAnnotationEventKind,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\nimport type { ScriptDiagnostic, ScriptExecutionError, ScriptUiEffect } from '@embedpdf/core-acrojs';\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { FillItem } from './core/fill-items';\nimport type { Box, FieldKey, Model, WidgetHit } from './core/model';\nimport type { AuthorableFormFamily } from './tools';\n\nexport interface FormState {\n model: Model;\n}\n\n/** The scripting switch moved to `actionsPlugin({ javascript })` (D8). */\nexport interface FormPluginOptions {}\n\nexport type FormCommitStatus = 'applied' | 'unchanged' | 'rejected' | 'failed';\n\nexport interface FormCommitResult {\n status: FormCommitStatus;\n scripted: boolean;\n effectsResult: FormEffectsResult | null;\n uiEffects: FormUiEffect[];\n diagnostics: ScriptDiagnostic[];\n error?: ScriptExecutionError;\n}\n\n/**\n * One DOM-free UI request produced by the curated Acrobat scripting surface.\n * `phase` says WHO asked: `'boot'` = a document-open script (Adobe's\n * version-check boilerplate lives here — embedders typically suppress these\n * nags), `'user'` = a script triggered by the user's own interaction (a\n * validation alert — show it).\n */\nexport type FormUiEffect = ScriptUiEffect & {\n /** WHO asked, script-model axis: `'boot'` = a name-tree/document-open boot\n * script, `'user'` = a runtime script. */\n phase: 'boot' | 'user';\n /**\n * The dispatch-origin axis (present when the script ran inside an action\n * dispatch): a lifecycle `/OpenAction` script is NOT a name-tree boot\n * script — the two axes are deliberately separate. Providers use this for\n * the default visibility matrix (suppress lifecycle alerts, block\n * non-user print); embedder handlers receive it and may decide otherwise.\n */\n origin?: ActionOrigin;\n};\n\n/** Input for {@link FormCapability.placeField}. */\nexport interface PlaceFieldInput {\n family: AuthorableFormFamily;\n pageObjectNumber: number;\n /** Content-space LOGICAL field box (no visual padding semantics). */\n box: Box;\n /** Widget styling in the engine vocabulary (`WidgetAppearance`). Convert a\n * tool's flat CSS defaults with `widgetAppearanceFromProps` from\n * `@embedpdf/plugin-annotation`. Omitted → the engine's bare defaults. */\n appearance?: WidgetAppearance;\n}\n\n/** What {@link FormCapability.placeField} created. */\nexport interface PlacedField {\n field: FormFieldDTO;\n /** The widget placed on the requested page (join key to the annotation\n * plane for auto-selection), or null when the engine reported none. */\n widget: FormFieldDTO['widgets'][number] | null;\n}\n\nexport type FormAction = { type: 'SET_MODEL'; model: Model };\n\n/**\n * The form plugin's public capability: the FIELD plane. Widgets stay\n * annotations (geometry/appearance live there); this surface owns values,\n * interchange, and the fill-mode projection.\n */\nexport interface FormCapability {\n /** The current reconciled form state (null until the first load lands). */\n snapshot(): FormSnapshot | null;\n /** Re-read the form from the engine (imports/repair/remote bursts). */\n refresh(): Promise<void>;\n\n /** Fill controls for one page — content-space, framework-agnostic. */\n fillItems(pageObjectNumber: number): FillItem[];\n /**\n * The fill control for ONE widget, by annotation object number — the join\n * the annotation-plane render layer uses (its RenderItem carries the live\n * box, so this item's `box` is advisory). Reference-stable per model change.\n * Null until the snapshot lands, or for families with no fill control.\n */\n fillItem(annotObjectNumber: number): FillItem | null;\n /** Make sure a page's widget geometry is loaded (idempotent, lazy). */\n ensureGeom(pageObjectNumber: number): void;\n\n field(key: FieldKey): FormFieldDTO | null;\n fieldForWidget(annotObjectNumber: number): FormFieldDTO | null;\n /**\n * The widget under a content-space point on a page (any family), with\n * its field — the hit test a sibling plugin runs on a pointer sample\n * before deciding what a click means (a mark dropped over a signature\n * field). The model's own geometry answers when it is loaded; until then\n * the annotation plane's live boxes do, so the first click on a page\n * already resolves. The smallest containing widget wins.\n */\n widgetAt(pageObjectNumber: number, point: { x: number; y: number }): WidgetHit | null;\n\n /** Commit a text value (call on blur/Enter — keystrokes stay local). */\n setText(key: FieldKey, value: string): Promise<void>;\n /** Toggle a checkbox/radio widget by its on-state; null clears the group. */\n toggle(key: FieldKey, onState: string | null): Promise<void>;\n /** Select choice options by export value. */\n choose(key: FieldKey, values: string[]): Promise<void>;\n /** Commit one originating-client value transaction, including K/V/C/F scripts when enabled. */\n commitValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormCommitResult>;\n /**\n * Execute one widget's `/A` activation. With the actions plugin installed\n * the FULL tree is delegated to its dispatcher (Hide/ResetForm buttons work\n * even with scripting off) — `kind: 'dispatched'`; without it, today's\n * scripting-transaction path runs — `kind: 'form'`.\n */\n activateWidget(key: FieldKey, annotationRef: AnnotationRef): Promise<WidgetActivationResult>;\n /**\n * Report one widget DOM event (pointer enter/leave, down/up, focus/blur).\n * With the actions plugin present the matching `/AA` tree dispatches\n * (hover rides the shared coalescing pump; `/A` shadows `/AA U` per ISO\n * Table 197); without it — or without a tree — this is a cheap no-op.\n * Fire-and-forget by design: results surface via the actions events.\n */\n notifyWidgetEvent(key: FieldKey, ref: AnnotationRef, event: PdfAnnotationEventKind): void;\n /** Restore a field to its /DV default. */\n reset(key: FieldKey): Promise<void>;\n /** Raw engine passthrough for anything the sugar above doesn't cover. */\n setValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormSetValueResult>;\n\n exportData(format?: FormDataFormat): Promise<FormDataExport>;\n importData(data: Uint8Array | ArrayBuffer, format?: FormDataFormat): Promise<FormImportResult>;\n repair(options?: FormRepairOptions): Promise<FormRepairResult>;\n\n // ── design mode (doc.forms.modify) ─────────────────────────────────────\n /**\n * Create a field of `family` with one styled widget at a content-space box\n * — the palette tools' commit, and the programmatic authoring entry (works\n * with NO annotation plugin: a pure `doc.forms` call). The box is clamped\n * to the page; sizing policy (click default vs drag rect) is the caller's.\n * The field gets a deterministic auto-name (`text_1`, …; rename in the\n * field panel). Resolves AFTER the annotation plane (when present) has\n * re-read the page, so the returned widget is immediately selectable.\n */\n placeField(input: PlaceFieldInput): Promise<PlacedField>;\n /** The page's content box (`{0,0,w,h}`) — page-bound placement math. */\n pageBox(pageObjectNumber: number): Box | null;\n /** Field-plane properties: name, required, options, default value. */\n updateField(key: FieldKey, patch: FormFieldPatch): Promise<void>;\n /** Delete the field and every widget of it (cascades on the page). */\n deleteField(key: FieldKey): Promise<void>;\n /** Unlink one widget: it stays as an inert annotation, the field survives. */\n detachWidget(key: FieldKey, annotObjectNumber: number): Promise<void>;\n\n /**\n * The twins (permissions.md): would the family's verbs succeed now for\n * this session? `canRead` — the form model hydrates at all (false = the\n * hydration gate left it empty by right); `canFill` — value writes\n * (`setText`/`toggle`/`choose`/`reset`; also fused into every\n * `FillItem.disabled`); `canDesign` — the field-design family\n * (`placeField`/`updateField`/`deleteField`/`detachWidget`).\n */\n canRead(): boolean;\n canFill(): boolean;\n canDesign(): boolean;\n}\n\n/** What one widget activation did — which world handled it (see\n * {@link FormCapability.activateWidget}). Both framework call sites ignore\n * the value today; chrome that cares can discriminate on `kind`. */\nexport type WidgetActivationResult =\n | { kind: 'form'; result: FormCommitResult }\n | { kind: 'dispatched'; result: ActionTriggerResult };\n\n/**\n * HOST lens — plugin-to-plugin only (the actions plugin's interim\n * `javascript` / `reset-form` executors). Import the token from\n * `@embedpdf/plugin-form/contract/host`, never from application code.\n */\nexport interface FormHostCapability extends FormCapability {\n /**\n * Execute one ResetForm action: resolve targets against the live snapshot\n * with the shared ISO selection (`null` = every field; a parent NAME\n * selects its descendants too; `exclude` = complement; a resolution\n * yielding zero refs never reaches the engine), reset as ONE engine\n * batch, refresh, then recalculate when scripting is enabled (Acrobat's\n * behaviour). `origin` (default `'user'`) is preserved through\n * recalculation surfacing — a lifecycle ResetForm's alerts stay lifecycle.\n */\n resetFormAction(\n fields: PdfActionTargetRef[] | null,\n exclude: boolean,\n origin?: ActionOrigin,\n ): Promise<FormCommitResult>;\n /**\n * The submit dataset resolver (Phase 4, D7): fresh engine read + the pure\n * ISO builder (`field-selection.ts`). Registered with the actions plugin\n * as THE resolver for both action-node and script submits.\n */\n resolveSubmitDataset(\n intent: SubmitIntent,\n ctx: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n ): Promise<ActionSubmitRequest>;\n /** The form DOCUMENT-commit sink (D3): engine `applyEffects` + snapshot\n * reconciliation. Sink contract: never throws, never enqueues, never\n * touches the script host — callable under a held host transaction. */\n commitScriptFormEffects(effects: FormEffect[]): Promise<FormEffectsResult>;\n}\n\n/**\n * The form capability token. Typed to the full {@link FormHostCapability}\n * here (the package internals + the `/internal` entry use this view). The\n * package root re-exports the SAME token narrowed to {@link FormCapability}.\n */\nexport const FormToken = createCapabilityToken<FormHostCapability>('form');\n\nexport type { FillItem } from './core/fill-items';\nexport type { Box, FieldKey, WidgetHit } from './core/model';\n"],"mappings":";;;;;;;AAoPA,MAAa,YAAY,sBAA0C,MAAM"}