@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.
- package/dist/direct-engine-BeZ18SKz.cjs +2 -0
- package/dist/direct-engine-BeZ18SKz.cjs.map +1 -0
- package/dist/{direct-engine-DuLFAbiv.js → direct-engine-CB3k-o0I.js} +533 -9
- package/dist/direct-engine-CB3k-o0I.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/orchestrator/remote-executor.d.ts +5 -0
- package/dist/lib/pdfium/cdn-fonts.d.ts +50 -0
- package/dist/lib/pdfium/engine.d.ts +17 -2
- package/dist/lib/pdfium/font-fallback.d.ts +207 -0
- package/dist/lib/pdfium/index.cjs +1 -1
- package/dist/lib/pdfium/index.cjs.map +1 -1
- package/dist/lib/pdfium/index.d.ts +2 -0
- package/dist/lib/pdfium/index.js +55 -2
- package/dist/lib/pdfium/index.js.map +1 -1
- package/dist/lib/pdfium/runner.d.ts +5 -1
- package/dist/lib/pdfium/web/direct-engine.cjs +1 -1
- package/dist/lib/pdfium/web/direct-engine.d.ts +8 -0
- package/dist/lib/pdfium/web/direct-engine.js +1 -1
- package/dist/lib/pdfium/web/worker-engine.cjs +1 -1
- package/dist/lib/pdfium/web/worker-engine.cjs.map +1 -1
- package/dist/lib/pdfium/web/worker-engine.d.ts +8 -0
- package/dist/lib/pdfium/web/worker-engine.js +5 -4
- package/dist/lib/pdfium/web/worker-engine.js.map +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +14 -4
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +14 -4
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/hooks/use-pdfium-engine.d.ts +5 -0
- package/dist/shared-react/hooks/use-pdfium-engine.d.ts +5 -0
- package/dist/svelte/hooks/use-pdfium-engine.svelte.d.ts +5 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +8 -3
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/composables/use-pdfium-engine.d.ts +5 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +4 -4
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -3
- package/dist/direct-engine-DuLFAbiv.js.map +0 -1
- package/dist/direct-engine-JeNRkc7w.cjs +0 -2
- package/dist/direct-engine-JeNRkc7w.cjs.map +0 -1
package/dist/lib/pdfium/index.js
CHANGED
|
@@ -1,19 +1,72 @@
|
|
|
1
|
-
import { B, P, a, R, d, c, i, b, r } from "../../direct-engine-
|
|
1
|
+
import { B, F, P, a, R, d, e, c, i, b, r } from "../../direct-engine-CB3k-o0I.js";
|
|
2
2
|
import { I, b as b2, a as a2, c as c2 } from "../../browser-awZxztMA.js";
|
|
3
3
|
import { P as P2 } from "../../pdf-engine-BVNF_Yo9.js";
|
|
4
|
+
import { FontCharset } from "@embedpdf/models";
|
|
5
|
+
import { FontCharset as FontCharset2 } from "@embedpdf/models";
|
|
6
|
+
import { fonts as fonts$6 } from "@embedpdf/fonts-jp";
|
|
7
|
+
import { fonts as fonts$5 } from "@embedpdf/fonts-kr";
|
|
8
|
+
import { fonts as fonts$4 } from "@embedpdf/fonts-sc";
|
|
9
|
+
import { fonts as fonts$3 } from "@embedpdf/fonts-tc";
|
|
10
|
+
import { fonts as fonts$2 } from "@embedpdf/fonts-arabic";
|
|
11
|
+
import { fonts as fonts$1 } from "@embedpdf/fonts-hebrew";
|
|
12
|
+
import { fonts } from "@embedpdf/fonts-latin";
|
|
4
13
|
import { createPdfiumEngine } from "./web/worker-engine.js";
|
|
5
|
-
|
|
14
|
+
function buildCdnUrls(version = "latest") {
|
|
15
|
+
return {
|
|
16
|
+
jp: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-jp@${version}/fonts`,
|
|
17
|
+
kr: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-kr@${version}/fonts`,
|
|
18
|
+
sc: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-sc@${version}/fonts`,
|
|
19
|
+
tc: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-tc@${version}/fonts`,
|
|
20
|
+
arabic: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-arabic@${version}/fonts`,
|
|
21
|
+
hebrew: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-hebrew@${version}/fonts`,
|
|
22
|
+
latin: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-latin@${version}/fonts`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function toFontVariants(fonts2, baseUrl) {
|
|
26
|
+
return fonts2.map((f) => ({
|
|
27
|
+
url: `${baseUrl}/${f.file}`,
|
|
28
|
+
weight: f.weight,
|
|
29
|
+
italic: f.italic
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
function buildCdnFontConfig(urls) {
|
|
33
|
+
return {
|
|
34
|
+
fonts: {
|
|
35
|
+
[FontCharset.SHIFTJIS]: toFontVariants(fonts$6, urls.jp),
|
|
36
|
+
[FontCharset.HANGEUL]: toFontVariants(fonts$5, urls.kr),
|
|
37
|
+
[FontCharset.GB2312]: toFontVariants(fonts$4, urls.sc),
|
|
38
|
+
[FontCharset.CHINESEBIG5]: toFontVariants(fonts$3, urls.tc),
|
|
39
|
+
[FontCharset.ARABIC]: toFontVariants(fonts$2, urls.arabic),
|
|
40
|
+
[FontCharset.HEBREW]: toFontVariants(fonts$1, urls.hebrew),
|
|
41
|
+
[FontCharset.CYRILLIC]: toFontVariants(fonts, urls.latin),
|
|
42
|
+
[FontCharset.GREEK]: toFontVariants(fonts, urls.latin),
|
|
43
|
+
[FontCharset.VIETNAMESE]: toFontVariants(fonts, urls.latin)
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const FONT_CDN_URLS = buildCdnUrls("latest");
|
|
48
|
+
const cdnFontConfig = buildCdnFontConfig(FONT_CDN_URLS);
|
|
49
|
+
function createCdnFontConfig(version = "latest") {
|
|
50
|
+
return buildCdnFontConfig(buildCdnUrls(version));
|
|
51
|
+
}
|
|
52
|
+
const DEFAULT_PDFIUM_WASM_URL = "https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.1.0/dist/pdfium.wasm";
|
|
6
53
|
export {
|
|
7
54
|
B as BitmapFormat,
|
|
8
55
|
DEFAULT_PDFIUM_WASM_URL,
|
|
56
|
+
FONT_CDN_URLS,
|
|
57
|
+
FontCharset2 as FontCharset,
|
|
58
|
+
F as FontFallbackManager,
|
|
9
59
|
I as ImageConverterError,
|
|
10
60
|
P2 as PdfEngine,
|
|
11
61
|
P as PdfiumErrorCode,
|
|
12
62
|
a as PdfiumNative,
|
|
13
63
|
R as RenderFlag,
|
|
14
64
|
b2 as browserImageDataToBlobConverter,
|
|
65
|
+
cdnFontConfig,
|
|
15
66
|
d as computeFormDrawParams,
|
|
67
|
+
createCdnFontConfig,
|
|
16
68
|
a2 as createHybridImageConverter,
|
|
69
|
+
e as createNodeFontLoader,
|
|
17
70
|
c as createPdfiumDirectEngine,
|
|
18
71
|
createPdfiumEngine as createPdfiumWorkerEngine,
|
|
19
72
|
c2 as createWorkerPoolImageConverter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/lib/pdfium/index.ts"],"sourcesContent":["export * from './engine';\nexport * from './helper';\nexport * from '../converters/types';\nexport * from '../converters/browser';\nexport * from '../orchestrator/pdf-engine';\n\n// Export web factory functions (avoid ambiguous exports)\nexport { createPdfiumEngine as createPdfiumDirectEngine } from './web/direct-engine';\nexport { createPdfiumEngine as createPdfiumWorkerEngine } from './web/worker-engine';\nexport type { CreatePdfiumEngineOptions } from './web/direct-engine';\n\nexport const DEFAULT_PDFIUM_WASM_URL: string =\n 'https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/lib/pdfium/cdn-fonts.ts","../../../src/lib/pdfium/index.ts"],"sourcesContent":["/**\n * CDN Font Configuration for Browser Environments\n *\n * This file is intentionally separate from font-fallback.ts so that\n * Node.js users don't have to bundle the CDN URLs and font definitions.\n *\n * Only import this in browser-specific code (like the worker).\n */\n\nimport { FontCharset, type FontFile } from '@embedpdf/models';\nimport type { FontFallbackConfig, FontVariant } from './font-fallback';\n\n// Import font definitions from font packages (single source of truth)\nimport { fonts as jpFonts } from '@embedpdf/fonts-jp';\nimport { fonts as krFonts } from '@embedpdf/fonts-kr';\nimport { fonts as scFonts } from '@embedpdf/fonts-sc';\nimport { fonts as tcFonts } from '@embedpdf/fonts-tc';\nimport { fonts as arabicFonts } from '@embedpdf/fonts-arabic';\nimport { fonts as hebrewFonts } from '@embedpdf/fonts-hebrew';\nimport { fonts as latinFonts } from '@embedpdf/fonts-latin';\n\n// ============================================================================\n// CDN URL Builders\n// ============================================================================\n\n/**\n * Build CDN URLs from package version\n */\nfunction buildCdnUrls(version: string = 'latest') {\n return {\n jp: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-jp@${version}/fonts`,\n kr: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-kr@${version}/fonts`,\n sc: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-sc@${version}/fonts`,\n tc: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-tc@${version}/fonts`,\n arabic: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-arabic@${version}/fonts`,\n hebrew: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-hebrew@${version}/fonts`,\n latin: `https://cdn.jsdelivr.net/npm/@embedpdf/fonts-latin@${version}/fonts`,\n };\n}\n\n/**\n * Convert font files to FontVariant array with base URL\n */\nfunction toFontVariants(fonts: FontFile[], baseUrl: string): FontVariant[] {\n return fonts.map((f) => ({\n url: `${baseUrl}/${f.file}`,\n weight: f.weight,\n italic: f.italic,\n }));\n}\n\n/**\n * Build a complete font config from CDN URLs\n */\nfunction buildCdnFontConfig(urls: ReturnType<typeof buildCdnUrls>): FontFallbackConfig {\n return {\n fonts: {\n [FontCharset.SHIFTJIS]: toFontVariants(jpFonts, urls.jp),\n [FontCharset.HANGEUL]: toFontVariants(krFonts, urls.kr),\n [FontCharset.GB2312]: toFontVariants(scFonts, urls.sc),\n [FontCharset.CHINESEBIG5]: toFontVariants(tcFonts, urls.tc),\n [FontCharset.ARABIC]: toFontVariants(arabicFonts, urls.arabic),\n [FontCharset.HEBREW]: toFontVariants(hebrewFonts, urls.hebrew),\n [FontCharset.CYRILLIC]: toFontVariants(latinFonts, urls.latin),\n [FontCharset.GREEK]: toFontVariants(latinFonts, urls.latin),\n [FontCharset.VIETNAMESE]: toFontVariants(latinFonts, urls.latin),\n },\n };\n}\n\n// ============================================================================\n// Public Exports\n// ============================================================================\n\n/**\n * CDN base URLs for EmbedPDF font packages hosted on jsDelivr (using @latest)\n */\nexport const FONT_CDN_URLS = buildCdnUrls('latest');\n\n/**\n * Default CDN font configuration using @embedpdf/fonts-* packages from jsDelivr\n *\n * This is the default configuration for browser-based worker engines.\n * Fonts are loaded on-demand from jsDelivr when PDFium needs them.\n *\n * Uses @latest to always get the newest version of font packages.\n *\n * Included packages:\n * - @embedpdf/fonts-jp: Japanese (7 weights: Thin to Black)\n * - @embedpdf/fonts-kr: Korean (7 weights: Thin to Black)\n * - @embedpdf/fonts-sc: Simplified Chinese (5 weights: Light to Bold)\n * - @embedpdf/fonts-tc: Traditional Chinese (7 weights: Thin to Black)\n * - @embedpdf/fonts-arabic: Arabic (Regular, Bold)\n * - @embedpdf/fonts-hebrew: Hebrew (Regular, Bold)\n * - @embedpdf/fonts-latin: Latin/Cyrillic/Greek/Vietnamese (9 weights with italics)\n */\nexport const cdnFontConfig: FontFallbackConfig = buildCdnFontConfig(FONT_CDN_URLS);\n\n/**\n * Create a CDN font config with a specific version\n *\n * Use this if you need to pin to a specific version for stability.\n *\n * @param version - Version string (e.g., '1.0.0', '1', 'latest')\n * @returns FontFallbackConfig with versioned CDN URLs\n *\n * @example\n * ```typescript\n * // Pin to specific version\n * const fontConfig = createCdnFontConfig('1.0.0');\n *\n * // Use major version (recommended for stability)\n * const fontConfig = createCdnFontConfig('1');\n * ```\n */\nexport function createCdnFontConfig(version: string = 'latest'): FontFallbackConfig {\n return buildCdnFontConfig(buildCdnUrls(version));\n}\n\n// Re-export types for convenience\nexport type { FontFallbackConfig };\n","export * from './engine';\nexport * from './helper';\nexport * from '../converters/types';\nexport * from '../converters/browser';\nexport * from '../orchestrator/pdf-engine';\nexport * from './font-fallback';\nexport * from './cdn-fonts';\n\n// Export web factory functions (avoid ambiguous exports)\nexport { createPdfiumEngine as createPdfiumDirectEngine } from './web/direct-engine';\nexport { createPdfiumEngine as createPdfiumWorkerEngine } from './web/worker-engine';\nexport type { CreatePdfiumEngineOptions } from './web/direct-engine';\n\nexport const DEFAULT_PDFIUM_WASM_URL: string =\n 'https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@__PDFIUM_VERSION__/dist/pdfium.wasm';\n"],"names":["fonts","jpFonts","krFonts","scFonts","tcFonts","arabicFonts","hebrewFonts","latinFonts"],"mappings":";;;;;;;;;;;;;AA4BA,SAAS,aAAa,UAAkB,UAAU;AAChD,SAAO;AAAA,IACL,IAAI,mDAAmD,OAAO;AAAA,IAC9D,IAAI,mDAAmD,OAAO;AAAA,IAC9D,IAAI,mDAAmD,OAAO;AAAA,IAC9D,IAAI,mDAAmD,OAAO;AAAA,IAC9D,QAAQ,uDAAuD,OAAO;AAAA,IACtE,QAAQ,uDAAuD,OAAO;AAAA,IACtE,OAAO,sDAAsD,OAAO;AAAA,EAAA;AAExE;AAKA,SAAS,eAAeA,QAAmB,SAAgC;AACzE,SAAOA,OAAM,IAAI,CAAC,OAAO;AAAA,IACvB,KAAK,GAAG,OAAO,IAAI,EAAE,IAAI;AAAA,IACzB,QAAQ,EAAE;AAAA,IACV,QAAQ,EAAE;AAAA,EAAA,EACV;AACJ;AAKA,SAAS,mBAAmB,MAA2D;AACrF,SAAO;AAAA,IACL,OAAO;AAAA,MACL,CAAC,YAAY,QAAQ,GAAG,eAAeC,SAAS,KAAK,EAAE;AAAA,MACvD,CAAC,YAAY,OAAO,GAAG,eAAeC,SAAS,KAAK,EAAE;AAAA,MACtD,CAAC,YAAY,MAAM,GAAG,eAAeC,SAAS,KAAK,EAAE;AAAA,MACrD,CAAC,YAAY,WAAW,GAAG,eAAeC,SAAS,KAAK,EAAE;AAAA,MAC1D,CAAC,YAAY,MAAM,GAAG,eAAeC,SAAa,KAAK,MAAM;AAAA,MAC7D,CAAC,YAAY,MAAM,GAAG,eAAeC,SAAa,KAAK,MAAM;AAAA,MAC7D,CAAC,YAAY,QAAQ,GAAG,eAAeC,OAAY,KAAK,KAAK;AAAA,MAC7D,CAAC,YAAY,KAAK,GAAG,eAAeA,OAAY,KAAK,KAAK;AAAA,MAC1D,CAAC,YAAY,UAAU,GAAG,eAAeA,OAAY,KAAK,KAAK;AAAA,IAAA;AAAA,EACjE;AAEJ;AASO,MAAM,gBAAgB,aAAa,QAAQ;AAmB3C,MAAM,gBAAoC,mBAAmB,aAAa;AAmB1E,SAAS,oBAAoB,UAAkB,UAA8B;AAClF,SAAO,mBAAmB,aAAa,OAAO,CAAC;AACjD;ACxGO,MAAM,0BACX;"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { PdfiumNativeRunner } from '../orchestrator/pdfium-native-runner';
|
|
2
2
|
import { Logger } from '@embedpdf/models';
|
|
3
|
+
import { FontFallbackConfig } from './font-fallback';
|
|
3
4
|
/**
|
|
4
5
|
* EngineRunner for pdfium-based wasm engine
|
|
5
6
|
*/
|
|
6
7
|
export declare class PdfiumEngineRunner extends PdfiumNativeRunner {
|
|
7
8
|
private wasmBinary;
|
|
9
|
+
private fontFallback?;
|
|
8
10
|
/**
|
|
9
11
|
* Create an instance of PdfiumEngineRunner
|
|
10
12
|
* @param wasmBinary - wasm binary that contains the pdfium wasm file
|
|
13
|
+
* @param logger - optional logger instance
|
|
14
|
+
* @param fontFallback - optional font fallback configuration
|
|
11
15
|
*/
|
|
12
|
-
constructor(wasmBinary: ArrayBuffer, logger?: Logger);
|
|
16
|
+
constructor(wasmBinary: ArrayBuffer, logger?: Logger, fontFallback?: FontFallbackConfig);
|
|
13
17
|
/**
|
|
14
18
|
* Initialize runner
|
|
15
19
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("@embedpdf/pdfium");const e=require("../../../direct-engine-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("@embedpdf/pdfium");const e=require("../../../direct-engine-BeZ18SKz.cjs");require("../../../pdf-engine-C3JeKij1.cjs"),require("../../../browser-C6QEa8uk.cjs"),exports.createPdfiumEngine=e.createPdfiumEngine;
|
|
2
2
|
//# sourceMappingURL=direct-engine.cjs.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Logger } from '@embedpdf/models';
|
|
2
2
|
import { PdfEngine } from '../../orchestrator/pdf-engine';
|
|
3
|
+
import { FontFallbackConfig } from '../font-fallback';
|
|
4
|
+
export type { FontFallbackConfig };
|
|
3
5
|
export interface CreatePdfiumEngineOptions {
|
|
4
6
|
/**
|
|
5
7
|
* Logger instance for debugging
|
|
@@ -10,6 +12,12 @@ export interface CreatePdfiumEngineOptions {
|
|
|
10
12
|
* Set to 2-4 for optimal performance with parallel encoding
|
|
11
13
|
*/
|
|
12
14
|
encoderPoolSize?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Font fallback configuration for handling missing fonts in PDFs.
|
|
17
|
+
* When enabled, PDFium will request fallback fonts from configured URLs
|
|
18
|
+
* when it encounters text that requires fonts not embedded in the PDF.
|
|
19
|
+
*/
|
|
20
|
+
fontFallback?: FontFallbackConfig;
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
15
23
|
* Create a PDFium engine running directly in the main thread
|