@formepdf/core 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -1
- package/package.json +5 -2
- package/pkg/forme_bg.wasm +0 -0
- package/pkg/package.json +1 -1
- package/pkg-node/forme_bg.wasm +0 -0
- package/pkg-node/package.json +1 -1
- package/pkg-web/forme_bg.wasm +0 -0
- package/pkg-web/package.json +1 -1
- package/scripts/render-template-layout.mjs +44 -0
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ export type ElementPosition = 'Relative' | 'Absolute';
|
|
|
37
37
|
* - `TableRow` / `TableCell` — NO `Table` wrapper (unwrapped by layout)
|
|
38
38
|
* - `List` + `ListItem` + `Lbl` — from `<OrderedList>` / `<UnorderedList>`
|
|
39
39
|
* - `FixedHeader` / `FixedFooter` — NO single `Fixed` (split by position)
|
|
40
|
+
* - `Bookmark` — zero-height marker from `bookmark` on a container, emitted
|
|
41
|
+
* on every container path (fits or overflowing) and the sole carrier of
|
|
42
|
+
* the outline entry
|
|
40
43
|
* - `TextLine` — leaf lines under `Text` blocks (holds `textContent`)
|
|
41
44
|
* - Inline `<Strong>`/`<Em>`/`<Code>`/`<Link>` do not appear here;
|
|
42
45
|
* they contribute style runs within `TextLine`
|
|
@@ -49,7 +52,7 @@ export type ElementPosition = 'Relative' | 'Absolute';
|
|
|
49
52
|
* never rendered"), on the exact drift risk this whole file exists
|
|
50
53
|
* to prevent.
|
|
51
54
|
*/
|
|
52
|
-
export type ElementNodeType = 'View' | 'Text' | 'TextLine' | 'H1' | 'H2' | 'H3' | 'H4' | 'H5' | 'H6' | 'TableRow' | 'TableCell' | 'List' | 'ListItem' | 'Lbl' | 'FixedHeader' | 'FixedFooter' | 'Image' | 'Svg' | 'QrCode' | 'Barcode' | 'Canvas' | 'Watermark' | 'BarChart' | 'LineChart' | 'PieChart' | 'AreaChart' | 'DotPlot' | 'TextField' | 'Checkbox' | 'Dropdown' | 'RadioButton';
|
|
55
|
+
export type ElementNodeType = 'View' | 'Text' | 'TextLine' | 'H1' | 'H2' | 'H3' | 'H4' | 'H5' | 'H6' | 'TableRow' | 'TableCell' | 'List' | 'ListItem' | 'Lbl' | 'FixedHeader' | 'FixedFooter' | 'Bookmark' | 'Image' | 'Svg' | 'QrCode' | 'Barcode' | 'Canvas' | 'Watermark' | 'BarChart' | 'LineChart' | 'PieChart' | 'AreaChart' | 'DotPlot' | 'TextField' | 'Checkbox' | 'Dropdown' | 'RadioButton';
|
|
53
56
|
/**
|
|
54
57
|
* Drawing kind for the node. Governs the PDF operator the serializer
|
|
55
58
|
* emits; NOT the same as `nodeType`, which describes semantic role.
|
|
@@ -128,6 +131,17 @@ export interface ElementStyleInfo {
|
|
|
128
131
|
* `TextLine` leaves.
|
|
129
132
|
* - `<PageBreak>` produces no node. It triggers a page break at
|
|
130
133
|
* layout time and is otherwise invisible.
|
|
134
|
+
* - `bookmark` on a container (`<View>`, `<Page>`, and bare `<ListItem>` /
|
|
135
|
+
* `<TableRow>` / `<TableCell>`) produces a zero-height `Bookmark` marker
|
|
136
|
+
* node (no rect, draws nothing) so the entry reaches the PDF outline.
|
|
137
|
+
* The marker is emitted whether or not the container overflows a page,
|
|
138
|
+
* and it is the ONLY element carrying that `bookmark` — one marker, one
|
|
139
|
+
* outline entry.
|
|
140
|
+
* Caveat: `bookmark` on a NON-container (`<Text>`, `<Image>`, `<Svg>`,
|
|
141
|
+
* charts, form fields) still rides on that node's own element, and rows
|
|
142
|
+
* or cells laid out inside a `<Table>` carry it on the row/cell element.
|
|
143
|
+
* So `Bookmark` nodes are not an exhaustive index of the document's
|
|
144
|
+
* bookmarks — scan the `bookmark` field for that.
|
|
131
145
|
*
|
|
132
146
|
* The runtime-conformance test in this package asserts every one of
|
|
133
147
|
* these transforms explicitly. If it breaks, update this JSDoc first.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formepdf/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "WASM-powered PDF rendering engine for Forme",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -59,17 +59,20 @@
|
|
|
59
59
|
"build:ts": "tsc",
|
|
60
60
|
"build": "npm run build:wasm && npm run build:ts",
|
|
61
61
|
"test": "vitest run",
|
|
62
|
+
"test:templates": "vitest run --config vitest.config.templates.ts",
|
|
62
63
|
"test:workers": "vitest run --config vitest.config.workers.ts",
|
|
63
64
|
"prepublishOnly": "npm run build && ./scripts/assert-tarball.sh"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
|
-
"@formepdf/react": "0.
|
|
67
|
+
"@formepdf/react": "0.13.0"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
70
|
"react": "^18 || ^19"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@cloudflare/vitest-pool-workers": "^0.12.21",
|
|
74
|
+
"@formepdf/templates": "0.13.0",
|
|
75
|
+
"@pdf-testkit/vitest": "^0.1.1",
|
|
73
76
|
"@types/node": "^22.0.0",
|
|
74
77
|
"@types/react": "^19.0.0",
|
|
75
78
|
"react": "^19.0.0",
|
package/pkg/forme_bg.wasm
CHANGED
|
Binary file
|
package/pkg/package.json
CHANGED
package/pkg-node/forme_bg.wasm
CHANGED
|
Binary file
|
package/pkg-node/package.json
CHANGED
package/pkg-web/forme_bg.wasm
CHANGED
|
Binary file
|
package/pkg-web/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render one shipped template and write its raw `LayoutInfo` JSON to disk.
|
|
3
|
+
*
|
|
4
|
+
* Exists for CI's "Document Regression Demo" job, which needs the *current*
|
|
5
|
+
* run as a file on disk to hand to @pdf-testkit/action. The vitest matcher
|
|
6
|
+
* compares in memory and never writes one, so this is the missing producer —
|
|
7
|
+
* deliberately the same two calls the regression suite makes (`getTemplate` +
|
|
8
|
+
* `renderDocumentWithLayout`), so the demo can't drift from what that suite
|
|
9
|
+
* asserts.
|
|
10
|
+
*
|
|
11
|
+
* `pdf-testkit snapshot` converts the LayoutInfo emitted here into the same
|
|
12
|
+
* StructuralSnapshot shape as the committed baselines.
|
|
13
|
+
*
|
|
14
|
+
* Usage: node scripts/render-template-layout.mjs <template-name> <out.json>
|
|
15
|
+
*/
|
|
16
|
+
import { writeFile } from 'node:fs/promises';
|
|
17
|
+
import { getTemplate } from '@formepdf/templates';
|
|
18
|
+
import * as schemas from '@formepdf/templates/schemas';
|
|
19
|
+
import { renderDocumentWithLayout } from '../dist/index.js';
|
|
20
|
+
|
|
21
|
+
const [name, out] = process.argv.slice(2);
|
|
22
|
+
if (!name || !out) {
|
|
23
|
+
console.error('usage: render-template-layout.mjs <template-name> <out.json>');
|
|
24
|
+
process.exit(2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const template = getTemplate(name);
|
|
28
|
+
if (!template) {
|
|
29
|
+
console.error(`getTemplate(${JSON.stringify(name)}) returned null`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Same `*Example` fixtures the regression suite uses. They're validated against
|
|
34
|
+
// their Zod schemas at import time, so they can't drift from the schemas.
|
|
35
|
+
const exampleKey = `${name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())}Example`;
|
|
36
|
+
const data = schemas[exampleKey];
|
|
37
|
+
if (!data) {
|
|
38
|
+
console.error(`No example fixture exported as "${exampleKey}" from @formepdf/templates/schemas`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { layout } = await renderDocumentWithLayout(template(data));
|
|
43
|
+
await writeFile(out, JSON.stringify(layout, null, 2) + '\n', 'utf8');
|
|
44
|
+
console.error(`wrote layout: ${out} (${layout.pages.length} page(s))`);
|