@t4h.framework/pdf 0.4.5 → 0.4.7

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.
@@ -1,360 +1,117 @@
1
1
  ---
2
2
  name: framework-pdf
3
3
  description: >-
4
- Guides correct use of @t4h.framework/pdf in T4H Framework workflows: the
5
- `render()` helper, PDF marker components (Document, Page, View, Text, Link,
6
- Image, PageNumber), custom fonts, Binary image sources, styling,
7
- password-protected PDFs via the `encrypt` option, and the FileSystemClaim
8
- the render activity requires. Use when generating PDFs in workflows,
9
- building PDF templates with JSX, registering fonts, encrypting PDFs, or
10
- working in packages/pdf.
4
+ Guides the use of @t4h.framework/pdf to generate PDF files in T4H Framework
5
+ workflows: the render() function, the JSX marker components (Document, Page,
6
+ View, Text, Link, Image, PageNumber), styles, custom fonts, Binary image
7
+ sources, password protection with the encrypt option (ProtectionFlags,
8
+ ProtectionPresets), the FileSystemClaim that render needs, and tests with
9
+ TestWorkflowEnvironment and mockClaim. Use when a workflow must produce a
10
+ PDF, an invoice, a report or a statement, when building a PDF template in
11
+ JSX, or when someone mentions @react-pdf/renderer in a workflow.
11
12
  ---
12
13
 
13
14
  # @t4h.framework/pdf
14
15
 
15
- Declarative PDF rendering for workflows, backed by `@react-pdf/renderer`.
16
- Package path: `framework/packages/pdf`. Peer dependencies:
17
- `@t4h.framework/core`, `@t4h.framework/fs`. Regular dependencies: `react`,
18
- `@react-pdf/renderer`.
16
+ ## Render a PDF in a workflow
19
17
 
20
- Import surface (from `src/pdf.ts` only — the `helpers/` modules are internal):
21
-
22
- ```typescript
23
- import {
24
- render,
25
- Document,
26
- Page,
27
- View,
28
- Text,
29
- Link,
30
- Image,
31
- PageNumber,
32
- RenderPDFActivity,
33
- ProtectionFlags,
34
- ProtectionPresets,
35
- type RenderPDFOptions,
36
- type RenderPDFInput,
37
- type EncryptPDFOptions,
38
- type DocumentProps,
39
- type PageProps,
40
- type ViewProps,
41
- type TextProps,
42
- type LinkProps,
43
- type ImageProps,
44
- type PageNumberProps,
45
- type DocumentNode,
46
- type PDFNode,
47
- type PDFStyle,
48
- } from '@t4h.framework/pdf'
49
- ```
50
-
51
- > Workflows use **`render()`** — for everything, including encryption. The
52
- > package also exports the underlying `RenderPDFActivity`, but workflow code
53
- > never imports, instantiates, or extends it. The `encryptPDF` tool in
54
- > `src/tools/` is internal and not exported — encryption always goes through
55
- > `render`'s `encrypt` option.
56
-
57
- ## Architecture
58
-
59
- `Workflow` → `render(<Document>…</Document>, options?)`
60
- (`History.reconciler(RenderPDFActivity)`) →
61
-
62
- 1. **`toInput`** (workflow side): the JSX tree is serialized into a plain
63
- `DocumentNode` JSON tree that is stored in the workflow history. User
64
- function components, fragments, arrays, and conditionals are flattened
65
- here; only marker components and strings remain.
66
- 2. **`run`** (activity side): `Binary` image and font sources are read through
67
- their claims and inlined as `data:` URIs on the calling thread, then the
68
- resolved tree is handed to a **worker thread** (pool size
69
- `PDF_RENDER_CONCURRENCY`, default `1`, created on first render, idle workers
70
- unrefed) that registers fonts once per process, converts the `DocumentNode`
71
- tree back into real `@react-pdf/renderer` elements and renders it to a
72
- buffer. The buffer is written through **`FileSystemClaim`** at
73
- `pdf/${activityId}.pdf`. With the `encrypt` option, a password-protected
74
- copy (AES-128, `%PDF-1.6`) is written from the same layout at
75
- `pdf/${activityId}-encrypted.pdf` — no second layout pass, no re-encryption
76
- of the finished file. A render therefore blocks the event loop of the
77
- calling process for milliseconds, not for the whole document.
78
- 3. The activity returns the **`Binary`** the claim produced — a reference to
79
- the stored file, not in-memory bytes. Replay-safe by construction. With
80
- `encrypt`, it returns the `[original, encrypted]` pair instead, and the
81
- `render` return type narrows automatically based on the options.
82
-
83
- ---
84
-
85
- ## Claims
86
-
87
- ### FileSystemClaim (required)
88
-
89
- The render activity persists the PDF through `fs`. Any workflow that calls
90
- `render()` needs a `FileSystemClaim` provider:
91
-
92
- ```typescript
93
- { provide: FileSystemClaim, value: new MyFileSystemClaimImpl() }
94
- ```
95
-
96
- Tests mock its `write` to return a `Binary` (see **Testing**).
97
-
98
- ---
99
-
100
- ## Marker components
101
-
102
- The components exported by this package are **markers**: they exist only as
103
- type-safe JSX tags inside a tree passed to `render()`. JSX never invokes
104
- them — the serializer recognizes them by reference. Calling one directly
105
- (`Image({ src })`) or rendering them with another renderer throws.
106
-
107
- | Component | Props (beyond `NodeProps`) | Notes |
108
- |-----------|---------------------------|-------|
109
- | `Document` | `title? author? subject? creator? producer? language?` | Root. Children must be `Page` elements |
110
- | `Page` | `size? orientation? style? wrap? dpi?` | `size` defaults to A4. Overflowing content paginates automatically |
111
- | `View` | — | Flex container, analogous to a `<div>` |
112
- | `Text` | — | All raw strings must live inside a `Text` |
113
- | `Link` | `href` (required) | Hyperlink; serialized `href` becomes react-pdf's `src` internally |
114
- | `Image` | `src: string \| Binary` (required) | URL, `data:` URI, or `Binary` with an image `contentType` |
115
- | `PageNumber` | `format?` | Resolves at layout time. Tokens: `{pageNumber}`, `{totalPages}`. Default `'{pageNumber}'`. Combine with `fixed` for running footers |
116
-
117
- `NodeProps` (shared by every node inside a page): `style`, `fixed` (repeat on
118
- every page — headers/footers), `break` (force page break before the node),
119
- `wrap` (allow splitting across pages, default `true`), `minPresenceAhead`
120
- (move to next page unless this many points remain — avoids orphaned headings).
121
-
122
- **Tree rules enforced at serialization** (violations throw `TypeError`):
123
-
124
- - The tree must resolve to a single `Document` root.
125
- - `Document` children must be `Page` elements.
126
- - Raw text must be wrapped in `Text` (`"x"` directly inside `View`/`Page` throws).
127
- - Only `Text`, `Link`, and `PageNumber` are allowed inside `Text`.
128
- - `Image` is not allowed inside `Text`.
129
-
130
- User function components, `.map()` arrays, fragments, and conditional
131
- rendering (`null` / `false` / `undefined`) work exactly like normal React —
132
- they are evaluated and flattened during serialization.
133
-
134
- ---
135
-
136
- ## Styling
137
-
138
- `PDFStyle` is a loose camelCase record (`fontSize`, `flexDirection`,
139
- `marginTop`, …). Layout is the CSS **flex model only** — no grid, no float.
140
- Values: numbers are points; strings accept units (`'2cm'`, `'5mm'`, `'50%'`).
141
- `style` also accepts an array of styles.
142
-
143
- Text styles (`color`, `fontSize`, `fontFamily`, …) **inherit** through the
144
- tree, so defaults belong on `Page`:
18
+ 1. Build the tree with the markers of `@t4h.framework/pdf`.
19
+ 2. Call `render` and `await` it. It returns a `Binary`, not bytes.
20
+ 3. Pass the `Binary` to the next activity (upload, e-mail, return value).
145
21
 
146
22
  ```tsx
147
- <Page size='A4' style={{ padding: '2cm', fontSize: 12, color: '#00513a' }}>
23
+ import { Document, Page, Text, View, render } from '@t4h.framework/pdf'
24
+
25
+ const pdf = await render(
26
+ <Document title='Invoice'>
27
+ <Page size='A4' style={{ padding: '2cm', fontSize: 12 }}>
28
+ {items.map(item => (
29
+ <View key={item.id} style={{ flexDirection: 'row' }}>
30
+ <Text>{item.label}</Text>
31
+ </View>
32
+ ))}
33
+ </Page>
34
+ </Document>,
35
+ )
148
36
  ```
149
37
 
150
- Built-in fonts (no registration needed): Helvetica, Courier, Times-Roman —
151
- with `fontWeight: 'bold'` / `fontStyle: 'italic'` variants.
152
-
153
- ---
154
-
155
- ## Rendering in a workflow
38
+ Your own function components, fragments, `.map()` and conditionals work as in
39
+ React.
40
+
41
+ ## Traps
42
+
43
+ - Import `Document`, `Page`, `Text` and the other markers from
44
+ `@t4h.framework/pdf`, never from `@react-pdf/renderer`. A react-pdf component
45
+ in the tree throws a `TypeError`. Never call a marker as a function.
46
+ - One `Document` root with only `Page` children. Raw text only in `Text` or
47
+ `Link`. Only text, `Text`, `Link` and `PageNumber` inside `Text`.
48
+ - Never use `new RenderPDFActivity()` or extend it. The lint rule
49
+ `no-framework-activity-in-app` reports it. Use `render` for everything,
50
+ encryption included.
51
+ - The runtime must provide a `FileSystemClaim` (from `@t4h.framework/fs`).
52
+ With no provider, `render` throws `ClaimProviderNotFoundException`.
53
+ - Styles use the flex model only: no grid, no float. Numbers are points;
54
+ strings take units (`'2cm'`, `'50%'`). Put text defaults on `Page`: they
55
+ inherit.
56
+ - Use a `Binary` as `Image src` or font source for private files and for
57
+ stable replays. A URL is fetched at each render and cannot authenticate.
58
+ Images: PNG or JPEG.
59
+ - Fonts: TTF or WOFF, never WOFF2 (Google Fonts links often point to WOFF2).
60
+ - With `encrypt`, `render` returns `[original, encrypted]`. When `protection`
61
+ is omitted, only `ProtectionFlags.Print` is granted. Viewers honor the
62
+ permission flags, but they are not cryptographic: only the password
63
+ protects.
64
+
65
+ ## Fonts and encryption
156
66
 
157
67
  ```tsx
158
- import { Workflow } from '@t4h.framework/core'
159
- import { Document, Page, PageNumber, Text, View, render } from '@t4h.framework/pdf'
160
-
161
- function Header({ title }: { title: string }) {
162
- return (
163
- <View style={{ borderBottom: '1 solid #333', marginBottom: 16 }}>
164
- <Text style={{ fontSize: 18 }}>{title}</Text>
165
- </View>
166
- )
167
- }
168
-
169
- export const invoice = new Workflow({ id: 'invoice' }, async () => {
170
- const pdf = await render(
171
- <Document title='Invoice'>
172
- <Page size='A4' style={{ padding: '2cm', fontSize: 12 }}>
173
- <Header title='Invoice #42' />
174
- {items.map(item => (
175
- <View key={item.id} style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
176
- <Text>{item.label}</Text>
177
- <Text>{item.total}</Text>
178
- </View>
179
- ))}
180
- <PageNumber
181
- fixed
182
- format='{pageNumber}/{totalPages}'
183
- style={{ position: 'absolute', bottom: 24, right: '2cm' }}
184
- />
185
- </Page>
186
- </Document>,
187
- )
188
-
189
- // pdf is a Binary — pass it to other activities, e.g. an http form upload:
190
- // await http.post(url, { form: { file: pdf } })
191
- })
192
- ```
193
-
194
- The returned `Binary` exposes `contentType` (`application/pdf`),
195
- `contentLength`, and `stream()`.
196
-
197
- ---
198
-
199
- ## Images
200
-
201
- `Image src` accepts three shapes:
202
-
203
- - **URL string** — fetched by react-pdf at layout time. Simple, but the fetch
204
- happens on every render/replay and cannot authenticate.
205
- - **`data:` URI string** — for small assets bundled with the app.
206
- - **`Binary`** — the replay-safe choice for anything private or that must stay
207
- byte-identical across replays. The bytes are inlined as a `data:` URI on the
208
- activity side. Typical source: an `http` response body
209
- (`response.body.binary`) or any other claim-produced `Binary`.
210
-
211
- Supported formats: PNG and JPEG.
68
+ import { ProtectionPresets, render } from '@t4h.framework/pdf'
212
69
 
213
- ---
214
-
215
- ## Fonts
216
-
217
- `render(element, { fonts })` — an object keyed by **family name**. The value
218
- is either a bare source (registers the regular 400/normal variant) or an
219
- array of variants:
220
-
221
- ```tsx
222
- const pdf = await render(<Doc />, {
70
+ const [original, encrypted] = await render(<Invoice />, {
223
71
  fonts: {
224
- // bare source: string URL or Binary
225
- Inter: 'https://cdn.example.com/Inter-Regular.ttf',
226
- Geometric: fontResponse.body.binary,
227
-
228
- // multiple weights/styles under one family
229
- Roboto: [
230
- { src: robotoRegular.body.binary },
231
- { src: robotoBold.body.binary, weight: 700 },
232
- { src: robotoItalic.body.binary, style: 'italic' },
233
- ],
72
+ Roboto: [{ src: robotoRegular }, { src: robotoBold, weight: 700 }],
234
73
  },
74
+ encrypt: { password: '1234', protection: ProtectionPresets.ReadOnly },
235
75
  })
236
76
  ```
237
77
 
238
- Select variants in styles with `fontFamily` + `fontWeight` + `fontStyle`.
239
- Weights are `100–900`; styles `'normal' | 'italic'`.
240
-
241
- Rules of thumb:
242
-
243
- - **TTF and WOFF only** — react-pdf cannot parse WOFF2 (Google Fonts links
244
- often point to WOFF2; pick the TTF URL).
245
- - Prefer `Binary` for private/licensed fonts and replay stability; a URL is a
246
- mutable external reference fetched at layout time.
247
- - Fonts registered per render; same-family re-registration is safe.
248
-
249
- ---
250
-
251
- ## Encryption
252
-
253
- `render(element, { encrypt })` also persists a password-protected copy and
254
- resolves with an `[original, encrypted]` tuple — the return type narrows
255
- automatically:
78
+ ## Running footer
256
79
 
257
80
  ```tsx
258
- const [original, encrypted] = await render(<Invoice />, {
259
- encrypt: {
260
- password: customer.documentNumber,
261
- protection: ProtectionPresets.ReadOnly,
262
- },
263
- })
81
+ <PageNumber
82
+ fixed
83
+ format='{pageNumber}/{totalPages}'
84
+ style={{ position: 'absolute', bottom: 24, right: '2cm' }}
85
+ />
264
86
  ```
265
87
 
266
- - `password`: a bare string (same password opens and owns the file) or
267
- `{ user, owner }` for a distinct owner password that bypasses permission
268
- restrictions.
269
- - `protection`: a `ProtectionFlags` bitmask granted to whoever opens with the
270
- user password. Combine flags with `|` (`Print`, `Modify`, `CopyAndExtract`,
271
- `AnnotateAndFill`, `FillForms`, `ExtractForAccessibility`, `Assemble`,
272
- `PrintHighResolution`) or use a preset: `ProtectionPresets.ReadOnly`
273
- (view + print only — invoices, statements) or `ProtectionPresets.All`.
274
- - Permission flags are honored by PDF viewers, **not enforced
275
- cryptographically** — the open password is the only real protection.
276
- - Encryption is **only** available through `render`'s `encrypt` option. Never
277
- import from `src/tools/encrypt-pdf.js` — it is internal and not exported.
278
-
279
- ---
280
-
281
- ## Testing
88
+ ## Test
282
89
 
283
- Test the **workflow** with `TestWorkflowEnvironment` from
284
- `@t4h.framework/core/testing`, mocking the single claim the render activity
285
- uses: `FileSystemClaim`. See the **framework-workflow-testing** skill for the
286
- harness API. The render runs in a worker in tests too, so the first render in a
287
- test file pays for the thread starting up (around 400 ms).
90
+ Mock `FileSystemClaim.write`. It receives the path (`pdf/<id>.pdf`) and the
91
+ rendered `Buffer`; return any `Binary` stub. A class that extends `Binary` is
92
+ allowed in test files only.
288
93
 
289
94
  ```typescript
290
- import { Readable } from 'node:stream'
291
- import { Binary } from '@t4h.framework/core'
292
95
  import { TestWorkflowEnvironment, mockClaim } from '@t4h.framework/core/testing'
293
96
  import { FileSystemClaim } from '@t4h.framework/fs'
294
97
 
295
- class MockBinary extends Binary {
296
- public readonly contentType = 'application/pdf'
297
- public readonly contentLength: number
298
-
299
- constructor(private readonly data: Buffer) {
300
- super()
301
- this.contentLength = data.byteLength
302
- }
303
-
304
- public stream() {
305
- return Readable.from(this.data)
306
- }
307
- }
308
-
309
- const mockWrite = vi.fn().mockImplementation(async (_path, pdf: Buffer) => {
310
- return new MockBinary(pdf)
311
- })
312
-
98
+ const write = vi.fn(async (path: string, pdf: Buffer) => storedBinary)
313
99
  const env = TestWorkflowEnvironment.create({ now: 0 })
314
100
 
315
- await env.execute(workflow, input, {
316
- claims: [mockClaim(FileSystemClaim, { write: mockWrite, read: vi.fn() })],
101
+ await env.execute(invoice, undefined, {
102
+ claims: [mockClaim(FileSystemClaim, { write })],
317
103
  })
318
104
 
319
- // The activity hands the rendered buffer to fs.write — assert on it:
320
- const [path, pdf] = mockWrite.mock.calls[0]
321
- expect(path).toMatch(/^pdf\/.+\.pdf$/)
105
+ const [, pdf] = write.mock.calls[0]
322
106
  expect(pdf.subarray(0, 5).toString()).toBe('%PDF-')
323
107
  ```
324
108
 
325
- For helper-level tests (serialization, element mapping, fonts), see
326
- `src/helpers/__tests__/` — they assert on the `DocumentNode` JSON shape and on
327
- react-pdf element trees without rendering.
328
-
329
- ---
330
-
331
- ## Checklist for agents
109
+ The render runs in a worker thread, so the first render in a test file takes
110
+ about 400 ms.
332
111
 
333
- 1. In workflows, **always** use **`render()`** — never define, extend, or
334
- hand-instantiate `RenderPDFActivity`.
335
- 2. Build templates with the **marker components from this package** — never
336
- import `Document`/`Page`/etc. from `@react-pdf/renderer` in workflow code,
337
- and never call a marker as a function.
338
- 3. Wrap every raw string in **`Text`**; only `Text`/`Link`/`PageNumber` go
339
- inside `Text`; `Document` children are `Page` only.
340
- 4. Ensure the runtime provides **`FileSystemClaim`** (or mock it in tests) —
341
- the rendered PDF is persisted through it and returned as a `Binary`.
342
- 5. Prefer **`Binary`** sources for images and fonts that must be private or
343
- replay-stable; URLs are fetched at layout time on every render.
344
- 6. Fonts: object keyed by family, **TTF/WOFF only**, select variants via
345
- `fontFamily`/`fontWeight`/`fontStyle`.
346
- 7. Style with the **flex model** (`PDFStyle`, camelCase, points or unit
347
- strings); put inheritable text defaults on `Page`.
348
- 8. Use `fixed` + absolute positioning for running headers/footers and
349
- `PageNumber` for pagination stamps.
350
- 9. Password-protect PDFs **only** via `render`'s `encrypt` option — it
351
- returns `[original, encrypted]`. Never import the internal `encryptPDF`
352
- tool. Remember permission flags are viewer-honored, not cryptographic.
353
- 10. Test workflows with **`TestWorkflowEnvironment`** + **`mockClaim`**,
354
- asserting the `%PDF-` magic bytes on the `fs.write` call.
355
- 11. Do not document or import APIs not exported from `@t4h.framework/pdf`
356
- (the `helpers/` and `tools/` modules are internal).
112
+ ## Reference
357
113
 
358
- See also: **framework-workflow-testing** for the test harness;
359
- **framework-fs** for `FileSystemClaim`; **framework-http** for fetching
360
- `Binary` assets (images, fonts) used in templates.
114
+ - Guide: https://tech4humans-brasil.github.io/framework/pdf/
115
+ - `FileSystemClaim`: https://tech4humans-brasil.github.io/framework/fs/
116
+ - Workflow testing: https://tech4humans-brasil.github.io/framework/core/testing
117
+ - Types: `node_modules/@t4h.framework/pdf/dist/pdf.d.ts`
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @t4h.framework/pdf
2
2
 
3
+ ## 0.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#257](https://github.com/tech4humans-brasil/framework/pull/257) [`586bfb4`](https://github.com/tech4humans-brasil/framework/commit/586bfb4663f4a478527ee0c8db360603f034d615) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The pdf README is now short and links to the site, and the skill keeps only the traps and the default steps. The docs no longer describe a `PDF_RENDER_CONCURRENCY` variable, and they give the default `protection` of `encrypt`.
8
+
9
+ ## 0.4.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#241](https://github.com/tech4humans-brasil/framework/pull/241) [`f6b8454`](https://github.com/tech4humans-brasil/framework/commit/f6b845484d22e7c8e7240fe2e113f1cdea7c8ce3) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Adds seven rules to `@t4h.framework/core/eslint` and turns them on in `configs.recommended`:
14
+ - `no-io-in-workflow` reports `fetch` and calls to network, file, database and mail modules in a workflow and in the `constructor`, `toInput` and `toOutput` of an activity. It also reports `zlib` and `stream` calls there, because they work on the content in memory on each replay.
15
+ - `no-binary-subclass` reports a class that extends `Binary`.
16
+ - `no-framework-activity-in-app` reports `new` and `extends` on an activity of a framework package other than the core.
17
+ - `no-testing-import-in-source` reports an import of a `@t4h.framework/<package>/testing` entry out of a test file.
18
+ - `require-workflow-id` reports a `Workflow` with no `id`.
19
+ - `no-secret-to-string` reports a `Secret` that becomes a string.
20
+ - `no-literal-secret-in-authorization` reports a string literal in the `secret` or `clientSecret` field of an `Authorization`.
21
+
22
+ The package skills now name these rules in place of the text that the rules enforce. The docs and skills give each `Workflow` an `id`, read the HMAC secret from `EnvDesign`, and do not document a custom HTTP activity.
23
+
24
+ - [#240](https://github.com/tech4humans-brasil/framework/pull/240) [`0606115`](https://github.com/tech4humans-brasil/framework/commit/0606115e2e0baa994e9f0ed3559ee54ecac88e44) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The skills do not repeat a rule that a lint rule, `tsc` or a runtime error already enforces. Each such rule is now one line that names the gate. The examples that broke a gate (`process.env`, `as any`, an inline secret, an `EnvDesign` in a workflow file, `ref.output` before `wait()`) are correct now.
25
+
26
+ - [#228](https://github.com/tech4humans-brasil/framework/pull/228) [`d29e1ab`](https://github.com/tech4humans-brasil/framework/commit/d29e1ab29a039b13c3e4b075472bd615566ae75e) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Uses exact types and `unknown` in place of `any`, and checks external data with guards.
27
+ - harness: the fix-issues prompt lists each sensor as `- checkTypes: PASS`. Before, it printed `- 0: [object Object]`.
28
+ - hmac: an algorithm name such as `constructor` throws `Unsupported algorithm`.
29
+ - oidc: a discovery response with no `introspection_endpoint`, or a null introspection body, throws a clear error.
30
+ - `HttpRequestActivity.toOutput` takes `HttpRequestActivityOutput` in place of `any`.
31
+
3
32
  ## 0.4.5
4
33
 
5
34
  ## 0.4.4
package/README.md CHANGED
@@ -1,25 +1,18 @@
1
1
  # @t4h.framework/pdf
2
2
 
3
- Declarative PDF rendering for workflows. Build documents with JSX components, render them replay-safely through the workflow history, and get back a `Binary` persisted via the filesystem claim. Backed by [`@react-pdf/renderer`](https://react-pdf.org).
3
+ Declarative PDF rendering for T4H Framework workflows. You write the document
4
+ as JSX with the marker components of this package, and `render` gives back a
5
+ `Binary` that it stores through the `FileSystemClaim` of `@t4h.framework/fs`.
4
6
 
5
- ## Claim
7
+ ## Install
6
8
 
7
- ### FileSystemClaim
8
-
9
- The render activity persists the generated PDF through `FileSystemClaim` (from `@t4h.framework/fs`) and returns the resulting `Binary`. The runtime must provide a concrete implementation.
10
-
11
- ```typescript
12
- import { FileSystemClaim } from '@t4h.framework/fs'
13
-
14
- // the runtime provides this:
15
- // { provide: FileSystemClaim, value: new MyFileSystemClaimImpl() }
9
+ ```bash
10
+ npm install @t4h.framework/pdf
16
11
  ```
17
12
 
18
- ## Rendering
19
-
20
- ### render
13
+ Peer dependencies: `@t4h.framework/core` and `@t4h.framework/fs`.
21
14
 
22
- Renders a JSX tree to a PDF `Binary` through the workflow history. The tree is serialized into the history on the workflow side and rendered on the activity side, so the step is replay-safe.
15
+ ## Usage
23
16
 
24
17
  ```tsx
25
18
  import { Workflow } from '@t4h.framework/core'
@@ -34,146 +27,10 @@ export const invoice = new Workflow({ id: 'invoice' }, async () => {
34
27
  </Document>,
35
28
  )
36
29
 
37
- // pdf is a Binary — hand it to other activities, e.g. an upload:
38
- // await http.post(url, { form: { file: pdf } })
30
+ return pdf
39
31
  })
40
32
  ```
41
33
 
42
- The returned `Binary` exposes `contentType` (`application/pdf`), `contentLength`, and `stream()`.
43
-
44
- ## Components
45
-
46
- The components exported by this package are **markers**: type-safe JSX tags that only exist inside a tree passed to `render()`. They are never invoked as functions — calling one directly or rendering it with another renderer throws.
47
-
48
- | Component | Key props | Description |
49
- |-----------|-----------|-------------|
50
- | `Document` | `title`, `author`, `subject`, `language` | Root of the PDF. Children must be `Page` elements |
51
- | `Page` | `size` (default `A4`), `orientation`, `style`, `dpi` | A page. Overflowing content paginates automatically |
52
- | `View` | — | Flex container, analogous to a `<div>` |
53
- | `Text` | — | Text content. All raw strings must live inside a `Text` |
54
- | `Link` | `href` | Hyperlink |
55
- | `Image` | `src` | Image from a URL, `data:` URI, or `Binary` |
56
- | `PageNumber` | `format` | Text resolved to the current page number at layout time |
57
-
58
- Every node inside a page also accepts: `style`, `fixed` (repeat on every page), `break` (force a page break), `wrap` (allow splitting across pages, default `true`), and `minPresenceAhead`.
59
-
60
- User function components, `.map()` arrays, fragments, and conditional rendering work exactly like normal React:
61
-
62
- ```tsx
63
- function LineItem({ label, value }: { label: string; value: string }) {
64
- return (
65
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
66
- <Text>{label}</Text>
67
- <Text>{value}</Text>
68
- </View>
69
- )
70
- }
71
-
72
- const pdf = await render(
73
- <Document>
74
- <Page size='A4'>
75
- {items.map(item => (
76
- <LineItem key={item.id} {...item} />
77
- ))}
78
- {showFooter && <Text>Footer</Text>}
79
- </Page>
80
- </Document>,
81
- )
82
- ```
83
-
84
- Tree rules enforced at serialization (violations throw):
85
-
86
- - The tree must resolve to a single `Document` root, and `Document` children must be `Page` elements.
87
- - Raw text must be wrapped in `Text`.
88
- - Only `Text`, `Link`, and `PageNumber` are allowed inside `Text`.
89
-
90
- ## Styling
91
-
92
- Styles are camelCase records following the CSS **flex model** (no grid, no float). Numbers are points; strings accept units (`'2cm'`, `'5mm'`, `'50%'`). Text styles inherit through the tree, so defaults belong on `Page`.
93
-
94
- ```tsx
95
- <Page size='A4' style={{ padding: '2cm', fontSize: 12, color: '#00513a' }}>
96
- <View style={{ flexDirection: 'row', gap: 8 }}>
97
- <Text style={{ fontWeight: 'bold' }}>Bold</Text>
98
- <Text style={[{ fontSize: 10 }, { color: '#666' }]}>Small and gray</Text>
99
- </View>
100
- </Page>
101
- ```
102
-
103
- The standard PDF fonts (Helvetica, Courier, Times-Roman) are available with no registration, including `bold` and `italic` variants.
104
-
105
- ## Images
106
-
107
- `Image src` accepts a URL, a `data:` URI, or a `Binary` whose `contentType` is an image type (PNG or JPEG). Prefer `Binary` for anything private or that must stay byte-identical across replays — URLs are fetched at layout time on every render.
108
-
109
- ```tsx
110
- const logo = await http.get('https://cdn.example.com/logo.png')
111
-
112
- <Image src={logo.body.binary} style={{ width: 120 }} />
113
- ```
114
-
115
- ## Fonts
34
+ ## Documentation
116
35
 
117
- Register custom fonts per render with an object keyed by family name. Values are a bare source — a URL string or a `Binary` — for the regular variant, or an array of variants with `weight` / `style`. TTF and WOFF only (no WOFF2).
118
-
119
- ```tsx
120
- const pdf = await render(<Doc />, {
121
- fonts: {
122
- Inter: 'https://cdn.example.com/Inter-Regular.ttf',
123
- Roboto: [
124
- { src: robotoRegular.body.binary },
125
- { src: robotoBold.body.binary, weight: 700 },
126
- { src: robotoItalic.body.binary, style: 'italic' },
127
- ],
128
- },
129
- })
130
- ```
131
-
132
- Select variants in styles with `fontFamily`, `fontWeight` (`100–900`), and `fontStyle` (`'normal' | 'italic'`).
133
-
134
- Each variant reaches the process-wide font store once, keyed by family, weight, style and the file's digest, so passing `fonts` on every render costs nothing after the first.
135
-
136
- ## Encryption
137
-
138
- Pass `encrypt` to also persist a password-protected copy — `render` then resolves with an `[original, encrypted]` pair (the return type narrows automatically). `password` is a bare string or `{ user, owner }`; `protection` is a `ProtectionFlags` bitmask (defaults follow the viewer; use `ProtectionPresets.ReadOnly` for view-and-print documents). Permission flags are honored by viewers, not enforced cryptographically.
139
-
140
- The encrypted copy is written with pdfkit's own encryption (AES-128, PDF 1.6) from the layout the first render already produced, so neither a re-encryption pass over the finished file nor a second layout is paid for.
141
-
142
- ```tsx
143
- import { ProtectionPresets, render } from '@t4h.framework/pdf'
144
-
145
- const [original, encrypted] = await render(<Invoice />, {
146
- encrypt: { password: '12345678900', protection: ProtectionPresets.ReadOnly },
147
- })
148
- ```
149
-
150
- ## Page numbers
151
-
152
- `PageNumber` resolves at layout time. The `format` string may reference `{pageNumber}` and `{totalPages}`; combine with `fixed` and absolute positioning for running footers.
153
-
154
- ```tsx
155
- <PageNumber
156
- fixed
157
- format='{pageNumber}/{totalPages}'
158
- style={{ position: 'absolute', bottom: 24, right: '2cm' }}
159
- />
160
- ```
161
-
162
- ## Testing
163
-
164
- Test workflows with `TestWorkflowEnvironment` from `@t4h.framework/core/testing`, mocking `FileSystemClaim` — the rendered buffer is handed to `fs.write`, so assert on the `%PDF-` magic bytes there:
165
-
166
- ```typescript
167
- import { TestWorkflowEnvironment, mockClaim } from '@t4h.framework/core/testing'
168
- import { FileSystemClaim } from '@t4h.framework/fs'
169
-
170
- const mockWrite = vi.fn().mockImplementation(async (_path, pdf) => new MockBinary(pdf))
171
-
172
- const env = TestWorkflowEnvironment.create({ now: 0 })
173
-
174
- await env.execute(workflow, input, {
175
- claims: [mockClaim(FileSystemClaim, { write: mockWrite, read: vi.fn() })],
176
- })
177
-
178
- expect(mockWrite.mock.calls[0][1].subarray(0, 5).toString()).toBe('%PDF-')
179
- ```
36
+ https://tech4humans-brasil.github.io/framework/pdf/
@@ -2,7 +2,7 @@ function marker(name) {
2
2
  throw new Error(`<${name}> is a PDF marker component — it only exists inside a document ` +
3
3
  'tree passed to render() and cannot be invoked as a regular component');
4
4
  }
5
- /* eslint-disable @typescript-eslint/no-unused-vars */
5
+ /* eslint-disable @typescript-eslint/no-unused-vars -- Marker components keep props for their public types but never read them. */
6
6
  /** Root of a PDF. Children must be {@link Page} elements. */
7
7
  export function Document(props) {
8
8
  marker('Document');
@@ -37,5 +37,5 @@ export function Image(props) {
37
37
  export function PageNumber(props) {
38
38
  marker('PageNumber');
39
39
  }
40
- /* eslint-enable @typescript-eslint/no-unused-vars */
40
+ /* eslint-enable @typescript-eslint/no-unused-vars -- Marker components end here. */
41
41
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AA6BA,SAAS,MAAM,CAAC,IAAY;IAC1B,MAAM,IAAI,KAAK,CACb,IAAI,IAAI,iEAAiE;QACvE,sEA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AAA;AAChB,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,CAAC,MAAM,CAAC,CAAA;AAChB,CAAC;AAED,mBAAmB;AACnB,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,CAAC,MAAM,CAAC,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,KAAiB;IACrC,MAAM,CAAC,OAAO,CAAC,CAAA;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,CAAC,YAAY,CAAC,CAAA;AACtB,CAAC;AAED,oFAAoF"}
@@ -6,7 +6,7 @@ async function toTextChildren(children) {
6
6
  return [];
7
7
  if (typeof children === 'string')
8
8
  return [children];
9
- return Promise.all(children.map(child => typeof child === 'string' ? child : nodeToElement(child)));
9
+ return Promise.all(children.map(async (child) => typeof child === 'string' ? child : nodeToElement(child)));
10
10
  }
11
11
  const DEFAULT_PAGE_NUMBER_FORMAT = '{pageNumber}';
12
12
  async function nodeToElement(node) {
@@ -1 +1 @@
1
- {"version":3,"file":"document-to-element.js","sourceRoot":"","sources":["../../src/helpers/document-to-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EAAE,aAAa,EAA0C,MAAM,OAAO,CAAA;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAQ3D,KAAK,UAAU,cAAc,CAC3B,QAAmD;IAEnD,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAErC,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAEnD,OAAO,OAAO,CAAC,GAAG,CAChB,QAAQ,CAAC,GAAG,CAAC,KAAK,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
- {"version":3,"file":"element-to-document.d.ts","sourceRoot":"","sources":["../../src/helpers/element-to-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AAWnE,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,WAAW,CAAA;AA8JlB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CA0BrE"}
1
+ {"version":3,"file":"element-to-document.d.ts","sourceRoot":"","sources":["../../src/helpers/element-to-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AAWnE,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,WAAW,CAAA;AAiKlB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CA0BrE"}
@@ -28,8 +28,12 @@ function resolveChildren(node) {
28
28
  resolved.push(String(child));
29
29
  return;
30
30
  }
31
- if (Array.isArray(child))
32
- return child.forEach(item => visit(item));
31
+ if (Array.isArray(child)) {
32
+ child.forEach(item => {
33
+ visit(item);
34
+ });
35
+ return;
36
+ }
33
37
  if (isElement(child)) {
34
38
  if (child.type === Fragment) {
35
39
  visit(child.props.children);
@@ -62,9 +66,7 @@ function toTextChildren(children) {
62
66
  });
63
67
  }
64
68
  function nameOf(element) {
65
- return typeof element.type === 'function'
66
- ? element.type.name
67
- : String(element.type);
69
+ return typeof element.type === 'function' ? element.type.name : element.type;
68
70
  }
69
71
  function toPDFNode(element) {
70
72
  const { children, ...props } = element.props;
@@ -1 +1 @@
1
- {"version":3,"file":"element-to-document.js","sourceRoot":"","sources":["../../src/helpers/element-to-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqC,MAAM,OAAO,CAAA;AAEnE,OAAO,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,IAAI,GACL,MAAM,kBAAkB,CAAA;AAYzB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AAO,CAAC,KAAK,CAAC,CAsB7D;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,KAAK,iBA0D7C"}
@@ -5,12 +5,15 @@ import { Binary } from '@t4h.framework/core';
5
5
  import { materializeBinary, toDataUrl } from './materialize-binary.js';
6
6
  const FONT_CONTENT_TYPE = 'font/ttf';
7
7
  const registered = new Set();
8
+ function isVariantList(source) {
9
+ return Array.isArray(source);
10
+ }
8
11
  function toVariantKey(family, fontWeight, fontStyle, source) {
9
12
  const digest = createHash('sha256').update(source).digest('hex');
10
- return `${family}\0${fontWeight}\0${fontStyle}\0${digest}`;
13
+ return `${family}\0${String(fontWeight)}\0${fontStyle}\0${digest}`;
11
14
  }
12
15
  export async function resolveFonts(raw) {
13
- const families = await Promise.all(Object.entries(raw ?? {}).map(async ([name, source]) => {
16
+ const families = await Promise.all(Object.entries(raw).map(async ([name, source]) => {
14
17
  const variants = typeof source === 'string' || source instanceof Binary
15
18
  ? [{ src: source }]
16
19
  : source;
@@ -25,11 +28,11 @@ export async function resolveFonts(raw) {
25
28
  return Object.fromEntries(families);
26
29
  }
27
30
  export async function registerFonts(raw) {
28
- const fonts = await Promise.all(Object.entries(raw ?? {}).flatMap(([name, source]) => {
31
+ const fonts = await Promise.all(Object.entries(raw).flatMap(([name, source]) => {
29
32
  const variants = [];
30
33
  if (typeof source === 'string' || source instanceof Binary)
31
34
  variants.push({ src: source });
32
- if (Array.isArray(source))
35
+ if (isVariantList(source))
33
36
  variants.push(...source);
34
37
  return variants.map(async (variant) => {
35
38
  const src = typeof variant.src === 'string'
@@ -1 +1 @@
1
- {"version":3,"file":"register-fonts.js","sourceRoot":"","sources":["../../src/helpers/register-fonts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,MAA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ACxC,aAAa,EACb,YAAY,GAAG,cAAc,GAAG,eAAe,GAAG,aAAa,CAChE,CAAA;AASD,wBAAgB,aAAa,CAC3B,UAAU,EAAE,eAAe,GAC1B,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAmB3C;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,iBAAiB,GACzB,uBAAuB,CAczB"}
1
+ {"version":3,"file":"encrypt-pdf.d.ts","sourceRoot":"","sources":["../../src/tools/encrypt-pdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,oBAAY,eAAe;IACzB,KAAK,IAAI;IACT,MAAM,IAAI;IACV,cAAc,KAAK;IACnB,eAAe,KAAK;IACpB,SAAS,MAAM;IACf,uBAAuB,MAAM;IAC7B,QAAQ,OAAO;IACf,mBAAmB,OAAO;CAC3B;AAED,eAAO,MAAM,iBAAiB;;;CAcpB,CAAA;AAEV,KAAK,QAAQ,GACT,MAAM,GACN;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAEL,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,CAAC,EAAE,eAAe,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,aAAa,EACb,YAAY,GAAG,cAAc,GAAG,eAAe,GAAG,aAAa,CAChE,CAAA;AAmBD,wBAAgB,aAAa,CAC3B,UAAU,EAAE,eAAe,GAC1B,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAa3C;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,iBAAiB,GACzB,uBAAuB,CAczB"}
@@ -25,14 +25,16 @@ export const ProtectionPresets = {
25
25
  const ENCRYPTED_PDF_VERSION = '1.6';
26
26
  const DEFAULT_PROTECTION = ProtectionFlags.Print;
27
27
  const has = (protection, flag) => (protection & flag) === flag;
28
+ function toPrinting(protection) {
29
+ if (has(protection, ProtectionFlags.PrintHighResolution))
30
+ return 'highResolution';
31
+ if (has(protection, ProtectionFlags.Print))
32
+ return 'lowResolution';
33
+ return undefined;
34
+ }
28
35
  export function toPermissions(protection) {
29
- const printing = has(protection, ProtectionFlags.PrintHighResolution)
30
- ? 'highResolution'
31
- : has(protection, ProtectionFlags.Print)
32
- ? 'lowResolution'
33
- : undefined;
34
36
  return {
35
- printing,
37
+ printing: toPrinting(protection),
36
38
  modifying: has(protection, ProtectionFlags.Modify),
37
39
  copying: has(protection, ProtectionFlags.CopyAndExtract),
38
40
  annotating: has(protection, ProtectionFlags.AnnotateAndFill),
@@ -1 +1 @@
1
- {"version":3,"file":"encrypt-pdf.js","sourceRoot":"","sources":["../../src/tools/encrypt-pdf.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACzB,uDAAS,CAAA;IACT,yDAAU,CAAA;IACV,0EAAmB,CAAA;IACnB,4EAAoB,CAAA;IACpB,iEAAe,CAAA;IACf,6FAA6B,CAAA;IAC7B,gEAAe,CAAA;IACf,sFAA0B,CAAA;AAC5B,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EACN,eAAe,CAAC,KAAK;QACrB,eAAe,CAAC,mBAAmB;QACnC,eAAe,CAAC,uBAAuB;IACzC,GAAG,EACD,eAAe,CAAC,KAAK;QACrB,eAAe,CAAC,MAAM;QACtB,eAAe,CAAC,cAAc;QAC9B,eAAe,CAAC,eAAe;QAC/B,eAAe,CAAC,SAAS;QACzB,eAAe,CAAC,uBAAuB;QACvC,eAAe,CAAC,QAAQ;QACxB,eAAe,CAAC,mBAAmB;CAC7B,CAAA;AAmBV,MAAM,qBAAqB,GAAgC,KAAK,CAAA;AAEhE,MAAM,kBAAkB,GAAG,eAAe,CAAC,KAAK,CAAA;AAEhD,MAAM,G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AAU,CAAC,UAAU,CAAC;QAChC,SAAS,EAAE,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC;QAClD,OAAO,EAAE,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,cAAc,CAAC;QACxD,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,eAAe,CAAC;QAC5D,YAAY,EAAE,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,CAAC;QACxD,oBAAoB,EAAE,GAAG,CACvB,UAAU,EACV,eAAe,CAAC,uBAAuB,CACxC;QACD,gBAAgB,EAAE,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,QAAQ,CAAC;KAC5D,CAAA;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAA0B;IAE1B,MAAM,QAAQ,GACZ,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAClC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,QAAQ,EAAE;QACpC,CAAC,CAAC;YACE,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;YACnC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK;SACtC,CAAA;IAEP,OAAO;QACL,UAAU,EAAE,qBAAqB;QACjC,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,UAAU,IAAI,kBAAkB,CAAC;QACpE,GAAG,QAAQ;KACZ,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t4h.framework/pdf",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Declarative PDF rendering module for the T4H Framework",
5
5
  "homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/pdf",
6
6
  "bugs": "https://github.com/tech4humans-brasil/framework/issues",
@@ -26,14 +26,15 @@
26
26
  "scripts": {
27
27
  "build": "tsc --project tsconfig.build.json",
28
28
  "check-types": "tsc --noEmit",
29
- "lint": "eslint .",
29
+ "check-package": "publint --strict && attw --pack . --profile esm-only",
30
+ "lint": "eslint . --max-warnings 0",
30
31
  "prepublishOnly": "yarn build",
31
32
  "test": "vitest run",
32
33
  "test:watch": "vitest"
33
34
  },
34
35
  "devDependencies": {
35
- "@t4h.framework/core": "^0.19.0",
36
- "@t4h.framework/fs": "^0.13.0",
36
+ "@t4h.framework/core": "^0.21.0",
37
+ "@t4h.framework/fs": "^0.14.0",
37
38
  "@types/react": "^19.2.17",
38
39
  "muhammara": "^6.0.5",
39
40
  "typescript": "^5.9.3",