@box/pdfjs-dist 6.4.299-box.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/pdfjs-dist",
3
- "version": "6.4.299-box.3",
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": "acc20024a21d922ff9cde3e9e82676358df970a4"
34
+ "gitHead": "38c965bc7d033b549bd8860505097b0c59b0fa8f"
35
35
  }
@@ -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";
@@ -67,4 +68,4 @@ import { Util } from "./shared/util.js";
67
68
  import { VerbosityLevel } from "./shared/util.js";
68
69
  import { version } from "./display/api.js";
69
70
  import { XfaLayer } from "./display/xfa_layer.js";
70
- 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, setBoxChangesEnabled, 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
@@ -20,8 +20,8 @@
20
20
  */
21
21
 
22
22
  /**
23
- * pdfjsVersion = 6.4.299-box.3
24
- * pdfjsBuild = acc2002
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,
@@ -628,7 +629,7 @@ const calcRound = function () {
628
629
  }();
629
630
 
630
631
  ;// ./web/internal_evt.js
631
- const INTERNAL_EVT = "1f166d3a-715c-4c7a-a062-1e0ddfefab93";
632
+ const INTERNAL_EVT = "560872f8-101c-43ba-adde-6fe2cd9435d3";
632
633
  const internalOpt = Object.freeze({
633
634
  internal: INTERNAL_EVT
634
635
  });
@@ -5782,6 +5783,7 @@ class StructTreeLayerBuilder {
5782
5783
 
5783
5784
  ;// ./web/text_accessibility.js
5784
5785
 
5786
+
5785
5787
  class TextAccessibilityManager {
5786
5788
  #enabled = false;
5787
5789
  #textChildren = null;
@@ -5791,8 +5793,9 @@ class TextAccessibilityManager {
5791
5793
  this.#textChildren = textDivs;
5792
5794
  }
5793
5795
  static #compareElementPositions(e1, e2) {
5794
- const rect1 = e1.getBoundingClientRect();
5795
- const rect2 = e2.getBoundingClientRect();
5796
+ return TextAccessibilityManager.#compareRectPositions(e1.getBoundingClientRect(), e2.getBoundingClientRect());
5797
+ }
5798
+ static #compareRectPositions(rect1, rect2) {
5796
5799
  if (rect1.width === 0 && rect1.height === 0) {
5797
5800
  return +1;
5798
5801
  }
@@ -5836,8 +5839,12 @@ class TextAccessibilityManager {
5836
5839
  this.#addIdToAriaOwns(id, textChildren[nodeIndex]);
5837
5840
  }
5838
5841
  }
5839
- for (const [element, isRemovable] of this.#waitingElements) {
5840
- this.addPointerInTextLayer(element, isRemovable);
5842
+ if (areBoxChangesEnabled()) {
5843
+ this.#addPointerEntries(this.#waitingElements);
5844
+ } else {
5845
+ for (const [element, isRemovable] of this.#waitingElements) {
5846
+ this.addPointerInTextLayer(element, isRemovable);
5847
+ }
5841
5848
  }
5842
5849
  this.#waitingElements.clear();
5843
5850
  }
@@ -5911,6 +5918,43 @@ class TextAccessibilityManager {
5911
5918
  const parent = child.parentNode;
5912
5919
  return parent?.classList.contains("markedContent") ? parent.id : null;
5913
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
+ }
5914
5958
  moveElementInDOM(container, element, contentElement, isRemovable) {
5915
5959
  const id = this.addPointerInTextLayer(contentElement, isRemovable);
5916
5960
  if (!container.hasChildNodes()) {
@@ -7986,7 +8030,7 @@ class PDFViewer {
7986
8030
  #savedPageViews = null;
7987
8031
  #deletedPageNumbers = null;
7988
8032
  constructor(options) {
7989
- const viewerVersion = "6.4.299-box.3";
8033
+ const viewerVersion = "6.4.299-box.4";
7990
8034
  if (version !== viewerVersion) {
7991
8035
  throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
7992
8036
  }