@segnavia/render 0.16.0 → 0.18.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/deck-pdf.js +17 -10
- package/package.json +4 -4
package/dist/deck-pdf.js
CHANGED
|
@@ -4,10 +4,13 @@ import { containFixedPageOverflow } from "./overflow-containment.js";
|
|
|
4
4
|
import { pdfPixelBox } from "./pdf-geometry.js";
|
|
5
5
|
import { composeImposedPdf, drawClippedPage, embedOnePage } from "./pdf-compose.js";
|
|
6
6
|
import { Imposition, fitPage, impose, pagePlacementLayout } from "@segnavia/format";
|
|
7
|
-
import { newNonce } from "@segnavia/frame/bridge";
|
|
8
|
-
import { htmlSlideDocument, notesLayoutGeometry, paginateNotes, printableDeck } from "@segnavia/frame/print-document";
|
|
7
|
+
import { PRINT_READY_ATTRIBUTE, newNonce } from "@segnavia/frame/bridge";
|
|
8
|
+
import { SLIDES_READY_DEADLINE_MS, htmlSlideDocument, notesLayoutGeometry, paginateNotes, printableDeck } from "@segnavia/frame/print-document";
|
|
9
9
|
import { fitImage, imageLayerStyles } from "@segnavia/frame/image-fit";
|
|
10
10
|
//#region src/deck-pdf.ts
|
|
11
|
+
async function waitForPrintReady(tab) {
|
|
12
|
+
await tab.locator(`html[${PRINT_READY_ATTRIBUTE}]`).waitFor({ timeout: SLIDES_READY_DEADLINE_MS }).catch(() => {});
|
|
13
|
+
}
|
|
11
14
|
function nameSlideError(error, id) {
|
|
12
15
|
if (error instanceof Error) {
|
|
13
16
|
error.message = `Slide "${id}" could not be rendered: ${error.message}`;
|
|
@@ -60,7 +63,8 @@ async function regularDeckPdf(deck, opts, services) {
|
|
|
60
63
|
const htmlSlides = deck.slides.flatMap((slide, index) => slide.content.kind === "html" ? [{
|
|
61
64
|
index,
|
|
62
65
|
id: slide.id,
|
|
63
|
-
html: slide.content.html
|
|
66
|
+
html: slide.content.html,
|
|
67
|
+
printAtMs: slide.printAtMs ?? 0
|
|
64
68
|
}] : []);
|
|
65
69
|
const css = `${services.fontFaces(opts)}${opts.css ?? ""}`;
|
|
66
70
|
const slideCss = containFixedPageOverflow(css);
|
|
@@ -89,18 +93,20 @@ async function regularDeckPdf(deck, opts, services) {
|
|
|
89
93
|
}, {
|
|
90
94
|
preferCSSPageSize: true,
|
|
91
95
|
printBackground: true
|
|
92
|
-
}), Promise.all(htmlSlides.map(async ({ index, id, html }) => {
|
|
96
|
+
}), Promise.all(htmlSlides.map(async ({ index, id, html, printAtMs }) => {
|
|
93
97
|
try {
|
|
94
98
|
return {
|
|
95
99
|
index,
|
|
96
100
|
bytes: await services.renderPdf({
|
|
97
101
|
viewport: deck.size,
|
|
98
|
-
scripts:
|
|
102
|
+
scripts: true,
|
|
99
103
|
html: htmlSlideDocument(deck, html, {
|
|
100
104
|
nonce: newNonce(),
|
|
101
|
-
css: slideCss
|
|
105
|
+
css: slideCss,
|
|
106
|
+
printAtMs
|
|
102
107
|
}),
|
|
103
|
-
boundMs: opts.boundMs
|
|
108
|
+
boundMs: opts.boundMs,
|
|
109
|
+
beforeOutput: waitForPrintReady
|
|
104
110
|
}, {
|
|
105
111
|
width: `${deck.size.width}px`,
|
|
106
112
|
height: `${deck.size.height}px`,
|
|
@@ -148,7 +154,8 @@ async function imposedDeckPdf(deck, imposition, opts, services) {
|
|
|
148
154
|
try {
|
|
149
155
|
const html = slide.content.kind === "html" ? htmlSlideDocument(deck, slide.content.html, {
|
|
150
156
|
nonce: newNonce(),
|
|
151
|
-
css
|
|
157
|
+
css,
|
|
158
|
+
printAtMs: slide.printAtMs ?? 0
|
|
152
159
|
}) : printableDeck(single, {
|
|
153
160
|
...opts,
|
|
154
161
|
layout: "slides",
|
|
@@ -159,10 +166,10 @@ async function imposedDeckPdf(deck, imposition, opts, services) {
|
|
|
159
166
|
index,
|
|
160
167
|
bytes: await services.renderPdf({
|
|
161
168
|
viewport: deck.size,
|
|
162
|
-
scripts:
|
|
169
|
+
scripts: true,
|
|
163
170
|
html,
|
|
164
171
|
boundMs: opts.boundMs,
|
|
165
|
-
beforeOutput: slide.content.kind === "image" ? placeRenderedImages : void 0
|
|
172
|
+
beforeOutput: slide.content.kind === "html" ? waitForPrintReady : slide.content.kind === "image" ? placeRenderedImages : void 0
|
|
166
173
|
}, {
|
|
167
174
|
width: `${deck.size.width}px`,
|
|
168
175
|
height: `${deck.size.height}px`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segnavia/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@segnavia/format": "0.
|
|
30
|
-
"@segnavia/frame": "0.
|
|
31
|
-
"@segnavia/html": "0.
|
|
29
|
+
"@segnavia/format": "0.18.0",
|
|
30
|
+
"@segnavia/frame": "0.18.0",
|
|
31
|
+
"@segnavia/html": "0.18.0",
|
|
32
32
|
"playwright-core": "1.55.1",
|
|
33
33
|
"pdf-lib": "^1.17.1"
|
|
34
34
|
}
|