teamsync-pdf-viewer 1.3.2 → 1.3.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 CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to `teamsync-pdf-viewer` are documented here.
4
4
 
5
+ ## [1.3.4] — 2026-09-04
6
+
7
+ ### Fixed
8
+ - **Mobile & Android Canvas Clamping**: Expanded `isMobileOrTablet()` to comprehensively detect Android and mobile devices, capping max dimension to 2048px and pixel buffer to 4.2 MP (~16MB) to eliminate canvas crashes and blank pages on mobile devices.
9
+ - **Render Task Lifecycle & Race Condition Fix**: Scoped `currentPage` locally within `renderCanvas` so cancelling in-flight renders during rapid zoom clicks never accidentally destroys resources of a newly scheduled page proxy.
10
+ - **Graceful Context Allocation Fallback**: Added half-resolution fallback if `getContext('2d')` ever encounters device memory pressure, preventing invisible pages.
11
+ - **Rapid Click Selection Prevention**: Added `userSelect: none` on toolbar zoom buttons to eliminate browser text selection during rapid clicking.
12
+
13
+ ## [1.3.3] — 2026-09-04
14
+
15
+ ### Fixed
16
+ - **Initial Programmatic Fit Scroll Compensation**: Fixed view jump on initial fit where scaling from seed 1.0 to ~2.27 at `scrollTop = 0` triggered viewport center compensation and hid page 1's top. Added `calculateScrollCompensation` with programmatic fit bypass and top-of-document boundary guard.
17
+ - **Capped Canvas Output Scale**: Capped `outputScale = Math.min(window.devicePixelRatio || 1, 2)` in `PageRenderer` and `LeftSidebar`, reducing GPU canvas raster memory and repaint strain on 3x+ Retina and mobile displays by over 55% while preserving 2x sharpness.
18
+ - **Scroll Shaking & Up-Front Dimension Reservation**: Replaced asynchronous sequential dimension streaming with up-front dimension measurement and space pre-allocation (`estimatePageDimensions`). Full scroll container height and row tops are reserved on the first frame, eliminating layout recalculations and page shifting/shaking during scrolling.
19
+ - **Exported Layout & Zoom Utilities**: Exported `calculateScrollCompensation`, `estimatePageDimensions`, `computeRowLayout`, `DEFAULT_FALLBACK_DIMS`, and related types from the package root.
20
+
5
21
  ## [1.3.2] — 2026-09-04
6
22
 
7
23
  ### Fixed
@@ -31,5 +31,8 @@ export type { PrintOptions } from './core/print';
31
31
  export { usePdfSearch, searchPdfText } from './hooks/usePdfSearch';
32
32
  export type { SearchResult, SearchBounds } from './hooks/usePdfSearch';
33
33
  export type { TransientHighlight } from './core/types';
34
- export { MIN_SCALE, MAX_SCALE, clampScale, calculateNextZoomIn, calculateNextZoomOut } from './utils/zoomUtils';
34
+ export { MIN_SCALE, MAX_SCALE, clampScale, calculateNextZoomIn, calculateNextZoomOut, calculateScrollCompensation } from './utils/zoomUtils';
35
+ export type { ScrollCompensationParams, ScrollPosition } from './utils/zoomUtils';
36
+ export { estimatePageDimensions, computeRowLayout, DEFAULT_FALLBACK_DIMS, hasDimensionMismatch } from './utils/layoutUtils';
37
+ export type { PageDimension, RowLayout } from './utils/layoutUtils';
35
38
  export * from './plugins/types';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
3
+ */
4
+ export interface PageDimension {
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export interface RowLayout {
9
+ heights: number[];
10
+ tops: number[];
11
+ total: number;
12
+ }
13
+ /** Standard US Letter dimensions in PDF points (72 points/inch: 8.5 x 11 inches). */
14
+ export declare const DEFAULT_FALLBACK_DIMS: PageDimension;
15
+ /**
16
+ * Pre-allocates an array of page dimensions for the entire document up front,
17
+ * reserving estimated space based on a sample page (e.g. Page 1).
18
+ */
19
+ export declare function estimatePageDimensions(numPages: number, sampleDim?: PageDimension): PageDimension[];
20
+ /**
21
+ * Computes row heights, vertical tops, and total container scroll height
22
+ * for given rows of pages and scale.
23
+ */
24
+ export declare function computeRowLayout(rows: number[][], dimsFor: (page: number) => PageDimension, scale: number, gap?: number): RowLayout;
25
+ /**
26
+ * Checks if any page dimension in array A differs from array B beyond a tolerance.
27
+ */
28
+ export declare function hasDimensionMismatch(dimsA: PageDimension[], dimsB: PageDimension[], tolerance?: number): boolean;
@@ -3,10 +3,12 @@
3
3
  */
4
4
  export declare const MIN_SCALE = 0.1;
5
5
  export declare const MAX_SCALE = 10;
6
+ export declare const isMobileOrTablet: () => boolean;
6
7
  export declare const isSafariOrMobile: () => boolean;
7
- export declare const MAX_CANVAS_DIM = 8192;
8
- export declare const MAX_CANVAS_DIM_MOBILE = 4096;
9
- export declare const MAX_CANVAS_PIXELS = 16777216;
8
+ export declare const MAX_CANVAS_DIM = 4096;
9
+ export declare const MAX_CANVAS_DIM_MOBILE = 2048;
10
+ export declare const MAX_CANVAS_PIXELS = 8388608;
11
+ export declare const MAX_CANVAS_PIXELS_MOBILE = 4194304;
10
12
  /**
11
13
  * Calculates the next step when zooming in.
12
14
  * - Below 200%: steps by +25%
@@ -30,3 +32,26 @@ export declare function clampScale(scale: number, minScale?: number, maxScale?:
30
32
  * canvas dimensions and texture memory stay strictly within hardware limits.
31
33
  */
32
34
  export declare function calculateSafeRenderScale(scale: number, outputScale: number, unscaledWidth: number, unscaledHeight: number, maxDim?: number, maxPixels?: number): number;
35
+ export interface ScrollCompensationParams {
36
+ prevScale: number;
37
+ newScale: number;
38
+ containerWidth: number;
39
+ containerHeight: number;
40
+ currentScrollLeft: number;
41
+ currentScrollTop: number;
42
+ basePageWidth: number;
43
+ focusPoint?: {
44
+ vx: number | null;
45
+ vy: number | null;
46
+ } | null;
47
+ isProgrammatic?: boolean;
48
+ }
49
+ export interface ScrollPosition {
50
+ scrollLeft: number;
51
+ scrollTop: number;
52
+ }
53
+ /**
54
+ * Calculates compensating scroll offsets during scale changes.
55
+ * Prevents view jumping or pushing page 1 down on initial fit or programmatic fit.
56
+ */
57
+ export declare function calculateScrollCompensation(params: ScrollCompensationParams): ScrollPosition;