@embedpdf/core-acrojs 3.0.0-next.0

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.
@@ -0,0 +1,168 @@
1
+ import { FormEffect, FormFieldDisplay, FormFieldFamily, FormFieldRef, FormSnapshot, PdfActionTree } from "@embedpdf/engine-core/runtime";
2
+ //#region src/actions.d.ts
3
+ /**
4
+ * Return executable JavaScript in PDF action order (root, then `/Next`
5
+ * depth-first). A poisoned native snapshot is never partially executed.
6
+ */
7
+ declare function javaScriptSourcesFromActionTree(tree: PdfActionTree): string[];
8
+ /** One event source that preserves the tree's shared field overlay. */
9
+ declare function javaScriptProgramFromActionTree(tree: PdfActionTree): string;
10
+ //#endregion
11
+ //#region src/types.d.ts
12
+ /** JSON-safe value vocabulary exposed through Acrobat's `event` and `Field`. */
13
+ type ScriptValue = string | number | boolean | null | string[];
14
+ interface ScriptFieldOption {
15
+ label: string;
16
+ value: string;
17
+ }
18
+ /** Detached field state supplied to one script transaction. */
19
+ interface ScriptFieldInput {
20
+ ref: FormFieldRef;
21
+ name: string;
22
+ family: FormFieldFamily;
23
+ value: ScriptValue;
24
+ defaultValue: ScriptValue;
25
+ display: FormFieldDisplay;
26
+ readOnly: boolean;
27
+ required: boolean;
28
+ options?: ScriptFieldOption[];
29
+ }
30
+ interface ScriptIdentity {
31
+ /** Acrobat `identity.name`. Empty when the embedder did not configure it. */
32
+ name: string;
33
+ loginName: string;
34
+ corporation: string;
35
+ email: string;
36
+ }
37
+ interface ScriptDocumentInput {
38
+ id: string;
39
+ fileName: string;
40
+ pageCount: number;
41
+ /** Zero-based current page, matching Acrobat `this.pageNum`. */
42
+ pageNumber: number;
43
+ }
44
+ /** Required deterministic environment. `utcOffsetMinutes` is local minus UTC. */
45
+ interface ScriptEnvironment {
46
+ nowMs: number;
47
+ utcOffsetMinutes: number;
48
+ randomSeed: number;
49
+ }
50
+ type ScriptEventKind = 'name-tree-boot' | 'widget-activate' | 'field-keystroke' | 'field-validate' | 'field-calculate' | 'field-format';
51
+ interface ScriptEventInput {
52
+ kind: ScriptEventKind;
53
+ target?: FormFieldRef;
54
+ source?: FormFieldRef;
55
+ value?: ScriptValue;
56
+ change?: string;
57
+ selStart?: number;
58
+ selEnd?: number;
59
+ willCommit?: boolean;
60
+ modifier?: boolean;
61
+ shift?: boolean;
62
+ }
63
+ /** Complete input for one deterministic run. No ambient host values are read. */
64
+ interface ScriptInput {
65
+ document: ScriptDocumentInput;
66
+ identity: ScriptIdentity;
67
+ environment: ScriptEnvironment;
68
+ fields: ScriptFieldInput[];
69
+ event: ScriptEventInput;
70
+ }
71
+ type ScriptUiEffect = {
72
+ kind: 'alert';
73
+ message: string;
74
+ icon: number;
75
+ title?: string;
76
+ } | {
77
+ kind: 'print';
78
+ } | {
79
+ kind: 'gotoPage';
80
+ page: number;
81
+ };
82
+ type ScriptDiagnosticCode = 'blocked-network' | 'unsupported-api' | 'invalid-field-value' | 'script-error';
83
+ interface ScriptDiagnostic {
84
+ code: ScriptDiagnosticCode;
85
+ message: string;
86
+ }
87
+ interface ScriptExecutionError {
88
+ kind: 'exception' | 'budget' | 'invalid-output';
89
+ message: string;
90
+ stack?: string;
91
+ }
92
+ interface ScriptEventOutput {
93
+ rc: boolean;
94
+ value: ScriptValue;
95
+ change: string;
96
+ selStart: number;
97
+ selEnd: number;
98
+ }
99
+ /** Effects are committed only by the originating client's orchestrator. */
100
+ interface ScriptOutput {
101
+ event: ScriptEventOutput;
102
+ formEffects: FormEffect[];
103
+ uiEffects: ScriptUiEffect[];
104
+ diagnostics: ScriptDiagnostic[];
105
+ error?: ScriptExecutionError;
106
+ }
107
+ interface ScriptBudget {
108
+ maxExecutionMs: number;
109
+ maxMemoryBytes: number;
110
+ maxStackBytes: number;
111
+ maxEffects: number;
112
+ maxOutputBytes: number;
113
+ }
114
+ declare const DEFAULT_SCRIPT_BUDGET: Readonly<ScriptBudget>;
115
+ /** V1 security posture. The only configurable switch is explicit opt-in. */
116
+ interface ScriptSecurityPolicy {
117
+ enabled: boolean;
118
+ executionOwner: 'originating-client-only';
119
+ nameTreeBoot: 'lazy-first-transaction';
120
+ submitForm: 'blocked';
121
+ openAction: 'preserve-only';
122
+ pageActions: 'preserve-only';
123
+ catalogLifecycleActions: 'preserve-only';
124
+ annotationActions: 'widget-activate-only';
125
+ }
126
+ declare const DEFAULT_SCRIPT_SECURITY_POLICY: Readonly<ScriptSecurityPolicy>;
127
+ /** Frozen V1 dispatch matrix; extracted actions outside it remain data only. */
128
+ declare const SCRIPT_EVENT_MATRIX: Readonly<{
129
+ readonly nameTree: "lazy-first-originating-field-transaction";
130
+ readonly field: Readonly<{
131
+ keystroke: "execute-on-commit";
132
+ validate: "execute";
133
+ calculate: "execute-in-calculation-order";
134
+ format: "execute-after-value-calculation";
135
+ }>;
136
+ readonly openAction: "preserve-only";
137
+ readonly page: "preserve-only";
138
+ readonly catalogLifecycle: "preserve-only";
139
+ readonly annotation: Readonly<{
140
+ widgetActivate: "execute-on-originating-client";
141
+ other: "preserve-only";
142
+ }>;
143
+ readonly submitForm: "blocked";
144
+ }>;
145
+ /** Functions installed into the isolated VM global by `PRELUDE_SOURCE`. */
146
+ interface AcroJsVmGlobal {
147
+ __acrojsBoot(sources: string[], input: ScriptInput, budget?: Pick<ScriptBudget, 'maxEffects'>): ScriptOutput;
148
+ __acrojsRun(source: string, input: ScriptInput, budget?: Pick<ScriptBudget, 'maxEffects'>): ScriptOutput;
149
+ }
150
+ //#endregion
151
+ //#region src/input.d.ts
152
+ /** Build the VM's detached field view from the engine's lossless snapshot. */
153
+ declare function scriptFieldsFromSnapshot(snapshot: FormSnapshot): ScriptFieldInput[];
154
+ //#endregion
155
+ //#region src/prelude.d.ts
156
+ /**
157
+ * Install the curated Acrobat object model into an isolated JavaScript realm.
158
+ *
159
+ * This function must remain self-contained: no imports and no closed-over
160
+ * values. The sandbox ships `installAcroJs.toString()` into QuickJS, while
161
+ * tests execute the same source in a Node VM. Types disappear at build time.
162
+ */
163
+ declare function installAcroJs(g: Record<string, unknown>): void;
164
+ /** The exact self-contained source evaluated in Node parity tests and QuickJS. */
165
+ declare const PRELUDE_SOURCE: string;
166
+ //#endregion
167
+ export { type AcroJsVmGlobal, DEFAULT_SCRIPT_BUDGET, DEFAULT_SCRIPT_SECURITY_POLICY, PRELUDE_SOURCE, SCRIPT_EVENT_MATRIX, type ScriptBudget, type ScriptDiagnostic, type ScriptDiagnosticCode, type ScriptDocumentInput, type ScriptEnvironment, type ScriptEventInput, type ScriptEventKind, type ScriptEventOutput, type ScriptExecutionError, type ScriptFieldInput, type ScriptFieldOption, type ScriptIdentity, type ScriptInput, type ScriptOutput, type ScriptSecurityPolicy, type ScriptUiEffect, type ScriptValue, installAcroJs, javaScriptProgramFromActionTree, javaScriptSourcesFromActionTree, scriptFieldsFromSnapshot };
168
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,168 @@
1
+ import { FormEffect, FormFieldDisplay, FormFieldFamily, FormFieldRef, FormSnapshot, PdfActionTree } from "@embedpdf/engine-core/runtime";
2
+ //#region src/actions.d.ts
3
+ /**
4
+ * Return executable JavaScript in PDF action order (root, then `/Next`
5
+ * depth-first). A poisoned native snapshot is never partially executed.
6
+ */
7
+ declare function javaScriptSourcesFromActionTree(tree: PdfActionTree): string[];
8
+ /** One event source that preserves the tree's shared field overlay. */
9
+ declare function javaScriptProgramFromActionTree(tree: PdfActionTree): string;
10
+ //#endregion
11
+ //#region src/types.d.ts
12
+ /** JSON-safe value vocabulary exposed through Acrobat's `event` and `Field`. */
13
+ type ScriptValue = string | number | boolean | null | string[];
14
+ interface ScriptFieldOption {
15
+ label: string;
16
+ value: string;
17
+ }
18
+ /** Detached field state supplied to one script transaction. */
19
+ interface ScriptFieldInput {
20
+ ref: FormFieldRef;
21
+ name: string;
22
+ family: FormFieldFamily;
23
+ value: ScriptValue;
24
+ defaultValue: ScriptValue;
25
+ display: FormFieldDisplay;
26
+ readOnly: boolean;
27
+ required: boolean;
28
+ options?: ScriptFieldOption[];
29
+ }
30
+ interface ScriptIdentity {
31
+ /** Acrobat `identity.name`. Empty when the embedder did not configure it. */
32
+ name: string;
33
+ loginName: string;
34
+ corporation: string;
35
+ email: string;
36
+ }
37
+ interface ScriptDocumentInput {
38
+ id: string;
39
+ fileName: string;
40
+ pageCount: number;
41
+ /** Zero-based current page, matching Acrobat `this.pageNum`. */
42
+ pageNumber: number;
43
+ }
44
+ /** Required deterministic environment. `utcOffsetMinutes` is local minus UTC. */
45
+ interface ScriptEnvironment {
46
+ nowMs: number;
47
+ utcOffsetMinutes: number;
48
+ randomSeed: number;
49
+ }
50
+ type ScriptEventKind = 'name-tree-boot' | 'widget-activate' | 'field-keystroke' | 'field-validate' | 'field-calculate' | 'field-format';
51
+ interface ScriptEventInput {
52
+ kind: ScriptEventKind;
53
+ target?: FormFieldRef;
54
+ source?: FormFieldRef;
55
+ value?: ScriptValue;
56
+ change?: string;
57
+ selStart?: number;
58
+ selEnd?: number;
59
+ willCommit?: boolean;
60
+ modifier?: boolean;
61
+ shift?: boolean;
62
+ }
63
+ /** Complete input for one deterministic run. No ambient host values are read. */
64
+ interface ScriptInput {
65
+ document: ScriptDocumentInput;
66
+ identity: ScriptIdentity;
67
+ environment: ScriptEnvironment;
68
+ fields: ScriptFieldInput[];
69
+ event: ScriptEventInput;
70
+ }
71
+ type ScriptUiEffect = {
72
+ kind: 'alert';
73
+ message: string;
74
+ icon: number;
75
+ title?: string;
76
+ } | {
77
+ kind: 'print';
78
+ } | {
79
+ kind: 'gotoPage';
80
+ page: number;
81
+ };
82
+ type ScriptDiagnosticCode = 'blocked-network' | 'unsupported-api' | 'invalid-field-value' | 'script-error';
83
+ interface ScriptDiagnostic {
84
+ code: ScriptDiagnosticCode;
85
+ message: string;
86
+ }
87
+ interface ScriptExecutionError {
88
+ kind: 'exception' | 'budget' | 'invalid-output';
89
+ message: string;
90
+ stack?: string;
91
+ }
92
+ interface ScriptEventOutput {
93
+ rc: boolean;
94
+ value: ScriptValue;
95
+ change: string;
96
+ selStart: number;
97
+ selEnd: number;
98
+ }
99
+ /** Effects are committed only by the originating client's orchestrator. */
100
+ interface ScriptOutput {
101
+ event: ScriptEventOutput;
102
+ formEffects: FormEffect[];
103
+ uiEffects: ScriptUiEffect[];
104
+ diagnostics: ScriptDiagnostic[];
105
+ error?: ScriptExecutionError;
106
+ }
107
+ interface ScriptBudget {
108
+ maxExecutionMs: number;
109
+ maxMemoryBytes: number;
110
+ maxStackBytes: number;
111
+ maxEffects: number;
112
+ maxOutputBytes: number;
113
+ }
114
+ declare const DEFAULT_SCRIPT_BUDGET: Readonly<ScriptBudget>;
115
+ /** V1 security posture. The only configurable switch is explicit opt-in. */
116
+ interface ScriptSecurityPolicy {
117
+ enabled: boolean;
118
+ executionOwner: 'originating-client-only';
119
+ nameTreeBoot: 'lazy-first-transaction';
120
+ submitForm: 'blocked';
121
+ openAction: 'preserve-only';
122
+ pageActions: 'preserve-only';
123
+ catalogLifecycleActions: 'preserve-only';
124
+ annotationActions: 'widget-activate-only';
125
+ }
126
+ declare const DEFAULT_SCRIPT_SECURITY_POLICY: Readonly<ScriptSecurityPolicy>;
127
+ /** Frozen V1 dispatch matrix; extracted actions outside it remain data only. */
128
+ declare const SCRIPT_EVENT_MATRIX: Readonly<{
129
+ readonly nameTree: "lazy-first-originating-field-transaction";
130
+ readonly field: Readonly<{
131
+ keystroke: "execute-on-commit";
132
+ validate: "execute";
133
+ calculate: "execute-in-calculation-order";
134
+ format: "execute-after-value-calculation";
135
+ }>;
136
+ readonly openAction: "preserve-only";
137
+ readonly page: "preserve-only";
138
+ readonly catalogLifecycle: "preserve-only";
139
+ readonly annotation: Readonly<{
140
+ widgetActivate: "execute-on-originating-client";
141
+ other: "preserve-only";
142
+ }>;
143
+ readonly submitForm: "blocked";
144
+ }>;
145
+ /** Functions installed into the isolated VM global by `PRELUDE_SOURCE`. */
146
+ interface AcroJsVmGlobal {
147
+ __acrojsBoot(sources: string[], input: ScriptInput, budget?: Pick<ScriptBudget, 'maxEffects'>): ScriptOutput;
148
+ __acrojsRun(source: string, input: ScriptInput, budget?: Pick<ScriptBudget, 'maxEffects'>): ScriptOutput;
149
+ }
150
+ //#endregion
151
+ //#region src/input.d.ts
152
+ /** Build the VM's detached field view from the engine's lossless snapshot. */
153
+ declare function scriptFieldsFromSnapshot(snapshot: FormSnapshot): ScriptFieldInput[];
154
+ //#endregion
155
+ //#region src/prelude.d.ts
156
+ /**
157
+ * Install the curated Acrobat object model into an isolated JavaScript realm.
158
+ *
159
+ * This function must remain self-contained: no imports and no closed-over
160
+ * values. The sandbox ships `installAcroJs.toString()` into QuickJS, while
161
+ * tests execute the same source in a Node VM. Types disappear at build time.
162
+ */
163
+ declare function installAcroJs(g: Record<string, unknown>): void;
164
+ /** The exact self-contained source evaluated in Node parity tests and QuickJS. */
165
+ declare const PRELUDE_SOURCE: string;
166
+ //#endregion
167
+ export { type AcroJsVmGlobal, DEFAULT_SCRIPT_BUDGET, DEFAULT_SCRIPT_SECURITY_POLICY, PRELUDE_SOURCE, SCRIPT_EVENT_MATRIX, type ScriptBudget, type ScriptDiagnostic, type ScriptDiagnosticCode, type ScriptDocumentInput, type ScriptEnvironment, type ScriptEventInput, type ScriptEventKind, type ScriptEventOutput, type ScriptExecutionError, type ScriptFieldInput, type ScriptFieldOption, type ScriptIdentity, type ScriptInput, type ScriptOutput, type ScriptSecurityPolicy, type ScriptUiEffect, type ScriptValue, installAcroJs, javaScriptProgramFromActionTree, javaScriptSourcesFromActionTree, scriptFieldsFromSnapshot };
168
+ //# sourceMappingURL=index.d.ts.map