@embedpdf/react 3.0.0-next.1 → 3.0.0-next.10

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 (104) hide show
  1. package/dist/AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.cts +347 -0
  2. package/dist/AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.ts +347 -0
  3. package/dist/anchored.cjs +89 -0
  4. package/dist/anchored.cjs.map +1 -0
  5. package/dist/anchored.d.cts +45 -0
  6. package/dist/anchored.d.ts +45 -0
  7. package/dist/anchored.js +60 -0
  8. package/dist/anchored.js.map +1 -0
  9. package/dist/annotation-menu.cjs +33 -84
  10. package/dist/annotation-menu.cjs.map +1 -1
  11. package/dist/annotation-menu.d.cts +28 -2
  12. package/dist/annotation-menu.d.ts +28 -2
  13. package/dist/annotation-menu.js +27 -78
  14. package/dist/annotation-menu.js.map +1 -1
  15. package/dist/annotation.cjs +752 -16
  16. package/dist/annotation.cjs.map +1 -0
  17. package/dist/annotation.d.cts +159 -2
  18. package/dist/annotation.d.ts +159 -2
  19. package/dist/annotation.js +737 -3
  20. package/dist/annotation.js.map +1 -0
  21. package/dist/commands.js +1 -0
  22. package/dist/commands.js.map +1 -1
  23. package/dist/form.cjs +3 -3
  24. package/dist/form.cjs.map +1 -1
  25. package/dist/form.d.cts +2 -2
  26. package/dist/form.d.ts +2 -2
  27. package/dist/form.js +3 -3
  28. package/dist/form.js.map +1 -1
  29. package/dist/index.cjs +34 -5
  30. package/dist/index.d.cts +14 -8
  31. package/dist/index.d.ts +14 -8
  32. package/dist/index.js +8 -6
  33. package/dist/interaction.cjs +17 -4
  34. package/dist/interaction.cjs.map +1 -1
  35. package/dist/interaction.d.cts +2 -2
  36. package/dist/interaction.d.ts +2 -2
  37. package/dist/interaction.js +7 -5
  38. package/dist/interaction.js.map +1 -1
  39. package/dist/link.cjs +29 -6
  40. package/dist/link.cjs.map +1 -1
  41. package/dist/link.d.cts +12 -3
  42. package/dist/link.d.ts +12 -3
  43. package/dist/link.js +31 -8
  44. package/dist/link.js.map +1 -1
  45. package/dist/metadata.js +1 -0
  46. package/dist/metadata.js.map +1 -1
  47. package/dist/page-edit.js +1 -0
  48. package/dist/page-edit.js.map +1 -1
  49. package/dist/page-view.cjs +62 -38
  50. package/dist/page-view.cjs.map +1 -1
  51. package/dist/page-view.js +59 -37
  52. package/dist/page-view.js.map +1 -1
  53. package/dist/redaction.js +1 -0
  54. package/dist/redaction.js.map +1 -1
  55. package/dist/render.cjs +67 -50
  56. package/dist/render.cjs.map +1 -1
  57. package/dist/render.d.cts +6 -19
  58. package/dist/render.d.ts +6 -19
  59. package/dist/render.js +71 -52
  60. package/dist/render.js.map +1 -1
  61. package/dist/rolldown-runtime-BBjsoOtd.js +27 -0
  62. package/dist/{runtime-DV98q7I0.d.ts → runtime-Cvi0wQ4d.d.cts} +23 -10
  63. package/dist/{runtime-CMxIuF2O.d.cts → runtime-DXxr8T4L.d.ts} +23 -10
  64. package/dist/runtime.cjs +6 -5
  65. package/dist/runtime.cjs.map +1 -1
  66. package/dist/runtime.d.cts +1 -1
  67. package/dist/runtime.d.ts +1 -1
  68. package/dist/runtime.js +7 -5
  69. package/dist/runtime.js.map +1 -1
  70. package/dist/search.cjs +36 -19
  71. package/dist/search.cjs.map +1 -1
  72. package/dist/search.d.cts +1 -1
  73. package/dist/search.d.ts +1 -1
  74. package/dist/search.js +36 -19
  75. package/dist/search.js.map +1 -1
  76. package/dist/selection.cjs +217 -22
  77. package/dist/selection.cjs.map +1 -1
  78. package/dist/selection.d.cts +60 -2
  79. package/dist/selection.d.ts +60 -2
  80. package/dist/selection.js +214 -27
  81. package/dist/selection.js.map +1 -1
  82. package/dist/shell.js +1 -0
  83. package/dist/shell.js.map +1 -1
  84. package/dist/stage.cjs +47 -146
  85. package/dist/stage.cjs.map +1 -1
  86. package/dist/stage.d.cts +18 -5
  87. package/dist/stage.d.ts +18 -5
  88. package/dist/stage.js +50 -148
  89. package/dist/stage.js.map +1 -1
  90. package/dist/stamp.js +1 -0
  91. package/dist/stamp.js.map +1 -1
  92. package/dist/toolbar.js +1 -0
  93. package/dist/toolbar.js.map +1 -1
  94. package/dist/views.js +1 -0
  95. package/dist/views.js.map +1 -1
  96. package/package.json +27 -26
  97. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts +0 -2593
  98. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts +0 -2593
  99. package/dist/annotation-B6jwfTCh.d.cts +0 -173
  100. package/dist/annotation-Ct6dFtzJ.cjs +0 -913
  101. package/dist/annotation-Ct6dFtzJ.cjs.map +0 -1
  102. package/dist/annotation-DjGWJljY.js +0 -829
  103. package/dist/annotation-DjGWJljY.js.map +0 -1
  104. package/dist/annotation-nUMefyjw.d.ts +0 -173
@@ -1,2593 +0,0 @@
1
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.d.cts
2
- type Primitive = string | number | symbol | bigint | boolean | null | undefined;
3
- //#endregion
4
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.d.cts
5
- declare namespace util {
6
- type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends (<V>() => V extends U ? 1 : 2) ? true : false;
7
- export type isAny<T> = 0 extends 1 & T ? true : false;
8
- export const assertEqual: <A, B>(_: AssertEqual<A, B>) => void;
9
- export function assertIs<T>(_arg: T): void;
10
- export function assertNever(_x: never): never;
11
- export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
12
- export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
13
- export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
14
- export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
15
- export type InexactPartial<T> = { [k in keyof T]?: T[k] | undefined; };
16
- export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
17
- export const getValidEnumValues: (obj: any) => any[];
18
- export const objectValues: (obj: any) => any[];
19
- export const objectKeys: ObjectConstructor["keys"];
20
- export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
21
- export type identity<T> = objectUtil.identity<T>;
22
- export type flatten<T> = objectUtil.flatten<T>;
23
- export type noUndefined<T> = T extends undefined ? never : T;
24
- export const isInteger: NumberConstructor["isInteger"];
25
- export function joinValues<T extends any[]>(array: T, separator?: string): string;
26
- export const jsonStringifyReplacer: (_: string, value: any) => any;
27
- export {};
28
- }
29
- declare namespace objectUtil {
30
- export type MergeShapes<U, V> = keyof U & keyof V extends never ? U & V : { [k in Exclude<keyof U, keyof V>]: U[k]; } & V;
31
- type optionalKeys<T extends object> = { [k in keyof T]: undefined extends T[k] ? k : never; }[keyof T];
32
- type requiredKeys<T extends object> = { [k in keyof T]: undefined extends T[k] ? never : k; }[keyof T];
33
- export type addQuestionMarks<T extends object, _O = any> = { [K in requiredKeys<T>]: T[K]; } & { [K in optionalKeys<T>]?: T[K]; } & { [k in keyof T]?: unknown; };
34
- export type identity<T> = T;
35
- export type flatten<T> = identity<{ [k in keyof T]: T[k]; }>;
36
- export type noNeverKeys<T> = { [k in keyof T]: [T[k]] extends [never] ? never : k; }[keyof T];
37
- export type noNever<T> = identity<{ [k in noNeverKeys<T>]: k extends keyof T ? T[k] : never; }>;
38
- export const mergeShapes: <U, T>(first: U, second: T) => T & U;
39
- export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never ? A & B : { [K in keyof A as K extends keyof B ? never : K]: A[K]; } & { [K in keyof B]: B[K]; };
40
- export {};
41
- }
42
- declare const ZodParsedType: {
43
- string: "string";
44
- nan: "nan";
45
- number: "number";
46
- integer: "integer";
47
- float: "float";
48
- boolean: "boolean";
49
- date: "date";
50
- bigint: "bigint";
51
- symbol: "symbol";
52
- function: "function";
53
- undefined: "undefined";
54
- null: "null";
55
- array: "array";
56
- object: "object";
57
- unknown: "unknown";
58
- promise: "promise";
59
- void: "void";
60
- never: "never";
61
- map: "map";
62
- set: "set";
63
- };
64
- type ZodParsedType = keyof typeof ZodParsedType;
65
- //#endregion
66
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.d.cts
67
- type allKeys<T> = T extends any ? keyof T : never;
68
- type typeToFlattenedError<T, U = string> = {
69
- formErrors: U[];
70
- fieldErrors: { [P in allKeys<T>]?: U[]; };
71
- };
72
- declare const ZodIssueCode: {
73
- invalid_type: "invalid_type";
74
- invalid_literal: "invalid_literal";
75
- custom: "custom";
76
- invalid_union: "invalid_union";
77
- invalid_union_discriminator: "invalid_union_discriminator";
78
- invalid_enum_value: "invalid_enum_value";
79
- unrecognized_keys: "unrecognized_keys";
80
- invalid_arguments: "invalid_arguments";
81
- invalid_return_type: "invalid_return_type";
82
- invalid_date: "invalid_date";
83
- invalid_string: "invalid_string";
84
- too_small: "too_small";
85
- too_big: "too_big";
86
- invalid_intersection_types: "invalid_intersection_types";
87
- not_multiple_of: "not_multiple_of";
88
- not_finite: "not_finite";
89
- };
90
- type ZodIssueCode = keyof typeof ZodIssueCode;
91
- type ZodIssueBase = {
92
- path: (string | number)[];
93
- message?: string | undefined;
94
- };
95
- interface ZodInvalidTypeIssue extends ZodIssueBase {
96
- code: typeof ZodIssueCode.invalid_type;
97
- expected: ZodParsedType;
98
- received: ZodParsedType;
99
- }
100
- interface ZodInvalidLiteralIssue extends ZodIssueBase {
101
- code: typeof ZodIssueCode.invalid_literal;
102
- expected: unknown;
103
- received: unknown;
104
- }
105
- interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
106
- code: typeof ZodIssueCode.unrecognized_keys;
107
- keys: string[];
108
- }
109
- interface ZodInvalidUnionIssue extends ZodIssueBase {
110
- code: typeof ZodIssueCode.invalid_union;
111
- unionErrors: ZodError[];
112
- }
113
- interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
114
- code: typeof ZodIssueCode.invalid_union_discriminator;
115
- options: Primitive[];
116
- }
117
- interface ZodInvalidEnumValueIssue extends ZodIssueBase {
118
- received: string | number;
119
- code: typeof ZodIssueCode.invalid_enum_value;
120
- options: (string | number)[];
121
- }
122
- interface ZodInvalidArgumentsIssue extends ZodIssueBase {
123
- code: typeof ZodIssueCode.invalid_arguments;
124
- argumentsError: ZodError;
125
- }
126
- interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
127
- code: typeof ZodIssueCode.invalid_return_type;
128
- returnTypeError: ZodError;
129
- }
130
- interface ZodInvalidDateIssue extends ZodIssueBase {
131
- code: typeof ZodIssueCode.invalid_date;
132
- }
133
- type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "cidr" | "base64" | "jwt" | "base64url" | {
134
- includes: string;
135
- position?: number | undefined;
136
- } | {
137
- startsWith: string;
138
- } | {
139
- endsWith: string;
140
- };
141
- interface ZodInvalidStringIssue extends ZodIssueBase {
142
- code: typeof ZodIssueCode.invalid_string;
143
- validation: StringValidation;
144
- }
145
- interface ZodTooSmallIssue extends ZodIssueBase {
146
- code: typeof ZodIssueCode.too_small;
147
- minimum: number | bigint;
148
- inclusive: boolean;
149
- exact?: boolean;
150
- type: "array" | "string" | "number" | "set" | "date" | "bigint";
151
- }
152
- interface ZodTooBigIssue extends ZodIssueBase {
153
- code: typeof ZodIssueCode.too_big;
154
- maximum: number | bigint;
155
- inclusive: boolean;
156
- exact?: boolean;
157
- type: "array" | "string" | "number" | "set" | "date" | "bigint";
158
- }
159
- interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
160
- code: typeof ZodIssueCode.invalid_intersection_types;
161
- }
162
- interface ZodNotMultipleOfIssue extends ZodIssueBase {
163
- code: typeof ZodIssueCode.not_multiple_of;
164
- multipleOf: number | bigint;
165
- }
166
- interface ZodNotFiniteIssue extends ZodIssueBase {
167
- code: typeof ZodIssueCode.not_finite;
168
- }
169
- interface ZodCustomIssue extends ZodIssueBase {
170
- code: typeof ZodIssueCode.custom;
171
- params?: {
172
- [k: string]: any;
173
- };
174
- }
175
- type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;
176
- type ZodIssue = ZodIssueOptionalMessage & {
177
- fatal?: boolean | undefined;
178
- message: string;
179
- };
180
- type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? { [K in keyof T]?: ZodFormattedError<T[K]>; } : T extends any[] ? {
181
- [k: number]: ZodFormattedError<T[number]>;
182
- } : T extends object ? { [K in keyof T]?: ZodFormattedError<T[K]>; } : unknown;
183
- type ZodFormattedError<T, U = string> = {
184
- _errors: U[];
185
- } & recursiveZodFormattedError<NonNullable<T>>;
186
- declare class ZodError<T = any> extends Error {
187
- issues: ZodIssue[];
188
- get errors(): ZodIssue[];
189
- constructor(issues: ZodIssue[]);
190
- format(): ZodFormattedError<T>;
191
- format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
192
- static create: (issues: ZodIssue[]) => ZodError<any>;
193
- static assert(value: unknown): asserts value is ZodError;
194
- toString(): string;
195
- get message(): string;
196
- get isEmpty(): boolean;
197
- addIssue: (sub: ZodIssue) => void;
198
- addIssues: (subs?: ZodIssue[]) => void;
199
- flatten(): typeToFlattenedError<T>;
200
- flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
201
- get formErrors(): typeToFlattenedError<T, string>;
202
- }
203
- type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
204
- type IssueData = stripPath<ZodIssueOptionalMessage> & {
205
- path?: (string | number)[];
206
- fatal?: boolean | undefined;
207
- };
208
- type ErrorMapCtx = {
209
- defaultError: string;
210
- data: any;
211
- };
212
- type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
213
- message: string;
214
- };
215
- //#endregion
216
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.d.cts
217
- type ParseParams = {
218
- path: (string | number)[];
219
- errorMap: ZodErrorMap;
220
- async: boolean;
221
- };
222
- type ParsePathComponent = string | number;
223
- type ParsePath = ParsePathComponent[];
224
- interface ParseContext {
225
- readonly common: {
226
- readonly issues: ZodIssue[];
227
- readonly contextualErrorMap?: ZodErrorMap | undefined;
228
- readonly async: boolean;
229
- };
230
- readonly path: ParsePath;
231
- readonly schemaErrorMap?: ZodErrorMap | undefined;
232
- readonly parent: ParseContext | null;
233
- readonly data: any;
234
- readonly parsedType: ZodParsedType;
235
- }
236
- type ParseInput = {
237
- data: any;
238
- path: (string | number)[];
239
- parent: ParseContext;
240
- };
241
- declare class ParseStatus {
242
- value: "aborted" | "dirty" | "valid";
243
- dirty(): void;
244
- abort(): void;
245
- static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
246
- static mergeObjectAsync(status: ParseStatus, pairs: {
247
- key: ParseReturnType<any>;
248
- value: ParseReturnType<any>;
249
- }[]): Promise<SyncParseReturnType<any>>;
250
- static mergeObjectSync(status: ParseStatus, pairs: {
251
- key: SyncParseReturnType<any>;
252
- value: SyncParseReturnType<any>;
253
- alwaysSet?: boolean;
254
- }[]): SyncParseReturnType;
255
- }
256
- type INVALID = {
257
- status: "aborted";
258
- };
259
- declare const INVALID: INVALID;
260
- type DIRTY<T> = {
261
- status: "dirty";
262
- value: T;
263
- };
264
- declare const DIRTY: <T>(value: T) => DIRTY<T>;
265
- type OK<T> = {
266
- status: "valid";
267
- value: T;
268
- };
269
- declare const OK: <T>(value: T) => OK<T>;
270
- type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
271
- type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
272
- type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
273
- //#endregion
274
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.d.cts
275
- declare namespace errorUtil {
276
- type ErrMessage = string | {
277
- message?: string | undefined;
278
- };
279
- const errToObj: (message?: ErrMessage) => {
280
- message?: string | undefined;
281
- };
282
- const toString: (message?: ErrMessage) => string | undefined;
283
- }
284
- //#endregion
285
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/standard-schema.d.cts
286
- /**
287
- * The Standard Schema interface.
288
- */
289
- type StandardSchemaV1<Input = unknown, Output = Input> = {
290
- /**
291
- * The Standard Schema properties.
292
- */
293
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
294
- };
295
- declare namespace StandardSchemaV1 {
296
- /**
297
- * The Standard Schema properties interface.
298
- */
299
- export interface Props<Input = unknown, Output = Input> {
300
- /**
301
- * The version number of the standard.
302
- */
303
- readonly version: 1;
304
- /**
305
- * The vendor name of the schema library.
306
- */
307
- readonly vendor: string;
308
- /**
309
- * Validates unknown input values.
310
- */
311
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
312
- /**
313
- * Inferred types associated with the schema.
314
- */
315
- readonly types?: Types<Input, Output> | undefined;
316
- }
317
- /**
318
- * The result interface of the validate function.
319
- */
320
- export type Result<Output> = SuccessResult<Output> | FailureResult;
321
- /**
322
- * The result interface if validation succeeds.
323
- */
324
- export interface SuccessResult<Output> {
325
- /**
326
- * The typed output value.
327
- */
328
- readonly value: Output;
329
- /**
330
- * The non-existent issues.
331
- */
332
- readonly issues?: undefined;
333
- }
334
- /**
335
- * The result interface if validation fails.
336
- */
337
- export interface FailureResult {
338
- /**
339
- * The issues of failed validation.
340
- */
341
- readonly issues: ReadonlyArray<Issue>;
342
- }
343
- /**
344
- * The issue interface of the failure output.
345
- */
346
- export interface Issue {
347
- /**
348
- * The error message of the issue.
349
- */
350
- readonly message: string;
351
- /**
352
- * The path of the issue, if any.
353
- */
354
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
355
- }
356
- /**
357
- * The path segment interface of the issue.
358
- */
359
- export interface PathSegment {
360
- /**
361
- * The key representing a path segment.
362
- */
363
- readonly key: PropertyKey;
364
- }
365
- /**
366
- * The Standard Schema types interface.
367
- */
368
- export interface Types<Input = unknown, Output = Input> {
369
- /**
370
- * The input type of the schema.
371
- */
372
- readonly input: Input;
373
- /**
374
- * The output type of the schema.
375
- */
376
- readonly output: Output;
377
- }
378
- /**
379
- * Infers the input type of a Standard Schema.
380
- */
381
- export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
382
- /**
383
- * Infers the output type of a Standard Schema.
384
- */
385
- export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
386
- export {};
387
- }
388
- //#endregion
389
- //#region ../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.d.cts
390
- interface RefinementCtx {
391
- addIssue: (arg: IssueData) => void;
392
- path: (string | number)[];
393
- }
394
- type ZodTypeAny = ZodType<any, any, any>;
395
- type input<T extends ZodType<any, any, any>> = T["_input"];
396
- type output<T extends ZodType<any, any, any>> = T["_output"];
397
- type CustomErrorParams = Partial<util.Omit<ZodCustomIssue, "code">>;
398
- interface ZodTypeDef {
399
- errorMap?: ZodErrorMap | undefined;
400
- description?: string | undefined;
401
- }
402
- type RawCreateParams = {
403
- errorMap?: ZodErrorMap | undefined;
404
- invalid_type_error?: string | undefined;
405
- required_error?: string | undefined;
406
- message?: string | undefined;
407
- description?: string | undefined;
408
- } | undefined;
409
- type SafeParseSuccess<Output> = {
410
- success: true;
411
- data: Output;
412
- error?: never;
413
- };
414
- type SafeParseError<Input> = {
415
- success: false;
416
- error: ZodError<Input>;
417
- data?: never;
418
- };
419
- type SafeParseReturnType<Input, Output> = SafeParseSuccess<Output> | SafeParseError<Input>;
420
- declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
421
- readonly _type: Output;
422
- readonly _output: Output;
423
- readonly _input: Input;
424
- readonly _def: Def;
425
- get description(): string | undefined;
426
- "~standard": StandardSchemaV1.Props<Input, Output>;
427
- abstract _parse(input: ParseInput): ParseReturnType<Output>;
428
- _getType(input: ParseInput): string;
429
- _getOrReturnCtx(input: ParseInput, ctx?: ParseContext | undefined): ParseContext;
430
- _processInputParams(input: ParseInput): {
431
- status: ParseStatus;
432
- ctx: ParseContext;
433
- };
434
- _parseSync(input: ParseInput): SyncParseReturnType<Output>;
435
- _parseAsync(input: ParseInput): AsyncParseReturnType<Output>;
436
- parse(data: unknown, params?: util.InexactPartial<ParseParams>): Output;
437
- safeParse(data: unknown, params?: util.InexactPartial<ParseParams>): SafeParseReturnType<Input, Output>;
438
- "~validate"(data: unknown): StandardSchemaV1.Result<Output> | Promise<StandardSchemaV1.Result<Output>>;
439
- parseAsync(data: unknown, params?: util.InexactPartial<ParseParams>): Promise<Output>;
440
- safeParseAsync(data: unknown, params?: util.InexactPartial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>;
441
- /** Alias of safeParseAsync */
442
- spa: (data: unknown, params?: util.InexactPartial<ParseParams>) => Promise<SafeParseReturnType<Input, Output>>;
443
- refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, Input>;
444
- refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>;
445
- refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, Input>;
446
- refinement(check: (arg: Output) => boolean, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, Output, Input>;
447
- _refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>;
448
- superRefine<RefinedOutput extends Output>(refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput): ZodEffects<this, RefinedOutput, Input>;
449
- superRefine(refinement: (arg: Output, ctx: RefinementCtx) => void): ZodEffects<this, Output, Input>;
450
- superRefine(refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>): ZodEffects<this, Output, Input>;
451
- constructor(def: Def);
452
- optional(): ZodOptional<this>;
453
- nullable(): ZodNullable<this>;
454
- nullish(): ZodOptional<ZodNullable<this>>;
455
- array(): ZodArray<this>;
456
- promise(): ZodPromise<this>;
457
- or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>;
458
- and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>;
459
- transform<NewOut>(transform: (arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>;
460
- default(def: util.noUndefined<Input>): ZodDefault<this>;
461
- default(def: () => util.noUndefined<Input>): ZodDefault<this>;
462
- brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
463
- catch(def: Output): ZodCatch<this>;
464
- catch(def: (ctx: {
465
- error: ZodError;
466
- input: Input;
467
- }) => Output): ZodCatch<this>;
468
- describe(description: string): this;
469
- pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
470
- readonly(): ZodReadonly<this>;
471
- isOptional(): boolean;
472
- isNullable(): boolean;
473
- }
474
- interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
475
- type: T;
476
- typeName: ZodFirstPartyTypeKind.ZodArray;
477
- exactLength: {
478
- value: number;
479
- message?: string | undefined;
480
- } | null;
481
- minLength: {
482
- value: number;
483
- message?: string | undefined;
484
- } | null;
485
- maxLength: {
486
- value: number;
487
- message?: string | undefined;
488
- } | null;
489
- }
490
- type ArrayCardinality = "many" | "atleastone";
491
- type arrayOutputType<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> = Cardinality extends "atleastone" ? [T["_output"], ...T["_output"][]] : T["_output"][];
492
- declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> extends ZodType<arrayOutputType<T, Cardinality>, ZodArrayDef<T>, Cardinality extends "atleastone" ? [T["_input"], ...T["_input"][]] : T["_input"][]> {
493
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
494
- get element(): T;
495
- min(minLength: number, message?: errorUtil.ErrMessage): this;
496
- max(maxLength: number, message?: errorUtil.ErrMessage): this;
497
- length(len: number, message?: errorUtil.ErrMessage): this;
498
- nonempty(message?: errorUtil.ErrMessage): ZodArray<T, "atleastone">;
499
- static create: <El extends ZodTypeAny>(schema: El, params?: RawCreateParams) => ZodArray<El>;
500
- }
501
- type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
502
- interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>> extends ZodTypeDef {
503
- options: T;
504
- typeName: ZodFirstPartyTypeKind.ZodUnion;
505
- }
506
- declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
507
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
508
- get options(): T;
509
- static create: <Options extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>>(types: Options, params?: RawCreateParams) => ZodUnion<Options>;
510
- }
511
- interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
512
- left: T;
513
- right: U;
514
- typeName: ZodFirstPartyTypeKind.ZodIntersection;
515
- }
516
- declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
517
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
518
- static create: <TSchema extends ZodTypeAny, USchema extends ZodTypeAny>(left: TSchema, right: USchema, params?: RawCreateParams) => ZodIntersection<TSchema, USchema>;
519
- }
520
- interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
521
- type: T;
522
- typeName: ZodFirstPartyTypeKind.ZodPromise;
523
- }
524
- declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
525
- unwrap(): T;
526
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
527
- static create: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
528
- }
529
- type RefinementEffect<T> = {
530
- type: "refinement";
531
- refinement: (arg: T, ctx: RefinementCtx) => any;
532
- };
533
- type TransformEffect<T> = {
534
- type: "transform";
535
- transform: (arg: T, ctx: RefinementCtx) => any;
536
- };
537
- type PreprocessEffect<T> = {
538
- type: "preprocess";
539
- transform: (arg: T, ctx: RefinementCtx) => any;
540
- };
541
- type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEffect<T>;
542
- interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
543
- schema: T;
544
- typeName: ZodFirstPartyTypeKind.ZodEffects;
545
- effect: Effect<any>;
546
- }
547
- declare class ZodEffects<T extends ZodTypeAny, Output = output<T>, Input = input<T>> extends ZodType<Output, ZodEffectsDef<T>, Input> {
548
- innerType(): T;
549
- sourceType(): T;
550
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
551
- static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"]>;
552
- static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
553
- }
554
- interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
555
- innerType: T;
556
- typeName: ZodFirstPartyTypeKind.ZodOptional;
557
- }
558
- declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
559
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
560
- unwrap(): T;
561
- static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodOptional<Inner>;
562
- }
563
- interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
564
- innerType: T;
565
- typeName: ZodFirstPartyTypeKind.ZodNullable;
566
- }
567
- declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
568
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
569
- unwrap(): T;
570
- static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodNullable<Inner>;
571
- }
572
- interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
573
- innerType: T;
574
- defaultValue: () => util.noUndefined<T["_input"]>;
575
- typeName: ZodFirstPartyTypeKind.ZodDefault;
576
- }
577
- declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodDefaultDef<T>, T["_input"] | undefined> {
578
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
579
- removeDefault(): T;
580
- static create: <Inner extends ZodTypeAny>(type: Inner, params: RawCreateParams & {
581
- default: Inner["_input"] | (() => util.noUndefined<Inner["_input"]>);
582
- }) => ZodDefault<Inner>;
583
- }
584
- interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
585
- innerType: T;
586
- catchValue: (ctx: {
587
- error: ZodError;
588
- input: unknown;
589
- }) => T["_input"];
590
- typeName: ZodFirstPartyTypeKind.ZodCatch;
591
- }
592
- declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
593
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
594
- removeCatch(): T;
595
- static create: <Inner extends ZodTypeAny>(type: Inner, params: RawCreateParams & {
596
- catch: Inner["_output"] | (() => Inner["_output"]);
597
- }) => ZodCatch<Inner>;
598
- }
599
- interface ZodBrandedDef<T extends ZodTypeAny> extends ZodTypeDef {
600
- type: T;
601
- typeName: ZodFirstPartyTypeKind.ZodBranded;
602
- }
603
- declare const BRAND: unique symbol;
604
- type BRAND<T extends string | number | symbol> = {
605
- [BRAND]: { [k in T]: true; };
606
- };
607
- declare class ZodBranded<T extends ZodTypeAny, B extends string | number | symbol> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
608
- _parse(input: ParseInput): ParseReturnType<any>;
609
- unwrap(): T;
610
- }
611
- interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodTypeDef {
612
- in: A;
613
- out: B;
614
- typeName: ZodFirstPartyTypeKind.ZodPipeline;
615
- }
616
- declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
617
- _parse(input: ParseInput): ParseReturnType<any>;
618
- static create<ASchema extends ZodTypeAny, BSchema extends ZodTypeAny>(a: ASchema, b: BSchema): ZodPipeline<ASchema, BSchema>;
619
- }
620
- type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
621
- readonly [Symbol.toStringTag]: string;
622
- } | Date | Error | Generator | Promise<unknown> | RegExp;
623
- type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
624
- interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
625
- innerType: T;
626
- typeName: ZodFirstPartyTypeKind.ZodReadonly;
627
- }
628
- declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, MakeReadonly<T["_input"]>> {
629
- _parse(input: ParseInput): ParseReturnType<this["_output"]>;
630
- static create: <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams) => ZodReadonly<Inner>;
631
- unwrap(): T;
632
- }
633
- declare enum ZodFirstPartyTypeKind {
634
- ZodString = "ZodString",
635
- ZodNumber = "ZodNumber",
636
- ZodNaN = "ZodNaN",
637
- ZodBigInt = "ZodBigInt",
638
- ZodBoolean = "ZodBoolean",
639
- ZodDate = "ZodDate",
640
- ZodSymbol = "ZodSymbol",
641
- ZodUndefined = "ZodUndefined",
642
- ZodNull = "ZodNull",
643
- ZodAny = "ZodAny",
644
- ZodUnknown = "ZodUnknown",
645
- ZodNever = "ZodNever",
646
- ZodVoid = "ZodVoid",
647
- ZodArray = "ZodArray",
648
- ZodObject = "ZodObject",
649
- ZodUnion = "ZodUnion",
650
- ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
651
- ZodIntersection = "ZodIntersection",
652
- ZodTuple = "ZodTuple",
653
- ZodRecord = "ZodRecord",
654
- ZodMap = "ZodMap",
655
- ZodSet = "ZodSet",
656
- ZodFunction = "ZodFunction",
657
- ZodLazy = "ZodLazy",
658
- ZodLiteral = "ZodLiteral",
659
- ZodEnum = "ZodEnum",
660
- ZodEffects = "ZodEffects",
661
- ZodNativeEnum = "ZodNativeEnum",
662
- ZodOptional = "ZodOptional",
663
- ZodNullable = "ZodNullable",
664
- ZodDefault = "ZodDefault",
665
- ZodCatch = "ZodCatch",
666
- ZodPromise = "ZodPromise",
667
- ZodBranded = "ZodBranded",
668
- ZodPipeline = "ZodPipeline",
669
- ZodReadonly = "ZodReadonly"
670
- }
671
- //#endregion
672
- //#region ../../engine/core/dist/AnnotationListSnapshot-W0RCsyDE.d.ts
673
- //#endregion
674
- //#region src/dto/PdfAction.d.ts
675
- /** Normalized values of an action dictionary's `/S` name. */
676
- type PdfActionType = 'unknown' | 'goto' | 'goto-remote' | 'goto-embedded' | 'launch' | 'thread' | 'uri' | 'sound' | 'movie' | 'hide' | 'named' | 'submit-form' | 'reset-form' | 'import-data' | 'javascript' | 'set-ocg-state' | 'rendition' | 'transition' | 'goto-3d-view';
677
- /** One detached node in a normalized PDF action tree. */
678
- interface PdfActionNode {
679
- type: PdfActionType;
680
- /** Raw `/S` name, retained for unknown and future action types. */
681
- subtype: string;
682
- /** Decoded `/JS` source for JavaScript and Rendition actions. */
683
- script?: string;
684
- /** Normalized `/Next` children in PDF order. */
685
- next: PdfActionNode[];
686
- }
687
- type PdfActionWarning = 'cycle-dropped' | 'malformed-next' | 'incomplete';
688
- /**
689
- * One extracted action root plus the native reader's safety verdict.
690
- * Consumers must never execute a tree whose `incomplete` flag is true.
691
- */
692
- interface PdfActionTree {
693
- /** Null when the model was valid but its root exceeded a safety bound. */
694
- root: PdfActionNode | null;
695
- incomplete: boolean;
696
- /** Raw native bits, retained so newer warnings survive older SDKs. */
697
- warningFlags: number;
698
- warnings: PdfActionWarning[];
699
- }
700
- interface PdfFieldActions {
701
- keystroke?: PdfActionTree;
702
- format?: PdfActionTree;
703
- validate?: PdfActionTree;
704
- calculate?: PdfActionTree;
705
- }
706
- interface PdfAnnotationActions {
707
- activate?: PdfActionTree;
708
- cursorEnter?: PdfActionTree;
709
- cursorExit?: PdfActionTree;
710
- mouseDown?: PdfActionTree;
711
- mouseUp?: PdfActionTree;
712
- focus?: PdfActionTree;
713
- blur?: PdfActionTree;
714
- pageOpen?: PdfActionTree;
715
- pageClose?: PdfActionTree;
716
- pageVisible?: PdfActionTree;
717
- pageInvisible?: PdfActionTree;
718
- }
719
- //#endregion
720
- //#region src/geometry/primitives.d.ts
721
- /**
722
- * Canonical PDF-document geometry primitives.
723
- *
724
- * These are the ONE geometry vocabulary the engine API speaks. They are
725
- * PDF user space:
726
- * - y-UP (origin at the page box's bottom-left; `top > bottom`)
727
- * - edges, not x/y/width/height
728
- * - page-box origin preserved (NOT origin-normalized)
729
- * - browser-free (no DOM, no device pixels) and portable to Rust/Swift/Kotlin
730
- *
731
- * They are the only geometry ever sent as engine wire data. Viewer-local
732
- * geometry (content/view/screen space, y-down, x/y/width/height) lives in the
733
- * v3 viewer layer and is always produced from these by an EXPLICIT transform.
734
- *
735
- * No dependency on PDFium or any browser/Node surface: this is the lingua
736
- * franca between local engine, cloud engine, and server.
737
- */
738
- /** A point in PDF user space (y-up). */
739
- interface PdfPoint {
740
- x: number;
741
- y: number;
742
- }
743
- /**
744
- * A rectangle in PDF user space, expressed as edges (y-up, so `top > bottom`
745
- * and `right > left` once normalized). Page-box origin is preserved, so
746
- * `left`/`bottom` may be non-zero or negative.
747
- */
748
- interface PdfRect {
749
- left: number;
750
- bottom: number;
751
- right: number;
752
- top: number;
753
- }
754
- /**
755
- * The two endpoints of a line annotation's `/L` entry, in PDF user space
756
- * (y-up). `start` is `[x1 y1]` and `end` is `[x2 y2]`.
757
- */
758
- interface LinePoints {
759
- start: PdfPoint;
760
- end: PdfPoint;
761
- }
762
- /**
763
- * A single ink stroke — one continuous pen path, as the ordered point list
764
- * of an `/InkList` sub-array. Coordinates are PDF user space, y-up.
765
- */
766
- type InkStroke = PdfPoint[];
767
- /**
768
- * An ink annotation's `/InkList` — an array of strokes (each a point path).
769
- * Mirrors the PDF structure: `/InkList [ [x1 y1 x2 y2 ...] [ ... ] ]`.
770
- */
771
- type InkList = InkStroke[];
772
- /**
773
- * A free-text callout annotation's `/CL` leader line, in PDF user space
774
- * (y-up). Two points draw a straight leader (`[knee->end]` collapses to
775
- * `[start, end]`); three points draw a knee-jointed leader
776
- * (`[start, knee, end]`). The last point is the end that touches the text
777
- * box; the first is the point being called out.
778
- */
779
- type CalloutLine = readonly [PdfPoint, PdfPoint] | readonly [PdfPoint, PdfPoint, PdfPoint];
780
- /**
781
- * A /QuadPoints quad. The four points are POSITIONAL, in PDFium
782
- * `FS_QUADPOINTSF` order (PDF 32000 §12.5.6.10): `p1 p2 p3 p4`. Coordinates
783
- * are PDF user space, y-up.
784
- *
785
- * This type asserts NO corner semantics. Quads can be rotated or skewed
786
- * (e.g. text markup over rotated text), and PDF producers disagree on corner
787
- * order — so naming corners `topLeft`/... on the wire would be a false
788
- * guarantee. Derive named corners with `pdfQuadCorners` (valid only for
789
- * axis-aligned quads) or get the enclosing box with `pdfQuadBounds`.
790
- */
791
- interface PdfQuad {
792
- p1: PdfPoint;
793
- p2: PdfPoint;
794
- p3: PdfPoint;
795
- p4: PdfPoint;
796
- }
797
- /**
798
- * sRGB color. Components are 0..255 integers. Engines normalize PDFium's
799
- * device color space into sRGB at read time.
800
- *
801
- * Colour carries NO alpha: annotation transparency is a separate concern
802
- * stored in `/CA` and surfaced as the `opacity` style field, so there is a
803
- * single source of truth for transparency. See `ColorStyleFields.opacity`.
804
- */
805
- interface Color {
806
- r: number;
807
- g: number;
808
- b: number;
809
- }
810
- /**
811
- * /LE entries (line endings). Maps PDFium FPDFAnnot_GetLineEndings codes
812
- * onto the spec names. We use kebab-case so the wire format is stable
813
- * across language ports.
814
- */
815
- type LineEnding = 'none' | 'square' | 'circle' | 'diamond' | 'open-arrow' | 'closed-arrow' | 'butt' | 'r-open-arrow' | 'r-closed-arrow' | 'slash';
816
- /**
817
- * The `/LE` pair carried by line and polyline annotations: the ending
818
- * drawn at the start point and the ending drawn at the end point.
819
- */
820
- interface LineEndings {
821
- start: LineEnding;
822
- end: LineEnding;
823
- }
824
- /**
825
- * The 14 standard PDF fonts a free-text annotation's `/DA` can name. We use
826
- * kebab-case so the wire format is stable across language ports; the engine
827
- * maps these onto PDFium's `FPDF_STANDARD_FONT` integer codes at write time.
828
- */
829
- type StandardFont = 'courier' | 'courier-bold' | 'courier-bold-oblique' | 'courier-oblique' | 'helvetica' | 'helvetica-bold' | 'helvetica-bold-oblique' | 'helvetica-oblique' | 'times-roman' | 'times-bold' | 'times-bold-italic' | 'times-italic' | 'symbol' | 'zapf-dingbats';
830
- /**
831
- * Font selector for a free-text annotation: either one of the 14 PDF
832
- * {@link StandardFont} names, or the `key` of a font registered through
833
- * `engine.fonts` (local/WASM engine only).
834
- *
835
- * The `(string & {})` arm keeps the standard-font literals auto-completing
836
- * while still accepting any registered key. Because the standard names are
837
- * matched first at write time, those 14 names are reserved: don't register a
838
- * custom font under a key like `'helvetica'`.
839
- */
840
- type FreeTextFont = StandardFont | (string & {});
841
- /**
842
- * Horizontal text alignment (`/Q`) for free-text annotations. Maps onto the
843
- * ISO 32000 §12.7.3.3 quadding codes 0/1/2 at write time.
844
- */
845
- type TextAlignment = 'left' | 'center' | 'right';
846
- /**
847
- * Free-text `/IT` intent. `free-text` is a plain text box; `free-text-callout`
848
- * adds a `/CL` leader line pointing at the called-out region.
849
- */
850
- type FreeTextIntent = 'free-text' | 'free-text-callout';
851
- /** Caret `/IT` intent used by an Acrobat-compatible replace-text edit. */
852
- type CaretIntent = 'replace';
853
- /** Strikeout `/IT` intent used by the subordinate part of a replace-text edit. */
854
- type StrikeoutIntent = 'strikeout-text-edit';
855
- /** Ink `/IT` intent used by an Acrobat-compatible freehand highlighter. */
856
- type InkIntent = 'ink-highlight';
857
- /**
858
- * Effective blend mode of an annotation's normal appearance stream (`/AP /N`).
859
- * Values use CSS-compatible kebab-case so the wire vocabulary is portable; the
860
- * engine maps them onto PDFium's `FPDF_BLENDMODE` integer codes.
861
- */
862
- type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
863
- /**
864
- * Border/line style for shape annotations — the `/BS /S` (border style)
865
- * subset PDFium can author. Maps onto the ISO 32000 §8.4.3.3 border style
866
- * names. Cloudy borders are a SEPARATE concern (`/BE` border effect),
867
- * surfaced as `cloudyIntensity` on the shape DTO, not as a border style.
868
- *
869
- * kebab-/lower-case so the wire format is stable across language ports;
870
- * the engine maps these onto PDFium's integer codes at write time.
871
- */
872
- type AnnotationBorderStyle = 'solid' | 'dashed' | 'beveled' | 'inset';
873
- /**
874
- * `/RD` (rectangle differences) for shape annotations — the four margins,
875
- * in PDF points, between the annotation `/Rect` and the geometry actually
876
- * drawn inside it. Used so a thick/cloudy border has room to render
877
- * without being clipped by the `/Rect`. y-up PDF user space, so each value
878
- * is a non-negative inset from the corresponding `/Rect` edge.
879
- */
880
- interface PdfRectDifferences {
881
- left: number;
882
- top: number;
883
- right: number;
884
- bottom: number;
885
- }
886
- /**
887
- * The `/RT` (reply type) relationship an annotation declares toward the
888
- * annotation its `/IRT` points at (ISO 32000 §12.5.6.2). Wire-stable
889
- * kebab/lower-case strings; the engine maps these onto PDFium's
890
- * `FPDF_ANNOT_REPLY_TYPE` integer codes at read/write time.
891
- *
892
- * 'reply' -> `/R` a comment-thread reply (the ISO default when
893
- * `/IRT` is present but `/RT` is absent).
894
- * 'group' -> `/Group` a subordinate part of one logical annotation
895
- * group (e.g. the Caret of a text-edit pair).
896
- */
897
- type AnnotationReplyType = 'reply' | 'group';
898
- /**
899
- * Bitset wrapper for the `/F` (Annotation Flags) PDF entry. We expose each
900
- * bit as its own boolean so callers don't have to know the bit positions.
901
- */
902
- interface AnnotationFlags {
903
- invisible: boolean;
904
- hidden: boolean;
905
- print: boolean;
906
- noZoom: boolean;
907
- noRotate: boolean;
908
- noView: boolean;
909
- readOnly: boolean;
910
- locked: boolean;
911
- toggleNoView: boolean;
912
- lockedContents: boolean;
913
- }
914
- //#endregion
915
- //#region src/identity/PageObjectNumber.d.ts
916
- /**
917
- * PDF indirect object number for a page.
918
- *
919
- * Resolved via the PDFium runtime helper `EPDFPage_GetObjectNumber(pagePtr)`.
920
- * Always > 0 for well-formed PDFs. This replaces the v2 page index as the
921
- * primary addressing key. The page index is kept on `PageHandle` as display
922
- * metadata only, because it can shift when pages are inserted, deleted, or
923
- * reordered while a session is open.
924
- */
925
- type PageObjectNumber = number;
926
- //#endregion
927
- //#region src/revision/RevisionToken.d.ts
928
- /**
929
- * Opaque token a client must hand back when addressing an annotation by
930
- * `(pageObjectNumber, index)`. The engine validates strict equality against
931
- * its own `RevisionStore`; mismatches throw `EngineError(InvalidReference)`.
932
- *
933
- * Bleed-over prevention: `docSessionId` ties a token to one open session,
934
- * so a token minted before close-and-reopen is rejected by the new session.
935
- */
936
- interface RevisionToken {
937
- docSessionId: string;
938
- pageObjectNumber: PageObjectNumber;
939
- generation: number;
940
- }
941
- //#endregion
942
- //#region src/identity/AnnotationRef.d.ts
943
- /**
944
- * The discriminated union the engine accepts to address an annotation.
945
- *
946
- * The resolution order in `AnnotationIdentityResolver` is:
947
- * 1. `objectNumber` -> `EPDFPage_GetAnnotByObjectNumber(pagePtr, n)`
948
- * 2. `nm` -> `EPDFPage_GetAnnotByName(pagePtr, nm)`
949
- * 3. `index` -> validate `revision` against `RevisionStore`, then
950
- * `EPDFPage_GetAnnotRaw(docPtr, pageIndex, index)`
951
- *
952
- * The `index` form is the strict escape hatch for legacy / direct-object
953
- * annotations. It must carry a fresh `RevisionToken`, which the engine
954
- * checks against the per-page generation counter on every dereference.
955
- * Stale tokens fail with `EngineError(InvalidReference)` instead of silently
956
- * pointing at the wrong annotation.
957
- */
958
- type AnnotationRef = {
959
- kind: 'objectNumber';
960
- pageObjectNumber: PageObjectNumber;
961
- annotObjectNumber: number;
962
- } | {
963
- kind: 'nm';
964
- pageObjectNumber: PageObjectNumber;
965
- nm: string;
966
- } | {
967
- kind: 'index';
968
- pageObjectNumber: PageObjectNumber;
969
- index: number;
970
- revision: RevisionToken;
971
- };
972
- //#endregion
973
- //#region src/annotation/draft-base.d.ts
974
- /**
975
- * Generic fields every annotation Draft carries. These are not specific
976
- * to any subtype family; they map to PDF dictionary entries that exist
977
- * on every annotation per ISO 32000 §12.5.2 and may be authored at
978
- * create time.
979
- *
980
- * `nm` is here (and not in AnnotationPatchBase) because /NM seeds the
981
- * stable identity of a new annotation; it cannot be changed afterwards
982
- * without changing which annotation is being targeted.
983
- *
984
- * Authorial identity (/T author display, /EMBD_Metadata UserID and
985
- * GroupID) is set by the server from the caller's JWT identity at
986
- * creation — the worker writes /T from the caller's `display_name`
987
- * claim and /EMBD_Metadata from the caller's `user_id` / `group_id`
988
- * claims. The `doc.annotate.create` capability is the gate.
989
- */
990
- interface AnnotationDraftBase {
991
- contents?: string | null;
992
- /** Blend mode to bake into the normal appearance. Omit for the subtype default. */
993
- blendMode?: BlendMode;
994
- /** Optional /NM the caller wants to assign on creation. */
995
- nm?: string;
996
- /**
997
- * Optional `/F` (Annotation Flags) to set on creation. Only the keys
998
- * provided are set; omitted keys default to `false` (the dict starts at
999
- * 0). E.g. `{ print: true }` or `{ readOnly: true, hidden: true }`.
1000
- */
1001
- flags?: Partial<AnnotationFlags>;
1002
- /**
1003
- * Link this new annotation to an existing parent via `/IRT`. The parent
1004
- * must be on the SAME page as this draft — the engine throws
1005
- * `InvalidArg` otherwise (ISO 32000 §12.5.6.2). Resolving + writing the
1006
- * link promotes a weak/direct parent to an indirect object; the
1007
- * parent's strengthened stable id is reported in the create result's
1008
- * `meta.changed`, and the read-back DTO's `inReplyTo` carries its
1009
- * durable ref.
1010
- */
1011
- inReplyTo?: AnnotationRef;
1012
- /**
1013
- * `/RT` to write when {@link inReplyTo} is set. Defaults to `'reply'`
1014
- * (the ISO default) when omitted. Ignored when `inReplyTo` is absent.
1015
- */
1016
- replyType?: AnnotationReplyType;
1017
- }
1018
- //#endregion
1019
- //#region src/identity/AnnotationIdentityQuality.d.ts
1020
- /**
1021
- * Classification used by clients to decide whether they can hold long-lived
1022
- * references to an annotation.
1023
- *
1024
- * `durable` - the annotation has a stable wire id (PDF indirect object
1025
- * number, or `/NM`). References survive structural mutations.
1026
- * `weak` - the annotation has no stable wire id; the only handle is
1027
- * `(pageObjectNumber, index, revision)`. Index can shift after
1028
- * any structural mutation on the same page; the engine encodes
1029
- * that fact in `AnnotationListMutationMeta.weakRefsInvalidated`.
1030
- */
1031
- type AnnotationIdentityQuality = 'durable' | 'weak';
1032
- //#endregion
1033
- //#region src/annotation/base.d.ts
1034
- /**
1035
- * Identity + provenance shell every annotation DTO extends.
1036
- *
1037
- * No subtype-specific fields. Each subtype's DTO under `annotation/kinds/`
1038
- * extends this with exactly the fields it needs and the `subtype` literal
1039
- * discriminator. This shell never grows when a new subtype lands.
1040
- */
1041
- interface AnnotationBase {
1042
- ref: AnnotationRef;
1043
- pageObjectNumber: PageObjectNumber;
1044
- /** Display order inside the page; 0-based. */
1045
- index: number;
1046
- identityQuality: AnnotationIdentityQuality;
1047
- /** /NM if present, exposed read-only. The engine never auto-stamps it. */
1048
- nm: string | null;
1049
- flags: AnnotationFlags;
1050
- rect: PdfRect;
1051
- /** /Contents text. */
1052
- contents: string | null;
1053
- /** /T author. */
1054
- author: string | null;
1055
- /** ISO 8601 from /CreationDate. */
1056
- created: string | null;
1057
- /** ISO 8601 from /M. */
1058
- modified: string | null;
1059
- /** Effective blend mode used by the normal appearance stream (`/AP /N`). */
1060
- blendMode: BlendMode;
1061
- /**
1062
- * `/IRT` ("in reply to"), resolved to the parent annotation's
1063
- * {@link AnnotationRef}, or `null` when this is a top-level annotation.
1064
- *
1065
- * The parent is always on the same page (ISO 32000 §12.5.6.2 requires
1066
- * it) and is always an indirect object — `/IRT` is an indirect
1067
- * reference — so the resolved ref is durable (`objectNumber`, or `nm`
1068
- * if the parent carries `/NM`). The engine never auto-stamps the parent
1069
- * on read; it only reports the identity PDFium already exposes.
1070
- *
1071
- * Relationships are NOT nested into the DTO: a reply / group member is
1072
- * itself a first-class annotation in the flat page list. Use
1073
- * `buildThreads()` to compose this flat edge into primary + replies +
1074
- * groupedParts for a comments sidebar.
1075
- */
1076
- inReplyTo: AnnotationRef | null;
1077
- /**
1078
- * `/RT` (reply type) — how this annotation relates to its `/IRT`
1079
- * parent. `null` exactly when {@link inReplyTo} is `null`. When `/IRT`
1080
- * is present but `/RT` is absent, the engine normalizes it to `'reply'`
1081
- * (the ISO 32000 §12.5.6.2 default).
1082
- */
1083
- replyType: AnnotationReplyType | null;
1084
- /**
1085
- * EmbedPDF-namespaced /EMBD_Metadata fields, when present on the
1086
- * annotation. These are written by the cloud annotation pipeline (and
1087
- * by engine-local when an identity is supplied at open time) so the
1088
- * client can resolve collab semantics and author display.
1089
- *
1090
- * Absence means either:
1091
- * - the annotation was created before EMBD_Metadata was wired up,
1092
- * - it was created by a non-cloud writer (Acrobat, Foxit, etc.),
1093
- * - or the writer ran without an actor (anonymous test fixtures).
1094
- *
1095
- * Collab filters in the resolver treat absent userId/groupId as
1096
- * not-self / not-in-group — i.e. deny — so unstamped annotations are
1097
- * invisible to per-record collab rules. They are still visible to
1098
- * `view:all` style reads, since reads aren't filtered (per the v1
1099
- * spec).
1100
- */
1101
- userId?: string;
1102
- groupId?: string;
1103
- createdBy?: string;
1104
- updatedBy?: string;
1105
- /** `/A` and annotation `/AA`, available for every annotation subtype. */
1106
- actions?: PdfAnnotationActions;
1107
- }
1108
- //#endregion
1109
- //#region src/annotation/patch-base.d.ts
1110
- /**
1111
- * Generic fields every annotation Patch carries.
1112
- *
1113
- * Three-state semantics on string|null fields:
1114
- * undefined -> don't touch
1115
- * null -> clear the field
1116
- * "..." -> set to this value
1117
- *
1118
- * Authorial identity is immutable after create:
1119
- *
1120
- * - `/EMBD_Metadata/UserID` and `/CreatedBy` are bound at creation
1121
- * and cannot be patched. `/EMBD_Metadata/UpdatedBy` is refreshed by
1122
- * the server from the caller's identity on every update.
1123
- * - `/T` (the standard PDF "author" display field) is bound at
1124
- * creation from the caller's JWT `display_name` and cannot be
1125
- * patched. Acrobat and other viewers display /T as "author", so
1126
- * allowing edits would let any caller with update authority
1127
- * rewrite who appears to have authored the annotation.
1128
- *
1129
- * `groupId` IS patchable — organizational ownership (which team an
1130
- * annotation belongs to) can legitimately change with reorgs /
1131
- * handoffs. Reassignment runs `checkSetGroup` against the caller's
1132
- * scope.
1133
- */
1134
- interface AnnotationPatchBase {
1135
- contents?: string | null;
1136
- /** New appearance blend mode. Omit to preserve the current effective mode. */
1137
- blendMode?: BlendMode;
1138
- /**
1139
- * Reassign the annotation's `/EMBD_Metadata/GroupID`.
1140
- *
1141
- * When supplied and differs from the annotation's current GroupID,
1142
- * the route runs `checkSetGroup` against the caller's scope; 403 if
1143
- * denied. `groupId` does not support a `null` clear-form — group
1144
- * attribution is either present or absent, and the only mutation is
1145
- * "reassign to a different group."
1146
- */
1147
- groupId?: string;
1148
- /**
1149
- * Update the `/F` (Annotation Flags). Only the keys provided are
1150
- * changed; omitted keys preserve their current value. E.g.
1151
- * `{ hidden: true }` hides without touching `print`.
1152
- */
1153
- flags?: Partial<AnnotationFlags>;
1154
- /**
1155
- * Re-target or clear the `/IRT` link, three-state:
1156
- * undefined -> leave the link untouched
1157
- * null -> clear `/IRT` (and `/RT`); becomes top-level
1158
- * ref -> set/relink to this parent (must be on the same page;
1159
- * `InvalidArg` otherwise). Setting a link promotes a
1160
- * weak/direct parent to indirect — its strengthened
1161
- * stable id is reported in `meta.changed`.
1162
- */
1163
- inReplyTo?: AnnotationRef | null;
1164
- /**
1165
- * Change `/RT` without re-linking. Applies to the current `/IRT`
1166
- * parent; ignored if the annotation has no link and `inReplyTo` is not
1167
- * being set in the same patch.
1168
- */
1169
- replyType?: AnnotationReplyType;
1170
- }
1171
- //#endregion
1172
- //#region src/annotation/subtype.d.ts
1173
- /**
1174
- * Closed-world string catalog of annotation subtypes the v3 wire format knows
1175
- * about. The TypeScript discriminated union `AnnotationDTO` is keyed on this
1176
- * literal type. PDFium's integer subtype code is mapped onto these strings
1177
- * by the reader registry.
1178
- *
1179
- * `unsupported` is the forward-compat fallback for any PDF subtype that
1180
- * the engine has not implemented a reader for yet. Unknown subtypes never
1181
- * silently disappear from the wire — they round-trip as
1182
- * `{ subtype: 'unsupported', rawSubtypeCode }`.
1183
- */
1184
- declare const ANNOTATION_SUBTYPES: readonly ["text", "link", "free-text", "line", "square", "circle", "polygon", "polyline", "highlight", "underline", "squiggly", "strikeout", "stamp", "caret", "ink", "popup", "file-attachment", "redact", "widget", "unsupported"];
1185
- type AnnotationSubtype = (typeof ANNOTATION_SUBTYPES)[number];
1186
- /** What replaces a `BinarySource` field in the wire form of a draft/patch. */
1187
- interface ResourceRef {
1188
- resource: string;
1189
- }
1190
- //#endregion
1191
- //#region src/dto/Attachment.d.ts
1192
- /**
1193
- * One vocabulary for "a file living inside a PDF" — shared by the
1194
- * file-attachment annotation kind and the document-level EmbeddedFiles
1195
- * service, on both the write and read sides:
1196
- *
1197
- * write -> {@link AttachmentFileSource}: the shared metadata fields plus
1198
- * inline `data` bytes (the [[BinarySource]] rule — bytes are a
1199
- * call argument, never engine state).
1200
- * read -> {@link AttachmentFileInfo}: the same metadata fields plus
1201
- * engine-derived facts (size, checksum, creationDate) and never
1202
- * the bytes — listings stay cheap; bytes leave the engine only
1203
- * through an explicit download call.
1204
- *
1205
- * A file has exactly two possible homes: the document catalog's
1206
- * `/EmbeddedFiles` name tree (addressed by {@link EmbeddedFileItem.index}),
1207
- * and a FileAttachment annotation's `/FS` (addressed by the annotation ref).
1208
- */
1209
- /** Metadata fields shared by the write and read forms. */
1210
- interface AttachmentFileBase {
1211
- /** File name — `/UF` (and `/F`) on the filespec. */
1212
- name: string;
1213
- /** MIME type — `/Subtype` of the embedded file stream. */
1214
- mimeType?: string;
1215
- /** Human-readable description — `/Desc` on the filespec. */
1216
- description?: string;
1217
- }
1218
- /** Read-side projection of an embedded file stream (`/EF` + `/Params`). */
1219
- interface AttachmentFileInfo extends AttachmentFileBase {
1220
- /** `/Params /Size` — decoded size in bytes. */
1221
- size?: number;
1222
- /** `/Params /CheckSum` — MD5 of the decoded bytes, lowercase hex. */
1223
- checksum?: string;
1224
- /** `/Params /CreationDate` — PDF date string. */
1225
- creationDate?: string;
1226
- }
1227
- //#endregion
1228
- //#region src/annotation/kinds/style.shared.d.ts
1229
- /**
1230
- * Composable styling layers shared by every annotation family, named after
1231
- * the PDF entries they map onto so the v3 wire vocabulary matches ISO 32000:
1232
- *
1233
- * ColorStyleFields -> `/C` (color) + `/CA` (opacity) — universal
1234
- * GeometryStyleFields -> + `/BS` (border style / width / dash) — geometric
1235
- * FilledStyleFields -> + `/IC` (interior color) — filled shapes
1236
- *
1237
- * There is exactly one `/C` in the spec ("Color") and one `/IC` ("Interior
1238
- * Color") — there is no "stroke color" — so every family that carries `/C`
1239
- * exposes the same `color` field. This is what lets a multi-select "change
1240
- * colour" operate uniformly across text-markup, lines, and shapes.
1241
- *
1242
- * Composition by family:
1243
- * - text-markup (highlight/underline/squiggly/strikeout) -> ColorStyleFields
1244
- * - ink -> GeometryStyleFields
1245
- * - square/circle/polygon/polyline/line -> FilledStyleFields
1246
- */
1247
- interface ColorStyleFields {
1248
- /** `/C` color. Stroke colour for geometric kinds; highlight colour for markup. */
1249
- color: Color;
1250
- /** `/CA` constant opacity, 0..1. */
1251
- opacity: number;
1252
- }
1253
- interface ColorStyleDraftFields {
1254
- color?: Color;
1255
- opacity?: number;
1256
- }
1257
- type ColorStylePatchFields = ColorStyleDraftFields;
1258
- interface GeometryStyleFields extends ColorStyleFields {
1259
- /** `/BS /W` border width, in PDF points. */
1260
- strokeWidth: number;
1261
- /** `/BS /S` border style. */
1262
- borderStyle: AnnotationBorderStyle;
1263
- /** `/BS /D` dash pattern. Only meaningful when `borderStyle === 'dashed'`. */
1264
- dashArray?: number[];
1265
- }
1266
- interface GeometryStyleDraftFields extends ColorStyleDraftFields {
1267
- strokeWidth?: number;
1268
- borderStyle?: AnnotationBorderStyle;
1269
- dashArray?: number[];
1270
- }
1271
- type GeometryStylePatchFields = GeometryStyleDraftFields;
1272
- interface FilledStyleFields extends GeometryStyleFields {
1273
- /** `/IC` interior (fill) color. `null` when the annotation has no fill. */
1274
- interiorColor: Color | null;
1275
- }
1276
- interface FilledStyleDraftFields extends GeometryStyleDraftFields {
1277
- interiorColor?: Color | null;
1278
- }
1279
- type FilledStylePatchFields = FilledStyleDraftFields;
1280
- //#endregion
1281
- //#region src/annotation/kinds/file-attachment/draft.d.ts
1282
- /** `/Name` icon of a file attachment annotation — ISO 32000 §12.5.6.15. */
1283
- type FileAttachmentIcon = 'push-pin' | 'paperclip' | 'graph' | 'tag';
1284
- /**
1285
- * Wire form of the attached file: the metadata half of
1286
- * {@link AttachmentFileSource} stays in the JSON body (so the single Zod
1287
- * schema validates it on client, worker, and server) while the bytes
1288
- * travel out-of-band under the referenced resource key.
1289
- */
1290
- interface WireAttachmentFile {
1291
- resource: string;
1292
- name: string;
1293
- mimeType?: string;
1294
- description?: string;
1295
- }
1296
- /** Wire form of {@link FileAttachmentDraft} — pure JSON. */
1297
- interface FileAttachmentWireDraft extends AnnotationDraftBase, ColorStyleDraftFields {
1298
- subtype: 'file-attachment';
1299
- rect: PdfRect;
1300
- file: WireAttachmentFile;
1301
- icon?: FileAttachmentIcon;
1302
- }
1303
- //#endregion
1304
- //#region src/annotation/registry.d.ts
1305
- /**
1306
- * One module per PDF annotation subtype. A kind module is the single source
1307
- * of truth for that subtype: DTO type, draft type, patch type, and the zod
1308
- * schemas for each. The catalog union types and runtime schemas are derived
1309
- * from `AnnotationKinds` so adding a subtype is one folder, never a
1310
- * type-system refactor.
1311
- */
1312
- interface AnnotationKindModule<S extends AnnotationSubtype, DTO extends AnnotationBase & {
1313
- subtype: S;
1314
- }, Draft, Patch> {
1315
- readonly subtype: S;
1316
- /**
1317
- * The PDFium subtype code(s) this module handles. Most kinds claim a single
1318
- * code; text-markup kinds map a single PDFium code each (HIGHLIGHT,
1319
- * UNDERLINE, SQUIGGLY, STRIKEOUT) but share an internal reader.
1320
- */
1321
- readonly pdfSubtypeCode: number;
1322
- readonly dtoSchema: ZodType<DTO>;
1323
- readonly draftSchema: ZodType<Draft>;
1324
- readonly patchSchema: ZodType<Patch>;
1325
- }
1326
- //#endregion
1327
- //#region src/dto/PdfDestination.d.ts
1328
- /**
1329
- * An explicit PDF destination (ISO 32000-1 §12.3.2.2): a page, a location,
1330
- * and a magnification. Produced by outlines/bookmarks, link annotations,
1331
- * `/OpenAction`, and GoTo actions; named destinations resolve to one of
1332
- * these through the catalog's `/Dests` dictionary or name tree — the
1333
- * ENGINE does that resolution, so the viewer only ever sees this explicit
1334
- * form.
1335
- *
1336
- * Coordinates are PDF user space (y-up, points, absolute — NOT
1337
- * crop-relative). `null` means "retain the current value" (the spec's
1338
- * meaning for null array entries); a `/XYZ` zoom of `0` is equivalent to
1339
- * null. The `fitB*` kinds refer to the page's content BOUNDING box rather
1340
- * than the crop box.
1341
- *
1342
- * Viewers translate these onto the stage's reveal primitive — see
1343
- * `destinationToReveal` in `@embedpdf/plugin-stage`.
1344
- */
1345
- type PdfDestination = {
1346
- kind: 'xyz';
1347
- pageObjectNumber: PageObjectNumber;
1348
- left?: number | null;
1349
- top?: number | null;
1350
- zoom?: number | null;
1351
- } | {
1352
- kind: 'fit';
1353
- pageObjectNumber: PageObjectNumber;
1354
- } | {
1355
- kind: 'fitH';
1356
- pageObjectNumber: PageObjectNumber;
1357
- top?: number | null;
1358
- } | {
1359
- kind: 'fitV';
1360
- pageObjectNumber: PageObjectNumber;
1361
- left?: number | null;
1362
- } | {
1363
- kind: 'fitR';
1364
- pageObjectNumber: PageObjectNumber;
1365
- left: number;
1366
- bottom: number;
1367
- right: number;
1368
- top: number;
1369
- } | {
1370
- kind: 'fitB';
1371
- pageObjectNumber: PageObjectNumber;
1372
- } | {
1373
- kind: 'fitBH';
1374
- pageObjectNumber: PageObjectNumber;
1375
- top?: number | null;
1376
- } | {
1377
- kind: 'fitBV';
1378
- pageObjectNumber: PageObjectNumber;
1379
- left?: number | null;
1380
- };
1381
- //#endregion
1382
- //#region src/dto/PdfLinkTarget.d.ts
1383
- /**
1384
- * Where a link annotation points, NORMALIZED. A link may carry either a
1385
- * direct `/Dest` or an `/A` action (ISO 32000-1 §12.5.6.5); to a viewer a
1386
- * `/Dest` and a `/A GoTo` are the same intent, so the engine collapses both
1387
- * onto the `goto` arm — clients never see the raw two-shape split (the v2
1388
- * `target.action.destination` double-wrap). Named destinations are resolved
1389
- * to explicit ones engine-side, the same rule {@link PdfDestination}
1390
- * documents.
1391
- *
1392
- * Arm names follow the `PdfActionType` vocabulary (`goto`, `uri`,
1393
- * `goto-remote`, `launch`, `javascript`) so the two action-shaped surfaces
1394
- * never drift.
1395
- *
1396
- * `goto-remote`, `launch`, and `javascript` are READ-ONLY in v1: the
1397
- * engine reports them so a client can display/inspect (or, for
1398
- * `javascript`, hand the link to the scripting orchestrator), but never
1399
- * follows or executes them here, and refuses to write them (see
1400
- * {@link PdfLinkTargetWritable}). `javascript` deliberately carries NO
1401
- * script payload — the text already rides the base
1402
- * `actions.activate` model, which is the scripting plane's single home
1403
- * for action scripts. `unsupported` preserves round-trip for action
1404
- * types the reader doesn't model.
1405
- */
1406
- type PdfLinkTarget = {
1407
- kind: 'goto';
1408
- destination: PdfDestination;
1409
- } | {
1410
- kind: 'uri';
1411
- uri: string;
1412
- } | {
1413
- kind: 'goto-remote';
1414
- file: string;
1415
- } | {
1416
- kind: 'launch';
1417
- path: string;
1418
- } | {
1419
- kind: 'javascript';
1420
- } |
1421
- /** `/S /Named` — a viewer verb (`NextPage`, `PrevPage`, `FirstPage`,
1422
- * `LastPage`, …). Read-only in v1; common in TOC/nav links. */
1423
- {
1424
- kind: 'named';
1425
- name: string;
1426
- } | {
1427
- kind: 'unsupported';
1428
- };
1429
- /**
1430
- * The subset of {@link PdfLinkTarget} that drafts/patches may author:
1431
- * in-document destinations and URIs. Keeping `goto-remote`/`launch` out of
1432
- * the WRITE surface is deliberate (executable-shaped actions are a security
1433
- * liability the viewer never needs to author), and `unsupported` carries
1434
- * nothing to write.
1435
- */
1436
- type PdfLinkTargetWritable = Extract<PdfLinkTarget, {
1437
- kind: 'goto' | 'uri';
1438
- }>;
1439
- //#endregion
1440
- //#region src/identity/FormFieldRef.d.ts
1441
- /**
1442
- * How callers address a logical form field.
1443
- *
1444
- * - `objectNumber` — the indirect object number of the field dictionary.
1445
- * ISO 32000 guarantees every real AcroForm field dictionary is an
1446
- * indirect object, and the layer runtime never renumbers (frozen base +
1447
- * incremental deltas), so this is the durable identity for the lifetime
1448
- * of a document. Preferred for all engine calls.
1449
- * - `fqn` — the fully qualified field name ("billing.name"). The portable,
1450
- * semantic identity used by interchange formats (FDF/XFDF) and analytics;
1451
- * survives document rewrites but is only as unique as the producer made
1452
- * it. The engine resolves it against the reconciled field tree.
1453
- */
1454
- type FormFieldRef = {
1455
- kind: 'objectNumber';
1456
- fieldObjectNumber: number;
1457
- } | {
1458
- kind: 'fqn';
1459
- name: string;
1460
- };
1461
- /** A widget annotation of a field, as the forms subsystem sees it. */
1462
- interface FormWidgetRef {
1463
- /**
1464
- * Indirect object number of the widget annotation — the join key to the
1465
- * annotation subsystem's `objectNumber` refs. `0` when the widget is
1466
- * stored as a direct object (spec-violating; cannot be addressed).
1467
- */
1468
- annotObjectNumber: number;
1469
- /**
1470
- * Object number of the page whose /Annots array references the widget.
1471
- * `0` when the widget is not reachable from any page ("unplaced").
1472
- */
1473
- pageObjectNumber: PageObjectNumber;
1474
- }
1475
- //#endregion
1476
- //#region src/forms/value-entry.d.ts
1477
- /** Lossless shape of a field's effective PDF `/V` or `/DV` object. */
1478
- type FormValueEntry = {
1479
- kind: 'none';
1480
- } | {
1481
- kind: 'scalar';
1482
- value: string;
1483
- } | {
1484
- kind: 'array';
1485
- values: string[];
1486
- } | {
1487
- kind: 'unsupported';
1488
- };
1489
- //#endregion
1490
- //#region src/forms/field.d.ts
1491
- /**
1492
- * The field family — the discriminant of {@link FormFieldDTO}. Narrowing on
1493
- * it reveals exactly the members that are meaningful for that family, the
1494
- * same way annotation DTOs narrow on `subtype`.
1495
- */
1496
- type FormFieldFamily = 'text' | 'checkbox' | 'radio' | 'combobox' | 'listbox' | 'pushbutton' | 'signature' | 'unknown';
1497
- /**
1498
- * Where the field was found.
1499
- *
1500
- * - `acroform` — reachable from the /AcroForm /Fields tree, as the spec
1501
- * requires.
1502
- * - `recovered` — only reachable through a page's /Annots array (a common
1503
- * producer bug). The engine reconciles these on every read so they work
1504
- * like any other field, but other PDF processors will not see them until
1505
- * {@link DocumentFormsService.repair} makes the fix durable.
1506
- */
1507
- type FormFieldOrigin = 'acroform' | 'recovered';
1508
- /**
1509
- * The /Ff flags every field family shares. Family-specific flags (comb,
1510
- * multi-select, radios-in-unison, ...) live as plain booleans on the
1511
- * family DTOs where they are always meaningful.
1512
- */
1513
- interface FormFieldFlags {
1514
- /**
1515
- * The user must not change the value. The engine's write transactions
1516
- * still accept programmatic writes to read-only fields (calculated
1517
- * fields are read-only yet script-written); enforcing fill policy is
1518
- * the application's job.
1519
- */
1520
- readOnly: boolean;
1521
- required: boolean;
1522
- noExport: boolean;
1523
- /** The raw /Ff integer, for anything not surfaced. */
1524
- raw: number;
1525
- }
1526
- /**
1527
- * A widget of a toggle (checkbox/radio) field. Toggle widgets always carry
1528
- * their appearance-state machinery — no nullable fields to probe.
1529
- */
1530
- interface ToggleFieldWidget extends FormWidgetRef {
1531
- /**
1532
- * The widget's appearance state name (the non-"Off" key of its /AP /N
1533
- * dictionary) — the token toggle writes address widgets by.
1534
- */
1535
- onState: string;
1536
- /**
1537
- * The widget's export value (/Opt entry when present, else the
1538
- * on-state). The identity FDF/XFDF carry.
1539
- */
1540
- exportValue: string;
1541
- /** Whether this widget is currently checked. */
1542
- checked: boolean;
1543
- }
1544
- /** One option of a choice (combo/list box) field. */
1545
- interface FormFieldOption {
1546
- /** Display label shown to the user. */
1547
- label: string;
1548
- /** Export value used by /V, interchange, and `FormFieldValue.choice`. */
1549
- value: string;
1550
- /** Whether the option is currently selected. */
1551
- selected: boolean;
1552
- }
1553
- /**
1554
- * The trunk every field family shares: identity, provenance, universal
1555
- * flags, and widget placement. A logical field is the document-scoped
1556
- * record that holds the value; its widgets are page-scoped views — join
1557
- * them to the annotation subsystem via `annotObjectNumber`.
1558
- */
1559
- interface FormFieldBase {
1560
- /** Durable ref (`objectNumber` whenever the field dictionary is indirect). */
1561
- ref: FormFieldRef;
1562
- /** Field dictionary object number; `0` for direct (spec-violating) dicts. */
1563
- fieldObjectNumber: number;
1564
- /** Fully qualified name, e.g. `"billing.name"`. */
1565
- name: string;
1566
- family: FormFieldFamily;
1567
- origin: FormFieldOrigin;
1568
- flags: FormFieldFlags;
1569
- /** /TU — the accessible tooltip / alternate name. */
1570
- alternateName: string | null;
1571
- /** /TM — the export mapping name. */
1572
- mappingName: string | null;
1573
- /** Exact effective `/V` object shape; family conveniences below are derived. */
1574
- valueEntry: FormValueEntry;
1575
- /** Exact effective `/DV` object shape, including absent and malformed values. */
1576
- defaultValueEntry: FormValueEntry;
1577
- /** Effective inherited field `/AA` actions. */
1578
- actions?: PdfFieldActions;
1579
- /** The field's widget annotations, in control order. May be empty ("unplaced"). */
1580
- widgets: FormWidgetRef[];
1581
- }
1582
- /** A text field. Write with `{ type: 'text', value }`. */
1583
- interface TextFieldDTO extends FormFieldBase {
1584
- family: 'text';
1585
- value: string;
1586
- /** /DV — restored by `reset()`. */
1587
- defaultValue: string;
1588
- /** /MaxLen; `null` when unlimited. Longer writes are truncated to this length. */
1589
- maxLength: number | null;
1590
- multiline: boolean;
1591
- password: boolean;
1592
- /** Fixed character cells; meaningful with `maxLength`. */
1593
- comb: boolean;
1594
- }
1595
- /** A checkbox. Write with `{ type: 'toggle', state: onState | null }`. */
1596
- interface CheckboxFieldDTO extends FormFieldBase {
1597
- family: 'checkbox';
1598
- checked: boolean;
1599
- /** The export value reported while checked ("Off" is never exported). */
1600
- exportValue: string;
1601
- widgets: ToggleFieldWidget[];
1602
- }
1603
- /** A radio group: ONE field, N widgets. Write with `{ type: 'toggle', state }`. */
1604
- interface RadioFieldDTO extends FormFieldBase {
1605
- family: 'radio';
1606
- /** The checked widget's export value, or `"Off"` when the group is clear. */
1607
- value: string;
1608
- /** Widgets sharing an export value check together. */
1609
- radiosInUnison: boolean;
1610
- /** The group cannot be cleared once a choice is made. */
1611
- noToggleToOff: boolean;
1612
- widgets: ToggleFieldWidget[];
1613
- }
1614
- /** A combo box (dropdown). Write with `{ type: 'choice', values: [v] }`. */
1615
- interface ComboBoxFieldDTO extends FormFieldBase {
1616
- family: 'combobox';
1617
- /** An option export value — or free text when `edit` is set. */
1618
- value: string;
1619
- /** /DV — restored by `reset()`. */
1620
- defaultValue: string;
1621
- /** Free text is allowed in addition to the options. */
1622
- edit: boolean;
1623
- options: FormFieldOption[];
1624
- }
1625
- /** A list box. Write with `{ type: 'choice', values }`. */
1626
- interface ListBoxFieldDTO extends FormFieldBase {
1627
- family: 'listbox';
1628
- /** Selected option export values, in option order. */
1629
- selectedValues: string[];
1630
- /** Whether several options may be selected at once. */
1631
- multiSelect: boolean;
1632
- options: FormFieldOption[];
1633
- }
1634
- /** A push button: pure trigger, holds no value. Never written or exported. */
1635
- interface PushButtonFieldDTO extends FormFieldBase {
1636
- family: 'pushbutton';
1637
- }
1638
- /**
1639
- * A signature field. Identity and placement only for now — the engine
1640
- * never writes signature values; signing is a future capability.
1641
- */
1642
- interface SignatureFieldDTO extends FormFieldBase {
1643
- family: 'signature';
1644
- }
1645
- /**
1646
- * Forward-compat placeholder for field types the engine does not model,
1647
- * mirroring the `unsupported` annotation kind. Round-trips safely.
1648
- */
1649
- interface UnknownFieldDTO extends FormFieldBase {
1650
- family: 'unknown';
1651
- /** The raw /V value as text, for diagnostics. */
1652
- rawValue: string;
1653
- }
1654
- /**
1655
- * A logical form field. Discriminated on `family`:
1656
- *
1657
- * ```ts
1658
- * if (field.family === 'listbox') {
1659
- * field.selectedValues; // string[]
1660
- * }
1661
- * ```
1662
- */
1663
- type FormFieldDTO = TextFieldDTO | CheckboxFieldDTO | RadioFieldDTO | ComboBoxFieldDTO | ListBoxFieldDTO | PushButtonFieldDTO | SignatureFieldDTO | UnknownFieldDTO;
1664
- //#endregion
1665
- //#region src/annotation/kinds/widget.shared.d.ts
1666
- /**
1667
- * Widget-plane styling, using the same vocabulary as the sibling kinds
1668
- * (`color` strokes the border, `interiorColor` fills, `strokeWidth` is the
1669
- * border width — the free-text/shape convention) mapped onto the widget
1670
- * dictionaries: /MK for colors, /BS for the border, /DA for the text
1671
- * defaults, /Q for alignment.
1672
- *
1673
- * These fields are shared VERBATIM with `doc.forms` authoring: a
1674
- * `WidgetPlacement.appearance` in `createField` is exactly
1675
- * {@link WidgetAppearance}, and one writer applies both underneath.
1676
- */
1677
- interface WidgetStyleFields {
1678
- /** `/MK /BC` — border colour. `null` when the widget draws no border colour. */
1679
- color: Color | null;
1680
- /** `/MK /BG` — background. `null` = transparent (no entry). */
1681
- interiorColor: Color | null;
1682
- /** `/BS /W` — border width. */
1683
- strokeWidth: number;
1684
- /** `/BS /S` — border style. */
1685
- borderStyle: AnnotationBorderStyle;
1686
- /** `/DA` font. Absent when the widget has no default appearance. */
1687
- fontFamily?: StandardFont;
1688
- /** `/DA` size; `0` = auto-size. */
1689
- fontSize?: number;
1690
- /** `/DA` colour. */
1691
- fontColor?: Color;
1692
- /** `/Q`. */
1693
- textAlign: TextAlignment;
1694
- }
1695
- interface WidgetStyleDraftFields {
1696
- /** `/MK /BC`. `null` = write no border colour. */
1697
- color?: Color | null;
1698
- /** `/MK /BG`. `null` = transparent. */
1699
- interiorColor?: Color | null;
1700
- strokeWidth?: number;
1701
- borderStyle?: AnnotationBorderStyle;
1702
- fontFamily?: StandardFont;
1703
- /** `0` = auto-size. */
1704
- fontSize?: number;
1705
- fontColor?: Color;
1706
- textAlign?: TextAlignment;
1707
- }
1708
- /** Patch fields are the draft fields; `null` clears the colour entries. */
1709
- type WidgetStylePatchFields = WidgetStyleDraftFields;
1710
- //#endregion
1711
- //#region src/forms/snapshot.d.ts
1712
- /**
1713
- * What kind of interactive form the document declares.
1714
- *
1715
- * - `none` — no /AcroForm dictionary. Recovered fields may still exist
1716
- * (see {@link FormFieldOrigin}); `repair()` can bootstrap the dictionary.
1717
- * - `acroform` — a standard AcroForm.
1718
- * - `xfa` — the /AcroForm carries an /XFA entry. The engine serves the
1719
- * AcroForm shell read-only and never executes XFA.
1720
- */
1721
- type FormKind = 'none' | 'acroform' | 'xfa';
1722
- /**
1723
- * The document's complete form state at one instant: the reconciled field
1724
- * tree flattened to terminal fields with fully qualified names.
1725
- *
1726
- * Snapshots are detached and immutable — any mutation (a value write, an
1727
- * annotation edit, a page operation) makes previously returned snapshots
1728
- * stale. Re-read after mutating; the engine caches the underlying model
1729
- * per document version, so repeated reads between mutations are cheap.
1730
- */
1731
- interface FormSnapshot {
1732
- formKind: FormKind;
1733
- /**
1734
- * Whether the /AcroForm sets /NeedAppearances (viewer-generated widget
1735
- * appearances). The engine bakes appearances on every write regardless;
1736
- * `repair({ bakeAppearances: true })` can clear the flag document-wide.
1737
- */
1738
- needsAppearances: boolean;
1739
- fields: FormFieldDTO[];
1740
- /** `/AcroForm /CO` order; null preserves each malformed/unresolved slot. */
1741
- calculationOrder: Array<FormFieldRef | null>;
1742
- }
1743
- //#endregion
1744
- //#region src/search/types.d.ts
1745
- /**
1746
- * What to search for — THE one shape, engine → wire → plugin state →
1747
- * search box. One flat object; the flags define behavior per mode instead
1748
- * of the mode changing the shape:
1749
- *
1750
- * | flag | literal | regex |
1751
- * |-------------------|------------------|--------------------------------|
1752
- * | `matchCase` | fold case | `i` flag |
1753
- * | `wholeWord` | boundary check | pattern is `\b(?:…)\b`-wrapped |
1754
- * | `matchDiacritics` | mark fold | REJECTED (`InvalidArg`) |
1755
- *
1756
- * Literal queries match over FOLDED text; regex queries run the portable
1757
- * dialect against the RAW page text — which is why `matchDiacritics`
1758
- * cannot apply to them (diacritic folding is a property of the folded
1759
- * text plane). Validate with `validateSearchQuery` for early UI feedback;
1760
- * engines re-validate and reject with `EngineErrorCode.InvalidArg`.
1761
- */
1762
- interface SearchQuery {
1763
- /**
1764
- * The literal text — or, when `regex`, a pattern in the portable
1765
- * search-regex dialect: JavaScript `u`-mode syntax MINUS backreferences
1766
- * and lookaround, so every valid pattern also runs on RE2 (the
1767
- * server-side engine).
1768
- */
1769
- text: string;
1770
- /** Interpret `text` as a regex pattern. Default false (literal). */
1771
- regex?: boolean;
1772
- /** Exact-case matching. Default false (case-folded / `i` semantics). */
1773
- matchCase?: boolean;
1774
- /** Only match at word boundaries (letters/digits end the word). */
1775
- wholeWord?: boolean;
1776
- /**
1777
- * Treat diacritics as significant ("café" ≠ "cafe"). Default false —
1778
- * marks are stripped on both sides, which is what viewers ship.
1779
- * LITERAL ONLY: combined with `regex` the query is rejected.
1780
- */
1781
- matchDiacritics?: boolean;
1782
- }
1783
- //#endregion
1784
- //#region src/annotation/kinds/text-markup.shared.d.ts
1785
- /**
1786
- * Text-markup family-specific fields. The four text-markup subtypes
1787
- * (highlight/underline/squiggly/strikeout) share their wire shape per
1788
- * ISO 32000 12.5.6.10: the universal {@link ColorStyleFields} (`/C` color +
1789
- * `/CA` opacity) plus one or more `quadPoints` quads.
1790
- *
1791
- * This file ONLY carries fields that are unique to the text-markup
1792
- * family. Annotation-wide author-metadata (`contents`, `author`, `nm`)
1793
- * lives on `AnnotationDraftBase` / `AnnotationPatchBase`. Each kind's
1794
- * draft/patch type composes the two: family fields + base fields +
1795
- * own `subtype` literal.
1796
- */
1797
- interface TextMarkupAnnotationFields extends ColorStyleFields {
1798
- quadPoints: PdfQuad[];
1799
- }
1800
- interface TextMarkupDraftFields extends ColorStyleDraftFields {
1801
- quadPoints: PdfQuad[];
1802
- }
1803
- interface TextMarkupPatchFields extends ColorStylePatchFields {
1804
- quadPoints?: PdfQuad[];
1805
- }
1806
- /** Glue type used by each kind file to construct its concrete DTO. */
1807
- type TextMarkupDTO<S extends string> = AnnotationBase & {
1808
- subtype: S;
1809
- } & TextMarkupAnnotationFields;
1810
- //#endregion
1811
- //#region src/annotation/kinds/highlight/draft.d.ts
1812
- interface HighlightDraft extends AnnotationDraftBase, TextMarkupDraftFields {
1813
- subtype: 'highlight';
1814
- }
1815
- //#endregion
1816
- //#region src/annotation/kinds/highlight/dto.d.ts
1817
- type HighlightAnnotationDTO = TextMarkupDTO<'highlight'>;
1818
- //#endregion
1819
- //#region src/annotation/kinds/highlight/patch.d.ts
1820
- interface HighlightPatch extends AnnotationPatchBase, TextMarkupPatchFields {
1821
- subtype: 'highlight';
1822
- }
1823
- //#endregion
1824
- //#region src/annotation/kinds/underline/draft.d.ts
1825
- interface UnderlineDraft extends AnnotationDraftBase, TextMarkupDraftFields {
1826
- subtype: 'underline';
1827
- }
1828
- //#endregion
1829
- //#region src/annotation/kinds/underline/dto.d.ts
1830
- type UnderlineAnnotationDTO = TextMarkupDTO<'underline'>;
1831
- //#endregion
1832
- //#region src/annotation/kinds/underline/patch.d.ts
1833
- interface UnderlinePatch extends AnnotationPatchBase, TextMarkupPatchFields {
1834
- subtype: 'underline';
1835
- }
1836
- //#endregion
1837
- //#region src/annotation/kinds/squiggly/draft.d.ts
1838
- interface SquigglyDraft extends AnnotationDraftBase, TextMarkupDraftFields {
1839
- subtype: 'squiggly';
1840
- }
1841
- //#endregion
1842
- //#region src/annotation/kinds/squiggly/dto.d.ts
1843
- type SquigglyAnnotationDTO = TextMarkupDTO<'squiggly'>;
1844
- //#endregion
1845
- //#region src/annotation/kinds/squiggly/patch.d.ts
1846
- interface SquigglyPatch extends AnnotationPatchBase, TextMarkupPatchFields {
1847
- subtype: 'squiggly';
1848
- }
1849
- //#endregion
1850
- //#region src/annotation/kinds/strikeout/draft.d.ts
1851
- interface StrikeoutDraft extends AnnotationDraftBase, TextMarkupDraftFields {
1852
- subtype: 'strikeout';
1853
- intent?: StrikeoutIntent;
1854
- }
1855
- //#endregion
1856
- //#region src/annotation/kinds/strikeout/dto.d.ts
1857
- type StrikeoutAnnotationDTO = TextMarkupDTO<'strikeout'> & {
1858
- /** Normalized `/IT`; null for an ordinary standalone strikeout. */
1859
- intent: StrikeoutIntent | null;
1860
- };
1861
- //#endregion
1862
- //#region src/annotation/kinds/strikeout/patch.d.ts
1863
- interface StrikeoutPatch extends AnnotationPatchBase, TextMarkupPatchFields {
1864
- subtype: 'strikeout';
1865
- intent?: StrikeoutIntent;
1866
- }
1867
- //#endregion
1868
- //#region src/annotation/kinds/shape.shared.d.ts
1869
- /**
1870
- * Shape-family-specific fields. The two shape subtypes (circle/square)
1871
- * share their wire shape per ISO 32000 §12.5.6.8: they are `/Rect`-based
1872
- * outlines with the common stroke/fill styling ({@link FilledStyleFields}),
1873
- * an optional cloudy border effect (`/BE`), and optional rectangle
1874
- * differences (`/RD`).
1875
- *
1876
- * Unlike the text-markup family (which derives `/Rect` from `quadPoints`),
1877
- * shapes carry `/Rect` as their primary geometry — so the Draft requires
1878
- * `rect` explicitly while the DTO inherits it from `AnnotationBase`.
1879
- */
1880
- /**
1881
- * Rotation fields shared by the rotatable box families (shapes + free-text).
1882
- * `rotation` is degrees in PDF convention (the v3 plugin converts its
1883
- * content-space clockwise angle at the boundary); `unrotatedRect` is the
1884
- * logical (pre-rotation) box. Together they drive PDFium's `/EMBD_Metadata`
1885
- * AP rotation (`/Matrix` + `/BBox`); `/Rect` stays the rotated visual AABB.
1886
- */
1887
- interface ShapeAnnotationFields extends FilledStyleFields {
1888
- /** `/BE` cloudy border intensity; `null` when the border carries no effect. */
1889
- cloudyIntensity: number | null;
1890
- /** `/RD` rectangle differences (inset of drawn geometry from `/Rect`); `null` when absent. */
1891
- rectDifferences: PdfRectDifferences | null;
1892
- /** `/EMBD_Metadata/Rotation` — degrees, normalized `[0,360)`. */
1893
- rotation?: number;
1894
- /** `/EMBD_Metadata/UnrotatedRect` — the logical box (required when rotation != 0). */
1895
- unrotatedRect?: PdfRect;
1896
- }
1897
- interface ShapeDraftFields extends FilledStyleDraftFields {
1898
- /** `/Rect` geometry — required for shapes (they are not derived from quads). */
1899
- rect: PdfRect;
1900
- cloudyIntensity?: number | null;
1901
- rectDifferences?: PdfRectDifferences | null;
1902
- rotation?: number | null;
1903
- unrotatedRect?: PdfRect | null;
1904
- }
1905
- interface ShapePatchFields extends FilledStylePatchFields {
1906
- rect?: PdfRect;
1907
- /** Tri-state (as `interiorColor`): omitted preserves, a value sets, `null` removes `/BE`. */
1908
- cloudyIntensity?: number | null;
1909
- /** Tri-state: omitted preserves, a value sets, `null` removes `/RD`. */
1910
- rectDifferences?: PdfRectDifferences | null;
1911
- /** Tri-state: omitted preserves, `null`/`0` flattens, a value sets (needs the box). */
1912
- rotation?: number | null;
1913
- /** Tri-state: omitted preserves, `null` removes, a value sets. */
1914
- unrotatedRect?: PdfRect | null;
1915
- }
1916
- /** Glue type used by each shape kind file to construct its concrete DTO. */
1917
- type ShapeDTO<S extends string> = AnnotationBase & {
1918
- subtype: S;
1919
- } & ShapeAnnotationFields;
1920
- //#endregion
1921
- //#region src/annotation/kinds/circle/draft.d.ts
1922
- interface CircleDraft extends AnnotationDraftBase, ShapeDraftFields {
1923
- subtype: 'circle';
1924
- }
1925
- //#endregion
1926
- //#region src/annotation/kinds/circle/dto.d.ts
1927
- type CircleAnnotationDTO = ShapeDTO<'circle'>;
1928
- //#endregion
1929
- //#region src/annotation/kinds/circle/patch.d.ts
1930
- interface CirclePatch extends AnnotationPatchBase, ShapePatchFields {
1931
- subtype: 'circle';
1932
- }
1933
- //#endregion
1934
- //#region src/annotation/kinds/square/draft.d.ts
1935
- interface SquareDraft extends AnnotationDraftBase, ShapeDraftFields {
1936
- subtype: 'square';
1937
- }
1938
- //#endregion
1939
- //#region src/annotation/kinds/square/dto.d.ts
1940
- type SquareAnnotationDTO = ShapeDTO<'square'>;
1941
- //#endregion
1942
- //#region src/annotation/kinds/square/patch.d.ts
1943
- interface SquarePatch extends AnnotationPatchBase, ShapePatchFields {
1944
- subtype: 'square';
1945
- }
1946
- //#endregion
1947
- //#region src/annotation/kinds/vertex.shared.d.ts
1948
- /**
1949
- * Vertex-family-specific fields. The two vertex subtypes (polygon/polyline)
1950
- * carry their geometry as a `/Vertices` point list (ISO 32000 §12.5.6.9)
1951
- * plus the common stroke/fill styling ({@link FilledStyleFields}). Polygon
1952
- * layers a cloudy border (`/BE`) on top; polyline layers line endings
1953
- * (`/LE`); each kind file adds those. (Polygon does not use `/RD` — its
1954
- * geometry is fully described by `/Vertices` + `/Rect`, so `/RD` is for the
1955
- * shape family only.)
1956
- *
1957
- * Like shapes, the engine takes an explicit `/Rect` on the Draft (the v3
1958
- * plugin owns the bounding-box + rotation math, so the engine stays a
1959
- * faithful persistence layer); the DTO inherits `rect` from
1960
- * `AnnotationBase`.
1961
- */
1962
- interface VertexAnnotationFields extends FilledStyleFields {
1963
- /** `/Vertices` — the ordered point list (PDF user space, y-up). */
1964
- vertices: PdfPoint[];
1965
- /**
1966
- * `/EMBD_Metadata/Rotation` — ADVISORY rotation (degrees, PDF convention). The
1967
- * vertices are already rotated (they ARE the portable visual); this scalar
1968
- * just records the applied angle so EmbedPDF can show an oriented selection
1969
- * box and offer reset. It carries NO `unrotatedRect`, so it is inert for AP
1970
- * (PDFium ignores a lone `Rotation`).
1971
- */
1972
- rotation?: number;
1973
- }
1974
- interface VertexDraftFields extends FilledStyleDraftFields {
1975
- /** `/Vertices` geometry — required (vertex annotations are not derived). */
1976
- vertices: PdfPoint[];
1977
- /** `/Rect` bounding box — required (computed by the caller/plugin). */
1978
- rect: PdfRect;
1979
- /** Advisory rotation (deg). See {@link VertexAnnotationFields.rotation}. */
1980
- rotation?: number | null;
1981
- }
1982
- interface VertexPatchFields extends FilledStylePatchFields {
1983
- vertices?: PdfPoint[];
1984
- rect?: PdfRect;
1985
- /** Tri-state: omitted preserves, `null`/`0` clears the advisory scalar. */
1986
- rotation?: number | null;
1987
- }
1988
- /** Glue type used by each vertex kind file to construct its concrete DTO. */
1989
- type VertexDTO<S extends string> = AnnotationBase & {
1990
- subtype: S;
1991
- } & VertexAnnotationFields;
1992
- //#endregion
1993
- //#region src/annotation/kinds/polygon/draft.d.ts
1994
- interface PolygonDraft extends AnnotationDraftBase, VertexDraftFields {
1995
- subtype: 'polygon';
1996
- cloudyIntensity?: number | null;
1997
- }
1998
- //#endregion
1999
- //#region src/annotation/kinds/polygon/dto.d.ts
2000
- type PolygonAnnotationDTO = VertexDTO<'polygon'> & {
2001
- /** `/BE` cloudy border intensity; `null` when the border carries no effect. */
2002
- cloudyIntensity: number | null;
2003
- };
2004
- //#endregion
2005
- //#region src/annotation/kinds/polygon/patch.d.ts
2006
- interface PolygonPatch extends AnnotationPatchBase, VertexPatchFields {
2007
- subtype: 'polygon';
2008
- /** Tri-state (as `interiorColor`): omitted preserves, a value sets, `null` removes `/BE`. */
2009
- cloudyIntensity?: number | null;
2010
- }
2011
- //#endregion
2012
- //#region src/annotation/kinds/polyline/draft.d.ts
2013
- interface PolylineDraft extends AnnotationDraftBase, VertexDraftFields {
2014
- subtype: 'polyline';
2015
- lineEndings?: LineEndings;
2016
- }
2017
- //#endregion
2018
- //#region src/annotation/kinds/polyline/dto.d.ts
2019
- type PolylineAnnotationDTO = VertexDTO<'polyline'> & {
2020
- lineEndings: LineEndings;
2021
- };
2022
- //#endregion
2023
- //#region src/annotation/kinds/polyline/patch.d.ts
2024
- interface PolylinePatch extends AnnotationPatchBase, VertexPatchFields {
2025
- subtype: 'polyline';
2026
- lineEndings?: LineEndings;
2027
- }
2028
- //#endregion
2029
- //#region src/annotation/kinds/line/draft.d.ts
2030
- interface LineDraft extends AnnotationDraftBase, FilledStyleDraftFields {
2031
- subtype: 'line';
2032
- /** `/L` the two endpoints — required. */
2033
- linePoints: LinePoints;
2034
- /** `/Rect` bounding box — required (computed by the caller/plugin). */
2035
- rect: PdfRect;
2036
- lineEndings?: LineEndings;
2037
- /** Advisory rotation (deg). */
2038
- rotation?: number | null;
2039
- }
2040
- //#endregion
2041
- //#region src/annotation/kinds/line/dto.d.ts
2042
- type LineAnnotationDTO = AnnotationBase & {
2043
- subtype: 'line';
2044
- /** `/L` the two endpoints of the line. */
2045
- linePoints: LinePoints;
2046
- /** `/LE` the start/end line endings. */
2047
- lineEndings: LineEndings;
2048
- /** `/EMBD_Metadata/Rotation` — advisory rotation (deg); the endpoints are
2049
- * already rotated. No `unrotatedRect`, so it is inert for AP. */
2050
- rotation?: number;
2051
- } & FilledStyleFields;
2052
- //#endregion
2053
- //#region src/annotation/kinds/line/patch.d.ts
2054
- interface LinePatch extends AnnotationPatchBase, FilledStylePatchFields {
2055
- subtype: 'line';
2056
- linePoints?: LinePoints;
2057
- rect?: PdfRect;
2058
- lineEndings?: LineEndings;
2059
- rotation?: number | null;
2060
- }
2061
- //#endregion
2062
- //#region src/annotation/kinds/link/draft.d.ts
2063
- /**
2064
- * Creates a link annotation. `target: null` is allowed — the authoring flow
2065
- * is create-then-edit (drag the rect first, set the destination/URI from the
2066
- * selection editor) — and only `goto`/`uri` targets are writable (see
2067
- * {@link PdfLinkTargetWritable}).
2068
- *
2069
- * To group the link to another annotation (v2's attached links), pass the
2070
- * base draft's `inReplyTo` + `replyType: 'group'` — relationship writing is
2071
- * kind-agnostic.
2072
- */
2073
- interface LinkDraft extends AnnotationDraftBase {
2074
- subtype: 'link';
2075
- /** `/Rect` — required; a link IS its hit rectangle. */
2076
- rect: PdfRect;
2077
- target: PdfLinkTargetWritable | null;
2078
- }
2079
- //#endregion
2080
- //#region src/annotation/kinds/link/dto.d.ts
2081
- /**
2082
- * Link annotation (`/Subtype /Link`): an invisible hit rectangle over page
2083
- * content that navigates somewhere. The DTO carries the NORMALIZED target
2084
- * (see {@link PdfLinkTarget} — `/Dest` and `/A GoTo` both read as `goto`)
2085
- * plus the base shell; links draw nothing of their own in v1 (any visible
2086
- * border a PDF specifies still renders through the page raster).
2087
- *
2088
- * Links ride the base relationship fields like every kind: a link grouped
2089
- * to another annotation (the Apryse/v2 "attached link" pattern) reads as
2090
- * `inReplyTo` + `replyType: 'group'`.
2091
- */
2092
- interface LinkAnnotationDTO extends AnnotationBase {
2093
- subtype: 'link';
2094
- /** `null` = a dead link (no `/A`, no `/Dest`) — legal PDF, reported as-is. */
2095
- target: PdfLinkTarget | null;
2096
- }
2097
- //#endregion
2098
- //#region src/annotation/kinds/link/patch.d.ts
2099
- /**
2100
- * Move (`rect`) and retarget a link. `target` is three-state: `undefined`
2101
- * leaves it, a value REPLACES the `/A` action (any stray direct `/Dest`
2102
- * is stripped — the spec forbids both), and `null` CLEARS the target
2103
- * entirely (`/A` and `/Dest` both removed → a dead link). Only
2104
- * `goto`/`uri` targets are writable.
2105
- */
2106
- interface LinkPatch extends AnnotationPatchBase {
2107
- subtype: 'link';
2108
- rect?: PdfRect;
2109
- target?: PdfLinkTargetWritable | null;
2110
- }
2111
- //#endregion
2112
- //#region src/annotation/kinds/ink/draft.d.ts
2113
- interface InkDraft extends AnnotationDraftBase, GeometryStyleDraftFields {
2114
- subtype: 'ink';
2115
- intent?: InkIntent;
2116
- /** `/InkList` — required (the freehand strokes). */
2117
- inkList: InkList;
2118
- /** `/Rect` bounding box — required (computed by the caller/plugin). */
2119
- rect: PdfRect;
2120
- /** Advisory rotation (deg). */
2121
- rotation?: number | null;
2122
- }
2123
- //#endregion
2124
- //#region src/annotation/kinds/ink/dto.d.ts
2125
- type InkAnnotationDTO = AnnotationBase & {
2126
- subtype: 'ink';
2127
- /** Normalized `/IT`; null for ordinary pen ink. */
2128
- intent: InkIntent | null;
2129
- /** `/InkList` — the freehand pen strokes (array of point paths). */
2130
- inkList: InkList;
2131
- /** `/EMBD_Metadata/Rotation` — advisory rotation (deg); strokes are already
2132
- * rotated. No `unrotatedRect`, so it is inert for AP. */
2133
- rotation?: number;
2134
- } & GeometryStyleFields;
2135
- //#endregion
2136
- //#region src/annotation/kinds/ink/patch.d.ts
2137
- interface InkPatch extends AnnotationPatchBase, GeometryStylePatchFields {
2138
- subtype: 'ink';
2139
- intent?: InkIntent;
2140
- inkList?: InkList;
2141
- rect?: PdfRect;
2142
- rotation?: number | null;
2143
- }
2144
- //#endregion
2145
- //#region src/annotation/kinds/free-text/draft.d.ts
2146
- interface FreeTextDraft extends AnnotationDraftBase {
2147
- subtype: 'free-text';
2148
- /** `/IT` intent — required (selects plain text box vs callout). */
2149
- intent: FreeTextIntent;
2150
- /**
2151
- * A PDF standard font name, or the `key` of a font registered through
2152
- * `engine.fonts`. A registered key makes the `/DA` reference that runtime
2153
- * font and embeds a per-annotation glyph subset on save (local engine only).
2154
- */
2155
- fontFamily: FreeTextFont;
2156
- fontSize: number;
2157
- textAlign: TextAlignment;
2158
- /** `/Rect` bounding box — required (computed by the caller/plugin). */
2159
- rect: PdfRect;
2160
- /** `/DA` colour (border + default text). */
2161
- color?: Color;
2162
- /** Text colour override (`TextColor`). Omit to let text follow `color`. */
2163
- fontColor?: Color;
2164
- /** `/C` box background. `null`/omitted = transparent. */
2165
- interiorColor?: Color | null;
2166
- opacity?: number;
2167
- strokeWidth?: number;
2168
- borderStyle?: AnnotationBorderStyle;
2169
- dashArray?: number[];
2170
- rectDifferences?: PdfRectDifferences | null;
2171
- calloutLine?: CalloutLine;
2172
- lineEnding?: LineEnding;
2173
- rotation?: number | null;
2174
- unrotatedRect?: PdfRect | null;
2175
- }
2176
- //#endregion
2177
- //#region src/annotation/kinds/free-text/dto.d.ts
2178
- /**
2179
- * FreeText (and Callout) annotation. One kind covers both: a plain text box
2180
- * (`intent: 'free-text'`) and a callout (`intent: 'free-text-callout'`) which
2181
- * adds a `/CL` leader line.
2182
- *
2183
- * Color model (see the kind docs): `color` is the `/DA` colour — it paints the
2184
- * border and, by default, the text. `fontColor` (optional) overrides just the
2185
- * text via the `TextColor` channel. `interiorColor` is the `/C` box background
2186
- * (`null` when transparent).
2187
- */
2188
- type FreeTextAnnotationDTO = AnnotationBase & {
2189
- subtype: 'free-text';
2190
- /** `/IT` intent. */
2191
- intent: FreeTextIntent;
2192
- /** `/DA` font. */
2193
- fontFamily: StandardFont;
2194
- /** `/DA` font size, in points. */
2195
- fontSize: number;
2196
- /** `/Q` horizontal text alignment. */
2197
- textAlign: TextAlignment;
2198
- /** `/DA` colour: the border colour and the default text colour. */
2199
- color: Color;
2200
- /** Text colour override (`TextColor`). Absent when the text follows `color`. */
2201
- fontColor?: Color;
2202
- /** `/C` box background. `null` when the box is transparent. */
2203
- interiorColor: Color | null;
2204
- /** `/CA` constant opacity, 0..1. */
2205
- opacity: number;
2206
- /** `/BS /W` border width, in points. */
2207
- strokeWidth: number;
2208
- /** `/BS /S` border style. */
2209
- borderStyle: AnnotationBorderStyle;
2210
- /** `/BS /D` dash pattern. Only meaningful when `borderStyle === 'dashed'`. */
2211
- dashArray?: number[];
2212
- /** `/RD` inset of the drawn box from `/Rect`; `null` when absent. */
2213
- rectDifferences: PdfRectDifferences | null;
2214
- /** `/CL` leader line (2 or 3 points). */
2215
- calloutLine?: CalloutLine;
2216
- /** `/LE` ending drawn at the called-out end of the leader line. */
2217
- lineEnding?: LineEnding;
2218
- /** `/EMBD_Metadata/Rotation` — degrees, normalized `[0,360)`. */
2219
- rotation?: number;
2220
- /** `/EMBD_Metadata/UnrotatedRect` — the logical box (required when rotation != 0). */
2221
- unrotatedRect?: PdfRect;
2222
- };
2223
- //#endregion
2224
- //#region src/annotation/kinds/free-text/patch.d.ts
2225
- interface FreeTextPatch extends AnnotationPatchBase {
2226
- subtype: 'free-text';
2227
- intent?: FreeTextIntent;
2228
- /** A PDF standard font name or a registered font `key`. See `FreeTextDraft`. */
2229
- fontFamily?: FreeTextFont;
2230
- fontSize?: number;
2231
- textAlign?: TextAlignment;
2232
- rect?: PdfRect;
2233
- color?: Color;
2234
- fontColor?: Color;
2235
- interiorColor?: Color | null;
2236
- opacity?: number;
2237
- strokeWidth?: number;
2238
- borderStyle?: AnnotationBorderStyle;
2239
- dashArray?: number[];
2240
- /** Tri-state: omitted preserves, a value sets, `null` removes `/RD`. */
2241
- rectDifferences?: PdfRectDifferences | null;
2242
- calloutLine?: CalloutLine;
2243
- lineEnding?: LineEnding;
2244
- /** Tri-state: omitted preserves, `null`/`0` flattens, a value sets (needs the box). */
2245
- rotation?: number | null;
2246
- /** Tri-state: omitted preserves, `null` removes, a value sets. */
2247
- unrotatedRect?: PdfRect | null;
2248
- }
2249
- //#endregion
2250
- //#region src/annotation/kinds/caret/draft.d.ts
2251
- interface CaretDraft extends AnnotationDraftBase, ColorStyleDraftFields {
2252
- subtype: 'caret';
2253
- /** `/IT /Replace` for the primary of a replace-text pair. */
2254
- intent?: CaretIntent;
2255
- /** `/Rect` bounding box — required (computed by the caller/plugin). */
2256
- rect: PdfRect;
2257
- /** `/RD` inset of the drawn caret from `/Rect`. */
2258
- rectDifferences?: PdfRectDifferences | null;
2259
- }
2260
- //#endregion
2261
- //#region src/annotation/kinds/caret/dto.d.ts
2262
- /**
2263
- * Caret annotation — a visual marker for a proposed text insertion or edit
2264
- * point. It carries no geometry of its own beyond `/Rect`: just a `/C` color,
2265
- * `/CA` opacity, and an optional `/RD` inset of the drawn symbol from `/Rect`.
2266
- */
2267
- type CaretAnnotationDTO = AnnotationBase & ColorStyleFields & {
2268
- subtype: 'caret';
2269
- /** Normalized `/IT`; null for an ordinary caret without a text-edit intent. */
2270
- intent: CaretIntent | null;
2271
- /** `/RD` inset of the drawn caret from `/Rect`; `null` when absent. */
2272
- rectDifferences: PdfRectDifferences | null;
2273
- };
2274
- //#endregion
2275
- //#region src/annotation/kinds/caret/patch.d.ts
2276
- interface CaretPatch extends AnnotationPatchBase, ColorStylePatchFields {
2277
- subtype: 'caret';
2278
- intent?: CaretIntent;
2279
- rect?: PdfRect;
2280
- /** Tri-state: omitted preserves, a value sets, `null` removes `/RD`. */
2281
- rectDifferences?: PdfRectDifferences | null;
2282
- }
2283
- //#endregion
2284
- //#region src/annotation/kinds/text/draft.d.ts
2285
- /**
2286
- * `/Name` icon of a text (sticky-note) annotation — ISO 32000 §12.5.6.4.
2287
- * The appearance generator currently draws one note glyph for every icon;
2288
- * the name still round-trips so other viewers can render their own set.
2289
- */
2290
- type NoteIcon = 'comment' | 'key' | 'note' | 'help' | 'new-paragraph' | 'paragraph' | 'insert';
2291
- /**
2292
- * Text annotation ("sticky note", `/Subtype /Text`). The generated
2293
- * appearance is a fixed 20×20 icon anchored at the `/Rect`'s bottom-left
2294
- * corner, filled with `color` (`/C`, default yellow) and outlined with a
2295
- * luminance-contrast stroke. Note tools typically also set
2296
- * `flags: { print: true, noZoom: true, noRotate: true }`.
2297
- */
2298
- interface TextDraft extends AnnotationDraftBase, ColorStyleDraftFields {
2299
- subtype: 'text';
2300
- /** `/Rect` — the icon renders 20×20 from this rect's bottom-left corner. */
2301
- rect: PdfRect;
2302
- /** `/Name` icon. Default `'note'` (the ISO 32000 default). */
2303
- icon?: NoteIcon;
2304
- }
2305
- //#endregion
2306
- //#region src/annotation/kinds/text/dto.d.ts
2307
- /**
2308
- * Text annotation ("sticky note") — an icon-sized comment marker whose
2309
- * conversation text lives in the base `contents` (and replies via
2310
- * `inReplyTo`). Popup state (`/Popup`, `/Open`) is presentation-layer and
2311
- * deliberately not modeled here.
2312
- */
2313
- type TextAnnotationDTO = AnnotationBase & ColorStyleFields & {
2314
- subtype: 'text';
2315
- /** `/Name` icon; an absent `/Name` reads as `'note'` (the ISO default). */
2316
- icon: NoteIcon;
2317
- };
2318
- //#endregion
2319
- //#region src/annotation/kinds/text/patch.d.ts
2320
- interface TextPatch extends AnnotationPatchBase, ColorStylePatchFields {
2321
- subtype: 'text';
2322
- rect?: PdfRect;
2323
- icon?: NoteIcon;
2324
- }
2325
- //#endregion
2326
- //#region src/annotation/kinds/stamp/draft.d.ts
2327
- /**
2328
- * How the stamp's content is scaled into `/Rect` (CSS `object-fit`
2329
- * vocabulary; maps onto the native `EPDF_STAMP_FIT` policies):
2330
- * `'contain'` preserves aspect and stays fully visible, `'cover'`
2331
- * preserves aspect and fills the box (may crop), `'fill'` stretches.
2332
- */
2333
- type StampFit = 'contain' | 'cover' | 'fill';
2334
- /**
2335
- * Wire form of {@link StampDraft}: pure JSON, validated by the single Zod
2336
- * schema on client, worker, and server. The `source` bytes travel
2337
- * out-of-band under the referenced resource key.
2338
- */
2339
- interface StampWireDraft extends AnnotationDraftBase {
2340
- subtype: 'stamp';
2341
- rect: PdfRect;
2342
- source: ResourceRef;
2343
- name?: string;
2344
- fit?: StampFit;
2345
- rotation?: number | null;
2346
- unrotatedRect?: PdfRect | null;
2347
- }
2348
- //#endregion
2349
- //#region src/annotation/kinds/stamp/dto.d.ts
2350
- /**
2351
- * Stamp annotation (`/Subtype /Stamp`, ISO 32000 §12.5.6.12).
2352
- *
2353
- * The DTO carries no binary fields: the stamp's visual content lives in its
2354
- * `/AP` appearance stream inside the document, and is displayed via
2355
- * `renderAppearanceImages()` like every other baked appearance.
2356
- */
2357
- type StampAnnotationDTO = AnnotationBase & {
2358
- subtype: 'stamp';
2359
- /** `/Name` — advisory stamp label ('Approved', 'Draft', …). */
2360
- name: string | null;
2361
- /** Rotation (deg) from `/EMBD_Metadata`. */
2362
- rotation?: number;
2363
- /** Pre-rotation `/Rect` from `/EMBD_Metadata` (present with `rotation`). */
2364
- unrotatedRect?: PdfRect;
2365
- };
2366
- /** Wire form of {@link StampPatch} — see {@link StampWireDraft} for the rules. */
2367
- interface StampWirePatch extends AnnotationPatchBase {
2368
- subtype: 'stamp';
2369
- rect?: PdfRect;
2370
- source?: ResourceRef;
2371
- name?: string;
2372
- fit?: StampFit;
2373
- rotation?: number | null;
2374
- unrotatedRect?: PdfRect | null;
2375
- }
2376
- //#endregion
2377
- //#region src/annotation/kinds/file-attachment/dto.d.ts
2378
- /**
2379
- * FileAttachment annotation. The DTO carries the attached file's METADATA
2380
- * only — bytes never ride a listing. Download them explicitly via
2381
- * `PageAnnotationsService.downloadFile(ref)`.
2382
- */
2383
- type FileAttachmentAnnotationDTO = AnnotationBase & ColorStyleFields & {
2384
- subtype: 'file-attachment';
2385
- /** `/Name` icon; an absent `/Name` reads as `'push-pin'` (the ISO default). */
2386
- icon: FileAttachmentIcon;
2387
- /** Metadata of the attached file (`/FS` filespec projection). */
2388
- file: AttachmentFileInfo;
2389
- };
2390
- //#endregion
2391
- //#region src/annotation/kinds/file-attachment/patch.d.ts
2392
- /**
2393
- * The attached `file` is deliberately NOT patchable — bytes enter once at
2394
- * create; replacing a file is a new attachment (delete + create). Only
2395
- * the icon presentation and base fields can change.
2396
- */
2397
- interface FileAttachmentPatch extends AnnotationPatchBase, ColorStylePatchFields {
2398
- subtype: 'file-attachment';
2399
- rect?: PdfRect;
2400
- icon?: FileAttachmentIcon;
2401
- }
2402
- //#endregion
2403
- //#region src/annotation/kinds/widget/draft.d.ts
2404
- /**
2405
- * Creates an INERT widget annotation — placed and styled, but not yet a
2406
- * form control. Adoption (`doc.forms.attachWidget`, or inline placement in
2407
- * `doc.forms.createField`) is what binds it to a field and bakes the
2408
- * family-correct appearance.
2409
- */
2410
- interface WidgetDraft extends AnnotationDraftBase, WidgetStyleDraftFields {
2411
- subtype: 'widget';
2412
- /** `/Rect` — required; widgets are box-placed. */
2413
- rect: PdfRect;
2414
- }
2415
- //#endregion
2416
- //#region src/annotation/kinds/widget/dto.d.ts
2417
- /**
2418
- * A form widget annotation: the page-scoped VIEW of a logical form field.
2419
- * The value, options, and field semantics live on `doc.forms`; this DTO
2420
- * carries the widget plane only — geometry, appearance, and the join key.
2421
- *
2422
- * Widgets are readable and patchable like every kind, and creatable as
2423
- * INERT annotations (no field). Adoption by a field — and deletion while
2424
- * adopted — go through `doc.forms` (`attachWidget` / `deleteField`), which
2425
- * own the field-tree bookkeeping.
2426
- */
2427
- interface WidgetAnnotationDTO extends AnnotationBase, WidgetStyleFields {
2428
- subtype: 'widget';
2429
- /**
2430
- * Object number of the owning field's dictionary, or `0` when the
2431
- * widget is unattached (inert). Join key to `FormFieldDTO.ref` /
2432
- * `FormFieldWidget.annotObjectNumber` on the forms side.
2433
- */
2434
- fieldObjectNumber: number;
2435
- /**
2436
- * The owning field's family when attached — what kind of control this
2437
- * widget renders. `'unknown'` for inert widgets (no field yet). Client
2438
- * kind tables key per-family editing surfaces (a radio widget has no
2439
- * font) off this without consulting the forms snapshot.
2440
- */
2441
- fieldFamily: FormFieldFamily;
2442
- }
2443
- //#endregion
2444
- //#region src/annotation/kinds/widget/patch.d.ts
2445
- /**
2446
- * Move (`rect`) and restyle a widget through the annotation plane — the
2447
- * same path every other kind uses. When the widget is attached to a field
2448
- * the engine re-bakes the family-correct appearance after the patch.
2449
- */
2450
- interface WidgetPatch extends AnnotationPatchBase, WidgetStylePatchFields {
2451
- subtype: 'widget';
2452
- rect?: PdfRect;
2453
- }
2454
- //#endregion
2455
- //#region src/annotation/kinds/redact/draft.d.ts
2456
- interface RedactDraft extends AnnotationDraftBase {
2457
- subtype: 'redact';
2458
- /**
2459
- * `/Rect` bounding box — required (for a text redaction, the caller
2460
- * computes it as the quads' bounds).
2461
- */
2462
- rect: PdfRect;
2463
- /** `/QuadPoints`. Omit (or send empty) for an area redaction. */
2464
- quadPoints?: PdfQuad[];
2465
- /** `/C` marking-stage outline colour. */
2466
- color?: Color;
2467
- /** `/CA` marking-stage opacity. The applied overlay always paints opaque. */
2468
- opacity?: number;
2469
- /** `/IC` fill painted after apply. `null`/omitted = region left transparent. */
2470
- interiorColor?: Color | null;
2471
- /**
2472
- * `/OverlayText`. When set, the writer also emits a `/DA` (ISO requires
2473
- * one alongside `/OverlayText`), defaulting any omitted triple member.
2474
- */
2475
- overlayText?: string;
2476
- /** `/Repeat` — tile the label to fill the region. */
2477
- repeat?: boolean;
2478
- /**
2479
- * `/DA` font: a PDF standard font name, or the `key` of a font registered
2480
- * through `engine.fonts` (embeds a per-annotation glyph subset on save —
2481
- * local engine only). See `FreeTextDraft`.
2482
- */
2483
- fontFamily?: FreeTextFont;
2484
- /** `/DA` font size, in points. `0` = auto-fit the label to the region. */
2485
- fontSize?: number;
2486
- /** `/DA` colour: the label text colour. */
2487
- fontColor?: Color;
2488
- /** `/Q` label alignment. */
2489
- textAlign?: TextAlignment;
2490
- }
2491
- //#endregion
2492
- //#region src/annotation/kinds/redact/dto.d.ts
2493
- /**
2494
- * Redaction annotation (`/Redact`, ISO 32000-2 12.5.6.23). The annotation is
2495
- * the non-destructive MARKING stage: it declares what should be removed and
2496
- * what the region must look like afterwards. The destructive APPLY is a
2497
- * separate document operation, not an annotation mutation.
2498
- *
2499
- * Color model: `color` is `/C` — the marking-stage outline (the universal
2500
- * `/C` field every family shares). `interiorColor` is `/IC` — the fill
2501
- * painted where content was removed once the redaction is applied (`null` =
2502
- * region left transparent, the ISO default).
2503
- *
2504
- * Label model: `overlayText` (`/OverlayText`) is drawn over the applied
2505
- * region, styled by the `/DA` triple (`fontFamily`/`fontSize`/`fontColor`)
2506
- * and `/Q` (`textAlign`); `repeat` (`/Repeat`) tiles it to fill the region.
2507
- * A pre-baked `/RO` overlay stream, when present in a file, takes precedence
2508
- * over all of these at apply time — it is an appearance artifact and is not
2509
- * surfaced on the DTO.
2510
- */
2511
- type RedactAnnotationDTO = AnnotationBase & ColorStyleFields & {
2512
- subtype: 'redact';
2513
- /**
2514
- * `/QuadPoints` — the regions of a text redaction. Empty for an area
2515
- * redaction, where `/Rect` itself is the removal region (ISO 32000-2).
2516
- */
2517
- quadPoints: PdfQuad[];
2518
- /** `/IC` fill painted after apply. `null` when the region stays transparent. */
2519
- interiorColor: Color | null;
2520
- /** `/OverlayText` label. `null` when the redaction has no label. */
2521
- overlayText: string | null;
2522
- /** `/Repeat` — tile the label to fill the region. */
2523
- repeat: boolean;
2524
- /** `/DA` font. */
2525
- fontFamily: StandardFont;
2526
- /** `/DA` font size, in points. `0` = auto-fit the label to the region. */
2527
- fontSize: number;
2528
- /** `/DA` colour: the label text colour. */
2529
- fontColor: Color;
2530
- /** `/Q` label alignment. */
2531
- textAlign: TextAlignment;
2532
- };
2533
- //#endregion
2534
- //#region src/annotation/kinds/redact/patch.d.ts
2535
- interface RedactPatch extends AnnotationPatchBase {
2536
- subtype: 'redact';
2537
- rect?: PdfRect;
2538
- quadPoints?: PdfQuad[];
2539
- color?: Color;
2540
- opacity?: number;
2541
- interiorColor?: Color | null;
2542
- /** `/OverlayText`. `null` clears the label. */
2543
- overlayText?: string | null;
2544
- repeat?: boolean;
2545
- /**
2546
- * `/DA` triple. Because `/DA` packs font, size, and colour into one string,
2547
- * send the full triple (`fontFamily` + `fontSize` + `fontColor`) together
2548
- * when changing any of them — same rule as `FreeTextPatch`.
2549
- */
2550
- fontFamily?: FreeTextFont;
2551
- fontSize?: number;
2552
- fontColor?: Color;
2553
- textAlign?: TextAlignment;
2554
- }
2555
- //#endregion
2556
- //#region src/annotation/kinds/unsupported/dto.d.ts
2557
- /**
2558
- * Forward-compat fallback. Emitted whenever the engine encounters a
2559
- * subtype it doesn't (yet) have a dedicated reader for. The wire format
2560
- * is stable: when a per-subtype reader lands later, the engine starts
2561
- * producing the dedicated DTO without breaking older clients.
2562
- */
2563
- interface UnsupportedAnnotationDTO extends AnnotationBase {
2564
- subtype: 'unsupported';
2565
- /** PDFium's `FPDFAnnot_GetSubtype` integer code for diagnostics. */
2566
- rawSubtypeCode: number;
2567
- /** Best-effort string subtype name from the PDF dict, when readable. */
2568
- rawSubtypeName: string | null;
2569
- }
2570
- //#endregion
2571
- //#region src/annotation/kinds/index.d.ts
2572
- /**
2573
- * The closed-world catalog of currently-implemented annotation kinds.
2574
- *
2575
- * Adding a new subtype is one folder under `kinds/<name>/` exporting the
2576
- * five files (dto, draft, patch, schema, index) and one entry in this
2577
- * tuple. The discriminated unions and zod discriminator below regenerate
2578
- * automatically; no other file in the package needs to change.
2579
- *
2580
- * Every subtype the engine has not yet wired up rides on
2581
- * `UnsupportedKind`. The wire format is stable: when a per-subtype reader
2582
- * lands later, the engine starts emitting the dedicated DTO instead of
2583
- * `unsupported`, and existing clients widen their handling without a
2584
- * version bump.
2585
- */
2586
- declare const ANNOTATION_KINDS: readonly [AnnotationKindModule<"highlight", HighlightAnnotationDTO, HighlightDraft, HighlightPatch>, AnnotationKindModule<"underline", UnderlineAnnotationDTO, UnderlineDraft, UnderlinePatch>, AnnotationKindModule<"squiggly", SquigglyAnnotationDTO, SquigglyDraft, SquigglyPatch>, AnnotationKindModule<"strikeout", StrikeoutAnnotationDTO, StrikeoutDraft, StrikeoutPatch>, AnnotationKindModule<"circle", CircleAnnotationDTO, CircleDraft, CirclePatch>, AnnotationKindModule<"square", SquareAnnotationDTO, SquareDraft, SquarePatch>, AnnotationKindModule<"polygon", PolygonAnnotationDTO, PolygonDraft, PolygonPatch>, AnnotationKindModule<"polyline", PolylineAnnotationDTO, PolylineDraft, PolylinePatch>, AnnotationKindModule<"line", LineAnnotationDTO, LineDraft, LinePatch>, AnnotationKindModule<"link", LinkAnnotationDTO, LinkDraft, LinkPatch>, AnnotationKindModule<"ink", InkAnnotationDTO, InkDraft, InkPatch>, AnnotationKindModule<"free-text", FreeTextAnnotationDTO, FreeTextDraft, FreeTextPatch>, AnnotationKindModule<"caret", CaretAnnotationDTO, CaretDraft, CaretPatch>, AnnotationKindModule<"text", TextAnnotationDTO, TextDraft, TextPatch>, AnnotationKindModule<"stamp", StampAnnotationDTO, StampWireDraft, StampWirePatch>, AnnotationKindModule<"file-attachment", FileAttachmentAnnotationDTO, FileAttachmentWireDraft, FileAttachmentPatch>, AnnotationKindModule<"widget", WidgetAnnotationDTO, WidgetDraft, WidgetPatch>, AnnotationKindModule<"redact", RedactAnnotationDTO, RedactDraft, RedactPatch>, AnnotationKindModule<"unsupported", UnsupportedAnnotationDTO, never, never>];
2587
- type AnnotationKind = (typeof ANNOTATION_KINDS)[number];
2588
- type DTOFromKind<K> = K extends AnnotationKindModule<infer _S, infer D, infer _Dr, infer _Pa> ? D : never;
2589
- /** Discriminated union over `subtype`, derived from the registry. */
2590
- type AnnotationDTO = DTOFromKind<AnnotationKind>;
2591
- //#endregion
2592
- export { FormSnapshot as n, SearchQuery as r, AnnotationDTO as t };
2593
- //# sourceMappingURL=AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts.map