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 +21 -1
- package/README.md +279 -221
- package/dist/adapters/PageFlipAdapter.d.ts +6 -1
- package/dist/components/App.d.ts +3 -0
- package/dist/components/NavigationArrows.d.ts +3 -0
- package/dist/components/Thumbnails.d.ts +3 -0
- package/dist/components/Toolbar.d.ts +3 -0
- package/dist/components/Viewer.d.ts +3 -0
- package/dist/core/InteractionManager.d.ts +4 -1
- package/dist/core/LayoutManager.d.ts +19 -1
- package/dist/core/PdfRenderCache.d.ts +22 -0
- package/dist/core/PdfRenderer.d.ts +24 -17
- package/dist/engine-BuVkDIh-.js +3378 -0
- package/dist/engine-BuVkDIh-.js.map +1 -0
- package/dist/engine.d.ts +34 -1
- package/dist/flipbook-engine.css +1 -1
- package/dist/flipbook-engine.iife.js +66 -85
- package/dist/flipbook-engine.iife.js.map +1 -1
- package/dist/flipbook-engine.js +4 -20813
- package/dist/flipbook-engine.js.map +1 -1
- package/dist/flipbook-engine.react.js +44 -29
- package/dist/flipbook-engine.react.js.map +1 -1
- package/dist/flipbook-engine.vue.js +25 -22
- package/dist/flipbook-engine.vue.js.map +1 -1
- package/dist/react/index.d.ts +4 -1
- package/dist/state/store.d.ts +41 -22
- package/dist/vue/index.d.ts +5 -2
- package/package.json +9 -2
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
|
-
[](https://www.npmjs.com/package/flipbookengine)
|
|
4
|
-
[](https://github.com/Bizeka/flipbook-engine/blob/main/LICENSE)
|
|
5
|
-
[](https://www.npmjs.com/package/flipbookengine)
|
|
6
|
-
[](https://www.npmjs.com/package/flipbookengine)
|
|
7
|
-
|
|
8
|
-
**[
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
1
|
+
# FlipbookEngine
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/flipbookengine)
|
|
4
|
+
[](https://github.com/Bizeka/flipbook-engine/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/flipbookengine)
|
|
6
|
+
[](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;
|
package/dist/components/App.d.ts
CHANGED
|
@@ -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,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
|
-
|
|
10
|
+
private listenerAbortController;
|
|
11
|
+
constructor(container: HTMLElement, pageFlipAdapter: PageFlipAdapter, store: FlipbookStore);
|
|
9
12
|
init(): void;
|
|
10
13
|
private setupStateSync;
|
|
11
14
|
private bindWheel;
|