gutterpress 0.11.23-alpha.7 → 0.11.23-beta.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 (59) hide show
  1. package/README.md +2 -0
  2. package/dist/{README-syg2hn83.md → README-8rct3axy.md} +2 -2
  3. package/dist/api/index.d.ts +3 -3
  4. package/dist/api/index.js +7 -5
  5. package/dist/{build-w572wq10.js → build-dg8a566j.js} +8 -7
  6. package/dist/{cli-eatdqx3z.js → cli-1fy1pm9d.js} +1 -1
  7. package/dist/cli-65gy8ask.js +82 -0
  8. package/dist/{cli-3cvq3n1c.js → cli-989eg8jz.js} +186 -83
  9. package/dist/{cli-6pv84kf3.js → cli-e31jshz6.js} +6 -84
  10. package/dist/{cli-58fsk6d7.js → cli-k087gj0p.js} +66 -34
  11. package/dist/{cli-5ba6bm6z.js → cli-s1zt779w.js} +1 -1
  12. package/dist/{cli-wyg7qstd.js → cli-ttj95aex.js} +3 -3
  13. package/dist/{cli-mmgtqnmr.js → cli-vhav8g82.js} +1 -1
  14. package/dist/cli.js +12 -12
  15. package/dist/{doctor-2f3zqmza.js → doctor-g4a42tcz.js} +3 -3
  16. package/dist/engine/shared/page-vars.d.ts +32 -0
  17. package/dist/{engine-4rabsgwq.js → engine-jvkcahr1.js} +2 -1
  18. package/dist/{engine-wm4fggac.js → engine-wgkaqjsc.js} +3 -3
  19. package/dist/{ext-0cgky8n3.js → ext-w9d5ftcg.js} +8 -7
  20. package/dist/{extension-restore-vghc58vx.js → extension-restore-5x4mj79d.js} +3 -3
  21. package/dist/{extension-restore-e7je32pr.js → extension-restore-as0g38p1.js} +5 -4
  22. package/dist/{gutterpress-viewer-mafsby5k.js → gutterpress-viewer-ze691rrd.js} +52 -13
  23. package/dist/{index-2vxzxyyj.js → index-798jt0qc.js} +9 -9
  24. package/dist/{index-fp7xwvpr.js → index-a4j3xcfp.js} +3 -3
  25. package/dist/{index-nfysshcc.js → index-c6y0p7jy.js} +249 -139
  26. package/dist/{index-wm4x7xbf.js → index-fk2kpf2t.js} +58 -26
  27. package/dist/{index-hphcn7th.js → index-rj5vrhz6.js} +5 -85
  28. package/dist/index-tayzfr9c.js +99 -0
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.js +233 -6
  31. package/dist/lib/book-css.d.ts +56 -0
  32. package/dist/lib/markdown/assemble.d.ts +58 -0
  33. package/dist/lib/publish/google-drive.d.ts +12 -4
  34. package/dist/lib/publish/manifest-publish.d.ts +6 -0
  35. package/dist/lib/publish/providers/gdrive-folder.d.ts +30 -0
  36. package/dist/lib/publish/run-publish.d.ts +6 -1
  37. package/dist/lib/publish/types.d.ts +52 -5
  38. package/dist/lib/remote-auth/converge-merge.d.ts +3 -3
  39. package/dist/lib/remote-auth/sync-messages.d.ts +2 -2
  40. package/dist/lib/root-tokens.d.ts +76 -0
  41. package/dist/lib/version-changes.d.ts +12 -12
  42. package/dist/{manifest-79zsgkpn.yaml → manifest-0vwaskj2.yaml} +1 -1
  43. package/dist/{manifest-2kc56wvw.yaml → manifest-aya31jwt.yaml} +1 -1
  44. package/dist/{manifest-41ddzm13.yaml → manifest-mffah3hr.yaml} +1 -1
  45. package/dist/{manifest-sqzm4681.yaml → manifest-wbcv8cbp.yaml} +2 -2
  46. package/dist/{manifest.schema-93sd7zje.json → manifest.schema-0jgj0jt1.json} +1 -1
  47. package/dist/{new-88rkrv71.js → new-jtk028rf.js} +8 -7
  48. package/dist/{page-rules-ytj9p04v.css → page-rules-vnja6grt.css} +2 -2
  49. package/dist/{plugins-3aj0wc5h.js → plugins-bcbe7xs8.js} +1 -1
  50. package/dist/{plugins-sprxsz5d.js → plugins-zsm6wv79.js} +3 -3
  51. package/dist/{preflight-11dg1qkk.js → preflight-cs6mj1d6.js} +8 -7
  52. package/dist/{preview-nftp782j.js → preview-d1j1g4qf.js} +8 -7
  53. package/dist/{publish-6tgxfck9.js → publish-7yw4jyrt.js} +24 -8
  54. package/dist/render.js +65 -24
  55. package/dist/schema/manifest.types.d.ts +2 -1
  56. package/dist/{tokens-n82t4k9h.css → tokens-a7grv940.css} +4 -5
  57. package/dist/{validate-pktqrye5.js → validate-rkcdnzhw.js} +8 -7
  58. package/package.json +1 -1
  59. package/dist/index-46ycxe6r.js +0 -18
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  launchChromium
3
3
  } from "./cli-eyyggect.js";
4
+ import {
5
+ round3
6
+ } from "./cli-65gy8ask.js";
4
7
 
5
8
  // src/engine/compiler/build.ts
6
9
  import { readFile as readFile2 } from "node:fs/promises";
@@ -630,6 +633,33 @@ function marginBoxesOnEdges(edges) {
630
633
  return Object.entries(owners).filter(([, own]) => own.some((e) => edges.includes(e))).map(([name]) => name);
631
634
  }
632
635
 
636
+ // src/engine/shared/page-vars.ts
637
+ var decls = (pairs) => pairs.map(([name, n]) => `--gp-page-${name}: ${round3(n)}pt;`).join(" ");
638
+ function pageDecls(model, name) {
639
+ const { width, height, margin } = resolvePage(model, { name, pseudos: ["right"] }).geometry;
640
+ return decls([
641
+ ["width", width],
642
+ ["height", height],
643
+ ["margin-top", margin.top],
644
+ ["margin-bottom", margin.bottom],
645
+ ["margin-inside", margin.left],
646
+ ["margin-outside", margin.right]
647
+ ]);
648
+ }
649
+ function pageGeometryVarsCss(model, area) {
650
+ const bookWide = decls([
651
+ ["bleed", area?.bleed ?? 0],
652
+ ["safe", area?.safe ?? 0],
653
+ ["gutter", area?.gutter ?? 0],
654
+ ["art-safe", area?.artSafe ?? 0]
655
+ ]);
656
+ return [
657
+ `:root { ${pageDecls(model)} ${bookWide} }`,
658
+ ...model.pageAssignments.map((a) => `${a.selector} { ${pageDecls(model, a.page)} }`)
659
+ ].join(`
660
+ `);
661
+ }
662
+
633
663
  // src/engine/shared/margin-box-support.ts
634
664
  var MARGIN_BOX_IGNORED_PROPERTIES = new Set([
635
665
  "transform",
@@ -1140,7 +1170,7 @@ import { fileURLToPath } from "node:url";
1140
1170
  var favicon_default = "./favicon-272ga6y0.ico";
1141
1171
 
1142
1172
  // src/assets/manifest.schema.json
1143
- var manifest_schema_default = "./manifest.schema-93sd7zje.json";
1173
+ var manifest_schema_default = "./manifest.schema-0jgj0jt1.json";
1144
1174
 
1145
1175
  // src/assets/preview/scripts/preview-interface.js
1146
1176
  var preview_interface_default = "./preview-interface-0xdh0r5b.js";
@@ -1155,31 +1185,31 @@ var preview_shell_default = "./preview-shell-wk9k3gcd.js";
1155
1185
  var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
1156
1186
 
1157
1187
  // src/assets/engine/gutterpress-viewer.js
1158
- var gutterpress_viewer_default = "./gutterpress-viewer-mafsby5k.js";
1188
+ var gutterpress_viewer_default = "./gutterpress-viewer-ze691rrd.js";
1159
1189
 
1160
1190
  // src/assets/engine/gutterpress-agent.js
1161
1191
  var gutterpress_agent_default = "./gutterpress-agent-d29ry3ak.js";
1162
1192
 
1163
1193
  // src/assets/templates/book/manifest.yaml
1164
- var manifest_default = "./manifest-41ddzm13.yaml";
1194
+ var manifest_default = "./manifest-mffah3hr.yaml";
1165
1195
 
1166
1196
  // src/assets/templates/book/chapter-01.md
1167
1197
  var chapter_01_default = "./chapter-01-gsbjt584.md";
1168
1198
 
1169
1199
  // src/assets/templates/zine/manifest.yaml
1170
- var manifest_default2 = "./manifest-sqzm4681.yaml";
1200
+ var manifest_default2 = "./manifest-wbcv8cbp.yaml";
1171
1201
 
1172
1202
  // src/assets/templates/zine/chapter-01.md
1173
1203
  var chapter_01_default2 = "./chapter-01-wgjfz4w6.md";
1174
1204
 
1175
1205
  // src/assets/templates/technical/manifest.yaml
1176
- var manifest_default3 = "./manifest-2kc56wvw.yaml";
1206
+ var manifest_default3 = "./manifest-aya31jwt.yaml";
1177
1207
 
1178
1208
  // src/assets/templates/technical/chapter-01.md
1179
1209
  var chapter_01_default3 = "./chapter-01-6fn9pvd0.md";
1180
1210
 
1181
1211
  // src/assets/templates/paper/manifest.yaml
1182
- var manifest_default4 = "./manifest-79zsgkpn.yaml";
1212
+ var manifest_default4 = "./manifest-0vwaskj2.yaml";
1183
1213
 
1184
1214
  // src/assets/templates/paper/chapter-01.md
1185
1215
  var chapter_01_default4 = "./chapter-01-s71xrf5q.md";
@@ -1212,7 +1242,7 @@ var plugin_test_js_default = "./plugin.test.js-gxzqqfdh.tpl";
1212
1242
  var package_default2 = "./package-awwkt7sa.json";
1213
1243
 
1214
1244
  // src/assets/extension-templates/look/README.md
1215
- var README_default2 = "./README-syg2hn83.md";
1245
+ var README_default2 = "./README-8rct3axy.md";
1216
1246
 
1217
1247
  // src/assets/extension-templates/look/components.yaml
1218
1248
  var components_default = "./components-zzqdpt3m.yaml";
@@ -1221,7 +1251,7 @@ var components_default = "./components-zzqdpt3m.yaml";
1221
1251
  var callout_default = "./callout-hv56m16h.md";
1222
1252
 
1223
1253
  // src/assets/extension-templates/look/styles/tokens.css
1224
- var tokens_default = "./tokens-n82t4k9h.css";
1254
+ var tokens_default = "./tokens-a7grv940.css";
1225
1255
 
1226
1256
  // src/assets/extension-templates/look/styles/base.css
1227
1257
  var base_default = "./base-ypqh9n7f.css";
@@ -1233,7 +1263,7 @@ var components_default2 = "./components-aam0fe2z.css";
1233
1263
  var page_templates_default = "./page-templates-tx9ryt19.css";
1234
1264
 
1235
1265
  // src/assets/extension-templates/look/styles/page-rules.css
1236
- var page_rules_default = "./page-rules-ytj9p04v.css";
1266
+ var page_rules_default = "./page-rules-vnja6grt.css";
1237
1267
 
1238
1268
  // src/assets/extension-templates/look/styles/book.css
1239
1269
  var book_default = "./book-ted3tzrp.css";
@@ -1341,9 +1371,9 @@ function pseudoVariants(model) {
1341
1371
  function consumedStrings(model) {
1342
1372
  const names = new Set;
1343
1373
  for (const rule of model.pageRules)
1344
- for (const decls of Object.values(rule.marginBoxes))
1345
- if (decls.content) {
1346
- for (const part of parseContent(decls.content))
1374
+ for (const decls2 of Object.values(rule.marginBoxes))
1375
+ if (decls2.content) {
1376
+ for (const part of parseContent(decls2.content))
1347
1377
  if (part.type === "string")
1348
1378
  names.add(part.name);
1349
1379
  }
@@ -1674,7 +1704,8 @@ async function build(opts) {
1674
1704
  key: root.key
1675
1705
  });
1676
1706
  }
1677
- const printArea = pinRoots.length ? await page.evaluate(`window.__gp.printArea()`) : null;
1707
+ const printArea = await page.evaluate(`window.__gp.printArea()`);
1708
+ const geometryVarsCss = pageGeometryVarsCss(model, printArea);
1678
1709
  const pinStyle = (group, pseudos) => pinRootStyle(resolvePage(model, { name: group.authorPage, pseudos }).geometry.margin, printArea, pseudos.includes("left") ? "verso" : "recto", group.edges, group.padding);
1679
1710
  if (pinGroups.size) {
1680
1711
  const lines = [];
@@ -1694,11 +1725,11 @@ async function build(opts) {
1694
1725
  const body = [];
1695
1726
  for (const [prop, value] of Object.entries(rule.decls))
1696
1727
  body.push(` ${prop}: ${value};`);
1697
- for (const [box, decls] of Object.entries(rule.marginBoxes)) {
1728
+ for (const [box, decls2] of Object.entries(rule.marginBoxes)) {
1698
1729
  if (relocated.has(box.slice(1)))
1699
1730
  continue;
1700
1731
  body.push(` ${box} {`);
1701
- for (const [prop, value] of Object.entries(decls))
1732
+ for (const [prop, value] of Object.entries(decls2))
1702
1733
  body.push(` ${prop}: ${value};`);
1703
1734
  body.push(` }`);
1704
1735
  }
@@ -1741,11 +1772,12 @@ ${pinCss}`);
1741
1772
  const minContentHeightPx = Math.min(contentHeightPt(), ...model.pageNames.map((name) => contentHeightPt(name))) * 96 / 72;
1742
1773
  const pageVarsCss = [
1743
1774
  `:root { --gp-content-h: ${contentHeightPx}px; }`,
1744
- ...model.pageAssignments.map((a) => `${a.selector} { --gp-content-h: ${namedContentHeightsPx[a.page] ?? contentHeightPx}px; }`)
1775
+ ...model.pageAssignments.map((a) => `${a.selector} { --gp-content-h: ${namedContentHeightsPx[a.page] ?? contentHeightPx}px; }`),
1776
+ geometryVarsCss
1745
1777
  ].join(`
1746
1778
  `);
1747
1779
  await page.evaluate(`window.__gp.addCss("gp-page-vars", ${JSON.stringify(pageVarsCss)})`);
1748
- log(`page geometry published (--gp-content-h: ${Math.round(contentHeightPx)}px)`);
1780
+ log(`page geometry published (--gp-content-h: ${Math.round(contentHeightPx)}px, --gp-page-*)`);
1749
1781
  const relocationBoxes = (group, pseudos) => {
1750
1782
  const ctx = resolvePage(model, { name: group.authorPage, pseudos });
1751
1783
  return marginBoxesOnEdges(group.edges).map((name) => [name, ctx.marginBoxes[`@${name}`]]).filter((pair) => {
@@ -1949,8 +1981,8 @@ ${mapCss}`;
1949
1981
  const g = ctx.geometry;
1950
1982
  const eff = flushMargins(g.margin, group.edges);
1951
1983
  const boxes = [];
1952
- for (const [name, decls] of relocationBoxes(group, pseudos)) {
1953
- const text = evaluate(decls.content, {
1984
+ for (const [name, decls2] of relocationBoxes(group, pseudos)) {
1985
+ const text = evaluate(decls2.content, {
1954
1986
  page: toFolioPage(physical, pageValues),
1955
1987
  pages: pageCount,
1956
1988
  strings: (n, w) => stringValueAt(byName.get(n) ?? [], physical, parseWhich(w)),
@@ -1962,13 +1994,13 @@ ${mapCss}`;
1962
1994
  if (!text) {
1963
1995
  if (!relocationDiagnosed.has(name)) {
1964
1996
  relocationDiagnosed.add(name);
1965
- diagnose("engine.pin.margin-box", `@${name} sits on an edge a pinned image frees, and its content could not be ` + `re-homed into the page (unsupported content value: ${decls.content}). It will ` + `not print on that page — simplify the box's content, or pin the image to another edge.`);
1997
+ diagnose("engine.pin.margin-box", `@${name} sits on an edge a pinned image frees, and its content could not be ` + `re-homed into the page (unsupported content value: ${decls2.content}). It will ` + `not print on that page — simplify the box's content, or pin the image to another edge.`);
1966
1998
  }
1967
1999
  continue;
1968
2000
  }
1969
2001
  const r = marginBoxRectPt(name, g);
1970
2002
  const outDecls = {};
1971
- for (const [prop, value] of Object.entries(decls)) {
2003
+ for (const [prop, value] of Object.entries(decls2)) {
1972
2004
  if (prop.toLowerCase() === "content" || isIgnoredMarginBoxProperty(prop))
1973
2005
  continue;
1974
2006
  outDecls[prop] = value;
@@ -2603,10 +2635,10 @@ function counterStyleCss(model, sources, pageMap, pageCount, resetSites = [], ha
2603
2635
  return "";
2604
2636
  const pairs = new Map;
2605
2637
  for (const rule of model.pageRules) {
2606
- for (const decls of Object.values(rule.marginBoxes)) {
2607
- if (!decls.content)
2638
+ for (const decls2 of Object.values(rule.marginBoxes)) {
2639
+ if (!decls2.content)
2608
2640
  continue;
2609
- for (const part of parseContent(decls.content)) {
2641
+ for (const part of parseContent(decls2.content)) {
2610
2642
  if (part.type !== "string" || !byName.has(part.name))
2611
2643
  continue;
2612
2644
  const which = parseWhich(part.which);
@@ -2645,13 +2677,13 @@ function counterStyleCss(model, sources, pageMap, pageCount, resetSites = [], ha
2645
2677
  for (const pseudos of variants) {
2646
2678
  const resolved = resolvePage(model, { name, pseudos });
2647
2679
  const lines = [];
2648
- for (const [box, decls] of Object.entries(resolved.marginBoxes)) {
2649
- if (!decls.content)
2680
+ for (const [box, decls2] of Object.entries(resolved.marginBoxes)) {
2681
+ if (!decls2.content)
2650
2682
  continue;
2651
- const hasString = /\bstring\s*\(/.test(decls.content);
2652
- const hasPageCounter = pageValues && /\bcounter\(\s*page\b(?!s)/.test(decls.content);
2683
+ const hasString = /\bstring\s*\(/.test(decls2.content);
2684
+ const hasPageCounter = pageValues && /\bcounter\(\s*page\b(?!s)/.test(decls2.content);
2653
2685
  const needsRewrite = hasString || hasPageCounter;
2654
- lines.push(` ${box} { content: ${needsRewrite ? rewrite(decls.content) : decls.content}; }`);
2686
+ lines.push(` ${box} { content: ${needsRewrite ? rewrite(decls2.content) : decls2.content}; }`);
2655
2687
  }
2656
2688
  if (!lines.length)
2657
2689
  continue;
@@ -2665,13 +2697,13 @@ ${lines.join(`
2665
2697
  if (hasBlank) {
2666
2698
  const blank = resolvePage(model, { pseudos: ["blank"] });
2667
2699
  const lines = [];
2668
- for (const [box, decls] of Object.entries(blank.marginBoxes)) {
2669
- if (!decls.content)
2700
+ for (const [box, decls2] of Object.entries(blank.marginBoxes)) {
2701
+ if (!decls2.content)
2670
2702
  continue;
2671
- const hasString = /\bstring\s*\(/.test(decls.content);
2672
- const hasPageCounter = pageValues && /\bcounter\(\s*page\b(?!s)/.test(decls.content);
2703
+ const hasString = /\bstring\s*\(/.test(decls2.content);
2704
+ const hasPageCounter = pageValues && /\bcounter\(\s*page\b(?!s)/.test(decls2.content);
2673
2705
  const needsRewrite = hasString || hasPageCounter;
2674
- lines.push(` ${box} { content: ${needsRewrite ? rewrite(decls.content) : decls.content}; }`);
2706
+ lines.push(` ${box} { content: ${needsRewrite ? rewrite(decls2.content) : decls2.content}; }`);
2675
2707
  }
2676
2708
  out.push(`@page ${BLANK_PAGE} {
2677
2709
  ${lines.length ? lines.join(`
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "gutterpress",
4
- version: "0.11.23-alpha.7",
4
+ version: "0.11.23-beta.1",
5
5
  description: "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
6
6
  author: "itlackey",
7
7
  license: "MPL-2.0",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PACKAGE_VERSION,
3
3
  debug
4
- } from "./cli-eatdqx3z.js";
4
+ } from "./cli-1fy1pm9d.js";
5
5
  import {
6
6
  isExactNpmVersion,
7
7
  isValidNpmPackageName,
@@ -3575,9 +3575,9 @@ async function loadNpmPackage(packageName, baseDir, version) {
3575
3575
  const looksLikeJsFilename = /\.(m?js|cjs)$/i.test(packageName);
3576
3576
  const suggestedPath = looksLikeJsFilename ? `./${packageName}` : `./plugins/${packageName}.js`;
3577
3577
  if (!looksLikeJsFilename && (!version || !isExactNpmVersion(version))) {
3578
- throw new Error(`Extension "${packageName}${version ? `@${version}` : ""}" is not pinned to an exact version, so it can't be downloaded automatically. Run \`gutterpress ext add ${packageName}\` (or use Book setup > Advanced in the desktop app) to download it and pin its version in your manifest.`);
3578
+ throw new Error(`Extension "${packageName}${version ? `@${version}` : ""}" is not pinned to an exact version, so it can't be downloaded automatically. Run \`gutterpress ext add ${packageName}\` (or add it in Book setup) to download it and pin its version in your manifest.`);
3579
3579
  }
3580
- throw new Error(`Extension "${packageName}" not found. Install it with \`gutterpress ext add ${version ? `${packageName}@${version}` : packageName}\` (or Book setup > Advanced in the desktop app),
3580
+ throw new Error(`Extension "${packageName}" not found. Install it with \`gutterpress ext add ${version ? `${packageName}@${version}` : packageName}\` (or add it in Book setup),
3581
3581
  or reference a local file under \`extensions:\`:
3582
3582
  extensions:
3583
3583
  - ${suggestedPath}`);
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  PACKAGE_VERSION,
16
16
  log
17
- } from "./cli-eatdqx3z.js";
17
+ } from "./cli-1fy1pm9d.js";
18
18
  import {
19
19
  __require
20
20
  } from "./cli-37x76zdn.js";
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from "./cli-d8xjns66.js";
9
9
  import {
10
10
  package_default
11
- } from "./cli-5ba6bm6z.js";
11
+ } from "./cli-s1zt779w.js";
12
12
  import {
13
13
  EXIT_CODES
14
14
  } from "./cli-46ycxe6r.js";
@@ -20,14 +20,14 @@ import {
20
20
  import { defineCommand, parseArgs, runMain } from "citty";
21
21
  import { statSync } from "node:fs";
22
22
  var SUBCOMMANDS = {
23
- new: () => import("./new-88rkrv71.js").then((m) => m.default),
24
- preview: () => import("./preview-nftp782j.js").then((m) => m.default),
25
- build: () => import("./build-w572wq10.js").then((m) => m.default),
26
- publish: () => import("./publish-6tgxfck9.js").then((m) => m.default),
27
- validate: () => import("./validate-pktqrye5.js").then((m) => m.default),
28
- preflight: () => import("./preflight-11dg1qkk.js").then((m) => m.default),
29
- doctor: () => import("./doctor-2f3zqmza.js").then((m) => m.default),
30
- ext: () => import("./ext-0cgky8n3.js").then((m) => m.default)
23
+ new: () => import("./new-jtk028rf.js").then((m) => m.default),
24
+ preview: () => import("./preview-d1j1g4qf.js").then((m) => m.default),
25
+ build: () => import("./build-dg8a566j.js").then((m) => m.default),
26
+ publish: () => import("./publish-7yw4jyrt.js").then((m) => m.default),
27
+ validate: () => import("./validate-rkcdnzhw.js").then((m) => m.default),
28
+ preflight: () => import("./preflight-cs6mj1d6.js").then((m) => m.default),
29
+ doctor: () => import("./doctor-g4a42tcz.js").then((m) => m.default),
30
+ ext: () => import("./ext-w9d5ftcg.js").then((m) => m.default)
31
31
  };
32
32
  var VERSION = package_default.version;
33
33
  var main = defineCommand({
@@ -52,7 +52,7 @@ async function preflightRequiredInvocations(rawArgs) {
52
52
  const [command, ...commandArgs] = rawArgs;
53
53
  try {
54
54
  if (command === "new") {
55
- const { newArgs } = await import("./new-88rkrv71.js");
55
+ const { newArgs } = await import("./new-jtk028rf.js");
56
56
  rejectUnknownFlags(commandArgs, newArgs, "new");
57
57
  const parsed = parseArgs(commandArgs, {
58
58
  ...newArgs,
@@ -64,7 +64,7 @@ async function preflightRequiredInvocations(rawArgs) {
64
64
  return;
65
65
  }
66
66
  if (command === "preflight") {
67
- const { preflightArgs } = await import("./preflight-11dg1qkk.js");
67
+ const { preflightArgs } = await import("./preflight-cs6mj1d6.js");
68
68
  rejectUnknownFlags(commandArgs, preflightArgs, "preflight");
69
69
  const parsed = parseArgs(commandArgs, {
70
70
  ...preflightArgs,
@@ -84,7 +84,7 @@ async function preflightRequiredInvocations(rawArgs) {
84
84
  }
85
85
  if (subcommand.startsWith("-"))
86
86
  return;
87
- const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-0cgky8n3.js");
87
+ const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-w9d5ftcg.js");
88
88
  if (!EXT_SUBCOMMANDS.includes(subcommand)) {
89
89
  throw new UsageError(`gutterpress ext: unknown command "${subcommand}"`);
90
90
  }
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  getSystemDiagnostics
3
- } from "./cli-mmgtqnmr.js";
3
+ } from "./cli-vhav8g82.js";
4
4
  import"./cli-5crpmz42.js";
5
5
  import"./cli-asap4t1z.js";
6
6
  import {
7
7
  log
8
- } from "./cli-eatdqx3z.js";
8
+ } from "./cli-1fy1pm9d.js";
9
9
  import {
10
10
  UsageError,
11
11
  rejectExtraPositionals,
12
12
  rejectUnknownFlags
13
13
  } from "./cli-d8xjns66.js";
14
- import"./cli-5ba6bm6z.js";
14
+ import"./cli-s1zt779w.js";
15
15
  import"./cli-46ycxe6r.js";
16
16
  import"./cli-37x76zdn.js";
17
17
 
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The page's own numbers, published as custom properties so a stylesheet reads
3
+ * them instead of keeping a copy that stops following Book setup:
4
+ *
5
+ * --gp-page-width --gp-page-height --gp-page-bleed --gp-page-safe
6
+ * --gp-page-gutter --gp-page-art-safe --gp-page-margin-top
7
+ * --gp-page-margin-bottom --gp-page-margin-inside --gp-page-margin-outside
8
+ *
9
+ * Every value is in `pt` with the unit, so `calc()` takes it directly, and every
10
+ * name is always there: a value the book does not define is `0pt`.
11
+ *
12
+ * Where each comes from:
13
+ * - size and margins: the `@page` reader (`resolvePage`) over the stylesheet
14
+ * the engine reads. The assembly writes the manifest's size, and its margins
15
+ * when it sets any, as plain `@page` rules after every sheet (see
16
+ * lib/markdown/assemble.ts), so the reader returns the manifest's when it
17
+ * decided and the look's or the 1in default when it did not. The recto is
18
+ * read (`:right`, page 1 and every odd page): `inside` is its left, the
19
+ * binding, and `outside` its right.
20
+ * - bleed, safe, gutter, art-safe: the manifest's `page`, through the book's
21
+ * `<meta name="gp-print-area">` (shared/print-area.ts).
22
+ *
23
+ * The size and margins are also published per named page, on the selectors that
24
+ * assign it (the way `--gp-content-h` is); the book-wide ones are on `:root`.
25
+ *
26
+ * Pure: the compiler publishes this CSS for the PDF and the viewer for the
27
+ * preview (viewer/fragment.ts), from the same model and print area.
28
+ */
29
+ import { type GcpmModel } from "./gcpm-extract.ts";
30
+ import { type PrintArea } from "./print-area.ts";
31
+ /** The `gp-page-vars` rules for one book; `area` is `null` when it carries no print area. */
32
+ export declare function pageGeometryVarsCss(model: GcpmModel, area: PrintArea | null): string;
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  build
3
- } from "./cli-58fsk6d7.js";
3
+ } from "./cli-k087gj0p.js";
4
4
  import"./cli-eyyggect.js";
5
5
  import"./cli-asap4t1z.js";
6
+ import"./cli-65gy8ask.js";
6
7
  import {
7
8
  BuildError
8
9
  } from "./cli-46ycxe6r.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  build
3
- } from "./index-wm4x7xbf.js";
4
- import"./index-2vxzxyyj.js";
3
+ } from "./index-fk2kpf2t.js";
4
+ import"./index-798jt0qc.js";
5
5
  import {
6
6
  BuildError
7
- } from "./index-46ycxe6r.js";
7
+ } from "./index-tayzfr9c.js";
8
8
  import"./index-bt0qws5c.js";
9
9
  import"./index-37x76zdn.js";
10
10
 
@@ -2,10 +2,10 @@ import {
2
2
  importExtensionFromFile,
3
3
  importExtensionFromUrl,
4
4
  searchNpmExtensions
5
- } from "./cli-3cvq3n1c.js";
6
- import"./cli-mmgtqnmr.js";
5
+ } from "./cli-989eg8jz.js";
6
+ import"./cli-vhav8g82.js";
7
7
  import"./cli-ht1bcqdd.js";
8
- import"./cli-58fsk6d7.js";
8
+ import"./cli-k087gj0p.js";
9
9
  import"./cli-5crpmz42.js";
10
10
  import"./cli-eyyggect.js";
11
11
  import"./cli-asap4t1z.js";
@@ -18,12 +18,12 @@ import {
18
18
  removeExtension,
19
19
  setExtensionEnabled,
20
20
  updateExtensions
21
- } from "./cli-6pv84kf3.js";
21
+ } from "./cli-e31jshz6.js";
22
22
  import {
23
23
  isPathSpecifier,
24
24
  parseExtensionSpecifier
25
- } from "./cli-wyg7qstd.js";
26
- import"./cli-eatdqx3z.js";
25
+ } from "./cli-ttj95aex.js";
26
+ import"./cli-1fy1pm9d.js";
27
27
  import {
28
28
  UsageError,
29
29
  exitForUsage,
@@ -31,7 +31,8 @@ import {
31
31
  rejectUnknownFlags,
32
32
  resolveProjectDir
33
33
  } from "./cli-d8xjns66.js";
34
- import"./cli-5ba6bm6z.js";
34
+ import"./cli-s1zt779w.js";
35
+ import"./cli-65gy8ask.js";
35
36
  import {
36
37
  EXIT_CODES
37
38
  } from "./cli-46ycxe6r.js";
@@ -3,9 +3,9 @@ import {
3
3
  restoreForCommand,
4
4
  restoreOfflineMessage,
5
5
  restorePinnedExtensions
6
- } from "./index-hphcn7th.js";
7
- import"./index-fp7xwvpr.js";
8
- import"./index-46ycxe6r.js";
6
+ } from "./index-rj5vrhz6.js";
7
+ import"./index-a4j3xcfp.js";
8
+ import"./index-tayzfr9c.js";
9
9
  import"./index-5x42amh8.js";
10
10
  import"./index-37x76zdn.js";
11
11
  export {
@@ -3,11 +3,12 @@ import {
3
3
  restoreForCommand,
4
4
  restoreOfflineMessage,
5
5
  restorePinnedExtensions
6
- } from "./cli-6pv84kf3.js";
7
- import"./cli-wyg7qstd.js";
8
- import"./cli-eatdqx3z.js";
6
+ } from "./cli-e31jshz6.js";
7
+ import"./cli-ttj95aex.js";
8
+ import"./cli-1fy1pm9d.js";
9
9
  import"./cli-d8xjns66.js";
10
- import"./cli-5ba6bm6z.js";
10
+ import"./cli-s1zt779w.js";
11
+ import"./cli-65gy8ask.js";
11
12
  import"./cli-46ycxe6r.js";
12
13
  import"./cli-y28j019d.js";
13
14
  import"./cli-37x76zdn.js";
@@ -34,6 +34,7 @@
34
34
  makeOverflowFragmentable: () => makeOverflowFragmentable,
35
35
  loadStyleSources: () => loadStyleSources,
36
36
  injectViewerCss: () => injectViewerCss,
37
+ injectPageVars: () => injectPageVars,
37
38
  injectBreakMapping: () => injectBreakMapping,
38
39
  indexInStrip: () => indexInStrip,
39
40
  fragmentDocument: () => fragmentDocument,
@@ -1118,6 +1119,7 @@
1118
1119
  }
1119
1120
 
1120
1121
  // src/engine/shared/print-area.ts
1122
+ var round3 = (n) => Math.round(n * 1000) / 1000;
1121
1123
  function printAreaFromMeta(doc) {
1122
1124
  const raw = doc.querySelector('meta[name="gp-print-area"]')?.getAttribute("content");
1123
1125
  if (!raw)
@@ -1200,6 +1202,33 @@
1200
1202
  return { kind, gap, need };
1201
1203
  }
1202
1204
 
1205
+ // src/engine/shared/page-vars.ts
1206
+ var decls = (pairs) => pairs.map(([name, n]) => `--gp-page-${name}: ${round3(n)}pt;`).join(" ");
1207
+ function pageDecls(model, name) {
1208
+ const { width, height, margin } = resolvePage(model, { name, pseudos: ["right"] }).geometry;
1209
+ return decls([
1210
+ ["width", width],
1211
+ ["height", height],
1212
+ ["margin-top", margin.top],
1213
+ ["margin-bottom", margin.bottom],
1214
+ ["margin-inside", margin.left],
1215
+ ["margin-outside", margin.right]
1216
+ ]);
1217
+ }
1218
+ function pageGeometryVarsCss(model, area) {
1219
+ const bookWide = decls([
1220
+ ["bleed", area?.bleed ?? 0],
1221
+ ["safe", area?.safe ?? 0],
1222
+ ["gutter", area?.gutter ?? 0],
1223
+ ["art-safe", area?.artSafe ?? 0]
1224
+ ]);
1225
+ return [
1226
+ `:root { ${pageDecls(model)} ${bookWide} }`,
1227
+ ...model.pageAssignments.map((a) => `${a.selector} { ${pageDecls(model, a.page)} }`)
1228
+ ].join(`
1229
+ `);
1230
+ }
1231
+
1203
1232
  // src/engine/viewer/fragment.ts
1204
1233
  var PX_PER_PT = 96 / 72;
1205
1234
  function injectViewerCss(doc = document) {
@@ -1210,6 +1239,15 @@
1210
1239
  style.textContent = viewer_default;
1211
1240
  doc.head.appendChild(style);
1212
1241
  }
1242
+ function injectPageVars(model, doc = document) {
1243
+ let style = doc.getElementById("gp-page-vars");
1244
+ if (!style) {
1245
+ style = doc.createElement("style");
1246
+ style.id = "gp-page-vars";
1247
+ doc.head.appendChild(style);
1248
+ }
1249
+ style.textContent = pageGeometryVarsCss(model, printAreaFromMeta(doc));
1250
+ }
1213
1251
  var pt = (v) => v * PX_PER_PT;
1214
1252
  function collectCssText(doc = document) {
1215
1253
  let out = "";
@@ -1793,13 +1831,13 @@
1793
1831
  return shim;
1794
1832
  }
1795
1833
  function compensateRectoBreaks(model, strips) {
1796
- const decls = model.breaks.filter(isRectoVersoBreak);
1834
+ const decls2 = model.breaks.filter(isRectoVersoBreak);
1797
1835
  for (const spacer of Array.from(document.querySelectorAll(".gp-recto-spacer")))
1798
1836
  spacer.remove();
1799
- if (!decls.length)
1837
+ if (!decls2.length)
1800
1838
  return 0;
1801
1839
  const sites = [];
1802
- for (const d of decls) {
1840
+ for (const d of decls2) {
1803
1841
  let els = [];
1804
1842
  try {
1805
1843
  els = Array.from(document.querySelectorAll(d.selector));
@@ -1993,6 +2031,7 @@
1993
2031
  document.head.appendChild(style);
1994
2032
  }
1995
2033
  const model = extract(css);
2034
+ injectPageVars(model);
1996
2035
  injectBreakMapping(model);
1997
2036
  const authoring = [];
1998
2037
  const strips = buildStrips(model, opts, authoring);
@@ -2861,8 +2900,8 @@
2861
2900
  } catch {}
2862
2901
  return document.getElementById(id);
2863
2902
  }
2864
- function applyPageBackground(sheet, decls) {
2865
- for (const [prop, value] of Object.entries(decls)) {
2903
+ function applyPageBackground(sheet, decls2) {
2904
+ for (const [prop, value] of Object.entries(decls2)) {
2866
2905
  const p = prop.toLowerCase();
2867
2906
  if (p !== "background" && !p.startsWith("background-"))
2868
2907
  continue;
@@ -2941,8 +2980,8 @@
2941
2980
  }
2942
2981
  if (blankPages.has(bookIndex)) {
2943
2982
  const pseudos2 = ["blank"];
2944
- const { geometry: geometry2, marginBoxes: marginBoxes2, decls: decls2 } = resolvePage(model, { pseudos: pseudos2 });
2945
- return { index: bookIndex, strip, pseudos: pseudos2, geometry: geometry2, marginBoxes: marginBoxes2, decls: decls2 };
2983
+ const { geometry: geometry2, marginBoxes: marginBoxes2, decls: decls3 } = resolvePage(model, { pseudos: pseudos2 });
2984
+ return { index: bookIndex, strip, pseudos: pseudos2, geometry: geometry2, marginBoxes: marginBoxes2, decls: decls3 };
2946
2985
  }
2947
2986
  const pseudos = [];
2948
2987
  if (bookIndex === 0)
@@ -2950,11 +2989,11 @@
2950
2989
  if (indexInStrip2 === 0)
2951
2990
  pseudos.push("nth-first-of-run");
2952
2991
  pseudos.push(bookIndex % 2 === 0 ? "right" : "left");
2953
- const { geometry, marginBoxes, decls } = resolvePage(model, {
2992
+ const { geometry, marginBoxes, decls: decls2 } = resolvePage(model, {
2954
2993
  name: strip.page,
2955
2994
  pseudos
2956
2995
  });
2957
- return { index: bookIndex, strip, pseudos, geometry, marginBoxes, decls };
2996
+ return { index: bookIndex, strip, pseudos, geometry, marginBoxes, decls: decls2 };
2958
2997
  }
2959
2998
  function buildMaps() {
2960
2999
  api.stringMap = new Map;
@@ -3150,10 +3189,10 @@
3150
3189
  function drawMarginBoxes(sheet, ctx, totalPages) {
3151
3190
  const g = ctx.geometry;
3152
3191
  for (const name of MARGIN_BOX_NAMES) {
3153
- const decls = ctx.marginBoxes[`@${name}`];
3154
- if (!decls?.content)
3192
+ const decls2 = ctx.marginBoxes[`@${name}`];
3193
+ if (!decls2?.content)
3155
3194
  continue;
3156
- const text = evaluate(decls.content, {
3195
+ const text = evaluate(decls2.content, {
3157
3196
  page: api.pageNumbers[ctx.index] ?? ctx.index + 1,
3158
3197
  pages: totalPages,
3159
3198
  strings: (n, w) => stringAt(n, w, ctx.index),
@@ -3169,7 +3208,7 @@
3169
3208
  const content = document.createElement("span");
3170
3209
  content.className = "gp-marginbox-content";
3171
3210
  content.textContent = text;
3172
- for (const [prop, value] of Object.entries(decls)) {
3211
+ for (const [prop, value] of Object.entries(decls2)) {
3173
3212
  if (prop.toLowerCase() === "content" || isIgnoredMarginBoxProperty(prop))
3174
3213
  continue;
3175
3214
  content.style.setProperty(prop, value);