@chialab/pdfjs-lib 1.0.0-alpha.18 → 1.0.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/NodeCanvasFactory-OREYUFNU.js +58 -0
- package/dist/browser/chunk-5IWODJWD.js +801 -0
- package/dist/browser/chunk-MXRUYXDD.js +1127 -0
- package/dist/browser/{chunk-O4CM6PII.js → chunk-NJUB3B5A.js} +5 -787
- package/dist/browser/index.js +68 -1107
- package/dist/browser/worker.js +16 -14
- package/dist/lib/NodeCanvasFactory.d.ts +9 -0
- package/dist/lib/NodeFilterFactory.d.ts +10 -0
- package/dist/lib/utils.d.ts +1 -1
- package/dist/node/NodeCanvasFactory-N32SOXPQ.js +8 -0
- package/dist/node/chunk-QCIN557M.js +1424 -0
- package/dist/node/{chunk-4FQTXXTH.js → chunk-XMKSLA4K.js} +5 -787
- package/dist/node/chunk-ZKUTXCS2.js +801 -0
- package/dist/node/index.js +115 -1482
- package/dist/node/worker.js +16 -14
- package/dist/pdf.js/src/display/api.d.ts +5 -5
- package/dist/pdf.js/src/display/display_utils.d.ts +1 -1
- package/dist/pdf.js/src/display/draw_layer.d.ts +2 -2
- package/dist/pdf.js/src/display/editor/alt_text.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/color_picker.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/draw.d.ts +7 -7
- package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +3 -3
- package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +13 -13
- package/dist/pdf.js/src/display/editor/editor.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/freetext.d.ts +2 -2
- package/dist/pdf.js/src/display/editor/highlight.d.ts +4 -4
- package/dist/pdf.js/src/display/editor/stamp.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/toolbar.d.ts +2 -2
- package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
- package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
- package/dist/pdf.js/src/shared/util.d.ts +2 -2
- package/dist/pdf.js/web/text_accessibility.d.ts +1 -1
- package/package.json +2 -2
- package/dist/pdf.js/src/display/cmap_reader_factory.d.ts +0 -25
- package/dist/pdf.js/src/display/node_utils.d.ts +0 -32
- package/dist/pdf.js/src/display/wasm_factory.d.ts +0 -20
package/dist/node/index.js
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColorConverters,
|
|
3
|
+
MessageHandler,
|
|
4
|
+
MurmurHash3_64,
|
|
5
|
+
convertBlackAndWhiteToRGBA,
|
|
6
|
+
wrapReason
|
|
7
|
+
} from "./chunk-ZKUTXCS2.js";
|
|
8
|
+
import {
|
|
9
|
+
DOMCanvasFactory,
|
|
10
|
+
DOMFilterFactory,
|
|
11
|
+
NodeCanvasFactory,
|
|
12
|
+
NodeFilterFactory,
|
|
13
|
+
OutputScale,
|
|
14
|
+
PDFDateString,
|
|
15
|
+
PageViewport,
|
|
16
|
+
PixelsPerInch,
|
|
17
|
+
RenderingCancelledException,
|
|
18
|
+
SVG_NS,
|
|
19
|
+
StatTimer,
|
|
20
|
+
SupportedImageMimeTypes,
|
|
21
|
+
canvasToData,
|
|
22
|
+
colorToRgb,
|
|
23
|
+
deprecated,
|
|
24
|
+
fetchData,
|
|
25
|
+
getColorValues,
|
|
26
|
+
getCurrentTransform,
|
|
27
|
+
getCurrentTransformInverse,
|
|
28
|
+
getFilenameFromUrl,
|
|
29
|
+
getPdfFilenameFromUrl,
|
|
30
|
+
getRGB,
|
|
31
|
+
getXfaPageViewport,
|
|
32
|
+
isDataScheme,
|
|
33
|
+
isPdfFile,
|
|
34
|
+
isValidFetchUrl,
|
|
35
|
+
makeSerializable,
|
|
36
|
+
noContextMenu,
|
|
37
|
+
rgbToHex,
|
|
38
|
+
setLayerDimensions,
|
|
39
|
+
stopEvent,
|
|
40
|
+
toDataUrl
|
|
41
|
+
} from "./chunk-QCIN557M.js";
|
|
1
42
|
import {
|
|
2
43
|
AbortException,
|
|
3
44
|
AnnotationBorderStyleType,
|
|
@@ -7,8 +48,6 @@ import {
|
|
|
7
48
|
AnnotationMode,
|
|
8
49
|
AnnotationPrefix,
|
|
9
50
|
AnnotationType,
|
|
10
|
-
BaseException,
|
|
11
|
-
ColorConverters,
|
|
12
51
|
DrawOPS,
|
|
13
52
|
FONT_IDENTITY_MATRIX,
|
|
14
53
|
FeatureTest,
|
|
@@ -17,8 +56,6 @@ import {
|
|
|
17
56
|
InvalidPDFException,
|
|
18
57
|
LINE_FACTOR,
|
|
19
58
|
MathClamp,
|
|
20
|
-
MessageHandler,
|
|
21
|
-
MurmurHash3_64,
|
|
22
59
|
OPS,
|
|
23
60
|
PasswordResponses,
|
|
24
61
|
PermissionFlag,
|
|
@@ -29,7 +66,6 @@ import {
|
|
|
29
66
|
VerbosityLevel,
|
|
30
67
|
_isValidExplicitDest,
|
|
31
68
|
assert,
|
|
32
|
-
convertBlackAndWhiteToRGBA,
|
|
33
69
|
createValidAbsoluteUrl,
|
|
34
70
|
fromBase64Util,
|
|
35
71
|
getUuid,
|
|
@@ -44,9 +80,8 @@ import {
|
|
|
44
80
|
toBase64Util,
|
|
45
81
|
unreachable,
|
|
46
82
|
updateUrlHash,
|
|
47
|
-
warn
|
|
48
|
-
|
|
49
|
-
} from "./chunk-4FQTXXTH.js";
|
|
83
|
+
warn
|
|
84
|
+
} from "./chunk-XMKSLA4K.js";
|
|
50
85
|
import {
|
|
51
86
|
__privateAdd,
|
|
52
87
|
__privateGet,
|
|
@@ -56,569 +91,6 @@ import {
|
|
|
56
91
|
__publicField
|
|
57
92
|
} from "./chunk-7MW5RQZ5.js";
|
|
58
93
|
|
|
59
|
-
// src/pdf.js/src/display/display_utils.js
|
|
60
|
-
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
61
|
-
var _PixelsPerInch = class _PixelsPerInch {
|
|
62
|
-
};
|
|
63
|
-
__publicField(_PixelsPerInch, "CSS", 96);
|
|
64
|
-
__publicField(_PixelsPerInch, "PDF", 72);
|
|
65
|
-
__publicField(_PixelsPerInch, "PDF_TO_CSS_UNITS", _PixelsPerInch.CSS / _PixelsPerInch.PDF);
|
|
66
|
-
var PixelsPerInch = _PixelsPerInch;
|
|
67
|
-
async function fetchData(url, type = "text") {
|
|
68
|
-
if (isValidFetchUrl(url, document.baseURI)) {
|
|
69
|
-
const response = await fetch(url);
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
throw new Error(response.statusText);
|
|
72
|
-
}
|
|
73
|
-
switch (type) {
|
|
74
|
-
case "arraybuffer":
|
|
75
|
-
return response.arrayBuffer();
|
|
76
|
-
case "blob":
|
|
77
|
-
return response.blob();
|
|
78
|
-
case "json":
|
|
79
|
-
return response.json();
|
|
80
|
-
}
|
|
81
|
-
return response.text();
|
|
82
|
-
}
|
|
83
|
-
return new Promise((resolve, reject) => {
|
|
84
|
-
const request = new XMLHttpRequest();
|
|
85
|
-
request.open(
|
|
86
|
-
"GET",
|
|
87
|
-
url,
|
|
88
|
-
/* async = */
|
|
89
|
-
true
|
|
90
|
-
);
|
|
91
|
-
request.responseType = type;
|
|
92
|
-
request.onreadystatechange = () => {
|
|
93
|
-
if (request.readyState !== XMLHttpRequest.DONE) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (request.status === 200 || request.status === 0) {
|
|
97
|
-
switch (type) {
|
|
98
|
-
case "arraybuffer":
|
|
99
|
-
case "blob":
|
|
100
|
-
case "json":
|
|
101
|
-
resolve(request.response);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
resolve(request.responseText);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
reject(new Error(request.statusText));
|
|
108
|
-
};
|
|
109
|
-
request.send(null);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
var PageViewport = class _PageViewport {
|
|
113
|
-
/**
|
|
114
|
-
* @param {PageViewportParameters}
|
|
115
|
-
*/
|
|
116
|
-
constructor({
|
|
117
|
-
viewBox,
|
|
118
|
-
userUnit,
|
|
119
|
-
scale,
|
|
120
|
-
rotation,
|
|
121
|
-
offsetX = 0,
|
|
122
|
-
offsetY = 0,
|
|
123
|
-
dontFlip = false
|
|
124
|
-
}) {
|
|
125
|
-
this.viewBox = viewBox;
|
|
126
|
-
this.userUnit = userUnit;
|
|
127
|
-
this.scale = scale;
|
|
128
|
-
this.rotation = rotation;
|
|
129
|
-
this.offsetX = offsetX;
|
|
130
|
-
this.offsetY = offsetY;
|
|
131
|
-
scale *= userUnit;
|
|
132
|
-
const centerX = (viewBox[2] + viewBox[0]) / 2;
|
|
133
|
-
const centerY = (viewBox[3] + viewBox[1]) / 2;
|
|
134
|
-
let rotateA, rotateB, rotateC, rotateD;
|
|
135
|
-
rotation %= 360;
|
|
136
|
-
if (rotation < 0) {
|
|
137
|
-
rotation += 360;
|
|
138
|
-
}
|
|
139
|
-
switch (rotation) {
|
|
140
|
-
case 180:
|
|
141
|
-
rotateA = -1;
|
|
142
|
-
rotateB = 0;
|
|
143
|
-
rotateC = 0;
|
|
144
|
-
rotateD = 1;
|
|
145
|
-
break;
|
|
146
|
-
case 90:
|
|
147
|
-
rotateA = 0;
|
|
148
|
-
rotateB = 1;
|
|
149
|
-
rotateC = 1;
|
|
150
|
-
rotateD = 0;
|
|
151
|
-
break;
|
|
152
|
-
case 270:
|
|
153
|
-
rotateA = 0;
|
|
154
|
-
rotateB = -1;
|
|
155
|
-
rotateC = -1;
|
|
156
|
-
rotateD = 0;
|
|
157
|
-
break;
|
|
158
|
-
case 0:
|
|
159
|
-
rotateA = 1;
|
|
160
|
-
rotateB = 0;
|
|
161
|
-
rotateC = 0;
|
|
162
|
-
rotateD = -1;
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
throw new Error(
|
|
166
|
-
"PageViewport: Invalid rotation, must be a multiple of 90 degrees."
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
if (dontFlip) {
|
|
170
|
-
rotateC = -rotateC;
|
|
171
|
-
rotateD = -rotateD;
|
|
172
|
-
}
|
|
173
|
-
let offsetCanvasX, offsetCanvasY;
|
|
174
|
-
let width, height;
|
|
175
|
-
if (rotateA === 0) {
|
|
176
|
-
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
|
|
177
|
-
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
|
|
178
|
-
width = (viewBox[3] - viewBox[1]) * scale;
|
|
179
|
-
height = (viewBox[2] - viewBox[0]) * scale;
|
|
180
|
-
} else {
|
|
181
|
-
offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
|
|
182
|
-
offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
|
|
183
|
-
width = (viewBox[2] - viewBox[0]) * scale;
|
|
184
|
-
height = (viewBox[3] - viewBox[1]) * scale;
|
|
185
|
-
}
|
|
186
|
-
this.transform = [
|
|
187
|
-
rotateA * scale,
|
|
188
|
-
rotateB * scale,
|
|
189
|
-
rotateC * scale,
|
|
190
|
-
rotateD * scale,
|
|
191
|
-
offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
|
|
192
|
-
offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
|
|
193
|
-
];
|
|
194
|
-
this.width = width;
|
|
195
|
-
this.height = height;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* The original, un-scaled, viewport dimensions.
|
|
199
|
-
* @type {Object}
|
|
200
|
-
*/
|
|
201
|
-
get rawDims() {
|
|
202
|
-
const dims = this.viewBox;
|
|
203
|
-
return shadow(this, "rawDims", {
|
|
204
|
-
pageWidth: dims[2] - dims[0],
|
|
205
|
-
pageHeight: dims[3] - dims[1],
|
|
206
|
-
pageX: dims[0],
|
|
207
|
-
pageY: dims[1]
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Clones viewport, with optional additional properties.
|
|
212
|
-
* @param {PageViewportCloneParameters} [params]
|
|
213
|
-
* @returns {PageViewport} Cloned viewport.
|
|
214
|
-
*/
|
|
215
|
-
clone({
|
|
216
|
-
scale = this.scale,
|
|
217
|
-
rotation = this.rotation,
|
|
218
|
-
offsetX = this.offsetX,
|
|
219
|
-
offsetY = this.offsetY,
|
|
220
|
-
dontFlip = false
|
|
221
|
-
} = {}) {
|
|
222
|
-
return new _PageViewport({
|
|
223
|
-
viewBox: this.viewBox.slice(),
|
|
224
|
-
userUnit: this.userUnit,
|
|
225
|
-
scale,
|
|
226
|
-
rotation,
|
|
227
|
-
offsetX,
|
|
228
|
-
offsetY,
|
|
229
|
-
dontFlip
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Converts PDF point to the viewport coordinates. For examples, useful for
|
|
234
|
-
* converting PDF location into canvas pixel coordinates.
|
|
235
|
-
* @param {number} x - The x-coordinate.
|
|
236
|
-
* @param {number} y - The y-coordinate.
|
|
237
|
-
* @returns {Array} Array containing `x`- and `y`-coordinates of the
|
|
238
|
-
* point in the viewport coordinate space.
|
|
239
|
-
* @see {@link convertToPdfPoint}
|
|
240
|
-
* @see {@link convertToViewportRectangle}
|
|
241
|
-
*/
|
|
242
|
-
convertToViewportPoint(x, y) {
|
|
243
|
-
const p = [x, y];
|
|
244
|
-
Util.applyTransform(p, this.transform);
|
|
245
|
-
return p;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Converts PDF rectangle to the viewport coordinates.
|
|
249
|
-
* @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.
|
|
250
|
-
* @returns {Array} Array containing corresponding coordinates of the
|
|
251
|
-
* rectangle in the viewport coordinate space.
|
|
252
|
-
* @see {@link convertToViewportPoint}
|
|
253
|
-
*/
|
|
254
|
-
convertToViewportRectangle(rect) {
|
|
255
|
-
const topLeft = [rect[0], rect[1]];
|
|
256
|
-
Util.applyTransform(topLeft, this.transform);
|
|
257
|
-
const bottomRight = [rect[2], rect[3]];
|
|
258
|
-
Util.applyTransform(bottomRight, this.transform);
|
|
259
|
-
return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Converts viewport coordinates to the PDF location. For examples, useful
|
|
263
|
-
* for converting canvas pixel location into PDF one.
|
|
264
|
-
* @param {number} x - The x-coordinate.
|
|
265
|
-
* @param {number} y - The y-coordinate.
|
|
266
|
-
* @returns {Array} Array containing `x`- and `y`-coordinates of the
|
|
267
|
-
* point in the PDF coordinate space.
|
|
268
|
-
* @see {@link convertToViewportPoint}
|
|
269
|
-
*/
|
|
270
|
-
convertToPdfPoint(x, y) {
|
|
271
|
-
const p = [x, y];
|
|
272
|
-
Util.applyInverseTransform(p, this.transform);
|
|
273
|
-
return p;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
var RenderingCancelledException = class extends BaseException {
|
|
277
|
-
constructor(msg, extraDelay = 0) {
|
|
278
|
-
super(msg, "RenderingCancelledException");
|
|
279
|
-
this.extraDelay = extraDelay;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
function isDataScheme(url) {
|
|
283
|
-
const ii = url.length;
|
|
284
|
-
let i = 0;
|
|
285
|
-
while (i < ii && url[i].trim() === "") {
|
|
286
|
-
i++;
|
|
287
|
-
}
|
|
288
|
-
return url.substring(i, i + 5).toLowerCase() === "data:";
|
|
289
|
-
}
|
|
290
|
-
function isPdfFile(filename) {
|
|
291
|
-
return typeof filename === "string" && /\.pdf$/i.test(filename);
|
|
292
|
-
}
|
|
293
|
-
function getFilenameFromUrl(url) {
|
|
294
|
-
[url] = url.split(/[#?]/, 1);
|
|
295
|
-
return url.substring(url.lastIndexOf("/") + 1);
|
|
296
|
-
}
|
|
297
|
-
function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
|
|
298
|
-
if (typeof url !== "string") {
|
|
299
|
-
return defaultFilename;
|
|
300
|
-
}
|
|
301
|
-
if (isDataScheme(url)) {
|
|
302
|
-
warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
|
|
303
|
-
return defaultFilename;
|
|
304
|
-
}
|
|
305
|
-
const getURL = (urlString) => {
|
|
306
|
-
try {
|
|
307
|
-
return new URL(urlString);
|
|
308
|
-
} catch {
|
|
309
|
-
try {
|
|
310
|
-
return new URL(decodeURIComponent(urlString));
|
|
311
|
-
} catch {
|
|
312
|
-
try {
|
|
313
|
-
return new URL(urlString, "https://foo.bar");
|
|
314
|
-
} catch {
|
|
315
|
-
try {
|
|
316
|
-
return new URL(decodeURIComponent(urlString), "https://foo.bar");
|
|
317
|
-
} catch {
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
const newURL = getURL(url);
|
|
325
|
-
if (!newURL) {
|
|
326
|
-
return defaultFilename;
|
|
327
|
-
}
|
|
328
|
-
const decode = (name) => {
|
|
329
|
-
try {
|
|
330
|
-
let decoded = decodeURIComponent(name);
|
|
331
|
-
if (decoded.includes("/")) {
|
|
332
|
-
decoded = decoded.split("/").at(-1);
|
|
333
|
-
if (decoded.test(/^\.pdf$/i)) {
|
|
334
|
-
return decoded;
|
|
335
|
-
}
|
|
336
|
-
return name;
|
|
337
|
-
}
|
|
338
|
-
return decoded;
|
|
339
|
-
} catch {
|
|
340
|
-
return name;
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
const pdfRegex = /\.pdf$/i;
|
|
344
|
-
const filename = newURL.pathname.split("/").at(-1);
|
|
345
|
-
if (pdfRegex.test(filename)) {
|
|
346
|
-
return decode(filename);
|
|
347
|
-
}
|
|
348
|
-
if (newURL.searchParams.size > 0) {
|
|
349
|
-
const values = Array.from(newURL.searchParams.values()).reverse();
|
|
350
|
-
for (const value of values) {
|
|
351
|
-
if (pdfRegex.test(value)) {
|
|
352
|
-
return decode(value);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
const keys = Array.from(newURL.searchParams.keys()).reverse();
|
|
356
|
-
for (const key of keys) {
|
|
357
|
-
if (pdfRegex.test(key)) {
|
|
358
|
-
return decode(key);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (newURL.hash) {
|
|
363
|
-
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
|
364
|
-
const hashFilename = reFilename.exec(newURL.hash);
|
|
365
|
-
if (hashFilename) {
|
|
366
|
-
return decode(hashFilename[0]);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return defaultFilename;
|
|
370
|
-
}
|
|
371
|
-
var StatTimer = class {
|
|
372
|
-
constructor() {
|
|
373
|
-
__publicField(this, "started", /* @__PURE__ */ Object.create(null));
|
|
374
|
-
__publicField(this, "times", []);
|
|
375
|
-
}
|
|
376
|
-
time(name) {
|
|
377
|
-
if (name in this.started) {
|
|
378
|
-
warn(`Timer is already running for ${name}`);
|
|
379
|
-
}
|
|
380
|
-
this.started[name] = Date.now();
|
|
381
|
-
}
|
|
382
|
-
timeEnd(name) {
|
|
383
|
-
if (!(name in this.started)) {
|
|
384
|
-
warn(`Timer has not been started for ${name}`);
|
|
385
|
-
}
|
|
386
|
-
this.times.push({
|
|
387
|
-
name,
|
|
388
|
-
start: this.started[name],
|
|
389
|
-
end: Date.now()
|
|
390
|
-
});
|
|
391
|
-
delete this.started[name];
|
|
392
|
-
}
|
|
393
|
-
toString() {
|
|
394
|
-
const outBuf = [];
|
|
395
|
-
let longest = 0;
|
|
396
|
-
for (const { name } of this.times) {
|
|
397
|
-
longest = Math.max(name.length, longest);
|
|
398
|
-
}
|
|
399
|
-
for (const { name, start, end } of this.times) {
|
|
400
|
-
outBuf.push(`${name.padEnd(longest)} ${end - start}ms
|
|
401
|
-
`);
|
|
402
|
-
}
|
|
403
|
-
return outBuf.join("");
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
function isValidFetchUrl(url, baseUrl) {
|
|
407
|
-
if (false) {
|
|
408
|
-
throw new Error("Not implemented: isValidFetchUrl");
|
|
409
|
-
}
|
|
410
|
-
const res = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
|
|
411
|
-
return res?.protocol === "http:" || res?.protocol === "https:";
|
|
412
|
-
}
|
|
413
|
-
function noContextMenu(e) {
|
|
414
|
-
e.preventDefault();
|
|
415
|
-
}
|
|
416
|
-
function stopEvent(e) {
|
|
417
|
-
e.preventDefault();
|
|
418
|
-
e.stopPropagation();
|
|
419
|
-
}
|
|
420
|
-
function deprecated(details) {
|
|
421
|
-
console.log("Deprecated API usage: " + details);
|
|
422
|
-
}
|
|
423
|
-
var _regex;
|
|
424
|
-
var PDFDateString = class {
|
|
425
|
-
/**
|
|
426
|
-
* Convert a PDF date string to a JavaScript `Date` object.
|
|
427
|
-
*
|
|
428
|
-
* The PDF date string format is described in section 7.9.4 of the official
|
|
429
|
-
* PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth
|
|
430
|
-
* edition) Adobe describes the same format including a trailing apostrophe.
|
|
431
|
-
* This syntax in incorrect, but Adobe Acrobat creates PDF files that contain
|
|
432
|
-
* them. We ignore all apostrophes as they are not necessary for date parsing.
|
|
433
|
-
*
|
|
434
|
-
* Moreover, Adobe Acrobat doesn't handle changing the date to universal time
|
|
435
|
-
* and doesn't use the user's time zone (effectively ignoring the HH' and mm'
|
|
436
|
-
* parts of the date string).
|
|
437
|
-
*
|
|
438
|
-
* @param {string} input
|
|
439
|
-
* @returns {Date|null}
|
|
440
|
-
*/
|
|
441
|
-
static toDateObject(input) {
|
|
442
|
-
if (!input || typeof input !== "string") {
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
__privateGet(this, _regex) || __privateSet(this, _regex, new RegExp(
|
|
446
|
-
"^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"
|
|
447
|
-
// Trailing apostrophe (optional)
|
|
448
|
-
));
|
|
449
|
-
const matches = __privateGet(this, _regex).exec(input);
|
|
450
|
-
if (!matches) {
|
|
451
|
-
return null;
|
|
452
|
-
}
|
|
453
|
-
const year = parseInt(matches[1], 10);
|
|
454
|
-
let month = parseInt(matches[2], 10);
|
|
455
|
-
month = month >= 1 && month <= 12 ? month - 1 : 0;
|
|
456
|
-
let day = parseInt(matches[3], 10);
|
|
457
|
-
day = day >= 1 && day <= 31 ? day : 1;
|
|
458
|
-
let hour = parseInt(matches[4], 10);
|
|
459
|
-
hour = hour >= 0 && hour <= 23 ? hour : 0;
|
|
460
|
-
let minute = parseInt(matches[5], 10);
|
|
461
|
-
minute = minute >= 0 && minute <= 59 ? minute : 0;
|
|
462
|
-
let second = parseInt(matches[6], 10);
|
|
463
|
-
second = second >= 0 && second <= 59 ? second : 0;
|
|
464
|
-
const universalTimeRelation = matches[7] || "Z";
|
|
465
|
-
let offsetHour = parseInt(matches[8], 10);
|
|
466
|
-
offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
|
|
467
|
-
let offsetMinute = parseInt(matches[9], 10) || 0;
|
|
468
|
-
offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
|
|
469
|
-
if (universalTimeRelation === "-") {
|
|
470
|
-
hour += offsetHour;
|
|
471
|
-
minute += offsetMinute;
|
|
472
|
-
} else if (universalTimeRelation === "+") {
|
|
473
|
-
hour -= offsetHour;
|
|
474
|
-
minute -= offsetMinute;
|
|
475
|
-
}
|
|
476
|
-
return new Date(Date.UTC(year, month, day, hour, minute, second));
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
_regex = new WeakMap();
|
|
480
|
-
__privateAdd(PDFDateString, _regex);
|
|
481
|
-
function getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) {
|
|
482
|
-
const { width, height } = xfaPage.attributes.style;
|
|
483
|
-
const viewBox = [0, 0, parseInt(width), parseInt(height)];
|
|
484
|
-
return new PageViewport({
|
|
485
|
-
viewBox,
|
|
486
|
-
userUnit: 1,
|
|
487
|
-
scale,
|
|
488
|
-
rotation
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
function getRGB(color) {
|
|
492
|
-
if (color.startsWith("#")) {
|
|
493
|
-
const colorRGB = parseInt(color.slice(1), 16);
|
|
494
|
-
return [
|
|
495
|
-
(colorRGB & 16711680) >> 16,
|
|
496
|
-
(colorRGB & 65280) >> 8,
|
|
497
|
-
colorRGB & 255
|
|
498
|
-
];
|
|
499
|
-
}
|
|
500
|
-
if (color.startsWith("rgb(")) {
|
|
501
|
-
return color.slice(
|
|
502
|
-
/* "rgb(".length */
|
|
503
|
-
4,
|
|
504
|
-
-1
|
|
505
|
-
).split(",").map((x) => parseInt(x));
|
|
506
|
-
}
|
|
507
|
-
if (color.startsWith("rgba(")) {
|
|
508
|
-
return color.slice(
|
|
509
|
-
/* "rgba(".length */
|
|
510
|
-
5,
|
|
511
|
-
-1
|
|
512
|
-
).split(",").map((x) => parseInt(x)).slice(0, 3);
|
|
513
|
-
}
|
|
514
|
-
warn(`Not a valid color format: "${color}"`);
|
|
515
|
-
return [0, 0, 0];
|
|
516
|
-
}
|
|
517
|
-
function getColorValues(colors) {
|
|
518
|
-
const span = document.createElement("span");
|
|
519
|
-
span.style.visibility = "hidden";
|
|
520
|
-
span.style.colorScheme = "only light";
|
|
521
|
-
document.body.append(span);
|
|
522
|
-
for (const name of colors.keys()) {
|
|
523
|
-
span.style.color = name;
|
|
524
|
-
const computedColor = window.getComputedStyle(span).color;
|
|
525
|
-
colors.set(name, getRGB(computedColor));
|
|
526
|
-
}
|
|
527
|
-
span.remove();
|
|
528
|
-
}
|
|
529
|
-
function getCurrentTransform(ctx) {
|
|
530
|
-
const { a, b, c, d, e, f } = ctx.getTransform();
|
|
531
|
-
return [a, b, c, d, e, f];
|
|
532
|
-
}
|
|
533
|
-
function getCurrentTransformInverse(ctx) {
|
|
534
|
-
const { a, b, c, d, e, f } = ctx.getTransform().invertSelf();
|
|
535
|
-
return [a, b, c, d, e, f];
|
|
536
|
-
}
|
|
537
|
-
function setLayerDimensions(div, viewport, mustFlip = false, mustRotate = true) {
|
|
538
|
-
if (viewport instanceof PageViewport) {
|
|
539
|
-
const { pageWidth, pageHeight } = viewport.rawDims;
|
|
540
|
-
const { style } = div;
|
|
541
|
-
const useRound = FeatureTest.isCSSRoundSupported;
|
|
542
|
-
const w = `var(--total-scale-factor) * ${pageWidth}px`, h = `var(--total-scale-factor) * ${pageHeight}px`;
|
|
543
|
-
const widthStr = useRound ? `round(down, ${w}, var(--scale-round-x))` : `calc(${w})`, heightStr = useRound ? `round(down, ${h}, var(--scale-round-y))` : `calc(${h})`;
|
|
544
|
-
if (!mustFlip || viewport.rotation % 180 === 0) {
|
|
545
|
-
style.width = widthStr;
|
|
546
|
-
style.height = heightStr;
|
|
547
|
-
} else {
|
|
548
|
-
style.width = heightStr;
|
|
549
|
-
style.height = widthStr;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
if (mustRotate) {
|
|
553
|
-
div.setAttribute("data-main-rotation", viewport.rotation);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
var OutputScale = class _OutputScale {
|
|
557
|
-
constructor() {
|
|
558
|
-
const { pixelRatio } = _OutputScale;
|
|
559
|
-
this.sx = pixelRatio;
|
|
560
|
-
this.sy = pixelRatio;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* @type {boolean} Returns `true` when scaling is required, `false` otherwise.
|
|
564
|
-
*/
|
|
565
|
-
get scaled() {
|
|
566
|
-
return this.sx !== 1 || this.sy !== 1;
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* @type {boolean} Returns `true` when scaling is symmetric,
|
|
570
|
-
* `false` otherwise.
|
|
571
|
-
*/
|
|
572
|
-
get symmetric() {
|
|
573
|
-
return this.sx === this.sy;
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* @returns {boolean} Returns `true` if scaling was limited,
|
|
577
|
-
* `false` otherwise.
|
|
578
|
-
*/
|
|
579
|
-
limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {
|
|
580
|
-
let maxAreaScale = Infinity, maxWidthScale = Infinity, maxHeightScale = Infinity;
|
|
581
|
-
maxPixels = _OutputScale.capPixels(maxPixels, capAreaFactor);
|
|
582
|
-
if (maxPixels > 0) {
|
|
583
|
-
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
|
584
|
-
}
|
|
585
|
-
if (maxDim !== -1) {
|
|
586
|
-
maxWidthScale = maxDim / width;
|
|
587
|
-
maxHeightScale = maxDim / height;
|
|
588
|
-
}
|
|
589
|
-
const maxScale = Math.min(maxAreaScale, maxWidthScale, maxHeightScale);
|
|
590
|
-
if (this.sx > maxScale || this.sy > maxScale) {
|
|
591
|
-
this.sx = maxScale;
|
|
592
|
-
this.sy = maxScale;
|
|
593
|
-
return true;
|
|
594
|
-
}
|
|
595
|
-
return false;
|
|
596
|
-
}
|
|
597
|
-
static get pixelRatio() {
|
|
598
|
-
return globalThis.devicePixelRatio || 1;
|
|
599
|
-
}
|
|
600
|
-
static capPixels(maxPixels, capAreaFactor) {
|
|
601
|
-
if (capAreaFactor >= 0) {
|
|
602
|
-
const winPixels = Math.ceil(
|
|
603
|
-
(false ? window.innerWidth * window.innerHeight : window.screen.availWidth * window.screen.availHeight) * this.pixelRatio ** 2 * (1 + capAreaFactor / 100)
|
|
604
|
-
);
|
|
605
|
-
return maxPixels > 0 ? Math.min(maxPixels, winPixels) : winPixels;
|
|
606
|
-
}
|
|
607
|
-
return maxPixels;
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
var SupportedImageMimeTypes = [
|
|
611
|
-
"image/apng",
|
|
612
|
-
"image/avif",
|
|
613
|
-
"image/bmp",
|
|
614
|
-
"image/gif",
|
|
615
|
-
"image/jpeg",
|
|
616
|
-
"image/png",
|
|
617
|
-
"image/svg+xml",
|
|
618
|
-
"image/webp",
|
|
619
|
-
"image/x-icon"
|
|
620
|
-
];
|
|
621
|
-
|
|
622
94
|
// src/pdf.js/src/display/editor/toolbar.js
|
|
623
95
|
var _toolbar, _colorPicker, _editor, _buttons, _altText, _signatureDescriptionButton, _l10nRemove, _EditorToolbar_static, pointerDown_fn, _EditorToolbar_instances, focusIn_fn, focusOut_fn, addListenersToElement_fn, divider_get;
|
|
624
96
|
var _EditorToolbar = class _EditorToolbar {
|
|
@@ -5545,30 +5017,29 @@ _serializable = new WeakMap();
|
|
|
5545
5017
|
|
|
5546
5018
|
// src/lib/NodeCanvas.ts
|
|
5547
5019
|
import { writeFile } from "node:fs/promises";
|
|
5548
|
-
import { createRequire } from "node:module";
|
|
5549
5020
|
import { dirname, join } from "node:path";
|
|
5550
5021
|
import { fileURLToPath } from "node:url";
|
|
5551
|
-
|
|
5552
|
-
var {
|
|
5553
|
-
createCanvas: create,
|
|
5554
|
-
GlobalFonts,
|
|
5555
|
-
Path2D
|
|
5556
|
-
} = require2("@napi-rs/canvas");
|
|
5022
|
+
import { Canvas, FontLibrary, Path2D } from "skia-canvas";
|
|
5557
5023
|
async function createCanvas(width, height) {
|
|
5558
5024
|
await loadDefaultFonts();
|
|
5559
|
-
return
|
|
5025
|
+
return new Canvas(width, height);
|
|
5560
5026
|
}
|
|
5561
5027
|
var loadingFontPromise = null;
|
|
5562
5028
|
async function loadDefaultFonts() {
|
|
5563
5029
|
if (loadingFontPromise === null) {
|
|
5564
5030
|
loadingFontPromise = import("./LiberationSans-Regular-CDMMZL5S.js").then((module) => module.default).then(async (sansBuffer) => {
|
|
5031
|
+
if (typeof sansBuffer === "string") {
|
|
5032
|
+
FontLibrary.use({
|
|
5033
|
+
"Liberation Sans": [join(process.cwd(), sansBuffer)]
|
|
5034
|
+
});
|
|
5035
|
+
return;
|
|
5036
|
+
}
|
|
5565
5037
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
5566
5038
|
const fileName = join(currentDir, "LiberationSans-Regular.ttf");
|
|
5567
5039
|
await writeFile(fileName, sansBuffer);
|
|
5568
|
-
|
|
5569
|
-
fileName
|
|
5570
|
-
|
|
5571
|
-
);
|
|
5040
|
+
FontLibrary.use({
|
|
5041
|
+
"Liberation Sans": [fileName]
|
|
5042
|
+
});
|
|
5572
5043
|
});
|
|
5573
5044
|
}
|
|
5574
5045
|
return loadingFontPromise;
|
|
@@ -6327,73 +5798,13 @@ var LoopbackPort = class {
|
|
|
6327
5798
|
_listeners = new WeakMap();
|
|
6328
5799
|
_deferred = new WeakMap();
|
|
6329
5800
|
|
|
6330
|
-
// src/
|
|
6331
|
-
import {
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
__privateAdd(this, _enableHWA, false);
|
|
6338
|
-
if (false) {
|
|
6339
|
-
unreachable("Cannot initialize BaseCanvasFactory.");
|
|
6340
|
-
}
|
|
6341
|
-
__privateSet(this, _enableHWA, enableHWA);
|
|
6342
|
-
}
|
|
6343
|
-
create(width, height) {
|
|
6344
|
-
if (width <= 0 || height <= 0) {
|
|
6345
|
-
throw new Error("Invalid canvas size");
|
|
6346
|
-
}
|
|
6347
|
-
const canvas = this._createCanvas(width, height);
|
|
6348
|
-
return {
|
|
6349
|
-
canvas,
|
|
6350
|
-
context: canvas.getContext("2d", {
|
|
6351
|
-
willReadFrequently: !__privateGet(this, _enableHWA)
|
|
6352
|
-
})
|
|
6353
|
-
};
|
|
6354
|
-
}
|
|
6355
|
-
reset(canvasAndContext, width, height) {
|
|
6356
|
-
if (!canvasAndContext.canvas) {
|
|
6357
|
-
throw new Error("Canvas is not specified");
|
|
6358
|
-
}
|
|
6359
|
-
if (width <= 0 || height <= 0) {
|
|
6360
|
-
throw new Error("Invalid canvas size");
|
|
6361
|
-
}
|
|
6362
|
-
canvasAndContext.canvas.width = width;
|
|
6363
|
-
canvasAndContext.canvas.height = height;
|
|
6364
|
-
}
|
|
6365
|
-
destroy(canvasAndContext) {
|
|
6366
|
-
if (!canvasAndContext.canvas) {
|
|
6367
|
-
throw new Error("Canvas is not specified");
|
|
6368
|
-
}
|
|
6369
|
-
canvasAndContext.canvas.width = 0;
|
|
6370
|
-
canvasAndContext.canvas.height = 0;
|
|
6371
|
-
canvasAndContext.canvas = null;
|
|
6372
|
-
canvasAndContext.context = null;
|
|
6373
|
-
}
|
|
6374
|
-
/**
|
|
6375
|
-
* @ignore
|
|
6376
|
-
*/
|
|
6377
|
-
_createCanvas(width, height) {
|
|
6378
|
-
unreachable("Abstract method `_createCanvas` called.");
|
|
6379
|
-
}
|
|
6380
|
-
};
|
|
6381
|
-
_enableHWA = new WeakMap();
|
|
6382
|
-
var DOMCanvasFactory = class extends BaseCanvasFactory {
|
|
6383
|
-
constructor({ ownerDocument = globalThis.document, enableHWA = false }) {
|
|
6384
|
-
super({ enableHWA });
|
|
6385
|
-
this._document = ownerDocument;
|
|
6386
|
-
}
|
|
6387
|
-
/**
|
|
6388
|
-
* @ignore
|
|
6389
|
-
*/
|
|
6390
|
-
_createCanvas(width, height) {
|
|
6391
|
-
const canvas = this._document.createElement("canvas");
|
|
6392
|
-
canvas.width = width;
|
|
6393
|
-
canvas.height = height;
|
|
6394
|
-
return canvas;
|
|
6395
|
-
}
|
|
6396
|
-
};
|
|
5801
|
+
// src/lib/NodeUtils.ts
|
|
5802
|
+
import {
|
|
5803
|
+
DOMMatrix as NodeDOMMatrix,
|
|
5804
|
+
DOMPoint as NodeDOMPoint,
|
|
5805
|
+
ImageData as NodeImageData,
|
|
5806
|
+
Path2D as NodePath2D
|
|
5807
|
+
} from "skia-canvas";
|
|
6397
5808
|
|
|
6398
5809
|
// src/pdf.js/src/display/cmap_reader_factory.js
|
|
6399
5810
|
var BaseCMapReaderFactory = class {
|
|
@@ -6442,380 +5853,6 @@ var DOMCMapReaderFactory = class extends BaseCMapReaderFactory {
|
|
|
6442
5853
|
}
|
|
6443
5854
|
};
|
|
6444
5855
|
|
|
6445
|
-
// src/pdf.js/src/display/filter_factory.js
|
|
6446
|
-
var BaseFilterFactory = class {
|
|
6447
|
-
constructor() {
|
|
6448
|
-
if (false) {
|
|
6449
|
-
unreachable("Cannot initialize BaseFilterFactory.");
|
|
6450
|
-
}
|
|
6451
|
-
}
|
|
6452
|
-
addFilter(maps) {
|
|
6453
|
-
return "none";
|
|
6454
|
-
}
|
|
6455
|
-
addHCMFilter(fgColor, bgColor) {
|
|
6456
|
-
return "none";
|
|
6457
|
-
}
|
|
6458
|
-
addAlphaFilter(map) {
|
|
6459
|
-
return "none";
|
|
6460
|
-
}
|
|
6461
|
-
addLuminosityFilter(map) {
|
|
6462
|
-
return "none";
|
|
6463
|
-
}
|
|
6464
|
-
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
|
|
6465
|
-
return "none";
|
|
6466
|
-
}
|
|
6467
|
-
destroy(keepHCM = false) {
|
|
6468
|
-
}
|
|
6469
|
-
};
|
|
6470
|
-
var _baseUrl, __cache, __defs, _docId, _document, __hcmCache, _id3, _DOMFilterFactory_instances, cache_get, hcmCache_get, defs_get, createTables_fn, createUrl_fn, addLuminosityConversion_fn, addGrayConversion_fn, createFilter_fn, appendFeFunc_fn, addTransferMapConversion_fn, addTransferMapAlphaConversion_fn, getRGB_fn;
|
|
6471
|
-
var DOMFilterFactory = class extends BaseFilterFactory {
|
|
6472
|
-
constructor({ docId, ownerDocument = globalThis.document }) {
|
|
6473
|
-
super();
|
|
6474
|
-
__privateAdd(this, _DOMFilterFactory_instances);
|
|
6475
|
-
__privateAdd(this, _baseUrl);
|
|
6476
|
-
__privateAdd(this, __cache);
|
|
6477
|
-
__privateAdd(this, __defs);
|
|
6478
|
-
__privateAdd(this, _docId);
|
|
6479
|
-
__privateAdd(this, _document);
|
|
6480
|
-
__privateAdd(this, __hcmCache);
|
|
6481
|
-
__privateAdd(this, _id3, 0);
|
|
6482
|
-
__privateSet(this, _docId, docId);
|
|
6483
|
-
__privateSet(this, _document, ownerDocument);
|
|
6484
|
-
}
|
|
6485
|
-
addFilter(maps) {
|
|
6486
|
-
if (!maps) {
|
|
6487
|
-
return "none";
|
|
6488
|
-
}
|
|
6489
|
-
let value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(maps);
|
|
6490
|
-
if (value) {
|
|
6491
|
-
return value;
|
|
6492
|
-
}
|
|
6493
|
-
const [tableR, tableG, tableB] = __privateMethod(this, _DOMFilterFactory_instances, createTables_fn).call(this, maps);
|
|
6494
|
-
const key = maps.length === 1 ? tableR : `${tableR}${tableG}${tableB}`;
|
|
6495
|
-
value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(key);
|
|
6496
|
-
if (value) {
|
|
6497
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(maps, value);
|
|
6498
|
-
return value;
|
|
6499
|
-
}
|
|
6500
|
-
const id = `g_${__privateGet(this, _docId)}_transfer_map_${__privateWrapper(this, _id3)._++}`;
|
|
6501
|
-
const url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
|
|
6502
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(maps, url);
|
|
6503
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(key, url);
|
|
6504
|
-
const filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
|
|
6505
|
-
__privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, tableR, tableG, tableB, filter);
|
|
6506
|
-
return url;
|
|
6507
|
-
}
|
|
6508
|
-
addHCMFilter(fgColor, bgColor) {
|
|
6509
|
-
const key = `${fgColor}-${bgColor}`;
|
|
6510
|
-
const filterName = "base";
|
|
6511
|
-
let info2 = __privateGet(this, _DOMFilterFactory_instances, hcmCache_get).get(filterName);
|
|
6512
|
-
if (info2?.key === key) {
|
|
6513
|
-
return info2.url;
|
|
6514
|
-
}
|
|
6515
|
-
if (info2) {
|
|
6516
|
-
info2.filter?.remove();
|
|
6517
|
-
info2.key = key;
|
|
6518
|
-
info2.url = "none";
|
|
6519
|
-
info2.filter = null;
|
|
6520
|
-
} else {
|
|
6521
|
-
info2 = {
|
|
6522
|
-
key,
|
|
6523
|
-
url: "none",
|
|
6524
|
-
filter: null
|
|
6525
|
-
};
|
|
6526
|
-
__privateGet(this, _DOMFilterFactory_instances, hcmCache_get).set(filterName, info2);
|
|
6527
|
-
}
|
|
6528
|
-
if (!fgColor || !bgColor) {
|
|
6529
|
-
return info2.url;
|
|
6530
|
-
}
|
|
6531
|
-
const fgRGB = __privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).call(this, fgColor);
|
|
6532
|
-
fgColor = Util.makeHexColor(...fgRGB);
|
|
6533
|
-
const bgRGB = __privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).call(this, bgColor);
|
|
6534
|
-
bgColor = Util.makeHexColor(...bgRGB);
|
|
6535
|
-
__privateGet(this, _DOMFilterFactory_instances, defs_get).style.color = "";
|
|
6536
|
-
if (fgColor === "#000000" && bgColor === "#ffffff" || fgColor === bgColor) {
|
|
6537
|
-
return info2.url;
|
|
6538
|
-
}
|
|
6539
|
-
const map = new Array(256);
|
|
6540
|
-
for (let i = 0; i <= 255; i++) {
|
|
6541
|
-
const x = i / 255;
|
|
6542
|
-
map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
6543
|
-
}
|
|
6544
|
-
const table = map.join(",");
|
|
6545
|
-
const id = `g_${__privateGet(this, _docId)}_hcm_filter`;
|
|
6546
|
-
const filter = info2.filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
|
|
6547
|
-
__privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, table, table, table, filter);
|
|
6548
|
-
__privateMethod(this, _DOMFilterFactory_instances, addGrayConversion_fn).call(this, filter);
|
|
6549
|
-
const getSteps = (c, n) => {
|
|
6550
|
-
const start = fgRGB[c] / 255;
|
|
6551
|
-
const end = bgRGB[c] / 255;
|
|
6552
|
-
const arr = new Array(n + 1);
|
|
6553
|
-
for (let i = 0; i <= n; i++) {
|
|
6554
|
-
arr[i] = start + i / n * (end - start);
|
|
6555
|
-
}
|
|
6556
|
-
return arr.join(",");
|
|
6557
|
-
};
|
|
6558
|
-
__privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, getSteps(0, 5), getSteps(1, 5), getSteps(2, 5), filter);
|
|
6559
|
-
info2.url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
|
|
6560
|
-
return info2.url;
|
|
6561
|
-
}
|
|
6562
|
-
addAlphaFilter(map) {
|
|
6563
|
-
let value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(map);
|
|
6564
|
-
if (value) {
|
|
6565
|
-
return value;
|
|
6566
|
-
}
|
|
6567
|
-
const [tableA] = __privateMethod(this, _DOMFilterFactory_instances, createTables_fn).call(this, [map]);
|
|
6568
|
-
const key = `alpha_${tableA}`;
|
|
6569
|
-
value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(key);
|
|
6570
|
-
if (value) {
|
|
6571
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, value);
|
|
6572
|
-
return value;
|
|
6573
|
-
}
|
|
6574
|
-
const id = `g_${__privateGet(this, _docId)}_alpha_map_${__privateWrapper(this, _id3)._++}`;
|
|
6575
|
-
const url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
|
|
6576
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, url);
|
|
6577
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(key, url);
|
|
6578
|
-
const filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
|
|
6579
|
-
__privateMethod(this, _DOMFilterFactory_instances, addTransferMapAlphaConversion_fn).call(this, tableA, filter);
|
|
6580
|
-
return url;
|
|
6581
|
-
}
|
|
6582
|
-
addLuminosityFilter(map) {
|
|
6583
|
-
let value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(map || "luminosity");
|
|
6584
|
-
if (value) {
|
|
6585
|
-
return value;
|
|
6586
|
-
}
|
|
6587
|
-
let tableA, key;
|
|
6588
|
-
if (map) {
|
|
6589
|
-
[tableA] = __privateMethod(this, _DOMFilterFactory_instances, createTables_fn).call(this, [map]);
|
|
6590
|
-
key = `luminosity_${tableA}`;
|
|
6591
|
-
} else {
|
|
6592
|
-
key = "luminosity";
|
|
6593
|
-
}
|
|
6594
|
-
value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(key);
|
|
6595
|
-
if (value) {
|
|
6596
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, value);
|
|
6597
|
-
return value;
|
|
6598
|
-
}
|
|
6599
|
-
const id = `g_${__privateGet(this, _docId)}_luminosity_map_${__privateWrapper(this, _id3)._++}`;
|
|
6600
|
-
const url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
|
|
6601
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, url);
|
|
6602
|
-
__privateGet(this, _DOMFilterFactory_instances, cache_get).set(key, url);
|
|
6603
|
-
const filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
|
|
6604
|
-
__privateMethod(this, _DOMFilterFactory_instances, addLuminosityConversion_fn).call(this, filter);
|
|
6605
|
-
if (map) {
|
|
6606
|
-
__privateMethod(this, _DOMFilterFactory_instances, addTransferMapAlphaConversion_fn).call(this, tableA, filter);
|
|
6607
|
-
}
|
|
6608
|
-
return url;
|
|
6609
|
-
}
|
|
6610
|
-
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
|
|
6611
|
-
const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
|
|
6612
|
-
let info2 = __privateGet(this, _DOMFilterFactory_instances, hcmCache_get).get(filterName);
|
|
6613
|
-
if (info2?.key === key) {
|
|
6614
|
-
return info2.url;
|
|
6615
|
-
}
|
|
6616
|
-
if (info2) {
|
|
6617
|
-
info2.filter?.remove();
|
|
6618
|
-
info2.key = key;
|
|
6619
|
-
info2.url = "none";
|
|
6620
|
-
info2.filter = null;
|
|
6621
|
-
} else {
|
|
6622
|
-
info2 = {
|
|
6623
|
-
key,
|
|
6624
|
-
url: "none",
|
|
6625
|
-
filter: null
|
|
6626
|
-
};
|
|
6627
|
-
__privateGet(this, _DOMFilterFactory_instances, hcmCache_get).set(filterName, info2);
|
|
6628
|
-
}
|
|
6629
|
-
if (!fgColor || !bgColor) {
|
|
6630
|
-
return info2.url;
|
|
6631
|
-
}
|
|
6632
|
-
const [fgRGB, bgRGB] = [fgColor, bgColor].map(__privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).bind(this));
|
|
6633
|
-
let fgGray = Math.round(
|
|
6634
|
-
0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]
|
|
6635
|
-
);
|
|
6636
|
-
let bgGray = Math.round(
|
|
6637
|
-
0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]
|
|
6638
|
-
);
|
|
6639
|
-
let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(
|
|
6640
|
-
__privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).bind(this)
|
|
6641
|
-
);
|
|
6642
|
-
if (bgGray < fgGray) {
|
|
6643
|
-
[fgGray, bgGray, newFgRGB, newBgRGB] = [
|
|
6644
|
-
bgGray,
|
|
6645
|
-
fgGray,
|
|
6646
|
-
newBgRGB,
|
|
6647
|
-
newFgRGB
|
|
6648
|
-
];
|
|
6649
|
-
}
|
|
6650
|
-
__privateGet(this, _DOMFilterFactory_instances, defs_get).style.color = "";
|
|
6651
|
-
const getSteps = (fg, bg, n) => {
|
|
6652
|
-
const arr = new Array(256);
|
|
6653
|
-
const step = (bgGray - fgGray) / n;
|
|
6654
|
-
const newStart = fg / 255;
|
|
6655
|
-
const newStep = (bg - fg) / (255 * n);
|
|
6656
|
-
let prev = 0;
|
|
6657
|
-
for (let i = 0; i <= n; i++) {
|
|
6658
|
-
const k = Math.round(fgGray + i * step);
|
|
6659
|
-
const value = newStart + i * newStep;
|
|
6660
|
-
for (let j = prev; j <= k; j++) {
|
|
6661
|
-
arr[j] = value;
|
|
6662
|
-
}
|
|
6663
|
-
prev = k + 1;
|
|
6664
|
-
}
|
|
6665
|
-
for (let i = prev; i < 256; i++) {
|
|
6666
|
-
arr[i] = arr[prev - 1];
|
|
6667
|
-
}
|
|
6668
|
-
return arr.join(",");
|
|
6669
|
-
};
|
|
6670
|
-
const id = `g_${__privateGet(this, _docId)}_hcm_${filterName}_filter`;
|
|
6671
|
-
const filter = info2.filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
|
|
6672
|
-
__privateMethod(this, _DOMFilterFactory_instances, addGrayConversion_fn).call(this, filter);
|
|
6673
|
-
__privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, getSteps(newFgRGB[0], newBgRGB[0], 5), getSteps(newFgRGB[1], newBgRGB[1], 5), getSteps(newFgRGB[2], newBgRGB[2], 5), filter);
|
|
6674
|
-
info2.url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
|
|
6675
|
-
return info2.url;
|
|
6676
|
-
}
|
|
6677
|
-
destroy(keepHCM = false) {
|
|
6678
|
-
if (keepHCM && __privateGet(this, __hcmCache)?.size) {
|
|
6679
|
-
return;
|
|
6680
|
-
}
|
|
6681
|
-
__privateGet(this, __defs)?.parentNode.parentNode.remove();
|
|
6682
|
-
__privateSet(this, __defs, null);
|
|
6683
|
-
__privateGet(this, __cache)?.clear();
|
|
6684
|
-
__privateSet(this, __cache, null);
|
|
6685
|
-
__privateGet(this, __hcmCache)?.clear();
|
|
6686
|
-
__privateSet(this, __hcmCache, null);
|
|
6687
|
-
__privateSet(this, _id3, 0);
|
|
6688
|
-
}
|
|
6689
|
-
};
|
|
6690
|
-
_baseUrl = new WeakMap();
|
|
6691
|
-
__cache = new WeakMap();
|
|
6692
|
-
__defs = new WeakMap();
|
|
6693
|
-
_docId = new WeakMap();
|
|
6694
|
-
_document = new WeakMap();
|
|
6695
|
-
__hcmCache = new WeakMap();
|
|
6696
|
-
_id3 = new WeakMap();
|
|
6697
|
-
_DOMFilterFactory_instances = new WeakSet();
|
|
6698
|
-
cache_get = function() {
|
|
6699
|
-
return __privateGet(this, __cache) || __privateSet(this, __cache, /* @__PURE__ */ new Map());
|
|
6700
|
-
};
|
|
6701
|
-
hcmCache_get = function() {
|
|
6702
|
-
return __privateGet(this, __hcmCache) || __privateSet(this, __hcmCache, /* @__PURE__ */ new Map());
|
|
6703
|
-
};
|
|
6704
|
-
defs_get = function() {
|
|
6705
|
-
if (!__privateGet(this, __defs)) {
|
|
6706
|
-
const div = __privateGet(this, _document).createElement("div");
|
|
6707
|
-
const { style } = div;
|
|
6708
|
-
style.visibility = "hidden";
|
|
6709
|
-
style.contain = "strict";
|
|
6710
|
-
style.width = style.height = 0;
|
|
6711
|
-
style.position = "absolute";
|
|
6712
|
-
style.top = style.left = 0;
|
|
6713
|
-
style.zIndex = -1;
|
|
6714
|
-
const svg = __privateGet(this, _document).createElementNS(SVG_NS, "svg");
|
|
6715
|
-
svg.setAttribute("width", 0);
|
|
6716
|
-
svg.setAttribute("height", 0);
|
|
6717
|
-
__privateSet(this, __defs, __privateGet(this, _document).createElementNS(SVG_NS, "defs"));
|
|
6718
|
-
div.append(svg);
|
|
6719
|
-
svg.append(__privateGet(this, __defs));
|
|
6720
|
-
__privateGet(this, _document).body.append(div);
|
|
6721
|
-
}
|
|
6722
|
-
return __privateGet(this, __defs);
|
|
6723
|
-
};
|
|
6724
|
-
createTables_fn = function(maps) {
|
|
6725
|
-
if (maps.length === 1) {
|
|
6726
|
-
const mapR2 = maps[0];
|
|
6727
|
-
const buffer = new Array(256);
|
|
6728
|
-
for (let i = 0; i < 256; i++) {
|
|
6729
|
-
buffer[i] = mapR2[i] / 255;
|
|
6730
|
-
}
|
|
6731
|
-
const table = buffer.join(",");
|
|
6732
|
-
return [table, table, table];
|
|
6733
|
-
}
|
|
6734
|
-
const [mapR, mapG, mapB] = maps;
|
|
6735
|
-
const bufferR = new Array(256);
|
|
6736
|
-
const bufferG = new Array(256);
|
|
6737
|
-
const bufferB = new Array(256);
|
|
6738
|
-
for (let i = 0; i < 256; i++) {
|
|
6739
|
-
bufferR[i] = mapR[i] / 255;
|
|
6740
|
-
bufferG[i] = mapG[i] / 255;
|
|
6741
|
-
bufferB[i] = mapB[i] / 255;
|
|
6742
|
-
}
|
|
6743
|
-
return [bufferR.join(","), bufferG.join(","), bufferB.join(",")];
|
|
6744
|
-
};
|
|
6745
|
-
createUrl_fn = function(id) {
|
|
6746
|
-
if (__privateGet(this, _baseUrl) === void 0) {
|
|
6747
|
-
__privateSet(this, _baseUrl, "");
|
|
6748
|
-
const url = __privateGet(this, _document).URL;
|
|
6749
|
-
if (url !== __privateGet(this, _document).baseURI) {
|
|
6750
|
-
if (isDataScheme(url)) {
|
|
6751
|
-
warn('#createUrl: ignore "data:"-URL for performance reasons.');
|
|
6752
|
-
} else {
|
|
6753
|
-
__privateSet(this, _baseUrl, updateUrlHash(url, ""));
|
|
6754
|
-
}
|
|
6755
|
-
}
|
|
6756
|
-
}
|
|
6757
|
-
return `url(${__privateGet(this, _baseUrl)}#${id})`;
|
|
6758
|
-
};
|
|
6759
|
-
addLuminosityConversion_fn = function(filter) {
|
|
6760
|
-
const feColorMatrix = __privateGet(this, _document).createElementNS(
|
|
6761
|
-
SVG_NS,
|
|
6762
|
-
"feColorMatrix"
|
|
6763
|
-
);
|
|
6764
|
-
feColorMatrix.setAttribute("type", "matrix");
|
|
6765
|
-
feColorMatrix.setAttribute(
|
|
6766
|
-
"values",
|
|
6767
|
-
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"
|
|
6768
|
-
);
|
|
6769
|
-
filter.append(feColorMatrix);
|
|
6770
|
-
};
|
|
6771
|
-
addGrayConversion_fn = function(filter) {
|
|
6772
|
-
const feColorMatrix = __privateGet(this, _document).createElementNS(
|
|
6773
|
-
SVG_NS,
|
|
6774
|
-
"feColorMatrix"
|
|
6775
|
-
);
|
|
6776
|
-
feColorMatrix.setAttribute("type", "matrix");
|
|
6777
|
-
feColorMatrix.setAttribute(
|
|
6778
|
-
"values",
|
|
6779
|
-
"0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"
|
|
6780
|
-
);
|
|
6781
|
-
filter.append(feColorMatrix);
|
|
6782
|
-
};
|
|
6783
|
-
createFilter_fn = function(id) {
|
|
6784
|
-
const filter = __privateGet(this, _document).createElementNS(SVG_NS, "filter");
|
|
6785
|
-
filter.setAttribute("color-interpolation-filters", "sRGB");
|
|
6786
|
-
filter.setAttribute("id", id);
|
|
6787
|
-
__privateGet(this, _DOMFilterFactory_instances, defs_get).append(filter);
|
|
6788
|
-
return filter;
|
|
6789
|
-
};
|
|
6790
|
-
appendFeFunc_fn = function(feComponentTransfer, func, table) {
|
|
6791
|
-
const feFunc = __privateGet(this, _document).createElementNS(SVG_NS, func);
|
|
6792
|
-
feFunc.setAttribute("type", "discrete");
|
|
6793
|
-
feFunc.setAttribute("tableValues", table);
|
|
6794
|
-
feComponentTransfer.append(feFunc);
|
|
6795
|
-
};
|
|
6796
|
-
addTransferMapConversion_fn = function(rTable, gTable, bTable, filter) {
|
|
6797
|
-
const feComponentTransfer = __privateGet(this, _document).createElementNS(
|
|
6798
|
-
SVG_NS,
|
|
6799
|
-
"feComponentTransfer"
|
|
6800
|
-
);
|
|
6801
|
-
filter.append(feComponentTransfer);
|
|
6802
|
-
__privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncR", rTable);
|
|
6803
|
-
__privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncG", gTable);
|
|
6804
|
-
__privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncB", bTable);
|
|
6805
|
-
};
|
|
6806
|
-
addTransferMapAlphaConversion_fn = function(aTable, filter) {
|
|
6807
|
-
const feComponentTransfer = __privateGet(this, _document).createElementNS(
|
|
6808
|
-
SVG_NS,
|
|
6809
|
-
"feComponentTransfer"
|
|
6810
|
-
);
|
|
6811
|
-
filter.append(feComponentTransfer);
|
|
6812
|
-
__privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncA", aTable);
|
|
6813
|
-
};
|
|
6814
|
-
getRGB_fn = function(color) {
|
|
6815
|
-
__privateGet(this, _DOMFilterFactory_instances, defs_get).style.color = color;
|
|
6816
|
-
return getRGB(getComputedStyle(__privateGet(this, _DOMFilterFactory_instances, defs_get)).getPropertyValue("color"));
|
|
6817
|
-
};
|
|
6818
|
-
|
|
6819
5856
|
// src/pdf.js/src/display/standard_fontdata_factory.js
|
|
6820
5857
|
var BaseStandardFontDataFactory = class {
|
|
6821
5858
|
constructor({ baseUrl = null }) {
|
|
@@ -6902,75 +5939,31 @@ var DOMWasmFactory = class extends BaseWasmFactory {
|
|
|
6902
5939
|
}
|
|
6903
5940
|
};
|
|
6904
5941
|
|
|
6905
|
-
// src/
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
throw new Error(
|
|
6909
|
-
'Module "./node_utils.js" shall not be used with MOZCENTRAL builds.'
|
|
6910
|
-
);
|
|
5942
|
+
// src/lib/NodeUtils.ts
|
|
5943
|
+
if (!globalThis.DOMMatrix) {
|
|
5944
|
+
globalThis.DOMMatrix = NodeDOMMatrix;
|
|
6911
5945
|
}
|
|
6912
|
-
if (
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
if (!globalThis.DOMMatrix) {
|
|
6928
|
-
if (canvas?.DOMMatrix) {
|
|
6929
|
-
globalThis.DOMMatrix = canvas.DOMMatrix;
|
|
6930
|
-
} else {
|
|
6931
|
-
warn("Cannot polyfill `DOMMatrix`, rendering may be broken.");
|
|
6932
|
-
}
|
|
6933
|
-
}
|
|
6934
|
-
if (!globalThis.ImageData) {
|
|
6935
|
-
if (canvas?.ImageData) {
|
|
6936
|
-
globalThis.ImageData = canvas.ImageData;
|
|
6937
|
-
} else {
|
|
6938
|
-
warn("Cannot polyfill `ImageData`, rendering may be broken.");
|
|
6939
|
-
}
|
|
6940
|
-
}
|
|
6941
|
-
if (!globalThis.Path2D) {
|
|
6942
|
-
if (canvas?.Path2D) {
|
|
6943
|
-
globalThis.Path2D = canvas.Path2D;
|
|
6944
|
-
} else {
|
|
6945
|
-
warn("Cannot polyfill `Path2D`, rendering may be broken.");
|
|
6946
|
-
}
|
|
6947
|
-
}
|
|
6948
|
-
if (!globalThis.navigator?.language) {
|
|
6949
|
-
globalThis.navigator = {
|
|
6950
|
-
language: "en-US",
|
|
6951
|
-
platform: "",
|
|
6952
|
-
userAgent: ""
|
|
6953
|
-
};
|
|
6954
|
-
}
|
|
6955
|
-
}
|
|
5946
|
+
if (!globalThis.DOMPoint) {
|
|
5947
|
+
globalThis.DOMPoint = NodeDOMPoint;
|
|
5948
|
+
}
|
|
5949
|
+
if (!globalThis.ImageData) {
|
|
5950
|
+
globalThis.ImageData = NodeImageData;
|
|
5951
|
+
}
|
|
5952
|
+
if (!globalThis.Path2D) {
|
|
5953
|
+
globalThis.Path2D = NodePath2D;
|
|
5954
|
+
}
|
|
5955
|
+
if (!globalThis.navigator?.language) {
|
|
5956
|
+
globalThis.navigator = {
|
|
5957
|
+
language: "en-US",
|
|
5958
|
+
platform: "",
|
|
5959
|
+
userAgent: ""
|
|
5960
|
+
};
|
|
6956
5961
|
}
|
|
6957
5962
|
async function fetchData2(url) {
|
|
6958
|
-
const
|
|
6959
|
-
const data = await
|
|
5963
|
+
const { readFile } = await import("node:fs/promises");
|
|
5964
|
+
const data = await readFile(url);
|
|
6960
5965
|
return new Uint8Array(data);
|
|
6961
5966
|
}
|
|
6962
|
-
var NodeFilterFactory = class extends BaseFilterFactory {
|
|
6963
|
-
};
|
|
6964
|
-
var NodeCanvasFactory = class extends BaseCanvasFactory {
|
|
6965
|
-
/**
|
|
6966
|
-
* @ignore
|
|
6967
|
-
*/
|
|
6968
|
-
_createCanvas(width, height) {
|
|
6969
|
-
const require3 = __require__("module").createRequire(import.meta.url);
|
|
6970
|
-
const canvas = require3("@napi-rs/canvas");
|
|
6971
|
-
return canvas.createCanvas(width, height);
|
|
6972
|
-
}
|
|
6973
|
-
};
|
|
6974
5967
|
var NodeCMapReaderFactory = class extends BaseCMapReaderFactory {
|
|
6975
5968
|
/**
|
|
6976
5969
|
* @ignore
|
|
@@ -6996,370 +5989,6 @@ var NodeWasmFactory = class extends BaseWasmFactory {
|
|
|
6996
5989
|
}
|
|
6997
5990
|
};
|
|
6998
5991
|
|
|
6999
|
-
// src/lib/utils.ts
|
|
7000
|
-
async function canvasToData(canvas) {
|
|
7001
|
-
if ("toBlob" in canvas) {
|
|
7002
|
-
const blob = await new Promise(
|
|
7003
|
-
(resolve) => canvas.toBlob((data) => resolve(data))
|
|
7004
|
-
);
|
|
7005
|
-
if (!blob) {
|
|
7006
|
-
throw new Error("Failed to generate graphics");
|
|
7007
|
-
}
|
|
7008
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
7009
|
-
}
|
|
7010
|
-
const buffer = await canvas.encode("png");
|
|
7011
|
-
return new Uint8Array(buffer);
|
|
7012
|
-
}
|
|
7013
|
-
async function toDataUrl(data, type = "image/png") {
|
|
7014
|
-
if (typeof FileReader !== "undefined") {
|
|
7015
|
-
return new Promise((resolve) => {
|
|
7016
|
-
const reader = new FileReader();
|
|
7017
|
-
reader.onload = () => {
|
|
7018
|
-
resolve(reader.result);
|
|
7019
|
-
};
|
|
7020
|
-
reader.readAsDataURL(new Blob([data], { type }));
|
|
7021
|
-
});
|
|
7022
|
-
}
|
|
7023
|
-
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
7024
|
-
}
|
|
7025
|
-
function makeSerializable(object) {
|
|
7026
|
-
if (typeof object !== "object" || object === null) {
|
|
7027
|
-
return object;
|
|
7028
|
-
}
|
|
7029
|
-
if (object instanceof Int8Array || object instanceof Uint8Array || object instanceof Uint8ClampedArray || object instanceof Int16Array || object instanceof Uint16Array || object instanceof Int32Array || object instanceof Uint32Array || object instanceof Float32Array || object instanceof Float64Array) {
|
|
7030
|
-
return makeSerializable(Array.from(object));
|
|
7031
|
-
}
|
|
7032
|
-
if (object instanceof BigInt64Array || object instanceof BigUint64Array) {
|
|
7033
|
-
return makeSerializable(Array.from(object));
|
|
7034
|
-
}
|
|
7035
|
-
if (Array.isArray(object)) {
|
|
7036
|
-
return object.map(makeSerializable);
|
|
7037
|
-
}
|
|
7038
|
-
return Object.fromEntries(
|
|
7039
|
-
Object.entries(object).map(([key, value]) => [
|
|
7040
|
-
key,
|
|
7041
|
-
makeSerializable(value)
|
|
7042
|
-
])
|
|
7043
|
-
);
|
|
7044
|
-
}
|
|
7045
|
-
function colorToRgb(color) {
|
|
7046
|
-
if (color.startsWith("#")) {
|
|
7047
|
-
const hex = color.slice(1);
|
|
7048
|
-
if (hex.length === 3) {
|
|
7049
|
-
return [
|
|
7050
|
-
Number.parseInt(hex[0] + hex[0], 16),
|
|
7051
|
-
Number.parseInt(hex[1] + hex[1], 16),
|
|
7052
|
-
Number.parseInt(hex[2] + hex[2], 16)
|
|
7053
|
-
];
|
|
7054
|
-
}
|
|
7055
|
-
if (hex.length === 6) {
|
|
7056
|
-
return [
|
|
7057
|
-
Number.parseInt(hex.slice(0, 2), 16),
|
|
7058
|
-
Number.parseInt(hex.slice(2, 4), 16),
|
|
7059
|
-
Number.parseInt(hex.slice(4, 6), 16)
|
|
7060
|
-
];
|
|
7061
|
-
}
|
|
7062
|
-
}
|
|
7063
|
-
throw new Error(`Invalid color format: ${color}`);
|
|
7064
|
-
}
|
|
7065
|
-
function rgbToHex(r, g, b) {
|
|
7066
|
-
const toHex = (value) => value.toString(16).padStart(2, "0");
|
|
7067
|
-
if (Array.isArray(r)) {
|
|
7068
|
-
return `#${toHex(r[0])}${toHex(r[1])}${toHex(r[2])}`;
|
|
7069
|
-
}
|
|
7070
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
7071
|
-
}
|
|
7072
|
-
|
|
7073
|
-
// src/lib/NodeFilterFactory.ts
|
|
7074
|
-
var filtersRegistry = /* @__PURE__ */ new Map();
|
|
7075
|
-
function createTables(maps) {
|
|
7076
|
-
if (maps.length === 1) {
|
|
7077
|
-
const mapR2 = maps[0];
|
|
7078
|
-
const buffer = new Array(256);
|
|
7079
|
-
for (let i = 0; i < 256; i++) {
|
|
7080
|
-
buffer[i] = mapR2[i] / 255;
|
|
7081
|
-
}
|
|
7082
|
-
return [buffer, buffer, buffer];
|
|
7083
|
-
}
|
|
7084
|
-
const [mapR, mapG, mapB] = maps;
|
|
7085
|
-
const bufferR = new Array(256);
|
|
7086
|
-
const bufferG = new Array(256);
|
|
7087
|
-
const bufferB = new Array(256);
|
|
7088
|
-
for (let i = 0; i < 256; i++) {
|
|
7089
|
-
bufferR[i] = mapR[i] / 255;
|
|
7090
|
-
bufferG[i] = mapG[i] / 255;
|
|
7091
|
-
bufferB[i] = mapB[i] / 255;
|
|
7092
|
-
}
|
|
7093
|
-
return [bufferR, bufferG, bufferB];
|
|
7094
|
-
}
|
|
7095
|
-
function createTransferMapAlphaConversion(aTable) {
|
|
7096
|
-
return (ctx) => {
|
|
7097
|
-
const imageData = ctx.getImageData(
|
|
7098
|
-
0,
|
|
7099
|
-
0,
|
|
7100
|
-
ctx.canvas.width,
|
|
7101
|
-
ctx.canvas.height
|
|
7102
|
-
);
|
|
7103
|
-
const data = imageData.data;
|
|
7104
|
-
const tableSize = aTable.length;
|
|
7105
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
7106
|
-
const alpha = data[i + 3] / 255;
|
|
7107
|
-
const index = alpha * (tableSize - 1);
|
|
7108
|
-
const lower = Math.floor(index);
|
|
7109
|
-
const upper = Math.min(lower + 1, tableSize - 1);
|
|
7110
|
-
const t = index - lower;
|
|
7111
|
-
const newAlpha = (1 - t) * aTable[lower] + t * aTable[upper];
|
|
7112
|
-
data[i + 3] = newAlpha * 255;
|
|
7113
|
-
}
|
|
7114
|
-
ctx.putImageData(imageData, 0, 0);
|
|
7115
|
-
};
|
|
7116
|
-
}
|
|
7117
|
-
function createTransferMapConversion(rTable, gTable, bTable) {
|
|
7118
|
-
return (ctx) => {
|
|
7119
|
-
const imageData = ctx.getImageData(
|
|
7120
|
-
0,
|
|
7121
|
-
0,
|
|
7122
|
-
ctx.canvas.width,
|
|
7123
|
-
ctx.canvas.height
|
|
7124
|
-
);
|
|
7125
|
-
const data = imageData.data;
|
|
7126
|
-
const rSize = rTable.length;
|
|
7127
|
-
const gSize = gTable.length;
|
|
7128
|
-
const bSize = bTable.length;
|
|
7129
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
7130
|
-
const r = data[i] / 255;
|
|
7131
|
-
const g = data[i + 1] / 255;
|
|
7132
|
-
const b = data[i + 2] / 255;
|
|
7133
|
-
const rIndex = r * (rSize - 1);
|
|
7134
|
-
const rLower = Math.floor(rIndex);
|
|
7135
|
-
const rUpper = Math.min(rLower + 1, rSize - 1);
|
|
7136
|
-
const rT = rIndex - rLower;
|
|
7137
|
-
const newR = (1 - rT) * rTable[rLower] + rT * rTable[rUpper];
|
|
7138
|
-
const gIndex = g * (gSize - 1);
|
|
7139
|
-
const gLower = Math.floor(gIndex);
|
|
7140
|
-
const gUpper = Math.min(gLower + 1, gSize - 1);
|
|
7141
|
-
const gT = gIndex - gLower;
|
|
7142
|
-
const newG = (1 - gT) * gTable[gLower] + gT * gTable[gUpper];
|
|
7143
|
-
const bIndex = b * (bSize - 1);
|
|
7144
|
-
const bLower = Math.floor(bIndex);
|
|
7145
|
-
const bUpper = Math.min(bLower + 1, bSize - 1);
|
|
7146
|
-
const bT = bIndex - bLower;
|
|
7147
|
-
const newB = (1 - bT) * bTable[bLower] + bT * bTable[bUpper];
|
|
7148
|
-
data[i] = newR * 255;
|
|
7149
|
-
data[i + 1] = newG * 255;
|
|
7150
|
-
data[i + 2] = newB * 255;
|
|
7151
|
-
}
|
|
7152
|
-
ctx.putImageData(imageData, 0, 0);
|
|
7153
|
-
};
|
|
7154
|
-
}
|
|
7155
|
-
function createLuminosityConversion() {
|
|
7156
|
-
return (ctx) => {
|
|
7157
|
-
const imageData = ctx.getImageData(
|
|
7158
|
-
0,
|
|
7159
|
-
0,
|
|
7160
|
-
ctx.canvas.width,
|
|
7161
|
-
ctx.canvas.height
|
|
7162
|
-
);
|
|
7163
|
-
const data = imageData.data;
|
|
7164
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
7165
|
-
const r = data[i];
|
|
7166
|
-
const g = data[i + 1];
|
|
7167
|
-
const b = data[i + 2];
|
|
7168
|
-
data[i] = data[i + 1] = data[i + 2] = 0;
|
|
7169
|
-
data[i + 3] = r * 0.3 + g * 0.59 + b * 0.11;
|
|
7170
|
-
}
|
|
7171
|
-
ctx.putImageData(imageData, 0, 0);
|
|
7172
|
-
};
|
|
7173
|
-
}
|
|
7174
|
-
function createGrayConversion() {
|
|
7175
|
-
return (ctx) => {
|
|
7176
|
-
const imageData = ctx.getImageData(
|
|
7177
|
-
0,
|
|
7178
|
-
0,
|
|
7179
|
-
ctx.canvas.width,
|
|
7180
|
-
ctx.canvas.height
|
|
7181
|
-
);
|
|
7182
|
-
const data = imageData.data;
|
|
7183
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
7184
|
-
const r = data[i];
|
|
7185
|
-
const g = data[i + 1];
|
|
7186
|
-
const b = data[i + 2];
|
|
7187
|
-
const gray = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
7188
|
-
data[i] = data[i + 1] = data[i + 2] = gray;
|
|
7189
|
-
}
|
|
7190
|
-
ctx.putImageData(imageData, 0, 0);
|
|
7191
|
-
};
|
|
7192
|
-
}
|
|
7193
|
-
var NodeFilterFactory2 = class extends NodeFilterFactory {
|
|
7194
|
-
addFilter(maps) {
|
|
7195
|
-
if (!maps) {
|
|
7196
|
-
return "none";
|
|
7197
|
-
}
|
|
7198
|
-
const [rTable, gTable, bTable] = createTables(maps);
|
|
7199
|
-
const url = `url(#filter_${maps.length === 1 ? rTable.join("_") : `${rTable.join("_")}_${gTable.join("_")}_${bTable.join("_")}`})`;
|
|
7200
|
-
if (!filtersRegistry.has(url)) {
|
|
7201
|
-
filtersRegistry.set(
|
|
7202
|
-
url,
|
|
7203
|
-
createTransferMapConversion(rTable, gTable, bTable)
|
|
7204
|
-
);
|
|
7205
|
-
}
|
|
7206
|
-
return url;
|
|
7207
|
-
}
|
|
7208
|
-
addHCMFilter(fgColor, bgColor) {
|
|
7209
|
-
const fgRGB = colorToRgb(fgColor);
|
|
7210
|
-
const bgRGB = colorToRgb(bgColor);
|
|
7211
|
-
const url = `url(#hcm_${rgbToHex(fgRGB)}_${rgbToHex(bgRGB)})`;
|
|
7212
|
-
if (!filtersRegistry.has(url)) {
|
|
7213
|
-
const table = new Array(256);
|
|
7214
|
-
for (let i = 0; i <= 255; i++) {
|
|
7215
|
-
const x = i / 255;
|
|
7216
|
-
table[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
7217
|
-
}
|
|
7218
|
-
const transferMapFilter = createTransferMapConversion(
|
|
7219
|
-
table,
|
|
7220
|
-
table,
|
|
7221
|
-
table
|
|
7222
|
-
);
|
|
7223
|
-
const grayFilter = createGrayConversion();
|
|
7224
|
-
const getSteps = (c, n) => {
|
|
7225
|
-
const start = fgRGB[c] / 255;
|
|
7226
|
-
const end = bgRGB[c] / 255;
|
|
7227
|
-
const arr = new Array(n + 1);
|
|
7228
|
-
for (let i = 0; i <= n; i++) {
|
|
7229
|
-
arr[i] = start + i / n * (end - start);
|
|
7230
|
-
}
|
|
7231
|
-
return arr;
|
|
7232
|
-
};
|
|
7233
|
-
const finalTransferMap = createTransferMapConversion(
|
|
7234
|
-
getSteps(0, 5),
|
|
7235
|
-
getSteps(1, 5),
|
|
7236
|
-
getSteps(2, 5)
|
|
7237
|
-
);
|
|
7238
|
-
filtersRegistry.set(url, (ctx) => {
|
|
7239
|
-
transferMapFilter(ctx);
|
|
7240
|
-
grayFilter(ctx);
|
|
7241
|
-
finalTransferMap(ctx);
|
|
7242
|
-
});
|
|
7243
|
-
}
|
|
7244
|
-
return url;
|
|
7245
|
-
}
|
|
7246
|
-
addAlphaFilter(map) {
|
|
7247
|
-
const [tableA] = createTables([map]);
|
|
7248
|
-
const url = `url(#alpha_${tableA.join("_")})`;
|
|
7249
|
-
if (!filtersRegistry.has(url)) {
|
|
7250
|
-
filtersRegistry.set(url, createTransferMapAlphaConversion(map));
|
|
7251
|
-
}
|
|
7252
|
-
return url;
|
|
7253
|
-
}
|
|
7254
|
-
addLuminosityFilter(map) {
|
|
7255
|
-
const url = `url(#luminosity${map ? `_${map.join("_")}` : ""})`;
|
|
7256
|
-
if (!filtersRegistry.has(url)) {
|
|
7257
|
-
const tables = map ? createTables([map]) : null;
|
|
7258
|
-
const alphaFilter = tables ? createTransferMapAlphaConversion(tables[0]) : null;
|
|
7259
|
-
const luminosityFilter = createLuminosityConversion();
|
|
7260
|
-
filtersRegistry.set(url, (ctx) => {
|
|
7261
|
-
luminosityFilter(ctx);
|
|
7262
|
-
alphaFilter?.(ctx);
|
|
7263
|
-
});
|
|
7264
|
-
}
|
|
7265
|
-
return url;
|
|
7266
|
-
}
|
|
7267
|
-
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
|
|
7268
|
-
const fgRGB = colorToRgb(fgColor);
|
|
7269
|
-
const bgRGB = colorToRgb(bgColor);
|
|
7270
|
-
let newFgRGB = colorToRgb(newFgColor);
|
|
7271
|
-
let newBgRGB = colorToRgb(newBgColor);
|
|
7272
|
-
const url = `url(#highlight_hcm_${filterName}_${rgbToHex(fgRGB)}_${rgbToHex(bgRGB)}_${rgbToHex(newFgRGB)}_${rgbToHex(newBgRGB)})`;
|
|
7273
|
-
if (!filtersRegistry.has(url)) {
|
|
7274
|
-
let fgGray = Math.round(
|
|
7275
|
-
0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]
|
|
7276
|
-
);
|
|
7277
|
-
let bgGray = Math.round(
|
|
7278
|
-
0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]
|
|
7279
|
-
);
|
|
7280
|
-
if (bgGray < fgGray) {
|
|
7281
|
-
[fgGray, bgGray, newFgRGB, newBgRGB] = [
|
|
7282
|
-
bgGray,
|
|
7283
|
-
fgGray,
|
|
7284
|
-
newBgRGB,
|
|
7285
|
-
newFgRGB
|
|
7286
|
-
];
|
|
7287
|
-
}
|
|
7288
|
-
const grayFilter = createGrayConversion();
|
|
7289
|
-
const getSteps = (fg, bg, n) => {
|
|
7290
|
-
const arr = new Array(256);
|
|
7291
|
-
const step = (bgGray - fgGray) / n;
|
|
7292
|
-
const newStart = fg / 255;
|
|
7293
|
-
const newStep = (bg - fg) / (255 * n);
|
|
7294
|
-
let prev = 0;
|
|
7295
|
-
for (let i = 0; i <= n; i++) {
|
|
7296
|
-
const k = Math.round(fgGray + i * step);
|
|
7297
|
-
const value = newStart + i * newStep;
|
|
7298
|
-
for (let j = prev; j <= k; j++) {
|
|
7299
|
-
arr[j] = value;
|
|
7300
|
-
}
|
|
7301
|
-
prev = k + 1;
|
|
7302
|
-
}
|
|
7303
|
-
for (let i = prev; i < 256; i++) {
|
|
7304
|
-
arr[i] = arr[prev - 1];
|
|
7305
|
-
}
|
|
7306
|
-
return arr;
|
|
7307
|
-
};
|
|
7308
|
-
const transferMapFilter = createTransferMapConversion(
|
|
7309
|
-
getSteps(newFgRGB[0], newBgRGB[0], 5),
|
|
7310
|
-
getSteps(newFgRGB[1], newBgRGB[1], 5),
|
|
7311
|
-
getSteps(newFgRGB[2], newBgRGB[2], 5)
|
|
7312
|
-
);
|
|
7313
|
-
filtersRegistry.set(url, (ctx) => {
|
|
7314
|
-
grayFilter(ctx);
|
|
7315
|
-
transferMapFilter(ctx);
|
|
7316
|
-
});
|
|
7317
|
-
}
|
|
7318
|
-
return url;
|
|
7319
|
-
}
|
|
7320
|
-
};
|
|
7321
|
-
|
|
7322
|
-
// src/lib/NodeCanvasFactory.ts
|
|
7323
|
-
var NodeCanvasFactory2 = class extends NodeCanvasFactory {
|
|
7324
|
-
create(width, height) {
|
|
7325
|
-
const factory = this;
|
|
7326
|
-
const { canvas, context } = super.create(width, height);
|
|
7327
|
-
const drawImage = context.drawImage;
|
|
7328
|
-
let currentFilter = "none";
|
|
7329
|
-
Object.defineProperty(context, "filter", {
|
|
7330
|
-
get() {
|
|
7331
|
-
if (currentFilter.startsWith("url(")) {
|
|
7332
|
-
return "none";
|
|
7333
|
-
}
|
|
7334
|
-
return currentFilter;
|
|
7335
|
-
},
|
|
7336
|
-
set(value) {
|
|
7337
|
-
currentFilter = value;
|
|
7338
|
-
},
|
|
7339
|
-
configurable: true
|
|
7340
|
-
});
|
|
7341
|
-
context.drawImage = function(src, ...args) {
|
|
7342
|
-
const filter = filtersRegistry.get(currentFilter);
|
|
7343
|
-
if (!filter) {
|
|
7344
|
-
drawImage.call(this, src, ...args);
|
|
7345
|
-
return;
|
|
7346
|
-
}
|
|
7347
|
-
const { canvas: canvas2, context: context2 } = factory.create(src.width, src.height);
|
|
7348
|
-
context2.drawImage(src, 0, 0, src.width, src.height);
|
|
7349
|
-
filter(context2);
|
|
7350
|
-
drawImage.call(this, canvas2, ...args);
|
|
7351
|
-
factory.destroy({
|
|
7352
|
-
canvas: canvas2,
|
|
7353
|
-
context: context2
|
|
7354
|
-
});
|
|
7355
|
-
};
|
|
7356
|
-
return {
|
|
7357
|
-
canvas,
|
|
7358
|
-
context
|
|
7359
|
-
};
|
|
7360
|
-
}
|
|
7361
|
-
};
|
|
7362
|
-
|
|
7363
5992
|
// src/pdf.js/src/display/pattern_helper.js
|
|
7364
5993
|
var PathType = {
|
|
7365
5994
|
FILL: "Fill",
|
|
@@ -11632,8 +10261,8 @@ var PDFNetworkStreamRangeRequestReader = class {
|
|
|
11632
10261
|
};
|
|
11633
10262
|
|
|
11634
10263
|
// src/pdf.js/src/display/node_stream.js
|
|
11635
|
-
import { createRequire as
|
|
11636
|
-
var
|
|
10264
|
+
import { createRequire as __createRequire__ } from "module";
|
|
10265
|
+
var __require__ = __createRequire__(import.meta.url);
|
|
11637
10266
|
if (false) {
|
|
11638
10267
|
throw new Error(
|
|
11639
10268
|
'Module "./node_stream.js" shall not be used with MOZCENTRAL builds.'
|
|
@@ -11644,7 +10273,7 @@ function parseUrlOrPath(sourceUrl) {
|
|
|
11644
10273
|
if (urlRegex.test(sourceUrl)) {
|
|
11645
10274
|
return new URL(sourceUrl);
|
|
11646
10275
|
}
|
|
11647
|
-
const url =
|
|
10276
|
+
const url = __require__("url");
|
|
11648
10277
|
return new URL(url.pathToFileURL(sourceUrl));
|
|
11649
10278
|
}
|
|
11650
10279
|
var PDFNodeStream = class {
|
|
@@ -11704,7 +10333,7 @@ var PDFNodeStreamFsFullReader = class {
|
|
|
11704
10333
|
this._readableStream = null;
|
|
11705
10334
|
this._readCapability = Promise.withResolvers();
|
|
11706
10335
|
this._headersCapability = Promise.withResolvers();
|
|
11707
|
-
const fs =
|
|
10336
|
+
const fs = __require__("fs");
|
|
11708
10337
|
fs.promises.lstat(this._url).then(
|
|
11709
10338
|
(stat) => {
|
|
11710
10339
|
this._contentLength = stat.size;
|
|
@@ -11803,7 +10432,7 @@ var PDFNodeStreamFsRangeReader = class {
|
|
|
11803
10432
|
this._readCapability = Promise.withResolvers();
|
|
11804
10433
|
const source = stream.source;
|
|
11805
10434
|
this._isStreamingSupported = !source.disableStream;
|
|
11806
|
-
const fs =
|
|
10435
|
+
const fs = __require__("fs");
|
|
11807
10436
|
this._setReadableStream(
|
|
11808
10437
|
fs.createReadStream(this._url, { start, end: end - 1 })
|
|
11809
10438
|
);
|
|
@@ -12479,8 +11108,8 @@ function getDocument(src = {}) {
|
|
|
12479
11108
|
const disableStream = src.disableStream === true;
|
|
12480
11109
|
const disableAutoFetch = src.disableAutoFetch === true;
|
|
12481
11110
|
const pdfBug = src.pdfBug === true;
|
|
12482
|
-
const CanvasFactory = src.CanvasFactory || (isNodeJS ?
|
|
12483
|
-
const FilterFactory = src.FilterFactory || (isNodeJS ?
|
|
11111
|
+
const CanvasFactory = src.CanvasFactory || (isNodeJS ? NodeCanvasFactory : DOMCanvasFactory);
|
|
11112
|
+
const FilterFactory = src.FilterFactory || (isNodeJS ? NodeFilterFactory : DOMFilterFactory);
|
|
12484
11113
|
const enableHWA = src.enableHWA === true;
|
|
12485
11114
|
const useWasm = src.useWasm !== false;
|
|
12486
11115
|
const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
|
|
@@ -12596,7 +11225,7 @@ function getDocument(src = {}) {
|
|
|
12596
11225
|
}).catch(task._capability.reject);
|
|
12597
11226
|
return task;
|
|
12598
11227
|
}
|
|
12599
|
-
var
|
|
11228
|
+
var _docId;
|
|
12600
11229
|
var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
12601
11230
|
constructor() {
|
|
12602
11231
|
/**
|
|
@@ -12615,7 +11244,7 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
12615
11244
|
* Unique identifier for the document loading task.
|
|
12616
11245
|
* @type {string}
|
|
12617
11246
|
*/
|
|
12618
|
-
__publicField(this, "docId", `d${__privateWrapper(_PDFDocumentLoadingTask,
|
|
11247
|
+
__publicField(this, "docId", `d${__privateWrapper(_PDFDocumentLoadingTask, _docId)._++}`);
|
|
12619
11248
|
/**
|
|
12620
11249
|
* Whether the loading task is destroyed or not.
|
|
12621
11250
|
* @type {boolean}
|
|
@@ -12675,8 +11304,8 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
12675
11304
|
return this._transport.getData();
|
|
12676
11305
|
}
|
|
12677
11306
|
};
|
|
12678
|
-
|
|
12679
|
-
__privateAdd(_PDFDocumentLoadingTask,
|
|
11307
|
+
_docId = new WeakMap();
|
|
11308
|
+
__privateAdd(_PDFDocumentLoadingTask, _docId, 0);
|
|
12680
11309
|
var PDFDocumentLoadingTask = _PDFDocumentLoadingTask;
|
|
12681
11310
|
var _capability2, _progressiveDoneListeners, _progressiveReadListeners, _progressListeners, _rangeListeners;
|
|
12682
11311
|
var PDFDataRangeTransport = class {
|
|
@@ -19704,7 +18333,7 @@ __privateAdd(_ColorPicker, _l10nColor, null);
|
|
|
19704
18333
|
var ColorPicker = _ColorPicker;
|
|
19705
18334
|
|
|
19706
18335
|
// src/pdf.js/src/display/editor/highlight.js
|
|
19707
|
-
var _anchorNode, _anchorOffset, _boxes, _clipPathId, _colorPicker2, _focusOutlines, _focusNode, _focusOffset, _highlightDiv, _highlightOutlines,
|
|
18336
|
+
var _anchorNode, _anchorOffset, _boxes, _clipPathId, _colorPicker2, _focusOutlines, _focusNode, _focusOffset, _highlightDiv, _highlightOutlines, _id3, _isFreeHighlight, _lastPoint2, _opacity, _outlineId, _text, _thickness2, _methodOfCreation, _HighlightEditor_instances, createOutlines_fn, createFreeOutlines_fn, updateColor_fn2, updateThickness_fn, changeThickness_fn, cleanDrawLayer_fn, addToDrawLayer_fn, _HighlightEditor_static, rotateBbox_fn, keydown_fn, setCaret_fn, getRotation_fn, serializeBoxes_fn, serializeOutlines_fn, highlightMove_fn, endHighlight_fn, hasElementChanged_fn2;
|
|
19708
18337
|
var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
19709
18338
|
constructor(params) {
|
|
19710
18339
|
super({ ...params, name: "highlightEditor" });
|
|
@@ -19719,7 +18348,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19719
18348
|
__privateAdd(this, _focusOffset, 0);
|
|
19720
18349
|
__privateAdd(this, _highlightDiv, null);
|
|
19721
18350
|
__privateAdd(this, _highlightOutlines, null);
|
|
19722
|
-
__privateAdd(this,
|
|
18351
|
+
__privateAdd(this, _id3, null);
|
|
19723
18352
|
__privateAdd(this, _isFreeHighlight, false);
|
|
19724
18353
|
__privateAdd(this, _lastPoint2, null);
|
|
19725
18354
|
__privateAdd(this, _opacity);
|
|
@@ -19933,7 +18562,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19933
18562
|
} else {
|
|
19934
18563
|
box = __privateMethod(_b = _HighlightEditor, _HighlightEditor_static, rotateBbox_fn).call(_b, [this.x, this.y, this.width, this.height], angle);
|
|
19935
18564
|
}
|
|
19936
|
-
drawLayer.updateProperties(__privateGet(this,
|
|
18565
|
+
drawLayer.updateProperties(__privateGet(this, _id3), {
|
|
19937
18566
|
bbox: box,
|
|
19938
18567
|
root: {
|
|
19939
18568
|
"data-main-rotation": angle
|
|
@@ -20053,7 +18682,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
20053
18682
|
show(visible = this._isVisible) {
|
|
20054
18683
|
super.show(visible);
|
|
20055
18684
|
if (this.parent) {
|
|
20056
|
-
this.parent.drawLayer.updateProperties(__privateGet(this,
|
|
18685
|
+
this.parent.drawLayer.updateProperties(__privateGet(this, _id3), {
|
|
20057
18686
|
rootClass: {
|
|
20058
18687
|
hidden: !visible
|
|
20059
18688
|
}
|
|
@@ -20304,7 +18933,7 @@ _focusNode = new WeakMap();
|
|
|
20304
18933
|
_focusOffset = new WeakMap();
|
|
20305
18934
|
_highlightDiv = new WeakMap();
|
|
20306
18935
|
_highlightOutlines = new WeakMap();
|
|
20307
|
-
|
|
18936
|
+
_id3 = new WeakMap();
|
|
20308
18937
|
_isFreeHighlight = new WeakMap();
|
|
20309
18938
|
_lastPoint2 = new WeakMap();
|
|
20310
18939
|
_opacity = new WeakMap();
|
|
@@ -20348,7 +18977,7 @@ createFreeOutlines_fn = function({ highlightOutlines, highlightId, clipPathId })
|
|
|
20348
18977
|
25e-4
|
|
20349
18978
|
));
|
|
20350
18979
|
if (highlightId >= 0) {
|
|
20351
|
-
__privateSet(this,
|
|
18980
|
+
__privateSet(this, _id3, highlightId);
|
|
20352
18981
|
__privateSet(this, _clipPathId, clipPathId);
|
|
20353
18982
|
this.parent.drawLayer.finalizeDraw(highlightId, {
|
|
20354
18983
|
bbox: highlightOutlines.box,
|
|
@@ -20372,7 +19001,7 @@ createFreeOutlines_fn = function({ highlightOutlines, highlightId, clipPathId })
|
|
|
20372
19001
|
));
|
|
20373
19002
|
} else if (this.parent) {
|
|
20374
19003
|
const angle = this.parent.viewport.rotation;
|
|
20375
|
-
this.parent.drawLayer.updateProperties(__privateGet(this,
|
|
19004
|
+
this.parent.drawLayer.updateProperties(__privateGet(this, _id3), {
|
|
20376
19005
|
bbox: __privateMethod(_a2 = _HighlightEditor, _HighlightEditor_static, rotateBbox_fn).call(_a2, __privateGet(this, _highlightOutlines).box, (angle - this.rotation + 360) % 360),
|
|
20377
19006
|
path: {
|
|
20378
19007
|
d: highlightOutlines.toSVGPath()
|
|
@@ -20427,7 +19056,7 @@ updateColor_fn2 = function(color) {
|
|
|
20427
19056
|
const setColorAndOpacity = (col, opa) => {
|
|
20428
19057
|
this.color = col;
|
|
20429
19058
|
__privateSet(this, _opacity, opa);
|
|
20430
|
-
this.parent?.drawLayer.updateProperties(__privateGet(this,
|
|
19059
|
+
this.parent?.drawLayer.updateProperties(__privateGet(this, _id3), {
|
|
20431
19060
|
root: {
|
|
20432
19061
|
fill: col,
|
|
20433
19062
|
"fill-opacity": opa
|
|
@@ -20496,19 +19125,19 @@ changeThickness_fn = function(thickness) {
|
|
|
20496
19125
|
this.setDims(this.width * parentWidth, this.height * parentHeight);
|
|
20497
19126
|
};
|
|
20498
19127
|
cleanDrawLayer_fn = function() {
|
|
20499
|
-
if (__privateGet(this,
|
|
19128
|
+
if (__privateGet(this, _id3) === null || !this.parent) {
|
|
20500
19129
|
return;
|
|
20501
19130
|
}
|
|
20502
|
-
this.parent.drawLayer.remove(__privateGet(this,
|
|
20503
|
-
__privateSet(this,
|
|
19131
|
+
this.parent.drawLayer.remove(__privateGet(this, _id3));
|
|
19132
|
+
__privateSet(this, _id3, null);
|
|
20504
19133
|
this.parent.drawLayer.remove(__privateGet(this, _outlineId));
|
|
20505
19134
|
__privateSet(this, _outlineId, null);
|
|
20506
19135
|
};
|
|
20507
19136
|
addToDrawLayer_fn = function(parent = this.parent) {
|
|
20508
|
-
if (__privateGet(this,
|
|
19137
|
+
if (__privateGet(this, _id3) !== null) {
|
|
20509
19138
|
return;
|
|
20510
19139
|
}
|
|
20511
|
-
({ id: __privateWrapper(this,
|
|
19140
|
+
({ id: __privateWrapper(this, _id3)._, clipPathId: __privateWrapper(this, _clipPathId)._ } = parent.drawLayer.draw(
|
|
20512
19141
|
{
|
|
20513
19142
|
bbox: __privateGet(this, _highlightOutlines).box,
|
|
20514
19143
|
root: {
|
|
@@ -25029,7 +23658,7 @@ __privateAdd(_AnnotationEditorLayer, _editorTypes2, new Map(
|
|
|
25029
23658
|
var AnnotationEditorLayer = _AnnotationEditorLayer;
|
|
25030
23659
|
|
|
25031
23660
|
// src/pdf.js/src/display/draw_layer.js
|
|
25032
|
-
var _parent2, _mapping, _toUpdate,
|
|
23661
|
+
var _parent2, _mapping, _toUpdate, _id4, _DrawLayer_static, setBox_fn, _DrawLayer_instances, createSVG_fn, createClipPath_fn, updateProperties_fn;
|
|
25033
23662
|
var _DrawLayer = class _DrawLayer {
|
|
25034
23663
|
constructor({ pageIndex }) {
|
|
25035
23664
|
__privateAdd(this, _DrawLayer_instances);
|
|
@@ -25057,7 +23686,7 @@ var _DrawLayer = class _DrawLayer {
|
|
|
25057
23686
|
return shadow(this, "_svgFactory", new DOMSVGFactory());
|
|
25058
23687
|
}
|
|
25059
23688
|
draw(properties, isPathUpdatable = false, hasClip = false) {
|
|
25060
|
-
const id = __privateWrapper(_DrawLayer,
|
|
23689
|
+
const id = __privateWrapper(_DrawLayer, _id4)._++;
|
|
25061
23690
|
const root = __privateMethod(this, _DrawLayer_instances, createSVG_fn).call(this);
|
|
25062
23691
|
const defs = _DrawLayer._svgFactory.createElement("defs");
|
|
25063
23692
|
root.append(defs);
|
|
@@ -25078,7 +23707,7 @@ var _DrawLayer = class _DrawLayer {
|
|
|
25078
23707
|
return { id, clipPathId: `url(#${clipPathId})` };
|
|
25079
23708
|
}
|
|
25080
23709
|
drawOutline(properties, mustRemoveSelfIntersections) {
|
|
25081
|
-
const id = __privateWrapper(_DrawLayer,
|
|
23710
|
+
const id = __privateWrapper(_DrawLayer, _id4)._++;
|
|
25082
23711
|
const root = __privateMethod(this, _DrawLayer_instances, createSVG_fn).call(this);
|
|
25083
23712
|
const defs = _DrawLayer._svgFactory.createElement("defs");
|
|
25084
23713
|
root.append(defs);
|
|
@@ -25185,7 +23814,7 @@ var _DrawLayer = class _DrawLayer {
|
|
|
25185
23814
|
_parent2 = new WeakMap();
|
|
25186
23815
|
_mapping = new WeakMap();
|
|
25187
23816
|
_toUpdate = new WeakMap();
|
|
25188
|
-
|
|
23817
|
+
_id4 = new WeakMap();
|
|
25189
23818
|
_DrawLayer_static = new WeakSet();
|
|
25190
23819
|
setBox_fn = function(element, [x, y, width, height]) {
|
|
25191
23820
|
const { style } = element;
|
|
@@ -25228,7 +23857,7 @@ updateProperties_fn = function(element, properties) {
|
|
|
25228
23857
|
}
|
|
25229
23858
|
};
|
|
25230
23859
|
__privateAdd(_DrawLayer, _DrawLayer_static);
|
|
25231
|
-
__privateAdd(_DrawLayer,
|
|
23860
|
+
__privateAdd(_DrawLayer, _id4, 0);
|
|
25232
23861
|
var DrawLayer = _DrawLayer;
|
|
25233
23862
|
|
|
25234
23863
|
// src/pdf.js/src/pdf.js
|
|
@@ -26301,6 +24930,10 @@ async function toSvgNode(ctx) {
|
|
|
26301
24930
|
}
|
|
26302
24931
|
|
|
26303
24932
|
// src/lib/PDFPageProxy.ts
|
|
24933
|
+
async function loadNodeCanvasFactory() {
|
|
24934
|
+
const { NodeCanvasFactory: NodeCanvasFactory2 } = await import("./NodeCanvasFactory-N32SOXPQ.js");
|
|
24935
|
+
return new NodeCanvasFactory2({});
|
|
24936
|
+
}
|
|
26304
24937
|
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
26305
24938
|
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
26306
24939
|
const annotations = await getAnnotations.call(this, params);
|
|
@@ -26313,7 +24946,7 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
26313
24946
|
if (opList) {
|
|
26314
24947
|
if (annotation.subtype === "Stamp") {
|
|
26315
24948
|
try {
|
|
26316
|
-
const canvasFactory = isNodeJS ?
|
|
24949
|
+
const canvasFactory = isNodeJS ? await loadNodeCanvasFactory() : new DOMCanvasFactory({});
|
|
26317
24950
|
const scale = 2;
|
|
26318
24951
|
const viewport = this.getViewport({ scale });
|
|
26319
24952
|
const svgContext = await createSvgContext(
|