@t4h.framework/pdf 0.4.5 → 0.4.6
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/.ai/skills/framework-pdf/SKILL.md +31 -36
- package/CHANGELOG.md +23 -0
- package/dist/components.js +2 -2
- package/dist/components.js.map +1 -1
- package/dist/helpers/document-to-element.js +1 -1
- package/dist/helpers/document-to-element.js.map +1 -1
- package/dist/helpers/element-to-document.d.ts.map +1 -1
- package/dist/helpers/element-to-document.js +7 -5
- package/dist/helpers/element-to-document.js.map +1 -1
- package/dist/helpers/register-fonts.d.ts.map +1 -1
- package/dist/helpers/register-fonts.js +7 -4
- package/dist/helpers/register-fonts.js.map +1 -1
- package/dist/tools/encrypt-pdf.d.ts.map +1 -1
- package/dist/tools/encrypt-pdf.js +8 -6
- package/dist/tools/encrypt-pdf.js.map +1 -1
- package/package.json +5 -4
|
@@ -17,7 +17,7 @@ Package path: `framework/packages/pdf`. Peer dependencies:
|
|
|
17
17
|
`@t4h.framework/core`, `@t4h.framework/fs`. Regular dependencies: `react`,
|
|
18
18
|
`@react-pdf/renderer`.
|
|
19
19
|
|
|
20
|
-
Import surface
|
|
20
|
+
Import surface:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
23
|
import {
|
|
@@ -48,11 +48,9 @@ import {
|
|
|
48
48
|
} from '@t4h.framework/pdf'
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
> Workflows use **`render()`** — for everything, including encryption.
|
|
52
|
-
>
|
|
53
|
-
>
|
|
54
|
-
> `src/tools/` is internal and not exported — encryption always goes through
|
|
55
|
-
> `render`'s `encrypt` option.
|
|
51
|
+
> Workflows use **`render()`** — for everything, including encryption.
|
|
52
|
+
> `@t4h.framework/core/no-framework-activity-in-app` rejects `new` and
|
|
53
|
+
> `extends` on `RenderPDFActivity`.
|
|
56
54
|
|
|
57
55
|
## Architecture
|
|
58
56
|
|
|
@@ -101,8 +99,8 @@ Tests mock its `write` to return a `Binary` (see **Testing**).
|
|
|
101
99
|
|
|
102
100
|
The components exported by this package are **markers**: they exist only as
|
|
103
101
|
type-safe JSX tags inside a tree passed to `render()`. JSX never invokes
|
|
104
|
-
them — the serializer recognizes them by reference.
|
|
105
|
-
(`Image({ src })`)
|
|
102
|
+
them — the serializer recognizes them by reference. A marker called as a
|
|
103
|
+
function (`Image({ src })`) throws.
|
|
106
104
|
|
|
107
105
|
| Component | Props (beyond `NodeProps`) | Notes |
|
|
108
106
|
|-----------|---------------------------|-------|
|
|
@@ -119,13 +117,13 @@ every page — headers/footers), `break` (force page break before the node),
|
|
|
119
117
|
`wrap` (allow splitting across pages, default `true`), `minPresenceAhead`
|
|
120
118
|
(move to next page unless this many points remain — avoids orphaned headings).
|
|
121
119
|
|
|
122
|
-
**
|
|
120
|
+
**Valid tree.** `render()` throws a `TypeError` for a tree that breaks one
|
|
121
|
+
of these rules:
|
|
123
122
|
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
- `Image` is not allowed inside `Text`.
|
|
123
|
+
- One `Document` root, with only `Page` children.
|
|
124
|
+
- Raw text only inside `Text` or `Link`.
|
|
125
|
+
- Inside `Text`: only text, `Text`, `Link` and `PageNumber`.
|
|
126
|
+
- Inside `Page` and `View`: only the marker components of this package.
|
|
129
127
|
|
|
130
128
|
User function components, `.map()` arrays, fragments, and conditional
|
|
131
129
|
rendering (`null` / `false` / `undefined`) work exactly like normal React —
|
|
@@ -273,8 +271,7 @@ const [original, encrypted] = await render(<Invoice />, {
|
|
|
273
271
|
(view + print only — invoices, statements) or `ProtectionPresets.All`.
|
|
274
272
|
- Permission flags are honored by PDF viewers, **not enforced
|
|
275
273
|
cryptographically** — the open password is the only real protection.
|
|
276
|
-
- Encryption is
|
|
277
|
-
import from `src/tools/encrypt-pdf.js` — it is internal and not exported.
|
|
274
|
+
- Encryption is available only through `render`'s `encrypt` option.
|
|
278
275
|
|
|
279
276
|
---
|
|
280
277
|
|
|
@@ -330,30 +327,28 @@ react-pdf element trees without rendering.
|
|
|
330
327
|
|
|
331
328
|
## Checklist for agents
|
|
332
329
|
|
|
333
|
-
1. In workflows, **always** use **`render()
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
3.
|
|
339
|
-
|
|
340
|
-
4.
|
|
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
|
|
330
|
+
1. In workflows, **always** use **`render()`**.
|
|
331
|
+
2. Build templates with the **marker components from this package**.
|
|
332
|
+
`render()` throws a `TypeError` for a `@react-pdf/renderer` component, a
|
|
333
|
+
marker called as a function throws, and the **Valid tree** rules above
|
|
334
|
+
apply.
|
|
335
|
+
3. Provide **`FileSystemClaim`** in the runtime (or mock it in tests). A
|
|
336
|
+
missing provider throws `ClaimProviderNotFoundException`.
|
|
337
|
+
4. Prefer **`Binary`** sources for images and fonts that must be private or
|
|
343
338
|
replay-stable; URLs are fetched at layout time on every render.
|
|
344
|
-
|
|
339
|
+
5. Fonts: object keyed by family, **TTF/WOFF only**, select variants via
|
|
345
340
|
`fontFamily`/`fontWeight`/`fontStyle`.
|
|
346
|
-
|
|
341
|
+
6. Style with the **flex model** (`PDFStyle`, camelCase, points or unit
|
|
347
342
|
strings); put inheritable text defaults on `Page`.
|
|
348
|
-
|
|
343
|
+
7. Use `fixed` + absolute positioning for running headers/footers and
|
|
349
344
|
`PageNumber` for pagination stamps.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
345
|
+
8. Password-protect PDFs via `render`'s `encrypt` option — it returns
|
|
346
|
+
`[original, encrypted]`. Permission flags are viewer-honored, not
|
|
347
|
+
cryptographic.
|
|
348
|
+
9. Test workflows with **`TestWorkflowEnvironment`** + **`mockClaim`**,
|
|
349
|
+
asserting the `%PDF-` magic bytes on the `fs.write` call.
|
|
350
|
+
10. The package exports only its entry, so a deep import into `helpers/` or
|
|
351
|
+
`tools/` fails in `tsc`.
|
|
357
352
|
|
|
358
353
|
See also: **framework-workflow-testing** for the test harness;
|
|
359
354
|
**framework-fs** for `FileSystemClaim`; **framework-http** for fetching
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @t4h.framework/pdf
|
|
2
2
|
|
|
3
|
+
## 0.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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`:
|
|
8
|
+
- `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.
|
|
9
|
+
- `no-binary-subclass` reports a class that extends `Binary`.
|
|
10
|
+
- `no-framework-activity-in-app` reports `new` and `extends` on an activity of a framework package other than the core.
|
|
11
|
+
- `no-testing-import-in-source` reports an import of a `@t4h.framework/<package>/testing` entry out of a test file.
|
|
12
|
+
- `require-workflow-id` reports a `Workflow` with no `id`.
|
|
13
|
+
- `no-secret-to-string` reports a `Secret` that becomes a string.
|
|
14
|
+
- `no-literal-secret-in-authorization` reports a string literal in the `secret` or `clientSecret` field of an `Authorization`.
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
- [#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.
|
|
19
|
+
|
|
20
|
+
- [#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.
|
|
21
|
+
- harness: the fix-issues prompt lists each sensor as `- checkTypes: PASS`. Before, it printed `- 0: [object Object]`.
|
|
22
|
+
- hmac: an algorithm name such as `constructor` throws `Unsupported algorithm`.
|
|
23
|
+
- oidc: a discovery response with no `introspection_endpoint`, or a null introspection body, throws a clear error.
|
|
24
|
+
- `HttpRequestActivity.toOutput` takes `HttpRequestActivityOutput` in place of `any`.
|
|
25
|
+
|
|
3
26
|
## 0.4.5
|
|
4
27
|
|
|
5
28
|
## 0.4.4
|
package/dist/components.js
CHANGED
|
@@ -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
|
package/dist/components.js.map
CHANGED
|
@@ -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,sEAAsE,CACzE,CAAA;AACH,CAAC;AAED,
|
|
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,sEAAsE,CACzE,CAAA;AACH,CAAC;AAED,kIAAkI;AAElI,6DAA6D;AAC7D,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,MAAM,CAAC,UAAU,CAAC,CAAA;AACpB,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,CAAC,MAAM,CAAC,CAAA;AAChB,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,CAAC,MAAM,CAAC,CAAA;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,
|
|
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,IAA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AAY,EAAkB,MAAM,OAAO,CAAA;AAWnE,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,WAAW,CAAA;
|
|
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
|
-
|
|
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,CAA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AG,QAAQ,CAAA;AAE3C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,WAAW,EAAE,CAAA;CACpD,CAAA;
|
|
1
|
+
{"version":3,"file":"register-fonts.d.ts","sourceRoot":"","sources":["../../src/helpers/register-fonts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAI5C,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAE5E,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE3C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,WAAW,EAAE,CAAA;CACpD,CAAA;AAuBD,wBAAsB,YAAY,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,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
|
|
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
|
|
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 (
|
|
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,MAAM,EAAE,MAAM,qBAAqB,CAAA;A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,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QAEjC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,QAAQ;QACvC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAW,CAAC,CAAA;AACvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,GAAG,GAAG,CAAC,UAAkB,EAAE,
|
|
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,CAA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xD,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.
|
|
3
|
+
"version": "0.4.6",
|
|
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
|
-
"
|
|
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.
|
|
36
|
-
"@t4h.framework/fs": "^0.13.
|
|
36
|
+
"@t4h.framework/core": "^0.20.0",
|
|
37
|
+
"@t4h.framework/fs": "^0.13.1",
|
|
37
38
|
"@types/react": "^19.2.17",
|
|
38
39
|
"muhammara": "^6.0.5",
|
|
39
40
|
"typescript": "^5.9.3",
|