@hanifhan1f/vidstack-react 1.12.26 → 1.12.31

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.
Files changed (85) hide show
  1. package/dev/chunks/vidstack-3rdEWplD.js +189 -0
  2. package/dev/chunks/vidstack-BRTBRJ_I.js +288 -0
  3. package/dev/chunks/vidstack-BalWqr4j.js +1422 -0
  4. package/dev/chunks/vidstack-C56TjAKZ.js +61 -0
  5. package/dev/chunks/vidstack-C5tZAkKo.js +11694 -0
  6. package/dev/chunks/vidstack-CKsUl4ll.js +1384 -0
  7. package/dev/chunks/vidstack-CXjRKTos.js +401 -0
  8. package/dev/chunks/vidstack-C_xw7iZ2.js +34 -0
  9. package/dev/chunks/vidstack-CaaASbOf.js +476 -0
  10. package/dev/chunks/vidstack-CqNX679o.js +669 -0
  11. package/dev/chunks/vidstack-D2Bi2Td9.js +1537 -0
  12. package/dev/chunks/vidstack-D3ZXOE4d.js +643 -0
  13. package/dev/chunks/vidstack-D95QIbAo.js +551 -0
  14. package/dev/chunks/vidstack-DjqYvkVp.js +84 -0
  15. package/dev/chunks/vidstack-DnmOVAbr.js +643 -0
  16. package/dev/chunks/vidstack-Dnoefs4z.js +180 -0
  17. package/dev/chunks/vidstack-DqaqkU4T.js +9 -0
  18. package/dev/chunks/vidstack-FuCbl228.js +226 -0
  19. package/dev/chunks/vidstack-PREbBNMG.js +125 -0
  20. package/dev/chunks/vidstack-S_S6XDnL.js +375 -0
  21. package/dev/chunks/vidstack-gqKBE4xH.js +376 -0
  22. package/dev/chunks/vidstack-oOGofWSl.js +668 -0
  23. package/dev/chunks/vidstack-vh0BKYWJ.js +84 -0
  24. package/dev/player/vidstack-default-components.js +5 -5
  25. package/dev/player/vidstack-default-layout.js +5 -5
  26. package/dev/player/vidstack-plyr-layout.js +4 -4
  27. package/dev/player/vidstack-remotion.js +3 -3
  28. package/dev/vidstack.js +7 -7
  29. package/package.json +1 -1
  30. package/prod/chunks/vidstack-B0SSIHIv.js +1537 -0
  31. package/prod/chunks/vidstack-B3E9kXKq.js +34 -0
  32. package/prod/chunks/vidstack-BCBskRpc.js +664 -0
  33. package/prod/chunks/vidstack-BLWRqo3I.js +470 -0
  34. package/prod/chunks/vidstack-BXAOpsiW.js +61 -0
  35. package/prod/chunks/vidstack-BZVrgeRF.js +9 -0
  36. package/prod/chunks/vidstack-BzPma_p3.js +288 -0
  37. package/prod/chunks/vidstack-C48MQkXV.js +11199 -0
  38. package/prod/chunks/vidstack-CKBLQMZi.js +159 -0
  39. package/prod/chunks/vidstack-CKapDFwB.js +376 -0
  40. package/prod/chunks/vidstack-CYK75vJF.js +1382 -0
  41. package/prod/chunks/vidstack-CtxjO6HG.js +84 -0
  42. package/prod/chunks/vidstack-CwlfLr4v.js +504 -0
  43. package/prod/chunks/vidstack-D91K36KQ.js +206 -0
  44. package/prod/chunks/vidstack-DJThTSEm.js +125 -0
  45. package/prod/chunks/vidstack-DVMwXUgY.js +189 -0
  46. package/prod/chunks/vidstack-DXSNXDnS.js +1384 -0
  47. package/prod/chunks/vidstack-D_Sd7838.js +663 -0
  48. package/prod/chunks/vidstack-DdiGCJVp.js +504 -0
  49. package/prod/chunks/vidstack-DgsBXr1J.js +84 -0
  50. package/prod/chunks/vidstack-DhSvljmQ.js +375 -0
  51. package/prod/chunks/vidstack-DlPpeEXU.js +545 -0
  52. package/prod/chunks/vidstack-xwdT591E.js +386 -0
  53. package/prod/player/vidstack-default-components.js +5 -5
  54. package/prod/player/vidstack-default-layout.js +5 -5
  55. package/prod/player/vidstack-plyr-layout.js +4 -4
  56. package/prod/player/vidstack-remotion.js +3 -3
  57. package/prod/vidstack.js +7 -7
  58. package/server/chunks/vidstack--ufi23Q6.js +1537 -0
  59. package/server/chunks/vidstack-3hd9uS5U.js +386 -0
  60. package/server/chunks/vidstack-B4rJ1ZKK.js +376 -0
  61. package/server/chunks/vidstack-BTdEfKqV.js +84 -0
  62. package/server/chunks/vidstack-B_l_DXPI.js +61 -0
  63. package/server/chunks/vidstack-Bb44UuL8.js +470 -0
  64. package/server/chunks/vidstack-Bu9QXEz1.js +159 -0
  65. package/server/chunks/vidstack-Cb_tNfNU.js +11199 -0
  66. package/server/chunks/vidstack-D4t_SZbb.js +1416 -0
  67. package/server/chunks/vidstack-D9vUNwri.js +288 -0
  68. package/server/chunks/vidstack-DM-5dPT-.js +663 -0
  69. package/server/chunks/vidstack-DOIUveQF.js +504 -0
  70. package/server/chunks/vidstack-DWfS9vAY.js +84 -0
  71. package/server/chunks/vidstack-DY51lx0R.js +189 -0
  72. package/server/chunks/vidstack-DbNoKLjz.js +664 -0
  73. package/server/chunks/vidstack-DeS67_gx.js +9 -0
  74. package/server/chunks/vidstack-DiHlnSws.js +1384 -0
  75. package/server/chunks/vidstack-DnoqxmOs.js +125 -0
  76. package/server/chunks/vidstack-SkX-mSrw.js +206 -0
  77. package/server/chunks/vidstack-VGPw_CQP.js +375 -0
  78. package/server/chunks/vidstack-dz2TmHzm.js +34 -0
  79. package/server/chunks/vidstack-e0ZPAI-d.js +504 -0
  80. package/server/chunks/vidstack-zzooMghu.js +545 -0
  81. package/server/player/vidstack-default-components.js +5 -5
  82. package/server/player/vidstack-default-layout.js +5 -5
  83. package/server/player/vidstack-plyr-layout.js +4 -4
  84. package/server/player/vidstack-remotion.js +3 -3
  85. package/server/vidstack.js +7 -7
@@ -0,0 +1,180 @@
1
+ "use client"
2
+
3
+ import { IS_CHROME, IS_IOS, canGoogleCastSrc, IS_SERVER, loadScript } from './vidstack-C5tZAkKo.js';
4
+ import { listenEvent, peek } from './vidstack-D_bWd66h.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
+ {
43
+ switch (code) {
44
+ case chrome.cast.ErrorCode.API_NOT_INITIALIZED:
45
+ return "The API is not initialized.";
46
+ case chrome.cast.ErrorCode.CANCEL:
47
+ return "The operation was canceled by the user";
48
+ case chrome.cast.ErrorCode.CHANNEL_ERROR:
49
+ return "A channel to the receiver is not available.";
50
+ case chrome.cast.ErrorCode.EXTENSION_MISSING:
51
+ return "The Cast extension is not available.";
52
+ case chrome.cast.ErrorCode.INVALID_PARAMETER:
53
+ return "The parameters to the operation were not valid.";
54
+ case chrome.cast.ErrorCode.RECEIVER_UNAVAILABLE:
55
+ return "No receiver was compatible with the session request.";
56
+ case chrome.cast.ErrorCode.SESSION_ERROR:
57
+ return "A session could not be created, or a session was invalid.";
58
+ case chrome.cast.ErrorCode.TIMEOUT:
59
+ return "The operation timed out.";
60
+ default:
61
+ return defaultMessage;
62
+ }
63
+ }
64
+ }
65
+ function listenCastContextEvent(type, handler) {
66
+ return listenEvent(getCastContext(), type, handler);
67
+ }
68
+
69
+ class GoogleCastLoader {
70
+ name = "google-cast";
71
+ target;
72
+ #player;
73
+ /**
74
+ * @see {@link https://developers.google.com/cast/docs/reference/web_sender/cast.framework.CastContext}
75
+ */
76
+ get cast() {
77
+ return getCastContext();
78
+ }
79
+ mediaType() {
80
+ return "video";
81
+ }
82
+ canPlay(src) {
83
+ return IS_CHROME && !IS_IOS && canGoogleCastSrc(src);
84
+ }
85
+ async prompt(ctx) {
86
+ let loadEvent, openEvent, errorEvent;
87
+ try {
88
+ loadEvent = await this.#loadCastFramework(ctx);
89
+ if (!this.#player) {
90
+ this.#player = new cast.framework.RemotePlayer();
91
+ new cast.framework.RemotePlayerController(this.#player);
92
+ }
93
+ openEvent = ctx.player.createEvent("google-cast-prompt-open", {
94
+ trigger: loadEvent
95
+ });
96
+ ctx.player.dispatchEvent(openEvent);
97
+ this.#notifyRemoteStateChange(ctx, "connecting", openEvent);
98
+ await this.#showPrompt(peek(ctx.$props.googleCast));
99
+ ctx.$state.remotePlaybackInfo.set({
100
+ deviceName: getCastSession()?.getCastDevice().friendlyName
101
+ });
102
+ if (isCastConnected()) this.#notifyRemoteStateChange(ctx, "connected", openEvent);
103
+ } catch (code) {
104
+ const error = code instanceof Error ? code : this.#createError(
105
+ (code + "").toUpperCase(),
106
+ "Prompt failed."
107
+ );
108
+ errorEvent = ctx.player.createEvent("google-cast-prompt-error", {
109
+ detail: error,
110
+ trigger: openEvent ?? loadEvent,
111
+ cancelable: true
112
+ });
113
+ ctx.player.dispatch(errorEvent);
114
+ this.#notifyRemoteStateChange(
115
+ ctx,
116
+ isCastConnected() ? "connected" : "disconnected",
117
+ errorEvent
118
+ );
119
+ throw error;
120
+ } finally {
121
+ ctx.player.dispatch("google-cast-prompt-close", {
122
+ trigger: errorEvent ?? openEvent ?? loadEvent
123
+ });
124
+ }
125
+ }
126
+ async load(ctx) {
127
+ if (IS_SERVER) {
128
+ throw Error("[vidstack] can not load google cast provider server-side");
129
+ }
130
+ if (!this.#player) {
131
+ throw Error("[vidstack] google cast player was not initialized");
132
+ }
133
+ return new (await import('./vidstack-CaaASbOf.js')).GoogleCastProvider(this.#player, ctx);
134
+ }
135
+ async #loadCastFramework(ctx) {
136
+ if (hasLoadedCastFramework()) return;
137
+ const loadStartEvent = ctx.player.createEvent("google-cast-load-start");
138
+ ctx.player.dispatch(loadStartEvent);
139
+ await loadScript(getCastFrameworkURL());
140
+ await customElements.whenDefined("google-cast-launcher");
141
+ const loadedEvent = ctx.player.createEvent("google-cast-loaded", { trigger: loadStartEvent });
142
+ ctx.player.dispatch(loadedEvent);
143
+ if (!isCastAvailable()) {
144
+ throw this.#createError("CAST_NOT_AVAILABLE", "Google Cast not available on this platform.");
145
+ }
146
+ return loadedEvent;
147
+ }
148
+ async #showPrompt(options) {
149
+ this.#setOptions(options);
150
+ const errorCode = await this.cast.requestSession();
151
+ if (errorCode) {
152
+ throw this.#createError(
153
+ errorCode.toUpperCase(),
154
+ getCastErrorMessage(errorCode)
155
+ );
156
+ }
157
+ }
158
+ #setOptions(options) {
159
+ this.cast?.setOptions({
160
+ ...getDefaultCastOptions(),
161
+ ...options
162
+ });
163
+ }
164
+ #notifyRemoteStateChange(ctx, state, trigger) {
165
+ const detail = { type: "google-cast", state };
166
+ ctx.notify("remote-playback-change", detail, trigger);
167
+ }
168
+ #createError(code, message) {
169
+ const error = Error(message);
170
+ error.code = code;
171
+ return error;
172
+ }
173
+ }
174
+
175
+ var loader = /*#__PURE__*/Object.freeze({
176
+ __proto__: null,
177
+ GoogleCastLoader: GoogleCastLoader
178
+ });
179
+
180
+ export { getCastContext, getCastErrorMessage, getCastSession, getCastSessionMedia, hasActiveCastSession, listenCastContextEvent, loader };
@@ -0,0 +1,9 @@
1
+ "use client"
2
+
3
+ import { signal } from './vidstack-BalWqr4j.js';
4
+
5
+ const RemotionThumbnail = /* @__PURE__ */ signal(null);
6
+ const RemotionSliderThumbnail = /* @__PURE__ */ signal(null);
7
+ const RemotionPoster = /* @__PURE__ */ signal(null);
8
+
9
+ export { RemotionPoster, RemotionSliderThumbnail, RemotionThumbnail };
@@ -0,0 +1,226 @@
1
+ "use client"
2
+
3
+ import * as React from 'react';
4
+ import { composeRefs, useStateContext, useSignal, useSignalRecord } from './vidstack-BalWqr4j.js';
5
+ import { MediaPlayer, MediaAnnouncer, MediaProvider, Controls, ControlsGroup, Tooltip, TooltipTrigger, TooltipContent, ToggleButton, AirPlayButton, GoogleCastButton, PlayButton, CaptionButton, FullscreenButton, MuteButton, PIPButton, SeekButton, LiveButton, Slider, SliderValue, SliderPreview, VolumeSlider, QualitySlider, AudioGainSlider, SpeedSlider, Thumbnail, TimeSlider, SliderChapters, SliderThumbnail, SliderVideo, RadioGroup, Radio, Menu, MenuButton, MenuItems, MenuItem, Gesture, Captions, Poster, Time, MenuPortal, sliderState, mediaState } from 'vidstack';
6
+
7
+ class MediaPlayerInstance extends MediaPlayer {
8
+ }
9
+ class MediaProviderInstance extends MediaProvider {
10
+ }
11
+ class MediaAnnouncerInstance extends MediaAnnouncer {
12
+ }
13
+ class ControlsInstance extends Controls {
14
+ }
15
+ class ControlsGroupInstance extends ControlsGroup {
16
+ }
17
+ class ToggleButtonInstance extends ToggleButton {
18
+ }
19
+ class CaptionButtonInstance extends CaptionButton {
20
+ }
21
+ class FullscreenButtonInstance extends FullscreenButton {
22
+ }
23
+ class LiveButtonInstance extends LiveButton {
24
+ }
25
+ class MuteButtonInstance extends MuteButton {
26
+ }
27
+ class PIPButtonInstance extends PIPButton {
28
+ }
29
+ class PlayButtonInstance extends PlayButton {
30
+ }
31
+ class AirPlayButtonInstance extends AirPlayButton {
32
+ }
33
+ class GoogleCastButtonInstance extends GoogleCastButton {
34
+ }
35
+ class SeekButtonInstance extends SeekButton {
36
+ }
37
+ class TooltipInstance extends Tooltip {
38
+ }
39
+ class TooltipTriggerInstance extends TooltipTrigger {
40
+ }
41
+ class TooltipContentInstance extends TooltipContent {
42
+ }
43
+ class SliderInstance extends Slider {
44
+ }
45
+ class TimeSliderInstance extends TimeSlider {
46
+ }
47
+ class VolumeSliderInstance extends VolumeSlider {
48
+ }
49
+ class AudioGainSliderInstance extends AudioGainSlider {
50
+ }
51
+ class SpeedSliderInstance extends SpeedSlider {
52
+ }
53
+ class QualitySliderInstance extends QualitySlider {
54
+ }
55
+ class SliderThumbnailInstance extends SliderThumbnail {
56
+ }
57
+ class SliderValueInstance extends SliderValue {
58
+ }
59
+ class SliderVideoInstance extends SliderVideo {
60
+ }
61
+ class SliderPreviewInstance extends SliderPreview {
62
+ }
63
+ class SliderChaptersInstance extends SliderChapters {
64
+ }
65
+ class MenuInstance extends Menu {
66
+ }
67
+ class MenuButtonInstance extends MenuButton {
68
+ }
69
+ class MenuItemsInstance extends MenuItems {
70
+ }
71
+ class MenuItemInstance extends MenuItem {
72
+ }
73
+ class MenuPortalInstance extends MenuPortal {
74
+ }
75
+ class RadioGroupInstance extends RadioGroup {
76
+ }
77
+ class RadioInstance extends Radio {
78
+ }
79
+ class CaptionsInstance extends Captions {
80
+ }
81
+ class GestureInstance extends Gesture {
82
+ }
83
+ class PosterInstance extends Poster {
84
+ }
85
+ class ThumbnailInstance extends Thumbnail {
86
+ }
87
+ class TimeInstance extends Time {
88
+ }
89
+
90
+ const Slot = React.forwardRef((props, forwardedRef) => {
91
+ const { children, ...slotProps } = props;
92
+ const childrenArray = React.Children.toArray(children);
93
+ const slottable = childrenArray.find(isSlottable);
94
+ if (slottable) {
95
+ const newElement = slottable.props.children;
96
+ const newChildren = childrenArray.map((child) => {
97
+ if (child === slottable) {
98
+ if (React.Children.count(newElement) > 1) return React.Children.only(null);
99
+ return React.isValidElement(newElement) ? newElement.props.children : null;
100
+ } else {
101
+ return child;
102
+ }
103
+ });
104
+ return /* @__PURE__ */ React.createElement(SlotClone, { ...slotProps, ref: forwardedRef }, React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null);
105
+ }
106
+ return /* @__PURE__ */ React.createElement(SlotClone, { ...slotProps, ref: forwardedRef }, children);
107
+ });
108
+ Slot.displayName = "Slot";
109
+ const SlotClone = React.forwardRef((props, forwardedRef) => {
110
+ const { children, ...slotProps } = props;
111
+ if (React.isValidElement(children)) {
112
+ return React.cloneElement(children, {
113
+ ...mergeProps(slotProps, children.props),
114
+ ref: forwardedRef ? composeRefs(forwardedRef, children.ref) : children.ref
115
+ });
116
+ }
117
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
118
+ });
119
+ SlotClone.displayName = "SlotClone";
120
+ const Slottable = ({ children }) => {
121
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
122
+ };
123
+ function isSlottable(child) {
124
+ return React.isValidElement(child) && child.type === Slottable;
125
+ }
126
+ function mergeProps(slotProps, childProps) {
127
+ const overrideProps = { ...childProps };
128
+ for (const propName in childProps) {
129
+ const slotPropValue = slotProps[propName];
130
+ const childPropValue = childProps[propName];
131
+ const isHandler = /^on[A-Z]/.test(propName);
132
+ if (isHandler) {
133
+ if (slotPropValue && childPropValue) {
134
+ overrideProps[propName] = (...args) => {
135
+ childPropValue(...args);
136
+ slotPropValue(...args);
137
+ };
138
+ } else if (slotPropValue) {
139
+ overrideProps[propName] = slotPropValue;
140
+ }
141
+ } else if (propName === "style") {
142
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
143
+ } else if (propName === "className") {
144
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
145
+ }
146
+ }
147
+ return { ...slotProps, ...overrideProps };
148
+ }
149
+
150
+ const NODES = ["button", "div", "span", "img", "video", "audio"];
151
+ const Primitive = NODES.reduce((primitives, node) => {
152
+ const Node = React.forwardRef((props, forwardedRef) => {
153
+ const { asChild, ...primitiveProps } = props;
154
+ const Comp = asChild ? Slot : node;
155
+ return /* @__PURE__ */ React.createElement(Comp, { ...primitiveProps, ref: forwardedRef });
156
+ });
157
+ Node.displayName = `Primitive.${node}`;
158
+ return { ...primitives, [node]: Node };
159
+ }, {});
160
+
161
+ function isRemotionProvider(provider) {
162
+ return provider?.$$PROVIDER_TYPE === "REMOTION";
163
+ }
164
+ function isRemotionSrc(src) {
165
+ return src?.type === "video/remotion";
166
+ }
167
+
168
+ const sliderStateRecord = SliderInstance.state.record, initialSliderStore = Object.keys(sliderStateRecord).reduce(
169
+ (store, prop) => ({
170
+ ...store,
171
+ [prop]() {
172
+ return sliderStateRecord[prop];
173
+ }
174
+ }),
175
+ {}
176
+ );
177
+ function useSliderState(prop, ref) {
178
+ const $state = useStateContext(sliderState);
179
+ if (!$state && !ref) {
180
+ console.warn(
181
+ `[vidstack] \`useSliderState\` requires \`RefObject<SliderInstance>\` argument if called outside of a slider component`
182
+ );
183
+ }
184
+ return useSignal((ref?.current?.$state || $state || initialSliderStore)[prop]);
185
+ }
186
+ function useSliderStore(ref) {
187
+ const $state = useStateContext(sliderState);
188
+ if (!$state && !ref) {
189
+ console.warn(
190
+ `[vidstack] \`useSliderStore\` requires \`RefObject<SliderInstance>\` argument if called outside of a slider component`
191
+ );
192
+ }
193
+ return useSignalRecord(ref?.current ? ref.current.$state : $state || initialSliderStore);
194
+ }
195
+
196
+ const IS_SERVER = typeof document === "undefined";
197
+
198
+ const mediaStateRecord = MediaPlayerInstance.state.record, initialMediaStore = Object.keys(mediaStateRecord).reduce(
199
+ (store, prop) => ({
200
+ ...store,
201
+ [prop]() {
202
+ return mediaStateRecord[prop];
203
+ }
204
+ }),
205
+ {}
206
+ );
207
+ function useMediaState(prop, ref) {
208
+ const $state = useStateContext(mediaState);
209
+ if (!$state && !ref) {
210
+ console.warn(
211
+ `[vidstack] \`useMediaState\` requires \`RefObject<MediaPlayerInstance>\` argument if called outside the \`<MediaPlayer>\` component`
212
+ );
213
+ }
214
+ return useSignal((ref?.current?.$state || $state || initialMediaStore)[prop]);
215
+ }
216
+ function useMediaStore(ref) {
217
+ const $state = useStateContext(mediaState);
218
+ if (!$state && !ref) {
219
+ console.warn(
220
+ `[vidstack] \`useMediaStore\` requires \`RefObject<MediaPlayerInstance>\` argument if called outside the \`<MediaPlayer>\` component`
221
+ );
222
+ }
223
+ return useSignalRecord(ref?.current ? ref.current.$state : $state || initialMediaStore);
224
+ }
225
+
226
+ export { AirPlayButtonInstance, AudioGainSliderInstance, CaptionButtonInstance, CaptionsInstance, ControlsGroupInstance, ControlsInstance, FullscreenButtonInstance, GestureInstance, GoogleCastButtonInstance, IS_SERVER, LiveButtonInstance, MediaAnnouncerInstance, MediaPlayerInstance, MediaProviderInstance, MenuButtonInstance, MenuInstance, MenuItemInstance, MenuItemsInstance, MenuPortalInstance, MuteButtonInstance, PIPButtonInstance, PlayButtonInstance, PosterInstance, Primitive, QualitySliderInstance, RadioGroupInstance, RadioInstance, SeekButtonInstance, SliderChaptersInstance, SliderInstance, SliderPreviewInstance, SliderThumbnailInstance, SliderValueInstance, SliderVideoInstance, SpeedSliderInstance, ThumbnailInstance, TimeInstance, TimeSliderInstance, ToggleButtonInstance, TooltipContentInstance, TooltipInstance, TooltipTriggerInstance, VolumeSliderInstance, isRemotionProvider, isRemotionSrc, useMediaState, useMediaStore, useSliderState, useSliderStore };
@@ -0,0 +1,125 @@
1
+ "use client"
2
+
3
+ import * as React from 'react';
4
+ import { MediaRemoteControl, sortVideoQualities, DEFAULT_PLAYBACK_RATES } from 'vidstack';
5
+ import { MediaPlayerInstance } from './vidstack-FuCbl228.js';
6
+ import { useMediaContext } from './vidstack-CqNX679o.js';
7
+ import { useSignal, isString } from './vidstack-BalWqr4j.js';
8
+
9
+ function useMediaRemote(target) {
10
+ const media = useMediaContext(), remote = React.useRef(null);
11
+ if (!remote.current) {
12
+ remote.current = new MediaRemoteControl();
13
+ }
14
+ React.useEffect(() => {
15
+ const ref = target && "current" in target ? target.current : target, isPlayerRef = ref instanceof MediaPlayerInstance, player = isPlayerRef ? ref : media?.player;
16
+ remote.current.setPlayer(player ?? null);
17
+ remote.current.setTarget(ref ?? null);
18
+ }, [media, target && "current" in target ? target.current : target]);
19
+ return remote.current;
20
+ }
21
+
22
+ function useVideoQualityOptions({
23
+ auto = true,
24
+ sort = "descending"
25
+ } = {}) {
26
+ const media = useMediaContext(), { qualities, quality, autoQuality, canSetQuality } = media.$state, $qualities = useSignal(qualities);
27
+ useSignal(quality);
28
+ useSignal(autoQuality);
29
+ useSignal(canSetQuality);
30
+ return React.useMemo(() => {
31
+ const sortedQualities = sortVideoQualities($qualities, sort === "descending"), options = sortedQualities.map((q) => {
32
+ return {
33
+ quality: q,
34
+ label: q.height + "p",
35
+ value: getQualityValue(q),
36
+ bitrateText: q.bitrate && q.bitrate > 0 ? `${(q.bitrate / 1e6).toFixed(2)} Mbps` : null,
37
+ get selected() {
38
+ return q === quality();
39
+ },
40
+ get autoSelected() {
41
+ return autoQuality();
42
+ },
43
+ select(trigger) {
44
+ const index = qualities().indexOf(q);
45
+ if (index >= 0) media.remote.changeQuality(index, trigger);
46
+ }
47
+ };
48
+ });
49
+ if (auto) {
50
+ options.unshift({
51
+ quality: null,
52
+ label: isString(auto) ? auto : "Auto",
53
+ value: "auto",
54
+ bitrateText: null,
55
+ get selected() {
56
+ return autoQuality();
57
+ },
58
+ get autoSelected() {
59
+ return autoQuality();
60
+ },
61
+ select(trigger) {
62
+ media.remote.requestAutoQuality(trigger);
63
+ }
64
+ });
65
+ }
66
+ Object.defineProperty(options, "disabled", {
67
+ get() {
68
+ return !canSetQuality() || $qualities.length <= 1;
69
+ }
70
+ });
71
+ Object.defineProperty(options, "selectedQuality", {
72
+ get() {
73
+ return quality();
74
+ }
75
+ });
76
+ Object.defineProperty(options, "selectedValue", {
77
+ get() {
78
+ const $quality = quality();
79
+ return !autoQuality() && $quality ? getQualityValue($quality) : "auto";
80
+ }
81
+ });
82
+ return options;
83
+ }, [$qualities, sort]);
84
+ }
85
+ function getQualityValue(quality) {
86
+ return quality.height + "_" + quality.bitrate;
87
+ }
88
+
89
+ function usePlaybackRateOptions({
90
+ rates = DEFAULT_PLAYBACK_RATES,
91
+ normalLabel = "Normal"
92
+ } = {}) {
93
+ const media = useMediaContext(), { playbackRate, canSetPlaybackRate } = media.$state;
94
+ useSignal(playbackRate);
95
+ useSignal(canSetPlaybackRate);
96
+ return React.useMemo(() => {
97
+ const options = rates.map((opt) => {
98
+ const label = typeof opt === "number" ? opt === 1 && normalLabel ? normalLabel : opt + "x" : opt.label, rate = typeof opt === "number" ? opt : opt.rate;
99
+ return {
100
+ label,
101
+ value: rate.toString(),
102
+ rate,
103
+ get selected() {
104
+ return playbackRate() === rate;
105
+ },
106
+ select(trigger) {
107
+ media.remote.changePlaybackRate(rate, trigger);
108
+ }
109
+ };
110
+ });
111
+ Object.defineProperty(options, "disabled", {
112
+ get() {
113
+ return !canSetPlaybackRate() || !options.length;
114
+ }
115
+ });
116
+ Object.defineProperty(options, "selectedValue", {
117
+ get() {
118
+ return playbackRate().toString();
119
+ }
120
+ });
121
+ return options;
122
+ }, [rates]);
123
+ }
124
+
125
+ export { useMediaRemote, usePlaybackRateOptions, useVideoQualityOptions };