@sesionario/blocks 1.17.1 → 1.18.0

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/index.cjs CHANGED
@@ -3788,7 +3788,7 @@ function insertAtCaret(element, value, text) {
3788
3788
  }
3789
3789
 
3790
3790
  // src/components/emoji/emoji-field-shared.ts
3791
- var emojiFieldWrapperClassName = "relative w-full rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 has-[[aria-invalid=true]]:border-destructive has-[[aria-invalid=true]]:ring-destructive/20 has-[:disabled]:opacity-50 dark:bg-input/30 dark:has-[[aria-invalid=true]]:ring-destructive/40";
3791
+ var emojiFieldWrapperClassName = "relative w-full rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 has-[[aria-invalid=true]]:border-destructive has-[[aria-invalid=true]]:ring-destructive/20 has-[[data-slot=textarea]:disabled]:opacity-50 has-[[data-slot=input]:disabled]:opacity-50 dark:bg-input/30 dark:has-[[aria-invalid=true]]:ring-destructive/40";
3792
3792
  var emojiFieldResetClassName = "border-0 bg-transparent shadow-none focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent";
3793
3793
  function mergeRefs(...refs) {
3794
3794
  return (node) => {
@@ -4514,6 +4514,7 @@ function VideoPlayer({
4514
4514
  stats,
4515
4515
  labels,
4516
4516
  showQualitySelector = true,
4517
+ paused = false,
4517
4518
  onPlayingChange,
4518
4519
  onFirstPlay,
4519
4520
  onError,
@@ -4605,6 +4606,11 @@ function VideoPlayer({
4605
4606
  video.removeEventListener("ratechange", onRate);
4606
4607
  };
4607
4608
  }, [videoRef, active, mode]);
4609
+ React7__namespace.useEffect(() => {
4610
+ const video = videoRef.current;
4611
+ if (!paused || !video || !isPlaying) return;
4612
+ video.pause();
4613
+ }, [paused, videoRef, isPlaying]);
4608
4614
  React7__namespace.useEffect(() => {
4609
4615
  setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
4610
4616
  }, [videoRef, active]);
@@ -5112,6 +5118,106 @@ function MenuItem({
5112
5118
  }
5113
5119
  );
5114
5120
  }
5121
+
5122
+ // src/components/video/feedPlaybackCoordinator.ts
5123
+ var players = /* @__PURE__ */ new Map();
5124
+ function registerFeedPlayer(id, pause) {
5125
+ players.set(id, pause);
5126
+ return () => {
5127
+ if (players.get(id) === pause) {
5128
+ players.delete(id);
5129
+ }
5130
+ };
5131
+ }
5132
+ function claimFeedPlaying(id) {
5133
+ for (const [otherId, pause] of players) {
5134
+ if (otherId !== id) pause();
5135
+ }
5136
+ }
5137
+
5138
+ // src/components/video/useFeedExclusivePlayback.ts
5139
+ var VISIBILITY_THRESHOLDS = [0, 0.5, 1];
5140
+ var MIN_VISIBLE_RATIO = 0.5;
5141
+ function videoInPictureInPicture(container) {
5142
+ if (typeof document === "undefined" || !container) return false;
5143
+ const pip = document.pictureInPictureElement;
5144
+ if (!pip) return false;
5145
+ return container.contains(pip);
5146
+ }
5147
+ function useFeedExclusivePlayback(playbackId) {
5148
+ const containerRef = React7__namespace.useRef(null);
5149
+ const [forcePaused, setForcePaused] = React7__namespace.useState(false);
5150
+ const requestPause = React7__namespace.useCallback(() => {
5151
+ if (videoInPictureInPicture(containerRef.current)) return;
5152
+ setForcePaused(true);
5153
+ }, []);
5154
+ React7__namespace.useEffect(() => {
5155
+ return registerFeedPlayer(playbackId, requestPause);
5156
+ }, [playbackId, requestPause]);
5157
+ React7__namespace.useEffect(() => {
5158
+ const node = containerRef.current;
5159
+ if (!node || typeof IntersectionObserver === "undefined") return;
5160
+ const observer = new IntersectionObserver(
5161
+ (entries) => {
5162
+ const entry = entries[0];
5163
+ if (!entry) return;
5164
+ if (!entry.isIntersecting || entry.intersectionRatio < MIN_VISIBLE_RATIO) {
5165
+ requestPause();
5166
+ }
5167
+ },
5168
+ { threshold: [...VISIBILITY_THRESHOLDS] }
5169
+ );
5170
+ observer.observe(node);
5171
+ return () => observer.disconnect();
5172
+ }, [requestPause]);
5173
+ React7__namespace.useEffect(() => {
5174
+ const onVisibility = () => {
5175
+ if (document.hidden) requestPause();
5176
+ };
5177
+ document.addEventListener("visibilitychange", onVisibility);
5178
+ return () => document.removeEventListener("visibilitychange", onVisibility);
5179
+ }, [requestPause]);
5180
+ const onPlayingChange = React7__namespace.useCallback(
5181
+ (playing) => {
5182
+ if (!playing) return;
5183
+ setForcePaused(false);
5184
+ claimFeedPlaying(playbackId);
5185
+ },
5186
+ [playbackId]
5187
+ );
5188
+ return {
5189
+ containerRef,
5190
+ paused: forcePaused,
5191
+ onPlayingChange
5192
+ };
5193
+ }
5194
+ function FeedVideoPlayer({
5195
+ playbackId,
5196
+ onPlayingChange,
5197
+ paused: pausedProp,
5198
+ ...playerProps
5199
+ }) {
5200
+ const {
5201
+ containerRef,
5202
+ paused: exclusivePaused,
5203
+ onPlayingChange: onExclusivePlayingChange
5204
+ } = useFeedExclusivePlayback(playbackId);
5205
+ const handlePlayingChange = React7__namespace.useCallback(
5206
+ (playing) => {
5207
+ onExclusivePlayingChange(playing);
5208
+ onPlayingChange?.(playing);
5209
+ },
5210
+ [onExclusivePlayingChange, onPlayingChange]
5211
+ );
5212
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, "data-slot": "feed-video-player", children: /* @__PURE__ */ jsxRuntime.jsx(
5213
+ VideoPlayer,
5214
+ {
5215
+ ...playerProps,
5216
+ paused: pausedProp || exclusivePaused,
5217
+ onPlayingChange: handlePlayingChange
5218
+ }
5219
+ ) });
5220
+ }
5115
5221
  function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
5116
5222
  const [stats, setStats] = React7__namespace.useState({});
5117
5223
  React7__namespace.useEffect(() => {
@@ -7769,6 +7875,7 @@ exports.EmptyState = EmptyState;
7769
7875
  exports.EmptyTitle = EmptyTitle;
7770
7876
  exports.ErrorState = ErrorState;
7771
7877
  exports.ExpandableText = ExpandableText;
7878
+ exports.FeedVideoPlayer = FeedVideoPlayer;
7772
7879
  exports.ImageLightbox = ImageLightbox;
7773
7880
  exports.LanguageContext = LanguageContext;
7774
7881
  exports.LanguageSwitcher = LanguageSwitcher;
@@ -7822,6 +7929,7 @@ exports.normalizeEmojiQuery = normalizeEmojiQuery;
7822
7929
  exports.shouldRetryLiveEdge404 = shouldRetryLiveEdge404;
7823
7930
  exports.useDebouncedValue = useDebouncedValue;
7824
7931
  exports.useDebouncedValueStrict = useDebouncedValueStrict;
7932
+ exports.useFeedExclusivePlayback = useFeedExclusivePlayback;
7825
7933
  exports.useHlsPlayback = useHlsPlayback;
7826
7934
  exports.useLanguageContext = useLanguageContext;
7827
7935
  exports.useMediaQuery = useMediaQuery2;