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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
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
+
12
+
13
+ ## 0.4.0
14
+
15
+ - externalized PDF.js as an npm dependency with consumer-provided worker configuration
16
+ - fixed PDF-only initialization when `pages` is omitted
17
+ - isolated engine state and lifecycle cancellation per instance
18
+ - aligned framework wrappers, events, options, fullscreen, audio, and download controls
19
+ - added progressive image quality loading and bounded PDF rendering with cancellation
20
+ - added accessibility semantics, structured PDF progress/error events, and expanded regression tests
21
+ - added CI dependency audit, reproducible package verification, and provenance-enabled release workflow
2
22
 
3
23
  ## 0.1.0
4
24
 
package/README.md CHANGED
@@ -1,221 +1,279 @@
1
- # FlipbookEngine
2
-
3
- [![NPM Version](https://img.shields.io/npm/v/flipbookengine?style=flat-square&color=blue)](https://www.npmjs.com/package/flipbookengine)
4
- [![License](https://img.shields.io/npm/l/flipbookengine?style=flat-square)](https://github.com/Bizeka/flipbook-engine/blob/main/LICENSE)
5
- [![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/flipbookengine?style=flat-square)](https://www.npmjs.com/package/flipbookengine)
6
- [![NPM Downloads](https://img.shields.io/npm/dt/flipbookengine?style=flat-square)](https://www.npmjs.com/package/flipbookengine)
7
-
8
- **[🔥 Live Demo & Playground](https://flipbookengine.com)**
9
-
10
- FlipbookEngine is a modern, lightweight, and embeddable HTML flipbook viewer for PDF-backed catalogs, brochures, and digital publications. Written in TypeScript, it features single-page and spread modes, a thumbnail rail, smooth zoom/pan, full internationalization (i18n), and robust theme customization.
11
-
12
- ## Highlights
13
-
14
- - **Dual-Mode Layout**: Seamlessly switches between single-page (mobile-optimized) and spread (book/catalog layout) modes.
15
- - **Rich Interaction**: Built-in thumbnail navigation rail, smooth zoom & pan, and HTML5 fullscreen support.
16
- - **Media & Autoplay**: Configurable page-flip sound effects and automated slideshow presentation with `Autoplay`.
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
- - **Multi-Language (i18n)**: Out-of-the-box support for English (`en`) and Turkish (`tr`) with customizable overrides.
19
- - **Framework Wrappers**: Direct React and Vue wrapper exports for seamless modern integration.
20
-
21
- ## Installation
22
-
23
- Install via npm:
24
-
25
- ```bash
26
- npm install flipbookengine
27
- ```
28
-
29
- For direct CDN usage in the browser (Vanilla HTML/JS):
30
-
31
- ```html
32
- <link rel="stylesheet" href="https://unpkg.com/flipbookengine/dist/flipbook-engine.css" />
33
- <script src="https://unpkg.com/flipbookengine/dist/flipbook-engine.iife.js"></script>
34
- ```
35
-
36
- ## Quick Start
37
-
38
- ### Vanilla HTML / JS
39
-
40
- Include the styles and script, then initialize the engine:
41
-
42
- ```html
43
- <div id="viewer" style="width: 100%; height: 600px;"></div>
44
-
45
- <script>
46
- const engine = new FlipbookEngine('#viewer', {
47
- allowDownload: true,
48
- showThumbs: true,
49
- primaryColor: '#7367f0',
50
- theme: 'auto',
51
- locale: 'en'
52
- });
53
-
54
- engine.init('/files/catalog.pdf', [
55
- { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
56
- { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
57
- ]);
58
- </script>
59
- ```
60
-
61
- ### React
62
-
63
- ```tsx
64
- import React, { useRef } from 'react';
65
- import { Flipbook, FlipbookRef } from 'flipbookengine/react';
66
- import 'flipbookengine/dist/flipbook-engine.css';
67
-
68
- function CatalogViewer() {
69
- const flipbookRef = useRef<FlipbookRef>(null);
70
-
71
- const handleNextPage = () => {
72
- flipbookRef.current?.goToPage(flipbookRef.current.getCurrentPage() + 1);
73
- };
74
-
75
- return (
76
- <Flipbook
77
- ref={flipbookRef}
78
- pdfUrl="/files/catalog.pdf"
79
- pages={[
80
- { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
81
- { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
82
- ]}
83
- allowDownload={true}
84
- showThumbs={true}
85
- primaryColor="#7367f0"
86
- />
87
- );
88
- }
89
- ```
90
-
91
- ### Vue 3
92
-
93
- ```vue
94
- <template>
95
- <Flipbook
96
- pdfUrl="/files/catalog.pdf"
97
- :pages="pages"
98
- :allowDownload="true"
99
- :showThumbs="true"
100
- primaryColor="#7367f0"
101
- />
102
- </template>
103
-
104
- <script setup>
105
- import { Flipbook } from 'flipbookengine/vue';
106
- import 'flipbookengine/dist/flipbook-engine.css';
107
-
108
- const pages = [
109
- { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
110
- { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
111
- ];
112
- </script>
113
- ```
114
-
115
- ## Public API Reference
116
-
117
- The `FlipbookEngine` class exposes the following public methods:
118
-
119
- - **`init(pdfUrl: string, imageList?: FlipbookPageAsset[])`**: Initializes the viewer and loads the flipbook with pages.
120
- - **`goToPage(pageIndex: number)`**: Navigates programmatically to a 0-based page index.
121
- - **`getCurrentPage()`**: Returns the 0-based index of the currently active page.
122
- - **`getTotalPages()`**: Returns the total number of pages.
123
- - **`getZoom()`**: Returns the current zoom level (default is `1`).
124
- - **`setZoom(zoomLevel: number)`**: Programmatically sets the zoom level (accepts values between `0.5` and `5`).
125
- - **`setSingleMode(isSingle: boolean)`**: Programmatically toggles between single-page mode (`true`) and double-page spread mode (`false`).
126
- - **`toggleFullscreen()`**: Programmatically toggles fullscreen mode.
127
- - **`updateOptions(options: Partial<FlipbookEngineOptions>)`**: Updates instance options at runtime.
128
- - **`setLocale(locale: string, messages?: PartialFlipbookMessages)`**: Updates the locale programmatically.
129
- - **`destroy(clearMarkup = true)`**: Tears down the instance and clean up DOM listeners.
130
-
131
- ### Subscribing to Events
132
-
133
- You can subscribe to events using `.on()`:
134
-
135
- ```ts
136
- const unsubscribe = engine.on('pageChange', ({ currentPage, totalPages, isSingle }) => {
137
- console.log('Page Changed:', currentPage, 'Total:', totalPages);
138
- });
139
-
140
- // To unsubscribe:
141
- unsubscribe();
142
- ```
143
-
144
- Supported events: `pageChange`, `zoomChange`, `singlePageModeChange`, `thumbsToggle`, `destroy`.
145
-
146
- | Option | Type | Default | Description |
147
- | :--- | :--- | :--- | :--- |
148
- | `soundEnabled` | `boolean` | `true` | Enables page turning sound effect. |
149
- | `soundUrl` | `string` | `'https://.../page-flip.mp3'` | URL of the audio file. |
150
- | `autoPlayInterval`| `number` | `3000` | Autoplay page duration in milliseconds. |
151
- | `flippingTime` | `number` | `1000` | Duration of the page turn animation in milliseconds. |
152
- | `maxShadowOpacity` | `number` | `0.5` | Maximum opacity of the shadow during page turn (0 to 1). |
153
- | `whiteLabel` | `boolean` | `false` | Hides the "Powered by FlipbookEngine" watermark. |
154
-
155
- ## Styling and Theming
156
-
157
- FlipbookEngine features fully custom-property-based styling compatible with modern styling systems.
158
-
159
- ### Global CSS Variables
160
-
161
- ```css
162
- :root {
163
- --mainbgcolor: #f3f6fb;
164
- --panelbgcolor: #172033;
165
- --accentcolor: #7367f0;
166
- --thumbrailbgcolor: #0f172a;
167
- }
168
- ```
169
-
170
- ## 🚀 Performance & Bundle Metrics
171
-
172
- FlipbookEngine is engineered for high performance, utilizing hardware-accelerated CSS 3D transforms instead of heavy WebGL, ensuring a smooth **60 FPS** experience even on low-end mobile devices.
173
-
174
- ### 📦 Bundle Size (Zero-Config PDF Engine)
175
- Unlike other libraries that require complex external PDF.js worker configurations, FlipbookEngine ships as an **"All-in-One"** package. It includes the Core Engine, UI layout, StPageFlip, and the full PDF.js rendering engine out of the box.
176
-
177
- * **Core + PDF Engine (Gzipped):** `~788 KB` *(A single drop-in script, no external workers needed)*
178
- * **Styles (CSS Gzipped):** `~2.9 KB`
179
- * **React / Vue Wrappers (Gzipped):** `< 1 KB`
180
-
181
- ### ⚡ Performance Highlights
182
- * **Hardware Accelerated:** Uses purely CSS-based 3D transformations (`transform: rotateY`, `translateZ`) which offloads rendering to the GPU. No heavy WebGL overhead.
183
- * **Smart Memory Management (Lazy Loading):** Automatically unloads hidden pages from the DOM and destroys unused PDF blobs to prevent memory leaks on large catalogs.
184
- * **Zero-CLS Layouts:** Prevents Cumulative Layout Shift (CLS) by utilizing highly optimized `AbortController` bound resize event listeners and native CSS `aspect-ratio` calculations.
185
- * **Eco-Friendly Standby:** Stops running layout calculations when the catalog is not actively being dragged or flipped.
186
-
187
- ## 🥊 FlipbookEngine vs. The Industry
188
-
189
- When choosing a flipbook library, here is how we compare to other solutions:
190
-
191
- * **Legacy Libraries (e.g., Turn.js):** Turn.js is over a decade old, relies on jQuery, and lacks native PDF support. **FlipbookEngine** uses a modern framework-agnostic stack (Vanilla/React/Vue), TypeScript, and has built-in PDF.js integration.
192
- * **Heavy 3D Plugins (e.g., DearFlip, Real3D):** Many 3D plugins use WebGL, which drains CPU/RAM and can be sluggish on mobile. **FlipbookEngine** is powered by StPageFlip, delivering buttery-smooth 60FPS CSS 2D/3D performance while remaining lightweight.
193
- * **Closed SaaS Platforms (e.g., Issuu, Heyzine):** These charge high monthly fees and lock your data on their servers. **FlipbookEngine** gives you 100% control to host and embed directly in your own code (AGPL-3.0).
194
-
195
- ---
196
-
197
- ## 🙏 Acknowledgments
198
-
199
- A special thanks to the incredible team behind **[Serenity](https://github.com/serenity-is/serenity)**. FlipbookEngine's reactive UI layer is proudly powered by **[domwise](https://github.com/serenity-is/serenity/tree/master/packages/domwise)** (a brilliant DOM manipulation library developed by the Serenity team). Coupled with `@preact/signals-core`, `domwise` allows us to completely bypass the heavy overhead of traditional Virtual DOM diffing. This architectural choice is a massive contributor to FlipbookEngine's lightning-fast UI updates, ensuring buttery-smooth 60 FPS performance even on low-end mobile devices.
200
-
201
- ---
202
-
203
- ## 🗺️ Roadmap (Upcoming in v1.0.0)
204
-
205
- We are constantly working to make FlipbookEngine the definitive choice for enterprise digital catalogs. The upcoming **v1.0.0 Major Release** will introduce several advanced features designed for commercial scale:
206
-
207
- - 📑 **Table of Contents (Index):** A dedicated, interactive side-menu allowing readers to instantly jump to specific chapters or product categories.
208
- - 📝 **Page Notes & Annotations:** Allow readers to drop personal notes or bookmarks directly onto pages.
209
- - 🔍 **Full-Text PDF Search:** Client-side search capabilities via extracted JSON indices, enabling instant text highlighting across hundreds of pages without locking the UI.
210
- - 🎯 **Interactive Hotspots & Pop-ups:** Draw custom coordinates over the canvas to embed YouTube videos, image galleries, or direct "Buy Now" e-commerce links right on top of the catalog pages.
211
-
212
- ---
213
-
214
- ## 📄 Licensing
215
-
216
- FlipbookEngine is distributed under a dual-license model:
217
-
218
- - **Open Source**: GNU Affero General Public License v3.0 or later (see [LICENSE](./LICENSE)).
219
- - **Commercial**: For use in closed-source projects, proprietary SaaS platforms, or agency client deliveries (see [COMMERCIAL_LICENSE.md](./COMMERCIAL_LICENSE.md)).
220
-
221
- For commercial licenses and inquiries, contact: **murat.dogan@hotmail.com.tr**
1
+ # FlipbookEngine
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/flipbookengine?style=flat-square&color=blue)](https://www.npmjs.com/package/flipbookengine)
4
+ [![License](https://img.shields.io/npm/l/flipbookengine?style=flat-square)](https://github.com/Bizeka/flipbook-engine/blob/main/LICENSE)
5
+ [![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/flipbookengine?style=flat-square)](https://www.npmjs.com/package/flipbookengine)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/flipbookengine?style=flat-square)](https://www.npmjs.com/package/flipbookengine)
7
+
8
+ **[Live Demo & Playground ↗](https://flipbookengine.com)**
9
+
10
+ FlipbookEngine is a modern, lightweight, and embeddable HTML flipbook viewer for PDF-backed catalogs, brochures, and digital publications. Written in TypeScript, it features single-page and spread modes, a thumbnail rail, smooth zoom/pan, full internationalization (i18n), and robust theme customization.
11
+
12
+ ## Highlights
13
+
14
+ - **Dual-Mode Layout**: Seamlessly switches between single-page (mobile-optimized) and spread (book/catalog layout) modes.
15
+ - **Rich Interaction**: Built-in thumbnail navigation rail, smooth zoom & pan, and HTML5 fullscreen support.
16
+ - **Media & Autoplay**: Configurable page-flip sound effects and automated slideshow presentation with `Autoplay`.
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
+ - **Multi-Language (i18n)**: Out-of-the-box support for English (`en`) and Turkish (`tr`) with customizable overrides.
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.
21
+
22
+ ## Installation
23
+
24
+ Install via npm:
25
+
26
+ ```bash
27
+ npm install flipbookengine
28
+ ```
29
+
30
+ `pdfjs-dist` is a production dependency of FlipbookEngine. It is installed by npm, but is deliberately excluded from the FlipbookEngine bundle so applications can deduplicate, cache, and upgrade PDF.js independently.
31
+
32
+ ## Quick Start
33
+
34
+ ### npm and Bundlers
35
+
36
+ Configure the PDF.js worker in the consuming application. The `?url` suffix is supported by Vite and other modern bundlers that emit imported assets.
37
+
38
+ ```ts
39
+ import { FlipbookEngine } from 'flipbookengine';
40
+ import 'flipbookengine/styles.css';
41
+ import pdfWorkerSrc from 'pdfjs-dist/build/pdf.worker.mjs?url';
42
+
43
+ const engine = new FlipbookEngine('#viewer', {
44
+ allowDownload: true,
45
+ showThumbs: true,
46
+ primaryColor: '#7367f0',
47
+ theme: 'auto',
48
+ locale: 'en',
49
+ pdfWorkerSrc,
50
+ pdfRenderCacheSize: 32
51
+ });
52
+
53
+ await engine.init('/files/catalog.pdf');
54
+ ```
55
+
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).
59
+
60
+ ### Browser CDN
61
+
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.
63
+
64
+ ```html
65
+ <link rel="stylesheet" href="https://unpkg.com/flipbookengine@0.5.0/dist/flipbook-engine.css" />
66
+ <div id="viewer" style="width: 100%; height: 600px;"></div>
67
+
68
+ <script type="importmap">
69
+ {
70
+ "imports": {
71
+ "pdfjs-dist": "https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.min.mjs"
72
+ }
73
+ }
74
+ </script>
75
+ <script type="module">
76
+ import { FlipbookEngine } from 'https://unpkg.com/flipbookengine@0.5.0/dist/flipbook-engine.js';
77
+
78
+ const engine = new FlipbookEngine('#viewer', {
79
+ pdfWorkerSrc: 'https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.worker.min.mjs'
80
+ });
81
+
82
+ await engine.init('/files/catalog.pdf');
83
+ </script>
84
+ ```
85
+
86
+ ### React
87
+
88
+ ```tsx
89
+ import React, { useRef } from 'react';
90
+ import { Flipbook, FlipbookRef } from 'flipbookengine/react';
91
+ import 'flipbookengine/styles.css';
92
+
93
+ function CatalogViewer() {
94
+ const flipbookRef = useRef<FlipbookRef>(null);
95
+
96
+ const handleNextPage = () => {
97
+ flipbookRef.current?.goToPage(flipbookRef.current.getCurrentPage() + 1);
98
+ };
99
+
100
+ return (
101
+ <Flipbook
102
+ ref={flipbookRef}
103
+ pdfUrl="/files/catalog.pdf"
104
+ pages={[
105
+ { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
106
+ { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
107
+ ]}
108
+ allowDownload={true}
109
+ showThumbs={true}
110
+ primaryColor="#7367f0"
111
+ />
112
+ );
113
+ }
114
+ ```
115
+
116
+ ### Vue 3
117
+
118
+ ```vue
119
+ <template>
120
+ <Flipbook
121
+ pdfUrl="/files/catalog.pdf"
122
+ :pages="pages"
123
+ :allowDownload="true"
124
+ :showThumbs="true"
125
+ primaryColor="#7367f0"
126
+ />
127
+ </template>
128
+
129
+ <script setup>
130
+ import { Flipbook } from 'flipbookengine/vue';
131
+ import 'flipbookengine/styles.css';
132
+
133
+ const pages = [
134
+ { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
135
+ { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
136
+ ];
137
+ </script>
138
+ ```
139
+
140
+ ## Migration Notes
141
+
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.
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
+
146
+
147
+ ## Public API Reference
148
+
149
+ The `FlipbookEngine` class exposes the following public methods:
150
+
151
+ - **`init(pdfUrl: string, imageList?: FlipbookPageAsset[])`**: Initializes the viewer and loads the flipbook with pages.
152
+ - **`goToPage(pageIndex: number)`**: Navigates programmatically to a 0-based page index.
153
+ - **`getCurrentPage()`**: Returns the 0-based index of the currently active page.
154
+ - **`getTotalPages()`**: Returns the total number of pages.
155
+ - **`getZoom()`**: Returns the current zoom level (default is `1`).
156
+ - **`setZoom(zoomLevel: number)`**: Programmatically sets the zoom level (accepts values between `0.5` and `5`).
157
+ - **`setSingleMode(isSingle: boolean)`**: Programmatically toggles between single-page mode (`true`) and double-page spread mode (`false`).
158
+ - **`toggleFullscreen()`**: Programmatically toggles fullscreen mode.
159
+ - **`updateOptions(options: Partial<FlipbookEngineOptions>)`**: Updates instance options at runtime.
160
+ - **`setLocale(locale: string, messages?: PartialFlipbookMessages)`**: Updates the locale programmatically.
161
+ - **`destroy(clearMarkup = true)`**: Tears down the instance and clean up DOM listeners.
162
+
163
+ ### Subscribing to Events
164
+
165
+ You can subscribe to events using `.on()`. PDF-backed initialization reports loading/rendering progress and emits a structured `error` event when loading or rendering fails:
166
+
167
+ ```ts
168
+ const unsubscribe = engine.on('pageChange', ({ currentPage, totalPages, isSingle }) => {
169
+ console.log('Page Changed:', currentPage, 'Total:', totalPages);
170
+ });
171
+
172
+ // To unsubscribe:
173
+ unsubscribe();
174
+ ```
175
+
176
+ Supported events: `init`, `progress`, `pageChange`, `zoomChange`, `singlePageModeChange`, `thumbsToggle`, `orientationChange`, `error`, `destroy`.
177
+
178
+ | Option | Type | Default | Description |
179
+ | :--- | :--- | :--- | :--- |
180
+ | `showArrows` | `boolean` | `true` | Shows the previous/next navigation arrows. |
181
+ | `soundEnabled` | `boolean` | `true` | Enables page turning sound effect. |
182
+ | `soundUrl` | `string` | `'https://.../page-flip.mp3'` | URL of the audio file. |
183
+ | `autoPlayInterval`| `number` | `3000` | Autoplay page duration in milliseconds. |
184
+ | `flippingTime` | `number` | `1000` | Duration of the page turn animation in milliseconds; automatically disabled when reduced motion is preferred. |
185
+ | `maxShadowOpacity` | `number` | `0.5` | Maximum opacity of the shadow during page turn (0 to 1). |
186
+ | `whiteLabel` | `boolean` | `false` | Hides the "Powered by FlipbookEngine" watermark. |
187
+ | `pdfWorkerSrc` | `string` | - | URL of the PDF.js worker emitted or hosted by the consuming application. |
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. |
190
+
191
+ ## Styling and Theming
192
+
193
+ FlipbookEngine features fully custom-property-based styling compatible with modern styling systems.
194
+
195
+ ### Global CSS Variables
196
+
197
+ ```css
198
+ :root {
199
+ --mainbgcolor: #f3f6fb;
200
+ --panelbgcolor: #172033;
201
+ --flipbook-accent: #7367f0;
202
+ --thumbrailbgcolor: #0f172a;
203
+ }
204
+ ```
205
+
206
+ ## Performance & Bundle Metrics
207
+
208
+ FlipbookEngine is designed for responsive rendering with hardware-accelerated CSS 3D transforms and a lightweight DOM update path.
209
+
210
+ ### Package Size and PDF.js
211
+
212
+ FlipbookEngine does not bundle PDF.js or its worker. `pdfjs-dist` remains a normal npm dependency, while the host application supplies `pdfWorkerSrc`. This keeps the FlipbookEngine package smaller and lets the application control PDF.js versioning, caching, CSP, and worker hosting.
213
+
214
+ * **Core engine:** excludes PDF.js and the PDF worker.
215
+ * **Styles:** distributed as `flipbookengine/styles.css`.
216
+ * **PDF rendering:** enabled by configuring `pdfWorkerSrc` as shown above.
217
+
218
+ ### Performance Highlights
219
+ * **Hardware Accelerated:** Uses CSS-based 3D transformations (`transform: rotateY`, `translateZ`) without a WebGL runtime.
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.
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.
224
+
225
+ ## FlipbookEngine vs. The Industry
226
+
227
+ When choosing a flipbook library, here is how we compare to other solutions:
228
+
229
+ * **Legacy Libraries (e.g., Turn.js):** Turn.js is over a decade old, relies on jQuery, and lacks native PDF support. **FlipbookEngine** uses a modern framework-agnostic stack (Vanilla/React/Vue), TypeScript, and has built-in PDF.js integration.
230
+ * **Heavy 3D Plugins (e.g., DearFlip, Real3D):** Many 3D plugins use WebGL, which can increase runtime overhead on mobile. **FlipbookEngine** uses StPageFlip with CSS 2D/3D transforms and no WebGL runtime.
231
+ * **Closed SaaS Platforms (e.g., Issuu, Heyzine):** These charge high monthly fees and lock your data on their servers. **FlipbookEngine** gives you 100% control to host and embed directly in your own code (AGPL-3.0).
232
+
233
+ ---
234
+
235
+ ## Acknowledgments
236
+
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.
238
+
239
+ ---
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
+ ---
268
+
269
+ ## Licensing
270
+
271
+ FlipbookEngine is distributed under a dual-license model:
272
+
273
+ - **Open Source**: GNU Affero General Public License v3.0 or later (see [LICENSE](./LICENSE)).
274
+ - **Commercial**: For use in closed-source projects, proprietary SaaS platforms, or agency client deliveries (see [COMMERCIAL_LICENSE.md](./COMMERCIAL_LICENSE.md)).
275
+
276
+ For commercial licenses and inquiries, contact: **murat.dogan@hotmail.com.tr**
277
+
278
+
279
+
@@ -1,14 +1,19 @@
1
+ import { FlipbookStore } from '../state/store';
1
2
  import { FlipbookEngineOptions } from '../engine';
2
3
 
4
+ export declare function prefersReducedMotion(): boolean;
5
+ export declare function resolveFlippingTime(flippingTime?: number, reducedMotion?: boolean): number;
3
6
  export declare class PageFlipAdapter {
4
7
  private pageFlip;
5
8
  private bookContainer;
6
9
  private options;
10
+ private store;
7
11
  private unsubs;
8
12
  private audioEl;
13
+ private audioUnlockHandler;
9
14
  private isLibraryFlipping;
10
15
  private autoPlayTimer;
11
- constructor(bookContainer: HTMLElement, options: FlipbookEngineOptions);
16
+ constructor(bookContainer: HTMLElement, options: FlipbookEngineOptions, store: FlipbookStore);
12
17
  private unlockAudio;
13
18
  init(viewportWidth: number, viewportHeight: number): void;
14
19
  private bindEvents;
@@ -1,3 +1,4 @@
1
+ import { FlipbookStore } from '../state/store';
1
2
  import { PageFlipAdapter } from '../adapters/PageFlipAdapter';
2
3
  import { InteractionManager } from '../core/InteractionManager';
3
4
 
@@ -13,6 +14,8 @@ interface AppProps {
13
14
  bookContainerRef: (el: HTMLElement) => void;
14
15
  className?: string;
15
16
  onDownload: () => void;
17
+ onToggleFullscreen: () => void;
18
+ store: FlipbookStore;
16
19
  }
17
20
  export declare function App(props: AppProps): import('@serenity-is/domwise').JSXElement;
18
21
  export {};
@@ -1,4 +1,7 @@
1
+ import { FlipbookStore } from '../state/store';
2
+
1
3
  interface NavigationArrowsProps {
4
+ store: FlipbookStore;
2
5
  onPrevPage: () => void;
3
6
  onNextPage: () => void;
4
7
  }
@@ -1,4 +1,7 @@
1
+ import { FlipbookStore } from '../state/store';
2
+
1
3
  interface ThumbnailsProps {
4
+ store: FlipbookStore;
2
5
  onThumbClick: (pageIndex: number) => void;
3
6
  }
4
7
  export declare function Thumbnails(props: ThumbnailsProps): import('@serenity-is/domwise').JSXElement;
@@ -1,4 +1,7 @@
1
+ import { FlipbookStore } from '../state/store';
2
+
1
3
  interface ToolbarProps {
4
+ store: FlipbookStore;
2
5
  onToggleThumbs: () => void;
3
6
  onToggleSingleMode: () => void;
4
7
  onZoomIn: () => void;
@@ -1,4 +1,7 @@
1
+ import { FlipbookStore } from '../state/store';
2
+
1
3
  interface ViewerProps {
4
+ store: FlipbookStore;
2
5
  bookWrapperRef: (el: HTMLElement) => void;
3
6
  bookSizerRef: (el: HTMLElement) => void;
4
7
  bookContainerRef: (el: HTMLElement) => void;
@@ -1,11 +1,14 @@
1
+ import { FlipbookStore } from '../state/store';
1
2
  import { PageFlipAdapter } from '../adapters/PageFlipAdapter';
2
3
 
3
4
  export declare class InteractionManager {
4
5
  private container;
5
6
  private pageFlipAdapter;
7
+ private store;
6
8
  private touchStartX;
7
9
  private unsubs;
8
- constructor(container: HTMLElement, pageFlipAdapter: PageFlipAdapter);
10
+ private listenerAbortController;
11
+ constructor(container: HTMLElement, pageFlipAdapter: PageFlipAdapter, store: FlipbookStore);
9
12
  init(): void;
10
13
  private setupStateSync;
11
14
  private bindWheel;