@embedpdf/engines 2.0.0-next.1 → 2.0.0-next.3

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.
Files changed (76) hide show
  1. package/dist/browser-B5Y-F6il.cjs +2 -0
  2. package/dist/browser-B5Y-F6il.cjs.map +1 -0
  3. package/dist/browser-Cm3DA8l_.js +70 -0
  4. package/dist/browser-Cm3DA8l_.js.map +1 -0
  5. package/dist/{engine-B-RaFU77.js → direct-engine-BZRK27cv.js} +197 -508
  6. package/dist/direct-engine-BZRK27cv.js.map +1 -0
  7. package/dist/direct-engine-CZAhOupl.cjs +2 -0
  8. package/dist/direct-engine-CZAhOupl.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +283 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/converters/browser.d.ts +32 -0
  14. package/dist/lib/converters/index.cjs +1 -1
  15. package/dist/lib/converters/index.cjs.map +1 -1
  16. package/dist/lib/converters/index.d.ts +3 -51
  17. package/dist/lib/converters/index.js +6 -1
  18. package/dist/lib/converters/index.js.map +1 -1
  19. package/dist/lib/converters/node.d.ts +51 -0
  20. package/dist/lib/converters/types.d.ts +6 -3
  21. package/dist/lib/image-encoder/image-encoder-worker.d.ts +24 -0
  22. package/dist/lib/image-encoder/index.d.ts +2 -0
  23. package/dist/lib/image-encoder/worker-pool.d.ts +61 -0
  24. package/dist/lib/orchestrator/index.d.ts +16 -0
  25. package/dist/lib/orchestrator/pdf-engine.d.ts +100 -0
  26. package/dist/lib/orchestrator/pdfium-native-runner.d.ts +65 -0
  27. package/dist/lib/orchestrator/remote-executor.d.ts +94 -0
  28. package/dist/lib/orchestrator/task-queue.d.ts +87 -0
  29. package/dist/lib/pdfium/engine.d.ts +50 -84
  30. package/dist/lib/pdfium/index.cjs +1 -1
  31. package/dist/lib/pdfium/index.cjs.map +1 -1
  32. package/dist/lib/pdfium/index.d.ts +5 -1
  33. package/dist/lib/pdfium/index.js +12 -7
  34. package/dist/lib/pdfium/index.js.map +1 -1
  35. package/dist/lib/pdfium/runner.d.ts +2 -2
  36. package/dist/lib/pdfium/web/direct-engine.cjs +1 -1
  37. package/dist/lib/pdfium/web/direct-engine.cjs.map +1 -1
  38. package/dist/lib/pdfium/web/direct-engine.d.ts +33 -2
  39. package/dist/lib/pdfium/web/direct-engine.js +5 -9
  40. package/dist/lib/pdfium/web/direct-engine.js.map +1 -1
  41. package/dist/lib/pdfium/web/worker-engine.cjs +1 -1
  42. package/dist/lib/pdfium/web/worker-engine.cjs.map +1 -1
  43. package/dist/lib/pdfium/web/worker-engine.d.ts +40 -4
  44. package/dist/lib/pdfium/web/worker-engine.js +415 -9
  45. package/dist/lib/pdfium/web/worker-engine.js.map +1 -1
  46. package/dist/lib/webworker/runner.d.ts +0 -12
  47. package/dist/pdf-engine-CrarIjJ6.cjs +2 -0
  48. package/dist/pdf-engine-CrarIjJ6.cjs.map +1 -0
  49. package/dist/pdf-engine-yZzBqL_l.js +798 -0
  50. package/dist/pdf-engine-yZzBqL_l.js.map +1 -0
  51. package/dist/preact/index.cjs +1 -1
  52. package/dist/preact/index.cjs.map +1 -1
  53. package/dist/preact/index.js +3 -3
  54. package/dist/preact/index.js.map +1 -1
  55. package/dist/react/index.cjs +1 -1
  56. package/dist/react/index.cjs.map +1 -1
  57. package/dist/react/index.js +3 -3
  58. package/dist/react/index.js.map +1 -1
  59. package/dist/shared-preact/hooks/use-pdfium-engine.d.ts +1 -0
  60. package/dist/shared-react/hooks/use-pdfium-engine.d.ts +1 -0
  61. package/dist/svelte/index.cjs +1 -1
  62. package/dist/svelte/index.cjs.map +1 -1
  63. package/dist/svelte/index.js +1 -1
  64. package/dist/svelte/index.js.map +1 -1
  65. package/dist/vue/index.cjs +1 -1
  66. package/dist/vue/index.cjs.map +1 -1
  67. package/dist/vue/index.js +2 -2
  68. package/dist/vue/index.js.map +1 -1
  69. package/package.json +3 -3
  70. package/dist/engine-B-RaFU77.js.map +0 -1
  71. package/dist/engine-CXnLqg_9.cjs +0 -2
  72. package/dist/engine-CXnLqg_9.cjs.map +0 -1
  73. package/dist/index-C3mv9vLs.js +0 -342
  74. package/dist/index-C3mv9vLs.js.map +0 -1
  75. package/dist/index-C4OBhnbs.cjs +0 -2
  76. package/dist/index-C4OBhnbs.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-engine-yZzBqL_l.js","sources":["../src/lib/orchestrator/task-queue.ts","../src/lib/orchestrator/pdf-engine.ts"],"sourcesContent":["import { Task, TaskError, Logger, NoopLogger } from '@embedpdf/models';\n\nconst LOG_SOURCE = 'TaskQueue';\nconst LOG_CATEGORY = 'Queue';\n\nexport enum Priority {\n CRITICAL = 3,\n HIGH = 2,\n MEDIUM = 1,\n LOW = 0,\n}\n\n// ============================================================================\n// Type Utilities\n// ============================================================================\n\n/**\n * Extract result type from Task\n */\nexport type ExtractTaskResult<T> = T extends Task<infer R, any, any> ? R : never;\n\n/**\n * Extract error type from Task\n */\nexport type ExtractTaskError<T> = T extends Task<any, infer D, any> ? D : never;\n\n/**\n * Extract progress type from Task\n */\nexport type ExtractTaskProgress<T> = T extends Task<any, any, infer P> ? P : never;\n\n// ============================================================================\n// Queue Interfaces\n// ============================================================================\n\nexport interface QueuedTask<T extends Task<any, any, any>> {\n id: string;\n priority: Priority;\n meta?: Record<string, unknown>;\n executeFactory: () => T; // Factory function - called when it's time to execute!\n cancelled?: boolean;\n}\n\nexport interface EnqueueOptions {\n priority?: Priority;\n meta?: Record<string, unknown>;\n fifo?: boolean;\n}\n\nexport type TaskComparator = (a: QueuedTask<any>, b: QueuedTask<any>) => number;\nexport type TaskRanker = (task: QueuedTask<any>) => number;\n\nexport interface WorkerTaskQueueOptions {\n concurrency?: number;\n comparator?: TaskComparator;\n ranker?: TaskRanker;\n onIdle?: () => void;\n maxQueueSize?: number;\n autoStart?: boolean;\n logger?: Logger;\n}\n\n// ============================================================================\n// WorkerTaskQueue - Corrected with Deferred Execution\n// ============================================================================\n\nexport class WorkerTaskQueue {\n private queue: QueuedTask<any>[] = [];\n private running = 0;\n private resultTasks = new Map<string, Task<any, any, any>>();\n private logger: Logger;\n private opts: Required<Omit<WorkerTaskQueueOptions, 'comparator' | 'ranker' | 'logger'>> & {\n comparator?: TaskComparator;\n ranker?: TaskRanker;\n };\n\n constructor(options: WorkerTaskQueueOptions = {}) {\n const {\n concurrency = 1,\n comparator,\n ranker,\n onIdle,\n maxQueueSize,\n autoStart = true,\n logger,\n } = options;\n this.logger = logger ?? new NoopLogger();\n this.opts = {\n concurrency: Math.max(1, concurrency),\n comparator,\n ranker,\n onIdle: onIdle ?? (() => {}),\n maxQueueSize: maxQueueSize ?? Number.POSITIVE_INFINITY,\n autoStart,\n };\n }\n\n setComparator(comparator?: TaskComparator): void {\n this.opts.comparator = comparator;\n }\n\n setRanker(ranker?: TaskRanker): void {\n this.opts.ranker = ranker;\n }\n\n size(): number {\n return this.queue.length;\n }\n\n inFlight(): number {\n return this.running;\n }\n\n isIdle(): boolean {\n return this.queue.length === 0 && this.running === 0;\n }\n\n async drain(): Promise<void> {\n if (this.isIdle()) return;\n await new Promise<void>((resolve) => {\n const check = () => {\n if (this.isIdle()) {\n this.offIdle(check);\n resolve();\n }\n };\n this.onIdle(check);\n });\n }\n\n private idleListeners = new Set<() => void>();\n private notifyIdle() {\n if (this.isIdle()) {\n [...this.idleListeners].forEach((fn) => fn());\n this.idleListeners.clear();\n this.opts.onIdle();\n }\n }\n private onIdle(fn: () => void) {\n this.idleListeners.add(fn);\n }\n private offIdle(fn: () => void) {\n this.idleListeners.delete(fn);\n }\n\n /**\n * Enqueue a task factory - with automatic type inference!\n *\n * The factory function is ONLY called when it's the task's turn to execute.\n *\n * Usage:\n * const task = queue.enqueue({\n * execute: () => this.executor.getMetadata(doc), // Factory - not called yet!\n * meta: { operation: 'getMetadata' }\n * }, { priority: Priority.LOW });\n *\n * The returned task has the SAME type as executor.getMetadata() would return!\n */\n enqueue<T extends Task<any, any, any>>(\n taskDef: {\n execute: () => T; // Factory function that returns Task when called!\n meta?: Record<string, unknown>;\n },\n options: EnqueueOptions = {},\n ): T {\n const id = this.generateId();\n const priority = options.priority ?? Priority.MEDIUM;\n\n // Create a proxy task that we return to the user\n // This task bridges to the real task that will be created later\n const resultTask = new Task<\n ExtractTaskResult<T>,\n ExtractTaskError<T>,\n ExtractTaskProgress<T>\n >() as T;\n\n if (this.queue.length >= this.opts.maxQueueSize) {\n const error = new Error('Queue is full (maxQueueSize reached).');\n resultTask.reject(error as any);\n return resultTask;\n }\n\n // Store the result task for bridging\n this.resultTasks.set(id, resultTask);\n\n const queuedTask: QueuedTask<T> = {\n id,\n priority,\n meta: options.meta ?? taskDef.meta,\n executeFactory: taskDef.execute, // Store factory, don't call it yet!\n };\n\n this.queue.push(queuedTask);\n\n this.logger.debug(\n LOG_SOURCE,\n LOG_CATEGORY,\n `Task enqueued: ${id} | Priority: ${priority} | Running: ${this.running} | Queued: ${this.queue.length}`,\n );\n\n // Set up automatic abort handling\n // When result task is aborted externally, remove from queue\n const originalAbort = resultTask.abort.bind(resultTask);\n resultTask.abort = (reason: any) => {\n this.logger.debug(LOG_SOURCE, LOG_CATEGORY, `Task aborted: ${id}`);\n this.cancel(id);\n originalAbort(reason);\n };\n\n if (this.opts.autoStart) this.process(options.fifo === true);\n\n return resultTask;\n }\n\n /**\n * Cancel/remove a task from the queue\n */\n private cancel(taskId: string): void {\n const before = this.queue.length;\n this.queue = this.queue.filter((t) => {\n if (t.id === taskId) {\n t.cancelled = true;\n return false;\n }\n return true;\n });\n\n this.resultTasks.delete(taskId);\n\n if (before !== this.queue.length) {\n this.logger.debug(LOG_SOURCE, LOG_CATEGORY, `Task cancelled and removed: ${taskId}`);\n this.kick();\n }\n }\n\n private kick() {\n queueMicrotask(() => this.process());\n }\n\n private async process(fifo = false): Promise<void> {\n this.logger.debug(\n LOG_SOURCE,\n LOG_CATEGORY,\n `process() called | Running: ${this.running} | Concurrency: ${this.opts.concurrency} | Queued: ${this.queue.length}`,\n );\n\n while (this.running < this.opts.concurrency && this.queue.length > 0) {\n this.logger.debug(\n LOG_SOURCE,\n LOG_CATEGORY,\n `Starting new task | Running: ${this.running} | Queued: ${this.queue.length}`,\n );\n\n if (!fifo) this.sortQueue();\n\n const queuedTask = this.queue.shift()!;\n if (queuedTask.cancelled) {\n this.logger.debug(LOG_SOURCE, LOG_CATEGORY, `Skipping cancelled task: ${queuedTask.id}`);\n continue;\n }\n\n const resultTask = this.resultTasks.get(queuedTask.id);\n if (!resultTask) continue; // Shouldn't happen, but guard anyway.\n\n this.running++;\n\n // NOW call the factory to create the real task!\n (async () => {\n let realTask: Task<any, any, any> | null = null;\n\n try {\n // Call the factory function NOW - this is when execution actually starts\n realTask = queuedTask.executeFactory();\n\n // Guard against null/undefined return from factory\n if (!realTask) {\n throw new Error('Task factory returned null/undefined');\n }\n\n // Bridge the real task to the result task\n realTask.wait(\n (result) => {\n if (resultTask.state.stage === 0 /* Pending */) {\n resultTask.resolve(result);\n }\n },\n (error) => {\n if (resultTask.state.stage === 0 /* Pending */) {\n if (error.type === 'abort') {\n resultTask.abort(error.reason);\n } else {\n resultTask.reject(error.reason);\n }\n }\n },\n );\n\n // Bridge progress\n realTask.onProgress((progress) => {\n resultTask.progress(progress);\n });\n\n // Wait for completion\n await realTask.toPromise();\n } catch (error) {\n // Handle any errors from factory or execution\n if (resultTask.state.stage === 0 /* Pending */) {\n resultTask.reject(error as any);\n }\n } finally {\n this.resultTasks.delete(queuedTask.id);\n this.running--;\n\n this.logger.debug(\n LOG_SOURCE,\n LOG_CATEGORY,\n `Task completed: ${queuedTask.id} | Running: ${this.running} | Queued: ${this.queue.length}`,\n );\n\n if (this.isIdle()) {\n this.notifyIdle();\n } else if (this.queue.length > 0) {\n this.kick();\n }\n }\n })().catch((error) => {\n this.logger.error(\n LOG_SOURCE,\n LOG_CATEGORY,\n 'Unhandled error in task execution wrapper:',\n error,\n );\n this.running = Math.max(0, this.running - 1);\n if (this.isIdle()) {\n this.notifyIdle();\n } else if (this.queue.length > 0) {\n this.kick();\n }\n });\n }\n }\n\n private sortQueue(): void {\n const { comparator, ranker } = this.opts;\n if (comparator) {\n this.queue.sort(comparator);\n return;\n }\n\n const rankCache = new Map<string, number>();\n const getRank = (t: QueuedTask<any>) => {\n if (!ranker) return this.defaultRank(t);\n if (!rankCache.has(t.id)) rankCache.set(t.id, ranker(t));\n return rankCache.get(t.id)!;\n };\n\n this.queue.sort((a, b) => {\n if (a.priority !== b.priority) return b.priority - a.priority;\n const ar = getRank(a);\n const br = getRank(b);\n if (ar !== br) return br - ar;\n return this.extractTime(a.id) - this.extractTime(b.id);\n });\n }\n\n private defaultRank(_task: QueuedTask<any>): number {\n return 0;\n }\n\n private generateId(): string {\n if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n }\n\n private extractTime(id: string): number {\n const t = Number(id.split('-')[0]);\n return Number.isFinite(t) ? t : 0;\n }\n}\n","import {\n BatchProgress,\n Logger,\n NoopLogger,\n PdfEngine as IPdfEngine,\n PdfDocumentObject,\n PdfPageObject,\n PdfTask,\n PdfErrorReason,\n PdfFileUrl,\n PdfFile,\n PdfOpenDocumentUrlOptions,\n PdfOpenDocumentBufferOptions,\n PdfMetadataObject,\n PdfBookmarksObject,\n PdfBookmarkObject,\n PdfRenderPageOptions,\n PdfRenderThumbnailOptions,\n PdfRenderPageAnnotationOptions,\n PdfAnnotationObject,\n PdfTextRectObject,\n PdfSearchAllPagesOptions,\n SearchAllPagesResult,\n PdfPageSearchProgress,\n PdfAnnotationsProgress,\n PdfAttachmentObject,\n PdfAddAttachmentParams,\n PdfWidgetAnnoObject,\n FormFieldValue,\n PdfFlattenPageOptions,\n PdfPageFlattenResult,\n PdfRedactTextOptions,\n Rect,\n PageTextSlice,\n PdfGlyphObject,\n PdfPageGeometry,\n PdfPrintOptions,\n PdfEngineFeature,\n PdfEngineOperation,\n PdfSignatureObject,\n AnnotationCreateContext,\n Task,\n PdfErrorCode,\n SearchResult,\n CompoundTask,\n ImageDataLike,\n IPdfiumExecutor,\n} from '@embedpdf/models';\nimport { WorkerTaskQueue, Priority } from './task-queue';\nimport type { ImageDataConverter } from '../converters/types';\n\n// Re-export for convenience\nexport type { ImageDataConverter } from '../converters/types';\nexport type { ImageDataLike, IPdfiumExecutor, BatchProgress } from '@embedpdf/models';\n\nconst LOG_SOURCE = 'PdfEngine';\nconst LOG_CATEGORY = 'Orchestrator';\n\nexport interface PdfEngineOptions<T> {\n /**\n * Image data converter (for encoding raw image data to Blob/other format)\n */\n imageConverter: ImageDataConverter<T>;\n /**\n * Fetch function for fetching remote URLs\n */\n fetcher?: typeof fetch;\n /**\n * Logger instance\n */\n logger?: Logger;\n}\n\n/**\n * PdfEngine orchestrator\n *\n * This is the \"smart\" layer that:\n * - Implements the PdfEngine interface\n * - Uses WorkerTaskQueue for priority-based task scheduling\n * - Orchestrates complex multi-page operations\n * - Handles image encoding with separate encoder pool\n * - Manages visibility-based task ranking\n */\nexport class PdfEngine<T = Blob> implements IPdfEngine<T> {\n private executor: IPdfiumExecutor;\n private workerQueue: WorkerTaskQueue;\n private logger: Logger;\n private options: PdfEngineOptions<T>;\n\n constructor(executor: IPdfiumExecutor, options: PdfEngineOptions<T>) {\n this.executor = executor;\n this.logger = options.logger ?? new NoopLogger();\n this.options = {\n imageConverter: options.imageConverter,\n fetcher:\n options.fetcher ??\n (typeof fetch !== 'undefined' ? (url, init) => fetch(url, init) : undefined),\n logger: this.logger,\n };\n\n // Create worker queue with single concurrency (PDFium is single-threaded)\n this.workerQueue = new WorkerTaskQueue({\n concurrency: 1,\n autoStart: true,\n logger: this.logger,\n });\n\n this.logger.debug(LOG_SOURCE, LOG_CATEGORY, 'PdfEngine orchestrator created');\n }\n\n /**\n * Split an array into chunks of a given size\n */\n private chunkArray<U>(items: U[], chunkSize: number): U[][] {\n const chunks: U[][] = [];\n for (let i = 0; i < items.length; i += chunkSize) {\n chunks.push(items.slice(i, i + chunkSize));\n }\n return chunks;\n }\n\n // ========== IPdfEngine Implementation ==========\n\n isSupport(feature: PdfEngineFeature): PdfTask<PdfEngineOperation[]> {\n const task = new Task<PdfEngineOperation[], PdfErrorReason>();\n // PDFium supports all features\n task.resolve([\n PdfEngineOperation.Create,\n PdfEngineOperation.Read,\n PdfEngineOperation.Update,\n PdfEngineOperation.Delete,\n ]);\n return task;\n }\n\n initialize(): PdfTask<boolean> {\n const task = new Task<boolean, PdfErrorReason>();\n try {\n this.executor.initialize();\n task.resolve(true);\n } catch (error) {\n task.reject({ code: PdfErrorCode.Unknown, message: String(error) });\n }\n return task;\n }\n\n destroy(): PdfTask<boolean> {\n const task = new Task<boolean, PdfErrorReason>();\n try {\n this.executor.destroy();\n task.resolve(true);\n } catch (error) {\n task.reject({ code: PdfErrorCode.Unknown, message: String(error) });\n }\n return task;\n }\n\n openDocumentUrl(\n file: PdfFileUrl,\n options?: PdfOpenDocumentUrlOptions,\n ): PdfTask<PdfDocumentObject> {\n const task = new Task<PdfDocumentObject, PdfErrorReason>();\n\n // Handle fetch in main thread (not worker!)\n (async () => {\n try {\n if (!this.options.fetcher) {\n throw new Error('Fetcher is not set');\n }\n\n const response = await this.options.fetcher(file.url, options?.requestOptions);\n const arrayBuf = await response.arrayBuffer();\n\n const pdfFile: PdfFile = {\n id: file.id,\n content: arrayBuf,\n };\n\n // Then open in worker\n const doc = await this.openDocumentBuffer(pdfFile, {\n password: options?.password,\n }).toPromise();\n\n task.resolve(doc);\n } catch (error) {\n task.reject({ code: PdfErrorCode.Unknown, message: String(error) });\n }\n })();\n\n return task;\n }\n\n openDocumentBuffer(\n file: PdfFile,\n options?: PdfOpenDocumentBufferOptions,\n ): PdfTask<PdfDocumentObject> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.openDocumentBuffer(file, options),\n meta: { docId: file.id, operation: 'openDocumentBuffer' },\n },\n { priority: Priority.CRITICAL },\n );\n }\n\n getMetadata(doc: PdfDocumentObject): PdfTask<PdfMetadataObject> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getMetadata(doc),\n meta: { docId: doc.id, operation: 'getMetadata' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n setMetadata(doc: PdfDocumentObject, metadata: Partial<PdfMetadataObject>): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.setMetadata(doc, metadata),\n meta: { docId: doc.id, operation: 'setMetadata' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getDocPermissions(doc: PdfDocumentObject): PdfTask<number> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getDocPermissions(doc),\n meta: { docId: doc.id, operation: 'getDocPermissions' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getDocUserPermissions(doc: PdfDocumentObject): PdfTask<number> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getDocUserPermissions(doc),\n meta: { docId: doc.id, operation: 'getDocUserPermissions' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getSignatures(doc: PdfDocumentObject): PdfTask<PdfSignatureObject[]> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getSignatures(doc),\n meta: { docId: doc.id, operation: 'getSignatures' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getBookmarks(doc: PdfDocumentObject): PdfTask<PdfBookmarksObject> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getBookmarks(doc),\n meta: { docId: doc.id, operation: 'getBookmarks' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n setBookmarks(doc: PdfDocumentObject, bookmarks: PdfBookmarkObject[]): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.setBookmarks(doc, bookmarks),\n meta: { docId: doc.id, operation: 'setBookmarks' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n deleteBookmarks(doc: PdfDocumentObject): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.deleteBookmarks(doc),\n meta: { docId: doc.id, operation: 'deleteBookmarks' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n // ========== Rendering with Encoding ==========\n\n renderPage(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n options?: PdfRenderPageOptions,\n ): PdfTask<T> {\n return this.renderWithEncoding(\n () => this.executor.renderPageRaw(doc, page, options),\n options,\n doc.id,\n page.index,\n Priority.CRITICAL,\n );\n }\n\n renderPageRect(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n rect: Rect,\n options?: PdfRenderPageOptions,\n ): PdfTask<T> {\n return this.renderWithEncoding(\n () => this.executor.renderPageRect(doc, page, rect, options),\n options,\n doc.id,\n page.index,\n Priority.HIGH,\n );\n }\n\n renderThumbnail(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n options?: PdfRenderThumbnailOptions,\n ): PdfTask<T> {\n return this.renderWithEncoding(\n () => this.executor.renderThumbnailRaw(doc, page, options),\n options,\n doc.id,\n page.index,\n Priority.MEDIUM,\n );\n }\n\n renderPageAnnotation(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n annotation: PdfAnnotationObject,\n options?: PdfRenderPageAnnotationOptions,\n ): PdfTask<T> {\n return this.renderWithEncoding(\n () => this.executor.renderPageAnnotationRaw(doc, page, annotation, options),\n options,\n doc.id,\n page.index,\n Priority.MEDIUM,\n );\n }\n\n /**\n * Helper to render and encode in two stages with priority queue\n */\n private renderWithEncoding(\n renderFn: () => PdfTask<ImageDataLike>,\n options?: PdfRenderPageOptions | PdfRenderThumbnailOptions | PdfRenderPageAnnotationOptions,\n docId?: string,\n pageIndex?: number,\n priority: Priority = Priority.CRITICAL,\n ): PdfTask<T> {\n const resultTask = new Task<T, PdfErrorReason>();\n\n // Step 1: Add HIGH/MEDIUM priority task to render raw bytes\n const renderHandle = this.workerQueue.enqueue(\n {\n execute: () => renderFn(),\n meta: { docId, pageIndex, operation: 'render' },\n },\n { priority },\n );\n\n // Wire up abort: when resultTask is aborted, also abort the queue task\n const originalAbort = resultTask.abort.bind(resultTask);\n resultTask.abort = (reason) => {\n renderHandle.abort(reason); // Cancel the queue task!\n originalAbort(reason);\n };\n\n renderHandle.wait(\n (rawImageData) => {\n // Check if resultTask was already aborted before encoding\n if (resultTask.state.stage !== 0 /* Pending */) {\n return;\n }\n this.encodeImage(rawImageData, options, resultTask);\n },\n (error) => {\n // Only forward error if resultTask is still pending\n if (resultTask.state.stage === 0 /* Pending */) {\n resultTask.fail(error);\n }\n },\n );\n\n return resultTask;\n }\n\n /**\n * Encode image using encoder pool or inline\n */\n private encodeImage(\n rawImageData: ImageDataLike,\n options: any,\n resultTask: Task<T, PdfErrorReason>,\n ): void {\n const imageType = options?.imageType ?? 'image/webp';\n const quality = options?.quality;\n\n // Convert to plain object for encoding\n const plainImageData = {\n data: new Uint8ClampedArray(rawImageData.data),\n width: rawImageData.width,\n height: rawImageData.height,\n };\n\n this.options\n .imageConverter(() => plainImageData, imageType, quality)\n .then((result) => resultTask.resolve(result))\n .catch((error) => resultTask.reject({ code: PdfErrorCode.Unknown, message: String(error) }));\n }\n\n // ========== Annotations ==========\n\n getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getPageAnnotations(doc, page),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'getPageAnnotations' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n createPageAnnotation<A extends PdfAnnotationObject>(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n annotation: A,\n context?: AnnotationCreateContext<A>,\n ): PdfTask<string> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.createPageAnnotation(doc, page, annotation, context),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'createPageAnnotation' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n updatePageAnnotation(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n annotation: PdfAnnotationObject,\n ): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.updatePageAnnotation(doc, page, annotation),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'updatePageAnnotation' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n removePageAnnotation(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n annotation: PdfAnnotationObject,\n ): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.removePageAnnotation(doc, page, annotation),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'removePageAnnotation' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n /**\n * Get all annotations across all pages\n * Uses batched operations to reduce queue overhead\n */\n getAllAnnotations(\n doc: PdfDocumentObject,\n ): CompoundTask<Record<number, PdfAnnotationObject[]>, PdfErrorReason, PdfAnnotationsProgress> {\n // Chunk pages for batched processing\n const chunks = this.chunkArray(doc.pages, 500);\n\n this.logger.debug(\n LOG_SOURCE,\n LOG_CATEGORY,\n `getAllAnnotations: ${doc.pages.length} pages in ${chunks.length} chunks`,\n );\n\n // Create compound task for result aggregation\n const compound = new CompoundTask<\n Record<number, PdfAnnotationObject[]>,\n PdfErrorReason,\n PdfAnnotationsProgress\n >({\n aggregate: (results) => Object.assign({}, ...results),\n });\n\n // Create one task per chunk and wire up progress forwarding\n chunks.forEach((chunkPages, chunkIndex) => {\n const batchTask = this.workerQueue.enqueue(\n {\n execute: () => this.executor.getAnnotationsBatch(doc, chunkPages),\n meta: { docId: doc.id, operation: 'getAnnotationsBatch', chunkSize: chunkPages.length },\n },\n { priority: Priority.LOW },\n );\n\n // Forward batch progress (per-page) to compound task\n batchTask.onProgress((batchProgress: BatchProgress<PdfAnnotationObject[]>) => {\n compound.progress({\n page: batchProgress.pageIndex,\n result: batchProgress.result,\n });\n });\n\n compound.addChild(batchTask, chunkIndex);\n });\n\n compound.finalize();\n return compound;\n }\n\n getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfTextRectObject[]> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getPageTextRects(doc, page),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'getPageTextRects' },\n },\n {\n priority: Priority.MEDIUM,\n },\n );\n }\n\n // ========== Search ==========\n\n /**\n * Search across all pages\n * Uses batched operations to reduce queue overhead\n */\n searchAllPages(\n doc: PdfDocumentObject,\n keyword: string,\n options?: PdfSearchAllPagesOptions,\n ): PdfTask<SearchAllPagesResult, PdfPageSearchProgress> {\n const flags = Array.isArray(options?.flags)\n ? options.flags.reduce((acc, flag) => acc | flag, 0)\n : (options?.flags ?? 0);\n\n // Chunk pages for batched processing\n const chunks = this.chunkArray(doc.pages, 25);\n\n this.logger.debug(\n LOG_SOURCE,\n LOG_CATEGORY,\n `searchAllPages: ${doc.pages.length} pages in ${chunks.length} chunks`,\n );\n\n // Create compound task for result aggregation\n const compound = new CompoundTask<SearchAllPagesResult, PdfErrorReason, PdfPageSearchProgress>({\n aggregate: (results) => {\n // Merge all batch results into a flat array\n const allResults = results.flatMap((batchResult: Record<number, SearchResult[]>) =>\n Object.values(batchResult).flat(),\n );\n return { results: allResults, total: allResults.length };\n },\n });\n\n // Create one task per chunk and wire up progress forwarding\n chunks.forEach((chunkPages, chunkIndex) => {\n const batchTask = this.workerQueue.enqueue(\n {\n execute: () => this.executor.searchBatch(doc, chunkPages, keyword, flags),\n meta: { docId: doc.id, operation: 'searchBatch', chunkSize: chunkPages.length },\n },\n { priority: Priority.LOW },\n );\n\n // Forward batch progress (per-page) to compound task\n batchTask.onProgress((batchProgress: BatchProgress<SearchResult[]>) => {\n compound.progress({\n page: batchProgress.pageIndex,\n results: batchProgress.result,\n });\n });\n\n compound.addChild(batchTask, chunkIndex);\n });\n\n compound.finalize();\n return compound;\n }\n\n // ========== Attachments ==========\n\n getAttachments(doc: PdfDocumentObject): PdfTask<PdfAttachmentObject[]> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getAttachments(doc),\n meta: { docId: doc.id, operation: 'getAttachments' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n addAttachment(doc: PdfDocumentObject, params: PdfAddAttachmentParams): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.addAttachment(doc, params),\n meta: { docId: doc.id, operation: 'addAttachment' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n removeAttachment(doc: PdfDocumentObject, attachment: PdfAttachmentObject): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.removeAttachment(doc, attachment),\n meta: { docId: doc.id, operation: 'removeAttachment' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n readAttachmentContent(\n doc: PdfDocumentObject,\n attachment: PdfAttachmentObject,\n ): PdfTask<ArrayBuffer> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.readAttachmentContent(doc, attachment),\n meta: { docId: doc.id, operation: 'readAttachmentContent' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n // ========== Forms ==========\n\n setFormFieldValue(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n annotation: PdfWidgetAnnoObject,\n value: FormFieldValue,\n ): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.setFormFieldValue(doc, page, annotation, value),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'setFormFieldValue' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n flattenPage(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n options?: PdfFlattenPageOptions,\n ): PdfTask<PdfPageFlattenResult> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.flattenPage(doc, page, options),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'flattenPage' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n // ========== Text Operations ==========\n\n extractPages(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<ArrayBuffer> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.extractPages(doc, pageIndexes),\n meta: { docId: doc.id, pageIndexes: pageIndexes, operation: 'extractPages' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n extractText(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<string> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.extractText(doc, pageIndexes),\n meta: { docId: doc.id, pageIndexes: pageIndexes, operation: 'extractText' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n redactTextInRects(\n doc: PdfDocumentObject,\n page: PdfPageObject,\n rects: Rect[],\n options?: PdfRedactTextOptions,\n ): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.redactTextInRects(doc, page, rects, options),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'redactTextInRects' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): PdfTask<string[]> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getTextSlices(doc, slices),\n meta: { docId: doc.id, slices: slices, operation: 'getTextSlices' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfGlyphObject[]> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getPageGlyphs(doc, page),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'getPageGlyphs' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n getPageGeometry(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfPageGeometry> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.getPageGeometry(doc, page),\n meta: { docId: doc.id, pageIndex: page.index, operation: 'getPageGeometry' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n // ========== Document Operations ==========\n\n merge(files: PdfFile[]): PdfTask<PdfFile> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.merge(files),\n meta: { docId: files.map((file) => file.id).join(','), operation: 'merge' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n mergePages(mergeConfigs: Array<{ docId: string; pageIndices: number[] }>): PdfTask<PdfFile> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.mergePages(mergeConfigs),\n meta: {\n docId: mergeConfigs.map((config) => config.docId).join(','),\n operation: 'mergePages',\n },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n preparePrintDocument(doc: PdfDocumentObject, options?: PdfPrintOptions): PdfTask<ArrayBuffer> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.preparePrintDocument(doc, options),\n meta: { docId: doc.id, operation: 'preparePrintDocument' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n saveAsCopy(doc: PdfDocumentObject): PdfTask<ArrayBuffer> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.saveAsCopy(doc),\n meta: { docId: doc.id, operation: 'saveAsCopy' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n closeDocument(doc: PdfDocumentObject): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.closeDocument(doc),\n meta: { docId: doc.id, operation: 'closeDocument' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n\n closeAllDocuments(): PdfTask<boolean> {\n return this.workerQueue.enqueue(\n {\n execute: () => this.executor.closeAllDocuments(),\n meta: { operation: 'closeAllDocuments' },\n },\n { priority: Priority.MEDIUM },\n );\n }\n}\n"],"names":["LOG_SOURCE","LOG_CATEGORY","Priority"],"mappings":";AAEA,MAAMA,eAAa;AACnB,MAAMC,iBAAe;AAEd,IAAK,6BAAAC,cAAL;AACLA,YAAAA,UAAA,cAAW,CAAA,IAAX;AACAA,YAAAA,UAAA,UAAO,CAAA,IAAP;AACAA,YAAAA,UAAA,YAAS,CAAA,IAAT;AACAA,YAAAA,UAAA,SAAM,CAAA,IAAN;AAJU,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AA6DL,MAAM,gBAAgB;AAAA,EAU3B,YAAY,UAAkC,IAAI;AATlD,SAAQ,QAA2B,CAAA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,SAAS,OAAA;AAAA,IAAO;AAAA,EAEhC;AAAA,EAEA,oBAAsC;AACpC,WAAO,KAAK,YAAY;AAAA,MACtB;AAAA,QACE,SAAS,MAAM,KAAK,SAAS,kBAAA;AAAA,QAC7B,MAAM,EAAE,WAAW,oBAAA;AAAA,MAAoB;AAAA,MAEzC,EAAE,UAAU,SAAS,OAAA;AAAA,IAAO;AAAA,EAEhC;AACF;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("preact/hooks"),r=require("preact"),t=require("@embedpdf/models"),n=require("preact/jsx-runtime"),i="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.1/dist/pdfium.wasm";const o=r.createContext(void 0);function s(){const r=e.useContext(o);if(void 0===r)throw new Error("useEngineContext must be used within a PdfEngineProvider");return r}exports.PdfEngineProvider=function({children:e,engine:r,isLoading:t,error:i}){const s={engine:r,isLoading:t,error:i};return n.jsx(o.Provider,{value:s,children:e})},exports.useEngine=function(){const{engine:e,error:r}=s();if(r)throw r;return e},exports.useEngineContext=s,exports.usePdfiumEngine=function(r){const{wasmUrl:n=i,worker:o=!0,logger:s}=r??{},[u,c]=e.useState(null),[d,a]=e.useState(!0),[l,p]=e.useState(null),g=e.useRef(null);return e.useEffect(()=>{let e=!1;return(async()=>{try{const{createPdfiumEngine:e}=o?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),r=await e(n,s);g.current=r,r.initialize().wait(()=>{c(r),a(!1)},e=>{p(new Error(e.reason.message)),a(!1)})}catch(r){e||(p(r),a(!1))}})(),()=>{var r,n;e=!0,null==(n=null==(r=g.current)?void 0:r.closeAllDocuments)||n.call(r).wait(()=>{var e,r;null==(r=null==(e=g.current)?void 0:e.destroy)||r.call(e),g.current=null},t.ignore)}},[n,o,s]),{engine:u,isLoading:d,error:l}};
1
+ "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("preact/hooks"),r=require("preact"),t=require("@embedpdf/models"),n=require("preact/jsx-runtime"),i="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.3/dist/pdfium.wasm";const o=r.createContext(void 0);function s(){const r=e.useContext(o);if(void 0===r)throw new Error("useEngineContext must be used within a PdfEngineProvider");return r}exports.PdfEngineProvider=function({children:e,engine:r,isLoading:t,error:i}){const s={engine:r,isLoading:t,error:i};return n.jsx(o.Provider,{value:s,children:e})},exports.useEngine=function(){const{engine:e,error:r}=s();if(r)throw r;return e},exports.useEngineContext=s,exports.usePdfiumEngine=function(r){const{wasmUrl:n=i,worker:o=!0,logger:s,encoderPoolSize:u}=r??{},[c,d]=e.useState(null),[l,a]=e.useState(!0),[g,p]=e.useState(null),f=e.useRef(null);return e.useEffect(()=>{let e=!1;return(async()=>{try{const{createPdfiumEngine:e}=o?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),r=await e(n,{logger:s,encoderPoolSize:u});f.current=r,r.initialize().wait(()=>{d(r),a(!1)},e=>{p(new Error(e.reason.message)),a(!1)})}catch(r){e||(p(r),a(!1))}})(),()=>{var r,n;e=!0,null==(n=null==(r=f.current)?void 0:r.closeAllDocuments)||n.call(r).wait(()=>{var e,r;null==(r=null==(e=f.current)?void 0:e.destroy)||r.call(e),f.current=null},t.ignore)}},[n,o,s]),{engine:c,isLoading:l,error:g}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["defaultWasmUrl","PdfEngineContext","createContext","useEngineContext","contextValue","useContext","Error","children","engine","isLoading","error","Provider","value","config","wasmUrl","worker","logger","setEngine","useState","loading","setLoading","setError","engineRef","useRef","useEffect","cancelled","createPdfiumEngine","import","pdfEngine","current","initialize","wait","e","reason","message","_b","_a","closeAllDocuments","call","destroy","ignore"],"mappings":"uVAGMA,EAAiB,8ECMhB,MAAMC,EAAmBC,EAAAA,mBAAiD,GCD1E,SAASC,IACd,MAAMC,EAAeC,EAAAA,WAAWJ,GAEhC,QAAqB,IAAjBG,EACF,MAAM,IAAIE,MAAM,4DAGlB,OAAOF,CACT,2BCEO,UAA2BG,SAAEA,EAAAC,OAAUA,EAAAC,UAAQA,EAAAC,MAAWA,IAC/D,MAAMN,EAAe,CACnBI,SACAC,YACAC,SAGF,aAAQT,EAAiBU,SAAjB,CAA0BC,MAAOR,EAAeG,YAC1D,oBDJO,WACL,MAAMC,OAAEA,EAAAE,MAAQA,GAAUP,IAE1B,GAAIO,EACF,MAAMA,EAGR,OAAOF,CACT,qDFnBO,SAAyBK,GAC9B,MAAMC,QAAEA,EAAUd,EAAAe,OAAgBA,GAAS,SAAMC,GAAWH,GAAU,CAAA,GAE/DL,EAAQS,GAAaC,EAAAA,SAA2B,OAChDC,EAASC,GAAcF,EAAAA,UAAS,IAChCR,EAAOW,GAAYH,EAAAA,SAAuB,MAC3CI,EAAYC,EAAAA,OAAyB,MAwC3C,OAtCAC,EAAAA,UAAU,KACR,IAAIC,GAAY,EA4BhB,MA1BA,WACE,IACE,MAAMC,mBAAEA,GAAuBX,QACrBY,OAAO,gDACPA,OAAO,0CAEXC,QAAkBF,EAAmBZ,EAASE,GACpDM,EAAUO,QAAUD,EACpBA,EAAUE,aAAaC,KACrB,KACEd,EAAUW,GACVR,GAAW,IAEZY,IACCX,EAAS,IAAIf,MAAM0B,EAAEC,OAAOC,UAC5Bd,GAAW,IAGjB,OAASY,GACFP,IACHJ,EAASW,GACTZ,GAAW,GAEf,CACF,EAxBA,GA0BO,aACLK,GAAY,EACZ,OAAAU,EAAA,OAAAC,EAAAd,EAAUO,cAAV,EAAAO,EAAmBC,oBAAnBF,EAAAG,KAAAF,GAAyCL,KAAK,aAC5C,OAAAI,EAAA,OAAAC,EAAAd,EAAUO,gBAAVO,EAAmBG,UAAnBJ,EAAAG,KAAAF,GACAd,EAAUO,QAAU,MACnBW,EAAAA,UAEJ,CAAC1B,EAASC,EAAQC,IAEd,CAAER,SAAQC,UAAWU,EAAST,QACvC"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n encoderPoolSize?: number;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger, encoderPoolSize } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger, encoderPoolSize });\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["defaultWasmUrl","PdfEngineContext","createContext","useEngineContext","contextValue","useContext","Error","children","engine","isLoading","error","Provider","value","config","wasmUrl","worker","logger","encoderPoolSize","setEngine","useState","loading","setLoading","setError","engineRef","useRef","useEffect","cancelled","createPdfiumEngine","import","pdfEngine","current","initialize","wait","e","reason","message","_b","_a","closeAllDocuments","call","destroy","ignore"],"mappings":"uVAGMA,EAAiB,8ECMhB,MAAMC,EAAmBC,EAAAA,mBAAiD,GCD1E,SAASC,IACd,MAAMC,EAAeC,EAAAA,WAAWJ,GAEhC,QAAqB,IAAjBG,EACF,MAAM,IAAIE,MAAM,4DAGlB,OAAOF,CACT,2BCEO,UAA2BG,SAAEA,EAAAC,OAAUA,EAAAC,UAAQA,EAAAC,MAAWA,IAC/D,MAAMN,EAAe,CACnBI,SACAC,YACAC,SAGF,aAAQT,EAAiBU,SAAjB,CAA0BC,MAAOR,EAAeG,YAC1D,oBDJO,WACL,MAAMC,OAAEA,EAAAE,MAAQA,GAAUP,IAE1B,GAAIO,EACF,MAAMA,EAGR,OAAOF,CACT,qDFlBO,SAAyBK,GAC9B,MAAMC,QAAEA,EAAUd,EAAAe,OAAgBA,GAAS,SAAMC,EAAAC,gBAAQA,GAAoBJ,GAAU,CAAA,GAEhFL,EAAQU,GAAaC,EAAAA,SAA2B,OAChDC,EAASC,GAAcF,EAAAA,UAAS,IAChCT,EAAOY,GAAYH,EAAAA,SAAuB,MAC3CI,EAAYC,EAAAA,OAAyB,MAwC3C,OAtCAC,EAAAA,UAAU,KACR,IAAIC,GAAY,EA4BhB,MA1BA,WACE,IACE,MAAMC,mBAAEA,GAAuBZ,QACrBa,OAAO,gDACPA,OAAO,0CAEXC,QAAkBF,EAAmBb,EAAS,CAAEE,SAAQC,oBAC9DM,EAAUO,QAAUD,EACpBA,EAAUE,aAAaC,KACrB,KACEd,EAAUW,GACVR,GAAW,IAEZY,IACCX,EAAS,IAAIhB,MAAM2B,EAAEC,OAAOC,UAC5Bd,GAAW,IAGjB,OAASY,GACFP,IACHJ,EAASW,GACTZ,GAAW,GAEf,CACF,EAxBA,GA0BO,aACLK,GAAY,EACZ,OAAAU,EAAA,OAAAC,EAAAd,EAAUO,cAAV,EAAAO,EAAmBC,oBAAnBF,EAAAG,KAAAF,GAAyCL,KAAK,aAC5C,OAAAI,EAAA,OAAAC,EAAAd,EAAUO,gBAAVO,EAAmBG,UAAnBJ,EAAAG,KAAAF,GACAd,EAAUO,QAAU,MACnBW,EAAAA,UAEJ,CAAC3B,EAASC,EAAQC,IAEd,CAAER,SAAQC,UAAWW,EAASV,QACvC"}
@@ -2,9 +2,9 @@ import { useState, useRef, useEffect, useContext } from "preact/hooks";
2
2
  import { createContext } from "preact";
3
3
  import { ignore } from "@embedpdf/models";
4
4
  import { jsx } from "preact/jsx-runtime";
5
- const defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.1/dist/pdfium.wasm`;
5
+ const defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.3/dist/pdfium.wasm`;
6
6
  function usePdfiumEngine(config) {
7
- const { wasmUrl = defaultWasmUrl, worker = true, logger } = config ?? {};
7
+ const { wasmUrl = defaultWasmUrl, worker = true, logger, encoderPoolSize } = config ?? {};
8
8
  const [engine, setEngine] = useState(null);
9
9
  const [loading, setLoading] = useState(true);
10
10
  const [error, setError] = useState(null);
@@ -14,7 +14,7 @@ function usePdfiumEngine(config) {
14
14
  (async () => {
15
15
  try {
16
16
  const { createPdfiumEngine } = worker ? await import("@embedpdf/engines/pdfium-worker-engine") : await import("@embedpdf/engines/pdfium-direct-engine");
17
- const pdfEngine = await createPdfiumEngine(wasmUrl, logger);
17
+ const pdfEngine = await createPdfiumEngine(wasmUrl, { logger, encoderPoolSize });
18
18
  engineRef.current = pdfEngine;
19
19
  pdfEngine.initialize().wait(
20
20
  () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["_b","_a"],"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AACxD,QAAM,eAAe,WAAW,gBAAgB;AAEhD,MAAI,iBAAiB,QAAW;AAC9B,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,SAAO;AACT;AAMO,SAAS,YAAY;AAC1B,QAAM,EAAE,QAAQ,MAAA,IAAU,iBAAA;AAE1B,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AAEA,SAAO;AACT;ACZO,SAAS,kBAAkB,EAAE,UAAU,QAAQ,WAAW,SAAiC;AAChG,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,6BAAQ,iBAAiB,UAAjB,EAA0B,OAAO,cAAe,UAAS;AACnE;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n encoderPoolSize?: number;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger, encoderPoolSize } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger, encoderPoolSize });\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["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AAS;ACDnF,SAAS,mBAA0C;AACxD,QAAM,eAAe,WAAW,gBAAgB;AAEhD,MAAI,iBAAiB,QAAW;AAC9B,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,SAAO;AACT;AAMO,SAAS,YAAY;AAC1B,QAAM,EAAE,QAAQ,MAAA,IAAU,iBAAA;AAE1B,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AAEA,SAAO;AACT;ACZO,SAAS,kBAAkB,EAAE,UAAU,QAAQ,WAAW,SAAiC;AAChG,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,6BAAQ,iBAAiB,UAAjB,EAA0B,OAAO,cAAe,UAAS;AACnE;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("@embedpdf/models"),t=require("react/jsx-runtime"),n="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.1/dist/pdfium.wasm";const i=e.createContext(void 0);function o(){const r=e.useContext(i);if(void 0===r)throw new Error("useEngineContext must be used within a PdfEngineProvider");return r}exports.PdfEngineProvider=function({children:e,engine:r,isLoading:n,error:o}){const s={engine:r,isLoading:n,error:o};return t.jsx(i.Provider,{value:s,children:e})},exports.useEngine=function(){const{engine:e,error:r}=o();if(r)throw r;return e},exports.useEngineContext=o,exports.usePdfiumEngine=function(t){const{wasmUrl:i=n,worker:o=!0,logger:s}=t??{},[u,c]=e.useState(null),[d,a]=e.useState(!0),[l,g]=e.useState(null),p=e.useRef(null);return e.useEffect(()=>{let e=!1;return(async()=>{try{const{createPdfiumEngine:e}=o?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),r=await e(i,s);p.current=r,r.initialize().wait(()=>{c(r),a(!1)},e=>{g(new Error(e.reason.message)),a(!1)})}catch(r){e||(g(r),a(!1))}})(),()=>{var t,n;e=!0,null==(n=null==(t=p.current)?void 0:t.closeAllDocuments)||n.call(t).wait(()=>{var e,r;null==(r=null==(e=p.current)?void 0:e.destroy)||r.call(e),p.current=null},r.ignore)}},[i,o,s]),{engine:u,isLoading:d,error:l}};
1
+ "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("@embedpdf/models"),t=require("react/jsx-runtime"),n="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.3/dist/pdfium.wasm";const i=e.createContext(void 0);function o(){const r=e.useContext(i);if(void 0===r)throw new Error("useEngineContext must be used within a PdfEngineProvider");return r}exports.PdfEngineProvider=function({children:e,engine:r,isLoading:n,error:o}){const s={engine:r,isLoading:n,error:o};return t.jsx(i.Provider,{value:s,children:e})},exports.useEngine=function(){const{engine:e,error:r}=o();if(r)throw r;return e},exports.useEngineContext=o,exports.usePdfiumEngine=function(t){const{wasmUrl:i=n,worker:o=!0,logger:s,encoderPoolSize:u}=t??{},[c,d]=e.useState(null),[l,a]=e.useState(!0),[g,p]=e.useState(null),f=e.useRef(null);return e.useEffect(()=>{let e=!1;return(async()=>{try{const{createPdfiumEngine:e}=o?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),r=await e(i,{logger:s,encoderPoolSize:u});f.current=r,r.initialize().wait(()=>{d(r),a(!1)},e=>{p(new Error(e.reason.message)),a(!1)})}catch(r){e||(p(r),a(!1))}})(),()=>{var t,n;e=!0,null==(n=null==(t=f.current)?void 0:t.closeAllDocuments)||n.call(t).wait(()=>{var e,r;null==(r=null==(e=f.current)?void 0:e.destroy)||r.call(e),f.current=null},r.ignore)}},[i,o,s]),{engine:c,isLoading:l,error:g}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["defaultWasmUrl","PdfEngineContext","createContext","useEngineContext","contextValue","useContext","Error","children","engine","isLoading","error","Provider","value","config","wasmUrl","worker","logger","setEngine","useState","loading","setLoading","setError","engineRef","useRef","useEffect","cancelled","createPdfiumEngine","import","pdfEngine","current","initialize","wait","e","reason","message","_b","_a","closeAllDocuments","call","destroy","ignore"],"mappings":"2TAGMA,EAAiB,8ECMhB,MAAMC,EAAmBC,EAAAA,mBAAiD,GCD1E,SAASC,IACd,MAAMC,EAAeC,EAAAA,WAAWJ,GAEhC,QAAqB,IAAjBG,EACF,MAAM,IAAIE,MAAM,4DAGlB,OAAOF,CACT,2BCEO,UAA2BG,SAAEA,EAAAC,OAAUA,EAAAC,UAAQA,EAAAC,MAAWA,IAC/D,MAAMN,EAAe,CACnBI,SACAC,YACAC,SAGF,aAAQT,EAAiBU,SAAjB,CAA0BC,MAAOR,EAAeG,YAC1D,oBDJO,WACL,MAAMC,OAAEA,EAAAE,MAAQA,GAAUP,IAE1B,GAAIO,EACF,MAAMA,EAGR,OAAOF,CACT,qDFnBO,SAAyBK,GAC9B,MAAMC,QAAEA,EAAUd,EAAAe,OAAgBA,GAAS,SAAMC,GAAWH,GAAU,CAAA,GAE/DL,EAAQS,GAAaC,EAAAA,SAA2B,OAChDC,EAASC,GAAcF,EAAAA,UAAS,IAChCR,EAAOW,GAAYH,EAAAA,SAAuB,MAC3CI,EAAYC,EAAAA,OAAyB,MAwC3C,OAtCAC,EAAAA,UAAU,KACR,IAAIC,GAAY,EA4BhB,MA1BA,WACE,IACE,MAAMC,mBAAEA,GAAuBX,QACrBY,OAAO,gDACPA,OAAO,0CAEXC,QAAkBF,EAAmBZ,EAASE,GACpDM,EAAUO,QAAUD,EACpBA,EAAUE,aAAaC,KACrB,KACEd,EAAUW,GACVR,GAAW,IAEZY,IACCX,EAAS,IAAIf,MAAM0B,EAAEC,OAAOC,UAC5Bd,GAAW,IAGjB,OAASY,GACFP,IACHJ,EAASW,GACTZ,GAAW,GAEf,CACF,EAxBA,GA0BO,aACLK,GAAY,EACZ,OAAAU,EAAA,OAAAC,EAAAd,EAAUO,cAAV,EAAAO,EAAmBC,oBAAnBF,EAAAG,KAAAF,GAAyCL,KAAK,aAC5C,OAAAI,EAAA,OAAAC,EAAAd,EAAUO,gBAAVO,EAAmBG,UAAnBJ,EAAAG,KAAAF,GACAd,EAAUO,QAAU,MACnBW,EAAAA,UAEJ,CAAC1B,EAASC,EAAQC,IAEd,CAAER,SAAQC,UAAWU,EAAST,QACvC"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n encoderPoolSize?: number;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger, encoderPoolSize } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger, encoderPoolSize });\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["defaultWasmUrl","PdfEngineContext","createContext","useEngineContext","contextValue","useContext","Error","children","engine","isLoading","error","Provider","value","config","wasmUrl","worker","logger","encoderPoolSize","setEngine","useState","loading","setLoading","setError","engineRef","useRef","useEffect","cancelled","createPdfiumEngine","import","pdfEngine","current","initialize","wait","e","reason","message","_b","_a","closeAllDocuments","call","destroy","ignore"],"mappings":"2TAGMA,EAAiB,8ECMhB,MAAMC,EAAmBC,EAAAA,mBAAiD,GCD1E,SAASC,IACd,MAAMC,EAAeC,EAAAA,WAAWJ,GAEhC,QAAqB,IAAjBG,EACF,MAAM,IAAIE,MAAM,4DAGlB,OAAOF,CACT,2BCEO,UAA2BG,SAAEA,EAAAC,OAAUA,EAAAC,UAAQA,EAAAC,MAAWA,IAC/D,MAAMN,EAAe,CACnBI,SACAC,YACAC,SAGF,aAAQT,EAAiBU,SAAjB,CAA0BC,MAAOR,EAAeG,YAC1D,oBDJO,WACL,MAAMC,OAAEA,EAAAE,MAAQA,GAAUP,IAE1B,GAAIO,EACF,MAAMA,EAGR,OAAOF,CACT,qDFlBO,SAAyBK,GAC9B,MAAMC,QAAEA,EAAUd,EAAAe,OAAgBA,GAAS,SAAMC,EAAAC,gBAAQA,GAAoBJ,GAAU,CAAA,GAEhFL,EAAQU,GAAaC,EAAAA,SAA2B,OAChDC,EAASC,GAAcF,EAAAA,UAAS,IAChCT,EAAOY,GAAYH,EAAAA,SAAuB,MAC3CI,EAAYC,EAAAA,OAAyB,MAwC3C,OAtCAC,EAAAA,UAAU,KACR,IAAIC,GAAY,EA4BhB,MA1BA,WACE,IACE,MAAMC,mBAAEA,GAAuBZ,QACrBa,OAAO,gDACPA,OAAO,0CAEXC,QAAkBF,EAAmBb,EAAS,CAAEE,SAAQC,oBAC9DM,EAAUO,QAAUD,EACpBA,EAAUE,aAAaC,KACrB,KACEd,EAAUW,GACVR,GAAW,IAEZY,IACCX,EAAS,IAAIhB,MAAM2B,EAAEC,OAAOC,UAC5Bd,GAAW,IAGjB,OAASY,GACFP,IACHJ,EAASW,GACTZ,GAAW,GAEf,CACF,EAxBA,GA0BO,aACLK,GAAY,EACZ,OAAAU,EAAA,OAAAC,EAAAd,EAAUO,cAAV,EAAAO,EAAmBC,oBAAnBF,EAAAG,KAAAF,GAAyCL,KAAK,aAC5C,OAAAI,EAAA,OAAAC,EAAAd,EAAUO,gBAAVO,EAAmBG,UAAnBJ,EAAAG,KAAAF,GACAd,EAAUO,QAAU,MACnBW,EAAAA,UAEJ,CAAC3B,EAASC,EAAQC,IAEd,CAAER,SAAQC,UAAWW,EAASV,QACvC"}
@@ -1,9 +1,9 @@
1
1
  import { useState, useRef, useEffect, createContext, useContext } from "react";
2
2
  import { ignore } from "@embedpdf/models";
3
3
  import { jsx } from "react/jsx-runtime";
4
- const defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.1/dist/pdfium.wasm`;
4
+ const defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.3/dist/pdfium.wasm`;
5
5
  function usePdfiumEngine(config) {
6
- const { wasmUrl = defaultWasmUrl, worker = true, logger } = config ?? {};
6
+ const { wasmUrl = defaultWasmUrl, worker = true, logger, encoderPoolSize } = config ?? {};
7
7
  const [engine, setEngine] = useState(null);
8
8
  const [loading, setLoading] = useState(true);
9
9
  const [error, setError] = useState(null);
@@ -13,7 +13,7 @@ function usePdfiumEngine(config) {
13
13
  (async () => {
14
14
  try {
15
15
  const { createPdfiumEngine } = worker ? await import("@embedpdf/engines/pdfium-worker-engine") : await import("@embedpdf/engines/pdfium-direct-engine");
16
- const pdfEngine = await createPdfiumEngine(wasmUrl, logger);
16
+ const pdfEngine = await createPdfiumEngine(wasmUrl, { logger, encoderPoolSize });
17
17
  engineRef.current = pdfEngine;
18
18
  pdfEngine.initialize().wait(
19
19
  () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["_b","_a"],"mappings":";;;AAGA,MAAM,iBAAiB;AAQhB,SAAS,gBAAgB,QAA+B;AAC7D,QAAM,EAAE,UAAU,gBAAgB,SAAS,MAAM,OAAA,IAAW,UAAU,CAAA;AAEtE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA2B,IAAI;AAC3D,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,YAAY,OAAyB,IAAI;AAE/C,YAAU,MAAM;AACd,QAAI,YAAY;AAEhB,KAAC,YAAY;AACX,UAAI;AACF,cAAM,EAAE,mBAAA,IAAuB,SAC3B,MAAM,OAAO,wCAAwC,IACrD,MAAM,OAAO,wCAAwC;AAEzD,cAAM,YAAY,MAAM,mBAAmB,SAAS,MAAM;AAC1D,kBAAU,UAAU;AACpB,kBAAU,aAAa;AAAA,UACrB,MAAM;AACJ,sBAAU,SAAS;AACnB,uBAAW,KAAK;AAAA,UAClB;AAAA,UACA,CAAC,MAAM;AACL,qBAAS,IAAI,MAAM,EAAE,OAAO,OAAO,CAAC;AACpC,uBAAW,KAAK;AAAA,UAClB;AAAA,QAAA;AAAA,MAEJ,SAAS,GAAG;AACV,YAAI,CAAC,WAAW;AACd,mBAAS,CAAU;AACnB,qBAAW,KAAK;AAAA,QAClB;AAAA,MACF;AAAA,IACF,GAAA;AAEA,WAAO,MAAM;;AACX,kBAAY;AACZ,4BAAU,YAAV,mBAAmB,sBAAnB,4BAAyC,KAAK,MAAM;;AAClD,SAAAA,OAAAC,MAAA,UAAU,YAAV,gBAAAA,IAAmB,YAAnB,gBAAAD,IAAA,KAAAC;AACA,kBAAU,UAAU;AAAA,MACtB,GAAG;AAAA,IACL;AAAA,EACF,GAAG,CAAC,SAAS,QAAQ,MAAM,CAAC;AAE5B,SAAO,EAAE,QAAQ,WAAW,SAAS,MAAA;AACvC;ACjDO,MAAM,mBAAmB,cAAiD,MAAS;ACDnF,SAAS,mBAA0C;AACxD,QAAM,eAAe,WAAW,gBAAgB;AAEhD,MAAI,iBAAiB,QAAW;AAC9B,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,SAAO;AACT;AAMO,SAAS,YAAY;AAC1B,QAAM,EAAE,QAAQ,MAAA,IAAU,iBAAA;AAE1B,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AAEA,SAAO;AACT;ACZO,SAAS,kBAAkB,EAAE,UAAU,QAAQ,WAAW,SAAiC;AAChG,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,6BAAQ,iBAAiB,UAAjB,EAA0B,OAAO,cAAe,UAAS;AACnE;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-pdfium-engine.ts","../../src/shared/context/pdf-engine-context.ts","../../src/shared/hooks/use-engine-context.ts","../../src/shared/components/pdf-engine-provider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from '@framework';\nimport { ignore, Logger, PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl = `https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm`;\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n encoderPoolSize?: number;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = defaultWasmUrl, worker = true, logger, encoderPoolSize } = config ?? {};\n\n const [engine, setEngine] = useState<PdfEngine | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const engineRef = useRef<PdfEngine | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger, encoderPoolSize });\n engineRef.current = pdfEngine;\n pdfEngine.initialize().wait(\n () => {\n setEngine(pdfEngine);\n setLoading(false);\n },\n (e) => {\n setError(new Error(e.reason.message));\n setLoading(false);\n },\n );\n } catch (e) {\n if (!cancelled) {\n setError(e as Error);\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef.current?.closeAllDocuments?.().wait(() => {\n engineRef.current?.destroy?.();\n engineRef.current = null;\n }, ignore);\n };\n }, [wasmUrl, worker, logger]);\n\n return { engine, isLoading: loading, error };\n}\n","import { createContext } from '@framework';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport const PdfEngineContext = createContext<PdfEngineContextState | undefined>(undefined);\n","import { useContext } from '@framework';\nimport { PdfEngineContext, PdfEngineContextState } from '../context';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = useContext(PdfEngineContext);\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ReactNode } from '@framework';\nimport { PdfEngineContext } from '../context';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineProviderProps {\n children: ReactNode;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n/**\n * Provider component that makes a PDF engine instance available\n * to all child components via context.\n *\n * This provider is completely engine-agnostic - it accepts any engine\n * and its loading state from the parent component.\n */\nexport function PdfEngineProvider({ children, engine, isLoading, error }: PdfEngineProviderProps) {\n const contextValue = {\n engine,\n isLoading,\n error,\n };\n\n return <PdfEngineContext.Provider value={contextValue}>{children}</PdfEngineContext.Provider>;\n}\n"],"names":["_b","_a"],"mappings":";;;AAGA,MAAM,iBAAiB;AAShB,SAAS,gBAAgB,QAA+B;AAC7D,QAAM,EAAE,UAAU,gBAAgB,SAAS,MAAM,QAAQ,oBAAoB,UAAU,CAAA;AAEvF,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA2B,IAAI;AAC3D,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,YAAY,OAAyB,IAAI;AAE/C,YAAU,MAAM;AACd,QAAI,YAAY;AAEhB,KAAC,YAAY;AACX,UAAI;AACF,cAAM,EAAE,mBAAA,IAAuB,SAC3B,MAAM,OAAO,wCAAwC,IACrD,MAAM,OAAO,wCAAwC;AAEzD,cAAM,YAAY,MAAM,mBAAmB,SAAS,EAAE,QAAQ,iBAAiB;AAC/E,kBAAU,UAAU;AACpB,kBAAU,aAAa;AAAA,UACrB,MAAM;AACJ,sBAAU,SAAS;AACnB,uBAAW,KAAK;AAAA,UAClB;AAAA,UACA,CAAC,MAAM;AACL,qBAAS,IAAI,MAAM,EAAE,OAAO,OAAO,CAAC;AACpC,uBAAW,KAAK;AAAA,UAClB;AAAA,QAAA;AAAA,MAEJ,SAAS,GAAG;AACV,YAAI,CAAC,WAAW;AACd,mBAAS,CAAU;AACnB,qBAAW,KAAK;AAAA,QAClB;AAAA,MACF;AAAA,IACF,GAAA;AAEA,WAAO,MAAM;;AACX,kBAAY;AACZ,4BAAU,YAAV,mBAAmB,sBAAnB,4BAAyC,KAAK,MAAM;;AAClD,SAAAA,OAAAC,MAAA,UAAU,YAAV,gBAAAA,IAAmB,YAAnB,gBAAAD,IAAA,KAAAC;AACA,kBAAU,UAAU;AAAA,MACtB,GAAG;AAAA,IACL;AAAA,EACF,GAAG,CAAC,SAAS,QAAQ,MAAM,CAAC;AAE5B,SAAO,EAAE,QAAQ,WAAW,SAAS,MAAA;AACvC;AClDO,MAAM,mBAAmB,cAAiD,MAAS;ACDnF,SAAS,mBAA0C;AACxD,QAAM,eAAe,WAAW,gBAAgB;AAEhD,MAAI,iBAAiB,QAAW;AAC9B,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,SAAO;AACT;AAMO,SAAS,YAAY;AAC1B,QAAM,EAAE,QAAQ,MAAA,IAAU,iBAAA;AAE1B,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AAEA,SAAO;AACT;ACZO,SAAS,kBAAkB,EAAE,UAAU,QAAQ,WAAW,SAAiC;AAChG,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,6BAAQ,iBAAiB,UAAjB,EAA0B,OAAO,cAAe,UAAS;AACnE;"}
@@ -3,6 +3,7 @@ interface UsePdfiumEngineProps {
3
3
  wasmUrl?: string;
4
4
  worker?: boolean;
5
5
  logger?: Logger;
6
+ encoderPoolSize?: number;
6
7
  }
7
8
  export declare function usePdfiumEngine(config?: UsePdfiumEngineProps): {
8
9
  engine: PdfEngine<Blob> | null;
@@ -3,6 +3,7 @@ interface UsePdfiumEngineProps {
3
3
  wasmUrl?: string;
4
4
  worker?: boolean;
5
5
  logger?: Logger;
6
+ encoderPoolSize?: number;
6
7
  }
7
8
  export declare function usePdfiumEngine(config?: UsePdfiumEngineProps): {
8
9
  engine: PdfEngine<Blob> | null;
@@ -1,2 +1,2 @@
1
- "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),n=require("svelte"),t=require("@embedpdf/models"),r=require("@embedpdf/engines");function i(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}return n.default=e,Object.freeze(n)}require("svelte/internal/disclose-version");const o=i(e),s=Symbol("pdfEngineContext");function u(){const e=n.getContext(s);if(void 0===e)throw new Error("getPdfEngineContext must be used within a PdfEngineProvider");return e}exports.PdfEngineProvider=function(e,t){o.push(t,!0),o.user_effect(()=>{var e;e={engine:t.engine,isLoading:t.isLoading,error:t.error},n.setContext(s,e)});var r=o.comment(),i=o.first_child(r);o.snippet(i,()=>t.children),o.append(e,r),o.pop()},exports.useEngine=function(){const{engine:e,error:n}=u();if(n)throw n;return e},exports.useEngineContext=function(){const e=u();if(void 0===e)throw new Error("useEngineContext must be used within a PdfEngineProvider");return e},exports.usePdfiumEngine=function(e){const{wasmUrl:n=r.DEFAULT_PDFIUM_WASM_URL,worker:i=!0,logger:s}=e??{},u=o.proxy({engine:null,isLoading:!0,error:null});let l=o.state(null);return"undefined"!=typeof window&&o.user_effect(()=>{let e=!1;return(async()=>{try{const{createPdfiumEngine:e}=i?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),t=await e(n,s);o.set(l,t,!0),t.initialize().wait(()=>{u.engine=t,u.isLoading=!1},e=>{u.error=new Error(e.reason.message),u.isLoading=!1})}catch(t){e||(u.error=t,u.isLoading=!1)}})(),()=>{var n,r;e=!0,null==(r=null==(n=o.get(l))?void 0:n.closeAllDocuments)||r.call(n).wait(()=>{var e,n;null==(n=null==(e=o.get(l))?void 0:e.destroy)||n.call(e),o.set(l,null)},t.ignore)}}),u};
1
+ "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),n=require("svelte"),t=require("@embedpdf/models"),r=require("@embedpdf/engines");function i(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}return n.default=e,Object.freeze(n)}require("svelte/internal/disclose-version");const o=i(e),s=Symbol("pdfEngineContext");function l(){const e=n.getContext(s);if(void 0===e)throw new Error("getPdfEngineContext must be used within a PdfEngineProvider");return e}exports.PdfEngineProvider=function(e,t){o.push(t,!0),o.user_effect(()=>{var e;e={engine:t.engine,isLoading:t.isLoading,error:t.error},n.setContext(s,e)});var r=o.comment(),i=o.first_child(r);o.snippet(i,()=>t.children),o.append(e,r),o.pop()},exports.useEngine=function(){const{engine:e,error:n}=l();if(n)throw n;return e},exports.useEngineContext=function(){const e=l();if(void 0===e)throw new Error("useEngineContext must be used within a PdfEngineProvider");return e},exports.usePdfiumEngine=function(e){const{wasmUrl:n=r.DEFAULT_PDFIUM_WASM_URL,worker:i=!0,logger:s}=e??{},l=o.proxy({engine:null,isLoading:!0,error:null});let u=o.state(null);return"undefined"!=typeof window&&o.user_effect(()=>{let e=!1;return(async()=>{try{const{createPdfiumEngine:e}=i?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),t=await e(n,{logger:s});o.set(u,t,!0),t.initialize().wait(()=>{l.engine=t,l.isLoading=!1},e=>{l.error=new Error(e.reason.message),l.isLoading=!1})}catch(t){e||(l.error=t,l.isLoading=!1)}})(),()=>{var n,r;e=!0,null==(r=null==(n=o.get(u))?void 0:n.closeAllDocuments)||r.call(n).wait(()=>{var e,n;null==(n=null==(e=o.get(u))?void 0:e.destroy)||n.call(e),o.set(u,null)},t.ignore)}}),l};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/svelte/context/pdf-engine-context.svelte.ts","../../src/svelte/components/PdfEngineProvider.svelte","../../src/svelte/hooks/use-engine-context.ts","../../src/svelte/hooks/use-pdfium-engine.svelte.ts"],"sourcesContent":["import { getContext, setContext } from 'svelte';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst PDF_ENGINE_CONTEXT_KEY = Symbol('pdfEngineContext');\n\n/**\n * Set the PDF engine context (used by PdfEngineProvider)\n */\nexport function setPdfEngineContext(value: PdfEngineContextState) {\n setContext(PDF_ENGINE_CONTEXT_KEY, value);\n}\n\n/**\n * Get the PDF engine context\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function getPdfEngineContext(): PdfEngineContextState {\n const context = getContext<PdfEngineContextState | undefined>(PDF_ENGINE_CONTEXT_KEY);\n\n if (context === undefined) {\n throw new Error('getPdfEngineContext must be used within a PdfEngineProvider');\n }\n\n return context;\n}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { PdfEngine } from '@embedpdf/models';\n import { setPdfEngineContext } from '../context';\n\n interface Props {\n children: Snippet;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n }\n\n let { children, engine, isLoading, error }: Props = $props();\n\n // Update context reactively whenever props change\n $effect(() => {\n setPdfEngineContext({\n engine,\n isLoading,\n error,\n });\n });\n</script>\n\n{@render children()}\n","import {\n getPdfEngineContext,\n type PdfEngineContextState,\n} from '../context/pdf-engine-context.svelte';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = getPdfEngineContext();\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = getPdfEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ignore, Logger, PdfEngine } from '@embedpdf/models';\nimport { DEFAULT_PDFIUM_WASM_URL } from '@embedpdf/engines';\n\nexport interface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = DEFAULT_PDFIUM_WASM_URL, worker = true, logger } = config ?? {};\n\n // Create a reactive state object\n const state = $state({\n engine: null as PdfEngine | null,\n isLoading: true,\n error: null as Error | null,\n });\n\n let engineRef = $state<PdfEngine | null>(null);\n\n const isBrowser = typeof window !== 'undefined';\n\n if (isBrowser) {\n $effect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n engineRef = pdfEngine;\n\n pdfEngine.initialize().wait(\n () => {\n state.engine = pdfEngine;\n state.isLoading = false;\n },\n (e) => {\n state.error = new Error(e.reason.message);\n state.isLoading = false;\n },\n );\n } catch (e) {\n if (!cancelled) {\n state.error = e as Error;\n state.isLoading = false;\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef?.closeAllDocuments?.().wait(() => {\n engineRef?.destroy?.();\n engineRef = null;\n }, ignore);\n };\n });\n }\n\n // Return the reactive state object directly\n return state;\n}\n"],"names":["PDF_ENGINE_CONTEXT_KEY","Symbol","getPdfEngineContext","context","getContext","Error","$","user_effect","value","engine","$$props","isLoading","error","setContext","contextValue","config","wasmUrl","DEFAULT_PDFIUM_WASM_URL","worker","logger","state","engineRef","window","cancelled","createPdfiumEngine","pdfEngine","set","initialize","wait","e","reason","message","closeAllDocuments","get","destroy","ignore"],"mappings":"oqBASMA,EAAyBC,OAAO,oBAatB,SAAAC,UACRC,EAAUC,EAAAA,WAA8CJ,eAE1DG,EACQ,MAAA,IAAAE,MAAM,sEAGXF,CACT,sDCfEG,EAAAC,YAAO,SDD2BC,ICEb,CACjBC,OAAMC,EAAAD,OACNE,UAASD,EAAAC,UACTC,MAAKF,EAAAE,ODJTC,EAAAA,WAAWb,EAAwBQ,2FCOrC,oBCEO,WACL,MAAMC,OAAEA,EAAAG,MAAQA,GAAUV,IAE1B,GAAIU,EACF,MAAMA,EAGR,OAAOH,CACT,2BAtBO,WACL,MAAMK,EAAeZ,IAErB,QAAqB,IAAjBY,EACF,MAAM,IAAIT,MAAM,4DAGlB,OAAOS,CACT,mCCTgCC,iBACtBC,EAAUC,iCAAyBC,GAAS,EAAAC,OAAMA,GAAWJ,MAG/DK,WACJX,OAAQ,KACRE,WAAW,EACXC,MAAO,OAGL,IAAAS,UAAqC,YAEL,oBAAXC,QAGvBhB,EAAAC,iBACM,IAAAgB,GAAY,uBAIJ,MAAAC,mBAAAA,GAAuBN,eACd,uDACA,0CAEXO,QAAkBD,EAAmBR,EAASG,GACpDb,EAAAoB,IAAAL,EAAYI,GAAA,GAEZA,EAAUE,aAAaC,UAEnBR,EAAMX,OAASgB,EACfL,EAAMT,WAAY,GAEnBkB,IACCT,EAAMR,MAAA,IAAYP,MAAMwB,EAAEC,OAAOC,SACjCX,EAAMT,WAAY,GAGxB,OAASkB,GACFN,IACHH,EAAMR,MAAQiB,EACdT,EAAMT,WAAY,EAEtB,CACF,kBAGEY,GAAY,0BACZF,aAAWW,8BAAsBJ,kBAC/BtB,OAAAA,EAAAA,OAAAA,EAAAA,EAAA2B,IAAAZ,SAAAf,EAAAA,EAAW4B,UAAX5B,EAAAA,KAAAA,GACAA,EAAAoB,IAAAL,EAAY,OACXc,EAAAA,WAMFf,CACT"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/svelte/context/pdf-engine-context.svelte.ts","../../src/svelte/components/PdfEngineProvider.svelte","../../src/svelte/hooks/use-engine-context.ts","../../src/svelte/hooks/use-pdfium-engine.svelte.ts"],"sourcesContent":["import { getContext, setContext } from 'svelte';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst PDF_ENGINE_CONTEXT_KEY = Symbol('pdfEngineContext');\n\n/**\n * Set the PDF engine context (used by PdfEngineProvider)\n */\nexport function setPdfEngineContext(value: PdfEngineContextState) {\n setContext(PDF_ENGINE_CONTEXT_KEY, value);\n}\n\n/**\n * Get the PDF engine context\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function getPdfEngineContext(): PdfEngineContextState {\n const context = getContext<PdfEngineContextState | undefined>(PDF_ENGINE_CONTEXT_KEY);\n\n if (context === undefined) {\n throw new Error('getPdfEngineContext must be used within a PdfEngineProvider');\n }\n\n return context;\n}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { PdfEngine } from '@embedpdf/models';\n import { setPdfEngineContext } from '../context';\n\n interface Props {\n children: Snippet;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n }\n\n let { children, engine, isLoading, error }: Props = $props();\n\n // Update context reactively whenever props change\n $effect(() => {\n setPdfEngineContext({\n engine,\n isLoading,\n error,\n });\n });\n</script>\n\n{@render children()}\n","import {\n getPdfEngineContext,\n type PdfEngineContextState,\n} from '../context/pdf-engine-context.svelte';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = getPdfEngineContext();\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = getPdfEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ignore, Logger, PdfEngine } from '@embedpdf/models';\nimport { DEFAULT_PDFIUM_WASM_URL } from '@embedpdf/engines';\n\nexport interface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = DEFAULT_PDFIUM_WASM_URL, worker = true, logger } = config ?? {};\n\n // Create a reactive state object\n const state = $state({\n engine: null as PdfEngine | null,\n isLoading: true,\n error: null as Error | null,\n });\n\n let engineRef = $state<PdfEngine | null>(null);\n\n const isBrowser = typeof window !== 'undefined';\n\n if (isBrowser) {\n $effect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger });\n engineRef = pdfEngine;\n\n pdfEngine.initialize().wait(\n () => {\n state.engine = pdfEngine;\n state.isLoading = false;\n },\n (e) => {\n state.error = new Error(e.reason.message);\n state.isLoading = false;\n },\n );\n } catch (e) {\n if (!cancelled) {\n state.error = e as Error;\n state.isLoading = false;\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef?.closeAllDocuments?.().wait(() => {\n engineRef?.destroy?.();\n engineRef = null;\n }, ignore);\n };\n });\n }\n\n // Return the reactive state object directly\n return state;\n}\n"],"names":["PDF_ENGINE_CONTEXT_KEY","Symbol","getPdfEngineContext","context","getContext","Error","$","user_effect","value","engine","$$props","isLoading","error","setContext","contextValue","config","wasmUrl","DEFAULT_PDFIUM_WASM_URL","worker","logger","state","engineRef","window","cancelled","createPdfiumEngine","pdfEngine","set","initialize","wait","e","reason","message","closeAllDocuments","get","destroy","ignore"],"mappings":"oqBASMA,EAAyBC,OAAO,oBAatB,SAAAC,UACRC,EAAUC,EAAAA,WAA8CJ,eAE1DG,EACQ,MAAA,IAAAE,MAAM,sEAGXF,CACT,sDCfEG,EAAAC,YAAO,SDD2BC,ICEb,CACjBC,OAAMC,EAAAD,OACNE,UAASD,EAAAC,UACTC,MAAKF,EAAAE,ODJTC,EAAAA,WAAWb,EAAwBQ,2FCOrC,oBCEO,WACL,MAAMC,OAAEA,EAAAG,MAAQA,GAAUV,IAE1B,GAAIU,EACF,MAAMA,EAGR,OAAOH,CACT,2BAtBO,WACL,MAAMK,EAAeZ,IAErB,QAAqB,IAAjBY,EACF,MAAM,IAAIT,MAAM,4DAGlB,OAAOS,CACT,mCCTgCC,iBACtBC,EAAUC,iCAAyBC,GAAS,EAAAC,OAAMA,GAAWJ,MAG/DK,WACJX,OAAQ,KACRE,WAAW,EACXC,MAAO,OAGL,IAAAS,UAAqC,YAEL,oBAAXC,QAGvBhB,EAAAC,iBACM,IAAAgB,GAAY,uBAIJ,MAAAC,mBAAAA,GAAuBN,eACd,uDACA,0CAEXO,QAAkBD,EAAmBR,GAAWG,WACtDb,EAAAoB,IAAAL,EAAYI,GAAA,GAEZA,EAAUE,aAAaC,UAEnBR,EAAMX,OAASgB,EACfL,EAAMT,WAAY,GAEnBkB,IACCT,EAAMR,MAAA,IAAYP,MAAMwB,EAAEC,OAAOC,SACjCX,EAAMT,WAAY,GAGxB,OAASkB,GACFN,IACHH,EAAMR,MAAQiB,EACdT,EAAMT,WAAY,EAEtB,CACF,kBAGEY,GAAY,0BACZF,aAAWW,8BAAsBJ,kBAC/BtB,OAAAA,EAAAA,OAAAA,EAAAA,EAAA2B,IAAAZ,SAAAf,EAAAA,EAAW4B,UAAX5B,EAAAA,KAAAA,GACAA,EAAAoB,IAAAL,EAAY,OACXc,EAAAA,WAMFf,CACT"}
@@ -39,7 +39,7 @@ function usePdfiumEngine(config) {
39
39
  (async () => {
40
40
  try {
41
41
  const { createPdfiumEngine } = worker ? await import("@embedpdf/engines/pdfium-worker-engine") : await import("@embedpdf/engines/pdfium-direct-engine");
42
- const pdfEngine = await createPdfiumEngine(wasmUrl, logger);
42
+ const pdfEngine = await createPdfiumEngine(wasmUrl, { logger });
43
43
  $.set(engineRef, pdfEngine, true);
44
44
  pdfEngine.initialize().wait(
45
45
  () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/context/pdf-engine-context.svelte.ts","../../src/svelte/hooks/use-engine-context.ts","../../src/svelte/hooks/use-pdfium-engine.svelte.ts","../../src/svelte/components/PdfEngineProvider.svelte"],"sourcesContent":["import { getContext, setContext } from 'svelte';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst PDF_ENGINE_CONTEXT_KEY = Symbol('pdfEngineContext');\n\n/**\n * Set the PDF engine context (used by PdfEngineProvider)\n */\nexport function setPdfEngineContext(value: PdfEngineContextState) {\n setContext(PDF_ENGINE_CONTEXT_KEY, value);\n}\n\n/**\n * Get the PDF engine context\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function getPdfEngineContext(): PdfEngineContextState {\n const context = getContext<PdfEngineContextState | undefined>(PDF_ENGINE_CONTEXT_KEY);\n\n if (context === undefined) {\n throw new Error('getPdfEngineContext must be used within a PdfEngineProvider');\n }\n\n return context;\n}\n","import {\n getPdfEngineContext,\n type PdfEngineContextState,\n} from '../context/pdf-engine-context.svelte';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = getPdfEngineContext();\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = getPdfEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ignore, Logger, PdfEngine } from '@embedpdf/models';\nimport { DEFAULT_PDFIUM_WASM_URL } from '@embedpdf/engines';\n\nexport interface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = DEFAULT_PDFIUM_WASM_URL, worker = true, logger } = config ?? {};\n\n // Create a reactive state object\n const state = $state({\n engine: null as PdfEngine | null,\n isLoading: true,\n error: null as Error | null,\n });\n\n let engineRef = $state<PdfEngine | null>(null);\n\n const isBrowser = typeof window !== 'undefined';\n\n if (isBrowser) {\n $effect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n engineRef = pdfEngine;\n\n pdfEngine.initialize().wait(\n () => {\n state.engine = pdfEngine;\n state.isLoading = false;\n },\n (e) => {\n state.error = new Error(e.reason.message);\n state.isLoading = false;\n },\n );\n } catch (e) {\n if (!cancelled) {\n state.error = e as Error;\n state.isLoading = false;\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef?.closeAllDocuments?.().wait(() => {\n engineRef?.destroy?.();\n engineRef = null;\n }, ignore);\n };\n });\n }\n\n // Return the reactive state object directly\n return state;\n}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { PdfEngine } from '@embedpdf/models';\n import { setPdfEngineContext } from '../context';\n\n interface Props {\n children: Snippet;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n }\n\n let { children, engine, isLoading, error }: Props = $props();\n\n // Update context reactively whenever props change\n $effect(() => {\n setPdfEngineContext({\n engine,\n isLoading,\n error,\n });\n });\n</script>\n\n{@render children()}\n"],"names":["_b","_a"],"mappings":";;;;;MASM,yBAAyB,OAAO,kBAAkB;SAKxC,oBAAoB,OAA8B;AAChE,aAAW,wBAAwB,KAAK;AAC1C;AAMgB,SAAA,sBAA6C;QACrD,UAAU,WAA8C,sBAAsB;MAEhF,oBAAuB;AACf,UAAA,IAAA,MAAM,6DAA6D;AAAA,EAC/E;SAEO;AACT;ACpBO,SAAS,mBAA0C;AACxD,QAAM,eAAe,oBAAA;AAErB,MAAI,iBAAiB,QAAW;AAC9B,UAAM,IAAI,MAAM,0DAA0D;AA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AET,CAAC;;;;;;AACH;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/context/pdf-engine-context.svelte.ts","../../src/svelte/hooks/use-engine-context.ts","../../src/svelte/hooks/use-pdfium-engine.svelte.ts","../../src/svelte/components/PdfEngineProvider.svelte"],"sourcesContent":["import { getContext, setContext } from 'svelte';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst PDF_ENGINE_CONTEXT_KEY = Symbol('pdfEngineContext');\n\n/**\n * Set the PDF engine context (used by PdfEngineProvider)\n */\nexport function setPdfEngineContext(value: PdfEngineContextState) {\n setContext(PDF_ENGINE_CONTEXT_KEY, value);\n}\n\n/**\n * Get the PDF engine context\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function getPdfEngineContext(): PdfEngineContextState {\n const context = getContext<PdfEngineContextState | undefined>(PDF_ENGINE_CONTEXT_KEY);\n\n if (context === undefined) {\n throw new Error('getPdfEngineContext must be used within a PdfEngineProvider');\n }\n\n return context;\n}\n","import {\n getPdfEngineContext,\n type PdfEngineContextState,\n} from '../context/pdf-engine-context.svelte';\n\n/**\n * Hook to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = getPdfEngineContext();\n\n if (contextValue === undefined) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Hook to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = getPdfEngineContext();\n\n if (error) {\n throw error;\n }\n\n return engine;\n}\n","import { ignore, Logger, PdfEngine } from '@embedpdf/models';\nimport { DEFAULT_PDFIUM_WASM_URL } from '@embedpdf/engines';\n\nexport interface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\nexport function usePdfiumEngine(config?: UsePdfiumEngineProps) {\n const { wasmUrl = DEFAULT_PDFIUM_WASM_URL, worker = true, logger } = config ?? {};\n\n // Create a reactive state object\n const state = $state({\n engine: null as PdfEngine | null,\n isLoading: true,\n error: null as Error | null,\n });\n\n let engineRef = $state<PdfEngine | null>(null);\n\n const isBrowser = typeof window !== 'undefined';\n\n if (isBrowser) {\n $effect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger });\n engineRef = pdfEngine;\n\n pdfEngine.initialize().wait(\n () => {\n state.engine = pdfEngine;\n state.isLoading = false;\n },\n (e) => {\n state.error = new Error(e.reason.message);\n state.isLoading = false;\n },\n );\n } catch (e) {\n if (!cancelled) {\n state.error = e as Error;\n state.isLoading = false;\n }\n }\n })();\n\n return () => {\n cancelled = true;\n engineRef?.closeAllDocuments?.().wait(() => {\n engineRef?.destroy?.();\n engineRef = null;\n }, ignore);\n };\n });\n }\n\n // Return the reactive state object directly\n return state;\n}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { PdfEngine } from '@embedpdf/models';\n import { setPdfEngineContext } from '../context';\n\n interface Props {\n children: Snippet;\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n }\n\n let { children, engine, isLoading, error }: Props = $props();\n\n // Update context reactively whenever props change\n $effect(() => {\n setPdfEngineContext({\n engine,\n isLoading,\n error,\n });\n });\n</script>\n\n{@render children()}\n"],"names":["_b","_a"],"mappings":";;;;;MASM,yBAAyB,OAAO,kBAAkB;SAKxC,oBAAoB,OAA8B;AAChE,aAAW,wBAAwB,KAAK;AAC1C;AAMgB,SAAA,sBAA6C;QACrD,UAAU,WAA8C,sBAAsB;MAEhF,oBAAuB;AACf,UAAA,IAAA,MAAM,6DAA6D;AAAA,EAC/E;SAEO;AACT;ACpBO,SAAS,mBAA0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;AAAA,MACjB,QAAM,QAAA;AAAA,MACN,WAAS,QAAA;AAAA,MACT,OAAK,QAAA;AAAA;EAET,CAAC;;;;;;AACH;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),n=require("@embedpdf/models"),r=Symbol("pdfEngineKey");function t(){const n=e.inject(r);if(!n)throw new Error("useEngineContext must be used within a PdfEngineProvider");return n}const o="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.1/dist/pdfium.wasm";const i=e.defineComponent({__name:"pdf-engine-provider",props:{engine:{},isLoading:{type:Boolean},error:{}},setup(n){const t=n,{engine:o,isLoading:i,error:u}=e.toRefs(t);return e.provide(r,{engine:o,isLoading:i,error:u}),(n,r)=>e.renderSlot(n.$slots,"default")}});exports.PdfEngineProvider=i,exports.useEngine=function(){const{engine:e,error:n}=t();if(n.value)throw n.value;return e},exports.useEngineContext=t,exports.usePdfiumEngine=function(r={}){const{wasmUrl:t=o,worker:i=!0,logger:u}=r,s=e.ref(null),a=e.ref(!0),l=e.ref(null);async function d(){try{const{createPdfiumEngine:e}=i?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),n=await e(t,u);n.initialize().wait(()=>{a.value=!1,s.value=n},e=>{l.value=new Error(e.reason.message),a.value=!1}),a.value=!1}catch(e){l.value=e,a.value=!1}}function c(){var e,r;null==(r=null==(e=s.value)?void 0:e.closeAllDocuments)||r.call(e).wait(()=>{var e,n;null==(n=null==(e=s.value)?void 0:e.destroy)||n.call(e),s.value=null},n.ignore)}return e.onMounted(d),e.onBeforeUnmount(c),e.watch(()=>[t,i,u],()=>{c(),d()}),{engine:s,isLoading:a,error:l}};
1
+ "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),n=require("@embedpdf/models"),r=Symbol("pdfEngineKey");function t(){const n=e.inject(r);if(!n)throw new Error("useEngineContext must be used within a PdfEngineProvider");return n}const o="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.3/dist/pdfium.wasm";const i=e.defineComponent({__name:"pdf-engine-provider",props:{engine:{},isLoading:{type:Boolean},error:{}},setup(n){const t=n,{engine:o,isLoading:i,error:u}=e.toRefs(t);return e.provide(r,{engine:o,isLoading:i,error:u}),(n,r)=>e.renderSlot(n.$slots,"default")}});exports.PdfEngineProvider=i,exports.useEngine=function(){const{engine:e,error:n}=t();if(n.value)throw n.value;return e},exports.useEngineContext=t,exports.usePdfiumEngine=function(r={}){const{wasmUrl:t=o,worker:i=!0,logger:u}=r,s=e.ref(null),l=e.ref(!0),a=e.ref(null);async function d(){try{const{createPdfiumEngine:e}=i?await import("@embedpdf/engines/pdfium-worker-engine"):await import("@embedpdf/engines/pdfium-direct-engine"),n=await e(t,{logger:u});n.initialize().wait(()=>{l.value=!1,s.value=n},e=>{a.value=new Error(e.reason.message),l.value=!1}),l.value=!1}catch(e){a.value=e,l.value=!1}}function c(){var e,r;null==(r=null==(e=s.value)?void 0:e.closeAllDocuments)||r.call(e).wait(()=>{var e,n;null==(n=null==(e=s.value)?void 0:e.destroy)||n.call(e),s.value=null},n.ignore)}return e.onMounted(d),e.onBeforeUnmount(c),e.watch(()=>[t,i,u],()=>{c(),d()}),{engine:s,isLoading:l,error:a}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/vue/context/pdf-engine-context.ts","../../src/vue/composables/use-engine-context.ts","../../src/vue/composables/use-pdfium-engine.ts","../../src/vue/components/pdf-engine-provider.vue"],"sourcesContent":["import { InjectionKey, Ref } from 'vue';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\nexport const pdfEngineKey: InjectionKey<PdfEngineContextState> = Symbol('pdfEngineKey');\n","import { inject } from 'vue';\nimport { pdfEngineKey, PdfEngineContextState } from '../context/pdf-engine-context';\n\n/**\n * Composable to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = inject(pdfEngineKey);\n\n if (!contextValue) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Composable to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error.value) {\n throw error.value;\n }\n\n return engine;\n}\n","import { ref, onMounted, onBeforeUnmount, watch, Ref } from 'vue';\nimport { ignore, type Logger, type PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl =\n 'https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm';\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\ninterface UsePdfiumEngineResult {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\n/**\n * Vue composable that loads a PdfiumEngine (worker or direct)\n * and keeps its lifetime tied to the component.\n */\nexport function usePdfiumEngine(props: UsePdfiumEngineProps = {}): UsePdfiumEngineResult {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = props;\n\n const engine = ref<PdfEngine | null>(null);\n const isLoading = ref(true);\n const error = ref<Error | null>(null);\n\n /* create / destroy tied to component lifecycle ----------------- */\n onMounted(loadEngine);\n onBeforeUnmount(destroyEngine);\n\n /* re‑load if reactive props change ----------------------------- */\n watch(\n () => [wasmUrl, worker, logger] as const,\n () => {\n destroyEngine();\n loadEngine();\n },\n );\n\n async function loadEngine() {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n pdfEngine.initialize().wait(\n () => {\n isLoading.value = false;\n engine.value = pdfEngine;\n },\n (e) => {\n error.value = new Error(e.reason.message);\n isLoading.value = false;\n },\n );\n isLoading.value = false;\n } catch (e) {\n error.value = e as Error;\n isLoading.value = false;\n }\n }\n\n function destroyEngine() {\n engine.value?.closeAllDocuments?.().wait(() => {\n engine.value?.destroy?.();\n engine.value = null;\n }, ignore);\n }\n\n return { engine, isLoading, error };\n}\n","<script setup lang=\"ts\">\nimport { provide, toRefs } from 'vue';\nimport { pdfEngineKey } from '../context/pdf-engine-context';\nimport type { PdfEngine } from '@embedpdf/models';\n\ninterface Props {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst props = defineProps<Props>();\n\n// Convert props to refs and provide them\nconst { engine, isLoading, error } = toRefs(props);\n\nprovide(pdfEngineKey, {\n engine,\n isLoading,\n error,\n});\n</script>\n\n<template>\n <slot />\n</template>\n"],"names":["pdfEngineKey","Symbol","useEngineContext","contextValue","inject","Error","defaultWasmUrl","props","__props","engine","isLoading","error","toRefs","provide","_renderSlot","_ctx","$slots","value","wasmUrl","worker","logger","ref","async","loadEngine","createPdfiumEngine","import","pdfEngine","initialize","wait","e","reason","message","destroyEngine","_b","_a","closeAllDocuments","call","destroy","ignore","onMounted","onBeforeUnmount","watch"],"mappings":"0RASaA,EAAoDC,OAAO,gBCDjE,SAASC,IACd,MAAMC,EAAeC,EAAAA,OAAOJ,GAE5B,IAAKG,EACH,MAAM,IAAIE,MAAM,4DAGlB,OAAOF,CACT,CCbA,MAAMG,EACJ,mMCOF,MAAMC,EAAQC,GAGRC,OAAEA,EAAAC,UAAQA,EAAAC,MAAWA,GAAUC,EAAAA,OAAOL,UAE5CM,EAAAA,QAAQb,EAAc,CACpBS,SACAC,YACAC,iBAKAG,aAAQC,EAAAC,OAAA,4DFFH,WACL,MAAMP,OAAEA,EAAAE,MAAQA,GAAUT,IAE1B,GAAIS,EAAMM,MACR,MAAMN,EAAMM,MAGd,OAAOR,CACT,qDCRO,SAAyBF,EAA8B,IAC5D,MAAMW,QAAEA,EAAUZ,EAAAa,OAAgBA,GAAS,EAAAC,OAAMA,GAAWb,EAEtDE,EAASY,EAAAA,IAAsB,MAC/BX,EAAYW,EAAAA,KAAI,GAChBV,EAAQU,EAAAA,IAAkB,MAehCC,eAAeC,IACb,IACE,MAAMC,mBAAEA,GAAuBL,QACrBM,OAAO,gDACPA,OAAO,0CAEXC,QAAkBF,EAAmBN,EAASE,GACpDM,EAAUC,aAAaC,KACrB,KACElB,EAAUO,OAAQ,EAClBR,EAAOQ,MAAQS,GAEhBG,IACClB,EAAMM,MAAQ,IAAIZ,MAAMwB,EAAEC,OAAOC,SACjCrB,EAAUO,OAAQ,IAGtBP,EAAUO,OAAQ,CACpB,OAASY,GACPlB,EAAMM,MAAQY,EACdnB,EAAUO,OAAQ,CACpB,CACF,CAEA,SAASe,YACP,OAAAC,EAAA,OAAAC,EAAAzB,EAAOQ,YAAP,EAAAiB,EAAcC,oBAAdF,EAAAG,KAAAF,GAAoCN,KAAK,aACvC,OAAAK,EAAA,OAAAC,EAAAzB,EAAOQ,cAAPiB,EAAcG,UAAdJ,EAAAG,KAAAF,GACAzB,EAAOQ,MAAQ,MACdqB,EAAAA,OACL,CAEA,OA3CAC,EAAAA,UAAUhB,GACViB,EAAAA,gBAAgBR,GAGhBS,EAAAA,MACE,IAAM,CAACvB,EAASC,EAAQC,GACxB,KACEY,IACAT,MAmCG,CAAEd,SAAQC,YAAWC,QAC9B"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/context/pdf-engine-context.ts","../../src/vue/composables/use-engine-context.ts","../../src/vue/composables/use-pdfium-engine.ts","../../src/vue/components/pdf-engine-provider.vue"],"sourcesContent":["import { InjectionKey, Ref } from 'vue';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\nexport const pdfEngineKey: InjectionKey<PdfEngineContextState> = Symbol('pdfEngineKey');\n","import { inject } from 'vue';\nimport { pdfEngineKey, PdfEngineContextState } from '../context/pdf-engine-context';\n\n/**\n * Composable to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = inject(pdfEngineKey);\n\n if (!contextValue) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Composable to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error.value) {\n throw error.value;\n }\n\n return engine;\n}\n","import { ref, onMounted, onBeforeUnmount, watch, Ref } from 'vue';\nimport { ignore, type Logger, type PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl =\n 'https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm';\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\ninterface UsePdfiumEngineResult {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\n/**\n * Vue composable that loads a PdfiumEngine (worker or direct)\n * and keeps its lifetime tied to the component.\n */\nexport function usePdfiumEngine(props: UsePdfiumEngineProps = {}): UsePdfiumEngineResult {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = props;\n\n const engine = ref<PdfEngine | null>(null);\n const isLoading = ref(true);\n const error = ref<Error | null>(null);\n\n /* create / destroy tied to component lifecycle ----------------- */\n onMounted(loadEngine);\n onBeforeUnmount(destroyEngine);\n\n /* re‑load if reactive props change ----------------------------- */\n watch(\n () => [wasmUrl, worker, logger] as const,\n () => {\n destroyEngine();\n loadEngine();\n },\n );\n\n async function loadEngine() {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger });\n pdfEngine.initialize().wait(\n () => {\n isLoading.value = false;\n engine.value = pdfEngine;\n },\n (e) => {\n error.value = new Error(e.reason.message);\n isLoading.value = false;\n },\n );\n isLoading.value = false;\n } catch (e) {\n error.value = e as Error;\n isLoading.value = false;\n }\n }\n\n function destroyEngine() {\n engine.value?.closeAllDocuments?.().wait(() => {\n engine.value?.destroy?.();\n engine.value = null;\n }, ignore);\n }\n\n return { engine, isLoading, error };\n}\n","<script setup lang=\"ts\">\nimport { provide, toRefs } from 'vue';\nimport { pdfEngineKey } from '../context/pdf-engine-context';\nimport type { PdfEngine } from '@embedpdf/models';\n\ninterface Props {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst props = defineProps<Props>();\n\n// Convert props to refs and provide them\nconst { engine, isLoading, error } = toRefs(props);\n\nprovide(pdfEngineKey, {\n engine,\n isLoading,\n error,\n});\n</script>\n\n<template>\n <slot />\n</template>\n"],"names":["pdfEngineKey","Symbol","useEngineContext","contextValue","inject","Error","defaultWasmUrl","props","__props","engine","isLoading","error","toRefs","provide","_renderSlot","_ctx","$slots","value","wasmUrl","worker","logger","ref","async","loadEngine","createPdfiumEngine","import","pdfEngine","initialize","wait","e","reason","message","destroyEngine","_b","_a","closeAllDocuments","call","destroy","ignore","onMounted","onBeforeUnmount","watch"],"mappings":"0RASaA,EAAoDC,OAAO,gBCDjE,SAASC,IACd,MAAMC,EAAeC,EAAAA,OAAOJ,GAE5B,IAAKG,EACH,MAAM,IAAIE,MAAM,4DAGlB,OAAOF,CACT,CCbA,MAAMG,EACJ,mMCOF,MAAMC,EAAQC,GAGRC,OAAE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  return engine;
17
17
  }
18
- const defaultWasmUrl = "https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.1/dist/pdfium.wasm";
18
+ const defaultWasmUrl = "https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.0-next.3/dist/pdfium.wasm";
19
19
  function usePdfiumEngine(props = {}) {
20
20
  const { wasmUrl = defaultWasmUrl, worker = true, logger } = props;
21
21
  const engine = ref(null);
@@ -33,7 +33,7 @@ function usePdfiumEngine(props = {}) {
33
33
  async function loadEngine() {
34
34
  try {
35
35
  const { createPdfiumEngine } = worker ? await import("@embedpdf/engines/pdfium-worker-engine") : await import("@embedpdf/engines/pdfium-direct-engine");
36
- const pdfEngine = await createPdfiumEngine(wasmUrl, logger);
36
+ const pdfEngine = await createPdfiumEngine(wasmUrl, { logger });
37
37
  pdfEngine.initialize().wait(
38
38
  () => {
39
39
  isLoading.value = false;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/vue/context/pdf-engine-context.ts","../../src/vue/composables/use-engine-context.ts","../../src/vue/composables/use-pdfium-engine.ts","../../src/vue/components/pdf-engine-provider.vue"],"sourcesContent":["import { InjectionKey, Ref } from 'vue';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\nexport const pdfEngineKey: InjectionKey<PdfEngineContextState> = Symbol('pdfEngineKey');\n","import { inject } from 'vue';\nimport { pdfEngineKey, PdfEngineContextState } from '../context/pdf-engine-context';\n\n/**\n * Composable to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = inject(pdfEngineKey);\n\n if (!contextValue) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Composable to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error.value) {\n throw error.value;\n }\n\n return engine;\n}\n","import { ref, onMounted, onBeforeUnmount, watch, Ref } from 'vue';\nimport { ignore, type Logger, type PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl =\n 'https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm';\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\ninterface UsePdfiumEngineResult {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\n/**\n * Vue composable that loads a PdfiumEngine (worker or direct)\n * and keeps its lifetime tied to the component.\n */\nexport function usePdfiumEngine(props: UsePdfiumEngineProps = {}): UsePdfiumEngineResult {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = props;\n\n const engine = ref<PdfEngine | null>(null);\n const isLoading = ref(true);\n const error = ref<Error | null>(null);\n\n /* create / destroy tied to component lifecycle ----------------- */\n onMounted(loadEngine);\n onBeforeUnmount(destroyEngine);\n\n /* re‑load if reactive props change ----------------------------- */\n watch(\n () => [wasmUrl, worker, logger] as const,\n () => {\n destroyEngine();\n loadEngine();\n },\n );\n\n async function loadEngine() {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, logger);\n pdfEngine.initialize().wait(\n () => {\n isLoading.value = false;\n engine.value = pdfEngine;\n },\n (e) => {\n error.value = new Error(e.reason.message);\n isLoading.value = false;\n },\n );\n isLoading.value = false;\n } catch (e) {\n error.value = e as Error;\n isLoading.value = false;\n }\n }\n\n function destroyEngine() {\n engine.value?.closeAllDocuments?.().wait(() => {\n engine.value?.destroy?.();\n engine.value = null;\n }, ignore);\n }\n\n return { engine, isLoading, error };\n}\n","<script setup lang=\"ts\">\nimport { provide, toRefs } from 'vue';\nimport { pdfEngineKey } from '../context/pdf-engine-context';\nimport type { PdfEngine } from '@embedpdf/models';\n\ninterface Props {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst props = defineProps<Props>();\n\n// Convert props to refs and provide them\nconst { engine, isLoading, error } = toRefs(props);\n\nprovide(pdfEngineKey, {\n engine,\n isLoading,\n error,\n});\n</script>\n\n<template>\n <slot />\n</template>\n"],"names":["_b","_a","_renderSlot"],"mappings":";;AASO,MAAM,eAAoD,OAAO,cAAc;ACD/E,SAAS,mBAA0C;AACxD,QAAM,eAAe,OAAO,YAAY;AAExC,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,SAAO;AACT;AAMO,SAAS,YAAY;AAC1B,QAAM,EAAE,QAAQ,MAAA,IAAU,iBAAA;AAE1B,MAAI,MAAM,OAAO;AACf,UAAM,MAAM;AAAA,EACd;AAEA,SAAO;AACT;AC3BA,MAAM,iBACJ;AAkBK,SAAS,gBAAgB,QAA8B,IAA2B;AACvF,QAAM,EAAE,UAAU,gBAAgB,SAAS,MAAM,WAAW;AAE5D,QAAM,SAAS,IAAsB,IAAI;AACzC,QAAM,YAAY,IAAI,IAAI;AAC1B,QAAM,QAAQ,IAAkB,IAAI;AAGpC,YAAU,UAAU;AACpB,kBAAgB,aAAa;AAG7B;AAAA,IACE,MAAM,CAAC,SAAS,QAAQ,MAAM;AAAA,IAC9B,MAAM;AACJ,oBAAA;AACA,iBAAA;AAAA,IACF;AAAA,EAAA;AAGF,iBAAe,aAAa;AAC1B,QAAI;AACF,YAAM,EAAE,mBAAA,IAAuB,SAC3B,MAAM,OAAO,wCAAwC,IACrD,MAAM,OAAO,wCAAwC;AAEzD,YAAM,YAAY,MAAM,mBAAmB,SAAS,MAAM;AAC1D,gBAAU,aAAa;AAAA,QACrB,MAAM;AACJ,oBAAU,QAAQ;AAClB,iBAAO,QAAQ;AAAA,QACjB;AAAA,QACA,CAAC,MAAM;AACL,gBAAM,QAAQ,IAAI,MAAM,EAAE,OAAO,OAAO;AACxC,oBAAU,QAAQ;AAAA,QACpB;AAAA,MAAA;AAEF,gBAAU,QAAQ;AAAA,IACpB,SAAS,GAAG;AACV,YAAM,QAAQ;AACd,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,WAAS,gBAAgB;;AACvB,uBAAO,UAAP,mBAAc,sBAAd,4BAAoC,KAAK,MAAM;;AAC7C,OAAAA,OAAAC,MAAA,OAAO,UAAP,gBAAAA,IAAc,YAAd,gBAAAD,IAAA,KAAAC;AACA,aAAO,QAAQ;AAAA,IACjB,GAAG;AAAA,EACL;AAEA,SAAO,EAAE,QAAQ,WAAW,MAAA;AAC9B;;;;;;;;;AC/DA,UAAM,QAAQ;AAGd,UAAM,EAAE,QAAQ,WAAW,MAAA,IAAU,OAAO,KAAK;AAEjD,YAAQ,cAAc;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;;aAICC,WAAQ,KAAA,QAAA,SAAA;AAAA;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/context/pdf-engine-context.ts","../../src/vue/composables/use-engine-context.ts","../../src/vue/composables/use-pdfium-engine.ts","../../src/vue/components/pdf-engine-provider.vue"],"sourcesContent":["import { InjectionKey, Ref } from 'vue';\nimport type { PdfEngine } from '@embedpdf/models';\n\nexport interface PdfEngineContextState {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\nexport const pdfEngineKey: InjectionKey<PdfEngineContextState> = Symbol('pdfEngineKey');\n","import { inject } from 'vue';\nimport { pdfEngineKey, PdfEngineContextState } from '../context/pdf-engine-context';\n\n/**\n * Composable to access the PDF engine from context.\n * @returns The PDF engine context state\n * @throws Error if used outside of PdfEngineProvider\n */\nexport function useEngineContext(): PdfEngineContextState {\n const contextValue = inject(pdfEngineKey);\n\n if (!contextValue) {\n throw new Error('useEngineContext must be used within a PdfEngineProvider');\n }\n\n return contextValue;\n}\n\n/**\n * Composable to access the PDF engine, with a more convenient API.\n * @returns The PDF engine or null if loading/error\n */\nexport function useEngine() {\n const { engine, error } = useEngineContext();\n\n if (error.value) {\n throw error.value;\n }\n\n return engine;\n}\n","import { ref, onMounted, onBeforeUnmount, watch, Ref } from 'vue';\nimport { ignore, type Logger, type PdfEngine } from '@embedpdf/models';\n\nconst defaultWasmUrl =\n 'https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm';\n\ninterface UsePdfiumEngineProps {\n wasmUrl?: string;\n worker?: boolean;\n logger?: Logger;\n}\n\ninterface UsePdfiumEngineResult {\n engine: Ref<PdfEngine | null>;\n isLoading: Ref<boolean>;\n error: Ref<Error | null>;\n}\n\n/**\n * Vue composable that loads a PdfiumEngine (worker or direct)\n * and keeps its lifetime tied to the component.\n */\nexport function usePdfiumEngine(props: UsePdfiumEngineProps = {}): UsePdfiumEngineResult {\n const { wasmUrl = defaultWasmUrl, worker = true, logger } = props;\n\n const engine = ref<PdfEngine | null>(null);\n const isLoading = ref(true);\n const error = ref<Error | null>(null);\n\n /* create / destroy tied to component lifecycle ----------------- */\n onMounted(loadEngine);\n onBeforeUnmount(destroyEngine);\n\n /* re‑load if reactive props change ----------------------------- */\n watch(\n () => [wasmUrl, worker, logger] as const,\n () => {\n destroyEngine();\n loadEngine();\n },\n );\n\n async function loadEngine() {\n try {\n const { createPdfiumEngine } = worker\n ? await import('@embedpdf/engines/pdfium-worker-engine')\n : await import('@embedpdf/engines/pdfium-direct-engine');\n\n const pdfEngine = await createPdfiumEngine(wasmUrl, { logger });\n pdfEngine.initialize().wait(\n () => {\n isLoading.value = false;\n engine.value = pdfEngine;\n },\n (e) => {\n error.value = new Error(e.reason.message);\n isLoading.value = false;\n },\n );\n isLoading.value = false;\n } catch (e) {\n error.value = e as Error;\n isLoading.value = false;\n }\n }\n\n function destroyEngine() {\n engine.value?.closeAllDocuments?.().wait(() => {\n engine.value?.destroy?.();\n engine.value = null;\n }, ignore);\n }\n\n return { engine, isLoading, error };\n}\n","<script setup lang=\"ts\">\nimport { provide, toRefs } from 'vue';\nimport { pdfEngineKey } from '../context/pdf-engine-context';\nimport type { PdfEngine } from '@embedpdf/models';\n\ninterface Props {\n engine: PdfEngine | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst props = defineProps<Props>();\n\n// Convert props to refs and provide them\nconst { engine, isLoading, error } = toRefs(props);\n\nprovide(pdfEngineKey, {\n engine,\n isLoading,\n error,\n});\n</script>\n\n<template>\n <slot />\n</template>\n"],"names":["_b","_a","_renderSlot"],"mappings":";;AASO,MAAM,eAAoD,OAAO,cAAc;ACD/E,SAAS,mBAA0C;AACxD,QAAM,eAAe,OAAO,YAAY;AAExC,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,SAAO;AACT;AAMO,SAAS,YAAY;AAC1B,QAAM,EAAE,QAAQ,MAAA,IAAU,iBAAA;AAE1B,MAAI,MAAM,OAAO;AACf,UAAM,MAAM;AAAA,EACd;AAEA,SAAO;AACT;AC3BA,MAAM,iBACJ;AAkBK,SAAS,gBAAgB,QAA8B,IAA2B;AACvF,QAAM,EAAE,UAAU,gBAAgB,SAAS,MAAM,WAAW;AAE5D,QAAM,SAAS,IAAsB,IAAI;AACzC,QAAM,YAAY,IAAI,IAAI;AAC1B,QAAM,QAAQ,IAAkB,IAAI;AAGpC,YAAU,UAAU;AACpB,kBAAgB,aAAa;AAG7B;AAAA,IACE,MAAM,CAAC,SAAS,QAAQ,MAAM;AAAA,IAC9B,MAAM;AACJ,oBAAA;AACA,iBAAA;AAAA,IACF;AAAA,EAAA;AAGF,iBAAe,aAAa;AAC1B,QAAI;AACF,YAAM,EAAE,mBAAA,IAAuB,SAC3B,MAAM,OAAO,wCAAwC,IACrD,MAAM,OAAO,wCAAwC;AAEzD,YAAM,YAAY,MAAM,mBAAmB,SAAS,EAAE,QAAQ;AAC9D,gBAAU,aAAa;AAAA,QACrB,MAAM;AACJ,oBAAU,QAAQ;AAClB,iBAAO,QAAQ;AAAA,QACjB;AAAA,QACA,CAAC,MAAM;AACL,gBAAM,QAAQ,IAAI,MAAM,EAAE,OAAO,OAAO;AACxC,oBAAU,QAAQ;AAAA,QACpB;AAAA,MAAA;AAEF,gBAAU,QAAQ;AAAA,IACpB,SAAS,GAAG;AACV,YAAM,QAAQ;AACd,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,WAAS,gBAAgB;;AACvB,uBAAO,UAAP,mBAAc,sBAAd,4BAAoC,KAAK,MAAM;;AAC7C,OAAAA,OAAAC,MAAA,OAAO,UAAP,gBAAAA,IAAc,YAAd,gBAAAD,IAAA,KAAAC;AACA,aAAO,QAAQ;AAAA,IACjB,GAAG;AAAA,EACL;AAEA,SAAO,EAAE,QAAQ,WAAW,MAAA;AAC9B;;;;;;;;;AC/DA,UAAM,QAAQ;AAGd,UAAM,EAAE,QAAQ,WAAW,MAAA,IAAU,OAAO,KAAK;AAEjD,YAAQ,cAAc;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;;aAICC,WAAQ,KAAA,QAAA,SAAA;AAAA;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/engines",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.3",
4
4
  "description": "Pluggable runtime layer that abstracts over multiple PDF engines (PDF-ium, Web Workers, mocks, etc.) to provide a unified API for rendering, search, annotation, and other document-level operations in EmbedPDF.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -88,8 +88,8 @@
88
88
  "@embedpdf/build": "1.1.0"
89
89
  },
90
90
  "dependencies": {
91
- "@embedpdf/models": "2.0.0-next.1",
92
- "@embedpdf/pdfium": "2.0.0-next.1"
91
+ "@embedpdf/models": "2.0.0-next.3",
92
+ "@embedpdf/pdfium": "2.0.0-next.3"
93
93
  },
94
94
  "peerDependencies": {
95
95
  "preact": "^10.26.4",