@box/pdfjs-dist 6.4.299-box.2 → 6.4.299-box.4
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/CHANGELOG.md +8 -0
- package/build/pdf.min.mjs +4 -4
- package/build/pdf.mjs +33 -9
- package/build/pdf.mjs.map +1 -1
- package/build/pdf.sandbox.min.mjs +2 -2
- package/build/pdf.sandbox.mjs +2 -2
- package/build/pdf.worker.min.mjs +3 -3
- package/build/pdf.worker.mjs +3 -3
- package/image_decoders/pdf.image_decoders.min.mjs +2 -2
- package/image_decoders/pdf.image_decoders.mjs +2 -2
- package/legacy/build/pdf.min.mjs +4 -4
- package/legacy/build/pdf.mjs +34 -9
- package/legacy/build/pdf.mjs.map +1 -1
- package/legacy/build/pdf.sandbox.min.mjs +2 -2
- package/legacy/build/pdf.sandbox.mjs +2 -2
- package/legacy/build/pdf.worker.min.mjs +3 -3
- package/legacy/build/pdf.worker.mjs +3 -3
- package/legacy/image_decoders/pdf.image_decoders.min.mjs +2 -2
- package/legacy/image_decoders/pdf.image_decoders.mjs +2 -2
- package/legacy/web/pdf_viewer.mjs +55 -8
- package/legacy/web/pdf_viewer.mjs.map +1 -1
- package/package.json +2 -2
- package/types/src/display/display_utils.d.ts +8 -0
- package/types/src/pdf.d.ts +3 -1
- package/types/web/text_accessibility.d.ts +15 -0
- package/web/pdf_viewer.mjs +53 -8
- package/web/pdf_viewer.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/pdfjs-dist",
|
|
3
|
-
"version": "6.4.299-box.
|
|
3
|
+
"version": "6.4.299-box.4",
|
|
4
4
|
"author": "Box",
|
|
5
5
|
"main": "build/pdf.mjs",
|
|
6
6
|
"types": "types/src/pdf.d.ts",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"node": ">=22.13.0 || >=24"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "38c965bc7d033b549bd8860505097b0c59b0fa8f"
|
|
35
35
|
}
|
|
@@ -4,6 +4,7 @@ export type AxisAlignedPath = {
|
|
|
4
4
|
minSubpathHeight: number;
|
|
5
5
|
};
|
|
6
6
|
export function applyOpacity(color: any, opacity: any): any;
|
|
7
|
+
export function areBoxChangesEnabled(): boolean;
|
|
7
8
|
export class ColorScheme {
|
|
8
9
|
static get isDarkMode(): any;
|
|
9
10
|
}
|
|
@@ -145,6 +146,13 @@ export function renderRichText({ html, dir, className }: {
|
|
|
145
146
|
dir: any;
|
|
146
147
|
className: any;
|
|
147
148
|
}, container: any): void;
|
|
149
|
+
/**
|
|
150
|
+
* Turns Box's runtime changes to PDF.js on or off for every document; call it
|
|
151
|
+
* between renders. They are on by default; with them off, pages render like
|
|
152
|
+
* the upstream release this build is based on.
|
|
153
|
+
* @param {boolean} enabled
|
|
154
|
+
*/
|
|
155
|
+
export function setBoxChangesEnabled(enabled: boolean): void;
|
|
148
156
|
/**
|
|
149
157
|
* @param {HTMLDivElement} div
|
|
150
158
|
* @param {PageViewport} viewport
|
package/types/src/pdf.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { AnnotationLayer } from "./display/annotation_layer.js";
|
|
|
13
13
|
import { AnnotationMode } from "./shared/util.js";
|
|
14
14
|
import { AnnotationType } from "./shared/util.js";
|
|
15
15
|
import { applyOpacity } from "./display/display_utils.js";
|
|
16
|
+
import { areBoxChangesEnabled } from "./display/display_utils.js";
|
|
16
17
|
import { build } from "./display/api.js";
|
|
17
18
|
import { ColorPicker } from "./display/editor/color_picker.js";
|
|
18
19
|
import { createValidAbsoluteUrl } from "./shared/util.js";
|
|
@@ -53,6 +54,7 @@ import { PixelsPerInch } from "./display/display_utils.js";
|
|
|
53
54
|
import { RenderingCancelledException } from "./display/display_utils.js";
|
|
54
55
|
import { renderRichText } from "./display/display_utils.js";
|
|
55
56
|
import { ResponseException } from "./shared/util.js";
|
|
57
|
+
import { setBoxChangesEnabled } from "./display/display_utils.js";
|
|
56
58
|
import { setLayerDimensions } from "./display/display_utils.js";
|
|
57
59
|
import { shadow } from "./shared/util.js";
|
|
58
60
|
import { SignatureExtractor } from "./display/editor/drawers/signaturedraw.js";
|
|
@@ -66,4 +68,4 @@ import { Util } from "./shared/util.js";
|
|
|
66
68
|
import { VerbosityLevel } from "./shared/util.js";
|
|
67
69
|
import { version } from "./display/api.js";
|
|
68
70
|
import { XfaLayer } from "./display/xfa_layer.js";
|
|
69
|
-
export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, applyOpacity, build, ColorPicker, createValidAbsoluteUrl, CSSConstants, DOMSVGFactory, DrawLayer, FeatureTest, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getRGBA, getUuid, GlobalWorkerOptions, ImageKind, InvalidPDFException, isDataScheme, isPdfFile, isValidExplicitDest, makeArr, makeMap, makeObj, makeSet, MathClamp, noContextMenu, normalizeUnicode, OPS, OutputScale, PasswordException, PasswordResponses, PDFDataRangeTransport, PDFDateString, PDFWorker, PermissionFlag, PixelsPerInch, RenderingCancelledException, renderRichText, ResponseException, setLayerDimensions, shadow, SignatureExtractor, stopEvent, SupportedImageMimeTypes, TextLayer, TextLayerImages, TouchManager, updateUrlHash, Util, VerbosityLevel, version, XfaLayer };
|
|
71
|
+
export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, applyOpacity, areBoxChangesEnabled, build, ColorPicker, createValidAbsoluteUrl, CSSConstants, DOMSVGFactory, DrawLayer, FeatureTest, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getRGBA, getUuid, GlobalWorkerOptions, ImageKind, InvalidPDFException, isDataScheme, isPdfFile, isValidExplicitDest, makeArr, makeMap, makeObj, makeSet, MathClamp, noContextMenu, normalizeUnicode, OPS, OutputScale, PasswordException, PasswordResponses, PDFDataRangeTransport, PDFDateString, PDFWorker, PermissionFlag, PixelsPerInch, RenderingCancelledException, renderRichText, ResponseException, setBoxChangesEnabled, setLayerDimensions, shadow, SignatureExtractor, stopEvent, SupportedImageMimeTypes, TextLayer, TextLayerImages, TouchManager, updateUrlHash, Util, VerbosityLevel, version, XfaLayer };
|
|
@@ -14,6 +14,12 @@ export class TextAccessibilityManager {
|
|
|
14
14
|
* @returns {number}
|
|
15
15
|
*/
|
|
16
16
|
static #compareElementPositions(e1: HTMLElement, e2: HTMLElement): number;
|
|
17
|
+
/**
|
|
18
|
+
* @param {DOMRect} rect1
|
|
19
|
+
* @param {DOMRect} rect2
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
22
|
+
static #compareRectPositions(rect1: DOMRect, rect2: DOMRect): number;
|
|
17
23
|
setTextMapping(textDivs: any): void;
|
|
18
24
|
/**
|
|
19
25
|
* Function called when the text layer has finished rendering.
|
|
@@ -33,6 +39,15 @@ export class TextAccessibilityManager {
|
|
|
33
39
|
* @returns {string|null} The id in the struct tree if any.
|
|
34
40
|
*/
|
|
35
41
|
addPointerInTextLayer(element: HTMLElement, isRemovable: boolean): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Set the same aria-owns as addPointerInTextLayer on each element, in order,
|
|
44
|
+
* with at most one forced style recalc. Every position is read before any
|
|
45
|
+
* write, which is safe because aria-owns and role do not affect layout.
|
|
46
|
+
* @param {Array<HTMLElement>} elements
|
|
47
|
+
* @param {boolean} isRemovable
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
addPointersInTextLayer(elements: Array<HTMLElement>, isRemovable: boolean): void;
|
|
36
51
|
/**
|
|
37
52
|
* Move a div in the DOM in order to respect the visual order.
|
|
38
53
|
* @param {HTMLElement} container
|
package/web/pdf_viewer.mjs
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* pdfjsVersion = 6.4.299-box.
|
|
24
|
-
* pdfjsBuild =
|
|
23
|
+
* pdfjsVersion = 6.4.299-box.4
|
|
24
|
+
* pdfjsBuild = 38c965b
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
;// ./web/pdfjs.js
|
|
@@ -35,6 +35,7 @@ const {
|
|
|
35
35
|
AnnotationMode,
|
|
36
36
|
AnnotationType,
|
|
37
37
|
applyOpacity,
|
|
38
|
+
areBoxChangesEnabled,
|
|
38
39
|
build,
|
|
39
40
|
ColorPicker,
|
|
40
41
|
createValidAbsoluteUrl,
|
|
@@ -75,6 +76,7 @@ const {
|
|
|
75
76
|
RenderingCancelledException,
|
|
76
77
|
renderRichText,
|
|
77
78
|
ResponseException,
|
|
79
|
+
setBoxChangesEnabled,
|
|
78
80
|
setLayerDimensions,
|
|
79
81
|
shadow,
|
|
80
82
|
SignatureExtractor,
|
|
@@ -627,7 +629,7 @@ const calcRound = function () {
|
|
|
627
629
|
}();
|
|
628
630
|
|
|
629
631
|
;// ./web/internal_evt.js
|
|
630
|
-
const INTERNAL_EVT = "
|
|
632
|
+
const INTERNAL_EVT = "560872f8-101c-43ba-adde-6fe2cd9435d3";
|
|
631
633
|
const internalOpt = Object.freeze({
|
|
632
634
|
internal: INTERNAL_EVT
|
|
633
635
|
});
|
|
@@ -5781,6 +5783,7 @@ class StructTreeLayerBuilder {
|
|
|
5781
5783
|
|
|
5782
5784
|
;// ./web/text_accessibility.js
|
|
5783
5785
|
|
|
5786
|
+
|
|
5784
5787
|
class TextAccessibilityManager {
|
|
5785
5788
|
#enabled = false;
|
|
5786
5789
|
#textChildren = null;
|
|
@@ -5790,8 +5793,9 @@ class TextAccessibilityManager {
|
|
|
5790
5793
|
this.#textChildren = textDivs;
|
|
5791
5794
|
}
|
|
5792
5795
|
static #compareElementPositions(e1, e2) {
|
|
5793
|
-
|
|
5794
|
-
|
|
5796
|
+
return TextAccessibilityManager.#compareRectPositions(e1.getBoundingClientRect(), e2.getBoundingClientRect());
|
|
5797
|
+
}
|
|
5798
|
+
static #compareRectPositions(rect1, rect2) {
|
|
5795
5799
|
if (rect1.width === 0 && rect1.height === 0) {
|
|
5796
5800
|
return +1;
|
|
5797
5801
|
}
|
|
@@ -5835,8 +5839,12 @@ class TextAccessibilityManager {
|
|
|
5835
5839
|
this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
|
|
5836
5840
|
}
|
|
5837
5841
|
}
|
|
5838
|
-
|
|
5839
|
-
this
|
|
5842
|
+
if (areBoxChangesEnabled()) {
|
|
5843
|
+
this.#addPointerEntries(this.#waitingElements);
|
|
5844
|
+
} else {
|
|
5845
|
+
for (const [element, isRemovable] of this.#waitingElements) {
|
|
5846
|
+
this.addPointerInTextLayer(element, isRemovable);
|
|
5847
|
+
}
|
|
5840
5848
|
}
|
|
5841
5849
|
this.#waitingElements.clear();
|
|
5842
5850
|
}
|
|
@@ -5910,6 +5918,43 @@ class TextAccessibilityManager {
|
|
|
5910
5918
|
const parent = child.parentNode;
|
|
5911
5919
|
return parent?.classList.contains("markedContent") ? parent.id : null;
|
|
5912
5920
|
}
|
|
5921
|
+
addPointersInTextLayer(elements, isRemovable) {
|
|
5922
|
+
this.#addPointerEntries(elements.map(element => [element, isRemovable]));
|
|
5923
|
+
}
|
|
5924
|
+
#addPointerEntries(entries) {
|
|
5925
|
+
const children = this.#textChildren;
|
|
5926
|
+
if (!this.#enabled || !children?.length) {
|
|
5927
|
+
for (const [element, isRemovable] of entries) {
|
|
5928
|
+
this.addPointerInTextLayer(element, isRemovable);
|
|
5929
|
+
}
|
|
5930
|
+
return;
|
|
5931
|
+
}
|
|
5932
|
+
const childRects = new Map();
|
|
5933
|
+
const pointers = [];
|
|
5934
|
+
for (const [element, isRemovable] of entries) {
|
|
5935
|
+
if (!element.id) {
|
|
5936
|
+
continue;
|
|
5937
|
+
}
|
|
5938
|
+
const elementRect = element.getBoundingClientRect();
|
|
5939
|
+
const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareRectPositions(elementRect, childRects.getOrInsertComputed(node, () => node.getBoundingClientRect())) < 0);
|
|
5940
|
+
pointers.push({
|
|
5941
|
+
element,
|
|
5942
|
+
isRemovable,
|
|
5943
|
+
nodeIndex: Math.max(0, index - 1)
|
|
5944
|
+
});
|
|
5945
|
+
}
|
|
5946
|
+
for (const {
|
|
5947
|
+
element,
|
|
5948
|
+
isRemovable,
|
|
5949
|
+
nodeIndex
|
|
5950
|
+
} of pointers) {
|
|
5951
|
+
if (isRemovable) {
|
|
5952
|
+
this.removePointerInTextLayer(element);
|
|
5953
|
+
}
|
|
5954
|
+
this.#addIdToAriaOwns(element.id, children[nodeIndex]);
|
|
5955
|
+
this.#textNodes.set(element.id, nodeIndex);
|
|
5956
|
+
}
|
|
5957
|
+
}
|
|
5913
5958
|
moveElementInDOM(container, element, contentElement, isRemovable) {
|
|
5914
5959
|
const id = this.addPointerInTextLayer(contentElement, isRemovable);
|
|
5915
5960
|
if (!container.hasChildNodes()) {
|
|
@@ -7985,7 +8030,7 @@ class PDFViewer {
|
|
|
7985
8030
|
#savedPageViews = null;
|
|
7986
8031
|
#deletedPageNumbers = null;
|
|
7987
8032
|
constructor(options) {
|
|
7988
|
-
const viewerVersion = "6.4.299-box.
|
|
8033
|
+
const viewerVersion = "6.4.299-box.4";
|
|
7989
8034
|
if (version !== viewerVersion) {
|
|
7990
8035
|
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
|
|
7991
8036
|
}
|