gutterpress 0.11.16 → 0.11.17-alpha.2
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/api/index.js +2 -2
- package/dist/{build-8epzrj8g.js → build-1p999cmg.js} +4 -4
- package/dist/{cli-ev175hx9.js → cli-6z5zthzt.js} +138 -93
- package/dist/{cli-0prrt9e4.js → cli-70xgehq2.js} +1 -1
- package/dist/{cli-wqy8hnnh.js → cli-gymfg04q.js} +8 -6
- package/dist/{cli-182j48xc.js → cli-ppc0vz4b.js} +1 -1
- package/dist/cli.js +12 -12
- package/dist/{doctor-24mbx7y1.js → doctor-reqpnn3h.js} +2 -2
- package/dist/engine/shared/synthesis.d.ts +8 -0
- package/dist/{engine-j5h953pg.js → engine-078ggczp.js} +1 -1
- package/dist/{engine-w17dbt4f.js → engine-5jzhjjvv.js} +2 -2
- package/dist/{ext-p9gx5aac.js → ext-dsbfejt3.js} +4 -4
- package/dist/{gutterpress-viewer-swz6bwfa.js → gutterpress-viewer-zkv2stfy.js} +51 -6
- package/dist/{index-qep93v0z.js → index-5dcj1vts.js} +7 -5
- package/dist/{index-40achhs8.js → index-c275p061.js} +137 -90
- package/dist/{index-ee7wp8q3.js → index-eyaj6nkc.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/markdown/assemble.d.ts +10 -0
- package/dist/lib/markdown/index.d.ts +10 -0
- package/dist/lib/static-serve.d.ts +6 -0
- package/dist/{new-wsjsrm7w.js → new-m5y2wepr.js} +4 -4
- package/dist/{preflight-0fjjnk9e.js → preflight-bwpqwwny.js} +4 -4
- package/dist/preview/file-watcher.d.ts +5 -1
- package/dist/preview/server-context.d.ts +10 -0
- package/dist/{preview-azy06gw0.js → preview-62y7qhkp.js} +4 -4
- package/dist/{preview-interface-5wnzrvhf.js → preview-interface-c44qk17f.js} +7 -2
- package/dist/{publish-8db67m2h.js → publish-k2zyt3x6.js} +4 -4
- package/dist/render.js +2 -1
- package/dist/{validate-e7mw1xyd.js → validate-fgwwxtbn.js} +4 -4
- package/package.json +1 -1
|
@@ -34,6 +34,14 @@ export interface RectoSite {
|
|
|
34
34
|
* Page 1 is a recto; recto pages are odd.
|
|
35
35
|
*/
|
|
36
36
|
export declare function planRectoBlanks(sites: RectoSite[]): boolean[];
|
|
37
|
+
/**
|
|
38
|
+
* How many blank pages the build appends after `pageCount` content pages:
|
|
39
|
+
* enough to reach a multiple of `signature`, and — with `reserveLastPage` — a
|
|
40
|
+
* full extra signature when that would add none, so the last page is always a
|
|
41
|
+
* blank one (one page when `signature` <= 1). `postprocess.ts` pads the PDF by
|
|
42
|
+
* this and the viewer shows the same sheets, so their page counts agree.
|
|
43
|
+
*/
|
|
44
|
+
export declare function signaturePadding(pageCount: number, signature?: number, reserveLastPage?: boolean): number;
|
|
37
45
|
export type StringWhich = "first" | "start" | "last" | "first-except";
|
|
38
46
|
export interface StringEntry {
|
|
39
47
|
/** 1-based page the assignment lands on */
|
|
@@ -12,16 +12,16 @@ import {
|
|
|
12
12
|
searchNpmExtensions,
|
|
13
13
|
setExtensionEnabled,
|
|
14
14
|
updateExtensions
|
|
15
|
-
} from "./cli-
|
|
16
|
-
import"./cli-
|
|
15
|
+
} from "./cli-6z5zthzt.js";
|
|
16
|
+
import"./cli-70xgehq2.js";
|
|
17
17
|
import {
|
|
18
18
|
UsageError,
|
|
19
19
|
exitForUsage,
|
|
20
20
|
rejectExtraPositionals,
|
|
21
21
|
rejectUnknownFlags,
|
|
22
22
|
resolveProjectDir
|
|
23
|
-
} from "./cli-
|
|
24
|
-
import"./cli-
|
|
23
|
+
} from "./cli-ppc0vz4b.js";
|
|
24
|
+
import"./cli-gymfg04q.js";
|
|
25
25
|
import {
|
|
26
26
|
EXIT_CODES
|
|
27
27
|
} from "./cli-46ycxe6r.js";
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
rowStrideOf: () => rowStrideOf,
|
|
29
29
|
pageRangeOf: () => pageRangeOf,
|
|
30
30
|
pageOf: () => pageOf,
|
|
31
|
+
padToSignature: () => padToSignature,
|
|
31
32
|
measure: () => measure,
|
|
32
33
|
makeOverflowFragmentable: () => makeOverflowFragmentable,
|
|
33
34
|
loadStyleSources: () => loadStyleSources,
|
|
@@ -62,7 +63,11 @@
|
|
|
62
63
|
background: var(--gp-stage-bg);
|
|
63
64
|
margin: 0;
|
|
64
65
|
padding: 32px;
|
|
65
|
-
overflow
|
|
66
|
+
/* No \`overflow\` of its own. The page scrolls through the viewport, which
|
|
67
|
+
scrolls on its own. An \`overflow: auto\` here only ever reached the
|
|
68
|
+
viewport by propagation; once a host clips \`<html>\` (fit-to-width), it
|
|
69
|
+
stopped propagating and made the body a sideways scroller whose
|
|
70
|
+
scrollbars sit off-screen (#353). */
|
|
66
71
|
/* Standalone pages use \`--gutterpress-fit-zoom\`; embedded previews use the
|
|
67
72
|
host-owned \`--gutterpress-zoom\`. fitZoom() guarantees only one is active. */
|
|
68
73
|
--gp-zoom: calc(var(--gutterpress-zoom, 1) * var(--gutterpress-fit-zoom, 1));
|
|
@@ -942,6 +947,11 @@
|
|
|
942
947
|
return wrong;
|
|
943
948
|
});
|
|
944
949
|
}
|
|
950
|
+
function signaturePadding(pageCount, signature = 1, reserveLastPage = false) {
|
|
951
|
+
const size = signature > 1 ? signature : 1;
|
|
952
|
+
const padded = (size - pageCount % size) % size;
|
|
953
|
+
return padded === 0 && reserveLastPage ? size : padded;
|
|
954
|
+
}
|
|
945
955
|
var WHICH_VALUES = new Set(["first", "start", "last", "first-except"]);
|
|
946
956
|
function parseWhich(raw) {
|
|
947
957
|
const w = (raw ?? "").trim();
|
|
@@ -1664,6 +1674,29 @@
|
|
|
1664
1674
|
function blankPageIndices(strips) {
|
|
1665
1675
|
return Array.from(document.querySelectorAll(".gp-recto-spacer")).map((el) => pageOf(el, strips));
|
|
1666
1676
|
}
|
|
1677
|
+
function padToSignature(strips, contentPages) {
|
|
1678
|
+
for (const spacer of Array.from(document.querySelectorAll(".gp-pad-spacer")))
|
|
1679
|
+
spacer.remove();
|
|
1680
|
+
const data = document.documentElement.dataset;
|
|
1681
|
+
const count = signaturePadding(contentPages, Number(data.gpSignature) || 1, data.gpReserveLastPage !== undefined);
|
|
1682
|
+
const last = strips[strips.length - 1];
|
|
1683
|
+
if (!last || count === 0)
|
|
1684
|
+
return contentPages;
|
|
1685
|
+
const target = contentPages + count;
|
|
1686
|
+
let total = contentPages;
|
|
1687
|
+
for (let n = 0;n < count + 2 && total < target; n++) {
|
|
1688
|
+
const spacer = document.createElement("div");
|
|
1689
|
+
spacer.className = "gp-pad-spacer";
|
|
1690
|
+
spacer.setAttribute("aria-hidden", "true");
|
|
1691
|
+
spacer.style.cssText = "break-before: column; height: 0; margin: 0; padding: 0; border: 0;";
|
|
1692
|
+
last.el.appendChild(spacer);
|
|
1693
|
+
total = measure(strips).totalPages;
|
|
1694
|
+
}
|
|
1695
|
+
return total;
|
|
1696
|
+
}
|
|
1697
|
+
function pagesAfter(contentPages, totalPages) {
|
|
1698
|
+
return Array.from({ length: Math.max(0, totalPages - contentPages) }, (_, i) => contentPages + i);
|
|
1699
|
+
}
|
|
1667
1700
|
function pageRangeOf(el, strips) {
|
|
1668
1701
|
const strip = strips.find((s) => s.el.contains(el));
|
|
1669
1702
|
if (!strip)
|
|
@@ -1714,7 +1747,8 @@
|
|
|
1714
1747
|
if (blanks)
|
|
1715
1748
|
measure(strips);
|
|
1716
1749
|
const headers = opts.compensateHeaders === false ? { tables: 0, passes: 0, warnings: [] } : compensateRepeatedHeaders(strips);
|
|
1717
|
-
const
|
|
1750
|
+
const contentPages = measure(strips).totalPages;
|
|
1751
|
+
const totalPages = padToSignature(strips, contentPages);
|
|
1718
1752
|
const api = {
|
|
1719
1753
|
model,
|
|
1720
1754
|
strips,
|
|
@@ -1722,13 +1756,14 @@
|
|
|
1722
1756
|
warnings: [...new Set([...authoring, ...headers.warnings])],
|
|
1723
1757
|
blankPages: blanks,
|
|
1724
1758
|
blankPageIndices: blankPageIndices(strips),
|
|
1759
|
+
paddedPageIndices: pagesAfter(contentPages, totalPages),
|
|
1725
1760
|
pageOf: (sel) => pageOf(typeof sel === "string" ? document.querySelector(sel) : sel, strips),
|
|
1726
1761
|
pageRangeOf: (sel) => pageRangeOf(typeof sel === "string" ? document.querySelector(sel) : sel, strips),
|
|
1727
1762
|
relayout: () => {
|
|
1728
1763
|
restoreFullHeightPageRoots();
|
|
1729
1764
|
restoreScrollContainers();
|
|
1730
1765
|
unwrapStrips(strips);
|
|
1731
|
-
for (const spacer of Array.from(document.querySelectorAll(".gp-recto-spacer")))
|
|
1766
|
+
for (const spacer of Array.from(document.querySelectorAll(".gp-recto-spacer, .gp-pad-spacer")))
|
|
1732
1767
|
spacer.remove();
|
|
1733
1768
|
const rebuilt = buildStrips(model, opts, authoring);
|
|
1734
1769
|
strips.length = 0;
|
|
@@ -1742,9 +1777,12 @@
|
|
|
1742
1777
|
api.warnings = [
|
|
1743
1778
|
...new Set([...authoring, ...compensateRepeatedHeaders(strips).warnings])
|
|
1744
1779
|
];
|
|
1780
|
+
const content = measure(strips).totalPages;
|
|
1781
|
+
padToSignature(strips, content);
|
|
1745
1782
|
const r = measure(strips);
|
|
1746
1783
|
api.totalPages = r.totalPages;
|
|
1747
1784
|
api.blankPageIndices = blankPageIndices(strips);
|
|
1785
|
+
api.paddedPageIndices = pagesAfter(content, r.totalPages);
|
|
1748
1786
|
return r;
|
|
1749
1787
|
}
|
|
1750
1788
|
};
|
|
@@ -2035,6 +2073,7 @@
|
|
|
2035
2073
|
const model = layout.model;
|
|
2036
2074
|
const sheets = new Map;
|
|
2037
2075
|
let blankPages = new Set;
|
|
2076
|
+
let paddedPages = new Set;
|
|
2038
2077
|
const warnings = [];
|
|
2039
2078
|
const api = {
|
|
2040
2079
|
redraw: () => draw(),
|
|
@@ -2052,6 +2091,10 @@
|
|
|
2052
2091
|
if (document.body.dataset.designer === undefined)
|
|
2053
2092
|
api.setDesigner(!!opts.designer);
|
|
2054
2093
|
function pageContext(strip, indexInStrip2, bookIndex) {
|
|
2094
|
+
if (paddedPages.has(bookIndex)) {
|
|
2095
|
+
const { geometry: geometry2 } = resolvePage(model, { pseudos: [] });
|
|
2096
|
+
return { index: bookIndex, strip, pseudos: [], geometry: geometry2, marginBoxes: {}, decls: {}, padded: true };
|
|
2097
|
+
}
|
|
2055
2098
|
if (blankPages.has(bookIndex)) {
|
|
2056
2099
|
const pseudos2 = ["blank"];
|
|
2057
2100
|
const { geometry: geometry2, marginBoxes: marginBoxes2, decls: decls2 } = resolvePage(model, { pseudos: pseudos2 });
|
|
@@ -2198,6 +2241,7 @@
|
|
|
2198
2241
|
sheets.clear();
|
|
2199
2242
|
warnings.length = 0;
|
|
2200
2243
|
blankPages = new Set(layout.blankPageIndices);
|
|
2244
|
+
paddedPages = new Set(layout.paddedPageIndices);
|
|
2201
2245
|
buildMaps();
|
|
2202
2246
|
fillXrefs();
|
|
2203
2247
|
let prevPageH = 0;
|
|
@@ -2228,11 +2272,12 @@
|
|
|
2228
2272
|
sheet.style.setProperty("--gp-page-w", px(ctx.geometry.width));
|
|
2229
2273
|
sheet.style.setProperty("--gp-page-h", px(ctx.geometry.height));
|
|
2230
2274
|
applyPageBackground(sheet, ctx.decls);
|
|
2231
|
-
|
|
2232
|
-
|
|
2275
|
+
if (!ctx.padded)
|
|
2276
|
+
for (const [prop, value] of canvasBg)
|
|
2277
|
+
sheet.style.setProperty(prop, value);
|
|
2233
2278
|
layer.appendChild(sheet);
|
|
2234
2279
|
sheets.set(bookIndex, sheet);
|
|
2235
|
-
drawMarginBoxes(sheet, ctx, layout.totalPages);
|
|
2280
|
+
drawMarginBoxes(sheet, ctx, layout.totalPages - paddedPages.size);
|
|
2236
2281
|
drawGuides(sheet, ctx);
|
|
2237
2282
|
drawCropMarks(sheet, ctx);
|
|
2238
2283
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isIgnoredMarginBoxProperty,
|
|
4
4
|
marginBoxAlign,
|
|
5
5
|
marginBoxRectPt
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-eyaj6nkc.js";
|
|
7
7
|
import {
|
|
8
8
|
launchChromium
|
|
9
9
|
} from "./index-rzm1phg0.js";
|
|
@@ -633,6 +633,11 @@ function planRectoBlanks(sites) {
|
|
|
633
633
|
return wrong;
|
|
634
634
|
});
|
|
635
635
|
}
|
|
636
|
+
function signaturePadding(pageCount, signature = 1, reserveLastPage = false) {
|
|
637
|
+
const size = signature > 1 ? signature : 1;
|
|
638
|
+
const padded = (size - pageCount % size) % size;
|
|
639
|
+
return padded === 0 && reserveLastPage ? size : padded;
|
|
640
|
+
}
|
|
636
641
|
var WHICH_VALUES = new Set(["first", "start", "last", "first-except"]);
|
|
637
642
|
function parseWhich(raw) {
|
|
638
643
|
const w = (raw ?? "").trim();
|
|
@@ -1207,10 +1212,7 @@ async function postprocess(input, opts) {
|
|
|
1207
1212
|
g.media.width - inset,
|
|
1208
1213
|
g.media.height - inset
|
|
1209
1214
|
];
|
|
1210
|
-
const
|
|
1211
|
-
let padded = (signature - doc.getPageCount() % signature) % signature;
|
|
1212
|
-
if (padded === 0 && opts.reserveLastPage)
|
|
1213
|
-
padded = signature;
|
|
1215
|
+
const padded = signaturePadding(doc.getPageCount(), opts.signature, opts.reserveLastPage);
|
|
1214
1216
|
for (let i = 0;i < padded; i++)
|
|
1215
1217
|
doc.addPage([g.media.width, g.media.height]);
|
|
1216
1218
|
const wantMarks = opts.marks || g.marks.includes("crop") || g.marks.includes("cross");
|