@embedpdf/engines 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/direct-engine-BeZ18SKz.cjs +2 -0
  2. package/dist/direct-engine-BeZ18SKz.cjs.map +1 -0
  3. package/dist/{direct-engine-DuLFAbiv.js → direct-engine-CB3k-o0I.js} +533 -9
  4. package/dist/direct-engine-CB3k-o0I.js.map +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.js +11 -4
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/orchestrator/remote-executor.d.ts +5 -0
  10. package/dist/lib/pdfium/cdn-fonts.d.ts +50 -0
  11. package/dist/lib/pdfium/engine.d.ts +17 -2
  12. package/dist/lib/pdfium/font-fallback.d.ts +207 -0
  13. package/dist/lib/pdfium/index.cjs +1 -1
  14. package/dist/lib/pdfium/index.cjs.map +1 -1
  15. package/dist/lib/pdfium/index.d.ts +2 -0
  16. package/dist/lib/pdfium/index.js +55 -2
  17. package/dist/lib/pdfium/index.js.map +1 -1
  18. package/dist/lib/pdfium/runner.d.ts +5 -1
  19. package/dist/lib/pdfium/web/direct-engine.cjs +1 -1
  20. package/dist/lib/pdfium/web/direct-engine.d.ts +8 -0
  21. package/dist/lib/pdfium/web/direct-engine.js +1 -1
  22. package/dist/lib/pdfium/web/worker-engine.cjs +1 -1
  23. package/dist/lib/pdfium/web/worker-engine.cjs.map +1 -1
  24. package/dist/lib/pdfium/web/worker-engine.d.ts +8 -0
  25. package/dist/lib/pdfium/web/worker-engine.js +5 -4
  26. package/dist/lib/pdfium/web/worker-engine.js.map +1 -1
  27. package/dist/preact/index.cjs +1 -1
  28. package/dist/preact/index.cjs.map +1 -1
  29. package/dist/preact/index.js +14 -4
  30. package/dist/preact/index.js.map +1 -1
  31. package/dist/react/index.cjs +1 -1
  32. package/dist/react/index.cjs.map +1 -1
  33. package/dist/react/index.js +14 -4
  34. package/dist/react/index.js.map +1 -1
  35. package/dist/shared-preact/hooks/use-pdfium-engine.d.ts +5 -0
  36. package/dist/shared-react/hooks/use-pdfium-engine.d.ts +5 -0
  37. package/dist/svelte/hooks/use-pdfium-engine.svelte.d.ts +5 -0
  38. package/dist/svelte/index.cjs +1 -1
  39. package/dist/svelte/index.cjs.map +1 -1
  40. package/dist/svelte/index.js +8 -3
  41. package/dist/svelte/index.js.map +1 -1
  42. package/dist/vue/composables/use-pdfium-engine.d.ts +5 -0
  43. package/dist/vue/index.cjs +1 -1
  44. package/dist/vue/index.cjs.map +1 -1
  45. package/dist/vue/index.js +4 -4
  46. package/dist/vue/index.js.map +1 -1
  47. package/package.json +10 -3
  48. package/dist/direct-engine-DuLFAbiv.js.map +0 -1
  49. package/dist/direct-engine-JeNRkc7w.cjs +0 -2
  50. package/dist/direct-engine-JeNRkc7w.cjs.map +0 -1
@@ -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 engine.value = pdfEngine;\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","e","destroyEngine","_b","_a","closeAllDocuments","call","wait","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,4LCOF,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,EAAS,CAAEE,WACtDX,EAAOQ,MAAQS,EACfhB,EAAUO,OAAQ,CACpB,OAASU,GACPhB,EAAMM,MAAQU,EACdjB,EAAUO,OAAQ,CACpB,CACF,CAEA,SAASW,YACP,OAAAC,EAAA,OAAAC,EAAArB,EAAOQ,YAAP,EAAAa,EAAcC,oBAAdF,EAAAG,KAAAF,GAAoCG,KAAK,aACvC,OAAAJ,EAAA,OAAAC,EAAArB,EAAOQ,cAAPa,EAAcI,UAAdL,EAAAG,KAAAF,GACArB,EAAOQ,MAAQ,MACdkB,EAAAA,OACL,CAEA,OAlCAC,EAAAA,UAAUb,GACVc,EAAAA,gBAAgBT,GAGhBU,EAAAA,MACE,IAAM,CAACpB,EAASC,EAAQC,GACxB,KACEQ,IACAL,MA0BG,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';\nimport type { FontFallbackConfig } from '@embedpdf/engines';\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 * Font fallback configuration for handling missing fonts in PDFs.\n */\n fontFallback?: FontFallbackConfig;\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, fontFallback } = 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, fontFallback] 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, fontFallback });\n engine.value = pdfEngine;\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","fontFallback","ref","async","loadEngine","createPdfiumEngine","import","pdfEngine","e","destroyEngine","_b","_a","closeAllDocuments","call","wait","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,CCZA,MAAMG,EACJ,4LCMF,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,qDCHO,SAAyBF,EAA8B,IAC5D,MAAMW,QAAEA,EAAUZ,EAAAa,OAAgBA,GAAS,EAAAC,OAAMA,EAAAC,aAAQA,GAAiBd,EAEpEE,EAASa,EAAAA,IAAsB,MAC/BZ,EAAYY,EAAAA,KAAI,GAChBX,EAAQW,EAAAA,IAAkB,MAehCC,eAAeC,IACb,IACE,MAAMC,mBAAEA,GAAuBN,QACrBO,OAAO,gDACPA,OAAO,0CAEXC,QAAkBF,EAAmBP,EAAS,CAAEE,SAAQC,iBAC9DZ,EAAOQ,MAAQU,EACfjB,EAAUO,OAAQ,CACpB,OAASW,GACPjB,EAAMM,MAAQW,EACdlB,EAAUO,OAAQ,CACpB,CACF,CAEA,SAASY,YACP,OAAAC,EAAA,OAAAC,EAAAtB,EAAOQ,YAAP,EAAAc,EAAcC,oBAAdF,EAAAG,KAAAF,GAAoCG,KAAK,aACvC,OAAAJ,EAAA,OAAAC,EAAAtB,EAAOQ,cAAPc,EAAcI,UAAdL,EAAAG,KAAAF,GACAtB,EAAOQ,MAAQ,MACdmB,EAAAA,OACL,CAEA,OAlCAC,EAAAA,UAAUb,GACVc,EAAAA,gBAAgBT,GAGhBU,EAAAA,MACE,IAAM,CAACrB,EAASC,EAAQC,EAAQC,GAChC,KACEQ,IACAL,MA0BG,CAAEf,SAAQC,YAAWC,QAC9B"}
package/dist/vue/index.js CHANGED
@@ -15,16 +15,16 @@ function useEngine() {
15
15
  }
16
16
  return engine;
17
17
  }
18
- const defaultWasmUrl = "https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.0.1/dist/pdfium.wasm";
18
+ const defaultWasmUrl = "https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.1.0/dist/pdfium.wasm";
19
19
  function usePdfiumEngine(props = {}) {
20
- const { wasmUrl = defaultWasmUrl, worker = true, logger } = props;
20
+ const { wasmUrl = defaultWasmUrl, worker = true, logger, fontFallback } = props;
21
21
  const engine = ref(null);
22
22
  const isLoading = ref(true);
23
23
  const error = ref(null);
24
24
  onMounted(loadEngine);
25
25
  onBeforeUnmount(destroyEngine);
26
26
  watch(
27
- () => [wasmUrl, worker, logger],
27
+ () => [wasmUrl, worker, logger, fontFallback],
28
28
  () => {
29
29
  destroyEngine();
30
30
  loadEngine();
@@ -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, fontFallback });
37
37
  engine.value = pdfEngine;
38
38
  isLoading.value = false;
39
39
  } catch (e) {
@@ -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 engine.value = pdfEngine;\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,aAAO,QAAQ;AACf,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;;;;;;;;;ACtDA,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';\nimport type { FontFallbackConfig } from '@embedpdf/engines';\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 * Font fallback configuration for handling missing fonts in PDFs.\n */\n fontFallback?: FontFallbackConfig;\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, fontFallback } = 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, fontFallback] 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, fontFallback });\n engine.value = pdfEngine;\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;AC1BA,MAAM,iBACJ;AAsBK,SAAS,gBAAgB,QAA8B,IAA2B;AACvF,QAAM,EAAE,UAAU,gBAAgB,SAAS,MAAM,QAAQ,iBAAiB;AAE1E,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,QAAQ,YAAY;AAAA,IAC5C,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,cAAc;AAC5E,aAAO,QAAQ;AACf,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;;;;;;;;;AC3DA,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.1",
3
+ "version": "2.1.0",
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,15 @@
88
88
  "@embedpdf/build": "1.1.0"
89
89
  },
90
90
  "dependencies": {
91
- "@embedpdf/models": "2.0.1",
92
- "@embedpdf/pdfium": "2.0.1"
91
+ "@embedpdf/fonts-arabic": "1.0.0",
92
+ "@embedpdf/fonts-hebrew": "1.0.0",
93
+ "@embedpdf/fonts-jp": "1.0.0",
94
+ "@embedpdf/fonts-latin": "1.0.0",
95
+ "@embedpdf/fonts-kr": "1.0.0",
96
+ "@embedpdf/models": "2.1.0",
97
+ "@embedpdf/pdfium": "2.1.0",
98
+ "@embedpdf/fonts-sc": "1.0.0",
99
+ "@embedpdf/fonts-tc": "1.0.0"
93
100
  },
94
101
  "peerDependencies": {
95
102
  "preact": "^10.26.4",