flipbookengine 0.3.0 → 0.4.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,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ - externalized PDF.js as an npm dependency with consumer-provided worker configuration
6
+ - fixed PDF-only initialization when `pages` is omitted
7
+ - isolated engine state and lifecycle cancellation per instance
8
+ - aligned framework wrappers, events, options, fullscreen, audio, and download controls
9
+ - added progressive image quality loading and bounded PDF rendering with cancellation
10
+ - added accessibility semantics, structured PDF progress/error events, and expanded regression tests
11
+ - added CI dependency audit, reproducible package verification, and provenance-enabled release workflow
12
+
3
13
  ## 0.1.0
4
14
 
5
15
  - renamed public product identity to FlipbookEngine
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:
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
+ `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.
30
+
31
+ ## Quick Start
32
+
33
+ ### npm and Bundlers
34
+
35
+ Configure the PDF.js worker in the consuming application. The `?url` suffix is supported by Vite and other modern bundlers that emit imported assets.
36
+
37
+ ```ts
38
+ import { FlipbookEngine } from 'flipbookengine';
39
+ import 'flipbookengine/styles.css';
40
+ import pdfWorkerSrc from 'pdfjs-dist/build/pdf.worker.mjs?url';
41
+
42
+ const engine = new FlipbookEngine('#viewer', {
43
+ allowDownload: true,
44
+ showThumbs: true,
45
+ primaryColor: '#7367f0',
46
+ theme: 'auto',
47
+ locale: 'en',
48
+ pdfWorkerSrc
49
+ });
50
+
51
+ await engine.init('/files/catalog.pdf');
52
+ ```
53
+
54
+ Passing `pages` remains optional. When omitted, FlipbookEngine renders the pages from `pdfUrl`.
55
+
56
+ ### Browser CDN
57
+
58
+ 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
+
60
+ ```html
61
+ <link rel="stylesheet" href="https://unpkg.com/flipbookengine@0.4.0/dist/flipbook-engine.css" />
62
+ <div id="viewer" style="width: 100%; height: 600px;"></div>
63
+
64
+ <script type="importmap">
65
+ {
66
+ "imports": {
67
+ "pdfjs-dist": "https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.min.mjs"
68
+ }
69
+ }
70
+ </script>
71
+ <script type="module">
72
+ import { FlipbookEngine } from 'https://unpkg.com/flipbookengine@0.4.0/dist/flipbook-engine.js';
73
+
74
+ const engine = new FlipbookEngine('#viewer', {
75
+ pdfWorkerSrc: 'https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.worker.min.mjs'
76
+ });
77
+
78
+ await engine.init('/files/catalog.pdf');
79
+ </script>
80
+ ```
81
+
82
+ ### React
83
+
84
+ ```tsx
85
+ import React, { useRef } from 'react';
86
+ import { Flipbook, FlipbookRef } from 'flipbookengine/react';
87
+ import 'flipbookengine/styles.css';
88
+
89
+ function CatalogViewer() {
90
+ const flipbookRef = useRef<FlipbookRef>(null);
91
+
92
+ const handleNextPage = () => {
93
+ flipbookRef.current?.goToPage(flipbookRef.current.getCurrentPage() + 1);
94
+ };
95
+
96
+ return (
97
+ <Flipbook
98
+ ref={flipbookRef}
99
+ pdfUrl="/files/catalog.pdf"
100
+ pages={[
101
+ { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
102
+ { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
103
+ ]}
104
+ allowDownload={true}
105
+ showThumbs={true}
106
+ primaryColor="#7367f0"
107
+ />
108
+ );
109
+ }
110
+ ```
111
+
112
+ ### Vue 3
113
+
114
+ ```vue
115
+ <template>
116
+ <Flipbook
117
+ pdfUrl="/files/catalog.pdf"
118
+ :pages="pages"
119
+ :allowDownload="true"
120
+ :showThumbs="true"
121
+ primaryColor="#7367f0"
122
+ />
123
+ </template>
124
+
125
+ <script setup>
126
+ import { Flipbook } from 'flipbookengine/vue';
127
+ import 'flipbookengine/styles.css';
128
+
129
+ const pages = [
130
+ { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
131
+ { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
132
+ ];
133
+ </script>
134
+ ```
135
+
136
+ ## Migration Notes
137
+
138
+ 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
+
140
+
141
+ ## Local npm Release
142
+
143
+ Run the complete release verification locally before publishing:
24
144
 
25
145
  ```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>
146
+ npm ci
147
+ npm run release:verify
148
+ npm login
149
+ npm publish --provenance --access public
59
150
  ```
60
151
 
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);
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
70
154
 
71
- const handleNextPage = () => {
72
- flipbookRef.current?.goToPage(flipbookRef.current.getCurrentPage() + 1);
73
- };
155
+ If PowerShell blocks `npm.ps1` because script execution is disabled, use the Windows command shim explicitly:
74
156
 
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
- }
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
89
163
  ```
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**
164
+ ## Public API Reference
165
+
166
+ The `FlipbookEngine` class exposes the following public methods:
167
+
168
+ - **`init(pdfUrl: string, imageList?: FlipbookPageAsset[])`**: Initializes the viewer and loads the flipbook with pages.
169
+ - **`goToPage(pageIndex: number)`**: Navigates programmatically to a 0-based page index.
170
+ - **`getCurrentPage()`**: Returns the 0-based index of the currently active page.
171
+ - **`getTotalPages()`**: Returns the total number of pages.
172
+ - **`getZoom()`**: Returns the current zoom level (default is `1`).
173
+ - **`setZoom(zoomLevel: number)`**: Programmatically sets the zoom level (accepts values between `0.5` and `5`).
174
+ - **`setSingleMode(isSingle: boolean)`**: Programmatically toggles between single-page mode (`true`) and double-page spread mode (`false`).
175
+ - **`toggleFullscreen()`**: Programmatically toggles fullscreen mode.
176
+ - **`updateOptions(options: Partial<FlipbookEngineOptions>)`**: Updates instance options at runtime.
177
+ - **`setLocale(locale: string, messages?: PartialFlipbookMessages)`**: Updates the locale programmatically.
178
+ - **`destroy(clearMarkup = true)`**: Tears down the instance and clean up DOM listeners.
179
+
180
+ ### Subscribing to Events
181
+
182
+ 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:
183
+
184
+ ```ts
185
+ const unsubscribe = engine.on('pageChange', ({ currentPage, totalPages, isSingle }) => {
186
+ console.log('Page Changed:', currentPage, 'Total:', totalPages);
187
+ });
188
+
189
+ // To unsubscribe:
190
+ unsubscribe();
191
+ ```
192
+
193
+ Supported events: `init`, `progress`, `pageChange`, `zoomChange`, `singlePageModeChange`, `thumbsToggle`, `orientationChange`, `error`, `destroy`.
194
+
195
+ | Option | Type | Default | Description |
196
+ | :--- | :--- | :--- | :--- |
197
+ | `showArrows` | `boolean` | `true` | Shows the previous/next navigation arrows. |
198
+ | `soundEnabled` | `boolean` | `true` | Enables page turning sound effect. |
199
+ | `soundUrl` | `string` | `'https://.../page-flip.mp3'` | URL of the audio file. |
200
+ | `autoPlayInterval`| `number` | `3000` | Autoplay page duration in milliseconds. |
201
+ | `flippingTime` | `number` | `1000` | Duration of the page turn animation in milliseconds. |
202
+ | `maxShadowOpacity` | `number` | `0.5` | Maximum opacity of the shadow during page turn (0 to 1). |
203
+ | `whiteLabel` | `boolean` | `false` | Hides the "Powered by FlipbookEngine" watermark. |
204
+ | `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 during initialization. |
206
+
207
+ ## Styling and Theming
208
+
209
+ FlipbookEngine features fully custom-property-based styling compatible with modern styling systems.
210
+
211
+ ### Global CSS Variables
212
+
213
+ ```css
214
+ :root {
215
+ --mainbgcolor: #f3f6fb;
216
+ --panelbgcolor: #172033;
217
+ --flipbook-accent: #7367f0;
218
+ --thumbrailbgcolor: #0f172a;
219
+ }
220
+ ```
221
+
222
+ ## Performance & Bundle Metrics
223
+
224
+ FlipbookEngine is designed for responsive rendering with hardware-accelerated CSS 3D transforms and a lightweight DOM update path.
225
+
226
+ ### Package Size and PDF.js
227
+
228
+ 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.
229
+
230
+ * **Core engine:** excludes PDF.js and the PDF worker.
231
+ * **Styles:** distributed as `flipbookengine/styles.css`.
232
+ * **PDF rendering:** enabled by configuring `pdfWorkerSrc` as shown above.
233
+
234
+ ### Performance Highlights
235
+ * **Hardware Accelerated:** Uses CSS-based 3D transformations (`transform: rotateY`, `translateZ`) without a WebGL runtime.
236
+ * **Progressive Image Quality:** Loads low-quality page assets first and upgrades visible pages to their normal-quality source through `IntersectionObserver`.
237
+ * **Bounded PDF Rendering:** PDF pages are rendered with configurable concurrency (`pdfRenderConcurrency`, default `3`) and can be cancelled when an initialization is superseded or destroyed.
238
+
239
+ ## FlipbookEngine vs. The Industry
240
+
241
+ When choosing a flipbook library, here is how we compare to other solutions:
242
+
243
+ * **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.
244
+ * **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.
245
+ * **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).
246
+
247
+ ---
248
+
249
+ ## Acknowledgments
250
+
251
+ A special thanks to the incredible team behind **[Serenity](https://github.com/serenity-is/serenity)**. FlipbookEngine's reactive UI layer is powered by **[domwise](https://github.com/serenity-is/serenity/tree/master/packages/domwise)**. Coupled with `@preact/signals-core`, this keeps the UI update path small without requiring a traditional Virtual DOM runtime.
252
+
253
+ ---
254
+
255
+ ## Roadmap (Upcoming in v1.0.0)
256
+
257
+ 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:
258
+
259
+ - **Table of Contents (Index):** A dedicated, interactive side-menu allowing readers to instantly jump to specific chapters or product categories.
260
+ - **Page Notes & Annotations:** Allow readers to drop personal notes or bookmarks directly onto pages.
261
+ - **Full-Text PDF Search:** Client-side search capabilities via extracted JSON indices, enabling instant text highlighting across hundreds of pages without locking the UI.
262
+ - **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.
263
+ - **Partial PDF Downloads:** Allow readers to select and download specific pages. Features a hybrid architecture: standalone client-side generation using `pdf-lib`, or an event-driven `onDownloadRequest` hook to offload generation to your own secure backend.
264
+ - **AI Chatbot (Chat with Docs):** A built-in AI assistant interface to help users query catalog contents, find products, and get page recommendations instantly.
265
+ - **Deep Linking & Social Share:** Generate and share URLs that point to specific pages or spreads directly via social media.
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,17 @@
1
+ import { FlipbookStore } from '../state/store';
1
2
  import { FlipbookEngineOptions } from '../engine';
2
3
 
3
4
  export declare class PageFlipAdapter {
4
5
  private pageFlip;
5
6
  private bookContainer;
6
7
  private options;
8
+ private store;
7
9
  private unsubs;
8
10
  private audioEl;
11
+ private audioUnlockHandler;
9
12
  private isLibraryFlipping;
10
13
  private autoPlayTimer;
11
- constructor(bookContainer: HTMLElement, options: FlipbookEngineOptions);
14
+ constructor(bookContainer: HTMLElement, options: FlipbookEngineOptions, store: FlipbookStore);
12
15
  private unlockAudio;
13
16
  init(viewportWidth: number, viewportHeight: number): void;
14
17
  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;
@@ -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;