gutterpress 0.11.16 → 0.11.17-alpha.1

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.
Files changed (29) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/{build-8epzrj8g.js → build-jfjzam95.js} +4 -4
  3. package/dist/{cli-0prrt9e4.js → cli-0754wskb.js} +1 -1
  4. package/dist/{cli-ev175hx9.js → cli-ew3gc4nt.js} +138 -93
  5. package/dist/{cli-wqy8hnnh.js → cli-xx5bryh6.js} +7 -5
  6. package/dist/{cli-182j48xc.js → cli-zce1zcqc.js} +1 -1
  7. package/dist/cli.js +12 -12
  8. package/dist/{doctor-24mbx7y1.js → doctor-h01f71ws.js} +2 -2
  9. package/dist/engine/shared/synthesis.d.ts +8 -0
  10. package/dist/{engine-w17dbt4f.js → engine-aaam2nz3.js} +2 -2
  11. package/dist/{engine-j5h953pg.js → engine-rhmwgk9k.js} +1 -1
  12. package/dist/{ext-p9gx5aac.js → ext-ja4hy1c2.js} +4 -4
  13. package/dist/{gutterpress-viewer-swz6bwfa.js → gutterpress-viewer-5a6h4evk.js} +46 -5
  14. package/dist/{index-qep93v0z.js → index-3nk5mnn6.js} +7 -5
  15. package/dist/{index-ee7wp8q3.js → index-dmm31ys3.js} +1 -1
  16. package/dist/{index-40achhs8.js → index-r9t4acx5.js} +137 -90
  17. package/dist/index.js +3 -3
  18. package/dist/lib/markdown/assemble.d.ts +10 -0
  19. package/dist/lib/markdown/index.d.ts +10 -0
  20. package/dist/lib/static-serve.d.ts +6 -0
  21. package/dist/{new-wsjsrm7w.js → new-yzswp0ge.js} +4 -4
  22. package/dist/{preflight-0fjjnk9e.js → preflight-0s1vw6y1.js} +4 -4
  23. package/dist/preview/file-watcher.d.ts +5 -1
  24. package/dist/preview/server-context.d.ts +10 -0
  25. package/dist/{preview-azy06gw0.js → preview-tam7azsr.js} +4 -4
  26. package/dist/{publish-8db67m2h.js → publish-ra8kyf0z.js} +4 -4
  27. package/dist/render.js +2 -1
  28. package/dist/{validate-e7mw1xyd.js → validate-n9vae7p8.js} +4 -4
  29. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  build
3
- } from "./index-qep93v0z.js";
3
+ } from "./index-3nk5mnn6.js";
4
4
  import {
5
5
  BuildError
6
- } from "./index-ee7wp8q3.js";
6
+ } from "./index-dmm31ys3.js";
7
7
  import"./index-rzm1phg0.js";
8
8
  import"./index-37x76zdn.js";
9
9
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  build
3
- } from "./cli-wqy8hnnh.js";
3
+ } from "./cli-xx5bryh6.js";
4
4
  import {
5
5
  BuildError
6
6
  } from "./cli-46ycxe6r.js";
@@ -12,16 +12,16 @@ import {
12
12
  searchNpmExtensions,
13
13
  setExtensionEnabled,
14
14
  updateExtensions
15
- } from "./cli-ev175hx9.js";
16
- import"./cli-0prrt9e4.js";
15
+ } from "./cli-ew3gc4nt.js";
16
+ import"./cli-0754wskb.js";
17
17
  import {
18
18
  UsageError,
19
19
  exitForUsage,
20
20
  rejectExtraPositionals,
21
21
  rejectUnknownFlags,
22
22
  resolveProjectDir
23
- } from "./cli-182j48xc.js";
24
- import"./cli-wqy8hnnh.js";
23
+ } from "./cli-zce1zcqc.js";
24
+ import"./cli-xx5bryh6.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,
@@ -942,6 +943,11 @@
942
943
  return wrong;
943
944
  });
944
945
  }
946
+ function signaturePadding(pageCount, signature = 1, reserveLastPage = false) {
947
+ const size = signature > 1 ? signature : 1;
948
+ const padded = (size - pageCount % size) % size;
949
+ return padded === 0 && reserveLastPage ? size : padded;
950
+ }
945
951
  var WHICH_VALUES = new Set(["first", "start", "last", "first-except"]);
946
952
  function parseWhich(raw) {
947
953
  const w = (raw ?? "").trim();
@@ -1664,6 +1670,29 @@
1664
1670
  function blankPageIndices(strips) {
1665
1671
  return Array.from(document.querySelectorAll(".gp-recto-spacer")).map((el) => pageOf(el, strips));
1666
1672
  }
1673
+ function padToSignature(strips, contentPages) {
1674
+ for (const spacer of Array.from(document.querySelectorAll(".gp-pad-spacer")))
1675
+ spacer.remove();
1676
+ const data = document.documentElement.dataset;
1677
+ const count = signaturePadding(contentPages, Number(data.gpSignature) || 1, data.gpReserveLastPage !== undefined);
1678
+ const last = strips[strips.length - 1];
1679
+ if (!last || count === 0)
1680
+ return contentPages;
1681
+ const target = contentPages + count;
1682
+ let total = contentPages;
1683
+ for (let n = 0;n < count + 2 && total < target; n++) {
1684
+ const spacer = document.createElement("div");
1685
+ spacer.className = "gp-pad-spacer";
1686
+ spacer.setAttribute("aria-hidden", "true");
1687
+ spacer.style.cssText = "break-before: column; height: 0; margin: 0; padding: 0; border: 0;";
1688
+ last.el.appendChild(spacer);
1689
+ total = measure(strips).totalPages;
1690
+ }
1691
+ return total;
1692
+ }
1693
+ function pagesAfter(contentPages, totalPages) {
1694
+ return Array.from({ length: Math.max(0, totalPages - contentPages) }, (_, i) => contentPages + i);
1695
+ }
1667
1696
  function pageRangeOf(el, strips) {
1668
1697
  const strip = strips.find((s) => s.el.contains(el));
1669
1698
  if (!strip)
@@ -1714,7 +1743,8 @@
1714
1743
  if (blanks)
1715
1744
  measure(strips);
1716
1745
  const headers = opts.compensateHeaders === false ? { tables: 0, passes: 0, warnings: [] } : compensateRepeatedHeaders(strips);
1717
- const { totalPages } = measure(strips);
1746
+ const contentPages = measure(strips).totalPages;
1747
+ const totalPages = padToSignature(strips, contentPages);
1718
1748
  const api = {
1719
1749
  model,
1720
1750
  strips,
@@ -1722,13 +1752,14 @@
1722
1752
  warnings: [...new Set([...authoring, ...headers.warnings])],
1723
1753
  blankPages: blanks,
1724
1754
  blankPageIndices: blankPageIndices(strips),
1755
+ paddedPageIndices: pagesAfter(contentPages, totalPages),
1725
1756
  pageOf: (sel) => pageOf(typeof sel === "string" ? document.querySelector(sel) : sel, strips),
1726
1757
  pageRangeOf: (sel) => pageRangeOf(typeof sel === "string" ? document.querySelector(sel) : sel, strips),
1727
1758
  relayout: () => {
1728
1759
  restoreFullHeightPageRoots();
1729
1760
  restoreScrollContainers();
1730
1761
  unwrapStrips(strips);
1731
- for (const spacer of Array.from(document.querySelectorAll(".gp-recto-spacer")))
1762
+ for (const spacer of Array.from(document.querySelectorAll(".gp-recto-spacer, .gp-pad-spacer")))
1732
1763
  spacer.remove();
1733
1764
  const rebuilt = buildStrips(model, opts, authoring);
1734
1765
  strips.length = 0;
@@ -1742,9 +1773,12 @@
1742
1773
  api.warnings = [
1743
1774
  ...new Set([...authoring, ...compensateRepeatedHeaders(strips).warnings])
1744
1775
  ];
1776
+ const content = measure(strips).totalPages;
1777
+ padToSignature(strips, content);
1745
1778
  const r = measure(strips);
1746
1779
  api.totalPages = r.totalPages;
1747
1780
  api.blankPageIndices = blankPageIndices(strips);
1781
+ api.paddedPageIndices = pagesAfter(content, r.totalPages);
1748
1782
  return r;
1749
1783
  }
1750
1784
  };
@@ -2035,6 +2069,7 @@
2035
2069
  const model = layout.model;
2036
2070
  const sheets = new Map;
2037
2071
  let blankPages = new Set;
2072
+ let paddedPages = new Set;
2038
2073
  const warnings = [];
2039
2074
  const api = {
2040
2075
  redraw: () => draw(),
@@ -2052,6 +2087,10 @@
2052
2087
  if (document.body.dataset.designer === undefined)
2053
2088
  api.setDesigner(!!opts.designer);
2054
2089
  function pageContext(strip, indexInStrip2, bookIndex) {
2090
+ if (paddedPages.has(bookIndex)) {
2091
+ const { geometry: geometry2 } = resolvePage(model, { pseudos: [] });
2092
+ return { index: bookIndex, strip, pseudos: [], geometry: geometry2, marginBoxes: {}, decls: {}, padded: true };
2093
+ }
2055
2094
  if (blankPages.has(bookIndex)) {
2056
2095
  const pseudos2 = ["blank"];
2057
2096
  const { geometry: geometry2, marginBoxes: marginBoxes2, decls: decls2 } = resolvePage(model, { pseudos: pseudos2 });
@@ -2198,6 +2237,7 @@
2198
2237
  sheets.clear();
2199
2238
  warnings.length = 0;
2200
2239
  blankPages = new Set(layout.blankPageIndices);
2240
+ paddedPages = new Set(layout.paddedPageIndices);
2201
2241
  buildMaps();
2202
2242
  fillXrefs();
2203
2243
  let prevPageH = 0;
@@ -2228,11 +2268,12 @@
2228
2268
  sheet.style.setProperty("--gp-page-w", px(ctx.geometry.width));
2229
2269
  sheet.style.setProperty("--gp-page-h", px(ctx.geometry.height));
2230
2270
  applyPageBackground(sheet, ctx.decls);
2231
- for (const [prop, value] of canvasBg)
2232
- sheet.style.setProperty(prop, value);
2271
+ if (!ctx.padded)
2272
+ for (const [prop, value] of canvasBg)
2273
+ sheet.style.setProperty(prop, value);
2233
2274
  layer.appendChild(sheet);
2234
2275
  sheets.set(bookIndex, sheet);
2235
- drawMarginBoxes(sheet, ctx, layout.totalPages);
2276
+ drawMarginBoxes(sheet, ctx, layout.totalPages - paddedPages.size);
2236
2277
  drawGuides(sheet, ctx);
2237
2278
  drawCropMarks(sheet, ctx);
2238
2279
  }
@@ -3,7 +3,7 @@ import {
3
3
  isIgnoredMarginBoxProperty,
4
4
  marginBoxAlign,
5
5
  marginBoxRectPt
6
- } from "./index-ee7wp8q3.js";
6
+ } from "./index-dmm31ys3.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 signature = opts.signature && opts.signature > 1 ? opts.signature : 1;
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");
@@ -41,7 +41,7 @@ var preview_shell_default = "./preview-shell-xwn84kqr.js";
41
41
  var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
42
42
 
43
43
  // src/assets/engine/gutterpress-viewer.js
44
- var gutterpress_viewer_default = "./gutterpress-viewer-swz6bwfa.js";
44
+ var gutterpress_viewer_default = "./gutterpress-viewer-5a6h4evk.js";
45
45
 
46
46
  // src/assets/engine/gutterpress-agent.js
47
47
  var gutterpress_agent_default = "./gutterpress-agent-cazqstr1.js";