flipbookengine 0.6.0 → 0.6.5
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 +14 -1
- package/README.md +18 -7
- package/dist/core/LayoutManager.d.ts +1 -1
- package/dist/core/PdfRenderer.d.ts +12 -2
- package/dist/{engine-MdZzt6R9.js → engine-DhQ2zxpm.js} +1173 -1112
- package/dist/engine-DhQ2zxpm.js.map +1 -0
- package/dist/engine.d.ts +10 -1
- package/dist/flipbook-engine.css +1 -1
- package/dist/flipbook-engine.iife.js +30 -30
- package/dist/flipbook-engine.iife.js.map +1 -1
- package/dist/flipbook-engine.js +6 -5
- package/dist/flipbook-engine.react.js +1 -1
- package/dist/flipbook-engine.vue.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/model/pages.d.ts +2 -0
- package/dist/theme/theme.d.ts +16 -0
- package/package.json +1 -1
- package/dist/engine-MdZzt6R9.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Next (unreleased)
|
|
4
|
+
|
|
5
|
+
## 0.6.5
|
|
6
|
+
|
|
7
|
+
- added automatic A3 landscape PDF splitting with configurable auto, single, and split modes
|
|
8
|
+
- added source-page-aware lazy rendering for split PDF pages
|
|
9
|
+
- added optional light/dark viewer backgrounds and responsive presentation gutters
|
|
10
|
+
- enlarged the opt-in thumbnail rail and moved page labels into transparent, high-contrast overlays
|
|
11
|
+
- kept thumbnail labels black in both themes and preserved a thin neon selected state
|
|
12
|
+
- enabled native mobile scrolling to avoid non-cancelable touchstart interventions
|
|
13
|
+
- fixed single-view PDF hydration after switching from spread mode
|
|
14
|
+
- added regression coverage for PDF splitting, backgrounds, presentation layout, and PDF hydration
|
|
15
|
+
|
|
16
|
+
## 0.6.0
|
|
4
17
|
|
|
5
18
|
- added a localized, theme-aware Table of Contents panel with nested host-provided page entries
|
|
6
19
|
- added TOC visibility events, page navigation, normalization, accessibility, and regression tests
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# FlipbookEngine
|
|
2
2
|
|
|
3
|
-
> **Release notice:** `flipbookengine@0.5
|
|
4
|
-
> **Development notice:**
|
|
3
|
+
> **Release notice:** `flipbookengine@0.6.5` is the latest published release and includes the localized Table of Contents API.
|
|
4
|
+
> **Development notice:** Version 0.6.5 adds automatic PDF A3 splitting, per-theme backgrounds, responsive viewer gutters, enlarged thumbnails, and mobile touch fixes.
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/flipbookengine)
|
|
7
7
|
[](https://github.com/Bizeka/flipbook-engine/blob/main/LICENSE)
|
|
@@ -45,18 +45,23 @@ import pdfWorkerSrc from 'pdfjs-dist/build/pdf.worker.mjs?url';
|
|
|
45
45
|
|
|
46
46
|
const engine = new FlipbookEngine('#viewer', {
|
|
47
47
|
allowDownload: true,
|
|
48
|
-
showThumbs:
|
|
48
|
+
showThumbs: false,
|
|
49
49
|
primaryColor: '#7367f0',
|
|
50
50
|
theme: 'auto',
|
|
51
51
|
locale: 'en',
|
|
52
52
|
pdfWorkerSrc,
|
|
53
|
-
pdfRenderCacheSize: 32
|
|
53
|
+
pdfRenderCacheSize: 32,
|
|
54
|
+
pdfPageMode: 'auto',
|
|
55
|
+
background: {
|
|
56
|
+
light: { color: '#f8fafc', image: '/branding/light.webp', size: 'cover' },
|
|
57
|
+
dark: { color: '#0f172a', image: '/branding/dark.webp', size: 'cover' }
|
|
58
|
+
}
|
|
54
59
|
});
|
|
55
60
|
|
|
56
61
|
await engine.init('/files/catalog.pdf');
|
|
57
62
|
```
|
|
58
63
|
|
|
59
|
-
Passing `pages` remains optional. When omitted, FlipbookEngine creates the page structure from `pdfUrl`, renders the first page before `init` resolves, and prefetches the next page. Additional pages render as they become visible or are selected.
|
|
64
|
+
Passing `pages` remains optional. When omitted, FlipbookEngine creates the page structure from `pdfUrl`, renders the first page before `init` resolves, and prefetches the next page. Additional pages render as they become visible or are selected. In `pdfPageMode: 'auto'` (the default), ISO A3 landscape pages are normalized into two logical pages; use `'single'` to keep every PDF page intact or `'split'` to split every landscape PDF page.
|
|
60
65
|
|
|
61
66
|
`pdfRenderCacheSize` controls the per-instance LRU cache (default `32`, set to `0` to disable it).
|
|
62
67
|
|
|
@@ -65,7 +70,7 @@ Passing `pages` remains optional. When omitted, FlipbookEngine creates the page
|
|
|
65
70
|
Use the ESM build with an import map for PDF.js. The worker must be served from a URL your site permits in its Content Security Policy.
|
|
66
71
|
|
|
67
72
|
```html
|
|
68
|
-
<link rel="stylesheet" href="https://unpkg.com/flipbookengine@0.5
|
|
73
|
+
<link rel="stylesheet" href="https://unpkg.com/flipbookengine@0.6.5/dist/flipbook-engine.css" />
|
|
69
74
|
<div id="viewer" style="width: 100%; height: 600px;"></div>
|
|
70
75
|
|
|
71
76
|
<script type="importmap">
|
|
@@ -76,7 +81,7 @@ Use the ESM build with an import map for PDF.js. The worker must be served from
|
|
|
76
81
|
}
|
|
77
82
|
</script>
|
|
78
83
|
<script type="module">
|
|
79
|
-
import { FlipbookEngine } from 'https://unpkg.com/flipbookengine@0.5
|
|
84
|
+
import { FlipbookEngine } from 'https://unpkg.com/flipbookengine@0.6.5/dist/flipbook-engine.js';
|
|
80
85
|
|
|
81
86
|
const engine = new FlipbookEngine('#viewer', {
|
|
82
87
|
pdfWorkerSrc: 'https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.worker.min.mjs'
|
|
@@ -192,6 +197,12 @@ Supported events: `init`, `progress`, `pageChange`, `zoomChange`, `singlePageMod
|
|
|
192
197
|
| `pdfWorkerSrc` | `string` | - | URL of the PDF.js worker emitted or hosted by the consuming application. |
|
|
193
198
|
| `pdfRenderConcurrency` | `number` | `3` | Maximum number of PDF pages rendered concurrently when on-demand pages are requested. |
|
|
194
199
|
| `pdfRenderCacheSize` | `number` | `32` | Maximum number of rendered PDF page images retained per engine instance (LRU); `0` disables caching. |
|
|
200
|
+
| `pdfPageMode` | `'auto' \| 'single' \| 'split'` | `'auto'` | Controls PDF page splitting: A3 landscape pages are split automatically, all landscape pages can be split explicitly, or splitting can be disabled. |
|
|
201
|
+
| `background` | `FlipbookBackgrounds \| null` | `null` | Optional light/dark viewer backgrounds with color, image, size, position, and repeat settings. |
|
|
202
|
+
|
|
203
|
+
## PDF page formats
|
|
204
|
+
|
|
205
|
+
PDF.js page dimensions are detected at runtime, so portrait A4, landscape A4, and other page ratios are supported without a fixed size preset. A3 landscape pages are split into left/right logical pages when `pdfPageMode` is `'auto'` or `'split'`; the halves are presented as an A4-like spread in double-page mode.
|
|
195
206
|
|
|
196
207
|
## Styling and Theming
|
|
197
208
|
|
|
@@ -4,6 +4,14 @@ export interface PdfRenderProgress {
|
|
|
4
4
|
completed: number;
|
|
5
5
|
total: number;
|
|
6
6
|
}
|
|
7
|
+
export type PdfPageMode = 'auto' | 'single' | 'split';
|
|
8
|
+
export interface PdfPageLayout {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
split: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Detects ISO A3 landscape pages while allowing PDF metadata rounding and bleed. */
|
|
14
|
+
export declare function isA3Landscape(width: number, height: number): boolean;
|
|
7
15
|
export interface PdfRenderOptions {
|
|
8
16
|
scale?: number;
|
|
9
17
|
quality?: number;
|
|
@@ -22,8 +30,10 @@ export declare class PdfRenderer {
|
|
|
22
30
|
loadDocument(pdfUrl: string, signal?: AbortSignal): Promise<number>;
|
|
23
31
|
/** Renders a specific page to a Data URL. The page index is 1-based. */
|
|
24
32
|
renderPageToDataUrl(pageIndex: number, signal?: AbortSignal): Promise<string>;
|
|
25
|
-
/**
|
|
26
|
-
|
|
33
|
+
/** Returns source page dimensions and whether the page should be split. */
|
|
34
|
+
getPageLayouts(mode?: PdfPageMode): Promise<PdfPageLayout[]>;
|
|
35
|
+
/** Calculates the best viewport dimensions based on the first logical page. */
|
|
36
|
+
calculateViewportDimensions(baseShortSide?: number, firstPageLayout?: PdfPageLayout): Promise<{
|
|
27
37
|
width: number;
|
|
28
38
|
height: number;
|
|
29
39
|
}>;
|