presenter 0.9.3 → 0.9.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.
package/dist/export.mjs CHANGED
@@ -757,40 +757,34 @@ function Sa(t) {
757
757
  return typeof t == "string" ? [[{ text: t }]] : t.map((n) => n.map((e) => typeof e == "string" ? { text: e } : e));
758
758
  }
759
759
  function Br(t) {
760
+ const n = Math.max(...t.map((A) => A.bottom), 0), e = Math.max(...t.map((A) => A.top), 0);
760
761
  return {
761
- bottom: Math.max(...t.map((n) => n.bottom), 0),
762
- height: Math.max(...t.map((n) => n.height), 0),
763
- lineAdvance: Math.max(...t.map((n) => n.lineAdvance), 0),
764
- top: Math.max(...t.map((n) => n.top), 0),
765
- width: t.reduce((n, e) => n + e.width, 0)
762
+ bottom: n,
763
+ height: e + n,
764
+ lineAdvance: Math.max(...t.map((A) => A.lineAdvance), 0),
765
+ top: e,
766
+ width: t.reduce((A, a) => A + a.width, 0)
766
767
  };
767
768
  }
768
769
  function Ia(t, n = 1) {
769
770
  const e = t.map(Br);
770
771
  if (e.length === 0)
771
772
  return {
772
- lines: [],
773
+ baselines: [],
773
774
  size: xt()
774
775
  };
775
- let A = e[0]?.top ?? 0, a = 0;
776
- const i = [];
777
- for (let r = 0; r < e.length; r++) {
778
- const o = e[r];
779
- o !== void 0 && (r > 0 && (A += a * n), i.push({
780
- ...o,
781
- baselineY: A
782
- }), a = o.lineAdvance);
776
+ let A = 0, a, i = 0, s = 0;
777
+ const c = [];
778
+ for (const r of e) {
779
+ const f = (r.lineAdvance * n - r.height) / 2, g = r.top + f;
780
+ a === void 0 ? A = g : A += a + g, c.push(A), i = Math.min(i, A - r.top), s = Math.max(s, A + r.bottom), a = r.bottom + f;
783
781
  }
784
- const s = Math.min(...i.map((r) => r.baselineY - r.top), 0), c = Math.max(...i.map((r) => r.baselineY + r.bottom), 0), l = -s;
782
+ const l = -i;
785
783
  return {
786
- lines: i.map((r) => ({
787
- ...r,
788
- // Keep all returned baselines relative to the top edge of the final text block
789
- baselineY: r.baselineY + l
790
- })),
784
+ baselines: c.map((r) => r + l),
791
785
  size: xt({
792
- height: c - s,
793
- width: Math.max(...i.map((r) => r.width), 0)
786
+ height: s - i,
787
+ width: Math.max(...e.map((r) => r.width), 0)
794
788
  })
795
789
  };
796
790
  }
@@ -859,7 +853,7 @@ const Pr = ({ ctx: t, object: n, opacity: e }) => {
859
853
  const { length: a } = n, i = Sa(n.text), s = Fa(n), c = Ea(i, s, t), l = Ia(c, n.lineSpacing), r = Ot(mt({ x: n.x, y: n.y }), n.anchor, l.size);
860
854
  let o = r.origin.x, f = 0;
861
855
  for (let g = 0; g < i.length; g++) {
862
- const d = i[g], m = c[g], u = l.lines[g];
856
+ const d = i[g], m = c[g], u = l.baselines[g];
863
857
  if (d == null || m == null || u == null) {
864
858
  console.error("Could not determine text units or sizes for line");
865
859
  continue;
@@ -879,7 +873,7 @@ const Pr = ({ ctx: t, object: n, opacity: e }) => {
879
873
  Ut(n.alignment);
880
874
  break;
881
875
  }
882
- const v = r.origin.y + u.baselineY;
876
+ const v = r.origin.y + u;
883
877
  for (let b = 0; b < d.length && !(a !== null && f >= a); b++) {
884
878
  const x = d[b], k = m[b];
885
879
  if (x == null || k == null) {