@embedpdf/react 3.0.0-next.1 → 3.0.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.cts +546 -0
- package/dist/AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.ts +546 -0
- package/dist/actions.cjs +42 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +18 -0
- package/dist/actions.d.ts +18 -0
- package/dist/actions.js +34 -0
- package/dist/actions.js.map +1 -0
- package/dist/anchored.cjs +89 -0
- package/dist/anchored.cjs.map +1 -0
- package/dist/anchored.d.cts +45 -0
- package/dist/anchored.d.ts +45 -0
- package/dist/anchored.js +60 -0
- package/dist/anchored.js.map +1 -0
- package/dist/{annotation-B6jwfTCh.d.cts → annotation-BCED_p9H.d.cts} +56 -69
- package/dist/annotation-anchors-CetwM1g7.js +15 -0
- package/dist/annotation-anchors-CetwM1g7.js.map +1 -0
- package/dist/annotation-anchors-DuYRBJLl.cjs +26 -0
- package/dist/annotation-anchors-DuYRBJLl.cjs.map +1 -0
- package/dist/annotation-hooks-BB5ZhPpf.cjs +16 -0
- package/dist/annotation-hooks-BB5ZhPpf.cjs.map +1 -0
- package/dist/annotation-hooks-Df8EmzDO.js +11 -0
- package/dist/annotation-hooks-Df8EmzDO.js.map +1 -0
- package/dist/{annotation-nUMefyjw.d.ts → annotation-k38KDlIZ.d.ts} +57 -70
- package/dist/annotation-menu.cjs +37 -88
- package/dist/annotation-menu.cjs.map +1 -1
- package/dist/annotation-menu.d.cts +28 -2
- package/dist/annotation-menu.d.ts +28 -2
- package/dist/annotation-menu.js +28 -79
- package/dist/annotation-menu.js.map +1 -1
- package/dist/annotation.cjs +738 -16
- package/dist/annotation.cjs.map +1 -0
- package/dist/annotation.d.cts +2 -2
- package/dist/annotation.d.ts +2 -2
- package/dist/annotation.js +723 -3
- package/dist/annotation.js.map +1 -0
- package/dist/commands.js +1 -0
- package/dist/commands.js.map +1 -1
- package/dist/form-BwrLFpKN.js +805 -0
- package/dist/form-BwrLFpKN.js.map +1 -0
- package/dist/form-D-ZSfGmB.cjs +836 -0
- package/dist/form-D-ZSfGmB.cjs.map +1 -0
- package/dist/form.cjs +8 -551
- package/dist/form.d.cts +4 -21
- package/dist/form.d.ts +4 -21
- package/dist/form.js +3 -544
- package/dist/index.cjs +49 -16
- package/dist/index.d.cts +17 -10
- package/dist/index.d.ts +17 -10
- package/dist/index.js +14 -9
- package/dist/interaction.cjs +17 -4
- package/dist/interaction.cjs.map +1 -1
- package/dist/interaction.d.cts +2 -2
- package/dist/interaction.d.ts +2 -2
- package/dist/interaction.js +7 -5
- package/dist/interaction.js.map +1 -1
- package/dist/link.cjs +70 -7
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +12 -3
- package/dist/link.d.ts +12 -3
- package/dist/link.js +73 -10
- package/dist/link.js.map +1 -1
- package/dist/metadata.js +1 -0
- package/dist/metadata.js.map +1 -1
- package/dist/page-edit.js +1 -0
- package/dist/page-edit.js.map +1 -1
- package/dist/page-view.cjs +62 -38
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.js +59 -37
- package/dist/page-view.js.map +1 -1
- package/dist/redaction.js +1 -0
- package/dist/redaction.js.map +1 -1
- package/dist/render.cjs +67 -50
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +6 -19
- package/dist/render.d.ts +6 -19
- package/dist/render.js +71 -52
- package/dist/render.js.map +1 -1
- package/dist/rolldown-runtime-BBjsoOtd.js +27 -0
- package/dist/{runtime-CMxIuF2O.d.cts → runtime-DE76hlnl.d.ts} +32 -11
- package/dist/{runtime-DV98q7I0.d.ts → runtime-umHA_xHt.d.cts} +32 -11
- package/dist/runtime.cjs +25 -5
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +26 -6
- package/dist/runtime.js.map +1 -1
- package/dist/scrollbar.cjs +3 -3
- package/dist/scrollbar.cjs.map +1 -1
- package/dist/scrollbar.d.cts +1 -1
- package/dist/scrollbar.d.ts +1 -1
- package/dist/scrollbar.js +1 -1
- package/dist/scrollbar.js.map +1 -1
- package/dist/search.cjs +36 -19
- package/dist/search.cjs.map +1 -1
- package/dist/search.d.cts +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/search.js +36 -19
- package/dist/search.js.map +1 -1
- package/dist/selection.cjs +217 -22
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +60 -2
- package/dist/selection.d.ts +60 -2
- package/dist/selection.js +214 -27
- package/dist/selection.js.map +1 -1
- package/dist/shell.js +1 -0
- package/dist/shell.js.map +1 -1
- package/dist/stage.cjs +49 -148
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.d.cts +18 -5
- package/dist/stage.d.ts +18 -5
- package/dist/stage.js +51 -149
- package/dist/stage.js.map +1 -1
- package/dist/stamp.js +1 -0
- package/dist/stamp.js.map +1 -1
- package/dist/toolbar.cjs +4 -4
- package/dist/toolbar.cjs.map +1 -1
- package/dist/toolbar.d.cts +1 -1
- package/dist/toolbar.d.ts +1 -1
- package/dist/toolbar.js +2 -1
- package/dist/toolbar.js.map +1 -1
- package/dist/views.js +1 -0
- package/dist/views.js.map +1 -1
- package/package.json +33 -26
- package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts +0 -2593
- package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts +0 -2593
- package/dist/annotation-Ct6dFtzJ.cjs +0 -913
- package/dist/annotation-Ct6dFtzJ.cjs.map +0 -1
- package/dist/annotation-DjGWJljY.js +0 -829
- package/dist/annotation-DjGWJljY.js.map +0 -1
- package/dist/form.cjs.map +0 -1
- package/dist/form.js.map +0 -1
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
//#region ../../engine/core/dist/AnnotationListSnapshot-C1U3XUxP.d.ts
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region src/identity/PageObjectNumber.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* PDF indirect object number for a page.
|
|
6
|
+
*
|
|
7
|
+
* Resolved via the PDFium runtime helper `EPDFPage_GetObjectNumber(pagePtr)`.
|
|
8
|
+
* Always > 0 for well-formed PDFs. This replaces the v2 page index as the
|
|
9
|
+
* primary addressing key. The page index is kept on `PageHandle` as display
|
|
10
|
+
* metadata only, because it can shift when pages are inserted, deleted, or
|
|
11
|
+
* reordered while a session is open.
|
|
12
|
+
*/
|
|
13
|
+
type PageObjectNumber = number;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/dto/PdfDestination.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* An explicit PDF destination (ISO 32000-1 §12.3.2.2): a page, a location,
|
|
18
|
+
* and a magnification. Produced by outlines/bookmarks, link annotations,
|
|
19
|
+
* `/OpenAction`, and GoTo actions; named destinations resolve to one of
|
|
20
|
+
* these through the catalog's `/Dests` dictionary or name tree — the
|
|
21
|
+
* ENGINE does that resolution, so the viewer only ever sees this explicit
|
|
22
|
+
* form.
|
|
23
|
+
*
|
|
24
|
+
* Coordinates are PDF user space (y-up, points, absolute — NOT
|
|
25
|
+
* crop-relative). `null` means "retain the current value" (the spec's
|
|
26
|
+
* meaning for null array entries); a `/XYZ` zoom of `0` is equivalent to
|
|
27
|
+
* null. The `fitB*` kinds refer to the page's content BOUNDING box rather
|
|
28
|
+
* than the crop box.
|
|
29
|
+
*
|
|
30
|
+
* Viewers translate these onto the stage's reveal primitive — see
|
|
31
|
+
* `destinationToReveal` in `@embedpdf/plugin-stage`.
|
|
32
|
+
*/
|
|
33
|
+
type PdfDestination = {
|
|
34
|
+
kind: 'xyz';
|
|
35
|
+
pageObjectNumber: PageObjectNumber;
|
|
36
|
+
left?: number | null;
|
|
37
|
+
top?: number | null;
|
|
38
|
+
zoom?: number | null;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'fit';
|
|
41
|
+
pageObjectNumber: PageObjectNumber;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'fitH';
|
|
44
|
+
pageObjectNumber: PageObjectNumber;
|
|
45
|
+
top?: number | null;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'fitV';
|
|
48
|
+
pageObjectNumber: PageObjectNumber;
|
|
49
|
+
left?: number | null;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'fitR';
|
|
52
|
+
pageObjectNumber: PageObjectNumber;
|
|
53
|
+
left: number;
|
|
54
|
+
bottom: number;
|
|
55
|
+
right: number;
|
|
56
|
+
top: number;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'fitB';
|
|
59
|
+
pageObjectNumber: PageObjectNumber;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'fitBH';
|
|
62
|
+
pageObjectNumber: PageObjectNumber;
|
|
63
|
+
top?: number | null;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'fitBV';
|
|
66
|
+
pageObjectNumber: PageObjectNumber;
|
|
67
|
+
left?: number | null;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* One Hide `/T` or ResetForm `/Fields` entry. Deliberately UNSCOPED: a
|
|
71
|
+
* dictionary reference carries no page, so resolution (a name to widgets, an
|
|
72
|
+
* object number to an annotation or field) is the interpreter's job — never
|
|
73
|
+
* the extractor's.
|
|
74
|
+
*/
|
|
75
|
+
type PdfActionTargetRef = {
|
|
76
|
+
kind: 'name';
|
|
77
|
+
name: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'objectNumber';
|
|
80
|
+
objectNumber: number;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Decoded SubmitForm `/Flags` word (ISO 32000-2:2020 Table 240) plus the raw
|
|
84
|
+
* value. `exclude` is DERIVED from bit 1 — never stored separately, so the
|
|
85
|
+
* two cannot disagree. Note the two easily-missed positions verified against
|
|
86
|
+
* the spec: bit 12 is `ExclFKey` (not "ExclFDFTemplate") and bit 13 is
|
|
87
|
+
* reserved/undefined, so `EmbedForm` is bit 14.
|
|
88
|
+
*/
|
|
89
|
+
interface SubmitFormFlags {
|
|
90
|
+
raw: number;
|
|
91
|
+
/** Bit 1: set → `fields` lists EXCLUDED fields. */
|
|
92
|
+
exclude: boolean;
|
|
93
|
+
/** Bit 2: submit designated valueless fields too, as name-only entries. */
|
|
94
|
+
includeNoValueFields: boolean;
|
|
95
|
+
/** Bits 3/6/9 folded into one verdict: bit 9 SubmitPDF dominates ("all
|
|
96
|
+
* other flags shall be ignored except GetMethod"), else bit 6 XFDF, else
|
|
97
|
+
* bit 3 HTML Form format, else FDF (the Table 240 default). */
|
|
98
|
+
format: 'fdf' | 'html' | 'xfdf' | 'pdf';
|
|
99
|
+
/** Bit 4. ISO makes GetMethod meaningful only with ExportFormat set, and
|
|
100
|
+
* the bit-9 rule keeps it alive for SubmitPDF — so `'get'` only for
|
|
101
|
+
* `'html'` and `'pdf'`; everything else posts. */
|
|
102
|
+
method: 'post' | 'get';
|
|
103
|
+
/** Bit 5 (meaningful only with ExportFormat; passed through — this stack
|
|
104
|
+
* does not capture click coordinates). */
|
|
105
|
+
submitCoordinates: boolean;
|
|
106
|
+
/** Bit 7 (FDF only): include incremental updates via FDF `Differences`. */
|
|
107
|
+
includeAppendSaves: boolean;
|
|
108
|
+
/** Bit 8 (FDF only): include markup annotations. */
|
|
109
|
+
includeAnnotations: boolean;
|
|
110
|
+
/** Bit 10: convert date-like values to the standard date format. */
|
|
111
|
+
canonicalFormat: boolean;
|
|
112
|
+
/** Bit 11 (FDF, with IncludeAnnotations): only the current user's
|
|
113
|
+
* annotations. */
|
|
114
|
+
exclNonUserAnnots: boolean;
|
|
115
|
+
/** Bit 12: the submitted FDF excludes its `F` entry. */
|
|
116
|
+
exclFKey: boolean;
|
|
117
|
+
/** Bit 14 (bit 13 is reserved): the FDF `F` entry embeds the source PDF. */
|
|
118
|
+
embedForm: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* SubmitForm's extracted intent. ATOMIC on purpose: either every required
|
|
122
|
+
* component resolved (a complete, executable payload) or the node carries no
|
|
123
|
+
* payload at all — partial states are unrepresentable. An unreadable
|
|
124
|
+
* REQUIRED component (`/F`) degrades the whole node to `unknown` +
|
|
125
|
+
* `payload-dropped` at read time instead.
|
|
126
|
+
*/
|
|
127
|
+
interface SubmitFormPayload {
|
|
128
|
+
/** Resolved `/F` URL — a `<< /FS /URL >>` file specification (7.11.5,
|
|
129
|
+
* `/UF` preferred over `/F` per 7.11.2); a bare string `/F` is accepted
|
|
130
|
+
* as a producer-compat extension. */
|
|
131
|
+
url: string;
|
|
132
|
+
/**
|
|
133
|
+
* `null` = `/Fields` ABSENT → Include/Exclude is ignored and every field
|
|
134
|
+
* except NoExport-flagged ones is submitted (Table 239). `[]` =
|
|
135
|
+
* present-but-empty: include mode submits NOTHING, exclude mode submits
|
|
136
|
+
* everything eligible — presence and emptiness are different states.
|
|
137
|
+
*/
|
|
138
|
+
fields: PdfActionTargetRef[] | null;
|
|
139
|
+
flags: SubmitFormFlags;
|
|
140
|
+
/** `/CharSet` (PDF 2.0), extracted but not encoded by this stack. */
|
|
141
|
+
charSet?: string;
|
|
142
|
+
}
|
|
143
|
+
interface PdfActionNodeCommon {
|
|
144
|
+
/** Raw `/S` name, retained for unknown and future action types. */
|
|
145
|
+
subtype: string;
|
|
146
|
+
/** Normalized `/Next` children in PDF order. */
|
|
147
|
+
next: PdfActionNode[];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* One detached node in a normalized PDF action tree, discriminated on the
|
|
151
|
+
* interpreter that would execute it. Every executable arm carries its full
|
|
152
|
+
* payload — a `goto` without a destination or a `uri` without a URI is
|
|
153
|
+
* unrepresentable. A payload the reader cannot materialize degrades the node
|
|
154
|
+
* to `unknown` (original `/S` kept on `subtype`) and appends the tree-level
|
|
155
|
+
* `'payload-dropped'` warning.
|
|
156
|
+
*/
|
|
157
|
+
type PdfActionNode = PdfActionNodeCommon & ({
|
|
158
|
+
type: 'javascript';
|
|
159
|
+
script: string;
|
|
160
|
+
} | {
|
|
161
|
+
type: 'goto';
|
|
162
|
+
destination: PdfDestination;
|
|
163
|
+
} | {
|
|
164
|
+
type: 'uri';
|
|
165
|
+
uri: string;
|
|
166
|
+
isMap: boolean;
|
|
167
|
+
} | {
|
|
168
|
+
type: 'named';
|
|
169
|
+
name: string;
|
|
170
|
+
} | {
|
|
171
|
+
type: 'hide';
|
|
172
|
+
targets: PdfActionTargetRef[];
|
|
173
|
+
hide: boolean;
|
|
174
|
+
} | {
|
|
175
|
+
type: 'reset-form';
|
|
176
|
+
/**
|
|
177
|
+
* `null` = `/Fields` ABSENT → reset every field (`exclude` is
|
|
178
|
+
* meaningless). `[]` = present-but-empty: with `exclude` false reset
|
|
179
|
+
* NOTHING, with `exclude` true reset EVERYTHING — PDFium's executor
|
|
180
|
+
* branches on presence first.
|
|
181
|
+
*/
|
|
182
|
+
fields: PdfActionTargetRef[] | null;
|
|
183
|
+
exclude: boolean;
|
|
184
|
+
} |
|
|
185
|
+
/** Reported, never executed. */
|
|
186
|
+
{
|
|
187
|
+
type: 'goto-remote';
|
|
188
|
+
filePath: string;
|
|
189
|
+
} | {
|
|
190
|
+
type: 'goto-embedded';
|
|
191
|
+
filePath: string;
|
|
192
|
+
} | {
|
|
193
|
+
type: 'launch';
|
|
194
|
+
filePath: string;
|
|
195
|
+
} |
|
|
196
|
+
/** ISO allows `/Rendition` to carry `/JS`; preserved, not collected. */
|
|
197
|
+
{
|
|
198
|
+
type: 'rendition';
|
|
199
|
+
script?: string;
|
|
200
|
+
} |
|
|
201
|
+
/** Recognized; executable only when `payload` is present. Absent payload
|
|
202
|
+
* = extracted by an older runtime (skew) — the node stays
|
|
203
|
+
* recognized-inert exactly as before this payload existed. */
|
|
204
|
+
{
|
|
205
|
+
type: 'submit-form';
|
|
206
|
+
payload?: SubmitFormPayload;
|
|
207
|
+
} | {
|
|
208
|
+
type: 'thread';
|
|
209
|
+
} | {
|
|
210
|
+
type: 'sound';
|
|
211
|
+
} | {
|
|
212
|
+
type: 'movie';
|
|
213
|
+
} | {
|
|
214
|
+
type: 'import-data';
|
|
215
|
+
} | {
|
|
216
|
+
type: 'set-ocg-state';
|
|
217
|
+
} | {
|
|
218
|
+
type: 'transition';
|
|
219
|
+
} | {
|
|
220
|
+
type: 'goto-3d-view';
|
|
221
|
+
} | {
|
|
222
|
+
type: 'unknown';
|
|
223
|
+
});
|
|
224
|
+
type PdfActionWarning = 'cycle-dropped' | 'malformed-next' | 'incomplete' |
|
|
225
|
+
/** A node's payload could not be read; that node degraded to `unknown`. */
|
|
226
|
+
'payload-dropped';
|
|
227
|
+
/**
|
|
228
|
+
* One extracted action root plus the native reader's safety verdict.
|
|
229
|
+
* Consumers must never execute a tree whose `incomplete` flag is true.
|
|
230
|
+
*/
|
|
231
|
+
interface PdfActionTree {
|
|
232
|
+
/** Null when the model was valid but its root exceeded a safety bound. */
|
|
233
|
+
root: PdfActionNode | null;
|
|
234
|
+
incomplete: boolean;
|
|
235
|
+
/** Raw native bits, retained so newer warnings survive older SDKs.
|
|
236
|
+
* TS-detected warnings (`payload-dropped`) appear only in `warnings`. */
|
|
237
|
+
warningFlags: number;
|
|
238
|
+
warnings: PdfActionWarning[];
|
|
239
|
+
}
|
|
240
|
+
interface PdfFieldActions {
|
|
241
|
+
keystroke?: PdfActionTree;
|
|
242
|
+
format?: PdfActionTree;
|
|
243
|
+
validate?: PdfActionTree;
|
|
244
|
+
calculate?: PdfActionTree;
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/identity/FormFieldRef.d.ts
|
|
248
|
+
/**
|
|
249
|
+
* How callers address a logical form field.
|
|
250
|
+
*
|
|
251
|
+
* - `objectNumber` — the indirect object number of the field dictionary.
|
|
252
|
+
* ISO 32000 guarantees every real AcroForm field dictionary is an
|
|
253
|
+
* indirect object, and the layer runtime never renumbers (frozen base +
|
|
254
|
+
* incremental deltas), so this is the durable identity for the lifetime
|
|
255
|
+
* of a document. Preferred for all engine calls.
|
|
256
|
+
* - `fqn` — the fully qualified field name ("billing.name"). The portable,
|
|
257
|
+
* semantic identity used by interchange formats (FDF/XFDF) and analytics;
|
|
258
|
+
* survives document rewrites but is only as unique as the producer made
|
|
259
|
+
* it. The engine resolves it against the reconciled field tree.
|
|
260
|
+
*/
|
|
261
|
+
type FormFieldRef = {
|
|
262
|
+
kind: 'objectNumber';
|
|
263
|
+
fieldObjectNumber: number;
|
|
264
|
+
} | {
|
|
265
|
+
kind: 'fqn';
|
|
266
|
+
name: string;
|
|
267
|
+
};
|
|
268
|
+
/** A widget annotation of a field, as the forms subsystem sees it. */
|
|
269
|
+
interface FormWidgetRef {
|
|
270
|
+
/**
|
|
271
|
+
* Indirect object number of the widget annotation — the join key to the
|
|
272
|
+
* annotation subsystem's `objectNumber` refs. `0` when the widget is
|
|
273
|
+
* stored as a direct object (spec-violating; cannot be addressed).
|
|
274
|
+
*/
|
|
275
|
+
annotObjectNumber: number;
|
|
276
|
+
/**
|
|
277
|
+
* Object number of the page whose /Annots array references the widget.
|
|
278
|
+
* `0` when the widget is not reachable from any page ("unplaced").
|
|
279
|
+
*/
|
|
280
|
+
pageObjectNumber: PageObjectNumber;
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/forms/value-entry.d.ts
|
|
284
|
+
/** Lossless shape of a field's effective PDF `/V` or `/DV` object. */
|
|
285
|
+
type FormValueEntry = {
|
|
286
|
+
kind: 'none';
|
|
287
|
+
} | {
|
|
288
|
+
kind: 'scalar';
|
|
289
|
+
value: string;
|
|
290
|
+
} | {
|
|
291
|
+
kind: 'array';
|
|
292
|
+
values: string[];
|
|
293
|
+
} | {
|
|
294
|
+
kind: 'unsupported';
|
|
295
|
+
};
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/forms/field.d.ts
|
|
298
|
+
/**
|
|
299
|
+
* The field family — the discriminant of {@link FormFieldDTO}. Narrowing on
|
|
300
|
+
* it reveals exactly the members that are meaningful for that family, the
|
|
301
|
+
* same way annotation DTOs narrow on `subtype`.
|
|
302
|
+
*/
|
|
303
|
+
type FormFieldFamily = 'text' | 'checkbox' | 'radio' | 'combobox' | 'listbox' | 'pushbutton' | 'signature' | 'unknown';
|
|
304
|
+
/**
|
|
305
|
+
* Where the field was found.
|
|
306
|
+
*
|
|
307
|
+
* - `acroform` — reachable from the /AcroForm /Fields tree, as the spec
|
|
308
|
+
* requires.
|
|
309
|
+
* - `recovered` — only reachable through a page's /Annots array (a common
|
|
310
|
+
* producer bug). The engine reconciles these on every read so they work
|
|
311
|
+
* like any other field, but other PDF processors will not see them until
|
|
312
|
+
* {@link DocumentFormsService.repair} makes the fix durable.
|
|
313
|
+
*/
|
|
314
|
+
type FormFieldOrigin = 'acroform' | 'recovered';
|
|
315
|
+
/**
|
|
316
|
+
* The /Ff flags every field family shares. Family-specific flags (comb,
|
|
317
|
+
* multi-select, radios-in-unison, ...) live as plain booleans on the
|
|
318
|
+
* family DTOs where they are always meaningful.
|
|
319
|
+
*/
|
|
320
|
+
interface FormFieldFlags {
|
|
321
|
+
/**
|
|
322
|
+
* The user must not change the value. The engine's write transactions
|
|
323
|
+
* still accept programmatic writes to read-only fields (calculated
|
|
324
|
+
* fields are read-only yet script-written); enforcing fill policy is
|
|
325
|
+
* the application's job.
|
|
326
|
+
*/
|
|
327
|
+
readOnly: boolean;
|
|
328
|
+
required: boolean;
|
|
329
|
+
noExport: boolean;
|
|
330
|
+
/** The raw /Ff integer, for anything not surfaced. */
|
|
331
|
+
raw: number;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* A widget of a toggle (checkbox/radio) field. Toggle widgets always carry
|
|
335
|
+
* their appearance-state machinery — no nullable fields to probe.
|
|
336
|
+
*/
|
|
337
|
+
interface ToggleFieldWidget extends FormWidgetRef {
|
|
338
|
+
/**
|
|
339
|
+
* The widget's appearance state name (the non-"Off" key of its /AP /N
|
|
340
|
+
* dictionary) — the token toggle writes address widgets by.
|
|
341
|
+
*/
|
|
342
|
+
onState: string;
|
|
343
|
+
/**
|
|
344
|
+
* The widget's export value (/Opt entry when present, else the
|
|
345
|
+
* on-state). The identity FDF/XFDF carry.
|
|
346
|
+
*/
|
|
347
|
+
exportValue: string;
|
|
348
|
+
/** Whether this widget is currently checked. */
|
|
349
|
+
checked: boolean;
|
|
350
|
+
}
|
|
351
|
+
/** One option of a choice (combo/list box) field. */
|
|
352
|
+
interface FormFieldOption {
|
|
353
|
+
/** Display label shown to the user. */
|
|
354
|
+
label: string;
|
|
355
|
+
/** Export value used by /V, interchange, and `FormFieldValue.choice`. */
|
|
356
|
+
value: string;
|
|
357
|
+
/** Whether the option is currently selected. */
|
|
358
|
+
selected: boolean;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* The trunk every field family shares: identity, provenance, universal
|
|
362
|
+
* flags, and widget placement. A logical field is the document-scoped
|
|
363
|
+
* record that holds the value; its widgets are page-scoped views — join
|
|
364
|
+
* them to the annotation subsystem via `annotObjectNumber`.
|
|
365
|
+
*/
|
|
366
|
+
interface FormFieldBase {
|
|
367
|
+
/** Durable ref (`objectNumber` whenever the field dictionary is indirect). */
|
|
368
|
+
ref: FormFieldRef;
|
|
369
|
+
/** Field dictionary object number; `0` for direct (spec-violating) dicts. */
|
|
370
|
+
fieldObjectNumber: number;
|
|
371
|
+
/** Fully qualified name, e.g. `"billing.name"`. */
|
|
372
|
+
name: string;
|
|
373
|
+
family: FormFieldFamily;
|
|
374
|
+
origin: FormFieldOrigin;
|
|
375
|
+
flags: FormFieldFlags;
|
|
376
|
+
/** /TU — the accessible tooltip / alternate name. */
|
|
377
|
+
alternateName: string | null;
|
|
378
|
+
/** /TM — the export mapping name. */
|
|
379
|
+
mappingName: string | null;
|
|
380
|
+
/** Exact effective `/V` object shape; family conveniences below are derived. */
|
|
381
|
+
valueEntry: FormValueEntry;
|
|
382
|
+
/** Exact effective `/DV` object shape, including absent and malformed values. */
|
|
383
|
+
defaultValueEntry: FormValueEntry;
|
|
384
|
+
/** Effective inherited field `/AA` actions. */
|
|
385
|
+
actions?: PdfFieldActions;
|
|
386
|
+
/** The field's widget annotations, in control order. May be empty ("unplaced"). */
|
|
387
|
+
widgets: FormWidgetRef[];
|
|
388
|
+
}
|
|
389
|
+
/** A text field. Write with `{ type: 'text', value }`. */
|
|
390
|
+
interface TextFieldDTO extends FormFieldBase {
|
|
391
|
+
family: 'text';
|
|
392
|
+
value: string;
|
|
393
|
+
/** /DV — restored by `reset()`. */
|
|
394
|
+
defaultValue: string;
|
|
395
|
+
/** /MaxLen; `null` when unlimited. Longer writes are truncated to this length. */
|
|
396
|
+
maxLength: number | null;
|
|
397
|
+
multiline: boolean;
|
|
398
|
+
password: boolean;
|
|
399
|
+
/** Fixed character cells; meaningful with `maxLength`. */
|
|
400
|
+
comb: boolean;
|
|
401
|
+
}
|
|
402
|
+
/** A checkbox. Write with `{ type: 'toggle', state: onState | null }`. */
|
|
403
|
+
interface CheckboxFieldDTO extends FormFieldBase {
|
|
404
|
+
family: 'checkbox';
|
|
405
|
+
checked: boolean;
|
|
406
|
+
/** The export value reported while checked ("Off" is never exported). */
|
|
407
|
+
exportValue: string;
|
|
408
|
+
widgets: ToggleFieldWidget[];
|
|
409
|
+
}
|
|
410
|
+
/** A radio group: ONE field, N widgets. Write with `{ type: 'toggle', state }`. */
|
|
411
|
+
interface RadioFieldDTO extends FormFieldBase {
|
|
412
|
+
family: 'radio';
|
|
413
|
+
/** The checked widget's export value, or `"Off"` when the group is clear. */
|
|
414
|
+
value: string;
|
|
415
|
+
/** Widgets sharing an export value check together. */
|
|
416
|
+
radiosInUnison: boolean;
|
|
417
|
+
/** The group cannot be cleared once a choice is made. */
|
|
418
|
+
noToggleToOff: boolean;
|
|
419
|
+
widgets: ToggleFieldWidget[];
|
|
420
|
+
}
|
|
421
|
+
/** A combo box (dropdown). Write with `{ type: 'choice', values: [v] }`. */
|
|
422
|
+
interface ComboBoxFieldDTO extends FormFieldBase {
|
|
423
|
+
family: 'combobox';
|
|
424
|
+
/** An option export value — or free text when `edit` is set. */
|
|
425
|
+
value: string;
|
|
426
|
+
/** /DV — restored by `reset()`. */
|
|
427
|
+
defaultValue: string;
|
|
428
|
+
/** Free text is allowed in addition to the options. */
|
|
429
|
+
edit: boolean;
|
|
430
|
+
options: FormFieldOption[];
|
|
431
|
+
}
|
|
432
|
+
/** A list box. Write with `{ type: 'choice', values }`. */
|
|
433
|
+
interface ListBoxFieldDTO extends FormFieldBase {
|
|
434
|
+
family: 'listbox';
|
|
435
|
+
/** Selected option export values, in option order. */
|
|
436
|
+
selectedValues: string[];
|
|
437
|
+
/** Whether several options may be selected at once. */
|
|
438
|
+
multiSelect: boolean;
|
|
439
|
+
options: FormFieldOption[];
|
|
440
|
+
}
|
|
441
|
+
/** A push button: pure trigger, holds no value. Never written or exported. */
|
|
442
|
+
interface PushButtonFieldDTO extends FormFieldBase {
|
|
443
|
+
family: 'pushbutton';
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* A signature field. Identity and placement only for now — the engine
|
|
447
|
+
* never writes signature values; signing is a future capability.
|
|
448
|
+
*/
|
|
449
|
+
interface SignatureFieldDTO extends FormFieldBase {
|
|
450
|
+
family: 'signature';
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Forward-compat placeholder for field types the engine does not model,
|
|
454
|
+
* mirroring the `unsupported` annotation kind. Round-trips safely.
|
|
455
|
+
*/
|
|
456
|
+
interface UnknownFieldDTO extends FormFieldBase {
|
|
457
|
+
family: 'unknown';
|
|
458
|
+
/** The raw /V value as text, for diagnostics. */
|
|
459
|
+
rawValue: string;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* A logical form field. Discriminated on `family`:
|
|
463
|
+
*
|
|
464
|
+
* ```ts
|
|
465
|
+
* if (field.family === 'listbox') {
|
|
466
|
+
* field.selectedValues; // string[]
|
|
467
|
+
* }
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
type FormFieldDTO = TextFieldDTO | CheckboxFieldDTO | RadioFieldDTO | ComboBoxFieldDTO | ListBoxFieldDTO | PushButtonFieldDTO | SignatureFieldDTO | UnknownFieldDTO;
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/forms/snapshot.d.ts
|
|
473
|
+
/**
|
|
474
|
+
* What kind of interactive form the document declares.
|
|
475
|
+
*
|
|
476
|
+
* - `none` — no /AcroForm dictionary. Recovered fields may still exist
|
|
477
|
+
* (see {@link FormFieldOrigin}); `repair()` can bootstrap the dictionary.
|
|
478
|
+
* - `acroform` — a standard AcroForm.
|
|
479
|
+
* - `xfa` — the /AcroForm carries an /XFA entry. The engine serves the
|
|
480
|
+
* AcroForm shell read-only and never executes XFA.
|
|
481
|
+
*/
|
|
482
|
+
type FormKind = 'none' | 'acroform' | 'xfa';
|
|
483
|
+
/**
|
|
484
|
+
* The document's complete form state at one instant: the reconciled field
|
|
485
|
+
* tree flattened to terminal fields with fully qualified names.
|
|
486
|
+
*
|
|
487
|
+
* Snapshots are detached and immutable — any mutation (a value write, an
|
|
488
|
+
* annotation edit, a page operation) makes previously returned snapshots
|
|
489
|
+
* stale. Re-read after mutating; the engine caches the underlying model
|
|
490
|
+
* per document version, so repeated reads between mutations are cheap.
|
|
491
|
+
*/
|
|
492
|
+
interface FormSnapshot {
|
|
493
|
+
formKind: FormKind;
|
|
494
|
+
/**
|
|
495
|
+
* Whether the /AcroForm sets /NeedAppearances (viewer-generated widget
|
|
496
|
+
* appearances). The engine bakes appearances on every write regardless;
|
|
497
|
+
* `repair({ bakeAppearances: true })` can clear the flag document-wide.
|
|
498
|
+
*/
|
|
499
|
+
needsAppearances: boolean;
|
|
500
|
+
fields: FormFieldDTO[];
|
|
501
|
+
/** `/AcroForm /CO` order; null preserves each malformed/unresolved slot. */
|
|
502
|
+
calculationOrder: Array<FormFieldRef | null>;
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/search/types.d.ts
|
|
506
|
+
/**
|
|
507
|
+
* What to search for — THE one shape, engine → wire → plugin state →
|
|
508
|
+
* search box. One flat object; the flags define behavior per mode instead
|
|
509
|
+
* of the mode changing the shape:
|
|
510
|
+
*
|
|
511
|
+
* | flag | literal | regex |
|
|
512
|
+
* |-------------------|------------------|--------------------------------|
|
|
513
|
+
* | `matchCase` | fold case | `i` flag |
|
|
514
|
+
* | `wholeWord` | boundary check | pattern is `\b(?:…)\b`-wrapped |
|
|
515
|
+
* | `matchDiacritics` | mark fold | REJECTED (`InvalidArg`) |
|
|
516
|
+
*
|
|
517
|
+
* Literal queries match over FOLDED text; regex queries run the portable
|
|
518
|
+
* dialect against the RAW page text — which is why `matchDiacritics`
|
|
519
|
+
* cannot apply to them (diacritic folding is a property of the folded
|
|
520
|
+
* text plane). Validate with `validateSearchQuery` for early UI feedback;
|
|
521
|
+
* engines re-validate and reject with `EngineErrorCode.InvalidArg`.
|
|
522
|
+
*/
|
|
523
|
+
interface SearchQuery {
|
|
524
|
+
/**
|
|
525
|
+
* The literal text — or, when `regex`, a pattern in the portable
|
|
526
|
+
* search-regex dialect: JavaScript `u`-mode syntax MINUS backreferences
|
|
527
|
+
* and lookaround, so every valid pattern also runs on RE2 (the
|
|
528
|
+
* server-side engine).
|
|
529
|
+
*/
|
|
530
|
+
text: string;
|
|
531
|
+
/** Interpret `text` as a regex pattern. Default false (literal). */
|
|
532
|
+
regex?: boolean;
|
|
533
|
+
/** Exact-case matching. Default false (case-folded / `i` semantics). */
|
|
534
|
+
matchCase?: boolean;
|
|
535
|
+
/** Only match at word boundaries (letters/digits end the word). */
|
|
536
|
+
wholeWord?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Treat diacritics as significant ("café" ≠ "cafe"). Default false —
|
|
539
|
+
* marks are stripped on both sides, which is what viewers ship.
|
|
540
|
+
* LITERAL ONLY: combined with `regex` the query is rejected.
|
|
541
|
+
*/
|
|
542
|
+
matchDiacritics?: boolean;
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
545
|
+
export { SearchQuery as n, FormSnapshot as t };
|
|
546
|
+
//# sourceMappingURL=AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.ts.map
|
package/dist/actions.cjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _embedpdf_web = require("@embedpdf/web");
|
|
5
|
+
let _embedpdf_plugin_stage_contract = require("@embedpdf/plugin-stage/contract");
|
|
6
|
+
let _embedpdf_plugin_actions = require("@embedpdf/plugin-actions");
|
|
7
|
+
//#region src/actions.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Install the UI adapter for the active document's action dispatcher. The
|
|
10
|
+
* DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
|
|
11
|
+
* URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
|
|
12
|
+
* `createDefaultActionsUiAdapter`, written ONCE for every binding; this
|
|
13
|
+
* hook is React glue only (late-bound handlers, stage navigation,
|
|
14
|
+
* identity-safe install/uninstall). The doc.print AUTHORITY gate is
|
|
15
|
+
* upstream (the actions plugin) and not overridable.
|
|
16
|
+
*/
|
|
17
|
+
function useActionsUiAdapter(handlers) {
|
|
18
|
+
const actions = require_runtime.useOptionalCapability(_embedpdf_plugin_actions.ActionsToken);
|
|
19
|
+
const stage = require_runtime.useOptionalCapability(_embedpdf_plugin_stage_contract.StageToken);
|
|
20
|
+
const handlersRef = (0, react.useRef)(handlers);
|
|
21
|
+
handlersRef.current = handlers;
|
|
22
|
+
(0, react.useEffect)(() => {
|
|
23
|
+
if (!actions) return;
|
|
24
|
+
const adapter = (0, _embedpdf_web.createDefaultActionsUiAdapter)({
|
|
25
|
+
overrides: () => handlersRef.current,
|
|
26
|
+
goToPage: (page) => stage?.goToPage(page)
|
|
27
|
+
});
|
|
28
|
+
return actions.setUiAdapter(adapter);
|
|
29
|
+
}, [actions, stage]);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.useActionsUiAdapter = useActionsUiAdapter;
|
|
33
|
+
Object.keys(_embedpdf_plugin_actions).forEach(function(k) {
|
|
34
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function() {
|
|
37
|
+
return _embedpdf_plugin_actions[k];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=actions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.cjs","names":["useOptionalCapability","ActionsToken","StageToken"],"sources":["../src/actions.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-actions — the action engine's UI port.\n *\n * The plugin is DOM-free; opening tabs and printing are this layer's job.\n * `useActionsUiAdapter()` installs the browser-default adapter (the same\n * sanitizer + window.open the link layer uses; print = the browser dialog),\n * overridable per handler. Without it, `adapter`-routed actions (URI, Print)\n * report `no-adapter` diagnostics instead of executing.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-actions';\nimport { useEffect, useRef } from 'react';\nimport { ActionsToken, type ActionUiAdapter } from '@embedpdf/plugin-actions';\nimport { StageToken } from '@embedpdf/plugin-stage/contract';\nimport { createDefaultActionsUiAdapter } from '@embedpdf/web';\n\nimport { useOptionalCapability } from './runtime';\n\n/** Override any subset of the default adapter policy. */\nexport type ActionsUiHandlers = Partial<ActionUiAdapter>;\n\n/**\n * Install the UI adapter for the active document's action dispatcher. The\n * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri\n * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s\n * `createDefaultActionsUiAdapter`, written ONCE for every binding; this\n * hook is React glue only (late-bound handlers, stage navigation,\n * identity-safe install/uninstall). The doc.print AUTHORITY gate is\n * upstream (the actions plugin) and not overridable.\n */\nexport function useActionsUiAdapter(handlers?: ActionsUiHandlers): void {\n const actions = useOptionalCapability(ActionsToken);\n const stage = useOptionalCapability(StageToken);\n const handlersRef = useRef(handlers);\n handlersRef.current = handlers;\n\n useEffect(() => {\n if (!actions) return;\n const adapter: ActionUiAdapter = createDefaultActionsUiAdapter({\n overrides: () => handlersRef.current,\n goToPage: (page) => stage?.goToPage(page),\n });\n return actions.setUiAdapter(adapter);\n }, [actions, stage]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,SAAgB,oBAAoB,UAAoC;CACtE,MAAM,UAAUA,gBAAAA,sBAAsBC,yBAAAA,YAAY;CAClD,MAAM,QAAQD,gBAAAA,sBAAsBE,gCAAAA,UAAU;CAC9C,MAAM,eAAA,GAAA,MAAA,OAAA,CAAqB,QAAQ;CACnC,YAAY,UAAU;CAEtB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAA,GAAA,cAAA,8BAAA,CAAyD;GAC7D,iBAAiB,YAAY;GAC7B,WAAW,SAAS,OAAO,SAAS,IAAI;EAC1C,CAAC;EACD,OAAO,QAAQ,aAAa,OAAO;CACrC,GAAG,CAAC,SAAS,KAAK,CAAC;AACrB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionUiAdapter } from "@embedpdf/plugin-actions";
|
|
2
|
+
export * from "@embedpdf/plugin-actions";
|
|
3
|
+
//#region src/actions.d.ts
|
|
4
|
+
/** Override any subset of the default adapter policy. */
|
|
5
|
+
type ActionsUiHandlers = Partial<ActionUiAdapter>;
|
|
6
|
+
/**
|
|
7
|
+
* Install the UI adapter for the active document's action dispatcher. The
|
|
8
|
+
* DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
|
|
9
|
+
* URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
|
|
10
|
+
* `createDefaultActionsUiAdapter`, written ONCE for every binding; this
|
|
11
|
+
* hook is React glue only (late-bound handlers, stage navigation,
|
|
12
|
+
* identity-safe install/uninstall). The doc.print AUTHORITY gate is
|
|
13
|
+
* upstream (the actions plugin) and not overridable.
|
|
14
|
+
*/
|
|
15
|
+
declare function useActionsUiAdapter(handlers?: ActionsUiHandlers): void;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ActionsUiHandlers, useActionsUiAdapter };
|
|
18
|
+
//# sourceMappingURL=actions.d.cts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionUiAdapter } from "@embedpdf/plugin-actions";
|
|
2
|
+
export * from "@embedpdf/plugin-actions";
|
|
3
|
+
//#region src/actions.d.ts
|
|
4
|
+
/** Override any subset of the default adapter policy. */
|
|
5
|
+
type ActionsUiHandlers = Partial<ActionUiAdapter>;
|
|
6
|
+
/**
|
|
7
|
+
* Install the UI adapter for the active document's action dispatcher. The
|
|
8
|
+
* DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
|
|
9
|
+
* URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
|
|
10
|
+
* `createDefaultActionsUiAdapter`, written ONCE for every binding; this
|
|
11
|
+
* hook is React glue only (late-bound handlers, stage navigation,
|
|
12
|
+
* identity-safe install/uninstall). The doc.print AUTHORITY gate is
|
|
13
|
+
* upstream (the actions plugin) and not overridable.
|
|
14
|
+
*/
|
|
15
|
+
declare function useActionsUiAdapter(handlers?: ActionsUiHandlers): void;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ActionsUiHandlers, useActionsUiAdapter };
|
|
18
|
+
//# sourceMappingURL=actions.d.ts.map
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useOptionalCapability } from "./runtime.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { createDefaultActionsUiAdapter } from "@embedpdf/web";
|
|
4
|
+
import { StageToken } from "@embedpdf/plugin-stage/contract";
|
|
5
|
+
import { ActionsToken } from "@embedpdf/plugin-actions";
|
|
6
|
+
export * from "@embedpdf/plugin-actions";
|
|
7
|
+
//#region src/actions.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Install the UI adapter for the active document's action dispatcher. The
|
|
10
|
+
* DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri
|
|
11
|
+
* URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s
|
|
12
|
+
* `createDefaultActionsUiAdapter`, written ONCE for every binding; this
|
|
13
|
+
* hook is React glue only (late-bound handlers, stage navigation,
|
|
14
|
+
* identity-safe install/uninstall). The doc.print AUTHORITY gate is
|
|
15
|
+
* upstream (the actions plugin) and not overridable.
|
|
16
|
+
*/
|
|
17
|
+
function useActionsUiAdapter(handlers) {
|
|
18
|
+
const actions = useOptionalCapability(ActionsToken);
|
|
19
|
+
const stage = useOptionalCapability(StageToken);
|
|
20
|
+
const handlersRef = useRef(handlers);
|
|
21
|
+
handlersRef.current = handlers;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!actions) return;
|
|
24
|
+
const adapter = createDefaultActionsUiAdapter({
|
|
25
|
+
overrides: () => handlersRef.current,
|
|
26
|
+
goToPage: (page) => stage?.goToPage(page)
|
|
27
|
+
});
|
|
28
|
+
return actions.setUiAdapter(adapter);
|
|
29
|
+
}, [actions, stage]);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { useActionsUiAdapter };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","names":[],"sources":["../src/actions.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-actions — the action engine's UI port.\n *\n * The plugin is DOM-free; opening tabs and printing are this layer's job.\n * `useActionsUiAdapter()` installs the browser-default adapter (the same\n * sanitizer + window.open the link layer uses; print = the browser dialog),\n * overridable per handler. Without it, `adapter`-routed actions (URI, Print)\n * report `no-adapter` diagnostics instead of executing.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-actions';\nimport { useEffect, useRef } from 'react';\nimport { ActionsToken, type ActionUiAdapter } from '@embedpdf/plugin-actions';\nimport { StageToken } from '@embedpdf/plugin-stage/contract';\nimport { createDefaultActionsUiAdapter } from '@embedpdf/web';\n\nimport { useOptionalCapability } from './runtime';\n\n/** Override any subset of the default adapter policy. */\nexport type ActionsUiHandlers = Partial<ActionUiAdapter>;\n\n/**\n * Install the UI adapter for the active document's action dispatcher. The\n * DEFAULT policy — the origin×phase visibility matrix, sanitizeExternalUri\n * URI opens, browser print/alert fallbacks — is `@embedpdf/web`'s\n * `createDefaultActionsUiAdapter`, written ONCE for every binding; this\n * hook is React glue only (late-bound handlers, stage navigation,\n * identity-safe install/uninstall). The doc.print AUTHORITY gate is\n * upstream (the actions plugin) and not overridable.\n */\nexport function useActionsUiAdapter(handlers?: ActionsUiHandlers): void {\n const actions = useOptionalCapability(ActionsToken);\n const stage = useOptionalCapability(StageToken);\n const handlersRef = useRef(handlers);\n handlersRef.current = handlers;\n\n useEffect(() => {\n if (!actions) return;\n const adapter: ActionUiAdapter = createDefaultActionsUiAdapter({\n overrides: () => handlersRef.current,\n goToPage: (page) => stage?.goToPage(page),\n });\n return actions.setUiAdapter(adapter);\n }, [actions, stage]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,SAAgB,oBAAoB,UAAoC;CACtE,MAAM,UAAU,sBAAsB,YAAY;CAClD,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CAEtB,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,UAA2B,8BAA8B;GAC7D,iBAAiB,YAAY;GAC7B,WAAW,SAAS,OAAO,SAAS,IAAI;EAC1C,CAAC;EACD,OAAO,QAAQ,aAAa,OAAO;CACrC,GAAG,CAAC,SAAS,KAAK,CAAC;AACrB"}
|