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

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.
@@ -1,2 +1,2 @@
1
- import { a as FormHostCapability, l as FormToken } from "../types-Blr4QQM5.cjs";
1
+ import { a as FormHostCapability, c as FormToken } from "../types-CnUW7z1W.cjs";
2
2
  export { type FormHostCapability, FormToken };
@@ -1,2 +1,2 @@
1
- import { a as FormHostCapability, l as FormToken } from "../types-BlXdnNRf.js";
1
+ import { a as FormHostCapability, c as FormToken } from "../types-NGRZjJNj.js";
2
2
  export { type FormHostCapability, FormToken };
@@ -1 +1 @@
1
- {"version":3,"file":"contract.cjs","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormScriptingOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\nexport type { FormFieldDTO, FormFieldPatch, WidgetAppearance } from '@embedpdf/engine-core/runtime';\n"],"mappings":";;AAMA,MAAa,0CAAYA,CAAAA,CAAAA"}
1
+ {"version":3,"file":"contract.cjs","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\nexport type { FormFieldDTO, FormFieldPatch, WidgetAppearance } from '@embedpdf/engine-core/runtime';\n"],"mappings":";;AAMA,MAAa,0CAAYA,CAAAA,CAAAA"}
@@ -1,8 +1,8 @@
1
- import { 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";
1
+ import { d as PlacedField, f as WidgetActivationResult, h as FieldKey, i as FormCommitStatus, l as FormUiEffect, m as Box, n as FormCapability, o as FormPluginOptions, p as FillItem, r as FormCommitResult, s as FormState, t as FormAction, u as PlaceFieldInput } from "./types-CnUW7z1W.cjs";
2
2
  import { CapabilityToken } from "@embedpdf/core";
3
3
  import { FormFieldDTO, FormFieldPatch, WidgetAppearance } from "@embedpdf/engine-core/runtime";
4
4
  //#region src/contract.d.ts
5
5
  declare const FormToken: CapabilityToken<FormCapability>;
6
6
  //#endregion
7
- export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, type FormScriptingOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance };
7
+ export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance };
8
8
  //# sourceMappingURL=contract.d.cts.map
@@ -1,8 +1,8 @@
1
- import { 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";
1
+ import { d as PlacedField, f as WidgetActivationResult, h as FieldKey, i as FormCommitStatus, l as FormUiEffect, m as Box, n as FormCapability, o as FormPluginOptions, p as FillItem, r as FormCommitResult, s as FormState, t as FormAction, u as PlaceFieldInput } from "./types-NGRZjJNj.js";
2
2
  import { CapabilityToken } from "@embedpdf/core";
3
3
  import { FormFieldDTO, FormFieldPatch, WidgetAppearance } from "@embedpdf/engine-core/runtime";
4
4
  //#region src/contract.d.ts
5
5
  declare const FormToken: CapabilityToken<FormCapability>;
6
6
  //#endregion
7
- export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, type FormScriptingOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance };
7
+ export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance };
8
8
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormScriptingOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\nexport type { FormFieldDTO, FormFieldPatch, WidgetAppearance } from '@embedpdf/engine-core/runtime';\n"],"mappings":";;AAMA,MAAa,YAAYA"}
1
+ {"version":3,"file":"contract.js","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\nexport type { FormFieldDTO, FormFieldPatch, WidgetAppearance } from '@embedpdf/engine-core/runtime';\n"],"mappings":";;AAMA,MAAa,YAAYA"}
package/dist/index.cjs CHANGED
@@ -355,28 +355,21 @@ function createFormCapability(ctx, options = {}) {
355
355
  };
356
356
  const enqueueMutation = createSerialMutationQueue();
357
357
  const actionsHost = ctx.tryGet(_embedpdf_plugin_actions_contract_host.ActionsToken);
358
- const scriptPort = actionsHost?.scriptTransaction?.bind(actionsHost) ?? null;
359
- const scripting = scriptPort && ctx.doc ? require_scripting.createFormScriptingController({
358
+ const realm = actionsHost?.scriptRealm ?? null;
359
+ const scripting = realm && ctx.doc ? require_scripting.createFormScriptingController({
360
360
  doc: ctx.doc,
361
361
  document: () => ctx.document(),
362
- transaction: scriptPort
362
+ transaction: realm.transaction.bind(realm),
363
+ budget: realm.budget
363
364
  }) : null;
364
365
  if (scripting) ctx.cleanup(() => scripting.dispose());
365
366
  /** Every script surface (UI effects, diagnostics, errors) flows through
366
367
  * the actions plugin's ONE port — origin/phase attached (D9). */
367
368
  const surfaceViaActions = (result, origin) => {
368
- if (!actionsHost) return;
369
- for (const phase of ["boot", "user"]) {
370
- const uiEffects = result.uiEffects.filter((effect) => effect.phase === phase);
371
- if (uiEffects.length === 0 && phase === "boot") continue;
372
- actionsHost.surfaceScriptResult({
373
- uiEffects,
374
- diagnostics: phase === "user" ? result.diagnostics : [],
375
- ...phase === "user" && result.error ? { error: result.error } : {},
376
- origin,
377
- phase
378
- });
379
- }
369
+ actionsHost?.surfaceScriptCommit(result, {
370
+ origin,
371
+ realm: "document"
372
+ });
380
373
  };
381
374
  const can = (cap) => ctx.doc?.security.allows(cap) ?? false;
382
375
  let refreshPromise = null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createSerialQueue","ActionsHostToken","createFormScriptingController","fillItems","coreFillItems","coreFillItemForWidget","PermissionDenied","AnnotationHostToken","coreFieldForWidget","ActionsToken","MIN_DRAG","FormToken","InteractionToken","AnnotationToken","ActionsToken","AnnotationHostToken","ActionsHostToken"],"sources":["../src/field-selection.ts","../src/core/model.ts","../src/core/fill-items.ts","../src/mutationQueue.ts","../src/capability.ts","../src/effects.ts","../src/tools.ts","../src/handler.ts","../src/reducer.ts","../src/form.plugin.ts"],"sourcesContent":["import type {\n FormFieldDTO,\n FormFieldRef,\n FormSubmissionEntry,\n PdfActionTargetRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { ActionDiagnostic, SubmitIntent } from '@embedpdf/plugin-actions/contract';\n\n/**\n * ISO field selection, written ONCE for ResetForm (Tables 241/242) and\n * SubmitForm (Tables 239/240): a NAME target selects the field AND its\n * descendants (FQN dot-prefix — `parent` selects `parent.c1`, the rule the\n * old exact-match resolution violated); an objectNumber target selects that\n * field dictionary. Include mode keeps the selection; exclude mode keeps\n * the complement (a name excludes its subtree the same way it includes\n * it). `targets === null` (the key ABSENT) selects everything and the flag\n * is ignored; `[]` + include selects NOTHING while `[]` + exclude selects\n * everything — presence and emptiness are different states.\n *\n * `listed` reports whether a field was ADDRESSED by the target list\n * (directly or through its subtree) — the \"explicitly listed\" predicate the\n * submit honesty diagnostics key on.\n */\nexport const resolveFieldSelection = <F extends { name: string; ref: FormFieldRef }>(\n all: readonly F[],\n targets: PdfActionTargetRef[] | null,\n exclude: boolean,\n): { selected: F[]; listed: (field: F) => boolean } => {\n if (targets === null) return { selected: [...all], listed: () => false };\n const names = targets.filter((t) => t.kind === 'name').map((t) => t.name);\n const objectNumbers = new Set(\n targets.filter((t) => t.kind === 'objectNumber').map((t) => t.objectNumber),\n );\n const listed = (field: F): boolean =>\n (field.ref.kind === 'objectNumber' && objectNumbers.has(field.ref.fieldObjectNumber)) ||\n names.some((name) => field.name === name || field.name.startsWith(`${name}.`));\n const selected = exclude ? all.filter((f) => !listed(f)) : all.filter(listed);\n return { selected, listed };\n};\n\n/**\n * Build the resolved submission dataset from a live field list (Tables\n * 239/240 semantics; pure — the capability supplies a FRESH engine read so\n * no model-lag class exists):\n *\n * - the unconditional **NoExport veto** — even an explicit include cannot\n * override it (diagnosed when explicitly listed, so the veto is\n * observable, silent when swept in implicitly);\n * - **push-buttons and signatures** never contribute entries in v1 —\n * ISO's explicit-pushbutton-`/AP`-in-FDF rule is unrepresentable in the\n * current DTO, so an EXPLICITLY listed one is diagnosed\n * (`submit-entry-unsupported`), never silently dropped;\n * - an **unsupported `/V` shape** is always diagnosed (silent omission\n * would be data loss);\n * - a valueless field becomes a NAME-ONLY entry (`value: null`) only under\n * IncludeNoValueFields, else it is skipped (the ISO default);\n * - values are entry-faithful: scalar → string, array (multi-select list\n * box) → string[]; the submitted name is the fully qualified name.\n */\nexport const buildSubmitEntries = (\n fields: readonly FormFieldDTO[],\n intent: SubmitIntent,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n): FormSubmissionEntry[] => {\n const { selected, listed } = resolveFieldSelection(fields, intent.fields, intent.exclude);\n const explicitInclude = intent.fields !== null && !intent.exclude;\n const entries: FormSubmissionEntry[] = [];\n for (const field of selected) {\n const explicit = explicitInclude && listed(field);\n if (field.family === 'pushbutton' || field.family === 'signature') {\n if (explicit) {\n diagnose({\n code: 'submit-entry-unsupported',\n message: `submit: '${field.name}' (${field.family}) has no representable submission value in v1 — skipped`,\n });\n }\n continue;\n }\n if (field.flags.noExport) {\n if (explicit) {\n diagnose({\n code: 'submit-entry-unsupported',\n message: `submit: '${field.name}' carries the NoExport flag — the veto is unconditional (ISO 12.7.6.2), skipped`,\n });\n }\n continue;\n }\n const entry = field.valueEntry;\n if (entry.kind === 'scalar') {\n entries.push({ name: field.name, value: entry.value });\n } else if (entry.kind === 'array') {\n entries.push({ name: field.name, value: entry.values });\n } else if (entry.kind === 'none') {\n if (intent.includeNoValueFields) entries.push({ name: field.name, value: null });\n } else {\n diagnose({\n code: 'submit-entry-unsupported',\n message: `submit: '${field.name}' has an unsupported /V shape — skipped (would otherwise be silent data loss)`,\n });\n }\n }\n return entries;\n};\n","/**\n * The pure heart of the form plugin — no DOM, no engine, no kernel imports.\n * Same discipline as `annotation-core`, folded in as a directory because the\n * model is small and has no consumer besides this plugin.\n *\n * The model mirrors ENGINE truth plus transient write status. Keystroke\n * drafts deliberately live in the framework controls (a focused `<input>` is\n * already the draft store); the model only learns about a value when it is\n * committed. That keeps typing synchronous and the model identical across\n * frameworks.\n */\nimport type { FormFieldDTO, FormSnapshot } from '@embedpdf/engine-core/runtime';\n\n/** A content-space box (top-left origin, y-down, PDF points). */\nexport interface Box {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Stable client key for a field: object number when durable, else FQN. */\nexport type FieldKey = string;\n\nexport const fieldKeyOf = (field: { fieldObjectNumber: number; name: string }): FieldKey =>\n field.fieldObjectNumber > 0 ? `obj:${field.fieldObjectNumber}` : `fqn:${field.name}`;\n\nexport interface Model {\n /** Engine truth; replaced wholesale on refresh, patched on write-backs. */\n snapshot: FormSnapshot | null;\n /** fieldKey → index into snapshot.fields. */\n byKey: Record<FieldKey, number>;\n /** annotObjectNumber → index into snapshot.fields (widget → field join). */\n byWidget: Record<number, number>;\n /** Fields with an in-flight engine write (disables their controls). */\n writing: Record<FieldKey, true>;\n /**\n * Widget geometry per page: annotObjectNumber → content-space box. Fed by\n * the shell from the WIDGET plane (one annotations read per page); value\n * writes never move widgets, so this survives snapshot refreshes and is\n * only cleared on structural form events.\n */\n geom: Record<number, Record<number, Box> | undefined>;\n /** Bumped on every change — cheap equality for memoized projections. */\n seq: number;\n}\n\nexport const initialModel = (): Model => ({\n snapshot: null,\n byKey: {},\n byWidget: {},\n writing: {},\n geom: {},\n seq: 0,\n});\n\nexport type Msg =\n | { t: 'snapshot'; snapshot: FormSnapshot }\n | { t: 'writeStart'; key: FieldKey }\n | { t: 'writeDone'; key: FieldKey; field: FormFieldDTO }\n | { t: 'writeFailed'; key: FieldKey }\n | { t: 'pageGeom'; pageObjectNumber: number; boxes: Record<number, Box> }\n | { t: 'clearGeom'; pageObjectNumber?: number };\n\nfunction index(snapshot: FormSnapshot): Pick<Model, 'byKey' | 'byWidget'> {\n const byKey: Record<FieldKey, number> = {};\n const byWidget: Record<number, number> = {};\n snapshot.fields.forEach((field, i) => {\n byKey[fieldKeyOf(field)] = i;\n for (const w of field.widgets) {\n if (w.annotObjectNumber > 0) byWidget[w.annotObjectNumber] = i;\n }\n });\n return { byKey, byWidget };\n}\n\nexport function update(model: Model, msg: Msg): Model {\n switch (msg.t) {\n case 'snapshot':\n return {\n ...model,\n snapshot: msg.snapshot,\n ...index(msg.snapshot),\n writing: {},\n seq: model.seq + 1,\n };\n case 'writeStart':\n return { ...model, writing: { ...model.writing, [msg.key]: true }, seq: model.seq + 1 };\n case 'writeDone': {\n if (!model.snapshot) return model;\n const i = model.byKey[msg.key];\n if (i === undefined) return model;\n const fields = model.snapshot.fields.slice();\n fields[i] = msg.field;\n const { [msg.key]: _done, ...writing } = model.writing;\n const snapshot = { ...model.snapshot, fields };\n return { ...model, snapshot, ...index(snapshot), writing, seq: model.seq + 1 };\n }\n case 'writeFailed': {\n const { [msg.key]: _failed, ...writing } = model.writing;\n return { ...model, writing, seq: model.seq + 1 };\n }\n case 'pageGeom':\n return {\n ...model,\n geom: { ...model.geom, [msg.pageObjectNumber]: msg.boxes },\n seq: model.seq + 1,\n };\n case 'clearGeom': {\n if (msg.pageObjectNumber === undefined) {\n return { ...model, geom: {}, seq: model.seq + 1 };\n }\n const geom = { ...model.geom };\n delete geom[msg.pageObjectNumber];\n return { ...model, geom, seq: model.seq + 1 };\n }\n }\n}\n\nexport const fieldByKey = (model: Model, key: FieldKey): FormFieldDTO | null => {\n const i = model.byKey[key];\n return i === undefined ? null : (model.snapshot?.fields[i] ?? null);\n};\n\nexport const fieldForWidget = (model: Model, annotObjectNumber: number): FormFieldDTO | null => {\n const i = model.byWidget[annotObjectNumber];\n return i === undefined ? null : (model.snapshot?.fields[i] ?? null);\n};\n","/**\n * The fill-mode projection: what a framework paints for one page. Pure data\n * in CONTENT space (top-left origin, y-down PDF points) — the same space\n * annotation RenderItems use, so layers position with the page transform\n * and never re-derive scale.\n *\n * Geometry comes from the WIDGET plane: the shell reads each page's\n * annotations once (widgets are annotations; their DTOs carry /Rect) and\n * feeds content-space boxes into the model via `pageGeom`. The field plane\n * (this snapshot) contributes identity, value, and behavior.\n */\nimport type { FormFieldDTO, FormFieldOption, FormSnapshot } from '@embedpdf/engine-core/runtime';\n\nimport { fieldForWidget, fieldKeyOf, type Box, type FieldKey, type Model } from './model';\n\nexport type { Box } from './model';\n\ninterface FillItemBase {\n key: FieldKey;\n /** Widget identity — joins to the annotation plane. */\n annotObjectNumber: number;\n box: Box;\n /** Read-only field or write in flight: render, don't accept input. */\n disabled: boolean;\n /** Accessible name: /TU when present, else the fully qualified name. */\n label: string;\n}\n\nexport type FillItem = FillItemBase &\n (\n | {\n control: 'text';\n value: string;\n multiline: boolean;\n password: boolean;\n maxLength: number | null;\n comb: boolean;\n }\n | { control: 'toggle'; kind: 'checkbox' | 'radio'; checked: boolean; onState: string }\n | {\n control: 'choice';\n kind: 'combo' | 'list';\n edit: boolean;\n multi: boolean;\n options: FormFieldOption[];\n selected: string[];\n }\n | { control: 'button' }\n );\n\nconst ZERO_BOX: Box = { x: 0, y: 0, width: 0, height: 0 };\n\n/**\n * Project ONE widget of a field into a fill control. `box` is supplied by the\n * caller: the page projection reads the model's widget geometry; a consumer\n * that already owns a live box (the annotation plane's RenderItem) passes it —\n * or nothing, when only the semantics matter. Null for families with no fill\n * control (signature/unknown: rendered by the annotation plane only).\n */\nexport function projectWidget(\n model: Model,\n field: FormFieldDTO,\n annotObjectNumber: number,\n box: Box = ZERO_BOX,\n): FillItem | null {\n const key = fieldKeyOf(field);\n const base: FillItemBase = {\n key,\n annotObjectNumber,\n box,\n disabled: field.flags.readOnly || model.writing[key] === true,\n label: field.alternateName ?? field.name,\n };\n switch (field.family) {\n case 'text':\n return {\n ...base,\n control: 'text',\n value: field.value,\n multiline: field.multiline,\n password: field.password,\n maxLength: field.maxLength,\n comb: field.comb,\n };\n case 'checkbox': {\n const toggle = field.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n return {\n ...base,\n control: 'toggle',\n kind: 'checkbox',\n checked: field.checked,\n onState: toggle && 'onState' in toggle ? toggle.onState : 'Yes',\n };\n }\n case 'radio': {\n const toggle = field.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n return {\n ...base,\n control: 'toggle',\n kind: 'radio',\n checked: toggle && 'checked' in toggle ? toggle.checked : false,\n onState: toggle && 'onState' in toggle ? toggle.onState : '',\n };\n }\n case 'combobox':\n return {\n ...base,\n control: 'choice',\n kind: 'combo',\n edit: field.edit,\n multi: false,\n options: field.options,\n selected: field.value === '' ? [] : [field.value],\n };\n case 'listbox':\n return {\n ...base,\n control: 'choice',\n kind: 'list',\n edit: false,\n multi: field.multiSelect,\n options: field.options,\n selected: field.selectedValues,\n };\n case 'pushbutton':\n return { ...base, control: 'button' };\n default:\n return null;\n }\n}\n\n/**\n * Project one page's widgets into fill controls. Widgets whose geometry has\n * not arrived yet (or that are direct objects with no join key) are skipped —\n * the shell re-runs the projection when `pageGeom` lands.\n */\nexport function fillItems(model: Model, pageObjectNumber: number): FillItem[] {\n const snapshot: FormSnapshot | null = model.snapshot;\n const geom = model.geom[pageObjectNumber];\n if (!snapshot || !geom) return [];\n const items: FillItem[] = [];\n\n for (const field of snapshot.fields) {\n for (const widget of field.widgets) {\n if (widget.pageObjectNumber !== pageObjectNumber) continue;\n const box = geom[widget.annotObjectNumber];\n if (!box) continue;\n const item = projectWidget(model, field, widget.annotObjectNumber, box);\n if (item) items.push(item);\n }\n }\n return items;\n}\n\n/**\n * Project a SINGLE widget by its annotation object number — the join the\n * annotation-plane render layer uses (it owns a live box already, so the\n * model's cached geometry is used only when it happens to be loaded; the\n * item's semantics never depend on it). Null while the snapshot hasn't\n * landed, or for families with no fill control.\n */\nexport function fillItemForWidget(model: Model, annotObjectNumber: number): FillItem | null {\n const field = fieldForWidget(model, annotObjectNumber);\n if (!field) return null;\n const widget = field.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n if (!widget) return null;\n const box = model.geom[widget.pageObjectNumber]?.[annotObjectNumber];\n return projectWidget(model, field, annotObjectNumber, box);\n}\n","import { createSerialQueue } from '@embedpdf/core';\n\n/** The core serial queue under its historical form-plugin name. */\nexport const createSerialMutationQueue = createSerialQueue;\n","import {\n PermissionDenied,\n type AnnotationRef,\n type FormDataFormat,\n type FormFieldDraft,\n type FormFieldPatch,\n type FormFieldRef,\n type FormFieldValue,\n type FormSnapshot,\n type PdfActionTargetRef,\n type PdfActionTree,\n type PdfRect,\n} from '@embedpdf/engine-core/runtime';\nimport { DocumentsToken, type PluginContext } from '@embedpdf/core';\nimport { ActionsToken, createHoverPump } from '@embedpdf/plugin-actions/contract';\nimport { ActionsToken as ActionsHostToken } from '@embedpdf/plugin-actions/contract/host';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSource,\n ActionSubmitRequest,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\n\nimport { buildSubmitEntries, resolveFieldSelection } from './field-selection';\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/contract/host';\n\nimport {\n fillItemForWidget as coreFillItemForWidget,\n fillItems as coreFillItems,\n type FillItem,\n} from './core/fill-items';\nimport {\n fieldByKey,\n fieldForWidget as coreFieldForWidget,\n update,\n type Box,\n type FieldKey,\n type Model,\n type Msg,\n} from './core/model';\nimport { createSerialMutationQueue } from './mutationQueue';\nimport { createFormScriptingController } from './scripting';\nimport type { FormEffectsResult } from '@embedpdf/engine-core/runtime';\nimport type {\n FormAction,\n FormCommitResult,\n FormHostCapability,\n FormPluginOptions,\n FormState,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\n\n/** PDF user-space rect (y-up) → content-space box (y-down, crop-relative). */\nconst toBox = (rect: PdfRect, crop: PdfRect): Box => ({\n x: rect.left - crop.left,\n y: crop.top - rect.top,\n width: rect.right - rect.left,\n height: rect.top - rect.bottom,\n});\n\nconst sameAnnotationRef = (left: AnnotationRef, right: AnnotationRef): boolean => {\n if (left.kind !== right.kind || left.pageObjectNumber !== right.pageObjectNumber) return false;\n if (left.kind === 'objectNumber' && right.kind === 'objectNumber') {\n return left.annotObjectNumber === right.annotObjectNumber;\n }\n if (left.kind === 'nm' && right.kind === 'nm') return left.nm === right.nm;\n return (\n left.kind === 'index' &&\n right.kind === 'index' &&\n left.index === right.index &&\n left.revision === right.revision\n );\n};\n\n/**\n * The form shell. Pure `update` runs here; the resulting model is dispatched\n * to the store; engine calls happen around it. Every read the frameworks do\n * goes through memoized projections keyed on `model.seq`.\n */\nexport function createFormCapability(\n ctx: PluginContext<FormState, FormAction>,\n options: FormPluginOptions = {},\n): FormHostCapability {\n const model = (): Model => ctx.getState().model;\n const apply = (msg: Msg): void => {\n ctx.dispatch({ type: 'SET_MODEL', model: update(model(), msg) });\n };\n\n const refKeyOf = (key: FieldKey): FormFieldRef => {\n if (key.startsWith('obj:')) {\n return { kind: 'objectNumber', fieldObjectNumber: Number(key.slice(4)) };\n }\n return { kind: 'fqn', name: key.slice(4) };\n };\n const enqueueMutation = createSerialMutationQueue();\n\n // Scripting rides the actions plugin's per-document realm: the transaction\n // port's PRESENCE is the \"JavaScript is on\" signal (D8 — the switch lives\n // on actionsPlugin({ javascript }); form owns only the K/V/C/F pipeline).\n const actionsHost = ctx.tryGet(ActionsHostToken);\n const scriptPort = actionsHost?.scriptTransaction?.bind(actionsHost) ?? null;\n const scripting =\n scriptPort && ctx.doc\n ? createFormScriptingController({\n doc: ctx.doc,\n document: () => ctx.document(),\n transaction: scriptPort,\n })\n : null;\n if (scripting) ctx.cleanup(() => scripting.dispose());\n\n /** Every script surface (UI effects, diagnostics, errors) flows through\n * the actions plugin's ONE port — origin/phase attached (D9). */\n const surfaceViaActions = (result: FormCommitResult, origin: ActionOrigin): void => {\n if (!actionsHost) return;\n const phases: Array<'boot' | 'user'> = ['boot', 'user'];\n for (const phase of phases) {\n const uiEffects = result.uiEffects.filter((effect) => effect.phase === phase);\n if (uiEffects.length === 0 && phase === 'boot') continue;\n actionsHost.surfaceScriptResult({\n uiEffects,\n diagnostics: phase === 'user' ? result.diagnostics : [],\n ...(phase === 'user' && result.error ? { error: result.error } : {}),\n origin,\n phase,\n });\n }\n };\n\n // Authority reads for the twins, the hydration gate, the fused fill\n // projection, and the write gate — one wildcard-aware helper.\n const can = (cap: 'doc.forms.read' | 'doc.forms.fill' | 'doc.forms.modify'): boolean =>\n ctx.doc?.security.allows(cap) ?? false;\n\n // ── snapshot loading ────────────────────────────────────────────────────\n let refreshPromise: Promise<void> | null = null;\n const refresh = async (force = false): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n // No read authority → don't fire a doomed list (a reviewer-shaped token\n // without `doc.forms.read` is the COMMON narrowed scope); the model stays\n // empty and `canRead()` tells chrome why. The engine enforces regardless.\n if (!can('doc.forms.read')) return;\n if (refreshPromise) {\n await refreshPromise;\n if (!force) return;\n }\n refreshPromise = doc.forms\n .list()\n .then((snapshot) => apply({ t: 'snapshot', snapshot }))\n .catch((err) => {\n // A race with an access change 403s here; anything else is a real\n // load failure. Either way: surfaced, never an unhandled rejection.\n console.warn('[form] form snapshot failed to load', err);\n })\n .finally(() => {\n refreshPromise = null;\n });\n return refreshPromise;\n };\n\n // ── widget geometry (from the WIDGET plane: one annotations read/page) ──\n const geomLoading = new Set<number>();\n const ensureGeom = (pon: number): void => {\n const doc = ctx.doc;\n if (!doc || geomLoading.has(pon) || model().geom[pon]) return;\n const crop = ctx.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n if (!crop) return;\n geomLoading.add(pon);\n void doc\n .page(pon)\n .annotations.list()\n .then(({ annotations }) => {\n const boxes: Record<number, Box> = {};\n for (const dto of annotations) {\n if (dto.subtype !== 'widget') continue;\n const objectNumber = dto.ref.kind === 'objectNumber' ? dto.ref.annotObjectNumber : 0;\n if (objectNumber > 0) boxes[objectNumber] = toBox(dto.rect, crop);\n }\n apply({ t: 'pageGeom', pageObjectNumber: pon, boxes });\n })\n .finally(() => {\n geomLoading.delete(pon);\n });\n };\n\n // ── memoized fill projection ────────────────────────────────────────────\n // Session fill authority FUSES into the same `disabled` the field's\n // ReadOnly flag feeds (permissions.md: authority rides the flags gate) —\n // without `doc.forms.fill` every widget renders inert, so the pixels are\n // truthful and no gesture reaches a doomed write.\n const fuseFill = (item: FillItem | null, fillable: boolean): FillItem | null =>\n item === null || fillable || item.disabled ? item : { ...item, disabled: true };\n\n const fillCache = new Map<number, { seq: number; fillable: boolean; items: FillItem[] }>();\n const fillItems = (pon: number): FillItem[] => {\n const m = model();\n const fillable = can('doc.forms.fill');\n const hit = fillCache.get(pon);\n if (hit && hit.seq === m.seq && hit.fillable === fillable) return hit.items;\n const items = coreFillItems(m, pon).map((item) => fuseFill(item, fillable) as FillItem);\n fillCache.set(pon, { seq: m.seq, fillable, items });\n return items;\n };\n\n // Single-widget projection — reference-stable per model.seq so framework\n // selectors can use plain identity equality.\n const fillItemCache = new Map<\n number,\n { seq: number; fillable: boolean; item: FillItem | null }\n >();\n const fillItem = (annotObjectNumber: number): FillItem | null => {\n const m = model();\n const fillable = can('doc.forms.fill');\n const hit = fillItemCache.get(annotObjectNumber);\n if (hit && hit.seq === m.seq && hit.fillable === fillable) return hit.item;\n const item = fuseFill(coreFillItemForWidget(m, annotObjectNumber), fillable);\n fillItemCache.set(annotObjectNumber, { seq: m.seq, fillable, item });\n return item;\n };\n\n // ── typed writes: writeStart → engine → writeDone/writeFailed ──────────\n const commitValueNow = async (\n ref: FormFieldRef,\n value: FormFieldValue,\n ): Promise<FormCommitResult> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n if (scripting) {\n const result = await scripting.commit(ref, value);\n surfaceViaActions(result, 'user');\n // A native partial/failed effects result can still have mutated state.\n if (result.effectsResult !== null) await refresh(true);\n return result;\n }\n\n const result = await doc.forms.setValue(ref, value);\n await refresh(true);\n return {\n status: result.changedWidgets.length > 0 ? 'applied' : 'unchanged',\n scripted: false,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n };\n\n const write = (key: FieldKey, value: FormFieldValue): Promise<void> => {\n // The optimistic gate: no fill authority → refuse BEFORE the spinner and\n // the queued engine call, with the refusal shape the engine would send.\n // (The fused projection renders such widgets inert; this covers the\n // imperative door.)\n if (!can('doc.forms.fill'))\n return Promise.reject(new PermissionDenied('doc.forms.fill', 'form.fill'));\n return enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) return;\n apply({ t: 'writeStart', key });\n try {\n const result = await commitValueNow(refKeyOf(key), value);\n if (result.status === 'rejected' || result.status === 'failed') {\n apply({ t: 'writeFailed', key });\n } else if (result.effectsResult === null && result.scripted) {\n // A scripted no-op has no engine read-back to clear the spinner.\n apply({ t: 'writeFailed', key });\n }\n } catch (err) {\n apply({ t: 'writeFailed', key });\n throw err;\n }\n });\n };\n\n // ── design mode ──────────────────────────────────────────────────────────\n // The annotation plane must re-read pages whose widget population changed\n // underneath it (created/deleted widgets); optional — fill-only setups\n // simply have no annotation plugin to nudge.\n const annotationHost = ctx.tryGet(AnnotationHostToken);\n\n const annotationActivation = async (ref: AnnotationRef) => {\n const doc = ctx.doc;\n if (!doc) return null;\n const loaded = annotationHost?.get(ref);\n if (loaded?.subtype === 'widget') return loaded.actions?.activate ?? null;\n const { annotations } = await doc.page(ref.pageObjectNumber).annotations.list();\n const annotation = annotations.find((candidate) => sameAnnotationRef(candidate.ref, ref));\n return annotation?.subtype === 'widget' ? (annotation.actions?.activate ?? null) : null;\n };\n\n const activateWidgetNow = async (\n key: FieldKey,\n annotationRef: AnnotationRef,\n ): Promise<FormCommitResult> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n if (!scripting) {\n return {\n status: 'unchanged',\n scripted: false,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n }\n const action = await annotationActivation(annotationRef);\n if (!action) {\n return {\n status: 'unchanged',\n scripted: true,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n }\n const result = await scripting.activate(refKeyOf(key), action);\n surfaceViaActions(result, 'user');\n if (result.effectsResult !== null) await refresh(true);\n return result;\n };\n\n // ── action-executor doors (host lens) ───────────────────────────────────\n // Both ride enqueueMutation: an actions-driven form mutation must never\n // interleave with a user's in-flight commit. The direction is always\n // actions queue → form queue — the delegated activateWidget below never\n // enters the form queue, so these can (no self-deadlock).\n\n const NOT_SCRIPTED: FormCommitResult = {\n status: 'unchanged',\n scripted: false,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n\n /**\n * The shared reset core: one effects batch → refresh → V/C/F\n * recalculation when the transaction port is present. Ridden by BOTH\n * doors — the /ResetForm executor and the public `reset(key)` — so the\n * two can never diverge again (the \"reset() asymmetry\" fix). `origin` is\n * PRESERVED through recalculation surfacing: a lifecycle/hover ResetForm\n * can no longer launder its alerts into user origin.\n */\n const applyResetBatch = async (\n refs: FormFieldRef[],\n origin: ActionOrigin,\n ): Promise<FormCommitResult> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n if (!doc.forms.applyEffects) {\n const result: FormCommitResult = {\n ...NOT_SCRIPTED,\n diagnostics: [\n { code: 'unsupported-api', message: 'this engine has no form-effects batch door' },\n ],\n };\n surfaceViaActions(result, origin);\n return result;\n }\n // Zero refs must NEVER reach the engine (the applier throws InvalidArg\n // on an empty reset) — `[] + include` is a valid action that resets\n // nothing. `effectsResult: null` tells the executor this was inert.\n if (refs.length === 0) return NOT_SCRIPTED;\n const effectsResult = await doc.forms.applyEffects([{ kind: 'reset', refs }]);\n // The batch is non-rollback-atomic and resolves with per-effect\n // statuses instead of throwing — reflect a rejected/failed reset\n // honestly (the executor maps 'failed' to a failed chain node).\n const resetFailed = effectsResult.results.some(\n (entry) => entry.status === 'failed' || entry.status === 'rejected',\n );\n await refresh(true);\n if (resetFailed) {\n return {\n status: 'failed',\n scripted: false,\n effectsResult,\n uiEffects: [],\n diagnostics: [],\n };\n }\n // Acrobat recalculates after a reset; boot rides along lazily.\n let recalc: FormCommitResult | null = null;\n if (scripting) {\n recalc = await scripting.recalculate();\n surfaceViaActions(recalc, origin);\n if (recalc.effectsResult !== null) await refresh(true);\n }\n return {\n status: 'applied',\n scripted: recalc !== null,\n effectsResult,\n uiEffects: recalc?.uiEffects ?? [],\n diagnostics: recalc?.diagnostics ?? [],\n ...(recalc?.error ? { error: recalc.error } : {}),\n };\n };\n\n const resetFormAction = (\n targets: PdfActionTargetRef[] | null,\n exclude: boolean,\n origin: ActionOrigin = 'user',\n ): Promise<FormCommitResult> =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const snapshot = await doc.forms.list();\n // The shared ISO selection (Tables 241/242): a parent NAME resets its\n // descendants too — the exact-match resolution this replaces was a\n // conformance bug.\n const { selected } = resolveFieldSelection(snapshot.fields, targets, exclude);\n // ResetForm SKIPS fields with nothing to restore — the engine's batch\n // applier refuses pushbutton/signature refs outright (validateEffect),\n // and an exclude-mode complement always sweeps in the form's buttons.\n const resettable = selected.filter(\n (f) => f.family !== 'pushbutton' && f.family !== 'signature',\n );\n return applyResetBatch(\n resettable.map((f) => f.ref),\n origin,\n );\n });\n\n /**\n * The submit dataset resolver (Phase 4, D7): a FRESH engine read — never\n * the cached model, so no staleness class exists — then the pure ISO\n * builder. Selection/veto/value semantics live in `field-selection.ts`;\n * this door only supplies the live fields and assembles the request.\n */\n const resolveSubmitDataset = async (\n intent: SubmitIntent,\n actionCtx: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n ): Promise<ActionSubmitRequest> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const snapshot = await doc.forms.list();\n return {\n url: intent.url,\n method: intent.method,\n format: intent.format,\n flagsRaw: intent.flagsRaw,\n ...(intent.charSet === undefined ? {} : { charSet: intent.charSet }),\n entries: buildSubmitEntries(snapshot.fields, intent, diagnose),\n origin: actionCtx.origin,\n event: actionCtx.event,\n };\n };\n\n // ── widget DOM-event feed helpers ───────────────────────────────────────\n const widgetSource = (key: FieldKey, annotationRef: AnnotationRef): ActionSource => ({\n kind: 'widget',\n field: refKeyOf(key),\n annotation: annotationRef,\n pon: annotationRef.pageObjectNumber,\n });\n\n /** One shared hover pump (Exit→Enter as one ordered pair; intermediates\n * skipped), created on first use against the resolved actions capability. */\n let widgetPump: ReturnType<typeof createHoverPump> | null = null;\n const widgetHoverPump = (actions: {\n dispatch: Parameters<typeof createHoverPump>[0];\n }): ReturnType<typeof createHoverPump> => {\n widgetPump ??= createHoverPump(actions.dispatch);\n return widgetPump;\n };\n\n const widgetHoverFlags = (\n annotationRef: AnnotationRef,\n ): { enter: boolean; exit: boolean } | null => {\n const loaded = annotationHost?.get(annotationRef);\n if (loaded?.subtype !== 'widget') return null;\n return {\n enter: Boolean(loaded.actions?.cursorEnter?.root),\n exit: Boolean(loaded.actions?.cursorExit?.root),\n };\n };\n\n const nudgeAnnotations = (pons: Iterable<number>): void => {\n if (!annotationHost) return;\n for (const pon of new Set(pons)) void annotationHost.reloadPage(pon);\n };\n\n /** Content-space box → PDF rect (inverse of `toBox`). */\n const toPdfRect = (\n box: { x: number; y: number; width: number; height: number },\n crop: PdfRect,\n ): PdfRect => ({\n left: box.x + crop.left,\n top: crop.top - box.y,\n right: box.x + crop.left + box.width,\n bottom: crop.top - box.y - box.height,\n });\n\n /** The page's content box (`{0,0,w,h}`), for page-bound placement math. */\n const pageBox = (pon: number): Box | null => {\n const crop = ctx.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n return crop\n ? { x: 0, y: 0, width: crop.right - crop.left, height: crop.top - crop.bottom }\n : null;\n };\n\n /** Deterministic, collision-free auto-name: `text_1`, `text_2`, … counted\n * against the CURRENT snapshot (rename in the field panel). */\n const autoName = (family: string): string => {\n const names = new Set((model().snapshot?.fields ?? []).map((f) => f.name));\n let n = 1;\n while (names.has(`${family}_${n}`)) n++;\n return `${family}_${n}`;\n };\n\n const placeFieldNow = async (input: PlaceFieldInput): Promise<PlacedField> => {\n const doc = ctx.doc;\n const pon = input.pageObjectNumber;\n const crop = ctx.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n if (!doc || !crop) throw new Error('[form] placeField: document/page not ready');\n // Placement is page-bound: intersect a (possibly overshooting) drag box\n // with the page. Sizing policy is the CALLER's job (the place handler's\n // click policy / drag rect) — a degenerate result is a caller bug.\n const page = pageBox(pon)!;\n const x = Math.max(page.x, Math.min(input.box.x, page.width));\n const y = Math.max(page.y, Math.min(input.box.y, page.height));\n const box: Box = {\n x,\n y,\n width: Math.max(0, Math.min(input.box.x + input.box.width, page.width) - x),\n height: Math.max(0, Math.min(input.box.y + input.box.height, page.height) - y),\n };\n if (box.width < 1 || box.height < 1) {\n throw new Error('[form] placeField: degenerate box (size the box before placing)');\n }\n const { family, appearance } = input;\n const name = autoName(family);\n const placement = {\n pageObjectNumber: pon,\n rect: toPdfRect(box, crop),\n ...(appearance ? { appearance } : {}),\n };\n const draft: FormFieldDraft =\n family === 'radio'\n ? { family, name, widgets: [{ ...placement, onState: 'option1' }] }\n : family === 'combobox' || family === 'listbox'\n ? {\n family,\n name,\n widget: placement,\n options: [\n { label: 'Option 1', value: 'Option 1' },\n { label: 'Option 2', value: 'Option 2' },\n ],\n }\n : { family, name, widget: placement };\n const result = await doc.forms.createField(draft);\n await refresh(true);\n apply({ t: 'clearGeom', pageObjectNumber: pon });\n // AWAIT the annotation-plane reload so the returned widget ref is already\n // selectable — the caller's auto-select needs the model to know it.\n if (annotationHost) await annotationHost.reloadPage(pon);\n const widget = result.field.widgets.find((w) => w.pageObjectNumber === pon) ?? null;\n return { field: result.field, widget };\n };\n\n const updateFieldNow = async (key: FieldKey, patch: FormFieldPatch): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n await doc.forms.updateField(refKeyOf(key), patch);\n await refresh(true);\n };\n\n const deleteFieldNow = async (key: FieldKey): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n const field = fieldByKey(model(), key);\n const pons = field?.widgets.map((w) => w.pageObjectNumber).filter((p) => p > 0) ?? [];\n await doc.forms.deleteField(refKeyOf(key));\n await refresh(true);\n for (const pon of new Set(pons)) apply({ t: 'clearGeom', pageObjectNumber: pon });\n nudgeAnnotations(pons);\n };\n\n const detachWidgetNow = async (key: FieldKey, annotObjectNumber: number): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n const field = fieldByKey(model(), key);\n const widget = field?.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n await doc.forms.detachWidget(refKeyOf(key), {\n annotObjectNumber,\n pageObjectNumber: widget?.pageObjectNumber ?? 0,\n });\n await refresh(true);\n if (widget && widget.pageObjectNumber > 0) {\n apply({ t: 'clearGeom', pageObjectNumber: widget.pageObjectNumber });\n nudgeAnnotations([widget.pageObjectNumber]);\n }\n };\n\n void refresh();\n\n return {\n snapshot: () => model().snapshot,\n refresh,\n fillItems,\n fillItem,\n ensureGeom,\n field: (key) => fieldByKey(model(), key),\n fieldForWidget: (annotObjectNumber) => coreFieldForWidget(model(), annotObjectNumber),\n setText: (key, value) => write(key, { type: 'text', value }),\n toggle: (key, onState) => write(key, { type: 'toggle', state: onState }),\n choose: (key, values) => write(key, { type: 'choice', values }),\n reset: (key) => {\n // Reset writes a value (the default) — same optimistic gate as write().\n if (!can('doc.forms.fill'))\n return Promise.reject(new PermissionDenied('doc.forms.fill', 'form.reset'));\n return enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) return;\n apply({ t: 'writeStart', key });\n try {\n if (doc.forms.applyEffects) {\n // The reset() SYMMETRY fix: this door now rides the SAME core a\n // /ResetForm action does — one reset effect, then V/C/F\n // recalculation — so a dependent /C total can never go stale\n // through the public API while staying fresh through the action.\n const result = await applyResetBatch([refKeyOf(key)], 'user');\n if (result.status === 'failed') {\n throw new Error(\n result.effectsResult?.results.find(\n (entry) => entry.status === 'failed' || entry.status === 'rejected',\n )?.error?.message ?? 'reset failed',\n );\n }\n const field = fieldByKey(model(), key);\n if (field) apply({ t: 'writeDone', key, field });\n else apply({ t: 'writeFailed', key });\n } else {\n // Batch-less engines keep the direct single-field door.\n const result = await doc.forms.reset(refKeyOf(key));\n apply({ t: 'writeDone', key, field: result.field });\n }\n } catch (err) {\n apply({ t: 'writeFailed', key });\n throw err;\n }\n });\n },\n commitValue: (ref, value) => enqueueMutation(() => commitValueNow(ref, value)),\n activateWidget: async (key, annotationRef): Promise<WidgetActivationResult> => {\n // Delegated path: the ACTIONS queue is the serializer — entering the\n // form queue here would deadlock the executors it calls back into\n // (queue-direction law: actions → form, never form → actions → form).\n // No scripting gate on purpose: Hide/ResetForm buttons must work with\n // JS off — per-type policy lives in the dispatcher now. Submission is\n // SYNCHRONOUS (no pre-resolution await): a mouseUp notified just\n // before this takes the earlier queue slot, always.\n const actions = ctx.tryGet(ActionsToken);\n if (actions) {\n const result = await actions.dispatch({\n scope: 'activate',\n ref: annotationRef,\n pon: annotationRef.pageObjectNumber,\n source: widgetSource(key, annotationRef),\n });\n // inert + zero steps + zero diagnostics = no /A tree at all — only\n // then does the legacy form path apply (byte-for-byte no-actions\n // behavior); anything else IS the dispatch outcome, refusals included.\n const noTree =\n result.status === 'inert' &&\n result.steps.length === 0 &&\n result.diagnostics.length === 0;\n if (!noTree) return { kind: 'dispatched', result };\n }\n return {\n kind: 'form',\n result: await enqueueMutation(() => activateWidgetNow(key, annotationRef)),\n };\n },\n notifyWidgetEvent: (key, annotationRef, event) => {\n const actions = ctx.tryGet(ActionsToken);\n if (!actions) return;\n const source = widgetSource(key, annotationRef);\n if (event === 'cursorEnter' || event === 'cursorExit') {\n if (event === 'cursorExit') {\n widgetHoverPump(actions).hover(null);\n return;\n }\n // Tree-presence pre-check through the folded annotation model when\n // available — tree-less hover costs zero dispatches. Without the\n // annotation plugin the flags stay unknown and the dispatcher\n // resolves authoritatively in-queue.\n const flags = widgetHoverFlags(annotationRef);\n if (flags && !flags.enter && !flags.exit) return;\n widgetHoverPump(actions).hover({\n ref: annotationRef,\n pon: annotationRef.pageObjectNumber,\n source,\n ...(flags ? { events: flags } : {}),\n });\n return;\n }\n // D/U/Fo/Bl: direct fire-and-forget — dispatch never rejects, the\n // queue orders, results surface via the actions events. /A-shadowing\n // of U (ISO Table 197) is enforced centrally by the dispatcher.\n void actions.dispatch({\n scope: 'annotation',\n event,\n ref: annotationRef,\n pon: annotationRef.pageObjectNumber,\n source,\n });\n },\n // Host lens (the actions plugin's executors/sinks) — FormHostCapability.\n resetFormAction,\n resolveSubmitDataset,\n commitScriptFormEffects: async (effects) => {\n const doc = ctx.doc;\n if (!doc?.forms.applyEffects) {\n // Sink contract: never throw — shape an all-failed batch honestly.\n return {\n results: effects.map((_, index) => ({\n index,\n status: 'failed' as const,\n fields: [],\n changedWidgets: [],\n error: { code: 'NotSupported', message: 'no form-effects batch door' } as never,\n })),\n changedWidgets: [],\n meta: null,\n };\n }\n let result: FormEffectsResult;\n try {\n result = await doc.forms.applyEffects(effects);\n } catch (error) {\n // Sink contract: never throw. An authority pre-check rejection\n // (PermissionDenied) becomes an all-failed batch, honestly.\n const message = error instanceof Error ? error.message : String(error);\n return {\n results: effects.map((_, index) => ({\n index,\n status: 'failed' as const,\n fields: [],\n changedWidgets: [],\n error: { code: 'Refused', message } as never,\n })),\n changedWidgets: [],\n meta: null,\n };\n }\n // Reconcile OUR model — the owner folds its own writes (the effects\n // listener deliberately ignores local events) — and the ANNOTATION\n // plane's view of any changed widgets (setDisplay flips widget /F\n // bits, and widget pixels live on that plane).\n await refresh(true);\n if (annotationHost) {\n const pons = new Set(\n result.changedWidgets\n .map((widget) => widget.pageObjectNumber)\n .filter((pon) => pon > 0),\n );\n for (const pon of pons) await annotationHost.reloadPage(pon);\n }\n return result;\n },\n setValue: (ref, value) =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const result = await doc.forms.setValue(ref, value);\n await refresh(true);\n return result;\n }),\n exportData: async (format: FormDataFormat = 'xfdf') => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n return doc.forms.exportData(format);\n },\n importData: (data, format) =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const result = await doc.forms.importData(data, format);\n apply({ t: 'snapshot', snapshot: result.snapshot });\n return result;\n }),\n repair: (repairOptions) =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const result = await doc.forms.repair(repairOptions);\n await refresh(true);\n return result;\n }),\n placeField: (input) => enqueueMutation(() => placeFieldNow(input)),\n pageBox,\n updateField: (key, patch) => enqueueMutation(() => updateFieldNow(key, patch)),\n deleteField: (key) => enqueueMutation(() => deleteFieldNow(key)),\n detachWidget: (key, annotObjectNumber) =>\n enqueueMutation(() => detachWidgetNow(key, annotObjectNumber)),\n // The twins (permissions.md). `canRead` mirrors the hydration gate above\n // — false means the model stays empty by RIGHT, not by loading. Fill and\n // design are independent grants: a filler is not a designer.\n canRead: () => can('doc.forms.read'),\n canFill: () => can('doc.forms.fill'),\n canDesign: () => can('doc.forms.modify'),\n };\n}\n","/**\n * Makes the form REACTIVE beyond this session's own writes — the same\n * pattern the metadata and annotation plugins use.\n *\n * Own value writes flow through the capability (writeDone patches one\n * field). This effect folds in everything else: remote collaborators'\n * `form.*` events (SSE on cloud), and structural events that can move or\n * add widgets (field created/deleted, repair) — those also invalidate the\n * cached widget geometry, because the widget PLANE changed.\n */\nimport type { DocumentEvent, EffectContext } from '@embedpdf/core';\n\nimport { update } from './core/model';\nimport type { FormAction, FormState } from './types';\n\nconst STRUCTURAL = new Set<DocumentEvent['type']>([\n 'form.fieldCreated',\n 'form.fieldUpdated',\n 'form.fieldDeleted',\n 'form.widgetAttached',\n 'form.widgetDetached',\n 'form.repaired',\n]);\n\nexport function registerFormEffects(ctx: EffectContext<FormState, FormAction>): void {\n const doc = ctx.doc;\n if (!doc) return;\n\n let refreshing = false;\n const refresh = async (): Promise<void> => {\n if (refreshing) return;\n refreshing = true;\n try {\n const snapshot = await doc.forms.list();\n ctx.dispatch({\n type: 'SET_MODEL',\n model: update(ctx.getState().model, { t: 'snapshot', snapshot }),\n });\n } finally {\n refreshing = false;\n }\n };\n\n const unsubscribe = doc.events.subscribe((event) => {\n // The live stream fell too far behind to replay: the gap's form events\n // will never arrive, so the snapshot in the model may be stale. This\n // plugin reconciles by REFETCH (not incremental merge), so the desync\n // notice is the only extra signal it needs — re-read the whole (cheap)\n // snapshot.\n if (event.type === 'stream.desynced') {\n void refresh();\n return;\n }\n if (!event.type.startsWith('form.') || !('origin' in event)) return;\n const structural = STRUCTURAL.has(event.type);\n // Own non-structural writes already landed via the capability.\n if (event.origin.kind !== 'remote' && !structural) return;\n if (structural) {\n ctx.dispatch({\n type: 'SET_MODEL',\n model: update(ctx.getState().model, { t: 'clearGeom' }),\n });\n }\n void refresh();\n });\n ctx.cleanup(unsubscribe);\n}\n","/**\n * THE form-tool table — the single source of truth for the palette. Every\n * derivation reads this one list: interaction registration (annotation-less),\n * annotation tool/style registration (full viewer), active-tool → field\n * family lookup, click placement, and default appearance.\n *\n * \"One tool system, two commit planes\": the tools live in the ANNOTATION\n * registry when that plugin is present (defaults, style panel, click-create —\n * the shared authoring infrastructure), but the COMMIT always goes\n * through `doc.forms.createField` via the form place handler. The tags make\n * that structural: these tools enable `form-place`, never `annotation-draw`,\n * so the annotation draw handler can't wake up for them.\n */\nimport type { FormFieldFamily } from '@embedpdf/engine-core/runtime';\nimport type { AnnotationPropsPatch, ClickCreate } from '@embedpdf/plugin-annotation/contract';\n\n/** The families the palette can author (no pushbutton/signature tools). */\nexport type AuthorableFormFamily = Exclude<FormFieldFamily, 'pushbutton' | 'signature' | 'unknown'>;\n\nexport interface FormToolDef {\n id: string;\n /** The field family `placeField` commits (the FORM plane's vocabulary). */\n family: AuthorableFormFamily;\n /** The client kind the ANNOTATION registry routes on (props panel).\n * Not a PDF subtype — every widget is PDF `widget`; this is the view. */\n visualKind: 'widget-text' | 'widget-choice' | 'widget-toggle';\n /** What a bare click places (box policies only — fields are boxes). */\n clickCreate: Extract<ClickCreate, { width: number }>;\n /** Seed drawing defaults: a placed field is VISIBLE (white box, gray\n * border) and restylable per tool through the shared style panel. */\n defaults: AnnotationPropsPatch;\n cursor: string;\n}\n\n/** Palette tools keep widgets editable right after placement. */\nexport const PLACE_TAGS = ['form-place', 'annotation-edit'] as const;\n\nconst FIELD_CHROME: AnnotationPropsPatch = {\n interiorColor: '#ffffff',\n color: '#6b7280',\n strokeWidth: 1,\n};\n\nexport const FORM_TOOLS: readonly FormToolDef[] = [\n {\n id: 'form-text',\n family: 'text',\n visualKind: 'widget-text',\n clickCreate: { width: 160, height: 24 },\n defaults: { ...FIELD_CHROME, fontSize: 12 },\n cursor: 'crosshair',\n },\n {\n id: 'form-checkbox',\n family: 'checkbox',\n visualKind: 'widget-toggle',\n clickCreate: { width: 18, height: 18 },\n defaults: FIELD_CHROME,\n cursor: 'crosshair',\n },\n {\n id: 'form-radio',\n family: 'radio',\n visualKind: 'widget-toggle',\n clickCreate: { width: 18, height: 18 },\n defaults: FIELD_CHROME,\n cursor: 'crosshair',\n },\n {\n id: 'form-combobox',\n family: 'combobox',\n visualKind: 'widget-choice',\n clickCreate: { width: 140, height: 24 },\n defaults: { ...FIELD_CHROME, fontSize: 12 },\n cursor: 'crosshair',\n },\n {\n id: 'form-listbox',\n family: 'listbox',\n visualKind: 'widget-choice',\n clickCreate: { width: 140, height: 72 },\n defaults: { ...FIELD_CHROME, fontSize: 12 },\n cursor: 'crosshair',\n },\n];\n\nexport const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef> = new Map(\n FORM_TOOLS.map((t) => [t.id, t]),\n);\n","import {\n MIN_DRAG,\n resolveClickPlacement,\n widgetAppearanceFromProps,\n} from '@embedpdf/plugin-annotation/authoring';\nimport type { AnnotationHostCapability } from '@embedpdf/plugin-annotation/contract/host';\nimport {\n samplePointOn,\n type InteractionCapability,\n type InteractionHandler,\n} from '@embedpdf/plugin-interaction/contract';\n\nimport type { Box } from './core/model';\nimport { FORM_TOOL_BY_ID } from './tools';\nimport type { FormCapability } from './types';\n\ntype Vec = { x: number; y: number };\n\nconst rectFrom = (a: Vec, b: Vec): Box => ({\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n width: Math.abs(b.x - a.x),\n height: Math.abs(b.y - a.y),\n});\n\n/**\n * Draw-to-place: drag a box (live placement preview through the annotation\n * plane's ghost pipeline) or just click (the tool's `clickCreate` policy,\n * resolved by the SAME `resolveClickPlacement` the annotation core uses) —\n * the commit creates field + widget through `doc.forms.placeField`, styled\n * from the tool's live defaults. The tool stays active for repeat placement\n * (v2 rubber-stamp feel) and the fresh widget is auto-selected.\n *\n * Gesture rules match the annotation handlers: page-anchored via the sample\n * projection (the box keeps sizing along the edge when the cursor overshoots\n * or crosses a gap), the UP sample is the final point, and a CLICK means\n * width AND height under the shared threshold — a thin 100×2 drag is a drag.\n */\nexport function createPlaceHandler(\n form: FormCapability,\n interaction: InteractionCapability,\n annotation: AnnotationHostCapability | null,\n): InteractionHandler {\n let origin: { pon: number; start: Vec; last: Vec } | null = null;\n return {\n id: 'form-place',\n // Above the annotation edit handler (100): while a palette tool is\n // active, a drag on empty page means \"place a field\", not \"marquee\".\n priority: 95,\n enabledFor: (t) => t.enables.has('form-place'),\n onDown: (s) => {\n // No capture without a page, a known palette tool, or write permission —\n // declining lets edit/pan/text-selection act on the gesture instead.\n if (!s.page || !FORM_TOOL_BY_ID.has(interaction.activeToolId())) return false;\n if (!form.canDesign()) return false;\n origin = { pon: s.page.pon, start: s.page.point, last: s.page.point };\n return true;\n },\n onMove: (s) => {\n if (!origin) return;\n const point = samplePointOn(s, origin.pon);\n if (!point) return;\n origin.last = point;\n const box = rectFrom(origin.start, point);\n // Live preview once the gesture reads as a drag — the WYSIWYG white box\n // (tool defaults) through the annotation ghost pipeline. Never dispatch\n // into the annotation store directly; this is its typed seam.\n if (annotation) {\n if (Math.max(box.width, box.height) >= MIN_DRAG) {\n annotation.setPlacementPreview(interaction.activeToolId(), origin.pon, box);\n } else {\n annotation.clearPlacementPreview();\n }\n }\n },\n onUp: (s) => {\n if (!origin) return;\n const o = origin;\n origin = null;\n annotation?.clearPlacementPreview();\n const toolId = interaction.activeToolId();\n const tool = FORM_TOOL_BY_ID.get(toolId);\n if (!tool) return;\n // The UP sample is the final point (projection first, like every\n // page-anchored gesture); a release over the gap falls back to the\n // last resolved point.\n const end = samplePointOn(s, o.pon) ?? o.last;\n const dragged = rectFrom(o.start, end);\n const isClick = dragged.width < MIN_DRAG && dragged.height < MIN_DRAG;\n const pageBox = form.pageBox(o.pon);\n const box = isClick ? boxOfClick(o.start, tool.clickCreate, pageBox) : dragged; // placeField clamps a drag to the page\n form\n .placeField({\n family: tool.family,\n pageObjectNumber: o.pon,\n box,\n // Style from the tool's LIVE defaults when the annotation plane is\n // here to hold them (the user restyled the tool in the panel);\n // annotation-less placement uses the table's static seed — a field\n // is never invisible. One conversion, the exported boundary util.\n appearance: widgetAppearanceFromProps(\n annotation ? annotation.currentDefaults(toolId) : tool.defaults,\n ),\n })\n .then((placed) => {\n // Auto-select the fresh widget — placeField resolves AFTER the\n // annotation page reload, so the ref is selectable. Skip when the\n // world moved on (tool changed) while the engine write ran.\n if (!annotation || interaction.activeToolId() !== toolId) return;\n const widget = placed.widget;\n if (!widget || widget.annotObjectNumber <= 0) return;\n annotation.select({\n kind: 'objectNumber',\n annotObjectNumber: widget.annotObjectNumber,\n pageObjectNumber: o.pon,\n });\n })\n .catch((err) => {\n globalThis.console?.error('[form] placeField failed:', err);\n });\n },\n };\n}\n\n/** The click-create box through the SHARED placement layer (fields are boxes;\n * the policy anchor + page clamp are exactly the annotation click's). */\nfunction boxOfClick(\n point: Vec,\n policy: { width: number; height: number; anchor?: 'center' | 'top-left' },\n pageBox: Box | null,\n): Box {\n const placement = resolveClickPlacement(point, policy, { pageBox: pageBox ?? undefined });\n return placement.kind === 'box'\n ? placement.rect\n : { x: point.x, y: point.y, width: policy.width, height: policy.height };\n}\n","import { initialModel } from './core/model';\nimport type { FormAction, FormState } from './types';\n\nexport const initialFormState = (): FormState => ({ model: initialModel() });\n\n/** Dumb store: the pure core computes the next model; the shell dispatches it. */\nexport const formReducer = (state: FormState, action: FormAction): FormState =>\n action.type === 'SET_MODEL' ? { model: action.model } : state;\n","import { definePlugin } from '@embedpdf/core';\nimport { ActionsToken } from '@embedpdf/plugin-actions/contract';\n// Executor registration lives on the actions HOST capability — same runtime\n// token, wider type (the annotation-internal precedent).\nimport { ActionsToken as ActionsHostToken } from '@embedpdf/plugin-actions/contract/host';\nimport { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\n// Behavior registration lives on the HOST capability (framework/plugin\n// surface) — same runtime token, wider type.\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/contract/host';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract';\n\nimport { createFormCapability } from './capability';\nimport { registerFormEffects } from './effects';\nimport { createPlaceHandler } from './handler';\nimport { formReducer, initialFormState } from './reducer';\nimport { FORM_TOOLS, PLACE_TAGS } from './tools';\nimport { FormToken } from './types';\nimport type { FormAction, FormHostCapability, FormPluginOptions, FormState } from './types';\n\n/**\n * The form plugin: the FIELD plane. Document-scoped; requires the\n * interaction hub. Fill mode works with no annotation plugin at all —\n * geometry is read from the engine's widget DTOs. When the annotation\n * plugin IS present, a Behavior keeps widgets geometry-inert while the\n * active tool carries 'form-fill' (the built-in pointer/pan tools do, so\n * filling is the resting state) and stands the fill controls down under\n * every other tool — the single-active-tool hub IS the mode switch.\n * Design mode = the 'form-edit' / palette tools: no 'form-fill' tag, so\n * widgets become ordinary editable annotations.\n */\nexport const formPlugin = (options: FormPluginOptions = {}) =>\n definePlugin<FormState, FormAction, FormHostCapability>({\n id: 'form',\n token: FormToken,\n scope: 'document',\n requires: [InteractionToken],\n optional: [AnnotationToken, ActionsToken],\n initialState: initialFormState,\n reduce: formReducer,\n capability: (ctx) => createFormCapability(ctx, options),\n effects: registerFormEffects,\n init: (ctx) => {\n const interaction = ctx.get(InteractionToken);\n const form = ctx.get(FormToken);\n // Fill-ONLY mode: forms fillable, no annotation editing at all. The\n // DEFAULT fill experience doesn't need this tool — the built-in\n // pointer/pan tools carry the 'form-fill' tag themselves.\n interaction.registerTool({\n id: 'form-fill',\n cursor: 'default',\n // `link-nav` rides along: links keep navigating while a form is being\n // filled (Acrobat behaviour) — inert without the link plugin.\n enables: new Set(['form-fill', 'link-nav']),\n });\n // Design mode's resting state (the Form tab): no 'form-fill', so the\n // widget Behavior disengages and widgets select/move/resize like any\n // annotation. Palette tools layer drag-to-place on top of this.\n interaction.registerTool({\n id: 'form-edit',\n cursor: 'default',\n enables: new Set(['annotation-edit', 'annotation-marquee']),\n });\n // Field palette: ONE tool table, two registration paths. With the\n // annotation plugin, palette tools join ITS registry — they gain live\n // defaults, the schema style panel (`propsForTool`), click-create — all\n // the shared authoring infrastructure. Without it,\n // the same table registers plain hub tools: drag/click placement and\n // programmatic authoring still work (`placeField` is a pure `doc.forms`\n // call); only INTERACTIVE styling/moving needs the annotation plane.\n // Either way the commit goes through the form place handler — these\n // tools enable 'form-place', never 'annotation-draw', so the two commit\n // planes can't cross structurally.\n const annotation = ctx.tryGet(AnnotationHostToken);\n for (const t of FORM_TOOLS) {\n if (annotation) {\n annotation.registerTool({\n id: t.id,\n subtype: t.visualKind,\n cursor: t.cursor,\n enables: [...PLACE_TAGS],\n clickCreate: t.clickCreate,\n defaults: t.defaults,\n });\n } else {\n interaction.registerTool({\n id: t.id,\n cursor: t.cursor,\n enables: new Set(PLACE_TAGS),\n });\n }\n }\n interaction.registerHandler(createPlaceHandler(form, interaction, annotation));\n\n if (annotation) {\n annotation.registerBehavior({\n id: 'form-widgets',\n matches: (a) => a.subtype.startsWith('widget'),\n engaged: () => interaction.activeTool()?.enables.has('form-fill') ?? false,\n });\n }\n\n // ── interim Phase-1 action executors ────────────────────────────────\n // The registry is the phasing seam: Phase 3's shared ScriptHost swaps\n // in by re-registering 'javascript' (last-wins). Lazy self-resolution\n // on purpose — executors run post-bringup against the kernel's\n // memoized capability, so the closure-held scripting controller exists\n // exactly when needed.\n const actions = ctx.tryGet(ActionsHostToken);\n if (actions) {\n // The real `javascript` executor is the actions plugin's own (Phase 3\n // ScriptHost); form contributes its DOCUMENT-commit sink so script\n // form effects land through the owner (engine write + model\n // reconciliation in one place — the stale-model class is structural).\n ctx.cleanup(\n actions.registerFormCommitSink((effects) => {\n const formHost = ctx.tryGet(FormToken);\n if (!formHost) {\n return Promise.resolve({\n results: effects.map((_, index) => ({\n index,\n status: 'failed' as const,\n fields: [],\n changedWidgets: [],\n })),\n changedWidgets: [],\n meta: null,\n });\n }\n return formHost.commitScriptFormEffects(effects);\n }),\n );\n ctx.cleanup(\n actions.registerSubmitResolver((intent, actionCtx, diagnose) => {\n const formHost = ctx.tryGet(FormToken);\n if (!formHost) throw new Error('form plugin unavailable');\n return formHost.resolveSubmitDataset(intent, actionCtx, diagnose);\n }),\n );\n ctx.cleanup(\n // The executor THREADS its ActionContext (the origin-laundering\n // fix): a lifecycle ResetForm's recalculation surfaces as\n // lifecycle, never as a user gesture.\n actions.registerExecutor('reset-form', async (node, actionCtx) => {\n if (node.type !== 'reset-form') {\n return { status: 'inert', reason: 'not a reset-form node' };\n }\n const formHost = ctx.tryGet(FormToken);\n if (!formHost) return { status: 'inert', reason: 'form plugin unavailable' };\n const result = await formHost.resetFormAction(\n node.fields,\n node.exclude,\n actionCtx.origin,\n );\n if (result.status === 'failed') {\n return { status: 'failed', error: result.error?.message ?? 'reset failed' };\n }\n if (result.effectsResult === null) {\n return {\n status: 'inert',\n reason: result.diagnostics[0]?.message ?? 'reset-form resolved no fields',\n };\n }\n return { status: 'executed' };\n }),\n );\n }\n },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,yBACX,KACA,SACA,YACqD;CACrD,IAAI,YAAY,MAAM,OAAO;EAAE,UAAU,CAAC,GAAG,GAAG;EAAG,cAAc;CAAM;CACvE,MAAM,QAAQ,QAAQ,QAAQ,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,IAAI;CACxE,MAAM,gBAAgB,IAAI,IACxB,QAAQ,QAAQ,MAAM,EAAE,SAAS,cAAc,CAAC,CAAC,KAAK,MAAM,EAAE,YAAY,CAC5E;CACA,MAAM,UAAU,UACb,MAAM,IAAI,SAAS,kBAAkB,cAAc,IAAI,MAAM,IAAI,iBAAiB,KACnF,MAAM,MAAM,SAAS,MAAM,SAAS,QAAQ,MAAM,KAAK,WAAW,GAAG,KAAK,EAAE,CAAC;CAE/E,OAAO;EAAE,UADQ,UAAU,IAAI,QAAQ,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,MAAM;EACzD;CAAO;AAC5B;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,sBACX,QACA,QACA,aAC0B;CAC1B,MAAM,EAAE,UAAU,WAAW,sBAAsB,QAAQ,OAAO,QAAQ,OAAO,OAAO;CACxF,MAAM,kBAAkB,OAAO,WAAW,QAAQ,CAAC,OAAO;CAC1D,MAAM,UAAiC,CAAC;CACxC,KAAK,MAAM,SAAS,UAAU;EAC5B,MAAM,WAAW,mBAAmB,OAAO,KAAK;EAChD,IAAI,MAAM,WAAW,gBAAgB,MAAM,WAAW,aAAa;GACjE,IAAI,UACF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9D,MAAM,WAAW,IAAI,OAAOA,cAAAA,SAAS;IACrC,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,yBAAyB;IACxD,OAAO,SAAS,qBAAqB,QAAQ,WAAW,QAAQ;GAClE,CAAC,CACH;GACA,IAAI,QAIF,QAAQ,iBAAiB,cAAc,OAAO,MAAM,cAAc;IAChE,IAAI,KAAK,SAAS,cAChB,OAAO;KAAE,QAAQ;KAAS,QAAQ;IAAwB;IAE5D,MAAM,WAAW,IAAI,OAAOA,cAAAA,SAAS;IACrC,IAAI,CAAC,UAAU,OAAO;KAAE,QAAQ;KAAS,QAAQ;IAA0B;IAC3E,MAAM,SAAS,MAAM,SAAS,gBAC5B,KAAK,QACL,KAAK,SACL,UAAU,MACZ;IACA,IAAI,OAAO,WAAW,UACpB,OAAO;KAAE,QAAQ;KAAU,OAAO,OAAO,OAAO,WAAW;IAAe;IAE5E,IAAI,OAAO,kBAAkB,MAC3B,OAAO;KACL,QAAQ;KACR,QAAQ,OAAO,YAAY,EAAE,EAAE,WAAW;IAC5C;IAEF,OAAO,EAAE,QAAQ,WAAW;GAC9B,CAAC,CACH;EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["createSerialQueue","ActionsHostToken","createFormScriptingController","fillItems","coreFillItems","coreFillItemForWidget","PermissionDenied","AnnotationHostToken","coreFieldForWidget","ActionsToken","MIN_DRAG","FormToken","InteractionToken","AnnotationToken","ActionsToken","AnnotationHostToken","ActionsHostToken"],"sources":["../src/field-selection.ts","../src/core/model.ts","../src/core/fill-items.ts","../src/mutationQueue.ts","../src/capability.ts","../src/effects.ts","../src/tools.ts","../src/handler.ts","../src/reducer.ts","../src/form.plugin.ts"],"sourcesContent":["import type {\n FormFieldDTO,\n FormFieldRef,\n FormSubmissionEntry,\n PdfActionTargetRef,\n} from '@embedpdf/engine-core/runtime';\nimport type { ActionDiagnostic, SubmitIntent } from '@embedpdf/plugin-actions/contract';\n\n/**\n * ISO field selection, written ONCE for ResetForm (Tables 241/242) and\n * SubmitForm (Tables 239/240): a NAME target selects the field AND its\n * descendants (FQN dot-prefix — `parent` selects `parent.c1`, the rule the\n * old exact-match resolution violated); an objectNumber target selects that\n * field dictionary. Include mode keeps the selection; exclude mode keeps\n * the complement (a name excludes its subtree the same way it includes\n * it). `targets === null` (the key ABSENT) selects everything and the flag\n * is ignored; `[]` + include selects NOTHING while `[]` + exclude selects\n * everything — presence and emptiness are different states.\n *\n * `listed` reports whether a field was ADDRESSED by the target list\n * (directly or through its subtree) — the \"explicitly listed\" predicate the\n * submit honesty diagnostics key on.\n */\nexport const resolveFieldSelection = <F extends { name: string; ref: FormFieldRef }>(\n all: readonly F[],\n targets: PdfActionTargetRef[] | null,\n exclude: boolean,\n): { selected: F[]; listed: (field: F) => boolean } => {\n if (targets === null) return { selected: [...all], listed: () => false };\n const names = targets.filter((t) => t.kind === 'name').map((t) => t.name);\n const objectNumbers = new Set(\n targets.filter((t) => t.kind === 'objectNumber').map((t) => t.objectNumber),\n );\n const listed = (field: F): boolean =>\n (field.ref.kind === 'objectNumber' && objectNumbers.has(field.ref.fieldObjectNumber)) ||\n names.some((name) => field.name === name || field.name.startsWith(`${name}.`));\n const selected = exclude ? all.filter((f) => !listed(f)) : all.filter(listed);\n return { selected, listed };\n};\n\n/**\n * Build the resolved submission dataset from a live field list (Tables\n * 239/240 semantics; pure — the capability supplies a FRESH engine read so\n * no model-lag class exists):\n *\n * - the unconditional **NoExport veto** — even an explicit include cannot\n * override it (diagnosed when explicitly listed, so the veto is\n * observable, silent when swept in implicitly);\n * - **push-buttons and signatures** never contribute entries in v1 —\n * ISO's explicit-pushbutton-`/AP`-in-FDF rule is unrepresentable in the\n * current DTO, so an EXPLICITLY listed one is diagnosed\n * (`submit-entry-unsupported`), never silently dropped;\n * - an **unsupported `/V` shape** is always diagnosed (silent omission\n * would be data loss);\n * - a valueless field becomes a NAME-ONLY entry (`value: null`) only under\n * IncludeNoValueFields, else it is skipped (the ISO default);\n * - values are entry-faithful: scalar → string, array (multi-select list\n * box) → string[]; the submitted name is the fully qualified name.\n */\nexport const buildSubmitEntries = (\n fields: readonly FormFieldDTO[],\n intent: SubmitIntent,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n): FormSubmissionEntry[] => {\n const { selected, listed } = resolveFieldSelection(fields, intent.fields, intent.exclude);\n const explicitInclude = intent.fields !== null && !intent.exclude;\n const entries: FormSubmissionEntry[] = [];\n for (const field of selected) {\n const explicit = explicitInclude && listed(field);\n if (field.family === 'pushbutton' || field.family === 'signature') {\n if (explicit) {\n diagnose({\n code: 'submit-entry-unsupported',\n message: `submit: '${field.name}' (${field.family}) has no representable submission value in v1 — skipped`,\n });\n }\n continue;\n }\n if (field.flags.noExport) {\n if (explicit) {\n diagnose({\n code: 'submit-entry-unsupported',\n message: `submit: '${field.name}' carries the NoExport flag — the veto is unconditional (ISO 12.7.6.2), skipped`,\n });\n }\n continue;\n }\n const entry = field.valueEntry;\n if (entry.kind === 'scalar') {\n entries.push({ name: field.name, value: entry.value });\n } else if (entry.kind === 'array') {\n entries.push({ name: field.name, value: entry.values });\n } else if (entry.kind === 'none') {\n if (intent.includeNoValueFields) entries.push({ name: field.name, value: null });\n } else {\n diagnose({\n code: 'submit-entry-unsupported',\n message: `submit: '${field.name}' has an unsupported /V shape — skipped (would otherwise be silent data loss)`,\n });\n }\n }\n return entries;\n};\n","/**\n * The pure heart of the form plugin — no DOM, no engine, no kernel imports.\n * Same discipline as `annotation-core`, folded in as a directory because the\n * model is small and has no consumer besides this plugin.\n *\n * The model mirrors ENGINE truth plus transient write status. Keystroke\n * drafts deliberately live in the framework controls (a focused `<input>` is\n * already the draft store); the model only learns about a value when it is\n * committed. That keeps typing synchronous and the model identical across\n * frameworks.\n */\nimport type { FormFieldDTO, FormSnapshot } from '@embedpdf/engine-core/runtime';\n\n/** A content-space box (top-left origin, y-down, PDF points). */\nexport interface Box {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Stable client key for a field: object number when durable, else FQN. */\nexport type FieldKey = string;\n\nexport const fieldKeyOf = (field: { fieldObjectNumber: number; name: string }): FieldKey =>\n field.fieldObjectNumber > 0 ? `obj:${field.fieldObjectNumber}` : `fqn:${field.name}`;\n\nexport interface Model {\n /** Engine truth; replaced wholesale on refresh, patched on write-backs. */\n snapshot: FormSnapshot | null;\n /** fieldKey → index into snapshot.fields. */\n byKey: Record<FieldKey, number>;\n /** annotObjectNumber → index into snapshot.fields (widget → field join). */\n byWidget: Record<number, number>;\n /** Fields with an in-flight engine write (disables their controls). */\n writing: Record<FieldKey, true>;\n /**\n * Widget geometry per page: annotObjectNumber → content-space box. Fed by\n * the shell from the WIDGET plane (one annotations read per page); value\n * writes never move widgets, so this survives snapshot refreshes and is\n * only cleared on structural form events.\n */\n geom: Record<number, Record<number, Box> | undefined>;\n /** Bumped on every change — cheap equality for memoized projections. */\n seq: number;\n}\n\nexport const initialModel = (): Model => ({\n snapshot: null,\n byKey: {},\n byWidget: {},\n writing: {},\n geom: {},\n seq: 0,\n});\n\nexport type Msg =\n | { t: 'snapshot'; snapshot: FormSnapshot }\n | { t: 'writeStart'; key: FieldKey }\n | { t: 'writeDone'; key: FieldKey; field: FormFieldDTO }\n | { t: 'writeFailed'; key: FieldKey }\n | { t: 'pageGeom'; pageObjectNumber: number; boxes: Record<number, Box> }\n | { t: 'clearGeom'; pageObjectNumber?: number };\n\nfunction index(snapshot: FormSnapshot): Pick<Model, 'byKey' | 'byWidget'> {\n const byKey: Record<FieldKey, number> = {};\n const byWidget: Record<number, number> = {};\n snapshot.fields.forEach((field, i) => {\n byKey[fieldKeyOf(field)] = i;\n for (const w of field.widgets) {\n if (w.annotObjectNumber > 0) byWidget[w.annotObjectNumber] = i;\n }\n });\n return { byKey, byWidget };\n}\n\nexport function update(model: Model, msg: Msg): Model {\n switch (msg.t) {\n case 'snapshot':\n return {\n ...model,\n snapshot: msg.snapshot,\n ...index(msg.snapshot),\n writing: {},\n seq: model.seq + 1,\n };\n case 'writeStart':\n return { ...model, writing: { ...model.writing, [msg.key]: true }, seq: model.seq + 1 };\n case 'writeDone': {\n if (!model.snapshot) return model;\n const i = model.byKey[msg.key];\n if (i === undefined) return model;\n const fields = model.snapshot.fields.slice();\n fields[i] = msg.field;\n const { [msg.key]: _done, ...writing } = model.writing;\n const snapshot = { ...model.snapshot, fields };\n return { ...model, snapshot, ...index(snapshot), writing, seq: model.seq + 1 };\n }\n case 'writeFailed': {\n const { [msg.key]: _failed, ...writing } = model.writing;\n return { ...model, writing, seq: model.seq + 1 };\n }\n case 'pageGeom':\n return {\n ...model,\n geom: { ...model.geom, [msg.pageObjectNumber]: msg.boxes },\n seq: model.seq + 1,\n };\n case 'clearGeom': {\n if (msg.pageObjectNumber === undefined) {\n return { ...model, geom: {}, seq: model.seq + 1 };\n }\n const geom = { ...model.geom };\n delete geom[msg.pageObjectNumber];\n return { ...model, geom, seq: model.seq + 1 };\n }\n }\n}\n\nexport const fieldByKey = (model: Model, key: FieldKey): FormFieldDTO | null => {\n const i = model.byKey[key];\n return i === undefined ? null : (model.snapshot?.fields[i] ?? null);\n};\n\nexport const fieldForWidget = (model: Model, annotObjectNumber: number): FormFieldDTO | null => {\n const i = model.byWidget[annotObjectNumber];\n return i === undefined ? null : (model.snapshot?.fields[i] ?? null);\n};\n","/**\n * The fill-mode projection: what a framework paints for one page. Pure data\n * in CONTENT space (top-left origin, y-down PDF points) — the same space\n * annotation RenderItems use, so layers position with the page transform\n * and never re-derive scale.\n *\n * Geometry comes from the WIDGET plane: the shell reads each page's\n * annotations once (widgets are annotations; their DTOs carry /Rect) and\n * feeds content-space boxes into the model via `pageGeom`. The field plane\n * (this snapshot) contributes identity, value, and behavior.\n */\nimport type { FormFieldDTO, FormFieldOption, FormSnapshot } from '@embedpdf/engine-core/runtime';\n\nimport { fieldForWidget, fieldKeyOf, type Box, type FieldKey, type Model } from './model';\n\nexport type { Box } from './model';\n\ninterface FillItemBase {\n key: FieldKey;\n /** Widget identity — joins to the annotation plane. */\n annotObjectNumber: number;\n box: Box;\n /** Read-only field or write in flight: render, don't accept input. */\n disabled: boolean;\n /** Accessible name: /TU when present, else the fully qualified name. */\n label: string;\n}\n\nexport type FillItem = FillItemBase &\n (\n | {\n control: 'text';\n value: string;\n multiline: boolean;\n password: boolean;\n maxLength: number | null;\n comb: boolean;\n }\n | { control: 'toggle'; kind: 'checkbox' | 'radio'; checked: boolean; onState: string }\n | {\n control: 'choice';\n kind: 'combo' | 'list';\n edit: boolean;\n multi: boolean;\n options: FormFieldOption[];\n selected: string[];\n }\n | { control: 'button' }\n );\n\nconst ZERO_BOX: Box = { x: 0, y: 0, width: 0, height: 0 };\n\n/**\n * Project ONE widget of a field into a fill control. `box` is supplied by the\n * caller: the page projection reads the model's widget geometry; a consumer\n * that already owns a live box (the annotation plane's RenderItem) passes it —\n * or nothing, when only the semantics matter. Null for families with no fill\n * control (signature/unknown: rendered by the annotation plane only).\n */\nexport function projectWidget(\n model: Model,\n field: FormFieldDTO,\n annotObjectNumber: number,\n box: Box = ZERO_BOX,\n): FillItem | null {\n const key = fieldKeyOf(field);\n const base: FillItemBase = {\n key,\n annotObjectNumber,\n box,\n disabled: field.flags.readOnly || model.writing[key] === true,\n label: field.alternateName ?? field.name,\n };\n switch (field.family) {\n case 'text':\n return {\n ...base,\n control: 'text',\n value: field.value,\n multiline: field.multiline,\n password: field.password,\n maxLength: field.maxLength,\n comb: field.comb,\n };\n case 'checkbox': {\n const toggle = field.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n return {\n ...base,\n control: 'toggle',\n kind: 'checkbox',\n checked: field.checked,\n onState: toggle && 'onState' in toggle ? toggle.onState : 'Yes',\n };\n }\n case 'radio': {\n const toggle = field.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n return {\n ...base,\n control: 'toggle',\n kind: 'radio',\n checked: toggle && 'checked' in toggle ? toggle.checked : false,\n onState: toggle && 'onState' in toggle ? toggle.onState : '',\n };\n }\n case 'combobox':\n return {\n ...base,\n control: 'choice',\n kind: 'combo',\n edit: field.edit,\n multi: false,\n options: field.options,\n selected: field.value === '' ? [] : [field.value],\n };\n case 'listbox':\n return {\n ...base,\n control: 'choice',\n kind: 'list',\n edit: false,\n multi: field.multiSelect,\n options: field.options,\n selected: field.selectedValues,\n };\n case 'pushbutton':\n return { ...base, control: 'button' };\n default:\n return null;\n }\n}\n\n/**\n * Project one page's widgets into fill controls. Widgets whose geometry has\n * not arrived yet (or that are direct objects with no join key) are skipped —\n * the shell re-runs the projection when `pageGeom` lands.\n */\nexport function fillItems(model: Model, pageObjectNumber: number): FillItem[] {\n const snapshot: FormSnapshot | null = model.snapshot;\n const geom = model.geom[pageObjectNumber];\n if (!snapshot || !geom) return [];\n const items: FillItem[] = [];\n\n for (const field of snapshot.fields) {\n for (const widget of field.widgets) {\n if (widget.pageObjectNumber !== pageObjectNumber) continue;\n const box = geom[widget.annotObjectNumber];\n if (!box) continue;\n const item = projectWidget(model, field, widget.annotObjectNumber, box);\n if (item) items.push(item);\n }\n }\n return items;\n}\n\n/**\n * Project a SINGLE widget by its annotation object number — the join the\n * annotation-plane render layer uses (it owns a live box already, so the\n * model's cached geometry is used only when it happens to be loaded; the\n * item's semantics never depend on it). Null while the snapshot hasn't\n * landed, or for families with no fill control.\n */\nexport function fillItemForWidget(model: Model, annotObjectNumber: number): FillItem | null {\n const field = fieldForWidget(model, annotObjectNumber);\n if (!field) return null;\n const widget = field.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n if (!widget) return null;\n const box = model.geom[widget.pageObjectNumber]?.[annotObjectNumber];\n return projectWidget(model, field, annotObjectNumber, box);\n}\n","import { createSerialQueue } from '@embedpdf/core';\n\n/** The core serial queue under its historical form-plugin name. */\nexport const createSerialMutationQueue = createSerialQueue;\n","import {\n PermissionDenied,\n type AnnotationRef,\n type FormDataFormat,\n type FormFieldDraft,\n type FormFieldPatch,\n type FormFieldRef,\n type FormFieldValue,\n type FormSnapshot,\n type PdfActionTargetRef,\n type PdfActionTree,\n type PdfRect,\n} from '@embedpdf/engine-core/runtime';\nimport { DocumentsToken, type PluginContext } from '@embedpdf/core';\nimport { ActionsToken, createHoverPump } from '@embedpdf/plugin-actions/contract';\nimport { ActionsToken as ActionsHostToken } from '@embedpdf/plugin-actions/contract/host';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSource,\n ActionSubmitRequest,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\n\nimport { buildSubmitEntries, resolveFieldSelection } from './field-selection';\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/contract/host';\n\nimport {\n fillItemForWidget as coreFillItemForWidget,\n fillItems as coreFillItems,\n type FillItem,\n} from './core/fill-items';\nimport {\n fieldByKey,\n fieldForWidget as coreFieldForWidget,\n update,\n type Box,\n type FieldKey,\n type Model,\n type Msg,\n} from './core/model';\nimport { createSerialMutationQueue } from './mutationQueue';\nimport { createFormScriptingController } from './scripting';\nimport type { FormEffectsResult } from '@embedpdf/engine-core/runtime';\nimport type {\n FormAction,\n FormCommitResult,\n FormHostCapability,\n FormPluginOptions,\n FormState,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\n\n/** PDF user-space rect (y-up) → content-space box (y-down, crop-relative). */\nconst toBox = (rect: PdfRect, crop: PdfRect): Box => ({\n x: rect.left - crop.left,\n y: crop.top - rect.top,\n width: rect.right - rect.left,\n height: rect.top - rect.bottom,\n});\n\nconst sameAnnotationRef = (left: AnnotationRef, right: AnnotationRef): boolean => {\n if (left.kind !== right.kind || left.pageObjectNumber !== right.pageObjectNumber) return false;\n if (left.kind === 'objectNumber' && right.kind === 'objectNumber') {\n return left.annotObjectNumber === right.annotObjectNumber;\n }\n if (left.kind === 'nm' && right.kind === 'nm') return left.nm === right.nm;\n return (\n left.kind === 'index' &&\n right.kind === 'index' &&\n left.index === right.index &&\n left.revision === right.revision\n );\n};\n\n/**\n * The form shell. Pure `update` runs here; the resulting model is dispatched\n * to the store; engine calls happen around it. Every read the frameworks do\n * goes through memoized projections keyed on `model.seq`.\n */\nexport function createFormCapability(\n ctx: PluginContext<FormState, FormAction>,\n options: FormPluginOptions = {},\n): FormHostCapability {\n const model = (): Model => ctx.getState().model;\n const apply = (msg: Msg): void => {\n ctx.dispatch({ type: 'SET_MODEL', model: update(model(), msg) });\n };\n\n const refKeyOf = (key: FieldKey): FormFieldRef => {\n if (key.startsWith('obj:')) {\n return { kind: 'objectNumber', fieldObjectNumber: Number(key.slice(4)) };\n }\n return { kind: 'fqn', name: key.slice(4) };\n };\n const enqueueMutation = createSerialMutationQueue();\n\n // Scripting rides the actions plugin's per-document realm: the transaction\n // port's PRESENCE is the \"JavaScript is on\" signal (D8 — the switch lives\n // on actionsPlugin({ javascript }); form owns only the K/V/C/F pipeline).\n const actionsHost = ctx.tryGet(ActionsHostToken);\n const realm = actionsHost?.scriptRealm ?? null;\n const scripting =\n realm && ctx.doc\n ? createFormScriptingController({\n doc: ctx.doc,\n document: () => ctx.document(),\n transaction: realm.transaction.bind(realm),\n budget: realm.budget,\n })\n : null;\n if (scripting) ctx.cleanup(() => scripting.dispose());\n\n /** Every script surface (UI effects, diagnostics, errors) flows through\n * the actions plugin's ONE port — origin/phase attached (D9). */\n const surfaceViaActions = (result: FormCommitResult, origin: ActionOrigin): void => {\n actionsHost?.surfaceScriptCommit(result, { origin, realm: 'document' });\n };\n\n // Authority reads for the twins, the hydration gate, the fused fill\n // projection, and the write gate — one wildcard-aware helper.\n const can = (cap: 'doc.forms.read' | 'doc.forms.fill' | 'doc.forms.modify'): boolean =>\n ctx.doc?.security.allows(cap) ?? false;\n\n // ── snapshot loading ────────────────────────────────────────────────────\n let refreshPromise: Promise<void> | null = null;\n const refresh = async (force = false): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n // No read authority → don't fire a doomed list (a reviewer-shaped token\n // without `doc.forms.read` is the COMMON narrowed scope); the model stays\n // empty and `canRead()` tells chrome why. The engine enforces regardless.\n if (!can('doc.forms.read')) return;\n if (refreshPromise) {\n await refreshPromise;\n if (!force) return;\n }\n refreshPromise = doc.forms\n .list()\n .then((snapshot) => apply({ t: 'snapshot', snapshot }))\n .catch((err) => {\n // A race with an access change 403s here; anything else is a real\n // load failure. Either way: surfaced, never an unhandled rejection.\n console.warn('[form] form snapshot failed to load', err);\n })\n .finally(() => {\n refreshPromise = null;\n });\n return refreshPromise;\n };\n\n // ── widget geometry (from the WIDGET plane: one annotations read/page) ──\n const geomLoading = new Set<number>();\n const ensureGeom = (pon: number): void => {\n const doc = ctx.doc;\n if (!doc || geomLoading.has(pon) || model().geom[pon]) return;\n const crop = ctx.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n if (!crop) return;\n geomLoading.add(pon);\n void doc\n .page(pon)\n .annotations.list()\n .then(({ annotations }) => {\n const boxes: Record<number, Box> = {};\n for (const dto of annotations) {\n if (dto.subtype !== 'widget') continue;\n const objectNumber = dto.ref.kind === 'objectNumber' ? dto.ref.annotObjectNumber : 0;\n if (objectNumber > 0) boxes[objectNumber] = toBox(dto.rect, crop);\n }\n apply({ t: 'pageGeom', pageObjectNumber: pon, boxes });\n })\n .finally(() => {\n geomLoading.delete(pon);\n });\n };\n\n // ── memoized fill projection ────────────────────────────────────────────\n // Session fill authority FUSES into the same `disabled` the field's\n // ReadOnly flag feeds (permissions.md: authority rides the flags gate) —\n // without `doc.forms.fill` every widget renders inert, so the pixels are\n // truthful and no gesture reaches a doomed write.\n const fuseFill = (item: FillItem | null, fillable: boolean): FillItem | null =>\n item === null || fillable || item.disabled ? item : { ...item, disabled: true };\n\n const fillCache = new Map<number, { seq: number; fillable: boolean; items: FillItem[] }>();\n const fillItems = (pon: number): FillItem[] => {\n const m = model();\n const fillable = can('doc.forms.fill');\n const hit = fillCache.get(pon);\n if (hit && hit.seq === m.seq && hit.fillable === fillable) return hit.items;\n const items = coreFillItems(m, pon).map((item) => fuseFill(item, fillable) as FillItem);\n fillCache.set(pon, { seq: m.seq, fillable, items });\n return items;\n };\n\n // Single-widget projection — reference-stable per model.seq so framework\n // selectors can use plain identity equality.\n const fillItemCache = new Map<\n number,\n { seq: number; fillable: boolean; item: FillItem | null }\n >();\n const fillItem = (annotObjectNumber: number): FillItem | null => {\n const m = model();\n const fillable = can('doc.forms.fill');\n const hit = fillItemCache.get(annotObjectNumber);\n if (hit && hit.seq === m.seq && hit.fillable === fillable) return hit.item;\n const item = fuseFill(coreFillItemForWidget(m, annotObjectNumber), fillable);\n fillItemCache.set(annotObjectNumber, { seq: m.seq, fillable, item });\n return item;\n };\n\n // ── typed writes: writeStart → engine → writeDone/writeFailed ──────────\n const commitValueNow = async (\n ref: FormFieldRef,\n value: FormFieldValue,\n ): Promise<FormCommitResult> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n if (scripting) {\n const result = await scripting.commit(ref, value);\n surfaceViaActions(result, 'user');\n // A native partial/failed effects result can still have mutated state.\n if (result.effectsResult !== null) await refresh(true);\n return result;\n }\n\n const result = await doc.forms.setValue(ref, value);\n await refresh(true);\n return {\n status: result.changedWidgets.length > 0 ? 'applied' : 'unchanged',\n scripted: false,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n };\n\n const write = (key: FieldKey, value: FormFieldValue): Promise<void> => {\n // The optimistic gate: no fill authority → refuse BEFORE the spinner and\n // the queued engine call, with the refusal shape the engine would send.\n // (The fused projection renders such widgets inert; this covers the\n // imperative door.)\n if (!can('doc.forms.fill'))\n return Promise.reject(new PermissionDenied('doc.forms.fill', 'form.fill'));\n return enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) return;\n apply({ t: 'writeStart', key });\n try {\n const result = await commitValueNow(refKeyOf(key), value);\n if (result.status === 'rejected' || result.status === 'failed') {\n apply({ t: 'writeFailed', key });\n } else if (result.effectsResult === null && result.scripted) {\n // A scripted no-op has no engine read-back to clear the spinner.\n apply({ t: 'writeFailed', key });\n }\n } catch (err) {\n apply({ t: 'writeFailed', key });\n throw err;\n }\n });\n };\n\n // ── design mode ──────────────────────────────────────────────────────────\n // The annotation plane must re-read pages whose widget population changed\n // underneath it (created/deleted widgets); optional — fill-only setups\n // simply have no annotation plugin to nudge.\n const annotationHost = ctx.tryGet(AnnotationHostToken);\n\n const annotationActivation = async (ref: AnnotationRef) => {\n const doc = ctx.doc;\n if (!doc) return null;\n const loaded = annotationHost?.get(ref);\n if (loaded?.subtype === 'widget') return loaded.actions?.activate ?? null;\n const { annotations } = await doc.page(ref.pageObjectNumber).annotations.list();\n const annotation = annotations.find((candidate) => sameAnnotationRef(candidate.ref, ref));\n return annotation?.subtype === 'widget' ? (annotation.actions?.activate ?? null) : null;\n };\n\n const activateWidgetNow = async (\n key: FieldKey,\n annotationRef: AnnotationRef,\n ): Promise<FormCommitResult> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n if (!scripting) {\n return {\n status: 'unchanged',\n scripted: false,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n }\n const action = await annotationActivation(annotationRef);\n if (!action) {\n return {\n status: 'unchanged',\n scripted: true,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n }\n const result = await scripting.activate(refKeyOf(key), action);\n surfaceViaActions(result, 'user');\n if (result.effectsResult !== null) await refresh(true);\n return result;\n };\n\n // ── action-executor doors (host lens) ───────────────────────────────────\n // Both ride enqueueMutation: an actions-driven form mutation must never\n // interleave with a user's in-flight commit. The direction is always\n // actions queue → form queue — the delegated activateWidget below never\n // enters the form queue, so these can (no self-deadlock).\n\n const NOT_SCRIPTED: FormCommitResult = {\n status: 'unchanged',\n scripted: false,\n effectsResult: null,\n uiEffects: [],\n diagnostics: [],\n };\n\n /**\n * The shared reset core: one effects batch → refresh → V/C/F\n * recalculation when the transaction port is present. Ridden by BOTH\n * doors — the /ResetForm executor and the public `reset(key)` — so the\n * two can never diverge again (the \"reset() asymmetry\" fix). `origin` is\n * PRESERVED through recalculation surfacing: a lifecycle/hover ResetForm\n * can no longer launder its alerts into user origin.\n */\n const applyResetBatch = async (\n refs: FormFieldRef[],\n origin: ActionOrigin,\n ): Promise<FormCommitResult> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n if (!doc.forms.applyEffects) {\n const result: FormCommitResult = {\n ...NOT_SCRIPTED,\n diagnostics: [\n { code: 'unsupported-api', message: 'this engine has no form-effects batch door' },\n ],\n };\n surfaceViaActions(result, origin);\n return result;\n }\n // Zero refs must NEVER reach the engine (the applier throws InvalidArg\n // on an empty reset) — `[] + include` is a valid action that resets\n // nothing. `effectsResult: null` tells the executor this was inert.\n if (refs.length === 0) return NOT_SCRIPTED;\n const effectsResult = await doc.forms.applyEffects([{ kind: 'reset', refs }]);\n // The batch is non-rollback-atomic and resolves with per-effect\n // statuses instead of throwing — reflect a rejected/failed reset\n // honestly (the executor maps 'failed' to a failed chain node).\n const resetFailed = effectsResult.results.some(\n (entry) => entry.status === 'failed' || entry.status === 'rejected',\n );\n await refresh(true);\n if (resetFailed) {\n return {\n status: 'failed',\n scripted: false,\n effectsResult,\n uiEffects: [],\n diagnostics: [],\n };\n }\n // Acrobat recalculates after a reset; boot rides along lazily.\n let recalc: FormCommitResult | null = null;\n if (scripting) {\n recalc = await scripting.recalculate();\n surfaceViaActions(recalc, origin);\n if (recalc.effectsResult !== null) await refresh(true);\n }\n return {\n status: 'applied',\n scripted: recalc !== null,\n effectsResult,\n uiEffects: recalc?.uiEffects ?? [],\n diagnostics: recalc?.diagnostics ?? [],\n ...(recalc?.error ? { error: recalc.error } : {}),\n };\n };\n\n const resetFormAction = (\n targets: PdfActionTargetRef[] | null,\n exclude: boolean,\n origin: ActionOrigin = 'user',\n ): Promise<FormCommitResult> =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const snapshot = await doc.forms.list();\n // The shared ISO selection (Tables 241/242): a parent NAME resets its\n // descendants too — the exact-match resolution this replaces was a\n // conformance bug.\n const { selected } = resolveFieldSelection(snapshot.fields, targets, exclude);\n // ResetForm SKIPS fields with nothing to restore — the engine's batch\n // applier refuses pushbutton/signature refs outright (validateEffect),\n // and an exclude-mode complement always sweeps in the form's buttons.\n const resettable = selected.filter(\n (f) => f.family !== 'pushbutton' && f.family !== 'signature',\n );\n return applyResetBatch(\n resettable.map((f) => f.ref),\n origin,\n );\n });\n\n /**\n * The submit dataset resolver (Phase 4, D7): a FRESH engine read — never\n * the cached model, so no staleness class exists — then the pure ISO\n * builder. Selection/veto/value semantics live in `field-selection.ts`;\n * this door only supplies the live fields and assembles the request.\n */\n const resolveSubmitDataset = async (\n intent: SubmitIntent,\n actionCtx: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n ): Promise<ActionSubmitRequest> => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const snapshot = await doc.forms.list();\n return {\n url: intent.url,\n method: intent.method,\n format: intent.format,\n flagsRaw: intent.flagsRaw,\n ...(intent.charSet === undefined ? {} : { charSet: intent.charSet }),\n entries: buildSubmitEntries(snapshot.fields, intent, diagnose),\n origin: actionCtx.origin,\n event: actionCtx.event,\n };\n };\n\n // ── widget DOM-event feed helpers ───────────────────────────────────────\n const widgetSource = (key: FieldKey, annotationRef: AnnotationRef): ActionSource => ({\n kind: 'widget',\n field: refKeyOf(key),\n annotation: annotationRef,\n pon: annotationRef.pageObjectNumber,\n });\n\n /** One shared hover pump (Exit→Enter as one ordered pair; intermediates\n * skipped), created on first use against the resolved actions capability. */\n let widgetPump: ReturnType<typeof createHoverPump> | null = null;\n const widgetHoverPump = (actions: {\n dispatch: Parameters<typeof createHoverPump>[0];\n }): ReturnType<typeof createHoverPump> => {\n widgetPump ??= createHoverPump(actions.dispatch);\n return widgetPump;\n };\n\n const widgetHoverFlags = (\n annotationRef: AnnotationRef,\n ): { enter: boolean; exit: boolean } | null => {\n const loaded = annotationHost?.get(annotationRef);\n if (loaded?.subtype !== 'widget') return null;\n return {\n enter: Boolean(loaded.actions?.cursorEnter?.root),\n exit: Boolean(loaded.actions?.cursorExit?.root),\n };\n };\n\n const nudgeAnnotations = (pons: Iterable<number>): void => {\n if (!annotationHost) return;\n for (const pon of new Set(pons)) void annotationHost.reloadPage(pon);\n };\n\n /** Content-space box → PDF rect (inverse of `toBox`). */\n const toPdfRect = (\n box: { x: number; y: number; width: number; height: number },\n crop: PdfRect,\n ): PdfRect => ({\n left: box.x + crop.left,\n top: crop.top - box.y,\n right: box.x + crop.left + box.width,\n bottom: crop.top - box.y - box.height,\n });\n\n /** The page's content box (`{0,0,w,h}`), for page-bound placement math. */\n const pageBox = (pon: number): Box | null => {\n const crop = ctx.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n return crop\n ? { x: 0, y: 0, width: crop.right - crop.left, height: crop.top - crop.bottom }\n : null;\n };\n\n /** Deterministic, collision-free auto-name: `text_1`, `text_2`, … counted\n * against the CURRENT snapshot (rename in the field panel). */\n const autoName = (family: string): string => {\n const names = new Set((model().snapshot?.fields ?? []).map((f) => f.name));\n let n = 1;\n while (names.has(`${family}_${n}`)) n++;\n return `${family}_${n}`;\n };\n\n const placeFieldNow = async (input: PlaceFieldInput): Promise<PlacedField> => {\n const doc = ctx.doc;\n const pon = input.pageObjectNumber;\n const crop = ctx.document()?.pages.find((p) => p.pageObjectNumber === pon)?.boxes.crop;\n if (!doc || !crop) throw new Error('[form] placeField: document/page not ready');\n // Placement is page-bound: intersect a (possibly overshooting) drag box\n // with the page. Sizing policy is the CALLER's job (the place handler's\n // click policy / drag rect) — a degenerate result is a caller bug.\n const page = pageBox(pon)!;\n const x = Math.max(page.x, Math.min(input.box.x, page.width));\n const y = Math.max(page.y, Math.min(input.box.y, page.height));\n const box: Box = {\n x,\n y,\n width: Math.max(0, Math.min(input.box.x + input.box.width, page.width) - x),\n height: Math.max(0, Math.min(input.box.y + input.box.height, page.height) - y),\n };\n if (box.width < 1 || box.height < 1) {\n throw new Error('[form] placeField: degenerate box (size the box before placing)');\n }\n const { family, appearance } = input;\n const name = autoName(family);\n const placement = {\n pageObjectNumber: pon,\n rect: toPdfRect(box, crop),\n ...(appearance ? { appearance } : {}),\n };\n const draft: FormFieldDraft =\n family === 'radio'\n ? { family, name, widgets: [{ ...placement, onState: 'option1' }] }\n : family === 'combobox' || family === 'listbox'\n ? {\n family,\n name,\n widget: placement,\n options: [\n { label: 'Option 1', value: 'Option 1' },\n { label: 'Option 2', value: 'Option 2' },\n ],\n }\n : { family, name, widget: placement };\n const result = await doc.forms.createField(draft);\n await refresh(true);\n apply({ t: 'clearGeom', pageObjectNumber: pon });\n // AWAIT the annotation-plane reload so the returned widget ref is already\n // selectable — the caller's auto-select needs the model to know it.\n if (annotationHost) await annotationHost.reloadPage(pon);\n const widget = result.field.widgets.find((w) => w.pageObjectNumber === pon) ?? null;\n return { field: result.field, widget };\n };\n\n const updateFieldNow = async (key: FieldKey, patch: FormFieldPatch): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n await doc.forms.updateField(refKeyOf(key), patch);\n await refresh(true);\n };\n\n const deleteFieldNow = async (key: FieldKey): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n const field = fieldByKey(model(), key);\n const pons = field?.widgets.map((w) => w.pageObjectNumber).filter((p) => p > 0) ?? [];\n await doc.forms.deleteField(refKeyOf(key));\n await refresh(true);\n for (const pon of new Set(pons)) apply({ t: 'clearGeom', pageObjectNumber: pon });\n nudgeAnnotations(pons);\n };\n\n const detachWidgetNow = async (key: FieldKey, annotObjectNumber: number): Promise<void> => {\n const doc = ctx.doc;\n if (!doc) return;\n const field = fieldByKey(model(), key);\n const widget = field?.widgets.find((w) => w.annotObjectNumber === annotObjectNumber);\n await doc.forms.detachWidget(refKeyOf(key), {\n annotObjectNumber,\n pageObjectNumber: widget?.pageObjectNumber ?? 0,\n });\n await refresh(true);\n if (widget && widget.pageObjectNumber > 0) {\n apply({ t: 'clearGeom', pageObjectNumber: widget.pageObjectNumber });\n nudgeAnnotations([widget.pageObjectNumber]);\n }\n };\n\n void refresh();\n\n return {\n snapshot: () => model().snapshot,\n refresh,\n fillItems,\n fillItem,\n ensureGeom,\n field: (key) => fieldByKey(model(), key),\n fieldForWidget: (annotObjectNumber) => coreFieldForWidget(model(), annotObjectNumber),\n setText: (key, value) => write(key, { type: 'text', value }),\n toggle: (key, onState) => write(key, { type: 'toggle', state: onState }),\n choose: (key, values) => write(key, { type: 'choice', values }),\n reset: (key) => {\n // Reset writes a value (the default) — same optimistic gate as write().\n if (!can('doc.forms.fill'))\n return Promise.reject(new PermissionDenied('doc.forms.fill', 'form.reset'));\n return enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) return;\n apply({ t: 'writeStart', key });\n try {\n if (doc.forms.applyEffects) {\n // The reset() SYMMETRY fix: this door now rides the SAME core a\n // /ResetForm action does — one reset effect, then V/C/F\n // recalculation — so a dependent /C total can never go stale\n // through the public API while staying fresh through the action.\n const result = await applyResetBatch([refKeyOf(key)], 'user');\n if (result.status === 'failed') {\n throw new Error(\n result.effectsResult?.results.find(\n (entry) => entry.status === 'failed' || entry.status === 'rejected',\n )?.error?.message ?? 'reset failed',\n );\n }\n const field = fieldByKey(model(), key);\n if (field) apply({ t: 'writeDone', key, field });\n else apply({ t: 'writeFailed', key });\n } else {\n // Batch-less engines keep the direct single-field door.\n const result = await doc.forms.reset(refKeyOf(key));\n apply({ t: 'writeDone', key, field: result.field });\n }\n } catch (err) {\n apply({ t: 'writeFailed', key });\n throw err;\n }\n });\n },\n commitValue: (ref, value) => enqueueMutation(() => commitValueNow(ref, value)),\n activateWidget: async (key, annotationRef): Promise<WidgetActivationResult> => {\n // Delegated path: the ACTIONS queue is the serializer — entering the\n // form queue here would deadlock the executors it calls back into\n // (queue-direction law: actions → form, never form → actions → form).\n // No scripting gate on purpose: Hide/ResetForm buttons must work with\n // JS off — per-type policy lives in the dispatcher now. Submission is\n // SYNCHRONOUS (no pre-resolution await): a mouseUp notified just\n // before this takes the earlier queue slot, always.\n const actions = ctx.tryGet(ActionsToken);\n if (actions) {\n const result = await actions.dispatch({\n scope: 'activate',\n ref: annotationRef,\n pon: annotationRef.pageObjectNumber,\n source: widgetSource(key, annotationRef),\n });\n // inert + zero steps + zero diagnostics = no /A tree at all — only\n // then does the legacy form path apply (byte-for-byte no-actions\n // behavior); anything else IS the dispatch outcome, refusals included.\n const noTree =\n result.status === 'inert' && result.steps.length === 0 && result.diagnostics.length === 0;\n if (!noTree) return { kind: 'dispatched', result };\n }\n return {\n kind: 'form',\n result: await enqueueMutation(() => activateWidgetNow(key, annotationRef)),\n };\n },\n notifyWidgetEvent: (key, annotationRef, event) => {\n const actions = ctx.tryGet(ActionsToken);\n if (!actions) return;\n const source = widgetSource(key, annotationRef);\n if (event === 'cursorEnter' || event === 'cursorExit') {\n if (event === 'cursorExit') {\n widgetHoverPump(actions).hover(null);\n return;\n }\n // Tree-presence pre-check through the folded annotation model when\n // available — tree-less hover costs zero dispatches. Without the\n // annotation plugin the flags stay unknown and the dispatcher\n // resolves authoritatively in-queue.\n const flags = widgetHoverFlags(annotationRef);\n if (flags && !flags.enter && !flags.exit) return;\n widgetHoverPump(actions).hover({\n ref: annotationRef,\n pon: annotationRef.pageObjectNumber,\n source,\n ...(flags ? { events: flags } : {}),\n });\n return;\n }\n // D/U/Fo/Bl: direct fire-and-forget — dispatch never rejects, the\n // queue orders, results surface via the actions events. /A-shadowing\n // of U (ISO Table 197) is enforced centrally by the dispatcher.\n void actions.dispatch({\n scope: 'annotation',\n event,\n ref: annotationRef,\n pon: annotationRef.pageObjectNumber,\n source,\n });\n },\n // Host lens (the actions plugin's executors/sinks) — FormHostCapability.\n resetFormAction,\n resolveSubmitDataset,\n commitScriptFormEffects: async (effects) => {\n const doc = ctx.doc;\n if (!doc?.forms.applyEffects) {\n // Sink contract: never throw — shape an all-failed batch honestly.\n return {\n results: effects.map((_, index) => ({\n index,\n status: 'failed' as const,\n fields: [],\n changedWidgets: [],\n error: { code: 'NotSupported', message: 'no form-effects batch door' } as never,\n })),\n changedWidgets: [],\n meta: null,\n };\n }\n let result: FormEffectsResult;\n try {\n result = await doc.forms.applyEffects(effects);\n } catch (error) {\n // Sink contract: never throw. An authority pre-check rejection\n // (PermissionDenied) becomes an all-failed batch, honestly.\n const message = error instanceof Error ? error.message : String(error);\n return {\n results: effects.map((_, index) => ({\n index,\n status: 'failed' as const,\n fields: [],\n changedWidgets: [],\n error: { code: 'Refused', message } as never,\n })),\n changedWidgets: [],\n meta: null,\n };\n }\n // Reconcile OUR model — the owner folds its own writes (the effects\n // listener deliberately ignores local events) — and the ANNOTATION\n // plane's view of any changed widgets (setDisplay flips widget /F\n // bits, and widget pixels live on that plane).\n await refresh(true);\n if (annotationHost) {\n const pons = new Set(\n result.changedWidgets.map((widget) => widget.pageObjectNumber).filter((pon) => pon > 0),\n );\n for (const pon of pons) await annotationHost.reloadPage(pon);\n }\n return result;\n },\n setValue: (ref, value) =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const result = await doc.forms.setValue(ref, value);\n await refresh(true);\n return result;\n }),\n exportData: async (format: FormDataFormat = 'xfdf') => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n return doc.forms.exportData(format);\n },\n importData: (data, format) =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const result = await doc.forms.importData(data, format);\n apply({ t: 'snapshot', snapshot: result.snapshot });\n return result;\n }),\n repair: (repairOptions) =>\n enqueueMutation(async () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('no document');\n const result = await doc.forms.repair(repairOptions);\n await refresh(true);\n return result;\n }),\n placeField: (input) => enqueueMutation(() => placeFieldNow(input)),\n pageBox,\n updateField: (key, patch) => enqueueMutation(() => updateFieldNow(key, patch)),\n deleteField: (key) => enqueueMutation(() => deleteFieldNow(key)),\n detachWidget: (key, annotObjectNumber) =>\n enqueueMutation(() => detachWidgetNow(key, annotObjectNumber)),\n // The twins (permissions.md). `canRead` mirrors the hydration gate above\n // — false means the model stays empty by RIGHT, not by loading. Fill and\n // design are independent grants: a filler is not a designer.\n canRead: () => can('doc.forms.read'),\n canFill: () => can('doc.forms.fill'),\n canDesign: () => can('doc.forms.modify'),\n };\n}\n","/**\n * Makes the form REACTIVE beyond this session's own writes — the same\n * pattern the metadata and annotation plugins use.\n *\n * Own value writes flow through the capability (writeDone patches one\n * field). This effect folds in everything else: remote collaborators'\n * `form.*` events (SSE on cloud), and structural events that can move or\n * add widgets (field created/deleted, repair) — those also invalidate the\n * cached widget geometry, because the widget PLANE changed.\n */\nimport type { DocumentEvent, EffectContext } from '@embedpdf/core';\n\nimport { update } from './core/model';\nimport type { FormAction, FormState } from './types';\n\nconst STRUCTURAL = new Set<DocumentEvent['type']>([\n 'form.fieldCreated',\n 'form.fieldUpdated',\n 'form.fieldDeleted',\n 'form.widgetAttached',\n 'form.widgetDetached',\n 'form.repaired',\n]);\n\nexport function registerFormEffects(ctx: EffectContext<FormState, FormAction>): void {\n const doc = ctx.doc;\n if (!doc) return;\n\n let refreshing = false;\n const refresh = async (): Promise<void> => {\n if (refreshing) return;\n refreshing = true;\n try {\n const snapshot = await doc.forms.list();\n ctx.dispatch({\n type: 'SET_MODEL',\n model: update(ctx.getState().model, { t: 'snapshot', snapshot }),\n });\n } finally {\n refreshing = false;\n }\n };\n\n const unsubscribe = doc.events.subscribe((event) => {\n // The live stream fell too far behind to replay: the gap's form events\n // will never arrive, so the snapshot in the model may be stale. This\n // plugin reconciles by REFETCH (not incremental merge), so the desync\n // notice is the only extra signal it needs — re-read the whole (cheap)\n // snapshot.\n if (event.type === 'stream.desynced') {\n void refresh();\n return;\n }\n if (!event.type.startsWith('form.') || !('origin' in event)) return;\n const structural = STRUCTURAL.has(event.type);\n // Own non-structural writes already landed via the capability.\n if (event.origin.kind !== 'remote' && !structural) return;\n if (structural) {\n ctx.dispatch({\n type: 'SET_MODEL',\n model: update(ctx.getState().model, { t: 'clearGeom' }),\n });\n }\n void refresh();\n });\n ctx.cleanup(unsubscribe);\n}\n","/**\n * THE form-tool table — the single source of truth for the palette. Every\n * derivation reads this one list: interaction registration (annotation-less),\n * annotation tool/style registration (full viewer), active-tool → field\n * family lookup, click placement, and default appearance.\n *\n * \"One tool system, two commit planes\": the tools live in the ANNOTATION\n * registry when that plugin is present (defaults, style panel, click-create —\n * the shared authoring infrastructure), but the COMMIT always goes\n * through `doc.forms.createField` via the form place handler. The tags make\n * that structural: these tools enable `form-place`, never `annotation-draw`,\n * so the annotation draw handler can't wake up for them.\n */\nimport type { FormFieldFamily } from '@embedpdf/engine-core/runtime';\nimport type { AnnotationPropsPatch, ClickCreate } from '@embedpdf/plugin-annotation/contract';\n\n/** The families the palette can author (no pushbutton/signature tools). */\nexport type AuthorableFormFamily = Exclude<FormFieldFamily, 'pushbutton' | 'signature' | 'unknown'>;\n\nexport interface FormToolDef {\n id: string;\n /** The field family `placeField` commits (the FORM plane's vocabulary). */\n family: AuthorableFormFamily;\n /** The client kind the ANNOTATION registry routes on (props panel).\n * Not a PDF subtype — every widget is PDF `widget`; this is the view. */\n visualKind: 'widget-text' | 'widget-choice' | 'widget-toggle';\n /** What a bare click places (box policies only — fields are boxes). */\n clickCreate: Extract<ClickCreate, { width: number }>;\n /** Seed drawing defaults: a placed field is VISIBLE (white box, gray\n * border) and restylable per tool through the shared style panel. */\n defaults: AnnotationPropsPatch;\n cursor: string;\n}\n\n/** Palette tools keep widgets editable right after placement. */\nexport const PLACE_TAGS = ['form-place', 'annotation-edit'] as const;\n\nconst FIELD_CHROME: AnnotationPropsPatch = {\n interiorColor: '#ffffff',\n color: '#6b7280',\n strokeWidth: 1,\n};\n\nexport const FORM_TOOLS: readonly FormToolDef[] = [\n {\n id: 'form-text',\n family: 'text',\n visualKind: 'widget-text',\n clickCreate: { width: 160, height: 24 },\n defaults: { ...FIELD_CHROME, fontSize: 12 },\n cursor: 'crosshair',\n },\n {\n id: 'form-checkbox',\n family: 'checkbox',\n visualKind: 'widget-toggle',\n clickCreate: { width: 18, height: 18 },\n defaults: FIELD_CHROME,\n cursor: 'crosshair',\n },\n {\n id: 'form-radio',\n family: 'radio',\n visualKind: 'widget-toggle',\n clickCreate: { width: 18, height: 18 },\n defaults: FIELD_CHROME,\n cursor: 'crosshair',\n },\n {\n id: 'form-combobox',\n family: 'combobox',\n visualKind: 'widget-choice',\n clickCreate: { width: 140, height: 24 },\n defaults: { ...FIELD_CHROME, fontSize: 12 },\n cursor: 'crosshair',\n },\n {\n id: 'form-listbox',\n family: 'listbox',\n visualKind: 'widget-choice',\n clickCreate: { width: 140, height: 72 },\n defaults: { ...FIELD_CHROME, fontSize: 12 },\n cursor: 'crosshair',\n },\n];\n\nexport const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef> = new Map(\n FORM_TOOLS.map((t) => [t.id, t]),\n);\n","import {\n MIN_DRAG,\n resolveClickPlacement,\n widgetAppearanceFromProps,\n} from '@embedpdf/plugin-annotation/authoring';\nimport type { AnnotationHostCapability } from '@embedpdf/plugin-annotation/contract/host';\nimport {\n samplePointOn,\n type InteractionCapability,\n type InteractionHandler,\n} from '@embedpdf/plugin-interaction/contract';\n\nimport type { Box } from './core/model';\nimport { FORM_TOOL_BY_ID } from './tools';\nimport type { FormCapability } from './types';\n\ntype Vec = { x: number; y: number };\n\nconst rectFrom = (a: Vec, b: Vec): Box => ({\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n width: Math.abs(b.x - a.x),\n height: Math.abs(b.y - a.y),\n});\n\n/**\n * Draw-to-place: drag a box (live placement preview through the annotation\n * plane's ghost pipeline) or just click (the tool's `clickCreate` policy,\n * resolved by the SAME `resolveClickPlacement` the annotation core uses) —\n * the commit creates field + widget through `doc.forms.placeField`, styled\n * from the tool's live defaults. The tool stays active for repeat placement\n * (v2 rubber-stamp feel) and the fresh widget is auto-selected.\n *\n * Gesture rules match the annotation handlers: page-anchored via the sample\n * projection (the box keeps sizing along the edge when the cursor overshoots\n * or crosses a gap), the UP sample is the final point, and a CLICK means\n * width AND height under the shared threshold — a thin 100×2 drag is a drag.\n */\nexport function createPlaceHandler(\n form: FormCapability,\n interaction: InteractionCapability,\n annotation: AnnotationHostCapability | null,\n): InteractionHandler {\n let origin: { pon: number; start: Vec; last: Vec } | null = null;\n return {\n id: 'form-place',\n // Above the annotation edit handler (100): while a palette tool is\n // active, a drag on empty page means \"place a field\", not \"marquee\".\n priority: 95,\n enabledFor: (t) => t.enables.has('form-place'),\n onDown: (s) => {\n // No capture without a page, a known palette tool, or write permission —\n // declining lets edit/pan/text-selection act on the gesture instead.\n if (!s.page || !FORM_TOOL_BY_ID.has(interaction.activeToolId())) return false;\n if (!form.canDesign()) return false;\n origin = { pon: s.page.pon, start: s.page.point, last: s.page.point };\n return true;\n },\n onMove: (s) => {\n if (!origin) return;\n const point = samplePointOn(s, origin.pon);\n if (!point) return;\n origin.last = point;\n const box = rectFrom(origin.start, point);\n // Live preview once the gesture reads as a drag — the WYSIWYG white box\n // (tool defaults) through the annotation ghost pipeline. Never dispatch\n // into the annotation store directly; this is its typed seam.\n if (annotation) {\n if (Math.max(box.width, box.height) >= MIN_DRAG) {\n annotation.setPlacementPreview(interaction.activeToolId(), origin.pon, box);\n } else {\n annotation.clearPlacementPreview();\n }\n }\n },\n onUp: (s) => {\n if (!origin) return;\n const o = origin;\n origin = null;\n annotation?.clearPlacementPreview();\n const toolId = interaction.activeToolId();\n const tool = FORM_TOOL_BY_ID.get(toolId);\n if (!tool) return;\n // The UP sample is the final point (projection first, like every\n // page-anchored gesture); a release over the gap falls back to the\n // last resolved point.\n const end = samplePointOn(s, o.pon) ?? o.last;\n const dragged = rectFrom(o.start, end);\n const isClick = dragged.width < MIN_DRAG && dragged.height < MIN_DRAG;\n const pageBox = form.pageBox(o.pon);\n const box = isClick ? boxOfClick(o.start, tool.clickCreate, pageBox) : dragged; // placeField clamps a drag to the page\n form\n .placeField({\n family: tool.family,\n pageObjectNumber: o.pon,\n box,\n // Style from the tool's LIVE defaults when the annotation plane is\n // here to hold them (the user restyled the tool in the panel);\n // annotation-less placement uses the table's static seed — a field\n // is never invisible. One conversion, the exported boundary util.\n appearance: widgetAppearanceFromProps(\n annotation ? annotation.currentDefaults(toolId) : tool.defaults,\n ),\n })\n .then((placed) => {\n // Auto-select the fresh widget — placeField resolves AFTER the\n // annotation page reload, so the ref is selectable. Skip when the\n // world moved on (tool changed) while the engine write ran.\n if (!annotation || interaction.activeToolId() !== toolId) return;\n const widget = placed.widget;\n if (!widget || widget.annotObjectNumber <= 0) return;\n annotation.select({\n kind: 'objectNumber',\n annotObjectNumber: widget.annotObjectNumber,\n pageObjectNumber: o.pon,\n });\n })\n .catch((err) => {\n globalThis.console?.error('[form] placeField failed:', err);\n });\n },\n };\n}\n\n/** The click-create box through the SHARED placement layer (fields are boxes;\n * the policy anchor + page clamp are exactly the annotation click's). */\nfunction boxOfClick(\n point: Vec,\n policy: { width: number; height: number; anchor?: 'center' | 'top-left' },\n pageBox: Box | null,\n): Box {\n const placement = resolveClickPlacement(point, policy, { pageBox: pageBox ?? undefined });\n return placement.kind === 'box'\n ? placement.rect\n : { x: point.x, y: point.y, width: policy.width, height: policy.height };\n}\n","import { initialModel } from './core/model';\nimport type { FormAction, FormState } from './types';\n\nexport const initialFormState = (): FormState => ({ model: initialModel() });\n\n/** Dumb store: the pure core computes the next model; the shell dispatches it. */\nexport const formReducer = (state: FormState, action: FormAction): FormState =>\n action.type === 'SET_MODEL' ? { model: action.model } : state;\n","import { definePlugin } from '@embedpdf/core';\nimport { ActionsToken } from '@embedpdf/plugin-actions/contract';\n// Executor registration lives on the actions HOST capability — same runtime\n// token, wider type (the annotation-internal precedent).\nimport { ActionsToken as ActionsHostToken } from '@embedpdf/plugin-actions/contract/host';\nimport { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\n// Behavior registration lives on the HOST capability (framework/plugin\n// surface) — same runtime token, wider type.\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/contract/host';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract';\n\nimport { createFormCapability } from './capability';\nimport { registerFormEffects } from './effects';\nimport { createPlaceHandler } from './handler';\nimport { formReducer, initialFormState } from './reducer';\nimport { FORM_TOOLS, PLACE_TAGS } from './tools';\nimport { FormToken } from './types';\nimport type { FormAction, FormHostCapability, FormPluginOptions, FormState } from './types';\n\n/**\n * The form plugin: the FIELD plane. Document-scoped; requires the\n * interaction hub. Fill mode works with no annotation plugin at all —\n * geometry is read from the engine's widget DTOs. When the annotation\n * plugin IS present, a Behavior keeps widgets geometry-inert while the\n * active tool carries 'form-fill' (the built-in pointer/pan tools do, so\n * filling is the resting state) and stands the fill controls down under\n * every other tool — the single-active-tool hub IS the mode switch.\n * Design mode = the 'form-edit' / palette tools: no 'form-fill' tag, so\n * widgets become ordinary editable annotations.\n */\nexport const formPlugin = (options: FormPluginOptions = {}) =>\n definePlugin<FormState, FormAction, FormHostCapability>({\n id: 'form',\n token: FormToken,\n scope: 'document',\n requires: [InteractionToken],\n optional: [AnnotationToken, ActionsToken],\n initialState: initialFormState,\n reduce: formReducer,\n capability: (ctx) => createFormCapability(ctx, options),\n effects: registerFormEffects,\n init: (ctx) => {\n const interaction = ctx.get(InteractionToken);\n const form = ctx.get(FormToken);\n // Fill-ONLY mode: forms fillable, no annotation editing at all. The\n // DEFAULT fill experience doesn't need this tool — the built-in\n // pointer/pan tools carry the 'form-fill' tag themselves.\n interaction.registerTool({\n id: 'form-fill',\n cursor: 'default',\n // `link-nav` rides along: links keep navigating while a form is being\n // filled (Acrobat behaviour) — inert without the link plugin.\n enables: new Set(['form-fill', 'link-nav']),\n });\n // Design mode's resting state (the Form tab): no 'form-fill', so the\n // widget Behavior disengages and widgets select/move/resize like any\n // annotation. Palette tools layer drag-to-place on top of this.\n interaction.registerTool({\n id: 'form-edit',\n cursor: 'default',\n enables: new Set(['annotation-edit', 'annotation-marquee']),\n });\n // Field palette: ONE tool table, two registration paths. With the\n // annotation plugin, palette tools join ITS registry — they gain live\n // defaults, the schema style panel (`propsForTool`), click-create — all\n // the shared authoring infrastructure. Without it,\n // the same table registers plain hub tools: drag/click placement and\n // programmatic authoring still work (`placeField` is a pure `doc.forms`\n // call); only INTERACTIVE styling/moving needs the annotation plane.\n // Either way the commit goes through the form place handler — these\n // tools enable 'form-place', never 'annotation-draw', so the two commit\n // planes can't cross structurally.\n const annotation = ctx.tryGet(AnnotationHostToken);\n for (const t of FORM_TOOLS) {\n if (annotation) {\n annotation.registerTool({\n id: t.id,\n subtype: t.visualKind,\n cursor: t.cursor,\n enables: [...PLACE_TAGS],\n clickCreate: t.clickCreate,\n defaults: t.defaults,\n });\n } else {\n interaction.registerTool({\n id: t.id,\n cursor: t.cursor,\n enables: new Set(PLACE_TAGS),\n });\n }\n }\n interaction.registerHandler(createPlaceHandler(form, interaction, annotation));\n\n if (annotation) {\n annotation.registerBehavior({\n id: 'form-widgets',\n matches: (a) => a.subtype.startsWith('widget'),\n engaged: () => interaction.activeTool()?.enables.has('form-fill') ?? false,\n });\n }\n\n // ── interim Phase-1 action executors ────────────────────────────────\n // The registry is the phasing seam: Phase 3's shared ScriptHost swaps\n // in by re-registering 'javascript' (last-wins). Lazy self-resolution\n // on purpose — executors run post-bringup against the kernel's\n // memoized capability, so the closure-held scripting controller exists\n // exactly when needed.\n const actions = ctx.tryGet(ActionsHostToken);\n if (actions) {\n // The real `javascript` executor is the actions plugin's own (Phase 3\n // ScriptHost); form contributes its DOCUMENT-commit sink so script\n // form effects land through the owner (engine write + model\n // reconciliation in one place — the stale-model class is structural).\n ctx.cleanup(\n actions.registerFormCommitSink((effects) => {\n const formHost = ctx.tryGet(FormToken);\n if (!formHost) {\n return Promise.resolve({\n results: effects.map((_, index) => ({\n index,\n status: 'failed' as const,\n fields: [],\n changedWidgets: [],\n })),\n changedWidgets: [],\n meta: null,\n });\n }\n return formHost.commitScriptFormEffects(effects);\n }),\n );\n ctx.cleanup(\n actions.registerSubmitResolver((intent, actionCtx, diagnose) => {\n const formHost = ctx.tryGet(FormToken);\n if (!formHost) throw new Error('form plugin unavailable');\n return formHost.resolveSubmitDataset(intent, actionCtx, diagnose);\n }),\n );\n ctx.cleanup(\n // The executor THREADS its ActionContext (the origin-laundering\n // fix): a lifecycle ResetForm's recalculation surfaces as\n // lifecycle, never as a user gesture.\n actions.registerExecutor('reset-form', async (node, actionCtx) => {\n if (node.type !== 'reset-form') {\n return { status: 'inert', reason: 'not a reset-form node' };\n }\n const formHost = ctx.tryGet(FormToken);\n if (!formHost) return { status: 'inert', reason: 'form plugin unavailable' };\n const result = await formHost.resetFormAction(\n node.fields,\n node.exclude,\n actionCtx.origin,\n );\n if (result.status === 'failed') {\n return { status: 'failed', error: result.error?.message ?? 'reset failed' };\n }\n if (result.effectsResult === null) {\n return {\n status: 'inert',\n reason: result.diagnostics[0]?.message ?? 'reset-form resolved no fields',\n };\n }\n return { status: 'executed' };\n }),\n );\n }\n },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,yBACX,KACA,SACA,YACqD;CACrD,IAAI,YAAY,MAAM,OAAO;EAAE,UAAU,CAAC,GAAG,GAAG;EAAG,cAAc;CAAM;CACvE,MAAM,QAAQ,QAAQ,QAAQ,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,IAAI;CACxE,MAAM,gBAAgB,IAAI,IACxB,QAAQ,QAAQ,MAAM,EAAE,SAAS,cAAc,CAAC,CAAC,KAAK,MAAM,EAAE,YAAY,CAC5E;CACA,MAAM,UAAU,UACb,MAAM,IAAI,SAAS,kBAAkB,cAAc,IAAI,MAAM,IAAI,iBAAiB,KACnF,MAAM,MAAM,SAAS,MAAM,SAAS,QAAQ,MAAM,KAAK,WAAW,GAAG,KAAK,EAAE,CAAC;CAE/E,OAAO;EAAE,UADQ,UAAU,IAAI,QAAQ,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,MAAM;EACzD;CAAO;AAC5B;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,sBACX,QACA,QACA,aAC0B;CAC1B,MAAM,EAAE,UAAU,WAAW,sBA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AW,IAAI,OAAOA,cAAAA,SAAS;IACrC,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,yBAAyB;IACxD,OAAO,SAAS,qBAAqB,QAAQ,WAAW,QAAQ;GAClE,CAAC,CACH;GACA,IAAI,QAIF,QAAQ,iBAAiB,cAAc,OAAO,MAAM,cAAc;IAChE,IAAI,KAAK,SAAS,cAChB,OAAO;KAAE,QAAQ;KAAS,QAAQ;IAAwB;IAE5D,MAAM,WAAW,IAAI,OAAOA,cAAAA,SAAS;IACrC,IAAI,CAAC,UAAU,OAAO;KAAE,QAAQ;KAAS,QAAQ;IAA0B;IAC3E,MAAM,SAAS,MAAM,SAAS,gBAC5B,KAAK,QACL,KAAK,SACL,UAAU,MACZ;IACA,IAAI,OAAO,WAAW,UACpB,OAAO;KAAE,QAAQ;KAAU,OAAO,OAAO,OAAO,WAAW;IAAe;IAE5E,IAAI,OAAO,kBAAkB,MAC3B,OAAO;KACL,QAAQ;KACR,QAAQ,OAAO,YAAY,EAAE,EAAE,WAAW;IAC5C;IAEF,OAAO,EAAE,QAAQ,WAAW;GAC9B,CAAC,CACH;EACF;CACF;AACF,CAAC"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { a as FormHostCapability, d as PlacedField, f as WidgetActivationResult, g as fieldKeyOf, h as FieldKey, i as FormCommitStatus, l as FormUiEffect, m as Box, n as FormCapability, o as FormPluginOptions, p as FillItem, r as FormCommitResult, s as FormState, t as FormAction, u as PlaceFieldInput } from "./types-CnUW7z1W.cjs";
2
2
  import { FormFieldDTO, FormFieldPatch, FormToken, WidgetAppearance } from "./contract.cjs";
3
3
  import { FormScriptingController, createFormScriptingController } from "./scripting.cjs";
4
4
  import { createSerialQueue } from "@embedpdf/core";
@@ -44,5 +44,5 @@ interface FormToolDef {
44
44
  declare const FORM_TOOLS: readonly FormToolDef[];
45
45
  declare const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef>;
46
46
  //#endregion
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 };
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 FormState, FormToken, type FormToolDef, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance, createFormScriptingController, createSerialMutationQueue, fieldKeyOf, formPlugin };
48
48
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { a as FormHostCapability, d as PlacedField, f as WidgetActivationResult, g as fieldKeyOf, h as FieldKey, i as FormCommitStatus, l as FormUiEffect, m as Box, n as FormCapability, o as FormPluginOptions, p as FillItem, r as FormCommitResult, s as FormState, t as FormAction, u as PlaceFieldInput } from "./types-NGRZjJNj.js";
2
2
  import { FormFieldDTO, FormFieldPatch, FormToken, WidgetAppearance } from "./contract.js";
3
3
  import { FormScriptingController, createFormScriptingController } from "./scripting.js";
4
4
  import { createSerialQueue } from "@embedpdf/core";
@@ -44,5 +44,5 @@ interface FormToolDef {
44
44
  declare const FORM_TOOLS: readonly FormToolDef[];
45
45
  declare const FORM_TOOL_BY_ID: ReadonlyMap<string, FormToolDef>;
46
46
  //#endregion
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 };
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 FormState, FormToken, type FormToolDef, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance, createFormScriptingController, createSerialMutationQueue, fieldKeyOf, formPlugin };
48
48
  //# sourceMappingURL=index.d.ts.map