@chialab/pdfjs-lib 1.0.0-alpha.11 → 1.0.0-alpha.13
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/{chunk-AK2AE3GS.js → chunk-TKDBOXH4.js} +31 -39
- package/dist/browser/index.js +620 -491
- package/dist/browser/openjpeg-K2XBCFFN.js +9 -0
- package/dist/browser/qcms_bg-Q7BRLLZG.js +9 -0
- package/dist/browser/worker.js +1260 -1121
- package/dist/lib/utils.d.ts +8 -0
- package/dist/node/{chunk-WL32POZ2.js → chunk-MAMMG4XK.js} +31 -39
- package/dist/node/index.js +1034 -608
- package/dist/node/openjpeg-B2WN24QZ.js +9 -0
- package/dist/node/qcms_bg-T4RSHPOQ.js +9 -0
- package/dist/node/worker.js +1260 -1121
- package/dist/pdf.js/src/display/annotation_storage.d.ts +1 -8
- package/dist/pdf.js/src/display/api.d.ts +10 -69
- package/dist/pdf.js/src/display/api_utils.d.ts +13 -0
- package/dist/pdf.js/src/display/canvas.d.ts +2 -2
- package/dist/pdf.js/src/display/display_utils.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +4 -4
- package/dist/pdf.js/src/display/editor/editor.d.ts +17 -3
- package/dist/pdf.js/src/display/editor/freetext.d.ts +2 -5
- package/dist/pdf.js/src/display/editor/tools.d.ts +2 -1
- package/dist/pdf.js/src/display/metadata.d.ts +1 -2
- package/dist/pdf.js/src/display/optional_content_config.d.ts +1 -1
- package/dist/pdf.js/src/display/pdf_objects.d.ts +40 -0
- 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/pdf.d.ts +3 -2
- package/dist/pdf.js/src/shared/util.d.ts +12 -5
- package/package.json +1 -1
- package/dist/browser/openjpeg-NLAGCGEG.js +0 -9
- package/dist/browser/qcms_bg-EPYCMBVV.js +0 -9
- package/dist/node/openjpeg-O3KQE6R6.js +0 -9
- package/dist/node/qcms_bg-5Z325MLG.js +0 -9
package/dist/node/index.js
CHANGED
|
@@ -36,16 +36,16 @@ import {
|
|
|
36
36
|
info,
|
|
37
37
|
isNodeJS,
|
|
38
38
|
normalizeUnicode,
|
|
39
|
-
objectFromMap,
|
|
40
39
|
setVerbosityLevel,
|
|
41
40
|
shadow,
|
|
42
41
|
string32,
|
|
43
42
|
stringToBytes,
|
|
44
43
|
toBase64Util,
|
|
45
44
|
unreachable,
|
|
45
|
+
updateUrlHash,
|
|
46
46
|
warn,
|
|
47
47
|
wrapReason
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-MAMMG4XK.js";
|
|
49
49
|
import {
|
|
50
50
|
__privateAdd,
|
|
51
51
|
__privateGet,
|
|
@@ -367,6 +367,9 @@ function stopEvent(e) {
|
|
|
367
367
|
e.preventDefault();
|
|
368
368
|
e.stopPropagation();
|
|
369
369
|
}
|
|
370
|
+
function deprecated(details) {
|
|
371
|
+
console.log("Deprecated API usage: " + details);
|
|
372
|
+
}
|
|
370
373
|
var _regex;
|
|
371
374
|
var PDFDateString = class {
|
|
372
375
|
/**
|
|
@@ -464,6 +467,7 @@ function getRGB(color) {
|
|
|
464
467
|
function getColorValues(colors) {
|
|
465
468
|
const span = document.createElement("span");
|
|
466
469
|
span.style.visibility = "hidden";
|
|
470
|
+
span.style.colorScheme = "only light";
|
|
467
471
|
document.body.append(span);
|
|
468
472
|
for (const name of colors.keys()) {
|
|
469
473
|
span.style.color = name;
|
|
@@ -522,8 +526,9 @@ var OutputScale = class _OutputScale {
|
|
|
522
526
|
* @returns {boolean} Returns `true` if scaling was limited,
|
|
523
527
|
* `false` otherwise.
|
|
524
528
|
*/
|
|
525
|
-
limitCanvas(width, height, maxPixels, maxDim) {
|
|
529
|
+
limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {
|
|
526
530
|
let maxAreaScale = Infinity, maxWidthScale = Infinity, maxHeightScale = Infinity;
|
|
531
|
+
maxPixels = _OutputScale.capPixels(maxPixels, capAreaFactor);
|
|
527
532
|
if (maxPixels > 0) {
|
|
528
533
|
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
|
529
534
|
}
|
|
@@ -542,6 +547,15 @@ var OutputScale = class _OutputScale {
|
|
|
542
547
|
static get pixelRatio() {
|
|
543
548
|
return globalThis.devicePixelRatio || 1;
|
|
544
549
|
}
|
|
550
|
+
static capPixels(maxPixels, capAreaFactor) {
|
|
551
|
+
if (capAreaFactor >= 0) {
|
|
552
|
+
const winPixels = Math.ceil(
|
|
553
|
+
(false ? window.innerWidth * window.innerHeight : window.screen.availWidth * window.screen.availHeight) * this.pixelRatio ** 2 * (1 + capAreaFactor / 100)
|
|
554
|
+
);
|
|
555
|
+
return maxPixels > 0 ? Math.min(maxPixels, winPixels) : winPixels;
|
|
556
|
+
}
|
|
557
|
+
return maxPixels;
|
|
558
|
+
}
|
|
545
559
|
};
|
|
546
560
|
var SupportedImageMimeTypes = [
|
|
547
561
|
"image/apng",
|
|
@@ -1950,6 +1964,7 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1950
1964
|
}
|
|
1951
1965
|
}
|
|
1952
1966
|
__privateSet(this, _updateModeCapability, Promise.withResolvers());
|
|
1967
|
+
__privateGet(this, _currentDrawingSession)?.commitOrRemove();
|
|
1953
1968
|
__privateSet(this, _mode, mode);
|
|
1954
1969
|
if (mode === AnnotationEditorType.NONE) {
|
|
1955
1970
|
this.setEditingState(false);
|
|
@@ -1975,7 +1990,7 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1975
1990
|
return;
|
|
1976
1991
|
}
|
|
1977
1992
|
for (const editor of __privateGet(this, _allEditors).values()) {
|
|
1978
|
-
if (editor.annotationElementId === editId) {
|
|
1993
|
+
if (editor.annotationElementId === editId || editor.id === editId) {
|
|
1979
1994
|
this.setSelected(editor);
|
|
1980
1995
|
editor.enterInEditMode();
|
|
1981
1996
|
} else {
|
|
@@ -1991,16 +2006,17 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1991
2006
|
}
|
|
1992
2007
|
/**
|
|
1993
2008
|
* Update the toolbar if it's required to reflect the tool currently used.
|
|
2009
|
+
* @param {Object} options
|
|
1994
2010
|
* @param {number} mode
|
|
1995
2011
|
* @returns {undefined}
|
|
1996
2012
|
*/
|
|
1997
|
-
updateToolbar(
|
|
1998
|
-
if (mode === __privateGet(this, _mode)) {
|
|
2013
|
+
updateToolbar(options) {
|
|
2014
|
+
if (options.mode === __privateGet(this, _mode)) {
|
|
1999
2015
|
return;
|
|
2000
2016
|
}
|
|
2001
2017
|
this._eventBus.dispatch("switchannotationeditormode", {
|
|
2002
2018
|
source: this,
|
|
2003
|
-
|
|
2019
|
+
...options
|
|
2004
2020
|
});
|
|
2005
2021
|
}
|
|
2006
2022
|
/**
|
|
@@ -3390,9 +3406,11 @@ onTouchEnd_fn = function(evt) {
|
|
|
3390
3406
|
if (evt.touches.length >= 2) {
|
|
3391
3407
|
return;
|
|
3392
3408
|
}
|
|
3393
|
-
__privateGet(this, _touchMoveAC)
|
|
3394
|
-
|
|
3395
|
-
|
|
3409
|
+
if (__privateGet(this, _touchMoveAC)) {
|
|
3410
|
+
__privateGet(this, _touchMoveAC).abort();
|
|
3411
|
+
__privateSet(this, _touchMoveAC, null);
|
|
3412
|
+
(_a2 = __privateGet(this, _onPinchEnd)) == null ? void 0 : _a2.call(this);
|
|
3413
|
+
}
|
|
3396
3414
|
if (!__privateGet(this, _touchInfo)) {
|
|
3397
3415
|
return;
|
|
3398
3416
|
}
|
|
@@ -3432,6 +3450,7 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3432
3450
|
__privateAdd(this, _prevDragY, 0);
|
|
3433
3451
|
__privateAdd(this, _telemetryTimeouts, null);
|
|
3434
3452
|
__privateAdd(this, _touchManager, null);
|
|
3453
|
+
__publicField(this, "isSelected", false);
|
|
3435
3454
|
__publicField(this, "_isCopy", false);
|
|
3436
3455
|
__publicField(this, "_editToolbar", null);
|
|
3437
3456
|
__publicField(this, "_initialOptions", /* @__PURE__ */ Object.create(null));
|
|
@@ -4052,7 +4071,7 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4052
4071
|
}
|
|
4053
4072
|
const [tx, ty] = this.getInitialTranslation();
|
|
4054
4073
|
this.translate(tx, ty);
|
|
4055
|
-
bindEvents(this, div, ["keydown", "pointerdown"]);
|
|
4074
|
+
bindEvents(this, div, ["keydown", "pointerdown", "dblclick"]);
|
|
4056
4075
|
if (this.isResizable && this._uiManager._supportsPinchToZoom) {
|
|
4057
4076
|
__privateGet(this, _touchManager) || __privateSet(this, _touchManager, new TouchManager({
|
|
4058
4077
|
container: div,
|
|
@@ -4083,9 +4102,6 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4083
4102
|
}
|
|
4084
4103
|
__privateMethod(this, _AnnotationEditor_instances, selectOnPointerEvent_fn).call(this, event);
|
|
4085
4104
|
}
|
|
4086
|
-
get isSelected() {
|
|
4087
|
-
return this._uiManager.isSelected(this);
|
|
4088
|
-
}
|
|
4089
4105
|
_onStartDragging() {
|
|
4090
4106
|
}
|
|
4091
4107
|
_onStopDragging() {
|
|
@@ -4192,15 +4208,27 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4192
4208
|
}
|
|
4193
4209
|
/**
|
|
4194
4210
|
* Enable edit mode.
|
|
4211
|
+
* @returns {boolean} - true if the edit mode has been enabled.
|
|
4195
4212
|
*/
|
|
4196
4213
|
enableEditMode() {
|
|
4214
|
+
if (this.isInEditMode()) {
|
|
4215
|
+
return false;
|
|
4216
|
+
}
|
|
4217
|
+
this.parent.setEditingState(false);
|
|
4197
4218
|
__privateSet(this, _isInEditMode, true);
|
|
4219
|
+
return true;
|
|
4198
4220
|
}
|
|
4199
4221
|
/**
|
|
4200
4222
|
* Disable edit mode.
|
|
4223
|
+
* @returns {boolean} - true if the edit mode has been disabled.
|
|
4201
4224
|
*/
|
|
4202
4225
|
disableEditMode() {
|
|
4226
|
+
if (!this.isInEditMode()) {
|
|
4227
|
+
return false;
|
|
4228
|
+
}
|
|
4229
|
+
this.parent.setEditingState(true);
|
|
4203
4230
|
__privateSet(this, _isInEditMode, false);
|
|
4231
|
+
return true;
|
|
4204
4232
|
}
|
|
4205
4233
|
/**
|
|
4206
4234
|
* Check if the editor is edited.
|
|
@@ -4441,6 +4469,10 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4441
4469
|
* Select this editor.
|
|
4442
4470
|
*/
|
|
4443
4471
|
select() {
|
|
4472
|
+
if (this.isSelected && this._editToolbar) {
|
|
4473
|
+
return;
|
|
4474
|
+
}
|
|
4475
|
+
this.isSelected = true;
|
|
4444
4476
|
this.makeResizable();
|
|
4445
4477
|
this.div?.classList.add("selectedEditor");
|
|
4446
4478
|
if (!this._editToolbar) {
|
|
@@ -4458,6 +4490,10 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4458
4490
|
* Unselect this editor.
|
|
4459
4491
|
*/
|
|
4460
4492
|
unselect() {
|
|
4493
|
+
if (!this.isSelected) {
|
|
4494
|
+
return;
|
|
4495
|
+
}
|
|
4496
|
+
this.isSelected = false;
|
|
4461
4497
|
__privateGet(this, _resizersDiv)?.classList.add("hidden");
|
|
4462
4498
|
this.div?.classList.remove("selectedEditor");
|
|
4463
4499
|
if (this.div?.contains(document.activeElement)) {
|
|
@@ -4487,10 +4523,35 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4487
4523
|
*/
|
|
4488
4524
|
enableEditing() {
|
|
4489
4525
|
}
|
|
4526
|
+
/**
|
|
4527
|
+
* Check if the content of this editor can be changed.
|
|
4528
|
+
* For example, a FreeText editor can be changed (the user can change the
|
|
4529
|
+
* text), but a Stamp editor cannot.
|
|
4530
|
+
* @returns {boolean}
|
|
4531
|
+
*/
|
|
4532
|
+
get canChangeContent() {
|
|
4533
|
+
return false;
|
|
4534
|
+
}
|
|
4490
4535
|
/**
|
|
4491
4536
|
* The editor is about to be edited.
|
|
4492
4537
|
*/
|
|
4493
4538
|
enterInEditMode() {
|
|
4539
|
+
if (!this.canChangeContent) {
|
|
4540
|
+
return;
|
|
4541
|
+
}
|
|
4542
|
+
this.enableEditMode();
|
|
4543
|
+
this.div.focus();
|
|
4544
|
+
}
|
|
4545
|
+
/**
|
|
4546
|
+
* ondblclick callback.
|
|
4547
|
+
* @param {MouseEvent} event
|
|
4548
|
+
*/
|
|
4549
|
+
dblclick(event) {
|
|
4550
|
+
this.enterInEditMode();
|
|
4551
|
+
this.parent.updateToolbar({
|
|
4552
|
+
mode: this.constructor._editorType,
|
|
4553
|
+
editId: this.id
|
|
4554
|
+
});
|
|
4494
4555
|
}
|
|
4495
4556
|
/**
|
|
4496
4557
|
* @returns {HTMLElement | null} the element requiring an alt text.
|
|
@@ -5131,6 +5192,15 @@ var AnnotationStorage = class {
|
|
|
5131
5192
|
this.onSetModified = null;
|
|
5132
5193
|
this.onResetModified = null;
|
|
5133
5194
|
this.onAnnotationEditor = null;
|
|
5195
|
+
if (false) {
|
|
5196
|
+
Object.defineProperty(this, "_setValues", {
|
|
5197
|
+
value: (obj) => {
|
|
5198
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
5199
|
+
this.setValue(key, val);
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
});
|
|
5203
|
+
}
|
|
5134
5204
|
}
|
|
5135
5205
|
/**
|
|
5136
5206
|
* Get the value for a given key if it exists, or return the default value.
|
|
@@ -5205,20 +5275,6 @@ var AnnotationStorage = class {
|
|
|
5205
5275
|
has(key) {
|
|
5206
5276
|
return __privateGet(this, _storage).has(key);
|
|
5207
5277
|
}
|
|
5208
|
-
/**
|
|
5209
|
-
* @returns {Object | null}
|
|
5210
|
-
*/
|
|
5211
|
-
getAll() {
|
|
5212
|
-
return __privateGet(this, _storage).size > 0 ? objectFromMap(__privateGet(this, _storage)) : null;
|
|
5213
|
-
}
|
|
5214
|
-
/**
|
|
5215
|
-
* @param {Object} obj
|
|
5216
|
-
*/
|
|
5217
|
-
setAll(obj) {
|
|
5218
|
-
for (const [key, val] of Object.entries(obj)) {
|
|
5219
|
-
this.setValue(key, val);
|
|
5220
|
-
}
|
|
5221
|
-
}
|
|
5222
5278
|
get size() {
|
|
5223
5279
|
return __privateGet(this, _storage).size;
|
|
5224
5280
|
}
|
|
@@ -5325,6 +5381,9 @@ var AnnotationStorage = class {
|
|
|
5325
5381
|
hash: ids.join(",")
|
|
5326
5382
|
});
|
|
5327
5383
|
}
|
|
5384
|
+
[Symbol.iterator]() {
|
|
5385
|
+
return __privateGet(this, _storage).entries();
|
|
5386
|
+
}
|
|
5328
5387
|
};
|
|
5329
5388
|
_modified = new WeakMap();
|
|
5330
5389
|
_modifiedIds = new WeakMap();
|
|
@@ -6050,6 +6109,110 @@ var FontFaceObject = class {
|
|
|
6050
6109
|
}
|
|
6051
6110
|
};
|
|
6052
6111
|
|
|
6112
|
+
// src/pdf.js/src/display/api_utils.js
|
|
6113
|
+
function getUrlProp(val) {
|
|
6114
|
+
if (false) {
|
|
6115
|
+
return null;
|
|
6116
|
+
}
|
|
6117
|
+
if (val instanceof URL) {
|
|
6118
|
+
return val.href;
|
|
6119
|
+
}
|
|
6120
|
+
if (typeof val === "string") {
|
|
6121
|
+
if (isNodeJS) {
|
|
6122
|
+
return val;
|
|
6123
|
+
}
|
|
6124
|
+
const url = URL.parse(val, window.location);
|
|
6125
|
+
if (url) {
|
|
6126
|
+
return url.href;
|
|
6127
|
+
}
|
|
6128
|
+
}
|
|
6129
|
+
throw new Error(
|
|
6130
|
+
"Invalid PDF url data: either string or URL-object is expected in the url property."
|
|
6131
|
+
);
|
|
6132
|
+
}
|
|
6133
|
+
function getDataProp(val) {
|
|
6134
|
+
if (isNodeJS && typeof Buffer !== "undefined" && // eslint-disable-line no-undef
|
|
6135
|
+
val instanceof Buffer) {
|
|
6136
|
+
throw new Error(
|
|
6137
|
+
"Please provide binary data as `Uint8Array`, rather than `Buffer`."
|
|
6138
|
+
);
|
|
6139
|
+
}
|
|
6140
|
+
if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
|
|
6141
|
+
return val;
|
|
6142
|
+
}
|
|
6143
|
+
if (typeof val === "string") {
|
|
6144
|
+
return stringToBytes(val);
|
|
6145
|
+
}
|
|
6146
|
+
if (val instanceof ArrayBuffer || ArrayBuffer.isView(val) || typeof val === "object" && !isNaN(val?.length)) {
|
|
6147
|
+
return new Uint8Array(val);
|
|
6148
|
+
}
|
|
6149
|
+
throw new Error(
|
|
6150
|
+
"Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property."
|
|
6151
|
+
);
|
|
6152
|
+
}
|
|
6153
|
+
function getFactoryUrlProp(val) {
|
|
6154
|
+
if (typeof val !== "string") {
|
|
6155
|
+
return null;
|
|
6156
|
+
}
|
|
6157
|
+
if (val.endsWith("/")) {
|
|
6158
|
+
return val;
|
|
6159
|
+
}
|
|
6160
|
+
throw new Error(`Invalid factory url: "${val}" must include trailing slash.`);
|
|
6161
|
+
}
|
|
6162
|
+
var isRefProxy = (v) => typeof v === "object" && Number.isInteger(v?.num) && v.num >= 0 && Number.isInteger(v?.gen) && v.gen >= 0;
|
|
6163
|
+
var isNameProxy = (v) => typeof v === "object" && typeof v?.name === "string";
|
|
6164
|
+
var isValidExplicitDest = _isValidExplicitDest.bind(
|
|
6165
|
+
null,
|
|
6166
|
+
/* validRef = */
|
|
6167
|
+
isRefProxy,
|
|
6168
|
+
/* validName = */
|
|
6169
|
+
isNameProxy
|
|
6170
|
+
);
|
|
6171
|
+
var _listeners, _deferred;
|
|
6172
|
+
var LoopbackPort = class {
|
|
6173
|
+
constructor() {
|
|
6174
|
+
__privateAdd(this, _listeners, /* @__PURE__ */ new Map());
|
|
6175
|
+
__privateAdd(this, _deferred, Promise.resolve());
|
|
6176
|
+
}
|
|
6177
|
+
postMessage(obj, transfer) {
|
|
6178
|
+
const event = {
|
|
6179
|
+
data: structuredClone(obj, transfer ? { transfer } : null)
|
|
6180
|
+
};
|
|
6181
|
+
__privateGet(this, _deferred).then(() => {
|
|
6182
|
+
for (const [listener] of __privateGet(this, _listeners)) {
|
|
6183
|
+
listener.call(this, event);
|
|
6184
|
+
}
|
|
6185
|
+
});
|
|
6186
|
+
}
|
|
6187
|
+
addEventListener(name, listener, options = null) {
|
|
6188
|
+
let rmAbort = null;
|
|
6189
|
+
if (options?.signal instanceof AbortSignal) {
|
|
6190
|
+
const { signal } = options;
|
|
6191
|
+
if (signal.aborted) {
|
|
6192
|
+
warn("LoopbackPort - cannot use an `aborted` signal.");
|
|
6193
|
+
return;
|
|
6194
|
+
}
|
|
6195
|
+
const onAbort = () => this.removeEventListener(name, listener);
|
|
6196
|
+
rmAbort = () => signal.removeEventListener("abort", onAbort);
|
|
6197
|
+
signal.addEventListener("abort", onAbort);
|
|
6198
|
+
}
|
|
6199
|
+
__privateGet(this, _listeners).set(listener, rmAbort);
|
|
6200
|
+
}
|
|
6201
|
+
removeEventListener(name, listener) {
|
|
6202
|
+
const rmAbort = __privateGet(this, _listeners).get(listener);
|
|
6203
|
+
rmAbort?.();
|
|
6204
|
+
__privateGet(this, _listeners).delete(listener);
|
|
6205
|
+
}
|
|
6206
|
+
terminate() {
|
|
6207
|
+
for (const [, rmAbort] of __privateGet(this, _listeners)) {
|
|
6208
|
+
rmAbort?.();
|
|
6209
|
+
}
|
|
6210
|
+
__privateGet(this, _listeners).clear();
|
|
6211
|
+
}
|
|
6212
|
+
};
|
|
6213
|
+
_listeners = new WeakMap();
|
|
6214
|
+
_deferred = new WeakMap();
|
|
6215
|
+
|
|
6053
6216
|
// src/pdf.js/src/display/node_utils.js
|
|
6054
6217
|
import { createRequire as __createRequire__ } from "module";
|
|
6055
6218
|
|
|
@@ -6473,7 +6636,7 @@ createUrl_fn = function(id) {
|
|
|
6473
6636
|
if (isDataScheme(url)) {
|
|
6474
6637
|
warn('#createUrl: ignore "data:"-URL for performance reasons.');
|
|
6475
6638
|
} else {
|
|
6476
|
-
__privateSet(this, _baseUrl, url
|
|
6639
|
+
__privateSet(this, _baseUrl, updateUrlHash(url, ""));
|
|
6477
6640
|
}
|
|
6478
6641
|
}
|
|
6479
6642
|
}
|
|
@@ -6668,6 +6831,13 @@ if (isNodeJS) {
|
|
|
6668
6831
|
warn("Cannot polyfill `Path2D`, rendering may be broken.");
|
|
6669
6832
|
}
|
|
6670
6833
|
}
|
|
6834
|
+
if (!globalThis.navigator?.language) {
|
|
6835
|
+
globalThis.navigator = {
|
|
6836
|
+
language: "en-US",
|
|
6837
|
+
platform: "",
|
|
6838
|
+
userAgent: ""
|
|
6839
|
+
};
|
|
6840
|
+
}
|
|
6671
6841
|
}
|
|
6672
6842
|
}
|
|
6673
6843
|
async function fetchData2(url) {
|
|
@@ -6712,77 +6882,441 @@ var NodeWasmFactory = class extends BaseWasmFactory {
|
|
|
6712
6882
|
}
|
|
6713
6883
|
};
|
|
6714
6884
|
|
|
6715
|
-
// src/
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6885
|
+
// src/lib/utils.ts
|
|
6886
|
+
async function canvasToData(canvas) {
|
|
6887
|
+
if ("toBlob" in canvas) {
|
|
6888
|
+
const blob = await new Promise(
|
|
6889
|
+
(resolve) => canvas.toBlob((data) => resolve(data))
|
|
6890
|
+
);
|
|
6891
|
+
if (!blob) {
|
|
6892
|
+
throw new Error("Failed to generate graphics");
|
|
6893
|
+
}
|
|
6894
|
+
return new Uint8Array(await blob.arrayBuffer());
|
|
6724
6895
|
}
|
|
6725
|
-
const
|
|
6726
|
-
|
|
6727
|
-
const region = new SvgPath2D();
|
|
6728
|
-
region.rect(bbox[0], bbox[1], width, height);
|
|
6729
|
-
ctx.clip(region);
|
|
6896
|
+
const buffer = await canvas.encode("png");
|
|
6897
|
+
return new Uint8Array(buffer);
|
|
6730
6898
|
}
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6899
|
+
async function toDataUrl(data, type = "image/png") {
|
|
6900
|
+
if (typeof FileReader !== "undefined") {
|
|
6901
|
+
return new Promise((resolve) => {
|
|
6902
|
+
const reader = new FileReader();
|
|
6903
|
+
reader.onload = () => {
|
|
6904
|
+
resolve(reader.result);
|
|
6905
|
+
};
|
|
6906
|
+
reader.readAsDataURL(new Blob([data], { type }));
|
|
6907
|
+
});
|
|
6736
6908
|
}
|
|
6737
|
-
|
|
6738
|
-
|
|
6909
|
+
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
6910
|
+
}
|
|
6911
|
+
function makeSerializable(object) {
|
|
6912
|
+
if (typeof object !== "object" || object === null) {
|
|
6913
|
+
return object;
|
|
6739
6914
|
}
|
|
6740
|
-
|
|
6741
|
-
|
|
6915
|
+
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) {
|
|
6916
|
+
return makeSerializable(Array.from(object));
|
|
6742
6917
|
}
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
constructor(IR) {
|
|
6746
|
-
super();
|
|
6747
|
-
this._type = IR[1];
|
|
6748
|
-
this._bbox = IR[2];
|
|
6749
|
-
this._colorStops = IR[3];
|
|
6750
|
-
this._p0 = IR[4];
|
|
6751
|
-
this._p1 = IR[5];
|
|
6752
|
-
this._r0 = IR[6];
|
|
6753
|
-
this._r1 = IR[7];
|
|
6754
|
-
this.matrix = null;
|
|
6918
|
+
if (object instanceof BigInt64Array || object instanceof BigUint64Array) {
|
|
6919
|
+
return makeSerializable(Array.from(object));
|
|
6755
6920
|
}
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
if (this._type === "axial") {
|
|
6759
|
-
grad = ctx.createLinearGradient(
|
|
6760
|
-
this._p0[0],
|
|
6761
|
-
this._p0[1],
|
|
6762
|
-
this._p1[0],
|
|
6763
|
-
this._p1[1]
|
|
6764
|
-
);
|
|
6765
|
-
} else if (this._type === "radial") {
|
|
6766
|
-
grad = ctx.createRadialGradient(
|
|
6767
|
-
this._p0[0],
|
|
6768
|
-
this._p0[1],
|
|
6769
|
-
this._r0,
|
|
6770
|
-
this._p1[0],
|
|
6771
|
-
this._p1[1],
|
|
6772
|
-
this._r1
|
|
6773
|
-
);
|
|
6774
|
-
}
|
|
6775
|
-
for (const colorStop of this._colorStops) {
|
|
6776
|
-
grad.addColorStop(colorStop[0], colorStop[1]);
|
|
6777
|
-
}
|
|
6778
|
-
return grad;
|
|
6921
|
+
if (Array.isArray(object)) {
|
|
6922
|
+
return object.map(makeSerializable);
|
|
6779
6923
|
}
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6924
|
+
return Object.fromEntries(
|
|
6925
|
+
Object.entries(object).map(([key, value]) => [
|
|
6926
|
+
key,
|
|
6927
|
+
makeSerializable(value)
|
|
6928
|
+
])
|
|
6929
|
+
);
|
|
6930
|
+
}
|
|
6931
|
+
function colorToRgb(color) {
|
|
6932
|
+
if (color.startsWith("#")) {
|
|
6933
|
+
const hex = color.slice(1);
|
|
6934
|
+
if (hex.length === 3) {
|
|
6935
|
+
return [
|
|
6936
|
+
Number.parseInt(hex[0] + hex[0], 16),
|
|
6937
|
+
Number.parseInt(hex[1] + hex[1], 16),
|
|
6938
|
+
Number.parseInt(hex[2] + hex[2], 16)
|
|
6939
|
+
];
|
|
6940
|
+
}
|
|
6941
|
+
if (hex.length === 6) {
|
|
6942
|
+
return [
|
|
6943
|
+
Number.parseInt(hex.slice(0, 2), 16),
|
|
6944
|
+
Number.parseInt(hex.slice(2, 4), 16),
|
|
6945
|
+
Number.parseInt(hex.slice(4, 6), 16)
|
|
6946
|
+
];
|
|
6947
|
+
}
|
|
6948
|
+
}
|
|
6949
|
+
throw new Error(`Invalid color format: ${color}`);
|
|
6950
|
+
}
|
|
6951
|
+
function rgbToHex(r, g, b) {
|
|
6952
|
+
const toHex = (value) => value.toString(16).padStart(2, "0");
|
|
6953
|
+
if (Array.isArray(r)) {
|
|
6954
|
+
return `#${toHex(r[0])}${toHex(r[1])}${toHex(r[2])}`;
|
|
6955
|
+
}
|
|
6956
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
6957
|
+
}
|
|
6958
|
+
|
|
6959
|
+
// src/lib/NodeFilterFactory.ts
|
|
6960
|
+
var filtersRegistry = /* @__PURE__ */ new Map();
|
|
6961
|
+
function createTables(maps) {
|
|
6962
|
+
if (maps.length === 1) {
|
|
6963
|
+
const mapR2 = maps[0];
|
|
6964
|
+
const buffer = new Array(256);
|
|
6965
|
+
for (let i = 0; i < 256; i++) {
|
|
6966
|
+
buffer[i] = mapR2[i] / 255;
|
|
6967
|
+
}
|
|
6968
|
+
return [buffer, buffer, buffer];
|
|
6969
|
+
}
|
|
6970
|
+
const [mapR, mapG, mapB] = maps;
|
|
6971
|
+
const bufferR = new Array(256);
|
|
6972
|
+
const bufferG = new Array(256);
|
|
6973
|
+
const bufferB = new Array(256);
|
|
6974
|
+
for (let i = 0; i < 256; i++) {
|
|
6975
|
+
bufferR[i] = mapR[i] / 255;
|
|
6976
|
+
bufferG[i] = mapG[i] / 255;
|
|
6977
|
+
bufferB[i] = mapB[i] / 255;
|
|
6978
|
+
}
|
|
6979
|
+
return [bufferR, bufferG, bufferB];
|
|
6980
|
+
}
|
|
6981
|
+
function createTransferMapAlphaConversion(aTable) {
|
|
6982
|
+
return (ctx) => {
|
|
6983
|
+
const imageData = ctx.getImageData(
|
|
6984
|
+
0,
|
|
6985
|
+
0,
|
|
6986
|
+
ctx.canvas.width,
|
|
6987
|
+
ctx.canvas.height
|
|
6988
|
+
);
|
|
6989
|
+
const data = imageData.data;
|
|
6990
|
+
const tableSize = aTable.length;
|
|
6991
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
6992
|
+
const alpha = data[i + 3] / 255;
|
|
6993
|
+
const index = alpha * (tableSize - 1);
|
|
6994
|
+
const lower = Math.floor(index);
|
|
6995
|
+
const upper = Math.min(lower + 1, tableSize - 1);
|
|
6996
|
+
const t = index - lower;
|
|
6997
|
+
const newAlpha = (1 - t) * aTable[lower] + t * aTable[upper];
|
|
6998
|
+
data[i + 3] = newAlpha * 255;
|
|
6999
|
+
}
|
|
7000
|
+
ctx.putImageData(imageData, 0, 0);
|
|
7001
|
+
};
|
|
7002
|
+
}
|
|
7003
|
+
function createTransferMapConversion(rTable, gTable, bTable) {
|
|
7004
|
+
return (ctx) => {
|
|
7005
|
+
const imageData = ctx.getImageData(
|
|
7006
|
+
0,
|
|
7007
|
+
0,
|
|
7008
|
+
ctx.canvas.width,
|
|
7009
|
+
ctx.canvas.height
|
|
7010
|
+
);
|
|
7011
|
+
const data = imageData.data;
|
|
7012
|
+
const rSize = rTable.length;
|
|
7013
|
+
const gSize = gTable.length;
|
|
7014
|
+
const bSize = bTable.length;
|
|
7015
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
7016
|
+
const r = data[i] / 255;
|
|
7017
|
+
const g = data[i + 1] / 255;
|
|
7018
|
+
const b = data[i + 2] / 255;
|
|
7019
|
+
const rIndex = r * (rSize - 1);
|
|
7020
|
+
const rLower = Math.floor(rIndex);
|
|
7021
|
+
const rUpper = Math.min(rLower + 1, rSize - 1);
|
|
7022
|
+
const rT = rIndex - rLower;
|
|
7023
|
+
const newR = (1 - rT) * rTable[rLower] + rT * rTable[rUpper];
|
|
7024
|
+
const gIndex = g * (gSize - 1);
|
|
7025
|
+
const gLower = Math.floor(gIndex);
|
|
7026
|
+
const gUpper = Math.min(gLower + 1, gSize - 1);
|
|
7027
|
+
const gT = gIndex - gLower;
|
|
7028
|
+
const newG = (1 - gT) * gTable[gLower] + gT * gTable[gUpper];
|
|
7029
|
+
const bIndex = b * (bSize - 1);
|
|
7030
|
+
const bLower = Math.floor(bIndex);
|
|
7031
|
+
const bUpper = Math.min(bLower + 1, bSize - 1);
|
|
7032
|
+
const bT = bIndex - bLower;
|
|
7033
|
+
const newB = (1 - bT) * bTable[bLower] + bT * bTable[bUpper];
|
|
7034
|
+
data[i] = newR * 255;
|
|
7035
|
+
data[i + 1] = newG * 255;
|
|
7036
|
+
data[i + 2] = newB * 255;
|
|
7037
|
+
}
|
|
7038
|
+
ctx.putImageData(imageData, 0, 0);
|
|
7039
|
+
};
|
|
7040
|
+
}
|
|
7041
|
+
function createLuminosityConversion() {
|
|
7042
|
+
return (ctx) => {
|
|
7043
|
+
const imageData = ctx.getImageData(
|
|
7044
|
+
0,
|
|
7045
|
+
0,
|
|
7046
|
+
ctx.canvas.width,
|
|
7047
|
+
ctx.canvas.height
|
|
7048
|
+
);
|
|
7049
|
+
const data = imageData.data;
|
|
7050
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
7051
|
+
const r = data[i];
|
|
7052
|
+
const g = data[i + 1];
|
|
7053
|
+
const b = data[i + 2];
|
|
7054
|
+
data[i] = data[i + 1] = data[i + 2] = 0;
|
|
7055
|
+
data[i + 3] = r * 0.3 + g * 0.59 + b * 0.11;
|
|
7056
|
+
}
|
|
7057
|
+
ctx.putImageData(imageData, 0, 0);
|
|
7058
|
+
};
|
|
7059
|
+
}
|
|
7060
|
+
function createGrayConversion() {
|
|
7061
|
+
return (ctx) => {
|
|
7062
|
+
const imageData = ctx.getImageData(
|
|
7063
|
+
0,
|
|
7064
|
+
0,
|
|
7065
|
+
ctx.canvas.width,
|
|
7066
|
+
ctx.canvas.height
|
|
7067
|
+
);
|
|
7068
|
+
const data = imageData.data;
|
|
7069
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
7070
|
+
const r = data[i];
|
|
7071
|
+
const g = data[i + 1];
|
|
7072
|
+
const b = data[i + 2];
|
|
7073
|
+
const gray = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
7074
|
+
data[i] = data[i + 1] = data[i + 2] = gray;
|
|
7075
|
+
}
|
|
7076
|
+
ctx.putImageData(imageData, 0, 0);
|
|
7077
|
+
};
|
|
7078
|
+
}
|
|
7079
|
+
var NodeFilterFactory2 = class extends NodeFilterFactory {
|
|
7080
|
+
addFilter(maps) {
|
|
7081
|
+
if (!maps) {
|
|
7082
|
+
return "none";
|
|
7083
|
+
}
|
|
7084
|
+
const [rTable, gTable, bTable] = createTables(maps);
|
|
7085
|
+
const url = `url(#filter_${maps.length === 1 ? rTable.join("_") : `${rTable.join("_")}_${gTable.join("_")}_${bTable.join("_")}`})`;
|
|
7086
|
+
if (!filtersRegistry.has(url)) {
|
|
7087
|
+
filtersRegistry.set(
|
|
7088
|
+
url,
|
|
7089
|
+
createTransferMapConversion(rTable, gTable, bTable)
|
|
7090
|
+
);
|
|
7091
|
+
}
|
|
7092
|
+
return url;
|
|
7093
|
+
}
|
|
7094
|
+
addHCMFilter(fgColor, bgColor) {
|
|
7095
|
+
const fgRGB = colorToRgb(fgColor);
|
|
7096
|
+
const bgRGB = colorToRgb(bgColor);
|
|
7097
|
+
const url = `url(#hcm_${rgbToHex(fgRGB)}_${rgbToHex(bgRGB)})`;
|
|
7098
|
+
if (!filtersRegistry.has(url)) {
|
|
7099
|
+
const table = new Array(256);
|
|
7100
|
+
for (let i = 0; i <= 255; i++) {
|
|
7101
|
+
const x = i / 255;
|
|
7102
|
+
table[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
7103
|
+
}
|
|
7104
|
+
const transferMapFilter = createTransferMapConversion(
|
|
7105
|
+
table,
|
|
7106
|
+
table,
|
|
7107
|
+
table
|
|
7108
|
+
);
|
|
7109
|
+
const grayFilter = createGrayConversion();
|
|
7110
|
+
const getSteps = (c, n) => {
|
|
7111
|
+
const start = fgRGB[c] / 255;
|
|
7112
|
+
const end = bgRGB[c] / 255;
|
|
7113
|
+
const arr = new Array(n + 1);
|
|
7114
|
+
for (let i = 0; i <= n; i++) {
|
|
7115
|
+
arr[i] = start + i / n * (end - start);
|
|
7116
|
+
}
|
|
7117
|
+
return arr;
|
|
7118
|
+
};
|
|
7119
|
+
const finalTransferMap = createTransferMapConversion(
|
|
7120
|
+
getSteps(0, 5),
|
|
7121
|
+
getSteps(1, 5),
|
|
7122
|
+
getSteps(2, 5)
|
|
7123
|
+
);
|
|
7124
|
+
filtersRegistry.set(url, (ctx) => {
|
|
7125
|
+
transferMapFilter(ctx);
|
|
7126
|
+
grayFilter(ctx);
|
|
7127
|
+
finalTransferMap(ctx);
|
|
7128
|
+
});
|
|
7129
|
+
}
|
|
7130
|
+
return url;
|
|
7131
|
+
}
|
|
7132
|
+
addAlphaFilter(map) {
|
|
7133
|
+
const [tableA] = createTables([map]);
|
|
7134
|
+
const url = `url(#alpha_${tableA.join("_")})`;
|
|
7135
|
+
if (!filtersRegistry.has(url)) {
|
|
7136
|
+
filtersRegistry.set(url, createTransferMapAlphaConversion(map));
|
|
7137
|
+
}
|
|
7138
|
+
return url;
|
|
7139
|
+
}
|
|
7140
|
+
addLuminosityFilter(map) {
|
|
7141
|
+
const url = `url(#luminosity${map ? `_${map.join("_")}` : ""})`;
|
|
7142
|
+
if (!filtersRegistry.has(url)) {
|
|
7143
|
+
const tables = map ? createTables([map]) : null;
|
|
7144
|
+
const alphaFilter = tables ? createTransferMapAlphaConversion(tables[0]) : null;
|
|
7145
|
+
const luminosityFilter = createLuminosityConversion();
|
|
7146
|
+
filtersRegistry.set(url, (ctx) => {
|
|
7147
|
+
luminosityFilter(ctx);
|
|
7148
|
+
alphaFilter?.(ctx);
|
|
7149
|
+
});
|
|
7150
|
+
}
|
|
7151
|
+
return url;
|
|
7152
|
+
}
|
|
7153
|
+
addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
|
|
7154
|
+
const fgRGB = colorToRgb(fgColor);
|
|
7155
|
+
const bgRGB = colorToRgb(bgColor);
|
|
7156
|
+
let newFgRGB = colorToRgb(newFgColor);
|
|
7157
|
+
let newBgRGB = colorToRgb(newBgColor);
|
|
7158
|
+
const url = `url(#highlight_hcm_${filterName}_${rgbToHex(fgRGB)}_${rgbToHex(bgRGB)}_${rgbToHex(newFgRGB)}_${rgbToHex(newBgRGB)})`;
|
|
7159
|
+
if (!filtersRegistry.has(url)) {
|
|
7160
|
+
let fgGray = Math.round(
|
|
7161
|
+
0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]
|
|
7162
|
+
);
|
|
7163
|
+
let bgGray = Math.round(
|
|
7164
|
+
0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]
|
|
7165
|
+
);
|
|
7166
|
+
if (bgGray < fgGray) {
|
|
7167
|
+
[fgGray, bgGray, newFgRGB, newBgRGB] = [
|
|
7168
|
+
bgGray,
|
|
7169
|
+
fgGray,
|
|
7170
|
+
newBgRGB,
|
|
7171
|
+
newFgRGB
|
|
7172
|
+
];
|
|
7173
|
+
}
|
|
7174
|
+
const grayFilter = createGrayConversion();
|
|
7175
|
+
const getSteps = (fg, bg, n) => {
|
|
7176
|
+
const arr = new Array(256);
|
|
7177
|
+
const step = (bgGray - fgGray) / n;
|
|
7178
|
+
const newStart = fg / 255;
|
|
7179
|
+
const newStep = (bg - fg) / (255 * n);
|
|
7180
|
+
let prev = 0;
|
|
7181
|
+
for (let i = 0; i <= n; i++) {
|
|
7182
|
+
const k = Math.round(fgGray + i * step);
|
|
7183
|
+
const value = newStart + i * newStep;
|
|
7184
|
+
for (let j = prev; j <= k; j++) {
|
|
7185
|
+
arr[j] = value;
|
|
7186
|
+
}
|
|
7187
|
+
prev = k + 1;
|
|
7188
|
+
}
|
|
7189
|
+
for (let i = prev; i < 256; i++) {
|
|
7190
|
+
arr[i] = arr[prev - 1];
|
|
7191
|
+
}
|
|
7192
|
+
return arr;
|
|
7193
|
+
};
|
|
7194
|
+
const transferMapFilter = createTransferMapConversion(
|
|
7195
|
+
getSteps(newFgRGB[0], newBgRGB[0], 5),
|
|
7196
|
+
getSteps(newFgRGB[1], newBgRGB[1], 5),
|
|
7197
|
+
getSteps(newFgRGB[2], newBgRGB[2], 5)
|
|
7198
|
+
);
|
|
7199
|
+
filtersRegistry.set(url, (ctx) => {
|
|
7200
|
+
grayFilter(ctx);
|
|
7201
|
+
transferMapFilter(ctx);
|
|
7202
|
+
});
|
|
7203
|
+
}
|
|
7204
|
+
return url;
|
|
7205
|
+
}
|
|
7206
|
+
};
|
|
7207
|
+
|
|
7208
|
+
// src/lib/NodeCanvasFactory.ts
|
|
7209
|
+
var NodeCanvasFactory2 = class extends NodeCanvasFactory {
|
|
7210
|
+
create(width, height) {
|
|
7211
|
+
const factory = this;
|
|
7212
|
+
const { canvas, context } = super.create(width, height);
|
|
7213
|
+
const drawImage = context.drawImage;
|
|
7214
|
+
let currentFilter = "none";
|
|
7215
|
+
Object.defineProperty(context, "filter", {
|
|
7216
|
+
get() {
|
|
7217
|
+
if (currentFilter.startsWith("url(")) {
|
|
7218
|
+
return "none";
|
|
7219
|
+
}
|
|
7220
|
+
return currentFilter;
|
|
7221
|
+
},
|
|
7222
|
+
set(value) {
|
|
7223
|
+
currentFilter = value;
|
|
7224
|
+
},
|
|
7225
|
+
configurable: true
|
|
7226
|
+
});
|
|
7227
|
+
context.drawImage = function(src, ...args) {
|
|
7228
|
+
const filter = filtersRegistry.get(currentFilter);
|
|
7229
|
+
if (!filter) {
|
|
7230
|
+
drawImage.call(this, src, ...args);
|
|
7231
|
+
return;
|
|
7232
|
+
}
|
|
7233
|
+
const { canvas: canvas2, context: context2 } = factory.create(src.width, src.height);
|
|
7234
|
+
context2.drawImage(src, 0, 0, src.width, src.height);
|
|
7235
|
+
filter(context2);
|
|
7236
|
+
drawImage.call(this, canvas2, ...args);
|
|
7237
|
+
factory.destroy({
|
|
7238
|
+
canvas: canvas2,
|
|
7239
|
+
context: context2
|
|
7240
|
+
});
|
|
7241
|
+
};
|
|
7242
|
+
return {
|
|
7243
|
+
canvas,
|
|
7244
|
+
context
|
|
7245
|
+
};
|
|
7246
|
+
}
|
|
7247
|
+
};
|
|
7248
|
+
|
|
7249
|
+
// src/pdf.js/src/display/pattern_helper.js
|
|
7250
|
+
var PathType = {
|
|
7251
|
+
FILL: "Fill",
|
|
7252
|
+
STROKE: "Stroke",
|
|
7253
|
+
SHADING: "Shading"
|
|
7254
|
+
};
|
|
7255
|
+
function applyBoundingBox(ctx, bbox) {
|
|
7256
|
+
if (!bbox) {
|
|
7257
|
+
return;
|
|
7258
|
+
}
|
|
7259
|
+
const width = bbox[2] - bbox[0];
|
|
7260
|
+
const height = bbox[3] - bbox[1];
|
|
7261
|
+
const region = new SvgPath2D();
|
|
7262
|
+
region.rect(bbox[0], bbox[1], width, height);
|
|
7263
|
+
ctx.clip(region);
|
|
7264
|
+
}
|
|
7265
|
+
var BaseShadingPattern = class {
|
|
7266
|
+
constructor() {
|
|
7267
|
+
if (false) {
|
|
7268
|
+
unreachable("Cannot initialize BaseShadingPattern.");
|
|
7269
|
+
}
|
|
7270
|
+
}
|
|
7271
|
+
isModifyingCurrentTransform() {
|
|
7272
|
+
return false;
|
|
7273
|
+
}
|
|
7274
|
+
getPattern() {
|
|
7275
|
+
unreachable("Abstract method `getPattern` called.");
|
|
7276
|
+
}
|
|
7277
|
+
};
|
|
7278
|
+
var RadialAxialShadingPattern = class extends BaseShadingPattern {
|
|
7279
|
+
constructor(IR) {
|
|
7280
|
+
super();
|
|
7281
|
+
this._type = IR[1];
|
|
7282
|
+
this._bbox = IR[2];
|
|
7283
|
+
this._colorStops = IR[3];
|
|
7284
|
+
this._p0 = IR[4];
|
|
7285
|
+
this._p1 = IR[5];
|
|
7286
|
+
this._r0 = IR[6];
|
|
7287
|
+
this._r1 = IR[7];
|
|
7288
|
+
this.matrix = null;
|
|
7289
|
+
}
|
|
7290
|
+
_createGradient(ctx) {
|
|
7291
|
+
let grad;
|
|
7292
|
+
if (this._type === "axial") {
|
|
7293
|
+
grad = ctx.createLinearGradient(
|
|
7294
|
+
this._p0[0],
|
|
7295
|
+
this._p0[1],
|
|
7296
|
+
this._p1[0],
|
|
7297
|
+
this._p1[1]
|
|
7298
|
+
);
|
|
7299
|
+
} else if (this._type === "radial") {
|
|
7300
|
+
grad = ctx.createRadialGradient(
|
|
7301
|
+
this._p0[0],
|
|
7302
|
+
this._p0[1],
|
|
7303
|
+
this._r0,
|
|
7304
|
+
this._p1[0],
|
|
7305
|
+
this._p1[1],
|
|
7306
|
+
this._r1
|
|
7307
|
+
);
|
|
7308
|
+
}
|
|
7309
|
+
for (const colorStop of this._colorStops) {
|
|
7310
|
+
grad.addColorStop(colorStop[0], colorStop[1]);
|
|
7311
|
+
}
|
|
7312
|
+
return grad;
|
|
7313
|
+
}
|
|
7314
|
+
getPattern(ctx, owner, inverse, pathType) {
|
|
7315
|
+
let pattern;
|
|
7316
|
+
if (pathType === PathType.STROKE || pathType === PathType.FILL) {
|
|
7317
|
+
const ownerBBox = owner.current.getClippedPathBoundingBox(
|
|
7318
|
+
pathType,
|
|
7319
|
+
getCurrentTransform(ctx)
|
|
6786
7320
|
) || [0, 0, 0, 0];
|
|
6787
7321
|
const width = Math.ceil(ownerBBox[2] - ownerBBox[0]) || 1;
|
|
6788
7322
|
const height = Math.ceil(ownerBBox[3] - ownerBBox[1]) || 1;
|
|
@@ -7254,18 +7788,13 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7254
7788
|
const context = graphics.ctx, current = graphics.current;
|
|
7255
7789
|
switch (paintType) {
|
|
7256
7790
|
case PaintType.COLORED:
|
|
7257
|
-
const
|
|
7258
|
-
context.fillStyle =
|
|
7259
|
-
context.strokeStyle =
|
|
7260
|
-
current.fillColor = ctx.fillStyle;
|
|
7261
|
-
current.strokeColor = ctx.strokeStyle;
|
|
7791
|
+
const { fillStyle, strokeStyle } = this.ctx;
|
|
7792
|
+
context.fillStyle = current.fillColor = fillStyle;
|
|
7793
|
+
context.strokeStyle = current.strokeColor = strokeStyle;
|
|
7262
7794
|
break;
|
|
7263
7795
|
case PaintType.UNCOLORED:
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
context.strokeStyle = cssColor;
|
|
7267
|
-
current.fillColor = cssColor;
|
|
7268
|
-
current.strokeColor = cssColor;
|
|
7796
|
+
context.fillStyle = context.strokeStyle = color;
|
|
7797
|
+
current.fillColor = current.strokeColor = color;
|
|
7269
7798
|
break;
|
|
7270
7799
|
default:
|
|
7271
7800
|
throw new FormatError(`Unsupported paint type: ${paintType}`);
|
|
@@ -8202,7 +8731,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8202
8731
|
let maskX = layerOffsetX - maskOffsetX;
|
|
8203
8732
|
let maskY = layerOffsetY - maskOffsetY;
|
|
8204
8733
|
if (backdrop) {
|
|
8205
|
-
const backdropRGB = Util.makeHexColor(...backdrop);
|
|
8206
8734
|
if (maskX < 0 || maskY < 0 || maskX + width > maskCanvas.width || maskY + height > maskCanvas.height) {
|
|
8207
8735
|
const canvas = this.cachedCanvases.getCanvas(
|
|
8208
8736
|
"maskExtension",
|
|
@@ -8212,7 +8740,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8212
8740
|
const ctx = canvas.context;
|
|
8213
8741
|
ctx.drawImage(maskCanvas, -maskX, -maskY);
|
|
8214
8742
|
ctx.globalCompositeOperation = "destination-atop";
|
|
8215
|
-
ctx.fillStyle =
|
|
8743
|
+
ctx.fillStyle = backdrop;
|
|
8216
8744
|
ctx.fillRect(0, 0, width, height);
|
|
8217
8745
|
ctx.globalCompositeOperation = "source-over";
|
|
8218
8746
|
maskCanvas = canvas.canvas;
|
|
@@ -8225,7 +8753,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8225
8753
|
clip2.rect(maskX, maskY, width, height);
|
|
8226
8754
|
maskCtx.clip(clip2);
|
|
8227
8755
|
maskCtx.globalCompositeOperation = "destination-atop";
|
|
8228
|
-
maskCtx.fillStyle =
|
|
8756
|
+
maskCtx.fillStyle = backdrop;
|
|
8229
8757
|
maskCtx.fillRect(maskX, maskY, width, height);
|
|
8230
8758
|
maskCtx.restore();
|
|
8231
8759
|
}
|
|
@@ -8904,20 +9432,16 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8904
9432
|
this.current.fillColor = this.getColorN_Pattern(arguments);
|
|
8905
9433
|
this.current.patternFill = true;
|
|
8906
9434
|
}
|
|
8907
|
-
setStrokeRGBColor(
|
|
8908
|
-
this.ctx.strokeStyle = this.current.strokeColor =
|
|
8909
|
-
r,
|
|
8910
|
-
g,
|
|
8911
|
-
b
|
|
8912
|
-
);
|
|
9435
|
+
setStrokeRGBColor(color) {
|
|
9436
|
+
this.ctx.strokeStyle = this.current.strokeColor = color;
|
|
8913
9437
|
this.current.patternStroke = false;
|
|
8914
9438
|
}
|
|
8915
9439
|
setStrokeTransparent() {
|
|
8916
9440
|
this.ctx.strokeStyle = this.current.strokeColor = "transparent";
|
|
8917
9441
|
this.current.patternStroke = false;
|
|
8918
9442
|
}
|
|
8919
|
-
setFillRGBColor(
|
|
8920
|
-
this.ctx.fillStyle = this.current.fillColor =
|
|
9443
|
+
setFillRGBColor(color) {
|
|
9444
|
+
this.ctx.fillStyle = this.current.fillColor = color;
|
|
8921
9445
|
this.current.patternFill = false;
|
|
8922
9446
|
}
|
|
8923
9447
|
setFillTransparent() {
|
|
@@ -9667,28 +10191,25 @@ __privateAdd(GlobalWorkerOptions, _port, null);
|
|
|
9667
10191
|
__privateAdd(GlobalWorkerOptions, _src, "");
|
|
9668
10192
|
|
|
9669
10193
|
// src/pdf.js/src/display/metadata.js
|
|
9670
|
-
var
|
|
10194
|
+
var _map, _data;
|
|
9671
10195
|
var Metadata = class {
|
|
9672
10196
|
constructor({ parsedData, rawData }) {
|
|
9673
|
-
__privateAdd(this,
|
|
10197
|
+
__privateAdd(this, _map);
|
|
9674
10198
|
__privateAdd(this, _data);
|
|
9675
|
-
__privateSet(this,
|
|
10199
|
+
__privateSet(this, _map, parsedData);
|
|
9676
10200
|
__privateSet(this, _data, rawData);
|
|
9677
10201
|
}
|
|
9678
10202
|
getRaw() {
|
|
9679
10203
|
return __privateGet(this, _data);
|
|
9680
10204
|
}
|
|
9681
10205
|
get(name) {
|
|
9682
|
-
return __privateGet(this,
|
|
9683
|
-
}
|
|
9684
|
-
getAll() {
|
|
9685
|
-
return objectFromMap(__privateGet(this, _metadataMap));
|
|
10206
|
+
return __privateGet(this, _map).get(name) ?? null;
|
|
9686
10207
|
}
|
|
9687
|
-
|
|
9688
|
-
return __privateGet(this,
|
|
10208
|
+
[Symbol.iterator]() {
|
|
10209
|
+
return __privateGet(this, _map).entries();
|
|
9689
10210
|
}
|
|
9690
10211
|
};
|
|
9691
|
-
|
|
10212
|
+
_map = new WeakMap();
|
|
9692
10213
|
_data = new WeakMap();
|
|
9693
10214
|
|
|
9694
10215
|
// src/pdf.js/src/display/optional_content_config.js
|
|
@@ -9908,9 +10429,6 @@ var OptionalContentConfig = class {
|
|
|
9908
10429
|
}
|
|
9909
10430
|
return [...__privateGet(this, _groups).keys()];
|
|
9910
10431
|
}
|
|
9911
|
-
getGroups() {
|
|
9912
|
-
return __privateGet(this, _groups).size > 0 ? objectFromMap(__privateGet(this, _groups)) : null;
|
|
9913
|
-
}
|
|
9914
10432
|
getGroup(id) {
|
|
9915
10433
|
return __privateGet(this, _groups).get(id) || null;
|
|
9916
10434
|
}
|
|
@@ -9924,6 +10442,9 @@ var OptionalContentConfig = class {
|
|
|
9924
10442
|
}
|
|
9925
10443
|
return __privateSet(this, _cachedGetHash, hash.hexdigest());
|
|
9926
10444
|
}
|
|
10445
|
+
[Symbol.iterator]() {
|
|
10446
|
+
return __privateGet(this, _groups).entries();
|
|
10447
|
+
}
|
|
9927
10448
|
};
|
|
9928
10449
|
_cachedGetHash = new WeakMap();
|
|
9929
10450
|
_groups = new WeakMap();
|
|
@@ -11224,6 +11745,102 @@ var PDFNodeStreamFsRangeReader = class {
|
|
|
11224
11745
|
}
|
|
11225
11746
|
};
|
|
11226
11747
|
|
|
11748
|
+
// src/pdf.js/src/display/pdf_objects.js
|
|
11749
|
+
var INITIAL_DATA = Symbol("INITIAL_DATA");
|
|
11750
|
+
var _objs, _PDFObjects_instances, ensureObj_fn;
|
|
11751
|
+
var PDFObjects = class {
|
|
11752
|
+
constructor() {
|
|
11753
|
+
__privateAdd(this, _PDFObjects_instances);
|
|
11754
|
+
__privateAdd(this, _objs, /* @__PURE__ */ Object.create(null));
|
|
11755
|
+
}
|
|
11756
|
+
/**
|
|
11757
|
+
* If called *without* callback, this returns the data of `objId` but the
|
|
11758
|
+
* object needs to be resolved. If it isn't, this method throws.
|
|
11759
|
+
*
|
|
11760
|
+
* If called *with* a callback, the callback is called with the data of the
|
|
11761
|
+
* object once the object is resolved. That means, if you call this method
|
|
11762
|
+
* and the object is already resolved, the callback gets called right away.
|
|
11763
|
+
*
|
|
11764
|
+
* @param {string} objId
|
|
11765
|
+
* @param {function} [callback]
|
|
11766
|
+
* @returns {any}
|
|
11767
|
+
*/
|
|
11768
|
+
get(objId, callback = null) {
|
|
11769
|
+
if (callback) {
|
|
11770
|
+
const obj2 = __privateMethod(this, _PDFObjects_instances, ensureObj_fn).call(this, objId);
|
|
11771
|
+
obj2.promise.then(() => callback(obj2.data));
|
|
11772
|
+
return null;
|
|
11773
|
+
}
|
|
11774
|
+
const obj = __privateGet(this, _objs)[objId];
|
|
11775
|
+
if (!obj || obj.data === INITIAL_DATA) {
|
|
11776
|
+
throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
|
|
11777
|
+
}
|
|
11778
|
+
return obj.data;
|
|
11779
|
+
}
|
|
11780
|
+
/**
|
|
11781
|
+
* @param {string} objId
|
|
11782
|
+
* @returns {boolean}
|
|
11783
|
+
*/
|
|
11784
|
+
has(objId) {
|
|
11785
|
+
const obj = __privateGet(this, _objs)[objId];
|
|
11786
|
+
return !!obj && obj.data !== INITIAL_DATA;
|
|
11787
|
+
}
|
|
11788
|
+
/**
|
|
11789
|
+
* @param {string} objId
|
|
11790
|
+
* @returns {boolean}
|
|
11791
|
+
*/
|
|
11792
|
+
delete(objId) {
|
|
11793
|
+
const obj = __privateGet(this, _objs)[objId];
|
|
11794
|
+
if (!obj || obj.data === INITIAL_DATA) {
|
|
11795
|
+
return false;
|
|
11796
|
+
}
|
|
11797
|
+
delete __privateGet(this, _objs)[objId];
|
|
11798
|
+
return true;
|
|
11799
|
+
}
|
|
11800
|
+
/**
|
|
11801
|
+
* Resolves the object `objId` with optional `data`.
|
|
11802
|
+
*
|
|
11803
|
+
* @param {string} objId
|
|
11804
|
+
* @param {any} [data]
|
|
11805
|
+
*/
|
|
11806
|
+
resolve(objId, data = null) {
|
|
11807
|
+
const obj = __privateMethod(this, _PDFObjects_instances, ensureObj_fn).call(this, objId);
|
|
11808
|
+
obj.data = data;
|
|
11809
|
+
obj.resolve();
|
|
11810
|
+
}
|
|
11811
|
+
clear() {
|
|
11812
|
+
for (const objId in __privateGet(this, _objs)) {
|
|
11813
|
+
const { data } = __privateGet(this, _objs)[objId];
|
|
11814
|
+
data?.bitmap?.close();
|
|
11815
|
+
}
|
|
11816
|
+
__privateSet(this, _objs, /* @__PURE__ */ Object.create(null));
|
|
11817
|
+
}
|
|
11818
|
+
*[Symbol.iterator]() {
|
|
11819
|
+
for (const objId in __privateGet(this, _objs)) {
|
|
11820
|
+
const { data } = __privateGet(this, _objs)[objId];
|
|
11821
|
+
if (data === INITIAL_DATA) {
|
|
11822
|
+
continue;
|
|
11823
|
+
}
|
|
11824
|
+
yield [objId, data];
|
|
11825
|
+
}
|
|
11826
|
+
}
|
|
11827
|
+
};
|
|
11828
|
+
_objs = new WeakMap();
|
|
11829
|
+
_PDFObjects_instances = new WeakSet();
|
|
11830
|
+
/**
|
|
11831
|
+
* Ensures there is an object defined for `objId`.
|
|
11832
|
+
*
|
|
11833
|
+
* @param {string} objId
|
|
11834
|
+
* @returns {Object}
|
|
11835
|
+
*/
|
|
11836
|
+
ensureObj_fn = function(objId) {
|
|
11837
|
+
var _a2;
|
|
11838
|
+
return (_a2 = __privateGet(this, _objs))[objId] || (_a2[objId] = {
|
|
11839
|
+
...Promise.withResolvers(),
|
|
11840
|
+
data: INITIAL_DATA
|
|
11841
|
+
});
|
|
11842
|
+
};
|
|
11843
|
+
|
|
11227
11844
|
// src/pdf.js/src/display/text_layer.js
|
|
11228
11845
|
var MAX_TEXT_DIVS_TO_RENDER = 1e5;
|
|
11229
11846
|
var DEFAULT_FONT_SIZE = 30;
|
|
@@ -11699,7 +12316,6 @@ var XfaText = class _XfaText {
|
|
|
11699
12316
|
};
|
|
11700
12317
|
|
|
11701
12318
|
// src/pdf.js/src/display/api.js
|
|
11702
|
-
var DEFAULT_RANGE_CHUNK_SIZE = 65536;
|
|
11703
12319
|
var RENDERING_CANCELLED_TIMEOUT = 100;
|
|
11704
12320
|
function getDocument(src = {}) {
|
|
11705
12321
|
if (true) {
|
|
@@ -11717,7 +12333,7 @@ function getDocument(src = {}) {
|
|
|
11717
12333
|
const withCredentials = src.withCredentials === true;
|
|
11718
12334
|
const password = src.password ?? null;
|
|
11719
12335
|
const rangeTransport = src.range instanceof PDFDataRangeTransport ? src.range : null;
|
|
11720
|
-
const rangeChunkSize = Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0 ? src.rangeChunkSize :
|
|
12336
|
+
const rangeChunkSize = Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0 ? src.rangeChunkSize : 2 ** 16;
|
|
11721
12337
|
let worker = src.worker instanceof PDFWorker ? src.worker : null;
|
|
11722
12338
|
const verbosity = src.verbosity;
|
|
11723
12339
|
const docBaseUrl = typeof src.docBaseUrl === "string" && !isDataScheme(src.docBaseUrl) ? src.docBaseUrl : null;
|
|
@@ -11749,8 +12365,8 @@ function getDocument(src = {}) {
|
|
|
11749
12365
|
const disableStream = src.disableStream === true;
|
|
11750
12366
|
const disableAutoFetch = src.disableAutoFetch === true;
|
|
11751
12367
|
const pdfBug = src.pdfBug === true;
|
|
11752
|
-
const CanvasFactory = src.CanvasFactory || (isNodeJS ?
|
|
11753
|
-
const FilterFactory = src.FilterFactory || (isNodeJS ?
|
|
12368
|
+
const CanvasFactory = src.CanvasFactory || (isNodeJS ? NodeCanvasFactory2 : DOMCanvasFactory);
|
|
12369
|
+
const FilterFactory = src.FilterFactory || (isNodeJS ? NodeFilterFactory2 : DOMFilterFactory);
|
|
11754
12370
|
const enableHWA = src.enableHWA === true;
|
|
11755
12371
|
const useWasm = src.useWasm !== false;
|
|
11756
12372
|
const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
|
|
@@ -11766,11 +12382,10 @@ function getDocument(src = {}) {
|
|
|
11766
12382
|
wasmFactory: useWorkerFetch ? null : new WasmFactory2({ baseUrl: wasmUrl })
|
|
11767
12383
|
};
|
|
11768
12384
|
if (!worker) {
|
|
11769
|
-
|
|
12385
|
+
worker = PDFWorker.create({
|
|
11770
12386
|
verbosity,
|
|
11771
12387
|
port: GlobalWorkerOptions.workerPort
|
|
11772
|
-
};
|
|
11773
|
-
worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
|
|
12388
|
+
});
|
|
11774
12389
|
task._worker = worker;
|
|
11775
12390
|
}
|
|
11776
12391
|
const docParams = {
|
|
@@ -11835,21 +12450,7 @@ function getDocument(src = {}) {
|
|
|
11835
12450
|
if (!url) {
|
|
11836
12451
|
throw new Error("getDocument - no `url` parameter provided.");
|
|
11837
12452
|
}
|
|
11838
|
-
|
|
11839
|
-
if (isNodeJS) {
|
|
11840
|
-
if (isValidFetchUrl(url)) {
|
|
11841
|
-
if (typeof fetch === "undefined" || typeof Response === "undefined" || !("body" in Response.prototype)) {
|
|
11842
|
-
throw new Error(
|
|
11843
|
-
"getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`."
|
|
11844
|
-
);
|
|
11845
|
-
}
|
|
11846
|
-
NetworkStream = PDFFetchStream;
|
|
11847
|
-
} else {
|
|
11848
|
-
NetworkStream = PDFNodeStream;
|
|
11849
|
-
}
|
|
11850
|
-
} else {
|
|
11851
|
-
NetworkStream = isValidFetchUrl(url) ? PDFFetchStream : PDFNetworkStream;
|
|
11852
|
-
}
|
|
12453
|
+
const NetworkStream = isValidFetchUrl(url) ? PDFFetchStream : isNodeJS ? PDFNodeStream : PDFNetworkStream;
|
|
11853
12454
|
networkStream = new NetworkStream({
|
|
11854
12455
|
url,
|
|
11855
12456
|
length,
|
|
@@ -11881,64 +12482,6 @@ function getDocument(src = {}) {
|
|
|
11881
12482
|
}).catch(task._capability.reject);
|
|
11882
12483
|
return task;
|
|
11883
12484
|
}
|
|
11884
|
-
function getUrlProp(val) {
|
|
11885
|
-
if (false) {
|
|
11886
|
-
return null;
|
|
11887
|
-
}
|
|
11888
|
-
if (val instanceof URL) {
|
|
11889
|
-
return val.href;
|
|
11890
|
-
}
|
|
11891
|
-
if (typeof val === "string") {
|
|
11892
|
-
if (isNodeJS) {
|
|
11893
|
-
return val;
|
|
11894
|
-
}
|
|
11895
|
-
const url = URL.parse(val, window.location);
|
|
11896
|
-
if (url) {
|
|
11897
|
-
return url.href;
|
|
11898
|
-
}
|
|
11899
|
-
}
|
|
11900
|
-
throw new Error(
|
|
11901
|
-
"Invalid PDF url data: either string or URL-object is expected in the url property."
|
|
11902
|
-
);
|
|
11903
|
-
}
|
|
11904
|
-
function getDataProp(val) {
|
|
11905
|
-
if (isNodeJS && typeof Buffer !== "undefined" && // eslint-disable-line no-undef
|
|
11906
|
-
val instanceof Buffer) {
|
|
11907
|
-
throw new Error(
|
|
11908
|
-
"Please provide binary data as `Uint8Array`, rather than `Buffer`."
|
|
11909
|
-
);
|
|
11910
|
-
}
|
|
11911
|
-
if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
|
|
11912
|
-
return val;
|
|
11913
|
-
}
|
|
11914
|
-
if (typeof val === "string") {
|
|
11915
|
-
return stringToBytes(val);
|
|
11916
|
-
}
|
|
11917
|
-
if (val instanceof ArrayBuffer || ArrayBuffer.isView(val) || typeof val === "object" && !isNaN(val?.length)) {
|
|
11918
|
-
return new Uint8Array(val);
|
|
11919
|
-
}
|
|
11920
|
-
throw new Error(
|
|
11921
|
-
"Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property."
|
|
11922
|
-
);
|
|
11923
|
-
}
|
|
11924
|
-
function getFactoryUrlProp(val) {
|
|
11925
|
-
if (typeof val !== "string") {
|
|
11926
|
-
return null;
|
|
11927
|
-
}
|
|
11928
|
-
if (val.endsWith("/")) {
|
|
11929
|
-
return val;
|
|
11930
|
-
}
|
|
11931
|
-
throw new Error(`Invalid factory url: "${val}" must include trailing slash.`);
|
|
11932
|
-
}
|
|
11933
|
-
var isRefProxy = (v) => typeof v === "object" && Number.isInteger(v?.num) && v.num >= 0 && Number.isInteger(v?.gen) && v.gen >= 0;
|
|
11934
|
-
var isNameProxy = (v) => typeof v === "object" && typeof v?.name === "string";
|
|
11935
|
-
var isValidExplicitDest = _isValidExplicitDest.bind(
|
|
11936
|
-
null,
|
|
11937
|
-
/* validRef = */
|
|
11938
|
-
isRefProxy,
|
|
11939
|
-
/* validName = */
|
|
11940
|
-
isNameProxy
|
|
11941
|
-
);
|
|
11942
12485
|
var _docId2;
|
|
11943
12486
|
var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
11944
12487
|
constructor() {
|
|
@@ -11993,20 +12536,16 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
11993
12536
|
*/
|
|
11994
12537
|
async destroy() {
|
|
11995
12538
|
this.destroyed = true;
|
|
11996
|
-
|
|
12539
|
+
try {
|
|
12540
|
+
if (this._worker?.port) {
|
|
12541
|
+
this._worker._pendingDestroy = true;
|
|
12542
|
+
}
|
|
11997
12543
|
await this._transport?.destroy();
|
|
11998
|
-
}
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
this._worker._pendingDestroy = true;
|
|
12002
|
-
}
|
|
12003
|
-
await this._transport?.destroy();
|
|
12004
|
-
} catch (ex) {
|
|
12005
|
-
if (this._worker?.port) {
|
|
12006
|
-
delete this._worker._pendingDestroy;
|
|
12007
|
-
}
|
|
12008
|
-
throw ex;
|
|
12544
|
+
} catch (ex) {
|
|
12545
|
+
if (this._worker?.port) {
|
|
12546
|
+
delete this._worker._pendingDestroy;
|
|
12009
12547
|
}
|
|
12548
|
+
throw ex;
|
|
12010
12549
|
}
|
|
12011
12550
|
this._transport = null;
|
|
12012
12551
|
this._worker?.destroy();
|
|
@@ -12025,6 +12564,7 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
12025
12564
|
_docId2 = new WeakMap();
|
|
12026
12565
|
__privateAdd(_PDFDocumentLoadingTask, _docId2, 0);
|
|
12027
12566
|
var PDFDocumentLoadingTask = _PDFDocumentLoadingTask;
|
|
12567
|
+
var _capability2, _progressiveDoneListeners, _progressiveReadListeners, _progressListeners, _rangeListeners;
|
|
12028
12568
|
var PDFDataRangeTransport = class {
|
|
12029
12569
|
/**
|
|
12030
12570
|
* @param {number} length
|
|
@@ -12033,46 +12573,46 @@ var PDFDataRangeTransport = class {
|
|
|
12033
12573
|
* @param {string} [contentDispositionFilename]
|
|
12034
12574
|
*/
|
|
12035
12575
|
constructor(length, initialData, progressiveDone = false, contentDispositionFilename = null) {
|
|
12576
|
+
__privateAdd(this, _capability2, Promise.withResolvers());
|
|
12577
|
+
__privateAdd(this, _progressiveDoneListeners, []);
|
|
12578
|
+
__privateAdd(this, _progressiveReadListeners, []);
|
|
12579
|
+
__privateAdd(this, _progressListeners, []);
|
|
12580
|
+
__privateAdd(this, _rangeListeners, []);
|
|
12036
12581
|
this.length = length;
|
|
12037
12582
|
this.initialData = initialData;
|
|
12038
12583
|
this.progressiveDone = progressiveDone;
|
|
12039
12584
|
this.contentDispositionFilename = contentDispositionFilename;
|
|
12040
|
-
this._rangeListeners = [];
|
|
12041
|
-
this._progressListeners = [];
|
|
12042
|
-
this._progressiveReadListeners = [];
|
|
12043
|
-
this._progressiveDoneListeners = [];
|
|
12044
|
-
this._readyCapability = Promise.withResolvers();
|
|
12045
12585
|
}
|
|
12046
12586
|
/**
|
|
12047
12587
|
* @param {function} listener
|
|
12048
12588
|
*/
|
|
12049
12589
|
addRangeListener(listener) {
|
|
12050
|
-
this
|
|
12590
|
+
__privateGet(this, _rangeListeners).push(listener);
|
|
12051
12591
|
}
|
|
12052
12592
|
/**
|
|
12053
12593
|
* @param {function} listener
|
|
12054
12594
|
*/
|
|
12055
12595
|
addProgressListener(listener) {
|
|
12056
|
-
this
|
|
12596
|
+
__privateGet(this, _progressListeners).push(listener);
|
|
12057
12597
|
}
|
|
12058
12598
|
/**
|
|
12059
12599
|
* @param {function} listener
|
|
12060
12600
|
*/
|
|
12061
12601
|
addProgressiveReadListener(listener) {
|
|
12062
|
-
this
|
|
12602
|
+
__privateGet(this, _progressiveReadListeners).push(listener);
|
|
12063
12603
|
}
|
|
12064
12604
|
/**
|
|
12065
12605
|
* @param {function} listener
|
|
12066
12606
|
*/
|
|
12067
12607
|
addProgressiveDoneListener(listener) {
|
|
12068
|
-
this
|
|
12608
|
+
__privateGet(this, _progressiveDoneListeners).push(listener);
|
|
12069
12609
|
}
|
|
12070
12610
|
/**
|
|
12071
12611
|
* @param {number} begin
|
|
12072
12612
|
* @param {Uint8Array|null} chunk
|
|
12073
12613
|
*/
|
|
12074
12614
|
onDataRange(begin, chunk) {
|
|
12075
|
-
for (const listener of this
|
|
12615
|
+
for (const listener of __privateGet(this, _rangeListeners)) {
|
|
12076
12616
|
listener(begin, chunk);
|
|
12077
12617
|
}
|
|
12078
12618
|
}
|
|
@@ -12081,8 +12621,8 @@ var PDFDataRangeTransport = class {
|
|
|
12081
12621
|
* @param {number|undefined} total
|
|
12082
12622
|
*/
|
|
12083
12623
|
onDataProgress(loaded, total) {
|
|
12084
|
-
this.
|
|
12085
|
-
for (const listener of this
|
|
12624
|
+
__privateGet(this, _capability2).promise.then(() => {
|
|
12625
|
+
for (const listener of __privateGet(this, _progressListeners)) {
|
|
12086
12626
|
listener(loaded, total);
|
|
12087
12627
|
}
|
|
12088
12628
|
});
|
|
@@ -12091,21 +12631,21 @@ var PDFDataRangeTransport = class {
|
|
|
12091
12631
|
* @param {Uint8Array|null} chunk
|
|
12092
12632
|
*/
|
|
12093
12633
|
onDataProgressiveRead(chunk) {
|
|
12094
|
-
this.
|
|
12095
|
-
for (const listener of this
|
|
12634
|
+
__privateGet(this, _capability2).promise.then(() => {
|
|
12635
|
+
for (const listener of __privateGet(this, _progressiveReadListeners)) {
|
|
12096
12636
|
listener(chunk);
|
|
12097
12637
|
}
|
|
12098
12638
|
});
|
|
12099
12639
|
}
|
|
12100
12640
|
onDataProgressiveDone() {
|
|
12101
|
-
this.
|
|
12102
|
-
for (const listener of this
|
|
12641
|
+
__privateGet(this, _capability2).promise.then(() => {
|
|
12642
|
+
for (const listener of __privateGet(this, _progressiveDoneListeners)) {
|
|
12103
12643
|
listener();
|
|
12104
12644
|
}
|
|
12105
12645
|
});
|
|
12106
12646
|
}
|
|
12107
12647
|
transportReady() {
|
|
12108
|
-
this.
|
|
12648
|
+
__privateGet(this, _capability2).resolve();
|
|
12109
12649
|
}
|
|
12110
12650
|
/**
|
|
12111
12651
|
* @param {number} begin
|
|
@@ -12117,6 +12657,11 @@ var PDFDataRangeTransport = class {
|
|
|
12117
12657
|
abort() {
|
|
12118
12658
|
}
|
|
12119
12659
|
};
|
|
12660
|
+
_capability2 = new WeakMap();
|
|
12661
|
+
_progressiveDoneListeners = new WeakMap();
|
|
12662
|
+
_progressiveReadListeners = new WeakMap();
|
|
12663
|
+
_progressListeners = new WeakMap();
|
|
12664
|
+
_rangeListeners = new WeakMap();
|
|
12120
12665
|
var PDFDocumentProxy = class {
|
|
12121
12666
|
constructor(pdfInfo, transport) {
|
|
12122
12667
|
this._pdfInfo = pdfInfo;
|
|
@@ -12992,51 +13537,7 @@ tryCleanup_fn = function() {
|
|
|
12992
13537
|
__privateSet(this, _pendingCleanup, false);
|
|
12993
13538
|
return true;
|
|
12994
13539
|
};
|
|
12995
|
-
var
|
|
12996
|
-
var LoopbackPort = class {
|
|
12997
|
-
constructor() {
|
|
12998
|
-
__privateAdd(this, _listeners, /* @__PURE__ */ new Map());
|
|
12999
|
-
__privateAdd(this, _deferred, Promise.resolve());
|
|
13000
|
-
}
|
|
13001
|
-
postMessage(obj, transfer) {
|
|
13002
|
-
const event = {
|
|
13003
|
-
data: structuredClone(obj, transfer ? { transfer } : null)
|
|
13004
|
-
};
|
|
13005
|
-
__privateGet(this, _deferred).then(() => {
|
|
13006
|
-
for (const [listener] of __privateGet(this, _listeners)) {
|
|
13007
|
-
listener.call(this, event);
|
|
13008
|
-
}
|
|
13009
|
-
});
|
|
13010
|
-
}
|
|
13011
|
-
addEventListener(name, listener, options = null) {
|
|
13012
|
-
let rmAbort = null;
|
|
13013
|
-
if (options?.signal instanceof AbortSignal) {
|
|
13014
|
-
const { signal } = options;
|
|
13015
|
-
if (signal.aborted) {
|
|
13016
|
-
warn("LoopbackPort - cannot use an `aborted` signal.");
|
|
13017
|
-
return;
|
|
13018
|
-
}
|
|
13019
|
-
const onAbort = () => this.removeEventListener(name, listener);
|
|
13020
|
-
rmAbort = () => signal.removeEventListener("abort", onAbort);
|
|
13021
|
-
signal.addEventListener("abort", onAbort);
|
|
13022
|
-
}
|
|
13023
|
-
__privateGet(this, _listeners).set(listener, rmAbort);
|
|
13024
|
-
}
|
|
13025
|
-
removeEventListener(name, listener) {
|
|
13026
|
-
const rmAbort = __privateGet(this, _listeners).get(listener);
|
|
13027
|
-
rmAbort?.();
|
|
13028
|
-
__privateGet(this, _listeners).delete(listener);
|
|
13029
|
-
}
|
|
13030
|
-
terminate() {
|
|
13031
|
-
for (const [, rmAbort] of __privateGet(this, _listeners)) {
|
|
13032
|
-
rmAbort?.();
|
|
13033
|
-
}
|
|
13034
|
-
__privateGet(this, _listeners).clear();
|
|
13035
|
-
}
|
|
13036
|
-
};
|
|
13037
|
-
_listeners = new WeakMap();
|
|
13038
|
-
_deferred = new WeakMap();
|
|
13039
|
-
var _a, _fakeWorkerId, _isWorkerDisabled, _workerPorts, _PDFWorker_instances, resolve_fn, _PDFWorker_static, mainThreadWorkerMessageHandler_get;
|
|
13540
|
+
var _a, _capability3, _messageHandler, _port2, _webWorker, _fakeWorkerId, _isWorkerDisabled, _workerPorts, _PDFWorker_instances, resolve_fn, initializeFromPort_fn, initialize_fn, setupFakeWorker_fn, _PDFWorker_static, mainThreadWorkerMessageHandler_get;
|
|
13040
13541
|
var _PDFWorker = class _PDFWorker {
|
|
13041
13542
|
constructor({
|
|
13042
13543
|
name = null,
|
|
@@ -13044,173 +13545,73 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13044
13545
|
verbosity = getVerbosityLevel()
|
|
13045
13546
|
} = {}) {
|
|
13046
13547
|
__privateAdd(this, _PDFWorker_instances);
|
|
13548
|
+
__privateAdd(this, _capability3, Promise.withResolvers());
|
|
13549
|
+
__privateAdd(this, _messageHandler, null);
|
|
13550
|
+
__privateAdd(this, _port2, null);
|
|
13551
|
+
__privateAdd(this, _webWorker, null);
|
|
13047
13552
|
this.name = name;
|
|
13048
13553
|
this.destroyed = false;
|
|
13049
13554
|
this.verbosity = verbosity;
|
|
13050
|
-
this._readyCapability = Promise.withResolvers();
|
|
13051
|
-
this._port = null;
|
|
13052
|
-
this._webWorker = null;
|
|
13053
|
-
this._messageHandler = null;
|
|
13054
13555
|
if (port) {
|
|
13055
|
-
if (__privateGet(_PDFWorker, _workerPorts)
|
|
13556
|
+
if (__privateGet(_PDFWorker, _workerPorts).has(port)) {
|
|
13056
13557
|
throw new Error("Cannot use more than one PDFWorker per port.");
|
|
13057
13558
|
}
|
|
13058
|
-
|
|
13059
|
-
this.
|
|
13060
|
-
|
|
13559
|
+
__privateGet(_PDFWorker, _workerPorts).set(port, this);
|
|
13560
|
+
__privateMethod(this, _PDFWorker_instances, initializeFromPort_fn).call(this, port);
|
|
13561
|
+
} else {
|
|
13562
|
+
__privateMethod(this, _PDFWorker_instances, initialize_fn).call(this);
|
|
13563
|
+
}
|
|
13564
|
+
if (false) {
|
|
13565
|
+
Object.defineProperty(this, "_webWorker", {
|
|
13566
|
+
get() {
|
|
13567
|
+
return __privateGet(this, _webWorker);
|
|
13568
|
+
}
|
|
13569
|
+
});
|
|
13061
13570
|
}
|
|
13062
|
-
this._initialize();
|
|
13063
13571
|
}
|
|
13064
13572
|
/**
|
|
13065
13573
|
* Promise for worker initialization completion.
|
|
13066
13574
|
* @type {Promise<void>}
|
|
13067
13575
|
*/
|
|
13068
13576
|
get promise() {
|
|
13069
|
-
return this.
|
|
13577
|
+
return __privateGet(this, _capability3).promise;
|
|
13070
13578
|
}
|
|
13071
13579
|
/**
|
|
13072
13580
|
* The current `workerPort`, when it exists.
|
|
13073
13581
|
* @type {Worker}
|
|
13074
13582
|
*/
|
|
13075
13583
|
get port() {
|
|
13076
|
-
return this
|
|
13584
|
+
return __privateGet(this, _port2);
|
|
13077
13585
|
}
|
|
13078
13586
|
/**
|
|
13079
13587
|
* The current MessageHandler-instance.
|
|
13080
13588
|
* @type {MessageHandler}
|
|
13081
13589
|
*/
|
|
13082
13590
|
get messageHandler() {
|
|
13083
|
-
return this
|
|
13084
|
-
}
|
|
13085
|
-
_initializeFromPort(port) {
|
|
13086
|
-
if (false) {
|
|
13087
|
-
throw new Error("Not implemented: _initializeFromPort");
|
|
13088
|
-
}
|
|
13089
|
-
this._port = port;
|
|
13090
|
-
this._messageHandler = new MessageHandler("main", "worker", port);
|
|
13091
|
-
this._messageHandler.on("ready", function() {
|
|
13092
|
-
});
|
|
13093
|
-
__privateMethod(this, _PDFWorker_instances, resolve_fn).call(this);
|
|
13094
|
-
}
|
|
13095
|
-
_initialize() {
|
|
13096
|
-
if (__privateGet(_PDFWorker, _isWorkerDisabled) || __privateGet(_PDFWorker, _PDFWorker_static, mainThreadWorkerMessageHandler_get)) {
|
|
13097
|
-
this._setupFakeWorker();
|
|
13098
|
-
return;
|
|
13099
|
-
}
|
|
13100
|
-
let { workerSrc } = _PDFWorker;
|
|
13101
|
-
try {
|
|
13102
|
-
if (!_PDFWorker._isSameOrigin(window.location, workerSrc)) {
|
|
13103
|
-
workerSrc = _PDFWorker._createCDNWrapper(
|
|
13104
|
-
new URL(workerSrc, window.location).href
|
|
13105
|
-
);
|
|
13106
|
-
}
|
|
13107
|
-
const worker = new Worker(workerSrc, { type: "module" });
|
|
13108
|
-
const messageHandler = new MessageHandler("main", "worker", worker);
|
|
13109
|
-
const terminateEarly = () => {
|
|
13110
|
-
ac.abort();
|
|
13111
|
-
messageHandler.destroy();
|
|
13112
|
-
worker.terminate();
|
|
13113
|
-
if (this.destroyed) {
|
|
13114
|
-
this._readyCapability.reject(new Error("Worker was destroyed"));
|
|
13115
|
-
} else {
|
|
13116
|
-
this._setupFakeWorker();
|
|
13117
|
-
}
|
|
13118
|
-
};
|
|
13119
|
-
const ac = new AbortController();
|
|
13120
|
-
worker.addEventListener(
|
|
13121
|
-
"error",
|
|
13122
|
-
() => {
|
|
13123
|
-
if (!this._webWorker) {
|
|
13124
|
-
terminateEarly();
|
|
13125
|
-
}
|
|
13126
|
-
},
|
|
13127
|
-
{ signal: ac.signal }
|
|
13128
|
-
);
|
|
13129
|
-
messageHandler.on("test", (data) => {
|
|
13130
|
-
ac.abort();
|
|
13131
|
-
if (this.destroyed || !data) {
|
|
13132
|
-
terminateEarly();
|
|
13133
|
-
return;
|
|
13134
|
-
}
|
|
13135
|
-
this._messageHandler = messageHandler;
|
|
13136
|
-
this._port = worker;
|
|
13137
|
-
this._webWorker = worker;
|
|
13138
|
-
__privateMethod(this, _PDFWorker_instances, resolve_fn).call(this);
|
|
13139
|
-
});
|
|
13140
|
-
messageHandler.on("ready", (data) => {
|
|
13141
|
-
ac.abort();
|
|
13142
|
-
if (this.destroyed) {
|
|
13143
|
-
terminateEarly();
|
|
13144
|
-
return;
|
|
13145
|
-
}
|
|
13146
|
-
try {
|
|
13147
|
-
sendTest();
|
|
13148
|
-
} catch {
|
|
13149
|
-
this._setupFakeWorker();
|
|
13150
|
-
}
|
|
13151
|
-
});
|
|
13152
|
-
const sendTest = () => {
|
|
13153
|
-
const testObj = new Uint8Array();
|
|
13154
|
-
messageHandler.send("test", testObj, [testObj.buffer]);
|
|
13155
|
-
};
|
|
13156
|
-
sendTest();
|
|
13157
|
-
return;
|
|
13158
|
-
} catch {
|
|
13159
|
-
info("The worker has been disabled.");
|
|
13160
|
-
}
|
|
13161
|
-
this._setupFakeWorker();
|
|
13162
|
-
}
|
|
13163
|
-
_setupFakeWorker() {
|
|
13164
|
-
if (!__privateGet(_PDFWorker, _isWorkerDisabled)) {
|
|
13165
|
-
warn("Setting up fake worker.");
|
|
13166
|
-
__privateSet(_PDFWorker, _isWorkerDisabled, true);
|
|
13167
|
-
}
|
|
13168
|
-
_PDFWorker._setupFakeWorkerGlobal.then((WorkerMessageHandler) => {
|
|
13169
|
-
if (this.destroyed) {
|
|
13170
|
-
this._readyCapability.reject(new Error("Worker was destroyed"));
|
|
13171
|
-
return;
|
|
13172
|
-
}
|
|
13173
|
-
const port = new LoopbackPort();
|
|
13174
|
-
this._port = port;
|
|
13175
|
-
const id = `fake${__privateWrapper(_PDFWorker, _fakeWorkerId)._++}`;
|
|
13176
|
-
const workerHandler = new MessageHandler(id + "_worker", id, port);
|
|
13177
|
-
WorkerMessageHandler.setup(workerHandler, port);
|
|
13178
|
-
this._messageHandler = new MessageHandler(id, id + "_worker", port);
|
|
13179
|
-
__privateMethod(this, _PDFWorker_instances, resolve_fn).call(this);
|
|
13180
|
-
}).catch((reason) => {
|
|
13181
|
-
this._readyCapability.reject(
|
|
13182
|
-
new Error(`Setting up fake worker failed: "${reason.message}".`)
|
|
13183
|
-
);
|
|
13184
|
-
});
|
|
13591
|
+
return __privateGet(this, _messageHandler);
|
|
13185
13592
|
}
|
|
13186
13593
|
/**
|
|
13187
13594
|
* Destroys the worker instance.
|
|
13188
13595
|
*/
|
|
13189
13596
|
destroy() {
|
|
13190
13597
|
this.destroyed = true;
|
|
13191
|
-
this
|
|
13192
|
-
this
|
|
13193
|
-
__privateGet(_PDFWorker, _workerPorts)
|
|
13194
|
-
this
|
|
13195
|
-
this
|
|
13196
|
-
this
|
|
13598
|
+
__privateGet(this, _webWorker)?.terminate();
|
|
13599
|
+
__privateSet(this, _webWorker, null);
|
|
13600
|
+
__privateGet(_PDFWorker, _workerPorts).delete(__privateGet(this, _port2));
|
|
13601
|
+
__privateSet(this, _port2, null);
|
|
13602
|
+
__privateGet(this, _messageHandler)?.destroy();
|
|
13603
|
+
__privateSet(this, _messageHandler, null);
|
|
13197
13604
|
}
|
|
13198
13605
|
/**
|
|
13199
13606
|
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
|
13200
13607
|
* @returns {PDFWorker}
|
|
13201
13608
|
*/
|
|
13202
|
-
static
|
|
13203
|
-
|
|
13204
|
-
throw new Error("Not implemented: fromPort");
|
|
13205
|
-
}
|
|
13206
|
-
if (!params?.port) {
|
|
13207
|
-
throw new Error("PDFWorker.fromPort - invalid method signature.");
|
|
13208
|
-
}
|
|
13209
|
-
const cachedPort = __privateGet(this, _workerPorts)?.get(params.port);
|
|
13609
|
+
static create(params) {
|
|
13610
|
+
const cachedPort = __privateGet(this, _workerPorts).get(params?.port);
|
|
13210
13611
|
if (cachedPort) {
|
|
13211
13612
|
if (cachedPort._pendingDestroy) {
|
|
13212
13613
|
throw new Error(
|
|
13213
|
-
"PDFWorker.
|
|
13614
|
+
"PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls."
|
|
13214
13615
|
);
|
|
13215
13616
|
}
|
|
13216
13617
|
return cachedPort;
|
|
@@ -13233,20 +13634,122 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13233
13634
|
if (__privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get)) {
|
|
13234
13635
|
return __privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get);
|
|
13235
13636
|
}
|
|
13236
|
-
const worker = true ? await import("./worker.js") : await __raw_import__(this.workerSrc);
|
|
13237
|
-
return worker.WorkerMessageHandler;
|
|
13637
|
+
const worker = true ? await import("./worker.js") : await __raw_import__(this.workerSrc);
|
|
13638
|
+
return worker.WorkerMessageHandler;
|
|
13639
|
+
};
|
|
13640
|
+
return shadow(this, "_setupFakeWorkerGlobal", loader());
|
|
13641
|
+
}
|
|
13642
|
+
};
|
|
13643
|
+
_capability3 = new WeakMap();
|
|
13644
|
+
_messageHandler = new WeakMap();
|
|
13645
|
+
_port2 = new WeakMap();
|
|
13646
|
+
_webWorker = new WeakMap();
|
|
13647
|
+
_fakeWorkerId = new WeakMap();
|
|
13648
|
+
_isWorkerDisabled = new WeakMap();
|
|
13649
|
+
_workerPorts = new WeakMap();
|
|
13650
|
+
_PDFWorker_instances = new WeakSet();
|
|
13651
|
+
resolve_fn = function() {
|
|
13652
|
+
__privateGet(this, _capability3).resolve();
|
|
13653
|
+
__privateGet(this, _messageHandler).send("configure", {
|
|
13654
|
+
verbosity: this.verbosity
|
|
13655
|
+
});
|
|
13656
|
+
};
|
|
13657
|
+
initializeFromPort_fn = function(port) {
|
|
13658
|
+
__privateSet(this, _port2, port);
|
|
13659
|
+
__privateSet(this, _messageHandler, new MessageHandler("main", "worker", port));
|
|
13660
|
+
__privateGet(this, _messageHandler).on("ready", () => {
|
|
13661
|
+
});
|
|
13662
|
+
__privateMethod(this, _PDFWorker_instances, resolve_fn).call(this);
|
|
13663
|
+
};
|
|
13664
|
+
initialize_fn = function() {
|
|
13665
|
+
if (__privateGet(_PDFWorker, _isWorkerDisabled) || __privateGet(_PDFWorker, _PDFWorker_static, mainThreadWorkerMessageHandler_get)) {
|
|
13666
|
+
__privateMethod(this, _PDFWorker_instances, setupFakeWorker_fn).call(this);
|
|
13667
|
+
return;
|
|
13668
|
+
}
|
|
13669
|
+
let { workerSrc } = _PDFWorker;
|
|
13670
|
+
try {
|
|
13671
|
+
if (!_PDFWorker._isSameOrigin(window.location, workerSrc)) {
|
|
13672
|
+
workerSrc = _PDFWorker._createCDNWrapper(
|
|
13673
|
+
new URL(workerSrc, window.location).href
|
|
13674
|
+
);
|
|
13675
|
+
}
|
|
13676
|
+
const worker = new Worker(workerSrc, { type: "module" });
|
|
13677
|
+
const messageHandler = new MessageHandler("main", "worker", worker);
|
|
13678
|
+
const terminateEarly = () => {
|
|
13679
|
+
ac.abort();
|
|
13680
|
+
messageHandler.destroy();
|
|
13681
|
+
worker.terminate();
|
|
13682
|
+
if (this.destroyed) {
|
|
13683
|
+
__privateGet(this, _capability3).reject(new Error("Worker was destroyed"));
|
|
13684
|
+
} else {
|
|
13685
|
+
__privateMethod(this, _PDFWorker_instances, setupFakeWorker_fn).call(this);
|
|
13686
|
+
}
|
|
13687
|
+
};
|
|
13688
|
+
const ac = new AbortController();
|
|
13689
|
+
worker.addEventListener(
|
|
13690
|
+
"error",
|
|
13691
|
+
() => {
|
|
13692
|
+
if (!__privateGet(this, _webWorker)) {
|
|
13693
|
+
terminateEarly();
|
|
13694
|
+
}
|
|
13695
|
+
},
|
|
13696
|
+
{ signal: ac.signal }
|
|
13697
|
+
);
|
|
13698
|
+
messageHandler.on("test", (data) => {
|
|
13699
|
+
ac.abort();
|
|
13700
|
+
if (this.destroyed || !data) {
|
|
13701
|
+
terminateEarly();
|
|
13702
|
+
return;
|
|
13703
|
+
}
|
|
13704
|
+
__privateSet(this, _messageHandler, messageHandler);
|
|
13705
|
+
__privateSet(this, _port2, worker);
|
|
13706
|
+
__privateSet(this, _webWorker, worker);
|
|
13707
|
+
__privateMethod(this, _PDFWorker_instances, resolve_fn).call(this);
|
|
13708
|
+
});
|
|
13709
|
+
messageHandler.on("ready", (data) => {
|
|
13710
|
+
ac.abort();
|
|
13711
|
+
if (this.destroyed) {
|
|
13712
|
+
terminateEarly();
|
|
13713
|
+
return;
|
|
13714
|
+
}
|
|
13715
|
+
try {
|
|
13716
|
+
sendTest();
|
|
13717
|
+
} catch {
|
|
13718
|
+
__privateMethod(this, _PDFWorker_instances, setupFakeWorker_fn).call(this);
|
|
13719
|
+
}
|
|
13720
|
+
});
|
|
13721
|
+
const sendTest = () => {
|
|
13722
|
+
const testObj = new Uint8Array();
|
|
13723
|
+
messageHandler.send("test", testObj, [testObj.buffer]);
|
|
13238
13724
|
};
|
|
13239
|
-
|
|
13725
|
+
sendTest();
|
|
13726
|
+
return;
|
|
13727
|
+
} catch {
|
|
13728
|
+
info("The worker has been disabled.");
|
|
13240
13729
|
}
|
|
13730
|
+
__privateMethod(this, _PDFWorker_instances, setupFakeWorker_fn).call(this);
|
|
13241
13731
|
};
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13732
|
+
setupFakeWorker_fn = function() {
|
|
13733
|
+
if (!__privateGet(_PDFWorker, _isWorkerDisabled)) {
|
|
13734
|
+
warn("Setting up fake worker.");
|
|
13735
|
+
__privateSet(_PDFWorker, _isWorkerDisabled, true);
|
|
13736
|
+
}
|
|
13737
|
+
_PDFWorker._setupFakeWorkerGlobal.then((WorkerMessageHandler) => {
|
|
13738
|
+
if (this.destroyed) {
|
|
13739
|
+
__privateGet(this, _capability3).reject(new Error("Worker was destroyed"));
|
|
13740
|
+
return;
|
|
13741
|
+
}
|
|
13742
|
+
const port = new LoopbackPort();
|
|
13743
|
+
__privateSet(this, _port2, port);
|
|
13744
|
+
const id = `fake${__privateWrapper(_PDFWorker, _fakeWorkerId)._++}`;
|
|
13745
|
+
const workerHandler = new MessageHandler(id + "_worker", id, port);
|
|
13746
|
+
WorkerMessageHandler.setup(workerHandler, port);
|
|
13747
|
+
__privateSet(this, _messageHandler, new MessageHandler(id, id + "_worker", port));
|
|
13748
|
+
__privateMethod(this, _PDFWorker_instances, resolve_fn).call(this);
|
|
13749
|
+
}).catch((reason) => {
|
|
13750
|
+
__privateGet(this, _capability3).reject(
|
|
13751
|
+
new Error(`Setting up fake worker failed: "${reason.message}".`)
|
|
13752
|
+
);
|
|
13250
13753
|
});
|
|
13251
13754
|
};
|
|
13252
13755
|
_PDFWorker_static = new WeakSet();
|
|
@@ -13260,7 +13763,7 @@ mainThreadWorkerMessageHandler_get = function() {
|
|
|
13260
13763
|
__privateAdd(_PDFWorker, _PDFWorker_static);
|
|
13261
13764
|
__privateAdd(_PDFWorker, _fakeWorkerId, 0);
|
|
13262
13765
|
__privateAdd(_PDFWorker, _isWorkerDisabled, false);
|
|
13263
|
-
__privateAdd(_PDFWorker, _workerPorts);
|
|
13766
|
+
__privateAdd(_PDFWorker, _workerPorts, /* @__PURE__ */ new WeakMap());
|
|
13264
13767
|
(() => {
|
|
13265
13768
|
if (true) {
|
|
13266
13769
|
if (isNodeJS) {
|
|
@@ -13281,6 +13784,21 @@ __privateAdd(_PDFWorker, _workerPorts);
|
|
|
13281
13784
|
new Blob([wrapper], { type: "text/javascript" })
|
|
13282
13785
|
);
|
|
13283
13786
|
};
|
|
13787
|
+
_PDFWorker.fromPort = (params) => {
|
|
13788
|
+
deprecated(
|
|
13789
|
+
"`PDFWorker.fromPort` - please use `PDFWorker.create` instead."
|
|
13790
|
+
);
|
|
13791
|
+
if (!params?.port) {
|
|
13792
|
+
throw new Error("PDFWorker.fromPort - invalid method signature.");
|
|
13793
|
+
}
|
|
13794
|
+
return _PDFWorker.create(params);
|
|
13795
|
+
};
|
|
13796
|
+
}
|
|
13797
|
+
if (false) {
|
|
13798
|
+
_PDFWorker._resetGlobalState = () => {
|
|
13799
|
+
__privateSet(_PDFWorker, _isWorkerDisabled, false);
|
|
13800
|
+
delete globalThis.pdfjsWorker;
|
|
13801
|
+
};
|
|
13284
13802
|
}
|
|
13285
13803
|
})();
|
|
13286
13804
|
var PDFWorker = _PDFWorker;
|
|
@@ -13846,100 +14364,6 @@ cacheSimpleMethod_fn = function(name, data = null) {
|
|
|
13846
14364
|
__privateGet(this, _methodPromises).set(name, promise);
|
|
13847
14365
|
return promise;
|
|
13848
14366
|
};
|
|
13849
|
-
var INITIAL_DATA = Symbol("INITIAL_DATA");
|
|
13850
|
-
var _objs, _PDFObjects_instances, ensureObj_fn;
|
|
13851
|
-
var PDFObjects = class {
|
|
13852
|
-
constructor() {
|
|
13853
|
-
__privateAdd(this, _PDFObjects_instances);
|
|
13854
|
-
__privateAdd(this, _objs, /* @__PURE__ */ Object.create(null));
|
|
13855
|
-
}
|
|
13856
|
-
/**
|
|
13857
|
-
* If called *without* callback, this returns the data of `objId` but the
|
|
13858
|
-
* object needs to be resolved. If it isn't, this method throws.
|
|
13859
|
-
*
|
|
13860
|
-
* If called *with* a callback, the callback is called with the data of the
|
|
13861
|
-
* object once the object is resolved. That means, if you call this method
|
|
13862
|
-
* and the object is already resolved, the callback gets called right away.
|
|
13863
|
-
*
|
|
13864
|
-
* @param {string} objId
|
|
13865
|
-
* @param {function} [callback]
|
|
13866
|
-
* @returns {any}
|
|
13867
|
-
*/
|
|
13868
|
-
get(objId, callback = null) {
|
|
13869
|
-
if (callback) {
|
|
13870
|
-
const obj2 = __privateMethod(this, _PDFObjects_instances, ensureObj_fn).call(this, objId);
|
|
13871
|
-
obj2.promise.then(() => callback(obj2.data));
|
|
13872
|
-
return null;
|
|
13873
|
-
}
|
|
13874
|
-
const obj = __privateGet(this, _objs)[objId];
|
|
13875
|
-
if (!obj || obj.data === INITIAL_DATA) {
|
|
13876
|
-
throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
|
|
13877
|
-
}
|
|
13878
|
-
return obj.data;
|
|
13879
|
-
}
|
|
13880
|
-
/**
|
|
13881
|
-
* @param {string} objId
|
|
13882
|
-
* @returns {boolean}
|
|
13883
|
-
*/
|
|
13884
|
-
has(objId) {
|
|
13885
|
-
const obj = __privateGet(this, _objs)[objId];
|
|
13886
|
-
return !!obj && obj.data !== INITIAL_DATA;
|
|
13887
|
-
}
|
|
13888
|
-
/**
|
|
13889
|
-
* @param {string} objId
|
|
13890
|
-
* @returns {boolean}
|
|
13891
|
-
*/
|
|
13892
|
-
delete(objId) {
|
|
13893
|
-
const obj = __privateGet(this, _objs)[objId];
|
|
13894
|
-
if (!obj || obj.data === INITIAL_DATA) {
|
|
13895
|
-
return false;
|
|
13896
|
-
}
|
|
13897
|
-
delete __privateGet(this, _objs)[objId];
|
|
13898
|
-
return true;
|
|
13899
|
-
}
|
|
13900
|
-
/**
|
|
13901
|
-
* Resolves the object `objId` with optional `data`.
|
|
13902
|
-
*
|
|
13903
|
-
* @param {string} objId
|
|
13904
|
-
* @param {any} [data]
|
|
13905
|
-
*/
|
|
13906
|
-
resolve(objId, data = null) {
|
|
13907
|
-
const obj = __privateMethod(this, _PDFObjects_instances, ensureObj_fn).call(this, objId);
|
|
13908
|
-
obj.data = data;
|
|
13909
|
-
obj.resolve();
|
|
13910
|
-
}
|
|
13911
|
-
clear() {
|
|
13912
|
-
for (const objId in __privateGet(this, _objs)) {
|
|
13913
|
-
const { data } = __privateGet(this, _objs)[objId];
|
|
13914
|
-
data?.bitmap?.close();
|
|
13915
|
-
}
|
|
13916
|
-
__privateSet(this, _objs, /* @__PURE__ */ Object.create(null));
|
|
13917
|
-
}
|
|
13918
|
-
*[Symbol.iterator]() {
|
|
13919
|
-
for (const objId in __privateGet(this, _objs)) {
|
|
13920
|
-
const { data } = __privateGet(this, _objs)[objId];
|
|
13921
|
-
if (data === INITIAL_DATA) {
|
|
13922
|
-
continue;
|
|
13923
|
-
}
|
|
13924
|
-
yield [objId, data];
|
|
13925
|
-
}
|
|
13926
|
-
}
|
|
13927
|
-
};
|
|
13928
|
-
_objs = new WeakMap();
|
|
13929
|
-
_PDFObjects_instances = new WeakSet();
|
|
13930
|
-
/**
|
|
13931
|
-
* Ensures there is an object defined for `objId`.
|
|
13932
|
-
*
|
|
13933
|
-
* @param {string} objId
|
|
13934
|
-
* @returns {Object}
|
|
13935
|
-
*/
|
|
13936
|
-
ensureObj_fn = function(objId) {
|
|
13937
|
-
var _a2;
|
|
13938
|
-
return (_a2 = __privateGet(this, _objs))[objId] || (_a2[objId] = {
|
|
13939
|
-
...Promise.withResolvers(),
|
|
13940
|
-
data: INITIAL_DATA
|
|
13941
|
-
});
|
|
13942
|
-
};
|
|
13943
14367
|
var _internalRenderTask;
|
|
13944
14368
|
var RenderTask = class {
|
|
13945
14369
|
constructor(internalRenderTask) {
|
|
@@ -17455,12 +17879,9 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17455
17879
|
}
|
|
17456
17880
|
/** @inheritdoc */
|
|
17457
17881
|
enableEditMode() {
|
|
17458
|
-
if (
|
|
17459
|
-
return;
|
|
17882
|
+
if (!super.enableEditMode()) {
|
|
17883
|
+
return false;
|
|
17460
17884
|
}
|
|
17461
|
-
this.parent.setEditingState(false);
|
|
17462
|
-
this.parent.updateToolbar(AnnotationEditorType.FREETEXT);
|
|
17463
|
-
super.enableEditMode();
|
|
17464
17885
|
this.overlayDiv.classList.remove("enabled");
|
|
17465
17886
|
this.editorDiv.contentEditable = true;
|
|
17466
17887
|
this._isDraggable = false;
|
|
@@ -17490,14 +17911,13 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17490
17911
|
this.editorDiv.addEventListener("paste", this.editorDivPaste.bind(this), {
|
|
17491
17912
|
signal
|
|
17492
17913
|
});
|
|
17914
|
+
return true;
|
|
17493
17915
|
}
|
|
17494
17916
|
/** @inheritdoc */
|
|
17495
17917
|
disableEditMode() {
|
|
17496
|
-
if (!
|
|
17497
|
-
return;
|
|
17918
|
+
if (!super.disableEditMode()) {
|
|
17919
|
+
return false;
|
|
17498
17920
|
}
|
|
17499
|
-
this.parent.setEditingState(true);
|
|
17500
|
-
super.disableEditMode();
|
|
17501
17921
|
this.overlayDiv.classList.add("enabled");
|
|
17502
17922
|
this.editorDiv.contentEditable = false;
|
|
17503
17923
|
this.div.setAttribute("aria-activedescendant", __privateGet(this, _editorDivId));
|
|
@@ -17509,6 +17929,7 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17509
17929
|
});
|
|
17510
17930
|
this.isEditing = false;
|
|
17511
17931
|
this.parent.div.classList.add("freetextEditing");
|
|
17932
|
+
return true;
|
|
17512
17933
|
}
|
|
17513
17934
|
/** @inheritdoc */
|
|
17514
17935
|
focusin(event) {
|
|
@@ -17592,17 +18013,7 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17592
18013
|
this.enableEditMode();
|
|
17593
18014
|
this.editorDiv.focus();
|
|
17594
18015
|
}
|
|
17595
|
-
/**
|
|
17596
|
-
* ondblclick callback.
|
|
17597
|
-
* @param {MouseEvent} event
|
|
17598
|
-
*/
|
|
17599
|
-
dblclick(event) {
|
|
17600
|
-
this.enterInEditMode();
|
|
17601
|
-
}
|
|
17602
|
-
/**
|
|
17603
|
-
* onkeydown callback.
|
|
17604
|
-
* @param {KeyboardEvent} event
|
|
17605
|
-
*/
|
|
18016
|
+
/** @inheritdoc */
|
|
17606
18017
|
keydown(event) {
|
|
17607
18018
|
if (event.target === this.div && event.key === "Enter") {
|
|
17608
18019
|
this.enterInEditMode();
|
|
@@ -17632,6 +18043,10 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17632
18043
|
this.editorDiv.setAttribute("aria-multiline", true);
|
|
17633
18044
|
}
|
|
17634
18045
|
/** @inheritdoc */
|
|
18046
|
+
get canChangeContent() {
|
|
18047
|
+
return true;
|
|
18048
|
+
}
|
|
18049
|
+
/** @inheritdoc */
|
|
17635
18050
|
render() {
|
|
17636
18051
|
if (this.div) {
|
|
17637
18052
|
return this.div;
|
|
@@ -17656,7 +18071,6 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17656
18071
|
this.overlayDiv = document.createElement("div");
|
|
17657
18072
|
this.overlayDiv.classList.add("overlay", "enabled");
|
|
17658
18073
|
this.div.append(this.overlayDiv);
|
|
17659
|
-
bindEvents(this, this.div, ["dblclick", "keydown"]);
|
|
17660
18074
|
if (this._isCopy || this.annotationElementId) {
|
|
17661
18075
|
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
17662
18076
|
if (this.annotationElementId) {
|
|
@@ -22487,14 +22901,8 @@ getGrayPixels_fn = function(bitmap) {
|
|
|
22487
22901
|
const isteps = Math.floor(steps);
|
|
22488
22902
|
steps = steps === isteps ? isteps - 1 : isteps;
|
|
22489
22903
|
for (let i = 0; i < steps; i++) {
|
|
22490
|
-
newWidth = prevWidth;
|
|
22491
|
-
newHeight = prevHeight;
|
|
22492
|
-
if (newWidth > maxDim) {
|
|
22493
|
-
newWidth = Math.ceil(newWidth / 2);
|
|
22494
|
-
}
|
|
22495
|
-
if (newHeight > maxDim) {
|
|
22496
|
-
newHeight = Math.ceil(newHeight / 2);
|
|
22497
|
-
}
|
|
22904
|
+
newWidth = Math.ceil(prevWidth / 2);
|
|
22905
|
+
newHeight = Math.ceil(prevHeight / 2);
|
|
22498
22906
|
const offscreen2 = new OffscreenCanvas(newWidth, newHeight);
|
|
22499
22907
|
const ctx2 = offscreen2.getContext("2d");
|
|
22500
22908
|
ctx2.drawImage(
|
|
@@ -22568,7 +22976,7 @@ var SignatureOptions = class _SignatureOptions extends DrawingOptions {
|
|
|
22568
22976
|
constructor() {
|
|
22569
22977
|
super();
|
|
22570
22978
|
super.updateProperties({
|
|
22571
|
-
fill:
|
|
22979
|
+
fill: AnnotationEditor._defaultLineColor,
|
|
22572
22980
|
"stroke-width": 0
|
|
22573
22981
|
});
|
|
22574
22982
|
}
|
|
@@ -22582,7 +22990,7 @@ var DrawnSignatureOptions = class _DrawnSignatureOptions extends InkDrawingOptio
|
|
|
22582
22990
|
constructor(viewerParameters) {
|
|
22583
22991
|
super(viewerParameters);
|
|
22584
22992
|
super.updateProperties({
|
|
22585
|
-
stroke:
|
|
22993
|
+
stroke: AnnotationEditor._defaultLineColor,
|
|
22586
22994
|
"stroke-width": 1
|
|
22587
22995
|
});
|
|
22588
22996
|
}
|
|
@@ -22955,9 +23363,10 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
22955
23363
|
}
|
|
22956
23364
|
/** @inheritdoc */
|
|
22957
23365
|
static paste(item, parent) {
|
|
22958
|
-
parent.pasteEditor(
|
|
22959
|
-
|
|
22960
|
-
|
|
23366
|
+
parent.pasteEditor(
|
|
23367
|
+
{ mode: AnnotationEditorType.STAMP },
|
|
23368
|
+
{ bitmapFile: item.getAsFile() }
|
|
23369
|
+
);
|
|
22961
23370
|
}
|
|
22962
23371
|
/** @inheritdoc */
|
|
22963
23372
|
altTextFinish() {
|
|
@@ -23722,10 +24131,10 @@ var _AnnotationEditorLayer = class _AnnotationEditorLayer {
|
|
|
23722
24131
|
}
|
|
23723
24132
|
/**
|
|
23724
24133
|
* Update the toolbar if it's required to reflect the tool currently used.
|
|
23725
|
-
* @param {
|
|
24134
|
+
* @param {Object} options
|
|
23726
24135
|
*/
|
|
23727
|
-
updateToolbar(
|
|
23728
|
-
__privateGet(this, _uiManager3).updateToolbar(
|
|
24136
|
+
updateToolbar(options) {
|
|
24137
|
+
__privateGet(this, _uiManager3).updateToolbar(options);
|
|
23729
24138
|
}
|
|
23730
24139
|
/**
|
|
23731
24140
|
* The mode has changed: it must be updated.
|
|
@@ -24084,12 +24493,12 @@ var _AnnotationEditorLayer = class _AnnotationEditorLayer {
|
|
|
24084
24493
|
}
|
|
24085
24494
|
/**
|
|
24086
24495
|
* Paste some content into a new editor.
|
|
24087
|
-
* @param {
|
|
24496
|
+
* @param {Object} options
|
|
24088
24497
|
* @param {Object} params
|
|
24089
24498
|
*/
|
|
24090
|
-
async pasteEditor(
|
|
24091
|
-
|
|
24092
|
-
await __privateGet(this, _uiManager3).updateMode(mode);
|
|
24499
|
+
async pasteEditor(options, params) {
|
|
24500
|
+
this.updateToolbar(options);
|
|
24501
|
+
await __privateGet(this, _uiManager3).updateMode(options.mode);
|
|
24093
24502
|
const { offsetX, offsetY } = __privateMethod(this, _AnnotationEditorLayer_instances, getCenterPoint_fn).call(this);
|
|
24094
24503
|
const id = this.getNextId();
|
|
24095
24504
|
const editor = __privateMethod(this, _AnnotationEditorLayer_instances, createNewEditor_fn).call(this, {
|
|
@@ -24665,10 +25074,63 @@ var DrawLayer = _DrawLayer;
|
|
|
24665
25074
|
|
|
24666
25075
|
// src/pdf.js/src/pdf.js
|
|
24667
25076
|
if (false) {
|
|
24668
|
-
globalThis.
|
|
25077
|
+
globalThis._pdfjsTestingUtils = {
|
|
24669
25078
|
HighlightOutliner
|
|
24670
25079
|
};
|
|
24671
25080
|
}
|
|
25081
|
+
globalThis.pdfjsLib = {
|
|
25082
|
+
AbortException,
|
|
25083
|
+
AnnotationEditorLayer,
|
|
25084
|
+
AnnotationEditorParamsType,
|
|
25085
|
+
AnnotationEditorType,
|
|
25086
|
+
AnnotationEditorUIManager,
|
|
25087
|
+
AnnotationLayer,
|
|
25088
|
+
AnnotationMode,
|
|
25089
|
+
AnnotationType,
|
|
25090
|
+
build,
|
|
25091
|
+
ColorPicker,
|
|
25092
|
+
createValidAbsoluteUrl,
|
|
25093
|
+
DOMSVGFactory,
|
|
25094
|
+
DrawLayer,
|
|
25095
|
+
FeatureTest,
|
|
25096
|
+
fetchData,
|
|
25097
|
+
getDocument,
|
|
25098
|
+
getFilenameFromUrl,
|
|
25099
|
+
getPdfFilenameFromUrl,
|
|
25100
|
+
getUuid,
|
|
25101
|
+
getXfaPageViewport,
|
|
25102
|
+
GlobalWorkerOptions,
|
|
25103
|
+
ImageKind,
|
|
25104
|
+
InvalidPDFException,
|
|
25105
|
+
isDataScheme,
|
|
25106
|
+
isPdfFile,
|
|
25107
|
+
isValidExplicitDest,
|
|
25108
|
+
MathClamp,
|
|
25109
|
+
noContextMenu,
|
|
25110
|
+
normalizeUnicode,
|
|
25111
|
+
OPS,
|
|
25112
|
+
OutputScale,
|
|
25113
|
+
PasswordResponses,
|
|
25114
|
+
PDFDataRangeTransport,
|
|
25115
|
+
PDFDateString,
|
|
25116
|
+
PDFWorker,
|
|
25117
|
+
PermissionFlag,
|
|
25118
|
+
PixelsPerInch,
|
|
25119
|
+
RenderingCancelledException,
|
|
25120
|
+
ResponseException,
|
|
25121
|
+
setLayerDimensions,
|
|
25122
|
+
shadow,
|
|
25123
|
+
SignatureExtractor,
|
|
25124
|
+
stopEvent,
|
|
25125
|
+
SupportedImageMimeTypes,
|
|
25126
|
+
TextLayer,
|
|
25127
|
+
TouchManager,
|
|
25128
|
+
updateUrlHash,
|
|
25129
|
+
Util,
|
|
25130
|
+
VerbosityLevel,
|
|
25131
|
+
version,
|
|
25132
|
+
XfaLayer
|
|
25133
|
+
};
|
|
24672
25134
|
|
|
24673
25135
|
// src/lib/AnnotationOperatorsList.ts
|
|
24674
25136
|
var AnnotationOperatorsList = class {
|
|
@@ -25621,53 +26083,6 @@ async function toSvgNode(ctx) {
|
|
|
25621
26083
|
return ctx.getNode();
|
|
25622
26084
|
}
|
|
25623
26085
|
|
|
25624
|
-
// src/lib/utils.ts
|
|
25625
|
-
async function canvasToData(canvas) {
|
|
25626
|
-
if ("toBlob" in canvas) {
|
|
25627
|
-
const blob = await new Promise(
|
|
25628
|
-
(resolve) => canvas.toBlob((data) => resolve(data))
|
|
25629
|
-
);
|
|
25630
|
-
if (!blob) {
|
|
25631
|
-
throw new Error("Failed to generate graphics");
|
|
25632
|
-
}
|
|
25633
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
25634
|
-
}
|
|
25635
|
-
const buffer = await canvas.encode("png");
|
|
25636
|
-
return new Uint8Array(buffer);
|
|
25637
|
-
}
|
|
25638
|
-
async function toDataUrl(data, type = "image/png") {
|
|
25639
|
-
if (typeof FileReader !== "undefined") {
|
|
25640
|
-
return new Promise((resolve) => {
|
|
25641
|
-
const reader = new FileReader();
|
|
25642
|
-
reader.onload = () => {
|
|
25643
|
-
resolve(reader.result);
|
|
25644
|
-
};
|
|
25645
|
-
reader.readAsDataURL(new Blob([data], { type }));
|
|
25646
|
-
});
|
|
25647
|
-
}
|
|
25648
|
-
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
25649
|
-
}
|
|
25650
|
-
function makeSerializable(object) {
|
|
25651
|
-
if (typeof object !== "object" || object === null) {
|
|
25652
|
-
return object;
|
|
25653
|
-
}
|
|
25654
|
-
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) {
|
|
25655
|
-
return makeSerializable(Array.from(object));
|
|
25656
|
-
}
|
|
25657
|
-
if (object instanceof BigInt64Array || object instanceof BigUint64Array) {
|
|
25658
|
-
return makeSerializable(Array.from(object));
|
|
25659
|
-
}
|
|
25660
|
-
if (Array.isArray(object)) {
|
|
25661
|
-
return object.map(makeSerializable);
|
|
25662
|
-
}
|
|
25663
|
-
return Object.fromEntries(
|
|
25664
|
-
Object.entries(object).map(([key, value]) => [
|
|
25665
|
-
key,
|
|
25666
|
-
makeSerializable(value)
|
|
25667
|
-
])
|
|
25668
|
-
);
|
|
25669
|
-
}
|
|
25670
|
-
|
|
25671
26086
|
// src/lib/PDFPageProxy.ts
|
|
25672
26087
|
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
25673
26088
|
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
@@ -25792,10 +26207,18 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
25792
26207
|
annotation.borderStyle.width = currentLineWidth;
|
|
25793
26208
|
}
|
|
25794
26209
|
if (fn === OPS.setStrokeRGBColor && firstStroke) {
|
|
25795
|
-
|
|
26210
|
+
if (typeof args[0] === "string") {
|
|
26211
|
+
annotation.color = colorToRgb(args[0]);
|
|
26212
|
+
} else {
|
|
26213
|
+
annotation.color = args;
|
|
26214
|
+
}
|
|
25796
26215
|
}
|
|
25797
26216
|
if (fn === OPS.setFillRGBColor && firstFill) {
|
|
25798
|
-
|
|
26217
|
+
if (typeof args[0] === "string") {
|
|
26218
|
+
currentFillColor = colorToRgb(args[0]);
|
|
26219
|
+
} else {
|
|
26220
|
+
currentFillColor = args;
|
|
26221
|
+
}
|
|
25799
26222
|
}
|
|
25800
26223
|
if (fn === OPS.setGState) {
|
|
25801
26224
|
for (const entry of args[0]) {
|
|
@@ -25838,11 +26261,11 @@ var WasmFactory = class {
|
|
|
25838
26261
|
async fetch({ filename }) {
|
|
25839
26262
|
switch (filename) {
|
|
25840
26263
|
case "openjpeg.wasm":
|
|
25841
|
-
return import("./openjpeg-
|
|
26264
|
+
return import("./openjpeg-B2WN24QZ.js").then(
|
|
25842
26265
|
(module) => module.default
|
|
25843
26266
|
);
|
|
25844
26267
|
case "qcms_bg":
|
|
25845
|
-
return import("./qcms_bg-
|
|
26268
|
+
return import("./qcms_bg-T4RSHPOQ.js").then(
|
|
25846
26269
|
(module) => module.default
|
|
25847
26270
|
);
|
|
25848
26271
|
}
|
|
@@ -26508,6 +26931,7 @@ export {
|
|
|
26508
26931
|
XfaLayer,
|
|
26509
26932
|
build,
|
|
26510
26933
|
canvasToData,
|
|
26934
|
+
colorToRgb,
|
|
26511
26935
|
createCanvas,
|
|
26512
26936
|
createSvgContext,
|
|
26513
26937
|
createTextLayer,
|
|
@@ -26559,10 +26983,12 @@ export {
|
|
|
26559
26983
|
makeSerializable,
|
|
26560
26984
|
noContextMenu,
|
|
26561
26985
|
normalizeUnicode,
|
|
26986
|
+
rgbToHex,
|
|
26562
26987
|
setLayerDimensions,
|
|
26563
26988
|
shadow,
|
|
26564
26989
|
stopEvent,
|
|
26565
26990
|
toDataUrl,
|
|
26566
26991
|
toSvgNode,
|
|
26992
|
+
updateUrlHash,
|
|
26567
26993
|
version
|
|
26568
26994
|
};
|