flipbookengine 0.3.0 → 0.5.0

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.
@@ -1,15 +1,33 @@
1
+ import { FlipbookStore } from '../state/store';
2
+
3
+ /**
4
+ * @license FlipbookEngine v0.2.4
5
+ * Copyright (c) 2026 Murat Dogan
6
+ *
7
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
8
+ *
9
+ * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
10
+ * under the terms of the GNU Affero General Public License v3.0.
11
+ *
12
+ * 2. Commercial License: If you wish to use this software in commercial,
13
+ * closed-source, or SaaS products without the AGPLv3 obligations,
14
+ * you must purchase a Commercial License from:
15
+ * https://flipbookengine.com/pricing
16
+ */
1
17
  export declare class LayoutManager {
2
18
  private wrapperElement;
3
19
  private sizerElement;
4
20
  private pageViewport;
21
+ private store;
5
22
  private resizeObserver;
6
23
  private orientationMediaQuery;
24
+ private orientationChangeHandler;
7
25
  private unsubs;
8
26
  onResizeCallback?: () => void;
9
27
  constructor(pageViewport: {
10
28
  width: number;
11
29
  height: number;
12
- });
30
+ }, store: FlipbookStore);
13
31
  init(wrapperElement: HTMLElement, sizerElement: HTMLElement): void;
14
32
  private setupStateSync;
15
33
  private setupResizeObserver;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Small LRU cache for rendered PDF page data URLs.
3
+ * The cache is intentionally owned by one PdfRenderer instance so pages from
4
+ * different engine instances or documents can never be mixed.
5
+ */
6
+ export declare class PdfRenderCache {
7
+ private readonly maxEntries;
8
+ private readonly entries;
9
+ private hits;
10
+ private misses;
11
+ constructor(maxEntries?: number);
12
+ get(pageNumber: number): string | undefined;
13
+ set(pageNumber: number, dataUrl: string): void;
14
+ clear(): void;
15
+ get size(): number;
16
+ getStats(): {
17
+ size: number;
18
+ maxEntries: number;
19
+ hits: number;
20
+ misses: number;
21
+ };
22
+ }
@@ -1,34 +1,41 @@
1
1
  import { NormalizedFlipbookPage } from '../model/pages';
2
2
 
3
+ export interface PdfRenderProgress {
4
+ completed: number;
5
+ total: number;
6
+ }
3
7
  export interface PdfRenderOptions {
4
8
  scale?: number;
5
9
  quality?: number;
6
10
  format?: string;
11
+ workerSrc?: string;
12
+ concurrency?: number;
13
+ cacheSize?: number;
7
14
  }
8
15
  export declare class PdfRenderer {
9
16
  private pdfDoc;
17
+ private loadingTask;
10
18
  private options;
19
+ private readonly cache;
11
20
  constructor(options?: PdfRenderOptions);
12
- /**
13
- * Loads the PDF document from the given URL.
14
- */
15
- loadDocument(pdfUrl: string): Promise<number>;
16
- /**
17
- * Renders a specific page to a Data URL.
18
- * @param pageIndex 1-based page index
19
- */
20
- renderPageToDataUrl(pageIndex: number): Promise<string>;
21
- /**
22
- * Calculates the best viewport dimensions based on the first page.
23
- * Used for determining the overall flipbook dimensions.
24
- */
21
+ /** Loads a PDF document and cancels PDF.js loading when the signal aborts. */
22
+ loadDocument(pdfUrl: string, signal?: AbortSignal): Promise<number>;
23
+ /** Renders a specific page to a Data URL. The page index is 1-based. */
24
+ renderPageToDataUrl(pageIndex: number, signal?: AbortSignal): Promise<string>;
25
+ /** Calculates the best viewport dimensions based on the first page. */
25
26
  calculateViewportDimensions(baseShortSide?: number): Promise<{
26
27
  width: number;
27
28
  height: number;
28
29
  }>;
29
- /**
30
- * Renders all pages sequentially and returns an array of NormalizedFlipbookPage.
31
- */
32
- renderAllPages(): Promise<NormalizedFlipbookPage[]>;
30
+ /** Renders pages concurrently with a bounded worker pool and preserves page order. */
31
+ renderAllPages(signal?: AbortSignal, onProgress?: (progress: PdfRenderProgress) => void): Promise<NormalizedFlipbookPage[]>;
32
+ getCacheStats(): {
33
+ size: number;
34
+ maxEntries: number;
35
+ hits: number;
36
+ misses: number;
37
+ };
38
+ private throwIfAborted;
39
+ private createAbortError;
33
40
  destroy(): void;
34
41
  }