@embedpdf/plugin-form 3.0.0-next.10 → 3.0.0-next.11

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/index.d.cts CHANGED
@@ -1,219 +1,9 @@
1
- import { AnnotationRef, DocumentHandle, FormDataExport, FormDataFormat, FormEffectsResult, FormFieldDTO, FormFieldDTO as FormFieldDTO$1, FormFieldFamily, FormFieldOption, FormFieldPatch, FormFieldPatch as FormFieldPatch$1, FormFieldRef, FormFieldValue, FormImportResult, FormRepairOptions, FormRepairResult, FormSetValueResult, FormSnapshot, PdfActionTree, WidgetAppearance, WidgetAppearance as WidgetAppearance$1 } from "@embedpdf/engine-core/runtime";
2
- import { ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptIdentity, ScriptUiEffect } from "@embedpdf/core-acrojs";
3
- import { ScriptSandboxFactory } from "@embedpdf/core-js-sandbox";
4
- import { DocumentMeta } from "@embedpdf/core";
5
- import { AnnotationPropsPatch, ClickCreate } from "@embedpdf/plugin-annotation";
6
- //#region src/core/model.d.ts
7
- /** A content-space box (top-left origin, y-down, PDF points). */
8
- interface Box {
9
- x: number;
10
- y: number;
11
- width: number;
12
- height: number;
13
- }
14
- /** Stable client key for a field: object number when durable, else FQN. */
15
- type FieldKey = string;
16
- declare const fieldKeyOf: (field: {
17
- fieldObjectNumber: number;
18
- name: string;
19
- }) => FieldKey;
20
- interface Model {
21
- /** Engine truth; replaced wholesale on refresh, patched on write-backs. */
22
- snapshot: FormSnapshot | null;
23
- /** fieldKey → index into snapshot.fields. */
24
- byKey: Record<FieldKey, number>;
25
- /** annotObjectNumber → index into snapshot.fields (widget → field join). */
26
- byWidget: Record<number, number>;
27
- /** Fields with an in-flight engine write (disables their controls). */
28
- writing: Record<FieldKey, true>;
29
- /**
30
- * Widget geometry per page: annotObjectNumber → content-space box. Fed by
31
- * the shell from the WIDGET plane (one annotations read per page); value
32
- * writes never move widgets, so this survives snapshot refreshes and is
33
- * only cleared on structural form events.
34
- */
35
- geom: Record<number, Record<number, Box> | undefined>;
36
- /** Bumped on every change — cheap equality for memoized projections. */
37
- seq: number;
38
- }
39
- //#endregion
40
- //#region src/core/fill-items.d.ts
41
- interface FillItemBase {
42
- key: FieldKey;
43
- /** Widget identity — joins to the annotation plane. */
44
- annotObjectNumber: number;
45
- box: Box;
46
- /** Read-only field or write in flight: render, don't accept input. */
47
- disabled: boolean;
48
- /** Accessible name: /TU when present, else the fully qualified name. */
49
- label: string;
50
- }
51
- type FillItem = FillItemBase & ({
52
- control: 'text';
53
- value: string;
54
- multiline: boolean;
55
- password: boolean;
56
- maxLength: number | null;
57
- comb: boolean;
58
- } | {
59
- control: 'toggle';
60
- kind: 'checkbox' | 'radio';
61
- checked: boolean;
62
- onState: string;
63
- } | {
64
- control: 'choice';
65
- kind: 'combo' | 'list';
66
- edit: boolean;
67
- multi: boolean;
68
- options: FormFieldOption[];
69
- selected: string[];
70
- } | {
71
- control: 'button';
72
- });
73
- //#endregion
74
- //#region src/types.d.ts
75
- interface FormState {
76
- model: Model;
77
- }
78
- interface FormScriptingOptions {
79
- /** Explicit opt-in. PDF JavaScript remains inert when false/omitted. */
80
- enabled: boolean;
81
- /** Override the lazy QuickJS factory (tests or another isolated VM). */
82
- sandboxFactory?: ScriptSandboxFactory;
83
- /** Optional embedder identity fields layered over engine/JWT identity. */
84
- identity?: Partial<ScriptIdentity> | (() => Partial<ScriptIdentity>);
85
- /** Target document filename exposed as `this.documentFileName`. */
86
- fileName?: () => string;
87
- /** Injected deterministic transaction environment. */
88
- now?: () => number;
89
- utcOffsetMinutes?: () => number;
90
- randomSeed?: () => number;
91
- budget?: ScriptBudget;
92
- /** Framework/application port for app.alert, print, and page navigation. */
93
- onUiEffect?: (effect: ScriptUiEffect) => void;
94
- onDiagnostic?: (diagnostic: ScriptDiagnostic) => void;
95
- onError?: (error: ScriptExecutionError) => void;
96
- }
97
- interface FormPluginOptions {
98
- scripting?: FormScriptingOptions;
99
- }
100
- type FormCommitStatus = 'applied' | 'unchanged' | 'rejected' | 'failed';
101
- interface FormCommitResult {
102
- status: FormCommitStatus;
103
- scripted: boolean;
104
- effectsResult: FormEffectsResult | null;
105
- uiEffects: FormUiEffect[];
106
- diagnostics: ScriptDiagnostic[];
107
- error?: ScriptExecutionError;
108
- }
109
- /**
110
- * One DOM-free UI request produced by the curated Acrobat scripting surface.
111
- * `phase` says WHO asked: `'boot'` = a document-open script (Adobe's
112
- * version-check boilerplate lives here — embedders typically suppress these
113
- * nags), `'user'` = a script triggered by the user's own interaction (a
114
- * validation alert — show it).
115
- */
116
- type FormUiEffect = ScriptUiEffect & {
117
- phase: 'boot' | 'user';
118
- };
119
- /** Runtime adapter for alerts, print requests, and zero-based page navigation. */
120
- type FormUiEffectProvider = (effect: FormUiEffect) => void;
121
- /** Input for {@link FormCapability.placeField}. */
122
- interface PlaceFieldInput {
123
- family: Exclude<FormFieldFamily, 'pushbutton' | 'signature' | 'unknown'>;
124
- pageObjectNumber: number;
125
- /** Content-space LOGICAL field box (no visual padding semantics). */
126
- box: Box;
127
- /** Widget styling in the engine vocabulary (`WidgetAppearance`). Convert a
128
- * tool's flat CSS defaults with `widgetAppearanceFromProps` from
129
- * `@embedpdf/plugin-annotation`. Omitted → the engine's bare defaults. */
130
- appearance?: WidgetAppearance$1;
131
- }
132
- /** What {@link FormCapability.placeField} created. */
133
- interface PlacedField {
134
- field: FormFieldDTO$1;
135
- /** The widget placed on the requested page (join key to the annotation
136
- * plane for auto-selection), or null when the engine reported none. */
137
- widget: FormFieldDTO$1['widgets'][number] | null;
138
- }
139
- type FormAction = {
140
- type: 'SET_MODEL';
141
- model: Model;
142
- };
143
- /**
144
- * The form plugin's public capability: the FIELD plane. Widgets stay
145
- * annotations (geometry/appearance live there); this surface owns values,
146
- * interchange, and the fill-mode projection.
147
- */
148
- interface FormCapability {
149
- /** The current reconciled form state (null until the first load lands). */
150
- snapshot(): FormSnapshot | null;
151
- /** Re-read the form from the engine (imports/repair/remote bursts). */
152
- refresh(): Promise<void>;
153
- /** Fill controls for one page — content-space, framework-agnostic. */
154
- fillItems(pageObjectNumber: number): FillItem[];
155
- /**
156
- * The fill control for ONE widget, by annotation object number — the join
157
- * the annotation-plane render layer uses (its RenderItem carries the live
158
- * box, so this item's `box` is advisory). Reference-stable per model change.
159
- * Null until the snapshot lands, or for families with no fill control.
160
- */
161
- fillItem(annotObjectNumber: number): FillItem | null;
162
- /** Make sure a page's widget geometry is loaded (idempotent, lazy). */
163
- ensureGeom(pageObjectNumber: number): void;
164
- field(key: FieldKey): FormFieldDTO$1 | null;
165
- fieldForWidget(annotObjectNumber: number): FormFieldDTO$1 | null;
166
- /** Commit a text value (call on blur/Enter — keystrokes stay local). */
167
- setText(key: FieldKey, value: string): Promise<void>;
168
- /** Toggle a checkbox/radio widget by its on-state; null clears the group. */
169
- toggle(key: FieldKey, onState: string | null): Promise<void>;
170
- /** Select choice options by export value. */
171
- choose(key: FieldKey, values: string[]): Promise<void>;
172
- /** Commit one originating-client value transaction, including K/V/C/F scripts when enabled. */
173
- commitValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormCommitResult>;
174
- /** Execute one widget's `/A` activation action (and `/Next`) when scripting is enabled. */
175
- activateWidget(key: FieldKey, annotationRef: AnnotationRef): Promise<FormCommitResult>;
176
- /** Install the framework/application adapter for script-produced UI requests. */
177
- setUiEffectProvider(provider: FormUiEffectProvider | null): void;
178
- /** Restore a field to its /DV default. */
179
- reset(key: FieldKey): Promise<void>;
180
- /** Raw engine passthrough for anything the sugar above doesn't cover. */
181
- setValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormSetValueResult>;
182
- exportData(format?: FormDataFormat): Promise<FormDataExport>;
183
- importData(data: Uint8Array | ArrayBuffer, format?: FormDataFormat): Promise<FormImportResult>;
184
- repair(options?: FormRepairOptions): Promise<FormRepairResult>;
185
- /**
186
- * Create a field of `family` with one styled widget at a content-space box
187
- * — the palette tools' commit, and the programmatic authoring entry (works
188
- * with NO annotation plugin: a pure `doc.forms` call). The box is clamped
189
- * to the page; sizing policy (click default vs drag rect) is the caller's.
190
- * The field gets a deterministic auto-name (`text_1`, …; rename in the
191
- * field panel). Resolves AFTER the annotation plane (when present) has
192
- * re-read the page, so the returned widget is immediately selectable.
193
- */
194
- placeField(input: PlaceFieldInput): Promise<PlacedField>;
195
- /** The page's content box (`{0,0,w,h}`) — page-bound placement math. */
196
- pageBox(pageObjectNumber: number): Box | null;
197
- /** Field-plane properties: name, required, options, default value. */
198
- updateField(key: FieldKey, patch: FormFieldPatch$1): Promise<void>;
199
- /** Delete the field and every widget of it (cascades on the page). */
200
- deleteField(key: FieldKey): Promise<void>;
201
- /** Unlink one widget: it stays as an inert annotation, the field survives. */
202
- detachWidget(key: FieldKey, annotObjectNumber: number): Promise<void>;
203
- /**
204
- * The twins (permissions.md): would the family's verbs succeed now for
205
- * this session? `canRead` — the form model hydrates at all (false = the
206
- * hydration gate left it empty by right); `canFill` — value writes
207
- * (`setText`/`toggle`/`choose`/`reset`; also fused into every
208
- * `FillItem.disabled`); `canDesign` — the field-design family
209
- * (`placeField`/`updateField`/`deleteField`/`detachWidget`).
210
- */
211
- canRead(): boolean;
212
- canFill(): boolean;
213
- canDesign(): boolean;
214
- }
215
- declare const FormToken: import("@embedpdf/core").CapabilityToken<FormCapability>;
216
- //#endregion
1
+ import { _ as fieldKeyOf, a as FormHostCapability, c as FormState, d as PlaceFieldInput, f as PlacedField, g as FieldKey, h as Box, i as FormCommitStatus, m as FillItem, n as FormCapability, o as FormPluginOptions, p as WidgetActivationResult, r as FormCommitResult, s as FormScriptingOptions, t as FormAction, u as FormUiEffect } from "./types-Blr4QQM5.cjs";
2
+ import { FormFieldDTO, FormFieldPatch, FormToken, WidgetAppearance } from "./contract.cjs";
3
+ import { FormScriptingController, createFormScriptingController } from "./scripting.cjs";
4
+ import { createSerialQueue } from "@embedpdf/core";
5
+ import { FormFieldFamily } from "@embedpdf/engine-core/runtime";
6
+ import { AnnotationPropsPatch, ClickCreate } from "@embedpdf/plugin-annotation/contract";
217
7
  //#region src/form.plugin.d.ts
218
8
  /**
219
9
  * The form plugin: the FIELD plane. Document-scoped; requires the
@@ -226,38 +16,11 @@ declare const FormToken: import("@embedpdf/core").CapabilityToken<FormCapability
226
16
  * Design mode = the 'form-edit' / palette tools: no 'form-fill' tag, so
227
17
  * widgets become ordinary editable annotations.
228
18
  */
229
- declare const formPlugin: (options?: FormPluginOptions) => import("@embedpdf/core").PluginDef<FormState, FormAction, FormCapability>;
230
- //#endregion
231
- //#region src/scripting.d.ts
232
- interface FormScriptingControllerOptions {
233
- doc: DocumentHandle;
234
- document(): DocumentMeta | null;
235
- config: FormScriptingOptions;
236
- sandboxFactory: ScriptSandboxFactory;
237
- }
238
- declare class FormScriptingController {
239
- private readonly options;
240
- private sandboxPromise;
241
- private booted;
242
- private disposed;
243
- private sequence;
244
- constructor(options: FormScriptingControllerOptions);
245
- dispose(): void;
246
- commit(snapshot: FormSnapshot, ref: FormFieldRef, proposed: FormFieldValue): Promise<FormCommitResult>;
247
- /** Execute one originating widget's activation action (`/A`, including `/Next`). */
248
- activate(snapshot: FormSnapshot, ref: FormFieldRef, action: PdfActionTree): Promise<FormCommitResult>;
249
- /** Run lazy document boot plus the `/CO` chain without a user field change. */
250
- recalculate(snapshot: FormSnapshot): Promise<FormCommitResult>;
251
- private transact;
252
- private sandbox;
253
- private failed;
254
- private finishRejected;
255
- }
256
- declare function createFormScriptingController(options: FormScriptingControllerOptions): FormScriptingController;
19
+ declare const formPlugin: (options?: FormPluginOptions) => import("@embedpdf/core").PluginDef<FormState, FormAction, FormHostCapability>;
257
20
  //#endregion
258
21
  //#region src/mutationQueue.d.ts
259
- /** Small promise-tail queue: failures never poison later mutations. */
260
- declare function createSerialMutationQueue(): <T>(operation: () => Promise<T>) => Promise<T>;
22
+ /** The core serial queue under its historical form-plugin name. */
23
+ declare const createSerialMutationQueue: typeof createSerialQueue;
261
24
  //#endregion
262
25
  //#region src/tools.d.ts
263
26
  /** The families the palette can author (no pushbutton/signature tools). */
@@ -281,5 +44,5 @@ interface FormToolDef {
281
44
  declare const FORM_TOOLS: readonly FormToolDef[];
282
45
  declare const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef>;
283
46
  //#endregion
284
- export { type AuthorableFormFamily, type Box, FORM_TOOLS, FORM_TOOL_BY_ID, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, FormScriptingController, type FormScriptingOptions, type FormState, FormToken, type FormToolDef, type FormUiEffect, type FormUiEffectProvider, type PlaceFieldInput, type PlacedField, type WidgetAppearance, createFormScriptingController, createSerialMutationQueue, fieldKeyOf, formPlugin };
47
+ export { type AuthorableFormFamily, type Box, FORM_TOOLS, FORM_TOOL_BY_ID, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, FormScriptingController, type FormScriptingOptions, type FormState, FormToken, type FormToolDef, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance, createFormScriptingController, createSerialMutationQueue, fieldKeyOf, formPlugin };
285
48
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,219 +1,9 @@
1
- import { DocumentMeta } from "@embedpdf/core";
2
- import { AnnotationPropsPatch, ClickCreate } from "@embedpdf/plugin-annotation";
3
- import { AnnotationRef, DocumentHandle, FormDataExport, FormDataFormat, FormEffectsResult, FormFieldDTO, FormFieldDTO as FormFieldDTO$1, FormFieldFamily, FormFieldOption, FormFieldPatch, FormFieldPatch as FormFieldPatch$1, FormFieldRef, FormFieldValue, FormImportResult, FormRepairOptions, FormRepairResult, FormSetValueResult, FormSnapshot, PdfActionTree, WidgetAppearance, WidgetAppearance as WidgetAppearance$1 } from "@embedpdf/engine-core/runtime";
4
- import { ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptIdentity, ScriptUiEffect } from "@embedpdf/core-acrojs";
5
- import { ScriptSandboxFactory } from "@embedpdf/core-js-sandbox";
6
- //#region src/core/model.d.ts
7
- /** A content-space box (top-left origin, y-down, PDF points). */
8
- interface Box {
9
- x: number;
10
- y: number;
11
- width: number;
12
- height: number;
13
- }
14
- /** Stable client key for a field: object number when durable, else FQN. */
15
- type FieldKey = string;
16
- declare const fieldKeyOf: (field: {
17
- fieldObjectNumber: number;
18
- name: string;
19
- }) => FieldKey;
20
- interface Model {
21
- /** Engine truth; replaced wholesale on refresh, patched on write-backs. */
22
- snapshot: FormSnapshot | null;
23
- /** fieldKey → index into snapshot.fields. */
24
- byKey: Record<FieldKey, number>;
25
- /** annotObjectNumber → index into snapshot.fields (widget → field join). */
26
- byWidget: Record<number, number>;
27
- /** Fields with an in-flight engine write (disables their controls). */
28
- writing: Record<FieldKey, true>;
29
- /**
30
- * Widget geometry per page: annotObjectNumber → content-space box. Fed by
31
- * the shell from the WIDGET plane (one annotations read per page); value
32
- * writes never move widgets, so this survives snapshot refreshes and is
33
- * only cleared on structural form events.
34
- */
35
- geom: Record<number, Record<number, Box> | undefined>;
36
- /** Bumped on every change — cheap equality for memoized projections. */
37
- seq: number;
38
- }
39
- //#endregion
40
- //#region src/core/fill-items.d.ts
41
- interface FillItemBase {
42
- key: FieldKey;
43
- /** Widget identity — joins to the annotation plane. */
44
- annotObjectNumber: number;
45
- box: Box;
46
- /** Read-only field or write in flight: render, don't accept input. */
47
- disabled: boolean;
48
- /** Accessible name: /TU when present, else the fully qualified name. */
49
- label: string;
50
- }
51
- type FillItem = FillItemBase & ({
52
- control: 'text';
53
- value: string;
54
- multiline: boolean;
55
- password: boolean;
56
- maxLength: number | null;
57
- comb: boolean;
58
- } | {
59
- control: 'toggle';
60
- kind: 'checkbox' | 'radio';
61
- checked: boolean;
62
- onState: string;
63
- } | {
64
- control: 'choice';
65
- kind: 'combo' | 'list';
66
- edit: boolean;
67
- multi: boolean;
68
- options: FormFieldOption[];
69
- selected: string[];
70
- } | {
71
- control: 'button';
72
- });
73
- //#endregion
74
- //#region src/types.d.ts
75
- interface FormState {
76
- model: Model;
77
- }
78
- interface FormScriptingOptions {
79
- /** Explicit opt-in. PDF JavaScript remains inert when false/omitted. */
80
- enabled: boolean;
81
- /** Override the lazy QuickJS factory (tests or another isolated VM). */
82
- sandboxFactory?: ScriptSandboxFactory;
83
- /** Optional embedder identity fields layered over engine/JWT identity. */
84
- identity?: Partial<ScriptIdentity> | (() => Partial<ScriptIdentity>);
85
- /** Target document filename exposed as `this.documentFileName`. */
86
- fileName?: () => string;
87
- /** Injected deterministic transaction environment. */
88
- now?: () => number;
89
- utcOffsetMinutes?: () => number;
90
- randomSeed?: () => number;
91
- budget?: ScriptBudget;
92
- /** Framework/application port for app.alert, print, and page navigation. */
93
- onUiEffect?: (effect: ScriptUiEffect) => void;
94
- onDiagnostic?: (diagnostic: ScriptDiagnostic) => void;
95
- onError?: (error: ScriptExecutionError) => void;
96
- }
97
- interface FormPluginOptions {
98
- scripting?: FormScriptingOptions;
99
- }
100
- type FormCommitStatus = 'applied' | 'unchanged' | 'rejected' | 'failed';
101
- interface FormCommitResult {
102
- status: FormCommitStatus;
103
- scripted: boolean;
104
- effectsResult: FormEffectsResult | null;
105
- uiEffects: FormUiEffect[];
106
- diagnostics: ScriptDiagnostic[];
107
- error?: ScriptExecutionError;
108
- }
109
- /**
110
- * One DOM-free UI request produced by the curated Acrobat scripting surface.
111
- * `phase` says WHO asked: `'boot'` = a document-open script (Adobe's
112
- * version-check boilerplate lives here — embedders typically suppress these
113
- * nags), `'user'` = a script triggered by the user's own interaction (a
114
- * validation alert — show it).
115
- */
116
- type FormUiEffect = ScriptUiEffect & {
117
- phase: 'boot' | 'user';
118
- };
119
- /** Runtime adapter for alerts, print requests, and zero-based page navigation. */
120
- type FormUiEffectProvider = (effect: FormUiEffect) => void;
121
- /** Input for {@link FormCapability.placeField}. */
122
- interface PlaceFieldInput {
123
- family: Exclude<FormFieldFamily, 'pushbutton' | 'signature' | 'unknown'>;
124
- pageObjectNumber: number;
125
- /** Content-space LOGICAL field box (no visual padding semantics). */
126
- box: Box;
127
- /** Widget styling in the engine vocabulary (`WidgetAppearance`). Convert a
128
- * tool's flat CSS defaults with `widgetAppearanceFromProps` from
129
- * `@embedpdf/plugin-annotation`. Omitted → the engine's bare defaults. */
130
- appearance?: WidgetAppearance$1;
131
- }
132
- /** What {@link FormCapability.placeField} created. */
133
- interface PlacedField {
134
- field: FormFieldDTO$1;
135
- /** The widget placed on the requested page (join key to the annotation
136
- * plane for auto-selection), or null when the engine reported none. */
137
- widget: FormFieldDTO$1['widgets'][number] | null;
138
- }
139
- type FormAction = {
140
- type: 'SET_MODEL';
141
- model: Model;
142
- };
143
- /**
144
- * The form plugin's public capability: the FIELD plane. Widgets stay
145
- * annotations (geometry/appearance live there); this surface owns values,
146
- * interchange, and the fill-mode projection.
147
- */
148
- interface FormCapability {
149
- /** The current reconciled form state (null until the first load lands). */
150
- snapshot(): FormSnapshot | null;
151
- /** Re-read the form from the engine (imports/repair/remote bursts). */
152
- refresh(): Promise<void>;
153
- /** Fill controls for one page — content-space, framework-agnostic. */
154
- fillItems(pageObjectNumber: number): FillItem[];
155
- /**
156
- * The fill control for ONE widget, by annotation object number — the join
157
- * the annotation-plane render layer uses (its RenderItem carries the live
158
- * box, so this item's `box` is advisory). Reference-stable per model change.
159
- * Null until the snapshot lands, or for families with no fill control.
160
- */
161
- fillItem(annotObjectNumber: number): FillItem | null;
162
- /** Make sure a page's widget geometry is loaded (idempotent, lazy). */
163
- ensureGeom(pageObjectNumber: number): void;
164
- field(key: FieldKey): FormFieldDTO$1 | null;
165
- fieldForWidget(annotObjectNumber: number): FormFieldDTO$1 | null;
166
- /** Commit a text value (call on blur/Enter — keystrokes stay local). */
167
- setText(key: FieldKey, value: string): Promise<void>;
168
- /** Toggle a checkbox/radio widget by its on-state; null clears the group. */
169
- toggle(key: FieldKey, onState: string | null): Promise<void>;
170
- /** Select choice options by export value. */
171
- choose(key: FieldKey, values: string[]): Promise<void>;
172
- /** Commit one originating-client value transaction, including K/V/C/F scripts when enabled. */
173
- commitValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormCommitResult>;
174
- /** Execute one widget's `/A` activation action (and `/Next`) when scripting is enabled. */
175
- activateWidget(key: FieldKey, annotationRef: AnnotationRef): Promise<FormCommitResult>;
176
- /** Install the framework/application adapter for script-produced UI requests. */
177
- setUiEffectProvider(provider: FormUiEffectProvider | null): void;
178
- /** Restore a field to its /DV default. */
179
- reset(key: FieldKey): Promise<void>;
180
- /** Raw engine passthrough for anything the sugar above doesn't cover. */
181
- setValue(ref: FormFieldRef, value: FormFieldValue): Promise<FormSetValueResult>;
182
- exportData(format?: FormDataFormat): Promise<FormDataExport>;
183
- importData(data: Uint8Array | ArrayBuffer, format?: FormDataFormat): Promise<FormImportResult>;
184
- repair(options?: FormRepairOptions): Promise<FormRepairResult>;
185
- /**
186
- * Create a field of `family` with one styled widget at a content-space box
187
- * — the palette tools' commit, and the programmatic authoring entry (works
188
- * with NO annotation plugin: a pure `doc.forms` call). The box is clamped
189
- * to the page; sizing policy (click default vs drag rect) is the caller's.
190
- * The field gets a deterministic auto-name (`text_1`, …; rename in the
191
- * field panel). Resolves AFTER the annotation plane (when present) has
192
- * re-read the page, so the returned widget is immediately selectable.
193
- */
194
- placeField(input: PlaceFieldInput): Promise<PlacedField>;
195
- /** The page's content box (`{0,0,w,h}`) — page-bound placement math. */
196
- pageBox(pageObjectNumber: number): Box | null;
197
- /** Field-plane properties: name, required, options, default value. */
198
- updateField(key: FieldKey, patch: FormFieldPatch$1): Promise<void>;
199
- /** Delete the field and every widget of it (cascades on the page). */
200
- deleteField(key: FieldKey): Promise<void>;
201
- /** Unlink one widget: it stays as an inert annotation, the field survives. */
202
- detachWidget(key: FieldKey, annotObjectNumber: number): Promise<void>;
203
- /**
204
- * The twins (permissions.md): would the family's verbs succeed now for
205
- * this session? `canRead` — the form model hydrates at all (false = the
206
- * hydration gate left it empty by right); `canFill` — value writes
207
- * (`setText`/`toggle`/`choose`/`reset`; also fused into every
208
- * `FillItem.disabled`); `canDesign` — the field-design family
209
- * (`placeField`/`updateField`/`deleteField`/`detachWidget`).
210
- */
211
- canRead(): boolean;
212
- canFill(): boolean;
213
- canDesign(): boolean;
214
- }
215
- declare const FormToken: import("@embedpdf/core").CapabilityToken<FormCapability>;
216
- //#endregion
1
+ import { _ as fieldKeyOf, a as FormHostCapability, c as FormState, d as PlaceFieldInput, f as PlacedField, g as FieldKey, h as Box, i as FormCommitStatus, m as FillItem, n as FormCapability, o as FormPluginOptions, p as WidgetActivationResult, r as FormCommitResult, s as FormScriptingOptions, t as FormAction, u as FormUiEffect } from "./types-BlXdnNRf.js";
2
+ import { FormFieldDTO, FormFieldPatch, FormToken, WidgetAppearance } from "./contract.js";
3
+ import { FormScriptingController, createFormScriptingController } from "./scripting.js";
4
+ import { createSerialQueue } from "@embedpdf/core";
5
+ import { AnnotationPropsPatch, ClickCreate } from "@embedpdf/plugin-annotation/contract";
6
+ import { FormFieldFamily } from "@embedpdf/engine-core/runtime";
217
7
  //#region src/form.plugin.d.ts
218
8
  /**
219
9
  * The form plugin: the FIELD plane. Document-scoped; requires the
@@ -226,38 +16,11 @@ declare const FormToken: import("@embedpdf/core").CapabilityToken<FormCapability
226
16
  * Design mode = the 'form-edit' / palette tools: no 'form-fill' tag, so
227
17
  * widgets become ordinary editable annotations.
228
18
  */
229
- declare const formPlugin: (options?: FormPluginOptions) => import("@embedpdf/core").PluginDef<FormState, FormAction, FormCapability>;
230
- //#endregion
231
- //#region src/scripting.d.ts
232
- interface FormScriptingControllerOptions {
233
- doc: DocumentHandle;
234
- document(): DocumentMeta | null;
235
- config: FormScriptingOptions;
236
- sandboxFactory: ScriptSandboxFactory;
237
- }
238
- declare class FormScriptingController {
239
- private readonly options;
240
- private sandboxPromise;
241
- private booted;
242
- private disposed;
243
- private sequence;
244
- constructor(options: FormScriptingControllerOptions);
245
- dispose(): void;
246
- commit(snapshot: FormSnapshot, ref: FormFieldRef, proposed: FormFieldValue): Promise<FormCommitResult>;
247
- /** Execute one originating widget's activation action (`/A`, including `/Next`). */
248
- activate(snapshot: FormSnapshot, ref: FormFieldRef, action: PdfActionTree): Promise<FormCommitResult>;
249
- /** Run lazy document boot plus the `/CO` chain without a user field change. */
250
- recalculate(snapshot: FormSnapshot): Promise<FormCommitResult>;
251
- private transact;
252
- private sandbox;
253
- private failed;
254
- private finishRejected;
255
- }
256
- declare function createFormScriptingController(options: FormScriptingControllerOptions): FormScriptingController;
19
+ declare const formPlugin: (options?: FormPluginOptions) => import("@embedpdf/core").PluginDef<FormState, FormAction, FormHostCapability>;
257
20
  //#endregion
258
21
  //#region src/mutationQueue.d.ts
259
- /** Small promise-tail queue: failures never poison later mutations. */
260
- declare function createSerialMutationQueue(): <T>(operation: () => Promise<T>) => Promise<T>;
22
+ /** The core serial queue under its historical form-plugin name. */
23
+ declare const createSerialMutationQueue: typeof createSerialQueue;
261
24
  //#endregion
262
25
  //#region src/tools.d.ts
263
26
  /** The families the palette can author (no pushbutton/signature tools). */
@@ -281,5 +44,5 @@ interface FormToolDef {
281
44
  declare const FORM_TOOLS: readonly FormToolDef[];
282
45
  declare const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef>;
283
46
  //#endregion
284
- export { type AuthorableFormFamily, type Box, FORM_TOOLS, FORM_TOOL_BY_ID, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, FormScriptingController, type FormScriptingOptions, type FormState, FormToken, type FormToolDef, type FormUiEffect, type FormUiEffectProvider, type PlaceFieldInput, type PlacedField, type WidgetAppearance, createFormScriptingController, createSerialMutationQueue, fieldKeyOf, formPlugin };
47
+ export { type AuthorableFormFamily, type Box, FORM_TOOLS, FORM_TOOL_BY_ID, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, FormScriptingController, type FormScriptingOptions, type FormState, FormToken, type FormToolDef, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance, createFormScriptingController, createSerialMutationQueue, fieldKeyOf, formPlugin };
285
48
  //# sourceMappingURL=index.d.ts.map