@dloizides/poster-render 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.7
4
+
5
+ - P-B "Phone arch": the title block starts at the top margin (0.05h) instead of under a clock zone; the arch picture starts at 0.47h and grows.
6
+ - The footer stays attached under the includes list: columns never spread space between them, and both stay in one column.
7
+
3
8
  ## 0.2.5
4
9
 
5
10
  - Own-key checks: the schema validator and the asset lookup use `Object.hasOwn`, so a `__proto__` key is rejected and an imageId such as `constructor` is reported missing.
package/dist/index.js CHANGED
@@ -299,7 +299,7 @@ var flanksBeside = (pic, top, bottom2, m) => [
299
299
  [pic[0] + pic[2] + m, top, 1 - pic[0] - pic[2] - 2 * m, bottom2 - top]
300
300
  ];
301
301
  var ARCH_PIC = [0.22, 0.42, 0.56, 0.58];
302
- var PHONE_ARCH_PIC = [0.2, 0.6, 0.6, 0.4];
302
+ var PHONE_ARCH_PIC = [0.2, 0.47, 0.6, 0.53];
303
303
  var DESK_ARCH_PIC = [0.355, 0.07, 0.32, 0.93];
304
304
  var ARCH_LANDSCAPE = {
305
305
  header: [0.04, 0.06, 0.3, 0.5],
@@ -319,7 +319,7 @@ var LAYOUT_SPECS = {
319
319
  landscape: { header: [0.04, 0.2, 0.52, 0.3], body: [0.04, 0.52, 0.52, 0.42], picture: [0.6, 0.12, 0.4, 0.88], alignX: 1 }
320
320
  },
321
321
  ["phone-arch" /* PhoneArch */]: {
322
- portrait: { header: [0.045, 0.3, 0.91, 0.13], body: [0.045, 0.44, 0.91, 0.14], picture: PHONE_ARCH_PIC, alignX: 0.5, flanks: flanksBeside(PHONE_ARCH_PIC, 0.63, 0.94, 0.03), arch: 0.08 },
322
+ portrait: { header: [0.045, 0.05, 0.91, 0.16], body: [0.045, 0.22, 0.91, 0.21], picture: PHONE_ARCH_PIC, alignX: 0.5, flanks: flanksBeside(PHONE_ARCH_PIC, 0.5, 0.94, 0.03), arch: 0.08 },
323
323
  landscape: { ...ARCH_LANDSCAPE, header: [0.04, 0.16, 0.3, 0.42], picture: [0.36, 0.16, 0.3, 0.84] }
324
324
  },
325
325
  ["desktop-safe" /* DesktopSafe */]: {
@@ -552,7 +552,7 @@ function bodyGroups(doc, p, u, options = {}) {
552
552
  groups.push(...isList ? listGroups(doc, l, u) : eventGroups(doc, l, u, options));
553
553
  if (b.includes) {
554
554
  const lines = [l.accent(b.includes.heading, SIZE.small), ...b.includes.items.map((i) => l.item(i, SIZE.small))].flatMap((line) => wrapped(line, options.wrap));
555
- groups.push({ lines, gapAfter: GAP.includes * u, uniform: true });
555
+ groups.push({ lines, gapAfter: GAP.includes * u, uniform: true, keepWithNext: b.footer !== void 0, attachNext: b.footer !== void 0 });
556
556
  }
557
557
  if (b.footer) {
558
558
  groups.push({ lines: wrapped(l.soft(b.footer, SIZE.small), options.wrap), gapAfter: 0 });
@@ -641,11 +641,15 @@ function placeGroup(m, at, out) {
641
641
  function placeColumn(groups, at, out) {
642
642
  const { k, col, spread = 0 } = at;
643
643
  let h = 0;
644
- for (const g of groups) {
645
- h += placeGroup(g, { k, col, y0: col.y + h }, out) + spread;
646
- }
647
- return h - spread;
644
+ groups.forEach((g, i) => {
645
+ h += placeGroup(g, { k, col, y0: col.y + h }, out);
646
+ if (i < groups.length - 1 && g.group.attachNext !== true) {
647
+ h += spread;
648
+ }
649
+ });
650
+ return h;
648
651
  }
652
+ var spreadGaps = (groups) => groups.slice(0, -1).filter((g) => g.group.attachNext !== true).length;
649
653
  var columnSum = (heights, from, to) => heights.slice(from, to).reduce((a, b) => a + b, 0);
650
654
  var tallest = (heights, cut) => {
651
655
  const left = heights.slice(0, cut).reduce((a, b) => a + b, 0);
@@ -725,7 +729,10 @@ function flow(ctx, groups, zone, fonts) {
725
729
  const out = emptyFlow();
726
730
  const heights = columns.map((c) => placeColumn(c.groups, { k: lo, col: c.col }, null));
727
731
  const end = Math.max(...heights);
728
- columns.forEach((c, i) => placeColumn(c.groups, { k: lo, col: c.col, spread: c.groups.length > 1 && columns.length > 1 ? (end - (heights[i] ?? end)) / (c.groups.length - 1) : 0 }, out));
732
+ columns.forEach((c, i) => {
733
+ const gaps = spreadGaps(c.groups);
734
+ placeColumn(c.groups, { k: lo, col: c.col, spread: gaps > 0 && columns.length > 1 ? (end - (heights[i] ?? end)) / gaps : 0 }, out);
735
+ });
729
736
  const lines = groups.flatMap((g) => g.lines);
730
737
  out.texts.forEach((t, i) => {
731
738
  const line = lines[i];
@@ -1030,7 +1037,7 @@ var LAYOUT_CATALOGUE = [
1030
1037
  { id: "picture-bottom" /* PictureBottom */, designId: "picture-bottom", label: "Picture bottom", description: "Titles and details on top, the picture across the bottom half.", formats: POSTERS },
1031
1038
  { id: "list" /* List */, designId: "list", label: "Upcoming list", description: "Several dated events as a list beside the picture.", formats: POSTERS },
1032
1039
  { id: "phone-clock-safe" /* PhoneClockSafe */, designId: "P-A", label: "Phone, clock clear", description: "Lock-screen wallpaper: top kept clear for the clock, details on the left, picture on the right.", formats: ["phone" /* Phone */] },
1033
- { id: "phone-arch" /* PhoneArch */, designId: "P-B", label: "Phone arch", description: "Lock-screen wallpaper: top kept clear for the clock, details in the middle, the picture in an arch at the bottom.", formats: ["phone" /* Phone */] },
1040
+ { id: "phone-arch" /* PhoneArch */, designId: "P-B", label: "Phone arch", description: "Lock-screen wallpaper: titles at the top, details under them, the picture in an arch at the bottom.", formats: ["phone" /* Phone */] },
1034
1041
  { id: "desktop-safe" /* DesktopSafe */, designId: "D-A", label: "Desktop, icons clear", description: "Desktop wallpaper: text on the left clear of desktop icons and the taskbar, the picture on the right.", formats: ["desktop" /* Desktop */] },
1035
1042
  { id: "desktop-arch" /* DesktopArch */, designId: "D-B", label: "Desktop arch", description: "Desktop wallpaper: titles left, the picture in a centred arch, details right.", formats: ["desktop" /* Desktop */] }
1036
1043
  ];