@bendyline/squisq-react 2.12.9 → 2.12.11

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.
@@ -12,7 +12,7 @@ import {
12
12
  getAnchorOffset,
13
13
  getTransitionClass,
14
14
  resolveValue
15
- } from "./chunk-DN6JZRJI.js";
15
+ } from "./chunk-VX5XFSGI.js";
16
16
 
17
17
  // src/BlockRenderer.tsx
18
18
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-6BKIY72Q.js";
3
+ } from "./chunk-YLTG7BV5.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {
@@ -613,10 +613,7 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
613
613
  style: textStyles,
614
614
  filter: filterId ? `url(#${filterId})` : void 0,
615
615
  transform: fitTransform,
616
- children: lines.map((line, i) => /* @__PURE__ */ jsxs2("tspan", { x, dy: i === 0 ? firstLineDy + baselineShiftPx : lineHeightPx, children: [
617
- renderLine(line),
618
- " "
619
- ] }, i))
616
+ children: lines.map((line, i) => /* @__PURE__ */ jsx3("tspan", { x, dy: i === 0 ? firstLineDy + baselineShiftPx : lineHeightPx, children: renderLine(line) }, i))
620
617
  }
621
618
  )
622
619
  }
@@ -856,7 +853,11 @@ function ShapeLayer({ layer, viewport, blockTime }) {
856
853
  const animStyle = getAnimationStyle(animation, blockTime);
857
854
  const fill = content.fill || "none";
858
855
  const isCSSGradient = typeof fill === "string" && fill.includes("gradient(");
859
- if (content.shape === "rect" && isCSSGradient && !content.gradient) {
856
+ const backdropFilter = content.shape === "rect" ? [
857
+ content.backdropBlur ? `blur(${content.backdropBlur}px)` : "",
858
+ content.backdropContrast !== void 0 ? `contrast(${content.backdropContrast})` : ""
859
+ ].filter(Boolean).join(" ") : "";
860
+ if (content.shape === "rect" && (isCSSGradient && !content.gradient || backdropFilter)) {
860
861
  return (
861
862
  // Shape layers are visual primitives. In particular, theme top-layers
862
863
  // can cover the whole slide; they must not shield interactive table,
@@ -876,6 +877,7 @@ function ShapeLayer({ layer, viewport, blockTime }) {
876
877
  height: `${paintHeight}px`,
877
878
  background: fill,
878
879
  borderRadius: content.borderRadius ? `${content.borderRadius}px` : void 0,
880
+ ...backdropFilter ? { backdropFilter, WebkitBackdropFilter: backdropFilter } : {},
879
881
  pointerEvents: "none"
880
882
  }
881
883
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-6BKIY72Q.js";
3
+ } from "./chunk-YLTG7BV5.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
@@ -15,11 +15,11 @@ import {
15
15
  } from "./chunk-FLPGMUXM.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-WACTP75S.js";
18
+ } from "./chunk-S73QOMOR.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-DN6JZRJI.js";
22
+ } from "./chunk-VX5XFSGI.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
@@ -523,6 +523,9 @@ var SOCIAL_CAPTION_LAYOUT = {
523
523
  chunkPadXEm: 0.55,
524
524
  letterSpacingEm: 0.01
525
525
  };
526
+ function socialCaptionLayout(textCase = "upper") {
527
+ return textCase === "upper" ? SOCIAL_CAPTION_LAYOUT : { ...SOCIAL_CAPTION_LAYOUT, columnGapEm: 0.16 };
528
+ }
526
529
  var CHAR_EM = {
527
530
  A: 0.76,
528
531
  B: 0.76,
@@ -582,28 +585,116 @@ var CHAR_EM = {
582
585
  "\xB0": 0.42,
583
586
  $: 0.64
584
587
  };
588
+ var AS_WRITTEN_CHAR_EM = {
589
+ A: 0.76,
590
+ B: 0.76,
591
+ C: 0.74,
592
+ D: 0.83,
593
+ E: 0.72,
594
+ F: 0.67,
595
+ G: 0.81,
596
+ H: 0.91,
597
+ I: 0.45,
598
+ J: 0.6,
599
+ K: 0.82,
600
+ L: 0.69,
601
+ M: 1.02,
602
+ N: 0.84,
603
+ O: 0.82,
604
+ P: 0.7,
605
+ Q: 0.82,
606
+ R: 0.8,
607
+ S: 0.67,
608
+ T: 0.68,
609
+ U: 0.83,
610
+ V: 0.76,
611
+ W: 1.13,
612
+ X: 0.81,
613
+ Y: 0.73,
614
+ Z: 0.69,
615
+ a: 0.6,
616
+ b: 0.65,
617
+ c: 0.57,
618
+ d: 0.66,
619
+ e: 0.57,
620
+ f: 0.39,
621
+ g: 0.61,
622
+ h: 0.68,
623
+ i: 0.35,
624
+ j: 0.35,
625
+ k: 0.63,
626
+ l: 0.34,
627
+ m: 1.02,
628
+ n: 0.69,
629
+ o: 0.64,
630
+ p: 0.66,
631
+ q: 0.65,
632
+ r: 0.52,
633
+ s: 0.56,
634
+ t: 0.4,
635
+ u: 0.68,
636
+ v: 0.57,
637
+ w: 0.86,
638
+ x: 0.59,
639
+ y: 0.56,
640
+ z: 0.53,
641
+ "0": 0.7,
642
+ "1": 0.57,
643
+ "2": 0.63,
644
+ "3": 0.62,
645
+ "4": 0.65,
646
+ "5": 0.6,
647
+ "6": 0.65,
648
+ "7": 0.57,
649
+ "8": 0.68,
650
+ "9": 0.65,
651
+ "'": 0.28,
652
+ "\u2019": 0.31,
653
+ ".": 0.33,
654
+ ",": 0.33,
655
+ ";": 0.37,
656
+ ":": 0.37,
657
+ "!": 0.38,
658
+ "?": 0.61,
659
+ "-": 0.41,
660
+ "\u2013": 0.7,
661
+ "\u2014": 1,
662
+ '"': 0.51,
663
+ "\u201C": 0.52,
664
+ "\u201D": 0.52,
665
+ "(": 0.45,
666
+ ")": 0.45,
667
+ "%": 1,
668
+ "&": 0.9,
669
+ "/": 0.47,
670
+ "\xB0": 0.44,
671
+ $: 0.64
672
+ };
585
673
  var DEFAULT_CHAR_EM = 0.9;
586
674
  var WIDTH_SAFETY = 1.06;
587
- function estimateSocialWordEm(text) {
675
+ function estimateSocialWordEm(text, textCase = "upper") {
676
+ const upper = textCase === "upper";
677
+ const table = upper ? CHAR_EM : AS_WRITTEN_CHAR_EM;
588
678
  let em = 0;
589
679
  let count = 0;
590
- for (const ch of text.toUpperCase().normalize("NFD").replace(/\p{M}/gu, "")) {
591
- em += CHAR_EM[ch] ?? DEFAULT_CHAR_EM;
680
+ for (const ch of (upper ? text.toUpperCase() : text).normalize("NFD").replace(/\p{M}/gu, "")) {
681
+ em += table[ch] ?? DEFAULT_CHAR_EM;
592
682
  count++;
593
683
  }
594
- const { letterSpacingEm: letterSpacingEm2, wordPadEm: wordPadEm2 } = SOCIAL_CAPTION_LAYOUT;
595
- return (em + count * letterSpacingEm2) * WIDTH_SAFETY + 2 * wordPadEm2;
684
+ const { letterSpacingEm, wordPadEm } = socialCaptionLayout(textCase);
685
+ return (em + count * letterSpacingEm) * WIDTH_SAFETY + 2 * wordPadEm;
596
686
  }
597
- function estimateSocialRows(words, rowEm) {
687
+ function estimateSocialRows(words, rowEm, textCase = "upper") {
688
+ const { columnGapEm } = socialCaptionLayout(textCase);
598
689
  let rows = 0;
599
690
  let x = 0;
600
691
  for (const word of words) {
601
- const width = estimateSocialWordEm(word);
692
+ const width = estimateSocialWordEm(word, textCase);
602
693
  if (rows === 0) {
603
694
  rows = 1;
604
695
  x = width;
605
- } else if (x + SOCIAL_CAPTION_LAYOUT.columnGapEm + width <= rowEm) {
606
- x += SOCIAL_CAPTION_LAYOUT.columnGapEm + width;
696
+ } else if (x + columnGapEm + width <= rowEm) {
697
+ x += columnGapEm + width;
607
698
  } else {
608
699
  rows++;
609
700
  x = width;
@@ -611,12 +702,16 @@ function estimateSocialRows(words, rowEm) {
611
702
  }
612
703
  return rows;
613
704
  }
705
+ function endsSentence(text) {
706
+ return /[.!?…]["'”’»)\]]*$/.test(text);
707
+ }
614
708
  function resolvePhraseTiming(phrase) {
615
709
  if (phrase.words && phrase.words.length > 0) {
616
710
  return phrase.words.map((w) => ({
617
711
  text: w.text,
618
712
  startTime: w.startTime,
619
- endTime: w.endTime
713
+ endTime: w.endTime,
714
+ ...w.paragraphEnd ? { paragraphEnd: true } : {}
620
715
  }));
621
716
  }
622
717
  const rawWords = phrase.text.split(/\s+/).filter((w) => w.length > 0);
@@ -629,7 +724,7 @@ function resolvePhraseTiming(phrase) {
629
724
  endTime: phrase.startTime + (i + 1) * wordDuration
630
725
  }));
631
726
  }
632
- function buildWordStream(captions, rowEm = Number.POSITIVE_INFINITY) {
727
+ function buildWordStream(captions, rowEm = Number.POSITIVE_INFINITY, textCase = "upper") {
633
728
  const allWords = [];
634
729
  for (const phrase of captions.phrases) {
635
730
  for (const word of resolvePhraseTiming(phrase))
@@ -656,7 +751,7 @@ function buildWordStream(captions, rowEm = Number.POSITIVE_INFINITY) {
656
751
  current = [];
657
752
  };
658
753
  for (const word of allWords) {
659
- if (current.length > 0 && (current.length >= chunkSize || word.segment !== current[0].segment || estimateSocialRows([...current.map((w) => w.text), word.text], rowEm) > SOCIAL_CAPTION_MAX_ROWS)) {
754
+ if (current.length > 0 && (current.length >= chunkSize || word.segment !== current[0].segment || current[current.length - 1].paragraphEnd || current.length >= MIN_CHUNK_SIZE && endsSentence(current[current.length - 1].text) || estimateSocialRows([...current.map((w) => w.text), word.text], rowEm, textCase) > SOCIAL_CAPTION_MAX_ROWS)) {
660
755
  close();
661
756
  }
662
757
  current.push(word);
@@ -667,7 +762,6 @@ function buildWordStream(captions, rowEm = Number.POSITIVE_INFINITY) {
667
762
 
668
763
  // src/SocialCaptionOverlay.tsx
669
764
  import { jsx as jsx2 } from "react/jsx-runtime";
670
- var { wordPadEm, columnGapEm, chunkPadXEm, letterSpacingEm } = SOCIAL_CAPTION_LAYOUT;
671
765
  function positionStyle(position, portrait) {
672
766
  switch (position) {
673
767
  case "top":
@@ -703,10 +797,12 @@ function SocialCaptionOverlay({
703
797
  const baseFontSize = Math.min(viewportHeight * 0.055, viewportWidth * 0.068);
704
798
  const fontSize = Math.max(22, Math.min(96, Math.round(baseFontSize)));
705
799
  const sidePadding = portrait ? 0.07 : 0.1;
800
+ const textCase = theme?.typography?.captionCase ?? "upper";
801
+ const { wordPadEm, columnGapEm, chunkPadXEm, letterSpacingEm } = socialCaptionLayout(textCase);
706
802
  const rowEm = viewportWidth * (1 - 2 * sidePadding) / fontSize - 2 * chunkPadXEm;
707
803
  const { chunks } = useMemo3(
708
- () => captions ? buildWordStream(captions, rowEm) : { words: [], chunks: [] },
709
- [captions, rowEm]
804
+ () => captions ? buildWordStream(captions, rowEm, textCase) : { words: [], chunks: [] },
805
+ [captions, rowEm, textCase]
710
806
  );
711
807
  if (!enabled || chunks.length === 0) {
712
808
  return /* @__PURE__ */ jsx2(
@@ -765,8 +861,11 @@ function SocialCaptionOverlay({
765
861
  if (activeWordIndex === -1) activeWordIndex = 0;
766
862
  }
767
863
  const primaryColor = theme?.colors?.primary ?? "#5b9bd5";
768
- const fontFamily = theme?.typography?.titleFont ? resolveFontFamily(theme.typography.titleFont, '"PT Serif", Georgia, serif') : '"PT Serif", Georgia, serif';
769
- const widestEm = Math.max(...activeChunk.words.map((w) => estimateSocialWordEm(w.text)));
864
+ const captionFont = theme?.typography?.captionFont ?? theme?.typography?.titleFont;
865
+ const fontFamily = captionFont ? resolveFontFamily(captionFont, '"PT Serif", Georgia, serif') : '"PT Serif", Georgia, serif';
866
+ const widestEm = Math.max(
867
+ ...activeChunk.words.map((w) => estimateSocialWordEm(w.text, textCase))
868
+ );
770
869
  const chunkFontSize = widestEm > rowEm ? Math.max(16, Math.floor(fontSize * rowEm / widestEm)) : fontSize;
771
870
  return /* @__PURE__ */ jsx2(
772
871
  "div",
@@ -806,7 +905,7 @@ function SocialCaptionOverlay({
806
905
  fontFamily,
807
906
  fontSize: `${chunkFontSize}px`,
808
907
  lineHeight: 1.18,
809
- textTransform: "uppercase",
908
+ textTransform: textCase === "upper" ? "uppercase" : "none",
810
909
  letterSpacing: `${letterSpacingEm}em`,
811
910
  whiteSpace: "normal"
812
911
  },
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-FLPGMUXM.js";
9
9
  import {
10
10
  BlockRenderer
11
- } from "./chunk-WACTP75S.js";
11
+ } from "./chunk-S73QOMOR.js";
12
12
  import {
13
13
  svgDataImageSrc,
14
14
  useMediaUrl
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BlockRenderer
3
- } from "../chunk-WACTP75S.js";
4
- import "../chunk-DN6JZRJI.js";
3
+ } from "../chunk-S73QOMOR.js";
4
+ import "../chunk-VX5XFSGI.js";
5
5
  import "../chunk-BXPGK5VO.js";
6
6
  import {
7
7
  renderMermaidSvgForExport
package/dist/index.js CHANGED
@@ -17,17 +17,17 @@ import {
17
17
  resolveDocPlayerAppearance,
18
18
  useBuildNavigation,
19
19
  useMediaClipDurations
20
- } from "./chunk-3SMC447F.js";
20
+ } from "./chunk-WWVCJLRY.js";
21
21
  import {
22
22
  PaginatedDocView
23
- } from "./chunk-R7PHQNC7.js";
23
+ } from "./chunk-VT7JZORD.js";
24
24
  import {
25
25
  CanvasSection,
26
26
  LinearDocView,
27
27
  PageSectionView,
28
28
  PageViewContext,
29
29
  usePageView
30
- } from "./chunk-6BKIY72Q.js";
30
+ } from "./chunk-YLTG7BV5.js";
31
31
  import {
32
32
  useModalDialog
33
33
  } from "./chunk-JP457U6N.js";
@@ -57,7 +57,7 @@ import {
57
57
  } from "./chunk-FLPGMUXM.js";
58
58
  import {
59
59
  BlockRenderer
60
- } from "./chunk-WACTP75S.js";
60
+ } from "./chunk-S73QOMOR.js";
61
61
  import {
62
62
  ImageLayer,
63
63
  MapLayer,
@@ -71,7 +71,7 @@ import {
71
71
  VideoLayer,
72
72
  getAnimationStyle,
73
73
  getTransitionClass
74
- } from "./chunk-DN6JZRJI.js";
74
+ } from "./chunk-VX5XFSGI.js";
75
75
  import {
76
76
  MermaidDiagram
77
77
  } from "./chunk-BXPGK5VO.js";
@@ -9,7 +9,7 @@ import {
9
9
  TextLayer,
10
10
  TreeLayer,
11
11
  VideoLayer
12
- } from "../chunk-DN6JZRJI.js";
12
+ } from "../chunk-VX5XFSGI.js";
13
13
  import "../chunk-BXPGK5VO.js";
14
14
  import "../chunk-P6MT4F3R.js";
15
15
  export {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  PaginatedDocView
3
- } from "../chunk-R7PHQNC7.js";
3
+ } from "../chunk-VT7JZORD.js";
4
4
  import {
5
5
  CanvasSection,
6
6
  LinearDocView,
7
7
  PageSectionView,
8
8
  PageViewContext,
9
9
  usePageView
10
- } from "../chunk-6BKIY72Q.js";
10
+ } from "../chunk-YLTG7BV5.js";
11
11
  import "../chunk-TT6ENR6T.js";
12
12
  import "../chunk-FLPGMUXM.js";
13
- import "../chunk-WACTP75S.js";
14
- import "../chunk-DN6JZRJI.js";
13
+ import "../chunk-S73QOMOR.js";
14
+ import "../chunk-VX5XFSGI.js";
15
15
  import "../chunk-BXPGK5VO.js";
16
16
  import "../chunk-P6MT4F3R.js";
17
17
  export {
@@ -12,8 +12,8 @@ import {
12
12
  MediaClipLayer,
13
13
  SocialCaptionOverlay,
14
14
  formatTime
15
- } from "../chunk-3SMC447F.js";
16
- import "../chunk-6BKIY72Q.js";
15
+ } from "../chunk-WWVCJLRY.js";
16
+ import "../chunk-YLTG7BV5.js";
17
17
  import "../chunk-M44RDTSG.js";
18
18
  import "../chunk-TT6ENR6T.js";
19
19
  import {
@@ -22,8 +22,8 @@ import {
22
22
  } from "../chunk-FLPGMUXM.js";
23
23
  import {
24
24
  BlockRenderer
25
- } from "../chunk-WACTP75S.js";
26
- import "../chunk-DN6JZRJI.js";
25
+ } from "../chunk-S73QOMOR.js";
26
+ import "../chunk-VX5XFSGI.js";
27
27
  import "../chunk-BXPGK5VO.js";
28
28
  import "../chunk-P6MT4F3R.js";
29
29
  export {