genus-pdf-viewer 0.1.9 → 0.1.10
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/README.md +15 -0
- package/fesm2022/genus-pdf-viewer.mjs +223 -140
- package/fesm2022/genus-pdf-viewer.mjs.map +1 -1
- package/genus-pdf-viewer-0.1.10.tgz +0 -0
- package/index.d.ts +6 -2
- package/package.json +5 -1
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +168 -0
- package/schematics/ng-add/schema.json +27 -0
package/README.md
CHANGED
|
@@ -10,6 +10,21 @@ npm i pdfjs-dist
|
|
|
10
10
|
|
|
11
11
|
This library declares `pdfjs-dist` as a dependency and Angular as peer dependencies.
|
|
12
12
|
|
|
13
|
+
## Quick setup with ng add
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng add genus-pdf-viewer
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`ng add` will:
|
|
20
|
+
- add `provideGenusPdfViewer()` to your app config when `app.config.ts` is found
|
|
21
|
+
- copy `pdf.worker.min.mjs` to your app assets/public path
|
|
22
|
+
|
|
23
|
+
Optional flags:
|
|
24
|
+
- `--project <name>` target a specific Angular app in a workspace
|
|
25
|
+
- `--skipWorkerCopy` skip worker file copy
|
|
26
|
+
- `--overwriteWorker` replace existing worker file
|
|
27
|
+
|
|
13
28
|
## Worker setup (recommended: library provider)
|
|
14
29
|
|
|
15
30
|
Use the provider shipped by the library, which sets a sensible default and allows overrides.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, effect, ViewChild, Input, Component, InjectionToken,
|
|
2
|
+
import { signal, effect, ViewChild, Input, Component, InjectionToken, PLATFORM_ID, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
|
5
5
|
import * as pdfjsLib from 'pdfjs-dist';
|
|
@@ -17,6 +17,7 @@ class GenusPdfViewerComponent {
|
|
|
17
17
|
zoomAnimation = true;
|
|
18
18
|
zoomAnimationMs = 180;
|
|
19
19
|
gestureAnimationMs = 120;
|
|
20
|
+
loadTimeoutMs = 15000;
|
|
20
21
|
canvas;
|
|
21
22
|
singleStage;
|
|
22
23
|
stage;
|
|
@@ -98,41 +99,113 @@ class GenusPdfViewerComponent {
|
|
|
98
99
|
async loadDocument() {
|
|
99
100
|
this.loading.set(true);
|
|
100
101
|
this.error.set(null);
|
|
101
|
-
|
|
102
|
-
const task = pdfjsLib.getDocument(this.normalizePdfSource(this.src));
|
|
103
|
-
this.doc = await task.promise;
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
// Fallback for environments (notably some iOS builds) where range/streaming fetch fails.
|
|
107
|
-
// Try fetching the whole file via fetch() and pass ArrayBuffer to pdf.js.
|
|
102
|
+
if (this.doc) {
|
|
108
103
|
try {
|
|
109
|
-
|
|
110
|
-
if (href && typeof fetch !== 'undefined') {
|
|
111
|
-
const res = await fetch(href, { mode: 'cors' });
|
|
112
|
-
if (res.ok) {
|
|
113
|
-
const ab = await res.arrayBuffer();
|
|
114
|
-
const data = new Uint8Array(ab);
|
|
115
|
-
const task2 = pdfjsLib.getDocument({ data });
|
|
116
|
-
this.doc = await task2.promise;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
this.doc = undefined;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
this.doc = undefined;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
this.doc = undefined;
|
|
104
|
+
await this.doc.destroy();
|
|
128
105
|
}
|
|
106
|
+
catch { }
|
|
107
|
+
this.doc = undefined;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
this.doc = await this.loadDocumentWithFallbacks(this.src);
|
|
129
111
|
if (!this.doc)
|
|
130
112
|
this.error.set('Failed to load PDF');
|
|
131
113
|
}
|
|
114
|
+
catch {
|
|
115
|
+
this.doc = undefined;
|
|
116
|
+
this.error.set('Failed to load PDF');
|
|
117
|
+
}
|
|
132
118
|
finally {
|
|
133
119
|
this.loading.set(false);
|
|
134
120
|
}
|
|
135
121
|
}
|
|
122
|
+
async loadDocumentWithFallbacks(src) {
|
|
123
|
+
const primary = this.createPrimaryParams(src);
|
|
124
|
+
if (primary) {
|
|
125
|
+
const doc = await this.tryLoadDocument(primary);
|
|
126
|
+
if (doc)
|
|
127
|
+
return doc;
|
|
128
|
+
}
|
|
129
|
+
const bytes = await this.toPdfBytes(src);
|
|
130
|
+
if (!bytes)
|
|
131
|
+
return undefined;
|
|
132
|
+
return this.tryLoadDocument({
|
|
133
|
+
data: bytes,
|
|
134
|
+
disableRange: true,
|
|
135
|
+
disableStream: true,
|
|
136
|
+
disableAutoFetch: true,
|
|
137
|
+
stopAtErrors: true,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
createPrimaryParams(src) {
|
|
141
|
+
if (typeof src === 'string') {
|
|
142
|
+
return { url: src, withCredentials: false, stopAtErrors: true };
|
|
143
|
+
}
|
|
144
|
+
if (src instanceof URL) {
|
|
145
|
+
return { url: src.toString(), withCredentials: false, stopAtErrors: true };
|
|
146
|
+
}
|
|
147
|
+
if (src instanceof Uint8Array) {
|
|
148
|
+
const copy = new Uint8Array(src.byteLength);
|
|
149
|
+
copy.set(src);
|
|
150
|
+
return {
|
|
151
|
+
data: copy,
|
|
152
|
+
disableRange: true,
|
|
153
|
+
disableStream: true,
|
|
154
|
+
disableAutoFetch: true,
|
|
155
|
+
stopAtErrors: true,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
async tryLoadDocument(params) {
|
|
161
|
+
const task = pdfjsLib.getDocument(params);
|
|
162
|
+
const timeoutMs = Number.isFinite(this.loadTimeoutMs) ? Math.max(4000, this.loadTimeoutMs) : 15000;
|
|
163
|
+
let timer = null;
|
|
164
|
+
try {
|
|
165
|
+
const timeout = new Promise((_, reject) => {
|
|
166
|
+
timer = setTimeout(() => reject(new Error('PDF load timeout')), timeoutMs);
|
|
167
|
+
});
|
|
168
|
+
return await Promise.race([task.promise, timeout]);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
try {
|
|
172
|
+
await task.destroy();
|
|
173
|
+
}
|
|
174
|
+
catch { }
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
if (timer)
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async toPdfBytes(src) {
|
|
183
|
+
if (src instanceof Uint8Array) {
|
|
184
|
+
const copy = new Uint8Array(src.byteLength);
|
|
185
|
+
copy.set(src);
|
|
186
|
+
return copy;
|
|
187
|
+
}
|
|
188
|
+
if (src instanceof Blob) {
|
|
189
|
+
try {
|
|
190
|
+
return new Uint8Array(await src.arrayBuffer());
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const href = typeof src === 'string' ? src : src.toString();
|
|
197
|
+
if (typeof fetch === 'undefined')
|
|
198
|
+
return null;
|
|
199
|
+
try {
|
|
200
|
+
const res = await fetch(href, { mode: 'cors' });
|
|
201
|
+
if (!res.ok)
|
|
202
|
+
return null;
|
|
203
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
136
209
|
async render() {
|
|
137
210
|
if (!this.doc)
|
|
138
211
|
return;
|
|
@@ -194,96 +267,100 @@ class GenusPdfViewerComponent {
|
|
|
194
267
|
const existing = Array.from(stageEl.querySelectorAll('.pdf-page'));
|
|
195
268
|
const isInitialBuild = existing.length !== total;
|
|
196
269
|
this.renderLockCount++;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
stageEl.appendChild(contentEl);
|
|
202
|
-
for (let i = 1; i <= total; i++) {
|
|
203
|
-
const page = await this.doc.getPage(i);
|
|
204
|
-
const baseViewport = page.getViewport({ scale: 1 });
|
|
205
|
-
let baseScale = 1;
|
|
206
|
-
if (this.fit === 'width')
|
|
207
|
-
baseScale = (parentWidth - 16) / baseViewport.width;
|
|
208
|
-
if (this.fit === 'page')
|
|
209
|
-
baseScale = (parentWidth - 16) / baseViewport.width;
|
|
210
|
-
const minScale = baseScale * this.minZoom;
|
|
211
|
-
const maxScale = baseScale * this.maxZoom;
|
|
212
|
-
const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));
|
|
213
|
-
if (i === 1)
|
|
214
|
-
computedCanPan = finalScale > baseScale + 0.001;
|
|
215
|
-
const viewport = page.getViewport({ scale: finalScale });
|
|
216
|
-
const wrapper = document.createElement('div');
|
|
217
|
-
wrapper.className = 'pdf-page';
|
|
218
|
-
wrapper.setAttribute('data-page', String(i));
|
|
219
|
-
wrapper.style.width = Math.floor(viewport.width) + 'px';
|
|
220
|
-
wrapper.style.height = Math.floor(viewport.height) + 'px';
|
|
221
|
-
wrapper.style.margin = '0 auto 12px auto';
|
|
222
|
-
const canvas = document.createElement('canvas');
|
|
223
|
-
const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;
|
|
224
|
-
canvas.style.width = Math.floor(viewport.width) + 'px';
|
|
225
|
-
canvas.style.height = Math.floor(viewport.height) + 'px';
|
|
226
|
-
canvas.width = Math.floor(viewport.width * dpr);
|
|
227
|
-
canvas.height = Math.floor(viewport.height * dpr);
|
|
228
|
-
const ctx = canvas.getContext('2d');
|
|
229
|
-
wrapper.appendChild(canvas);
|
|
230
|
-
contentEl.appendChild(wrapper);
|
|
231
|
-
const renderCtx = { canvasContext: ctx, viewport };
|
|
232
|
-
if (dpr !== 1)
|
|
233
|
-
renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];
|
|
234
|
-
const task = page.render(renderCtx);
|
|
235
|
-
await task.promise;
|
|
236
|
-
if (this.renderVersion !== version)
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
let contentEl = stageEl.querySelector('.pdf-content');
|
|
242
|
-
if (!contentEl) {
|
|
243
|
-
contentEl = document.createElement('div');
|
|
270
|
+
try {
|
|
271
|
+
if (isInitialBuild) {
|
|
272
|
+
stageEl.innerHTML = '';
|
|
273
|
+
const contentEl = document.createElement('div');
|
|
244
274
|
contentEl.className = 'pdf-content';
|
|
245
|
-
const pages = Array.from(stageEl.querySelectorAll('.pdf-page'));
|
|
246
|
-
for (const el of pages)
|
|
247
|
-
contentEl.appendChild(el);
|
|
248
275
|
stageEl.appendChild(contentEl);
|
|
276
|
+
for (let i = 1; i <= total; i++) {
|
|
277
|
+
const page = await this.doc.getPage(i);
|
|
278
|
+
const baseViewport = page.getViewport({ scale: 1 });
|
|
279
|
+
let baseScale = 1;
|
|
280
|
+
if (this.fit === 'width')
|
|
281
|
+
baseScale = (parentWidth - 16) / baseViewport.width;
|
|
282
|
+
if (this.fit === 'page')
|
|
283
|
+
baseScale = (parentWidth - 16) / baseViewport.width;
|
|
284
|
+
const minScale = baseScale * this.minZoom;
|
|
285
|
+
const maxScale = baseScale * this.maxZoom;
|
|
286
|
+
const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));
|
|
287
|
+
if (i === 1)
|
|
288
|
+
computedCanPan = finalScale > baseScale + 0.001;
|
|
289
|
+
const viewport = page.getViewport({ scale: finalScale });
|
|
290
|
+
const wrapper = document.createElement('div');
|
|
291
|
+
wrapper.className = 'pdf-page';
|
|
292
|
+
wrapper.setAttribute('data-page', String(i));
|
|
293
|
+
wrapper.style.width = Math.floor(viewport.width) + 'px';
|
|
294
|
+
wrapper.style.height = Math.floor(viewport.height) + 'px';
|
|
295
|
+
wrapper.style.margin = '0 auto 12px auto';
|
|
296
|
+
const canvas = document.createElement('canvas');
|
|
297
|
+
const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;
|
|
298
|
+
canvas.style.width = Math.floor(viewport.width) + 'px';
|
|
299
|
+
canvas.style.height = Math.floor(viewport.height) + 'px';
|
|
300
|
+
canvas.width = Math.floor(viewport.width * dpr);
|
|
301
|
+
canvas.height = Math.floor(viewport.height * dpr);
|
|
302
|
+
const ctx = canvas.getContext('2d');
|
|
303
|
+
wrapper.appendChild(canvas);
|
|
304
|
+
contentEl.appendChild(wrapper);
|
|
305
|
+
const renderCtx = { canvasContext: ctx, viewport };
|
|
306
|
+
if (dpr !== 1)
|
|
307
|
+
renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];
|
|
308
|
+
const task = page.render(renderCtx);
|
|
309
|
+
await task.promise;
|
|
310
|
+
if (this.renderVersion !== version)
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
249
313
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
314
|
+
else {
|
|
315
|
+
let contentEl = stageEl.querySelector('.pdf-content');
|
|
316
|
+
if (!contentEl) {
|
|
317
|
+
contentEl = document.createElement('div');
|
|
318
|
+
contentEl.className = 'pdf-content';
|
|
319
|
+
const pages = Array.from(stageEl.querySelectorAll('.pdf-page'));
|
|
320
|
+
for (const el of pages)
|
|
321
|
+
contentEl.appendChild(el);
|
|
322
|
+
stageEl.appendChild(contentEl);
|
|
323
|
+
}
|
|
324
|
+
for (let i = 1; i <= total; i++) {
|
|
325
|
+
const page = await this.doc.getPage(i);
|
|
326
|
+
const baseViewport = page.getViewport({ scale: 1 });
|
|
327
|
+
let baseScale = 1;
|
|
328
|
+
if (this.fit === 'width')
|
|
329
|
+
baseScale = (parentWidth - 16) / baseViewport.width;
|
|
330
|
+
if (this.fit === 'page')
|
|
331
|
+
baseScale = (parentWidth - 16) / baseViewport.width;
|
|
332
|
+
const minScale = baseScale * this.minZoom;
|
|
333
|
+
const maxScale = baseScale * this.maxZoom;
|
|
334
|
+
const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));
|
|
335
|
+
if (i === 1)
|
|
336
|
+
computedCanPan = finalScale > baseScale + 0.001;
|
|
337
|
+
const viewport = page.getViewport({ scale: finalScale });
|
|
338
|
+
const wrapper = existing[i - 1];
|
|
339
|
+
const canvas = wrapper.querySelector('canvas');
|
|
340
|
+
wrapper.style.width = Math.floor(viewport.width) + 'px';
|
|
341
|
+
wrapper.style.height = Math.floor(viewport.height) + 'px';
|
|
342
|
+
const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;
|
|
343
|
+
canvas.style.width = Math.floor(viewport.width) + 'px';
|
|
344
|
+
canvas.style.height = Math.floor(viewport.height) + 'px';
|
|
345
|
+
canvas.width = Math.floor(viewport.width * dpr);
|
|
346
|
+
canvas.height = Math.floor(viewport.height * dpr);
|
|
347
|
+
const ctx = canvas.getContext('2d');
|
|
348
|
+
const renderCtx = { canvasContext: ctx, viewport };
|
|
349
|
+
if (dpr !== 1)
|
|
350
|
+
renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];
|
|
351
|
+
const task = page.render(renderCtx);
|
|
352
|
+
await task.promise;
|
|
353
|
+
if (this.renderVersion !== version)
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
281
356
|
}
|
|
357
|
+
this.canPan.set(computedCanPan);
|
|
358
|
+
if (anchor)
|
|
359
|
+
this.restoreScrollAnchor(stageEl, anchor);
|
|
360
|
+
}
|
|
361
|
+
finally {
|
|
362
|
+
this.renderLockCount = Math.max(0, this.renderLockCount - 1);
|
|
282
363
|
}
|
|
283
|
-
this.canPan.set(computedCanPan);
|
|
284
|
-
if (anchor)
|
|
285
|
-
this.restoreScrollAnchor(stageEl, anchor);
|
|
286
|
-
this.renderLockCount = Math.max(0, this.renderLockCount - 1);
|
|
287
364
|
}
|
|
288
365
|
async goTo(page) {
|
|
289
366
|
if (!this.doc)
|
|
@@ -786,8 +863,7 @@ class GenusPdfViewerComponent {
|
|
|
786
863
|
try {
|
|
787
864
|
let doc = this.doc;
|
|
788
865
|
if (!doc) {
|
|
789
|
-
|
|
790
|
-
doc = await task.promise;
|
|
866
|
+
doc = await this.loadDocumentWithFallbacks(this.src);
|
|
791
867
|
}
|
|
792
868
|
if (!doc)
|
|
793
869
|
return false;
|
|
@@ -873,19 +949,8 @@ class GenusPdfViewerComponent {
|
|
|
873
949
|
const last = path.split('/').filter(Boolean).pop() || '';
|
|
874
950
|
return last.endsWith('.pdf') ? last : (last ? last + '.pdf' : 'document.pdf');
|
|
875
951
|
}
|
|
876
|
-
normalizePdfSource(src) {
|
|
877
|
-
if (typeof src === 'string') {
|
|
878
|
-
try {
|
|
879
|
-
return new URL(src, typeof window !== 'undefined' ? window.location?.href : undefined);
|
|
880
|
-
}
|
|
881
|
-
catch {
|
|
882
|
-
return src;
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return src;
|
|
886
|
-
}
|
|
887
952
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: GenusPdfViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
888
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.1", type: GenusPdfViewerComponent, isStandalone: true, selector: "genus-pdf-viewer", inputs: { src: "src", page: "page", zoom: "zoom", maxZoom: "maxZoom", minZoom: "minZoom", fit: "fit", disableTextLayer: "disableTextLayer", continuous: "continuous", showToolbar: "showToolbar", zoomAnimation: "zoomAnimation", zoomAnimationMs: "zoomAnimationMs", gestureAnimationMs: "gestureAnimationMs" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true }, { propertyName: "singleStage", first: true, predicate: ["singleStage"], descendants: true }, { propertyName: "stage", first: true, predicate: ["stage"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
953
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.1", type: GenusPdfViewerComponent, isStandalone: true, selector: "genus-pdf-viewer", inputs: { src: "src", page: "page", zoom: "zoom", maxZoom: "maxZoom", minZoom: "minZoom", fit: "fit", disableTextLayer: "disableTextLayer", continuous: "continuous", showToolbar: "showToolbar", zoomAnimation: "zoomAnimation", zoomAnimationMs: "zoomAnimationMs", gestureAnimationMs: "gestureAnimationMs", loadTimeoutMs: "loadTimeoutMs" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true }, { propertyName: "singleStage", first: true, predicate: ["singleStage"], descendants: true }, { propertyName: "stage", first: true, predicate: ["stage"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
889
954
|
<div class="genus-pdf-shell">
|
|
890
955
|
<ng-content select="[toolbar]"></ng-content>
|
|
891
956
|
|
|
@@ -1000,6 +1065,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImpor
|
|
|
1000
1065
|
type: Input
|
|
1001
1066
|
}], gestureAnimationMs: [{
|
|
1002
1067
|
type: Input
|
|
1068
|
+
}], loadTimeoutMs: [{
|
|
1069
|
+
type: Input
|
|
1003
1070
|
}], canvas: [{
|
|
1004
1071
|
type: ViewChild,
|
|
1005
1072
|
args: ['canvas', { static: false }]
|
|
@@ -1012,8 +1079,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImpor
|
|
|
1012
1079
|
}] } });
|
|
1013
1080
|
|
|
1014
1081
|
const GENUS_PDF_WORKER_CONFIG = new InjectionToken('GENUS_PDF_WORKER_CONFIG');
|
|
1082
|
+
function resolveBundledWorkerUrl() {
|
|
1083
|
+
try {
|
|
1084
|
+
return new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).toString();
|
|
1085
|
+
}
|
|
1086
|
+
catch {
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
async function isWorkerUrlReachable(url) {
|
|
1091
|
+
try {
|
|
1092
|
+
const response = await fetch(url, { method: 'HEAD', cache: 'no-store' });
|
|
1093
|
+
return response.ok || response.status === 405;
|
|
1094
|
+
}
|
|
1095
|
+
catch {
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1015
1099
|
function initPdfWorkerFactory(cfg, platformId) {
|
|
1016
|
-
return () => {
|
|
1100
|
+
return async () => {
|
|
1017
1101
|
if (!isPlatformBrowser(platformId))
|
|
1018
1102
|
return;
|
|
1019
1103
|
const defaults = {
|
|
@@ -1021,19 +1105,17 @@ function initPdfWorkerFactory(cfg, platformId) {
|
|
|
1021
1105
|
workerSrc: '/assets/pdf.worker.min.mjs',
|
|
1022
1106
|
};
|
|
1023
1107
|
const merged = { ...defaults, ...cfg };
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1108
|
+
const globalOptions = pdfjsLib.GlobalWorkerOptions;
|
|
1109
|
+
globalOptions.workerPort = null;
|
|
1110
|
+
globalOptions.workerSrc = merged.workerSrc;
|
|
1111
|
+
if (!merged.tryModuleWorker)
|
|
1112
|
+
return;
|
|
1113
|
+
const bundledWorkerUrl = resolveBundledWorkerUrl();
|
|
1114
|
+
if (!bundledWorkerUrl)
|
|
1115
|
+
return;
|
|
1116
|
+
if (await isWorkerUrlReachable(bundledWorkerUrl)) {
|
|
1117
|
+
globalOptions.workerSrc = bundledWorkerUrl;
|
|
1034
1118
|
}
|
|
1035
|
-
// 2) Fallback: classic worker path served by the app
|
|
1036
|
-
pdfjsLib.GlobalWorkerOptions.workerSrc = merged.workerSrc;
|
|
1037
1119
|
};
|
|
1038
1120
|
}
|
|
1039
1121
|
function provideGenusPdfViewer(cfg = {}) {
|
|
@@ -1042,7 +1124,8 @@ function provideGenusPdfViewer(cfg = {}) {
|
|
|
1042
1124
|
{
|
|
1043
1125
|
provide: APP_INITIALIZER,
|
|
1044
1126
|
multi: true,
|
|
1045
|
-
useFactory:
|
|
1127
|
+
useFactory: initPdfWorkerFactory,
|
|
1128
|
+
deps: [GENUS_PDF_WORKER_CONFIG, PLATFORM_ID],
|
|
1046
1129
|
},
|
|
1047
1130
|
];
|
|
1048
1131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genus-pdf-viewer.mjs","sources":["../../../projects/genus-pdf-viewer/src/lib/genus-pdf-viewer.ts","../../../projects/genus-pdf-viewer/src/lib/pdfjs-worker.provider.ts","../../../projects/genus-pdf-viewer/src/public-api.ts","../../../projects/genus-pdf-viewer/src/genus-pdf-viewer.ts"],"sourcesContent":["import { Component, Input, ViewChild, ElementRef, OnChanges, SimpleChanges, effect, signal } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport * as pdfjsLib from 'pdfjs-dist';\nimport type { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist/types/src/display/api';\n\n@Component({\n selector: 'genus-pdf-viewer',\n standalone: true,\n imports: [CommonModule],\n template: `\n <div class=\"genus-pdf-shell\">\n <ng-content select=\"[toolbar]\"></ng-content>\n\n <div class=\"genus-pdf-toolbar\" *ngIf=\"showToolbar\">\n <button type=\"button\" title=\"Zoom out\" aria-label=\"Zoom out\" (click)=\"zoomOut()\">−</button>\n <span class=\"pct\">{{ (zoomSig() * 100) | number:'1.0-0' }}%</span>\n <button type=\"button\" title=\"Zoom in\" aria-label=\"Zoom in\" (click)=\"zoomIn()\">+</button>\n <button type=\"button\" *ngIf=\"isZoomed()\" title=\"Reset zoom to 100%\" aria-label=\"Reset zoom to 100%\" (click)=\"resetZoom()\">100%</button>\n <span class=\"spacer\"></span>\n <button type=\"button\" title=\"Previous page\" aria-label=\"Previous page\" (click)=\"prevPage()\" [disabled]=\"pageSig() <= 1\">⟨</button>\n <span>{{ pageSig() }} / {{ doc ? doc.numPages : 0 }}</span>\n <button type=\"button\" title=\"Next page\" aria-label=\"Next page\" (click)=\"nextPage()\" [disabled]=\"doc ? pageSig() >= doc.numPages : true\">⟩</button>\n <span class=\"spacer\"></span>\n <button type=\"button\" class=\"download-btn\" title=\"Download\" aria-label=\"Download\" (click)=\"download()\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n <path d=\"M12 3v10m0 0 4-4m-4 4-4-4M5 15v3a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-3\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n <span>Download</span>\n </button>\n </div>\n\n <div class=\"genus-pdf-stage\" #singleStage [style.display]=\"continuous ? 'none' : 'flex'\" [class.can-pan]=\"canPan()\" [class.is-panning]=\"isPanning()\" (pointerdown)=\"onPointerDown($event, singleStage)\" (wheel)=\"onWheel($event, singleStage)\" (scroll)=\"onScroll($event)\">\n <div class=\"genus-pdf-overlay\" *ngIf=\"loading()\"><div class=\"spinner\" aria-label=\"Loading\"></div></div>\n <div class=\"genus-pdf-overlay error\" *ngIf=\"error()\">\n <div style=\"display:flex;flex-direction:column;gap:8px;align-items:center;\">\n <span>{{ error() }}</span>\n <button type=\"button\" (click)=\"retryLoad()\">Retry</button>\n </div>\n </div>\n <canvas #canvas></canvas>\n </div>\n\n <div class=\"genus-pdf-stage genus-pdf-stage--continuous\" #stage [style.display]=\"continuous ? 'block' : 'none'\" [class.can-pan]=\"canPan()\" [class.is-panning]=\"isPanning()\" (pointerdown)=\"onPointerDown($event, stage)\" (wheel)=\"onWheel($event, stage)\" (scroll)=\"onScroll($event)\">\n <div class=\"genus-pdf-overlay\" *ngIf=\"loading()\"><div class=\"spinner\" aria-label=\"Loading\"></div></div>\n <div class=\"genus-pdf-overlay error\" *ngIf=\"error()\">\n <div style=\"display:flex;flex-direction:column;gap:8px;align-items:center;\">\n <span>{{ error() }}</span>\n <button type=\"button\" (click)=\"retryLoad()\">Retry</button>\n </div>\n </div>\n </div>\n </div>\n `,\n styles: [`\n .genus-pdf-shell { display:flex; flex-direction:column; gap:8px; width:100%; height:100%; background:#f3f4f6; }\n .genus-pdf-toolbar { position:sticky; top:0; z-index:2; display:flex; align-items:center; gap:8px; padding:6px 8px; border:1px solid #e5e7eb; border-radius:8px; background:#ffffffd9; backdrop-filter:saturate(1.2) blur(6px); box-shadow:0 1px 2px rgba(0,0,0,0.06); }\n .genus-pdf-toolbar .pct { min-width: 48px; text-align:center; font-variant-numeric: tabular-nums; color:#111827; }\n .genus-pdf-toolbar button { appearance:none; border:1px solid #e5e7eb; background:#fff; padding:6px 10px; border-radius:6px; cursor:pointer; color:#111827; font-size:14px; line-height:1; font-weight:500; min-width:32px; user-select:none; display:inline-flex; align-items:center; gap:6px; }\n .genus-pdf-toolbar button.download-btn { background:#2563eb; border-color:#2563eb; color:#fff; }\n .genus-pdf-toolbar button.download-btn:hover { background:#1d4ed8; border-color:#1d4ed8; }\n .genus-pdf-toolbar button:disabled { opacity:0.5; cursor:not-allowed; }\n .genus-pdf-toolbar .spacer { flex:1; }\n .genus-pdf-stage { position:relative; flex:1; overflow:auto; display:flex; align-items:flex-start; justify-content:center; background:#fafafa; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; overscroll-behavior-y: contain; }\n .genus-pdf-stage.can-pan { cursor: grab; touch-action: none; }\n .genus-pdf-stage.is-panning { cursor: grabbing; }\n .genus-pdf-stage--continuous { display:block; align-items:unset; justify-content:unset; padding:8px; scroll-behavior:smooth; }\n .genus-pdf-stage--continuous .pdf-page { margin:0 auto 12px auto; background:white; box-shadow:0 1px 2px rgba(0,0,0,0.08); }\n canvas { display:block; max-width:100%; height:auto; }\n .genus-pdf-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,0.7); z-index:1; }\n .genus-pdf-overlay.error { background:transparent; }\n .spinner { width:28px; height:28px; border-radius:50%; border:3px solid #e5e7eb; border-top-color:#111827; animation:spin 1s linear infinite; }\n @keyframes spin { from { transform: rotate(0) } to { transform: rotate(360deg) } }\n `]\n})\nexport class GenusPdfViewerComponent implements OnChanges {\n @Input() src!: string | URL | Uint8Array | Blob;\n @Input() page = 1;\n @Input() zoom = 1.0;\n @Input() maxZoom = 4;\n @Input() minZoom = 0.25;\n @Input() fit: 'width'|'height'|'page'|'none' = 'width';\n @Input() disableTextLayer = true;\n @Input() continuous = true;\n @Input() showToolbar = true;\n @Input() zoomAnimation = true;\n @Input() zoomAnimationMs = 180;\n @Input() gestureAnimationMs = 120;\n\n @ViewChild('canvas', { static: false }) canvas!: ElementRef<HTMLCanvasElement>;\n @ViewChild('singleStage', { static: false }) singleStage!: ElementRef<HTMLDivElement>;\n @ViewChild('stage', { static: false }) stage!: ElementRef<HTMLDivElement>;\n\n doc?: PDFDocumentProxy;\n private currentPage?: PDFPageProxy;\n\n pageSig = signal(1);\n zoomSig = signal(1);\n isPanning = signal(false);\n canPan = signal(false);\n loading = signal(false);\n error = signal<string | null>(null);\n private readonly PRINT_SCALE = 2;\n private scrollRaf = 0 as any;\n private renderLockCount = 0;\n private zoomAnimInFlight = false;\n private activeRenderTasks = new Set<any>();\n private wheelRaf = 0 as any;\n private pinchState: { id1: number; id2: number; startDist: number; startZoom: number } | null = null;\n private activePointers = new Map<number, { x: number; y: number; type: string }>();\n private renderVersion = 0;\n private previewActive = false;\n private reRenderQueued = false;\n private pendingAnchor: { page: number; ratio: number } | undefined;\n private lastZoomClient: { x: number; y: number } | null = null;\n private readonly WHEEL_STEP = 0.02;\n private readonly PINCH_SENSITIVITY = 0.5;\n private wheelCommitTimer = 0 as any;\n \n\n constructor() {\n effect(() => {\n // Only react to zoom changes here; page changes in continuous mode should NOT trigger a re-render\n this.zoomSig();\n if (this.renderLockCount > 0 || this.previewActive) return;\n this.safeRender();\n });\n }\n\n async ngOnChanges(changes: SimpleChanges) {\n if (changes['page']) this.pageSig.set(this.page);\n if (changes['zoom']) this.zoomSig.set(this.zoom);\n\n const srcChanged = !!changes['src'];\n const layoutChanged = !!(changes['fit'] || changes['minZoom'] || changes['maxZoom']);\n\n if (!this.src) return;\n\n if (srcChanged) {\n await this.loadDocument();\n\n if (this.doc) {\n const pages = this.doc.numPages;\n if (this.pageSig() < 1) this.pageSig.set(1);\n if (this.pageSig() > pages) this.pageSig.set(pages);\n await this.render();\n }\n return;\n }\n\n if (layoutChanged) {\n if (this.continuous) {\n const container = this.stage?.nativeElement;\n const anchor = container ? this.captureScrollAnchor(container) || undefined : undefined;\n await this.renderAllPages(anchor);\n } else {\n await this.render();\n }\n return;\n }\n\n if (!this.continuous && changes['page']) {\n await this.render();\n }\n }\n\n async safeRender() {\n try { await this.render(); } catch (_) {}\n }\n\n private async loadDocument() {\n this.loading.set(true);\n this.error.set(null);\n try {\n const task = pdfjsLib.getDocument(this.normalizePdfSource(this.src) as any);\n this.doc = await task.promise;\n } catch (e) {\n // Fallback for environments (notably some iOS builds) where range/streaming fetch fails.\n // Try fetching the whole file via fetch() and pass ArrayBuffer to pdf.js.\n try {\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (href && typeof fetch !== 'undefined') {\n const res = await fetch(href, { mode: 'cors' });\n if (res.ok) {\n const ab = await res.arrayBuffer();\n const data = new Uint8Array(ab);\n const task2 = pdfjsLib.getDocument({ data } as any);\n this.doc = await task2.promise;\n } else {\n this.doc = undefined;\n }\n } else {\n this.doc = undefined;\n }\n } catch {\n this.doc = undefined;\n }\n if (!this.doc) this.error.set('Failed to load PDF');\n } finally {\n this.loading.set(false);\n }\n }\n\n async render() {\n if (!this.doc) return;\n const version = ++this.renderVersion;\n if (this.continuous) {\n await this.renderAllPages();\n return;\n }\n\n const pageNum = this.pageSig();\n const pdfPage = await this.doc.getPage(pageNum);\n this.currentPage = pdfPage;\n\n const canvas = this.canvas?.nativeElement;\n if (!canvas) return;\n const ctx = canvas.getContext('2d')!;\n\n const baseViewport = pdfPage.getViewport({ scale: 1 });\n const parent = canvas.parentElement!;\n const anchor = this.captureScrollAnchor(parent) || undefined;\n const pW = parent.clientWidth, pH = parent.clientHeight || baseViewport.height;\n\n let baseScale = 1;\n if (this.fit === 'width') baseScale = (pW - 16) / baseViewport.width;\n if (this.fit === 'height') baseScale = (pH - 16) / baseViewport.height;\n if (this.fit === 'page') baseScale = Math.min((pW - 16) / baseViewport.width, (pH - 16) / baseViewport.height);\n\n const minScale = baseScale * this.minZoom;\n const maxScale = baseScale * this.maxZoom;\n const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));\n this.canPan.set(finalScale > baseScale + 0.001);\n const viewport = pdfPage.getViewport({ scale: finalScale });\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;\n canvas.style.width = Math.floor(viewport.width) + 'px';\n canvas.style.height = Math.floor(viewport.height) + 'px';\n canvas.width = Math.floor(viewport.width * dpr);\n canvas.height = Math.floor(viewport.height * dpr);\n const renderCtx: any = { canvasContext: ctx, viewport };\n if (dpr !== 1) renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];\n const task = pdfPage.render(renderCtx);\n await task.promise;\n if (this.renderVersion !== version) return;\n if (anchor) this.restoreScrollAnchor(parent, anchor);\n }\n\n private async renderAllPages(anchorOverride?: { page: number; ratio: number }) {\n if (!this.doc) return;\n const stageEl = this.stage?.nativeElement;\n if (!stageEl) return;\n const version = ++this.renderVersion;\n const anchor = anchorOverride ?? this.captureScrollAnchor(stageEl);\n const total = this.doc.numPages;\n const parentRect = stageEl.getBoundingClientRect();\n const parentWidth = parentRect.width || stageEl.clientWidth || 800;\n let computedCanPan = false;\n const existing = Array.from(stageEl.querySelectorAll<HTMLElement>('.pdf-page'));\n const isInitialBuild = existing.length !== total;\n this.renderLockCount++;\n if (isInitialBuild) {\n stageEl.innerHTML = '';\n const contentEl = document.createElement('div');\n contentEl.className = 'pdf-content';\n stageEl.appendChild(contentEl);\n for (let i = 1; i <= total; i++) {\n const page = await this.doc.getPage(i);\n const baseViewport = page.getViewport({ scale: 1 });\n let baseScale = 1;\n if (this.fit === 'width') baseScale = (parentWidth - 16) / baseViewport.width;\n if (this.fit === 'page') baseScale = (parentWidth - 16) / baseViewport.width;\n const minScale = baseScale * this.minZoom;\n const maxScale = baseScale * this.maxZoom;\n const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));\n if (i === 1) computedCanPan = finalScale > baseScale + 0.001;\n const viewport = page.getViewport({ scale: finalScale });\n\n const wrapper = document.createElement('div');\n wrapper.className = 'pdf-page';\n wrapper.setAttribute('data-page', String(i));\n wrapper.style.width = Math.floor(viewport.width) + 'px';\n wrapper.style.height = Math.floor(viewport.height) + 'px';\n wrapper.style.margin = '0 auto 12px auto';\n\n const canvas = document.createElement('canvas');\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;\n canvas.style.width = Math.floor(viewport.width) + 'px';\n canvas.style.height = Math.floor(viewport.height) + 'px';\n canvas.width = Math.floor(viewport.width * dpr);\n canvas.height = Math.floor(viewport.height * dpr);\n const ctx = canvas.getContext('2d')!;\n\n wrapper.appendChild(canvas);\n contentEl.appendChild(wrapper);\n\n const renderCtx: any = { canvasContext: ctx, viewport };\n if (dpr !== 1) renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];\n const task = page.render(renderCtx);\n await task.promise;\n if (this.renderVersion !== version) return;\n }\n } else {\n let contentEl = stageEl.querySelector<HTMLElement>('.pdf-content');\n if (!contentEl) {\n contentEl = document.createElement('div');\n contentEl.className = 'pdf-content';\n const pages = Array.from(stageEl.querySelectorAll<HTMLElement>('.pdf-page'));\n for (const el of pages) contentEl.appendChild(el);\n stageEl.appendChild(contentEl);\n }\n for (let i = 1; i <= total; i++) {\n const page = await this.doc.getPage(i);\n const baseViewport = page.getViewport({ scale: 1 });\n let baseScale = 1;\n if (this.fit === 'width') baseScale = (parentWidth - 16) / baseViewport.width;\n if (this.fit === 'page') baseScale = (parentWidth - 16) / baseViewport.width;\n const minScale = baseScale * this.minZoom;\n const maxScale = baseScale * this.maxZoom;\n const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));\n if (i === 1) computedCanPan = finalScale > baseScale + 0.001;\n const viewport = page.getViewport({ scale: finalScale });\n\n const wrapper = existing[i - 1];\n const canvas = wrapper.querySelector('canvas') as HTMLCanvasElement;\n wrapper.style.width = Math.floor(viewport.width) + 'px';\n wrapper.style.height = Math.floor(viewport.height) + 'px';\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;\n canvas.style.width = Math.floor(viewport.width) + 'px';\n canvas.style.height = Math.floor(viewport.height) + 'px';\n canvas.width = Math.floor(viewport.width * dpr);\n canvas.height = Math.floor(viewport.height * dpr);\n const ctx = canvas.getContext('2d')!;\n const renderCtx: any = { canvasContext: ctx, viewport };\n if (dpr !== 1) renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];\n const task = page.render(renderCtx);\n await task.promise;\n if (this.renderVersion !== version) return;\n }\n }\n this.canPan.set(computedCanPan);\n if (anchor) this.restoreScrollAnchor(stageEl, anchor);\n this.renderLockCount = Math.max(0, this.renderLockCount - 1);\n }\n\n async goTo(page: number) {\n if (!this.doc) return;\n const p = Math.max(1, Math.min(this.doc.numPages, page));\n this.pageSig.set(p);\n if (this.continuous) {\n const stageEl = this.stage?.nativeElement;\n const el = stageEl?.querySelector(`[data-page=\"${p}\"]`) as HTMLElement | null;\n el?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n } else {\n await this.render();\n }\n }\n async zoomIn(step = 0.1) { await this.applyZoomDelta(step); }\n async zoomOut(step = 0.1) { await this.applyZoomDelta(-step); }\n\n private clampZoom(z: number): number {\n return Math.max(this.minZoom, Math.min(this.maxZoom, z));\n }\n\n private cancelPreviewIfAny(container?: HTMLElement): void {\n if (!this.previewActive || !container) return;\n const target = this.continuous ? (container.querySelector('.pdf-content') as HTMLElement || container) : (container.querySelector('canvas') as HTMLElement || container);\n try {\n target.style.transform = '';\n target.style.willChange = '';\n target.style.transition = '';\n } catch {}\n this.previewActive = false;\n this.lastZoomClient = null;\n }\n\n private async applyZoomDelta(delta: number): Promise<void> {\n const oldZoom = this.zoomSig();\n const newZoom = this.clampZoom(oldZoom + delta);\n if (Math.abs(newZoom - oldZoom) < 0.0001) return;\n\n const container = this.continuous ? this.stage?.nativeElement : this.singleStage?.nativeElement;\n // If a preview transform is active (from pinch/wheel), clear it before capturing anchor or animating\n this.cancelPreviewIfAny(container);\n const anchor = container ? this.captureScrollAnchor(container) || undefined : undefined;\n const ratio = newZoom / oldZoom;\n\n if (this.zoomAnimation && container && !this.zoomAnimInFlight) {\n this.zoomAnimInFlight = true;\n this.renderLockCount++;\n // Update UI value immediately\n this.zoomSig.set(newZoom);\n try {\n await this.runZoomAnimation(container, ratio);\n } finally {\n // Release the render lock before triggering the actual re-render\n this.renderLockCount = Math.max(0, this.renderLockCount - 1);\n await this.safeReRenderWithCancellation(anchor);\n this.zoomAnimInFlight = false;\n }\n } else {\n this.zoomSig.set(newZoom);\n await this.safeReRenderWithCancellation(anchor);\n }\n }\n\n private async runZoomAnimation(container: HTMLElement, ratio: number): Promise<void> {\n if (Math.abs(ratio - 1) < 0.0001) return;\n const { target, originX, originY } = this.getZoomAnimTarget(container);\n return new Promise<void>((resolve) => {\n try {\n const onDone = () => {\n cleanup();\n resolve();\n };\n const cleanup = () => {\n target.removeEventListener('transitionend', onEnd as any);\n target.style.transition = '';\n target.style.transform = '';\n target.style.transformOrigin = '';\n target.style.willChange = '';\n };\n const onEnd = () => onDone();\n target.style.willChange = 'transform';\n target.style.transformOrigin = `${Math.max(0, originX)}px ${Math.max(0, originY)}px`;\n target.style.transition = 'none';\n target.style.transform = 'scale(1)';\n requestAnimationFrame(() => {\n target.addEventListener('transitionend', onEnd as any, { once: true } as any);\n target.style.transition = `transform ${this.zoomAnimationMs}ms cubic-bezier(0.2,0,0,1)`;\n target.style.transform = `scale(${ratio})`;\n setTimeout(onDone, this.zoomAnimationMs + 60);\n });\n } catch {\n resolve();\n }\n });\n }\n\n private getZoomAnimTarget(container: HTMLElement): { target: HTMLElement; originX: number; originY: number } {\n const isContinuous = this.continuous;\n let target: HTMLElement | null = null;\n if (isContinuous) {\n target = container.querySelector<HTMLElement>('.pdf-content');\n if (!target) target = container; // fallback\n } else {\n target = container.querySelector<HTMLElement>('canvas');\n if (!target) target = container; // fallback\n }\n const rectLeft = target.offsetLeft;\n const rectTop = target.offsetTop;\n // Prefer last gesture point (pinch center or wheel pointer) if available\n const client = this.lastZoomClient;\n const originX = client ? (container.scrollLeft + client.x - rectLeft) : (container.scrollLeft + container.clientWidth / 2 - rectLeft);\n const originY = client ? (container.scrollTop + client.y - rectTop) : (container.scrollTop + container.clientHeight / 2 - rectTop);\n return { target, originX, originY };\n }\n\n onScroll(evt: Event) {\n const container = evt.target as HTMLElement;\n // debounce via rAF\n if (this.scrollRaf) cancelAnimationFrame(this.scrollRaf);\n this.scrollRaf = requestAnimationFrame(() => {\n if (!this.doc || !this.continuous) return;\n const pages = Array.from(container.querySelectorAll<HTMLElement>('.pdf-page'));\n if (!pages.length) return;\n const centerY = container.scrollTop + container.clientHeight / 2;\n let current = this.pageSig();\n for (const el of pages) {\n const top = el.offsetTop;\n const bottom = top + el.offsetHeight;\n if (centerY >= top && centerY <= bottom) {\n const p = parseInt(el.getAttribute('data-page') || '1', 10);\n current = p;\n break;\n }\n }\n if (current !== this.pageSig()) this.pageSig.set(current);\n });\n }\n\n async nextPage() { await this.goTo(this.pageSig() + 1); }\n async prevPage() { await this.goTo(this.pageSig() - 1); }\n\n isZoomed(): boolean {\n return Math.abs(this.zoomSig() - 1) > 0.0001;\n }\n\n async resetZoom() {\n // Reset to exactly 1.0 (100%)\n const delta = 1 - this.zoomSig();\n await this.applyZoomDelta(delta);\n }\n\n async retryLoad() {\n await this.loadDocument();\n if (this.doc) {\n const pages = this.doc.numPages;\n if (this.pageSig() < 1) this.pageSig.set(1);\n if (this.pageSig() > pages) this.pageSig.set(pages);\n await this.render();\n }\n }\n\n onPointerDown(evt: PointerEvent, containerEl: HTMLElement) {\n // Pinch-to-zoom (two pointers)\n if (evt.pointerType === 'touch') {\n this.activePointers.set(evt.pointerId, { x: evt.clientX, y: evt.clientY, type: evt.pointerType });\n const onPointerMove = (e: PointerEvent) => {\n if (e.pointerType === 'touch') this.activePointers.set(e.pointerId, { x: e.clientX, y: e.clientY, type: e.pointerType });\n const touches = Array.from(this.activePointers.entries()).map(([id, p]) => ({ pointerId: id, clientX: p.x, clientY: p.y }))\n .slice(0, 2);\n if (touches.length === 2) {\n const [a, b] = touches;\n const dist = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);\n if (!this.pinchState) {\n this.pinchState = { id1: a.pointerId, id2: b.pointerId, startDist: Math.max(1, dist), startZoom: this.zoomSig() };\n const rect = containerEl.getBoundingClientRect();\n this.lastZoomClient = { x: ((a.clientX + b.clientX) / 2) - rect.left, y: ((a.clientY + b.clientY) / 2) - rect.top };\n }\n const scale = dist / Math.max(1, this.pinchState.startDist);\n const adjusted = 1 + (scale - 1) * this.PINCH_SENSITIVITY;\n const desiredAdj = this.clampZoom(this.pinchState.startZoom * adjusted);\n this.previewZoom(containerEl, desiredAdj);\n e.preventDefault();\n return;\n }\n // When pinch ends (not exactly two touches), commit render if we were previewing\n if (this.pinchState) {\n const final = this.zoomSig();\n this.commitPreviewZoom(containerEl, final);\n this.pinchState = null;\n this.lastZoomClient = null;\n }\n };\n const onPointerEnd = (e: PointerEvent) => {\n this.activePointers.delete(e.pointerId);\n const touches = Array.from(this.activePointers.values());\n if (touches.length !== 2 && this.pinchState) {\n const final = this.zoomSig();\n this.commitPreviewZoom(containerEl, final);\n this.pinchState = null;\n this.lastZoomClient = null;\n }\n cleanup();\n };\n const cleanup = () => {\n containerEl.removeEventListener('pointermove', onPointerMove);\n containerEl.removeEventListener('pointerup', onPointerEnd);\n containerEl.removeEventListener('pointercancel', onPointerEnd);\n this.activePointers.clear();\n };\n containerEl.addEventListener('pointermove', onPointerMove);\n containerEl.addEventListener('pointerup', onPointerEnd);\n containerEl.addEventListener('pointercancel', onPointerEnd);\n return;\n }\n\n // Mouse pan when canPan\n if (!this.canPan()) return;\n this.isPanning.set(true);\n const startX = evt.clientX;\n const startY = evt.clientY;\n const startLeft = containerEl.scrollLeft;\n const startTop = containerEl.scrollTop;\n containerEl.style.scrollBehavior = 'auto';\n containerEl.setPointerCapture?.(evt.pointerId);\n const move = (e: PointerEvent) => {\n const dx = e.clientX - startX;\n const dy = e.clientY - startY;\n containerEl.scrollLeft = startLeft - dx;\n containerEl.scrollTop = startTop - dy;\n e.preventDefault();\n };\n const end = (e: PointerEvent) => {\n this.isPanning.set(false);\n containerEl.releasePointerCapture?.(evt.pointerId);\n containerEl.removeEventListener('pointermove', move);\n containerEl.removeEventListener('pointerup', end);\n containerEl.removeEventListener('pointercancel', end);\n containerEl.style.scrollBehavior = 'smooth';\n };\n containerEl.addEventListener('pointermove', move);\n containerEl.addEventListener('pointerup', end);\n containerEl.addEventListener('pointercancel', end);\n }\n\n private getActiveTouches(containerEl: HTMLElement): PointerEvent[] {\n // We capture pointer events only on this element; maintain list by querying PointerEvent.getCoalescedEvents not available broadly.\n // Instead, rely on touches reported in native events; browsers will deliver move events for all active pointers targeting the element.\n // Here we cannot query directly; so we return an empty array and use move handler state. For simplicity, we derive from event stream only.\n // This helper remains for future extension; current logic passes actual events to compute pinch.\n return [] as any;\n }\n\n onWheel(evt: WheelEvent, containerEl: HTMLElement) {\n const isCtrlZoom = evt.ctrlKey || evt.metaKey;\n if (!isCtrlZoom) return;\n evt.preventDefault();\n const rect = containerEl.getBoundingClientRect();\n // Record gesture point relative to container\n this.lastZoomClient = { x: evt.clientX - rect.left, y: evt.clientY - rect.top };\n if (this.wheelRaf) cancelAnimationFrame(this.wheelRaf);\n if (this.wheelCommitTimer) clearTimeout(this.wheelCommitTimer);\n const delta = -evt.deltaY;\n const step = delta > 0 ? this.WHEEL_STEP : -this.WHEEL_STEP;\n const desired = this.clampZoom(this.zoomSig() + step);\n this.previewZoom(containerEl, desired);\n this.wheelRaf = requestAnimationFrame(() => {\n this.wheelCommitTimer = setTimeout(() => {\n this.commitPreviewZoom(containerEl, this.zoomSig());\n this.lastZoomClient = null;\n }, this.gestureAnimationMs + 20);\n });\n }\n\n private previewZoom(container: HTMLElement, newZoom: number) {\n const oldZoom = this.zoomSig();\n if (Math.abs(newZoom - oldZoom) < 0.0001) return;\n const ratio = newZoom / oldZoom;\n const target = this.continuous ? (container.querySelector('.pdf-content') as HTMLElement || container) : (container.querySelector('canvas') as HTMLElement || container);\n const origin = this.getZoomAnimTarget(container);\n target.style.willChange = 'transform';\n target.style.transformOrigin = `${Math.max(0, origin.originX)}px ${Math.max(0, origin.originY)}px`;\n target.style.transition = `transform ${this.gestureAnimationMs}ms cubic-bezier(0.2,0,0,1)`;\n target.style.transform = `scale(${ratio})`;\n this.zoomSig.set(newZoom);\n this.previewActive = true;\n }\n\n private async commitPreviewZoom(container: HTMLElement, expectedZoom: number) {\n // Clear transform and re-render once; cancel any in-flight render tasks\n const target = this.continuous ? (container.querySelector('.pdf-content') as HTMLElement || container) : (container.querySelector('canvas') as HTMLElement || container);\n target.style.transform = '';\n target.style.willChange = '';\n target.style.transition = '';\n const anchor = this.captureScrollAnchor(container) || undefined;\n if (this.previewActive) {\n await this.safeReRenderWithCancellation(anchor);\n this.previewActive = false;\n }\n }\n\n private async safeReRenderWithCancellation(anchor?: { page: number; ratio: number }) {\n // If a render is in progress, queue once with the most recent anchor\n if (this.renderLockCount > 0) {\n this.reRenderQueued = true;\n if (anchor) this.pendingAnchor = anchor;\n return;\n }\n try {\n this.renderLockCount++;\n if (this.continuous) {\n await this.renderAllPages(anchor);\n } else {\n await this.render();\n }\n } finally {\n this.renderLockCount = Math.max(0, this.renderLockCount - 1);\n if (this.renderLockCount === 0 && this.reRenderQueued) {\n const nextAnchor = this.pendingAnchor;\n this.reRenderQueued = false;\n this.pendingAnchor = undefined;\n await this.safeReRenderWithCancellation(nextAnchor);\n }\n }\n }\n\n private captureScrollAnchor(container: HTMLElement, client?: { x: number; y: number } | null): { page: number; ratio: number } | null {\n try {\n const pages = Array.from(container.querySelectorAll<HTMLElement>('.pdf-page'));\n const centerY = container.scrollTop + container.clientHeight / 2;\n if (pages.length > 0) {\n let pageEl = pages.find(el => (el.offsetTop <= centerY && (el.offsetTop + el.offsetHeight) >= centerY))\n || pages.find(el => (el.offsetTop + el.offsetHeight) > (container.scrollTop + 1))\n || pages[0];\n const page = parseInt(pageEl.getAttribute('data-page') || '1', 10);\n const height = Math.max(1, pageEl.offsetHeight);\n const ratio = Math.max(0, Math.min(1, (centerY - pageEl.offsetTop) / height));\n return { page, ratio };\n }\n // Fallback: single-canvas mode\n const canvas = container.querySelector('canvas');\n if (!canvas) return null;\n const height = Math.max(1, (canvas as HTMLElement).offsetHeight);\n const ratio = Math.max(0, Math.min(1, (centerY - (canvas as HTMLElement).offsetTop) / height));\n return { page: 1, ratio };\n } catch {\n return null;\n }\n }\n\n private restoreScrollAnchor(container: HTMLElement, anchor: { page: number; ratio: number }): void {\n try {\n let el = container.querySelector<HTMLElement>(`[data-page=\"${anchor.page}\"]`);\n if (!el) el = container.querySelector<HTMLElement>('canvas');\n if (!el) return;\n const prevBehavior = container.style.scrollBehavior;\n container.style.scrollBehavior = 'auto';\n const height = Math.max(1, el.offsetHeight);\n const desired = el.offsetTop + anchor.ratio * height - container.clientHeight / 2;\n const maxScroll = Math.max(0, container.scrollHeight - container.clientHeight);\n container.scrollTop = Math.max(0, Math.min(maxScroll, desired));\n container.style.scrollBehavior = prevBehavior;\n } catch {}\n }\n\n async download() {\n const filename = this.deriveFilename();\n const link = document.createElement('a');\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && (navigator as any).maxTouchPoints > 1);\n let popup: Window | null = null;\n if (isIOS) {\n // Open a tab synchronously to stay within user gesture\n try { popup = window.open('', '_blank', 'noopener,noreferrer'); } catch { popup = null; }\n }\n\n const blob = await this.createBlobFromSrc();\n if (blob) {\n const url = URL.createObjectURL(blob);\n if (isIOS) {\n if (popup) {\n try { popup.location.href = url; } catch { /* ignore */ }\n // Revoke later to allow the view to load fully\n setTimeout(() => URL.revokeObjectURL(url), 30000);\n } else {\n const a = document.createElement('a');\n a.href = url;\n a.target = '_blank';\n a.rel = 'noopener';\n document.body.appendChild(a);\n a.click();\n a.remove();\n setTimeout(() => URL.revokeObjectURL(url), 30000);\n }\n } else {\n link.href = url;\n link.download = filename;\n link.rel = 'noopener';\n link.style.display = 'none';\n document.body.appendChild(link);\n link.click();\n link.remove();\n URL.revokeObjectURL(url);\n }\n return;\n }\n\n // Fallback: cross-origin without CORS\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (!href) return;\n if (isIOS) {\n if (popup) {\n try { popup.location.href = href; } catch { /* ignore */ }\n } else {\n const a = document.createElement('a');\n a.href = href;\n a.target = '_blank';\n a.rel = 'noopener';\n document.body.appendChild(a);\n a.click();\n a.remove();\n }\n } else {\n link.href = href;\n link.target = '_blank';\n link.rel = 'noopener';\n link.download = filename; // browsers may ignore for cross-origin\n link.style.display = 'none';\n document.body.appendChild(link);\n link.click();\n link.remove();\n }\n }\n\n async print() {\n // Robust, plugin-free printing by rendering pages to images\n const ok = await this.printViaImages();\n if (ok) return;\n // Fallbacks\n const blob = await this.createBlobFromSrc();\n if (blob) {\n const url = URL.createObjectURL(blob);\n const win = window.open('', '_blank', 'noopener,noreferrer');\n if (win) {\n win.document.write('<!doctype html><html><head><title>Print</title><meta charset=\"utf-8\"><style>html,body{height:100%;margin:0}@page{size:auto;margin:0} iframe{border:0;width:100%;height:100%}</style></head><body><iframe src=\"' + url + '\"></iframe></body></html>');\n win.document.close();\n setTimeout(() => { try { win.focus(); win.print(); } catch {} }, 800);\n win.onafterprint = () => { try { win.close(); } catch {} URL.revokeObjectURL(url); };\n } else {\n const iframe = document.createElement('iframe');\n iframe.style.position = 'fixed'; iframe.style.right = '0'; iframe.style.bottom = '0';\n iframe.style.width = '0'; iframe.style.height = '0'; iframe.style.border = '0';\n iframe.src = url; document.body.appendChild(iframe);\n iframe.onload = () => { try { setTimeout(() => iframe.contentWindow?.print(), 800); } catch {} setTimeout(() => { URL.revokeObjectURL(url); iframe.remove(); }, 3000); };\n }\n return;\n }\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (href) window.open(href, '_blank');\n }\n\n private async printViaImages(): Promise<boolean> {\n try {\n let doc = this.doc;\n if (!doc) {\n const task = pdfjsLib.getDocument(this.normalizePdfSource(this.src) as any);\n doc = await task.promise;\n }\n if (!doc) return false;\n const win = window.open('', '_blank', 'noopener,noreferrer');\n if (!win) return false;\n win.document.write('<!doctype html><html><head><meta charset=\"utf-8\"><title>Print</title><style>@page{size:auto;margin:0} html,body{margin:0;padding:0} .page{page-break-after:always;}</style></head><body></body></html>');\n win.document.close();\n\n for (let i = 1; i <= doc.numPages; i++) {\n const page = await doc.getPage(i);\n const vp = page.getViewport({ scale: this.PRINT_SCALE });\n const canvas = document.createElement('canvas');\n canvas.width = Math.floor(vp.width);\n canvas.height = Math.floor(vp.height);\n const ctx = canvas.getContext('2d')!;\n await page.render({ canvas, canvasContext: ctx, viewport: vp }).promise;\n const img = win.document.createElement('img');\n img.className = 'page';\n img.style.width = '100%';\n img.style.display = 'block';\n img.src = canvas.toDataURL('image/png');\n win.document.body.appendChild(img);\n }\n setTimeout(() => { try { win.focus(); win.print(); } catch {} }, 300);\n win.onafterprint = () => { try { win.close(); } catch {} };\n setTimeout(() => { try { win.close(); } catch {} }, 60000);\n return true;\n } catch {\n return false;\n }\n }\n\n private async createBlobFromSrc(): Promise<Blob | null> {\n if (!this.src) return null;\n if (this.src instanceof Blob) return this.src;\n if (this.src instanceof Uint8Array) {\n const ab = new ArrayBuffer(this.src.byteLength);\n new Uint8Array(ab).set(this.src);\n return new Blob([ab], { type: 'application/pdf' });\n }\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (!href || typeof fetch === 'undefined') return null;\n try {\n const res = await fetch(href, { mode: 'cors' });\n if (!res.ok) return null;\n const blob = await res.blob();\n return blob.type ? blob : new Blob([await res.arrayBuffer()], { type: 'application/pdf' });\n } catch {\n return null;\n }\n }\n\n private deriveFilename(): string {\n if (typeof this.src === 'string') {\n try { const u = new URL(this.src, window.location.origin); return this.basename(u.pathname) || 'document.pdf'; } catch { return 'document.pdf'; }\n }\n if (this.src instanceof URL) {\n return this.basename(this.src.pathname) || 'document.pdf';\n }\n return 'document.pdf';\n }\n\n private basename(path: string): string {\n const last = path.split('/').filter(Boolean).pop() || '';\n return last.endsWith('.pdf') ? last : (last ? last + '.pdf' : 'document.pdf');\n }\n\n private normalizePdfSource(src: string | URL | Uint8Array | Blob): string | URL | Uint8Array | Blob {\n if (typeof src === 'string') {\n try {\n return new URL(src, typeof window !== 'undefined' ? window.location?.href : undefined);\n } catch {\n return src;\n }\n }\n return src;\n }\n}\n","import { APP_INITIALIZER, InjectionToken, Provider, PLATFORM_ID, inject } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport * as pdfjsLib from 'pdfjs-dist';\n\nexport type GenusPdfWorkerConfig = {\n /** Try ESM module worker first (best); falls back to workerSrc if creation fails. */\n tryModuleWorker?: boolean;\n /** Absolute URL the app serves the worker from. Default: /assets/pdf.worker.min.mjs */\n workerSrc?: string;\n};\n\nexport const GENUS_PDF_WORKER_CONFIG = new InjectionToken<GenusPdfWorkerConfig>('GENUS_PDF_WORKER_CONFIG');\n\nfunction initPdfWorkerFactory(cfg: GenusPdfWorkerConfig, platformId: object) {\n return () => {\n if (!isPlatformBrowser(platformId)) return;\n\n const defaults: Required<Pick<GenusPdfWorkerConfig, 'tryModuleWorker' | 'workerSrc'>> = {\n tryModuleWorker: true,\n workerSrc: '/assets/pdf.worker.min.mjs',\n };\n const merged = { ...defaults, ...cfg };\n\n // 1) Try an ESM module worker (most robust across modern browsers)\n try {\n if (merged.tryModuleWorker && 'Worker' in window) {\n const worker = new Worker(\n new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url),\n { type: 'module' }\n );\n (pdfjsLib as any).GlobalWorkerOptions.workerPort = worker;\n return;\n }\n } catch {\n // fall back below\n }\n\n // 2) Fallback: classic worker path served by the app\n (pdfjsLib as any).GlobalWorkerOptions.workerSrc = merged.workerSrc;\n };\n}\n\nexport function provideGenusPdfViewer(cfg: GenusPdfWorkerConfig = {}): Provider[] {\n return [\n { provide: GENUS_PDF_WORKER_CONFIG, useValue: cfg },\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: () => initPdfWorkerFactory(inject(GENUS_PDF_WORKER_CONFIG), inject(PLATFORM_ID)),\n },\n ];\n}\n","/*\n * Public API Surface of genus-pdf-viewer\n */\n\nexport * from './lib/genus-pdf-viewer';\nexport { GenusPdfViewerComponent } from './lib/genus-pdf-viewer';\nexport * from './lib/pdfjs-worker.provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MA0Ea,uBAAuB,CAAA;AACzB,IAAA,GAAG;IACH,IAAI,GAAG,CAAC;IACR,IAAI,GAAG,GAAG;IACV,OAAO,GAAG,CAAC;IACX,OAAO,GAAG,IAAI;IACd,GAAG,GAAmC,OAAO;IAC7C,gBAAgB,GAAG,IAAI;IACvB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,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,GAAG,EAAE;;AAGtC,QAAA,IAAI;YACF,IAAI,MAAM,CAAC,eAAe,IAAI,QAAQ,IAAI,MAAM,EAAE;gBAChD,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,IAAI,GAAG,CAAC,qCAAqC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAC/D,EAAE,IAAI,EAAE,QAAQ,EAAE,CACnB;AACA,gBAAA,QAAgB,CAAC,mBAAmB,CAAC,UAAU,GAAG,MAAM;gBACzD;YACF;QACF;AAAE,QAAA,MAAM;;QAER;;QAGC,QAAgB,CAAC,mBAAmB,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;AACpE,IAAA,CAAC;AACH;AAEM,SAAU,qBAAqB,CAAC,GAAA,GAA4B,EAAE,EAAA;IAClE,OAAO;AACL,QAAA,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,GAAG,EAAE;AACnD,QAAA;AACE,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,UAAU,EAAE,MAAM,oBAAoB,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;AAC7F,SAAA;KACF;AACH;;ACnDA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"genus-pdf-viewer.mjs","sources":["../../../projects/genus-pdf-viewer/src/lib/genus-pdf-viewer.ts","../../../projects/genus-pdf-viewer/src/lib/pdfjs-worker.provider.ts","../../../projects/genus-pdf-viewer/src/public-api.ts","../../../projects/genus-pdf-viewer/src/genus-pdf-viewer.ts"],"sourcesContent":["import { Component, Input, ViewChild, ElementRef, OnChanges, SimpleChanges, effect, signal } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport * as pdfjsLib from 'pdfjs-dist';\nimport type {\n DocumentInitParameters,\n PDFDocumentLoadingTask,\n PDFDocumentProxy,\n PDFPageProxy,\n} from 'pdfjs-dist/types/src/display/api';\n\n@Component({\n selector: 'genus-pdf-viewer',\n standalone: true,\n imports: [CommonModule],\n template: `\n <div class=\"genus-pdf-shell\">\n <ng-content select=\"[toolbar]\"></ng-content>\n\n <div class=\"genus-pdf-toolbar\" *ngIf=\"showToolbar\">\n <button type=\"button\" title=\"Zoom out\" aria-label=\"Zoom out\" (click)=\"zoomOut()\">−</button>\n <span class=\"pct\">{{ (zoomSig() * 100) | number:'1.0-0' }}%</span>\n <button type=\"button\" title=\"Zoom in\" aria-label=\"Zoom in\" (click)=\"zoomIn()\">+</button>\n <button type=\"button\" *ngIf=\"isZoomed()\" title=\"Reset zoom to 100%\" aria-label=\"Reset zoom to 100%\" (click)=\"resetZoom()\">100%</button>\n <span class=\"spacer\"></span>\n <button type=\"button\" title=\"Previous page\" aria-label=\"Previous page\" (click)=\"prevPage()\" [disabled]=\"pageSig() <= 1\">⟨</button>\n <span>{{ pageSig() }} / {{ doc ? doc.numPages : 0 }}</span>\n <button type=\"button\" title=\"Next page\" aria-label=\"Next page\" (click)=\"nextPage()\" [disabled]=\"doc ? pageSig() >= doc.numPages : true\">⟩</button>\n <span class=\"spacer\"></span>\n <button type=\"button\" class=\"download-btn\" title=\"Download\" aria-label=\"Download\" (click)=\"download()\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\">\n <path d=\"M12 3v10m0 0 4-4m-4 4-4-4M5 15v3a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-3\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n <span>Download</span>\n </button>\n </div>\n\n <div class=\"genus-pdf-stage\" #singleStage [style.display]=\"continuous ? 'none' : 'flex'\" [class.can-pan]=\"canPan()\" [class.is-panning]=\"isPanning()\" (pointerdown)=\"onPointerDown($event, singleStage)\" (wheel)=\"onWheel($event, singleStage)\" (scroll)=\"onScroll($event)\">\n <div class=\"genus-pdf-overlay\" *ngIf=\"loading()\"><div class=\"spinner\" aria-label=\"Loading\"></div></div>\n <div class=\"genus-pdf-overlay error\" *ngIf=\"error()\">\n <div style=\"display:flex;flex-direction:column;gap:8px;align-items:center;\">\n <span>{{ error() }}</span>\n <button type=\"button\" (click)=\"retryLoad()\">Retry</button>\n </div>\n </div>\n <canvas #canvas></canvas>\n </div>\n\n <div class=\"genus-pdf-stage genus-pdf-stage--continuous\" #stage [style.display]=\"continuous ? 'block' : 'none'\" [class.can-pan]=\"canPan()\" [class.is-panning]=\"isPanning()\" (pointerdown)=\"onPointerDown($event, stage)\" (wheel)=\"onWheel($event, stage)\" (scroll)=\"onScroll($event)\">\n <div class=\"genus-pdf-overlay\" *ngIf=\"loading()\"><div class=\"spinner\" aria-label=\"Loading\"></div></div>\n <div class=\"genus-pdf-overlay error\" *ngIf=\"error()\">\n <div style=\"display:flex;flex-direction:column;gap:8px;align-items:center;\">\n <span>{{ error() }}</span>\n <button type=\"button\" (click)=\"retryLoad()\">Retry</button>\n </div>\n </div>\n </div>\n </div>\n `,\n styles: [`\n .genus-pdf-shell { display:flex; flex-direction:column; gap:8px; width:100%; height:100%; background:#f3f4f6; }\n .genus-pdf-toolbar { position:sticky; top:0; z-index:2; display:flex; align-items:center; gap:8px; padding:6px 8px; border:1px solid #e5e7eb; border-radius:8px; background:#ffffffd9; backdrop-filter:saturate(1.2) blur(6px); box-shadow:0 1px 2px rgba(0,0,0,0.06); }\n .genus-pdf-toolbar .pct { min-width: 48px; text-align:center; font-variant-numeric: tabular-nums; color:#111827; }\n .genus-pdf-toolbar button { appearance:none; border:1px solid #e5e7eb; background:#fff; padding:6px 10px; border-radius:6px; cursor:pointer; color:#111827; font-size:14px; line-height:1; font-weight:500; min-width:32px; user-select:none; display:inline-flex; align-items:center; gap:6px; }\n .genus-pdf-toolbar button.download-btn { background:#2563eb; border-color:#2563eb; color:#fff; }\n .genus-pdf-toolbar button.download-btn:hover { background:#1d4ed8; border-color:#1d4ed8; }\n .genus-pdf-toolbar button:disabled { opacity:0.5; cursor:not-allowed; }\n .genus-pdf-toolbar .spacer { flex:1; }\n .genus-pdf-stage { position:relative; flex:1; overflow:auto; display:flex; align-items:flex-start; justify-content:center; background:#fafafa; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; overscroll-behavior-y: contain; }\n .genus-pdf-stage.can-pan { cursor: grab; touch-action: none; }\n .genus-pdf-stage.is-panning { cursor: grabbing; }\n .genus-pdf-stage--continuous { display:block; align-items:unset; justify-content:unset; padding:8px; scroll-behavior:smooth; }\n .genus-pdf-stage--continuous .pdf-page { margin:0 auto 12px auto; background:white; box-shadow:0 1px 2px rgba(0,0,0,0.08); }\n canvas { display:block; max-width:100%; height:auto; }\n .genus-pdf-overlay { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,0.7); z-index:1; }\n .genus-pdf-overlay.error { background:transparent; }\n .spinner { width:28px; height:28px; border-radius:50%; border:3px solid #e5e7eb; border-top-color:#111827; animation:spin 1s linear infinite; }\n @keyframes spin { from { transform: rotate(0) } to { transform: rotate(360deg) } }\n `]\n})\nexport class GenusPdfViewerComponent implements OnChanges {\n @Input() src!: string | URL | Uint8Array | Blob;\n @Input() page = 1;\n @Input() zoom = 1.0;\n @Input() maxZoom = 4;\n @Input() minZoom = 0.25;\n @Input() fit: 'width'|'height'|'page'|'none' = 'width';\n @Input() disableTextLayer = true;\n @Input() continuous = true;\n @Input() showToolbar = true;\n @Input() zoomAnimation = true;\n @Input() zoomAnimationMs = 180;\n @Input() gestureAnimationMs = 120;\n @Input() loadTimeoutMs = 15000;\n\n @ViewChild('canvas', { static: false }) canvas!: ElementRef<HTMLCanvasElement>;\n @ViewChild('singleStage', { static: false }) singleStage!: ElementRef<HTMLDivElement>;\n @ViewChild('stage', { static: false }) stage!: ElementRef<HTMLDivElement>;\n\n doc?: PDFDocumentProxy;\n private currentPage?: PDFPageProxy;\n\n pageSig = signal(1);\n zoomSig = signal(1);\n isPanning = signal(false);\n canPan = signal(false);\n loading = signal(false);\n error = signal<string | null>(null);\n private readonly PRINT_SCALE = 2;\n private scrollRaf = 0 as any;\n private renderLockCount = 0;\n private zoomAnimInFlight = false;\n private activeRenderTasks = new Set<any>();\n private wheelRaf = 0 as any;\n private pinchState: { id1: number; id2: number; startDist: number; startZoom: number } | null = null;\n private activePointers = new Map<number, { x: number; y: number; type: string }>();\n private renderVersion = 0;\n private previewActive = false;\n private reRenderQueued = false;\n private pendingAnchor: { page: number; ratio: number } | undefined;\n private lastZoomClient: { x: number; y: number } | null = null;\n private readonly WHEEL_STEP = 0.02;\n private readonly PINCH_SENSITIVITY = 0.5;\n private wheelCommitTimer = 0 as any;\n \n\n constructor() {\n effect(() => {\n // Only react to zoom changes here; page changes in continuous mode should NOT trigger a re-render\n this.zoomSig();\n if (this.renderLockCount > 0 || this.previewActive) return;\n this.safeRender();\n });\n }\n\n async ngOnChanges(changes: SimpleChanges) {\n if (changes['page']) this.pageSig.set(this.page);\n if (changes['zoom']) this.zoomSig.set(this.zoom);\n\n const srcChanged = !!changes['src'];\n const layoutChanged = !!(changes['fit'] || changes['minZoom'] || changes['maxZoom']);\n\n if (!this.src) return;\n\n if (srcChanged) {\n await this.loadDocument();\n\n if (this.doc) {\n const pages = this.doc.numPages;\n if (this.pageSig() < 1) this.pageSig.set(1);\n if (this.pageSig() > pages) this.pageSig.set(pages);\n await this.render();\n }\n return;\n }\n\n if (layoutChanged) {\n if (this.continuous) {\n const container = this.stage?.nativeElement;\n const anchor = container ? this.captureScrollAnchor(container) || undefined : undefined;\n await this.renderAllPages(anchor);\n } else {\n await this.render();\n }\n return;\n }\n\n if (!this.continuous && changes['page']) {\n await this.render();\n }\n }\n\n async safeRender() {\n try { await this.render(); } catch (_) {}\n }\n\n private async loadDocument() {\n this.loading.set(true);\n this.error.set(null);\n if (this.doc) {\n try { await this.doc.destroy(); } catch {}\n this.doc = undefined;\n }\n try {\n this.doc = await this.loadDocumentWithFallbacks(this.src);\n if (!this.doc) this.error.set('Failed to load PDF');\n } catch {\n this.doc = undefined;\n this.error.set('Failed to load PDF');\n } finally {\n this.loading.set(false);\n }\n }\n\n private async loadDocumentWithFallbacks(src: string | URL | Uint8Array | Blob): Promise<PDFDocumentProxy | undefined> {\n const primary = this.createPrimaryParams(src);\n if (primary) {\n const doc = await this.tryLoadDocument(primary);\n if (doc) return doc;\n }\n\n const bytes = await this.toPdfBytes(src);\n if (!bytes) return undefined;\n\n return this.tryLoadDocument({\n data: bytes,\n disableRange: true,\n disableStream: true,\n disableAutoFetch: true,\n stopAtErrors: true,\n });\n }\n\n private createPrimaryParams(src: string | URL | Uint8Array | Blob): DocumentInitParameters | null {\n if (typeof src === 'string') {\n return { url: src, withCredentials: false, stopAtErrors: true };\n }\n if (src instanceof URL) {\n return { url: src.toString(), withCredentials: false, stopAtErrors: true };\n }\n if (src instanceof Uint8Array) {\n const copy = new Uint8Array(src.byteLength);\n copy.set(src);\n return {\n data: copy,\n disableRange: true,\n disableStream: true,\n disableAutoFetch: true,\n stopAtErrors: true,\n };\n }\n return null;\n }\n\n private async tryLoadDocument(params: DocumentInitParameters): Promise<PDFDocumentProxy | undefined> {\n const task = pdfjsLib.getDocument(params as any) as PDFDocumentLoadingTask;\n const timeoutMs = Number.isFinite(this.loadTimeoutMs) ? Math.max(4000, this.loadTimeoutMs) : 15000;\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('PDF load timeout')), timeoutMs);\n });\n return await Promise.race([task.promise, timeout]);\n } catch {\n try { await task.destroy(); } catch {}\n return undefined;\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n private async toPdfBytes(src: string | URL | Uint8Array | Blob): Promise<Uint8Array | null> {\n if (src instanceof Uint8Array) {\n const copy = new Uint8Array(src.byteLength);\n copy.set(src);\n return copy;\n }\n if (src instanceof Blob) {\n try {\n return new Uint8Array(await src.arrayBuffer());\n } catch {\n return null;\n }\n }\n const href = typeof src === 'string' ? src : src.toString();\n if (typeof fetch === 'undefined') return null;\n try {\n const res = await fetch(href, { mode: 'cors' });\n if (!res.ok) return null;\n return new Uint8Array(await res.arrayBuffer());\n } catch {\n return null;\n }\n }\n\n async render() {\n if (!this.doc) return;\n const version = ++this.renderVersion;\n if (this.continuous) {\n await this.renderAllPages();\n return;\n }\n\n const pageNum = this.pageSig();\n const pdfPage = await this.doc.getPage(pageNum);\n this.currentPage = pdfPage;\n\n const canvas = this.canvas?.nativeElement;\n if (!canvas) return;\n const ctx = canvas.getContext('2d')!;\n\n const baseViewport = pdfPage.getViewport({ scale: 1 });\n const parent = canvas.parentElement!;\n const anchor = this.captureScrollAnchor(parent) || undefined;\n const pW = parent.clientWidth, pH = parent.clientHeight || baseViewport.height;\n\n let baseScale = 1;\n if (this.fit === 'width') baseScale = (pW - 16) / baseViewport.width;\n if (this.fit === 'height') baseScale = (pH - 16) / baseViewport.height;\n if (this.fit === 'page') baseScale = Math.min((pW - 16) / baseViewport.width, (pH - 16) / baseViewport.height);\n\n const minScale = baseScale * this.minZoom;\n const maxScale = baseScale * this.maxZoom;\n const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));\n this.canPan.set(finalScale > baseScale + 0.001);\n const viewport = pdfPage.getViewport({ scale: finalScale });\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;\n canvas.style.width = Math.floor(viewport.width) + 'px';\n canvas.style.height = Math.floor(viewport.height) + 'px';\n canvas.width = Math.floor(viewport.width * dpr);\n canvas.height = Math.floor(viewport.height * dpr);\n const renderCtx: any = { canvasContext: ctx, viewport };\n if (dpr !== 1) renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];\n const task = pdfPage.render(renderCtx);\n await task.promise;\n if (this.renderVersion !== version) return;\n if (anchor) this.restoreScrollAnchor(parent, anchor);\n }\n\n private async renderAllPages(anchorOverride?: { page: number; ratio: number }) {\n if (!this.doc) return;\n const stageEl = this.stage?.nativeElement;\n if (!stageEl) return;\n const version = ++this.renderVersion;\n const anchor = anchorOverride ?? this.captureScrollAnchor(stageEl);\n const total = this.doc.numPages;\n const parentRect = stageEl.getBoundingClientRect();\n const parentWidth = parentRect.width || stageEl.clientWidth || 800;\n let computedCanPan = false;\n const existing = Array.from(stageEl.querySelectorAll<HTMLElement>('.pdf-page'));\n const isInitialBuild = existing.length !== total;\n this.renderLockCount++;\n try {\n if (isInitialBuild) {\n stageEl.innerHTML = '';\n const contentEl = document.createElement('div');\n contentEl.className = 'pdf-content';\n stageEl.appendChild(contentEl);\n for (let i = 1; i <= total; i++) {\n const page = await this.doc.getPage(i);\n const baseViewport = page.getViewport({ scale: 1 });\n let baseScale = 1;\n if (this.fit === 'width') baseScale = (parentWidth - 16) / baseViewport.width;\n if (this.fit === 'page') baseScale = (parentWidth - 16) / baseViewport.width;\n const minScale = baseScale * this.minZoom;\n const maxScale = baseScale * this.maxZoom;\n const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));\n if (i === 1) computedCanPan = finalScale > baseScale + 0.001;\n const viewport = page.getViewport({ scale: finalScale });\n\n const wrapper = document.createElement('div');\n wrapper.className = 'pdf-page';\n wrapper.setAttribute('data-page', String(i));\n wrapper.style.width = Math.floor(viewport.width) + 'px';\n wrapper.style.height = Math.floor(viewport.height) + 'px';\n wrapper.style.margin = '0 auto 12px auto';\n\n const canvas = document.createElement('canvas');\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;\n canvas.style.width = Math.floor(viewport.width) + 'px';\n canvas.style.height = Math.floor(viewport.height) + 'px';\n canvas.width = Math.floor(viewport.width * dpr);\n canvas.height = Math.floor(viewport.height * dpr);\n const ctx = canvas.getContext('2d')!;\n\n wrapper.appendChild(canvas);\n contentEl.appendChild(wrapper);\n\n const renderCtx: any = { canvasContext: ctx, viewport };\n if (dpr !== 1) renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];\n const task = page.render(renderCtx);\n await task.promise;\n if (this.renderVersion !== version) return;\n }\n } else {\n let contentEl = stageEl.querySelector<HTMLElement>('.pdf-content');\n if (!contentEl) {\n contentEl = document.createElement('div');\n contentEl.className = 'pdf-content';\n const pages = Array.from(stageEl.querySelectorAll<HTMLElement>('.pdf-page'));\n for (const el of pages) contentEl.appendChild(el);\n stageEl.appendChild(contentEl);\n }\n for (let i = 1; i <= total; i++) {\n const page = await this.doc.getPage(i);\n const baseViewport = page.getViewport({ scale: 1 });\n let baseScale = 1;\n if (this.fit === 'width') baseScale = (parentWidth - 16) / baseViewport.width;\n if (this.fit === 'page') baseScale = (parentWidth - 16) / baseViewport.width;\n const minScale = baseScale * this.minZoom;\n const maxScale = baseScale * this.maxZoom;\n const finalScale = Math.max(minScale, Math.min(maxScale, baseScale * this.zoomSig()));\n if (i === 1) computedCanPan = finalScale > baseScale + 0.001;\n const viewport = page.getViewport({ scale: finalScale });\n\n const wrapper = existing[i - 1];\n const canvas = wrapper.querySelector('canvas') as HTMLCanvasElement;\n wrapper.style.width = Math.floor(viewport.width) + 'px';\n wrapper.style.height = Math.floor(viewport.height) + 'px';\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;\n canvas.style.width = Math.floor(viewport.width) + 'px';\n canvas.style.height = Math.floor(viewport.height) + 'px';\n canvas.width = Math.floor(viewport.width * dpr);\n canvas.height = Math.floor(viewport.height * dpr);\n const ctx = canvas.getContext('2d')!;\n const renderCtx: any = { canvasContext: ctx, viewport };\n if (dpr !== 1) renderCtx.transform = [dpr, 0, 0, dpr, 0, 0];\n const task = page.render(renderCtx);\n await task.promise;\n if (this.renderVersion !== version) return;\n }\n }\n this.canPan.set(computedCanPan);\n if (anchor) this.restoreScrollAnchor(stageEl, anchor);\n } finally {\n this.renderLockCount = Math.max(0, this.renderLockCount - 1);\n }\n }\n\n async goTo(page: number) {\n if (!this.doc) return;\n const p = Math.max(1, Math.min(this.doc.numPages, page));\n this.pageSig.set(p);\n if (this.continuous) {\n const stageEl = this.stage?.nativeElement;\n const el = stageEl?.querySelector(`[data-page=\"${p}\"]`) as HTMLElement | null;\n el?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n } else {\n await this.render();\n }\n }\n async zoomIn(step = 0.1) { await this.applyZoomDelta(step); }\n async zoomOut(step = 0.1) { await this.applyZoomDelta(-step); }\n\n private clampZoom(z: number): number {\n return Math.max(this.minZoom, Math.min(this.maxZoom, z));\n }\n\n private cancelPreviewIfAny(container?: HTMLElement): void {\n if (!this.previewActive || !container) return;\n const target = this.continuous ? (container.querySelector('.pdf-content') as HTMLElement || container) : (container.querySelector('canvas') as HTMLElement || container);\n try {\n target.style.transform = '';\n target.style.willChange = '';\n target.style.transition = '';\n } catch {}\n this.previewActive = false;\n this.lastZoomClient = null;\n }\n\n private async applyZoomDelta(delta: number): Promise<void> {\n const oldZoom = this.zoomSig();\n const newZoom = this.clampZoom(oldZoom + delta);\n if (Math.abs(newZoom - oldZoom) < 0.0001) return;\n\n const container = this.continuous ? this.stage?.nativeElement : this.singleStage?.nativeElement;\n // If a preview transform is active (from pinch/wheel), clear it before capturing anchor or animating\n this.cancelPreviewIfAny(container);\n const anchor = container ? this.captureScrollAnchor(container) || undefined : undefined;\n const ratio = newZoom / oldZoom;\n\n if (this.zoomAnimation && container && !this.zoomAnimInFlight) {\n this.zoomAnimInFlight = true;\n this.renderLockCount++;\n // Update UI value immediately\n this.zoomSig.set(newZoom);\n try {\n await this.runZoomAnimation(container, ratio);\n } finally {\n // Release the render lock before triggering the actual re-render\n this.renderLockCount = Math.max(0, this.renderLockCount - 1);\n await this.safeReRenderWithCancellation(anchor);\n this.zoomAnimInFlight = false;\n }\n } else {\n this.zoomSig.set(newZoom);\n await this.safeReRenderWithCancellation(anchor);\n }\n }\n\n private async runZoomAnimation(container: HTMLElement, ratio: number): Promise<void> {\n if (Math.abs(ratio - 1) < 0.0001) return;\n const { target, originX, originY } = this.getZoomAnimTarget(container);\n return new Promise<void>((resolve) => {\n try {\n const onDone = () => {\n cleanup();\n resolve();\n };\n const cleanup = () => {\n target.removeEventListener('transitionend', onEnd as any);\n target.style.transition = '';\n target.style.transform = '';\n target.style.transformOrigin = '';\n target.style.willChange = '';\n };\n const onEnd = () => onDone();\n target.style.willChange = 'transform';\n target.style.transformOrigin = `${Math.max(0, originX)}px ${Math.max(0, originY)}px`;\n target.style.transition = 'none';\n target.style.transform = 'scale(1)';\n requestAnimationFrame(() => {\n target.addEventListener('transitionend', onEnd as any, { once: true } as any);\n target.style.transition = `transform ${this.zoomAnimationMs}ms cubic-bezier(0.2,0,0,1)`;\n target.style.transform = `scale(${ratio})`;\n setTimeout(onDone, this.zoomAnimationMs + 60);\n });\n } catch {\n resolve();\n }\n });\n }\n\n private getZoomAnimTarget(container: HTMLElement): { target: HTMLElement; originX: number; originY: number } {\n const isContinuous = this.continuous;\n let target: HTMLElement | null = null;\n if (isContinuous) {\n target = container.querySelector<HTMLElement>('.pdf-content');\n if (!target) target = container; // fallback\n } else {\n target = container.querySelector<HTMLElement>('canvas');\n if (!target) target = container; // fallback\n }\n const rectLeft = target.offsetLeft;\n const rectTop = target.offsetTop;\n // Prefer last gesture point (pinch center or wheel pointer) if available\n const client = this.lastZoomClient;\n const originX = client ? (container.scrollLeft + client.x - rectLeft) : (container.scrollLeft + container.clientWidth / 2 - rectLeft);\n const originY = client ? (container.scrollTop + client.y - rectTop) : (container.scrollTop + container.clientHeight / 2 - rectTop);\n return { target, originX, originY };\n }\n\n onScroll(evt: Event) {\n const container = evt.target as HTMLElement;\n // debounce via rAF\n if (this.scrollRaf) cancelAnimationFrame(this.scrollRaf);\n this.scrollRaf = requestAnimationFrame(() => {\n if (!this.doc || !this.continuous) return;\n const pages = Array.from(container.querySelectorAll<HTMLElement>('.pdf-page'));\n if (!pages.length) return;\n const centerY = container.scrollTop + container.clientHeight / 2;\n let current = this.pageSig();\n for (const el of pages) {\n const top = el.offsetTop;\n const bottom = top + el.offsetHeight;\n if (centerY >= top && centerY <= bottom) {\n const p = parseInt(el.getAttribute('data-page') || '1', 10);\n current = p;\n break;\n }\n }\n if (current !== this.pageSig()) this.pageSig.set(current);\n });\n }\n\n async nextPage() { await this.goTo(this.pageSig() + 1); }\n async prevPage() { await this.goTo(this.pageSig() - 1); }\n\n isZoomed(): boolean {\n return Math.abs(this.zoomSig() - 1) > 0.0001;\n }\n\n async resetZoom() {\n // Reset to exactly 1.0 (100%)\n const delta = 1 - this.zoomSig();\n await this.applyZoomDelta(delta);\n }\n\n async retryLoad() {\n await this.loadDocument();\n if (this.doc) {\n const pages = this.doc.numPages;\n if (this.pageSig() < 1) this.pageSig.set(1);\n if (this.pageSig() > pages) this.pageSig.set(pages);\n await this.render();\n }\n }\n\n onPointerDown(evt: PointerEvent, containerEl: HTMLElement) {\n // Pinch-to-zoom (two pointers)\n if (evt.pointerType === 'touch') {\n this.activePointers.set(evt.pointerId, { x: evt.clientX, y: evt.clientY, type: evt.pointerType });\n const onPointerMove = (e: PointerEvent) => {\n if (e.pointerType === 'touch') this.activePointers.set(e.pointerId, { x: e.clientX, y: e.clientY, type: e.pointerType });\n const touches = Array.from(this.activePointers.entries()).map(([id, p]) => ({ pointerId: id, clientX: p.x, clientY: p.y }))\n .slice(0, 2);\n if (touches.length === 2) {\n const [a, b] = touches;\n const dist = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);\n if (!this.pinchState) {\n this.pinchState = { id1: a.pointerId, id2: b.pointerId, startDist: Math.max(1, dist), startZoom: this.zoomSig() };\n const rect = containerEl.getBoundingClientRect();\n this.lastZoomClient = { x: ((a.clientX + b.clientX) / 2) - rect.left, y: ((a.clientY + b.clientY) / 2) - rect.top };\n }\n const scale = dist / Math.max(1, this.pinchState.startDist);\n const adjusted = 1 + (scale - 1) * this.PINCH_SENSITIVITY;\n const desiredAdj = this.clampZoom(this.pinchState.startZoom * adjusted);\n this.previewZoom(containerEl, desiredAdj);\n e.preventDefault();\n return;\n }\n // When pinch ends (not exactly two touches), commit render if we were previewing\n if (this.pinchState) {\n const final = this.zoomSig();\n this.commitPreviewZoom(containerEl, final);\n this.pinchState = null;\n this.lastZoomClient = null;\n }\n };\n const onPointerEnd = (e: PointerEvent) => {\n this.activePointers.delete(e.pointerId);\n const touches = Array.from(this.activePointers.values());\n if (touches.length !== 2 && this.pinchState) {\n const final = this.zoomSig();\n this.commitPreviewZoom(containerEl, final);\n this.pinchState = null;\n this.lastZoomClient = null;\n }\n cleanup();\n };\n const cleanup = () => {\n containerEl.removeEventListener('pointermove', onPointerMove);\n containerEl.removeEventListener('pointerup', onPointerEnd);\n containerEl.removeEventListener('pointercancel', onPointerEnd);\n this.activePointers.clear();\n };\n containerEl.addEventListener('pointermove', onPointerMove);\n containerEl.addEventListener('pointerup', onPointerEnd);\n containerEl.addEventListener('pointercancel', onPointerEnd);\n return;\n }\n\n // Mouse pan when canPan\n if (!this.canPan()) return;\n this.isPanning.set(true);\n const startX = evt.clientX;\n const startY = evt.clientY;\n const startLeft = containerEl.scrollLeft;\n const startTop = containerEl.scrollTop;\n containerEl.style.scrollBehavior = 'auto';\n containerEl.setPointerCapture?.(evt.pointerId);\n const move = (e: PointerEvent) => {\n const dx = e.clientX - startX;\n const dy = e.clientY - startY;\n containerEl.scrollLeft = startLeft - dx;\n containerEl.scrollTop = startTop - dy;\n e.preventDefault();\n };\n const end = (e: PointerEvent) => {\n this.isPanning.set(false);\n containerEl.releasePointerCapture?.(evt.pointerId);\n containerEl.removeEventListener('pointermove', move);\n containerEl.removeEventListener('pointerup', end);\n containerEl.removeEventListener('pointercancel', end);\n containerEl.style.scrollBehavior = 'smooth';\n };\n containerEl.addEventListener('pointermove', move);\n containerEl.addEventListener('pointerup', end);\n containerEl.addEventListener('pointercancel', end);\n }\n\n private getActiveTouches(containerEl: HTMLElement): PointerEvent[] {\n // We capture pointer events only on this element; maintain list by querying PointerEvent.getCoalescedEvents not available broadly.\n // Instead, rely on touches reported in native events; browsers will deliver move events for all active pointers targeting the element.\n // Here we cannot query directly; so we return an empty array and use move handler state. For simplicity, we derive from event stream only.\n // This helper remains for future extension; current logic passes actual events to compute pinch.\n return [] as any;\n }\n\n onWheel(evt: WheelEvent, containerEl: HTMLElement) {\n const isCtrlZoom = evt.ctrlKey || evt.metaKey;\n if (!isCtrlZoom) return;\n evt.preventDefault();\n const rect = containerEl.getBoundingClientRect();\n // Record gesture point relative to container\n this.lastZoomClient = { x: evt.clientX - rect.left, y: evt.clientY - rect.top };\n if (this.wheelRaf) cancelAnimationFrame(this.wheelRaf);\n if (this.wheelCommitTimer) clearTimeout(this.wheelCommitTimer);\n const delta = -evt.deltaY;\n const step = delta > 0 ? this.WHEEL_STEP : -this.WHEEL_STEP;\n const desired = this.clampZoom(this.zoomSig() + step);\n this.previewZoom(containerEl, desired);\n this.wheelRaf = requestAnimationFrame(() => {\n this.wheelCommitTimer = setTimeout(() => {\n this.commitPreviewZoom(containerEl, this.zoomSig());\n this.lastZoomClient = null;\n }, this.gestureAnimationMs + 20);\n });\n }\n\n private previewZoom(container: HTMLElement, newZoom: number) {\n const oldZoom = this.zoomSig();\n if (Math.abs(newZoom - oldZoom) < 0.0001) return;\n const ratio = newZoom / oldZoom;\n const target = this.continuous ? (container.querySelector('.pdf-content') as HTMLElement || container) : (container.querySelector('canvas') as HTMLElement || container);\n const origin = this.getZoomAnimTarget(container);\n target.style.willChange = 'transform';\n target.style.transformOrigin = `${Math.max(0, origin.originX)}px ${Math.max(0, origin.originY)}px`;\n target.style.transition = `transform ${this.gestureAnimationMs}ms cubic-bezier(0.2,0,0,1)`;\n target.style.transform = `scale(${ratio})`;\n this.zoomSig.set(newZoom);\n this.previewActive = true;\n }\n\n private async commitPreviewZoom(container: HTMLElement, expectedZoom: number) {\n // Clear transform and re-render once; cancel any in-flight render tasks\n const target = this.continuous ? (container.querySelector('.pdf-content') as HTMLElement || container) : (container.querySelector('canvas') as HTMLElement || container);\n target.style.transform = '';\n target.style.willChange = '';\n target.style.transition = '';\n const anchor = this.captureScrollAnchor(container) || undefined;\n if (this.previewActive) {\n await this.safeReRenderWithCancellation(anchor);\n this.previewActive = false;\n }\n }\n\n private async safeReRenderWithCancellation(anchor?: { page: number; ratio: number }) {\n // If a render is in progress, queue once with the most recent anchor\n if (this.renderLockCount > 0) {\n this.reRenderQueued = true;\n if (anchor) this.pendingAnchor = anchor;\n return;\n }\n try {\n this.renderLockCount++;\n if (this.continuous) {\n await this.renderAllPages(anchor);\n } else {\n await this.render();\n }\n } finally {\n this.renderLockCount = Math.max(0, this.renderLockCount - 1);\n if (this.renderLockCount === 0 && this.reRenderQueued) {\n const nextAnchor = this.pendingAnchor;\n this.reRenderQueued = false;\n this.pendingAnchor = undefined;\n await this.safeReRenderWithCancellation(nextAnchor);\n }\n }\n }\n\n private captureScrollAnchor(container: HTMLElement, client?: { x: number; y: number } | null): { page: number; ratio: number } | null {\n try {\n const pages = Array.from(container.querySelectorAll<HTMLElement>('.pdf-page'));\n const centerY = container.scrollTop + container.clientHeight / 2;\n if (pages.length > 0) {\n let pageEl = pages.find(el => (el.offsetTop <= centerY && (el.offsetTop + el.offsetHeight) >= centerY))\n || pages.find(el => (el.offsetTop + el.offsetHeight) > (container.scrollTop + 1))\n || pages[0];\n const page = parseInt(pageEl.getAttribute('data-page') || '1', 10);\n const height = Math.max(1, pageEl.offsetHeight);\n const ratio = Math.max(0, Math.min(1, (centerY - pageEl.offsetTop) / height));\n return { page, ratio };\n }\n // Fallback: single-canvas mode\n const canvas = container.querySelector('canvas');\n if (!canvas) return null;\n const height = Math.max(1, (canvas as HTMLElement).offsetHeight);\n const ratio = Math.max(0, Math.min(1, (centerY - (canvas as HTMLElement).offsetTop) / height));\n return { page: 1, ratio };\n } catch {\n return null;\n }\n }\n\n private restoreScrollAnchor(container: HTMLElement, anchor: { page: number; ratio: number }): void {\n try {\n let el = container.querySelector<HTMLElement>(`[data-page=\"${anchor.page}\"]`);\n if (!el) el = container.querySelector<HTMLElement>('canvas');\n if (!el) return;\n const prevBehavior = container.style.scrollBehavior;\n container.style.scrollBehavior = 'auto';\n const height = Math.max(1, el.offsetHeight);\n const desired = el.offsetTop + anchor.ratio * height - container.clientHeight / 2;\n const maxScroll = Math.max(0, container.scrollHeight - container.clientHeight);\n container.scrollTop = Math.max(0, Math.min(maxScroll, desired));\n container.style.scrollBehavior = prevBehavior;\n } catch {}\n }\n\n async download() {\n const filename = this.deriveFilename();\n const link = document.createElement('a');\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && (navigator as any).maxTouchPoints > 1);\n let popup: Window | null = null;\n if (isIOS) {\n // Open a tab synchronously to stay within user gesture\n try { popup = window.open('', '_blank', 'noopener,noreferrer'); } catch { popup = null; }\n }\n\n const blob = await this.createBlobFromSrc();\n if (blob) {\n const url = URL.createObjectURL(blob);\n if (isIOS) {\n if (popup) {\n try { popup.location.href = url; } catch { /* ignore */ }\n // Revoke later to allow the view to load fully\n setTimeout(() => URL.revokeObjectURL(url), 30000);\n } else {\n const a = document.createElement('a');\n a.href = url;\n a.target = '_blank';\n a.rel = 'noopener';\n document.body.appendChild(a);\n a.click();\n a.remove();\n setTimeout(() => URL.revokeObjectURL(url), 30000);\n }\n } else {\n link.href = url;\n link.download = filename;\n link.rel = 'noopener';\n link.style.display = 'none';\n document.body.appendChild(link);\n link.click();\n link.remove();\n URL.revokeObjectURL(url);\n }\n return;\n }\n\n // Fallback: cross-origin without CORS\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (!href) return;\n if (isIOS) {\n if (popup) {\n try { popup.location.href = href; } catch { /* ignore */ }\n } else {\n const a = document.createElement('a');\n a.href = href;\n a.target = '_blank';\n a.rel = 'noopener';\n document.body.appendChild(a);\n a.click();\n a.remove();\n }\n } else {\n link.href = href;\n link.target = '_blank';\n link.rel = 'noopener';\n link.download = filename; // browsers may ignore for cross-origin\n link.style.display = 'none';\n document.body.appendChild(link);\n link.click();\n link.remove();\n }\n }\n\n async print() {\n // Robust, plugin-free printing by rendering pages to images\n const ok = await this.printViaImages();\n if (ok) return;\n // Fallbacks\n const blob = await this.createBlobFromSrc();\n if (blob) {\n const url = URL.createObjectURL(blob);\n const win = window.open('', '_blank', 'noopener,noreferrer');\n if (win) {\n win.document.write('<!doctype html><html><head><title>Print</title><meta charset=\"utf-8\"><style>html,body{height:100%;margin:0}@page{size:auto;margin:0} iframe{border:0;width:100%;height:100%}</style></head><body><iframe src=\"' + url + '\"></iframe></body></html>');\n win.document.close();\n setTimeout(() => { try { win.focus(); win.print(); } catch {} }, 800);\n win.onafterprint = () => { try { win.close(); } catch {} URL.revokeObjectURL(url); };\n } else {\n const iframe = document.createElement('iframe');\n iframe.style.position = 'fixed'; iframe.style.right = '0'; iframe.style.bottom = '0';\n iframe.style.width = '0'; iframe.style.height = '0'; iframe.style.border = '0';\n iframe.src = url; document.body.appendChild(iframe);\n iframe.onload = () => { try { setTimeout(() => iframe.contentWindow?.print(), 800); } catch {} setTimeout(() => { URL.revokeObjectURL(url); iframe.remove(); }, 3000); };\n }\n return;\n }\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (href) window.open(href, '_blank');\n }\n\n private async printViaImages(): Promise<boolean> {\n try {\n let doc = this.doc;\n if (!doc) {\n doc = await this.loadDocumentWithFallbacks(this.src);\n }\n if (!doc) return false;\n const win = window.open('', '_blank', 'noopener,noreferrer');\n if (!win) return false;\n win.document.write('<!doctype html><html><head><meta charset=\"utf-8\"><title>Print</title><style>@page{size:auto;margin:0} html,body{margin:0;padding:0} .page{page-break-after:always;}</style></head><body></body></html>');\n win.document.close();\n\n for (let i = 1; i <= doc.numPages; i++) {\n const page = await doc.getPage(i);\n const vp = page.getViewport({ scale: this.PRINT_SCALE });\n const canvas = document.createElement('canvas');\n canvas.width = Math.floor(vp.width);\n canvas.height = Math.floor(vp.height);\n const ctx = canvas.getContext('2d')!;\n await page.render({ canvas, canvasContext: ctx, viewport: vp }).promise;\n const img = win.document.createElement('img');\n img.className = 'page';\n img.style.width = '100%';\n img.style.display = 'block';\n img.src = canvas.toDataURL('image/png');\n win.document.body.appendChild(img);\n }\n setTimeout(() => { try { win.focus(); win.print(); } catch {} }, 300);\n win.onafterprint = () => { try { win.close(); } catch {} };\n setTimeout(() => { try { win.close(); } catch {} }, 60000);\n return true;\n } catch {\n return false;\n }\n }\n\n private async createBlobFromSrc(): Promise<Blob | null> {\n if (!this.src) return null;\n if (this.src instanceof Blob) return this.src;\n if (this.src instanceof Uint8Array) {\n const ab = new ArrayBuffer(this.src.byteLength);\n new Uint8Array(ab).set(this.src);\n return new Blob([ab], { type: 'application/pdf' });\n }\n const href = typeof this.src === 'string' ? this.src : (this.src instanceof URL ? this.src.toString() : '');\n if (!href || typeof fetch === 'undefined') return null;\n try {\n const res = await fetch(href, { mode: 'cors' });\n if (!res.ok) return null;\n const blob = await res.blob();\n return blob.type ? blob : new Blob([await res.arrayBuffer()], { type: 'application/pdf' });\n } catch {\n return null;\n }\n }\n\n private deriveFilename(): string {\n if (typeof this.src === 'string') {\n try { const u = new URL(this.src, window.location.origin); return this.basename(u.pathname) || 'document.pdf'; } catch { return 'document.pdf'; }\n }\n if (this.src instanceof URL) {\n return this.basename(this.src.pathname) || 'document.pdf';\n }\n return 'document.pdf';\n }\n\n private basename(path: string): string {\n const last = path.split('/').filter(Boolean).pop() || '';\n return last.endsWith('.pdf') ? last : (last ? last + '.pdf' : 'document.pdf');\n }\n}\n","import { APP_INITIALIZER, InjectionToken, Provider, PLATFORM_ID } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport * as pdfjsLib from 'pdfjs-dist';\n\nexport type GenusPdfWorkerConfig = {\n /** Try ESM module worker first (best); falls back to workerSrc if creation fails. */\n tryModuleWorker?: boolean;\n /** Absolute URL the app serves the worker from. Default: /assets/pdf.worker.min.mjs */\n workerSrc?: string;\n};\n\nexport const GENUS_PDF_WORKER_CONFIG = new InjectionToken<GenusPdfWorkerConfig>('GENUS_PDF_WORKER_CONFIG');\n\nfunction resolveBundledWorkerUrl(): string | null {\n try {\n return new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).toString();\n } catch {\n return null;\n }\n}\n\nasync function isWorkerUrlReachable(url: string): Promise<boolean> {\n try {\n const response = await fetch(url, { method: 'HEAD', cache: 'no-store' });\n return response.ok || response.status === 405;\n } catch {\n return false;\n }\n}\n\nfunction initPdfWorkerFactory(cfg: GenusPdfWorkerConfig, platformId: object) {\n return async () => {\n if (!isPlatformBrowser(platformId)) return;\n\n const defaults: Required<Pick<GenusPdfWorkerConfig, 'tryModuleWorker' | 'workerSrc'>> = {\n tryModuleWorker: true,\n workerSrc: '/assets/pdf.worker.min.mjs',\n };\n const merged = { ...defaults, ...cfg };\n\n const globalOptions = (pdfjsLib as any).GlobalWorkerOptions;\n globalOptions.workerPort = null;\n globalOptions.workerSrc = merged.workerSrc;\n\n if (!merged.tryModuleWorker) return;\n const bundledWorkerUrl = resolveBundledWorkerUrl();\n if (!bundledWorkerUrl) return;\n if (await isWorkerUrlReachable(bundledWorkerUrl)) {\n globalOptions.workerSrc = bundledWorkerUrl;\n }\n };\n}\n\nexport function provideGenusPdfViewer(cfg: GenusPdfWorkerConfig = {}): Provider[] {\n return [\n { provide: GENUS_PDF_WORKER_CONFIG, useValue: cfg },\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: initPdfWorkerFactory,\n deps: [GENUS_PDF_WORKER_CONFIG, PLATFORM_ID],\n },\n ];\n}\n","/*\n * Public API Surface of genus-pdf-viewer\n */\n\nexport * from './lib/genus-pdf-viewer';\nexport { GenusPdfViewerComponent } from './lib/genus-pdf-viewer';\nexport * from './lib/pdfjs-worker.provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MA+Ea,uBAAuB,CAAA;AACzB,IAAA,GAAG;IACH,IAAI,GAAG,CAAC;IACR,IAAI,GAAG,GAAG;IACV,OAA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AO,YAAW;AAChB,QAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;YAAE;AAEpC,QAAA,MAAM,QAAQ,GAA0E;AACtF,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,SAAS,EAAE,4BAA4B;SACxC;QACD,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,GAAG,EAAE;AAEtC,QAAA,MAAM,aAAa,GAAI,QAAgB,CAAC,mBAAmB;AAC3D,QAAA,aAAa,CAAC,UAAU,GAAG,IAAI;AAC/B,QAAA,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;QAE1C,IAAI,CAAC,MAAM,CAAC,eAAe;YAAE;AAC7B,QAAA,MAAM,gBAAgB,GAAG,uBAAuB,EAAE;AAClD,QAAA,IAAI,CAAC,gBAAgB;YAAE;AACvB,QAAA,IAAI,MAAM,oBAAoB,CAAC,gBAAgB,CAAC,EAAE;AAChD,YAAA,aAAa,CAAC,SAAS,GAAG,gBAAgB;QAC5C;AACF,IAAA,CAAC;AACH;AAEM,SAAU,qBAAqB,CAAC,GAAA,GAA4B,EAAE,EAAA;IAClE,OAAO;AACL,QAAA,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,GAAG,EAAE;AACnD,QAAA;AACE,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,UAAU,EAAE,oBAAoB;AAChC,YAAA,IAAI,EAAE,CAAC,uBAAuB,EAAE,WAAW,CAAC;AAC7C,SAAA;KACF;AACH;;AC/DA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare class GenusPdfViewerComponent implements OnChanges {
|
|
|
15
15
|
zoomAnimation: boolean;
|
|
16
16
|
zoomAnimationMs: number;
|
|
17
17
|
gestureAnimationMs: number;
|
|
18
|
+
loadTimeoutMs: number;
|
|
18
19
|
canvas: ElementRef<HTMLCanvasElement>;
|
|
19
20
|
singleStage: ElementRef<HTMLDivElement>;
|
|
20
21
|
stage: ElementRef<HTMLDivElement>;
|
|
@@ -46,6 +47,10 @@ declare class GenusPdfViewerComponent implements OnChanges {
|
|
|
46
47
|
ngOnChanges(changes: SimpleChanges): Promise<void>;
|
|
47
48
|
safeRender(): Promise<void>;
|
|
48
49
|
private loadDocument;
|
|
50
|
+
private loadDocumentWithFallbacks;
|
|
51
|
+
private createPrimaryParams;
|
|
52
|
+
private tryLoadDocument;
|
|
53
|
+
private toPdfBytes;
|
|
49
54
|
render(): Promise<void>;
|
|
50
55
|
private renderAllPages;
|
|
51
56
|
goTo(page: number): Promise<void>;
|
|
@@ -76,9 +81,8 @@ declare class GenusPdfViewerComponent implements OnChanges {
|
|
|
76
81
|
private createBlobFromSrc;
|
|
77
82
|
private deriveFilename;
|
|
78
83
|
private basename;
|
|
79
|
-
private normalizePdfSource;
|
|
80
84
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<GenusPdfViewerComponent, never>;
|
|
81
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<GenusPdfViewerComponent, "genus-pdf-viewer", never, { "src": { "alias": "src"; "required": false; }; "page": { "alias": "page"; "required": false; }; "zoom": { "alias": "zoom"; "required": false; }; "maxZoom": { "alias": "maxZoom"; "required": false; }; "minZoom": { "alias": "minZoom"; "required": false; }; "fit": { "alias": "fit"; "required": false; }; "disableTextLayer": { "alias": "disableTextLayer"; "required": false; }; "continuous": { "alias": "continuous"; "required": false; }; "showToolbar": { "alias": "showToolbar"; "required": false; }; "zoomAnimation": { "alias": "zoomAnimation"; "required": false; }; "zoomAnimationMs": { "alias": "zoomAnimationMs"; "required": false; }; "gestureAnimationMs": { "alias": "gestureAnimationMs"; "required": false; }; }, {}, never, ["[toolbar]"], true, never>;
|
|
85
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<GenusPdfViewerComponent, "genus-pdf-viewer", never, { "src": { "alias": "src"; "required": false; }; "page": { "alias": "page"; "required": false; }; "zoom": { "alias": "zoom"; "required": false; }; "maxZoom": { "alias": "maxZoom"; "required": false; }; "minZoom": { "alias": "minZoom"; "required": false; }; "fit": { "alias": "fit"; "required": false; }; "disableTextLayer": { "alias": "disableTextLayer"; "required": false; }; "continuous": { "alias": "continuous"; "required": false; }; "showToolbar": { "alias": "showToolbar"; "required": false; }; "zoomAnimation": { "alias": "zoomAnimation"; "required": false; }; "zoomAnimationMs": { "alias": "zoomAnimationMs"; "required": false; }; "gestureAnimationMs": { "alias": "gestureAnimationMs"; "required": false; }; "loadTimeoutMs": { "alias": "loadTimeoutMs"; "required": false; }; }, {}, never, ["[toolbar]"], true, never>;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
type GenusPdfWorkerConfig = {
|
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Add genus-pdf-viewer provider and worker asset",
|
|
6
|
+
"factory": "./ng-add/index#ngAdd",
|
|
7
|
+
"schema": "./ng-add/schema.json"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { SchematicsException } = require('@angular-devkit/schematics');
|
|
4
|
+
|
|
5
|
+
const PROVIDER_CALL = 'provideGenusPdfViewer()';
|
|
6
|
+
|
|
7
|
+
function toPosix(filePath) {
|
|
8
|
+
return filePath.replace(/\\/g, '/');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function readWorkspace(tree) {
|
|
12
|
+
const workspacePath = '/angular.json';
|
|
13
|
+
if (!tree.exists(workspacePath)) {
|
|
14
|
+
throw new SchematicsException('angular.json not found in workspace root');
|
|
15
|
+
}
|
|
16
|
+
const raw = tree.read(workspacePath);
|
|
17
|
+
if (!raw) {
|
|
18
|
+
throw new SchematicsException('Unable to read angular.json');
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(raw.toString('utf-8'));
|
|
22
|
+
} catch {
|
|
23
|
+
throw new SchematicsException('Invalid angular.json');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolveProjectName(workspace, requestedProject) {
|
|
28
|
+
if (requestedProject) return requestedProject;
|
|
29
|
+
if (workspace.defaultProject) return workspace.defaultProject;
|
|
30
|
+
const projectNames = Object.keys(workspace.projects || {});
|
|
31
|
+
const appProject = projectNames.find((name) => workspace.projects[name]?.projectType === 'application');
|
|
32
|
+
return appProject || projectNames[0];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveAssetsDir(project) {
|
|
36
|
+
const assets = project?.architect?.build?.options?.assets;
|
|
37
|
+
if (Array.isArray(assets)) {
|
|
38
|
+
for (const asset of assets) {
|
|
39
|
+
if (typeof asset === 'string') {
|
|
40
|
+
const normalized = toPosix(asset);
|
|
41
|
+
if (normalized.endsWith('/assets')) return normalized;
|
|
42
|
+
} else if (asset && typeof asset.input === 'string') {
|
|
43
|
+
const input = toPosix(asset.input).replace(/\/$/, '');
|
|
44
|
+
if (input.endsWith('/assets')) return input;
|
|
45
|
+
return `${input}/assets`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (typeof project?.sourceRoot === 'string') {
|
|
50
|
+
return `${toPosix(project.sourceRoot).replace(/\/$/, '')}/assets`;
|
|
51
|
+
}
|
|
52
|
+
if (typeof project?.root === 'string') {
|
|
53
|
+
return `${toPosix(project.root).replace(/\/$/, '')}/src/assets`;
|
|
54
|
+
}
|
|
55
|
+
return 'src/assets';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function findAppConfigPath(tree, project) {
|
|
59
|
+
const sourceRoot = toPosix(project?.sourceRoot || '');
|
|
60
|
+
const candidates = [
|
|
61
|
+
`${sourceRoot}/app/app.config.ts`,
|
|
62
|
+
`${sourceRoot}/app.config.ts`,
|
|
63
|
+
];
|
|
64
|
+
return candidates.find((candidate) => candidate && tree.exists(candidate)) || null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function detectImportPath(content, requestedImportPath) {
|
|
68
|
+
if (content.includes(`from '@genus/pdf-viewer'`) || content.includes(`from "@genus/pdf-viewer"`)) {
|
|
69
|
+
return '@genus/pdf-viewer';
|
|
70
|
+
}
|
|
71
|
+
if (content.includes(`from 'genus-pdf-viewer'`) || content.includes(`from "genus-pdf-viewer"`)) {
|
|
72
|
+
return 'genus-pdf-viewer';
|
|
73
|
+
}
|
|
74
|
+
return requestedImportPath || 'genus-pdf-viewer';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function ensureImport(content, importPath) {
|
|
78
|
+
if (content.includes('provideGenusPdfViewer')) return content;
|
|
79
|
+
const importLine = `import { provideGenusPdfViewer } from '${importPath}';`;
|
|
80
|
+
const lines = content.split('\n');
|
|
81
|
+
let lastImportIndex = -1;
|
|
82
|
+
for (let i = 0; i < lines.length; i++) {
|
|
83
|
+
if (lines[i].trim().startsWith('import ')) {
|
|
84
|
+
lastImportIndex = i;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
lines.splice(lastImportIndex + 1, 0, importLine);
|
|
88
|
+
return lines.join('\n');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function ensureProvider(content) {
|
|
92
|
+
if (content.includes(PROVIDER_CALL)) return { content, changed: false };
|
|
93
|
+
if (!/providers\s*:\s*\[/.test(content)) return { content, changed: false };
|
|
94
|
+
return {
|
|
95
|
+
content: content.replace(/providers\s*:\s*\[/, (match) => `${match}\n ${PROVIDER_CALL},`),
|
|
96
|
+
changed: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function patchAppConfig(tree, appConfigPath, importPath, context) {
|
|
101
|
+
const raw = tree.read(appConfigPath);
|
|
102
|
+
if (!raw) return false;
|
|
103
|
+
let content = raw.toString('utf-8');
|
|
104
|
+
const detectedImportPath = detectImportPath(content, importPath);
|
|
105
|
+
content = ensureImport(content, detectedImportPath);
|
|
106
|
+
const result = ensureProvider(content);
|
|
107
|
+
if (!result.changed) {
|
|
108
|
+
if (!result.content.includes(PROVIDER_CALL)) {
|
|
109
|
+
context.logger.warn(`Could not inject ${PROVIDER_CALL} into ${appConfigPath}. Add it manually.`);
|
|
110
|
+
}
|
|
111
|
+
if (result.content !== raw.toString('utf-8')) {
|
|
112
|
+
tree.overwrite(appConfigPath, result.content);
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
tree.overwrite(appConfigPath, result.content);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function copyWorkerFile(tree, targetDir, overwriteWorker, context) {
|
|
121
|
+
const sourcePath = path.join(process.cwd(), 'node_modules', 'pdfjs-dist', 'build', 'pdf.worker.min.mjs');
|
|
122
|
+
if (!fs.existsSync(sourcePath)) {
|
|
123
|
+
context.logger.warn('pdfjs worker not found in node_modules. Install dependencies and copy manually.');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const targetPath = `${targetDir.replace(/\/$/, '')}/pdf.worker.min.mjs`;
|
|
127
|
+
const contents = fs.readFileSync(sourcePath, 'utf-8');
|
|
128
|
+
if (tree.exists(targetPath)) {
|
|
129
|
+
if (overwriteWorker) {
|
|
130
|
+
tree.overwrite(targetPath, contents);
|
|
131
|
+
context.logger.info(`Updated ${targetPath}`);
|
|
132
|
+
} else {
|
|
133
|
+
context.logger.info(`Kept existing ${targetPath}`);
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
tree.create(targetPath, contents);
|
|
138
|
+
context.logger.info(`Created ${targetPath}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function ngAdd(options = {}) {
|
|
142
|
+
return (tree, context) => {
|
|
143
|
+
const workspace = readWorkspace(tree);
|
|
144
|
+
const projectName = resolveProjectName(workspace, options.project);
|
|
145
|
+
if (!projectName || !workspace.projects?.[projectName]) {
|
|
146
|
+
throw new SchematicsException('Could not resolve target Angular project');
|
|
147
|
+
}
|
|
148
|
+
const project = workspace.projects[projectName];
|
|
149
|
+
const appConfigPath = findAppConfigPath(tree, project);
|
|
150
|
+
if (appConfigPath) {
|
|
151
|
+
patchAppConfig(tree, appConfigPath, options.importPath, context);
|
|
152
|
+
} else {
|
|
153
|
+
context.logger.warn('app.config.ts not found. Add provideGenusPdfViewer() manually.');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!options.skipWorkerCopy) {
|
|
157
|
+
const assetsDir = resolveAssetsDir(project);
|
|
158
|
+
copyWorkerFile(tree, assetsDir, options.overwriteWorker, context);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
context.logger.info('genus-pdf-viewer ng-add completed.');
|
|
162
|
+
return tree;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
module.exports = {
|
|
167
|
+
ngAdd,
|
|
168
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "GenusPdfViewerNgAddSchema",
|
|
4
|
+
"title": "Genus PDF Viewer ng-add",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Angular project to configure"
|
|
10
|
+
},
|
|
11
|
+
"importPath": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Import path used for provideGenusPdfViewer",
|
|
14
|
+
"default": "genus-pdf-viewer"
|
|
15
|
+
},
|
|
16
|
+
"skipWorkerCopy": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Skip copying pdf.worker.min.mjs into assets/public",
|
|
19
|
+
"default": false
|
|
20
|
+
},
|
|
21
|
+
"overwriteWorker": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Overwrite existing worker file",
|
|
24
|
+
"default": false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|