@box/pdfjs-dist 6.4.299-box.1 → 6.4.299-box.3

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.
@@ -20,8 +20,8 @@
20
20
  */
21
21
 
22
22
  /**
23
- * pdfjsVersion = 6.4.299-box.1
24
- * pdfjsBuild = 99c657f
23
+ * pdfjsVersion = 6.4.299-box.3
24
+ * pdfjsBuild = acc2002
25
25
  */
26
26
  /******/ var __webpack_modules__ = ({
27
27
 
@@ -6839,6 +6839,12 @@ if (typeof Iterator.prototype.join !== "function") {
6839
6839
  ;// ./node_modules/core-js/modules/es.iterator.map.js
6840
6840
  es_iterator_map_namespaceFn();
6841
6841
 
6842
+ ;// ./node_modules/core-js/modules/es.weak-map.get-or-insert.js
6843
+ es_weak_map_get_or_insert_namespaceFn();
6844
+
6845
+ ;// ./node_modules/core-js/modules/es.weak-map.get-or-insert-computed.js
6846
+ es_weak_map_get_or_insert_computed_namespaceFn();
6847
+
6842
6848
  ;// ./src/shared/math_clamp.js
6843
6849
  function MathClamp(v, min, max) {
6844
6850
  return Math.min(Math.max(v, min), max);
@@ -7299,6 +7305,8 @@ class XfaLayer {
7299
7305
 
7300
7306
 
7301
7307
 
7308
+
7309
+
7302
7310
 
7303
7311
 
7304
7312
 
@@ -7830,6 +7838,138 @@ function renderRichText({
7830
7838
  fragment.firstElementChild.classList.add("richText", className);
7831
7839
  container.append(fragment);
7832
7840
  }
7841
+ let isBoxChangesSwitchOn = true;
7842
+ function setBoxChangesEnabled(enabled) {
7843
+ if (typeof enabled !== "boolean") {
7844
+ throw new Error("Invalid `enabled` type.");
7845
+ }
7846
+ isBoxChangesSwitchOn = enabled;
7847
+ }
7848
+ function areBoxChangesEnabled() {
7849
+ return isBoxChangesSwitchOn;
7850
+ }
7851
+ const axisAlignedClipPaths = new WeakMap();
7852
+ const NEAR_ZERO_TRANSFORM_RATIO = 1e-6;
7853
+ const MIN_SNAPPED_CLIP_SIZE = 2;
7854
+ function isNearZero(value, scale) {
7855
+ return Math.abs(value) <= NEAR_ZERO_TRANSFORM_RATIO * Math.abs(scale);
7856
+ }
7857
+ function isAxisAlignedScale([a, b, c, d]) {
7858
+ return isNearZero(b, a) && isNearZero(c, d);
7859
+ }
7860
+ function isQuarterTurn([a, b, c, d]) {
7861
+ return isNearZero(a, b) && isNearZero(d, c);
7862
+ }
7863
+ function isAxisAlignedEdge(x0, y0, x1, y1) {
7864
+ return x0 === x1 || y0 === y1;
7865
+ }
7866
+ function updateMinSubpathSize(minSubpathSize, [minX, minY, maxX, maxY]) {
7867
+ const hasEdges = minX !== Infinity;
7868
+ if (hasEdges) {
7869
+ minSubpathSize[0] = Math.min(minSubpathSize[0], maxX - minX);
7870
+ minSubpathSize[1] = Math.min(minSubpathSize[1], maxY - minY);
7871
+ }
7872
+ }
7873
+ function getAxisAlignedPath(data) {
7874
+ const minSubpathSize = [Infinity, Infinity];
7875
+ let subpathMinMax = BBOX_INIT.slice();
7876
+ let hasSubpath = false;
7877
+ let startX = 0;
7878
+ let startY = 0;
7879
+ let currentX = 0;
7880
+ let currentY = 0;
7881
+ for (let i = 0, ii = data.length; i < ii;) {
7882
+ switch (data[i++]) {
7883
+ case DrawOPS.moveTo:
7884
+ if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
7885
+ return null;
7886
+ }
7887
+ updateMinSubpathSize(minSubpathSize, subpathMinMax);
7888
+ subpathMinMax = BBOX_INIT.slice();
7889
+ hasSubpath = true;
7890
+ startX = currentX = data[i++];
7891
+ startY = currentY = data[i++];
7892
+ break;
7893
+ case DrawOPS.lineTo:
7894
+ {
7895
+ const x = data[i++];
7896
+ const y = data[i++];
7897
+ if (!hasSubpath || !isAxisAlignedEdge(currentX, currentY, x, y)) {
7898
+ return null;
7899
+ }
7900
+ Util.rectBoundingBox(currentX, currentY, x, y, subpathMinMax);
7901
+ currentX = x;
7902
+ currentY = y;
7903
+ break;
7904
+ }
7905
+ case DrawOPS.closePath:
7906
+ if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
7907
+ return null;
7908
+ }
7909
+ updateMinSubpathSize(minSubpathSize, subpathMinMax);
7910
+ subpathMinMax = BBOX_INIT.slice();
7911
+ currentX = startX;
7912
+ currentY = startY;
7913
+ break;
7914
+ default:
7915
+ return null;
7916
+ }
7917
+ }
7918
+ if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
7919
+ return null;
7920
+ }
7921
+ updateMinSubpathSize(minSubpathSize, subpathMinMax);
7922
+ const [minSubpathWidth, minSubpathHeight] = minSubpathSize;
7923
+ return minSubpathWidth > 0 && minSubpathHeight > 0 && minSubpathWidth < Infinity ? {
7924
+ data,
7925
+ minSubpathWidth,
7926
+ minSubpathHeight
7927
+ } : null;
7928
+ }
7929
+ function snapToDevicePixel(coordinate, scale, offset) {
7930
+ return (Math.round(scale * coordinate + offset) - offset) / scale;
7931
+ }
7932
+ function snapAxisAlignedPath({
7933
+ data,
7934
+ minSubpathWidth,
7935
+ minSubpathHeight
7936
+ }, transform) {
7937
+ const [a, b, c, d, e, f] = transform;
7938
+ let scaleX, offsetX, scaleY, offsetY;
7939
+ if (isAxisAlignedScale(transform)) {
7940
+ [scaleX, offsetX, scaleY, offsetY] = [a, e, d, f];
7941
+ } else if (isQuarterTurn(transform)) {
7942
+ [scaleX, offsetX, scaleY, offsetY] = [b, f, c, e];
7943
+ } else {
7944
+ return null;
7945
+ }
7946
+ if (Math.abs(scaleX * minSubpathWidth) < MIN_SNAPPED_CLIP_SIZE || Math.abs(scaleY * minSubpathHeight) < MIN_SNAPPED_CLIP_SIZE) {
7947
+ return null;
7948
+ }
7949
+ const snappedDrawOPS = [];
7950
+ for (let i = 0, ii = data.length; i < ii;) {
7951
+ const op = data[i++];
7952
+ snappedDrawOPS.push(op);
7953
+ if (op === DrawOPS.moveTo || op === DrawOPS.lineTo) {
7954
+ snappedDrawOPS.push(snapToDevicePixel(data[i++], scaleX, offsetX), snapToDevicePixel(data[i++], scaleY, offsetY));
7955
+ }
7956
+ }
7957
+ return snappedDrawOPS;
7958
+ }
7959
+ function recordClipPath(path, data) {
7960
+ const axisAlignedPath = getAxisAlignedPath(data);
7961
+ if (axisAlignedPath) {
7962
+ axisAlignedClipPaths.set(path, axisAlignedPath);
7963
+ }
7964
+ }
7965
+ function getPixelSnappedClipPath(path, transform) {
7966
+ if (!areBoxChangesEnabled()) {
7967
+ return path;
7968
+ }
7969
+ const axisAlignedPath = axisAlignedClipPaths.get(path);
7970
+ const snappedDrawOPS = axisAlignedPath && snapAxisAlignedPath(axisAlignedPath, transform);
7971
+ return snappedDrawOPS ? makePathFromDrawOPS(snappedDrawOPS) : path;
7972
+ }
7833
7973
  function makePathFromDrawOPS(data) {
7834
7974
  const path = new Path2D();
7835
7975
  if (!data) {
@@ -7863,12 +8003,6 @@ function makePathFromDrawOPS(data) {
7863
8003
  ;// ./node_modules/core-js/modules/es.iterator.take.js
7864
8004
  es_iterator_take_namespaceFn();
7865
8005
 
7866
- ;// ./node_modules/core-js/modules/es.weak-map.get-or-insert.js
7867
- es_weak_map_get_or_insert_namespaceFn();
7868
-
7869
- ;// ./node_modules/core-js/modules/es.weak-map.get-or-insert-computed.js
7870
- es_weak_map_get_or_insert_computed_namespaceFn();
7871
-
7872
8006
  ;// ./node_modules/core-js/modules/web.dom-exception.stack.js
7873
8007
  web_dom_exception_stack_namespaceFn();
7874
8008
 
@@ -8195,7 +8329,7 @@ class FloatingToolbar {
8195
8329
  }
8196
8330
 
8197
8331
  ;// ./src/shared/internal_evt.js
8198
- const INTERNAL_EVT = "32533502-63d2-47b3-84b0-128ba9620ee0";
8332
+ const INTERNAL_EVT = "1f166d3a-715c-4c7a-a062-1e0ddfefab93";
8199
8333
  const internalOpt = Object.freeze({
8200
8334
  internal: INTERNAL_EVT
8201
8335
  });
@@ -16846,8 +16980,10 @@ function mirrorContextOperations(ctx, destCtx) {
16846
16980
  };
16847
16981
  }
16848
16982
  function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
16849
- const [a, b, c, d, tx, ty] = getCurrentTransform(ctx);
16850
- if (b === 0 && c === 0) {
16983
+ const transform = getCurrentTransform(ctx);
16984
+ const [a, b, c, d, tx, ty] = transform;
16985
+ const isRoundingTolerated = areBoxChangesEnabled();
16986
+ if (isRoundingTolerated ? isAxisAlignedScale(transform) : b === 0 && c === 0) {
16851
16987
  const tlX = destX * a + tx;
16852
16988
  const rTlX = Math.round(tlX);
16853
16989
  const tlY = destY * d + ty;
@@ -16861,7 +16997,7 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
16861
16997
  ctx.setTransform(a, b, c, d, tx, ty);
16862
16998
  return [rWidth, rHeight];
16863
16999
  }
16864
- if (a === 0 && d === 0) {
17000
+ if (isRoundingTolerated ? isQuarterTurn(transform) : a === 0 && d === 0) {
16865
17001
  const tlX = destY * c + tx;
16866
17002
  const rTlX = Math.round(tlX);
16867
17003
  const tlY = destX * b + ty;
@@ -18087,7 +18223,11 @@ class CanvasGraphics {
18087
18223
  this.dependencyTracker.resetBBox(opIdx).recordBBox(opIdx, this.ctx, minMax[0] - outerExtraSize, minMax[2] + outerExtraSize, minMax[1] - outerExtraSize, minMax[3] + outerExtraSize).recordDependencies(opIdx, ["transform"]);
18088
18224
  }
18089
18225
  if (!(path instanceof Path2D)) {
18090
- path = data[0] = makePathFromDrawOPS(path);
18226
+ const drawOPS = path;
18227
+ path = data[0] = makePathFromDrawOPS(drawOPS);
18228
+ if (this.pendingClip) {
18229
+ recordClipPath(path, drawOPS);
18230
+ }
18091
18231
  }
18092
18232
  Util.axialAlignedBoundingBox(minMax, getCurrentTransform(this.ctx), this.current.minMax);
18093
18233
  const tilingDims = this.current.tilingPatternDims;
@@ -19417,10 +19557,11 @@ class CanvasGraphics {
19417
19557
  const ctx = this.ctx;
19418
19558
  if (this.pendingClip) {
19419
19559
  if (!isEmpty) {
19560
+ const clipPath = getPixelSnappedClipPath(path, getCurrentTransform(ctx));
19420
19561
  if (this.pendingClip === EO_CLIP) {
19421
- ctx.clip(path, "evenodd");
19562
+ ctx.clip(clipPath, "evenodd");
19422
19563
  } else {
19423
- ctx.clip(path);
19564
+ ctx.clip(clipPath);
19424
19565
  }
19425
19566
  }
19426
19567
  this.pendingClip = null;
@@ -21810,7 +21951,7 @@ function getDocument(src = {}) {
21810
21951
  }
21811
21952
  const docParams = {
21812
21953
  docId,
21813
- apiVersion: "6.4.299-box.1",
21954
+ apiVersion: "6.4.299-box.3",
21814
21955
  data,
21815
21956
  password,
21816
21957
  disableAutoFetch,
@@ -23511,8 +23652,8 @@ class InternalRenderTask {
23511
23652
  }
23512
23653
  }
23513
23654
  }
23514
- const api_version = "6.4.299-box.1";
23515
- const build = "99c657f";
23655
+ const api_version = "6.4.299-box.3";
23656
+ const build = "acc2002";
23516
23657
 
23517
23658
  ;// ./node_modules/core-js/modules/es.math.sum-precise.js
23518
23659
  es_math_sum_precise_namespaceFn();
@@ -34652,6 +34793,7 @@ globalThis.pdfjsLib = {
34652
34793
  RenderingCancelledException: RenderingCancelledException,
34653
34794
  renderRichText: renderRichText,
34654
34795
  ResponseException: ResponseException,
34796
+ setBoxChangesEnabled: setBoxChangesEnabled,
34655
34797
  setLayerDimensions: setLayerDimensions,
34656
34798
  shadow: util_shadow,
34657
34799
  SignatureExtractor: SignatureExtractor,
@@ -34667,6 +34809,6 @@ globalThis.pdfjsLib = {
34667
34809
  XfaLayer: XfaLayer
34668
34810
  };
34669
34811
 
34670
- export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, CSSConstants, ColorPicker, DOMSVGFactory, DrawLayer, FeatureTest, GlobalWorkerOptions, ImageKind, InvalidPDFException, MathClamp, OPS, OutputScale, PDFDataRangeTransport, PDFDateString, PDFWorker, PasswordException, PasswordResponses, PermissionFlag, PixelsPerInch, RenderingCancelledException, ResponseException, SignatureExtractor, SupportedImageMimeTypes, TextLayer, TextLayerImages, TouchManager, Util, VerbosityLevel, XfaLayer, applyOpacity, build, createValidAbsoluteUrl, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getRGBA, getUuid, isDataScheme, isPdfFile, isValidExplicitDest, makeArr, makeMap, makeObj, makeSet, noContextMenu, normalizeUnicode, renderRichText, setLayerDimensions, util_shadow as shadow, stopEvent, updateUrlHash, api_version as version };
34812
+ export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, CSSConstants, ColorPicker, DOMSVGFactory, DrawLayer, FeatureTest, GlobalWorkerOptions, ImageKind, InvalidPDFException, MathClamp, OPS, OutputScale, PDFDataRangeTransport, PDFDateString, PDFWorker, PasswordException, PasswordResponses, PermissionFlag, PixelsPerInch, RenderingCancelledException, ResponseException, SignatureExtractor, SupportedImageMimeTypes, TextLayer, TextLayerImages, TouchManager, Util, VerbosityLevel, XfaLayer, applyOpacity, build, createValidAbsoluteUrl, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getRGBA, getUuid, isDataScheme, isPdfFile, isValidExplicitDest, makeArr, makeMap, makeObj, makeSet, noContextMenu, normalizeUnicode, renderRichText, setBoxChangesEnabled, setLayerDimensions, util_shadow as shadow, stopEvent, updateUrlHash, api_version as version };
34671
34813
 
34672
34814
  //# sourceMappingURL=pdf.mjs.map