fix(structure): group components into groups inside the repo
This commit is contained in:
36
ts_web/elements/00group-pdf/dees-pdf-shared/PdfManager.ts
Normal file
36
ts_web/elements/00group-pdf/dees-pdf-shared/PdfManager.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { domtools } from '@design.estate/dees-element';
|
||||
|
||||
export class PdfManager {
|
||||
private static pdfjsLib: any;
|
||||
private static initialized = false;
|
||||
|
||||
public static async initialize() {
|
||||
if (this.initialized) return;
|
||||
|
||||
// @ts-ignore
|
||||
this.pdfjsLib = await import('https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/+esm');
|
||||
this.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/build/pdf.worker.mjs';
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public static async loadDocument(url: string): Promise<any> {
|
||||
await this.initialize();
|
||||
|
||||
// IMPORTANT: Disabled caching to ensure component isolation
|
||||
// Each viewer instance gets its own document to prevent state sharing
|
||||
// This fixes issues where multiple viewers interfere with each other
|
||||
const loadingTask = this.pdfjsLib.getDocument(url);
|
||||
const document = await loadingTask.promise;
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public static releaseDocument(_url: string) {
|
||||
// No-op since we're not caching documents anymore
|
||||
// Each viewer manages its own document lifecycle
|
||||
}
|
||||
|
||||
// Cache methods removed to ensure component isolation
|
||||
// Each viewer now manages its own document lifecycle
|
||||
}
|
||||
Reference in New Issue
Block a user