gutterpress 0.11.17 → 0.11.18-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.
Files changed (29) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/{build-gxy185pv.js → build-se062swz.js} +4 -4
  3. package/dist/{cli-a4qtctrw.js → cli-0w3961p5.js} +15 -10
  4. package/dist/{cli-ycbg7mxk.js → cli-161z4n0s.js} +5 -5
  5. package/dist/{cli-zfgvssqz.js → cli-qp6dtsh3.js} +1 -1
  6. package/dist/{cli-8nw6d915.js → cli-yqpnksaa.js} +1 -1
  7. package/dist/cli.js +12 -12
  8. package/dist/{doctor-fygmzevd.js → doctor-tkbdx8c1.js} +2 -2
  9. package/dist/{engine-5d1rpxxq.js → engine-7gfr16t8.js} +2 -2
  10. package/dist/{engine-yf2w9hj7.js → engine-jkf4pxz9.js} +1 -1
  11. package/dist/{ext-c48s56jm.js → ext-kg8m8vda.js} +4 -4
  12. package/dist/{gutterpress-viewer-ez7k4ha7.js → gutterpress-viewer-spq1ge52.js} +365 -1
  13. package/dist/{index-09h3n36d.js → index-3x23by5j.js} +1 -1
  14. package/dist/{index-3k3fyrec.js → index-bb2d1ev8.js} +14 -9
  15. package/dist/{index-vmcfahe2.js → index-t3zxy69d.js} +5 -5
  16. package/dist/index.js +3 -3
  17. package/dist/lib/presets.d.ts +11 -0
  18. package/dist/{manifest.schema-gh0jjve9.json → manifest.schema-8m82f37q.json} +6 -0
  19. package/dist/{new-a9m2jwyy.js → new-w7q0n21v.js} +4 -4
  20. package/dist/{preflight-w3tnbtb8.js → preflight-m54qsjs7.js} +4 -4
  21. package/dist/preview/file-watcher.d.ts +4 -1
  22. package/dist/{preview-7z8tt0b4.js → preview-bg3wxqxc.js} +4 -4
  23. package/dist/{preview-bridge-8jhd1wpb.js → preview-bridge-evecsh4w.js} +5 -1
  24. package/dist/{preview-interface-c44qk17f.js → preview-interface-2n1d9pbf.js} +77 -1
  25. package/dist/{preview-shell-xwn84kqr.js → preview-shell-hyp7g158.js} +9 -0
  26. package/dist/{publish-bbftdxh2.js → publish-waps63wf.js} +4 -4
  27. package/dist/schema/manifest.types.d.ts +11 -0
  28. package/dist/{validate-x1ha1gqj.js → validate-c9d8d656.js} +4 -4
  29. package/package.json +1 -1
package/dist/api/index.js CHANGED
@@ -136,11 +136,11 @@ import {
136
136
  testRemoteAccess,
137
137
  updateExtensions,
138
138
  validateProjectExtensions
139
- } from "../index-3k3fyrec.js";
139
+ } from "../index-bb2d1ev8.js";
140
140
  import"../index-ht1bcqdd.js";
141
141
  import {
142
142
  BuildError
143
- } from "../index-vmcfahe2.js";
143
+ } from "../index-t3zxy69d.js";
144
144
  import {
145
145
  DEFAULT_PRINT_OPTS,
146
146
  assertMilestone,
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  runBuild,
3
3
  splitOutPath
4
- } from "./cli-a4qtctrw.js";
4
+ } from "./cli-0w3961p5.js";
5
5
  import {
6
6
  log
7
- } from "./cli-zfgvssqz.js";
7
+ } from "./cli-qp6dtsh3.js";
8
8
  import {
9
9
  UsageError,
10
10
  parseFormat,
11
11
  parsePdfxFlavor,
12
12
  rejectExtraPositionals,
13
13
  rejectUnknownFlags
14
- } from "./cli-8nw6d915.js";
14
+ } from "./cli-yqpnksaa.js";
15
15
  import"./cli-ht1bcqdd.js";
16
- import"./cli-ycbg7mxk.js";
16
+ import"./cli-161z4n0s.js";
17
17
  import {
18
18
  BuildError
19
19
  } from "./cli-46ycxe6r.js";
@@ -13,12 +13,12 @@ import {
13
13
  stampCreator,
14
14
  stripAnnotations,
15
15
  warn
16
- } from "./cli-zfgvssqz.js";
16
+ } from "./cli-qp6dtsh3.js";
17
17
  import {
18
18
  DEBOUNCE,
19
19
  UsageError,
20
20
  resolvePort
21
- } from "./cli-8nw6d915.js";
21
+ } from "./cli-yqpnksaa.js";
22
22
  import {
23
23
  blackTextToGray
24
24
  } from "./cli-ht1bcqdd.js";
@@ -27,7 +27,7 @@ import {
27
27
  getAssetPath,
28
28
  getAssetsDir,
29
29
  lastPageMode
30
- } from "./cli-ycbg7mxk.js";
30
+ } from "./cli-161z4n0s.js";
31
31
  import {
32
32
  BuildError,
33
33
  EXIT_CODES
@@ -120,7 +120,8 @@ var DTRPG_PRESET = {
120
120
  page: {
121
121
  width: 621,
122
122
  height: 810,
123
- tolerance: 0.5
123
+ tolerance: 0.5,
124
+ bleed: 9
124
125
  },
125
126
  ink: {
126
127
  maxTac: 240,
@@ -196,7 +197,8 @@ var BOOK_PRESET = {
196
197
  page: {
197
198
  width: 432,
198
199
  height: 648,
199
- tolerance: 0.5
200
+ tolerance: 0.5,
201
+ bleed: undefined
200
202
  },
201
203
  ink: {
202
204
  maxTac: 400,
@@ -543,7 +545,8 @@ function resolveCustomPage(c, m) {
543
545
  return {
544
546
  width,
545
547
  height,
546
- tolerance: c.page?.tolerance ?? m.page?.tolerance ?? 0.5
548
+ tolerance: c.page?.tolerance ?? m.page?.tolerance ?? 0.5,
549
+ bleed: c.page?.bleed ?? m.page?.bleed
547
550
  };
548
551
  }
549
552
  function resolveWithPreset(cliOverrides, manifest, preset) {
@@ -9723,7 +9726,7 @@ class PdfOutput {
9723
9726
  const rawPdf = pdfxMode ? path13.join(stage, "raw.pdf") : path13.resolve(pdfFile);
9724
9727
  await fsp2.mkdir(path13.dirname(path13.resolve(pdfFile)), { recursive: true });
9725
9728
  log.info("Rendering HTML to PDF via the Gutterpress engine (native Chromium pagination)");
9726
- const { buildNativePdf } = await import("./engine-yf2w9hj7.js");
9729
+ const { buildNativePdf } = await import("./engine-jkf4pxz9.js");
9727
9730
  const engineDiagnostics = await buildNativePdf(htmlFile, rawPdf, {
9728
9731
  title: config.title,
9729
9732
  author: config.authors.length > 0 ? config.authors.join(", ") : undefined,
@@ -9974,8 +9977,10 @@ async function renderPreviewBook(inputPath, config, opts) {
9974
9977
  }
9975
9978
  });
9976
9979
  }
9977
- function injectPreviewScripts(html) {
9978
- const scripts = ` <script src="/engine/gutterpress-viewer.js"></script>
9980
+ function injectPreviewScripts(html, insetBleedPt = 0) {
9981
+ const meta = insetBleedPt > 0 ? ` <meta name="gp-inset-bleed" content="${insetBleedPt}">
9982
+ ` : "";
9983
+ const scripts = meta + ` <script src="/engine/gutterpress-viewer.js"></script>
9979
9984
  ` + `<script src="/preview/scripts/preview-interface.js"></script>
9980
9985
  ` + `<script src="/preview/scripts/preview-bridge.js"></script>
9981
9986
  `;
@@ -10009,7 +10014,7 @@ async function generateAndWriteHtml(inputPath, tempDir, config, cssAssets, image
10009
10014
  for (const ref of nextImageRefs)
10010
10015
  imageRefs.add(ref);
10011
10016
  }
10012
- await fsp3.writeFile(path15.join(tempDir, BOOK_HTML_FILENAME), injectPreviewScripts(html), "utf-8");
10017
+ await fsp3.writeFile(path15.join(tempDir, BOOK_HTML_FILENAME), injectPreviewScripts(html, config.page?.bleed), "utf-8");
10013
10018
  }
10014
10019
  function isDotPathUnderRoot(candidatePath, root) {
10015
10020
  const normalizedRoot = root.replace(/\\/g, "/").replace(/\/+$/, "");
@@ -1116,22 +1116,22 @@ import { fileURLToPath } from "node:url";
1116
1116
  var favicon_default = "./favicon-272ga6y0.ico";
1117
1117
 
1118
1118
  // src/assets/manifest.schema.json
1119
- var manifest_schema_default = "./manifest.schema-gh0jjve9.json";
1119
+ var manifest_schema_default = "./manifest.schema-8m82f37q.json";
1120
1120
 
1121
1121
  // src/assets/preview/scripts/preview-interface.js
1122
- var preview_interface_default = "./preview-interface-c44qk17f.js";
1122
+ var preview_interface_default = "./preview-interface-2n1d9pbf.js";
1123
1123
 
1124
1124
  // src/assets/preview/scripts/preview-bridge.js
1125
- var preview_bridge_default = "./preview-bridge-8jhd1wpb.js";
1125
+ var preview_bridge_default = "./preview-bridge-evecsh4w.js";
1126
1126
 
1127
1127
  // src/assets/preview/scripts/preview-shell.js
1128
- var preview_shell_default = "./preview-shell-xwn84kqr.js";
1128
+ var preview_shell_default = "./preview-shell-hyp7g158.js";
1129
1129
 
1130
1130
  // profiles/CGATS21_CRPC1.icc
1131
1131
  var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
1132
1132
 
1133
1133
  // src/assets/engine/gutterpress-viewer.js
1134
- var gutterpress_viewer_default = "./gutterpress-viewer-ez7k4ha7.js";
1134
+ var gutterpress_viewer_default = "./gutterpress-viewer-spq1ge52.js";
1135
1135
 
1136
1136
  // src/assets/engine/gutterpress-agent.js
1137
1137
  var gutterpress_agent_default = "./gutterpress-agent-cazqstr1.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./cli-8nw6d915.js";
3
+ } from "./cli-yqpnksaa.js";
4
4
  import {
5
5
  execCapture,
6
6
  findTool,
@@ -4,7 +4,7 @@ import {
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "gutterpress",
7
- version: "0.11.17",
7
+ version: "0.11.18-alpha.2",
8
8
  description: "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
9
9
  author: "itlackey",
10
10
  license: "MPL-2.0",
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  UsageError,
7
7
  package_default,
8
8
  rejectUnknownFlags
9
- } from "./cli-8nw6d915.js";
9
+ } from "./cli-yqpnksaa.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-a9m2jwyy.js").then((m) => m.default),
22
- preview: () => import("./preview-7z8tt0b4.js").then((m) => m.default),
23
- build: () => import("./build-gxy185pv.js").then((m) => m.default),
24
- publish: () => import("./publish-bbftdxh2.js").then((m) => m.default),
25
- validate: () => import("./validate-x1ha1gqj.js").then((m) => m.default),
26
- preflight: () => import("./preflight-w3tnbtb8.js").then((m) => m.default),
27
- doctor: () => import("./doctor-fygmzevd.js").then((m) => m.default),
28
- ext: () => import("./ext-c48s56jm.js").then((m) => m.default)
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)
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-a9m2jwyy.js");
53
+ const { newArgs } = await import("./new-w7q0n21v.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-w3tnbtb8.js");
65
+ const { preflightArgs } = await import("./preflight-m54qsjs7.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-c48s56jm.js");
85
+ const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-kg8m8vda.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-zfgvssqz.js";
4
+ } from "./cli-qp6dtsh3.js";
5
5
  import {
6
6
  UsageError,
7
7
  rejectExtraPositionals,
8
8
  rejectUnknownFlags
9
- } from "./cli-8nw6d915.js";
9
+ } from "./cli-yqpnksaa.js";
10
10
  import"./cli-46ycxe6r.js";
11
11
  import"./cli-7fkhgtfn.js";
12
12
  import"./cli-37x76zdn.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  build
3
- } from "./index-09h3n36d.js";
3
+ } from "./index-3x23by5j.js";
4
4
  import {
5
5
  BuildError
6
- } from "./index-vmcfahe2.js";
6
+ } from "./index-t3zxy69d.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-ycbg7mxk.js";
3
+ } from "./cli-161z4n0s.js";
4
4
  import {
5
5
  BuildError
6
6
  } from "./cli-46ycxe6r.js";
@@ -12,17 +12,17 @@ import {
12
12
  searchNpmExtensions,
13
13
  setExtensionEnabled,
14
14
  updateExtensions
15
- } from "./cli-a4qtctrw.js";
16
- import"./cli-zfgvssqz.js";
15
+ } from "./cli-0w3961p5.js";
16
+ import"./cli-qp6dtsh3.js";
17
17
  import {
18
18
  UsageError,
19
19
  exitForUsage,
20
20
  rejectExtraPositionals,
21
21
  rejectUnknownFlags,
22
22
  resolveProjectDir
23
- } from "./cli-8nw6d915.js";
23
+ } from "./cli-yqpnksaa.js";
24
24
  import"./cli-ht1bcqdd.js";
25
- import"./cli-ycbg7mxk.js";
25
+ import"./cli-161z4n0s.js";
26
26
  import {
27
27
  EXIT_CODES
28
28
  } from "./cli-46ycxe6r.js";
@@ -34,7 +34,9 @@
34
34
  loadStyleSources: () => loadStyleSources,
35
35
  injectViewerCss: () => injectViewerCss,
36
36
  injectBreakMapping: () => injectBreakMapping,
37
+ indexInStrip: () => indexInStrip,
37
38
  fragmentDocument: () => fragmentDocument,
39
+ cssZoomOf: () => cssZoomOf,
38
40
  contentEdgeRect: () => contentEdgeRect,
39
41
  compensateRepeatedHeaders: () => compensateRepeatedHeaders,
40
42
  compensateRectoBreaks: () => compensateRectoBreaks,
@@ -267,6 +269,116 @@
267
269
  .gp-marginbox[data-align="center"] > .gp-marginbox-content { justify-content: center; }
268
270
  .gp-marginbox[data-align="end"] > .gp-marginbox-content { justify-content: flex-end; }
269
271
 
272
+ /* margin & bleed overlay (overlay.ts) -------------------------------- */
273
+ /* THE LOOK LIVES HERE, in these tokens, and nowhere else: colours, line
274
+ width, line style, tint strength. The desktop app's settings change the
275
+ colour (an inline \`--gp-ov-color\` on <body>) and pick a strength preset
276
+ (\`data-overlay-strength\`); nothing in a book's CSS is involved or needed. */
277
+ .gp-stage {
278
+ --gp-ov-color: #2f80ed; /* margin box line + the tint over the margins */
279
+ --gp-ov-width: 2px; /* line width as seen on screen, at any zoom */
280
+ --gp-ov-style: dashed; /* margin box line style */
281
+ --gp-ov-tint: 0.1; /* opacity of the tint over the margin area */
282
+ --gp-ov-bleed-color: #e5484d; /* bleed band + trim line */
283
+ --gp-ov-bleed-alpha: 0.45; /* opacity of the bleed band */
284
+ --gp-ov-trim-color: #8a0b18; /* the trim line: darker than the band so it reads as an edge */
285
+ --gp-ov-flag-width: 2px; /* overflow flag outline */
286
+ --gp-ov-warn: #f59e0b; /* reaches into the margin */
287
+ --gp-ov-error: #e5484d; /* crosses the trim / leaves the page */
288
+ --gp-ov-intent: #8b5cf6; /* placed on purpose */
289
+ }
290
+ .gp-stage[data-overlay-strength="subtle"] {
291
+ --gp-ov-width: 1px;
292
+ --gp-ov-tint: 0.05;
293
+ --gp-ov-bleed-alpha: 0.3;
294
+ }
295
+ .gp-stage[data-overlay-strength="strong"] {
296
+ --gp-ov-width: 3px;
297
+ --gp-ov-tint: 0.2;
298
+ --gp-ov-bleed-alpha: 0.65;
299
+ --gp-ov-flag-width: 3px;
300
+ }
301
+
302
+ /* One sibling layer per run, ABOVE the strip so the lines stay visible over
303
+ author backgrounds and art. Absolutely positioned and pointer-transparent:
304
+ it takes no flow space and no hits, so it cannot move a page break. Exists
305
+ only while the overlay is on. */
306
+ .gp-ov {
307
+ position: absolute;
308
+ inset: 0;
309
+ z-index: 5;
310
+ pointer-events: none;
311
+ /* The stage is a paint transform, so a 2px line would shrink with the zoom
312
+ and vanish at fit-to-width. Lines are sized in layout px divided by the
313
+ zoom, which makes them the same width on screen at every zoom. */
314
+ --gp-ov-w: calc(var(--gp-ov-width) / var(--gp-zoom, 1));
315
+ --gp-ov-flag-w: calc(var(--gp-ov-flag-width) / var(--gp-zoom, 1));
316
+ }
317
+
318
+ .gp-ov-page {
319
+ position: absolute;
320
+ }
321
+
322
+ /* the margins as a region: the trim minus the content box (clip-path, set in
323
+ overlay.ts), so a margin reads as an area, not a hairline */
324
+ .gp-ov-tint {
325
+ position: absolute;
326
+ inset: 0;
327
+ background: color-mix(in srgb, var(--gp-ov-color) calc(var(--gp-ov-tint) * 100%), transparent);
328
+ }
329
+
330
+ /* margin box: the content area's outline */
331
+ .gp-ov-margin {
332
+ position: absolute;
333
+ box-sizing: border-box;
334
+ border: var(--gp-ov-w) var(--gp-ov-style) var(--gp-ov-color);
335
+ }
336
+
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
+ /* bleed: a translucent band OUTSIDE the trim (its width is the border) */
347
+ .gp-ov-bleed {
348
+ position: absolute;
349
+ box-sizing: border-box;
350
+ border-style: solid;
351
+ border-color: color-mix(in srgb, var(--gp-ov-bleed-color) calc(var(--gp-ov-bleed-alpha) * 100%), transparent);
352
+ }
353
+
354
+ /* trim: where the sheet will be cut, drawn only when there is bleed — solid,
355
+ just inside the edge so it never paints over the band (overlay.ts sizes and
356
+ places it: the whole sheet, or the sheet less an in-sheet bleed) */
357
+ .gp-ov-trim {
358
+ position: absolute;
359
+ outline: var(--gp-ov-w) solid var(--gp-ov-trim-color);
360
+ outline-offset: calc(-1 * var(--gp-ov-w));
361
+ }
362
+
363
+ /* overflow flags — outline + faint tint, never a box change */
364
+ .gp-ov-flag {
365
+ position: absolute;
366
+ box-sizing: border-box;
367
+ }
368
+ .gp-ov-flag[data-kind="margin"] {
369
+ outline: var(--gp-ov-flag-w) solid var(--gp-ov-warn);
370
+ background: color-mix(in srgb, var(--gp-ov-warn) 16%, transparent);
371
+ }
372
+ .gp-ov-flag[data-kind="bleed"],
373
+ .gp-ov-flag[data-kind="off-page"] {
374
+ outline: var(--gp-ov-flag-w) solid var(--gp-ov-error);
375
+ background: color-mix(in srgb, var(--gp-ov-error) 18%, transparent);
376
+ }
377
+ /* placed on purpose (.gp-bleed, .gp-pin, …): present, not a problem */
378
+ .gp-ov-flag[data-kind="intended"] {
379
+ outline: var(--gp-ov-flag-w) dotted var(--gp-ov-intent);
380
+ }
381
+
270
382
  /* designer mode ------------------------------------------------------- */
271
383
  .gp-guide-trim,
272
384
  .gp-guide-safe,
@@ -310,6 +422,7 @@
310
422
  transform: none;
311
423
  }
312
424
  .gp-layer,
425
+ .gp-ov,
313
426
  .gp-warning,
314
427
  .gp-guide-trim,
315
428
  .gp-guide-safe,
@@ -2067,6 +2180,217 @@
2067
2180
  return /right/.test(name) ? "end" : "start";
2068
2181
  }
2069
2182
 
2183
+ // src/engine/compiler/tier2.ts
2184
+ var DEFAULT_SLUG_PT = 18;
2185
+ function pageGeometry(model, opts) {
2186
+ const base = resolvePage(model);
2187
+ const trim = { width: base.geometry.width, height: base.geometry.height };
2188
+ const bleed = opts.bleedPt ?? base.geometry.bleed;
2189
+ const wantsMarks = base.geometry.marks.length > 0 || opts.marks === true;
2190
+ const slug = wantsMarks ? opts.slugPt ?? DEFAULT_SLUG_PT : 0;
2191
+ return {
2192
+ trim,
2193
+ bleed,
2194
+ slug,
2195
+ marks: base.geometry.marks.length ? base.geometry.marks : wantsMarks ? ["crop"] : [],
2196
+ media: {
2197
+ width: trim.width + 2 * (bleed + slug),
2198
+ height: trim.height + 2 * (bleed + slug)
2199
+ }
2200
+ };
2201
+ }
2202
+
2203
+ // src/engine/viewer/overlay.ts
2204
+ function documentBleedPt(model) {
2205
+ return pageGeometry(model, { model }).bleed;
2206
+ }
2207
+ function pageBoxes(g, margin, bleed, scale = 1) {
2208
+ const w = g.width * scale;
2209
+ const h = g.height * scale;
2210
+ const b = Math.max(0, bleed) * scale;
2211
+ return {
2212
+ host: { x: 0, y: 0, w, h },
2213
+ trim: { x: 0, y: 0, w, h },
2214
+ content: {
2215
+ x: margin.left * scale,
2216
+ y: margin.top * scale,
2217
+ w: w - (margin.left + margin.right) * scale,
2218
+ h: h - (margin.top + margin.bottom) * scale
2219
+ },
2220
+ bleedBox: { x: -b, y: -b, w: w + 2 * b, h: h + 2 * b },
2221
+ bleed: b
2222
+ };
2223
+ }
2224
+ function insetPageBoxes(g, margin, bleed, side, scale = 1) {
2225
+ const sheet = pageBoxes(g, margin, 0, scale);
2226
+ const b = Math.max(0, bleed) * scale;
2227
+ return {
2228
+ host: sheet.host,
2229
+ trim: { x: side === "verso" ? b : 0, y: b, w: sheet.host.w - b, h: sheet.host.h - 2 * b },
2230
+ content: sheet.content,
2231
+ bleedBox: sheet.host,
2232
+ bleed: b
2233
+ };
2234
+ }
2235
+ var SEVERITY = { inside: 0, margin: 1, bleed: 2, "off-page": 3 };
2236
+ var within = (r, outer, tol) => r.x >= outer.x - tol && r.y >= outer.y - tol && r.x + r.w <= outer.x + outer.w + tol && r.y + r.h <= outer.y + outer.h + tol;
2237
+ function classifyRect(r, boxes, tol = 0) {
2238
+ if (within(r, boxes.content, tol))
2239
+ return "inside";
2240
+ if (within(r, boxes.trim, tol))
2241
+ return "margin";
2242
+ if (boxes.bleed > 0 && within(r, boxes.bleedBox, tol))
2243
+ return "bleed";
2244
+ return "off-page";
2245
+ }
2246
+ function worstKind(kinds) {
2247
+ return kinds.reduce((worst, k) => SEVERITY[k] > SEVERITY[worst] ? k : worst, "inside");
2248
+ }
2249
+ var INTENT_SELECTOR = ".gp-bleed, .gp-pin, .gp-flush, .gp-behind, .gp-page-full-bleed";
2250
+ var OVERLAY_STRENGTHS = ["subtle", "normal", "strong"];
2251
+ var HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
2252
+ function sanitizeOverlayStyle(style) {
2253
+ const s = style && typeof style === "object" ? style : {};
2254
+ const out = {};
2255
+ if (typeof s.color === "string" && HEX_COLOR.test(s.color.trim()))
2256
+ out.color = s.color.trim();
2257
+ if (OVERLAY_STRENGTHS.includes(s.strength))
2258
+ out.strength = s.strength;
2259
+ return out;
2260
+ }
2261
+ 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);
2264
+ }
2265
+ function configInsetBleedPt() {
2266
+ const v = parseFloat(document.querySelector('meta[name="gp-inset-bleed"]')?.getAttribute("content") ?? "");
2267
+ return Number.isFinite(v) && v > 0 ? v : 0;
2268
+ }
2269
+ var SKIP = new Set(["SCRIPT", "STYLE", "LINK", "TEMPLATE", "BR", "WBR", "SOURCE", "TRACK", "META"]);
2270
+ var TOL_PX = 1;
2271
+ function div(cls, box) {
2272
+ const el = document.createElement("div");
2273
+ el.className = cls;
2274
+ if (box)
2275
+ place(el, box);
2276
+ return el;
2277
+ }
2278
+ function place(el, r) {
2279
+ el.style.left = `${r.x}px`;
2280
+ el.style.top = `${r.y}px`;
2281
+ el.style.width = `${r.w}px`;
2282
+ el.style.height = `${r.h}px`;
2283
+ }
2284
+ function marginTint(b) {
2285
+ const el = div("gp-ov-tint");
2286
+ const t = b.trim;
2287
+ const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
2288
+ const l = clamp(b.content.x, t.x, t.x + t.w);
2289
+ const r = clamp(b.content.x + b.content.w, t.x, t.x + t.w);
2290
+ const top = clamp(b.content.y, t.y, t.y + t.h);
2291
+ const bot = clamp(b.content.y + b.content.h, t.y, t.y + t.h);
2292
+ const x2 = t.x + t.w;
2293
+ const y2 = t.y + t.h;
2294
+ el.style.clipPath = `polygon(evenodd, ${t.x}px ${t.y}px, ${x2}px ${t.y}px, ${x2}px ${y2}px, ${t.x}px ${y2}px, ${t.x}px ${t.y}px, ` + `${l}px ${top}px, ${l}px ${bot}px, ${r}px ${bot}px, ${r}px ${top}px, ${l}px ${top}px)`;
2295
+ return el;
2296
+ }
2297
+ function clearOverlay() {
2298
+ for (const layer of Array.from(document.querySelectorAll(".gp-ov")))
2299
+ layer.remove();
2300
+ }
2301
+ function paintOverlay(pages, strips, bleedPt, insetBleedPt = 0) {
2302
+ const inSheet = bleedPt <= 0 && insetBleedPt > 0;
2303
+ clearOverlay();
2304
+ const layers = new Map;
2305
+ const painted = new Map;
2306
+ for (const p of pages) {
2307
+ const run = p.sheet.closest(".gp-run");
2308
+ if (!run)
2309
+ continue;
2310
+ let layer = layers.get(run);
2311
+ if (!layer) {
2312
+ layer = div("gp-ov");
2313
+ run.appendChild(layer);
2314
+ layers.set(run, layer);
2315
+ }
2316
+ const boxes = inSheet ? insetPageBoxes(p.geometry, p.margin, insetBleedPt, p.sheet.dataset.side === "verso" ? "verso" : "recto", PX_PER_PT) : pageBoxes(p.geometry, p.margin, bleedPt, PX_PER_PT);
2317
+ const host = div("gp-ov-page", boxes.host);
2318
+ host.style.left = p.sheet.style.left;
2319
+ host.style.top = p.sheet.style.top;
2320
+ host.dataset.page = String(p.index + 1);
2321
+ if (boxes.bleed > 0) {
2322
+ const bb = boxes.bleedBox;
2323
+ const t = boxes.trim;
2324
+ const band = div("gp-ov-bleed", bb);
2325
+ band.style.borderWidth = `${t.y - bb.y}px ${bb.x + bb.w - (t.x + t.w)}px ${bb.y + bb.h - (t.y + t.h)}px ${t.x - bb.x}px`;
2326
+ host.appendChild(band);
2327
+ host.appendChild(div("gp-ov-trim", t));
2328
+ }
2329
+ host.appendChild(marginTint(boxes));
2330
+ 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
+ layer.appendChild(host);
2335
+ painted.set(p.index, { host, boxes, sheet: p.sheet });
2336
+ }
2337
+ const flags = [];
2338
+ let issues = 0;
2339
+ let intended = 0;
2340
+ for (const strip of strips) {
2341
+ const zoom = cssZoomOf(strip.el);
2342
+ const colW = (parseFloat(strip.el.style.getPropertyValue("--gp-content-w")) || 0) * zoom;
2343
+ const colH = (parseFloat(strip.el.style.getPropertyValue("--gp-content-h")) || 0) * zoom;
2344
+ const visit = (el) => {
2345
+ if (SKIP.has(el.tagName) || el.classList.contains("gp-wrap-spacer"))
2346
+ return;
2347
+ const kinds = [];
2348
+ const found = [];
2349
+ for (const r of Array.from(el.getClientRects())) {
2350
+ if (r.width <= 0 && r.height <= 0)
2351
+ continue;
2352
+ const ax = r.left + Math.min(r.width, colW || r.width) / 2;
2353
+ const ay = r.top + Math.min(r.height, colH || r.height) / 2;
2354
+ const target = painted.get(strip.offset + indexInStrip(ax, ay, strip));
2355
+ if (!target)
2356
+ continue;
2357
+ target.rect ??= target.sheet.getBoundingClientRect();
2358
+ const local = {
2359
+ x: (r.left - target.rect.left) / zoom,
2360
+ y: (r.top - target.rect.top) / zoom,
2361
+ w: r.width / zoom,
2362
+ h: r.height / zoom
2363
+ };
2364
+ const kind = classifyRect(local, target.boxes, TOL_PX);
2365
+ kinds.push(kind);
2366
+ if (kind !== "inside")
2367
+ found.push({ host: target.host, kind, box: local });
2368
+ }
2369
+ const worst = worstKind(kinds);
2370
+ if (worst !== "inside") {
2371
+ const isIntended = el.closest(INTENT_SELECTOR) !== null;
2372
+ if (isIntended)
2373
+ intended++;
2374
+ else
2375
+ issues++;
2376
+ for (const f of found)
2377
+ flags.push(isIntended ? { ...f, kind: "intended" } : f);
2378
+ return;
2379
+ }
2380
+ for (const child of Array.from(el.children))
2381
+ visit(child);
2382
+ };
2383
+ for (const child of Array.from(strip.el.children))
2384
+ visit(child);
2385
+ }
2386
+ for (const f of flags) {
2387
+ const el = div(`gp-ov-flag`, f.box);
2388
+ el.dataset.kind = f.kind;
2389
+ f.host.appendChild(el);
2390
+ }
2391
+ return inSheet ? { on: true, issues, intended, bleedPt: insetBleedPt, bleedInSheet: true } : { on: true, issues, intended, bleedPt };
2392
+ }
2393
+
2070
2394
  // src/engine/viewer/decorate.ts
2071
2395
  var px = (v) => `${v * PX_PER_PT}px`;
2072
2396
  function elementForHref(href) {
@@ -2095,6 +2419,13 @@
2095
2419
  let blankPages = new Set;
2096
2420
  let paddedPages = new Set;
2097
2421
  const warnings = [];
2422
+ let overlayOn = false;
2423
+ let overlayPages = [];
2424
+ let overlaySummary = OVERLAY_OFF;
2425
+ const paintOverlayNow = () => {
2426
+ overlaySummary = paintOverlay(overlayPages, layout.strips, documentBleedPt(model), configInsetBleedPt());
2427
+ window.dispatchEvent(new CustomEvent("gp:overlay", { detail: overlaySummary }));
2428
+ };
2098
2429
  const api = {
2099
2430
  redraw: () => draw(),
2100
2431
  sheetFor: (p) => sheets.get(p),
@@ -2104,7 +2435,29 @@
2104
2435
  warnings,
2105
2436
  setDesigner(on) {
2106
2437
  document.body.dataset.designer = on ? "on" : "off";
2107
- }
2438
+ },
2439
+ setOverlay(on, style) {
2440
+ if (style) {
2441
+ const { color, strength } = sanitizeOverlayStyle(style);
2442
+ if (strength)
2443
+ document.body.dataset.overlayStrength = strength;
2444
+ if (color)
2445
+ document.body.style.setProperty("--gp-ov-color", color);
2446
+ }
2447
+ const wasOn = overlayOn;
2448
+ overlayOn = on;
2449
+ document.body.dataset.overlay = on ? "on" : "off";
2450
+ if (on) {
2451
+ if (!(wasOn && style))
2452
+ paintOverlayNow();
2453
+ } else {
2454
+ clearOverlay();
2455
+ overlaySummary = OVERLAY_OFF;
2456
+ window.dispatchEvent(new CustomEvent("gp:overlay", { detail: overlaySummary }));
2457
+ }
2458
+ return overlaySummary;
2459
+ },
2460
+ overlay: () => overlaySummary
2108
2461
  };
2109
2462
  const canvasBg = captureCanvasBackground();
2110
2463
  document.body.classList.add("gp-stage");
@@ -2262,6 +2615,7 @@
2262
2615
  warnings.length = 0;
2263
2616
  blankPages = new Set(layout.blankPageIndices);
2264
2617
  paddedPages = new Set(layout.paddedPageIndices);
2618
+ overlayPages = [];
2265
2619
  buildMaps();
2266
2620
  fillXrefs();
2267
2621
  let prevPageH = 0;
@@ -2300,6 +2654,14 @@
2300
2654
  drawMarginBoxes(sheet, ctx, layout.totalPages - paddedPages.size);
2301
2655
  drawGuides(sheet, ctx);
2302
2656
  drawCropMarks(sheet, ctx);
2657
+ overlayPages.push({
2658
+ index: bookIndex,
2659
+ sheet,
2660
+ strip,
2661
+ 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
2664
+ });
2303
2665
  }
2304
2666
  const rows = Math.max(1, Math.ceil((strip.pages + shift) / perRow));
2305
2667
  run.style.height = `${rowStride * (rows - 1) + PX_PER_PT * g.height}px`;
@@ -2310,6 +2672,8 @@
2310
2672
  if (opts.designer)
2311
2673
  checkOverflow(strip, warnings);
2312
2674
  }
2675
+ if (overlayOn)
2676
+ paintOverlayNow();
2313
2677
  }
2314
2678
  function drawMarginBoxes(sheet, ctx, totalPages) {
2315
2679
  const g = ctx.geometry;
@@ -19,7 +19,7 @@ import {
19
19
  stringValueAt,
20
20
  toFolioPage,
21
21
  wantsRecto
22
- } from "./index-vmcfahe2.js";
22
+ } from "./index-t3zxy69d.js";
23
23
  import {
24
24
  launchChromium
25
25
  } from "./index-rzm1phg0.js";
@@ -9,7 +9,7 @@ import {
9
9
  getAssetsDir,
10
10
  lastPageMode,
11
11
  parseSize
12
- } from "./index-vmcfahe2.js";
12
+ } from "./index-t3zxy69d.js";
13
13
  import {
14
14
  INSTALL_HINTS,
15
15
  execCapture,
@@ -155,7 +155,8 @@ var DTRPG_PRESET = {
155
155
  page: {
156
156
  width: 621,
157
157
  height: 810,
158
- tolerance: 0.5
158
+ tolerance: 0.5,
159
+ bleed: 9
159
160
  },
160
161
  ink: {
161
162
  maxTac: 240,
@@ -231,7 +232,8 @@ var BOOK_PRESET = {
231
232
  page: {
232
233
  width: 432,
233
234
  height: 648,
234
- tolerance: 0.5
235
+ tolerance: 0.5,
236
+ bleed: undefined
235
237
  },
236
238
  ink: {
237
239
  maxTac: 400,
@@ -584,7 +586,8 @@ function resolveCustomPage(c, m) {
584
586
  return {
585
587
  width,
586
588
  height,
587
- tolerance: c.page?.tolerance ?? m.page?.tolerance ?? 0.5
589
+ tolerance: c.page?.tolerance ?? m.page?.tolerance ?? 0.5,
590
+ bleed: c.page?.bleed ?? m.page?.bleed
588
591
  };
589
592
  }
590
593
  function resolveWithPreset(cliOverrides, manifest, preset) {
@@ -5747,7 +5750,7 @@ import git from "isomorphic-git";
5747
5750
  // package.json
5748
5751
  var package_default = {
5749
5752
  name: "gutterpress",
5750
- version: "0.11.17",
5753
+ version: "0.11.18-alpha.2",
5751
5754
  description: "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
5752
5755
  author: "itlackey",
5753
5756
  license: "MPL-2.0",
@@ -10303,7 +10306,7 @@ class PdfOutput {
10303
10306
  const rawPdf = pdfxMode ? path13.join(stage, "raw.pdf") : path13.resolve(pdfFile);
10304
10307
  await fsp2.mkdir(path13.dirname(path13.resolve(pdfFile)), { recursive: true });
10305
10308
  log.info("Rendering HTML to PDF via the Gutterpress engine (native Chromium pagination)");
10306
- const { buildNativePdf } = await import("./engine-5d1rpxxq.js");
10309
+ const { buildNativePdf } = await import("./engine-7gfr16t8.js");
10307
10310
  const engineDiagnostics = await buildNativePdf(htmlFile, rawPdf, {
10308
10311
  title: config.title,
10309
10312
  author: config.authors.length > 0 ? config.authors.join(", ") : undefined,
@@ -10525,8 +10528,10 @@ async function renderPreviewBook(inputPath, config, opts) {
10525
10528
  }
10526
10529
  });
10527
10530
  }
10528
- function injectPreviewScripts(html) {
10529
- const scripts = ` <script src="/engine/gutterpress-viewer.js"></script>
10531
+ function injectPreviewScripts(html, insetBleedPt = 0) {
10532
+ const meta = insetBleedPt > 0 ? ` <meta name="gp-inset-bleed" content="${insetBleedPt}">
10533
+ ` : "";
10534
+ const scripts = meta + ` <script src="/engine/gutterpress-viewer.js"></script>
10530
10535
  ` + `<script src="/preview/scripts/preview-interface.js"></script>
10531
10536
  ` + `<script src="/preview/scripts/preview-bridge.js"></script>
10532
10537
  `;
@@ -10560,7 +10565,7 @@ async function generateAndWriteHtml(inputPath, tempDir, config, cssAssets, image
10560
10565
  for (const ref of nextImageRefs)
10561
10566
  imageRefs.add(ref);
10562
10567
  }
10563
- await fsp3.writeFile(path15.join(tempDir, BOOK_HTML_FILENAME), injectPreviewScripts(html), "utf-8");
10568
+ await fsp3.writeFile(path15.join(tempDir, BOOK_HTML_FILENAME), injectPreviewScripts(html, config.page?.bleed), "utf-8");
10564
10569
  }
10565
10570
  function isDotPathUnderRoot(candidatePath, root) {
10566
10571
  const normalizedRoot = root.replace(/\\/g, "/").replace(/\/+$/, "");
@@ -148,22 +148,22 @@ import { fileURLToPath } from "node:url";
148
148
  var favicon_default = "./favicon-272ga6y0.ico";
149
149
 
150
150
  // src/assets/manifest.schema.json
151
- var manifest_schema_default = "./manifest.schema-gh0jjve9.json";
151
+ var manifest_schema_default = "./manifest.schema-8m82f37q.json";
152
152
 
153
153
  // src/assets/preview/scripts/preview-interface.js
154
- var preview_interface_default = "./preview-interface-c44qk17f.js";
154
+ var preview_interface_default = "./preview-interface-2n1d9pbf.js";
155
155
 
156
156
  // src/assets/preview/scripts/preview-bridge.js
157
- var preview_bridge_default = "./preview-bridge-8jhd1wpb.js";
157
+ var preview_bridge_default = "./preview-bridge-evecsh4w.js";
158
158
 
159
159
  // src/assets/preview/scripts/preview-shell.js
160
- var preview_shell_default = "./preview-shell-xwn84kqr.js";
160
+ var preview_shell_default = "./preview-shell-hyp7g158.js";
161
161
 
162
162
  // profiles/CGATS21_CRPC1.icc
163
163
  var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
164
164
 
165
165
  // src/assets/engine/gutterpress-viewer.js
166
- var gutterpress_viewer_default = "./gutterpress-viewer-ez7k4ha7.js";
166
+ var gutterpress_viewer_default = "./gutterpress-viewer-spq1ge52.js";
167
167
 
168
168
  // src/assets/engine/gutterpress-agent.js
169
169
  var gutterpress_agent_default = "./gutterpress-agent-cazqstr1.js";
package/dist/index.js CHANGED
@@ -153,14 +153,14 @@ import {
153
153
  testRemoteAccess,
154
154
  updateExtensions,
155
155
  validateProjectExtensions
156
- } from "./index-3k3fyrec.js";
156
+ } from "./index-bb2d1ev8.js";
157
157
  import"./index-ht1bcqdd.js";
158
158
  import {
159
159
  BUILD_DIAGNOSTIC_CODES
160
- } from "./index-09h3n36d.js";
160
+ } from "./index-3x23by5j.js";
161
161
  import {
162
162
  BuildError
163
- } from "./index-vmcfahe2.js";
163
+ } from "./index-t3zxy69d.js";
164
164
  import {
165
165
  DEFAULT_PRINT_OPTS,
166
166
  assertMilestone,
@@ -21,6 +21,17 @@ export interface VendorPreset extends Omit<ResolvedConfig, "title" | "authors" |
21
21
  /** The built-in preset ids, in the order pickers should offer them. */
22
22
  export declare const PRESET_IDS: readonly ["dtrpg", "book", "custom"];
23
23
  export type PresetId = (typeof PRESET_IDS)[number];
24
+ /**
25
+ * DriveThruRPG print-on-demand interior. Where each value comes from:
26
+ *
27
+ * SPEC = DriveThru Partners, "Quick Specifications for Print Books"
28
+ * (help.drivethrupartners.com/hc/en-us/articles/12780800178583)
29
+ * GUIDE = third-party DriveThruRPG layout guides (consistent with SPEC's
30
+ * bleed rule; not stated by DriveThru itself)
31
+ * CONVENTION = Gutterpress's own choice or a value DERIVED from a spec
32
+ * requirement (e.g. PDF/X-1a forbids transparency) — NOT a DriveThru
33
+ * requirement in its own right.
34
+ */
24
35
  export declare const DTRPG_PRESET: VendorPreset;
25
36
  /**
26
37
  * A neutral, vendor-agnostic default for authors who aren't targeting a
@@ -200,6 +200,12 @@
200
200
  "description": "Allowed deviation, in points, between the expected and the actual page size.",
201
201
  "default": 0.5,
202
202
  "minimum": 0
203
+ },
204
+ "bleed": {
205
+ "type": "number",
206
+ "description": "A bleed, in points, that the page width x height ALREADY CONTAINS on the top, bottom and OUTER edges (none on the binding edge) — how DriveThruRPG's interior file is cut (8.625 x 11.25in for an 8.5 x 11in book). Preview overlay only: it tells the margin & bleed overlay where the trim is and changes nothing in the PDF. CSS `@page { bleed }` wins when the stylesheet declares one. Preset default: dtrpg 9 (0.125in); book and custom none.",
207
+ "minimum": 0,
208
+ "examples": [9]
203
209
  }
204
210
  }
205
211
  },
@@ -7,17 +7,17 @@ import {
7
7
  TARGET_IDS,
8
8
  scaffoldExtension,
9
9
  scaffoldProject
10
- } from "./cli-a4qtctrw.js";
10
+ } from "./cli-0w3961p5.js";
11
11
  import {
12
12
  resolveGhostscript
13
- } from "./cli-zfgvssqz.js";
13
+ } from "./cli-qp6dtsh3.js";
14
14
  import {
15
15
  UsageError,
16
16
  rejectExtraPositionals,
17
17
  rejectUnknownFlags
18
- } from "./cli-8nw6d915.js";
18
+ } from "./cli-yqpnksaa.js";
19
19
  import"./cli-ht1bcqdd.js";
20
- import"./cli-ycbg7mxk.js";
20
+ import"./cli-161z4n0s.js";
21
21
  import {
22
22
  EXIT_CODES
23
23
  } from "./cli-46ycxe6r.js";
@@ -2,17 +2,17 @@ import {
2
2
  executeValidation,
3
3
  publishTargetFor,
4
4
  reportMissingTools
5
- } from "./cli-a4qtctrw.js";
5
+ } from "./cli-0w3961p5.js";
6
6
  import {
7
7
  log
8
- } from "./cli-zfgvssqz.js";
8
+ } from "./cli-qp6dtsh3.js";
9
9
  import {
10
10
  UsageError,
11
11
  rejectExtraPositionals,
12
12
  rejectUnknownFlags
13
- } from "./cli-8nw6d915.js";
13
+ } from "./cli-yqpnksaa.js";
14
14
  import"./cli-ht1bcqdd.js";
15
- import"./cli-ycbg7mxk.js";
15
+ import"./cli-161z4n0s.js";
16
16
  import {
17
17
  BuildError,
18
18
  EXIT_CODES
@@ -22,7 +22,7 @@ import type { PrintPadding } from '../engine/shared/synthesis.ts';
22
22
  * no per-source wrappers or forced breaks are added, so preview pagination
23
23
  * never diverges from the PDF where a source file begins mid-page.
24
24
  */
25
- export declare function injectPreviewScripts(html: string): string;
25
+ export declare function injectPreviewScripts(html: string, insetBleedPt?: number): string;
26
26
  /**
27
27
  * Generate HTML from markdown and write book.html to the temp directory.
28
28
  * The desktop's iframe loads `book.html` via a relative URL — same name in
@@ -45,6 +45,9 @@ export declare function generateAndWriteHtml(inputPath: string, tempDir: string,
45
45
  };
46
46
  extensions?: ResolvedExtensionConfig[];
47
47
  print?: PrintPadding;
48
+ page?: {
49
+ bleed?: number;
50
+ };
48
51
  }, cssAssets: Map<string, string>, imageRefs?: Set<string>): Promise<void>;
49
52
  /**
50
53
  * Chokidar 5's `ignored` matcher (regex or function) is tested against the
@@ -7,10 +7,10 @@ import {
7
7
  runBuild,
8
8
  splitOutPath,
9
9
  startPreviewServer
10
- } from "./cli-a4qtctrw.js";
10
+ } from "./cli-0w3961p5.js";
11
11
  import {
12
12
  log
13
- } from "./cli-zfgvssqz.js";
13
+ } from "./cli-qp6dtsh3.js";
14
14
  import {
15
15
  UsageError,
16
16
  parseFormat,
@@ -18,9 +18,9 @@ import {
18
18
  rejectExtraPositionals,
19
19
  rejectUnknownFlags,
20
20
  resolvePort
21
- } from "./cli-8nw6d915.js";
21
+ } from "./cli-yqpnksaa.js";
22
22
  import"./cli-ht1bcqdd.js";
23
- import"./cli-ycbg7mxk.js";
23
+ import"./cli-161z4n0s.js";
24
24
  import {
25
25
  BuildError
26
26
  } from "./cli-46ycxe6r.js";
@@ -14,7 +14,7 @@
14
14
  //
15
15
  // Commands map 1:1 to previewAPI methods: getTotalPages, getCurrentPage,
16
16
  // goToPage, firstPage, prevPage, nextPage, lastPage, setViewMode, setZoom,
17
- // toggleDebugMode. Plus a synthetic 'print' command that calls window.print().
17
+ // toggleDebugMode, setMarginOverlay(on, {color, strength}). Plus a synthetic 'print' command that calls window.print().
18
18
  //
19
19
  // Additional messages:
20
20
  // parent -> iframe: { type: 'gutterpress:inject-styles', id: <attr-name>, css: <string> }
@@ -82,6 +82,10 @@
82
82
  window.addEventListener('contextMenuRequested', function (e) {
83
83
  post({ type: 'gutterpress:event', name: 'contextMenuRequested', detail: e.detail });
84
84
  });
85
+ // Margin & bleed overlay result (protocol v9): {on, issues, intended, bleedPt}.
86
+ window.addEventListener('overlayChanged', function (e) {
87
+ post({ type: 'gutterpress:event', name: 'overlayChanged', detail: e.detail });
88
+ });
85
89
  // In-flow block editing (protocol v8). `Requested` is the double-click entry
86
90
  // point — the SPA answers it with a beginBlockEdit command. `Finished`
87
91
  // carries the edited text back for an end the AUTHOR initiated inside the
@@ -1070,6 +1070,12 @@
1070
1070
  refreshPages();
1071
1071
  currentPage = detectVisiblePage();
1072
1072
  recordVisibleSource();
1073
+ // A hot-reload swap makes this frame the active one AFTER its overlay was
1074
+ // switched on (while hidden, where nothing is relayed): say so now.
1075
+ var overlay = api.getMarginOverlay();
1076
+ if (overlay && overlay.on) {
1077
+ window.dispatchEvent(new CustomEvent('overlayChanged', { detail: overlay }));
1078
+ }
1073
1079
  return api.notifyPageChange();
1074
1080
  },
1075
1081
 
@@ -1091,7 +1097,33 @@
1091
1097
  // floating edit panel this replaces. A v8 lib with a pre-v8 SPA loses the
1092
1098
  // "Edit this block" action and nothing else; a v8 SPA feature-detects on
1093
1099
  // the version before offering it.
1094
- getProtocolVersion: function () { return 8; },
1100
+ // v9: ADDED setMarginOverlay()/toggleMarginOverlay()/getMarginOverlay() and
1101
+ // the overlayChanged event (margin & bleed overlay, engine/viewer/
1102
+ // overlay.ts). A v9 lib with a pre-v9 SPA simply never turns it on; a v9
1103
+ // SPA feature-detects on the version before offering the toggle.
1104
+ // (v9 is unreleased as of this writing, so setMarginOverlay's optional
1105
+ // second argument — the look, below — is part of v9, not a bump.)
1106
+ getProtocolVersion: function () { return 9; },
1107
+
1108
+ // Margin & bleed overlay. Viewer chrome only — it adds no box to the book
1109
+ // and no attribute to its elements, so pagination is identical on or off.
1110
+ // Returns the summary {on, issues, intended, bleedPt}, or null when the
1111
+ // viewer predates it. `style` ({color: '#rrggbb', strength: 'subtle' |
1112
+ // 'normal' | 'strong'}) is optional: it only sets the viewer's own
1113
+ // `--gp-ov-*` tokens, and a call that carries it while the overlay is
1114
+ // already on restyles without repainting.
1115
+ setMarginOverlay: function (on, style) {
1116
+ var d = window.Gutterpress && window.Gutterpress.decoration;
1117
+ return d && typeof d.setOverlay === 'function' ? d.setOverlay(!!on, style) : null;
1118
+ },
1119
+ toggleMarginOverlay: function () {
1120
+ var d = window.Gutterpress && window.Gutterpress.decoration;
1121
+ return d && typeof d.setOverlay === 'function' ? d.setOverlay(document.body.dataset.overlay !== 'on') : null;
1122
+ },
1123
+ getMarginOverlay: function () {
1124
+ var d = window.Gutterpress && window.Gutterpress.decoration;
1125
+ return d && typeof d.overlay === 'function' ? d.overlay() : null;
1126
+ },
1095
1127
 
1096
1128
  // Resolve the annotated element/selection at a viewport point (protocol
1097
1129
  // v4). Pure read; see buildContextTarget() above for the full contract.
@@ -1596,4 +1628,48 @@
1596
1628
  // The Gutterpress engine viewer dispatches this when its pagination
1597
1629
  // completes (engine/viewer/index.ts's mount()).
1598
1630
  window.addEventListener('gp:layout', onRenderingComplete);
1631
+
1632
+ // Margin & bleed overlay: relay the viewer's result as 'overlayChanged' (the
1633
+ // bridge posts it to a host toolbar) and, where no host toolbar exists, give
1634
+ // the standalone CLI preview its own switch: Alt+M, plus a small status pill.
1635
+ // "Standalone" = the shell is top level (the CLI); under the desktop app the
1636
+ // shell's parent is the app, which owns the toggle and the count.
1637
+ var standalone = false;
1638
+ try { standalone = window.parent === window || window.parent.parent === window.parent; } catch (_e) {}
1639
+
1640
+ function updateOverlayBadge(summary) {
1641
+ var badge = document.getElementById('gp-ov-badge');
1642
+ if (!standalone || !summary || !summary.on) {
1643
+ if (badge) badge.remove();
1644
+ return;
1645
+ }
1646
+ if (!badge) {
1647
+ badge = document.createElement('div');
1648
+ badge.id = 'gp-ov-badge';
1649
+ badge.setAttribute('role', 'status');
1650
+ badge.style.cssText = 'position:fixed;top:8px;right:8px;z-index:2147483000;pointer-events:none;' +
1651
+ 'background:rgba(20,20,24,.88);color:#fff;font:600 11px/1.4 ui-sans-serif,system-ui,sans-serif;' +
1652
+ 'padding:4px 10px;border-radius:999px;box-shadow:0 1px 6px rgba(0,0,0,.4)';
1653
+ document.documentElement.appendChild(badge);
1654
+ }
1655
+ var parts = ['Margins & bleed'];
1656
+ parts.push(summary.issues ? summary.issues + ' overflowing' : 'nothing overflows');
1657
+ if (summary.intended) parts.push(summary.intended + ' placed on purpose');
1658
+ if (summary.bleedInSheet) parts.push('bleed inside the page (print preset)');
1659
+ if (!summary.bleedPt) parts.push('no bleed set \u2014 add @page { bleed: 0.125in } to see the bleed edge');
1660
+ badge.textContent = parts.join(' \u00b7 ') + ' (Alt+M hides)';
1661
+ }
1662
+
1663
+ window.addEventListener('gp:overlay', function (e) {
1664
+ updateOverlayBadge(e.detail);
1665
+ window.dispatchEvent(new CustomEvent('overlayChanged', { detail: e.detail }));
1666
+ });
1667
+
1668
+ if (standalone) {
1669
+ document.addEventListener('keydown', function (e) {
1670
+ if (e.code !== 'KeyM' || !e.altKey || e.ctrlKey || e.metaKey || e.defaultPrevented) return;
1671
+ e.preventDefault();
1672
+ api.toggleMarginOverlay();
1673
+ });
1674
+ }
1599
1675
  })();
@@ -106,6 +106,15 @@
106
106
  else if (sourceBody.classList.contains('view-spread')) api.setViewMode('spread', true);
107
107
  else if (sourceBody.classList.contains('view-two-column')) api.setViewMode('two-column', true);
108
108
  if (sourceBody.classList.contains('debug')) api.toggleDebugMode();
109
+ // The margin & bleed overlay is a review aid the author switched on: a
110
+ // hot reload must not drop it.
111
+ // Its look (colour, strength) travels with it.
112
+ if (sourceBody.dataset.overlay === 'on' && api.setMarginOverlay) {
113
+ api.setMarginOverlay(true, {
114
+ color: sourceBody.style.getPropertyValue('--gp-ov-color').trim(),
115
+ strength: sourceBody.dataset.overlayStrength
116
+ });
117
+ }
109
118
  }
110
119
  var zoom = source.documentElement.style.getPropertyValue('--gutterpress-zoom');
111
120
  // Carry the fit flag too (setZoom's third argument clips sideways overflow).
@@ -11,18 +11,18 @@ import {
11
11
  publishProviderFor,
12
12
  resolvePublishFormat,
13
13
  runPublish
14
- } from "./cli-a4qtctrw.js";
14
+ } from "./cli-0w3961p5.js";
15
15
  import {
16
16
  FileTokenStore,
17
17
  log
18
- } from "./cli-zfgvssqz.js";
18
+ } from "./cli-qp6dtsh3.js";
19
19
  import {
20
20
  UsageError,
21
21
  rejectExtraPositionals,
22
22
  rejectUnknownFlags
23
- } from "./cli-8nw6d915.js";
23
+ } from "./cli-yqpnksaa.js";
24
24
  import"./cli-ht1bcqdd.js";
25
- import"./cli-ycbg7mxk.js";
25
+ import"./cli-161z4n0s.js";
26
26
  import {
27
27
  EXIT_CODES
28
28
  } from "./cli-46ycxe6r.js";
@@ -146,6 +146,15 @@ export interface GutterpressManifest {
146
146
  width?: number;
147
147
  height?: number;
148
148
  tolerance?: number;
149
+ /**
150
+ * A bleed (pt) the page `width` x `height` ALREADY CONTAINS, on the top,
151
+ * bottom and OUTER edges only (the binding edge has none) — how
152
+ * DriveThruRPG's interior file is cut (8.625 x 11.25in for an 8.5 x 11in
153
+ * book). It changes nothing in the PDF: it only tells the preview's margin
154
+ * & bleed overlay where the trim is. CSS `@page { bleed }` (symmetric,
155
+ * grows the page) wins when the stylesheet declares one.
156
+ */
157
+ bleed?: number;
149
158
  };
150
159
  ink?: {
151
160
  maxTac?: number;
@@ -261,6 +270,8 @@ export interface ResolvedConfig {
261
270
  width: number;
262
271
  height: number;
263
272
  tolerance: number;
273
+ /** In-sheet bleed in pt (top, bottom, outer edge; see the manifest field); absent = none. */
274
+ bleed?: number;
264
275
  };
265
276
  ink: {
266
277
  maxTac: number;
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  executeAndReport
3
- } from "./cli-a4qtctrw.js";
3
+ } from "./cli-0w3961p5.js";
4
4
  import {
5
5
  log
6
- } from "./cli-zfgvssqz.js";
6
+ } from "./cli-qp6dtsh3.js";
7
7
  import {
8
8
  UsageError,
9
9
  rejectExtraPositionals,
10
10
  rejectUnknownFlags
11
- } from "./cli-8nw6d915.js";
11
+ } from "./cli-yqpnksaa.js";
12
12
  import"./cli-ht1bcqdd.js";
13
- import"./cli-ycbg7mxk.js";
13
+ import"./cli-161z4n0s.js";
14
14
  import {
15
15
  BuildError,
16
16
  EXIT_CODES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gutterpress",
3
- "version": "0.11.17",
3
+ "version": "0.11.18-alpha.2",
4
4
  "description": "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
5
5
  "author": "itlackey",
6
6
  "license": "MPL-2.0",