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

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/build/pdf.mjs CHANGED
@@ -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.2
24
+ * pdfjsBuild = 9c8224a
25
25
  */
26
26
 
27
27
  ;// ./src/shared/util.js
@@ -1759,6 +1759,125 @@ function renderRichText({
1759
1759
  fragment.firstElementChild.classList.add("richText", className);
1760
1760
  container.append(fragment);
1761
1761
  }
1762
+ const axisAlignedClipPaths = new WeakMap();
1763
+ const NEAR_ZERO_TRANSFORM_RATIO = 1e-6;
1764
+ const MIN_SNAPPED_CLIP_SIZE = 2;
1765
+ function isNearZero(value, scale) {
1766
+ return Math.abs(value) <= NEAR_ZERO_TRANSFORM_RATIO * Math.abs(scale);
1767
+ }
1768
+ function isAxisAlignedScale([a, b, c, d]) {
1769
+ return isNearZero(b, a) && isNearZero(c, d);
1770
+ }
1771
+ function isQuarterTurn([a, b, c, d]) {
1772
+ return isNearZero(a, b) && isNearZero(d, c);
1773
+ }
1774
+ function isAxisAlignedEdge(x0, y0, x1, y1) {
1775
+ return x0 === x1 || y0 === y1;
1776
+ }
1777
+ function updateMinSubpathSize(minSubpathSize, [minX, minY, maxX, maxY]) {
1778
+ const hasEdges = minX !== Infinity;
1779
+ if (hasEdges) {
1780
+ minSubpathSize[0] = Math.min(minSubpathSize[0], maxX - minX);
1781
+ minSubpathSize[1] = Math.min(minSubpathSize[1], maxY - minY);
1782
+ }
1783
+ }
1784
+ function getAxisAlignedPath(data) {
1785
+ const minSubpathSize = [Infinity, Infinity];
1786
+ let subpathMinMax = BBOX_INIT.slice();
1787
+ let hasSubpath = false;
1788
+ let startX = 0;
1789
+ let startY = 0;
1790
+ let currentX = 0;
1791
+ let currentY = 0;
1792
+ for (let i = 0, ii = data.length; i < ii;) {
1793
+ switch (data[i++]) {
1794
+ case DrawOPS.moveTo:
1795
+ if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
1796
+ return null;
1797
+ }
1798
+ updateMinSubpathSize(minSubpathSize, subpathMinMax);
1799
+ subpathMinMax = BBOX_INIT.slice();
1800
+ hasSubpath = true;
1801
+ startX = currentX = data[i++];
1802
+ startY = currentY = data[i++];
1803
+ break;
1804
+ case DrawOPS.lineTo:
1805
+ {
1806
+ const x = data[i++];
1807
+ const y = data[i++];
1808
+ if (!hasSubpath || !isAxisAlignedEdge(currentX, currentY, x, y)) {
1809
+ return null;
1810
+ }
1811
+ Util.rectBoundingBox(currentX, currentY, x, y, subpathMinMax);
1812
+ currentX = x;
1813
+ currentY = y;
1814
+ break;
1815
+ }
1816
+ case DrawOPS.closePath:
1817
+ if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
1818
+ return null;
1819
+ }
1820
+ updateMinSubpathSize(minSubpathSize, subpathMinMax);
1821
+ subpathMinMax = BBOX_INIT.slice();
1822
+ currentX = startX;
1823
+ currentY = startY;
1824
+ break;
1825
+ default:
1826
+ return null;
1827
+ }
1828
+ }
1829
+ if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
1830
+ return null;
1831
+ }
1832
+ updateMinSubpathSize(minSubpathSize, subpathMinMax);
1833
+ const [minSubpathWidth, minSubpathHeight] = minSubpathSize;
1834
+ return minSubpathWidth > 0 && minSubpathHeight > 0 && minSubpathWidth < Infinity ? {
1835
+ data,
1836
+ minSubpathWidth,
1837
+ minSubpathHeight
1838
+ } : null;
1839
+ }
1840
+ function snapToDevicePixel(coordinate, scale, offset) {
1841
+ return (Math.round(scale * coordinate + offset) - offset) / scale;
1842
+ }
1843
+ function snapAxisAlignedPath({
1844
+ data,
1845
+ minSubpathWidth,
1846
+ minSubpathHeight
1847
+ }, transform) {
1848
+ const [a, b, c, d, e, f] = transform;
1849
+ let scaleX, offsetX, scaleY, offsetY;
1850
+ if (isAxisAlignedScale(transform)) {
1851
+ [scaleX, offsetX, scaleY, offsetY] = [a, e, d, f];
1852
+ } else if (isQuarterTurn(transform)) {
1853
+ [scaleX, offsetX, scaleY, offsetY] = [b, f, c, e];
1854
+ } else {
1855
+ return null;
1856
+ }
1857
+ if (Math.abs(scaleX * minSubpathWidth) < MIN_SNAPPED_CLIP_SIZE || Math.abs(scaleY * minSubpathHeight) < MIN_SNAPPED_CLIP_SIZE) {
1858
+ return null;
1859
+ }
1860
+ const snappedDrawOPS = [];
1861
+ for (let i = 0, ii = data.length; i < ii;) {
1862
+ const op = data[i++];
1863
+ snappedDrawOPS.push(op);
1864
+ if (op === DrawOPS.moveTo || op === DrawOPS.lineTo) {
1865
+ snappedDrawOPS.push(snapToDevicePixel(data[i++], scaleX, offsetX), snapToDevicePixel(data[i++], scaleY, offsetY));
1866
+ }
1867
+ }
1868
+ return snappedDrawOPS;
1869
+ }
1870
+ function recordClipPath(path, data) {
1871
+ const axisAlignedPath = getAxisAlignedPath(data);
1872
+ if (axisAlignedPath) {
1873
+ axisAlignedClipPaths.set(path, axisAlignedPath);
1874
+ }
1875
+ }
1876
+ function getPixelSnappedClipPath(path, transform) {
1877
+ const axisAlignedPath = axisAlignedClipPaths.get(path);
1878
+ const snappedDrawOPS = axisAlignedPath && snapAxisAlignedPath(axisAlignedPath, transform);
1879
+ return snappedDrawOPS ? makePathFromDrawOPS(snappedDrawOPS) : path;
1880
+ }
1762
1881
  function makePathFromDrawOPS(data) {
1763
1882
  const path = new Path2D();
1764
1883
  if (!data) {
@@ -2094,7 +2213,7 @@ class FloatingToolbar {
2094
2213
  }
2095
2214
 
2096
2215
  ;// ./src/shared/internal_evt.js
2097
- const INTERNAL_EVT = "32533502-63d2-47b3-84b0-128ba9620ee0";
2216
+ const INTERNAL_EVT = "b73885cd-1954-4723-8cc0-0364b7abb527";
2098
2217
  const internalOpt = Object.freeze({
2099
2218
  internal: INTERNAL_EVT
2100
2219
  });
@@ -10581,8 +10700,9 @@ function mirrorContextOperations(ctx, destCtx) {
10581
10700
  };
10582
10701
  }
10583
10702
  function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
10584
- const [a, b, c, d, tx, ty] = getCurrentTransform(ctx);
10585
- if (b === 0 && c === 0) {
10703
+ const transform = getCurrentTransform(ctx);
10704
+ const [a, b, c, d, tx, ty] = transform;
10705
+ if (isAxisAlignedScale(transform)) {
10586
10706
  const tlX = destX * a + tx;
10587
10707
  const rTlX = Math.round(tlX);
10588
10708
  const tlY = destY * d + ty;
@@ -10596,7 +10716,7 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
10596
10716
  ctx.setTransform(a, b, c, d, tx, ty);
10597
10717
  return [rWidth, rHeight];
10598
10718
  }
10599
- if (a === 0 && d === 0) {
10719
+ if (isQuarterTurn(transform)) {
10600
10720
  const tlX = destY * c + tx;
10601
10721
  const rTlX = Math.round(tlX);
10602
10722
  const tlY = destX * b + ty;
@@ -11822,7 +11942,11 @@ class CanvasGraphics {
11822
11942
  this.dependencyTracker.resetBBox(opIdx).recordBBox(opIdx, this.ctx, minMax[0] - outerExtraSize, minMax[2] + outerExtraSize, minMax[1] - outerExtraSize, minMax[3] + outerExtraSize).recordDependencies(opIdx, ["transform"]);
11823
11943
  }
11824
11944
  if (!(path instanceof Path2D)) {
11825
- path = data[0] = makePathFromDrawOPS(path);
11945
+ const drawOPS = path;
11946
+ path = data[0] = makePathFromDrawOPS(drawOPS);
11947
+ if (this.pendingClip) {
11948
+ recordClipPath(path, drawOPS);
11949
+ }
11826
11950
  }
11827
11951
  Util.axialAlignedBoundingBox(minMax, getCurrentTransform(this.ctx), this.current.minMax);
11828
11952
  const tilingDims = this.current.tilingPatternDims;
@@ -13152,10 +13276,11 @@ class CanvasGraphics {
13152
13276
  const ctx = this.ctx;
13153
13277
  if (this.pendingClip) {
13154
13278
  if (!isEmpty) {
13279
+ const clipPath = getPixelSnappedClipPath(path, getCurrentTransform(ctx));
13155
13280
  if (this.pendingClip === EO_CLIP) {
13156
- ctx.clip(path, "evenodd");
13281
+ ctx.clip(clipPath, "evenodd");
13157
13282
  } else {
13158
- ctx.clip(path);
13283
+ ctx.clip(clipPath);
13159
13284
  }
13160
13285
  }
13161
13286
  this.pendingClip = null;
@@ -15464,7 +15589,7 @@ function getDocument(src = {}) {
15464
15589
  }
15465
15590
  const docParams = {
15466
15591
  docId,
15467
- apiVersion: "6.4.299-box.1",
15592
+ apiVersion: "6.4.299-box.2",
15468
15593
  data,
15469
15594
  password,
15470
15595
  disableAutoFetch,
@@ -17165,8 +17290,8 @@ class InternalRenderTask {
17165
17290
  }
17166
17291
  }
17167
17292
  }
17168
- const version = "6.4.299-box.1";
17169
- const build = "99c657f";
17293
+ const version = "6.4.299-box.2";
17294
+ const build = "9c8224a";
17170
17295
 
17171
17296
  ;// ./src/display/editor/color_picker.js
17172
17297