@embedpdf/core-acrojs 3.0.0-next.14 → 3.0.0-next.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,11 +2,12 @@ import { AnnotationRef, DocumentHandle, FormEffect, FormFieldDisplay, FormFieldF
2
2
  //#region src/actions.d.ts
3
3
  /**
4
4
  * Return executable JavaScript in PDF action order (root, then `/Next`
5
- * depth-first). A poisoned native snapshot is never partially executed.
5
+ * depth-first). A poisoned native snapshot is never partially executed. Any
6
+ * kind of destination will do: only the scripts are read.
6
7
  */
7
- declare function javaScriptSourcesFromActionTree(tree: PdfActionTree): string[];
8
+ declare function javaScriptSourcesFromActionTree<Destination>(tree: PdfActionTree<Destination>): string[];
8
9
  /** One event source that preserves the tree's shared field overlay. */
9
- declare function javaScriptProgramFromActionTree(tree: PdfActionTree): string;
10
+ declare function javaScriptProgramFromActionTree<Destination>(tree: PdfActionTree<Destination>): string;
10
11
  //#endregion
11
12
  //#region src/types.d.ts
12
13
  /** JSON-safe value vocabulary exposed through Acrobat's `event` and `Field`. */
@@ -26,6 +27,8 @@ interface ScriptFieldInput {
26
27
  readOnly: boolean;
27
28
  required: boolean;
28
29
  options?: ScriptFieldOption[];
30
+ /** A checkbox's or radio group's widget export values, in widget order (Acrobat `exportValues`). */
31
+ exportValues?: string[];
29
32
  }
30
33
  interface ScriptIdentity {
31
34
  /** Acrobat `identity.name`. Empty when the embedder did not configure it. */
@@ -53,7 +56,7 @@ interface ScriptEventInput {
53
56
  /**
54
57
  * Explicit Acrobat `event.type` / `event.name` overrides for action-driven
55
58
  * runs (built from the dispatcher's trigger provenance — `Field` × `Mouse
56
- * Enter`, `Page` × `Open`, …; the `Annot` type is an EmbedPDF EXTENSION,
59
+ * Enter`, `Page` × `Open`, …; the `Annot` type is an EmbedPDF extension,
57
60
  * Acrobat has no event type for plain-annotation events). When omitted the
58
61
  * prelude derives them from `kind` (the K/V/C/F pipeline path).
59
62
  */
@@ -77,7 +80,7 @@ interface ScriptEventInput {
77
80
  type ScriptColorArray = ['T'] | ['G', number] | ['RGB', number, number, number] | ['CMYK', number, number, number, number];
78
81
  /**
79
82
  * One script-addressable annotation in the prefetched world — every subtype
80
- * EXCEPT link and widget (Acrobat serves those through `Link`/`Field`
83
+ * except link and widget (Acrobat serves those through `Link`/`Field`
81
84
  * objects; here they are separate event planes). Curated read surface only —
82
85
  * never a raw dictionary.
83
86
  */
@@ -113,10 +116,10 @@ interface ScriptAnnotInput {
113
116
  * (stamps, images): appearance writes are refused with a diagnostic. */
114
117
  opaqueBody: boolean;
115
118
  }
116
- /** The curated WRITE patch one script staged for one annotation — a
119
+ /** The curated write patch one script staged for one annotation — a
117
120
  * canonical per-annot diff (last-write-wins per key, derived at run end
118
121
  * exactly like form effects). Visibility keys ride `flags` so the commit
119
- * sink maps them onto ONE engine flags patch. */
122
+ * sink maps them onto one engine flags patch. */
120
123
  interface ScriptAnnotEffect {
121
124
  ref: AnnotationRef;
122
125
  patch: {
@@ -139,10 +142,10 @@ interface ScriptAnnotEffect {
139
142
  };
140
143
  }
141
144
  /**
142
- * The writable-property validity matrix, keyed by engine subtype — the ONE
145
+ * The writable-property validity matrix, keyed by engine subtype — the one
143
146
  * exported table (the prelude inlines an identical copy; a parity test pins
144
147
  * them together, and plugin-annotation drift-guards this against the kind
145
- * registry's PropSpecs). Flags + contents are writable everywhere
148
+ * registry's FieldSpecs). Flags + contents are writable everywhere
146
149
  * script-addressable; appearance keys vary by kind.
147
150
  */
148
151
  declare const ANNOT_WRITABLE_KEYS: Readonly<Record<string, readonly string[]>>;
@@ -152,7 +155,8 @@ interface ScriptInput {
152
155
  identity: ScriptIdentity;
153
156
  environment: ScriptEnvironment;
154
157
  fields: ScriptFieldInput[];
155
- /** The prefetched annots plane (page-scoped — see the D6 deviation). */
158
+ /** The prefetched annots plane. It covers only the pages in `annotPages`;
159
+ * `getAnnots` reports a compatibility deviation for any other page. */
156
160
  annots?: ScriptAnnotInput[];
157
161
  /** Zero-based page indexes the plane covers. */
158
162
  annotPages?: number[];
@@ -171,7 +175,7 @@ type ScriptUiEffect = {
171
175
  kind: 'gotoPage';
172
176
  page: number;
173
177
  } |
174
- /** `doc.submitForm(...)` — a submit INTENT, resolved and sink-routed
178
+ /** `doc.submitForm(...)` — a submit intent, resolved and sink-routed
175
179
  * outside the VM (never a network call from here). `fieldNames` are
176
180
  * include-mode (Acrobat's aFields); `null` = the whole eligible form. */
177
181
  {
@@ -214,9 +218,9 @@ interface ScriptEventOutput {
214
218
  }
215
219
  /**
216
220
  * Effects are committed only by the originating client's orchestrator, in
217
- * the DECLARED cross-plane order: `formEffects` first (field order — matching
221
+ * the declared cross-plane order: `formEffects` first (field order — matching
218
222
  * the derive-by-diff model), then `annotEffects` (annot order); the first
219
- * failing effect marks every later effect in BOTH streams skipped.
223
+ * failing effect marks every later effect in both streams skipped.
220
224
  */
221
225
  interface ScriptOutput {
222
226
  event: ScriptEventOutput;
@@ -237,19 +241,19 @@ declare const DEFAULT_SCRIPT_BUDGET: Readonly<ScriptBudget>;
237
241
  /**
238
242
  * The shipped security posture (updated per phase — the live authority for
239
243
  * per-type × origin decisions is the actions plugin's policy; these
240
- * constants DOCUMENT the posture, they do not enforce it). The only
244
+ * constants document the posture, they do not enforce it). The only
241
245
  * configurable switch is explicit opt-in.
242
246
  */
243
247
  interface ScriptSecurityPolicy {
244
248
  enabled: boolean;
245
249
  executionOwner: 'originating-client-only';
246
250
  nameTreeBoot: 'lazy-first-transaction';
247
- /** Submit is a sink chain — embedder handler → the document's HOME
251
+ /** Submit is a sink chain — embedder handler → the document's home
248
252
  * (`doc.forms.submit`, engine-asserted) → blocked. Never auto-network. */
249
253
  submitForm: 'sink-chain';
250
254
  openAction: 'execute-lifecycle';
251
255
  pageActions: 'execute-lifecycle';
252
- /** WC/WS/DS/WP/DP run when the VERB OWNER dispatches them. */
256
+ /** WC/WS/DS/WP/DP run when the verb owner dispatches them. */
253
257
  catalogLifecycleActions: 'execute-on-verb';
254
258
  annotationActions: 'execute-full-matrix';
255
259
  }
@@ -284,7 +288,7 @@ interface AcroJsVmGlobal {
284
288
  /**
285
289
  * Host-side Acrobat color-array conversions — the commit sinks and world
286
290
  * builders cross the Acrobat-array ↔ renderer-color boundary through these.
287
- * The PRELUDE inlines its own identical formulas (it must stay
291
+ * The prelude inlines its own identical formulas (it must stay
288
292
  * self-contained); `prelude.test.ts` pins the two implementations together.
289
293
  *
290
294
  * Conversion vectors (the documented Acrobat semantics):
@@ -307,7 +311,7 @@ declare function cssToScriptColor(css: string | null | undefined): ScriptColorAr
307
311
  declare function isScriptColorArray(value: unknown): value is ScriptColorArray;
308
312
  //#endregion
309
313
  //#region src/host.d.ts
310
- /** The per-run world a CALLER supplies (fields snapshot, prefetched annots
314
+ /** The per-run world a caller supplies (fields snapshot, prefetched annots
311
315
  * plane, the event). Document/identity/environment come from the host. */
312
316
  interface ScriptWorldInput {
313
317
  fields: ScriptFieldInput[];
@@ -322,14 +326,14 @@ interface ScriptWorldInput {
322
326
  interface ScriptTransaction {
323
327
  /**
324
328
  * Run the name-tree boot if it has not run in this realm yet; returns the
325
- * boot output exactly ONCE (its effects belong to the first transaction —
329
+ * boot output exactly once (its effects belong to the first transaction —
326
330
  * commit them, tag their UI effects `phase: 'boot'`), null thereafter.
327
331
  */
328
332
  boot(world: ScriptWorldInput, budget?: ScriptBudget): Promise<ScriptOutput | null>;
329
333
  /** One deterministic run against the shared realm. Auto-boots defensively
330
334
  * (that boot's output is then returned by the next `boot()` call).
331
335
  * `budget` overrides the host default per run — the form pipeline slices
332
- * ONE transaction-wide time budget across its K/V/C/F passes. */
336
+ * one transaction-wide time budget across its K/V/C/F passes. */
333
337
  run(program: string, world: ScriptWorldInput, budget?: ScriptBudget): Promise<ScriptOutput>;
334
338
  }
335
339
  interface ScriptHostOptions {
@@ -344,12 +348,12 @@ interface ScriptHostOptions {
344
348
  budget?: ScriptBudget;
345
349
  }
346
350
  /**
347
- * The ONE realm per document (umbrella law #5): a name-tree function must be
351
+ * The one realm per document: a name-tree function must be
348
352
  * callable from a page-open script and a field calculate alike.
349
353
  *
350
- * `transaction(body)` is the realm mutex, and the body performs EVERYTHING
354
+ * `transaction(body)` is the realm mutex, and the body performs everything
351
355
  * for one logical script transaction — world prefetch, VM run(s), document
352
- * commits through the owner sinks, model reconciliation — BEFORE the mutex
356
+ * commits through the owner sinks, model reconciliation — before the mutex
353
357
  * releases, so the next transaction always prefetches post-commit truth
354
358
  * (the commit-inside-the-boundary law). Lock hierarchy: caller queues
355
359
  * (actions dispatch / form mutation) acquire this queue, never the reverse,
@@ -368,8 +372,8 @@ interface ScriptHost {
368
372
  * (ported verbatim from the form controller; exported for callers building
369
373
  * `ScriptHostOptions.environment`). */
370
374
  declare function seedFrom(documentId: string, sequence: number): number;
371
- /** Engine JWT/session identity composed under embedder overrides — the
372
- * standard `ScriptHostOptions.identity` builder. */
375
+ /** The session's identity, as Acrobat JavaScript's `identity` object, under
376
+ * embedder overrides — the standard `ScriptHostOptions.identity` builder. */
373
377
  declare function resolveScriptIdentity(doc: DocumentHandle, overrides?: Partial<ScriptIdentity> | (() => Partial<ScriptIdentity>)): ScriptIdentity;
374
378
  declare function createScriptHost(options: ScriptHostOptions): ScriptHost;
375
379
  //#endregion
@@ -385,7 +389,7 @@ declare function scriptFieldsFromSnapshot(snapshot: FormSnapshot): ScriptFieldIn
385
389
  * values. The sandbox ships `installAcroJs.toString()` into QuickJS, while
386
390
  * tests execute the same source in a Node VM. Types disappear at build time.
387
391
  */
388
- declare function installAcroJs(g: Record<string, unknown>): void;
392
+ declare function installAcroJs(globalObject: Record<string, unknown>): void;
389
393
  /** The exact self-contained source evaluated in Node parity tests and QuickJS. */
390
394
  declare const PRELUDE_SOURCE: string;
391
395
  //#endregion
package/dist/index.d.ts CHANGED
@@ -2,11 +2,12 @@ import { AnnotationRef, DocumentHandle, FormEffect, FormFieldDisplay, FormFieldF
2
2
  //#region src/actions.d.ts
3
3
  /**
4
4
  * Return executable JavaScript in PDF action order (root, then `/Next`
5
- * depth-first). A poisoned native snapshot is never partially executed.
5
+ * depth-first). A poisoned native snapshot is never partially executed. Any
6
+ * kind of destination will do: only the scripts are read.
6
7
  */
7
- declare function javaScriptSourcesFromActionTree(tree: PdfActionTree): string[];
8
+ declare function javaScriptSourcesFromActionTree<Destination>(tree: PdfActionTree<Destination>): string[];
8
9
  /** One event source that preserves the tree's shared field overlay. */
9
- declare function javaScriptProgramFromActionTree(tree: PdfActionTree): string;
10
+ declare function javaScriptProgramFromActionTree<Destination>(tree: PdfActionTree<Destination>): string;
10
11
  //#endregion
11
12
  //#region src/types.d.ts
12
13
  /** JSON-safe value vocabulary exposed through Acrobat's `event` and `Field`. */
@@ -26,6 +27,8 @@ interface ScriptFieldInput {
26
27
  readOnly: boolean;
27
28
  required: boolean;
28
29
  options?: ScriptFieldOption[];
30
+ /** A checkbox's or radio group's widget export values, in widget order (Acrobat `exportValues`). */
31
+ exportValues?: string[];
29
32
  }
30
33
  interface ScriptIdentity {
31
34
  /** Acrobat `identity.name`. Empty when the embedder did not configure it. */
@@ -53,7 +56,7 @@ interface ScriptEventInput {
53
56
  /**
54
57
  * Explicit Acrobat `event.type` / `event.name` overrides for action-driven
55
58
  * runs (built from the dispatcher's trigger provenance — `Field` × `Mouse
56
- * Enter`, `Page` × `Open`, …; the `Annot` type is an EmbedPDF EXTENSION,
59
+ * Enter`, `Page` × `Open`, …; the `Annot` type is an EmbedPDF extension,
57
60
  * Acrobat has no event type for plain-annotation events). When omitted the
58
61
  * prelude derives them from `kind` (the K/V/C/F pipeline path).
59
62
  */
@@ -77,7 +80,7 @@ interface ScriptEventInput {
77
80
  type ScriptColorArray = ['T'] | ['G', number] | ['RGB', number, number, number] | ['CMYK', number, number, number, number];
78
81
  /**
79
82
  * One script-addressable annotation in the prefetched world — every subtype
80
- * EXCEPT link and widget (Acrobat serves those through `Link`/`Field`
83
+ * except link and widget (Acrobat serves those through `Link`/`Field`
81
84
  * objects; here they are separate event planes). Curated read surface only —
82
85
  * never a raw dictionary.
83
86
  */
@@ -113,10 +116,10 @@ interface ScriptAnnotInput {
113
116
  * (stamps, images): appearance writes are refused with a diagnostic. */
114
117
  opaqueBody: boolean;
115
118
  }
116
- /** The curated WRITE patch one script staged for one annotation — a
119
+ /** The curated write patch one script staged for one annotation — a
117
120
  * canonical per-annot diff (last-write-wins per key, derived at run end
118
121
  * exactly like form effects). Visibility keys ride `flags` so the commit
119
- * sink maps them onto ONE engine flags patch. */
122
+ * sink maps them onto one engine flags patch. */
120
123
  interface ScriptAnnotEffect {
121
124
  ref: AnnotationRef;
122
125
  patch: {
@@ -139,10 +142,10 @@ interface ScriptAnnotEffect {
139
142
  };
140
143
  }
141
144
  /**
142
- * The writable-property validity matrix, keyed by engine subtype — the ONE
145
+ * The writable-property validity matrix, keyed by engine subtype — the one
143
146
  * exported table (the prelude inlines an identical copy; a parity test pins
144
147
  * them together, and plugin-annotation drift-guards this against the kind
145
- * registry's PropSpecs). Flags + contents are writable everywhere
148
+ * registry's FieldSpecs). Flags + contents are writable everywhere
146
149
  * script-addressable; appearance keys vary by kind.
147
150
  */
148
151
  declare const ANNOT_WRITABLE_KEYS: Readonly<Record<string, readonly string[]>>;
@@ -152,7 +155,8 @@ interface ScriptInput {
152
155
  identity: ScriptIdentity;
153
156
  environment: ScriptEnvironment;
154
157
  fields: ScriptFieldInput[];
155
- /** The prefetched annots plane (page-scoped — see the D6 deviation). */
158
+ /** The prefetched annots plane. It covers only the pages in `annotPages`;
159
+ * `getAnnots` reports a compatibility deviation for any other page. */
156
160
  annots?: ScriptAnnotInput[];
157
161
  /** Zero-based page indexes the plane covers. */
158
162
  annotPages?: number[];
@@ -171,7 +175,7 @@ type ScriptUiEffect = {
171
175
  kind: 'gotoPage';
172
176
  page: number;
173
177
  } |
174
- /** `doc.submitForm(...)` — a submit INTENT, resolved and sink-routed
178
+ /** `doc.submitForm(...)` — a submit intent, resolved and sink-routed
175
179
  * outside the VM (never a network call from here). `fieldNames` are
176
180
  * include-mode (Acrobat's aFields); `null` = the whole eligible form. */
177
181
  {
@@ -214,9 +218,9 @@ interface ScriptEventOutput {
214
218
  }
215
219
  /**
216
220
  * Effects are committed only by the originating client's orchestrator, in
217
- * the DECLARED cross-plane order: `formEffects` first (field order — matching
221
+ * the declared cross-plane order: `formEffects` first (field order — matching
218
222
  * the derive-by-diff model), then `annotEffects` (annot order); the first
219
- * failing effect marks every later effect in BOTH streams skipped.
223
+ * failing effect marks every later effect in both streams skipped.
220
224
  */
221
225
  interface ScriptOutput {
222
226
  event: ScriptEventOutput;
@@ -237,19 +241,19 @@ declare const DEFAULT_SCRIPT_BUDGET: Readonly<ScriptBudget>;
237
241
  /**
238
242
  * The shipped security posture (updated per phase — the live authority for
239
243
  * per-type × origin decisions is the actions plugin's policy; these
240
- * constants DOCUMENT the posture, they do not enforce it). The only
244
+ * constants document the posture, they do not enforce it). The only
241
245
  * configurable switch is explicit opt-in.
242
246
  */
243
247
  interface ScriptSecurityPolicy {
244
248
  enabled: boolean;
245
249
  executionOwner: 'originating-client-only';
246
250
  nameTreeBoot: 'lazy-first-transaction';
247
- /** Submit is a sink chain — embedder handler → the document's HOME
251
+ /** Submit is a sink chain — embedder handler → the document's home
248
252
  * (`doc.forms.submit`, engine-asserted) → blocked. Never auto-network. */
249
253
  submitForm: 'sink-chain';
250
254
  openAction: 'execute-lifecycle';
251
255
  pageActions: 'execute-lifecycle';
252
- /** WC/WS/DS/WP/DP run when the VERB OWNER dispatches them. */
256
+ /** WC/WS/DS/WP/DP run when the verb owner dispatches them. */
253
257
  catalogLifecycleActions: 'execute-on-verb';
254
258
  annotationActions: 'execute-full-matrix';
255
259
  }
@@ -284,7 +288,7 @@ interface AcroJsVmGlobal {
284
288
  /**
285
289
  * Host-side Acrobat color-array conversions — the commit sinks and world
286
290
  * builders cross the Acrobat-array ↔ renderer-color boundary through these.
287
- * The PRELUDE inlines its own identical formulas (it must stay
291
+ * The prelude inlines its own identical formulas (it must stay
288
292
  * self-contained); `prelude.test.ts` pins the two implementations together.
289
293
  *
290
294
  * Conversion vectors (the documented Acrobat semantics):
@@ -307,7 +311,7 @@ declare function cssToScriptColor(css: string | null | undefined): ScriptColorAr
307
311
  declare function isScriptColorArray(value: unknown): value is ScriptColorArray;
308
312
  //#endregion
309
313
  //#region src/host.d.ts
310
- /** The per-run world a CALLER supplies (fields snapshot, prefetched annots
314
+ /** The per-run world a caller supplies (fields snapshot, prefetched annots
311
315
  * plane, the event). Document/identity/environment come from the host. */
312
316
  interface ScriptWorldInput {
313
317
  fields: ScriptFieldInput[];
@@ -322,14 +326,14 @@ interface ScriptWorldInput {
322
326
  interface ScriptTransaction {
323
327
  /**
324
328
  * Run the name-tree boot if it has not run in this realm yet; returns the
325
- * boot output exactly ONCE (its effects belong to the first transaction —
329
+ * boot output exactly once (its effects belong to the first transaction —
326
330
  * commit them, tag their UI effects `phase: 'boot'`), null thereafter.
327
331
  */
328
332
  boot(world: ScriptWorldInput, budget?: ScriptBudget): Promise<ScriptOutput | null>;
329
333
  /** One deterministic run against the shared realm. Auto-boots defensively
330
334
  * (that boot's output is then returned by the next `boot()` call).
331
335
  * `budget` overrides the host default per run — the form pipeline slices
332
- * ONE transaction-wide time budget across its K/V/C/F passes. */
336
+ * one transaction-wide time budget across its K/V/C/F passes. */
333
337
  run(program: string, world: ScriptWorldInput, budget?: ScriptBudget): Promise<ScriptOutput>;
334
338
  }
335
339
  interface ScriptHostOptions {
@@ -344,12 +348,12 @@ interface ScriptHostOptions {
344
348
  budget?: ScriptBudget;
345
349
  }
346
350
  /**
347
- * The ONE realm per document (umbrella law #5): a name-tree function must be
351
+ * The one realm per document: a name-tree function must be
348
352
  * callable from a page-open script and a field calculate alike.
349
353
  *
350
- * `transaction(body)` is the realm mutex, and the body performs EVERYTHING
354
+ * `transaction(body)` is the realm mutex, and the body performs everything
351
355
  * for one logical script transaction — world prefetch, VM run(s), document
352
- * commits through the owner sinks, model reconciliation — BEFORE the mutex
356
+ * commits through the owner sinks, model reconciliation — before the mutex
353
357
  * releases, so the next transaction always prefetches post-commit truth
354
358
  * (the commit-inside-the-boundary law). Lock hierarchy: caller queues
355
359
  * (actions dispatch / form mutation) acquire this queue, never the reverse,
@@ -368,8 +372,8 @@ interface ScriptHost {
368
372
  * (ported verbatim from the form controller; exported for callers building
369
373
  * `ScriptHostOptions.environment`). */
370
374
  declare function seedFrom(documentId: string, sequence: number): number;
371
- /** Engine JWT/session identity composed under embedder overrides — the
372
- * standard `ScriptHostOptions.identity` builder. */
375
+ /** The session's identity, as Acrobat JavaScript's `identity` object, under
376
+ * embedder overrides — the standard `ScriptHostOptions.identity` builder. */
373
377
  declare function resolveScriptIdentity(doc: DocumentHandle, overrides?: Partial<ScriptIdentity> | (() => Partial<ScriptIdentity>)): ScriptIdentity;
374
378
  declare function createScriptHost(options: ScriptHostOptions): ScriptHost;
375
379
  //#endregion
@@ -385,7 +389,7 @@ declare function scriptFieldsFromSnapshot(snapshot: FormSnapshot): ScriptFieldIn
385
389
  * values. The sandbox ships `installAcroJs.toString()` into QuickJS, while
386
390
  * tests execute the same source in a Node VM. Types disappear at build time.
387
391
  */
388
- declare function installAcroJs(g: Record<string, unknown>): void;
392
+ declare function installAcroJs(globalObject: Record<string, unknown>): void;
389
393
  /** The exact self-contained source evaluated in Node parity tests and QuickJS. */
390
394
  declare const PRELUDE_SOURCE: string;
391
395
  //#endregion