@chialab/pdfjs-lib 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +29 -0
  2. package/dist/browser/FoxitDingbats-SB6TO3S5.js +9 -0
  3. package/dist/browser/FoxitFixed-UIGSMBQB.js +9 -0
  4. package/dist/browser/FoxitFixedBold-2PAEIZAT.js +9 -0
  5. package/dist/browser/FoxitFixedBoldItalic-OSQUQDEE.js +9 -0
  6. package/dist/browser/FoxitFixedItalic-W73RDK22.js +9 -0
  7. package/dist/browser/FoxitSerif-3HH3SOZF.js +9 -0
  8. package/dist/browser/FoxitSerifBold-HXP2QOO7.js +9 -0
  9. package/dist/browser/FoxitSerifBoldItalic-FZXLNWD7.js +9 -0
  10. package/dist/browser/FoxitSerifItalic-WQFHUBI2.js +9 -0
  11. package/dist/browser/FoxitSymbol-OVWU7LKS.js +9 -0
  12. package/dist/browser/LiberationMono-Regular-UUOCTXY2.js +9 -0
  13. package/dist/browser/LiberationSans-Bold-GSJN42N5.js +9 -0
  14. package/dist/browser/LiberationSans-BoldItalic-UCPQJ3L2.js +9 -0
  15. package/dist/browser/LiberationSans-Italic-6CIHEALY.js +9 -0
  16. package/dist/browser/LiberationSans-Regular-KIF3IRJY.js +9 -0
  17. package/dist/browser/LiberationSerif-Regular-ASQ2LI3D.js +9 -0
  18. package/dist/browser/chunk-DYHYQ33L.js +1775 -0
  19. package/dist/browser/chunk-O4UKW7AD.js +44 -0
  20. package/dist/browser/index.js +26324 -0
  21. package/dist/browser/worker.js +84242 -0
  22. package/dist/index.d.ts +10 -0
  23. package/dist/lib/AnnotationData.d.ts +204 -0
  24. package/dist/lib/Canvas.d.ts +17 -0
  25. package/dist/lib/PDFPageProxy.d.ts +1 -0
  26. package/dist/lib/Path2D.d.ts +72 -0
  27. package/dist/lib/StandardFontDataFactory.d.ts +14 -0
  28. package/dist/lib/SvgCanvasContext.d.ts +156 -0
  29. package/dist/lib/TextLayer.d.ts +51 -0
  30. package/dist/lib/polyfills.d.ts +0 -0
  31. package/dist/lib/utils.d.ts +13 -0
  32. package/dist/node/FoxitDingbats-65AZ2Z2V.js +9 -0
  33. package/dist/node/FoxitFixed-OZGLVVOQ.js +9 -0
  34. package/dist/node/FoxitFixedBold-37OOYMV7.js +9 -0
  35. package/dist/node/FoxitFixedBoldItalic-XYFHEG2V.js +9 -0
  36. package/dist/node/FoxitFixedItalic-MM7OSGS6.js +9 -0
  37. package/dist/node/FoxitSerif-MLMJQPRP.js +9 -0
  38. package/dist/node/FoxitSerifBold-AC7RJQWJ.js +9 -0
  39. package/dist/node/FoxitSerifBoldItalic-YCQ4CLKE.js +9 -0
  40. package/dist/node/FoxitSerifItalic-CXVTCST4.js +9 -0
  41. package/dist/node/FoxitSymbol-VUGMZN5C.js +9 -0
  42. package/dist/node/LiberationMono-Regular-KMFXXO3B.js +9 -0
  43. package/dist/node/LiberationSans-Bold-XSHQQBWB.js +9 -0
  44. package/dist/node/LiberationSans-BoldItalic-CTAZRFRL.js +9 -0
  45. package/dist/node/LiberationSans-Italic-WIOTUKLC.js +9 -0
  46. package/dist/node/LiberationSans-Regular-CDMMZL5S.js +9 -0
  47. package/dist/node/LiberationSerif-Regular-WAOWR76G.js +9 -0
  48. package/dist/node/chunk-7MW5RQZ5.js +30 -0
  49. package/dist/node/chunk-KTTVPO2G.js +1775 -0
  50. package/dist/node/index.js +26621 -0
  51. package/dist/node/worker.js +84242 -0
  52. package/dist/pdf.js/src/display/annotation_layer.d.ts +241 -0
  53. package/dist/pdf.js/src/display/annotation_storage.d.ts +99 -0
  54. package/dist/pdf.js/src/display/api.d.ts +1586 -0
  55. package/dist/pdf.js/src/display/canvas.d.ts +213 -0
  56. package/dist/pdf.js/src/display/canvas_factory.d.ts +27 -0
  57. package/dist/pdf.js/src/display/cmap_reader_factory.d.ts +25 -0
  58. package/dist/pdf.js/src/display/display_utils.d.ts +247 -0
  59. package/dist/pdf.js/src/display/draw_layer.d.ts +26 -0
  60. package/dist/pdf.js/src/display/editor/alt_text.d.ts +34 -0
  61. package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +230 -0
  62. package/dist/pdf.js/src/display/editor/color_picker.d.ts +20 -0
  63. package/dist/pdf.js/src/display/editor/draw.d.ts +121 -0
  64. package/dist/pdf.js/src/display/editor/drawers/contour.d.ts +3 -0
  65. package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +31 -0
  66. package/dist/pdf.js/src/display/editor/drawers/highlight.d.ts +36 -0
  67. package/dist/pdf.js/src/display/editor/drawers/inkdraw.d.ts +129 -0
  68. package/dist/pdf.js/src/display/editor/drawers/outline.d.ts +19 -0
  69. package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +79 -0
  70. package/dist/pdf.js/src/display/editor/editor.d.ts +474 -0
  71. package/dist/pdf.js/src/display/editor/freetext.d.ts +59 -0
  72. package/dist/pdf.js/src/display/editor/highlight.d.ts +70 -0
  73. package/dist/pdf.js/src/display/editor/ink.d.ts +36 -0
  74. package/dist/pdf.js/src/display/editor/signature.d.ts +79 -0
  75. package/dist/pdf.js/src/display/editor/stamp.d.ts +48 -0
  76. package/dist/pdf.js/src/display/editor/toolbar.d.ts +21 -0
  77. package/dist/pdf.js/src/display/editor/tools.d.ts +424 -0
  78. package/dist/pdf.js/src/display/filter_factory.d.ts +29 -0
  79. package/dist/pdf.js/src/display/font_loader.d.ts +39 -0
  80. package/dist/pdf.js/src/display/metadata.d.ts +11 -0
  81. package/dist/pdf.js/src/display/node_utils.d.ts +32 -0
  82. package/dist/pdf.js/src/display/optional_content_config.d.ts +18 -0
  83. package/dist/pdf.js/src/display/pattern_helper.d.ts +73 -0
  84. package/dist/pdf.js/src/display/standard_fontdata_factory.d.ts +20 -0
  85. package/dist/pdf.js/src/display/svg_factory.d.ts +14 -0
  86. package/dist/pdf.js/src/display/text_layer.d.ts +85 -0
  87. package/dist/pdf.js/src/display/touch_manager.d.ts +14 -0
  88. package/dist/pdf.js/src/display/transport_stream.d.ts +67 -0
  89. package/dist/pdf.js/src/display/wasm_factory.d.ts +20 -0
  90. package/dist/pdf.js/src/display/worker_options.d.ts +25 -0
  91. package/dist/pdf.js/src/display/xfa_layer.d.ts +47 -0
  92. package/dist/pdf.js/src/display/xfa_text.d.ts +21 -0
  93. package/dist/pdf.js/src/interfaces.d.ts +122 -0
  94. package/dist/pdf.js/src/pdf.d.ts +55 -0
  95. package/dist/pdf.js/src/shared/image_utils.d.ts +17 -0
  96. package/dist/pdf.js/src/shared/message_handler.d.ts +48 -0
  97. package/dist/pdf.js/src/shared/murmurhash3.d.ts +7 -0
  98. package/dist/pdf.js/src/shared/scripting_utils.d.ts +16 -0
  99. package/dist/pdf.js/src/shared/util.d.ts +388 -0
  100. package/dist/pdf.js/web/interfaces.d.ts +167 -0
  101. package/dist/pdf.js/web/struct_tree_layer_builder.d.ts +25 -0
  102. package/dist/pdf.js/web/text_accessibility.d.ts +44 -0
  103. package/dist/pdf.js/web/ui_utils.d.ts +273 -0
  104. package/package.json +43 -0
@@ -0,0 +1,273 @@
1
+ export type GetPageSizeInchesParameters = {
2
+ view: number[];
3
+ userUnit: number;
4
+ rotate: number;
5
+ };
6
+ export type PageSize = {
7
+ /**
8
+ * - In inches.
9
+ */
10
+ width: number;
11
+ /**
12
+ * - In inches.
13
+ */
14
+ height: number;
15
+ };
16
+ export type GetVisibleElementsParameters = {
17
+ /**
18
+ * - A container that can possibly scroll.
19
+ */
20
+ scrollEl: HTMLElement;
21
+ /**
22
+ * - Objects with a `div` property that contains an
23
+ * HTMLElement, which should all be descendants of `scrollEl` satisfying the
24
+ * relevant layout assumptions.
25
+ */
26
+ views: any[];
27
+ /**
28
+ * - If `true`, the returned elements are
29
+ * sorted in descending order of the percent of their padding box that is
30
+ * visible. The default value is `false`.
31
+ */
32
+ sortByVisibility: boolean;
33
+ /**
34
+ * - If `true`, the elements are assumed to be
35
+ * laid out horizontally instead of vertically. The default value is `false`.
36
+ */
37
+ horizontal: boolean;
38
+ /**
39
+ * - If `true`, the `scrollEl` container is assumed to
40
+ * be in right-to-left mode. The default value is `false`.
41
+ */
42
+ rtl: boolean;
43
+ };
44
+ /**
45
+ * Promise that is resolved when DOM window becomes visible.
46
+ */
47
+ export const animationStarted: Promise<any>;
48
+ /**
49
+ * Converts API PageLayout values to the format used by `BaseViewer`.
50
+ * @param {string} layout - The API PageLayout value.
51
+ * @returns {Object}
52
+ */
53
+ export function apiPageLayoutToViewerModes(layout: string): Object;
54
+ /**
55
+ * Converts API PageMode values to the format used by `PDFSidebar`.
56
+ * NOTE: There's also a "FullScreen" parameter which is not possible to support,
57
+ * since the Fullscreen API used in browsers requires that entering
58
+ * fullscreen mode only occurs as a result of a user-initiated event.
59
+ * @param {string} mode - The API PageMode value.
60
+ * @returns {number} A value from {SidebarView}.
61
+ */
62
+ export function apiPageModeToSidebarView(mode: string): number;
63
+ /**
64
+ * Approximates float number as a fraction using Farey sequence (max order
65
+ * of 8).
66
+ * @param {number} x - Positive float number.
67
+ * @returns {Array} Estimated fraction: the first array item is a numerator,
68
+ * the second one is a denominator.
69
+ * They are both natural numbers.
70
+ */
71
+ export function approximateFraction(x: number): any[];
72
+ export const AutoPrintRegExp: RegExp;
73
+ /**
74
+ * Helper function for getVisibleElements.
75
+ *
76
+ * @param {number} index - initial guess at the first visible element
77
+ * @param {Array} views - array of pages, into which `index` is an index
78
+ * @param {number} top - the top of the scroll pane
79
+ * @returns {number} less than or equal to `index` that is definitely at or
80
+ * before the first visible element in `views`, but not by too much. (Usually,
81
+ * this will be the first element in the first partially visible row in
82
+ * `views`, although sometimes it goes back one row further.)
83
+ */
84
+ export function backtrackBeforeAllVisibleElements(index: number, views: any[], top: number): number;
85
+ /**
86
+ * Use binary search to find the index of the first item in a given array which
87
+ * passes a given condition. The items are expected to be sorted in the sense
88
+ * that if the condition is true for one item in the array, then it is also true
89
+ * for all following items.
90
+ *
91
+ * @returns {number} Index of the first array element to pass the test,
92
+ * or |items.length| if no such element exists.
93
+ */
94
+ export function binarySearchFirstItem(items: any, condition: any, start?: number): number;
95
+ export const calcRound: ((x: number) => number) | ((x: any) => any);
96
+ export namespace CursorTool {
97
+ let SELECT: number;
98
+ let HAND: number;
99
+ let ZOOM: number;
100
+ }
101
+ export const DEFAULT_SCALE: 1;
102
+ export const DEFAULT_SCALE_DELTA: 1.1;
103
+ export const DEFAULT_SCALE_VALUE: "auto";
104
+ export const docStyle: CSSStyleDeclaration | null;
105
+ /**
106
+ * @param {number} x - A positive number to round to a multiple of `div`.
107
+ * @param {number} div - A natural number.
108
+ */
109
+ export function floorToDivide(x: number, div: number): number;
110
+ /**
111
+ * Get the active or focused element in current DOM.
112
+ *
113
+ * Recursively search for the truly active or focused element in case there are
114
+ * shadow DOMs.
115
+ *
116
+ * @returns {Element} the truly active or focused element.
117
+ */
118
+ export function getActiveOrFocusedElement(): Element;
119
+ /**
120
+ * @typedef {Object} GetPageSizeInchesParameters
121
+ * @property {number[]} view
122
+ * @property {number} userUnit
123
+ * @property {number} rotate
124
+ */
125
+ /**
126
+ * @typedef {Object} PageSize
127
+ * @property {number} width - In inches.
128
+ * @property {number} height - In inches.
129
+ */
130
+ /**
131
+ * Gets the size of the specified page, converted from PDF units to inches.
132
+ * @param {GetPageSizeInchesParameters} params
133
+ * @returns {PageSize}
134
+ */
135
+ export function getPageSizeInches({ view, userUnit, rotate }: GetPageSizeInchesParameters): PageSize;
136
+ /**
137
+ * @typedef {Object} GetVisibleElementsParameters
138
+ * @property {HTMLElement} scrollEl - A container that can possibly scroll.
139
+ * @property {Array} views - Objects with a `div` property that contains an
140
+ * HTMLElement, which should all be descendants of `scrollEl` satisfying the
141
+ * relevant layout assumptions.
142
+ * @property {boolean} sortByVisibility - If `true`, the returned elements are
143
+ * sorted in descending order of the percent of their padding box that is
144
+ * visible. The default value is `false`.
145
+ * @property {boolean} horizontal - If `true`, the elements are assumed to be
146
+ * laid out horizontally instead of vertically. The default value is `false`.
147
+ * @property {boolean} rtl - If `true`, the `scrollEl` container is assumed to
148
+ * be in right-to-left mode. The default value is `false`.
149
+ */
150
+ /**
151
+ * Generic helper to find out what elements are visible within a scroll pane.
152
+ *
153
+ * Well, pretty generic. There are some assumptions placed on the elements
154
+ * referenced by `views`:
155
+ * - If `horizontal`, no left of any earlier element is to the right of the
156
+ * left of any later element.
157
+ * - Otherwise, `views` can be split into contiguous rows where, within a row,
158
+ * no top of any element is below the bottom of any other element, and
159
+ * between rows, no bottom of any element in an earlier row is below the
160
+ * top of any element in a later row.
161
+ *
162
+ * (Here, top, left, etc. all refer to the padding edge of the element in
163
+ * question. For pages, that ends up being equivalent to the bounding box of the
164
+ * rendering canvas. Earlier and later refer to index in `views`, not page
165
+ * layout.)
166
+ *
167
+ * @param {GetVisibleElementsParameters} params
168
+ * @returns {Object} `{ first, last, views: [{ id, x, y, view, percent }] }`
169
+ */
170
+ export function getVisibleElements({ scrollEl, views, sortByVisibility, horizontal, rtl, }: GetVisibleElementsParameters): Object;
171
+ export function isPortraitOrientation(size: any): boolean;
172
+ export function isValidRotation(angle: any): boolean;
173
+ export function isValidScrollMode(mode: any): boolean;
174
+ export function isValidSpreadMode(mode: any): boolean;
175
+ export const MAX_AUTO_SCALE: 1.25;
176
+ export const MAX_SCALE: 10;
177
+ export const MIN_SCALE: 0.1;
178
+ export function normalizeWheelEventDelta(evt: any): number;
179
+ export function normalizeWheelEventDirection(evt: any): number;
180
+ /**
181
+ * Helper function to parse query string (e.g. ?param1=value&param2=...).
182
+ * @param {string} query
183
+ * @returns {Map}
184
+ */
185
+ export function parseQueryString(query: string): Map<any, any>;
186
+ export namespace PresentationModeState {
187
+ let UNKNOWN: number;
188
+ let NORMAL: number;
189
+ let CHANGING: number;
190
+ let FULLSCREEN: number;
191
+ }
192
+ export class ProgressBar {
193
+ constructor(bar: any);
194
+ set percent(val: number);
195
+ get percent(): number;
196
+ setWidth(viewer: any): void;
197
+ setDisableAutoFetch(delay?: number): void;
198
+ hide(): void;
199
+ show(): void;
200
+ #private;
201
+ }
202
+ /**
203
+ * @param {string} str
204
+ * @param {boolean} [replaceInvisible]
205
+ */
206
+ export function removeNullCharacters(str: string, replaceInvisible?: boolean): string;
207
+ export namespace RenderingStates {
208
+ let INITIAL: number;
209
+ let RUNNING: number;
210
+ let PAUSED: number;
211
+ let FINISHED: number;
212
+ }
213
+ export const SCROLLBAR_PADDING: 40;
214
+ /**
215
+ * Scrolls specified element into view of its parent.
216
+ * @param {HTMLElement} element - The element to be visible.
217
+ * @param {Object} [spot] - An object with optional top and left properties,
218
+ * specifying the offset from the top left edge.
219
+ * @param {number} [spot.left]
220
+ * @param {number} [spot.top]
221
+ * @param {boolean} [scrollMatches] - When scrolling search results into view,
222
+ * ignore elements that either: Contains marked content identifiers,
223
+ * or have the CSS-rule `overflow: hidden;` set. The default value is `false`.
224
+ */
225
+ export function scrollIntoView(element: HTMLElement, spot?: {
226
+ left?: number | undefined;
227
+ top?: number | undefined;
228
+ }, scrollMatches?: boolean): void;
229
+ export namespace ScrollMode {
230
+ let UNKNOWN_1: number;
231
+ export { UNKNOWN_1 as UNKNOWN };
232
+ export let VERTICAL: number;
233
+ export let HORIZONTAL: number;
234
+ export let WRAPPED: number;
235
+ export let PAGE: number;
236
+ }
237
+ export namespace SidebarView {
238
+ let UNKNOWN_2: number;
239
+ export { UNKNOWN_2 as UNKNOWN };
240
+ export let NONE: number;
241
+ export let THUMBS: number;
242
+ export let OUTLINE: number;
243
+ export let ATTACHMENTS: number;
244
+ export let LAYERS: number;
245
+ }
246
+ export namespace SpreadMode {
247
+ let UNKNOWN_3: number;
248
+ export { UNKNOWN_3 as UNKNOWN };
249
+ let NONE_1: number;
250
+ export { NONE_1 as NONE };
251
+ export let ODD: number;
252
+ export let EVEN: number;
253
+ }
254
+ export namespace TextLayerMode {
255
+ let DISABLE: number;
256
+ let ENABLE: number;
257
+ let ENABLE_PERMISSIONS: number;
258
+ }
259
+ export function toggleCheckedBtn(button: any, toggle: any, view?: null): void;
260
+ export function toggleExpandedBtn(button: any, toggle: any, view?: null): void;
261
+ export const UNKNOWN_SCALE: 0;
262
+ export const VERTICAL_PADDING: 5;
263
+ /**
264
+ * Helper function to start monitoring the scroll event and converting them into
265
+ * PDF.js friendly one: with scroll debounce and scroll direction.
266
+ */
267
+ export function watchScroll(viewAreaElement: any, callback: any, abortSignal?: undefined): {
268
+ right: boolean;
269
+ down: boolean;
270
+ lastX: any;
271
+ lastY: any;
272
+ _eventHandler: (evt: any) => void;
273
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@chialab/pdfjs-lib",
3
+ "description": "A custom Mozilla's PDF.js build with better Node support and extras.",
4
+ "version": "1.0.0-alpha.0",
5
+ "type": "module",
6
+ "author": "Chialab <dev@chialab.it>",
7
+ "license": "MIT",
8
+ "files": [
9
+ "dist",
10
+ "package.json"
11
+ ],
12
+ "scripts": {
13
+ "build": "rimraf 'dist' && tsc && node build.js",
14
+ "check": "biome check",
15
+ "publint": "publint --pack npm",
16
+ "prepack": "yarn build && publint --pack npm"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "node": "./dist/node/index.js",
22
+ "default": "./dist/browser/index.js"
23
+ },
24
+ "./worker": {
25
+ "node": "./dist/node/worker.js",
26
+ "default": "./dist/browser/worker.js"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@napi-rs/canvas": "^0.1.67",
31
+ "pdfjs-dist": "^4.10.38"
32
+ },
33
+ "devDependencies": {
34
+ "@biomejs/biome": "^1.9.4",
35
+ "@changesets/cli": "^2.28.1",
36
+ "@types/node": "^22.13.5",
37
+ "esbuild": "^0.25.0",
38
+ "magic-string": "^0.30.17",
39
+ "publint": "^0.3.7",
40
+ "rimraf": "^6.0.1",
41
+ "typescript": "^5.7.3"
42
+ }
43
+ }