@aibrains/pdf-renderer 0.2.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/README.md +41 -0
- package/dist/core/format.d.ts +41 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/format.js +98 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/i18n.d.ts +45 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/i18n.js +67 -0
- package/dist/core/i18n.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +23 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/theme.d.ts +59 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/theme.js +58 -0
- package/dist/core/theme.js.map +1 -0
- package/dist/i18n/en/common.json +32 -0
- package/dist/i18n/ne/common.json +32 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @aibrains/pdf-renderer
|
|
2
|
+
|
|
3
|
+
EdForge PDF rendering library. JSX-based document templates built on
|
|
4
|
+
[`@react-pdf/renderer`](https://react-pdf.org/), with Devanagari (Nepali) font support,
|
|
5
|
+
Bikram Sambat date support, and a `TemplateDescriptor` registry for cross-domain
|
|
6
|
+
document types.
|
|
7
|
+
|
|
8
|
+
## Status
|
|
9
|
+
|
|
10
|
+
**Sprint C.0.1 — skeleton + first publish.** No documents or primitives shipped yet.
|
|
11
|
+
See [`docs/pilot-greenlight/c-epic-pdf-generation-design.md`](../../docs/pilot-greenlight/c-epic-pdf-generation-design.md)
|
|
12
|
+
for the architecture and the C.0.* sprint plan.
|
|
13
|
+
|
|
14
|
+
## Roadmap (C.0.* tickets)
|
|
15
|
+
|
|
16
|
+
| Ticket | Content |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| **C.0.1** (this) | Package skeleton, build infrastructure, first publish to npm at 0.1.0 |
|
|
19
|
+
| C.0.2 | Fonts (Latin + Devanagari), theme tokens, i18n helpers (EN/NE bundles), format helpers (Gregorian/BS/dual date, currency, number) |
|
|
20
|
+
| C.0.3 | Layout primitives (`Document`, `Page`, `BrandedHeader`, `BrandedFooter`, `Watermark`) + reusable components (`KeyValueTable`, `LineItemTable`, `TotalsBlock`, `SignatureLine`) |
|
|
21
|
+
| C.0.4 | `TemplateDescriptor<T>` type + per-`DocType` registry (`getDescriptor`, `registerDescriptor`) |
|
|
22
|
+
| C.0.5 | `SchoolBranding` schema + entity extension (lands on `@aibrains/shared-types` + identity service — not this package) |
|
|
23
|
+
| C.0.6 | Tenant PDF S3 buckets via CDK (not this package) |
|
|
24
|
+
| C.0.7 | Branding presigned-upload + GET endpoints (identity service — not this package) |
|
|
25
|
+
| C.1.* | First document components: `<InvoicePdf>`, `<ReceiptPdf>` |
|
|
26
|
+
| C.3.1 | `<GradeTable>` component + `<ReportCardPdf>` |
|
|
27
|
+
| C.5.1 | `<AdmitCardPdf>` data-shape |
|
|
28
|
+
|
|
29
|
+
## Build
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# From repo root
|
|
33
|
+
npm install
|
|
34
|
+
cd packages/pdf-renderer
|
|
35
|
+
npm run build # produces dist/index.js + dist/index.d.ts
|
|
36
|
+
npm run typecheck # tsc --noEmit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT — see [LICENSE](../../LICENSE) at the repo root.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date / currency / number formatting helpers for PDF documents.
|
|
3
|
+
*
|
|
4
|
+
* Wraps utilities from `@aibrains/shared-types`:
|
|
5
|
+
* - `gregorianToBs` for Bikram Sambat conversion (BS 2000-2090)
|
|
6
|
+
* - `formatCurrency` for archetype-aware currency rendering
|
|
7
|
+
*
|
|
8
|
+
* Three date modes per the design (§5.1):
|
|
9
|
+
* - `gregorian`: AD only, ISO-style "YYYY-MM-DD"
|
|
10
|
+
* - `bikram_sambat`: BS only, "B.S. YYYY-MM-DD"
|
|
11
|
+
* - `dual`: BS first, AD in parens — "B.S. YYYY-MM-DD (YYYY-MM-DD)"
|
|
12
|
+
*
|
|
13
|
+
* Locale parameter is accepted for future expansion (e.g., long-form month
|
|
14
|
+
* names per locale), but V1 outputs are locale-independent format strings.
|
|
15
|
+
*/
|
|
16
|
+
export type DateFormat = 'gregorian' | 'bikram_sambat' | 'dual';
|
|
17
|
+
/**
|
|
18
|
+
* Format an ISO-8601 date string for display in a PDF.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* formatDate('2026-04-28T00:00:00Z', 'gregorian', 'en-US') // '2026-04-28'
|
|
22
|
+
* formatDate('2026-04-28T00:00:00Z', 'bikram_sambat', 'ne-NP') // 'B.S. 2083-01-15'
|
|
23
|
+
* formatDate('2026-04-28T00:00:00Z', 'dual', 'ne-NP') // 'B.S. 2083-01-15 (2026-04-28)'
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatDate(isoDate: string, format: DateFormat, _locale?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format a number with locale-aware grouping. V1 supports south-asian
|
|
28
|
+
* (lakh / crore grouping) and western (thousands grouping) styles.
|
|
29
|
+
*
|
|
30
|
+
* Currency formatting that respects the archetype workspace setting lives
|
|
31
|
+
* in `@aibrains/shared-types/utils/currency::formatCurrency`. Re-exported
|
|
32
|
+
* from this module for convenience so document components have one import.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* formatNumber(1234567, 'south-asian') // '12,34,567'
|
|
36
|
+
* formatNumber(1234567, 'western') // '1,234,567'
|
|
37
|
+
*/
|
|
38
|
+
export type NumberGrouping = 'south-asian' | 'western';
|
|
39
|
+
export declare function formatNumber(value: number, grouping: NumberGrouping): string;
|
|
40
|
+
export { formatCurrency } from '@aibrains/shared-types';
|
|
41
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/core/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,eAAe,GAAG,MAAM,CAAC;AAEhE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAElB,OAAO,GAAE,MAAgB,GACxB,MAAM,CAgBR;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,SAAS,CAAC;AAEvD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,cAAc,GACvB,MAAM,CAOR;AAID,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Date / currency / number formatting helpers for PDF documents.
|
|
4
|
+
*
|
|
5
|
+
* Wraps utilities from `@aibrains/shared-types`:
|
|
6
|
+
* - `gregorianToBs` for Bikram Sambat conversion (BS 2000-2090)
|
|
7
|
+
* - `formatCurrency` for archetype-aware currency rendering
|
|
8
|
+
*
|
|
9
|
+
* Three date modes per the design (§5.1):
|
|
10
|
+
* - `gregorian`: AD only, ISO-style "YYYY-MM-DD"
|
|
11
|
+
* - `bikram_sambat`: BS only, "B.S. YYYY-MM-DD"
|
|
12
|
+
* - `dual`: BS first, AD in parens — "B.S. YYYY-MM-DD (YYYY-MM-DD)"
|
|
13
|
+
*
|
|
14
|
+
* Locale parameter is accepted for future expansion (e.g., long-form month
|
|
15
|
+
* names per locale), but V1 outputs are locale-independent format strings.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.formatCurrency = void 0;
|
|
19
|
+
exports.formatDate = formatDate;
|
|
20
|
+
exports.formatNumber = formatNumber;
|
|
21
|
+
const shared_types_1 = require("@aibrains/shared-types");
|
|
22
|
+
/**
|
|
23
|
+
* Format an ISO-8601 date string for display in a PDF.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* formatDate('2026-04-28T00:00:00Z', 'gregorian', 'en-US') // '2026-04-28'
|
|
27
|
+
* formatDate('2026-04-28T00:00:00Z', 'bikram_sambat', 'ne-NP') // 'B.S. 2083-01-15'
|
|
28
|
+
* formatDate('2026-04-28T00:00:00Z', 'dual', 'ne-NP') // 'B.S. 2083-01-15 (2026-04-28)'
|
|
29
|
+
*/
|
|
30
|
+
function formatDate(isoDate, format,
|
|
31
|
+
// locale reserved for V1.5 long-form months; suppress unused warning explicitly
|
|
32
|
+
_locale = 'en-US') {
|
|
33
|
+
// Normalize any ISO form (date-only or datetime, with or without TZ) to
|
|
34
|
+
// YYYY-MM-DD before BS conversion. Document dates (dueDate, issuedDate,
|
|
35
|
+
// etc.) are calendrical, not precise instants — and the shared-types BS
|
|
36
|
+
// converter has different behavior for date-only vs `T00:00:00Z` strings
|
|
37
|
+
// (date-only anchors to noon-local; datetime hits UTC interpretation and
|
|
38
|
+
// can be off-by-one in non-UTC timezones). Slicing first removes ambiguity.
|
|
39
|
+
const dateOnly = normalizeToDateOnly(isoDate);
|
|
40
|
+
if (format === 'gregorian')
|
|
41
|
+
return dateOnly;
|
|
42
|
+
const bs = (0, shared_types_1.gregorianToBs)(dateOnly);
|
|
43
|
+
const bsStr = `B.S. ${bs.year}-${pad2(bs.month)}-${pad2(bs.day)}`;
|
|
44
|
+
if (format === 'bikram_sambat')
|
|
45
|
+
return bsStr;
|
|
46
|
+
// dual: BS first, AD in parens
|
|
47
|
+
return `${bsStr} (${dateOnly})`;
|
|
48
|
+
}
|
|
49
|
+
function formatNumber(value, grouping) {
|
|
50
|
+
if (!Number.isFinite(value))
|
|
51
|
+
return '0';
|
|
52
|
+
if (grouping === 'western') {
|
|
53
|
+
return Math.trunc(value).toLocaleString('en-US');
|
|
54
|
+
}
|
|
55
|
+
// South-asian: last 3 digits, then groups of 2 (Indian-style lakh/crore)
|
|
56
|
+
return formatSouthAsian(value);
|
|
57
|
+
}
|
|
58
|
+
// Re-export the canonical currency formatter so consumers have one import path
|
|
59
|
+
// for all formatting helpers.
|
|
60
|
+
var shared_types_2 = require("@aibrains/shared-types");
|
|
61
|
+
Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return shared_types_2.formatCurrency; } });
|
|
62
|
+
// --- internals ---
|
|
63
|
+
const YMD_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
64
|
+
/**
|
|
65
|
+
* Extract YYYY-MM-DD from any ISO-8601 input. Works for both date-only
|
|
66
|
+
* (`'2026-04-28'`) and full datetime (`'2026-04-28T17:30:00Z'`) — slices the
|
|
67
|
+
* first 10 chars when the prefix is well-formed, falls back to UTC-component
|
|
68
|
+
* parsing otherwise. Returns the raw input verbatim if both paths fail
|
|
69
|
+
* (PDF rendering must never crash on a malformed date — surface it instead).
|
|
70
|
+
*/
|
|
71
|
+
function normalizeToDateOnly(iso) {
|
|
72
|
+
const slice = iso.slice(0, 10);
|
|
73
|
+
if (YMD_PATTERN.test(slice))
|
|
74
|
+
return slice;
|
|
75
|
+
const d = new Date(iso);
|
|
76
|
+
if (Number.isNaN(d.getTime()))
|
|
77
|
+
return iso;
|
|
78
|
+
const yyyy = d.getUTCFullYear();
|
|
79
|
+
const mm = pad2(d.getUTCMonth() + 1);
|
|
80
|
+
const dd = pad2(d.getUTCDate());
|
|
81
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
82
|
+
}
|
|
83
|
+
function pad2(n) {
|
|
84
|
+
return n.toString().padStart(2, '0');
|
|
85
|
+
}
|
|
86
|
+
function formatSouthAsian(value) {
|
|
87
|
+
const isNegative = value < 0;
|
|
88
|
+
const abs = Math.trunc(Math.abs(value)).toString();
|
|
89
|
+
if (abs.length <= 3)
|
|
90
|
+
return isNegative ? `-${abs}` : abs;
|
|
91
|
+
const lastThree = abs.slice(-3);
|
|
92
|
+
const rest = abs.slice(0, -3);
|
|
93
|
+
// Group rest into pairs from the right.
|
|
94
|
+
const grouped = rest.replace(/\B(?=(\d{2})+(?!\d))/g, ',');
|
|
95
|
+
const formatted = `${grouped},${lastThree}`;
|
|
96
|
+
return isNegative ? `-${formatted}` : formatted;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/core/format.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n helper for document labels.
|
|
3
|
+
*
|
|
4
|
+
* Translations live in JSON bundles under `src/i18n/{lang}/{namespace}.json`,
|
|
5
|
+
* loaded statically at module init via `resolveJsonModule`. The bundle ships
|
|
6
|
+
* with the package; consumers never load external translation files.
|
|
7
|
+
*
|
|
8
|
+
* Fallback rules:
|
|
9
|
+
* - Missing key in target language → fall back to English.
|
|
10
|
+
* - Missing key in English → return the key itself (visible breadcrumb in
|
|
11
|
+
* the rendered PDF, surfacing the gap to whoever's reviewing).
|
|
12
|
+
* - Missing namespace → behaves as missing key.
|
|
13
|
+
*
|
|
14
|
+
* Interpolation: simple `{var}` placeholders. Non-string values are coerced
|
|
15
|
+
* via String(value); undefined/null become empty string.
|
|
16
|
+
*
|
|
17
|
+
* V1 supports two languages (`'en'`, `'ne'`) and one namespace (`'common'`).
|
|
18
|
+
* Doc-type namespaces (`'invoice'`, `'receipt'`, etc.) ship with their
|
|
19
|
+
* documents in Sprint C.1+.
|
|
20
|
+
*/
|
|
21
|
+
/** Supported document languages in V1. */
|
|
22
|
+
export type Lang = 'en' | 'ne';
|
|
23
|
+
/** Supported translation namespaces in V1. New doc types append here. */
|
|
24
|
+
export type Namespace = 'common';
|
|
25
|
+
/**
|
|
26
|
+
* Translate a key.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* t('common', 'subtotal', 'ne') // → 'उप-योग'
|
|
30
|
+
* t('common', 'pageOf', 'en', {page: 1, total: 3}) // → 'Page 1 of 3'
|
|
31
|
+
* t('common', 'nonexistentKey', 'ne') // → 'nonexistentKey' (and absent from EN too)
|
|
32
|
+
*/
|
|
33
|
+
export declare function t(namespace: Namespace, key: string, lang: Lang, vars?: Record<string, string | number | undefined | null>): string;
|
|
34
|
+
/**
|
|
35
|
+
* Render the same key in two languages side-by-side. Used when a template
|
|
36
|
+
* has `labelLanguages: ['en', 'ne']` (dual-language mode).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* tDual('common', 'subtotal', ['en', 'ne']) // → { primary: 'Subtotal', secondary: 'उप-योग' }
|
|
40
|
+
*/
|
|
41
|
+
export declare function tDual(namespace: Namespace, key: string, langs: [Lang, Lang], vars?: Record<string, string | number | undefined | null>): {
|
|
42
|
+
primary: string;
|
|
43
|
+
secondary: string;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/core/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,0CAA0C;AAC1C,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/B,yEAAyE;AACzE,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;AAajC;;;;;;;GAOG;AACH,wBAAgB,CAAC,CACf,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,GACxD,MAAM,CAYR;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,GACxD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAKxC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* i18n helper for document labels.
|
|
4
|
+
*
|
|
5
|
+
* Translations live in JSON bundles under `src/i18n/{lang}/{namespace}.json`,
|
|
6
|
+
* loaded statically at module init via `resolveJsonModule`. The bundle ships
|
|
7
|
+
* with the package; consumers never load external translation files.
|
|
8
|
+
*
|
|
9
|
+
* Fallback rules:
|
|
10
|
+
* - Missing key in target language → fall back to English.
|
|
11
|
+
* - Missing key in English → return the key itself (visible breadcrumb in
|
|
12
|
+
* the rendered PDF, surfacing the gap to whoever's reviewing).
|
|
13
|
+
* - Missing namespace → behaves as missing key.
|
|
14
|
+
*
|
|
15
|
+
* Interpolation: simple `{var}` placeholders. Non-string values are coerced
|
|
16
|
+
* via String(value); undefined/null become empty string.
|
|
17
|
+
*
|
|
18
|
+
* V1 supports two languages (`'en'`, `'ne'`) and one namespace (`'common'`).
|
|
19
|
+
* Doc-type namespaces (`'invoice'`, `'receipt'`, etc.) ship with their
|
|
20
|
+
* documents in Sprint C.1+.
|
|
21
|
+
*/
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.t = t;
|
|
27
|
+
exports.tDual = tDual;
|
|
28
|
+
const common_json_1 = __importDefault(require("../i18n/en/common.json"));
|
|
29
|
+
const common_json_2 = __importDefault(require("../i18n/ne/common.json"));
|
|
30
|
+
const BUNDLES = {
|
|
31
|
+
en: { common: common_json_1.default },
|
|
32
|
+
ne: { common: common_json_2.default },
|
|
33
|
+
};
|
|
34
|
+
/** Default fallback language when target language is missing a key. */
|
|
35
|
+
const FALLBACK_LANG = 'en';
|
|
36
|
+
/**
|
|
37
|
+
* Translate a key.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* t('common', 'subtotal', 'ne') // → 'उप-योग'
|
|
41
|
+
* t('common', 'pageOf', 'en', {page: 1, total: 3}) // → 'Page 1 of 3'
|
|
42
|
+
* t('common', 'nonexistentKey', 'ne') // → 'nonexistentKey' (and absent from EN too)
|
|
43
|
+
*/
|
|
44
|
+
function t(namespace, key, lang, vars) {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f;
|
|
46
|
+
const raw = (_f = (_c = (_b = (_a = BUNDLES[lang]) === null || _a === void 0 ? void 0 : _a[namespace]) === null || _b === void 0 ? void 0 : _b[key]) !== null && _c !== void 0 ? _c : (_e = (_d = BUNDLES[FALLBACK_LANG]) === null || _d === void 0 ? void 0 : _d[namespace]) === null || _e === void 0 ? void 0 : _e[key]) !== null && _f !== void 0 ? _f : key;
|
|
47
|
+
if (!vars)
|
|
48
|
+
return raw;
|
|
49
|
+
return raw.replace(/\{(\w+)\}/g, (match, varName) => {
|
|
50
|
+
const value = vars[varName];
|
|
51
|
+
return value === undefined || value === null ? '' : String(value);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Render the same key in two languages side-by-side. Used when a template
|
|
56
|
+
* has `labelLanguages: ['en', 'ne']` (dual-language mode).
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* tDual('common', 'subtotal', ['en', 'ne']) // → { primary: 'Subtotal', secondary: 'उप-योग' }
|
|
60
|
+
*/
|
|
61
|
+
function tDual(namespace, key, langs, vars) {
|
|
62
|
+
return {
|
|
63
|
+
primary: t(namespace, key, langs[0], vars),
|
|
64
|
+
secondary: t(namespace, key, langs[1], vars),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/core/i18n.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;AA8BH,cAiBC;AASD,sBAUC;AAhED,yEAA8C;AAC9C,yEAA8C;AAW9C,MAAM,OAAO,GAA8B;IACzC,EAAE,EAAE,EAAE,MAAM,EAAE,qBAAQ,EAAE;IACxB,EAAE,EAAE,EAAE,MAAM,EAAE,qBAAQ,EAAE;CACzB,CAAC;AAEF,uEAAuE;AACvE,MAAM,aAAa,GAAS,IAAI,CAAC;AAEjC;;;;;;;GAOG;AACH,SAAgB,CAAC,CACf,SAAoB,EACpB,GAAW,EACX,IAAU,EACV,IAAyD;;IAEzD,MAAM,GAAG,GACP,MAAA,MAAA,MAAA,MAAA,OAAO,CAAC,IAAI,CAAC,0CAAG,SAAS,CAAC,0CAAG,GAAG,CAAC,mCACjC,MAAA,MAAA,OAAO,CAAC,aAAa,CAAC,0CAAG,SAAS,CAAC,0CAAG,GAAG,CAAC,mCAC1C,GAAG,CAAC;IAEN,IAAI,CAAC,IAAI;QAAE,OAAO,GAAG,CAAC;IAEtB,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAe,EAAE,EAAE;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,KAAK,CACnB,SAAoB,EACpB,GAAW,EACX,KAAmB,EACnB,IAAyD;IAEzD,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QAC1C,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core utilities for @aibrains/pdf-renderer documents.
|
|
3
|
+
*
|
|
4
|
+
* Sprint C.0.2 — exports theme tokens, i18n helper, and format helpers.
|
|
5
|
+
* Subsequent sprints (C.0.3+) add fonts registration, layout primitives,
|
|
6
|
+
* and reusable components on top of these.
|
|
7
|
+
*/
|
|
8
|
+
export { DEFAULT_COLORS, DEFAULT_SPACING, DEFAULT_FONT_SIZE, DEFAULT_MARGINS_MM, } from './theme';
|
|
9
|
+
export type { Colors, Spacing, FontSize, Margins } from './theme';
|
|
10
|
+
export { t, tDual } from './i18n';
|
|
11
|
+
export type { Lang, Namespace } from './i18n';
|
|
12
|
+
export { formatDate, formatNumber, formatCurrency } from './format';
|
|
13
|
+
export type { DateFormat, NumberGrouping } from './format';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAClC,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Core utilities for @aibrains/pdf-renderer documents.
|
|
4
|
+
*
|
|
5
|
+
* Sprint C.0.2 — exports theme tokens, i18n helper, and format helpers.
|
|
6
|
+
* Subsequent sprints (C.0.3+) add fonts registration, layout primitives,
|
|
7
|
+
* and reusable components on top of these.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.formatCurrency = exports.formatNumber = exports.formatDate = exports.tDual = exports.t = exports.DEFAULT_MARGINS_MM = exports.DEFAULT_FONT_SIZE = exports.DEFAULT_SPACING = exports.DEFAULT_COLORS = void 0;
|
|
11
|
+
var theme_1 = require("./theme");
|
|
12
|
+
Object.defineProperty(exports, "DEFAULT_COLORS", { enumerable: true, get: function () { return theme_1.DEFAULT_COLORS; } });
|
|
13
|
+
Object.defineProperty(exports, "DEFAULT_SPACING", { enumerable: true, get: function () { return theme_1.DEFAULT_SPACING; } });
|
|
14
|
+
Object.defineProperty(exports, "DEFAULT_FONT_SIZE", { enumerable: true, get: function () { return theme_1.DEFAULT_FONT_SIZE; } });
|
|
15
|
+
Object.defineProperty(exports, "DEFAULT_MARGINS_MM", { enumerable: true, get: function () { return theme_1.DEFAULT_MARGINS_MM; } });
|
|
16
|
+
var i18n_1 = require("./i18n");
|
|
17
|
+
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return i18n_1.t; } });
|
|
18
|
+
Object.defineProperty(exports, "tDual", { enumerable: true, get: function () { return i18n_1.tDual; } });
|
|
19
|
+
var format_1 = require("./format");
|
|
20
|
+
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return format_1.formatDate; } });
|
|
21
|
+
Object.defineProperty(exports, "formatNumber", { enumerable: true, get: function () { return format_1.formatNumber; } });
|
|
22
|
+
Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return format_1.formatCurrency; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAKiB;AAJf,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,0GAAA,iBAAiB,OAAA;AACjB,2GAAA,kBAAkB,OAAA;AAIpB,+BAAkC;AAAzB,yFAAA,CAAC,OAAA;AAAE,6FAAA,KAAK,OAAA;AAGjB,mCAAoE;AAA3D,oGAAA,UAAU,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,wGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default theme tokens for @aibrains/pdf-renderer documents.
|
|
3
|
+
*
|
|
4
|
+
* These are the defaults applied when a template's `brandingOverrides` does not
|
|
5
|
+
* specify the value. Document components import from here; per-template overrides
|
|
6
|
+
* are layered on top at render time via `template.brandingOverrides`.
|
|
7
|
+
*
|
|
8
|
+
* V1 keeps tokens minimal (8 colors, 5 spacings, 5 font sizes). Future sprints
|
|
9
|
+
* may extend without breaking consumers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_COLORS: {
|
|
12
|
+
/** Default primary accent (EdForge teal). Overridden per template. */
|
|
13
|
+
readonly primary: "#0D9488";
|
|
14
|
+
/** Default accent (used for secondary headings, hover-like states). */
|
|
15
|
+
readonly accent: "#0F766E";
|
|
16
|
+
/** Body text. */
|
|
17
|
+
readonly text: "#1F2937";
|
|
18
|
+
/** Muted text (metadata, captions). */
|
|
19
|
+
readonly textMuted: "#6B7280";
|
|
20
|
+
/** Light border (table dividers). */
|
|
21
|
+
readonly border: "#E5E7EB";
|
|
22
|
+
/** Page background. */
|
|
23
|
+
readonly background: "#FFFFFF";
|
|
24
|
+
/** Failure / NG / overdue highlight. */
|
|
25
|
+
readonly danger: "#DC2626";
|
|
26
|
+
/** Success / paid stamp. */
|
|
27
|
+
readonly success: "#16A34A";
|
|
28
|
+
};
|
|
29
|
+
export declare const DEFAULT_SPACING: {
|
|
30
|
+
readonly xs: 4;
|
|
31
|
+
readonly sm: 8;
|
|
32
|
+
readonly md: 12;
|
|
33
|
+
readonly lg: 16;
|
|
34
|
+
readonly xl: 24;
|
|
35
|
+
};
|
|
36
|
+
export declare const DEFAULT_FONT_SIZE: {
|
|
37
|
+
/** Caption / metadata (8pt). */
|
|
38
|
+
readonly xs: 8;
|
|
39
|
+
/** Body text (10pt). */
|
|
40
|
+
readonly sm: 10;
|
|
41
|
+
/** Default (11pt). */
|
|
42
|
+
readonly md: 11;
|
|
43
|
+
/** Section heading (14pt). */
|
|
44
|
+
readonly lg: 14;
|
|
45
|
+
/** Document title (18pt). */
|
|
46
|
+
readonly xl: 18;
|
|
47
|
+
};
|
|
48
|
+
/** Default page margins in millimetres (A4 conventional). */
|
|
49
|
+
export declare const DEFAULT_MARGINS_MM: {
|
|
50
|
+
readonly top: 15;
|
|
51
|
+
readonly right: 15;
|
|
52
|
+
readonly bottom: 15;
|
|
53
|
+
readonly left: 15;
|
|
54
|
+
};
|
|
55
|
+
export type Colors = typeof DEFAULT_COLORS;
|
|
56
|
+
export type Spacing = typeof DEFAULT_SPACING;
|
|
57
|
+
export type FontSize = typeof DEFAULT_FONT_SIZE;
|
|
58
|
+
export type Margins = typeof DEFAULT_MARGINS_MM;
|
|
59
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/core/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,cAAc;IACzB,sEAAsE;;IAEtE,uEAAuE;;IAEvE,iBAAiB;;IAEjB,uCAAuC;;IAEvC,qCAAqC;;IAErC,uBAAuB;;IAEvB,wCAAwC;;IAExC,4BAA4B;;CAEpB,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC;AAEX,eAAO,MAAM,iBAAiB;IAC5B,gCAAgC;;IAEhC,wBAAwB;;IAExB,sBAAsB;;IAEtB,8BAA8B;;IAE9B,6BAA6B;;CAErB,CAAC;AAEX,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,OAAO,cAAc,CAAC;AAC3C,MAAM,MAAM,OAAO,GAAG,OAAO,eAAe,CAAC;AAC7C,MAAM,MAAM,QAAQ,GAAG,OAAO,iBAAiB,CAAC;AAChD,MAAM,MAAM,OAAO,GAAG,OAAO,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Default theme tokens for @aibrains/pdf-renderer documents.
|
|
4
|
+
*
|
|
5
|
+
* These are the defaults applied when a template's `brandingOverrides` does not
|
|
6
|
+
* specify the value. Document components import from here; per-template overrides
|
|
7
|
+
* are layered on top at render time via `template.brandingOverrides`.
|
|
8
|
+
*
|
|
9
|
+
* V1 keeps tokens minimal (8 colors, 5 spacings, 5 font sizes). Future sprints
|
|
10
|
+
* may extend without breaking consumers.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.DEFAULT_MARGINS_MM = exports.DEFAULT_FONT_SIZE = exports.DEFAULT_SPACING = exports.DEFAULT_COLORS = void 0;
|
|
14
|
+
exports.DEFAULT_COLORS = {
|
|
15
|
+
/** Default primary accent (EdForge teal). Overridden per template. */
|
|
16
|
+
primary: '#0D9488',
|
|
17
|
+
/** Default accent (used for secondary headings, hover-like states). */
|
|
18
|
+
accent: '#0F766E',
|
|
19
|
+
/** Body text. */
|
|
20
|
+
text: '#1F2937',
|
|
21
|
+
/** Muted text (metadata, captions). */
|
|
22
|
+
textMuted: '#6B7280',
|
|
23
|
+
/** Light border (table dividers). */
|
|
24
|
+
border: '#E5E7EB',
|
|
25
|
+
/** Page background. */
|
|
26
|
+
background: '#FFFFFF',
|
|
27
|
+
/** Failure / NG / overdue highlight. */
|
|
28
|
+
danger: '#DC2626',
|
|
29
|
+
/** Success / paid stamp. */
|
|
30
|
+
success: '#16A34A',
|
|
31
|
+
};
|
|
32
|
+
exports.DEFAULT_SPACING = {
|
|
33
|
+
xs: 4,
|
|
34
|
+
sm: 8,
|
|
35
|
+
md: 12,
|
|
36
|
+
lg: 16,
|
|
37
|
+
xl: 24,
|
|
38
|
+
};
|
|
39
|
+
exports.DEFAULT_FONT_SIZE = {
|
|
40
|
+
/** Caption / metadata (8pt). */
|
|
41
|
+
xs: 8,
|
|
42
|
+
/** Body text (10pt). */
|
|
43
|
+
sm: 10,
|
|
44
|
+
/** Default (11pt). */
|
|
45
|
+
md: 11,
|
|
46
|
+
/** Section heading (14pt). */
|
|
47
|
+
lg: 14,
|
|
48
|
+
/** Document title (18pt). */
|
|
49
|
+
xl: 18,
|
|
50
|
+
};
|
|
51
|
+
/** Default page margins in millimetres (A4 conventional). */
|
|
52
|
+
exports.DEFAULT_MARGINS_MM = {
|
|
53
|
+
top: 15,
|
|
54
|
+
right: 15,
|
|
55
|
+
bottom: 15,
|
|
56
|
+
left: 15,
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/core/theme.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEU,QAAA,cAAc,GAAG;IAC5B,sEAAsE;IACtE,OAAO,EAAE,SAAS;IAClB,uEAAuE;IACvE,MAAM,EAAE,SAAS;IACjB,iBAAiB;IACjB,IAAI,EAAE,SAAS;IACf,uCAAuC;IACvC,SAAS,EAAE,SAAS;IACpB,qCAAqC;IACrC,MAAM,EAAE,SAAS;IACjB,uBAAuB;IACvB,UAAU,EAAE,SAAS;IACrB,wCAAwC;IACxC,MAAM,EAAE,SAAS;IACjB,4BAA4B;IAC5B,OAAO,EAAE,SAAS;CACV,CAAC;AAEE,QAAA,eAAe,GAAG;IAC7B,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;CACE,CAAC;AAEE,QAAA,iBAAiB,GAAG;IAC/B,gCAAgC;IAChC,EAAE,EAAE,CAAC;IACL,wBAAwB;IACxB,EAAE,EAAE,EAAE;IACN,sBAAsB;IACtB,EAAE,EAAE,EAAE;IACN,8BAA8B;IAC9B,EAAE,EAAE,EAAE;IACN,6BAA6B;IAC7B,EAAE,EAAE,EAAE;CACE,CAAC;AAEX,6DAA6D;AAChD,QAAA,kBAAkB,GAAG;IAChC,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;CACA,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"address": "Address",
|
|
3
|
+
"phone": "Phone",
|
|
4
|
+
"email": "Email",
|
|
5
|
+
"panNumber": "PAN",
|
|
6
|
+
"vatNumber": "VAT",
|
|
7
|
+
"studentName": "Student Name",
|
|
8
|
+
"studentId": "Student ID",
|
|
9
|
+
"schoolName": "School Name",
|
|
10
|
+
"principal": "Principal",
|
|
11
|
+
"classTeacher": "Class Teacher",
|
|
12
|
+
"signature": "Signature",
|
|
13
|
+
"date": "Date",
|
|
14
|
+
"time": "Time",
|
|
15
|
+
"page": "Page",
|
|
16
|
+
"pageOf": "Page {page} of {total}",
|
|
17
|
+
"of": "of",
|
|
18
|
+
"from": "From",
|
|
19
|
+
"to": "To",
|
|
20
|
+
"at": "at",
|
|
21
|
+
"amount": "Amount",
|
|
22
|
+
"quantity": "Qty",
|
|
23
|
+
"description": "Description",
|
|
24
|
+
"subtotal": "Subtotal",
|
|
25
|
+
"total": "Total",
|
|
26
|
+
"tax": "Tax",
|
|
27
|
+
"discount": "Discount",
|
|
28
|
+
"grandTotal": "Grand Total",
|
|
29
|
+
"amountPaid": "Amount Paid",
|
|
30
|
+
"amountDue": "Amount Due",
|
|
31
|
+
"notes": "Notes"
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"address": "ठेगाना",
|
|
3
|
+
"phone": "फोन",
|
|
4
|
+
"email": "इमेल",
|
|
5
|
+
"panNumber": "स्थायी लेखा नम्बर",
|
|
6
|
+
"vatNumber": "मू.अ.कर नम्बर",
|
|
7
|
+
"studentName": "विद्यार्थीको नाम",
|
|
8
|
+
"studentId": "विद्यार्थी परिचय",
|
|
9
|
+
"schoolName": "विद्यालयको नाम",
|
|
10
|
+
"principal": "प्रधानाध्यापक",
|
|
11
|
+
"classTeacher": "कक्षाध्यापक",
|
|
12
|
+
"signature": "हस्ताक्षर",
|
|
13
|
+
"date": "मिति",
|
|
14
|
+
"time": "समय",
|
|
15
|
+
"page": "पृष्ठ",
|
|
16
|
+
"pageOf": "पृष्ठ {page} / {total}",
|
|
17
|
+
"of": "/",
|
|
18
|
+
"from": "देखि",
|
|
19
|
+
"to": "सम्म",
|
|
20
|
+
"at": "मा",
|
|
21
|
+
"amount": "रकम",
|
|
22
|
+
"quantity": "मात्रा",
|
|
23
|
+
"description": "विवरण",
|
|
24
|
+
"subtotal": "उप-योग",
|
|
25
|
+
"total": "जम्मा",
|
|
26
|
+
"tax": "कर",
|
|
27
|
+
"discount": "छुट",
|
|
28
|
+
"grandTotal": "कुल जम्मा",
|
|
29
|
+
"amountPaid": "भुक्तानी रकम",
|
|
30
|
+
"amountDue": "बाँकी रकम",
|
|
31
|
+
"notes": "कैफियत"
|
|
32
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aibrains/pdf-renderer — EdForge PDF rendering library.
|
|
3
|
+
*
|
|
4
|
+
* Sprint C.0.2 ships core utilities (theme tokens, i18n helper, date/currency
|
|
5
|
+
* /number format helpers). Bikram Sambat support comes via `@aibrains/shared-types`.
|
|
6
|
+
*
|
|
7
|
+
* Subsequent C.0.* tickets add:
|
|
8
|
+
* - C.0.3: fonts registration (Noto Sans + Noto Sans Devanagari) + layout
|
|
9
|
+
* primitives (Document, Page, BrandedHeader, BrandedFooter, Watermark)
|
|
10
|
+
* + reusable components (KeyValueTable, LineItemTable, TotalsBlock,
|
|
11
|
+
* SignatureLine) + Devanagari snapshot tests
|
|
12
|
+
* - C.0.4: TemplateDescriptor<T> generic + per-docType registry
|
|
13
|
+
* Sprint C.1+: <InvoicePdf>, <ReceiptPdf>, <ReportCardPdf>, ...
|
|
14
|
+
*
|
|
15
|
+
* Design source of truth: docs/pilot-greenlight/c-epic-pdf-generation-design.md
|
|
16
|
+
*/
|
|
17
|
+
export declare const PDF_RENDERER_PACKAGE_VERSION = "0.2.0";
|
|
18
|
+
export * from './core';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAGpD,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @aibrains/pdf-renderer — EdForge PDF rendering library.
|
|
4
|
+
*
|
|
5
|
+
* Sprint C.0.2 ships core utilities (theme tokens, i18n helper, date/currency
|
|
6
|
+
* /number format helpers). Bikram Sambat support comes via `@aibrains/shared-types`.
|
|
7
|
+
*
|
|
8
|
+
* Subsequent C.0.* tickets add:
|
|
9
|
+
* - C.0.3: fonts registration (Noto Sans + Noto Sans Devanagari) + layout
|
|
10
|
+
* primitives (Document, Page, BrandedHeader, BrandedFooter, Watermark)
|
|
11
|
+
* + reusable components (KeyValueTable, LineItemTable, TotalsBlock,
|
|
12
|
+
* SignatureLine) + Devanagari snapshot tests
|
|
13
|
+
* - C.0.4: TemplateDescriptor<T> generic + per-docType registry
|
|
14
|
+
* Sprint C.1+: <InvoicePdf>, <ReceiptPdf>, <ReportCardPdf>, ...
|
|
15
|
+
*
|
|
16
|
+
* Design source of truth: docs/pilot-greenlight/c-epic-pdf-generation-design.md
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
30
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.PDF_RENDERER_PACKAGE_VERSION = void 0;
|
|
34
|
+
exports.PDF_RENDERER_PACKAGE_VERSION = '0.2.0';
|
|
35
|
+
// Re-export the C.0.2 core API surface.
|
|
36
|
+
__exportStar(require("./core"), exports);
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;AAEU,QAAA,4BAA4B,GAAG,OAAO,CAAC;AAEpD,wCAAwC;AACxC,yCAAuB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aibrains/pdf-renderer",
|
|
3
|
+
"version": "0.2.0",
|
|
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
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./core": {
|
|
14
|
+
"types": "./dist/core/index.d.ts",
|
|
15
|
+
"require": "./dist/core/index.js",
|
|
16
|
+
"default": "./dist/core/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"watch": "tsc --watch",
|
|
26
|
+
"clean": "rimraf dist",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "jest --config jest.config.cjs",
|
|
29
|
+
"prepare": "tsc",
|
|
30
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@aibrains/shared-types": "^0.60.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/jest": "^29.5.0",
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"jest": "^29.7.0",
|
|
39
|
+
"rimraf": "^5.0.5",
|
|
40
|
+
"ts-jest": "^29.1.0",
|
|
41
|
+
"typescript": "^5.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|