@hanifhan1f/vidstack-react 1.12.24 → 1.12.25
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/dev/chunks/vidstack-BNwnoM-l.js +84 -0
- package/dev/chunks/vidstack-BOPSNTgH.js +668 -0
- package/dev/chunks/vidstack-BSZY6sbC.js +180 -0
- package/dev/chunks/vidstack-BVVxkUlq.js +288 -0
- package/dev/chunks/vidstack-BXgKy_7V.js +11693 -0
- package/dev/chunks/vidstack-BrqDQG-r.js +643 -0
- package/dev/chunks/vidstack-C3QPOZNd.js +476 -0
- package/dev/chunks/vidstack-C7BwfK5c.js +1537 -0
- package/dev/chunks/vidstack-CEUjDh4x.js +34 -0
- package/dev/chunks/vidstack-CQSHFVu7.js +401 -0
- package/dev/chunks/vidstack-Csfg08VS.js +551 -0
- package/dev/chunks/vidstack-DTow20pt.js +189 -0
- package/dev/chunks/vidstack-L5mw2iPb.js +375 -0
- package/dev/chunks/vidstack-iRuTLfhk.js +61 -0
- package/dev/player/vidstack-default-components.js +5 -5
- package/dev/player/vidstack-default-layout.js +5 -5
- package/dev/player/vidstack-plyr-layout.js +4 -4
- package/dev/player/vidstack-remotion.js +3 -3
- package/dev/vidstack.js +7 -7
- package/package.json +1 -1
- package/prod/chunks/vidstack-58ZavMvv.js +159 -0
- package/prod/chunks/vidstack-BS445j5D.js +84 -0
- package/prod/chunks/vidstack-B_9VGrZQ.js +504 -0
- package/prod/chunks/vidstack-Bm2UemPE.js +470 -0
- package/prod/chunks/vidstack-Bp_hAwzI.js +61 -0
- package/prod/chunks/vidstack-CQll06Hv.js +34 -0
- package/prod/chunks/vidstack-D3cSYtez.js +663 -0
- package/prod/chunks/vidstack-D_ijTIbV.js +11198 -0
- package/prod/chunks/vidstack-DgGDsAKh.js +375 -0
- package/prod/chunks/vidstack-DrEorv9m.js +189 -0
- package/prod/chunks/vidstack-ehqxnvc9.js +1537 -0
- package/prod/chunks/vidstack-lc8NHly9.js +288 -0
- package/prod/chunks/vidstack-rKV98aQH.js +545 -0
- package/prod/chunks/vidstack-uA7h-Bsq.js +386 -0
- package/prod/player/vidstack-default-components.js +5 -5
- package/prod/player/vidstack-default-layout.js +5 -5
- package/prod/player/vidstack-plyr-layout.js +4 -4
- package/prod/player/vidstack-remotion.js +3 -3
- package/prod/vidstack.js +7 -7
- package/server/chunks/vidstack-B3AXUfgF.js +189 -0
- package/server/chunks/vidstack-BJCx78pm.js +386 -0
- package/server/chunks/vidstack-BtitkRvR.js +11198 -0
- package/server/chunks/vidstack-BweZhuNd.js +1537 -0
- package/server/chunks/vidstack-CSiPajWY.js +470 -0
- package/server/chunks/vidstack-CgXa6YO3.js +61 -0
- package/server/chunks/vidstack-DH6N0AoF.js +375 -0
- package/server/chunks/vidstack-DKr7br9D.js +34 -0
- package/server/chunks/vidstack-Dbs_rXUT.js +663 -0
- package/server/chunks/vidstack-E7eUOyFt.js +288 -0
- package/server/chunks/vidstack-JkJEYEQM.js +159 -0
- package/server/chunks/vidstack-KhtuR229.js +504 -0
- package/server/chunks/vidstack-X1Hex9PH.js +84 -0
- package/server/chunks/vidstack-yf18YVAb.js +545 -0
- package/server/player/vidstack-default-components.js +5 -5
- package/server/player/vidstack-default-layout.js +5 -5
- package/server/player/vidstack-plyr-layout.js +4 -4
- package/server/player/vidstack-remotion.js +3 -3
- package/server/vidstack.js +7 -7
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { createDisposalBin, animationFrameThrottle, noop } from '../chunks/vidstack-D_bWd66h.js';
|
|
5
5
|
import { Internals, random } from 'remotion';
|
|
6
|
-
import { IS_SERVER, useMediaState, isRemotionSrc, Primitive, useSliderState } from '../chunks/vidstack-
|
|
7
|
-
export { isRemotionProvider } from '../chunks/vidstack-
|
|
6
|
+
import { IS_SERVER, useMediaState, isRemotionSrc, Primitive, useSliderState } from '../chunks/vidstack-BXgKy_7V.js';
|
|
7
|
+
export { isRemotionProvider } from '../chunks/vidstack-BXgKy_7V.js';
|
|
8
8
|
import { RemotionThumbnail as RemotionThumbnail$1, RemotionSliderThumbnail as RemotionSliderThumbnail$1, RemotionPoster as RemotionPoster$1 } from '../chunks/vidstack-D-hQD1eE.js';
|
|
9
9
|
import '@floating-ui/dom';
|
|
10
10
|
|
|
@@ -338,7 +338,7 @@ class RemotionProviderLoader {
|
|
|
338
338
|
return "video";
|
|
339
339
|
}
|
|
340
340
|
async load(ctx) {
|
|
341
|
-
return new (await import('../chunks/vidstack-
|
|
341
|
+
return new (await import('../chunks/vidstack-BrqDQG-r.js')).RemotionProvider(this.target, ctx);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
|
package/dev/vidstack.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { TextTrackSymbol, RadioGroupController, useMediaContext, menuContext, Primitive, MediaPlayerInstance, MediaProviderInstance, isRemotionProvider, mediaState, TextTrack, ToggleButtonInstance, PosterInstance, useMediaState, ThumbnailsLoader, updateSliderPreviewPlacement } from './chunks/vidstack-
|
|
4
|
-
export { ARIAKeyShortcuts, AUDIO_EXTENSIONS, AUDIO_TYPES, AirPlayButtonInstance, AudioGainSliderInstance, AudioProviderLoader, AudioTrackList, CaptionButtonInstance, CaptionsInstance, ControlsGroupInstance, ControlsInstance, DASHProviderLoader, DASH_VIDEO_EXTENSIONS, DASH_VIDEO_TYPES, FullscreenButtonInstance, FullscreenController, GestureInstance, GoogleCastButtonInstance, HLSProviderLoader, HLS_VIDEO_EXTENSIONS, HLS_VIDEO_TYPES, List, LiveButtonInstance, LocalMediaStorage, Logger, MEDIA_KEY_SHORTCUTS, MediaAnnouncerInstance, MediaControls, MediaRemoteControl, MenuButtonInstance, MenuInstance, MenuItemInstance, MenuItemsInstance, MenuPortalInstance, MuteButtonInstance, PIPButtonInstance, PlayButtonInstance, QualitySliderInstance, RadioGroupInstance, RadioInstance, ScreenOrientationController, SeekButtonInstance, SliderChaptersInstance, SliderInstance, SliderPreviewInstance, SliderThumbnailInstance, SliderValueInstance, SliderVideoInstance, SpeedSliderInstance, TextRenderers, TextTrackList, ThumbnailInstance, TimeInstance, TimeRange, TimeSliderInstance, TooltipContentInstance, TooltipInstance, TooltipTriggerInstance, VIDEO_EXTENSIONS, VIDEO_TYPES, VideoProviderLoader, VideoQualityList, VimeoProviderLoader, VolumeSliderInstance, YouTubeProviderLoader, boundTime, canChangeVolume, canFullscreen, canGoogleCastSrc, canOrientScreen, canPlayHLSNatively, canRotateScreen, canUsePictureInPicture, canUseVideoPresentation, findActiveCue, formatSpokenTime, formatTime, getDownloadFile, getTimeRangesEnd, getTimeRangesStart, isAudioProvider, isAudioSrc, isCueActive, isDASHProvider, isDASHSrc, isGoogleCastProvider, isHLSProvider, isHLSSrc, isHTMLAudioElement, isHTMLIFrameElement, isHTMLMediaElement, isHTMLVideoElement, isMediaStream, isTrackCaptionKind, isVideoProvider, isVideoQualitySrc, isVideoSrc, isVimeoProvider, isYouTubeProvider, mediaContext, normalizeTimeIntervals, parseJSONCaptionsFile, sliderState, softResetMediaState, sortVideoQualities, updateTimeIntervals, useMediaStore, useSliderState, useSliderStore, watchActiveTextTrack, watchCueTextChange } from './chunks/vidstack-
|
|
3
|
+
import { TextTrackSymbol, RadioGroupController, useMediaContext, menuContext, Primitive, MediaPlayerInstance, MediaProviderInstance, isRemotionProvider, mediaState, TextTrack, ToggleButtonInstance, PosterInstance, useMediaState, ThumbnailsLoader, updateSliderPreviewPlacement } from './chunks/vidstack-BXgKy_7V.js';
|
|
4
|
+
export { ARIAKeyShortcuts, AUDIO_EXTENSIONS, AUDIO_TYPES, AirPlayButtonInstance, AudioGainSliderInstance, AudioProviderLoader, AudioTrackList, CaptionButtonInstance, CaptionsInstance, ControlsGroupInstance, ControlsInstance, DASHProviderLoader, DASH_VIDEO_EXTENSIONS, DASH_VIDEO_TYPES, FullscreenButtonInstance, FullscreenController, GestureInstance, GoogleCastButtonInstance, HLSProviderLoader, HLS_VIDEO_EXTENSIONS, HLS_VIDEO_TYPES, List, LiveButtonInstance, LocalMediaStorage, Logger, MEDIA_KEY_SHORTCUTS, MediaAnnouncerInstance, MediaControls, MediaRemoteControl, MenuButtonInstance, MenuInstance, MenuItemInstance, MenuItemsInstance, MenuPortalInstance, MuteButtonInstance, PIPButtonInstance, PlayButtonInstance, QualitySliderInstance, RadioGroupInstance, RadioInstance, ScreenOrientationController, SeekButtonInstance, SliderChaptersInstance, SliderInstance, SliderPreviewInstance, SliderThumbnailInstance, SliderValueInstance, SliderVideoInstance, SpeedSliderInstance, TextRenderers, TextTrackList, ThumbnailInstance, TimeInstance, TimeRange, TimeSliderInstance, TooltipContentInstance, TooltipInstance, TooltipTriggerInstance, VIDEO_EXTENSIONS, VIDEO_TYPES, VideoProviderLoader, VideoQualityList, VimeoProviderLoader, VolumeSliderInstance, YouTubeProviderLoader, boundTime, canChangeVolume, canFullscreen, canGoogleCastSrc, canOrientScreen, canPlayHLSNatively, canRotateScreen, canUsePictureInPicture, canUseVideoPresentation, findActiveCue, formatSpokenTime, formatTime, getDownloadFile, getTimeRangesEnd, getTimeRangesStart, isAudioProvider, isAudioSrc, isCueActive, isDASHProvider, isDASHSrc, isGoogleCastProvider, isHLSProvider, isHLSSrc, isHTMLAudioElement, isHTMLIFrameElement, isHTMLMediaElement, isHTMLVideoElement, isMediaStream, isTrackCaptionKind, isVideoProvider, isVideoQualitySrc, isVideoSrc, isVimeoProvider, isYouTubeProvider, mediaContext, normalizeTimeIntervals, parseJSONCaptionsFile, sliderState, softResetMediaState, sortVideoQualities, updateTimeIntervals, useMediaStore, useSliderState, useSliderStore, watchActiveTextTrack, watchCueTextChange } from './chunks/vidstack-BXgKy_7V.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { isString, EventsController, DOMEvent, prop, method, Component, hasProvidedContext, useContext, effect, createReactComponent, useStateContext, useSignal, composeRefs, useSignalRecord, useReactScope, signal } from './chunks/vidstack-D_bWd66h.js';
|
|
7
7
|
export { appendTriggerEvent, findTriggerEvent, hasTriggerEvent, isKeyboardClick, isKeyboardEvent, isPointerEvent, walkTriggerEventChain } from './chunks/vidstack-D_bWd66h.js';
|
|
8
|
-
import { createSignal, useScoped } from './chunks/vidstack-
|
|
9
|
-
export { audioGainSlider as AudioGainSlider, Captions, ChapterTitle, controls as Controls, GoogleCastButton, MediaAnnouncer, qualitySlider as QualitySlider, speedSlider as SpeedSlider, spinner as Spinner, Title, tooltip as Tooltip, useActiveTextCues, useActiveTextTrack, useChapterOptions, useChapterTitle, useTextCues } from './chunks/vidstack-
|
|
10
|
-
import { useMediaContext as useMediaContext$1 } from './chunks/vidstack-
|
|
11
|
-
export { AirPlayButton, CaptionButton, FullscreenButton, Gesture, LiveButton, menu as Menu, MuteButton, PIPButton, PlayButton, radioGroup as RadioGroup, SeekButton, slider as Slider, thumbnail as Thumbnail, Time, timeSlider as TimeSlider, volumeSlider as VolumeSlider, useAudioOptions, useCaptionOptions, useMediaPlayer } from './chunks/vidstack-
|
|
8
|
+
import { createSignal, useScoped } from './chunks/vidstack-L5mw2iPb.js';
|
|
9
|
+
export { audioGainSlider as AudioGainSlider, Captions, ChapterTitle, controls as Controls, GoogleCastButton, MediaAnnouncer, qualitySlider as QualitySlider, speedSlider as SpeedSlider, spinner as Spinner, Title, tooltip as Tooltip, useActiveTextCues, useActiveTextTrack, useChapterOptions, useChapterTitle, useTextCues } from './chunks/vidstack-L5mw2iPb.js';
|
|
10
|
+
import { useMediaContext as useMediaContext$1 } from './chunks/vidstack-BOPSNTgH.js';
|
|
11
|
+
export { AirPlayButton, CaptionButton, FullscreenButton, Gesture, LiveButton, menu as Menu, MuteButton, PIPButton, PlayButton, radioGroup as RadioGroup, SeekButton, slider as Slider, thumbnail as Thumbnail, Time, timeSlider as TimeSlider, volumeSlider as VolumeSlider, useAudioOptions, useCaptionOptions, useMediaPlayer } from './chunks/vidstack-BOPSNTgH.js';
|
|
12
12
|
import { Icon } from './chunks/vidstack-CBF7iUqu.js';
|
|
13
|
-
export { DEFAULT_PLAYBACK_RATES, useMediaRemote, usePlaybackRateOptions, useVideoQualityOptions } from './chunks/vidstack-
|
|
13
|
+
export { DEFAULT_PLAYBACK_RATES, useMediaRemote, usePlaybackRateOptions, useVideoQualityOptions } from './chunks/vidstack-DTow20pt.js';
|
|
14
14
|
import '@floating-ui/dom';
|
|
15
15
|
import 'react-dom';
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanifhan1f/vidstack-react",
|
|
3
3
|
"description": "UI component library for building high-quality, accessible video and audio experiences on the web.",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.25",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "index.d.ts",
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { IS_CHROME, IS_IOS, canGoogleCastSrc, IS_SERVER, loadScript } from './vidstack-D_ijTIbV.js';
|
|
4
|
+
import { listenEvent, peek } from './vidstack-CZgUA94N.js';
|
|
5
|
+
|
|
6
|
+
function getCastFrameworkURL() {
|
|
7
|
+
return "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
|
|
8
|
+
}
|
|
9
|
+
function hasLoadedCastFramework() {
|
|
10
|
+
return !!window.cast?.framework;
|
|
11
|
+
}
|
|
12
|
+
function isCastAvailable() {
|
|
13
|
+
return !!window.chrome?.cast?.isAvailable;
|
|
14
|
+
}
|
|
15
|
+
function isCastConnected() {
|
|
16
|
+
return getCastContext().getCastState() === cast.framework.CastState.CONNECTED;
|
|
17
|
+
}
|
|
18
|
+
function getCastContext() {
|
|
19
|
+
return window.cast.framework.CastContext.getInstance();
|
|
20
|
+
}
|
|
21
|
+
function getCastSession() {
|
|
22
|
+
return getCastContext().getCurrentSession();
|
|
23
|
+
}
|
|
24
|
+
function getCastSessionMedia() {
|
|
25
|
+
return getCastSession()?.getSessionObj().media[0];
|
|
26
|
+
}
|
|
27
|
+
function hasActiveCastSession(src) {
|
|
28
|
+
const contentId = getCastSessionMedia()?.media.contentId;
|
|
29
|
+
return contentId === src?.src;
|
|
30
|
+
}
|
|
31
|
+
function getDefaultCastOptions() {
|
|
32
|
+
return {
|
|
33
|
+
language: "en-US",
|
|
34
|
+
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
|
|
35
|
+
receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
|
|
36
|
+
resumeSavedSession: true,
|
|
37
|
+
androidReceiverCompatible: true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function getCastErrorMessage(code) {
|
|
41
|
+
const defaultMessage = `Google Cast Error Code: ${code}`;
|
|
42
|
+
return defaultMessage;
|
|
43
|
+
}
|
|
44
|
+
function listenCastContextEvent(type, handler) {
|
|
45
|
+
return listenEvent(getCastContext(), type, handler);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class GoogleCastLoader {
|
|
49
|
+
name = "google-cast";
|
|
50
|
+
target;
|
|
51
|
+
#player;
|
|
52
|
+
/**
|
|
53
|
+
* @see {@link https://developers.google.com/cast/docs/reference/web_sender/cast.framework.CastContext}
|
|
54
|
+
*/
|
|
55
|
+
get cast() {
|
|
56
|
+
return getCastContext();
|
|
57
|
+
}
|
|
58
|
+
mediaType() {
|
|
59
|
+
return "video";
|
|
60
|
+
}
|
|
61
|
+
canPlay(src) {
|
|
62
|
+
return IS_CHROME && !IS_IOS && canGoogleCastSrc(src);
|
|
63
|
+
}
|
|
64
|
+
async prompt(ctx) {
|
|
65
|
+
let loadEvent, openEvent, errorEvent;
|
|
66
|
+
try {
|
|
67
|
+
loadEvent = await this.#loadCastFramework(ctx);
|
|
68
|
+
if (!this.#player) {
|
|
69
|
+
this.#player = new cast.framework.RemotePlayer();
|
|
70
|
+
new cast.framework.RemotePlayerController(this.#player);
|
|
71
|
+
}
|
|
72
|
+
openEvent = ctx.player.createEvent("google-cast-prompt-open", {
|
|
73
|
+
trigger: loadEvent
|
|
74
|
+
});
|
|
75
|
+
ctx.player.dispatchEvent(openEvent);
|
|
76
|
+
this.#notifyRemoteStateChange(ctx, "connecting", openEvent);
|
|
77
|
+
await this.#showPrompt(peek(ctx.$props.googleCast));
|
|
78
|
+
ctx.$state.remotePlaybackInfo.set({
|
|
79
|
+
deviceName: getCastSession()?.getCastDevice().friendlyName
|
|
80
|
+
});
|
|
81
|
+
if (isCastConnected()) this.#notifyRemoteStateChange(ctx, "connected", openEvent);
|
|
82
|
+
} catch (code) {
|
|
83
|
+
const error = code instanceof Error ? code : this.#createError(
|
|
84
|
+
(code + "").toUpperCase(),
|
|
85
|
+
"Prompt failed."
|
|
86
|
+
);
|
|
87
|
+
errorEvent = ctx.player.createEvent("google-cast-prompt-error", {
|
|
88
|
+
detail: error,
|
|
89
|
+
trigger: openEvent ?? loadEvent,
|
|
90
|
+
cancelable: true
|
|
91
|
+
});
|
|
92
|
+
ctx.player.dispatch(errorEvent);
|
|
93
|
+
this.#notifyRemoteStateChange(
|
|
94
|
+
ctx,
|
|
95
|
+
isCastConnected() ? "connected" : "disconnected",
|
|
96
|
+
errorEvent
|
|
97
|
+
);
|
|
98
|
+
throw error;
|
|
99
|
+
} finally {
|
|
100
|
+
ctx.player.dispatch("google-cast-prompt-close", {
|
|
101
|
+
trigger: errorEvent ?? openEvent ?? loadEvent
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async load(ctx) {
|
|
106
|
+
if (IS_SERVER) {
|
|
107
|
+
throw Error("[vidstack] can not load google cast provider server-side");
|
|
108
|
+
}
|
|
109
|
+
if (!this.#player) {
|
|
110
|
+
throw Error("[vidstack] google cast player was not initialized");
|
|
111
|
+
}
|
|
112
|
+
return new (await import('./vidstack-Bm2UemPE.js')).GoogleCastProvider(this.#player, ctx);
|
|
113
|
+
}
|
|
114
|
+
async #loadCastFramework(ctx) {
|
|
115
|
+
if (hasLoadedCastFramework()) return;
|
|
116
|
+
const loadStartEvent = ctx.player.createEvent("google-cast-load-start");
|
|
117
|
+
ctx.player.dispatch(loadStartEvent);
|
|
118
|
+
await loadScript(getCastFrameworkURL());
|
|
119
|
+
await customElements.whenDefined("google-cast-launcher");
|
|
120
|
+
const loadedEvent = ctx.player.createEvent("google-cast-loaded", { trigger: loadStartEvent });
|
|
121
|
+
ctx.player.dispatch(loadedEvent);
|
|
122
|
+
if (!isCastAvailable()) {
|
|
123
|
+
throw this.#createError("CAST_NOT_AVAILABLE", "Google Cast not available on this platform.");
|
|
124
|
+
}
|
|
125
|
+
return loadedEvent;
|
|
126
|
+
}
|
|
127
|
+
async #showPrompt(options) {
|
|
128
|
+
this.#setOptions(options);
|
|
129
|
+
const errorCode = await this.cast.requestSession();
|
|
130
|
+
if (errorCode) {
|
|
131
|
+
throw this.#createError(
|
|
132
|
+
errorCode.toUpperCase(),
|
|
133
|
+
getCastErrorMessage(errorCode)
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
#setOptions(options) {
|
|
138
|
+
this.cast?.setOptions({
|
|
139
|
+
...getDefaultCastOptions(),
|
|
140
|
+
...options
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
#notifyRemoteStateChange(ctx, state, trigger) {
|
|
144
|
+
const detail = { type: "google-cast", state };
|
|
145
|
+
ctx.notify("remote-playback-change", detail, trigger);
|
|
146
|
+
}
|
|
147
|
+
#createError(code, message) {
|
|
148
|
+
const error = Error(message);
|
|
149
|
+
error.code = code;
|
|
150
|
+
return error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
var loader = /*#__PURE__*/Object.freeze({
|
|
155
|
+
__proto__: null,
|
|
156
|
+
GoogleCastLoader: GoogleCastLoader
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export { getCastContext, getCastErrorMessage, getCastSession, getCastSessionMedia, hasActiveCastSession, listenCastContextEvent, loader };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { listenEvent, EventsController, animationFrameThrottle, effect } from './vidstack-CZgUA94N.js';
|
|
5
|
+
import { useMediaPlayer } from './vidstack-D3cSYtez.js';
|
|
6
|
+
|
|
7
|
+
function useClassName(el, className) {
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
if (!el || !className) return;
|
|
10
|
+
const tokens = className.split(" ");
|
|
11
|
+
for (const token of tokens) el.classList.add(token);
|
|
12
|
+
return () => {
|
|
13
|
+
for (const token of tokens) el.classList.remove(token);
|
|
14
|
+
};
|
|
15
|
+
}, [el, className]);
|
|
16
|
+
}
|
|
17
|
+
function useResizeObserver(el, callback) {
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
if (!el) return;
|
|
20
|
+
callback();
|
|
21
|
+
const observer = new ResizeObserver(animationFrameThrottle(callback));
|
|
22
|
+
observer.observe(el);
|
|
23
|
+
return () => observer.disconnect();
|
|
24
|
+
}, [el, callback]);
|
|
25
|
+
}
|
|
26
|
+
function useTransitionActive(el) {
|
|
27
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
if (!el) return;
|
|
30
|
+
const events = new EventsController(el).add("transitionstart", () => setIsActive(true)).add("transitionend", () => setIsActive(false));
|
|
31
|
+
return () => events.abort();
|
|
32
|
+
}, [el]);
|
|
33
|
+
return isActive;
|
|
34
|
+
}
|
|
35
|
+
function useMouseEnter(el) {
|
|
36
|
+
const [isMouseEnter, setIsMouseEnter] = React.useState(false);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (!el) return;
|
|
39
|
+
const events = new EventsController(el).add("mouseenter", () => setIsMouseEnter(true)).add("mouseleave", () => setIsMouseEnter(false));
|
|
40
|
+
return () => events.abort();
|
|
41
|
+
}, [el]);
|
|
42
|
+
return isMouseEnter;
|
|
43
|
+
}
|
|
44
|
+
function useFocusIn(el) {
|
|
45
|
+
const [isFocusIn, setIsFocusIn] = React.useState(false);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (!el) return;
|
|
48
|
+
const events = new EventsController(el).add("focusin", () => setIsFocusIn(true)).add("focusout", () => setIsFocusIn(false));
|
|
49
|
+
return () => events.abort();
|
|
50
|
+
}, [el]);
|
|
51
|
+
return isFocusIn;
|
|
52
|
+
}
|
|
53
|
+
function useActive(el) {
|
|
54
|
+
const isMouseEnter = useMouseEnter(el), isFocusIn = useFocusIn(el), prevMouseEnter = React.useRef(false);
|
|
55
|
+
if (prevMouseEnter.current && !isMouseEnter) return false;
|
|
56
|
+
prevMouseEnter.current = isMouseEnter;
|
|
57
|
+
return isMouseEnter || isFocusIn;
|
|
58
|
+
}
|
|
59
|
+
function useColorSchemePreference() {
|
|
60
|
+
const [colorScheme, setColorScheme] = React.useState("dark");
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
const media = window.matchMedia("(prefers-color-scheme: light)");
|
|
63
|
+
function onChange() {
|
|
64
|
+
setColorScheme(media.matches ? "light" : "dark");
|
|
65
|
+
}
|
|
66
|
+
onChange();
|
|
67
|
+
return listenEvent(media, "change", onChange);
|
|
68
|
+
}, []);
|
|
69
|
+
return colorScheme;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function useLayoutName(name) {
|
|
73
|
+
const player = useMediaPlayer();
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
if (!player) return;
|
|
76
|
+
return effect(() => {
|
|
77
|
+
const el = player.$el;
|
|
78
|
+
el?.setAttribute("data-layout", name);
|
|
79
|
+
return () => el?.removeAttribute("data-layout");
|
|
80
|
+
});
|
|
81
|
+
}, [player]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { useActive, useClassName, useColorSchemePreference, useLayoutName, useResizeObserver, useTransitionActive };
|