@embedpdf/plugin-actions 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.
Files changed (41) hide show
  1. package/dist/contract/host.cjs +13 -1
  2. package/dist/contract/host.cjs.map +1 -1
  3. package/dist/contract/host.d.cts +3 -7
  4. package/dist/contract/host.d.ts +3 -7
  5. package/dist/contract/host.js +10 -3
  6. package/dist/contract/host.js.map +1 -1
  7. package/dist/contract-BTPW8b4L.d.cts +557 -0
  8. package/dist/contract-Cn-7mBY8.d.ts +557 -0
  9. package/dist/contract-CwN3NAXU.js +175 -0
  10. package/dist/contract-CwN3NAXU.js.map +1 -0
  11. package/dist/contract-_HB_UliT.cjs +210 -0
  12. package/dist/contract-_HB_UliT.cjs.map +1 -0
  13. package/dist/contract.cjs +5 -4
  14. package/dist/contract.d.cts +2 -3
  15. package/dist/contract.d.ts +2 -3
  16. package/dist/contract.js +2 -3
  17. package/dist/host-contract-BbODswDs.d.ts +165 -0
  18. package/dist/host-contract-D22Gz-qt.d.cts +165 -0
  19. package/dist/index.cjs +1588 -1072
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +11 -9
  22. package/dist/index.d.ts +11 -9
  23. package/dist/index.js +1586 -1072
  24. package/dist/index.js.map +1 -1
  25. package/package.json +7 -11
  26. package/dist/contract-C1K3H4RP.cjs +0 -89
  27. package/dist/contract-C1K3H4RP.cjs.map +0 -1
  28. package/dist/contract-COk-w3Fo.d.ts +0 -50
  29. package/dist/contract-DAem-EST.js +0 -78
  30. package/dist/contract-DAem-EST.js.map +0 -1
  31. package/dist/contract-Os5y4NaD.d.cts +0 -50
  32. package/dist/internal.cjs +0 -3
  33. package/dist/internal.d.cts +0 -3
  34. package/dist/internal.d.ts +0 -3
  35. package/dist/internal.js +0 -2
  36. package/dist/types-BXJLAKXi.cjs +0 -52
  37. package/dist/types-BXJLAKXi.cjs.map +0 -1
  38. package/dist/types-D-DoiESj.d.cts +0 -504
  39. package/dist/types-D-DoiESj.d.ts +0 -504
  40. package/dist/types-DgBMy5nE.js +0 -35
  41. package/dist/types-DgBMy5nE.js.map +0 -1
@@ -0,0 +1,165 @@
1
+ import { B as SubmitIntent, T as ActionsCapability, d as ActionOrigin, h as ActionSource, n as ActionContext, r as ActionDiagnostic, v as ActionSubmitRequest } from "./contract-Cn-7mBY8.js";
2
+ import { DocumentMeta, Unsubscribe } from "@embedpdf/core";
3
+ import { DocumentHandle, FormEffect, FormSnapshot, PageRef } from "@embedpdf/engine-core/runtime";
4
+ import { ScriptAnnotEffect, ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptTransaction, ScriptUiEffect } from "@embedpdf/core-acrojs";
5
+ //#region src/host-contract.d.ts
6
+ /**
7
+ * The stage's page-truth report, the one door into the lifecycle
8
+ * coordinator. The stage stays authoritative for what page the viewer is on;
9
+ * the coordinator owns when page-lifecycle triggers fire: reports are
10
+ * buffered until the document-open sequence has run and diffed against the
11
+ * last-emitted state, so pre-open motion (a restored view, the open
12
+ * destination's reveal) never emits close and open churn. `cause` feeds the
13
+ * cascade budget: consecutive programmatic rounds are capped, and a
14
+ * user-caused report resets the count.
15
+ */
16
+ interface PageStateReport {
17
+ currentPage: PageRef | null;
18
+ visiblePages: readonly PageRef[];
19
+ /** False until layout exists; pre-placement reports are ignored. */
20
+ placed: boolean;
21
+ cause: 'user' | 'programmatic';
22
+ }
23
+ /** One annotation-effect commit entry. `page` may be absent for bare Hide
24
+ * object-number targets: the sink resolves it from its model (`obj:N` is a
25
+ * cross-page key there), and entries it cannot resolve fail. */
26
+ interface AnnotCommitEntry {
27
+ annotObjectNumber: number;
28
+ page?: PageRef;
29
+ patch: ScriptAnnotEffect['patch'];
30
+ }
31
+ interface AnnotCommitResult {
32
+ results: Array<{
33
+ annotObjectNumber: number;
34
+ status: 'applied' | 'failed' | 'skipped';
35
+ error?: string;
36
+ }>;
37
+ }
38
+ type AnnotCommitSink = (entries: AnnotCommitEntry[]) => Promise<AnnotCommitResult>;
39
+ /**
40
+ * What the form plugin's commit did: `applied`, the effects are one change on its way (shown at
41
+ * once; the engine's refusal comes through the change queue); `failed`, none of them is.
42
+ */
43
+ interface FormCommitSinkResult {
44
+ status: 'applied' | 'failed';
45
+ /** Why the change couldn't be made, when it couldn't. */
46
+ error?: string;
47
+ }
48
+ /** The form plugin's document commit: a script run's form effects, written as one change. */
49
+ type FormCommitSink = (effects: FormEffect[]) => Promise<FormCommitSinkResult>;
50
+ /**
51
+ * The form as the user sees it: the form plugin's fields and widgets with this session's pending
52
+ * fills, or `null` before it has read the form. What scripts and dispatch read instead of the
53
+ * engine, so they see a fill before the engine answers it.
54
+ */
55
+ type FormReader = () => FormSnapshot | null;
56
+ /**
57
+ * Which realm produced a script result. `'document'` = this document's own
58
+ * realm: every effect targets the viewer document. `'detached'` = a realm
59
+ * minted for a document that is not displayed (a stamp asset): it has no
60
+ * document surface, so only alerts reach the adapter — print, page
61
+ * navigation, and submit are suppressed with a diagnostic rather than
62
+ * acting on the wrong document.
63
+ */
64
+ type ScriptRealmKind = 'document' | 'detached';
65
+ /** What a script transaction surfaced besides document effects. */
66
+ interface ScriptSurfaceResult {
67
+ uiEffects: ScriptUiEffect[];
68
+ diagnostics: ScriptDiagnostic[];
69
+ error?: ScriptExecutionError;
70
+ origin: ActionOrigin;
71
+ phase: 'boot' | 'user';
72
+ realm: ScriptRealmKind;
73
+ /** What started the script, when an action did: `onScriptFailed` and diagnostics carry it. */
74
+ source?: ActionSource;
75
+ }
76
+ /** A K/V/C/F transaction's result as the form controller reports it: effects
77
+ * carry their own phase (boot effects belong to the first transaction that
78
+ * lazily booted the realm). Structurally the surface half of the form
79
+ * plugin's commit result, typed here so the actions plane never imports the
80
+ * form package. */
81
+ interface ScriptCommitSurface {
82
+ uiEffects: Array<ScriptUiEffect & {
83
+ phase: 'boot' | 'user';
84
+ }>;
85
+ diagnostics: ScriptDiagnostic[];
86
+ error?: ScriptExecutionError;
87
+ }
88
+ /** What a realm is minted for. `doc` is the document the scripts operate on
89
+ * (the viewer document, or a detached asset); `document()` is the metadata
90
+ * scripts observe (`this.documentFileName` …): for a detached stamp that is
91
+ * the target document's, matching Acrobat's dynamic stamps. */
92
+ /** What a script realm reads of the document it runs for. */
93
+ type ScriptDocument = Pick<DocumentMeta, 'name' | 'pageCount' | 'pages'>;
94
+ interface ScriptRealmTarget {
95
+ doc: DocumentHandle;
96
+ document(): ScriptDocument | null;
97
+ /** Name-tree programs, fetched lazily once per realm build. */
98
+ bootSources(): Promise<string[]>;
99
+ }
100
+ /** The realm transaction port plus the budget consumers apply as their
101
+ * transaction aggregate: the same shape whether the realm is this document's
102
+ * own (owned by actions) or a detached one (owned by the caller). */
103
+ interface ScriptRealmPort {
104
+ /** The body must perform prefetch, runs, sink commits and reconciliation
105
+ * before returning: commits happen inside the transaction. */
106
+ transaction<T>(body: (transaction: ScriptTransaction) => Promise<T>): Promise<T>;
107
+ budget: ScriptBudget;
108
+ }
109
+ /** A detached realm: the caller owns its lifetime. */
110
+ interface DetachedScriptRealm extends ScriptRealmPort {
111
+ dispose(): void;
112
+ }
113
+ /** The form plugin's dataset resolver, registered on the host lens.
114
+ * `diagnose` is the per-entry observability channel: an explicitly listed
115
+ * push-button, signature or unsupported value is diagnosed as
116
+ * `submit-entry-unsupported`, never silently dropped. */
117
+ type SubmitResolver = (intent: SubmitIntent, actionContext: ActionContext, diagnose: (diagnostic: ActionDiagnostic) => void) => Promise<ActionSubmitRequest>;
118
+ /** The host lens, plugin-to-plugin only: import the token from
119
+ * `@embedpdf/plugin-actions/contract/host`, never from application code. */
120
+ interface ActionsHostCapability extends ActionsCapability {
121
+ /** The annotation plugin's commit sink for script and Hide annotation effects. Identity-safe. */
122
+ registerAnnotCommitSink(sink: AnnotCommitSink): Unsubscribe;
123
+ /** The form plugin's commit sink for script and Hide form effects. Identity-safe. */
124
+ registerFormCommitSink(sink: FormCommitSink): Unsubscribe;
125
+ /** The form plugin's form, which scripts and dispatch read; without one they read the engine. Identity-safe. */
126
+ registerFormReader(reader: FormReader): Unsubscribe;
127
+ /**
128
+ * This document's realm, present only when `javascript.enabled` (its
129
+ * presence is the form plugin's "scripting on" signal).
130
+ */
131
+ scriptRealm?: ScriptRealmPort;
132
+ /**
133
+ * Mint a realm for a detached document under this document's policy and
134
+ * environment (the same sandbox factory, identity, clock and budget; a
135
+ * fresh sandbox, so isolated globals). Present only when
136
+ * `javascript.enabled`, like `scriptRealm`. The caller owns the returned
137
+ * realm's lifetime and surfaces its results with `realm: 'detached'`.
138
+ */
139
+ createDetachedScriptRealm?(target: ScriptRealmTarget): DetachedScriptRealm;
140
+ /** Surface a script transaction's UI effects, diagnostics and error through
141
+ * the one port (the adapter matrix, the authority print gate, the script
142
+ * events). */
143
+ surfaceScriptResult(result: ScriptSurfaceResult): void;
144
+ /** Surface a K/V/C/F commit result: splits boot-phase and user-phase
145
+ * effects into their own surfaces (diagnostics and the error ride the
146
+ * user phase); the one place that split lives. */
147
+ surfaceScriptCommit(commit: ScriptCommitSurface, context: {
148
+ origin: ActionOrigin;
149
+ realm: ScriptRealmKind;
150
+ source?: ActionSource;
151
+ }): void;
152
+ /** The stage's page-truth report (see {@link PageStateReport}). */
153
+ reportPageState(report: PageStateReport): void;
154
+ /**
155
+ * The form plugin's dataset resolver: both submit sources (action nodes
156
+ * and script `doc.submitForm()` effects) normalize to a
157
+ * {@link SubmitIntent} and resolve through this one door. Identity-safe;
158
+ * without it every submit blocks with `no-submit-resolver`.
159
+ */
160
+ registerSubmitResolver(resolver: SubmitResolver): Unsubscribe;
161
+ }
162
+ declare const ActionsToken: import("@embedpdf/core").CapabilityToken<ActionsHostCapability>;
163
+ //#endregion
164
+ export { SubmitResolver as _, AnnotCommitSink as a, FormCommitSinkResult as c, ScriptCommitSurface as d, ScriptDocument as f, ScriptSurfaceResult as g, ScriptRealmTarget as h, AnnotCommitResult as i, FormReader as l, ScriptRealmPort as m, ActionsToken as n, DetachedScriptRealm as o, ScriptRealmKind as p, AnnotCommitEntry as r, FormCommitSink as s, ActionsHostCapability as t, PageStateReport as u };
165
+ //# sourceMappingURL=host-contract-BbODswDs.d.ts.map
@@ -0,0 +1,165 @@
1
+ import { B as SubmitIntent, T as ActionsCapability, d as ActionOrigin, h as ActionSource, n as ActionContext, r as ActionDiagnostic, v as ActionSubmitRequest } from "./contract-BTPW8b4L.cjs";
2
+ import { DocumentMeta, Unsubscribe } from "@embedpdf/core";
3
+ import { ScriptAnnotEffect, ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptTransaction, ScriptUiEffect } from "@embedpdf/core-acrojs";
4
+ import { DocumentHandle, FormEffect, FormSnapshot, PageRef } from "@embedpdf/engine-core/runtime";
5
+ //#region src/host-contract.d.ts
6
+ /**
7
+ * The stage's page-truth report, the one door into the lifecycle
8
+ * coordinator. The stage stays authoritative for what page the viewer is on;
9
+ * the coordinator owns when page-lifecycle triggers fire: reports are
10
+ * buffered until the document-open sequence has run and diffed against the
11
+ * last-emitted state, so pre-open motion (a restored view, the open
12
+ * destination's reveal) never emits close and open churn. `cause` feeds the
13
+ * cascade budget: consecutive programmatic rounds are capped, and a
14
+ * user-caused report resets the count.
15
+ */
16
+ interface PageStateReport {
17
+ currentPage: PageRef | null;
18
+ visiblePages: readonly PageRef[];
19
+ /** False until layout exists; pre-placement reports are ignored. */
20
+ placed: boolean;
21
+ cause: 'user' | 'programmatic';
22
+ }
23
+ /** One annotation-effect commit entry. `page` may be absent for bare Hide
24
+ * object-number targets: the sink resolves it from its model (`obj:N` is a
25
+ * cross-page key there), and entries it cannot resolve fail. */
26
+ interface AnnotCommitEntry {
27
+ annotObjectNumber: number;
28
+ page?: PageRef;
29
+ patch: ScriptAnnotEffect['patch'];
30
+ }
31
+ interface AnnotCommitResult {
32
+ results: Array<{
33
+ annotObjectNumber: number;
34
+ status: 'applied' | 'failed' | 'skipped';
35
+ error?: string;
36
+ }>;
37
+ }
38
+ type AnnotCommitSink = (entries: AnnotCommitEntry[]) => Promise<AnnotCommitResult>;
39
+ /**
40
+ * What the form plugin's commit did: `applied`, the effects are one change on its way (shown at
41
+ * once; the engine's refusal comes through the change queue); `failed`, none of them is.
42
+ */
43
+ interface FormCommitSinkResult {
44
+ status: 'applied' | 'failed';
45
+ /** Why the change couldn't be made, when it couldn't. */
46
+ error?: string;
47
+ }
48
+ /** The form plugin's document commit: a script run's form effects, written as one change. */
49
+ type FormCommitSink = (effects: FormEffect[]) => Promise<FormCommitSinkResult>;
50
+ /**
51
+ * The form as the user sees it: the form plugin's fields and widgets with this session's pending
52
+ * fills, or `null` before it has read the form. What scripts and dispatch read instead of the
53
+ * engine, so they see a fill before the engine answers it.
54
+ */
55
+ type FormReader = () => FormSnapshot | null;
56
+ /**
57
+ * Which realm produced a script result. `'document'` = this document's own
58
+ * realm: every effect targets the viewer document. `'detached'` = a realm
59
+ * minted for a document that is not displayed (a stamp asset): it has no
60
+ * document surface, so only alerts reach the adapter — print, page
61
+ * navigation, and submit are suppressed with a diagnostic rather than
62
+ * acting on the wrong document.
63
+ */
64
+ type ScriptRealmKind = 'document' | 'detached';
65
+ /** What a script transaction surfaced besides document effects. */
66
+ interface ScriptSurfaceResult {
67
+ uiEffects: ScriptUiEffect[];
68
+ diagnostics: ScriptDiagnostic[];
69
+ error?: ScriptExecutionError;
70
+ origin: ActionOrigin;
71
+ phase: 'boot' | 'user';
72
+ realm: ScriptRealmKind;
73
+ /** What started the script, when an action did: `onScriptFailed` and diagnostics carry it. */
74
+ source?: ActionSource;
75
+ }
76
+ /** A K/V/C/F transaction's result as the form controller reports it: effects
77
+ * carry their own phase (boot effects belong to the first transaction that
78
+ * lazily booted the realm). Structurally the surface half of the form
79
+ * plugin's commit result, typed here so the actions plane never imports the
80
+ * form package. */
81
+ interface ScriptCommitSurface {
82
+ uiEffects: Array<ScriptUiEffect & {
83
+ phase: 'boot' | 'user';
84
+ }>;
85
+ diagnostics: ScriptDiagnostic[];
86
+ error?: ScriptExecutionError;
87
+ }
88
+ /** What a realm is minted for. `doc` is the document the scripts operate on
89
+ * (the viewer document, or a detached asset); `document()` is the metadata
90
+ * scripts observe (`this.documentFileName` …): for a detached stamp that is
91
+ * the target document's, matching Acrobat's dynamic stamps. */
92
+ /** What a script realm reads of the document it runs for. */
93
+ type ScriptDocument = Pick<DocumentMeta, 'name' | 'pageCount' | 'pages'>;
94
+ interface ScriptRealmTarget {
95
+ doc: DocumentHandle;
96
+ document(): ScriptDocument | null;
97
+ /** Name-tree programs, fetched lazily once per realm build. */
98
+ bootSources(): Promise<string[]>;
99
+ }
100
+ /** The realm transaction port plus the budget consumers apply as their
101
+ * transaction aggregate: the same shape whether the realm is this document's
102
+ * own (owned by actions) or a detached one (owned by the caller). */
103
+ interface ScriptRealmPort {
104
+ /** The body must perform prefetch, runs, sink commits and reconciliation
105
+ * before returning: commits happen inside the transaction. */
106
+ transaction<T>(body: (transaction: ScriptTransaction) => Promise<T>): Promise<T>;
107
+ budget: ScriptBudget;
108
+ }
109
+ /** A detached realm: the caller owns its lifetime. */
110
+ interface DetachedScriptRealm extends ScriptRealmPort {
111
+ dispose(): void;
112
+ }
113
+ /** The form plugin's dataset resolver, registered on the host lens.
114
+ * `diagnose` is the per-entry observability channel: an explicitly listed
115
+ * push-button, signature or unsupported value is diagnosed as
116
+ * `submit-entry-unsupported`, never silently dropped. */
117
+ type SubmitResolver = (intent: SubmitIntent, actionContext: ActionContext, diagnose: (diagnostic: ActionDiagnostic) => void) => Promise<ActionSubmitRequest>;
118
+ /** The host lens, plugin-to-plugin only: import the token from
119
+ * `@embedpdf/plugin-actions/contract/host`, never from application code. */
120
+ interface ActionsHostCapability extends ActionsCapability {
121
+ /** The annotation plugin's commit sink for script and Hide annotation effects. Identity-safe. */
122
+ registerAnnotCommitSink(sink: AnnotCommitSink): Unsubscribe;
123
+ /** The form plugin's commit sink for script and Hide form effects. Identity-safe. */
124
+ registerFormCommitSink(sink: FormCommitSink): Unsubscribe;
125
+ /** The form plugin's form, which scripts and dispatch read; without one they read the engine. Identity-safe. */
126
+ registerFormReader(reader: FormReader): Unsubscribe;
127
+ /**
128
+ * This document's realm, present only when `javascript.enabled` (its
129
+ * presence is the form plugin's "scripting on" signal).
130
+ */
131
+ scriptRealm?: ScriptRealmPort;
132
+ /**
133
+ * Mint a realm for a detached document under this document's policy and
134
+ * environment (the same sandbox factory, identity, clock and budget; a
135
+ * fresh sandbox, so isolated globals). Present only when
136
+ * `javascript.enabled`, like `scriptRealm`. The caller owns the returned
137
+ * realm's lifetime and surfaces its results with `realm: 'detached'`.
138
+ */
139
+ createDetachedScriptRealm?(target: ScriptRealmTarget): DetachedScriptRealm;
140
+ /** Surface a script transaction's UI effects, diagnostics and error through
141
+ * the one port (the adapter matrix, the authority print gate, the script
142
+ * events). */
143
+ surfaceScriptResult(result: ScriptSurfaceResult): void;
144
+ /** Surface a K/V/C/F commit result: splits boot-phase and user-phase
145
+ * effects into their own surfaces (diagnostics and the error ride the
146
+ * user phase); the one place that split lives. */
147
+ surfaceScriptCommit(commit: ScriptCommitSurface, context: {
148
+ origin: ActionOrigin;
149
+ realm: ScriptRealmKind;
150
+ source?: ActionSource;
151
+ }): void;
152
+ /** The stage's page-truth report (see {@link PageStateReport}). */
153
+ reportPageState(report: PageStateReport): void;
154
+ /**
155
+ * The form plugin's dataset resolver: both submit sources (action nodes
156
+ * and script `doc.submitForm()` effects) normalize to a
157
+ * {@link SubmitIntent} and resolve through this one door. Identity-safe;
158
+ * without it every submit blocks with `no-submit-resolver`.
159
+ */
160
+ registerSubmitResolver(resolver: SubmitResolver): Unsubscribe;
161
+ }
162
+ declare const ActionsToken: import("@embedpdf/core").CapabilityToken<ActionsHostCapability>;
163
+ //#endregion
164
+ export { SubmitResolver as _, AnnotCommitSink as a, FormCommitSinkResult as c, ScriptCommitSurface as d, ScriptDocument as f, ScriptSurfaceResult as g, ScriptRealmTarget as h, AnnotCommitResult as i, FormReader as l, ScriptRealmPort as m, ActionsToken as n, DetachedScriptRealm as o, ScriptRealmKind as p, AnnotCommitEntry as r, FormCommitSink as s, ActionsHostCapability as t, PageStateReport as u };
165
+ //# sourceMappingURL=host-contract-D22Gz-qt.d.cts.map