unpdf 0.5.4 → 0.6.1

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 (88) hide show
  1. package/README.md +65 -31
  2. package/dist/index.cjs +120 -0
  3. package/dist/index.d.cts +49 -0
  4. package/dist/index.d.mts +49 -0
  5. package/dist/index.d.ts +49 -0
  6. package/dist/index.mjs +112 -0
  7. package/dist/pdfjs.d.mts +1 -0
  8. package/dist/pdfjs.d.ts +1 -0
  9. package/dist/pdfjs.mjs +1 -0
  10. package/dist/types/external/webL10n/l10n.d.ts +0 -0
  11. package/dist/types/src/display/annotation_layer.d.ts +203 -0
  12. package/dist/types/src/display/annotation_storage.d.ts +89 -0
  13. package/dist/types/src/display/api.d.ts +1466 -0
  14. package/dist/types/src/display/base_factory.d.ts +54 -0
  15. package/dist/types/src/display/canvas.d.ts +208 -0
  16. package/dist/types/src/display/display_utils.d.ts +277 -0
  17. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +196 -0
  18. package/dist/types/src/display/editor/editor.d.ts +325 -0
  19. package/dist/types/src/display/editor/freetext.d.ts +72 -0
  20. package/dist/types/src/display/editor/ink.d.ts +95 -0
  21. package/dist/types/src/display/editor/stamp.d.ts +28 -0
  22. package/dist/types/src/display/editor/tools.d.ts +349 -0
  23. package/dist/types/src/display/font_loader.d.ts +43 -0
  24. package/dist/types/src/display/metadata.d.ts +11 -0
  25. package/dist/types/src/display/optional_content_config.d.ts +13 -0
  26. package/dist/types/src/display/pattern_helper.d.ts +73 -0
  27. package/dist/types/src/display/text_layer.d.ts +151 -0
  28. package/dist/types/src/display/transport_stream.d.ts +68 -0
  29. package/dist/types/src/display/worker_options.d.ts +27 -0
  30. package/dist/types/src/display/xfa_layer.d.ts +46 -0
  31. package/dist/types/src/display/xfa_text.d.ts +19 -0
  32. package/dist/types/src/pdf.d.ts +50 -0
  33. package/dist/types/src/shared/image_utils.d.ts +17 -0
  34. package/dist/types/src/shared/message_handler.d.ts +43 -0
  35. package/dist/types/src/shared/murmurhash3.d.ts +7 -0
  36. package/dist/types/src/shared/scripting_utils.d.ts +16 -0
  37. package/dist/types/src/shared/util.d.ts +398 -0
  38. package/dist/types/web/annotation_editor_layer_builder.d.ts +50 -0
  39. package/dist/types/web/annotation_layer_builder.d.ts +83 -0
  40. package/dist/types/web/app_options.d.ts +14 -0
  41. package/dist/types/web/download_manager.d.ts +14 -0
  42. package/dist/types/web/event_utils.d.ts +75 -0
  43. package/dist/types/web/generic_scripting.d.ts +8 -0
  44. package/dist/types/web/genericl10n.d.ts +13 -0
  45. package/dist/types/web/interfaces.d.ts +163 -0
  46. package/dist/types/web/l10n_utils.d.ts +7 -0
  47. package/dist/types/web/pdf_find_controller.d.ts +108 -0
  48. package/dist/types/web/pdf_find_utils.d.ts +16 -0
  49. package/dist/types/web/pdf_history.d.ts +168 -0
  50. package/dist/types/web/pdf_link_service.d.ts +243 -0
  51. package/dist/types/web/pdf_page_view.d.ts +209 -0
  52. package/dist/types/web/pdf_rendering_queue.d.ts +53 -0
  53. package/dist/types/web/pdf_scripting_manager.component.d.ts +5 -0
  54. package/dist/types/web/pdf_scripting_manager.d.ts +61 -0
  55. package/dist/types/web/pdf_single_page_viewer.d.ts +7 -0
  56. package/dist/types/web/pdf_thumbnail_view.d.ts +131 -0
  57. package/dist/types/web/pdf_thumbnail_viewer.d.ts +104 -0
  58. package/dist/types/web/pdf_viewer.component.d.ts +24 -0
  59. package/dist/types/web/pdf_viewer.d.ts +455 -0
  60. package/dist/types/web/struct_tree_layer_builder.d.ts +7 -0
  61. package/dist/types/web/text_accessibility.d.ts +42 -0
  62. package/dist/types/web/text_highlighter.d.ts +63 -0
  63. package/dist/types/web/text_layer_builder.d.ts +64 -0
  64. package/dist/types/web/ui_utils.d.ts +288 -0
  65. package/dist/types/web/xfa_layer_builder.d.ts +41 -0
  66. package/package.json +54 -44
  67. package/dist/index.node.cjs +0 -25
  68. package/dist/index.node.d.cts +0 -10
  69. package/dist/index.node.d.mts +0 -10
  70. package/dist/index.node.d.ts +0 -10
  71. package/dist/index.node.mjs +0 -18
  72. package/dist/index.web.cjs +0 -25
  73. package/dist/index.web.d.cts +0 -10
  74. package/dist/index.web.d.mts +0 -10
  75. package/dist/index.web.d.ts +0 -10
  76. package/dist/index.web.mjs +0 -18
  77. package/dist/index.worker.cjs +0 -21
  78. package/dist/index.worker.d.cts +0 -10
  79. package/dist/index.worker.d.mts +0 -10
  80. package/dist/index.worker.d.ts +0 -10
  81. package/dist/index.worker.mjs +0 -13
  82. package/dist/shared/unpdf.3dcacb97.mjs +0 -49
  83. package/dist/shared/unpdf.42987ff1.cjs +0 -52
  84. package/dist/shared/unpdf.6363738c.d.cts +0 -43
  85. package/dist/shared/unpdf.6363738c.d.mts +0 -43
  86. package/dist/shared/unpdf.6363738c.d.ts +0 -43
  87. package/dist/shared/unpdf.ab6a2535.mjs +0 -46
  88. package/dist/shared/unpdf.eba9a3dc.cjs +0 -53
File without changes
@@ -0,0 +1,203 @@
1
+ export type PDFPageProxy = import("./api").PDFPageProxy;
2
+ export type PageViewport = import("./display_utils").PageViewport;
3
+ export type IDownloadManager = any;
4
+ export type IPDFLinkService = import("../../web/interfaces").IPDFLinkService;
5
+ export type AnnotationElementParameters = {
6
+ data: Object;
7
+ layer: HTMLDivElement;
8
+ linkService: IPDFLinkService;
9
+ downloadManager: any;
10
+ annotationStorage?: AnnotationStorage | undefined;
11
+ /**
12
+ * - Path for image resources, mainly
13
+ * for annotation icons. Include trailing slash.
14
+ */
15
+ imageResourcesPath?: string | undefined;
16
+ renderForms: boolean;
17
+ svgFactory: Object;
18
+ enableScripting?: boolean | undefined;
19
+ hasJSActions?: boolean | undefined;
20
+ fieldObjects?: Object | undefined;
21
+ };
22
+ export type AnnotationLayerParameters = {
23
+ viewport: PageViewport;
24
+ div: HTMLDivElement;
25
+ annotations: any[];
26
+ page: PDFPageProxy;
27
+ linkService: IPDFLinkService;
28
+ downloadManager: any;
29
+ annotationStorage?: AnnotationStorage | undefined;
30
+ /**
31
+ * - Path for image resources, mainly
32
+ * for annotation icons. Include trailing slash.
33
+ */
34
+ imageResourcesPath?: string | undefined;
35
+ renderForms: boolean;
36
+ /**
37
+ * - Enable embedded script execution.
38
+ */
39
+ enableScripting?: boolean | undefined;
40
+ /**
41
+ * - Some fields have JS actions.
42
+ * The default value is `false`.
43
+ */
44
+ hasJSActions?: boolean | undefined;
45
+ fieldObjects?: {
46
+ [x: string]: Object[];
47
+ } | null | undefined;
48
+ annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined;
49
+ accessibilityManager?: any;
50
+ };
51
+ /**
52
+ * @typedef {Object} AnnotationLayerParameters
53
+ * @property {PageViewport} viewport
54
+ * @property {HTMLDivElement} div
55
+ * @property {Array} annotations
56
+ * @property {PDFPageProxy} page
57
+ * @property {IPDFLinkService} linkService
58
+ * @property {IDownloadManager} downloadManager
59
+ * @property {AnnotationStorage} [annotationStorage]
60
+ * @property {string} [imageResourcesPath] - Path for image resources, mainly
61
+ * for annotation icons. Include trailing slash.
62
+ * @property {boolean} renderForms
63
+ * @property {boolean} [enableScripting] - Enable embedded script execution.
64
+ * @property {boolean} [hasJSActions] - Some fields have JS actions.
65
+ * The default value is `false`.
66
+ * @property {Object<string, Array<Object>> | null} [fieldObjects]
67
+ * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
68
+ * @property {TextAccessibilityManager} [accessibilityManager]
69
+ */
70
+ /**
71
+ * Manage the layer containing all the annotations.
72
+ */
73
+ export class AnnotationLayer {
74
+ constructor({ div, accessibilityManager, annotationCanvasMap, l10n, page, viewport, }: {
75
+ div: any;
76
+ accessibilityManager: any;
77
+ annotationCanvasMap: any;
78
+ l10n: any;
79
+ page: any;
80
+ viewport: any;
81
+ });
82
+ div: any;
83
+ l10n: any;
84
+ page: any;
85
+ viewport: any;
86
+ zIndex: number;
87
+ popupShow: any[] | undefined;
88
+ /**
89
+ * Render a new annotation layer with all annotation elements.
90
+ *
91
+ * @param {AnnotationLayerParameters} params
92
+ * @memberof AnnotationLayer
93
+ */
94
+ render(params: AnnotationLayerParameters): Promise<void>;
95
+ /**
96
+ * Update the annotation elements on existing annotation layer.
97
+ *
98
+ * @param {AnnotationLayerParameters} viewport
99
+ * @memberof AnnotationLayer
100
+ */
101
+ update({ viewport }: AnnotationLayerParameters): void;
102
+ getEditableAnnotations(): any[];
103
+ getEditableAnnotation(id: any): any;
104
+ #private;
105
+ }
106
+ export class FreeTextAnnotationElement extends AnnotationElement {
107
+ constructor(parameters: any);
108
+ textContent: any;
109
+ textPosition: any;
110
+ annotationEditorType: number;
111
+ render(): HTMLElement | undefined;
112
+ }
113
+ export class InkAnnotationElement extends AnnotationElement {
114
+ constructor(parameters: any);
115
+ containerClassName: string;
116
+ svgElementName: string;
117
+ annotationEditorType: number;
118
+ render(): HTMLElement | undefined;
119
+ getElementsToTriggerPopup(): any[];
120
+ #private;
121
+ }
122
+ export class StampAnnotationElement extends AnnotationElement {
123
+ constructor(parameters: any);
124
+ render(): HTMLElement | undefined;
125
+ }
126
+ import { AnnotationStorage } from "./annotation_storage.js";
127
+ declare class AnnotationElement {
128
+ constructor(parameters: any, { isRenderable, ignoreBorder, createQuadrilaterals, }?: {
129
+ isRenderable?: boolean | undefined;
130
+ ignoreBorder?: boolean | undefined;
131
+ createQuadrilaterals?: boolean | undefined;
132
+ });
133
+ isRenderable: boolean;
134
+ data: any;
135
+ layer: any;
136
+ linkService: any;
137
+ downloadManager: any;
138
+ imageResourcesPath: any;
139
+ renderForms: any;
140
+ svgFactory: any;
141
+ annotationStorage: any;
142
+ enableScripting: any;
143
+ hasJSActions: any;
144
+ _fieldObjects: any;
145
+ parent: any;
146
+ container: HTMLElement | undefined;
147
+ /**
148
+ * Create an empty container for the annotation's HTML element.
149
+ *
150
+ * @private
151
+ * @param {boolean} ignoreBorder
152
+ * @memberof AnnotationElement
153
+ * @returns {HTMLElement} A section element.
154
+ */
155
+ private _createContainer;
156
+ setRotation(angle: any, container?: HTMLElement | undefined): void;
157
+ get _commonActions(): any;
158
+ _dispatchEventFromSandbox(actions: any, jsEvent: any): void;
159
+ _setDefaultPropertiesFromJS(element: any): void;
160
+ /**
161
+ * Create quadrilaterals from the annotation's quadpoints.
162
+ *
163
+ * @private
164
+ * @memberof AnnotationElement
165
+ */
166
+ private _createQuadrilaterals;
167
+ /**
168
+ * Create a popup for the annotation's HTML element. This is used for
169
+ * annotations that do not have a Popup entry in the dictionary, but
170
+ * are of a type that works with popups (such as Highlight annotations).
171
+ *
172
+ * @private
173
+ * @memberof AnnotationElement
174
+ */
175
+ private _createPopup;
176
+ /**
177
+ * Render the annotation's HTML element(s).
178
+ *
179
+ * @public
180
+ * @memberof AnnotationElement
181
+ */
182
+ public render(): void;
183
+ /**
184
+ * @private
185
+ * @returns {Array}
186
+ */
187
+ private _getElementsByName;
188
+ show(): void;
189
+ hide(): void;
190
+ /**
191
+ * Get the HTML element(s) which can trigger a popup when clicked or hovered.
192
+ *
193
+ * @public
194
+ * @memberof AnnotationElement
195
+ * @returns {Array<HTMLElement>|HTMLElement} An array of elements or an
196
+ * element.
197
+ */
198
+ public getElementsToTriggerPopup(): Array<HTMLElement> | HTMLElement;
199
+ addHighlightArea(): void;
200
+ _editOnDoubleClick(): void;
201
+ #private;
202
+ }
203
+ export {};
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Key/value storage for annotation data in forms.
3
+ */
4
+ export class AnnotationStorage {
5
+ onSetModified: any;
6
+ onResetModified: any;
7
+ onAnnotationEditor: any;
8
+ /**
9
+ * Get the value for a given key if it exists, or return the default value.
10
+ * @param {string} key
11
+ * @param {Object} defaultValue
12
+ * @returns {Object}
13
+ */
14
+ getValue(key: string, defaultValue: Object): Object;
15
+ /**
16
+ * Get the value for a given key.
17
+ * @param {string} key
18
+ * @returns {Object}
19
+ */
20
+ getRawValue(key: string): Object;
21
+ /**
22
+ * Remove a value from the storage.
23
+ * @param {string} key
24
+ */
25
+ remove(key: string): void;
26
+ /**
27
+ * Set the value for a given key
28
+ * @param {string} key
29
+ * @param {Object} value
30
+ */
31
+ setValue(key: string, value: Object): void;
32
+ /**
33
+ * Check if the storage contains the given key.
34
+ * @param {string} key
35
+ * @returns {boolean}
36
+ */
37
+ has(key: string): boolean;
38
+ /**
39
+ * @returns {Object | null}
40
+ */
41
+ getAll(): Object | null;
42
+ /**
43
+ * @param {Object} obj
44
+ */
45
+ setAll(obj: Object): void;
46
+ get size(): number;
47
+ resetModified(): void;
48
+ /**
49
+ * @returns {PrintAnnotationStorage}
50
+ */
51
+ get print(): PrintAnnotationStorage;
52
+ /**
53
+ * PLEASE NOTE: Only intended for usage within the API itself.
54
+ * @ignore
55
+ */
56
+ get serializable(): Readonly<{
57
+ map: null;
58
+ hash: "";
59
+ transfers: undefined;
60
+ }> | {
61
+ map: Map<any, any>;
62
+ hash: string;
63
+ transfers: any[];
64
+ };
65
+ #private;
66
+ }
67
+ /**
68
+ * A special `AnnotationStorage` for use during printing, where the serializable
69
+ * data is *frozen* upon initialization, to prevent scripting from modifying its
70
+ * contents. (Necessary since printing is triggered synchronously in browsers.)
71
+ */
72
+ export class PrintAnnotationStorage extends AnnotationStorage {
73
+ constructor(parent: any);
74
+ /**
75
+ * PLEASE NOTE: Only intended for usage within the API itself.
76
+ * @ignore
77
+ */
78
+ get serializable(): {
79
+ map: any;
80
+ hash: any;
81
+ transfers: any;
82
+ };
83
+ #private;
84
+ }
85
+ export const SerializableEmpty: Readonly<{
86
+ map: null;
87
+ hash: "";
88
+ transfers: undefined;
89
+ }>;