@formepdf/cli 0.22.0 → 0.24.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/build.js +9 -1
- package/dist/dev.js +11 -1
- package/package.json +2 -2
package/dist/build.js
CHANGED
|
@@ -5,10 +5,18 @@ export async function buildPdf(inputPath, options) {
|
|
|
5
5
|
const absoluteInput = resolve(inputPath);
|
|
6
6
|
console.log(`Building ${absoluteInput}...`);
|
|
7
7
|
try {
|
|
8
|
-
const { pdf } = await renderFromFile(absoluteInput, {
|
|
8
|
+
const { pdf, warnings } = await renderFromFile(absoluteInput, {
|
|
9
|
+
dataPath: options.dataPath,
|
|
10
|
+
});
|
|
9
11
|
const outputPath = resolve(options.output);
|
|
10
12
|
await writeFile(outputPath, pdf);
|
|
11
13
|
console.log(`Written ${pdf.length} bytes to ${outputPath}`);
|
|
14
|
+
// Warnings are the engine telling you what it did that you didn't ask
|
|
15
|
+
// for — a flex row that serialized across a page break, a character with
|
|
16
|
+
// no glyph, a table column clamped below its content. Silence here is
|
|
17
|
+
// how a rendering compromise reaches a user as a mystery.
|
|
18
|
+
for (const w of warnings ?? [])
|
|
19
|
+
console.warn(` warning: ${w}`);
|
|
12
20
|
}
|
|
13
21
|
catch (err) {
|
|
14
22
|
const message = err instanceof Error ? err.message : String(err);
|
package/dist/dev.js
CHANGED
|
@@ -13,6 +13,7 @@ export function startDevServer(inputPath, options) {
|
|
|
13
13
|
let currentPdf = null;
|
|
14
14
|
let currentLayout = null;
|
|
15
15
|
let lastRenderTime = 0;
|
|
16
|
+
let lastWarnings = [];
|
|
16
17
|
let lastError = null;
|
|
17
18
|
let firstRender = true;
|
|
18
19
|
// Override state
|
|
@@ -76,6 +77,10 @@ export function startDevServer(inputPath, options) {
|
|
|
76
77
|
hasData: !!dataPath,
|
|
77
78
|
dataContent,
|
|
78
79
|
pageSizeOverride,
|
|
80
|
+
// The first render finishes before the browser is opened, so its
|
|
81
|
+
// warnings only ever arrive on `init`. Without this the badge stays
|
|
82
|
+
// empty until the user happens to save the file again.
|
|
83
|
+
warnings: lastWarnings,
|
|
79
84
|
};
|
|
80
85
|
if (ws.readyState === ws.OPEN) {
|
|
81
86
|
ws.send(JSON.stringify(initMsg));
|
|
@@ -134,6 +139,11 @@ export function startDevServer(inputPath, options) {
|
|
|
134
139
|
currentLayout = result.layout;
|
|
135
140
|
lastError = null;
|
|
136
141
|
lastRenderTime = result.renderTimeMs;
|
|
142
|
+
// The preview's warnings badge shipped complete — CSS, markup, element
|
|
143
|
+
// lookups — and this file never read `warnings`, so the flagship
|
|
144
|
+
// surface showed nothing while `forme build` and the VS Code panel
|
|
145
|
+
// both reported correctly.
|
|
146
|
+
lastWarnings = result.warnings ?? [];
|
|
137
147
|
const pageCount = result.layout?.pages?.length ?? 0;
|
|
138
148
|
if (firstRender) {
|
|
139
149
|
firstRender = false;
|
|
@@ -147,7 +157,7 @@ export function startDevServer(inputPath, options) {
|
|
|
147
157
|
else {
|
|
148
158
|
console.log(`Rebuilt in ${lastRenderTime}ms (${pageCount} page${pageCount !== 1 ? 's' : ''})`);
|
|
149
159
|
}
|
|
150
|
-
broadcast({ type: 'reload', renderTime: lastRenderTime });
|
|
160
|
+
broadcast({ type: 'reload', renderTime: lastRenderTime, warnings: lastWarnings });
|
|
151
161
|
}
|
|
152
162
|
catch (err) {
|
|
153
163
|
const message = err instanceof Error ? err.message : String(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formepdf/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "CLI for Forme PDF rendering engine — dev server with live preview and build command",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@formepdf/renderer": "0.
|
|
17
|
+
"@formepdf/renderer": "0.24.0",
|
|
18
18
|
"chokidar": "^4.0.0",
|
|
19
19
|
"ws": "^8.18.0",
|
|
20
20
|
"open": "^10.1.0"
|