flipbookengine 0.4.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.
- package/CHANGELOG.md +11 -1
- package/README.md +43 -43
- package/dist/adapters/PageFlipAdapter.d.ts +2 -0
- package/dist/core/PdfRenderCache.d.ts +22 -0
- package/dist/core/PdfRenderer.d.ts +8 -0
- package/dist/{engine-G9HiVpA-.js → engine-BuVkDIh-.js} +797 -672
- package/dist/engine-BuVkDIh-.js.map +1 -0
- package/dist/engine.d.ts +7 -0
- package/dist/flipbook-engine.css +1 -1
- package/dist/flipbook-engine.iife.js +24 -24
- package/dist/flipbook-engine.iife.js.map +1 -1
- package/dist/flipbook-engine.js +1 -1
- package/dist/flipbook-engine.react.js +1 -1
- package/dist/flipbook-engine.vue.js +1 -1
- package/package.json +5 -4
- package/dist/engine-G9HiVpA-.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- added on-demand PDF page rendering with first-page readiness and next-page prefetch
|
|
6
|
+
- added bounded per-instance PDF render cache via `pdfRenderCacheSize`
|
|
7
|
+
- added React/Vue wrapper, browser E2E, and large-document regression coverage
|
|
8
|
+
- added reduced-motion support for JavaScript page turns and CSS transitions
|
|
9
|
+
- removed test exception suppression so asynchronous teardown failures surface
|
|
10
|
+
|
|
11
|
+
|
|
2
12
|
|
|
3
13
|
## 0.4.0
|
|
4
14
|
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ FlipbookEngine is a modern, lightweight, and embeddable HTML flipbook viewer for
|
|
|
17
17
|
- **Theme Engine**: Styled with compiled CSS and CSS Custom Properties, featuring full support for light/dark modes (auto-responsive to Bootstrap 5 or tailorable per instance).
|
|
18
18
|
- **Multi-Language (i18n)**: Out-of-the-box support for English (`en`) and Turkish (`tr`) with customizable overrides.
|
|
19
19
|
- **Framework Wrappers**: Direct React and Vue wrapper exports for seamless modern integration.
|
|
20
|
+
- **Progressive PDF Rendering**: PDF pages render on demand with bounded concurrency and an instance-local LRU cache, keeping large documents responsive.
|
|
20
21
|
|
|
21
22
|
## Installation
|
|
22
23
|
|
|
@@ -45,20 +46,23 @@ const engine = new FlipbookEngine('#viewer', {
|
|
|
45
46
|
primaryColor: '#7367f0',
|
|
46
47
|
theme: 'auto',
|
|
47
48
|
locale: 'en',
|
|
48
|
-
pdfWorkerSrc
|
|
49
|
+
pdfWorkerSrc,
|
|
50
|
+
pdfRenderCacheSize: 32
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
await engine.init('/files/catalog.pdf');
|
|
52
54
|
```
|
|
53
55
|
|
|
54
|
-
Passing `pages` remains optional. When omitted, FlipbookEngine
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
`pdfRenderCacheSize` controls the per-instance LRU cache (default `32`, set to `0` to disable it).
|
|
55
59
|
|
|
56
60
|
### Browser CDN
|
|
57
61
|
|
|
58
62
|
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.
|
|
59
63
|
|
|
60
64
|
```html
|
|
61
|
-
<link rel="stylesheet" href="https://unpkg.com/flipbookengine@0.
|
|
65
|
+
<link rel="stylesheet" href="https://unpkg.com/flipbookengine@0.5.0/dist/flipbook-engine.css" />
|
|
62
66
|
<div id="viewer" style="width: 100%; height: 600px;"></div>
|
|
63
67
|
|
|
64
68
|
<script type="importmap">
|
|
@@ -69,7 +73,7 @@ Use the ESM build with an import map for PDF.js. The worker must be served from
|
|
|
69
73
|
}
|
|
70
74
|
</script>
|
|
71
75
|
<script type="module">
|
|
72
|
-
import { FlipbookEngine } from 'https://unpkg.com/flipbookengine@0.
|
|
76
|
+
import { FlipbookEngine } from 'https://unpkg.com/flipbookengine@0.5.0/dist/flipbook-engine.js';
|
|
73
77
|
|
|
74
78
|
const engine = new FlipbookEngine('#viewer', {
|
|
75
79
|
pdfWorkerSrc: 'https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.worker.min.mjs'
|
|
@@ -137,30 +141,9 @@ const pages = [
|
|
|
137
141
|
|
|
138
142
|
Upgrading from 0.3.x to 0.4.0 keeps the public engine methods intact. The release isolates state per engine instance, makes wrapper updates lifecycle-safe, and scopes viewer markup to its container. If host CSS or automation selected the former fixed viewer IDs, migrate those selectors to the instance classes documented in the theming guide. PDF-backed consumers should configure `pdfWorkerSrc`; image-only viewers do not expose a download control.
|
|
139
143
|
|
|
144
|
+
For 0.5.0 behavior, see the [0.5.0 migration guide](./docs/migration-0.5.0.md). PDF-backed viewers now render on demand; callers should use `progress` and `error` events for rendering telemetry.
|
|
145
|
+
|
|
140
146
|
|
|
141
|
-
## Local npm Release
|
|
142
|
-
|
|
143
|
-
Run the complete release verification locally before publishing:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
npm ci
|
|
147
|
-
npm run release:verify
|
|
148
|
-
npm login
|
|
149
|
-
npm publish --provenance --access public
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Confirm the package version with `npm pkg get version` before publishing. The publish command is intentionally separate from `release:verify` so credentials and the final npm upload remain under the maintainer's direct control.
|
|
153
|
-
### Windows PowerShell
|
|
154
|
-
|
|
155
|
-
If PowerShell blocks `npm.ps1` because script execution is disabled, use the Windows command shim explicitly:
|
|
156
|
-
|
|
157
|
-
```powershell
|
|
158
|
-
npm.cmd ci
|
|
159
|
-
npm.cmd run release:verify
|
|
160
|
-
npm.cmd login
|
|
161
|
-
npm.cmd whoami
|
|
162
|
-
npm.cmd publish --access public
|
|
163
|
-
```
|
|
164
147
|
## Public API Reference
|
|
165
148
|
|
|
166
149
|
The `FlipbookEngine` class exposes the following public methods:
|
|
@@ -198,11 +181,12 @@ Supported events: `init`, `progress`, `pageChange`, `zoomChange`, `singlePageMod
|
|
|
198
181
|
| `soundEnabled` | `boolean` | `true` | Enables page turning sound effect. |
|
|
199
182
|
| `soundUrl` | `string` | `'https://.../page-flip.mp3'` | URL of the audio file. |
|
|
200
183
|
| `autoPlayInterval`| `number` | `3000` | Autoplay page duration in milliseconds. |
|
|
201
|
-
| `flippingTime` | `number` | `1000` | Duration of the page turn animation in milliseconds. |
|
|
184
|
+
| `flippingTime` | `number` | `1000` | Duration of the page turn animation in milliseconds; automatically disabled when reduced motion is preferred. |
|
|
202
185
|
| `maxShadowOpacity` | `number` | `0.5` | Maximum opacity of the shadow during page turn (0 to 1). |
|
|
203
186
|
| `whiteLabel` | `boolean` | `false` | Hides the "Powered by FlipbookEngine" watermark. |
|
|
204
187
|
| `pdfWorkerSrc` | `string` | - | URL of the PDF.js worker emitted or hosted by the consuming application. |
|
|
205
|
-
| `pdfRenderConcurrency` | `number` | `3` | Maximum number of PDF pages rendered concurrently
|
|
188
|
+
| `pdfRenderConcurrency` | `number` | `3` | Maximum number of PDF pages rendered concurrently when on-demand pages are requested. |
|
|
189
|
+
| `pdfRenderCacheSize` | `number` | `32` | Maximum number of rendered PDF page images retained per engine instance (LRU); `0` disables caching. |
|
|
206
190
|
|
|
207
191
|
## Styling and Theming
|
|
208
192
|
|
|
@@ -234,7 +218,9 @@ FlipbookEngine does not bundle PDF.js or its worker. `pdfjs-dist` remains a norm
|
|
|
234
218
|
### Performance Highlights
|
|
235
219
|
* **Hardware Accelerated:** Uses CSS-based 3D transformations (`transform: rotateY`, `translateZ`) without a WebGL runtime.
|
|
236
220
|
* **Progressive Image Quality:** Loads low-quality page assets first and upgrades visible pages to their normal-quality source through `IntersectionObserver`.
|
|
221
|
+
* **On-demand PDF Rendering:** Large PDFs create lightweight placeholders first; the current page and next page render before or during navigation.
|
|
237
222
|
* **Bounded PDF Rendering:** PDF pages are rendered with configurable concurrency (`pdfRenderConcurrency`, default `3`) and can be cancelled when an initialization is superseded or destroyed.
|
|
223
|
+
* **PDF Render Cache:** A bounded per-instance LRU cache (`pdfRenderCacheSize`, default `32`) avoids repeated canvas work while preventing unbounded memory growth.
|
|
238
224
|
|
|
239
225
|
## FlipbookEngine vs. The Industry
|
|
240
226
|
|
|
@@ -248,22 +234,36 @@ When choosing a flipbook library, here is how we compare to other solutions:
|
|
|
248
234
|
|
|
249
235
|
## Acknowledgments
|
|
250
236
|
|
|
251
|
-
A special thanks to the
|
|
237
|
+
A special thanks to the domwise project. FlipbookEngine's reactive UI layer is powered by **domwise** and `@preact/signals-core`, keeping the UI update path small without requiring a traditional Virtual DOM runtime.
|
|
252
238
|
|
|
253
239
|
---
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
- **
|
|
263
|
-
- **
|
|
264
|
-
- **
|
|
265
|
-
- **
|
|
266
|
-
|
|
240
|
+
## Roadmap
|
|
241
|
+
|
|
242
|
+
FlipbookEngine has two complementary targets: an AGPL open-source viewer package and a separate closed-source commercial backend edition.
|
|
243
|
+
|
|
244
|
+
### Open-source v1.0.0 (AGPL viewer)
|
|
245
|
+
|
|
246
|
+
The npm package remains an embeddable, framework-agnostic PDF viewer. The open-source v1.0.0 target focuses on client-side reader capabilities:
|
|
247
|
+
|
|
248
|
+
- **Table of Contents (Index):** Interactive navigation to chapters or product categories.
|
|
249
|
+
- **Page Notes & Annotations:** Reader notes and bookmarks stored by the host application.
|
|
250
|
+
- **Full-Text PDF Search:** Client-side text extraction and highlighting without blocking the viewer.
|
|
251
|
+
- **Interactive Hotspots & Pop-ups:** Custom overlays for media, galleries, and commerce links.
|
|
252
|
+
- **Deep Linking & Social Share:** URLs that address specific pages or spreads.
|
|
253
|
+
|
|
254
|
+
The open-source viewer continues to use PDF.js as an external npm dependency and does not require a backend renderer.
|
|
255
|
+
|
|
256
|
+
### Commercial edition (closed-source backend)
|
|
257
|
+
|
|
258
|
+
The commercial roadmap is separate from the AGPL package and is intended for a separate backend project. It will provide licensed server-side capabilities, including:
|
|
259
|
+
|
|
260
|
+
- **Backend PDF rendering:** Secure, server-side rendering and caching for protected documents and high-volume workloads.
|
|
261
|
+
- **Protected partial downloads:** Server-generated page selections and authorization-aware download policies.
|
|
262
|
+
- **AI-assisted document features:** Backend indexing, catalog search, and Chat with Docs integrations.
|
|
263
|
+
- **Enterprise identity and provenance:** OIDC, auditability, tenant controls, and deployment integration.
|
|
264
|
+
|
|
265
|
+
These backend renderer and enterprise features will not be included in the public `flipbookengine` npm package; they will be delivered under the commercial license.
|
|
266
|
+
|
|
267
267
|
---
|
|
268
268
|
|
|
269
269
|
## Licensing
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FlipbookStore } from '../state/store';
|
|
2
2
|
import { FlipbookEngineOptions } from '../engine';
|
|
3
3
|
|
|
4
|
+
export declare function prefersReducedMotion(): boolean;
|
|
5
|
+
export declare function resolveFlippingTime(flippingTime?: number, reducedMotion?: boolean): number;
|
|
4
6
|
export declare class PageFlipAdapter {
|
|
5
7
|
private pageFlip;
|
|
6
8
|
private bookContainer;
|
|
@@ -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
|
+
}
|
|
@@ -10,11 +10,13 @@ export interface PdfRenderOptions {
|
|
|
10
10
|
format?: string;
|
|
11
11
|
workerSrc?: string;
|
|
12
12
|
concurrency?: number;
|
|
13
|
+
cacheSize?: number;
|
|
13
14
|
}
|
|
14
15
|
export declare class PdfRenderer {
|
|
15
16
|
private pdfDoc;
|
|
16
17
|
private loadingTask;
|
|
17
18
|
private options;
|
|
19
|
+
private readonly cache;
|
|
18
20
|
constructor(options?: PdfRenderOptions);
|
|
19
21
|
/** Loads a PDF document and cancels PDF.js loading when the signal aborts. */
|
|
20
22
|
loadDocument(pdfUrl: string, signal?: AbortSignal): Promise<number>;
|
|
@@ -27,6 +29,12 @@ export declare class PdfRenderer {
|
|
|
27
29
|
}>;
|
|
28
30
|
/** Renders pages concurrently with a bounded worker pool and preserves page order. */
|
|
29
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
|
+
};
|
|
30
38
|
private throwIfAborted;
|
|
31
39
|
private createAbortError;
|
|
32
40
|
destroy(): void;
|