@aibrains/pdf-renderer 0.10.0 → 0.10.1
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/core/fonts.d.ts +7 -1
- package/dist/core/fonts.d.ts.map +1 -1
- package/dist/core/fonts.js +14 -3
- package/dist/core/fonts.js.map +1 -1
- package/package.json +3 -3
package/dist/core/fonts.d.ts
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* Both are sourced from @fontsource/* at build time and copied to ./fonts/ at the
|
|
9
9
|
* package root (see scripts/copy-fonts.js). At runtime, paths resolve identically
|
|
10
10
|
* from `src/core/fonts.ts` and `dist/core/fonts.js` because both live two
|
|
11
|
-
* directories below the package root (../../fonts/).
|
|
11
|
+
* directories below the package root (../../fonts/). A consumer that bundles
|
|
12
|
+
* this module into a single file (esbuild for AWS Lambda) loses that layout:
|
|
13
|
+
* `__dirname` is then the bundle's own directory. Such a consumer ships the
|
|
14
|
+
* `fonts/` directory beside its bundle and names it in `PDF_FONT_DIR`.
|
|
12
15
|
*
|
|
13
16
|
* Devanagari rendering uses Yoga + Fontkit + Harfbuzz inside @react-pdf/renderer v4
|
|
14
17
|
* to handle complex script shaping (conjuncts, vowel marks). This is the canary for
|
|
@@ -23,6 +26,9 @@
|
|
|
23
26
|
* pick them up via the relative path. URL-based registration for CDN deployments
|
|
24
27
|
* is a Sprint C.2 concern.
|
|
25
28
|
*/
|
|
29
|
+
/** Environment variable naming the font directory when the package-relative default cannot apply. */
|
|
30
|
+
export declare const FONT_DIR_ENV = "PDF_FONT_DIR";
|
|
31
|
+
export declare function resolveFontDir(env?: NodeJS.ProcessEnv): string;
|
|
26
32
|
/** Latin font family registered by `registerFonts()`. */
|
|
27
33
|
export declare const FONT_FAMILY_LATIN: "Noto Sans";
|
|
28
34
|
/** Devanagari (Nepali) font family registered by `registerFonts()`. */
|
package/dist/core/fonts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/core/fonts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/core/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAOH,qGAAqG;AACrG,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAG3E;AAED,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,EAAG,WAAoB,CAAC;AACtD,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,EAAG,sBAA+B,CAAC;AAStE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,OAAO,iBAAiB,GAAG,OAAO,sBAAsB,CAI1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAI1C;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAqCpC;AAED,wFAAwF;AACxF,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|
package/dist/core/fonts.js
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* Both are sourced from @fontsource/* at build time and copied to ./fonts/ at the
|
|
10
10
|
* package root (see scripts/copy-fonts.js). At runtime, paths resolve identically
|
|
11
11
|
* from `src/core/fonts.ts` and `dist/core/fonts.js` because both live two
|
|
12
|
-
* directories below the package root (../../fonts/).
|
|
12
|
+
* directories below the package root (../../fonts/). A consumer that bundles
|
|
13
|
+
* this module into a single file (esbuild for AWS Lambda) loses that layout:
|
|
14
|
+
* `__dirname` is then the bundle's own directory. Such a consumer ships the
|
|
15
|
+
* `fonts/` directory beside its bundle and names it in `PDF_FONT_DIR`.
|
|
13
16
|
*
|
|
14
17
|
* Devanagari rendering uses Yoga + Fontkit + Harfbuzz inside @react-pdf/renderer v4
|
|
15
18
|
* to handle complex script shaping (conjuncts, vowel marks). This is the canary for
|
|
@@ -58,14 +61,21 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
58
61
|
};
|
|
59
62
|
})();
|
|
60
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
exports.FONT_FAMILY_DEVANAGARI = exports.FONT_FAMILY_LATIN = void 0;
|
|
64
|
+
exports.FONT_FAMILY_DEVANAGARI = exports.FONT_FAMILY_LATIN = exports.FONT_DIR_ENV = void 0;
|
|
65
|
+
exports.resolveFontDir = resolveFontDir;
|
|
62
66
|
exports.pickFontFamily = pickFontFamily;
|
|
63
67
|
exports.registerFonts = registerFonts;
|
|
64
68
|
exports._resetFontsForTest = _resetFontsForTest;
|
|
65
69
|
const path = __importStar(require("node:path"));
|
|
66
70
|
const renderer_1 = require("@react-pdf/renderer");
|
|
67
71
|
const PACKAGE_ROOT = path.resolve(__dirname, '..', '..');
|
|
68
|
-
|
|
72
|
+
/** Environment variable naming the font directory when the package-relative default cannot apply. */
|
|
73
|
+
exports.FONT_DIR_ENV = 'PDF_FONT_DIR';
|
|
74
|
+
function resolveFontDir(env = process.env) {
|
|
75
|
+
var _a;
|
|
76
|
+
const override = (_a = env[exports.FONT_DIR_ENV]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
77
|
+
return override ? path.resolve(override) : path.join(PACKAGE_ROOT, 'fonts');
|
|
78
|
+
}
|
|
69
79
|
/** Latin font family registered by `registerFonts()`. */
|
|
70
80
|
exports.FONT_FAMILY_LATIN = 'Noto Sans';
|
|
71
81
|
/** Devanagari (Nepali) font family registered by `registerFonts()`. */
|
|
@@ -120,6 +130,7 @@ let registered = false;
|
|
|
120
130
|
function registerFonts() {
|
|
121
131
|
if (registered)
|
|
122
132
|
return;
|
|
133
|
+
const FONT_DIR = resolveFontDir();
|
|
123
134
|
// @react-pdf/renderer uses NUMERIC fontWeight internally (400 for normal,
|
|
124
135
|
// 700 for bold). Passing the string 'normal'/'bold' to Font.register stores
|
|
125
136
|
// them as strings but the resolver looks up numerics, so the registration
|
package/dist/core/fonts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/core/fonts.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/core/fonts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUH,wCAGC;AAwCD,wCAMC;AAgCD,sCAqCC;AAGD,gDAEC;AAnID,gDAAkC;AAClC,kDAA2C;AAE3C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEzD,qGAAqG;AACxF,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,SAAgB,cAAc,CAAC,MAAyB,OAAO,CAAC,GAAG;;IACjE,MAAM,QAAQ,GAAG,MAAA,GAAG,CAAC,oBAAY,CAAC,0CAAE,IAAI,EAAE,CAAC;IAC3C,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED,yDAAyD;AAC5C,QAAA,iBAAiB,GAAG,WAAoB,CAAC;AACtD,uEAAuE;AAC1D,QAAA,sBAAsB,GAAG,sBAA+B,CAAC;AAEtE,+EAA+E;AAC/E,uEAAuE;AACvE,0EAA0E;AAC1E,6EAA6E;AAC7E,wDAAwD;AACxD,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB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KAAK,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aibrains/pdf-renderer",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "EdForge PDF rendering library. JSX-based document templates built on @react-pdf/renderer, with localization (EN + NE), Bikram Sambat date support, and a TemplateDescriptor registry for cross-domain doc types (invoice, receipt, report card, admit card, etc.).",
|
|
5
|
-
"license": "
|
|
6
|
-
"author": "
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Shoaib Rain",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|