gutterpress 0.11.18-alpha.2 → 0.11.18-alpha.4

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-se062swz.js → build-63nwjhzf.js} +4 -4
  3. package/dist/{cli-qp6dtsh3.js → cli-36v78t6w.js} +1 -1
  4. package/dist/{cli-161z4n0s.js → cli-5x7s8bap.js} +2 -2
  5. package/dist/{cli-yqpnksaa.js → cli-88hddvbz.js} +1 -1
  6. package/dist/{cli-0w3961p5.js → cli-dmcy8kay.js} +400 -44
  7. package/dist/cli.js +12 -12
  8. package/dist/{doctor-tkbdx8c1.js → doctor-n1cwrwx2.js} +2 -2
  9. package/dist/{engine-jkf4pxz9.js → engine-6zfj0jte.js} +1 -1
  10. package/dist/{engine-7gfr16t8.js → engine-zw8626be.js} +2 -2
  11. package/dist/{ext-kg8m8vda.js → ext-ddfjfcg4.js} +4 -4
  12. package/dist/{gutterpress-viewer-spq1ge52.js → gutterpress-viewer-k4mpqjh0.js} +57 -29
  13. package/dist/{index-bb2d1ev8.js → index-1ergtg60.js} +401 -45
  14. package/dist/{index-t3zxy69d.js → index-jt552wtf.js} +2 -2
  15. package/dist/{index-3x23by5j.js → index-qbd874dh.js} +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/lib/markdown/block-names.d.ts +82 -0
  18. package/dist/lib/markdown/renderer.d.ts +3 -2
  19. package/dist/lib/markdown/table-align.d.ts +32 -0
  20. package/dist/lib/printsafe.d.ts +1 -0
  21. package/dist/lib/unknown-classes.d.ts +12 -0
  22. package/dist/{manifest.schema-8m82f37q.json → manifest.schema-5pzhscqh.json} +1 -1
  23. package/dist/{new-w7q0n21v.js → new-ede0f1nm.js} +4 -4
  24. package/dist/{preflight-m54qsjs7.js → preflight-b6c3k3qt.js} +4 -4
  25. package/dist/{preview-bg3wxqxc.js → preview-y2dxxbrk.js} +4 -4
  26. package/dist/{publish-waps63wf.js → publish-n60n0hm1.js} +4 -4
  27. package/dist/render.js +199 -28
  28. package/dist/{validate-c9d8d656.js → validate-2c7sfyxn.js} +4 -4
  29. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  UsageError,
7
7
  package_default,
8
8
  rejectUnknownFlags
9
- } from "./cli-yqpnksaa.js";
9
+ } from "./cli-88hddvbz.js";
10
10
  import {
11
11
  EXIT_CODES
12
12
  } from "./cli-46ycxe6r.js";
@@ -18,14 +18,14 @@ import {
18
18
  import { defineCommand, parseArgs, runMain } from "citty";
19
19
  import { statSync } from "node:fs";
20
20
  var SUBCOMMANDS = {
21
- new: () => import("./new-w7q0n21v.js").then((m) => m.default),
22
- preview: () => import("./preview-bg3wxqxc.js").then((m) => m.default),
23
- build: () => import("./build-se062swz.js").then((m) => m.default),
24
- publish: () => import("./publish-waps63wf.js").then((m) => m.default),
25
- validate: () => import("./validate-c9d8d656.js").then((m) => m.default),
26
- preflight: () => import("./preflight-m54qsjs7.js").then((m) => m.default),
27
- doctor: () => import("./doctor-tkbdx8c1.js").then((m) => m.default),
28
- ext: () => import("./ext-kg8m8vda.js").then((m) => m.default)
21
+ new: () => import("./new-ede0f1nm.js").then((m) => m.default),
22
+ preview: () => import("./preview-y2dxxbrk.js").then((m) => m.default),
23
+ build: () => import("./build-63nwjhzf.js").then((m) => m.default),
24
+ publish: () => import("./publish-n60n0hm1.js").then((m) => m.default),
25
+ validate: () => import("./validate-2c7sfyxn.js").then((m) => m.default),
26
+ preflight: () => import("./preflight-b6c3k3qt.js").then((m) => m.default),
27
+ doctor: () => import("./doctor-n1cwrwx2.js").then((m) => m.default),
28
+ ext: () => import("./ext-ddfjfcg4.js").then((m) => m.default)
29
29
  };
30
30
  var VERSION = package_default.version;
31
31
  var main = defineCommand({
@@ -50,7 +50,7 @@ async function preflightRequiredInvocations(rawArgs) {
50
50
  const [command, ...commandArgs] = rawArgs;
51
51
  try {
52
52
  if (command === "new") {
53
- const { newArgs } = await import("./new-w7q0n21v.js");
53
+ const { newArgs } = await import("./new-ede0f1nm.js");
54
54
  rejectUnknownFlags(commandArgs, newArgs, "new");
55
55
  const parsed = parseArgs(commandArgs, {
56
56
  ...newArgs,
@@ -62,7 +62,7 @@ async function preflightRequiredInvocations(rawArgs) {
62
62
  return;
63
63
  }
64
64
  if (command === "preflight") {
65
- const { preflightArgs } = await import("./preflight-m54qsjs7.js");
65
+ const { preflightArgs } = await import("./preflight-b6c3k3qt.js");
66
66
  rejectUnknownFlags(commandArgs, preflightArgs, "preflight");
67
67
  const parsed = parseArgs(commandArgs, {
68
68
  ...preflightArgs,
@@ -82,7 +82,7 @@ async function preflightRequiredInvocations(rawArgs) {
82
82
  }
83
83
  if (subcommand.startsWith("-"))
84
84
  return;
85
- const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-kg8m8vda.js");
85
+ const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-ddfjfcg4.js");
86
86
  if (!EXT_SUBCOMMANDS.includes(subcommand)) {
87
87
  throw new UsageError(`gutterpress ext: unknown command "${subcommand}"`);
88
88
  }
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getSystemDiagnostics,
3
3
  log
4
- } from "./cli-qp6dtsh3.js";
4
+ } from "./cli-36v78t6w.js";
5
5
  import {
6
6
  UsageError,
7
7
  rejectExtraPositionals,
8
8
  rejectUnknownFlags
9
- } from "./cli-yqpnksaa.js";
9
+ } from "./cli-88hddvbz.js";
10
10
  import"./cli-46ycxe6r.js";
11
11
  import"./cli-7fkhgtfn.js";
12
12
  import"./cli-37x76zdn.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  build
3
- } from "./cli-161z4n0s.js";
3
+ } from "./cli-5x7s8bap.js";
4
4
  import {
5
5
  BuildError
6
6
  } from "./cli-46ycxe6r.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  build
3
- } from "./index-3x23by5j.js";
3
+ } from "./index-qbd874dh.js";
4
4
  import {
5
5
  BuildError
6
- } from "./index-t3zxy69d.js";
6
+ } from "./index-jt552wtf.js";
7
7
  import"./index-rzm1phg0.js";
8
8
  import"./index-37x76zdn.js";
9
9
 
@@ -12,17 +12,17 @@ import {
12
12
  searchNpmExtensions,
13
13
  setExtensionEnabled,
14
14
  updateExtensions
15
- } from "./cli-0w3961p5.js";
16
- import"./cli-qp6dtsh3.js";
15
+ } from "./cli-dmcy8kay.js";
16
+ import"./cli-36v78t6w.js";
17
17
  import {
18
18
  UsageError,
19
19
  exitForUsage,
20
20
  rejectExtraPositionals,
21
21
  rejectUnknownFlags,
22
22
  resolveProjectDir
23
- } from "./cli-yqpnksaa.js";
23
+ } from "./cli-88hddvbz.js";
24
24
  import"./cli-ht1bcqdd.js";
25
- import"./cli-161z4n0s.js";
25
+ import"./cli-5x7s8bap.js";
26
26
  import {
27
27
  EXIT_CODES
28
28
  } from "./cli-46ycxe6r.js";
@@ -19,6 +19,7 @@
19
19
  __export(exports_fragment, {
20
20
  wrapGeometry: () => wrapGeometry,
21
21
  waitForLayoutReady: () => waitForLayoutReady,
22
+ versoShiftPt: () => versoShiftPt,
22
23
  synthesizeColumnBreaks: () => synthesizeColumnBreaks,
23
24
  stripMetrics: () => stripMetrics,
24
25
  strideOf: () => strideOf,
@@ -108,13 +109,20 @@
108
109
  below is already sized to the run's full width and owns the actual
109
110
  clipping/visibility, so the strip does not need to. */
110
111
  .gp-strip {
112
+ /* Column pitch less the content width. \`--gp-verso-shift\` is set only on a
113
+ book with mirrored margins: decorate.ts slides each verso's sheet by it,
114
+ and growing the pitch by the same amount keeps the gap between a verso and
115
+ the recto it faces at the sheet gap (the gap across the page turn gets
116
+ twice the shift instead). Without it, it is 0px and nothing changes. */
117
+ --gp-col-gap: calc(
118
+ var(--gp-margin-right) + var(--gp-margin-left) + var(--gp-sheet-gap) +
119
+ var(--gp-verso-shift, 0px)
120
+ );
111
121
  position: relative;
112
122
  width: var(--gp-content-w);
113
123
  height: var(--gp-content-h);
114
124
  column-width: var(--gp-content-w);
115
- column-gap: calc(
116
- var(--gp-margin-right) + var(--gp-margin-left) + var(--gp-sheet-gap)
117
- );
125
+ column-gap: var(--gp-col-gap);
118
126
  column-fill: auto;
119
127
  overflow: visible;
120
128
  margin: 0;
@@ -176,9 +184,7 @@
176
184
  );
177
185
  width: calc(
178
186
  var(--gp-content-w) * var(--gp-wrap-cols, 2) +
179
- (
180
- var(--gp-margin-right) + var(--gp-margin-left) + var(--gp-sheet-gap)
181
- ) * (var(--gp-wrap-cols, 2) - 1)
187
+ var(--gp-col-gap) * (var(--gp-wrap-cols, 2) - 1)
182
188
  );
183
189
  }
184
190
 
@@ -334,15 +340,6 @@
334
340
  border: var(--gp-ov-w) var(--gp-ov-style) var(--gp-ov-color);
335
341
  }
336
342
 
337
- /* the PDF's own margins for this page, where they differ from where the
338
- preview lays the text (mirrored :left/:right, .gp-flush): fainter, dotted */
339
- .gp-ov-print {
340
- position: absolute;
341
- box-sizing: border-box;
342
- border: var(--gp-ov-w) dotted var(--gp-ov-color);
343
- opacity: 0.6;
344
- }
345
-
346
343
  /* bleed: a translucent band OUTSIDE the trim (its width is the border) */
347
344
  .gp-ov-bleed {
348
345
  position: absolute;
@@ -1475,6 +1472,13 @@
1475
1472
  }
1476
1473
  }
1477
1474
  function runPageBox(model, name, warnings = []) {
1475
+ const { right, agree, r, l } = pageSides(model, name);
1476
+ if (agree)
1477
+ return right;
1478
+ warnings.push(`@page :left and @page :right give ${name ? `the "${name}" page` : "this book"} ` + `different content areas (${l.w.toFixed(1)}×${l.h.toFixed(1)}pt vs ` + `${r.w.toFixed(1)}×${r.h.toFixed(1)}pt). Print alternates between them; the preview can ` + `only show one, so page breaks here may not match the PDF. Mirror the margins instead: ` + `swap which edge is wide and keep the total the same.`);
1479
+ return resolvePage(model, { name }).geometry;
1480
+ }
1481
+ function pageSides(model, name) {
1478
1482
  const right = resolvePage(model, { name, pseudos: ["right"] }).geometry;
1479
1483
  const left = resolvePage(model, { name, pseudos: ["left"] }).geometry;
1480
1484
  const box = (g) => ({
@@ -1483,10 +1487,23 @@
1483
1487
  });
1484
1488
  const r = box(right);
1485
1489
  const l = box(left);
1486
- if (Math.abs(r.w - l.w) < 0.01 && Math.abs(r.h - l.h) < 0.01)
1487
- return right;
1488
- warnings.push(`@page :left and @page :right give ${name ? `the "${name}" page` : "this book"} ` + `different content areas (${l.w.toFixed(1)}×${l.h.toFixed(1)}pt vs ` + `${r.w.toFixed(1)}×${r.h.toFixed(1)}pt). Print alternates between them; the preview can ` + `only show one, so page breaks here may not match the PDF. Mirror the margins instead: ` + `swap which edge is wide and keep the total the same.`);
1489
- return resolvePage(model, { name }).geometry;
1490
+ return {
1491
+ right,
1492
+ left,
1493
+ r,
1494
+ l,
1495
+ agree: Math.abs(r.w - l.w) < 0.01 && Math.abs(r.h - l.h) < 0.01
1496
+ };
1497
+ }
1498
+ function versoShiftPt(model, name, flushEdges = []) {
1499
+ const { right, left, agree } = pageSides(model, name);
1500
+ if (!agree)
1501
+ return 0;
1502
+ const r = flushMargins(right.margin, flushEdges);
1503
+ const l = flushMargins(left.margin, flushEdges);
1504
+ if (Math.abs(r.left + r.right - (l.left + l.right)) >= 0.01)
1505
+ return 0;
1506
+ return r.left - l.left;
1490
1507
  }
1491
1508
  function buildStrips(model, opts = {}, warnings = []) {
1492
1509
  const doc = document;
@@ -1512,6 +1529,10 @@
1512
1529
  strip.style.setProperty("--gp-margin-right", `${pt(margin.right)}px`);
1513
1530
  strip.style.setProperty("--gp-margin-bottom", `${pt(margin.bottom)}px`);
1514
1531
  strip.style.setProperty("--gp-margin-left", `${pt(margin.left)}px`);
1532
+ const rawShift = versoShiftPt(model, run.page, run.flushEdges);
1533
+ const versoShift = Math.abs(rawShift) >= 0.01 ? rawShift : 0;
1534
+ if (versoShift)
1535
+ strip.style.setProperty("--gp-verso-shift", `${pt(versoShift)}px`);
1515
1536
  run.nodes[0].before(strip);
1516
1537
  for (const n of run.nodes)
1517
1538
  strip.appendChild(n);
@@ -1520,6 +1541,7 @@
1520
1541
  page: run.page,
1521
1542
  geometry,
1522
1543
  flushEdges: run.flushEdges,
1544
+ versoShift,
1523
1545
  pages: 0,
1524
1546
  offset: 0
1525
1547
  });
@@ -2259,8 +2281,10 @@
2259
2281
  return out;
2260
2282
  }
2261
2283
  var OVERLAY_OFF = { on: false, issues: 0, intended: 0, bleedPt: 0 };
2262
- function marginsDiffer(a, b) {
2263
- return ["top", "right", "bottom", "left"].some((k) => Math.abs(a[k] - b[k]) > 0.5);
2284
+ function pageFrameMargin(margin, versoShift, side) {
2285
+ if (side === "recto" || !versoShift)
2286
+ return margin;
2287
+ return { ...margin, left: margin.left - versoShift, right: margin.right + versoShift };
2264
2288
  }
2265
2289
  function configInsetBleedPt() {
2266
2290
  const v = parseFloat(document.querySelector('meta[name="gp-inset-bleed"]')?.getAttribute("content") ?? "");
@@ -2328,9 +2352,6 @@
2328
2352
  }
2329
2353
  host.appendChild(marginTint(boxes));
2330
2354
  host.appendChild(div("gp-ov-margin", boxes.content));
2331
- if (marginsDiffer(p.printMargin, p.margin)) {
2332
- host.appendChild(div("gp-ov-print", pageBoxes(p.geometry, p.printMargin, 0, PX_PER_PT).content));
2333
- }
2334
2355
  layer.appendChild(host);
2335
2356
  painted.set(p.index, { host, boxes, sheet: p.sheet });
2336
2357
  }
@@ -2619,6 +2640,8 @@
2619
2640
  buildMaps();
2620
2641
  fillXrefs();
2621
2642
  let prevPageH = 0;
2643
+ let prevVersoShift = 0;
2644
+ let prevRunX = 0;
2622
2645
  let first = true;
2623
2646
  for (const strip of layout.strips) {
2624
2647
  const run = ensureRun(strip);
@@ -2635,12 +2658,13 @@
2635
2658
  const slot = i + shift;
2636
2659
  const row = Math.floor(slot / perRow);
2637
2660
  const colVisual = slot % perRow;
2638
- const sheetLeft = colVisual * stride;
2661
+ const side = bookIndex % 2 === 0 ? "recto" : "verso";
2662
+ const sheetLeft = colVisual * stride + (side === "verso" ? strip.versoShift * PX_PER_PT : 0);
2639
2663
  const sheetTop = row * rowStride;
2640
2664
  const sheet = document.createElement("div");
2641
2665
  sheet.className = "gp-sheet";
2642
2666
  sheet.dataset.page = String(bookIndex + 1);
2643
- sheet.dataset.side = bookIndex % 2 === 0 ? "recto" : "verso";
2667
+ sheet.dataset.side = side;
2644
2668
  sheet.style.left = `${sheetLeft}px`;
2645
2669
  sheet.style.top = `${sheetTop}px`;
2646
2670
  sheet.style.setProperty("--gp-page-w", px(ctx.geometry.width));
@@ -2659,15 +2683,19 @@
2659
2683
  sheet,
2660
2684
  strip,
2661
2685
  geometry: ctx.geometry,
2662
- printMargin: ctx.geometry.margin,
2663
- margin: ctx.padded || blankPages.has(bookIndex) ? ctx.geometry.margin : strip.flushEdges?.length ? flushMargins(g.margin, strip.flushEdges) : g.margin
2686
+ margin: ctx.padded || blankPages.has(bookIndex) ? ctx.geometry.margin : pageFrameMargin(flushMargins(g.margin, strip.flushEdges ?? []), strip.versoShift, side)
2664
2687
  });
2665
2688
  }
2666
2689
  const rows = Math.max(1, Math.ceil((strip.pages + shift) / perRow));
2667
2690
  run.style.height = `${rowStride * (rows - 1) + PX_PER_PT * g.height}px`;
2668
2691
  run.style.width = `${stride * perRow}px`;
2669
- run.style.marginTop = strip.wrapCols && shift === 1 && !first ? `${-(prevPageH + sheetGap)}px` : "";
2692
+ const composed = !!strip.wrapCols && shift === 1 && !first;
2693
+ run.style.marginTop = composed ? `${-(prevPageH + sheetGap)}px` : "";
2694
+ const runX = composed ? prevRunX + (prevVersoShift - strip.versoShift) * PX_PER_PT : 0;
2695
+ run.style.marginLeft = runX ? `${runX}px` : "";
2670
2696
  prevPageH = PX_PER_PT * g.height;
2697
+ prevVersoShift = strip.versoShift;
2698
+ prevRunX = runX;
2671
2699
  first = false;
2672
2700
  if (opts.designer)
2673
2701
  checkOverflow(strip, warnings);